@ecopages/radiant 0.3.0-alpha.8 → 0.3.0-beta.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/dist/README.md +315 -0
- package/dist/client/app-bootstrap.d.ts +19 -0
- package/dist/client/app-bootstrap.js +3 -0
- package/dist/client/app-bootstrap.js.map +10 -0
- package/dist/context/decorators/consume-context.js +2 -2
- package/dist/context/decorators/consume-context.js.map +4 -4
- package/dist/context/decorators/context-selector.js +2 -2
- package/dist/context/decorators/context-selector.js.map +8 -7
- package/dist/context/decorators/legacy/consume-context.js +2 -2
- package/dist/context/decorators/legacy/consume-context.js.map +4 -4
- package/dist/context/decorators/legacy/context-selector-field.js +2 -2
- package/dist/context/decorators/legacy/context-selector-field.js.map +4 -4
- package/dist/context/decorators/legacy/context-selector.js +2 -2
- package/dist/context/decorators/legacy/context-selector.js.map +4 -4
- package/dist/context/decorators/legacy/provide-context.js +2 -2
- package/dist/context/decorators/legacy/provide-context.js.map +4 -4
- package/dist/context/decorators/on-context-update.js +2 -2
- package/dist/context/decorators/on-context-update.js.map +4 -4
- package/dist/context/decorators/provide-context.js +2 -2
- package/dist/context/decorators/provide-context.js.map +4 -4
- package/dist/context/decorators/standard-legacy-dispatch.d.ts +6 -0
- package/dist/context/decorators/standard-legacy-dispatch.js +3 -0
- package/dist/context/decorators/standard-legacy-dispatch.js.map +10 -0
- package/dist/context/index.js +2 -2
- package/dist/context/index.js.map +11 -10
- package/dist/controller-registry.js +2 -2
- package/dist/controller-registry.js.map +3 -3
- package/dist/core/event-subscription-registry.d.ts +16 -0
- package/dist/core/event-subscription-registry.js +3 -0
- package/dist/core/event-subscription-registry.js.map +10 -0
- package/dist/core/host-ssr-registry.d.ts +13 -0
- package/dist/core/host-ssr-registry.js +3 -0
- package/dist/core/host-ssr-registry.js.map +10 -0
- package/dist/core/hydration-capable-host.d.ts +8 -0
- package/dist/core/hydration-capable-host.js +3 -0
- package/dist/core/hydration-capable-host.js.map +10 -0
- package/dist/core/radiant-controller.d.ts +36 -15
- package/dist/core/radiant-controller.js +2 -2
- package/dist/core/radiant-controller.js.map +13 -6
- package/dist/core/{radiant-component-ssr.d.ts → radiant-element-ssr-host.d.ts} +16 -16
- package/dist/core/radiant-element-ssr-host.js +3 -0
- package/dist/core/radiant-element-ssr-host.js.map +10 -0
- package/dist/core/radiant-element-ssr-registry.d.ts +18 -0
- package/dist/core/radiant-element-ssr-registry.js +3 -0
- package/dist/core/radiant-element-ssr-registry.js.map +10 -0
- package/dist/core/radiant-element.d.ts +38 -138
- package/dist/core/radiant-element.js +2 -2
- package/dist/core/radiant-element.js.map +21 -10
- package/dist/core/reactive-host.d.ts +3 -16
- package/dist/core/reactive-host.js +2 -2
- package/dist/core/reactive-host.js.map +7 -4
- package/dist/core/reactive-jsx-value.d.ts +2 -1
- package/dist/core/reactive-jsx-value.js.map +2 -2
- package/dist/core/reactive-prop-core.d.ts +44 -0
- package/dist/core/reactive-prop-core.js +3 -0
- package/dist/core/reactive-prop-core.js.map +11 -0
- package/dist/core/reactive-prop-metadata.d.ts +1 -1
- package/dist/core/reactive-prop-metadata.js +2 -2
- package/dist/core/reactive-prop-metadata.js.map +2 -2
- package/dist/core/reactive-property-state.d.ts +17 -0
- package/dist/core/reactive-property-state.js +3 -0
- package/dist/core/reactive-property-state.js.map +12 -0
- package/dist/core/reactivity-adapter.d.ts +8 -0
- package/dist/core/reactivity-adapter.js +3 -0
- package/dist/core/reactivity-adapter.js.map +12 -0
- package/dist/core/reactivity-contract.d.ts +39 -0
- package/dist/core/reactivity-contract.js +2 -0
- package/dist/core/reactivity-contract.js.map +9 -0
- package/dist/core/reactivity-runtime.d.ts +18 -0
- package/dist/core/reactivity-runtime.js +3 -0
- package/dist/core/reactivity-runtime.js.map +11 -0
- package/dist/core/reactivity-signals.d.ts +10 -0
- package/dist/core/reactivity-signals.js +3 -0
- package/dist/core/reactivity-signals.js.map +10 -0
- package/dist/core/render-runtime.d.ts +28 -0
- package/dist/core/render-runtime.js +3 -0
- package/dist/core/render-runtime.js.map +16 -0
- package/dist/core/render-scheduler.d.ts +22 -0
- package/dist/core/render-scheduler.js +3 -0
- package/dist/core/render-scheduler.js.map +10 -0
- package/dist/core/slot-projection-runtime.js +2 -2
- package/dist/core/slot-projection-runtime.js.map +3 -3
- package/dist/decorators/attr.js +2 -2
- package/dist/decorators/attr.js.map +6 -5
- package/dist/decorators/controller.js +2 -2
- package/dist/decorators/controller.js.map +3 -3
- package/dist/decorators/event.js +2 -2
- package/dist/decorators/event.js.map +3 -3
- package/dist/decorators/legacy/attr.js +2 -2
- package/dist/decorators/legacy/attr.js.map +6 -5
- package/dist/decorators/legacy/event.js +2 -2
- package/dist/decorators/legacy/event.js.map +3 -3
- package/dist/decorators/legacy/host-readiness.d.ts +8 -0
- package/dist/decorators/legacy/host-readiness.js +3 -0
- package/dist/decorators/legacy/host-readiness.js.map +11 -0
- package/dist/decorators/legacy/instance-initializers.d.ts +16 -0
- package/dist/decorators/legacy/instance-initializers.js +2 -2
- package/dist/decorators/legacy/instance-initializers.js.map +3 -3
- package/dist/decorators/legacy/on-event.js +2 -2
- package/dist/decorators/legacy/on-event.js.map +6 -5
- package/dist/decorators/legacy/on-updated.d.ts +1 -1
- package/dist/decorators/legacy/on-updated.js +2 -2
- package/dist/decorators/legacy/on-updated.js.map +4 -4
- package/dist/decorators/legacy/query-slot.js +2 -2
- package/dist/decorators/legacy/query-slot.js.map +5 -5
- package/dist/decorators/legacy/query.js +2 -2
- package/dist/decorators/legacy/query.js.map +3 -3
- package/dist/decorators/legacy/reactive-field.js +2 -2
- package/dist/decorators/legacy/reactive-field.js.map +3 -3
- package/dist/decorators/legacy/reactive-prop.d.ts +1 -1
- package/dist/decorators/legacy/reactive-prop.js +2 -2
- package/dist/decorators/legacy/reactive-prop.js.map +7 -6
- package/dist/decorators/legacy/signal.d.ts +1 -1
- package/dist/decorators/legacy/signal.js +2 -2
- package/dist/decorators/legacy/signal.js.map +6 -5
- package/dist/decorators/on-event.js +2 -2
- package/dist/decorators/on-event.js.map +6 -5
- package/dist/decorators/on-updated.js +2 -2
- package/dist/decorators/on-updated.js.map +4 -4
- package/dist/decorators/prop.d.ts +1 -1
- package/dist/decorators/prop.js +2 -2
- package/dist/decorators/prop.js.map +9 -8
- package/dist/decorators/query-slot.js +2 -2
- package/dist/decorators/query-slot.js.map +6 -6
- package/dist/decorators/query.js +2 -2
- package/dist/decorators/query.js.map +3 -3
- package/dist/decorators/shared/reactive-attr.d.ts +1 -1
- package/dist/decorators/shared/reactive-attr.js +2 -2
- package/dist/decorators/shared/reactive-attr.js.map +5 -4
- package/dist/decorators/signal.js +2 -2
- package/dist/decorators/signal.js.map +7 -6
- package/dist/decorators/standard/attr.js +2 -2
- package/dist/decorators/standard/attr.js.map +5 -4
- package/dist/decorators/standard/on-event.js +2 -2
- package/dist/decorators/standard/on-event.js.map +5 -4
- package/dist/decorators/standard/query-slot.d.ts +0 -1
- package/dist/decorators/standard/query-slot.js +2 -2
- package/dist/decorators/standard/query-slot.js.map +4 -4
- package/dist/decorators/standard/reactive-field.js +2 -2
- package/dist/decorators/standard/reactive-field.js.map +3 -3
- package/dist/decorators/standard/reactive-prop.d.ts +1 -1
- package/dist/decorators/standard/reactive-prop.js +2 -2
- package/dist/decorators/standard/reactive-prop.js.map +6 -5
- package/dist/decorators/standard/signal.d.ts +1 -1
- package/dist/decorators/standard/signal.js +2 -2
- package/dist/decorators/standard/signal.js.map +5 -4
- package/dist/decorators/state.js +2 -2
- package/dist/decorators/state.js.map +4 -4
- package/dist/helpers/create-event-listener.js +2 -2
- package/dist/helpers/create-event-listener.js.map +5 -4
- package/dist/helpers/create-query-slot.d.ts +0 -1
- package/dist/helpers/create-query-slot.js +2 -2
- package/dist/helpers/create-query-slot.js.map +3 -3
- package/dist/helpers/index.js +2 -2
- package/dist/helpers/index.js.map +6 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +37 -25
- package/dist/package.json +209 -0
- package/dist/server/host-attribute-serialization.d.ts +46 -0
- package/dist/server/host-attribute-serialization.js +3 -0
- package/dist/server/host-attribute-serialization.js.map +12 -0
- package/dist/server/host-script-composition.d.ts +42 -0
- package/dist/server/host-script-composition.js +3 -0
- package/dist/server/host-script-composition.js.map +10 -0
- package/dist/server/install-light-dom-shim.js +2 -2
- package/dist/server/install-light-dom-shim.js.map +3 -3
- package/dist/server/internal-radiant-host.d.ts +2 -0
- package/dist/server/internal-radiant-host.js +3 -0
- package/dist/server/internal-radiant-host.js.map +9 -0
- package/dist/server/light-dom-shim.d.ts +9 -0
- package/dist/server/light-dom-shim.js +2 -2
- package/dist/server/light-dom-shim.js.map +3 -3
- package/dist/server/radiant-element-ssr-bridge.d.ts +21 -0
- package/dist/server/radiant-element-ssr-bridge.js +3 -0
- package/dist/server/radiant-element-ssr-bridge.js.map +24 -0
- package/dist/server/radiant-element-ssr-extractor.d.ts +2 -0
- package/dist/server/radiant-element-ssr-extractor.js +3 -0
- package/dist/server/radiant-element-ssr-extractor.js.map +12 -0
- package/dist/server/radiant-element-ssr-service.d.ts +13 -0
- package/dist/server/radiant-element-ssr-service.js +3 -0
- package/dist/server/radiant-element-ssr-service.js.map +22 -0
- package/dist/server/radiant-element-ssr.d.ts +1 -0
- package/dist/server/radiant-element-ssr.js +3 -0
- package/dist/server/radiant-element-ssr.js.map +24 -0
- package/dist/server/render-component.d.ts +3 -9
- package/dist/server/render-component.js +2 -2
- package/dist/server/render-component.js.map +17 -9
- package/dist/server/render-controller.js +2 -2
- package/dist/server/render-controller.js.map +19 -11
- package/dist/server/render-fragment.d.ts +7 -0
- package/dist/server/render-fragment.js +3 -0
- package/dist/server/render-fragment.js.map +10 -0
- package/dist/server/slot-projection-html.js +2 -2
- package/dist/server/slot-projection-html.js.map +3 -3
- package/dist/tools/escape-css-identifier.d.ts +1 -0
- package/dist/tools/escape-css-identifier.js +3 -0
- package/dist/tools/escape-css-identifier.js.map +10 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +2 -2
- package/dist/tools/index.js.map +4 -3
- package/dist/utils/escape-html-attribute.d.ts +2 -0
- package/dist/utils/escape-html-attribute.js +3 -0
- package/dist/utils/escape-html-attribute.js.map +10 -0
- package/package.json +12 -5
- package/dist/core/radiant-component-ssr-registry.d.ts +0 -54
- package/dist/core/radiant-component-ssr-registry.js +0 -3
- package/dist/core/radiant-component-ssr-registry.js.map +0 -10
- package/dist/core/radiant-component-ssr.js +0 -3
- package/dist/core/radiant-component-ssr.js.map +0 -14
- package/dist/server/radiant-component-ssr-runtime.d.ts +0 -9
- package/dist/server/radiant-component-ssr-runtime.js +0 -3
- package/dist/server/radiant-component-ssr-runtime.js.map +0 -17
- package/size-budget.json +0 -25
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/decorators/bridge.ts", "../src/tools/event-emitter.ts", "../src/helpers/create-event.ts", "../src/decorators/legacy/event.ts", "../src/decorators/standard/event.ts", "../src/decorators/event.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\
|
|
5
|
+
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\nconst LEGACY_POST_CONSTRUCTION_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-post-construction-initializers');\nconst LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS = Symbol.for(\n\t'@ecopages/radiant.legacy-executed-post-construction-initializers',\n);\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_INSTANCE_INITIALIZERS, initializer);\n}\n\n/**\n * Registers post-construction work for a legacy decorator.\n *\n * This phase exists for decorators that eagerly write instance fields. With\n * legacy decorators plus `useDefineForClassFields`, subclass field definition\n * can overwrite values written during the base-class constructor.\n */\nexport function registerLegacyPostConstructionInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_POST_CONSTRUCTION_INITIALIZERS, initializer);\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\trunLegacyInitializers(instance, LEGACY_INSTANCE_INITIALIZERS);\n}\n\n/**\n * Runs legacy decorator setup that must happen after subclass field\n * initialization has completed.\n *\n * Each initializer runs at most once per instance even if multiple lifecycle\n * entrypoints call this helper.\n */\nexport function runLegacyPostConstructionInitializers<T extends object>(instance: T): void {\n\tconst target = instance as Record<PropertyKey, unknown>;\n\n\trunLegacyInitializers(\n\t\tinstance,\n\t\tLEGACY_POST_CONSTRUCTION_INITIALIZERS,\n\t\t(target[LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS] ??= new Set()) as Set<LegacyInstanceInitializer<T>>,\n\t);\n}\n\nfunction registerInitializer<T extends object>(proto: T, key: symbol, initializer: LegacyInstanceInitializer<T>): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = Object.prototype.hasOwnProperty.call(target, key) ? target[key] : undefined;\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(target, key, {\n\t\tvalue: [initializer],\n\t});\n}\n\nfunction runLegacyInitializers<T extends object>(\n\tinstance: T,\n\tkey: symbol,\n\texecutedInitializers?: Set<LegacyInstanceInitializer<T>>,\n\tprototype: object | null = Object.getPrototypeOf(instance),\n): void {\n\tif (!prototype || prototype === Object.prototype) {\n\t\treturn;\n\t}\n\n\trunLegacyInitializers(instance, key, executedInitializers, Object.getPrototypeOf(prototype));\n\n\tconst initializers = (prototype as Record<PropertyKey, unknown>)[key] as LegacyInstanceInitializer<T>[] | undefined;\n\n\tif (!Array.isArray(initializers)) {\n\t\treturn;\n\t}\n\n\tfor (const initializer of initializers) {\n\t\tif (executedInitializers?.has(initializer)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tinitializer(instance);\n\t\texecutedInitializers?.add(initializer);\n\t}\n}\n",
|
|
6
6
|
"import type { Method } from '../types';\n\ntype StandardFieldFn<Host extends object, Value, Result> = (\n\ttarget: undefined,\n\tcontext: ClassFieldDecoratorContext<Host, Value>,\n) => Result;\n\ntype LegacyFieldFn<Proto, Result> = (proto: Proto, name: string) => Result;\n\ntype StandardMethodFn<Host extends object, TMethod extends Method, Result> = (\n\ttarget: TMethod,\n\tcontext: ClassMethodDecoratorContext<Host, TMethod>,\n) => Result;\n\ntype LegacyMethodFn<Proto, Result> = (proto: Proto, name: string, descriptor: PropertyDescriptor) => Result;\n\nfunction isMethod(value: unknown): value is Method {\n\treturn typeof value === 'function';\n}\n\nexport function fieldDecoratorBridge<Host extends object, Value, Result, Proto>(\n\tstandard: StandardFieldFn<Host, Value, Result>,\n\tlegacy: LegacyFieldFn<Proto, void>,\n\tprotoOrTarget: undefined,\n\tnameOrContext: ClassFieldDecoratorContext<Host, Value>,\n): Result;\nexport function fieldDecoratorBridge<Host extends object, Value, Proto, Result>(\n\tstandard: StandardFieldFn<Host, Value, void>,\n\tlegacy: LegacyFieldFn<Proto, Result>,\n\tprotoOrTarget: Proto,\n\tnameOrContext: string,\n): Result;\nexport function fieldDecoratorBridge<Host extends object, Value, StandardResult, Proto, LegacyResult>(\n\tstandard: StandardFieldFn<Host, Value, StandardResult>,\n\tlegacy: LegacyFieldFn<Proto, LegacyResult>,\n\tprotoOrTarget: Proto | undefined,\n\tnameOrContext: string | ClassFieldDecoratorContext<Host, Value>,\n): StandardResult | LegacyResult;\n\nexport function fieldDecoratorBridge(\n\tstandard: StandardFieldFn<object, unknown, unknown>,\n\tlegacy: LegacyFieldFn<unknown, unknown>,\n\tprotoOrTarget: unknown,\n\tnameOrContext: string | ClassFieldDecoratorContext<object, unknown>,\n): unknown {\n\tif (typeof nameOrContext === 'object') {\n\t\treturn standard(undefined, nameOrContext);\n\t}\n\n\treturn legacy(protoOrTarget, nameOrContext);\n}\n\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, Result, Proto>(\n\tstandard: StandardMethodFn<Host, TMethod, Result>,\n\tlegacy: LegacyMethodFn<Proto, void>,\n\tprotoOrTarget: TMethod,\n\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\tdescriptor?: undefined,\n): Result;\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, Proto, Result>(\n\tstandard: StandardMethodFn<Host, TMethod, void>,\n\tlegacy: LegacyMethodFn<Proto, Result>,\n\tprotoOrTarget: Proto,\n\tnameOrContext: string,\n\tdescriptor: PropertyDescriptor,\n): Result;\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, StandardResult, Proto, LegacyResult>(\n\tstandard: StandardMethodFn<Host, TMethod, StandardResult>,\n\tlegacy: LegacyMethodFn<Proto, LegacyResult>,\n\tprotoOrTarget: Proto | TMethod,\n\tnameOrContext: string | ClassMethodDecoratorContext<Host, TMethod>,\n\tdescriptor?: PropertyDescriptor,\n): StandardResult | LegacyResult;\n\nexport function methodDecoratorBridge(\n\tstandard: StandardMethodFn<object, Method, unknown>,\n\tlegacy: LegacyMethodFn<unknown, unknown>,\n\tprotoOrTarget: unknown,\n\tnameOrContext: string | ClassMethodDecoratorContext<object, Method>,\n\tdescriptor?: PropertyDescriptor,\n): unknown {\n\tif (typeof nameOrContext === 'object') {\n\t\tif (!isMethod(protoOrTarget)) {\n\t\t\tthrow new TypeError('Standard method decorators require a method target');\n\t\t}\n\n\t\treturn standard(protoOrTarget, nameOrContext);\n\t}\n\n\tif (!descriptor) {\n\t\tthrow new TypeError('Legacy method decorators require a property descriptor');\n\t}\n\n\treturn legacy(protoOrTarget, nameOrContext, descriptor);\n}\n",
|
|
7
7
|
"import type { RadiantElement } from '../core/radiant-element';\n\nexport interface EventEmitterConfig {\n\tname: string;\n\tbubbles?: boolean;\n\tcancelable?: boolean;\n\tcomposed?: boolean;\n}\n\n/**\n * A generic event emitter class that allows emitting custom events.\n *\n * @template T - The type of the event detail.\n */\nexport class EventEmitter<T = unknown> {\n\tprivate host: RadiantElement;\n\tprivate eventConfig: EventEmitterConfig;\n\n\t/**\n\t * Constructs a new instance of the EventEmitter class.\n\t *\n\t * @param host - The host element on which the events will be dispatched.\n\t * @param eventConfig - The configuration for the event.\n\t */\n\tconstructor(host: RadiantElement, eventConfig: EventEmitterConfig) {\n\t\tthis.host = host;\n\t\tthis.eventConfig = eventConfig;\n\t}\n\n\t/**\n\t * Emits a custom event with the specified detail.\n\t *\n\t * @param detail - The detail object to be passed along with the event.\n\t */\n\temit(detail?: T) {\n\t\tconst event = new CustomEvent(this.eventConfig.name, {\n\t\t\tdetail: detail,\n\t\t\tbubbles: this.eventConfig.bubbles,\n\t\t\tcancelable: this.eventConfig.cancelable,\n\t\t\tcomposed: this.eventConfig.composed,\n\t\t});\n\t\tthis.host.dispatchEvent(event);\n\t}\n}\n",
|
|
8
8
|
"import type { RadiantElement } from '../core/radiant-element';\nimport { EventEmitter, type EventEmitterConfig } from '../tools/event-emitter';\n\n/**\n * Creates an EventEmitter bound to a host element and registers it on the host.\n * Functional equivalent of the `@event` decorator for vanilla JS usage.\n * @param host The host element that will dispatch the events.\n * @param config {@link EventEmitterConfig} The event emitter configuration.\n */\nexport function createEvent<T = unknown>(host: RadiantElement, config: EventEmitterConfig): EventEmitter<T> {\n\tconst emitter = new EventEmitter<T>(host, config);\n\thost.registerEventEmitter(config.name, emitter);\n\treturn emitter;\n}\n",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"import type { RadiantElement } from '../../core/radiant-element';\nimport { createEvent } from '../../helpers/create-event';\nimport type { EventEmitterConfig } from '../../tools/event-emitter';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n\treturn function <T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tconst emitter = createEvent(this, eventConfig);\n\n\t\t\tObject.defineProperty(this, context.name, {\n\t\t\t\tget() {\n\t\t\t\t\treturn emitter;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
11
11
|
"import { type EventEmitterConfig } from '../tools/event-emitter';\nimport type { RadiantElement } from '../core/radiant-element';\nimport { event as legacyEvent } from './legacy/event';\nimport { event as standardEvent } from './standard/event';\nimport { fieldDecoratorBridge } from './bridge';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig {@link EventEmitterConfig} Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n\tfunction decorator<THost extends RadiantElement, TValue>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<THost, TValue>,\n\t): void;\n\tfunction decorator(protoOrTarget: RadiantElement, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: RadiantElement | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<RadiantElement, unknown>,\n\t): void {\n\t\treturn fieldDecoratorBridge(standardEvent(eventConfig), legacyEvent(eventConfig), protoOrTarget, nameOrContext);\n\t}\n\n\treturn decorator;\n}\n"
|
|
12
12
|
],
|
|
13
|
-
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,
|
|
14
|
-
"debugId": "
|
|
13
|
+
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,EAC1F,EAAwC,OAAO,IAAI,yDAAyD,EAC5G,EAAiD,OAAO,IAC7D,kEACD,EAQO,SAAS,CAAmD,CAClE,EACA,EACO,CACP,EAAoB,EAAO,EAA8B,CAAW,EAU9D,SAAS,CAA2D,CAC1E,EACA,EACO,CACP,EAAoB,EAAO,EAAuC,CAAW,EASvE,SAAS,CAA+C,CAAC,EAAmB,CAClF,EAAsB,EAAU,CAA4B,EAUtD,SAAS,CAAuD,CAAC,EAAmB,CAC1F,IAAM,EAAS,EAEf,EACC,EACA,EACC,EAAO,KAAoD,IAAI,GACjE,EAGD,SAAS,CAAqC,CAAC,EAAU,EAAa,EAAiD,CACtH,IAAM,EAAS,EACT,EAAkB,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAG,EAAI,EAAO,GAAO,OAE1F,GAAI,MAAM,QAAQ,CAAe,EAAG,CACnC,EAAgB,KAAK,CAAW,EAChC,OAGD,OAAO,eAAe,EAAQ,EAAK,CAClC,MAAO,CAAC,CAAW,CACpB,CAAC,EAGF,SAAS,CAAuC,CAC/C,EACA,EACA,EACA,EAA2B,OAAO,eAAe,CAAQ,EAClD,CACP,GAAI,CAAC,GAAa,IAAc,OAAO,UACtC,OAGD,EAAsB,EAAU,EAAK,EAAsB,OAAO,eAAe,CAAS,CAAC,EAE3F,IAAM,EAAgB,EAA2C,GAEjE,GAAI,CAAC,MAAM,QAAQ,CAAY,EAC9B,OAGD,QAAW,KAAe,EAA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EACD,EACD,GCfI,SAAS,CAAK,CAAC,EAAiC,CACtD,OAAO,QAAsC,CAAC,EAAc,EAA2C,CACtG,EAAQ,eAAe,QAAS,EAAU,CACzC,IAAM,EAAU,EAAY,KAAM,CAAW,EAE7C,OAAO,eAAe,KAAM,EAAQ,KAAM,CACzC,GAAG,EAAG,CACL,OAAO,GAER,WAAY,GACZ,aAAc,EACf,CAAC,EACD,GCVI,SAAS,CAAK,CAAC,EAAiC,CAMtD,SAAS,CAAS,CACjB,EACA,EACO,CACP,OAAO,EAAqB,EAAc,CAAW,EAAG,EAAY,CAAW,EAAG,EAAe,CAAa,EAG/G,OAAO",
|
|
14
|
+
"debugId": "B307D91DFF24EA6264756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var V=((n)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(c,b)=>(typeof require<"u"?require:c)[b]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var x=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),L=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),Z=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function E(n,c){P(n,x,c)}function N(n,c){P(n,L,c)}function u(n){k(n,x)}function z(n){let c=n;k(n,L,c[Z]??=new Set)}function P(n,c,b){let A=n,r=Object.prototype.hasOwnProperty.call(A,c)?A[c]:void 0;if(Array.isArray(r)){r.push(b);return}Object.defineProperty(A,c,{value:[b]})}function k(n,c,b,A=Object.getPrototypeOf(n)){if(!A||A===Object.prototype)return;k(n,c,b,Object.getPrototypeOf(A));let r=A[c];if(!Array.isArray(r))return;for(let R of r){if(b?.has(R))continue;R(n),b?.add(R)}}function F(n){switch(n){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function G(n){switch(typeof n){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(n))return"array";if(Object.prototype.toString.call(n)==="[object Object]")return"object"}function M(n){switch(n){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function Y(n){try{return JSON.parse(n)}catch{throw TypeError("Invalid JSON string")}}var J={array(n){let c=Y(n);if(!Array.isArray(c))throw TypeError(`Expected an array but got a value of type "${typeof c}"`);return c},boolean(n){return!(n==="0"||String(n).toLowerCase()==="false")},number(n){return Number(n.replace(/_/g,""))},object(n){let c=JSON.parse(n);if(c===null||typeof c!=="object"||Array.isArray(c))throw TypeError(`expected value of type "object" but instead got value "${n}" of type "${G(c)}"`);return c},string(n){return n}},j={default:q,array:D,object:D};function D(n){return JSON.stringify(n)}function q(n){return`${n}`}function f(n,c){let b=F(c);if(!b)throw TypeError(`[radiant-element] Unknown type "${c}"`);return J[b](n)}function B(n,c){let b=F(c);if(!b)throw TypeError(`[radiant-element] Unknown type "${c}"`);return(j[b]??j.default??q)(n)}function K(n){return typeof n==="boolean"}function _(n){return typeof n==="number"}function S(n){return typeof n==="string"}function w(n){return Array.isArray(n)}function o(n){return typeof n==="object"&&!Array.isArray(n)&&n!==null}function Q(n,c){switch(n){case Boolean:return K(c);case Number:return _(c);case String:return S(c);case Array:return w(c);case Object:return o(c);default:return!1}}var l=(n,c,b,A)=>{if(c===Boolean){let R=n.getAttribute(b);if(R===null)return A;return R===""?!0:f(R,c)}let r=n.getAttribute(b);return r!==null?f(r,c):A??M(c)};function U(n,c){if(c!==void 0&&!Q(n,c))throw Error(`defaultValue does not match the expected type for ${n.name}`)}function nn(n,c,b,A){return{type:b,name:n,value:A,initialValue:A,attribute:c,converter:{fromAttribute:(r)=>f(r,b),toAttribute:(r)=>B(r,b)}}}function O(n){if(n instanceof Element)return n;if("host"in n)return n.host;return n.element}function i(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function e(n,c){if(c.converter?.fromAttribute){let b=c.converter.fromAttribute(n);if(n===null&&b===void 0&&"defaultValue"in c)return c.defaultValue;return b}if(c.type){if(n===null)return c.defaultValue??M(c.type);if(c.type===Boolean&&n==="")return!0;return f(n,c.type)}if(n===null)return c.defaultValue;return n}function t(n,c,b){return e(O(n).getAttribute(c),b)}function h(n,c,b,A){let r=A.converter?.toAttribute?A.converter.toAttribute(b):A.type?B(b,A.type):b==null?null:String(b);if(r===null){n.removeAttribute(c);return}n.setAttribute(c,r)}function X(n,c,b={}){if(b.type)U(b.type,b.defaultValue);let A=n,r=b.source??i(c),R=Symbol(`@ecopages/radiant/attr:${c}:observer`),d=Symbol(`@ecopages/radiant/attr:${c}:last-value`),W=b.bind??n.shouldAutoBindReactiveMembers?.()??!1;n.defineReactiveBinding(c,W),n.registerReactiveDependencyReader(c,()=>t(n,r,b)),A[d]=t(n,r,b),Object.defineProperty(n,c,{get(){return n.trackReactiveRead(c),t(this,r,b)},set(s){let v=O(this),H=t(this,r,b);h(v,r,s,b);let g=t(this,r,b);if(Object.is(H,g))return;this[d]=g,n.notifyUpdate(c,H,g)},enumerable:!0,configurable:!0});let m=()=>{A[R]?.disconnect()},C=()=>{let s=t(n,r,b),v=A[d];if(!Object.is(v,s))A[d]=s,n.notifyUpdate(c,v,s);if(typeof MutationObserver>"u")return;let H=O(n);m();let g=new MutationObserver(()=>{let T=t(n,r,b),$=A[d];if(Object.is($,T))return;A[d]=T,n.notifyUpdate(c,$,T)});g.observe(H,{attributeFilter:[r],attributes:!0}),A[R]=g};C(),n.registerConnectedCallback(C),n.registerCleanupCallback(m)}function tn(n={}){return(c,b)=>{let A=Symbol(`@ecopages/radiant/attr:${b}:installed`);E(c,(r)=>{r.registerConnectedCallback(()=>{if(r[A])return;let R=r[b],d=n.defaultValue===void 0?R:n.defaultValue;X(r,b,{...n,defaultValue:d}),r[A]=!0})})}}export{tn as reactiveAttr};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=E3A9274EE7EA0F7664756E2164756E21
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/utils/attribute-utils.ts", "../src/decorators/shared/reactive-attr.ts", "../src/decorators/legacy/attr.ts"],
|
|
3
|
+
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/utils/attribute-utils.ts", "../src/core/reactive-prop-core.ts", "../src/decorators/shared/reactive-attr.ts", "../src/decorators/legacy/attr.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\
|
|
5
|
+
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\nconst LEGACY_POST_CONSTRUCTION_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-post-construction-initializers');\nconst LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS = Symbol.for(\n\t'@ecopages/radiant.legacy-executed-post-construction-initializers',\n);\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_INSTANCE_INITIALIZERS, initializer);\n}\n\n/**\n * Registers post-construction work for a legacy decorator.\n *\n * This phase exists for decorators that eagerly write instance fields. With\n * legacy decorators plus `useDefineForClassFields`, subclass field definition\n * can overwrite values written during the base-class constructor.\n */\nexport function registerLegacyPostConstructionInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_POST_CONSTRUCTION_INITIALIZERS, initializer);\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\trunLegacyInitializers(instance, LEGACY_INSTANCE_INITIALIZERS);\n}\n\n/**\n * Runs legacy decorator setup that must happen after subclass field\n * initialization has completed.\n *\n * Each initializer runs at most once per instance even if multiple lifecycle\n * entrypoints call this helper.\n */\nexport function runLegacyPostConstructionInitializers<T extends object>(instance: T): void {\n\tconst target = instance as Record<PropertyKey, unknown>;\n\n\trunLegacyInitializers(\n\t\tinstance,\n\t\tLEGACY_POST_CONSTRUCTION_INITIALIZERS,\n\t\t(target[LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS] ??= new Set()) as Set<LegacyInstanceInitializer<T>>,\n\t);\n}\n\nfunction registerInitializer<T extends object>(proto: T, key: symbol, initializer: LegacyInstanceInitializer<T>): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = Object.prototype.hasOwnProperty.call(target, key) ? target[key] : undefined;\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(target, key, {\n\t\tvalue: [initializer],\n\t});\n}\n\nfunction runLegacyInitializers<T extends object>(\n\tinstance: T,\n\tkey: symbol,\n\texecutedInitializers?: Set<LegacyInstanceInitializer<T>>,\n\tprototype: object | null = Object.getPrototypeOf(instance),\n): void {\n\tif (!prototype || prototype === Object.prototype) {\n\t\treturn;\n\t}\n\n\trunLegacyInitializers(instance, key, executedInitializers, Object.getPrototypeOf(prototype));\n\n\tconst initializers = (prototype as Record<PropertyKey, unknown>)[key] as LegacyInstanceInitializer<T>[] | undefined;\n\n\tif (!Array.isArray(initializers)) {\n\t\treturn;\n\t}\n\n\tfor (const initializer of initializers) {\n\t\tif (executedInitializers?.has(initializer)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tinitializer(instance);\n\t\texecutedInitializers?.add(initializer);\n\t}\n}\n",
|
|
6
6
|
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
|
|
7
|
-
"import type {
|
|
7
|
+
"import type { JsxRenderable, SubscribableJsxValue } from '@ecopages/jsx';\nimport {\n\ttype AttributeTypeConstant,\n\ttype ReadAttributeValueReturnType,\n\ttype WriteAttributeValueReturnType,\n\tisValueOfType,\n\treadAttributeValue,\n\twriteAttributeValue,\n} from '../utils/attribute-utils';\n\ntype StringPropertyKey<Value> = Extract<keyof Value, string>;\n\nexport interface ReactiveProperty<T = unknown> {\n\ttype: AttributeTypeConstant;\n\tvalue?: T;\n\tinitialValue?: T;\n\tname: string;\n\tattribute: string;\n\tconverter: {\n\t\tfromAttribute: (value: string) => ReadAttributeValueReturnType;\n\t\ttoAttribute: (value: any) => WriteAttributeValueReturnType;\n\t};\n}\n\nexport type ReactivePropertyOptions<T> = {\n\ttype: AttributeTypeConstant;\n\treflect?: boolean;\n\tattribute?: string;\n\tdefaultValue?: T;\n\tbind?: boolean | string;\n};\n\nexport type ReactiveBindingOption = boolean | string;\n\nexport type ReactiveFieldOptions = {\n\tbind?: ReactiveBindingOption;\n\t/** When true, skip the initial notifyUpdate emitted while defining the field. */\n\tsuppressInitialNotify?: boolean;\n};\n\nexport type ReactiveField<T = unknown> = {\n\tname: string;\n\tvalue: T;\n\tinitialValue: T;\n};\n\nexport type ReactiveBindingValue<\n\tHost extends object,\n\tProperty extends StringPropertyKey<Host>,\n> = Host[Property] extends JsxRenderable ? Host[Property] : JsxRenderable;\n\nexport type ReactiveBindings<Bindings extends object> = {\n\treadonly [Property in StringPropertyKey<Bindings>]: SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n};\n\nexport type ReactiveAccessorDefinition<T> = {\n\tbind?: ReactiveBindingOption;\n\tgetValue: () => T | undefined;\n\tsetValue: (value: T) => void;\n};\n\nexport function validateReactivePropertyDefault(type: AttributeTypeConstant, defaultValue: unknown): void {\n\tif (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {\n\t\tthrow new Error(`defaultValue does not match the expected type for ${type.name}`);\n\t}\n}\n\nexport function createReactivePropertyMapping<T>(\n\tpropertyName: string,\n\tattributeKey: string,\n\ttype: AttributeTypeConstant,\n\tinitialValue: T | undefined,\n): ReactiveProperty<T> {\n\treturn {\n\t\ttype,\n\t\tname: propertyName,\n\t\tvalue: initialValue,\n\t\tinitialValue,\n\t\tattribute: attributeKey,\n\t\tconverter: {\n\t\t\tfromAttribute: (value) => readAttributeValue(value, type),\n\t\t\ttoAttribute: (value) => writeAttributeValue(value, type),\n\t\t},\n\t};\n}\n",
|
|
8
|
+
"import type { ReactiveHostLike } from '../../core/reactive-host';\nimport { type ReactiveBindingOption, validateReactivePropertyDefault } from '../../core/reactive-prop-core';\nimport {\n\tdefaultValueForType,\n\treadAttributeValue,\n\ttype AttributeTypeConstant,\n\twriteAttributeValue,\n} from '../../utils/attribute-utils';\n\nexport type AttrConverter<T> = {\n\tfromAttribute?: (value: string | null) => T;\n\ttoAttribute?: (value: T) => string | null;\n};\n\nexport type AttrOptions<T = string | undefined> = {\n\tsource?: string;\n\ttype?: AttributeTypeConstant;\n\tbind?: ReactiveBindingOption;\n\tdefaultValue?: T;\n\tconverter?: AttrConverter<T>;\n};\n\ntype ReactiveAttributeHostApi<Bindings extends object = {}> = ReactiveHostLike<Bindings> & {\n\tregisterCleanupCallback(callback: () => void): void;\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\nexport type ReactiveAttributeHostLike<Bindings extends object = {}> =\n\t| (ReactiveAttributeHostApi<Bindings> & Element)\n\t| (ReactiveAttributeHostApi<Bindings> & { host: Element })\n\t| (ReactiveAttributeHostApi<Bindings> & { element: Element });\n\nfunction resolveAttributeTarget(host: ReactiveAttributeHostLike): Element {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\treturn host.element;\n}\n\nfunction toAttributeName(propertyName: string): string {\n\treturn propertyName\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n\t\t.replace(/_/g, '-')\n\t\t.toLowerCase();\n}\n\nfunction resolveAttributeValue<T>(rawValue: string | null, options: AttrOptions<T>): T {\n\tif (options.converter?.fromAttribute) {\n\t\tconst convertedValue = options.converter.fromAttribute(rawValue);\n\n\t\tif (rawValue === null && convertedValue === undefined && 'defaultValue' in options) {\n\t\t\treturn options.defaultValue as T;\n\t\t}\n\n\t\treturn convertedValue;\n\t}\n\n\tif (options.type) {\n\t\tif (rawValue === null) {\n\t\t\treturn (options.defaultValue ?? defaultValueForType(options.type)) as T;\n\t\t}\n\n\t\tif (options.type === Boolean && rawValue === '') {\n\t\t\treturn true as T;\n\t\t}\n\n\t\treturn readAttributeValue(rawValue, options.type) as T;\n\t}\n\n\tif (rawValue === null) {\n\t\treturn options.defaultValue as T;\n\t}\n\n\treturn rawValue as T;\n}\n\nfunction readReactiveAttributeValue<T>(\n\thost: ReactiveAttributeHostLike,\n\tattributeName: string,\n\toptions: AttrOptions<T>,\n): T {\n\treturn resolveAttributeValue(resolveAttributeTarget(host).getAttribute(attributeName), options);\n}\n\nfunction writeReactiveAttributeValue<T>(\n\ttarget: Element,\n\tattributeName: string,\n\tvalue: T,\n\toptions: AttrOptions<T>,\n): void {\n\tconst attributeValue = options.converter?.toAttribute\n\t\t? options.converter.toAttribute(value)\n\t\t: options.type\n\t\t\t? writeAttributeValue(value, options.type)\n\t\t\t: value == null\n\t\t\t\t? null\n\t\t\t\t: String(value);\n\n\tif (attributeValue === null) {\n\t\ttarget.removeAttribute(attributeName);\n\t\treturn;\n\t}\n\n\ttarget.setAttribute(attributeName, attributeValue);\n}\n\nexport function installReactiveAttribute<TBindings extends object, TValue>(\n\thost: ReactiveAttributeHostLike<TBindings>,\n\tpropertyName: string,\n\toptions: AttrOptions<TValue> = {},\n): void {\n\tif (options.type) {\n\t\tvalidateReactivePropertyDefault(options.type, options.defaultValue);\n\t}\n\n\tconst hostRecord = host as unknown as Record<PropertyKey, unknown>;\n\tconst attributeName = options.source ?? toAttributeName(propertyName);\n\tconst observerKey = Symbol(`@ecopages/radiant/attr:${propertyName}:observer`);\n\tconst lastValueKey = Symbol(`@ecopages/radiant/attr:${propertyName}:last-value`);\n\tconst bind =\n\t\toptions.bind ??\n\t\t(host as unknown as { shouldAutoBindReactiveMembers?: () => boolean }).shouldAutoBindReactiveMembers?.() ??\n\t\tfalse;\n\n\thost.defineReactiveBinding(propertyName, bind);\n\thost.registerReactiveDependencyReader(propertyName, () => readReactiveAttributeValue(host, attributeName, options));\n\thostRecord[lastValueKey] = readReactiveAttributeValue(host, attributeName, options);\n\n\tObject.defineProperty(host, propertyName, {\n\t\tget() {\n\t\t\thost.trackReactiveRead(propertyName);\n\t\t\treturn readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t},\n\t\tset(newValue: TValue) {\n\t\t\tconst target = resolveAttributeTarget(this as ReactiveAttributeHostLike);\n\t\t\tconst oldValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t\twriteReactiveAttributeValue(target, attributeName, newValue, options);\n\t\t\tconst nextValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\n\t\t\tif (Object.is(oldValue, nextValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t(this as Record<PropertyKey, unknown>)[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, oldValue, nextValue);\n\t\t},\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\tconst disconnectObserver = () => {\n\t\tconst observer = hostRecord[observerKey] as MutationObserver | undefined;\n\t\tobserver?.disconnect();\n\t};\n\n\tconst syncAndObserve = () => {\n\t\tconst nextValue = readReactiveAttributeValue(host, attributeName, options);\n\t\tconst previousValue = hostRecord[lastValueKey];\n\n\t\tif (!Object.is(previousValue, nextValue)) {\n\t\t\thostRecord[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, previousValue, nextValue);\n\t\t}\n\n\t\tif (typeof MutationObserver === 'undefined') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst target = resolveAttributeTarget(host);\n\n\t\tdisconnectObserver();\n\n\t\tconst observer = new MutationObserver(() => {\n\t\t\tconst currentValue = readReactiveAttributeValue(host, attributeName, options);\n\t\t\tconst lastValue = hostRecord[lastValueKey];\n\n\t\t\tif (Object.is(lastValue, currentValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\thostRecord[lastValueKey] = currentValue;\n\t\t\thost.notifyUpdate(propertyName, lastValue, currentValue);\n\t\t});\n\n\t\tobserver.observe(target, {\n\t\t\tattributeFilter: [attributeName],\n\t\t\tattributes: true,\n\t\t});\n\n\t\thostRecord[observerKey] = observer;\n\t};\n\n\tsyncAndObserve();\n\thost.registerConnectedCallback(syncAndObserve);\n\thost.registerCleanupCallback(disconnectObserver);\n}\n",
|
|
8
9
|
"import { installReactiveAttribute, type AttrOptions, type ReactiveAttributeHostLike } from '../shared/reactive-attr';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\nexport function reactiveAttr<TValue = string | undefined>(options: AttrOptions<TValue> = {}) {\n\treturn (target: ReactiveAttributeHostLike, propertyName: string) => {\n\t\tconst installedKey = Symbol(`@ecopages/radiant/attr:${propertyName}:installed`);\n\n\t\tregisterLegacyInstanceInitializer(target, (host) => {\n\t\t\t(host as ReactiveAttributeHostLike).registerConnectedCallback(() => {\n\t\t\t\tif ((host as unknown as Record<PropertyKey, unknown>)[installedKey]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst initializerValue = (host as unknown as Record<PropertyKey, TValue | undefined>)[propertyName];\n\t\t\t\tconst defaultValue = (options.defaultValue === undefined ? initializerValue : options.defaultValue) as\n\t\t\t\t\t| TValue\n\t\t\t\t\t| undefined;\n\n\t\t\t\tinstallReactiveAttribute(host as ReactiveAttributeHostLike, propertyName, {\n\t\t\t\t\t...options,\n\t\t\t\t\tdefaultValue,\n\t\t\t\t});\n\n\t\t\t\t(host as unknown as Record<PropertyKey, unknown>)[installedKey] = true;\n\t\t\t});\n\t\t});\n\t};\n}\n"
|
|
9
10
|
],
|
|
10
|
-
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,
|
|
11
|
-
"debugId": "
|
|
11
|
+
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,EAC1F,EAAwC,OAAO,IAAI,yDAAyD,EAC5G,EAAiD,OAAO,IAC7D,kEACD,EAQO,SAAS,CAAmD,CAClE,EACA,EACO,CACP,EAAoB,EAAO,EAA8B,CAAW,EAU9D,SAAS,CAA2D,CAC1E,EACA,EACO,CACP,EAAoB,EAAO,EAAuC,CAAW,EASvE,SAAS,CAA+C,CAAC,EAAmB,CAClF,EAAsB,EAAU,CAA4B,EAUtD,SAAS,CAAuD,CAAC,EAAmB,CAC1F,IAAM,EAAS,EAEf,EACC,EACA,EACC,EAAO,KAAoD,IAAI,GACjE,EAGD,SAAS,CAAqC,CAAC,EAAU,EAAa,EAAiD,CACtH,IAAM,EAAS,EACT,EAAkB,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAG,EAAI,EAAO,GAAO,OAE1F,GAAI,MAAM,QAAQ,CAAe,EAAG,CACnC,EAAgB,KAAK,CAAW,EAChC,OAGD,OAAO,eAAe,EAAQ,EAAK,CAClC,MAAO,CAAC,CAAW,CACpB,CAAC,EAGF,SAAS,CAAuC,CAC/C,EACA,EACA,EACA,EAA2B,OAAO,eAAe,CAAQ,EAClD,CACP,GAAI,CAAC,GAAa,IAAc,OAAO,UACtC,OAGD,EAAsB,EAAU,EAAK,EAAsB,OAAO,eAAe,CAAS,CAAC,EAE3F,IAAM,EAAg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AM,CAC5B,IAAM,EAAY,EAA2B,EAAM,EAAe,CAAO,EACnE,EAAgB,EAAW,GAEjC,GAAI,CAAC,OAAO,GAAG,EAAe,CAAS,EACtC,EAAW,GAAgB,EAC3B,EAAK,aAAa,EAAc,EAAe,CAAS,EAGzD,GAAI,OAAO,iBAAqB,IAC/B,OAGD,IAAM,EAAS,EAAuB,CAAI,EAE1C,EAAmB,EAEnB,IAAM,EAAW,IAAI,iBAAiB,IAAM,CAC3C,IAAM,EAAe,EAA2B,EAAM,EAAe,CAAO,EACtE,EAAY,EAAW,GAE7B,GAAI,OAAO,GAAG,EAAW,CAAY,EACpC,OAGD,EAAW,GAAgB,EAC3B,EAAK,aAAa,EAAc,EAAW,CAAY,EACvD,EAED,EAAS,QAAQ,EAAQ,CACxB,gBAAiB,CAAC,CAAa,EAC/B,WAAY,EACb,CAAC,EAED,EAAW,GAAe,GAG3B,EAAe,EACf,EAAK,0BAA0B,CAAc,EAC7C,EAAK,wBAAwB,CAAkB,ECpMzC,SAAS,EAAyC,CAAC,EAA+B,CAAC,EAAG,CAC5F,MAAO,CAAC,EAAmC,IAAyB,CACnE,IAAM,EAAe,OAAO,0BAA0B,aAAwB,EAE9E,EAAkC,EAAQ,CAAC,IAAS,CAClD,EAAmC,0BAA0B,IAAM,CACnE,GAAK,EAAiD,GACrD,OAGD,IAAM,EAAoB,EAA4D,GAChF,EAAgB,EAAQ,eAAiB,OAAY,EAAmB,EAAQ,aAItF,EAAyB,EAAmC,EAAc,IACtE,EACH,cACD,CAAC,EAEA,EAAiD,GAAgB,GAClE,EACD",
|
|
12
|
+
"debugId": "E3A9274EE7EA0F7664756E2164756E21",
|
|
12
13
|
"names": []
|
|
13
14
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var K=((B)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(B,{get:(D,H)=>(typeof require<"u"?require:D)[H]}):B)(function(B){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+B+'" is not supported')});var $=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),j=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),G=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function q(B,D){F(B,$,D)}function U(B,D){F(B,j,D)}function Y(B){W(B,$)}function Z(B){let D=B;W(B,j,D[G]??=new Set)}function F(B,D,H){let M=B,Q=Object.prototype.hasOwnProperty.call(M,D)?M[D]:void 0;if(Array.isArray(Q)){Q.push(H);return}Object.defineProperty(M,D,{value:[H]})}function W(B,D,H,M=Object.getPrototypeOf(B)){if(!M||M===Object.prototype)return;W(B,D,H,Object.getPrototypeOf(M));let Q=M[D];if(!Array.isArray(Q))return;for(let V of Q){if(H?.has(V))continue;V(B),H?.add(V)}}class X{host;eventConfig;constructor(B,D){this.host=B,this.eventConfig=D}emit(B){let D=new CustomEvent(this.eventConfig.name,{detail:B,bubbles:this.eventConfig.bubbles,cancelable:this.eventConfig.cancelable,composed:this.eventConfig.composed});this.host.dispatchEvent(D)}}function J(B,D){let H=new X(B,D);return B.registerEventEmitter(D.name,H),H}function O(B){return(D,H)=>{q(D,(M)=>{let Q=J(M,B);M.registerConnectedCallback(()=>{Object.defineProperty(M,H,{get(){return Q},enumerable:!0,configurable:!0})})})}}export{O as event};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=1AB8EE13696F1F2F64756E2164756E21
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/tools/event-emitter.ts", "../src/helpers/create-event.ts", "../src/decorators/legacy/event.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\
|
|
5
|
+
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\nconst LEGACY_POST_CONSTRUCTION_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-post-construction-initializers');\nconst LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS = Symbol.for(\n\t'@ecopages/radiant.legacy-executed-post-construction-initializers',\n);\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_INSTANCE_INITIALIZERS, initializer);\n}\n\n/**\n * Registers post-construction work for a legacy decorator.\n *\n * This phase exists for decorators that eagerly write instance fields. With\n * legacy decorators plus `useDefineForClassFields`, subclass field definition\n * can overwrite values written during the base-class constructor.\n */\nexport function registerLegacyPostConstructionInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_POST_CONSTRUCTION_INITIALIZERS, initializer);\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\trunLegacyInitializers(instance, LEGACY_INSTANCE_INITIALIZERS);\n}\n\n/**\n * Runs legacy decorator setup that must happen after subclass field\n * initialization has completed.\n *\n * Each initializer runs at most once per instance even if multiple lifecycle\n * entrypoints call this helper.\n */\nexport function runLegacyPostConstructionInitializers<T extends object>(instance: T): void {\n\tconst target = instance as Record<PropertyKey, unknown>;\n\n\trunLegacyInitializers(\n\t\tinstance,\n\t\tLEGACY_POST_CONSTRUCTION_INITIALIZERS,\n\t\t(target[LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS] ??= new Set()) as Set<LegacyInstanceInitializer<T>>,\n\t);\n}\n\nfunction registerInitializer<T extends object>(proto: T, key: symbol, initializer: LegacyInstanceInitializer<T>): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = Object.prototype.hasOwnProperty.call(target, key) ? target[key] : undefined;\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(target, key, {\n\t\tvalue: [initializer],\n\t});\n}\n\nfunction runLegacyInitializers<T extends object>(\n\tinstance: T,\n\tkey: symbol,\n\texecutedInitializers?: Set<LegacyInstanceInitializer<T>>,\n\tprototype: object | null = Object.getPrototypeOf(instance),\n): void {\n\tif (!prototype || prototype === Object.prototype) {\n\t\treturn;\n\t}\n\n\trunLegacyInitializers(instance, key, executedInitializers, Object.getPrototypeOf(prototype));\n\n\tconst initializers = (prototype as Record<PropertyKey, unknown>)[key] as LegacyInstanceInitializer<T>[] | undefined;\n\n\tif (!Array.isArray(initializers)) {\n\t\treturn;\n\t}\n\n\tfor (const initializer of initializers) {\n\t\tif (executedInitializers?.has(initializer)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tinitializer(instance);\n\t\texecutedInitializers?.add(initializer);\n\t}\n}\n",
|
|
6
6
|
"import type { RadiantElement } from '../core/radiant-element';\n\nexport interface EventEmitterConfig {\n\tname: string;\n\tbubbles?: boolean;\n\tcancelable?: boolean;\n\tcomposed?: boolean;\n}\n\n/**\n * A generic event emitter class that allows emitting custom events.\n *\n * @template T - The type of the event detail.\n */\nexport class EventEmitter<T = unknown> {\n\tprivate host: RadiantElement;\n\tprivate eventConfig: EventEmitterConfig;\n\n\t/**\n\t * Constructs a new instance of the EventEmitter class.\n\t *\n\t * @param host - The host element on which the events will be dispatched.\n\t * @param eventConfig - The configuration for the event.\n\t */\n\tconstructor(host: RadiantElement, eventConfig: EventEmitterConfig) {\n\t\tthis.host = host;\n\t\tthis.eventConfig = eventConfig;\n\t}\n\n\t/**\n\t * Emits a custom event with the specified detail.\n\t *\n\t * @param detail - The detail object to be passed along with the event.\n\t */\n\temit(detail?: T) {\n\t\tconst event = new CustomEvent(this.eventConfig.name, {\n\t\t\tdetail: detail,\n\t\t\tbubbles: this.eventConfig.bubbles,\n\t\t\tcancelable: this.eventConfig.cancelable,\n\t\t\tcomposed: this.eventConfig.composed,\n\t\t});\n\t\tthis.host.dispatchEvent(event);\n\t}\n}\n",
|
|
7
7
|
"import type { RadiantElement } from '../core/radiant-element';\nimport { EventEmitter, type EventEmitterConfig } from '../tools/event-emitter';\n\n/**\n * Creates an EventEmitter bound to a host element and registers it on the host.\n * Functional equivalent of the `@event` decorator for vanilla JS usage.\n * @param host The host element that will dispatch the events.\n * @param config {@link EventEmitterConfig} The event emitter configuration.\n */\nexport function createEvent<T = unknown>(host: RadiantElement, config: EventEmitterConfig): EventEmitter<T> {\n\tconst emitter = new EventEmitter<T>(host, config);\n\thost.registerEventEmitter(config.name, emitter);\n\treturn emitter;\n}\n",
|
|
8
8
|
"import type { RadiantElement } from '../../core/radiant-element';\nimport { createEvent } from '../../helpers/create-event';\nimport type { EventEmitterConfig } from '../../tools/event-emitter';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n\treturn (proto: RadiantElement, propertyKey: string) => {\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tconst emitter = createEvent(element, eventConfig);\n\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tObject.defineProperty(element, propertyKey, {\n\t\t\t\t\tget() {\n\t\t\t\t\t\treturn emitter;\n\t\t\t\t\t},\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,
|
|
11
|
-
"debugId": "
|
|
10
|
+
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,EAC1F,EAAwC,OAAO,IAAI,yDAAyD,EAC5G,EAAiD,OAAO,IAC7D,kEACD,EAQO,SAAS,CAAmD,CAClE,EACA,EACO,CACP,EAAoB,EAAO,EAA8B,CAAW,EAU9D,SAAS,CAA2D,CAC1E,EACA,EACO,CACP,EAAoB,EAAO,EAAuC,CAAW,EASvE,SAAS,CAA+C,CAAC,EAAmB,CAClF,EAAsB,EAAU,CAA4B,EAUtD,SAAS,CAAuD,CAAC,EAAmB,CAC1F,IAAM,EAAS,EAEf,EACC,EACA,EACC,EAAO,KAAoD,IAAI,GACjE,EAGD,SAAS,CAAqC,CAAC,EAAU,EAAa,EAAiD,CACtH,IAAM,EAAS,EACT,EAAkB,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAG,EAAI,EAAO,GAAO,OAE1F,GAAI,MAAM,QAAQ,CAAe,EAAG,CACnC,EAAgB,KAAK,CAAW,EAChC,OAGD,OAAO,eAAe,EAAQ,EAAK,CAClC,MAAO,CAAC,CAAW,CACpB,CAAC,EAGF,SAAS,CAAuC,CAC/C,EACA,EACA,EACA,EAA2B,OAAO,eAAe,CAAQ,EAClD,CACP,GAAI,CAAC,GAAa,IAAc,OAAO,UACtC,OAGD,EAAsB,EAAU,EAAK,EAAsB,OAAO,eAAe,CAAS,CAAC,EAE3F,IAAM,EAAgB,EAA2C,GAEjE,GAAI,CAAC,MAAM,QAAQ,CAAY,EAC9B,OAGD,QAAW,KAAe,EAAc,CACvC,GAAI,GAAsB,IAAI,CAAW,EACxC,SAGD,EAAY,CAAQ,EACpB,GAAsB,IAAI,CAAW,GCtFhC,MAAM,CAA0B,CAC9B,KACA,YAQR,WAAW,CAAC,EAAsB,EAAiC,CAClE,KAAK,KAAO,EACZ,KAAK,YAAc,EAQpB,IAAI,CAAC,EAAY,CAChB,IAAM,EAAQ,IAAI,YAAY,KAAK,YAAY,KAAM,CACpD,OAAQ,EACR,QAAS,KAAK,YAAY,QAC1B,WAAY,KAAK,YAAY,WAC7B,SAAU,KAAK,YAAY,QAC5B,CAAC,EACD,KAAK,KAAK,cAAc,CAAK,EAE/B,CClCO,SAAS,CAAwB,CAAC,EAAsB,EAA6C,CAC3G,IAAM,EAAU,IAAI,EAAgB,EAAM,CAAM,EAEhD,OADA,EAAK,qBAAqB,EAAO,KAAM,CAAO,EACvC,ECDD,SAAS,CAAK,CAAC,EAAiC,CACtD,MAAO,CAAC,EAAuB,IAAwB,CACtD,EAAkC,EAAO,CAAC,IAAY,CACrD,IAAM,EAAU,EAAY,EAAS,CAAW,EAEhD,EAAQ,0BAA0B,IAAM,CACvC,OAAO,eAAe,EAAS,EAAa,CAC3C,GAAG,EAAG,CACL,OAAO,GAER,WAAY,GACZ,aAAc,EACf,CAAC,EACD,EACD",
|
|
11
|
+
"debugId": "1AB8EE13696F1F2F64756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type LegacyHostReadinessPhase = 'construct' | 'connect' | 'ssr';
|
|
2
|
+
/**
|
|
3
|
+
* Runs legacy decorator initialization for the requested lifecycle phase.
|
|
4
|
+
*
|
|
5
|
+
* Post-construction work is idempotent — multiple calls with `connect` or `ssr`
|
|
6
|
+
* only execute each registered initializer once per instance.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensureLegacyHostReady<T extends object>(host: T, phase: LegacyHostReadinessPhase): void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var Q=((b)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(b,{get:(f,j)=>(typeof require<"u"?require:f)[j]}):b)(function(b){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+b+'" is not supported')});var D=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),F=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),M=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function W(b,f){K(b,D,f)}function X(b,f){K(b,F,f)}function H(b){B(b,D)}function J(b){let f=b;B(b,F,f[M]??=new Set)}function K(b,f,j){let m=b,q=Object.prototype.hasOwnProperty.call(m,f)?m[f]:void 0;if(Array.isArray(q)){q.push(j);return}Object.defineProperty(m,f,{value:[j]})}function B(b,f,j,m=Object.getPrototypeOf(b)){if(!m||m===Object.prototype)return;B(b,f,j,Object.getPrototypeOf(m));let q=m[f];if(!Array.isArray(q))return;for(let v of q){if(j?.has(v))continue;v(b),j?.add(v)}}function G(b,f){switch(f){case"construct":H(b);break;case"connect":case"ssr":J(b);break}}export{G as ensureLegacyHostReady};
|
|
2
|
+
|
|
3
|
+
//# debugId=2B24C82066F9CD4764756E2164756E21
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/decorators/legacy/host-readiness.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\nconst LEGACY_POST_CONSTRUCTION_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-post-construction-initializers');\nconst LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS = Symbol.for(\n\t'@ecopages/radiant.legacy-executed-post-construction-initializers',\n);\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_INSTANCE_INITIALIZERS, initializer);\n}\n\n/**\n * Registers post-construction work for a legacy decorator.\n *\n * This phase exists for decorators that eagerly write instance fields. With\n * legacy decorators plus `useDefineForClassFields`, subclass field definition\n * can overwrite values written during the base-class constructor.\n */\nexport function registerLegacyPostConstructionInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_POST_CONSTRUCTION_INITIALIZERS, initializer);\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\trunLegacyInitializers(instance, LEGACY_INSTANCE_INITIALIZERS);\n}\n\n/**\n * Runs legacy decorator setup that must happen after subclass field\n * initialization has completed.\n *\n * Each initializer runs at most once per instance even if multiple lifecycle\n * entrypoints call this helper.\n */\nexport function runLegacyPostConstructionInitializers<T extends object>(instance: T): void {\n\tconst target = instance as Record<PropertyKey, unknown>;\n\n\trunLegacyInitializers(\n\t\tinstance,\n\t\tLEGACY_POST_CONSTRUCTION_INITIALIZERS,\n\t\t(target[LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS] ??= new Set()) as Set<LegacyInstanceInitializer<T>>,\n\t);\n}\n\nfunction registerInitializer<T extends object>(proto: T, key: symbol, initializer: LegacyInstanceInitializer<T>): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = Object.prototype.hasOwnProperty.call(target, key) ? target[key] : undefined;\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(target, key, {\n\t\tvalue: [initializer],\n\t});\n}\n\nfunction runLegacyInitializers<T extends object>(\n\tinstance: T,\n\tkey: symbol,\n\texecutedInitializers?: Set<LegacyInstanceInitializer<T>>,\n\tprototype: object | null = Object.getPrototypeOf(instance),\n): void {\n\tif (!prototype || prototype === Object.prototype) {\n\t\treturn;\n\t}\n\n\trunLegacyInitializers(instance, key, executedInitializers, Object.getPrototypeOf(prototype));\n\n\tconst initializers = (prototype as Record<PropertyKey, unknown>)[key] as LegacyInstanceInitializer<T>[] | undefined;\n\n\tif (!Array.isArray(initializers)) {\n\t\treturn;\n\t}\n\n\tfor (const initializer of initializers) {\n\t\tif (executedInitializers?.has(initializer)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tinitializer(instance);\n\t\texecutedInitializers?.add(initializer);\n\t}\n}\n",
|
|
6
|
+
"import {\n\trunLegacyInstanceInitializers,\n\trunLegacyPostConstructionInitializers,\n} from './instance-initializers';\n\nexport type LegacyHostReadinessPhase = 'construct' | 'connect' | 'ssr';\n\n/**\n * Runs legacy decorator initialization for the requested lifecycle phase.\n *\n * Post-construction work is idempotent — multiple calls with `connect` or `ssr`\n * only execute each registered initializer once per instance.\n */\nexport function ensureLegacyHostReady<T extends object>(host: T, phase: LegacyHostReadinessPhase): void {\n\tswitch (phase) {\n\t\tcase 'construct':\n\t\t\trunLegacyInstanceInitializers(host);\n\t\t\tbreak;\n\t\tcase 'connect':\n\t\tcase 'ssr':\n\t\t\trunLegacyPostConstructionInitializers(host);\n\t\t\tbreak;\n\t}\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,EAC1F,EAAwC,OAAO,IAAI,yDAAyD,EAC5G,EAAiD,OAAO,IAC7D,kEACD,EAQO,SAAS,CAAmD,CAClE,EACA,EACO,CACP,EAAoB,EAAO,EAA8B,CAAW,EAU9D,SAAS,CAA2D,CAC1E,EACA,EACO,CACP,EAAoB,EAAO,EAAuC,CAAW,EASvE,SAAS,CAA+C,CAAC,EAAmB,CAClF,EAAsB,EAAU,CAA4B,EAUtD,SAAS,CAAuD,CAAC,EAAmB,CAC1F,IAAM,EAAS,EAEf,EACC,EACA,EACC,EAAO,KAAoD,IAAI,GACjE,EAGD,SAAS,CAAqC,CAAC,EAAU,EAAa,EAAiD,CACtH,IAAM,EAAS,EACT,EAAkB,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAG,EAAI,EAAO,GAAO,OAE1F,GAAI,MAAM,QAAQ,CAAe,EAAG,CACnC,EAAgB,KAAK,CAAW,EAChC,OAGD,OAAO,eAAe,EAAQ,EAAK,CAClC,MAAO,CAAC,CAAW,CACpB,CAAC,EAGF,SAAS,CAAuC,CAC/C,EACA,EACA,EACA,EAA2B,OAAO,eAAe,CAAQ,EAClD,CACP,GAAI,CAAC,GAAa,IAAc,OAAO,UACtC,OAGD,EAAsB,EAAU,EAAK,EAAsB,OAAO,eAAe,CAAS,CAAC,EAE3F,IAAM,EAAgB,EAA2C,GAEjE,GAAI,CAAC,MAAM,QAAQ,CAAY,EAC9B,OAGD,QAAW,KAAe,EAAc,CACvC,GAAI,GAAsB,IAAI,CAAW,EACxC,SAGD,EAAY,CAAQ,EACpB,GAAsB,IAAI,CAAW,GCvFhC,SAAS,CAAuC,CAAC,EAAS,EAAuC,CACvG,OAAQ,OACF,YACJ,EAA8B,CAAI,EAClC,UACI,cACA,MACJ,EAAsC,CAAI,EAC1C",
|
|
9
|
+
"debugId": "2B24C82066F9CD4764756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -6,6 +6,14 @@ type LegacyInstanceInitializer<T extends object = object> = (instance: T) => voi
|
|
|
6
6
|
* needs the concrete element instance must be deferred until construction time.
|
|
7
7
|
*/
|
|
8
8
|
export declare function registerLegacyInstanceInitializer<T extends object>(proto: T, initializer: LegacyInstanceInitializer<T>): void;
|
|
9
|
+
/**
|
|
10
|
+
* Registers post-construction work for a legacy decorator.
|
|
11
|
+
*
|
|
12
|
+
* This phase exists for decorators that eagerly write instance fields. With
|
|
13
|
+
* legacy decorators plus `useDefineForClassFields`, subclass field definition
|
|
14
|
+
* can overwrite values written during the base-class constructor.
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerLegacyPostConstructionInitializer<T extends object>(proto: T, initializer: LegacyInstanceInitializer<T>): void;
|
|
9
17
|
/**
|
|
10
18
|
* Runs all legacy decorator initializers for a newly constructed element.
|
|
11
19
|
*
|
|
@@ -13,4 +21,12 @@ export declare function registerLegacyInstanceInitializer<T extends object>(prot
|
|
|
13
21
|
* derived class so inherited setup remains stable.
|
|
14
22
|
*/
|
|
15
23
|
export declare function runLegacyInstanceInitializers<T extends object>(instance: T): void;
|
|
24
|
+
/**
|
|
25
|
+
* Runs legacy decorator setup that must happen after subclass field
|
|
26
|
+
* initialization has completed.
|
|
27
|
+
*
|
|
28
|
+
* Each initializer runs at most once per instance even if multiple lifecycle
|
|
29
|
+
* entrypoints call this helper.
|
|
30
|
+
*/
|
|
31
|
+
export declare function runLegacyPostConstructionInitializers<T extends object>(instance: T): void;
|
|
16
32
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var J=((
|
|
1
|
+
var J=((b)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(b,{get:(f,h)=>(typeof require<"u"?require:f)[h]}):b)(function(b){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+b+'" is not supported')});var B=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),D=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),H=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function M(b,f){F(b,B,f)}function Q(b,f){F(b,D,f)}function V(b){v(b,B)}function W(b){let f=b;v(b,D,f[H]??=new Set)}function F(b,f,h){let j=b,m=Object.prototype.hasOwnProperty.call(j,f)?j[f]:void 0;if(Array.isArray(m)){m.push(h);return}Object.defineProperty(j,f,{value:[h]})}function v(b,f,h,j=Object.getPrototypeOf(b)){if(!j||j===Object.prototype)return;v(b,f,h,Object.getPrototypeOf(j));let m=j[f];if(!Array.isArray(m))return;for(let q of m){if(h?.has(q))continue;q(b),h?.add(q)}}export{W as runLegacyPostConstructionInitializers,V as runLegacyInstanceInitializers,Q as registerLegacyPostConstructionInitializer,M as registerLegacyInstanceInitializer};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=31B43FCC2270E87364756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/decorators/legacy/instance-initializers.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\
|
|
5
|
+
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\nconst LEGACY_POST_CONSTRUCTION_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-post-construction-initializers');\nconst LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS = Symbol.for(\n\t'@ecopages/radiant.legacy-executed-post-construction-initializers',\n);\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_INSTANCE_INITIALIZERS, initializer);\n}\n\n/**\n * Registers post-construction work for a legacy decorator.\n *\n * This phase exists for decorators that eagerly write instance fields. With\n * legacy decorators plus `useDefineForClassFields`, subclass field definition\n * can overwrite values written during the base-class constructor.\n */\nexport function registerLegacyPostConstructionInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_POST_CONSTRUCTION_INITIALIZERS, initializer);\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\trunLegacyInitializers(instance, LEGACY_INSTANCE_INITIALIZERS);\n}\n\n/**\n * Runs legacy decorator setup that must happen after subclass field\n * initialization has completed.\n *\n * Each initializer runs at most once per instance even if multiple lifecycle\n * entrypoints call this helper.\n */\nexport function runLegacyPostConstructionInitializers<T extends object>(instance: T): void {\n\tconst target = instance as Record<PropertyKey, unknown>;\n\n\trunLegacyInitializers(\n\t\tinstance,\n\t\tLEGACY_POST_CONSTRUCTION_INITIALIZERS,\n\t\t(target[LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS] ??= new Set()) as Set<LegacyInstanceInitializer<T>>,\n\t);\n}\n\nfunction registerInitializer<T extends object>(proto: T, key: symbol, initializer: LegacyInstanceInitializer<T>): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = Object.prototype.hasOwnProperty.call(target, key) ? target[key] : undefined;\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(target, key, {\n\t\tvalue: [initializer],\n\t});\n}\n\nfunction runLegacyInitializers<T extends object>(\n\tinstance: T,\n\tkey: symbol,\n\texecutedInitializers?: Set<LegacyInstanceInitializer<T>>,\n\tprototype: object | null = Object.getPrototypeOf(instance),\n): void {\n\tif (!prototype || prototype === Object.prototype) {\n\t\treturn;\n\t}\n\n\trunLegacyInitializers(instance, key, executedInitializers, Object.getPrototypeOf(prototype));\n\n\tconst initializers = (prototype as Record<PropertyKey, unknown>)[key] as LegacyInstanceInitializer<T>[] | undefined;\n\n\tif (!Array.isArray(initializers)) {\n\t\treturn;\n\t}\n\n\tfor (const initializer of initializers) {\n\t\tif (executedInitializers?.has(initializer)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tinitializer(instance);\n\t\texecutedInitializers?.add(initializer);\n\t}\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,EAC1F,EAAwC,OAAO,IAAI,yDAAyD,EAC5G,EAAiD,OAAO,IAC7D,kEACD,EAQO,SAAS,CAAmD,CAClE,EACA,EACO,CACP,EAAoB,EAAO,EAA8B,CAAW,EAU9D,SAAS,CAA2D,CAC1E,EACA,EACO,CACP,EAAoB,EAAO,EAAuC,CAAW,EASvE,SAAS,CAA+C,CAAC,EAAmB,CAClF,EAAsB,EAAU,CAA4B,EAUtD,SAAS,CAAuD,CAAC,EAAmB,CAC1F,IAAM,EAAS,EAEf,EACC,EACA,EACC,EAAO,KAAoD,IAAI,GACjE,EAGD,SAAS,CAAqC,CAAC,EAAU,EAAa,EAAiD,CACtH,IAAM,EAAS,EACT,EAAkB,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAG,EAAI,EAAO,GAAO,OAE1F,GAAI,MAAM,QAAQ,CAAe,EAAG,CACnC,EAAgB,KAAK,CAAW,EAChC,OAGD,OAAO,eAAe,EAAQ,EAAK,CAClC,MAAO,CAAC,CAAW,CACpB,CAAC,EAGF,SAAS,CAAuC,CAC/C,EACA,EACA,EACA,EAA2B,OAAO,eAAe,CAAQ,EAClD,CACP,GAAI,CAAC,GAAa,IAAc,OAAO,UACtC,OAGD,EAAsB,EAAU,EAAK,EAAsB,OAAO,eAAe,CAAS,CAAC,EAE3F,IAAM,EAAgB,EAA2C,GAEjE,GAAI,CAAC,MAAM,QAAQ,CAAY,EAC9B,OAGD,QAAW,KAAe,EAAc,CACvC,GAAI,GAAsB,IAAI,CAAW,EACxC,SAGD,EAAY,CAAQ,EACpB,GAAsB,IAAI,CAAW",
|
|
8
|
+
"debugId": "31B43FCC2270E87364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var H=(($)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy($,{get:(x,W)=>(typeof require<"u"?require:x)[W]}):$)(function($){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var U=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),Y=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),R=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function Z($,x){N($,U,x)}function m($,x){N($,Y,x)}function v($){J($,U)}function L($){let x=$;J($,Y,x[R]??=new Set)}function N($,x,W){let j=$,B=Object.prototype.hasOwnProperty.call(j,x)?j[x]:void 0;if(Array.isArray(B)){B.push(W);return}Object.defineProperty(j,x,{value:[W]})}function J($,x,W,j=Object.getPrototypeOf($)){if(!j||j===Object.prototype)return;J($,x,W,Object.getPrototypeOf(j));let B=j[x];if(!Array.isArray(B))return;for(let F of B){if(W?.has(F))continue;F($),W?.add(F)}}function _($){let x=globalThis.CSS;if(typeof x?.escape==="function")return x.escape($);let W="";for(let j=0;j<$.length;j+=1){let B=$[j]??"",F=B.codePointAt(0)??0;if(F===0){W+="�";continue}let D=F>=1&&F<=31||F===127,P=j===0&&F>=48&&F<=57,Q=j===1&&F>=48&&F<=57&&($[0]??"")==="-",V=j===0&&B==="-"&&$.length===1;if(D||P||Q){W+=`\\${F.toString(16)} `;continue}if(F>=128||B==="-"||B==="_"||F>=48&&F<=57||F>=65&&F<=90||F>=97&&F<=122){W+=V?`\\${B}`:B;continue}W+=`\\${B}`}return W}var X=Symbol("radiant.shadowRootListenerHooks"),K=Symbol("radiant.patchedAttachShadow");function S($){if($ instanceof Element)return $;if("host"in $)return $.host;return $.element}function A($){return!($ instanceof Element)}function O($,x,W,j){let B=(F)=>{if(F.target instanceof Element&&F.target.matches(W))j(F)};return $.addEventListener(x.type,B,x.options),()=>{$.removeEventListener(x.type,B,x.options)}}function E($,x){let W=S($);if(!W[X])W[X]=new Set;if(W[X].add(x),W[K])return;let j=W.attachShadow;W.attachShadow=function(F){let D=j.call(this,F);for(let P of W[X]??[])P();return D},W[K]=!0}function T($,x,W){if(A($)&&"scope"in x&&x.scope&&x.scope!=="light")throw Error("RadiantController event listeners only support light DOM scope.");let j=S($),B=W.bind($),F=null,D=null,P=null,Q=null,V=!1,G=()=>{F?.(),D?.(),P?.(),Q?.(),F=null,D=null,P=null,Q=null},q=()=>{if(V)return;if("window"in x&&!F)window.addEventListener(x.type,B,x.options),F=()=>{window.removeEventListener(x.type,B,x.options)};if("document"in x&&!D)document.addEventListener(x.type,B,x.options),D=()=>{document.removeEventListener(x.type,B,x.options)};if("selector"in x||"ref"in x){let M="selector"in x?x.selector:`[data-ref='${_(x.ref)}']`;if(x.scope!=="shadow"&&!P)P=O(j,x,M,B);if(x.scope!=="light"&&j.shadowRoot&&!Q)Q=O(j.shadowRoot,x,M,B)}};if("selector"in x||"ref"in x){if(x.scope!=="light")E($,()=>{if($.isConnected)q()})}if($.registerConnectedCallback(q),$.registerCleanupCallback(G),$.isConnected)q();return()=>{V=!0,G()}}function w($){return(x,W,j)=>{let B=j.value;return Z(x,(F)=>{T(F,$,B.bind(F))}),j}}export{w as onEvent};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=23FB8CBE1C12C11964756E2164756E21
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/helpers/create-event-listener.ts", "../src/decorators/legacy/on-event.ts"],
|
|
3
|
+
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/tools/escape-css-identifier.ts", "../src/helpers/create-event-listener.ts", "../src/decorators/legacy/on-event.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\
|
|
6
|
-
"
|
|
5
|
+
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\nconst LEGACY_POST_CONSTRUCTION_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-post-construction-initializers');\nconst LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS = Symbol.for(\n\t'@ecopages/radiant.legacy-executed-post-construction-initializers',\n);\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_INSTANCE_INITIALIZERS, initializer);\n}\n\n/**\n * Registers post-construction work for a legacy decorator.\n *\n * This phase exists for decorators that eagerly write instance fields. With\n * legacy decorators plus `useDefineForClassFields`, subclass field definition\n * can overwrite values written during the base-class constructor.\n */\nexport function registerLegacyPostConstructionInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tregisterInitializer(proto, LEGACY_POST_CONSTRUCTION_INITIALIZERS, initializer);\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\trunLegacyInitializers(instance, LEGACY_INSTANCE_INITIALIZERS);\n}\n\n/**\n * Runs legacy decorator setup that must happen after subclass field\n * initialization has completed.\n *\n * Each initializer runs at most once per instance even if multiple lifecycle\n * entrypoints call this helper.\n */\nexport function runLegacyPostConstructionInitializers<T extends object>(instance: T): void {\n\tconst target = instance as Record<PropertyKey, unknown>;\n\n\trunLegacyInitializers(\n\t\tinstance,\n\t\tLEGACY_POST_CONSTRUCTION_INITIALIZERS,\n\t\t(target[LEGACY_EXECUTED_POST_CONSTRUCTION_INITIALIZERS] ??= new Set()) as Set<LegacyInstanceInitializer<T>>,\n\t);\n}\n\nfunction registerInitializer<T extends object>(proto: T, key: symbol, initializer: LegacyInstanceInitializer<T>): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = Object.prototype.hasOwnProperty.call(target, key) ? target[key] : undefined;\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(target, key, {\n\t\tvalue: [initializer],\n\t});\n}\n\nfunction runLegacyInitializers<T extends object>(\n\tinstance: T,\n\tkey: symbol,\n\texecutedInitializers?: Set<LegacyInstanceInitializer<T>>,\n\tprototype: object | null = Object.getPrototypeOf(instance),\n): void {\n\tif (!prototype || prototype === Object.prototype) {\n\t\treturn;\n\t}\n\n\trunLegacyInitializers(instance, key, executedInitializers, Object.getPrototypeOf(prototype));\n\n\tconst initializers = (prototype as Record<PropertyKey, unknown>)[key] as LegacyInstanceInitializer<T>[] | undefined;\n\n\tif (!Array.isArray(initializers)) {\n\t\treturn;\n\t}\n\n\tfor (const initializer of initializers) {\n\t\tif (executedInitializers?.has(initializer)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tinitializer(instance);\n\t\texecutedInitializers?.add(initializer);\n\t}\n}\n",
|
|
6
|
+
"export function escapeCssIdentifier(value: string): string {\n\tconst cssNamespace = globalThis.CSS as { escape?: (value: string) => string } | undefined;\n\n\tif (typeof cssNamespace?.escape === 'function') {\n\t\treturn cssNamespace.escape(value);\n\t}\n\n\tlet escaped = '';\n\n\tfor (let index = 0; index < value.length; index += 1) {\n\t\tconst character = value[index] ?? '';\n\t\tconst codePoint = character.codePointAt(0) ?? 0;\n\n\t\tif (codePoint === 0) {\n\t\t\tescaped += '\\uFFFD';\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isControlCharacter = (codePoint >= 0x0001 && codePoint <= 0x001f) || codePoint === 0x007f;\n\t\tconst startsWithDigit = index === 0 && codePoint >= 0x0030 && codePoint <= 0x0039;\n\t\tconst startsWithHyphenDigit =\n\t\t\tindex === 1 && codePoint >= 0x0030 && codePoint <= 0x0039 && (value[0] ?? '') === '-';\n\t\tconst isSingleHyphen = index === 0 && character === '-' && value.length === 1;\n\n\t\tif (isControlCharacter || startsWithDigit || startsWithHyphenDigit) {\n\t\t\tescaped += `\\\\${codePoint.toString(16)} `;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\tcodePoint >= 0x0080 ||\n\t\t\tcharacter === '-' ||\n\t\t\tcharacter === '_' ||\n\t\t\t(codePoint >= 0x0030 && codePoint <= 0x0039) ||\n\t\t\t(codePoint >= 0x0041 && codePoint <= 0x005a) ||\n\t\t\t(codePoint >= 0x0061 && codePoint <= 0x007a)\n\t\t) {\n\t\t\tescaped += isSingleHyphen ? `\\\\${character}` : character;\n\t\t\tcontinue;\n\t\t}\n\n\t\tescaped += `\\\\${character}`;\n\t}\n\n\treturn escaped;\n}\n",
|
|
7
|
+
"import type { RadiantElementEventListener } from '../core/radiant-element';\nimport { escapeCssIdentifier } from '../tools/escape-css-identifier';\n\n/**\n * Selects which DOM tree delegated event listeners should observe.\n */\nexport type OnEventScope = 'light' | 'shadow' | 'both';\n\ntype BaseOnEventConfig = Pick<RadiantElementEventListener, 'type' | 'options'> & {\n\tscope?: OnEventScope;\n};\n\nexport type OnEventConfig = BaseOnEventConfig &\n\t(\n\t\t| {\n\t\t\t\tselector: string;\n\t\t }\n\t\t| {\n\t\t\t\tref: string;\n\t\t }\n\t\t| {\n\t\t\t\twindow: true;\n\t\t }\n\t\t| {\n\t\t\t\tdocument: true;\n\t\t }\n\t);\n\ntype DelegatedEventRoot = Element | ShadowRoot;\n\ntype EventListenerLifecycleHost = {\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterCleanupCallback(callback: () => void): void;\n\tisConnected: boolean;\n};\n\nexport type EventListenerHost =\n\t| (EventListenerLifecycleHost & Element)\n\t| (EventListenerLifecycleHost & { host: Element })\n\t| (EventListenerLifecycleHost & { element: Element });\n\nconst shadowRootListenerHooksKey = Symbol('radiant.shadowRootListenerHooks');\nconst patchedAttachShadowKey = Symbol('radiant.patchedAttachShadow');\n\ntype ShadowRootHookHost = Element & {\n\t[patchedAttachShadowKey]?: true;\n\t[shadowRootListenerHooksKey]?: Set<() => void>;\n};\n\nfunction resolveEventListenerHostElement(host: EventListenerHost): Element {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\treturn host.element;\n}\n\nfunction isControllerEventHost(host: EventListenerHost): host is EventListenerLifecycleHost & { host: Element } {\n\treturn !(host instanceof Element);\n}\n\nfunction addDelegatedListener(\n\troot: DelegatedEventRoot,\n\tconfig: Pick<OnEventConfig, 'type' | 'options'>,\n\tselector: string,\n\tlistener: EventListener,\n): () => void {\n\tconst delegatedListener = (event: Event) => {\n\t\tif (event.target instanceof Element && event.target.matches(selector)) {\n\t\t\tlistener(event);\n\t\t}\n\t};\n\n\troot.addEventListener(config.type, delegatedListener, config.options);\n\n\treturn () => {\n\t\troot.removeEventListener(config.type, delegatedListener, config.options);\n\t};\n}\n\nfunction registerShadowRootHook(host: EventListenerHost, hook: () => void): void {\n\tconst shadowAwareHost = resolveEventListenerHostElement(host) as ShadowRootHookHost;\n\n\tif (!shadowAwareHost[shadowRootListenerHooksKey]) {\n\t\tshadowAwareHost[shadowRootListenerHooksKey] = new Set();\n\t}\n\n\tshadowAwareHost[shadowRootListenerHooksKey].add(hook);\n\n\tif (shadowAwareHost[patchedAttachShadowKey]) {\n\t\treturn;\n\t}\n\n\tconst originalAttachShadow = shadowAwareHost.attachShadow;\n\n\tshadowAwareHost.attachShadow = function patchedAttachShadow(init: ShadowRootInit): ShadowRoot {\n\t\tconst shadowRoot = originalAttachShadow.call(this, init);\n\t\tfor (const shadowRootHook of shadowAwareHost[shadowRootListenerHooksKey] ?? []) {\n\t\t\tshadowRootHook();\n\t\t}\n\t\treturn shadowRoot;\n\t};\n\n\tshadowAwareHost[patchedAttachShadowKey] = true;\n}\n\n/**\n * Subscribes to a DOM event with delegation, window, or document targeting.\n * Functional equivalent of the `@onEvent` decorator for vanilla JS usage.\n * Returns a cleanup function to remove the listener.\n * @param host The host RadiantElement.\n * @param config The event listener configuration.\n * @param callback The event handler function.\n */\nexport function createEventListener(\n\thost: EventListenerHost,\n\tconfig: OnEventConfig,\n\tcallback: (event: Event) => void,\n): () => void {\n\tif (isControllerEventHost(host) && 'scope' in config && config.scope && config.scope !== 'light') {\n\t\tthrow new Error('RadiantController event listeners only support light DOM scope.');\n\t}\n\n\tconst hostElement = resolveEventListenerHostElement(host);\n\tconst boundCallback = callback.bind(host);\n\tlet windowCleanup: (() => void) | null = null;\n\tlet documentCleanup: (() => void) | null = null;\n\tlet lightCleanup: (() => void) | null = null;\n\tlet shadowCleanup: (() => void) | null = null;\n\tlet disposed = false;\n\n\tconst detachListeners = () => {\n\t\twindowCleanup?.();\n\t\tdocumentCleanup?.();\n\t\tlightCleanup?.();\n\t\tshadowCleanup?.();\n\n\t\twindowCleanup = null;\n\t\tdocumentCleanup = null;\n\t\tlightCleanup = null;\n\t\tshadowCleanup = null;\n\t};\n\n\tconst attachListeners = () => {\n\t\tif (disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ('window' in config && !windowCleanup) {\n\t\t\twindow.addEventListener(config.type, boundCallback, config.options);\n\t\t\twindowCleanup = () => {\n\t\t\t\twindow.removeEventListener(config.type, boundCallback, config.options);\n\t\t\t};\n\t\t}\n\n\t\tif ('document' in config && !documentCleanup) {\n\t\t\tdocument.addEventListener(config.type, boundCallback, config.options);\n\t\t\tdocumentCleanup = () => {\n\t\t\t\tdocument.removeEventListener(config.type, boundCallback, config.options);\n\t\t\t};\n\t\t}\n\n\t\tif ('selector' in config || 'ref' in config) {\n\t\t\tconst selector = 'selector' in config ? config.selector : `[data-ref='${escapeCssIdentifier(config.ref)}']`;\n\n\t\t\tif (config.scope !== 'shadow' && !lightCleanup) {\n\t\t\t\tlightCleanup = addDelegatedListener(hostElement, config, selector, boundCallback);\n\t\t\t}\n\n\t\t\tif (config.scope !== 'light' && hostElement.shadowRoot && !shadowCleanup) {\n\t\t\t\tshadowCleanup = addDelegatedListener(hostElement.shadowRoot, config, selector, boundCallback);\n\t\t\t}\n\t\t}\n\t};\n\n\tif ('selector' in config || 'ref' in config) {\n\t\tif (config.scope !== 'light') {\n\t\t\tregisterShadowRootHook(host, () => {\n\t\t\t\tif (host.isConnected) {\n\t\t\t\t\tattachListeners();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\thost.registerConnectedCallback(attachListeners);\n\thost.registerCleanupCallback(detachListeners);\n\n\tif (host.isConnected) {\n\t\tattachListeners();\n\t}\n\n\treturn () => {\n\t\tdisposed = true;\n\t\tdetachListeners();\n\t};\n}\n",
|
|
7
8
|
"import { createEventListener, type EventListenerHost } from '../../helpers/create-event-listener';\nimport type { OnEventConfig } from '../on-event';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\n/**\n * A decorator to subscribe to an event on the target element.\n * The event listener will be automatically unsubscribed when the element is disconnected.\n *\n * Note: This decorator uses event delegation, which means it relies on event bubbling.\n * Therefore, it will not work with events that do not bubble, such as `focus`, `blur`, `load`, `unload`, `scroll`, etc.\n * For focus and blur events, consider using `focusin` and `focusout` which are similar but do bubble.\n *\n * @param eventConfig The event configuration.\n * @param eventConfig.selectors The CSS selector(s) of the target element(s).\n * @param eventConfig.ref The data-ref attribute of the target element.\n * @param eventConfig.type The type of the event to listen for.\n * @param eventConfig.options Optional. An options object that specifies characteristics about the event listener.\n */\nexport function onEvent(eventConfig: OnEventConfig) {\n\treturn (proto: EventListenerHost, _: string, descriptor: PropertyDescriptor) => {\n\t\tconst originalMethod = descriptor.value;\n\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tcreateEventListener(element, eventConfig, originalMethod.bind(element));\n\t\t});\n\n\t\treturn descriptor;\n\t};\n}\n"
|
|
8
9
|
],
|
|
9
|
-
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,
|
|
10
|
-
"debugId": "
|
|
10
|
+
"mappings": "2PAEA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,EAC1F,EAAwC,OAAO,IAAI,yDAAyD,EAC5G,EAAiD,OAAO,IAC7D,kEACD,EAQO,SAAS,CAAmD,CAClE,EACA,EACO,CACP,EAAoB,EAAO,EAA8B,CAAW,EAU9D,SAAS,CAA2D,CAC1E,EACA,EACO,CACP,EAAoB,EAAO,EAAuC,CAAW,EASvE,SAAS,CAA+C,CAAC,EAAmB,CAClF,EAAsB,EAAU,CAA4B,EAUtD,SAAS,CAAuD,CAAC,EAAmB,CAC1F,IAAM,EAAS,EAEf,EACC,EACA,EACC,EAAO,KAAoD,IAAI,GACjE,EAGD,SAAS,CAAqC,CAAC,EAAU,EAAa,EAAiD,CACtH,IAAM,EAAS,EACT,EAAkB,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAG,EAAI,EAAO,GAAO,OAE1F,GAAI,MAAM,QAAQ,CAAe,EAAG,CACnC,EAAgB,KAAK,CAAW,EAChC,OAGD,OAAO,eAAe,EAAQ,EAAK,CAClC,MAAO,CAAC,CAAW,CACp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AGD,GAAI,WAAY,GAAU,CAAC,EAC1B,OAAO,iBAAiB,EAAO,KAAM,EAAe,EAAO,OAAO,EAClE,EAAgB,IAAM,CACrB,OAAO,oBAAoB,EAAO,KAAM,EAAe,EAAO,OAAO,GAIvE,GAAI,aAAc,GAAU,CAAC,EAC5B,SAAS,iBAAiB,EAAO,KAAM,EAAe,EAAO,OAAO,EACpE,EAAkB,IAAM,CACvB,SAAS,oBAAoB,EAAO,KAAM,EAAe,EAAO,OAAO,GAIzE,GAAI,aAAc,GAAU,QAAS,EAAQ,CAC5C,IAAM,EAAW,aAAc,EAAS,EAAO,SAAW,cAAc,EAAoB,EAAO,GAAG,MAEtG,GAAI,EAAO,QAAU,UAAY,CAAC,EACjC,EAAe,EAAqB,EAAa,EAAQ,EAAU,CAAa,EAGjF,GAAI,EAAO,QAAU,SAAW,EAAY,YAAc,CAAC,EAC1D,EAAgB,EAAqB,EAAY,WAAY,EAAQ,EAAU,CAAa,IAK/F,GAAI,aAAc,GAAU,QAAS,GACpC,GAAI,EAAO,QAAU,QACpB,EAAuB,EAAM,IAAM,CAClC,GAAI,EAAK,YACR,EAAgB,EAEjB,EAOH,GAHA,EAAK,0BAA0B,CAAe,EAC9C,EAAK,wBAAwB,CAAe,EAExC,EAAK,YACR,EAAgB,EAGjB,MAAO,IAAM,CACZ,EAAW,GACX,EAAgB,GCpLX,SAAS,CAAO,CAAC,EAA4B,CACnD,MAAO,CAAC,EAA0B,EAAW,IAAmC,CAC/E,IAAM,EAAiB,EAAW,MAMlC,OAJA,EAAkC,EAAO,CAAC,IAAY,CACrD,EAAoB,EAAS,EAAa,EAAe,KAAK,CAAO,CAAC,EACtE,EAEM",
|
|
11
|
+
"debugId": "23FB8CBE1C12C11964756E2164756E21",
|
|
11
12
|
"names": []
|
|
12
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type LegacyUpdatedHost = {
|
|
2
2
|
registerCleanupCallback(callback: () => void): void;
|
|
3
3
|
registerConnectedCallback(callback: () => void): void;
|
|
4
|
-
registerUpdateCallback(key: string, update: (
|
|
4
|
+
registerUpdateCallback(key: string, update: () => void): () => void;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
7
|
* A decorator to subscribe to an updated callback when a reactive field or property changes.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=((f)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(f,{get:(j,B)=>(typeof require<"u"?require:j)[B]}):f)(function(f){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+f+'" is not supported')});var Q=Symbol.for("@ecopages/radiant.legacy-instance-initializers"),V=Symbol.for("@ecopages/radiant.legacy-post-construction-initializers"),$=Symbol.for("@ecopages/radiant.legacy-executed-post-construction-initializers");function W(f,j){X(f,Q,j)}function G(f,j){X(f,V,j)}function M(f){J(f,Q)}function P(f){let j=f;J(f,V,j[$]??=new Set)}function X(f,j,B){let v=f,q=Object.prototype.hasOwnProperty.call(v,j)?v[j]:void 0;if(Array.isArray(q)){q.push(B);return}Object.defineProperty(v,j,{value:[B]})}function J(f,j,B,v=Object.getPrototypeOf(f)){if(!v||v===Object.prototype)return;J(f,j,B,Object.getPrototypeOf(v));let q=v[j];if(!Array.isArray(q))return;for(let D of q){if(B?.has(D))continue;D(f),B?.add(D)}}function Z(f){return(j,B)=>{let v=Symbol(`@ecopages/radiant/on-updated:${B}:cleanup`);W(j,(q)=>{q.registerConnectedCallback(()=>{let D=q[B].bind(q),F=[];if(Array.isArray(f))for(let H of f)F.push(q.registerUpdateCallback(H,D));else if(typeof f==="string")F.push(q.registerUpdateCallback(f,D));q[v]=()=>{for(let H of F)H()}}),q.registerCleanupCallback(()=>{let D=q[v];if(typeof D==="function")D(),delete q[v]})})}}export{Z as onUpdated};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=CF508F1A5822955664756E2164756E21
|