@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,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Worker-side playground compiler factory.
|
|
3
|
+
//
|
|
4
|
+
// This module ships a ready-to-bind `ICompilerService` implementation. The
|
|
5
|
+
// consumer's worker entry boots the wasm once, builds tsconfig variants for
|
|
6
|
+
// the site's chosen module shape, registers the typia/lint plugin verbs (or
|
|
7
|
+
// the site-provided overrides), and serializes every MemFS-mutating call onto
|
|
8
|
+
// a single chain so concurrent compiles never corrupt each other.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createWorkerCompiler = createWorkerCompiler;
|
|
11
|
+
const wasm_1 = require("@ttsc/wasm");
|
|
12
|
+
const buildTsconfigJSON_1 = require("./buildTsconfigJSON");
|
|
13
|
+
const DEFAULT_ENTRY_FILE_1 = require("./DEFAULT_ENTRY_FILE");
|
|
14
|
+
const DEFAULT_LINT_PLUGIN_NAME_1 = require("./DEFAULT_LINT_PLUGIN_NAME");
|
|
15
|
+
const DEFAULT_TSCONFIG_PATH_1 = require("./DEFAULT_TSCONFIG_PATH");
|
|
16
|
+
const DEFAULT_TYPIA_PLUGIN_NAME_1 = require("./DEFAULT_TYPIA_PLUGIN_NAME");
|
|
17
|
+
const DEFAULT_WORK_DIR_1 = require("./DEFAULT_WORK_DIR");
|
|
18
|
+
const installDependenciesIntoMemFS_1 = require("./installDependenciesIntoMemFS");
|
|
19
|
+
const joinUnder_1 = require("./internal/joinUnder");
|
|
20
|
+
const parseLintDiagnostics_1 = require("./internal/parseLintDiagnostics");
|
|
21
|
+
const safeParseTypiaTransform_1 = require("./internal/safeParseTypiaTransform");
|
|
22
|
+
const mapDiagnostic_1 = require("./mapDiagnostic");
|
|
23
|
+
const normalizeError_1 = require("./normalizeError");
|
|
24
|
+
const pickEmittedJS_1 = require("./pickEmittedJS");
|
|
25
|
+
/**
|
|
26
|
+
* Build an `ICompilerService` ready to register with tgrid's `WorkerServer`.
|
|
27
|
+
*
|
|
28
|
+
* Usage in the worker entry:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { createWorkerCompiler } from "@ttsc/playground";
|
|
32
|
+
* import { WorkerServer } from "tgrid";
|
|
33
|
+
*
|
|
34
|
+
* const service = createWorkerCompiler({
|
|
35
|
+
* wasmUrl: "/compiler/playground.wasm",
|
|
36
|
+
* apiName: "ttscPlayground",
|
|
37
|
+
* typiaPlugin: { mount: installTypiaPack },
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* const main = async () => {
|
|
41
|
+
* const worker = new WorkerServer();
|
|
42
|
+
* await worker.open(service);
|
|
43
|
+
* };
|
|
44
|
+
* void main();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function createWorkerCompiler(options) {
|
|
48
|
+
const workDir = options.workDir ?? DEFAULT_WORK_DIR_1.DEFAULT_WORK_DIR;
|
|
49
|
+
const tsconfigPath = options.tsconfigPath ?? DEFAULT_TSCONFIG_PATH_1.DEFAULT_TSCONFIG_PATH;
|
|
50
|
+
const entryFile = options.entryFile ?? DEFAULT_ENTRY_FILE_1.DEFAULT_ENTRY_FILE;
|
|
51
|
+
const typiaPlugin = options.typiaPlugin === false ? null : (options.typiaPlugin ?? {});
|
|
52
|
+
const typiaPluginName = typiaPlugin?.name ?? DEFAULT_TYPIA_PLUGIN_NAME_1.DEFAULT_TYPIA_PLUGIN_NAME;
|
|
53
|
+
const typiaTransformModule = typiaPlugin?.transformModule ?? "typia/lib/transform";
|
|
54
|
+
const lintPlugin = options.lintPlugin === false ? null : (options.lintPlugin ?? {});
|
|
55
|
+
const lintPluginName = lintPlugin?.name ?? DEFAULT_LINT_PLUGIN_NAME_1.DEFAULT_LINT_PLUGIN_NAME;
|
|
56
|
+
// tsconfig variants. ESM for the "Compiled JS" preview lane, CommonJS for
|
|
57
|
+
// the bundle/Execute lane (whose `new Function` driver expects CJS).
|
|
58
|
+
const tsconfigPlugins = typiaPlugin
|
|
59
|
+
? [{ transform: typiaTransformModule }]
|
|
60
|
+
: [];
|
|
61
|
+
const extraCompilerOptions = {
|
|
62
|
+
...(options.extraCompilerOptions ?? {}),
|
|
63
|
+
...(tsconfigPlugins.length > 0 ? { plugins: tsconfigPlugins } : {}),
|
|
64
|
+
};
|
|
65
|
+
const tsconfigESM = (0, buildTsconfigJSON_1.buildTsconfigJSON)({
|
|
66
|
+
module: "ESNext",
|
|
67
|
+
compilerOptions: extraCompilerOptions,
|
|
68
|
+
});
|
|
69
|
+
const tsconfigCJS = (0, buildTsconfigJSON_1.buildTsconfigJSON)({
|
|
70
|
+
module: "CommonJS",
|
|
71
|
+
compilerOptions: extraCompilerOptions,
|
|
72
|
+
});
|
|
73
|
+
// Cache the boot promise across calls. If the boot rejects we clear the
|
|
74
|
+
// cache so the next call retries — otherwise every later compile/bundle/
|
|
75
|
+
// lint would replay the same rejection forever (page reload required).
|
|
76
|
+
// Mirrors the createCompilerClient (UI-side) pattern.
|
|
77
|
+
let boot = null;
|
|
78
|
+
function getBoot() {
|
|
79
|
+
if (boot)
|
|
80
|
+
return boot;
|
|
81
|
+
boot = (async () => {
|
|
82
|
+
const result = await (0, wasm_1.bootTtsc)({
|
|
83
|
+
wasmUrl: options.wasmUrl,
|
|
84
|
+
wasmExecUrl: options.wasmExecUrl,
|
|
85
|
+
apiName: options.apiName,
|
|
86
|
+
});
|
|
87
|
+
if (typiaPlugin?.mount)
|
|
88
|
+
await typiaPlugin.mount(result.host, workDir);
|
|
89
|
+
return result;
|
|
90
|
+
})().catch((err) => {
|
|
91
|
+
boot = null;
|
|
92
|
+
throw err;
|
|
93
|
+
});
|
|
94
|
+
return boot;
|
|
95
|
+
}
|
|
96
|
+
// Serialize every MemFS-mutating call. tgrid queues incoming messages, but
|
|
97
|
+
// the wasm-side host runs them concurrently — a fast keystroke could
|
|
98
|
+
// interleave a bundle's tsconfig rewrite with a lint pass and corrupt
|
|
99
|
+
// either result. The chain keeps compile/bundle/lint linear.
|
|
100
|
+
let busy = Promise.resolve();
|
|
101
|
+
const enqueue = (fn) => {
|
|
102
|
+
const next = busy.then(fn, fn);
|
|
103
|
+
busy = next.catch(() => { });
|
|
104
|
+
return next;
|
|
105
|
+
};
|
|
106
|
+
const projectFiles = (source, tsconfigText) => ({
|
|
107
|
+
[`${workDir}/${tsconfigPath}`]: tsconfigText,
|
|
108
|
+
[`${workDir}/${entryFile}`]: source,
|
|
109
|
+
});
|
|
110
|
+
const writeProject = (host, files) => {
|
|
111
|
+
for (const [path, text] of Object.entries(files)) {
|
|
112
|
+
host.writeFile(path, text);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
// Typia transform — run the registered typia plugin's `transform` verb,
|
|
116
|
+
// parse its JSON stdout, and write the rewritten TS back into MemFS so the
|
|
117
|
+
// subsequent `api.build` sees the post-transform text.
|
|
118
|
+
const applyTypiaTransform = async (api, host) => {
|
|
119
|
+
if (!typiaPlugin)
|
|
120
|
+
return;
|
|
121
|
+
try {
|
|
122
|
+
const raw = await api.plugin({
|
|
123
|
+
name: typiaPluginName,
|
|
124
|
+
command: "transform",
|
|
125
|
+
cwd: workDir,
|
|
126
|
+
tsconfig: tsconfigPath,
|
|
127
|
+
output: "ts",
|
|
128
|
+
});
|
|
129
|
+
if (!raw.stdout)
|
|
130
|
+
return;
|
|
131
|
+
const transformed = (0, safeParseTypiaTransform_1.safeParseTypiaTransform)(raw.stdout);
|
|
132
|
+
if (!transformed)
|
|
133
|
+
return;
|
|
134
|
+
for (const [rel, text] of Object.entries(transformed.typescript)) {
|
|
135
|
+
host.writeFile((0, joinUnder_1.joinUnder)(workDir, rel), text);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Swallow plugin spawn / JSON parse failures so the user still sees the
|
|
140
|
+
// tsgo compile diagnostics from the subsequent build call. Real
|
|
141
|
+
// user-facing errors (e.g. typia rule violations) flow through the
|
|
142
|
+
// wasm-side diagnostics path.
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const runBuildPipeline = async (source, runTypia, tsconfigText) => {
|
|
146
|
+
try {
|
|
147
|
+
const { api, host } = await getBoot();
|
|
148
|
+
writeProject(host, projectFiles(source, tsconfigText));
|
|
149
|
+
if (runTypia)
|
|
150
|
+
await applyTypiaTransform(api, host);
|
|
151
|
+
const raw = await api.build({
|
|
152
|
+
cwd: workDir,
|
|
153
|
+
tsconfig: tsconfigPath,
|
|
154
|
+
});
|
|
155
|
+
if (raw.code !== 0 && !raw.result) {
|
|
156
|
+
return {
|
|
157
|
+
type: "error",
|
|
158
|
+
target: "javascript",
|
|
159
|
+
value: {
|
|
160
|
+
message: raw.stderr || "ttsc: build failed without a result payload",
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const parsed = (0, wasm_1.parseResult)(raw);
|
|
165
|
+
if (!parsed) {
|
|
166
|
+
return {
|
|
167
|
+
type: "error",
|
|
168
|
+
target: "javascript",
|
|
169
|
+
value: { message: "ttsc: result JSON could not be parsed" },
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const diagnostics = (parsed.diagnostics ?? []).map((d) => (0, mapDiagnostic_1.mapDiagnostic)(d, source));
|
|
173
|
+
const js = (0, pickEmittedJS_1.pickEmittedJS)(parsed.output ?? {}, entryFile);
|
|
174
|
+
const errors = diagnostics.filter((d) => d.severity === "error");
|
|
175
|
+
if (errors.length > 0) {
|
|
176
|
+
return {
|
|
177
|
+
type: "failure",
|
|
178
|
+
target: "javascript",
|
|
179
|
+
value: js ?? "",
|
|
180
|
+
diagnostics,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return { type: "success", target: "javascript", value: js ?? "" };
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
return {
|
|
187
|
+
type: "error",
|
|
188
|
+
target: "javascript",
|
|
189
|
+
value: (0, normalizeError_1.normalizeError)(error),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
// Lint pipeline. The lint plugin emits tsgo-style pretty diagnostics on
|
|
194
|
+
// stderr; we parse those lines back into IDiagnostic so the UI can render
|
|
195
|
+
// them in the Lint tab.
|
|
196
|
+
const runLintPipeline = async (source) => {
|
|
197
|
+
if (!lintPlugin)
|
|
198
|
+
return { diagnostics: [] };
|
|
199
|
+
try {
|
|
200
|
+
const { api, host } = await getBoot();
|
|
201
|
+
writeProject(host, projectFiles(source, tsconfigESM));
|
|
202
|
+
const raw = await api.plugin({
|
|
203
|
+
name: lintPluginName,
|
|
204
|
+
command: "check",
|
|
205
|
+
cwd: workDir,
|
|
206
|
+
tsconfig: tsconfigPath,
|
|
207
|
+
});
|
|
208
|
+
return { diagnostics: (0, parseLintDiagnostics_1.parseLintDiagnostics)(raw.stderr, source) };
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return { diagnostics: [] };
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
return {
|
|
215
|
+
installDependencies: (props) => enqueue(async () => {
|
|
216
|
+
const { host } = await getBoot();
|
|
217
|
+
return (0, installDependenciesIntoMemFS_1.installDependenciesIntoMemFS)(host, workDir, props);
|
|
218
|
+
}),
|
|
219
|
+
compile: (props) => enqueue(() => runBuildPipeline(props.source, shouldRunTypia(props.options), tsconfigESM)),
|
|
220
|
+
bundle: (props) => enqueue(() => runBuildPipeline(props.source, shouldRunTypia(props.options), tsconfigCJS)),
|
|
221
|
+
lint: (props) => enqueue(() => runLintPipeline(props.source)),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function shouldRunTypia(options) {
|
|
225
|
+
return options?.typia !== false;
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=createWorkerCompiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWorkerCompiler.js","sourceRoot":"","sources":["../../../src/compiler/createWorkerCompiler.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,kEAAkE;;;AAElE,qCAKoB;AAKpB,2DAAwD;AACxD,6DAA0D;AAC1D,yEAAsE;AACtE,mEAAgE;AAChE,2EAAwE;AACxE,yDAAsD;AACtD,iFAA8E;AAC9E,oDAAiD;AACjD,0EAAuE;AACvE,gFAA6E;AAC7E,mDAAgD;AAChD,qDAAkD;AAClD,mDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8BACE,OAAqC;IAErC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,mCAAgB,CAAC;IACpD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,6CAAqB,CAAC;IACnE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,uCAAkB,CAAC;IAE1D,MAAM,WAAW,GACf,OAAO,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;IACrE,MAAM,eAAe,GAAG,WAAW,EAAE,IAAI,IAAI,qDAAyB,CAAC;IACvE,MAAM,oBAAoB,GACxB,WAAW,EAAE,eAAe,IAAI,qBAAqB,CAAC;IAExD,MAAM,UAAU,GACd,OAAO,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACnE,MAAM,cAAc,GAAG,UAAU,EAAE,IAAI,IAAI,mDAAwB,CAAC;IAEpE,0EAA0E;IAC1E,qEAAqE;IACrE,MAAM,eAAe,G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C,MAAM,CAAC,CAAC;KAC9D,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAA2B;IACjD,OAAO,OAAO,EAAE,KAAK,KAAK,KAAK,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IMemFSHost } from "@ttsc/wasm";
|
|
2
|
+
import type { ICompilerService } from "../structures/ICompilerService";
|
|
3
|
+
/**
|
|
4
|
+
* Mount external npm package files into the worker's MemFS under
|
|
5
|
+
* `<workDir>/node_modules/...`.
|
|
6
|
+
*
|
|
7
|
+
* Used by `createWorkerCompiler` to implement the `installDependencies` verb
|
|
8
|
+
* of `ICompilerService`. The dependency installer (UI side) feeds keys like
|
|
9
|
+
* `node_modules/uuid/dist/index.js`; we normalize, sanity-check, and copy
|
|
10
|
+
* each entry under the project root.
|
|
11
|
+
*/
|
|
12
|
+
export declare function installDependenciesIntoMemFS(host: IMemFSHost, workDir: string, props: ICompilerService.IInstallDependenciesProps): ICompilerService.IInstallDependenciesResult;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installDependenciesIntoMemFS = installDependenciesIntoMemFS;
|
|
4
|
+
const normalizeNodeModulePath_1 = require("./normalizeNodeModulePath");
|
|
5
|
+
/**
|
|
6
|
+
* Mount external npm package files into the worker's MemFS under
|
|
7
|
+
* `<workDir>/node_modules/...`.
|
|
8
|
+
*
|
|
9
|
+
* Used by `createWorkerCompiler` to implement the `installDependencies` verb
|
|
10
|
+
* of `ICompilerService`. The dependency installer (UI side) feeds keys like
|
|
11
|
+
* `node_modules/uuid/dist/index.js`; we normalize, sanity-check, and copy
|
|
12
|
+
* each entry under the project root.
|
|
13
|
+
*/
|
|
14
|
+
function installDependenciesIntoMemFS(host, workDir, props) {
|
|
15
|
+
let fileCount = 0;
|
|
16
|
+
for (const [rel, text] of Object.entries(props.files)) {
|
|
17
|
+
const normalized = (0, normalizeNodeModulePath_1.normalizeNodeModulePath)(rel);
|
|
18
|
+
if (!normalized)
|
|
19
|
+
continue;
|
|
20
|
+
host.writeFile(`${workDir}/${normalized}`, text);
|
|
21
|
+
fileCount++;
|
|
22
|
+
}
|
|
23
|
+
return { installed: props.packages, fileCount };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=installDependenciesIntoMemFS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installDependenciesIntoMemFS.js","sourceRoot":"","sources":["../../../src/compiler/installDependenciesIntoMemFS.ts"],"names":[],"mappings":";;;AAGA,uEAAoE;AAEpE;;;;;;;;GAQG;AACH,sCACE,IAAgB,EAChB,OAAe,EACf,KAAiD;IAEjD,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,UAAU,GAAG,IAAA,iDAAuB,EAAC,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU;YAAE,SAAS;QAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO,IAAI,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;QACjD,SAAS,EAAE,CAAC;IACd,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IMemFSHost } from "@ttsc/wasm";
|
|
2
|
+
import type { IInstallTypiaSourcePackOptions } from "../structures/IInstallTypiaSourcePackOptions";
|
|
3
|
+
/**
|
|
4
|
+
* Mounts typia + @typia/* source trees into the in-browser MemFS so the
|
|
5
|
+
* wasm-side compiler can resolve `import typia, { tags } from "typia"`
|
|
6
|
+
* against the same code the published package uses.
|
|
7
|
+
*
|
|
8
|
+
* Idempotent on the same host (re-writing the same paths is a no-op for the
|
|
9
|
+
* MemFS implementation).
|
|
10
|
+
*/
|
|
11
|
+
export declare function installTypiaSourcePack(host: IMemFSHost, options: IInstallTypiaSourcePackOptions): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.installTypiaSourcePack = installTypiaSourcePack;
|
|
4
|
+
const loadTypiaSourcePack_1 = require("./loadTypiaSourcePack");
|
|
5
|
+
/**
|
|
6
|
+
* Mounts typia + @typia/* source trees into the in-browser MemFS so the
|
|
7
|
+
* wasm-side compiler can resolve `import typia, { tags } from "typia"`
|
|
8
|
+
* against the same code the published package uses.
|
|
9
|
+
*
|
|
10
|
+
* Idempotent on the same host (re-writing the same paths is a no-op for the
|
|
11
|
+
* MemFS implementation).
|
|
12
|
+
*/
|
|
13
|
+
async function installTypiaSourcePack(host, options) {
|
|
14
|
+
const mountRoot = options.mountRoot ?? "/work/node_modules";
|
|
15
|
+
const pack = await (0, loadTypiaSourcePack_1.loadTypiaSourcePack)(options);
|
|
16
|
+
host.mkdirp(mountRoot);
|
|
17
|
+
for (const [rel, content] of Object.entries(pack)) {
|
|
18
|
+
host.writeFile(`${mountRoot}/${rel}`, content);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=installTypiaSourcePack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installTypiaSourcePack.js","sourceRoot":"","sources":["../../../src/compiler/installTypiaSourcePack.ts"],"names":[],"mappings":";;;AAGA,+DAA4D;AAE5D;;;;;;;GAOG;AACI,KAAK,iCACV,IAAgB,EAChB,OAAuC;IAEvC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,oBAAoB,CAAC;IAC5D,MAAM,IAAI,GAAG,MAAM,IAAA,yCAAmB,EAAC,OAAO,CAAC,CAAC;IAChD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvB,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS,IAAI,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinUnder = joinUnder;
|
|
4
|
+
/** Join a relative path under a base directory, ignoring base when `rel` is absolute. */
|
|
5
|
+
function joinUnder(base, rel) {
|
|
6
|
+
if (rel.startsWith("/"))
|
|
7
|
+
return rel;
|
|
8
|
+
return `${base}/${rel}`;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=joinUnder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joinUnder.js","sourceRoot":"","sources":["../../../../src/compiler/internal/joinUnder.ts"],"names":[],"mappings":";;;AAAA,yFAAyF;AACzF,mBAA0B,IAAY,EAAE,GAAW;IACjD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACpC,OAAO,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ICompilerService } from "../../structures/ICompilerService";
|
|
2
|
+
/**
|
|
3
|
+
* Parse the lint plugin's stderr (tsgo-style pretty diagnostics) into the
|
|
4
|
+
* playground's normalized diagnostic shape.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseLintDiagnostics(stderr: string, source: string): ICompilerService.IDiagnostic[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLintDiagnostics = parseLintDiagnostics;
|
|
4
|
+
// Match `file:line:col - severity TS<code>: [rule-name] message` lines from
|
|
5
|
+
// tsgo's pretty diagnostic renderer. ANSI color escapes are stripped first
|
|
6
|
+
// so the matcher works on the exact text rendered in the Lint tab.
|
|
7
|
+
const LINT_LINE_REGEXP = /([^\s:]+):(\d+):(\d+)\s+-\s+(error|warning)\s+TS(\d+):\s+(?:\[([^\]]+)\]\s+)?(.*)$/;
|
|
8
|
+
// Strip real ANSI SGR sequences, which always start with ESC (0x1b). The
|
|
9
|
+
// leading ESC byte is required — `/\[[0-9;]*m/g` would also chew innocuous
|
|
10
|
+
// substrings like "[m" or "[0;1m" inside diagnostic messages, and would
|
|
11
|
+
// fail to actually strip the ESC bytes tsgo writes, leaving the
|
|
12
|
+
// LINT_LINE_REGEXP unable to anchor on the filename column.
|
|
13
|
+
const ANSI_REGEXP = /\x1b\[[0-9;]*m/g;
|
|
14
|
+
/**
|
|
15
|
+
* Parse the lint plugin's stderr (tsgo-style pretty diagnostics) into the
|
|
16
|
+
* playground's normalized diagnostic shape.
|
|
17
|
+
*/
|
|
18
|
+
function parseLintDiagnostics(stderr, source) {
|
|
19
|
+
const stripped = stderr.replace(ANSI_REGEXP, "");
|
|
20
|
+
const lines = stripped.split(/\r?\n/);
|
|
21
|
+
const out = [];
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
const m = line.match(LINT_LINE_REGEXP);
|
|
24
|
+
if (!m)
|
|
25
|
+
continue;
|
|
26
|
+
const [, , lineStr, colStr, sev, codeStr, rule, message] = m;
|
|
27
|
+
const lineNum = Number(lineStr);
|
|
28
|
+
const colNum = Number(colStr);
|
|
29
|
+
if (!Number.isFinite(lineNum) || !Number.isFinite(colNum))
|
|
30
|
+
continue;
|
|
31
|
+
out.push({
|
|
32
|
+
line: lineNum,
|
|
33
|
+
column: colNum,
|
|
34
|
+
length: lengthOfTokenAt(source, lineNum, colNum) ?? 1,
|
|
35
|
+
severity: sev === "warning" ? "warning" : "error",
|
|
36
|
+
message: rule ? `[${rule}] ${message ?? ""}` : (message ?? ""),
|
|
37
|
+
code: `TS${codeStr ?? ""}`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Best-effort length of the identifier-like token starting at (`line`, `column`)
|
|
44
|
+
* in `source`. Falls back to 1 when no token is found.
|
|
45
|
+
*/
|
|
46
|
+
function lengthOfTokenAt(source, line, column) {
|
|
47
|
+
const lines = source.split(/\r?\n/);
|
|
48
|
+
if (line < 1 || line > lines.length)
|
|
49
|
+
return null;
|
|
50
|
+
const text = lines[line - 1] ?? "";
|
|
51
|
+
const start = Math.max(0, column - 1);
|
|
52
|
+
const match = text.slice(start).match(/^[\w$]+/);
|
|
53
|
+
if (!match)
|
|
54
|
+
return null;
|
|
55
|
+
return match[0].length;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=parseLintDiagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseLintDiagnostics.js","sourceRoot":"","sources":["../../../../src/compiler/internal/parseLintDiagnostics.ts"],"names":[],"mappings":";;;AAEA,4EAA4E;AAC5E,2EAA2E;AAC3E,mEAAmE;AACnE,MAAM,gBAAgB,GACpB,oFAAoF,CAAC;AACvF,yEAAyE;AACzE,2EAA2E;AAC3E,wEAAwE;AACxE,gEAAgE;AAChE,4DAA4D;AAC5D,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC;;;GAGG;AACH,8BACE,MAAc,EACd,MAAc;IAEd,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,GAAG,GAAmC,EAAE,CAAC;IAC/C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;Q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MAAM,GAAG,CAAC,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Shape of the typia transform plugin's stdout JSON payload. */
|
|
2
|
+
export interface ITypiaTransformOutput {
|
|
3
|
+
diagnostics?: unknown;
|
|
4
|
+
typescript: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Parse the typia transform plugin's stdout into the expected shape.
|
|
8
|
+
* Returns null on any parse / shape mismatch — the caller treats null as
|
|
9
|
+
* "transform produced no usable output".
|
|
10
|
+
*/
|
|
11
|
+
export declare function safeParseTypiaTransform(text: string): ITypiaTransformOutput | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeParseTypiaTransform = safeParseTypiaTransform;
|
|
4
|
+
/**
|
|
5
|
+
* Parse the typia transform plugin's stdout into the expected shape.
|
|
6
|
+
* Returns null on any parse / shape mismatch — the caller treats null as
|
|
7
|
+
* "transform produced no usable output".
|
|
8
|
+
*/
|
|
9
|
+
function safeParseTypiaTransform(text) {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(text);
|
|
12
|
+
if (parsed && typeof parsed === "object" && parsed.typescript) {
|
|
13
|
+
return parsed;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=safeParseTypiaTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeParseTypiaTransform.js","sourceRoot":"","sources":["../../../../src/compiler/internal/safeParseTypiaTransform.ts"],"names":[],"mappings":";;;AAMA;;;;GAIG;AACH,iCACE,IAAY;IAEZ,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA0B,CAAC;QACzD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YAC9D,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lineColumnOf = lineColumnOf;
|
|
4
|
+
/** Compute 1-based line/column for a 0-based char offset into `source`. */
|
|
5
|
+
function lineColumnOf(source, start) {
|
|
6
|
+
if (typeof start !== "number" || start < 0)
|
|
7
|
+
return { line: 1, column: 1 };
|
|
8
|
+
const slice = source.slice(0, Math.min(start, source.length));
|
|
9
|
+
const newlines = slice.match(/\n/g);
|
|
10
|
+
const line = newlines ? newlines.length + 1 : 1;
|
|
11
|
+
const lastNewline = slice.lastIndexOf("\n");
|
|
12
|
+
const column = lastNewline === -1 ? slice.length + 1 : slice.length - lastNewline;
|
|
13
|
+
return { line, column };
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=lineColumnOf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineColumnOf.js","sourceRoot":"","sources":["../../../src/compiler/lineColumnOf.ts"],"names":[],"mappings":";;;AAAA,2EAA2E;AAC3E,sBACE,MAAc,EACd,KAAyB;IAEzB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,MAAM,GACV,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;IACrE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IInstallTypiaSourcePackOptions } from "../structures/IInstallTypiaSourcePackOptions";
|
|
2
|
+
/**
|
|
3
|
+
* Fetch the typia source pack JSON. Cached per URL across calls. On
|
|
4
|
+
* rejection the cache entry is cleared so the next call retries —
|
|
5
|
+
* otherwise a transient fetch failure during the first boot would wedge
|
|
6
|
+
* every later boot through `getBoot`'s typiaPlugin.mount path.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadTypiaSourcePack(options: IInstallTypiaSourcePackOptions): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadTypiaSourcePack = loadTypiaSourcePack;
|
|
4
|
+
const packCache = new Map();
|
|
5
|
+
/**
|
|
6
|
+
* Fetch the typia source pack JSON. Cached per URL across calls. On
|
|
7
|
+
* rejection the cache entry is cleared so the next call retries —
|
|
8
|
+
* otherwise a transient fetch failure during the first boot would wedge
|
|
9
|
+
* every later boot through `getBoot`'s typiaPlugin.mount path.
|
|
10
|
+
*/
|
|
11
|
+
function loadTypiaSourcePack(options) {
|
|
12
|
+
const cached = packCache.get(options.url);
|
|
13
|
+
if (cached)
|
|
14
|
+
return cached;
|
|
15
|
+
const fetchImpl = options.fetch ?? globalThis.fetch?.bind(globalThis);
|
|
16
|
+
if (!fetchImpl) {
|
|
17
|
+
throw new Error("loadTypiaSourcePack: no fetch implementation available in this environment.");
|
|
18
|
+
}
|
|
19
|
+
const url = options.url;
|
|
20
|
+
const promise = (async () => {
|
|
21
|
+
const response = await fetchImpl(url);
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
throw new Error(`loadTypiaSourcePack: failed to fetch ${url}: ${response.status}`);
|
|
24
|
+
}
|
|
25
|
+
return (await response.json());
|
|
26
|
+
})().catch((err) => {
|
|
27
|
+
packCache.delete(url);
|
|
28
|
+
throw err;
|
|
29
|
+
});
|
|
30
|
+
packCache.set(url, promise);
|
|
31
|
+
return promise;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=loadTypiaSourcePack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadTypiaSourcePack.js","sourceRoot":"","sources":["../../../src/compiler/loadTypiaSourcePack.ts"],"names":[],"mappings":";;;AAEA,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2C,CAAC;AAErE;;;;;GAKG;AACH,6BACE,OAAuC;IAEvC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1C,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACtE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACxB,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE;QAC1B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,wCAAwC,GAAG,KAAK,QAAQ,CAAC,MAAM,EAAE,CAClE,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA2B,CAAC;IAC3D,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACjB,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACtB,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ITtscCompileResult } from "@ttsc/wasm";
|
|
2
|
+
import type { ICompilerService } from "../structures/ICompilerService";
|
|
3
|
+
/**
|
|
4
|
+
* Convert a `@ttsc/wasm` diagnostic into the playground's normalized shape.
|
|
5
|
+
*
|
|
6
|
+
* Falls back to computing line/column from the source text when the wasm
|
|
7
|
+
* diagnostic did not carry them (some plugin emitters drop them).
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapDiagnostic(diag: NonNullable<ITtscCompileResult["diagnostics"]>[number], source: string): ICompilerService.IDiagnostic;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapDiagnostic = mapDiagnostic;
|
|
4
|
+
const lineColumnOf_1 = require("./lineColumnOf");
|
|
5
|
+
/**
|
|
6
|
+
* Convert a `@ttsc/wasm` diagnostic into the playground's normalized shape.
|
|
7
|
+
*
|
|
8
|
+
* Falls back to computing line/column from the source text when the wasm
|
|
9
|
+
* diagnostic did not carry them (some plugin emitters drop them).
|
|
10
|
+
*/
|
|
11
|
+
function mapDiagnostic(diag, source) {
|
|
12
|
+
const fallback = (0, lineColumnOf_1.lineColumnOf)(source, diag.start);
|
|
13
|
+
return {
|
|
14
|
+
line: diag.line && diag.line > 0 ? diag.line : fallback.line,
|
|
15
|
+
column: diag.character && diag.character > 0 ? diag.character : fallback.column,
|
|
16
|
+
length: typeof diag.length === "number" ? diag.length : 1,
|
|
17
|
+
severity: diag.category === "warning" ? "warning" : "error",
|
|
18
|
+
message: diag.messageText,
|
|
19
|
+
code: typeof diag.code === "number" ? `TS${diag.code}` : String(diag.code),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=mapDiagnostic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapDiagnostic.js","sourceRoot":"","sources":["../../../src/compiler/mapDiagnostic.ts"],"names":[],"mappings":";;;AAGA,iDAA8C;AAE9C;;;;;GAKG;AACH,uBACE,IAA4D,EAC5D,MAAc;IAEd,MAAM,QAAQ,GAAG,IAAA,2BAAY,EAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAClD,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI;QAC5D,MAAM,EACJ,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM;QACzE,MAAM,EAAE,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACzD,QAAQ,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;QAC3D,OAAO,EAAE,IAAI,CAAC,WAAW;QACzB,IAAI,EAAE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;KAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeError = normalizeError;
|
|
4
|
+
/** Best-effort error normalization for tgrid transport. */
|
|
5
|
+
function normalizeError(error) {
|
|
6
|
+
if (error instanceof Error)
|
|
7
|
+
return { name: error.name, message: error.message, stack: error.stack };
|
|
8
|
+
if (error &&
|
|
9
|
+
typeof error === "object" &&
|
|
10
|
+
"message" in error)
|
|
11
|
+
return error;
|
|
12
|
+
return { name: "Error", message: String(error) };
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=normalizeError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeError.js","sourceRoot":"","sources":["../../../src/compiler/normalizeError.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,wBAA+B,KAAc;IAC3C,IAAI,KAAK,YAAY,KAAK;QACxB,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1E,IACE,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,SAAS,IAAK,KAAiC;QAE/C,OAAO,KAAK,CAAC;IACf,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accept either `node_modules/...` or `/node_modules/...` (or backslash
|
|
3
|
+
* variants); reject anything that escapes the node_modules root via `..`.
|
|
4
|
+
*
|
|
5
|
+
* Returns `null` for paths that don't match the expected shape — the caller
|
|
6
|
+
* skips those entries instead of writing them to the MemFS.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeNodeModulePath(path: string): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeNodeModulePath = normalizeNodeModulePath;
|
|
4
|
+
/**
|
|
5
|
+
* Accept either `node_modules/...` or `/node_modules/...` (or backslash
|
|
6
|
+
* variants); reject anything that escapes the node_modules root via `..`.
|
|
7
|
+
*
|
|
8
|
+
* Returns `null` for paths that don't match the expected shape — the caller
|
|
9
|
+
* skips those entries instead of writing them to the MemFS.
|
|
10
|
+
*/
|
|
11
|
+
function normalizeNodeModulePath(path) {
|
|
12
|
+
const normalized = path.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
13
|
+
if (!normalized.startsWith("node_modules/"))
|
|
14
|
+
return null;
|
|
15
|
+
if (normalized.split("/").some((segment) => segment === ".."))
|
|
16
|
+
return null;
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=normalizeNodeModulePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeNodeModulePath.js","sourceRoot":"","sources":["../../../src/compiler/normalizeNodeModulePath.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,iCAAwC,IAAY;IAClD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3E,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pick the most likely emitted JavaScript file from a compile result's output
|
|
3
|
+
* map. Tries common paths first, then falls back to the first `.js` entry.
|
|
4
|
+
* Returns null when no `.js` was emitted.
|
|
5
|
+
*/
|
|
6
|
+
export declare function pickEmittedJS(output: Record<string, string>, entryFile: string): string | null;
|