@womp/kakapo-sdk 0.1.0 → 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.
package/dist/api.d.ts CHANGED
@@ -13,6 +13,10 @@ export interface SceneEdit {
13
13
  getNodeParent(id: number): KakapoNode | null;
14
14
  getNodeChildren(id: number): KakapoNode[];
15
15
  applyScenePatch(operations: JsonPatchOperation[]): Scene;
16
+ getSceneExt(): Record<string, JsonValue>;
17
+ patchSceneExt(operations: JsonPatchOperation[]): Scene;
18
+ getSceneProperties(): Record<string, JsonValue>;
19
+ patchSceneProperties(operations: JsonPatchOperation[]): Scene;
16
20
  createNode(input: CreateNodeInput): KakapoNode;
17
21
  cloneNode(id: number, options?: {
18
22
  parentId?: number;
@@ -74,6 +78,14 @@ export declare class KakapoAPI {
74
78
  getScene(): Scene;
75
79
  editScene<T>(callback: (scene: SceneEdit) => T | Promise<T>): Promise<T>;
76
80
  private applyScenePatch;
81
+ /** The scene's consumer-owned extension bag. Kakapo does not interpret it. */
82
+ getSceneExt(): Record<string, JsonValue>;
83
+ /** Apply JSON Patch operations rooted at the scene's `ext` bag. */
84
+ patchSceneExt(operations: JsonPatchOperation[]): Scene;
85
+ /** The scene's renderer/environment properties (HDR, background, and similar). */
86
+ getSceneProperties(): Record<string, JsonValue>;
87
+ /** Apply JSON Patch operations rooted at the scene's `properties` bag. */
88
+ patchSceneProperties(operations: JsonPatchOperation[]): Scene;
77
89
  listNodes(options?: ListNodeOptions): KakapoNode[];
78
90
  findNodes(options: FindNodeOptions): KakapoNode[];
79
91
  getNode(id: number): KakapoNode;
package/dist/api.js CHANGED
@@ -126,6 +126,24 @@ export class KakapoAPI {
126
126
  this.draftDirty = true;
127
127
  return this.getScene();
128
128
  }
129
+ /** The scene's consumer-owned extension bag. Kakapo does not interpret it. */
130
+ getSceneExt() {
131
+ const scene = this.getScene();
132
+ return scene.ext ?? {};
133
+ }
134
+ /** Apply JSON Patch operations rooted at the scene's `ext` bag. */
135
+ patchSceneExt(operations) {
136
+ return this.applyScenePatch(operations.map((op) => ({ ...op, path: `/ext${op.path}` })));
137
+ }
138
+ /** The scene's renderer/environment properties (HDR, background, and similar). */
139
+ getSceneProperties() {
140
+ const scene = this.getScene();
141
+ return scene.properties ?? {};
142
+ }
143
+ /** Apply JSON Patch operations rooted at the scene's `properties` bag. */
144
+ patchSceneProperties(operations) {
145
+ return this.applyScenePatch(operations.map((op) => ({ ...op, path: `/properties${op.path}` })));
146
+ }
129
147
  listNodes(options = {}) {
130
148
  const scene = this.requireScene("listNodes");
131
149
  return Object.keys(scene.nodes).map(Number).sort((a, b) => a - b).map((id) => wireToNode(scene, id)).filter((node) => (options.kind === undefined || node.kind === options.kind) && (options.parentId === undefined || node.parentId === options.parentId)).map(deepClone);
@@ -569,6 +587,10 @@ export class KakapoAPI {
569
587
  getNodeParent: (id) => this.getNodeParent(id),
570
588
  getNodeChildren: (id) => this.getNodeChildren(id),
571
589
  applyScenePatch: (operations) => this.applyScenePatch(operations),
590
+ getSceneExt: () => this.getSceneExt(),
591
+ patchSceneExt: (operations) => this.patchSceneExt(operations),
592
+ getSceneProperties: () => this.getSceneProperties(),
593
+ patchSceneProperties: (operations) => this.patchSceneProperties(operations),
572
594
  createNode: (input) => this.createNode(input),
573
595
  cloneNode: (id, options) => this.cloneNode(id, options),
574
596
  updateNode: (id, changes) => this.updateNode(id, changes),
package/dist/scene.js CHANGED
@@ -294,7 +294,7 @@ export function toPublicScene(raw) {
294
294
  return id === undefined ? [] : [[key, wireToMaterial(id, value)]];
295
295
  }));
296
296
  const scripts = Object.fromEntries(Object.entries(raw.storage.openscad?.scripts ?? {}).map(([id, value]) => [id, { id: Number(id), name: str(value.name, "OpenSCAD Script"), source: str(value.source) }]));
297
- return { version: raw.version ?? 0, name: raw.name ?? "", nodes, tree, materials, openScadScripts: scripts, properties: (raw.properties ?? {}), camera: (raw.camera ?? {}) };
297
+ return { version: raw.version ?? 0, name: raw.name ?? "", nodes, tree, materials, openScadScripts: scripts, properties: (raw.properties ?? {}), camera: (raw.camera ?? {}), ext: (raw.ext ?? {}) };
298
298
  }
299
299
  export function missingNode(id, operation) {
300
300
  return new KakapoValidationError(`Node ${id} does not exist.`, { code: "NODE_NOT_FOUND", operation, path: "nodeId", received: id, expected: "an existing node ID", hint: "Call listNodes() or refreshScene() and use a current node ID." });
package/dist/types.d.ts CHANGED
@@ -268,6 +268,12 @@ export interface Scene {
268
268
  openScadScripts: Record<string, OpenScadScript>;
269
269
  properties: Record<string, JsonValue>;
270
270
  camera: Record<string, JsonValue>;
271
+ /**
272
+ * Consumer-owned extension bag carried in the scene file. Kakapo does not
273
+ * interpret its contents; Womp stores node and material metadata here
274
+ * (e.g. `ext[nodeId].locked`, `ext.materialsExt[materialId].tier`).
275
+ */
276
+ ext: Record<string, JsonValue>;
271
277
  }
272
278
  export interface BoundingBox {
273
279
  min: Vec3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@womp/kakapo-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Typed Node.js and browser SDK for controlling Kakapo over WebSocket",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "sideEffects": false,
22
22
  "engines": {
23
- "node": ">=20"
23
+ "node": ">=22.0.0"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",