@jamesyong42/infinite-canvas 1.0.0 → 1.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/README.md +170 -9
- package/dist/SelectionRenderer-CR2PBQwx.d.cts +105 -0
- package/dist/SelectionRenderer-CR2PBQwx.d.cts.map +1 -0
- package/dist/SelectionRenderer-DlsBstAq.d.mts +105 -0
- package/dist/SelectionRenderer-DlsBstAq.d.mts.map +1 -0
- package/dist/WebGLWidgetLayer-BBMuwzHq.cjs +3560 -0
- package/dist/WebGLWidgetLayer-BBMuwzHq.cjs.map +1 -0
- package/dist/WebGLWidgetLayer-C3p1tnpm.mjs +3375 -0
- package/dist/WebGLWidgetLayer-C3p1tnpm.mjs.map +1 -0
- package/dist/advanced.cjs +110 -165
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +58 -40
- package/dist/advanced.d.cts.map +1 -0
- package/dist/advanced.d.mts +99 -0
- package/dist/advanced.d.mts.map +1 -0
- package/dist/advanced.mjs +105 -0
- package/dist/advanced.mjs.map +1 -0
- package/dist/devtools.cjs +654 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +23 -0
- package/dist/devtools.d.cts.map +1 -0
- package/dist/devtools.d.mts +23 -0
- package/dist/devtools.d.mts.map +1 -0
- package/dist/devtools.mjs +652 -0
- package/dist/devtools.mjs.map +1 -0
- package/dist/engine-BfbvWXSk.d.mts +982 -0
- package/dist/engine-BfbvWXSk.d.mts.map +1 -0
- package/dist/engine-CCjuFMC-.d.cts +982 -0
- package/dist/engine-CCjuFMC-.d.cts.map +1 -0
- package/dist/hooks-BwY7rRHg.mjs +425 -0
- package/dist/hooks-BwY7rRHg.mjs.map +1 -0
- package/dist/hooks-DHShH86C.cjs +707 -0
- package/dist/hooks-DHShH86C.cjs.map +1 -0
- package/dist/index.cjs +909 -803
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +199 -67
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +258 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +855 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -15
- package/dist/SelectionRenderer-CeWSNZT8.d.cts +0 -891
- package/dist/SelectionRenderer-CeWSNZT8.d.ts +0 -891
- package/dist/advanced.d.ts +0 -81
- package/dist/advanced.js +0 -124
- package/dist/advanced.js.map +0 -1
- package/dist/chunk-VSHXWTJH.cjs +0 -3228
- package/dist/chunk-VSHXWTJH.cjs.map +0 -1
- package/dist/chunk-Z6JQQOWL.js +0 -3142
- package/dist/chunk-Z6JQQOWL.js.map +0 -1
- package/dist/index.d.ts +0 -126
- package/dist/index.js +0 -602
- package/dist/index.js.map +0 -1
package/dist/advanced.cjs
CHANGED
|
@@ -1,175 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_WebGLWidgetLayer = require("./WebGLWidgetLayer-BBMuwzHq.cjs");
|
|
3
|
+
const require_hooks = require("./hooks-DHShH86C.cjs");
|
|
4
|
+
//#region src/serialization.ts
|
|
5
|
+
/**
|
|
6
|
+
* Serializes all entities, components, and tags to a JSON-compatible document.
|
|
7
|
+
* Requires registries of known component and tag types for enumeration.
|
|
8
|
+
*/
|
|
6
9
|
function serializeWorld(world, componentTypes, tagTypes, camera, navigationFrames) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
camera: { ...camera },
|
|
34
|
-
navigationStack: structuredClone(navigationFrames)
|
|
35
|
-
}
|
|
36
|
-
};
|
|
10
|
+
const entities = [];
|
|
11
|
+
const allEntities = world.query();
|
|
12
|
+
for (const entityId of allEntities) {
|
|
13
|
+
const components = {};
|
|
14
|
+
const tags = [];
|
|
15
|
+
for (const type of componentTypes) {
|
|
16
|
+
const data = world.getComponent(entityId, type);
|
|
17
|
+
if (data !== void 0) components[type.name] = structuredClone(data);
|
|
18
|
+
}
|
|
19
|
+
for (const type of tagTypes) if (world.hasTag(entityId, type)) {
|
|
20
|
+
if (type.name !== "Active" && type.name !== "Visible") tags.push(type.name);
|
|
21
|
+
}
|
|
22
|
+
if (Object.keys(components).length > 0 || tags.length > 0) entities.push({
|
|
23
|
+
id: entityId,
|
|
24
|
+
components,
|
|
25
|
+
tags
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
version: 1,
|
|
30
|
+
entities,
|
|
31
|
+
resources: {
|
|
32
|
+
camera: { ...camera },
|
|
33
|
+
navigationStack: structuredClone(navigationFrames)
|
|
34
|
+
}
|
|
35
|
+
};
|
|
37
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Restores entities from a serialized document into the world.
|
|
39
|
+
* Clears existing state first and remaps entity IDs automatically.
|
|
40
|
+
*/
|
|
38
41
|
function deserializeWorld(world, doc, componentTypes, tagTypes) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const mappedId = idMap.get(parent.id);
|
|
70
|
-
if (mappedId !== void 0) {
|
|
71
|
-
world.setComponent(newId, chunkVSHXWTJH_cjs.Parent, { id: mappedId });
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const children = world.getComponent(newId, chunkVSHXWTJH_cjs.Children);
|
|
75
|
-
if (children) {
|
|
76
|
-
world.setComponent(newId, chunkVSHXWTJH_cjs.Children, {
|
|
77
|
-
ids: children.ids.map((id) => idMap.get(id) ?? id)
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const handleSet = world.getComponent(newId, chunkVSHXWTJH_cjs.HandleSet);
|
|
81
|
-
if (handleSet) {
|
|
82
|
-
world.setComponent(newId, chunkVSHXWTJH_cjs.HandleSet, {
|
|
83
|
-
ids: handleSet.ids.map((id) => idMap.get(id) ?? id)
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
42
|
+
if (doc.version !== 1) throw new Error(`Unsupported canvas document version: ${doc.version}. Expected version 1.`);
|
|
43
|
+
const compByName = /* @__PURE__ */ new Map();
|
|
44
|
+
for (const t of componentTypes) compByName.set(t.name, t);
|
|
45
|
+
const tagByName = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const t of tagTypes) tagByName.set(t.name, t);
|
|
47
|
+
for (const entityId of world.query()) world.destroyEntity(entityId);
|
|
48
|
+
const idMap = /* @__PURE__ */ new Map();
|
|
49
|
+
for (const entry of doc.entities) {
|
|
50
|
+
const newId = world.createEntity();
|
|
51
|
+
idMap.set(entry.id, newId);
|
|
52
|
+
for (const [compName, data] of Object.entries(entry.components)) {
|
|
53
|
+
const type = compByName.get(compName);
|
|
54
|
+
if (type) world.addComponent(newId, type, data);
|
|
55
|
+
}
|
|
56
|
+
for (const tagName of entry.tags) {
|
|
57
|
+
const type = tagByName.get(tagName);
|
|
58
|
+
if (type) world.addTag(newId, type);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const [_oldId, newId] of idMap) {
|
|
62
|
+
const parent = world.getComponent(newId, require_hooks.Parent);
|
|
63
|
+
if (parent && idMap.has(parent.id)) {
|
|
64
|
+
const mappedId = idMap.get(parent.id);
|
|
65
|
+
if (mappedId !== void 0) world.setComponent(newId, require_hooks.Parent, { id: mappedId });
|
|
66
|
+
}
|
|
67
|
+
const children = world.getComponent(newId, require_hooks.Children);
|
|
68
|
+
if (children) world.setComponent(newId, require_hooks.Children, { ids: children.ids.map((id) => idMap.get(id) ?? id) });
|
|
69
|
+
const handleSet = world.getComponent(newId, require_hooks.HandleSet);
|
|
70
|
+
if (handleSet) world.setComponent(newId, require_hooks.HandleSet, { ids: handleSet.ids.map((id) => idMap.get(id) ?? id) });
|
|
71
|
+
}
|
|
87
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Serializes a subset of entities (e.g., for copy/paste).
|
|
75
|
+
* Recursively includes children of the specified entities.
|
|
76
|
+
*/
|
|
88
77
|
function serializeEntities(world, entityIds, componentTypes, tagTypes) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
visit(childId);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for (const id of entityIds) {
|
|
118
|
-
visit(id);
|
|
119
|
-
}
|
|
120
|
-
return result;
|
|
78
|
+
const result = [];
|
|
79
|
+
const visited = /* @__PURE__ */ new Set();
|
|
80
|
+
function visit(entityId) {
|
|
81
|
+
if (visited.has(entityId)) return;
|
|
82
|
+
visited.add(entityId);
|
|
83
|
+
const components = {};
|
|
84
|
+
const tags = [];
|
|
85
|
+
for (const type of componentTypes) {
|
|
86
|
+
const data = world.getComponent(entityId, type);
|
|
87
|
+
if (data !== void 0) components[type.name] = structuredClone(data);
|
|
88
|
+
}
|
|
89
|
+
for (const type of tagTypes) if (world.hasTag(entityId, type)) {
|
|
90
|
+
if (type.name !== "Active" && type.name !== "Visible") tags.push(type.name);
|
|
91
|
+
}
|
|
92
|
+
result.push({
|
|
93
|
+
id: entityId,
|
|
94
|
+
components,
|
|
95
|
+
tags
|
|
96
|
+
});
|
|
97
|
+
const children = components.Children;
|
|
98
|
+
if (children?.ids) for (const childId of children.ids) visit(childId);
|
|
99
|
+
}
|
|
100
|
+
for (const id of entityIds) visit(id);
|
|
101
|
+
return result;
|
|
121
102
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
Object.defineProperty(exports, "Profiler", {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
get: function () { return chunkVSHXWTJH_cjs.Profiler; }
|
|
138
|
-
});
|
|
139
|
-
Object.defineProperty(exports, "SelectionOverlaySlot", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
get: function () { return chunkVSHXWTJH_cjs.SelectionOverlaySlot; }
|
|
142
|
-
});
|
|
143
|
-
Object.defineProperty(exports, "SelectionRenderer", {
|
|
144
|
-
enumerable: true,
|
|
145
|
-
get: function () { return chunkVSHXWTJH_cjs.SelectionRenderer; }
|
|
146
|
-
});
|
|
147
|
-
Object.defineProperty(exports, "SpatialIndex", {
|
|
148
|
-
enumerable: true,
|
|
149
|
-
get: function () { return chunkVSHXWTJH_cjs.SpatialIndex; }
|
|
150
|
-
});
|
|
151
|
-
Object.defineProperty(exports, "SpatialIndexResource", {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
get: function () { return chunkVSHXWTJH_cjs.SpatialIndexResource; }
|
|
154
|
-
});
|
|
155
|
-
Object.defineProperty(exports, "WebGLWidgetLayer", {
|
|
156
|
-
enumerable: true,
|
|
157
|
-
get: function () { return chunkVSHXWTJH_cjs.WebGLWidgetLayer; }
|
|
158
|
-
});
|
|
159
|
-
Object.defineProperty(exports, "WebGLWidgetSlot", {
|
|
160
|
-
enumerable: true,
|
|
161
|
-
get: function () { return chunkVSHXWTJH_cjs.WebGLWidgetSlot; }
|
|
162
|
-
});
|
|
163
|
-
Object.defineProperty(exports, "WidgetSlot", {
|
|
164
|
-
enumerable: true,
|
|
165
|
-
get: function () { return chunkVSHXWTJH_cjs.WidgetSlot; }
|
|
166
|
-
});
|
|
167
|
-
Object.defineProperty(exports, "computeSnapGuides", {
|
|
168
|
-
enumerable: true,
|
|
169
|
-
get: function () { return chunkVSHXWTJH_cjs.computeSnapGuides; }
|
|
170
|
-
});
|
|
103
|
+
//#endregion
|
|
104
|
+
exports.ContainerRefProvider = require_hooks.ContainerRefProvider;
|
|
105
|
+
exports.EngineProvider = require_hooks.EngineProvider;
|
|
106
|
+
exports.GridRenderer = require_WebGLWidgetLayer.GridRenderer;
|
|
107
|
+
exports.Profiler = require_WebGLWidgetLayer.Profiler;
|
|
108
|
+
exports.SelectionOverlaySlot = require_WebGLWidgetLayer.SelectionOverlaySlot;
|
|
109
|
+
exports.SelectionRenderer = require_WebGLWidgetLayer.SelectionRenderer;
|
|
110
|
+
exports.SpatialIndex = require_WebGLWidgetLayer.SpatialIndex;
|
|
111
|
+
exports.SpatialIndexResource = require_WebGLWidgetLayer.SpatialIndexResource;
|
|
112
|
+
exports.WebGLWidgetLayer = require_WebGLWidgetLayer.WebGLWidgetLayer;
|
|
113
|
+
exports.WebGLWidgetSlot = require_WebGLWidgetLayer.WebGLWidgetSlot;
|
|
114
|
+
exports.WidgetSlot = require_WebGLWidgetLayer.WidgetSlot;
|
|
115
|
+
exports.computeSnapGuides = require_WebGLWidgetLayer.computeSnapGuides;
|
|
171
116
|
exports.deserializeWorld = deserializeWorld;
|
|
172
117
|
exports.serializeEntities = serializeEntities;
|
|
173
118
|
exports.serializeWorld = serializeWorld;
|
|
174
|
-
|
|
119
|
+
|
|
175
120
|
//# sourceMappingURL=advanced.cjs.map
|
package/dist/advanced.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/serialization.ts"],"names":["Parent","Children","HandleSet"],"mappings":";;;;;AA6BO,SAAS,cAAA,CACf,KAAA,EACA,cAAA,EACA,QAAA,EACA,QACA,gBAAA,EACiB;AACjB,EAAA,MAAM,WAA+B,EAAC;AAGtC,EAAA,MAAM,WAAA,GAAc,MAAM,KAAA,EAAM;AAEhC,EAAA,KAAA,MAAW,YAAY,WAAA,EAAa;AACnC,IAAA,MAAM,aAAsC,EAAC;AAC7C,IAAA,MAAM,OAAiB,EAAC;AAExB,IAAA,KAAA,MAAW,QAAQ,cAAA,EAAgB;AAClC,MAAA,MAAM,IAAA,GAAO,KAAA,CAAM,YAAA,CAAa,QAAA,EAAU,IAAI,CAAA;AAC9C,MAAA,IAAI,SAAS,MAAA,EAAW;AACvB,QAAA,UAAA,CAAW,IAAA,CAAK,IAAI,CAAA,GAAI,eAAA,CAAgB,IAAI,CAAA;AAAA,MAC7C;AAAA,IACD;AAEA,IAAA,KAAA,MAAW,QAAQ,QAAA,EAAU;AAC5B,MAAA,IAAI,KAAA,CAAM,MAAA,CAAO,QAAA,EAAU,IAAI,CAAA,EAAG;AAEjC,QAAA,IAAI,IAAA,CAAK,IAAA,KAAS,QAAA,IAAY,IAAA,CAAK,SAAS,SAAA,EAAW;AACtD,UAAA,IAAA,CAAK,IAAA,CAAK,KAAK,IAAI,CAAA;AAAA,QACpB;AAAA,MACD;AAAA,IACD;AAEA,IAAA,IAAI,MAAA,CAAO,KAAK,UAAU,CAAA,CAAE,SAAS,CAAA,IAAK,IAAA,CAAK,SAAS,CAAA,EAAG;AAC1D,MAAA,QAAA,CAAS,KAAK,EAAE,EAAA,EAAI,QAA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AAK,EAAE,EAAA,EAAI,QAAA,EAAU,UAAA,EAAY,MAAM,CAAA;AAI9C,IAAA,MAAM,WAAW,UAAA,CAAW,QAAA;AAC5B,IAAA,IAAI,UAAU,GAAA,EAAK;AAClB,MAAA,KAAA,MAAW,OAAA,IAAW,SAAS,GAAA,EAAK;AACnC,QAAA,KAAA,CAAM,OAAO,CAAA;AAAA,MACd;AAAA,IACD;AAAA,EACD;AAEA,EAAA,KAAA,MAAW,MAAM,SAAA,EAAW;AAC3B,IAAA,KAAA,CAAM,EAAE,CAAA;AAAA,EACT;AAEA,EAAA,OAAO,MAAA;AACR","file":"advanced.cjs","sourcesContent":["import type { ComponentType, EntityId, TagType, World } from '@jamesyong42/reactive-ecs';\nimport { Children, HandleSet, Parent } from './components.js';\nimport type { NavigationFrame } from './resources.js';\n\n// === Serialization Types ===\n\n/** JSON-serializable snapshot of the canvas state, including all entities and camera. */\nexport interface CanvasDocument {\n\tversion: number;\n\tentities: SerializedEntity[];\n\tresources: {\n\t\tcamera: { x: number; y: number; zoom: number };\n\t\tnavigationStack: NavigationFrame[];\n\t};\n}\n\n/** A single serialized entity with its components and tags. */\nexport interface SerializedEntity {\n\tid: EntityId;\n\tcomponents: Record<string, unknown>;\n\ttags: string[];\n}\n\n// === Serialize/Deserialize ===\n\n/**\n * Serializes all entities, components, and tags to a JSON-compatible document.\n * Requires registries of known component and tag types for enumeration.\n */\nexport function serializeWorld(\n\tworld: World,\n\tcomponentTypes: ComponentType[],\n\ttagTypes: TagType[],\n\tcamera: { x: number; y: number; zoom: number },\n\tnavigationFrames: NavigationFrame[],\n): CanvasDocument {\n\tconst entities: SerializedEntity[] = [];\n\n\t// Get all entity IDs (use a broad query)\n\tconst allEntities = world.query();\n\n\tfor (const entityId of allEntities) {\n\t\tconst components: Record<string, unknown> = {};\n\t\tconst tags: string[] = [];\n\n\t\tfor (const type of componentTypes) {\n\t\t\tconst data = world.getComponent(entityId, type);\n\t\t\tif (data !== undefined) {\n\t\t\t\tcomponents[type.name] = structuredClone(data);\n\t\t\t}\n\t\t}\n\n\t\tfor (const type of tagTypes) {\n\t\t\tif (world.hasTag(entityId, type)) {\n\t\t\t\t// Skip runtime-only tags (Active, Visible — they're recomputed)\n\t\t\t\tif (type.name !== 'Active' && type.name !== 'Visible') {\n\t\t\t\t\ttags.push(type.name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(components).length > 0 || tags.length > 0) {\n\t\t\tentities.push({ id: entityId, components, tags });\n\t\t}\n\t}\n\n\treturn {\n\t\tversion: 1,\n\t\tentities,\n\t\tresources: {\n\t\t\tcamera: { ...camera },\n\t\t\tnavigationStack: structuredClone(navigationFrames),\n\t\t},\n\t};\n}\n\n/**\n * Restores entities from a serialized document into the world.\n * Clears existing state first and remaps entity IDs automatically.\n */\nexport function deserializeWorld(\n\tworld: World,\n\tdoc: CanvasDocument,\n\tcomponentTypes: ComponentType[],\n\ttagTypes: TagType[],\n): void {\n\tif (doc.version !== 1) {\n\t\tthrow new Error(`Unsupported canvas document version: ${doc.version}. Expected version 1.`);\n\t}\n\n\t// Build lookup maps\n\tconst compByName = new Map<string, ComponentType>();\n\tfor (const t of componentTypes) compByName.set(t.name, t);\n\n\tconst tagByName = new Map<string, TagType>();\n\tfor (const t of tagTypes) tagByName.set(t.name, t);\n\n\t// Destroy all existing entities\n\tfor (const entityId of world.query()) {\n\t\tworld.destroyEntity(entityId);\n\t}\n\n\t// First pass: create entities and build old-to-new ID mapping\n\tconst idMap = new Map<EntityId, EntityId>();\n\n\tfor (const entry of doc.entities) {\n\t\tconst newId = world.createEntity();\n\t\tidMap.set(entry.id as EntityId, newId);\n\n\t\tfor (const [compName, data] of Object.entries(entry.components)) {\n\t\t\tconst type = compByName.get(compName);\n\t\t\tif (type) {\n\t\t\t\tworld.addComponent(newId, type, data);\n\t\t\t}\n\t\t}\n\n\t\tfor (const tagName of entry.tags) {\n\t\t\tconst type = tagByName.get(tagName);\n\t\t\tif (type) {\n\t\t\t\tworld.addTag(newId, type);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Second pass: remap cross-reference components (Parent, Children, HandleSet)\n\tfor (const [_oldId, newId] of idMap) {\n\t\tconst parent = world.getComponent(newId, Parent);\n\t\tif (parent && idMap.has(parent.id)) {\n\t\t\tconst mappedId = idMap.get(parent.id);\n\t\t\tif (mappedId !== undefined) {\n\t\t\t\tworld.setComponent(newId, Parent, { id: mappedId });\n\t\t\t}\n\t\t}\n\n\t\tconst children = world.getComponent(newId, Children);\n\t\tif (children) {\n\t\t\tworld.setComponent(newId, Children, {\n\t\t\t\tids: children.ids.map((id: EntityId) => idMap.get(id) ?? id),\n\t\t\t});\n\t\t}\n\n\t\tconst handleSet = world.getComponent(newId, HandleSet);\n\t\tif (handleSet) {\n\t\t\tworld.setComponent(newId, HandleSet, {\n\t\t\t\tids: handleSet.ids.map((id: EntityId) => idMap.get(id) ?? id),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Serializes a subset of entities (e.g., for copy/paste).\n * Recursively includes children of the specified entities.\n */\nexport function serializeEntities(\n\tworld: World,\n\tentityIds: EntityId[],\n\tcomponentTypes: ComponentType[],\n\ttagTypes: TagType[],\n): SerializedEntity[] {\n\tconst result: SerializedEntity[] = [];\n\tconst visited = new Set<EntityId>();\n\n\tfunction visit(entityId: EntityId) {\n\t\tif (visited.has(entityId)) return;\n\t\tvisited.add(entityId);\n\n\t\tconst components: Record<string, unknown> = {};\n\t\tconst tags: string[] = [];\n\n\t\tfor (const type of componentTypes) {\n\t\t\tconst data = world.getComponent(entityId, type);\n\t\t\tif (data !== undefined) {\n\t\t\t\tcomponents[type.name] = structuredClone(data);\n\t\t\t}\n\t\t}\n\n\t\tfor (const type of tagTypes) {\n\t\t\tif (world.hasTag(entityId, type)) {\n\t\t\t\tif (type.name !== 'Active' && type.name !== 'Visible') {\n\t\t\t\t\ttags.push(type.name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tresult.push({ id: entityId, components, tags });\n\n\t\t// Recurse into children. components.Children is typed as unknown via\n\t\t// the Record<string, unknown> shape, so narrow through a cast.\n\t\tconst children = components.Children as { ids?: EntityId[] } | undefined;\n\t\tif (children?.ids) {\n\t\t\tfor (const childId of children.ids) {\n\t\t\t\tvisit(childId);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const id of entityIds) {\n\t\tvisit(id);\n\t}\n\n\treturn result;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"advanced.cjs","names":["Parent","Children","HandleSet"],"sources":["../src/serialization.ts"],"sourcesContent":["import type { ComponentType, EntityId, TagType, World } from '@jamesyong42/reactive-ecs';\nimport { Children, HandleSet, Parent } from './components.js';\nimport type { NavigationFrame } from './resources.js';\n\n// === Serialization Types ===\n\n/** JSON-serializable snapshot of the canvas state, including all entities and camera. */\nexport interface CanvasDocument {\n\tversion: number;\n\tentities: SerializedEntity[];\n\tresources: {\n\t\tcamera: { x: number; y: number; zoom: number };\n\t\tnavigationStack: NavigationFrame[];\n\t};\n}\n\n/** A single serialized entity with its components and tags. */\nexport interface SerializedEntity {\n\tid: EntityId;\n\tcomponents: Record<string, unknown>;\n\ttags: string[];\n}\n\n// === Serialize/Deserialize ===\n\n/**\n * Serializes all entities, components, and tags to a JSON-compatible document.\n * Requires registries of known component and tag types for enumeration.\n */\nexport function serializeWorld(\n\tworld: World,\n\tcomponentTypes: ComponentType[],\n\ttagTypes: TagType[],\n\tcamera: { x: number; y: number; zoom: number },\n\tnavigationFrames: NavigationFrame[],\n): CanvasDocument {\n\tconst entities: SerializedEntity[] = [];\n\n\t// Get all entity IDs (use a broad query)\n\tconst allEntities = world.query();\n\n\tfor (const entityId of allEntities) {\n\t\tconst components: Record<string, unknown> = {};\n\t\tconst tags: string[] = [];\n\n\t\tfor (const type of componentTypes) {\n\t\t\tconst data = world.getComponent(entityId, type);\n\t\t\tif (data !== undefined) {\n\t\t\t\tcomponents[type.name] = structuredClone(data);\n\t\t\t}\n\t\t}\n\n\t\tfor (const type of tagTypes) {\n\t\t\tif (world.hasTag(entityId, type)) {\n\t\t\t\t// Skip runtime-only tags (Active, Visible — they're recomputed)\n\t\t\t\tif (type.name !== 'Active' && type.name !== 'Visible') {\n\t\t\t\t\ttags.push(type.name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(components).length > 0 || tags.length > 0) {\n\t\t\tentities.push({ id: entityId, components, tags });\n\t\t}\n\t}\n\n\treturn {\n\t\tversion: 1,\n\t\tentities,\n\t\tresources: {\n\t\t\tcamera: { ...camera },\n\t\t\tnavigationStack: structuredClone(navigationFrames),\n\t\t},\n\t};\n}\n\n/**\n * Restores entities from a serialized document into the world.\n * Clears existing state first and remaps entity IDs automatically.\n */\nexport function deserializeWorld(\n\tworld: World,\n\tdoc: CanvasDocument,\n\tcomponentTypes: ComponentType[],\n\ttagTypes: TagType[],\n): void {\n\tif (doc.version !== 1) {\n\t\tthrow new Error(`Unsupported canvas document version: ${doc.version}. Expected version 1.`);\n\t}\n\n\t// Build lookup maps\n\tconst compByName = new Map<string, ComponentType>();\n\tfor (const t of componentTypes) compByName.set(t.name, t);\n\n\tconst tagByName = new Map<string, TagType>();\n\tfor (const t of tagTypes) tagByName.set(t.name, t);\n\n\t// Destroy all existing entities\n\tfor (const entityId of world.query()) {\n\t\tworld.destroyEntity(entityId);\n\t}\n\n\t// First pass: create entities and build old-to-new ID mapping\n\tconst idMap = new Map<EntityId, EntityId>();\n\n\tfor (const entry of doc.entities) {\n\t\tconst newId = world.createEntity();\n\t\tidMap.set(entry.id as EntityId, newId);\n\n\t\tfor (const [compName, data] of Object.entries(entry.components)) {\n\t\t\tconst type = compByName.get(compName);\n\t\t\tif (type) {\n\t\t\t\tworld.addComponent(newId, type, data);\n\t\t\t}\n\t\t}\n\n\t\tfor (const tagName of entry.tags) {\n\t\t\tconst type = tagByName.get(tagName);\n\t\t\tif (type) {\n\t\t\t\tworld.addTag(newId, type);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Second pass: remap cross-reference components (Parent, Children, HandleSet)\n\tfor (const [_oldId, newId] of idMap) {\n\t\tconst parent = world.getComponent(newId, Parent);\n\t\tif (parent && idMap.has(parent.id)) {\n\t\t\tconst mappedId = idMap.get(parent.id);\n\t\t\tif (mappedId !== undefined) {\n\t\t\t\tworld.setComponent(newId, Parent, { id: mappedId });\n\t\t\t}\n\t\t}\n\n\t\tconst children = world.getComponent(newId, Children);\n\t\tif (children) {\n\t\t\tworld.setComponent(newId, Children, {\n\t\t\t\tids: children.ids.map((id: EntityId) => idMap.get(id) ?? id),\n\t\t\t});\n\t\t}\n\n\t\tconst handleSet = world.getComponent(newId, HandleSet);\n\t\tif (handleSet) {\n\t\t\tworld.setComponent(newId, HandleSet, {\n\t\t\t\tids: handleSet.ids.map((id: EntityId) => idMap.get(id) ?? id),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Serializes a subset of entities (e.g., for copy/paste).\n * Recursively includes children of the specified entities.\n */\nexport function serializeEntities(\n\tworld: World,\n\tentityIds: EntityId[],\n\tcomponentTypes: ComponentType[],\n\ttagTypes: TagType[],\n): SerializedEntity[] {\n\tconst result: SerializedEntity[] = [];\n\tconst visited = new Set<EntityId>();\n\n\tfunction visit(entityId: EntityId) {\n\t\tif (visited.has(entityId)) return;\n\t\tvisited.add(entityId);\n\n\t\tconst components: Record<string, unknown> = {};\n\t\tconst tags: string[] = [];\n\n\t\tfor (const type of componentTypes) {\n\t\t\tconst data = world.getComponent(entityId, type);\n\t\t\tif (data !== undefined) {\n\t\t\t\tcomponents[type.name] = structuredClone(data);\n\t\t\t}\n\t\t}\n\n\t\tfor (const type of tagTypes) {\n\t\t\tif (world.hasTag(entityId, type)) {\n\t\t\t\tif (type.name !== 'Active' && type.name !== 'Visible') {\n\t\t\t\t\ttags.push(type.name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tresult.push({ id: entityId, components, tags });\n\n\t\t// Recurse into children. components.Children is typed as unknown via\n\t\t// the Record<string, unknown> shape, so narrow through a cast.\n\t\tconst children = components.Children as { ids?: EntityId[] } | undefined;\n\t\tif (children?.ids) {\n\t\t\tfor (const childId of children.ids) {\n\t\t\t\tvisit(childId);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const id of entityIds) {\n\t\tvisit(id);\n\t}\n\n\treturn result;\n}\n"],"mappings":";;;;;;;;AA6BA,SAAgB,eACf,OACA,gBACA,UACA,QACA,kBACiB;CACjB,MAAM,WAA+B,EAAE;CAGvC,MAAM,cAAc,MAAM,OAAO;AAEjC,MAAK,MAAM,YAAY,aAAa;EACnC,MAAM,aAAsC,EAAE;EAC9C,MAAM,OAAiB,EAAE;AAEzB,OAAK,MAAM,QAAQ,gBAAgB;GAClC,MAAM,OAAO,MAAM,aAAa,UAAU,KAAK;AAC/C,OAAI,SAAS,KAAA,EACZ,YAAW,KAAK,QAAQ,gBAAgB,KAAK;;AAI/C,OAAK,MAAM,QAAQ,SAClB,KAAI,MAAM,OAAO,UAAU,KAAK;OAE3B,KAAK,SAAS,YAAY,KAAK,SAAS,UAC3C,MAAK,KAAK,KAAK,KAAK;;AAKvB,MAAI,OAAO,KAAK,WAAW,CAAC,SAAS,KAAK,KAAK,SAAS,EACvD,UAAS,KAAK;GAAE,IAAI;GAAU;GAAY;GAAM,CAAC;;AAInD,QAAO;EACN,SAAS;EACT;EACA,WAAW;GACV,QAAQ,EAAE,GAAG,QAAQ;GACrB,iBAAiB,gBAAgB,iBAAiB;GAClD;EACD;;;;;;AAOF,SAAgB,iBACf,OACA,KACA,gBACA,UACO;AACP,KAAI,IAAI,YAAY,EACnB,OAAM,IAAI,MAAM,wCAAwC,IAAI,QAAQ,uBAAuB;CAI5F,MAAM,6BAAa,IAAI,KAA4B;AACnD,MAAK,MAAM,KAAK,eAAgB,YAAW,IAAI,EAAE,MAAM,EAAE;CAEzD,MAAM,4BAAY,IAAI,KAAsB;AAC5C,MAAK,MAAM,KAAK,SAAU,WAAU,IAAI,EAAE,MAAM,EAAE;AAGlD,MAAK,MA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AI,QAAQ,IAAI,SAAS,CAAE;AAC3B,UAAQ,IAAI,SAAS;EAErB,MAAM,aAAsC,EAAE;EAC9C,MAAM,OAAiB,EAAE;AAEzB,OAAK,MAAM,QAAQ,gBAAgB;GAClC,MAAM,OAAO,MAAM,aAAa,UAAU,KAAK;AAC/C,OAAI,SAAS,KAAA,EACZ,YAAW,KAAK,QAAQ,gBAAgB,KAAK;;AAI/C,OAAK,MAAM,QAAQ,SAClB,KAAI,MAAM,OAAO,UAAU,KAAK;OAC3B,KAAK,SAAS,YAAY,KAAK,SAAS,UAC3C,MAAK,KAAK,KAAK,KAAK;;AAKvB,SAAO,KAAK;GAAE,IAAI;GAAU;GAAY;GAAM,CAAC;EAI/C,MAAM,WAAW,WAAW;AAC5B,MAAI,UAAU,IACb,MAAK,MAAM,WAAW,SAAS,IAC9B,OAAM,QAAQ;;AAKjB,MAAK,MAAM,MAAM,UAChB,OAAM,GAAG;AAGV,QAAO"}
|
package/dist/advanced.d.cts
CHANGED
|
@@ -1,71 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import 'three';
|
|
1
|
+
import { A as NavigationFrame, C as computeSnapGuides, G as FrameTimeStats, J as R3FSample, K as Profiler, L as R3FWidgetProps, Q as WebGLStats, W as EcsStats, X as TickSample, Y as R3FStats, Z as WebGLPass, l as SpatialIndex, n as LayoutEngine, o as SpatialIndexResource, q as ProfilerStats } from "./engine-CCjuFMC-.cjs";
|
|
2
|
+
import { c as ContainerRefProvider, i as SelectionRenderer, l as EngineProvider, s as GridRenderer, u as ResolvedWidget } from "./SelectionRenderer-CR2PBQwx.cjs";
|
|
3
|
+
import { ComponentType, EntityId, TagType, World } from "@jamesyong42/reactive-ecs";
|
|
4
|
+
import * as _$react from "react";
|
|
5
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
6
|
|
|
7
|
+
//#region src/react/SelectionOverlaySlot.d.ts
|
|
8
8
|
interface SelectionOverlaySlotProps {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
entityId: EntityId;
|
|
10
|
+
slotRef: (entityId: EntityId, el: HTMLDivElement | null) => void;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* DOM overlay for WebGL widgets — provides selection frame and pointer
|
|
14
14
|
* interaction (select, drag, resize) without rendering widget content.
|
|
15
15
|
*/
|
|
16
|
-
declare const SelectionOverlaySlot: react.MemoExoticComponent<({
|
|
17
|
-
|
|
16
|
+
declare const SelectionOverlaySlot: _$react.MemoExoticComponent<({
|
|
17
|
+
entityId,
|
|
18
|
+
slotRef
|
|
19
|
+
}: SelectionOverlaySlotProps) => _$react_jsx_runtime0.JSX.Element>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/react/WidgetSlot.d.ts
|
|
18
22
|
interface WidgetSlotProps {
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
entityId: EntityId;
|
|
24
|
+
slotRef: (entityId: EntityId, el: HTMLDivElement | null) => void;
|
|
21
25
|
}
|
|
22
|
-
declare const WidgetSlot: react.MemoExoticComponent<({
|
|
23
|
-
|
|
26
|
+
declare const WidgetSlot: _$react.MemoExoticComponent<({
|
|
27
|
+
entityId,
|
|
28
|
+
slotRef
|
|
29
|
+
}: WidgetSlotProps) => _$react_jsx_runtime0.JSX.Element>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/react/webgl/WebGLWidgetLayer.d.ts
|
|
24
32
|
interface WebGLWidgetLayerProps {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
engine: LayoutEngine;
|
|
34
|
+
entities: EntityId[];
|
|
35
|
+
resolve: (entityId: EntityId) => ResolvedWidget | null;
|
|
28
36
|
}
|
|
29
|
-
declare function WebGLWidgetLayer({
|
|
30
|
-
|
|
37
|
+
declare function WebGLWidgetLayer({
|
|
38
|
+
engine,
|
|
39
|
+
entities,
|
|
40
|
+
resolve
|
|
41
|
+
}: WebGLWidgetLayerProps): _$react_jsx_runtime0.JSX.Element;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/react/webgl/WebGLWidgetSlot.d.ts
|
|
31
44
|
interface WebGLWidgetSlotProps {
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
entityId: EntityId;
|
|
46
|
+
component: React.ComponentType<R3FWidgetProps>;
|
|
34
47
|
}
|
|
35
48
|
/**
|
|
36
49
|
* Positions a Three.js Group at the entity's world-space center.
|
|
37
50
|
* The widget component renders in local space: origin at center,
|
|
38
51
|
* X right, Y up, dimensions = (width, height) in world units.
|
|
39
52
|
*/
|
|
40
|
-
declare function WebGLWidgetSlot({
|
|
41
|
-
|
|
53
|
+
declare function WebGLWidgetSlot({
|
|
54
|
+
entityId,
|
|
55
|
+
component: WidgetComponent
|
|
56
|
+
}: WebGLWidgetSlotProps): _$react_jsx_runtime0.JSX.Element | null;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/serialization.d.ts
|
|
42
59
|
/** JSON-serializable snapshot of the canvas state, including all entities and camera. */
|
|
43
60
|
interface CanvasDocument {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
navigationStack: NavigationFrame[];
|
|
61
|
+
version: number;
|
|
62
|
+
entities: SerializedEntity[];
|
|
63
|
+
resources: {
|
|
64
|
+
camera: {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
zoom: number;
|
|
53
68
|
};
|
|
69
|
+
navigationStack: NavigationFrame[];
|
|
70
|
+
};
|
|
54
71
|
}
|
|
55
72
|
/** A single serialized entity with its components and tags. */
|
|
56
73
|
interface SerializedEntity {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
id: EntityId;
|
|
75
|
+
components: Record<string, unknown>;
|
|
76
|
+
tags: string[];
|
|
60
77
|
}
|
|
61
78
|
/**
|
|
62
79
|
* Serializes all entities, components, and tags to a JSON-compatible document.
|
|
63
80
|
* Requires registries of known component and tag types for enumeration.
|
|
64
81
|
*/
|
|
65
82
|
declare function serializeWorld(world: World, componentTypes: ComponentType[], tagTypes: TagType[], camera: {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
zoom: number;
|
|
69
86
|
}, navigationFrames: NavigationFrame[]): CanvasDocument;
|
|
70
87
|
/**
|
|
71
88
|
* Restores entities from a serialized document into the world.
|
|
@@ -77,5 +94,6 @@ declare function deserializeWorld(world: World, doc: CanvasDocument, componentTy
|
|
|
77
94
|
* Recursively includes children of the specified entities.
|
|
78
95
|
*/
|
|
79
96
|
declare function serializeEntities(world: World, entityIds: EntityId[], componentTypes: ComponentType[], tagTypes: TagType[]): SerializedEntity[];
|
|
80
|
-
|
|
81
|
-
export { type CanvasDocument, SelectionOverlaySlot, type SerializedEntity, WebGLWidgetLayer, WebGLWidgetSlot, WidgetSlot, deserializeWorld, serializeEntities, serializeWorld };
|
|
97
|
+
//#endregion
|
|
98
|
+
export { type CanvasDocument, ContainerRefProvider, type EcsStats, EngineProvider, type FrameTimeStats, GridRenderer, Profiler, type ProfilerStats, type R3FSample, type R3FStats, SelectionOverlaySlot, SelectionRenderer, type SerializedEntity, SpatialIndex, SpatialIndexResource, type TickSample, type WebGLPass, type WebGLStats, WebGLWidgetLayer, WebGLWidgetSlot, WidgetSlot, computeSnapGuides, deserializeWorld, serializeEntities, serializeWorld };
|
|
99
|
+
//# sourceMappingURL=advanced.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.cts","names":[],"sources":["../src/react/SelectionOverlaySlot.tsx","../src/react/WidgetSlot.tsx","../src/react/webgl/WebGLWidgetLayer.tsx","../src/react/webgl/WebGLWidgetSlot.tsx","../src/serialization.ts"],"mappings":";;;;;;;UAMU,yBAAA;EACT,QAAA,EAAU,QAAA;EACV,O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AW,IAAA;AAAA,GAChC,gBAAA,EAAkB,eAAA,KAChB,cAAA;;;;;iBA6Ca,gBAAA,CACf,KAAA,EAAO,KAAA,EACP,GAAA,EAAK,cAAA,EACL,cAAA,EAAgB,aAAA,IAChB,QAAA,EAAU,OAAA;;;;;iBAsEK,iBAAA,CACf,KAAA,EAAO,KAAA,EACP,SAAA,EAAW,QAAA,IACX,cAAA,EAAgB,aAAA,IAChB,QAAA,EAAU,OAAA,KACR,gBAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { A as NavigationFrame, C as computeSnapGuides, G as FrameTimeStats, J as R3FSample, K as Profiler, L as R3FWidgetProps, Q as WebGLStats, W as EcsStats, X as TickSample, Y as R3FStats, Z as WebGLPass, l as SpatialIndex, n as LayoutEngine, o as SpatialIndexResource, q as ProfilerStats } from "./engine-BfbvWXSk.mjs";
|
|
2
|
+
import { c as ContainerRefProvider, i as SelectionRenderer, l as EngineProvider, s as GridRenderer, u as ResolvedWidget } from "./SelectionRenderer-DlsBstAq.mjs";
|
|
3
|
+
import { ComponentType, EntityId, TagType, World } from "@jamesyong42/reactive-ecs";
|
|
4
|
+
import * as _$react from "react";
|
|
5
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/react/SelectionOverlaySlot.d.ts
|
|
8
|
+
interface SelectionOverlaySlotProps {
|
|
9
|
+
entityId: EntityId;
|
|
10
|
+
slotRef: (entityId: EntityId, el: HTMLDivElement | null) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* DOM overlay for WebGL widgets — provides selection frame and pointer
|
|
14
|
+
* interaction (select, drag, resize) without rendering widget content.
|
|
15
|
+
*/
|
|
16
|
+
declare const SelectionOverlaySlot: _$react.MemoExoticComponent<({
|
|
17
|
+
entityId,
|
|
18
|
+
slotRef
|
|
19
|
+
}: SelectionOverlaySlotProps) => _$react_jsx_runtime0.JSX.Element>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/react/WidgetSlot.d.ts
|
|
22
|
+
interface WidgetSlotProps {
|
|
23
|
+
entityId: EntityId;
|
|
24
|
+
slotRef: (entityId: EntityId, el: HTMLDivElement | null) => void;
|
|
25
|
+
}
|
|
26
|
+
declare const WidgetSlot: _$react.MemoExoticComponent<({
|
|
27
|
+
entityId,
|
|
28
|
+
slotRef
|
|
29
|
+
}: WidgetSlotProps) => _$react_jsx_runtime0.JSX.Element>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/react/webgl/WebGLWidgetLayer.d.ts
|
|
32
|
+
interface WebGLWidgetLayerProps {
|
|
33
|
+
engine: LayoutEngine;
|
|
34
|
+
entities: EntityId[];
|
|
35
|
+
resolve: (entityId: EntityId) => ResolvedWidget | null;
|
|
36
|
+
}
|
|
37
|
+
declare function WebGLWidgetLayer({
|
|
38
|
+
engine,
|
|
39
|
+
entities,
|
|
40
|
+
resolve
|
|
41
|
+
}: WebGLWidgetLayerProps): _$react_jsx_runtime0.JSX.Element;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/react/webgl/WebGLWidgetSlot.d.ts
|
|
44
|
+
interface WebGLWidgetSlotProps {
|
|
45
|
+
entityId: EntityId;
|
|
46
|
+
component: React.ComponentType<R3FWidgetProps>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Positions a Three.js Group at the entity's world-space center.
|
|
50
|
+
* The widget component renders in local space: origin at center,
|
|
51
|
+
* X right, Y up, dimensions = (width, height) in world units.
|
|
52
|
+
*/
|
|
53
|
+
declare function WebGLWidgetSlot({
|
|
54
|
+
entityId,
|
|
55
|
+
component: WidgetComponent
|
|
56
|
+
}: WebGLWidgetSlotProps): _$react_jsx_runtime0.JSX.Element | null;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/serialization.d.ts
|
|
59
|
+
/** JSON-serializable snapshot of the canvas state, including all entities and camera. */
|
|
60
|
+
interface CanvasDocument {
|
|
61
|
+
version: number;
|
|
62
|
+
entities: SerializedEntity[];
|
|
63
|
+
resources: {
|
|
64
|
+
camera: {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
zoom: number;
|
|
68
|
+
};
|
|
69
|
+
navigationStack: NavigationFrame[];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** A single serialized entity with its components and tags. */
|
|
73
|
+
interface SerializedEntity {
|
|
74
|
+
id: EntityId;
|
|
75
|
+
components: Record<string, unknown>;
|
|
76
|
+
tags: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Serializes all entities, components, and tags to a JSON-compatible document.
|
|
80
|
+
* Requires registries of known component and tag types for enumeration.
|
|
81
|
+
*/
|
|
82
|
+
declare function serializeWorld(world: World, componentTypes: ComponentType[], tagTypes: TagType[], camera: {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
zoom: number;
|
|
86
|
+
}, navigationFrames: NavigationFrame[]): CanvasDocument;
|
|
87
|
+
/**
|
|
88
|
+
* Restores entities from a serialized document into the world.
|
|
89
|
+
* Clears existing state first and remaps entity IDs automatically.
|
|
90
|
+
*/
|
|
91
|
+
declare function deserializeWorld(world: World, doc: CanvasDocument, componentTypes: ComponentType[], tagTypes: TagType[]): void;
|
|
92
|
+
/**
|
|
93
|
+
* Serializes a subset of entities (e.g., for copy/paste).
|
|
94
|
+
* Recursively includes children of the specified entities.
|
|
95
|
+
*/
|
|
96
|
+
declare function serializeEntities(world: World, entityIds: EntityId[], componentTypes: ComponentType[], tagTypes: TagType[]): SerializedEntity[];
|
|
97
|
+
//#endregion
|
|
98
|
+
export { type CanvasDocument, ContainerRefProvider, type EcsStats, EngineProvider, type FrameTimeStats, GridRenderer, Profiler, type ProfilerStats, type R3FSample, type R3FStats, SelectionOverlaySlot, SelectionRenderer, type SerializedEntity, SpatialIndex, SpatialIndexResource, type TickSample, type WebGLPass, type WebGLStats, WebGLWidgetLayer, WebGLWidgetSlot, WidgetSlot, computeSnapGuides, deserializeWorld, serializeEntities, serializeWorld };
|
|
99
|
+
//# sourceMappingURL=advanced.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.mts","names":[],"sources":["../src/react/SelectionOverlaySlot.tsx","../src/react/WidgetSlot.tsx","../src/react/webgl/WebGLWidgetLayer.tsx","../src/react/webgl/WebGLWidgetSlot.tsx","../src/serialization.ts"],"mappings":";;;;;;;UAMU,yBAAA;EACT,QAAA,EAAU,QAAA;EACV,OAAA,GAAU,QAAA,EAAU,QAAA,EAAU,EAAA,EAAI,cAAA;AAAA;;;AARuB;;cAmB7C,oBAAA,EAGe,OAAA,CAHK,mBAAA;EAAA,QAAA;EAAA;AAAA,GAG9B,yBAAA,KAAyB,oBAAA,CAAA,GAAA,CAAA,OAAA;;;UCflB,eAAA;EACT,QAAA,EAAU,QAAA;EACV,OAAA,GAAU,QAAA,EAAU,QAAA,EAAU,EAAA,EAAI,cAAA;AAAA;AAAA,cAOtB,UAAA,EAA4E,OAAA,CAAlE,mBAAA;EAAA,QAAA;EAAA;AAAA,GAAmD,eAAA,KAAe,oBAAA,CAAA,GAAA,CAAA,OAAA;;;UCgG/E,qBAAA;EACT,MAAA,EAAQ,YAAA;EACR,QAAA,EAAU,QAAA;EACV,OAAA,GAAU,QAAA,EAAU,QAAA,KAAa,cAAA;AAAA;AAAA,iBAGlB,gBAAA,CAAA;EAAmB,MAAA;EAAQ,QAAA;EAAU;AAAA,GAAW,qBAAA,GAAqB,oBAAA,CAAA,GAAA,CAAA,OAAA;;;UC7G3E,oBAAA;EACT,QAAA,EAAU,QAAA;EACV,SAAA,EAAW,KAAA,CAAM,aAAA,CAAc,cAAA;AAAA;;AHX0B;;;;iBGmB1C,eAAA,CAAA;EAAkB,QAAA;EAAU,SAAA,EAAW;AAAA,GAAmB,oBAAA,GAAoB,oBAAA,CAAA,GAAA,CAAA,OAAA;;;;UCZ7E,cAAA;EAChB,OAAA;EACA,QAAA,EAAU,gBAAA;EACV,SA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