@nisli/core 0.56.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -6
- package/dist/bundler/component.js +409 -0
- package/dist/bundler/component.js.map +7 -0
- package/dist/bundler/context.js +27 -0
- package/dist/bundler/context.js.map +7 -0
- package/dist/bundler/diagnostics.js +55 -0
- package/dist/bundler/diagnostics.js.map +7 -0
- package/dist/bundler/disposable.js +9 -0
- package/dist/bundler/disposable.js.map +7 -0
- package/dist/bundler/element-context.js +47 -0
- package/dist/bundler/element-context.js.map +7 -0
- package/dist/bundler/emitter.js +70 -0
- package/dist/bundler/emitter.js.map +7 -0
- package/dist/bundler/hmr/registry.js +72 -0
- package/dist/bundler/hmr/registry.js.map +7 -0
- package/dist/bundler/hmr/transform.js +30 -0
- package/dist/bundler/hmr/transform.js.map +7 -0
- package/dist/bundler/index.js +103 -0
- package/dist/bundler/index.js.map +7 -0
- package/dist/bundler/injector.js +75 -0
- package/dist/bundler/injector.js.map +7 -0
- package/dist/bundler/lifecycle.js +56 -0
- package/dist/bundler/lifecycle.js.map +7 -0
- package/dist/bundler/projection.js +92 -0
- package/dist/bundler/projection.js.map +7 -0
- package/dist/bundler/query.js +302 -0
- package/dist/bundler/query.js.map +7 -0
- package/dist/bundler/ref.js +16 -0
- package/dist/bundler/ref.js.map +7 -0
- package/dist/bundler/resource.js +99 -0
- package/dist/bundler/resource.js.map +7 -0
- package/dist/bundler/settle.js +43 -0
- package/dist/bundler/settle.js.map +7 -0
- package/dist/bundler/signal.js +403 -0
- package/dist/bundler/signal.js.map +7 -0
- package/dist/bundler/template-audit.js +162 -0
- package/dist/bundler/template-audit.js.map +7 -0
- package/dist/bundler/template.js +847 -0
- package/dist/bundler/template.js.map +7 -0
- package/dist/bundler/view-transition.js +20 -0
- package/dist/bundler/view-transition.js.map +7 -0
- package/dist/bundler/vite-hmr/plugin.js +32 -0
- package/dist/bundler/vite-hmr/plugin.js.map +7 -0
- package/dist/bundler/vite-hmr/runtime.js +8 -0
- package/dist/bundler/vite-hmr/runtime.js.map +7 -0
- package/dist/index.js +2607 -47
- package/dist/index.js.map +7 -1
- package/dist/index.production.js +2 -0
- package/dist/index.production.js.map +6 -0
- package/dist/{diagnostics.d.ts → types/diagnostics.d.ts} +8 -15
- package/dist/{template-audit.d.ts → types/template-audit.d.ts} +4 -5
- package/package.json +12 -9
- package/dist/component.js +0 -633
- package/dist/component.js.map +0 -1
- package/dist/context.js +0 -55
- package/dist/context.js.map +0 -1
- package/dist/diagnostics.js +0 -118
- package/dist/diagnostics.js.map +0 -1
- package/dist/disposable.js +0 -8
- package/dist/disposable.js.map +0 -1
- package/dist/element-context.js +0 -108
- package/dist/element-context.js.map +0 -1
- package/dist/emitter.js +0 -91
- package/dist/emitter.js.map +0 -1
- package/dist/hmr/registry.js +0 -136
- package/dist/hmr/registry.js.map +0 -1
- package/dist/hmr/transform.js +0 -52
- package/dist/hmr/transform.js.map +0 -1
- package/dist/injector.js +0 -118
- package/dist/injector.js.map +0 -1
- package/dist/lifecycle.js +0 -117
- package/dist/lifecycle.js.map +0 -1
- package/dist/projection.js +0 -179
- package/dist/projection.js.map +0 -1
- package/dist/query.js +0 -429
- package/dist/query.js.map +0 -1
- package/dist/ref.js +0 -43
- package/dist/ref.js.map +0 -1
- package/dist/resource.js +0 -129
- package/dist/resource.js.map +0 -1
- package/dist/settle.js +0 -106
- package/dist/settle.js.map +0 -1
- package/dist/signal.js +0 -645
- package/dist/signal.js.map +0 -1
- package/dist/template-audit.js +0 -246
- package/dist/template-audit.js.map +0 -1
- package/dist/template.js +0 -1244
- package/dist/template.js.map +0 -1
- package/dist/view-transition.js +0 -98
- package/dist/view-transition.js.map +0 -1
- package/dist/vite-hmr/plugin.js +0 -62
- package/dist/vite-hmr/plugin.js.map +0 -1
- package/dist/vite-hmr/runtime.js +0 -17
- package/dist/vite-hmr/runtime.js.map +0 -1
- /package/dist/{component.d.ts → types/component.d.ts} +0 -0
- /package/dist/{context.d.ts → types/context.d.ts} +0 -0
- /package/dist/{disposable.d.ts → types/disposable.d.ts} +0 -0
- /package/dist/{element-context.d.ts → types/element-context.d.ts} +0 -0
- /package/dist/{emitter.d.ts → types/emitter.d.ts} +0 -0
- /package/dist/{hmr → types/hmr}/registry.d.ts +0 -0
- /package/dist/{hmr → types/hmr}/transform.d.ts +0 -0
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
- /package/dist/{injector.d.ts → types/injector.d.ts} +0 -0
- /package/dist/{lifecycle.d.ts → types/lifecycle.d.ts} +0 -0
- /package/dist/{projection.d.ts → types/projection.d.ts} +0 -0
- /package/dist/{query.d.ts → types/query.d.ts} +0 -0
- /package/dist/{ref.d.ts → types/ref.d.ts} +0 -0
- /package/dist/{resource.d.ts → types/resource.d.ts} +0 -0
- /package/dist/{settle.d.ts → types/settle.d.ts} +0 -0
- /package/dist/{signal.d.ts → types/signal.d.ts} +0 -0
- /package/dist/{template.d.ts → types/template.d.ts} +0 -0
- /package/dist/{view-transition.d.ts → types/view-transition.d.ts} +0 -0
- /package/dist/{vite-hmr → types/vite-hmr}/plugin.d.ts +0 -0
- /package/dist/{vite-hmr → types/vite-hmr}/runtime.d.ts +0 -0
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
import {
|
|
2
|
+
signal,
|
|
3
|
+
isSignal,
|
|
4
|
+
effect,
|
|
5
|
+
computed,
|
|
6
|
+
untrack
|
|
7
|
+
} from "./signal.js";
|
|
8
|
+
import { isRef } from "./ref.js";
|
|
9
|
+
import { auditTemplate, captureCallsite } from "./template-audit.js";
|
|
10
|
+
const canMoveWithin = (parent) => typeof parent.moveBefore === "function";
|
|
11
|
+
function untracked(fn) {
|
|
12
|
+
let result;
|
|
13
|
+
untrack(() => {
|
|
14
|
+
result = fn();
|
|
15
|
+
});
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
function raw(value) {
|
|
19
|
+
return { __raw: true, value };
|
|
20
|
+
}
|
|
21
|
+
function isRawHtml(value) {
|
|
22
|
+
return typeof value === "object" && value !== null && "__raw" in value && value.__raw === true && typeof value.value === "string";
|
|
23
|
+
}
|
|
24
|
+
function sanitized(value) {
|
|
25
|
+
return { __sanitize: true, value };
|
|
26
|
+
}
|
|
27
|
+
function isSanitizedHtml(value) {
|
|
28
|
+
return typeof value === "object" && value !== null && "__sanitize" in value && value.__sanitize === true && typeof value.value === "string";
|
|
29
|
+
}
|
|
30
|
+
let sanitizerFallback = null;
|
|
31
|
+
function setSanitizerFallback(fn) {
|
|
32
|
+
sanitizerFallback = fn;
|
|
33
|
+
}
|
|
34
|
+
const nativeSetHtml = (el2, html2) => {
|
|
35
|
+
el2.setHTML(html2);
|
|
36
|
+
};
|
|
37
|
+
function sanitizerFor(el2) {
|
|
38
|
+
const platform = typeof Element === "function" ? Element.prototype.setHTML : void 0;
|
|
39
|
+
return typeof platform === "function" && el2.setHTML === platform ? nativeSetHtml : sanitizerFallback;
|
|
40
|
+
}
|
|
41
|
+
function isTrustedHtml(value) {
|
|
42
|
+
const tt = globalThis.trustedTypes;
|
|
43
|
+
return tt !== void 0 && tt.isHTML(value);
|
|
44
|
+
}
|
|
45
|
+
function nisliError(code, message) {
|
|
46
|
+
return new Error(`[nisli] ${code}: ${message}`);
|
|
47
|
+
}
|
|
48
|
+
const templateCache = /* @__PURE__ */ new WeakMap();
|
|
49
|
+
let parseCount = 0;
|
|
50
|
+
function __templateParseCount() {
|
|
51
|
+
return parseCount;
|
|
52
|
+
}
|
|
53
|
+
function parseTemplate(strings, valueCount) {
|
|
54
|
+
let template = templateCache.get(strings);
|
|
55
|
+
if (template) return template;
|
|
56
|
+
let htmlStr = "";
|
|
57
|
+
let inTag = false;
|
|
58
|
+
let quoteChar = null;
|
|
59
|
+
for (let i = 0; i < strings.length; i++) {
|
|
60
|
+
const s = strings[i] ?? "";
|
|
61
|
+
for (let c = 0; c < s.length; c++) {
|
|
62
|
+
const ch = s.charAt(c);
|
|
63
|
+
if (quoteChar) {
|
|
64
|
+
if (ch === quoteChar) quoteChar = null;
|
|
65
|
+
} else if (inTag) {
|
|
66
|
+
if (ch === ">") inTag = false;
|
|
67
|
+
else if (ch === '"' || ch === "'") quoteChar = ch;
|
|
68
|
+
} else {
|
|
69
|
+
if (ch === "<") inTag = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
htmlStr += s;
|
|
73
|
+
if (i < valueCount) {
|
|
74
|
+
const needsQuotes = inTag && !quoteChar && /=\s*$/.test(s);
|
|
75
|
+
htmlStr += needsQuotes ? `"${createMarker(i)}"` : createMarker(i);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
parseCount++;
|
|
79
|
+
template = document.createElement("template");
|
|
80
|
+
template.innerHTML = htmlStr;
|
|
81
|
+
templateCache.set(strings, template);
|
|
82
|
+
if (process.env.NODE_ENV !== "production") auditTemplate(strings, template);
|
|
83
|
+
return template;
|
|
84
|
+
}
|
|
85
|
+
const MARKER_PREFIX = "<!--bk-";
|
|
86
|
+
const MARKER_SUFFIX = "-->";
|
|
87
|
+
const ATTR_MARKER = "bk-";
|
|
88
|
+
function createMarker(index) {
|
|
89
|
+
return `${MARKER_PREFIX}${index}${MARKER_SUFFIX}`;
|
|
90
|
+
}
|
|
91
|
+
function html(strings, ...values) {
|
|
92
|
+
const bindings = [];
|
|
93
|
+
const disposers = [];
|
|
94
|
+
if (process.env.NODE_ENV !== "production") captureCallsite(strings);
|
|
95
|
+
let mounted = false;
|
|
96
|
+
return {
|
|
97
|
+
__templateResult: true,
|
|
98
|
+
mount(host) {
|
|
99
|
+
if (mounted && values.length > 0) {
|
|
100
|
+
throw nisliError(
|
|
101
|
+
"N105",
|
|
102
|
+
`mount() on an already-mounted TemplateResult with ${values.length} value binding(s) \u2014 dispose() it first or create a fresh template per mount. Template starts: ${JSON.stringify((strings[0] ?? "").slice(0, 60))}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
mounted = true;
|
|
106
|
+
const template = parseTemplate(strings, values.length);
|
|
107
|
+
const fragment = template.content.cloneNode(true);
|
|
108
|
+
processNode(fragment, values, bindings, disposers);
|
|
109
|
+
host.appendChild(fragment);
|
|
110
|
+
},
|
|
111
|
+
dispose() {
|
|
112
|
+
for (const d of disposers) {
|
|
113
|
+
try {
|
|
114
|
+
d();
|
|
115
|
+
} catch (_) {
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
disposers.length = 0;
|
|
119
|
+
for (const b of bindings) {
|
|
120
|
+
if ("dispose" in b && b.dispose) {
|
|
121
|
+
try {
|
|
122
|
+
b.dispose();
|
|
123
|
+
} catch (_) {
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
bindings.length = 0;
|
|
128
|
+
mounted = false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function processNode(node, values, bindings, disposers) {
|
|
133
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
134
|
+
const el2 = node;
|
|
135
|
+
processAttributes(el2, values, bindings, disposers);
|
|
136
|
+
}
|
|
137
|
+
if (node.nodeType === Node.COMMENT_NODE) {
|
|
138
|
+
const comment = node;
|
|
139
|
+
const text = comment.textContent || "";
|
|
140
|
+
if (text.startsWith("bk-") && !isNaN(Number(text.slice(3)))) {
|
|
141
|
+
const index = Number(text.slice(3));
|
|
142
|
+
const value = values[index];
|
|
143
|
+
replaceMarkerWithBinding(comment, value, bindings, disposers);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const children = [...node.childNodes];
|
|
148
|
+
for (const child of children) {
|
|
149
|
+
processNode(child, values, bindings, disposers);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function processAttributes(el2, values, bindings, disposers) {
|
|
153
|
+
const attrsToRemove = [];
|
|
154
|
+
for (const attr of [...el2.attributes]) {
|
|
155
|
+
const name = attr.name;
|
|
156
|
+
const attrValue = attr.value;
|
|
157
|
+
if (name.startsWith("@")) {
|
|
158
|
+
const eventParts = name.slice(1).split(".");
|
|
159
|
+
const eventName = eventParts[0] ?? "";
|
|
160
|
+
const modifiers = eventParts.slice(1);
|
|
161
|
+
const markerMatch = attrValue.match(/<!--bk-(\d+)-->/);
|
|
162
|
+
if (markerMatch) {
|
|
163
|
+
const index = Number(markerMatch[1]);
|
|
164
|
+
const handler = values[index];
|
|
165
|
+
if (typeof handler === "function") {
|
|
166
|
+
bindEvent(el2, eventName, handler, modifiers, bindings);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
attrsToRemove.push(name);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (name.startsWith("class:")) {
|
|
173
|
+
const className = name.slice(6);
|
|
174
|
+
const markerMatch = attrValue.match(/<!--bk-(\d+)-->/);
|
|
175
|
+
if (markerMatch) {
|
|
176
|
+
const index = Number(markerMatch[1]);
|
|
177
|
+
const value = values[index];
|
|
178
|
+
bindClass(el2, className, value, bindings, disposers);
|
|
179
|
+
}
|
|
180
|
+
attrsToRemove.push(name);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (name === "html:inner") {
|
|
184
|
+
const markerMatch = attrValue.match(/<!--bk-(\d+)-->/);
|
|
185
|
+
if (markerMatch) {
|
|
186
|
+
const index = Number(markerMatch[1]);
|
|
187
|
+
const value = values[index];
|
|
188
|
+
bindInnerHtml(el2, value, bindings, disposers);
|
|
189
|
+
}
|
|
190
|
+
attrsToRemove.push(name);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (name === "ref" && attrValue.includes(MARKER_PREFIX)) {
|
|
194
|
+
const markerMatch = attrValue.match(/<!--bk-(\d+)-->/);
|
|
195
|
+
if (markerMatch) {
|
|
196
|
+
const index = Number(markerMatch[1]);
|
|
197
|
+
const value = values[index];
|
|
198
|
+
if (isRef(value)) {
|
|
199
|
+
value.current = el2;
|
|
200
|
+
disposers.push(() => {
|
|
201
|
+
value.current = null;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
attrsToRemove.push(name);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (attrValue.includes(MARKER_PREFIX)) {
|
|
209
|
+
const markers = [...attrValue.matchAll(/<!--bk-(\d+)-->/g)];
|
|
210
|
+
if (markers.length) {
|
|
211
|
+
const first = markers[0];
|
|
212
|
+
if (markers.length === 1 && first && attrValue === first[0]) {
|
|
213
|
+
bindAttribute(el2, name, values[Number(first[1])], bindings, disposers);
|
|
214
|
+
} else {
|
|
215
|
+
const resolve = () => attrValue.replace(/<!--bk-(\d+)-->/g, (_, i) => {
|
|
216
|
+
const v = values[Number(i)];
|
|
217
|
+
const raw2 = isSignal(v) ? v.value : v;
|
|
218
|
+
return raw2 == null || raw2 === false ? "" : String(raw2);
|
|
219
|
+
});
|
|
220
|
+
const hasSignals = markers.some((m) => isSignal(values[Number(m[1])]));
|
|
221
|
+
bindAttribute(el2, name, hasSignals ? computed(resolve) : resolve(), bindings, disposers);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
for (const name of attrsToRemove) {
|
|
228
|
+
el2.removeAttribute(name);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function mountFactoryResult(factory) {
|
|
232
|
+
const el2 = document.createElement(factory.tagName);
|
|
233
|
+
const localDisposers = [];
|
|
234
|
+
for (const [key, raw2] of Object.entries(factory.props)) {
|
|
235
|
+
if (isSignal(raw2)) {
|
|
236
|
+
const sig = raw2;
|
|
237
|
+
const unsub = sig.subscribe((newVal) => {
|
|
238
|
+
el2._setProp?.(key, newVal);
|
|
239
|
+
});
|
|
240
|
+
localDisposers.push(unsub);
|
|
241
|
+
} else {
|
|
242
|
+
el2._setProp?.(key, raw2);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (factory.hostAttrs?.class != null) {
|
|
246
|
+
const classVal = factory.hostAttrs.class;
|
|
247
|
+
if (isSignal(classVal)) {
|
|
248
|
+
const sig = classVal;
|
|
249
|
+
let prevClasses = [];
|
|
250
|
+
const applyClasses = (raw2) => {
|
|
251
|
+
const next = raw2 ? raw2.split(/\s+/).filter(Boolean) : [];
|
|
252
|
+
for (const cls of prevClasses) {
|
|
253
|
+
if (!next.includes(cls)) el2.classList.remove(cls);
|
|
254
|
+
}
|
|
255
|
+
for (const cls of next) {
|
|
256
|
+
if (!prevClasses.includes(cls)) el2.classList.add(cls);
|
|
257
|
+
}
|
|
258
|
+
prevClasses = next;
|
|
259
|
+
};
|
|
260
|
+
const unsub = sig.subscribe(applyClasses);
|
|
261
|
+
localDisposers.push(unsub);
|
|
262
|
+
} else if (typeof classVal === "string" && classVal) {
|
|
263
|
+
for (const cls of classVal.split(/\s+/).filter(Boolean)) {
|
|
264
|
+
el2.classList.add(cls);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
element: el2,
|
|
270
|
+
dispose() {
|
|
271
|
+
for (const dispose of localDisposers.splice(0)) {
|
|
272
|
+
try {
|
|
273
|
+
dispose();
|
|
274
|
+
} catch (_) {
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function replaceMarkerWithBinding(comment, value, bindings, disposers) {
|
|
281
|
+
const parent = comment.parentNode;
|
|
282
|
+
if (!parent) return;
|
|
283
|
+
if (isSignal(value)) {
|
|
284
|
+
const startMarker = document.createComment("slot-start");
|
|
285
|
+
const endMarker = document.createComment("slot-end");
|
|
286
|
+
parent.replaceChild(endMarker, comment);
|
|
287
|
+
parent.insertBefore(startMarker, endMarker);
|
|
288
|
+
let currentResults = [];
|
|
289
|
+
let currentNodes = [];
|
|
290
|
+
let currentFactoryDisposers = [];
|
|
291
|
+
let currentText = null;
|
|
292
|
+
const NOT_RENDERED = /* @__PURE__ */ Symbol("not-rendered");
|
|
293
|
+
let lastValue = NOT_RENDERED;
|
|
294
|
+
const dispose = effect(() => {
|
|
295
|
+
const newValue = value.value;
|
|
296
|
+
const liveParent = endMarker.parentNode;
|
|
297
|
+
if (!liveParent) return;
|
|
298
|
+
if (newValue === lastValue) return;
|
|
299
|
+
lastValue = newValue;
|
|
300
|
+
const isTemplate = Boolean(
|
|
301
|
+
newValue && typeof newValue === "object" && "__templateResult" in newValue
|
|
302
|
+
);
|
|
303
|
+
const isFactory = Boolean(
|
|
304
|
+
newValue && typeof newValue === "object" && "__type" in newValue && newValue.__type === "factory"
|
|
305
|
+
);
|
|
306
|
+
const isPrimitive = newValue != null && newValue !== false && !Array.isArray(newValue) && !isTemplate && !isFactory;
|
|
307
|
+
if (isPrimitive && currentText) {
|
|
308
|
+
currentText.data = String(newValue);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
for (const r of currentResults) {
|
|
312
|
+
try {
|
|
313
|
+
r.dispose();
|
|
314
|
+
} catch (_) {
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
for (const dispose2 of currentFactoryDisposers) {
|
|
318
|
+
try {
|
|
319
|
+
dispose2();
|
|
320
|
+
} catch (_) {
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
for (const node of currentNodes) {
|
|
324
|
+
node.parentNode?.removeChild(node);
|
|
325
|
+
}
|
|
326
|
+
currentNodes = [];
|
|
327
|
+
currentResults = [];
|
|
328
|
+
currentFactoryDisposers = [];
|
|
329
|
+
currentText = null;
|
|
330
|
+
if (newValue == null) {
|
|
331
|
+
} else if (Array.isArray(newValue)) {
|
|
332
|
+
for (const item of newValue) {
|
|
333
|
+
if (item && typeof item === "object" && "__templateResult" in item) {
|
|
334
|
+
const tpl = item;
|
|
335
|
+
const wrapper = document.createDocumentFragment();
|
|
336
|
+
tpl.mount(wrapper);
|
|
337
|
+
const nodes = [...wrapper.childNodes];
|
|
338
|
+
currentNodes.push(...nodes);
|
|
339
|
+
currentResults.push(tpl);
|
|
340
|
+
liveParent.insertBefore(wrapper, endMarker);
|
|
341
|
+
} else if (item && typeof item === "object" && "__type" in item && item.__type === "factory") {
|
|
342
|
+
const mounted = mountFactoryResult(item);
|
|
343
|
+
currentNodes.push(mounted.element);
|
|
344
|
+
currentFactoryDisposers.push(mounted.dispose);
|
|
345
|
+
liveParent.insertBefore(mounted.element, endMarker);
|
|
346
|
+
} else if (item != null && item !== false) {
|
|
347
|
+
const textNode = document.createTextNode(String(item));
|
|
348
|
+
currentNodes.push(textNode);
|
|
349
|
+
liveParent.insertBefore(textNode, endMarker);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} else if (isTemplate) {
|
|
353
|
+
const tpl = newValue;
|
|
354
|
+
const wrapper = document.createDocumentFragment();
|
|
355
|
+
tpl.mount(wrapper);
|
|
356
|
+
currentNodes = [...wrapper.childNodes];
|
|
357
|
+
currentResults.push(tpl);
|
|
358
|
+
liveParent.insertBefore(wrapper, endMarker);
|
|
359
|
+
} else if (isFactory) {
|
|
360
|
+
const mounted = mountFactoryResult(newValue);
|
|
361
|
+
currentNodes.push(mounted.element);
|
|
362
|
+
currentFactoryDisposers.push(mounted.dispose);
|
|
363
|
+
liveParent.insertBefore(mounted.element, endMarker);
|
|
364
|
+
} else if (newValue !== false) {
|
|
365
|
+
currentText = document.createTextNode(String(newValue));
|
|
366
|
+
currentNodes.push(currentText);
|
|
367
|
+
liveParent.insertBefore(currentText, endMarker);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
disposers.push(dispose);
|
|
371
|
+
disposers.push(() => {
|
|
372
|
+
for (const r of currentResults.splice(0)) {
|
|
373
|
+
try {
|
|
374
|
+
r.dispose();
|
|
375
|
+
} catch (_) {
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
for (const factoryDispose of currentFactoryDisposers.splice(0)) {
|
|
379
|
+
try {
|
|
380
|
+
factoryDispose();
|
|
381
|
+
} catch (_) {
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
currentNodes = [];
|
|
385
|
+
currentText = null;
|
|
386
|
+
});
|
|
387
|
+
} else if (value && typeof value === "object" && "__templateResult" in value) {
|
|
388
|
+
const result = value;
|
|
389
|
+
const startMarker = document.createComment("tpl-start");
|
|
390
|
+
const endMarker = document.createComment("tpl-end");
|
|
391
|
+
parent.replaceChild(endMarker, comment);
|
|
392
|
+
parent.insertBefore(startMarker, endMarker);
|
|
393
|
+
const wrapper = document.createDocumentFragment();
|
|
394
|
+
result.mount(wrapper);
|
|
395
|
+
parent.insertBefore(wrapper, endMarker);
|
|
396
|
+
disposers.push(() => result.dispose());
|
|
397
|
+
} else if (value && typeof value === "object" && "__type" in value && value.__type === "factory") {
|
|
398
|
+
const mounted = mountFactoryResult(value);
|
|
399
|
+
parent.replaceChild(mounted.element, comment);
|
|
400
|
+
disposers.push(mounted.dispose);
|
|
401
|
+
} else if (Array.isArray(value)) {
|
|
402
|
+
const startMarker = document.createComment("list-start");
|
|
403
|
+
const endMarker = document.createComment("list-end");
|
|
404
|
+
parent.replaceChild(endMarker, comment);
|
|
405
|
+
parent.insertBefore(startMarker, endMarker);
|
|
406
|
+
for (const item of value) {
|
|
407
|
+
if (item && typeof item === "object" && "__templateResult" in item) {
|
|
408
|
+
const wrapper = document.createDocumentFragment();
|
|
409
|
+
item.mount(wrapper);
|
|
410
|
+
parent.insertBefore(wrapper, endMarker);
|
|
411
|
+
disposers.push(() => item.dispose());
|
|
412
|
+
} else if (item && typeof item === "object" && "__type" in item && item.__type === "factory") {
|
|
413
|
+
const mounted = mountFactoryResult(item);
|
|
414
|
+
parent.insertBefore(mounted.element, endMarker);
|
|
415
|
+
disposers.push(mounted.dispose);
|
|
416
|
+
} else {
|
|
417
|
+
const textNode = document.createTextNode(String(item));
|
|
418
|
+
parent.insertBefore(textNode, endMarker);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
} else if (value == null || value === false) {
|
|
422
|
+
parent.removeChild(comment);
|
|
423
|
+
} else {
|
|
424
|
+
const textNode = document.createTextNode(String(value));
|
|
425
|
+
parent.replaceChild(textNode, comment);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function bindAttribute(el2, name, value, bindings, disposers) {
|
|
429
|
+
if (name === "class") {
|
|
430
|
+
bindClassAttribute(el2, value, bindings, disposers);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const isHtmlAttr = name === "id" || name === "style" || name === "slot" || name === "title" || name === "role" || name === "tabindex" || name === "name" || name.startsWith("data-") || name.startsWith("aria-");
|
|
434
|
+
const hasPropSetter = !isHtmlAttr && typeof el2._setProp === "function";
|
|
435
|
+
if (hasPropSetter) {
|
|
436
|
+
if (isSignal(value)) {
|
|
437
|
+
const binding = { type: "attribute", element: el2, name };
|
|
438
|
+
bindings.push(binding);
|
|
439
|
+
const dispose = effect(() => {
|
|
440
|
+
el2._setProp(name, value.value);
|
|
441
|
+
});
|
|
442
|
+
binding.dispose = dispose;
|
|
443
|
+
disposers.push(dispose);
|
|
444
|
+
} else {
|
|
445
|
+
el2._setProp(name, value);
|
|
446
|
+
}
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
bindPlainAttribute(el2, name, value, bindings, disposers);
|
|
450
|
+
}
|
|
451
|
+
function bindPlainAttribute(el2, name, value, bindings, disposers) {
|
|
452
|
+
if (isSignal(value)) {
|
|
453
|
+
const binding = { type: "attribute", element: el2, name };
|
|
454
|
+
bindings.push(binding);
|
|
455
|
+
const dispose = effect(() => {
|
|
456
|
+
const v = value.value;
|
|
457
|
+
if (v == null || v === false) {
|
|
458
|
+
el2.removeAttribute(name);
|
|
459
|
+
} else if (v === true) {
|
|
460
|
+
el2.setAttribute(name, "");
|
|
461
|
+
} else {
|
|
462
|
+
el2.setAttribute(name, String(v));
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
binding.dispose = dispose;
|
|
466
|
+
disposers.push(dispose);
|
|
467
|
+
} else {
|
|
468
|
+
if (value == null || value === false) {
|
|
469
|
+
el2.removeAttribute(name);
|
|
470
|
+
} else if (value === true) {
|
|
471
|
+
el2.setAttribute(name, "");
|
|
472
|
+
} else {
|
|
473
|
+
el2.setAttribute(name, String(value));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function bindClassAttribute(el2, value, bindings, disposers) {
|
|
478
|
+
let initialized = false;
|
|
479
|
+
let prevClasses = [];
|
|
480
|
+
const applyClasses = (raw2) => {
|
|
481
|
+
if (!initialized) {
|
|
482
|
+
el2.setAttribute("class", "");
|
|
483
|
+
initialized = true;
|
|
484
|
+
}
|
|
485
|
+
const str = raw2 == null || raw2 === false ? "" : String(raw2);
|
|
486
|
+
const next = str.split(/\s+/).filter(Boolean);
|
|
487
|
+
for (const cls of prevClasses) {
|
|
488
|
+
if (!next.includes(cls)) {
|
|
489
|
+
el2.classList.remove(cls);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
for (const cls of next) {
|
|
493
|
+
if (!prevClasses.includes(cls)) {
|
|
494
|
+
el2.classList.add(cls);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
prevClasses = next;
|
|
498
|
+
};
|
|
499
|
+
if (isSignal(value)) {
|
|
500
|
+
const binding = { type: "attribute", element: el2, name: "class" };
|
|
501
|
+
bindings.push(binding);
|
|
502
|
+
const dispose = effect(() => {
|
|
503
|
+
applyClasses(value.value);
|
|
504
|
+
});
|
|
505
|
+
binding.dispose = dispose;
|
|
506
|
+
disposers.push(dispose);
|
|
507
|
+
} else {
|
|
508
|
+
applyClasses(value);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function bindClass(el2, className, value, bindings, disposers) {
|
|
512
|
+
if (isSignal(value)) {
|
|
513
|
+
const binding = { type: "class", element: el2, className };
|
|
514
|
+
bindings.push(binding);
|
|
515
|
+
const dispose = effect(() => {
|
|
516
|
+
const v = value.value;
|
|
517
|
+
el2.classList.toggle(className, !!v);
|
|
518
|
+
});
|
|
519
|
+
binding.dispose = dispose;
|
|
520
|
+
disposers.push(dispose);
|
|
521
|
+
} else {
|
|
522
|
+
el2.classList.toggle(className, !!value);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function bindInnerHtml(el2, value, bindings, disposers) {
|
|
526
|
+
const resolveHtml = (v) => {
|
|
527
|
+
if (v == null) return "";
|
|
528
|
+
if (isRawHtml(v)) {
|
|
529
|
+
if (isSanitizedHtml(v)) {
|
|
530
|
+
throw nisliError(
|
|
531
|
+
"N106",
|
|
532
|
+
`html:inner rejects a value branded both raw() and sanitized() \u2014 the trust decision is ambiguous. Pick one brand.`
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
return v.value;
|
|
536
|
+
}
|
|
537
|
+
if (isSanitizedHtml(v)) {
|
|
538
|
+
if (sanitizerFor(el2) === null) {
|
|
539
|
+
throw nisliError(
|
|
540
|
+
"N107",
|
|
541
|
+
`html:inner cannot render sanitized() markup: this engine has no native Element.setHTML() and no fallback is registered. Wire one at startup \u2014 setSanitizerFallback((el, html) => { el.innerHTML = DOMPurify.sanitize(html) }) \u2014 nisli ships no sanitizer and will not fall back to innerHTML.`
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
return v;
|
|
545
|
+
}
|
|
546
|
+
if (isTrustedHtml(v)) return v;
|
|
547
|
+
throw nisliError(
|
|
548
|
+
"N106",
|
|
549
|
+
`html:inner rejects unbranded values (got ${typeof v}). Wrap trusted markup in raw(html), untrusted markup in sanitized(html) \u2014 and never wrap user-generated input in raw().`
|
|
550
|
+
);
|
|
551
|
+
};
|
|
552
|
+
const writeHtml = (v) => {
|
|
553
|
+
const resolved = resolveHtml(v);
|
|
554
|
+
if (isSanitizedHtml(resolved)) {
|
|
555
|
+
sanitizerFor(el2)?.(el2, resolved.value);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
el2.innerHTML = resolved;
|
|
559
|
+
};
|
|
560
|
+
if (isSignal(value)) {
|
|
561
|
+
untracked(() => resolveHtml(value.value));
|
|
562
|
+
const binding = { type: "innerHtml", element: el2 };
|
|
563
|
+
bindings.push(binding);
|
|
564
|
+
const dispose = effect(() => {
|
|
565
|
+
writeHtml(value.value);
|
|
566
|
+
});
|
|
567
|
+
binding.dispose = dispose;
|
|
568
|
+
disposers.push(dispose);
|
|
569
|
+
} else {
|
|
570
|
+
writeHtml(value);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function bindEvent(el2, eventName, handler, modifiers, bindings) {
|
|
574
|
+
let safeHandler;
|
|
575
|
+
let composed = handler;
|
|
576
|
+
if (modifiers.includes("stop")) {
|
|
577
|
+
const inner = composed;
|
|
578
|
+
composed = (e) => {
|
|
579
|
+
e.stopPropagation();
|
|
580
|
+
inner(e);
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
if (modifiers.includes("prevent")) {
|
|
584
|
+
const inner = composed;
|
|
585
|
+
composed = (e) => {
|
|
586
|
+
e.preventDefault();
|
|
587
|
+
inner(e);
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
if (modifiers.includes("once")) {
|
|
591
|
+
const inner = composed;
|
|
592
|
+
composed = (e) => {
|
|
593
|
+
el2.removeEventListener(eventName, safeHandler);
|
|
594
|
+
inner(e);
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
for (const mod of modifiers) {
|
|
598
|
+
if (["enter", "escape", "space", "tab"].includes(mod)) {
|
|
599
|
+
const keyMap = {
|
|
600
|
+
enter: "Enter",
|
|
601
|
+
escape: "Escape",
|
|
602
|
+
space: " ",
|
|
603
|
+
tab: "Tab"
|
|
604
|
+
};
|
|
605
|
+
const inner = composed;
|
|
606
|
+
composed = (e) => {
|
|
607
|
+
if (e.key === keyMap[mod]) {
|
|
608
|
+
inner(e);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
safeHandler = (e) => {
|
|
614
|
+
try {
|
|
615
|
+
untrack(() => composed(e));
|
|
616
|
+
} catch (err) {
|
|
617
|
+
console.error(`Event handler error for '${eventName}':`, err);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
el2.addEventListener(eventName, safeHandler);
|
|
621
|
+
bindings.push({
|
|
622
|
+
type: "event",
|
|
623
|
+
element: el2,
|
|
624
|
+
eventName,
|
|
625
|
+
handler: safeHandler,
|
|
626
|
+
modifiers,
|
|
627
|
+
dispose: () => el2.removeEventListener(eventName, safeHandler)
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
const EACH_BRAND = /* @__PURE__ */ Symbol.for("backlog.each");
|
|
631
|
+
function asTemplateResult(result) {
|
|
632
|
+
if (result && typeof result === "object" && "__templateResult" in result) {
|
|
633
|
+
return result;
|
|
634
|
+
}
|
|
635
|
+
if (result && typeof result === "object" && result.__type === "factory") {
|
|
636
|
+
let mounted = null;
|
|
637
|
+
return {
|
|
638
|
+
__templateResult: true,
|
|
639
|
+
mount(host) {
|
|
640
|
+
mounted = mountFactoryResult(result);
|
|
641
|
+
host.appendChild(mounted.element);
|
|
642
|
+
},
|
|
643
|
+
dispose() {
|
|
644
|
+
mounted?.dispose();
|
|
645
|
+
mounted?.element.remove();
|
|
646
|
+
mounted = null;
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
throw new TypeError(
|
|
651
|
+
`each(): template callback must return a TemplateResult or a component factory result, got ${result === null ? "null" : typeof result}`
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
function each(items, keyFn, templateFn) {
|
|
655
|
+
let startMarker;
|
|
656
|
+
let endMarker;
|
|
657
|
+
let entries = [];
|
|
658
|
+
let effectDispose = null;
|
|
659
|
+
return {
|
|
660
|
+
__templateResult: true,
|
|
661
|
+
mount(host) {
|
|
662
|
+
startMarker = document.createComment("each-start");
|
|
663
|
+
endMarker = document.createComment("each-end");
|
|
664
|
+
host.appendChild(startMarker);
|
|
665
|
+
host.appendChild(endMarker);
|
|
666
|
+
effectDispose = effect(() => {
|
|
667
|
+
const newItems = items.value;
|
|
668
|
+
reconcile(newItems);
|
|
669
|
+
});
|
|
670
|
+
},
|
|
671
|
+
dispose() {
|
|
672
|
+
if (effectDispose) {
|
|
673
|
+
effectDispose();
|
|
674
|
+
effectDispose = null;
|
|
675
|
+
}
|
|
676
|
+
for (const entry of entries) {
|
|
677
|
+
entry.templateResult.dispose();
|
|
678
|
+
}
|
|
679
|
+
entries = [];
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
function reconcile(newItems) {
|
|
683
|
+
const parent = endMarker.parentNode;
|
|
684
|
+
if (!parent) return;
|
|
685
|
+
const keyedItems = [];
|
|
686
|
+
const keyIndices = /* @__PURE__ */ new Map();
|
|
687
|
+
for (let i = 0; i < newItems.length; i++) {
|
|
688
|
+
const item = newItems[i];
|
|
689
|
+
if (item === void 0) continue;
|
|
690
|
+
const key = keyFn(item, i);
|
|
691
|
+
const previousIndex = keyIndices.get(key);
|
|
692
|
+
if (previousIndex !== void 0) {
|
|
693
|
+
const formattedKey = typeof key === "string" ? JSON.stringify(key) : String(key);
|
|
694
|
+
console.error(
|
|
695
|
+
`each() requires unique keys. Duplicate key ${formattedKey} found at indices ${previousIndex} and ${i}; reconciliation skipped.`
|
|
696
|
+
);
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
keyIndices.set(key, i);
|
|
700
|
+
keyedItems.push({ item, index: i, key });
|
|
701
|
+
}
|
|
702
|
+
const oldMap = /* @__PURE__ */ new Map();
|
|
703
|
+
for (const entry of entries) {
|
|
704
|
+
oldMap.set(entry.key, entry);
|
|
705
|
+
}
|
|
706
|
+
const newEntries = [];
|
|
707
|
+
const newKeys = /* @__PURE__ */ new Set();
|
|
708
|
+
for (const { item, index, key } of keyedItems) {
|
|
709
|
+
newKeys.add(key);
|
|
710
|
+
const existing = oldMap.get(key);
|
|
711
|
+
if (existing) {
|
|
712
|
+
existing.itemSignal.value = item;
|
|
713
|
+
existing.indexSignal.value = index;
|
|
714
|
+
newEntries.push(existing);
|
|
715
|
+
} else {
|
|
716
|
+
const itemSignal = signal(item);
|
|
717
|
+
const indexSignal = signal(index);
|
|
718
|
+
const wrapper = document.createElement("each-item");
|
|
719
|
+
wrapper.style.display = "contents";
|
|
720
|
+
const templateResult = asTemplateResult(templateFn(itemSignal, indexSignal));
|
|
721
|
+
templateResult.mount(wrapper);
|
|
722
|
+
newEntries.push({ key, itemSignal, indexSignal, templateResult, wrapper });
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
for (const entry of entries) {
|
|
726
|
+
if (!newKeys.has(entry.key)) {
|
|
727
|
+
entry.templateResult.dispose();
|
|
728
|
+
entry.wrapper.parentNode?.removeChild(entry.wrapper);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
let cursor = startMarker;
|
|
732
|
+
for (const entry of newEntries) {
|
|
733
|
+
const nextSibling = cursor.nextSibling;
|
|
734
|
+
if (nextSibling !== entry.wrapper) {
|
|
735
|
+
if (entry.wrapper.parentNode === parent && canMoveWithin(parent)) {
|
|
736
|
+
parent.moveBefore(entry.wrapper, nextSibling);
|
|
737
|
+
} else {
|
|
738
|
+
parent.insertBefore(entry.wrapper, nextSibling);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
cursor = entry.wrapper;
|
|
742
|
+
}
|
|
743
|
+
entries = newEntries;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function when(condition, template, elseTemplate) {
|
|
747
|
+
const resolveBranch = (branch) => {
|
|
748
|
+
if (branch === void 0) return null;
|
|
749
|
+
if (typeof branch === "function") return untracked(branch);
|
|
750
|
+
return branch;
|
|
751
|
+
};
|
|
752
|
+
if (isSignal(condition)) {
|
|
753
|
+
let lastGate;
|
|
754
|
+
let lastResult = null;
|
|
755
|
+
return computed(() => {
|
|
756
|
+
const gate = !!condition.value;
|
|
757
|
+
if (gate === lastGate) return lastResult;
|
|
758
|
+
const next = gate ? resolveBranch(template) : resolveBranch(elseTemplate);
|
|
759
|
+
lastGate = gate;
|
|
760
|
+
lastResult = next;
|
|
761
|
+
return next;
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
return condition ? resolveBranch(template) : resolveBranch(elseTemplate);
|
|
765
|
+
}
|
|
766
|
+
function el(tag, props = {}, children) {
|
|
767
|
+
let node = null;
|
|
768
|
+
const bindings = [];
|
|
769
|
+
const disposers = [];
|
|
770
|
+
return {
|
|
771
|
+
__templateResult: true,
|
|
772
|
+
mount(host) {
|
|
773
|
+
const element = document.createElement(tag);
|
|
774
|
+
node = element;
|
|
775
|
+
for (const [key, val] of Object.entries(props)) {
|
|
776
|
+
if (val === void 0) continue;
|
|
777
|
+
if (key === "ref") {
|
|
778
|
+
if (isRef(val)) {
|
|
779
|
+
val.current = element;
|
|
780
|
+
disposers.push(() => {
|
|
781
|
+
val.current = null;
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
if (key === "on") {
|
|
787
|
+
for (const [event, handler] of Object.entries(val)) {
|
|
788
|
+
bindEvent(element, event, handler, [], bindings);
|
|
789
|
+
}
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
if (key === "class") {
|
|
793
|
+
bindClassAttribute(element, val, bindings, disposers);
|
|
794
|
+
continue;
|
|
795
|
+
}
|
|
796
|
+
bindPlainAttribute(element, key, val, bindings, disposers);
|
|
797
|
+
}
|
|
798
|
+
const flat = [];
|
|
799
|
+
flattenChildren(children, flat);
|
|
800
|
+
for (const child of flat) {
|
|
801
|
+
const anchor = document.createComment("");
|
|
802
|
+
element.appendChild(anchor);
|
|
803
|
+
replaceMarkerWithBinding(anchor, child, bindings, disposers);
|
|
804
|
+
}
|
|
805
|
+
host.appendChild(element);
|
|
806
|
+
},
|
|
807
|
+
dispose() {
|
|
808
|
+
for (const d of disposers) {
|
|
809
|
+
try {
|
|
810
|
+
d();
|
|
811
|
+
} catch (_) {
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
disposers.length = 0;
|
|
815
|
+
for (const b of bindings) {
|
|
816
|
+
if ("dispose" in b && b.dispose) {
|
|
817
|
+
try {
|
|
818
|
+
b.dispose();
|
|
819
|
+
} catch (_) {
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
bindings.length = 0;
|
|
824
|
+
node?.parentNode?.removeChild(node);
|
|
825
|
+
node = null;
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function flattenChildren(children, out) {
|
|
830
|
+
if (children === void 0) return;
|
|
831
|
+
if (Array.isArray(children)) {
|
|
832
|
+
for (const c of children) flattenChildren(c, out);
|
|
833
|
+
} else {
|
|
834
|
+
out.push(children);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
export {
|
|
838
|
+
__templateParseCount,
|
|
839
|
+
each,
|
|
840
|
+
el,
|
|
841
|
+
html,
|
|
842
|
+
raw,
|
|
843
|
+
sanitized,
|
|
844
|
+
setSanitizerFallback,
|
|
845
|
+
when
|
|
846
|
+
};
|
|
847
|
+
//# sourceMappingURL=template.js.map
|