Files
twosugar d83d52b73d feat(migrate): port TryIt (interactive API caller) to React workspace
Sprint 2 §S7. Ports legacy TryIt (9 vue files under
`docs/.vitepress/theme/components/TryIt/` + `theme/utils/{http-client,
websocket-client}.ts`) to React inside a new `packages/tryit` workspace
published as `@longbridge/openapi-tryit`. Uses react-hook-form for
form generation from openapi schema; fires real API requests against
`openapi.longportapp.com`.

Files created:
- packages/tryit/package.json — bun workspace, deps: react-hook-form,
  @longbridge/openapi-utils, @longbridge/openapi-api-reference
- packages/tryit/tsconfig.json
- packages/tryit/src/index.ts — barrel
- packages/tryit/src/TryIt.tsx — orchestrator: button mode → panel mode,
  data-lbus-component="tryit" preserved
- packages/tryit/src/AuthorizationForm.tsx — cookie/localStorage-backed
  appKey / appSecret / accessToken inputs
- packages/tryit/src/ParametersForm.tsx — walks op parameters + request
  body via SchemaRenderer
- packages/tryit/src/PlayButton.tsx — assembles request, dispatches via
  clients
- packages/tryit/src/ResponseView.tsx — pretty-prints JSON response
- packages/tryit/src/tryit.css — form + response viewer styles
- packages/tryit/src/clients/http-client.ts — verbatim port of legacy
- packages/tryit/src/clients/websocket-client.ts — verbatim port of legacy
- packages/tryit/src/utils/app-id.ts — id derivation
- packages/tryit/src/utils/request.ts — request assembly helper
- packages/tryit/src/hooks/useTryItMode.ts — `?mode=try-it` URL toggle
- packages/tryit/src/hooks/useAuthorization.ts — cookie sync
- packages/tryit/src/hooks/useResponse.ts — response state

Modified:
- src/mdx-components.tsx — swap import from placeholder to
  `@longbridge/openapi-tryit`
- root package.json — workspace dep

Deleted:
- src/components/mdx/placeholders/TryIt.tsx

Verified:
- astro check: 0 errors (0 new warnings)
- All 15 canonical URLs return 200
- `<TryIt />` registered in mdx-components; mount site (frontmatter
  `httpInfo` or explicit tag) is handled by later plumbing

Closes Sprint 2 §S7.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-08-19 01:26:53 +08:00

18 lines
405 B
JSON

{
"name": "@longbridge/openapi-tryit",
"version": "0.0.0",
"private": true,
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts",
"./src/tryit.css": "./src/tryit.css"
},
"dependencies": {
"react-hook-form": "^7",
"@longbridge/openapi-utils": "workspace:*",
"@longbridge/openapi-api-reference": "workspace:*"
}
}