pixiboardjs 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (58) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +30 -5
  3. package/VERSIONING.md +9 -7
  4. package/dist/agent-tools-schemas.d.ts +18 -0
  5. package/dist/agent-tools-schemas.js +4 -0
  6. package/dist/agent-tools-schemas.js.map +1 -0
  7. package/dist/agent-tools.d.ts +140 -0
  8. package/dist/agent-tools.js +124 -0
  9. package/dist/agent-tools.js.map +1 -0
  10. package/dist/browser.d.ts +12 -6
  11. package/dist/browser.js +57 -4405
  12. package/dist/browser.js.map +1 -1
  13. package/dist/capabilities.d.ts +14 -0
  14. package/dist/capabilities.js +5 -0
  15. package/dist/capabilities.js.map +1 -0
  16. package/dist/chunk-AYOOOEXM.js +27 -0
  17. package/dist/chunk-AYOOOEXM.js.map +1 -0
  18. package/dist/chunk-KQHR2G24.js +2257 -0
  19. package/dist/chunk-KQHR2G24.js.map +1 -0
  20. package/dist/chunk-NPEG2TBO.js +2353 -0
  21. package/dist/chunk-NPEG2TBO.js.map +1 -0
  22. package/dist/chunk-PZ5AY32C.js +9 -0
  23. package/dist/chunk-PZ5AY32C.js.map +1 -0
  24. package/dist/chunk-SNUXC33Q.js +560 -0
  25. package/dist/chunk-SNUXC33Q.js.map +1 -0
  26. package/dist/core-B_8DmBaT.d.ts +294 -0
  27. package/dist/core.d.ts +11 -0
  28. package/dist/core.js +4 -0
  29. package/dist/core.js.map +1 -0
  30. package/dist/errors-CEQ_RiJ_.d.ts +27 -0
  31. package/dist/index.d.ts +9 -73
  32. package/dist/index.js +4 -4356
  33. package/dist/index.js.map +1 -1
  34. package/dist/node.d.ts +8 -2
  35. package/dist/node.js +4 -4356
  36. package/dist/node.js.map +1 -1
  37. package/dist/plugin.d.ts +88 -0
  38. package/dist/plugin.js +37 -0
  39. package/dist/plugin.js.map +1 -0
  40. package/dist/preview-registry-BjdGxaWe.d.ts +115 -0
  41. package/dist/resize-BK1wOjTc.d.ts +120 -0
  42. package/dist/types-BEsq8g6W.d.ts +199 -0
  43. package/dist/types-BskqWTyl.d.ts +224 -0
  44. package/dist/types.d.ts +416 -1
  45. package/etc/pixiboardjs-agent-tools-schemas.api.md +29 -0
  46. package/etc/pixiboardjs-agent-tools.api.md +288 -0
  47. package/etc/pixiboardjs-browser.api.md +1913 -1755
  48. package/etc/pixiboardjs-capabilities.api.md +366 -0
  49. package/etc/pixiboardjs-core.api.md +725 -0
  50. package/etc/pixiboardjs-node.api.md +1020 -862
  51. package/etc/pixiboardjs-plugin.api.md +129 -0
  52. package/etc/pixiboardjs-types.api.md +836 -755
  53. package/etc/pixiboardjs.api.md +1020 -862
  54. package/package.json +39 -5
  55. package/src/node-media-provider.d.ts +195 -0
  56. package/src/node-media-provider.mjs +139 -0
  57. package/dist/tsdoc-metadata.json +0 -11
  58. package/dist/types-D39-tYZ8.d.ts +0 -789
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-alpha.7
4
+
5
+ ### Minor Changes
6
+
7
+ - b9344de: Add `PreviewRenderer` and `PreviewRendererRegistry`: previews are produced by registered renderers, one per format, with no built-in renderers in core. Remove the format-specific `isDocumentPreviewType`, `isPreviewNodeType` and the ZIP special case in `previewStatusLabel`; re-export the registry from `pixiboardjs` (the two removed helpers are no longer exported there either); add `defaultHeight` to `PreviewSpecOptions` in place of the hard-coded model height.
8
+ - fdfb4a4: `pixiboardjs` is now the only published package. Core, capabilities, agent tools and the plugin contract move to subpaths: `pixiboardjs/core`, `pixiboardjs/capabilities`, `pixiboardjs/agent-tools` (schemas at `pixiboardjs/agent-tools/schemas`) and `pixiboardjs/plugin`, with exactly the same exports as `@pixi-board/core`, `@pixi-board/capabilities`, `@pixi-board/agent-tools` and `@pixi-board/plugin-sdk`. Every entry now shares one bundled copy of core and capabilities, so `instanceof` checks and registries behave consistently across entries. The old package names get one final release that forwards to these subpaths and are then deprecated.
9
+
10
+ ## 0.1.0-alpha.6
11
+
12
+ ### Patch Changes
13
+
14
+ - Preserve original media resources, fit imported content to its natural dimensions, and provide Node media preparation for reliable image, video, and audio previews. Support non-history media updates and safer asset import contracts.
15
+
3
16
  ## 0.1.0-alpha.5
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -20,9 +20,11 @@ Install target for SDK consumers:
20
20
  pnpm add pixiboardjs@alpha
21
21
  ```
22
22
 
23
- The public surface is the package root. `./browser`, `./node` and `./types`
24
- are explicit subpath contracts so consumers can select platform ports without
25
- depending on internal workspace packages.
23
+ The public surface is the package root. `./browser`, `./node`, `./types` and
24
+ the Node-only `./node-media-provider` are explicit subpath contracts so
25
+ consumers can select platform ports without depending on internal workspace
26
+ packages. The media provider is not imported by the browser entries and must
27
+ only be loaded in Node.
26
28
 
27
29
  ```ts
28
30
  import { createPixiBoard } from "pixiboardjs";
@@ -43,6 +45,28 @@ await board.destroy();
43
45
  See [`VERSIONING.md`](VERSIONING.md) for the separate SDK, document, node,
44
46
  plugin and Agent-tool version dimensions.
45
47
 
48
+ ### Node media provider
49
+
50
+ The host injects `sharp`; install it in the Node application if it is not
51
+ already available. `ffmpeg` and `ffprobe` are executable dependencies used for
52
+ video/audio probing and previews. Pass their paths explicitly, or set
53
+ `FFMPEG_PATH` / `FFPROBE_PATH`:
54
+
55
+ ```ts
56
+ import sharp from "sharp";
57
+ import { createNodeMediaProvider } from "pixiboardjs/node-media-provider";
58
+
59
+ const media = createNodeMediaProvider({
60
+ sharp,
61
+ ffmpegPath: "/opt/homebrew/bin/ffmpeg",
62
+ ffprobePath: "/opt/homebrew/bin/ffprobe",
63
+ });
64
+ ```
65
+
66
+ If paths are omitted, the provider checks `FFMPEG_PATH` / `FFPROBE_PATH` and
67
+ common installation locations before falling back to the executable names on
68
+ `PATH`. Do not import this subpath from browser code.
69
+
46
70
  `pnpm build:release` reproducibly creates ESM JavaScript, source maps and
47
71
  declaration artifacts under `dist/`. The public facade bundles private workspace
48
72
  implementation packages and keeps `pixi.js` as its only registry runtime
@@ -91,5 +115,6 @@ from `pixiboardjs/browser`; no private workspace imports are needed. See the
91
115
  for lifecycle, style and host integration details. Call `destroy()` on controllers
92
116
  when removing a host surface.
93
117
 
94
- The browser ESM budget is 270,000 bytes (uncompressed) for the native connection
95
- renderer and node-agent additions; the root and Node budgets are unchanged.
118
+ The browser ESM budget is 290,000 bytes (uncompressed) for the native connection
119
+ renderer, node-agent, and media import and preview runtime. The alpha.6 release
120
+ candidate measured 285,882 bytes in CI; the root and Node budgets are unchanged.
package/VERSIONING.md CHANGED
@@ -6,19 +6,21 @@ identifiers (for example `0.1.0-alpha.0`) communicate internal-alpha status.
6
6
  The following compatibility dimensions remain independent and must not be
7
7
  encoded as one shared number:
8
8
 
9
- - SDK package SemVer (`pixiboardjs` and public `@pixi-board/core` are intended
10
- to move lockstep in 1.x).
9
+ - SDK package SemVer (`pixiboardjs` is the only published package; core,
10
+ capabilities, agent-tools and plugin ship as its subpaths).
11
11
  - `schemaVersion` for persisted documents.
12
12
  - `node typeVersion` for custom node payloads.
13
13
  - Plugin API version (new SDK host starts at v3; no v2 adapter).
14
14
  - Agent tool schema version.
15
15
 
16
- Changesets keeps `pixiboardjs` and `@pixi-board/core` in a fixed version group.
17
- Private workspace packages retain their internal versioning independently; they
18
- are bundled into the main package and are not registry dependencies.
16
+ Changesets keeps the former public packages in a fixed version group with
17
+ `pixiboardjs` so their internal versions follow it, but they are private and
18
+ never published. All workspace packages are bundled into the main package and
19
+ are not registry dependencies (ADR 0016).
19
20
 
20
21
  `pnpm release:check` verifies the real packed manifest and only runs external
21
22
  consumers when generated JavaScript, declarations and API reports exist. It does
22
23
  not build or invent artifacts. Internal packages stay private unless an ADR
23
- explicitly makes them public; the planned `@pixi-board/plugin-sdk` is not the
24
- current private `@pixi-board/plugin-api-v3` package.
24
+ explicitly makes them public; `pixiboardjs/plugin` (the private
25
+ `@pixi-board/plugin-sdk` package) is not the private
26
+ `@pixi-board/plugin-api-v3` host package.
@@ -0,0 +1,18 @@
1
+ declare const canvasReadSchema: {
2
+ oneOf: {
3
+ type: string;
4
+ additionalProperties: boolean;
5
+ properties: Record<string, unknown>;
6
+ required: string[];
7
+ }[];
8
+ };
9
+ declare const canvasWriteSchema: {
10
+ oneOf: {
11
+ type: string;
12
+ additionalProperties: boolean;
13
+ properties: Record<string, unknown>;
14
+ required: string[];
15
+ }[];
16
+ };
17
+
18
+ export { canvasReadSchema, canvasWriteSchema };
@@ -0,0 +1,4 @@
1
+ export { canvasReadSchema, canvasWriteSchema } from './chunk-AYOOOEXM.js';
2
+ import './chunk-PZ5AY32C.js';
3
+ //# sourceMappingURL=agent-tools-schemas.js.map
4
+ //# sourceMappingURL=agent-tools-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-tools-schemas.js"}
@@ -0,0 +1,140 @@
1
+ import { j as RequestOptions, b as AssetImportSource, B as BoardCapabilities } from './types-BskqWTyl.js';
2
+ import { l as ContentFit, J as JsonValue, g as AssetRef, B as BoardChangeSet } from './types-BEsq8g6W.js';
3
+ export { canvasReadSchema, canvasWriteSchema } from './agent-tools-schemas.js';
4
+
5
+ type CanvasReadInput = {
6
+ type: "nodes";
7
+ ids?: string[];
8
+ types?: string[];
9
+ limit?: number;
10
+ cursor?: string;
11
+ fields?: string[];
12
+ } | {
13
+ type: "assets";
14
+ ids?: string[];
15
+ kinds?: string[];
16
+ limit?: number;
17
+ cursor?: string;
18
+ fields?: string[];
19
+ } | {
20
+ type: "preview";
21
+ id: string;
22
+ maxWidth?: number;
23
+ maxHeight?: number;
24
+ frameNumber?: number;
25
+ fps?: number;
26
+ };
27
+ type CanvasWriteInput = {
28
+ type: "create";
29
+ nodes: Array<AgentNodeCreate>;
30
+ } | {
31
+ type: "update";
32
+ nodes: Array<AgentNodeUpdate>;
33
+ } | {
34
+ type: "delete";
35
+ nodeIds: string[];
36
+ };
37
+ type AgentNodeCreate = {
38
+ id?: string;
39
+ type: string;
40
+ name?: string;
41
+ content?: string;
42
+ path?: string;
43
+ source?: AssetImportSource;
44
+ fileName?: string;
45
+ mimeType?: string;
46
+ relativePath?: string;
47
+ rootPath?: string;
48
+ baseUrl?: string;
49
+ x?: number;
50
+ y?: number;
51
+ width?: number;
52
+ height?: number;
53
+ rotation?: number;
54
+ zIndex?: number;
55
+ locked?: boolean;
56
+ visible?: boolean;
57
+ fit?: ContentFit;
58
+ props?: JsonValue;
59
+ };
60
+ type AgentNodeUpdate = Omit<AgentNodeCreate, "type"> & {
61
+ id: string;
62
+ };
63
+ type AgentToolError = {
64
+ code: string;
65
+ name: string;
66
+ message: string;
67
+ retryable: boolean;
68
+ requestId?: string;
69
+ details?: Record<string, unknown>;
70
+ };
71
+ type AgentToolResponse<T> = {
72
+ ok: true;
73
+ data: T;
74
+ } | {
75
+ ok: false;
76
+ error: AgentToolError;
77
+ };
78
+ type AgentCallOptions = RequestOptions & {
79
+ origin?: string;
80
+ };
81
+ type AgentTools = {
82
+ schemas: Record<"canvas.read" | "canvas.write", Record<string, unknown>>;
83
+ call(name: "canvas.read" | "canvas.write", input: unknown, options?: AgentCallOptions): Promise<AgentToolResponse<unknown>>;
84
+ };
85
+ type CompactNode = {
86
+ id: string;
87
+ type: string;
88
+ name?: string;
89
+ position?: {
90
+ x: number;
91
+ y: number;
92
+ };
93
+ size?: {
94
+ width: number;
95
+ height: number;
96
+ };
97
+ rotation?: number;
98
+ zIndex?: number;
99
+ fit?: ContentFit;
100
+ assetRefs?: Record<string, AssetRef>;
101
+ props?: JsonValue;
102
+ };
103
+ type CompactAsset = {
104
+ id: string;
105
+ kind: string;
106
+ [key: string]: JsonValue | undefined;
107
+ };
108
+ type CanvasOutput = {
109
+ type: string;
110
+ revision: number;
111
+ requestId?: string;
112
+ changed?: boolean;
113
+ nodes?: CompactNode[];
114
+ assets?: CompactAsset[];
115
+ deletedNodeIds?: string[];
116
+ deletedAssetIds?: string[];
117
+ changeSet?: BoardChangeSet;
118
+ page?: {
119
+ hasMore: boolean;
120
+ nextCursor?: string;
121
+ };
122
+ preview?: {
123
+ nodeId: string;
124
+ dataUrl: string;
125
+ mimeType: string;
126
+ width?: number;
127
+ height?: number;
128
+ revision: number;
129
+ requestId?: string;
130
+ };
131
+ content?: Array<{
132
+ type: "image";
133
+ dataUrl: string;
134
+ mimeType: string;
135
+ }>;
136
+ };
137
+
138
+ declare function createPixiBoardAgentTools(capabilities: BoardCapabilities): AgentTools;
139
+
140
+ export { type AgentCallOptions, type AgentNodeCreate, type AgentNodeUpdate, type AgentToolError, type AgentToolResponse, type AgentTools, BoardCapabilities, type CanvasOutput, type CanvasReadInput, type CanvasWriteInput, type CompactAsset, type CompactNode, createPixiBoardAgentTools };
@@ -0,0 +1,124 @@
1
+ import { CapabilityError, isCapabilityError } from './chunk-SNUXC33Q.js';
2
+ import './chunk-NPEG2TBO.js';
3
+ import { canvasWriteSchema, canvasReadSchema } from './chunk-AYOOOEXM.js';
4
+ export { canvasReadSchema, canvasWriteSchema } from './chunk-AYOOOEXM.js';
5
+ import './chunk-PZ5AY32C.js';
6
+
7
+ // ../agent-tools/src/index.ts
8
+ function createPixiBoardAgentTools(capabilities) {
9
+ return { schemas: { "canvas.read": canvasReadSchema, "canvas.write": canvasWriteSchema }, async call(name, raw, options = {}) {
10
+ const requestId = options.requestId;
11
+ try {
12
+ if (name === "canvas.read") return { ok: true, data: await read(capabilities, validateRead(raw), options) };
13
+ if (name === "canvas.write") return { ok: true, data: await write(capabilities, validateWrite(raw), options) };
14
+ throw new CapabilityError("INVALID_INPUT", `Unknown tool: ${name}`);
15
+ } catch (error) {
16
+ const e = isCapabilityError(error) ? error : new CapabilityError("INTERNAL_ERROR", error instanceof Error ? error.message : String(error));
17
+ return { ok: false, error: { code: e.code, name: e.name, message: e.message, retryable: e.code === "ABORTED" || e.code === "TRANSACTION_CONFLICT", requestId, details: e.details ? { ...e.details } : void 0 } };
18
+ }
19
+ } };
20
+ }
21
+ async function read(c, input, options) {
22
+ if (input.type === "nodes") {
23
+ const r2 = await c.nodes.read({ filter: { ids: input.ids, types: input.types }, limit: input.limit, cursor: input.cursor }, options);
24
+ return { type: "nodes", nodes: r2.nodes.map((n) => compact(n, input.fields)), page: r2.page, revision: r2.revision, requestId: options.requestId };
25
+ }
26
+ if (input.type === "assets") {
27
+ const r2 = await c.assets.read({ ids: input.ids, kinds: input.kinds, limit: input.limit, cursor: input.cursor }, options);
28
+ return { type: "assets", assets: r2.assets.map((a) => project(a, input.fields)), page: r2.page, revision: r2.revision, requestId: options.requestId };
29
+ }
30
+ const r = await c.preview.get({ nodeId: input.id, maxWidth: input.maxWidth, maxHeight: input.maxHeight, frameNumber: input.frameNumber, fps: input.fps }, options);
31
+ return { type: "preview", preview: r, content: [{ type: "image", dataUrl: r.dataUrl, mimeType: r.mimeType }], revision: r.revision, requestId: options.requestId };
32
+ }
33
+ async function write(c, input, options) {
34
+ const writeOptions = { ...options, origin: options.origin ?? "agent:canvas" };
35
+ if (input.type === "delete") {
36
+ const r2 = await c.nodes.delete({ nodeIds: input.nodeIds }, writeOptions);
37
+ return { type: "delete", deletedNodeIds: [...r2.deletedNodeIds ?? []], revision: r2.revision, changeSet: r2.changeSet, requestId: options.requestId };
38
+ }
39
+ if (input.type === "create") {
40
+ const nodes = input.nodes.map((node) => {
41
+ const { content, path, source, ...rest } = node;
42
+ const { fileName, mimeType, relativePath, rootPath, baseUrl, ...geometry } = rest;
43
+ const hasSource = source !== void 0 || content !== void 0 || path !== void 0;
44
+ const positioned = {
45
+ x: 0,
46
+ y: 0,
47
+ rotation: 0,
48
+ zIndex: 0,
49
+ ...geometry
50
+ };
51
+ if (!hasSource) return { width: 100, height: 100, ...positioned };
52
+ return {
53
+ ...positioned,
54
+ source: agentSource(source, content, path, { fileName, mimeType, relativePath, rootPath, baseUrl })
55
+ };
56
+ });
57
+ const r2 = await c.nodes.create({ nodes }, writeOptions);
58
+ return { type: "create", nodes: r2.nodes.map((node) => compact(node)), revision: r2.revision, changed: r2.changed, changeSet: r2.changeSet, requestId: options.requestId };
59
+ }
60
+ const current = await c.nodes.read({ filter: { ids: input.nodes.map((node) => node.id) } }, options);
61
+ const byId = new Map(current.nodes.map((node) => [node.id, node]));
62
+ const updates = input.nodes.map(({ id, content, path, source, ...rest }) => {
63
+ const { fileName, mimeType, relativePath, rootPath, baseUrl, ...patch } = rest;
64
+ if (content === void 0 && path === void 0 && source === void 0) return { id, patch };
65
+ if (!byId.has(id)) throw new CapabilityError("NODE_NOT_FOUND", `Node not found: ${id}`, { nodeId: id });
66
+ return { id, patch, source: agentSource(source, content, path, { fileName, mimeType, relativePath, rootPath, baseUrl }) };
67
+ });
68
+ const r = await c.nodes.update({ nodes: updates }, writeOptions);
69
+ return { type: "update", nodes: r.nodes.map((node) => compact(node)), revision: r.revision, changed: r.changed, changeSet: r.changeSet, requestId: options.requestId };
70
+ }
71
+ function agentSource(explicit, content, path, fields) {
72
+ if (explicit) return explicit;
73
+ const shared = {
74
+ ...fields.fileName ? { fileName: fields.fileName } : {},
75
+ ...fields.mimeType ? { mimeType: fields.mimeType } : {},
76
+ ...fields.relativePath ? { relativePath: fields.relativePath } : {},
77
+ ...fields.baseUrl ? { baseUrl: fields.baseUrl } : {}
78
+ };
79
+ if (content !== void 0) return { type: "content", content, ...shared };
80
+ if (path !== void 0) return { type: "file", path, ...shared, ...fields.rootPath ? { rootPath: fields.rootPath } : {} };
81
+ throw new CapabilityError("INVALID_INPUT", "source must be content, file, or url");
82
+ }
83
+ function compact(node, fields) {
84
+ const out = { id: node.id, type: node.type, ...node.name === void 0 ? {} : { name: node.name } };
85
+ if (!fields?.length || fields.includes("position")) out.position = { x: node.x, y: node.y };
86
+ if (!fields?.length || fields.includes("size")) out.size = { width: node.width, height: node.height };
87
+ if (!fields?.length || fields.includes("rotation")) out.rotation = node.rotation;
88
+ if (!fields?.length || fields.includes("zIndex")) out.zIndex = node.zIndex;
89
+ if (!fields?.length || fields.includes("fit")) out.fit = node.fit ?? "contain";
90
+ if (!fields?.length || fields.includes("assetRefs")) out.assetRefs = node.assetRefs;
91
+ if (!fields?.length || fields.includes("props")) out.props = node.props;
92
+ return out;
93
+ }
94
+ function project(value, fields) {
95
+ if (!fields?.length) return { ...value };
96
+ const out = { id: value.id, kind: value.kind };
97
+ for (const field of fields) if (field in value) out[field] = value[field];
98
+ return out;
99
+ }
100
+ function validateRead(value) {
101
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CapabilityError("INVALID_INPUT", "canvas.read input must be an object");
102
+ const v = value;
103
+ if (!["nodes", "assets", "preview"].includes(v.type)) throw new CapabilityError("INVALID_INPUT", "canvas.read.type is invalid");
104
+ const allowed = v.type === "nodes" ? ["type", "ids", "types", "limit", "cursor", "fields"] : v.type === "assets" ? ["type", "ids", "kinds", "limit", "cursor", "fields"] : ["type", "id", "maxWidth", "maxHeight", "frameNumber", "fps"];
105
+ rejectUnknown(v, allowed);
106
+ if (v.type === "preview" && typeof v.id !== "string") throw new CapabilityError("INVALID_INPUT", "canvas.read preview requires id");
107
+ if (v.limit !== void 0 && (!Number.isInteger(v.limit) || Number(v.limit) < 1 || Number(v.limit) > 200)) throw new CapabilityError("INVALID_INPUT", "limit must be between 1 and 200");
108
+ return v;
109
+ }
110
+ function validateWrite(value) {
111
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CapabilityError("INVALID_INPUT", "canvas.write input must be an object");
112
+ const v = value;
113
+ if (!["create", "update", "delete"].includes(v.type)) throw new CapabilityError("INVALID_INPUT", "canvas.write.type is invalid");
114
+ rejectUnknown(v, v.type === "delete" ? ["type", "nodeIds"] : ["type", "nodes"]);
115
+ if (v.type === "delete" ? !Array.isArray(v.nodeIds) || !v.nodeIds.length : !Array.isArray(v.nodes) || !v.nodes.length) throw new CapabilityError("INVALID_INPUT", "write payload must contain a non-empty batch");
116
+ return v;
117
+ }
118
+ function rejectUnknown(value, allowed) {
119
+ for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new CapabilityError("INVALID_INPUT", `Unsupported field: ${key}`);
120
+ }
121
+
122
+ export { createPixiBoardAgentTools };
123
+ //# sourceMappingURL=agent-tools.js.map
124
+ //# sourceMappingURL=agent-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../agent-tools/src/index.ts"],"names":["r"],"mappings":";;;;;;;AAOO,SAAS,0BAA0B,YAAA,EAA6C;AACrF,EAAA,OAAO,EAAE,OAAA,EAAS,EAAE,aAAA,EAAe,kBAAkB,cAAA,EAAgB,iBAAA,EAAkB,EAAG,MAAM,IAAA,CAAK,IAAA,EAAM,GAAA,EAAK,OAAA,GAAU,EAAC,EAAG;AAC5H,IAAA,MAAM,YAAY,OAAA,CAAQ,SAAA;AAC1B,IAAA,IAAI;AACF,MAAA,IAAI,IAAA,KAAS,aAAA,EAAe,OAAO,EAAE,IAAI,IAAA,EAAM,IAAA,EAAM,MAAM,IAAA,CAAK,YAAA,EAAc,YAAA,CAAa,GAAG,CAAA,EAAG,OAAO,CAAA,EAAE;AAC1G,MAAA,IAAI,IAAA,KAAS,cAAA,EAAgB,OAAO,EAAE,IAAI,IAAA,EAAM,IAAA,EAAM,MAAM,KAAA,CAAM,YAAA,EAAc,aAAA,CAAc,GAAG,CAAA,EAAG,OAAO,CAAA,EAAE;AAC7G,MAAA,MAAM,IAAI,eAAA,CAAgB,eAAA,EAAiB,CAAA,cAAA,EAAiB,IAAI,CAAA,CAAE,CAAA;AAAA,IACpE,SAAS,KAAA,EAAO;AAAE,MAAA,MAAM,CAAA,GAAI,iBAAA,CAAkB,KAAK,CAAA,GAAI,QAAQ,IAAI,eAAA,CAAgB,gBAAA,EAAkB,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AAAG,MAAA,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAO,EAAE,IAAA,EAAM,CAAA,CAAE,IAAA,EAA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AAA,EAAkC;AAAE,EAAA,KAAA,MAAW,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,MAAO,CAAC,OAAA,CAAQ,QAAA,CAAS,GAAG,GAAG,MAAM,IAAI,gBAAgB,eAAA,EAAiB,CAAA,mBAAA,EAAsB,GAAG,CAAA,CAAE,CAAA;AAAG","file":"agent-tools.js","sourcesContent":["import { CapabilityError, isCapabilityError, type BoardCapabilities } from \"@pixi-board/capabilities\";\nimport { canvasReadSchema, canvasWriteSchema } from \"./schemas.ts\";\nimport type { AgentCallOptions, AgentTools, CanvasOutput, CanvasReadInput, CanvasWriteInput, CompactAsset, CompactNode } from \"./types.ts\";\nimport type { AssetImportSource, AssetRecord, BoardNode, CreateNodeInput, JsonValue } from \"@pixi-board/capabilities\";\nexport * from \"./types.ts\";\nexport * from \"./schemas.ts\";\n\nexport function createPixiBoardAgentTools(capabilities: BoardCapabilities): AgentTools {\n return { schemas: { \"canvas.read\": canvasReadSchema, \"canvas.write\": canvasWriteSchema }, async call(name, raw, options = {}) {\n const requestId = options.requestId;\n try {\n if (name === \"canvas.read\") return { ok: true, data: await read(capabilities, validateRead(raw), options) };\n if (name === \"canvas.write\") return { ok: true, data: await write(capabilities, validateWrite(raw), options) };\n throw new CapabilityError(\"INVALID_INPUT\", `Unknown tool: ${name}`);\n } catch (error) { const e = isCapabilityError(error) ? error : new CapabilityError(\"INTERNAL_ERROR\", error instanceof Error ? error.message : String(error)); return { ok: false, error: { code: e.code, name: e.name, message: e.message, retryable: e.code === \"ABORTED\" || e.code === \"TRANSACTION_CONFLICT\", requestId, details: e.details ? { ...e.details } : undefined } }; }\n } };\n}\nasync function read(c: BoardCapabilities, input: CanvasReadInput, options: AgentCallOptions): Promise<CanvasOutput> {\n if (input.type === \"nodes\") { const r = await c.nodes.read({ filter: { ids: input.ids, types: input.types }, limit: input.limit, cursor: input.cursor }, options); return { type: \"nodes\", nodes: r.nodes.map((n) => compact(n, input.fields)), page: r.page, revision: r.revision, requestId: options.requestId }; }\n if (input.type === \"assets\") { const r = await c.assets.read({ ids: input.ids, kinds: input.kinds, limit: input.limit, cursor: input.cursor }, options); return { type: \"assets\", assets: r.assets.map((a) => project(a, input.fields)), page: r.page, revision: r.revision, requestId: options.requestId }; }\n const r = await c.preview.get({ nodeId: input.id, maxWidth: input.maxWidth, maxHeight: input.maxHeight, frameNumber: input.frameNumber, fps: input.fps }, options); return { type: \"preview\", preview: r, content: [{ type: \"image\", dataUrl: r.dataUrl, mimeType: r.mimeType }], revision: r.revision, requestId: options.requestId };\n}\nasync function write(c: BoardCapabilities, input: CanvasWriteInput, options: AgentCallOptions): Promise<CanvasOutput> {\n const writeOptions = { ...options, origin: options.origin ?? \"agent:canvas\" };\n if (input.type === \"delete\") { const r = await c.nodes.delete({ nodeIds: input.nodeIds }, writeOptions); return { type: \"delete\", deletedNodeIds: [...(r.deletedNodeIds ?? [])], revision: r.revision, changeSet: r.changeSet, requestId: options.requestId }; }\n if (input.type === \"create\") {\n const nodes = input.nodes.map((node): CreateNodeInput => {\n const { content, path, source, ...rest } = node;\n const { fileName, mimeType, relativePath, rootPath, baseUrl, ...geometry } = rest;\n const hasSource = source !== undefined || content !== undefined || path !== undefined;\n const positioned = {\n x: 0,\n y: 0,\n rotation: 0,\n zIndex: 0,\n ...geometry,\n };\n if (!hasSource) return { width: 100, height: 100, ...positioned };\n return {\n ...positioned,\n source: agentSource(source, content, path, { fileName, mimeType, relativePath, rootPath, baseUrl }),\n };\n });\n const r = await c.nodes.create({ nodes }, writeOptions); return { type: \"create\", nodes: r.nodes.map((node) => compact(node)), revision: r.revision, changed: r.changed, changeSet: r.changeSet, requestId: options.requestId };\n }\n const current = await c.nodes.read({ filter: { ids: input.nodes.map((node) => node.id) } }, options);\n const byId = new Map(current.nodes.map((node) => [node.id, node]));\n const updates = input.nodes.map(({ id, content, path, source, ...rest }) => {\n const { fileName, mimeType, relativePath, rootPath, baseUrl, ...patch } = rest;\n if (content === undefined && path === undefined && source === undefined) return { id, patch };\n if (!byId.has(id)) throw new CapabilityError(\"NODE_NOT_FOUND\", `Node not found: ${id}`, { nodeId: id });\n return { id, patch, source: agentSource(source, content, path, { fileName, mimeType, relativePath, rootPath, baseUrl }) };\n });\n const r = await c.nodes.update({ nodes: updates }, writeOptions); return { type: \"update\", nodes: r.nodes.map((node) => compact(node)), revision: r.revision, changed: r.changed, changeSet: r.changeSet, requestId: options.requestId };\n}\nfunction agentSource(\n explicit: AssetImportSource | undefined,\n content: string | undefined,\n path: string | undefined,\n fields: {\n fileName?: string;\n mimeType?: string;\n relativePath?: string;\n rootPath?: string;\n baseUrl?: string;\n },\n): AssetImportSource {\n if (explicit) return explicit;\n const shared = {\n ...(fields.fileName ? { fileName: fields.fileName } : {}),\n ...(fields.mimeType ? { mimeType: fields.mimeType } : {}),\n ...(fields.relativePath ? { relativePath: fields.relativePath } : {}),\n ...(fields.baseUrl ? { baseUrl: fields.baseUrl } : {}),\n };\n if (content !== undefined) return { type: \"content\", content, ...shared };\n if (path !== undefined) return { type: \"file\", path, ...shared, ...(fields.rootPath ? { rootPath: fields.rootPath } : {}) };\n throw new CapabilityError(\"INVALID_INPUT\", \"source must be content, file, or url\");\n}\nfunction compact(node: BoardNode, fields?: string[]): CompactNode {\n const out: CompactNode = { id: node.id, type: node.type, ...(node.name === undefined ? {} : { name: node.name }) };\n if (!fields?.length || fields.includes(\"position\")) out.position = { x: node.x, y: node.y };\n if (!fields?.length || fields.includes(\"size\")) out.size = { width: node.width, height: node.height };\n if (!fields?.length || fields.includes(\"rotation\")) out.rotation = node.rotation;\n if (!fields?.length || fields.includes(\"zIndex\")) out.zIndex = node.zIndex;\n if (!fields?.length || fields.includes(\"fit\")) out.fit = node.fit ?? \"contain\";\n if (!fields?.length || fields.includes(\"assetRefs\")) out.assetRefs = node.assetRefs;\n if (!fields?.length || fields.includes(\"props\")) out.props = node.props;\n return out;\n}\nfunction project(value: AssetRecord, fields?: string[]): CompactAsset { if (!fields?.length) return { ...value }; const out: CompactAsset = { id: value.id, kind: value.kind }; for (const field of fields) if (field in value) out[field] = value[field] as JsonValue | undefined; return out; }\nfunction validateRead(value: unknown): CanvasReadInput { if (!value || typeof value !== \"object\" || Array.isArray(value)) throw new CapabilityError(\"INVALID_INPUT\", \"canvas.read input must be an object\"); const v = value as Record<string, unknown>; if (![\"nodes\", \"assets\", \"preview\"].includes(v.type as string)) throw new CapabilityError(\"INVALID_INPUT\", \"canvas.read.type is invalid\"); const allowed = v.type === \"nodes\" ? [\"type\",\"ids\",\"types\",\"limit\",\"cursor\",\"fields\"] : v.type === \"assets\" ? [\"type\",\"ids\",\"kinds\",\"limit\",\"cursor\",\"fields\"] : [\"type\",\"id\",\"maxWidth\",\"maxHeight\",\"frameNumber\",\"fps\"]; rejectUnknown(v, allowed); if (v.type === \"preview\" && typeof v.id !== \"string\") throw new CapabilityError(\"INVALID_INPUT\", \"canvas.read preview requires id\"); if (v.limit !== undefined && (!Number.isInteger(v.limit) || Number(v.limit) < 1 || Number(v.limit) > 200)) throw new CapabilityError(\"INVALID_INPUT\", \"limit must be between 1 and 200\"); return v as unknown as CanvasReadInput; }\nfunction validateWrite(value: unknown): CanvasWriteInput { if (!value || typeof value !== \"object\" || Array.isArray(value)) throw new CapabilityError(\"INVALID_INPUT\", \"canvas.write input must be an object\"); const v = value as Record<string, unknown>; if (![\"create\", \"update\", \"delete\"].includes(v.type as string)) throw new CapabilityError(\"INVALID_INPUT\", \"canvas.write.type is invalid\"); rejectUnknown(v, v.type === \"delete\" ? [\"type\",\"nodeIds\"] : [\"type\",\"nodes\"]); if (v.type === \"delete\" ? !Array.isArray(v.nodeIds) || !v.nodeIds.length : !Array.isArray(v.nodes) || !v.nodes.length) throw new CapabilityError(\"INVALID_INPUT\", \"write payload must contain a non-empty batch\"); return v as unknown as CanvasWriteInput; }\nfunction rejectUnknown(value: Record<string, unknown>, allowed: readonly string[]): void { for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new CapabilityError(\"INVALID_INPUT\", `Unsupported field: ${key}`); }\n"]}
package/dist/browser.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- export { AssetUnavailableError, BoardDestroyedError, CapabilityError, CapabilityUnavailableError, DocumentValidationError, NodeNotFoundError, NodeTypeNotRegisteredError, NodeValidationError, PermissionDeniedError, RESIZE_HANDLES, TransactionConflictError, createPixiBoard, isAssetVariant, resizeHandleAxes, resizeHandleCursor } from './index.js';
2
- import { B as BoardNode, W as WorldBounds, R as ResizeHandle, P as PixiBoard, J as JsonValue, a as Point, V as ViewportSnapshot, A as AssetVariant, b as BoardDocument, c as AssetRecord, d as BoardDocumentUpdate, e as BoardChangeSet, C as ConnectionStyle, f as ConnectionCurve } from './types-D39-tYZ8.js';
3
- export { g as AssetRef, h as BoardCapabilities, i as BoardChangeEvent, j as BoardLifecycleState, k as BoardNodeConvertInput, l as BoardNodeCreateInput, m as BoardNodePatch, n as BoardRuntimePorts, o as BrowserEventPort, p as CaptureInput, q as CaptureResult, r as ChangeOrigin, s as ConnectionLayer, t as CustomDisplayFactory, u as CustomDisplayObject, v as CustomNodeDataDefinition, w as CustomNodeDefinition, x as CustomNodeRenderer, y as CustomNodeRendererContext, z as CustomNodeRendererRegistry, D as CustomNodeView, E as CustomRendererResources, F as CustomResizePolicy, G as CustomTextureLease, H as DocumentLoadOptions, I as DocumentPersistence, K as HistoryChangeEvent, N as NodeGeometry, L as NodeHandle, M as NodeHandleEventMap, O as NodeInput, Q as NodeListFilter, S as NodePatch, T as NodeQuery, U as NodeResizeRequest, X as NodeTypeDefinition, Y as NodeTypeRegistrationDisposer, Z as NodeTypeRegistrationOptions, _ as NodeTypeRegistry, $ as PixiBoardOptions, a0 as PixiBoardRendererOptions, a1 as PreviewNode, a2 as PreviewQuality, a3 as PreviewSpec, a4 as PreviewSpecOptions, a5 as PreviewState, a6 as PreviewStatus, a7 as PublicBoardEventMap, a8 as PublicNodeTypeDefinition, a9 as PublicRendererOptions, aa as RenderCompleteEvent, ab as RendererApplyResult, ac as ResizeObserverPort, ad as RuntimeRenderer, ae as SelectionChangeEvent, af as TickerPort, ag as TransactionOptions, ah as TransactionOrigin, ai as TransformBounds, aj as TransformHandlePlacement, ak as TransformSession, al as ViewportChangeEvent, am as createPreviewSpec, an as isDocumentPreviewType, ao as isPreviewNodeType, ap as previewStatusLabel } from './types-D39-tYZ8.js';
4
-
5
- declare function rotatedRectBounds(node: BoardNode): WorldBounds;
1
+ export { createPixiBoard } from './index.js';
2
+ import { PixiBoard } from './types.js';
3
+ export { BoardLifecycleState, BoardRuntimePorts, BrowserEventPort, CaptureInput, ConnectionLayer, CustomDisplayFactory, CustomDisplayObject, CustomNodeDataDefinition, CustomNodeDefinition, CustomNodeRenderer, CustomNodeRendererContext, CustomNodeRendererRegistry, CustomNodeView, CustomRendererResources, CustomResizePolicy, CustomTextureLease, DocumentPersistence, HistoryChangeEvent, NodeHandle, NodeHandleEventMap, NodeInput, NodePatch, NodeQuery, NodeTypeDefinition, NodeTypeRegistrationDisposer, NodeTypeRegistrationOptions, PixiBoardOptions, PixiBoardRendererOptions, PublicBoardEventMap, PublicNodeTypeDefinition, PublicRendererOptions, RenderCompleteEvent, RendererApplyResult, ResizeObserverPort, RuntimeRenderer, SelectionChangeEvent, TickerPort, TransactionOrigin, TransformBounds, TransformHandlePlacement, TransformSession, ViewportChangeEvent } from './types.js';
4
+ import { R as ResizeHandle, a as BoardNode, J as JsonValue, W as WorldBounds, P as Point, V as ViewportSnapshot, k as AssetVariant, h as BoardDocument, A as AssetRecord, i as BoardDocumentUpdate, B as BoardChangeSet, C as ConnectionStyle, b as ConnectionCurve } from './types-BEsq8g6W.js';
5
+ export { g as AssetRef, e as BoardNodeConvertInput, c as BoardNodeCreateInput, d as BoardNodePatch, j as ChangeOrigin, l as ContentFit, D as DocumentLoadOptions, M as MediaMetadata, m as NodeGeometry, f as NodeListFilter, N as NodeResizeRequest, T as TransactionOptions } from './types-BEsq8g6W.js';
6
+ export { D as DocumentValidationError, N as NodeNotFoundError, a as NodeTypeNotRegisteredError, b as NodeValidationError, R as RESIZE_HANDLES, T as TransactionConflictError, c as createMediaAssetRefs, d as createMediaMetadata, f as fitMediaRect, i as isAssetVariant, e as isContentFit, p as preferredMediaNodeSize, r as resizeHandleAxes, g as resizeHandleCursor, h as resolveTextureAssetRef } from './resize-BK1wOjTc.js';
7
+ export { P as PreviewBlobLike, a as PreviewNode, b as PreviewQuality, c as PreviewRenderInput, d as PreviewRenderResult, e as PreviewRenderer, l as PreviewRendererRegistry, f as PreviewRendererRegistryOptions, g as PreviewSource, h as PreviewSpec, i as PreviewSpecOptions, j as PreviewState, k as PreviewStatus, R as RegisterPreviewRendererOptions, m as createPreviewSpec, p as previewStatusLabel } from './preview-registry-BjdGxaWe.js';
8
+ export { a as BoardChangeEvent, N as NodeTypeRegistry } from './core-B_8DmBaT.js';
9
+ export { rotatedRectBounds } from './core.js';
10
+ export { a as AssetImportRequest, A as AssetImportService, b as AssetImportSource, B as BoardCapabilities, c as CaptureResult, I as ImportedAsset } from './types-BskqWTyl.js';
11
+ export { A as AssetUnavailableError, B as BoardDestroyedError, C as CapabilityError, b as CapabilityUnavailableError, P as PermissionDeniedError } from './errors-CEQ_RiJ_.js';
6
12
 
7
13
  type DomTransformerOptions = {
8
14
  /**
@@ -889,4 +895,4 @@ declare function indexedDbPersistence(options?: {
889
895
  database?: string;
890
896
  }): BrowserPersistenceAdapter;
891
897
 
892
- export { type AdapterOperationOptions, type AssetBinaryVariant, type AssetGcOptions, type AssetGcResult, type AssetGcRoots, type AssetStorageLocation, AssetVariant, type BoardConnection, BoardDocument, BoardDocumentUpdate, BoardNode, type BrowserAdapterCapabilities, type BrowserAdapterContractEvidence, type BrowserAdapterContractHarness, type BrowserAsset, BrowserAssetBinaryMissingError, type BrowserAssetExport, BrowserAssetNotFoundError, type BrowserCleanupError, type BrowserCleanupOperation, type BrowserCommitImportOptions, BrowserDocumentConflictError, type BrowserDocumentMetadata, type BrowserDocumentRecord, type BrowserDownloadRequest, type BrowserExportOptions, type BrowserImportOptions, type BrowserImportResult, type BrowserImportSourceType, BrowserPersistenceAbortError, BrowserPersistenceAdapter, type BrowserPersistenceAdapterOptions, BrowserPersistenceDestroyedError, BrowserPersistenceError, type BrowserPrepareImportOptions, type BrowserPreparedImport, BrowserStorageCapabilityError, BrowserStorageKeyCollisionError, BrowserStorageQuotaError, ConnectionCurve, ConnectionStyle, type ConnectionsController, type ConnectionsOptions, DEFAULT_OPFS_THRESHOLD_BYTES, type DomTransformer, type DomTransformerOptions, type DownloadPort, type GetAssetOptions, type IndexedDbPort, JsonValue, type LabelOverlayOptions, NativeDownloadPort, type NativeDownloadPortOptions, NativeIndexedDbPort, type NativeIndexedDbPortOptions, NativeObjectUrlPort, NativeOpfsPort, type NativeOpfsPortOptions, type NodeAgentContext, type NodeAgentContextOptions, type NodeAgentOperation, type NodeAgentOptions, type NodeAgentRequest, type NodeAgentResource, type NodeAgentScope, type NodeAgentTarget, type ObjectUrlLease, type ObjectUrlPort, type OpfsPort, type OverlayAnchor, type OverlayBoundsResolver, type OverlayDeclutter, type OverlayItem, type OverlayLayer, type OverlayLayerOptions, type OverlayPlacement, type OverlayRenderContext, type OverlayScaleMode, PixiBoard, PixiBoardRenderer, Point, type PortLifecycle, type PutAssetOptions, ResizeHandle, type SaveBrowserDocumentInput, type SaveBrowserDocumentOptions, type SelectionOverlayOptions, type StoredAssetBinary, type StoredAssetEntry, ViewportSnapshot, WorldBounds, anchorRatio, anchorWorldPoint, attachConnections, attachDomTransformer, attachLabelOverlay, attachOverlayLayer, attachSelectionOverlay, buildNodeAgentPrompt, createNodeAgentController, createPixiApplicationFactory, indexedDbPersistence, isBrowserQuotaError, loadPixiRuntime, projectOverlayItem, resolveOverlayBounds, resolveScale, rotatedRectBounds, runBrowserAdapterContract };
898
+ export { type AdapterOperationOptions, type AssetBinaryVariant, type AssetGcOptions, type AssetGcResult, type AssetGcRoots, type AssetStorageLocation, AssetVariant, type BoardConnection, BoardDocument, BoardDocumentUpdate, BoardNode, type BrowserAdapterCapabilities, type BrowserAdapterContractEvidence, type BrowserAdapterContractHarness, type BrowserAsset, BrowserAssetBinaryMissingError, type BrowserAssetExport, BrowserAssetNotFoundError, type BrowserCleanupError, type BrowserCleanupOperation, type BrowserCommitImportOptions, BrowserDocumentConflictError, type BrowserDocumentMetadata, type BrowserDocumentRecord, type BrowserDownloadRequest, type BrowserExportOptions, type BrowserImportOptions, type BrowserImportResult, type BrowserImportSourceType, BrowserPersistenceAbortError, BrowserPersistenceAdapter, type BrowserPersistenceAdapterOptions, BrowserPersistenceDestroyedError, BrowserPersistenceError, type BrowserPrepareImportOptions, type BrowserPreparedImport, BrowserStorageCapabilityError, BrowserStorageKeyCollisionError, BrowserStorageQuotaError, ConnectionCurve, ConnectionStyle, type ConnectionsController, type ConnectionsOptions, DEFAULT_OPFS_THRESHOLD_BYTES, type DomTransformer, type DomTransformerOptions, type DownloadPort, type GetAssetOptions, type IndexedDbPort, JsonValue, type LabelOverlayOptions, NativeDownloadPort, type NativeDownloadPortOptions, NativeIndexedDbPort, type NativeIndexedDbPortOptions, NativeObjectUrlPort, NativeOpfsPort, type NativeOpfsPortOptions, type NodeAgentContext, type NodeAgentContextOptions, type NodeAgentOperation, type NodeAgentOptions, type NodeAgentRequest, type NodeAgentResource, type NodeAgentScope, type NodeAgentTarget, type ObjectUrlLease, type ObjectUrlPort, type OpfsPort, type OverlayAnchor, type OverlayBoundsResolver, type OverlayDeclutter, type OverlayItem, type OverlayLayer, type OverlayLayerOptions, type OverlayPlacement, type OverlayRenderContext, type OverlayScaleMode, PixiBoard, PixiBoardRenderer, Point, type PortLifecycle, type PutAssetOptions, ResizeHandle, type SaveBrowserDocumentInput, type SaveBrowserDocumentOptions, type SelectionOverlayOptions, type StoredAssetBinary, type StoredAssetEntry, ViewportSnapshot, WorldBounds, anchorRatio, anchorWorldPoint, attachConnections, attachDomTransformer, attachLabelOverlay, attachOverlayLayer, attachSelectionOverlay, buildNodeAgentPrompt, createNodeAgentController, createPixiApplicationFactory, indexedDbPersistence, isBrowserQuotaError, loadPixiRuntime, projectOverlayItem, resolveOverlayBounds, resolveScale, runBrowserAdapterContract };