@cossackframework/renderer 0.8.2 → 0.9.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 +5 -4
- package/agent-docs.json +88 -0
- package/dist/browser-ssr.d.ts +5 -0
- package/dist/browser-ssr.js +7 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +9 -0
- package/dist/cossack-element.d.ts +5 -1
- package/dist/cossack-element.js +10 -7
- package/dist/cossack-html.d.ts +24 -2
- package/dist/cossack-html.js +657 -322
- package/dist/directives.d.ts +4 -0
- package/dist/index.js +3 -3
- package/dist/minify-html.js +2 -2
- package/dist/ssr-form-values.d.ts +2 -0
- package/dist/ssr-form-values.js +71 -0
- package/package.json +10 -4
package/dist/cossack-html.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// @ts-self-types="./cossack-html.d.ts"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { serializeFormValues as e } from "./ssr-form-values.js";
|
|
3
|
+
import { isComponentResult as t } from "./component.js";
|
|
4
|
+
import { CossackElement as n, popCurrentInstance as r, pushCurrentInstance as i } from "./cossack-element.js";
|
|
5
|
+
import { BindResult as a, CacheResult as o, GuardResult as s, IfDefinedResult as c, KeyResult as l, LiveResult as u, PreventDefaultResult as d, RepeatResult as f, resolveField as p, setField as m } from "./directives.js";
|
|
5
6
|
//#region src/cossack-html.ts
|
|
6
|
-
var
|
|
7
|
+
var h = class {
|
|
7
8
|
strings;
|
|
8
9
|
values;
|
|
9
10
|
_cossack_template_result = !0;
|
|
@@ -13,91 +14,130 @@ var m = class {
|
|
|
13
14
|
}
|
|
14
15
|
__cossackOwner;
|
|
15
16
|
__cossackScope;
|
|
16
|
-
},
|
|
17
|
-
let r = new
|
|
17
|
+
}, g = (e, ...t) => {
|
|
18
|
+
let r = new h(e, t, 1), i = n.currentRenderingInstance;
|
|
18
19
|
return i && (r.__cossackOwner = i, r.__cossackScope = i._getStyleScopeId()), r;
|
|
19
|
-
},
|
|
20
|
-
let r = new
|
|
20
|
+
}, ee = (e, ...t) => {
|
|
21
|
+
let r = new h(e, t, 2), i = n.currentRenderingInstance;
|
|
21
22
|
return i && (r.__cossackOwner = i, r.__cossackScope = i._getStyleScopeId()), r;
|
|
22
|
-
}, _ = Symbol.for("cossack-nothing")
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
}, _ = Symbol.for("cossack-nothing");
|
|
24
|
+
function te(e, t, r) {
|
|
25
|
+
return g`${{
|
|
26
|
+
_type: "COMPONENT",
|
|
27
|
+
clazz: e,
|
|
28
|
+
props: t ?? {},
|
|
29
|
+
children: r,
|
|
30
|
+
parent: n.currentRenderingInstance
|
|
31
|
+
}}`;
|
|
32
|
+
}
|
|
33
|
+
var v = (e) => typeof e == "object" && !!e && e._cossack_template_result === !0, y = Symbol.for("@cossackframework/renderer/unsafe-html"), b = class {
|
|
29
34
|
value;
|
|
35
|
+
[y] = !0;
|
|
30
36
|
constructor(e) {
|
|
31
37
|
this.value = e;
|
|
32
38
|
}
|
|
33
|
-
},
|
|
34
|
-
if (
|
|
35
|
-
if (Array.isArray(
|
|
36
|
-
if (
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
39
|
-
if (
|
|
40
|
-
if (
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
43
|
-
if (e
|
|
44
|
-
let
|
|
45
|
-
Object.assign(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
39
|
+
}, ne = (e) => new b(e), x = (e) => typeof e == "object" && !!e && e[y] === !0, S = (e) => String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), C = (e, c = {}) => {
|
|
40
|
+
if (e === _ || e === "" || e == null || e === !1) return "";
|
|
41
|
+
if (Array.isArray(e)) return c.hydrate ? e.map((e) => `<!--CSA-S-->${C(e, c)}<!--CSA-E-->`).join("") : e.map((e) => C(e, c)).join("");
|
|
42
|
+
if (v(e)) return O(e, c);
|
|
43
|
+
if (e instanceof u) return C(e.value, c);
|
|
44
|
+
if (e instanceof f) return c.hydrate ? e.items.map((t, n) => `<!--CSA-S-->${C(e.templateFn(t, n), c)}<!--CSA-E-->`).join("") : e.items.map((t, n) => C(e.templateFn(t, n), c)).join("");
|
|
45
|
+
if (e instanceof l) return C(e.template, c);
|
|
46
|
+
if (e instanceof s) return C(e.factory(), c);
|
|
47
|
+
if (e instanceof o) return C(e.value, c);
|
|
48
|
+
if (e instanceof a) return C(p(e.component, e.fieldName), c);
|
|
49
|
+
if (t(e)) {
|
|
50
|
+
let t = new e.clazz();
|
|
51
|
+
Object.assign(t, e.props), "props" in t && (t.props = e.props), t.children = e.children, t.__parent = e.parent || n.currentRenderingInstance, e.serviceScope && typeof t._setServiceScope == "function" && t._setServiceScope(e.serviceScope), t.__parent && (t._id = `${t.__parent._id}:${t.__parent._childCounter++}`), t.connectedCallback(), i(t);
|
|
52
|
+
try {
|
|
53
|
+
t.willUpdate(/* @__PURE__ */ new Map());
|
|
54
|
+
let e = t._getWrappedTemplate, n = typeof e == "function" ? e.call(t) : t._finalizeRenderOutput(t.render());
|
|
55
|
+
return n ? O(v(n) ? n : g`${n}`, c) : "";
|
|
56
|
+
} finally {
|
|
57
|
+
r();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return x(e) ? e.value : typeof e == "function" || typeof e == "object" && e && "value" in e ? "" : S(e);
|
|
61
|
+
}, w = /* @__PURE__ */ new Set([
|
|
62
|
+
"allowfullscreen",
|
|
63
|
+
"async",
|
|
64
|
+
"autofocus",
|
|
65
|
+
"autoplay",
|
|
51
66
|
"checked",
|
|
67
|
+
"controls",
|
|
68
|
+
"default",
|
|
69
|
+
"defer",
|
|
52
70
|
"disabled",
|
|
53
|
-
"
|
|
54
|
-
"required",
|
|
71
|
+
"formnovalidate",
|
|
55
72
|
"hidden",
|
|
56
|
-
"
|
|
73
|
+
"inert",
|
|
74
|
+
"ismap",
|
|
75
|
+
"itemscope",
|
|
76
|
+
"loop",
|
|
57
77
|
"multiple",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
78
|
+
"muted",
|
|
79
|
+
"nomodule",
|
|
80
|
+
"novalidate",
|
|
81
|
+
"open",
|
|
82
|
+
"playsinline",
|
|
83
|
+
"readonly",
|
|
84
|
+
"required",
|
|
85
|
+
"reversed",
|
|
86
|
+
"selected"
|
|
87
|
+
]), T = (e, t) => w.has(e.toLowerCase()) ? t ? "" : null : String(t), re = (e, t) => {
|
|
61
88
|
if (!(e === _ || typeof e != "object" || !e)) for (let [n, r] of Object.entries(e)) {
|
|
62
89
|
if (n.startsWith("@")) continue;
|
|
63
|
-
let e = n,
|
|
90
|
+
let e = n, i = r;
|
|
64
91
|
if (n.startsWith("?")) {
|
|
65
92
|
r !== _ && r && (t.result += ` ${n.slice(1)}`);
|
|
66
93
|
continue;
|
|
67
94
|
}
|
|
68
95
|
if (n.startsWith(".")) {
|
|
69
|
-
if (e = n.slice(1),
|
|
70
|
-
if (
|
|
71
|
-
|
|
96
|
+
if (e = n === ".value" ? ".value" : n.slice(1), i instanceof a ? i = p(i.component, i.fieldName) : i instanceof u && (i = i.value), i === _) continue;
|
|
97
|
+
if (e === ".value") {
|
|
98
|
+
t.result += ` .value="${S(String(i ?? ""))}"`;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (w.has(e)) {
|
|
102
|
+
i && (t.result += ` ${e}`);
|
|
72
103
|
continue;
|
|
73
104
|
}
|
|
74
105
|
}
|
|
75
|
-
if ((e === "class" || e === "className") &&
|
|
76
|
-
|
|
106
|
+
if ((e === "class" || e === "className") && i instanceof c) {
|
|
107
|
+
if (i.value === void 0) continue;
|
|
108
|
+
i = String(i.value);
|
|
109
|
+
}
|
|
110
|
+
if ((e === "class" || e === "className") && typeof i == "string") {
|
|
111
|
+
let e = ie(t.result, i);
|
|
77
112
|
if (e !== null) {
|
|
78
113
|
t.result = e;
|
|
79
114
|
continue;
|
|
80
115
|
}
|
|
116
|
+
import.meta.env?.DEV && console.warn("[cossack/renderer] spread class merge failed — falling back to a separate class attribute. If the tag already has a class attribute, check that it uses double quotes.");
|
|
81
117
|
}
|
|
82
|
-
|
|
118
|
+
if (i !== _) if (i instanceof c) i.value !== void 0 && (t.result += ` ${e}="${S(String(i.value))}"`);
|
|
119
|
+
else if (typeof i == "boolean") {
|
|
120
|
+
let n = T(e, i);
|
|
121
|
+
n === "" ? t.result += ` ${e}` : n !== null && (t.result += ` ${e}="${n}"`);
|
|
122
|
+
} else typeof i == "function" || i != null && (t.result += ` ${e}="${S(i)}"`);
|
|
83
123
|
}
|
|
84
|
-
},
|
|
124
|
+
}, ie = (e, t) => {
|
|
85
125
|
let n = e.lastIndexOf("<"), r = n >= 0 ? e.slice(n) : e, i = r.match(/(^|\s)class="([^"]*)"(\s|\/?>|$)/);
|
|
86
126
|
if (!i) return null;
|
|
87
|
-
let a = i[1], o = i[2], s = i[3], c = t.trim();
|
|
127
|
+
let a = i[1], o = i[2], s = i[3], c = S(t.trim());
|
|
88
128
|
if (!c) return e;
|
|
89
|
-
let l = o ? `${o} ${c}` : c, u = r.replace(i[0], `${a}class="${l}"${s}`);
|
|
129
|
+
let l = o ? `${o} ${c}` : c, u = r.replace(i[0], () => `${a}class="${l}"${s}`);
|
|
90
130
|
return e.slice(0, n) + u;
|
|
91
|
-
},
|
|
131
|
+
}, ae = (e) => {
|
|
92
132
|
let t = [], n = !1, r = null, i = /(\.\.\.|[.@?]?[a-zA-Z0-9_:-]+)=["']?$/;
|
|
93
133
|
for (let a = 0; a < e.length - 1; a++) {
|
|
94
134
|
let o = e[a];
|
|
95
|
-
for (let e = 0; e < o.length; e++) r ? o[e] === r && (r = null) : o[e] === "\"" || o[e] === "'" ? e > 0 && o[e - 1] === "=" && (r = o[e]) : o[e] === "<" && o[e + 1] !== "!" && o[e + 1] !== "/" ? n = !0 : o[e] === ">" && (n = !1);
|
|
135
|
+
for (let e = 0; e < o.length; e++) r ? o[e] === r && (r = null) : n && (o[e] === "\"" || o[e] === "'") ? e > 0 && o[e - 1] === "=" && (r = o[e]) : o[e] === "<" && o[e + 1] !== "!" && o[e + 1] !== "/" ? n = !0 : o[e] === ">" && (n = !1);
|
|
96
136
|
let s = o.match(i);
|
|
97
137
|
t[a] = !(n && (s || r));
|
|
98
138
|
}
|
|
99
139
|
return t;
|
|
100
|
-
},
|
|
140
|
+
}, E = (e) => {
|
|
101
141
|
let t = 0, n;
|
|
102
142
|
do
|
|
103
143
|
n = `\uE000cossack:${t++}:`;
|
|
@@ -107,9 +147,9 @@ var m = class {
|
|
|
107
147
|
marker: (e) => `${n}${e}${r}`,
|
|
108
148
|
pattern: RegExp(`${n}(\\d+)${r}`, "g")
|
|
109
149
|
};
|
|
110
|
-
},
|
|
150
|
+
}, D = (e, t) => {
|
|
111
151
|
if (!t) return e;
|
|
112
|
-
let n =
|
|
152
|
+
let n = E(e), r = "";
|
|
113
153
|
for (let t = 0; t < e.length; t++) r += e[t], t < e.length - 1 && (r += n.marker(t));
|
|
114
154
|
let i = "", a = !1, o = null, s = "", c = "";
|
|
115
155
|
for (let e = 0; e < r.length;) {
|
|
@@ -138,8 +178,8 @@ var m = class {
|
|
|
138
178
|
let l = [], u = 0, d;
|
|
139
179
|
for (; d = n.pattern.exec(i);) l.push(i.slice(u, d.index)), u = d.index + d[0].length;
|
|
140
180
|
return l.push(i.slice(u)), l;
|
|
141
|
-
},
|
|
142
|
-
let n =
|
|
181
|
+
}, oe = (e, t) => {
|
|
182
|
+
let n = E(e), r = "";
|
|
143
183
|
for (let t = 0; t < e.length; t++) r += e[t], t < e.length - 1 && (r += n.marker(t));
|
|
144
184
|
let i = /* @__PURE__ */ new Map(), a = /<(?![!/])(?:[^>"']|"[^"]*"|'[^']*')*>/g, o;
|
|
145
185
|
for (; o = a.exec(r);) {
|
|
@@ -159,7 +199,7 @@ var m = class {
|
|
|
159
199
|
}
|
|
160
200
|
}
|
|
161
201
|
return i;
|
|
162
|
-
},
|
|
202
|
+
}, se = class {
|
|
163
203
|
resultObj;
|
|
164
204
|
opts;
|
|
165
205
|
result = "";
|
|
@@ -169,58 +209,178 @@ var m = class {
|
|
|
169
209
|
strings;
|
|
170
210
|
nothingAttributeGroups;
|
|
171
211
|
constructor(e, t = {}) {
|
|
172
|
-
this.resultObj = e, this.opts = t, this.strings =
|
|
212
|
+
this.resultObj = e, this.opts = t, this.strings = D(e.strings, e.__cossackScope), this.isNodePositions = ae(this.strings), this.nothingAttributeGroups = oe(this.strings, e.values);
|
|
173
213
|
}
|
|
174
214
|
scan() {
|
|
175
|
-
let { values:
|
|
176
|
-
for (; this.stringIdx <
|
|
177
|
-
let
|
|
178
|
-
if (this.result +=
|
|
179
|
-
let
|
|
180
|
-
if (
|
|
181
|
-
this.result.endsWith(
|
|
215
|
+
let { values: t } = this.resultObj, n = this.strings;
|
|
216
|
+
for (; this.stringIdx < n.length;) {
|
|
217
|
+
let e = n[this.stringIdx].substring(this.charIdxForNext || 0), r = e.match(/(\.\.\.|[.@?]?[a-zA-Z0-9_:-]+)=["']?$/);
|
|
218
|
+
if (this.result += e, this.charIdxForNext = 0, this.stringIdx < n.length - 1) {
|
|
219
|
+
let e = t[this.stringIdx], i = this.nothingAttributeGroups.get(this.stringIdx);
|
|
220
|
+
if (i) {
|
|
221
|
+
this.result.endsWith(i.prefix) && (this.result = this.result.slice(0, -i.prefix.length)), this.stringIdx = i.last, this.charIdxForNext = i.suffix.length, this.stringIdx++;
|
|
182
222
|
continue;
|
|
183
223
|
}
|
|
184
|
-
if (r) {
|
|
185
|
-
let
|
|
186
|
-
this.result = this.result.substring(0, this.result.length -
|
|
187
|
-
let o =
|
|
188
|
-
if (
|
|
224
|
+
if (r && !this.isNodePositions[this.stringIdx]) {
|
|
225
|
+
let t = r[0], i = r[1];
|
|
226
|
+
this.result = this.result.substring(0, this.result.length - t.length);
|
|
227
|
+
let o = t.endsWith("\"") ? "\"" : t.endsWith("'") ? "'" : "", s = !0;
|
|
228
|
+
if (i === "...") {
|
|
229
|
+
this.result = this.result.trimEnd();
|
|
230
|
+
let t = { result: this.result };
|
|
231
|
+
re(e, t), this.result = t.result;
|
|
232
|
+
} else if (i === "ref") this.result = this.result.trimEnd();
|
|
233
|
+
else if (i.startsWith("@")) this.result = this.result.trimEnd();
|
|
234
|
+
else if (i.startsWith("?")) e ? (this.result = this.result.trimEnd(), this.result += ` ${i.slice(1)}`) : this.result = this.result.trimEnd();
|
|
235
|
+
else if (i.startsWith(".")) {
|
|
236
|
+
let t, n = e instanceof a;
|
|
237
|
+
t = n ? p(e.component, e.fieldName) : e;
|
|
238
|
+
let r = i === ".value" ? ".value" : i.slice(1), o = n && w.has(r);
|
|
239
|
+
if (r === ".value") {
|
|
240
|
+
let e = t instanceof u ? t.value : t;
|
|
241
|
+
this.result = this.result.trimEnd(), this.result += ` .value="${S(String(e ?? ""))}"`;
|
|
242
|
+
} else o ? (this.result = this.result.trimEnd(), t && (this.result += ` ${r}`)) : t != null && t !== !1 ? (this.result = this.result.trimEnd(), this.result += ` ${r}="${C(t, this.opts)}"`) : this.result = this.result.trimEnd();
|
|
243
|
+
} else if (e instanceof c) e.value === void 0 ? this.result = this.result.trimEnd() : (this.result = this.result.trimEnd(), this.result += ` ${i}="${S(String(e.value))}"`);
|
|
244
|
+
else if (e == null || e === _) this.result = this.result.trimEnd();
|
|
245
|
+
else if (typeof e == "boolean") {
|
|
189
246
|
this.result = this.result.trimEnd();
|
|
190
|
-
let
|
|
191
|
-
|
|
192
|
-
} else
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
let e, t = n instanceof i;
|
|
197
|
-
e = t ? f(n.component, n.fieldName) : n;
|
|
198
|
-
let r = a.slice(1);
|
|
199
|
-
t && T.has(r) ? (this.result = this.result.trimEnd(), e && (this.result += ` ${r}`)) : e != null && e !== !1 ? (this.result = this.result.trimEnd(), this.result += ` ${r}="${w(e, this.opts)}"`) : this.result = this.result.trimEnd();
|
|
200
|
-
} else if (n instanceof s) n.value === void 0 ? this.result = this.result.trimEnd() : (this.result = this.result.trimEnd(), this.result += ` ${a}="${C(String(n.value))}"`);
|
|
201
|
-
else {
|
|
202
|
-
this.result += e;
|
|
203
|
-
let t = w(n, this.opts);
|
|
204
|
-
o ? (this.result += t, c = !1) : this.result += `"${t}"`;
|
|
247
|
+
let t = T(i, e);
|
|
248
|
+
t === "" ? this.result += ` ${i}` : t !== null && (this.result += ` ${i}="${t}"`);
|
|
249
|
+
} else {
|
|
250
|
+
this.result += t;
|
|
251
|
+
let n = C(e, this.opts);
|
|
252
|
+
o ? (this.result += n, s = !1) : this.result += `"${n}"`;
|
|
205
253
|
}
|
|
206
|
-
if (o &&
|
|
207
|
-
let e =
|
|
254
|
+
if (o && s) {
|
|
255
|
+
let e = n[this.stringIdx + 1];
|
|
208
256
|
e && e.startsWith(o) && (this.charIdxForNext = 1);
|
|
209
257
|
}
|
|
210
|
-
} else this.opts.hydrate && this.isNodePositions[this.stringIdx] ? (this.result += `<!--CRP_${this.stringIdx}-->`, this.result +=
|
|
258
|
+
} else this.opts.hydrate && this.isNodePositions[this.stringIdx] ? (this.result += `<!--CRP_${this.stringIdx}-->`, this.result += C(e, this.opts), this.result += "<!--/CRP-->") : this.result += C(e, this.opts);
|
|
211
259
|
}
|
|
212
260
|
this.stringIdx++;
|
|
213
261
|
}
|
|
214
|
-
return this.result;
|
|
262
|
+
return e(this.result);
|
|
215
263
|
}
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
|
|
264
|
+
}, O = (e, t = {}) => new se(e, t).scan(), k = !!import.meta.env?.DEV, A = k ? /* @__PURE__ */ new WeakMap() : void 0, j = (e, t) => {
|
|
265
|
+
if (!(!k || !t)) for (let n = 0; n < e.length; n++) e[n] && A.set(e[n], {
|
|
266
|
+
...t,
|
|
267
|
+
fields: void 0,
|
|
268
|
+
statePath: t.fields?.[n] ?? t.statePath
|
|
269
|
+
});
|
|
270
|
+
}, M = (e, t) => ({
|
|
271
|
+
identity: e.identity,
|
|
272
|
+
parts: e.parts.map((n) => {
|
|
273
|
+
if (!n) return;
|
|
274
|
+
let r = n.component;
|
|
275
|
+
if (r) {
|
|
276
|
+
let e = r.token ? r.fork?.(r.token) : void 0;
|
|
277
|
+
if (r.token && !e) return;
|
|
278
|
+
r = {
|
|
279
|
+
...r,
|
|
280
|
+
token: e,
|
|
281
|
+
instance: t.owners.get(r.instance) ?? r.instance,
|
|
282
|
+
parent: r.parent ? t.owners.get(r.parent) ?? r.parent : r.parent
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
...n,
|
|
287
|
+
component: r,
|
|
288
|
+
template: n.template ? M(n.template, t) : void 0,
|
|
289
|
+
cached: new Map([...n.cached].map(([e, n]) => [e, M(n, t)])),
|
|
290
|
+
children: M({
|
|
291
|
+
identity: e.identity,
|
|
292
|
+
parts: n.children
|
|
293
|
+
}, t).parts,
|
|
294
|
+
keys: [...n.keys]
|
|
295
|
+
};
|
|
296
|
+
})
|
|
297
|
+
}), N = /* @__PURE__ */ new WeakMap(), P = (e) => e.map((e) => e instanceof z ? e.captureDraft() : void 0), F = (e, t, n) => {
|
|
298
|
+
!t || t.tree.identity !== n || !t.context.active || !t.context.current() || e.forEach((e, n) => {
|
|
299
|
+
e instanceof z && e.restoreDraft(t.tree.parts[n], t.context);
|
|
300
|
+
});
|
|
301
|
+
}, ce = (e) => {
|
|
302
|
+
let t = G.get(e), n = t ? {
|
|
303
|
+
identity: t.identity,
|
|
304
|
+
parts: P(t.parts)
|
|
305
|
+
} : void 0, r;
|
|
306
|
+
return {
|
|
307
|
+
restore(t, i = []) {
|
|
308
|
+
!n || r || (r = {
|
|
309
|
+
active: !0,
|
|
310
|
+
current: t,
|
|
311
|
+
owners: new Map(i)
|
|
312
|
+
}, N.set(e, {
|
|
313
|
+
tree: n,
|
|
314
|
+
context: r
|
|
315
|
+
}), n = void 0);
|
|
316
|
+
},
|
|
317
|
+
discard() {
|
|
318
|
+
n = void 0, r && (r.active = !1, r.owners.clear(), N.get(e)?.context === r && N.delete(e));
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
}, I = (e) => {
|
|
322
|
+
for (let t of e) try {
|
|
323
|
+
t?.dispose?.();
|
|
324
|
+
} catch (e) {
|
|
325
|
+
console.error("[cossack] Failed render cleanup:", e);
|
|
326
|
+
}
|
|
327
|
+
}, L = /* @__PURE__ */ new WeakMap(), R = (e) => {
|
|
328
|
+
let t = L.get(e.strings);
|
|
329
|
+
t || (t = /* @__PURE__ */ new Map(), L.set(e.strings, t));
|
|
219
330
|
let n = `${e._$litType$}:${e.__cossackScope ?? ""}`, r = t.get(n);
|
|
220
331
|
return r || (r = {}, t.set(n, r)), r;
|
|
221
|
-
},
|
|
332
|
+
}, z = class e {
|
|
222
333
|
startNode;
|
|
223
334
|
endNode;
|
|
335
|
+
_draft;
|
|
336
|
+
_componentDraft;
|
|
337
|
+
_cacheDrafts = /* @__PURE__ */ new Map();
|
|
338
|
+
captureDraft() {
|
|
339
|
+
let e = this.componentInstance, t = /* @__PURE__ */ new Map();
|
|
340
|
+
for (let [e, n] of this._cacheDrafts) n.context.active && n.context.current() && t.set(e, M(n.tree, n.context));
|
|
341
|
+
for (let [e, n] of this._cacheMap) e !== this._cachedTemplateIdentity && t.set(e, {
|
|
342
|
+
identity: e,
|
|
343
|
+
parts: P(n.parts)
|
|
344
|
+
});
|
|
345
|
+
return {
|
|
346
|
+
component: e ? {
|
|
347
|
+
instance: e,
|
|
348
|
+
clazz: e.constructor,
|
|
349
|
+
parent: e.__parent,
|
|
350
|
+
scope: e._getServiceScope?.(),
|
|
351
|
+
token: e._frameworkCaptureClientDraft?.(),
|
|
352
|
+
fork: e.constructor._frameworkForkClientDraft?.bind(e.constructor)
|
|
353
|
+
} : void 0,
|
|
354
|
+
template: this._cachedParts && this._cachedTemplateIdentity ? {
|
|
355
|
+
identity: this._cachedTemplateIdentity,
|
|
356
|
+
parts: P(this._cachedParts)
|
|
357
|
+
} : void 0,
|
|
358
|
+
cached: t,
|
|
359
|
+
children: this._childParts.map((e) => e.captureDraft()),
|
|
360
|
+
keys: [...this._partKeys],
|
|
361
|
+
keySet: this._keySet,
|
|
362
|
+
key: this._key
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
restoreDraft(e, t) {
|
|
366
|
+
this._draft = e && t.active && t.current() ? {
|
|
367
|
+
snapshot: e,
|
|
368
|
+
context: t
|
|
369
|
+
} : void 0;
|
|
370
|
+
}
|
|
371
|
+
restoreComponentDraft(e) {
|
|
372
|
+
let t = this._draft;
|
|
373
|
+
if (this._componentDraft = void 0, !t || !t.context.active || !t.context.current()) return;
|
|
374
|
+
let n = t.snapshot.component;
|
|
375
|
+
!n || n.clazz !== e.constructor || (n.parent && (t.context.owners.get(n.parent) ?? n.parent)) !== e.__parent || n.scope !== e._getServiceScope?.() || e !== n.instance && n.token && !e._frameworkRestoreClientDraft?.(n.token) || (t.context.owners.set(n.instance, e), t.snapshot.template && (this._componentDraft = {
|
|
376
|
+
tree: t.snapshot.template,
|
|
377
|
+
context: t.context
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
updateComponentTemplate(e) {
|
|
381
|
+
let t = this._componentDraft;
|
|
382
|
+
this._componentDraft = void 0, this.updateNode(e, t ?? null);
|
|
383
|
+
}
|
|
224
384
|
componentInstance = null;
|
|
225
385
|
renderListener = null;
|
|
226
386
|
_childParts = [];
|
|
@@ -241,25 +401,37 @@ var m = class {
|
|
|
241
401
|
_beginHydration() {
|
|
242
402
|
this._hydrating = !0;
|
|
243
403
|
}
|
|
244
|
-
update(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
t instanceof o && (t = this._resolveGuard(t));
|
|
250
|
-
let n = !1;
|
|
251
|
-
if (t instanceof a) {
|
|
252
|
-
let e = t.value;
|
|
253
|
-
if (y(e)) {
|
|
254
|
-
this.componentInstance && this.disposeComponent(), this._childParts.length > 0 && this.clearChildParts(), this.updateCache(e);
|
|
404
|
+
update(e) {
|
|
405
|
+
try {
|
|
406
|
+
if (!(e instanceof o) && !(e instanceof s) && this._cacheDrafts.clear(), this._hydrating) {
|
|
407
|
+
this._hydrating = !1, this._hydrateValue(e);
|
|
255
408
|
return;
|
|
256
409
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
410
|
+
e instanceof s && (e = this._resolveGuard(e), e instanceof o || this._cacheDrafts.clear());
|
|
411
|
+
let n = !1;
|
|
412
|
+
if (e instanceof o) {
|
|
413
|
+
this.prepareCacheDrafts();
|
|
414
|
+
let t = e.value;
|
|
415
|
+
if (v(t)) {
|
|
416
|
+
this.componentInstance && this.disposeComponent(), this._childParts.length > 0 && this.clearChildParts(), this.updateCache(t);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
e = t, n = !0;
|
|
420
|
+
} else if (this._cacheMap.size > 0 || this._cacheCurrent) {
|
|
421
|
+
for (let e of this._cacheMap.values()) for (let t of e.parts) t && typeof t.dispose == "function" && t.dispose();
|
|
422
|
+
this._cacheMap.clear(), this._cacheCurrent = null;
|
|
423
|
+
}
|
|
424
|
+
if (n && this._cacheCurrent) {
|
|
425
|
+
if (this._stashCurrent(), this._draft) {
|
|
426
|
+
for (let e of this._cacheMap.values()) I(e.parts);
|
|
427
|
+
this._cacheMap.clear();
|
|
428
|
+
}
|
|
429
|
+
this._cacheCurrent = null;
|
|
430
|
+
}
|
|
431
|
+
this.componentInstance && (!t(e) || e.clazz !== this.componentInstance.constructor) && this.disposeComponent(), !(e instanceof f) && !Array.isArray(e) && this._childParts.length > 0 && this.clearChildParts(), !(e instanceof l) && this._draft?.snapshot.keySet && (this._draft = void 0), t(e) ? this.updateComponent(e) : e instanceof f ? this.updateRepeat(e) : e instanceof l ? this.updateKey(e) : Array.isArray(e) ? this.updateArray(e) : this.updateNode(e);
|
|
432
|
+
} finally {
|
|
433
|
+
this._draft = void 0;
|
|
261
434
|
}
|
|
262
|
-
n && this._cacheCurrent && (this._stashCurrent(), this._cacheCurrent = null), this.componentInstance && (!e(t) || t.clazz !== this.componentInstance.constructor) && this.disposeComponent(), !(t instanceof d) && !Array.isArray(t) && this._childParts.length > 0 && this.clearChildParts(), e(t) ? this.updateComponent(t) : t instanceof d ? this.updateRepeat(t) : t instanceof c ? this.updateKey(t) : Array.isArray(t) ? this.updateArray(t) : this.updateNode(t);
|
|
263
435
|
}
|
|
264
436
|
_resolveGuard(e) {
|
|
265
437
|
let t = Array.isArray(e.deps) ? [...e.deps] : [e.deps];
|
|
@@ -270,95 +442,119 @@ var m = class {
|
|
|
270
442
|
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
271
443
|
return !0;
|
|
272
444
|
}
|
|
273
|
-
_hydrateValue(
|
|
274
|
-
if (e
|
|
275
|
-
this._adoptComponent(
|
|
445
|
+
_hydrateValue(e) {
|
|
446
|
+
if (t(e)) {
|
|
447
|
+
this._adoptComponent(e);
|
|
276
448
|
return;
|
|
277
449
|
}
|
|
278
|
-
if (
|
|
279
|
-
this._adoptTemplate(
|
|
450
|
+
if (v(e)) {
|
|
451
|
+
this._adoptTemplate(e);
|
|
280
452
|
return;
|
|
281
453
|
}
|
|
282
|
-
if (
|
|
283
|
-
this._adoptSequence(
|
|
454
|
+
if (e instanceof f) {
|
|
455
|
+
this._adoptSequence(e.items.map((t, n) => e.templateFn(t, n)), e.items.map((t, n) => e.keyFn(t, n)));
|
|
284
456
|
return;
|
|
285
457
|
}
|
|
286
|
-
if (Array.isArray(
|
|
287
|
-
this._adoptSequence(
|
|
458
|
+
if (Array.isArray(e)) {
|
|
459
|
+
this._adoptSequence(e);
|
|
288
460
|
return;
|
|
289
461
|
}
|
|
290
|
-
if (
|
|
291
|
-
if (
|
|
292
|
-
this._keySet = !0, this._key =
|
|
462
|
+
if (e instanceof l) {
|
|
463
|
+
if (v(e.template)) {
|
|
464
|
+
this._keySet = !0, this._key = e.value, this._adoptTemplate(e.template);
|
|
293
465
|
return;
|
|
294
466
|
}
|
|
295
|
-
this.clear(), this._clearTemplateCache(), this.updateNode(
|
|
467
|
+
this.clear(), this._clearTemplateCache(), this.updateNode(e.template);
|
|
296
468
|
return;
|
|
297
469
|
}
|
|
298
|
-
if (
|
|
299
|
-
let
|
|
300
|
-
this._hydrateValue(
|
|
470
|
+
if (e instanceof s) {
|
|
471
|
+
let t = this._resolveGuard(e);
|
|
472
|
+
this._hydrateValue(t);
|
|
301
473
|
return;
|
|
302
474
|
}
|
|
303
|
-
if (
|
|
304
|
-
let
|
|
305
|
-
if (
|
|
306
|
-
let
|
|
307
|
-
this._cacheMap.has(
|
|
308
|
-
} else this._hydrateValue(
|
|
475
|
+
if (e instanceof o) {
|
|
476
|
+
let t = e.value;
|
|
477
|
+
if (v(t)) {
|
|
478
|
+
let e = R(t);
|
|
479
|
+
this._cacheMap.has(e) ? this.updateCache(t) : (this._adoptTemplate(t), this._cacheCurrent = e);
|
|
480
|
+
} else this._hydrateValue(t);
|
|
309
481
|
return;
|
|
310
482
|
}
|
|
311
|
-
if (
|
|
483
|
+
if (e === _ || e === "" || e == null || e === !1) {
|
|
312
484
|
this.clear();
|
|
313
485
|
return;
|
|
314
486
|
}
|
|
315
|
-
if (!(
|
|
316
|
-
if (
|
|
487
|
+
if (!(e instanceof Node)) {
|
|
488
|
+
if (x(e)) {
|
|
317
489
|
if (this.startNode.nextSibling !== this.endNode) return;
|
|
318
|
-
this.clear(), this._clearTemplateCache(), this.updateNode(
|
|
490
|
+
this.clear(), this._clearTemplateCache(), this.updateNode(e);
|
|
319
491
|
return;
|
|
320
492
|
}
|
|
321
|
-
if (typeof
|
|
322
|
-
let
|
|
323
|
-
n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode ? n.nodeValue !==
|
|
493
|
+
if (typeof e != "object") {
|
|
494
|
+
let t = String(e), n = this.startNode.nextSibling;
|
|
495
|
+
n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode ? n.nodeValue !== t && (k && X(new J("text-content", ue(n), "text", "text"), A.get(this)?.boundary ?? "root", void 0, A.get(this), "text-reconcile"), n.nodeValue = t) : (this.clear(), this.startNode.parentNode.insertBefore(document.createTextNode(t), this.endNode));
|
|
324
496
|
return;
|
|
325
497
|
}
|
|
326
|
-
this.clear(), this._clearTemplateCache(), this.updateNode(
|
|
498
|
+
this.clear(), this._clearTemplateCache(), this.updateNode(e);
|
|
327
499
|
}
|
|
328
500
|
}
|
|
329
501
|
_adoptComponent(e) {
|
|
330
|
-
let
|
|
331
|
-
if (this.componentInstance && (this.componentInstance.constructor !== e.clazz || this.componentInstance.__parent !==
|
|
332
|
-
this.componentInstance = new e.clazz(), this.componentInstance.__parent =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
502
|
+
let t = e.parent || n.currentRenderingInstance;
|
|
503
|
+
if (this.componentInstance && (this.componentInstance.constructor !== e.clazz || this.componentInstance.__parent !== t) && this.disposeComponent(), !this.componentInstance) {
|
|
504
|
+
if (this.componentInstance = new e.clazz(), this.componentInstance.__parent = t, e.serviceScope && typeof this.componentInstance._setServiceScope == "function" && this.componentInstance._setServiceScope(e.serviceScope), this.componentInstance.__parent && (this.componentInstance._id = `${this.componentInstance.__parent._id}:${this.componentInstance.__parent._childCounter++}`), k) {
|
|
505
|
+
let t = this.componentInstance.hydrationMetadata, n = A.get(this);
|
|
506
|
+
A.set(this, {
|
|
507
|
+
...n,
|
|
508
|
+
...t,
|
|
509
|
+
component: t?.component ?? e.clazz.name ?? n?.component,
|
|
510
|
+
statePath: t?.statePath,
|
|
511
|
+
fields: t?.fields,
|
|
512
|
+
boundary: "component"
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
let n = !0;
|
|
516
|
+
this.renderListener = (t) => {
|
|
517
|
+
if (n) if (n = !1, v(t)) try {
|
|
518
|
+
this._adoptTemplate(t);
|
|
519
|
+
} catch (n) {
|
|
520
|
+
if (n instanceof J) k && X(n, "component", e.clazz.name || "anonymous", A.get(this)), this.clear(), this._clearTemplateCache(), this.updateComponentTemplate(t);
|
|
521
|
+
else throw n;
|
|
340
522
|
}
|
|
341
|
-
else
|
|
342
|
-
else this.
|
|
343
|
-
}, this.componentInstance.addRenderListener(this.renderListener), Object.assign(this.componentInstance, e.props), "props" in this.componentInstance && (this.componentInstance.props = e.props), this.componentInstance.children = e.children
|
|
523
|
+
else t == null ? this.clear() : this.updateComponentTemplate(t);
|
|
524
|
+
else this.updateComponentTemplate(t);
|
|
525
|
+
}, this.componentInstance.addRenderListener(this.renderListener), Object.assign(this.componentInstance, e.props), "props" in this.componentInstance && (this.componentInstance.props = e.props), this.componentInstance.children = e.children;
|
|
526
|
+
try {
|
|
527
|
+
this.componentInstance._frameworkRendererAttached?.(), this.restoreComponentDraft(this.componentInstance), this.componentInstance.connectedCallback();
|
|
528
|
+
} catch (e) {
|
|
529
|
+
throw this.disposeComponent(), e;
|
|
530
|
+
}
|
|
344
531
|
}
|
|
345
532
|
let r = this.componentInstance;
|
|
346
|
-
Object.assign(r, e.props), "props" in r && (r.props = e.props), r.children = e.children, r.requestUpdate();
|
|
533
|
+
this._draft?.snapshot.component?.instance === r && this.restoreComponentDraft(r), Object.assign(r, e.props), "props" in r && (r.props = e.props), r.children = e.children, r.requestUpdate();
|
|
347
534
|
}
|
|
348
|
-
_adoptSequence(
|
|
349
|
-
let r =
|
|
350
|
-
if (r.length !==
|
|
351
|
-
this._childParts = [], this._partKeys =
|
|
352
|
-
for (let i = 0; i <
|
|
353
|
-
let [a, o] = r[i], s = new
|
|
354
|
-
|
|
535
|
+
_adoptSequence(t, n) {
|
|
536
|
+
let r = le(this._nodesBetween());
|
|
537
|
+
if (r.length !== t.length) throw new J("sequence-length", "sequence", `${t.length} client items`, `${r.length} SSR items`);
|
|
538
|
+
this._childParts = [], this._partKeys = n ? [] : this._partKeys;
|
|
539
|
+
for (let i = 0; i < t.length; i++) {
|
|
540
|
+
let [a, o] = r[i], s = new e(a, o);
|
|
541
|
+
if (k) {
|
|
542
|
+
let e = A.get(this);
|
|
543
|
+
e && A.set(s, e);
|
|
544
|
+
}
|
|
545
|
+
s._beginHydration(), this._childParts.push(s), n && this._partKeys.push(n[i]), s.update(t[i]);
|
|
355
546
|
}
|
|
356
547
|
}
|
|
357
548
|
_adoptTemplate(e) {
|
|
358
|
-
let { fragment: t, parts: n } =
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
549
|
+
let { fragment: t, parts: n } = K(e);
|
|
550
|
+
try {
|
|
551
|
+
let r = this._nodesBetween(), i = /* @__PURE__ */ new Map();
|
|
552
|
+
Q(t.childNodes, r, i, "root", k ? A.get(this) : void 0), $(n, i), j(n, k ? A.get(this) : void 0);
|
|
553
|
+
for (let t = 0; t < e.values.length; t++) n[t] && n[t].update(e.values[t]);
|
|
554
|
+
this._cachedTemplateIdentity = R(e), this._cachedParts = n;
|
|
555
|
+
} catch (e) {
|
|
556
|
+
throw I(n), e;
|
|
557
|
+
}
|
|
362
558
|
}
|
|
363
559
|
_nodesBetween() {
|
|
364
560
|
let e = [], t = this.startNode.nextSibling;
|
|
@@ -366,20 +562,36 @@ var m = class {
|
|
|
366
562
|
return e;
|
|
367
563
|
}
|
|
368
564
|
teardownComponent(e) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
565
|
+
this.renderListener &&= (e.removeRenderListener(this.renderListener), null);
|
|
566
|
+
try {
|
|
567
|
+
e.disconnectedCallback();
|
|
568
|
+
} catch (e) {
|
|
569
|
+
console.error("[cossack] Component disconnection failed:", e);
|
|
570
|
+
} finally {
|
|
571
|
+
try {
|
|
572
|
+
typeof e.destroy == "function" && e.destroy();
|
|
573
|
+
} catch {} finally {
|
|
574
|
+
e._frameworkRendererDetached?.();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
372
577
|
}
|
|
373
578
|
disposeComponent() {
|
|
374
579
|
this.componentInstance && (this.teardownComponent(this.componentInstance), this.componentInstance = null, this._clearTemplateCache());
|
|
375
580
|
}
|
|
376
581
|
updateComponent(e) {
|
|
377
|
-
let
|
|
378
|
-
this.componentInstance && this.componentInstance.__parent !==
|
|
379
|
-
this.
|
|
380
|
-
|
|
582
|
+
let t = e.parent || n.currentRenderingInstance;
|
|
583
|
+
if (this.componentInstance && this.componentInstance.__parent !== t && this.disposeComponent(), !this.componentInstance) {
|
|
584
|
+
this.componentInstance = new e.clazz(), this.componentInstance.__parent = t, e.serviceScope && typeof this.componentInstance._setServiceScope == "function" && this.componentInstance._setServiceScope(e.serviceScope), this.componentInstance.__parent && (this.componentInstance._id = `${this.componentInstance.__parent._id}:${this.componentInstance.__parent._childCounter++}`), this.renderListener = (e) => {
|
|
585
|
+
this.updateComponentTemplate(e);
|
|
586
|
+
}, this.componentInstance.addRenderListener(this.renderListener), Object.assign(this.componentInstance, e.props), "props" in this.componentInstance && (this.componentInstance.props = e.props), this.componentInstance.children = e.children;
|
|
587
|
+
try {
|
|
588
|
+
this.componentInstance._frameworkRendererAttached?.(), this.restoreComponentDraft(this.componentInstance), this.componentInstance.connectedCallback();
|
|
589
|
+
} catch (e) {
|
|
590
|
+
throw this.disposeComponent(), e;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
381
593
|
let r = this.componentInstance;
|
|
382
|
-
Object.assign(r, e.props), "props" in r && (r.props = e.props), r.children = e.children, r.requestUpdate();
|
|
594
|
+
this._draft?.snapshot.component?.instance === r && this.restoreComponentDraft(r), Object.assign(r, e.props), "props" in r && (r.props = e.props), r.children = e.children, r.requestUpdate();
|
|
383
595
|
}
|
|
384
596
|
updateRepeat(e) {
|
|
385
597
|
let { items: t, keyFn: n, templateFn: r } = e, i = /* @__PURE__ */ new Map();
|
|
@@ -388,35 +600,57 @@ var m = class {
|
|
|
388
600
|
n !== void 0 && i.set(n, e);
|
|
389
601
|
});
|
|
390
602
|
let a = [], o = [], s = this.startNode;
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
603
|
+
try {
|
|
604
|
+
t.forEach((e, t) => {
|
|
605
|
+
let c = n(e, t);
|
|
606
|
+
o.push(c);
|
|
607
|
+
let l = i.get(c);
|
|
608
|
+
l ? (i.delete(c), l.startNode.previousSibling !== s && this.movePart(l, s)) : l = this.createChildPart(s), a.push(l);
|
|
609
|
+
let u = this._draft?.snapshot.keys.findIndex((e) => Object.is(e, c)) ?? -1;
|
|
610
|
+
this._draft && u !== -1 && l.restoreDraft(this._draft.snapshot.children[u], this._draft.context), l.update(r(e, t)), s = l.endNode;
|
|
611
|
+
}), i.forEach((e) => e.dispose()), this._childParts = a, this._partKeys = o;
|
|
612
|
+
} catch (e) {
|
|
613
|
+
throw I([.../* @__PURE__ */ new Set([...this._childParts, ...a])]), this._childParts = [], this._partKeys = [], e;
|
|
614
|
+
}
|
|
397
615
|
}
|
|
398
616
|
updateKey(e) {
|
|
617
|
+
this._draft && (!this._draft.snapshot.keySet || !Object.is(this._draft.snapshot.key, e.value)) && (this._draft = void 0);
|
|
399
618
|
let t = !this._keySet || !Object.is(this._key, e.value);
|
|
400
619
|
this._keySet = !0, this._key = e.value, t && (this.componentInstance && this.disposeComponent(), this._clearTemplateCache(), this.clear()), this.updateNode(e.template);
|
|
401
620
|
}
|
|
621
|
+
prepareCacheDrafts() {
|
|
622
|
+
for (let [e, t] of this._cacheDrafts) (!t.context.active || !t.context.current()) && this._cacheDrafts.delete(e);
|
|
623
|
+
if (this._draft && this._draft.context.active && this._draft.context.current()) {
|
|
624
|
+
let { snapshot: e, context: t } = this._draft;
|
|
625
|
+
for (let [e, t] of this._cacheMap) e !== this._cachedTemplateIdentity && (I(t.parts), this._cacheMap.delete(e));
|
|
626
|
+
for (let [n, r] of e.cached) this._cacheDrafts.set(n, {
|
|
627
|
+
tree: r,
|
|
628
|
+
context: t
|
|
629
|
+
});
|
|
630
|
+
e.template && this._cacheDrafts.set(e.template.identity, {
|
|
631
|
+
tree: e.template,
|
|
632
|
+
context: t
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
402
636
|
updateCache(e) {
|
|
403
|
-
let t =
|
|
404
|
-
if (this._cacheCurrent === t && this._cachedParts) {
|
|
405
|
-
this._cachedParts.forEach((t, n) => {
|
|
637
|
+
let t = R(e), n = this._cacheDrafts.get(t);
|
|
638
|
+
if (this._cacheDrafts.delete(t), this._cacheCurrent === t && this._cachedParts) {
|
|
639
|
+
F(this._cachedParts, n, t), this._cachedParts.forEach((t, n) => {
|
|
406
640
|
t.update(e.values[n]);
|
|
407
641
|
});
|
|
408
642
|
return;
|
|
409
643
|
}
|
|
410
|
-
(this._cacheCurrent || this._cachedParts) && this._stashCurrent();
|
|
411
|
-
let
|
|
412
|
-
if (
|
|
644
|
+
if ((this._cacheCurrent || this._cachedParts) && (this._stashCurrent(), this._draft)) for (let [e, n] of this._cacheMap) e !== t && (I(n.parts), this._cacheMap.delete(e));
|
|
645
|
+
let r = this._cacheMap.get(t);
|
|
646
|
+
if (r) {
|
|
413
647
|
this.clear();
|
|
414
|
-
let
|
|
415
|
-
if (!
|
|
416
|
-
for (let e of
|
|
417
|
-
this._cachedTemplateIdentity = t, this._cachedParts =
|
|
418
|
-
for (let t = 0; t < e.values.length; t++)
|
|
419
|
-
} else this.clear(), this.updateNode(e);
|
|
648
|
+
let i = this.startNode.parentNode;
|
|
649
|
+
if (!i) return;
|
|
650
|
+
for (let e of r.nodes) i.insertBefore(e, this.endNode);
|
|
651
|
+
this._cachedTemplateIdentity = t, this._cachedParts = r.parts, F(r.parts, n, t);
|
|
652
|
+
for (let t = 0; t < e.values.length; t++) r.parts[t] && r.parts[t].update(e.values[t]);
|
|
653
|
+
} else this.clear(), this.updateNode(e, n ?? null);
|
|
420
654
|
this._cacheCurrent = t;
|
|
421
655
|
}
|
|
422
656
|
_stashCurrent() {
|
|
@@ -436,19 +670,19 @@ var m = class {
|
|
|
436
670
|
updateArray(e) {
|
|
437
671
|
this._partKeys = [];
|
|
438
672
|
let t = Math.min(e.length, this._childParts.length);
|
|
439
|
-
for (let n = 0; n < t; n++) this._childParts[n].update(e[n]);
|
|
673
|
+
for (let n = 0; n < t; n++) this._draft && this._draft.snapshot.keys.length === 0 && this._childParts[n].restoreDraft(this._draft.snapshot.children[n], this._draft.context), this._childParts[n].update(e[n]);
|
|
440
674
|
if (e.length > this._childParts.length) {
|
|
441
675
|
let n = this._childParts.length > 0 ? this._childParts[this._childParts.length - 1].endNode : this.startNode;
|
|
442
676
|
for (let r = t; r < e.length; r++) {
|
|
443
677
|
let t = this.createChildPart(n);
|
|
444
|
-
this._childParts.push(t), t.update(e[r]), n = t.endNode;
|
|
678
|
+
this._childParts.push(t), this._draft && this._draft.snapshot.keys.length === 0 && t.restoreDraft(this._draft.snapshot.children[r], this._draft.context), t.update(e[r]), n = t.endNode;
|
|
445
679
|
}
|
|
446
680
|
}
|
|
447
681
|
if (e.length < this._childParts.length) for (let t = this._childParts.length - 1; t >= e.length; t--) this._childParts[t].dispose(), this._childParts.pop();
|
|
448
682
|
}
|
|
449
|
-
createChildPart(
|
|
450
|
-
let
|
|
451
|
-
return
|
|
683
|
+
createChildPart(t) {
|
|
684
|
+
let n = document.createComment("CRP-Item"), r = document.createComment("/CRP-Item"), i = t.nextSibling;
|
|
685
|
+
return t.parentNode.insertBefore(n, i), t.parentNode.insertBefore(r, i), new e(n, r);
|
|
452
686
|
}
|
|
453
687
|
movePart(e, t) {
|
|
454
688
|
let n = t.parentNode, r = [], i = e.startNode;
|
|
@@ -461,40 +695,57 @@ var m = class {
|
|
|
461
695
|
this._childParts.forEach((e) => e.dispose()), this._childParts = [], this._partKeys = [];
|
|
462
696
|
}
|
|
463
697
|
dispose() {
|
|
464
|
-
if (this.clear(), this._clearTemplateCache(), this._cacheMap.size > 0) {
|
|
698
|
+
if (this._draft = void 0, this._componentDraft = void 0, this._cacheDrafts.clear(), this.clear(), this._clearTemplateCache(), this._cacheMap.size > 0) {
|
|
465
699
|
for (let e of this._cacheMap.values()) for (let t of e.parts) t && typeof t.dispose == "function" && t.dispose();
|
|
466
700
|
this._cacheMap.clear();
|
|
467
701
|
}
|
|
468
702
|
this._cacheCurrent = null, this.clearChildParts(), this.startNode.parentNode && this.startNode.parentNode.removeChild(this.startNode), this.endNode.parentNode && this.endNode.parentNode.removeChild(this.endNode), this.componentInstance &&= (this.teardownComponent(this.componentInstance), null);
|
|
469
703
|
}
|
|
470
|
-
updateNode(
|
|
471
|
-
|
|
472
|
-
|
|
704
|
+
updateNode(e, n) {
|
|
705
|
+
let r = n === void 0 ? this._draft?.snapshot.template ? {
|
|
706
|
+
tree: this._draft.snapshot.template,
|
|
707
|
+
context: this._draft.context
|
|
708
|
+
} : void 0 : n ?? void 0;
|
|
709
|
+
if (this.startNode.parentNode) if (v(e)) if (this._cachedTemplateIdentity === R(e) && this._cachedParts) F(this._cachedParts, r, R(e)), this._cachedParts.forEach((t, n) => {
|
|
710
|
+
t.update(e.values[n]);
|
|
473
711
|
});
|
|
474
712
|
else {
|
|
475
713
|
this._clearTemplateCache(), this.clear();
|
|
476
|
-
let
|
|
477
|
-
|
|
478
|
-
let n =
|
|
714
|
+
let t = document.createDocumentFragment();
|
|
715
|
+
r && N.set(t, r), q(e, t), this.startNode.parentNode.insertBefore(t, this.endNode);
|
|
716
|
+
let n = G.get(t.firstChild?.childNodes[0] || t);
|
|
479
717
|
n && (this._cachedTemplateIdentity = n.identity, this._cachedParts = n.parts);
|
|
480
718
|
}
|
|
481
|
-
else if (
|
|
719
|
+
else if (x(e)) {
|
|
482
720
|
this._clearTemplateCache(), this.clear();
|
|
483
|
-
let
|
|
484
|
-
|
|
485
|
-
|
|
721
|
+
let t = this.startNode.parentNode, n = this.startNode.ownerDocument;
|
|
722
|
+
if (t instanceof Element && t.namespaceURI === "http://www.w3.org/2000/svg" && ![
|
|
723
|
+
"foreignObject",
|
|
724
|
+
"desc",
|
|
725
|
+
"title"
|
|
726
|
+
].includes(t.localName)) {
|
|
727
|
+
let r = n.createElementNS(t.namespaceURI, t.localName);
|
|
728
|
+
r.innerHTML = e.value;
|
|
729
|
+
let i = n.createDocumentFragment();
|
|
730
|
+
for (; r.firstChild;) i.appendChild(r.firstChild);
|
|
731
|
+
t.insertBefore(i, this.endNode);
|
|
732
|
+
} else {
|
|
733
|
+
let r = n.createElement("template");
|
|
734
|
+
r.innerHTML = e.value, t.insertBefore(r.content, this.endNode);
|
|
735
|
+
}
|
|
736
|
+
} else if (t(e) || typeof e == "object" && e && !(e instanceof Node) && !Array.isArray(e)) {
|
|
486
737
|
this._clearTemplateCache(), this.clear();
|
|
487
|
-
let
|
|
488
|
-
|
|
489
|
-
} else if (
|
|
490
|
-
else if (
|
|
738
|
+
let t = document.createDocumentFragment();
|
|
739
|
+
q(g`${e}`, t), this.startNode.parentNode.insertBefore(t, this.endNode);
|
|
740
|
+
} else if (e instanceof Node) this._clearTemplateCache(), this.clear(), this.startNode.parentNode.insertBefore(e, this.endNode);
|
|
741
|
+
else if (e === _ || e === "" || e == null || e === !1) this._clearTemplateCache(), this.clear();
|
|
491
742
|
else {
|
|
492
|
-
let
|
|
493
|
-
if (n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode) n.nodeValue !==
|
|
743
|
+
let t = String(e), n = this.startNode.nextSibling;
|
|
744
|
+
if (n && n.nodeType === Node.TEXT_NODE && n.nextSibling === this.endNode) n.nodeValue !== t && (n.nodeValue = t);
|
|
494
745
|
else {
|
|
495
746
|
this._clearTemplateCache(), this.clear();
|
|
496
|
-
let
|
|
497
|
-
this.startNode.parentNode.insertBefore(
|
|
747
|
+
let e = document.createTextNode(t);
|
|
748
|
+
this.startNode.parentNode.insertBefore(e, this.endNode);
|
|
498
749
|
}
|
|
499
750
|
}
|
|
500
751
|
}
|
|
@@ -509,8 +760,9 @@ var m = class {
|
|
|
509
760
|
e.parentNode.removeChild(e), e = t;
|
|
510
761
|
}
|
|
511
762
|
}
|
|
512
|
-
},
|
|
763
|
+
}, B = class {
|
|
513
764
|
element;
|
|
765
|
+
selectCommit = new H();
|
|
514
766
|
previousValues = {};
|
|
515
767
|
bindStates = /* @__PURE__ */ new Map();
|
|
516
768
|
spreadClasses = [];
|
|
@@ -519,7 +771,7 @@ var m = class {
|
|
|
519
771
|
}
|
|
520
772
|
update(e) {
|
|
521
773
|
if (e !== _ && (typeof e != "object" || !e)) return;
|
|
522
|
-
let t = e === _ ? {} : e;
|
|
774
|
+
let t = e === _ ? {} : e, n = this.selectCommit.cancel();
|
|
523
775
|
for (let e of Object.keys(this.previousValues)) if (!(e in t)) if (e.startsWith("@")) {
|
|
524
776
|
let t = e.slice(1), n = `__crp_handler_${t}`, r = this.element[n];
|
|
525
777
|
r && this.element.removeEventListener(t, r);
|
|
@@ -531,35 +783,45 @@ var m = class {
|
|
|
531
783
|
for (let e of this.spreadClasses) this.element.classList.remove(e);
|
|
532
784
|
this.spreadClasses = [];
|
|
533
785
|
} else this.element.removeAttribute(e);
|
|
534
|
-
for (let [e,
|
|
535
|
-
let t = e.slice(1),
|
|
536
|
-
if (i && this.element.removeEventListener(t, i),
|
|
537
|
-
this.element[
|
|
786
|
+
for (let [e, r] of Object.entries(t)) if (e.startsWith("@")) {
|
|
787
|
+
let t = e.slice(1), n = `__crp_handler_${t}`, i = this.element[n];
|
|
788
|
+
if (i && this.element.removeEventListener(t, i), r === _ || typeof r != "function" && !(r instanceof d)) {
|
|
789
|
+
this.element[n] = void 0;
|
|
538
790
|
continue;
|
|
539
791
|
}
|
|
540
792
|
let a;
|
|
541
|
-
if (
|
|
542
|
-
let e =
|
|
543
|
-
t instanceof HTMLFormElement && (
|
|
793
|
+
if (r instanceof d) {
|
|
794
|
+
let e = r.handler, t = this.element instanceof HTMLFormElement ? this.element : this.element.closest("form");
|
|
795
|
+
t instanceof HTMLFormElement && (r.novalidate ? t.setAttribute("novalidate", "") : t.removeAttribute("novalidate")), a = (t) => {
|
|
544
796
|
t.preventDefault(), e.call(t.currentTarget, t);
|
|
545
797
|
};
|
|
546
|
-
} else a =
|
|
547
|
-
this.element[
|
|
798
|
+
} else a = r;
|
|
799
|
+
this.element[n] = a, this.element.addEventListener(t, a);
|
|
548
800
|
} else if (e.startsWith(".")) {
|
|
549
|
-
let t = e.slice(1),
|
|
550
|
-
if (
|
|
551
|
-
else if (
|
|
552
|
-
else if (
|
|
801
|
+
let t = e.slice(1), i = this.bindStates.get(e);
|
|
802
|
+
if (i && !(r instanceof a) && (this.element.removeEventListener(i.listener.__eventName, i.listener), this.bindStates.delete(e)), r === _) this.element[t] = void 0;
|
|
803
|
+
else if (r instanceof a && (t === "value" || t === "checked")) this.applySpreadBind(e, t, r);
|
|
804
|
+
else if (t === "value" && (this.element instanceof HTMLSelectElement || this.element instanceof HTMLTextAreaElement || this.element instanceof HTMLInputElement)) {
|
|
805
|
+
let t = r instanceof u, i = t ? r.value : r, o = i == null ? "" : String(i), s = this.previousValues[e], c = s instanceof u ? s.value : s, l = !(e in this.previousValues) || s instanceof a || s === _ || String(c ?? "") !== o;
|
|
806
|
+
(t ? this.element.value !== o : l) && (this.element.value = o), this.element instanceof HTMLSelectElement && (t || l || n) && this.selectCommit.schedule(this.element, o);
|
|
807
|
+
} else if (r instanceof u && (t === "value" || t === "checked")) {
|
|
553
808
|
let e = this.element;
|
|
554
809
|
if (t === "checked") {
|
|
555
|
-
let t = !!
|
|
810
|
+
let t = !!r.value;
|
|
556
811
|
e.checked !== t && (e.checked = t);
|
|
557
812
|
} else {
|
|
558
|
-
let t =
|
|
813
|
+
let t = r.value == null ? "" : String(r.value);
|
|
559
814
|
e.value !== t && (e.value = t);
|
|
560
815
|
}
|
|
561
|
-
} else
|
|
562
|
-
} else e.startsWith("?")
|
|
816
|
+
} else r instanceof a ? this.element[t] = p(r.component, r.fieldName) : r instanceof u ? this.element[t] = r.value : this.element[t] = r;
|
|
817
|
+
} else if (e.startsWith("?")) r !== _ && r ? this.element.setAttribute(e.slice(1), "") : this.element.removeAttribute(e.slice(1));
|
|
818
|
+
else if (r === _) e === "class" || e === "className" ? this.applySpreadClass("") : this.element.removeAttribute(e);
|
|
819
|
+
else if (r instanceof c) e === "class" || e === "className" ? this.applySpreadClass(r.value === void 0 ? "" : String(r.value)) : r.value === void 0 ? this.element.removeAttribute(e) : this.element.setAttribute(e, String(r.value));
|
|
820
|
+
else if (r == null) this.element.removeAttribute(e);
|
|
821
|
+
else if (typeof r == "boolean") {
|
|
822
|
+
let t = T(e, r);
|
|
823
|
+
t === null ? this.element.removeAttribute(e) : this.element.setAttribute(e, t);
|
|
824
|
+
} else (e === "class" || e === "className") && typeof r == "string" ? this.applySpreadClass(r) : this.element.setAttribute(e, String(r));
|
|
563
825
|
this.previousValues = { ...t };
|
|
564
826
|
}
|
|
565
827
|
applySpreadClass(e) {
|
|
@@ -569,7 +831,7 @@ var m = class {
|
|
|
569
831
|
this.spreadClasses = t;
|
|
570
832
|
}
|
|
571
833
|
applySpreadBind(e, t, n) {
|
|
572
|
-
let r = this.element, i = n.component, a =
|
|
834
|
+
let r = this.element, i = n.component, a = p(i, n.fieldName), o = this.bindStates.get(e);
|
|
573
835
|
if (t === "checked") {
|
|
574
836
|
let e = !!a;
|
|
575
837
|
(!o || o.lastKind !== "checked" || o.lastValue !== e) && (r.checked = e);
|
|
@@ -577,12 +839,12 @@ var m = class {
|
|
|
577
839
|
let e = a == null ? "" : String(a);
|
|
578
840
|
(!o || o.lastKind !== "value" || String(o.lastValue) !== e || this.element instanceof HTMLSelectElement && r.value !== e) && (r.value = e);
|
|
579
841
|
}
|
|
580
|
-
let s =
|
|
842
|
+
let s = W(this.element, t), c = !!o && (o.boundComponent !== i || o.boundField !== n.fieldName || o.listener.__eventName !== s);
|
|
581
843
|
if (o && c && (this.element.removeEventListener(o.listener.__eventName, o.listener), this.bindStates.delete(e), o = void 0), o) o.lastKind = t, o.lastValue = t === "checked" ? !!a : a == null ? "" : String(a);
|
|
582
844
|
else {
|
|
583
845
|
let r = (e) => {
|
|
584
846
|
let r = e.currentTarget, a = t === "checked" ? !!r[t] : r[t];
|
|
585
|
-
i &&
|
|
847
|
+
i && m(i, n.fieldName, a);
|
|
586
848
|
};
|
|
587
849
|
r.__eventName = s, this.element.addEventListener(s, r), o = {
|
|
588
850
|
listener: r,
|
|
@@ -590,12 +852,13 @@ var m = class {
|
|
|
590
852
|
lastValue: t === "checked" ? !!a : a == null ? "" : String(a),
|
|
591
853
|
boundComponent: i,
|
|
592
854
|
boundField: n.fieldName
|
|
593
|
-
}, this.bindStates.set(e, o), t === "value" &&
|
|
855
|
+
}, this.bindStates.set(e, o), t === "value" && U(this.element, () => this.bindStates.get(e) === o, () => p(o.boundComponent, o.boundField));
|
|
594
856
|
}
|
|
595
857
|
}
|
|
596
|
-
},
|
|
858
|
+
}, V = class {
|
|
597
859
|
element;
|
|
598
860
|
name;
|
|
861
|
+
selectCommit = new H();
|
|
599
862
|
segments;
|
|
600
863
|
isMulti;
|
|
601
864
|
multiState;
|
|
@@ -622,6 +885,7 @@ var m = class {
|
|
|
622
885
|
this.segments.push(n.substring(a)), this.isMulti = i.length > 1, this.multiState = r ?? null;
|
|
623
886
|
}
|
|
624
887
|
update(e) {
|
|
888
|
+
let t = this.selectCommit.cancel();
|
|
625
889
|
if (e === _) {
|
|
626
890
|
if (this.bindListener && this._detachBindListener(), this.isMulti && this.multiState) {
|
|
627
891
|
this.multiState.currentValues[this.multiState.position] = _, this.element.removeAttribute(this.name);
|
|
@@ -634,10 +898,10 @@ var m = class {
|
|
|
634
898
|
} else this.name.startsWith("?") && this.element.removeAttribute(this.name.slice(1)), this.element.removeAttribute(this.name);
|
|
635
899
|
return;
|
|
636
900
|
}
|
|
637
|
-
let t = !1;
|
|
638
|
-
e instanceof l && (t = !0, e = e.value);
|
|
639
901
|
let n = !1;
|
|
640
|
-
|
|
902
|
+
e instanceof u && (n = !0, e = e.value);
|
|
903
|
+
let r = !1;
|
|
904
|
+
if (e instanceof c && (r = !0, e = e.value), e instanceof a) {
|
|
641
905
|
this.updateBind(e);
|
|
642
906
|
return;
|
|
643
907
|
}
|
|
@@ -666,7 +930,7 @@ var m = class {
|
|
|
666
930
|
this.element[r] = e, this.element.addEventListener(t, e);
|
|
667
931
|
}
|
|
668
932
|
let i = e;
|
|
669
|
-
if (i instanceof
|
|
933
|
+
if (i instanceof d) {
|
|
670
934
|
let e = i.handler, t = this.element instanceof HTMLFormElement ? this.element : this.element.closest("form");
|
|
671
935
|
t instanceof HTMLFormElement && (i.novalidate ? t.setAttribute("novalidate", "") : t.removeAttribute("novalidate")), i = (t) => {
|
|
672
936
|
t.preventDefault(), e.call(t.currentTarget, t);
|
|
@@ -674,28 +938,33 @@ var m = class {
|
|
|
674
938
|
}
|
|
675
939
|
this.element[n] = typeof i == "function" ? i : void 0, this.element.hasAttribute(this.name) && this.element.removeAttribute(this.name);
|
|
676
940
|
} else if (this.name.startsWith(".")) {
|
|
677
|
-
let
|
|
678
|
-
if ((
|
|
679
|
-
let
|
|
680
|
-
(
|
|
941
|
+
let r = this.name.slice(1);
|
|
942
|
+
if ((r === "value" || r === "checked") && (this.element instanceof HTMLInputElement || this.element instanceof HTMLTextAreaElement || this.element instanceof HTMLSelectElement)) if (r === "checked") {
|
|
943
|
+
let t = !!e;
|
|
944
|
+
(n ? this.element.checked !== t : this.lastFormKind !== "checked" || this.lastFormValue !== t) && (this.element.checked = t, this.lastFormValue = t, this.lastFormKind = "checked");
|
|
681
945
|
} else {
|
|
682
|
-
let
|
|
683
|
-
|
|
946
|
+
let r = e == null ? "" : String(e), i = n ? this.element.value !== r : this.lastFormKind !== "value" || String(this.lastFormValue) !== r;
|
|
947
|
+
i && (this.element.value = r, this.lastFormValue = r, this.lastFormKind = "value"), this.element instanceof HTMLSelectElement && (n || i || t) && this.selectCommit.schedule(this.element, r);
|
|
684
948
|
}
|
|
685
|
-
else this.element[
|
|
949
|
+
else this.element[r] = e;
|
|
686
950
|
this.element.hasAttribute(this.name) && this.element.removeAttribute(this.name);
|
|
687
951
|
} else if (this.name.startsWith("?")) {
|
|
688
952
|
let t = this.name.slice(1);
|
|
689
953
|
e ? this.element.setAttribute(t, "") : this.element.removeAttribute(t), this.element.hasAttribute(this.name) && this.element.removeAttribute(this.name);
|
|
690
|
-
} else
|
|
954
|
+
} else if (r) e === void 0 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, this.segments[0] + String(e) + this.segments[1]);
|
|
955
|
+
else if (e == null) this.element.removeAttribute(this.name);
|
|
956
|
+
else if (typeof e == "boolean") {
|
|
957
|
+
let t = T(this.name, e);
|
|
958
|
+
t === null ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t);
|
|
959
|
+
} else this.element.setAttribute(this.name, this.segments[0] + String(e) + this.segments[1]);
|
|
691
960
|
}
|
|
692
961
|
updateBind(e) {
|
|
693
962
|
let t = this.name.startsWith(".") ? this.name.slice(1) : this.name;
|
|
694
963
|
if (t !== "value" && t !== "checked") {
|
|
695
|
-
this.element[t] =
|
|
964
|
+
this.element[t] = p(e.component, e.fieldName), this.element.hasAttribute(this.name) && this.element.removeAttribute(this.name), this.bindListener && this._detachBindListener();
|
|
696
965
|
return;
|
|
697
966
|
}
|
|
698
|
-
let n = this.element, r = e.component, i =
|
|
967
|
+
let n = this.element, r = e.component, i = p(r, e.fieldName);
|
|
699
968
|
if (t === "checked") {
|
|
700
969
|
let e = !!i;
|
|
701
970
|
(this.lastFormKind !== "checked" || this.lastFormValue !== e) && (n.checked = e, this.lastFormValue = e, this.lastFormKind = "checked");
|
|
@@ -703,26 +972,38 @@ var m = class {
|
|
|
703
972
|
let e = i == null ? "" : String(i);
|
|
704
973
|
(this.lastFormKind !== "value" || String(this.lastFormValue) !== e || this.element instanceof HTMLSelectElement && n.value !== e) && (n.value = e, this.lastFormValue = e, this.lastFormKind = "value");
|
|
705
974
|
}
|
|
706
|
-
let a =
|
|
975
|
+
let a = W(this.element, t);
|
|
707
976
|
if (this.bindListener && (this.boundPropName !== t || this.boundComponent !== r || this.boundFieldName !== e.fieldName || this.bindListener.__eventName !== a) && this._detachBindListener(), !this.bindListener) {
|
|
708
977
|
let n = (n) => {
|
|
709
978
|
let i = n.currentTarget, a = t === "checked" ? !!i[t] : i[t];
|
|
710
|
-
r &&
|
|
979
|
+
r && m(r, e.fieldName, a);
|
|
711
980
|
};
|
|
712
981
|
if (n.__eventName = a, this.bindListener = n, this.boundPropName = t, this.boundComponent = r, this.boundFieldName = e.fieldName, this.element.addEventListener(a, n), t === "value") {
|
|
713
982
|
let e = n;
|
|
714
|
-
|
|
983
|
+
U(this.element, () => this.bindListener === e, () => p(this.boundComponent, this.boundFieldName));
|
|
715
984
|
}
|
|
716
985
|
}
|
|
717
986
|
this.element.hasAttribute(this.name) && this.element.removeAttribute(this.name);
|
|
718
987
|
}
|
|
719
|
-
},
|
|
988
|
+
}, H = class {
|
|
989
|
+
pending = null;
|
|
990
|
+
cancel() {
|
|
991
|
+
let e = this.pending !== null;
|
|
992
|
+
return this.pending = null, e;
|
|
993
|
+
}
|
|
994
|
+
schedule(e, t) {
|
|
995
|
+
let n = {};
|
|
996
|
+
this.pending = n, queueMicrotask(() => {
|
|
997
|
+
this.pending === n && (this.pending = null, e.value !== t && (e.value = t));
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
}, U = (e, t, n) => {
|
|
720
1001
|
e instanceof HTMLSelectElement && queueMicrotask(() => {
|
|
721
1002
|
if (!t()) return;
|
|
722
1003
|
let r = n(), i = r == null ? "" : String(r);
|
|
723
1004
|
e.value !== i && (e.value = i);
|
|
724
1005
|
});
|
|
725
|
-
},
|
|
1006
|
+
}, W = (e, t) => {
|
|
726
1007
|
if (e instanceof HTMLSelectElement) return "change";
|
|
727
1008
|
if (e instanceof HTMLTextAreaElement) return "input";
|
|
728
1009
|
if (e instanceof HTMLInputElement) {
|
|
@@ -730,11 +1011,11 @@ var m = class {
|
|
|
730
1011
|
return t === "checked" || n === "checkbox" || n === "radio" || n === "range" ? "change" : "input";
|
|
731
1012
|
}
|
|
732
1013
|
return "input";
|
|
733
|
-
},
|
|
734
|
-
let t = [], n =
|
|
1014
|
+
}, G = /* @__PURE__ */ new WeakMap(), K = (e) => {
|
|
1015
|
+
let t = [], n = D(e.strings, e.__cossackScope), r = "", i = !1, a = null, o = /(\.\.\.|[.@?]?[a-zA-Z0-9_:-]+)=["']?$/;
|
|
735
1016
|
for (let e = 0; e < n.length - 1; e++) {
|
|
736
1017
|
let t = n[e];
|
|
737
|
-
for (let e = 0; e < t.length; e++) a ? t[e] === a && (a = null) : t[e] === "\"" || t[e] === "'" ? e > 0 && t[e - 1] === "=" && (a = t[e]) : t[e] === "<" && t[e + 1] !== "!" && t[e + 1] !== "/" ? i = !0 : t[e] === ">" && (i = !1);
|
|
1018
|
+
for (let e = 0; e < t.length; e++) a ? t[e] === a && (a = null) : i && (t[e] === "\"" || t[e] === "'") ? e > 0 && t[e - 1] === "=" && (a = t[e]) : t[e] === "<" && t[e + 1] !== "!" && t[e + 1] !== "/" ? i = !0 : t[e] === ">" && (i = !1);
|
|
738
1019
|
r += t;
|
|
739
1020
|
let s = t.match(o);
|
|
740
1021
|
if (i && (s || a)) {
|
|
@@ -762,7 +1043,7 @@ var m = class {
|
|
|
762
1043
|
if (n) {
|
|
763
1044
|
let r = parseInt(n[1]), i = document.createComment("/CRP");
|
|
764
1045
|
e.parentNode.insertBefore(i, e.nextSibling);
|
|
765
|
-
let a = new
|
|
1046
|
+
let a = new z(e, i);
|
|
766
1047
|
t[r] = a;
|
|
767
1048
|
}
|
|
768
1049
|
} else if (e.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -773,10 +1054,10 @@ var m = class {
|
|
|
773
1054
|
if (r.length === 1) {
|
|
774
1055
|
let i = parseInt(r[0][1]);
|
|
775
1056
|
if (!t[i]) if (e.name === "...") {
|
|
776
|
-
let e = new
|
|
1057
|
+
let e = new B(n);
|
|
777
1058
|
t[i] = e, n.removeAttribute("...");
|
|
778
1059
|
} else {
|
|
779
|
-
let r = new
|
|
1060
|
+
let r = new V(n, e.name, e.value);
|
|
780
1061
|
t[i] = r;
|
|
781
1062
|
}
|
|
782
1063
|
return;
|
|
@@ -786,7 +1067,7 @@ var m = class {
|
|
|
786
1067
|
for (let r = 0; r < i.length; r++) {
|
|
787
1068
|
let o = i[r];
|
|
788
1069
|
if (!t[o]) {
|
|
789
|
-
let i = new
|
|
1070
|
+
let i = new V(n, e.name, e.value, {
|
|
790
1071
|
currentValues: a,
|
|
791
1072
|
position: r
|
|
792
1073
|
});
|
|
@@ -799,31 +1080,70 @@ var m = class {
|
|
|
799
1080
|
fragment: l,
|
|
800
1081
|
parts: t
|
|
801
1082
|
};
|
|
802
|
-
},
|
|
803
|
-
let n =
|
|
804
|
-
|
|
805
|
-
|
|
1083
|
+
}, q = (e, t) => {
|
|
1084
|
+
let n = N.get(t);
|
|
1085
|
+
N.delete(t);
|
|
1086
|
+
let r = G.get(t), i = R(e);
|
|
1087
|
+
if (r && r.identity === i) {
|
|
1088
|
+
F(r.parts, n, i), r.parts.forEach((t, n) => {
|
|
806
1089
|
t.update(e.values[n]);
|
|
807
1090
|
});
|
|
808
1091
|
return;
|
|
809
1092
|
}
|
|
810
|
-
if (
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1093
|
+
if (r) {
|
|
1094
|
+
G.delete(t);
|
|
1095
|
+
for (let e of r.parts) e && typeof e.dispose == "function" && e.dispose();
|
|
1096
|
+
}
|
|
1097
|
+
let { fragment: a, parts: o } = K(e);
|
|
1098
|
+
F(o, n, i);
|
|
1099
|
+
let s = e.values;
|
|
1100
|
+
try {
|
|
1101
|
+
for (let e = 0; e < s.length; e++) o[e] && o[e].update(s[e]);
|
|
1102
|
+
if (typeof HTMLElement < "u" && t instanceof HTMLElement || typeof ShadowRoot < "u" && t instanceof ShadowRoot) t.innerHTML = "";
|
|
1103
|
+
else for (; t.firstChild;) t.removeChild(t.firstChild);
|
|
1104
|
+
t.appendChild(a), G.set(t, {
|
|
1105
|
+
identity: i,
|
|
1106
|
+
parts: o
|
|
1107
|
+
});
|
|
1108
|
+
} catch (e) {
|
|
1109
|
+
throw I(o), e;
|
|
1110
|
+
}
|
|
1111
|
+
}, J = class extends Error {
|
|
1112
|
+
category;
|
|
1113
|
+
path;
|
|
1114
|
+
expected;
|
|
1115
|
+
actual;
|
|
1116
|
+
constructor(e, t, n, r) {
|
|
1117
|
+
super(`${e} at ${t}: expected ${n}; found ${r}`), this.category = e, this.path = t, this.expected = n, this.actual = r;
|
|
1118
|
+
}
|
|
1119
|
+
}, Y = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? `<${e.nodeName.toLowerCase()}>` : e.nodeType === Node.COMMENT_NODE ? "comment" : e.nodeType === Node.TEXT_NODE ? "text" : `nodeType:${e.nodeType}` : "<none>", X = (e, t, n, r, i = "full-render-fallback") => {
|
|
1120
|
+
if (!k || r?.expectedClientOnly) return;
|
|
1121
|
+
n ??= r?.component;
|
|
1122
|
+
let a = r?.statePath && /^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\])*$/.test(r.statePath) ? r.statePath.slice(0, 160) : void 0, o = r?.source?.file, s = typeof o == "string" && o.length <= 240 && !o.startsWith("/") && !o.includes("\\") && !o.split("/").includes("..") && !/^[a-zA-Z]+:/.test(o) ? {
|
|
1123
|
+
file: o,
|
|
1124
|
+
...Number.isSafeInteger(r?.source?.line) && r.source.line > 0 ? { line: r.source.line } : {},
|
|
1125
|
+
...Number.isSafeInteger(r?.source?.column) && r.source.column > 0 ? { column: r.source.column } : {}
|
|
1126
|
+
} : void 0, c = n?.replace(/[^a-zA-Z0-9_$]/g, "_").slice(0, 80);
|
|
1127
|
+
console.warn({
|
|
1128
|
+
event: "cossack.hydration.mismatch",
|
|
1129
|
+
boundary: t,
|
|
1130
|
+
...c ? { component: c } : {},
|
|
1131
|
+
...s ? { source: s } : {},
|
|
1132
|
+
...a ? { statePath: a } : {},
|
|
1133
|
+
category: e.category,
|
|
1134
|
+
path: e.path,
|
|
1135
|
+
expected: e.expected,
|
|
1136
|
+
actual: e.actual,
|
|
1137
|
+
action: i
|
|
818
1138
|
});
|
|
819
|
-
},
|
|
1139
|
+
}, Z = (e) => {
|
|
820
1140
|
if (e.nodeType === Node.TEXT_NODE) return (e.nodeValue || "").trim() === "";
|
|
821
1141
|
if (e.nodeType === Node.COMMENT_NODE) {
|
|
822
1142
|
let t = e.nodeValue || "";
|
|
823
1143
|
return !/^CRP_\d+$/.test(t) && t !== "/CRP" && t !== "CSA-S" && t !== "CSA-E";
|
|
824
1144
|
}
|
|
825
1145
|
return !1;
|
|
826
|
-
},
|
|
1146
|
+
}, le = (e) => {
|
|
827
1147
|
let t = [], n = [];
|
|
828
1148
|
for (let r of e) {
|
|
829
1149
|
if (r.nodeType !== Node.COMMENT_NODE) continue;
|
|
@@ -835,70 +1155,85 @@ var m = class {
|
|
|
835
1155
|
}
|
|
836
1156
|
}
|
|
837
1157
|
return t;
|
|
838
|
-
},
|
|
839
|
-
let
|
|
840
|
-
for (let
|
|
841
|
-
let
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1158
|
+
}, ue = (e) => {
|
|
1159
|
+
let t = [];
|
|
1160
|
+
for (let n = e; n?.parentNode && t.length < 12; n = n.parentNode) {
|
|
1161
|
+
let e = Array.prototype.indexOf.call(n.parentNode.childNodes, n);
|
|
1162
|
+
t.unshift(`${n.nodeType === Node.ELEMENT_NODE ? n.nodeName.toLowerCase() : "node"}[${e}]`);
|
|
1163
|
+
}
|
|
1164
|
+
return `root/${t.join("/")}`;
|
|
1165
|
+
}, Q = (e, t, n, r = "root", i) => {
|
|
1166
|
+
let a = 0;
|
|
1167
|
+
for (let o = 0; o < e.length; o++) {
|
|
1168
|
+
let s = e[o];
|
|
1169
|
+
if (Z(s)) continue;
|
|
1170
|
+
for (; a < t.length && Z(t[a]);) a++;
|
|
1171
|
+
let c = t[a], l = `${r}/${s.nodeType === Node.ELEMENT_NODE ? s.nodeName.toLowerCase() : "node"}[${o}]`;
|
|
1172
|
+
if (!c) throw new J("missing-node", l, Y(s), "<none>");
|
|
1173
|
+
if (s.nodeType === Node.ELEMENT_NODE) {
|
|
1174
|
+
if (c.nodeType !== Node.ELEMENT_NODE || s.nodeName !== c.nodeName) throw new J("element-tag", l, Y(s), Y(c));
|
|
1175
|
+
if (s.namespaceURI !== c.namespaceURI) throw new J("element-namespace", l, Y(s), Y(c));
|
|
1176
|
+
if (n.set(s, c), s.nodeName === "TEXTAREA") {
|
|
1177
|
+
a++;
|
|
1178
|
+
continue;
|
|
1179
|
+
}
|
|
1180
|
+
Q(s.childNodes, Array.from(c.childNodes), n, `${r}/${s.nodeName.toLowerCase()}[${o}]`, i);
|
|
849
1181
|
} else {
|
|
850
|
-
if (
|
|
851
|
-
n.set(
|
|
1182
|
+
if (s.nodeType !== c.nodeType) throw new J("node-type", l, Y(s), Y(c));
|
|
1183
|
+
s.nodeType === Node.TEXT_NODE && s.nodeValue !== c.nodeValue && (k && X(new J("text-content", l, "text", "text"), i?.boundary ?? "root", void 0, i, "text-reconcile"), c.nodeValue = s.nodeValue), n.set(s, c);
|
|
852
1184
|
}
|
|
853
|
-
if (
|
|
1185
|
+
if (a++, s.nodeType === Node.COMMENT_NODE && /^CRP_\d+$/.test(s.nodeValue || "")) {
|
|
854
1186
|
let e = 1;
|
|
855
|
-
for (;
|
|
856
|
-
let n = t[
|
|
1187
|
+
for (; a < t.length && e > 0;) {
|
|
1188
|
+
let n = t[a];
|
|
857
1189
|
if (n.nodeType === Node.COMMENT_NODE) {
|
|
858
1190
|
if (/^CRP_\d+$/.test(n.nodeValue || "")) e++;
|
|
859
1191
|
else if (n.nodeValue === "/CRP" && (e--, e === 0)) break;
|
|
860
1192
|
}
|
|
861
|
-
|
|
1193
|
+
a++;
|
|
862
1194
|
}
|
|
863
1195
|
}
|
|
864
1196
|
}
|
|
865
|
-
for (;
|
|
866
|
-
if (
|
|
867
|
-
},
|
|
1197
|
+
for (; a < t.length && Z(t[a]);) a++;
|
|
1198
|
+
if (a < t.length) throw new J("unexpected-node", `${r}/node[${a}]`, "end of template", Y(t[a]));
|
|
1199
|
+
}, $ = (e, t) => {
|
|
868
1200
|
for (let n of e) if (n) {
|
|
869
|
-
if (n instanceof
|
|
1201
|
+
if (n instanceof z) {
|
|
870
1202
|
let e = t.get(n.startNode), r = t.get(n.endNode);
|
|
871
|
-
if (!e || !r) throw new
|
|
1203
|
+
if (!e || !r) throw new J("missing-part-anchor", "part", "start and end anchors", "missing anchor");
|
|
872
1204
|
n.startNode = e, n.endNode = r, n._beginHydration();
|
|
873
|
-
} else if (n instanceof
|
|
1205
|
+
} else if (n instanceof V || n instanceof B) {
|
|
874
1206
|
let e = t.get(n.element);
|
|
875
|
-
if (!e) throw new
|
|
1207
|
+
if (!e) throw new J("missing-part-element", "part", "attribute element", "missing element");
|
|
876
1208
|
n.element = e;
|
|
877
1209
|
}
|
|
878
1210
|
}
|
|
879
|
-
},
|
|
880
|
-
if (!t.hasChildNodes()) return
|
|
881
|
-
let
|
|
882
|
-
if (
|
|
883
|
-
|
|
1211
|
+
}, de = (e, t, n) => {
|
|
1212
|
+
if (!t.hasChildNodes()) return q(e, t);
|
|
1213
|
+
let r = G.get(t), i = R(e);
|
|
1214
|
+
if (r && r.identity === i) {
|
|
1215
|
+
r.parts.forEach((t, n) => t.update(e.values[n]));
|
|
884
1216
|
return;
|
|
885
1217
|
}
|
|
886
|
-
if (
|
|
887
|
-
|
|
1218
|
+
if (r) {
|
|
1219
|
+
G.delete(t);
|
|
1220
|
+
for (let e of r.parts) e && typeof e.dispose == "function" && e.dispose();
|
|
1221
|
+
}
|
|
1222
|
+
let a = [];
|
|
888
1223
|
try {
|
|
889
|
-
let { fragment:
|
|
890
|
-
|
|
891
|
-
let
|
|
892
|
-
|
|
893
|
-
for (let t = 0; t < e.values.length; t++)
|
|
894
|
-
} catch (
|
|
895
|
-
if (
|
|
896
|
-
throw
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
identity:
|
|
900
|
-
parts:
|
|
1224
|
+
let { fragment: r, parts: i } = K(e);
|
|
1225
|
+
a = i;
|
|
1226
|
+
let o = /* @__PURE__ */ new Map();
|
|
1227
|
+
Q(r.childNodes, Array.from(t.childNodes), o, "root", k ? n : void 0), $(a, o), j(a, n);
|
|
1228
|
+
for (let t = 0; t < e.values.length; t++) a[t] && a[t].update(e.values[t]);
|
|
1229
|
+
} catch (r) {
|
|
1230
|
+
if (I(a), r instanceof J) return k && X(r, "root", void 0, n), q(e, t);
|
|
1231
|
+
throw r;
|
|
1232
|
+
}
|
|
1233
|
+
G.set(t, {
|
|
1234
|
+
identity: i,
|
|
1235
|
+
parts: a
|
|
901
1236
|
});
|
|
902
1237
|
};
|
|
903
1238
|
//#endregion
|
|
904
|
-
export {
|
|
1239
|
+
export { h as TemplateResult, b as UnsafeHTMLResult, ce as captureRenderDrafts, te as component, S as escapeHtml, g as html, de as hydrate, v as isTemplateResult, x as isUnsafeHTML, _ as nothing, q as render, O as renderToString, ee as svg, ne as unsafeHTML };
|