@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.
- package/LICENSE +21 -0
- package/README.md +230 -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 +2 -0
- package/lib/src/compiler/internal/joinUnder.js +10 -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 +26 -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 +83 -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 +15 -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 +2 -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 +64 -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 +274 -0
- package/src/compiler/installDependenciesIntoMemFS.ts +28 -0
- package/src/compiler/installTypiaSourcePack.ts +24 -0
- package/src/compiler/internal/joinUnder.ts +5 -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 +23 -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 +288 -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 +79 -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 +95 -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 +15 -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 +9 -0
- package/src/structures/IPlaygroundExample.ts +16 -0
- package/src/structures/IPlaygroundShellProps.ts +77 -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,83 @@
|
|
|
1
|
+
import type { ITransformOptions } from "./ITransformOptions";
|
|
2
|
+
/**
|
|
3
|
+
* Worker ↔ UI RPC contract for the playground compiler service.
|
|
4
|
+
*
|
|
5
|
+
* `createWorkerCompiler` (worker side) implements this. `createCompilerClient`
|
|
6
|
+
* (UI side) returns a tgrid Driver bound to this shape. Sites that need an
|
|
7
|
+
* `extraTabs` lane should layer additional verbs over this base interface in
|
|
8
|
+
* their own ICompilerService subtype.
|
|
9
|
+
*/
|
|
10
|
+
export interface ICompilerService {
|
|
11
|
+
/**
|
|
12
|
+
* Mount external npm package files into the worker's MemFS under
|
|
13
|
+
* `node_modules/`. Driven by the dependency installer in `@ttsc/playground/npm`.
|
|
14
|
+
*/
|
|
15
|
+
installDependencies(props: ICompilerService.IInstallDependenciesProps): Promise<ICompilerService.IInstallDependenciesResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Compile the user's source into JavaScript with diagnostics. Plugin
|
|
18
|
+
* transforms (typia, when enabled in options) run first; the result is the
|
|
19
|
+
* post-transform emit.
|
|
20
|
+
*/
|
|
21
|
+
compile(props: ICompilerService.IProps): Promise<ICompilerService.IResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Same pipeline as `compile`, but using the bundle-flavored tsconfig
|
|
24
|
+
* (typically `module: "CommonJS"` for in-page `new Function` sandboxing).
|
|
25
|
+
* Sites that don't run user code may treat this identically to `compile`.
|
|
26
|
+
*/
|
|
27
|
+
bundle(props: ICompilerService.IProps): Promise<ICompilerService.IResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Run the lint plugin and parse its findings into the same diagnostic shape
|
|
30
|
+
* as `compile`. Returns an empty list when no lint plugin is wired into the
|
|
31
|
+
* worker.
|
|
32
|
+
*/
|
|
33
|
+
lint(props: ICompilerService.IProps): Promise<ICompilerService.ILintResult>;
|
|
34
|
+
}
|
|
35
|
+
export declare namespace ICompilerService {
|
|
36
|
+
export interface IProps {
|
|
37
|
+
source: string;
|
|
38
|
+
options?: ITransformOptions;
|
|
39
|
+
}
|
|
40
|
+
export interface IInstallDependenciesProps {
|
|
41
|
+
/** node_modules-relative paths to text content. */
|
|
42
|
+
files: Record<string, string>;
|
|
43
|
+
/** Metadata for the packages whose files are in `files`. */
|
|
44
|
+
packages: IInstalledPackage[];
|
|
45
|
+
}
|
|
46
|
+
export interface IInstalledPackage {
|
|
47
|
+
name: string;
|
|
48
|
+
version: string;
|
|
49
|
+
}
|
|
50
|
+
export interface IInstallDependenciesResult {
|
|
51
|
+
installed: IInstalledPackage[];
|
|
52
|
+
fileCount: number;
|
|
53
|
+
}
|
|
54
|
+
export type IResult = ISuccess | IFailure | IError;
|
|
55
|
+
export interface ISuccess extends IBase<"success", string> {
|
|
56
|
+
}
|
|
57
|
+
export interface IFailure extends IBase<"failure", string> {
|
|
58
|
+
diagnostics: IDiagnostic[];
|
|
59
|
+
}
|
|
60
|
+
export interface IError extends IBase<"error", unknown> {
|
|
61
|
+
}
|
|
62
|
+
interface IBase<Type extends string, Value> {
|
|
63
|
+
type: Type;
|
|
64
|
+
target: "javascript";
|
|
65
|
+
value: Value;
|
|
66
|
+
}
|
|
67
|
+
export interface IDiagnostic {
|
|
68
|
+
/** 1-based line number. */
|
|
69
|
+
line: number;
|
|
70
|
+
/** 1-based column number. */
|
|
71
|
+
column: number;
|
|
72
|
+
/** Length of the span in source characters; at least 1. */
|
|
73
|
+
length: number;
|
|
74
|
+
severity: "error" | "warning";
|
|
75
|
+
message: string;
|
|
76
|
+
/** Diagnostic code, e.g. `"TS2322"` or a lint rule id. */
|
|
77
|
+
code?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface ILintResult {
|
|
80
|
+
diagnostics: IDiagnostic[];
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICompilerService.js","sourceRoot":"","sources":["../../../src/structures/ICompilerService.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One captured `console.*` invocation. `value` is the argv (the spread of
|
|
3
|
+
* `console.log(...args)`), so `console.log("user:", user)` shows up as a
|
|
4
|
+
* single row with both pieces rendered inline, separated by a space — same
|
|
5
|
+
* as a real DevTools console.
|
|
6
|
+
*/
|
|
7
|
+
export interface IConsoleMessage {
|
|
8
|
+
type: "debug" | "dir" | "error" | "info" | "log" | "table" | "warn";
|
|
9
|
+
value: unknown[];
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConsoleMessage.js","sourceRoot":"","sources":["../../../src/structures/IConsoleMessage.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"ICreateCompilerClientOptions.js","sourceRoot":"","sources":["../../../src/structures/ICreateCompilerClientOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ILintPluginConfig } from "./ILintPluginConfig";
|
|
2
|
+
import type { ITypiaPluginConfig } from "./ITypiaPluginConfig";
|
|
3
|
+
/** Options for {@link createWorkerCompiler}. */
|
|
4
|
+
export interface ICreateWorkerCompilerOptions {
|
|
5
|
+
/** URL of the site's pre-built playground.wasm. */
|
|
6
|
+
wasmUrl: string;
|
|
7
|
+
/** URL of the matching wasm_exec.js. Defaults to next to wasmUrl. */
|
|
8
|
+
wasmExecUrl?: string;
|
|
9
|
+
/**
|
|
10
|
+
* `globalThis[apiName]` the wasm binds. Must match the `apiName` passed to
|
|
11
|
+
* `host.Expose` when the site's wasm was built.
|
|
12
|
+
*/
|
|
13
|
+
apiName: string;
|
|
14
|
+
/** In-MemFS project root. Defaults to `/work`. */
|
|
15
|
+
workDir?: string;
|
|
16
|
+
/** tsconfig path relative to `workDir`. Defaults to `tsconfig.json`. */
|
|
17
|
+
tsconfigPath?: string;
|
|
18
|
+
/** Entry source path relative to `workDir`. Defaults to `src/playground.ts`. */
|
|
19
|
+
entryFile?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Typia integration. Pass `false` to disable. When omitted, defaults to
|
|
22
|
+
* `{ name: "typia", transformModule: "typia/lib/transform" }` — and only
|
|
23
|
+
* actually runs when the per-call `options.typia` is not `false`.
|
|
24
|
+
*/
|
|
25
|
+
typiaPlugin?: ITypiaPluginConfig | false;
|
|
26
|
+
/** Lint integration. Pass `false` to disable. */
|
|
27
|
+
lintPlugin?: ILintPluginConfig | false;
|
|
28
|
+
/**
|
|
29
|
+
* Extra entries spliced into the tsconfig's `compilerOptions`. Use to wire
|
|
30
|
+
* site-specific plugins, paths, or lib overrides. The typia plugin entry
|
|
31
|
+
* is appended automatically when `typiaPlugin` is enabled — sites should
|
|
32
|
+
* NOT include it here.
|
|
33
|
+
*/
|
|
34
|
+
extraCompilerOptions?: Record<string, unknown>;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICreateWorkerCompilerOptions.js","sourceRoot":"","sources":["../../../src/structures/ICreateWorkerCompilerOptions.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"IInstallTypiaSourcePackOptions.js","sourceRoot":"","sources":["../../../src/structures/IInstallTypiaSourcePackOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILintPluginConfig.js","sourceRoot":"","sources":["../../../src/structures/ILintPluginConfig.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"IOptionToggle.js","sourceRoot":"","sources":["../../../src/structures/IOptionToggle.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IPlaygroundDependencyProgress } from "./IPlaygroundDependencyProgress";
|
|
2
|
+
/** Options for {@link installPlaygroundDependencies}. */
|
|
3
|
+
export interface IPlaygroundDependencyInstallOptions {
|
|
4
|
+
/** Defaults to `globalThis.fetch`. Override for tests or for offline runs. */
|
|
5
|
+
fetch?: (input: string, init?: RequestInit) => Promise<Response>;
|
|
6
|
+
/** Package names the wasm already has — skip re-installing them. */
|
|
7
|
+
installedPackages?: Iterable<string>;
|
|
8
|
+
/** Package names to never install (preinstalled / built-in). */
|
|
9
|
+
ignoredPackages?: Iterable<string>;
|
|
10
|
+
/** Safety cap: error out after installing this many packages. */
|
|
11
|
+
maxPackages?: number;
|
|
12
|
+
/** Aborts the install when triggered. */
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
/** Fires for each phase transition during the install. */
|
|
15
|
+
onProgress?: (event: IPlaygroundDependencyProgress) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPlaygroundDependencyInstallOptions.js","sourceRoot":"","sources":["../../../src/structures/IPlaygroundDependencyInstallOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IPlaygroundDependencyPackage } from "./IPlaygroundDependencyPackage";
|
|
2
|
+
/** Aggregate result returned by {@link installPlaygroundDependencies}. */
|
|
3
|
+
export interface IPlaygroundDependencyInstallResult {
|
|
4
|
+
packages: IPlaygroundDependencyPackage[];
|
|
5
|
+
/**
|
|
6
|
+
* `node_modules/...` keyed map of files to mount inside the wasm-side
|
|
7
|
+
* compiler MemFS.
|
|
8
|
+
*/
|
|
9
|
+
compilerFiles: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* `file:///node_modules/...` keyed map of `.d.ts` + `package.json` files to
|
|
12
|
+
* register with Monaco via `addExtraLib`.
|
|
13
|
+
*/
|
|
14
|
+
editorLibs: Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Package-rooted runtime files (e.g. `uuid/dist/index.js`) the in-page
|
|
17
|
+
* execute sandbox `require` can resolve.
|
|
18
|
+
*/
|
|
19
|
+
runtimeFiles: Record<string, string>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPlaygroundDependencyInstallResult.js","sourceRoot":"","sources":["../../../src/structures/IPlaygroundDependencyInstallResult.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPlaygroundDependencyPackage.js","sourceRoot":"","sources":["../../../src/structures/IPlaygroundDependencyPackage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IPlaygroundDependencyProgressPhase } from "./IPlaygroundDependencyProgressPhase";
|
|
2
|
+
/** A single progress event emitted while installing playground dependencies. */
|
|
3
|
+
export interface IPlaygroundDependencyProgress {
|
|
4
|
+
phase: IPlaygroundDependencyProgressPhase;
|
|
5
|
+
packageName?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
completed: number;
|
|
8
|
+
total: number;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPlaygroundDependencyProgress.js","sourceRoot":"","sources":["../../../src/structures/IPlaygroundDependencyProgress.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPlaygroundDependencyProgressPhase.js","sourceRoot":"","sources":["../../../src/structures/IPlaygroundDependencyProgressPhase.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"IPlaygroundExample.js","sourceRoot":"","sources":["../../../src/structures/IPlaygroundExample.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { IOptionToggle } from "./IOptionToggle";
|
|
3
|
+
import type { IPlaygroundExample } from "./IPlaygroundExample";
|
|
4
|
+
import type { ITransformOptions } from "./ITransformOptions";
|
|
5
|
+
/**
|
|
6
|
+
* Props for the full playground shell.
|
|
7
|
+
*
|
|
8
|
+
* The shell is intentionally configurable rather than configurable-by-context:
|
|
9
|
+
* every changing field is an explicit prop, so wrappers can spread their own
|
|
10
|
+
* defaults without a Provider in between.
|
|
11
|
+
*/
|
|
12
|
+
export interface IPlaygroundShellProps {
|
|
13
|
+
/** URL of the bundled worker script (rspack output of the site's worker entry). */
|
|
14
|
+
workerUrl: string;
|
|
15
|
+
/** Source code shown on first mount (and on Reset). */
|
|
16
|
+
defaultScript: string;
|
|
17
|
+
/** Examples available in the dropdown. Empty array hides the dropdown. */
|
|
18
|
+
examples?: readonly IPlaygroundExample[];
|
|
19
|
+
/** Display labels for example groups. */
|
|
20
|
+
exampleGroupLabels?: Record<string, string>;
|
|
21
|
+
/** Toggles rendered in the Options modal. Defaults to typia + lint. */
|
|
22
|
+
optionToggles?: readonly IOptionToggle[];
|
|
23
|
+
/** Initial values for the transform options. Defaults to `{typia: true, lint: true}`. */
|
|
24
|
+
defaultOptions?: ITransformOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Static extra .d.ts entries to mount in Monaco (e.g. a pre-packed typia
|
|
27
|
+
* type pack). Merged with dependencies installed at runtime.
|
|
28
|
+
*/
|
|
29
|
+
staticEditorLibs?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Packages the site has already pre-mounted into the wasm. These are
|
|
32
|
+
* skipped by the runtime npm dependency installer.
|
|
33
|
+
*/
|
|
34
|
+
preinstalledPackages?: readonly string[];
|
|
35
|
+
/**
|
|
36
|
+
* Optional execute hook. When provided, the shell renders an "Execute"
|
|
37
|
+
* button; on click it calls `service.bundle(...)` to get the JS and passes
|
|
38
|
+
* it here. The returned messages are appended to the Console pane.
|
|
39
|
+
*
|
|
40
|
+
* `sandbox.runtimeFiles` is the accumulated runtime-file map produced by
|
|
41
|
+
* every `installPlaygroundDependencies` call so far in this session
|
|
42
|
+
* (package-rooted keys like `uuid/dist/index.js`). The site's executeBundle
|
|
43
|
+
* typically merges these on top of its own typia-runtime pack and feeds
|
|
44
|
+
* the union to `createSandboxRequire` — without this channel the in-page
|
|
45
|
+
* Execute sandbox cannot resolve any npm dependency the user installed.
|
|
46
|
+
*
|
|
47
|
+
* When omitted, the Execute UI is hidden.
|
|
48
|
+
*/
|
|
49
|
+
executeBundle?: (code: string, sandbox: {
|
|
50
|
+
console: Record<string, (...args: unknown[]) => void>;
|
|
51
|
+
runtimeFiles: Record<string, string>;
|
|
52
|
+
}) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Brand slot in the toolbar (left side). Renders before the Playground
|
|
55
|
+
* label. Sites typically pass `<a href="/">SiteName</a>`.
|
|
56
|
+
*/
|
|
57
|
+
brand?: ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Caption shown on the result pane when the active tab is "javascript".
|
|
60
|
+
* Defaults to `"dist/playground.js"`. Receives the current transform
|
|
61
|
+
* options so sites can append `· typia disabled` etc.
|
|
62
|
+
*/
|
|
63
|
+
resultCaption?: (options: ITransformOptions) => string;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IPlaygroundShellProps.js","sourceRoot":"","sources":["../../../src/structures/IPlaygroundShellProps.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"ISourceEditorProps.js","sourceRoot":"","sources":["../../../src/structures/ISourceEditorProps.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"ITransformOptions.js","sourceRoot":"","sources":["../../../src/structures/ITransformOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IMemFSHost } from "@ttsc/wasm";
|
|
2
|
+
/** Options for the typia integration of {@link createWorkerCompiler}. */
|
|
3
|
+
export interface ITypiaPluginConfig {
|
|
4
|
+
/** Plugin id registered with `host.Expose` (default: `"typia"`). */
|
|
5
|
+
name?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Module specifier the typia transform receives via
|
|
8
|
+
* `compilerOptions.plugins` (default: `"typia/lib/transform"`).
|
|
9
|
+
*/
|
|
10
|
+
transformModule?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional hook to mount typia source files into the MemFS during boot.
|
|
13
|
+
* The site fetches its pre-built typia pack and writes it under
|
|
14
|
+
* `<workDir>/node_modules/`. `workDir` is forwarded from
|
|
15
|
+
* `createWorkerCompiler` so the mount can honor a non-default project
|
|
16
|
+
* root without the site rewiring the URL.
|
|
17
|
+
*/
|
|
18
|
+
mount?: (host: IMemFSHost, workDir: string) => Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITypiaPluginConfig.js","sourceRoot":"","sources":["../../../src/structures/ITypiaPluginConfig.ts"],"names":[],"mappings":""}
|
|
@@ -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";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./IBuildTsconfigOptions"), exports);
|
|
18
|
+
__exportStar(require("./ICompilerService"), exports);
|
|
19
|
+
__exportStar(require("./IConsoleMessage"), exports);
|
|
20
|
+
__exportStar(require("./ICreateCompilerClientOptions"), exports);
|
|
21
|
+
__exportStar(require("./ICreateWorkerCompilerOptions"), exports);
|
|
22
|
+
__exportStar(require("./IInstallTypiaSourcePackOptions"), exports);
|
|
23
|
+
__exportStar(require("./ILintPluginConfig"), exports);
|
|
24
|
+
__exportStar(require("./IOptionToggle"), exports);
|
|
25
|
+
__exportStar(require("./IPlaygroundDependencyInstallOptions"), exports);
|
|
26
|
+
__exportStar(require("./IPlaygroundDependencyInstallResult"), exports);
|
|
27
|
+
__exportStar(require("./IPlaygroundDependencyPackage"), exports);
|
|
28
|
+
__exportStar(require("./IPlaygroundDependencyProgress"), exports);
|
|
29
|
+
__exportStar(require("./IPlaygroundDependencyProgressPhase"), exports);
|
|
30
|
+
__exportStar(require("./IPlaygroundExample"), exports);
|
|
31
|
+
__exportStar(require("./IPlaygroundShellProps"), exports);
|
|
32
|
+
__exportStar(require("./ISourceEditorProps"), exports);
|
|
33
|
+
__exportStar(require("./ITransformOptions"), exports);
|
|
34
|
+
__exportStar(require("./ITypiaPluginConfig"), exports);
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,qDAAmC;AACnC,oDAAkC;AAClC,iEAA+C;AAC/C,iEAA+C;AAC/C,mEAAiD;AACjD,sDAAoC;AACpC,kDAAgC;AAChC,wEAAsD;AACtD,uEAAqD;AACrD,iEAA+C;AAC/C,kEAAgD;AAChD,uEAAqD;AACrD,uDAAqC;AACrC,0DAAwC;AACxC,uDAAqC;AACrC,sDAAoC;AACpC,uDAAqC"}
|