@ttsc/playground 0.14.0-dev.20250530.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.
- package/LICENSE +21 -0
- package/README.md +191 -0
- package/lib/src/compiler/DEFAULT_ENTRY_FILE.d.ts +2 -0
- package/lib/src/compiler/DEFAULT_ENTRY_FILE.js +6 -0
- package/lib/src/compiler/DEFAULT_ENTRY_FILE.js.map +1 -0
- package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.d.ts +5 -0
- package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.js +9 -0
- package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.js.map +1 -0
- package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.d.ts +19 -0
- package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.js +23 -0
- package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.js.map +1 -0
- package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.d.ts +2 -0
- package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.js +6 -0
- package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.js.map +1 -0
- package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.d.ts +6 -0
- package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.js +10 -0
- package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.js.map +1 -0
- package/lib/src/compiler/DEFAULT_WORK_DIR.d.ts +2 -0
- package/lib/src/compiler/DEFAULT_WORK_DIR.js +6 -0
- package/lib/src/compiler/DEFAULT_WORK_DIR.js.map +1 -0
- package/lib/src/compiler/buildTsconfigJSON.d.ts +9 -0
- package/lib/src/compiler/buildTsconfigJSON.js +24 -0
- package/lib/src/compiler/buildTsconfigJSON.js.map +1 -0
- package/lib/src/compiler/createTypiaSourcePackMount.d.ts +11 -0
- package/lib/src/compiler/createTypiaSourcePackMount.js +29 -0
- package/lib/src/compiler/createTypiaSourcePackMount.js.map +1 -0
- package/lib/src/compiler/createWorkerCompiler.d.ts +25 -0
- package/lib/src/compiler/createWorkerCompiler.js +227 -0
- package/lib/src/compiler/createWorkerCompiler.js.map +1 -0
- package/lib/src/compiler/installDependenciesIntoMemFS.d.ts +12 -0
- package/lib/src/compiler/installDependenciesIntoMemFS.js +25 -0
- package/lib/src/compiler/installDependenciesIntoMemFS.js.map +1 -0
- package/lib/src/compiler/installTypiaSourcePack.d.ts +11 -0
- package/lib/src/compiler/installTypiaSourcePack.js +21 -0
- package/lib/src/compiler/installTypiaSourcePack.js.map +1 -0
- package/lib/src/compiler/internal/joinUnder.d.ts +5 -0
- package/lib/src/compiler/internal/joinUnder.js +13 -0
- package/lib/src/compiler/internal/joinUnder.js.map +1 -0
- package/lib/src/compiler/internal/parseLintDiagnostics.d.ts +6 -0
- package/lib/src/compiler/internal/parseLintDiagnostics.js +57 -0
- package/lib/src/compiler/internal/parseLintDiagnostics.js.map +1 -0
- package/lib/src/compiler/internal/safeParseTypiaTransform.d.ts +11 -0
- package/lib/src/compiler/internal/safeParseTypiaTransform.js +21 -0
- package/lib/src/compiler/internal/safeParseTypiaTransform.js.map +1 -0
- package/lib/src/compiler/lineColumnOf.d.ts +5 -0
- package/lib/src/compiler/lineColumnOf.js +15 -0
- package/lib/src/compiler/lineColumnOf.js.map +1 -0
- package/lib/src/compiler/loadTypiaSourcePack.d.ts +8 -0
- package/lib/src/compiler/loadTypiaSourcePack.js +33 -0
- package/lib/src/compiler/loadTypiaSourcePack.js.map +1 -0
- package/lib/src/compiler/mapDiagnostic.d.ts +9 -0
- package/lib/src/compiler/mapDiagnostic.js +22 -0
- package/lib/src/compiler/mapDiagnostic.js.map +1 -0
- package/lib/src/compiler/normalizeError.d.ts +2 -0
- package/lib/src/compiler/normalizeError.js +14 -0
- package/lib/src/compiler/normalizeError.js.map +1 -0
- package/lib/src/compiler/normalizeNodeModulePath.d.ts +8 -0
- package/lib/src/compiler/normalizeNodeModulePath.js +19 -0
- package/lib/src/compiler/normalizeNodeModulePath.js.map +1 -0
- package/lib/src/compiler/pickEmittedJS.d.ts +6 -0
- package/lib/src/compiler/pickEmittedJS.js +21 -0
- package/lib/src/compiler/pickEmittedJS.js.map +1 -0
- package/lib/src/index.d.ts +47 -0
- package/lib/src/index.js +104 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.d.ts +6 -0
- package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.js +15 -0
- package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.js.map +1 -0
- package/lib/src/npm/collectExternalPackageNames.d.ts +5 -0
- package/lib/src/npm/collectExternalPackageNames.js +34 -0
- package/lib/src/npm/collectExternalPackageNames.js.map +1 -0
- package/lib/src/npm/installPlaygroundDependencies.d.ts +13 -0
- package/lib/src/npm/installPlaygroundDependencies.js +121 -0
- package/lib/src/npm/installPlaygroundDependencies.js.map +1 -0
- package/lib/src/npm/internal/npmRegistry.d.ts +57 -0
- package/lib/src/npm/internal/npmRegistry.js +216 -0
- package/lib/src/npm/internal/npmRegistry.js.map +1 -0
- package/lib/src/npm/packageNameFromSpecifier.d.ts +7 -0
- package/lib/src/npm/packageNameFromSpecifier.js +66 -0
- package/lib/src/npm/packageNameFromSpecifier.js.map +1 -0
- package/lib/src/react/ConsoleViewer.d.ts +7 -0
- package/lib/src/react/ConsoleViewer.js +57 -0
- package/lib/src/react/ConsoleViewer.js.map +1 -0
- package/lib/src/react/DEFAULT_OPTION_TOGGLES.d.ts +3 -0
- package/lib/src/react/DEFAULT_OPTION_TOGGLES.js +17 -0
- package/lib/src/react/DEFAULT_OPTION_TOGGLES.js.map +1 -0
- package/lib/src/react/DependencyProgressModal.d.ts +7 -0
- package/lib/src/react/DependencyProgressModal.js +16 -0
- package/lib/src/react/DependencyProgressModal.js.map +1 -0
- package/lib/src/react/DiagnosticsPanel.d.ts +4 -0
- package/lib/src/react/DiagnosticsPanel.js +15 -0
- package/lib/src/react/DiagnosticsPanel.js.map +1 -0
- package/lib/src/react/ExamplePicker.d.ts +9 -0
- package/lib/src/react/ExamplePicker.js +43 -0
- package/lib/src/react/ExamplePicker.js.map +1 -0
- package/lib/src/react/LintPane.d.ts +9 -0
- package/lib/src/react/LintPane.js +17 -0
- package/lib/src/react/LintPane.js.map +1 -0
- package/lib/src/react/OptionsPanel.d.ts +13 -0
- package/lib/src/react/OptionsPanel.js +43 -0
- package/lib/src/react/OptionsPanel.js.map +1 -0
- package/lib/src/react/PlaygroundShell.d.ts +2 -0
- package/lib/src/react/PlaygroundShell.js +609 -0
- package/lib/src/react/PlaygroundShell.js.map +1 -0
- package/lib/src/react/ResultViewer.d.ts +10 -0
- package/lib/src/react/ResultViewer.js +49 -0
- package/lib/src/react/ResultViewer.js.map +1 -0
- package/lib/src/react/SourceEditor.d.ts +2 -0
- package/lib/src/react/SourceEditor.js +74 -0
- package/lib/src/react/SourceEditor.js.map +1 -0
- package/lib/src/react/createCompilerClient.d.ts +14 -0
- package/lib/src/react/createCompilerClient.js +77 -0
- package/lib/src/react/createCompilerClient.js.map +1 -0
- package/lib/src/sandbox/createSandboxRequire.d.ts +11 -0
- package/lib/src/sandbox/createSandboxRequire.js +211 -0
- package/lib/src/sandbox/createSandboxRequire.js.map +1 -0
- package/lib/src/sandbox/loadTypiaRuntimePack.d.ts +7 -0
- package/lib/src/sandbox/loadTypiaRuntimePack.js +35 -0
- package/lib/src/sandbox/loadTypiaRuntimePack.js.map +1 -0
- package/lib/src/structures/IBuildTsconfigOptions.d.ts +19 -0
- package/lib/src/structures/IBuildTsconfigOptions.js +3 -0
- package/lib/src/structures/IBuildTsconfigOptions.js.map +1 -0
- package/lib/src/structures/ICompilerService.d.ts +84 -0
- package/lib/src/structures/ICompilerService.js +3 -0
- package/lib/src/structures/ICompilerService.js.map +1 -0
- package/lib/src/structures/IConsoleMessage.d.ts +10 -0
- package/lib/src/structures/IConsoleMessage.js +3 -0
- package/lib/src/structures/IConsoleMessage.js.map +1 -0
- package/lib/src/structures/ICreateCompilerClientOptions.d.ts +13 -0
- package/lib/src/structures/ICreateCompilerClientOptions.js +3 -0
- package/lib/src/structures/ICreateCompilerClientOptions.js.map +1 -0
- package/lib/src/structures/ICreateWorkerCompilerOptions.d.ts +35 -0
- package/lib/src/structures/ICreateWorkerCompilerOptions.js +3 -0
- package/lib/src/structures/ICreateWorkerCompilerOptions.js.map +1 -0
- package/lib/src/structures/IInstallTypiaSourcePackOptions.d.ts +18 -0
- package/lib/src/structures/IInstallTypiaSourcePackOptions.js +3 -0
- package/lib/src/structures/IInstallTypiaSourcePackOptions.js.map +1 -0
- package/lib/src/structures/ILintPluginConfig.d.ts +5 -0
- package/lib/src/structures/ILintPluginConfig.js +3 -0
- package/lib/src/structures/ILintPluginConfig.js.map +1 -0
- package/lib/src/structures/IOptionToggle.d.ts +12 -0
- package/lib/src/structures/IOptionToggle.js +3 -0
- package/lib/src/structures/IOptionToggle.js.map +1 -0
- package/lib/src/structures/IPlaygroundDependencyInstallOptions.d.ts +16 -0
- package/lib/src/structures/IPlaygroundDependencyInstallOptions.js +3 -0
- package/lib/src/structures/IPlaygroundDependencyInstallOptions.js.map +1 -0
- package/lib/src/structures/IPlaygroundDependencyInstallResult.d.ts +20 -0
- package/lib/src/structures/IPlaygroundDependencyInstallResult.js +3 -0
- package/lib/src/structures/IPlaygroundDependencyInstallResult.js.map +1 -0
- package/lib/src/structures/IPlaygroundDependencyPackage.d.ts +8 -0
- package/lib/src/structures/IPlaygroundDependencyPackage.js +3 -0
- package/lib/src/structures/IPlaygroundDependencyPackage.js.map +1 -0
- package/lib/src/structures/IPlaygroundDependencyProgress.d.ts +10 -0
- package/lib/src/structures/IPlaygroundDependencyProgress.js +3 -0
- package/lib/src/structures/IPlaygroundDependencyProgress.js.map +1 -0
- package/lib/src/structures/IPlaygroundDependencyProgressPhase.d.ts +5 -0
- package/lib/src/structures/IPlaygroundDependencyProgressPhase.js +3 -0
- package/lib/src/structures/IPlaygroundDependencyProgressPhase.js.map +1 -0
- package/lib/src/structures/IPlaygroundExample.d.ts +16 -0
- package/lib/src/structures/IPlaygroundExample.js +3 -0
- package/lib/src/structures/IPlaygroundExample.js.map +1 -0
- package/lib/src/structures/IPlaygroundShellProps.d.ts +70 -0
- package/lib/src/structures/IPlaygroundShellProps.js +3 -0
- package/lib/src/structures/IPlaygroundShellProps.js.map +1 -0
- package/lib/src/structures/ISourceEditorProps.d.ts +18 -0
- package/lib/src/structures/ISourceEditorProps.js +3 -0
- package/lib/src/structures/ISourceEditorProps.js.map +1 -0
- package/lib/src/structures/ITransformOptions.d.ts +15 -0
- package/lib/src/structures/ITransformOptions.js +3 -0
- package/lib/src/structures/ITransformOptions.js.map +1 -0
- package/lib/src/structures/ITypiaPluginConfig.d.ts +19 -0
- package/lib/src/structures/ITypiaPluginConfig.js +3 -0
- package/lib/src/structures/ITypiaPluginConfig.js.map +1 -0
- package/lib/src/structures/index.d.ts +18 -0
- package/lib/src/structures/index.js +35 -0
- package/lib/src/structures/index.js.map +1 -0
- package/package.json +66 -0
- package/src/compiler/DEFAULT_ENTRY_FILE.ts +2 -0
- package/src/compiler/DEFAULT_LINT_PLUGIN_NAME.ts +5 -0
- package/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.ts +19 -0
- package/src/compiler/DEFAULT_TSCONFIG_PATH.ts +2 -0
- package/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.ts +6 -0
- package/src/compiler/DEFAULT_WORK_DIR.ts +2 -0
- package/src/compiler/buildTsconfigJSON.ts +22 -0
- package/src/compiler/createTypiaSourcePackMount.ts +32 -0
- package/src/compiler/createWorkerCompiler.ts +273 -0
- package/src/compiler/installDependenciesIntoMemFS.ts +28 -0
- package/src/compiler/installTypiaSourcePack.ts +24 -0
- package/src/compiler/internal/joinUnder.ts +8 -0
- package/src/compiler/internal/parseLintDiagnostics.ts +61 -0
- package/src/compiler/internal/safeParseTypiaTransform.ts +24 -0
- package/src/compiler/lineColumnOf.ts +14 -0
- package/src/compiler/loadTypiaSourcePack.ts +37 -0
- package/src/compiler/mapDiagnostic.ts +26 -0
- package/src/compiler/normalizeError.ts +12 -0
- package/src/compiler/normalizeNodeModulePath.ts +13 -0
- package/src/compiler/pickEmittedJS.ts +18 -0
- package/src/index.ts +57 -0
- package/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.ts +11 -0
- package/src/npm/collectExternalPackageNames.ts +34 -0
- package/src/npm/installPlaygroundDependencies.ts +163 -0
- package/src/npm/internal/npmRegistry.ts +292 -0
- package/src/npm/packageNameFromSpecifier.ts +61 -0
- package/src/react/ConsoleViewer.tsx +121 -0
- package/src/react/DEFAULT_OPTION_TOGGLES.ts +15 -0
- package/src/react/DependencyProgressModal.tsx +73 -0
- package/src/react/DiagnosticsPanel.tsx +74 -0
- package/src/react/ExamplePicker.tsx +93 -0
- package/src/react/LintPane.tsx +58 -0
- package/src/react/OptionsPanel.tsx +132 -0
- package/src/react/PlaygroundShell.tsx +864 -0
- package/src/react/ResultViewer.tsx +75 -0
- package/src/react/SourceEditor.tsx +96 -0
- package/src/react/createCompilerClient.ts +80 -0
- package/src/sandbox/createSandboxRequire.ts +275 -0
- package/src/sandbox/loadTypiaRuntimePack.ts +36 -0
- package/src/structures/IBuildTsconfigOptions.ts +19 -0
- package/src/structures/ICompilerService.ts +96 -0
- package/src/structures/IConsoleMessage.ts +10 -0
- package/src/structures/ICreateCompilerClientOptions.ts +13 -0
- package/src/structures/ICreateWorkerCompilerOptions.ts +40 -0
- package/src/structures/IInstallTypiaSourcePackOptions.ts +18 -0
- package/src/structures/ILintPluginConfig.ts +5 -0
- package/src/structures/IOptionToggle.ts +12 -0
- package/src/structures/IPlaygroundDependencyInstallOptions.ts +17 -0
- package/src/structures/IPlaygroundDependencyInstallResult.ts +21 -0
- package/src/structures/IPlaygroundDependencyPackage.ts +8 -0
- package/src/structures/IPlaygroundDependencyProgress.ts +11 -0
- package/src/structures/IPlaygroundDependencyProgressPhase.ts +12 -0
- package/src/structures/IPlaygroundExample.ts +16 -0
- package/src/structures/IPlaygroundShellProps.ts +83 -0
- package/src/structures/ISourceEditorProps.ts +18 -0
- package/src/structures/ITransformOptions.ts +15 -0
- package/src/structures/ITypiaPluginConfig.ts +20 -0
- 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- worker
|
|
8
|
+
* semantics. A custom Worker factory hook is intentionally not exposed — the
|
|
9
|
+
* upstream tgrid v1 API only accepts a URL. File an issue if you need module
|
|
10
|
+
* 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 is
|
|
36
|
+
* appended automatically when `typiaPlugin` is enabled — sites should NOT
|
|
37
|
+
* include it here.
|
|
38
|
+
*/
|
|
39
|
+
extraCompilerOptions?: Record<string, unknown>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@link installTypiaSourcePack} and
|
|
3
|
+
* {@link createTypiaSourcePackMount}.
|
|
4
|
+
*/
|
|
5
|
+
export interface IInstallTypiaSourcePackOptions {
|
|
6
|
+
/** URL the site serves the pre-built typia source pack from. */
|
|
7
|
+
url: string;
|
|
8
|
+
/**
|
|
9
|
+
* Where to mount the pack inside the MemFS. Defaults to `/work/node_modules`,
|
|
10
|
+
* matching `DEFAULT_WORK_DIR + "/node_modules"`.
|
|
11
|
+
*/
|
|
12
|
+
mountRoot?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional fetcher. Defaults to `globalThis.fetch`. Override for tests or for
|
|
15
|
+
* sites that want their own caching strategy.
|
|
16
|
+
*/
|
|
17
|
+
fetch?: (input: string) => Promise<Response>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toggle metadata the OptionsPanel renders.
|
|
3
|
+
*
|
|
4
|
+
* Sites declare these for whatever transform plugins their wasm registered; the
|
|
5
|
+
* 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,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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One pre-canned source script the playground dropdown can load. Sites provide
|
|
3
|
+
* their own list — typia's site lists `random/is/json/protobuf`, the ttsc site
|
|
4
|
+
* 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,83 @@
|
|
|
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
|
+
/**
|
|
16
|
+
* URL of the bundled worker script (rspack output of the site's worker
|
|
17
|
+
* entry).
|
|
18
|
+
*/
|
|
19
|
+
workerUrl: string;
|
|
20
|
+
|
|
21
|
+
/** Source code shown on first mount (and on Reset). */
|
|
22
|
+
defaultScript: string;
|
|
23
|
+
|
|
24
|
+
/** Examples available in the dropdown. Empty array hides the dropdown. */
|
|
25
|
+
examples?: readonly IPlaygroundExample[];
|
|
26
|
+
/** Display labels for example groups. */
|
|
27
|
+
exampleGroupLabels?: Record<string, string>;
|
|
28
|
+
|
|
29
|
+
/** Toggles rendered in the Options modal. Defaults to typia + lint. */
|
|
30
|
+
optionToggles?: readonly IOptionToggle[];
|
|
31
|
+
/**
|
|
32
|
+
* Initial values for the transform options. Defaults to `{typia: true, lint:
|
|
33
|
+
* true}`.
|
|
34
|
+
*/
|
|
35
|
+
defaultOptions?: ITransformOptions;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Static extra .d.ts entries to mount in Monaco (e.g. a pre-packed typia type
|
|
39
|
+
* pack). Merged with dependencies installed at runtime.
|
|
40
|
+
*/
|
|
41
|
+
staticEditorLibs?: Record<string, string>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Packages the site has already pre-mounted into the wasm. These are skipped
|
|
45
|
+
* by the runtime npm dependency installer.
|
|
46
|
+
*/
|
|
47
|
+
preinstalledPackages?: readonly string[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Optional execute hook. When provided, the shell renders an "Execute"
|
|
51
|
+
* button; on click it calls `service.bundle(...)` to get the JS and passes it
|
|
52
|
+
* here. The returned messages are appended to the Console pane.
|
|
53
|
+
*
|
|
54
|
+
* `sandbox.runtimeFiles` is the accumulated runtime-file map produced by
|
|
55
|
+
* every `installPlaygroundDependencies` call so far in this session
|
|
56
|
+
* (package-rooted keys like `uuid/dist/index.js`). The site's executeBundle
|
|
57
|
+
* typically merges these on top of its own typia-runtime pack and feeds the
|
|
58
|
+
* union to `createSandboxRequire` — without this channel the in-page Execute
|
|
59
|
+
* sandbox cannot resolve any npm dependency the user installed.
|
|
60
|
+
*
|
|
61
|
+
* When omitted, the Execute UI is hidden.
|
|
62
|
+
*/
|
|
63
|
+
executeBundle?: (
|
|
64
|
+
code: string,
|
|
65
|
+
sandbox: {
|
|
66
|
+
console: Record<string, (...args: unknown[]) => void>;
|
|
67
|
+
runtimeFiles: Record<string, string>;
|
|
68
|
+
},
|
|
69
|
+
) => Promise<void>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Brand slot in the toolbar (left side). Renders before the Playground label.
|
|
73
|
+
* Sites typically pass `<a href="/">SiteName</a>`.
|
|
74
|
+
*/
|
|
75
|
+
brand?: ReactNode;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Caption shown on the result pane when the active tab is "javascript".
|
|
79
|
+
* Defaults to `"dist/playground.js"`. Receives the current transform options
|
|
80
|
+
* so sites can append `· typia disabled` etc.
|
|
81
|
+
*/
|
|
82
|
+
resultCaption?: (options: ITransformOptions) => string;
|
|
83
|
+
}
|
|
@@ -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` files
|
|
4
|
+
* — 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 libs
|
|
13
|
+
* 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 `compilerOptions.plugins`
|
|
9
|
+
* (default: `"typia/lib/transform"`).
|
|
10
|
+
*/
|
|
11
|
+
transformModule?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional hook to mount typia source files into the MemFS during boot. The
|
|
14
|
+
* 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 root
|
|
17
|
+
* 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";
|