@vielzeug/ore 26.11.9 → 26.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-element.cjs +1 -1
- package/dist/base-element.cjs.map +1 -1
- package/dist/base-element.d.ts +12 -39
- package/dist/base-element.d.ts.map +1 -1
- package/dist/base-element.js +1 -1
- package/dist/base-element.js.map +1 -1
- package/dist/context.cjs.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/define.cjs +1 -1
- package/dist/define.cjs.map +1 -1
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +1 -1
- package/dist/define.js.map +1 -1
- package/dist/directives/each.cjs +1 -1
- package/dist/directives/each.cjs.map +1 -1
- package/dist/directives/each.d.ts.map +1 -1
- package/dist/directives/each.js +1 -1
- package/dist/directives/each.js.map +1 -1
- package/dist/directives/model.cjs.map +1 -1
- package/dist/directives/model.d.ts +2 -3
- package/dist/directives/model.d.ts.map +1 -1
- package/dist/directives/model.js.map +1 -1
- package/dist/directives/unsafe-html.cjs +1 -1
- package/dist/directives/unsafe-html.cjs.map +1 -1
- package/dist/directives/unsafe-html.d.ts.map +1 -1
- package/dist/directives/unsafe-html.js +1 -1
- package/dist/directives/unsafe-html.js.map +1 -1
- package/dist/directives/when.cjs +1 -1
- package/dist/directives/when.cjs.map +1 -1
- package/dist/directives/when.d.ts.map +1 -1
- package/dist/directives/when.js +1 -1
- package/dist/directives/when.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/host-bind.cjs +1 -1
- package/dist/host-bind.cjs.map +1 -1
- package/dist/host-bind.d.ts +2 -2
- package/dist/host-bind.js +1 -1
- package/dist/host-bind.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +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 +411 -424
- package/dist/ore.js.map +1 -1
- package/dist/props.cjs +1 -1
- package/dist/props.cjs.map +1 -1
- package/dist/props.d.ts +6 -10
- package/dist/props.d.ts.map +1 -1
- package/dist/props.js +1 -1
- package/dist/props.js.map +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.ts +22 -9
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/slots.cjs.map +1 -1
- package/dist/slots.d.ts.map +1 -1
- package/dist/slots.js.map +1 -1
- package/dist/template/binding-types.d.ts +3 -9
- package/dist/template/binding-types.d.ts.map +1 -1
- package/dist/template/bindings.cjs +1 -1
- package/dist/template/bindings.cjs.map +1 -1
- package/dist/template/bindings.d.ts +8 -9
- package/dist/template/bindings.d.ts.map +1 -1
- package/dist/template/bindings.js +1 -1
- package/dist/template/bindings.js.map +1 -1
- package/dist/template/instantiator.cjs +1 -1
- package/dist/template/instantiator.cjs.map +1 -1
- package/dist/template/instantiator.d.ts.map +1 -1
- package/dist/template/instantiator.js +1 -1
- package/dist/template/instantiator.js.map +1 -1
- package/dist/template/result.cjs +1 -1
- package/dist/template/result.cjs.map +1 -1
- package/dist/template/result.d.ts +10 -16
- package/dist/template/result.d.ts.map +1 -1
- package/dist/template/result.js +1 -1
- package/dist/template/result.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/mount.cjs +1 -1
- package/dist/testing/mount.cjs.map +1 -1
- package/dist/testing/mount.d.ts.map +1 -1
- package/dist/testing/mount.js +1 -1
- package/dist/testing/mount.js.map +1 -1
- package/dist/testing/render-hook.cjs +1 -1
- package/dist/testing/render-hook.cjs.map +1 -1
- package/dist/testing/render-hook.d.ts +16 -13
- package/dist/testing/render-hook.d.ts.map +1 -1
- package/dist/testing/render-hook.js +1 -1
- package/dist/testing/render-hook.js.map +1 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/utils/brand.cjs.map +1 -1
- package/dist/utils/brand.d.ts +1 -1
- package/dist/utils/brand.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 +12 -10
- 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 +5 -5
- package/dist/directives/live.cjs +0 -2
- package/dist/directives/live.cjs.map +0 -1
- package/dist/directives/live.d.ts +0 -23
- package/dist/directives/live.d.ts.map +0 -1
- package/dist/directives/live.js +0 -2
- package/dist/directives/live.js.map +0 -1
package/dist/ore.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { batch as e, computed as t, createScope as n, effect as r, isReactive as i,
|
|
1
|
+
import { batch as e, computed as t, createScope as n, effect as r, isReactive as i, onCleanup as a, signal as o, untrack as s } from "@vielzeug/ripple";
|
|
2
2
|
// src/errors.ts
|
|
3
3
|
var OreError = class extends Error {
|
|
4
4
|
constructor(e, t) {
|
|
@@ -18,18 +18,20 @@ function reportRuntimeError(e, t) {
|
|
|
18
18
|
detail: e
|
|
19
19
|
}));
|
|
20
20
|
}
|
|
21
|
-
var
|
|
21
|
+
var c = {
|
|
22
22
|
asyncSetupUnsupported: "setup() must return an HTMLResult or null; use reactive state for asynchronous work",
|
|
23
23
|
defineDuplicate: (e) => `define('${e}') called twice: custom element already registered`,
|
|
24
24
|
defineFieldRequiresFormAssociated: (e) => `useField() requires define('${e}', { formAssociated: true })`,
|
|
25
25
|
defineRequiresTag: "define() requires a tag name",
|
|
26
26
|
eachDuplicateKey: (e, t) => `each() received duplicate key "${e}" at index ${t}`,
|
|
27
27
|
eventModifierUnknown: (e, t) => `@${e}.${t}: unknown event modifier "${t}". Supported: .stop, .prevent, .once, .capture`,
|
|
28
|
+
htmlResultReused: "html`...` result was already rendered: each result renders once. Call the template function again for another copy.",
|
|
28
29
|
injectStrictFailed: (e, t) => `injectStrict() could not resolve key "${e}" in <${t}>`,
|
|
29
30
|
invariantViolated: (e) => `invariant violated: ${e}`,
|
|
30
31
|
lifecycleOutsideSetup: "Lifecycle hooks must be called during component setup",
|
|
31
32
|
listenNullTarget: (e) => `listen() called with a null/undefined target for event "${e}": listener not attached`,
|
|
32
33
|
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)}.`,
|
|
34
|
+
notAnHtmlResult: "expected an html`...` result",
|
|
33
35
|
propBindingForbiddenName: (e) => `html\`...\`: ".${e}" is a forbidden property-binding name (prototype pollution guard)`,
|
|
34
36
|
propBindingHtmlInjectionName: (e) => `html\`...\`: ".${e}" parses raw HTML and is not a supported property binding. Sanitize untrusted content, then bind it with the unsafeHtml() directive.`,
|
|
35
37
|
propInvalidReflect: "Structured props cannot use reflect:true: use prop.json() with reflect:false",
|
|
@@ -38,30 +40,35 @@ var s = {
|
|
|
38
40
|
validationFailed: (e, t) => `Validation failed for <${e}>:\n${t.join("\n")}`
|
|
39
41
|
};
|
|
40
42
|
function invariant(e, t) {
|
|
41
|
-
if (!e) throw new OreInternalError(
|
|
43
|
+
if (!e) throw new OreInternalError(c.invariantViolated(t));
|
|
42
44
|
}
|
|
43
45
|
// src/utils/dom.ts
|
|
44
|
-
var resolveMaybeReactive = (e) => typeof e == "function" ? e() : i(e) ? e.value : e,
|
|
45
|
-
for (let t = e.length - 1; t >= 0; t--) e[t]?.();
|
|
46
|
-
}, removeNodes = (e) => {
|
|
46
|
+
var resolveMaybeReactive = (e) => typeof e == "function" ? e() : i(e) ? e.value : e, l = /[;{}]/g, sanitizeCssToken = (e) => e.replace(l, ""), removeNodes = (e) => {
|
|
47
47
|
for (let t of e) t.remove();
|
|
48
48
|
}, createReplaceableSlot = () => {
|
|
49
|
-
let e = [], t =
|
|
49
|
+
let e = [], t = null, clear = () => {
|
|
50
|
+
t?.dispose(), t = null, removeNodes(e), e = [];
|
|
51
|
+
};
|
|
50
52
|
return {
|
|
51
|
-
clear
|
|
52
|
-
runAll(t), removeNodes(e), t = [], e = [];
|
|
53
|
-
},
|
|
53
|
+
clear,
|
|
54
54
|
get nodes() {
|
|
55
55
|
return e;
|
|
56
56
|
},
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
render(e) {
|
|
58
|
+
clear();
|
|
59
|
+
let r = n();
|
|
60
|
+
t = r;
|
|
61
|
+
try {
|
|
62
|
+
return r.run(e);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
throw r.dispose(), t = null, e;
|
|
65
|
+
}
|
|
59
66
|
},
|
|
60
67
|
setNodes(t) {
|
|
61
68
|
e = t;
|
|
62
69
|
}
|
|
63
70
|
};
|
|
64
|
-
},
|
|
71
|
+
}, u = /* @__PURE__ */ new Set([
|
|
65
72
|
"action",
|
|
66
73
|
"cite",
|
|
67
74
|
"codebase",
|
|
@@ -73,15 +80,15 @@ var resolveMaybeReactive = (e) => typeof e == "function" ? e() : i(e) ? e.value
|
|
|
73
80
|
"poster",
|
|
74
81
|
"src",
|
|
75
82
|
"xlink:href"
|
|
76
|
-
]),
|
|
77
|
-
let t =
|
|
83
|
+
]), d = /^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i, f = /[\t\n\r]/g, p = /^[\s\p{C}]+|[\s\p{C}]+$/gu, normalizeUrlForSchemeCheck = (e) => e.replace(f, "").replace(p, ""), isDangerousUrl = (e) => d.test(normalizeUrlForSchemeCheck(e)), m = /* @__PURE__ */ new Map(), h = 512, getAttrWritePlan = (e) => {
|
|
84
|
+
let t = m.get(e);
|
|
78
85
|
if (t) return t;
|
|
79
86
|
let n = e.toLowerCase(), r = {
|
|
80
87
|
event: /^on[a-z]/i.test(e),
|
|
81
88
|
srcdoc: n === "srcdoc",
|
|
82
|
-
url:
|
|
89
|
+
url: u.has(n)
|
|
83
90
|
};
|
|
84
|
-
return
|
|
91
|
+
return m.size >= h && m.clear(), m.set(e, r), r;
|
|
85
92
|
}, setAttr = (e, t, n) => {
|
|
86
93
|
let r = getAttrWritePlan(t);
|
|
87
94
|
if (r.event) {
|
|
@@ -95,7 +102,7 @@ var resolveMaybeReactive = (e) => typeof e == "function" ? e() : i(e) ? e.value
|
|
|
95
102
|
let i = n === !0 ? "true" : String(n);
|
|
96
103
|
r.url && isDangerousUrl(i) ? (`${t}`, e.removeAttribute(t)) : e.setAttribute(t, i);
|
|
97
104
|
}, listen = (e, t, n, r) => {
|
|
98
|
-
if (!e) return
|
|
105
|
+
if (!e) return c.listenNullTarget(t), () => {};
|
|
99
106
|
let i = n;
|
|
100
107
|
return e.addEventListener(t, i, r), () => e.removeEventListener(t, i, r);
|
|
101
108
|
}, toKebab = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), cssDeclarationName = (e) => sanitizeCssToken(e.startsWith("--") ? e : toKebab(e)), cssDeclarationValue = (e) => {
|
|
@@ -109,79 +116,79 @@ var resolveMaybeReactive = (e) => typeof e == "function" ? e() : i(e) ? e.value
|
|
|
109
116
|
e && t.add(e);
|
|
110
117
|
}
|
|
111
118
|
return t;
|
|
112
|
-
}, isStructuredValue = (e) => Array.isArray(e) || typeof e == "object" && !!e,
|
|
119
|
+
}, isStructuredValue = (e) => Array.isArray(e) || typeof e == "object" && !!e, g = null, createRuntimeContext = (e) => ({
|
|
113
120
|
element: e,
|
|
114
121
|
formResetCallbacks: [],
|
|
115
|
-
mountCallbacks: []
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
mountCallbacks: [],
|
|
123
|
+
scope: n()
|
|
124
|
+
}), _ = 0, beginPendingWork = () => {
|
|
125
|
+
_++;
|
|
118
126
|
let e = !1;
|
|
119
127
|
return () => {
|
|
120
|
-
e || (e = !0,
|
|
128
|
+
e || (e = !0, _--);
|
|
121
129
|
};
|
|
122
130
|
}, runWithContext = (e, t) => {
|
|
123
|
-
let n =
|
|
124
|
-
|
|
131
|
+
let n = g;
|
|
132
|
+
g = e;
|
|
125
133
|
try {
|
|
126
|
-
return t
|
|
134
|
+
return e.scope.run(t);
|
|
127
135
|
} finally {
|
|
128
|
-
|
|
136
|
+
g = n;
|
|
129
137
|
}
|
|
130
138
|
}, requireSetupContext = (e) => {
|
|
131
|
-
if (
|
|
132
|
-
throw new OreApiError(`${e}: ${
|
|
133
|
-
}, getHost = () => requireSetupContext("getHost").element,
|
|
134
|
-
|
|
139
|
+
if (g) return g;
|
|
140
|
+
throw new OreApiError(`${e}: ${c.lifecycleOutsideSetup}`);
|
|
141
|
+
}, getHost = () => requireSetupContext("getHost").element, hasSetupContext = () => g !== null, onCleanup = (e) => {
|
|
142
|
+
requireSetupContext("onCleanup"), a(e);
|
|
135
143
|
}, onMounted = (e) => {
|
|
136
144
|
requireSetupContext("onMounted").mountCallbacks.push(e);
|
|
137
145
|
}, onFormReset = (e) => {
|
|
138
146
|
requireSetupContext("onFormReset").formResetCallbacks.push(e);
|
|
139
147
|
}, watchEffect = (e) => {
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
requireSetupContext("watchEffect");
|
|
149
|
+
let t = r(e);
|
|
150
|
+
return () => t.dispose();
|
|
142
151
|
};
|
|
143
152
|
function onEvent(e, t, n, r) {
|
|
144
|
-
|
|
145
|
-
let i = listen(e, t, n, r);
|
|
146
|
-
tryRegisterCleanup(i) || i();
|
|
153
|
+
requireSetupContext("onEvent"), e && a(listen(e, t, n, r));
|
|
147
154
|
}
|
|
148
155
|
var onElement = (e, t) => watchEffect(() => {
|
|
149
156
|
let n = e.value;
|
|
150
157
|
if (n) return t(n);
|
|
151
|
-
}),
|
|
158
|
+
}), v = /* @__PURE__ */ new WeakMap(), buildAncestorChain = (e) => {
|
|
152
159
|
let t = [], n = e;
|
|
153
160
|
for (; n;) n instanceof HTMLElement && t.push(n), n = n.parentNode ?? (n instanceof ShadowRoot ? n.host : null);
|
|
154
161
|
return t;
|
|
155
162
|
}, provideOnElement = (e, t, n) => {
|
|
156
|
-
let r =
|
|
157
|
-
r.has(t) && `${e.localName}`, r.set(t, n),
|
|
163
|
+
let r = v.get(e) ?? /* @__PURE__ */ new Map();
|
|
164
|
+
r.has(t) && `${e.localName}`, r.set(t, n), v.set(e, r);
|
|
158
165
|
}, provide = (e, t) => {
|
|
159
166
|
let n = requireSetupContext("provide").element;
|
|
160
167
|
provideOnElement(n, e, t), onCleanup(() => {
|
|
161
|
-
let t =
|
|
162
|
-
t && (t.delete(e), t.size === 0 &&
|
|
168
|
+
let t = v.get(n);
|
|
169
|
+
t && (t.delete(e), t.size === 0 && v.delete(n));
|
|
163
170
|
});
|
|
164
|
-
},
|
|
171
|
+
}, y = Symbol("inject.not_found"), b = /* @__PURE__ */ new WeakMap(), walkAndFind = (e, t) => {
|
|
165
172
|
let n = buildAncestorChain(e);
|
|
166
173
|
for (let e of n) {
|
|
167
|
-
let n =
|
|
174
|
+
let n = v.get(e);
|
|
168
175
|
if (n?.has(t)) return n.get(t);
|
|
169
176
|
}
|
|
170
|
-
return
|
|
177
|
+
return y;
|
|
171
178
|
}, lookup = (e, t) => {
|
|
172
|
-
let n =
|
|
173
|
-
n || (n = /* @__PURE__ */ new Map(),
|
|
179
|
+
let n = b.get(e);
|
|
180
|
+
n || (n = /* @__PURE__ */ new Map(), b.set(e, n));
|
|
174
181
|
let r = t;
|
|
175
182
|
return n.has(r) || n.set(r, walkAndFind(e.element, t)), n.get(r);
|
|
176
183
|
};
|
|
177
184
|
function inject(e, ...t) {
|
|
178
185
|
let n = lookup(requireSetupContext("inject"), e);
|
|
179
|
-
return n ===
|
|
186
|
+
return n === y ? t.length > 0 ? t[0] : void 0 : n;
|
|
180
187
|
}
|
|
181
188
|
var injectStrict = (e) => {
|
|
182
189
|
let t = requireSetupContext("injectStrict"), n = lookup(t, e);
|
|
183
|
-
if (n !==
|
|
184
|
-
throw new OreApiError(
|
|
190
|
+
if (n !== y) return n;
|
|
191
|
+
throw new OreApiError(c.injectStrictFailed(String(e), t.element.localName));
|
|
185
192
|
};
|
|
186
193
|
function createContext(e) {
|
|
187
194
|
return Symbol(e);
|
|
@@ -213,7 +220,7 @@ function _stringProp(e) {
|
|
|
213
220
|
reflect: !0
|
|
214
221
|
};
|
|
215
222
|
}
|
|
216
|
-
var
|
|
223
|
+
var x = {
|
|
217
224
|
bool(e) {
|
|
218
225
|
return {
|
|
219
226
|
default: e ?? !1,
|
|
@@ -257,51 +264,57 @@ var b = {
|
|
|
257
264
|
};
|
|
258
265
|
},
|
|
259
266
|
string: _stringProp
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
for (let [n, r] of Object.entries(e)) try {
|
|
275
|
-
normalizePropDefinition(r, n);
|
|
276
|
-
} catch (e) {
|
|
277
|
-
t.push(e instanceof Error ? e.message : String(e));
|
|
267
|
+
}, describeReceived = (e) => e === null ? "null" : typeof e, checkPropDef = (e, t) => {
|
|
268
|
+
if (typeof e != "object" || !e || !("default" in e)) return `Prop "${t}" must be a PropDef ({ default, parse, reflect? }), e.g. from a prop.* helper. Received: ${describeReceived(e)}`;
|
|
269
|
+
let { parse: n, reflect: r } = e;
|
|
270
|
+
if (typeof n != "function") return `Prop "${t}" must have a parse function.`;
|
|
271
|
+
if (r && isStructuredValue(e.default)) return `Prop "${t}": ${c.propInvalidReflect}`;
|
|
272
|
+
};
|
|
273
|
+
function normalizePropDefs(e, t) {
|
|
274
|
+
let n = [], r = {};
|
|
275
|
+
for (let [e, i] of Object.entries(t)) {
|
|
276
|
+
let t = checkPropDef(i, e);
|
|
277
|
+
t ? n.push(t) : r[e] = {
|
|
278
|
+
...i,
|
|
279
|
+
reflect: i.reflect ?? !1
|
|
280
|
+
};
|
|
278
281
|
}
|
|
279
|
-
|
|
282
|
+
if (n.length > 0) throw new OreApiError(c.validationFailed(e, n));
|
|
283
|
+
return r;
|
|
280
284
|
}
|
|
281
|
-
var
|
|
282
|
-
let i =
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
};
|
|
289
|
-
return u ? l.value = u.signal.peek() : d ? (delete e[t], l.value = coerceIncoming(f, s)) : e.hasAttribute(n) && (l.value = s(e.getAttribute(n))), i.set(n, p), Object.defineProperty(e, t, {
|
|
285
|
+
var S = /* @__PURE__ */ new WeakMap(), getPropMeta = (e, t) => S.get(e)?.get(t), coerceIncoming = (e, t) => typeof e == "string" ? t(e) : e, createPropMeta = (e, t, n, r) => {
|
|
286
|
+
let { default: i, parse: a, reflect: s = !1 } = r, c = e, l = o(i);
|
|
287
|
+
if (Object.hasOwn(c, t)) {
|
|
288
|
+
let e = c[t];
|
|
289
|
+
delete c[t], l.value = coerceIncoming(e, a);
|
|
290
|
+
} else e.hasAttribute(n) && (l.value = a(e.getAttribute(n)));
|
|
291
|
+
return Object.defineProperty(e, t, {
|
|
290
292
|
configurable: !0,
|
|
291
293
|
enumerable: !0,
|
|
292
294
|
get: () => l.value,
|
|
293
295
|
set: (e) => {
|
|
294
|
-
l.value = coerceIncoming(e,
|
|
296
|
+
l.value = coerceIncoming(e, a);
|
|
295
297
|
}
|
|
296
|
-
}),
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
}), {
|
|
299
|
+
parse: a,
|
|
300
|
+
reflect: s,
|
|
301
|
+
signal: l
|
|
302
|
+
};
|
|
303
|
+
}, reflectProp = (e, t, n) => {
|
|
304
|
+
watchEffect(() => {
|
|
305
|
+
let r = n.value;
|
|
306
|
+
r == null ? e.removeAttribute(t) : typeof r == "boolean" ? e.toggleAttribute(t, r) : setAttr(e, t, r);
|
|
307
|
+
});
|
|
300
308
|
};
|
|
301
309
|
function createProps(e, t) {
|
|
302
|
-
let n =
|
|
303
|
-
|
|
304
|
-
|
|
310
|
+
let n = S.get(e);
|
|
311
|
+
n || (n = /* @__PURE__ */ new Map(), S.set(e, n));
|
|
312
|
+
let r = {};
|
|
313
|
+
for (let [i, a] of Object.entries(t)) {
|
|
314
|
+
let t = toKebab(i), o = n.get(t);
|
|
315
|
+
o || (o = createPropMeta(e, i, t, a), n.set(t, o)), o.reflect && reflectProp(e, t, o.signal), r[i] = o.signal;
|
|
316
|
+
}
|
|
317
|
+
return r;
|
|
305
318
|
}
|
|
306
319
|
// src/utils/brand.ts
|
|
307
320
|
var makeBrand = (e) => {
|
|
@@ -310,64 +323,79 @@ var makeBrand = (e) => {
|
|
|
310
323
|
is,
|
|
311
324
|
stamp
|
|
312
325
|
};
|
|
313
|
-
}
|
|
326
|
+
};
|
|
327
|
+
// src/template/result.ts
|
|
328
|
+
function ref() {
|
|
329
|
+
return o(null);
|
|
330
|
+
}
|
|
331
|
+
var C = makeBrand("ore:directive"), createDirectiveResult = (e) => C.stamp({ mount: e }), w = C.is, T = makeBrand("ore:html-result"), E = T.is, asCompiled = (e) => {
|
|
332
|
+
if (!E(e)) throw new OreApiError(c.notAnHtmlResult);
|
|
333
|
+
return e;
|
|
334
|
+
};
|
|
335
|
+
function createHtmlResult(e, t) {
|
|
336
|
+
let n = !1, claim = () => {
|
|
337
|
+
if (n) throw new OreApiError(c.htmlResultReused);
|
|
338
|
+
n = !0;
|
|
339
|
+
}, mount = (n, r) => {
|
|
340
|
+
claim();
|
|
341
|
+
let i = Array.from(e.childNodes);
|
|
342
|
+
return n.insertBefore(e, r), t(), i;
|
|
343
|
+
};
|
|
344
|
+
return T.stamp({
|
|
345
|
+
apply: t,
|
|
346
|
+
claim,
|
|
347
|
+
fragment: e,
|
|
348
|
+
mount
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
// src/utils/css.ts
|
|
352
|
+
var D = makeBrand("ore:css-result"), O = D.is, cssResultToString = function() {
|
|
314
353
|
return this.content;
|
|
315
354
|
}, css = (e, ...t) => {
|
|
316
355
|
let n = "";
|
|
317
356
|
for (let r = 0; r < e.length; r++) if (n += e[r], r < t.length) {
|
|
318
357
|
let e = t[r];
|
|
319
|
-
n +=
|
|
358
|
+
n += O(e) ? e.content : String(e);
|
|
320
359
|
}
|
|
321
|
-
return
|
|
360
|
+
return D.stamp({
|
|
322
361
|
content: n.trim(),
|
|
323
362
|
toString: cssResultToString
|
|
324
363
|
});
|
|
325
|
-
},
|
|
364
|
+
}, k = /* @__PURE__ */ new Map(), A = 256, loadStylesheet = (e) => {
|
|
326
365
|
if (e instanceof CSSStyleSheet) return e;
|
|
327
|
-
let t = typeof e == "string" ? e : e.content, n =
|
|
328
|
-
if (n) return
|
|
366
|
+
let t = typeof e == "string" ? e : e.content, n = k.get(t);
|
|
367
|
+
if (n) return k.delete(t), k.set(t, n), n;
|
|
329
368
|
let r = new CSSStyleSheet();
|
|
330
369
|
try {
|
|
331
370
|
r.replaceSync(t);
|
|
332
371
|
} catch {
|
|
333
372
|
return r;
|
|
334
373
|
}
|
|
335
|
-
if (
|
|
336
|
-
let e =
|
|
337
|
-
e !== void 0 &&
|
|
374
|
+
if (k.set(t, r), k.size > A) {
|
|
375
|
+
let e = k.keys().next().value;
|
|
376
|
+
e !== void 0 && k.delete(e);
|
|
338
377
|
}
|
|
339
378
|
return r;
|
|
340
|
-
},
|
|
341
|
-
SETUP_DONE: "setup_done",
|
|
342
|
-
SETUP_RUNNING: "setup_running",
|
|
343
|
-
UNINITIALIZED: "uninitialized",
|
|
344
|
-
UNMOUNTED: "unmounted"
|
|
345
|
-
}, createComponentState = () => ({
|
|
346
|
-
formResetCallbacks: [],
|
|
347
|
-
generation: 0,
|
|
348
|
-
mountCallbacks: [],
|
|
349
|
-
phase: E.UNINITIALIZED,
|
|
350
|
-
scope: n(),
|
|
351
|
-
templateResult: null
|
|
352
|
-
}), isPromiseLike = (e) => (typeof e == "object" || typeof e == "function") && e !== null && "then" in e && typeof e.then == "function", BaseElement = class extends HTMLElement {
|
|
379
|
+
}, isPromiseLike = (e) => (typeof e == "object" || typeof e == "function") && e !== null && "then" in e && typeof e.then == "function", BaseElement = class extends HTMLElement {
|
|
353
380
|
static _definition;
|
|
354
381
|
static _normalizedPropDefs;
|
|
355
382
|
static formAssociated = !1;
|
|
356
383
|
static observedAttributes = [];
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
_stylesApplied = !1;
|
|
384
|
+
_connection = null;
|
|
385
|
+
_teardownPending = !1;
|
|
360
386
|
constructor() {
|
|
361
387
|
super();
|
|
362
388
|
let e = this.constructor._definition;
|
|
363
|
-
e?.shadow
|
|
389
|
+
if (e?.shadow === !1) return;
|
|
390
|
+
let t = this.attachShadow({
|
|
364
391
|
mode: "open",
|
|
365
392
|
...e?.shadow
|
|
366
|
-
})
|
|
393
|
+
});
|
|
394
|
+
e?.styles?.length && (t.adoptedStyleSheets = e.styles.map(loadStylesheet));
|
|
367
395
|
}
|
|
368
396
|
connectedCallback() {
|
|
369
|
-
|
|
370
|
-
this.
|
|
397
|
+
s(() => {
|
|
398
|
+
this._teardownPending ? (this._teardownPending = !1, this._scheduleMountCallbacks()) : this._connect();
|
|
371
399
|
});
|
|
372
400
|
}
|
|
373
401
|
attributeChangedCallback(e, t, n) {
|
|
@@ -375,20 +403,15 @@ var makeBrand = (e) => {
|
|
|
375
403
|
let r = getPropMeta(this, e);
|
|
376
404
|
if (!r) return;
|
|
377
405
|
let i = r.parse(n);
|
|
378
|
-
Object.is(
|
|
406
|
+
Object.is(s(() => r.signal.value), i) || (r.signal.value = i);
|
|
379
407
|
}
|
|
380
408
|
disconnectedCallback() {
|
|
381
|
-
this.
|
|
382
|
-
|
|
383
|
-
this._pendingTeardown = e, queueMicrotask(() => {
|
|
384
|
-
this._pendingTeardown === e && (this._pendingTeardown = null, this._component.generation++, this._resetSetupState());
|
|
409
|
+
this._teardownPending = !0, queueMicrotask(() => {
|
|
410
|
+
this._teardownPending && (this._teardownPending = !1, this._connection?.scope.dispose(), this._connection = null);
|
|
385
411
|
});
|
|
386
412
|
}
|
|
387
|
-
_resetSetupState() {
|
|
388
|
-
this._component.scope.dispose(), this._component.formResetCallbacks = [], this._component.mountCallbacks = [], this._component.phase = E.UNINITIALIZED, this._component.scope = n(), this._component.templateResult = null;
|
|
389
|
-
}
|
|
390
413
|
formResetCallback() {
|
|
391
|
-
for (let e of this.
|
|
414
|
+
for (let e of this._connection?.formResetCallbacks ?? []) try {
|
|
392
415
|
e();
|
|
393
416
|
} catch (e) {
|
|
394
417
|
this._reportLifecycleError(e, "form-reset");
|
|
@@ -396,72 +419,46 @@ var makeBrand = (e) => {
|
|
|
396
419
|
}
|
|
397
420
|
_reportLifecycleError(e, t) {
|
|
398
421
|
let n = e instanceof Error ? e : Error(String(e));
|
|
399
|
-
reportRuntimeError(new OreLifecycleError(`<${this.localName}> failed during ${
|
|
422
|
+
reportRuntimeError(new OreLifecycleError(`<${this.localName}> failed during ${t}`, {
|
|
400
423
|
cause: n,
|
|
401
424
|
component: this.localName,
|
|
402
425
|
phase: t
|
|
403
426
|
}), this);
|
|
404
427
|
}
|
|
405
|
-
|
|
406
|
-
this.
|
|
407
|
-
let e = this.constructor._definition, t = this.constructor._normalizedPropDefs, n = createRuntimeContext(this);
|
|
428
|
+
_connect() {
|
|
429
|
+
let e = this.constructor, t = createRuntimeContext(this);
|
|
408
430
|
try {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
})
|
|
416
|
-
this._component.templateResult = r ?? null, this._component.phase = E.SETUP_DONE;
|
|
431
|
+
runWithContext(t, () => {
|
|
432
|
+
let t = e._normalizedPropDefs ? createProps(this, e._normalizedPropDefs) : {}, n = e._definition.setup(t);
|
|
433
|
+
if (isPromiseLike(n)) throw new OreApiError(c.asyncSetupUnsupported);
|
|
434
|
+
if (n == null) return;
|
|
435
|
+
let r = this.shadowRoot ?? this;
|
|
436
|
+
r.replaceChildren(), asCompiled(n).mount(r, null);
|
|
437
|
+
});
|
|
417
438
|
} catch (e) {
|
|
418
|
-
throw this._reportLifecycleError(e, "setup"),
|
|
439
|
+
throw t.scope.dispose(), this._reportLifecycleError(e, "setup"), e;
|
|
419
440
|
}
|
|
420
|
-
|
|
421
|
-
_isStale(e) {
|
|
422
|
-
return this._component.generation !== e || !this.isConnected;
|
|
423
|
-
}
|
|
424
|
-
_applyResult(e) {
|
|
425
|
-
if (!e) return;
|
|
426
|
-
let t = this.shadowRoot ?? this, n = createRuntimeContext(this);
|
|
427
|
-
t.replaceChildren(), this._component.scope.run(() => {
|
|
428
|
-
runWithContext(n, () => {
|
|
429
|
-
e.mount(t, null, onCleanup);
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
_init() {
|
|
434
|
-
this._applyStyles(), this._mountTemplate(), this._component.phase === E.SETUP_DONE && this._scheduleMountCallbacks();
|
|
435
|
-
}
|
|
436
|
-
_applyStyles() {
|
|
437
|
-
if (this._stylesApplied) return;
|
|
438
|
-
let e = this.constructor._definition;
|
|
439
|
-
this.shadowRoot && e?.styles?.length && (this.shadowRoot.adoptedStyleSheets = e.styles.map(loadStylesheet), this._stylesApplied = !0);
|
|
440
|
-
}
|
|
441
|
-
_mountTemplate() {
|
|
442
|
-
let e = this._component.templateResult;
|
|
443
|
-
e && this._applyResult(e);
|
|
441
|
+
this._connection = t, this._scheduleMountCallbacks();
|
|
444
442
|
}
|
|
445
443
|
_scheduleMountCallbacks() {
|
|
446
|
-
|
|
447
|
-
|
|
444
|
+
let e = this._connection;
|
|
445
|
+
if (!e || e.mountCallbacks.length === 0) return;
|
|
446
|
+
let t = beginPendingWork();
|
|
448
447
|
queueMicrotask(() => {
|
|
449
448
|
try {
|
|
450
|
-
if (this.
|
|
451
|
-
let t =
|
|
452
|
-
for (
|
|
453
|
-
let n = t
|
|
449
|
+
if (this._connection !== e || !this.isConnected) return;
|
|
450
|
+
let t = e.mountCallbacks.shift();
|
|
451
|
+
for (; t;) {
|
|
452
|
+
let n = t;
|
|
454
453
|
try {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
typeof e == "function" && onCleanup(e);
|
|
460
|
-
});
|
|
461
|
-
}), e.mountCallbacks.length > 0 && t.push(...e.mountCallbacks), e.formResetCallbacks.length > 0 && this._component.formResetCallbacks.push(...e.formResetCallbacks);
|
|
454
|
+
runWithContext(e, () => {
|
|
455
|
+
let e = n();
|
|
456
|
+
typeof e == "function" && onCleanup(e);
|
|
457
|
+
});
|
|
462
458
|
} catch (e) {
|
|
463
459
|
this._reportLifecycleError(e, "mounted");
|
|
464
460
|
}
|
|
461
|
+
t = e.mountCallbacks.shift();
|
|
465
462
|
}
|
|
466
463
|
} finally {
|
|
467
464
|
t();
|
|
@@ -471,16 +468,9 @@ var makeBrand = (e) => {
|
|
|
471
468
|
};
|
|
472
469
|
// src/define.ts
|
|
473
470
|
function define(e, t) {
|
|
474
|
-
if (!e) throw new OreApiError(
|
|
475
|
-
if (customElements.get(e)) throw new OreApiError(
|
|
476
|
-
let { props: n } = t, r = (()
|
|
477
|
-
if (!n) return;
|
|
478
|
-
let t = validatePropDefs(n);
|
|
479
|
-
if (t.length > 0) throw new OreApiError(s.validationFailed(e, t));
|
|
480
|
-
let r = {};
|
|
481
|
-
for (let [e, t] of Object.entries(n)) r[e] = normalizePropDefinition(t, e);
|
|
482
|
-
return r;
|
|
483
|
-
})(), i = r ? Object.keys(r).map(toKebab) : [], ComponentClass = class extends BaseElement {
|
|
471
|
+
if (!e) throw new OreApiError(c.defineRequiresTag);
|
|
472
|
+
if (customElements.get(e)) throw new OreApiError(c.defineDuplicate(e));
|
|
473
|
+
let { props: n } = t, r = n ? normalizePropDefs(e, n) : void 0, i = r ? Object.keys(r).map(toKebab) : [], ComponentClass = class extends BaseElement {
|
|
484
474
|
static _definition = t;
|
|
485
475
|
static _normalizedPropDefs = r;
|
|
486
476
|
static formAssociated = t.formAssociated ?? !1;
|
|
@@ -489,43 +479,24 @@ function define(e, t) {
|
|
|
489
479
|
return Object.defineProperty(ComponentClass, "name", { value: e }), customElements.define(e, ComponentClass), ComponentClass;
|
|
490
480
|
}
|
|
491
481
|
// src/directives/classMap.ts
|
|
492
|
-
var classMap = (e) => t(() => [...resolveClassTokens(e)].join(" "))
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
var D = makeBrand("ore:directive"), createDirectiveResult = (e) => D.stamp({ mount: e }), O = D.is, k = makeBrand("ore:html-result"), A = k.is;
|
|
498
|
-
function createHtmlResult(e, t) {
|
|
499
|
-
let mount = (n, r, i) => {
|
|
500
|
-
let a = Array.from(e.childNodes);
|
|
501
|
-
return n.insertBefore(e, r), t(i), a;
|
|
502
|
-
};
|
|
503
|
-
return k.stamp({
|
|
504
|
-
apply: t,
|
|
505
|
-
fragment: e,
|
|
506
|
-
mount
|
|
482
|
+
var classMap = (e) => t(() => [...resolveClassTokens(e)].join(" ")), createItem = (e, t, r, i) => {
|
|
483
|
+
let a = o(e), s = o(t), c = n(), l = [], u = document.createComment("each/item-start");
|
|
484
|
+
i.appendChild(u), c.run(() => {
|
|
485
|
+
l = asCompiled(r(a, s)).mount(i, null);
|
|
507
486
|
});
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
u = r(o, s).mount(i, null, (e) => l.push(e));
|
|
514
|
-
});
|
|
515
|
-
let f = document.createComment("each/item");
|
|
516
|
-
return i.appendChild(f), u = [
|
|
517
|
-
d,
|
|
518
|
-
...u,
|
|
519
|
-
f
|
|
487
|
+
let d = document.createComment("each/item");
|
|
488
|
+
return i.appendChild(d), l = [
|
|
489
|
+
u,
|
|
490
|
+
...l,
|
|
491
|
+
d
|
|
520
492
|
], {
|
|
521
|
-
|
|
522
|
-
data: o,
|
|
493
|
+
data: a,
|
|
523
494
|
index: s,
|
|
524
|
-
nodes:
|
|
495
|
+
nodes: l,
|
|
525
496
|
scope: c
|
|
526
497
|
};
|
|
527
498
|
}, removeItem = (e) => {
|
|
528
|
-
e.scope.dispose(),
|
|
499
|
+
e.scope.dispose(), removeNodes(e.nodes);
|
|
529
500
|
}, reusedEntriesInOrder = (e, t) => {
|
|
530
501
|
let n = /* @__PURE__ */ new Map();
|
|
531
502
|
for (let e = 0; e < t.length; e++) n.set(t[e], e);
|
|
@@ -538,13 +509,13 @@ var createItem = (e, t, r, i) => {
|
|
|
538
509
|
}
|
|
539
510
|
}
|
|
540
511
|
return !0;
|
|
541
|
-
}, reconcileItems = (t, n, r, i, a,
|
|
512
|
+
}, reconcileItems = (t, n, r, i, a, o, c, l) => {
|
|
542
513
|
let u = document.createDocumentFragment();
|
|
543
514
|
for (let e = 0; e < n.length; e++) {
|
|
544
515
|
let a = r[e];
|
|
545
516
|
if (t.has(a)) continue;
|
|
546
|
-
let
|
|
547
|
-
c.push(
|
|
517
|
+
let o = s(() => createItem(n[e], e, i, u));
|
|
518
|
+
c.push(o), t.set(a, o);
|
|
548
519
|
}
|
|
549
520
|
let d = [];
|
|
550
521
|
e(() => {
|
|
@@ -553,7 +524,7 @@ var createItem = (e, t, r, i) => {
|
|
|
553
524
|
invariant(i, "each() reconcile phase 2 lost an entry created in phase 1"), i.data.value = n[e], i.index.value = e, d.push(i);
|
|
554
525
|
}
|
|
555
526
|
});
|
|
556
|
-
let f = reusedEntriesInOrder(d, l), p = new Set(c), m =
|
|
527
|
+
let f = reusedEntriesInOrder(d, l), p = new Set(c), m = o;
|
|
557
528
|
for (let e = d.length - 1; e >= 0; e--) {
|
|
558
529
|
let t = d[e], n = t.nodes[0], r = t.nodes[t.nodes.length - 1];
|
|
559
530
|
if ((!f || p.has(t)) && r !== m.previousSibling) {
|
|
@@ -581,7 +552,7 @@ var createItem = (e, t, r, i) => {
|
|
|
581
552
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
582
553
|
for (let i = 0; i < e.length; i++) {
|
|
583
554
|
let a = t(e[i], i);
|
|
584
|
-
if (r.has(a)) throw new OreApiError(
|
|
555
|
+
if (r.has(a)) throw new OreApiError(c.eachDuplicateKey(String(a), i));
|
|
585
556
|
r.add(a), n.push(a);
|
|
586
557
|
}
|
|
587
558
|
return n;
|
|
@@ -593,52 +564,61 @@ var createItem = (e, t, r, i) => {
|
|
|
593
564
|
phase: "each-reconcile"
|
|
594
565
|
}), t);
|
|
595
566
|
};
|
|
596
|
-
function each(e,
|
|
597
|
-
let
|
|
598
|
-
return createDirectiveResult((e
|
|
599
|
-
let
|
|
600
|
-
invariant(
|
|
601
|
-
let
|
|
602
|
-
|
|
603
|
-
let container = () =>
|
|
604
|
-
if (!
|
|
567
|
+
function each(e, i, c, l) {
|
|
568
|
+
let u = Array.isArray(e) ? o(e) : typeof e == "function" ? t(e) : e;
|
|
569
|
+
return createDirectiveResult((e) => {
|
|
570
|
+
let t = e.parentNode;
|
|
571
|
+
invariant(t, "each() anchor comment has no parent node");
|
|
572
|
+
let o = document.createComment("each/end");
|
|
573
|
+
t.insertBefore(o, e.nextSibling);
|
|
574
|
+
let container = () => o.parentNode, d = /* @__PURE__ */ new Map(), f = [], p = null, m = null, mountFallback = () => {
|
|
575
|
+
if (!l) return;
|
|
605
576
|
let e = container();
|
|
606
|
-
|
|
577
|
+
if (!e) return;
|
|
578
|
+
let t = n();
|
|
579
|
+
m = t;
|
|
580
|
+
try {
|
|
581
|
+
t.run(() => {
|
|
582
|
+
p = asCompiled(l()).mount(e, o);
|
|
583
|
+
});
|
|
584
|
+
} catch (e) {
|
|
585
|
+
throw clearFallback(), e;
|
|
586
|
+
}
|
|
607
587
|
}, clearFallback = () => {
|
|
608
|
-
|
|
609
|
-
},
|
|
610
|
-
let t =
|
|
588
|
+
m?.dispose(), m = null, p &&= (removeNodes(p), null);
|
|
589
|
+
}, h = r(() => {
|
|
590
|
+
let t = u.value ?? [];
|
|
611
591
|
if (t.length === 0) {
|
|
612
|
-
for (let e of
|
|
613
|
-
|
|
592
|
+
for (let e of s(() => f)) removeItem(e);
|
|
593
|
+
d = /* @__PURE__ */ new Map(), f = [], p || s(mountFallback);
|
|
614
594
|
return;
|
|
615
595
|
}
|
|
616
|
-
let
|
|
596
|
+
let n;
|
|
617
597
|
try {
|
|
618
|
-
|
|
598
|
+
n = s(() => collectKeys(t, i));
|
|
619
599
|
} catch (t) {
|
|
620
600
|
reportEachError(t, e);
|
|
621
601
|
return;
|
|
622
602
|
}
|
|
623
603
|
clearFallback();
|
|
624
|
-
let
|
|
625
|
-
if (!
|
|
626
|
-
let
|
|
604
|
+
let r = container();
|
|
605
|
+
if (!r) return;
|
|
606
|
+
let a = [];
|
|
627
607
|
try {
|
|
628
|
-
|
|
608
|
+
f = s(() => reconcileItems(d, t, n, c, r, o, a, f));
|
|
629
609
|
} catch (t) {
|
|
630
|
-
reportEachError(t, e),
|
|
610
|
+
reportEachError(t, e), s(() => rollbackCreated(d, a));
|
|
631
611
|
}
|
|
632
612
|
});
|
|
633
|
-
|
|
634
|
-
clearFallback();
|
|
635
|
-
for (let e of
|
|
636
|
-
|
|
613
|
+
a(() => {
|
|
614
|
+
h.dispose(), clearFallback();
|
|
615
|
+
for (let e of f) removeItem(e);
|
|
616
|
+
o.remove();
|
|
637
617
|
});
|
|
638
618
|
});
|
|
639
619
|
}
|
|
640
|
-
// src/directives/
|
|
641
|
-
var j = makeBrand("ore:
|
|
620
|
+
// src/directives/model.ts
|
|
621
|
+
var j = makeBrand("ore:model"), M = j.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) => j.stamp({
|
|
642
622
|
event: t?.event,
|
|
643
623
|
get: t?.get,
|
|
644
624
|
source: e
|
|
@@ -660,57 +640,63 @@ var j = makeBrand("ore:live"), live = (e) => j.stamp({ source: e }), M = j.is, N
|
|
|
660
640
|
};
|
|
661
641
|
function unsafeHtml(e) {
|
|
662
642
|
let n = typeof e == "function" ? t(e) : i(e) ? e : null;
|
|
663
|
-
return createDirectiveResult((t
|
|
664
|
-
let
|
|
665
|
-
invariant(
|
|
643
|
+
return createDirectiveResult((t) => {
|
|
644
|
+
let i = t.parentNode;
|
|
645
|
+
invariant(i, "unsafeHtml() anchor comment has no parent node");
|
|
666
646
|
let o = document.createComment("unsafe-html/end");
|
|
667
|
-
if (
|
|
647
|
+
if (i.insertBefore(o, t.nextSibling), n) {
|
|
668
648
|
let e = createReplaceableSlot(), t = r(() => {
|
|
669
|
-
e.clear();
|
|
670
649
|
let t = o.parentNode;
|
|
671
|
-
t
|
|
650
|
+
t ? e.render(() => {
|
|
651
|
+
e.setNodes(parseHtml(n.value, t, o));
|
|
652
|
+
}) : e.clear();
|
|
672
653
|
});
|
|
673
|
-
|
|
674
|
-
e.clear(), o.remove();
|
|
654
|
+
a(() => {
|
|
655
|
+
t.dispose(), e.clear(), o.remove();
|
|
675
656
|
});
|
|
676
|
-
} else parseHtml(e,
|
|
657
|
+
} else parseHtml(e, i, o), a(() => o.remove());
|
|
677
658
|
});
|
|
678
659
|
}
|
|
679
660
|
// src/directives/when.ts
|
|
680
|
-
var
|
|
681
|
-
function when(e, n,
|
|
682
|
-
return typeof e != "function" && !i(e) ? createDirectiveResult((t
|
|
683
|
-
let
|
|
684
|
-
if (!
|
|
685
|
-
let
|
|
686
|
-
invariant(
|
|
687
|
-
let s =
|
|
688
|
-
|
|
689
|
-
}) : createDirectiveResult((i
|
|
661
|
+
var N = "when() anchor comment has no parent node";
|
|
662
|
+
function when(e, n, o) {
|
|
663
|
+
return typeof e != "function" && !i(e) ? createDirectiveResult((t) => {
|
|
664
|
+
let r = e ? n() : o ? o() : null;
|
|
665
|
+
if (!r || !E(r)) return;
|
|
666
|
+
let i = t.parentNode;
|
|
667
|
+
invariant(i, N);
|
|
668
|
+
let s = r.mount(i, t);
|
|
669
|
+
a(() => removeNodes(s));
|
|
670
|
+
}) : createDirectiveResult((i) => {
|
|
690
671
|
let c = (typeof e == "function" ? t(e) : null) ?? e, l = i.parentNode;
|
|
691
|
-
invariant(l,
|
|
672
|
+
invariant(l, N);
|
|
692
673
|
let u = document.createComment("when/end");
|
|
693
674
|
l.insertBefore(u, i.nextSibling);
|
|
694
675
|
let d = createReplaceableSlot(), f = r(() => {
|
|
695
|
-
let e = c.value;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
676
|
+
let e = c.value ? n() : o ? o() : null;
|
|
677
|
+
if (!e || !E(e)) {
|
|
678
|
+
d.clear();
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
let t = u.parentNode;
|
|
682
|
+
t ? s(() => {
|
|
683
|
+
d.render(() => {
|
|
684
|
+
d.setNodes(e.mount(t, u));
|
|
685
|
+
});
|
|
686
|
+
}) : d.clear();
|
|
701
687
|
});
|
|
702
|
-
|
|
703
|
-
d.clear(), u.remove();
|
|
688
|
+
a(() => {
|
|
689
|
+
f.dispose(), d.clear(), u.remove();
|
|
704
690
|
});
|
|
705
691
|
});
|
|
706
692
|
}
|
|
707
693
|
// src/forms/field.ts
|
|
708
|
-
var
|
|
694
|
+
var P = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakSet(), useField = (e) => {
|
|
709
695
|
let t = getHost();
|
|
710
|
-
if (!t.constructor.formAssociated) throw new OreApiError(
|
|
711
|
-
if (
|
|
712
|
-
let n =
|
|
713
|
-
|
|
696
|
+
if (!t.constructor.formAssociated) throw new OreApiError(c.defineFieldRequiresFormAssociated(t.localName));
|
|
697
|
+
if (F.has(t)) throw new OreApiError(c.useFieldAlreadyCalled(t.localName));
|
|
698
|
+
let n = P.get(t) ?? t.attachInternals();
|
|
699
|
+
P.set(t, n), F.add(t), onCleanup(() => F.delete(t));
|
|
714
700
|
let r = e.toFormValue ?? ((t) => t == null ? e.emptyStringForNull ? "" : null : t instanceof File || t instanceof FormData ? t : String(t));
|
|
715
701
|
watchEffect(() => {
|
|
716
702
|
n.setFormValue(r(e.value.value));
|
|
@@ -741,7 +727,7 @@ var I = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakSet(), useFie
|
|
|
741
727
|
}, normalizeHostAttrKey = (e) => e === "role" || e.startsWith("aria-") ? e : e.startsWith("aria") ? `aria-${e.slice(4).toLowerCase()}` : e, bind = (e, t) => {
|
|
742
728
|
let n = t?.target ?? getHost(), r = [];
|
|
743
729
|
if (e.attr) for (let [t, i] of Object.entries(e.attr)) {
|
|
744
|
-
let e = applyAttribute(n,
|
|
730
|
+
let e = applyAttribute(n, I(t), i);
|
|
745
731
|
e && r.push(e);
|
|
746
732
|
}
|
|
747
733
|
if (e.class && r.push(applyClassMap(n, e.class)), e.style) for (let [t, i] of Object.entries(e.style)) {
|
|
@@ -758,14 +744,15 @@ var I = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakSet(), useFie
|
|
|
758
744
|
let cleanup = () => {
|
|
759
745
|
for (let e of r) e();
|
|
760
746
|
};
|
|
761
|
-
return
|
|
762
|
-
},
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
});
|
|
766
|
-
if (i(e)) return watchEffect(() => {
|
|
767
|
-
t(e.value);
|
|
747
|
+
return hasSetupContext() && a(cleanup), cleanup;
|
|
748
|
+
}, I = normalizeHostAttrKey, reactive = (e) => {
|
|
749
|
+
let t = r(() => {
|
|
750
|
+
e();
|
|
768
751
|
});
|
|
752
|
+
return () => t.dispose();
|
|
753
|
+
}, applyReactiveBinding = (e, t) => {
|
|
754
|
+
if (typeof e == "function") return reactive(() => t(e()));
|
|
755
|
+
if (i(e)) return reactive(() => t(e.value));
|
|
769
756
|
t(e);
|
|
770
757
|
};
|
|
771
758
|
function applyAttribute(e, t, n) {
|
|
@@ -782,7 +769,7 @@ function applyStyle(e, t, n) {
|
|
|
782
769
|
}
|
|
783
770
|
function applyClassMap(e, t) {
|
|
784
771
|
let n = typeof t == "function" ? t : () => Object.fromEntries([...resolveClassTokens(t)].map((e) => [e, !0])), r = /* @__PURE__ */ new Set();
|
|
785
|
-
return
|
|
772
|
+
return reactive(() => {
|
|
786
773
|
let t = /* @__PURE__ */ new Set();
|
|
787
774
|
for (let [i, a] of Object.entries(n())) a && (t.add(i), r.has(i) || e.classList.add(i));
|
|
788
775
|
for (let n of r) t.has(n) || e.classList.remove(n);
|
|
@@ -790,12 +777,12 @@ function applyClassMap(e, t) {
|
|
|
790
777
|
});
|
|
791
778
|
}
|
|
792
779
|
// src/slots.ts
|
|
793
|
-
var
|
|
780
|
+
var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
|
|
794
781
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), ensureSlotEntry = (e) => {
|
|
795
782
|
let n = t.get(e);
|
|
796
783
|
return n || (n = {
|
|
797
|
-
elements:
|
|
798
|
-
presence:
|
|
784
|
+
elements: o([]),
|
|
785
|
+
presence: o(!1)
|
|
799
786
|
}, t.set(e, n)), n;
|
|
800
787
|
}, areElementsEqual = (e, t) => {
|
|
801
788
|
if (e.length !== t.length) return !1;
|
|
@@ -853,115 +840,114 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
853
840
|
return onMounted(initSlots), onCleanup(() => {
|
|
854
841
|
i?.disconnect(), i = null;
|
|
855
842
|
for (let e of r.values()) e();
|
|
856
|
-
r.clear(), n.clear(), t.clear(),
|
|
843
|
+
r.clear(), n.clear(), t.clear(), R.delete(e);
|
|
857
844
|
}), {
|
|
858
845
|
elements: (e) => ensureSlotEntry(normalizeSlotName(e)).elements,
|
|
859
846
|
has: (e) => ensureSlotEntry(normalizeSlotName(e)).presence
|
|
860
847
|
};
|
|
861
|
-
},
|
|
862
|
-
let e = requireSetupContext("useSlots"), t =
|
|
863
|
-
return t || (t = createSlots(e.element),
|
|
864
|
-
}, signalEffect = (e, t
|
|
865
|
-
|
|
848
|
+
}, R = /* @__PURE__ */ new WeakMap(), useSlots = () => {
|
|
849
|
+
let e = requireSetupContext("useSlots"), t = R.get(e.element);
|
|
850
|
+
return t || (t = createSlots(e.element), R.set(e.element, t)), t;
|
|
851
|
+
}, signalEffect = (e, t) => {
|
|
852
|
+
r(() => {
|
|
866
853
|
t(e.value);
|
|
867
854
|
});
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
}, applyAttrBinding = (e, t) => {
|
|
879
|
-
let { el: n, mode: r, name: i } = e, a = { last: void 0 }, update = (t) => {
|
|
880
|
-
let o = getPropMeta(n, i);
|
|
881
|
-
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);
|
|
855
|
+
}, 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) => {
|
|
856
|
+
let r = isCheckableInput(e), i = r ? !!t : t == null ? "" : String(t), a = r ? e.checked : e.value;
|
|
857
|
+
(!n || n.last === void 0 || Object.is(a, n.last) || Object.is(a, i)) && (r ? e.checked = i : e.value = i, n && (n.last = i));
|
|
858
|
+
}, isAttributeValue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", toRegisteredPropValue = (e, t, n) => t === "bool" ? e.parse(n ? "" : null) : n == null || n === !1 ? e.parse(null) : typeof n == "string" ? e.parse(n) : n, syncRegisteredProp = (e, t, n, r) => {
|
|
859
|
+
let i = toRegisteredPropValue(t, n.mode, r);
|
|
860
|
+
Object.is(s(() => t.signal.value), i) || (t.signal.value = i), !t.reflect && (r == null || isAttributeValue(r)) && (n.mode === "bool" ? e.toggleAttribute(n.name, !!r) : setAttr(e, n.name, r));
|
|
861
|
+
}, applyAttrBinding = (e) => {
|
|
862
|
+
let { el: t, mode: n, name: r } = e, update = (i) => {
|
|
863
|
+
let a = getPropMeta(t, r);
|
|
864
|
+
a ? syncRegisteredProp(t, a, e, i) : r === "value" && isNativeFormInput(t) || r === "checked" && t instanceof HTMLInputElement ? syncFormControl(t, i) : r === "indeterminate" && t instanceof HTMLInputElement ? t.indeterminate = !!i : n === "bool" ? t.toggleAttribute(r, !!i) : setAttr(t, r, i);
|
|
882
865
|
};
|
|
883
|
-
"signal" in e ? signalEffect(e.signal, update
|
|
884
|
-
}, applyEventBinding = (e
|
|
885
|
-
let { modifiers:
|
|
886
|
-
|
|
887
|
-
} : e.handler,
|
|
888
|
-
capture:
|
|
889
|
-
once:
|
|
866
|
+
"signal" in e ? signalEffect(e.signal, update) : update(e.value);
|
|
867
|
+
}, applyEventBinding = (e) => {
|
|
868
|
+
let { modifiers: t } = e, n = t?.stop || t?.prevent ? (n) => {
|
|
869
|
+
t.stop && n.stopPropagation(), t.prevent && n.preventDefault(), e.handler(n);
|
|
870
|
+
} : e.handler, r = t?.once || t?.capture ? {
|
|
871
|
+
capture: t.capture,
|
|
872
|
+
once: t.once
|
|
890
873
|
} : void 0;
|
|
891
|
-
|
|
892
|
-
}, applyPropBinding = (e
|
|
874
|
+
a(listen(e.el, e.name, n, r));
|
|
875
|
+
}, applyPropBinding = (e) => {
|
|
893
876
|
let update = (t) => {
|
|
894
877
|
e.el[e.name] = t;
|
|
895
878
|
};
|
|
896
|
-
"signal" in e ? signalEffect(e.signal, update
|
|
897
|
-
}, applyModelBinding = (e
|
|
898
|
-
let { el:
|
|
899
|
-
isNativeFormInput(
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
879
|
+
"signal" in e ? signalEffect(e.signal, update) : update(e.value);
|
|
880
|
+
}, applyModelBinding = (e) => {
|
|
881
|
+
let { el: t, get: n, signal: i } = e, o = { last: void 0 }, write = (e) => {
|
|
882
|
+
isNativeFormInput(t) ? syncFormControl(t, e, o) : t.value = e;
|
|
883
|
+
};
|
|
884
|
+
r(() => {
|
|
885
|
+
write(i.value);
|
|
886
|
+
});
|
|
887
|
+
let onEvent = () => {
|
|
888
|
+
let e = n(t);
|
|
889
|
+
Object.is(s(() => i.value), e) || (i.value = e);
|
|
905
890
|
};
|
|
906
|
-
|
|
907
|
-
}, applyRefBinding = (e
|
|
908
|
-
let { el:
|
|
909
|
-
typeof
|
|
910
|
-
|
|
891
|
+
a(listen(t, e.event, onEvent));
|
|
892
|
+
}, applyRefBinding = (e) => {
|
|
893
|
+
let { el: t, ref: n } = e;
|
|
894
|
+
typeof n == "function" ? (n(t), a(() => n(null))) : (n.value = t, a(() => {
|
|
895
|
+
n.value = null;
|
|
911
896
|
}));
|
|
912
|
-
}, insertHtmlValues = (e, t, n) => {
|
|
913
|
-
let r =
|
|
914
|
-
invariant(
|
|
915
|
-
for (let
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
897
|
+
}, insertHtmlValues = (e, t, n = []) => {
|
|
898
|
+
let r = t.parentNode;
|
|
899
|
+
invariant(r, "html binding anchor has no parent node");
|
|
900
|
+
for (let i of e) if (E(i)) {
|
|
901
|
+
i.claim();
|
|
902
|
+
let e = Array.from(i.fragment.childNodes);
|
|
903
|
+
r.insertBefore(i.fragment, t), i.apply(), n.push(...e);
|
|
904
|
+
} else if (i != null && i !== !1) {
|
|
905
|
+
let e = document.createTextNode(String(i));
|
|
906
|
+
r.insertBefore(e, t), n.push(e);
|
|
921
907
|
}
|
|
922
|
-
return
|
|
923
|
-
}, toHtmlValues = (e) => Array.isArray(e) ? e : [e], applyHtmlBinding = (e
|
|
924
|
-
let { anchor:
|
|
925
|
-
let e = toHtmlValues(typeof
|
|
926
|
-
|
|
927
|
-
|
|
908
|
+
return n;
|
|
909
|
+
}, toHtmlValues = (e) => Array.isArray(e) ? e : [e], applyHtmlBinding = (e) => {
|
|
910
|
+
let { anchor: t, source: n } = e, i = createReplaceableSlot(), o = r(() => {
|
|
911
|
+
let e = toHtmlValues(typeof n == "function" ? n() : n.value);
|
|
912
|
+
e == null || e.length === 0 ? i.clear() : s(() => {
|
|
913
|
+
i.render(() => {
|
|
914
|
+
let n = [];
|
|
915
|
+
try {
|
|
916
|
+
insertHtmlValues(e, t, n);
|
|
917
|
+
} finally {
|
|
918
|
+
i.setNodes(n);
|
|
919
|
+
}
|
|
920
|
+
});
|
|
928
921
|
});
|
|
929
922
|
});
|
|
930
|
-
|
|
931
|
-
|
|
923
|
+
a(() => {
|
|
924
|
+
o.dispose(), i.clear();
|
|
932
925
|
});
|
|
933
|
-
}, applyDirectiveBinding = (e
|
|
934
|
-
e.directive.mount(e.anchor
|
|
935
|
-
}, applyBinding = (e
|
|
926
|
+
}, applyDirectiveBinding = (e) => {
|
|
927
|
+
e.directive.mount(e.anchor);
|
|
928
|
+
}, applyBinding = (e) => {
|
|
936
929
|
switch (e.type) {
|
|
937
930
|
case "attr":
|
|
938
|
-
applyAttrBinding(e
|
|
931
|
+
applyAttrBinding(e);
|
|
939
932
|
break;
|
|
940
933
|
case "directive":
|
|
941
|
-
applyDirectiveBinding(e
|
|
934
|
+
applyDirectiveBinding(e);
|
|
942
935
|
break;
|
|
943
936
|
case "event":
|
|
944
|
-
applyEventBinding(e
|
|
937
|
+
applyEventBinding(e);
|
|
945
938
|
break;
|
|
946
939
|
case "html":
|
|
947
|
-
applyHtmlBinding(e
|
|
940
|
+
applyHtmlBinding(e);
|
|
948
941
|
break;
|
|
949
942
|
case "model":
|
|
950
|
-
applyModelBinding(e
|
|
943
|
+
applyModelBinding(e);
|
|
951
944
|
break;
|
|
952
945
|
case "prop":
|
|
953
|
-
applyPropBinding(e
|
|
946
|
+
applyPropBinding(e);
|
|
954
947
|
break;
|
|
955
|
-
case "ref": applyRefBinding(e
|
|
948
|
+
case "ref": applyRefBinding(e);
|
|
956
949
|
}
|
|
957
|
-
}, createAttrBindingFromValue = (e, n, r, a) =>
|
|
958
|
-
el: e,
|
|
959
|
-
live: !0,
|
|
960
|
-
mode: n,
|
|
961
|
-
name: r,
|
|
962
|
-
signal: a.source,
|
|
963
|
-
type: "attr"
|
|
964
|
-
} : typeof a == "function" ? {
|
|
950
|
+
}, createAttrBindingFromValue = (e, n, r, a) => typeof a == "function" ? {
|
|
965
951
|
el: e,
|
|
966
952
|
mode: n,
|
|
967
953
|
name: r,
|
|
@@ -979,14 +965,14 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
979
965
|
name: r,
|
|
980
966
|
type: "attr",
|
|
981
967
|
value: a
|
|
982
|
-
}, resolveStaticText = (e) => e == null ? "" : String(e),
|
|
968
|
+
}, resolveStaticText = (e) => e == null ? "" : String(e), z = {
|
|
983
969
|
ATTR: "attr",
|
|
984
970
|
BOOL_ATTR: "boolAttr",
|
|
985
971
|
EVENT: "event",
|
|
986
972
|
NODE: "node",
|
|
987
973
|
PROP: "prop",
|
|
988
974
|
REF: "ref"
|
|
989
|
-
},
|
|
975
|
+
}, B = {
|
|
990
976
|
capture: !0,
|
|
991
977
|
once: !0,
|
|
992
978
|
prevent: !0,
|
|
@@ -995,73 +981,73 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
995
981
|
if (t.length === 0) return;
|
|
996
982
|
let n = {};
|
|
997
983
|
for (let r of t) {
|
|
998
|
-
if (!(r in
|
|
984
|
+
if (!(r in B)) throw new OreApiError(c.eventModifierUnknown(e, r));
|
|
999
985
|
n[r] = !0;
|
|
1000
986
|
}
|
|
1001
987
|
return n;
|
|
1002
|
-
},
|
|
988
|
+
}, V = /\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/, H = /\s+ref\s*=\s*["']?$/, U = /\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, W = /\s+\.([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, G = /\s+([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, K = /* @__PURE__ */ new Set([
|
|
1003
989
|
"innerhtml",
|
|
1004
990
|
"outerhtml",
|
|
1005
991
|
"srcdoc"
|
|
1006
992
|
]), detectSlot = (e) => {
|
|
1007
993
|
let t;
|
|
1008
|
-
if (t =
|
|
994
|
+
if (t = V.exec(e)) {
|
|
1009
995
|
let n = e.slice(0, -t[0].length), [r, ...i] = t[1].split(".");
|
|
1010
996
|
return {
|
|
1011
997
|
eventModifiers: parseEventModifiers(r, i),
|
|
1012
|
-
kind:
|
|
998
|
+
kind: z.EVENT,
|
|
1013
999
|
name: r,
|
|
1014
1000
|
prefix: n
|
|
1015
1001
|
};
|
|
1016
1002
|
}
|
|
1017
|
-
if (t =
|
|
1018
|
-
kind:
|
|
1003
|
+
if (t = H.exec(e)) return {
|
|
1004
|
+
kind: z.REF,
|
|
1019
1005
|
prefix: e.slice(0, -t[0].length)
|
|
1020
1006
|
};
|
|
1021
|
-
if (t =
|
|
1022
|
-
kind:
|
|
1007
|
+
if (t = U.exec(e)) return {
|
|
1008
|
+
kind: z.BOOL_ATTR,
|
|
1023
1009
|
name: t[1],
|
|
1024
1010
|
prefix: e.slice(0, -t[0].length)
|
|
1025
1011
|
};
|
|
1026
|
-
if (t =
|
|
1012
|
+
if (t = W.exec(e)) {
|
|
1027
1013
|
let n = t[1];
|
|
1028
|
-
if (n === "__proto__" || n === "constructor" || n === "prototype") throw new OreApiError(
|
|
1029
|
-
if (
|
|
1014
|
+
if (n === "__proto__" || n === "constructor" || n === "prototype") throw new OreApiError(c.propBindingForbiddenName(n));
|
|
1015
|
+
if (K.has(n.toLowerCase())) throw new OreApiError(c.propBindingHtmlInjectionName(n));
|
|
1030
1016
|
return {
|
|
1031
|
-
kind:
|
|
1017
|
+
kind: z.PROP,
|
|
1032
1018
|
name: n,
|
|
1033
1019
|
prefix: e.slice(0, -t[0].length)
|
|
1034
1020
|
};
|
|
1035
1021
|
}
|
|
1036
|
-
if (t =
|
|
1037
|
-
kind:
|
|
1022
|
+
if (t = G.exec(e)) return {
|
|
1023
|
+
kind: z.ATTR,
|
|
1038
1024
|
name: t[1],
|
|
1039
1025
|
prefix: e.slice(0, -t[0].length)
|
|
1040
1026
|
};
|
|
1041
1027
|
let n = e.lastIndexOf("<");
|
|
1042
|
-
if (n > e.lastIndexOf(">") && e[n + 1] !== "/") throw new OreApiError(
|
|
1028
|
+
if (n > e.lastIndexOf(">") && e[n + 1] !== "/") throw new OreApiError(c.templateInterpolationInTag);
|
|
1043
1029
|
return {
|
|
1044
|
-
kind:
|
|
1030
|
+
kind: z.NODE,
|
|
1045
1031
|
prefix: e
|
|
1046
1032
|
};
|
|
1047
|
-
},
|
|
1033
|
+
}, q = /* @__PURE__ */ new WeakMap(), J = /[@?]?[a-zA-Z_][-a-zA-Z0-9_.]*\s*=\s*$/, normalizeTemplateStrings = (e) => {
|
|
1048
1034
|
let t = Array.from(e), n = !1;
|
|
1049
1035
|
for (let e = 0; e < t.length - 1; e++) {
|
|
1050
1036
|
let r = t[e], i = r[r.length - 1];
|
|
1051
1037
|
for (let e of r) e === "<" ? n = !0 : e === ">" && (n = !1);
|
|
1052
|
-
if ((i === "\"" || i === "'") && n &&
|
|
1038
|
+
if ((i === "\"" || i === "'") && n && J.test(r.slice(0, -1))) {
|
|
1053
1039
|
t[e] = r.slice(0, -1);
|
|
1054
1040
|
let n = t[e + 1];
|
|
1055
1041
|
n.startsWith(i) && (t[e + 1] = n.slice(1));
|
|
1056
1042
|
}
|
|
1057
1043
|
}
|
|
1058
1044
|
return t;
|
|
1059
|
-
},
|
|
1045
|
+
}, Y = "data-ore-b", X = /^ore:(\d+)$/, walkNode = (e, t, n, r) => {
|
|
1060
1046
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
1061
|
-
let r = e, i = r.getAttribute(
|
|
1062
|
-
i !== null && (n.set(Number(i), [...t]), r.removeAttribute(
|
|
1047
|
+
let r = e, i = r.getAttribute(Y);
|
|
1048
|
+
i !== null && (n.set(Number(i), [...t]), r.removeAttribute(Y));
|
|
1063
1049
|
} else if (e.nodeType === Node.COMMENT_NODE) {
|
|
1064
|
-
let n = e.nodeValue, i = n === null ? null :
|
|
1050
|
+
let n = e.nodeValue, i = n === null ? null : X.exec(n);
|
|
1065
1051
|
i && r.set(Number(i[1]), [...t]);
|
|
1066
1052
|
}
|
|
1067
1053
|
let i = e.childNodes;
|
|
@@ -1070,13 +1056,13 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1070
1056
|
let t = normalizeTemplateStrings(e), n = "", r, i = 0, a = 0, o = [];
|
|
1071
1057
|
for (let e = 0; e < t.length - 1; e++) {
|
|
1072
1058
|
let s = t[e], c = detectSlot(s);
|
|
1073
|
-
if (c.kind ===
|
|
1059
|
+
if (c.kind === z.NODE) n += `${c.prefix}<!--ore:${a}-->`, o.push({
|
|
1074
1060
|
commentId: a,
|
|
1075
|
-
kind:
|
|
1061
|
+
kind: z.NODE
|
|
1076
1062
|
}), a++, r = void 0;
|
|
1077
1063
|
else {
|
|
1078
|
-
r === void 0 || c.prefix.lastIndexOf("<") > c.prefix.lastIndexOf(">") ? (r = i++, n += `${c.prefix} ${
|
|
1079
|
-
let e = c.kind ===
|
|
1064
|
+
r === void 0 || c.prefix.lastIndexOf("<") > c.prefix.lastIndexOf(">") ? (r = i++, n += `${c.prefix} ${Y}="${r}"`) : n += c.prefix;
|
|
1065
|
+
let e = c.kind === z.BOOL_ATTR ? "bool" : c.kind === z.ATTR ? "attr" : void 0;
|
|
1080
1066
|
o.push({
|
|
1081
1067
|
elementId: r,
|
|
1082
1068
|
eventModifiers: c.eventModifiers,
|
|
@@ -1098,20 +1084,21 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1098
1084
|
slots: o
|
|
1099
1085
|
};
|
|
1100
1086
|
}, getStaticTemplate = (e) => {
|
|
1101
|
-
let t =
|
|
1102
|
-
return t || (t = buildStaticTemplate(e),
|
|
1087
|
+
let t = q.get(e);
|
|
1088
|
+
return t || (t = buildStaticTemplate(e), q.set(e, t)), t;
|
|
1103
1089
|
}, followPath = (e, t) => {
|
|
1104
1090
|
let n = e;
|
|
1105
1091
|
for (let e of t) n = n.childNodes[e];
|
|
1106
1092
|
return n;
|
|
1107
|
-
},
|
|
1093
|
+
}, Z = "html`...`: node-slot comment anchor has no parent node", embedStaticResult = (e, t, n) => {
|
|
1094
|
+
e.claim();
|
|
1108
1095
|
let r = t.parentNode;
|
|
1109
|
-
for (invariant(r,
|
|
1096
|
+
for (invariant(r, Z); e.fragment.firstChild;) r.insertBefore(e.fragment.firstChild, t);
|
|
1110
1097
|
n.push(e.apply.bind(e));
|
|
1111
1098
|
}, compileTemplate = (e, n) => {
|
|
1112
|
-
let r = getStaticTemplate(e), a = r.element.content.cloneNode(!0), o = [],
|
|
1099
|
+
let r = getStaticTemplate(e), a = r.element.content.cloneNode(!0), o = [], s = [], l = r.slots.map((e, t) => {
|
|
1113
1100
|
let i = n[t];
|
|
1114
|
-
if (e.kind ===
|
|
1101
|
+
if (e.kind === z.NODE) {
|
|
1115
1102
|
let t = e.commentId === void 0 ? void 0 : r.commentPaths.get(e.commentId);
|
|
1116
1103
|
return invariant(t, `compiled template is missing a comment path for node slot ${e.commentId}`), {
|
|
1117
1104
|
comment: followPath(a, t),
|
|
@@ -1126,9 +1113,9 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1126
1113
|
value: i
|
|
1127
1114
|
};
|
|
1128
1115
|
});
|
|
1129
|
-
for (let { comment: e, el: n, slot: r, value: a } of l) if (r.kind ===
|
|
1116
|
+
for (let { comment: e, el: n, slot: r, value: a } of l) if (r.kind === z.NODE) {
|
|
1130
1117
|
let t = e;
|
|
1131
|
-
if (invariant(t, "compiled template produced a node slot without a comment anchor"),
|
|
1118
|
+
if (invariant(t, "compiled template produced a node slot without a comment anchor"), w(a)) {
|
|
1132
1119
|
o.push({
|
|
1133
1120
|
anchor: t,
|
|
1134
1121
|
directive: a,
|
|
@@ -1136,8 +1123,8 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1136
1123
|
});
|
|
1137
1124
|
continue;
|
|
1138
1125
|
}
|
|
1139
|
-
if (
|
|
1140
|
-
embedStaticResult(a, t,
|
|
1126
|
+
if (E(a)) {
|
|
1127
|
+
embedStaticResult(a, t, s), t.remove();
|
|
1141
1128
|
continue;
|
|
1142
1129
|
}
|
|
1143
1130
|
if (typeof a == "function" || i(a)) {
|
|
@@ -1149,16 +1136,16 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1149
1136
|
continue;
|
|
1150
1137
|
}
|
|
1151
1138
|
if (Array.isArray(a)) {
|
|
1152
|
-
for (let e of a) if (
|
|
1139
|
+
for (let e of a) if (E(e)) embedStaticResult(e, t, s);
|
|
1153
1140
|
else {
|
|
1154
1141
|
let n = t.parentNode;
|
|
1155
|
-
invariant(n,
|
|
1142
|
+
invariant(n, Z), n.insertBefore(document.createTextNode(resolveStaticText(e)), t);
|
|
1156
1143
|
}
|
|
1157
1144
|
t.remove();
|
|
1158
1145
|
continue;
|
|
1159
1146
|
}
|
|
1160
1147
|
t.replaceWith(document.createTextNode(resolveStaticText(a)));
|
|
1161
|
-
} else if (invariant(n, "compiled template produced an element slot without an element"), r.kind ===
|
|
1148
|
+
} else if (invariant(n, "compiled template produced an element slot without an element"), r.kind === z.EVENT) {
|
|
1162
1149
|
let e = r.name;
|
|
1163
1150
|
if (invariant(e, "compiled template produced an event slot without an event name"), typeof a == "function") o.push({
|
|
1164
1151
|
el: n,
|
|
@@ -1180,7 +1167,7 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1180
1167
|
type: "event"
|
|
1181
1168
|
});
|
|
1182
1169
|
}
|
|
1183
|
-
} else if (r.kind ===
|
|
1170
|
+
} else if (r.kind === z.PROP) {
|
|
1184
1171
|
let e = r.name;
|
|
1185
1172
|
invariant(e, "compiled template produced a prop slot without a property name"), typeof a == "function" ? o.push({
|
|
1186
1173
|
el: n,
|
|
@@ -1198,13 +1185,13 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1198
1185
|
type: "prop",
|
|
1199
1186
|
value: a
|
|
1200
1187
|
});
|
|
1201
|
-
} else if (r.kind ===
|
|
1188
|
+
} else if (r.kind === z.REF) a && o.push({
|
|
1202
1189
|
el: n,
|
|
1203
1190
|
ref: a,
|
|
1204
1191
|
type: "ref"
|
|
1205
1192
|
});
|
|
1206
|
-
else if (invariant(r.name, "compiled template produced an attr slot without an attribute name"),
|
|
1207
|
-
if (r.mode !== "attr") throw new OreApiError(
|
|
1193
|
+
else if (invariant(r.name, "compiled template produced an attr slot without an attribute name"), M(a)) {
|
|
1194
|
+
if (r.mode !== "attr") throw new OreApiError(c.modelRequiresValueBinding(r.name));
|
|
1208
1195
|
o.push({
|
|
1209
1196
|
el: n,
|
|
1210
1197
|
event: a.event ?? modelDefaultEvent(n),
|
|
@@ -1213,11 +1200,11 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1213
1200
|
type: "model"
|
|
1214
1201
|
});
|
|
1215
1202
|
} else o.push(createAttrBindingFromValue(n, r.mode ?? "attr", r.name, a));
|
|
1216
|
-
return createHtmlResult(a, (
|
|
1217
|
-
for (let
|
|
1218
|
-
for (let
|
|
1203
|
+
return createHtmlResult(a, () => {
|
|
1204
|
+
for (let e of o) applyBinding(e);
|
|
1205
|
+
for (let e of s) e();
|
|
1219
1206
|
});
|
|
1220
|
-
}, html = (e, ...t) => compileTemplate(e, t),
|
|
1207
|
+
}, html = (e, ...t) => compileTemplate(e, t), Q = {
|
|
1221
1208
|
bubbles: !0,
|
|
1222
1209
|
cancelable: !0,
|
|
1223
1210
|
composed: !0
|
|
@@ -1225,12 +1212,12 @@ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
|
|
|
1225
1212
|
let e = getHost();
|
|
1226
1213
|
return ((t, ...n) => {
|
|
1227
1214
|
let r = n.length > 0 ? {
|
|
1228
|
-
|
|
1215
|
+
...Q,
|
|
1229
1216
|
detail: n[0]
|
|
1230
|
-
} :
|
|
1217
|
+
} : Q;
|
|
1231
1218
|
return e.dispatchEvent(new CustomEvent(String(t), r));
|
|
1232
1219
|
});
|
|
1233
|
-
},
|
|
1234
|
-
export { OreApiError, OreError, OreInternalError, OreLifecycleError, bind, classMap, createContext, createId, css, define, each, getHost, html, inject, injectStrict,
|
|
1220
|
+
}, $ = 0, ee = Math.random().toString(36).slice(2, 6), createId = (e = "id") => `${e}-${ee}${++$}`;
|
|
1221
|
+
export { OreApiError, OreError, OreInternalError, OreLifecycleError, bind, classMap, createContext, createId, css, define, each, getHost, html, inject, injectStrict, model, onCleanup, onElement, onEvent, onFormReset, onMounted, x as prop, provide, ref, styleMap, unsafeHtml, useEmit, useField, useSlots, watchEffect, when };
|
|
1235
1222
|
|
|
1236
1223
|
//# sourceMappingURL=ore.js.map
|