@spearwolf/shadow-objects 0.33.0 → 0.34.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.
Files changed (210) hide show
  1. package/CHANGELOG.md +320 -61
  2. package/README.md +57 -13
  3. package/bundle.js +5 -54
  4. package/package.json +7 -3
  5. package/src/ChangeTrailRefusedError.d.ts +27 -0
  6. package/src/ChangeTrailRefusedError.d.ts.map +1 -0
  7. package/src/ChangeTrailRefusedError.js +12 -0
  8. package/src/ChangeTrailRefusedError.js.map +7 -0
  9. package/src/EntityUuidInUseError.d.ts +19 -0
  10. package/src/EntityUuidInUseError.d.ts.map +1 -0
  11. package/src/EntityUuidInUseError.js +11 -0
  12. package/src/EntityUuidInUseError.js.map +7 -0
  13. package/src/WorkerTimeoutError.d.ts +25 -0
  14. package/src/WorkerTimeoutError.d.ts.map +1 -0
  15. package/src/WorkerTimeoutError.js +12 -0
  16. package/src/WorkerTimeoutError.js.map +7 -0
  17. package/src/bundle.d.ts +1 -1
  18. package/src/bundle.d.ts.map +1 -1
  19. package/src/bundle.js +1 -1
  20. package/src/bundle.js.map +2 -2
  21. package/src/constants.d.ts +9 -2
  22. package/src/constants.d.ts.map +1 -1
  23. package/src/constants.js +1 -1
  24. package/src/constants.js.map +2 -2
  25. package/src/create-worker.bundle.d.ts +1 -1
  26. package/src/create-worker.bundle.d.ts.map +1 -1
  27. package/src/create-worker.bundle.js.map +1 -1
  28. package/src/create-worker.d.ts +1 -1
  29. package/src/create-worker.d.ts.map +1 -1
  30. package/src/create-worker.js.map +1 -1
  31. package/src/elements/ShaeElement.d.ts +70 -2
  32. package/src/elements/ShaeElement.d.ts.map +1 -1
  33. package/src/elements/ShaeElement.js +129 -25
  34. package/src/elements/ShaeElement.js.map +3 -3
  35. package/src/elements/ShaeEntElement.d.ts +39 -1
  36. package/src/elements/ShaeEntElement.d.ts.map +1 -1
  37. package/src/elements/ShaeEntElement.js +397 -167
  38. package/src/elements/ShaeEntElement.js.map +2 -2
  39. package/src/elements/ShaeLifecycleElement.d.ts +71 -0
  40. package/src/elements/ShaeLifecycleElement.d.ts.map +1 -0
  41. package/src/elements/ShaeLifecycleElement.js +83 -0
  42. package/src/elements/ShaeLifecycleElement.js.map +7 -0
  43. package/src/elements/ShaePropElement.d.ts +52 -2
  44. package/src/elements/ShaePropElement.d.ts.map +1 -1
  45. package/src/elements/ShaePropElement.js +240 -219
  46. package/src/elements/ShaePropElement.js.map +2 -2
  47. package/src/elements/ShaeWorkerElement.d.ts +49 -5
  48. package/src/elements/ShaeWorkerElement.d.ts.map +1 -1
  49. package/src/elements/ShaeWorkerElement.js +204 -73
  50. package/src/elements/ShaeWorkerElement.js.map +2 -2
  51. package/src/elements/constants.d.ts +6 -0
  52. package/src/elements/constants.d.ts.map +1 -1
  53. package/src/elements/constants.js +12 -0
  54. package/src/elements/constants.js.map +2 -2
  55. package/src/elements/deferredTeardown.d.ts +24 -0
  56. package/src/elements/deferredTeardown.d.ts.map +1 -0
  57. package/src/elements/deferredTeardown.js +30 -0
  58. package/src/elements/deferredTeardown.js.map +7 -0
  59. package/src/elements/displayContentsRule.d.ts +25 -0
  60. package/src/elements/displayContentsRule.d.ts.map +1 -0
  61. package/src/elements/displayContentsRule.js +37 -0
  62. package/src/elements/displayContentsRule.js.map +7 -0
  63. package/src/elements/events.d.ts +10 -7
  64. package/src/elements/events.d.ts.map +1 -1
  65. package/src/elements/forwardCustomEvents.d.ts +19 -0
  66. package/src/elements/forwardCustomEvents.d.ts.map +1 -0
  67. package/src/elements/forwardCustomEvents.js +47 -0
  68. package/src/elements/forwardCustomEvents.js.map +7 -0
  69. package/src/elements/hostedSlots.d.ts +36 -0
  70. package/src/elements/hostedSlots.d.ts.map +1 -0
  71. package/src/elements/hostedSlots.js +118 -0
  72. package/src/elements/hostedSlots.js.map +7 -0
  73. package/src/elements/parentRemoval.d.ts +18 -0
  74. package/src/elements/parentRemoval.d.ts.map +1 -0
  75. package/src/elements/parentRemoval.js +60 -0
  76. package/src/elements/parentRemoval.js.map +7 -0
  77. package/src/elements/propValueConverters.d.ts +3 -0
  78. package/src/elements/propValueConverters.d.ts.map +1 -0
  79. package/src/elements/propValueConverters.js +54 -0
  80. package/src/elements/propValueConverters.js.map +7 -0
  81. package/src/elements/requestEntAncestor.d.ts +32 -0
  82. package/src/elements/requestEntAncestor.d.ts.map +1 -0
  83. package/src/elements/requestEntAncestor.js +16 -0
  84. package/src/elements/requestEntAncestor.js.map +7 -0
  85. package/src/elements.js.map +1 -1
  86. package/src/in-the-dark/Entity.d.ts +113 -3
  87. package/src/in-the-dark/Entity.d.ts.map +1 -1
  88. package/src/in-the-dark/Entity.js +292 -63
  89. package/src/in-the-dark/Entity.js.map +3 -3
  90. package/src/in-the-dark/Kernel.d.ts +76 -17
  91. package/src/in-the-dark/Kernel.d.ts.map +1 -1
  92. package/src/in-the-dark/Kernel.js +410 -378
  93. package/src/in-the-dark/Kernel.js.map +3 -3
  94. package/src/in-the-dark/Registry.d.ts.map +1 -1
  95. package/src/in-the-dark/Registry.js +83 -14
  96. package/src/in-the-dark/Registry.js.map +2 -2
  97. package/src/in-the-dark/ShadowObject.d.ts.map +1 -1
  98. package/src/in-the-dark/ShadowObject.js +1 -0
  99. package/src/in-the-dark/ShadowObject.js.map +2 -2
  100. package/src/in-the-dark/ShadowObjectCreationScope.d.ts +126 -0
  101. package/src/in-the-dark/ShadowObjectCreationScope.d.ts.map +1 -0
  102. package/src/in-the-dark/ShadowObjectCreationScope.js +596 -0
  103. package/src/in-the-dark/ShadowObjectCreationScope.js.map +7 -0
  104. package/src/in-the-dark/SignalsPath.d.ts.map +1 -1
  105. package/src/in-the-dark/SignalsPath.js +2 -2
  106. package/src/in-the-dark/SignalsPath.js.map +2 -2
  107. package/src/in-the-dark/events.js.map +1 -1
  108. package/src/in-the-dark/importModule.d.ts +7 -0
  109. package/src/in-the-dark/importModule.d.ts.map +1 -1
  110. package/src/in-the-dark/importModule.js +5 -2
  111. package/src/in-the-dark/importModule.js.map +2 -2
  112. package/src/index.d.ts +7 -1
  113. package/src/index.d.ts.map +1 -1
  114. package/src/index.js +5 -1
  115. package/src/index.js.map +2 -2
  116. package/src/shadow-objects.d.ts +2 -0
  117. package/src/shadow-objects.d.ts.map +1 -1
  118. package/src/shadow-objects.js +2 -0
  119. package/src/shadow-objects.js.map +2 -2
  120. package/src/shadow-objects.worker.js +0 -1
  121. package/src/shadow-objects.worker.js.map +2 -2
  122. package/src/shae-ent.js.map +1 -1
  123. package/src/shae-prop.js +2 -2
  124. package/src/shae-prop.js.map +2 -2
  125. package/src/shae-worker.js.map +1 -1
  126. package/src/types.d.ts +35 -4
  127. package/src/types.d.ts.map +1 -1
  128. package/src/utils/ConsoleLogger.d.ts +45 -10
  129. package/src/utils/ConsoleLogger.d.ts.map +1 -1
  130. package/src/utils/ConsoleLogger.js +51 -26
  131. package/src/utils/ConsoleLogger.js.map +2 -2
  132. package/src/utils/FrameLoop.d.ts +42 -3
  133. package/src/utils/FrameLoop.d.ts.map +1 -1
  134. package/src/utils/FrameLoop.js +71 -10
  135. package/src/utils/FrameLoop.js.map +2 -2
  136. package/src/utils/MicrotaskCollector.d.ts +45 -0
  137. package/src/utils/MicrotaskCollector.d.ts.map +1 -0
  138. package/src/utils/MicrotaskCollector.js +33 -0
  139. package/src/utils/MicrotaskCollector.js.map +7 -0
  140. package/src/utils/MicrotaskGate.d.ts +17 -0
  141. package/src/utils/MicrotaskGate.d.ts.map +1 -0
  142. package/src/utils/MicrotaskGate.js +20 -0
  143. package/src/utils/MicrotaskGate.js.map +7 -0
  144. package/src/utils/array-utils.js.map +1 -1
  145. package/src/utils/attr-utils.d.ts +6 -0
  146. package/src/utils/attr-utils.d.ts.map +1 -1
  147. package/src/utils/attr-utils.js +3 -1
  148. package/src/utils/attr-utils.js.map +2 -2
  149. package/src/utils/constants.js.map +1 -1
  150. package/src/utils/generateUUID.d.ts +11 -0
  151. package/src/utils/generateUUID.d.ts.map +1 -1
  152. package/src/utils/generateUUID.js +31 -266
  153. package/src/utils/generateUUID.js.map +2 -2
  154. package/src/utils/props-utils.d.ts +3 -2
  155. package/src/utils/props-utils.d.ts.map +1 -1
  156. package/src/utils/props-utils.js +13 -24
  157. package/src/utils/props-utils.js.map +2 -2
  158. package/src/utils/runGuarded.d.ts +27 -0
  159. package/src/utils/runGuarded.d.ts.map +1 -0
  160. package/src/utils/runGuarded.js +11 -0
  161. package/src/utils/runGuarded.js.map +7 -0
  162. package/src/utils/toMaybe.d.ts.map +1 -1
  163. package/src/utils/toMaybe.js.map +1 -1
  164. package/src/utils/toNamespace.d.ts.map +1 -1
  165. package/src/utils/toNamespace.js.map +1 -1
  166. package/src/utils/toUrlString.d.ts +12 -0
  167. package/src/utils/toUrlString.d.ts.map +1 -1
  168. package/src/utils/toUrlString.js.map +2 -2
  169. package/src/utils/waitForMessageOfType.d.ts +12 -1
  170. package/src/utils/waitForMessageOfType.d.ts.map +1 -1
  171. package/src/utils/waitForMessageOfType.js +16 -1
  172. package/src/utils/waitForMessageOfType.js.map +2 -2
  173. package/src/view/ComponentChanges.d.ts +88 -1
  174. package/src/view/ComponentChanges.d.ts.map +1 -1
  175. package/src/view/ComponentChanges.js +243 -73
  176. package/src/view/ComponentChanges.js.map +2 -2
  177. package/src/view/ComponentContext.d.ts +206 -16
  178. package/src/view/ComponentContext.d.ts.map +1 -1
  179. package/src/view/ComponentContext.js +548 -91
  180. package/src/view/ComponentContext.js.map +2 -2
  181. package/src/view/ComponentMemory.d.ts +3 -3
  182. package/src/view/ComponentMemory.d.ts.map +1 -1
  183. package/src/view/ComponentMemory.js.map +1 -1
  184. package/src/view/IShadowObjectEnvProxy.d.ts +29 -3
  185. package/src/view/IShadowObjectEnvProxy.d.ts.map +1 -1
  186. package/src/view/LocalShadowObjectEnv.d.ts +1 -1
  187. package/src/view/LocalShadowObjectEnv.d.ts.map +1 -1
  188. package/src/view/LocalShadowObjectEnv.js +8 -6
  189. package/src/view/LocalShadowObjectEnv.js.map +2 -2
  190. package/src/view/RemoteWorkerEnv.d.ts +89 -5
  191. package/src/view/RemoteWorkerEnv.d.ts.map +1 -1
  192. package/src/view/RemoteWorkerEnv.js +195 -77
  193. package/src/view/RemoteWorkerEnv.js.map +2 -2
  194. package/src/view/ShadowEnv.d.ts +49 -2
  195. package/src/view/ShadowEnv.d.ts.map +1 -1
  196. package/src/view/ShadowEnv.js +223 -60
  197. package/src/view/ShadowEnv.js.map +2 -2
  198. package/src/view/ViewComponent.d.ts +78 -14
  199. package/src/view/ViewComponent.d.ts.map +1 -1
  200. package/src/view/ViewComponent.js +90 -14
  201. package/src/view/ViewComponent.js.map +2 -2
  202. package/src/view/cloneChangeTrail.js.map +2 -2
  203. package/src/worker/MessageRouter.d.ts +14 -0
  204. package/src/worker/MessageRouter.d.ts.map +1 -1
  205. package/src/worker/MessageRouter.js +75 -15
  206. package/src/worker/MessageRouter.js.map +2 -2
  207. package/src/worker/WorkerRuntime.d.ts +22 -1
  208. package/src/worker/WorkerRuntime.d.ts.map +1 -1
  209. package/src/worker/WorkerRuntime.js +60 -8
  210. package/src/worker/WorkerRuntime.js.map +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/view/ComponentChanges.ts"],
4
- "sourcesContent": ["import {ChangeTrailPhase, ComponentChangeType, VoidToken} from '../constants.js';\nimport type {\n IChangeToken,\n IComponentChangeType,\n IComponentEvent,\n ICreateEntitiesChange,\n IDestroyEntitiesChange,\n IPropertiesChange,\n ISendEvents,\n ISetParentChange,\n IUpdateOrderChange,\n} from '../types.js';\nimport {appendToEnd, removeFrom} from '../utils/array-utils.js';\n\nconst ROOT = '#root';\n\nexport class ComponentChanges {\n readonly #uuid: string;\n\n get uuid(): string {\n return this.#uuid;\n }\n\n #serial = 0;\n\n constructor(uuid: string) {\n this.#uuid = uuid;\n }\n\n #isNew = true;\n #createCount = 0;\n #destroyCount = 0;\n\n hasChanges(): boolean {\n return this.#serial > 0;\n }\n\n get isNew(): boolean {\n return this.#isNew;\n }\n\n get isCreated(): boolean {\n return this.#createCount > 0 && this.#createCount > this.#destroyCount;\n }\n\n get isDestroyed(): boolean {\n return this.#destroyCount > 0 && this.#destroyCount >= this.#createCount;\n }\n\n #token: string = VoidToken;\n #parentUuid?: string;\n #order: number = 0;\n #autoDestructionOnParentRemoval = false;\n\n #nextToken?: string;\n #nextParentUuid?: string;\n #nextOrder?: number;\n\n create(token: string = VoidToken, parentUuid?: string, order: number = 0, autoDestructionOnParentRemoval = false) {\n this.#serial++;\n this.#createCount++;\n\n this.#nextToken = token;\n this.#nextParentUuid = parentUuid ?? ROOT;\n this.#nextOrder = !order ? undefined : order;\n this.#autoDestructionOnParentRemoval = autoDestructionOnParentRemoval;\n }\n\n destroy() {\n this.#destroyCount++;\n this.#serial++;\n }\n\n clear() {\n this.#serial = 0;\n\n this.#isNew = false;\n\n this.#nextToken = undefined;\n this.#nextParentUuid = undefined;\n this.#nextOrder = undefined;\n\n this.#nextProperties.clear();\n this.#propsChangeOrder.length = 0;\n\n this.#events.length = 0;\n this.#transferables.clear();\n }\n\n changeToken(token: string | undefined) {\n // an absent token means the void token everywhere else, so normalize here too;\n // otherwise `undefined` would mark the component dirty without ever emitting a change\n token ??= VoidToken;\n\n if (token === this.#token) {\n // a component that has not been flushed yet still owes the trail its create-token:\n // #token is only the last *written* token, so dropping #nextToken here would emit a\n // CreateEntities change without any token at all\n this.#nextToken = this.#isNew ? token : undefined;\n } else {\n this.#nextToken = token;\n this.#serial++;\n }\n }\n\n setParent(parentUuid?: string) {\n if (parentUuid === this.#parentUuid) {\n this.#nextParentUuid = undefined;\n } else {\n this.#nextParentUuid = parentUuid ?? ROOT;\n this.#serial++;\n }\n }\n\n changeOrder(order: number) {\n if (order === this.#order) {\n this.#nextOrder = undefined;\n } else {\n this.#nextOrder = order;\n this.#serial++;\n }\n }\n\n #properties: Map<string, unknown> = new Map();\n #nextProperties: Map<string, unknown> = new Map();\n #propsChangeOrder: string[] = []; // we use an Array here and not a Set, because we want to keep the change order\n\n /**\n * @returns `true` if the value differs from the last value written to a change trail\n */\n changeProperty<T = unknown>(key: string, value: T, isEqual?: (a: T, b: T) => boolean): boolean {\n const prevValue = this.#properties.get(key) as T;\n const valueChanged = (isEqual == null && value !== prevValue) || (isEqual != null && !isEqual(value, prevValue));\n\n if (valueChanged) {\n this.#nextProperties.set(key, value);\n appendToEnd(this.#propsChangeOrder, key);\n this.#serial++;\n } else {\n this.#nextProperties.delete(key);\n removeFrom(this.#propsChangeOrder, key);\n }\n\n return valueChanged;\n }\n\n removeProperty(key: string) {\n const propExists = this.#properties.has(key);\n if (this.#nextProperties.has(key)) {\n this.#nextProperties.delete(key);\n if (!propExists) {\n removeFrom(this.#propsChangeOrder, key);\n }\n } else if (propExists) {\n appendToEnd(this.#propsChangeOrder, key);\n this.#serial++;\n }\n }\n\n #events: IComponentEvent[] = [];\n #transferables = new Set<Transferable>();\n\n createEvent(type: string, data: unknown, transferables?: Transferable[]) {\n this.#events.push({type, data});\n for (const transferable of transferables ?? []) {\n this.#transferables.add(transferable);\n }\n this.#serial++;\n }\n\n transferEventsTo(changes: ComponentChanges) {\n if (this.#events.length > 0) {\n changes.#events.push(...this.#events);\n this.#events.length = 0;\n }\n if (this.#transferables.size > 0) {\n changes.#transferables = new Set([...changes.#transferables, ...this.#transferables]);\n this.#transferables.clear();\n }\n }\n\n buildChangeTrail(trail: IComponentChangeType[], trailPhase: ChangeTrailPhase) {\n const {isNew, isCreated, isDestroyed} = this;\n\n if (isNew && isDestroyed) return;\n\n switch (trailPhase) {\n case ChangeTrailPhase.StructuralChanges:\n if (isNew) {\n trail.push(this.makeCreateEntityChange());\n } else if (!isDestroyed) {\n if (this.#nextParentUuid !== undefined && !(this.#nextParentUuid === ROOT && this.#parentUuid === undefined)) {\n trail.push(this.makeSetParentChange());\n } else if (this.#nextOrder !== undefined && this.#nextOrder !== this.#order) {\n trail.push(this.makeUpdateOrderChange());\n }\n if (this.#nextToken !== undefined && this.#nextToken !== this.#token) {\n trail.push(this.makeChangeToken());\n }\n }\n break;\n\n case ChangeTrailPhase.ContentUpdates:\n if (!isNew && isCreated && this.#propsChangeOrder.length > 0) {\n trail.push(this.makeChangePropertyChange());\n }\n if (this.#events.length > 0) {\n trail.push(this.makeEvents());\n }\n break;\n\n case ChangeTrailPhase.Removal:\n if (isDestroyed) {\n trail.push(this.makeDestroyEntityChange());\n }\n break;\n }\n }\n\n makeEvents(): ISendEvents {\n const event: ISendEvents = {\n type: ComponentChangeType.SendEvents,\n uuid: this.#uuid,\n events: this.#events.slice(0),\n };\n if (this.#transferables.size > 0) {\n event.transferables = Array.from(this.#transferables);\n }\n return event;\n }\n\n makeCreateEntityChange(): ICreateEntitiesChange {\n // never emit a create without a token: the kernel would register an entity that no\n // shadow object can ever be looked up for\n const token = this.#nextToken ?? this.#token;\n\n const entry: ICreateEntitiesChange = {\n type: ComponentChangeType.CreateEntities,\n uuid: this.#uuid,\n token,\n };\n\n this.#token = token;\n\n if (this.#nextParentUuid !== undefined) {\n const nextParentUuid = this.#nextParentUuid === ROOT ? undefined : this.#nextParentUuid;\n this.#parentUuid = nextParentUuid;\n if (nextParentUuid !== undefined) {\n entry.parentUuid = nextParentUuid;\n }\n }\n\n if (this.#nextProperties.size > 0) {\n entry.properties = Array.from(this.#nextProperties.entries()).filter(([, value]) => value !== undefined);\n for (const [key, value] of entry.properties) {\n this.#properties.set(key, value);\n }\n }\n\n if (this.#nextOrder !== undefined && this.#nextOrder !== this.#order) {\n entry.order = this.#order = this.#nextOrder;\n }\n\n if (this.#autoDestructionOnParentRemoval) {\n entry.autoDestructionOnParentRemoval = true;\n }\n\n return entry;\n }\n\n makeDestroyEntityChange(): IDestroyEntitiesChange {\n return {\n type: ComponentChangeType.DestroyEntities,\n uuid: this.#uuid,\n };\n }\n\n makeSetParentChange(): ISetParentChange {\n this.#parentUuid = this.#nextParentUuid === ROOT ? undefined : this.#nextParentUuid;\n\n const entry: ISetParentChange = {\n type: ComponentChangeType.SetParent,\n uuid: this.#uuid,\n parentUuid: this.#parentUuid,\n };\n\n if (this.#nextOrder !== undefined && this.#nextOrder !== this.#order) {\n entry.order = this.#order = this.#nextOrder;\n }\n\n return entry;\n }\n\n makeUpdateOrderChange(): IUpdateOrderChange {\n this.#order = this.#nextOrder ?? 0;\n\n return {\n type: ComponentChangeType.UpdateOrder,\n uuid: this.#uuid,\n order: this.#order,\n };\n }\n\n makeChangeToken(): IChangeToken {\n this.#token = this.#nextToken ?? VoidToken;\n\n return {\n type: ComponentChangeType.ChangeToken,\n uuid: this.#uuid,\n token: this.#token,\n };\n }\n\n makeChangePropertyChange(): IPropertiesChange {\n const properties = this.#propsChangeOrder.map((key) => {\n if (this.#nextProperties.has(key)) {\n // set prop \u2014 an explicit `undefined` is a removal, exactly like removeProperty()\n const nextValue = this.#nextProperties.get(key);\n if (nextValue === undefined) {\n this.#properties.delete(key);\n } else {\n this.#properties.set(key, nextValue);\n }\n return [key, nextValue] as [string, unknown];\n } else {\n // remove prop\n this.#properties.delete(key);\n return [key, undefined] as [string, unknown];\n }\n });\n\n return {\n type: ComponentChangeType.ChangeProperties,\n uuid: this.#uuid,\n properties,\n };\n }\n}"],
5
- "mappings": "AAAA,SAAQ,kBAAkB,qBAAqB,iBAAgB;AAY/D,SAAQ,aAAa,kBAAiB;AAEtC,MAAM,OAAO;AAEN,MAAM,iBAAiB;AAAA,EACnB;AAAA,EAET,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,UAAU;AAAA,EAEV,YAAY,MAAc;AACxB,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB;AAAA,EAEhB,aAAsB;AACpB,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,IAAI,QAAiB;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,YAAqB;AACvB,WAAO,KAAK,eAAe,KAAK,KAAK,eAAe,KAAK;AAAA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nC;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,wBAA4C;AAC1C,SAAK,SAAS,KAAK,cAAc;AAEjC,WAAO;AAAA,MACL,MAAM,oBAAoB;AAAA,MAC1B,MAAM,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,IACd;AAAA,EACF;AAAA,EAEA,kBAAgC;AAC9B,SAAK,SAAS,KAAK,cAAc;AAEjC,WAAO;AAAA,MACL,MAAM,oBAAoB;AAAA,MAC1B,MAAM,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,IACd;AAAA,EACF;AAAA,EAEA,2BAA8C;AAC5C,UAAM,aAAa,KAAK,kBAAkB,IAAI,CAAC,QAAQ;AACrD,UAAI,KAAK,gBAAgB,IAAI,GAAG,GAAG;AAEjC,cAAM,YAAY,KAAK,gBAAgB,IAAI,GAAG;AAC9C,YAAI,cAAc,QAAW;AAC3B,eAAK,YAAY,OAAO,GAAG;AAAA,QAC7B,OAAO;AACL,eAAK,YAAY,IAAI,KAAK,SAAS;AAAA,QACrC;AACA,eAAO,CAAC,KAAK,SAAS;AAAA,MACxB,OAAO;AAEL,aAAK,YAAY,OAAO,GAAG;AAC3B,eAAO,CAAC,KAAK,MAAS;AAAA,MACxB;AAAA,IACF,CAAC;AAED,WAAO;AAAA,MACL,MAAM,oBAAoB;AAAA,MAC1B,MAAM,KAAK;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import {ChangeTrailPhase, ComponentChangeType, VoidToken} from '../constants.js';\nimport type {\n ComponentPropertiesType,\n IChangeToken,\n IComponentChangeType,\n IComponentEvent,\n ICreateEntitiesChange,\n IDestroyEntitiesChange,\n IPropertiesChange,\n ISendEvents,\n ISetParentChange,\n IUpdateOrderChange,\n} from '../types.js';\nimport {appendToEnd, removeFrom} from '../utils/array-utils.js';\n\nconst ROOT = '#root';\n\n/**\n * The value a property carries in this bookkeeping when it is set without one \u2014 the third form\n * of {@link ComponentPropertiesType}, which travels as a one-element `[key]`. `undefined`\n * cannot say it: that is what a removal reads as, and the two have to stay apart all the way\n * to the entry.\n *\n * It never leaves the View Layer. A change trail runs through `structuredClone()` on its way\n * to a worker, and a symbol on that wire is a `DataCloneError` \u2014 so every method that builds\n * an entry turns it back into the one-element form, and the one reader outside this class,\n * `ComponentContext.transferPropertiesTo()`, tests for it before it hands a value on.\n */\nexport const PropertyWithoutValue = Symbol('shadow-objects/property-without-value');\n\n/**\n * Tracks one component's outstanding changes between two change trails as four written \u2194\n * pending pairs: `#token`/`#nextToken`, `#parentUuid`/`#nextParentUuid`, `#order`/`#nextOrder`\n * and `#properties`/`#nextProperties`. The `make*` methods read the pending half and leave it\n * where it is: a trail entry is a request, and until the Shadow Environment has applied it the\n * change is still owed. {@link ComponentChanges.commitChange} is what moves the line \u2014 it folds\n * one applied entry into the written half and releases exactly the pending values that entry\n * carried, so a value that changed again while the entry was on its way goes out with the next\n * trail instead of being lost.\n *\n * Whether anything is outstanding follows from those pairs rather than from a counter, which is\n * what lets a partly applied trail leave the rest of the component untouched.\n *\n * The create/destroy counts behind {@link ComponentChanges.isCreated} and {@link\n * ComponentChanges.isDestroyed} belong to the uuid, not to a `ViewComponent` instance. They\n * carry the rule `ComponentContext.addComponent` keeps: a uuid names one component of a\n * `ComponentContext` at a time, so a later component takes this bookkeeping over only once\n * its predecessor has counted its own `destroy()`. A count pair that outlives its component\n * therefore describes an entity, and the successor on that uuid continues the same entity\n * rather than starting a second.\n */\nexport class ComponentChanges {\n readonly #uuid: string;\n\n get uuid(): string {\n return this.#uuid;\n }\n\n constructor(uuid: string) {\n this.#uuid = uuid;\n }\n\n #isNew = true;\n #createCount = 0;\n #destroyCount = 0;\n\n /**\n * Whether this component owes the next change trail anything: a creation, a destruction, or a\n * pending value in one of the four written \u2194 pending pairs.\n */\n hasChanges(): boolean {\n return (\n (this.#isNew && this.isCreated) ||\n this.isDestroyed ||\n (this.#nextToken !== undefined && this.#nextToken !== this.#token) ||\n this.#hasPendingParent() ||\n (this.#nextOrder !== undefined && this.#nextOrder !== this.#order) ||\n this.#propsChangeOrder.length > 0 ||\n this.#events.length > 0\n );\n }\n\n get isNew(): boolean {\n return this.#isNew;\n }\n\n get isCreated(): boolean {\n return this.#createCount > 0 && this.#createCount > this.#destroyCount;\n }\n\n get isDestroyed(): boolean {\n return this.#destroyCount > 0 && this.#destroyCount >= this.#createCount;\n }\n\n #token: string = VoidToken;\n #parentUuid?: string | undefined;\n #order: number = 0;\n #autoDestructionOnParentRemoval = false;\n\n #nextToken?: string | undefined;\n #nextParentUuid?: string | undefined;\n #nextOrder?: number | undefined;\n\n create(token: string = VoidToken, parentUuid?: string, order: number = 0, autoDestructionOnParentRemoval = false) {\n this.#createCount++;\n\n this.#nextToken = token;\n this.#nextParentUuid = parentUuid ?? ROOT;\n this.#nextOrder = !order ? undefined : order;\n this.#autoDestructionOnParentRemoval = autoDestructionOnParentRemoval;\n }\n\n destroy() {\n this.#destroyCount++;\n }\n\n /**\n * Whether the pending parent asks for something the confirmed one is not already. A pending\n * value that has come back to the confirmed parent is a change that cancelled itself out.\n */\n #hasPendingParent(): boolean {\n if (this.#nextParentUuid === undefined) return false;\n return (this.#nextParentUuid === ROOT ? undefined : this.#nextParentUuid) !== this.#parentUuid;\n }\n\n /**\n * Drop every pending value without writing any of them forward.\n *\n * This is the way out for a component whose bookkeeping is about to be replaced wholesale \u2014\n * `ComponentContext.reCreateChanges` does exactly that. A trail that has gone out is\n * settled with {@link ComponentChanges.commitChange} instead.\n */\n clear() {\n this.#nextToken = undefined;\n this.#nextParentUuid = undefined;\n this.#nextOrder = undefined;\n\n this.#nextProperties.clear();\n this.#propsChangeOrder.length = 0;\n this.#travellingProperties = undefined;\n\n this.#events.length = 0;\n this.#transferables.clear();\n }\n\n /**\n * The three scalar pairs below all answer the same question the same way: is anything owed once\n * the entry that is on its way out has landed?\n *\n * The written half alone cannot answer it. It is the last *confirmed* value and stays behind\n * until the entry is committed, so a value the caller sets back to it while the entry travels\n * would look like \"nothing to do\" \u2014 and the entry would then be the last word, leaving the\n * Shadow Environment holding a value the view has already moved on from. So the pending half is\n * only released where there is nothing in flight to contradict it; where there is, the new value\n * takes the pending slot and the emitting side decides, against the written half it settles on.\n */\n changeToken(token: string | undefined) {\n // an absent token means the void token everywhere else, so normalize here too;\n // otherwise `undefined` would mark the component dirty without ever emitting a change\n token ??= VoidToken;\n\n // nothing pending and the confirmed token is the wanted one: nothing to queue. A component\n // that has not been flushed yet is the exception \u2014 it still owes the trail its create-token,\n // and dropping it here would emit a CreateEntities change without any token at all.\n if (token === this.#token && this.#nextToken === undefined && !this.#isNew) return;\n\n this.#nextToken = token;\n }\n\n setParent(parentUuid?: string) {\n const nextParentUuid = parentUuid ?? ROOT;\n\n if (nextParentUuid === (this.#parentUuid ?? ROOT) && this.#nextParentUuid === undefined) return;\n\n this.#nextParentUuid = nextParentUuid;\n }\n\n changeOrder(order: number) {\n if (order === this.#order && this.#nextOrder === undefined) return;\n\n this.#nextOrder = order;\n }\n\n #properties: Map<string, unknown> = new Map();\n #nextProperties: Map<string, unknown> = new Map();\n /**\n * The keys with a queued change, in the order their changes happened \u2014 the order an entry\n * carries them in, and the reason this is a list and not a set.\n *\n * A set beside it would answer membership in one step, and per call it does win from about eight\n * keys on: 8.0 ns for the set against 10.7 ns for the list at eight keys, 10.4 ns against 43.9 ns\n * at 64. The distance is what decides against it. At the upper stop this repository can produce \u2014\n * 64 keys, every one of them changed in every frame at 60 fps, so 3840 calls per second \u2014 that is\n * 0.13 ms saved per second of animation. And membership is the smaller half: `removeFrom()` and\n * `appendToEnd()` are an `indexOf` plus a `splice`, and the splice stays linear no matter what\n * answers the membership. Numbers measured 2026-08-31 on node v25.9.0.\n */\n #propsChangeOrder: string[] = [];\n\n /**\n * The keys an entry on its way out carries, until that entry is settled. For those keys the\n * written half is behind, and {@link ComponentChanges.changeProperty} must not cancel against it.\n */\n #travellingProperties?: Map<string, unknown> | undefined;\n\n /**\n * @returns `true` if the value differs from the last value this component asked for\n */\n changeProperty<T = unknown>(key: string, value: T, isEqual?: (a: T, b: T) => boolean): boolean {\n const equals = (a: T, b: T) =>\n // a registered rule compares values, and the marker is not one -- handed to it, a rule\n // would be asked about a property it never saw, and one that reaches into its arguments\n // throws on a symbol. Where either side is the marker the only question left is whether\n // it is still the same third form, and identity answers that.\n (a as unknown) === PropertyWithoutValue || (b as unknown) === PropertyWithoutValue\n ? (a as unknown) === (b as unknown)\n : isEqual == null\n ? a === b\n : isEqual(a, b);\n\n const isQueued = this.#propsChangeOrder.includes(key);\n const isTravelling = this.#travellingProperties?.has(key) ?? false;\n\n // the value this component last said the property should have: the pending half where\n // something is queued, else what an entry on its way out carries, else the confirmed value.\n // A key that is none of the three reads as `undefined`, and a registered rule decides that\n // comparison too -- a rule that calls the value equal to `undefined` says there is nothing\n // to send.\n let prevValue: T;\n if (isQueued) {\n prevValue = this.#nextProperties.get(key) as T;\n } else if (isTravelling) {\n prevValue = this.#travellingProperties!.get(key) as T;\n } else {\n prevValue = this.#properties.get(key) as T;\n }\n\n const valueChanged = !equals(value, prevValue);\n\n // The pending half is released only where the confirmed value is the wanted one and no entry\n // carrying another one is on its way out -- such an entry would otherwise be the last word.\n // The travelling test comes first because it decides the branch on its own, and a comparison\n // rule can be expensive on a path that runs once per frame. Where nothing is queued the\n // comparison above was already the one against the confirmed value, so it is reused.\n const nothingToSend = !isTravelling && (isQueued ? equals(value, this.#properties.get(key) as T) : !valueChanged);\n\n if (nothingToSend) {\n this.#nextProperties.delete(key);\n removeFrom(this.#propsChangeOrder, key);\n } else {\n this.#nextProperties.set(key, value);\n appendToEnd(this.#propsChangeOrder, key);\n }\n\n return valueChanged;\n }\n\n /**\n * Mark `key` as set without giving it a value: the next trail carries an entry that names\n * only the key. A later {@link ComponentChanges.changeProperty} replaces it with a value,\n * and {@link ComponentChanges.removeProperty} takes it away like any other property.\n *\n * @returns `true` if this differs from the last value this component asked for\n */\n setPropertyWithoutValue(key: string): boolean {\n return this.changeProperty(key, PropertyWithoutValue as unknown);\n }\n\n removeProperty(key: string) {\n const isQueued = this.#propsChangeOrder.includes(key);\n\n this.#nextProperties.delete(key);\n\n if (!this.#properties.has(key) && !this.#travellingProperties?.has(key)) {\n // nothing confirmed and nothing travelling: there is nothing to remove\n removeFrom(this.#propsChangeOrder, key);\n return;\n }\n\n // a key that was already queued keeps the place it took: the entry carries the changes in\n // the order they happened, and a removal is not a second change to the same key\n if (!isQueued) {\n appendToEnd(this.#propsChangeOrder, key);\n }\n }\n\n /**\n * The properties this component holds at this moment: the ones a change trail has already\n * carried, overlaid with everything that has accrued since.\n *\n * The overlay is what makes the result the current state instead of the state of the last\n * trail \u2014 `#properties` is only written forward while a trail is being built\n * ({@link ComponentChanges.makeCreateEntityChange},\n * {@link ComponentChanges.makeChangePropertyChange}). A key whose accrued value is `undefined`\n * and a key queued for change without an accrued value are both removals, and neither appears\n * in the result. A key that is set without a value stands in the result with\n * {@link PropertyWithoutValue}.\n */\n getProperties(): Map<string, unknown> {\n const properties = new Map(this.#properties);\n\n for (const key of this.#propsChangeOrder) {\n const value = this.#nextProperties.get(key);\n if (value === undefined) {\n properties.delete(key);\n } else {\n properties.set(key, value);\n }\n }\n\n return properties;\n }\n\n #events: IComponentEvent[] = [];\n #transferables = new Set<Transferable>();\n\n createEvent(type: string, data: unknown, transferables?: Transferable[]) {\n this.#events.push({type, data});\n for (const transferable of transferables ?? []) {\n this.#transferables.add(transferable);\n }\n }\n\n transferEventsTo(changes: ComponentChanges) {\n if (this.#events.length > 0) {\n changes.#events.push(...this.#events);\n this.#events.length = 0;\n }\n if (this.#transferables.size > 0) {\n changes.#transferables = new Set([...changes.#transferables, ...this.#transferables]);\n this.#transferables.clear();\n }\n }\n\n buildChangeTrail(trail: IComponentChangeType[], trailPhase: ChangeTrailPhase) {\n const {isNew, isCreated, isDestroyed} = this;\n\n if (isNew && isDestroyed) return;\n\n switch (trailPhase) {\n case ChangeTrailPhase.StructuralChanges:\n if (isNew) {\n trail.push(this.makeCreateEntityChange());\n } else if (!isDestroyed) {\n if (this.#hasPendingParent()) {\n trail.push(this.makeSetParentChange());\n } else if (this.#nextOrder !== undefined && this.#nextOrder !== this.#order) {\n trail.push(this.makeUpdateOrderChange());\n }\n if (this.#nextToken !== undefined && this.#nextToken !== this.#token) {\n trail.push(this.makeChangeToken());\n }\n }\n break;\n\n case ChangeTrailPhase.ContentUpdates:\n if (!isNew && isCreated && this.#propsChangeOrder.length > 0) {\n trail.push(this.makeChangePropertyChange());\n }\n if (this.#events.length > 0) {\n trail.push(this.makeEvents());\n }\n break;\n\n case ChangeTrailPhase.Removal:\n if (isDestroyed) {\n trail.push(this.makeDestroyEntityChange());\n }\n break;\n }\n }\n\n makeEvents(): ISendEvents {\n const event: ISendEvents = {\n type: ComponentChangeType.SendEvents,\n uuid: this.#uuid,\n events: this.#events.slice(0),\n };\n if (this.#transferables.size > 0) {\n event.transferables = Array.from(this.#transferables);\n }\n return event;\n }\n\n makeCreateEntityChange(): ICreateEntitiesChange {\n // never emit a create without a token: the kernel would register an entity that no\n // shadow object can ever be looked up for\n const token = this.#nextToken ?? this.#token;\n\n const entry: ICreateEntitiesChange = {\n type: ComponentChangeType.CreateEntities,\n uuid: this.#uuid,\n token,\n };\n\n if (this.#nextParentUuid !== undefined && this.#nextParentUuid !== ROOT) {\n entry.parentUuid = this.#nextParentUuid;\n }\n\n if (this.#nextProperties.size > 0) {\n // a create carries only the keys that have a value or are set without one; where nothing\n // is left, the field stays off the entry \u2014 an absent `properties` and an empty one say\n // the same thing, and the shorter one is what travels. The note is taken either way: it\n // records what this entry carries, and an entry with no property is travelling with none\n const properties: ComponentPropertiesType = [];\n for (const [key, value] of this.#nextProperties) {\n if (value === PropertyWithoutValue) {\n properties.push([key]);\n } else if (value !== undefined) {\n properties.push([key, value]);\n }\n }\n this.#noteTravellingProperties(properties);\n if (properties.length > 0) {\n entry.properties = properties;\n }\n }\n\n if (this.#nextOrder !== undefined && this.#nextOrder !== this.#order) {\n entry.order = this.#nextOrder;\n }\n\n if (this.#autoDestructionOnParentRemoval) {\n entry.autoDestructionOnParentRemoval = true;\n }\n\n return entry;\n }\n\n makeDestroyEntityChange(): IDestroyEntitiesChange {\n return {\n type: ComponentChangeType.DestroyEntities,\n uuid: this.#uuid,\n };\n }\n\n makeSetParentChange(): ISetParentChange {\n const entry: ISetParentChange = {\n type: ComponentChangeType.SetParent,\n uuid: this.#uuid,\n parentUuid: this.#nextParentUuid === ROOT ? undefined : this.#nextParentUuid,\n };\n\n if (this.#nextOrder !== undefined && this.#nextOrder !== this.#order) {\n entry.order = this.#nextOrder;\n }\n\n return entry;\n }\n\n makeUpdateOrderChange(): IUpdateOrderChange {\n return {\n type: ComponentChangeType.UpdateOrder,\n uuid: this.#uuid,\n order: this.#nextOrder ?? 0,\n };\n }\n\n makeChangeToken(): IChangeToken {\n return {\n type: ComponentChangeType.ChangeToken,\n uuid: this.#uuid,\n token: this.#nextToken ?? VoidToken,\n };\n }\n\n makeChangePropertyChange(): IPropertiesChange {\n // a key without a pending value is a removal, and so is a pending value of `undefined` --\n // `get()` answers the same for both, which is what the receiving side reads them as. A key\n // set without a value is the third form and travels as the bare key\n const properties: ComponentPropertiesType = this.#propsChangeOrder.map((key) => {\n const value = this.#nextProperties.get(key);\n return value === PropertyWithoutValue ? [key] : [key, value];\n });\n\n this.#noteTravellingProperties(properties);\n\n return {\n type: ComponentChangeType.ChangeProperties,\n uuid: this.#uuid,\n properties,\n };\n }\n\n /**\n * Records the keys of an entry that is going out, so a later change knows the written half\n * is behind.\n */\n #noteTravellingProperties(properties: ComponentPropertiesType): void {\n // the arity carries the meaning on the wire, the marker carries it in here\n this.#travellingProperties = new Map(\n properties.map((entry) => [entry[0], entry.length === 1 ? PropertyWithoutValue : entry[1]]),\n );\n }\n\n /**\n * Fold one trail entry into the written half of this component's bookkeeping: the values the\n * entry carries become the values the next diff is taken against, and the pending half that\n * produced them is released. Called once per entry the Shadow Environment has applied.\n *\n * A pending value is released only while it is still the value the entry carried. Between the\n * build of a trail and its confirmation lies a round trip, and whatever changed in that window\n * is owed to the Shadow Environment \u2014 releasing it here would leave the two sides holding\n * different values with nothing left to correct them.\n */\n commitChange(entry: IComponentChangeType): void {\n switch (entry.type) {\n case ComponentChangeType.CreateEntities:\n this.#commitToken(entry.token);\n this.#commitParentUuid(entry.parentUuid);\n this.#commitOrder(entry.order ?? this.#order);\n this.#commitProperties(entry.properties);\n // a create carries only the properties that have a value; a pending removal of a key the\n // entity was never given has nothing left to ask for and is released along with it\n for (const key of this.#propsChangeOrder.slice(0)) {\n if (this.#nextProperties.get(key) === undefined && !this.#properties.has(key)) {\n this.#nextProperties.delete(key);\n removeFrom(this.#propsChangeOrder, key);\n }\n }\n this.#travellingProperties = undefined;\n this.#isNew = false;\n break;\n\n case ComponentChangeType.SetParent:\n this.#commitParentUuid(entry.parentUuid);\n this.#commitOrder(entry.order ?? this.#order);\n break;\n\n case ComponentChangeType.UpdateOrder:\n this.#commitOrder(entry.order);\n break;\n\n case ComponentChangeType.ChangeToken:\n this.#commitToken(entry.token);\n break;\n\n case ComponentChangeType.ChangeProperties:\n this.#commitProperties(entry.properties);\n this.#travellingProperties = undefined;\n break;\n\n case ComponentChangeType.SendEvents:\n // the entry carries a snapshot taken while the trail was built; anything that arrived\n // behind it is still waiting to go out\n this.#events.splice(0, entry.events.length);\n for (const transferable of entry.transferables ?? []) {\n this.#transferables.delete(transferable);\n }\n break;\n\n case ComponentChangeType.DestroyEntities:\n // The entity behind this uuid is gone. Usually the component entry goes with it, but a\n // uuid its holder has left is free again, and a component that took it over in the\n // meantime keeps the entry alive. The written half describes an entity that no longer\n // exists, so it is reset to what a component nobody knows yet looks like -- otherwise the\n // successor would diff against it and ask for a change to something that is not there.\n this.#token = VoidToken;\n this.#parentUuid = undefined;\n this.#order = 0;\n this.#properties.clear();\n this.#travellingProperties = undefined;\n this.#isNew = true;\n break;\n }\n }\n\n #commitToken(token: string): void {\n this.#token = token;\n if (this.#nextToken === token) {\n this.#nextToken = undefined;\n }\n }\n\n #commitParentUuid(parentUuid: string | undefined): void {\n this.#parentUuid = parentUuid;\n if ((this.#nextParentUuid === ROOT ? undefined : this.#nextParentUuid) === parentUuid) {\n this.#nextParentUuid = undefined;\n }\n }\n\n #commitOrder(order: number): void {\n this.#order = order;\n if (this.#nextOrder === order) {\n this.#nextOrder = undefined;\n }\n }\n\n #commitProperties(properties: ComponentPropertiesType | undefined): void {\n for (const entry of properties ?? []) {\n const key = entry[0];\n // an entry that names only the key is the third form and not a removal: the written\n // half has to hold it, or the next diff reads the key as one that was never set\n const value = entry.length === 1 ? PropertyWithoutValue : entry[1];\n\n if (value === undefined) {\n this.#properties.delete(key);\n } else {\n this.#properties.set(key, value);\n }\n\n if (this.#nextProperties.get(key) === value) {\n this.#nextProperties.delete(key);\n removeFrom(this.#propsChangeOrder, key);\n }\n }\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,kBAAkB,qBAAqB,iBAAgB;AAa/D,SAAQ,aAAa,kBAAiB;AAEtC,MAAM,OAAO;AAaN,MAAM,uBAAuB,uBAAO,uCAAuC;AAuB3E,MAAM,iBAAiB;AAAA,EACnB;AAAA,EAET,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,MAAc;AACxB,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,SAAS;AAAA,EACT,eAAe;AAAA,EACf,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhB,aAAsB;AACpB,WACG,KAAK,UAAU,KAAK,aACrB,KAAK,eACJ,KAAK,eAAe,UAAa,KAAK,eAAe,KAAK,UAC3D,KAAK,kBAAkB,KACtB,KAAK,eAAe,UAAa,KAAK,eAAe,KAAK,UAC3D,KAAK,kBAAkB,SAAS,KAChC,KAAK,QAAQ,SAAS;AAAA,EAE1B;AAAA,EAEA,IAAI,QAAiB;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,YAAqB;AACvB,WAAO,KAAK,eAAe,KAAK,KAAK,eAAe,KAAK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AM,CAAC;AAEjE,UAAI,UAAU,QAAW;AACvB,aAAK,YAAY,OAAO,GAAG;AAAA,MAC7B,OAAO;AACL,aAAK,YAAY,IAAI,KAAK,KAAK;AAAA,MACjC;AAEA,UAAI,KAAK,gBAAgB,IAAI,GAAG,MAAM,OAAO;AAC3C,aAAK,gBAAgB,OAAO,GAAG;AAC/B,mBAAW,KAAK,mBAAmB,GAAG;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,24 @@
1
1
  import type { ChangeTrailType, NamespaceType } from '../types.js';
2
+ import { type ComponentState } from './ComponentMemory.js';
2
3
  import type { ViewComponent } from './ViewComponent.js';
3
4
  declare global {
4
- var __shadowEntsContexts: Map<string | symbol, ComponentContext> | undefined;
5
+ var __shadowObjectsContexts: Map<string | symbol, ComponentContext> | undefined;
6
+ }
7
+ /**
8
+ * Thrown when a {@link ViewComponent} tries to join a {@link ComponentContext} that has
9
+ * already been disposed.
10
+ */
11
+ export declare class ComponentContextDisposedError extends Error {
12
+ constructor(message?: string);
13
+ }
14
+ /**
15
+ * Thrown when a {@link ViewComponent} tries to join a {@link ComponentContext} under a uuid
16
+ * another component of that {@link ComponentContext} is holding. A uuid names one component at a
17
+ * time; it becomes free again once its holder has left.
18
+ */
19
+ export declare class ComponentUuidInUseError extends Error {
20
+ readonly uuid: string;
21
+ constructor(uuid: string);
5
22
  }
6
23
  /**
7
24
  * The {@link ComponentContext} represents the current real-time state of the _view components_.
@@ -19,18 +36,24 @@ declare global {
19
36
  *
20
37
  * A context is always associated with a namespace.
21
38
  * If no namespace is specified when creating a {@link ComponentContext}, the global namespace is used.
22
- * There is only one {@link ComponentContext} (a singleton) for each namespace.
23
- */
24
- /**
25
- * Thrown when a {@link ViewComponent} tries to join a {@link ComponentContext} that has
26
- * already been disposed.
39
+ * There is only one {@link ComponentContext} instance per namespace: the constructor returns the
40
+ * existing instance for an already-occupied namespace rather than building a second one, so
41
+ * {@link ComponentContext.get} is the way consumers are meant to reach it.
27
42
  */
28
- export declare class ComponentContextDisposedError extends Error {
29
- constructor(message?: string);
30
- }
31
43
  export declare class ComponentContext {
32
44
  #private;
33
45
  static readonly ReRequestParentRoots = "re-request-parent-roots";
46
+ static readonly ReRequestParent = "re-request-parent";
47
+ /**
48
+ * Ask the element behind a component to let the properties hanging on it look for their host
49
+ * again.
50
+ *
51
+ * A context knows nothing about `<shae-prop>` — a property has no view component and cannot be
52
+ * addressed here. The signal still belongs next to the two above: it travels the same broadcast
53
+ * channel to the same receivers, and the element on the other end is the one that can reach the
54
+ * properties below it.
55
+ */
56
+ static readonly ReRequestEntHost = "re-request-ent-host";
34
57
  static getContextsMap(): Map<NamespaceType, ComponentContext>;
35
58
  static get(namespace?: NamespaceType): ComponentContext;
36
59
  ns?: NamespaceType;
@@ -43,19 +66,47 @@ export declare class ComponentContext {
43
66
  * obtain a fresh context for the same namespace.
44
67
  */
45
68
  get isDisposed(): boolean;
69
+ /**
70
+ * Take a component in: it becomes a member of this {@link ComponentContext} and a
71
+ * `CreateEntities` change is written for its uuid.
72
+ *
73
+ * Called by the {@link ViewComponent#context} setter, and by nothing else.
74
+ *
75
+ * @throws {ComponentContextDisposedError} if this {@link ComponentContext} has been disposed
76
+ * @throws {ComponentUuidInUseError} if another member of this {@link ComponentContext} holds
77
+ * `component.uuid`
78
+ */
46
79
  addComponent(component: ViewComponent): void;
80
+ /**
81
+ * Whether `component` is a member of this {@link ComponentContext} right now.
82
+ *
83
+ * This is the question about the instance, and the only one this class answers about
84
+ * membership. A component that has left gets `false`, even while its entry is still standing —
85
+ * {@link ComponentContext.hasComponents} is what counts entries.
86
+ */
47
87
  hasComponent(component: ViewComponent): boolean;
48
88
  hasComponents(): boolean;
49
89
  isRootComponent(component: ViewComponent): boolean;
50
90
  destroyComponent(component: ViewComponent): void;
91
+ /**
92
+ * The children of `component`, in sort order — a fresh array each call, and an empty one for
93
+ * an instance that does not own its entry.
94
+ *
95
+ * Uuids without a matching view instance are skipped instead of dereferenced: `addToChildren()`
96
+ * writes a uuid into a children list without the parent link of the child following along, so
97
+ * `#deleteComponent()` has no list to take that uuid out of and the entry behind it goes while
98
+ * the list keeps naming it. `#appendToOrdered()` and `#traverseLevelOrderBFS()` read a children
99
+ * list the same way.
100
+ */
51
101
  getChildren(component: ViewComponent): ViewComponent[];
52
- removeFromParent(childUuid: string, parent: ViewComponent): void;
53
- moveToRoot(childUuid: string): void;
102
+ removeFromParent(component: ViewComponent, parent: ViewComponent): void;
103
+ moveToRoot(component: ViewComponent): void;
54
104
  changeToken(component: ViewComponent, token?: string): void;
55
105
  isChildOf(child: ViewComponent, parent: ViewComponent): boolean;
56
106
  addToChildren(parent: ViewComponent, child: ViewComponent): void;
57
107
  /**
58
108
  * Destroy a component and all its descendants without writing anything to a change trail.
109
+ * Each of them is detached from this context and reports {@link ViewComponent#isDestroyed}.
59
110
  *
60
111
  * @see {@link ComponentContext.clear}
61
112
  */
@@ -64,7 +115,48 @@ export declare class ComponentContext {
64
115
  * @returns `true` if the value differs from the last value written to a change trail
65
116
  */
66
117
  setProperty<T = unknown>(component: ViewComponent, propKey: string, value: T, isEqual?: (a: T, b: T) => boolean): boolean;
118
+ /**
119
+ * Mark `propKey` on `component` as set without giving it a value: the change trail carries
120
+ * an entry that names only the key, and the entity behind it reads the property as
121
+ * `undefined` with the key in place. {@link ComponentContext.setProperty} with `undefined`
122
+ * is the other thing — a removal.
123
+ *
124
+ * An equality rule registered for the key is forgotten, the way it is for a
125
+ * {@link ComponentContext.setProperty} that comes without one: there is no value here for a
126
+ * rule to compare.
127
+ *
128
+ * @returns `true` when this differs from the last value written to a change trail, and
129
+ * `false` for an instance that does not own its entry
130
+ */
131
+ setPropertyWithoutValue(component: ViewComponent, propKey: string): boolean;
67
132
  removeProperty(component: ViewComponent, propKey: string): void;
133
+ /**
134
+ * Hand the properties of `component` over to the context it has just joined.
135
+ *
136
+ * Called by the {@link ViewComponent#context} setter, and by nothing else. It reads the state
137
+ * this context still holds for the component: leaving a context destroys it, but the entry
138
+ * survives until the next {@link ComponentContext.buildChangeTrails}, so the properties are
139
+ * still there to be read once the join has happened.
140
+ *
141
+ * The equality function travels with each property, because it is a rule about the key and not
142
+ * about the value — the same key means the same notion of "unchanged" wherever it lives. It does
143
+ * not get to decide about the arrival, though: the target holds nothing for the key yet, so it
144
+ * would be asked whether the value equals `undefined`, and a function that says yes would drop
145
+ * the property instead of carrying it over. The value is therefore written first and the rule
146
+ * registered after it — the other way round, the write would delete the entry it just made,
147
+ * because {@link ComponentContext.setProperty} keeps only what its caller passes.
148
+ *
149
+ * What the registered rule is for: {@link ComponentContext.reCreateChanges} is its one reader,
150
+ * and it compares with it when it rebuilds a component from the memory. A later
151
+ * {@link ComponentContext.setProperty} does not consult it — it uses its own argument, or none.
152
+ *
153
+ * A property that is set without a value goes over as one: handing it on as the value
154
+ * `undefined` would have the target read it as a removal, and the key would not arrive.
155
+ *
156
+ * Built like {@link ComponentChanges.transferEventsTo}, with one difference: the properties are
157
+ * copied, not moved. What stays behind goes down with the entity in this context.
158
+ */
159
+ transferPropertiesTo(component: ViewComponent, target: ComponentContext): void;
68
160
  changeOrder(component: ViewComponent): void;
69
161
  /**
70
162
  * @returns all view-components in breadth-first order
@@ -83,26 +175,124 @@ export declare class ComponentContext {
83
175
  */
84
176
  dispatchMessage(uuid: string, type: string, data?: unknown, traverseChildren?: boolean): void;
85
177
  /**
86
- * Inform all root components that they should re-request their parents
178
+ * Inform all root components that they should re-request their parents.
179
+ *
180
+ * Every root is asked, because there is nothing here to ask about: the message carries no
181
+ * sender, so this side cannot narrow the set down at all. The receiver is the one that can:
182
+ * it re-asks the element tree, and whoever answers first wins.
183
+ *
184
+ * Delivery is immediate: the round is over by the time the call returns. Two paths inside the
185
+ * library end here — {@link ComponentContext.dispatchReRequestParentSiblings} for a component
186
+ * without a parent, whose candidate set is the roots, and the delivery of a collected round for
187
+ * that same set. What does not come this way is an entity that has just arrived: it hands its
188
+ * round to the collector below. The method is public because running a round at a moment of
189
+ * one's own choosing is what it is for.
87
190
  */
88
191
  dispatchReRequestParentRoots(): void;
192
+ /**
193
+ * Inform the children of `component` that they should re-request their parents.
194
+ *
195
+ * The receivers are the components hanging on `component` right now, and every one of them has
196
+ * to let go: the message carries no sender and needs no filter, because there is nothing here to
197
+ * decide. {@link ComponentContext.ReRequestParentRoots} is the signal for it — it means "drop
198
+ * your parent and ask again", which is what the roots happen to be asked for most often, not
199
+ * what it says.
200
+ */
201
+ dispatchReRequestParentChildren(component: ViewComponent): void;
202
+ /**
203
+ * Inform the siblings of `component` that they should re-request their parents.
204
+ *
205
+ * This narrows the candidate set for one specific question: which components could have bound
206
+ * to an ancestor further away than they should have, because `component` was not yet answering
207
+ * when they asked? Such a component sits below `component` in the element tree and shares its
208
+ * parent — any entity in between would have answered first. As long as `component` has no
209
+ * parent of its own, the roots are that same set.
210
+ *
211
+ * The signal alone does not decide anything: the receiver re-asks, and whoever answers first
212
+ * wins. Which components exist as candidates is what this method knows; whether one of them
213
+ * really sits below `component` is settled on the receiving side, which is where the element
214
+ * tree is visible — `data` is what carries the sender's identity there.
215
+ *
216
+ * The two signals differ in the order they work in, and that decides more than it looks like:
217
+ * {@link ComponentContext.ReRequestParentRoots} releases the parent before asking, so a
218
+ * component that gets the same answer back re-joins its parent's children at the end;
219
+ * {@link ComponentContext.ReRequestParent} asks first and releases only where nobody answers,
220
+ * which leaves every component that is already bound where it stands, order included.
221
+ *
222
+ * Delivery is immediate, and nothing inside the library calls it: like
223
+ * {@link ComponentContext.dispatchReRequestParentRoots} it is public so that a round can be run
224
+ * at a moment of one's own choosing.
225
+ */
226
+ dispatchReRequestParentSiblings(component: ViewComponent, data?: unknown): void;
89
227
  /**
90
228
  * Create the component change trails at this point in time.
91
229
  * The next call will only return the differences from the previous call.
92
230
  *
231
+ * @param commit whether the trail counts as applied the moment it is built. Pass `false` when
232
+ * the trail still has to travel to a Shadow Environment that may refuse it, and settle it
233
+ * afterwards with {@link ComponentContext.commitChangeTrail}.
234
+ *
235
+ * @see {@link ComponentContext.commitChangeTrail}
93
236
  * @see {@link ComponentContext.reCreateChanges}
94
237
  */
95
- buildChangeTrails(clearChanges?: boolean): ChangeTrailType;
238
+ buildChangeTrails(commit?: boolean): ChangeTrailType;
239
+ /**
240
+ * Fold the first `appliedCount` entries of the change trail this context built last into the
241
+ * state the next trail is diffed against, and write them to the Component Memory. Every entry
242
+ * behind that line stays pending and goes out again with the next trail.
243
+ *
244
+ * A component is retired -- its entry dropped -- only where the build read it as spent and every
245
+ * entry it contributed is settled. One component can hold a creation and an event in the same
246
+ * trail, and a creation sent twice is refused by the Shadow Environment, which already holds an
247
+ * entity behind that uuid.
248
+ *
249
+ * @param appliedCount how many entries the Shadow Environment applied, counted from the front.
250
+ * Clamped to the length of the trail.
251
+ * @param changeTrail the trail this call settles. Given, the call is ignored unless it is the
252
+ * very trail this context built last -- a cycle that lost its trail to a later build must not
253
+ * draw a line through that later trail.
254
+ */
255
+ commitChangeTrail(appliedCount: number, changeTrail?: ChangeTrailType): void;
256
+ /**
257
+ * Whether the Component Memory holds a state for `uuid` — the state
258
+ * {@link ComponentContext.reCreateChanges} would rebuild that component from.
259
+ */
260
+ hasComponentState(uuid: string): boolean;
261
+ /**
262
+ * The state the Component Memory holds for `uuid`, or `undefined` where it holds none.
263
+ *
264
+ * A snapshot, not the record: the property list of the record is rewritten in place as
265
+ * trails come in, so a caller holding on to it would be reading a moving value — or
266
+ * writing one. What it is a snapshot of is the memory at the moment of the call, and the
267
+ * memory moves under several hands: {@link ComponentContext.commitChangeTrail} folds a
268
+ * settled trail into it, {@link ComponentContext.buildChangeTrails} does the same for the
269
+ * trail it builds unless it is told not to commit, {@link ComponentContext.reCreateChanges}
270
+ * writes the trail it builds and empties the memory afterwards, and
271
+ * {@link ComponentContext.clear} empties it outright. A snapshot taken before any of those
272
+ * describes a state that is over; take it again to see the current one.
273
+ *
274
+ * This is the window a test or a diagnosis needs, and the one that leaves the context as it
275
+ * found it — reading the same thing out of {@link ComponentContext.reCreateChanges} costs a
276
+ * rebuild of every component in the namespace.
277
+ */
278
+ getComponentState(uuid: string): ComponentState | undefined;
96
279
  /**
97
280
  * Resets the internal component change states so that all view components are regenerated with the next change trail.
98
281
  * The outstanding events are taken over.
99
282
  *
283
+ * The trail this produces belongs to a Shadow Environment that holds none of these uuids -- a
284
+ * fresh proxy. One whose Kernel still holds them refuses the first re-created creation it reads,
285
+ * and every cycle that follows, because a uuid names one entity at a time.
286
+ *
100
287
  * @see {@link ComponentContext.buildChangeTrails}
101
288
  */
102
289
  reCreateChanges(): void;
103
290
  /**
104
- * Remove all components without writing anything to a change trail. The context stays
105
- * registered under its namespace and can be used again afterwards.
291
+ * Remove all components without writing anything to a change trail. Every
292
+ * {@link ViewComponent} this context holds is destroyed, so each of them reports
293
+ * {@link ViewComponent#isDestroyed} and holds no context afterwards. The context itself stays
294
+ * registered under its namespace and can be used again — assigning it to a component takes
295
+ * that component back in under the same uuid.
106
296
  *
107
297
  * @see {@link ComponentContext.dispose} for the final teardown
108
298
  */
@@ -116,7 +306,7 @@ export declare class ComponentContext {
116
306
  * produces empty change trails, and rejects any component that tries to join it. Calling
117
307
  * it more than once is a no-op.
118
308
  *
119
- * A {@link ShadowEnv} bound to this context keeps its reference; destroy the environment
309
+ * A `ShadowEnv` bound to this context keeps its reference; destroy the environment
120
310
  * first if you want the namespace released on both sides.
121
311
  */
122
312
  dispose(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentContext.d.ts","sourceRoot":"","sources":["../../../src/view/ComponentContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAwB,aAAa,EAAC,MAAM,aAAa,CAAC;AAKtF,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAStD,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,oBAAoB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS,CAAC;CAC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