@relu-interactives/spatial-ecs 0.2.20 → 0.2.22

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 (51) hide show
  1. package/dist/{System-BjwOBx81.d.cts → System-CYWZ_Zx5.d.cts} +9 -4
  2. package/dist/{System-BjwOBx81.d.ts → System-CYWZ_Zx5.d.ts} +9 -4
  3. package/dist/{Video-B8yVI1tF.d.cts → Video-C1IOat7L.d.ts} +38 -9
  4. package/dist/{Video-B9z5AtIf.d.ts → Video-ppAXaKt0.d.cts} +38 -9
  5. package/dist/{chunk-HUHN6IFD.js → chunk-52CHDPRQ.js} +118 -92
  6. package/dist/chunk-52CHDPRQ.js.map +1 -0
  7. package/dist/{chunk-67MFQDHX.js → chunk-GZ2NKSMV.js} +609 -90
  8. package/dist/chunk-GZ2NKSMV.js.map +1 -0
  9. package/dist/{chunk-Z6OMYEXU.js → chunk-JHCPRVBC.js} +34 -5
  10. package/dist/chunk-JHCPRVBC.js.map +1 -0
  11. package/dist/{chunk-DY4ETMP2.js → chunk-WKGCC7YL.js} +3 -3
  12. package/dist/{chunk-DY4ETMP2.js.map → chunk-WKGCC7YL.js.map} +1 -1
  13. package/dist/components/index.cjs +31 -2
  14. package/dist/components/index.cjs.map +1 -1
  15. package/dist/components/index.d.cts +3 -3
  16. package/dist/components/index.d.ts +3 -3
  17. package/dist/components/index.js +1 -1
  18. package/dist/docs/guide/authoring-a-behaviour.md +3 -40
  19. package/dist/docs/guide/authoring-a-script-object.md +102 -0
  20. package/dist/docs/guide/behaviour-lifecycle.md +4 -4
  21. package/dist/docs/guide/prefabs.md +24 -5
  22. package/dist/docs/guide/spawning/script-object.md +36 -0
  23. package/dist/docs/guide/systems/_sidebar.json +4 -0
  24. package/dist/docs/guide/systems/script-behaviour-system.md +1 -17
  25. package/dist/docs/guide/systems/script-object-system.md +44 -0
  26. package/dist/factories/index.cjs +164 -117
  27. package/dist/factories/index.cjs.map +1 -1
  28. package/dist/factories/index.d.cts +5 -3
  29. package/dist/factories/index.d.ts +5 -3
  30. package/dist/factories/index.js +3 -3
  31. package/dist/{index-LHLKpJhZ.d.cts → index-Cu2Pt7wN.d.cts} +33 -14
  32. package/dist/{index-BBI2YdCu.d.ts → index-DdiWu1b6.d.ts} +33 -14
  33. package/dist/index.cjs +1132 -302
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +219 -32
  36. package/dist/index.d.ts +219 -32
  37. package/dist/index.js +254 -11
  38. package/dist/index.js.map +1 -1
  39. package/dist/systems/index.cjs +429 -43
  40. package/dist/systems/index.cjs.map +1 -1
  41. package/dist/systems/index.d.cts +44 -3
  42. package/dist/systems/index.d.ts +44 -3
  43. package/dist/systems/index.js +3 -3
  44. package/dist/types.d.cts +1 -1
  45. package/dist/types.d.ts +1 -1
  46. package/dist/worldSnapshotUtils.d.cts +1 -1
  47. package/dist/worldSnapshotUtils.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/dist/chunk-67MFQDHX.js.map +0 -1
  50. package/dist/chunk-HUHN6IFD.js.map +0 -1
  51. package/dist/chunk-Z6OMYEXU.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, collectEntitySubtree } from './chunk-67MFQDHX.js';
2
- export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, HYDRATABLE_ENTITY_KINDS, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectVisibilitySystem, PREFAB_FILE_VERSION, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem, buildComponentValueMaps, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, computeInstanceOverrides, decanonicalizeComponentValue, despawnPrefab, encodeOverride, findSnapshotRootEntityIds, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, mergeComponentValue, parseOverride, parsePrefabAsset, restoreComponentState, restorePostCreateComponents, setPrefabAssetUrlResolver, spawnPrefab } from './chunk-67MFQDHX.js';
3
- import { registerDefaultFactories } from './chunk-HUHN6IFD.js';
4
- export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-HUHN6IFD.js';
5
- import { ObjectManagementSystem } from './chunk-DY4ETMP2.js';
6
- export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, clearModelCache, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath } from './chunk-DY4ETMP2.js';
7
- import { SelectionTransformState, Object3DRef, Name, EntityType, ParentId, Environment, Postprocessing, ScriptComponent } from './chunk-Z6OMYEXU.js';
8
- export { AnimationStateMachine, AnimationStateManager, components_exports as CoreComponents } from './chunk-Z6OMYEXU.js';
1
+ import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, buildNodeKeyMapsFromSnapshot, indexSnapshotByEntity, findTopLevelNestedRegions, collectSnapshotSubtreeIds, groupOverridePaths, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, canonicalizeComponentValue, mergeComponentValue, decanonicalizeComponentValue, computeInstanceOverrides, collectEntitySubtree, ADDED_NODE_MARKER_COMPONENT } from './chunk-GZ2NKSMV.js';
2
+ export { ADDED_NODE_MARKER_COMPONENT, AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, HYDRATABLE_ENTITY_KINDS, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, NODE_KEY_SEPARATOR, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectVisibilitySystem, PREFAB_FILE_VERSION, PREFAB_FILE_VERSION_NESTED, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObject, ScriptObjectSystem, TransformSyncSystem, VideoSystem, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, despawnPrefab, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, restoreComponentState, restorePostCreateComponents, setPrefabAssetUrlResolver, spawnPrefab } from './chunk-GZ2NKSMV.js';
3
+ import { registerDefaultFactories } from './chunk-52CHDPRQ.js';
4
+ export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-52CHDPRQ.js';
5
+ import { ObjectManagementSystem } from './chunk-WKGCC7YL.js';
6
+ export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, clearModelCache, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath } from './chunk-WKGCC7YL.js';
7
+ import { SelectionTransformState, Object3DRef, Name, EntityType, ParentId, Environment, Postprocessing, ScriptComponent } from './chunk-JHCPRVBC.js';
8
+ export { AnimationStateMachine, AnimationStateManager, components_exports as CoreComponents } from './chunk-JHCPRVBC.js';
9
9
  import './chunk-QHILSPT4.js';
10
10
  import { normalizeDebugValue, DEBUG_CHANGE_IGNORED_SYSTEMS, cloneHistoryValue } from './chunk-ZXGHKX7N.js';
11
11
  import { __name } from './chunk-OY7ZODZP.js';
@@ -1037,6 +1037,11 @@ function remapSnapshotEntityIds(snapshot, idMap, options) {
1037
1037
  };
1038
1038
  });
1039
1039
  }
1040
+ } else if (block.component === "ScriptObjectComponent" && record) {
1041
+ const data = asRecord(record.data);
1042
+ if (data) {
1043
+ record.data = remapScriptData(data, idMap, nullExternal, warn);
1044
+ }
1040
1045
  } else if (block.component === "InstancedMeshComponent" && record) {
1041
1046
  if (Array.isArray(record.instanceEntityIds)) {
1042
1047
  const remapped = [];
@@ -1078,12 +1083,237 @@ function remapSnapshotEntityIds(snapshot, idMap, options) {
1078
1083
  }
1079
1084
  __name(remapSnapshotEntityIds, "remapSnapshotEntityIds");
1080
1085
 
1086
+ // core/prefab/applyPrefabToSnapshot.ts
1087
+ var asRecord2 = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null, "asRecord");
1088
+ var clone = /* @__PURE__ */ __name((value) => structuredClone(value), "clone");
1089
+ var stableStringify = /* @__PURE__ */ __name((value) => {
1090
+ try {
1091
+ return JSON.stringify(value);
1092
+ } catch {
1093
+ return "";
1094
+ }
1095
+ }, "stableStringify");
1096
+ function getBlock(snapshot, component) {
1097
+ let block = snapshot.components.find((b) => b.component === component);
1098
+ if (!block) {
1099
+ block = { component, entries: [] };
1100
+ snapshot.components.push(block);
1101
+ }
1102
+ return block;
1103
+ }
1104
+ __name(getBlock, "getBlock");
1105
+ function setEntry(snapshot, component, entityId, value) {
1106
+ const block = getBlock(snapshot, component);
1107
+ const entry = block.entries.find((e) => e.entityId === entityId);
1108
+ if (entry) {
1109
+ entry.value = value;
1110
+ } else {
1111
+ block.entries.push({ entityId, value });
1112
+ block.entries.sort((a, b) => a.entityId - b.entityId);
1113
+ }
1114
+ }
1115
+ __name(setEntry, "setEntry");
1116
+ function deleteEntities(snapshot, entityIds) {
1117
+ snapshot.entities = snapshot.entities.filter((id) => !entityIds.has(id));
1118
+ snapshot.components = snapshot.components.map((block) => ({
1119
+ component: block.component,
1120
+ entries: block.entries.filter((e) => !entityIds.has(e.entityId))
1121
+ })).filter((block) => block.entries.length > 0);
1122
+ }
1123
+ __name(deleteEntities, "deleteEntities");
1124
+ function extractRegionDoc(hostSnapshot, regionIds) {
1125
+ const idSet = new Set(regionIds);
1126
+ return {
1127
+ entities: regionIds.slice(),
1128
+ components: hostSnapshot.components.map((block) => ({
1129
+ component: block.component,
1130
+ entries: block.entries.filter((e) => idSet.has(e.entityId))
1131
+ })).filter((block) => block.entries.length > 0)
1132
+ };
1133
+ }
1134
+ __name(extractRegionDoc, "extractRegionDoc");
1135
+ function applyPrefabToSnapshotInstances(hostSnapshot, nestedUrl, newNestedSnapshot) {
1136
+ const host = clone(hostSnapshot);
1137
+ const newMaps = buildNodeKeyMapsFromSnapshot(newNestedSnapshot);
1138
+ const newByEntity = indexSnapshotByEntity(newNestedSnapshot);
1139
+ if (!newMaps.rootKey) {
1140
+ return { snapshot: host, changed: false };
1141
+ }
1142
+ let changed = false;
1143
+ const regions = findTopLevelNestedRegions(host).filter(
1144
+ (region) => region.url === nestedUrl
1145
+ );
1146
+ for (const region of regions) {
1147
+ const before = stableStringify(
1148
+ extractRegionDoc(host, collectSnapshotSubtreeIds(host, region.rootEntityId))
1149
+ );
1150
+ patchRegion(host, region.rootEntityId, region.overrides, {
1151
+ newSnapshot: newNestedSnapshot,
1152
+ newMaps,
1153
+ newByEntity
1154
+ });
1155
+ const after = stableStringify(
1156
+ extractRegionDoc(host, collectSnapshotSubtreeIds(host, region.rootEntityId))
1157
+ );
1158
+ if (before !== after) {
1159
+ changed = true;
1160
+ }
1161
+ }
1162
+ return { snapshot: host, changed };
1163
+ }
1164
+ __name(applyPrefabToSnapshotInstances, "applyPrefabToSnapshotInstances");
1165
+ function patchRegion(host, regionRootId, storedOverrides, file) {
1166
+ const { newSnapshot, newMaps, newByEntity } = file;
1167
+ const regionIds = collectSnapshotSubtreeIds(host, regionRootId);
1168
+ const regionDoc = extractRegionDoc(host, regionIds);
1169
+ const regionMaps = buildNodeKeyMapsFromSnapshot(regionDoc, {
1170
+ scopeRootEntityId: regionRootId
1171
+ });
1172
+ const regionByEntity = indexSnapshotByEntity(regionDoc);
1173
+ const grouped = groupOverridePaths(storedOverrides);
1174
+ const overridePathsFor = /* @__PURE__ */ __name((key, component) => grouped.get(key)?.get(component), "overridePathsFor");
1175
+ const isMarkedAddition = /* @__PURE__ */ __name((key) => Boolean(grouped.get(key)?.get(ADDED_NODE_MARKER_COMPONENT)), "isMarkedAddition");
1176
+ const parentBlockNew = newSnapshot.components.find(
1177
+ (b) => b.component === "ParentId"
1178
+ );
1179
+ const keyToHostId = /* @__PURE__ */ new Map();
1180
+ for (const [hostId, key] of regionMaps.idToKey) {
1181
+ keyToHostId.set(key, hostId);
1182
+ }
1183
+ const addedFileIds = [...newMaps.keyToId.entries()].filter(([key]) => !keyToHostId.has(key)).map(([, fileId]) => fileId);
1184
+ if (addedFileIds.length > 0) {
1185
+ let nextHostId = Math.max(0, ...host.entities) + 1;
1186
+ const addedSet = new Set(addedFileIds);
1187
+ const idMap = /* @__PURE__ */ new Map();
1188
+ for (const [key, fileId] of newMaps.keyToId) {
1189
+ const hostId = keyToHostId.get(key);
1190
+ if (hostId !== void 0) {
1191
+ idMap.set(fileId, hostId);
1192
+ }
1193
+ }
1194
+ for (const fileId of addedFileIds) {
1195
+ idMap.set(fileId, nextHostId);
1196
+ nextHostId += 1;
1197
+ }
1198
+ const addedSub = {
1199
+ entities: newSnapshot.entities.filter((id) => addedSet.has(id)),
1200
+ components: newSnapshot.components.map((block) => ({
1201
+ component: block.component,
1202
+ entries: block.entries.filter((e) => addedSet.has(e.entityId))
1203
+ })).filter((block) => block.entries.length > 0)
1204
+ };
1205
+ const { snapshot: remapped } = remapSnapshotEntityIds(addedSub, idMap, {
1206
+ externalRefPolicy: "null"
1207
+ });
1208
+ host.entities = [...host.entities, ...remapped.entities];
1209
+ for (const block of remapped.components) {
1210
+ for (const entry of block.entries) {
1211
+ setEntry(host, block.component, entry.entityId, entry.value);
1212
+ }
1213
+ }
1214
+ for (const fileId of addedFileIds) {
1215
+ const hostId = idMap.get(fileId);
1216
+ const parentValue = asRecord2(
1217
+ parentBlockNew?.entries.find((e) => e.entityId === fileId)?.value
1218
+ )?.value;
1219
+ if (typeof parentValue === "number" && !addedSet.has(parentValue)) {
1220
+ const parentKey = newMaps.idToKey.get(parentValue);
1221
+ const parentHost = parentKey ? keyToHostId.get(parentKey) : void 0;
1222
+ setEntry(host, "ParentId", hostId, {
1223
+ __type: "ParentId",
1224
+ value: parentHost ?? regionRootId
1225
+ });
1226
+ }
1227
+ const key = newMaps.idToKey.get(fileId);
1228
+ if (key) {
1229
+ keyToHostId.set(key, hostId);
1230
+ }
1231
+ }
1232
+ }
1233
+ for (const [key, fileId] of newMaps.keyToId) {
1234
+ const hostId = keyToHostId.get(key);
1235
+ if (hostId === void 0) continue;
1236
+ const isRegionRoot = key === newMaps.rootKey;
1237
+ const fileComponents = newByEntity.get(fileId);
1238
+ if (!fileComponents) continue;
1239
+ const regionEntityComponents = regionByEntity.get(hostId);
1240
+ for (const [componentName, fileRaw] of fileComponents) {
1241
+ if (OVERRIDE_DIFF_EXCLUDED_COMPONENTS.has(componentName)) continue;
1242
+ if (isRegionRoot && OVERRIDE_ROOT_EXCLUDED_COMPONENTS.has(componentName))
1243
+ continue;
1244
+ const fileCanonical = canonicalizeComponentValue(
1245
+ componentName,
1246
+ fileRaw,
1247
+ newMaps.idToKey
1248
+ );
1249
+ const regionRaw = regionEntityComponents?.get(componentName);
1250
+ const regionCanonical = regionRaw === void 0 ? void 0 : canonicalizeComponentValue(
1251
+ componentName,
1252
+ regionRaw,
1253
+ regionMaps.idToKey
1254
+ );
1255
+ const merged = regionCanonical === void 0 ? fileCanonical : mergeComponentValue(
1256
+ fileCanonical,
1257
+ regionCanonical,
1258
+ overridePathsFor(key, componentName)
1259
+ );
1260
+ if (regionCanonical !== void 0 && stableStringify(merged) === stableStringify(regionCanonical)) {
1261
+ continue;
1262
+ }
1263
+ const hostValue = decanonicalizeComponentValue(merged, keyToHostId);
1264
+ setEntry(host, componentName, hostId, hostValue);
1265
+ }
1266
+ }
1267
+ const removedHostIds = /* @__PURE__ */ new Set();
1268
+ for (const [key, hostId] of keyToHostId) {
1269
+ if (newMaps.keyToId.has(key)) continue;
1270
+ if (isMarkedAddition(key)) continue;
1271
+ removedHostIds.add(hostId);
1272
+ }
1273
+ if (removedHostIds.size > 0) {
1274
+ const regionIdSet = new Set(regionIds);
1275
+ const parentBlockHost = host.components.find(
1276
+ (b) => b.component === "ParentId"
1277
+ );
1278
+ for (const entry of parentBlockHost?.entries ?? []) {
1279
+ const record = asRecord2(entry.value);
1280
+ if (!removedHostIds.has(entry.entityId) && regionIdSet.has(entry.entityId) && record && typeof record.value === "number" && removedHostIds.has(record.value)) {
1281
+ record.value = regionRootId;
1282
+ }
1283
+ }
1284
+ deleteEntities(host, removedHostIds);
1285
+ }
1286
+ const refreshedRegionIds = collectSnapshotSubtreeIds(host, regionRootId);
1287
+ const refreshedDoc = extractRegionDoc(host, refreshedRegionIds);
1288
+ const refreshedOverrides = computeInstanceOverrides(
1289
+ newSnapshot,
1290
+ refreshedDoc,
1291
+ { emitAdditionMarkers: true }
1292
+ );
1293
+ const instanceEntry = asRecord2(
1294
+ host.components.find((b) => b.component === "PrefabInstance")?.entries.find((e) => e.entityId === regionRootId)?.value
1295
+ );
1296
+ if (instanceEntry) {
1297
+ instanceEntry.overrides = refreshedOverrides;
1298
+ }
1299
+ }
1300
+ __name(patchRegion, "patchRegion");
1301
+
1302
+ // core/prefab/dependencies.ts
1303
+ function collectDirectPrefabDependencies(snapshot) {
1304
+ const urls = /* @__PURE__ */ new Set();
1305
+ for (const region of findTopLevelNestedRegions(snapshot)) {
1306
+ urls.add(region.url);
1307
+ }
1308
+ return [...urls];
1309
+ }
1310
+ __name(collectDirectPrefabDependencies, "collectDirectPrefabDependencies");
1311
+
1081
1312
  // core/prefab/serializeEntitySubtree.ts
1082
1313
  var SUBTREE_EXCLUDED_COMPONENTS = /* @__PURE__ */ new Set([
1083
1314
  "Environment",
1084
1315
  "Postprocessing",
1085
- "SelectionTransformState",
1086
- "PrefabInstance"
1316
+ "SelectionTransformState"
1087
1317
  ]);
1088
1318
  function serializeEntitySubtree(world, rootId, options) {
1089
1319
  const orderedIds = collectEntitySubtree(world, [rootId]);
@@ -1115,6 +1345,19 @@ function serializeEntitySubtree(world, rootId, options) {
1115
1345
  if (rootParentEntry && rootParentEntry.value !== null && typeof rootParentEntry.value === "object") {
1116
1346
  rootParentEntry.value.value = null;
1117
1347
  }
1348
+ const prefabInstanceBlock = snapshot.components.find(
1349
+ (block) => block.component === "PrefabInstance"
1350
+ );
1351
+ if (prefabInstanceBlock) {
1352
+ prefabInstanceBlock.entries = prefabInstanceBlock.entries.filter(
1353
+ (entry) => entry.entityId !== rootFileId
1354
+ );
1355
+ if (prefabInstanceBlock.entries.length === 0) {
1356
+ snapshot.components = snapshot.components.filter(
1357
+ (block) => block !== prefabInstanceBlock
1358
+ );
1359
+ }
1360
+ }
1118
1361
  const filteredWarnings = warnings.filter(
1119
1362
  (warning) => !(warning.component === "ParentId" && warning.entityId === rootId)
1120
1363
  );
@@ -1122,6 +1365,6 @@ function serializeEntitySubtree(world, rootId, options) {
1122
1365
  }
1123
1366
  __name(serializeEntitySubtree, "serializeEntitySubtree");
1124
1367
 
1125
- export { World, remapSnapshotEntityIds, serializeEntitySubtree };
1368
+ export { World, applyPrefabToSnapshotInstances, collectDirectPrefabDependencies, remapSnapshotEntityIds, serializeEntitySubtree };
1126
1369
  //# sourceMappingURL=index.js.map
1127
1370
  //# sourceMappingURL=index.js.map