@tscircuit/eval 0.0.362 → 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 (108) hide show
  1. package/dist/blob-url.js +1 -1
  2. package/dist/webworker/entrypoint.js +120 -120
  3. package/package.json +7 -4
  4. package/.github/workflows/bun-formatcheck.yml +0 -27
  5. package/.github/workflows/bun-pver-release.yml +0 -70
  6. package/.github/workflows/bun-test.yml +0 -87
  7. package/.github/workflows/bun-typecheck.yml +0 -27
  8. package/.github/workflows/playwright.yml +0 -40
  9. package/.github/workflows/update-deps.yml +0 -47
  10. package/.github/workflows/update-tscircuit-core.yml +0 -59
  11. package/biome.json +0 -50
  12. package/browser-tests/browser.test.ts +0 -15
  13. package/browser-tests/browsertest.html +0 -15
  14. package/browser-tests/browsertest.ts +0 -53
  15. package/bunfig.toml +0 -6
  16. package/lib/getPlatformConfig.ts +0 -41
  17. package/lib/getPossibleEntrypointComponentPaths.ts +0 -42
  18. package/lib/index.ts +0 -5
  19. package/lib/runner/CircuitRunner.ts +0 -201
  20. package/lib/runner/index.ts +0 -4
  21. package/lib/runner/normalizeFsMap.ts +0 -20
  22. package/lib/runner/resolveFilePath.ts +0 -90
  23. package/lib/runner/runTscircuitCode.ts +0 -30
  24. package/lib/runner/runTscircuitModule.ts +0 -37
  25. package/lib/runner/setupDefaultEntrypointIfNeeded.ts +0 -81
  26. package/lib/shared/static-asset-extensions.ts +0 -10
  27. package/lib/shared/types.ts +0 -79
  28. package/lib/utils/dirname.ts +0 -21
  29. package/lib/utils/get-imports-from-code.ts +0 -23
  30. package/lib/utils/index.ts +0 -1
  31. package/lib/utils/resolve-node-module.ts +0 -193
  32. package/lib/worker.ts +0 -246
  33. package/playwright.config.ts +0 -23
  34. package/scripts/build-worker-blob-url.ts +0 -27
  35. package/scripts/copy-core-versions.ts +0 -81
  36. package/scripts/validate-test-matrix.js +0 -148
  37. package/tests/circuit-runner/circuitrunner1-readme-example.test.tsx +0 -29
  38. package/tests/custom-component-with-fsmap/should-reject-invalid-main-component-path.test.ts +0 -26
  39. package/tests/custom-component-with-fsmap/should-render-multiple-components-from-fsmap.test.ts +0 -46
  40. package/tests/custom-component-with-fsmap/should-render-single-component-from-fsmap.test.ts +0 -38
  41. package/tests/examples/__snapshots__/example18-kicad-footprint-server.snap.svg +0 -1
  42. package/tests/examples/example01-readme-example.test.tsx +0 -30
  43. package/tests/examples/example02-multiple-files.test.tsx +0 -45
  44. package/tests/examples/example03-encoded-url.test.tsx +0 -28
  45. package/tests/examples/example04-root-child-issue.test.tsx +0 -37
  46. package/tests/examples/example05-event-recording.test.tsx +0 -44
  47. package/tests/examples/example06-dynamic-load-blob-url.test.tsx +0 -29
  48. package/tests/examples/example07-import-default-and-namespace.test.tsx +0 -74
  49. package/tests/examples/example08-footprinter-to220.test.tsx +0 -30
  50. package/tests/examples/example09-not-defined-component.test.tsx +0 -24
  51. package/tests/examples/example10-run-tscircuit-code.test.tsx +0 -14
  52. package/tests/examples/example11-flexible-import-extensions.test.tsx +0 -20
  53. package/tests/examples/example12-import-from-subdirectory.test.tsx +0 -26
  54. package/tests/examples/example13-webworker-without-entrypoint.test.tsx +0 -32
  55. package/tests/examples/example14-run-tscircuit-module.test.tsx +0 -20
  56. package/tests/examples/example15-run-tscircuit-module-with-props.test.tsx +0 -24
  57. package/tests/examples/example16-parts-engine.test.tsx +0 -118
  58. package/tests/examples/example17-parse-tscircuit-config.test.tsx +0 -49
  59. package/tests/examples/example18-kicad-footprint-server.test.tsx +0 -39
  60. package/tests/examples/example19-support-backwards-compat.test.tsx +0 -31
  61. package/tests/examples/example20-kicad-import.test.tsx +0 -48
  62. package/tests/features/circuit-event-forwarding.test.tsx +0 -45
  63. package/tests/features/enable-debug.test.ts +0 -26
  64. package/tests/features/execute-component-runner.test.tsx +0 -47
  65. package/tests/features/execute-component-worker.test.tsx +0 -25
  66. package/tests/features/fetch-proxy/fetch-override.test.ts +0 -46
  67. package/tests/features/fetch-proxy/fetch-proxy-validation.test.ts +0 -95
  68. package/tests/features/kill.test.ts +0 -24
  69. package/tests/features/manual-edits.test.tsx +0 -118
  70. package/tests/features/npm-import.test.tsx +0 -47
  71. package/tests/features/parent-directory-import.test.tsx +0 -26
  72. package/tests/features/platform-config.test.tsx +0 -23
  73. package/tests/features/prioritize-default-export.test.tsx +0 -27
  74. package/tests/features/project-config.test.tsx +0 -25
  75. package/tests/features/static-file-imports/static-file-import.test.ts +0 -50
  76. package/tests/fixtures/preload.ts +0 -10
  77. package/tests/fixtures/resourcePaths.ts +0 -3
  78. package/tests/node-resolution/node-module-resolution-1.test.tsx +0 -32
  79. package/tests/node-resolution/node-module-resolution-10.test.tsx +0 -30
  80. package/tests/node-resolution/node-module-resolution-11.test.tsx +0 -41
  81. package/tests/node-resolution/node-module-resolution-2.test.tsx +0 -33
  82. package/tests/node-resolution/node-module-resolution-3.test.tsx +0 -38
  83. package/tests/node-resolution/node-module-resolution-4.test.tsx +0 -29
  84. package/tests/node-resolution/node-module-resolution-5.test.tsx +0 -38
  85. package/tests/node-resolution/node-module-resolution-6.test.tsx +0 -40
  86. package/tests/node-resolution/node-module-resolution-7.test.tsx +0 -43
  87. package/tests/node-resolution/node-module-resolution-8.test.tsx +0 -32
  88. package/tests/node-resolution/node-module-resolution-9.test.tsx +0 -29
  89. package/tests/node-resolution/node-modules-resolution-12.test.tsx +0 -30
  90. package/tests/repros/group-wrapper.test.tsx +0 -18
  91. package/tests/repros/nine-keyboard-default-export.test.tsx +0 -26
  92. package/tests/util-fns/get-imports-from-code.test.tsx +0 -93
  93. package/tests/util-fns/getPossibleEntrypointComponentPaths.test.ts +0 -35
  94. package/tsconfig.json +0 -34
  95. package/tsup-lib.config.ts +0 -11
  96. package/tsup-runner.config.ts +0 -12
  97. package/tsup-webworker.config.ts +0 -21
  98. package/webworker/entrypoint.ts +0 -227
  99. package/webworker/eval-compiled-js.ts +0 -61
  100. package/webworker/execution-context.ts +0 -64
  101. package/webworker/fetchProxy.ts +0 -83
  102. package/webworker/import-eval-path.ts +0 -78
  103. package/webworker/import-local-file.ts +0 -93
  104. package/webworker/import-node-module.ts +0 -54
  105. package/webworker/import-npm-package.ts +0 -77
  106. package/webworker/import-snippet.ts +0 -30
  107. package/webworker/index.ts +0 -1
  108. package/webworker/transform-with-sucrase.ts +0 -68
@@ -1,148 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { readdirSync, statSync, readFileSync } from "fs"
4
- import { join } from "path"
5
- import { fileURLToPath } from "url"
6
- import { dirname } from "path"
7
-
8
- const __filename = fileURLToPath(import.meta.url)
9
- const __dirname = dirname(__filename)
10
-
11
- const testsDir = join(__dirname, "..", "tests")
12
- const workflowFile = join(
13
- __dirname,
14
- "..",
15
- ".github",
16
- "workflows",
17
- "bun-test.yml",
18
- )
19
-
20
- // Get all directories in tests/ that contain test files
21
- function getTestDirectories() {
22
- const entries = readdirSync(testsDir)
23
- const testDirs = []
24
-
25
- for (const entry of entries) {
26
- const fullPath = join(testsDir, entry)
27
-
28
- // Skip non-directories
29
- if (!statSync(fullPath).isDirectory()) continue
30
-
31
- // Skip hidden directories like .claude
32
- if (entry.startsWith(".")) continue
33
-
34
- // Check if directory contains test files
35
- if (hasTestFiles(fullPath)) {
36
- testDirs.push(entry)
37
- }
38
- }
39
-
40
- return testDirs.sort()
41
- }
42
-
43
- // Check if a directory contains test files (recursively)
44
- function hasTestFiles(dirPath) {
45
- try {
46
- const entries = readdirSync(dirPath)
47
-
48
- for (const entry of entries) {
49
- const fullPath = join(dirPath, entry)
50
- const stat = statSync(fullPath)
51
-
52
- if (
53
- stat.isFile() &&
54
- (entry.endsWith(".test.ts") || entry.endsWith(".test.tsx"))
55
- ) {
56
- return true
57
- }
58
-
59
- if (stat.isDirectory() && hasTestFiles(fullPath)) {
60
- return true
61
- }
62
- }
63
-
64
- return false
65
- } catch (error) {
66
- console.warn(`Warning: Could not read directory ${dirPath}`)
67
- return false
68
- }
69
- }
70
-
71
- // Extract test directories from workflow file
72
- function getWorkflowTestDirectories() {
73
- const workflowContent = readFileSync(workflowFile, "utf8")
74
-
75
- // Look for the matrix test-dir configuration
76
- const matrixMatch = workflowContent.match(/test-dir:\s*\[(.*?)\]/s)
77
-
78
- if (!matrixMatch) {
79
- throw new Error(
80
- "Could not find test-dir matrix configuration in workflow file",
81
- )
82
- }
83
-
84
- const matrixContent = matrixMatch[1]
85
- const dirs = matrixContent
86
- .split(",")
87
- .map((dir) => dir.trim().replace(/['"]/g, ""))
88
- .filter((dir) => dir.length > 0)
89
- .sort()
90
-
91
- return dirs
92
- }
93
-
94
- function main() {
95
- console.log("🔍 Validating test matrix configuration...")
96
-
97
- const actualTestDirs = getTestDirectories()
98
- const workflowTestDirs = getWorkflowTestDirectories()
99
-
100
- console.log(
101
- `Found ${actualTestDirs.length} test directories:`,
102
- actualTestDirs,
103
- )
104
- console.log(
105
- `Workflow covers ${workflowTestDirs.length} directories:`,
106
- workflowTestDirs,
107
- )
108
-
109
- const missing = actualTestDirs.filter(
110
- (dir) => !workflowTestDirs.includes(dir),
111
- )
112
- const extra = workflowTestDirs.filter((dir) => !actualTestDirs.includes(dir))
113
-
114
- if (missing.length > 0) {
115
- console.error(
116
- "❌ ERROR: The following test directories are NOT covered by the workflow matrix:",
117
- )
118
- for (const dir of missing) {
119
- console.error(` - ${dir}`)
120
- }
121
- console.error(
122
- "\nPlease add these directories to the test-dir matrix in .github/workflows/bun-test.yml",
123
- )
124
- }
125
-
126
- if (extra.length > 0) {
127
- console.warn(
128
- "⚠️ WARNING: The following directories in the workflow matrix do not contain test files:",
129
- )
130
- for (const dir of extra) {
131
- console.warn(` - ${dir}`)
132
- }
133
- console.warn(
134
- "\nConsider removing these from the test-dir matrix in .github/workflows/bun-test.yml",
135
- )
136
- }
137
-
138
- if (missing.length === 0 && extra.length === 0) {
139
- console.log(
140
- "✅ All test directories are properly covered by the workflow matrix!",
141
- )
142
- process.exit(0)
143
- } else {
144
- process.exit(1)
145
- }
146
- }
147
-
148
- main()
@@ -1,29 +0,0 @@
1
- import { createCircuitWebWorker } from "lib"
2
- import { expect, test } from "bun:test"
3
- import { CircuitRunner } from "lib/runner/CircuitRunner"
4
-
5
- test("circuitrunner1-readme-example", async () => {
6
- const circuitRunner = new CircuitRunner()
7
-
8
- await circuitRunner.execute(`
9
- import { RedLed } from "@tsci/seveibar.red-led"
10
-
11
- circuit.add(
12
- <board width="10mm" height="10mm">
13
- <RedLed name="LED1" />
14
- </board>
15
- )
16
- `)
17
-
18
- await circuitRunner.renderUntilSettled()
19
-
20
- const circuitJson = await circuitRunner.getCircuitJson()
21
-
22
- expect(circuitJson).toBeDefined()
23
-
24
- const led = circuitJson.find((el: any) => el.name === "LED1")
25
- expect(led).toBeDefined()
26
- expect(led?.type).toBe("source_component")
27
-
28
- await circuitRunner.kill()
29
- })
@@ -1,26 +0,0 @@
1
- import { expect, test } from "bun:test"
2
- import { createCircuitWebWorker } from "lib"
3
-
4
- test("should reject invalid mainComponentPath", async () => {
5
- const circuitWebWorker = createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- const worker = await circuitWebWorker
10
- expect(
11
- worker.executeWithFsMap({
12
- fsMap: {
13
- "index.tsx": `
14
- export default () => (
15
- <board width="10mm" height="10mm">
16
- <resistor resistance="1k" footprint="0402" name="E1" />
17
- </board>
18
- );
19
- `,
20
- },
21
- mainComponentPath: "myled.tsx",
22
- }),
23
- ).rejects.toThrow('File not found "myled.tsx"')
24
-
25
- await worker.kill()
26
- })
@@ -1,46 +0,0 @@
1
- import { expect, test } from "bun:test"
2
- import { createCircuitWebWorker } from "lib"
3
-
4
- test("should render multiple components from FSMap", async () => {
5
- const circuitWebWorker = createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- const worker = await circuitWebWorker
10
- await worker.executeWithFsMap({
11
- fsMap: {
12
- "index.tsx": `
13
- export default () => (
14
- <board width="10mm" height="10mm">
15
- <resistor resistance="1k" footprint="0402" name="E1" />
16
- <resistor resistance="1k" footprint="0402" name="E2" />
17
- <resistor resistance="1k" footprint="0402" name="E3" />
18
- <resistor resistance="1k" footprint="0402" name="E4" />
19
- </board>
20
- );
21
-
22
- `,
23
- "myled.tsx": `
24
- export default () => (
25
- <board width="10mm" height="10mm">
26
- <resistor resistance="1k" footprint="0402" name="F1" />
27
- <resistor resistance="1k" footprint="0402" name="F2" />
28
- <resistor resistance="1k" footprint="0402" name="F3" />
29
- <resistor resistance="1k" footprint="0402" name="F4" />
30
- </board>
31
- );
32
-
33
- `,
34
- },
35
- mainComponentPath: "myled.tsx",
36
- })
37
-
38
- await worker.renderUntilSettled()
39
-
40
- const circuitJson = await worker.getCircuitJson()
41
- expect(
42
- circuitJson.filter((el: any) => el.name?.startsWith("F")),
43
- ).toHaveLength(4)
44
-
45
- await worker.kill()
46
- })
@@ -1,38 +0,0 @@
1
- import { expect, test } from "bun:test"
2
- import { createCircuitWebWorker } from "lib"
3
-
4
- test("should render single component from FSMap", async () => {
5
- const circuitWebWorker = createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- const worker = await circuitWebWorker
10
- await worker.executeWithFsMap({
11
- fsMap: {
12
- "index.tsx": `
13
- export default () => (
14
- <board width="10mm" height="10mm">
15
- <resistor resistance="1k" footprint="0402" name="E1" />
16
- </board>
17
- );
18
-
19
- `,
20
- "myled.tsx": `
21
- export default () => (
22
- <board width="10mm" height="10mm">
23
- <resistor resistance="1k" footprint="0402" name="F1" />
24
- </board>
25
- );
26
-
27
- `,
28
- },
29
- mainComponentPath: "myled.tsx",
30
- })
31
-
32
- await worker.renderUntilSettled()
33
-
34
- const circuitJson = await worker.getCircuitJson()
35
- expect(circuitJson.filter((el: any) => el.name === "F1")).toHaveLength(1)
36
-
37
- await worker.kill()
38
- })
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.706"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="69.204152249135" y="139.44636678200698" width="661.5916955017301" height="321.10726643598616"/><path class="pcb-board" d="M 69.204152249135 460.55363321799314 L 730.795847750865 460.55363321799314 L 730.795847750865 139.44636678200698 L 69.204152249135 139.44636678200698 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="6.920415224913495"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 503.11418685121106 300.00000000000006 L 296.88581314878894 300.00000000000006" stroke-width="10.380622837370241" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-layer="top"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 296.88581314878894 300.00000000000006 L 296.88581314878894 300.00000000000006" stroke-width="10.380622837370241" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="484.42906574394465" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="555.0173010380622" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="207.61245674740485" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><rect class="pcb-pad" fill="rgb(200, 52, 52)" x="278.20069204152253" y="277.8546712802769" width="37.37024221453287" height="44.29065743944637" data-layer="top"/><path class="pcb-silkscreen pcb-silkscreen-top" d="M 573.7024221453287 250.17301038062288 L 470.5882352941177 250.17301038062288 L 470.5882352941177 349.82698961937723 L 573.7024221453287 349.82698961937723" fill="none" stroke="#f2eda1" stroke-width="6.920415224913495" stroke-linecap="round" stroke-linejoin="round" data-pcb-component-id="pcb_component_1" data-pcb-silkscreen-path-id="pcb_silkscreen_path_0"/><path class="pcb-silkscreen pcb-silkscreen-top" d="M 250.95910034602076 273.7024221453288 L 272.22429065743944 273.7024221453288" fill="none" stroke="#f2eda1" stroke-width="8.304498269896193" stroke-linecap="round" stroke-linejoin="round" data-pcb-component-id="pcb_component_0" data-pcb-silkscreen-path-id="pcb_silkscreen_path_1"/><path class="pcb-silkscreen pcb-silkscreen-top" d="M 250.95910034602076 326.2975778546713 L 272.22429065743944 326.2975778546713" fill="none" stroke="#f2eda1" stroke-width="8.304498269896193" stroke-linecap="round" stroke-linejoin="round" data-pcb-component-id="pcb_component_0" data-pcb-silkscreen-path-id="pcb_silkscreen_path_2"/><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="27.68166089965398" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,538.4083044982699,215.5709342560554)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_component_1" stroke="none">C1</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="101.73010380622837" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,261.5916955017301,219.03114186851218)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_component_0" stroke="none">R1</text></svg>
@@ -1,30 +0,0 @@
1
- import { createCircuitWebWorker } from "lib/worker"
2
- import { expect, test } from "bun:test"
3
-
4
- test("example1-readme-example", async () => {
5
- const circuitWebWorker = await createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- await circuitWebWorker.executeWithFsMap({
10
- fsMap: {
11
- "index.tsx": `
12
- export default () => (
13
- <led name="LED1" color="red" />
14
- )
15
- `,
16
- },
17
- })
18
-
19
- await circuitWebWorker.renderUntilSettled()
20
-
21
- const circuitJson = await circuitWebWorker.getCircuitJson()
22
-
23
- expect(circuitJson).toBeDefined()
24
-
25
- const led = circuitJson.find((el: any) => el.name === "LED1")
26
- expect(led).toBeDefined()
27
- expect(led?.type).toBe("source_component")
28
-
29
- await circuitWebWorker.kill()
30
- })
@@ -1,45 +0,0 @@
1
- import { createCircuitWebWorker } from "lib"
2
- import { expect, test } from "bun:test"
3
-
4
- test("virtual filesystem with components", async () => {
5
- const circuitWebWorker = await createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- await circuitWebWorker.executeWithFsMap({
10
- fsMap: {
11
- "entrypoint.tsx": `
12
- import { MyLed } from "./myled.tsx"
13
- import someJson from "./some.json"
14
-
15
- circuit.add(
16
- <board width="10mm" height="10mm">
17
- <MyLed name="LED1" />
18
- </board>
19
- )
20
- `,
21
- "myled.tsx": `
22
- import { RedLed } from "@tsci/seveibar.red-led"
23
-
24
- export const MyLed = ({ name }) => {
25
- return <RedLed name={name} />
26
- }
27
- `,
28
- "some.json": `
29
- {
30
- "some": "value"
31
- }
32
- `,
33
- },
34
- entrypoint: "entrypoint.tsx",
35
- })
36
-
37
- await circuitWebWorker.renderUntilSettled()
38
-
39
- const circuitJson = await circuitWebWorker.getCircuitJson()
40
-
41
- const led = circuitJson.find((el: any) => el.name === "LED1")
42
- expect(led?.type).toBe("source_component")
43
-
44
- await circuitWebWorker.kill()
45
- })
@@ -1,28 +0,0 @@
1
- import { createCircuitWebWorker } from "lib"
2
- import { expect, test } from "bun:test"
3
- // @ts-ignore
4
- import blobUrl from "../../dist/blob-url"
5
-
6
- test("example3-encoded-worker-url", async () => {
7
- const circuitWebWorker = await createCircuitWebWorker({
8
- webWorkerUrl: blobUrl,
9
- })
10
-
11
- await circuitWebWorker.execute(`
12
- circuit.add(
13
- <board width="10mm" height="10mm">
14
- <resistor resistance="1k" footprint="0402" name="R1" />
15
- </board>
16
- )
17
- `)
18
-
19
- await circuitWebWorker.renderUntilSettled()
20
-
21
- const circuitJson = await circuitWebWorker.getCircuitJson()
22
-
23
- const resistor = circuitJson.find((el: any) => el.name === "R1")
24
- expect(resistor).toBeDefined()
25
- expect(resistor?.type).toBe("source_component")
26
-
27
- await circuitWebWorker.kill()
28
- })
@@ -1,37 +0,0 @@
1
- import { test, expect } from "bun:test"
2
- import { createCircuitWebWorker } from "lib/index"
3
-
4
- const example4 = {
5
- entrypoint: "entrypoint.tsx",
6
- fsMap: {
7
- "entrypoint.tsx":
8
- '\nimport MyCircuit from "./snippet.tsx"\n\ncircuit.add(<MyCircuit />)\n\nconsole.log("rootComponent", circuit._guessRootComponent(), circuit.firstChild)\n',
9
- "snippet.tsx":
10
- 'import "@tscircuit/core"\nimport { useRedLed } from "@tsci/seveibar.red-led"\nimport { usePushButton } from "@tsci/seveibar.push-button"\nimport { useUsbC } from "@tsci/seveibar.smd-usb-c"\n\nexport default () => {\n const USBC = useUsbC("USBC")\n const Button = usePushButton("SW1")\n const Led = useRedLed("LED")\n return (\n <board width="12mm" height="30mm" schAutoLayoutEnabled>\n <USBC GND="net.GND" pcbY={-10} VBUS1="net.VBUS" />\n <Led neg="net.GND" pcbY={12} />\n <Button pcbY={0} pin2=".R1 > .pos" pin3="net.VBUS" />\n <resistor name="R1" footprint="0603" resistance="1k" pcbY={7} />\n <trace from=".R1 > .neg" to={Led.pos} />\n </board>\n )\n}\n',
11
- },
12
- }
13
-
14
- test(
15
- "example4-root-child-issue",
16
- async () => {
17
- const circuitWebWorker = await createCircuitWebWorker({
18
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
19
- })
20
-
21
- await circuitWebWorker.executeWithFsMap({
22
- fsMap: example4.fsMap,
23
- entrypoint: example4.entrypoint,
24
- })
25
-
26
- await circuitWebWorker.renderUntilSettled()
27
-
28
- const circuitJson = await circuitWebWorker.getCircuitJson()
29
-
30
- const led = circuitJson.find((el: any) => el.name === "LED")
31
- expect(led).toBeDefined()
32
- expect(led?.type).toBe("source_component")
33
-
34
- await circuitWebWorker.kill()
35
- },
36
- 30 * 1000,
37
- )
@@ -1,44 +0,0 @@
1
- import { test, expect } from "bun:test"
2
- import { createCircuitWebWorker } from "lib/index"
3
-
4
- // Skipped for flakiness, re-enable when flakiness is solved
5
- test.skip("example5-event-recording", async () => {
6
- const circuitWebWorker = await createCircuitWebWorker({
7
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
8
- })
9
-
10
- let eventCount = 0
11
- circuitWebWorker.on("board:renderPhaseStarted", (event) => {
12
- eventCount++
13
- })
14
-
15
- await circuitWebWorker.execute(`
16
- circuit.add(
17
- <board width="10mm" height="10mm">
18
- <resistor name="R1" resistance="1k" footprint="0402" />
19
- </board>
20
- )
21
- `)
22
-
23
- await circuitWebWorker.renderUntilSettled()
24
-
25
- expect(eventCount).toBeGreaterThan(0)
26
- const initialEventCount = eventCount
27
-
28
- // Clear event listeners
29
- circuitWebWorker.clearEventListeners()
30
-
31
- // Add another component to trigger more events
32
- await circuitWebWorker.execute(`
33
- circuit.add(
34
- <board width="10mm" height="10mm">
35
- <resistor name="R2" resistance="2k" footprint="0402" />
36
- </board>
37
- )
38
- `)
39
-
40
- await circuitWebWorker.renderUntilSettled()
41
-
42
- // Verify no new events were recorded after clearing listeners
43
- expect(eventCount).toBe(initialEventCount)
44
- })
@@ -1,29 +0,0 @@
1
- import { createCircuitWebWorker } from "lib"
2
- import { expect, test } from "bun:test"
3
-
4
- // TODO should skip b/c uses network
5
- test.skip("example6-dynamic-load-blob-url", async () => {
6
- const circuitWebWorker = await createCircuitWebWorker({})
7
-
8
- await circuitWebWorker.execute(`
9
- import { RedLed } from "@tsci/seveibar.red-led"
10
-
11
- circuit.add(
12
- <board width="10mm" height="10mm">
13
- <RedLed name="LED1" />
14
- </board>
15
- )
16
- `)
17
-
18
- await circuitWebWorker.renderUntilSettled()
19
-
20
- const circuitJson = await circuitWebWorker.getCircuitJson()
21
-
22
- expect(circuitJson).toBeDefined()
23
-
24
- const led = circuitJson.find((el: any) => el.name === "LED1")
25
- expect(led).toBeDefined()
26
- expect(led?.type).toBe("source_component")
27
-
28
- await circuitWebWorker.kill()
29
- })
@@ -1,74 +0,0 @@
1
- import { createCircuitWebWorker } from "lib"
2
- import { expect, test } from "bun:test"
3
-
4
- test("namespace import syntax", async () => {
5
- const circuitWebWorker = await createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- await circuitWebWorker.executeWithFsMap({
10
- fsMap: {
11
- "entrypoint.tsx": `
12
- import * as Components from "./component.tsx"
13
-
14
- circuit.add(
15
- <board width="10mm" height="10mm">
16
- <Components.MyComponent name="COMP1" />
17
- </board>
18
- )
19
- `,
20
- "component.tsx": `
21
- export const MyComponent = ({ name }) => {
22
- return <resistor name={name} resistance="10k" />
23
- }
24
- `,
25
- },
26
- entrypoint: "entrypoint.tsx",
27
- })
28
-
29
- await circuitWebWorker.renderUntilSettled()
30
-
31
- const circuitJson = await circuitWebWorker.getCircuitJson()
32
-
33
- const component = circuitJson.find((el: any) => el.name === "COMP1")
34
- expect(component).toBeDefined()
35
- expect(component?.type).toBe("source_component")
36
-
37
- await circuitWebWorker.kill()
38
- })
39
-
40
- test("combined default and namespace import with fallback", async () => {
41
- const circuitWebWorker = await createCircuitWebWorker({
42
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
43
- })
44
-
45
- await circuitWebWorker.executeWithFsMap({
46
- fsMap: {
47
- "board.tsx": `
48
- export const MyBoard = ({ name = "BOARD1" }) => {
49
- return (
50
- <board width="10mm" height="10mm">
51
- <resistor name={name} resistance="10k" />
52
- </board>
53
- )
54
- }
55
- `,
56
- "entrypoint.tsx": `
57
- import DefaultExport, * as OtherExports from "./board.tsx";
58
- let Board = DefaultExport ?? OtherExports[Object.keys(OtherExports).filter(k => k[0] === k[0].toUpperCase())[0]];
59
- circuit.add(<Board />)
60
- `,
61
- },
62
- entrypoint: "entrypoint.tsx",
63
- })
64
-
65
- await circuitWebWorker.renderUntilSettled()
66
-
67
- const circuitJson = await circuitWebWorker.getCircuitJson()
68
-
69
- const board = circuitJson.find((el: any) => el.name === "BOARD1")
70
- expect(board).toBeDefined()
71
- expect(board?.type).toBe("source_component")
72
-
73
- await circuitWebWorker.kill()
74
- })
@@ -1,30 +0,0 @@
1
- import { createCircuitWebWorker } from "lib/index"
2
- import { expect, test } from "bun:test"
3
-
4
- test("example8-footprinter-to220", async () => {
5
- const circuitWebWorker = await createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- await circuitWebWorker.execute(`
10
- circuit.add(
11
- <board width="10mm" height="10mm">
12
- <chip footprint="to220_3" name="U3" pcbX={15} pcbY={0} />
13
- </board>
14
- )
15
- `)
16
-
17
- await circuitWebWorker.renderUntilSettled()
18
-
19
- const circuitJson = await circuitWebWorker.getCircuitJson()
20
-
21
- const pcb_plated_hole = circuitJson.filter(
22
- (el: any) => el.type === "pcb_plated_hole",
23
- )
24
- expect(pcb_plated_hole).toBeDefined()
25
-
26
- const chip = circuitJson.find((el: any) => el.name === "U3")
27
- expect(chip).toBeDefined()
28
-
29
- await circuitWebWorker.kill()
30
- })
@@ -1,24 +0,0 @@
1
- import { createCircuitWebWorker } from "lib/index"
2
- import { expect, test } from "bun:test"
3
-
4
- test("example9-not-defined-component", async () => {
5
- const circuitWebWorker = await createCircuitWebWorker({
6
- webWorkerUrl: new URL("../../webworker/entrypoint.ts", import.meta.url),
7
- })
8
-
9
- expect(async () => {
10
- await circuitWebWorker.execute(`
11
- import { NotExportedComponent } from "@tsci/seveibar.a555timer";
12
-
13
- circuit.add(
14
- <board width="10mm" height="10mm">
15
- <NotExportedComponent name="01" />
16
- </board>
17
- );
18
- `)
19
- }).toThrowError(
20
- `Component "NotExportedComponent" is not exported by "@tsci/seveibar.a555timer"`,
21
- )
22
-
23
- await circuitWebWorker.kill()
24
- })
@@ -1,14 +0,0 @@
1
- import { describe, expect, test } from "bun:test"
2
- import { runTscircuitCode } from "lib/runner"
3
-
4
- test("example10 runTscircuitCode", async () => {
5
- const circuitJson = await runTscircuitCode(`
6
- export default () => (<resistor name="R1" resistance="1k" />)
7
- `)
8
-
9
- const resistor = circuitJson.find(
10
- (element) => element.type === "source_component" && element.name === "R1",
11
- )
12
-
13
- expect(resistor).toBeDefined()
14
- })