@mulmoclaude/shapescript-plugin 1.2.0 → 1.4.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.
- package/README.md +19 -0
- package/dist/core/dispatch.d.ts +8 -3
- package/dist/core/dispatch.d.ts.map +1 -1
- package/dist/core/index.d.ts +5 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/paths.d.ts +5 -0
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core-CpVzK-0i.js +53 -0
- package/dist/core-bcFgqR_m.cjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -3
- package/dist/export/tool.d.ts +45 -0
- package/dist/export/tool.d.ts.map +1 -0
- package/dist/export/usdz.d.ts +17 -0
- package/dist/export/usdz.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/lang/de.d.ts.map +1 -1
- package/dist/lang/en.d.ts.map +1 -1
- package/dist/lang/es.d.ts.map +1 -1
- package/dist/lang/fr.d.ts.map +1 -1
- package/dist/lang/ja.d.ts.map +1 -1
- package/dist/lang/ko.d.ts.map +1 -1
- package/dist/lang/messages.d.ts +2 -0
- package/dist/lang/messages.d.ts.map +1 -1
- package/dist/lang/ptBR.d.ts.map +1 -1
- package/dist/lang/zh.d.ts.map +1 -1
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/renderer.d.ts +11 -0
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/tool.d.ts +118 -0
- package/dist/render/tool.d.ts.map +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.js +115 -11
- package/dist/samples-DPOGWslc.js +1038 -0
- package/dist/samples-DZNAeuSZ.cjs +210 -0
- package/dist/style.css +1 -1
- package/dist/{toThreeJS-B5LiF110.js → toThreeJS-BX_aeGdA.js} +18 -18
- package/dist/{toThreeJS-BOBpx5Dc.cjs → toThreeJS-XGDoVISb.cjs} +1 -1
- package/dist/vue/View.vue.d.ts.map +1 -1
- package/dist/vue.cjs +16 -16
- package/dist/vue.js +1760 -1716
- package/package.json +1 -1
- package/dist/samples-DHEKUNs5.cjs +0 -186
- package/dist/samples-SaXsqbHJ.js +0 -180
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ name, and the `Present3D*` type names, are renamed throughout.
|
|
|
13
13
|
| Entry | Contents |
|
|
14
14
|
| ------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
15
15
|
| `.` | `TOOL_NAME`, `TOOL_DEFINITION`, `executePresentShapeScript`, `pluginCore`, `samples`, `parseShapeScript`, `astToThreeJS`, `executeShapeScriptDispatch` + the `artifacts/shapes` path rules |
|
|
16
|
+
| `.` (export) | `shapeScriptToUsdz`, `sceneToUsdz`, `USDZ_MIME_TYPE`, `USDZ_EXTENSION`, and the **`exportShapeScriptUsdz`** tool (`executeExportShapeScriptUsdz`, `EXPORT_USDZ_*`). Browser-safe: it needs no canvas, so the View's "Download USDZ" button and a host's MCP tool run the same code. |
|
|
16
17
|
| `./render` | **server-only** — `renderShapeScriptSheet` and the render page. Rasterises a model to a PNG with Puppeteer's headless Chromium (an OPTIONAL peer); a host without one gets `RenderUnavailableError` carrying the install hint. |
|
|
17
18
|
| `./vue` | the `ToolPlugin` (View + Preview + `SYSTEM_PROMPT`), plus everything on `.` |
|
|
18
19
|
| `./style.css` | the compiled component styles (Vite lib mode does not auto-inject them) |
|
|
@@ -39,6 +40,24 @@ for i in 1 to count {
|
|
|
39
40
|
});
|
|
40
41
|
```
|
|
41
42
|
|
|
43
|
+
## USDZ export
|
|
44
|
+
|
|
45
|
+
`exportShapeScriptUsdz` writes a model out as a USDZ archive (AR Quick Look on Apple devices, or
|
|
46
|
+
any USD viewer). A host wires it against the same `{ files: { artifacts, byPath? } }` context shape
|
|
47
|
+
`executeShapeScriptDispatch` takes — a full `FileOps`, or just `read` / `write` / `exists`
|
|
48
|
+
(`ShapeFileOps`) — no browser, no `node:*`:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { executeExportShapeScriptUsdz, EXPORT_USDZ_TOOL_NAME, EXPORT_USDZ_DESCRIPTION, EXPORT_USDZ_SCHEMA, EXPORT_USDZ_PROMPT } from "@mulmoclaude/shapescript-plugin";
|
|
52
|
+
|
|
53
|
+
// register { name: EXPORT_USDZ_TOOL_NAME, description: EXPORT_USDZ_DESCRIPTION, inputSchema: EXPORT_USDZ_SCHEMA }
|
|
54
|
+
const { message, filePath } = await executeExportShapeScriptUsdz({ files: shapeFiles }, args);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The file lands at `artifacts/shapes/<slug>-<epoch-ms>-<token>.usdz`. The View's **Download USDZ**
|
|
58
|
+
button builds the same archive in the browser with `shapeScriptToUsdz` and saves it locally.
|
|
59
|
+
USDZ units are metres, so `size 1` is one metre in AR.
|
|
60
|
+
|
|
42
61
|
## ShapeScript language
|
|
43
62
|
|
|
44
63
|
- **Primitives**: `cube`, `sphere`, `cylinder`, `cone`, `torus`, `circle`, `square`, `polygon`
|
package/dist/core/dispatch.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { FileOps } from "gui-chat-protocol";
|
|
2
2
|
import type { ShapeScriptDispatchArgs } from "./contract";
|
|
3
|
+
/** The three FileOps methods this plugin's file paths actually use. A host's
|
|
4
|
+
* full `FileOps` satisfies it; so does a three-method object, which is what
|
|
5
|
+
* lets a host wire the `exportShapeScriptUsdz` MCP tool without reaching into
|
|
6
|
+
* its plugin runtime for a complete FileOps (that import cycles in MulmoClaude). */
|
|
7
|
+
export type ShapeFileOps = Pick<FileOps, "read" | "write" | "exists">;
|
|
3
8
|
/** Capabilities the dispatch router needs: the generic, shared
|
|
4
9
|
* `files.artifacts` FileOps, plus — for hosts that let presentShapeScript
|
|
5
10
|
* open sources outside `artifacts/shapes/` — `files.byPath`. */
|
|
6
11
|
export interface ShapeScriptDispatchContext {
|
|
7
12
|
files: {
|
|
8
|
-
artifacts:
|
|
9
|
-
byPath?:
|
|
13
|
+
artifacts: ShapeFileOps;
|
|
14
|
+
byPath?: ShapeFileOps;
|
|
10
15
|
};
|
|
11
16
|
}
|
|
12
17
|
/** The FileOps that owns a given source, plus the path in that FileOps' terms.
|
|
@@ -14,7 +19,7 @@ export interface ShapeScriptDispatchContext {
|
|
|
14
19
|
* capability an older host provides, and what writes there — while anything
|
|
15
20
|
* else needs the host's `files.byPath`. */
|
|
16
21
|
export declare function locateShape(context: ShapeScriptDispatchContext, filePath: string): {
|
|
17
|
-
files:
|
|
22
|
+
files: ShapeFileOps;
|
|
18
23
|
rel: string;
|
|
19
24
|
} | null;
|
|
20
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/core/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;iEAEiE;AACjE,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE;QAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/core/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;qFAGqF;AACrF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC;AAEtE;;iEAEiE;AACjE,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE;QAAE,SAAS,EAAE,YAAY,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC;CAC3D;AAED;;;4CAG4C;AAC5C,wBAAgB,WAAW,CAAC,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAK9H;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,0BAA0B,EACnC,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAqChD"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,10 +3,13 @@ export { TOOL_NAME, TOOL_DEFINITION } from "./definition";
|
|
|
3
3
|
export { pluginCore, presentShapeScript, executePresentShapeScript } from "./plugin";
|
|
4
4
|
export type { ShapeScriptExecuteContext } from "./plugin";
|
|
5
5
|
export { executeShapeScriptDispatch, locateShape } from "./dispatch";
|
|
6
|
-
export type { ShapeScriptDispatchContext } from "./dispatch";
|
|
6
|
+
export type { ShapeScriptDispatchContext, ShapeFileOps } from "./dispatch";
|
|
7
7
|
export { isShapeScriptDispatchArgs, readLoadShapeResult, readSaveShapeResult } from "./contract";
|
|
8
8
|
export type { LoadShapeArgs, SaveShapeArgs, ShapeScriptDispatchArgs, ShapeScriptDispatchResult } from "./contract";
|
|
9
|
-
export { isPresentableShapePath, isShapeArtifactPath, shapeArtifactPath, toArtifactsRelative, SHAPE_EXTENSIONS } from "./paths";
|
|
9
|
+
export { isPresentableShapePath, isShapeArtifactPath, shapeArtifactPath, usdzArtifactPath, toArtifactsRelative, SHAPE_EXTENSIONS } from "./paths";
|
|
10
|
+
export { sceneToUsdz, shapeScriptToUsdz, USDZ_MIME_TYPE, USDZ_EXTENSION } from "../export/usdz";
|
|
11
|
+
export { executeExportShapeScriptUsdz, EXPORT_USDZ_TOOL_NAME, EXPORT_USDZ_DESCRIPTION, EXPORT_USDZ_PROMPT, EXPORT_USDZ_SCHEMA, EXPORT_USDZ_TOOL_TIMEOUT_MS, } from "../export/tool";
|
|
12
|
+
export type { ExportUsdzResult } from "../export/tool";
|
|
10
13
|
export { samples } from "./samples";
|
|
11
14
|
export { parseShapeScript } from "../shapescript/parser";
|
|
12
15
|
export { astToThreeJS } from "../shapescript/toThreeJS";
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrF,YAAY,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrE,YAAY,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrF,YAAY,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrE,YAAY,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjG,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACnH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIlJ,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/core/paths.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export interface ShapePath {
|
|
|
21
21
|
* `write` replaces the first model with no error anywhere (codex on #3056).
|
|
22
22
|
* `token` is injectable so a test can assert the whole filename. */
|
|
23
23
|
export declare function shapeArtifactPath(title: string | undefined, now?: Date, token?: string): ShapePath;
|
|
24
|
+
/** Build a fresh path for a USDZ export, beside the `.shape` sources in the
|
|
25
|
+
* same flat `artifacts/shapes/` directory — an export is opened by name too,
|
|
26
|
+
* and the user finds it next to the model it came from. Same collision rule as
|
|
27
|
+
* `shapeArtifactPath`. */
|
|
28
|
+
export declare function usdzArtifactPath(title: string | undefined, now?: Date, token?: string): ShapePath;
|
|
24
29
|
/**
|
|
25
30
|
* Strict guard for a workspace-relative path the caller claims is an existing
|
|
26
31
|
* ShapeScript artifact. Rejects anything outside `artifacts/shapes/`,
|
package/dist/core/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AAoBA,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,qBAAsB,CAAC;AAEpD;yDACyD;AACzD,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,SAAsB,GAAG,MAAM,CAEzF;AAED,MAAM,WAAW,SAAS;IACxB;sDACkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB;gEAC4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAeD;;;;;;;;qEAQqE;AACrE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,IAAiB,EAAE,KAAK,GAAE,MAAsB,GAAG,SAAS,CAW7H;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;sDAEsD;AACtD,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;+DAG+D;AAC/D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/core/paths.ts"],"names":[],"mappings":"AAoBA,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,qBAAsB,CAAC;AAEpD;yDACyD;AACzD,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,SAAsB,GAAG,MAAM,CAEzF;AAED,MAAM,WAAW,SAAS;IACxB;sDACkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB;gEAC4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAeD;;;;;;;;qEAQqE;AACrE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,IAAiB,EAAE,KAAK,GAAE,MAAsB,GAAG,SAAS,CAW7H;AAED;;;2BAG2B;AAC3B,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,IAAiB,EAAE,KAAK,GAAE,MAAsB,GAAG,SAAS,CAW5H;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;sDAEsD;AACtD,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;+DAG+D;AAC/D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { _ as e, a as t, u as n } from "./samples-DPOGWslc.js";
|
|
2
|
+
import { t as r } from "./toThreeJS-BX_aeGdA.js";
|
|
3
|
+
//#region src/export/tool.ts
|
|
4
|
+
var i = "exportShapeScriptUsdz", a = r + 3e4, o = "Export a ShapeScript model to a USDZ file (Apple's AR / 3D format, openable with AR Quick Look on iPhone, iPad and Mac) and save it under artifacts/shapes/. Returns the saved path. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file. USDZ units are metres, so a `size 1` cube becomes a one-metre object in AR — scale the model in the script if that is not what the user wants.", s = "Use exportShapeScriptUsdz when the user wants to take a 3D model out of the chat — to view it in AR, open it in a 3D app, or share the file. It saves a .usdz next to the model's .shape file and returns the path; tell the user where it is. The user can also press \"Download USDZ\" in the model's view themselves.", c = {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
script: {
|
|
8
|
+
type: "string",
|
|
9
|
+
description: "ShapeScript source to export. Provide either this or `path`, not both."
|
|
10
|
+
},
|
|
11
|
+
path: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "Path to an existing .shape file to export (e.g. one presentShapeScript saved under artifacts/shapes/)."
|
|
14
|
+
},
|
|
15
|
+
title: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Name for the exported file; it is slugified into the filename. Defaults to the .shape file's own name when `path` is given."
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
required: []
|
|
21
|
+
};
|
|
22
|
+
function l(e) {
|
|
23
|
+
return typeof e == "string" && e.trim() !== "" ? e : void 0;
|
|
24
|
+
}
|
|
25
|
+
function u(e) {
|
|
26
|
+
return (e.split(/[\\/]/).pop() ?? e).replace(/\.shape$/i, "");
|
|
27
|
+
}
|
|
28
|
+
async function d(e, t) {
|
|
29
|
+
let r = l(t.script), i = l(t.path), a = l(t.title);
|
|
30
|
+
if (r && i) throw Error("Provide either `script` or `path`, not both");
|
|
31
|
+
if (r) return {
|
|
32
|
+
script: r,
|
|
33
|
+
title: a
|
|
34
|
+
};
|
|
35
|
+
if (!i) throw Error("Provide either `script` (inline source) or `path` (an existing .shape file)");
|
|
36
|
+
let o = n(e, i);
|
|
37
|
+
if (!o) throw Error("`path` must name a .shape file, without `.` / `..` segments");
|
|
38
|
+
if (!await o.files.exists(o.rel)) throw Error(`No ShapeScript exists at ${i}`);
|
|
39
|
+
return {
|
|
40
|
+
script: await o.files.read(o.rel),
|
|
41
|
+
title: a ?? u(i)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function f(n, r) {
|
|
45
|
+
let { script: i, title: a } = await d(n, r), o = await t(i), { relPath: s, filePath: c } = e(a);
|
|
46
|
+
return await n.files.artifacts.write(s, o), {
|
|
47
|
+
message: `Saved USDZ to ${c} (${o.byteLength} bytes). Open it with AR Quick Look or any USD viewer.`,
|
|
48
|
+
filePath: c,
|
|
49
|
+
bytes: o.byteLength
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { a, i, s as n, f as o, c as r, o as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./samples-DZNAeuSZ.cjs"),t=require("./toThreeJS-XGDoVISb.cjs");var n=`exportShapeScriptUsdz`,r=t.t+3e4,i="Export a ShapeScript model to a USDZ file (Apple's AR / 3D format, openable with AR Quick Look on iPhone, iPad and Mac) and save it under artifacts/shapes/. Returns the saved path. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file. USDZ units are metres, so a `size 1` cube becomes a one-metre object in AR — scale the model in the script if that is not what the user wants.",a=`Use exportShapeScriptUsdz when the user wants to take a 3D model out of the chat — to view it in AR, open it in a 3D app, or share the file. It saves a .usdz next to the model's .shape file and returns the path; tell the user where it is. The user can also press "Download USDZ" in the model's view themselves.`,o={type:`object`,properties:{script:{type:`string`,description:"ShapeScript source to export. Provide either this or `path`, not both."},path:{type:`string`,description:`Path to an existing .shape file to export (e.g. one presentShapeScript saved under artifacts/shapes/).`},title:{type:`string`,description:"Name for the exported file; it is slugified into the filename. Defaults to the .shape file's own name when `path` is given."}},required:[]};function s(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function c(e){return(e.split(/[\\/]/).pop()??e).replace(/\.shape$/i,``)}async function l(t,n){let r=s(n.script),i=s(n.path),a=s(n.title);if(r&&i)throw Error("Provide either `script` or `path`, not both");if(r)return{script:r,title:a};if(!i)throw Error("Provide either `script` (inline source) or `path` (an existing .shape file)");let o=e.u(t,i);if(!o)throw Error("`path` must name a .shape file, without `.` / `..` segments");if(!await o.files.exists(o.rel))throw Error(`No ShapeScript exists at ${i}`);return{script:await o.files.read(o.rel),title:a??c(i)}}async function u(t,n){let{script:r,title:i}=await l(t,n),a=await e.a(r),{relPath:o,filePath:s}=e._(i);return await t.files.artifacts.write(o,a),{message:`Saved USDZ to ${s} (${a.byteLength} bytes). Open it with AR Quick Look or any USD viewer.`,filePath:s,bytes:a.byteLength}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-DZNAeuSZ.cjs"),t=require("./toThreeJS-XGDoVISb.cjs"),n=require("./core-bcFgqR_m.cjs");exports.EXPORT_USDZ_DESCRIPTION=n.t,exports.EXPORT_USDZ_PROMPT=n.n,exports.EXPORT_USDZ_SCHEMA=n.r,exports.EXPORT_USDZ_TOOL_NAME=n.i,exports.EXPORT_USDZ_TOOL_TIMEOUT_MS=n.a,exports.SHAPE_EXTENSIONS=e.d,exports.TOOL_DEFINITION=e.v,exports.TOOL_NAME=e.y,exports.USDZ_EXTENSION=e.n,exports.USDZ_MIME_TYPE=e.r,exports.astToThreeJS=t.r,exports.executeExportShapeScriptUsdz=n.o,exports.executePresentShapeScript=e.o,exports.executeShapeScriptDispatch=e.l,exports.isPresentableShapePath=e.f,exports.isShapeArtifactPath=e.p,exports.isShapeScriptDispatchArgs=t.zn,exports.locateShape=e.u,exports.parseShapeScript=t.In,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Bn,exports.readSaveShapeResult=t.Vn,exports.samples=e.t,exports.sceneToUsdz=e.i,exports.shapeArtifactPath=e.m,exports.shapeScriptToUsdz=e.a,exports.toArtifactsRelative=e.g,exports.usdzArtifactPath=e._;
|
package/dist/core.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "./samples-DPOGWslc.js";
|
|
2
|
+
import { Bn as v, In as y, Vn as b, r as x, zn as S } from "./toThreeJS-BX_aeGdA.js";
|
|
3
|
+
import { a as C, i as w, n as T, o as E, r as D, t as O } from "./core-CpVzK-0i.js";
|
|
4
|
+
export { O as EXPORT_USDZ_DESCRIPTION, T as EXPORT_USDZ_PROMPT, D as EXPORT_USDZ_SCHEMA, w as EXPORT_USDZ_TOOL_NAME, C as EXPORT_USDZ_TOOL_TIMEOUT_MS, r as SHAPE_EXTENSIONS, g as TOOL_DEFINITION, _ as TOOL_NAME, l as USDZ_EXTENSION, f as USDZ_MIME_TYPE, x as astToThreeJS, E as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, S as isShapeScriptDispatchArgs, h as locateShape, y as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, b as readSaveShapeResult, m as samples, o as sceneToUsdz, c as shapeArtifactPath, t as shapeScriptToUsdz, a as toArtifactsRelative, e as usdzArtifactPath };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ShapeScriptDispatchContext } from "../core/dispatch";
|
|
2
|
+
export declare const EXPORT_USDZ_TOOL_NAME = "exportShapeScriptUsdz";
|
|
3
|
+
/** Milliseconds a host must allow this tool before its own transport gives up.
|
|
4
|
+
* Conversion may legitimately spend its whole `DEFAULT_MAX_DURATION_MS` on a
|
|
5
|
+
* near-limit model, and serialising the result to USDZ (plus the write) comes
|
|
6
|
+
* AFTER that — a transport sized to the conversion alone aborts an export that
|
|
7
|
+
* was about to succeed, exactly as #3056 found for `renderShapeScript`. */
|
|
8
|
+
export declare const EXPORT_USDZ_TOOL_TIMEOUT_MS: number;
|
|
9
|
+
export declare const EXPORT_USDZ_DESCRIPTION = "Export a ShapeScript model to a USDZ file (Apple's AR / 3D format, openable with AR Quick Look on iPhone, iPad and Mac) and save it under artifacts/shapes/. Returns the saved path. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file. USDZ units are metres, so a `size 1` cube becomes a one-metre object in AR \u2014 scale the model in the script if that is not what the user wants.";
|
|
10
|
+
export declare const EXPORT_USDZ_PROMPT = "Use exportShapeScriptUsdz when the user wants to take a 3D model out of the chat \u2014 to view it in AR, open it in a 3D app, or share the file. It saves a .usdz next to the model's .shape file and returns the path; tell the user where it is. The user can also press \"Download USDZ\" in the model's view themselves.";
|
|
11
|
+
/** The tool's JSON schema, in the shape both a gui-chat-protocol `ToolDefinition`
|
|
12
|
+
* (`parameters`) and an MCP tool (`inputSchema`) take. */
|
|
13
|
+
export declare const EXPORT_USDZ_SCHEMA: {
|
|
14
|
+
type: "object";
|
|
15
|
+
properties: {
|
|
16
|
+
script: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
path: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
title: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
31
|
+
/** What one call did: the sentence the agent reads, and the path for a host
|
|
32
|
+
* that wants to log or link it. */
|
|
33
|
+
export interface ExportUsdzResult {
|
|
34
|
+
message: string;
|
|
35
|
+
/** Workspace-relative, `artifacts/shapes/<slug>-<epoch>-<token>.usdz`. */
|
|
36
|
+
filePath: string;
|
|
37
|
+
bytes: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Run one `exportShapeScriptUsdz` call. Throws on a missing / invalid source
|
|
41
|
+
* and on ShapeScript errors — the host's own error path reports those to the
|
|
42
|
+
* model, exactly as it does for `renderShapeScript`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function executeExportShapeScriptUsdz(context: ShapeScriptDispatchContext, args: Record<string, unknown>): Promise<ExportUsdzResult>;
|
|
45
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/export/tool.ts"],"names":[],"mappings":"AASA,OAAO,EAAe,KAAK,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAKhF,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D;;;;4EAI4E;AAC5E,eAAO,MAAM,2BAA2B,QAAmC,CAAC;AAE5E,eAAO,MAAM,uBAAuB,6aACmY,CAAC;AAExa,eAAO,MAAM,kBAAkB,kUAC6R,CAAC;AAE7T;2DAC2D;AAC3D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;cAgBb,MAAM,EAAE;CACzB,CAAC;AAEF;oCACoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AA0BD;;;;GAIG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,0BAA0B,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAUhJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { type ConversionOptions } from "../shapescript/toThreeJS";
|
|
3
|
+
/** The MIME type a `.usdz` is served / downloaded as (Apple's registration). */
|
|
4
|
+
export declare const USDZ_MIME_TYPE = "model/vnd.usdz+zip";
|
|
5
|
+
/** The extension a USDZ archive carries. */
|
|
6
|
+
export declare const USDZ_EXTENSION = ".usdz";
|
|
7
|
+
/** Serialise an already-built Three.js object tree to a USDZ archive.
|
|
8
|
+
*
|
|
9
|
+
* `quickLookCompatible` lets Apple's AR Quick Look open the file, which is the
|
|
10
|
+
* main reason anyone wants USDZ; the flag costs nothing elsewhere. */
|
|
11
|
+
export declare function sceneToUsdz(object: THREE.Object3D): Promise<Uint8Array<ArrayBuffer>>;
|
|
12
|
+
/** Parse, evaluate and export one ShapeScript source. Geometry is built the
|
|
13
|
+
* same way `presentShapeScript` validates it (same converter, same limits),
|
|
14
|
+
* solid rather than wireframe, and released once serialised — the CSG buffers
|
|
15
|
+
* are the expensive part and nothing keeps them after this. */
|
|
16
|
+
export declare function shapeScriptToUsdz(script: string, options?: Omit<ConversionOptions, "wireframe">): Promise<Uint8Array<ArrayBuffer>>;
|
|
17
|
+
//# sourceMappingURL=usdz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usdz.d.ts","sourceRoot":"","sources":["../../src/export/usdz.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,gFAAgF;AAChF,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,4CAA4C;AAC5C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;;uEAGuE;AACvE,wBAAsB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAI1F;AAED;;;gEAGgE;AAChE,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAO5I"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-DZNAeuSZ.cjs"),t=require("./toThreeJS-XGDoVISb.cjs"),n=require("./core-bcFgqR_m.cjs");exports.EXPORT_USDZ_DESCRIPTION=n.t,exports.EXPORT_USDZ_PROMPT=n.n,exports.EXPORT_USDZ_SCHEMA=n.r,exports.EXPORT_USDZ_TOOL_NAME=n.i,exports.EXPORT_USDZ_TOOL_TIMEOUT_MS=n.a,exports.SHAPE_EXTENSIONS=e.d,exports.TOOL_DEFINITION=e.v,exports.TOOL_NAME=e.y,exports.USDZ_EXTENSION=e.n,exports.USDZ_MIME_TYPE=e.r,exports.astToThreeJS=t.r,exports.executeExportShapeScriptUsdz=n.o,exports.executePresentShapeScript=e.o,exports.executeShapeScriptDispatch=e.l,exports.isPresentableShapePath=e.f,exports.isShapeArtifactPath=e.p,exports.isShapeScriptDispatchArgs=t.zn,exports.locateShape=e.u,exports.parseShapeScript=t.In,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Bn,exports.readSaveShapeResult=t.Vn,exports.samples=e.t,exports.sceneToUsdz=e.i,exports.shapeArtifactPath=e.m,exports.shapeScriptToUsdz=e.a,exports.toArtifactsRelative=e.g,exports.usdzArtifactPath=e._;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./core.js";
|
|
4
|
-
export {
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "./samples-DPOGWslc.js";
|
|
2
|
+
import { Bn as v, In as y, Vn as b, r as x, zn as S } from "./toThreeJS-BX_aeGdA.js";
|
|
3
|
+
import { a as C, i as w, n as T, o as E, r as D, t as O } from "./core-CpVzK-0i.js";
|
|
4
|
+
export { O as EXPORT_USDZ_DESCRIPTION, T as EXPORT_USDZ_PROMPT, D as EXPORT_USDZ_SCHEMA, w as EXPORT_USDZ_TOOL_NAME, C as EXPORT_USDZ_TOOL_TIMEOUT_MS, r as SHAPE_EXTENSIONS, g as TOOL_DEFINITION, _ as TOOL_NAME, l as USDZ_EXTENSION, f as USDZ_MIME_TYPE, x as astToThreeJS, E as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, S as isShapeScriptDispatchArgs, h as locateShape, y as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, b as readSaveShapeResult, m as samples, o as sceneToUsdz, c as shapeArtifactPath, t as shapeScriptToUsdz, a as toArtifactsRelative, e as usdzArtifactPath };
|
package/dist/lang/de.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"de.d.ts","sourceRoot":"","sources":["../../src/lang/de.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"de.d.ts","sourceRoot":"","sources":["../../src/lang/de.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAYT,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/lang/en.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/lang/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/lang/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAYT,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/lang/es.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../src/lang/es.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../src/lang/es.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAYT,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/lang/fr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../src/lang/fr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../src/lang/fr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAYT,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/lang/ja.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ja.d.ts","sourceRoot":"","sources":["../../src/lang/ja.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"ja.d.ts","sourceRoot":"","sources":["../../src/lang/ja.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAYT,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/lang/ko.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ko.d.ts","sourceRoot":"","sources":["../../src/lang/ko.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"ko.d.ts","sourceRoot":"","sources":["../../src/lang/ko.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAYT,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/lang/messages.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/lang/messages.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/lang/messages.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/lang/ptBR.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ptBR.d.ts","sourceRoot":"","sources":["../../src/lang/ptBR.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"ptBR.d.ts","sourceRoot":"","sources":["../../src/lang/ptBR.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,QAYX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/lang/zh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zh.d.ts","sourceRoot":"","sources":["../../src/lang/zh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"zh.d.ts","sourceRoot":"","sources":["../../src/lang/zh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAYT,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/render/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export { renderShapeScriptSheet, RenderUnavailableError, CHROMIUM_HINT, RENDER_T
|
|
|
2
2
|
export type { RenderShapeScriptOptions } from "./renderer";
|
|
3
3
|
export { buildRenderPage, gridFor } from "./page";
|
|
4
4
|
export type { ViewAngle, RenderPageOptions } from "./page";
|
|
5
|
+
export { executeRenderShapeScript, viewAngles, RENDER_SHAPE_SCRIPT_TOOL_NAME, RENDER_SHAPE_SCRIPT_DESCRIPTION, RENDER_SHAPE_SCRIPT_PROMPT, RENDER_SHAPE_SCRIPT_SCHEMA, RENDER_TOOL_TIMEOUT_MS, renderOptionsFrom, savedMessage, } from "./tool";
|
|
6
|
+
export type { RenderToolDeps, RenderToolResult } from "./tool";
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnJ,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAClD,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnJ,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAClD,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,6BAA6B,EAC7B,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,GACb,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -34,6 +34,17 @@ export interface RenderShapeScriptOptions {
|
|
|
34
34
|
* the script is at fault. */
|
|
35
35
|
export declare class RenderUnavailableError extends Error {
|
|
36
36
|
}
|
|
37
|
+
/** Report something the host should record, without letting the report become
|
|
38
|
+
* the outcome. The callback is the HOST's code, and it is called from paths
|
|
39
|
+
* whose whole purpose is to answer gracefully — the `finally` that releases the
|
|
40
|
+
* browser after a finished render (CodeRabbit on #3059), and the
|
|
41
|
+
* browser-unavailable branch that returns install guidance (codex on #3060). A
|
|
42
|
+
* synchronous throw from a logger must not turn either into a rejection.
|
|
43
|
+
*
|
|
44
|
+
* Exported because both callers need the same guarantee and one of them lives
|
|
45
|
+
* in `./tool`; two copies of "wrap the host's logger" is exactly the kind of
|
|
46
|
+
* thing that ends up guarded in one place and not the other. */
|
|
47
|
+
export declare function safeWarn(onWarning: ((message: string) => void) | undefined, message: string): void;
|
|
37
48
|
/**
|
|
38
49
|
* Render `script` to a PNG contact sheet, returned base64-encoded.
|
|
39
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/render/renderer.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAUzD;+EAC+E;AAC/E,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD;;2EAE2E;AAC3E,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD;;;;;8DAK8D;AAC9D,eAAO,MAAM,gBAAgB,QAAwC,CAAC;AAEtE;8EAC8E;AAC9E,eAAO,MAAM,aAAa,oNACyL,CAAC;AAEpN,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,GAAG,cAAc,CAAC;IAC3C;;;sBAGkB;IAClB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED;;8BAE8B;AAC9B,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/render/renderer.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAUzD;+EAC+E;AAC/E,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD;;2EAE2E;AAC3E,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD;;;;;8DAK8D;AAC9D,eAAO,MAAM,gBAAgB,QAAwC,CAAC;AAEtE;8EAC8E;AAC9E,eAAO,MAAM,aAAa,oNACyL,CAAC;AAEpN,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,GAAG,cAAc,CAAC;IAC3C;;;sBAGkB;IAClB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED;;8BAE8B;AAC9B,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;AAEpD;;;;;;;;;iEASiE;AACjE,wBAAgB,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMlG;AAkJD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkD/F"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ViewAngle } from "./page";
|
|
2
|
+
/** Milliseconds a host must allow this tool before its own transport gives up.
|
|
3
|
+
* Covers launch plus render, plus room for the work either side — serialising
|
|
4
|
+
* the scene and writing the PNG. A transport sized to the render alone aborts a
|
|
5
|
+
* call that was about to succeed. */
|
|
6
|
+
export declare const RENDER_TOOL_TIMEOUT_MS: number;
|
|
7
|
+
export declare const RENDER_SHAPE_SCRIPT_TOOL_NAME = "renderShapeScript";
|
|
8
|
+
export declare const RENDER_SHAPE_SCRIPT_DESCRIPTION = "Render a ShapeScript model to a PNG image and save it, so you can LOOK at the model you wrote and check it before showing it to the user. Returns the image path \u2014 read that file to see the result. By default it renders four camera angles onto one sheet, because a single view cannot settle what is in front of what. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file.";
|
|
9
|
+
export declare const RENDER_SHAPE_SCRIPT_PROMPT = "Use renderShapeScript to CHECK a 3D model you wrote before presenting it \u2014 it saves a PNG and returns the path, which you then read to see what the model actually looks like. Fix what you see and re-render. Rendering needs a local headless browser; if it reports one is missing, say so and continue with presentShapeScript rather than retrying.";
|
|
10
|
+
/** The tool's JSON schema, in the shape both a gui-chat-protocol `ToolDefinition`
|
|
11
|
+
* (`parameters`) and an MCP tool (`inputSchema`) take. */
|
|
12
|
+
export declare const RENDER_SHAPE_SCRIPT_SCHEMA: {
|
|
13
|
+
type: "object";
|
|
14
|
+
properties: {
|
|
15
|
+
script: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
path: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
azimuth: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
elevation: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
zoom: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
views: {
|
|
36
|
+
type: string;
|
|
37
|
+
enum: string[];
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
projection: {
|
|
41
|
+
type: string;
|
|
42
|
+
enum: string[];
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
width: {
|
|
46
|
+
type: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
height: {
|
|
50
|
+
type: string;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
required: string[];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The angles one call renders.
|
|
58
|
+
*
|
|
59
|
+
* The default is FOUR views, not one, and that is the point of the tool: a
|
|
60
|
+
* single projection is ambiguous about depth and occlusion, and a model asked
|
|
61
|
+
* to judge one confidently gets "which of these is in front" wrong. Three
|
|
62
|
+
* quarters around the model plus a top-down resolves it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function viewAngles(azimuth: number, elevation: number, single: boolean): ViewAngle[];
|
|
65
|
+
/** What a host has to supply: the two things that are actually its own. */
|
|
66
|
+
export interface RenderToolDeps {
|
|
67
|
+
/** Read the `.shape` a `path` argument names, through this host's file layer.
|
|
68
|
+
* Throws — with a message the agent can act on — when the path is not one it
|
|
69
|
+
* will open. */
|
|
70
|
+
readShape: (path: string) => Promise<string>;
|
|
71
|
+
/** Persist the PNG (base64) and answer with the path the AGENT should read.
|
|
72
|
+
* Absolute or relative is the host's call: it depends on where its sessions
|
|
73
|
+
* run, and only the host knows that. */
|
|
74
|
+
saveImage: (base64: string) => Promise<string>;
|
|
75
|
+
/** Optional host logger for anything the host should record but the model does
|
|
76
|
+
* not need as an error — a browser that would not close, and the unavailable
|
|
77
|
+
* browser below. */
|
|
78
|
+
onWarning?: (message: string) => void;
|
|
79
|
+
}
|
|
80
|
+
/** What one call did. `rendered: false` means the tool answered without an image
|
|
81
|
+
* — today only a host with no usable browser.
|
|
82
|
+
*
|
|
83
|
+
* The flag exists because the two outcomes look identical from the outside: both
|
|
84
|
+
* return a sentence for the model. Before the extraction the host logged
|
|
85
|
+
* `unavailable` on this path and `ok` on the other; collapsing them to a string
|
|
86
|
+
* made a missing Chromium invisible to host monitoring while the host went on
|
|
87
|
+
* logging success (codex on #3060). A host that ignores the flag still behaves
|
|
88
|
+
* correctly — it just cannot tell the two apart, which is the caller's choice
|
|
89
|
+
* to make rather than this function's. */
|
|
90
|
+
export interface RenderToolResult {
|
|
91
|
+
/** The sentence the agent reads — the saved path, or why there is none. */
|
|
92
|
+
message: string;
|
|
93
|
+
rendered: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Run one `renderShapeScript` call.
|
|
97
|
+
*
|
|
98
|
+
* A missing browser comes back as a message rather than a throw: the model can
|
|
99
|
+
* do nothing about it, and the useful response is the install hint plus "carry
|
|
100
|
+
* on without me". Everything else throws, so a host's own error path reports it.
|
|
101
|
+
*/
|
|
102
|
+
/** The renderer's options for one call: every model-supplied number defaulted and
|
|
103
|
+
* clamped, so nothing downstream has to wonder whether it was checked. */
|
|
104
|
+
export declare function renderOptionsFrom(args: Record<string, unknown>, script: string, views: readonly ViewAngle[], onWarning?: (message: string) => void): {
|
|
105
|
+
onWarning?: (message: string) => void;
|
|
106
|
+
script: string;
|
|
107
|
+
views: readonly ViewAngle[];
|
|
108
|
+
width: number;
|
|
109
|
+
height: number;
|
|
110
|
+
zoom: number;
|
|
111
|
+
projection: "perspective" | "orthographic";
|
|
112
|
+
};
|
|
113
|
+
/** What the model is told about a sheet that WAS produced. The captions are
|
|
114
|
+
* repeated here rather than left to the image alone: a model that has not opened
|
|
115
|
+
* the file yet still knows which angles it is about to see. */
|
|
116
|
+
export declare function savedMessage(imagePath: string, views: readonly ViewAngle[]): string;
|
|
117
|
+
export declare function executeRenderShapeScript(deps: RenderToolDeps, args: Record<string, unknown>): Promise<RenderToolResult>;
|
|
118
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/render/tool.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAcxC;;;sCAGsC;AACtC,eAAO,MAAM,sBAAsB,QAA4B,CAAC;AAEhE,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAEjE,eAAO,MAAM,+BAA+B,qaACmX,CAAC;AAEha,eAAO,MAAM,0BAA0B,kWACqT,CAAC;AAE7V;2DAC2D;AAC3D,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2CrB,MAAM,EAAE;CACzB,CAAC;AAcF;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,CAa3F;AAED,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B;;qBAEiB;IACjB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C;;6CAEyC;IACzC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C;;yBAEqB;IACrB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAWD;;;;;;;;;2CAS2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH;2EAC2E;AAC3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;0BAAf,MAAM,KAAK,IAAI;;;;;;;EAUlJ;AAED;;gEAEgE;AAChE,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAInF;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiB7H"}
|
package/dist/render.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./toThreeJS-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./toThreeJS-XGDoVISb.cjs");let l=require("node:fs/promises"),u=require("node:module"),d=require("node:url"),f=require("node:path");f=s(f,1);function p(e){let t=Math.ceil(Math.sqrt(e));return{columns:t,rows:Math.ceil(e/t)}}function m(e,t,n){return`import { AmbientLight, Box3, DirectionalLight, GridHelper, MathUtils, ObjectLoader, OrthographicCamera, PerspectiveCamera, Scene, Sphere, Vector3, WebGLRenderer } from ${JSON.stringify(e)};
|
|
2
2
|
|
|
3
3
|
const config = ${t};
|
|
4
4
|
const { columns, rows } = ${n};
|
|
@@ -79,4 +79,4 @@ window.__shapeSheet = sheet.toDataURL("image/png");`}function g(e){let{threeUrl:
|
|
|
79
79
|
<canvas id="sheet"></canvas>
|
|
80
80
|
<script type="module">
|
|
81
81
|
${`${m(t,JSON.stringify({views:r,width:i,height:a,zoom:o,projection:s,scene:n}),JSON.stringify(p(r.length)))}\n${h()}`}
|
|
82
|
-
<\/script>`}var _=1e3;function v(e){return e instanceof Error?e.message:String(e)}var y=60*_,b=30*_,x=9e4,S="renderShapeScript needs Puppeteer's headless Chromium, which this host does not have. Run `npx puppeteer browsers install chrome`, then retry. Everything else, including presentShapeScript, works without it.",C=class extends Error{};function w(e,t){try{e
|
|
82
|
+
<\/script>`}var _=1e3;function v(e){return e instanceof Error?e.message:String(e)}var y=60*_,b=30*_,x=9e4,S="renderShapeScript needs Puppeteer's headless Chromium, which this host does not have. Run `npx puppeteer browsers install chrome`, then retry. Everything else, including presentShapeScript, works without it.",C=class extends Error{};function w(e,t){try{e?.(t)}catch{}}function T(){let e={}.url;if(typeof e==`string`&&e.length>0)return e;if(typeof __filename==`string`)return(0,d.pathToFileURL)(__filename).href;throw Error(`shapescript render: cannot locate this module to resolve three from`)}var E=(0,u.createRequire)(T());function D(e){return c.Rn(e)&&typeof e.launch==`function`}async function ee(){try{let e=await import(`puppeteer`);return D(e)?e:c.Rn(e)&&D(e.default)?e.default:null}catch{return null}}function te(){try{return(0,u.createRequire)(E.resolve(`@mulmoclaude/shapescript-plugin/package.json`))}catch{return E}}function O(){let e=te().resolve(`three`);return e.endsWith(`three.cjs`)?e.replace(/three\.cjs$/,`three.module.js`):e}var k=`https://shapescript.invalid`,A=`${k}/render.html`,j=`./three.module.js`;async function M(e,t,n){let r;try{r=new URL(e)}catch{return null}if(r.origin!==k)return null;let i=f.default.posix.basename(r.pathname);return i===`render.html`?{contentType:`text/html; charset=utf-8`,body:t}:/^three[\w.-]*\.js$/.test(i)?{contentType:`text/javascript; charset=utf-8`,body:await(0,l.readFile)(f.default.join(n,i),`utf-8`)}:null}async function N(e,t){let n=f.default.dirname(O());await e.setRequestInterception(!0),e.on(`request`,e=>{(async()=>{try{let r=await M(e.url(),t,n);await(r?e.respond({status:200,...r}):e.abort())}catch{}})()})}async function P(e){let t=await ee();if(!t)throw new C(S);let n=c.r(c.In(e.script)).toJSON(),r=g({...e,threeUrl:j,sceneJson:n}),i;try{i=await t.launch({headless:!0,timeout:b,args:[`--enable-unsafe-swiftshader`,`--use-gl=swiftshader`]})}catch(e){throw new C(`${S} (launch failed: ${v(e)})`)}try{let e=await i.newPage();await e.setViewport({width:800,height:600});let t=[];e.on(`pageerror`,e=>t.push(e.message)),await N(e,r),await e.goto(A,{waitUntil:`load`});try{await e.waitForFunction(`typeof window.__shapeSheet === 'string'`,{timeout:y})}catch(e){let n=t.length>0?`the render page failed: ${t.join(`; `)}`:v(e);throw Error(n,{cause:e})}let n=await e.evaluate(`window.__shapeSheet`);if(typeof n!=`string`||!n.startsWith(`data:image/png;base64,`))throw Error(`the render page produced no image`);return n.slice(22)}finally{await i.close().catch(t=>w(e.onWarning,`chromium close failed: ${v(t)}`))}}var F=30,I=25,L=1,R=480,z=900,B=160,V=85,H=x+3e4,U=`renderShapeScript`,W="Render a ShapeScript model to a PNG image and save it, so you can LOOK at the model you wrote and check it before showing it to the user. Returns the image path — read that file to see the result. By default it renders four camera angles onto one sheet, because a single view cannot settle what is in front of what. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file.",G=`Use renderShapeScript to CHECK a 3D model you wrote before presenting it — it saves a PNG and returns the path, which you then read to see what the model actually looks like. Fix what you see and re-render. Rendering needs a local headless browser; if it reports one is missing, say so and continue with presentShapeScript rather than retrying.`,K={type:`object`,properties:{script:{type:`string`,description:"ShapeScript source to render. Provide either this or `path`, not both."},path:{type:`string`,description:`Path to an existing .shape file to render (e.g. one presentShapeScript saved under artifacts/shapes/).`},azimuth:{type:`number`,description:`Camera rotation around the model in degrees, 0 = looking from +Z. Default ${F}. In the default four-view sheet this is the FIRST view's angle; the others are offset from it.`},elevation:{type:`number`,description:`Camera height in degrees above the horizon, 90 = straight down. Default ${I}. Avoid 0 and 90 for the main view — an axis-aligned shot flattens depth.`},zoom:{type:`number`,description:`Multiplier on the automatic framing, which fits the whole model. 1 = fit (default), 2 = twice as close, 0.5 = further out. Prefer this over guessing a camera distance: it means the same thing at any model scale.`},views:{type:`string`,enum:[`quad`,`single`],description:"`quad` (default) renders four angles on one sheet — use it to judge shape and layout. `single` renders only `azimuth`/`elevation`, for a close look at one detail."},projection:{type:`string`,enum:[`perspective`,`orthographic`],description:"`perspective` (default) looks natural; `orthographic` keeps parallel edges parallel, which is better for comparing proportions."},width:{type:`number`,description:`Pixel width of ONE view. Default ${R}, clamped to ${B}–${z}.`},height:{type:`number`,description:`Pixel height of ONE view. Default ${R}, clamped to ${B}–${z}.`}},required:[]};function q(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(z,Math.max(B,Math.round(e)))}function J(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}var Y=e=>`${Math.round(e)}°`;function X(e,t,n){let r=(e,t,n)=>({azimuth:e,elevation:t,label:`${n} — az ${Y(e)}, el ${Y(t)}`});return n?[r(e,t,`view`)]:[r(e,t,`front-right`),r(e+90,t,`back-right`),r(e+180,t,`back-left`),r(e,V,`top`)]}async function Z(e,t){let n=typeof t.script==`string`&&t.script.trim()!==``?t.script:void 0,r=typeof t.path==`string`&&t.path.trim()!==``?t.path:void 0;if(n&&r)throw Error("Provide either `script` or `path`, not both");if(n)return n;if(r)return e.readShape(r);throw Error("Provide either `script` (inline source) or `path` (an existing .shape file)")}function Q(e,t,n,r){return{script:t,views:n,width:q(e.width,R),height:q(e.height,R),zoom:Math.max(J(e.zoom,L),.01),projection:e.projection===`orthographic`?`orthographic`:`perspective`,...r?{onWarning:r}:{}}}function $(e,t){let n=t.map(e=>e.label).join(`; `);return`Saved render to ${e} (${t.length===1?`1 view`:`${t.length} views`}: ${n}). Read that file to see the model.`}async function ne(e,t){let n=await Z(e,t),r=X(J(t.azimuth,F),J(t.elevation,I),t.views===`single`);try{let i=await P(Q(t,n,r,e.onWarning));return{message:$(await e.saveImage(i),r),rendered:!0}}catch(t){if(t instanceof C)return w(e.onWarning,`renderShapeScript: unavailable — ${t.message}`),{message:t.message,rendered:!1};throw t}}exports.CHROMIUM_HINT=S,exports.LAUNCH_TIMEOUT_MS=b,exports.RENDER_BUDGET_MS=x,exports.RENDER_SHAPE_SCRIPT_DESCRIPTION=W,exports.RENDER_SHAPE_SCRIPT_PROMPT=G,exports.RENDER_SHAPE_SCRIPT_SCHEMA=K,exports.RENDER_SHAPE_SCRIPT_TOOL_NAME=U,exports.RENDER_TIMEOUT_MS=y,exports.RENDER_TOOL_TIMEOUT_MS=H,exports.RenderUnavailableError=C,exports.buildRenderPage=g,exports.executeRenderShapeScript=ne,exports.gridFor=p,exports.renderOptionsFrom=Q,exports.renderShapeScriptSheet=P,exports.savedMessage=$,exports.viewAngles=X;
|