@spearwolf/shadow-objects 0.33.0 → 0.35.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/CHANGELOG.md +350 -61
- package/README.md +66 -13
- package/bundle.js +6 -53
- package/package.json +15 -3
- package/src/ChangeTrailRefusedError.d.ts +27 -0
- package/src/ChangeTrailRefusedError.d.ts.map +1 -0
- package/src/ChangeTrailRefusedError.js +12 -0
- package/src/ChangeTrailRefusedError.js.map +7 -0
- package/src/EntityUuidInUseError.d.ts +19 -0
- package/src/EntityUuidInUseError.d.ts.map +1 -0
- package/src/EntityUuidInUseError.js +11 -0
- package/src/EntityUuidInUseError.js.map +7 -0
- package/src/WorkerTimeoutError.d.ts +26 -0
- package/src/WorkerTimeoutError.d.ts.map +1 -0
- package/src/WorkerTimeoutError.js +12 -0
- package/src/WorkerTimeoutError.js.map +7 -0
- package/src/bundle.d.ts +1 -1
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +1 -1
- package/src/bundle.js.map +2 -2
- package/src/constants.d.ts +13 -2
- package/src/constants.d.ts.map +1 -1
- package/src/constants.js +7 -1
- package/src/constants.js.map +2 -2
- package/src/create-worker.bundle.d.ts +1 -1
- package/src/create-worker.bundle.d.ts.map +1 -1
- package/src/create-worker.bundle.js.map +1 -1
- package/src/create-worker.d.ts +1 -1
- package/src/create-worker.d.ts.map +1 -1
- package/src/create-worker.js.map +1 -1
- package/src/elements/ShaeElement.d.ts +70 -2
- package/src/elements/ShaeElement.d.ts.map +1 -1
- package/src/elements/ShaeElement.js +129 -25
- package/src/elements/ShaeElement.js.map +3 -3
- package/src/elements/ShaeEntElement.d.ts +39 -1
- package/src/elements/ShaeEntElement.d.ts.map +1 -1
- package/src/elements/ShaeEntElement.js +397 -167
- package/src/elements/ShaeEntElement.js.map +2 -2
- package/src/elements/ShaeLifecycleElement.d.ts +71 -0
- package/src/elements/ShaeLifecycleElement.d.ts.map +1 -0
- package/src/elements/ShaeLifecycleElement.js +83 -0
- package/src/elements/ShaeLifecycleElement.js.map +7 -0
- package/src/elements/ShaePropElement.d.ts +61 -2
- package/src/elements/ShaePropElement.d.ts.map +1 -1
- package/src/elements/ShaePropElement.js +264 -219
- package/src/elements/ShaePropElement.js.map +2 -2
- package/src/elements/ShaeWorkerElement.d.ts +59 -5
- package/src/elements/ShaeWorkerElement.d.ts.map +1 -1
- package/src/elements/ShaeWorkerElement.js +271 -73
- package/src/elements/ShaeWorkerElement.js.map +2 -2
- package/src/elements/constants.d.ts +9 -0
- package/src/elements/constants.d.ts.map +1 -1
- package/src/elements/constants.js +18 -0
- package/src/elements/constants.js.map +2 -2
- package/src/elements/deferredTeardown.d.ts +24 -0
- package/src/elements/deferredTeardown.d.ts.map +1 -0
- package/src/elements/deferredTeardown.js +30 -0
- package/src/elements/deferredTeardown.js.map +7 -0
- package/src/elements/displayContentsRule.d.ts +25 -0
- package/src/elements/displayContentsRule.d.ts.map +1 -0
- package/src/elements/displayContentsRule.js +37 -0
- package/src/elements/displayContentsRule.js.map +7 -0
- package/src/elements/events.d.ts +10 -7
- package/src/elements/events.d.ts.map +1 -1
- package/src/elements/forwardCustomEvents.d.ts +19 -0
- package/src/elements/forwardCustomEvents.d.ts.map +1 -0
- package/src/elements/forwardCustomEvents.js +47 -0
- package/src/elements/forwardCustomEvents.js.map +7 -0
- package/src/elements/hostedSlots.d.ts +36 -0
- package/src/elements/hostedSlots.d.ts.map +1 -0
- package/src/elements/hostedSlots.js +118 -0
- package/src/elements/hostedSlots.js.map +7 -0
- package/src/elements/parentRemoval.d.ts +18 -0
- package/src/elements/parentRemoval.d.ts.map +1 -0
- package/src/elements/parentRemoval.js +60 -0
- package/src/elements/parentRemoval.js.map +7 -0
- package/src/elements/propValueConverters.d.ts +3 -0
- package/src/elements/propValueConverters.d.ts.map +1 -0
- package/src/elements/propValueConverters.js +54 -0
- package/src/elements/propValueConverters.js.map +7 -0
- package/src/elements/requestEntAncestor.d.ts +32 -0
- package/src/elements/requestEntAncestor.d.ts.map +1 -0
- package/src/elements/requestEntAncestor.js +16 -0
- package/src/elements/requestEntAncestor.js.map +7 -0
- package/src/elements.js.map +1 -1
- package/src/in-the-dark/Entity.d.ts +143 -3
- package/src/in-the-dark/Entity.d.ts.map +1 -1
- package/src/in-the-dark/Entity.js +330 -63
- package/src/in-the-dark/Entity.js.map +3 -3
- package/src/in-the-dark/Kernel.d.ts +98 -16
- package/src/in-the-dark/Kernel.d.ts.map +1 -1
- package/src/in-the-dark/Kernel.js +466 -379
- package/src/in-the-dark/Kernel.js.map +3 -3
- package/src/in-the-dark/Registry.d.ts +7 -1
- package/src/in-the-dark/Registry.d.ts.map +1 -1
- package/src/in-the-dark/Registry.js +112 -14
- package/src/in-the-dark/Registry.js.map +2 -2
- package/src/in-the-dark/ShadowObject.d.ts.map +1 -1
- package/src/in-the-dark/ShadowObject.js +1 -0
- package/src/in-the-dark/ShadowObject.js.map +2 -2
- package/src/in-the-dark/ShadowObjectCreationScope.d.ts +133 -0
- package/src/in-the-dark/ShadowObjectCreationScope.d.ts.map +1 -0
- package/src/in-the-dark/ShadowObjectCreationScope.js +603 -0
- package/src/in-the-dark/ShadowObjectCreationScope.js.map +7 -0
- package/src/in-the-dark/SignalsPath.d.ts +2 -0
- package/src/in-the-dark/SignalsPath.d.ts.map +1 -1
- package/src/in-the-dark/SignalsPath.js +6 -2
- package/src/in-the-dark/SignalsPath.js.map +2 -2
- package/src/in-the-dark/displayName.d.ts +4 -0
- package/src/in-the-dark/displayName.d.ts.map +1 -0
- package/src/in-the-dark/displayName.js +5 -0
- package/src/in-the-dark/displayName.js.map +7 -0
- package/src/in-the-dark/events.js.map +1 -1
- package/src/in-the-dark/importModule.d.ts +7 -0
- package/src/in-the-dark/importModule.d.ts.map +1 -1
- package/src/in-the-dark/importModule.js +5 -2
- package/src/in-the-dark/importModule.js.map +2 -2
- package/src/index.d.ts +9 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +9 -1
- package/src/index.js.map +2 -2
- package/src/inspect/createKernelSnapshot.d.ts +17 -0
- package/src/inspect/createKernelSnapshot.d.ts.map +1 -0
- package/src/inspect/createKernelSnapshot.js +247 -0
- package/src/inspect/createKernelSnapshot.js.map +7 -0
- package/src/inspect/createViewSnapshot.d.ts +10 -0
- package/src/inspect/createViewSnapshot.d.ts.map +1 -0
- package/src/inspect/createViewSnapshot.js +143 -0
- package/src/inspect/createViewSnapshot.js.map +7 -0
- package/src/inspect/normalizeInspectRequest.d.ts +32 -0
- package/src/inspect/normalizeInspectRequest.d.ts.map +1 -0
- package/src/inspect/normalizeInspectRequest.js +55 -0
- package/src/inspect/normalizeInspectRequest.js.map +7 -0
- package/src/inspect/serializeValue.d.ts +13 -0
- package/src/inspect/serializeValue.d.ts.map +1 -0
- package/src/inspect/serializeValue.js +149 -0
- package/src/inspect/serializeValue.js.map +7 -0
- package/src/inspect/types.d.ts +260 -0
- package/src/inspect/types.d.ts.map +1 -0
- package/src/inspect/types.js +1 -0
- package/src/inspect/types.js.map +7 -0
- package/src/model-context/ModelContextLike.d.ts +59 -0
- package/src/model-context/ModelContextLike.d.ts.map +1 -0
- package/src/model-context/ModelContextLike.js +15 -0
- package/src/model-context/ModelContextLike.js.map +7 -0
- package/src/model-context/exposeShadowEnvsToModelContext.d.ts +48 -0
- package/src/model-context/exposeShadowEnvsToModelContext.d.ts.map +1 -0
- package/src/model-context/exposeShadowEnvsToModelContext.js +39 -0
- package/src/model-context/exposeShadowEnvsToModelContext.js.map +7 -0
- package/src/model-context/redactProps.d.ts +14 -0
- package/src/model-context/redactProps.d.ts.map +1 -0
- package/src/model-context/redactProps.js +22 -0
- package/src/model-context/redactProps.js.map +7 -0
- package/src/model-context/sharedExposure.d.ts +32 -0
- package/src/model-context/sharedExposure.d.ts.map +1 -0
- package/src/model-context/sharedExposure.js +108 -0
- package/src/model-context/sharedExposure.js.map +7 -0
- package/src/model-context/toolSupport.d.ts +72 -0
- package/src/model-context/toolSupport.d.ts.map +1 -0
- package/src/model-context/toolSupport.js +145 -0
- package/src/model-context/toolSupport.js.map +7 -0
- package/src/model-context/tools/findEntities.d.ts +15 -0
- package/src/model-context/tools/findEntities.d.ts.map +1 -0
- package/src/model-context/tools/findEntities.js +71 -0
- package/src/model-context/tools/findEntities.js.map +7 -0
- package/src/model-context/tools/getEntity.d.ts +16 -0
- package/src/model-context/tools/getEntity.d.ts.map +1 -0
- package/src/model-context/tools/getEntity.js +65 -0
- package/src/model-context/tools/getEntity.js.map +7 -0
- package/src/model-context/tools/getEntityTree.d.ts +4 -0
- package/src/model-context/tools/getEntityTree.d.ts.map +1 -0
- package/src/model-context/tools/getEntityTree.js +58 -0
- package/src/model-context/tools/getEntityTree.js.map +7 -0
- package/src/model-context/tools/getRegistry.d.ts +14 -0
- package/src/model-context/tools/getRegistry.d.ts.map +1 -0
- package/src/model-context/tools/getRegistry.js +39 -0
- package/src/model-context/tools/getRegistry.js.map +7 -0
- package/src/model-context/tools/index.d.ts +9 -0
- package/src/model-context/tools/index.d.ts.map +1 -0
- package/src/model-context/tools/index.js +16 -0
- package/src/model-context/tools/index.js.map +7 -0
- package/src/model-context/tools/listEnvs.d.ts +33 -0
- package/src/model-context/tools/listEnvs.d.ts.map +1 -0
- package/src/model-context/tools/listEnvs.js +37 -0
- package/src/model-context/tools/listEnvs.js.map +7 -0
- package/src/model-context.d.ts +13 -0
- package/src/model-context.d.ts.map +1 -0
- package/src/model-context.js +15 -0
- package/src/model-context.js.map +7 -0
- package/src/shadow-objects.d.ts +4 -0
- package/src/shadow-objects.d.ts.map +1 -1
- package/src/shadow-objects.js +6 -0
- package/src/shadow-objects.js.map +2 -2
- package/src/shadow-objects.worker.js +0 -1
- package/src/shadow-objects.worker.js.map +2 -2
- package/src/shae-ent.js.map +1 -1
- package/src/shae-prop.js +2 -2
- package/src/shae-prop.js.map +2 -2
- package/src/shae-worker.js.map +1 -1
- package/src/testing/TestEntity.d.ts +79 -0
- package/src/testing/TestEntity.d.ts.map +1 -0
- package/src/testing/TestEntity.js +135 -0
- package/src/testing/TestEntity.js.map +7 -0
- package/src/testing/createTestKernel.d.ts +11 -0
- package/src/testing/createTestKernel.d.ts.map +1 -0
- package/src/testing/createTestKernel.js +132 -0
- package/src/testing/createTestKernel.js.map +7 -0
- package/src/testing/mountShadowObject.d.ts +21 -0
- package/src/testing/mountShadowObject.d.ts.map +1 -0
- package/src/testing/mountShadowObject.js +72 -0
- package/src/testing/mountShadowObject.js.map +7 -0
- package/src/testing/recordKernelErrors.d.ts +21 -0
- package/src/testing/recordKernelErrors.d.ts.map +1 -0
- package/src/testing/recordKernelErrors.js +39 -0
- package/src/testing/recordKernelErrors.js.map +7 -0
- package/src/testing/settle.d.ts +15 -0
- package/src/testing/settle.d.ts.map +1 -0
- package/src/testing/settle.js +19 -0
- package/src/testing/settle.js.map +7 -0
- package/src/testing/types.d.ts +119 -0
- package/src/testing/types.d.ts.map +1 -0
- package/src/testing/types.js +1 -0
- package/src/testing/types.js.map +7 -0
- package/src/testing.d.ts +14 -0
- package/src/testing.d.ts.map +1 -0
- package/src/testing.js +11 -0
- package/src/testing.js.map +7 -0
- package/src/types.d.ts +185 -14
- package/src/types.d.ts.map +1 -1
- package/src/utils/ConsoleLogger.d.ts +45 -10
- package/src/utils/ConsoleLogger.d.ts.map +1 -1
- package/src/utils/ConsoleLogger.js +51 -26
- package/src/utils/ConsoleLogger.js.map +2 -2
- package/src/utils/FrameLoop.d.ts +42 -3
- package/src/utils/FrameLoop.d.ts.map +1 -1
- package/src/utils/FrameLoop.js +71 -10
- package/src/utils/FrameLoop.js.map +2 -2
- package/src/utils/MicrotaskCollector.d.ts +45 -0
- package/src/utils/MicrotaskCollector.d.ts.map +1 -0
- package/src/utils/MicrotaskCollector.js +33 -0
- package/src/utils/MicrotaskCollector.js.map +7 -0
- package/src/utils/MicrotaskGate.d.ts +17 -0
- package/src/utils/MicrotaskGate.d.ts.map +1 -0
- package/src/utils/MicrotaskGate.js +20 -0
- package/src/utils/MicrotaskGate.js.map +7 -0
- package/src/utils/array-utils.js.map +1 -1
- package/src/utils/attr-utils.d.ts +11 -0
- package/src/utils/attr-utils.d.ts.map +1 -1
- package/src/utils/attr-utils.js +5 -1
- package/src/utils/attr-utils.js.map +2 -2
- package/src/utils/constants.js.map +1 -1
- package/src/utils/generateUUID.d.ts +11 -0
- package/src/utils/generateUUID.d.ts.map +1 -1
- package/src/utils/generateUUID.js +31 -266
- package/src/utils/generateUUID.js.map +2 -2
- package/src/utils/props-utils.d.ts +3 -2
- package/src/utils/props-utils.d.ts.map +1 -1
- package/src/utils/props-utils.js +13 -24
- package/src/utils/props-utils.js.map +2 -2
- package/src/utils/runGuarded.d.ts +27 -0
- package/src/utils/runGuarded.d.ts.map +1 -0
- package/src/utils/runGuarded.js +11 -0
- package/src/utils/runGuarded.js.map +7 -0
- package/src/utils/toMaybe.d.ts.map +1 -1
- package/src/utils/toMaybe.js.map +1 -1
- package/src/utils/toNamespace.d.ts.map +1 -1
- package/src/utils/toNamespace.js.map +1 -1
- package/src/utils/toUrlString.d.ts +12 -0
- package/src/utils/toUrlString.d.ts.map +1 -1
- package/src/utils/toUrlString.js.map +2 -2
- package/src/utils/waitForMessageOfType.d.ts +12 -1
- package/src/utils/waitForMessageOfType.d.ts.map +1 -1
- package/src/utils/waitForMessageOfType.js +16 -1
- package/src/utils/waitForMessageOfType.js.map +2 -2
- package/src/view/ComponentChanges.d.ts +88 -1
- package/src/view/ComponentChanges.d.ts.map +1 -1
- package/src/view/ComponentChanges.js +243 -73
- package/src/view/ComponentChanges.js.map +2 -2
- package/src/view/ComponentContext.d.ts +206 -16
- package/src/view/ComponentContext.d.ts.map +1 -1
- package/src/view/ComponentContext.js +548 -91
- package/src/view/ComponentContext.js.map +2 -2
- package/src/view/ComponentMemory.d.ts +3 -3
- package/src/view/ComponentMemory.d.ts.map +1 -1
- package/src/view/ComponentMemory.js.map +1 -1
- package/src/view/IShadowObjectEnvProxy.d.ts +38 -3
- package/src/view/IShadowObjectEnvProxy.d.ts.map +1 -1
- package/src/view/LocalShadowObjectEnv.d.ts +8 -1
- package/src/view/LocalShadowObjectEnv.d.ts.map +1 -1
- package/src/view/LocalShadowObjectEnv.js +23 -7
- package/src/view/LocalShadowObjectEnv.js.map +2 -2
- package/src/view/RemoteWorkerEnv.d.ts +108 -5
- package/src/view/RemoteWorkerEnv.d.ts.map +1 -1
- package/src/view/RemoteWorkerEnv.js +244 -77
- package/src/view/RemoteWorkerEnv.js.map +2 -2
- package/src/view/ShadowEnv.d.ts +79 -2
- package/src/view/ShadowEnv.d.ts.map +1 -1
- package/src/view/ShadowEnv.js +323 -59
- package/src/view/ShadowEnv.js.map +3 -3
- package/src/view/ViewComponent.d.ts +78 -14
- package/src/view/ViewComponent.d.ts.map +1 -1
- package/src/view/ViewComponent.js +90 -14
- package/src/view/ViewComponent.js.map +2 -2
- package/src/view/cloneChangeTrail.js.map +2 -2
- package/src/worker/MessageRouter.d.ts +14 -0
- package/src/worker/MessageRouter.d.ts.map +1 -1
- package/src/worker/MessageRouter.js +98 -15
- package/src/worker/MessageRouter.js.map +2 -2
- package/src/worker/WorkerRuntime.d.ts +22 -1
- package/src/worker/WorkerRuntime.d.ts.map +1 -1
- package/src/worker/WorkerRuntime.js +60 -8
- package/src/worker/WorkerRuntime.js.map +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/elements/parentRemoval.ts"],
|
|
4
|
+
"sourcesContent": ["interface ParentWatch {\n observer: MutationObserver;\n /** What to run for each watched child of this parent, keyed by that child. */\n watchers: Map<Node, () => void>;\n}\n\n/**\n * One `MutationObserver` per watched parent node, however many nodes are watched on it.\n *\n * A `childList` observation belongs to the observer and not to the child it was taken out\n * for: n observers on one node see every mutation of that node n times, and each of them\n * walks the whole `removedNodes` list. Emptying a list of n siblings costs n\u00B2 callback runs\n * that way. One observer per node costs one run per mutation, and the lookup behind it is\n * keyed by the removed node \u2014 a set that is small against the number of siblings.\n *\n * The map is keyed by the parent node, so an entry cannot outlive the node it belongs to.\n * What it holds are children of that node, which the node already holds itself.\n */\nconst parentWatches = new WeakMap<Node, ParentWatch>();\n\n/**\n * Take every callback whose node shows up in `mutations`' `removedNodes` out of `watch.watchers`\n * and run it.\n *\n * Taken off before it runs, and that order is the whole point: the callback decides where its\n * node is watched next, and an entry deleted afterwards would take that answer with it. It is\n * also what makes a node that appears twice in one batch \u2014 taken out, put back, taken out again \u2014\n * run its callback once. A callback runs guarded: a `MutationObserver` callback that throws\n * reaches no caller of its own, and a watcher is code this module does not own \u2014 `onParentChanged`\n * is a documented extension point, called on every watcher in the same batch whether or not one of\n * them throws.\n */\nconst dispatchRemovals = (watch: ParentWatch, mutations: MutationRecord[]): void => {\n const removed: Array<() => void> = [];\n\n for (const {removedNodes} of mutations) {\n for (const node of removedNodes) {\n const onRemoved = watch.watchers.get(node);\n if (onRemoved == null) continue;\n watch.watchers.delete(node);\n removed.push(onRemoved);\n }\n }\n\n for (const onRemoved of removed) {\n try {\n onRemoved();\n } catch (error) {\n console.error('a removal watcher failed:', error);\n }\n }\n};\n\nconst createParentWatch = (parent: Node): ParentWatch => {\n const watchers = new Map<Node, () => void>();\n\n const watch: ParentWatch = {\n observer: new MutationObserver((mutations, activeObserver) => {\n dispatchRemovals(watch, mutations);\n\n // behind the callbacks, never in front of them: one that puts its node back under this\n // same parent keeps the observation standing instead of paying for a fresh one\n if (watchers.size === 0) {\n activeObserver.disconnect();\n // a callback above can have watched this same parent again on its own, which builds a\n // second watch and replaces this one in the registry before this line runs \u2014 deleting\n // unconditionally would then throw away that live entry instead of this dead one\n if (parentWatches.get(parent) === watch) parentWatches.delete(parent);\n }\n }),\n watchers,\n };\n\n watch.observer.observe(parent, {childList: true, subtree: false, attributes: false});\n\n return watch;\n};\n\n/**\n * Run `onRemoved` once `node` is taken out of `parent`'s child list.\n *\n * A second call for the same pair replaces the callback. The watch ends the moment it fires\n * \u2014 whoever wants to go on watching says so from inside the callback.\n *\n * A shared observer can already be sitting on a `childList` record from earlier in the same task\n * \u2014 a sibling taken out a moment ago, still waiting for the microtask that delivers observer\n * callbacks. Registering `node` now must not let that stale record apply to it once delivery\n * catches up, so pending records are taken out and dispatched first, against the watchers this\n * call still finds. `node` itself is not among them yet, so it cannot be the one a stale record\n * matches \u2014 the only nodes a `takeRecords()` batch can name here are ones some earlier call\n * already put in `parent`'s child list and that have since left it again.\n */\nexport const watchForRemovalFrom = (parent: Node, node: Node, onRemoved: () => void): void => {\n let watch = parentWatches.get(parent);\n if (watch != null) {\n dispatchRemovals(watch, watch.observer.takeRecords());\n // a callback the dispatch just ran can have unwatched the last other node on this same\n // parent, which tears the watch down and drops it from the registry \u2014 resolving the watch\n // again after the dispatch, instead of trusting the one this call started with, is what\n // makes `node` land in whichever watch is live once that outside code has had its turn\n watch = parentWatches.get(parent);\n }\n if (watch == null) {\n watch = createParentWatch(parent);\n parentWatches.set(parent, watch);\n }\n watch.watchers.set(node, onRemoved);\n};\n\n/** Stop watching `node` under `parent`. A pair nobody watches is left alone. */\nexport const stopWatchingForRemovalFrom = (parent: Node, node: Node): void => {\n const watch = parentWatches.get(parent);\n if (watch == null) return;\n if (!watch.watchers.delete(node)) return;\n if (watch.watchers.size === 0) {\n watch.observer.disconnect();\n parentWatches.delete(parent);\n }\n};\n"],
|
|
5
|
+
"mappings": "AAkBA,MAAM,gBAAgB,oBAAI,QAA2B;AAcrD,MAAM,mBAAmB,CAAC,OAAoB,cAAsC;AAClF,QAAM,UAA6B,CAAC;AAEpC,aAAW,EAAC,aAAY,KAAK,WAAW;AACtC,eAAW,QAAQ,cAAc;AAC/B,YAAM,YAAY,MAAM,SAAS,IAAI,IAAI;AACzC,UAAI,aAAa,KAAM;AACvB,YAAM,SAAS,OAAO,IAAI;AAC1B,cAAQ,KAAK,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,aAAW,aAAa,SAAS;AAC/B,QAAI;AACF,gBAAU;AAAA,IACZ,SAAS,OAAO;AACd,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AACF;AAEA,MAAM,oBAAoB,CAAC,WAA8B;AACvD,QAAM,WAAW,oBAAI,IAAsB;AAE3C,QAAM,QAAqB;AAAA,IACzB,UAAU,IAAI,iBAAiB,CAAC,WAAW,mBAAmB;AAC5D,uBAAiB,OAAO,SAAS;AAIjC,UAAI,SAAS,SAAS,GAAG;AACvB,uBAAe,WAAW;AAI1B,YAAI,cAAc,IAAI,MAAM,MAAM,MAAO,eAAc,OAAO,MAAM;AAAA,MACtE;AAAA,IACF,CAAC;AAAA,IACD;AAAA,EACF;AAEA,QAAM,SAAS,QAAQ,QAAQ,EAAC,WAAW,MAAM,SAAS,OAAO,YAAY,MAAK,CAAC;AAEnF,SAAO;AACT;AAgBO,MAAM,sBAAsB,CAAC,QAAc,MAAY,cAAgC;AAC5F,MAAI,QAAQ,cAAc,IAAI,MAAM;AACpC,MAAI,SAAS,MAAM;AACjB,qBAAiB,OAAO,MAAM,SAAS,YAAY,CAAC;AAKpD,YAAQ,cAAc,IAAI,MAAM;AAAA,EAClC;AACA,MAAI,SAAS,MAAM;AACjB,YAAQ,kBAAkB,MAAM;AAChC,kBAAc,IAAI,QAAQ,KAAK;AAAA,EACjC;AACA,QAAM,SAAS,IAAI,MAAM,SAAS;AACpC;AAGO,MAAM,6BAA6B,CAAC,QAAc,SAAqB;AAC5E,QAAM,QAAQ,cAAc,IAAI,MAAM;AACtC,MAAI,SAAS,KAAM;AACnB,MAAI,CAAC,MAAM,SAAS,OAAO,IAAI,EAAG;AAClC,MAAI,MAAM,SAAS,SAAS,GAAG;AAC7B,UAAM,SAAS,WAAW;AAC1B,kBAAc,OAAO,MAAM;AAAA,EAC7B;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propValueConverters.d.ts","sourceRoot":"","sources":["../../../src/elements/propValueConverters.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAuF5D,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAEvE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { TRUTHY_VALUES } from "../utils/constants.js";
|
|
2
|
+
const words = (value) => value.split(/\W+/);
|
|
3
|
+
const fields = (value) => value.split(/\s+/);
|
|
4
|
+
const assertNumber = (value, token) => {
|
|
5
|
+
if (Number.isNaN(value)) {
|
|
6
|
+
throw new TypeError(`not a number: "${token}"`);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
const toNumber = (parse) => (value) => assertNumber(parse(value), value);
|
|
11
|
+
const toNumberList = (parse, split) => (value) => split(value).map((v) => assertNumber(parse(v), v));
|
|
12
|
+
const toRadix = (base) => toNumber((value) => parseInt(value, base));
|
|
13
|
+
const toRadixList = (base) => toNumberList((value) => parseInt(value, base), words);
|
|
14
|
+
const toNumericArray = (Ctor, split) => (value) => new Ctor(split(value).map((v) => assertNumber(Number(v), v)));
|
|
15
|
+
const toBigIntArray = (Ctor) => (value) => new Ctor(words(value).map((v) => BigInt(v)));
|
|
16
|
+
const toBoolean = (value) => TRUTHY_VALUES.has(value.toLowerCase());
|
|
17
|
+
const CONVERTER_GROUPS = [
|
|
18
|
+
[["string", "text"], (value) => value],
|
|
19
|
+
[["number"], toNumber(Number)],
|
|
20
|
+
[["bigint"], (value) => BigInt(value)],
|
|
21
|
+
[["float"], toNumber(parseFloat)],
|
|
22
|
+
[["int", "integer"], toRadix(10)],
|
|
23
|
+
[["hex", "hexadecimal"], toRadix(16)],
|
|
24
|
+
[["oct", "octal"], toRadix(8)],
|
|
25
|
+
[["bin", "binary"], toRadix(2)],
|
|
26
|
+
[["bool", "boolean"], toBoolean],
|
|
27
|
+
[["[]", "text[]", "string[]"], words],
|
|
28
|
+
[["number[]"], toNumberList(Number, fields)],
|
|
29
|
+
[["float[]"], toNumberList(parseFloat, fields)],
|
|
30
|
+
[["int[]", "integer[]"], toNumberList((value) => parseInt(value, 10), fields)],
|
|
31
|
+
[["hex[]", "hexadecimal[]"], toRadixList(16)],
|
|
32
|
+
[["oct[]", "octal[]"], toRadixList(8)],
|
|
33
|
+
[["bin[]", "binary[]"], toRadixList(2)],
|
|
34
|
+
[["bool[]", "boolean[]"], (value) => words(value).map((v) => TRUTHY_VALUES.has(v.toLowerCase()))],
|
|
35
|
+
[["int8array"], toNumericArray(Int8Array, words)],
|
|
36
|
+
[["uint8array"], toNumericArray(Uint8Array, words)],
|
|
37
|
+
[["uint8clampedarray"], toNumericArray(Uint8ClampedArray, words)],
|
|
38
|
+
[["int16array"], toNumericArray(Int16Array, words)],
|
|
39
|
+
[["uint16array"], toNumericArray(Uint16Array, words)],
|
|
40
|
+
[["int32array"], toNumericArray(Int32Array, words)],
|
|
41
|
+
[["uint32array"], toNumericArray(Uint32Array, words)],
|
|
42
|
+
[["float32array"], toNumericArray(Float32Array, fields)],
|
|
43
|
+
[["float64array"], toNumericArray(Float64Array, fields)],
|
|
44
|
+
[["bigint64array"], toBigIntArray(BigInt64Array)],
|
|
45
|
+
[["biguint64array"], toBigIntArray(BigUint64Array)],
|
|
46
|
+
[["json"], (value) => JSON.parse(value)]
|
|
47
|
+
];
|
|
48
|
+
const propValueConverters = new Map(
|
|
49
|
+
CONVERTER_GROUPS.flatMap(([names, convert]) => names.map((name) => [name, convert]))
|
|
50
|
+
);
|
|
51
|
+
export {
|
|
52
|
+
propValueConverters
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=propValueConverters.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/elements/propValueConverters.ts"],
|
|
4
|
+
"sourcesContent": ["import {TRUTHY_VALUES} from '../utils/constants.js';\n\nexport type PropValueConverter = (value: string) => unknown;\n\nconst words = (value: string): string[] => value.split(/\\W+/);\nconst fields = (value: string): string[] => value.split(/\\s+/);\n\ntype NumberParser = (value: string) => number;\ntype Splitter = (value: string) => string[];\n\n// The check sits here, ahead of every constructor: `new Int8Array([NaN])` is `[0]` and\n// `new Float32Array([NaN])` carries the `NaN` into its buffer, so once the array exists nothing\n// separates a token that could not be read from one that was meant. A numeric branch answers with\n// a number or it answers with nothing \u2014 the token is named rather than the whole attribute value,\n// so a list says which of its segments does not carry.\nconst assertNumber = (value: number, token: string): number => {\n if (Number.isNaN(value)) {\n throw new TypeError(`not a number: \"${token}\"`);\n }\n return value;\n};\n\nconst toNumber =\n (parse: NumberParser): PropValueConverter =>\n (value) =>\n assertNumber(parse(value), value);\n\nconst toNumberList =\n (parse: NumberParser, split: Splitter): PropValueConverter =>\n (value) =>\n split(value).map((v) => assertNumber(parse(v), v));\n\nconst toRadix = (base: number): PropValueConverter => toNumber((value) => parseInt(value, base));\n\nconst toRadixList = (base: number): PropValueConverter => toNumberList((value) => parseInt(value, base), words);\n\ntype NumericArrayCtor = new (values: number[]) => ArrayBufferView;\ntype BigIntArrayCtor = new (values: bigint[]) => ArrayBufferView;\n\nconst toNumericArray =\n (Ctor: NumericArrayCtor, split: Splitter): PropValueConverter =>\n (value) =>\n new Ctor(split(value).map((v) => assertNumber(Number(v), v)));\n\nconst toBigIntArray =\n (Ctor: BigIntArrayCtor): PropValueConverter =>\n (value) =>\n new Ctor(words(value).map((v) => BigInt(v)));\n\nconst toBoolean: PropValueConverter = (value) => TRUTHY_VALUES.has(value.toLowerCase());\n\n// 29 groups: the names a group serves, then the one function they share. Alias marks (e.g.\n// `int`/`integer`) point at the same function object on purpose \u2014 the identity is structural, not\n// a matter of discipline. Every row therefore builds its converter in a single call.\nconst CONVERTER_GROUPS: ReadonlyArray<readonly [readonly string[], PropValueConverter]> = [\n [['string', 'text'], (value) => value],\n [['number'], toNumber(Number)],\n [['bigint'], (value) => BigInt(value)],\n [['float'], toNumber(parseFloat)],\n [['int', 'integer'], toRadix(10)],\n [['hex', 'hexadecimal'], toRadix(16)],\n [['oct', 'octal'], toRadix(8)],\n [['bin', 'binary'], toRadix(2)],\n [['bool', 'boolean'], toBoolean],\n [['[]', 'text[]', 'string[]'], words],\n [['number[]'], toNumberList(Number, fields)],\n [['float[]'], toNumberList(parseFloat, fields)],\n [['int[]', 'integer[]'], toNumberList((value) => parseInt(value, 10), fields)],\n [['hex[]', 'hexadecimal[]'], toRadixList(16)],\n [['oct[]', 'octal[]'], toRadixList(8)],\n [['bin[]', 'binary[]'], toRadixList(2)],\n [['bool[]', 'boolean[]'], (value) => words(value).map((v) => TRUTHY_VALUES.has(v.toLowerCase()))],\n [['int8array'], toNumericArray(Int8Array, words)],\n [['uint8array'], toNumericArray(Uint8Array, words)],\n [['uint8clampedarray'], toNumericArray(Uint8ClampedArray, words)],\n [['int16array'], toNumericArray(Int16Array, words)],\n [['uint16array'], toNumericArray(Uint16Array, words)],\n [['int32array'], toNumericArray(Int32Array, words)],\n [['uint32array'], toNumericArray(Uint32Array, words)],\n [['float32array'], toNumericArray(Float32Array, fields)],\n [['float64array'], toNumericArray(Float64Array, fields)],\n [['bigint64array'], toBigIntArray(BigInt64Array)],\n [['biguint64array'], toBigIntArray(BigUint64Array)],\n [['json'], (value) => JSON.parse(value)],\n];\n\n// A `Map`, not an object literal: a type name is whatever string stands in the `type` attribute,\n// and `'toString' in {}` is `true` \u2014 an object literal would answer to inherited keys it never\n// declared.\nexport const propValueConverters: ReadonlyMap<string, PropValueConverter> = new Map(\n CONVERTER_GROUPS.flatMap(([names, convert]) => names.map((name) => [name, convert] as const)),\n);\n"],
|
|
5
|
+
"mappings": "AAAA,SAAQ,qBAAoB;AAI5B,MAAM,QAAQ,CAAC,UAA4B,MAAM,MAAM,KAAK;AAC5D,MAAM,SAAS,CAAC,UAA4B,MAAM,MAAM,KAAK;AAU7D,MAAM,eAAe,CAAC,OAAe,UAA0B;AAC7D,MAAI,OAAO,MAAM,KAAK,GAAG;AACvB,UAAM,IA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CAAC;AAAA,EAChD,CAAC,CAAC,gBAAgB,GAAG,cAAc,cAAc,CAAC;AAAA,EAClD,CAAC,CAAC,MAAM,GAAG,CAAC,UAAU,KAAK,MAAM,KAAK,CAAC;AACzC;AAKO,MAAM,sBAA+D,IAAI;AAAA,EAC9E,iBAAiB,QAAQ,CAAC,CAAC,OAAO,OAAO,MAAM,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,OAAO,CAAU,CAAC;AAC9F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { NamespaceType } from '../types.js';
|
|
2
|
+
import type { ShaeEntElement } from './ShaeEntElement.js';
|
|
3
|
+
/**
|
|
4
|
+
* The request an element sends out to find the entity above it.
|
|
5
|
+
*
|
|
6
|
+
* It travels as the `detail` of a bubbling, composed `shaeRequestEntParent` event. The first
|
|
7
|
+
* ancestor that matches calls {@link EntAncestorRequest.answer} and stops the event there, so the
|
|
8
|
+
* answer always comes from the closest match and never from more than one.
|
|
9
|
+
*/
|
|
10
|
+
export interface EntAncestorRequest {
|
|
11
|
+
/** the element asking */
|
|
12
|
+
requester: HTMLElement;
|
|
13
|
+
/** the namespace the answer has to match — `undefined` lets any ancestor answer */
|
|
14
|
+
ns?: NamespaceType;
|
|
15
|
+
/** called by the first ancestor that matches; it stops the event right afterwards */
|
|
16
|
+
answer(entNode: ShaeEntElement): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Ask the closest entity above `requester` to identify itself.
|
|
20
|
+
*
|
|
21
|
+
* The path of a composed event *is* the ascent through the flattened tree, and it is the only one
|
|
22
|
+
* that sees all of it: `assignedSlot` reports `null` at a closed boundary, so an ascent along node
|
|
23
|
+
* pointers steps from a projected node straight to the host and skips the entire closed tree —
|
|
24
|
+
* the event travels through it.
|
|
25
|
+
*
|
|
26
|
+
* Both `<shae-ent>` and `<shae-prop>` therefore send this one request, and there is exactly one
|
|
27
|
+
* place that answers it.
|
|
28
|
+
*
|
|
29
|
+
* @see https://pm.dartus.fr/blog/a-complete-guide-on-shadow-dom-and-event-propagation/
|
|
30
|
+
*/
|
|
31
|
+
export declare const requestEntAncestor: (requester: HTMLElement, request: Omit<EntAncestorRequest, 'requester'>) => void;
|
|
32
|
+
//# sourceMappingURL=requestEntAncestor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestEntAncestor.d.ts","sourceRoot":"","sources":["../../../src/elements/requestEntAncestor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,yBAAyB;IACzB,SAAS,EAAE,WAAW,CAAC;IAEvB,mFAAmF;IACnF,EAAE,CAAC,EAAE,aAAa,CAAC;IAEnB,qFAAqF;IACrF,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,cAAe,WAAW,WAAW,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,KAAG,IAU3G,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestEntParentEventName } from "./constants.js";
|
|
2
|
+
const requestEntAncestor = (requester, request) => {
|
|
3
|
+
requester.dispatchEvent(
|
|
4
|
+
new CustomEvent(RequestEntParentEventName, {
|
|
5
|
+
bubbles: true,
|
|
6
|
+
composed: true,
|
|
7
|
+
// `requester` last: the element sending the request is the one fact about it that no
|
|
8
|
+
// caller gets to overwrite, and a caller not going through TypeScript could try
|
|
9
|
+
detail: { ...request, requester }
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
requestEntAncestor
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=requestEntAncestor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/elements/requestEntAncestor.ts"],
|
|
4
|
+
"sourcesContent": ["import type {NamespaceType} from '../types.js';\nimport {RequestEntParentEventName} from './constants.js';\nimport type {ShaeEntElement} from './ShaeEntElement.js';\n\n/**\n * The request an element sends out to find the entity above it.\n *\n * It travels as the `detail` of a bubbling, composed `shaeRequestEntParent` event. The first\n * ancestor that matches calls {@link EntAncestorRequest.answer} and stops the event there, so the\n * answer always comes from the closest match and never from more than one.\n */\nexport interface EntAncestorRequest {\n /** the element asking */\n requester: HTMLElement;\n\n /** the namespace the answer has to match \u2014 `undefined` lets any ancestor answer */\n ns?: NamespaceType;\n\n /** called by the first ancestor that matches; it stops the event right afterwards */\n answer(entNode: ShaeEntElement): void;\n}\n\n/**\n * Ask the closest entity above `requester` to identify itself.\n *\n * The path of a composed event *is* the ascent through the flattened tree, and it is the only one\n * that sees all of it: `assignedSlot` reports `null` at a closed boundary, so an ascent along node\n * pointers steps from a projected node straight to the host and skips the entire closed tree \u2014\n * the event travels through it.\n *\n * Both `<shae-ent>` and `<shae-prop>` therefore send this one request, and there is exactly one\n * place that answers it.\n *\n * @see https://pm.dartus.fr/blog/a-complete-guide-on-shadow-dom-and-event-propagation/\n */\nexport const requestEntAncestor = (requester: HTMLElement, request: Omit<EntAncestorRequest, 'requester'>): void => {\n requester.dispatchEvent(\n new CustomEvent<EntAncestorRequest>(RequestEntParentEventName, {\n bubbles: true,\n composed: true,\n // `requester` last: the element sending the request is the one fact about it that no\n // caller gets to overwrite, and a caller not going through TypeScript could try\n detail: {...request, requester},\n }),\n );\n};\n"],
|
|
5
|
+
"mappings": "AACA,SAAQ,iCAAgC;AAkCjC,MAAM,qBAAqB,CAAC,WAAwB,YAAyD;AAClH,YAAU;AAAA,IACR,IAAI,YAAgC,2BAA2B;AAAA,MAC7D,SAAS;AAAA,MACT,UAAU;AAAA;AAAA;AAAA,MAGV,QAAQ,EAAC,GAAG,SAAS,UAAS;AAAA,IAChC,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/elements.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/elements.ts"],
|
|
4
|
-
"sourcesContent": ["import './shae-ent.js';\nimport './shae-prop.js';\nimport './shae-worker.js'
|
|
4
|
+
"sourcesContent": ["import './shae-ent.js';\nimport './shae-prop.js';\nimport './shae-worker.js';\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO;AACP,OAAO;AACP,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signal, type SignalReader, type SignalWriter } from '@spearwolf/signalize';
|
|
2
|
-
import type { IComponentEvent } from '../types.js';
|
|
2
|
+
import type { ComponentPropertiesType, IComponentEvent } from '../types.js';
|
|
3
3
|
import { onDestroy } from './events.js';
|
|
4
4
|
import { Kernel } from './Kernel.js';
|
|
5
5
|
type ContextNameType = string | symbol;
|
|
@@ -24,20 +24,105 @@ export declare class Entity {
|
|
|
24
24
|
get children(): readonly Entity[];
|
|
25
25
|
constructor(kernel: Kernel, uuid: string);
|
|
26
26
|
traverse(callback: (entity: Entity) => void): void;
|
|
27
|
+
/**
|
|
28
|
+
* Releases everything the entity holds: its properties, its subscriptions, its contexts and its place
|
|
29
|
+
* in the entity tree.
|
|
30
|
+
*
|
|
31
|
+
* It runs once, whichever way it is reached. The kernel reaches it directly, right behind the
|
|
32
|
+
* destruction notification it sends on the entity, so that every listener on that notification has
|
|
33
|
+
* had its turn first -- down to `Priority.Min`, which is nobody's but the caller's. The entity is
|
|
34
|
+
* not a listener on its own notification: registering it in the constructor would put it ahead of
|
|
35
|
+
* anything registered at the same priority, because eventize breaks a tie by order of registration,
|
|
36
|
+
* and the bulk `off(this)` below would then take the listeners still waiting in that delivery with
|
|
37
|
+
* it. The flag makes a second call cost nothing and keeps every step below written for a
|
|
38
|
+
* single run: `kernel.getEntity()` hands the entity to anyone, and this method is as reachable as
|
|
39
|
+
* the rest of it.
|
|
40
|
+
*
|
|
41
|
+
* The flag is raised before the first step rather than after the last, because that is what a release
|
|
42
|
+
* running twice would cost: the steps below are written for one pass, not for a repeat.
|
|
43
|
+
*
|
|
44
|
+
* Every step below runs behind a guard of its own, the way `ShadowObjectCreationScope.tearDown()`
|
|
45
|
+
* gives each of its steps one: a step that throws is reported through the kernel's logger, named by
|
|
46
|
+
* the step and by the uuid of this entity, and costs only itself -- the steps behind it still run.
|
|
47
|
+
* The method therefore never throws to its own caller. The plain resets at the end -- clearing a
|
|
48
|
+
* collection, overwriting a field -- cannot throw and run unguarded, exactly as `tearDown()` empties
|
|
49
|
+
* its own sets at the end.
|
|
50
|
+
*/
|
|
27
51
|
[onDestroy](): void;
|
|
52
|
+
/**
|
|
53
|
+
* Refuses a parent that would close the entity tree into a ring: the entity itself, or an entity that
|
|
54
|
+
* already sits below it. The walk follows the parent chain upwards, which is a chain exactly because
|
|
55
|
+
* this guard keeps it one.
|
|
56
|
+
*
|
|
57
|
+
* `Kernel.setParent()` calls it before it detaches, and the `parentUuid` setter before it resolves the
|
|
58
|
+
* link, so a refused attachment leaves the entity where it was instead of orphaned halfway through.
|
|
59
|
+
* `ViewComponent.addChild()` guards the same thing on the view side.
|
|
60
|
+
*/
|
|
61
|
+
assertAttachableTo(nextParent: Entity): void;
|
|
62
|
+
/**
|
|
63
|
+
* Puts `child` into the children list, at its place among the siblings.
|
|
64
|
+
*
|
|
65
|
+
* Nothing here notifies. Neither this method nor {@link Entity.removeChild} nor a detachment
|
|
66
|
+
* sends anything to a listener on the entity -- the one notification over a moved entity is
|
|
67
|
+
* `onParentChanged`, and `Kernel.setParent()` is the call that sends it.
|
|
68
|
+
*/
|
|
28
69
|
addChild(child: Entity): void;
|
|
29
70
|
resortChildren(): void;
|
|
30
71
|
removeChild(child: Entity): void;
|
|
31
|
-
|
|
72
|
+
/**
|
|
73
|
+
* @param rebindContexts bind every context back to the root of the entity context tree. An entity
|
|
74
|
+
* that carries a context out of a subtree keeps following the value it can still see, rather
|
|
75
|
+
* than freezing on the last one the former parent held. Only a caller that attaches the entity
|
|
76
|
+
* to the next parent in the same breath passes `false` -- that parent binds the contexts itself,
|
|
77
|
+
* and the detour over the root would be visible to `useParentContext()`, which hands out the
|
|
78
|
+
* inherited value without the microtask collector `useContext()` has in front of it.
|
|
79
|
+
*/
|
|
80
|
+
removeFromParent(rebindContexts?: boolean): void;
|
|
32
81
|
get autoDestructionOnParentRemoval(): boolean;
|
|
33
82
|
set autoDestructionOnParentRemoval(autoDestruct: boolean);
|
|
83
|
+
/**
|
|
84
|
+
* Binds every context of this entity to its current position in the entity tree -- to the parent
|
|
85
|
+
* if there is one, to the root otherwise. `addChild()` and `removeFromParent()` each do this for
|
|
86
|
+
* the entity they move, so a caller needs this only when it changed the position by other means
|
|
87
|
+
* or wants the binding re-established without knowing which of the two ran.
|
|
88
|
+
*
|
|
89
|
+
* Moving an entity through the kernel is not such a case: both directions bring their own binding,
|
|
90
|
+
* and a third one would reach every `useParentContext()` reader as another change.
|
|
91
|
+
*/
|
|
34
92
|
reSubscribeToParentContexts(): void;
|
|
35
93
|
dispatchMessageToView(type: string, data?: unknown, transferables?: Transferable[], traverseChildren?: boolean): void;
|
|
94
|
+
/**
|
|
95
|
+
* Hands the events the view sent to whoever listens on this entity, one delivery per event.
|
|
96
|
+
*
|
|
97
|
+
* Each delivery is guarded, and the reason is where this call sits: the kernel makes it from
|
|
98
|
+
* inside a change trail, on a path that builds. Unguarded, a single shadow-object that cannot cope
|
|
99
|
+
* with a single view event would leave through `Kernel.run()` and refuse the whole trail -- the
|
|
100
|
+
* same argument that puts a guard around the `onParentChanged` notification, which is a delivery
|
|
101
|
+
* on a building path as well. The guard is per event, so one that fails costs neither the events
|
|
102
|
+
* behind it nor the caller anything; `emitStrict()` inside it makes the same promise one level
|
|
103
|
+
* down, to the listeners of one event.
|
|
104
|
+
*/
|
|
36
105
|
dispatchViewEvents(events: IComponentEvent[]): void;
|
|
37
106
|
dispatchViewEvent(type: string, data: unknown): void;
|
|
38
107
|
getPropertyReader<T = unknown>(key: string): SignalReader<T>;
|
|
108
|
+
/**
|
|
109
|
+
* A write head for one property. Every write through it drops the cache behind
|
|
110
|
+
* `truthyProps()`: that cache answers `Kernel.#updateShadowObjects()`, which picks the shadow
|
|
111
|
+
* objects of this entity along the property routes of the registry, and a write the cache does
|
|
112
|
+
* not see routes the entity to a state it no longer has.
|
|
113
|
+
*
|
|
114
|
+
* What comes back is a function of the entity, not the `set` of the signal behind the property.
|
|
115
|
+
* The signalize helpers that take a signal-like -- `isSignal()`, `destroySignal()`, `touch()` --
|
|
116
|
+
* do not recognise it; `getPropertyReader()` hands out the signal's own reader for that.
|
|
117
|
+
*
|
|
118
|
+
* A fresh closure is handed out on every call rather than one cached per key: `SignalAutoMap`
|
|
119
|
+
* hands out "a fresh, live" signal for a key whose signal was destroyed from the outside, so a
|
|
120
|
+
* writer cached against the signal captured on an earlier call could end up closing over a corpse.
|
|
121
|
+
* The call sites this feeds -- `setProperty()` from a change-trail application, at most once per
|
|
122
|
+
* property that actually changed -- do not turn this into a hot path.
|
|
123
|
+
*/
|
|
39
124
|
getPropertyWriter<T = unknown>(key: string): SignalWriter<T>;
|
|
40
|
-
setProperties(properties:
|
|
125
|
+
setProperties(properties: ComponentPropertiesType): void;
|
|
41
126
|
setProperty(key: string, value: unknown): void;
|
|
42
127
|
getProperty<T = unknown>(key: string): T;
|
|
43
128
|
propKeys(): string[];
|
|
@@ -45,10 +130,65 @@ export declare class Entity {
|
|
|
45
130
|
clearTruthyPropsCache(): void;
|
|
46
131
|
truthyProps(): Set<string> | undefined;
|
|
47
132
|
hasContext(name: ContextNameType): boolean;
|
|
133
|
+
/** The names of the Entity Contexts this entity holds, used or provided. Reads only, creates none. */
|
|
134
|
+
contextNames(): ContextNameType[];
|
|
135
|
+
/**
|
|
136
|
+
* The three values behind one Entity Context of this entity: what its own providers wrote, what it
|
|
137
|
+
* inherits from the parent (or from the global chain at a root), and what `useContext(name)` reads.
|
|
138
|
+
* `hasProviders` says whether a provider feed is attached -- a value written straight into the
|
|
139
|
+
* signal from `provideContext()` counts as provided but not as a provider.
|
|
140
|
+
*
|
|
141
|
+
* `undefined` when the entity holds no context of that name; asking does not create one. The
|
|
142
|
+
* reads are plain `.value` reads and track nothing, so a call from inside an effect does not
|
|
143
|
+
* subscribe that effect to the context.
|
|
144
|
+
*/
|
|
145
|
+
describeContext(name: ContextNameType): {
|
|
146
|
+
provided: unknown;
|
|
147
|
+
inherited: unknown;
|
|
148
|
+
effective: unknown;
|
|
149
|
+
hasProviders: boolean;
|
|
150
|
+
} | undefined;
|
|
151
|
+
/** The names of the global Entity Contexts this entity contributes to. Reads only, creates none. */
|
|
152
|
+
globalContextNames(): ContextNameType[];
|
|
153
|
+
/**
|
|
154
|
+
* What this entity contributes to the kernel-wide chain of one global Entity Context: the value
|
|
155
|
+
* and the very signal that stands in the chain, so a caller holding the chain can find this entity
|
|
156
|
+
* in it by identity. `undefined` when the entity contributes nothing under that name.
|
|
157
|
+
*/
|
|
158
|
+
describeGlobalContext(name: ContextNameType): {
|
|
159
|
+
value: unknown;
|
|
160
|
+
signal: Signal<unknown>;
|
|
161
|
+
hasProviders: boolean;
|
|
162
|
+
} | undefined;
|
|
48
163
|
useContext<T = unknown>(name: ContextNameType): SignalReader<T>;
|
|
49
164
|
useParentContext<T = unknown>(name: ContextNameType): SignalReader<T>;
|
|
50
165
|
provideContext<T = unknown>(name: ContextNameType): Signal<T>;
|
|
51
166
|
provideGlobalContext<T = unknown>(name: ContextNameType): Signal<T>;
|
|
167
|
+
/**
|
|
168
|
+
* Attaches a provider signal to the context of `name` on this entity and answers with the release
|
|
169
|
+
* that detaches it again.
|
|
170
|
+
*
|
|
171
|
+
* Every provider of one name writes into the single signal that `provideContext()` hands out, so
|
|
172
|
+
* what a consumer reads is what was written last. The release therefore does two things: it cuts
|
|
173
|
+
* this feed, and it then lets a provider that is still attached write its value once more. Without
|
|
174
|
+
* that second step the context would keep whatever the departure left standing -- the `undefined`
|
|
175
|
+
* of a clearing provider, or the last value of one that opted out of it -- even though this entity
|
|
176
|
+
* still has a provider of the name that says otherwise.
|
|
177
|
+
*
|
|
178
|
+
* A value written straight into the signal from `provideContext()` is not a feed and is therefore
|
|
179
|
+
* overwritten by the next release. Feeding a value in through this method is what makes it survive
|
|
180
|
+
* one.
|
|
181
|
+
*/
|
|
182
|
+
attachContextProvider(name: ContextNameType, provider: Signal<any>): () => void;
|
|
183
|
+
/**
|
|
184
|
+
* The counterpart of {@link Entity.attachContextProvider} for the global context of `name`.
|
|
185
|
+
*
|
|
186
|
+
* Within one entity the situation is the same one: every provider feeds the single signal this
|
|
187
|
+
* entity contributes to the kernel-wide chain of that name, and a release hands the name back to a
|
|
188
|
+
* provider that stays. Across entities the chain decides on its own -- it resolves to the first
|
|
189
|
+
* entry that holds something, so an entity whose signal falls empty lets the next one through.
|
|
190
|
+
*/
|
|
191
|
+
attachGlobalContextProvider(name: ContextNameType, provider: Signal<any>): () => void;
|
|
52
192
|
}
|
|
53
193
|
export {};
|
|
54
194
|
//# sourceMappingURL=Entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/in-the-dark/Entity.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,MAAM,
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/in-the-dark/Entity.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,MAAM,EAGN,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,uBAAuB,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAG1E,OAAO,EAAC,SAAS,EAAc,MAAM,aAAa,CAAC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