@ecopages/radiant 0.3.0-beta.1 → 0.3.0-beta.3
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/README.md +11 -7
- package/client/app-bootstrap.js +2 -2
- package/client/app-bootstrap.js.map +2 -2
- package/client/hydrator.js +2 -2
- package/client/hydrator.js.map +2 -2
- package/client/install-hydrator.js +2 -2
- package/client/install-hydrator.js.map +2 -2
- package/context/context-consumer-bootstrap.js +2 -2
- package/context/context-consumer-bootstrap.js.map +4 -4
- package/context/context-consumer-runtime.js +2 -2
- package/context/context-consumer-runtime.js.map +4 -4
- package/context/context-host.js +2 -2
- package/context/context-host.js.map +2 -2
- package/context/context-provider.js +2 -2
- package/context/context-provider.js.map +2 -2
- package/context/context-ssr-bridge.d.ts +1 -1
- package/context/context-ssr-bridge.js +2 -2
- package/context/context-ssr-bridge.js.map +3 -3
- package/context/create-context.js +2 -2
- package/context/create-context.js.map +2 -2
- package/context/decorators/consume-context.js +2 -2
- package/context/decorators/consume-context.js.map +4 -4
- package/context/decorators/context-selection-delivery.js +2 -2
- package/context/decorators/context-selection-delivery.js.map +2 -2
- package/context/decorators/context-selector.js +2 -2
- package/context/decorators/context-selector.js.map +4 -4
- package/context/decorators/legacy/consume-context.js +2 -2
- package/context/decorators/legacy/consume-context.js.map +4 -4
- package/context/decorators/legacy/context-selector-field.js +2 -2
- package/context/decorators/legacy/context-selector-field.js.map +4 -4
- package/context/decorators/legacy/context-selector.js +2 -2
- package/context/decorators/legacy/context-selector.js.map +4 -4
- package/context/decorators/legacy/provide-context.js +2 -2
- package/context/decorators/legacy/provide-context.js.map +2 -2
- package/context/decorators/on-context-update.js +2 -2
- package/context/decorators/on-context-update.js.map +4 -4
- package/context/decorators/provide-context.js +2 -2
- package/context/decorators/provide-context.js.map +2 -2
- package/context/decorators/standard/consume-context.js +2 -2
- package/context/decorators/standard/consume-context.js.map +4 -4
- package/context/decorators/standard/context-selector-field.js +2 -2
- package/context/decorators/standard/context-selector-field.js.map +4 -4
- package/context/decorators/standard/context-selector.js +2 -2
- package/context/decorators/standard/context-selector.js.map +4 -4
- package/context/decorators/standard/provide-context.js +2 -2
- package/context/decorators/standard/provide-context.js.map +2 -2
- package/context/decorators/standard-legacy-dispatch.js +2 -2
- package/context/decorators/standard-legacy-dispatch.js.map +2 -2
- package/context/events.js +2 -2
- package/context/events.js.map +2 -2
- package/context/hydration-script.js +2 -2
- package/context/hydration-script.js.map +2 -2
- package/context/index.js +2 -2
- package/context/index.js.map +4 -4
- package/controller-registry.js +2 -2
- package/controller-registry.js.map +2 -2
- package/core/controller-metadata.js +2 -2
- package/core/controller-metadata.js.map +2 -2
- package/core/custom-element-metadata.js +2 -2
- package/core/custom-element-metadata.js.map +2 -2
- package/core/event-subscription-registry.js +2 -2
- package/core/event-subscription-registry.js.map +2 -2
- package/core/host-ssr-registry.js +2 -2
- package/core/host-ssr-registry.js.map +2 -2
- package/core/hydration-capable-host.js +2 -2
- package/core/hydration-capable-host.js.map +2 -2
- package/core/hydration-codec.js +2 -2
- package/core/hydration-codec.js.map +2 -2
- package/core/radiant-controller.js +2 -2
- package/core/radiant-controller.js.map +2 -2
- package/core/radiant-element-brand.d.ts +2 -0
- package/core/radiant-element-brand.js +3 -0
- package/core/radiant-element-brand.js.map +10 -0
- package/core/radiant-element-ssr-host-source.d.ts +32 -0
- package/core/radiant-element-ssr-host-source.js +3 -0
- package/core/radiant-element-ssr-host-source.js.map +11 -0
- package/core/radiant-element-ssr-host.d.ts +5 -6
- package/core/radiant-element-ssr-host.js +1 -2
- package/core/radiant-element-ssr-host.js.map +3 -4
- package/core/radiant-element-ssr-registry.d.ts +24 -11
- package/core/radiant-element-ssr-registry.js +2 -2
- package/core/radiant-element-ssr-registry.js.map +3 -3
- package/core/radiant-element.d.ts +5 -3
- package/core/radiant-element.js +2 -2
- package/core/radiant-element.js.map +6 -5
- package/core/radiant-hydrator-state.js +2 -2
- package/core/radiant-hydrator-state.js.map +2 -2
- package/core/reactive-binding-adapter.js +2 -2
- package/core/reactive-binding-adapter.js.map +2 -2
- package/core/reactive-host.js +2 -2
- package/core/reactive-host.js.map +2 -2
- package/core/reactive-jsx-value.js +2 -2
- package/core/reactive-jsx-value.js.map +2 -2
- package/core/reactive-prop-core.js +2 -2
- package/core/reactive-prop-core.js.map +2 -2
- package/core/reactive-prop-metadata.js +2 -2
- package/core/reactive-prop-metadata.js.map +2 -2
- package/core/reactive-property-state.js +2 -2
- package/core/reactive-property-state.js.map +2 -2
- package/core/reactivity-adapter.js +2 -2
- package/core/reactivity-adapter.js.map +2 -2
- package/core/reactivity-runtime.js +2 -2
- package/core/reactivity-runtime.js.map +2 -2
- package/core/reactivity-signals.js +2 -2
- package/core/reactivity-signals.js.map +2 -2
- package/core/render-runtime.js +2 -2
- package/core/render-runtime.js.map +2 -2
- package/core/render-scheduler.js +2 -2
- package/core/render-scheduler.js.map +2 -2
- package/core/slot-projection-runtime.js +2 -2
- package/core/slot-projection-runtime.js.map +2 -2
- package/core/ssr-preparation.js +2 -2
- package/core/ssr-preparation.js.map +2 -2
- package/decorators/attr.js +2 -2
- package/decorators/attr.js.map +2 -2
- package/decorators/bound.js +2 -2
- package/decorators/bound.js.map +2 -2
- package/decorators/bridge.js +2 -2
- package/decorators/bridge.js.map +2 -2
- package/decorators/controller.js +2 -2
- package/decorators/controller.js.map +2 -2
- package/decorators/custom-element.js +2 -2
- package/decorators/custom-element.js.map +2 -2
- package/decorators/debounce.js +2 -2
- package/decorators/debounce.js.map +2 -2
- package/decorators/event.js +2 -2
- package/decorators/event.js.map +2 -2
- package/decorators/legacy/attr.js +2 -2
- package/decorators/legacy/attr.js.map +2 -2
- package/decorators/legacy/bound.js +2 -2
- package/decorators/legacy/bound.js.map +2 -2
- package/decorators/legacy/custom-element.js +2 -2
- package/decorators/legacy/custom-element.js.map +2 -2
- package/decorators/legacy/debounce.js +2 -2
- package/decorators/legacy/debounce.js.map +2 -2
- package/decorators/legacy/event.js +2 -2
- package/decorators/legacy/event.js.map +2 -2
- package/decorators/legacy/host-readiness.js +2 -2
- package/decorators/legacy/host-readiness.js.map +2 -2
- package/decorators/legacy/instance-initializers.js +2 -2
- package/decorators/legacy/instance-initializers.js.map +2 -2
- package/decorators/legacy/member-bootstrap.js +2 -2
- package/decorators/legacy/member-bootstrap.js.map +2 -2
- package/decorators/legacy/on-event.js +2 -2
- package/decorators/legacy/on-event.js.map +2 -2
- package/decorators/legacy/on-updated.js +2 -2
- package/decorators/legacy/on-updated.js.map +2 -2
- package/decorators/legacy/query-slot.js +2 -2
- package/decorators/legacy/query-slot.js.map +2 -2
- package/decorators/legacy/query.js +2 -2
- package/decorators/legacy/query.js.map +2 -2
- package/decorators/legacy/reactive-field.js +2 -2
- package/decorators/legacy/reactive-field.js.map +2 -2
- package/decorators/legacy/reactive-prop.js +2 -2
- package/decorators/legacy/reactive-prop.js.map +2 -2
- package/decorators/legacy/signal.js +2 -2
- package/decorators/legacy/signal.js.map +2 -2
- package/decorators/on-event.js +2 -2
- package/decorators/on-event.js.map +2 -2
- package/decorators/on-updated.js +2 -2
- package/decorators/on-updated.js.map +2 -2
- package/decorators/prop.js +2 -2
- package/decorators/prop.js.map +2 -2
- package/decorators/query-slot.js +2 -2
- package/decorators/query-slot.js.map +2 -2
- package/decorators/query.js +2 -2
- package/decorators/query.js.map +2 -2
- package/decorators/shared/auto-bind.js +2 -2
- package/decorators/shared/auto-bind.js.map +2 -2
- package/decorators/shared/reactive-attr.js +2 -2
- package/decorators/shared/reactive-attr.js.map +2 -2
- package/decorators/signal.js +2 -2
- package/decorators/signal.js.map +2 -2
- package/decorators/standard/attr.js +2 -2
- package/decorators/standard/attr.js.map +2 -2
- package/decorators/standard/bound.js +2 -2
- package/decorators/standard/bound.js.map +2 -2
- package/decorators/standard/custom-element.js +2 -2
- package/decorators/standard/custom-element.js.map +2 -2
- package/decorators/standard/debounce.js +2 -2
- package/decorators/standard/debounce.js.map +2 -2
- package/decorators/standard/event.js +2 -2
- package/decorators/standard/event.js.map +2 -2
- package/decorators/standard/on-event.js +2 -2
- package/decorators/standard/on-event.js.map +2 -2
- package/decorators/standard/on-updated.js +2 -2
- package/decorators/standard/on-updated.js.map +2 -2
- package/decorators/standard/query-slot.js +2 -2
- package/decorators/standard/query-slot.js.map +2 -2
- package/decorators/standard/query.js +2 -2
- package/decorators/standard/query.js.map +2 -2
- package/decorators/standard/reactive-field.js +2 -2
- package/decorators/standard/reactive-field.js.map +2 -2
- package/decorators/standard/reactive-prop.js +2 -2
- package/decorators/standard/reactive-prop.js.map +2 -2
- package/decorators/standard/signal.js +2 -2
- package/decorators/standard/signal.js.map +2 -2
- package/decorators/state.js +2 -2
- package/decorators/state.js.map +2 -2
- package/helpers/create-event-listener.js +2 -2
- package/helpers/create-event-listener.js.map +2 -2
- package/helpers/create-event.js +2 -2
- package/helpers/create-event.js.map +2 -2
- package/helpers/create-query-slot.js +2 -2
- package/helpers/create-query-slot.js.map +2 -2
- package/helpers/create-query.js +2 -2
- package/helpers/create-query.js.map +2 -2
- package/helpers/debounce.js +2 -2
- package/helpers/debounce.js.map +2 -2
- package/helpers/index.js +2 -2
- package/helpers/index.js.map +2 -2
- package/index.js +2 -2
- package/index.js.map +6 -5
- package/package.json +13 -3
- package/server/assert-light-dom-ssr.d.ts +10 -0
- package/server/assert-light-dom-ssr.js +3 -0
- package/server/assert-light-dom-ssr.js.map +10 -0
- package/server/context-ssr.d.ts +8 -19
- package/server/context-ssr.js +2 -2
- package/server/context-ssr.js.map +5 -5
- package/server/host-attribute-serialization.js +2 -2
- package/server/host-attribute-serialization.js.map +4 -4
- package/server/host-script-composition.js +2 -2
- package/server/host-script-composition.js.map +2 -2
- package/server/html-parser.js +2 -2
- package/server/html-parser.js.map +2 -2
- package/server/install-light-dom-shim.d.ts +2 -1
- package/server/install-light-dom-shim.js +2 -2
- package/server/install-light-dom-shim.js.map +9 -8
- package/server/install-ssr-runtime.d.ts +8 -0
- package/server/install-ssr-runtime.js +3 -0
- package/server/install-ssr-runtime.js.map +21 -0
- package/server/install-ssr-scope-adapters.d.ts +1 -0
- package/server/install-ssr-scope-adapters.js +3 -0
- package/server/install-ssr-scope-adapters.js.map +11 -0
- package/server/light-dom-shim.js +2 -2
- package/server/light-dom-shim.js.map +8 -7
- package/server/minimal-dom/dataset.d.ts +2 -0
- package/server/minimal-dom/dataset.js +3 -0
- package/server/minimal-dom/dataset.js.map +10 -0
- package/server/minimal-dom/document.js +2 -2
- package/server/minimal-dom/document.js.map +5 -6
- package/server/minimal-dom/html.d.ts +1 -2
- package/server/minimal-dom/html.js +2 -2
- package/server/minimal-dom/html.js.map +6 -5
- package/server/minimal-dom/install.d.ts +1 -0
- package/server/minimal-dom/install.js +2 -2
- package/server/minimal-dom/install.js.map +8 -7
- package/server/minimal-dom/nodes.d.ts +9 -0
- package/server/minimal-dom/nodes.js +3 -0
- package/server/minimal-dom/nodes.js.map +12 -0
- package/server/project-root.js +2 -2
- package/server/project-root.js.map +4 -5
- package/server/radiant-element-ssr-bridge.d.ts +9 -9
- package/server/radiant-element-ssr-bridge.js +2 -2
- package/server/radiant-element-ssr-bridge.js.map +27 -14
- package/server/radiant-element-ssr-extractor.d.ts +5 -1
- package/server/radiant-element-ssr-extractor.js +2 -2
- package/server/radiant-element-ssr-extractor.js.map +6 -5
- package/server/radiant-element-ssr-service.d.ts +4 -1
- package/server/radiant-element-ssr-service.js +2 -2
- package/server/radiant-element-ssr-service.js.map +15 -12
- package/server/radiant-element-ssr.d.ts +1 -1
- package/server/radiant-element-ssr.js +2 -2
- package/server/radiant-element-ssr.js.map +27 -14
- package/server/render-component.d.ts +3 -5
- package/server/render-component.js +2 -2
- package/server/render-component.js.map +27 -20
- package/server/render-controller.d.ts +1 -0
- package/server/render-controller.js +2 -2
- package/server/render-controller.js.map +30 -23
- package/server/render-fragment.js +2 -2
- package/server/render-fragment.js.map +2 -2
- package/server/slot-projection-html.js +2 -2
- package/server/slot-projection-html.js.map +5 -6
- package/signals/host-resource.js +2 -2
- package/signals/host-resource.js.map +2 -2
- package/signals/host-signal.js +2 -2
- package/signals/host-signal.js.map +2 -2
- package/signals/hydration-script.js +2 -2
- package/signals/hydration-script.js.map +2 -2
- package/tools/escape-css-identifier.js +2 -2
- package/tools/escape-css-identifier.js.map +2 -2
- package/tools/escape-script-json.js +2 -2
- package/tools/escape-script-json.js.map +2 -2
- package/tools/event-emitter.js +2 -2
- package/tools/event-emitter.js.map +2 -2
- package/tools/index.js +2 -2
- package/tools/index.js.map +2 -2
- package/tools/render-jsx-template.js +2 -2
- package/tools/render-jsx-template.js.map +2 -2
- package/types.js +2 -2
- package/types.js.map +2 -2
- package/utils/attribute-utils.js +2 -2
- package/utils/attribute-utils.js.map +2 -2
- package/utils/escape-html-attribute.js +2 -2
- package/utils/escape-html-attribute.js.map +2 -2
- package/utils/index.js +2 -2
- package/utils/index.js.map +2 -2
- package/server/internal-radiant-host.d.ts +0 -2
- package/server/internal-radiant-host.js +0 -3
- package/server/internal-radiant-host.js.map +0 -9
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"import type { ContextHostLike } from '../../context-host';\nimport { ContextProvider } from '../../context-provider';\nimport type { UnknownContext } from '../../types';\nimport type { ProvideContextOptions } from '../provide-context';\n\nexport function provideContext<T extends UnknownContext>({\n\tcontext,\n\tinitialValue,\n\thydrate,\n\tserialize,\n}: ProvideContextOptions<T>) {\n\treturn <C extends ContextHostLike, V>(target: undefined, targetContext: ClassFieldDecoratorContext<C, V>) => {\n\t\tvoid target;\n\t\tconst contextName = String(targetContext.name);\n\t\ttargetContext.addInitializer(function (this: C) {\n\t\t\tconst hostRecord = this as C & Record<string, unknown>;\n\t\t\tconst provider = new ContextProvider<T>(this, {\n\t\t\t\tcontext,\n\t\t\t\thydrationKey: contextName,\n\t\t\t\tinitialValue,\n\t\t\t\thydrate,\n\t\t\t\tserialize,\n\t\t\t});\n\t\t\thostRecord[contextName] = provider;\n\t\t\tthis.registerContextProvider(contextName, provider);\n\t\t\tthis.connectedContextCallback(context);\n\t\t});\n\t};\n}\n",
|
|
15
15
|
"import type { AttributeTypeConstant } from '../../utils';\nimport type { ContextHostLike } from '../context-host';\nimport type { UnknownContext } from '../types';\nimport { provideContext as legacyProvideContext } from './legacy/provide-context';\nimport { provideContext as standardProvideContext } from './standard/provide-context';\nimport { fieldDecoratorBridge } from '../../decorators/bridge';\n\nexport type ProvideContextOptions<T extends UnknownContext> = {\n\t/** Context token made available to descendant consumers. */\n\tcontext: T;\n\t/** Client-side default value installed before any SSR hydration is merged. */\n\tinitialValue?: T['__context__'];\n\t/** Attribute type used to opt the provider into SSR hydration. */\n\thydrate?: AttributeTypeConstant;\n\t/**\n\t * Projects the current provider value into an SSR-safe hydration payload.\n\t *\n\t * Use this when the live client context includes instances or other values\n\t * that should stay client-only. When `hydrate: Object` is active, the parsed\n\t * payload merges back into `initialValue`, so omitted members keep their\n\t * client-side defaults.\n\t */\n\tserialize?: (value: T['__context__']) => unknown;\n};\n\n/**\n * A decorator to provide a context to the target element.\n * @param options {@link ProvideContextOptions}\n * @returns\n */\nexport function provideContext<T extends UnknownContext>(options: ProvideContextOptions<T>) {\n\tfunction decorator<Host extends ContextHostLike, V>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<Host, V>,\n\t): void;\n\tfunction decorator(protoOrTarget: ContextHostLike, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ContextHostLike | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<ContextHostLike, unknown>,\n\t): void {\n\t\treturn fieldDecoratorBridge(\n\t\t\tstandardProvideContext(options),\n\t\t\tlegacyProvideContext(options),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n"
|
|
16
16
|
],
|
|
17
|
-
"mappings": "
|
|
18
|
-
"debugId": "
|
|
17
|
+
"mappings": "AAQA,IAAM,EAA+B,OAAO,IAAI,gDAAgD,EAC1F,EAAwC,OAAO,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oD,CAE5G,IAAM,EAAc,OAAO,EAAc,IAAI,EAC7C,EAAc,eAAe,QAAS,EAAU,CAC/C,IAAM,EAAa,KACb,EAAW,IAAI,EAAmB,KAAM,CAC7C,UACA,aAAc,EACd,eACA,UACA,WACD,CAAC,EACD,EAAW,GAAe,EAC1B,KAAK,wBAAwB,EAAa,CAAQ,EAClD,KAAK,yBAAyB,CAAO,EACrC,GCII,SAAS,EAAwC,CAAC,EAAmC,CAM3F,SAAS,CAAS,CACjB,EACA,EACO,CACP,OAAO,EACN,EAAuB,CAAO,EAC9B,EAAqB,CAAO,EAC5B,EACA,CACD,EAGD,OAAO",
|
|
18
|
+
"debugId": "6B84C8265C1AD6E564756E2164756E21",
|
|
19
19
|
"names": []
|
|
20
20
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Z=Symbol.for("@ecopages/radiant.ssr-preparation-callbacks"),f=Symbol.for("@ecopages/radiant.ssr-preparation-running");function K(j,D){let J=j[Z];if(Array.isArray(J)){J.push(D);return}Object.defineProperty(j,Z,{value:[D],configurable:!0})}function E(j){let D=j,M=D[Z];if(!Array.isArray(M))return;D[f]=!0;try{for(let J of M)J()}finally{delete D[f]}}var z;((Q)=>{Q.SUBSCRIPTION_REQUEST="context-subscription-request";Q.CONTEXT_REQUEST="context-request";Q.ON_MOUNT="context-on-mount";Q.MOUNTED="context-mounted"})(z||={});class $ extends Event{context;callback;subscribe;handled=!1;constructor(j,D,M){super("context-request",{bubbles:!0,composed:!0});this.context=j;this.callback=D;this.subscribe=M}markHandled(){this.handled=!0}}class N extends CustomEvent{constructor(j){super("context-on-mount",{detail:{context:j},bubbles:!0,composed:!0})}}class w extends Event{context;callback;select;subscribe;onSubscribe;handled=!1;constructor(j,D,M,J,Q){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=j;this.callback=D;this.select=M;this.subscribe=J;this.onSubscribe=Q}markHandled(){this.handled=!0}}var B;function P(j){B=j}function F(j){return B?.(j)}function G(j,D,M,J={}){let Q=F(D);if(!Q)return!1;if(M(Q),j.connectedContextCallback(D),J.emitMounted)j.dispatchEvent(new CustomEvent("context-mounted",{detail:Q}));return!0}function O(j,D,M,J={}){let Q=new $(D,(V)=>{if(M(V),j.connectedContextCallback(D),J.emitMounted)j.dispatchEvent(new CustomEvent("context-mounted",{detail:V}))});return j.dispatchEvent(Q),Q.handled}function X(j,D){let M=F(j);if(!M)return!1;let J=M.getContext();if(D.select)return D.callback(D.select(J)),!0;return D.callback(J),!0}function H(j,D,M,J){let Q=new w(D,M.callback,M.select,J.subscribe,J.onSubscribe);return j.dispatchEvent(Q),Q.handled}function L(j,D,M,J={}){return y(j,()=>G(j,D,M,J))}function R(j,D,M,J){return y(j,()=>{if(J)return X(D,{callback:M,select:J});return X(D,{callback:M})})}function I(j,D,M,J={}){if(G(j,D,M,J))return!0;return O(j,D,M,J)}function u(j,D,M,J={}){if(J.select){let V={callback:M,select:J.select};if(X(D,V))return!0;return H(j,D,V,{subscribe:J.subscribe,onSubscribe:J.onSubscribe})}let Q={callback:M};if(X(D,Q))return!0;return H(j,D,Q,{subscribe:J.subscribe,onSubscribe:J.onSubscribe})}function y(j,D){return K(j,D),D()}function h(j){return(D,M)=>{let J=String(M.name),Q=(W,Y)=>{let U=W;U[J]=Y},V=(W,Y={})=>{if(W[J])return!0;return I(W,j,(_)=>{Q(W,_)},Y)};M.addInitializer(function(){if(L(this,j,(W)=>{Q(this,W)},{emitMounted:!0}))return;this.registerConnectedCallback(()=>{if(V(this,{emitMounted:!0}))return;queueMicrotask(()=>{V(this,{emitMounted:!0})})})})}}export{h as consumeContext};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=2B8B6B77E0689A4664756E2164756E21
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/ssr-preparation.ts", "../src/context/
|
|
3
|
+
"sources": ["../src/core/ssr-preparation.ts", "../src/context/events.ts", "../src/context/context-ssr-bridge.ts", "../src/context/context-consumer-runtime.ts", "../src/context/context-consumer-bootstrap.ts", "../src/context/decorators/standard/consume-context.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"type SsrPreparationCallback = () => void;\n\nconst SSR_PREPARATION_CALLBACKS = Symbol.for('@ecopages/radiant.ssr-preparation-callbacks');\nexport const SSR_PREPARATION_RUNNING = Symbol.for('@ecopages/radiant.ssr-preparation-running');\n\n/**\n * Registers instance-local SSR preparation work that should run immediately\n * before a Radiant host serializes its first server render.\n *\n * Decorators use this to defer SSR-only setup until after class fields,\n * reactive props, and authored host content have all been applied.\n */\nexport function registerSsrPreparationCallback(host: object, callback: SsrPreparationCallback): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst existingCallbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (Array.isArray(existingCallbacks)) {\n\t\texistingCallbacks.push(callback);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(host, SSR_PREPARATION_CALLBACKS, {\n\t\tvalue: [callback],\n\t\tconfigurable: true,\n\t});\n}\n\n/**\n * Runs all registered SSR preparation callbacks for the provided host.\n *\n * The callbacks are intentionally retained so repeated SSR serializations stay\n * deterministic after later host mutations.\n */\nexport function runSsrPreparationCallbacks(host: object): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst callbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (!Array.isArray(callbacks)) {\n\t\treturn;\n\t}\n\n\ttarget[SSR_PREPARATION_RUNNING] = true;\n\n\ttry {\n\t\tfor (const callback of callbacks as SsrPreparationCallback[]) {\n\t\t\tcallback();\n\t\t}\n\t} finally {\n\t\tdelete target[SSR_PREPARATION_RUNNING];\n\t}\n}\n",
|
|
6
|
-
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nconst SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-provider-resolver');\n\ntype GlobalResolverScope = typeof globalThis & {\n\t[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?: SsrContextProviderResolver;\n};\n\nfunction getGlobalResolverScope(): GlobalResolverScope {\n\treturn globalThis as GlobalResolverScope;\n}\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tgetGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL] = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn getGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?.(context);\n}\n",
|
|
7
6
|
"import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n\tSUBSCRIPTION_REQUEST = 'context-subscription-request',\n\tCONTEXT_REQUEST = 'context-request',\n\tON_MOUNT = 'context-on-mount',\n\tMOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<ContextType<T>>,\n\t\tpublic readonly subscribe?: boolean,\n\t) {\n\t\tsuper(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\ntype DirectContextSubscription<T extends UnknownContext> = {\n\tselect?: undefined;\n\tcallback: ContextCallback<ContextType<T>>;\n};\n\ntype SelectedContextSubscription<T extends UnknownContext, Selected> = {\n\tselect: (context: ContextType<T>) => Selected;\n\tcallback: ContextCallback<Selected>;\n};\n\nexport type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> =\n\tDirectContextSubscription<T> | SelectedContextSubscription<T, Selected>;\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n\tpublic constructor(context: UnknownContext) {\n\t\tsuper(ContextEventsTypes.ON_MOUNT, {\n\t\t\tdetail: { context },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<Selected>,\n\t\tpublic readonly select?: (context: ContextType<T>) => Selected,\n\t\tpublic readonly subscribe?: boolean,\n\t\tpublic readonly onSubscribe?: (unsubscribe: () => void) => void,\n\t) {\n\t\tsuper(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementEventMap {\n\t\t/**\n\t\t * A 'context-request-subscription' event can be emitted by any element which desires\n\t\t * a context value to be injected by an external provider.\n\t\t */\n\t\t[ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n\t\t/**\n\t\t * A context-request-provider event can be emitted by a context requester to signal\n\t\t * that it desires a context value to be provided by a context provider.\n\t\t */\n\t\t[ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n\t\t/**\n\t\t * A 'context-mount' event can be emitted by a context provider to signal\n\t\t * that a context value has been mounted and is available for consumption.\n\t\t */\n\t\t[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n\t}\n}\n",
|
|
7
|
+
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nlet ssrContextProviderResolver: SsrContextProviderResolver | undefined;\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules. Module-local: SSR bundlers must resolve one radiant instance.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tssrContextProviderResolver = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn ssrContextProviderResolver?.(context);\n}\n",
|
|
8
8
|
"import type { ContextHostLike } from './context-host';\nimport { resolveAmbientSsrContextProvider } from './context-ssr-bridge';\nimport { ContextEventsTypes, ContextRequestEvent, ContextSubscriptionRequestEvent } from './events';\nimport type { ContextCallback, ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\ntype DirectContextSelectionRequest<TContext extends UnknownContext> = {\n\tcallback: (value: ContextType<TContext>) => void;\n\tselect?: undefined;\n};\n\ntype SelectedContextSelectionRequest<TContext extends UnknownContext, Selected> = {\n\tcallback: (value: Selected) => void;\n\tselect: (context: ContextType<TContext>) => Selected;\n};\n\ntype ContextSelectionRequest<TContext extends UnknownContext, Selected = ContextType<TContext>> =\n\tDirectContextSelectionRequest<TContext> | SelectedContextSelectionRequest<TContext, Selected>;\n\n/**\n * Resolves a consumed context from the active SSR provider stack when one is available.\n *\n * This keeps SSR-specific lookup outside decorator implementations while preserving\n * the same consumer initialization contract for both standard and legacy decorators.\n *\n * @returns `true` when the context was resolved synchronously from SSR state.\n */\nexport function initializeConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tassign(provider);\n\thost.connectedContextCallback(context);\n\n\tif (options.emitMounted) {\n\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t}\n\n\treturn true;\n}\n\n/**\n * Requests a context provider through the DOM event channel when SSR state is not active.\n */\nexport function requestConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst event = new ContextRequestEvent(context, (provider) => {\n\t\tassign(provider);\n\t\thost.connectedContextCallback(context);\n\n\t\tif (options.emitMounted) {\n\t\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t\t}\n\t});\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n\n/**\n * Resolves a selected context value from the active SSR provider stack when available.\n *\n * @returns `true` when the selection callback was satisfied synchronously from SSR state.\n */\nexport function initializeContextSelection<TContext extends UnknownContext>(\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected>(\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tconst resolvedContext = provider.getContext() as ContextType<TContext>;\n\n\tif (request.select) {\n\t\trequest.callback(request.select(resolvedContext));\n\t\treturn true;\n\t}\n\n\trequest.callback(resolvedContext);\n\treturn true;\n}\n\n/**\n * Requests a selected context value through the DOM event channel.\n */\nexport function requestContextSelection<TContext extends UnknownContext>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean {\n\tconst event = new ContextSubscriptionRequestEvent(\n\t\tcontext,\n\t\trequest.callback as ContextCallback<Selected>,\n\t\trequest.select,\n\t\toptions.subscribe,\n\t\toptions.onSubscribe,\n\t);\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n",
|
|
9
9
|
"import type { ContextHostLike } from './context-host';\nimport { registerSsrPreparationCallback } from '../core/ssr-preparation';\nimport {\n\tinitializeConsumedContext,\n\tinitializeContextSelection,\n\trequestConsumedContext,\n\trequestContextSelection,\n} from './context-consumer-runtime';\nimport type { ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\n/**\n * Resolves a consumed context immediately and registers the same resolution to\n * run again during the later SSR preparation phase.\n *\n * This keeps constructor-time state and pre-serialization state aligned after\n * instance fields, props, or authored host content change during SSR setup.\n */\nexport function bootstrapSsrConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => initializeConsumedContext(host, context, assign, options));\n}\n\n/**\n * Resolves a selected context value immediately and registers the same\n * selection for the later SSR preparation phase.\n *\n * This lets nested SSR renders recompute selector-backed state after the host\n * has finished construction and any server-side configuration hooks have run.\n */\nexport function bootstrapSsrContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: object,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\tselect?: (context: ContextType<TContext>) => Selected,\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => {\n\t\tif (select) {\n\t\t\treturn initializeContextSelection(context, { callback, select });\n\t\t}\n\n\t\treturn initializeContextSelection(context, {\n\t\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t\t});\n\t});\n}\n\n/**\n * Resolves a consumed context from SSR when available, otherwise requests it\n * through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tif (initializeConsumedContext(host, context, assign, options)) {\n\t\treturn true;\n\t}\n\n\treturn requestConsumedContext(host, context, assign, options);\n}\n\n/**\n * Resolves a selected context value from SSR when available, otherwise requests\n * it through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\toptions: {\n\t\tselect?: (context: ContextType<TContext>) => Selected;\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t} = {},\n): boolean {\n\tif (options.select) {\n\t\tconst request = { callback, select: options.select };\n\n\t\tif (initializeContextSelection(context, request)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn requestContextSelection(host, context, request, {\n\t\t\tsubscribe: options.subscribe,\n\t\t\tonSubscribe: options.onSubscribe,\n\t\t});\n\t}\n\n\tconst request = {\n\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t};\n\n\tif (initializeContextSelection(context, request)) {\n\t\treturn true;\n\t}\n\n\treturn requestContextSelection(host, context, request, {\n\t\tsubscribe: options.subscribe,\n\t\tonSubscribe: options.onSubscribe,\n\t});\n}\n\nfunction registerAndResolveConsumerBootstrap<TResult>(host: object, resolve: () => TResult): TResult {\n\tregisterSsrPreparationCallback(host, resolve);\n\treturn resolve();\n}\n",
|
|
10
10
|
"import type { ContextHostLike } from '../../context-host';\nimport { bootstrapSsrConsumedContext, connectConsumedContext } from '../../context-consumer-bootstrap';\nimport type { UnknownContext } from '../../types';\n\nexport function consumeContext(consumedContext: UnknownContext) {\n\treturn <T extends ContextHostLike, V>(target: undefined, context: ClassFieldDecoratorContext<T, V>) => {\n\t\tvoid target;\n\t\tconst contextName = String(context.name);\n\t\tconst assignContextProvider = (host: T, provider: unknown) => {\n\t\t\tconst hostRecord = host as T & Record<string, unknown>;\n\t\t\thostRecord[contextName] = provider;\n\t\t};\n\t\tconst initializeConsumedContextForHost = (host: T, options: { emitMounted?: boolean } = {}) => {\n\t\t\tconst hostRecord = host as T & Record<string, unknown>;\n\n\t\t\tif (hostRecord[contextName]) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn connectConsumedContext(\n\t\t\t\thost,\n\t\t\t\tconsumedContext,\n\t\t\t\t(provider) => {\n\t\t\t\t\tassignContextProvider(host, provider);\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t);\n\t\t};\n\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tif (\n\t\t\t\tbootstrapSsrConsumedContext(\n\t\t\t\t\tthis,\n\t\t\t\t\tconsumedContext,\n\t\t\t\t\t(provider) => {\n\t\t\t\t\t\tassignContextProvider(this, provider);\n\t\t\t\t\t},\n\t\t\t\t\t{ emitMounted: true },\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\tif (initializeConsumedContextForHost(this, { emitMounted: true })) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tinitializeConsumedContextForHost(this, { emitMounted: true });\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n"
|
|
11
11
|
],
|
|
12
|
-
"mappings": "
|
|
13
|
-
"debugId": "
|
|
12
|
+
"mappings": "AAEA,IAAM,EAA4B,OAAO,IAAI,6CAA6C,EAC7E,EAA0B,OAAO,IAAI,2CAA2C,EAStF,SAAS,CAA8B,CAAC,EAAc,EAAwC,CAEpG,IAAM,EADS,EACkB,GAEjC,GAAI,MAAM,QAAQ,CAAiB,EAAG,CACrC,EAAkB,KAAK,CAAQ,EAC/B,OAGD,OAAO,eAAe,EAAM,EAA2B,CACtD,MAAO,CAAC,CAAQ,EAChB,aAAc,EACf,CAAC,EASK,SAAS,CAA0B,CAAC,EAAoB,CAC9D,IAAM,EAAS,EACT,EAAY,EAAO,GAEzB,GAAI,CAAC,MAAM,QAAQ,CAAS,EAC3B,OAGD,EAAO,GAA2B,GAElC,GAAI,CACH,QAAW,KAAY,EACtB,EAAS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,EAAS,CACtD,UAAW,EAAQ,UACnB,YAAa,EAAQ,WACtB,CAAC,EAGF,IAAM,EAAU,CACf,SAAU,CACX,EAEA,GAAI,EAA2B,EAAS,CAAO,EAC9C,MAAO,GAGR,OAAO,EAAwB,EAAM,EAAS,EAAS,CACtD,UAAW,EAAQ,UACnB,YAAa,EAAQ,WACtB,CAAC,EAGF,SAAS,CAA4C,CAAC,EAAc,EAAiC,CAEpG,OADA,EAA+B,EAAM,CAAO,EACrC,EAAQ,EChHT,SAAS,CAAc,CAAC,EAAiC,CAC/D,MAAO,CAA+B,EAAmB,IAA8C,CAEtG,IAAM,EAAc,OAAO,EAAQ,IAAI,EACjC,EAAwB,CAAC,EAAS,IAAsB,CAC7D,IAAM,EAAa,EACnB,EAAW,GAAe,GAErB,EAAmC,CAAC,EAAS,EAAqC,CAAC,IAAM,CAG9F,GAFmB,EAEJ,GACd,MAAO,GAGR,OAAO,EACN,EACA,EACA,CAAC,IAAa,CACb,EAAsB,EAAM,CAAQ,GAErC,CACD,GAGD,EAAQ,eAAe,QAAS,EAAU,CACzC,GACC,EACC,KACA,EACA,CAAC,IAAa,CACb,EAAsB,KAAM,CAAQ,GAErC,CAAE,YAAa,EAAK,CACrB,EAEA,OAGD,KAAK,0BAA0B,IAAM,CACpC,GAAI,EAAiC,KAAM,CAAE,YAAa,EAAK,CAAC,EAC/D,OAGD,eAAe,IAAM,CACpB,EAAiC,KAAM,CAAE,YAAa,EAAK,CAAC,EAC5D,EACD,EACD",
|
|
13
|
+
"debugId": "2B8B6B77E0689A4664756E2164756E21",
|
|
14
14
|
"names": []
|
|
15
15
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var W=Symbol.for("@ecopages/radiant.ssr-preparation-callbacks"),M=Symbol.for("@ecopages/radiant.ssr-preparation-running");function O(V,j){let D=V[W];if(Array.isArray(D)){D.push(j);return}Object.defineProperty(V,W,{value:[j],configurable:!0})}function m(V){let j=V,U=j[W];if(!Array.isArray(U))return;j[M]=!0;try{for(let D of U)D()}finally{delete j[M]}}var B;((f)=>{f.SUBSCRIPTION_REQUEST="context-subscription-request";f.CONTEXT_REQUEST="context-request";f.ON_MOUNT="context-on-mount";f.MOUNTED="context-mounted"})(B||={});class X extends Event{context;callback;subscribe;handled=!1;constructor(V,j,U){super("context-request",{bubbles:!0,composed:!0});this.context=V;this.callback=j;this.subscribe=U}markHandled(){this.handled=!0}}class T extends CustomEvent{constructor(V){super("context-on-mount",{detail:{context:V},bubbles:!0,composed:!0})}}class Y extends Event{context;callback;select;subscribe;onSubscribe;handled=!1;constructor(V,j,U,D,f){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=V;this.callback=j;this.select=U;this.subscribe=D;this.onSubscribe=f}markHandled(){this.handled=!0}}var I;function k(V){I=V}function Z(V){return I?.(V)}function $(V,j,U,D={}){let f=Z(j);if(!f)return!1;if(U(f),V.connectedContextCallback(j),D.emitMounted)V.dispatchEvent(new CustomEvent("context-mounted",{detail:f}));return!0}function L(V,j,U,D={}){let f=new X(j,(w)=>{if(U(w),V.connectedContextCallback(j),D.emitMounted)V.dispatchEvent(new CustomEvent("context-mounted",{detail:w}))});return V.dispatchEvent(f),f.handled}function J(V,j){let U=Z(V);if(!U)return!1;let D=U.getContext();if(j.select)return j.callback(j.select(D)),!0;return j.callback(D),!0}function G(V,j,U,D){let f=new Y(j,U.callback,U.select,D.subscribe,D.onSubscribe);return V.dispatchEvent(f),f.handled}function C(V,j,U,D={}){return y(V,()=>$(V,j,U,D))}function N(V,j,U,D){return y(V,()=>{if(D)return J(j,{callback:U,select:D});return J(j,{callback:U})})}function h(V,j,U,D={}){if($(V,j,U,D))return!0;return L(V,j,U,D)}function _(V,j,U,D={}){if(D.select){let w={callback:U,select:D.select};if(J(j,w))return!0;return G(V,j,w,{subscribe:D.subscribe,onSubscribe:D.onSubscribe})}let f={callback:U};if(J(j,f))return!0;return G(V,j,f,{subscribe:D.subscribe,onSubscribe:D.onSubscribe})}function y(V,j){return O(V,j),j()}function E(V,j,U){let D=!1,f,w=V;return(F)=>{if(w[M]!==!0&&D&&Object.is(f,F))return;if(D=!0,f=F,j(F),U&&typeof w.requestUpdate==="function")w.requestUpdate()}}function r(V){let{context:j,select:U,subscribe:D=!0}=V;return function(f,w){let F=String(w.name);return w.addInitializer(function(){let H,K=E(this,(Q)=>{let P=this;P[F]=Q},!0);if(N(this,j,K,U))return;let z=()=>{return _(this,j,K,{onSubscribe:(Q)=>{H=Q},select:U,subscribe:D})};this.registerCleanupCallback(()=>{H?.(),H=void 0}),this.registerConnectedCallback(()=>{if(z())return;queueMicrotask(()=>{z()})})}),function(H){return H}}}export{r as contextSelectorField};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=B66112377DEA285B64756E2164756E21
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/ssr-preparation.ts", "../src/context/
|
|
3
|
+
"sources": ["../src/core/ssr-preparation.ts", "../src/context/events.ts", "../src/context/context-ssr-bridge.ts", "../src/context/context-consumer-runtime.ts", "../src/context/context-consumer-bootstrap.ts", "../src/context/decorators/context-selection-delivery.ts", "../src/context/decorators/standard/context-selector-field.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"type SsrPreparationCallback = () => void;\n\nconst SSR_PREPARATION_CALLBACKS = Symbol.for('@ecopages/radiant.ssr-preparation-callbacks');\nexport const SSR_PREPARATION_RUNNING = Symbol.for('@ecopages/radiant.ssr-preparation-running');\n\n/**\n * Registers instance-local SSR preparation work that should run immediately\n * before a Radiant host serializes its first server render.\n *\n * Decorators use this to defer SSR-only setup until after class fields,\n * reactive props, and authored host content have all been applied.\n */\nexport function registerSsrPreparationCallback(host: object, callback: SsrPreparationCallback): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst existingCallbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (Array.isArray(existingCallbacks)) {\n\t\texistingCallbacks.push(callback);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(host, SSR_PREPARATION_CALLBACKS, {\n\t\tvalue: [callback],\n\t\tconfigurable: true,\n\t});\n}\n\n/**\n * Runs all registered SSR preparation callbacks for the provided host.\n *\n * The callbacks are intentionally retained so repeated SSR serializations stay\n * deterministic after later host mutations.\n */\nexport function runSsrPreparationCallbacks(host: object): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst callbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (!Array.isArray(callbacks)) {\n\t\treturn;\n\t}\n\n\ttarget[SSR_PREPARATION_RUNNING] = true;\n\n\ttry {\n\t\tfor (const callback of callbacks as SsrPreparationCallback[]) {\n\t\t\tcallback();\n\t\t}\n\t} finally {\n\t\tdelete target[SSR_PREPARATION_RUNNING];\n\t}\n}\n",
|
|
6
|
-
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nconst SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-provider-resolver');\n\ntype GlobalResolverScope = typeof globalThis & {\n\t[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?: SsrContextProviderResolver;\n};\n\nfunction getGlobalResolverScope(): GlobalResolverScope {\n\treturn globalThis as GlobalResolverScope;\n}\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tgetGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL] = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn getGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?.(context);\n}\n",
|
|
7
6
|
"import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n\tSUBSCRIPTION_REQUEST = 'context-subscription-request',\n\tCONTEXT_REQUEST = 'context-request',\n\tON_MOUNT = 'context-on-mount',\n\tMOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<ContextType<T>>,\n\t\tpublic readonly subscribe?: boolean,\n\t) {\n\t\tsuper(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\ntype DirectContextSubscription<T extends UnknownContext> = {\n\tselect?: undefined;\n\tcallback: ContextCallback<ContextType<T>>;\n};\n\ntype SelectedContextSubscription<T extends UnknownContext, Selected> = {\n\tselect: (context: ContextType<T>) => Selected;\n\tcallback: ContextCallback<Selected>;\n};\n\nexport type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> =\n\tDirectContextSubscription<T> | SelectedContextSubscription<T, Selected>;\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n\tpublic constructor(context: UnknownContext) {\n\t\tsuper(ContextEventsTypes.ON_MOUNT, {\n\t\t\tdetail: { context },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<Selected>,\n\t\tpublic readonly select?: (context: ContextType<T>) => Selected,\n\t\tpublic readonly subscribe?: boolean,\n\t\tpublic readonly onSubscribe?: (unsubscribe: () => void) => void,\n\t) {\n\t\tsuper(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementEventMap {\n\t\t/**\n\t\t * A 'context-request-subscription' event can be emitted by any element which desires\n\t\t * a context value to be injected by an external provider.\n\t\t */\n\t\t[ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n\t\t/**\n\t\t * A context-request-provider event can be emitted by a context requester to signal\n\t\t * that it desires a context value to be provided by a context provider.\n\t\t */\n\t\t[ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n\t\t/**\n\t\t * A 'context-mount' event can be emitted by a context provider to signal\n\t\t * that a context value has been mounted and is available for consumption.\n\t\t */\n\t\t[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n\t}\n}\n",
|
|
7
|
+
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nlet ssrContextProviderResolver: SsrContextProviderResolver | undefined;\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules. Module-local: SSR bundlers must resolve one radiant instance.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tssrContextProviderResolver = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn ssrContextProviderResolver?.(context);\n}\n",
|
|
8
8
|
"import type { ContextHostLike } from './context-host';\nimport { resolveAmbientSsrContextProvider } from './context-ssr-bridge';\nimport { ContextEventsTypes, ContextRequestEvent, ContextSubscriptionRequestEvent } from './events';\nimport type { ContextCallback, ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\ntype DirectContextSelectionRequest<TContext extends UnknownContext> = {\n\tcallback: (value: ContextType<TContext>) => void;\n\tselect?: undefined;\n};\n\ntype SelectedContextSelectionRequest<TContext extends UnknownContext, Selected> = {\n\tcallback: (value: Selected) => void;\n\tselect: (context: ContextType<TContext>) => Selected;\n};\n\ntype ContextSelectionRequest<TContext extends UnknownContext, Selected = ContextType<TContext>> =\n\tDirectContextSelectionRequest<TContext> | SelectedContextSelectionRequest<TContext, Selected>;\n\n/**\n * Resolves a consumed context from the active SSR provider stack when one is available.\n *\n * This keeps SSR-specific lookup outside decorator implementations while preserving\n * the same consumer initialization contract for both standard and legacy decorators.\n *\n * @returns `true` when the context was resolved synchronously from SSR state.\n */\nexport function initializeConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tassign(provider);\n\thost.connectedContextCallback(context);\n\n\tif (options.emitMounted) {\n\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t}\n\n\treturn true;\n}\n\n/**\n * Requests a context provider through the DOM event channel when SSR state is not active.\n */\nexport function requestConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst event = new ContextRequestEvent(context, (provider) => {\n\t\tassign(provider);\n\t\thost.connectedContextCallback(context);\n\n\t\tif (options.emitMounted) {\n\t\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t\t}\n\t});\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n\n/**\n * Resolves a selected context value from the active SSR provider stack when available.\n *\n * @returns `true` when the selection callback was satisfied synchronously from SSR state.\n */\nexport function initializeContextSelection<TContext extends UnknownContext>(\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected>(\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tconst resolvedContext = provider.getContext() as ContextType<TContext>;\n\n\tif (request.select) {\n\t\trequest.callback(request.select(resolvedContext));\n\t\treturn true;\n\t}\n\n\trequest.callback(resolvedContext);\n\treturn true;\n}\n\n/**\n * Requests a selected context value through the DOM event channel.\n */\nexport function requestContextSelection<TContext extends UnknownContext>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean {\n\tconst event = new ContextSubscriptionRequestEvent(\n\t\tcontext,\n\t\trequest.callback as ContextCallback<Selected>,\n\t\trequest.select,\n\t\toptions.subscribe,\n\t\toptions.onSubscribe,\n\t);\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n",
|
|
9
9
|
"import type { ContextHostLike } from './context-host';\nimport { registerSsrPreparationCallback } from '../core/ssr-preparation';\nimport {\n\tinitializeConsumedContext,\n\tinitializeContextSelection,\n\trequestConsumedContext,\n\trequestContextSelection,\n} from './context-consumer-runtime';\nimport type { ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\n/**\n * Resolves a consumed context immediately and registers the same resolution to\n * run again during the later SSR preparation phase.\n *\n * This keeps constructor-time state and pre-serialization state aligned after\n * instance fields, props, or authored host content change during SSR setup.\n */\nexport function bootstrapSsrConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => initializeConsumedContext(host, context, assign, options));\n}\n\n/**\n * Resolves a selected context value immediately and registers the same\n * selection for the later SSR preparation phase.\n *\n * This lets nested SSR renders recompute selector-backed state after the host\n * has finished construction and any server-side configuration hooks have run.\n */\nexport function bootstrapSsrContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: object,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\tselect?: (context: ContextType<TContext>) => Selected,\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => {\n\t\tif (select) {\n\t\t\treturn initializeContextSelection(context, { callback, select });\n\t\t}\n\n\t\treturn initializeContextSelection(context, {\n\t\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t\t});\n\t});\n}\n\n/**\n * Resolves a consumed context from SSR when available, otherwise requests it\n * through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tif (initializeConsumedContext(host, context, assign, options)) {\n\t\treturn true;\n\t}\n\n\treturn requestConsumedContext(host, context, assign, options);\n}\n\n/**\n * Resolves a selected context value from SSR when available, otherwise requests\n * it through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\toptions: {\n\t\tselect?: (context: ContextType<TContext>) => Selected;\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t} = {},\n): boolean {\n\tif (options.select) {\n\t\tconst request = { callback, select: options.select };\n\n\t\tif (initializeContextSelection(context, request)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn requestContextSelection(host, context, request, {\n\t\t\tsubscribe: options.subscribe,\n\t\t\tonSubscribe: options.onSubscribe,\n\t\t});\n\t}\n\n\tconst request = {\n\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t};\n\n\tif (initializeContextSelection(context, request)) {\n\t\treturn true;\n\t}\n\n\treturn requestContextSelection(host, context, request, {\n\t\tsubscribe: options.subscribe,\n\t\tonSubscribe: options.onSubscribe,\n\t});\n}\n\nfunction registerAndResolveConsumerBootstrap<TResult>(host: object, resolve: () => TResult): TResult {\n\tregisterSsrPreparationCallback(host, resolve);\n\treturn resolve();\n}\n",
|
|
10
10
|
"import { SSR_PREPARATION_RUNNING } from '../../core/ssr-preparation';\n\ntype RequestUpdateCapable = {\n\trequestUpdate(): void;\n};\n\nexport function createContextSelectionDelivery<Value>(\n\thost: object,\n\tapply: (value: Value) => void,\n\trequestUpdate: boolean,\n) {\n\tlet hasDeliveredValue = false;\n\tlet previousValue: Value;\n\tconst target = host as Record<PropertyKey, unknown>;\n\n\treturn (value: Value) => {\n\t\tif (target[SSR_PREPARATION_RUNNING] !== true && hasDeliveredValue && Object.is(previousValue, value)) {\n\t\t\treturn;\n\t\t}\n\n\t\thasDeliveredValue = true;\n\t\tpreviousValue = value;\n\t\tapply(value);\n\n\t\tif (requestUpdate && typeof target.requestUpdate === 'function') {\n\t\t\t(target as RequestUpdateCapable).requestUpdate();\n\t\t}\n\t};\n}\n",
|
|
11
11
|
"import type { ContextHostLike } from '../../context-host';\nimport { bootstrapSsrContextSelection, connectContextSelection } from '../../context-consumer-bootstrap';\nimport type { Context, ContextType } from '../../types';\nimport { createContextSelectionDelivery } from '../context-selection-delivery';\n\nexport type ContextSelectorFieldOptions<T extends Context<unknown, unknown>, Selected = ContextType<T>> = {\n\tcontext: T;\n\tselect?: (context: ContextType<T>) => Selected;\n\tsubscribe?: boolean;\n};\n\nexport function contextSelectorField<T extends Context<unknown, unknown>, Selected = ContextType<T>>(\n\toptions: ContextSelectorFieldOptions<T, Selected>,\n) {\n\tconst { context, select, subscribe = true } = options;\n\n\treturn function <Host extends ContextHostLike>(\n\t\t_: undefined,\n\t\tfieldContext: ClassFieldDecoratorContext<Host, Selected>,\n\t) {\n\t\tconst propertyName = String(fieldContext.name);\n\n\t\tfieldContext.addInitializer(function (this: Host) {\n\t\t\tlet activeUnsubscribe: (() => void) | undefined;\n\t\t\tconst applyValue = createContextSelectionDelivery<Selected>(\n\t\t\t\tthis,\n\t\t\t\t(value) => {\n\t\t\t\t\tconst record = this as unknown as Record<string, unknown>;\n\t\t\t\t\trecord[propertyName] = value;\n\t\t\t\t},\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tif (bootstrapSsrContextSelection<T, Selected>(this, context, applyValue, select)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst connectSelection = () => {\n\t\t\t\treturn connectContextSelection<T, Selected>(this, context, applyValue, {\n\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t},\n\t\t\t\t\tselect,\n\t\t\t\t\tsubscribe,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registerCleanupCallback(() => {\n\t\t\t\tactiveUnsubscribe?.();\n\t\t\t\tactiveUnsubscribe = undefined;\n\t\t\t});\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\tif (connectSelection()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tconnectSelection();\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\treturn function (this: Host, initialValue: Selected) {\n\t\t\treturn initialValue;\n\t\t};\n\t};\n}\n"
|
|
12
12
|
],
|
|
13
|
-
"mappings": "
|
|
14
|
-
"debugId": "
|
|
13
|
+
"mappings": "AAEA,IAAM,EAA4B,OAAO,IAAI,6CAA6C,EAC7E,EAA0B,OAAO,IAAI,2CAA2C,EAStF,SAAS,CAA8B,CAAC,EAAc,EAAwC,CAEpG,IAAM,EADS,EACkB,GAEjC,GAAI,MAAM,QAAQ,CAAiB,EAAG,CACrC,EAAkB,KAAK,CAAQ,EAC/B,OAGD,OAAO,eAAe,EAAM,EAA2B,CACtD,MAAO,CAA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,GAGF,KAAK,wBAAwB,IAAM,CAClC,IAAoB,EACpB,EAAoB,OACpB,EAED,KAAK,0BAA0B,IAAM,CACpC,GAAI,EAAiB,EACpB,OAGD,eAAe,IAAM,CACpB,EAAiB,EACjB,EACD,EACD,EAEM,QAAS,CAAa,EAAwB,CACpD,OAAO",
|
|
14
|
+
"debugId": "B66112377DEA285B64756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var X=Symbol.for("@ecopages/radiant.ssr-preparation-callbacks"),Q=Symbol.for("@ecopages/radiant.ssr-preparation-running");function z(f,V){let j=f[X];if(Array.isArray(j)){j.push(V);return}Object.defineProperty(f,X,{value:[V],configurable:!0})}function P(f){let V=f,D=V[X];if(!Array.isArray(D))return;V[Q]=!0;try{for(let j of D)j()}finally{delete V[Q]}}var O;((w)=>{w.SUBSCRIPTION_REQUEST="context-subscription-request";w.CONTEXT_REQUEST="context-request";w.ON_MOUNT="context-on-mount";w.MOUNTED="context-mounted"})(O||={});class Y extends Event{context;callback;subscribe;handled=!1;constructor(f,V,D){super("context-request",{bubbles:!0,composed:!0});this.context=f;this.callback=V;this.subscribe=D}markHandled(){this.handled=!0}}class E extends CustomEvent{constructor(f){super("context-on-mount",{detail:{context:f},bubbles:!0,composed:!0})}}class Z extends Event{context;callback;select;subscribe;onSubscribe;handled=!1;constructor(f,V,D,j,w){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=f;this.callback=V;this.select=D;this.subscribe=j;this.onSubscribe=w}markHandled(){this.handled=!0}}var B;function q(f){B=f}function $(f){return B?.(f)}function G(f,V,D,j={}){let w=$(V);if(!w)return!1;if(D(w),f.connectedContextCallback(V),j.emitMounted)f.dispatchEvent(new CustomEvent("context-mounted",{detail:w}));return!0}function I(f,V,D,j={}){let w=new Y(V,(F)=>{if(D(F),f.connectedContextCallback(V),j.emitMounted)f.dispatchEvent(new CustomEvent("context-mounted",{detail:F}))});return f.dispatchEvent(w),w.handled}function J(f,V){let D=$(f);if(!D)return!1;let j=D.getContext();if(V.select)return V.callback(V.select(j)),!0;return V.callback(j),!0}function U(f,V,D,j){let w=new Z(V,D.callback,D.select,j.subscribe,j.onSubscribe);return f.dispatchEvent(w),w.handled}function d(f,V,D,j={}){return _(f,()=>G(f,V,D,j))}function L(f,V,D,j){return _(f,()=>{if(j)return J(V,{callback:D,select:j});return J(V,{callback:D})})}function C(f,V,D,j={}){if(G(f,V,D,j))return!0;return I(f,V,D,j)}function N(f,V,D,j={}){if(j.select){let F={callback:D,select:j.select};if(J(V,F))return!0;return U(f,V,F,{subscribe:j.subscribe,onSubscribe:j.onSubscribe})}let w={callback:D};if(J(V,w))return!0;return U(f,V,w,{subscribe:j.subscribe,onSubscribe:j.onSubscribe})}function _(f,V){return z(f,V),V()}function y(f,V,D){let j=!1,w,F=f;return(H)=>{if(F[Q]!==!0&&j&&Object.is(w,H))return;if(j=!0,w=H,V(H),D&&typeof F.requestUpdate==="function")F.requestUpdate()}}function l({context:f,select:V,subscribe:D=!0,requestUpdate:j=!0}){return function(w,F){F.addInitializer(function(){let H,K=y(this,(W)=>{w.call(this,W)},j);if(L(this,f,K,V))return;let M=()=>{return N(this,f,K,{onSubscribe:(W)=>{H=W},select:V,subscribe:D})};this.registerCleanupCallback(()=>{H?.(),H=void 0}),this.registerConnectedCallback(()=>{if(M())return;queueMicrotask(()=>{M()})})})}}export{l as contextSelector};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=E8ACB1FCD44FAA4464756E2164756E21
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/ssr-preparation.ts", "../src/context/
|
|
3
|
+
"sources": ["../src/core/ssr-preparation.ts", "../src/context/events.ts", "../src/context/context-ssr-bridge.ts", "../src/context/context-consumer-runtime.ts", "../src/context/context-consumer-bootstrap.ts", "../src/context/decorators/context-selection-delivery.ts", "../src/context/decorators/standard/context-selector.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"type SsrPreparationCallback = () => void;\n\nconst SSR_PREPARATION_CALLBACKS = Symbol.for('@ecopages/radiant.ssr-preparation-callbacks');\nexport const SSR_PREPARATION_RUNNING = Symbol.for('@ecopages/radiant.ssr-preparation-running');\n\n/**\n * Registers instance-local SSR preparation work that should run immediately\n * before a Radiant host serializes its first server render.\n *\n * Decorators use this to defer SSR-only setup until after class fields,\n * reactive props, and authored host content have all been applied.\n */\nexport function registerSsrPreparationCallback(host: object, callback: SsrPreparationCallback): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst existingCallbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (Array.isArray(existingCallbacks)) {\n\t\texistingCallbacks.push(callback);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(host, SSR_PREPARATION_CALLBACKS, {\n\t\tvalue: [callback],\n\t\tconfigurable: true,\n\t});\n}\n\n/**\n * Runs all registered SSR preparation callbacks for the provided host.\n *\n * The callbacks are intentionally retained so repeated SSR serializations stay\n * deterministic after later host mutations.\n */\nexport function runSsrPreparationCallbacks(host: object): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst callbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (!Array.isArray(callbacks)) {\n\t\treturn;\n\t}\n\n\ttarget[SSR_PREPARATION_RUNNING] = true;\n\n\ttry {\n\t\tfor (const callback of callbacks as SsrPreparationCallback[]) {\n\t\t\tcallback();\n\t\t}\n\t} finally {\n\t\tdelete target[SSR_PREPARATION_RUNNING];\n\t}\n}\n",
|
|
6
|
-
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nconst SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-provider-resolver');\n\ntype GlobalResolverScope = typeof globalThis & {\n\t[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?: SsrContextProviderResolver;\n};\n\nfunction getGlobalResolverScope(): GlobalResolverScope {\n\treturn globalThis as GlobalResolverScope;\n}\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tgetGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL] = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn getGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?.(context);\n}\n",
|
|
7
6
|
"import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n\tSUBSCRIPTION_REQUEST = 'context-subscription-request',\n\tCONTEXT_REQUEST = 'context-request',\n\tON_MOUNT = 'context-on-mount',\n\tMOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<ContextType<T>>,\n\t\tpublic readonly subscribe?: boolean,\n\t) {\n\t\tsuper(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\ntype DirectContextSubscription<T extends UnknownContext> = {\n\tselect?: undefined;\n\tcallback: ContextCallback<ContextType<T>>;\n};\n\ntype SelectedContextSubscription<T extends UnknownContext, Selected> = {\n\tselect: (context: ContextType<T>) => Selected;\n\tcallback: ContextCallback<Selected>;\n};\n\nexport type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> =\n\tDirectContextSubscription<T> | SelectedContextSubscription<T, Selected>;\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n\tpublic constructor(context: UnknownContext) {\n\t\tsuper(ContextEventsTypes.ON_MOUNT, {\n\t\t\tdetail: { context },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<Selected>,\n\t\tpublic readonly select?: (context: ContextType<T>) => Selected,\n\t\tpublic readonly subscribe?: boolean,\n\t\tpublic readonly onSubscribe?: (unsubscribe: () => void) => void,\n\t) {\n\t\tsuper(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementEventMap {\n\t\t/**\n\t\t * A 'context-request-subscription' event can be emitted by any element which desires\n\t\t * a context value to be injected by an external provider.\n\t\t */\n\t\t[ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n\t\t/**\n\t\t * A context-request-provider event can be emitted by a context requester to signal\n\t\t * that it desires a context value to be provided by a context provider.\n\t\t */\n\t\t[ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n\t\t/**\n\t\t * A 'context-mount' event can be emitted by a context provider to signal\n\t\t * that a context value has been mounted and is available for consumption.\n\t\t */\n\t\t[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n\t}\n}\n",
|
|
7
|
+
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nlet ssrContextProviderResolver: SsrContextProviderResolver | undefined;\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules. Module-local: SSR bundlers must resolve one radiant instance.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tssrContextProviderResolver = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn ssrContextProviderResolver?.(context);\n}\n",
|
|
8
8
|
"import type { ContextHostLike } from './context-host';\nimport { resolveAmbientSsrContextProvider } from './context-ssr-bridge';\nimport { ContextEventsTypes, ContextRequestEvent, ContextSubscriptionRequestEvent } from './events';\nimport type { ContextCallback, ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\ntype DirectContextSelectionRequest<TContext extends UnknownContext> = {\n\tcallback: (value: ContextType<TContext>) => void;\n\tselect?: undefined;\n};\n\ntype SelectedContextSelectionRequest<TContext extends UnknownContext, Selected> = {\n\tcallback: (value: Selected) => void;\n\tselect: (context: ContextType<TContext>) => Selected;\n};\n\ntype ContextSelectionRequest<TContext extends UnknownContext, Selected = ContextType<TContext>> =\n\tDirectContextSelectionRequest<TContext> | SelectedContextSelectionRequest<TContext, Selected>;\n\n/**\n * Resolves a consumed context from the active SSR provider stack when one is available.\n *\n * This keeps SSR-specific lookup outside decorator implementations while preserving\n * the same consumer initialization contract for both standard and legacy decorators.\n *\n * @returns `true` when the context was resolved synchronously from SSR state.\n */\nexport function initializeConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tassign(provider);\n\thost.connectedContextCallback(context);\n\n\tif (options.emitMounted) {\n\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t}\n\n\treturn true;\n}\n\n/**\n * Requests a context provider through the DOM event channel when SSR state is not active.\n */\nexport function requestConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst event = new ContextRequestEvent(context, (provider) => {\n\t\tassign(provider);\n\t\thost.connectedContextCallback(context);\n\n\t\tif (options.emitMounted) {\n\t\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t\t}\n\t});\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n\n/**\n * Resolves a selected context value from the active SSR provider stack when available.\n *\n * @returns `true` when the selection callback was satisfied synchronously from SSR state.\n */\nexport function initializeContextSelection<TContext extends UnknownContext>(\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected>(\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tconst resolvedContext = provider.getContext() as ContextType<TContext>;\n\n\tif (request.select) {\n\t\trequest.callback(request.select(resolvedContext));\n\t\treturn true;\n\t}\n\n\trequest.callback(resolvedContext);\n\treturn true;\n}\n\n/**\n * Requests a selected context value through the DOM event channel.\n */\nexport function requestContextSelection<TContext extends UnknownContext>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean {\n\tconst event = new ContextSubscriptionRequestEvent(\n\t\tcontext,\n\t\trequest.callback as ContextCallback<Selected>,\n\t\trequest.select,\n\t\toptions.subscribe,\n\t\toptions.onSubscribe,\n\t);\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n",
|
|
9
9
|
"import type { ContextHostLike } from './context-host';\nimport { registerSsrPreparationCallback } from '../core/ssr-preparation';\nimport {\n\tinitializeConsumedContext,\n\tinitializeContextSelection,\n\trequestConsumedContext,\n\trequestContextSelection,\n} from './context-consumer-runtime';\nimport type { ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\n/**\n * Resolves a consumed context immediately and registers the same resolution to\n * run again during the later SSR preparation phase.\n *\n * This keeps constructor-time state and pre-serialization state aligned after\n * instance fields, props, or authored host content change during SSR setup.\n */\nexport function bootstrapSsrConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => initializeConsumedContext(host, context, assign, options));\n}\n\n/**\n * Resolves a selected context value immediately and registers the same\n * selection for the later SSR preparation phase.\n *\n * This lets nested SSR renders recompute selector-backed state after the host\n * has finished construction and any server-side configuration hooks have run.\n */\nexport function bootstrapSsrContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: object,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\tselect?: (context: ContextType<TContext>) => Selected,\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => {\n\t\tif (select) {\n\t\t\treturn initializeContextSelection(context, { callback, select });\n\t\t}\n\n\t\treturn initializeContextSelection(context, {\n\t\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t\t});\n\t});\n}\n\n/**\n * Resolves a consumed context from SSR when available, otherwise requests it\n * through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tif (initializeConsumedContext(host, context, assign, options)) {\n\t\treturn true;\n\t}\n\n\treturn requestConsumedContext(host, context, assign, options);\n}\n\n/**\n * Resolves a selected context value from SSR when available, otherwise requests\n * it through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\toptions: {\n\t\tselect?: (context: ContextType<TContext>) => Selected;\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t} = {},\n): boolean {\n\tif (options.select) {\n\t\tconst request = { callback, select: options.select };\n\n\t\tif (initializeContextSelection(context, request)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn requestContextSelection(host, context, request, {\n\t\t\tsubscribe: options.subscribe,\n\t\t\tonSubscribe: options.onSubscribe,\n\t\t});\n\t}\n\n\tconst request = {\n\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t};\n\n\tif (initializeContextSelection(context, request)) {\n\t\treturn true;\n\t}\n\n\treturn requestContextSelection(host, context, request, {\n\t\tsubscribe: options.subscribe,\n\t\tonSubscribe: options.onSubscribe,\n\t});\n}\n\nfunction registerAndResolveConsumerBootstrap<TResult>(host: object, resolve: () => TResult): TResult {\n\tregisterSsrPreparationCallback(host, resolve);\n\treturn resolve();\n}\n",
|
|
10
10
|
"import { SSR_PREPARATION_RUNNING } from '../../core/ssr-preparation';\n\ntype RequestUpdateCapable = {\n\trequestUpdate(): void;\n};\n\nexport function createContextSelectionDelivery<Value>(\n\thost: object,\n\tapply: (value: Value) => void,\n\trequestUpdate: boolean,\n) {\n\tlet hasDeliveredValue = false;\n\tlet previousValue: Value;\n\tconst target = host as Record<PropertyKey, unknown>;\n\n\treturn (value: Value) => {\n\t\tif (target[SSR_PREPARATION_RUNNING] !== true && hasDeliveredValue && Object.is(previousValue, value)) {\n\t\t\treturn;\n\t\t}\n\n\t\thasDeliveredValue = true;\n\t\tpreviousValue = value;\n\t\tapply(value);\n\n\t\tif (requestUpdate && typeof target.requestUpdate === 'function') {\n\t\t\t(target as RequestUpdateCapable).requestUpdate();\n\t\t}\n\t};\n}\n",
|
|
11
11
|
"import type { ContextHostLike } from '../../context-host';\nimport { bootstrapSsrContextSelection, connectContextSelection } from '../../context-consumer-bootstrap';\nimport type { Context, ContextType } from '../../types';\nimport type { OnContextUpdateOptions } from '../on-context-update';\nimport { createContextSelectionDelivery } from '../context-selection-delivery';\n\nexport function contextSelector<T extends Context<unknown, unknown>, Selected = ContextType<T>>({\n\tcontext,\n\tselect,\n\tsubscribe = true,\n\trequestUpdate = true,\n}: OnContextUpdateOptions<T, Selected>) {\n\treturn function <Host extends ContextHostLike, TMethod extends (value: Selected) => unknown>(\n\t\toriginalMethod: TMethod,\n\t\ttargetContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): void {\n\t\ttargetContext.addInitializer(function (this: Host) {\n\t\t\tlet activeUnsubscribe: (() => void) | undefined;\n\t\t\tconst applySelectedContext = createContextSelectionDelivery<Selected>(\n\t\t\t\tthis,\n\t\t\t\t(value) => {\n\t\t\t\t\toriginalMethod.call(this, value);\n\t\t\t\t},\n\t\t\t\trequestUpdate,\n\t\t\t);\n\n\t\t\tif (bootstrapSsrContextSelection<T, Selected>(this, context, applySelectedContext, select)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst connectSelection = () => {\n\t\t\t\treturn connectContextSelection<T, Selected>(this, context, applySelectedContext, {\n\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t},\n\t\t\t\t\tselect,\n\t\t\t\t\tsubscribe,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registerCleanupCallback(() => {\n\t\t\t\tactiveUnsubscribe?.();\n\t\t\t\tactiveUnsubscribe = undefined;\n\t\t\t});\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\tif (connectSelection()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tconnectSelection();\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n"
|
|
12
12
|
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Aa,CAClD,IAAI,EACE,EAAuB,EAC5B,KACA,CAAC,IAAU,CACV,EAAe,KAAK,KAAM,CAAK,GAEhC,CACD,EAEA,GAAI,EAA0C,KAAM,EAAS,EAAsB,CAAM,EACxF,OAGD,IAAM,EAAmB,IAAM,CAC9B,OAAO,EAAqC,KAAM,EAAS,EAAsB,CAChF,YAAa,CAAC,IAAgB,CAC7B,EAAoB,GAErB,SACA,WACD,CAAC,GAGF,KAAK,wBAAwB,IAAM,CAClC,IAAoB,EACpB,EAAoB,OACpB,EAED,KAAK,0BAA0B,IAAM,CACpC,GAAI,EAAiB,EACpB,OAGD,eAAe,IAAM,CACpB,EAAiB,EACjB,EACD,EACD",
|
|
14
|
+
"debugId": "E8ACB1FCD44FAA4464756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
function w(f){return f.replace(/&/g,"\\u0026").replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var Q="data-hydration",X="data-hydration-type",G="data-hydration-key";function z(f){let L=f.hydrationKey?` ${G}="${x(f.hydrationKey)}"`:"";return`<script type="application/json" ${Q} ${X}="${f.type}"${L}>${f.serializedValue}</script>`}function J(f){return w(f)}function O(f,L){let C=f.textContent;if(!C)return L;try{return JSON.parse(C)}catch{if(typeof console<"u")console.warn(`[@ecopages/radiant] Failed to parse hydration payload from <script ${Q}>:`,C.slice(0,120));return L}}function U(f,L,C){let P=f.children;if(!P||P.length===0){let g=f.childNodes;if(!g||g.length===0)return null;for(let j=0;j<g.length;j+=1){let m=g[j];if(m.nodeType!==1)continue;let q=m;if(W(q,L,C))return q}return null}for(let g=0;g<P.length;g+=1)if(W(P[g],L,C))return P[g];return null}function W(f,L,C){if(f.tagName!=="SCRIPT"||!f.hasAttribute(Q)||f.getAttribute(X)!==L)return!1;if(C!==void 0)return f.getAttribute(G)===C;return!f.hasAttribute(G)}function x(f){return f.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Y(f){if(f instanceof Element)return f;if("host"in f)return f.host;if("element"in f)return f.element;return null}function k(f){if(f instanceof Element)return f;if("host"in f)return f.host;if("element"in f)return f.element;return f}function E(f){return z({type:"context",...f})}function M(f){return J(f)}var H;((g)=>{g.SUBSCRIPTION_REQUEST="context-subscription-request";g.CONTEXT_REQUEST="context-request";g.ON_MOUNT="context-on-mount";g.MOUNTED="context-mounted"})(H||={});class B extends Event{context;callback;subscribe;handled=!1;constructor(f,L,C){super("context-request",{bubbles:!0,composed:!0});this.context=f;this.callback=L;this.subscribe=C}markHandled(){this.handled=!0}}class F extends CustomEvent{constructor(f){super("context-on-mount",{detail:{context:f},bubbles:!0,composed:!0})}}class D extends Event{context;callback;select;subscribe;onSubscribe;handled=!1;constructor(f,L,C,P,g){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=f;this.callback=L;this.select=C;this.subscribe=P;this.onSubscribe=g}markHandled(){this.handled=!0}}import{createMarkupNodeLike as K}from"@ecopages/jsx";class Z{host;context;hydrationKey;hydrate;serialize;pendingHostHydration;value;subscriptions=[];constructor(f,L){this.host=f,this.context=L.context,this.hydrationKey=L.hydrationKey,this.hydrate=L.hydrate,this.serialize=L.serialize,this.pendingHostHydration=Boolean(L.hydrate),this.value=L.initialValue,this.tryHydrateFromHost(),this.registerEvents(),this.host.dispatchEvent(new F(this.context))}setContext=(f,L)=>{if(this.tryHydrateFromHost(),this.pendingHostHydration=!1,typeof this.value>"u"&&this.isObject(f)){let C=this.value;if(this.value={...f},L)L(this.value);this.notifySubscribers(this.value,C);return}if(this.isObject(this.value)&&this.isObject(f)){let C={...this.value};if(this.value={...this.value,...f},L)L(this.value);this.notifySubscribers(this.value,C)}};getContext=()=>{return this.tryHydrateFromHost(),this.value};getContextKey=()=>{return this.context};serializeHydrationValue=()=>{if(this.tryHydrateFromHost(),!this.hydrate||typeof this.value>"u")return;let f=this.serialize?this.serialize(this.value):this.value;if(typeof f>"u")return;let L=JSON.stringify(f);if(typeof L!=="string")return;return M(L)};renderHydrationScriptTag=()=>{let f=this.serializeHydrationValue();if(!f)return;return E({hydrationKey:this.hydrationKey,serializedValue:f})};renderHydrationScript=()=>{let f=this.renderHydrationScriptTag();if(!f)return;return K(f)};subscribe=(f)=>{let L={hasChanged:(C,P)=>{if(typeof P>"u"||!f.select)return!0;return f.select(C)!==f.select(P)},notify:(C)=>{if(f.select){f.callback(f.select(C),L.unsubscribe);return}f.callback(C,L.unsubscribe)},unsubscribe:()=>{let C=this.subscriptions.indexOf(L);if(C!==-1)this.subscriptions.splice(C,1)}};return this.subscriptions.push(L),L.unsubscribe};tryHydrateFromHost(){if(!this.pendingHostHydration)return;let f=this.findHydrationScriptElement();if(!f)return;this.value=this.mergeHydrationValue(O(f,this.value)),this.pendingHostHydration=!1}mergeHydrationValue(f){if(this.hydrate===Object&&this.isObject(f)&&(this.isObject(this.value)||typeof this.value>"u"))return{...this.value??{},...f};return f}isObject(f){return typeof f==="object"&&!Array.isArray(f)&&f!==null}findHydrationScriptElement(){return U(k(this.host),"context",this.hydrationKey)}notifySubscribers=(f,L)=>{for(let C of this.subscriptions)if(C.hasChanged(f,L))C.notify(f)};handleSubscriptionRequest=(f,{subscribe:L,onSubscribe:C})=>{this.tryHydrateFromHost();let P=L?this.subscribe(f):void 0;if(P)C?.(P);if(typeof this.value>"u")return;if(f.select)f.callback(f.select(this.value),P);else f.callback(this.value,P)};onSubscriptionRequest=(f)=>{let{context:L,callback:C,subscribe:P,select:g,target:j,onSubscribe:m}=f;if(L!==this.context)return;if(f.markHandled(),f.stopPropagation(),j instanceof EventTarget)j.dispatchEvent(new F(this.context));if(g){this.handleSubscriptionRequest({select:g,callback:C},{subscribe:P,onSubscribe:m});return}this.handleSubscriptionRequest({callback:C},{subscribe:P,onSubscribe:m})};onContextRequest=(f)=>{let{context:L,callback:C}=f;if(L!==this.context)return;f.markHandled(),f.stopPropagation(),C(this)};registerEvents=()=>{this.host.addEventListener("context-subscription-request",this.onSubscriptionRequest),this.host.addEventListener("context-request",this.onContextRequest)}}function n({context:f,initialValue:L,hydrate:C,serialize:P}){return(g,j)=>{let m=String(j.name);j.addInitializer(function(){let q=this,$=new Z(this,{context:f,hydrationKey:m,initialValue:L,hydrate:C,serialize:P});q[m]=$,this.registerContextProvider(m,$),this.connectedContextCallback(f)})}}export{n as provideContext};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=ED54F47BF0698F9964756E2164756E21
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"import { createMarkupNodeLike, type JsxRenderable } from '@ecopages/jsx';\nimport type { SsrSerializableHydrationBinding } from '../core/ssr-hydration-binding';\nimport type { AttributeTypeConstant } from '../utils/attribute-utils';\nimport {\n\tContextEventsTypes,\n\tContextOnMountEvent,\n\ttype ContextRequestEvent,\n\ttype ContextSubscription,\n\ttype ContextSubscriptionRequestEvent,\n} from './events';\nimport { findHydrationScript, parseHydrationPayload } from '../core/hydration-codec';\nimport { createContextHydrationScriptTag, escapeContextHydrationJson } from './hydration-script';\nimport type { Context, ContextType, UnknownContext } from './types';\nimport { resolveContextHydrationHost, type ContextHostLike } from './context-host';\n\ntype ContextProviderOptions<T extends UnknownContext> = {\n\tcontext: UnknownContext;\n\thydrationKey?: string;\n\tinitialValue?: T['__context__'];\n\thydrate?: AttributeTypeConstant;\n\tserialize?: (value: ContextType<T>) => unknown;\n};\n\ntype ActiveContextSubscription<T extends UnknownContext> = {\n\thasChanged(newContext: ContextType<T>, prevContext: ContextType<T> | undefined): boolean;\n\tnotify(context: ContextType<T>): void;\n\tunsubscribe: () => void;\n};\n\nexport interface SsrSerializableContextProvider extends SsrSerializableHydrationBinding {\n\t/** Returns the current context payload that should be visible to descendants. */\n\tgetContext(): unknown;\n\t/** Returns the context token used to match nested SSR consumers and providers. */\n\tgetContextKey(): UnknownContext;\n}\n\n/**\n * Represents a context provider that allows setting and getting the context,\n * as well as subscribing to context updates.\n *\n * @template T - The type of the context.\n */\nexport interface IContextProvider<T extends Context<unknown, unknown>> {\n\t/**\n\t * Sets the context with the provided update and invokes the optional callback function.\n\t *\n\t * @param update - The partial update to be applied to the context.\n\t * @param callback - An optional callback function that receives the updated context.\n\t */\n\tsetContext: (update: Partial<ContextType<T>>, callback?: (context: ContextType<T>) => void) => void;\n\n\t/**\n\t * Gets the current context.\n\t *\n\t * @returns The current context.\n\t */\n\tgetContext: () => ContextType<T>;\n\n\t/**\n\t * Subscribes to context updates.\n\t *\n\t * @param subscription - The subscription object that defines the callback function to be invoked on context updates.\n\t */\n\tsubscribe: <Selected = ContextType<T>>(subscription: ContextSubscription<T, Selected>) => () => void;\n}\n\n/**\n * It creates a context provider that allows setting and getting the context,\n * It will also be in charge of notifying the subscribers when the context changes.\n *\n * @template T - The type of the context.\n * @implements IContextProvider\n *\n * @example\n * ```ts\n * export class MyElement extends RadiantElement {\n * provider = new ContextProvider<typeof myContext>(this, {\n * context: myContext,\n * initialValue: {\n * value: 'Hello World',\n * },\n * });\n * ```\n */\nexport class ContextProvider<T extends Context<unknown, unknown>>\n\timplements IContextProvider<T>, SsrSerializableContextProvider\n{\n\tprivate host: ContextHostLike;\n\tprivate context: UnknownContext;\n\tprivate hydrationKey?: string;\n\tprivate hydrate?: AttributeTypeConstant;\n\tprivate serialize?: (value: ContextType<T>) => unknown;\n\tprivate pendingHostHydration: boolean;\n\tprivate value: ContextType<T> | undefined;\n\n\tsubscriptions: ActiveContextSubscription<T>[] = [];\n\n\t/**\n\t * Creates a new instance of the ContextProvider.\n\t *\n\t * @param host - The host element that will contain the context provider.\n\t * @param options - The options to configure the context provider.\n\t */\n\tconstructor(host: ContextHostLike, options: ContextProviderOptions<T>) {\n\t\tthis.host = host;\n\t\tthis.context = options.context;\n\t\tthis.hydrationKey = options.hydrationKey;\n\t\tthis.hydrate = options.hydrate;\n\t\tthis.serialize = options.serialize;\n\t\tthis.pendingHostHydration = Boolean(options.hydrate);\n\t\tthis.value = options.initialValue as ContextType<T>;\n\t\tthis.tryHydrateFromHost();\n\n\t\tthis.registerEvents();\n\t\tthis.host.dispatchEvent(new ContextOnMountEvent(this.context));\n\t}\n\n\tsetContext = (update: Partial<ContextType<T>>, callback?: (context: ContextType<T>) => void) => {\n\t\tthis.tryHydrateFromHost();\n\t\tthis.pendingHostHydration = false;\n\n\t\tif (typeof this.value === 'undefined' && this.isObject(update)) {\n\t\t\tconst oldContext = this.value;\n\t\t\tthis.value = { ...update } as ContextType<T>;\n\t\t\tif (callback) callback(this.value);\n\t\t\tthis.notifySubscribers(this.value, oldContext);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isObject(this.value) && this.isObject(update)) {\n\t\t\tconst oldContext = { ...this.value };\n\t\t\tthis.value = { ...this.value, ...update };\n\t\t\tif (callback) callback(this.value);\n\t\t\tthis.notifySubscribers(this.value, oldContext);\n\t\t}\n\t};\n\n\tgetContext = () => {\n\t\tthis.tryHydrateFromHost();\n\t\treturn this.value as ContextType<T>;\n\t};\n\n\t/**\n\t * Returns the provider's logical context token.\n\t *\n\t * SSR helpers use this token to resolve the closest matching provider while a\n\t * host subtree is being serialized.\n\t */\n\tgetContextKey = () => {\n\t\treturn this.context;\n\t};\n\n\t/**\n\t * Serializes the current provider value for inclusion in a hydration script.\n\t *\n\t * The serialized payload is JSON-escaped so it can be embedded safely inside a\n\t * `<script type=\"application/json\">` tag.\n\t */\n\tserializeHydrationValue = (): string | undefined => {\n\t\tthis.tryHydrateFromHost();\n\n\t\tif (!this.hydrate || typeof this.value === 'undefined') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst hydrationValue = this.serialize ? this.serialize(this.value) : this.value;\n\n\t\tif (typeof hydrationValue === 'undefined') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst serializedValue = JSON.stringify(hydrationValue);\n\n\t\tif (typeof serializedValue !== 'string') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn escapeContextHydrationJson(serializedValue);\n\t};\n\n\t/**\n\t * Builds the raw HTML hydration script for this provider.\n\t *\n\t * When `hydrationKey` is present, the marker is scoped so sibling or nested\n\t * providers can recover their own payloads without accidentally reading a\n\t * descendant script.\n\t */\n\trenderHydrationScriptTag = (): string | undefined => {\n\t\tconst serializedValue = this.serializeHydrationValue();\n\n\t\tif (!serializedValue) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createContextHydrationScriptTag({\n\t\t\thydrationKey: this.hydrationKey,\n\t\t\tserializedValue,\n\t\t});\n\t};\n\n\t/**\n\t * Wraps the provider hydration script in a minimal JSX node-like value.\n\t *\n\t * This lets JSX-based host renderers append the script without needing a real\n\t * DOM element instance during SSR.\n\t */\n\trenderHydrationScript = (): JsxRenderable | undefined => {\n\t\tconst outerHTML = this.renderHydrationScriptTag();\n\n\t\tif (!outerHTML) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createMarkupNodeLike(outerHTML);\n\t};\n\n\tsubscribe = <Selected = ContextType<T>>(subscriptionSpec: ContextSubscription<T, Selected>) => {\n\t\tconst subscription: ActiveContextSubscription<T> = {\n\t\t\thasChanged: (newContext, prevContext) => {\n\t\t\t\tif (typeof prevContext === 'undefined' || !subscriptionSpec.select) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn subscriptionSpec.select(newContext) !== subscriptionSpec.select(prevContext);\n\t\t\t},\n\t\t\tnotify: (context) => {\n\t\t\t\tif (subscriptionSpec.select) {\n\t\t\t\t\tsubscriptionSpec.callback(subscriptionSpec.select(context), subscription.unsubscribe);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsubscriptionSpec.callback(context, subscription.unsubscribe);\n\t\t\t},\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst index = this.subscriptions.indexOf(subscription);\n\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tthis.subscriptions.splice(index, 1);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tthis.subscriptions.push(subscription);\n\n\t\treturn subscription.unsubscribe;\n\t};\n\n\tprivate tryHydrateFromHost(): void {\n\t\tif (!this.pendingHostHydration) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst hydrationScriptElement = this.findHydrationScriptElement();\n\n\t\tif (!hydrationScriptElement) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.value = this.mergeHydrationValue(\n\t\t\tparseHydrationPayload(hydrationScriptElement, this.value) as ContextType<T>,\n\t\t);\n\t\tthis.pendingHostHydration = false;\n\t}\n\n\tprivate mergeHydrationValue(parsedHydrationValue: ContextType<T>): ContextType<T> {\n\t\tif (\n\t\t\tthis.hydrate === Object &&\n\t\t\tthis.isObject(parsedHydrationValue) &&\n\t\t\t(this.isObject(this.value) || typeof this.value === 'undefined')\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...(this.value ?? {}),\n\t\t\t\t...parsedHydrationValue,\n\t\t\t} as ContextType<T>;\n\t\t}\n\n\t\treturn parsedHydrationValue;\n\t}\n\n\tprivate isObject(value: unknown): value is Record<string, unknown> {\n\t\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n\t}\n\n\tprivate findHydrationScriptElement(): Element | null {\n\t\treturn findHydrationScript(resolveContextHydrationHost(this.host), 'context', this.hydrationKey);\n\t}\n\n\tprivate notifySubscribers = (newContext: ContextType<T>, prevContext: ContextType<T> | undefined) => {\n\t\tfor (const sub of this.subscriptions) {\n\t\t\tif (sub.hasChanged(newContext, prevContext)) {\n\t\t\t\tsub.notify(newContext);\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate handleSubscriptionRequest = (\n\t\tsubscription: ContextSubscription<T, unknown>,\n\t\t{\n\t\t\tsubscribe,\n\t\t\tonSubscribe,\n\t\t}: {\n\t\t\tsubscribe?: boolean;\n\t\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t\t},\n\t) => {\n\t\tthis.tryHydrateFromHost();\n\t\tconst unsubscribe = subscribe ? this.subscribe(subscription) : undefined;\n\n\t\tif (unsubscribe) {\n\t\t\tonSubscribe?.(unsubscribe);\n\t\t}\n\n\t\tif (typeof this.value === 'undefined') return;\n\n\t\tif (subscription.select) {\n\t\t\tsubscription.callback(subscription.select(this.value), unsubscribe);\n\t\t} else {\n\t\t\tsubscription.callback(this.value, unsubscribe);\n\t\t}\n\t};\n\n\tprivate onSubscriptionRequest = (event: ContextSubscriptionRequestEvent<UnknownContext>) => {\n\t\tconst { context, callback, subscribe, select, target, onSubscribe } = event;\n\t\tif (context !== this.context) return;\n\n\t\tevent.markHandled();\n\t\tevent.stopPropagation();\n\n\t\tif (target instanceof EventTarget) {\n\t\t\ttarget.dispatchEvent(new ContextOnMountEvent(this.context));\n\t\t}\n\n\t\tif (select) {\n\t\t\tthis.handleSubscriptionRequest({ select, callback }, { subscribe, onSubscribe });\n\t\t\treturn;\n\t\t}\n\n\t\tthis.handleSubscriptionRequest({ callback }, { subscribe, onSubscribe });\n\t};\n\n\tprivate onContextRequest = (event: ContextRequestEvent<UnknownContext>) => {\n\t\tconst { context, callback } = event;\n\t\tif (context !== this.context) return;\n\t\tevent.markHandled();\n\t\tevent.stopPropagation();\n\t\tcallback(this);\n\t};\n\n\tprivate registerEvents = () => {\n\t\tthis.host.addEventListener(\n\t\t\tContextEventsTypes.SUBSCRIPTION_REQUEST,\n\t\t\tthis.onSubscriptionRequest as EventListener,\n\t\t);\n\t\tthis.host.addEventListener(ContextEventsTypes.CONTEXT_REQUEST, this.onContextRequest as EventListener);\n\t};\n}\n",
|
|
11
11
|
"import type { ContextHostLike } from '../../context-host';\nimport { ContextProvider } from '../../context-provider';\nimport type { UnknownContext } from '../../types';\nimport type { ProvideContextOptions } from '../provide-context';\n\nexport function provideContext<T extends UnknownContext>({\n\tcontext,\n\tinitialValue,\n\thydrate,\n\tserialize,\n}: ProvideContextOptions<T>) {\n\treturn <C extends ContextHostLike, V>(target: undefined, targetContext: ClassFieldDecoratorContext<C, V>) => {\n\t\tvoid target;\n\t\tconst contextName = String(targetContext.name);\n\t\ttargetContext.addInitializer(function (this: C) {\n\t\t\tconst hostRecord = this as C & Record<string, unknown>;\n\t\t\tconst provider = new ContextProvider<T>(this, {\n\t\t\t\tcontext,\n\t\t\t\thydrationKey: contextName,\n\t\t\t\tinitialValue,\n\t\t\t\thydrate,\n\t\t\t\tserialize,\n\t\t\t});\n\t\t\thostRecord[contextName] = provider;\n\t\t\tthis.registerContextProvider(contextName, provider);\n\t\t\tthis.connectedContextCallback(context);\n\t\t});\n\t};\n}\n"
|
|
12
12
|
],
|
|
13
|
-
"mappings": "
|
|
14
|
-
"debugId": "
|
|
13
|
+
"mappings": "AAIO,SAAS,CAAgB,CAAC,EAAuB,CACvD,OAAO,EACL,QAAQ,KAAM,SAAS,EACvB,QAAQ,KAAM,SAAS,EACvB,QAAQ,KAAM,SAAS,EACvB,QAAQ,UAAW,SAAS,EAC5B,QAAQ,UAAW,SAAS,ECPxB,IAAM,EAAsB,iBAEtB,EAA2B,sBAE3B,EAA0B,qBAUhC,SAAS,CAAwB,CAAC,EAI9B,CACV,IAAM,EAAe,EAAQ,aAC1B,IAAI,MAA4B,EAAoB,EAAQ,YAAY,KACxE,GAEH,MAAO,mCAAmC,KAAuB,MAA6B,EAAQ,QAAQ,KAAgB,EAAQ,2BAIhI,SAAS,CAAmB,CAAC,EAAuB,CAC1D,OAAO,EAAiB,CAAK,EAIvB,SAAS,CAAwB,CAAC,EAAkB,EAAgB,CAC1E,IAAM,EAAc,EAAQ,YAE5B,GAAI,CAAC,EACJ,OAAO,EAGR,GAAI,CACH,OAAO,KAAK,MAAM,CAAW,EAC5B,KAAM,CACP,GAAI,OAAO,QAAY,IACtB,QAAQ,KACP,sEAAsE,MACtE,EAAY,MAAM,EAAG,GAAG,CACzB,EAED,OAAO,GAUF,SAAS,CAAmB,CAClC,EACA,EACA,EACiB,CACjB,IAAM,EAAW,EAAK,SAEtB,GAAI,CAAC,GAAY,EAAS,SAAW,EAAG,CACvC,IAAM,EAAc,EAAkE,WAEtF,GAAI,CAAC,GAAc,EA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AQ,eAAgB,EACtE,GAAI,IAAY,KAAK,QAAS,OAK9B,GAHA,EAAM,YAAY,EAClB,EAAM,gBAAgB,EAElB,aAAkB,YACrB,EAAO,cAAc,IAAI,EAAoB,KAAK,OAAO,CAAC,EAG3D,GAAI,EAAQ,CACX,KAAK,0BAA0B,CAAE,SAAQ,UAAS,EAAG,CAAE,YAAW,aAAY,CAAC,EAC/E,OAGD,KAAK,0BAA0B,CAAE,UAAS,EAAG,CAAE,YAAW,aAAY,CAAC,GAGhE,iBAAmB,CAAC,IAA+C,CAC1E,IAAQ,UAAS,YAAa,EAC9B,GAAI,IAAY,KAAK,QAAS,OAC9B,EAAM,YAAY,EAClB,EAAM,gBAAgB,EACtB,EAAS,IAAI,GAGN,eAAiB,IAAM,CAC9B,KAAK,KAAK,gDAET,KAAK,qBACN,EACA,KAAK,KAAK,mCAAqD,KAAK,gBAAiC,EAEvG,CC7VO,SAAS,CAAwC,EACvD,UACA,eACA,UACA,aAC4B,CAC5B,MAAO,CAA+B,EAAmB,IAAoD,CAE5G,IAAM,EAAc,OAAO,EAAc,IAAI,EAC7C,EAAc,eAAe,QAAS,EAAU,CAC/C,IAAM,EAAa,KACb,EAAW,IAAI,EAAmB,KAAM,CAC7C,UACA,aAAc,EACd,eACA,UACA,WACD,CAAC,EACD,EAAW,GAAe,EAC1B,KAAK,wBAAwB,EAAa,CAAQ,EAClD,KAAK,yBAAyB,CAAO,EACrC",
|
|
14
|
+
"debugId": "ED54F47BF0698F9964756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
function w(k,q,u,v,b,f,j){if(typeof f==="object"){if(f.kind==="field"){if(b!==void 0)throw TypeError("@contextSelector field decorators require an undefined target");return k(void 0,f)}if(typeof b!=="function")throw TypeError("@contextSelector standard method decorators require a method target");return q(b,f)}if(j){if(typeof b==="function"||b===void 0)throw TypeError("@contextSelector legacy method decorators require a host target");return v(b,f,j)}if(typeof b==="function"||b===void 0)throw TypeError("@contextSelector legacy field decorators require a host target");return u(b,f)}export{w as dispatchContextSelectorDecorator};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=06E353F0EC35208164756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Method } from '../../types';\nimport type { ContextHostLike } from '../context-host';\n\n/**\n * Dispatches context selector decorators to standard or legacy implementations.\n */\nexport function dispatchContextSelectorDecorator<Selected>(\n\tstandardField: (\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<ContextHostLike, Selected>,\n\t) => unknown,\n\tstandardMethod: (\n\t\tprotoOrTarget: Method,\n\t\tnameOrContext: ClassMethodDecoratorContext<ContextHostLike, (value: Selected) => unknown>,\n\t) => unknown,\n\tlegacyField: (protoOrTarget: ContextHostLike, nameOrContext: string) => unknown,\n\tlegacyMethod: (\n\t\tprotoOrTarget: ContextHostLike,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<(value: Selected) => unknown>,\n\t) => unknown,\n\tprotoOrTarget: ContextHostLike | Method | undefined,\n\tnameOrContext:\n\t\t| string\n\t\t| ClassFieldDecoratorContext<ContextHostLike, Selected>\n\t\t| ClassMethodDecoratorContext<ContextHostLike, (value: Selected) => unknown>,\n\tdescriptor?: TypedPropertyDescriptor<(value: Selected) => unknown>,\n):\n\t| ((this: ContextHostLike, initialValue: Selected) => Selected)\n\t| TypedPropertyDescriptor<(value: Selected) => unknown>\n\t| void {\n\tif (typeof nameOrContext === 'object') {\n\t\tif (nameOrContext.kind === 'field') {\n\t\t\tif (protoOrTarget !== undefined) {\n\t\t\t\tthrow new TypeError('@contextSelector field decorators require an undefined target');\n\t\t\t}\n\n\t\t\treturn standardField(undefined, nameOrContext) as (\n\t\t\t\tthis: ContextHostLike,\n\t\t\t\tinitialValue: Selected,\n\t\t\t) => Selected;\n\t\t}\n\n\t\tif (typeof protoOrTarget !== 'function') {\n\t\t\tthrow new TypeError('@contextSelector standard method decorators require a method target');\n\t\t}\n\n\t\treturn standardMethod(protoOrTarget, nameOrContext) as void;\n\t}\n\n\tif (descriptor) {\n\t\tif (typeof protoOrTarget === 'function' || protoOrTarget === undefined) {\n\t\t\tthrow new TypeError('@contextSelector legacy method decorators require a host target');\n\t\t}\n\n\t\treturn legacyMethod(protoOrTarget, nameOrContext, descriptor) as TypedPropertyDescriptor<\n\t\t\t(value: Selected) => unknown\n\t\t> | void;\n\t}\n\n\tif (typeof protoOrTarget === 'function' || protoOrTarget === undefined) {\n\t\tthrow new TypeError('@contextSelector legacy field decorators require a host target');\n\t}\n\n\treturn legacyField(protoOrTarget, nameOrContext) as void;\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "AAMO,SAAS,CAA0C,CACzD,EAIA,EAIA,EACA,EAKA,EACA,EAIA,EAIO,CACP,GAAI,OAAO,IAAkB,SAAU,CACtC,GAAI,EAAc,OAAS,QAAS,CACnC,GAAI,IAAkB,OACrB,MAAU,UAAU,+DAA+D,EAGpF,OAAO,EAAc,OAAW,CAAa,EAM9C,GAAI,OAAO,IAAkB,WAC5B,MAAU,UAAU,qEAAqE,EAG1F,OAAO,EAAe,EAAe,CAAa,EAGnD,GAAI,EAAY,CACf,GAAI,OAAO,IAAkB,YAAc,IAAkB,OAC5D,MAAU,UAAU,iEAAiE,EAGtF,OAAO,EAAa,EAAe,EAAe,CAAU,EAK7D,GAAI,OAAO,IAAkB,YAAc,IAAkB,OAC5D,MAAU,UAAU,gEAAgE,EAGrF,OAAO,EAAY,EAAe,CAAa",
|
|
8
|
+
"debugId": "06E353F0EC35208164756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/context/events.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var z;((j)=>{j.SUBSCRIPTION_REQUEST="context-subscription-request";j.CONTEXT_REQUEST="context-request";j.ON_MOUNT="context-on-mount";j.MOUNTED="context-mounted"})(z||={});class B extends Event{context;callback;subscribe;handled=!1;constructor(k,q,w){super("context-request",{bubbles:!0,composed:!0});this.context=k;this.callback=q;this.subscribe=w}markHandled(){this.handled=!0}}class D extends CustomEvent{constructor(k){super("context-on-mount",{detail:{context:k},bubbles:!0,composed:!0})}}class F extends Event{context;callback;select;subscribe;onSubscribe;handled=!1;constructor(k,q,w,G,j){super("context-subscription-request",{bubbles:!0,composed:!0});this.context=k;this.callback=q;this.select=w;this.subscribe=G;this.onSubscribe=j}markHandled(){this.handled=!0}}export{F as ContextSubscriptionRequestEvent,B as ContextRequestEvent,D as ContextOnMountEvent,z as ContextEventsTypes};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=58DD2B56CC03A5AA64756E2164756E21
|
package/context/events.js.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n\tSUBSCRIPTION_REQUEST = 'context-subscription-request',\n\tCONTEXT_REQUEST = 'context-request',\n\tON_MOUNT = 'context-on-mount',\n\tMOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<ContextType<T>>,\n\t\tpublic readonly subscribe?: boolean,\n\t) {\n\t\tsuper(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\ntype DirectContextSubscription<T extends UnknownContext> = {\n\tselect?: undefined;\n\tcallback: ContextCallback<ContextType<T>>;\n};\n\ntype SelectedContextSubscription<T extends UnknownContext, Selected> = {\n\tselect: (context: ContextType<T>) => Selected;\n\tcallback: ContextCallback<Selected>;\n};\n\nexport type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> =\n\tDirectContextSubscription<T> | SelectedContextSubscription<T, Selected>;\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n\tpublic constructor(context: UnknownContext) {\n\t\tsuper(ContextEventsTypes.ON_MOUNT, {\n\t\t\tdetail: { context },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<Selected>,\n\t\tpublic readonly select?: (context: ContextType<T>) => Selected,\n\t\tpublic readonly subscribe?: boolean,\n\t\tpublic readonly onSubscribe?: (unsubscribe: () => void) => void,\n\t) {\n\t\tsuper(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementEventMap {\n\t\t/**\n\t\t * A 'context-request-subscription' event can be emitted by any element which desires\n\t\t * a context value to be injected by an external provider.\n\t\t */\n\t\t[ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n\t\t/**\n\t\t * A context-request-provider event can be emitted by a context requester to signal\n\t\t * that it desires a context value to be provided by a context provider.\n\t\t */\n\t\t[ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n\t\t/**\n\t\t * A 'context-mount' event can be emitted by a context provider to signal\n\t\t * that a context value has been mounted and is available for consumption.\n\t\t */\n\t\t[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n\t}\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "AAKO,IAAK,GAAL,CAAK,IAAL,CACN,uBAAuB,+BACvB,kBAAkB,kBAClB,WAAW,mBACX,UAAU,oBAJC,QAiBL,MAAM,UAAsD,KAAM,CAIvD,QACA,SACA,UALV,QAAU,GAEV,WAAW,CACD,EACA,EACA,EACf,CACD,MAAM,kBAAoC,CAAE,QAAS,GAAM,SAAU,EAAK,CAAC,EAJ3D,eACA,gBACA,iBAKV,WAAW,EAAS,CAC1B,KAAK,QAAU,GAEjB,CAqBO,MAAM,UAA4B,WAAyC,CAC1E,WAAW,CAAC,EAAyB,CAC3C,MAAM,mBAA6B,CAClC,OAAQ,CAAE,SAAQ,EAClB,QAAS,GACT,SAAU,EACX,CAAC,EAEH,CAcO,MAAM,UAA6F,KAAM,CAI9F,QACA,SACA,OACA,UACA,YAPV,QAAU,GAEV,WAAW,CACD,EACA,EACA,EACA,EACA,EACf,CACD,MAAM,+BAAyC,CAC9C,QAAS,GACT,SAAU,EACX,CAAC,EATe,eACA,gBACA,cACA,iBACA,mBAQV,WAAW,EAAS,CAC1B,KAAK,QAAU,GAEjB",
|
|
8
|
+
"debugId": "58DD2B56CC03A5AA64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|