haori 0.4.13 → 0.4.14
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 +9 -9
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +533 -531
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +9 -9
- 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.map +1 -1
- package/dist/src/procedure.js +16 -3
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +27 -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 +12 -0
- package/dist/tests/procedure_events.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const O = class O {
|
|
2
2
|
/**
|
|
3
3
|
* 開発モードの状態を取得します。
|
|
4
4
|
*
|
|
5
5
|
* @returns 開発モードならtrue、そうでなければfalse
|
|
6
6
|
*/
|
|
7
7
|
static isEnabled() {
|
|
8
|
-
return
|
|
8
|
+
return O.devMode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 開発モードを有効化します。
|
|
12
12
|
*/
|
|
13
13
|
static enable() {
|
|
14
|
-
|
|
14
|
+
O.devMode = !0;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 開発モードを無効化します。
|
|
18
18
|
*/
|
|
19
19
|
static disable() {
|
|
20
|
-
|
|
20
|
+
O.devMode = !1;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 開発モードを切り替えます。
|
|
@@ -25,17 +25,17 @@ const C = class C {
|
|
|
25
25
|
* @param enabled trueで有効化、falseで無効化
|
|
26
26
|
*/
|
|
27
27
|
static set(t) {
|
|
28
|
-
|
|
28
|
+
O.devMode = t;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
let
|
|
33
|
-
const
|
|
34
|
-
function
|
|
31
|
+
O.devMode = !1;
|
|
32
|
+
let H = O;
|
|
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
|
+
H.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
|
+
H.set(!0);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
H.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
|
+
H.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
|
+
H.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`), p = t.getAttribute(`${u.prefix}form-detach`);
|
|
438
438
|
if (a) {
|
|
439
|
-
if (!p ||
|
|
439
|
+
if (!p || i) {
|
|
440
440
|
const m = e[String(a)];
|
|
441
|
-
l && Array.isArray(m) && r !== null ?
|
|
441
|
+
l && Array.isArray(m) && r !== null ? s.push(
|
|
442
442
|
A.applyFragmentValue(t, m[r] ?? null, n)
|
|
443
|
-
) : typeof m > "u" || (typeof m == "string" || typeof m == "number" || typeof m == "boolean" || m === null ?
|
|
443
|
+
) : typeof m > "u" || (typeof m == "string" || typeof m == "number" || typeof m == "boolean" || m === null ? s.push(A.applyFragmentValue(t, m, n)) : s.push(
|
|
444
444
|
A.applyFragmentValue(t, String(m), n)
|
|
445
445
|
));
|
|
446
446
|
}
|
|
447
447
|
} else if (o) {
|
|
448
448
|
const m = e[String(o)];
|
|
449
449
|
if (m && typeof m == "object")
|
|
450
|
-
for (const
|
|
451
|
-
|
|
450
|
+
for (const E of t.getChildElementFragments())
|
|
451
|
+
s.push(
|
|
452
452
|
A.setPartValues(
|
|
453
|
-
|
|
453
|
+
E,
|
|
454
454
|
m,
|
|
455
455
|
null,
|
|
456
|
-
|
|
456
|
+
i,
|
|
457
457
|
n
|
|
458
458
|
)
|
|
459
459
|
);
|
|
460
460
|
} else if (l) {
|
|
461
461
|
const m = e[String(l)];
|
|
462
462
|
if (Array.isArray(m)) {
|
|
463
|
-
const
|
|
464
|
-
for (let T = 0; T <
|
|
465
|
-
const h =
|
|
466
|
-
m.length > T ?
|
|
463
|
+
const E = t.getChildElementFragments();
|
|
464
|
+
for (let T = 0; T < E.length; T++) {
|
|
465
|
+
const h = E[T];
|
|
466
|
+
m.length > T ? s.push(
|
|
467
467
|
A.setPartValues(
|
|
468
468
|
h,
|
|
469
469
|
m[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
478
|
for (const m of t.getChildElementFragments())
|
|
479
|
-
|
|
480
|
-
A.setPartValues(m, e, null,
|
|
479
|
+
s.push(
|
|
480
|
+
A.setPartValues(m, 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,8 +573,8 @@ class A {
|
|
|
573
573
|
* @param level メッセージのレベル(省略可能)
|
|
574
574
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
575
575
|
*/
|
|
576
|
-
static addMessage(t, e, r,
|
|
577
|
-
const n = [],
|
|
576
|
+
static addMessage(t, e, r, i) {
|
|
577
|
+
const n = [], s = rt(), a = s.addMessage, o = (p) => typeof a == "function" ? a.call(s, p, r, i) : s.addErrorMessage(p, r), l = A.findFragmentsByKey(t, e);
|
|
578
578
|
return l.forEach((p) => {
|
|
579
579
|
n.push(o(p.getTarget()));
|
|
580
580
|
}), l.length === 0 && n.push(o(t.getTarget())), Promise.all(n).then(() => {
|
|
@@ -599,22 +599,22 @@ 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 =
|
|
613
|
+
const l = i.substring(s + 1, a), p = Number(l);
|
|
614
614
|
if (isNaN(p))
|
|
615
|
-
f.error("Haori", `Invalid index: ${
|
|
615
|
+
f.error("Haori", `Invalid index: ${i}`);
|
|
616
616
|
else {
|
|
617
|
-
const m = t.getChildElementFragments().filter((
|
|
617
|
+
const m = t.getChildElementFragments().filter((E) => E.hasAttribute(`${u.prefix}row`));
|
|
618
618
|
p < m.length && r.push(
|
|
619
619
|
...A.findFragmentByKeyParts(m[p], e.slice(1))
|
|
620
620
|
);
|
|
@@ -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, p = e[n - 3] || null;
|
|
757
757
|
if (this.startsObjectKey(
|
|
758
758
|
o,
|
|
759
|
-
|
|
759
|
+
i,
|
|
760
760
|
l,
|
|
761
761
|
p
|
|
762
|
-
) && (
|
|
763
|
-
this.decodeStringLiteral(
|
|
764
|
-
)) ||
|
|
765
|
-
this.decodeStringLiteral(
|
|
766
|
-
) ||
|
|
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,7 +775,7 @@ return (${t});`;
|
|
|
775
775
|
break;
|
|
776
776
|
}
|
|
777
777
|
case "[": {
|
|
778
|
-
const m = this.startsMemberAccess(
|
|
778
|
+
const m = this.startsMemberAccess(i) ? "member" : "array";
|
|
779
779
|
r.push(m);
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
@@ -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;
|
|
@@ -1268,10 +1268,10 @@ const I = class I {
|
|
|
1268
1268
|
e = new x(t);
|
|
1269
1269
|
break;
|
|
1270
1270
|
case Node.TEXT_NODE:
|
|
1271
|
-
e = new
|
|
1271
|
+
e = new C(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;
|
|
@@ -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);
|
|
@@ -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;
|
|
@@ -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
1850
|
let p = 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
|
|
@@ -1863,7 +1863,7 @@ class x extends w {
|
|
|
1863
1863
|
e
|
|
1864
1864
|
), this.children.push(t)) : (this.children.splice(T.index, 0, t), p = 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
1869
|
const m = this.skipMutationNodes;
|
|
@@ -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);
|
|
@@ -1976,7 +1976,7 @@ class x extends w {
|
|
|
1976
1976
|
return e === null ? null : e.closestByAttribute(t);
|
|
1977
1977
|
}
|
|
1978
1978
|
}
|
|
1979
|
-
class
|
|
1979
|
+
class C extends w {
|
|
1980
1980
|
/**
|
|
1981
1981
|
* テキストフラグメントのコンストラクタ。
|
|
1982
1982
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -1992,7 +1992,7 @@ class O extends w {
|
|
|
1992
1992
|
* @returns クローンされたフラグメント
|
|
1993
1993
|
*/
|
|
1994
1994
|
clone() {
|
|
1995
|
-
const t = new
|
|
1995
|
+
const t = new C(this.target.cloneNode(!0));
|
|
1996
1996
|
return t.mounted = !1, t.text = this.text, t.contents = this.contents, t;
|
|
1997
1997
|
}
|
|
1998
1998
|
/**
|
|
@@ -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 B =
|
|
2160
|
-
const
|
|
2158
|
+
K.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2159
|
+
let B = K;
|
|
2160
|
+
const G = class G extends B {
|
|
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,8 +2292,8 @@ 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
2298
|
const p = e?.[l], m = r[l];
|
|
2299
2299
|
p !== m && n.push(l);
|
|
@@ -2302,7 +2302,7 @@ class N {
|
|
|
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()
|
|
@@ -2622,17 +2622,17 @@ ${h}
|
|
|
2622
2622
|
}
|
|
2623
2623
|
}
|
|
2624
2624
|
}
|
|
2625
|
-
const
|
|
2626
|
-
n && (r.fetchUrl = t.getAttribute(
|
|
2627
|
-
const
|
|
2625
|
+
const i = c.attrName(e, "fetch"), n = t.hasAttribute(i);
|
|
2626
|
+
n && (r.fetchUrl = t.getAttribute(i));
|
|
2627
|
+
const s = {};
|
|
2628
2628
|
if (e) {
|
|
2629
2629
|
const h = c.attrName(e, "fetch-method");
|
|
2630
|
-
t.hasAttribute(h) && (
|
|
2630
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2631
2631
|
h
|
|
2632
2632
|
));
|
|
2633
2633
|
} else {
|
|
2634
2634
|
const h = c.attrName(null, "method", !0);
|
|
2635
|
-
t.hasAttribute(h) && (
|
|
2635
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2636
2636
|
h
|
|
2637
2637
|
));
|
|
2638
2638
|
}
|
|
@@ -2643,7 +2643,7 @@ ${h}
|
|
|
2643
2643
|
h
|
|
2644
2644
|
);
|
|
2645
2645
|
try {
|
|
2646
|
-
|
|
2646
|
+
s.headers = R.parseDataBind(d);
|
|
2647
2647
|
} catch (b) {
|
|
2648
2648
|
f.error("Haori", `Invalid fetch headers: ${b}`);
|
|
2649
2649
|
}
|
|
@@ -2659,7 +2659,7 @@ ${h}
|
|
|
2659
2659
|
h
|
|
2660
2660
|
);
|
|
2661
2661
|
try {
|
|
2662
|
-
|
|
2662
|
+
s.headers = R.parseDataBind(d);
|
|
2663
2663
|
} catch (b) {
|
|
2664
2664
|
f.error("Haori", `Invalid fetch headers: ${b}`);
|
|
2665
2665
|
}
|
|
@@ -2671,18 +2671,18 @@ ${h}
|
|
|
2671
2671
|
"fetch-content-type"
|
|
2672
2672
|
);
|
|
2673
2673
|
if (t.hasAttribute(h))
|
|
2674
|
-
|
|
2675
|
-
...
|
|
2674
|
+
s.headers = {
|
|
2675
|
+
...s.headers,
|
|
2676
2676
|
"Content-Type": t.getAttribute(h)
|
|
2677
2677
|
};
|
|
2678
|
-
else if (
|
|
2678
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2679
2679
|
let d = !1;
|
|
2680
|
-
|
|
2681
|
-
...
|
|
2680
|
+
s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
|
|
2681
|
+
...s.headers,
|
|
2682
2682
|
"Content-Type": "application/json"
|
|
2683
2683
|
});
|
|
2684
|
-
} else
|
|
2685
|
-
...
|
|
2684
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2685
|
+
...s.headers,
|
|
2686
2686
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2687
2687
|
});
|
|
2688
2688
|
} else {
|
|
@@ -2692,30 +2692,30 @@ ${h}
|
|
|
2692
2692
|
!0
|
|
2693
2693
|
);
|
|
2694
2694
|
if (t.hasAttribute(h))
|
|
2695
|
-
|
|
2696
|
-
...
|
|
2695
|
+
s.headers = {
|
|
2696
|
+
...s.headers,
|
|
2697
2697
|
"Content-Type": t.getAttribute(h)
|
|
2698
2698
|
};
|
|
2699
|
-
else if (
|
|
2699
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2700
2700
|
let d = !1;
|
|
2701
|
-
|
|
2702
|
-
...
|
|
2701
|
+
s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
|
|
2702
|
+
...s.headers,
|
|
2703
2703
|
"Content-Type": "application/json"
|
|
2704
2704
|
});
|
|
2705
|
-
} else
|
|
2706
|
-
...
|
|
2705
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2706
|
+
...s.headers,
|
|
2707
2707
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2708
2708
|
});
|
|
2709
2709
|
}
|
|
2710
|
-
Object.keys(
|
|
2710
|
+
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2711
2711
|
const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
|
|
2712
2712
|
if (t.hasAttribute(a)) {
|
|
2713
2713
|
const h = t.getRawAttribute(a);
|
|
2714
2714
|
if (h) {
|
|
2715
2715
|
const d = document.body.querySelectorAll(h);
|
|
2716
2716
|
d.length > 0 ? (r.bindFragments = [], d.forEach((b) => {
|
|
2717
|
-
const
|
|
2718
|
-
|
|
2717
|
+
const v = w.get(b);
|
|
2718
|
+
v && r.bindFragments.push(v);
|
|
2719
2719
|
})) : f.error(
|
|
2720
2720
|
"Haori",
|
|
2721
2721
|
`Bind element not found: ${h} (${a})`
|
|
@@ -2739,9 +2739,9 @@ ${h}
|
|
|
2739
2739
|
const h = t.getRawAttribute(m);
|
|
2740
2740
|
r.bindParams = h.split("&").map((d) => d.trim());
|
|
2741
2741
|
}
|
|
2742
|
-
const
|
|
2743
|
-
if (t.hasAttribute(
|
|
2744
|
-
const h = t.getRawAttribute(
|
|
2742
|
+
const E = e ? c.attrName(e, "bind-append") : c.attrName(null, "bind-append", !0);
|
|
2743
|
+
if (t.hasAttribute(E)) {
|
|
2744
|
+
const h = t.getRawAttribute(E);
|
|
2745
2745
|
r.bindAppendParams = h.split("&").map((d) => d.trim()).filter(Boolean);
|
|
2746
2746
|
}
|
|
2747
2747
|
const T = e ? c.attrName(e, "copy-params") : null;
|
|
@@ -2758,8 +2758,8 @@ ${h}
|
|
|
2758
2758
|
);
|
|
2759
2759
|
if (d) {
|
|
2760
2760
|
const b = document.body.querySelectorAll(d);
|
|
2761
|
-
b.length > 0 ? (r.adjustFragments = [], b.forEach((
|
|
2762
|
-
const y = w.get(
|
|
2761
|
+
b.length > 0 ? (r.adjustFragments = [], b.forEach((v) => {
|
|
2762
|
+
const y = w.get(v);
|
|
2763
2763
|
y && r.adjustFragments.push(y);
|
|
2764
2764
|
})) : f.error(
|
|
2765
2765
|
"Haori",
|
|
@@ -2769,8 +2769,8 @@ ${h}
|
|
|
2769
2769
|
if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
|
|
2770
2770
|
const b = t.getRawAttribute(
|
|
2771
2771
|
c.attrName(e, "adjust-value")
|
|
2772
|
-
),
|
|
2773
|
-
isNaN(
|
|
2772
|
+
), v = Number(b);
|
|
2773
|
+
isNaN(v) || (r.adjustValue = v);
|
|
2774
2774
|
}
|
|
2775
2775
|
}
|
|
2776
2776
|
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 +2798,8 @@ ${d}
|
|
|
2798
2798
|
);
|
|
2799
2799
|
const d = t.getRawAttribute(
|
|
2800
2800
|
c.attrName(e, "toast-level")
|
|
2801
|
-
),
|
|
2802
|
-
r.toastLevel =
|
|
2801
|
+
), v = ["info", "warning", "error", "success"].includes(d);
|
|
2802
|
+
r.toastLevel = v ? d : null;
|
|
2803
2803
|
}
|
|
2804
2804
|
if (t.hasAttribute(c.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2805
2805
|
c.attrName(e, "redirect")
|
|
@@ -2836,11 +2836,11 @@ ${d}
|
|
|
2836
2836
|
const b = c.attrName(e, d);
|
|
2837
2837
|
if (!t.hasAttribute(b))
|
|
2838
2838
|
return;
|
|
2839
|
-
const
|
|
2840
|
-
if (
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2843
|
-
}), y.length === 0 && f.error("Haori", `Element not found: ${
|
|
2839
|
+
const v = t.getRawAttribute(b), y = [];
|
|
2840
|
+
if (v ? (document.body.querySelectorAll(v).forEach((J) => {
|
|
2841
|
+
const et = w.get(J);
|
|
2842
|
+
et && y.push(et);
|
|
2843
|
+
}), y.length === 0 && f.error("Haori", `Element not found: ${v} (${b})`)) : y.push(t), y.length > 0)
|
|
2844
2844
|
switch (d) {
|
|
2845
2845
|
case "reset":
|
|
2846
2846
|
r.resetFragments = y;
|
|
@@ -2933,16 +2933,16 @@ ${d}
|
|
|
2933
2933
|
try {
|
|
2934
2934
|
if (Object.keys(this.options).length === 0 || this.options.formFragment && this.validate(this.options.formFragment) === !1 || !await this.confirm())
|
|
2935
2935
|
return !1;
|
|
2936
|
-
let r = this.options.fetchUrl,
|
|
2936
|
+
let r = this.options.fetchUrl, i = this.options.fetchOptions;
|
|
2937
2937
|
if (this.options.beforeCallback) {
|
|
2938
2938
|
const l = this.options.beforeCallback(
|
|
2939
2939
|
r || null,
|
|
2940
|
-
|
|
2940
|
+
i || null
|
|
2941
2941
|
);
|
|
2942
2942
|
if (l != null) {
|
|
2943
2943
|
if (l === !1 || typeof l == "object" && l.stop)
|
|
2944
2944
|
return !1;
|
|
2945
|
-
typeof l == "object" && (r = "fetchUrl" in l ? l.fetchUrl : r,
|
|
2945
|
+
typeof l == "object" && (r = "fetchUrl" in l ? l.fetchUrl : r, i = "fetchOptions" in l ? l.fetchOptions : i);
|
|
2946
2946
|
}
|
|
2947
2947
|
}
|
|
2948
2948
|
const n = {};
|
|
@@ -2951,77 +2951,77 @@ ${d}
|
|
|
2951
2951
|
Object.assign(n, l);
|
|
2952
2952
|
}
|
|
2953
2953
|
this.options.data && typeof this.options.data == "object" && Object.assign(n, this.options.data);
|
|
2954
|
-
const
|
|
2954
|
+
const s = Object.keys(n).length > 0;
|
|
2955
2955
|
if (r) {
|
|
2956
|
-
const l = { ...
|
|
2956
|
+
const l = { ...i || {} }, p = new Headers(
|
|
2957
2957
|
l.headers || void 0
|
|
2958
|
-
), m = (l.method || "GET").toUpperCase(),
|
|
2958
|
+
), m = (l.method || "GET").toUpperCase(), E = u.runtime === "demo" && !ct(m), T = E ? "GET" : m;
|
|
2959
2959
|
if (l.method = T, T === "GET" || T === "HEAD" || T === "OPTIONS")
|
|
2960
|
-
|
|
2961
|
-
else if (
|
|
2960
|
+
s && (r = ft(r, n));
|
|
2961
|
+
else if (s) {
|
|
2962
2962
|
const d = p.get("Content-Type") || "";
|
|
2963
2963
|
if (/multipart\/form-data/i.test(d)) {
|
|
2964
2964
|
p.delete("Content-Type");
|
|
2965
2965
|
const b = new FormData();
|
|
2966
|
-
for (const [
|
|
2967
|
-
y == null ? b.append(
|
|
2966
|
+
for (const [v, y] of Object.entries(n))
|
|
2967
|
+
y == null ? b.append(v, "") : y instanceof Blob ? b.append(v, y) : Array.isArray(y) ? y.forEach((M) => b.append(v, String(M))) : typeof y == "object" ? b.append(v, JSON.stringify(y)) : b.append(v, String(y));
|
|
2968
2968
|
l.body = b;
|
|
2969
2969
|
} else if (/application\/x-www-form-urlencoded/i.test(d)) {
|
|
2970
2970
|
const b = new URLSearchParams();
|
|
2971
|
-
for (const [
|
|
2972
|
-
y !== void 0 && (y === null ? b.append(
|
|
2971
|
+
for (const [v, y] of Object.entries(n))
|
|
2972
|
+
y !== void 0 && (y === null ? b.append(v, "") : Array.isArray(y) ? y.forEach((M) => b.append(v, String(M))) : typeof y == "object" ? b.append(v, JSON.stringify(y)) : b.append(v, String(y)));
|
|
2973
2973
|
l.body = b;
|
|
2974
2974
|
} else
|
|
2975
2975
|
p.set("Content-Type", "application/json"), l.body = JSON.stringify(n);
|
|
2976
2976
|
}
|
|
2977
2977
|
l.headers = p;
|
|
2978
2978
|
let h;
|
|
2979
|
-
if (
|
|
2979
|
+
if (E && (h = r && new URL(r, window.location.href).search || void 0, p.delete("Content-Type"), f.info("Haori demo fetch normalization", {
|
|
2980
2980
|
runtime: u.runtime,
|
|
2981
2981
|
requestedMethod: m,
|
|
2982
2982
|
effectiveMethod: T,
|
|
2983
2983
|
transportMode: "query-get",
|
|
2984
2984
|
url: r,
|
|
2985
|
-
payload:
|
|
2985
|
+
payload: s ? n : void 0,
|
|
2986
2986
|
queryString: h
|
|
2987
2987
|
})), this.options.targetFragment && r) {
|
|
2988
2988
|
const d = performance.now(), b = {
|
|
2989
2989
|
runtime: u.runtime,
|
|
2990
2990
|
requestedMethod: m,
|
|
2991
2991
|
effectiveMethod: T,
|
|
2992
|
-
transportMode:
|
|
2993
|
-
...
|
|
2992
|
+
transportMode: E ? "query-get" : "http",
|
|
2993
|
+
...E ? { queryString: h } : {}
|
|
2994
2994
|
};
|
|
2995
2995
|
return N.fetchStart(
|
|
2996
2996
|
this.options.targetFragment.getTarget(),
|
|
2997
2997
|
r,
|
|
2998
2998
|
l,
|
|
2999
|
-
|
|
2999
|
+
s ? n : void 0,
|
|
3000
3000
|
b
|
|
3001
|
-
), fetch(r, l).then((
|
|
3002
|
-
|
|
3001
|
+
), fetch(r, l).then((v) => this.handleFetchResult(
|
|
3002
|
+
v,
|
|
3003
3003
|
r || void 0,
|
|
3004
3004
|
d
|
|
3005
|
-
)).catch((
|
|
3005
|
+
)).catch((v) => {
|
|
3006
3006
|
throw r && N.fetchError(
|
|
3007
3007
|
this.options.targetFragment.getTarget(),
|
|
3008
3008
|
r,
|
|
3009
|
-
|
|
3010
|
-
),
|
|
3009
|
+
v
|
|
3010
|
+
), v;
|
|
3011
3011
|
});
|
|
3012
3012
|
}
|
|
3013
3013
|
return fetch(r, l).then((d) => this.handleFetchResult(d, r || void 0));
|
|
3014
3014
|
}
|
|
3015
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
3016
|
-
const l = this.options.formFragment, p = l.getTarget();
|
|
3017
|
-
p.setAttribute(
|
|
3015
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
3016
|
+
const l = this.options.formFragment, p = l.getTarget(), m = /* @__PURE__ */ new Set();
|
|
3017
|
+
t && t.appliedDisabledAttribute && this.options.targetFragment && m.add(this.options.targetFragment), p.setAttribute(
|
|
3018
3018
|
`${u.prefix}bind`,
|
|
3019
3019
|
JSON.stringify(n)
|
|
3020
3020
|
);
|
|
3021
|
-
const
|
|
3022
|
-
Object.assign(
|
|
3021
|
+
const E = l.getBindingData();
|
|
3022
|
+
Object.assign(E, n), await R.setBindingData(p, E, m);
|
|
3023
3023
|
}
|
|
3024
|
-
const a =
|
|
3024
|
+
const a = s ? n : {}, o = new Response(JSON.stringify(a), {
|
|
3025
3025
|
headers: { "Content-Type": "application/json" }
|
|
3026
3026
|
});
|
|
3027
3027
|
return this.handleFetchResult(o);
|
|
@@ -3037,9 +3037,9 @@ ${d}
|
|
|
3037
3037
|
acquireExecutionLock() {
|
|
3038
3038
|
if (this.eventType !== "click" || !this.options.targetFragment)
|
|
3039
3039
|
return null;
|
|
3040
|
-
const
|
|
3041
|
-
return c.RUNNING_CLICK_TARGETS.has(
|
|
3042
|
-
target:
|
|
3040
|
+
const e = this.options.targetFragment.getTarget();
|
|
3041
|
+
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", ""), {
|
|
3042
|
+
target: e,
|
|
3043
3043
|
appliedDisabledAttribute: !0
|
|
3044
3044
|
});
|
|
3045
3045
|
}
|
|
@@ -3050,13 +3050,13 @@ ${d}
|
|
|
3050
3050
|
* @returns 戻り値はありません。
|
|
3051
3051
|
*/
|
|
3052
3052
|
releaseExecutionLock(t) {
|
|
3053
|
-
t && (c.RUNNING_CLICK_TARGETS.delete(t.target), t.appliedDisabledAttribute && t.target.removeAttribute("disabled"));
|
|
3053
|
+
t && (c.RUNNING_CLICK_TARGETS.delete(t.target), t.appliedDisabledAttribute && (t.target.removeAttribute("disabled"), t.target.removeAttribute(W)));
|
|
3054
3054
|
}
|
|
3055
3055
|
/**
|
|
3056
3056
|
* フェッチ後の処理を実行します。
|
|
3057
3057
|
*/
|
|
3058
3058
|
async handleFetchResult(t, e, r) {
|
|
3059
|
-
const
|
|
3059
|
+
const i = z();
|
|
3060
3060
|
if (!t.ok)
|
|
3061
3061
|
return this.options.targetFragment && e && N.fetchError(
|
|
3062
3062
|
this.options.targetFragment.getTarget(),
|
|
@@ -3082,9 +3082,9 @@ ${d}
|
|
|
3082
3082
|
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
3083
|
this.options.resetFragments.map((a) => A.reset(a))
|
|
3084
3084
|
), await this.copy();
|
|
3085
|
-
const
|
|
3085
|
+
const s = [];
|
|
3086
3086
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
3087
|
-
|
|
3087
|
+
s.push(new c(a, null).run());
|
|
3088
3088
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
3089
3089
|
const o = a.getTarget();
|
|
3090
3090
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
@@ -3092,11 +3092,11 @@ ${d}
|
|
|
3092
3092
|
);
|
|
3093
3093
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
3094
3094
|
const o = a.getTarget();
|
|
3095
|
-
o instanceof HTMLElement ?
|
|
3095
|
+
o instanceof HTMLElement ? s.push(i.openDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
3096
3096
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
3097
3097
|
const o = a.getTarget();
|
|
3098
|
-
o instanceof HTMLElement ?
|
|
3099
|
-
}), await Promise.all(
|
|
3098
|
+
o instanceof HTMLElement ? s.push(i.closeDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
3099
|
+
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3100
3100
|
this.options.toastMessage,
|
|
3101
3101
|
this.options.toastLevel ?? "info"
|
|
3102
3102
|
), 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;
|
|
@@ -3112,7 +3112,7 @@ ${d}
|
|
|
3112
3112
|
const t = this.options.historyUrl !== void 0 && this.options.historyUrl !== null, e = this.options.historyData !== void 0 && this.options.historyData !== null, r = this.options.historyFormFragment !== void 0 && this.options.historyFormFragment !== null;
|
|
3113
3113
|
if (!(!t && !e && !r))
|
|
3114
3114
|
try {
|
|
3115
|
-
const
|
|
3115
|
+
const i = t ? this.options.historyUrl : window.location.pathname, n = new URL(i, window.location.href);
|
|
3116
3116
|
if (n.origin !== window.location.origin) {
|
|
3117
3117
|
const a = "history.pushState: cross-origin URL is not allowed: " + n.toString();
|
|
3118
3118
|
f.error(
|
|
@@ -3121,21 +3121,21 @@ ${d}
|
|
|
3121
3121
|
);
|
|
3122
3122
|
return;
|
|
3123
3123
|
}
|
|
3124
|
-
const
|
|
3124
|
+
const s = (a) => {
|
|
3125
3125
|
for (const [o, l] of Object.entries(a))
|
|
3126
3126
|
l != null && (Array.isArray(l) ? l.forEach((p) => n.searchParams.append(o, String(p))) : typeof l == "object" ? n.searchParams.set(o, JSON.stringify(l)) : n.searchParams.set(o, String(l)));
|
|
3127
3127
|
};
|
|
3128
|
-
e &&
|
|
3128
|
+
e && s(this.options.historyData), r && s(
|
|
3129
3129
|
A.getValues(
|
|
3130
3130
|
this.options.historyFormFragment
|
|
3131
3131
|
)
|
|
3132
3132
|
), history.pushState(
|
|
3133
|
-
{ [
|
|
3133
|
+
{ [lt]: !0 },
|
|
3134
3134
|
"",
|
|
3135
3135
|
n.toString()
|
|
3136
3136
|
);
|
|
3137
|
-
} catch (
|
|
3138
|
-
f.error("Haori", `history.pushState failed: ${
|
|
3137
|
+
} catch (i) {
|
|
3138
|
+
f.error("Haori", `history.pushState failed: ${i}`);
|
|
3139
3139
|
}
|
|
3140
3140
|
}
|
|
3141
3141
|
/**
|
|
@@ -3144,45 +3144,45 @@ ${d}
|
|
|
3144
3144
|
async handleFetchError(t) {
|
|
3145
3145
|
let e = null;
|
|
3146
3146
|
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3147
|
-
const r = async (
|
|
3147
|
+
const r = async (s) => {
|
|
3148
3148
|
const a = e ? e.getTarget() : document.body;
|
|
3149
|
-
await
|
|
3150
|
-
},
|
|
3149
|
+
await z().addErrorMessage(a, s);
|
|
3150
|
+
}, i = () => {
|
|
3151
3151
|
if (!this.options.scrollOnError)
|
|
3152
3152
|
return;
|
|
3153
|
-
const
|
|
3154
|
-
(
|
|
3153
|
+
const s = e ? e.getTarget() : document.body;
|
|
3154
|
+
(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
3155
|
};
|
|
3156
3156
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
3157
3157
|
try {
|
|
3158
|
-
const
|
|
3159
|
-
if (
|
|
3160
|
-
if (typeof
|
|
3161
|
-
for (const o of
|
|
3158
|
+
const s = await t.json(), a = [];
|
|
3159
|
+
if (s && typeof s == "object") {
|
|
3160
|
+
if (typeof s.message == "string" && a.push({ message: s.message }), Array.isArray(s.messages))
|
|
3161
|
+
for (const o of s.messages)
|
|
3162
3162
|
typeof o == "string" && a.push({ message: o });
|
|
3163
|
-
if (
|
|
3164
|
-
for (const [o, l] of Object.entries(
|
|
3163
|
+
if (s.errors && typeof s.errors == "object")
|
|
3164
|
+
for (const [o, l] of Object.entries(s.errors))
|
|
3165
3165
|
Array.isArray(l) ? a.push({ key: o, message: l.join(`
|
|
3166
3166
|
`) }) : typeof l == "string" ? a.push({ key: o, message: l }) : l != null && a.push({ key: o, message: String(l) });
|
|
3167
3167
|
if (a.length === 0)
|
|
3168
|
-
for (const [o, l] of Object.entries(
|
|
3168
|
+
for (const [o, l] of Object.entries(s))
|
|
3169
3169
|
o === "message" || o === "messages" || o === "errors" || (Array.isArray(l) ? a.push({ key: o, message: l.join(`
|
|
3170
3170
|
`) }) : typeof l == "string" && a.push({ key: o, message: l }));
|
|
3171
3171
|
}
|
|
3172
3172
|
if (a.length === 0)
|
|
3173
|
-
return await r(`${t.status} ${t.statusText}`),
|
|
3173
|
+
return await r(`${t.status} ${t.statusText}`), i(), !1;
|
|
3174
3174
|
for (const o of a)
|
|
3175
3175
|
o.key && e ? await A.addErrorMessage(e, o.key, o.message) : await r(o.message);
|
|
3176
|
-
return
|
|
3176
|
+
return i(), !1;
|
|
3177
3177
|
} catch {
|
|
3178
3178
|
}
|
|
3179
3179
|
try {
|
|
3180
|
-
const
|
|
3181
|
-
|
|
3180
|
+
const s = await t.text();
|
|
3181
|
+
s && s.trim().length > 0 ? await r(s.trim()) : await r(`${t.status} ${t.statusText}`);
|
|
3182
3182
|
} catch {
|
|
3183
3183
|
await r(`${t.status} ${t.statusText}`);
|
|
3184
3184
|
}
|
|
3185
|
-
return
|
|
3185
|
+
return i(), !1;
|
|
3186
3186
|
}
|
|
3187
3187
|
/**
|
|
3188
3188
|
* 対象のフラグメント以下の入力要素に対してバリデーションを実行します。
|
|
@@ -3207,8 +3207,8 @@ ${d}
|
|
|
3207
3207
|
findFirstInvalid(t) {
|
|
3208
3208
|
let e = null;
|
|
3209
3209
|
for (const r of t.getChildElementFragments().reverse()) {
|
|
3210
|
-
const
|
|
3211
|
-
|
|
3210
|
+
const i = this.findFirstInvalid(r);
|
|
3211
|
+
i !== null && (e = i);
|
|
3212
3212
|
}
|
|
3213
3213
|
return this.checkOne(t) ? e : t.getTarget();
|
|
3214
3214
|
}
|
|
@@ -3231,7 +3231,7 @@ ${d}
|
|
|
3231
3231
|
*/
|
|
3232
3232
|
confirm() {
|
|
3233
3233
|
const t = this.options.confirmMessage;
|
|
3234
|
-
return t == null ? Promise.resolve(!0) :
|
|
3234
|
+
return t == null ? Promise.resolve(!0) : z().confirm(t);
|
|
3235
3235
|
}
|
|
3236
3236
|
/**
|
|
3237
3237
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -3242,24 +3242,24 @@ ${d}
|
|
|
3242
3242
|
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
3243
|
if (this.options.bindParams) {
|
|
3244
3244
|
const n = {};
|
|
3245
|
-
this.options.bindParams.forEach((
|
|
3246
|
-
r && typeof r == "object" &&
|
|
3245
|
+
this.options.bindParams.forEach((s) => {
|
|
3246
|
+
r && typeof r == "object" && s in r && (n[s] = r[s]);
|
|
3247
3247
|
}), r = n;
|
|
3248
3248
|
}
|
|
3249
|
-
const
|
|
3249
|
+
const i = [];
|
|
3250
3250
|
if (this.options.bindArg)
|
|
3251
3251
|
this.options.bindFragments.forEach((n) => {
|
|
3252
|
-
const
|
|
3252
|
+
const s = n.getBindingData(), a = this.options.bindArg;
|
|
3253
3253
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3254
|
-
const o =
|
|
3255
|
-
|
|
3254
|
+
const o = s[a], l = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3255
|
+
s[a] = this.mergeAppendBindingData(
|
|
3256
3256
|
n,
|
|
3257
3257
|
r,
|
|
3258
3258
|
l
|
|
3259
3259
|
);
|
|
3260
3260
|
} else
|
|
3261
|
-
|
|
3262
|
-
|
|
3261
|
+
s[a] = r;
|
|
3262
|
+
i.push(R.setBindingData(n.getTarget(), s));
|
|
3263
3263
|
});
|
|
3264
3264
|
else {
|
|
3265
3265
|
if (typeof r == "string")
|
|
@@ -3267,19 +3267,19 @@ ${d}
|
|
|
3267
3267
|
new Error("string data cannot be bound without a bindArg.")
|
|
3268
3268
|
);
|
|
3269
3269
|
this.options.bindFragments.forEach((n) => {
|
|
3270
|
-
const
|
|
3270
|
+
const s = this.mergeAppendBindingData(
|
|
3271
3271
|
n,
|
|
3272
3272
|
r
|
|
3273
3273
|
);
|
|
3274
|
-
|
|
3274
|
+
i.push(
|
|
3275
3275
|
R.setBindingData(
|
|
3276
3276
|
n.getTarget(),
|
|
3277
|
-
|
|
3277
|
+
s
|
|
3278
3278
|
)
|
|
3279
3279
|
);
|
|
3280
3280
|
});
|
|
3281
3281
|
}
|
|
3282
|
-
return Promise.all(
|
|
3282
|
+
return Promise.all(i).then(() => {
|
|
3283
3283
|
});
|
|
3284
3284
|
});
|
|
3285
3285
|
}
|
|
@@ -3289,12 +3289,12 @@ ${d}
|
|
|
3289
3289
|
mergeAppendBindingData(t, e, r = t.getBindingData()) {
|
|
3290
3290
|
if (!this.options.bindAppendParams || this.options.bindAppendParams.length === 0)
|
|
3291
3291
|
return e;
|
|
3292
|
-
const
|
|
3293
|
-
for (const
|
|
3294
|
-
const a = s
|
|
3295
|
-
Array.isArray(o) && Array.isArray(a) && (s
|
|
3292
|
+
const i = { ...e }, n = r;
|
|
3293
|
+
for (const s of this.options.bindAppendParams) {
|
|
3294
|
+
const a = i[s], o = n[s];
|
|
3295
|
+
Array.isArray(o) && Array.isArray(a) && (i[s] = o.concat(a));
|
|
3296
3296
|
}
|
|
3297
|
-
return
|
|
3297
|
+
return i;
|
|
3298
3298
|
}
|
|
3299
3299
|
/**
|
|
3300
3300
|
* 指定されたフラグメントへバインディングデータをコピーします。
|
|
@@ -3302,12 +3302,12 @@ ${d}
|
|
|
3302
3302
|
copy() {
|
|
3303
3303
|
if (!this.options.copyFragments || this.options.copyFragments.length === 0)
|
|
3304
3304
|
return Promise.resolve();
|
|
3305
|
-
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((
|
|
3305
|
+
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((i) => {
|
|
3306
3306
|
const n = {
|
|
3307
|
-
...
|
|
3307
|
+
...i.getBindingData(),
|
|
3308
3308
|
...e
|
|
3309
3309
|
};
|
|
3310
|
-
return R.setBindingData(
|
|
3310
|
+
return R.setBindingData(i.getTarget(), n);
|
|
3311
3311
|
});
|
|
3312
3312
|
return Promise.all(r).then(() => {
|
|
3313
3313
|
});
|
|
@@ -3337,9 +3337,9 @@ ${d}
|
|
|
3337
3337
|
return Promise.resolve();
|
|
3338
3338
|
const t = this.options.adjustValue ?? 0, e = [];
|
|
3339
3339
|
for (const r of this.options.adjustFragments) {
|
|
3340
|
-
let
|
|
3341
|
-
(
|
|
3342
|
-
let n = Number(
|
|
3340
|
+
let i = r.getValue();
|
|
3341
|
+
(i == null || i === "") && (i = "0");
|
|
3342
|
+
let n = Number(i);
|
|
3343
3343
|
isNaN(n) && (n = 0), n += t, e.push(r.setValue(String(n)));
|
|
3344
3344
|
}
|
|
3345
3345
|
return Promise.all(e).then(() => {
|
|
@@ -3387,7 +3387,7 @@ ${d}
|
|
|
3387
3387
|
if (!t)
|
|
3388
3388
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3389
3389
|
const e = t.getParent();
|
|
3390
|
-
return e && e.getChildElementFragments().filter((
|
|
3390
|
+
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
3391
|
}
|
|
3392
3392
|
/**
|
|
3393
3393
|
* 前の行へ移動します。
|
|
@@ -3426,7 +3426,7 @@ ${d}
|
|
|
3426
3426
|
};
|
|
3427
3427
|
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
3428
|
let V = c;
|
|
3429
|
-
class
|
|
3429
|
+
class dt {
|
|
3430
3430
|
/**
|
|
3431
3431
|
* URLのクエリパラメータを取得します。
|
|
3432
3432
|
*
|
|
@@ -3434,12 +3434,12 @@ class ft {
|
|
|
3434
3434
|
*/
|
|
3435
3435
|
static readParams() {
|
|
3436
3436
|
const t = {}, e = window.location.search;
|
|
3437
|
-
return new URLSearchParams(e).forEach((
|
|
3438
|
-
t[n] =
|
|
3437
|
+
return new URLSearchParams(e).forEach((i, n) => {
|
|
3438
|
+
t[n] = i;
|
|
3439
3439
|
}), t;
|
|
3440
3440
|
}
|
|
3441
3441
|
}
|
|
3442
|
-
class
|
|
3442
|
+
class pt {
|
|
3443
3443
|
/**
|
|
3444
3444
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3445
3445
|
*
|
|
@@ -3463,17 +3463,17 @@ class dt {
|
|
|
3463
3463
|
const n = `${r.status} ${r.statusText}`;
|
|
3464
3464
|
throw f.error("[Haori]", "Import HTTP error:", t, n), new Error(`Failed to load ${t}: ${n}`);
|
|
3465
3465
|
}
|
|
3466
|
-
let
|
|
3466
|
+
let i;
|
|
3467
3467
|
try {
|
|
3468
|
-
|
|
3468
|
+
i = await r.text();
|
|
3469
3469
|
} catch (n) {
|
|
3470
3470
|
throw f.error("[Haori]", "Failed to read response text:", t, n), new Error(`Failed to read response from: ${t}`);
|
|
3471
3471
|
}
|
|
3472
3472
|
try {
|
|
3473
|
-
const
|
|
3474
|
-
return
|
|
3473
|
+
const s = new DOMParser().parseFromString(i, "text/html");
|
|
3474
|
+
return s && s.body ? s.body.innerHTML : (f.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3475
3475
|
} catch (n) {
|
|
3476
|
-
return f.error("[Haori]", "Failed to parse imported HTML:", t, n),
|
|
3476
|
+
return f.error("[Haori]", "Failed to parse imported HTML:", t, n), i;
|
|
3477
3477
|
}
|
|
3478
3478
|
}
|
|
3479
3479
|
}
|
|
@@ -3543,9 +3543,9 @@ const g = class g {
|
|
|
3543
3543
|
static reevaluateInterpolatedAttributes(t) {
|
|
3544
3544
|
let e = Promise.resolve();
|
|
3545
3545
|
for (const r of t.getAttributeNames()) {
|
|
3546
|
-
const
|
|
3547
|
-
g.shouldReevaluateAttribute(r,
|
|
3548
|
-
() => g.setAttribute(t.getTarget(), r,
|
|
3546
|
+
const i = t.getRawAttribute(r);
|
|
3547
|
+
g.shouldReevaluateAttribute(r, i) && (e = e.then(
|
|
3548
|
+
() => g.setAttribute(t.getTarget(), r, i)
|
|
3549
3549
|
));
|
|
3550
3550
|
}
|
|
3551
3551
|
return e.then(() => {
|
|
@@ -3563,39 +3563,39 @@ const g = class g {
|
|
|
3563
3563
|
return Promise.resolve();
|
|
3564
3564
|
t.parentNode && (w.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3565
3565
|
let r = Promise.resolve();
|
|
3566
|
-
const
|
|
3566
|
+
const i = /* @__PURE__ */ new Set();
|
|
3567
3567
|
for (const n of g.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3568
|
-
const
|
|
3569
|
-
e.hasAttribute(
|
|
3568
|
+
const s = u.prefix + n;
|
|
3569
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3570
3570
|
() => g.setAttribute(
|
|
3571
3571
|
e.getTarget(),
|
|
3572
|
-
|
|
3573
|
-
e.getRawAttribute(
|
|
3572
|
+
s,
|
|
3573
|
+
e.getRawAttribute(s)
|
|
3574
3574
|
)
|
|
3575
|
-
),
|
|
3575
|
+
), i.add(s));
|
|
3576
3576
|
}
|
|
3577
3577
|
for (const n of e.getAttributeNames()) {
|
|
3578
|
-
if (
|
|
3578
|
+
if (i.has(n) || g.isDeferredAttributeName(n))
|
|
3579
3579
|
continue;
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3582
|
-
() => g.setAttribute(e.getTarget(), n,
|
|
3580
|
+
const s = e.getRawAttribute(n);
|
|
3581
|
+
s !== null && (r = r.then(
|
|
3582
|
+
() => g.setAttribute(e.getTarget(), n, s)
|
|
3583
3583
|
));
|
|
3584
3584
|
}
|
|
3585
3585
|
for (const n of g.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3586
|
-
const
|
|
3587
|
-
e.hasAttribute(
|
|
3586
|
+
const s = u.prefix + n;
|
|
3587
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3588
3588
|
() => g.setAttribute(
|
|
3589
3589
|
e.getTarget(),
|
|
3590
|
-
|
|
3591
|
-
e.getRawAttribute(
|
|
3590
|
+
s,
|
|
3591
|
+
e.getRawAttribute(s)
|
|
3592
3592
|
)
|
|
3593
|
-
),
|
|
3593
|
+
), i.add(s));
|
|
3594
3594
|
}
|
|
3595
3595
|
return r.then(() => {
|
|
3596
3596
|
const n = [];
|
|
3597
|
-
return e.getChildren().forEach((
|
|
3598
|
-
|
|
3597
|
+
return e.getChildren().forEach((s) => {
|
|
3598
|
+
s instanceof x ? n.push(g.scan(s.getTarget())) : s instanceof C && n.push(g.evaluateText(s));
|
|
3599
3599
|
}), Promise.all(n).then(() => {
|
|
3600
3600
|
});
|
|
3601
3601
|
}).then(() => {
|
|
@@ -3610,14 +3610,14 @@ const g = class g {
|
|
|
3610
3610
|
* @param value 属性値
|
|
3611
3611
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3612
3612
|
*/
|
|
3613
|
-
static setAttribute(t, e, r,
|
|
3614
|
-
const n = w.get(t),
|
|
3615
|
-
if (
|
|
3616
|
-
return r === null ? n.removeAliasedAttribute(e,
|
|
3613
|
+
static setAttribute(t, e, r, i = !1) {
|
|
3614
|
+
const n = w.get(t), s = g.getAliasedAttributeName(e);
|
|
3615
|
+
if (s !== null)
|
|
3616
|
+
return r === null ? n.removeAliasedAttribute(e, s) : n.setAliasedAttribute(
|
|
3617
3617
|
e,
|
|
3618
|
-
|
|
3618
|
+
s,
|
|
3619
3619
|
r,
|
|
3620
|
-
|
|
3620
|
+
i
|
|
3621
3621
|
);
|
|
3622
3622
|
const a = [];
|
|
3623
3623
|
switch (e) {
|
|
@@ -3641,17 +3641,17 @@ const g = class g {
|
|
|
3641
3641
|
if (typeof r == "string") {
|
|
3642
3642
|
const o = n.getTarget(), l = performance.now();
|
|
3643
3643
|
o.setAttribute(`${u.prefix}importing`, ""), N.importStart(o, r), a.push(
|
|
3644
|
-
|
|
3644
|
+
pt.load(r).then((p) => {
|
|
3645
3645
|
const m = new TextEncoder().encode(p).length;
|
|
3646
3646
|
return F.enqueue(() => {
|
|
3647
3647
|
o.innerHTML = p;
|
|
3648
3648
|
}).then(() => {
|
|
3649
3649
|
if (o.removeAttribute(`${u.prefix}importing`), N.importEnd(o, r, m, l), !document.body.hasAttribute("data-haori-ready")) {
|
|
3650
|
-
const
|
|
3650
|
+
const E = [];
|
|
3651
3651
|
return o.childNodes.forEach((T) => {
|
|
3652
3652
|
const h = w.get(T);
|
|
3653
|
-
h instanceof x ?
|
|
3654
|
-
}), Promise.all(
|
|
3653
|
+
h instanceof x ? E.push(g.scan(h.getTarget())) : h instanceof C && E.push(g.evaluateText(h));
|
|
3654
|
+
}), Promise.all(E).then(() => {
|
|
3655
3655
|
});
|
|
3656
3656
|
}
|
|
3657
3657
|
});
|
|
@@ -3663,7 +3663,7 @@ const g = class g {
|
|
|
3663
3663
|
break;
|
|
3664
3664
|
}
|
|
3665
3665
|
case `${u.prefix}url-param`: {
|
|
3666
|
-
const o = n.getAttribute(`${u.prefix}url-arg`), l =
|
|
3666
|
+
const o = n.getAttribute(`${u.prefix}url-arg`), l = dt.readParams();
|
|
3667
3667
|
if (o === null)
|
|
3668
3668
|
a.push(g.setBindingData(t, l));
|
|
3669
3669
|
else {
|
|
@@ -3673,7 +3673,7 @@ const g = class g {
|
|
|
3673
3673
|
break;
|
|
3674
3674
|
}
|
|
3675
3675
|
}
|
|
3676
|
-
return r === null ? a.push(n.removeAttribute(e)) : a.push(n.setAttribute(e, r,
|
|
3676
|
+
return r === null ? a.push(n.removeAttribute(e)) : a.push(n.setAttribute(e, r, i)), Promise.all(a).then(() => {
|
|
3677
3677
|
});
|
|
3678
3678
|
}
|
|
3679
3679
|
/**
|
|
@@ -3684,18 +3684,18 @@ const g = class g {
|
|
|
3684
3684
|
* @param value 属性値
|
|
3685
3685
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3686
3686
|
*/
|
|
3687
|
-
static setBindingData(t, e) {
|
|
3688
|
-
const
|
|
3689
|
-
|
|
3690
|
-
let
|
|
3687
|
+
static setBindingData(t, e, r = /* @__PURE__ */ new Set()) {
|
|
3688
|
+
const i = w.get(t), n = i.getRawBindingData();
|
|
3689
|
+
i.setBindingData(e);
|
|
3690
|
+
let s = i.setAttribute(
|
|
3691
3691
|
`${u.prefix}bind`,
|
|
3692
3692
|
JSON.stringify(e)
|
|
3693
3693
|
);
|
|
3694
3694
|
if (t.tagName === "FORM") {
|
|
3695
|
-
const
|
|
3696
|
-
|
|
3695
|
+
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;
|
|
3696
|
+
s = s.then(() => A.syncValues(i, o));
|
|
3697
3697
|
}
|
|
3698
|
-
return
|
|
3698
|
+
return s = s.then(() => g.evaluateAll(i, r)), N.bindChange(t, n, e, "manual"), s.then(() => {
|
|
3699
3699
|
});
|
|
3700
3700
|
}
|
|
3701
3701
|
/**
|
|
@@ -3713,8 +3713,8 @@ const g = class g {
|
|
|
3713
3713
|
}
|
|
3714
3714
|
else {
|
|
3715
3715
|
const e = new URLSearchParams(t), r = {};
|
|
3716
|
-
for (const [
|
|
3717
|
-
r[
|
|
3716
|
+
for (const [i, n] of e.entries())
|
|
3717
|
+
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(n) : r[i] = [r[i], n] : r[i] = n;
|
|
3718
3718
|
return r;
|
|
3719
3719
|
}
|
|
3720
3720
|
}
|
|
@@ -3728,8 +3728,8 @@ const g = class g {
|
|
|
3728
3728
|
const r = w.get(t);
|
|
3729
3729
|
if (r.isSkipMutationNodes())
|
|
3730
3730
|
return;
|
|
3731
|
-
const
|
|
3732
|
-
n && (r.insertBefore(n,
|
|
3731
|
+
const i = w.get(e.nextSibling), n = w.get(e);
|
|
3732
|
+
n && (r.insertBefore(n, i), n instanceof x ? g.scan(n.getTarget()) : n instanceof C && g.evaluateText(n));
|
|
3733
3733
|
}
|
|
3734
3734
|
/**
|
|
3735
3735
|
* ノードを親要素から削除します。
|
|
@@ -3767,15 +3767,15 @@ const g = class g {
|
|
|
3767
3767
|
const r = w.get(t);
|
|
3768
3768
|
if (r.getValue() === e)
|
|
3769
3769
|
return Promise.resolve();
|
|
3770
|
-
const
|
|
3771
|
-
|
|
3770
|
+
const i = [];
|
|
3771
|
+
i.push(r.setValue(e));
|
|
3772
3772
|
const n = g.getFormFragment(r);
|
|
3773
3773
|
if (n) {
|
|
3774
|
-
const
|
|
3774
|
+
const s = A.getValues(n), a = n.getAttribute(`${u.prefix}form-arg`);
|
|
3775
3775
|
let o;
|
|
3776
|
-
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] =
|
|
3776
|
+
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(g.setBindingData(n.getTarget(), o));
|
|
3777
3777
|
}
|
|
3778
|
-
return Promise.all(
|
|
3778
|
+
return Promise.all(i).then(() => {
|
|
3779
3779
|
});
|
|
3780
3780
|
}
|
|
3781
3781
|
/**
|
|
@@ -3796,11 +3796,13 @@ const g = class g {
|
|
|
3796
3796
|
* @param fragment 対象フラグメント
|
|
3797
3797
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3798
3798
|
*/
|
|
3799
|
-
static evaluateAll(t) {
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
}), Promise.all(
|
|
3799
|
+
static evaluateAll(t, e = /* @__PURE__ */ new Set()) {
|
|
3800
|
+
if (e.has(t))
|
|
3801
|
+
return Promise.resolve();
|
|
3802
|
+
const r = [];
|
|
3803
|
+
return r.push(g.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${u.prefix}if`) && r.push(g.evaluateIf(t)), t.hasAttribute(`${u.prefix}each`) ? Promise.all(r).then(() => g.evaluateEach(t)) : (t.getChildren().forEach((i) => {
|
|
3804
|
+
i instanceof x ? r.push(g.evaluateAll(i, e)) : i instanceof C && r.push(g.evaluateText(i));
|
|
3805
|
+
}), Promise.all(r).then(() => {
|
|
3804
3806
|
}));
|
|
3805
3807
|
}
|
|
3806
3808
|
/**
|
|
@@ -3828,14 +3830,14 @@ const g = class g {
|
|
|
3828
3830
|
})
|
|
3829
3831
|
);
|
|
3830
3832
|
else {
|
|
3831
|
-
const
|
|
3833
|
+
const i = [];
|
|
3832
3834
|
t.getChildren().forEach((n) => {
|
|
3833
|
-
n instanceof x ?
|
|
3835
|
+
n instanceof x ? i.push(g.evaluateAll(n)) : n instanceof C && i.push(g.evaluateText(n));
|
|
3834
3836
|
}), e.push(
|
|
3835
3837
|
t.show().then(() => {
|
|
3836
3838
|
N.show(t.getTarget());
|
|
3837
3839
|
})
|
|
3838
|
-
), e.push(Promise.all(
|
|
3840
|
+
), e.push(Promise.all(i).then(() => {
|
|
3839
3841
|
}));
|
|
3840
3842
|
}
|
|
3841
3843
|
return Promise.all(e).then(() => {
|
|
@@ -3852,14 +3854,14 @@ const g = class g {
|
|
|
3852
3854
|
return Promise.resolve();
|
|
3853
3855
|
let e = t.getTemplate();
|
|
3854
3856
|
if (e === null) {
|
|
3855
|
-
let
|
|
3856
|
-
t.getChildren().forEach((
|
|
3857
|
-
if (!
|
|
3858
|
-
if (
|
|
3857
|
+
let i = !1;
|
|
3858
|
+
t.getChildren().forEach((s) => {
|
|
3859
|
+
if (!i && s instanceof x) {
|
|
3860
|
+
if (s.hasAttribute(`${u.prefix}each-before`) || s.hasAttribute(`${u.prefix}each-after`))
|
|
3859
3861
|
return;
|
|
3860
|
-
e =
|
|
3861
|
-
const a =
|
|
3862
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3862
|
+
e = s.clone(), t.setTemplate(e), i = !0, t.removeChild(s);
|
|
3863
|
+
const a = s.getTarget();
|
|
3864
|
+
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3863
3865
|
}
|
|
3864
3866
|
});
|
|
3865
3867
|
const n = t.getAttribute(`${u.prefix}each`);
|
|
@@ -3878,9 +3880,9 @@ const g = class g {
|
|
|
3878
3880
|
const r = t.getTemplate();
|
|
3879
3881
|
if (r === null)
|
|
3880
3882
|
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`),
|
|
3883
|
+
let i = t.getAttribute(`${u.prefix}each-index`);
|
|
3884
|
+
i && (i = String(i));
|
|
3885
|
+
const n = t.getAttribute(`${u.prefix}each-key`), s = t.getAttribute(`${u.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3884
3886
|
e.forEach((h, d) => {
|
|
3885
3887
|
const b = g.createListKey(
|
|
3886
3888
|
h,
|
|
@@ -3894,32 +3896,32 @@ const g = class g {
|
|
|
3894
3896
|
(h) => !h.hasAttribute(`${u.prefix}each-before`) && !h.hasAttribute(`${u.prefix}each-after`)
|
|
3895
3897
|
);
|
|
3896
3898
|
p = p.filter((h) => o.indexOf(String(h.getListKey())) === -1 ? (l.push(h.remove()), !1) : !0);
|
|
3897
|
-
const m = p.map((h) => h.getListKey()),
|
|
3899
|
+
const m = p.map((h) => h.getListKey()), E = t.getChildren().filter((h) => h instanceof x).filter((h) => h.hasAttribute(`${u.prefix}each-before`)).length;
|
|
3898
3900
|
let T = Promise.resolve();
|
|
3899
3901
|
return o.forEach((h, d) => {
|
|
3900
|
-
const b = m.indexOf(h), { item:
|
|
3902
|
+
const b = m.indexOf(h), { item: v, itemIndex: y } = a.get(h);
|
|
3901
3903
|
let M;
|
|
3902
3904
|
if (b !== -1)
|
|
3903
3905
|
M = p[b], T = T.then(
|
|
3904
3906
|
() => g.updateRowFragment(
|
|
3905
3907
|
M,
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
+
v,
|
|
3909
|
+
i,
|
|
3908
3910
|
y,
|
|
3909
|
-
|
|
3911
|
+
s ? String(s) : null,
|
|
3910
3912
|
h
|
|
3911
3913
|
).then(() => g.evaluateAll(M)).then(() => g.scheduleEvaluateAll(M))
|
|
3912
3914
|
);
|
|
3913
3915
|
else {
|
|
3914
3916
|
M = r.clone();
|
|
3915
|
-
const J =
|
|
3917
|
+
const J = E + d;
|
|
3916
3918
|
T = T.then(
|
|
3917
3919
|
() => g.updateRowFragment(
|
|
3918
3920
|
M,
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
+
v,
|
|
3922
|
+
i,
|
|
3921
3923
|
y,
|
|
3922
|
-
|
|
3924
|
+
s ? String(s) : null,
|
|
3923
3925
|
h
|
|
3924
3926
|
).then(
|
|
3925
3927
|
() => t.insertBefore(
|
|
@@ -3936,13 +3938,13 @@ const g = class g {
|
|
|
3936
3938
|
(y) => y !== null
|
|
3937
3939
|
), b = h.filter(
|
|
3938
3940
|
(y) => !d.includes(y)
|
|
3939
|
-
),
|
|
3941
|
+
), v = d.filter(
|
|
3940
3942
|
(y) => !h.includes(y)
|
|
3941
3943
|
);
|
|
3942
3944
|
N.eachUpdate(
|
|
3943
3945
|
t.getTarget(),
|
|
3944
3946
|
b,
|
|
3945
|
-
|
|
3947
|
+
v,
|
|
3946
3948
|
h
|
|
3947
3949
|
);
|
|
3948
3950
|
});
|
|
@@ -3956,16 +3958,16 @@ const g = class g {
|
|
|
3956
3958
|
* @returns リストキー
|
|
3957
3959
|
*/
|
|
3958
3960
|
static createListKey(t, e, r) {
|
|
3959
|
-
let
|
|
3961
|
+
let i;
|
|
3960
3962
|
if (typeof t == "object" && t !== null)
|
|
3961
3963
|
if (e) {
|
|
3962
3964
|
const n = t[e];
|
|
3963
|
-
n == null ?
|
|
3965
|
+
n == null ? i = `__index_${r}` : typeof n == "object" ? i = JSON.stringify(n) : i = String(n);
|
|
3964
3966
|
} else
|
|
3965
|
-
|
|
3967
|
+
i = `__index_${r}`;
|
|
3966
3968
|
else
|
|
3967
|
-
|
|
3968
|
-
return
|
|
3969
|
+
i = String(t);
|
|
3970
|
+
return i;
|
|
3969
3971
|
}
|
|
3970
3972
|
/**
|
|
3971
3973
|
* 行フラグメントにデータを設定します。
|
|
@@ -3978,22 +3980,22 @@ const g = class g {
|
|
|
3978
3980
|
* @param listKey リストキー
|
|
3979
3981
|
* @returns 行メタデータの更新完了 Promise
|
|
3980
3982
|
*/
|
|
3981
|
-
static updateRowFragment(t, e, r,
|
|
3983
|
+
static updateRowFragment(t, e, r, i, n, s) {
|
|
3982
3984
|
let a = e;
|
|
3983
3985
|
if (typeof e == "object" && e !== null)
|
|
3984
|
-
a = { ...e }, r && (a[r] =
|
|
3986
|
+
a = { ...e }, r && (a[r] = i), n && (a = {
|
|
3985
3987
|
[n]: a
|
|
3986
3988
|
});
|
|
3987
3989
|
else if (n)
|
|
3988
3990
|
a = {
|
|
3989
3991
|
[n]: e
|
|
3990
|
-
}, r && (a[r] =
|
|
3992
|
+
}, r && (a[r] = i);
|
|
3991
3993
|
else
|
|
3992
3994
|
return f.error(
|
|
3993
3995
|
"[Haori]",
|
|
3994
3996
|
`Primitive value requires '${u.prefix}each-arg' attribute: ${e}`
|
|
3995
3997
|
), Promise.resolve();
|
|
3996
|
-
return t.setListKey(
|
|
3998
|
+
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${u.prefix}row`, s);
|
|
3997
3999
|
}
|
|
3998
4000
|
/**
|
|
3999
4001
|
* フラグメントの再評価を次のイベントループで実行します。
|
|
@@ -4053,8 +4055,8 @@ const Y = class Y {
|
|
|
4053
4055
|
const r = this.getElementFromTarget(t.target, e);
|
|
4054
4056
|
if (!r)
|
|
4055
4057
|
return;
|
|
4056
|
-
const
|
|
4057
|
-
|
|
4058
|
+
const i = w.get(r);
|
|
4059
|
+
i && (e === "change" && i instanceof x && i.syncValue(), new V(i, e).run().catch((n) => {
|
|
4058
4060
|
f.error("[Haori]", "Procedure execution error:", n);
|
|
4059
4061
|
}));
|
|
4060
4062
|
}
|
|
@@ -4095,7 +4097,7 @@ const Y = class Y {
|
|
|
4095
4097
|
}
|
|
4096
4098
|
};
|
|
4097
4099
|
Y.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
4098
|
-
let
|
|
4100
|
+
let Z = Y;
|
|
4099
4101
|
const S = class S {
|
|
4100
4102
|
static syncTree(t) {
|
|
4101
4103
|
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && S.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
@@ -4110,10 +4112,10 @@ const S = class S {
|
|
|
4110
4112
|
}
|
|
4111
4113
|
if (typeof IntersectionObserver > "u")
|
|
4112
4114
|
return;
|
|
4113
|
-
const
|
|
4114
|
-
if (e && e.observer.root ===
|
|
4115
|
+
const i = S.resolveRoot(r), n = S.resolveRootMargin(r), s = S.resolveThreshold(r), a = r.hasAttribute(`${u.prefix}intersect-once`);
|
|
4116
|
+
if (e && e.observer.root === i && e.observer.rootMargin === n && S.sameThreshold(
|
|
4115
4117
|
e.observer.thresholds,
|
|
4116
|
-
|
|
4118
|
+
s
|
|
4117
4119
|
) && e.once === a) {
|
|
4118
4120
|
e.fragment = r;
|
|
4119
4121
|
return;
|
|
@@ -4123,24 +4125,24 @@ const S = class S {
|
|
|
4123
4125
|
(l) => {
|
|
4124
4126
|
const p = S.registrations.get(t);
|
|
4125
4127
|
p && l.forEach((m) => {
|
|
4126
|
-
!m.isIntersecting || p.running || S.isDisabled(p.fragment) || (p.running = !0, new V(p.fragment, "intersect").runWithResult().then((
|
|
4127
|
-
|
|
4128
|
-
}).catch((
|
|
4128
|
+
!m.isIntersecting || p.running || S.isDisabled(p.fragment) || (p.running = !0, new V(p.fragment, "intersect").runWithResult().then((E) => {
|
|
4129
|
+
E && p.once && (p.observer.disconnect(), S.registrations.delete(t));
|
|
4130
|
+
}).catch((E) => {
|
|
4129
4131
|
f.error(
|
|
4130
4132
|
"[Haori]",
|
|
4131
4133
|
"Intersect procedure execution error:",
|
|
4132
|
-
|
|
4134
|
+
E
|
|
4133
4135
|
);
|
|
4134
4136
|
}).finally(() => {
|
|
4135
|
-
const
|
|
4136
|
-
|
|
4137
|
+
const E = S.registrations.get(t);
|
|
4138
|
+
E && (E.running = !1);
|
|
4137
4139
|
}));
|
|
4138
4140
|
});
|
|
4139
4141
|
},
|
|
4140
4142
|
{
|
|
4141
|
-
root:
|
|
4143
|
+
root: i,
|
|
4142
4144
|
rootMargin: n,
|
|
4143
|
-
threshold:
|
|
4145
|
+
threshold: s
|
|
4144
4146
|
}
|
|
4145
4147
|
);
|
|
4146
4148
|
o.observe(t), S.registrations.set(t, {
|
|
@@ -4180,16 +4182,16 @@ const S = class S {
|
|
|
4180
4182
|
const r = t.getAttribute(e);
|
|
4181
4183
|
if (typeof r != "string" || r.trim() === "")
|
|
4182
4184
|
return null;
|
|
4183
|
-
const
|
|
4184
|
-
return
|
|
4185
|
+
const i = document.querySelector(r);
|
|
4186
|
+
return i instanceof HTMLElement ? i : (f.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
4185
4187
|
}
|
|
4186
4188
|
static resolveRootMargin(t) {
|
|
4187
4189
|
const e = `${u.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
4188
4190
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
4189
4191
|
}
|
|
4190
4192
|
static resolveThreshold(t) {
|
|
4191
|
-
const e = `${u.prefix}intersect-threshold`, r = t.getAttribute(e),
|
|
4192
|
-
return Number.isNaN(
|
|
4193
|
+
const e = `${u.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
4194
|
+
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
4193
4195
|
}
|
|
4194
4196
|
static isDisabled(t) {
|
|
4195
4197
|
const e = `${u.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
@@ -4197,8 +4199,8 @@ const S = class S {
|
|
|
4197
4199
|
return !1;
|
|
4198
4200
|
if (typeof r == "boolean")
|
|
4199
4201
|
return r;
|
|
4200
|
-
const
|
|
4201
|
-
return
|
|
4202
|
+
const i = String(r).trim().toLowerCase();
|
|
4203
|
+
return i !== "" && i !== "false" && i !== "0";
|
|
4202
4204
|
}
|
|
4203
4205
|
static sameThreshold(t, e) {
|
|
4204
4206
|
return t.length === 1 && t[0] === e;
|
|
@@ -4212,20 +4214,20 @@ S.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
4212
4214
|
"once"
|
|
4213
4215
|
]), S.registrations = /* @__PURE__ */ new Map();
|
|
4214
4216
|
let $ = S;
|
|
4215
|
-
const
|
|
4217
|
+
const L = class L {
|
|
4216
4218
|
/**
|
|
4217
4219
|
* 初期化メソッド。
|
|
4218
4220
|
* ドキュメントのheadとbodyを監視対象として設定します。
|
|
4219
4221
|
*/
|
|
4220
4222
|
static async init() {
|
|
4221
|
-
if (
|
|
4223
|
+
if (L._initialized)
|
|
4222
4224
|
return;
|
|
4223
|
-
|
|
4225
|
+
L._initialized = !0;
|
|
4224
4226
|
const t = await Promise.allSettled([
|
|
4225
4227
|
R.scan(document.head),
|
|
4226
4228
|
R.scan(document.body)
|
|
4227
4229
|
]), [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", ""),
|
|
4230
|
+
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", ""), L.observe(document.head), L.observe(document.body), new Z().start(), $.syncTree(document.body);
|
|
4229
4231
|
}
|
|
4230
4232
|
/**
|
|
4231
4233
|
* 指定された要素を監視します。
|
|
@@ -4234,26 +4236,26 @@ const H = class H {
|
|
|
4234
4236
|
*/
|
|
4235
4237
|
static observe(t) {
|
|
4236
4238
|
new MutationObserver(async (r) => {
|
|
4237
|
-
for (const
|
|
4239
|
+
for (const i of r)
|
|
4238
4240
|
try {
|
|
4239
|
-
switch (
|
|
4241
|
+
switch (i.type) {
|
|
4240
4242
|
case "attributes": {
|
|
4241
4243
|
f.info(
|
|
4242
4244
|
"[Haori]",
|
|
4243
4245
|
"Attribute changed:",
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
+
i.target,
|
|
4247
|
+
i.attributeName
|
|
4246
4248
|
);
|
|
4247
|
-
const n =
|
|
4248
|
-
if (
|
|
4249
|
+
const n = i.target;
|
|
4250
|
+
if (i.attributeName && n.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && R.isAliasedAttributeReflection(
|
|
4249
4251
|
n,
|
|
4250
|
-
|
|
4252
|
+
i.attributeName
|
|
4251
4253
|
))
|
|
4252
4254
|
break;
|
|
4253
4255
|
R.setAttribute(
|
|
4254
4256
|
n,
|
|
4255
|
-
|
|
4256
|
-
n.getAttribute(
|
|
4257
|
+
i.attributeName,
|
|
4258
|
+
n.getAttribute(i.attributeName),
|
|
4257
4259
|
!0
|
|
4258
4260
|
), $.syncElement(n);
|
|
4259
4261
|
break;
|
|
@@ -4262,11 +4264,11 @@ const H = class H {
|
|
|
4262
4264
|
f.info(
|
|
4263
4265
|
"[Haori]",
|
|
4264
4266
|
"Child list changed:",
|
|
4265
|
-
Array.from(
|
|
4266
|
-
Array.from(
|
|
4267
|
-
), Array.from(
|
|
4267
|
+
Array.from(i.removedNodes).map((n) => n.nodeName),
|
|
4268
|
+
Array.from(i.addedNodes).map((n) => n.nodeName)
|
|
4269
|
+
), Array.from(i.removedNodes).forEach((n) => {
|
|
4268
4270
|
$.cleanupTree(n), R.removeNode(n);
|
|
4269
|
-
}), Array.from(
|
|
4271
|
+
}), Array.from(i.addedNodes).forEach((n) => {
|
|
4270
4272
|
n.parentElement instanceof HTMLElement && (R.addNode(n.parentElement, n), $.syncTree(n));
|
|
4271
4273
|
});
|
|
4272
4274
|
break;
|
|
@@ -4275,17 +4277,17 @@ const H = class H {
|
|
|
4275
4277
|
f.info(
|
|
4276
4278
|
"[Haori]",
|
|
4277
4279
|
"Character data changed:",
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
),
|
|
4280
|
+
i.target,
|
|
4281
|
+
i.target.textContent
|
|
4282
|
+
), i.target instanceof Text || i.target instanceof Comment ? R.changeText(i.target, i.target.textContent) : f.warn(
|
|
4281
4283
|
"[Haori]",
|
|
4282
4284
|
"Unsupported character data type:",
|
|
4283
|
-
|
|
4285
|
+
i.target
|
|
4284
4286
|
);
|
|
4285
4287
|
break;
|
|
4286
4288
|
}
|
|
4287
4289
|
default:
|
|
4288
|
-
f.warn("[Haori]", "Unknown mutation type:",
|
|
4290
|
+
f.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
4289
4291
|
continue;
|
|
4290
4292
|
}
|
|
4291
4293
|
} catch (n) {
|
|
@@ -4299,10 +4301,10 @@ const H = class H {
|
|
|
4299
4301
|
}), f.info("[Haori]", "Observer initialized for", t);
|
|
4300
4302
|
}
|
|
4301
4303
|
};
|
|
4302
|
-
|
|
4303
|
-
let q =
|
|
4304
|
+
L._initialized = !1;
|
|
4305
|
+
let q = L;
|
|
4304
4306
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4305
|
-
const
|
|
4307
|
+
const gt = "0.4.13";
|
|
4306
4308
|
export {
|
|
4307
4309
|
R as Core,
|
|
4308
4310
|
u as Env,
|
|
@@ -4312,6 +4314,6 @@ export {
|
|
|
4312
4314
|
f as Log,
|
|
4313
4315
|
F as Queue,
|
|
4314
4316
|
X as default,
|
|
4315
|
-
|
|
4317
|
+
gt as version
|
|
4316
4318
|
};
|
|
4317
4319
|
//# sourceMappingURL=haori.es.js.map
|