@ttsc/playground 0.14.0-dev.20260528.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +230 -0
  3. package/lib/src/compiler/DEFAULT_ENTRY_FILE.d.ts +2 -0
  4. package/lib/src/compiler/DEFAULT_ENTRY_FILE.js +6 -0
  5. package/lib/src/compiler/DEFAULT_ENTRY_FILE.js.map +1 -0
  6. package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.d.ts +5 -0
  7. package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.js +9 -0
  8. package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.js.map +1 -0
  9. package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.d.ts +19 -0
  10. package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.js +23 -0
  11. package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.js.map +1 -0
  12. package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.d.ts +2 -0
  13. package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.js +6 -0
  14. package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.js.map +1 -0
  15. package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.d.ts +6 -0
  16. package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.js +10 -0
  17. package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.js.map +1 -0
  18. package/lib/src/compiler/DEFAULT_WORK_DIR.d.ts +2 -0
  19. package/lib/src/compiler/DEFAULT_WORK_DIR.js +6 -0
  20. package/lib/src/compiler/DEFAULT_WORK_DIR.js.map +1 -0
  21. package/lib/src/compiler/buildTsconfigJSON.d.ts +9 -0
  22. package/lib/src/compiler/buildTsconfigJSON.js +24 -0
  23. package/lib/src/compiler/buildTsconfigJSON.js.map +1 -0
  24. package/lib/src/compiler/createTypiaSourcePackMount.d.ts +11 -0
  25. package/lib/src/compiler/createTypiaSourcePackMount.js +29 -0
  26. package/lib/src/compiler/createTypiaSourcePackMount.js.map +1 -0
  27. package/lib/src/compiler/createWorkerCompiler.d.ts +25 -0
  28. package/lib/src/compiler/createWorkerCompiler.js +227 -0
  29. package/lib/src/compiler/createWorkerCompiler.js.map +1 -0
  30. package/lib/src/compiler/installDependenciesIntoMemFS.d.ts +12 -0
  31. package/lib/src/compiler/installDependenciesIntoMemFS.js +25 -0
  32. package/lib/src/compiler/installDependenciesIntoMemFS.js.map +1 -0
  33. package/lib/src/compiler/installTypiaSourcePack.d.ts +11 -0
  34. package/lib/src/compiler/installTypiaSourcePack.js +21 -0
  35. package/lib/src/compiler/installTypiaSourcePack.js.map +1 -0
  36. package/lib/src/compiler/internal/joinUnder.d.ts +2 -0
  37. package/lib/src/compiler/internal/joinUnder.js +10 -0
  38. package/lib/src/compiler/internal/joinUnder.js.map +1 -0
  39. package/lib/src/compiler/internal/parseLintDiagnostics.d.ts +6 -0
  40. package/lib/src/compiler/internal/parseLintDiagnostics.js +57 -0
  41. package/lib/src/compiler/internal/parseLintDiagnostics.js.map +1 -0
  42. package/lib/src/compiler/internal/safeParseTypiaTransform.d.ts +11 -0
  43. package/lib/src/compiler/internal/safeParseTypiaTransform.js +21 -0
  44. package/lib/src/compiler/internal/safeParseTypiaTransform.js.map +1 -0
  45. package/lib/src/compiler/lineColumnOf.d.ts +5 -0
  46. package/lib/src/compiler/lineColumnOf.js +15 -0
  47. package/lib/src/compiler/lineColumnOf.js.map +1 -0
  48. package/lib/src/compiler/loadTypiaSourcePack.d.ts +8 -0
  49. package/lib/src/compiler/loadTypiaSourcePack.js +33 -0
  50. package/lib/src/compiler/loadTypiaSourcePack.js.map +1 -0
  51. package/lib/src/compiler/mapDiagnostic.d.ts +9 -0
  52. package/lib/src/compiler/mapDiagnostic.js +22 -0
  53. package/lib/src/compiler/mapDiagnostic.js.map +1 -0
  54. package/lib/src/compiler/normalizeError.d.ts +2 -0
  55. package/lib/src/compiler/normalizeError.js +14 -0
  56. package/lib/src/compiler/normalizeError.js.map +1 -0
  57. package/lib/src/compiler/normalizeNodeModulePath.d.ts +8 -0
  58. package/lib/src/compiler/normalizeNodeModulePath.js +19 -0
  59. package/lib/src/compiler/normalizeNodeModulePath.js.map +1 -0
  60. package/lib/src/compiler/pickEmittedJS.d.ts +6 -0
  61. package/lib/src/compiler/pickEmittedJS.js +26 -0
  62. package/lib/src/compiler/pickEmittedJS.js.map +1 -0
  63. package/lib/src/index.d.ts +47 -0
  64. package/lib/src/index.js +104 -0
  65. package/lib/src/index.js.map +1 -0
  66. package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.d.ts +6 -0
  67. package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.js +15 -0
  68. package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.js.map +1 -0
  69. package/lib/src/npm/collectExternalPackageNames.d.ts +5 -0
  70. package/lib/src/npm/collectExternalPackageNames.js +34 -0
  71. package/lib/src/npm/collectExternalPackageNames.js.map +1 -0
  72. package/lib/src/npm/installPlaygroundDependencies.d.ts +13 -0
  73. package/lib/src/npm/installPlaygroundDependencies.js +121 -0
  74. package/lib/src/npm/installPlaygroundDependencies.js.map +1 -0
  75. package/lib/src/npm/internal/npmRegistry.d.ts +57 -0
  76. package/lib/src/npm/internal/npmRegistry.js +216 -0
  77. package/lib/src/npm/internal/npmRegistry.js.map +1 -0
  78. package/lib/src/npm/packageNameFromSpecifier.d.ts +7 -0
  79. package/lib/src/npm/packageNameFromSpecifier.js +66 -0
  80. package/lib/src/npm/packageNameFromSpecifier.js.map +1 -0
  81. package/lib/src/react/ConsoleViewer.d.ts +7 -0
  82. package/lib/src/react/ConsoleViewer.js +57 -0
  83. package/lib/src/react/ConsoleViewer.js.map +1 -0
  84. package/lib/src/react/DEFAULT_OPTION_TOGGLES.d.ts +3 -0
  85. package/lib/src/react/DEFAULT_OPTION_TOGGLES.js +17 -0
  86. package/lib/src/react/DEFAULT_OPTION_TOGGLES.js.map +1 -0
  87. package/lib/src/react/DependencyProgressModal.d.ts +7 -0
  88. package/lib/src/react/DependencyProgressModal.js +16 -0
  89. package/lib/src/react/DependencyProgressModal.js.map +1 -0
  90. package/lib/src/react/DiagnosticsPanel.d.ts +4 -0
  91. package/lib/src/react/DiagnosticsPanel.js +15 -0
  92. package/lib/src/react/DiagnosticsPanel.js.map +1 -0
  93. package/lib/src/react/ExamplePicker.d.ts +9 -0
  94. package/lib/src/react/ExamplePicker.js +43 -0
  95. package/lib/src/react/ExamplePicker.js.map +1 -0
  96. package/lib/src/react/LintPane.d.ts +9 -0
  97. package/lib/src/react/LintPane.js +17 -0
  98. package/lib/src/react/LintPane.js.map +1 -0
  99. package/lib/src/react/OptionsPanel.d.ts +13 -0
  100. package/lib/src/react/OptionsPanel.js +43 -0
  101. package/lib/src/react/OptionsPanel.js.map +1 -0
  102. package/lib/src/react/PlaygroundShell.d.ts +2 -0
  103. package/lib/src/react/PlaygroundShell.js +609 -0
  104. package/lib/src/react/PlaygroundShell.js.map +1 -0
  105. package/lib/src/react/ResultViewer.d.ts +10 -0
  106. package/lib/src/react/ResultViewer.js +49 -0
  107. package/lib/src/react/ResultViewer.js.map +1 -0
  108. package/lib/src/react/SourceEditor.d.ts +2 -0
  109. package/lib/src/react/SourceEditor.js +74 -0
  110. package/lib/src/react/SourceEditor.js.map +1 -0
  111. package/lib/src/react/createCompilerClient.d.ts +14 -0
  112. package/lib/src/react/createCompilerClient.js +77 -0
  113. package/lib/src/react/createCompilerClient.js.map +1 -0
  114. package/lib/src/sandbox/createSandboxRequire.d.ts +11 -0
  115. package/lib/src/sandbox/createSandboxRequire.js +211 -0
  116. package/lib/src/sandbox/createSandboxRequire.js.map +1 -0
  117. package/lib/src/sandbox/loadTypiaRuntimePack.d.ts +7 -0
  118. package/lib/src/sandbox/loadTypiaRuntimePack.js +35 -0
  119. package/lib/src/sandbox/loadTypiaRuntimePack.js.map +1 -0
  120. package/lib/src/structures/IBuildTsconfigOptions.d.ts +19 -0
  121. package/lib/src/structures/IBuildTsconfigOptions.js +3 -0
  122. package/lib/src/structures/IBuildTsconfigOptions.js.map +1 -0
  123. package/lib/src/structures/ICompilerService.d.ts +83 -0
  124. package/lib/src/structures/ICompilerService.js +3 -0
  125. package/lib/src/structures/ICompilerService.js.map +1 -0
  126. package/lib/src/structures/IConsoleMessage.d.ts +10 -0
  127. package/lib/src/structures/IConsoleMessage.js +3 -0
  128. package/lib/src/structures/IConsoleMessage.js.map +1 -0
  129. package/lib/src/structures/ICreateCompilerClientOptions.d.ts +13 -0
  130. package/lib/src/structures/ICreateCompilerClientOptions.js +3 -0
  131. package/lib/src/structures/ICreateCompilerClientOptions.js.map +1 -0
  132. package/lib/src/structures/ICreateWorkerCompilerOptions.d.ts +35 -0
  133. package/lib/src/structures/ICreateWorkerCompilerOptions.js +3 -0
  134. package/lib/src/structures/ICreateWorkerCompilerOptions.js.map +1 -0
  135. package/lib/src/structures/IInstallTypiaSourcePackOptions.d.ts +15 -0
  136. package/lib/src/structures/IInstallTypiaSourcePackOptions.js +3 -0
  137. package/lib/src/structures/IInstallTypiaSourcePackOptions.js.map +1 -0
  138. package/lib/src/structures/ILintPluginConfig.d.ts +5 -0
  139. package/lib/src/structures/ILintPluginConfig.js +3 -0
  140. package/lib/src/structures/ILintPluginConfig.js.map +1 -0
  141. package/lib/src/structures/IOptionToggle.d.ts +12 -0
  142. package/lib/src/structures/IOptionToggle.js +3 -0
  143. package/lib/src/structures/IOptionToggle.js.map +1 -0
  144. package/lib/src/structures/IPlaygroundDependencyInstallOptions.d.ts +16 -0
  145. package/lib/src/structures/IPlaygroundDependencyInstallOptions.js +3 -0
  146. package/lib/src/structures/IPlaygroundDependencyInstallOptions.js.map +1 -0
  147. package/lib/src/structures/IPlaygroundDependencyInstallResult.d.ts +20 -0
  148. package/lib/src/structures/IPlaygroundDependencyInstallResult.js +3 -0
  149. package/lib/src/structures/IPlaygroundDependencyInstallResult.js.map +1 -0
  150. package/lib/src/structures/IPlaygroundDependencyPackage.d.ts +8 -0
  151. package/lib/src/structures/IPlaygroundDependencyPackage.js +3 -0
  152. package/lib/src/structures/IPlaygroundDependencyPackage.js.map +1 -0
  153. package/lib/src/structures/IPlaygroundDependencyProgress.d.ts +10 -0
  154. package/lib/src/structures/IPlaygroundDependencyProgress.js +3 -0
  155. package/lib/src/structures/IPlaygroundDependencyProgress.js.map +1 -0
  156. package/lib/src/structures/IPlaygroundDependencyProgressPhase.d.ts +2 -0
  157. package/lib/src/structures/IPlaygroundDependencyProgressPhase.js +3 -0
  158. package/lib/src/structures/IPlaygroundDependencyProgressPhase.js.map +1 -0
  159. package/lib/src/structures/IPlaygroundExample.d.ts +16 -0
  160. package/lib/src/structures/IPlaygroundExample.js +3 -0
  161. package/lib/src/structures/IPlaygroundExample.js.map +1 -0
  162. package/lib/src/structures/IPlaygroundShellProps.d.ts +64 -0
  163. package/lib/src/structures/IPlaygroundShellProps.js +3 -0
  164. package/lib/src/structures/IPlaygroundShellProps.js.map +1 -0
  165. package/lib/src/structures/ISourceEditorProps.d.ts +18 -0
  166. package/lib/src/structures/ISourceEditorProps.js +3 -0
  167. package/lib/src/structures/ISourceEditorProps.js.map +1 -0
  168. package/lib/src/structures/ITransformOptions.d.ts +15 -0
  169. package/lib/src/structures/ITransformOptions.js +3 -0
  170. package/lib/src/structures/ITransformOptions.js.map +1 -0
  171. package/lib/src/structures/ITypiaPluginConfig.d.ts +19 -0
  172. package/lib/src/structures/ITypiaPluginConfig.js +3 -0
  173. package/lib/src/structures/ITypiaPluginConfig.js.map +1 -0
  174. package/lib/src/structures/index.d.ts +18 -0
  175. package/lib/src/structures/index.js +35 -0
  176. package/lib/src/structures/index.js.map +1 -0
  177. package/package.json +66 -0
  178. package/src/compiler/DEFAULT_ENTRY_FILE.ts +2 -0
  179. package/src/compiler/DEFAULT_LINT_PLUGIN_NAME.ts +5 -0
  180. package/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.ts +19 -0
  181. package/src/compiler/DEFAULT_TSCONFIG_PATH.ts +2 -0
  182. package/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.ts +6 -0
  183. package/src/compiler/DEFAULT_WORK_DIR.ts +2 -0
  184. package/src/compiler/buildTsconfigJSON.ts +22 -0
  185. package/src/compiler/createTypiaSourcePackMount.ts +32 -0
  186. package/src/compiler/createWorkerCompiler.ts +274 -0
  187. package/src/compiler/installDependenciesIntoMemFS.ts +28 -0
  188. package/src/compiler/installTypiaSourcePack.ts +24 -0
  189. package/src/compiler/internal/joinUnder.ts +5 -0
  190. package/src/compiler/internal/parseLintDiagnostics.ts +61 -0
  191. package/src/compiler/internal/safeParseTypiaTransform.ts +24 -0
  192. package/src/compiler/lineColumnOf.ts +14 -0
  193. package/src/compiler/loadTypiaSourcePack.ts +37 -0
  194. package/src/compiler/mapDiagnostic.ts +26 -0
  195. package/src/compiler/normalizeError.ts +12 -0
  196. package/src/compiler/normalizeNodeModulePath.ts +13 -0
  197. package/src/compiler/pickEmittedJS.ts +23 -0
  198. package/src/index.ts +57 -0
  199. package/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.ts +11 -0
  200. package/src/npm/collectExternalPackageNames.ts +34 -0
  201. package/src/npm/installPlaygroundDependencies.ts +163 -0
  202. package/src/npm/internal/npmRegistry.ts +288 -0
  203. package/src/npm/packageNameFromSpecifier.ts +61 -0
  204. package/src/react/ConsoleViewer.tsx +121 -0
  205. package/src/react/DEFAULT_OPTION_TOGGLES.ts +15 -0
  206. package/src/react/DependencyProgressModal.tsx +73 -0
  207. package/src/react/DiagnosticsPanel.tsx +74 -0
  208. package/src/react/ExamplePicker.tsx +93 -0
  209. package/src/react/LintPane.tsx +58 -0
  210. package/src/react/OptionsPanel.tsx +132 -0
  211. package/src/react/PlaygroundShell.tsx +864 -0
  212. package/src/react/ResultViewer.tsx +75 -0
  213. package/src/react/SourceEditor.tsx +96 -0
  214. package/src/react/createCompilerClient.ts +79 -0
  215. package/src/sandbox/createSandboxRequire.ts +275 -0
  216. package/src/sandbox/loadTypiaRuntimePack.ts +36 -0
  217. package/src/structures/IBuildTsconfigOptions.ts +19 -0
  218. package/src/structures/ICompilerService.ts +95 -0
  219. package/src/structures/IConsoleMessage.ts +10 -0
  220. package/src/structures/ICreateCompilerClientOptions.ts +13 -0
  221. package/src/structures/ICreateWorkerCompilerOptions.ts +40 -0
  222. package/src/structures/IInstallTypiaSourcePackOptions.ts +15 -0
  223. package/src/structures/ILintPluginConfig.ts +5 -0
  224. package/src/structures/IOptionToggle.ts +12 -0
  225. package/src/structures/IPlaygroundDependencyInstallOptions.ts +17 -0
  226. package/src/structures/IPlaygroundDependencyInstallResult.ts +21 -0
  227. package/src/structures/IPlaygroundDependencyPackage.ts +8 -0
  228. package/src/structures/IPlaygroundDependencyProgress.ts +11 -0
  229. package/src/structures/IPlaygroundDependencyProgressPhase.ts +9 -0
  230. package/src/structures/IPlaygroundExample.ts +16 -0
  231. package/src/structures/IPlaygroundShellProps.ts +77 -0
  232. package/src/structures/ISourceEditorProps.ts +18 -0
  233. package/src/structures/ITransformOptions.ts +15 -0
  234. package/src/structures/ITypiaPluginConfig.ts +20 -0
  235. package/src/structures/index.ts +18 -0
@@ -0,0 +1,13 @@
1
+ /** Options for {@link createCompilerClient}. */
2
+ export interface ICreateCompilerClientOptions {
3
+ /**
4
+ * URL of the bundled worker script (the site's rspack output of its
5
+ * `compiler/index.ts` worker entry, which calls `createWorkerCompiler`).
6
+ *
7
+ * The Worker is constructed by tgrid's `WorkerConnector` with classic-
8
+ * worker semantics. A custom Worker factory hook is intentionally not
9
+ * exposed — the upstream tgrid v1 API only accepts a URL. File an issue
10
+ * if you need module workers, named workers, or custom credentials.
11
+ */
12
+ workerUrl: string;
13
+ }
@@ -0,0 +1,40 @@
1
+ import type { ILintPluginConfig } from "./ILintPluginConfig";
2
+ import type { ITypiaPluginConfig } from "./ITypiaPluginConfig";
3
+
4
+ /** Options for {@link createWorkerCompiler}. */
5
+ export interface ICreateWorkerCompilerOptions {
6
+ /** URL of the site's pre-built playground.wasm. */
7
+ wasmUrl: string;
8
+ /** URL of the matching wasm_exec.js. Defaults to next to wasmUrl. */
9
+ wasmExecUrl?: string;
10
+ /**
11
+ * `globalThis[apiName]` the wasm binds. Must match the `apiName` passed to
12
+ * `host.Expose` when the site's wasm was built.
13
+ */
14
+ apiName: string;
15
+
16
+ /** In-MemFS project root. Defaults to `/work`. */
17
+ workDir?: string;
18
+ /** tsconfig path relative to `workDir`. Defaults to `tsconfig.json`. */
19
+ tsconfigPath?: string;
20
+ /** Entry source path relative to `workDir`. Defaults to `src/playground.ts`. */
21
+ entryFile?: string;
22
+
23
+ /**
24
+ * Typia integration. Pass `false` to disable. When omitted, defaults to
25
+ * `{ name: "typia", transformModule: "typia/lib/transform" }` — and only
26
+ * actually runs when the per-call `options.typia` is not `false`.
27
+ */
28
+ typiaPlugin?: ITypiaPluginConfig | false;
29
+
30
+ /** Lint integration. Pass `false` to disable. */
31
+ lintPlugin?: ILintPluginConfig | false;
32
+
33
+ /**
34
+ * Extra entries spliced into the tsconfig's `compilerOptions`. Use to wire
35
+ * site-specific plugins, paths, or lib overrides. The typia plugin entry
36
+ * is appended automatically when `typiaPlugin` is enabled — sites should
37
+ * NOT include it here.
38
+ */
39
+ extraCompilerOptions?: Record<string, unknown>;
40
+ }
@@ -0,0 +1,15 @@
1
+ /** Options for {@link installTypiaSourcePack} and {@link createTypiaSourcePackMount}. */
2
+ export interface IInstallTypiaSourcePackOptions {
3
+ /** URL the site serves the pre-built typia source pack from. */
4
+ url: string;
5
+ /**
6
+ * Where to mount the pack inside the MemFS. Defaults to
7
+ * `/work/node_modules`, matching `DEFAULT_WORK_DIR + "/node_modules"`.
8
+ */
9
+ mountRoot?: string;
10
+ /**
11
+ * Optional fetcher. Defaults to `globalThis.fetch`. Override for tests
12
+ * or for sites that want their own caching strategy.
13
+ */
14
+ fetch?: (input: string) => Promise<Response>;
15
+ }
@@ -0,0 +1,5 @@
1
+ /** Options for the `@ttsc/lint` integration of {@link createWorkerCompiler}. */
2
+ export interface ILintPluginConfig {
3
+ /** Plugin id registered with `host.Expose` (default: `"@ttsc/lint"`). */
4
+ name?: string;
5
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Toggle metadata the OptionsPanel renders.
3
+ *
4
+ * Sites declare these for whatever transform plugins their wasm registered;
5
+ * the panel renders one row per entry and bubbles `onChange` with the merged
6
+ * options object.
7
+ */
8
+ export interface IOptionToggle {
9
+ key: string;
10
+ label: string;
11
+ description: string;
12
+ }
@@ -0,0 +1,17 @@
1
+ import type { IPlaygroundDependencyProgress } from "./IPlaygroundDependencyProgress";
2
+
3
+ /** Options for {@link installPlaygroundDependencies}. */
4
+ export interface IPlaygroundDependencyInstallOptions {
5
+ /** Defaults to `globalThis.fetch`. Override for tests or for offline runs. */
6
+ fetch?: (input: string, init?: RequestInit) => Promise<Response>;
7
+ /** Package names the wasm already has — skip re-installing them. */
8
+ installedPackages?: Iterable<string>;
9
+ /** Package names to never install (preinstalled / built-in). */
10
+ ignoredPackages?: Iterable<string>;
11
+ /** Safety cap: error out after installing this many packages. */
12
+ maxPackages?: number;
13
+ /** Aborts the install when triggered. */
14
+ signal?: AbortSignal;
15
+ /** Fires for each phase transition during the install. */
16
+ onProgress?: (event: IPlaygroundDependencyProgress) => void;
17
+ }
@@ -0,0 +1,21 @@
1
+ import type { IPlaygroundDependencyPackage } from "./IPlaygroundDependencyPackage";
2
+
3
+ /** Aggregate result returned by {@link installPlaygroundDependencies}. */
4
+ export interface IPlaygroundDependencyInstallResult {
5
+ packages: IPlaygroundDependencyPackage[];
6
+ /**
7
+ * `node_modules/...` keyed map of files to mount inside the wasm-side
8
+ * compiler MemFS.
9
+ */
10
+ compilerFiles: Record<string, string>;
11
+ /**
12
+ * `file:///node_modules/...` keyed map of `.d.ts` + `package.json` files to
13
+ * register with Monaco via `addExtraLib`.
14
+ */
15
+ editorLibs: Record<string, string>;
16
+ /**
17
+ * Package-rooted runtime files (e.g. `uuid/dist/index.js`) the in-page
18
+ * execute sandbox `require` can resolve.
19
+ */
20
+ runtimeFiles: Record<string, string>;
21
+ }
@@ -0,0 +1,8 @@
1
+ /** Metadata for one successfully installed npm package. */
2
+ export interface IPlaygroundDependencyPackage {
3
+ name: string;
4
+ version: string;
5
+ tarball: string;
6
+ fileCount: number;
7
+ declarationCount: number;
8
+ }
@@ -0,0 +1,11 @@
1
+ import type { IPlaygroundDependencyProgressPhase } from "./IPlaygroundDependencyProgressPhase";
2
+
3
+ /** A single progress event emitted while installing playground dependencies. */
4
+ export interface IPlaygroundDependencyProgress {
5
+ phase: IPlaygroundDependencyProgressPhase;
6
+ packageName?: string;
7
+ version?: string;
8
+ completed: number;
9
+ total: number;
10
+ message: string;
11
+ }
@@ -0,0 +1,9 @@
1
+ /** Lifecycle phase of a single dependency install reported via the progress callback. */
2
+ export type IPlaygroundDependencyProgressPhase =
3
+ | "queued"
4
+ | "resolve"
5
+ | "download"
6
+ | "extract"
7
+ | "skip"
8
+ | "error"
9
+ | "done";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * One pre-canned source script the playground dropdown can load. Sites
3
+ * provide their own list — typia's site lists `random/is/json/protobuf`,
4
+ * the ttsc site lists `typia/lint/mixed`.
5
+ */
6
+ export interface IPlaygroundExample {
7
+ id: string;
8
+ title: string;
9
+ description: string;
10
+ source: string;
11
+ /**
12
+ * Optional grouping bucket. Examples are rendered grouped by this label.
13
+ * Defaults to "Examples" when omitted.
14
+ */
15
+ group?: string;
16
+ }
@@ -0,0 +1,77 @@
1
+ import type { ReactNode } from "react";
2
+
3
+ import type { IOptionToggle } from "./IOptionToggle";
4
+ import type { IPlaygroundExample } from "./IPlaygroundExample";
5
+ import type { ITransformOptions } from "./ITransformOptions";
6
+
7
+ /**
8
+ * Props for the full playground shell.
9
+ *
10
+ * The shell is intentionally configurable rather than configurable-by-context:
11
+ * every changing field is an explicit prop, so wrappers can spread their own
12
+ * defaults without a Provider in between.
13
+ */
14
+ export interface IPlaygroundShellProps {
15
+ /** URL of the bundled worker script (rspack output of the site's worker entry). */
16
+ workerUrl: string;
17
+
18
+ /** Source code shown on first mount (and on Reset). */
19
+ defaultScript: string;
20
+
21
+ /** Examples available in the dropdown. Empty array hides the dropdown. */
22
+ examples?: readonly IPlaygroundExample[];
23
+ /** Display labels for example groups. */
24
+ exampleGroupLabels?: Record<string, string>;
25
+
26
+ /** Toggles rendered in the Options modal. Defaults to typia + lint. */
27
+ optionToggles?: readonly IOptionToggle[];
28
+ /** Initial values for the transform options. Defaults to `{typia: true, lint: true}`. */
29
+ defaultOptions?: ITransformOptions;
30
+
31
+ /**
32
+ * Static extra .d.ts entries to mount in Monaco (e.g. a pre-packed typia
33
+ * type pack). Merged with dependencies installed at runtime.
34
+ */
35
+ staticEditorLibs?: Record<string, string>;
36
+
37
+ /**
38
+ * Packages the site has already pre-mounted into the wasm. These are
39
+ * skipped by the runtime npm dependency installer.
40
+ */
41
+ preinstalledPackages?: readonly string[];
42
+
43
+ /**
44
+ * Optional execute hook. When provided, the shell renders an "Execute"
45
+ * button; on click it calls `service.bundle(...)` to get the JS and passes
46
+ * it here. The returned messages are appended to the Console pane.
47
+ *
48
+ * `sandbox.runtimeFiles` is the accumulated runtime-file map produced by
49
+ * every `installPlaygroundDependencies` call so far in this session
50
+ * (package-rooted keys like `uuid/dist/index.js`). The site's executeBundle
51
+ * typically merges these on top of its own typia-runtime pack and feeds
52
+ * the union to `createSandboxRequire` — without this channel the in-page
53
+ * Execute sandbox cannot resolve any npm dependency the user installed.
54
+ *
55
+ * When omitted, the Execute UI is hidden.
56
+ */
57
+ executeBundle?: (
58
+ code: string,
59
+ sandbox: {
60
+ console: Record<string, (...args: unknown[]) => void>;
61
+ runtimeFiles: Record<string, string>;
62
+ },
63
+ ) => Promise<void>;
64
+
65
+ /**
66
+ * Brand slot in the toolbar (left side). Renders before the Playground
67
+ * label. Sites typically pass `<a href="/">SiteName</a>`.
68
+ */
69
+ brand?: ReactNode;
70
+
71
+ /**
72
+ * Caption shown on the result pane when the active tab is "javascript".
73
+ * Defaults to `"dist/playground.js"`. Receives the current transform
74
+ * options so sites can append `· typia disabled` etc.
75
+ */
76
+ resultCaption?: (options: ITransformOptions) => string;
77
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Props for the Monaco-based source editor. The site provides `extraLibs` —
3
+ * typically the typia `.d.ts` pack and any installed npm package `.d.ts`
4
+ * files — and the editor mounts them via
5
+ * `monaco.languages.typescript.typescriptDefaults.addExtraLib`.
6
+ */
7
+ export interface ISourceEditorProps {
8
+ value: string;
9
+ onChange: (value: string) => void;
10
+ /**
11
+ * Map of file path → declaration text. Mounted into Monaco's TypeScript
12
+ * extra-libs registry. Hot-replaceable: the editor disposes the previous
13
+ * libs and re-mounts when the map identity changes.
14
+ */
15
+ extraLibs?: Record<string, string>;
16
+ /** Editor model URI. Defaults to `file:///src/playground.ts`. */
17
+ path?: string;
18
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Toggle flags the UI surfaces in the Options panel and forwards to the worker
3
+ * on every compile. The built-in `typia` and `lint` keys mirror the two plugin
4
+ * verbs `createWorkerCompiler` calls by default; sites that wire additional
5
+ * plugins can extend this interface via TypeScript declaration merging or pass
6
+ * a richer shape through `[key: string]: boolean | undefined`.
7
+ */
8
+ export interface ITransformOptions {
9
+ /** Enable the typia transform plugin. Defaults to true. */
10
+ typia?: boolean;
11
+ /** Enable the `@ttsc/lint` preview rule pass. Defaults to true. */
12
+ lint?: boolean;
13
+ /** Additional site-specific toggles. */
14
+ [key: string]: boolean | undefined;
15
+ }
@@ -0,0 +1,20 @@
1
+ import type { IMemFSHost } from "@ttsc/wasm";
2
+
3
+ /** Options for the typia integration of {@link createWorkerCompiler}. */
4
+ export interface ITypiaPluginConfig {
5
+ /** Plugin id registered with `host.Expose` (default: `"typia"`). */
6
+ name?: string;
7
+ /**
8
+ * Module specifier the typia transform receives via
9
+ * `compilerOptions.plugins` (default: `"typia/lib/transform"`).
10
+ */
11
+ transformModule?: string;
12
+ /**
13
+ * Optional hook to mount typia source files into the MemFS during boot.
14
+ * The site fetches its pre-built typia pack and writes it under
15
+ * `<workDir>/node_modules/`. `workDir` is forwarded from
16
+ * `createWorkerCompiler` so the mount can honor a non-default project
17
+ * root without the site rewiring the URL.
18
+ */
19
+ mount?: (host: IMemFSHost, workDir: string) => Promise<void>;
20
+ }
@@ -0,0 +1,18 @@
1
+ export * from "./IBuildTsconfigOptions";
2
+ export * from "./ICompilerService";
3
+ export * from "./IConsoleMessage";
4
+ export * from "./ICreateCompilerClientOptions";
5
+ export * from "./ICreateWorkerCompilerOptions";
6
+ export * from "./IInstallTypiaSourcePackOptions";
7
+ export * from "./ILintPluginConfig";
8
+ export * from "./IOptionToggle";
9
+ export * from "./IPlaygroundDependencyInstallOptions";
10
+ export * from "./IPlaygroundDependencyInstallResult";
11
+ export * from "./IPlaygroundDependencyPackage";
12
+ export * from "./IPlaygroundDependencyProgress";
13
+ export * from "./IPlaygroundDependencyProgressPhase";
14
+ export * from "./IPlaygroundExample";
15
+ export * from "./IPlaygroundShellProps";
16
+ export * from "./ISourceEditorProps";
17
+ export * from "./ITransformOptions";
18
+ export * from "./ITypiaPluginConfig";