dsh-cad 0.2.0

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 (113) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +190 -0
  3. package/README.zh-CN.md +173 -0
  4. package/cordis.patch.yml +3 -0
  5. package/lib/b64.js +12 -0
  6. package/lib/cad_connector/builtin-executor.js +55 -0
  7. package/lib/cad_connector/builtin.js +8 -0
  8. package/lib/cad_connector/executor.js +76 -0
  9. package/lib/cad_connector/freecad-executor.js +398 -0
  10. package/lib/cad_connector/freecad.js +8 -0
  11. package/lib/cad_connector/fusion360-executor.js +398 -0
  12. package/lib/cad_connector/fusion360.js +8 -0
  13. package/lib/cad_connector/gstarcad3d.js +8 -0
  14. package/lib/cad_connector/index.js +20 -0
  15. package/lib/cad_connector/onshape.js +8 -0
  16. package/lib/cad_connector/solidworks.js +8 -0
  17. package/lib/cad_connector/types.js +6 -0
  18. package/lib/cad_connector/zw3d.js +8 -0
  19. package/lib/client.js +4117 -0
  20. package/lib/client.js.map +7 -0
  21. package/lib/convert/dcprt.js +38 -0
  22. package/lib/convert/detect.js +22 -0
  23. package/lib/convert/dxf.js +124 -0
  24. package/lib/convert/index.js +70 -0
  25. package/lib/convert/obj.js +106 -0
  26. package/lib/convert/png.js +114 -0
  27. package/lib/convert/step-worker.mjs +61 -0
  28. package/lib/convert/step.js +66 -0
  29. package/lib/convert/stl.js +110 -0
  30. package/lib/convert/svg.js +101 -0
  31. package/lib/demo-bracket.brep +668 -0
  32. package/lib/demo-flange.brep +709 -0
  33. package/lib/demo-shaft.brep +516 -0
  34. package/lib/feature_script/dc_asm.js +17 -0
  35. package/lib/feature_script/dc_engineering.js +19 -0
  36. package/lib/feature_script/dc_prt.js +21 -0
  37. package/lib/feature_script/index.js +7 -0
  38. package/lib/image/profile.js +218 -0
  39. package/lib/index.js +77 -0
  40. package/lib/modeling/assembly.js +63 -0
  41. package/lib/modeling/bin-format.js +80 -0
  42. package/lib/modeling/bin-store.js +67 -0
  43. package/lib/modeling/client.js +117 -0
  44. package/lib/modeling/document.js +55 -0
  45. package/lib/modeling/drawing.js +324 -0
  46. package/lib/modeling/hlr.cjs +328 -0
  47. package/lib/modeling/modeling-worker.cjs +235 -0
  48. package/lib/modeling/occt-adapter.cjs +271 -0
  49. package/lib/routes.js +142 -0
  50. package/lib/store.js +68 -0
  51. package/lib/tools/cad-freecad.js +160 -0
  52. package/lib/tools/cad-fusion.js +138 -0
  53. package/lib/tools/cad-image.js +121 -0
  54. package/lib/tools/cad-info.js +92 -0
  55. package/lib/tools/cad-model.js +816 -0
  56. package/lib/tools/cad-view.js +112 -0
  57. package/lib/tools/util.js +25 -0
  58. package/lib/types/b64.d.ts +8 -0
  59. package/lib/types/cad/builtin.d.ts +3 -0
  60. package/lib/types/cad/freecad.d.ts +3 -0
  61. package/lib/types/cad/fusion360.d.ts +3 -0
  62. package/lib/types/cad/gstarcad3d.d.ts +3 -0
  63. package/lib/types/cad/index.d.ts +8 -0
  64. package/lib/types/cad/onshape.d.ts +3 -0
  65. package/lib/types/cad/solidworks.d.ts +3 -0
  66. package/lib/types/cad/types.d.ts +21 -0
  67. package/lib/types/cad/zw3d.d.ts +3 -0
  68. package/lib/types/cad_connector/builtin-executor.d.ts +9 -0
  69. package/lib/types/cad_connector/builtin.d.ts +3 -0
  70. package/lib/types/cad_connector/executor.d.ts +69 -0
  71. package/lib/types/cad_connector/freecad-executor.d.ts +55 -0
  72. package/lib/types/cad_connector/freecad.d.ts +3 -0
  73. package/lib/types/cad_connector/fusion360-executor.d.ts +11 -0
  74. package/lib/types/cad_connector/fusion360.d.ts +3 -0
  75. package/lib/types/cad_connector/gstarcad3d.d.ts +3 -0
  76. package/lib/types/cad_connector/index.d.ts +8 -0
  77. package/lib/types/cad_connector/onshape.d.ts +3 -0
  78. package/lib/types/cad_connector/solidworks.d.ts +3 -0
  79. package/lib/types/cad_connector/types.d.ts +21 -0
  80. package/lib/types/cad_connector/zw3d.d.ts +3 -0
  81. package/lib/types/convert/dcprt.d.ts +14 -0
  82. package/lib/types/convert/detect.d.ts +7 -0
  83. package/lib/types/convert/dxf.d.ts +3 -0
  84. package/lib/types/convert/index.d.ts +9 -0
  85. package/lib/types/convert/obj.d.ts +7 -0
  86. package/lib/types/convert/png.d.ts +8 -0
  87. package/lib/types/convert/step.d.ts +4 -0
  88. package/lib/types/convert/stl.d.ts +7 -0
  89. package/lib/types/convert/svg.d.ts +8 -0
  90. package/lib/types/feature_script/dc_asm.d.ts +40 -0
  91. package/lib/types/feature_script/dc_engineering.d.ts +55 -0
  92. package/lib/types/feature_script/dc_prt.d.ts +37 -0
  93. package/lib/types/feature_script/index.d.ts +7 -0
  94. package/lib/types/image/profile.d.ts +28 -0
  95. package/lib/types/index.d.ts +18 -0
  96. package/lib/types/modeling/assembly.d.ts +17 -0
  97. package/lib/types/modeling/bin-format.d.ts +42 -0
  98. package/lib/types/modeling/bin-store.d.ts +20 -0
  99. package/lib/types/modeling/client.d.ts +125 -0
  100. package/lib/types/modeling/document.d.ts +26 -0
  101. package/lib/types/modeling/drawing.d.ts +38 -0
  102. package/lib/types/routes.d.ts +27 -0
  103. package/lib/types/store.d.ts +18 -0
  104. package/lib/types/tools/cad-freecad.d.ts +10 -0
  105. package/lib/types/tools/cad-fusion.d.ts +8 -0
  106. package/lib/types/tools/cad-image.d.ts +8 -0
  107. package/lib/types/tools/cad-info.d.ts +6 -0
  108. package/lib/types/tools/cad-model.d.ts +13 -0
  109. package/lib/types/tools/cad-view.d.ts +10 -0
  110. package/lib/types/tools/util.d.ts +4 -0
  111. package/lib/types/types.d.ts +142 -0
  112. package/lib/types.js +25 -0
  113. package/package.json +91 -0
@@ -0,0 +1,112 @@
1
+ /**
2
+ * The `cad_view` tool: load a CAD file, convert it to a renderable scene, and
3
+ * project presentation metadata the Web UI card renders as a 3D/2D viewer.
4
+ */
5
+ import { basename } from 'node:path';
6
+ import { defineTool } from '@deepseek-ai/dsh-tools';
7
+ import { detectFormat, is3DFormat } from '../convert/detect.js';
8
+ import { convert } from '../convert/index.js';
9
+ import { sceneStats } from '../types.js';
10
+ import { loadCadFile, resolveWorkspacePath } from './util.js';
11
+ function formatBounds(stats) {
12
+ if (stats.boundsMin === undefined || stats.boundsMax === undefined)
13
+ return '';
14
+ const min = stats.boundsMin;
15
+ const max = stats.boundsMax;
16
+ return `bounds [${min.map((v) => v.toFixed(2)).join(', ')}] → [${max.map((v) => v.toFixed(2)).join(', ')}]`;
17
+ }
18
+ /** Build the cad_view tool definition over the scene store. */
19
+ export function createCadViewTool(deps) {
20
+ return defineTool({
21
+ name: 'cad_view',
22
+ description: 'Open a CAD file in the interactive viewer embedded in the chat UI. ' +
23
+ '3D: STL, OBJ, STEP (.step/.stp), IGES (.iges/.igs), BREP, DCPRT (.dcprt native part document). 2D: DXF, SVG. ' +
24
+ 'The card shows the geometry (orbit/zoom for 3D, pan/zoom for 2D) plus a geometry summary. ' +
25
+ 'Use it whenever the user wants to see, inspect, or verify CAD geometry; the returned summary carries bounds and counts.',
26
+ parameters: {
27
+ path: {
28
+ type: 'string',
29
+ required: true,
30
+ description: 'Path to the CAD file, absolute or relative to the workspace root.',
31
+ },
32
+ },
33
+ output: {
34
+ schema: {
35
+ type: 'object',
36
+ additionalProperties: false,
37
+ properties: {
38
+ viewId: { type: 'string', required: true, description: 'Viewer scene id.' },
39
+ kind: { type: 'string', enum: ['3d', '2d'], required: true, description: 'Viewer kind.' },
40
+ format: { type: 'string', required: true, description: 'Detected source format.' },
41
+ file: { type: 'string', required: true, description: 'Resolved file path.' },
42
+ sceneUrl: { type: 'string', description: 'Same-origin JSON scene URL (web compositions only).' },
43
+ triangles: { type: 'number', description: 'Total triangle count (3D).' },
44
+ meshes: { type: 'number', description: 'Part count (3D).' },
45
+ entities: { type: 'number', description: 'Drawing entity count (2D).' },
46
+ },
47
+ },
48
+ render: (_args, value) => {
49
+ const lines = [`CAD viewer: ${value.file} (${value.format.toUpperCase()}, ${value.kind.toUpperCase()})`];
50
+ if (value.kind === '3d') {
51
+ lines.push(`${value.meshes ?? 0} part(s), ${value.triangles ?? 0} triangles`);
52
+ }
53
+ else {
54
+ lines.push(`${value.entities ?? 0} entities`);
55
+ }
56
+ return [{ type: 'text', text: lines.join('\n') }];
57
+ },
58
+ presentationMeta: (_args, value) => ({
59
+ viewId: value.viewId,
60
+ kind: value.kind,
61
+ format: value.format,
62
+ file: basename(value.file),
63
+ ...(value.sceneUrl === undefined ? {} : { sceneUrl: value.sceneUrl }),
64
+ title: `${basename(value.file)} · ${value.format.toUpperCase()}`,
65
+ stats: {
66
+ ...(value.meshes === undefined ? {} : { meshes: value.meshes }),
67
+ ...(value.triangles === undefined ? {} : { triangles: value.triangles }),
68
+ ...(value.entities === undefined ? {} : { entities: value.entities }),
69
+ },
70
+ }),
71
+ },
72
+ timeoutMs: 180_000,
73
+ isConcurrencySafe: () => true,
74
+ async execute(args) {
75
+ const resolved = resolveWorkspacePath(args.path, deps.workspaceRoot);
76
+ const name = basename(resolved);
77
+ const format = detectFormat(name);
78
+ if (format === null) {
79
+ throw new Error(`unsupported CAD format: ${name} — supported extensions are .stl .obj .step .stp .iges .igs .brep .dcprt .dxf .svg`);
80
+ }
81
+ const buffer = await loadCadFile(resolved);
82
+ const scene = await convert(buffer, format, name);
83
+ const stats = sceneStats(scene);
84
+ const viewId = await deps.store.put(scene);
85
+ const kind = is3DFormat(format) ? '3d' : '2d';
86
+ const sceneUrlBase = deps.ensureSceneRoute();
87
+ // Optional fields spread conditionally: an explicit undefined value
88
+ // would fail the registry's lossless-JSON output validation.
89
+ return {
90
+ viewId,
91
+ kind,
92
+ format,
93
+ file: resolved,
94
+ ...(sceneUrlBase === null ? {} : { sceneUrl: `${sceneUrlBase}/${viewId}` }),
95
+ ...(stats.triangles === undefined ? {} : { triangles: stats.triangles }),
96
+ ...(stats.meshes === undefined ? {} : { meshes: stats.meshes }),
97
+ ...(stats.entities === undefined ? {} : { entities: stats.entities }),
98
+ };
99
+ },
100
+ presentCall: (args) => ({
101
+ card: 'generic',
102
+ title: `CAD view ${args.path}`,
103
+ kind: 'other',
104
+ }),
105
+ presentResult: (args, result) => ({
106
+ card: 'generic',
107
+ title: result.isError
108
+ ? `CAD view ${args.path} failed`
109
+ : `CAD viewer: ${args.path}`,
110
+ }),
111
+ });
112
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shared tool helpers: path resolution and file loading. CAD payloads are
3
+ * binary, so reads go through node:fs (the platform fs service exposes only
4
+ * UTF-8 text reads); relative paths resolve against the workspace root like
5
+ * every other model-facing path.
6
+ */
7
+ import { readFile, stat } from 'node:fs/promises';
8
+ import path from 'node:path';
9
+ /** Resolve a model-supplied path against the workspace root. */
10
+ export function resolveWorkspacePath(input, workspaceRoot) {
11
+ return path.isAbsolute(input) ? input : path.join(workspaceRoot, input);
12
+ }
13
+ /** Load a CAD file buffer, failing with model-friendly errors. */
14
+ export async function loadCadFile(resolvedPath) {
15
+ let info;
16
+ try {
17
+ info = await stat(resolvedPath);
18
+ }
19
+ catch {
20
+ throw new Error(`CAD file not found: ${resolvedPath}`);
21
+ }
22
+ if (!info.isFile())
23
+ throw new Error(`not a file: ${resolvedPath}`);
24
+ return readFile(resolvedPath);
25
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Base64 codecs for typed arrays. Node (host) encodes; the browser card
3
+ * decodes. Kept dependency-free on both sides.
4
+ */
5
+ /** Encode a Float32Array's buffer as base64 (Node, host side). */
6
+ export declare function encodeF32B64(array: Float32Array): string;
7
+ /** Encode a Uint32Array's buffer as base64 (Node, host side). */
8
+ export declare function encodeU32B64(array: Uint32Array): string;
@@ -0,0 +1,3 @@
1
+ /** The built-in modeling kernel: opencascade.js (WASM) in a worker, rendered with WebGL/three.js. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const BUILTIN_CONNECTOR: CadConnector;
@@ -0,0 +1,3 @@
1
+ /** FreeCAD — first external executor planned. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const FREECAD_CONNECTOR: CadConnector;
@@ -0,0 +1,3 @@
1
+ /** Fusion 360 — planned external executor. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const FUSION360_CONNECTOR: CadConnector;
@@ -0,0 +1,3 @@
1
+ /** GstarCAD 3D / 浩辰3D — planned external executor. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const GSTARCAD3D_CONNECTOR: CadConnector;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Connector registry, ordered like the README table: the built-in kernel
3
+ * first, then external CAD executors by support status.
4
+ */
5
+ import type { CadConnector } from './types.js';
6
+ export declare const CONNECTORS: readonly CadConnector[];
7
+ export declare function connectorById(id: string): CadConnector | undefined;
8
+ export * from './types.js';
@@ -0,0 +1,3 @@
1
+ /** Onshape — planned external executor, cloud-native. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const ONSHAPE_CONNECTOR: CadConnector;
@@ -0,0 +1,3 @@
1
+ /** SolidWorks — planned external executor. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const SOLIDWORKS_CONNECTOR: CadConnector;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Connector contracts: how dsh-cad describes the CAD engines it can drive.
3
+ * The built-in WebGL/OCCT kernel is one entry; external engines (FreeCAD,
4
+ * SolidWorks, …) are executors reached through the language declared here.
5
+ */
6
+ export type ConnectorStatus = 'built-in' | 'coming-soon' | 'planned';
7
+ /**
8
+ * The language/binding a connector speaks. `sdk` marks vendor
9
+ * secondary-development kits whose surface is not a single language.
10
+ */
11
+ export type ExecutorLanguage = 'webgl' | 'python' | 'csharp' | 'cpp' | 'javascript' | 'rest' | 'sdk';
12
+ export interface CadConnector {
13
+ id: string;
14
+ label: string;
15
+ vendor: string;
16
+ /** The external language this engine is driven through. */
17
+ language: ExecutorLanguage;
18
+ status: ConnectorStatus;
19
+ /** Short note on the binding path. */
20
+ binding?: string;
21
+ }
@@ -0,0 +1,3 @@
1
+ /** ZW3D / 中望3D — planned external executor. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const ZW3D_CONNECTOR: CadConnector;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The built-in kernel as a GeometryExecutor: runs a one-shot op program on an
3
+ * ISOLATED OCCT worker (never the shared modeling-session worker), so
4
+ * executor-driven runs can't clobber live session state. This is the same
5
+ * primitive .dcprt replay uses.
6
+ */
7
+ import type { GeometryExecutor } from './executor.js';
8
+ /** The shared WASM kernel always exists in this build. */
9
+ export declare const BUILTIN_EXECUTOR: GeometryExecutor;
@@ -0,0 +1,3 @@
1
+ /** The built-in modeling kernel: opencascade.js (WASM) in a worker, rendered with WebGL/three.js. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const BUILTIN_CONNECTOR: CadConnector;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * GeometryExecutor — the unified backend access contract.
3
+ *
4
+ * The display layer is one WebGL pipeline and never changes; what varies is
5
+ * HOW geometry is produced. Every backend (the built-in OCCT/WASM kernel,
6
+ * FreeCAD, Fusion 360, a future SolidWorks bridge…) implements this one
7
+ * interface over the same op program shape, so swapping executors changes
8
+ * only the quality of the produced geometry — never the frontend.
9
+ */
10
+ /** The mesh currency shared by every executor and the binary scene store. */
11
+ export interface ExecutorMesh {
12
+ bodyId: string;
13
+ name: string;
14
+ positions: Float32Array;
15
+ normals: Float32Array;
16
+ indices: Uint32Array;
17
+ vertexCount: number;
18
+ triangleCount: number;
19
+ }
20
+ /** A CAD file loaded as the initial body before the ops run. */
21
+ export interface ExecutorInput {
22
+ format: 'step' | 'stp' | 'brep' | 'stl';
23
+ path: string;
24
+ bodyId?: string;
25
+ }
26
+ export interface ExecutorExport {
27
+ format: 'step' | 'stp' | 'stl';
28
+ path: string;
29
+ }
30
+ /** The canonical op program every executor understands. */
31
+ export interface GeometryProgram {
32
+ ops: Array<Record<string, unknown>>;
33
+ /** bodyId → display name (from create ops). */
34
+ names?: Record<string, string>;
35
+ input?: ExecutorInput;
36
+ export?: ExecutorExport;
37
+ /** Keep the result on screen in the engine's own window, when supported. */
38
+ display?: boolean;
39
+ }
40
+ export interface GeometryResult {
41
+ meshes: ExecutorMesh[];
42
+ volumes: Record<string, number>;
43
+ exported?: string;
44
+ }
45
+ export interface RunOptions {
46
+ timeoutMs?: number;
47
+ }
48
+ export interface GeometryExecutor {
49
+ id: string;
50
+ label: string;
51
+ /** Whether this executor is usable on the current machine right now. */
52
+ available(): boolean;
53
+ /** Human-readable reason when unavailable (install guidance). */
54
+ unavailableReason?(): string;
55
+ /** Run one op program; rejects on any executor failure. */
56
+ run(program: GeometryProgram, options?: RunOptions): Promise<GeometryResult>;
57
+ }
58
+ /**
59
+ * LLM callers emit op shapes liberally. Normalize the common variants onto
60
+ * the canonical op shape before validation/execution:
61
+ * - {op:"cut", target, tools} → {kind:"boolean", op:"cut", ...}
62
+ * - {op:"create_prim", kind:"box", dx:...} → {kind:"create_prim", prim:"box", params:{dx:...}}
63
+ * - {kind:"create_prim", prim, dx:...} → params folded in
64
+ */
65
+ export declare function normalizeOps(raw: unknown[]): Array<Record<string, unknown>>;
66
+ /** Op discriminators the canonical program accepts. */
67
+ export declare function isKnownOpKind(kind: unknown): boolean;
68
+ export declare const EXECUTORS: readonly GeometryExecutor[];
69
+ export declare function executorById(id: string): GeometryExecutor | undefined;
@@ -0,0 +1,55 @@
1
+ import type { GeometryExecutor } from './executor.js';
2
+ /** Mesh shape shared with the WASM worker pipeline. */
3
+ export interface FreeCadMesh {
4
+ bodyId: string;
5
+ name: string;
6
+ positions: Float32Array;
7
+ normals: Float32Array;
8
+ indices: Uint32Array;
9
+ vertexCount: number;
10
+ triangleCount: number;
11
+ }
12
+ export interface FreeCadProgram {
13
+ ops: Array<Record<string, unknown>>;
14
+ /** bodyId → display name (from create ops). */
15
+ names?: Record<string, string>;
16
+ input?: {
17
+ format: 'step' | 'stp' | 'brep' | 'stl';
18
+ path: string;
19
+ bodyId?: string;
20
+ };
21
+ export?: {
22
+ format: 'step' | 'stp' | 'stl';
23
+ path: string;
24
+ };
25
+ /** Put the final bodies into a FreeCAD document so the GUI shows them. */
26
+ display?: boolean;
27
+ }
28
+ export interface FreeCadResult {
29
+ meshes: FreeCadMesh[];
30
+ volumes: Record<string, number>;
31
+ exported?: string;
32
+ }
33
+ /**
34
+ * Locate a FreeCAD console executable: FREECAD_BIN env → PATH candidates →
35
+ * common install directories. Cached after the first probe. Pass
36
+ * `{ gui: true }` for the GUI binary (windowed) variant.
37
+ */
38
+ export declare function findFreeCad(options?: {
39
+ gui?: boolean;
40
+ }): string | null;
41
+ /** Whether an external FreeCAD executor is usable on this machine. */
42
+ export declare function freecadAvailable(): boolean;
43
+ export interface RunFreeCadOptions {
44
+ timeoutMs?: number;
45
+ /** Run in the FreeCAD GUI (detached window that stays open, showing the bodies). */
46
+ gui?: boolean;
47
+ }
48
+ /**
49
+ * Run a feature program in an external FreeCAD process and return tessellated
50
+ * meshes + volumes (+ exported file path). Console mode waits for exit; GUI
51
+ * mode detaches the windowed process and polls for the result file.
52
+ */
53
+ export declare function runFreeCadProgram(program: FreeCadProgram, options?: RunFreeCadOptions): Promise<FreeCadResult>;
54
+ /** The GeometryExecutor contract over the FreeCAD console/GUI bridge. */
55
+ export declare const FREECAD_EXECUTOR: GeometryExecutor;
@@ -0,0 +1,3 @@
1
+ /** FreeCAD — external executor, live via the local console binary. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const FREECAD_CONNECTOR: CadConnector;
@@ -0,0 +1,11 @@
1
+ import type { GeometryExecutor, GeometryProgram, GeometryResult, RunOptions } from './executor.js';
2
+ /** Locate a Fusion 360 application bundle/binary, or null when absent. */
3
+ export declare function findFusion360(): string | null;
4
+ /** Whether the Fusion executor is usable on this machine. */
5
+ export declare function fusion360Available(): boolean;
6
+ /** Idempotently install the resident bridge add-in next to its manifest. */
7
+ export declare function installFusionBridge(): Promise<string>;
8
+ /** Write a job, make sure Fusion is running, poll for the bridge result. */
9
+ export declare function runFusionProgram(program: GeometryProgram, options?: RunOptions): Promise<GeometryResult>;
10
+ /** The GeometryExecutor contract over the Fusion GUI bridge. */
11
+ export declare const FUSION360_EXECUTOR: GeometryExecutor;
@@ -0,0 +1,3 @@
1
+ /** Fusion 360 — external executor via the resident-add-in GUI bridge. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const FUSION360_CONNECTOR: CadConnector;
@@ -0,0 +1,3 @@
1
+ /** GstarCAD 3D / 浩辰3D — planned external executor. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const GSTARCAD3D_CONNECTOR: CadConnector;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Connector registry, ordered like the README table: the built-in kernel
3
+ * first, then external CAD executors by support status.
4
+ */
5
+ import type { CadConnector } from './types.js';
6
+ export declare const CONNECTORS: readonly CadConnector[];
7
+ export declare function connectorById(id: string): CadConnector | undefined;
8
+ export * from './types.js';
@@ -0,0 +1,3 @@
1
+ /** Onshape — planned external executor, cloud-native. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const ONSHAPE_CONNECTOR: CadConnector;
@@ -0,0 +1,3 @@
1
+ /** SolidWorks — planned external executor (Windows-only COM/.NET). */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const SOLIDWORKS_CONNECTOR: CadConnector;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Connector contracts: how dsh-cad describes the CAD engines it can drive.
3
+ * The built-in WebGL/OCCT kernel is one entry; external engines (FreeCAD,
4
+ * SolidWorks, …) are executors reached through the language declared here.
5
+ */
6
+ export type ConnectorStatus = 'built-in' | 'available' | 'experimental' | 'coming-soon' | 'planned';
7
+ /**
8
+ * The language/binding a connector speaks. `sdk` marks vendor
9
+ * secondary-development kits whose surface is not a single language.
10
+ */
11
+ export type ExecutorLanguage = 'webgl' | 'python' | 'csharp' | 'cpp' | 'javascript' | 'rest' | 'sdk';
12
+ export interface CadConnector {
13
+ id: string;
14
+ label: string;
15
+ vendor: string;
16
+ /** The external language this engine is driven through. */
17
+ language: ExecutorLanguage;
18
+ status: ConnectorStatus;
19
+ /** Short note on the binding path. */
20
+ binding?: string;
21
+ }
@@ -0,0 +1,3 @@
1
+ /** ZW3D / 中望3D — planned external executor. */
2
+ import type { CadConnector } from './types.js';
3
+ export declare const ZW3D_CONNECTOR: CadConnector;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * .dcprt converter: parse the native part document, replay its feature
3
+ * history on the OCCT worker, and tessellate the rebuilt bodies into
4
+ * indexed CadMeshes.
5
+ *
6
+ * Replay runs on the SHARED worker (via runModelOp): the opencascade.js WASM
7
+ * heap is too large for a second concurrent instance. Every replay posts a
8
+ * `reset`, which bumps the client's reset epoch — the live modeling session
9
+ * detects the stale epoch and re-replays its own document before the next
10
+ * modeling op, so out-of-band replays cannot corrupt the session.
11
+ */
12
+ import type { CadMesh } from '../types.js';
13
+ /** Convert a .dcprt buffer to indexed CadMeshes by replaying its features. */
14
+ export declare function parseDcprt(buffer: Buffer, fallbackName: string, timeoutMs?: number): Promise<CadMesh[]>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * CAD format detection by file extension (case-insensitive). Returns null for
3
+ * formats this plugin does not consume.
4
+ */
5
+ export type CadFormat = 'stl' | 'obj' | 'step' | 'iges' | 'brep' | 'dxf' | 'svg' | 'dcprt';
6
+ export declare function detectFormat(fileName: string): CadFormat | null;
7
+ export declare function is3DFormat(format: CadFormat): boolean;
@@ -0,0 +1,3 @@
1
+ import type { CadDrawing2D } from '../types.js';
2
+ /** Convert DXF text into a 2D drawing. */
3
+ export declare function parseDXF(text: string): CadDrawing2D;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * File buffer → CadScene: format dispatch, bounds computation, unit handling.
3
+ */
4
+ import type { CadScene, CadScene3D, CadMesh } from '../types.js';
5
+ import type { CadFormat } from './detect.js';
6
+ /** Scan a set of CadMeshes for their axis-aligned bounds. */
7
+ export declare function computeMeshBounds(meshes: CadMesh[]): CadScene3D['bounds'];
8
+ /** Convert a supported CAD file buffer into a renderable scene. */
9
+ export declare function convert(buffer: Buffer, format: CadFormat, fileName: string): Promise<CadScene>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Minimal OBJ parser (v / vn / f with polygon triangulation, o / g groups).
3
+ * Ignores materials, curves, and other entities the viewer cannot show.
4
+ */
5
+ import type { CadMesh } from '../types.js';
6
+ /** Convert OBJ text into CadMeshes (one per non-empty group). */
7
+ export declare function parseOBJ(text: string, fallbackName: string): CadMesh[];
@@ -0,0 +1,8 @@
1
+ export interface GrayImage {
2
+ width: number;
3
+ height: number;
4
+ /** Luma per pixel, row-major, 0–255. */
5
+ gray: Uint8Array;
6
+ }
7
+ /** Decode a PNG buffer to a luma image. */
8
+ export declare function decodePng(buffer: Buffer): GrayImage;
@@ -0,0 +1,4 @@
1
+ import type { CadMesh } from '../types.js';
2
+ export type OcctFormat = 'step' | 'iges' | 'brep';
3
+ /** Convert a STEP/IGES/BREP buffer to indexed CadMeshes. */
4
+ export declare function parseOcct(buffer: Buffer, format: OcctFormat, fallbackName: string, timeoutMs?: number): Promise<CadMesh[]>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Minimal STL parser (binary and ASCII) producing indexed triangle meshes.
3
+ * Written by hand so the host side carries no Three.js dependency.
4
+ */
5
+ import type { CadMesh } from '../types.js';
6
+ /** Convert an STL buffer into one indexed CadMesh. */
7
+ export declare function parseSTL(buffer: Buffer, name: string): CadMesh;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * SVG → CadDrawing2D. The raw SVG source is carried through and rendered in a
3
+ * sandboxed <img>; entities/bounds are a best-effort scan of basic shapes for
4
+ * the stats line.
5
+ */
6
+ import type { CadDrawing2D } from '../types.js';
7
+ /** Extract the renderable entity subset from an SVG document. */
8
+ export declare function parseSVG(text: string): CadDrawing2D;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * dsh-cad assembly document (`.dcasm`) — instances of parts placed in one
3
+ * coordinate system. Parts are referenced, never embedded, so an assembly
4
+ * stays small and part edits propagate on reload.
5
+ *
6
+ * Placement mirrors the `cad_transform` op semantics (mm, Z-up, Euler degrees)
7
+ * so an instance can be materialized by replaying a transform on the
8
+ * referenced body.
9
+ */
10
+ export declare const DC_ASM_FORMAT: "dcasm";
11
+ export declare const DC_ASM_EXTENSION = ".dcasm";
12
+ export interface DcAsmHeader {
13
+ format: typeof DC_ASM_FORMAT;
14
+ version: 1;
15
+ units: 'mm';
16
+ upAxis: 'Z';
17
+ }
18
+ export interface DcAsmPlacement {
19
+ at: [number, number, number];
20
+ /** Euler XYZ rotation in degrees, matching `cad_transform`. */
21
+ rotate?: [number, number, number];
22
+ mirror?: [number, number, number];
23
+ }
24
+ export type DcAsmSource = {
25
+ kind: 'body';
26
+ bodyId: string;
27
+ } | {
28
+ kind: 'prt';
29
+ path: string;
30
+ };
31
+ export interface DcAsmInstance {
32
+ instanceId: string;
33
+ source: DcAsmSource;
34
+ placement: DcAsmPlacement;
35
+ }
36
+ export interface DcAsmDocument {
37
+ header: DcAsmHeader;
38
+ instances: DcAsmInstance[];
39
+ }
40
+ export declare function isDcAsmDocument(value: unknown): value is DcAsmDocument;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * dsh-cad engineering drawing document (`.dceng`) — a 2D sheet referencing 3D
3
+ * models through projected views, plus dimensions. Views are projections of
4
+ * referenced parts/bodies, so the drawing stays in sync with the geometry.
5
+ *
6
+ * Default sheet is A4 landscape (297 × 210 mm), matching the DXF/SVG 2D
7
+ * pipeline's true-drawing-units convention.
8
+ */
9
+ export declare const DC_ENG_FORMAT: "dceng";
10
+ export declare const DC_ENG_EXTENSION = ".dceng";
11
+ export declare const DC_ENG_SHEET_A4: DcEngSheet;
12
+ export interface DcEngHeader {
13
+ format: typeof DC_ENG_FORMAT;
14
+ version: 1;
15
+ units: 'mm';
16
+ }
17
+ export interface DcEngSheet {
18
+ width: number;
19
+ height: number;
20
+ }
21
+ export type DcEngProjection = 'front' | 'top' | 'right' | 'iso';
22
+ export type DcEngSource = {
23
+ kind: 'body';
24
+ bodyId: string;
25
+ } | {
26
+ kind: 'prt';
27
+ path: string;
28
+ };
29
+ export interface DcEngView {
30
+ viewId: string;
31
+ projection: DcEngProjection;
32
+ source: DcEngSource;
33
+ /** Sheet-space placement of the view origin. */
34
+ at: [number, number];
35
+ scale: number;
36
+ }
37
+ export type DcEngDimensionKind = 'linear' | 'diameter' | 'radius' | 'angle';
38
+ export interface DcEngDimension {
39
+ dimensionId: string;
40
+ kind: DcEngDimensionKind;
41
+ /** Sheet-space anchor points; the value is derived unless overridden. */
42
+ from: [number, number];
43
+ to?: [number, number];
44
+ /** Explicit override for derived dimensions. */
45
+ value?: number;
46
+ }
47
+ export interface DcEngDocument {
48
+ header: DcEngHeader;
49
+ sheet: DcEngSheet;
50
+ /** Sheet-wide default scale (1:2 = 0.5); views may override. */
51
+ scale: number;
52
+ views: DcEngView[];
53
+ dimensions: DcEngDimension[];
54
+ }
55
+ export declare function isDcEngDocument(value: unknown): value is DcEngDocument;