@tscircuit/eval 0.0.317 → 0.0.319
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/dist/blob-url.js +1 -1
- package/dist/eval/index.d.ts +18 -0
- package/dist/eval/index.js +9 -1
- package/dist/lib/index.d.ts +18 -0
- package/dist/lib/index.js +9 -1
- package/dist/webworker/entrypoint.js +355 -355
- package/package.json +8 -8
- package/tests/features/import-glb-file.test.tsx +54 -0
- package/webworker/import-local-file.ts +8 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/eval",
|
|
3
3
|
"main": "dist/lib/index.js",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.319",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "bun run build:lib && bun run build:webworker && bun run build:blob-url && bun run build:runner && bun run build:worker-wrapper",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"@biomejs/biome": "^1.8.3",
|
|
55
55
|
"@playwright/test": "^1.50.1",
|
|
56
56
|
"@tscircuit/capacity-autorouter": "^0.0.107",
|
|
57
|
-
"@tscircuit/checks": "^0.0.
|
|
57
|
+
"@tscircuit/checks": "^0.0.75",
|
|
58
58
|
"@tscircuit/circuit-json-flex": "^0.0.3",
|
|
59
59
|
"@tscircuit/circuit-json-util": "^0.0.67",
|
|
60
|
-
"@tscircuit/core": "^0.0.
|
|
60
|
+
"@tscircuit/core": "^0.0.722",
|
|
61
61
|
"@tscircuit/footprinter": "^0.0.236",
|
|
62
62
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
63
63
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"@tscircuit/math-utils": "^0.0.21",
|
|
68
68
|
"@tscircuit/miniflex": "^0.0.4",
|
|
69
69
|
"@tscircuit/parts-engine": "^0.0.8",
|
|
70
|
-
"@tscircuit/props": "0.0.
|
|
70
|
+
"@tscircuit/props": "0.0.319",
|
|
71
71
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
72
72
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
73
73
|
"@tscircuit/schematic-trace-solver": "^0.0.36",
|
|
74
|
-
"@tscircuit/simple-3d-svg": "^0.0.
|
|
74
|
+
"@tscircuit/simple-3d-svg": "^0.0.41",
|
|
75
75
|
"@types/babel__standalone": "^7.1.9",
|
|
76
76
|
"@types/bun": "^1.2.16",
|
|
77
77
|
"@types/debug": "^4.1.12",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"bun-match-svg": "0.0.12",
|
|
83
83
|
"calculate-elbow": "^0.0.12",
|
|
84
84
|
"chokidar-cli": "^3.0.0",
|
|
85
|
-
"circuit-json": "^0.0.
|
|
85
|
+
"circuit-json": "^0.0.251",
|
|
86
86
|
"circuit-json-to-bpc": "^0.0.13",
|
|
87
87
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
88
|
-
"circuit-json-to-simple-3d": "^0.0.
|
|
89
|
-
"circuit-to-svg": "^0.0.
|
|
88
|
+
"circuit-json-to-simple-3d": "^0.0.8",
|
|
89
|
+
"circuit-to-svg": "^0.0.189",
|
|
90
90
|
"comlink": "^4.4.2",
|
|
91
91
|
"concurrently": "^9.1.2",
|
|
92
92
|
"connectivity-map": "^1.0.0",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import type { AnyCircuitElement, CadComponent } from "circuit-json"
|
|
3
|
+
import { CircuitRunner } from "lib/runner/CircuitRunner"
|
|
4
|
+
|
|
5
|
+
test("should support importing .glb files", async () => {
|
|
6
|
+
const runner = new CircuitRunner()
|
|
7
|
+
|
|
8
|
+
const glbContent = "This is a dummy glb file"
|
|
9
|
+
|
|
10
|
+
const fsMap = {
|
|
11
|
+
"my-model.glb": glbContent,
|
|
12
|
+
"user-code.tsx": `
|
|
13
|
+
import myGlbUrl from "./my-model.glb"
|
|
14
|
+
|
|
15
|
+
export default () => (
|
|
16
|
+
<chip
|
|
17
|
+
name="C1"
|
|
18
|
+
cadModel={{
|
|
19
|
+
gltfUrl: myGlbUrl,
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
`,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
await runner.executeWithFsMap({
|
|
27
|
+
fsMap,
|
|
28
|
+
mainComponentPath: "user-code.tsx",
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
await runner.renderUntilSettled()
|
|
32
|
+
const circuitJson = await runner.getCircuitJson()
|
|
33
|
+
|
|
34
|
+
const chip =
|
|
35
|
+
(circuitJson.find(
|
|
36
|
+
(elm) => elm.type === "source_component" && elm.name === "C1",
|
|
37
|
+
) as AnyCircuitElement) || undefined
|
|
38
|
+
const cadModel =
|
|
39
|
+
(circuitJson.find((elm) => elm.type === "cad_component") as CadComponent) ||
|
|
40
|
+
undefined
|
|
41
|
+
|
|
42
|
+
expect(chip).toBeDefined()
|
|
43
|
+
expect(cadModel?.model_gltf_url).toBeString()
|
|
44
|
+
expect(cadModel?.model_gltf_url).toStartWith("blob:")
|
|
45
|
+
|
|
46
|
+
if (cadModel?.model_gltf_url) {
|
|
47
|
+
const response = await fetch(cadModel.model_gltf_url)
|
|
48
|
+
const arrayBuffer = await response.arrayBuffer()
|
|
49
|
+
const text = new TextDecoder().decode(arrayBuffer)
|
|
50
|
+
expect(text).toBe(glbContent)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
await runner.kill()
|
|
54
|
+
})
|
|
@@ -44,6 +44,14 @@ export const importLocalFile = async (
|
|
|
44
44
|
__esModule: true,
|
|
45
45
|
default: objUrl,
|
|
46
46
|
}
|
|
47
|
+
} else if (fsPath.endsWith(".glb")) {
|
|
48
|
+
const glbArray = Uint8Array.from(fileContent, (c) => c.charCodeAt(0))
|
|
49
|
+
const glbBlob = new Blob([glbArray], { type: "model/gltf-binary" })
|
|
50
|
+
const glbUrl = URL.createObjectURL(glbBlob)
|
|
51
|
+
preSuppliedImports[fsPath] = {
|
|
52
|
+
__esModule: true,
|
|
53
|
+
default: glbUrl,
|
|
54
|
+
}
|
|
47
55
|
} else if (fsPath.endsWith(".gltf")) {
|
|
48
56
|
const gltfJson = JSON.parse(fileContent)
|
|
49
57
|
const fileDir = dirname(fsPath)
|