@tscircuit/eval 0.0.298 → 0.0.300
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 +178 -4
- package/dist/eval/index.js +9 -2
- package/dist/lib/index.d.ts +178 -4
- package/dist/lib/index.js +9 -2
- package/dist/webworker/entrypoint.js +381 -472
- package/lib/runner/resolveFilePath.ts +1 -1
- package/package.json +11 -10
- package/tests/features/import-obj-file.test.tsx +49 -0
- package/webworker/import-local-file.ts +7 -0
|
@@ -51,7 +51,7 @@ export const resolveFilePath = (
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Search for file with a set of different extensions
|
|
54
|
-
const extension = ["tsx", "ts", "json", "js", "jsx"]
|
|
54
|
+
const extension = ["tsx", "ts", "json", "js", "jsx", "obj"]
|
|
55
55
|
for (const ext of extension) {
|
|
56
56
|
const possibleFilePath = `${normalizedResolvedPath}.${ext}`
|
|
57
57
|
if (normalizedFilePathMap.has(possibleFilePath)) {
|
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.300",
|
|
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",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"@tscircuit/checks": "^0.0.71",
|
|
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.699",
|
|
61
61
|
"@tscircuit/footprinter": "^0.0.208",
|
|
62
62
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
63
63
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
64
64
|
"@tscircuit/layout": "^0.0.28",
|
|
65
65
|
"@tscircuit/log-soup": "^1.0.2",
|
|
66
|
-
"@tscircuit/matchpack": "^0.0.
|
|
67
|
-
"@tscircuit/math-utils": "^0.0.
|
|
66
|
+
"@tscircuit/matchpack": "^0.0.16",
|
|
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.298",
|
|
71
71
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
72
72
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
73
|
-
"@tscircuit/schematic-trace-solver": "^0.0.
|
|
73
|
+
"@tscircuit/schematic-trace-solver": "^0.0.34",
|
|
74
74
|
"@tscircuit/simple-3d-svg": "^0.0.38",
|
|
75
75
|
"@types/babel__standalone": "^7.1.9",
|
|
76
76
|
"@types/bun": "^1.2.16",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"@types/react-reconciler": "^0.28.9",
|
|
81
81
|
"bpc-graph": "^0.0.57",
|
|
82
82
|
"bun-match-svg": "0.0.12",
|
|
83
|
-
"calculate-elbow": "^0.0.
|
|
83
|
+
"calculate-elbow": "^0.0.11",
|
|
84
84
|
"chokidar-cli": "^3.0.0",
|
|
85
|
-
"circuit-json": "^0.0.
|
|
85
|
+
"circuit-json": "^0.0.245",
|
|
86
86
|
"circuit-json-to-bpc": "^0.0.13",
|
|
87
87
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
88
88
|
"circuit-json-to-simple-3d": "^0.0.6",
|
|
89
|
-
"circuit-to-svg": "^0.0.
|
|
89
|
+
"circuit-to-svg": "^0.0.185",
|
|
90
90
|
"comlink": "^4.4.2",
|
|
91
91
|
"concurrently": "^9.1.2",
|
|
92
92
|
"debug": "^4.3.6",
|
|
@@ -101,7 +101,8 @@
|
|
|
101
101
|
"ts-expect": "^1.3.0",
|
|
102
102
|
"tsup": "^8.2.4",
|
|
103
103
|
"minicssgrid": "^0.0.9",
|
|
104
|
-
"connectivity-map": "^1.0.0"
|
|
104
|
+
"connectivity-map": "^1.0.0",
|
|
105
|
+
"flatbush": "^4.5.0"
|
|
105
106
|
},
|
|
106
107
|
"peerDependencies": {
|
|
107
108
|
"typescript": "^5.0.0",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import type {
|
|
3
|
+
AnyCircuitElement,
|
|
4
|
+
AnySourceComponent,
|
|
5
|
+
CadComponent,
|
|
6
|
+
} from "circuit-json"
|
|
7
|
+
import { CircuitRunner } from "lib/runner/CircuitRunner"
|
|
8
|
+
|
|
9
|
+
test("should support importing .obj files", async () => {
|
|
10
|
+
const runner = new CircuitRunner()
|
|
11
|
+
|
|
12
|
+
const fsMap = {
|
|
13
|
+
"my-model.obj": `v 1.0 1.0 0.0`, // some dummy obj content
|
|
14
|
+
"user-code.tsx": `
|
|
15
|
+
import myObjUrl from "./my-model.obj"
|
|
16
|
+
|
|
17
|
+
export default () => (
|
|
18
|
+
<chip
|
|
19
|
+
name="C1"
|
|
20
|
+
cadModel={{
|
|
21
|
+
objUrl: myObjUrl,
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
`,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await runner.executeWithFsMap({
|
|
29
|
+
fsMap,
|
|
30
|
+
mainComponentPath: "user-code.tsx",
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
await runner.renderUntilSettled()
|
|
34
|
+
const circuitJson = await runner.getCircuitJson()
|
|
35
|
+
|
|
36
|
+
const chip =
|
|
37
|
+
(circuitJson.find(
|
|
38
|
+
(elm) => elm.type === "source_component" && elm.name === "C1",
|
|
39
|
+
) as AnyCircuitElement) || undefined
|
|
40
|
+
const cadModel =
|
|
41
|
+
(circuitJson.find((elm) => elm.type === "cad_component") as CadComponent) ||
|
|
42
|
+
undefined
|
|
43
|
+
|
|
44
|
+
expect(chip).toBeDefined()
|
|
45
|
+
expect(cadModel?.model_obj_url).toBeString()
|
|
46
|
+
expect(cadModel?.model_obj_url).toStartWith("blob:")
|
|
47
|
+
|
|
48
|
+
await runner.kill()
|
|
49
|
+
})
|
|
@@ -34,6 +34,13 @@ export const importLocalFile = async (
|
|
|
34
34
|
__esModule: true,
|
|
35
35
|
default: jsonData,
|
|
36
36
|
}
|
|
37
|
+
} else if (fsPath.endsWith(".obj")) {
|
|
38
|
+
const objBlob = new Blob([fileContent], { type: "model/obj" })
|
|
39
|
+
const objUrl = URL.createObjectURL(objBlob)
|
|
40
|
+
preSuppliedImports[fsPath] = {
|
|
41
|
+
__esModule: true,
|
|
42
|
+
default: objUrl,
|
|
43
|
+
}
|
|
37
44
|
} else if (fsPath.endsWith(".tsx") || fsPath.endsWith(".ts")) {
|
|
38
45
|
const importNames = getImportsFromCode(fileContent)
|
|
39
46
|
|