@vielzeug/ore 26.10.16 → 26.10.18
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/LICENSE +21 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/ore.cjs +2 -2
- package/dist/ore.cjs.map +1 -1
- package/dist/ore.iife.js +2 -2
- package/dist/ore.iife.js.map +1 -1
- package/dist/ore.js +115 -109
- package/dist/ore.js.map +1 -1
- package/dist/template/compiler.cjs +1 -1
- package/dist/template/compiler.cjs.map +1 -1
- package/dist/template/compiler.d.ts.map +1 -1
- package/dist/template/compiler.js +1 -1
- package/dist/template/compiler.js.map +1 -1
- package/dist/utils/dom.cjs +1 -1
- package/dist/utils/dom.cjs.map +1 -1
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/dom.js +1 -1
- package/dist/utils/dom.js.map +1 -1
- package/package.json +6 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Helmuth Saatkamp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/errors.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
require("./_dev.cjs");var e=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{},n=class extends e{},r=class extends e{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function i(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var a={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice: custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifierUnknown:(e,t)=>`@${e}.${t}: unknown event modifier "${t}". Supported: .stop, .prevent, .once, .capture`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}": listener not attached`,modelRequiresValueBinding:e=>`model(): "${e}" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${e}=\${model(sig)}, not ?${e}=\${model(sig)}.`,propBindingForbiddenName:e=>`html\`...\`: ".${e}" is a forbidden property-binding name (prototype pollution guard)`,propInvalidReflect:`Structured props cannot use reflect:true: use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
|
|
1
|
+
require("./_dev.cjs");var e=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{},n=class extends e{},r=class extends e{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function i(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var a={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice: custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifierUnknown:(e,t)=>`@${e}.${t}: unknown event modifier "${t}". Supported: .stop, .prevent, .once, .capture`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}": listener not attached`,modelRequiresValueBinding:e=>`model(): "${e}" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${e}=\${model(sig)}, not ?${e}=\${model(sig)}.`,propBindingForbiddenName:e=>`html\`...\`: ".${e}" is a forbidden property-binding name (prototype pollution guard)`,propBindingHtmlInjectionName:e=>`html\`...\`: ".${e}" parses raw HTML and is not a supported property binding. Sanitize untrusted content, then bind it with the unsafeHtml() directive.`,propInvalidReflect:`Structured props cannot use reflect:true: use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
|
|
2
2
|
`)}`};function o(e,t){if(!e)throw new n(a.invariantViolated(t))}exports.ORE_ERRORS=a,exports.OreApiError=t,exports.OreError=e,exports.OreInternalError=n,exports.OreLifecycleError=r,exports.invariant=o,exports.reportRuntimeError=i;
|
|
3
3
|
//# sourceMappingURL=errors.cjs.map
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":["error","OreError","message","opts","OreApiError","OreInternalError","OreLifecycleError","options","reportRuntimeError","error$1","target","ORE_ERRORS","tag","key","index","eventName","modifier","name","errors","invariant","condition"],"sources":["../src/errors.ts"],"sourcesContent":["import { error as logError } from './_dev';\n\n// ─── Error policy ─────────────────────────────────────────────────────────────\n// One rule for the whole package: decide by whose code failed and whether it\n// can continue, never ad hoc per call site:\n//\n// API misuse (wrong arguments, hook outside setup, duplicate define)\n// → throw `OreApiError`, immediately, every build.\n// User-authored code failing inside ore's execution (setup, onMounted,\n// onFormReset, each() reconciliation)\n// → wrap in `OreLifecycleError` and report via `reportRuntimeError()`\n// (`ore:error` DOM event + dev console) so other callbacks keep running.\n// Recoverable oddity (overwrite warnings, blocked attribute writes)\n// → dev `warn()`/`error()` and continue. Never swallow silently.\n// Internal impossibility (compiled template metadata out of sync)\n// → `invariant()` throws `OreInternalError`, every build.\n\n// ─── Structured error types ───────────────────────────────────────────────────\n\n/** Base class for all Ore errors. Use `instanceof OreError` to catch any Ore-originated error. */\nexport class OreError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when Ore API is called incorrectly (e.g. outside setup, duplicate define, invalid prop). */\nexport class OreApiError extends OreError {}\n\n/**\n * Thrown when an internal invariant fails: e.g. compiled template metadata no\n * longer matching the DOM it was cloned from. Distinct from `OreApiError`: this\n * is never the caller's fault, it signals a bug in ore itself. See `invariant()`.\n */\nexport class OreInternalError extends OreError {}\n\n/**\n * The phase in which a component error occurred.\n * - `'setup'`: synchronous setup() threw\n * - `'mounted'`: an onMounted callback threw\n * - `'form-reset'`: an onFormReset callback threw\n * - `'each-reconcile'`: `each()` failed to reconcile a list update (e.g. duplicate keys)\n */\nexport type OreErrorPhase = 'each-reconcile' | 'form-reset' | 'mounted' | 'setup';\n\n/**\n * Structured error thrown by the Ore runtime when component setup fails.\n * Provides component name and original cause for debugging.\n */\nexport class OreLifecycleError extends OreError {\n readonly component: string;\n readonly phase: OreErrorPhase;\n\n constructor(message: string, options: { cause: Error; component: string; phase: OreErrorPhase }) {\n super(message, { cause: options.cause });\n this.component = options.component;\n this.phase = options.phase;\n }\n}\n\n/**\n * Report a runtime error via the ore:error event and console.\n *\n * `target` only needs to be an `EventTarget` (not specifically an `HTMLElement`): component\n * lifecycle errors dispatch on the host element, but non-lifecycle failures (e.g. `each()`\n * reconciliation, which has no single \"component\" to attribute the error to) dispatch on\n * whatever live DOM node is available, such as the directive's own anchor `Comment`. Either way\n * the event still bubbles and crosses shadow boundaries (`composed: true`), so a listener on\n * `document`/`window` observes every report regardless of where it originated.\n *\n * The console log (via `_dev.ts`'s `error()`) is still dev-gated like the rest of the package's\n * console diagnostics, but the `ore:error` DOM event dispatch below is **not**: it fires in\n * every build, so consumers always have a way to observe runtime failures programmatically even\n * when console output is stripped in production.\n */\nexport function reportRuntimeError(error: OreLifecycleError, target: EventTarget): void {\n logError(`<${error.component}> lifecycle error (phase: ${error.phase}):`, error.cause);\n\n target.dispatchEvent(\n new CustomEvent('ore:error', {\n bubbles: true,\n composed: true,\n detail: error,\n }),\n );\n}\n\n// ─── Error message constants ─────────────────────────────────────────────────\n\nexport const ORE_ERRORS = {\n asyncSetupUnsupported: 'setup() must return an HTMLResult or null; use reactive state for asynchronous work',\n defineDuplicate: (tag: string): string => `define('${tag}') called twice: custom element already registered`,\n defineFieldRequiresFormAssociated: (tag: string): string =>\n `useField() requires define('${tag}', { formAssociated: true })`,\n defineRequiresTag: 'define() requires a tag name',\n eachDuplicateKey: (key: string, index: number): string => `each() received duplicate key \"${key}\" at index ${index}`,\n eventModifierUnknown: (eventName: string, modifier: string): string =>\n `@${eventName}.${modifier}: unknown event modifier \"${modifier}\". Supported: .stop, .prevent, .once, .capture`,\n injectStrictFailed: (key: string, tag: string): string => `injectStrict() could not resolve key \"${key}\" in <${tag}>`,\n invariantViolated: (message: string): string => `invariant violated: ${message}`,\n lifecycleOutsideSetup: 'Lifecycle hooks must be called during component setup',\n listenNullTarget: (eventName: string): string =>\n `listen() called with a null/undefined target for event \"${eventName}\": listener not attached`,\n modelRequiresValueBinding: (name: string): string =>\n `model(): \"${name}\" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${name}=\\${model(sig)}, not ?${name}=\\${model(sig)}.`,\n propBindingForbiddenName: (name: string): string =>\n `html\\`...\\`: \".${name}\" is a forbidden property-binding name (prototype pollution guard)`,\n propInvalidReflect: 'Structured props cannot use reflect:true: use prop.json() with reflect:false',\n templateInterpolationInTag:\n 'html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs',\n useFieldAlreadyCalled: (tag: string): string =>\n `useField() was already called on <${tag}>. Call it only once per component.`,\n validationFailed: (tag: string, errors: string[]): string => `Validation failed for <${tag}>:\\n${errors.join('\\n')}`,\n} as const;\n\n/**\n * Assert an internal invariant that must always hold: e.g. compiled template\n * metadata staying in sync with the DOM it was cloned from. A failed invariant\n * means a bug in ore itself, never user input, so it throws `OreInternalError`\n * unconditionally (every build, never gated like `_dev.ts`'s `warn()`).\n *\n * Narrowing caveat: `asserts condition` only narrows the exact expression\n * passed in. Assign to a local `const` first: `invariant(el.parentNode, msg)`\n * does not narrow later reads of `el.parentNode`.\n */\nexport function invariant(condition: unknown, message: string): asserts condition {\n if (!condition) throw new OreInternalError(ORE_ERRORS.invariantViolated(message));\n}\n"],"mappings":"A,sBAoBA,IAAaC,EAAb,cAA8B,KAAM,CAClC,YAAY,EAAiB,EAAqB,CAChD,MAAMC,EAASC,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGaC,EAAb,cAAiCH,CAAS,CAAC,EAO9BI,EAAb,cAAsCJ,CAAS,CAAC,EAenCK,EAAb,cAAuCL,CAAS,CAC9C,UACA,MAEA,YAAY,EAAiB,EAAoE,CAC/F,MAAMC,EAAS,CAAE,MAAOK,EAAQ,KAAM,CAAC,EACvC,KAAK,UAAYA,EAAQ,UACzB,KAAK,MAAQA,EAAQ,KACvB,CACF,EAiBA,SAAgBC,EAAmB,EAA0B,EAA2B,CAC7E,GAAIR,EAAM,UAAV,EAAgDA,EAAM,MAAtD,EAAiEA,EAAM,MAEhFU,EAAO,cACL,IAAI,YAAY,YAAa,CAC3B,QAAS,GACT,SAAU,GACV,OAAQV,CACV,CAAC,CACH,CACF,CAIA,IAAaW,EAAa,CACxB,sBAAuB,sFACvB,gBAAkB,GAAwB,WAAWC,EAAI,oDACzD,kCAAoC,GAClC,+BAA+BA,EAAI,8BACrC,kBAAmB,+BACnB,kBAAmB,EAAa,IAA0B,kCAAkCC,EAAI,aAAaC,IAC7G,sBAAuB,EAAmB,IACxC,IAAIC,EAAU,GAAGC,EAAS,4BAA4BA,EAAS,gDACjE,oBAAqB,EAAa,IAAwB,yCAAyCH,EAAI,QAAQD,EAAI,GACnH,kBAAoB,GAA4B,uBAAuBV,IACvE,sBAAuB,wDACvB,iBAAmB,GACjB,2DAA2Da,EAAU,0BACvE,0BAA4B,GAC1B,aAAaE,EAAK,yFAAyFA,EAAK,wBAAwBA,EAAK,kBAC/I,yBAA2B,GACzB,kBAAkBA,EAAK,oEACzB,mBAAoB,+EACpB,2BACE,uGACF,sBAAwB,GACtB,qCAAqCL,EAAI,qCAC3C,kBAAmB,EAAa,IAA6B,0BAA0BA,EAAI,MAAMM,EAAO,KAAK;CAAI,GACnH,EAYA,SAAgBC,EAAU,EAAoB,EAAoC,CAChF,GAAI,CAACC,EAAW,MAAM,IAAIf,EAAiBM,EAAW,kBAAkBT,CAAO,CAAC,CAClF,C"}
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":["error","OreError","message","opts","OreApiError","OreInternalError","OreLifecycleError","options","reportRuntimeError","error$1","target","ORE_ERRORS","tag","key","index","eventName","modifier","name","errors","invariant","condition"],"sources":["../src/errors.ts"],"sourcesContent":["import { error as logError } from './_dev';\n\n// ─── Error policy ─────────────────────────────────────────────────────────────\n// One rule for the whole package: decide by whose code failed and whether it\n// can continue, never ad hoc per call site:\n//\n// API misuse (wrong arguments, hook outside setup, duplicate define)\n// → throw `OreApiError`, immediately, every build.\n// User-authored code failing inside ore's execution (setup, onMounted,\n// onFormReset, each() reconciliation)\n// → wrap in `OreLifecycleError` and report via `reportRuntimeError()`\n// (`ore:error` DOM event + dev console) so other callbacks keep running.\n// Recoverable oddity (overwrite warnings, blocked attribute writes)\n// → dev `warn()`/`error()` and continue. Never swallow silently.\n// Internal impossibility (compiled template metadata out of sync)\n// → `invariant()` throws `OreInternalError`, every build.\n\n// ─── Structured error types ───────────────────────────────────────────────────\n\n/** Base class for all Ore errors. Use `instanceof OreError` to catch any Ore-originated error. */\nexport class OreError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when Ore API is called incorrectly (e.g. outside setup, duplicate define, invalid prop). */\nexport class OreApiError extends OreError {}\n\n/**\n * Thrown when an internal invariant fails: e.g. compiled template metadata no\n * longer matching the DOM it was cloned from. Distinct from `OreApiError`: this\n * is never the caller's fault, it signals a bug in ore itself. See `invariant()`.\n */\nexport class OreInternalError extends OreError {}\n\n/**\n * The phase in which a component error occurred.\n * - `'setup'`: synchronous setup() threw\n * - `'mounted'`: an onMounted callback threw\n * - `'form-reset'`: an onFormReset callback threw\n * - `'each-reconcile'`: `each()` failed to reconcile a list update (e.g. duplicate keys)\n */\nexport type OreErrorPhase = 'each-reconcile' | 'form-reset' | 'mounted' | 'setup';\n\n/**\n * Structured error thrown by the Ore runtime when component setup fails.\n * Provides component name and original cause for debugging.\n */\nexport class OreLifecycleError extends OreError {\n readonly component: string;\n readonly phase: OreErrorPhase;\n\n constructor(message: string, options: { cause: Error; component: string; phase: OreErrorPhase }) {\n super(message, { cause: options.cause });\n this.component = options.component;\n this.phase = options.phase;\n }\n}\n\n/**\n * Report a runtime error via the ore:error event and console.\n *\n * `target` only needs to be an `EventTarget` (not specifically an `HTMLElement`): component\n * lifecycle errors dispatch on the host element, but non-lifecycle failures (e.g. `each()`\n * reconciliation, which has no single \"component\" to attribute the error to) dispatch on\n * whatever live DOM node is available, such as the directive's own anchor `Comment`. Either way\n * the event still bubbles and crosses shadow boundaries (`composed: true`), so a listener on\n * `document`/`window` observes every report regardless of where it originated.\n *\n * The console log (via `_dev.ts`'s `error()`) is still dev-gated like the rest of the package's\n * console diagnostics, but the `ore:error` DOM event dispatch below is **not**: it fires in\n * every build, so consumers always have a way to observe runtime failures programmatically even\n * when console output is stripped in production.\n */\nexport function reportRuntimeError(error: OreLifecycleError, target: EventTarget): void {\n logError(`<${error.component}> lifecycle error (phase: ${error.phase}):`, error.cause);\n\n target.dispatchEvent(\n new CustomEvent('ore:error', {\n bubbles: true,\n composed: true,\n detail: error,\n }),\n );\n}\n\n// ─── Error message constants ─────────────────────────────────────────────────\n\nexport const ORE_ERRORS = {\n asyncSetupUnsupported: 'setup() must return an HTMLResult or null; use reactive state for asynchronous work',\n defineDuplicate: (tag: string): string => `define('${tag}') called twice: custom element already registered`,\n defineFieldRequiresFormAssociated: (tag: string): string =>\n `useField() requires define('${tag}', { formAssociated: true })`,\n defineRequiresTag: 'define() requires a tag name',\n eachDuplicateKey: (key: string, index: number): string => `each() received duplicate key \"${key}\" at index ${index}`,\n eventModifierUnknown: (eventName: string, modifier: string): string =>\n `@${eventName}.${modifier}: unknown event modifier \"${modifier}\". Supported: .stop, .prevent, .once, .capture`,\n injectStrictFailed: (key: string, tag: string): string => `injectStrict() could not resolve key \"${key}\" in <${tag}>`,\n invariantViolated: (message: string): string => `invariant violated: ${message}`,\n lifecycleOutsideSetup: 'Lifecycle hooks must be called during component setup',\n listenNullTarget: (eventName: string): string =>\n `listen() called with a null/undefined target for event \"${eventName}\": listener not attached`,\n modelRequiresValueBinding: (name: string): string =>\n `model(): \"${name}\" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${name}=\\${model(sig)}, not ?${name}=\\${model(sig)}.`,\n propBindingForbiddenName: (name: string): string =>\n `html\\`...\\`: \".${name}\" is a forbidden property-binding name (prototype pollution guard)`,\n propBindingHtmlInjectionName: (name: string): string =>\n `html\\`...\\`: \".${name}\" parses raw HTML and is not a supported property binding. Sanitize untrusted content, then bind it with the unsafeHtml() directive.`,\n propInvalidReflect: 'Structured props cannot use reflect:true: use prop.json() with reflect:false',\n templateInterpolationInTag:\n 'html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs',\n useFieldAlreadyCalled: (tag: string): string =>\n `useField() was already called on <${tag}>. Call it only once per component.`,\n validationFailed: (tag: string, errors: string[]): string => `Validation failed for <${tag}>:\\n${errors.join('\\n')}`,\n} as const;\n\n/**\n * Assert an internal invariant that must always hold: e.g. compiled template\n * metadata staying in sync with the DOM it was cloned from. A failed invariant\n * means a bug in ore itself, never user input, so it throws `OreInternalError`\n * unconditionally (every build, never gated like `_dev.ts`'s `warn()`).\n *\n * Narrowing caveat: `asserts condition` only narrows the exact expression\n * passed in. Assign to a local `const` first: `invariant(el.parentNode, msg)`\n * does not narrow later reads of `el.parentNode`.\n */\nexport function invariant(condition: unknown, message: string): asserts condition {\n if (!condition) throw new OreInternalError(ORE_ERRORS.invariantViolated(message));\n}\n"],"mappings":"A,sBAoBA,IAAaC,EAAb,cAA8B,KAAM,CAClC,YAAY,EAAiB,EAAqB,CAChD,MAAMC,EAASC,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGaC,EAAb,cAAiCH,CAAS,CAAC,EAO9BI,EAAb,cAAsCJ,CAAS,CAAC,EAenCK,EAAb,cAAuCL,CAAS,CAC9C,UACA,MAEA,YAAY,EAAiB,EAAoE,CAC/F,MAAMC,EAAS,CAAE,MAAOK,EAAQ,KAAM,CAAC,EACvC,KAAK,UAAYA,EAAQ,UACzB,KAAK,MAAQA,EAAQ,KACvB,CACF,EAiBA,SAAgBC,EAAmB,EAA0B,EAA2B,CAC7E,GAAIR,EAAM,UAAV,EAAgDA,EAAM,MAAtD,EAAiEA,EAAM,MAEhFU,EAAO,cACL,IAAI,YAAY,YAAa,CAC3B,QAAS,GACT,SAAU,GACV,OAAQV,CACV,CAAC,CACH,CACF,CAIA,IAAaW,EAAa,CACxB,sBAAuB,sFACvB,gBAAkB,GAAwB,WAAWC,EAAI,oDACzD,kCAAoC,GAClC,+BAA+BA,EAAI,8BACrC,kBAAmB,+BACnB,kBAAmB,EAAa,IAA0B,kCAAkCC,EAAI,aAAaC,IAC7G,sBAAuB,EAAmB,IACxC,IAAIC,EAAU,GAAGC,EAAS,4BAA4BA,EAAS,gDACjE,oBAAqB,EAAa,IAAwB,yCAAyCH,EAAI,QAAQD,EAAI,GACnH,kBAAoB,GAA4B,uBAAuBV,IACvE,sBAAuB,wDACvB,iBAAmB,GACjB,2DAA2Da,EAAU,0BACvE,0BAA4B,GAC1B,aAAaE,EAAK,yFAAyFA,EAAK,wBAAwBA,EAAK,kBAC/I,yBAA2B,GACzB,kBAAkBA,EAAK,oEACzB,6BAA+B,GAC7B,kBAAkBA,EAAK,sIACzB,mBAAoB,+EACpB,2BACE,uGACF,sBAAwB,GACtB,qCAAqCL,EAAI,qCAC3C,kBAAmB,EAAa,IAA6B,0BAA0BA,EAAI,MAAMM,EAAO,KAAK;CAAI,GACnH,EAYA,SAAgBC,EAAU,EAAoB,EAAoC,CAChF,GAAI,CAACC,EAAW,MAAM,IAAIf,EAAiBM,EAAW,kBAAkBT,CAAO,CAAC,CAClF,C"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare const ORE_ERRORS: {
|
|
|
62
62
|
readonly listenNullTarget: (eventName: string) => string;
|
|
63
63
|
readonly modelRequiresValueBinding: (name: string) => string;
|
|
64
64
|
readonly propBindingForbiddenName: (name: string) => string;
|
|
65
|
+
readonly propBindingHtmlInjectionName: (name: string) => string;
|
|
65
66
|
readonly propInvalidReflect: "Structured props cannot use reflect:true: use prop.json() with reflect:false";
|
|
66
67
|
readonly templateInterpolationInTag: "html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs";
|
|
67
68
|
readonly useFieldAlreadyCalled: (tag: string) => string;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAmBA,kGAAkG;AAClG,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;CAKjD;AAED,sGAAsG;AACtG,qBAAa,WAAY,SAAQ,QAAQ;CAAG;AAE5C;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;CAAG;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAElF;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,CAAA;KAAE;CAKhG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAUtF;AAID,eAAO,MAAM,UAAU;;oCAEE,MAAM,KAAG,MAAM;sDACG,MAAM,KAAG,MAAM;;qCAGhC,MAAM,SAAS,MAAM,KAAG,MAAM;+CACpB,MAAM,YAAY,MAAM,KAAG,MAAM;uCAEzC,MAAM,OAAO,MAAM,KAAG,MAAM;0CACzB,MAAM,KAAG,MAAM;;2CAEd,MAAM,KAAG,MAAM;+CAEX,MAAM,KAAG,MAAM;8CAEhB,MAAM,KAAG,MAAM;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAmBA,kGAAkG;AAClG,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;CAKjD;AAED,sGAAsG;AACtG,qBAAa,WAAY,SAAQ,QAAQ;CAAG;AAE5C;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;CAAG;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAElF;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,CAAA;KAAE;CAKhG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAUtF;AAID,eAAO,MAAM,UAAU;;oCAEE,MAAM,KAAG,MAAM;sDACG,MAAM,KAAG,MAAM;;qCAGhC,MAAM,SAAS,MAAM,KAAG,MAAM;+CACpB,MAAM,YAAY,MAAM,KAAG,MAAM;uCAEzC,MAAM,OAAO,MAAM,KAAG,MAAM;0CACzB,MAAM,KAAG,MAAM;;2CAEd,MAAM,KAAG,MAAM;+CAEX,MAAM,KAAG,MAAM;8CAEhB,MAAM,KAAG,MAAM;kDAEX,MAAM,KAAG,MAAM;;;0CAKvB,MAAM,KAAG,MAAM;qCAEpB,MAAM,UAAU,MAAM,EAAE,KAAG,MAAM;CACjD,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAEhF"}
|
package/dist/errors.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./_dev.js";var e=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{},n=class extends e{},r=class extends e{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function i(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var a={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice: custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifierUnknown:(e,t)=>`@${e}.${t}: unknown event modifier "${t}". Supported: .stop, .prevent, .once, .capture`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}": listener not attached`,modelRequiresValueBinding:e=>`model(): "${e}" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${e}=\${model(sig)}, not ?${e}=\${model(sig)}.`,propBindingForbiddenName:e=>`html\`...\`: ".${e}" is a forbidden property-binding name (prototype pollution guard)`,propInvalidReflect:`Structured props cannot use reflect:true: use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
|
|
1
|
+
import"./_dev.js";var e=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{},n=class extends e{},r=class extends e{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function i(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var a={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice: custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifierUnknown:(e,t)=>`@${e}.${t}: unknown event modifier "${t}". Supported: .stop, .prevent, .once, .capture`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}": listener not attached`,modelRequiresValueBinding:e=>`model(): "${e}" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${e}=\${model(sig)}, not ?${e}=\${model(sig)}.`,propBindingForbiddenName:e=>`html\`...\`: ".${e}" is a forbidden property-binding name (prototype pollution guard)`,propBindingHtmlInjectionName:e=>`html\`...\`: ".${e}" parses raw HTML and is not a supported property binding. Sanitize untrusted content, then bind it with the unsafeHtml() directive.`,propInvalidReflect:`Structured props cannot use reflect:true: use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
|
|
2
2
|
`)}`};function o(e,t){if(!e)throw new n(a.invariantViolated(t))}export{a as ORE_ERRORS,t as OreApiError,e as OreError,n as OreInternalError,r as OreLifecycleError,o as invariant,i as reportRuntimeError};
|
|
3
3
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":["error","OreError","message","opts","OreApiError","OreInternalError","OreLifecycleError","options","reportRuntimeError","error$1","target","ORE_ERRORS","tag","key","index","eventName","modifier","name","errors","invariant","condition"],"sources":["../src/errors.ts"],"sourcesContent":["import { error as logError } from './_dev';\n\n// ─── Error policy ─────────────────────────────────────────────────────────────\n// One rule for the whole package: decide by whose code failed and whether it\n// can continue, never ad hoc per call site:\n//\n// API misuse (wrong arguments, hook outside setup, duplicate define)\n// → throw `OreApiError`, immediately, every build.\n// User-authored code failing inside ore's execution (setup, onMounted,\n// onFormReset, each() reconciliation)\n// → wrap in `OreLifecycleError` and report via `reportRuntimeError()`\n// (`ore:error` DOM event + dev console) so other callbacks keep running.\n// Recoverable oddity (overwrite warnings, blocked attribute writes)\n// → dev `warn()`/`error()` and continue. Never swallow silently.\n// Internal impossibility (compiled template metadata out of sync)\n// → `invariant()` throws `OreInternalError`, every build.\n\n// ─── Structured error types ───────────────────────────────────────────────────\n\n/** Base class for all Ore errors. Use `instanceof OreError` to catch any Ore-originated error. */\nexport class OreError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when Ore API is called incorrectly (e.g. outside setup, duplicate define, invalid prop). */\nexport class OreApiError extends OreError {}\n\n/**\n * Thrown when an internal invariant fails: e.g. compiled template metadata no\n * longer matching the DOM it was cloned from. Distinct from `OreApiError`: this\n * is never the caller's fault, it signals a bug in ore itself. See `invariant()`.\n */\nexport class OreInternalError extends OreError {}\n\n/**\n * The phase in which a component error occurred.\n * - `'setup'`: synchronous setup() threw\n * - `'mounted'`: an onMounted callback threw\n * - `'form-reset'`: an onFormReset callback threw\n * - `'each-reconcile'`: `each()` failed to reconcile a list update (e.g. duplicate keys)\n */\nexport type OreErrorPhase = 'each-reconcile' | 'form-reset' | 'mounted' | 'setup';\n\n/**\n * Structured error thrown by the Ore runtime when component setup fails.\n * Provides component name and original cause for debugging.\n */\nexport class OreLifecycleError extends OreError {\n readonly component: string;\n readonly phase: OreErrorPhase;\n\n constructor(message: string, options: { cause: Error; component: string; phase: OreErrorPhase }) {\n super(message, { cause: options.cause });\n this.component = options.component;\n this.phase = options.phase;\n }\n}\n\n/**\n * Report a runtime error via the ore:error event and console.\n *\n * `target` only needs to be an `EventTarget` (not specifically an `HTMLElement`): component\n * lifecycle errors dispatch on the host element, but non-lifecycle failures (e.g. `each()`\n * reconciliation, which has no single \"component\" to attribute the error to) dispatch on\n * whatever live DOM node is available, such as the directive's own anchor `Comment`. Either way\n * the event still bubbles and crosses shadow boundaries (`composed: true`), so a listener on\n * `document`/`window` observes every report regardless of where it originated.\n *\n * The console log (via `_dev.ts`'s `error()`) is still dev-gated like the rest of the package's\n * console diagnostics, but the `ore:error` DOM event dispatch below is **not**: it fires in\n * every build, so consumers always have a way to observe runtime failures programmatically even\n * when console output is stripped in production.\n */\nexport function reportRuntimeError(error: OreLifecycleError, target: EventTarget): void {\n logError(`<${error.component}> lifecycle error (phase: ${error.phase}):`, error.cause);\n\n target.dispatchEvent(\n new CustomEvent('ore:error', {\n bubbles: true,\n composed: true,\n detail: error,\n }),\n );\n}\n\n// ─── Error message constants ─────────────────────────────────────────────────\n\nexport const ORE_ERRORS = {\n asyncSetupUnsupported: 'setup() must return an HTMLResult or null; use reactive state for asynchronous work',\n defineDuplicate: (tag: string): string => `define('${tag}') called twice: custom element already registered`,\n defineFieldRequiresFormAssociated: (tag: string): string =>\n `useField() requires define('${tag}', { formAssociated: true })`,\n defineRequiresTag: 'define() requires a tag name',\n eachDuplicateKey: (key: string, index: number): string => `each() received duplicate key \"${key}\" at index ${index}`,\n eventModifierUnknown: (eventName: string, modifier: string): string =>\n `@${eventName}.${modifier}: unknown event modifier \"${modifier}\". Supported: .stop, .prevent, .once, .capture`,\n injectStrictFailed: (key: string, tag: string): string => `injectStrict() could not resolve key \"${key}\" in <${tag}>`,\n invariantViolated: (message: string): string => `invariant violated: ${message}`,\n lifecycleOutsideSetup: 'Lifecycle hooks must be called during component setup',\n listenNullTarget: (eventName: string): string =>\n `listen() called with a null/undefined target for event \"${eventName}\": listener not attached`,\n modelRequiresValueBinding: (name: string): string =>\n `model(): \"${name}\" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${name}=\\${model(sig)}, not ?${name}=\\${model(sig)}.`,\n propBindingForbiddenName: (name: string): string =>\n `html\\`...\\`: \".${name}\" is a forbidden property-binding name (prototype pollution guard)`,\n propInvalidReflect: 'Structured props cannot use reflect:true: use prop.json() with reflect:false',\n templateInterpolationInTag:\n 'html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs',\n useFieldAlreadyCalled: (tag: string): string =>\n `useField() was already called on <${tag}>. Call it only once per component.`,\n validationFailed: (tag: string, errors: string[]): string => `Validation failed for <${tag}>:\\n${errors.join('\\n')}`,\n} as const;\n\n/**\n * Assert an internal invariant that must always hold: e.g. compiled template\n * metadata staying in sync with the DOM it was cloned from. A failed invariant\n * means a bug in ore itself, never user input, so it throws `OreInternalError`\n * unconditionally (every build, never gated like `_dev.ts`'s `warn()`).\n *\n * Narrowing caveat: `asserts condition` only narrows the exact expression\n * passed in. Assign to a local `const` first: `invariant(el.parentNode, msg)`\n * does not narrow later reads of `el.parentNode`.\n */\nexport function invariant(condition: unknown, message: string): asserts condition {\n if (!condition) throw new OreInternalError(ORE_ERRORS.invariantViolated(message));\n}\n"],"mappings":"A,kBAoBA,IAAaC,EAAb,cAA8B,KAAM,CAClC,YAAY,EAAiB,EAAqB,CAChD,MAAMC,EAASC,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGaC,EAAb,cAAiCH,CAAS,CAAC,EAO9BI,EAAb,cAAsCJ,CAAS,CAAC,EAenCK,EAAb,cAAuCL,CAAS,CAC9C,UACA,MAEA,YAAY,EAAiB,EAAoE,CAC/F,MAAMC,EAAS,CAAE,MAAOK,EAAQ,KAAM,CAAC,EACvC,KAAK,UAAYA,EAAQ,UACzB,KAAK,MAAQA,EAAQ,KACvB,CACF,EAiBA,SAAgBC,EAAmB,EAA0B,EAA2B,CAC7E,GAAIR,EAAM,UAAV,EAAgDA,EAAM,MAAtD,EAAiEA,EAAM,MAEhFU,EAAO,cACL,IAAI,YAAY,YAAa,CAC3B,QAAS,GACT,SAAU,GACV,OAAQV,CACV,CAAC,CACH,CACF,CAIA,IAAaW,EAAa,CACxB,sBAAuB,sFACvB,gBAAkB,GAAwB,WAAWC,EAAI,oDACzD,kCAAoC,GAClC,+BAA+BA,EAAI,8BACrC,kBAAmB,+BACnB,kBAAmB,EAAa,IAA0B,kCAAkCC,EAAI,aAAaC,IAC7G,sBAAuB,EAAmB,IACxC,IAAIC,EAAU,GAAGC,EAAS,4BAA4BA,EAAS,gDACjE,oBAAqB,EAAa,IAAwB,yCAAyCH,EAAI,QAAQD,EAAI,GACnH,kBAAoB,GAA4B,uBAAuBV,IACvE,sBAAuB,wDACvB,iBAAmB,GACjB,2DAA2Da,EAAU,0BACvE,0BAA4B,GAC1B,aAAaE,EAAK,yFAAyFA,EAAK,wBAAwBA,EAAK,kBAC/I,yBAA2B,GACzB,kBAAkBA,EAAK,oEACzB,mBAAoB,+EACpB,2BACE,uGACF,sBAAwB,GACtB,qCAAqCL,EAAI,qCAC3C,kBAAmB,EAAa,IAA6B,0BAA0BA,EAAI,MAAMM,EAAO,KAAK;CAAI,GACnH,EAYA,SAAgBC,EAAU,EAAoB,EAAoC,CAChF,GAAI,CAACC,EAAW,MAAM,IAAIf,EAAiBM,EAAW,kBAAkBT,CAAO,CAAC,CAClF,C"}
|
|
1
|
+
{"version":3,"file":"errors.js","names":["error","OreError","message","opts","OreApiError","OreInternalError","OreLifecycleError","options","reportRuntimeError","error$1","target","ORE_ERRORS","tag","key","index","eventName","modifier","name","errors","invariant","condition"],"sources":["../src/errors.ts"],"sourcesContent":["import { error as logError } from './_dev';\n\n// ─── Error policy ─────────────────────────────────────────────────────────────\n// One rule for the whole package: decide by whose code failed and whether it\n// can continue, never ad hoc per call site:\n//\n// API misuse (wrong arguments, hook outside setup, duplicate define)\n// → throw `OreApiError`, immediately, every build.\n// User-authored code failing inside ore's execution (setup, onMounted,\n// onFormReset, each() reconciliation)\n// → wrap in `OreLifecycleError` and report via `reportRuntimeError()`\n// (`ore:error` DOM event + dev console) so other callbacks keep running.\n// Recoverable oddity (overwrite warnings, blocked attribute writes)\n// → dev `warn()`/`error()` and continue. Never swallow silently.\n// Internal impossibility (compiled template metadata out of sync)\n// → `invariant()` throws `OreInternalError`, every build.\n\n// ─── Structured error types ───────────────────────────────────────────────────\n\n/** Base class for all Ore errors. Use `instanceof OreError` to catch any Ore-originated error. */\nexport class OreError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when Ore API is called incorrectly (e.g. outside setup, duplicate define, invalid prop). */\nexport class OreApiError extends OreError {}\n\n/**\n * Thrown when an internal invariant fails: e.g. compiled template metadata no\n * longer matching the DOM it was cloned from. Distinct from `OreApiError`: this\n * is never the caller's fault, it signals a bug in ore itself. See `invariant()`.\n */\nexport class OreInternalError extends OreError {}\n\n/**\n * The phase in which a component error occurred.\n * - `'setup'`: synchronous setup() threw\n * - `'mounted'`: an onMounted callback threw\n * - `'form-reset'`: an onFormReset callback threw\n * - `'each-reconcile'`: `each()` failed to reconcile a list update (e.g. duplicate keys)\n */\nexport type OreErrorPhase = 'each-reconcile' | 'form-reset' | 'mounted' | 'setup';\n\n/**\n * Structured error thrown by the Ore runtime when component setup fails.\n * Provides component name and original cause for debugging.\n */\nexport class OreLifecycleError extends OreError {\n readonly component: string;\n readonly phase: OreErrorPhase;\n\n constructor(message: string, options: { cause: Error; component: string; phase: OreErrorPhase }) {\n super(message, { cause: options.cause });\n this.component = options.component;\n this.phase = options.phase;\n }\n}\n\n/**\n * Report a runtime error via the ore:error event and console.\n *\n * `target` only needs to be an `EventTarget` (not specifically an `HTMLElement`): component\n * lifecycle errors dispatch on the host element, but non-lifecycle failures (e.g. `each()`\n * reconciliation, which has no single \"component\" to attribute the error to) dispatch on\n * whatever live DOM node is available, such as the directive's own anchor `Comment`. Either way\n * the event still bubbles and crosses shadow boundaries (`composed: true`), so a listener on\n * `document`/`window` observes every report regardless of where it originated.\n *\n * The console log (via `_dev.ts`'s `error()`) is still dev-gated like the rest of the package's\n * console diagnostics, but the `ore:error` DOM event dispatch below is **not**: it fires in\n * every build, so consumers always have a way to observe runtime failures programmatically even\n * when console output is stripped in production.\n */\nexport function reportRuntimeError(error: OreLifecycleError, target: EventTarget): void {\n logError(`<${error.component}> lifecycle error (phase: ${error.phase}):`, error.cause);\n\n target.dispatchEvent(\n new CustomEvent('ore:error', {\n bubbles: true,\n composed: true,\n detail: error,\n }),\n );\n}\n\n// ─── Error message constants ─────────────────────────────────────────────────\n\nexport const ORE_ERRORS = {\n asyncSetupUnsupported: 'setup() must return an HTMLResult or null; use reactive state for asynchronous work',\n defineDuplicate: (tag: string): string => `define('${tag}') called twice: custom element already registered`,\n defineFieldRequiresFormAssociated: (tag: string): string =>\n `useField() requires define('${tag}', { formAssociated: true })`,\n defineRequiresTag: 'define() requires a tag name',\n eachDuplicateKey: (key: string, index: number): string => `each() received duplicate key \"${key}\" at index ${index}`,\n eventModifierUnknown: (eventName: string, modifier: string): string =>\n `@${eventName}.${modifier}: unknown event modifier \"${modifier}\". Supported: .stop, .prevent, .once, .capture`,\n injectStrictFailed: (key: string, tag: string): string => `injectStrict() could not resolve key \"${key}\" in <${tag}>`,\n invariantViolated: (message: string): string => `invariant violated: ${message}`,\n lifecycleOutsideSetup: 'Lifecycle hooks must be called during component setup',\n listenNullTarget: (eventName: string): string =>\n `listen() called with a null/undefined target for event \"${eventName}\": listener not attached`,\n modelRequiresValueBinding: (name: string): string =>\n `model(): \"${name}\" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${name}=\\${model(sig)}, not ?${name}=\\${model(sig)}.`,\n propBindingForbiddenName: (name: string): string =>\n `html\\`...\\`: \".${name}\" is a forbidden property-binding name (prototype pollution guard)`,\n propBindingHtmlInjectionName: (name: string): string =>\n `html\\`...\\`: \".${name}\" parses raw HTML and is not a supported property binding. Sanitize untrusted content, then bind it with the unsafeHtml() directive.`,\n propInvalidReflect: 'Structured props cannot use reflect:true: use prop.json() with reflect:false',\n templateInterpolationInTag:\n 'html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs',\n useFieldAlreadyCalled: (tag: string): string =>\n `useField() was already called on <${tag}>. Call it only once per component.`,\n validationFailed: (tag: string, errors: string[]): string => `Validation failed for <${tag}>:\\n${errors.join('\\n')}`,\n} as const;\n\n/**\n * Assert an internal invariant that must always hold: e.g. compiled template\n * metadata staying in sync with the DOM it was cloned from. A failed invariant\n * means a bug in ore itself, never user input, so it throws `OreInternalError`\n * unconditionally (every build, never gated like `_dev.ts`'s `warn()`).\n *\n * Narrowing caveat: `asserts condition` only narrows the exact expression\n * passed in. Assign to a local `const` first: `invariant(el.parentNode, msg)`\n * does not narrow later reads of `el.parentNode`.\n */\nexport function invariant(condition: unknown, message: string): asserts condition {\n if (!condition) throw new OreInternalError(ORE_ERRORS.invariantViolated(message));\n}\n"],"mappings":"A,kBAoBA,IAAaC,EAAb,cAA8B,KAAM,CAClC,YAAY,EAAiB,EAAqB,CAChD,MAAMC,EAASC,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGaC,EAAb,cAAiCH,CAAS,CAAC,EAO9BI,EAAb,cAAsCJ,CAAS,CAAC,EAenCK,EAAb,cAAuCL,CAAS,CAC9C,UACA,MAEA,YAAY,EAAiB,EAAoE,CAC/F,MAAMC,EAAS,CAAE,MAAOK,EAAQ,KAAM,CAAC,EACvC,KAAK,UAAYA,EAAQ,UACzB,KAAK,MAAQA,EAAQ,KACvB,CACF,EAiBA,SAAgBC,EAAmB,EAA0B,EAA2B,CAC7E,GAAIR,EAAM,UAAV,EAAgDA,EAAM,MAAtD,EAAiEA,EAAM,MAEhFU,EAAO,cACL,IAAI,YAAY,YAAa,CAC3B,QAAS,GACT,SAAU,GACV,OAAQV,CACV,CAAC,CACH,CACF,CAIA,IAAaW,EAAa,CACxB,sBAAuB,sFACvB,gBAAkB,GAAwB,WAAWC,EAAI,oDACzD,kCAAoC,GAClC,+BAA+BA,EAAI,8BACrC,kBAAmB,+BACnB,kBAAmB,EAAa,IAA0B,kCAAkCC,EAAI,aAAaC,IAC7G,sBAAuB,EAAmB,IACxC,IAAIC,EAAU,GAAGC,EAAS,4BAA4BA,EAAS,gDACjE,oBAAqB,EAAa,IAAwB,yCAAyCH,EAAI,QAAQD,EAAI,GACnH,kBAAoB,GAA4B,uBAAuBV,IACvE,sBAAuB,wDACvB,iBAAmB,GACjB,2DAA2Da,EAAU,0BACvE,0BAA4B,GAC1B,aAAaE,EAAK,yFAAyFA,EAAK,wBAAwBA,EAAK,kBAC/I,yBAA2B,GACzB,kBAAkBA,EAAK,oEACzB,6BAA+B,GAC7B,kBAAkBA,EAAK,sIACzB,mBAAoB,+EACpB,2BACE,uGACF,sBAAwB,GACtB,qCAAqCL,EAAI,qCAC3C,kBAAmB,EAAa,IAA6B,0BAA0BA,EAAI,MAAMM,EAAO,KAAK;CAAI,GACnH,EAYA,SAAgBC,EAAU,EAAoB,EAAoC,CAChF,GAAI,CAACC,EAAW,MAAM,IAAIf,EAAiBM,EAAW,kBAAkBT,CAAO,CAAC,CAClF,C"}
|
package/dist/ore.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/ripple");var OreError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},OreApiError=class extends OreError{},OreInternalError=class extends OreError{},OreLifecycleError=class extends OreError{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function reportRuntimeError(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var t={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice: custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifierUnknown:(e,t)=>`@${e}.${t}: unknown event modifier "${t}". Supported: .stop, .prevent, .once, .capture`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}": listener not attached`,modelRequiresValueBinding:e=>`model(): "${e}" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${e}=\${model(sig)}, not ?${e}=\${model(sig)}.`,propBindingForbiddenName:e=>`html\`...\`: ".${e}" is a forbidden property-binding name (prototype pollution guard)`,propInvalidReflect:`Structured props cannot use reflect:true: use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
|
|
2
|
-
`)}`};function invariant(e,n){if(!e)throw new OreInternalError(t.invariantViolated(n))}var resolveMaybeReactive=t=>typeof t==`function`?t():(0,e.isReactive)(t)?t.value:t,n=/[;{}]/g,sanitizeCssToken=e=>e.replace(n,``),runAll=e=>{for(let t=e.length-1;t>=0;t--)e[t]?.()},removeNodes=e=>{for(let t of e)t.remove()},createReplaceableSlot=()=>{let e=[],t=[];return{clear(){runAll(t),removeNodes(e),t=[],e=[]},get nodes(){return e},registerCleanup(e){t.push(e)},setNodes(t){e=t}}},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,setAttr=(e,t,n)=>{let a=t.toLowerCase();if(/^on[a-z]/i.test(t)){`${t}${t.slice(2)}`,e.removeAttribute(t);return}if(a===`srcdoc`||n==null||n===!1){e.removeAttribute(t);return}let o=n===!0?`true`:String(n);r.has(a)&&i.test(o)?(`${t}`,e.removeAttribute(t)):e.setAttribute(t,o)},listen=(e,n,r,i)=>{if(!e)return t.listenNullTarget(n),()=>{};let a=r;return e.addEventListener(n,a,i),()=>e.removeEventListener(n,a,i)},toKebab=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),cssDeclarationName=e=>sanitizeCssToken(e.startsWith(`--`)?e:toKebab(e)),cssDeclarationValue=e=>{let t=resolveMaybeReactive(e);return t==null||t===!1?``:sanitizeCssToken(String(t))},resolveClassTokens=e=>{let t=new Set;for(let[n,r]of Object.entries(e)){if(!resolveMaybeReactive(r))continue;let e=n.replace(/\s+/g,``);e&&t.add(e)}return t},isStructuredValue=e=>Array.isArray(e)||typeof e==`object`&&!!e,a=null,createRuntimeContext=e=>({element:e,formResetCallbacks:[],mountCallbacks:[]}),o=0,beginPendingWork=()=>{o++;let e=!1;return()=>{e||(e=!0,o--)}},runWithContext=(e,t)=>{let n=a;a=e;try{return t()}finally{a=n}},requireSetupContext=e=>{if(a)return a;throw new OreApiError(`${e}: ${t.lifecycleOutsideSetup}`)},getHost=()=>requireSetupContext(`getHost`).element,tryRegisterCleanup=t=>a?((0,e.effect)(()=>t),!0):!1,onCleanup=e=>{if(!tryRegisterCleanup(e))throw new OreApiError(`onCleanup: ${t.lifecycleOutsideSetup}`)},onMounted=e=>{requireSetupContext(`onMounted`).mountCallbacks.push(e)},onFormReset=e=>{requireSetupContext(`onFormReset`).formResetCallbacks.push(e)},watchEffect=t=>{let n=(0,e.effect)(t),stop=()=>n.dispose();return tryRegisterCleanup(stop),stop};function onEvent(e,t,n,r){if(requireSetupContext(`onEvent`),!e)return;let i=listen(e,t,n,r);tryRegisterCleanup(i)||i()}var onElement=(e,t)=>watchEffect(()=>{let n=e.value;if(n)return t(n)}),s=new WeakMap,buildAncestorChain=e=>{let t=[],n=e;for(;n;)n instanceof HTMLElement&&t.push(n),n=n.parentNode??(n instanceof ShadowRoot?n.host:null);return t},provideOnElement=(e,t,n)=>{let r=s.get(e)??new Map;r.has(t)&&`${e.localName}`,r.set(t,n),s.set(e,r)},provide=(e,t)=>{let n=requireSetupContext(`provide`).element;provideOnElement(n,e,t),onCleanup(()=>{let t=s.get(n);t&&(t.delete(e),t.size===0&&s.delete(n))})},c=Symbol(`inject.not_found`),l=new WeakMap,walkAndFind=(e,t)=>{let n=buildAncestorChain(e);for(let e of n){let n=s.get(e);if(n?.has(t))return n.get(t)}return c},lookup=(e,t)=>{let n=l.get(e);n||(n=new Map,l.set(e,n));let r=t;return n.has(r)||n.set(r,walkAndFind(e.element,t)),n.get(r)};function inject(e,...t){let n=lookup(requireSetupContext(`inject`),e);return n===c?t.length>0?t[0]:void 0:n}var injectStrict=e=>{let n=requireSetupContext(`injectStrict`),r=lookup(n,e);if(r!==c)return r;throw new OreApiError(t.injectStrictFailed(String(e),n.element.localName))};function createContext(e){return Symbol(e)}function _jsOnlyProp(e){return{default:e,parse:()=>e,reflect:!1}}function _numberProp(e){let t=e;return{default:t,parse:e=>{if(e==null)return t;let n=Number(e);return Number.isNaN(n)?(`${e}${String(t)}`,t):n},reflect:!0}}function _stringProp(e){return{default:e,parse:t=>t??e,reflect:!0}}var u={bool(e){return{default:e??!1,parse:e=>e!==null&&e!==`false`,reflect:!0}},data(e){return _jsOnlyProp(e)},json(e){return{default:e,parse:t=>{if(t==null||t===``)return e;try{return JSON.parse(t)}catch{return e}},reflect:!1}},number:_numberProp,oneOf(e,t){return{default:t,parse:n=>{if(n==null)return t;let r=e,i=r.indexOf(n);if(i!==-1)return e[i];let a=Number(n);if(!Number.isNaN(a)){let t=r.indexOf(a);if(t!==-1)return e[t]}return t},reflect:!0}},string:_stringProp},isPropDef=e=>typeof e==`object`&&!!e&&`default`in e&&`parse`in e;function normalizePropDefinition(e,n){if(!isPropDef(e))throw new OreApiError(`Prop "${n}" must use a prop.* helper (string/number/bool/json/oneOf). Received: ${typeof e}`);let r=e;if(!r.parse)throw new OreApiError(`Prop "${n}" must have a parse function. Use prop.* helpers.`);let i=r.reflect??!1;if(i&&isStructuredValue(r.default))throw new OreApiError(`Prop "${n}": ${t.propInvalidReflect}`);return{...r,reflect:i}}function validatePropDefs(e){let t=[];for(let[n,r]of Object.entries(e))try{normalizePropDefinition(r,n)}catch(e){t.push(e instanceof Error?e.message:String(e))}return t}var d=new WeakMap,getPropMeta=(e,t)=>d.get(e)?.get(t),coerceIncoming=(e,t)=>typeof e==`string`?t(e):e,registerProp=(t,n,r,i)=>{let a=d.get(t);a||(a=new Map,d.set(t,a));let{default:o,parse:s,reflect:c=!1}=i,l=(0,e.signal)(o),u=a.get(r),f=Object.hasOwn(t,n),p=f?t[n]:void 0,m={parse:s,reflect:c,signal:l};return u?l.value=u.signal.peek():f?(delete t[n],l.value=coerceIncoming(p,s)):t.hasAttribute(r)&&(l.value=s(t.getAttribute(r))),a.set(r,m),Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get:()=>l.value,set:e=>{l.value=coerceIncoming(e,s)}}),c&&watchEffect(()=>{let e=l.value;e==null?t.removeAttribute(r):typeof e==`boolean`?t.toggleAttribute(r,e):setAttr(t,r,e)}),l};function createProps(e,t){let n={};for(let[r,i]of Object.entries(t))n[r]=registerProp(e,r,toKebab(r),i);return n}var makeBrand=e=>{let t=Symbol.for(e),stamp=e=>Object.assign(e,{[t]:!0}),is=e=>typeof e==`object`&&!!e&&t in e;return{is,stamp}},f=makeBrand(`ore:css-result`),p=f.is,cssResultToString=function(){return this.content},css=(e,...t)=>{let n=``;for(let r=0;r<e.length;r++)if(n+=e[r],r<t.length){let e=t[r];n+=p(e)?e.content:String(e)}return f.stamp({content:n.trim(),toString:cssResultToString})},m=new Map,h=256,loadStylesheet=e=>{if(e instanceof CSSStyleSheet)return e;let t=typeof e==`string`?e:e.content,n=m.get(t);if(n)return m.delete(t),m.set(t,n),n;let r=new CSSStyleSheet;try{r.replaceSync(t)}catch{return r}if(m.set(t,r),m.size>h){let e=m.keys().next().value;e!==void 0&&m.delete(e)}return r},g={SETUP_DONE:`setup_done`,SETUP_RUNNING:`setup_running`,UNINITIALIZED:`uninitialized`,UNMOUNTED:`unmounted`},createComponentState=()=>({formResetCallbacks:[],generation:0,mountCallbacks:[],phase:g.UNINITIALIZED,scope:(0,e.createScope)(),templateResult:null}),isPromiseLike=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&`then`in e&&typeof e.then==`function`,BaseElement=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=createComponentState()}connectedCallback(){(0,e.untrack)(()=>{this._component.phase===g.UNINITIALIZED&&this._runSetup(),this._init()})}attributeChangedCallback(t,n,r){if(n===r)return;let i=getPropMeta(this,t);if(!i)return;let a=i.parse(r);Object.is((0,e.untrack)(()=>i.signal.value),a)||(i.signal.value=a)}disconnectedCallback(){this._component.generation++,this._component.phase=g.UNMOUNTED,this._resetSetupState()}_resetSetupState(){this._component.scope.dispose(),this._component.formResetCallbacks=[],this._component.mountCallbacks=[],this._component.phase=g.UNINITIALIZED,this._component.scope=(0,e.createScope)(),this._component.templateResult=null}formResetCallback(){for(let e of this._component.formResetCallbacks)try{e()}catch(e){this._reportLifecycleError(e,`form-reset`)}}_reportLifecycleError(e,t){let n=e instanceof Error?e:Error(String(e));reportRuntimeError(new OreLifecycleError(`<${this.localName}> failed during ${this._component.phase} (${t})`,{cause:n,component:this.localName,phase:t}),this)}_runSetup(){this._component.phase=g.SETUP_RUNNING;let e=this.constructor._definition,n=this.constructor._normalizedPropDefs,r=createRuntimeContext(this);try{let i;if(this._component.scope.run(()=>{i=runWithContext(r,()=>{let t=n?createProps(this,n):{};return e.setup(t)})}),this._component.mountCallbacks.push(...r.mountCallbacks),this._component.formResetCallbacks.push(...r.formResetCallbacks),isPromiseLike(i))throw new OreApiError(t.asyncSetupUnsupported);this._component.templateResult=i??null,this._component.phase=g.SETUP_DONE}catch(e){throw this._reportLifecycleError(e,`setup`),this._resetSetupState(),e}}_isStale(e){return this._component.generation!==e||!this.isConnected}_applyResult(e){if(!e)return;let t=this.shadowRoot??this,n=createRuntimeContext(this);t.replaceChildren(),this._component.scope.run(()=>{runWithContext(n,()=>{e.mount(t,null,onCleanup)})})}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===g.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(loadStylesheet))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation,t=beginPendingWork();queueMicrotask(()=>{try{if(this._isStale(e))return;let t=this._component.mountCallbacks.splice(0);for(let e=0;e<t.length;e++){let n=t[e];try{let e=createRuntimeContext(this);this._component.scope.run(()=>{runWithContext(e,()=>{let e=n();typeof e==`function`&&onCleanup(e)})}),e.mountCallbacks.length>0&&t.push(...e.mountCallbacks),e.formResetCallbacks.length>0&&this._component.formResetCallbacks.push(...e.formResetCallbacks)}catch(e){this._reportLifecycleError(e,`mounted`)}}}finally{t()}})}};function define(e,n){if(!e)throw new OreApiError(t.defineRequiresTag);if(customElements.get(e))throw new OreApiError(t.defineDuplicate(e));let{props:r}=n,i=(()=>{if(!r)return;let n=validatePropDefs(r);if(n.length>0)throw new OreApiError(t.validationFailed(e,n));let i={};for(let[e,t]of Object.entries(r))i[e]=normalizePropDefinition(t,e);return i})(),a=i?Object.keys(i).map(toKebab):[],ComponentClass=class extends BaseElement{static _definition=n;static _normalizedPropDefs=i;static formAssociated=n.formAssociated??!1;static observedAttributes=a};return Object.defineProperty(ComponentClass,"name",{value:e}),customElements.define(e,ComponentClass),ComponentClass}var classMap=t=>(0,e.computed)(()=>[...resolveClassTokens(t)].join(` `));function ref(){return(0,e.signal)(null)}var _=makeBrand(`ore:directive`),createDirectiveResult=e=>_.stamp({mount:e}),v=_.is,y=makeBrand(`ore:html-result`),b=y.is;function createHtmlResult(e,t){let mount=(n,r,i)=>{let a=Array.from(e.childNodes);return n.insertBefore(e,r),t(i),a};return y.stamp({apply:t,fragment:e,mount})}var createItem=(t,n,r,i,a)=>{let o=(0,e.signal)(t),s=(0,e.signal)(n),c=(0,e.createScope)(),l=[],u=[];return c.run(()=>{u=r(o,s).mount(i,a,e=>l.push(e))}),{cleanups:l,data:o,index:s,nodes:u,scope:c}},removeItem=e=>{e.scope.dispose(),runAll(e.cleanups),removeNodes(e.nodes)},reconcileItems=(t,n,r,i,a,o,s)=>{for(let c=0;c<n.length;c++){let l=r[c];if(t.has(l))continue;let u=(0,e.untrack)(()=>createItem(n[c],c,i,a,o));s.push(u),t.set(l,u)}let c=[];(0,e.batch)(()=>{for(let e=0;e<n.length;e++){let i=t.get(r[e]);invariant(i,`each() reconcile phase 2 lost an entry created in phase 1`),i.data.value=n[e],i.index.value=e,c.push(i)}});let l=o;for(let e=c.length-1;e>=0;e--){let t=c[e],n=t.nodes[0],r=t.nodes[t.nodes.length-1];if(n&&r!==l.previousSibling)for(let e of t.nodes)a.insertBefore(e,l);l=n??l}let u=new Set(r);for(let[e,n]of t)u.has(e)||(removeItem(n),t.delete(e));return c},rollbackCreated=(e,t)=>{for(let n of t){removeItem(n);for(let[t,r]of e)if(r===n){e.delete(t);break}}},collectKeys=(e,n)=>{let r=[],i=new Set;for(let a=0;a<e.length;a++){let o=n(e[a],a);if(i.has(o))throw new OreApiError(t.eachDuplicateKey(String(o),a));i.add(o),r.push(o)}return r},reportEachError=(e,t)=>{let n=e instanceof Error?e:Error(String(e));reportRuntimeError(new OreLifecycleError(`each() failed to reconcile a list update: ${n.message}`,{cause:n,component:`each()`,phase:`each-reconcile`}),t)};function each(t,n,r,i){let a=Array.isArray(t)?(0,e.signal)(t):typeof t==`function`?(0,e.computed)(t):t;return createDirectiveResult((t,o)=>{let s=t.parentNode;invariant(s,`each() anchor comment has no parent node`);let c=document.createComment(`each/end`);s.insertBefore(c,t.nextSibling);let l=new Map,u=[],d=null,f=[],mountFallback=()=>{i&&(d=i().mount(s,c,e=>f.push(e)))},clearFallback=()=>{d&&(runAll(f),removeNodes(d),d=null,f=[])},p=(0,e.effect)(()=>{let i=a.value??[];if(i.length===0){for(let t of(0,e.untrack)(()=>u))removeItem(t);l=new Map,u=[],d||(0,e.untrack)(mountFallback);return}let o;try{o=(0,e.untrack)(()=>collectKeys(i,n))}catch(e){reportEachError(e,t);return}clearFallback();let f=[];try{u=(0,e.untrack)(()=>reconcileItems(l,i,o,r,s,c,f))}catch(n){reportEachError(n,t),(0,e.untrack)(()=>rollbackCreated(l,f))}});o(()=>p.dispose()),o(()=>{clearFallback();for(let e of u)removeItem(e);c.remove()})})}var x=makeBrand(`ore:live`),live=e=>x.stamp({source:e}),S=x.is,C=makeBrand(`ore:model`),w=C.is,modelDefaultGet=e=>e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`)?e.checked:e.value,modelDefaultEvent=e=>e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`)||e instanceof HTMLSelectElement?`change`:`input`,model=(e,t)=>C.stamp({event:t?.event,get:t?.get,source:e}),styleMap=t=>(0,e.computed)(()=>{let e=[];for(let[n,r]of Object.entries(t)){let t=cssDeclarationValue(r);if(!t)continue;let i=cssDeclarationName(n);i&&e.push(`${i}:${t}`)}return e.join(`;`)}),parseHtml=(e,t,n)=>{let r=document.createElement(`template`);r.innerHTML=e;let i=Array.from(r.content.cloneNode(!0).childNodes);for(let e of i)t.insertBefore(e,n);return i};function unsafeHtml(t){let n=typeof t==`function`?(0,e.computed)(t):(0,e.isReactive)(t)?t:null;return createDirectiveResult((r,i)=>{let a=r.parentNode;invariant(a,`unsafeHtml() anchor comment has no parent node`);let o=document.createComment(`unsafe-html/end`);if(a.insertBefore(o,r.nextSibling),n){let t=createReplaceableSlot(),r=(0,e.effect)(()=>{t.clear(),t.setNodes(parseHtml(n.value,a,o))});i(()=>r.dispose()),i(()=>{t.clear(),o.remove()})}else parseHtml(t,a,o),i(()=>o.remove())})}var T=`when() anchor comment has no parent node`;function when(t,n,r){return typeof t!=`function`&&!(0,e.isReactive)(t)?createDirectiveResult((e,i)=>{let a=t?n():r?r():null;if(!a||!b(a))return;let o=e.parentNode;invariant(o,T);let s=a.mount(o,e,i);i(()=>removeNodes(s))}):createDirectiveResult((i,a)=>{let o=(typeof t==`function`?(0,e.computed)(t):null)??t,s=i.parentNode;invariant(s,T);let c=document.createComment(`when/end`);s.insertBefore(c,i.nextSibling);let l=createReplaceableSlot(),u=(0,e.effect)(()=>{let t=o.value;l.clear();let i=t?n():r?r():null;i&&b(i)&&l.setNodes((0,e.untrack)(()=>i.mount(s,c,l.registerCleanup)))});a(()=>u.dispose()),a(()=>{l.clear(),c.remove()})})}var E=new WeakMap,D=new WeakSet,useField=e=>{let n=getHost();if(!n.constructor.formAssociated)throw new OreApiError(t.defineFieldRequiresFormAssociated(n.localName));if(D.has(n))throw new OreApiError(t.useFieldAlreadyCalled(n.localName));let r=E.get(n)??n.attachInternals();E.set(n,r),D.add(n),onCleanup(()=>D.delete(n));let i=e.toFormValue??(t=>t==null?e.emptyStringForNull?``:null:t instanceof File||t instanceof FormData?t:String(t));watchEffect(()=>{r.setFormValue(i(e.value.value))});let a=e.disabled;if(a&&`states`in r){let e=r.states;watchEffect(()=>{a.value?e.add(`disabled`):e.delete(`disabled`)})}e.validity&&watchEffect(()=>{let t=e.validity?.value;if(!t){r.setValidity({});return}let n=Object.values(t.flags).some(Boolean);r.setValidity(t.flags,n&&!t.message?`Invalid value.`:t.message)}),e.onReset&&onFormReset(e.onReset);let checkValidity=()=>r.checkValidity(),reportValidity=()=>r.reportValidity(),setCustomValidity=e=>e?r.setValidity({customError:!0},e):r.setValidity({});return{checkValidity,internals:r,reportValidity,setCustomValidity}},normalizeHostAttrKey=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:e,bind=(e,t)=>{let n=t?.target??getHost(),r=[];if(e.attr)for(let[t,i]of Object.entries(e.attr)){let e=applyAttribute(n,O(t),i);e&&r.push(e)}if(e.class&&r.push(applyClassMap(n,e.class)),e.style)for(let[t,i]of Object.entries(e.style)){let e=applyStyle(n,t,i);e&&r.push(e)}if(e.on){let{target:i,...a}=t??{};for(let t of Object.keys(e.on)){let i=e.on[t];i&&r.push(listen(n,t,i,a))}}let cleanup=()=>{for(let e of r)e()};return tryRegisterCleanup(cleanup),cleanup},O=normalizeHostAttrKey,applyReactiveBinding=(t,n)=>{if(typeof t==`function`)return watchEffect(()=>{n(t())});if((0,e.isReactive)(t))return watchEffect(()=>{n(t.value)});n(t)};function applyAttribute(e,t,n){return applyReactiveBinding(n,n=>setAttr(e,t,n))}function applyStyle(e,t,n){let r=cssDeclarationName(t);if(!r)return;let i=!1,setStyle=t=>{let n=cssDeclarationValue(t);n?(i=!0,e.style.setProperty(r,n)):i&&e.style.removeProperty(r)};return applyReactiveBinding(n,setStyle)}function applyClassMap(e,t){let n=typeof t==`function`?t:()=>Object.fromEntries([...resolveClassTokens(t)].map(e=>[e,!0])),r=new Set;return watchEffect(()=>{let t=new Set;for(let[i,a]of Object.entries(n()))a&&(t.add(i),r.has(i)||e.classList.add(i));for(let n of r)t.has(n)||e.classList.remove(n);r=t})}var k=`default`,normalizeSlotName=e=>e||k,createSlots=t=>{let n=new Map,r=new Map,i=new Map,ensureSlotEntry=t=>{let r=n.get(t);return r||(r={elements:(0,e.signal)([]),presence:(0,e.signal)(!1)},n.set(t,r)),r},areElementsEqual=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},recomputeSlot=e=>{let t=normalizeSlotName(e),n=r.get(t),i=[];if(n)for(let e of n)i.push(...e.assignedElements({flatten:!0}));let a=ensureSlotEntry(t);areElementsEqual(a.elements.value,i)||(a.elements.value=i);let o=i.length>0;a.presence.value!==o&&(a.presence.value=o)},bindSlot=e=>{if(i.has(e))return;let t=normalizeSlotName(e.getAttribute(`name`)),n=r.get(t)??new Set;n.add(e),r.set(t,n);let onChange=()=>recomputeSlot(t);e.addEventListener(`slotchange`,onChange),i.set(e,()=>{e.removeEventListener(`slotchange`,onChange)}),recomputeSlot(t)},unbindSlot=e=>{let t=i.get(e);if(!t)return;t(),i.delete(e);let n=normalizeSlotName(e.getAttribute(`name`)),a=r.get(n);a&&(a.delete(e),a.size===0&&r.delete(n)),recomputeSlot(n)},bindAllSlots=()=>{t.shadowRoot?.querySelectorAll(`slot`).forEach(e=>{bindSlot(e)})},recomputeAllSlots=()=>{for(let e of r.keys())recomputeSlot(e)},a=null,initSlots=()=>{bindAllSlots(),recomputeAllSlots(),!a&&t.shadowRoot&&(a=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)e instanceof HTMLSlotElement&&unbindSlot(e);bindAllSlots(),i.size>0&&recomputeAllSlots()}),a.observe(t.shadowRoot,{childList:!0,subtree:!0}))};return onMounted(initSlots),onCleanup(()=>{a?.disconnect(),a=null;for(let e of i.values())e();i.clear(),r.clear(),n.clear(),A.delete(t)}),{elements:e=>ensureSlotEntry(normalizeSlotName(e)).elements,has:e=>ensureSlotEntry(normalizeSlotName(e)).presence}},A=new WeakMap,useSlots=()=>{let e=requireSetupContext(`useSlots`),t=A.get(e.element);return t||(t=createSlots(e.element),A.set(e.element,t)),t},signalEffect=(t,n,r)=>{let i=(0,e.effect)(()=>{n(t.value)});r(()=>i.dispose())},isNativeFormInput=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,isCheckableInput=e=>e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`),syncFormControl=(e,t,n,r={last:void 0})=>{let i=isCheckableInput(e),a=i?!!t:t==null?``:String(t),o=i?e.checked:e.value;(!n||r.last===void 0||Object.is(o,r.last)||Object.is(o,a))&&(i?e.checked=a:e.value=a,n&&(r.last=a))},syncRegisteredProp=(t,n,r,i)=>{let a=isStructuredValue(i)?i:n.parse(r.mode===`bool`?i?``:null:i==null||i===!1?null:String(i));if(Object.is((0,e.untrack)(()=>n.signal.value),a)||(n.signal.value=a),!n.reflect){if(isStructuredValue(i))return;r.mode===`bool`?t.toggleAttribute(r.name,!!i):setAttr(t,r.name,i)}},applyAttrBinding=(e,t)=>{let{el:n,mode:r,name:i}=e,a={last:void 0},update=t=>{let o=getPropMeta(n,i);o?syncRegisteredProp(n,o,e,t):i===`value`&&isNativeFormInput(n)||i===`checked`&&n instanceof HTMLInputElement?syncFormControl(n,t,e.live,a):i===`indeterminate`&&n instanceof HTMLInputElement?n.indeterminate=!!t:r===`bool`?n.toggleAttribute(i,!!t):setAttr(n,i,t)};`signal`in e?signalEffect(e.signal,update,t):update(e.value)},applyEventBinding=(e,t)=>{let{modifiers:n}=e,r=n?.stop||n?.prevent?t=>{n.stop&&t.stopPropagation(),n.prevent&&t.preventDefault(),e.handler(t)}:e.handler,i=n?.once||n?.capture?{capture:n.capture,once:n.once}:void 0;t(listen(e.el,e.name,r,i))},applyPropBinding=(e,t)=>{let update=t=>{e.el[e.name]=t};`signal`in e?signalEffect(e.signal,update,t):update(e.value)},applyModelBinding=(t,n)=>{let{el:r,get:i,signal:a}=t,o={last:void 0},write=e=>{isNativeFormInput(r)?syncFormControl(r,e,!0,o):r.value=e},s=(0,e.effect)(()=>{write(a.value)}),onEvent=()=>{let t=i(r);Object.is((0,e.untrack)(()=>a.value),t)||(a.value=t)};n(()=>s.dispose()),n(listen(r,t.event,onEvent))},applyRefBinding=(e,t)=>{let{el:n,ref:r}=e;typeof r==`function`?(r(n),t(()=>r(null))):(r.value=n,t(()=>{r.value=null}))},insertHtmlValues=(e,t,n)=>{let r=[],i=t.parentNode;invariant(i,`html binding anchor has no parent node`);for(let a of e)if(b(a)){let e=Array.from(a.fragment.childNodes);i.insertBefore(a.fragment,t),a.apply(n),r.push(...e)}else if(a!=null&&a!==!1){let e=document.createTextNode(String(a));i.insertBefore(e,t),r.push(e)}return r},applyHtmlBinding=(t,n)=>{let{anchor:r,signal:i}=t,a=createReplaceableSlot(),o=(0,e.effect)(()=>{let t=i.value;a.clear(),t!=null&&t.length!==0&&(0,e.untrack)(()=>{a.setNodes(insertHtmlValues(t,r,a.registerCleanup))})});n(()=>{o.dispose(),a.clear()})},applyDirectiveBinding=(e,t)=>{e.directive.mount(e.anchor,t)},applyBinding=(e,t)=>{switch(e.type){case`attr`:applyAttrBinding(e,t);break;case`directive`:applyDirectiveBinding(e,t);break;case`event`:applyEventBinding(e,t);break;case`html`:applyHtmlBinding(e,t);break;case`model`:applyModelBinding(e,t);break;case`prop`:applyPropBinding(e,t);break;case`ref`:applyRefBinding(e,t)}},createAttrBindingFromValue=(t,n,r,i)=>S(i)?{el:t,live:!0,mode:n,name:r,signal:i.source,type:`attr`}:typeof i==`function`?{el:t,mode:n,name:r,signal:(0,e.computed)(i),type:`attr`}:(0,e.isReactive)(i)?{el:t,mode:n,name:r,signal:i,type:`attr`}:{el:t,mode:n,name:r,type:`attr`,value:i},resolveStaticText=e=>e==null?``:String(e),j={ATTR:`attr`,BOOL_ATTR:`boolAttr`,EVENT:`event`,NODE:`node`,PROP:`prop`,REF:`ref`},M={capture:!0,once:!0,prevent:!0,stop:!0},parseEventModifiers=(e,n)=>{if(n.length===0)return;let r={};for(let i of n){if(!(i in M))throw new OreApiError(t.eventModifierUnknown(e,i));r[i]=!0}return r},N=/\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/,P=/\s+ref\s*=\s*["']?$/,F=/\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,I=/\s+\.([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,L=/\s+([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,detectSlot=e=>{let n;if(n=N.exec(e)){let t=e.slice(0,-n[0].length),[r,...i]=n[1].split(`.`);return{eventModifiers:parseEventModifiers(r,i),kind:j.EVENT,name:r,prefix:t}}if(n=P.exec(e))return{kind:j.REF,prefix:e.slice(0,-n[0].length)};if(n=F.exec(e))return{kind:j.BOOL_ATTR,name:n[1],prefix:e.slice(0,-n[0].length)};if(n=I.exec(e)){let r=n[1];if(r===`__proto__`||r===`constructor`||r===`prototype`)throw new OreApiError(t.propBindingForbiddenName(r));return{kind:j.PROP,name:r,prefix:e.slice(0,-n[0].length)}}if(n=L.exec(e))return{kind:j.ATTR,name:n[1],prefix:e.slice(0,-n[0].length)};let r=e.lastIndexOf(`<`);if(r>e.lastIndexOf(`>`)&&e[r+1]!==`/`)throw new OreApiError(t.templateInterpolationInTag);return{kind:j.NODE,prefix:e}},R=new WeakMap,z=/[@?]?[a-zA-Z_][-a-zA-Z0-9_.]*\s*=\s*$/,normalizeTemplateStrings=e=>{let t=Array.from(e),n=!1;for(let e=0;e<t.length-1;e++){let r=t[e],i=r[r.length-1];for(let e of r)e===`<`?n=!0:e===`>`&&(n=!1);if((i===`"`||i===`'`)&&n&&z.test(r.slice(0,-1))){t[e]=r.slice(0,-1);let n=t[e+1];n.startsWith(i)&&(t[e+1]=n.slice(1))}}return t},B=`data-ore-b`,V=/^ore:(\d+)$/,walkNode=(e,t,n,r)=>{if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.getAttribute(B);i!==null&&(n.set(Number(i),[...t]),r.removeAttribute(B))}else if(e.nodeType===Node.COMMENT_NODE){let n=e.nodeValue,i=n===null?null:V.exec(n);i&&r.set(Number(i[1]),[...t])}let i=e.childNodes;for(let e=0;e<i.length;e++)walkNode(i[e],[...t,e],n,r)},buildStaticTemplate=e=>{let t=normalizeTemplateStrings(e),n=``,r,i=0,a=0,o=[];for(let e=0;e<t.length-1;e++){let s=t[e],c=detectSlot(s);if(c.kind===j.NODE)n+=`${c.prefix}<!--ore:${a}-->`,o.push({commentId:a,kind:j.NODE}),a++,r=void 0;else{r===void 0||c.prefix.lastIndexOf(`<`)>c.prefix.lastIndexOf(`>`)?(r=i++,n+=`${c.prefix} ${B}="${r}"`):n+=c.prefix;let e=c.kind===j.BOOL_ATTR?`bool`:c.kind===j.ATTR?`attr`:void 0;o.push({elementId:r,eventModifiers:c.eventModifiers,kind:c.kind,mode:e,name:c.name})}}n+=t[t.length-1]??``;let s=document.createElement(`template`);s.innerHTML=n;let c=new Map,l=new Map,u=s.content.childNodes;for(let e=0;e<u.length;e++)walkNode(u[e],[e],c,l);return{commentPaths:l,element:s,elementPaths:c,slots:o}},getStaticTemplate=e=>{let t=R.get(e);return t||(t=buildStaticTemplate(e),R.set(e,t)),t},followPath=(e,t)=>{let n=e;for(let e of t)n=n.childNodes[e];return n},H="html`...`: node-slot comment anchor has no parent node",toHtmlValues=e=>Array.isArray(e)?e:[e],embedStaticResult=(e,t,n)=>{let r=t.parentNode;for(invariant(r,H);e.fragment.firstChild;)r.insertBefore(e.fragment.firstChild,t);n.push(e.apply.bind(e))},compileTemplate=(n,r)=>{let i=getStaticTemplate(n),a=i.element.content.cloneNode(!0),o=[],s=[],c=i.slots.map((e,t)=>{let n=r[t];if(e.kind===j.NODE){let t=e.commentId===void 0?void 0:i.commentPaths.get(e.commentId);return invariant(t,`compiled template is missing a comment path for node slot ${e.commentId}`),{comment:followPath(a,t),slot:e,value:n}}let o=e.elementId===void 0?void 0:i.elementPaths.get(e.elementId);return invariant(o,`compiled template is missing an element path for slot ${e.elementId}`),{el:followPath(a,o),slot:e,value:n}});for(let{comment:n,el:r,slot:i,value:a}of c)if(i.kind===j.NODE){let t=n;if(invariant(t,`compiled template produced a node slot without a comment anchor`),v(a)){o.push({anchor:t,directive:a,type:`directive`});continue}if(b(a)){embedStaticResult(a,t,s),t.remove();continue}if(typeof a==`function`||(0,e.isReactive)(a)){let n=typeof a==`function`?(0,e.computed)(()=>toHtmlValues(a())):(0,e.computed)(()=>toHtmlValues(a.value));o.push({anchor:t,signal:n,type:`html`});continue}if(Array.isArray(a)){for(let e of a)if(b(e))embedStaticResult(e,t,s);else{let n=t.parentNode;invariant(n,H),n.insertBefore(document.createTextNode(resolveStaticText(e)),t)}t.remove();continue}t.replaceWith(document.createTextNode(resolveStaticText(a)))}else if(invariant(r,`compiled template produced an element slot without an element`),i.kind===j.EVENT){let t=i.name;if(invariant(t,`compiled template produced an event slot without an event name`),typeof a==`function`)o.push({el:r,handler:a,modifiers:i.eventModifiers,name:t,type:`event`});else if((0,e.isReactive)(a)){let e=a,handler=t=>{let n=e.value;typeof n==`function`&&n(t)};o.push({el:r,handler,modifiers:i.eventModifiers,name:t,type:`event`})}}else if(i.kind===j.PROP){let t=i.name;invariant(t,`compiled template produced a prop slot without a property name`),typeof a==`function`?o.push({el:r,name:t,signal:(0,e.computed)(a),type:`prop`}):(0,e.isReactive)(a)?o.push({el:r,name:t,signal:a,type:`prop`}):o.push({el:r,name:t,type:`prop`,value:a})}else if(i.kind===j.REF)a&&o.push({el:r,ref:a,type:`ref`});else if(invariant(i.name,`compiled template produced an attr slot without an attribute name`),w(a)){if(i.mode!==`attr`)throw new OreApiError(t.modelRequiresValueBinding(i.name));o.push({el:r,event:a.event??modelDefaultEvent(r),get:a.get??modelDefaultGet,signal:a.source,type:`model`})}else o.push(createAttrBindingFromValue(r,i.mode??`attr`,i.name,a));return createHtmlResult(a,e=>{for(let t of o)applyBinding(t,e);for(let t of s)t(e)})},html=(e,...t)=>compileTemplate(e,t),U={bubbles:!0,cancelable:!0,composed:!0},useEmit=()=>{let e=getHost();return((t,...n)=>{let r=n.length>0?{...U,detail:n[0]}:U;return e.dispatchEvent(new CustomEvent(String(t),r))})},W=0,G=Math.random().toString(36).slice(2,6),createId=(e=`id`)=>`${e}-${G}${++W}`;exports.OreApiError=OreApiError,exports.OreError=OreError,exports.OreInternalError=OreInternalError,exports.OreLifecycleError=OreLifecycleError,exports.bind=bind,exports.classMap=classMap,exports.createContext=createContext,exports.createId=createId,exports.css=css,exports.define=define,exports.each=each,exports.getHost=getHost,exports.html=html,exports.inject=inject,exports.injectStrict=injectStrict,exports.live=live,exports.model=model,exports.onCleanup=onCleanup,exports.onElement=onElement,exports.onEvent=onEvent,exports.onFormReset=onFormReset,exports.onMounted=onMounted,exports.prop=u,exports.provide=provide,exports.ref=ref,exports.styleMap=styleMap,exports.unsafeHtml=unsafeHtml,exports.useEmit=useEmit,exports.useField=useField,exports.useSlots=useSlots,exports.watchEffect=watchEffect,exports.when=when;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/ripple");var OreError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},OreApiError=class extends OreError{},OreInternalError=class extends OreError{},OreLifecycleError=class extends OreError{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function reportRuntimeError(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var t={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice: custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifierUnknown:(e,t)=>`@${e}.${t}: unknown event modifier "${t}". Supported: .stop, .prevent, .once, .capture`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}": listener not attached`,modelRequiresValueBinding:e=>`model(): "${e}" must be a plain value/checked attribute binding, not a boolean attribute. Bind it as ${e}=\${model(sig)}, not ?${e}=\${model(sig)}.`,propBindingForbiddenName:e=>`html\`...\`: ".${e}" is a forbidden property-binding name (prototype pollution guard)`,propBindingHtmlInjectionName:e=>`html\`...\`: ".${e}" parses raw HTML and is not a supported property binding. Sanitize untrusted content, then bind it with the unsafeHtml() directive.`,propInvalidReflect:`Structured props cannot use reflect:true: use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
|
|
2
|
+
`)}`};function invariant(e,n){if(!e)throw new OreInternalError(t.invariantViolated(n))}var resolveMaybeReactive=t=>typeof t==`function`?t():(0,e.isReactive)(t)?t.value:t,n=/[;{}]/g,sanitizeCssToken=e=>e.replace(n,``),runAll=e=>{for(let t=e.length-1;t>=0;t--)e[t]?.()},removeNodes=e=>{for(let t of e)t.remove()},createReplaceableSlot=()=>{let e=[],t=[];return{clear(){runAll(t),removeNodes(e),t=[],e=[]},get nodes(){return e},registerCleanup(e){t.push(e)},setNodes(t){e=t}}},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\r]/g,o=/^[\s\p{C}]+|[\s\p{C}]+$/gu,normalizeUrlForSchemeCheck=e=>e.replace(a,``).replace(o,``),isDangerousUrl=e=>i.test(normalizeUrlForSchemeCheck(e)),setAttr=(e,t,n)=>{let i=t.toLowerCase();if(/^on[a-z]/i.test(t)){`${t}${t.slice(2)}`,e.removeAttribute(t);return}if(i===`srcdoc`||n==null||n===!1){e.removeAttribute(t);return}let a=n===!0?`true`:String(n);r.has(i)&&isDangerousUrl(a)?(`${t}`,e.removeAttribute(t)):e.setAttribute(t,a)},listen=(e,n,r,i)=>{if(!e)return t.listenNullTarget(n),()=>{};let a=r;return e.addEventListener(n,a,i),()=>e.removeEventListener(n,a,i)},toKebab=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),cssDeclarationName=e=>sanitizeCssToken(e.startsWith(`--`)?e:toKebab(e)),cssDeclarationValue=e=>{let t=resolveMaybeReactive(e);return t==null||t===!1?``:sanitizeCssToken(String(t))},resolveClassTokens=e=>{let t=new Set;for(let[n,r]of Object.entries(e)){if(!resolveMaybeReactive(r))continue;let e=n.replace(/\s+/g,``);e&&t.add(e)}return t},isStructuredValue=e=>Array.isArray(e)||typeof e==`object`&&!!e,s=null,createRuntimeContext=e=>({element:e,formResetCallbacks:[],mountCallbacks:[]}),c=0,beginPendingWork=()=>{c++;let e=!1;return()=>{e||(e=!0,c--)}},runWithContext=(e,t)=>{let n=s;s=e;try{return t()}finally{s=n}},requireSetupContext=e=>{if(s)return s;throw new OreApiError(`${e}: ${t.lifecycleOutsideSetup}`)},getHost=()=>requireSetupContext(`getHost`).element,tryRegisterCleanup=t=>s?((0,e.effect)(()=>t),!0):!1,onCleanup=e=>{if(!tryRegisterCleanup(e))throw new OreApiError(`onCleanup: ${t.lifecycleOutsideSetup}`)},onMounted=e=>{requireSetupContext(`onMounted`).mountCallbacks.push(e)},onFormReset=e=>{requireSetupContext(`onFormReset`).formResetCallbacks.push(e)},watchEffect=t=>{let n=(0,e.effect)(t),stop=()=>n.dispose();return tryRegisterCleanup(stop),stop};function onEvent(e,t,n,r){if(requireSetupContext(`onEvent`),!e)return;let i=listen(e,t,n,r);tryRegisterCleanup(i)||i()}var onElement=(e,t)=>watchEffect(()=>{let n=e.value;if(n)return t(n)}),l=new WeakMap,buildAncestorChain=e=>{let t=[],n=e;for(;n;)n instanceof HTMLElement&&t.push(n),n=n.parentNode??(n instanceof ShadowRoot?n.host:null);return t},provideOnElement=(e,t,n)=>{let r=l.get(e)??new Map;r.has(t)&&`${e.localName}`,r.set(t,n),l.set(e,r)},provide=(e,t)=>{let n=requireSetupContext(`provide`).element;provideOnElement(n,e,t),onCleanup(()=>{let t=l.get(n);t&&(t.delete(e),t.size===0&&l.delete(n))})},u=Symbol(`inject.not_found`),d=new WeakMap,walkAndFind=(e,t)=>{let n=buildAncestorChain(e);for(let e of n){let n=l.get(e);if(n?.has(t))return n.get(t)}return u},lookup=(e,t)=>{let n=d.get(e);n||(n=new Map,d.set(e,n));let r=t;return n.has(r)||n.set(r,walkAndFind(e.element,t)),n.get(r)};function inject(e,...t){let n=lookup(requireSetupContext(`inject`),e);return n===u?t.length>0?t[0]:void 0:n}var injectStrict=e=>{let n=requireSetupContext(`injectStrict`),r=lookup(n,e);if(r!==u)return r;throw new OreApiError(t.injectStrictFailed(String(e),n.element.localName))};function createContext(e){return Symbol(e)}function _jsOnlyProp(e){return{default:e,parse:()=>e,reflect:!1}}function _numberProp(e){let t=e;return{default:t,parse:e=>{if(e==null)return t;let n=Number(e);return Number.isNaN(n)?(`${e}${String(t)}`,t):n},reflect:!0}}function _stringProp(e){return{default:e,parse:t=>t??e,reflect:!0}}var f={bool(e){return{default:e??!1,parse:e=>e!==null&&e!==`false`,reflect:!0}},data(e){return _jsOnlyProp(e)},json(e){return{default:e,parse:t=>{if(t==null||t===``)return e;try{return JSON.parse(t)}catch{return e}},reflect:!1}},number:_numberProp,oneOf(e,t){return{default:t,parse:n=>{if(n==null)return t;let r=e,i=r.indexOf(n);if(i!==-1)return e[i];let a=Number(n);if(!Number.isNaN(a)){let t=r.indexOf(a);if(t!==-1)return e[t]}return t},reflect:!0}},string:_stringProp},isPropDef=e=>typeof e==`object`&&!!e&&`default`in e&&`parse`in e;function normalizePropDefinition(e,n){if(!isPropDef(e))throw new OreApiError(`Prop "${n}" must use a prop.* helper (string/number/bool/json/oneOf). Received: ${typeof e}`);let r=e;if(!r.parse)throw new OreApiError(`Prop "${n}" must have a parse function. Use prop.* helpers.`);let i=r.reflect??!1;if(i&&isStructuredValue(r.default))throw new OreApiError(`Prop "${n}": ${t.propInvalidReflect}`);return{...r,reflect:i}}function validatePropDefs(e){let t=[];for(let[n,r]of Object.entries(e))try{normalizePropDefinition(r,n)}catch(e){t.push(e instanceof Error?e.message:String(e))}return t}var p=new WeakMap,getPropMeta=(e,t)=>p.get(e)?.get(t),coerceIncoming=(e,t)=>typeof e==`string`?t(e):e,registerProp=(t,n,r,i)=>{let a=p.get(t);a||(a=new Map,p.set(t,a));let{default:o,parse:s,reflect:c=!1}=i,l=(0,e.signal)(o),u=a.get(r),d=Object.hasOwn(t,n),f=d?t[n]:void 0,m={parse:s,reflect:c,signal:l};return u?l.value=u.signal.peek():d?(delete t[n],l.value=coerceIncoming(f,s)):t.hasAttribute(r)&&(l.value=s(t.getAttribute(r))),a.set(r,m),Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get:()=>l.value,set:e=>{l.value=coerceIncoming(e,s)}}),c&&watchEffect(()=>{let e=l.value;e==null?t.removeAttribute(r):typeof e==`boolean`?t.toggleAttribute(r,e):setAttr(t,r,e)}),l};function createProps(e,t){let n={};for(let[r,i]of Object.entries(t))n[r]=registerProp(e,r,toKebab(r),i);return n}var makeBrand=e=>{let t=Symbol.for(e),stamp=e=>Object.assign(e,{[t]:!0}),is=e=>typeof e==`object`&&!!e&&t in e;return{is,stamp}},m=makeBrand(`ore:css-result`),h=m.is,cssResultToString=function(){return this.content},css=(e,...t)=>{let n=``;for(let r=0;r<e.length;r++)if(n+=e[r],r<t.length){let e=t[r];n+=h(e)?e.content:String(e)}return m.stamp({content:n.trim(),toString:cssResultToString})},g=new Map,_=256,loadStylesheet=e=>{if(e instanceof CSSStyleSheet)return e;let t=typeof e==`string`?e:e.content,n=g.get(t);if(n)return g.delete(t),g.set(t,n),n;let r=new CSSStyleSheet;try{r.replaceSync(t)}catch{return r}if(g.set(t,r),g.size>_){let e=g.keys().next().value;e!==void 0&&g.delete(e)}return r},v={SETUP_DONE:`setup_done`,SETUP_RUNNING:`setup_running`,UNINITIALIZED:`uninitialized`,UNMOUNTED:`unmounted`},createComponentState=()=>({formResetCallbacks:[],generation:0,mountCallbacks:[],phase:v.UNINITIALIZED,scope:(0,e.createScope)(),templateResult:null}),isPromiseLike=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&`then`in e&&typeof e.then==`function`,BaseElement=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=createComponentState()}connectedCallback(){(0,e.untrack)(()=>{this._component.phase===v.UNINITIALIZED&&this._runSetup(),this._init()})}attributeChangedCallback(t,n,r){if(n===r)return;let i=getPropMeta(this,t);if(!i)return;let a=i.parse(r);Object.is((0,e.untrack)(()=>i.signal.value),a)||(i.signal.value=a)}disconnectedCallback(){this._component.generation++,this._component.phase=v.UNMOUNTED,this._resetSetupState()}_resetSetupState(){this._component.scope.dispose(),this._component.formResetCallbacks=[],this._component.mountCallbacks=[],this._component.phase=v.UNINITIALIZED,this._component.scope=(0,e.createScope)(),this._component.templateResult=null}formResetCallback(){for(let e of this._component.formResetCallbacks)try{e()}catch(e){this._reportLifecycleError(e,`form-reset`)}}_reportLifecycleError(e,t){let n=e instanceof Error?e:Error(String(e));reportRuntimeError(new OreLifecycleError(`<${this.localName}> failed during ${this._component.phase} (${t})`,{cause:n,component:this.localName,phase:t}),this)}_runSetup(){this._component.phase=v.SETUP_RUNNING;let e=this.constructor._definition,n=this.constructor._normalizedPropDefs,r=createRuntimeContext(this);try{let i;if(this._component.scope.run(()=>{i=runWithContext(r,()=>{let t=n?createProps(this,n):{};return e.setup(t)})}),this._component.mountCallbacks.push(...r.mountCallbacks),this._component.formResetCallbacks.push(...r.formResetCallbacks),isPromiseLike(i))throw new OreApiError(t.asyncSetupUnsupported);this._component.templateResult=i??null,this._component.phase=v.SETUP_DONE}catch(e){throw this._reportLifecycleError(e,`setup`),this._resetSetupState(),e}}_isStale(e){return this._component.generation!==e||!this.isConnected}_applyResult(e){if(!e)return;let t=this.shadowRoot??this,n=createRuntimeContext(this);t.replaceChildren(),this._component.scope.run(()=>{runWithContext(n,()=>{e.mount(t,null,onCleanup)})})}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===v.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(loadStylesheet))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation,t=beginPendingWork();queueMicrotask(()=>{try{if(this._isStale(e))return;let t=this._component.mountCallbacks.splice(0);for(let e=0;e<t.length;e++){let n=t[e];try{let e=createRuntimeContext(this);this._component.scope.run(()=>{runWithContext(e,()=>{let e=n();typeof e==`function`&&onCleanup(e)})}),e.mountCallbacks.length>0&&t.push(...e.mountCallbacks),e.formResetCallbacks.length>0&&this._component.formResetCallbacks.push(...e.formResetCallbacks)}catch(e){this._reportLifecycleError(e,`mounted`)}}}finally{t()}})}};function define(e,n){if(!e)throw new OreApiError(t.defineRequiresTag);if(customElements.get(e))throw new OreApiError(t.defineDuplicate(e));let{props:r}=n,i=(()=>{if(!r)return;let n=validatePropDefs(r);if(n.length>0)throw new OreApiError(t.validationFailed(e,n));let i={};for(let[e,t]of Object.entries(r))i[e]=normalizePropDefinition(t,e);return i})(),a=i?Object.keys(i).map(toKebab):[],ComponentClass=class extends BaseElement{static _definition=n;static _normalizedPropDefs=i;static formAssociated=n.formAssociated??!1;static observedAttributes=a};return Object.defineProperty(ComponentClass,"name",{value:e}),customElements.define(e,ComponentClass),ComponentClass}var classMap=t=>(0,e.computed)(()=>[...resolveClassTokens(t)].join(` `));function ref(){return(0,e.signal)(null)}var y=makeBrand(`ore:directive`),createDirectiveResult=e=>y.stamp({mount:e}),b=y.is,x=makeBrand(`ore:html-result`),S=x.is;function createHtmlResult(e,t){let mount=(n,r,i)=>{let a=Array.from(e.childNodes);return n.insertBefore(e,r),t(i),a};return x.stamp({apply:t,fragment:e,mount})}var createItem=(t,n,r,i,a)=>{let o=(0,e.signal)(t),s=(0,e.signal)(n),c=(0,e.createScope)(),l=[],u=[];return c.run(()=>{u=r(o,s).mount(i,a,e=>l.push(e))}),{cleanups:l,data:o,index:s,nodes:u,scope:c}},removeItem=e=>{e.scope.dispose(),runAll(e.cleanups),removeNodes(e.nodes)},reconcileItems=(t,n,r,i,a,o,s)=>{for(let c=0;c<n.length;c++){let l=r[c];if(t.has(l))continue;let u=(0,e.untrack)(()=>createItem(n[c],c,i,a,o));s.push(u),t.set(l,u)}let c=[];(0,e.batch)(()=>{for(let e=0;e<n.length;e++){let i=t.get(r[e]);invariant(i,`each() reconcile phase 2 lost an entry created in phase 1`),i.data.value=n[e],i.index.value=e,c.push(i)}});let l=o;for(let e=c.length-1;e>=0;e--){let t=c[e],n=t.nodes[0],r=t.nodes[t.nodes.length-1];if(n&&r!==l.previousSibling)for(let e of t.nodes)a.insertBefore(e,l);l=n??l}let u=new Set(r);for(let[e,n]of t)u.has(e)||(removeItem(n),t.delete(e));return c},rollbackCreated=(e,t)=>{for(let n of t){removeItem(n);for(let[t,r]of e)if(r===n){e.delete(t);break}}},collectKeys=(e,n)=>{let r=[],i=new Set;for(let a=0;a<e.length;a++){let o=n(e[a],a);if(i.has(o))throw new OreApiError(t.eachDuplicateKey(String(o),a));i.add(o),r.push(o)}return r},reportEachError=(e,t)=>{let n=e instanceof Error?e:Error(String(e));reportRuntimeError(new OreLifecycleError(`each() failed to reconcile a list update: ${n.message}`,{cause:n,component:`each()`,phase:`each-reconcile`}),t)};function each(t,n,r,i){let a=Array.isArray(t)?(0,e.signal)(t):typeof t==`function`?(0,e.computed)(t):t;return createDirectiveResult((t,o)=>{let s=t.parentNode;invariant(s,`each() anchor comment has no parent node`);let c=document.createComment(`each/end`);s.insertBefore(c,t.nextSibling);let l=new Map,u=[],d=null,f=[],mountFallback=()=>{i&&(d=i().mount(s,c,e=>f.push(e)))},clearFallback=()=>{d&&(runAll(f),removeNodes(d),d=null,f=[])},p=(0,e.effect)(()=>{let i=a.value??[];if(i.length===0){for(let t of(0,e.untrack)(()=>u))removeItem(t);l=new Map,u=[],d||(0,e.untrack)(mountFallback);return}let o;try{o=(0,e.untrack)(()=>collectKeys(i,n))}catch(e){reportEachError(e,t);return}clearFallback();let f=[];try{u=(0,e.untrack)(()=>reconcileItems(l,i,o,r,s,c,f))}catch(n){reportEachError(n,t),(0,e.untrack)(()=>rollbackCreated(l,f))}});o(()=>p.dispose()),o(()=>{clearFallback();for(let e of u)removeItem(e);c.remove()})})}var C=makeBrand(`ore:live`),live=e=>C.stamp({source:e}),w=C.is,T=makeBrand(`ore:model`),E=T.is,modelDefaultGet=e=>e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`)?e.checked:e.value,modelDefaultEvent=e=>e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`)||e instanceof HTMLSelectElement?`change`:`input`,model=(e,t)=>T.stamp({event:t?.event,get:t?.get,source:e}),styleMap=t=>(0,e.computed)(()=>{let e=[];for(let[n,r]of Object.entries(t)){let t=cssDeclarationValue(r);if(!t)continue;let i=cssDeclarationName(n);i&&e.push(`${i}:${t}`)}return e.join(`;`)}),parseHtml=(e,t,n)=>{let r=document.createElement(`template`);r.innerHTML=e;let i=Array.from(r.content.cloneNode(!0).childNodes);for(let e of i)t.insertBefore(e,n);return i};function unsafeHtml(t){let n=typeof t==`function`?(0,e.computed)(t):(0,e.isReactive)(t)?t:null;return createDirectiveResult((r,i)=>{let a=r.parentNode;invariant(a,`unsafeHtml() anchor comment has no parent node`);let o=document.createComment(`unsafe-html/end`);if(a.insertBefore(o,r.nextSibling),n){let t=createReplaceableSlot(),r=(0,e.effect)(()=>{t.clear(),t.setNodes(parseHtml(n.value,a,o))});i(()=>r.dispose()),i(()=>{t.clear(),o.remove()})}else parseHtml(t,a,o),i(()=>o.remove())})}var D=`when() anchor comment has no parent node`;function when(t,n,r){return typeof t!=`function`&&!(0,e.isReactive)(t)?createDirectiveResult((e,i)=>{let a=t?n():r?r():null;if(!a||!S(a))return;let o=e.parentNode;invariant(o,D);let s=a.mount(o,e,i);i(()=>removeNodes(s))}):createDirectiveResult((i,a)=>{let o=(typeof t==`function`?(0,e.computed)(t):null)??t,s=i.parentNode;invariant(s,D);let c=document.createComment(`when/end`);s.insertBefore(c,i.nextSibling);let l=createReplaceableSlot(),u=(0,e.effect)(()=>{let t=o.value;l.clear();let i=t?n():r?r():null;i&&S(i)&&l.setNodes((0,e.untrack)(()=>i.mount(s,c,l.registerCleanup)))});a(()=>u.dispose()),a(()=>{l.clear(),c.remove()})})}var O=new WeakMap,k=new WeakSet,useField=e=>{let n=getHost();if(!n.constructor.formAssociated)throw new OreApiError(t.defineFieldRequiresFormAssociated(n.localName));if(k.has(n))throw new OreApiError(t.useFieldAlreadyCalled(n.localName));let r=O.get(n)??n.attachInternals();O.set(n,r),k.add(n),onCleanup(()=>k.delete(n));let i=e.toFormValue??(t=>t==null?e.emptyStringForNull?``:null:t instanceof File||t instanceof FormData?t:String(t));watchEffect(()=>{r.setFormValue(i(e.value.value))});let a=e.disabled;if(a&&`states`in r){let e=r.states;watchEffect(()=>{a.value?e.add(`disabled`):e.delete(`disabled`)})}e.validity&&watchEffect(()=>{let t=e.validity?.value;if(!t){r.setValidity({});return}let n=Object.values(t.flags).some(Boolean);r.setValidity(t.flags,n&&!t.message?`Invalid value.`:t.message)}),e.onReset&&onFormReset(e.onReset);let checkValidity=()=>r.checkValidity(),reportValidity=()=>r.reportValidity(),setCustomValidity=e=>e?r.setValidity({customError:!0},e):r.setValidity({});return{checkValidity,internals:r,reportValidity,setCustomValidity}},normalizeHostAttrKey=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:e,bind=(e,t)=>{let n=t?.target??getHost(),r=[];if(e.attr)for(let[t,i]of Object.entries(e.attr)){let e=applyAttribute(n,A(t),i);e&&r.push(e)}if(e.class&&r.push(applyClassMap(n,e.class)),e.style)for(let[t,i]of Object.entries(e.style)){let e=applyStyle(n,t,i);e&&r.push(e)}if(e.on){let{target:i,...a}=t??{};for(let t of Object.keys(e.on)){let i=e.on[t];i&&r.push(listen(n,t,i,a))}}let cleanup=()=>{for(let e of r)e()};return tryRegisterCleanup(cleanup),cleanup},A=normalizeHostAttrKey,applyReactiveBinding=(t,n)=>{if(typeof t==`function`)return watchEffect(()=>{n(t())});if((0,e.isReactive)(t))return watchEffect(()=>{n(t.value)});n(t)};function applyAttribute(e,t,n){return applyReactiveBinding(n,n=>setAttr(e,t,n))}function applyStyle(e,t,n){let r=cssDeclarationName(t);if(!r)return;let i=!1,setStyle=t=>{let n=cssDeclarationValue(t);n?(i=!0,e.style.setProperty(r,n)):i&&e.style.removeProperty(r)};return applyReactiveBinding(n,setStyle)}function applyClassMap(e,t){let n=typeof t==`function`?t:()=>Object.fromEntries([...resolveClassTokens(t)].map(e=>[e,!0])),r=new Set;return watchEffect(()=>{let t=new Set;for(let[i,a]of Object.entries(n()))a&&(t.add(i),r.has(i)||e.classList.add(i));for(let n of r)t.has(n)||e.classList.remove(n);r=t})}var j=`default`,normalizeSlotName=e=>e||j,createSlots=t=>{let n=new Map,r=new Map,i=new Map,ensureSlotEntry=t=>{let r=n.get(t);return r||(r={elements:(0,e.signal)([]),presence:(0,e.signal)(!1)},n.set(t,r)),r},areElementsEqual=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},recomputeSlot=e=>{let t=normalizeSlotName(e),n=r.get(t),i=[];if(n)for(let e of n)i.push(...e.assignedElements({flatten:!0}));let a=ensureSlotEntry(t);areElementsEqual(a.elements.value,i)||(a.elements.value=i);let o=i.length>0;a.presence.value!==o&&(a.presence.value=o)},bindSlot=e=>{if(i.has(e))return;let t=normalizeSlotName(e.getAttribute(`name`)),n=r.get(t)??new Set;n.add(e),r.set(t,n);let onChange=()=>recomputeSlot(t);e.addEventListener(`slotchange`,onChange),i.set(e,()=>{e.removeEventListener(`slotchange`,onChange)}),recomputeSlot(t)},unbindSlot=e=>{let t=i.get(e);if(!t)return;t(),i.delete(e);let n=normalizeSlotName(e.getAttribute(`name`)),a=r.get(n);a&&(a.delete(e),a.size===0&&r.delete(n)),recomputeSlot(n)},bindAllSlots=()=>{t.shadowRoot?.querySelectorAll(`slot`).forEach(e=>{bindSlot(e)})},recomputeAllSlots=()=>{for(let e of r.keys())recomputeSlot(e)},a=null,initSlots=()=>{bindAllSlots(),recomputeAllSlots(),!a&&t.shadowRoot&&(a=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)e instanceof HTMLSlotElement&&unbindSlot(e);bindAllSlots(),i.size>0&&recomputeAllSlots()}),a.observe(t.shadowRoot,{childList:!0,subtree:!0}))};return onMounted(initSlots),onCleanup(()=>{a?.disconnect(),a=null;for(let e of i.values())e();i.clear(),r.clear(),n.clear(),M.delete(t)}),{elements:e=>ensureSlotEntry(normalizeSlotName(e)).elements,has:e=>ensureSlotEntry(normalizeSlotName(e)).presence}},M=new WeakMap,useSlots=()=>{let e=requireSetupContext(`useSlots`),t=M.get(e.element);return t||(t=createSlots(e.element),M.set(e.element,t)),t},signalEffect=(t,n,r)=>{let i=(0,e.effect)(()=>{n(t.value)});r(()=>i.dispose())},isNativeFormInput=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,isCheckableInput=e=>e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`),syncFormControl=(e,t,n,r={last:void 0})=>{let i=isCheckableInput(e),a=i?!!t:t==null?``:String(t),o=i?e.checked:e.value;(!n||r.last===void 0||Object.is(o,r.last)||Object.is(o,a))&&(i?e.checked=a:e.value=a,n&&(r.last=a))},syncRegisteredProp=(t,n,r,i)=>{let a=isStructuredValue(i)?i:n.parse(r.mode===`bool`?i?``:null:i==null||i===!1?null:String(i));if(Object.is((0,e.untrack)(()=>n.signal.value),a)||(n.signal.value=a),!n.reflect){if(isStructuredValue(i))return;r.mode===`bool`?t.toggleAttribute(r.name,!!i):setAttr(t,r.name,i)}},applyAttrBinding=(e,t)=>{let{el:n,mode:r,name:i}=e,a={last:void 0},update=t=>{let o=getPropMeta(n,i);o?syncRegisteredProp(n,o,e,t):i===`value`&&isNativeFormInput(n)||i===`checked`&&n instanceof HTMLInputElement?syncFormControl(n,t,e.live,a):i===`indeterminate`&&n instanceof HTMLInputElement?n.indeterminate=!!t:r===`bool`?n.toggleAttribute(i,!!t):setAttr(n,i,t)};`signal`in e?signalEffect(e.signal,update,t):update(e.value)},applyEventBinding=(e,t)=>{let{modifiers:n}=e,r=n?.stop||n?.prevent?t=>{n.stop&&t.stopPropagation(),n.prevent&&t.preventDefault(),e.handler(t)}:e.handler,i=n?.once||n?.capture?{capture:n.capture,once:n.once}:void 0;t(listen(e.el,e.name,r,i))},applyPropBinding=(e,t)=>{let update=t=>{e.el[e.name]=t};`signal`in e?signalEffect(e.signal,update,t):update(e.value)},applyModelBinding=(t,n)=>{let{el:r,get:i,signal:a}=t,o={last:void 0},write=e=>{isNativeFormInput(r)?syncFormControl(r,e,!0,o):r.value=e},s=(0,e.effect)(()=>{write(a.value)}),onEvent=()=>{let t=i(r);Object.is((0,e.untrack)(()=>a.value),t)||(a.value=t)};n(()=>s.dispose()),n(listen(r,t.event,onEvent))},applyRefBinding=(e,t)=>{let{el:n,ref:r}=e;typeof r==`function`?(r(n),t(()=>r(null))):(r.value=n,t(()=>{r.value=null}))},insertHtmlValues=(e,t,n)=>{let r=[],i=t.parentNode;invariant(i,`html binding anchor has no parent node`);for(let a of e)if(S(a)){let e=Array.from(a.fragment.childNodes);i.insertBefore(a.fragment,t),a.apply(n),r.push(...e)}else if(a!=null&&a!==!1){let e=document.createTextNode(String(a));i.insertBefore(e,t),r.push(e)}return r},applyHtmlBinding=(t,n)=>{let{anchor:r,signal:i}=t,a=createReplaceableSlot(),o=(0,e.effect)(()=>{let t=i.value;a.clear(),t!=null&&t.length!==0&&(0,e.untrack)(()=>{a.setNodes(insertHtmlValues(t,r,a.registerCleanup))})});n(()=>{o.dispose(),a.clear()})},applyDirectiveBinding=(e,t)=>{e.directive.mount(e.anchor,t)},applyBinding=(e,t)=>{switch(e.type){case`attr`:applyAttrBinding(e,t);break;case`directive`:applyDirectiveBinding(e,t);break;case`event`:applyEventBinding(e,t);break;case`html`:applyHtmlBinding(e,t);break;case`model`:applyModelBinding(e,t);break;case`prop`:applyPropBinding(e,t);break;case`ref`:applyRefBinding(e,t)}},createAttrBindingFromValue=(t,n,r,i)=>w(i)?{el:t,live:!0,mode:n,name:r,signal:i.source,type:`attr`}:typeof i==`function`?{el:t,mode:n,name:r,signal:(0,e.computed)(i),type:`attr`}:(0,e.isReactive)(i)?{el:t,mode:n,name:r,signal:i,type:`attr`}:{el:t,mode:n,name:r,type:`attr`,value:i},resolveStaticText=e=>e==null?``:String(e),N={ATTR:`attr`,BOOL_ATTR:`boolAttr`,EVENT:`event`,NODE:`node`,PROP:`prop`,REF:`ref`},P={capture:!0,once:!0,prevent:!0,stop:!0},parseEventModifiers=(e,n)=>{if(n.length===0)return;let r={};for(let i of n){if(!(i in P))throw new OreApiError(t.eventModifierUnknown(e,i));r[i]=!0}return r},F=/\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/,I=/\s+ref\s*=\s*["']?$/,L=/\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,R=/\s+\.([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,z=/\s+([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,B=new Set([`innerhtml`,`outerhtml`,`srcdoc`]),detectSlot=e=>{let n;if(n=F.exec(e)){let t=e.slice(0,-n[0].length),[r,...i]=n[1].split(`.`);return{eventModifiers:parseEventModifiers(r,i),kind:N.EVENT,name:r,prefix:t}}if(n=I.exec(e))return{kind:N.REF,prefix:e.slice(0,-n[0].length)};if(n=L.exec(e))return{kind:N.BOOL_ATTR,name:n[1],prefix:e.slice(0,-n[0].length)};if(n=R.exec(e)){let r=n[1];if(r===`__proto__`||r===`constructor`||r===`prototype`)throw new OreApiError(t.propBindingForbiddenName(r));if(B.has(r.toLowerCase()))throw new OreApiError(t.propBindingHtmlInjectionName(r));return{kind:N.PROP,name:r,prefix:e.slice(0,-n[0].length)}}if(n=z.exec(e))return{kind:N.ATTR,name:n[1],prefix:e.slice(0,-n[0].length)};let r=e.lastIndexOf(`<`);if(r>e.lastIndexOf(`>`)&&e[r+1]!==`/`)throw new OreApiError(t.templateInterpolationInTag);return{kind:N.NODE,prefix:e}},V=new WeakMap,H=/[@?]?[a-zA-Z_][-a-zA-Z0-9_.]*\s*=\s*$/,normalizeTemplateStrings=e=>{let t=Array.from(e),n=!1;for(let e=0;e<t.length-1;e++){let r=t[e],i=r[r.length-1];for(let e of r)e===`<`?n=!0:e===`>`&&(n=!1);if((i===`"`||i===`'`)&&n&&H.test(r.slice(0,-1))){t[e]=r.slice(0,-1);let n=t[e+1];n.startsWith(i)&&(t[e+1]=n.slice(1))}}return t},U=`data-ore-b`,W=/^ore:(\d+)$/,walkNode=(e,t,n,r)=>{if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.getAttribute(U);i!==null&&(n.set(Number(i),[...t]),r.removeAttribute(U))}else if(e.nodeType===Node.COMMENT_NODE){let n=e.nodeValue,i=n===null?null:W.exec(n);i&&r.set(Number(i[1]),[...t])}let i=e.childNodes;for(let e=0;e<i.length;e++)walkNode(i[e],[...t,e],n,r)},buildStaticTemplate=e=>{let t=normalizeTemplateStrings(e),n=``,r,i=0,a=0,o=[];for(let e=0;e<t.length-1;e++){let s=t[e],c=detectSlot(s);if(c.kind===N.NODE)n+=`${c.prefix}<!--ore:${a}-->`,o.push({commentId:a,kind:N.NODE}),a++,r=void 0;else{r===void 0||c.prefix.lastIndexOf(`<`)>c.prefix.lastIndexOf(`>`)?(r=i++,n+=`${c.prefix} ${U}="${r}"`):n+=c.prefix;let e=c.kind===N.BOOL_ATTR?`bool`:c.kind===N.ATTR?`attr`:void 0;o.push({elementId:r,eventModifiers:c.eventModifiers,kind:c.kind,mode:e,name:c.name})}}n+=t[t.length-1]??``;let s=document.createElement(`template`);s.innerHTML=n;let c=new Map,l=new Map,u=s.content.childNodes;for(let e=0;e<u.length;e++)walkNode(u[e],[e],c,l);return{commentPaths:l,element:s,elementPaths:c,slots:o}},getStaticTemplate=e=>{let t=V.get(e);return t||(t=buildStaticTemplate(e),V.set(e,t)),t},followPath=(e,t)=>{let n=e;for(let e of t)n=n.childNodes[e];return n},G="html`...`: node-slot comment anchor has no parent node",toHtmlValues=e=>Array.isArray(e)?e:[e],embedStaticResult=(e,t,n)=>{let r=t.parentNode;for(invariant(r,G);e.fragment.firstChild;)r.insertBefore(e.fragment.firstChild,t);n.push(e.apply.bind(e))},compileTemplate=(n,r)=>{let i=getStaticTemplate(n),a=i.element.content.cloneNode(!0),o=[],s=[],c=i.slots.map((e,t)=>{let n=r[t];if(e.kind===N.NODE){let t=e.commentId===void 0?void 0:i.commentPaths.get(e.commentId);return invariant(t,`compiled template is missing a comment path for node slot ${e.commentId}`),{comment:followPath(a,t),slot:e,value:n}}let o=e.elementId===void 0?void 0:i.elementPaths.get(e.elementId);return invariant(o,`compiled template is missing an element path for slot ${e.elementId}`),{el:followPath(a,o),slot:e,value:n}});for(let{comment:n,el:r,slot:i,value:a}of c)if(i.kind===N.NODE){let t=n;if(invariant(t,`compiled template produced a node slot without a comment anchor`),b(a)){o.push({anchor:t,directive:a,type:`directive`});continue}if(S(a)){embedStaticResult(a,t,s),t.remove();continue}if(typeof a==`function`||(0,e.isReactive)(a)){let n=typeof a==`function`?(0,e.computed)(()=>toHtmlValues(a())):(0,e.computed)(()=>toHtmlValues(a.value));o.push({anchor:t,signal:n,type:`html`});continue}if(Array.isArray(a)){for(let e of a)if(S(e))embedStaticResult(e,t,s);else{let n=t.parentNode;invariant(n,G),n.insertBefore(document.createTextNode(resolveStaticText(e)),t)}t.remove();continue}t.replaceWith(document.createTextNode(resolveStaticText(a)))}else if(invariant(r,`compiled template produced an element slot without an element`),i.kind===N.EVENT){let t=i.name;if(invariant(t,`compiled template produced an event slot without an event name`),typeof a==`function`)o.push({el:r,handler:a,modifiers:i.eventModifiers,name:t,type:`event`});else if((0,e.isReactive)(a)){let e=a,handler=t=>{let n=e.value;typeof n==`function`&&n(t)};o.push({el:r,handler,modifiers:i.eventModifiers,name:t,type:`event`})}}else if(i.kind===N.PROP){let t=i.name;invariant(t,`compiled template produced a prop slot without a property name`),typeof a==`function`?o.push({el:r,name:t,signal:(0,e.computed)(a),type:`prop`}):(0,e.isReactive)(a)?o.push({el:r,name:t,signal:a,type:`prop`}):o.push({el:r,name:t,type:`prop`,value:a})}else if(i.kind===N.REF)a&&o.push({el:r,ref:a,type:`ref`});else if(invariant(i.name,`compiled template produced an attr slot without an attribute name`),E(a)){if(i.mode!==`attr`)throw new OreApiError(t.modelRequiresValueBinding(i.name));o.push({el:r,event:a.event??modelDefaultEvent(r),get:a.get??modelDefaultGet,signal:a.source,type:`model`})}else o.push(createAttrBindingFromValue(r,i.mode??`attr`,i.name,a));return createHtmlResult(a,e=>{for(let t of o)applyBinding(t,e);for(let t of s)t(e)})},html=(e,...t)=>compileTemplate(e,t),K={bubbles:!0,cancelable:!0,composed:!0},useEmit=()=>{let e=getHost();return((t,...n)=>{let r=n.length>0?{...K,detail:n[0]}:K;return e.dispatchEvent(new CustomEvent(String(t),r))})},q=0,J=Math.random().toString(36).slice(2,6),createId=(e=`id`)=>`${e}-${J}${++q}`;exports.OreApiError=OreApiError,exports.OreError=OreError,exports.OreInternalError=OreInternalError,exports.OreLifecycleError=OreLifecycleError,exports.bind=bind,exports.classMap=classMap,exports.createContext=createContext,exports.createId=createId,exports.css=css,exports.define=define,exports.each=each,exports.getHost=getHost,exports.html=html,exports.inject=inject,exports.injectStrict=injectStrict,exports.live=live,exports.model=model,exports.onCleanup=onCleanup,exports.onElement=onElement,exports.onEvent=onEvent,exports.onFormReset=onFormReset,exports.onMounted=onMounted,exports.prop=f,exports.provide=provide,exports.ref=ref,exports.styleMap=styleMap,exports.unsafeHtml=unsafeHtml,exports.useEmit=useEmit,exports.useField=useField,exports.useSlots=useSlots,exports.watchEffect=watchEffect,exports.when=when;
|
|
3
3
|
//# sourceMappingURL=ore.cjs.map
|