@tscircuit/eval 0.0.363 → 0.0.364

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 (106) hide show
  1. package/package.json +4 -1
  2. package/.github/workflows/bun-formatcheck.yml +0 -27
  3. package/.github/workflows/bun-pver-release.yml +0 -70
  4. package/.github/workflows/bun-test.yml +0 -87
  5. package/.github/workflows/bun-typecheck.yml +0 -27
  6. package/.github/workflows/playwright.yml +0 -40
  7. package/.github/workflows/update-deps.yml +0 -47
  8. package/.github/workflows/update-tscircuit-core.yml +0 -59
  9. package/biome.json +0 -50
  10. package/browser-tests/browser.test.ts +0 -15
  11. package/browser-tests/browsertest.html +0 -15
  12. package/browser-tests/browsertest.ts +0 -53
  13. package/bunfig.toml +0 -6
  14. package/lib/getPlatformConfig.ts +0 -41
  15. package/lib/getPossibleEntrypointComponentPaths.ts +0 -42
  16. package/lib/index.ts +0 -5
  17. package/lib/runner/CircuitRunner.ts +0 -201
  18. package/lib/runner/index.ts +0 -4
  19. package/lib/runner/normalizeFsMap.ts +0 -20
  20. package/lib/runner/resolveFilePath.ts +0 -90
  21. package/lib/runner/runTscircuitCode.ts +0 -30
  22. package/lib/runner/runTscircuitModule.ts +0 -37
  23. package/lib/runner/setupDefaultEntrypointIfNeeded.ts +0 -81
  24. package/lib/shared/static-asset-extensions.ts +0 -10
  25. package/lib/shared/types.ts +0 -79
  26. package/lib/utils/dirname.ts +0 -21
  27. package/lib/utils/get-imports-from-code.ts +0 -23
  28. package/lib/utils/index.ts +0 -1
  29. package/lib/utils/resolve-node-module.ts +0 -193
  30. package/lib/worker.ts +0 -246
  31. package/playwright.config.ts +0 -23
  32. package/scripts/build-worker-blob-url.ts +0 -27
  33. package/scripts/copy-core-versions.ts +0 -81
  34. package/scripts/validate-test-matrix.js +0 -148
  35. package/tests/circuit-runner/circuitrunner1-readme-example.test.tsx +0 -29
  36. package/tests/custom-component-with-fsmap/should-reject-invalid-main-component-path.test.ts +0 -26
  37. package/tests/custom-component-with-fsmap/should-render-multiple-components-from-fsmap.test.ts +0 -46
  38. package/tests/custom-component-with-fsmap/should-render-single-component-from-fsmap.test.ts +0 -38
  39. package/tests/examples/__snapshots__/example18-kicad-footprint-server.snap.svg +0 -1
  40. package/tests/examples/example01-readme-example.test.tsx +0 -30
  41. package/tests/examples/example02-multiple-files.test.tsx +0 -45
  42. package/tests/examples/example03-encoded-url.test.tsx +0 -28
  43. package/tests/examples/example04-root-child-issue.test.tsx +0 -37
  44. package/tests/examples/example05-event-recording.test.tsx +0 -44
  45. package/tests/examples/example06-dynamic-load-blob-url.test.tsx +0 -29
  46. package/tests/examples/example07-import-default-and-namespace.test.tsx +0 -74
  47. package/tests/examples/example08-footprinter-to220.test.tsx +0 -30
  48. package/tests/examples/example09-not-defined-component.test.tsx +0 -24
  49. package/tests/examples/example10-run-tscircuit-code.test.tsx +0 -14
  50. package/tests/examples/example11-flexible-import-extensions.test.tsx +0 -20
  51. package/tests/examples/example12-import-from-subdirectory.test.tsx +0 -26
  52. package/tests/examples/example13-webworker-without-entrypoint.test.tsx +0 -32
  53. package/tests/examples/example14-run-tscircuit-module.test.tsx +0 -20
  54. package/tests/examples/example15-run-tscircuit-module-with-props.test.tsx +0 -24
  55. package/tests/examples/example16-parts-engine.test.tsx +0 -118
  56. package/tests/examples/example17-parse-tscircuit-config.test.tsx +0 -49
  57. package/tests/examples/example18-kicad-footprint-server.test.tsx +0 -39
  58. package/tests/examples/example19-support-backwards-compat.test.tsx +0 -31
  59. package/tests/examples/example20-kicad-import.test.tsx +0 -48
  60. package/tests/features/circuit-event-forwarding.test.tsx +0 -45
  61. package/tests/features/enable-debug.test.ts +0 -26
  62. package/tests/features/execute-component-runner.test.tsx +0 -47
  63. package/tests/features/execute-component-worker.test.tsx +0 -25
  64. package/tests/features/fetch-proxy/fetch-override.test.ts +0 -46
  65. package/tests/features/fetch-proxy/fetch-proxy-validation.test.ts +0 -95
  66. package/tests/features/kill.test.ts +0 -24
  67. package/tests/features/manual-edits.test.tsx +0 -118
  68. package/tests/features/npm-import.test.tsx +0 -47
  69. package/tests/features/parent-directory-import.test.tsx +0 -26
  70. package/tests/features/platform-config.test.tsx +0 -23
  71. package/tests/features/prioritize-default-export.test.tsx +0 -27
  72. package/tests/features/project-config.test.tsx +0 -25
  73. package/tests/features/static-file-imports/static-file-import.test.ts +0 -50
  74. package/tests/fixtures/preload.ts +0 -10
  75. package/tests/fixtures/resourcePaths.ts +0 -3
  76. package/tests/node-resolution/node-module-resolution-1.test.tsx +0 -32
  77. package/tests/node-resolution/node-module-resolution-10.test.tsx +0 -30
  78. package/tests/node-resolution/node-module-resolution-11.test.tsx +0 -41
  79. package/tests/node-resolution/node-module-resolution-2.test.tsx +0 -33
  80. package/tests/node-resolution/node-module-resolution-3.test.tsx +0 -38
  81. package/tests/node-resolution/node-module-resolution-4.test.tsx +0 -29
  82. package/tests/node-resolution/node-module-resolution-5.test.tsx +0 -38
  83. package/tests/node-resolution/node-module-resolution-6.test.tsx +0 -40
  84. package/tests/node-resolution/node-module-resolution-7.test.tsx +0 -43
  85. package/tests/node-resolution/node-module-resolution-8.test.tsx +0 -32
  86. package/tests/node-resolution/node-module-resolution-9.test.tsx +0 -29
  87. package/tests/node-resolution/node-modules-resolution-12.test.tsx +0 -30
  88. package/tests/repros/group-wrapper.test.tsx +0 -18
  89. package/tests/repros/nine-keyboard-default-export.test.tsx +0 -26
  90. package/tests/util-fns/get-imports-from-code.test.tsx +0 -93
  91. package/tests/util-fns/getPossibleEntrypointComponentPaths.test.ts +0 -35
  92. package/tsconfig.json +0 -34
  93. package/tsup-lib.config.ts +0 -11
  94. package/tsup-runner.config.ts +0 -12
  95. package/tsup-webworker.config.ts +0 -21
  96. package/webworker/entrypoint.ts +0 -227
  97. package/webworker/eval-compiled-js.ts +0 -61
  98. package/webworker/execution-context.ts +0 -64
  99. package/webworker/fetchProxy.ts +0 -83
  100. package/webworker/import-eval-path.ts +0 -78
  101. package/webworker/import-local-file.ts +0 -93
  102. package/webworker/import-node-module.ts +0 -54
  103. package/webworker/import-npm-package.ts +0 -77
  104. package/webworker/import-snippet.ts +0 -30
  105. package/webworker/index.ts +0 -1
  106. package/webworker/transform-with-sucrase.ts +0 -68
@@ -1,77 +0,0 @@
1
- import { evalCompiledJs } from "./eval-compiled-js"
2
- import type { ExecutionContext } from "./execution-context"
3
- import { dirname } from "lib/utils/dirname"
4
- import Debug from "debug"
5
- import { getImportsFromCode } from "lib/utils/get-imports-from-code"
6
- import { importEvalPath } from "./import-eval-path"
7
- import { transformWithSucrase } from "./transform-with-sucrase"
8
-
9
- const debug = Debug("tsci:eval:import-npm-package")
10
-
11
- function extractPackagePathFromJSDelivr(url: string) {
12
- const prefix = "https://cdn.jsdelivr.net/npm/"
13
- if (url.startsWith(prefix)) {
14
- return url.substring(prefix.length).replace(/\/\+esm$/, "")
15
- }
16
- return url
17
- }
18
-
19
- export async function importNpmPackage(
20
- importName: string,
21
- ctx: ExecutionContext,
22
- depth = 0,
23
- ) {
24
- debug(`importing npm package: ${importName}`)
25
- const { preSuppliedImports } = ctx
26
-
27
- if (preSuppliedImports[importName]) return
28
-
29
- const npmCdnUrl = `https://cdn.jsdelivr.net/npm/${importName}/+esm`
30
-
31
- let finalUrl: string | undefined
32
- const { content, error } = await globalThis
33
- .fetch(npmCdnUrl)
34
- .then(async (res) => {
35
- finalUrl = res.url
36
- if (!res.ok)
37
- throw new Error(
38
- `Could not fetch "${importName}" from jsdelivr: ${res.statusText}`,
39
- )
40
- return { content: await res.text(), error: null }
41
- })
42
- .catch((e) => ({ error: e, content: null }))
43
-
44
- if (error) {
45
- console.error("Error fetching npm import", importName, error)
46
- throw error
47
- }
48
-
49
- const finalImportName = extractPackagePathFromJSDelivr(finalUrl!)
50
- const cwd = dirname(finalImportName)
51
-
52
- const importNames = getImportsFromCode(content!)
53
- for (const subImportName of importNames) {
54
- if (!preSuppliedImports[subImportName]) {
55
- await importEvalPath(subImportName, ctx, depth + 1, {
56
- cwd,
57
- })
58
- }
59
- }
60
-
61
- const transformedCode = transformWithSucrase(
62
- content!,
63
- finalImportName || importName,
64
- )
65
- try {
66
- const exports = evalCompiledJs(
67
- transformedCode,
68
- preSuppliedImports,
69
- cwd,
70
- ).exports
71
- preSuppliedImports[importName] = exports
72
- preSuppliedImports[finalImportName] = exports
73
- preSuppliedImports[finalUrl!] = exports
74
- } catch (e: any) {
75
- throw new Error(`Eval npm package error for "${importName}": ${e.message}`)
76
- }
77
- }
@@ -1,30 +0,0 @@
1
- import { evalCompiledJs } from "./eval-compiled-js"
2
- import type { ExecutionContext } from "./execution-context"
3
-
4
- export async function importSnippet(
5
- importName: string,
6
- ctx: ExecutionContext,
7
- depth = 0,
8
- ) {
9
- const { preSuppliedImports } = ctx
10
- const fullSnippetName = importName.replace("@tsci/", "").replace(".", "/")
11
-
12
- const { cjs, error } = await globalThis
13
- .fetch(`${ctx.cjsRegistryUrl}/${fullSnippetName}`)
14
- .then(async (res) => ({ cjs: await res.text(), error: null }))
15
- .catch((e) => ({ error: e, cjs: null }))
16
-
17
- if (error) {
18
- console.error("Error fetching import", importName, error)
19
- return
20
- }
21
-
22
- try {
23
- preSuppliedImports[importName] = evalCompiledJs(
24
- cjs!,
25
- preSuppliedImports,
26
- ).exports
27
- } catch (e) {
28
- console.error("Error importing snippet", e)
29
- }
30
- }
@@ -1 +0,0 @@
1
- export * from "./entrypoint"
@@ -1,68 +0,0 @@
1
- import { transform, type Transform as SucraseTransform } from "sucrase"
2
-
3
- const TS_EXTENSIONS = new Set([".ts", ".tsx", ".mts", ".cts"])
4
- const JSX_EXTENSIONS = new Set([".tsx", ".jsx", ".ts"])
5
-
6
- const stripQueryAndHash = (filePath: string) => {
7
- const queryIndex = filePath.indexOf("?")
8
- const hashIndex = filePath.indexOf("#")
9
-
10
- let endIndex = filePath.length
11
-
12
- if (queryIndex !== -1 && hashIndex !== -1) {
13
- endIndex = Math.min(queryIndex, hashIndex)
14
- } else if (queryIndex !== -1) {
15
- endIndex = queryIndex
16
- } else if (hashIndex !== -1) {
17
- endIndex = hashIndex
18
- }
19
-
20
- return filePath.slice(0, endIndex)
21
- }
22
-
23
- const getExtension = (filePath: string) => {
24
- const normalizedPath = stripQueryAndHash(filePath)
25
- const lastDotIndex = normalizedPath.lastIndexOf(".")
26
-
27
- if (lastDotIndex === -1) {
28
- return ""
29
- }
30
-
31
- const lastSlashIndex = Math.max(
32
- normalizedPath.lastIndexOf("/"),
33
- normalizedPath.lastIndexOf("\\"),
34
- )
35
-
36
- if (lastSlashIndex > lastDotIndex) {
37
- return ""
38
- }
39
-
40
- return normalizedPath.slice(lastDotIndex).toLowerCase()
41
- }
42
-
43
- const getTransformsForFilePath = (filePath: string) => {
44
- const extension = getExtension(filePath)
45
-
46
- const transforms: SucraseTransform[] = ["imports"]
47
-
48
- if (TS_EXTENSIONS.has(extension)) {
49
- transforms.unshift("typescript")
50
- }
51
-
52
- if (JSX_EXTENSIONS.has(extension)) {
53
- transforms.push("jsx")
54
- }
55
-
56
- return transforms
57
- }
58
-
59
- export const transformWithSucrase = (code: string, filePath: string) => {
60
- const transforms = getTransformsForFilePath(filePath)
61
- const { code: transformedCode } = transform(code, {
62
- filePath,
63
- production: true,
64
- transforms,
65
- })
66
-
67
- return transformedCode
68
- }