@mulmoclaude/shapescript-plugin 2.4.0 → 2.5.1
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 +4 -5
- package/dist/core/definition.d.ts.map +1 -1
- package/dist/core/samples.d.ts.map +1 -1
- package/dist/{core-DmD6zaRF.cjs → core-1E7QiANi.cjs} +1 -1
- package/dist/{core-CvNYv5VF.js → core-CiJHiO3H.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -4
- package/dist/export/usdz.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/render.cjs +2 -2
- package/dist/render.js +9 -9
- package/dist/{samples-y59fsGq8.js → samples-BwyNyHha.js} +353 -298
- package/dist/{samples-BrJ4z8v-.cjs → samples-b6J0NoFm.cjs} +42 -18
- package/dist/shapescript/meshValues.d.ts +4 -0
- package/dist/shapescript/meshValues.d.ts.map +1 -1
- package/dist/shapescript/parser.d.ts +7 -0
- package/dist/shapescript/parser.d.ts.map +1 -1
- package/dist/shapescript/toThreeJS.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/{toThreeJS-CaZGJjfO.cjs → toThreeJS-BETrskvw.cjs} +4 -4
- package/dist/{toThreeJS-OGEAi4zV.js → toThreeJS-DyLC4g1t.js} +132 -94
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue.cjs +22 -21
- package/dist/vue.js +1078 -1077
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,9 +79,8 @@ USDZ units are metres, so `size 1` is one metre in AR.
|
|
|
79
79
|
A call is either C-like, with **no space** before its parenthesis (`sin(x)`; `sin (x)` is not a
|
|
80
80
|
call), or bare, as upstream: `max 0 (j - 1)`, `sqrt 9`, `sin pi / 2` — the function takes every
|
|
81
81
|
value after it, so parenthesise it inside a larger expression: `(sqrt 9) + (sqrt 16)`. Arguments are
|
|
82
|
-
a value list; commas (`max(0, j - 1)`) also work here but not in the upstream app.
|
|
83
|
-
|
|
84
|
-
portable scripts keep to that.
|
|
82
|
+
a value list; commas (`max(0, j - 1)`) also work here but not in the upstream app. One statement per
|
|
83
|
+
line, as upstream: `define a 1 define b 2` on one line is a parse error naming the rule.
|
|
85
84
|
|
|
86
85
|
## Storage
|
|
87
86
|
|
|
@@ -212,7 +211,7 @@ extrude path {
|
|
|
212
211
|
}
|
|
213
212
|
```
|
|
214
213
|
|
|
215
|
-
Also supported: `pi
|
|
214
|
+
Also supported: `pi` (no `tau`, as upstream; write `2 * pi`), `true`, `false`, scientific notation, unary `+`,
|
|
216
215
|
short-circuit `and`/`or`, string literals, `join`/`split`/`trim`, tuple arguments to `min`/`max`,
|
|
217
216
|
zero-based tuple/string subscripts (negative from the end, or by name: `v["y"]`), `.count`, ordinal
|
|
218
217
|
members `.first` … `.tenth`, `.last`, `.allButFirst`, `.allButLast`, vector `.x/.y/.z/.w`, size
|
|
@@ -298,7 +297,7 @@ places it (with `position` / `orientation` / `size` on the call), and its member
|
|
|
298
297
|
construction face for face, so scripts that index its faces (upstream's Dodecahedron) get the same
|
|
299
298
|
faces. `for v in … { expr }` and `if c { a } else { b }` are expressions, a function may build
|
|
300
299
|
shapes (`define face(data) { polygon { … } }`) and be called bare as a statement (`face data`), and
|
|
301
|
-
`mesh { … }` assembles the polygons its body produces — `polygon { color red
|
|
300
|
+
`mesh { … }` assembles the polygons its body produces — `polygon { color red … }` with one `point` per line
|
|
302
301
|
with 3D points, a tuple per point allowed — into one flat-shaded, vertex-coloured mesh. A value a
|
|
303
302
|
statement produces that is not a shape is an "unused value" error, as upstream. Paths as values and
|
|
304
303
|
`object` values remain unsupported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/core/definition.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC;AAE9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/core/definition.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC;AAE9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;CA+R3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/core/samples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/core/samples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,OAAO,EAAE,UAAU,EAgF/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./samples-
|
|
1
|
+
const e=require("./samples-b6J0NoFm.cjs"),t=require("./toThreeJS-BETrskvw.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}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as e, a as t, u as n } from "./samples-
|
|
2
|
-
import { t as r } from "./toThreeJS-
|
|
1
|
+
import { _ as e, a as t, u as n } from "./samples-BwyNyHha.js";
|
|
2
|
+
import { t as r } from "./toThreeJS-DyLC4g1t.js";
|
|
3
3
|
//#region src/export/tool.ts
|
|
4
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
5
|
type: "object",
|
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-b6J0NoFm.cjs"),t=require("./toThreeJS-BETrskvw.cjs"),n=require("./core-1E7QiANi.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.Vn,exports.locateShape=e.u,exports.parseShapeScript=t.s,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Hn,exports.readSaveShapeResult=t.Un,exports.samples=e.t,exports.sceneInfoOf=t.i,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,4 +1,4 @@
|
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-
|
|
4
|
-
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath,
|
|
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-BwyNyHha.js";
|
|
2
|
+
import { Hn as v, Un as y, Vn as b, i as x, r as S, s as C } from "./toThreeJS-DyLC4g1t.js";
|
|
3
|
+
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-CiJHiO3H.js";
|
|
4
|
+
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, b as isShapeScriptDispatchArgs, h as locateShape, C as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, y as readSaveShapeResult, m as samples, x as sceneInfoOf, o as sceneToUsdz, c as shapeArtifactPath, t as shapeScriptToUsdz, a as toArtifactsRelative, e as usdzArtifactPath };
|
|
@@ -1 +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,
|
|
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,CAS1F;AA8FD;;;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-b6J0NoFm.cjs"),t=require("./toThreeJS-BETrskvw.cjs"),n=require("./core-1E7QiANi.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.Vn,exports.locateShape=e.u,exports.parseShapeScript=t.s,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Hn,exports.readSaveShapeResult=t.Un,exports.samples=e.t,exports.sceneInfoOf=t.i,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 { _ 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-
|
|
2
|
-
import {
|
|
3
|
-
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-
|
|
4
|
-
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath,
|
|
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-BwyNyHha.js";
|
|
2
|
+
import { Hn as v, Un as y, Vn as b, i as x, r as S, s as C } from "./toThreeJS-DyLC4g1t.js";
|
|
3
|
+
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-CiJHiO3H.js";
|
|
4
|
+
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, b as isShapeScriptDispatchArgs, h as locateShape, C as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, y as readSaveShapeResult, m as samples, x as sceneInfoOf, o as sceneToUsdz, c as shapeArtifactPath, t as shapeScriptToUsdz, a as toArtifactsRelative, e as usdzArtifactPath };
|
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-BETrskvw.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, Color, 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};
|
|
@@ -83,4 +83,4 @@ window.__shapeSheet = sheet.toDataURL("image/png");`}function g(e){let{threeUrl:
|
|
|
83
83
|
<canvas id="sheet"></canvas>
|
|
84
84
|
<script type="module">
|
|
85
85
|
${`${m(t,JSON.stringify({views:r,width:i,height:a,zoom:o,projection:s,scene:n}),JSON.stringify(p(r.length)))}\n${h()}`}
|
|
86
|
-
<\/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.
|
|
86
|
+
<\/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.Bn(e)&&typeof e.launch==`function`}async function ee(){try{let e=await import(`puppeteer`);return D(e)?e:c.Bn(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.s(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;
|
package/dist/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as e, r as t, s as n } from "./toThreeJS-DyLC4g1t.js";
|
|
2
2
|
import { readFile as r } from "node:fs/promises";
|
|
3
3
|
import { createRequire as i } from "node:module";
|
|
4
4
|
import { pathToFileURL as a } from "node:url";
|
|
@@ -95,13 +95,13 @@ function y() {
|
|
|
95
95
|
throw Error("shapescript render: cannot locate this module to resolve three from");
|
|
96
96
|
}
|
|
97
97
|
var b = i(y());
|
|
98
|
-
function x(
|
|
99
|
-
return
|
|
98
|
+
function x(t) {
|
|
99
|
+
return e(t) && typeof t.launch == "function";
|
|
100
100
|
}
|
|
101
101
|
async function S() {
|
|
102
102
|
try {
|
|
103
|
-
let
|
|
104
|
-
return x(
|
|
103
|
+
let t = await import("puppeteer");
|
|
104
|
+
return x(t) ? t : e(t) && x(t.default) ? t.default : null;
|
|
105
105
|
} catch {
|
|
106
106
|
return null;
|
|
107
107
|
}
|
|
@@ -149,11 +149,11 @@ async function k(e, t) {
|
|
|
149
149
|
})();
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
-
async function A(
|
|
152
|
+
async function A(e) {
|
|
153
153
|
let r = await S();
|
|
154
154
|
if (!r) throw new _(g);
|
|
155
|
-
let i =
|
|
156
|
-
...
|
|
155
|
+
let i = t(n(e.script)).toJSON(), a = u({
|
|
156
|
+
...e,
|
|
157
157
|
threeUrl: D,
|
|
158
158
|
sceneJson: i
|
|
159
159
|
}), o;
|
|
@@ -184,7 +184,7 @@ async function A(n) {
|
|
|
184
184
|
if (typeof n != "string" || !n.startsWith("data:image/png;base64,")) throw Error("the render page produced no image");
|
|
185
185
|
return n.slice(22);
|
|
186
186
|
} finally {
|
|
187
|
-
await o.close().catch((
|
|
187
|
+
await o.close().catch((t) => v(e.onWarning, `chromium close failed: ${f(t)}`));
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
//#endregion
|