@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.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +191 -0
  3. package/lib/src/compiler/DEFAULT_ENTRY_FILE.d.ts +2 -0
  4. package/lib/src/compiler/DEFAULT_ENTRY_FILE.js +6 -0
  5. package/lib/src/compiler/DEFAULT_ENTRY_FILE.js.map +1 -0
  6. package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.d.ts +5 -0
  7. package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.js +9 -0
  8. package/lib/src/compiler/DEFAULT_LINT_PLUGIN_NAME.js.map +1 -0
  9. package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.d.ts +19 -0
  10. package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.js +23 -0
  11. package/lib/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.js.map +1 -0
  12. package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.d.ts +2 -0
  13. package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.js +6 -0
  14. package/lib/src/compiler/DEFAULT_TSCONFIG_PATH.js.map +1 -0
  15. package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.d.ts +6 -0
  16. package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.js +10 -0
  17. package/lib/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.js.map +1 -0
  18. package/lib/src/compiler/DEFAULT_WORK_DIR.d.ts +2 -0
  19. package/lib/src/compiler/DEFAULT_WORK_DIR.js +6 -0
  20. package/lib/src/compiler/DEFAULT_WORK_DIR.js.map +1 -0
  21. package/lib/src/compiler/buildTsconfigJSON.d.ts +9 -0
  22. package/lib/src/compiler/buildTsconfigJSON.js +24 -0
  23. package/lib/src/compiler/buildTsconfigJSON.js.map +1 -0
  24. package/lib/src/compiler/createTypiaSourcePackMount.d.ts +11 -0
  25. package/lib/src/compiler/createTypiaSourcePackMount.js +29 -0
  26. package/lib/src/compiler/createTypiaSourcePackMount.js.map +1 -0
  27. package/lib/src/compiler/createWorkerCompiler.d.ts +25 -0
  28. package/lib/src/compiler/createWorkerCompiler.js +227 -0
  29. package/lib/src/compiler/createWorkerCompiler.js.map +1 -0
  30. package/lib/src/compiler/installDependenciesIntoMemFS.d.ts +12 -0
  31. package/lib/src/compiler/installDependenciesIntoMemFS.js +25 -0
  32. package/lib/src/compiler/installDependenciesIntoMemFS.js.map +1 -0
  33. package/lib/src/compiler/installTypiaSourcePack.d.ts +11 -0
  34. package/lib/src/compiler/installTypiaSourcePack.js +21 -0
  35. package/lib/src/compiler/installTypiaSourcePack.js.map +1 -0
  36. package/lib/src/compiler/internal/joinUnder.d.ts +5 -0
  37. package/lib/src/compiler/internal/joinUnder.js +13 -0
  38. package/lib/src/compiler/internal/joinUnder.js.map +1 -0
  39. package/lib/src/compiler/internal/parseLintDiagnostics.d.ts +6 -0
  40. package/lib/src/compiler/internal/parseLintDiagnostics.js +57 -0
  41. package/lib/src/compiler/internal/parseLintDiagnostics.js.map +1 -0
  42. package/lib/src/compiler/internal/safeParseTypiaTransform.d.ts +11 -0
  43. package/lib/src/compiler/internal/safeParseTypiaTransform.js +21 -0
  44. package/lib/src/compiler/internal/safeParseTypiaTransform.js.map +1 -0
  45. package/lib/src/compiler/lineColumnOf.d.ts +5 -0
  46. package/lib/src/compiler/lineColumnOf.js +15 -0
  47. package/lib/src/compiler/lineColumnOf.js.map +1 -0
  48. package/lib/src/compiler/loadTypiaSourcePack.d.ts +8 -0
  49. package/lib/src/compiler/loadTypiaSourcePack.js +33 -0
  50. package/lib/src/compiler/loadTypiaSourcePack.js.map +1 -0
  51. package/lib/src/compiler/mapDiagnostic.d.ts +9 -0
  52. package/lib/src/compiler/mapDiagnostic.js +22 -0
  53. package/lib/src/compiler/mapDiagnostic.js.map +1 -0
  54. package/lib/src/compiler/normalizeError.d.ts +2 -0
  55. package/lib/src/compiler/normalizeError.js +14 -0
  56. package/lib/src/compiler/normalizeError.js.map +1 -0
  57. package/lib/src/compiler/normalizeNodeModulePath.d.ts +8 -0
  58. package/lib/src/compiler/normalizeNodeModulePath.js +19 -0
  59. package/lib/src/compiler/normalizeNodeModulePath.js.map +1 -0
  60. package/lib/src/compiler/pickEmittedJS.d.ts +6 -0
  61. package/lib/src/compiler/pickEmittedJS.js +21 -0
  62. package/lib/src/compiler/pickEmittedJS.js.map +1 -0
  63. package/lib/src/index.d.ts +47 -0
  64. package/lib/src/index.js +104 -0
  65. package/lib/src/index.js.map +1 -0
  66. package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.d.ts +6 -0
  67. package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.js +15 -0
  68. package/lib/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.js.map +1 -0
  69. package/lib/src/npm/collectExternalPackageNames.d.ts +5 -0
  70. package/lib/src/npm/collectExternalPackageNames.js +34 -0
  71. package/lib/src/npm/collectExternalPackageNames.js.map +1 -0
  72. package/lib/src/npm/installPlaygroundDependencies.d.ts +13 -0
  73. package/lib/src/npm/installPlaygroundDependencies.js +121 -0
  74. package/lib/src/npm/installPlaygroundDependencies.js.map +1 -0
  75. package/lib/src/npm/internal/npmRegistry.d.ts +57 -0
  76. package/lib/src/npm/internal/npmRegistry.js +216 -0
  77. package/lib/src/npm/internal/npmRegistry.js.map +1 -0
  78. package/lib/src/npm/packageNameFromSpecifier.d.ts +7 -0
  79. package/lib/src/npm/packageNameFromSpecifier.js +66 -0
  80. package/lib/src/npm/packageNameFromSpecifier.js.map +1 -0
  81. package/lib/src/react/ConsoleViewer.d.ts +7 -0
  82. package/lib/src/react/ConsoleViewer.js +57 -0
  83. package/lib/src/react/ConsoleViewer.js.map +1 -0
  84. package/lib/src/react/DEFAULT_OPTION_TOGGLES.d.ts +3 -0
  85. package/lib/src/react/DEFAULT_OPTION_TOGGLES.js +17 -0
  86. package/lib/src/react/DEFAULT_OPTION_TOGGLES.js.map +1 -0
  87. package/lib/src/react/DependencyProgressModal.d.ts +7 -0
  88. package/lib/src/react/DependencyProgressModal.js +16 -0
  89. package/lib/src/react/DependencyProgressModal.js.map +1 -0
  90. package/lib/src/react/DiagnosticsPanel.d.ts +4 -0
  91. package/lib/src/react/DiagnosticsPanel.js +15 -0
  92. package/lib/src/react/DiagnosticsPanel.js.map +1 -0
  93. package/lib/src/react/ExamplePicker.d.ts +9 -0
  94. package/lib/src/react/ExamplePicker.js +43 -0
  95. package/lib/src/react/ExamplePicker.js.map +1 -0
  96. package/lib/src/react/LintPane.d.ts +9 -0
  97. package/lib/src/react/LintPane.js +17 -0
  98. package/lib/src/react/LintPane.js.map +1 -0
  99. package/lib/src/react/OptionsPanel.d.ts +13 -0
  100. package/lib/src/react/OptionsPanel.js +43 -0
  101. package/lib/src/react/OptionsPanel.js.map +1 -0
  102. package/lib/src/react/PlaygroundShell.d.ts +2 -0
  103. package/lib/src/react/PlaygroundShell.js +609 -0
  104. package/lib/src/react/PlaygroundShell.js.map +1 -0
  105. package/lib/src/react/ResultViewer.d.ts +10 -0
  106. package/lib/src/react/ResultViewer.js +49 -0
  107. package/lib/src/react/ResultViewer.js.map +1 -0
  108. package/lib/src/react/SourceEditor.d.ts +2 -0
  109. package/lib/src/react/SourceEditor.js +74 -0
  110. package/lib/src/react/SourceEditor.js.map +1 -0
  111. package/lib/src/react/createCompilerClient.d.ts +14 -0
  112. package/lib/src/react/createCompilerClient.js +77 -0
  113. package/lib/src/react/createCompilerClient.js.map +1 -0
  114. package/lib/src/sandbox/createSandboxRequire.d.ts +11 -0
  115. package/lib/src/sandbox/createSandboxRequire.js +211 -0
  116. package/lib/src/sandbox/createSandboxRequire.js.map +1 -0
  117. package/lib/src/sandbox/loadTypiaRuntimePack.d.ts +7 -0
  118. package/lib/src/sandbox/loadTypiaRuntimePack.js +35 -0
  119. package/lib/src/sandbox/loadTypiaRuntimePack.js.map +1 -0
  120. package/lib/src/structures/IBuildTsconfigOptions.d.ts +19 -0
  121. package/lib/src/structures/IBuildTsconfigOptions.js +3 -0
  122. package/lib/src/structures/IBuildTsconfigOptions.js.map +1 -0
  123. package/lib/src/structures/ICompilerService.d.ts +84 -0
  124. package/lib/src/structures/ICompilerService.js +3 -0
  125. package/lib/src/structures/ICompilerService.js.map +1 -0
  126. package/lib/src/structures/IConsoleMessage.d.ts +10 -0
  127. package/lib/src/structures/IConsoleMessage.js +3 -0
  128. package/lib/src/structures/IConsoleMessage.js.map +1 -0
  129. package/lib/src/structures/ICreateCompilerClientOptions.d.ts +13 -0
  130. package/lib/src/structures/ICreateCompilerClientOptions.js +3 -0
  131. package/lib/src/structures/ICreateCompilerClientOptions.js.map +1 -0
  132. package/lib/src/structures/ICreateWorkerCompilerOptions.d.ts +35 -0
  133. package/lib/src/structures/ICreateWorkerCompilerOptions.js +3 -0
  134. package/lib/src/structures/ICreateWorkerCompilerOptions.js.map +1 -0
  135. package/lib/src/structures/IInstallTypiaSourcePackOptions.d.ts +18 -0
  136. package/lib/src/structures/IInstallTypiaSourcePackOptions.js +3 -0
  137. package/lib/src/structures/IInstallTypiaSourcePackOptions.js.map +1 -0
  138. package/lib/src/structures/ILintPluginConfig.d.ts +5 -0
  139. package/lib/src/structures/ILintPluginConfig.js +3 -0
  140. package/lib/src/structures/ILintPluginConfig.js.map +1 -0
  141. package/lib/src/structures/IOptionToggle.d.ts +12 -0
  142. package/lib/src/structures/IOptionToggle.js +3 -0
  143. package/lib/src/structures/IOptionToggle.js.map +1 -0
  144. package/lib/src/structures/IPlaygroundDependencyInstallOptions.d.ts +16 -0
  145. package/lib/src/structures/IPlaygroundDependencyInstallOptions.js +3 -0
  146. package/lib/src/structures/IPlaygroundDependencyInstallOptions.js.map +1 -0
  147. package/lib/src/structures/IPlaygroundDependencyInstallResult.d.ts +20 -0
  148. package/lib/src/structures/IPlaygroundDependencyInstallResult.js +3 -0
  149. package/lib/src/structures/IPlaygroundDependencyInstallResult.js.map +1 -0
  150. package/lib/src/structures/IPlaygroundDependencyPackage.d.ts +8 -0
  151. package/lib/src/structures/IPlaygroundDependencyPackage.js +3 -0
  152. package/lib/src/structures/IPlaygroundDependencyPackage.js.map +1 -0
  153. package/lib/src/structures/IPlaygroundDependencyProgress.d.ts +10 -0
  154. package/lib/src/structures/IPlaygroundDependencyProgress.js +3 -0
  155. package/lib/src/structures/IPlaygroundDependencyProgress.js.map +1 -0
  156. package/lib/src/structures/IPlaygroundDependencyProgressPhase.d.ts +5 -0
  157. package/lib/src/structures/IPlaygroundDependencyProgressPhase.js +3 -0
  158. package/lib/src/structures/IPlaygroundDependencyProgressPhase.js.map +1 -0
  159. package/lib/src/structures/IPlaygroundExample.d.ts +16 -0
  160. package/lib/src/structures/IPlaygroundExample.js +3 -0
  161. package/lib/src/structures/IPlaygroundExample.js.map +1 -0
  162. package/lib/src/structures/IPlaygroundShellProps.d.ts +70 -0
  163. package/lib/src/structures/IPlaygroundShellProps.js +3 -0
  164. package/lib/src/structures/IPlaygroundShellProps.js.map +1 -0
  165. package/lib/src/structures/ISourceEditorProps.d.ts +18 -0
  166. package/lib/src/structures/ISourceEditorProps.js +3 -0
  167. package/lib/src/structures/ISourceEditorProps.js.map +1 -0
  168. package/lib/src/structures/ITransformOptions.d.ts +15 -0
  169. package/lib/src/structures/ITransformOptions.js +3 -0
  170. package/lib/src/structures/ITransformOptions.js.map +1 -0
  171. package/lib/src/structures/ITypiaPluginConfig.d.ts +19 -0
  172. package/lib/src/structures/ITypiaPluginConfig.js +3 -0
  173. package/lib/src/structures/ITypiaPluginConfig.js.map +1 -0
  174. package/lib/src/structures/index.d.ts +18 -0
  175. package/lib/src/structures/index.js +35 -0
  176. package/lib/src/structures/index.js.map +1 -0
  177. package/package.json +66 -0
  178. package/src/compiler/DEFAULT_ENTRY_FILE.ts +2 -0
  179. package/src/compiler/DEFAULT_LINT_PLUGIN_NAME.ts +5 -0
  180. package/src/compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS.ts +19 -0
  181. package/src/compiler/DEFAULT_TSCONFIG_PATH.ts +2 -0
  182. package/src/compiler/DEFAULT_TYPIA_PLUGIN_NAME.ts +6 -0
  183. package/src/compiler/DEFAULT_WORK_DIR.ts +2 -0
  184. package/src/compiler/buildTsconfigJSON.ts +22 -0
  185. package/src/compiler/createTypiaSourcePackMount.ts +32 -0
  186. package/src/compiler/createWorkerCompiler.ts +273 -0
  187. package/src/compiler/installDependenciesIntoMemFS.ts +28 -0
  188. package/src/compiler/installTypiaSourcePack.ts +24 -0
  189. package/src/compiler/internal/joinUnder.ts +8 -0
  190. package/src/compiler/internal/parseLintDiagnostics.ts +61 -0
  191. package/src/compiler/internal/safeParseTypiaTransform.ts +24 -0
  192. package/src/compiler/lineColumnOf.ts +14 -0
  193. package/src/compiler/loadTypiaSourcePack.ts +37 -0
  194. package/src/compiler/mapDiagnostic.ts +26 -0
  195. package/src/compiler/normalizeError.ts +12 -0
  196. package/src/compiler/normalizeNodeModulePath.ts +13 -0
  197. package/src/compiler/pickEmittedJS.ts +18 -0
  198. package/src/index.ts +57 -0
  199. package/src/npm/BUILT_IN_PLAYGROUND_PACKAGES.ts +11 -0
  200. package/src/npm/collectExternalPackageNames.ts +34 -0
  201. package/src/npm/installPlaygroundDependencies.ts +163 -0
  202. package/src/npm/internal/npmRegistry.ts +292 -0
  203. package/src/npm/packageNameFromSpecifier.ts +61 -0
  204. package/src/react/ConsoleViewer.tsx +121 -0
  205. package/src/react/DEFAULT_OPTION_TOGGLES.ts +15 -0
  206. package/src/react/DependencyProgressModal.tsx +73 -0
  207. package/src/react/DiagnosticsPanel.tsx +74 -0
  208. package/src/react/ExamplePicker.tsx +93 -0
  209. package/src/react/LintPane.tsx +58 -0
  210. package/src/react/OptionsPanel.tsx +132 -0
  211. package/src/react/PlaygroundShell.tsx +864 -0
  212. package/src/react/ResultViewer.tsx +75 -0
  213. package/src/react/SourceEditor.tsx +96 -0
  214. package/src/react/createCompilerClient.ts +80 -0
  215. package/src/sandbox/createSandboxRequire.ts +275 -0
  216. package/src/sandbox/loadTypiaRuntimePack.ts +36 -0
  217. package/src/structures/IBuildTsconfigOptions.ts +19 -0
  218. package/src/structures/ICompilerService.ts +96 -0
  219. package/src/structures/IConsoleMessage.ts +10 -0
  220. package/src/structures/ICreateCompilerClientOptions.ts +13 -0
  221. package/src/structures/ICreateWorkerCompilerOptions.ts +40 -0
  222. package/src/structures/IInstallTypiaSourcePackOptions.ts +18 -0
  223. package/src/structures/ILintPluginConfig.ts +5 -0
  224. package/src/structures/IOptionToggle.ts +12 -0
  225. package/src/structures/IPlaygroundDependencyInstallOptions.ts +17 -0
  226. package/src/structures/IPlaygroundDependencyInstallResult.ts +21 -0
  227. package/src/structures/IPlaygroundDependencyPackage.ts +8 -0
  228. package/src/structures/IPlaygroundDependencyProgress.ts +11 -0
  229. package/src/structures/IPlaygroundDependencyProgressPhase.ts +12 -0
  230. package/src/structures/IPlaygroundExample.ts +16 -0
  231. package/src/structures/IPlaygroundShellProps.ts +83 -0
  232. package/src/structures/ISourceEditorProps.ts +18 -0
  233. package/src/structures/ITransformOptions.ts +15 -0
  234. package/src/structures/ITypiaPluginConfig.ts +20 -0
  235. package/src/structures/index.ts +18 -0
@@ -0,0 +1,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;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pickEmittedJS = pickEmittedJS;
4
+ /**
5
+ * Pick the most likely emitted JavaScript file from a compile result's output
6
+ * map. Tries common paths first, then falls back to the first `.js` entry.
7
+ * Returns null when no `.js` was emitted.
8
+ */
9
+ function pickEmittedJS(output, entryFile) {
10
+ const base = entryFile.replace(/\.[cm]?tsx?$/i, ".js");
11
+ const candidates = [`dist/${base}`, `dist/src/${base}`, `src/${base}`, base];
12
+ for (const key of candidates) {
13
+ if (output[key] !== undefined)
14
+ return output[key];
15
+ }
16
+ const jsKeys = Object.keys(output).filter((k) => k.endsWith(".js"));
17
+ if (jsKeys.length > 0)
18
+ return output[jsKeys[0]] ?? null;
19
+ return null;
20
+ }
21
+ //# sourceMappingURL=pickEmittedJS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickEmittedJS.js","sourceRoot":"","sources":["../../../src/compiler/pickEmittedJS.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,uBACE,MAA8B,EAC9B,SAAiB;IAEjB,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,CAAC,QAAQ,IAAI,EAAE,EAAE,YAAY,IAAI,EAAE,EAAE,OAAO,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7E,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,IAAI,IAAI,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * `@ttsc/playground` — reusable Web Worker + React scaffolding for in-browser
3
+ * ttsc playgrounds built on `@ttsc/wasm`.
4
+ *
5
+ * The package is organized by concern: the `compiler/*` modules implement the
6
+ * worker-side `ICompilerService` contract; the `npm/*` modules install
7
+ * on-the-fly npm dependencies into the wasm MemFS; the `sandbox/*` modules
8
+ * drive an in-page `new Function` execute sandbox; the `react/*` modules render
9
+ * the shell, editor, and result panes.
10
+ *
11
+ * The package root re-exports everything; sub-path imports are not needed.
12
+ */
13
+ export { buildTsconfigJSON } from "./compiler/buildTsconfigJSON";
14
+ export { createTypiaSourcePackMount } from "./compiler/createTypiaSourcePackMount";
15
+ export { createWorkerCompiler } from "./compiler/createWorkerCompiler";
16
+ export { DEFAULT_ENTRY_FILE } from "./compiler/DEFAULT_ENTRY_FILE";
17
+ export { DEFAULT_LINT_PLUGIN_NAME } from "./compiler/DEFAULT_LINT_PLUGIN_NAME";
18
+ export { DEFAULT_PLAYGROUND_COMPILER_OPTIONS } from "./compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS";
19
+ export { DEFAULT_TSCONFIG_PATH } from "./compiler/DEFAULT_TSCONFIG_PATH";
20
+ export { DEFAULT_TYPIA_PLUGIN_NAME } from "./compiler/DEFAULT_TYPIA_PLUGIN_NAME";
21
+ export { DEFAULT_WORK_DIR } from "./compiler/DEFAULT_WORK_DIR";
22
+ export { installDependenciesIntoMemFS } from "./compiler/installDependenciesIntoMemFS";
23
+ export { installTypiaSourcePack } from "./compiler/installTypiaSourcePack";
24
+ export { lineColumnOf } from "./compiler/lineColumnOf";
25
+ export { loadTypiaSourcePack } from "./compiler/loadTypiaSourcePack";
26
+ export { mapDiagnostic } from "./compiler/mapDiagnostic";
27
+ export { normalizeError } from "./compiler/normalizeError";
28
+ export { normalizeNodeModulePath } from "./compiler/normalizeNodeModulePath";
29
+ export { pickEmittedJS } from "./compiler/pickEmittedJS";
30
+ export { BUILT_IN_PLAYGROUND_PACKAGES } from "./npm/BUILT_IN_PLAYGROUND_PACKAGES";
31
+ export { collectExternalPackageNames } from "./npm/collectExternalPackageNames";
32
+ export { installPlaygroundDependencies } from "./npm/installPlaygroundDependencies";
33
+ export { packageNameFromSpecifier } from "./npm/packageNameFromSpecifier";
34
+ export { createSandboxRequire } from "./sandbox/createSandboxRequire";
35
+ export { loadTypiaRuntimePack } from "./sandbox/loadTypiaRuntimePack";
36
+ export { ConsoleViewer } from "./react/ConsoleViewer";
37
+ export { createCompilerClient } from "./react/createCompilerClient";
38
+ export { DEFAULT_OPTION_TOGGLES } from "./react/DEFAULT_OPTION_TOGGLES";
39
+ export { DependencyProgressModal } from "./react/DependencyProgressModal";
40
+ export { DiagnosticsPanel } from "./react/DiagnosticsPanel";
41
+ export { ExamplePicker } from "./react/ExamplePicker";
42
+ export { LintPane } from "./react/LintPane";
43
+ export { OptionsPanel } from "./react/OptionsPanel";
44
+ export { PlaygroundShell } from "./react/PlaygroundShell";
45
+ export { ResultViewer } from "./react/ResultViewer";
46
+ export { SourceEditor } from "./react/SourceEditor";
47
+ export * from "./structures/index";
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ /**
3
+ * `@ttsc/playground` — reusable Web Worker + React scaffolding for in-browser
4
+ * ttsc playgrounds built on `@ttsc/wasm`.
5
+ *
6
+ * The package is organized by concern: the `compiler/*` modules implement the
7
+ * worker-side `ICompilerService` contract; the `npm/*` modules install
8
+ * on-the-fly npm dependencies into the wasm MemFS; the `sandbox/*` modules
9
+ * drive an in-page `new Function` execute sandbox; the `react/*` modules render
10
+ * the shell, editor, and result panes.
11
+ *
12
+ * The package root re-exports everything; sub-path imports are not needed.
13
+ */
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.SourceEditor = exports.ResultViewer = exports.PlaygroundShell = exports.OptionsPanel = exports.LintPane = exports.ExamplePicker = exports.DiagnosticsPanel = exports.DependencyProgressModal = exports.DEFAULT_OPTION_TOGGLES = exports.createCompilerClient = exports.ConsoleViewer = exports.loadTypiaRuntimePack = exports.createSandboxRequire = exports.packageNameFromSpecifier = exports.installPlaygroundDependencies = exports.collectExternalPackageNames = exports.BUILT_IN_PLAYGROUND_PACKAGES = exports.pickEmittedJS = exports.normalizeNodeModulePath = exports.normalizeError = exports.mapDiagnostic = exports.loadTypiaSourcePack = exports.lineColumnOf = exports.installTypiaSourcePack = exports.installDependenciesIntoMemFS = exports.DEFAULT_WORK_DIR = exports.DEFAULT_TYPIA_PLUGIN_NAME = exports.DEFAULT_TSCONFIG_PATH = exports.DEFAULT_PLAYGROUND_COMPILER_OPTIONS = exports.DEFAULT_LINT_PLUGIN_NAME = exports.DEFAULT_ENTRY_FILE = exports.createWorkerCompiler = exports.createTypiaSourcePackMount = exports.buildTsconfigJSON = void 0;
30
+ // ── compiler / worker core ────────────────────────────────────────────────
31
+ var buildTsconfigJSON_1 = require("./compiler/buildTsconfigJSON");
32
+ Object.defineProperty(exports, "buildTsconfigJSON", { enumerable: true, get: function () { return buildTsconfigJSON_1.buildTsconfigJSON; } });
33
+ var createTypiaSourcePackMount_1 = require("./compiler/createTypiaSourcePackMount");
34
+ Object.defineProperty(exports, "createTypiaSourcePackMount", { enumerable: true, get: function () { return createTypiaSourcePackMount_1.createTypiaSourcePackMount; } });
35
+ var createWorkerCompiler_1 = require("./compiler/createWorkerCompiler");
36
+ Object.defineProperty(exports, "createWorkerCompiler", { enumerable: true, get: function () { return createWorkerCompiler_1.createWorkerCompiler; } });
37
+ var DEFAULT_ENTRY_FILE_1 = require("./compiler/DEFAULT_ENTRY_FILE");
38
+ Object.defineProperty(exports, "DEFAULT_ENTRY_FILE", { enumerable: true, get: function () { return DEFAULT_ENTRY_FILE_1.DEFAULT_ENTRY_FILE; } });
39
+ var DEFAULT_LINT_PLUGIN_NAME_1 = require("./compiler/DEFAULT_LINT_PLUGIN_NAME");
40
+ Object.defineProperty(exports, "DEFAULT_LINT_PLUGIN_NAME", { enumerable: true, get: function () { return DEFAULT_LINT_PLUGIN_NAME_1.DEFAULT_LINT_PLUGIN_NAME; } });
41
+ var DEFAULT_PLAYGROUND_COMPILER_OPTIONS_1 = require("./compiler/DEFAULT_PLAYGROUND_COMPILER_OPTIONS");
42
+ Object.defineProperty(exports, "DEFAULT_PLAYGROUND_COMPILER_OPTIONS", { enumerable: true, get: function () { return DEFAULT_PLAYGROUND_COMPILER_OPTIONS_1.DEFAULT_PLAYGROUND_COMPILER_OPTIONS; } });
43
+ var DEFAULT_TSCONFIG_PATH_1 = require("./compiler/DEFAULT_TSCONFIG_PATH");
44
+ Object.defineProperty(exports, "DEFAULT_TSCONFIG_PATH", { enumerable: true, get: function () { return DEFAULT_TSCONFIG_PATH_1.DEFAULT_TSCONFIG_PATH; } });
45
+ var DEFAULT_TYPIA_PLUGIN_NAME_1 = require("./compiler/DEFAULT_TYPIA_PLUGIN_NAME");
46
+ Object.defineProperty(exports, "DEFAULT_TYPIA_PLUGIN_NAME", { enumerable: true, get: function () { return DEFAULT_TYPIA_PLUGIN_NAME_1.DEFAULT_TYPIA_PLUGIN_NAME; } });
47
+ var DEFAULT_WORK_DIR_1 = require("./compiler/DEFAULT_WORK_DIR");
48
+ Object.defineProperty(exports, "DEFAULT_WORK_DIR", { enumerable: true, get: function () { return DEFAULT_WORK_DIR_1.DEFAULT_WORK_DIR; } });
49
+ var installDependenciesIntoMemFS_1 = require("./compiler/installDependenciesIntoMemFS");
50
+ Object.defineProperty(exports, "installDependenciesIntoMemFS", { enumerable: true, get: function () { return installDependenciesIntoMemFS_1.installDependenciesIntoMemFS; } });
51
+ var installTypiaSourcePack_1 = require("./compiler/installTypiaSourcePack");
52
+ Object.defineProperty(exports, "installTypiaSourcePack", { enumerable: true, get: function () { return installTypiaSourcePack_1.installTypiaSourcePack; } });
53
+ var lineColumnOf_1 = require("./compiler/lineColumnOf");
54
+ Object.defineProperty(exports, "lineColumnOf", { enumerable: true, get: function () { return lineColumnOf_1.lineColumnOf; } });
55
+ var loadTypiaSourcePack_1 = require("./compiler/loadTypiaSourcePack");
56
+ Object.defineProperty(exports, "loadTypiaSourcePack", { enumerable: true, get: function () { return loadTypiaSourcePack_1.loadTypiaSourcePack; } });
57
+ var mapDiagnostic_1 = require("./compiler/mapDiagnostic");
58
+ Object.defineProperty(exports, "mapDiagnostic", { enumerable: true, get: function () { return mapDiagnostic_1.mapDiagnostic; } });
59
+ var normalizeError_1 = require("./compiler/normalizeError");
60
+ Object.defineProperty(exports, "normalizeError", { enumerable: true, get: function () { return normalizeError_1.normalizeError; } });
61
+ var normalizeNodeModulePath_1 = require("./compiler/normalizeNodeModulePath");
62
+ Object.defineProperty(exports, "normalizeNodeModulePath", { enumerable: true, get: function () { return normalizeNodeModulePath_1.normalizeNodeModulePath; } });
63
+ var pickEmittedJS_1 = require("./compiler/pickEmittedJS");
64
+ Object.defineProperty(exports, "pickEmittedJS", { enumerable: true, get: function () { return pickEmittedJS_1.pickEmittedJS; } });
65
+ // ── npm-from-the-browser dependency installer ─────────────────────────────
66
+ var BUILT_IN_PLAYGROUND_PACKAGES_1 = require("./npm/BUILT_IN_PLAYGROUND_PACKAGES");
67
+ Object.defineProperty(exports, "BUILT_IN_PLAYGROUND_PACKAGES", { enumerable: true, get: function () { return BUILT_IN_PLAYGROUND_PACKAGES_1.BUILT_IN_PLAYGROUND_PACKAGES; } });
68
+ var collectExternalPackageNames_1 = require("./npm/collectExternalPackageNames");
69
+ Object.defineProperty(exports, "collectExternalPackageNames", { enumerable: true, get: function () { return collectExternalPackageNames_1.collectExternalPackageNames; } });
70
+ var installPlaygroundDependencies_1 = require("./npm/installPlaygroundDependencies");
71
+ Object.defineProperty(exports, "installPlaygroundDependencies", { enumerable: true, get: function () { return installPlaygroundDependencies_1.installPlaygroundDependencies; } });
72
+ var packageNameFromSpecifier_1 = require("./npm/packageNameFromSpecifier");
73
+ Object.defineProperty(exports, "packageNameFromSpecifier", { enumerable: true, get: function () { return packageNameFromSpecifier_1.packageNameFromSpecifier; } });
74
+ // ── typia runtime sandbox (CJS-flavoured require over a pack JSON) ────────
75
+ var createSandboxRequire_1 = require("./sandbox/createSandboxRequire");
76
+ Object.defineProperty(exports, "createSandboxRequire", { enumerable: true, get: function () { return createSandboxRequire_1.createSandboxRequire; } });
77
+ var loadTypiaRuntimePack_1 = require("./sandbox/loadTypiaRuntimePack");
78
+ Object.defineProperty(exports, "loadTypiaRuntimePack", { enumerable: true, get: function () { return loadTypiaRuntimePack_1.loadTypiaRuntimePack; } });
79
+ // ── React UI surface ──────────────────────────────────────────────────────
80
+ var ConsoleViewer_1 = require("./react/ConsoleViewer");
81
+ Object.defineProperty(exports, "ConsoleViewer", { enumerable: true, get: function () { return ConsoleViewer_1.ConsoleViewer; } });
82
+ var createCompilerClient_1 = require("./react/createCompilerClient");
83
+ Object.defineProperty(exports, "createCompilerClient", { enumerable: true, get: function () { return createCompilerClient_1.createCompilerClient; } });
84
+ var DEFAULT_OPTION_TOGGLES_1 = require("./react/DEFAULT_OPTION_TOGGLES");
85
+ Object.defineProperty(exports, "DEFAULT_OPTION_TOGGLES", { enumerable: true, get: function () { return DEFAULT_OPTION_TOGGLES_1.DEFAULT_OPTION_TOGGLES; } });
86
+ var DependencyProgressModal_1 = require("./react/DependencyProgressModal");
87
+ Object.defineProperty(exports, "DependencyProgressModal", { enumerable: true, get: function () { return DependencyProgressModal_1.DependencyProgressModal; } });
88
+ var DiagnosticsPanel_1 = require("./react/DiagnosticsPanel");
89
+ Object.defineProperty(exports, "DiagnosticsPanel", { enumerable: true, get: function () { return DiagnosticsPanel_1.DiagnosticsPanel; } });
90
+ var ExamplePicker_1 = require("./react/ExamplePicker");
91
+ Object.defineProperty(exports, "ExamplePicker", { enumerable: true, get: function () { return ExamplePicker_1.ExamplePicker; } });
92
+ var LintPane_1 = require("./react/LintPane");
93
+ Object.defineProperty(exports, "LintPane", { enumerable: true, get: function () { return LintPane_1.LintPane; } });
94
+ var OptionsPanel_1 = require("./react/OptionsPanel");
95
+ Object.defineProperty(exports, "OptionsPanel", { enumerable: true, get: function () { return OptionsPanel_1.OptionsPanel; } });
96
+ var PlaygroundShell_1 = require("./react/PlaygroundShell");
97
+ Object.defineProperty(exports, "PlaygroundShell", { enumerable: true, get: function () { return PlaygroundShell_1.PlaygroundShell; } });
98
+ var ResultViewer_1 = require("./react/ResultViewer");
99
+ Object.defineProperty(exports, "ResultViewer", { enumerable: true, get: function () { return ResultViewer_1.ResultViewer; } });
100
+ var SourceEditor_1 = require("./react/SourceEditor");
101
+ Object.defineProperty(exports, "SourceEditor", { enumerable: true, get: function () { return SourceEditor_1.SourceEditor; } });
102
+ // ── structured types ──────────────────────────────────────────────────────
103
+ __exportStar(require("./structures/index"), exports);
104
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;AAEH,6EAA6E;AAC7E,kEAAiE;AAAxD,sHAAA,iBAAiB,OAAA;AAC1B,oFAAmF;AAA1E,wIAAA,0BAA0B,OAAA;AACnC,wEAAuE;AAA9D,4HAAA,oBAAoB,OAAA;AAC7B,oEAAmE;AAA1D,wHAAA,kBAAkB,OAAA;AAC3B,gFAA+E;AAAtE,oIAAA,wBAAwB,OAAA;AACjC,sGAAqG;AAA5F,0JAAA,mCAAmC,OAAA;AAC5C,0EAAyE;AAAhE,8HAAA,qBAAqB,OAAA;AAC9B,kFAAiF;AAAxE,sIAAA,yBAAyB,OAAA;AAClC,gEAA+D;AAAtD,oHAAA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skips these so it doesn't try to fetch typia / @typia/* from the
4
+ * registry on top of the mounted source tree.
5
+ */
6
+ export declare const BUILT_IN_PLAYGROUND_PACKAGES: readonly ["typia", "@typia/interface", "@typia/utils", "@standard-schema/spec"];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUILT_IN_PLAYGROUND_PACKAGES = void 0;
4
+ /**
5
+ * Packages the typia source pack already mounts inside the wasm. The npm
6
+ * installer skips these so it doesn't try to fetch typia / @typia/* from the
7
+ * registry on top of the mounted source tree.
8
+ */
9
+ exports.BUILT_IN_PLAYGROUND_PACKAGES = [
10
+ "typia",
11
+ "@typia/interface",
12
+ "@typia/utils",
13
+ "@standard-schema/spec",
14
+ ];
15
+ //# sourceMappingURL=BUILT_IN_PLAYGROUND_PACKAGES.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BUILT_IN_PLAYGROUND_PACKAGES.js","sourceRoot":"","sources":["../../../src/npm/BUILT_IN_PLAYGROUND_PACKAGES.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,4BAA4B,GAAG;IAC1C,OAAO;IACP,kBAAkB;IAClB,cAAc;IACd,uBAAuB;CACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Scan `source` for `import` / `require` specifiers and return the unique
3
+ * sorted list of bare npm package names that are not in `ignoredPackages`.
4
+ */
5
+ export declare function collectExternalPackageNames(source: string, ignoredPackages?: Iterable<string>): string[];
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectExternalPackageNames = collectExternalPackageNames;
4
+ const BUILT_IN_PLAYGROUND_PACKAGES_1 = require("./BUILT_IN_PLAYGROUND_PACKAGES");
5
+ const packageNameFromSpecifier_1 = require("./packageNameFromSpecifier");
6
+ const MODULE_SPECIFIER_REGEXP = /\b(?:import|export)\s+(?:type\s+)?(?:[^"'()]*?\s+from\s*)?["']([^"']+)["']|import\s*\(\s*["']([^"']+)["']\s*\)|require\s*\(\s*["']([^"']+)["']\s*\)/g;
7
+ /**
8
+ * Scan `source` for `import` / `require` specifiers and return the unique
9
+ * sorted list of bare npm package names that are not in `ignoredPackages`.
10
+ */
11
+ function collectExternalPackageNames(source, ignoredPackages = BUILT_IN_PLAYGROUND_PACKAGES_1.BUILT_IN_PLAYGROUND_PACKAGES) {
12
+ const ignored = new Set(ignoredPackages);
13
+ const found = new Set();
14
+ for (const specifier of collectModuleSpecifiers(source)) {
15
+ const packageName = (0, packageNameFromSpecifier_1.packageNameFromSpecifier)(specifier);
16
+ if (packageName && !ignored.has(packageName))
17
+ found.add(packageName);
18
+ }
19
+ return [...found].sort();
20
+ }
21
+ function collectModuleSpecifiers(source) {
22
+ const out = [];
23
+ MODULE_SPECIFIER_REGEXP.lastIndex = 0;
24
+ for (;;) {
25
+ const match = MODULE_SPECIFIER_REGEXP.exec(source);
26
+ if (!match)
27
+ break;
28
+ const specifier = match[1] ?? match[2] ?? match[3];
29
+ if (specifier)
30
+ out.push(specifier);
31
+ }
32
+ return out;
33
+ }
34
+ //# sourceMappingURL=collectExternalPackageNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectExternalPackageNames.js","sourceRoot":"","sources":["../../../src/npm/collectExternalPackageNames.ts"],"names":[],"mappings":";;;AAAA,iFAA8E;AAC9E,yEAAsE;AAEtE,MAAM,uBAAuB,GAC3B,sJAAsJ,CAAC;AAEzJ;;;GAGG;AACH,qCACE,MAAc,EACd,eAAe,GAAqB,2DAA4B;IAEhE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,SAAS,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,MAAM,WAAW,GAAG,IAAA,mDAAwB,EAAC,SAAS,CAAC,CAAC;QACxD,IAAI,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;YAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED,SAAS,uBAAuB,CAAC,MAAc;IAC7C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,uBAAuB,CAAC,SAAS,GAAG,CAAC,CAAC;IACtC,SAAS,CAAC;QACR,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK;YAAE,MAAM;QAClB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { IPlaygroundDependencyInstallOptions } from "../structures/IPlaygroundDependencyInstallOptions";
2
+ import type { IPlaygroundDependencyInstallResult } from "../structures/IPlaygroundDependencyInstallResult";
3
+ /**
4
+ * Resolve, download, and unpack a set of npm packages directly inside the
5
+ * browser, returning their files keyed for the wasm-side MemFS, Monaco's
6
+ * extra-libs registry, and the in-page execute sandbox `require`.
7
+ *
8
+ * Transitive dependencies are followed via the resolved `package.json`'s
9
+ * `dependencies` and (non-optional) `peerDependencies` fields. The walk is
10
+ * bounded by `maxPackages` to keep a single keystroke from exhausting the tab's
11
+ * network/memory budget.
12
+ */
13
+ export declare function installPlaygroundDependencies(packageNames: Iterable<string>, options?: IPlaygroundDependencyInstallOptions): Promise<IPlaygroundDependencyInstallResult>;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installPlaygroundDependencies = installPlaygroundDependencies;
4
+ const BUILT_IN_PLAYGROUND_PACKAGES_1 = require("./BUILT_IN_PLAYGROUND_PACKAGES");
5
+ const npmRegistry_1 = require("./internal/npmRegistry");
6
+ const DEFAULT_MAX_PACKAGES = 48;
7
+ /**
8
+ * Resolve, download, and unpack a set of npm packages directly inside the
9
+ * browser, returning their files keyed for the wasm-side MemFS, Monaco's
10
+ * extra-libs registry, and the in-page execute sandbox `require`.
11
+ *
12
+ * Transitive dependencies are followed via the resolved `package.json`'s
13
+ * `dependencies` and (non-optional) `peerDependencies` fields. The walk is
14
+ * bounded by `maxPackages` to keep a single keystroke from exhausting the tab's
15
+ * network/memory budget.
16
+ */
17
+ async function installPlaygroundDependencies(packageNames, options = {}) {
18
+ const fetchImpl = options.fetch ?? globalThis.fetch?.bind(globalThis);
19
+ if (!fetchImpl) {
20
+ throw new Error("installPlaygroundDependencies requires fetch.");
21
+ }
22
+ (0, npmRegistry_1.throwIfAborted)(options.signal);
23
+ const ignored = new Set(options.ignoredPackages ?? BUILT_IN_PLAYGROUND_PACKAGES_1.BUILT_IN_PLAYGROUND_PACKAGES);
24
+ const installed = new Set(options.installedPackages ?? []);
25
+ const maxPackages = options.maxPackages ?? DEFAULT_MAX_PACKAGES;
26
+ const queue = [];
27
+ const queued = new Set();
28
+ const done = new Set();
29
+ const result = {
30
+ packages: [],
31
+ compilerFiles: {},
32
+ editorLibs: {},
33
+ runtimeFiles: {},
34
+ };
35
+ const enqueue = (item) => {
36
+ if (ignored.has(item.name) || installed.has(item.name))
37
+ return;
38
+ if (queued.has(item.name) || done.has(item.name))
39
+ return;
40
+ queued.add(item.name);
41
+ queue.push(item);
42
+ report("queued", item, `Queued ${item.name}`);
43
+ };
44
+ const report = (phase, item, message, version) => {
45
+ options.onProgress?.({
46
+ phase,
47
+ packageName: item?.name,
48
+ version,
49
+ completed: done.size,
50
+ total: Math.max(queue.length, done.size + (item ? 1 : 0)),
51
+ message,
52
+ });
53
+ };
54
+ for (const name of packageNames) {
55
+ enqueue({ name, range: "latest", optional: false });
56
+ }
57
+ for (let index = 0; index < queue.length; index++) {
58
+ if (done.size >= maxPackages) {
59
+ throw new Error(`Dependency install stopped after ${maxPackages} packages. Narrow the imports or raise maxPackages.`);
60
+ }
61
+ const item = queue[index];
62
+ if (installed.has(item.name) || done.has(item.name))
63
+ continue;
64
+ (0, npmRegistry_1.throwIfAborted)(options.signal);
65
+ report("resolve", item, `Resolving ${item.name}`);
66
+ const metadata = await (0, npmRegistry_1.fetchNpmMetadata)(fetchImpl, item.name, item.optional, options.signal);
67
+ (0, npmRegistry_1.throwIfAborted)(options.signal);
68
+ if (!metadata) {
69
+ done.add(item.name);
70
+ report("skip", item, `Skipped optional ${item.name}`);
71
+ continue;
72
+ }
73
+ const version = (0, npmRegistry_1.selectVersion)(metadata, item.range);
74
+ const versionMetadata = metadata.versions[version];
75
+ const tarball = versionMetadata?.dist?.tarball;
76
+ if (!versionMetadata || !tarball) {
77
+ if (item.optional) {
78
+ done.add(item.name);
79
+ report("skip", item, `Skipped optional ${item.name}`);
80
+ continue;
81
+ }
82
+ throw new Error(`No tarball found for ${item.name}@${version}.`);
83
+ }
84
+ report("download", item, `Downloading ${item.name}@${version}`, version);
85
+ const tgz = await (0, npmRegistry_1.downloadTarball)(fetchImpl, tarball, options.signal);
86
+ (0, npmRegistry_1.throwIfAborted)(options.signal);
87
+ report("extract", item, `Extracting ${item.name}@${version}`, version);
88
+ const unpacked = await (0, npmRegistry_1.unpackNpmTarball)(tgz, options.signal);
89
+ (0, npmRegistry_1.throwIfAborted)(options.signal);
90
+ const packageJson = {
91
+ ...versionMetadata,
92
+ ...unpacked.packageJson,
93
+ };
94
+ const mounted = (0, npmRegistry_1.mountPackageFiles)(item.name, unpacked.files);
95
+ Object.assign(result.compilerFiles, mounted.compilerFiles);
96
+ Object.assign(result.editorLibs, mounted.editorLibs);
97
+ Object.assign(result.runtimeFiles, mounted.runtimeFiles);
98
+ const declarationCount = Object.keys(mounted.editorLibs).filter((key) => npmRegistry_1.DECLARATION_FILE_REGEXP.test(key)).length;
99
+ result.packages.push({
100
+ name: item.name,
101
+ version,
102
+ tarball,
103
+ fileCount: Object.keys(mounted.compilerFiles).length,
104
+ declarationCount,
105
+ });
106
+ done.add(item.name);
107
+ installed.add(item.name);
108
+ report("done", item, `Installed ${item.name}@${version}`, version);
109
+ (0, npmRegistry_1.enqueuePackageDependencies)(packageJson, enqueue);
110
+ if (declarationCount === 0 && !item.name.startsWith("@types/")) {
111
+ enqueue({
112
+ name: (0, npmRegistry_1.toTypesPackageName)(item.name),
113
+ range: "latest",
114
+ optional: true,
115
+ });
116
+ }
117
+ }
118
+ report("done", null, "Dependency install complete");
119
+ return result;
120
+ }
121
+ //# sourceMappingURL=installPlaygroundDependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installPlaygroundDependencies.js","sourceRoot":"","sources":["../../../src/npm/installPlaygroundDependencies.ts"],"names":[],"mappings":";;;AAGA,iFAA8E;AAC9E,wDAWgC;AAEhC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC;;;;;;;;;GASG;AACI,KAAK,wCACV,YAA8B,EAC9B,OAAO,GAAwC,EAAE;IAEjD,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,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,IAAA,4BAAc,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/B,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,OAAO,CAAC,eAAe,IAAI,2DAA4B,CACxD,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,oBAAoB,CAAC;IAChE,MAAM,KAAK,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
1
+ interface IPackageJson {
2
+ name?: string;
3
+ version?: string;
4
+ dependencies?: Record<string, string>;
5
+ peerDependencies?: Record<string, string>;
6
+ peerDependenciesMeta?: Record<string, {
7
+ optional?: boolean;
8
+ }>;
9
+ }
10
+ export interface INpmVersionMetadata {
11
+ name: string;
12
+ version: string;
13
+ dependencies?: Record<string, string>;
14
+ peerDependencies?: Record<string, string>;
15
+ peerDependenciesMeta?: Record<string, {
16
+ optional?: boolean;
17
+ }>;
18
+ dist?: {
19
+ tarball?: string;
20
+ };
21
+ }
22
+ export interface INpmMetadata {
23
+ name: string;
24
+ "dist-tags"?: Record<string, string>;
25
+ versions: Record<string, INpmVersionMetadata | undefined>;
26
+ }
27
+ export interface IUnpackedPackage {
28
+ files: Record<string, string>;
29
+ packageJson: IPackageJson;
30
+ }
31
+ export interface IQueueItem {
32
+ name: string;
33
+ range: string;
34
+ optional: boolean;
35
+ }
36
+ export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
37
+ export declare const DECLARATION_FILE_REGEXP: RegExp;
38
+ export declare function throwIfAborted(signal: AbortSignal | undefined): void;
39
+ export declare function fetchNpmMetadata(fetchImpl: FetchLike, packageName: string, optional: boolean, signal: AbortSignal | undefined): Promise<INpmMetadata | null>;
40
+ export declare function selectVersion(metadata: INpmMetadata, range: string): string;
41
+ export declare function downloadTarball(fetchImpl: FetchLike, tarball: string, signal: AbortSignal | undefined): Promise<ArrayBuffer>;
42
+ export declare function unpackNpmTarball(tgz: ArrayBuffer, signal: AbortSignal | undefined): Promise<IUnpackedPackage>;
43
+ export interface IMountedFiles {
44
+ compilerFiles: Record<string, string>;
45
+ editorLibs: Record<string, string>;
46
+ runtimeFiles: Record<string, string>;
47
+ }
48
+ export declare function mountPackageFiles(packageName: string, files: Record<string, string>): IMountedFiles;
49
+ export declare function enqueuePackageDependencies(packageJson: {
50
+ dependencies?: Record<string, string>;
51
+ peerDependencies?: Record<string, string>;
52
+ peerDependenciesMeta?: Record<string, {
53
+ optional?: boolean;
54
+ }>;
55
+ }, enqueue: (item: IQueueItem) => void): void;
56
+ export declare function toTypesPackageName(packageName: string): string;
57
+ export {};