haori 0.4.13 → 0.4.15
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 +10 -10
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +695 -655
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +10 -10
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts +2 -2
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +7 -4
- package/dist/src/core.js.map +1 -1
- package/dist/src/observer.d.ts.map +1 -1
- package/dist/src/observer.js +6 -0
- package/dist/src/observer.js.map +1 -1
- package/dist/src/procedure.d.ts +36 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +98 -21
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +119 -0
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/dist/tests/procedure_events.test.d.ts.map +1 -1
- package/dist/tests/procedure_events.test.js +40 -0
- package/dist/tests/procedure_events.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -29,13 +29,13 @@ const C = class C {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
C.devMode = !1;
|
|
32
|
-
let
|
|
33
|
-
const
|
|
34
|
-
function
|
|
32
|
+
let B = C;
|
|
33
|
+
const Q = "embedded";
|
|
34
|
+
function it(P) {
|
|
35
35
|
return P === "embedded" || P === "demo";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return P === null ? null :
|
|
37
|
+
function st(P) {
|
|
38
|
+
return P === null ? null : it(P) ? P : Q;
|
|
39
39
|
}
|
|
40
40
|
const k = class k {
|
|
41
41
|
/**
|
|
@@ -53,7 +53,7 @@ const k = class k {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
k._runtime =
|
|
56
|
+
k._runtime = it(t) ? t : Q;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -67,21 +67,21 @@ const k = class k {
|
|
|
67
67
|
if (t instanceof HTMLScriptElement) {
|
|
68
68
|
const r = t.getAttribute("data-prefix") || k._prefix;
|
|
69
69
|
k._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
-
const
|
|
70
|
+
const i = st(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
|
-
|
|
73
|
+
i !== null && (k._runtime = i);
|
|
74
74
|
}
|
|
75
75
|
if (t instanceof HTMLScriptElement && t.hasAttribute(`${k._prefix}dev`)) {
|
|
76
|
-
|
|
76
|
+
B.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const e = window.location.hostname;
|
|
80
80
|
if (e === "localhost" || e.endsWith(".localhost") || e === "127.0.0.1" || e === "::1" || e.endsWith(".local")) {
|
|
81
|
-
|
|
81
|
+
B.set(!0);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
B.set(!1);
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -94,7 +94,7 @@ const k = class k {
|
|
|
94
94
|
return k._prefix;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
k._prefix = "data-", k._runtime =
|
|
97
|
+
k._prefix = "data-", k._runtime = Q;
|
|
98
98
|
let u = k;
|
|
99
99
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", u.detect) : u.detect();
|
|
100
100
|
class f {
|
|
@@ -105,7 +105,7 @@ class f {
|
|
|
105
105
|
* @param args 追加の引数
|
|
106
106
|
*/
|
|
107
107
|
static info(t, ...e) {
|
|
108
|
-
|
|
108
|
+
B.isEnabled() && console.log && console.log(t, ...e);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* 開発モードでのみコンソールに警告を出力します。
|
|
@@ -114,7 +114,7 @@ class f {
|
|
|
114
114
|
* @param args 追加の引数
|
|
115
115
|
*/
|
|
116
116
|
static warn(t, ...e) {
|
|
117
|
-
|
|
117
|
+
B.isEnabled() && console.warn && console.warn(t, ...e);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* モードに関係なくコンソールにエラーを出力します。
|
|
@@ -126,7 +126,7 @@ class f {
|
|
|
126
126
|
console.error(t, ...e);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class nt {
|
|
130
130
|
constructor() {
|
|
131
131
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
132
132
|
}
|
|
@@ -138,17 +138,17 @@ class st {
|
|
|
138
138
|
* @returns 処理完了Promise
|
|
139
139
|
*/
|
|
140
140
|
enqueue(t, e = !1) {
|
|
141
|
-
let r,
|
|
141
|
+
let r, i;
|
|
142
142
|
const n = new Promise((a, o) => {
|
|
143
|
-
r = a,
|
|
144
|
-
}),
|
|
143
|
+
r = a, i = o;
|
|
144
|
+
}), s = {
|
|
145
145
|
task: t,
|
|
146
146
|
timestamp: performance.now(),
|
|
147
147
|
promise: n,
|
|
148
148
|
resolve: r,
|
|
149
|
-
reject:
|
|
149
|
+
reject: i
|
|
150
150
|
};
|
|
151
|
-
return e ? this.queue.unshift(
|
|
151
|
+
return e ? this.queue.unshift(s) : this.queue.push(s), this.scheduleProcessing(), n;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* キューを処理します。
|
|
@@ -202,7 +202,7 @@ class st {
|
|
|
202
202
|
t.length > 0 && await Promise.allSettled(t);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const tt = class tt {
|
|
206
206
|
/**
|
|
207
207
|
* タスクをキューに追加します。
|
|
208
208
|
*
|
|
@@ -220,8 +220,8 @@ const _ = class _ {
|
|
|
220
220
|
return this.ASYNC_QUEUE.wait();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
|
|
224
|
-
let F =
|
|
223
|
+
tt.ASYNC_QUEUE = new nt();
|
|
224
|
+
let F = tt;
|
|
225
225
|
class X {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
@@ -315,8 +315,8 @@ class X {
|
|
|
315
315
|
*/
|
|
316
316
|
static addMessage(t, e, r) {
|
|
317
317
|
return F.enqueue(() => {
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
const i = t instanceof HTMLFormElement ? t : t.parentElement ?? t;
|
|
319
|
+
i.setAttribute("data-message", e), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
320
320
|
}, !0);
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
@@ -332,10 +332,10 @@ class X {
|
|
|
332
332
|
}, !0);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
const
|
|
336
|
-
function
|
|
335
|
+
const at = ["addErrorMessage", "clearMessages"];
|
|
336
|
+
function rt() {
|
|
337
337
|
const t = globalThis.window?.Haori;
|
|
338
|
-
return
|
|
338
|
+
return at.every(
|
|
339
339
|
(r) => typeof t?.[r] == "function"
|
|
340
340
|
) ? t : X;
|
|
341
341
|
}
|
|
@@ -361,32 +361,32 @@ class A {
|
|
|
361
361
|
* @returns values と同じオブジェクト
|
|
362
362
|
*/
|
|
363
363
|
static getPartValues(t, e) {
|
|
364
|
-
const r = t.getAttribute("name"),
|
|
364
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${u.prefix}form-object`), n = t.getAttribute(`${u.prefix}form-list`);
|
|
365
365
|
if (r) {
|
|
366
|
-
n ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(),
|
|
366
|
+
n ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && f.warn(
|
|
367
367
|
"Haori",
|
|
368
368
|
`Element cannot have both ${u.prefix}form-object and name attributes.`
|
|
369
369
|
);
|
|
370
|
-
for (const
|
|
371
|
-
A.getPartValues(
|
|
372
|
-
} else if (
|
|
373
|
-
const
|
|
370
|
+
for (const s of t.getChildElementFragments())
|
|
371
|
+
A.getPartValues(s, e);
|
|
372
|
+
} else if (i) {
|
|
373
|
+
const s = {};
|
|
374
374
|
for (const a of t.getChildElementFragments())
|
|
375
|
-
A.getPartValues(a,
|
|
376
|
-
Object.keys(
|
|
375
|
+
A.getPartValues(a, s);
|
|
376
|
+
Object.keys(s).length > 0 && (e[String(i)] = s), n && f.warn(
|
|
377
377
|
"Haori",
|
|
378
378
|
`Element cannot have both ${u.prefix}form-list and ${u.prefix}form-object attributes.`
|
|
379
379
|
);
|
|
380
380
|
} else if (n) {
|
|
381
|
-
const
|
|
381
|
+
const s = [];
|
|
382
382
|
for (const a of t.getChildElementFragments()) {
|
|
383
383
|
const o = {};
|
|
384
|
-
A.getPartValues(a, o), Object.keys(o).length > 0 &&
|
|
384
|
+
A.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
|
|
385
385
|
}
|
|
386
|
-
|
|
386
|
+
s.length > 0 && (e[String(n)] = s);
|
|
387
387
|
} else
|
|
388
|
-
for (const
|
|
389
|
-
A.getPartValues(
|
|
388
|
+
for (const s of t.getChildElementFragments())
|
|
389
|
+
A.getPartValues(s, e);
|
|
390
390
|
return e;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
@@ -433,53 +433,53 @@ class A {
|
|
|
433
433
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
434
434
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
435
435
|
*/
|
|
436
|
-
static setPartValues(t, e, r = null,
|
|
437
|
-
const
|
|
436
|
+
static setPartValues(t, e, r = null, i = !1, n = !0) {
|
|
437
|
+
const s = [], a = t.getAttribute("name"), o = t.getAttribute(`${u.prefix}form-object`), l = t.getAttribute(`${u.prefix}form-list`), g = t.getAttribute(`${u.prefix}form-detach`);
|
|
438
438
|
if (a) {
|
|
439
|
-
if (!
|
|
440
|
-
const
|
|
441
|
-
l && Array.isArray(
|
|
442
|
-
A.applyFragmentValue(t,
|
|
443
|
-
) : typeof
|
|
444
|
-
A.applyFragmentValue(t, String(
|
|
439
|
+
if (!g || i) {
|
|
440
|
+
const p = e[String(a)];
|
|
441
|
+
l && Array.isArray(p) && r !== null ? s.push(
|
|
442
|
+
A.applyFragmentValue(t, p[r] ?? null, n)
|
|
443
|
+
) : typeof p > "u" || (typeof p == "string" || typeof p == "number" || typeof p == "boolean" || p === null ? s.push(A.applyFragmentValue(t, p, n)) : s.push(
|
|
444
|
+
A.applyFragmentValue(t, String(p), n)
|
|
445
445
|
));
|
|
446
446
|
}
|
|
447
447
|
} else if (o) {
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
450
|
-
for (const
|
|
451
|
-
|
|
448
|
+
const p = e[String(o)];
|
|
449
|
+
if (p && typeof p == "object")
|
|
450
|
+
for (const E of t.getChildElementFragments())
|
|
451
|
+
s.push(
|
|
452
452
|
A.setPartValues(
|
|
453
|
-
|
|
454
|
-
|
|
453
|
+
E,
|
|
454
|
+
p,
|
|
455
455
|
null,
|
|
456
|
-
|
|
456
|
+
i,
|
|
457
457
|
n
|
|
458
458
|
)
|
|
459
459
|
);
|
|
460
460
|
} else if (l) {
|
|
461
|
-
const
|
|
462
|
-
if (Array.isArray(
|
|
463
|
-
const
|
|
464
|
-
for (let T = 0; T <
|
|
465
|
-
const h =
|
|
466
|
-
|
|
461
|
+
const p = e[String(l)];
|
|
462
|
+
if (Array.isArray(p)) {
|
|
463
|
+
const E = t.getChildElementFragments();
|
|
464
|
+
for (let T = 0; T < E.length; T++) {
|
|
465
|
+
const h = E[T];
|
|
466
|
+
p.length > T ? s.push(
|
|
467
467
|
A.setPartValues(
|
|
468
468
|
h,
|
|
469
|
-
|
|
469
|
+
p[T],
|
|
470
470
|
T,
|
|
471
|
-
|
|
471
|
+
i,
|
|
472
472
|
n
|
|
473
473
|
)
|
|
474
|
-
) :
|
|
474
|
+
) : s.push(A.setPartValues(h, {}, T, i, n));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
} else
|
|
478
|
-
for (const
|
|
479
|
-
|
|
480
|
-
A.setPartValues(
|
|
478
|
+
for (const p of t.getChildElementFragments())
|
|
479
|
+
s.push(
|
|
480
|
+
A.setPartValues(p, e, null, i, n)
|
|
481
481
|
);
|
|
482
|
-
return Promise.all(
|
|
482
|
+
return Promise.all(s).then(() => {
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
/**
|
|
@@ -500,8 +500,8 @@ class A {
|
|
|
500
500
|
else {
|
|
501
501
|
const r = e.parentElement;
|
|
502
502
|
if (r) {
|
|
503
|
-
const
|
|
504
|
-
n.appendChild(e), n.reset(), r.insertBefore(e,
|
|
503
|
+
const i = e.nextElementSibling, n = document.createElement("form");
|
|
504
|
+
n.appendChild(e), n.reset(), r.insertBefore(e, i);
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
}), await R.evaluateAll(t);
|
|
@@ -515,18 +515,18 @@ class A {
|
|
|
515
515
|
static clearEachClones(t) {
|
|
516
516
|
const e = [], r = (n) => {
|
|
517
517
|
if (n.hasAttribute(`${u.prefix}each`))
|
|
518
|
-
for (const
|
|
519
|
-
const a =
|
|
520
|
-
!a && !o && e.push(
|
|
518
|
+
for (const s of n.getChildElementFragments()) {
|
|
519
|
+
const a = s.hasAttribute(`${u.prefix}each-before`), o = s.hasAttribute(`${u.prefix}each-after`);
|
|
520
|
+
!a && !o && e.push(s.remove());
|
|
521
521
|
}
|
|
522
|
-
},
|
|
522
|
+
}, i = (n) => {
|
|
523
523
|
r(n);
|
|
524
|
-
for (const
|
|
525
|
-
s
|
|
524
|
+
for (const s of n.getChildElementFragments())
|
|
525
|
+
i(s);
|
|
526
526
|
};
|
|
527
527
|
r(t);
|
|
528
528
|
for (const n of t.getChildElementFragments())
|
|
529
|
-
|
|
529
|
+
i(n);
|
|
530
530
|
return Promise.all(e).then(() => {
|
|
531
531
|
});
|
|
532
532
|
}
|
|
@@ -547,7 +547,7 @@ class A {
|
|
|
547
547
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
548
548
|
*/
|
|
549
549
|
static clearMessages(t) {
|
|
550
|
-
return
|
|
550
|
+
return rt().clearMessages(
|
|
551
551
|
t.getTarget()
|
|
552
552
|
);
|
|
553
553
|
}
|
|
@@ -573,10 +573,10 @@ class A {
|
|
|
573
573
|
* @param level メッセージのレベル(省略可能)
|
|
574
574
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
575
575
|
*/
|
|
576
|
-
static addMessage(t, e, r,
|
|
577
|
-
const n = [],
|
|
578
|
-
return l.forEach((
|
|
579
|
-
n.push(o(
|
|
576
|
+
static addMessage(t, e, r, i) {
|
|
577
|
+
const n = [], s = rt(), a = s.addMessage, o = (g) => typeof a == "function" ? a.call(s, g, r, i) : s.addErrorMessage(g, r), l = A.findFragmentsByKey(t, e);
|
|
578
|
+
return l.forEach((g) => {
|
|
579
|
+
n.push(o(g.getTarget()));
|
|
580
580
|
}), l.length === 0 && n.push(o(t.getTarget())), Promise.all(n).then(() => {
|
|
581
581
|
});
|
|
582
582
|
}
|
|
@@ -599,24 +599,24 @@ class A {
|
|
|
599
599
|
* @returns 一致するフラグメントの配列
|
|
600
600
|
*/
|
|
601
601
|
static findFragmentByKeyParts(t, e) {
|
|
602
|
-
const r = [],
|
|
603
|
-
if (e.length == 1 && t.getAttribute("name") ===
|
|
604
|
-
e.length > 1 && t.getAttribute(`${u.prefix}form-object`) ===
|
|
605
|
-
r.push(...A.findFragmentByKeyParts(
|
|
602
|
+
const r = [], i = e[0];
|
|
603
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${u.prefix}form-object`))
|
|
604
|
+
e.length > 1 && t.getAttribute(`${u.prefix}form-object`) === i && t.getChildElementFragments().forEach((s) => {
|
|
605
|
+
r.push(...A.findFragmentByKeyParts(s, e.slice(1)));
|
|
606
606
|
});
|
|
607
607
|
else if (t.hasAttribute(`${u.prefix}form-list`)) {
|
|
608
608
|
if (e.length > 1) {
|
|
609
|
-
const n = t.getAttribute(`${u.prefix}form-list`),
|
|
610
|
-
if (
|
|
611
|
-
const o =
|
|
609
|
+
const n = t.getAttribute(`${u.prefix}form-list`), s = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
610
|
+
if (s !== -1 && a !== -1 && s < a) {
|
|
611
|
+
const o = i.substring(0, s);
|
|
612
612
|
if (n === o) {
|
|
613
|
-
const l =
|
|
614
|
-
if (isNaN(
|
|
615
|
-
f.error("Haori", `Invalid index: ${
|
|
613
|
+
const l = i.substring(s + 1, a), g = Number(l);
|
|
614
|
+
if (isNaN(g))
|
|
615
|
+
f.error("Haori", `Invalid index: ${i}`);
|
|
616
616
|
else {
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
...A.findFragmentByKeyParts(
|
|
617
|
+
const p = t.getChildElementFragments().filter((E) => E.hasAttribute(`${u.prefix}row`));
|
|
618
|
+
g < p.length && r.push(
|
|
619
|
+
...A.findFragmentByKeyParts(p[g], e.slice(1))
|
|
620
620
|
);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
@@ -641,7 +641,7 @@ class A {
|
|
|
641
641
|
return r ? this.getFormFragment(r) : null;
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
|
-
const
|
|
644
|
+
const M = class M {
|
|
645
645
|
/**
|
|
646
646
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
647
647
|
*
|
|
@@ -697,15 +697,15 @@ const D = class D {
|
|
|
697
697
|
e,
|
|
698
698
|
"Binded values contain forbidden values"
|
|
699
699
|
), null;
|
|
700
|
-
const r = Object.keys(e).filter((
|
|
701
|
-
let n = this.EXPRESSION_CACHE.get(
|
|
700
|
+
const r = Object.keys(e).filter((s) => !this.FORBIDDEN_BINDING_NAMES.has(s)).sort(), i = `${t}:${r.join(",")}`;
|
|
701
|
+
let n = this.EXPRESSION_CACHE.get(i);
|
|
702
702
|
if (!n) {
|
|
703
|
-
const
|
|
704
|
-
${
|
|
703
|
+
const s = this.buildAssignments(r), a = s ? `"use strict";
|
|
704
|
+
${s};
|
|
705
705
|
return (${t});` : `"use strict";
|
|
706
706
|
return (${t});`;
|
|
707
707
|
try {
|
|
708
|
-
n = new Function(...r, a), this.EXPRESSION_CACHE.set(
|
|
708
|
+
n = new Function(...r, a), this.EXPRESSION_CACHE.set(i, n);
|
|
709
709
|
} catch (o) {
|
|
710
710
|
return f.error(
|
|
711
711
|
"[Haori]",
|
|
@@ -716,12 +716,12 @@ return (${t});`;
|
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
718
|
try {
|
|
719
|
-
const
|
|
719
|
+
const s = [], a = this.wrapBoundValues(e);
|
|
720
720
|
return r.forEach((o) => {
|
|
721
|
-
|
|
722
|
-
}), this.withBlockedPropertyAccess(() => n(...
|
|
723
|
-
} catch (
|
|
724
|
-
return f.error("[Haori]", "Expression evaluation error:", t,
|
|
721
|
+
s.push(a[o]);
|
|
722
|
+
}), this.withBlockedPropertyAccess(() => n(...s));
|
|
723
|
+
} catch (s) {
|
|
724
|
+
return f.error("[Haori]", "Expression evaluation error:", t, s), s instanceof ReferenceError ? void 0 : null;
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
/**
|
|
@@ -751,21 +751,21 @@ return (${t});`;
|
|
|
751
751
|
if (e === null || e.length === 0)
|
|
752
752
|
return !1;
|
|
753
753
|
const r = [];
|
|
754
|
-
let
|
|
754
|
+
let i = null;
|
|
755
755
|
for (let n = 0; n < e.length; n++) {
|
|
756
|
-
const
|
|
756
|
+
const s = e[n], a = e[n + 1] || null, o = r[r.length - 1] || null, l = e[n - 2] || null, g = e[n - 3] || null;
|
|
757
757
|
if (this.startsObjectKey(
|
|
758
758
|
o,
|
|
759
|
-
|
|
759
|
+
i,
|
|
760
760
|
l,
|
|
761
|
-
|
|
762
|
-
) && (
|
|
763
|
-
this.decodeStringLiteral(
|
|
764
|
-
)) ||
|
|
765
|
-
this.decodeStringLiteral(
|
|
766
|
-
) ||
|
|
761
|
+
g
|
|
762
|
+
) && (s.value === "[" || s.type === "identifier" && this.FORBIDDEN_PROPERTY_NAMES.has(s.value) || s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
763
|
+
this.decodeStringLiteral(s.value)
|
|
764
|
+
)) || s.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(s.value) || this.STRICT_FORBIDDEN_NAMES.includes(s.value) || (i?.value === "." || i?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(s.value)) || o === "member" && s.value !== "]" && s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
765
|
+
this.decodeStringLiteral(s.value)
|
|
766
|
+
) || s.value === "." && a?.type !== "identifier" || s.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
767
767
|
return !1;
|
|
768
|
-
switch (
|
|
768
|
+
switch (s.value) {
|
|
769
769
|
case "(":
|
|
770
770
|
r.push("paren");
|
|
771
771
|
break;
|
|
@@ -775,8 +775,8 @@ return (${t});`;
|
|
|
775
775
|
break;
|
|
776
776
|
}
|
|
777
777
|
case "[": {
|
|
778
|
-
const
|
|
779
|
-
r.push(
|
|
778
|
+
const p = this.startsMemberAccess(i) ? "member" : "array";
|
|
779
|
+
r.push(p);
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
782
|
case "{":
|
|
@@ -793,7 +793,7 @@ return (${t});`;
|
|
|
793
793
|
break;
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
|
-
|
|
796
|
+
i = s;
|
|
797
797
|
}
|
|
798
798
|
return r.length === 0;
|
|
799
799
|
}
|
|
@@ -816,7 +816,7 @@ return (${t});`;
|
|
|
816
816
|
"==",
|
|
817
817
|
"!=",
|
|
818
818
|
"=>"
|
|
819
|
-
],
|
|
819
|
+
], i = /* @__PURE__ */ new Set([
|
|
820
820
|
"(",
|
|
821
821
|
")",
|
|
822
822
|
"{",
|
|
@@ -838,14 +838,14 @@ return (${t});`;
|
|
|
838
838
|
]);
|
|
839
839
|
let n = 0;
|
|
840
840
|
for (; n < t.length; ) {
|
|
841
|
-
const
|
|
842
|
-
if (/\s/.test(
|
|
841
|
+
const s = t[n];
|
|
842
|
+
if (/\s/.test(s)) {
|
|
843
843
|
n += 1;
|
|
844
844
|
continue;
|
|
845
845
|
}
|
|
846
|
-
if (
|
|
846
|
+
if (s === "/" && (t[n + 1] === "/" || t[n + 1] === "*"))
|
|
847
847
|
return null;
|
|
848
|
-
if (
|
|
848
|
+
if (s === '"' || s === "'") {
|
|
849
849
|
const o = this.readStringToken(t, n);
|
|
850
850
|
if (o === null)
|
|
851
851
|
return null;
|
|
@@ -859,18 +859,18 @@ return (${t});`;
|
|
|
859
859
|
e.push({ type: "operator", value: a, position: n }), n += a.length;
|
|
860
860
|
continue;
|
|
861
861
|
}
|
|
862
|
-
if (/[0-9]/.test(
|
|
862
|
+
if (/[0-9]/.test(s)) {
|
|
863
863
|
const o = this.readNumberToken(t, n);
|
|
864
864
|
e.push(o.token), n = o.nextIndex;
|
|
865
865
|
continue;
|
|
866
866
|
}
|
|
867
|
-
if (/[A-Za-z_$]/.test(
|
|
867
|
+
if (/[A-Za-z_$]/.test(s)) {
|
|
868
868
|
const o = this.readIdentifierToken(t, n);
|
|
869
869
|
e.push(o.token), n = o.nextIndex;
|
|
870
870
|
continue;
|
|
871
871
|
}
|
|
872
|
-
if (
|
|
873
|
-
e.push({ type: "operator", value:
|
|
872
|
+
if (i.has(s)) {
|
|
873
|
+
e.push({ type: "operator", value: s, position: n }), n += 1;
|
|
874
874
|
continue;
|
|
875
875
|
}
|
|
876
876
|
return null;
|
|
@@ -886,23 +886,23 @@ return (${t});`;
|
|
|
886
886
|
*/
|
|
887
887
|
static readStringToken(t, e) {
|
|
888
888
|
const r = t[e];
|
|
889
|
-
let
|
|
890
|
-
for (;
|
|
891
|
-
const n = t[
|
|
889
|
+
let i = e + 1;
|
|
890
|
+
for (; i < t.length; ) {
|
|
891
|
+
const n = t[i];
|
|
892
892
|
if (n === "\\") {
|
|
893
|
-
|
|
893
|
+
i += 2;
|
|
894
894
|
continue;
|
|
895
895
|
}
|
|
896
896
|
if (n === r)
|
|
897
897
|
return {
|
|
898
898
|
token: {
|
|
899
899
|
type: "string",
|
|
900
|
-
value: t.slice(e,
|
|
900
|
+
value: t.slice(e, i + 1),
|
|
901
901
|
position: e
|
|
902
902
|
},
|
|
903
|
-
nextIndex:
|
|
903
|
+
nextIndex: i + 1
|
|
904
904
|
};
|
|
905
|
-
|
|
905
|
+
i += 1;
|
|
906
906
|
}
|
|
907
907
|
return null;
|
|
908
908
|
}
|
|
@@ -965,8 +965,8 @@ return (${t});`;
|
|
|
965
965
|
* @param previous 直前のトークン
|
|
966
966
|
* @returns object literal のキー位置であれば true
|
|
967
967
|
*/
|
|
968
|
-
static startsObjectKey(t, e, r,
|
|
969
|
-
return t !== "object" ? !1 : e?.value === "{" || e?.value === "," || e?.type === "identifier" && this.OBJECT_PROPERTY_MODIFIERS.has(e.value) && (r?.value === "{" || r?.value === ",") ? !0 : e?.value !== "*" ? !1 : r?.value === "{" || r?.value === "," ? !0 : r?.type === "identifier" && r.value === "async" && (
|
|
968
|
+
static startsObjectKey(t, e, r, i) {
|
|
969
|
+
return t !== "object" ? !1 : e?.value === "{" || e?.value === "," || e?.type === "identifier" && this.OBJECT_PROPERTY_MODIFIERS.has(e.value) && (r?.value === "{" || r?.value === ",") ? !0 : e?.value !== "*" ? !1 : r?.value === "{" || r?.value === "," ? !0 : r?.type === "identifier" && r.value === "async" && (i?.value === "{" || i?.value === ",");
|
|
970
970
|
}
|
|
971
971
|
/**
|
|
972
972
|
* 文字列リテラルをプレーン文字列へ変換します。
|
|
@@ -1014,8 +1014,8 @@ return (${t});`;
|
|
|
1014
1014
|
*/
|
|
1015
1015
|
static wrapBoundValues(t) {
|
|
1016
1016
|
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
1017
|
-
return Object.entries(t).forEach(([
|
|
1018
|
-
r[
|
|
1017
|
+
return Object.entries(t).forEach(([i, n]) => {
|
|
1018
|
+
r[i] = this.wrapBoundValue(n, e);
|
|
1019
1019
|
}), r;
|
|
1020
1020
|
}
|
|
1021
1021
|
/**
|
|
@@ -1028,35 +1028,35 @@ return (${t});`;
|
|
|
1028
1028
|
static wrapBoundValue(t, e) {
|
|
1029
1029
|
if (!this.shouldWrapValue(t))
|
|
1030
1030
|
return t;
|
|
1031
|
-
const r = t,
|
|
1032
|
-
if (
|
|
1033
|
-
return
|
|
1031
|
+
const r = t, i = e.get(r);
|
|
1032
|
+
if (i !== void 0)
|
|
1033
|
+
return i;
|
|
1034
1034
|
const n = new Proxy(r, {
|
|
1035
|
-
get: (
|
|
1035
|
+
get: (s, a, o) => {
|
|
1036
1036
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
1037
1037
|
return;
|
|
1038
|
-
const l = Reflect.get(
|
|
1038
|
+
const l = Reflect.get(s, a, o);
|
|
1039
1039
|
return typeof a == "symbol" ? l : this.wrapBoundValue(
|
|
1040
1040
|
l,
|
|
1041
1041
|
e
|
|
1042
1042
|
);
|
|
1043
1043
|
},
|
|
1044
|
-
has: (
|
|
1045
|
-
getOwnPropertyDescriptor: (
|
|
1044
|
+
has: (s, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(s, a),
|
|
1045
|
+
getOwnPropertyDescriptor: (s, a) => {
|
|
1046
1046
|
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
1047
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
1047
|
+
return Reflect.getOwnPropertyDescriptor(s, a);
|
|
1048
1048
|
},
|
|
1049
|
-
apply: (
|
|
1049
|
+
apply: (s, a, o) => {
|
|
1050
1050
|
const l = Reflect.apply(
|
|
1051
|
-
|
|
1051
|
+
s,
|
|
1052
1052
|
a,
|
|
1053
1053
|
o
|
|
1054
1054
|
);
|
|
1055
1055
|
return this.isIteratorLike(l) ? l : this.wrapBoundValue(l, e);
|
|
1056
1056
|
},
|
|
1057
|
-
construct: (
|
|
1057
|
+
construct: (s, a, o) => this.wrapBoundValue(
|
|
1058
1058
|
Reflect.construct(
|
|
1059
|
-
|
|
1059
|
+
s,
|
|
1060
1060
|
a,
|
|
1061
1061
|
o
|
|
1062
1062
|
),
|
|
@@ -1092,12 +1092,12 @@ return (${t});`;
|
|
|
1092
1092
|
{ target: Object.prototype, property: "constructor" },
|
|
1093
1093
|
{ target: Function.prototype, property: "constructor" },
|
|
1094
1094
|
{ target: Object.prototype, property: "__proto__" }
|
|
1095
|
-
].map((
|
|
1096
|
-
...
|
|
1097
|
-
descriptor: Object.getOwnPropertyDescriptor(
|
|
1098
|
-
})).filter((
|
|
1099
|
-
r.forEach(({ target:
|
|
1100
|
-
Object.defineProperty(
|
|
1095
|
+
].map((i) => ({
|
|
1096
|
+
...i,
|
|
1097
|
+
descriptor: Object.getOwnPropertyDescriptor(i.target, i.property)
|
|
1098
|
+
})).filter((i) => i.descriptor?.configurable === !0);
|
|
1099
|
+
r.forEach(({ target: i, property: n }) => {
|
|
1100
|
+
Object.defineProperty(i, n, {
|
|
1101
1101
|
configurable: !0,
|
|
1102
1102
|
enumerable: !1,
|
|
1103
1103
|
get: () => {
|
|
@@ -1109,8 +1109,8 @@ return (${t});`;
|
|
|
1109
1109
|
try {
|
|
1110
1110
|
return t();
|
|
1111
1111
|
} finally {
|
|
1112
|
-
r.forEach(({ target:
|
|
1113
|
-
|
|
1112
|
+
r.forEach(({ target: i, property: n, descriptor: s }) => {
|
|
1113
|
+
s !== void 0 && Object.defineProperty(i, n, s);
|
|
1114
1114
|
});
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
@@ -1153,7 +1153,7 @@ return (${t});`;
|
|
|
1153
1153
|
for (const r of Object.values(t)) {
|
|
1154
1154
|
if (typeof r == "function") {
|
|
1155
1155
|
if (this.getForbiddenBindingValues().some(
|
|
1156
|
-
(
|
|
1156
|
+
(i) => i === r
|
|
1157
1157
|
))
|
|
1158
1158
|
return !0;
|
|
1159
1159
|
continue;
|
|
@@ -1164,7 +1164,7 @@ return (${t});`;
|
|
|
1164
1164
|
return !1;
|
|
1165
1165
|
}
|
|
1166
1166
|
};
|
|
1167
|
-
|
|
1167
|
+
M.FORBIDDEN_NAMES = [
|
|
1168
1168
|
// グローバルオブジェクト
|
|
1169
1169
|
"window",
|
|
1170
1170
|
"self",
|
|
@@ -1196,23 +1196,23 @@ D.FORBIDDEN_NAMES = [
|
|
|
1196
1196
|
"sessionStorage",
|
|
1197
1197
|
"IndexedDB",
|
|
1198
1198
|
"history"
|
|
1199
|
-
],
|
|
1200
|
-
...
|
|
1201
|
-
(t) => !
|
|
1199
|
+
], M.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], M.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), M.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1200
|
+
...M.FORBIDDEN_NAMES.filter(
|
|
1201
|
+
(t) => !M.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1202
1202
|
),
|
|
1203
1203
|
"constructor",
|
|
1204
1204
|
"__proto__",
|
|
1205
1205
|
"prototype",
|
|
1206
|
-
...
|
|
1207
|
-
]),
|
|
1206
|
+
...M.STRICT_FORBIDDEN_NAMES
|
|
1207
|
+
]), M.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1208
1208
|
"constructor",
|
|
1209
1209
|
"__proto__",
|
|
1210
1210
|
"prototype"
|
|
1211
|
-
]),
|
|
1211
|
+
]), M.OBJECT_PROPERTY_MODIFIERS = /* @__PURE__ */ new Set([
|
|
1212
1212
|
"get",
|
|
1213
1213
|
"set",
|
|
1214
1214
|
"async"
|
|
1215
|
-
]),
|
|
1215
|
+
]), M.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1216
1216
|
"await",
|
|
1217
1217
|
"break",
|
|
1218
1218
|
"case",
|
|
@@ -1246,8 +1246,8 @@ D.FORBIDDEN_NAMES = [
|
|
|
1246
1246
|
"while",
|
|
1247
1247
|
"with",
|
|
1248
1248
|
"yield"
|
|
1249
|
-
]),
|
|
1250
|
-
let j =
|
|
1249
|
+
]), M.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1250
|
+
let j = M;
|
|
1251
1251
|
const I = class I {
|
|
1252
1252
|
/**
|
|
1253
1253
|
* フラグメントのコンストラクタ。
|
|
@@ -1265,13 +1265,13 @@ const I = class I {
|
|
|
1265
1265
|
let e;
|
|
1266
1266
|
switch (t.nodeType) {
|
|
1267
1267
|
case Node.ELEMENT_NODE:
|
|
1268
|
-
e = new
|
|
1268
|
+
e = new D(t);
|
|
1269
1269
|
break;
|
|
1270
1270
|
case Node.TEXT_NODE:
|
|
1271
1271
|
e = new O(t);
|
|
1272
1272
|
break;
|
|
1273
1273
|
case Node.COMMENT_NODE:
|
|
1274
|
-
e = new
|
|
1274
|
+
e = new _(t);
|
|
1275
1275
|
break;
|
|
1276
1276
|
default:
|
|
1277
1277
|
return f.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
@@ -1381,7 +1381,7 @@ const I = class I {
|
|
|
1381
1381
|
};
|
|
1382
1382
|
I.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1383
1383
|
let w = I;
|
|
1384
|
-
class
|
|
1384
|
+
class D extends w {
|
|
1385
1385
|
/**
|
|
1386
1386
|
* エレメントフラグメントのコンストラクタ。
|
|
1387
1387
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1407,8 +1407,8 @@ class x extends w {
|
|
|
1407
1407
|
], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.bindingDataCache = null, this.visible = !0, this.display = null, this.displayPriority = null, this.template = null, this.listKey = null, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.syncValue(), t.getAttributeNames().forEach((e) => {
|
|
1408
1408
|
const r = t.getAttribute(e);
|
|
1409
1409
|
if (r !== null && !this.attributeMap.has(e)) {
|
|
1410
|
-
const
|
|
1411
|
-
this.attributeMap.set(e,
|
|
1410
|
+
const i = new U(e, r);
|
|
1411
|
+
this.attributeMap.set(e, i);
|
|
1412
1412
|
}
|
|
1413
1413
|
}), t.childNodes.forEach((e) => {
|
|
1414
1414
|
const r = w.get(e);
|
|
@@ -1430,7 +1430,7 @@ class x extends w {
|
|
|
1430
1430
|
*/
|
|
1431
1431
|
getChildElementFragments() {
|
|
1432
1432
|
return this.children.filter(
|
|
1433
|
-
(t) => t instanceof
|
|
1433
|
+
(t) => t instanceof D
|
|
1434
1434
|
);
|
|
1435
1435
|
}
|
|
1436
1436
|
/**
|
|
@@ -1462,7 +1462,7 @@ class x extends w {
|
|
|
1462
1462
|
* @returns クローンされたフラグメント
|
|
1463
1463
|
*/
|
|
1464
1464
|
clone() {
|
|
1465
|
-
const t = new
|
|
1465
|
+
const t = new D(
|
|
1466
1466
|
this.target.cloneNode(!1)
|
|
1467
1467
|
);
|
|
1468
1468
|
return this.attributeMap.forEach((e, r) => {
|
|
@@ -1477,7 +1477,7 @@ class x extends w {
|
|
|
1477
1477
|
*/
|
|
1478
1478
|
normalizeClonedVisibilityState() {
|
|
1479
1479
|
(this.visible === !1 || this.getTarget().style.display === "none" || this.getTarget().hasAttribute(`${u.prefix}if-false`)) && (this.visible = !0, this.display = null, this.displayPriority = null, this.getTarget().style.removeProperty("display"), this.getTarget().removeAttribute(`${u.prefix}if-false`)), this.children.forEach((t) => {
|
|
1480
|
-
t instanceof
|
|
1480
|
+
t instanceof D && t.normalizeClonedVisibilityState();
|
|
1481
1481
|
});
|
|
1482
1482
|
}
|
|
1483
1483
|
/**
|
|
@@ -1538,7 +1538,7 @@ class x extends w {
|
|
|
1538
1538
|
*/
|
|
1539
1539
|
clearBindingDataCache() {
|
|
1540
1540
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1541
|
-
t instanceof
|
|
1541
|
+
t instanceof D && t.clearBindingDataCache();
|
|
1542
1542
|
});
|
|
1543
1543
|
}
|
|
1544
1544
|
/**
|
|
@@ -1606,10 +1606,10 @@ class x extends w {
|
|
|
1606
1606
|
return Promise.resolve();
|
|
1607
1607
|
const r = this.getTarget();
|
|
1608
1608
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1609
|
-
const
|
|
1610
|
-
let
|
|
1611
|
-
return n ?
|
|
1612
|
-
r.checked =
|
|
1609
|
+
const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
|
|
1610
|
+
let s;
|
|
1611
|
+
return n ? s = t === !0 || t === "true" : i === "false" ? s = t === !1 : s = i === String(t), this.value = n ? s : s ? t : null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0, F.enqueue(() => {
|
|
1612
|
+
r.checked = s, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1613
1613
|
}).finally(() => {
|
|
1614
1614
|
this.skipChangeValue = !1;
|
|
1615
1615
|
}));
|
|
@@ -1678,13 +1678,13 @@ class x extends w {
|
|
|
1678
1678
|
* @param value 生の属性値
|
|
1679
1679
|
* @returns 属性更新の Promise
|
|
1680
1680
|
*/
|
|
1681
|
-
setAliasedAttribute(t, e, r,
|
|
1681
|
+
setAliasedAttribute(t, e, r, i = !1) {
|
|
1682
1682
|
return this.setAttributeInternal(
|
|
1683
1683
|
t,
|
|
1684
1684
|
e,
|
|
1685
1685
|
r,
|
|
1686
1686
|
!1,
|
|
1687
|
-
|
|
1687
|
+
i
|
|
1688
1688
|
);
|
|
1689
1689
|
}
|
|
1690
1690
|
/**
|
|
@@ -1714,28 +1714,28 @@ class x extends w {
|
|
|
1714
1714
|
* @param syncValueProperty value 属性更新時に DOM property も同期するかどうか
|
|
1715
1715
|
* @returns 属性更新の Promise
|
|
1716
1716
|
*/
|
|
1717
|
-
setAttributeInternal(t, e, r,
|
|
1717
|
+
setAttributeInternal(t, e, r, i, n = !1) {
|
|
1718
1718
|
if (this.skipMutationAttributes)
|
|
1719
1719
|
return Promise.resolve();
|
|
1720
1720
|
if (r === null)
|
|
1721
1721
|
return t === e ? this.removeAttribute(t) : this.removeAliasedAttribute(t, e);
|
|
1722
|
-
const
|
|
1722
|
+
const s = new U(t, r);
|
|
1723
1723
|
if (n) {
|
|
1724
1724
|
const l = this.attributeMap.get(t);
|
|
1725
|
-
if (l && (l.isEvaluate || l.isForceEvaluation()) && !
|
|
1725
|
+
if (l && (l.isEvaluate || l.isForceEvaluation()) && !s.isEvaluate && !s.isForceEvaluation())
|
|
1726
1726
|
return this.skipMutationAttributes = !0, F.enqueue(() => {
|
|
1727
1727
|
}).finally(() => {
|
|
1728
1728
|
this.skipMutationAttributes = !1;
|
|
1729
1729
|
});
|
|
1730
1730
|
}
|
|
1731
|
-
this.attributeMap.set(t,
|
|
1732
|
-
const a = this.getTarget(), o =
|
|
1731
|
+
this.attributeMap.set(t, s), this.skipMutationAttributes = !0;
|
|
1732
|
+
const a = this.getTarget(), o = s.isForceEvaluation() ? r : this.getAttribute(t);
|
|
1733
1733
|
return F.enqueue(() => {
|
|
1734
1734
|
if (a.getAttribute(t) !== r && a.setAttribute(t, r), o === null || o === !1)
|
|
1735
1735
|
a.removeAttribute(e);
|
|
1736
1736
|
else {
|
|
1737
1737
|
const l = String(o);
|
|
1738
|
-
a.getAttribute(e) !== l && a.setAttribute(e, l),
|
|
1738
|
+
a.getAttribute(e) !== l && a.setAttribute(e, l), i && s.isEvaluate && e === "value" && (a instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(a.type) || a instanceof HTMLTextAreaElement || a instanceof HTMLSelectElement) && (this.value = l, a.value !== l && (a.value = l));
|
|
1739
1739
|
}
|
|
1740
1740
|
}).finally(() => {
|
|
1741
1741
|
this.skipMutationAttributes = !1;
|
|
@@ -1770,7 +1770,7 @@ class x extends w {
|
|
|
1770
1770
|
if (e === void 0)
|
|
1771
1771
|
return null;
|
|
1772
1772
|
const r = e.evaluate(this.getBindingData());
|
|
1773
|
-
return r.length === 1 ? r[0] :
|
|
1773
|
+
return r.length === 1 ? r[0] : L.joinEvaluateResults(r);
|
|
1774
1774
|
}
|
|
1775
1775
|
/**
|
|
1776
1776
|
* 属性の生の値を取得します。
|
|
@@ -1810,18 +1810,18 @@ class x extends w {
|
|
|
1810
1810
|
const r = t.getTarget();
|
|
1811
1811
|
if (r.parentNode !== this.target)
|
|
1812
1812
|
return null;
|
|
1813
|
-
const
|
|
1813
|
+
const i = e ? r.nextSibling : r;
|
|
1814
1814
|
let n = e ? r.nextSibling : r;
|
|
1815
1815
|
for (; n !== null; ) {
|
|
1816
|
-
const
|
|
1817
|
-
if (
|
|
1818
|
-
const a = this.children.indexOf(
|
|
1816
|
+
const s = w.get(n);
|
|
1817
|
+
if (s !== null) {
|
|
1818
|
+
const a = this.children.indexOf(s);
|
|
1819
1819
|
if (a !== -1)
|
|
1820
|
-
return { index: a, referenceNode:
|
|
1820
|
+
return { index: a, referenceNode: i };
|
|
1821
1821
|
}
|
|
1822
1822
|
n = n.nextSibling;
|
|
1823
1823
|
}
|
|
1824
|
-
return { index: this.children.length, referenceNode:
|
|
1824
|
+
return { index: this.children.length, referenceNode: i };
|
|
1825
1825
|
}
|
|
1826
1826
|
/**
|
|
1827
1827
|
* 子ノードを参照ノードの前に挿入します。
|
|
@@ -1836,23 +1836,23 @@ class x extends w {
|
|
|
1836
1836
|
return Promise.resolve();
|
|
1837
1837
|
if (t === this)
|
|
1838
1838
|
return f.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1839
|
-
const
|
|
1839
|
+
const i = /* @__PURE__ */ new Set();
|
|
1840
1840
|
let n = this.parent;
|
|
1841
1841
|
for (; n; )
|
|
1842
|
-
|
|
1843
|
-
if (
|
|
1842
|
+
i.add(n), n = n.getParent();
|
|
1843
|
+
if (i.has(t))
|
|
1844
1844
|
return f.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1845
|
-
const
|
|
1845
|
+
const s = t.getParent() === this;
|
|
1846
1846
|
let a = -1, o = -1;
|
|
1847
|
-
|
|
1847
|
+
s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1848
1848
|
const l = t.getParent();
|
|
1849
1849
|
l !== null && l.removeChild(t);
|
|
1850
|
-
let
|
|
1850
|
+
let g = r === void 0 ? e?.getTarget() || null : r;
|
|
1851
1851
|
if (e === null)
|
|
1852
1852
|
this.children.push(t);
|
|
1853
1853
|
else {
|
|
1854
|
-
let
|
|
1855
|
-
if (
|
|
1854
|
+
let E;
|
|
1855
|
+
if (s ? a !== -1 && a < o ? E = o - 1 : E = o : E = this.children.indexOf(e), E === -1) {
|
|
1856
1856
|
const T = this.resolveInsertionPointFromDom(
|
|
1857
1857
|
e,
|
|
1858
1858
|
!1
|
|
@@ -1861,16 +1861,16 @@ class x extends w {
|
|
|
1861
1861
|
"[Haori]",
|
|
1862
1862
|
"Reference child not found in children.",
|
|
1863
1863
|
e
|
|
1864
|
-
), this.children.push(t)) : (this.children.splice(T.index, 0, t),
|
|
1864
|
+
), this.children.push(t)) : (this.children.splice(T.index, 0, t), g = T.referenceNode);
|
|
1865
1865
|
} else
|
|
1866
|
-
this.children.splice(
|
|
1866
|
+
this.children.splice(E, 0, t);
|
|
1867
1867
|
}
|
|
1868
1868
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1869
|
-
const
|
|
1869
|
+
const p = this.skipMutationNodes;
|
|
1870
1870
|
return this.skipMutationNodes = !0, F.enqueue(() => {
|
|
1871
|
-
this.target.insertBefore(t.getTarget(),
|
|
1871
|
+
this.target.insertBefore(t.getTarget(), g);
|
|
1872
1872
|
}).finally(() => {
|
|
1873
|
-
this.skipMutationNodes =
|
|
1873
|
+
this.skipMutationNodes = p;
|
|
1874
1874
|
});
|
|
1875
1875
|
}
|
|
1876
1876
|
/**
|
|
@@ -1885,18 +1885,18 @@ class x extends w {
|
|
|
1885
1885
|
return this.insertBefore(t, null);
|
|
1886
1886
|
const r = this.children.indexOf(e);
|
|
1887
1887
|
if (r === -1) {
|
|
1888
|
-
const
|
|
1888
|
+
const i = this.resolveInsertionPointFromDom(
|
|
1889
1889
|
e,
|
|
1890
1890
|
!0
|
|
1891
1891
|
);
|
|
1892
|
-
return
|
|
1892
|
+
return i === null ? (f.warn(
|
|
1893
1893
|
"[Haori]",
|
|
1894
1894
|
"Reference child not found in children.",
|
|
1895
1895
|
e
|
|
1896
1896
|
), this.insertBefore(t, null)) : this.insertBefore(
|
|
1897
1897
|
t,
|
|
1898
|
-
this.children[
|
|
1899
|
-
|
|
1898
|
+
this.children[i.index] || null,
|
|
1899
|
+
i.referenceNode
|
|
1900
1900
|
);
|
|
1901
1901
|
}
|
|
1902
1902
|
return this.insertBefore(t, this.children[r + 1] || null);
|
|
@@ -1984,7 +1984,7 @@ class O extends w {
|
|
|
1984
1984
|
* @param target 対象テキストノード
|
|
1985
1985
|
*/
|
|
1986
1986
|
constructor(t) {
|
|
1987
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1987
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new L(this.text);
|
|
1988
1988
|
}
|
|
1989
1989
|
/**
|
|
1990
1990
|
* フラグメントをクローンします。
|
|
@@ -2010,7 +2010,7 @@ class O extends w {
|
|
|
2010
2010
|
* @returns 更新のPromise
|
|
2011
2011
|
*/
|
|
2012
2012
|
setContent(t) {
|
|
2013
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
2013
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new L(t), this.evaluate());
|
|
2014
2014
|
}
|
|
2015
2015
|
/**
|
|
2016
2016
|
* フラグメントを評価します。
|
|
@@ -2023,7 +2023,7 @@ class O extends w {
|
|
|
2023
2023
|
) : F.enqueue(() => {
|
|
2024
2024
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
2025
2025
|
this.parent.getBindingData()
|
|
2026
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
2026
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = L.joinEvaluateResults(
|
|
2027
2027
|
this.contents.evaluate(this.parent.getBindingData())
|
|
2028
2028
|
) : this.target.textContent = this.text;
|
|
2029
2029
|
}).finally(() => {
|
|
@@ -2031,7 +2031,7 @@ class O extends w {
|
|
|
2031
2031
|
});
|
|
2032
2032
|
}
|
|
2033
2033
|
}
|
|
2034
|
-
class
|
|
2034
|
+
class _ extends w {
|
|
2035
2035
|
/**
|
|
2036
2036
|
* コメントフラグメントのコンストラクタ。
|
|
2037
2037
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -2047,7 +2047,7 @@ class Z extends w {
|
|
|
2047
2047
|
* @returns クローンされたフラグメント
|
|
2048
2048
|
*/
|
|
2049
2049
|
clone() {
|
|
2050
|
-
const t = new
|
|
2050
|
+
const t = new _(this.target.cloneNode(!0));
|
|
2051
2051
|
return t.mounted = !1, t.text = this.text, t;
|
|
2052
2052
|
}
|
|
2053
2053
|
/**
|
|
@@ -2072,7 +2072,7 @@ class Z extends w {
|
|
|
2072
2072
|
}));
|
|
2073
2073
|
}
|
|
2074
2074
|
}
|
|
2075
|
-
const
|
|
2075
|
+
const K = class K {
|
|
2076
2076
|
/**
|
|
2077
2077
|
* コンストラクタ。
|
|
2078
2078
|
*
|
|
@@ -2080,26 +2080,26 @@ const G = class G {
|
|
|
2080
2080
|
*/
|
|
2081
2081
|
constructor(t) {
|
|
2082
2082
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
2083
|
-
const e = [...t.matchAll(
|
|
2084
|
-
let r = 0,
|
|
2085
|
-
for (const
|
|
2086
|
-
|
|
2087
|
-
text: t.slice(r,
|
|
2083
|
+
const e = [...t.matchAll(K.PLACEHOLDER_REGEX)];
|
|
2084
|
+
let r = 0, i = !1, n = !1;
|
|
2085
|
+
for (const s of e) {
|
|
2086
|
+
s.index > r && this.contents.push({
|
|
2087
|
+
text: t.slice(r, s.index),
|
|
2088
2088
|
type: 0
|
|
2089
2089
|
/* TEXT */
|
|
2090
2090
|
});
|
|
2091
2091
|
const a = {
|
|
2092
|
-
text:
|
|
2093
|
-
type:
|
|
2092
|
+
text: s[1] ?? s[2],
|
|
2093
|
+
type: s[1] ? 2 : 1
|
|
2094
2094
|
/* EXPRESSION */
|
|
2095
2095
|
};
|
|
2096
|
-
|
|
2096
|
+
i = !0, n = n || a.type === 2, this.contents.push(a), r = s.index + s[0].length;
|
|
2097
2097
|
}
|
|
2098
2098
|
r < t.length && this.contents.push({
|
|
2099
2099
|
text: t.slice(r),
|
|
2100
2100
|
type: 0
|
|
2101
2101
|
/* TEXT */
|
|
2102
|
-
}), this.isEvaluate =
|
|
2102
|
+
}), this.isEvaluate = i, this.isRawEvaluate = n, this.checkRawExpressions();
|
|
2103
2103
|
}
|
|
2104
2104
|
/**
|
|
2105
2105
|
* 評価結果を結合して文字列にします。
|
|
@@ -2141,23 +2141,23 @@ const G = class G {
|
|
|
2141
2141
|
return this.contents.forEach((r) => {
|
|
2142
2142
|
try {
|
|
2143
2143
|
if (r.type === 1 || r.type === 2) {
|
|
2144
|
-
const
|
|
2145
|
-
e.push(
|
|
2144
|
+
const i = j.evaluate(r.text, t);
|
|
2145
|
+
e.push(i);
|
|
2146
2146
|
} else
|
|
2147
2147
|
e.push(r.text);
|
|
2148
|
-
} catch (
|
|
2148
|
+
} catch (i) {
|
|
2149
2149
|
f.error(
|
|
2150
2150
|
"[Haori]",
|
|
2151
2151
|
`Error evaluating text expression: ${r.text}`,
|
|
2152
|
-
|
|
2152
|
+
i
|
|
2153
2153
|
), e.push("");
|
|
2154
2154
|
}
|
|
2155
2155
|
}), e;
|
|
2156
2156
|
}
|
|
2157
2157
|
};
|
|
2158
|
-
|
|
2159
|
-
let
|
|
2160
|
-
const
|
|
2158
|
+
K.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2159
|
+
let L = K;
|
|
2160
|
+
const G = class G extends L {
|
|
2161
2161
|
/**
|
|
2162
2162
|
* コンストラクタ。
|
|
2163
2163
|
*
|
|
@@ -2165,7 +2165,7 @@ const K = class K extends B {
|
|
|
2165
2165
|
* @param text 属性値
|
|
2166
2166
|
*/
|
|
2167
2167
|
constructor(t, e) {
|
|
2168
|
-
super(e), this.forceEvaluation =
|
|
2168
|
+
super(e), this.forceEvaluation = G.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
2169
2169
|
}
|
|
2170
2170
|
/**
|
|
2171
2171
|
* 強制評価フラグを取得します。
|
|
@@ -2188,15 +2188,15 @@ const K = class K extends B {
|
|
|
2188
2188
|
return this.contents.forEach((r) => {
|
|
2189
2189
|
try {
|
|
2190
2190
|
if (this.forceEvaluation && r.type === 0 || r.type === 1 || r.type === 2) {
|
|
2191
|
-
const
|
|
2192
|
-
e.push(
|
|
2191
|
+
const i = j.evaluate(r.text, t);
|
|
2192
|
+
e.push(i);
|
|
2193
2193
|
} else
|
|
2194
2194
|
e.push(r.text);
|
|
2195
|
-
} catch (
|
|
2195
|
+
} catch (i) {
|
|
2196
2196
|
f.error(
|
|
2197
2197
|
"[Haori]",
|
|
2198
2198
|
`Error evaluating attribute expression: ${r.text}`,
|
|
2199
|
-
|
|
2199
|
+
i
|
|
2200
2200
|
), e.push("");
|
|
2201
2201
|
}
|
|
2202
2202
|
}), this.forceEvaluation && e.length > 1 ? (f.error(
|
|
@@ -2206,13 +2206,13 @@ const K = class K extends B {
|
|
|
2206
2206
|
), [e[0]]) : e;
|
|
2207
2207
|
}
|
|
2208
2208
|
};
|
|
2209
|
-
|
|
2209
|
+
G.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2210
2210
|
"data-if",
|
|
2211
2211
|
"hor-if",
|
|
2212
2212
|
"data-each",
|
|
2213
2213
|
"hor-each"
|
|
2214
2214
|
];
|
|
2215
|
-
let U =
|
|
2215
|
+
let U = G;
|
|
2216
2216
|
class N {
|
|
2217
2217
|
/**
|
|
2218
2218
|
* カスタムイベントを発火します。
|
|
@@ -2222,11 +2222,11 @@ class N {
|
|
|
2222
2222
|
* @param detail イベントの詳細データ
|
|
2223
2223
|
* @param options イベントオプション
|
|
2224
2224
|
*/
|
|
2225
|
-
static dispatch(t, e, r,
|
|
2225
|
+
static dispatch(t, e, r, i) {
|
|
2226
2226
|
const n = new CustomEvent(`haori:${e}`, {
|
|
2227
|
-
bubbles:
|
|
2228
|
-
cancelable:
|
|
2229
|
-
composed:
|
|
2227
|
+
bubbles: i?.bubbles ?? !0,
|
|
2228
|
+
cancelable: i?.cancelable ?? !1,
|
|
2229
|
+
composed: i?.composed ?? !0,
|
|
2230
2230
|
detail: r
|
|
2231
2231
|
});
|
|
2232
2232
|
return t.dispatchEvent(n);
|
|
@@ -2267,11 +2267,11 @@ class N {
|
|
|
2267
2267
|
* @param bytes 取得バイト数
|
|
2268
2268
|
* @param startedAt 開始時刻
|
|
2269
2269
|
*/
|
|
2270
|
-
static importEnd(t, e, r,
|
|
2270
|
+
static importEnd(t, e, r, i) {
|
|
2271
2271
|
N.dispatch(t, "importend", {
|
|
2272
2272
|
url: e,
|
|
2273
2273
|
bytes: r,
|
|
2274
|
-
durationMs: performance.now() -
|
|
2274
|
+
durationMs: performance.now() - i
|
|
2275
2275
|
});
|
|
2276
2276
|
}
|
|
2277
2277
|
/**
|
|
@@ -2292,17 +2292,17 @@ class N {
|
|
|
2292
2292
|
* @param next 変更後のデータ
|
|
2293
2293
|
* @param reason 変更理由
|
|
2294
2294
|
*/
|
|
2295
|
-
static bindChange(t, e, r,
|
|
2296
|
-
const n = [],
|
|
2295
|
+
static bindChange(t, e, r, i = "other") {
|
|
2296
|
+
const n = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
|
|
2297
2297
|
for (const l of o) {
|
|
2298
|
-
const
|
|
2299
|
-
|
|
2298
|
+
const g = e?.[l], p = r[l];
|
|
2299
|
+
g !== p && n.push(l);
|
|
2300
2300
|
}
|
|
2301
2301
|
N.dispatch(t, "bindchange", {
|
|
2302
2302
|
previous: e || {},
|
|
2303
2303
|
next: r,
|
|
2304
2304
|
changedKeys: n,
|
|
2305
|
-
reason:
|
|
2305
|
+
reason: i
|
|
2306
2306
|
});
|
|
2307
2307
|
}
|
|
2308
2308
|
/**
|
|
@@ -2313,12 +2313,12 @@ class N {
|
|
|
2313
2313
|
* @param removed 削除された行のキー
|
|
2314
2314
|
* @param order 現在の順序
|
|
2315
2315
|
*/
|
|
2316
|
-
static eachUpdate(t, e, r,
|
|
2316
|
+
static eachUpdate(t, e, r, i) {
|
|
2317
2317
|
N.dispatch(t, "eachupdate", {
|
|
2318
2318
|
added: e,
|
|
2319
2319
|
removed: r,
|
|
2320
|
-
order:
|
|
2321
|
-
total:
|
|
2320
|
+
order: i,
|
|
2321
|
+
total: i.length
|
|
2322
2322
|
});
|
|
2323
2323
|
}
|
|
2324
2324
|
/**
|
|
@@ -2329,8 +2329,8 @@ class N {
|
|
|
2329
2329
|
* @param index インデックス
|
|
2330
2330
|
* @param item 行データ
|
|
2331
2331
|
*/
|
|
2332
|
-
static rowAdd(t, e, r,
|
|
2333
|
-
N.dispatch(t, "rowadd", { key: e, index: r, item:
|
|
2332
|
+
static rowAdd(t, e, r, i) {
|
|
2333
|
+
N.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
2334
2334
|
}
|
|
2335
2335
|
/**
|
|
2336
2336
|
* rowremoveイベントを発火します。
|
|
@@ -2350,8 +2350,8 @@ class N {
|
|
|
2350
2350
|
* @param from 移動前インデックス
|
|
2351
2351
|
* @param to 移動後インデックス
|
|
2352
2352
|
*/
|
|
2353
|
-
static rowMove(t, e, r,
|
|
2354
|
-
N.dispatch(t, "rowmove", { key: e, from: r, to:
|
|
2353
|
+
static rowMove(t, e, r, i) {
|
|
2354
|
+
N.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
2355
2355
|
}
|
|
2356
2356
|
/**
|
|
2357
2357
|
* showイベントを発火します。
|
|
@@ -2379,11 +2379,11 @@ class N {
|
|
|
2379
2379
|
* @param metadata runtime とメソッド変換情報。
|
|
2380
2380
|
* @return 戻り値はありません。
|
|
2381
2381
|
*/
|
|
2382
|
-
static fetchStart(t, e, r,
|
|
2382
|
+
static fetchStart(t, e, r, i, n) {
|
|
2383
2383
|
N.dispatch(t, "fetchstart", {
|
|
2384
2384
|
url: e,
|
|
2385
2385
|
options: r || {},
|
|
2386
|
-
payload:
|
|
2386
|
+
payload: i,
|
|
2387
2387
|
startedAt: performance.now(),
|
|
2388
2388
|
...n
|
|
2389
2389
|
});
|
|
@@ -2396,11 +2396,11 @@ class N {
|
|
|
2396
2396
|
* @param status HTTPステータス
|
|
2397
2397
|
* @param startedAt 開始時刻
|
|
2398
2398
|
*/
|
|
2399
|
-
static fetchEnd(t, e, r,
|
|
2399
|
+
static fetchEnd(t, e, r, i) {
|
|
2400
2400
|
N.dispatch(t, "fetchend", {
|
|
2401
2401
|
url: e,
|
|
2402
2402
|
status: r,
|
|
2403
|
-
durationMs: performance.now() -
|
|
2403
|
+
durationMs: performance.now() - i
|
|
2404
2404
|
});
|
|
2405
2405
|
}
|
|
2406
2406
|
/**
|
|
@@ -2412,42 +2412,42 @@ class N {
|
|
|
2412
2412
|
* @param status HTTPステータス(存在する場合)
|
|
2413
2413
|
* @param startedAt 開始時刻(存在する場合)
|
|
2414
2414
|
*/
|
|
2415
|
-
static fetchError(t, e, r,
|
|
2415
|
+
static fetchError(t, e, r, i, n) {
|
|
2416
2416
|
N.dispatch(t, "fetcherror", {
|
|
2417
2417
|
url: e,
|
|
2418
|
-
status:
|
|
2418
|
+
status: i,
|
|
2419
2419
|
error: r,
|
|
2420
2420
|
durationMs: n ? performance.now() - n : void 0
|
|
2421
2421
|
});
|
|
2422
2422
|
}
|
|
2423
2423
|
}
|
|
2424
|
-
const
|
|
2424
|
+
const ot = [
|
|
2425
2425
|
"addErrorMessage",
|
|
2426
2426
|
"closeDialog",
|
|
2427
2427
|
"confirm",
|
|
2428
2428
|
"dialog",
|
|
2429
2429
|
"openDialog",
|
|
2430
2430
|
"toast"
|
|
2431
|
-
],
|
|
2432
|
-
function
|
|
2431
|
+
], lt = "__haoriHistoryState__", W = "data-haori-click-lock";
|
|
2432
|
+
function z() {
|
|
2433
2433
|
const t = globalThis.window?.Haori;
|
|
2434
|
-
return
|
|
2434
|
+
return ot.every(
|
|
2435
2435
|
(r) => typeof t?.[r] == "function"
|
|
2436
2436
|
) ? t : X;
|
|
2437
2437
|
}
|
|
2438
|
-
const
|
|
2439
|
-
function
|
|
2440
|
-
return
|
|
2438
|
+
const ut = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2439
|
+
function ct(P) {
|
|
2440
|
+
return ut.has(P.toUpperCase());
|
|
2441
2441
|
}
|
|
2442
|
-
function
|
|
2442
|
+
function ht(P, t) {
|
|
2443
2443
|
for (const [e, r] of Object.entries(t))
|
|
2444
|
-
r !== void 0 && (r === null ? P.append(e, "") : Array.isArray(r) ? r.forEach((
|
|
2445
|
-
P.append(e, String(
|
|
2444
|
+
r !== void 0 && (r === null ? P.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2445
|
+
P.append(e, String(i));
|
|
2446
2446
|
}) : typeof r == "object" || typeof r == "function" ? P.append(e, JSON.stringify(r)) : P.append(e, String(r)));
|
|
2447
2447
|
}
|
|
2448
|
-
function
|
|
2448
|
+
function ft(P, t) {
|
|
2449
2449
|
const e = new URL(P, window.location.href), r = new URLSearchParams(e.search);
|
|
2450
|
-
return
|
|
2450
|
+
return ht(r, t), e.search = r.toString(), e.toString();
|
|
2451
2451
|
}
|
|
2452
2452
|
const c = class c {
|
|
2453
2453
|
/**
|
|
@@ -2470,12 +2470,12 @@ const c = class c {
|
|
|
2470
2470
|
static resolveDataParamString(t, e) {
|
|
2471
2471
|
return t.replace(
|
|
2472
2472
|
c.DATA_PLACEHOLDER_REGEX,
|
|
2473
|
-
(r,
|
|
2474
|
-
const
|
|
2475
|
-
|
|
2473
|
+
(r, i, n) => {
|
|
2474
|
+
const s = j.evaluate(
|
|
2475
|
+
i ?? n ?? "",
|
|
2476
2476
|
e
|
|
2477
2477
|
);
|
|
2478
|
-
return
|
|
2478
|
+
return s == null || Number.isNaN(s) ? "" : encodeURIComponent(typeof s == "object" ? JSON.stringify(s) : String(s));
|
|
2479
2479
|
}
|
|
2480
2480
|
);
|
|
2481
2481
|
}
|
|
@@ -2487,18 +2487,18 @@ const c = class c {
|
|
|
2487
2487
|
* @returns JSON 文字列中なら true
|
|
2488
2488
|
*/
|
|
2489
2489
|
static isJsonStringContext(t, e) {
|
|
2490
|
-
let r = !1,
|
|
2490
|
+
let r = !1, i = !1;
|
|
2491
2491
|
for (let n = 0; n < e; n += 1) {
|
|
2492
|
-
const
|
|
2493
|
-
if (
|
|
2494
|
-
|
|
2492
|
+
const s = t[n];
|
|
2493
|
+
if (i) {
|
|
2494
|
+
i = !1;
|
|
2495
2495
|
continue;
|
|
2496
2496
|
}
|
|
2497
|
-
if (
|
|
2498
|
-
|
|
2497
|
+
if (s === "\\") {
|
|
2498
|
+
i = !0;
|
|
2499
2499
|
continue;
|
|
2500
2500
|
}
|
|
2501
|
-
|
|
2501
|
+
s === '"' && (r = !r);
|
|
2502
2502
|
}
|
|
2503
2503
|
return r;
|
|
2504
2504
|
}
|
|
@@ -2539,12 +2539,12 @@ const c = class c {
|
|
|
2539
2539
|
static resolveDataJsonString(t, e) {
|
|
2540
2540
|
return t.replace(
|
|
2541
2541
|
c.DATA_PLACEHOLDER_REGEX,
|
|
2542
|
-
(r,
|
|
2542
|
+
(r, i, n, s) => {
|
|
2543
2543
|
const a = j.evaluate(
|
|
2544
|
-
|
|
2544
|
+
i ?? n ?? "",
|
|
2545
2545
|
e
|
|
2546
2546
|
);
|
|
2547
|
-
return c.isJsonStringContext(t,
|
|
2547
|
+
return c.isJsonStringContext(t, s) ? c.stringifyJsonTemplateStringContent(a) : c.stringifyJsonTemplateValue(a);
|
|
2548
2548
|
}
|
|
2549
2549
|
);
|
|
2550
2550
|
}
|
|
@@ -2556,13 +2556,13 @@ const c = class c {
|
|
|
2556
2556
|
* @returns 送信データ
|
|
2557
2557
|
*/
|
|
2558
2558
|
static resolveDataAttribute(t, e) {
|
|
2559
|
-
const r = t.getRawAttribute(e),
|
|
2560
|
-
if (
|
|
2561
|
-
return
|
|
2562
|
-
if (typeof
|
|
2559
|
+
const r = t.getRawAttribute(e), i = t.getAttribute(e);
|
|
2560
|
+
if (i && typeof i == "object" && !Array.isArray(i))
|
|
2561
|
+
return i;
|
|
2562
|
+
if (typeof i != "string" || r === null)
|
|
2563
2563
|
return null;
|
|
2564
2564
|
const n = r.trim();
|
|
2565
|
-
return c.SINGLE_PLACEHOLDER_REGEX.test(n) ? R.parseDataBind(
|
|
2565
|
+
return c.SINGLE_PLACEHOLDER_REGEX.test(n) ? R.parseDataBind(i) : n.startsWith("{") || n.startsWith("[") ? R.parseDataBind(
|
|
2566
2566
|
c.resolveDataJsonString(
|
|
2567
2567
|
r,
|
|
2568
2568
|
t.getBindingData()
|
|
@@ -2586,10 +2586,7 @@ const c = class c {
|
|
|
2586
2586
|
if (t.hasAttribute(c.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(c.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2587
2587
|
c.attrName(e, "confirm")
|
|
2588
2588
|
).replace(/\\n/g, `
|
|
2589
|
-
`)), t.hasAttribute(c.attrName(e, "data")) && (r.
|
|
2590
|
-
t,
|
|
2591
|
-
c.attrName(e, "data")
|
|
2592
|
-
)), t.hasAttribute(c.attrName(e, "form"))) {
|
|
2589
|
+
`)), t.hasAttribute(c.attrName(e, "data")) && (r.dataAttrName = c.attrName(e, "data")), t.hasAttribute(c.attrName(e, "form"))) {
|
|
2593
2590
|
const h = t.getRawAttribute(
|
|
2594
2591
|
c.attrName(e, "form")
|
|
2595
2592
|
);
|
|
@@ -2622,17 +2619,17 @@ ${h}
|
|
|
2622
2619
|
}
|
|
2623
2620
|
}
|
|
2624
2621
|
}
|
|
2625
|
-
const
|
|
2626
|
-
n && (r.fetchUrl = t.getAttribute(
|
|
2627
|
-
const
|
|
2622
|
+
const i = c.attrName(e, "fetch"), n = t.hasAttribute(i);
|
|
2623
|
+
n && (r.fetchUrl = t.getAttribute(i));
|
|
2624
|
+
const s = {};
|
|
2628
2625
|
if (e) {
|
|
2629
2626
|
const h = c.attrName(e, "fetch-method");
|
|
2630
|
-
t.hasAttribute(h) && (
|
|
2627
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2631
2628
|
h
|
|
2632
2629
|
));
|
|
2633
2630
|
} else {
|
|
2634
2631
|
const h = c.attrName(null, "method", !0);
|
|
2635
|
-
t.hasAttribute(h) && (
|
|
2632
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2636
2633
|
h
|
|
2637
2634
|
));
|
|
2638
2635
|
}
|
|
@@ -2643,7 +2640,7 @@ ${h}
|
|
|
2643
2640
|
h
|
|
2644
2641
|
);
|
|
2645
2642
|
try {
|
|
2646
|
-
|
|
2643
|
+
s.headers = R.parseDataBind(d);
|
|
2647
2644
|
} catch (b) {
|
|
2648
2645
|
f.error("Haori", `Invalid fetch headers: ${b}`);
|
|
2649
2646
|
}
|
|
@@ -2659,7 +2656,7 @@ ${h}
|
|
|
2659
2656
|
h
|
|
2660
2657
|
);
|
|
2661
2658
|
try {
|
|
2662
|
-
|
|
2659
|
+
s.headers = R.parseDataBind(d);
|
|
2663
2660
|
} catch (b) {
|
|
2664
2661
|
f.error("Haori", `Invalid fetch headers: ${b}`);
|
|
2665
2662
|
}
|
|
@@ -2671,18 +2668,18 @@ ${h}
|
|
|
2671
2668
|
"fetch-content-type"
|
|
2672
2669
|
);
|
|
2673
2670
|
if (t.hasAttribute(h))
|
|
2674
|
-
|
|
2675
|
-
...
|
|
2671
|
+
s.headers = {
|
|
2672
|
+
...s.headers,
|
|
2676
2673
|
"Content-Type": t.getAttribute(h)
|
|
2677
2674
|
};
|
|
2678
|
-
else if (
|
|
2675
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2679
2676
|
let d = !1;
|
|
2680
|
-
|
|
2681
|
-
...
|
|
2677
|
+
s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
|
|
2678
|
+
...s.headers,
|
|
2682
2679
|
"Content-Type": "application/json"
|
|
2683
2680
|
});
|
|
2684
|
-
} else
|
|
2685
|
-
...
|
|
2681
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2682
|
+
...s.headers,
|
|
2686
2683
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2687
2684
|
});
|
|
2688
2685
|
} else {
|
|
@@ -2692,30 +2689,30 @@ ${h}
|
|
|
2692
2689
|
!0
|
|
2693
2690
|
);
|
|
2694
2691
|
if (t.hasAttribute(h))
|
|
2695
|
-
|
|
2696
|
-
...
|
|
2692
|
+
s.headers = {
|
|
2693
|
+
...s.headers,
|
|
2697
2694
|
"Content-Type": t.getAttribute(h)
|
|
2698
2695
|
};
|
|
2699
|
-
else if (
|
|
2696
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2700
2697
|
let d = !1;
|
|
2701
|
-
|
|
2702
|
-
...
|
|
2698
|
+
s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
|
|
2699
|
+
...s.headers,
|
|
2703
2700
|
"Content-Type": "application/json"
|
|
2704
2701
|
});
|
|
2705
|
-
} else
|
|
2706
|
-
...
|
|
2702
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2703
|
+
...s.headers,
|
|
2707
2704
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2708
2705
|
});
|
|
2709
2706
|
}
|
|
2710
|
-
Object.keys(
|
|
2707
|
+
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2711
2708
|
const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
|
|
2712
2709
|
if (t.hasAttribute(a)) {
|
|
2713
2710
|
const h = t.getRawAttribute(a);
|
|
2714
2711
|
if (h) {
|
|
2715
2712
|
const d = document.body.querySelectorAll(h);
|
|
2716
2713
|
d.length > 0 ? (r.bindFragments = [], d.forEach((b) => {
|
|
2717
|
-
const
|
|
2718
|
-
|
|
2714
|
+
const v = w.get(b);
|
|
2715
|
+
v && r.bindFragments.push(v);
|
|
2719
2716
|
})) : f.error(
|
|
2720
2717
|
"Haori",
|
|
2721
2718
|
`Bind element not found: ${h} (${a})`
|
|
@@ -2726,22 +2723,22 @@ ${h}
|
|
|
2726
2723
|
null,
|
|
2727
2724
|
"arg",
|
|
2728
2725
|
!0
|
|
2729
|
-
),
|
|
2726
|
+
), g = c.attrName(
|
|
2730
2727
|
null,
|
|
2731
2728
|
"bind-arg",
|
|
2732
2729
|
!0
|
|
2733
2730
|
);
|
|
2734
2731
|
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(l) ? r.bindArg = t.getRawAttribute(
|
|
2735
2732
|
l
|
|
2736
|
-
) : t.hasAttribute(
|
|
2737
|
-
const
|
|
2738
|
-
if (t.hasAttribute(
|
|
2739
|
-
const h = t.getRawAttribute(
|
|
2733
|
+
) : t.hasAttribute(g) && (r.bindArg = t.getRawAttribute(g));
|
|
2734
|
+
const p = e ? c.attrName(e, "bind-params") : c.attrName(null, "bind-params", !0);
|
|
2735
|
+
if (t.hasAttribute(p)) {
|
|
2736
|
+
const h = t.getRawAttribute(p);
|
|
2740
2737
|
r.bindParams = h.split("&").map((d) => d.trim());
|
|
2741
2738
|
}
|
|
2742
|
-
const
|
|
2743
|
-
if (t.hasAttribute(
|
|
2744
|
-
const h = t.getRawAttribute(
|
|
2739
|
+
const E = e ? c.attrName(e, "bind-append") : c.attrName(null, "bind-append", !0);
|
|
2740
|
+
if (t.hasAttribute(E)) {
|
|
2741
|
+
const h = t.getRawAttribute(E);
|
|
2745
2742
|
r.bindAppendParams = h.split("&").map((d) => d.trim()).filter(Boolean);
|
|
2746
2743
|
}
|
|
2747
2744
|
const T = e ? c.attrName(e, "copy-params") : null;
|
|
@@ -2758,8 +2755,8 @@ ${h}
|
|
|
2758
2755
|
);
|
|
2759
2756
|
if (d) {
|
|
2760
2757
|
const b = document.body.querySelectorAll(d);
|
|
2761
|
-
b.length > 0 ? (r.adjustFragments = [], b.forEach((
|
|
2762
|
-
const y = w.get(
|
|
2758
|
+
b.length > 0 ? (r.adjustFragments = [], b.forEach((v) => {
|
|
2759
|
+
const y = w.get(v);
|
|
2763
2760
|
y && r.adjustFragments.push(y);
|
|
2764
2761
|
})) : f.error(
|
|
2765
2762
|
"Haori",
|
|
@@ -2769,8 +2766,8 @@ ${h}
|
|
|
2769
2766
|
if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
|
|
2770
2767
|
const b = t.getRawAttribute(
|
|
2771
2768
|
c.attrName(e, "adjust-value")
|
|
2772
|
-
),
|
|
2773
|
-
isNaN(
|
|
2769
|
+
), v = Number(b);
|
|
2770
|
+
isNaN(v) || (r.adjustValue = v);
|
|
2774
2771
|
}
|
|
2775
2772
|
}
|
|
2776
2773
|
if (t.hasAttribute(c.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(c.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(c.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(c.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${u.prefix}${e}-after-run`)) {
|
|
@@ -2798,8 +2795,8 @@ ${d}
|
|
|
2798
2795
|
);
|
|
2799
2796
|
const d = t.getRawAttribute(
|
|
2800
2797
|
c.attrName(e, "toast-level")
|
|
2801
|
-
),
|
|
2802
|
-
r.toastLevel =
|
|
2798
|
+
), v = ["info", "warning", "error", "success"].includes(d);
|
|
2799
|
+
r.toastLevel = v ? d : null;
|
|
2803
2800
|
}
|
|
2804
2801
|
if (t.hasAttribute(c.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2805
2802
|
c.attrName(e, "redirect")
|
|
@@ -2807,10 +2804,7 @@ ${d}
|
|
|
2807
2804
|
c.attrName(e, "scroll")
|
|
2808
2805
|
)), t.hasAttribute(c.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2809
2806
|
c.attrName(e, "history")
|
|
2810
|
-
)), t.hasAttribute(c.attrName(e, "history-data")) && (r.
|
|
2811
|
-
t,
|
|
2812
|
-
c.attrName(e, "history-data")
|
|
2813
|
-
)), t.hasAttribute(c.attrName(e, "history-form"))) {
|
|
2807
|
+
)), t.hasAttribute(c.attrName(e, "history-data")) && (r.historyDataAttrName = c.attrName(e, "history-data")), t.hasAttribute(c.attrName(e, "history-form"))) {
|
|
2814
2808
|
const d = t.getRawAttribute(
|
|
2815
2809
|
c.attrName(e, "history-form")
|
|
2816
2810
|
);
|
|
@@ -2826,6 +2820,7 @@ ${d}
|
|
|
2826
2820
|
r.historyFormFragment = A.getFormFragment(t);
|
|
2827
2821
|
}
|
|
2828
2822
|
[
|
|
2823
|
+
"reset-before",
|
|
2829
2824
|
"reset",
|
|
2830
2825
|
"refetch",
|
|
2831
2826
|
"click",
|
|
@@ -2836,12 +2831,15 @@ ${d}
|
|
|
2836
2831
|
const b = c.attrName(e, d);
|
|
2837
2832
|
if (!t.hasAttribute(b))
|
|
2838
2833
|
return;
|
|
2839
|
-
const
|
|
2840
|
-
if (
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2843
|
-
}), y.length === 0 && f.error("Haori", `Element not found: ${
|
|
2834
|
+
const v = t.getRawAttribute(b), y = [];
|
|
2835
|
+
if (v ? (document.body.querySelectorAll(v).forEach((J) => {
|
|
2836
|
+
const et = w.get(J);
|
|
2837
|
+
et && y.push(et);
|
|
2838
|
+
}), y.length === 0 && f.error("Haori", `Element not found: ${v} (${b})`)) : y.push(t), y.length > 0)
|
|
2844
2839
|
switch (d) {
|
|
2840
|
+
case "reset-before":
|
|
2841
|
+
r.resetBeforeFragments = y;
|
|
2842
|
+
break;
|
|
2845
2843
|
case "reset":
|
|
2846
2844
|
r.resetFragments = y;
|
|
2847
2845
|
break;
|
|
@@ -2863,10 +2861,7 @@ ${d}
|
|
|
2863
2861
|
}
|
|
2864
2862
|
});
|
|
2865
2863
|
}
|
|
2866
|
-
if (!e && (t.hasAttribute(c.attrName(null, "data", !0)) && (r.
|
|
2867
|
-
t,
|
|
2868
|
-
c.attrName(null, "data", !0)
|
|
2869
|
-
)), t.hasAttribute(c.attrName(null, "form", !0)))) {
|
|
2864
|
+
if (!e && (t.hasAttribute(c.attrName(null, "data", !0)) && (r.dataAttrName = c.attrName(null, "data", !0)), t.hasAttribute(c.attrName(null, "form", !0)))) {
|
|
2870
2865
|
const h = t.getRawAttribute(
|
|
2871
2866
|
c.attrName(null, "form", !0)
|
|
2872
2867
|
);
|
|
@@ -2933,95 +2928,95 @@ ${d}
|
|
|
2933
2928
|
try {
|
|
2934
2929
|
if (Object.keys(this.options).length === 0 || this.options.formFragment && this.validate(this.options.formFragment) === !1 || !await this.confirm())
|
|
2935
2930
|
return !1;
|
|
2936
|
-
|
|
2931
|
+
this.options.resetBeforeFragments && this.options.resetBeforeFragments.length > 0 && (await Promise.all(
|
|
2932
|
+
this.options.resetBeforeFragments.map(
|
|
2933
|
+
(l) => A.reset(l)
|
|
2934
|
+
)
|
|
2935
|
+
), this.captureHistorySnapshots());
|
|
2936
|
+
const r = this.buildPayload();
|
|
2937
|
+
let i = this.options.fetchUrl, n = this.options.fetchOptions;
|
|
2937
2938
|
if (this.options.beforeCallback) {
|
|
2938
2939
|
const l = this.options.beforeCallback(
|
|
2939
|
-
|
|
2940
|
-
|
|
2940
|
+
i || null,
|
|
2941
|
+
n || null
|
|
2941
2942
|
);
|
|
2942
2943
|
if (l != null) {
|
|
2943
2944
|
if (l === !1 || typeof l == "object" && l.stop)
|
|
2944
2945
|
return !1;
|
|
2945
|
-
typeof l == "object" && (
|
|
2946
|
+
typeof l == "object" && (i = "fetchUrl" in l ? l.fetchUrl : i, n = "fetchOptions" in l ? l.fetchOptions : n);
|
|
2946
2947
|
}
|
|
2947
2948
|
}
|
|
2948
|
-
const
|
|
2949
|
-
if (
|
|
2950
|
-
const l =
|
|
2951
|
-
Object.assign(n, l);
|
|
2952
|
-
}
|
|
2953
|
-
this.options.data && typeof this.options.data == "object" && Object.assign(n, this.options.data);
|
|
2954
|
-
const i = Object.keys(n).length > 0;
|
|
2955
|
-
if (r) {
|
|
2956
|
-
const l = { ...s || {} }, p = new Headers(
|
|
2949
|
+
const s = Object.keys(r).length > 0;
|
|
2950
|
+
if (i) {
|
|
2951
|
+
const l = { ...n || {} }, g = new Headers(
|
|
2957
2952
|
l.headers || void 0
|
|
2958
|
-
),
|
|
2953
|
+
), p = (l.method || "GET").toUpperCase(), E = u.runtime === "demo" && !ct(p), T = E ? "GET" : p;
|
|
2959
2954
|
if (l.method = T, T === "GET" || T === "HEAD" || T === "OPTIONS")
|
|
2960
|
-
|
|
2961
|
-
else if (
|
|
2962
|
-
const d =
|
|
2955
|
+
s && (i = ft(i, r));
|
|
2956
|
+
else if (s) {
|
|
2957
|
+
const d = g.get("Content-Type") || "";
|
|
2963
2958
|
if (/multipart\/form-data/i.test(d)) {
|
|
2964
|
-
|
|
2959
|
+
g.delete("Content-Type");
|
|
2965
2960
|
const b = new FormData();
|
|
2966
|
-
for (const [
|
|
2967
|
-
y == null ? b.append(
|
|
2961
|
+
for (const [v, y] of Object.entries(r))
|
|
2962
|
+
y == null ? b.append(v, "") : y instanceof Blob ? b.append(v, y) : Array.isArray(y) ? y.forEach((x) => b.append(v, String(x))) : typeof y == "object" ? b.append(v, JSON.stringify(y)) : b.append(v, String(y));
|
|
2968
2963
|
l.body = b;
|
|
2969
2964
|
} else if (/application\/x-www-form-urlencoded/i.test(d)) {
|
|
2970
2965
|
const b = new URLSearchParams();
|
|
2971
|
-
for (const [
|
|
2972
|
-
y !== void 0 && (y === null ? b.append(
|
|
2966
|
+
for (const [v, y] of Object.entries(r))
|
|
2967
|
+
y !== void 0 && (y === null ? b.append(v, "") : Array.isArray(y) ? y.forEach((x) => b.append(v, String(x))) : typeof y == "object" ? b.append(v, JSON.stringify(y)) : b.append(v, String(y)));
|
|
2973
2968
|
l.body = b;
|
|
2974
2969
|
} else
|
|
2975
|
-
|
|
2970
|
+
g.set("Content-Type", "application/json"), l.body = JSON.stringify(r);
|
|
2976
2971
|
}
|
|
2977
|
-
l.headers =
|
|
2972
|
+
l.headers = g;
|
|
2978
2973
|
let h;
|
|
2979
|
-
if (
|
|
2974
|
+
if (E && (h = i && new URL(i, window.location.href).search || void 0, g.delete("Content-Type"), f.info("Haori demo fetch normalization", {
|
|
2980
2975
|
runtime: u.runtime,
|
|
2981
|
-
requestedMethod:
|
|
2976
|
+
requestedMethod: p,
|
|
2982
2977
|
effectiveMethod: T,
|
|
2983
2978
|
transportMode: "query-get",
|
|
2984
|
-
url:
|
|
2985
|
-
payload:
|
|
2979
|
+
url: i,
|
|
2980
|
+
payload: s ? r : void 0,
|
|
2986
2981
|
queryString: h
|
|
2987
|
-
})), this.options.targetFragment &&
|
|
2982
|
+
})), this.options.targetFragment && i) {
|
|
2988
2983
|
const d = performance.now(), b = {
|
|
2989
2984
|
runtime: u.runtime,
|
|
2990
|
-
requestedMethod:
|
|
2985
|
+
requestedMethod: p,
|
|
2991
2986
|
effectiveMethod: T,
|
|
2992
|
-
transportMode:
|
|
2993
|
-
...
|
|
2987
|
+
transportMode: E ? "query-get" : "http",
|
|
2988
|
+
...E ? { queryString: h } : {}
|
|
2994
2989
|
};
|
|
2995
2990
|
return N.fetchStart(
|
|
2996
2991
|
this.options.targetFragment.getTarget(),
|
|
2997
|
-
|
|
2992
|
+
i,
|
|
2998
2993
|
l,
|
|
2999
|
-
|
|
2994
|
+
s ? r : void 0,
|
|
3000
2995
|
b
|
|
3001
|
-
), fetch(
|
|
3002
|
-
|
|
3003
|
-
|
|
2996
|
+
), fetch(i, l).then((v) => this.handleFetchResult(
|
|
2997
|
+
v,
|
|
2998
|
+
i || void 0,
|
|
3004
2999
|
d
|
|
3005
|
-
)).catch((
|
|
3006
|
-
throw
|
|
3000
|
+
)).catch((v) => {
|
|
3001
|
+
throw i && N.fetchError(
|
|
3007
3002
|
this.options.targetFragment.getTarget(),
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
),
|
|
3003
|
+
i,
|
|
3004
|
+
v
|
|
3005
|
+
), v;
|
|
3011
3006
|
});
|
|
3012
3007
|
}
|
|
3013
|
-
return fetch(
|
|
3008
|
+
return fetch(i, l).then((d) => this.handleFetchResult(d, i || void 0));
|
|
3014
3009
|
}
|
|
3015
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
3016
|
-
const l = this.options.formFragment,
|
|
3017
|
-
p.setAttribute(
|
|
3010
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
3011
|
+
const l = this.options.formFragment, g = l.getTarget(), p = /* @__PURE__ */ new Set();
|
|
3012
|
+
t && t.appliedDisabledAttribute && this.options.targetFragment && p.add(this.options.targetFragment), g.setAttribute(
|
|
3018
3013
|
`${u.prefix}bind`,
|
|
3019
|
-
JSON.stringify(
|
|
3014
|
+
JSON.stringify(r)
|
|
3020
3015
|
);
|
|
3021
|
-
const
|
|
3022
|
-
Object.assign(
|
|
3016
|
+
const E = l.getBindingData();
|
|
3017
|
+
Object.assign(E, r), await R.setBindingData(g, E, p);
|
|
3023
3018
|
}
|
|
3024
|
-
const a =
|
|
3019
|
+
const a = s ? r : {}, o = new Response(JSON.stringify(a), {
|
|
3025
3020
|
headers: { "Content-Type": "application/json" }
|
|
3026
3021
|
});
|
|
3027
3022
|
return this.handleFetchResult(o);
|
|
@@ -3037,9 +3032,9 @@ ${d}
|
|
|
3037
3032
|
acquireExecutionLock() {
|
|
3038
3033
|
if (this.eventType !== "click" || !this.options.targetFragment)
|
|
3039
3034
|
return null;
|
|
3040
|
-
const
|
|
3041
|
-
return c.RUNNING_CLICK_TARGETS.has(
|
|
3042
|
-
target:
|
|
3035
|
+
const e = this.options.targetFragment.getTarget();
|
|
3036
|
+
return c.RUNNING_CLICK_TARGETS.has(e) || e.matches(":disabled") || e.hasAttribute("disabled") || e.hasAttribute(W) ? !1 : (c.RUNNING_CLICK_TARGETS.add(e), e.setAttribute(W, ""), e.setAttribute("disabled", ""), {
|
|
3037
|
+
target: e,
|
|
3043
3038
|
appliedDisabledAttribute: !0
|
|
3044
3039
|
});
|
|
3045
3040
|
}
|
|
@@ -3050,13 +3045,13 @@ ${d}
|
|
|
3050
3045
|
* @returns 戻り値はありません。
|
|
3051
3046
|
*/
|
|
3052
3047
|
releaseExecutionLock(t) {
|
|
3053
|
-
t && (c.RUNNING_CLICK_TARGETS.delete(t.target), t.appliedDisabledAttribute && t.target.removeAttribute("disabled"));
|
|
3048
|
+
t && (c.RUNNING_CLICK_TARGETS.delete(t.target), t.appliedDisabledAttribute && (t.target.removeAttribute("disabled"), t.target.removeAttribute(W)));
|
|
3054
3049
|
}
|
|
3055
3050
|
/**
|
|
3056
3051
|
* フェッチ後の処理を実行します。
|
|
3057
3052
|
*/
|
|
3058
3053
|
async handleFetchResult(t, e, r) {
|
|
3059
|
-
const
|
|
3054
|
+
const i = z();
|
|
3060
3055
|
if (!t.ok)
|
|
3061
3056
|
return this.options.targetFragment && e && N.fetchError(
|
|
3062
3057
|
this.options.targetFragment.getTarget(),
|
|
@@ -3082,9 +3077,9 @@ ${d}
|
|
|
3082
3077
|
n.push(this.bindResult(t)), 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(
|
|
3083
3078
|
this.options.resetFragments.map((a) => A.reset(a))
|
|
3084
3079
|
), await this.copy();
|
|
3085
|
-
const
|
|
3080
|
+
const s = [];
|
|
3086
3081
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
3087
|
-
|
|
3082
|
+
s.push(new c(a, null).run());
|
|
3088
3083
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
3089
3084
|
const o = a.getTarget();
|
|
3090
3085
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
@@ -3092,11 +3087,11 @@ ${d}
|
|
|
3092
3087
|
);
|
|
3093
3088
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
3094
3089
|
const o = a.getTarget();
|
|
3095
|
-
o instanceof HTMLElement ?
|
|
3090
|
+
o instanceof HTMLElement ? s.push(i.openDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
3096
3091
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
3097
3092
|
const o = a.getTarget();
|
|
3098
|
-
o instanceof HTMLElement ?
|
|
3099
|
-
}), await Promise.all(
|
|
3093
|
+
o instanceof HTMLElement ? s.push(i.closeDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
3094
|
+
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3100
3095
|
this.options.toastMessage,
|
|
3101
3096
|
this.options.toastLevel ?? "info"
|
|
3102
3097
|
), this.pushHistory(), this.options.scrollTarget && document.querySelector(this.options.scrollTarget)?.scrollIntoView({ behavior: "smooth", block: "nearest" }), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
@@ -3109,30 +3104,26 @@ ${d}
|
|
|
3109
3104
|
* 不正 URL・オリジン違反・例外は `Log.error` でログ出力してスキップし、後続処理は継続します。
|
|
3110
3105
|
*/
|
|
3111
3106
|
pushHistory() {
|
|
3112
|
-
const t = this.options.historyUrl !== void 0 && this.options.historyUrl !== null, e = this.
|
|
3113
|
-
if (!(!t && !
|
|
3107
|
+
const t = this.options.historyUrl !== void 0 && this.options.historyUrl !== null, e = this.resolveHistoryDataValues(), r = this.resolveHistoryFormValues(), i = e != null, n = r != null;
|
|
3108
|
+
if (!(!t && !i && !n))
|
|
3114
3109
|
try {
|
|
3115
|
-
const s = t ? this.options.historyUrl : window.location.pathname,
|
|
3116
|
-
if (
|
|
3117
|
-
const
|
|
3110
|
+
const s = t ? this.options.historyUrl : window.location.pathname, a = new URL(s, window.location.href);
|
|
3111
|
+
if (a.origin !== window.location.origin) {
|
|
3112
|
+
const l = "history.pushState: cross-origin URL is not allowed: " + a.toString();
|
|
3118
3113
|
f.error(
|
|
3119
3114
|
"Haori",
|
|
3120
|
-
|
|
3115
|
+
l
|
|
3121
3116
|
);
|
|
3122
3117
|
return;
|
|
3123
3118
|
}
|
|
3124
|
-
const
|
|
3125
|
-
for (const [
|
|
3126
|
-
|
|
3119
|
+
const o = (l) => {
|
|
3120
|
+
for (const [g, p] of Object.entries(l))
|
|
3121
|
+
p != null && (Array.isArray(p) ? p.forEach((E) => a.searchParams.append(g, String(E))) : typeof p == "object" ? a.searchParams.set(g, JSON.stringify(p)) : a.searchParams.set(g, String(p)));
|
|
3127
3122
|
};
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
this.options.historyFormFragment
|
|
3131
|
-
)
|
|
3132
|
-
), history.pushState(
|
|
3133
|
-
{ [ot]: !0 },
|
|
3123
|
+
i && o(e), n && o(r), history.pushState(
|
|
3124
|
+
{ [lt]: !0 },
|
|
3134
3125
|
"",
|
|
3135
|
-
|
|
3126
|
+
a.toString()
|
|
3136
3127
|
);
|
|
3137
3128
|
} catch (s) {
|
|
3138
3129
|
f.error("Haori", `history.pushState failed: ${s}`);
|
|
@@ -3144,45 +3135,45 @@ ${d}
|
|
|
3144
3135
|
async handleFetchError(t) {
|
|
3145
3136
|
let e = null;
|
|
3146
3137
|
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3147
|
-
const r = async (
|
|
3138
|
+
const r = async (s) => {
|
|
3148
3139
|
const a = e ? e.getTarget() : document.body;
|
|
3149
|
-
await
|
|
3150
|
-
},
|
|
3140
|
+
await z().addErrorMessage(a, s);
|
|
3141
|
+
}, i = () => {
|
|
3151
3142
|
if (!this.options.scrollOnError)
|
|
3152
3143
|
return;
|
|
3153
|
-
const
|
|
3154
|
-
(
|
|
3144
|
+
const s = e ? e.getTarget() : document.body;
|
|
3145
|
+
(s.getAttribute("data-message-level") === "error" ? s : s.parentElement?.getAttribute("data-message-level") === "error" ? s.parentElement : s.querySelector('[data-message-level="error"]'))?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3155
3146
|
};
|
|
3156
3147
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
3157
3148
|
try {
|
|
3158
|
-
const
|
|
3159
|
-
if (
|
|
3160
|
-
if (typeof
|
|
3161
|
-
for (const o of
|
|
3149
|
+
const s = await t.json(), a = [];
|
|
3150
|
+
if (s && typeof s == "object") {
|
|
3151
|
+
if (typeof s.message == "string" && a.push({ message: s.message }), Array.isArray(s.messages))
|
|
3152
|
+
for (const o of s.messages)
|
|
3162
3153
|
typeof o == "string" && a.push({ message: o });
|
|
3163
|
-
if (
|
|
3164
|
-
for (const [o, l] of Object.entries(
|
|
3154
|
+
if (s.errors && typeof s.errors == "object")
|
|
3155
|
+
for (const [o, l] of Object.entries(s.errors))
|
|
3165
3156
|
Array.isArray(l) ? a.push({ key: o, message: l.join(`
|
|
3166
3157
|
`) }) : typeof l == "string" ? a.push({ key: o, message: l }) : l != null && a.push({ key: o, message: String(l) });
|
|
3167
3158
|
if (a.length === 0)
|
|
3168
|
-
for (const [o, l] of Object.entries(
|
|
3159
|
+
for (const [o, l] of Object.entries(s))
|
|
3169
3160
|
o === "message" || o === "messages" || o === "errors" || (Array.isArray(l) ? a.push({ key: o, message: l.join(`
|
|
3170
3161
|
`) }) : typeof l == "string" && a.push({ key: o, message: l }));
|
|
3171
3162
|
}
|
|
3172
3163
|
if (a.length === 0)
|
|
3173
|
-
return await r(`${t.status} ${t.statusText}`),
|
|
3164
|
+
return await r(`${t.status} ${t.statusText}`), i(), !1;
|
|
3174
3165
|
for (const o of a)
|
|
3175
3166
|
o.key && e ? await A.addErrorMessage(e, o.key, o.message) : await r(o.message);
|
|
3176
|
-
return
|
|
3167
|
+
return i(), !1;
|
|
3177
3168
|
} catch {
|
|
3178
3169
|
}
|
|
3179
3170
|
try {
|
|
3180
|
-
const
|
|
3181
|
-
|
|
3171
|
+
const s = await t.text();
|
|
3172
|
+
s && s.trim().length > 0 ? await r(s.trim()) : await r(`${t.status} ${t.statusText}`);
|
|
3182
3173
|
} catch {
|
|
3183
3174
|
await r(`${t.status} ${t.statusText}`);
|
|
3184
3175
|
}
|
|
3185
|
-
return
|
|
3176
|
+
return i(), !1;
|
|
3186
3177
|
}
|
|
3187
3178
|
/**
|
|
3188
3179
|
* 対象のフラグメント以下の入力要素に対してバリデーションを実行します。
|
|
@@ -3207,8 +3198,8 @@ ${d}
|
|
|
3207
3198
|
findFirstInvalid(t) {
|
|
3208
3199
|
let e = null;
|
|
3209
3200
|
for (const r of t.getChildElementFragments().reverse()) {
|
|
3210
|
-
const
|
|
3211
|
-
|
|
3201
|
+
const i = this.findFirstInvalid(r);
|
|
3202
|
+
i !== null && (e = i);
|
|
3212
3203
|
}
|
|
3213
3204
|
return this.checkOne(t) ? e : t.getTarget();
|
|
3214
3205
|
}
|
|
@@ -3231,7 +3222,7 @@ ${d}
|
|
|
3231
3222
|
*/
|
|
3232
3223
|
confirm() {
|
|
3233
3224
|
const t = this.options.confirmMessage;
|
|
3234
|
-
return t == null ? Promise.resolve(!0) :
|
|
3225
|
+
return t == null ? Promise.resolve(!0) : z().confirm(t);
|
|
3235
3226
|
}
|
|
3236
3227
|
/**
|
|
3237
3228
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -3242,24 +3233,24 @@ ${d}
|
|
|
3242
3233
|
return !this.options.bindFragments || this.options.bindFragments.length === 0 ? Promise.resolve() : (t.headers.get("Content-Type")?.includes("application/json") ? t.json() : t.text()).then((r) => {
|
|
3243
3234
|
if (this.options.bindParams) {
|
|
3244
3235
|
const n = {};
|
|
3245
|
-
this.options.bindParams.forEach((
|
|
3246
|
-
r && typeof r == "object" &&
|
|
3236
|
+
this.options.bindParams.forEach((s) => {
|
|
3237
|
+
r && typeof r == "object" && s in r && (n[s] = r[s]);
|
|
3247
3238
|
}), r = n;
|
|
3248
3239
|
}
|
|
3249
|
-
const
|
|
3240
|
+
const i = [];
|
|
3250
3241
|
if (this.options.bindArg)
|
|
3251
3242
|
this.options.bindFragments.forEach((n) => {
|
|
3252
|
-
const
|
|
3243
|
+
const s = n.getBindingData(), a = this.options.bindArg;
|
|
3253
3244
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3254
|
-
const o =
|
|
3255
|
-
|
|
3245
|
+
const o = s[a], l = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3246
|
+
s[a] = this.mergeAppendBindingData(
|
|
3256
3247
|
n,
|
|
3257
3248
|
r,
|
|
3258
3249
|
l
|
|
3259
3250
|
);
|
|
3260
3251
|
} else
|
|
3261
|
-
|
|
3262
|
-
|
|
3252
|
+
s[a] = r;
|
|
3253
|
+
i.push(R.setBindingData(n.getTarget(), s));
|
|
3263
3254
|
});
|
|
3264
3255
|
else {
|
|
3265
3256
|
if (typeof r == "string")
|
|
@@ -3267,19 +3258,19 @@ ${d}
|
|
|
3267
3258
|
new Error("string data cannot be bound without a bindArg.")
|
|
3268
3259
|
);
|
|
3269
3260
|
this.options.bindFragments.forEach((n) => {
|
|
3270
|
-
const
|
|
3261
|
+
const s = this.mergeAppendBindingData(
|
|
3271
3262
|
n,
|
|
3272
3263
|
r
|
|
3273
3264
|
);
|
|
3274
|
-
|
|
3265
|
+
i.push(
|
|
3275
3266
|
R.setBindingData(
|
|
3276
3267
|
n.getTarget(),
|
|
3277
|
-
|
|
3268
|
+
s
|
|
3278
3269
|
)
|
|
3279
3270
|
);
|
|
3280
3271
|
});
|
|
3281
3272
|
}
|
|
3282
|
-
return Promise.all(
|
|
3273
|
+
return Promise.all(i).then(() => {
|
|
3283
3274
|
});
|
|
3284
3275
|
});
|
|
3285
3276
|
}
|
|
@@ -3289,12 +3280,12 @@ ${d}
|
|
|
3289
3280
|
mergeAppendBindingData(t, e, r = t.getBindingData()) {
|
|
3290
3281
|
if (!this.options.bindAppendParams || this.options.bindAppendParams.length === 0)
|
|
3291
3282
|
return e;
|
|
3292
|
-
const
|
|
3293
|
-
for (const
|
|
3294
|
-
const a = s
|
|
3295
|
-
Array.isArray(o) && Array.isArray(a) && (s
|
|
3283
|
+
const i = { ...e }, n = r;
|
|
3284
|
+
for (const s of this.options.bindAppendParams) {
|
|
3285
|
+
const a = i[s], o = n[s];
|
|
3286
|
+
Array.isArray(o) && Array.isArray(a) && (i[s] = o.concat(a));
|
|
3296
3287
|
}
|
|
3297
|
-
return
|
|
3288
|
+
return i;
|
|
3298
3289
|
}
|
|
3299
3290
|
/**
|
|
3300
3291
|
* 指定されたフラグメントへバインディングデータをコピーします。
|
|
@@ -3302,12 +3293,12 @@ ${d}
|
|
|
3302
3293
|
copy() {
|
|
3303
3294
|
if (!this.options.copyFragments || this.options.copyFragments.length === 0)
|
|
3304
3295
|
return Promise.resolve();
|
|
3305
|
-
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((
|
|
3296
|
+
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((i) => {
|
|
3306
3297
|
const n = {
|
|
3307
|
-
...
|
|
3298
|
+
...i.getBindingData(),
|
|
3308
3299
|
...e
|
|
3309
3300
|
};
|
|
3310
|
-
return R.setBindingData(
|
|
3301
|
+
return R.setBindingData(i.getTarget(), n);
|
|
3311
3302
|
});
|
|
3312
3303
|
return Promise.all(r).then(() => {
|
|
3313
3304
|
});
|
|
@@ -3318,6 +3309,53 @@ ${d}
|
|
|
3318
3309
|
resolveCopySourceData() {
|
|
3319
3310
|
return this.options.formFragment ? A.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3320
3311
|
}
|
|
3312
|
+
/**
|
|
3313
|
+
* data 属性とフォーム値を統合した送信データを作成します。
|
|
3314
|
+
*
|
|
3315
|
+
* @returns 送信データ。
|
|
3316
|
+
*/
|
|
3317
|
+
buildPayload() {
|
|
3318
|
+
const t = {};
|
|
3319
|
+
if (this.options.formFragment && Object.assign(t, A.getValues(this.options.formFragment)), this.options.data && typeof this.options.data == "object" && Object.assign(t, this.options.data), this.options.targetFragment && this.options.dataAttrName) {
|
|
3320
|
+
const e = c.resolveDataAttribute(
|
|
3321
|
+
this.options.targetFragment,
|
|
3322
|
+
this.options.dataAttrName
|
|
3323
|
+
);
|
|
3324
|
+
e && Object.assign(t, e);
|
|
3325
|
+
}
|
|
3326
|
+
return t;
|
|
3327
|
+
}
|
|
3328
|
+
/**
|
|
3329
|
+
* reset-before 後の history 用スナップショットを保存します。
|
|
3330
|
+
*/
|
|
3331
|
+
captureHistorySnapshots() {
|
|
3332
|
+
this.options.targetFragment && this.options.historyDataAttrName ? this.historyDataSnapshot = c.resolveDataAttribute(
|
|
3333
|
+
this.options.targetFragment,
|
|
3334
|
+
this.options.historyDataAttrName
|
|
3335
|
+
) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? A.getValues(this.options.historyFormFragment) : void 0;
|
|
3336
|
+
}
|
|
3337
|
+
/**
|
|
3338
|
+
* history-data の評価値を取得します。
|
|
3339
|
+
*
|
|
3340
|
+
* @returns history-data の評価値。
|
|
3341
|
+
*/
|
|
3342
|
+
resolveHistoryDataValues() {
|
|
3343
|
+
return this.historyDataSnapshot !== void 0 ? this.historyDataSnapshot : this.options.targetFragment && this.options.historyDataAttrName ? c.resolveDataAttribute(
|
|
3344
|
+
this.options.targetFragment,
|
|
3345
|
+
this.options.historyDataAttrName
|
|
3346
|
+
) : this.options.historyData;
|
|
3347
|
+
}
|
|
3348
|
+
/**
|
|
3349
|
+
* history-form の評価値を取得します。
|
|
3350
|
+
*
|
|
3351
|
+
* @returns history-form の評価値。
|
|
3352
|
+
*/
|
|
3353
|
+
resolveHistoryFormValues() {
|
|
3354
|
+
if (this.historyFormSnapshot !== void 0)
|
|
3355
|
+
return this.historyFormSnapshot;
|
|
3356
|
+
if (this.options.historyFormFragment)
|
|
3357
|
+
return A.getValues(this.options.historyFormFragment);
|
|
3358
|
+
}
|
|
3321
3359
|
/**
|
|
3322
3360
|
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
3323
3361
|
*/
|
|
@@ -3337,9 +3375,9 @@ ${d}
|
|
|
3337
3375
|
return Promise.resolve();
|
|
3338
3376
|
const t = this.options.adjustValue ?? 0, e = [];
|
|
3339
3377
|
for (const r of this.options.adjustFragments) {
|
|
3340
|
-
let
|
|
3341
|
-
(
|
|
3342
|
-
let n = Number(
|
|
3378
|
+
let i = r.getValue();
|
|
3379
|
+
(i == null || i === "") && (i = "0");
|
|
3380
|
+
let n = Number(i);
|
|
3343
3381
|
isNaN(n) && (n = 0), n += t, e.push(r.setValue(String(n)));
|
|
3344
3382
|
}
|
|
3345
3383
|
return Promise.all(e).then(() => {
|
|
@@ -3387,7 +3425,7 @@ ${d}
|
|
|
3387
3425
|
if (!t)
|
|
3388
3426
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3389
3427
|
const e = t.getParent();
|
|
3390
|
-
return e && e.getChildElementFragments().filter((
|
|
3428
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${u.prefix}each-before`) && !i.hasAttribute(`${u.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3391
3429
|
}
|
|
3392
3430
|
/**
|
|
3393
3431
|
* 前の行へ移動します。
|
|
@@ -3426,7 +3464,7 @@ ${d}
|
|
|
3426
3464
|
};
|
|
3427
3465
|
c.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, c.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/, c.RUNNING_CLICK_TARGETS = /* @__PURE__ */ new WeakSet();
|
|
3428
3466
|
let V = c;
|
|
3429
|
-
class
|
|
3467
|
+
class dt {
|
|
3430
3468
|
/**
|
|
3431
3469
|
* URLのクエリパラメータを取得します。
|
|
3432
3470
|
*
|
|
@@ -3434,12 +3472,12 @@ class ft {
|
|
|
3434
3472
|
*/
|
|
3435
3473
|
static readParams() {
|
|
3436
3474
|
const t = {}, e = window.location.search;
|
|
3437
|
-
return new URLSearchParams(e).forEach((
|
|
3438
|
-
t[n] =
|
|
3475
|
+
return new URLSearchParams(e).forEach((i, n) => {
|
|
3476
|
+
t[n] = i;
|
|
3439
3477
|
}), t;
|
|
3440
3478
|
}
|
|
3441
3479
|
}
|
|
3442
|
-
class
|
|
3480
|
+
class pt {
|
|
3443
3481
|
/**
|
|
3444
3482
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3445
3483
|
*
|
|
@@ -3463,21 +3501,21 @@ class dt {
|
|
|
3463
3501
|
const n = `${r.status} ${r.statusText}`;
|
|
3464
3502
|
throw f.error("[Haori]", "Import HTTP error:", t, n), new Error(`Failed to load ${t}: ${n}`);
|
|
3465
3503
|
}
|
|
3466
|
-
let
|
|
3504
|
+
let i;
|
|
3467
3505
|
try {
|
|
3468
|
-
|
|
3506
|
+
i = await r.text();
|
|
3469
3507
|
} catch (n) {
|
|
3470
3508
|
throw f.error("[Haori]", "Failed to read response text:", t, n), new Error(`Failed to read response from: ${t}`);
|
|
3471
3509
|
}
|
|
3472
3510
|
try {
|
|
3473
|
-
const
|
|
3474
|
-
return
|
|
3511
|
+
const s = new DOMParser().parseFromString(i, "text/html");
|
|
3512
|
+
return s && s.body ? s.body.innerHTML : (f.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3475
3513
|
} catch (n) {
|
|
3476
|
-
return f.error("[Haori]", "Failed to parse imported HTML:", t, n),
|
|
3514
|
+
return f.error("[Haori]", "Failed to parse imported HTML:", t, n), i;
|
|
3477
3515
|
}
|
|
3478
3516
|
}
|
|
3479
3517
|
}
|
|
3480
|
-
const
|
|
3518
|
+
const m = class m {
|
|
3481
3519
|
/**
|
|
3482
3520
|
* 遅延属性かどうか(完全名で判定)を判定します。
|
|
3483
3521
|
*
|
|
@@ -3485,7 +3523,7 @@ const g = class g {
|
|
|
3485
3523
|
* @returns 遅延属性かどうか
|
|
3486
3524
|
*/
|
|
3487
3525
|
static isDeferredAttributeName(t) {
|
|
3488
|
-
return
|
|
3526
|
+
return m.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3489
3527
|
(e) => t === `${u.prefix}${e}`
|
|
3490
3528
|
);
|
|
3491
3529
|
}
|
|
@@ -3496,7 +3534,7 @@ const g = class g {
|
|
|
3496
3534
|
* @returns 除外対象かどうか
|
|
3497
3535
|
*/
|
|
3498
3536
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3499
|
-
return
|
|
3537
|
+
return m.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3500
3538
|
(e) => t === `${u.prefix}${e}`
|
|
3501
3539
|
);
|
|
3502
3540
|
}
|
|
@@ -3508,7 +3546,7 @@ const g = class g {
|
|
|
3508
3546
|
* @returns 再評価する場合は true
|
|
3509
3547
|
*/
|
|
3510
3548
|
static shouldReevaluateAttribute(t, e) {
|
|
3511
|
-
return e !== null && !
|
|
3549
|
+
return e !== null && !m.isEvaluateAllExcludedAttributeName(t) && m.ATTRIBUTE_PLACEHOLDER_REGEX.test(e);
|
|
3512
3550
|
}
|
|
3513
3551
|
/**
|
|
3514
3552
|
* data-attr-* 形式の属性名から実際に更新する属性名を取得します。
|
|
@@ -3517,7 +3555,7 @@ const g = class g {
|
|
|
3517
3555
|
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
3518
3556
|
*/
|
|
3519
3557
|
static getAliasedAttributeName(t) {
|
|
3520
|
-
const e = `${u.prefix}${
|
|
3558
|
+
const e = `${u.prefix}${m.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
3521
3559
|
return !t.startsWith(e) || t.length <= e.length ? null : t.slice(e.length);
|
|
3522
3560
|
}
|
|
3523
3561
|
/**
|
|
@@ -3529,8 +3567,8 @@ const g = class g {
|
|
|
3529
3567
|
*/
|
|
3530
3568
|
static isAliasedAttributeReflection(t, e) {
|
|
3531
3569
|
const r = w.get(t);
|
|
3532
|
-
return r instanceof
|
|
3533
|
-
`${u.prefix}${
|
|
3570
|
+
return r instanceof D ? r.hasAttribute(
|
|
3571
|
+
`${u.prefix}${m.ATTRIBUTE_ALIAS_SUFFIX}${e}`
|
|
3534
3572
|
) : !1;
|
|
3535
3573
|
}
|
|
3536
3574
|
/**
|
|
@@ -3543,9 +3581,9 @@ const g = class g {
|
|
|
3543
3581
|
static reevaluateInterpolatedAttributes(t) {
|
|
3544
3582
|
let e = Promise.resolve();
|
|
3545
3583
|
for (const r of t.getAttributeNames()) {
|
|
3546
|
-
const
|
|
3547
|
-
|
|
3548
|
-
() =>
|
|
3584
|
+
const i = t.getRawAttribute(r);
|
|
3585
|
+
m.shouldReevaluateAttribute(r, i) && (e = e.then(
|
|
3586
|
+
() => m.setAttribute(t.getTarget(), r, i)
|
|
3549
3587
|
));
|
|
3550
3588
|
}
|
|
3551
3589
|
return e.then(() => {
|
|
@@ -3563,39 +3601,39 @@ const g = class g {
|
|
|
3563
3601
|
return Promise.resolve();
|
|
3564
3602
|
t.parentNode && (w.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3565
3603
|
let r = Promise.resolve();
|
|
3566
|
-
const
|
|
3567
|
-
for (const n of
|
|
3568
|
-
const
|
|
3569
|
-
e.hasAttribute(
|
|
3570
|
-
() =>
|
|
3604
|
+
const i = /* @__PURE__ */ new Set();
|
|
3605
|
+
for (const n of m.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3606
|
+
const s = u.prefix + n;
|
|
3607
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3608
|
+
() => m.setAttribute(
|
|
3571
3609
|
e.getTarget(),
|
|
3572
|
-
|
|
3573
|
-
e.getRawAttribute(
|
|
3610
|
+
s,
|
|
3611
|
+
e.getRawAttribute(s)
|
|
3574
3612
|
)
|
|
3575
|
-
),
|
|
3613
|
+
), i.add(s));
|
|
3576
3614
|
}
|
|
3577
3615
|
for (const n of e.getAttributeNames()) {
|
|
3578
|
-
if (
|
|
3616
|
+
if (i.has(n) || m.isDeferredAttributeName(n))
|
|
3579
3617
|
continue;
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3582
|
-
() =>
|
|
3618
|
+
const s = e.getRawAttribute(n);
|
|
3619
|
+
s !== null && (r = r.then(
|
|
3620
|
+
() => m.setAttribute(e.getTarget(), n, s)
|
|
3583
3621
|
));
|
|
3584
3622
|
}
|
|
3585
|
-
for (const n of
|
|
3586
|
-
const
|
|
3587
|
-
e.hasAttribute(
|
|
3588
|
-
() =>
|
|
3623
|
+
for (const n of m.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3624
|
+
const s = u.prefix + n;
|
|
3625
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3626
|
+
() => m.setAttribute(
|
|
3589
3627
|
e.getTarget(),
|
|
3590
|
-
|
|
3591
|
-
e.getRawAttribute(
|
|
3628
|
+
s,
|
|
3629
|
+
e.getRawAttribute(s)
|
|
3592
3630
|
)
|
|
3593
|
-
),
|
|
3631
|
+
), i.add(s));
|
|
3594
3632
|
}
|
|
3595
3633
|
return r.then(() => {
|
|
3596
3634
|
const n = [];
|
|
3597
|
-
return e.getChildren().forEach((
|
|
3598
|
-
|
|
3635
|
+
return e.getChildren().forEach((s) => {
|
|
3636
|
+
s instanceof D ? n.push(m.scan(s.getTarget())) : s instanceof O && n.push(m.evaluateText(s));
|
|
3599
3637
|
}), Promise.all(n).then(() => {
|
|
3600
3638
|
});
|
|
3601
3639
|
}).then(() => {
|
|
@@ -3610,26 +3648,26 @@ const g = class g {
|
|
|
3610
3648
|
* @param value 属性値
|
|
3611
3649
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3612
3650
|
*/
|
|
3613
|
-
static setAttribute(t, e, r,
|
|
3614
|
-
const n = w.get(t),
|
|
3615
|
-
if (
|
|
3616
|
-
return r === null ? n.removeAliasedAttribute(e,
|
|
3651
|
+
static setAttribute(t, e, r, i = !1) {
|
|
3652
|
+
const n = w.get(t), s = m.getAliasedAttributeName(e);
|
|
3653
|
+
if (s !== null)
|
|
3654
|
+
return r === null ? n.removeAliasedAttribute(e, s) : n.setAliasedAttribute(
|
|
3617
3655
|
e,
|
|
3618
|
-
|
|
3656
|
+
s,
|
|
3619
3657
|
r,
|
|
3620
|
-
|
|
3658
|
+
i
|
|
3621
3659
|
);
|
|
3622
3660
|
const a = [];
|
|
3623
3661
|
switch (e) {
|
|
3624
3662
|
case `${u.prefix}bind`: {
|
|
3625
|
-
r === null ? (n.clearBindingDataCache(), n.setBindingData({})) : n.setBindingData(
|
|
3663
|
+
r === null ? (n.clearBindingDataCache(), n.setBindingData({})) : n.setBindingData(m.parseDataBind(r));
|
|
3626
3664
|
break;
|
|
3627
3665
|
}
|
|
3628
3666
|
case `${u.prefix}if`:
|
|
3629
|
-
a.push(
|
|
3667
|
+
a.push(m.evaluateIf(n));
|
|
3630
3668
|
break;
|
|
3631
3669
|
case `${u.prefix}each`:
|
|
3632
|
-
a.push(
|
|
3670
|
+
a.push(m.evaluateEach(n));
|
|
3633
3671
|
break;
|
|
3634
3672
|
case `${u.prefix}fetch`:
|
|
3635
3673
|
a.push(
|
|
@@ -3641,39 +3679,39 @@ const g = class g {
|
|
|
3641
3679
|
if (typeof r == "string") {
|
|
3642
3680
|
const o = n.getTarget(), l = performance.now();
|
|
3643
3681
|
o.setAttribute(`${u.prefix}importing`, ""), N.importStart(o, r), a.push(
|
|
3644
|
-
|
|
3645
|
-
const
|
|
3682
|
+
pt.load(r).then((g) => {
|
|
3683
|
+
const p = new TextEncoder().encode(g).length;
|
|
3646
3684
|
return F.enqueue(() => {
|
|
3647
|
-
o.innerHTML =
|
|
3685
|
+
o.innerHTML = g;
|
|
3648
3686
|
}).then(() => {
|
|
3649
|
-
if (o.removeAttribute(`${u.prefix}importing`), N.importEnd(o, r,
|
|
3650
|
-
const
|
|
3687
|
+
if (o.removeAttribute(`${u.prefix}importing`), N.importEnd(o, r, p, l), !document.body.hasAttribute("data-haori-ready")) {
|
|
3688
|
+
const E = [];
|
|
3651
3689
|
return o.childNodes.forEach((T) => {
|
|
3652
3690
|
const h = w.get(T);
|
|
3653
|
-
h instanceof
|
|
3654
|
-
}), Promise.all(
|
|
3691
|
+
h instanceof D ? E.push(m.scan(h.getTarget())) : h instanceof O && E.push(m.evaluateText(h));
|
|
3692
|
+
}), Promise.all(E).then(() => {
|
|
3655
3693
|
});
|
|
3656
3694
|
}
|
|
3657
3695
|
});
|
|
3658
|
-
}).catch((
|
|
3659
|
-
o.removeAttribute(`${u.prefix}importing`), N.importError(o, r,
|
|
3696
|
+
}).catch((g) => {
|
|
3697
|
+
o.removeAttribute(`${u.prefix}importing`), N.importError(o, r, g), f.error("[Haori]", "Failed to import HTML:", r, g);
|
|
3660
3698
|
})
|
|
3661
3699
|
);
|
|
3662
3700
|
}
|
|
3663
3701
|
break;
|
|
3664
3702
|
}
|
|
3665
3703
|
case `${u.prefix}url-param`: {
|
|
3666
|
-
const o = n.getAttribute(`${u.prefix}url-arg`), l =
|
|
3704
|
+
const o = n.getAttribute(`${u.prefix}url-arg`), l = dt.readParams();
|
|
3667
3705
|
if (o === null)
|
|
3668
|
-
a.push(
|
|
3706
|
+
a.push(m.setBindingData(t, l));
|
|
3669
3707
|
else {
|
|
3670
|
-
const
|
|
3671
|
-
|
|
3708
|
+
const g = n.getRawBindingData() || {};
|
|
3709
|
+
g[String(o)] = l, a.push(m.setBindingData(t, g));
|
|
3672
3710
|
}
|
|
3673
3711
|
break;
|
|
3674
3712
|
}
|
|
3675
3713
|
}
|
|
3676
|
-
return r === null ? a.push(n.removeAttribute(e)) : a.push(n.setAttribute(e, r,
|
|
3714
|
+
return r === null ? a.push(n.removeAttribute(e)) : a.push(n.setAttribute(e, r, i)), Promise.all(a).then(() => {
|
|
3677
3715
|
});
|
|
3678
3716
|
}
|
|
3679
3717
|
/**
|
|
@@ -3684,18 +3722,18 @@ const g = class g {
|
|
|
3684
3722
|
* @param value 属性値
|
|
3685
3723
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3686
3724
|
*/
|
|
3687
|
-
static setBindingData(t, e) {
|
|
3688
|
-
const
|
|
3689
|
-
|
|
3690
|
-
let
|
|
3725
|
+
static setBindingData(t, e, r = /* @__PURE__ */ new Set()) {
|
|
3726
|
+
const i = w.get(t), n = i.getRawBindingData();
|
|
3727
|
+
i.setBindingData(e);
|
|
3728
|
+
let s = i.setAttribute(
|
|
3691
3729
|
`${u.prefix}bind`,
|
|
3692
3730
|
JSON.stringify(e)
|
|
3693
3731
|
);
|
|
3694
3732
|
if (t.tagName === "FORM") {
|
|
3695
|
-
const
|
|
3696
|
-
|
|
3733
|
+
const a = i.getAttribute(`${u.prefix}form-arg`), o = a && e[String(a)] && typeof e[String(a)] == "object" && !Array.isArray(e[String(a)]) ? e[String(a)] : a ? {} : e;
|
|
3734
|
+
s = s.then(() => A.syncValues(i, o));
|
|
3697
3735
|
}
|
|
3698
|
-
return
|
|
3736
|
+
return s = s.then(() => m.evaluateAll(i, r)), N.bindChange(t, n, e, "manual"), s.then(() => {
|
|
3699
3737
|
});
|
|
3700
3738
|
}
|
|
3701
3739
|
/**
|
|
@@ -3713,8 +3751,8 @@ const g = class g {
|
|
|
3713
3751
|
}
|
|
3714
3752
|
else {
|
|
3715
3753
|
const e = new URLSearchParams(t), r = {};
|
|
3716
|
-
for (const [
|
|
3717
|
-
r[
|
|
3754
|
+
for (const [i, n] of e.entries())
|
|
3755
|
+
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(n) : r[i] = [r[i], n] : r[i] = n;
|
|
3718
3756
|
return r;
|
|
3719
3757
|
}
|
|
3720
3758
|
}
|
|
@@ -3728,8 +3766,8 @@ const g = class g {
|
|
|
3728
3766
|
const r = w.get(t);
|
|
3729
3767
|
if (r.isSkipMutationNodes())
|
|
3730
3768
|
return;
|
|
3731
|
-
const
|
|
3732
|
-
n && (r.insertBefore(n,
|
|
3769
|
+
const i = w.get(e.nextSibling), n = w.get(e);
|
|
3770
|
+
n && (r.insertBefore(n, i), n instanceof D ? m.scan(n.getTarget()) : n instanceof O && m.evaluateText(n));
|
|
3733
3771
|
}
|
|
3734
3772
|
/**
|
|
3735
3773
|
* ノードを親要素から削除します。
|
|
@@ -3767,15 +3805,15 @@ const g = class g {
|
|
|
3767
3805
|
const r = w.get(t);
|
|
3768
3806
|
if (r.getValue() === e)
|
|
3769
3807
|
return Promise.resolve();
|
|
3770
|
-
const
|
|
3771
|
-
|
|
3772
|
-
const n =
|
|
3808
|
+
const i = [];
|
|
3809
|
+
i.push(r.setValue(e));
|
|
3810
|
+
const n = m.getFormFragment(r);
|
|
3773
3811
|
if (n) {
|
|
3774
|
-
const
|
|
3812
|
+
const s = A.getValues(n), a = n.getAttribute(`${u.prefix}form-arg`);
|
|
3775
3813
|
let o;
|
|
3776
|
-
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] =
|
|
3814
|
+
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(m.setBindingData(n.getTarget(), o));
|
|
3777
3815
|
}
|
|
3778
|
-
return Promise.all(
|
|
3816
|
+
return Promise.all(i).then(() => {
|
|
3779
3817
|
});
|
|
3780
3818
|
}
|
|
3781
3819
|
/**
|
|
@@ -3788,7 +3826,7 @@ const g = class g {
|
|
|
3788
3826
|
if (t.getTarget() instanceof HTMLFormElement)
|
|
3789
3827
|
return t;
|
|
3790
3828
|
const e = t.getParent();
|
|
3791
|
-
return e ?
|
|
3829
|
+
return e ? m.getFormFragment(e) : null;
|
|
3792
3830
|
}
|
|
3793
3831
|
/**
|
|
3794
3832
|
* フラグメントとその子要素を評価します。
|
|
@@ -3796,11 +3834,13 @@ const g = class g {
|
|
|
3796
3834
|
* @param fragment 対象フラグメント
|
|
3797
3835
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3798
3836
|
*/
|
|
3799
|
-
static evaluateAll(t) {
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
}), Promise.all(
|
|
3837
|
+
static evaluateAll(t, e = /* @__PURE__ */ new Set()) {
|
|
3838
|
+
if (e.has(t))
|
|
3839
|
+
return Promise.resolve();
|
|
3840
|
+
const r = [];
|
|
3841
|
+
return r.push(m.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${u.prefix}if`) && r.push(m.evaluateIf(t)), t.hasAttribute(`${u.prefix}each`) ? Promise.all(r).then(() => m.evaluateEach(t)) : (t.getChildren().forEach((i) => {
|
|
3842
|
+
i instanceof D ? r.push(m.evaluateAll(i, e)) : i instanceof O && r.push(m.evaluateText(i));
|
|
3843
|
+
}), Promise.all(r).then(() => {
|
|
3804
3844
|
}));
|
|
3805
3845
|
}
|
|
3806
3846
|
/**
|
|
@@ -3828,14 +3868,14 @@ const g = class g {
|
|
|
3828
3868
|
})
|
|
3829
3869
|
);
|
|
3830
3870
|
else {
|
|
3831
|
-
const
|
|
3871
|
+
const i = [];
|
|
3832
3872
|
t.getChildren().forEach((n) => {
|
|
3833
|
-
n instanceof
|
|
3873
|
+
n instanceof D ? i.push(m.evaluateAll(n)) : n instanceof O && i.push(m.evaluateText(n));
|
|
3834
3874
|
}), e.push(
|
|
3835
3875
|
t.show().then(() => {
|
|
3836
3876
|
N.show(t.getTarget());
|
|
3837
3877
|
})
|
|
3838
|
-
), e.push(Promise.all(
|
|
3878
|
+
), e.push(Promise.all(i).then(() => {
|
|
3839
3879
|
}));
|
|
3840
3880
|
}
|
|
3841
3881
|
return Promise.all(e).then(() => {
|
|
@@ -3852,14 +3892,14 @@ const g = class g {
|
|
|
3852
3892
|
return Promise.resolve();
|
|
3853
3893
|
let e = t.getTemplate();
|
|
3854
3894
|
if (e === null) {
|
|
3855
|
-
let
|
|
3856
|
-
t.getChildren().forEach((
|
|
3857
|
-
if (!
|
|
3858
|
-
if (
|
|
3895
|
+
let i = !1;
|
|
3896
|
+
t.getChildren().forEach((s) => {
|
|
3897
|
+
if (!i && s instanceof D) {
|
|
3898
|
+
if (s.hasAttribute(`${u.prefix}each-before`) || s.hasAttribute(`${u.prefix}each-after`))
|
|
3859
3899
|
return;
|
|
3860
|
-
e =
|
|
3861
|
-
const a =
|
|
3862
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3900
|
+
e = s.clone(), t.setTemplate(e), i = !0, t.removeChild(s);
|
|
3901
|
+
const a = s.getTarget();
|
|
3902
|
+
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3863
3903
|
}
|
|
3864
3904
|
});
|
|
3865
3905
|
const n = t.getAttribute(`${u.prefix}each`);
|
|
@@ -3878,11 +3918,11 @@ const g = class g {
|
|
|
3878
3918
|
const r = t.getTemplate();
|
|
3879
3919
|
if (r === null)
|
|
3880
3920
|
return f.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3881
|
-
let
|
|
3882
|
-
|
|
3883
|
-
const n = t.getAttribute(`${u.prefix}each-key`),
|
|
3921
|
+
let i = t.getAttribute(`${u.prefix}each-index`);
|
|
3922
|
+
i && (i = String(i));
|
|
3923
|
+
const n = t.getAttribute(`${u.prefix}each-key`), s = t.getAttribute(`${u.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3884
3924
|
e.forEach((h, d) => {
|
|
3885
|
-
const b =
|
|
3925
|
+
const b = m.createListKey(
|
|
3886
3926
|
h,
|
|
3887
3927
|
n ? String(n) : null,
|
|
3888
3928
|
d
|
|
@@ -3890,59 +3930,59 @@ const g = class g {
|
|
|
3890
3930
|
o.push(b), a.set(b, { item: h, itemIndex: d });
|
|
3891
3931
|
});
|
|
3892
3932
|
const l = [];
|
|
3893
|
-
let
|
|
3933
|
+
let g = t.getChildren().filter((h) => h instanceof D).filter(
|
|
3894
3934
|
(h) => !h.hasAttribute(`${u.prefix}each-before`) && !h.hasAttribute(`${u.prefix}each-after`)
|
|
3895
3935
|
);
|
|
3896
|
-
|
|
3897
|
-
const
|
|
3936
|
+
g = g.filter((h) => o.indexOf(String(h.getListKey())) === -1 ? (l.push(h.remove()), !1) : !0);
|
|
3937
|
+
const p = g.map((h) => h.getListKey()), E = t.getChildren().filter((h) => h instanceof D).filter((h) => h.hasAttribute(`${u.prefix}each-before`)).length;
|
|
3898
3938
|
let T = Promise.resolve();
|
|
3899
3939
|
return o.forEach((h, d) => {
|
|
3900
|
-
const b =
|
|
3901
|
-
let
|
|
3940
|
+
const b = p.indexOf(h), { item: v, itemIndex: y } = a.get(h);
|
|
3941
|
+
let x;
|
|
3902
3942
|
if (b !== -1)
|
|
3903
|
-
|
|
3904
|
-
() =>
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3943
|
+
x = g[b], T = T.then(
|
|
3944
|
+
() => m.updateRowFragment(
|
|
3945
|
+
x,
|
|
3946
|
+
v,
|
|
3947
|
+
i,
|
|
3908
3948
|
y,
|
|
3909
|
-
|
|
3949
|
+
s ? String(s) : null,
|
|
3910
3950
|
h
|
|
3911
|
-
).then(() =>
|
|
3951
|
+
).then(() => m.evaluateAll(x)).then(() => m.scheduleEvaluateAll(x))
|
|
3912
3952
|
);
|
|
3913
3953
|
else {
|
|
3914
|
-
|
|
3915
|
-
const J =
|
|
3954
|
+
x = r.clone();
|
|
3955
|
+
const J = E + d;
|
|
3916
3956
|
T = T.then(
|
|
3917
|
-
() =>
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3957
|
+
() => m.updateRowFragment(
|
|
3958
|
+
x,
|
|
3959
|
+
v,
|
|
3960
|
+
i,
|
|
3921
3961
|
y,
|
|
3922
|
-
|
|
3962
|
+
s ? String(s) : null,
|
|
3923
3963
|
h
|
|
3924
3964
|
).then(
|
|
3925
3965
|
() => t.insertBefore(
|
|
3926
|
-
|
|
3966
|
+
x,
|
|
3927
3967
|
t.getChildren()[J] || null
|
|
3928
|
-
).then(() =>
|
|
3968
|
+
).then(() => m.evaluateAll(x)).then(() => m.scheduleEvaluateAll(x))
|
|
3929
3969
|
)
|
|
3930
3970
|
);
|
|
3931
3971
|
}
|
|
3932
3972
|
}), Promise.all(l).then(() => T).then(() => {
|
|
3933
3973
|
const h = o.filter(
|
|
3934
3974
|
(y) => y !== null
|
|
3935
|
-
), d =
|
|
3975
|
+
), d = p.filter(
|
|
3936
3976
|
(y) => y !== null
|
|
3937
3977
|
), b = h.filter(
|
|
3938
3978
|
(y) => !d.includes(y)
|
|
3939
|
-
),
|
|
3979
|
+
), v = d.filter(
|
|
3940
3980
|
(y) => !h.includes(y)
|
|
3941
3981
|
);
|
|
3942
3982
|
N.eachUpdate(
|
|
3943
3983
|
t.getTarget(),
|
|
3944
3984
|
b,
|
|
3945
|
-
|
|
3985
|
+
v,
|
|
3946
3986
|
h
|
|
3947
3987
|
);
|
|
3948
3988
|
});
|
|
@@ -3956,16 +3996,16 @@ const g = class g {
|
|
|
3956
3996
|
* @returns リストキー
|
|
3957
3997
|
*/
|
|
3958
3998
|
static createListKey(t, e, r) {
|
|
3959
|
-
let
|
|
3999
|
+
let i;
|
|
3960
4000
|
if (typeof t == "object" && t !== null)
|
|
3961
4001
|
if (e) {
|
|
3962
4002
|
const n = t[e];
|
|
3963
|
-
n == null ?
|
|
4003
|
+
n == null ? i = `__index_${r}` : typeof n == "object" ? i = JSON.stringify(n) : i = String(n);
|
|
3964
4004
|
} else
|
|
3965
|
-
|
|
4005
|
+
i = `__index_${r}`;
|
|
3966
4006
|
else
|
|
3967
|
-
|
|
3968
|
-
return
|
|
4007
|
+
i = String(t);
|
|
4008
|
+
return i;
|
|
3969
4009
|
}
|
|
3970
4010
|
/**
|
|
3971
4011
|
* 行フラグメントにデータを設定します。
|
|
@@ -3978,22 +4018,22 @@ const g = class g {
|
|
|
3978
4018
|
* @param listKey リストキー
|
|
3979
4019
|
* @returns 行メタデータの更新完了 Promise
|
|
3980
4020
|
*/
|
|
3981
|
-
static updateRowFragment(t, e, r,
|
|
4021
|
+
static updateRowFragment(t, e, r, i, n, s) {
|
|
3982
4022
|
let a = e;
|
|
3983
4023
|
if (typeof e == "object" && e !== null)
|
|
3984
|
-
a = { ...e }, r && (a[r] =
|
|
4024
|
+
a = { ...e }, r && (a[r] = i), n && (a = {
|
|
3985
4025
|
[n]: a
|
|
3986
4026
|
});
|
|
3987
4027
|
else if (n)
|
|
3988
4028
|
a = {
|
|
3989
4029
|
[n]: e
|
|
3990
|
-
}, r && (a[r] =
|
|
4030
|
+
}, r && (a[r] = i);
|
|
3991
4031
|
else
|
|
3992
4032
|
return f.error(
|
|
3993
4033
|
"[Haori]",
|
|
3994
4034
|
`Primitive value requires '${u.prefix}each-arg' attribute: ${e}`
|
|
3995
4035
|
), Promise.resolve();
|
|
3996
|
-
return t.setListKey(
|
|
4036
|
+
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${u.prefix}row`, s);
|
|
3997
4037
|
}
|
|
3998
4038
|
/**
|
|
3999
4039
|
* フラグメントの再評価を次のイベントループで実行します。
|
|
@@ -4002,19 +4042,19 @@ const g = class g {
|
|
|
4002
4042
|
*/
|
|
4003
4043
|
static scheduleEvaluateAll(t) {
|
|
4004
4044
|
setTimeout(() => {
|
|
4005
|
-
|
|
4045
|
+
m.evaluateAll(t);
|
|
4006
4046
|
}, 100);
|
|
4007
4047
|
}
|
|
4008
4048
|
};
|
|
4009
|
-
|
|
4049
|
+
m.ATTRIBUTE_ALIAS_SUFFIX = "attr-", m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], m.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
4010
4050
|
"bind",
|
|
4011
4051
|
"if",
|
|
4012
4052
|
"each",
|
|
4013
4053
|
"fetch",
|
|
4014
4054
|
"import",
|
|
4015
4055
|
"url-param"
|
|
4016
|
-
],
|
|
4017
|
-
let R =
|
|
4056
|
+
], m.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
4057
|
+
let R = m;
|
|
4018
4058
|
const Y = class Y {
|
|
4019
4059
|
/**
|
|
4020
4060
|
* コンストラクタ。
|
|
@@ -4053,8 +4093,8 @@ const Y = class Y {
|
|
|
4053
4093
|
const r = this.getElementFromTarget(t.target, e);
|
|
4054
4094
|
if (!r)
|
|
4055
4095
|
return;
|
|
4056
|
-
const
|
|
4057
|
-
|
|
4096
|
+
const i = w.get(r);
|
|
4097
|
+
i && (e === "change" && i instanceof D && i.syncValue(), new V(i, e).run().catch((n) => {
|
|
4058
4098
|
f.error("[Haori]", "Procedure execution error:", n);
|
|
4059
4099
|
}));
|
|
4060
4100
|
}
|
|
@@ -4095,7 +4135,7 @@ const Y = class Y {
|
|
|
4095
4135
|
}
|
|
4096
4136
|
};
|
|
4097
4137
|
Y.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
4098
|
-
let
|
|
4138
|
+
let Z = Y;
|
|
4099
4139
|
const S = class S {
|
|
4100
4140
|
static syncTree(t) {
|
|
4101
4141
|
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && S.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
@@ -4110,10 +4150,10 @@ const S = class S {
|
|
|
4110
4150
|
}
|
|
4111
4151
|
if (typeof IntersectionObserver > "u")
|
|
4112
4152
|
return;
|
|
4113
|
-
const
|
|
4114
|
-
if (e && e.observer.root ===
|
|
4153
|
+
const i = S.resolveRoot(r), n = S.resolveRootMargin(r), s = S.resolveThreshold(r), a = r.hasAttribute(`${u.prefix}intersect-once`);
|
|
4154
|
+
if (e && e.observer.root === i && e.observer.rootMargin === n && S.sameThreshold(
|
|
4115
4155
|
e.observer.thresholds,
|
|
4116
|
-
|
|
4156
|
+
s
|
|
4117
4157
|
) && e.once === a) {
|
|
4118
4158
|
e.fragment = r;
|
|
4119
4159
|
return;
|
|
@@ -4121,26 +4161,26 @@ const S = class S {
|
|
|
4121
4161
|
e && (e.observer.disconnect(), S.registrations.delete(t));
|
|
4122
4162
|
const o = new IntersectionObserver(
|
|
4123
4163
|
(l) => {
|
|
4124
|
-
const
|
|
4125
|
-
|
|
4126
|
-
!
|
|
4127
|
-
|
|
4128
|
-
}).catch((
|
|
4164
|
+
const g = S.registrations.get(t);
|
|
4165
|
+
g && l.forEach((p) => {
|
|
4166
|
+
!p.isIntersecting || g.running || S.isDisabled(g.fragment) || (g.running = !0, new V(g.fragment, "intersect").runWithResult().then((E) => {
|
|
4167
|
+
E && g.once && (g.observer.disconnect(), S.registrations.delete(t));
|
|
4168
|
+
}).catch((E) => {
|
|
4129
4169
|
f.error(
|
|
4130
4170
|
"[Haori]",
|
|
4131
4171
|
"Intersect procedure execution error:",
|
|
4132
|
-
|
|
4172
|
+
E
|
|
4133
4173
|
);
|
|
4134
4174
|
}).finally(() => {
|
|
4135
|
-
const
|
|
4136
|
-
|
|
4175
|
+
const E = S.registrations.get(t);
|
|
4176
|
+
E && (E.running = !1);
|
|
4137
4177
|
}));
|
|
4138
4178
|
});
|
|
4139
4179
|
},
|
|
4140
4180
|
{
|
|
4141
|
-
root:
|
|
4181
|
+
root: i,
|
|
4142
4182
|
rootMargin: n,
|
|
4143
|
-
threshold:
|
|
4183
|
+
threshold: s
|
|
4144
4184
|
}
|
|
4145
4185
|
);
|
|
4146
4186
|
o.observe(t), S.registrations.set(t, {
|
|
@@ -4180,16 +4220,16 @@ const S = class S {
|
|
|
4180
4220
|
const r = t.getAttribute(e);
|
|
4181
4221
|
if (typeof r != "string" || r.trim() === "")
|
|
4182
4222
|
return null;
|
|
4183
|
-
const
|
|
4184
|
-
return
|
|
4223
|
+
const i = document.querySelector(r);
|
|
4224
|
+
return i instanceof HTMLElement ? i : (f.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
4185
4225
|
}
|
|
4186
4226
|
static resolveRootMargin(t) {
|
|
4187
4227
|
const e = `${u.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
4188
4228
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
4189
4229
|
}
|
|
4190
4230
|
static resolveThreshold(t) {
|
|
4191
|
-
const e = `${u.prefix}intersect-threshold`, r = t.getAttribute(e),
|
|
4192
|
-
return Number.isNaN(
|
|
4231
|
+
const e = `${u.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
4232
|
+
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
4193
4233
|
}
|
|
4194
4234
|
static isDisabled(t) {
|
|
4195
4235
|
const e = `${u.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
@@ -4197,8 +4237,8 @@ const S = class S {
|
|
|
4197
4237
|
return !1;
|
|
4198
4238
|
if (typeof r == "boolean")
|
|
4199
4239
|
return r;
|
|
4200
|
-
const
|
|
4201
|
-
return
|
|
4240
|
+
const i = String(r).trim().toLowerCase();
|
|
4241
|
+
return i !== "" && i !== "false" && i !== "0";
|
|
4202
4242
|
}
|
|
4203
4243
|
static sameThreshold(t, e) {
|
|
4204
4244
|
return t.length === 1 && t[0] === e;
|
|
@@ -4225,7 +4265,7 @@ const H = class H {
|
|
|
4225
4265
|
R.scan(document.head),
|
|
4226
4266
|
R.scan(document.body)
|
|
4227
4267
|
]), [e, r] = t;
|
|
4228
|
-
e.status !== "fulfilled" && f.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && f.error("[Haori]", "Failed to build body fragment:", r.reason), await F.wait(), document.body.setAttribute("data-haori-ready", ""), H.observe(document.head), H.observe(document.body), new
|
|
4268
|
+
e.status !== "fulfilled" && f.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && f.error("[Haori]", "Failed to build body fragment:", r.reason), await F.wait(), document.body.setAttribute("data-haori-ready", ""), H.observe(document.head), H.observe(document.body), new Z().start(), $.syncTree(document.body);
|
|
4229
4269
|
}
|
|
4230
4270
|
/**
|
|
4231
4271
|
* 指定された要素を監視します。
|
|
@@ -4234,26 +4274,26 @@ const H = class H {
|
|
|
4234
4274
|
*/
|
|
4235
4275
|
static observe(t) {
|
|
4236
4276
|
new MutationObserver(async (r) => {
|
|
4237
|
-
for (const
|
|
4277
|
+
for (const i of r)
|
|
4238
4278
|
try {
|
|
4239
|
-
switch (
|
|
4279
|
+
switch (i.type) {
|
|
4240
4280
|
case "attributes": {
|
|
4241
4281
|
f.info(
|
|
4242
4282
|
"[Haori]",
|
|
4243
4283
|
"Attribute changed:",
|
|
4244
|
-
|
|
4245
|
-
|
|
4284
|
+
i.target,
|
|
4285
|
+
i.attributeName
|
|
4246
4286
|
);
|
|
4247
|
-
const n =
|
|
4248
|
-
if (
|
|
4287
|
+
const n = i.target;
|
|
4288
|
+
if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && R.isAliasedAttributeReflection(
|
|
4249
4289
|
n,
|
|
4250
|
-
|
|
4290
|
+
i.attributeName
|
|
4251
4291
|
))
|
|
4252
4292
|
break;
|
|
4253
4293
|
R.setAttribute(
|
|
4254
4294
|
n,
|
|
4255
|
-
|
|
4256
|
-
n.getAttribute(
|
|
4295
|
+
i.attributeName,
|
|
4296
|
+
n.getAttribute(i.attributeName),
|
|
4257
4297
|
!0
|
|
4258
4298
|
), $.syncElement(n);
|
|
4259
4299
|
break;
|
|
@@ -4262,11 +4302,11 @@ const H = class H {
|
|
|
4262
4302
|
f.info(
|
|
4263
4303
|
"[Haori]",
|
|
4264
4304
|
"Child list changed:",
|
|
4265
|
-
Array.from(
|
|
4266
|
-
Array.from(
|
|
4267
|
-
), Array.from(
|
|
4305
|
+
Array.from(i.removedNodes).map((n) => n.nodeName),
|
|
4306
|
+
Array.from(i.addedNodes).map((n) => n.nodeName)
|
|
4307
|
+
), Array.from(i.removedNodes).forEach((n) => {
|
|
4268
4308
|
$.cleanupTree(n), R.removeNode(n);
|
|
4269
|
-
}), Array.from(
|
|
4309
|
+
}), Array.from(i.addedNodes).forEach((n) => {
|
|
4270
4310
|
n.parentElement instanceof HTMLElement && (R.addNode(n.parentElement, n), $.syncTree(n));
|
|
4271
4311
|
});
|
|
4272
4312
|
break;
|
|
@@ -4275,17 +4315,17 @@ const H = class H {
|
|
|
4275
4315
|
f.info(
|
|
4276
4316
|
"[Haori]",
|
|
4277
4317
|
"Character data changed:",
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
),
|
|
4318
|
+
i.target,
|
|
4319
|
+
i.target.textContent
|
|
4320
|
+
), i.target instanceof Text || i.target instanceof Comment ? R.changeText(i.target, i.target.textContent) : f.warn(
|
|
4281
4321
|
"[Haori]",
|
|
4282
4322
|
"Unsupported character data type:",
|
|
4283
|
-
|
|
4323
|
+
i.target
|
|
4284
4324
|
);
|
|
4285
4325
|
break;
|
|
4286
4326
|
}
|
|
4287
4327
|
default:
|
|
4288
|
-
f.warn("[Haori]", "Unknown mutation type:",
|
|
4328
|
+
f.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
4289
4329
|
continue;
|
|
4290
4330
|
}
|
|
4291
4331
|
} catch (n) {
|
|
@@ -4302,7 +4342,7 @@ const H = class H {
|
|
|
4302
4342
|
H._initialized = !1;
|
|
4303
4343
|
let q = H;
|
|
4304
4344
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4305
|
-
const
|
|
4345
|
+
const gt = "0.4.13";
|
|
4306
4346
|
export {
|
|
4307
4347
|
R as Core,
|
|
4308
4348
|
u as Env,
|
|
@@ -4312,6 +4352,6 @@ export {
|
|
|
4312
4352
|
f as Log,
|
|
4313
4353
|
F as Queue,
|
|
4314
4354
|
X as default,
|
|
4315
|
-
|
|
4355
|
+
gt as version
|
|
4316
4356
|
};
|
|
4317
4357
|
//# sourceMappingURL=haori.es.js.map
|