@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/elements/ShaePropElement.ts"],
|
|
4
|
-
"sourcesContent": ["import {batch, createEffect, createSignal, link} from '@spearwolf/signalize';\nimport {readBooleanAttribute} from '../utils/attr-utils.js';\nimport {ConsoleLogger} from '../utils/ConsoleLogger.js';\nimport {TRUTHY_VALUES} from '../utils/constants.js';\nimport type {ViewComponent} from '../view/ViewComponent.js';\nimport {ATTR_NAME, ATTR_NO_TRIM, ATTR_TYPE, ATTR_VALUE} from './constants.js';\nimport type {ShaeEntElement} from './ShaeEntElement.js';\n\nconst findEntNode = (start: HTMLElement): ShaeEntElement | undefined => {\n let el: HTMLElement | null = start.parentElement;\n while (el) {\n if ((el as ShaeEntElement).isShaeEntElement) {\n return el as ShaeEntElement;\n }\n el = el.parentElement;\n }\n return undefined;\n};\n\nconst TYPES = new Set([\n 'string',\n 'text',\n 'number',\n 'bigint',\n 'float',\n 'int',\n 'integer',\n 'hex',\n 'hexadecimal',\n 'oct',\n 'octal',\n 'bin',\n 'binary',\n 'bool',\n 'boolean',\n '[]',\n 'text[]',\n 'string[]',\n 'number[]',\n 'float[]',\n 'int[]',\n 'integer[]',\n 'hex[]',\n 'hexadecimal[]',\n 'oct[]',\n 'octal[]',\n 'bin[]',\n 'binary[]',\n 'bool[]',\n 'boolean[]',\n 'int8array',\n 'uint8array',\n 'uint8clampedarray',\n 'int16array',\n 'uint16array',\n 'int32array',\n 'uint32array',\n 'float32array',\n 'float64array',\n 'bigint64array',\n 'biguint64array',\n 'json',\n]);\n\nexport class ShaePropElement extends HTMLElement {\n static observedAttributes = [ATTR_NAME, ATTR_VALUE, ATTR_TYPE, ATTR_NO_TRIM];\n\n readonly isShaePropElement = true;\n\n protected readonly entNode$ = createSignal<ShaeEntElement | undefined>();\n protected readonly viewComponent$ = createSignal<ViewComponent | undefined>();\n\n protected readonly name$ = createSignal<string | undefined>();\n protected readonly valueIn$ = createSignal();\n protected readonly valueOut$ = createSignal();\n protected readonly type$ = createSignal<string | undefined>();\n protected readonly shouldTrim$ = createSignal(true);\n\n protected readonly logger = new ConsoleLogger('ShaePropElement');\n\n get name(): string | undefined {\n return this.name$.value;\n }\n\n get value(): unknown {\n return this.valueOut$.value;\n }\n\n set value(val: unknown) {\n this.valueIn$.set(val);\n }\n\n get shouldTrim(): boolean {\n return this.shouldTrim$.value;\n }\n\n get entNode(): ShaeEntElement | undefined {\n return this.entNode$.value;\n }\n\n set entNode(el: ShaeEntElement | undefined) {\n this.entNode$.set(el);\n }\n\n get viewComponent(): ViewComponent | undefined {\n return this.viewComponent$.value;\n }\n\n constructor() {\n super();\n\n this.entNode$.onChange((entNode) => {\n if (entNode) {\n const con = link(entNode.viewComponent$, this.viewComponent$);\n return () => {\n con.destroy();\n };\n } else {\n this.viewComponent$.set(undefined);\n }\n });\n\n // this.viewComponent$.onChange((vc) => {\n // if (vc) {\n // console.log(`[shae-prop:\"${this.name}\"] view-component changed to`, vc?.uuid, {\n // viewComponent: vc,\n // shaeProp: this,\n // });\n // } else {\n // console.log(`[shae-prop:\"${this.name}\"] lost connection to view-component :/`, {\n // shaeProp: this,\n // });\n // }\n // });\n\n createEffect(() => {\n const vc = this.viewComponent$.get();\n if (vc) {\n const name = this.name$.get();\n if (name) {\n const value = this.valueOut$.get();\n\n if (this.logger.isDebug) {\n this.logger.debug(`[${this.name}] view-component set-property`, name, value, vc.uuid, {\n viewComponent: vc,\n shaeProp: this,\n });\n }\n\n vc.setProperty(name, value);\n\n if (this.isConnected) {\n this.entNode?.syncShadowObjects();\n }\n }\n }\n });\n\n createEffect(() => {\n const type = this.type$.get();\n const shouldTrim = this.shouldTrim$.get();\n let value = this.valueIn$.get();\n\n if (shouldTrim && typeof value === 'string') {\n value = value.trim();\n }\n\n value = value || undefined;\n\n if (value != null && typeof value === 'string' && type) {\n switch (type) {\n case 'string':\n case 'text':\n break;\n\n case 'number':\n value = Number(value);\n break;\n\n case 'bigint':\n value = BigInt(value);\n break;\n\n case 'float':\n value = parseFloat(value);\n break;\n\n case 'int':\n case 'integer':\n value = parseInt(value, 10);\n break;\n\n case 'hex':\n case 'hexadecimal':\n value = parseInt(value, 16);\n break;\n\n case 'oct':\n case 'octal':\n value = parseInt(value, 8);\n break;\n\n case 'bin':\n case 'binary':\n value = parseInt(value, 2);\n break;\n\n case 'bool':\n case 'boolean':\n value = TRUTHY_VALUES.has(value.toLowerCase());\n break;\n\n case '[]':\n case 'text[]':\n case 'string[]':\n value = value.split(/\\W+/);\n break;\n\n case 'number[]':\n value = value.split(/\\s+/).map((v) => Number(v));\n break;\n\n case 'float[]':\n value = value.split(/\\s+/).map((v) => parseFloat(v));\n break;\n\n case 'int[]':\n case 'integer[]':\n value = value.split(/\\s+/).map((v) => parseInt(v, 10));\n break;\n\n case 'hex[]':\n case 'hexadecimal[]':\n value = value.split(/\\W+/).map((v) => parseInt(v, 16));\n break;\n\n case 'oct[]':\n case 'octal[]':\n value = value.split(/\\W+/).map((v) => parseInt(v, 8));\n break;\n\n case 'bin[]':\n case 'binary[]':\n value = value.split(/\\W+/).map((v) => parseInt(v, 2));\n break;\n\n case 'bool[]':\n case 'boolean[]':\n value = value.split(/\\W+/).map((v) => TRUTHY_VALUES.has(v.toLowerCase()));\n break;\n\n case 'int8array':\n value = new Int8Array(value.split(/\\W+/).map((v) => Number(v)));\n break;\n\n case 'uint8array':\n value = new Uint8Array(value.split(/\\W+/).map((v) => Number(v)));\n break;\n\n case 'uint8clampedarray':\n value = new Uint8ClampedArray(value.split(/\\W+/).map((v) => Number(v)));\n break;\n\n case 'int16array':\n value = new Int16Array(value.split(/\\W+/).map((v) => Number(v)));\n break;\n\n case 'uint16array':\n value = new Uint16Array(value.split(/\\W+/).map((v) => Number(v)));\n break;\n\n case 'int32array':\n value = new Int32Array(value.split(/\\W+/).map((v) => Number(v)));\n break;\n\n case 'uint32array':\n value = new Uint32Array(value.split(/\\W+/).map((v) => Number(v)));\n break;\n\n case 'float32array':\n value = new Float32Array(value.split(/\\s+/).map((v) => Number(v)));\n break;\n\n case 'float64array':\n value = new Float64Array(value.split(/\\s+/).map((v) => Number(v)));\n break;\n\n case 'bigint64array':\n value = new BigInt64Array(value.split(/\\W+/).map((v) => BigInt(v)));\n break;\n\n case 'biguint64array':\n value = new BigUint64Array(value.split(/\\W+/).map((v) => BigInt(v)));\n break;\n\n case 'json':\n value = JSON.parse(value);\n break;\n\n default:\n if (this.logger.isWarn) {\n this.logger.warn(`[${this.name}] unknown type \"${type}\"`, {\n value,\n shaeProp: this,\n });\n }\n }\n }\n\n this.valueOut$.set(value);\n });\n\n batch(() => {\n this.#readNameAttribute();\n this.#readValueAttribute();\n this.#readTypeAttribute();\n this.#readNoTrimAttribute();\n });\n\n this.style.display = 'contents';\n }\n\n connectedCallback() {\n batch(() => {\n this.#findEntNode();\n this.#readNameAttribute();\n this.#readValueAttribute();\n this.#readTypeAttribute();\n this.#readNoTrimAttribute();\n });\n }\n\n attributeChangedCallback(name: string) {\n switch (name) {\n case ATTR_NAME:\n this.#readNameAttribute();\n break;\n\n case ATTR_VALUE:\n this.#readValueAttribute();\n break;\n\n case ATTR_TYPE:\n this.#readTypeAttribute();\n break;\n\n case ATTR_NO_TRIM:\n this.#readNoTrimAttribute();\n break;\n }\n }\n\n disconnectedCallback() {\n this.#disconnectFromEntNode();\n }\n\n #findEntNode = () => {\n this.entNode$.set(findEntNode(this));\n };\n\n #disconnectFromEntNode = () => {\n queueMicrotask(() => {\n if (!this.isConnected) {\n this.entNode$.set(undefined);\n }\n });\n };\n\n #readNameAttribute = () => {\n this.name$.set(this.getAttribute(ATTR_NAME)?.trim() ?? undefined);\n };\n\n #readValueAttribute = () => {\n this.valueIn$.set(this.getAttribute(ATTR_VALUE));\n };\n\n #readTypeAttribute = () => {\n let type = this.getAttribute(ATTR_TYPE)?.trim().toLowerCase();\n if (type && !TYPES.has(type)) {\n if (this.logger.isWarn) {\n this.logger.warn(`[${this.name}] unknown type \"${type}\"`, {\n shaeProp: this,\n });\n }\n type = undefined;\n }\n this.type$.set(type);\n };\n\n #readNoTrimAttribute = () => {\n this.shouldTrim$.set(!readBooleanAttribute(this, ATTR_NO_TRIM));\n };\n}"],
|
|
5
|
-
"mappings": "AAAA,SAAQ,OAAO,cAAc,cAAc,YAAW;
|
|
4
|
+
"sourcesContent": ["import {batch, createEffect, createSignal, Effect, hibernate, link} from '@spearwolf/signalize';\nimport {readBooleanAttribute} from '../utils/attr-utils.js';\nimport {ConsoleLogger} from '../utils/ConsoleLogger.js';\nimport {MicrotaskGate} from '../utils/MicrotaskGate.js';\nimport type {ViewComponent} from '../view/ViewComponent.js';\nimport {ATTR_NAME, ATTR_NO_TRIM, ATTR_TYPE, ATTR_VALUE, ReRequestEntHostEventName} from './constants.js';\nimport {propValueConverters} from './propValueConverters.js';\nimport {requestEntAncestor} from './requestEntAncestor.js';\nimport type {ShaeEntElement} from './ShaeEntElement.js';\nimport {ShaeLifecycleElement} from './ShaeLifecycleElement.js';\n\n/**\n * How many `<shae-prop>` elements declare a given name on a given view component right now.\n *\n * A property belongs to the entity, not to the element that wrote it last: two elements may\n * declare the same name, and the entity keeps the property until the last of them lets go. The\n * count is keyed the way the binding is \u2014 (view component, name) \u2014 and lives beside the elements\n * because no single one of them can answer the question.\n */\nconst declarantsPerComponent = new WeakMap<ViewComponent, Map<string, number>>();\n\nconst addDeclarant = (vc: ViewComponent, name: string) => {\n let names = declarantsPerComponent.get(vc);\n if (names == null) {\n names = new Map();\n declarantsPerComponent.set(vc, names);\n }\n names.set(name, (names.get(name) ?? 0) + 1);\n};\n\n/** @returns `true` if this was the last element declaring `name` on `vc`. */\nconst removeDeclarant = (vc: ViewComponent, name: string): boolean => {\n const names = declarantsPerComponent.get(vc);\n if (names == null) return true;\n\n const remaining = (names.get(name) ?? 1) - 1;\n if (remaining > 0) {\n names.set(name, remaining);\n return false;\n }\n\n names.delete(name);\n if (names.size === 0) {\n declarantsPerComponent.delete(vc);\n }\n return true;\n};\n\n/**\n * Sets a property on the entity above it.\n *\n * Unlike `<shae-ent>` and `<shae-worker>`, this element does not extend `ShaeElement` and has no\n * namespace of its own. It shares their lifecycle: `ShaeLifecycleElement` is the base of all three,\n * and `destroy()`, `isDestroyed`, `restore()` and `teardown()` mean the same thing on every one of\n * them. What it does not share is the layer above it. `ShaeElement` exists for elements that pick\n * an environment: their `ns` attribute names the one they live in, and what they do goes there by\n * default \u2014 `ShaeElement.syncShadowObjectsOf()` is the explicit way to reach a different one, as\n * `<shae-ent>` does on a namespace change. A property picks nothing. It belongs to the closest\n * entity above it in the flattened tree, whatever namespace that entity happens to be in \u2014\n * proximity decides, not membership. An `ns` on a `<shae-prop>` would therefore be an attribute\n * that changes no answer, and the convention both siblings follow \u2014 spreading\n * `ShaeElement.observedAttributes` into their own \u2014 would put it into `observedAttributes` for\n * every reader to trip over.\n *\n * That is also why the sync runs through the host: the environment that has to hear about a\n * property is the one the host entity lives in, and this element is the wrong place to ask.\n * `entNode.syncShadowObjects()` reaches it; a sync of this element's own would target the\n * global namespace instead \u2014 nothing happens if no environment answers to that, and if one\n * does, it still leaves the namespaced host waiting.\n *\n * The marker for this element is `isShaePropElement`, beside `isShaeEntElement` and\n * `isShaeWorkerElement`. Each names one tag for consumers and tests to check \u2014 this file's own\n * spec included \u2014 not for the host lookup itself: that is decided by `ShaeEntElement`'s\n * `#onRequestParent`, the only listener registered for the request, and it checks `requester`,\n * `answer` and `ns`, never a flag. A `<shae-prop>` never answers a host request because it never\n * listens for one, not because its marker reads differently.\n */\nexport class ShaePropElement extends ShaeLifecycleElement {\n static observedAttributes = [ATTR_NAME, ATTR_VALUE, ATTR_TYPE, ATTR_NO_TRIM];\n\n readonly isShaePropElement = true;\n\n protected readonly entNode$ = createSignal<ShaeEntElement | undefined>();\n protected readonly viewComponent$ = createSignal<ViewComponent | undefined>();\n\n protected readonly name$ = createSignal<string | undefined>();\n protected readonly valueIn$ = createSignal();\n protected readonly valueOut$ = createSignal();\n protected readonly type$ = createSignal<string | undefined>();\n protected readonly shouldTrim$ = createSignal(true);\n\n readonly #logger = new ConsoleLogger('ShaePropElement');\n\n /** The logger this element reports through: a subclass reads it and does not replace it. */\n protected get logger(): ConsoleLogger {\n return this.#logger;\n }\n\n /** Binds this element to the entity above it, and carries that entity's component through. */\n #hostBinding?: (() => void) | undefined;\n\n /** Holds the property on the entity for as long as this element declares it. */\n #declareProperty?: Effect | undefined;\n\n /** Writes the value through to the entity. */\n #writePropertyValue?: Effect | undefined;\n\n /** Turns what the attribute spells into the value the property carries. */\n #convertValue?: Effect | undefined;\n\n /** Whether the missing-host warning has already gone out for this element. */\n #reportedMissingHost = false;\n\n /** The node this element listens on for a re-request of the host, so the listener can come off the same one. */\n #reRequestHostTarget?: EventTarget | undefined;\n\n // Two terms, and they answer two different questions. `isConnected` separates an element in\n // the tree from one on its way out: a round booked before the departure has nothing left to\n // say about a position the element no longer holds. `isDestroyed` separates one that is\n // listening from one that was ended by hand and is still standing where it was \u2014 a lookup\n // running there would write `entNode$` and register the re-request listener again that the\n // teardown just took off, and the element would be listening after it let go of everything.\n // The flag is up before `teardown()` runs, so a round that comes due afterwards reads the\n // state the element is actually in.\n //\n // The test stands here and not in the gate: a `MicrotaskGate` has no way to call a booking\n // off, and that is the whole of what tells it apart from `DeferredTeardown`.\n readonly #hostLookup = new MicrotaskGate(() => {\n if (this.isConnected && !this.isDestroyed) {\n this.#findEntNode();\n }\n });\n\n get name(): string | undefined {\n return this.name$.value;\n }\n\n /**\n * Writes the `name` attribute, and `attributeChangedCallback` takes it from there: the attribute\n * is the one source the name is read from, so a write through the property and a write through\n * `setAttribute` end up in the same place and are trimmed by the same rule. A framework renderer\n * assigns every prop it finds `in` the element as a property \u2014 React 19 and Vue 3 both do \u2014 and\n * a name it cannot assign is a property that never binds.\n */\n set name(name: string | undefined) {\n const trimmed = name?.trim();\n if (!trimmed) {\n this.removeAttribute(ATTR_NAME);\n } else if (this.getAttribute(ATTR_NAME) !== trimmed) {\n this.setAttribute(ATTR_NAME, trimmed);\n }\n }\n\n get value(): unknown {\n return this.valueOut$.value;\n }\n\n set value(val: unknown) {\n this.valueIn$.set(val);\n }\n\n get shouldTrim(): boolean {\n return this.shouldTrim$.value;\n }\n\n get entNode(): ShaeEntElement | undefined {\n return this.entNode$.value;\n }\n\n set entNode(el: ShaeEntElement | undefined) {\n this.entNode$.set(el);\n }\n\n get viewComponent(): ViewComponent | undefined {\n return this.viewComponent$.value;\n }\n\n constructor() {\n super();\n\n // read with nothing listening yet: what this puts into the signals is the state the attributes\n // already spell out, and the effects read it on their first run at the first connect\n batch(() => {\n this.#readNameAttribute();\n this.#readValueAttribute();\n this.#readTypeAttribute();\n this.#readNoTrimAttribute();\n });\n }\n\n /**\n * Take up everything this element listens to.\n *\n * Called from {@link ShaePropElement.restore} and from nowhere else \u2014 that is the one place where\n * this element's subscriptions begin, at the first connect as well as after a teardown.\n */\n #subscribe(): void {\n this.#hostBinding = this.entNode$.onChange((entNode) => {\n if (entNode) {\n const con = link(entNode.viewComponent$, this.viewComponent$);\n return () => {\n con.destroy();\n };\n } else {\n this.viewComponent$.set(undefined);\n }\n });\n\n // The binding this element holds is the pair (view component, name). It ends in three ways \u2014\n // the element leaves the tree, its name changes, or it moves to another entity \u2014 and each of\n // them moves one of these two signals. The cleanup takes the property back for exactly the\n // binding that ended, which is why the three need no code of their own.\n //\n // `valueOut$` is deliberately not read here: a value change would otherwise run a removal\n // against a set of the same key on every keystroke.\n //\n // Standing before the value effect is a matter of reading order, not of behaviour: the order a\n // rename ends up with in the trail is decided in `ComponentChanges.#propsChangeOrder`, where\n // `appendToEnd` moves a key that is already queued to the back. Measured both ways, the trail\n // reads `[['x', undefined], ['y', 7]]` either way.\n this.#declareProperty = createEffect(() => {\n const vc = this.viewComponent$.get();\n const name = this.name$.get();\n\n if (vc == null || !name) return;\n\n // untracked on purpose: the host is where the sync has to go, not something this binding\n // depends on. And it is the host and not this element, because the host carries the\n // namespace \u2014 the environment holding this property is its, and nothing else knows which.\n const entNode = this.entNode$.value;\n\n addDeclarant(vc, name);\n\n return () => {\n // only the last declarant clears the property \u2014 another element may be holding the same\n // name on the same entity, and the entity is what the property belongs to\n if (removeDeclarant(vc, name)) {\n vc.removeProperty(name);\n // no `isConnected` guard, unlike the value effect below: an element that is no longer\n // connected is precisely the case this has to reach\n entNode?.syncShadowObjects();\n }\n };\n });\n\n this.#writePropertyValue = createEffect(() => {\n const vc = this.viewComponent$.get();\n if (vc) {\n const name = this.name$.get();\n if (name) {\n const value = this.valueOut$.get();\n\n this.logger.debug(`[${this.name}] view-component set-property`, name, value, vc.uuid, {\n viewComponent: vc,\n shaeProp: this,\n });\n\n vc.setProperty(name, value);\n\n if (this.isConnected) {\n this.entNode?.syncShadowObjects();\n }\n }\n }\n });\n\n this.#convertValue = createEffect(() => {\n const type = this.type$.get();\n const shouldTrim = this.shouldTrim$.get();\n let value = this.valueIn$.get();\n\n if (shouldTrim && typeof value === 'string') {\n value = value.trim();\n }\n\n // only null and undefined mean \"no value\" \u2014 0, false and the empty string are values\n value = value ?? undefined;\n\n if (typeof value === 'string' && type) {\n const convert = propValueConverters.get(type);\n if (convert != null) {\n // invalid input is an operating case for this element, not an exceptional state: it is\n // reported and clears the value instead of throwing out of a reactive effect. A numeric\n // type throws when its conversion does not come out as a number, and takes the same way\n // out of here as malformed JSON does.\n try {\n value = convert(value);\n } catch (error) {\n // reported through `error`, not `warn`: `warn` is gated behind\n // `ConsoleLogger.sharedConfig.enable`, which defaults to \"the page is served from a\n // loopback host\". A dropped property value has to stay visible in production too.\n this.logger.error(`[${this.name}] could not convert the value into the type \"${type}\"`, {\n value,\n error,\n shaeProp: this,\n });\n value = undefined;\n }\n }\n // an unrecognized type name \u2014 `convert == null` \u2014 passes the string through untouched and\n // unreported here. `type$` is `protected`; the only writer in this repository is\n // `#readTypeAttribute`, which already warns for every unknown name it sees, so this branch\n // stays silent on purpose rather than warning a second time for the same name.\n }\n\n this.valueOut$.set(value);\n });\n }\n\n /**\n * Take this element's own subscriptions up. Its half of {@link ShaeLifecycleElement.restore}.\n *\n * There is nothing to catch up on here, unlike `<shae-ent>`: `connectedCallback` reads `name`,\n * `type` and `no-trim` off the attributes, `value` where the attribute carries one, and looks the\n * host up again straight after this. So the attributes decide, and whatever was written to a\n * released element through `prop.entNode` \u2014 or through `prop.value` against a `value` attribute\n * that says something \u2014 is replaced by what the tree and the markup say. That is this element's\n * rule in and out of a teardown alike \u2014 a `<shae-prop>` reads its position on every connect \u2014 and\n * the documentation states it as the difference it is.\n */\n protected override restore(): void {\n super.restore();\n\n this.#subscribe();\n }\n\n override connectedCallback() {\n // the whole body outside any reactive context of the caller, for the reason spelled out in\n // `ShaeLifecycleElement.connectedCallback`: an `append()` inside a foreign effect would\n // otherwise own the effects taken up here, and that effect's next run would release them\n hibernate(() => {\n super.connectedCallback();\n\n batch(() => {\n this.#findEntNode();\n this.#readNameAttribute();\n // `value` is the one attribute that is read only where it carries something: a value\n // written through `prop.value` never reaches the attribute, and a renderer that assigns\n // properties before it inserts the element \u2014 every framework renderer does \u2014 would\n // otherwise see its write replaced by \"no attribute, no value\" on the way in. An attribute\n // that carries a value decides, as it does for the three others.\n if (this.#valueAttributeCarriesValue()) {\n this.#readValueAttribute();\n }\n this.#readTypeAttribute();\n this.#readNoTrimAttribute();\n });\n });\n }\n\n attributeChangedCallback(name: string) {\n switch (name) {\n case ATTR_NAME:\n this.#readNameAttribute();\n break;\n\n case ATTR_VALUE:\n this.#readValueAttribute();\n break;\n\n case ATTR_TYPE:\n this.#readTypeAttribute();\n break;\n\n case ATTR_NO_TRIM:\n this.#readNoTrimAttribute();\n break;\n }\n }\n\n override disconnectedCallback() {\n this.#stopListeningForHostChanges();\n this.#disconnectFromEntNode();\n\n // last, and the order is not a matter of taste. `#disconnectFromEntNode` queues a microtask of\n // its own that writes `entNode$`, and microtasks run in the order they were queued: booked\n // second, the teardown runs second, so the unbinding still reaches a subscription that is on\n // and the property is taken off the entity it left. The other way round the write would arrive\n // after the release and reach nobody\n super.disconnectedCallback();\n }\n\n /**\n * Release this element's own subscriptions. Its half of {@link ShaeLifecycleElement.teardown}.\n *\n * The `link()` between the host's `viewComponent$` and this element's own needs no line of its\n * own: it is built in the cleanup path of the `entNode$` subscription, and taking that\n * subscription off runs the cleanup that destroys it.\n */\n protected override teardown(): void {\n this.#stopListeningForHostChanges();\n\n this.#hostBinding?.();\n this.#hostBinding = undefined;\n\n this.#declareProperty?.destroy();\n this.#declareProperty = undefined;\n\n this.#writePropertyValue?.destroy();\n this.#writePropertyValue = undefined;\n\n this.#convertValue?.destroy();\n this.#convertValue = undefined;\n\n super.teardown();\n }\n\n // Determines the host from where the element stands right now. The request runs *without* a\n // namespace: a property belongs to the closest entity above it, whatever namespace that entity\n // is in.\n //\n // Nobody answering means there is no entity above this position, and the element says so. A\n // binding without an answer belongs to a place that is no longer there \u2014 whether the element\n // moved or the entity above it did. The cleanup on `entNode$` then takes the property off the\n // entity that no longer holds it, instead of leaving the element writing into an entity it does\n // not sit under any more.\n #findEntNode = () => {\n let found: ShaeEntElement | undefined;\n requestEntAncestor(this, {answer: (entNode) => (found = entNode)});\n\n this.entNode$.set(found);\n\n // Reported once per element, not once per request: the re-request channel repeats this very\n // lookup, so a property that never gets a host would otherwise report again on every upgrade\n // happening anywhere above it.\n //\n // The `isConnected` term is what separates \"no host\" from \"no position\": an element on its way\n // out of the tree is not missing a host.\n //\n // The limit of this report belongs next to it: `logger.warn` hangs on\n // `ConsoleLogger.sharedConfig.enable`, which means \"the page is served from a loopback host\" \u2014\n // elsewhere the case stays silent. `warn` and not `error`, because in the upgrade path this\n // framework supports by design, \"no entity above me yet\" is a state to pass through: a\n // <shae-prop> under an element whose tag is registered later reports once and finds its host\n // right afterwards.\n if (found == null && this.isConnected && !this.#reportedMissingHost) {\n this.#reportedMissingHost = true;\n this.logger.warn(`[${this.name}] no entity above this element, the property is set nowhere`, {\n shaeProp: this,\n });\n }\n\n this.#listenForHostChanges();\n };\n\n // Someone above started or stopped answering. Two things separate this from a lookup the\n // element makes on arrival, and both belong here, to the trigger \u2014 what an unanswered\n // request means is the same on either path.\n //\n // It waits a microtask: the message arrives while the tree is still moving. An entity that\n // announces its departure has left, but everything below it can be back in place before the\n // tick ends, and an ancestor answering *right now* can be one this element is about to\n // leave behind. Asking after the dust settles is asking once, about the tree that is\n // actually there.\n //\n // And it drops the question if this element has left in the meantime, for the same reason\n // `#reRequestParent` does in `ShaeEntElement`: an element that is out of the tree answers\n // nothing about its position any more. Whether its departure is a move or an end is\n // `#disconnectFromEntNode`'s to answer, one microtask later, and it is answered in one place.\n // Nothing observable turns on the test \u2014 a departing entity takes its properties with it\n // either way \u2014 so it stands as a rule, not as a measurement.\n //\n // `#hostLookup` bounds the cost: a page filling up with entities sends many messages through the\n // same ancestor chain, and the gate turns them into one lookup per microtask and per element.\n #onReRequestHost = () => {\n this.#hostLookup.schedule();\n };\n\n #listenForHostChanges = () => {\n // bound: the entity itself is on the ascent of every element that could take the property\n // away from it. Unbound: the document is the one node every such event reaches, out of any\n // tree, closed roots included\n const target: EventTarget = this.entNode$.value ?? this.ownerDocument;\n if (target === this.#reRequestHostTarget) return;\n this.#stopListeningForHostChanges();\n target.addEventListener(ReRequestEntHostEventName, this.#onReRequestHost);\n this.#reRequestHostTarget = target;\n };\n\n #stopListeningForHostChanges = () => {\n this.#reRequestHostTarget?.removeEventListener(ReRequestEntHostEventName, this.#onReRequestHost);\n this.#reRequestHostTarget = undefined;\n };\n\n #disconnectFromEntNode = () => {\n queueMicrotask(() => {\n if (!this.isConnected) {\n this.entNode$.set(undefined);\n }\n });\n };\n\n #readNameAttribute = () => {\n this.name$.set(this.getAttribute(ATTR_NAME)?.trim() ?? undefined);\n };\n\n #readValueAttribute = () => {\n // an empty value attribute means \"no value\", exactly like a missing one. Everything else\n // goes in raw: valueIn$ is the source a no-trim switch recalculates from, so whitespace\n // has to survive until the trim decides what is left of it.\n const value = this.getAttribute(ATTR_VALUE);\n this.valueIn$.set(value === null || value === '' ? undefined : value);\n };\n\n /** Whether the `value` attribute says something \u2014 absent and empty are the same \"nothing\" here. */\n #valueAttributeCarriesValue = (): boolean => {\n const value = this.getAttribute(ATTR_VALUE);\n return value !== null && value !== '';\n };\n\n #readTypeAttribute = () => {\n let type = this.getAttribute(ATTR_TYPE)?.trim().toLowerCase();\n if (type && !propValueConverters.has(type)) {\n this.logger.warn(`[${this.name}] unknown type \"${type}\"`, {\n shaeProp: this,\n });\n type = undefined;\n }\n this.type$.set(type);\n };\n\n #readNoTrimAttribute = () => {\n this.shouldTrim$.set(!readBooleanAttribute(this, ATTR_NO_TRIM));\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAQ,OAAO,cAAc,cAA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mBAAmB;AAMxB,YAAI,KAAK,4BAA4B,GAAG;AACtC,eAAK,oBAAoB;AAAA,QAC3B;AACA,aAAK,mBAAmB;AACxB,aAAK,qBAAqB;AAAA,MAC5B,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,yBAAyB,MAAc;AACrC,YAAQ,MAAM;AAAA,MACZ,KAAK;AACH,aAAK,mBAAmB;AACxB;AAAA,MAEF,KAAK;AACH,aAAK,oBAAoB;AACzB;AAAA,MAEF,KAAK;AACH,aAAK,mBAAmB;AACxB;AAAA,MAEF,KAAK;AACH,aAAK,qBAAqB;AAC1B;AAAA,IACJ;AAAA,EACF;AAAA,EAES,uBAAuB;AAC9B,SAAK,6BAA6B;AAClC,SAAK,uBAAuB;AAO5B,UAAM,qBAAqB;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASmB,WAAiB;AAClC,SAAK,6BAA6B;AAElC,SAAK,eAAe;AACpB,SAAK,eAAe;AAEpB,SAAK,kBAAkB,QAAQ;AAC/B,SAAK,mBAAmB;AAExB,SAAK,qBAAqB,QAAQ;AAClC,SAAK,sBAAsB;AAE3B,SAAK,eAAe,QAAQ;AAC5B,SAAK,gBAAgB;AAErB,UAAM,SAAS;AAAA,EACjB;AAAA,EAWA;AAAA,EAgDA;AAAA,EAIA;AAAA,EAWA;AAAA,EAKA;AAAA,EAQA;AAAA,EAIA;AAAA,EASA;AAAA,EAKA;AAAA,EAWA;AAGF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExposeHandle } from '../model-context/exposeShadowEnvsToModelContext.js';
|
|
1
2
|
import { ConsoleLogger } from '../utils/ConsoleLogger.js';
|
|
2
3
|
import { FrameLoop } from '../utils/FrameLoop.js';
|
|
3
4
|
import { ShadowEnv } from '../view/ShadowEnv.js';
|
|
@@ -12,21 +13,74 @@ export declare class ShaeWorkerElement extends ShaeElement {
|
|
|
12
13
|
static DefaultAutoSync: string;
|
|
13
14
|
readonly isShaeWorkerElement = true;
|
|
14
15
|
readonly shadowEnv: ShadowEnv;
|
|
15
|
-
|
|
16
|
+
/** The logger this element reports through. */
|
|
17
|
+
get logger(): ConsoleLogger;
|
|
16
18
|
autostart: boolean;
|
|
17
19
|
isConnected$: import("@spearwolf/signalize").Signal<boolean>;
|
|
18
20
|
autoSync$: import("@spearwolf/signalize").Signal<string>;
|
|
19
21
|
src$: import("@spearwolf/signalize").Signal<string>;
|
|
20
|
-
|
|
22
|
+
/** The `redact-props` attribute as a list of property names, read as it stands right now. */
|
|
23
|
+
get redactProps(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* This element's share of the page's model-context registration, while it has one: a promise
|
|
26
|
+
* of the `ExposeHandle`, resolving once the tools are on the platform (`available: false` where
|
|
27
|
+
* there is none) and rejecting with what `registerTool()` rejected with. `undefined` without
|
|
28
|
+
* the `expose-to-model-context` attribute, before the first connect, and after a teardown.
|
|
29
|
+
*/
|
|
30
|
+
get modelContextExposure(): Promise<ExposeHandle> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Take the subscriptions up. Runs exactly once for this element, on the first connect.
|
|
33
|
+
*
|
|
34
|
+
* The return that `restore()` stands for on `<shae-ent>` and `<shae-prop>` does not exist here:
|
|
35
|
+
* `connectedCallback` turns a torn-down `<shae-worker>` away, so nothing ever calls this a second
|
|
36
|
+
* time.
|
|
37
|
+
*
|
|
38
|
+
* One path runs ahead of it, and it is the only one: `start()` is public, and an element started
|
|
39
|
+
* by hand while it is out of the document builds its environment before anything below is
|
|
40
|
+
* listening. Two things are lost there and stay lost, because both are moments rather than
|
|
41
|
+
* values, and there is no honest way to replay a moment that has passed:
|
|
42
|
+
*
|
|
43
|
+
* - the `contextcreated` — and, should the environment lose its connection first, the
|
|
44
|
+
* `contextlost` — DOM event for that environment. `ShadowEnv.ContextCreated` fires once, with
|
|
45
|
+
* nobody on the element listening for it; re-dispatching it from here would announce as new an
|
|
46
|
+
* environment that has been up for a while.
|
|
47
|
+
* - the namespace the environment points at, where `ns` changed between that `start()` and the
|
|
48
|
+
* first connect. `start()` resolves the view once with `??=`, the binding below only reacts to
|
|
49
|
+
* *changes*, and the change already happened. `shadowEnv.view` then names the context of the
|
|
50
|
+
* namespace the element carried when it was started. A write of `ns` after the first connect
|
|
51
|
+
* moves it, as it always does.
|
|
52
|
+
*
|
|
53
|
+
* A `<shae-worker>` that connects before it starts — the ordinary way, and the only way the
|
|
54
|
+
* declarative form has — meets neither. The import of `src` is the one case of this shape that
|
|
55
|
+
* *is* caught up, at the end of this method, because a pending import is a value and not a
|
|
56
|
+
* moment.
|
|
57
|
+
*/
|
|
58
|
+
protected restore(): void;
|
|
21
59
|
get shouldAutostart(): boolean;
|
|
22
|
-
get autoSync():
|
|
23
|
-
set autoSync(val:
|
|
60
|
+
get autoSync(): string | boolean | number;
|
|
61
|
+
set autoSync(val: string | boolean | number);
|
|
24
62
|
get frameLoop(): FrameLoop;
|
|
25
63
|
importScript(src: URL | string): Promise<ShaeWorkerElement>;
|
|
26
64
|
connectedCallback(): void;
|
|
27
65
|
disconnectedCallback(): void;
|
|
28
66
|
attributeChangedCallback(name: string): void;
|
|
29
67
|
start(): Promise<ShadowEnv>;
|
|
30
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Tear this element down — for good.
|
|
70
|
+
*
|
|
71
|
+
* The effects and signals below belong to the element alone, so the element is what decides
|
|
72
|
+
* whether they have already been released; the guard for that sits in
|
|
73
|
+
* `ShaeLifecycleElement.destroy()`, which has already set the flag by the time this runs. Here
|
|
74
|
+
* that matters more than anywhere else: `shadowEnv.destroy()` dispatches a `contextlost`
|
|
75
|
+
* `CustomEvent` on this element on its way out, and a listener on it that reaches back into
|
|
76
|
+
* `destroy()` finds the flag down and turns around instead of tearing the same environment down
|
|
77
|
+
* a second time.
|
|
78
|
+
*
|
|
79
|
+
* Unlike `<shae-ent>` and `<shae-prop>`, this teardown is final: it destroys the signals and
|
|
80
|
+
* takes the environment down with them, and neither comes back. `connectedCallback` turns a
|
|
81
|
+
* returning element away rather than handing it a half of what it had, which is what makes
|
|
82
|
+
* {@link ShaeWorkerElement.restore} a method that runs once and never again.
|
|
83
|
+
*/
|
|
84
|
+
protected teardown(): void;
|
|
31
85
|
}
|
|
32
86
|
//# sourceMappingURL=ShaeWorkerElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShaeWorkerElement.d.ts","sourceRoot":"","sources":["../../../src/elements/ShaeWorkerElement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShaeWorkerElement.d.ts","sourceRoot":"","sources":["../../../src/elements/ShaeWorkerElement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oDAAoD,CAAC;AAErF,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAIhD,OAAO,EAAC,SAAS,EAA0B,MAAM,sBAAsB,CAAC;AAgBxE,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AA6B7C,qBAAa,iBAAkB,SAAQ,WAAW;;IAiNhD;;OAEG;IACH,CAAC,SAAS,CAAC,OAAO,CAAC;IAnNnB,OAAgB,kBAAkB,WAOhC;IAEF,MAAM,CAAC,eAAe,SAAW;IAEjC,QAAQ,CAAC,mBAAmB,QAAQ;IAEpC,QAAQ,CAAC,SAAS,YAAmB;IAIrC,+CAA+C;IAC/C,IAAI,MAAM,IAAI,aAAa,CAE1B;IAED,SAAS,UAAQ;IAEjB,YAAY,iDAAuB;IACnC,SAAS,gDAAmD;IAC5D,IAAI,gDAAoB;IASxB,6FAA6F;IAC7F,IAAI,WAAW,IAAI,MAAM,EAAE,CAE1B;IAED;;;;;OAKG;IACH,IAAI,oBAAoB,IAAI,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,CAE5D;IAWD;;;;;;;;;;;;;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