haori 0.23.0 → 0.24.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.ja.md +1 -1
- package/README.md +1 -1
- package/dist/haori.cjs.js +15 -15
- package/dist/haori.es.js +641 -576
- package/dist/haori.iife.js +15 -15
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const X = class X {
|
|
2
2
|
/**
|
|
3
3
|
* 開発モードの状態を取得します。
|
|
4
4
|
*
|
|
5
5
|
* @returns 開発モードならtrue、そうでなければfalse
|
|
6
6
|
*/
|
|
7
7
|
static isEnabled() {
|
|
8
|
-
return
|
|
8
|
+
return X.devMode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 開発モードを有効化します。
|
|
12
12
|
*/
|
|
13
13
|
static enable() {
|
|
14
|
-
|
|
14
|
+
X.devMode = !0;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 開発モードを無効化します。
|
|
18
18
|
*/
|
|
19
19
|
static disable() {
|
|
20
|
-
|
|
20
|
+
X.devMode = !1;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 開発モードを切り替えます。
|
|
@@ -25,11 +25,11 @@ const J = class J {
|
|
|
25
25
|
* @param enabled trueで有効化、falseで無効化
|
|
26
26
|
*/
|
|
27
27
|
static set(e) {
|
|
28
|
-
|
|
28
|
+
X.devMode = e;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
let L =
|
|
31
|
+
X.devMode = !1;
|
|
32
|
+
let L = X;
|
|
33
33
|
const de = "embedded";
|
|
34
34
|
function Se(f) {
|
|
35
35
|
return f === "embedded" || f === "demo";
|
|
@@ -37,14 +37,14 @@ function Se(f) {
|
|
|
37
37
|
function Oe(f) {
|
|
38
38
|
return f === null ? null : Se(f) ? f : de;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const V = class V {
|
|
41
41
|
/**
|
|
42
42
|
* 実行モードを取得します。
|
|
43
43
|
*
|
|
44
44
|
* @returns 実行モード。
|
|
45
45
|
*/
|
|
46
46
|
static get runtime() {
|
|
47
|
-
return
|
|
47
|
+
return V._runtime;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 実行モードを設定します。
|
|
@@ -53,7 +53,7 @@ const U = class U {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(e) {
|
|
56
|
-
|
|
56
|
+
V._runtime = Se(e) ? e : de;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -65,14 +65,14 @@ const U = class U {
|
|
|
65
65
|
try {
|
|
66
66
|
const e = document.currentScript || document.querySelector('script[src*="haori"]');
|
|
67
67
|
if (e instanceof HTMLScriptElement) {
|
|
68
|
-
const r = e.getAttribute("data-prefix") ||
|
|
69
|
-
|
|
68
|
+
const r = e.getAttribute("data-prefix") || V._prefix;
|
|
69
|
+
V._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
70
|
const i = Oe(
|
|
71
71
|
e.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
|
-
i !== null && (
|
|
73
|
+
i !== null && (V._runtime = i);
|
|
74
74
|
}
|
|
75
|
-
if (e instanceof HTMLScriptElement && e.hasAttribute(`${
|
|
75
|
+
if (e instanceof HTMLScriptElement && e.hasAttribute(`${V._prefix}dev`)) {
|
|
76
76
|
L.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
@@ -91,13 +91,13 @@ const U = class U {
|
|
|
91
91
|
* @returns プレフィックス
|
|
92
92
|
*/
|
|
93
93
|
static get prefix() {
|
|
94
|
-
return
|
|
94
|
+
return V._prefix;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
|
|
98
|
-
let c =
|
|
97
|
+
V._prefix = "data-", V._runtime = de;
|
|
98
|
+
let c = V;
|
|
99
99
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
|
|
100
|
-
class
|
|
100
|
+
class b {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
103
103
|
*
|
|
@@ -127,21 +127,21 @@ class m {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
const He = "yyyy/MM/dd HH:mm", Le = "en-US", Ee = 1e4;
|
|
130
|
-
function
|
|
130
|
+
function K(f) {
|
|
131
131
|
return String(f).padStart(2, "0");
|
|
132
132
|
}
|
|
133
133
|
function we(f, e, t, r, i, n) {
|
|
134
134
|
return {
|
|
135
135
|
yyyy: String(f).padStart(4, "0"),
|
|
136
|
-
yy:
|
|
137
|
-
MM:
|
|
136
|
+
yy: K(f % 100),
|
|
137
|
+
MM: K(e),
|
|
138
138
|
M: String(e),
|
|
139
|
-
dd:
|
|
139
|
+
dd: K(t),
|
|
140
140
|
d: String(t),
|
|
141
|
-
HH:
|
|
141
|
+
HH: K(r),
|
|
142
142
|
H: String(r),
|
|
143
|
-
mm:
|
|
144
|
-
ss:
|
|
143
|
+
mm: K(i),
|
|
144
|
+
ss: K(n)
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
function Ue(f, e) {
|
|
@@ -226,7 +226,7 @@ function De(f, e, t) {
|
|
|
226
226
|
s.push(a);
|
|
227
227
|
return s;
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function Fe(f, e, t = {}) {
|
|
230
230
|
const r = Math.trunc(Number(f));
|
|
231
231
|
if (!Number.isFinite(r) || r <= 0)
|
|
232
232
|
return [];
|
|
@@ -240,16 +240,16 @@ function Ne(f, e, t = {}) {
|
|
|
240
240
|
a.add(u);
|
|
241
241
|
for (let u = Math.max(0, i - n); u <= Math.min(r - 1, i + n); u += 1)
|
|
242
242
|
a.add(u);
|
|
243
|
-
const o = Array.from(a).sort((u,
|
|
243
|
+
const o = Array.from(a).sort((u, m) => u - m), l = [];
|
|
244
244
|
let h = null;
|
|
245
245
|
for (const u of o) {
|
|
246
246
|
if (h !== null && u - h > 1)
|
|
247
247
|
if (u - h === 2) {
|
|
248
|
-
const
|
|
248
|
+
const m = h + 1;
|
|
249
249
|
l.push({
|
|
250
|
-
page:
|
|
251
|
-
label:
|
|
252
|
-
active:
|
|
250
|
+
page: m,
|
|
251
|
+
label: m + 1,
|
|
252
|
+
active: m === i,
|
|
253
253
|
ellipsis: !1
|
|
254
254
|
});
|
|
255
255
|
} else
|
|
@@ -278,15 +278,15 @@ function ue(f, e) {
|
|
|
278
278
|
if (i < 1 || i > 12)
|
|
279
279
|
return "";
|
|
280
280
|
const n = Number.isFinite(e) ? Math.trunc(e) : 0, s = r * 12 + (i - 1) + n, a = Math.floor(s / 12), o = s - a * 12 + 1;
|
|
281
|
-
return `${String(a).padStart(4, "0")}-${
|
|
281
|
+
return `${String(a).padStart(4, "0")}-${K(o)}`;
|
|
282
282
|
}
|
|
283
283
|
function qe(f) {
|
|
284
284
|
if (typeof f == "string" && f.trim() !== "")
|
|
285
285
|
return ue(f, 0);
|
|
286
286
|
const e = /* @__PURE__ */ new Date();
|
|
287
|
-
return `${String(e.getFullYear()).padStart(4, "0")}-${
|
|
287
|
+
return `${String(e.getFullYear()).padStart(4, "0")}-${K(e.getMonth() + 1)}`;
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function Ne(f, e) {
|
|
290
290
|
const t = Math.trunc(Number(f));
|
|
291
291
|
if (!Number.isFinite(t) || t < 0)
|
|
292
292
|
return [];
|
|
@@ -342,15 +342,15 @@ function ke(f, e) {
|
|
|
342
342
|
}
|
|
343
343
|
return t;
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function Ie(f, e) {
|
|
346
346
|
return e == null || f == null ? String(f) : String(f[e]);
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function Pe(f, e) {
|
|
349
349
|
if (!Array.isArray(f))
|
|
350
350
|
return [];
|
|
351
351
|
const t = /* @__PURE__ */ new Set(), r = [];
|
|
352
352
|
for (const i of f) {
|
|
353
|
-
const n =
|
|
353
|
+
const n = Ie(i, e);
|
|
354
354
|
t.has(n) || (t.add(n), r.push(i));
|
|
355
355
|
}
|
|
356
356
|
return r;
|
|
@@ -360,7 +360,7 @@ function Ce(f, e) {
|
|
|
360
360
|
return [];
|
|
361
361
|
const t = /* @__PURE__ */ new Map(), r = [];
|
|
362
362
|
for (const i of f) {
|
|
363
|
-
const n =
|
|
363
|
+
const n = Ie(i, e), s = t.get(n);
|
|
364
364
|
if (s === void 0) {
|
|
365
365
|
const a = i == null ? i : i[e];
|
|
366
366
|
t.set(n, r.length), r.push({ key: a, items: [i] });
|
|
@@ -372,14 +372,14 @@ function Ce(f, e) {
|
|
|
372
372
|
const We = Object.freeze({
|
|
373
373
|
date: Te,
|
|
374
374
|
number: Re,
|
|
375
|
-
pages:
|
|
375
|
+
pages: Fe,
|
|
376
376
|
range: De,
|
|
377
377
|
monthAdd: ue,
|
|
378
|
-
monthRange:
|
|
378
|
+
monthRange: Ne,
|
|
379
379
|
pageSummary: Me,
|
|
380
380
|
findBy: xe,
|
|
381
381
|
sum: ke,
|
|
382
|
-
distinct:
|
|
382
|
+
distinct: Pe,
|
|
383
383
|
groupBy: Ce
|
|
384
384
|
}), B = class B {
|
|
385
385
|
/**
|
|
@@ -475,18 +475,18 @@ const We = Object.freeze({
|
|
|
475
475
|
*/
|
|
476
476
|
static evaluateDetailed(e, t = {}) {
|
|
477
477
|
if (this.scheduleForbiddenBindingValueCacheReset(), e.trim() === "")
|
|
478
|
-
return
|
|
478
|
+
return b.warn("[Haori]", e, "Expression is empty"), { value: null, unresolvedReference: !1 };
|
|
479
479
|
if (this.containsDangerousPatterns(e)) {
|
|
480
480
|
const l = this.detectDisallowedKeywords(e);
|
|
481
481
|
if (l.length > 0) {
|
|
482
482
|
const h = l.some((u) => u === "function" || u === "return") ? " Statement keywords are not allowed in expressions; use an arrow function such as `x => ({key: value})` instead of `function(x){ return {key: value}; }`." : " These are statement keywords and cannot be used in expressions.";
|
|
483
|
-
|
|
483
|
+
b.warn(
|
|
484
484
|
"[Haori]",
|
|
485
485
|
e,
|
|
486
486
|
"Expression uses disallowed keyword(s): " + l.join(", ") + "." + h
|
|
487
487
|
);
|
|
488
488
|
} else
|
|
489
|
-
|
|
489
|
+
b.warn(
|
|
490
490
|
"[Haori]",
|
|
491
491
|
e,
|
|
492
492
|
"Expression contains dangerous patterns"
|
|
@@ -496,7 +496,7 @@ const We = Object.freeze({
|
|
|
496
496
|
const r = this.collectForbiddenKeys(t);
|
|
497
497
|
if (r.length > 0) {
|
|
498
498
|
const l = r.join(",");
|
|
499
|
-
this.loggedForbiddenKeySignatures.has(l) || (this.loggedForbiddenKeySignatures.add(l), this.scheduleForbiddenKeyLogReset(),
|
|
499
|
+
this.loggedForbiddenKeySignatures.has(l) || (this.loggedForbiddenKeySignatures.add(l), this.scheduleForbiddenKeyLogReset(), b.error(
|
|
500
500
|
"[Haori]",
|
|
501
501
|
"Binding keys are reserved and ignored: " + r.join(", ") + ". These collide with blocked global/prototype names and cannot be used as top-level binding keys; the remaining keys are still evaluated."
|
|
502
502
|
));
|
|
@@ -507,7 +507,7 @@ const We = Object.freeze({
|
|
|
507
507
|
/* @__PURE__ */ new WeakSet(),
|
|
508
508
|
i
|
|
509
509
|
))
|
|
510
|
-
return
|
|
510
|
+
return b.warn(
|
|
511
511
|
"[Haori]",
|
|
512
512
|
t,
|
|
513
513
|
"Binded values contain forbidden values"
|
|
@@ -518,7 +518,7 @@ const We = Object.freeze({
|
|
|
518
518
|
), s = this.BUILTIN_REFERENCE_PATTERN.test(
|
|
519
519
|
n
|
|
520
520
|
);
|
|
521
|
-
s && this.BUILTIN_NAMESPACE in t &&
|
|
521
|
+
s && this.BUILTIN_NAMESPACE in t && b.warn(
|
|
522
522
|
"[Haori]",
|
|
523
523
|
`Binding key "${this.BUILTIN_NAMESPACE}" is reserved for built-in helpers; the bound value is ignored in expressions.`
|
|
524
524
|
);
|
|
@@ -532,9 +532,9 @@ const We = Object.freeze({
|
|
|
532
532
|
if (h.compileFailed || h.evaluator === null)
|
|
533
533
|
return { value: null, unresolvedReference: !1 };
|
|
534
534
|
try {
|
|
535
|
-
const u = [],
|
|
535
|
+
const u = [], m = this.wrapBoundValues(a);
|
|
536
536
|
return h.bindKeys.forEach((v) => {
|
|
537
|
-
u.push(
|
|
537
|
+
u.push(m[v]);
|
|
538
538
|
}), {
|
|
539
539
|
value: this.withBlockedPropertyAccess(
|
|
540
540
|
() => h.evaluator(...u)
|
|
@@ -549,15 +549,15 @@ const We = Object.freeze({
|
|
|
549
549
|
continue;
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
const
|
|
553
|
-
return
|
|
552
|
+
const m = this.detectForbiddenIdentifiers(e);
|
|
553
|
+
return m.length > 0 && b.warn(
|
|
554
554
|
"[Haori]",
|
|
555
|
-
"Expression references blocked identifier(s): " +
|
|
555
|
+
"Expression references blocked identifier(s): " + m.join(", ") + ". These are blocked in expressions and evaluate to undefined (often the cause of this error). Use spread {...a, ...b} instead of Object.assign.",
|
|
556
556
|
e
|
|
557
|
-
),
|
|
557
|
+
), b.error("[Haori]", "Expression evaluation error:", e, u), u instanceof ReferenceError ? { value: void 0, unresolvedReference: !0 } : { value: null, unresolvedReference: !1 };
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
return
|
|
560
|
+
return b.error(
|
|
561
561
|
"[Haori]",
|
|
562
562
|
"Failed to recover missing identifiers:",
|
|
563
563
|
e,
|
|
@@ -591,7 +591,7 @@ return (${e});`;
|
|
|
591
591
|
compileFailed: !1
|
|
592
592
|
};
|
|
593
593
|
} catch (o) {
|
|
594
|
-
return
|
|
594
|
+
return b.error(
|
|
595
595
|
"[Haori]",
|
|
596
596
|
"Failed to compile expression:",
|
|
597
597
|
e,
|
|
@@ -1188,7 +1188,7 @@ B.MAX_IDENTIFIER_RECOVERY_COUNT = 8, B.BUILTIN_NAMESPACE = "haori", B.BUILTIN_HE
|
|
|
1188
1188
|
"with",
|
|
1189
1189
|
"yield"
|
|
1190
1190
|
]), B.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1191
|
-
let
|
|
1191
|
+
let G = B;
|
|
1192
1192
|
class ge {
|
|
1193
1193
|
constructor() {
|
|
1194
1194
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
@@ -1231,13 +1231,13 @@ class ge {
|
|
|
1231
1231
|
const r = await t.task();
|
|
1232
1232
|
t.resolve(r);
|
|
1233
1233
|
} catch (r) {
|
|
1234
|
-
t.reject(r),
|
|
1234
|
+
t.reject(r), b.error("[Haori]", `Task ${t.timestamp} failed:`, r);
|
|
1235
1235
|
}
|
|
1236
1236
|
if (performance.now() - e > this.MAX_BUDGET)
|
|
1237
1237
|
break;
|
|
1238
1238
|
}
|
|
1239
1239
|
} catch (e) {
|
|
1240
|
-
|
|
1240
|
+
b.error("[Haori]", "Error processing queue:", e);
|
|
1241
1241
|
} finally {
|
|
1242
1242
|
this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
|
|
1243
1243
|
}
|
|
@@ -1320,13 +1320,13 @@ const me = class me {
|
|
|
1320
1320
|
}
|
|
1321
1321
|
};
|
|
1322
1322
|
me.ASYNC_QUEUE = new ge();
|
|
1323
|
-
let
|
|
1324
|
-
const
|
|
1323
|
+
let I = me;
|
|
1324
|
+
const x = class x {
|
|
1325
1325
|
/**
|
|
1326
1326
|
* 集計状態を初期化します。
|
|
1327
1327
|
*/
|
|
1328
1328
|
static reset() {
|
|
1329
|
-
|
|
1329
|
+
x.ELEMENT_STORES.clear(), x.ensureGlobalAccess();
|
|
1330
1330
|
}
|
|
1331
1331
|
/**
|
|
1332
1332
|
* 現在の集計結果スナップショットを返します。
|
|
@@ -1334,7 +1334,7 @@ const F = class F {
|
|
|
1334
1334
|
* @returns エレメントごとの集計結果
|
|
1335
1335
|
*/
|
|
1336
1336
|
static snapshot() {
|
|
1337
|
-
return
|
|
1337
|
+
return x.ensureGlobalAccess(), [...x.ELEMENT_STORES.entries()].map(([e, t]) => ({
|
|
1338
1338
|
elementId: e,
|
|
1339
1339
|
tagName: t.tagName,
|
|
1340
1340
|
attributes: [...t.attributes.entries()].map(([r, i]) => ({
|
|
@@ -1343,7 +1343,7 @@ const F = class F {
|
|
|
1343
1343
|
calls: i.calls,
|
|
1344
1344
|
totalDurationMs: i.totalDurationMs,
|
|
1345
1345
|
maxDurationMs: i.maxDurationMs,
|
|
1346
|
-
placeholders:
|
|
1346
|
+
placeholders: x.sortPlaceholders(
|
|
1347
1347
|
i.placeholders
|
|
1348
1348
|
)
|
|
1349
1349
|
})).sort((r, i) => i.calls - r.calls),
|
|
@@ -1353,7 +1353,7 @@ const F = class F {
|
|
|
1353
1353
|
calls: i.calls,
|
|
1354
1354
|
totalDurationMs: i.totalDurationMs,
|
|
1355
1355
|
maxDurationMs: i.maxDurationMs,
|
|
1356
|
-
placeholders:
|
|
1356
|
+
placeholders: x.sortPlaceholders(
|
|
1357
1357
|
i.placeholders
|
|
1358
1358
|
)
|
|
1359
1359
|
})).sort((r, i) => i.calls - r.calls)
|
|
@@ -1371,29 +1371,29 @@ const F = class F {
|
|
|
1371
1371
|
static record(e, t, r) {
|
|
1372
1372
|
if (!L.isEnabled() || !e || t.length === 0)
|
|
1373
1373
|
return;
|
|
1374
|
-
|
|
1375
|
-
const i =
|
|
1374
|
+
x.ensureGlobalAccess();
|
|
1375
|
+
const i = x.getOrCreateElementStore(
|
|
1376
1376
|
e.element
|
|
1377
1377
|
);
|
|
1378
1378
|
if (e.kind === "attribute") {
|
|
1379
|
-
const s =
|
|
1379
|
+
const s = x.getOrCreateCounter(
|
|
1380
1380
|
i.attributes,
|
|
1381
1381
|
e.rawName,
|
|
1382
1382
|
e.template
|
|
1383
1383
|
);
|
|
1384
|
-
|
|
1384
|
+
x.updateCounter(
|
|
1385
1385
|
s,
|
|
1386
1386
|
t,
|
|
1387
1387
|
r
|
|
1388
1388
|
);
|
|
1389
1389
|
return;
|
|
1390
1390
|
}
|
|
1391
|
-
const n =
|
|
1391
|
+
const n = x.getOrCreateCounter(
|
|
1392
1392
|
i.texts,
|
|
1393
1393
|
String(e.childIndex),
|
|
1394
1394
|
e.template
|
|
1395
1395
|
);
|
|
1396
|
-
|
|
1396
|
+
x.updateCounter(
|
|
1397
1397
|
n,
|
|
1398
1398
|
t,
|
|
1399
1399
|
r
|
|
@@ -1406,9 +1406,9 @@ const F = class F {
|
|
|
1406
1406
|
if (!L.isEnabled())
|
|
1407
1407
|
return;
|
|
1408
1408
|
const e = globalThis;
|
|
1409
|
-
e[
|
|
1410
|
-
reset: () =>
|
|
1411
|
-
snapshot: () =>
|
|
1409
|
+
e[x.GLOBAL_KEY] === void 0 && (e[x.GLOBAL_KEY] = {
|
|
1410
|
+
reset: () => x.reset(),
|
|
1411
|
+
snapshot: () => x.snapshot()
|
|
1412
1412
|
});
|
|
1413
1413
|
}
|
|
1414
1414
|
/**
|
|
@@ -1418,7 +1418,7 @@ const F = class F {
|
|
|
1418
1418
|
* @returns 集計ストア
|
|
1419
1419
|
*/
|
|
1420
1420
|
static getOrCreateElementStore(e) {
|
|
1421
|
-
const t =
|
|
1421
|
+
const t = x.createElementId(e), r = x.ELEMENT_STORES.get(t);
|
|
1422
1422
|
if (r)
|
|
1423
1423
|
return r;
|
|
1424
1424
|
const i = {
|
|
@@ -1426,7 +1426,7 @@ const F = class F {
|
|
|
1426
1426
|
attributes: /* @__PURE__ */ new Map(),
|
|
1427
1427
|
texts: /* @__PURE__ */ new Map()
|
|
1428
1428
|
};
|
|
1429
|
-
return
|
|
1429
|
+
return x.ELEMENT_STORES.set(t, i), i;
|
|
1430
1430
|
}
|
|
1431
1431
|
/**
|
|
1432
1432
|
* カウンタを取得または初期化します。
|
|
@@ -1476,7 +1476,7 @@ const F = class F {
|
|
|
1476
1476
|
*/
|
|
1477
1477
|
static updateCounter(e, t, r) {
|
|
1478
1478
|
e.calls += 1, e.totalDurationMs += r, e.maxDurationMs = Math.max(e.maxDurationMs, r), t.forEach((i) => {
|
|
1479
|
-
const n =
|
|
1479
|
+
const n = x.getOrCreatePlaceholder(
|
|
1480
1480
|
e.placeholders,
|
|
1481
1481
|
i.expression
|
|
1482
1482
|
);
|
|
@@ -1515,10 +1515,10 @@ const F = class F {
|
|
|
1515
1515
|
* @returns 結果と所要時間
|
|
1516
1516
|
*/
|
|
1517
1517
|
static measure(e) {
|
|
1518
|
-
const t =
|
|
1518
|
+
const t = x.now();
|
|
1519
1519
|
return {
|
|
1520
1520
|
value: e(),
|
|
1521
|
-
durationMs:
|
|
1521
|
+
durationMs: x.now() - t
|
|
1522
1522
|
};
|
|
1523
1523
|
}
|
|
1524
1524
|
/**
|
|
@@ -1545,35 +1545,35 @@ const F = class F {
|
|
|
1545
1545
|
return t.join(" > ");
|
|
1546
1546
|
}
|
|
1547
1547
|
};
|
|
1548
|
-
|
|
1549
|
-
let ne =
|
|
1550
|
-
const
|
|
1548
|
+
x.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", x.ELEMENT_STORES = /* @__PURE__ */ new Map();
|
|
1549
|
+
let ne = x;
|
|
1550
|
+
const Q = class Q {
|
|
1551
1551
|
/**
|
|
1552
1552
|
* フラグメントのコンストラクタ。
|
|
1553
1553
|
*
|
|
1554
1554
|
* @param target 対象ノード
|
|
1555
1555
|
*/
|
|
1556
1556
|
constructor(e) {
|
|
1557
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e,
|
|
1557
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e, Q.FRAGMENT_CACHE.set(e, this);
|
|
1558
1558
|
}
|
|
1559
1559
|
static get(e) {
|
|
1560
1560
|
if (e == null)
|
|
1561
1561
|
return null;
|
|
1562
|
-
if (
|
|
1563
|
-
return
|
|
1562
|
+
if (Q.FRAGMENT_CACHE.has(e))
|
|
1563
|
+
return Q.FRAGMENT_CACHE.get(e);
|
|
1564
1564
|
let t;
|
|
1565
1565
|
switch (e.nodeType) {
|
|
1566
1566
|
case Node.ELEMENT_NODE:
|
|
1567
1567
|
t = new M(e);
|
|
1568
1568
|
break;
|
|
1569
1569
|
case Node.TEXT_NODE:
|
|
1570
|
-
t = new
|
|
1570
|
+
t = new j(e);
|
|
1571
1571
|
break;
|
|
1572
1572
|
case Node.COMMENT_NODE:
|
|
1573
1573
|
t = new pe(e);
|
|
1574
1574
|
break;
|
|
1575
1575
|
default:
|
|
1576
|
-
return
|
|
1576
|
+
return b.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
|
|
1577
1577
|
}
|
|
1578
1578
|
return t;
|
|
1579
1579
|
}
|
|
@@ -1595,7 +1595,7 @@ const X = class X {
|
|
|
1595
1595
|
return Promise.resolve();
|
|
1596
1596
|
if (this.parent) {
|
|
1597
1597
|
const e = this.parent, t = e.skipMutationNodes;
|
|
1598
|
-
return
|
|
1598
|
+
return I.enqueue(() => {
|
|
1599
1599
|
e.skipMutationNodes = !0, this.target.parentNode === e.getTarget() && e.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1600
1600
|
}).finally(() => {
|
|
1601
1601
|
e.skipMutationNodes = t;
|
|
@@ -1603,7 +1603,7 @@ const X = class X {
|
|
|
1603
1603
|
} else {
|
|
1604
1604
|
const e = this.target.parentNode;
|
|
1605
1605
|
if (e)
|
|
1606
|
-
return
|
|
1606
|
+
return I.enqueue(() => {
|
|
1607
1607
|
this.target.parentNode === e && e.removeChild(this.target), this.mounted = !1;
|
|
1608
1608
|
});
|
|
1609
1609
|
this.mounted = !1;
|
|
@@ -1620,7 +1620,7 @@ const X = class X {
|
|
|
1620
1620
|
return Promise.resolve();
|
|
1621
1621
|
if (this.parent) {
|
|
1622
1622
|
const e = this.parent, t = e.skipMutationNodes;
|
|
1623
|
-
return
|
|
1623
|
+
return I.enqueue(() => {
|
|
1624
1624
|
e.skipMutationNodes = !0, this.target.parentNode !== e.getTarget() && e.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1625
1625
|
}).finally(() => {
|
|
1626
1626
|
e.skipMutationNodes = t;
|
|
@@ -1651,7 +1651,7 @@ const X = class X {
|
|
|
1651
1651
|
* @return 除去のPromise
|
|
1652
1652
|
*/
|
|
1653
1653
|
remove(e = !0) {
|
|
1654
|
-
return this.parent && this.parent.removeChild(this),
|
|
1654
|
+
return this.parent && this.parent.removeChild(this), Q.FRAGMENT_CACHE.delete(this.target), e ? this.unmount() : Promise.resolve();
|
|
1655
1655
|
}
|
|
1656
1656
|
/**
|
|
1657
1657
|
* 対象ノードを取得します。
|
|
@@ -1678,9 +1678,9 @@ const X = class X {
|
|
|
1678
1678
|
this.parent = e;
|
|
1679
1679
|
}
|
|
1680
1680
|
};
|
|
1681
|
-
|
|
1682
|
-
let
|
|
1683
|
-
const
|
|
1681
|
+
Q.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1682
|
+
let S = Q;
|
|
1683
|
+
const z = class z extends S {
|
|
1684
1684
|
/**
|
|
1685
1685
|
* エレメントフラグメントのコンストラクタ。
|
|
1686
1686
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1710,7 +1710,7 @@ const K = class K extends T {
|
|
|
1710
1710
|
this.attributeMap.set(t, i);
|
|
1711
1711
|
}
|
|
1712
1712
|
}), e.childNodes.forEach((t) => {
|
|
1713
|
-
const r =
|
|
1713
|
+
const r = S.get(t);
|
|
1714
1714
|
r.setParent(this), this.children.push(r);
|
|
1715
1715
|
});
|
|
1716
1716
|
}
|
|
@@ -1729,7 +1729,7 @@ const K = class K extends T {
|
|
|
1729
1729
|
*/
|
|
1730
1730
|
getChildElementFragments() {
|
|
1731
1731
|
return this.children.filter(
|
|
1732
|
-
(e) => e instanceof
|
|
1732
|
+
(e) => e instanceof z
|
|
1733
1733
|
);
|
|
1734
1734
|
}
|
|
1735
1735
|
/**
|
|
@@ -1750,7 +1750,7 @@ const K = class K extends T {
|
|
|
1750
1750
|
removeChild(e) {
|
|
1751
1751
|
const t = this.children.indexOf(e);
|
|
1752
1752
|
if (t < 0) {
|
|
1753
|
-
|
|
1753
|
+
b.warn("[Haori]", "Child fragment not found.", e);
|
|
1754
1754
|
return;
|
|
1755
1755
|
}
|
|
1756
1756
|
this.children.splice(t, 1), e.setParent(null);
|
|
@@ -1761,7 +1761,7 @@ const K = class K extends T {
|
|
|
1761
1761
|
* @returns クローンされたフラグメント
|
|
1762
1762
|
*/
|
|
1763
1763
|
clone() {
|
|
1764
|
-
const e = new
|
|
1764
|
+
const e = new z(
|
|
1765
1765
|
this.target.cloneNode(!1)
|
|
1766
1766
|
);
|
|
1767
1767
|
return this.attributeMap.forEach((t, r) => {
|
|
@@ -1776,7 +1776,7 @@ const K = class K extends T {
|
|
|
1776
1776
|
*/
|
|
1777
1777
|
normalizeClonedVisibilityState() {
|
|
1778
1778
|
(this.visible === !1 || this.getTarget().style.display === "none" || this.getTarget().hasAttribute(`${c.prefix}if-false`)) && (this.visible = !0, this.display = null, this.displayPriority = null, this.getTarget().style.removeProperty("display"), this.getTarget().removeAttribute(`${c.prefix}if-false`)), this.children.forEach((e) => {
|
|
1779
|
-
e instanceof
|
|
1779
|
+
e instanceof z && e.normalizeClonedVisibilityState();
|
|
1780
1780
|
});
|
|
1781
1781
|
}
|
|
1782
1782
|
/**
|
|
@@ -1940,7 +1940,7 @@ const K = class K extends T {
|
|
|
1940
1940
|
*/
|
|
1941
1941
|
clearBindingDataCache() {
|
|
1942
1942
|
this.bindingDataCache = null, this.descendantBindingDataCache = null, this.children.forEach((e) => {
|
|
1943
|
-
e instanceof
|
|
1943
|
+
e instanceof z && e.clearBindingDataCache();
|
|
1944
1944
|
});
|
|
1945
1945
|
}
|
|
1946
1946
|
/**
|
|
@@ -2092,14 +2092,14 @@ const K = class K extends T {
|
|
|
2092
2092
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
2093
2093
|
const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
|
|
2094
2094
|
let s;
|
|
2095
|
-
return n ? s = e === !0 || e === "true" : i === "false" ? s = e === !1 : Array.isArray(e) ? s = e.map(String).includes(String(i)) : s = i === String(e), n ? this.value = s : s ? Array.isArray(e) ? this.value = String(i) : this.value = e : this.value = null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0,
|
|
2095
|
+
return n ? s = e === !0 || e === "true" : i === "false" ? s = e === !1 : Array.isArray(e) ? s = e.map(String).includes(String(i)) : s = i === String(e), n ? this.value = s : s ? Array.isArray(e) ? this.value = String(i) : this.value = e : this.value = null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0, I.enqueue(() => {
|
|
2096
2096
|
r.checked = s, t && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2097
2097
|
}).finally(() => {
|
|
2098
2098
|
this.skipChangeValue = !1;
|
|
2099
2099
|
}));
|
|
2100
2100
|
} else if (r instanceof HTMLSelectElement && r.multiple) {
|
|
2101
2101
|
const i = (Array.isArray(e) ? e : e === null ? [] : [e]).map(String);
|
|
2102
|
-
return this.value = i.slice(), this.skipChangeValue = !0,
|
|
2102
|
+
return this.value = i.slice(), this.skipChangeValue = !0, I.enqueue(() => {
|
|
2103
2103
|
let n = !1;
|
|
2104
2104
|
Array.from(r.options).forEach((s) => {
|
|
2105
2105
|
const a = i.includes(s.value);
|
|
@@ -2110,13 +2110,13 @@ const K = class K extends T {
|
|
|
2110
2110
|
});
|
|
2111
2111
|
} else if (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement) {
|
|
2112
2112
|
const i = Array.isArray(e) ? e.join(",") : e;
|
|
2113
|
-
return this.value = this.normalizeValueForElement(r, i), this.skipChangeValue = !0,
|
|
2113
|
+
return this.value = this.normalizeValueForElement(r, i), this.skipChangeValue = !0, I.enqueue(() => {
|
|
2114
2114
|
r.value = i === null ? "" : String(i), t && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
2115
2115
|
}).finally(() => {
|
|
2116
2116
|
this.skipChangeValue = !1;
|
|
2117
2117
|
});
|
|
2118
2118
|
} else
|
|
2119
|
-
return
|
|
2119
|
+
return b.warn(
|
|
2120
2120
|
"[Haori]",
|
|
2121
2121
|
"setValue is not supported for this element type.",
|
|
2122
2122
|
r
|
|
@@ -2220,7 +2220,7 @@ const K = class K extends T {
|
|
|
2220
2220
|
return Promise.resolve();
|
|
2221
2221
|
this.attributeMap.delete(e), this.skipMutationAttributes = !0;
|
|
2222
2222
|
const r = this.getTarget();
|
|
2223
|
-
return
|
|
2223
|
+
return I.enqueue(() => {
|
|
2224
2224
|
r.removeAttribute(e), t !== e && r.removeAttribute(t);
|
|
2225
2225
|
}).finally(() => {
|
|
2226
2226
|
this.skipMutationAttributes = !1;
|
|
@@ -2244,7 +2244,7 @@ const K = class K extends T {
|
|
|
2244
2244
|
if (n) {
|
|
2245
2245
|
const ce = this.attributeMap.get(e);
|
|
2246
2246
|
if (ce && (ce.isEvaluate || ce.isForceEvaluation()) && !s.isEvaluate && !s.isForceEvaluation())
|
|
2247
|
-
return this.skipMutationAttributes = !0,
|
|
2247
|
+
return this.skipMutationAttributes = !0, I.enqueue(() => {
|
|
2248
2248
|
}).finally(() => {
|
|
2249
2249
|
this.skipMutationAttributes = !1;
|
|
2250
2250
|
});
|
|
@@ -2255,9 +2255,9 @@ const K = class K extends T {
|
|
|
2255
2255
|
element: a,
|
|
2256
2256
|
rawName: e,
|
|
2257
2257
|
template: r
|
|
2258
|
-
}), l = s.isEvaluate || s.isRawEvaluate, h = e === t &&
|
|
2259
|
-
return !
|
|
2260
|
-
|
|
2258
|
+
}), l = s.isEvaluate || s.isRawEvaluate, h = e === t && z.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), u = s.isSingleExpression(), m = Y.joinEvaluateResults(o.results), v = o.results.length === 1 ? o.results[0] : m, T = !s.isForceEvaluation() && (t !== e || h || u ? o.hasUnresolvedReference || v === null || v === void 0 || v === !1 : l && m === ""), C = s.isForceEvaluation() ? r : u ? v : m, O = i && s.isEvaluate && t === "value" && (a instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(a.type) || a instanceof HTMLTextAreaElement || a instanceof HTMLSelectElement), E = a.getRootNode(), p = O && a === E.activeElement, y = T || C === null || C === !1 ? null : String(C), R = e !== t && a.getAttribute(e) !== r, P = y === null ? a.hasAttribute(t) : a.getAttribute(t) !== y, F = O && !p && y !== null && a.value !== y, U = t === "checked" && a instanceof HTMLInputElement && (a.type === "checkbox" || a.type === "radio"), $ = t === "selected" && a instanceof HTMLOptionElement, W = E.activeElement, be = W !== null && (U && a === W || $ && a.closest("select") === W), te = y !== null, ve = U && !be && a.checked !== te, ye = $ && !be && a.selected !== te;
|
|
2259
|
+
return !R && !P && !F && !ve && !ye ? (O && !p && y !== null && (this.value = this.normalizeValueForElement(a, y)), Promise.resolve()) : (this.skipMutationAttributes = !0, I.enqueue(() => {
|
|
2260
|
+
R && a.setAttribute(e, r), y === null ? a.removeAttribute(t) : (P && (a.setAttribute(t, y), t === `${c.prefix}bind` && this.recordSelfWrittenBind(y)), O && !p && (this.value = this.normalizeValueForElement(a, y), F && (a.value = y))), ve && (a.checked = te), ye && (a.selected = te);
|
|
2261
2261
|
}).finally(() => {
|
|
2262
2262
|
this.skipMutationAttributes = !1;
|
|
2263
2263
|
}));
|
|
@@ -2273,7 +2273,7 @@ const K = class K extends T {
|
|
|
2273
2273
|
return Promise.resolve();
|
|
2274
2274
|
this.attributeMap.delete(e), this.skipMutationAttributes = !0;
|
|
2275
2275
|
const t = this.getTarget();
|
|
2276
|
-
return
|
|
2276
|
+
return I.enqueue(() => {
|
|
2277
2277
|
t.removeAttribute(e);
|
|
2278
2278
|
}).finally(() => {
|
|
2279
2279
|
this.skipMutationAttributes = !1;
|
|
@@ -2309,7 +2309,7 @@ const K = class K extends T {
|
|
|
2309
2309
|
value: r.results[0],
|
|
2310
2310
|
hasUnresolvedReference: r.hasUnresolvedReference
|
|
2311
2311
|
} : {
|
|
2312
|
-
value:
|
|
2312
|
+
value: Y.joinEvaluateResults(r.results),
|
|
2313
2313
|
hasUnresolvedReference: r.hasUnresolvedReference
|
|
2314
2314
|
};
|
|
2315
2315
|
}
|
|
@@ -2354,7 +2354,7 @@ const K = class K extends T {
|
|
|
2354
2354
|
const i = t ? r.nextSibling : r;
|
|
2355
2355
|
let n = t ? r.nextSibling : r;
|
|
2356
2356
|
for (; n !== null; ) {
|
|
2357
|
-
const s =
|
|
2357
|
+
const s = S.get(n);
|
|
2358
2358
|
if (s !== null) {
|
|
2359
2359
|
const a = this.children.indexOf(s);
|
|
2360
2360
|
if (a !== -1)
|
|
@@ -2376,13 +2376,13 @@ const K = class K extends T {
|
|
|
2376
2376
|
if (this.skipMutationNodes)
|
|
2377
2377
|
return Promise.resolve();
|
|
2378
2378
|
if (e === this)
|
|
2379
|
-
return
|
|
2379
|
+
return b.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
2380
2380
|
const i = /* @__PURE__ */ new Set();
|
|
2381
2381
|
let n = this.parent;
|
|
2382
2382
|
for (; n; )
|
|
2383
2383
|
i.add(n), n = n.getParent();
|
|
2384
2384
|
if (i.has(e))
|
|
2385
|
-
return
|
|
2385
|
+
return b.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
2386
2386
|
const s = e.getParent() === this;
|
|
2387
2387
|
let a = -1, o = -1;
|
|
2388
2388
|
s && (a = this.children.indexOf(e), t !== null && (o = this.children.indexOf(t)));
|
|
@@ -2392,23 +2392,23 @@ const K = class K extends T {
|
|
|
2392
2392
|
if (t === null)
|
|
2393
2393
|
this.children.push(e);
|
|
2394
2394
|
else {
|
|
2395
|
-
let
|
|
2396
|
-
if (s ? a !== -1 && a < o ?
|
|
2395
|
+
let m;
|
|
2396
|
+
if (s ? a !== -1 && a < o ? m = o - 1 : m = o : m = this.children.indexOf(t), m === -1) {
|
|
2397
2397
|
const v = this.resolveInsertionPointFromDom(
|
|
2398
2398
|
t,
|
|
2399
2399
|
!1
|
|
2400
2400
|
);
|
|
2401
|
-
v === null ? (
|
|
2401
|
+
v === null ? (b.warn(
|
|
2402
2402
|
"[Haori]",
|
|
2403
2403
|
"Reference child not found in children.",
|
|
2404
2404
|
t
|
|
2405
2405
|
), this.children.push(e)) : (this.children.splice(v.index, 0, e), h = v.referenceNode);
|
|
2406
2406
|
} else
|
|
2407
|
-
this.children.splice(
|
|
2407
|
+
this.children.splice(m, 0, e);
|
|
2408
2408
|
}
|
|
2409
2409
|
e.setParent(this), e.setMounted(this.mounted);
|
|
2410
2410
|
const u = this.skipMutationNodes;
|
|
2411
|
-
return this.skipMutationNodes = !0,
|
|
2411
|
+
return this.skipMutationNodes = !0, I.enqueue(() => {
|
|
2412
2412
|
this.target.insertBefore(e.getTarget(), h);
|
|
2413
2413
|
}).finally(() => {
|
|
2414
2414
|
this.skipMutationNodes = u;
|
|
@@ -2430,7 +2430,7 @@ const K = class K extends T {
|
|
|
2430
2430
|
t,
|
|
2431
2431
|
!0
|
|
2432
2432
|
);
|
|
2433
|
-
return i === null ? (
|
|
2433
|
+
return i === null ? (b.warn(
|
|
2434
2434
|
"[Haori]",
|
|
2435
2435
|
"Reference child not found in children.",
|
|
2436
2436
|
t
|
|
@@ -2517,7 +2517,7 @@ const K = class K extends T {
|
|
|
2517
2517
|
return t === null ? null : t.closestByAttribute(e);
|
|
2518
2518
|
}
|
|
2519
2519
|
};
|
|
2520
|
-
|
|
2520
|
+
z.BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
2521
2521
|
"allowfullscreen",
|
|
2522
2522
|
"async",
|
|
2523
2523
|
"autofocus",
|
|
@@ -2542,8 +2542,8 @@ K.BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
2542
2542
|
"reversed",
|
|
2543
2543
|
"selected"
|
|
2544
2544
|
]);
|
|
2545
|
-
let M =
|
|
2546
|
-
class
|
|
2545
|
+
let M = z;
|
|
2546
|
+
class j extends S {
|
|
2547
2547
|
/**
|
|
2548
2548
|
* テキストフラグメントのコンストラクタ。
|
|
2549
2549
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -2551,7 +2551,7 @@ class V extends T {
|
|
|
2551
2551
|
* @param target 対象テキストノード
|
|
2552
2552
|
*/
|
|
2553
2553
|
constructor(e) {
|
|
2554
|
-
super(e), this.skipMutation = !1, this.renderedText = null, this.text = e.textContent || "", this.contents = new
|
|
2554
|
+
super(e), this.skipMutation = !1, this.renderedText = null, this.text = e.textContent || "", this.contents = new Y(this.text);
|
|
2555
2555
|
}
|
|
2556
2556
|
/**
|
|
2557
2557
|
* フラグメントをクローンします。
|
|
@@ -2559,7 +2559,7 @@ class V extends T {
|
|
|
2559
2559
|
* @returns クローンされたフラグメント
|
|
2560
2560
|
*/
|
|
2561
2561
|
clone() {
|
|
2562
|
-
const e = new
|
|
2562
|
+
const e = new j(this.target.cloneNode(!0));
|
|
2563
2563
|
return e.mounted = !1, e.text = this.text, e.contents = this.contents, e.renderedText = this.renderedText, e;
|
|
2564
2564
|
}
|
|
2565
2565
|
/**
|
|
@@ -2585,7 +2585,7 @@ class V extends T {
|
|
|
2585
2585
|
* @returns 更新のPromise
|
|
2586
2586
|
*/
|
|
2587
2587
|
setContent(e) {
|
|
2588
|
-
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, this.contents = new
|
|
2588
|
+
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, this.contents = new Y(e), this.evaluate());
|
|
2589
2589
|
}
|
|
2590
2590
|
/**
|
|
2591
2591
|
* フラグメントを評価します。
|
|
@@ -2595,7 +2595,7 @@ class V extends T {
|
|
|
2595
2595
|
evaluate() {
|
|
2596
2596
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
2597
2597
|
new Error("Parent fragment is required for raw evaluation")
|
|
2598
|
-
) :
|
|
2598
|
+
) : I.enqueue(() => {
|
|
2599
2599
|
this.skipMutation = !0;
|
|
2600
2600
|
let e = this.text;
|
|
2601
2601
|
this.contents.isRawEvaluate ? e = this.contents.evaluate(
|
|
@@ -2606,7 +2606,7 @@ class V extends T {
|
|
|
2606
2606
|
childIndex: this.parent.getChildren().indexOf(this),
|
|
2607
2607
|
template: this.text
|
|
2608
2608
|
}
|
|
2609
|
-
)[0] : this.contents.isEvaluate && (e =
|
|
2609
|
+
)[0] : this.contents.isEvaluate && (e = Y.joinEvaluateResults(
|
|
2610
2610
|
this.contents.evaluate(this.parent.getBindingData(), {
|
|
2611
2611
|
kind: "text",
|
|
2612
2612
|
element: this.parent.getTarget(),
|
|
@@ -2621,7 +2621,7 @@ class V extends T {
|
|
|
2621
2621
|
});
|
|
2622
2622
|
}
|
|
2623
2623
|
}
|
|
2624
|
-
class pe extends
|
|
2624
|
+
class pe extends S {
|
|
2625
2625
|
/**
|
|
2626
2626
|
* コメントフラグメントのコンストラクタ。
|
|
2627
2627
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -2655,7 +2655,7 @@ class pe extends T {
|
|
|
2655
2655
|
* @return 更新のPromise
|
|
2656
2656
|
*/
|
|
2657
2657
|
setContent(e) {
|
|
2658
|
-
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e,
|
|
2658
|
+
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, I.enqueue(() => {
|
|
2659
2659
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
2660
2660
|
}).finally(() => {
|
|
2661
2661
|
this.skipMutation = !1;
|
|
@@ -2721,7 +2721,7 @@ const oe = class oe {
|
|
|
2721
2721
|
*/
|
|
2722
2722
|
checkRawExpressions() {
|
|
2723
2723
|
for (let e = 0; e < this.contents.length; e++)
|
|
2724
|
-
this.contents[e].type === 2 && this.contents.length > 1 && (
|
|
2724
|
+
this.contents[e].type === 2 && this.contents.length > 1 && (b.error(
|
|
2725
2725
|
"[Haori]",
|
|
2726
2726
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2727
2727
|
), this.contents[e].type = 1);
|
|
@@ -2768,7 +2768,7 @@ const oe = class oe {
|
|
|
2768
2768
|
try {
|
|
2769
2769
|
if (r(l)) {
|
|
2770
2770
|
const h = ne.measure(
|
|
2771
|
-
() =>
|
|
2771
|
+
() => G.evaluateDetailed(l.text, e)
|
|
2772
2772
|
), u = h.value;
|
|
2773
2773
|
a += h.durationMs, s.push({
|
|
2774
2774
|
expression: l.text,
|
|
@@ -2777,7 +2777,7 @@ const oe = class oe {
|
|
|
2777
2777
|
} else
|
|
2778
2778
|
n.push(l.text);
|
|
2779
2779
|
} catch (h) {
|
|
2780
|
-
|
|
2780
|
+
b.error(
|
|
2781
2781
|
"[Haori]",
|
|
2782
2782
|
`Error evaluating ${i} expression: ${l.text}`,
|
|
2783
2783
|
h
|
|
@@ -2794,8 +2794,8 @@ const oe = class oe {
|
|
|
2794
2794
|
}
|
|
2795
2795
|
};
|
|
2796
2796
|
oe.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2797
|
-
let
|
|
2798
|
-
const le = class le extends
|
|
2797
|
+
let Y = oe;
|
|
2798
|
+
const le = class le extends Y {
|
|
2799
2799
|
/**
|
|
2800
2800
|
* コンストラクタ。
|
|
2801
2801
|
*
|
|
@@ -2840,7 +2840,7 @@ const le = class le extends G {
|
|
|
2840
2840
|
(i) => this.forceEvaluation && i.type === 0 || i.type === 1 || i.type === 2,
|
|
2841
2841
|
"attribute"
|
|
2842
2842
|
);
|
|
2843
|
-
return this.forceEvaluation && r.results.length > 1 ? (
|
|
2843
|
+
return this.forceEvaluation && r.results.length > 1 ? (b.error(
|
|
2844
2844
|
"[Haori]",
|
|
2845
2845
|
"each or if expressions must have a single content.",
|
|
2846
2846
|
r.results
|
|
@@ -2859,7 +2859,7 @@ le.FORCE_EVALUATION_ATTRIBUTES = [
|
|
|
2859
2859
|
"hor-derive"
|
|
2860
2860
|
];
|
|
2861
2861
|
let se = le;
|
|
2862
|
-
class
|
|
2862
|
+
class Z {
|
|
2863
2863
|
/**
|
|
2864
2864
|
* 実行モードを取得します。
|
|
2865
2865
|
*
|
|
@@ -2889,7 +2889,7 @@ class Q {
|
|
|
2889
2889
|
* @return すべてのレンダリングが完了したら解決される Promise
|
|
2890
2890
|
*/
|
|
2891
2891
|
static waitForRenders() {
|
|
2892
|
-
return
|
|
2892
|
+
return I.waitForIdle();
|
|
2893
2893
|
}
|
|
2894
2894
|
/**
|
|
2895
2895
|
* 通知ダイアログを表示します。
|
|
@@ -2898,7 +2898,7 @@ class Q {
|
|
|
2898
2898
|
* @returns 通知が閉じられると解決されるPromise
|
|
2899
2899
|
*/
|
|
2900
2900
|
static dialog(e) {
|
|
2901
|
-
return
|
|
2901
|
+
return I.enqueue(() => {
|
|
2902
2902
|
window.alert(e);
|
|
2903
2903
|
}, !0);
|
|
2904
2904
|
}
|
|
@@ -2926,7 +2926,7 @@ class Q {
|
|
|
2926
2926
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
2927
2927
|
*/
|
|
2928
2928
|
static confirm(e) {
|
|
2929
|
-
return
|
|
2929
|
+
return I.enqueue(() => window.confirm(e), !0);
|
|
2930
2930
|
}
|
|
2931
2931
|
/**
|
|
2932
2932
|
* ダイアログを開きます。
|
|
@@ -2934,8 +2934,8 @@ class Q {
|
|
|
2934
2934
|
* @param element 開くダイアログのHTML要素
|
|
2935
2935
|
*/
|
|
2936
2936
|
static openDialog(e) {
|
|
2937
|
-
return
|
|
2938
|
-
e instanceof HTMLDialogElement ? (
|
|
2937
|
+
return I.enqueue(() => {
|
|
2938
|
+
e instanceof HTMLDialogElement ? (Z.clearMessagesSync(e), e.showModal()) : b.error("[Haori]", "Element is not a dialog: ", e);
|
|
2939
2939
|
}, !0);
|
|
2940
2940
|
}
|
|
2941
2941
|
/**
|
|
@@ -2944,8 +2944,8 @@ class Q {
|
|
|
2944
2944
|
* @param element 閉じるダイアログのHTML要素
|
|
2945
2945
|
*/
|
|
2946
2946
|
static closeDialog(e) {
|
|
2947
|
-
return
|
|
2948
|
-
e instanceof HTMLDialogElement ? e.close() :
|
|
2947
|
+
return I.enqueue(() => {
|
|
2948
|
+
e instanceof HTMLDialogElement ? e.close() : b.error("[Haori]", "Element is not a dialog: ", e);
|
|
2949
2949
|
}, !0);
|
|
2950
2950
|
}
|
|
2951
2951
|
/**
|
|
@@ -2955,7 +2955,7 @@ class Q {
|
|
|
2955
2955
|
* @param message エラーメッセージ
|
|
2956
2956
|
*/
|
|
2957
2957
|
static addErrorMessage(e, t) {
|
|
2958
|
-
return
|
|
2958
|
+
return Z.addMessage(e, t, "error");
|
|
2959
2959
|
}
|
|
2960
2960
|
/**
|
|
2961
2961
|
* メッセージをレベル付きで追加します。
|
|
@@ -2965,7 +2965,7 @@ class Q {
|
|
|
2965
2965
|
* @param level メッセージのレベル(省略可能)
|
|
2966
2966
|
*/
|
|
2967
2967
|
static addMessage(e, t, r) {
|
|
2968
|
-
return
|
|
2968
|
+
return I.enqueue(() => {
|
|
2969
2969
|
const i = e instanceof HTMLFormElement ? e : e.parentElement ?? e;
|
|
2970
2970
|
i.setAttribute("data-message", t), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
2971
2971
|
}, !0);
|
|
@@ -2976,8 +2976,8 @@ class Q {
|
|
|
2976
2976
|
* @param parent メッセージをクリアする親要素
|
|
2977
2977
|
*/
|
|
2978
2978
|
static clearMessages(e) {
|
|
2979
|
-
return
|
|
2980
|
-
|
|
2979
|
+
return I.enqueue(() => {
|
|
2980
|
+
Z.clearMessagesSync(e);
|
|
2981
2981
|
}, !0);
|
|
2982
2982
|
}
|
|
2983
2983
|
/**
|
|
@@ -3042,7 +3042,7 @@ class Q {
|
|
|
3042
3042
|
* @returns 表示要素の配列
|
|
3043
3043
|
*/
|
|
3044
3044
|
static pages(e, t, r) {
|
|
3045
|
-
return
|
|
3045
|
+
return Fe(e, t, r);
|
|
3046
3046
|
}
|
|
3047
3047
|
/**
|
|
3048
3048
|
* `YYYY-MM` 形式の年月文字列に月数を加算します。
|
|
@@ -3066,7 +3066,7 @@ class Q {
|
|
|
3066
3066
|
* @returns 年月情報の降順配列。不正な入力は空配列
|
|
3067
3067
|
*/
|
|
3068
3068
|
static monthRange(e, t) {
|
|
3069
|
-
return
|
|
3069
|
+
return Ne(e, t);
|
|
3070
3070
|
}
|
|
3071
3071
|
/**
|
|
3072
3072
|
* ページレスポンスから表示用サマリーを作ります。
|
|
@@ -3118,7 +3118,7 @@ class Q {
|
|
|
3118
3118
|
* @returns 重複排除後の新しい配列。非配列は空配列
|
|
3119
3119
|
*/
|
|
3120
3120
|
static distinct(e, t) {
|
|
3121
|
-
return
|
|
3121
|
+
return Pe(e, t);
|
|
3122
3122
|
}
|
|
3123
3123
|
/**
|
|
3124
3124
|
* 配列を `item[key]` ごとのグループへ分けて返します。
|
|
@@ -3139,9 +3139,9 @@ function Ae() {
|
|
|
3139
3139
|
const e = globalThis.window?.Haori;
|
|
3140
3140
|
return Ke.every(
|
|
3141
3141
|
(r) => typeof e?.[r] == "function"
|
|
3142
|
-
) ? e :
|
|
3142
|
+
) ? e : Z;
|
|
3143
3143
|
}
|
|
3144
|
-
class
|
|
3144
|
+
class A {
|
|
3145
3145
|
/**
|
|
3146
3146
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
3147
3147
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -3152,7 +3152,7 @@ class E {
|
|
|
3152
3152
|
*/
|
|
3153
3153
|
static getValues(e) {
|
|
3154
3154
|
const t = {};
|
|
3155
|
-
return
|
|
3155
|
+
return A.getPartValues(e, t);
|
|
3156
3156
|
}
|
|
3157
3157
|
/**
|
|
3158
3158
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -3163,26 +3163,28 @@ class E {
|
|
|
3163
3163
|
* @returns values と同じオブジェクト
|
|
3164
3164
|
*/
|
|
3165
3165
|
static getPartValues(e, t) {
|
|
3166
|
+
if (e.getTarget().hasAttribute(`${c.prefix}if-false`))
|
|
3167
|
+
return t;
|
|
3166
3168
|
const r = e.getAttribute("name"), i = e.getAttribute(`${c.prefix}form-object`), n = e.getAttribute(`${c.prefix}form-list`);
|
|
3167
3169
|
if (r) {
|
|
3168
3170
|
if (n)
|
|
3169
3171
|
Array.isArray(t[String(r)]) ? t[String(r)].push(e.getValue()) : t[String(r)] = [e.getValue()];
|
|
3170
|
-
else if (
|
|
3171
|
-
const s = e.getValue(),
|
|
3172
|
-
|
|
3172
|
+
else if (A.isGroupedCheckable(e)) {
|
|
3173
|
+
const s = e.getTarget(), o = (s instanceof HTMLInputElement ? s.checked : !0) ? e.getValue() : null, l = String(r);
|
|
3174
|
+
o === null ? l in t || (t[l] = null) : t[l] === null || t[l] === void 0 ? t[l] = o : Array.isArray(t[l]) ? t[l].push(o) : t[l] = [t[l], o];
|
|
3173
3175
|
} else
|
|
3174
3176
|
t[String(r)] = e.getValue();
|
|
3175
|
-
i &&
|
|
3177
|
+
i && b.warn(
|
|
3176
3178
|
"Haori",
|
|
3177
3179
|
`Element cannot have both ${c.prefix}form-object and name attributes.`
|
|
3178
3180
|
);
|
|
3179
3181
|
for (const s of e.getChildElementFragments())
|
|
3180
|
-
|
|
3182
|
+
A.getPartValues(s, t);
|
|
3181
3183
|
} else if (i) {
|
|
3182
3184
|
const s = {};
|
|
3183
3185
|
for (const a of e.getChildElementFragments())
|
|
3184
|
-
|
|
3185
|
-
Object.keys(s).length > 0 && (t[String(i)] = s), n &&
|
|
3186
|
+
A.getPartValues(a, s);
|
|
3187
|
+
Object.keys(s).length > 0 && (t[String(i)] = s), n && b.warn(
|
|
3186
3188
|
"Haori",
|
|
3187
3189
|
`Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
|
|
3188
3190
|
);
|
|
@@ -3190,12 +3192,12 @@ class E {
|
|
|
3190
3192
|
const s = [];
|
|
3191
3193
|
for (const a of e.getChildElementFragments()) {
|
|
3192
3194
|
const o = {};
|
|
3193
|
-
|
|
3195
|
+
A.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
|
|
3194
3196
|
}
|
|
3195
3197
|
s.length > 0 && (t[String(n)] = s);
|
|
3196
3198
|
} else
|
|
3197
3199
|
for (const s of e.getChildElementFragments())
|
|
3198
|
-
|
|
3200
|
+
A.getPartValues(s, t);
|
|
3199
3201
|
return t;
|
|
3200
3202
|
}
|
|
3201
3203
|
/**
|
|
@@ -3208,7 +3210,7 @@ class E {
|
|
|
3208
3210
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
3209
3211
|
*/
|
|
3210
3212
|
static setValues(e, t, r = !1) {
|
|
3211
|
-
return
|
|
3213
|
+
return A.setPartValues(e, t, null, r, !0);
|
|
3212
3214
|
}
|
|
3213
3215
|
/**
|
|
3214
3216
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -3220,7 +3222,7 @@ class E {
|
|
|
3220
3222
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
3221
3223
|
*/
|
|
3222
3224
|
static syncValues(e, t, r = !1) {
|
|
3223
|
-
return
|
|
3225
|
+
return A.setPartValues(e, t, null, r, !1);
|
|
3224
3226
|
}
|
|
3225
3227
|
/**
|
|
3226
3228
|
* 値による上書きをグループ単位で扱うべき入力要素(boolean 型でない
|
|
@@ -3269,24 +3271,24 @@ class E {
|
|
|
3269
3271
|
if (!h || i) {
|
|
3270
3272
|
const u = t[String(a)];
|
|
3271
3273
|
l && Array.isArray(u) && r !== null ? s.push(
|
|
3272
|
-
|
|
3273
|
-
) : typeof u > "u" || (Array.isArray(u) &&
|
|
3274
|
-
|
|
3274
|
+
A.applyFragmentValue(e, u[r] ?? null, n)
|
|
3275
|
+
) : typeof u > "u" || (Array.isArray(u) && A.isGroupedCheckable(e) || Array.isArray(u) && A.isMultipleSelect(e) || typeof u == "string" || typeof u == "number" || typeof u == "boolean" || u === null ? s.push(
|
|
3276
|
+
A.applyFragmentValue(
|
|
3275
3277
|
e,
|
|
3276
3278
|
u,
|
|
3277
3279
|
n
|
|
3278
3280
|
)
|
|
3279
3281
|
) : s.push(
|
|
3280
|
-
|
|
3282
|
+
A.applyFragmentValue(e, String(u), n)
|
|
3281
3283
|
));
|
|
3282
3284
|
}
|
|
3283
3285
|
} else if (o) {
|
|
3284
3286
|
const u = t[String(o)];
|
|
3285
3287
|
if (u && typeof u == "object")
|
|
3286
|
-
for (const
|
|
3288
|
+
for (const m of e.getChildElementFragments())
|
|
3287
3289
|
s.push(
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
+
A.setPartValues(
|
|
3291
|
+
m,
|
|
3290
3292
|
u,
|
|
3291
3293
|
null,
|
|
3292
3294
|
i,
|
|
@@ -3296,24 +3298,24 @@ class E {
|
|
|
3296
3298
|
} else if (l) {
|
|
3297
3299
|
const u = t[String(l)];
|
|
3298
3300
|
if (Array.isArray(u)) {
|
|
3299
|
-
const
|
|
3300
|
-
for (let v = 0; v <
|
|
3301
|
-
const
|
|
3301
|
+
const m = e.getChildElementFragments();
|
|
3302
|
+
for (let v = 0; v < m.length; v++) {
|
|
3303
|
+
const T = m[v];
|
|
3302
3304
|
u.length > v ? s.push(
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
+
A.setPartValues(
|
|
3306
|
+
T,
|
|
3305
3307
|
u[v],
|
|
3306
3308
|
v,
|
|
3307
3309
|
i,
|
|
3308
3310
|
n
|
|
3309
3311
|
)
|
|
3310
|
-
) : s.push(
|
|
3312
|
+
) : s.push(A.setPartValues(T, {}, v, i, n));
|
|
3311
3313
|
}
|
|
3312
3314
|
}
|
|
3313
3315
|
} else
|
|
3314
3316
|
for (const u of e.getChildElementFragments())
|
|
3315
3317
|
s.push(
|
|
3316
|
-
|
|
3318
|
+
A.setPartValues(u, t, null, i, n)
|
|
3317
3319
|
);
|
|
3318
3320
|
return Promise.all(s).then(() => {
|
|
3319
3321
|
});
|
|
@@ -3326,10 +3328,10 @@ class E {
|
|
|
3326
3328
|
* @returns すべての初期化処理が完了するPromise
|
|
3327
3329
|
*/
|
|
3328
3330
|
static async reset(e) {
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
]), await
|
|
3331
|
+
A.clearValues(e), await Promise.all([
|
|
3332
|
+
A.clearMessages(e),
|
|
3333
|
+
A.clearEachClones(e)
|
|
3334
|
+
]), await I.enqueue(() => {
|
|
3333
3335
|
const r = e.getTarget();
|
|
3334
3336
|
if (r instanceof HTMLFormElement)
|
|
3335
3337
|
r.reset();
|
|
@@ -3342,20 +3344,20 @@ class E {
|
|
|
3342
3344
|
}
|
|
3343
3345
|
}
|
|
3344
3346
|
});
|
|
3345
|
-
const t =
|
|
3347
|
+
const t = A.collectBindingTargetForms(e);
|
|
3346
3348
|
for (const r of t) {
|
|
3347
|
-
const i =
|
|
3348
|
-
i && await
|
|
3349
|
+
const i = A.getInitialBindingData(r);
|
|
3350
|
+
i && await k.setBindingData(r.getTarget(), i);
|
|
3349
3351
|
}
|
|
3350
|
-
|
|
3352
|
+
A.syncValuesFromDom(e);
|
|
3351
3353
|
for (const r of t) {
|
|
3352
|
-
const i =
|
|
3354
|
+
const i = A.getInitialBindingData(r);
|
|
3353
3355
|
if (r.getRawBindingData() === null && i === null)
|
|
3354
3356
|
continue;
|
|
3355
|
-
const n =
|
|
3356
|
-
s ? a[String(s)] = n : Object.assign(a, n), await
|
|
3357
|
+
const n = A.getValues(r), s = r.getAttribute(`${c.prefix}form-arg`), a = { ...i || {} };
|
|
3358
|
+
s ? a[String(s)] = n : Object.assign(a, n), await k.setBindingData(r.getTarget(), a);
|
|
3357
3359
|
}
|
|
3358
|
-
await
|
|
3360
|
+
await k.evaluateAll(e);
|
|
3359
3361
|
}
|
|
3360
3362
|
/**
|
|
3361
3363
|
* data-bind 属性で宣言された初期バインドデータを取得します。
|
|
@@ -3365,7 +3367,7 @@ class E {
|
|
|
3365
3367
|
*/
|
|
3366
3368
|
static getInitialBindingData(e) {
|
|
3367
3369
|
const t = e.getInitialBindAttribute();
|
|
3368
|
-
return t === null ? null :
|
|
3370
|
+
return t === null ? null : k.parseDataBind(t);
|
|
3369
3371
|
}
|
|
3370
3372
|
/**
|
|
3371
3373
|
* フラグメント配下の入力要素について、内部値を現在の DOM 値と再同期します。
|
|
@@ -3376,7 +3378,7 @@ class E {
|
|
|
3376
3378
|
const t = e.getTarget();
|
|
3377
3379
|
(t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement) && e.syncValue();
|
|
3378
3380
|
for (const r of e.getChildElementFragments())
|
|
3379
|
-
|
|
3381
|
+
A.syncValuesFromDom(r);
|
|
3380
3382
|
}
|
|
3381
3383
|
/**
|
|
3382
3384
|
* リセット後にバインドデータを更新すべきフォームフラグメントを収集します。
|
|
@@ -3392,7 +3394,7 @@ class E {
|
|
|
3392
3394
|
t instanceof HTMLFormElement ? r.push(t) : r.push(...Array.from(t.querySelectorAll("form")));
|
|
3393
3395
|
const i = [];
|
|
3394
3396
|
for (const n of r) {
|
|
3395
|
-
const s =
|
|
3397
|
+
const s = S.get(n);
|
|
3396
3398
|
s instanceof M && i.push(s);
|
|
3397
3399
|
}
|
|
3398
3400
|
return i;
|
|
@@ -3429,7 +3431,7 @@ class E {
|
|
|
3429
3431
|
static clearValues(e) {
|
|
3430
3432
|
e.clearValue();
|
|
3431
3433
|
for (const t of e.getChildElementFragments())
|
|
3432
|
-
|
|
3434
|
+
A.clearValues(t);
|
|
3433
3435
|
}
|
|
3434
3436
|
/**
|
|
3435
3437
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -3452,7 +3454,7 @@ class E {
|
|
|
3452
3454
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
3453
3455
|
*/
|
|
3454
3456
|
static addErrorMessage(e, t, r) {
|
|
3455
|
-
return
|
|
3457
|
+
return A.addMessage(e, t, r, "error");
|
|
3456
3458
|
}
|
|
3457
3459
|
/**
|
|
3458
3460
|
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
@@ -3465,7 +3467,7 @@ class E {
|
|
|
3465
3467
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
3466
3468
|
*/
|
|
3467
3469
|
static addMessage(e, t, r, i) {
|
|
3468
|
-
const n = [], s = Ae(), a = s.addMessage, o = (h) => typeof a == "function" ? a.call(s, h, r, i) : s.addErrorMessage(h, r), l =
|
|
3470
|
+
const n = [], s = Ae(), a = s.addMessage, o = (h) => typeof a == "function" ? a.call(s, h, r, i) : s.addErrorMessage(h, r), l = A.findFragmentsByKey(e, t);
|
|
3469
3471
|
return l.forEach((h) => {
|
|
3470
3472
|
n.push(o(h.getTarget()));
|
|
3471
3473
|
}), l.length === 0 && n.push(o(e.getTarget())), Promise.all(n).then(() => {
|
|
@@ -3479,7 +3481,7 @@ class E {
|
|
|
3479
3481
|
* @returns 一致するフラグメントの配列
|
|
3480
3482
|
*/
|
|
3481
3483
|
static findFragmentsByKey(e, t) {
|
|
3482
|
-
return
|
|
3484
|
+
return A.findFragmentByKeyParts(e, t.split("."));
|
|
3483
3485
|
}
|
|
3484
3486
|
/**
|
|
3485
3487
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -3493,7 +3495,7 @@ class E {
|
|
|
3493
3495
|
const r = [], i = t[0];
|
|
3494
3496
|
if (t.length == 1 && e.getAttribute("name") === i && r.push(e), e.hasAttribute(`${c.prefix}form-object`))
|
|
3495
3497
|
t.length > 1 && e.getAttribute(`${c.prefix}form-object`) === i && e.getChildElementFragments().forEach((s) => {
|
|
3496
|
-
r.push(...
|
|
3498
|
+
r.push(...A.findFragmentByKeyParts(s, t.slice(1)));
|
|
3497
3499
|
});
|
|
3498
3500
|
else if (e.hasAttribute(`${c.prefix}form-list`)) {
|
|
3499
3501
|
if (t.length > 1) {
|
|
@@ -3503,11 +3505,11 @@ class E {
|
|
|
3503
3505
|
if (n === o) {
|
|
3504
3506
|
const l = i.substring(s + 1, a), h = Number(l);
|
|
3505
3507
|
if (isNaN(h))
|
|
3506
|
-
|
|
3508
|
+
b.error("Haori", `Invalid index: ${i}`);
|
|
3507
3509
|
else {
|
|
3508
|
-
const u = e.getChildElementFragments().filter((
|
|
3510
|
+
const u = e.getChildElementFragments().filter((m) => m.hasAttribute(`${c.prefix}row`));
|
|
3509
3511
|
h < u.length && r.push(
|
|
3510
|
-
...
|
|
3512
|
+
...A.findFragmentByKeyParts(u[h], t.slice(1))
|
|
3511
3513
|
);
|
|
3512
3514
|
}
|
|
3513
3515
|
}
|
|
@@ -3515,7 +3517,7 @@ class E {
|
|
|
3515
3517
|
}
|
|
3516
3518
|
} else
|
|
3517
3519
|
e.getChildElementFragments().forEach((n) => {
|
|
3518
|
-
r.push(...
|
|
3520
|
+
r.push(...A.findFragmentByKeyParts(n, t));
|
|
3519
3521
|
});
|
|
3520
3522
|
return r;
|
|
3521
3523
|
}
|
|
@@ -3759,7 +3761,7 @@ const ze = {
|
|
|
3759
3761
|
function Ge(f, e) {
|
|
3760
3762
|
return f.replace(/\{\{([\s\S]+?)\}\}/g, (t, r) => {
|
|
3761
3763
|
try {
|
|
3762
|
-
const i =
|
|
3764
|
+
const i = G.evaluate(String(r).trim(), e);
|
|
3763
3765
|
return i == null ? "" : String(i);
|
|
3764
3766
|
} catch {
|
|
3765
3767
|
return "";
|
|
@@ -3772,7 +3774,7 @@ function Ye(f, e) {
|
|
|
3772
3774
|
return null;
|
|
3773
3775
|
if (!t.includes("{{"))
|
|
3774
3776
|
return t;
|
|
3775
|
-
const r =
|
|
3777
|
+
const r = S.get(f), i = r instanceof M ? r.getBindingData() : {}, n = Ge(t, i);
|
|
3776
3778
|
return n === "" ? null : n;
|
|
3777
3779
|
}
|
|
3778
3780
|
function Je(f, e, t) {
|
|
@@ -3859,7 +3861,7 @@ function ie() {
|
|
|
3859
3861
|
const e = globalThis.window?.Haori;
|
|
3860
3862
|
return Xe.every(
|
|
3861
3863
|
(r) => typeof e?.[r] == "function"
|
|
3862
|
-
) ? e :
|
|
3864
|
+
) ? e : Z;
|
|
3863
3865
|
}
|
|
3864
3866
|
const Ze = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
3865
3867
|
function _e(f) {
|
|
@@ -3942,7 +3944,7 @@ const g = class g {
|
|
|
3942
3944
|
return { value: e.replace(
|
|
3943
3945
|
g.DATA_PLACEHOLDER_REGEX,
|
|
3944
3946
|
(n, s, a) => {
|
|
3945
|
-
const o =
|
|
3947
|
+
const o = G.evaluateDetailed(
|
|
3946
3948
|
s ?? a ?? "",
|
|
3947
3949
|
t
|
|
3948
3950
|
);
|
|
@@ -4022,7 +4024,7 @@ const g = class g {
|
|
|
4022
4024
|
return { value: e.replace(
|
|
4023
4025
|
g.DATA_PLACEHOLDER_REGEX,
|
|
4024
4026
|
(n, s, a, o) => {
|
|
4025
|
-
const l =
|
|
4027
|
+
const l = G.evaluateDetailed(
|
|
4026
4028
|
s ?? a ?? "",
|
|
4027
4029
|
t
|
|
4028
4030
|
);
|
|
@@ -4059,7 +4061,7 @@ const g = class g {
|
|
|
4059
4061
|
const a = r.trim();
|
|
4060
4062
|
if (g.SINGLE_PLACEHOLDER_REGEX.test(a))
|
|
4061
4063
|
return {
|
|
4062
|
-
value:
|
|
4064
|
+
value: k.parseDataBind(n),
|
|
4063
4065
|
hasUnresolvedReference: s
|
|
4064
4066
|
};
|
|
4065
4067
|
if (a.startsWith("{") || a.startsWith("[")) {
|
|
@@ -4068,7 +4070,7 @@ const g = class g {
|
|
|
4068
4070
|
e.getBindingData()
|
|
4069
4071
|
);
|
|
4070
4072
|
return {
|
|
4071
|
-
value:
|
|
4073
|
+
value: k.parseDataBind(l.value),
|
|
4072
4074
|
hasUnresolvedReference: s || l.hasUnresolvedReference
|
|
4073
4075
|
};
|
|
4074
4076
|
}
|
|
@@ -4077,7 +4079,7 @@ const g = class g {
|
|
|
4077
4079
|
e.getBindingData()
|
|
4078
4080
|
);
|
|
4079
4081
|
return {
|
|
4080
|
-
value:
|
|
4082
|
+
value: k.parseDataBind(o.value),
|
|
4081
4083
|
hasUnresolvedReference: s || o.hasUnresolvedReference
|
|
4082
4084
|
};
|
|
4083
4085
|
}
|
|
@@ -4095,22 +4097,22 @@ const g = class g {
|
|
|
4095
4097
|
if (t) {
|
|
4096
4098
|
if (e.hasAttribute(g.attrName(t, "validate")) && (r.valid = !0), e.hasAttribute(g.attrName(t, "confirm")) && (r.confirmMessage = e.getAttribute(g.attrName(t, "confirm")).replace(/\\n/g, `
|
|
4097
4099
|
`)), e.hasAttribute(g.attrName(t, "data")) && (r.dataAttrName = g.attrName(t, "data")), e.hasAttribute(g.attrName(t, "form"))) {
|
|
4098
|
-
const
|
|
4100
|
+
const p = e.getRawAttribute(
|
|
4099
4101
|
g.attrName(t, "form")
|
|
4100
4102
|
);
|
|
4101
|
-
if (
|
|
4102
|
-
const
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
) :
|
|
4103
|
+
if (p) {
|
|
4104
|
+
const y = document.body.querySelector(p);
|
|
4105
|
+
y !== null ? r.formFragment = A.getFormFragment(
|
|
4106
|
+
S.get(y)
|
|
4107
|
+
) : b.error(
|
|
4106
4108
|
"Haori",
|
|
4107
|
-
`Form element not found: ${
|
|
4109
|
+
`Form element not found: ${p} (${g.attrName(t, "form")})`
|
|
4108
4110
|
);
|
|
4109
4111
|
} else
|
|
4110
|
-
r.formFragment =
|
|
4111
|
-
} else (t === "change" || t === "input") && (r.formFragment =
|
|
4112
|
+
r.formFragment = A.getFormFragment(e);
|
|
4113
|
+
} else (t === "change" || t === "input") && (r.formFragment = A.getFormFragment(e));
|
|
4112
4114
|
if (e.hasAttribute(`${c.prefix}${t}-before-run`)) {
|
|
4113
|
-
const
|
|
4115
|
+
const p = e.getRawAttribute(
|
|
4114
4116
|
`${c.prefix}${t}-before-run`
|
|
4115
4117
|
);
|
|
4116
4118
|
try {
|
|
@@ -4119,100 +4121,100 @@ const g = class g {
|
|
|
4119
4121
|
"fetchOptions",
|
|
4120
4122
|
`
|
|
4121
4123
|
"use strict";
|
|
4122
|
-
${
|
|
4124
|
+
${p}
|
|
4123
4125
|
`
|
|
4124
4126
|
);
|
|
4125
|
-
} catch (
|
|
4126
|
-
|
|
4127
|
+
} catch (y) {
|
|
4128
|
+
b.error("Haori", `Invalid before script: ${y}`);
|
|
4127
4129
|
}
|
|
4128
4130
|
}
|
|
4129
|
-
const
|
|
4130
|
-
if (e.hasAttribute(
|
|
4131
|
-
const
|
|
4132
|
-
let
|
|
4131
|
+
const E = g.attrName(t, "run");
|
|
4132
|
+
if (e.hasAttribute(E)) {
|
|
4133
|
+
const p = String(e.getAttribute(E) ?? "");
|
|
4134
|
+
let y = null;
|
|
4133
4135
|
try {
|
|
4134
|
-
|
|
4136
|
+
y = new Function(
|
|
4135
4137
|
"event",
|
|
4136
4138
|
`"use strict"; return (
|
|
4137
|
-
${
|
|
4139
|
+
${p}
|
|
4138
4140
|
);`
|
|
4139
4141
|
);
|
|
4140
4142
|
} catch {
|
|
4141
4143
|
try {
|
|
4142
|
-
|
|
4144
|
+
y = new Function(
|
|
4143
4145
|
"event",
|
|
4144
4146
|
`"use strict";
|
|
4145
|
-
${
|
|
4147
|
+
${p}
|
|
4146
4148
|
`
|
|
4147
4149
|
);
|
|
4148
|
-
} catch (
|
|
4149
|
-
|
|
4150
|
+
} catch (R) {
|
|
4151
|
+
b.error("Haori", `Invalid run script: ${R}`);
|
|
4150
4152
|
}
|
|
4151
4153
|
}
|
|
4152
|
-
|
|
4154
|
+
y && (r.runScript = y);
|
|
4153
4155
|
}
|
|
4154
4156
|
}
|
|
4155
4157
|
const i = g.attrName(t, "fetch"), n = e.hasAttribute(i);
|
|
4156
4158
|
if (n) {
|
|
4157
|
-
const
|
|
4158
|
-
|
|
4159
|
+
const E = e.getAttributeEvaluation(i);
|
|
4160
|
+
E && (r.fetchHasUnresolvedReference = E.hasUnresolvedReference, r.fetchUrl = E.hasUnresolvedReference ? null : E.value);
|
|
4159
4161
|
}
|
|
4160
4162
|
const s = {};
|
|
4161
4163
|
if (t) {
|
|
4162
|
-
const
|
|
4163
|
-
if (e.hasAttribute(
|
|
4164
|
-
const
|
|
4165
|
-
|
|
4164
|
+
const E = g.attrName(t, "fetch-method");
|
|
4165
|
+
if (e.hasAttribute(E)) {
|
|
4166
|
+
const p = e.getAttributeEvaluation(E);
|
|
4167
|
+
p?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = p?.value;
|
|
4166
4168
|
}
|
|
4167
4169
|
} else {
|
|
4168
|
-
const
|
|
4169
|
-
if (e.hasAttribute(
|
|
4170
|
-
const
|
|
4171
|
-
|
|
4170
|
+
const E = g.attrName(null, "method", !0);
|
|
4171
|
+
if (e.hasAttribute(E)) {
|
|
4172
|
+
const p = e.getAttributeEvaluation(
|
|
4173
|
+
E
|
|
4172
4174
|
);
|
|
4173
|
-
|
|
4175
|
+
p?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : s.method = p?.value;
|
|
4174
4176
|
}
|
|
4175
4177
|
}
|
|
4176
4178
|
if (t) {
|
|
4177
|
-
const
|
|
4178
|
-
if (e.hasAttribute(
|
|
4179
|
-
const
|
|
4180
|
-
|
|
4179
|
+
const E = g.attrName(t, "fetch-headers");
|
|
4180
|
+
if (e.hasAttribute(E)) {
|
|
4181
|
+
const p = e.getRawAttribute(
|
|
4182
|
+
E
|
|
4181
4183
|
);
|
|
4182
4184
|
try {
|
|
4183
|
-
s.headers =
|
|
4184
|
-
} catch (
|
|
4185
|
-
|
|
4185
|
+
s.headers = k.parseDataBind(p);
|
|
4186
|
+
} catch (y) {
|
|
4187
|
+
b.error("Haori", `Invalid fetch headers: ${y}`);
|
|
4186
4188
|
}
|
|
4187
4189
|
}
|
|
4188
4190
|
} else {
|
|
4189
|
-
const
|
|
4191
|
+
const E = g.attrName(
|
|
4190
4192
|
null,
|
|
4191
4193
|
"headers",
|
|
4192
4194
|
!0
|
|
4193
4195
|
);
|
|
4194
|
-
if (e.hasAttribute(
|
|
4195
|
-
const
|
|
4196
|
-
|
|
4196
|
+
if (e.hasAttribute(E)) {
|
|
4197
|
+
const p = e.getRawAttribute(
|
|
4198
|
+
E
|
|
4197
4199
|
);
|
|
4198
4200
|
try {
|
|
4199
|
-
s.headers =
|
|
4200
|
-
} catch (
|
|
4201
|
-
|
|
4201
|
+
s.headers = k.parseDataBind(p);
|
|
4202
|
+
} catch (y) {
|
|
4203
|
+
b.error("Haori", `Invalid fetch headers: ${y}`);
|
|
4202
4204
|
}
|
|
4203
4205
|
}
|
|
4204
4206
|
}
|
|
4205
4207
|
if (t) {
|
|
4206
|
-
const
|
|
4207
|
-
if (e.hasAttribute(
|
|
4208
|
-
const
|
|
4209
|
-
|
|
4208
|
+
const E = g.attrName(t, "fetch-content-type");
|
|
4209
|
+
if (e.hasAttribute(E)) {
|
|
4210
|
+
const p = e.getAttributeEvaluation(E);
|
|
4211
|
+
p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
|
|
4210
4212
|
...s.headers,
|
|
4211
|
-
"Content-Type":
|
|
4213
|
+
"Content-Type": p?.value
|
|
4212
4214
|
};
|
|
4213
4215
|
} else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
4214
|
-
let
|
|
4215
|
-
s.headers && typeof s.headers == "object" && (
|
|
4216
|
+
let p = !1;
|
|
4217
|
+
s.headers && typeof s.headers == "object" && (p = "Content-Type" in s.headers), p || (s.headers = {
|
|
4216
4218
|
...s.headers,
|
|
4217
4219
|
"Content-Type": "application/json"
|
|
4218
4220
|
});
|
|
@@ -4221,20 +4223,20 @@ ${y}
|
|
|
4221
4223
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
4222
4224
|
});
|
|
4223
4225
|
} else {
|
|
4224
|
-
const
|
|
4226
|
+
const E = g.attrName(
|
|
4225
4227
|
null,
|
|
4226
4228
|
"content-type",
|
|
4227
4229
|
!0
|
|
4228
4230
|
);
|
|
4229
|
-
if (e.hasAttribute(
|
|
4230
|
-
const
|
|
4231
|
-
|
|
4231
|
+
if (e.hasAttribute(E)) {
|
|
4232
|
+
const p = e.getAttributeEvaluation(E);
|
|
4233
|
+
p?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), s.headers = {
|
|
4232
4234
|
...s.headers,
|
|
4233
|
-
"Content-Type":
|
|
4235
|
+
"Content-Type": p?.value
|
|
4234
4236
|
};
|
|
4235
4237
|
} else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
4236
|
-
let
|
|
4237
|
-
s.headers && typeof s.headers == "object" && (
|
|
4238
|
+
let p = !1;
|
|
4239
|
+
s.headers && typeof s.headers == "object" && (p = "Content-Type" in s.headers), p || (s.headers = {
|
|
4238
4240
|
...s.headers,
|
|
4239
4241
|
"Content-Type": "application/json"
|
|
4240
4242
|
});
|
|
@@ -4246,15 +4248,15 @@ ${y}
|
|
|
4246
4248
|
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
4247
4249
|
const a = t ? g.attrName(t, "bind") : g.attrName(null, "bind", !0);
|
|
4248
4250
|
if (e.hasAttribute(a)) {
|
|
4249
|
-
const
|
|
4250
|
-
if (
|
|
4251
|
-
const
|
|
4252
|
-
|
|
4253
|
-
const
|
|
4254
|
-
|
|
4255
|
-
})) :
|
|
4251
|
+
const E = e.getRawAttribute(a);
|
|
4252
|
+
if (E) {
|
|
4253
|
+
const p = document.body.querySelectorAll(E);
|
|
4254
|
+
p.length > 0 ? (r.bindFragments = [], p.forEach((y) => {
|
|
4255
|
+
const R = S.get(y);
|
|
4256
|
+
R && r.bindFragments.push(R);
|
|
4257
|
+
})) : b.error(
|
|
4256
4258
|
"Haori",
|
|
4257
|
-
`Bind element not found: ${
|
|
4259
|
+
`Bind element not found: ${E} (${a})`
|
|
4258
4260
|
);
|
|
4259
4261
|
}
|
|
4260
4262
|
}
|
|
@@ -4272,47 +4274,47 @@ ${y}
|
|
|
4272
4274
|
) : e.hasAttribute(h) && (r.bindArg = e.getRawAttribute(h));
|
|
4273
4275
|
const u = t ? g.attrName(t, "bind-params") : g.attrName(null, "bind-params", !0);
|
|
4274
4276
|
if (e.hasAttribute(u)) {
|
|
4275
|
-
const
|
|
4276
|
-
r.bindParams =
|
|
4277
|
+
const E = e.getRawAttribute(u);
|
|
4278
|
+
r.bindParams = E.split("&").map((p) => p.trim());
|
|
4277
4279
|
}
|
|
4278
|
-
const
|
|
4279
|
-
if (e.hasAttribute(
|
|
4280
|
-
const
|
|
4281
|
-
r.bindAppendParams =
|
|
4280
|
+
const m = t ? g.attrName(t, "bind-append") : g.attrName(null, "bind-append", !0);
|
|
4281
|
+
if (e.hasAttribute(m)) {
|
|
4282
|
+
const E = e.getRawAttribute(m);
|
|
4283
|
+
r.bindAppendParams = E.split("&").map((p) => p.trim()).filter(Boolean);
|
|
4282
4284
|
}
|
|
4283
4285
|
const v = t ? g.attrName(t, "bind-merge") : g.attrName(null, "bind-merge", !0);
|
|
4284
4286
|
e.hasAttribute(v) && (r.bindMerge = !0);
|
|
4285
|
-
const
|
|
4286
|
-
e.hasAttribute(
|
|
4287
|
-
const
|
|
4288
|
-
if (
|
|
4289
|
-
const
|
|
4290
|
-
r.copyParams =
|
|
4287
|
+
const T = t ? g.attrName(t, "bind-transform") : g.attrName(null, "bind-transform", !0);
|
|
4288
|
+
e.hasAttribute(T) && (r.bindTransform = e.getRawAttribute(T));
|
|
4289
|
+
const C = t ? g.attrName(t, "copy-params") : null;
|
|
4290
|
+
if (C && e.hasAttribute(C)) {
|
|
4291
|
+
const E = e.getRawAttribute(C);
|
|
4292
|
+
r.copyParams = E.split("&").map((p) => p.trim()).filter(Boolean);
|
|
4291
4293
|
}
|
|
4292
4294
|
if (t) {
|
|
4293
4295
|
if (e.hasAttribute(g.attrName(t, "adjust"))) {
|
|
4294
|
-
const
|
|
4296
|
+
const y = e.getRawAttribute(
|
|
4295
4297
|
g.attrName(t, "adjust")
|
|
4296
4298
|
);
|
|
4297
|
-
if (
|
|
4298
|
-
const
|
|
4299
|
-
|
|
4300
|
-
const
|
|
4301
|
-
|
|
4302
|
-
})) :
|
|
4299
|
+
if (y) {
|
|
4300
|
+
const R = document.body.querySelectorAll(y);
|
|
4301
|
+
R.length > 0 ? (r.adjustFragments = [], R.forEach((P) => {
|
|
4302
|
+
const F = S.get(P);
|
|
4303
|
+
F && r.adjustFragments.push(F);
|
|
4304
|
+
})) : b.error(
|
|
4303
4305
|
"Haori",
|
|
4304
|
-
`Adjust element not found: ${
|
|
4306
|
+
`Adjust element not found: ${y} (${g.attrName(t, "adjust")})`
|
|
4305
4307
|
);
|
|
4306
4308
|
}
|
|
4307
4309
|
if (e.hasAttribute(g.attrName(t, "adjust-value"))) {
|
|
4308
|
-
const
|
|
4310
|
+
const R = e.getRawAttribute(
|
|
4309
4311
|
g.attrName(t, "adjust-value")
|
|
4310
|
-
), P = Number(
|
|
4312
|
+
), P = Number(R);
|
|
4311
4313
|
isNaN(P) || (r.adjustValue = P);
|
|
4312
4314
|
}
|
|
4313
4315
|
}
|
|
4314
4316
|
if (e.hasAttribute(g.attrName(t, "row-add")) && (r.rowAdd = !0), e.hasAttribute(g.attrName(t, "row-remove")) && (r.rowRemove = !0), e.hasAttribute(g.attrName(t, "row-prev")) && (r.rowMovePrev = !0), e.hasAttribute(g.attrName(t, "row-next")) && (r.rowMoveNext = !0), e.hasAttribute(`${c.prefix}${t}-after-run`)) {
|
|
4315
|
-
const
|
|
4317
|
+
const y = e.getRawAttribute(
|
|
4316
4318
|
`${c.prefix}${t}-after-run`
|
|
4317
4319
|
);
|
|
4318
4320
|
try {
|
|
@@ -4320,11 +4322,11 @@ ${y}
|
|
|
4320
4322
|
"response",
|
|
4321
4323
|
`
|
|
4322
4324
|
"use strict";
|
|
4323
|
-
${
|
|
4325
|
+
${y}
|
|
4324
4326
|
`
|
|
4325
4327
|
);
|
|
4326
|
-
} catch (
|
|
4327
|
-
|
|
4328
|
+
} catch (R) {
|
|
4329
|
+
b.error("Haori", `Invalid after script: ${R}`);
|
|
4328
4330
|
}
|
|
4329
4331
|
}
|
|
4330
4332
|
if (e.hasAttribute(g.attrName(t, "dialog")) && (r.dialogMessage = e.getAttribute(g.attrName(t, "dialog")).replace(/\\n/g, `
|
|
@@ -4332,21 +4334,21 @@ ${b}
|
|
|
4332
4334
|
r.toastMessage = e.getAttribute(
|
|
4333
4335
|
g.attrName(t, "toast")
|
|
4334
4336
|
);
|
|
4335
|
-
const
|
|
4337
|
+
const y = e.getRawAttribute(
|
|
4336
4338
|
g.attrName(t, "toast-level")
|
|
4337
|
-
), P = ["info", "warning", "error", "success"].includes(
|
|
4338
|
-
r.toastLevel = P ?
|
|
4339
|
+
), P = ["info", "warning", "error", "success"].includes(y);
|
|
4340
|
+
r.toastLevel = P ? y : null;
|
|
4339
4341
|
}
|
|
4340
4342
|
if (e.hasAttribute(g.attrName(t, "redirect"))) {
|
|
4341
4343
|
r.redirectUrl = e.getAttribute(
|
|
4342
4344
|
g.attrName(t, "redirect")
|
|
4343
4345
|
);
|
|
4344
|
-
const
|
|
4346
|
+
const y = g.attrName(
|
|
4345
4347
|
t,
|
|
4346
4348
|
"redirect-return-param"
|
|
4347
4349
|
);
|
|
4348
|
-
e.hasAttribute(
|
|
4349
|
-
|
|
4350
|
+
e.hasAttribute(y) && (r.redirectReturnParam = e.getAttribute(
|
|
4351
|
+
y
|
|
4350
4352
|
));
|
|
4351
4353
|
}
|
|
4352
4354
|
if (e.hasAttribute(g.attrName(t, "scroll-error")) && (r.scrollOnError = !0), e.hasAttribute(g.attrName(t, "scroll")) && (r.scrollTarget = e.getAttribute(
|
|
@@ -4354,19 +4356,19 @@ ${b}
|
|
|
4354
4356
|
)), e.hasAttribute(g.attrName(t, "history")) && (r.historyUrl = e.getAttribute(
|
|
4355
4357
|
g.attrName(t, "history")
|
|
4356
4358
|
)), e.hasAttribute(g.attrName(t, "history-data")) && (r.historyDataAttrName = g.attrName(t, "history-data")), e.hasAttribute(g.attrName(t, "history-form"))) {
|
|
4357
|
-
const
|
|
4359
|
+
const y = e.getRawAttribute(
|
|
4358
4360
|
g.attrName(t, "history-form")
|
|
4359
4361
|
);
|
|
4360
|
-
if (
|
|
4361
|
-
const
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
) :
|
|
4362
|
+
if (y) {
|
|
4363
|
+
const R = document.body.querySelector(y);
|
|
4364
|
+
R !== null ? r.historyFormFragment = A.getFormFragment(
|
|
4365
|
+
S.get(R)
|
|
4366
|
+
) : b.error(
|
|
4365
4367
|
"Haori",
|
|
4366
|
-
`Form element not found: ${
|
|
4368
|
+
`Form element not found: ${y} (${g.attrName(t, "history-form")})`
|
|
4367
4369
|
);
|
|
4368
4370
|
} else
|
|
4369
|
-
r.historyFormFragment =
|
|
4371
|
+
r.historyFormFragment = A.getFormFragment(e);
|
|
4370
4372
|
}
|
|
4371
4373
|
[
|
|
4372
4374
|
"reset-before",
|
|
@@ -4376,82 +4378,93 @@ ${b}
|
|
|
4376
4378
|
"copy",
|
|
4377
4379
|
"open",
|
|
4378
4380
|
"close"
|
|
4379
|
-
].forEach((
|
|
4380
|
-
const
|
|
4381
|
-
if (!e.hasAttribute(
|
|
4381
|
+
].forEach((y) => {
|
|
4382
|
+
const R = g.attrName(t, y);
|
|
4383
|
+
if (!e.hasAttribute(R))
|
|
4382
4384
|
return;
|
|
4383
|
-
const P = e.getRawAttribute(
|
|
4385
|
+
const P = e.getRawAttribute(R), F = [];
|
|
4384
4386
|
if (P)
|
|
4385
|
-
document.body.querySelectorAll(P).forEach((
|
|
4386
|
-
const
|
|
4387
|
-
|
|
4388
|
-
}),
|
|
4389
|
-
else if (
|
|
4390
|
-
const
|
|
4391
|
-
|
|
4387
|
+
document.body.querySelectorAll(P).forEach(($) => {
|
|
4388
|
+
const W = S.get($);
|
|
4389
|
+
W && F.push(W);
|
|
4390
|
+
}), F.length === 0 && b.error("Haori", `Element not found: ${P} (${R})`);
|
|
4391
|
+
else if (y === "open" || y === "close") {
|
|
4392
|
+
const U = e.getTarget().closest("dialog");
|
|
4393
|
+
U ? F.push(S.get(U)) : b.error("Haori", `Ancestor <dialog> not found (${R})`);
|
|
4392
4394
|
} else
|
|
4393
|
-
|
|
4394
|
-
if (
|
|
4395
|
-
switch (
|
|
4395
|
+
F.push(e);
|
|
4396
|
+
if (F.length > 0)
|
|
4397
|
+
switch (y) {
|
|
4396
4398
|
case "reset-before":
|
|
4397
|
-
r.resetBeforeFragments =
|
|
4399
|
+
r.resetBeforeFragments = F;
|
|
4398
4400
|
break;
|
|
4399
4401
|
case "reset":
|
|
4400
|
-
r.resetFragments =
|
|
4402
|
+
r.resetFragments = F;
|
|
4401
4403
|
break;
|
|
4402
4404
|
case "refetch":
|
|
4403
|
-
r.refetchFragments =
|
|
4405
|
+
r.refetchFragments = F;
|
|
4404
4406
|
break;
|
|
4405
4407
|
case "click":
|
|
4406
|
-
r.clickFragments =
|
|
4408
|
+
r.clickFragments = F;
|
|
4407
4409
|
break;
|
|
4408
4410
|
case "copy":
|
|
4409
|
-
r.copyFragments =
|
|
4411
|
+
r.copyFragments = F;
|
|
4410
4412
|
break;
|
|
4411
4413
|
case "open":
|
|
4412
|
-
r.openFragments =
|
|
4414
|
+
r.openFragments = F;
|
|
4413
4415
|
break;
|
|
4414
4416
|
case "close":
|
|
4415
|
-
r.closeFragments =
|
|
4417
|
+
r.closeFragments = F;
|
|
4416
4418
|
break;
|
|
4417
4419
|
}
|
|
4418
4420
|
});
|
|
4419
|
-
const
|
|
4420
|
-
if (e.hasAttribute(
|
|
4421
|
-
const
|
|
4422
|
-
|
|
4421
|
+
const p = g.attrName(t, "copy-source");
|
|
4422
|
+
if (e.hasAttribute(p)) {
|
|
4423
|
+
const y = e.getRawAttribute(
|
|
4424
|
+
p
|
|
4423
4425
|
);
|
|
4424
|
-
if (
|
|
4425
|
-
const
|
|
4426
|
-
if (
|
|
4427
|
-
const P =
|
|
4428
|
-
P ? r.copySourceFragment = P :
|
|
4426
|
+
if (y) {
|
|
4427
|
+
const R = document.body.querySelector(y);
|
|
4428
|
+
if (R !== null) {
|
|
4429
|
+
const P = S.get(R);
|
|
4430
|
+
P ? r.copySourceFragment = P : b.error(
|
|
4429
4431
|
"Haori",
|
|
4430
|
-
`Element is not managed by Haori: ${
|
|
4432
|
+
`Element is not managed by Haori: ${y} (${p})`
|
|
4431
4433
|
);
|
|
4432
4434
|
} else
|
|
4433
|
-
|
|
4435
|
+
b.error(
|
|
4434
4436
|
"Haori",
|
|
4435
|
-
`Element not found: ${
|
|
4437
|
+
`Element not found: ${y} (${p})`
|
|
4436
4438
|
);
|
|
4437
4439
|
} else
|
|
4438
4440
|
r.copySourceFragment = e;
|
|
4439
4441
|
}
|
|
4440
4442
|
}
|
|
4441
4443
|
if (!t && (e.hasAttribute(g.attrName(null, "data", !0)) && (r.dataAttrName = g.attrName(null, "data", !0)), e.hasAttribute(g.attrName(null, "form", !0)))) {
|
|
4442
|
-
const
|
|
4444
|
+
const E = e.getRawAttribute(
|
|
4443
4445
|
g.attrName(null, "form", !0)
|
|
4444
4446
|
);
|
|
4445
|
-
if (
|
|
4446
|
-
const
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
) :
|
|
4447
|
+
if (E) {
|
|
4448
|
+
const p = document.body.querySelector(E);
|
|
4449
|
+
p !== null ? r.formFragment = A.getFormFragment(
|
|
4450
|
+
S.get(p)
|
|
4451
|
+
) : b.error(
|
|
4450
4452
|
"Haori",
|
|
4451
|
-
`Form element not found: ${
|
|
4453
|
+
`Form element not found: ${E} (${g.attrName(null, "fetch-form", !0)})`
|
|
4452
4454
|
);
|
|
4453
4455
|
} else
|
|
4454
|
-
r.formFragment =
|
|
4456
|
+
r.formFragment = A.getFormFragment(e);
|
|
4457
|
+
}
|
|
4458
|
+
const O = t ? g.attrName(t, "fetch-state") : g.attrName(null, "state", !0);
|
|
4459
|
+
if (e.hasAttribute(O)) {
|
|
4460
|
+
const E = e.getRawAttribute(O), p = [];
|
|
4461
|
+
E ? (document.body.querySelectorAll(E).forEach((R) => {
|
|
4462
|
+
const P = S.get(R);
|
|
4463
|
+
P && p.push(P);
|
|
4464
|
+
}), p.length === 0 && b.error(
|
|
4465
|
+
"Haori",
|
|
4466
|
+
`Element not found: ${E} (${O})`
|
|
4467
|
+
)) : p.push(e), p.length > 0 && (r.fetchStateFragments = p);
|
|
4455
4468
|
}
|
|
4456
4469
|
return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [e], r.defaultSelfBind = !0), r;
|
|
4457
4470
|
}
|
|
@@ -4521,14 +4534,14 @@ ${b}
|
|
|
4521
4534
|
);
|
|
4522
4535
|
u === !1 && this.domEvent && this.domEvent.preventDefault(), u != null && typeof u.then == "function" && await u;
|
|
4523
4536
|
} catch (u) {
|
|
4524
|
-
|
|
4537
|
+
b.error("Haori", `Run script execution error: ${u}`);
|
|
4525
4538
|
}
|
|
4526
4539
|
}
|
|
4527
4540
|
if (!await this.confirm())
|
|
4528
4541
|
return !1;
|
|
4529
4542
|
this.options.resetBeforeFragments && this.options.resetBeforeFragments.length > 0 && (await Promise.all(
|
|
4530
4543
|
this.options.resetBeforeFragments.map(
|
|
4531
|
-
(h) =>
|
|
4544
|
+
(h) => A.reset(h)
|
|
4532
4545
|
)
|
|
4533
4546
|
), this.captureHistorySnapshots());
|
|
4534
4547
|
const r = this.prepareFetchRequest(), i = r.payload;
|
|
@@ -4546,48 +4559,52 @@ ${b}
|
|
|
4546
4559
|
}
|
|
4547
4560
|
const a = Object.keys(i).length > 0;
|
|
4548
4561
|
if (n) {
|
|
4549
|
-
const h = { ...s || {} }, u = r.requestedMethod,
|
|
4550
|
-
if (v &&
|
|
4562
|
+
const h = { ...s || {} }, u = r.requestedMethod, m = r.effectiveMethod, v = r.transportMode === "query-get", T = r.queryString;
|
|
4563
|
+
if (v && b.info("Haori demo fetch normalization", {
|
|
4551
4564
|
runtime: c.runtime,
|
|
4552
4565
|
requestedMethod: u,
|
|
4553
|
-
effectiveMethod:
|
|
4566
|
+
effectiveMethod: m,
|
|
4554
4567
|
transportMode: "query-get",
|
|
4555
4568
|
url: n,
|
|
4556
4569
|
payload: a ? i : void 0,
|
|
4557
|
-
queryString:
|
|
4570
|
+
queryString: T
|
|
4558
4571
|
}), this.options.targetFragment && n) {
|
|
4559
|
-
const
|
|
4572
|
+
const C = performance.now(), O = {
|
|
4560
4573
|
runtime: c.runtime,
|
|
4561
4574
|
requestedMethod: u,
|
|
4562
|
-
effectiveMethod:
|
|
4575
|
+
effectiveMethod: m,
|
|
4563
4576
|
transportMode: v ? "query-get" : "http",
|
|
4564
|
-
...v ? { queryString:
|
|
4577
|
+
...v ? { queryString: T } : {}
|
|
4565
4578
|
};
|
|
4566
4579
|
return N.fetchStart(
|
|
4567
4580
|
this.options.targetFragment.getTarget(),
|
|
4568
4581
|
n,
|
|
4569
4582
|
h,
|
|
4570
4583
|
a ? i : void 0,
|
|
4571
|
-
|
|
4572
|
-
), fetch(n, h).then((
|
|
4573
|
-
|
|
4584
|
+
O
|
|
4585
|
+
), await this.injectFetchState("loading"), fetch(n, h).then((E) => this.handleFetchResult(
|
|
4586
|
+
E,
|
|
4574
4587
|
n || void 0,
|
|
4575
|
-
|
|
4576
|
-
)).catch((
|
|
4588
|
+
C
|
|
4589
|
+
)).catch(async (E) => {
|
|
4577
4590
|
throw n && N.fetchError(
|
|
4578
4591
|
this.options.targetFragment.getTarget(),
|
|
4579
4592
|
n,
|
|
4580
|
-
|
|
4581
|
-
),
|
|
4593
|
+
E
|
|
4594
|
+
), await this.injectFetchState(
|
|
4595
|
+
"error",
|
|
4596
|
+
null,
|
|
4597
|
+
E instanceof Error ? E.message : String(E)
|
|
4598
|
+
), E;
|
|
4582
4599
|
});
|
|
4583
4600
|
}
|
|
4584
|
-
return fetch(n, h).then((
|
|
4601
|
+
return fetch(n, h).then((C) => this.handleFetchResult(C, n || void 0));
|
|
4585
4602
|
}
|
|
4586
4603
|
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && a) {
|
|
4587
|
-
const h = this.options.formFragment, u = h.getTarget(),
|
|
4588
|
-
e && e.appliedDisabledAttribute && this.options.targetFragment &&
|
|
4604
|
+
const h = this.options.formFragment, u = h.getTarget(), m = /* @__PURE__ */ new Set();
|
|
4605
|
+
e && e.appliedDisabledAttribute && this.options.targetFragment && m.add(this.options.targetFragment);
|
|
4589
4606
|
const v = h.getBindingData();
|
|
4590
|
-
Object.assign(v, i), await
|
|
4607
|
+
Object.assign(v, i), await k.setBindingData(u, v, m);
|
|
4591
4608
|
}
|
|
4592
4609
|
const o = a ? i : {}, l = new Response(JSON.stringify(o), {
|
|
4593
4610
|
headers: { "Content-Type": "application/json" }
|
|
@@ -4637,7 +4654,11 @@ ${b}
|
|
|
4637
4654
|
new Error(`${e.status} ${e.statusText}`),
|
|
4638
4655
|
e.status,
|
|
4639
4656
|
r
|
|
4640
|
-
), await this.handleFetchError(e)
|
|
4657
|
+
), await this.handleFetchError(e), await this.injectFetchState(
|
|
4658
|
+
"error",
|
|
4659
|
+
e.status,
|
|
4660
|
+
e.statusText || null
|
|
4661
|
+
)), !1;
|
|
4641
4662
|
if (this.options.targetFragment && t && r && N.fetchEnd(
|
|
4642
4663
|
this.options.targetFragment.getTarget(),
|
|
4643
4664
|
t,
|
|
@@ -4652,15 +4673,15 @@ ${b}
|
|
|
4652
4673
|
}
|
|
4653
4674
|
}
|
|
4654
4675
|
const n = [];
|
|
4655
|
-
n.push(this.bindResult(e)), n.push(this.adjust()), n.push(this.addRow()), n.push(this.removeRow()), n.push(this.movePrevRow()), n.push(this.moveNextRow()), await Promise.all(n), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
4656
|
-
this.options.resetFragments.map((a) =>
|
|
4676
|
+
n.push(this.bindResult(e)), n.push(this.adjust()), n.push(this.addRow()), n.push(this.removeRow()), n.push(this.movePrevRow()), n.push(this.moveNextRow()), await Promise.all(n), await this.injectFetchState("success", e.status, null), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
4677
|
+
this.options.resetFragments.map((a) => A.reset(a))
|
|
4657
4678
|
), await this.copy();
|
|
4658
4679
|
const s = [];
|
|
4659
4680
|
if (this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
4660
4681
|
s.push(new g(a, null).run());
|
|
4661
4682
|
}), this.options.clickFragments && this.options.clickFragments.length > 0)
|
|
4662
4683
|
for (const a of this.options.clickFragments) {
|
|
4663
|
-
await
|
|
4684
|
+
await k.evaluateAll(a);
|
|
4664
4685
|
const o = a.getTarget();
|
|
4665
4686
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
4666
4687
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
@@ -4668,10 +4689,10 @@ ${b}
|
|
|
4668
4689
|
}
|
|
4669
4690
|
if (this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
4670
4691
|
const o = a.getTarget();
|
|
4671
|
-
o instanceof HTMLElement ? s.push(i.openDialog(o)) :
|
|
4692
|
+
o instanceof HTMLElement ? s.push(i.openDialog(o)) : b.error("Haori", "Element is not an HTML element: ", o);
|
|
4672
4693
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
4673
4694
|
const o = a.getTarget();
|
|
4674
|
-
o instanceof HTMLElement ? s.push(i.closeDialog(o)) :
|
|
4695
|
+
o instanceof HTMLElement ? s.push(i.closeDialog(o)) : b.error("Haori", "Element is not an HTML element: ", o);
|
|
4675
4696
|
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
4676
4697
|
this.options.toastMessage,
|
|
4677
4698
|
this.options.toastLevel ?? "info"
|
|
@@ -4682,7 +4703,7 @@ ${b}
|
|
|
4682
4703
|
const h = new URLSearchParams(window.location.search).get(o);
|
|
4683
4704
|
if (h !== null) {
|
|
4684
4705
|
const u = h.trim();
|
|
4685
|
-
$e.isSafeLocalPath(u) ? a = u :
|
|
4706
|
+
$e.isSafeLocalPath(u) ? a = u : b.warn(
|
|
4686
4707
|
"Haori",
|
|
4687
4708
|
`戻り先パスが安全なローカルパスではないため、既定の遷移先へフォールバックします: ${h}`
|
|
4688
4709
|
);
|
|
@@ -4706,12 +4727,12 @@ ${b}
|
|
|
4706
4727
|
const s = e ? this.options.historyUrl : window.location.pathname, a = new URL(s, window.location.href);
|
|
4707
4728
|
if (a.origin !== window.location.origin) {
|
|
4708
4729
|
const l = "history.pushState: cross-origin URL is not allowed: " + a.toString();
|
|
4709
|
-
|
|
4730
|
+
b.error("Haori", l);
|
|
4710
4731
|
return;
|
|
4711
4732
|
}
|
|
4712
4733
|
const o = (l) => {
|
|
4713
4734
|
for (const [h, u] of Object.entries(l))
|
|
4714
|
-
u != null && (Array.isArray(u) ? u.forEach((
|
|
4735
|
+
u != null && (Array.isArray(u) ? u.forEach((m) => a.searchParams.append(h, String(m))) : typeof u == "object" ? a.searchParams.set(h, JSON.stringify(u)) : a.searchParams.set(h, String(u)));
|
|
4715
4736
|
};
|
|
4716
4737
|
i && o(t), n && o(r), history.pushState(
|
|
4717
4738
|
{ [Qe]: !0 },
|
|
@@ -4719,7 +4740,7 @@ ${b}
|
|
|
4719
4740
|
a.toString()
|
|
4720
4741
|
);
|
|
4721
4742
|
} catch (s) {
|
|
4722
|
-
|
|
4743
|
+
b.error("Haori", `history.pushState failed: ${s}`);
|
|
4723
4744
|
}
|
|
4724
4745
|
}
|
|
4725
4746
|
/**
|
|
@@ -4727,7 +4748,7 @@ ${b}
|
|
|
4727
4748
|
*/
|
|
4728
4749
|
async handleFetchError(e) {
|
|
4729
4750
|
let t = null;
|
|
4730
|
-
this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t =
|
|
4751
|
+
this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
4731
4752
|
const r = t ? t.getTarget() : document.body;
|
|
4732
4753
|
await ie().clearMessages(r);
|
|
4733
4754
|
const i = async (a) => {
|
|
@@ -4746,17 +4767,17 @@ ${b}
|
|
|
4746
4767
|
const l = /* @__PURE__ */ new Map(), h = [];
|
|
4747
4768
|
for (const u of a)
|
|
4748
4769
|
if (u && typeof u == "object" && !Array.isArray(u)) {
|
|
4749
|
-
const
|
|
4750
|
-
if (
|
|
4770
|
+
const m = u.key, v = u.message, T = typeof m == "string" && m.length > 0 ? m : null, C = typeof v == "string" ? v : v != null ? String(v) : "";
|
|
4771
|
+
if (C.length === 0)
|
|
4751
4772
|
continue;
|
|
4752
|
-
if (
|
|
4753
|
-
const
|
|
4754
|
-
|
|
4773
|
+
if (T !== null) {
|
|
4774
|
+
const O = l.get(T) ?? [];
|
|
4775
|
+
O.push(C), l.set(T, O);
|
|
4755
4776
|
} else
|
|
4756
|
-
h.push(
|
|
4777
|
+
h.push(C);
|
|
4757
4778
|
} else typeof u == "string" && u.length > 0 && h.push(u);
|
|
4758
|
-
for (const [u,
|
|
4759
|
-
o.push({ key: u, message:
|
|
4779
|
+
for (const [u, m] of l)
|
|
4780
|
+
o.push({ key: u, message: m.join(`
|
|
4760
4781
|
`) });
|
|
4761
4782
|
for (const u of h)
|
|
4762
4783
|
o.push({ message: u });
|
|
@@ -4776,7 +4797,7 @@ ${b}
|
|
|
4776
4797
|
if (o.length === 0)
|
|
4777
4798
|
return await i(`${e.status} ${e.statusText}`), n(), !1;
|
|
4778
4799
|
for (const l of o)
|
|
4779
|
-
l.key && t ? await
|
|
4800
|
+
l.key && t ? await A.addErrorMessage(t, l.key, l.message) : await i(l.message);
|
|
4780
4801
|
return n(), !1;
|
|
4781
4802
|
} catch {
|
|
4782
4803
|
}
|
|
@@ -4852,11 +4873,11 @@ ${b}
|
|
|
4852
4873
|
let i = t ? JSON.parse(r) : r;
|
|
4853
4874
|
if (this.options.bindTransform)
|
|
4854
4875
|
try {
|
|
4855
|
-
i =
|
|
4876
|
+
i = G.evaluate(this.options.bindTransform, {
|
|
4856
4877
|
response: i
|
|
4857
4878
|
});
|
|
4858
4879
|
} catch (s) {
|
|
4859
|
-
|
|
4880
|
+
b.error("Haori", `Invalid bind-transform: ${s}`);
|
|
4860
4881
|
}
|
|
4861
4882
|
if (this.options.bindParams) {
|
|
4862
4883
|
const s = {};
|
|
@@ -4878,7 +4899,7 @@ ${b}
|
|
|
4878
4899
|
} else
|
|
4879
4900
|
a[o] = i;
|
|
4880
4901
|
n.push(
|
|
4881
|
-
|
|
4902
|
+
k.setBindingData(
|
|
4882
4903
|
s.getTarget(),
|
|
4883
4904
|
a,
|
|
4884
4905
|
/* @__PURE__ */ new Set(),
|
|
@@ -4892,13 +4913,13 @@ ${b}
|
|
|
4892
4913
|
});
|
|
4893
4914
|
else if (typeof i == "string") {
|
|
4894
4915
|
if (this.options.defaultSelfBind) {
|
|
4895
|
-
|
|
4916
|
+
b.warn(
|
|
4896
4917
|
"Haori",
|
|
4897
4918
|
"string data is not bound because no bind target was specified."
|
|
4898
4919
|
);
|
|
4899
4920
|
return;
|
|
4900
4921
|
}
|
|
4901
|
-
return
|
|
4922
|
+
return b.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
4902
4923
|
new Error("string data cannot be bound without a bindArg.")
|
|
4903
4924
|
);
|
|
4904
4925
|
} else
|
|
@@ -4908,7 +4929,7 @@ ${b}
|
|
|
4908
4929
|
i
|
|
4909
4930
|
), o = this.options.bindMerge ? { ...s.getRawBindingData() ?? {}, ...a } : a;
|
|
4910
4931
|
n.push(
|
|
4911
|
-
|
|
4932
|
+
k.setBindingData(
|
|
4912
4933
|
s.getTarget(),
|
|
4913
4934
|
o,
|
|
4914
4935
|
/* @__PURE__ */ new Set(),
|
|
@@ -4949,7 +4970,7 @@ ${b}
|
|
|
4949
4970
|
...i.getBindingData(),
|
|
4950
4971
|
...t
|
|
4951
4972
|
};
|
|
4952
|
-
return
|
|
4973
|
+
return k.setBindingData(i.getTarget(), n);
|
|
4953
4974
|
});
|
|
4954
4975
|
return Promise.all(r).then(() => {
|
|
4955
4976
|
});
|
|
@@ -4958,7 +4979,7 @@ ${b}
|
|
|
4958
4979
|
* copy のコピー元データを取得します。
|
|
4959
4980
|
*/
|
|
4960
4981
|
resolveCopySourceData() {
|
|
4961
|
-
return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ?
|
|
4982
|
+
return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ? A.getValues(this.options.copySourceFragment) : { ...this.options.copySourceFragment.getBindingData() } : this.options.formFragment ? A.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
4962
4983
|
}
|
|
4963
4984
|
/**
|
|
4964
4985
|
* data 属性とフォーム値を統合した送信データを作成します。
|
|
@@ -4976,7 +4997,7 @@ ${b}
|
|
|
4976
4997
|
buildPayloadResolution() {
|
|
4977
4998
|
const e = {};
|
|
4978
4999
|
let t = !1;
|
|
4979
|
-
if (this.options.formFragment && Object.assign(e,
|
|
5000
|
+
if (this.options.formFragment && Object.assign(e, A.getValues(this.options.formFragment)), this.options.data && typeof this.options.data == "object" && Object.assign(e, this.options.data), this.options.targetFragment && this.options.dataAttrName) {
|
|
4980
5001
|
const r = g.resolveDataAttributeDetailed(
|
|
4981
5002
|
this.options.targetFragment,
|
|
4982
5003
|
this.options.dataAttrName
|
|
@@ -5025,15 +5046,15 @@ ${b}
|
|
|
5025
5046
|
const u = s.get("Content-Type") || "";
|
|
5026
5047
|
if (/multipart\/form-data/i.test(u)) {
|
|
5027
5048
|
s.delete("Content-Type");
|
|
5028
|
-
const
|
|
5029
|
-
for (const [v,
|
|
5030
|
-
|
|
5031
|
-
n.body =
|
|
5049
|
+
const m = new FormData();
|
|
5050
|
+
for (const [v, T] of Object.entries(t))
|
|
5051
|
+
T == null ? m.append(v, "") : T instanceof Blob ? m.append(v, T) : Array.isArray(T) ? T.forEach((C) => m.append(v, String(C))) : typeof T == "object" ? m.append(v, JSON.stringify(T)) : m.append(v, String(T));
|
|
5052
|
+
n.body = m;
|
|
5032
5053
|
} else if (/application\/x-www-form-urlencoded/i.test(u)) {
|
|
5033
|
-
const
|
|
5034
|
-
for (const [v,
|
|
5035
|
-
|
|
5036
|
-
n.body =
|
|
5054
|
+
const m = new URLSearchParams();
|
|
5055
|
+
for (const [v, T] of Object.entries(t))
|
|
5056
|
+
T !== void 0 && (T === null ? m.append(v, "") : Array.isArray(T) ? T.forEach((C) => m.append(v, String(C))) : typeof T == "object" ? m.append(v, JSON.stringify(T)) : m.append(v, String(T)));
|
|
5057
|
+
n.body = m;
|
|
5037
5058
|
} else
|
|
5038
5059
|
s.set("Content-Type", "application/json"), n.body = JSON.stringify(t);
|
|
5039
5060
|
}
|
|
@@ -5058,7 +5079,7 @@ ${b}
|
|
|
5058
5079
|
this.options.targetFragment && this.options.historyDataAttrName ? this.historyDataSnapshot = g.resolveDataAttribute(
|
|
5059
5080
|
this.options.targetFragment,
|
|
5060
5081
|
this.options.historyDataAttrName
|
|
5061
|
-
) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ?
|
|
5082
|
+
) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? A.getValues(this.options.historyFormFragment) : void 0;
|
|
5062
5083
|
}
|
|
5063
5084
|
/**
|
|
5064
5085
|
* history-data の評価値を取得します。
|
|
@@ -5080,7 +5101,7 @@ ${b}
|
|
|
5080
5101
|
if (this.historyFormSnapshot !== void 0)
|
|
5081
5102
|
return this.historyFormSnapshot;
|
|
5082
5103
|
if (this.options.historyFormFragment)
|
|
5083
|
-
return
|
|
5104
|
+
return A.getValues(this.options.historyFormFragment);
|
|
5084
5105
|
}
|
|
5085
5106
|
/**
|
|
5086
5107
|
* copy-params が指定されている場合は include / exclude を考慮して抽出します。
|
|
@@ -5128,11 +5149,11 @@ ${b}
|
|
|
5128
5149
|
*/
|
|
5129
5150
|
getRowFragment() {
|
|
5130
5151
|
if (!this.options.targetFragment)
|
|
5131
|
-
return
|
|
5152
|
+
return b.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
5132
5153
|
const e = this.options.targetFragment.closestByAttribute(
|
|
5133
5154
|
`${c.prefix}row`
|
|
5134
5155
|
);
|
|
5135
|
-
return e || (
|
|
5156
|
+
return e || (b.error("Haori", "Row fragment not found."), null);
|
|
5136
5157
|
}
|
|
5137
5158
|
/**
|
|
5138
5159
|
* 行を追加します。
|
|
@@ -5148,7 +5169,7 @@ ${b}
|
|
|
5148
5169
|
const t = [], r = e.clone();
|
|
5149
5170
|
return t.push(
|
|
5150
5171
|
e.getParent().insertAfter(r, e)
|
|
5151
|
-
), t.push(
|
|
5172
|
+
), t.push(k.evaluateAll(r)), t.push(A.reset(r)), Promise.all(t).then(() => {
|
|
5152
5173
|
});
|
|
5153
5174
|
}
|
|
5154
5175
|
/**
|
|
@@ -5199,6 +5220,42 @@ ${b}
|
|
|
5199
5220
|
const r = e.getParent();
|
|
5200
5221
|
return r ? r.insertAfter(e, t) : Promise.resolve();
|
|
5201
5222
|
}
|
|
5223
|
+
/**
|
|
5224
|
+
* フェッチ状態を `_fetch` として対象要素群のバインディングデータへ注入します。
|
|
5225
|
+
*
|
|
5226
|
+
* `data-fetch-state` / `data-{event}-fetch-state` で指定された要素に対し、
|
|
5227
|
+
* `loading` / `success` / `error` の各状態を `_fetch` キーで設定します。
|
|
5228
|
+
* `reflectToAttribute=false` で呼ぶため data-bind 属性は汚さず、bindchange
|
|
5229
|
+
* イベントも発火しませんが、対象要素の再評価(data-if 等)は実行されます。
|
|
5230
|
+
* 指定要素が無い場合は何もしません。
|
|
5231
|
+
*
|
|
5232
|
+
* @param status フェッチ状態('loading' | 'success' | 'error')
|
|
5233
|
+
* @param statusCode HTTP ステータスコード(無い場合は null)
|
|
5234
|
+
* @param message エラーメッセージ等(無い場合は null)
|
|
5235
|
+
* @returns 注入完了の Promise
|
|
5236
|
+
*/
|
|
5237
|
+
async injectFetchState(e, t = null, r = null) {
|
|
5238
|
+
const i = this.options.fetchStateFragments;
|
|
5239
|
+
if (!i || i.length === 0)
|
|
5240
|
+
return;
|
|
5241
|
+
const n = {
|
|
5242
|
+
status: e,
|
|
5243
|
+
loading: e === "loading",
|
|
5244
|
+
success: e === "success",
|
|
5245
|
+
error: e === "error",
|
|
5246
|
+
statusCode: t,
|
|
5247
|
+
message: r
|
|
5248
|
+
};
|
|
5249
|
+
await Promise.all(
|
|
5250
|
+
i.map((s) => {
|
|
5251
|
+
const a = s.getTarget(), o = {
|
|
5252
|
+
...s.getRawBindingData() ?? {},
|
|
5253
|
+
_fetch: n
|
|
5254
|
+
};
|
|
5255
|
+
return k.setBindingData(a, o, /* @__PURE__ */ new Set(), !1, !1);
|
|
5256
|
+
})
|
|
5257
|
+
);
|
|
5258
|
+
}
|
|
5202
5259
|
};
|
|
5203
5260
|
g.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, g.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/, g.RUNNING_CLICK_TARGETS = /* @__PURE__ */ new WeakSet();
|
|
5204
5261
|
let q = g;
|
|
@@ -5220,24 +5277,24 @@ class nt {
|
|
|
5220
5277
|
try {
|
|
5221
5278
|
r = await fetch(e, t);
|
|
5222
5279
|
} catch (n) {
|
|
5223
|
-
throw
|
|
5280
|
+
throw b.error("[Haori]", "Failed to fetch import source:", e, n), new Error(`Failed to fetch: ${e}`);
|
|
5224
5281
|
}
|
|
5225
5282
|
if (!r.ok) {
|
|
5226
5283
|
Be(r.status);
|
|
5227
5284
|
const n = `${r.status} ${r.statusText}`;
|
|
5228
|
-
throw
|
|
5285
|
+
throw b.error("[Haori]", "Import HTTP error:", e, n), new Error(`Failed to load ${e}: ${n}`);
|
|
5229
5286
|
}
|
|
5230
5287
|
let i;
|
|
5231
5288
|
try {
|
|
5232
5289
|
i = await r.text();
|
|
5233
5290
|
} catch (n) {
|
|
5234
|
-
throw
|
|
5291
|
+
throw b.error("[Haori]", "Failed to read response text:", e, n), new Error(`Failed to read response from: ${e}`);
|
|
5235
5292
|
}
|
|
5236
5293
|
try {
|
|
5237
5294
|
const s = new DOMParser().parseFromString(i, "text/html");
|
|
5238
|
-
return s && s.body ? s.body.innerHTML : (
|
|
5295
|
+
return s && s.body ? s.body.innerHTML : (b.warn("[Haori]", "No body found in imported document:", e), i);
|
|
5239
5296
|
} catch (n) {
|
|
5240
|
-
return
|
|
5297
|
+
return b.error("[Haori]", "Failed to parse imported HTML:", e, n), i;
|
|
5241
5298
|
}
|
|
5242
5299
|
}
|
|
5243
5300
|
}
|
|
@@ -5292,7 +5349,7 @@ const d = class d {
|
|
|
5292
5349
|
* @returns data-attr-* の内部反映なら true
|
|
5293
5350
|
*/
|
|
5294
5351
|
static isAliasedAttributeReflection(e, t) {
|
|
5295
|
-
const r =
|
|
5352
|
+
const r = S.get(e);
|
|
5296
5353
|
return r instanceof M ? r.hasAttribute(
|
|
5297
5354
|
`${c.prefix}${d.ATTRIBUTE_ALIAS_SUFFIX}${t}`
|
|
5298
5355
|
) : !1;
|
|
@@ -5324,7 +5381,7 @@ const d = class d {
|
|
|
5324
5381
|
static reevaluateChildren(e) {
|
|
5325
5382
|
const t = [];
|
|
5326
5383
|
return e.getChildren().forEach((r) => {
|
|
5327
|
-
r instanceof M ? t.push(d.evaluateAll(r)) : r instanceof
|
|
5384
|
+
r instanceof M ? t.push(d.evaluateAll(r)) : r instanceof j && t.push(d.evaluateText(r));
|
|
5328
5385
|
}), Promise.all(t).then(() => {
|
|
5329
5386
|
});
|
|
5330
5387
|
}
|
|
@@ -5422,20 +5479,20 @@ const d = class d {
|
|
|
5422
5479
|
const s = performance.now();
|
|
5423
5480
|
return t.setAttribute(`${c.prefix}importing`, ""), N.importStart(t, n), nt.load(n).then((a) => {
|
|
5424
5481
|
const o = new TextEncoder().encode(a).length;
|
|
5425
|
-
return
|
|
5482
|
+
return I.enqueue(() => {
|
|
5426
5483
|
t.innerHTML = a;
|
|
5427
5484
|
}).then(() => {
|
|
5428
5485
|
if (t.removeAttribute(`${c.prefix}importing`), N.importEnd(t, n, o, s), !document.body.hasAttribute("data-haori-ready")) {
|
|
5429
5486
|
const l = [];
|
|
5430
5487
|
return t.childNodes.forEach((h) => {
|
|
5431
|
-
const u =
|
|
5432
|
-
u instanceof M ? l.push(d.scan(u.getTarget())) : u instanceof
|
|
5488
|
+
const u = S.get(h);
|
|
5489
|
+
u instanceof M ? l.push(d.scan(u.getTarget())) : u instanceof j && l.push(d.evaluateText(u));
|
|
5433
5490
|
}), Promise.all(l).then(() => {
|
|
5434
5491
|
});
|
|
5435
5492
|
}
|
|
5436
5493
|
});
|
|
5437
5494
|
}).catch((a) => {
|
|
5438
|
-
t.removeAttribute(`${c.prefix}importing`), N.importError(t, n, a),
|
|
5495
|
+
t.removeAttribute(`${c.prefix}importing`), N.importError(t, n, a), b.error("[Haori]", "Failed to import HTML:", n, a);
|
|
5439
5496
|
}).finally(() => {
|
|
5440
5497
|
if (r.running = !1, r.rerunRequested)
|
|
5441
5498
|
return r.rerunRequested = !1, d.executeManagedImport(e);
|
|
@@ -5448,7 +5505,7 @@ const d = class d {
|
|
|
5448
5505
|
* @returns Promise (スキャンが完了したときに解決される)
|
|
5449
5506
|
*/
|
|
5450
5507
|
static scan(e) {
|
|
5451
|
-
const t =
|
|
5508
|
+
const t = S.get(e);
|
|
5452
5509
|
return t ? d.initializeElementFragment(t, !1) : Promise.resolve();
|
|
5453
5510
|
}
|
|
5454
5511
|
/**
|
|
@@ -5478,7 +5535,7 @@ const d = class d {
|
|
|
5478
5535
|
}
|
|
5479
5536
|
const r = [];
|
|
5480
5537
|
return e.getChildren().forEach((i) => {
|
|
5481
|
-
i instanceof M ? r.push(d.initializeElementFragment(i, t)) : i instanceof
|
|
5538
|
+
i instanceof M ? r.push(d.initializeElementFragment(i, t)) : i instanceof j && r.push(d.evaluateText(i));
|
|
5482
5539
|
}), Promise.all(r).then(() => {
|
|
5483
5540
|
d.refreshDerivedSubtreeSignature(e);
|
|
5484
5541
|
});
|
|
@@ -5562,7 +5619,7 @@ const d = class d {
|
|
|
5562
5619
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
5563
5620
|
*/
|
|
5564
5621
|
static setAttribute(e, t, r, i = !1) {
|
|
5565
|
-
const n =
|
|
5622
|
+
const n = S.get(e), s = d.getAliasedAttributeName(t);
|
|
5566
5623
|
if (s !== null)
|
|
5567
5624
|
return r === null ? n.removeAliasedAttribute(t, s) : n.setAliasedAttribute(
|
|
5568
5625
|
t,
|
|
@@ -5624,8 +5681,8 @@ const d = class d {
|
|
|
5624
5681
|
if (h === null)
|
|
5625
5682
|
a.push(d.setBindingData(e, u, /* @__PURE__ */ new Set(), !0));
|
|
5626
5683
|
else {
|
|
5627
|
-
const
|
|
5628
|
-
|
|
5684
|
+
const m = n.getRawBindingData() || {};
|
|
5685
|
+
m[String(h)] = u, a.push(d.setBindingData(e, m, /* @__PURE__ */ new Set(), !0));
|
|
5629
5686
|
}
|
|
5630
5687
|
break;
|
|
5631
5688
|
}
|
|
@@ -5658,15 +5715,15 @@ const d = class d {
|
|
|
5658
5715
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
5659
5716
|
*/
|
|
5660
5717
|
static setBindingData(e, t, r = /* @__PURE__ */ new Set(), i = !1, n = !0) {
|
|
5661
|
-
const s =
|
|
5718
|
+
const s = S.get(e), a = s.getRawBindingData();
|
|
5662
5719
|
s.setBindingData(t), n && N.bindChange(e, a, t, "manual");
|
|
5663
5720
|
const o = () => {
|
|
5664
5721
|
s.markBindingWorkStart();
|
|
5665
5722
|
const l = s.getRawBindingData() ?? t;
|
|
5666
5723
|
let h = n ? s.setAttribute(`${c.prefix}bind`, JSON.stringify(l)) : Promise.resolve();
|
|
5667
5724
|
if (e.tagName === "FORM") {
|
|
5668
|
-
const u = s.getAttribute(`${c.prefix}form-arg`),
|
|
5669
|
-
h = h.then(() =>
|
|
5725
|
+
const u = s.getAttribute(`${c.prefix}form-arg`), m = u && l[String(u)] && typeof l[String(u)] == "object" && !Array.isArray(l[String(u)]) ? l[String(u)] : u ? {} : l;
|
|
5726
|
+
h = h.then(() => A.syncValues(s, m));
|
|
5670
5727
|
}
|
|
5671
5728
|
return h = h.then(() => d.evaluateAll(s, r)), h = h.then(
|
|
5672
5729
|
() => d.reevaluateReactiveSpecialAttributes(s, r)
|
|
@@ -5697,7 +5754,7 @@ const d = class d {
|
|
|
5697
5754
|
* `resolved: true` のときは解決済みスコープ(常にオブジェクト)。
|
|
5698
5755
|
*/
|
|
5699
5756
|
static getBindingData(e, t = {}) {
|
|
5700
|
-
const r =
|
|
5757
|
+
const r = S.get(e);
|
|
5701
5758
|
return r instanceof M ? t.resolved ? r.getBindingData() : r.getRawBindingData() : null;
|
|
5702
5759
|
}
|
|
5703
5760
|
/**
|
|
@@ -5716,26 +5773,26 @@ const d = class d {
|
|
|
5716
5773
|
* @return 解決済みスコープと各キーの由来情報
|
|
5717
5774
|
*/
|
|
5718
5775
|
static dumpScope(e) {
|
|
5719
|
-
const t =
|
|
5776
|
+
const t = S.get(e);
|
|
5720
5777
|
if (!t)
|
|
5721
5778
|
return { resolved: {}, sources: {} };
|
|
5722
5779
|
const r = t.getBindingData(), i = {}, n = (l) => {
|
|
5723
5780
|
const h = l.getTarget();
|
|
5724
5781
|
return h.id ? `#${h.id}` : h.tagName.toLowerCase();
|
|
5725
|
-
}, s = (l, h, u,
|
|
5782
|
+
}, s = (l, h, u, m) => {
|
|
5726
5783
|
if (l)
|
|
5727
5784
|
for (const v of Object.keys(l))
|
|
5728
5785
|
v in i || (i[v] = {
|
|
5729
5786
|
value: l[v],
|
|
5730
5787
|
source: n(h),
|
|
5731
5788
|
kind: u,
|
|
5732
|
-
depth:
|
|
5789
|
+
depth: m
|
|
5733
5790
|
});
|
|
5734
5791
|
};
|
|
5735
5792
|
let a = t, o = 0;
|
|
5736
5793
|
for (; a; )
|
|
5737
5794
|
a !== t && s(a.getRawDerivedBindingData(), a, "derive", o), s(a.getRawBindingData(), a, "bind", o), a = a.getParent(), o += 1;
|
|
5738
|
-
return L.isEnabled() &&
|
|
5795
|
+
return L.isEnabled() && b.info("[Haori]", "scope dump for", e, { resolved: r, sources: i }), { resolved: r, sources: i };
|
|
5739
5796
|
}
|
|
5740
5797
|
/**
|
|
5741
5798
|
* data-bind 属性の値をパースします。
|
|
@@ -5748,7 +5805,7 @@ const d = class d {
|
|
|
5748
5805
|
try {
|
|
5749
5806
|
return JSON.parse(e);
|
|
5750
5807
|
} catch (t) {
|
|
5751
|
-
return
|
|
5808
|
+
return b.error("[Haori]", "Invalid JSON in data-bind:", t), {};
|
|
5752
5809
|
}
|
|
5753
5810
|
else {
|
|
5754
5811
|
const t = new URLSearchParams(e), r = {};
|
|
@@ -5764,11 +5821,11 @@ const d = class d {
|
|
|
5764
5821
|
* @param node 追加するノード
|
|
5765
5822
|
*/
|
|
5766
5823
|
static addNode(e, t) {
|
|
5767
|
-
const r =
|
|
5824
|
+
const r = S.get(e);
|
|
5768
5825
|
if (r.isSkipMutationNodes())
|
|
5769
5826
|
return;
|
|
5770
|
-
const i =
|
|
5771
|
-
n && (r.insertBefore(n, i), n instanceof M ? d.scan(n.getTarget()) : n instanceof
|
|
5827
|
+
const i = S.get(t.nextSibling), n = S.get(t);
|
|
5828
|
+
n && (r.insertBefore(n, i), n instanceof M ? d.scan(n.getTarget()) : n instanceof j && d.evaluateText(n));
|
|
5772
5829
|
}
|
|
5773
5830
|
/**
|
|
5774
5831
|
* ノードを親要素から削除します。
|
|
@@ -5776,7 +5833,7 @@ const d = class d {
|
|
|
5776
5833
|
* @param node 削除するノード
|
|
5777
5834
|
*/
|
|
5778
5835
|
static removeNode(e) {
|
|
5779
|
-
const t =
|
|
5836
|
+
const t = S.get(e);
|
|
5780
5837
|
if (t) {
|
|
5781
5838
|
const r = t.getParent();
|
|
5782
5839
|
if (r && r.isSkipMutationNodes())
|
|
@@ -5791,7 +5848,7 @@ const d = class d {
|
|
|
5791
5848
|
* @param text 新しいテキスト
|
|
5792
5849
|
*/
|
|
5793
5850
|
static changeText(e, t) {
|
|
5794
|
-
const r =
|
|
5851
|
+
const r = S.get(e);
|
|
5795
5852
|
r && r.setContent(t);
|
|
5796
5853
|
}
|
|
5797
5854
|
/**
|
|
@@ -5803,14 +5860,14 @@ const d = class d {
|
|
|
5803
5860
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
5804
5861
|
*/
|
|
5805
5862
|
static changeValue(e, t) {
|
|
5806
|
-
const r =
|
|
5863
|
+
const r = S.get(e);
|
|
5807
5864
|
if (r.getValue() === t)
|
|
5808
5865
|
return Promise.resolve();
|
|
5809
5866
|
const i = [];
|
|
5810
5867
|
i.push(r.setValue(t));
|
|
5811
5868
|
const n = d.getFormFragment(r);
|
|
5812
5869
|
if (n) {
|
|
5813
|
-
const s =
|
|
5870
|
+
const s = A.getValues(n), a = n.getAttribute(`${c.prefix}form-arg`);
|
|
5814
5871
|
let o;
|
|
5815
5872
|
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(d.setBindingData(n.getTarget(), o));
|
|
5816
5873
|
}
|
|
@@ -5842,22 +5899,22 @@ const d = class d {
|
|
|
5842
5899
|
const i = e.hasAttribute(`${c.prefix}derive`), n = e.hasAttribute(`${c.prefix}if`), s = e.hasAttribute(`${c.prefix}each`), a = e.getRawAttribute(`${c.prefix}derive`), o = e.getRawAttribute(`${c.prefix}derive-name`);
|
|
5843
5900
|
let l = !1, h = !1, u = null;
|
|
5844
5901
|
if (!i && e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), !i && e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), i) {
|
|
5845
|
-
const
|
|
5902
|
+
const m = d.createDeriveInputSignature(
|
|
5846
5903
|
e,
|
|
5847
5904
|
a,
|
|
5848
5905
|
o
|
|
5849
5906
|
);
|
|
5850
|
-
|
|
5907
|
+
m === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
|
|
5851
5908
|
() => d.evaluateDerive(e, a, o).then(
|
|
5852
5909
|
() => {
|
|
5853
5910
|
}
|
|
5854
5911
|
)
|
|
5855
|
-
)) : e.getDeriveInputSignature() !==
|
|
5912
|
+
)) : e.getDeriveInputSignature() !== m && (r = r.then(() => d.evaluateDerive(
|
|
5856
5913
|
e,
|
|
5857
5914
|
a,
|
|
5858
5915
|
o
|
|
5859
5916
|
).then(() => {
|
|
5860
|
-
e.setDeriveInputSignature(
|
|
5917
|
+
e.setDeriveInputSignature(m);
|
|
5861
5918
|
})));
|
|
5862
5919
|
}
|
|
5863
5920
|
return n && (r = r.then(() => d.evaluateIf(e))), s ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => d.evaluateEach(e))) : n ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => {
|
|
@@ -5876,14 +5933,14 @@ const d = class d {
|
|
|
5876
5933
|
})), r.then(() => {
|
|
5877
5934
|
if (l)
|
|
5878
5935
|
return;
|
|
5879
|
-
const
|
|
5936
|
+
const m = [];
|
|
5880
5937
|
return e.getChildren().forEach((v) => {
|
|
5881
5938
|
if (v instanceof M) {
|
|
5882
5939
|
if (d.canSkipUnchangedNestedEach(v))
|
|
5883
5940
|
return;
|
|
5884
|
-
|
|
5885
|
-
} else v instanceof
|
|
5886
|
-
}), Promise.all(
|
|
5941
|
+
m.push(d.evaluateAll(v, t));
|
|
5942
|
+
} else v instanceof j && m.push(d.evaluateText(v));
|
|
5943
|
+
}), Promise.all(m).then(() => {
|
|
5887
5944
|
});
|
|
5888
5945
|
}).then(() => {
|
|
5889
5946
|
h && u !== null && e.setDeriveSubtreeSignature(u);
|
|
@@ -5905,7 +5962,7 @@ const d = class d {
|
|
|
5905
5962
|
const i = e.getRawDerivedBindingData(), n = typeof r == "string" ? r.trim() : "";
|
|
5906
5963
|
if (!t || n === "")
|
|
5907
5964
|
return i === null ? Promise.resolve(!1) : (e.setDerivedBindingData(null), Promise.resolve(!0));
|
|
5908
|
-
const s =
|
|
5965
|
+
const s = G.evaluateDetailed(
|
|
5909
5966
|
t,
|
|
5910
5967
|
e.getBindingData()
|
|
5911
5968
|
);
|
|
@@ -5961,7 +6018,7 @@ const d = class d {
|
|
|
5961
6018
|
const a = {};
|
|
5962
6019
|
i.forEach((o) => {
|
|
5963
6020
|
o in r && (a[o] = r[o]);
|
|
5964
|
-
}),
|
|
6021
|
+
}), b.info(
|
|
5965
6022
|
"[Haori]",
|
|
5966
6023
|
"data-if is falsy (hidden):",
|
|
5967
6024
|
t,
|
|
@@ -5990,7 +6047,7 @@ const d = class d {
|
|
|
5990
6047
|
e.getChildren().forEach((s) => {
|
|
5991
6048
|
s instanceof M ? n.push(
|
|
5992
6049
|
s.isMounted() ? d.evaluateAll(s) : d.scan(s.getTarget())
|
|
5993
|
-
) : s instanceof
|
|
6050
|
+
) : s instanceof j && n.push(d.evaluateText(s));
|
|
5994
6051
|
}), t.push(
|
|
5995
6052
|
e.show().then(() => {
|
|
5996
6053
|
N.show(e.getTarget()), i || d.triggerLoadOnShow(e);
|
|
@@ -6013,7 +6070,7 @@ const d = class d {
|
|
|
6013
6070
|
static triggerLoadOnShow(e) {
|
|
6014
6071
|
const t = `${c.prefix}load-`;
|
|
6015
6072
|
e.getTarget().getAttributeNames().some((i) => i.startsWith(t)) && new q(e, "load").run().catch((i) => {
|
|
6016
|
-
|
|
6073
|
+
b.error("[Haori]", "data-load procedure error (on show):", i);
|
|
6017
6074
|
});
|
|
6018
6075
|
}
|
|
6019
6076
|
/**
|
|
@@ -6097,14 +6154,14 @@ ${r}
|
|
|
6097
6154
|
${r}
|
|
6098
6155
|
`);
|
|
6099
6156
|
} catch (n) {
|
|
6100
|
-
|
|
6157
|
+
b.error("Haori", `Invalid each-rendered-run script: ${n}`);
|
|
6101
6158
|
}
|
|
6102
6159
|
}
|
|
6103
6160
|
if (i)
|
|
6104
6161
|
try {
|
|
6105
6162
|
i.call(e);
|
|
6106
6163
|
} catch (n) {
|
|
6107
|
-
|
|
6164
|
+
b.error("Haori", `each-rendered-run execution error: ${n}`);
|
|
6108
6165
|
}
|
|
6109
6166
|
}
|
|
6110
6167
|
/**
|
|
@@ -6138,10 +6195,10 @@ ${r}
|
|
|
6138
6195
|
(l) => !l.hasAttribute(`${c.prefix}each-before`) && !l.hasAttribute(`${c.prefix}each-after`)
|
|
6139
6196
|
).forEach((l) => {
|
|
6140
6197
|
if (!s) {
|
|
6141
|
-
const u =
|
|
6198
|
+
const u = S.get(l);
|
|
6142
6199
|
u instanceof M && (r = u.clone(), d.markFreshInitializationSkippable(r), e.setTemplate(r), s = !0);
|
|
6143
6200
|
}
|
|
6144
|
-
const h =
|
|
6201
|
+
const h = S.get(l);
|
|
6145
6202
|
h instanceof M && e.getChildren().includes(h) && (e.removeChild(h), h.setMounted(!1)), l.parentNode && l.parentNode.removeChild(l);
|
|
6146
6203
|
});
|
|
6147
6204
|
}
|
|
@@ -6161,7 +6218,7 @@ ${r}
|
|
|
6161
6218
|
*/
|
|
6162
6219
|
static resolveEachItems(e) {
|
|
6163
6220
|
const t = e.getAttributeEvaluation(`${c.prefix}each`), r = t?.value;
|
|
6164
|
-
return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (
|
|
6221
|
+
return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (b.error("[Haori]", "Invalid each attribute:", r), null);
|
|
6165
6222
|
}
|
|
6166
6223
|
/**
|
|
6167
6224
|
* nested data-each の入力が同値で、要素自身に他の動的要素が無い場合は
|
|
@@ -6319,7 +6376,7 @@ ${r}
|
|
|
6319
6376
|
*/
|
|
6320
6377
|
static logDerivedSubtreeProfileSnapshot(e, t) {
|
|
6321
6378
|
const r = d.getOrCreateDerivedSubtreeProfile(e);
|
|
6322
|
-
r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1),
|
|
6379
|
+
r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1), b.info("[Haori][derive-profile]", {
|
|
6323
6380
|
reason: t,
|
|
6324
6381
|
hostId: r.hostId,
|
|
6325
6382
|
signatureComputeTotal: r.signatureComputeTotal,
|
|
@@ -6351,7 +6408,7 @@ ${r}
|
|
|
6351
6408
|
const n = e.getRawAttribute(i);
|
|
6352
6409
|
return typeof n == "string" && n.includes("{{");
|
|
6353
6410
|
}) ? !0 : e.getChildren().some(
|
|
6354
|
-
(i) => i instanceof
|
|
6411
|
+
(i) => i instanceof j && i.hasDynamicContent()
|
|
6355
6412
|
);
|
|
6356
6413
|
}
|
|
6357
6414
|
/**
|
|
@@ -6361,7 +6418,7 @@ ${r}
|
|
|
6361
6418
|
* @returns subtree 全体を省略可能なら true
|
|
6362
6419
|
*/
|
|
6363
6420
|
static markFreshInitializationSkippable(e) {
|
|
6364
|
-
const t = e.getAttributeNames().some((n) => d.isFreshInitializationDynamicAttribute(e, n)), r = e.getChildren().some((n) => n instanceof M ? !d.markFreshInitializationSkippable(n) : n instanceof
|
|
6421
|
+
const t = e.getAttributeNames().some((n) => d.isFreshInitializationDynamicAttribute(e, n)), r = e.getChildren().some((n) => n instanceof M ? !d.markFreshInitializationSkippable(n) : n instanceof j ? n.hasDynamicContent() : !1), i = !t && !r;
|
|
6365
6422
|
return e.setFreshInitializationSkippable(i), i;
|
|
6366
6423
|
}
|
|
6367
6424
|
/**
|
|
@@ -6386,85 +6443,85 @@ ${r}
|
|
|
6386
6443
|
static updateDiff(e, t) {
|
|
6387
6444
|
const r = e.getTemplate();
|
|
6388
6445
|
if (r === null)
|
|
6389
|
-
return
|
|
6446
|
+
return b.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
6390
6447
|
let i = e.getAttribute(`${c.prefix}each-index`);
|
|
6391
6448
|
i && (i = String(i));
|
|
6392
6449
|
const n = e.getAttribute(`${c.prefix}each-key`), s = e.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
6393
|
-
t.forEach((
|
|
6394
|
-
const
|
|
6395
|
-
|
|
6450
|
+
t.forEach((p, y) => {
|
|
6451
|
+
const R = d.createListKey(
|
|
6452
|
+
p,
|
|
6396
6453
|
n ? String(n) : null,
|
|
6397
|
-
|
|
6454
|
+
y
|
|
6398
6455
|
);
|
|
6399
|
-
o.push(
|
|
6456
|
+
o.push(R), a.set(R, { item: p, itemIndex: y });
|
|
6400
6457
|
});
|
|
6401
6458
|
const l = new Set(o), h = [];
|
|
6402
|
-
let u = e.getChildren().filter((
|
|
6403
|
-
(
|
|
6459
|
+
let u = e.getChildren().filter((p) => p instanceof M).filter(
|
|
6460
|
+
(p) => !p.hasAttribute(`${c.prefix}each-before`) && !p.hasAttribute(`${c.prefix}each-after`)
|
|
6404
6461
|
);
|
|
6405
|
-
const
|
|
6406
|
-
u = u.filter((
|
|
6407
|
-
const v = u.map((
|
|
6408
|
-
u.forEach((
|
|
6409
|
-
const
|
|
6410
|
-
|
|
6462
|
+
const m = u.map((p) => p.getListKey());
|
|
6463
|
+
u = u.filter((p) => l.has(String(p.getListKey())) ? !0 : (h.push(p.remove()), !1));
|
|
6464
|
+
const v = u.map((p) => p.getListKey()), T = /* @__PURE__ */ new Map();
|
|
6465
|
+
u.forEach((p) => {
|
|
6466
|
+
const y = p.getListKey();
|
|
6467
|
+
y !== null && !T.has(y) && T.set(y, p);
|
|
6411
6468
|
});
|
|
6412
|
-
const
|
|
6413
|
-
(
|
|
6469
|
+
const C = e.getChildElementFragments().slice(), O = C.filter(
|
|
6470
|
+
(p) => p.hasAttribute(`${c.prefix}each-before`)
|
|
6414
6471
|
).length;
|
|
6415
|
-
let
|
|
6416
|
-
return o.forEach((
|
|
6417
|
-
const { item:
|
|
6418
|
-
let
|
|
6419
|
-
const
|
|
6420
|
-
if (
|
|
6421
|
-
|
|
6472
|
+
let E = Promise.resolve();
|
|
6473
|
+
return o.forEach((p, y) => {
|
|
6474
|
+
const { item: R, itemIndex: P } = a.get(p);
|
|
6475
|
+
let F;
|
|
6476
|
+
const U = T.get(p);
|
|
6477
|
+
if (U)
|
|
6478
|
+
F = U, E = E.then(
|
|
6422
6479
|
() => d.updateRowFragment(
|
|
6423
|
-
|
|
6424
|
-
|
|
6480
|
+
F,
|
|
6481
|
+
R,
|
|
6425
6482
|
i,
|
|
6426
|
-
|
|
6483
|
+
P,
|
|
6427
6484
|
s ? String(s) : null,
|
|
6428
|
-
|
|
6485
|
+
p
|
|
6429
6486
|
).then(($) => {
|
|
6430
6487
|
if ($)
|
|
6431
|
-
return d.evaluateAll(
|
|
6488
|
+
return d.evaluateAll(F);
|
|
6432
6489
|
})
|
|
6433
6490
|
);
|
|
6434
6491
|
else {
|
|
6435
|
-
|
|
6436
|
-
const $ =
|
|
6437
|
-
|
|
6492
|
+
F = r.clone();
|
|
6493
|
+
const $ = O + y;
|
|
6494
|
+
E = E.then(
|
|
6438
6495
|
() => d.updateRowFragment(
|
|
6439
|
-
|
|
6440
|
-
|
|
6496
|
+
F,
|
|
6497
|
+
R,
|
|
6441
6498
|
i,
|
|
6442
|
-
|
|
6499
|
+
P,
|
|
6443
6500
|
s ? String(s) : null,
|
|
6444
|
-
|
|
6501
|
+
p
|
|
6445
6502
|
).then(() => {
|
|
6446
|
-
const
|
|
6447
|
-
return e.insertBefore(
|
|
6448
|
-
|
|
6449
|
-
}).then(() => d.initializeFreshEachRow(
|
|
6503
|
+
const W = C[$] ?? null;
|
|
6504
|
+
return e.insertBefore(F, W).then(() => {
|
|
6505
|
+
C.splice($, 0, F);
|
|
6506
|
+
}).then(() => d.initializeFreshEachRow(F));
|
|
6450
6507
|
})
|
|
6451
6508
|
);
|
|
6452
6509
|
}
|
|
6453
|
-
}), Promise.all(h).then(() =>
|
|
6454
|
-
const
|
|
6510
|
+
}), Promise.all(h).then(() => E).then(() => {
|
|
6511
|
+
const p = o.filter(
|
|
6455
6512
|
($) => $ !== null
|
|
6456
|
-
),
|
|
6513
|
+
), y = v.filter(
|
|
6457
6514
|
($) => $ !== null
|
|
6458
|
-
),
|
|
6515
|
+
), R = new Set(y), P = p.filter(($) => !R.has($)), U = m.filter(
|
|
6459
6516
|
($) => $ !== null
|
|
6460
6517
|
).filter(
|
|
6461
6518
|
($) => !l.has($)
|
|
6462
6519
|
);
|
|
6463
6520
|
N.eachUpdate(
|
|
6464
6521
|
e.getTarget(),
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6522
|
+
P,
|
|
6523
|
+
U,
|
|
6524
|
+
p
|
|
6468
6525
|
);
|
|
6469
6526
|
});
|
|
6470
6527
|
}
|
|
@@ -6510,7 +6567,7 @@ ${r}
|
|
|
6510
6567
|
[n]: t
|
|
6511
6568
|
}, r && (a[r] = i);
|
|
6512
6569
|
else
|
|
6513
|
-
return
|
|
6570
|
+
return b.error(
|
|
6514
6571
|
"[Haori]",
|
|
6515
6572
|
`Primitive value requires '${c.prefix}each-arg' attribute: ${t}`
|
|
6516
6573
|
), Promise.resolve(!1);
|
|
@@ -6621,8 +6678,8 @@ d.ATTRIBUTE_ALIAS_SUFFIX = "attr-", d.PRIORITY_ATTRIBUTE_SUFFIXES = [
|
|
|
6621
6678
|
"import",
|
|
6622
6679
|
"url-param"
|
|
6623
6680
|
], d.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/, d.REACTIVE_FETCH_STATES = /* @__PURE__ */ new WeakMap(), d.REACTIVE_IMPORT_STATES = /* @__PURE__ */ new WeakMap(), d.DERIVE_SUBTREE_PROFILES = /* @__PURE__ */ new WeakMap(), d.EACH_UPDATE_STATES = /* @__PURE__ */ new WeakMap();
|
|
6624
|
-
let
|
|
6625
|
-
const
|
|
6681
|
+
let k = d;
|
|
6682
|
+
const ee = class ee {
|
|
6626
6683
|
/**
|
|
6627
6684
|
* コンストラクタ。
|
|
6628
6685
|
*
|
|
@@ -6630,11 +6687,11 @@ const _ = class _ {
|
|
|
6630
6687
|
*/
|
|
6631
6688
|
constructor(e = document) {
|
|
6632
6689
|
this.customEventHandlers = /* @__PURE__ */ new Map(), this.onClick = (t) => this.delegate(t, "click"), this.onChange = (t) => this.delegate(t, "change"), this.onInput = (t) => this.delegate(t, "input"), this.onLoadCapture = (t) => this.delegate(t, "load"), this.onWindowLoad = () => {
|
|
6633
|
-
const t = document.documentElement, r =
|
|
6690
|
+
const t = document.documentElement, r = S.get(t);
|
|
6634
6691
|
r && new q(r, "load").run();
|
|
6635
6692
|
}, this.onPopstate = (t) => {
|
|
6636
6693
|
const r = t.state;
|
|
6637
|
-
!r || r[
|
|
6694
|
+
!r || r[ee.HISTORY_STATE_KEY] !== !0 || location.reload();
|
|
6638
6695
|
}, this.root = e;
|
|
6639
6696
|
}
|
|
6640
6697
|
/**
|
|
@@ -6686,8 +6743,8 @@ const _ = class _ {
|
|
|
6686
6743
|
subscribeCustomEvent(e) {
|
|
6687
6744
|
if (e === null || e === "")
|
|
6688
6745
|
return;
|
|
6689
|
-
if (
|
|
6690
|
-
|
|
6746
|
+
if (ee.BUILTIN_EVENT_NAMES.has(e)) {
|
|
6747
|
+
b.warn(
|
|
6691
6748
|
"[Haori]",
|
|
6692
6749
|
`data-on="${e}" は組み込みイベントです。data-${e}-* を使用してください(data-on はカスタムイベント専用)。`
|
|
6693
6750
|
);
|
|
@@ -6709,9 +6766,9 @@ const _ = class _ {
|
|
|
6709
6766
|
this.root.querySelectorAll(`[${this.onAttributeName}]`).forEach((i) => {
|
|
6710
6767
|
if (i.getAttribute(this.onAttributeName) !== e)
|
|
6711
6768
|
return;
|
|
6712
|
-
const n =
|
|
6769
|
+
const n = S.get(i);
|
|
6713
6770
|
n instanceof M && new q(n, "on", t).run().catch((s) => {
|
|
6714
|
-
|
|
6771
|
+
b.error("[Haori]", "Procedure execution error:", s);
|
|
6715
6772
|
});
|
|
6716
6773
|
});
|
|
6717
6774
|
}
|
|
@@ -6755,13 +6812,21 @@ const _ = class _ {
|
|
|
6755
6812
|
return;
|
|
6756
6813
|
}
|
|
6757
6814
|
r.hasAttribute(`${c.prefix}${t}-prevent`) && e.preventDefault();
|
|
6758
|
-
const i =
|
|
6815
|
+
const i = S.get(r);
|
|
6759
6816
|
if (!i)
|
|
6760
6817
|
return;
|
|
6761
|
-
(t === "change" || t === "input") && i instanceof M && i.syncValue()
|
|
6818
|
+
if ((t === "change" || t === "input") && i instanceof M && (i.syncValue(), r instanceof HTMLInputElement && r.type === "radio" && r.name)) {
|
|
6819
|
+
const s = document.getElementsByName(r.name);
|
|
6820
|
+
for (const a of Array.from(s)) {
|
|
6821
|
+
if (a === r || !(a instanceof HTMLInputElement) || a.type !== "radio" || a.form !== r.form)
|
|
6822
|
+
continue;
|
|
6823
|
+
const o = S.get(a);
|
|
6824
|
+
o instanceof M && o.syncValue();
|
|
6825
|
+
}
|
|
6826
|
+
}
|
|
6762
6827
|
const n = () => {
|
|
6763
6828
|
new q(i, t, e).run().catch((s) => {
|
|
6764
|
-
|
|
6829
|
+
b.error("[Haori]", "Procedure execution error:", s);
|
|
6765
6830
|
});
|
|
6766
6831
|
};
|
|
6767
6832
|
if (t === "click" && r.hasAttribute(`${c.prefix}click-defer`)) {
|
|
@@ -6813,13 +6878,13 @@ const _ = class _ {
|
|
|
6813
6878
|
return null;
|
|
6814
6879
|
}
|
|
6815
6880
|
};
|
|
6816
|
-
|
|
6881
|
+
ee.HISTORY_STATE_KEY = "__haoriHistoryState__", ee.BUILTIN_EVENT_NAMES = /* @__PURE__ */ new Set([
|
|
6817
6882
|
"click",
|
|
6818
6883
|
"change",
|
|
6819
6884
|
"input",
|
|
6820
6885
|
"load"
|
|
6821
6886
|
]);
|
|
6822
|
-
let fe =
|
|
6887
|
+
let fe = ee;
|
|
6823
6888
|
const D = class D {
|
|
6824
6889
|
/**
|
|
6825
6890
|
* ノードが現在の Window に属する HTMLElement かどうかを判定します。
|
|
@@ -6839,7 +6904,7 @@ const D = class D {
|
|
|
6839
6904
|
}));
|
|
6840
6905
|
}
|
|
6841
6906
|
static syncElement(e) {
|
|
6842
|
-
const t = D.registrations.get(e), r =
|
|
6907
|
+
const t = D.registrations.get(e), r = S.get(e);
|
|
6843
6908
|
if (!r || !D.shouldObserve(r)) {
|
|
6844
6909
|
t && (t.observer.disconnect(), D.registrations.delete(e));
|
|
6845
6910
|
return;
|
|
@@ -6859,17 +6924,17 @@ const D = class D {
|
|
|
6859
6924
|
(l) => {
|
|
6860
6925
|
const h = D.registrations.get(e);
|
|
6861
6926
|
h && l.forEach((u) => {
|
|
6862
|
-
!u.isIntersecting || h.running || D.isDisabled(h.fragment) || (h.running = !0, new q(h.fragment, "intersect").runWithResult().then((
|
|
6863
|
-
|
|
6864
|
-
}).catch((
|
|
6865
|
-
|
|
6927
|
+
!u.isIntersecting || h.running || D.isDisabled(h.fragment) || (h.running = !0, new q(h.fragment, "intersect").runWithResult().then((m) => {
|
|
6928
|
+
m && h.once && (h.observer.disconnect(), D.registrations.delete(e));
|
|
6929
|
+
}).catch((m) => {
|
|
6930
|
+
b.error(
|
|
6866
6931
|
"[Haori]",
|
|
6867
6932
|
"Intersect procedure execution error:",
|
|
6868
|
-
|
|
6933
|
+
m
|
|
6869
6934
|
);
|
|
6870
6935
|
}).finally(() => {
|
|
6871
|
-
const
|
|
6872
|
-
|
|
6936
|
+
const m = D.registrations.get(e);
|
|
6937
|
+
m && (m.running = !1);
|
|
6873
6938
|
}));
|
|
6874
6939
|
});
|
|
6875
6940
|
},
|
|
@@ -6917,7 +6982,7 @@ const D = class D {
|
|
|
6917
6982
|
if (typeof r != "string" || r.trim() === "")
|
|
6918
6983
|
return null;
|
|
6919
6984
|
const i = document.querySelector(r);
|
|
6920
|
-
return D.isHtmlElement(i) ? i : (
|
|
6985
|
+
return D.isHtmlElement(i) ? i : (b.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
6921
6986
|
}
|
|
6922
6987
|
static resolveRootMargin(e) {
|
|
6923
6988
|
const t = `${c.prefix}intersect-root-margin`, r = e.getAttribute(t);
|
|
@@ -6947,7 +7012,7 @@ D.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
6947
7012
|
"disabled",
|
|
6948
7013
|
"once"
|
|
6949
7014
|
]), D.registrations = /* @__PURE__ */ new Map();
|
|
6950
|
-
let
|
|
7015
|
+
let _ = D;
|
|
6951
7016
|
function st(f) {
|
|
6952
7017
|
typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => f()) : Promise.resolve().then(f);
|
|
6953
7018
|
}
|
|
@@ -6981,7 +7046,7 @@ const w = class w {
|
|
|
6981
7046
|
* @param element 対象要素
|
|
6982
7047
|
*/
|
|
6983
7048
|
static syncElement(e) {
|
|
6984
|
-
const t = w.registrations.get(e), r =
|
|
7049
|
+
const t = w.registrations.get(e), r = S.get(e);
|
|
6985
7050
|
if (!(r instanceof M) || !w.shouldObserve(r)) {
|
|
6986
7051
|
t && (t.observer.disconnect(), w.registrations.delete(e));
|
|
6987
7052
|
return;
|
|
@@ -6990,7 +7055,7 @@ const w = class w {
|
|
|
6990
7055
|
return;
|
|
6991
7056
|
const i = w.resolveVarName(r);
|
|
6992
7057
|
if (i === "") {
|
|
6993
|
-
t && (t.observer.disconnect(), w.registrations.delete(e)),
|
|
7058
|
+
t && (t.observer.disconnect(), w.registrations.delete(e)), b.warn(
|
|
6994
7059
|
"[Haori]",
|
|
6995
7060
|
'data-each-visible requires a variable name (e.g. data-each-visible="visibleRange").'
|
|
6996
7061
|
);
|
|
@@ -7008,9 +7073,9 @@ const w = class w {
|
|
|
7008
7073
|
if (!h)
|
|
7009
7074
|
return;
|
|
7010
7075
|
let u = !1;
|
|
7011
|
-
l.forEach((
|
|
7012
|
-
const v =
|
|
7013
|
-
h.observedRows.has(v) && (
|
|
7076
|
+
l.forEach((m) => {
|
|
7077
|
+
const v = m.target;
|
|
7078
|
+
h.observedRows.has(v) && (m.isIntersecting ? h.visibleRows.has(v) || (h.visibleRows.add(v), u = !0) : h.visibleRows.delete(v) && (u = !0));
|
|
7014
7079
|
}), u && w.scheduleCompute(h);
|
|
7015
7080
|
},
|
|
7016
7081
|
{
|
|
@@ -7087,7 +7152,7 @@ const w = class w {
|
|
|
7087
7152
|
if (typeof r != "string" || r.trim() === "")
|
|
7088
7153
|
return null;
|
|
7089
7154
|
const i = document.querySelector(r);
|
|
7090
|
-
return w.isHtmlElement(i) ? i : (
|
|
7155
|
+
return w.isHtmlElement(i) ? i : (b.error("[Haori]", `Visible range root element not found: ${r}`), null);
|
|
7091
7156
|
}
|
|
7092
7157
|
/**
|
|
7093
7158
|
* rootMargin を解決します。
|
|
@@ -7186,7 +7251,7 @@ const w = class w {
|
|
|
7186
7251
|
static publish(e, t) {
|
|
7187
7252
|
const r = w.resolveBindOwner(e.fragment);
|
|
7188
7253
|
if (!r) {
|
|
7189
|
-
|
|
7254
|
+
b.warn(
|
|
7190
7255
|
"[Haori]",
|
|
7191
7256
|
"data-each-visible found no ancestor data-bind scope to publish into."
|
|
7192
7257
|
);
|
|
@@ -7197,14 +7262,14 @@ const w = class w {
|
|
|
7197
7262
|
};
|
|
7198
7263
|
n[e.varName] = { ...t };
|
|
7199
7264
|
const s = e.fragment.getTarget(), a = i === s ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([e.fragment]);
|
|
7200
|
-
|
|
7265
|
+
k.setBindingData(
|
|
7201
7266
|
i,
|
|
7202
7267
|
n,
|
|
7203
7268
|
a,
|
|
7204
7269
|
!1,
|
|
7205
7270
|
!1
|
|
7206
7271
|
).catch((o) => {
|
|
7207
|
-
|
|
7272
|
+
b.error("[Haori]", "Failed to publish visible range:", o);
|
|
7208
7273
|
});
|
|
7209
7274
|
}
|
|
7210
7275
|
/**
|
|
@@ -7226,7 +7291,7 @@ const w = class w {
|
|
|
7226
7291
|
}
|
|
7227
7292
|
};
|
|
7228
7293
|
w.THRESHOLD = 0, w.DEFAULT_ROOT_MARGIN = "0px", w.registrations = /* @__PURE__ */ new Map();
|
|
7229
|
-
let
|
|
7294
|
+
let J = w;
|
|
7230
7295
|
const H = class H {
|
|
7231
7296
|
/**
|
|
7232
7297
|
* 既存の MutationObserver をすべて停止します。
|
|
@@ -7245,10 +7310,10 @@ const H = class H {
|
|
|
7245
7310
|
return;
|
|
7246
7311
|
H._initialized = !0, H.disconnectMutationObservers();
|
|
7247
7312
|
const e = await Promise.allSettled([
|
|
7248
|
-
|
|
7249
|
-
|
|
7313
|
+
k.scan(document.head),
|
|
7314
|
+
k.scan(document.body)
|
|
7250
7315
|
]), [t, r] = e;
|
|
7251
|
-
t.status !== "fulfilled" &&
|
|
7316
|
+
t.status !== "fulfilled" && b.error("[Haori]", "Failed to build head fragment:", t.reason), r.status !== "fulfilled" && b.error("[Haori]", "Failed to build body fragment:", r.reason), await I.wait(), document.body.setAttribute("data-haori-ready", ""), H.observe(document.head), H.observe(document.body), new fe().start(), _.syncTree(document.body), J.syncTree(document.body);
|
|
7252
7317
|
}
|
|
7253
7318
|
/**
|
|
7254
7319
|
* 指定ノードが「外部管理」サブツリーに属するかどうかを判定します。
|
|
@@ -7280,31 +7345,31 @@ const H = class H {
|
|
|
7280
7345
|
switch (i.type) {
|
|
7281
7346
|
case "attributes": {
|
|
7282
7347
|
const n = i.target;
|
|
7283
|
-
if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName &&
|
|
7348
|
+
if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && k.isAliasedAttributeReflection(
|
|
7284
7349
|
n,
|
|
7285
7350
|
i.attributeName
|
|
7286
7351
|
))
|
|
7287
7352
|
break;
|
|
7288
|
-
|
|
7353
|
+
k.setAttribute(
|
|
7289
7354
|
n,
|
|
7290
7355
|
i.attributeName,
|
|
7291
7356
|
n.getAttribute(i.attributeName),
|
|
7292
7357
|
!0
|
|
7293
|
-
),
|
|
7358
|
+
), _.syncElement(n), J.syncElement(n);
|
|
7294
7359
|
break;
|
|
7295
7360
|
}
|
|
7296
7361
|
case "childList": {
|
|
7297
7362
|
Array.from(i.removedNodes).forEach((n) => {
|
|
7298
|
-
|
|
7363
|
+
_.cleanupTree(n), J.cleanupTree(n), k.removeNode(n);
|
|
7299
7364
|
}), Array.from(i.addedNodes).forEach((n) => {
|
|
7300
|
-
n.parentElement instanceof Element && (
|
|
7301
|
-
}), i.target instanceof Element &&
|
|
7365
|
+
n.parentElement instanceof Element && (k.addNode(n.parentElement, n), _.syncTree(n), J.syncTree(n));
|
|
7366
|
+
}), i.target instanceof Element && J.syncElement(
|
|
7302
7367
|
i.target
|
|
7303
7368
|
);
|
|
7304
7369
|
break;
|
|
7305
7370
|
}
|
|
7306
7371
|
case "characterData": {
|
|
7307
|
-
i.target instanceof Text || i.target instanceof Comment ?
|
|
7372
|
+
i.target instanceof Text || i.target instanceof Comment ? k.changeText(i.target, i.target.textContent) : b.warn(
|
|
7308
7373
|
"[Haori]",
|
|
7309
7374
|
"Unsupported character data type:",
|
|
7310
7375
|
i.target
|
|
@@ -7312,11 +7377,11 @@ const H = class H {
|
|
|
7312
7377
|
break;
|
|
7313
7378
|
}
|
|
7314
7379
|
default:
|
|
7315
|
-
|
|
7380
|
+
b.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
7316
7381
|
continue;
|
|
7317
7382
|
}
|
|
7318
7383
|
} catch (n) {
|
|
7319
|
-
|
|
7384
|
+
b.error("[Haori]", "Error processing mutation:", n);
|
|
7320
7385
|
}
|
|
7321
7386
|
});
|
|
7322
7387
|
t.observe(e, {
|
|
@@ -7330,16 +7395,16 @@ const H = class H {
|
|
|
7330
7395
|
H._initialized = !1, H._mutationObservers = [];
|
|
7331
7396
|
let ae = H;
|
|
7332
7397
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", ae.init) : ae.init();
|
|
7333
|
-
const at = () =>
|
|
7398
|
+
const at = () => Z.waitForRenders(), ot = "0.24.0";
|
|
7334
7399
|
export {
|
|
7335
|
-
|
|
7400
|
+
k as Core,
|
|
7336
7401
|
c as Env,
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7402
|
+
A as Form,
|
|
7403
|
+
S as Fragment,
|
|
7404
|
+
Z as Haori,
|
|
7405
|
+
b as Log,
|
|
7406
|
+
I as Queue,
|
|
7407
|
+
Z as default,
|
|
7343
7408
|
ot as version,
|
|
7344
7409
|
at as waitForRenders
|
|
7345
7410
|
};
|