@vielzeug/ore 1.0.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 +73 -0
- package/dist/_dev.cjs +2 -0
- package/dist/_dev.cjs.map +1 -0
- package/dist/_dev.d.ts +2 -0
- package/dist/_dev.d.ts.map +1 -0
- package/dist/_dev.js +2 -0
- package/dist/_dev.js.map +1 -0
- package/dist/aria.cjs +2 -0
- package/dist/aria.cjs.map +1 -0
- package/dist/aria.d.ts +12 -0
- package/dist/aria.d.ts.map +1 -0
- package/dist/aria.js +2 -0
- package/dist/aria.js.map +1 -0
- package/dist/base-element.cjs +2 -0
- package/dist/base-element.cjs.map +1 -0
- package/dist/base-element.d.ts +22 -0
- package/dist/base-element.d.ts.map +1 -0
- package/dist/base-element.js +2 -0
- package/dist/base-element.js.map +1 -0
- package/dist/component-types.d.ts +104 -0
- package/dist/component-types.d.ts.map +1 -0
- package/dist/context-bag.cjs +2 -0
- package/dist/context-bag.cjs.map +1 -0
- package/dist/context-bag.d.ts +12 -0
- package/dist/context-bag.d.ts.map +1 -0
- package/dist/context-bag.js +2 -0
- package/dist/context-bag.js.map +1 -0
- package/dist/context.cjs +2 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.ts +15 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +2 -0
- package/dist/context.js.map +1 -0
- package/dist/define.cjs +2 -0
- package/dist/define.cjs.map +1 -0
- package/dist/define.d.ts +33 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +2 -0
- package/dist/define.js.map +1 -0
- package/dist/devtools.cjs +2 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.ts +32 -0
- package/dist/devtools.d.ts.map +1 -0
- package/dist/devtools.js +2 -0
- package/dist/devtools.js.map +1 -0
- package/dist/directives/classMap.cjs +2 -0
- package/dist/directives/classMap.cjs.map +1 -0
- package/dist/directives/classMap.d.ts +19 -0
- package/dist/directives/classMap.d.ts.map +1 -0
- package/dist/directives/classMap.js +2 -0
- package/dist/directives/classMap.js.map +1 -0
- package/dist/directives/each.cjs +2 -0
- package/dist/directives/each.cjs.map +1 -0
- package/dist/directives/each.d.ts +25 -0
- package/dist/directives/each.d.ts.map +1 -0
- package/dist/directives/each.js +2 -0
- package/dist/directives/each.js.map +1 -0
- package/dist/directives/index.d.ts +8 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/directives/live.cjs +2 -0
- package/dist/directives/live.cjs.map +1 -0
- package/dist/directives/live.d.ts +25 -0
- package/dist/directives/live.d.ts.map +1 -0
- package/dist/directives/live.js +2 -0
- package/dist/directives/live.js.map +1 -0
- package/dist/directives/model.cjs +2 -0
- package/dist/directives/model.cjs.map +1 -0
- package/dist/directives/model.d.ts +28 -0
- package/dist/directives/model.d.ts.map +1 -0
- package/dist/directives/model.js +2 -0
- package/dist/directives/model.js.map +1 -0
- package/dist/directives/raw.cjs +2 -0
- package/dist/directives/raw.cjs.map +1 -0
- package/dist/directives/raw.d.ts +16 -0
- package/dist/directives/raw.d.ts.map +1 -0
- package/dist/directives/raw.js +2 -0
- package/dist/directives/raw.js.map +1 -0
- package/dist/directives/styleMap.cjs +2 -0
- package/dist/directives/styleMap.cjs.map +1 -0
- package/dist/directives/styleMap.d.ts +25 -0
- package/dist/directives/styleMap.d.ts.map +1 -0
- package/dist/directives/styleMap.js +2 -0
- package/dist/directives/styleMap.js.map +1 -0
- package/dist/directives/when.cjs +2 -0
- package/dist/directives/when.cjs.map +1 -0
- package/dist/directives/when.d.ts +19 -0
- package/dist/directives/when.d.ts.map +1 -0
- package/dist/directives/when.js +2 -0
- package/dist/directives/when.js.map +1 -0
- package/dist/directives.cjs +1 -0
- package/dist/directives.js +1 -0
- package/dist/errors.cjs +3 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +47 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +3 -0
- package/dist/errors.js.map +1 -0
- package/dist/form-context.cjs +2 -0
- package/dist/form-context.cjs.map +1 -0
- package/dist/form-context.d.ts +56 -0
- package/dist/form-context.d.ts.map +1 -0
- package/dist/form-context.js +2 -0
- package/dist/form-context.js.map +1 -0
- package/dist/form-field.cjs +2 -0
- package/dist/form-field.cjs.map +1 -0
- package/dist/form-field.d.ts +31 -0
- package/dist/form-field.d.ts.map +1 -0
- package/dist/form-field.js +2 -0
- package/dist/form-field.js.map +1 -0
- package/dist/host-bind.cjs +2 -0
- package/dist/host-bind.cjs.map +1 -0
- package/dist/host-bind.d.ts +37 -0
- package/dist/host-bind.d.ts.map +1 -0
- package/dist/host-bind.js +2 -0
- package/dist/host-bind.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/observers/index.d.ts +5 -0
- package/dist/observers/index.d.ts.map +1 -0
- package/dist/observers/intersection-observe.cjs +2 -0
- package/dist/observers/intersection-observe.cjs.map +1 -0
- package/dist/observers/intersection-observe.d.ts +9 -0
- package/dist/observers/intersection-observe.d.ts.map +1 -0
- package/dist/observers/intersection-observe.js +2 -0
- package/dist/observers/intersection-observe.js.map +1 -0
- package/dist/observers/media-observe.cjs +2 -0
- package/dist/observers/media-observe.cjs.map +1 -0
- package/dist/observers/media-observe.d.ts +8 -0
- package/dist/observers/media-observe.d.ts.map +1 -0
- package/dist/observers/media-observe.js +2 -0
- package/dist/observers/media-observe.js.map +1 -0
- package/dist/observers/mutation-observe.cjs +2 -0
- package/dist/observers/mutation-observe.cjs.map +1 -0
- package/dist/observers/mutation-observe.d.ts +10 -0
- package/dist/observers/mutation-observe.d.ts.map +1 -0
- package/dist/observers/mutation-observe.js +2 -0
- package/dist/observers/mutation-observe.js.map +1 -0
- package/dist/observers/resize-observe.cjs +2 -0
- package/dist/observers/resize-observe.cjs.map +1 -0
- package/dist/observers/resize-observe.d.ts +11 -0
- package/dist/observers/resize-observe.d.ts.map +1 -0
- package/dist/observers/resize-observe.js +2 -0
- package/dist/observers/resize-observe.js.map +1 -0
- package/dist/observers.cjs +1 -0
- package/dist/observers.js +1 -0
- package/dist/ore.cjs +3 -0
- package/dist/ore.cjs.map +1 -0
- package/dist/ore.iife.js +3 -0
- package/dist/ore.iife.js.map +1 -0
- package/dist/ore.js +3 -0
- package/dist/ore.js.map +1 -0
- package/dist/props.cjs +2 -0
- package/dist/props.cjs.map +1 -0
- package/dist/props.d.ts +76 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +2 -0
- package/dist/props.js.map +1 -0
- package/dist/runtime.cjs +2 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2 -0
- package/dist/runtime.js.map +1 -0
- package/dist/slots.cjs +2 -0
- package/dist/slots.cjs.map +1 -0
- package/dist/slots.d.ts +13 -0
- package/dist/slots.d.ts.map +1 -0
- package/dist/slots.js +2 -0
- package/dist/slots.js.map +1 -0
- package/dist/template/bindings.cjs +2 -0
- package/dist/template/bindings.cjs.map +1 -0
- package/dist/template/bindings.d.ts +17 -0
- package/dist/template/bindings.d.ts.map +1 -0
- package/dist/template/bindings.js +2 -0
- package/dist/template/bindings.js.map +1 -0
- package/dist/template/compiler.cjs +2 -0
- package/dist/template/compiler.cjs.map +1 -0
- package/dist/template/compiler.d.ts +27 -0
- package/dist/template/compiler.d.ts.map +1 -0
- package/dist/template/compiler.js +2 -0
- package/dist/template/compiler.js.map +1 -0
- package/dist/template/instantiator.cjs +2 -0
- package/dist/template/instantiator.cjs.map +1 -0
- package/dist/template/instantiator.d.ts +16 -0
- package/dist/template/instantiator.d.ts.map +1 -0
- package/dist/template/instantiator.js +2 -0
- package/dist/template/instantiator.js.map +1 -0
- package/dist/template.cjs +1 -0
- package/dist/template.d.ts +4 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +1 -0
- package/dist/testing/events.cjs +2 -0
- package/dist/testing/events.cjs.map +1 -0
- package/dist/testing/events.d.ts +37 -0
- package/dist/testing/events.d.ts.map +1 -0
- package/dist/testing/events.js +2 -0
- package/dist/testing/events.js.map +1 -0
- package/dist/testing/flush.cjs +2 -0
- package/dist/testing/flush.cjs.map +1 -0
- package/dist/testing/flush.d.ts +55 -0
- package/dist/testing/flush.d.ts.map +1 -0
- package/dist/testing/flush.js +2 -0
- package/dist/testing/flush.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/interactions.cjs +2 -0
- package/dist/testing/interactions.cjs.map +1 -0
- package/dist/testing/interactions.d.ts +27 -0
- package/dist/testing/interactions.d.ts.map +1 -0
- package/dist/testing/interactions.js +2 -0
- package/dist/testing/interactions.js.map +1 -0
- package/dist/testing/mount.cjs +2 -0
- package/dist/testing/mount.cjs.map +1 -0
- package/dist/testing/mount.d.ts +107 -0
- package/dist/testing/mount.d.ts.map +1 -0
- package/dist/testing/mount.js +2 -0
- package/dist/testing/mount.js.map +1 -0
- package/dist/testing/query.cjs +2 -0
- package/dist/testing/query.cjs.map +1 -0
- package/dist/testing/query.d.ts +24 -0
- package/dist/testing/query.d.ts.map +1 -0
- package/dist/testing/query.js +2 -0
- package/dist/testing/query.js.map +1 -0
- package/dist/testing/render-hook.cjs +2 -0
- package/dist/testing/render-hook.cjs.map +1 -0
- package/dist/testing/render-hook.d.ts +44 -0
- package/dist/testing/render-hook.d.ts.map +1 -0
- package/dist/testing/render-hook.js +2 -0
- package/dist/testing/render-hook.js.map +1 -0
- package/dist/testing/testing.cjs +2 -0
- package/dist/testing/testing.cjs.map +1 -0
- package/dist/testing/testing.d.ts +26 -0
- package/dist/testing/testing.d.ts.map +1 -0
- package/dist/testing/testing.js +2 -0
- package/dist/testing/testing.js.map +1 -0
- package/dist/testing/wait.cjs +2 -0
- package/dist/testing/wait.cjs.map +1 -0
- package/dist/testing/wait.d.ts +35 -0
- package/dist/testing/wait.d.ts.map +1 -0
- package/dist/testing/wait.js +2 -0
- package/dist/testing/wait.js.map +1 -0
- package/dist/testing.cjs +1 -0
- package/dist/testing.js +1 -0
- package/dist/types/bindings.cjs +2 -0
- package/dist/types/bindings.cjs.map +1 -0
- package/dist/types/bindings.d.ts +125 -0
- package/dist/types/bindings.d.ts.map +1 -0
- package/dist/types/bindings.js +2 -0
- package/dist/types/bindings.js.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/aria.cjs +2 -0
- package/dist/utils/aria.cjs.map +1 -0
- package/dist/utils/aria.d.ts +16 -0
- package/dist/utils/aria.d.ts.map +1 -0
- package/dist/utils/aria.js +2 -0
- package/dist/utils/aria.js.map +1 -0
- package/dist/utils/css.cjs +2 -0
- package/dist/utils/css.cjs.map +1 -0
- package/dist/utils/css.d.ts +11 -0
- package/dist/utils/css.d.ts.map +1 -0
- package/dist/utils/css.js +2 -0
- package/dist/utils/css.js.map +1 -0
- package/dist/utils/dom.cjs +2 -0
- package/dist/utils/dom.cjs.map +1 -0
- package/dist/utils/dom.d.ts +10 -0
- package/dist/utils/dom.d.ts.map +1 -0
- package/dist/utils/dom.js +2 -0
- package/dist/utils/dom.js.map +1 -0
- package/dist/utils/emit.cjs +2 -0
- package/dist/utils/emit.cjs.map +1 -0
- package/dist/utils/emit.d.ts +16 -0
- package/dist/utils/emit.d.ts.map +1 -0
- package/dist/utils/emit.js +2 -0
- package/dist/utils/emit.js.map +1 -0
- package/dist/utils/event-modifiers.cjs +2 -0
- package/dist/utils/event-modifiers.cjs.map +1 -0
- package/dist/utils/event-modifiers.d.ts +11 -0
- package/dist/utils/event-modifiers.d.ts.map +1 -0
- package/dist/utils/event-modifiers.js +2 -0
- package/dist/utils/event-modifiers.js.map +1 -0
- package/dist/utils/id.cjs +2 -0
- package/dist/utils/id.cjs.map +1 -0
- package/dist/utils/id.d.ts +18 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +2 -0
- package/dist/utils/id.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.cjs","names":[],"sources":["../../src/types/bindings.ts"],"sourcesContent":["/**\n * Core type definitions for the template binding and rendering system.\n *\n * All bindings reference actual DOM nodes directly (no UID-based lookup).\n * This eliminates the TreeWalker indexing pass and the string-based ID remapping\n * that the previous design required.\n */\n\nimport { type Readable, signal, type Signal } from '@vielzeug/ripple';\n\n// ─── REF TYPES ───────────────────────────────────────────────────────────────\n\nexport type Ref<T extends Element> = Signal<T | null>;\n\nexport function ref<T extends Element>(): Ref<T> {\n return signal<T | null>(null);\n}\n\nexport type RefCallback<T extends Element> = (el: T | null) => void;\n\n// ─── BINDING VARIANTS ────────────────────────────────────────────────────────\n// All bindings hold direct references to the DOM node they manage.\n\nexport type TextBinding = {\n node: Text;\n signal: Readable<unknown>;\n type: 'text';\n};\n\n/**\n * Minimal prop metadata needed by the attr binding layer.\n * Populated at binding creation time from propRegistry, so template-bindings.ts\n * has no direct dependency on props.ts.\n */\nexport type AttrPropMeta = {\n parse: (v: string | null) => unknown;\n reflect: boolean;\n signal: { value: unknown };\n};\n\ntype AttrBaseFields = {\n el: HTMLElement;\n /**\n * When true the binding uses live-write semantics: stale app-state writes are\n * skipped if the DOM value has diverged from the last programmatic write.\n */\n live?: true;\n mode: 'attr' | 'bool';\n name: string;\n /** Pre-resolved prop metadata (if the target element is an ore component). */\n propMeta?: AttrPropMeta;\n type: 'attr';\n};\n\n/** Attribute binding with a static value (no signal). */\nexport type AttrStaticBinding = AttrBaseFields & { value: unknown };\n\n/** Attribute binding driven by a reactive signal. */\nexport type AttrReactiveBinding = AttrBaseFields & { signal: Readable<unknown> };\n\nexport type AttrBinding = AttrStaticBinding | AttrReactiveBinding;\n\nexport type EventBinding = {\n el: HTMLElement;\n handler: (e: Event) => void;\n name: string;\n options?: AddEventListenerOptions;\n type: 'event';\n};\n\nexport type RefBinding = {\n el: HTMLElement;\n ref: Ref<Element> | RefCallback<Element>;\n type: 'ref';\n};\n\n/** Value types a reactive HTML slot can produce. */\nexport type HtmlBindingValue = HTMLResult | string | number | boolean | null | undefined;\n\nexport type HtmlBinding = {\n anchor: Comment;\n signal: Readable<HtmlBindingValue[]>;\n type: 'html';\n};\n\nexport type DirectiveBinding = {\n anchor: Comment;\n directive: DirectiveResult;\n type: 'directive';\n};\n\n/** Element-spread binding applied by model() and similar helpers. */\nexport type SpreadBinding = {\n el: HTMLElement;\n spread: SpreadObject;\n type: 'spread';\n};\n\nexport type Binding =\n TextBinding | AttrBinding | EventBinding | RefBinding | HtmlBinding | DirectiveBinding | SpreadBinding;\n\n// ─── BRAND UTILITY ───────────────────────────────────────────────────────────\n// Cross-realm–safe brand for branded types. Avoids repeating the symbol+guard boilerplate.\n\nconst makeBrand = <T extends object>(key: string) => {\n const BRAND = Symbol.for(key);\n const stamp = (obj: T): T => Object.assign(obj, { [BRAND]: true });\n const is = (value: unknown): value is T => typeof value === 'object' && value !== null && BRAND in (value as object);\n\n return { is, stamp };\n};\n\n// ─── DIRECTIVE RESULT ────────────────────────────────────────────────────────\n\nexport type DirectiveResult = {\n mount: (anchor: Comment, registerCleanup: (fn: () => void) => void) => void;\n};\n\nconst directiveBrand = makeBrand<DirectiveResult>('ore:directive');\n\n/**\n * Creates a registered DirectiveResult. All directive factories must use this\n * function — only objects created here pass `isDirectiveResult()`.\n */\nexport const createDirectiveResult = (mount: DirectiveResult['mount']): DirectiveResult =>\n directiveBrand.stamp({ mount });\n\nexport const isDirectiveResult = directiveBrand.is;\n\n// ─── SPREAD OBJECT ───────────────────────────────────────────────────────────\n// Returned by model() and similar helpers that apply multiple bindings to one element.\n\nexport type SpreadObject = {\n apply(el: HTMLElement, registerCleanup: (fn: () => void) => void): void;\n};\n\nconst spreadBrand = makeBrand<SpreadObject>('ore:spread');\n\n/**\n * Creates a registered SpreadObject. Used by model() to attach multiple bindings\n * (value sync + input event) to an element via a single template expression.\n */\nexport const createSpreadObject = (apply: SpreadObject['apply']): SpreadObject => spreadBrand.stamp({ apply });\n\nexport const isSpreadObject = spreadBrand.is;\n\n// ─── HTML RESULT ─────────────────────────────────────────────────────────────\n\n/**\n * The output of an `html` tagged template call.\n *\n * Each `html` call produces an independent fragment — there is no shared mutable\n * state between instances, so the same template can be safely rendered multiple\n * times (e.g. inside `each()`).\n */\nexport interface HTMLResult {\n /** The DOM fragment ready to insert into the document. Consumed on insertion. */\n readonly fragment: DocumentFragment;\n /** Wire up reactive effects to the fragment's nodes. Call after insertion. */\n apply(registerCleanup: (fn: () => void) => void): void;\n /**\n * Insert the fragment before `anchor` (or append to `parent` when no anchor)\n * and immediately wire up all reactive effects.\n *\n * This is the preferred single-step API — it is impossible to forget calling\n * `apply` separately. Use the lower-level `fragment` + `apply` only when you\n * need precise control over insertion (e.g. inside directive implementations).\n */\n mount(parent: ParentNode, anchor: Node | null, registerCleanup: (fn: () => void) => void): Node[];\n}\n\nconst htmlResultBrand = makeBrand<HTMLResult>('ore:html-result');\n\nexport const isHtmlResult = htmlResultBrand.is;\n\nexport function createHtmlResult(\n fragment: DocumentFragment,\n applyFn: (registerCleanup: (fn: () => void) => void) => void,\n): HTMLResult {\n const mount = (parent: ParentNode, anchor: Node | null, registerCleanup: (fn: () => void) => void): Node[] => {\n const nodes = Array.from(fragment.childNodes);\n\n parent.insertBefore(fragment, anchor);\n applyFn(registerCleanup);\n\n return nodes;\n };\n\n return htmlResultBrand.stamp({ apply: applyFn, fragment, mount });\n}\n"],"mappings":"kCAcA,SAAgB,GAAiC,CAC/C,OAAA,EAAA,EAAA,OAAA,CAAwB,IAAI,CAC9B,CAwFA,IAAM,EAA+B,GAAgB,CACnD,IAAM,EAAQ,OAAO,IAAI,CAAG,EAI5B,MAAO,CAAE,GAFG,GAA+B,OAAO,GAAU,YAAY,GAAkB,KAAU,EAEvF,MAHE,GAAc,OAAO,OAAO,EAAK,EAAG,GAAQ,EAAK,CAAC,CAG9C,CACrB,EAQM,EAAiB,EAA2B,eAAe,EAMpD,EAAyB,GACpC,EAAe,MAAM,CAAE,OAAM,CAAC,EAEnB,EAAoB,EAAe,GAS1C,EAAc,EAAwB,YAAY,EAM3C,EAAsB,GAA+C,EAAY,MAAM,CAAE,OAAM,CAAC,EAEhG,EAAiB,EAAY,GA2BpC,EAAkB,EAAsB,iBAAiB,EAElD,EAAe,EAAgB,GAE5C,SAAgB,EACd,EACA,EACY,CAUZ,OAAO,EAAgB,MAAM,CAAE,MAAO,EAAS,WAAU,OAT1C,EAAoB,EAAqB,IAAsD,CAC5G,IAAM,EAAQ,MAAM,KAAK,EAAS,UAAU,EAK5C,OAHA,EAAO,aAAa,EAAU,CAAM,EACpC,EAAQ,CAAe,EAEhB,CACT,CAE+D,CAAC,CAClE"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the template binding and rendering system.
|
|
3
|
+
*
|
|
4
|
+
* All bindings reference actual DOM nodes directly (no UID-based lookup).
|
|
5
|
+
* This eliminates the TreeWalker indexing pass and the string-based ID remapping
|
|
6
|
+
* that the previous design required.
|
|
7
|
+
*/
|
|
8
|
+
import { type Readable, type Signal } from '@vielzeug/ripple';
|
|
9
|
+
export type Ref<T extends Element> = Signal<T | null>;
|
|
10
|
+
export declare function ref<T extends Element>(): Ref<T>;
|
|
11
|
+
export type RefCallback<T extends Element> = (el: T | null) => void;
|
|
12
|
+
export type TextBinding = {
|
|
13
|
+
node: Text;
|
|
14
|
+
signal: Readable<unknown>;
|
|
15
|
+
type: 'text';
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Minimal prop metadata needed by the attr binding layer.
|
|
19
|
+
* Populated at binding creation time from propRegistry, so template-bindings.ts
|
|
20
|
+
* has no direct dependency on props.ts.
|
|
21
|
+
*/
|
|
22
|
+
export type AttrPropMeta = {
|
|
23
|
+
parse: (v: string | null) => unknown;
|
|
24
|
+
reflect: boolean;
|
|
25
|
+
signal: {
|
|
26
|
+
value: unknown;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type AttrBaseFields = {
|
|
30
|
+
el: HTMLElement;
|
|
31
|
+
/**
|
|
32
|
+
* When true the binding uses live-write semantics: stale app-state writes are
|
|
33
|
+
* skipped if the DOM value has diverged from the last programmatic write.
|
|
34
|
+
*/
|
|
35
|
+
live?: true;
|
|
36
|
+
mode: 'attr' | 'bool';
|
|
37
|
+
name: string;
|
|
38
|
+
/** Pre-resolved prop metadata (if the target element is an ore component). */
|
|
39
|
+
propMeta?: AttrPropMeta;
|
|
40
|
+
type: 'attr';
|
|
41
|
+
};
|
|
42
|
+
/** Attribute binding with a static value (no signal). */
|
|
43
|
+
export type AttrStaticBinding = AttrBaseFields & {
|
|
44
|
+
value: unknown;
|
|
45
|
+
};
|
|
46
|
+
/** Attribute binding driven by a reactive signal. */
|
|
47
|
+
export type AttrReactiveBinding = AttrBaseFields & {
|
|
48
|
+
signal: Readable<unknown>;
|
|
49
|
+
};
|
|
50
|
+
export type AttrBinding = AttrStaticBinding | AttrReactiveBinding;
|
|
51
|
+
export type EventBinding = {
|
|
52
|
+
el: HTMLElement;
|
|
53
|
+
handler: (e: Event) => void;
|
|
54
|
+
name: string;
|
|
55
|
+
options?: AddEventListenerOptions;
|
|
56
|
+
type: 'event';
|
|
57
|
+
};
|
|
58
|
+
export type RefBinding = {
|
|
59
|
+
el: HTMLElement;
|
|
60
|
+
ref: Ref<Element> | RefCallback<Element>;
|
|
61
|
+
type: 'ref';
|
|
62
|
+
};
|
|
63
|
+
/** Value types a reactive HTML slot can produce. */
|
|
64
|
+
export type HtmlBindingValue = HTMLResult | string | number | boolean | null | undefined;
|
|
65
|
+
export type HtmlBinding = {
|
|
66
|
+
anchor: Comment;
|
|
67
|
+
signal: Readable<HtmlBindingValue[]>;
|
|
68
|
+
type: 'html';
|
|
69
|
+
};
|
|
70
|
+
export type DirectiveBinding = {
|
|
71
|
+
anchor: Comment;
|
|
72
|
+
directive: DirectiveResult;
|
|
73
|
+
type: 'directive';
|
|
74
|
+
};
|
|
75
|
+
/** Element-spread binding applied by model() and similar helpers. */
|
|
76
|
+
export type SpreadBinding = {
|
|
77
|
+
el: HTMLElement;
|
|
78
|
+
spread: SpreadObject;
|
|
79
|
+
type: 'spread';
|
|
80
|
+
};
|
|
81
|
+
export type Binding = TextBinding | AttrBinding | EventBinding | RefBinding | HtmlBinding | DirectiveBinding | SpreadBinding;
|
|
82
|
+
export type DirectiveResult = {
|
|
83
|
+
mount: (anchor: Comment, registerCleanup: (fn: () => void) => void) => void;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Creates a registered DirectiveResult. All directive factories must use this
|
|
87
|
+
* function — only objects created here pass `isDirectiveResult()`.
|
|
88
|
+
*/
|
|
89
|
+
export declare const createDirectiveResult: (mount: DirectiveResult["mount"]) => DirectiveResult;
|
|
90
|
+
export declare const isDirectiveResult: (value: unknown) => value is DirectiveResult;
|
|
91
|
+
export type SpreadObject = {
|
|
92
|
+
apply(el: HTMLElement, registerCleanup: (fn: () => void) => void): void;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Creates a registered SpreadObject. Used by model() to attach multiple bindings
|
|
96
|
+
* (value sync + input event) to an element via a single template expression.
|
|
97
|
+
*/
|
|
98
|
+
export declare const createSpreadObject: (apply: SpreadObject["apply"]) => SpreadObject;
|
|
99
|
+
export declare const isSpreadObject: (value: unknown) => value is SpreadObject;
|
|
100
|
+
/**
|
|
101
|
+
* The output of an `html` tagged template call.
|
|
102
|
+
*
|
|
103
|
+
* Each `html` call produces an independent fragment — there is no shared mutable
|
|
104
|
+
* state between instances, so the same template can be safely rendered multiple
|
|
105
|
+
* times (e.g. inside `each()`).
|
|
106
|
+
*/
|
|
107
|
+
export interface HTMLResult {
|
|
108
|
+
/** The DOM fragment ready to insert into the document. Consumed on insertion. */
|
|
109
|
+
readonly fragment: DocumentFragment;
|
|
110
|
+
/** Wire up reactive effects to the fragment's nodes. Call after insertion. */
|
|
111
|
+
apply(registerCleanup: (fn: () => void) => void): void;
|
|
112
|
+
/**
|
|
113
|
+
* Insert the fragment before `anchor` (or append to `parent` when no anchor)
|
|
114
|
+
* and immediately wire up all reactive effects.
|
|
115
|
+
*
|
|
116
|
+
* This is the preferred single-step API — it is impossible to forget calling
|
|
117
|
+
* `apply` separately. Use the lower-level `fragment` + `apply` only when you
|
|
118
|
+
* need precise control over insertion (e.g. inside directive implementations).
|
|
119
|
+
*/
|
|
120
|
+
mount(parent: ParentNode, anchor: Node | null, registerCleanup: (fn: () => void) => void): Node[];
|
|
121
|
+
}
|
|
122
|
+
export declare const isHtmlResult: (value: unknown) => value is HTMLResult;
|
|
123
|
+
export declare function createHtmlResult(fragment: DocumentFragment, applyFn: (registerCleanup: (fn: () => void) => void) => void): HTMLResult;
|
|
124
|
+
export {};
|
|
125
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../src/types/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAU,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAItE,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,OAAO,IAAI,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAEtD,wBAAgB,GAAG,CAAC,CAAC,SAAS,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAE/C;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;AAKpE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC5B,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,WAAW,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,qDAAqD;AACrD,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,WAAW,CAAC;IAChB,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,WAAW,CAAC;IAChB,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,EAAE,KAAK,CAAC;CACb,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAEzF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,eAAe,CAAC;IAC3B,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,WAAW,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,OAAO,GACjB,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAezG,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC;CAC7E,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,eAAe,CAAC,OAAO,CAAC,KAAG,eACvC,CAAC;AAElC,eAAO,MAAM,iBAAiB,UApBT,OAAO,KAAG,KAAK,mBAoBc,CAAC;AAKnD,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;CACzE,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,YAAY,CAAC,OAAO,CAAC,KAAG,YAA4C,CAAC;AAE/G,eAAO,MAAM,cAAc,UArCN,OAAO,KAAG,KAAK,gBAqCQ,CAAC;AAI7C;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,8EAA8E;IAC9E,KAAK,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;IACvD;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,EAAE,CAAC;CACnG;AAID,eAAO,MAAM,YAAY,UAlEJ,OAAO,KAAG,KAAK,cAkEU,CAAC;AAE/C,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,KAAK,IAAI,GAC3D,UAAU,CAWZ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{signal as e}from"@vielzeug/ripple";function t(){return e(null)}var n=e=>{let t=Symbol.for(e);return{is:e=>typeof e==`object`&&!!e&&t in e,stamp:e=>Object.assign(e,{[t]:!0})}},r=n(`ore:directive`),i=e=>r.stamp({mount:e}),a=r.is,o=n(`ore:spread`),s=e=>o.stamp({apply:e}),c=o.is,l=n(`ore:html-result`),u=l.is;function d(e,t){return l.stamp({apply:t,fragment:e,mount:(n,r,i)=>{let a=Array.from(e.childNodes);return n.insertBefore(e,r),t(i),a}})}export{i as createDirectiveResult,d as createHtmlResult,s as createSpreadObject,a as isDirectiveResult,u as isHtmlResult,c as isSpreadObject,t as ref};
|
|
2
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","names":[],"sources":["../../src/types/bindings.ts"],"sourcesContent":["/**\n * Core type definitions for the template binding and rendering system.\n *\n * All bindings reference actual DOM nodes directly (no UID-based lookup).\n * This eliminates the TreeWalker indexing pass and the string-based ID remapping\n * that the previous design required.\n */\n\nimport { type Readable, signal, type Signal } from '@vielzeug/ripple';\n\n// ─── REF TYPES ───────────────────────────────────────────────────────────────\n\nexport type Ref<T extends Element> = Signal<T | null>;\n\nexport function ref<T extends Element>(): Ref<T> {\n return signal<T | null>(null);\n}\n\nexport type RefCallback<T extends Element> = (el: T | null) => void;\n\n// ─── BINDING VARIANTS ────────────────────────────────────────────────────────\n// All bindings hold direct references to the DOM node they manage.\n\nexport type TextBinding = {\n node: Text;\n signal: Readable<unknown>;\n type: 'text';\n};\n\n/**\n * Minimal prop metadata needed by the attr binding layer.\n * Populated at binding creation time from propRegistry, so template-bindings.ts\n * has no direct dependency on props.ts.\n */\nexport type AttrPropMeta = {\n parse: (v: string | null) => unknown;\n reflect: boolean;\n signal: { value: unknown };\n};\n\ntype AttrBaseFields = {\n el: HTMLElement;\n /**\n * When true the binding uses live-write semantics: stale app-state writes are\n * skipped if the DOM value has diverged from the last programmatic write.\n */\n live?: true;\n mode: 'attr' | 'bool';\n name: string;\n /** Pre-resolved prop metadata (if the target element is an ore component). */\n propMeta?: AttrPropMeta;\n type: 'attr';\n};\n\n/** Attribute binding with a static value (no signal). */\nexport type AttrStaticBinding = AttrBaseFields & { value: unknown };\n\n/** Attribute binding driven by a reactive signal. */\nexport type AttrReactiveBinding = AttrBaseFields & { signal: Readable<unknown> };\n\nexport type AttrBinding = AttrStaticBinding | AttrReactiveBinding;\n\nexport type EventBinding = {\n el: HTMLElement;\n handler: (e: Event) => void;\n name: string;\n options?: AddEventListenerOptions;\n type: 'event';\n};\n\nexport type RefBinding = {\n el: HTMLElement;\n ref: Ref<Element> | RefCallback<Element>;\n type: 'ref';\n};\n\n/** Value types a reactive HTML slot can produce. */\nexport type HtmlBindingValue = HTMLResult | string | number | boolean | null | undefined;\n\nexport type HtmlBinding = {\n anchor: Comment;\n signal: Readable<HtmlBindingValue[]>;\n type: 'html';\n};\n\nexport type DirectiveBinding = {\n anchor: Comment;\n directive: DirectiveResult;\n type: 'directive';\n};\n\n/** Element-spread binding applied by model() and similar helpers. */\nexport type SpreadBinding = {\n el: HTMLElement;\n spread: SpreadObject;\n type: 'spread';\n};\n\nexport type Binding =\n TextBinding | AttrBinding | EventBinding | RefBinding | HtmlBinding | DirectiveBinding | SpreadBinding;\n\n// ─── BRAND UTILITY ───────────────────────────────────────────────────────────\n// Cross-realm–safe brand for branded types. Avoids repeating the symbol+guard boilerplate.\n\nconst makeBrand = <T extends object>(key: string) => {\n const BRAND = Symbol.for(key);\n const stamp = (obj: T): T => Object.assign(obj, { [BRAND]: true });\n const is = (value: unknown): value is T => typeof value === 'object' && value !== null && BRAND in (value as object);\n\n return { is, stamp };\n};\n\n// ─── DIRECTIVE RESULT ────────────────────────────────────────────────────────\n\nexport type DirectiveResult = {\n mount: (anchor: Comment, registerCleanup: (fn: () => void) => void) => void;\n};\n\nconst directiveBrand = makeBrand<DirectiveResult>('ore:directive');\n\n/**\n * Creates a registered DirectiveResult. All directive factories must use this\n * function — only objects created here pass `isDirectiveResult()`.\n */\nexport const createDirectiveResult = (mount: DirectiveResult['mount']): DirectiveResult =>\n directiveBrand.stamp({ mount });\n\nexport const isDirectiveResult = directiveBrand.is;\n\n// ─── SPREAD OBJECT ───────────────────────────────────────────────────────────\n// Returned by model() and similar helpers that apply multiple bindings to one element.\n\nexport type SpreadObject = {\n apply(el: HTMLElement, registerCleanup: (fn: () => void) => void): void;\n};\n\nconst spreadBrand = makeBrand<SpreadObject>('ore:spread');\n\n/**\n * Creates a registered SpreadObject. Used by model() to attach multiple bindings\n * (value sync + input event) to an element via a single template expression.\n */\nexport const createSpreadObject = (apply: SpreadObject['apply']): SpreadObject => spreadBrand.stamp({ apply });\n\nexport const isSpreadObject = spreadBrand.is;\n\n// ─── HTML RESULT ─────────────────────────────────────────────────────────────\n\n/**\n * The output of an `html` tagged template call.\n *\n * Each `html` call produces an independent fragment — there is no shared mutable\n * state between instances, so the same template can be safely rendered multiple\n * times (e.g. inside `each()`).\n */\nexport interface HTMLResult {\n /** The DOM fragment ready to insert into the document. Consumed on insertion. */\n readonly fragment: DocumentFragment;\n /** Wire up reactive effects to the fragment's nodes. Call after insertion. */\n apply(registerCleanup: (fn: () => void) => void): void;\n /**\n * Insert the fragment before `anchor` (or append to `parent` when no anchor)\n * and immediately wire up all reactive effects.\n *\n * This is the preferred single-step API — it is impossible to forget calling\n * `apply` separately. Use the lower-level `fragment` + `apply` only when you\n * need precise control over insertion (e.g. inside directive implementations).\n */\n mount(parent: ParentNode, anchor: Node | null, registerCleanup: (fn: () => void) => void): Node[];\n}\n\nconst htmlResultBrand = makeBrand<HTMLResult>('ore:html-result');\n\nexport const isHtmlResult = htmlResultBrand.is;\n\nexport function createHtmlResult(\n fragment: DocumentFragment,\n applyFn: (registerCleanup: (fn: () => void) => void) => void,\n): HTMLResult {\n const mount = (parent: ParentNode, anchor: Node | null, registerCleanup: (fn: () => void) => void): Node[] => {\n const nodes = Array.from(fragment.childNodes);\n\n parent.insertBefore(fragment, anchor);\n applyFn(registerCleanup);\n\n return nodes;\n };\n\n return htmlResultBrand.stamp({ apply: applyFn, fragment, mount });\n}\n"],"mappings":"0CAcA,SAAgB,GAAiC,CAC/C,OAAO,EAAiB,IAAI,CAC9B,CAwFA,IAAM,EAA+B,GAAgB,CACnD,IAAM,EAAQ,OAAO,IAAI,CAAG,EAI5B,MAAO,CAAE,GAFG,GAA+B,OAAO,GAAU,YAAY,GAAkB,KAAU,EAEvF,MAHE,GAAc,OAAO,OAAO,EAAK,EAAG,GAAQ,EAAK,CAAC,CAG9C,CACrB,EAQM,EAAiB,EAA2B,eAAe,EAMpD,EAAyB,GACpC,EAAe,MAAM,CAAE,OAAM,CAAC,EAEnB,EAAoB,EAAe,GAS1C,EAAc,EAAwB,YAAY,EAM3C,EAAsB,GAA+C,EAAY,MAAM,CAAE,OAAM,CAAC,EAEhG,EAAiB,EAAY,GA2BpC,EAAkB,EAAsB,iBAAiB,EAElD,EAAe,EAAgB,GAE5C,SAAgB,EACd,EACA,EACY,CAUZ,OAAO,EAAgB,MAAM,CAAE,MAAO,EAAS,WAAU,OAT1C,EAAoB,EAAqB,IAAsD,CAC5G,IAAM,EAAQ,MAAM,KAAK,EAAS,UAAU,EAK5C,OAHA,EAAO,aAAa,EAAU,CAAM,EACpC,EAAQ,CAAe,EAEhB,CACT,CAE+D,CAAC,CAClE"}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Shared component phase and lifecycle event constants.\n * Extracted to a standalone module to break the circular dependency\n * between registration.ts and errors.ts.\n */\n\n// ─── ComponentPhase ───────────────────────────────────────────────────────────\n\nexport const ComponentPhase = {\n LOADING: 'loading',\n SETUP_DONE: 'setup_done',\n SETUP_RUNNING: 'setup_running',\n UNINITIALIZED: 'uninitialized',\n UNMOUNTED: 'unmounted',\n} as const;\n\nexport type ComponentPhase = (typeof ComponentPhase)[keyof typeof ComponentPhase];\n\n// ─── Lifecycle events ─────────────────────────────────────────────────────────\n\nexport const LIFECYCLE_EVENTS = {\n CONNECT: 'ore:connect',\n DISCONNECT: 'ore:disconnect',\n} as const;\n\nexport type LifecycleEventName = (typeof LIFECYCLE_EVENTS)[keyof typeof LIFECYCLE_EVENTS];\n"],"mappings":"AAQA,IAAa,EAAiB,CAC5B,QAAS,UACT,WAAY,aACZ,cAAe,gBACf,cAAe,gBACf,UAAW,WACb,EAMa,EAAmB,CAC9B,QAAS,cACT,WAAY,gBACd"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared component phase and lifecycle event constants.
|
|
3
|
+
* Extracted to a standalone module to break the circular dependency
|
|
4
|
+
* between registration.ts and errors.ts.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ComponentPhase: {
|
|
7
|
+
readonly LOADING: "loading";
|
|
8
|
+
readonly SETUP_DONE: "setup_done";
|
|
9
|
+
readonly SETUP_RUNNING: "setup_running";
|
|
10
|
+
readonly UNINITIALIZED: "uninitialized";
|
|
11
|
+
readonly UNMOUNTED: "unmounted";
|
|
12
|
+
};
|
|
13
|
+
export type ComponentPhase = (typeof ComponentPhase)[keyof typeof ComponentPhase];
|
|
14
|
+
export declare const LIFECYCLE_EVENTS: {
|
|
15
|
+
readonly CONNECT: "ore:connect";
|
|
16
|
+
readonly DISCONNECT: "ore:disconnect";
|
|
17
|
+
};
|
|
18
|
+
export type LifecycleEventName = (typeof LIFECYCLE_EVENTS)[keyof typeof LIFECYCLE_EVENTS];
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAIlF,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Shared component phase and lifecycle event constants.\n * Extracted to a standalone module to break the circular dependency\n * between registration.ts and errors.ts.\n */\n\n// ─── ComponentPhase ───────────────────────────────────────────────────────────\n\nexport const ComponentPhase = {\n LOADING: 'loading',\n SETUP_DONE: 'setup_done',\n SETUP_RUNNING: 'setup_running',\n UNINITIALIZED: 'uninitialized',\n UNMOUNTED: 'unmounted',\n} as const;\n\nexport type ComponentPhase = (typeof ComponentPhase)[keyof typeof ComponentPhase];\n\n// ─── Lifecycle events ─────────────────────────────────────────────────────────\n\nexport const LIFECYCLE_EVENTS = {\n CONNECT: 'ore:connect',\n DISCONNECT: 'ore:disconnect',\n} as const;\n\nexport type LifecycleEventName = (typeof LIFECYCLE_EVENTS)[keyof typeof LIFECYCLE_EVENTS];\n"],"mappings":"AAQA,IAAa,EAAiB,CAC5B,QAAS,UACT,WAAY,aACZ,cAAe,gBACf,cAAe,gBACf,UAAW,WACb,EAMa,EAAmB,CAC9B,QAAS,cACT,WAAY,gBACd"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:`aria-${e}`,t=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:e;exports.normalizeAriaKey=e,exports.normalizeHostAttrKey=t;
|
|
2
|
+
//# sourceMappingURL=aria.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.cjs","names":[],"sources":["../../src/utils/aria.ts"],"sourcesContent":["/**\n * Shared ARIA attribute key normalisation helpers.\n *\n * Two flavours are needed across the codebase:\n *\n * - `normalizeAriaKey` — always adds the `aria-` prefix for non-role keys.\n * Used by `syncAria()` where every config key is an ARIA attribute.\n *\n * - `normalizeHostAttrKey` — passes non-ARIA keys through unchanged.\n * Used by `host.bind({ attr: ... })` where keys may be arbitrary HTML attributes.\n */\n\n/** Normalise an aria config key to a full `aria-*` attribute name. */\nexport const normalizeAriaKey = (key: string): string => {\n if (key === 'role' || key.startsWith('aria-')) return key;\n\n // 'ariaLabel' → 'aria-label', 'expanded' → 'aria-expanded'\n return key.startsWith('aria') ? `aria-${key.slice(4).toLowerCase()}` : `aria-${key}`;\n};\n\n/** Normalise a host-bind attr key: aria-camelCase → aria-kebab-case; other keys pass through. */\nexport const normalizeHostAttrKey = (key: string): string => {\n if (key === 'role' || key.startsWith('aria-')) return key;\n\n // 'ariaLabel' → 'aria-label', other keys unchanged\n return key.startsWith('aria') ? `aria-${key.slice(4).toLowerCase()}` : key;\n};\n"],"mappings":"AAaA,IAAa,EAAoB,GAC3B,IAAQ,QAAU,EAAI,WAAW,OAAO,EAAU,EAG/C,EAAI,WAAW,MAAM,EAAI,QAAQ,EAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAM,QAAQ,IAIpE,EAAwB,GAC/B,IAAQ,QAAU,EAAI,WAAW,OAAO,EAAU,EAG/C,EAAI,WAAW,MAAM,EAAI,QAAQ,EAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAM"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ARIA attribute key normalisation helpers.
|
|
3
|
+
*
|
|
4
|
+
* Two flavours are needed across the codebase:
|
|
5
|
+
*
|
|
6
|
+
* - `normalizeAriaKey` — always adds the `aria-` prefix for non-role keys.
|
|
7
|
+
* Used by `syncAria()` where every config key is an ARIA attribute.
|
|
8
|
+
*
|
|
9
|
+
* - `normalizeHostAttrKey` — passes non-ARIA keys through unchanged.
|
|
10
|
+
* Used by `host.bind({ attr: ... })` where keys may be arbitrary HTML attributes.
|
|
11
|
+
*/
|
|
12
|
+
/** Normalise an aria config key to a full `aria-*` attribute name. */
|
|
13
|
+
export declare const normalizeAriaKey: (key: string) => string;
|
|
14
|
+
/** Normalise a host-bind attr key: aria-camelCase → aria-kebab-case; other keys pass through. */
|
|
15
|
+
export declare const normalizeHostAttrKey: (key: string) => string;
|
|
16
|
+
//# sourceMappingURL=aria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.d.ts","sourceRoot":"","sources":["../../src/utils/aria.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,MAK9C,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,MAKlD,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:`aria-${e}`,t=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:e;export{e as normalizeAriaKey,t as normalizeHostAttrKey};
|
|
2
|
+
//# sourceMappingURL=aria.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.js","names":[],"sources":["../../src/utils/aria.ts"],"sourcesContent":["/**\n * Shared ARIA attribute key normalisation helpers.\n *\n * Two flavours are needed across the codebase:\n *\n * - `normalizeAriaKey` — always adds the `aria-` prefix for non-role keys.\n * Used by `syncAria()` where every config key is an ARIA attribute.\n *\n * - `normalizeHostAttrKey` — passes non-ARIA keys through unchanged.\n * Used by `host.bind({ attr: ... })` where keys may be arbitrary HTML attributes.\n */\n\n/** Normalise an aria config key to a full `aria-*` attribute name. */\nexport const normalizeAriaKey = (key: string): string => {\n if (key === 'role' || key.startsWith('aria-')) return key;\n\n // 'ariaLabel' → 'aria-label', 'expanded' → 'aria-expanded'\n return key.startsWith('aria') ? `aria-${key.slice(4).toLowerCase()}` : `aria-${key}`;\n};\n\n/** Normalise a host-bind attr key: aria-camelCase → aria-kebab-case; other keys pass through. */\nexport const normalizeHostAttrKey = (key: string): string => {\n if (key === 'role' || key.startsWith('aria-')) return key;\n\n // 'ariaLabel' → 'aria-label', other keys unchanged\n return key.startsWith('aria') ? `aria-${key.slice(4).toLowerCase()}` : key;\n};\n"],"mappings":"AAaA,IAAa,EAAoB,GAC3B,IAAQ,QAAU,EAAI,WAAW,OAAO,EAAU,EAG/C,EAAI,WAAW,MAAM,EAAI,QAAQ,EAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAM,QAAQ,IAIpE,EAAwB,GAC/B,IAAQ,QAAU,EAAI,WAAW,OAAO,EAAU,EAG/C,EAAI,WAAW,MAAM,EAAI,QAAQ,EAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAM"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../_dev.cjs");var t=new WeakSet,n=e=>typeof e==`object`&&!!e&&t.has(e),r=function(){return this.content},i=(e,...i)=>{let a=``;for(let t=0;t<e.length;t++)if(a+=e[t],t<i.length){let e=i[t];a+=n(e)?e.content:String(e)}let o={content:a.trim(),toString:r};return t.add(o),o},a=new Map,o=()=>{a.clear()},s=t=>{if(t instanceof CSSStyleSheet)return t;let n=typeof t==`string`?t:t.content,r=a.get(n);if(r)return r;let i=new CSSStyleSheet;try{i.replaceSync(n)}catch(t){e.error(`Style sheet replace failed`,t)}return a.set(n,i),i};exports._clearStylesheetCache=o,exports.css=i,exports.isCssResult=n,exports.loadStylesheet=s;
|
|
2
|
+
//# sourceMappingURL=css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.cjs","names":[],"sources":["../../src/utils/css.ts"],"sourcesContent":["/**\n * CSS tagged template utility and CSSStyleSheet caching.\n */\n\nimport { error } from '../_dev';\n\nexport type CSSResult = {\n content: string;\n toString(): string;\n};\n\nconst cssResultBrand = new WeakSet<CSSResult>();\n\nexport const isCssResult = (value: unknown): value is CSSResult =>\n typeof value === 'object' && value !== null && cssResultBrand.has(value as CSSResult);\n\nconst cssResultToString = function (this: CSSResult): string {\n return this.content;\n};\n\nexport const css = (strings: TemplateStringsArray, ...values: Array<CSSResult | string | number>): CSSResult => {\n let content = '';\n\n for (let i = 0; i < strings.length; i++) {\n content += strings[i];\n\n if (i < values.length) {\n const v = values[i];\n\n content += isCssResult(v) ? v.content : String(v);\n }\n }\n\n const result: CSSResult = { content: content.trim(), toString: cssResultToString };\n\n cssResultBrand.add(result);\n\n return result;\n};\n\nconst stylesheetStringCache = new Map<string, CSSStyleSheet>();\n\n/** @internal Clear the stylesheet cache. Used for test isolation and HMR. */\nexport const _clearStylesheetCache = (): void => {\n stylesheetStringCache.clear();\n};\n\nexport const loadStylesheet = (style: string | CSSStyleSheet | CSSResult): CSSStyleSheet => {\n if (style instanceof CSSStyleSheet) return style;\n\n const cssText = typeof style === 'string' ? style : style.content;\n const cached = stylesheetStringCache.get(cssText);\n\n if (cached) return cached;\n\n const sheet = new CSSStyleSheet();\n\n try {\n sheet.replaceSync(cssText);\n } catch (err) {\n error('Style sheet replace failed', err);\n }\n\n stylesheetStringCache.set(cssText, sheet);\n\n return sheet;\n};\n"],"mappings":"+BAWA,IAAM,EAAiB,IAAI,QAEd,EAAe,GAC1B,OAAO,GAAU,YAAY,GAAkB,EAAe,IAAI,CAAkB,EAEhF,EAAoB,UAAmC,CAC3D,OAAO,KAAK,OACd,EAEa,GAAO,EAA+B,GAAG,IAA0D,CAC9G,IAAI,EAAU,GAEd,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAGlC,GAFA,GAAW,EAAQ,GAEf,EAAI,EAAO,OAAQ,CACrB,IAAM,EAAI,EAAO,GAEjB,GAAW,EAAY,CAAC,EAAI,EAAE,QAAU,OAAO,CAAC,CAClD,CAGF,IAAM,EAAoB,CAAE,QAAS,EAAQ,KAAK,EAAG,SAAU,CAAkB,EAIjF,OAFA,EAAe,IAAI,CAAM,EAElB,CACT,EAEM,EAAwB,IAAI,IAGrB,MAAoC,CAC/C,EAAsB,MAAM,CAC9B,EAEa,EAAkB,GAA6D,CAC1F,GAAI,aAAiB,cAAe,OAAO,EAE3C,IAAM,EAAU,OAAO,GAAU,SAAW,EAAQ,EAAM,QACpD,EAAS,EAAsB,IAAI,CAAO,EAEhD,GAAI,EAAQ,OAAO,EAEnB,IAAM,EAAQ,IAAI,cAElB,GAAI,CACF,EAAM,YAAY,CAAO,CAC3B,OAAS,EAAK,CACZ,EAAA,MAAM,6BAA8B,CAAG,CACzC,CAIA,OAFA,EAAsB,IAAI,EAAS,CAAK,EAEjC,CACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS tagged template utility and CSSStyleSheet caching.
|
|
3
|
+
*/
|
|
4
|
+
export type CSSResult = {
|
|
5
|
+
content: string;
|
|
6
|
+
toString(): string;
|
|
7
|
+
};
|
|
8
|
+
export declare const isCssResult: (value: unknown) => value is CSSResult;
|
|
9
|
+
export declare const css: (strings: TemplateStringsArray, ...values: Array<CSSResult | string | number>) => CSSResult;
|
|
10
|
+
export declare const loadStylesheet: (style: string | CSSStyleSheet | CSSResult) => CSSStyleSheet;
|
|
11
|
+
//# sourceMappingURL=css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/utils/css.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,IAAI,MAAM,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,SACiC,CAAC;AAMxF,eAAO,MAAM,GAAG,GAAI,SAAS,oBAAoB,EAAE,GAAG,QAAQ,KAAK,CAAC,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,KAAG,SAkBlG,CAAC;AASF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,aAAa,GAAG,SAAS,KAAG,aAmB1E,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{error as e}from"../_dev.js";var t=new WeakSet,n=e=>typeof e==`object`&&!!e&&t.has(e),r=function(){return this.content},i=(e,...i)=>{let a=``;for(let t=0;t<e.length;t++)if(a+=e[t],t<i.length){let e=i[t];a+=n(e)?e.content:String(e)}let o={content:a.trim(),toString:r};return t.add(o),o},a=new Map,o=()=>{a.clear()},s=t=>{if(t instanceof CSSStyleSheet)return t;let n=typeof t==`string`?t:t.content,r=a.get(n);if(r)return r;let i=new CSSStyleSheet;try{i.replaceSync(n)}catch(t){e(`Style sheet replace failed`,t)}return a.set(n,i),i};export{o as _clearStylesheetCache,i as css,n as isCssResult,s as loadStylesheet};
|
|
2
|
+
//# sourceMappingURL=css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.js","names":[],"sources":["../../src/utils/css.ts"],"sourcesContent":["/**\n * CSS tagged template utility and CSSStyleSheet caching.\n */\n\nimport { error } from '../_dev';\n\nexport type CSSResult = {\n content: string;\n toString(): string;\n};\n\nconst cssResultBrand = new WeakSet<CSSResult>();\n\nexport const isCssResult = (value: unknown): value is CSSResult =>\n typeof value === 'object' && value !== null && cssResultBrand.has(value as CSSResult);\n\nconst cssResultToString = function (this: CSSResult): string {\n return this.content;\n};\n\nexport const css = (strings: TemplateStringsArray, ...values: Array<CSSResult | string | number>): CSSResult => {\n let content = '';\n\n for (let i = 0; i < strings.length; i++) {\n content += strings[i];\n\n if (i < values.length) {\n const v = values[i];\n\n content += isCssResult(v) ? v.content : String(v);\n }\n }\n\n const result: CSSResult = { content: content.trim(), toString: cssResultToString };\n\n cssResultBrand.add(result);\n\n return result;\n};\n\nconst stylesheetStringCache = new Map<string, CSSStyleSheet>();\n\n/** @internal Clear the stylesheet cache. Used for test isolation and HMR. */\nexport const _clearStylesheetCache = (): void => {\n stylesheetStringCache.clear();\n};\n\nexport const loadStylesheet = (style: string | CSSStyleSheet | CSSResult): CSSStyleSheet => {\n if (style instanceof CSSStyleSheet) return style;\n\n const cssText = typeof style === 'string' ? style : style.content;\n const cached = stylesheetStringCache.get(cssText);\n\n if (cached) return cached;\n\n const sheet = new CSSStyleSheet();\n\n try {\n sheet.replaceSync(cssText);\n } catch (err) {\n error('Style sheet replace failed', err);\n }\n\n stylesheetStringCache.set(cssText, sheet);\n\n return sheet;\n};\n"],"mappings":"mCAWA,IAAM,EAAiB,IAAI,QAEd,EAAe,GAC1B,OAAO,GAAU,YAAY,GAAkB,EAAe,IAAI,CAAkB,EAEhF,EAAoB,UAAmC,CAC3D,OAAO,KAAK,OACd,EAEa,GAAO,EAA+B,GAAG,IAA0D,CAC9G,IAAI,EAAU,GAEd,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAGlC,GAFA,GAAW,EAAQ,GAEf,EAAI,EAAO,OAAQ,CACrB,IAAM,EAAI,EAAO,GAEjB,GAAW,EAAY,CAAC,EAAI,EAAE,QAAU,OAAO,CAAC,CAClD,CAGF,IAAM,EAAoB,CAAE,QAAS,EAAQ,KAAK,EAAG,SAAU,CAAkB,EAIjF,OAFA,EAAe,IAAI,CAAM,EAElB,CACT,EAEM,EAAwB,IAAI,IAGrB,MAAoC,CAC/C,EAAsB,MAAM,CAC9B,EAEa,EAAkB,GAA6D,CAC1F,GAAI,aAAiB,cAAe,OAAO,EAE3C,IAAM,EAAU,OAAO,GAAU,SAAW,EAAQ,EAAM,QACpD,EAAS,EAAsB,IAAI,CAAO,EAEhD,GAAI,EAAQ,OAAO,EAEnB,IAAM,EAAQ,IAAI,cAElB,GAAI,CACF,EAAM,YAAY,CAAO,CAC3B,OAAS,EAAK,CACZ,EAAM,6BAA8B,CAAG,CACzC,CAIA,OAFA,EAAsB,IAAI,EAAS,CAAK,EAEjC,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../_dev.cjs");var t=e=>{for(let t=e.length-1;t>=0;t--)e[t]()},n=e=>{for(let t of e)t.remove()},r=new Set([`action`,`cite`,`codebase`,`data`,`formaction`,`href`,`manifest`,`ping`,`poster`,`src`,`xlink:href`]),i=/^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i,a=(t,n,a)=>{let o=n.toLowerCase();if(/^on[a-z]/i.test(n)){e.warn(`Blocked setAttribute("${n}", ...) — inline event handler attributes are not supported. Use @${n.slice(2)} binding syntax instead.`),t.removeAttribute(n);return}if(o===`srcdoc`){e.warn(`Blocked setAttribute("srcdoc", ...) — "srcdoc" holds raw HTML, not a URL, and is not supported via attribute binding. Use raw() with a registered sanitizer if you need to inject trusted HTML.`),t.removeAttribute(n);return}if(a==null||a===!1){t.removeAttribute(n);return}let s=a===!0?`true`:String(a);if(r.has(o)&&i.test(s)){e.warn(`Blocked dangerous URL scheme in attribute "${n}". Only safe URLs are permitted in URL-accepting attributes.`),t.removeAttribute(n);return}t.setAttribute(n,s)},o=(e,t,n,r)=>{if(!e)return()=>{};let i=n;return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},s=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),c=e=>Array.isArray(e)||typeof e==`object`&&!!e;exports.isStructuredValue=c,exports.listen=o,exports.removeNodes=n,exports.runAll=t,exports.setAttr=a,exports.toKebab=s;
|
|
2
|
+
//# sourceMappingURL=dom.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.cjs","names":[],"sources":["../../src/utils/dom.ts"],"sourcesContent":["/**\n * Low-level DOM utilities used throughout the runtime and binding layers.\n */\n\nimport { warn } from '../_dev';\n\nexport const runAll = (fns: (() => void)[]): void => {\n for (let i = fns.length - 1; i >= 0; i--) fns[i]!();\n};\n\nexport const removeNodes = (nodes: Node[]): void => {\n for (const node of nodes) {\n (node as ChildNode).remove();\n }\n};\n\n/**\n * HTML attributes that accept URLs. Values bound to these attributes are\n * checked for dangerous schemes before being set.\n *\n * `srcdoc` is deliberately excluded: it holds raw HTML (not a URL), so scheme\n * checking doesn't apply — it's blocked unconditionally below, alongside `on*`.\n */\nconst URL_ATTRS = new Set([\n 'action',\n 'cite',\n 'codebase',\n 'data',\n 'formaction',\n 'href',\n 'manifest',\n 'ping',\n 'poster',\n 'src',\n 'xlink:href',\n]);\n\n/**\n * Schemes that execute JavaScript or can embed arbitrary HTML. Blocked\n * unconditionally in URL-accepting attributes.\n * Covers: javascript:, vbscript:, blob:, and data: variants that carry HTML/XML\n * or script-capable SVG. Plain data: image URIs (e.g. data:image/png) are\n * intentionally allowed.\n */\nconst DANGEROUS_SCHEME_RE =\n /^\\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\\/(?:html|svg\\+xml)|application\\/(?:xhtml|xml)))/i;\n\nexport const setAttr = (el: Element, name: string, val: unknown): void => {\n const lowerName = name.toLowerCase();\n\n if (/^on[a-z]/i.test(name)) {\n warn(\n `Blocked setAttribute(\"${name}\", ...) — inline event handler attributes are not supported. Use @${name.slice(2)} binding syntax instead.`,\n );\n el.removeAttribute(name);\n\n return;\n }\n\n if (lowerName === 'srcdoc') {\n warn(\n `Blocked setAttribute(\"srcdoc\", ...) — \"srcdoc\" holds raw HTML, not a URL, and is not supported via attribute binding. Use raw() with a registered sanitizer if you need to inject trusted HTML.`,\n );\n el.removeAttribute(name);\n\n return;\n }\n\n if (val == null || val === false) {\n el.removeAttribute(name);\n\n return;\n }\n\n const strVal = val === true ? 'true' : String(val);\n\n if (URL_ATTRS.has(lowerName) && DANGEROUS_SCHEME_RE.test(strVal)) {\n warn(\n `Blocked dangerous URL scheme in attribute \"${name}\". Only safe URLs are permitted in URL-accepting attributes.`,\n );\n el.removeAttribute(name);\n\n return;\n }\n\n el.setAttribute(name, strVal);\n};\n\nexport const listen = (\n el: EventTarget | null | undefined,\n name: string,\n handler: EventListener,\n options?: AddEventListenerOptions,\n): (() => void) => {\n if (!el) return () => {};\n\n const listener: EventListener = handler;\n\n el.addEventListener(name, listener, options);\n\n return () => el.removeEventListener(name, listener, options);\n};\n\nexport const toKebab = (str: string): string => str.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n\nexport const isStructuredValue = (value: unknown): value is object =>\n Array.isArray(value) || (typeof value === 'object' && value !== null);\n"],"mappings":"+BAMA,IAAa,EAAU,GAA8B,CACnD,IAAK,IAAI,EAAI,EAAI,OAAS,EAAG,GAAK,EAAG,IAAK,EAAI,EAAE,CAAE,CACpD,EAEa,EAAe,GAAwB,CAClD,IAAK,IAAM,KAAQ,EACjB,EAAoB,OAAO,CAE/B,EASM,EAAY,IAAI,IAAI,CACxB,SACA,OACA,WACA,OACA,aACA,OACA,WACA,OACA,SACA,MACA,YACF,CAAC,EASK,EACJ,sGAEW,GAAW,EAAa,EAAc,IAAuB,CACxE,IAAM,EAAY,EAAK,YAAY,EAEnC,GAAI,YAAY,KAAK,CAAI,EAAG,CAC1B,EAAA,KACE,yBAAyB,EAAK,oEAAoE,EAAK,MAAM,CAAC,EAAE,yBAClH,EACA,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,GAAI,IAAc,SAAU,CAC1B,EAAA,KACE,iMACF,EACA,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,GAAI,GAAO,MAAQ,IAAQ,GAAO,CAChC,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,IAAM,EAAS,IAAQ,GAAO,OAAS,OAAO,CAAG,EAEjD,GAAI,EAAU,IAAI,CAAS,GAAK,EAAoB,KAAK,CAAM,EAAG,CAChE,EAAA,KACE,8CAA8C,EAAK,6DACrD,EACA,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,EAAG,aAAa,EAAM,CAAM,CAC9B,EAEa,GACX,EACA,EACA,EACA,IACiB,CACjB,GAAI,CAAC,EAAI,UAAa,CAAC,EAEvB,IAAM,EAA0B,EAIhC,OAFA,EAAG,iBAAiB,EAAM,EAAU,CAAO,MAE9B,EAAG,oBAAoB,EAAM,EAAU,CAAO,CAC7D,EAEa,EAAW,GAAwB,EAAI,QAAQ,SAAW,GAAM,IAAI,EAAE,YAAY,GAAG,EAErF,EAAqB,GAChC,MAAM,QAAQ,CAAK,GAAM,OAAO,GAAU,YAAY"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level DOM utilities used throughout the runtime and binding layers.
|
|
3
|
+
*/
|
|
4
|
+
export declare const runAll: (fns: (() => void)[]) => void;
|
|
5
|
+
export declare const removeNodes: (nodes: Node[]) => void;
|
|
6
|
+
export declare const setAttr: (el: Element, name: string, val: unknown) => void;
|
|
7
|
+
export declare const listen: (el: EventTarget | null | undefined, name: string, handler: EventListener, options?: AddEventListenerOptions) => (() => void);
|
|
8
|
+
export declare const toKebab: (str: string) => string;
|
|
9
|
+
export declare const isStructuredValue: (value: unknown) => value is object;
|
|
10
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,MAAM,GAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,KAAG,IAE5C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,IAAI,EAAE,KAAG,IAI3C,CAAC;AAiCF,eAAO,MAAM,OAAO,GAAI,IAAI,OAAO,EAAE,MAAM,MAAM,EAAE,KAAK,OAAO,KAAG,IAuCjE,CAAC;AAEF,eAAO,MAAM,MAAM,GACjB,IAAI,WAAW,GAAG,IAAI,GAAG,SAAS,EAClC,MAAM,MAAM,EACZ,SAAS,aAAa,EACtB,UAAU,uBAAuB,KAChC,CAAC,MAAM,IAAI,CAQb,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAA6D,CAAC;AAEpG,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACW,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{warn as e}from"../_dev.js";var t=e=>{for(let t=e.length-1;t>=0;t--)e[t]()},n=e=>{for(let t of e)t.remove()},r=new Set([`action`,`cite`,`codebase`,`data`,`formaction`,`href`,`manifest`,`ping`,`poster`,`src`,`xlink:href`]),i=/^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i,a=(t,n,a)=>{let o=n.toLowerCase();if(/^on[a-z]/i.test(n)){e(`Blocked setAttribute("${n}", ...) — inline event handler attributes are not supported. Use @${n.slice(2)} binding syntax instead.`),t.removeAttribute(n);return}if(o===`srcdoc`){e(`Blocked setAttribute("srcdoc", ...) — "srcdoc" holds raw HTML, not a URL, and is not supported via attribute binding. Use raw() with a registered sanitizer if you need to inject trusted HTML.`),t.removeAttribute(n);return}if(a==null||a===!1){t.removeAttribute(n);return}let s=a===!0?`true`:String(a);if(r.has(o)&&i.test(s)){e(`Blocked dangerous URL scheme in attribute "${n}". Only safe URLs are permitted in URL-accepting attributes.`),t.removeAttribute(n);return}t.setAttribute(n,s)},o=(e,t,n,r)=>{if(!e)return()=>{};let i=n;return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},s=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),c=e=>Array.isArray(e)||typeof e==`object`&&!!e;export{c as isStructuredValue,o as listen,n as removeNodes,t as runAll,a as setAttr,s as toKebab};
|
|
2
|
+
//# sourceMappingURL=dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.js","names":[],"sources":["../../src/utils/dom.ts"],"sourcesContent":["/**\n * Low-level DOM utilities used throughout the runtime and binding layers.\n */\n\nimport { warn } from '../_dev';\n\nexport const runAll = (fns: (() => void)[]): void => {\n for (let i = fns.length - 1; i >= 0; i--) fns[i]!();\n};\n\nexport const removeNodes = (nodes: Node[]): void => {\n for (const node of nodes) {\n (node as ChildNode).remove();\n }\n};\n\n/**\n * HTML attributes that accept URLs. Values bound to these attributes are\n * checked for dangerous schemes before being set.\n *\n * `srcdoc` is deliberately excluded: it holds raw HTML (not a URL), so scheme\n * checking doesn't apply — it's blocked unconditionally below, alongside `on*`.\n */\nconst URL_ATTRS = new Set([\n 'action',\n 'cite',\n 'codebase',\n 'data',\n 'formaction',\n 'href',\n 'manifest',\n 'ping',\n 'poster',\n 'src',\n 'xlink:href',\n]);\n\n/**\n * Schemes that execute JavaScript or can embed arbitrary HTML. Blocked\n * unconditionally in URL-accepting attributes.\n * Covers: javascript:, vbscript:, blob:, and data: variants that carry HTML/XML\n * or script-capable SVG. Plain data: image URIs (e.g. data:image/png) are\n * intentionally allowed.\n */\nconst DANGEROUS_SCHEME_RE =\n /^\\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\\/(?:html|svg\\+xml)|application\\/(?:xhtml|xml)))/i;\n\nexport const setAttr = (el: Element, name: string, val: unknown): void => {\n const lowerName = name.toLowerCase();\n\n if (/^on[a-z]/i.test(name)) {\n warn(\n `Blocked setAttribute(\"${name}\", ...) — inline event handler attributes are not supported. Use @${name.slice(2)} binding syntax instead.`,\n );\n el.removeAttribute(name);\n\n return;\n }\n\n if (lowerName === 'srcdoc') {\n warn(\n `Blocked setAttribute(\"srcdoc\", ...) — \"srcdoc\" holds raw HTML, not a URL, and is not supported via attribute binding. Use raw() with a registered sanitizer if you need to inject trusted HTML.`,\n );\n el.removeAttribute(name);\n\n return;\n }\n\n if (val == null || val === false) {\n el.removeAttribute(name);\n\n return;\n }\n\n const strVal = val === true ? 'true' : String(val);\n\n if (URL_ATTRS.has(lowerName) && DANGEROUS_SCHEME_RE.test(strVal)) {\n warn(\n `Blocked dangerous URL scheme in attribute \"${name}\". Only safe URLs are permitted in URL-accepting attributes.`,\n );\n el.removeAttribute(name);\n\n return;\n }\n\n el.setAttribute(name, strVal);\n};\n\nexport const listen = (\n el: EventTarget | null | undefined,\n name: string,\n handler: EventListener,\n options?: AddEventListenerOptions,\n): (() => void) => {\n if (!el) return () => {};\n\n const listener: EventListener = handler;\n\n el.addEventListener(name, listener, options);\n\n return () => el.removeEventListener(name, listener, options);\n};\n\nexport const toKebab = (str: string): string => str.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n\nexport const isStructuredValue = (value: unknown): value is object =>\n Array.isArray(value) || (typeof value === 'object' && value !== null);\n"],"mappings":"kCAMA,IAAa,EAAU,GAA8B,CACnD,IAAK,IAAI,EAAI,EAAI,OAAS,EAAG,GAAK,EAAG,IAAK,EAAI,EAAE,CAAE,CACpD,EAEa,EAAe,GAAwB,CAClD,IAAK,IAAM,KAAQ,EACjB,EAAoB,OAAO,CAE/B,EASM,EAAY,IAAI,IAAI,CACxB,SACA,OACA,WACA,OACA,aACA,OACA,WACA,OACA,SACA,MACA,YACF,CAAC,EASK,EACJ,sGAEW,GAAW,EAAa,EAAc,IAAuB,CACxE,IAAM,EAAY,EAAK,YAAY,EAEnC,GAAI,YAAY,KAAK,CAAI,EAAG,CAC1B,EACE,yBAAyB,EAAK,oEAAoE,EAAK,MAAM,CAAC,EAAE,yBAClH,EACA,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,GAAI,IAAc,SAAU,CAC1B,EACE,iMACF,EACA,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,GAAI,GAAO,MAAQ,IAAQ,GAAO,CAChC,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,IAAM,EAAS,IAAQ,GAAO,OAAS,OAAO,CAAG,EAEjD,GAAI,EAAU,IAAI,CAAS,GAAK,EAAoB,KAAK,CAAM,EAAG,CAChE,EACE,8CAA8C,EAAK,6DACrD,EACA,EAAG,gBAAgB,CAAI,EAEvB,MACF,CAEA,EAAG,aAAa,EAAM,CAAM,CAC9B,EAEa,GACX,EACA,EACA,EACA,IACiB,CACjB,GAAI,CAAC,EAAI,UAAa,CAAC,EAEvB,IAAM,EAA0B,EAIhC,OAFA,EAAG,iBAAiB,EAAM,EAAU,CAAO,MAE9B,EAAG,oBAAoB,EAAM,EAAU,CAAO,CAC7D,EAEa,EAAW,GAAwB,EAAI,QAAQ,SAAW,GAAM,IAAI,EAAE,YAAY,GAAG,EAErF,EAAqB,GAChC,MAAM,QAAQ,CAAK,GAAM,OAAO,GAAU,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.cjs","names":[],"sources":["../../src/utils/emit.ts"],"sourcesContent":["/**\n * Type-safe custom event emission factory for components.\n */\n\ntype NoDetail = void | undefined | never;\ntype KeysWithoutDetail<T extends Record<string, unknown>> = {\n [P in keyof T]: [T[P]] extends [NoDetail] ? P : never;\n}[keyof T];\n\ntype StrictEmitFn<T extends Record<string, unknown>> = {\n <K extends KeysWithoutDetail<T>>(event: K): void;\n <K extends Exclude<keyof T, KeysWithoutDetail<T>>>(event: K, detail: T[K]): void;\n};\n\ntype LooseEmitFn = (event: string, detail?: unknown) => void;\n\nexport type EmitFn<T extends Record<string, unknown>> = StrictEmitFn<T> & LooseEmitFn;\n\nconst DEFAULT_FIRE_OPTIONS = { bubbles: true, cancelable: true, composed: false };\n\nexport const createEmitFn = <T extends Record<string, unknown>>(el: HTMLElement): EmitFn<T> => {\n return ((event: keyof T, ...rest: unknown[]) => {\n const customEventInit = rest.length > 0 ? { ...DEFAULT_FIRE_OPTIONS, detail: rest[0] } : DEFAULT_FIRE_OPTIONS;\n\n el.dispatchEvent(new CustomEvent<unknown>(String(event), customEventInit));\n }) as EmitFn<T>;\n};\n"],"mappings":"AAkBA,IAAM,EAAuB,CAAE,QAAS,GAAM,WAAY,GAAM,SAAU,EAAM,EAEnE,EAAmD,KACrD,EAAgB,GAAG,IAAoB,CAC9C,IAAM,EAAkB,EAAK,OAAS,EAAI,CAAE,GAAG,EAAsB,OAAQ,EAAK,EAAG,EAAI,EAEzF,EAAG,cAAc,IAAI,YAAqB,OAAO,CAAK,EAAG,CAAe,CAAC,CAC3E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe custom event emission factory for components.
|
|
3
|
+
*/
|
|
4
|
+
type NoDetail = void | undefined | never;
|
|
5
|
+
type KeysWithoutDetail<T extends Record<string, unknown>> = {
|
|
6
|
+
[P in keyof T]: [T[P]] extends [NoDetail] ? P : never;
|
|
7
|
+
}[keyof T];
|
|
8
|
+
type StrictEmitFn<T extends Record<string, unknown>> = {
|
|
9
|
+
<K extends KeysWithoutDetail<T>>(event: K): void;
|
|
10
|
+
<K extends Exclude<keyof T, KeysWithoutDetail<T>>>(event: K, detail: T[K]): void;
|
|
11
|
+
};
|
|
12
|
+
type LooseEmitFn = (event: string, detail?: unknown) => void;
|
|
13
|
+
export type EmitFn<T extends Record<string, unknown>> = StrictEmitFn<T> & LooseEmitFn;
|
|
14
|
+
export declare const createEmitFn: <T extends Record<string, unknown>>(el: HTMLElement) => EmitFn<T>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/utils/emit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,KAAK,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;AACzC,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KACzD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK;CACtD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACrD,CAAC,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACjD,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAClF,CAAC;AAEF,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAE7D,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;AAItF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,WAAW,KAAG,MAAM,CAAC,CAAC,CAMzF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.js","names":[],"sources":["../../src/utils/emit.ts"],"sourcesContent":["/**\n * Type-safe custom event emission factory for components.\n */\n\ntype NoDetail = void | undefined | never;\ntype KeysWithoutDetail<T extends Record<string, unknown>> = {\n [P in keyof T]: [T[P]] extends [NoDetail] ? P : never;\n}[keyof T];\n\ntype StrictEmitFn<T extends Record<string, unknown>> = {\n <K extends KeysWithoutDetail<T>>(event: K): void;\n <K extends Exclude<keyof T, KeysWithoutDetail<T>>>(event: K, detail: T[K]): void;\n};\n\ntype LooseEmitFn = (event: string, detail?: unknown) => void;\n\nexport type EmitFn<T extends Record<string, unknown>> = StrictEmitFn<T> & LooseEmitFn;\n\nconst DEFAULT_FIRE_OPTIONS = { bubbles: true, cancelable: true, composed: false };\n\nexport const createEmitFn = <T extends Record<string, unknown>>(el: HTMLElement): EmitFn<T> => {\n return ((event: keyof T, ...rest: unknown[]) => {\n const customEventInit = rest.length > 0 ? { ...DEFAULT_FIRE_OPTIONS, detail: rest[0] } : DEFAULT_FIRE_OPTIONS;\n\n el.dispatchEvent(new CustomEvent<unknown>(String(event), customEventInit));\n }) as EmitFn<T>;\n};\n"],"mappings":"AAkBA,IAAM,EAAuB,CAAE,QAAS,GAAM,WAAY,GAAM,SAAU,EAAM,EAEnE,EAAmD,KACrD,EAAgB,GAAG,IAAoB,CAC9C,IAAM,EAAkB,EAAK,OAAS,EAAI,CAAE,GAAG,EAAsB,OAAQ,EAAK,EAAG,EAAI,EAEzF,EAAG,cAAc,IAAI,YAAqB,OAAO,CAAK,EAAG,CAAe,CAAC,CAC3E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e={prevent:e=>t=>{t.preventDefault(),e(t)},self:e=>t=>{t.target===t.currentTarget&&e(t)},stop:e=>t=>{t.stopPropagation(),e(t)}},t=(t,n)=>{let r=t;for(let t of n){let n=e[t];n&&(r=n(r))}let i={};return n.includes(`capture`)&&(i.capture=!0),n.includes(`once`)&&(i.once=!0),n.includes(`passive`)&&(i.passive=!0),{handler:r,...Object.keys(i).length?{options:i}:{}}};exports.applyModifiers=t;
|
|
2
|
+
//# sourceMappingURL=event-modifiers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-modifiers.cjs","names":[],"sources":["../../src/utils/event-modifiers.ts"],"sourcesContent":["type EventHandler = (e: Event) => void;\n\nconst behaviorModifiers: Record<string, (h: EventHandler) => EventHandler> = {\n prevent: (h) => (e) => {\n e.preventDefault();\n h(e);\n },\n self: (h) => (e) => {\n if (e.target === e.currentTarget) h(e);\n },\n stop: (h) => (e) => {\n e.stopPropagation();\n h(e);\n },\n};\n\n/**\n * Apply event listener modifiers (prevent, stop, self, capture, once, passive).\n * Behavior modifiers wrap the handler; listener options are extracted separately.\n */\nexport const applyModifiers = (\n handler: EventHandler,\n modifiers: string[],\n): { handler: EventHandler; options?: AddEventListenerOptions } => {\n let wrappedHandler = handler;\n\n for (const modifier of modifiers) {\n const wrap = behaviorModifiers[modifier];\n\n if (wrap) wrappedHandler = wrap(wrappedHandler);\n }\n\n const options: AddEventListenerOptions = {};\n\n if (modifiers.includes('capture')) options.capture = true;\n\n if (modifiers.includes('once')) options.once = true;\n\n if (modifiers.includes('passive')) options.passive = true;\n\n return { handler: wrappedHandler, ...(Object.keys(options).length ? { options } : {}) };\n};\n"],"mappings":"AAEA,IAAM,EAAuE,CAC3E,QAAU,GAAO,GAAM,CACrB,EAAE,eAAe,EACjB,EAAE,CAAC,CACL,EACA,KAAO,GAAO,GAAM,CACd,EAAE,SAAW,EAAE,eAAe,EAAE,CAAC,CACvC,EACA,KAAO,GAAO,GAAM,CAClB,EAAE,gBAAgB,EAClB,EAAE,CAAC,CACL,CACF,EAMa,GACX,EACA,IACiE,CACjE,IAAI,EAAiB,EAErB,IAAK,IAAM,KAAY,EAAW,CAChC,IAAM,EAAO,EAAkB,GAE3B,IAAM,EAAiB,EAAK,CAAc,EAChD,CAEA,IAAM,EAAmC,CAAC,EAQ1C,OANI,EAAU,SAAS,SAAS,IAAG,EAAQ,QAAU,IAEjD,EAAU,SAAS,MAAM,IAAG,EAAQ,KAAO,IAE3C,EAAU,SAAS,SAAS,IAAG,EAAQ,QAAU,IAE9C,CAAE,QAAS,EAAgB,GAAI,OAAO,KAAK,CAAO,CAAC,CAAC,OAAS,CAAE,SAAQ,EAAI,CAAC,CAAG,CACxF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type EventHandler = (e: Event) => void;
|
|
2
|
+
/**
|
|
3
|
+
* Apply event listener modifiers (prevent, stop, self, capture, once, passive).
|
|
4
|
+
* Behavior modifiers wrap the handler; listener options are extracted separately.
|
|
5
|
+
*/
|
|
6
|
+
export declare const applyModifiers: (handler: EventHandler, modifiers: string[]) => {
|
|
7
|
+
handler: EventHandler;
|
|
8
|
+
options?: AddEventListenerOptions;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=event-modifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-modifiers.d.ts","sourceRoot":"","sources":["../../src/utils/event-modifiers.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;AAgBvC;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,YAAY,EACrB,WAAW,MAAM,EAAE,KAClB;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,OAAO,CAAC,EAAE,uBAAuB,CAAA;CAkB5D,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e={prevent:e=>t=>{t.preventDefault(),e(t)},self:e=>t=>{t.target===t.currentTarget&&e(t)},stop:e=>t=>{t.stopPropagation(),e(t)}},t=(t,n)=>{let r=t;for(let t of n){let n=e[t];n&&(r=n(r))}let i={};return n.includes(`capture`)&&(i.capture=!0),n.includes(`once`)&&(i.once=!0),n.includes(`passive`)&&(i.passive=!0),{handler:r,...Object.keys(i).length?{options:i}:{}}};export{t as applyModifiers};
|
|
2
|
+
//# sourceMappingURL=event-modifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-modifiers.js","names":[],"sources":["../../src/utils/event-modifiers.ts"],"sourcesContent":["type EventHandler = (e: Event) => void;\n\nconst behaviorModifiers: Record<string, (h: EventHandler) => EventHandler> = {\n prevent: (h) => (e) => {\n e.preventDefault();\n h(e);\n },\n self: (h) => (e) => {\n if (e.target === e.currentTarget) h(e);\n },\n stop: (h) => (e) => {\n e.stopPropagation();\n h(e);\n },\n};\n\n/**\n * Apply event listener modifiers (prevent, stop, self, capture, once, passive).\n * Behavior modifiers wrap the handler; listener options are extracted separately.\n */\nexport const applyModifiers = (\n handler: EventHandler,\n modifiers: string[],\n): { handler: EventHandler; options?: AddEventListenerOptions } => {\n let wrappedHandler = handler;\n\n for (const modifier of modifiers) {\n const wrap = behaviorModifiers[modifier];\n\n if (wrap) wrappedHandler = wrap(wrappedHandler);\n }\n\n const options: AddEventListenerOptions = {};\n\n if (modifiers.includes('capture')) options.capture = true;\n\n if (modifiers.includes('once')) options.once = true;\n\n if (modifiers.includes('passive')) options.passive = true;\n\n return { handler: wrappedHandler, ...(Object.keys(options).length ? { options } : {}) };\n};\n"],"mappings":"AAEA,IAAM,EAAuE,CAC3E,QAAU,GAAO,GAAM,CACrB,EAAE,eAAe,EACjB,EAAE,CAAC,CACL,EACA,KAAO,GAAO,GAAM,CACd,EAAE,SAAW,EAAE,eAAe,EAAE,CAAC,CACvC,EACA,KAAO,GAAO,GAAM,CAClB,EAAE,gBAAgB,EAClB,EAAE,CAAC,CACL,CACF,EAMa,GACX,EACA,IACiE,CACjE,IAAI,EAAiB,EAErB,IAAK,IAAM,KAAY,EAAW,CAChC,IAAM,EAAO,EAAkB,GAE3B,IAAM,EAAiB,EAAK,CAAc,EAChD,CAEA,IAAM,EAAmC,CAAC,EAQ1C,OANI,EAAU,SAAS,SAAS,IAAG,EAAQ,QAAU,IAEjD,EAAU,SAAS,MAAM,IAAG,EAAQ,KAAO,IAE3C,EAAU,SAAS,SAAS,IAAG,EAAQ,QAAU,IAE9C,CAAE,QAAS,EAAgB,GAAI,OAAO,KAAK,CAAO,CAAC,CAAC,OAAS,CAAE,SAAQ,EAAI,CAAC,CAAG,CACxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.cjs","names":[],"sources":["../../src/utils/id.ts"],"sourcesContent":["/**\n * Unique ID generation for runtime use (component IDs, label associations, etc.).\n * Template binding no longer uses this for marker IDs — binding targets are resolved\n * via path navigation on cloned template nodes.\n */\n\nlet _idCounter = 0;\nlet _stableCounter = 0;\nconst _tag = Math.random().toString(36).slice(2, 6);\n\n/** @internal Resets both ID counters. Called by testing cleanup(). */\nexport const _resetIdCounter = (): void => {\n _idCounter = 0;\n _stableCounter = 0;\n};\n\nexport const createId = (prefix = 'id'): string => `${prefix}-${++_idCounter}`;\n\n/**\n * Generates a stable, unique ID with an optional semantic prefix.\n * Includes a short random tag to prevent collisions across multiple app instances.\n * Format: `${prefix}-${tag}${counter}` — e.g. `field-a3k21`.\n */\nexport const createStableId = (prefix = 'id'): string => `${prefix}-${_tag}${++_stableCounter}`;\n\n/**\n * Resets the stable ID counter to 0. Use in test `beforeEach` hooks when you need\n * deterministic IDs across test runs.\n */\nexport const resetIdCounter = (): void => {\n _stableCounter = 0;\n};\n"],"mappings":"AAMA,IAAI,EAAa,EACb,EAAiB,EACf,EAAO,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAG,CAAC,EAGrC,MAA8B,CACzC,EAAa,EACb,EAAiB,CACnB,EAEa,GAAY,EAAS,OAAiB,GAAG,EAAO,GAAG,EAAE,IAOrD,GAAkB,EAAS,OAAiB,GAAG,EAAO,GAAG,IAAO,EAAE,IAMlE,MAA6B,CACxC,EAAiB,CACnB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique ID generation for runtime use (component IDs, label associations, etc.).
|
|
3
|
+
* Template binding no longer uses this for marker IDs — binding targets are resolved
|
|
4
|
+
* via path navigation on cloned template nodes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createId: (prefix?: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Generates a stable, unique ID with an optional semantic prefix.
|
|
9
|
+
* Includes a short random tag to prevent collisions across multiple app instances.
|
|
10
|
+
* Format: `${prefix}-${tag}${counter}` — e.g. `field-a3k21`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createStableId: (prefix?: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Resets the stable ID counter to 0. Use in test `beforeEach` hooks when you need
|
|
15
|
+
* deterministic IDs across test runs.
|
|
16
|
+
*/
|
|
17
|
+
export declare const resetIdCounter: () => void;
|
|
18
|
+
//# sourceMappingURL=id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,eAAO,MAAM,QAAQ,GAAI,eAAa,KAAG,MAAqC,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,eAAa,KAAG,MAAgD,CAAC;AAEhG;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAO,IAEjC,CAAC"}
|
package/dist/utils/id.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","names":[],"sources":["../../src/utils/id.ts"],"sourcesContent":["/**\n * Unique ID generation for runtime use (component IDs, label associations, etc.).\n * Template binding no longer uses this for marker IDs — binding targets are resolved\n * via path navigation on cloned template nodes.\n */\n\nlet _idCounter = 0;\nlet _stableCounter = 0;\nconst _tag = Math.random().toString(36).slice(2, 6);\n\n/** @internal Resets both ID counters. Called by testing cleanup(). */\nexport const _resetIdCounter = (): void => {\n _idCounter = 0;\n _stableCounter = 0;\n};\n\nexport const createId = (prefix = 'id'): string => `${prefix}-${++_idCounter}`;\n\n/**\n * Generates a stable, unique ID with an optional semantic prefix.\n * Includes a short random tag to prevent collisions across multiple app instances.\n * Format: `${prefix}-${tag}${counter}` — e.g. `field-a3k21`.\n */\nexport const createStableId = (prefix = 'id'): string => `${prefix}-${_tag}${++_stableCounter}`;\n\n/**\n * Resets the stable ID counter to 0. Use in test `beforeEach` hooks when you need\n * deterministic IDs across test runs.\n */\nexport const resetIdCounter = (): void => {\n _stableCounter = 0;\n};\n"],"mappings":"AAMA,IAAI,EAAa,EACb,EAAiB,EACf,EAAO,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAG,CAAC,EAGrC,MAA8B,CACzC,EAAa,EACb,EAAiB,CACnB,EAEa,GAAY,EAAS,OAAiB,GAAG,EAAO,GAAG,EAAE,IAOrD,GAAkB,EAAS,OAAiB,GAAG,EAAO,GAAG,IAAO,EAAE,IAMlE,MAA6B,CACxC,EAAiB,CACnB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vielzeug/ore",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Custom element authoring primitives — reactive templates, signals, slots, and automatic lifecycle management",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"source": "./src/index.ts",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./devtools": {
|
|
20
|
+
"source": "./src/devtools.ts",
|
|
21
|
+
"types": "./dist/devtools.d.ts",
|
|
22
|
+
"import": "./dist/devtools.js",
|
|
23
|
+
"require": "./dist/devtools.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./directives": {
|
|
26
|
+
"source": "./src/directives/index.ts",
|
|
27
|
+
"types": "./dist/directives/index.d.ts",
|
|
28
|
+
"import": "./dist/directives.js",
|
|
29
|
+
"require": "./dist/directives.cjs"
|
|
30
|
+
},
|
|
31
|
+
"./observers": {
|
|
32
|
+
"source": "./src/observers/index.ts",
|
|
33
|
+
"types": "./dist/observers/index.d.ts",
|
|
34
|
+
"import": "./dist/observers.js",
|
|
35
|
+
"require": "./dist/observers.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./testing": {
|
|
38
|
+
"source": "./src/testing/index.ts",
|
|
39
|
+
"types": "./dist/testing/index.d.ts",
|
|
40
|
+
"import": "./dist/testing.js",
|
|
41
|
+
"require": "./dist/testing.cjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "vite build && pnpm run build:bundle && pnpm run build:types",
|
|
46
|
+
"build:types": "tsc -p tsconfig.declarations.json",
|
|
47
|
+
"fix": "eslint --fix src",
|
|
48
|
+
"lint": "eslint src",
|
|
49
|
+
"prepublishOnly": "pnpm run build",
|
|
50
|
+
"preview": "vite preview",
|
|
51
|
+
"test": "vitest",
|
|
52
|
+
"build:bundle": "vite build --config vite.bundle.config.ts"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"registry": "https://registry.npmjs.org/"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@vielzeug/ripple": "workspace:*"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^26.1.0",
|
|
63
|
+
"jsdom": "^29.1.1",
|
|
64
|
+
"typescript": "~6.0.3",
|
|
65
|
+
"vite": "^8.1.3",
|
|
66
|
+
"vitest": "^4.1.9"
|
|
67
|
+
}
|
|
68
|
+
}
|