haori 0.4.4 → 0.4.5
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 +13 -13
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +737 -708
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +13 -13
- package/dist/haori.iife.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/event_dispatcher.d.ts +10 -2
- package/dist/src/event_dispatcher.d.ts.map +1 -1
- package/dist/src/event_dispatcher.js +21 -3
- package/dist/src/event_dispatcher.js.map +1 -1
- package/dist/src/procedure.d.ts +16 -3
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +71 -24
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +272 -4
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/dist/tests/procedure.test.js +3 -2
- package/dist/tests/procedure.test.js.map +1 -1
- package/dist/tests/row-operations.test.js +21 -1
- package/dist/tests/row-operations.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -30,12 +30,12 @@ const O = class O {
|
|
|
30
30
|
};
|
|
31
31
|
O.devMode = !1;
|
|
32
32
|
let B = O;
|
|
33
|
-
const
|
|
34
|
-
function
|
|
33
|
+
const z = "embedded";
|
|
34
|
+
function rt(F) {
|
|
35
35
|
return F === "embedded" || F === "demo";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return F === null ? null :
|
|
37
|
+
function it(F) {
|
|
38
|
+
return F === null ? null : rt(F) ? F : z;
|
|
39
39
|
}
|
|
40
40
|
const D = class D {
|
|
41
41
|
/**
|
|
@@ -53,7 +53,7 @@ const D = class D {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
D._runtime =
|
|
56
|
+
D._runtime = rt(t) ? t : z;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -67,7 +67,7 @@ const D = class D {
|
|
|
67
67
|
if (t instanceof HTMLScriptElement) {
|
|
68
68
|
const r = t.getAttribute("data-prefix") || D._prefix;
|
|
69
69
|
D._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
-
const i =
|
|
70
|
+
const i = it(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
73
|
i !== null && (D._runtime = i);
|
|
@@ -94,10 +94,10 @@ const D = class D {
|
|
|
94
94
|
return D._prefix;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
D._prefix = "data-", D._runtime =
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
100
|
-
class
|
|
97
|
+
D._prefix = "data-", D._runtime = z;
|
|
98
|
+
let c = D;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
|
|
100
|
+
class d {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
103
103
|
*
|
|
@@ -126,7 +126,7 @@ class f {
|
|
|
126
126
|
console.error(t, ...e);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class st {
|
|
130
130
|
constructor() {
|
|
131
131
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
132
132
|
}
|
|
@@ -139,16 +139,16 @@ class rt {
|
|
|
139
139
|
*/
|
|
140
140
|
enqueue(t, e = !1) {
|
|
141
141
|
let r, i;
|
|
142
|
-
const
|
|
142
|
+
const n = new Promise((a, o) => {
|
|
143
143
|
r = a, i = o;
|
|
144
|
-
}),
|
|
144
|
+
}), s = {
|
|
145
145
|
task: t,
|
|
146
146
|
timestamp: performance.now(),
|
|
147
|
-
promise:
|
|
147
|
+
promise: n,
|
|
148
148
|
resolve: r,
|
|
149
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
|
* キューを処理します。
|
|
@@ -168,13 +168,13 @@ class rt {
|
|
|
168
168
|
const r = await e.task();
|
|
169
169
|
e.resolve(r);
|
|
170
170
|
} catch (r) {
|
|
171
|
-
e.reject(r),
|
|
171
|
+
e.reject(r), d.error("[Haori]", `Task ${e.timestamp} failed:`, r);
|
|
172
172
|
}
|
|
173
173
|
if (performance.now() - t > this.MAX_BUDGET)
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
176
176
|
} catch (t) {
|
|
177
|
-
|
|
177
|
+
d.error("[Haori]", "Error processing queue:", t);
|
|
178
178
|
} finally {
|
|
179
179
|
this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
|
|
180
180
|
}
|
|
@@ -202,7 +202,7 @@ class rt {
|
|
|
202
202
|
t.length > 0 && await Promise.allSettled(t);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const _ = class _ {
|
|
206
206
|
/**
|
|
207
207
|
* タスクをキューに追加します。
|
|
208
208
|
*
|
|
@@ -220,16 +220,16 @@ const Q = class Q {
|
|
|
220
220
|
return this.ASYNC_QUEUE.wait();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
|
|
224
|
-
let P =
|
|
225
|
-
class
|
|
223
|
+
_.ASYNC_QUEUE = new st();
|
|
224
|
+
let P = _;
|
|
225
|
+
class J {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
228
228
|
*
|
|
229
229
|
* @return 実行モード。
|
|
230
230
|
*/
|
|
231
231
|
static get runtime() {
|
|
232
|
-
return
|
|
232
|
+
return c.runtime;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* 実行モードを設定します。
|
|
@@ -238,7 +238,7 @@ class X {
|
|
|
238
238
|
* @return 戻り値はありません。
|
|
239
239
|
*/
|
|
240
240
|
static setRuntime(t) {
|
|
241
|
-
|
|
241
|
+
c.setRuntime(t);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* 通知ダイアログを表示します。
|
|
@@ -284,7 +284,7 @@ class X {
|
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
286
|
return P.enqueue(() => {
|
|
287
|
-
t instanceof HTMLDialogElement ? t.showModal() :
|
|
287
|
+
t instanceof HTMLDialogElement ? t.showModal() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
@@ -294,7 +294,7 @@ class X {
|
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
296
|
return P.enqueue(() => {
|
|
297
|
-
t instanceof HTMLDialogElement ? t.close() :
|
|
297
|
+
t instanceof HTMLDialogElement ? t.close() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
@@ -304,7 +304,7 @@ class X {
|
|
|
304
304
|
* @param message エラーメッセージ
|
|
305
305
|
*/
|
|
306
306
|
static addErrorMessage(t, e) {
|
|
307
|
-
return
|
|
307
|
+
return J.addMessage(t, e, "error");
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* メッセージをレベル付きで追加します。
|
|
@@ -332,12 +332,12 @@ class X {
|
|
|
332
332
|
}, !0);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
const
|
|
336
|
-
function
|
|
335
|
+
const nt = ["addErrorMessage", "clearMessages"];
|
|
336
|
+
function et() {
|
|
337
337
|
const t = globalThis.window?.Haori;
|
|
338
|
-
return
|
|
338
|
+
return nt.every(
|
|
339
339
|
(r) => typeof t?.[r] == "function"
|
|
340
|
-
) ? t :
|
|
340
|
+
) ? t : J;
|
|
341
341
|
}
|
|
342
342
|
class b {
|
|
343
343
|
/**
|
|
@@ -361,32 +361,32 @@ class b {
|
|
|
361
361
|
* @returns values と同じオブジェクト
|
|
362
362
|
*/
|
|
363
363
|
static getPartValues(t, e) {
|
|
364
|
-
const r = t.getAttribute("name"), i = t.getAttribute(`${
|
|
364
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${c.prefix}form-object`), n = t.getAttribute(`${c.prefix}form-list`);
|
|
365
365
|
if (r) {
|
|
366
|
-
|
|
366
|
+
n ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && d.warn(
|
|
367
367
|
"Haori",
|
|
368
|
-
`Element cannot have both ${
|
|
368
|
+
`Element cannot have both ${c.prefix}form-object and name attributes.`
|
|
369
369
|
);
|
|
370
|
-
for (const
|
|
371
|
-
b.getPartValues(
|
|
370
|
+
for (const s of t.getChildElementFragments())
|
|
371
|
+
b.getPartValues(s, e);
|
|
372
372
|
} else if (i) {
|
|
373
|
-
const
|
|
373
|
+
const s = {};
|
|
374
374
|
for (const a of t.getChildElementFragments())
|
|
375
|
-
b.getPartValues(a,
|
|
376
|
-
Object.keys(
|
|
375
|
+
b.getPartValues(a, s);
|
|
376
|
+
Object.keys(s).length > 0 && (e[String(i)] = s), n && d.warn(
|
|
377
377
|
"Haori",
|
|
378
|
-
`Element cannot have both ${
|
|
378
|
+
`Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
|
|
379
379
|
);
|
|
380
|
-
} else if (
|
|
381
|
-
const
|
|
380
|
+
} else if (n) {
|
|
381
|
+
const s = [];
|
|
382
382
|
for (const a of t.getChildElementFragments()) {
|
|
383
383
|
const o = {};
|
|
384
|
-
b.getPartValues(a, o), Object.keys(o).length > 0 &&
|
|
384
|
+
b.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
|
-
b.getPartValues(
|
|
388
|
+
for (const s of t.getChildElementFragments())
|
|
389
|
+
b.getPartValues(s, e);
|
|
390
390
|
return e;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
@@ -433,53 +433,53 @@ class b {
|
|
|
433
433
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
434
434
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
435
435
|
*/
|
|
436
|
-
static setPartValues(t, e, r = null, i = !1,
|
|
437
|
-
const
|
|
436
|
+
static setPartValues(t, e, r = null, i = !1, n = !0) {
|
|
437
|
+
const s = [], a = t.getAttribute("name"), o = t.getAttribute(`${c.prefix}form-object`), u = t.getAttribute(`${c.prefix}form-list`), m = t.getAttribute(`${c.prefix}form-detach`);
|
|
438
438
|
if (a) {
|
|
439
439
|
if (!m || i) {
|
|
440
440
|
const y = e[String(a)];
|
|
441
|
-
|
|
442
|
-
b.applyFragmentValue(t, y[r] ?? null,
|
|
443
|
-
) : typeof y > "u" || (typeof y == "string" || typeof y == "number" || typeof y == "boolean" || y === null ?
|
|
444
|
-
b.applyFragmentValue(t, String(y),
|
|
441
|
+
u && Array.isArray(y) && r !== null ? s.push(
|
|
442
|
+
b.applyFragmentValue(t, y[r] ?? null, n)
|
|
443
|
+
) : typeof y > "u" || (typeof y == "string" || typeof y == "number" || typeof y == "boolean" || y === null ? s.push(b.applyFragmentValue(t, y, n)) : s.push(
|
|
444
|
+
b.applyFragmentValue(t, String(y), n)
|
|
445
445
|
));
|
|
446
446
|
}
|
|
447
447
|
} else if (o) {
|
|
448
448
|
const y = e[String(o)];
|
|
449
449
|
if (y && typeof y == "object")
|
|
450
450
|
for (const E of t.getChildElementFragments())
|
|
451
|
-
|
|
451
|
+
s.push(
|
|
452
452
|
b.setPartValues(
|
|
453
453
|
E,
|
|
454
454
|
y,
|
|
455
455
|
null,
|
|
456
456
|
i,
|
|
457
|
-
|
|
457
|
+
n
|
|
458
458
|
)
|
|
459
459
|
);
|
|
460
|
-
} else if (
|
|
461
|
-
const y = e[String(
|
|
460
|
+
} else if (u) {
|
|
461
|
+
const y = e[String(u)];
|
|
462
462
|
if (Array.isArray(y)) {
|
|
463
463
|
const E = t.getChildElementFragments();
|
|
464
464
|
for (let S = 0; S < E.length; S++) {
|
|
465
|
-
const
|
|
466
|
-
y.length > S ?
|
|
465
|
+
const h = E[S];
|
|
466
|
+
y.length > S ? s.push(
|
|
467
467
|
b.setPartValues(
|
|
468
|
-
|
|
468
|
+
h,
|
|
469
469
|
y[S],
|
|
470
470
|
S,
|
|
471
471
|
i,
|
|
472
|
-
|
|
472
|
+
n
|
|
473
473
|
)
|
|
474
|
-
) :
|
|
474
|
+
) : s.push(b.setPartValues(h, {}, S, i, n));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
} else
|
|
478
478
|
for (const y of t.getChildElementFragments())
|
|
479
|
-
|
|
480
|
-
b.setPartValues(y, e, null, i,
|
|
479
|
+
s.push(
|
|
480
|
+
b.setPartValues(y, e, null, i, n)
|
|
481
481
|
);
|
|
482
|
-
return Promise.all(
|
|
482
|
+
return Promise.all(s).then(() => {
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
/**
|
|
@@ -500,11 +500,11 @@ class b {
|
|
|
500
500
|
else {
|
|
501
501
|
const r = e.parentElement;
|
|
502
502
|
if (r) {
|
|
503
|
-
const i = e.nextElementSibling,
|
|
504
|
-
|
|
503
|
+
const i = e.nextElementSibling, n = document.createElement("form");
|
|
504
|
+
n.appendChild(e), n.reset(), r.insertBefore(e, i);
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
}), await
|
|
507
|
+
}), await R.evaluateAll(t);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -513,20 +513,20 @@ class b {
|
|
|
513
513
|
* 対象エレメント自体は削除しません。
|
|
514
514
|
*/
|
|
515
515
|
static clearEachClones(t) {
|
|
516
|
-
const e = [], r = (
|
|
517
|
-
if (
|
|
518
|
-
for (const
|
|
519
|
-
const a =
|
|
520
|
-
!a && !o && e.push(
|
|
516
|
+
const e = [], r = (n) => {
|
|
517
|
+
if (n.hasAttribute(`${c.prefix}each`))
|
|
518
|
+
for (const s of n.getChildElementFragments()) {
|
|
519
|
+
const a = s.hasAttribute(`${c.prefix}each-before`), o = s.hasAttribute(`${c.prefix}each-after`);
|
|
520
|
+
!a && !o && e.push(s.remove());
|
|
521
521
|
}
|
|
522
|
-
}, i = (
|
|
523
|
-
r(
|
|
524
|
-
for (const
|
|
525
|
-
i(
|
|
522
|
+
}, i = (n) => {
|
|
523
|
+
r(n);
|
|
524
|
+
for (const s of n.getChildElementFragments())
|
|
525
|
+
i(s);
|
|
526
526
|
};
|
|
527
527
|
r(t);
|
|
528
|
-
for (const
|
|
529
|
-
i(
|
|
528
|
+
for (const n of t.getChildElementFragments())
|
|
529
|
+
i(n);
|
|
530
530
|
return Promise.all(e).then(() => {
|
|
531
531
|
});
|
|
532
532
|
}
|
|
@@ -547,7 +547,7 @@ class b {
|
|
|
547
547
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
548
548
|
*/
|
|
549
549
|
static clearMessages(t) {
|
|
550
|
-
return
|
|
550
|
+
return et().clearMessages(
|
|
551
551
|
t.getTarget()
|
|
552
552
|
);
|
|
553
553
|
}
|
|
@@ -574,10 +574,10 @@ class b {
|
|
|
574
574
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
575
575
|
*/
|
|
576
576
|
static addMessage(t, e, r, i) {
|
|
577
|
-
const
|
|
578
|
-
return
|
|
579
|
-
|
|
580
|
-
}),
|
|
577
|
+
const n = [], s = et(), a = s.addMessage, o = (m) => typeof a == "function" ? a.call(s, m, r, i) : s.addErrorMessage(m, r), u = b.findFragmentsByKey(t, e);
|
|
578
|
+
return u.forEach((m) => {
|
|
579
|
+
n.push(o(m.getTarget()));
|
|
580
|
+
}), u.length === 0 && n.push(o(t.getTarget())), Promise.all(n).then(() => {
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
583
|
/**
|
|
@@ -600,21 +600,21 @@ class b {
|
|
|
600
600
|
*/
|
|
601
601
|
static findFragmentByKeyParts(t, e) {
|
|
602
602
|
const r = [], i = e[0];
|
|
603
|
-
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${
|
|
604
|
-
e.length > 1 && t.getAttribute(`${
|
|
605
|
-
r.push(...b.findFragmentByKeyParts(
|
|
603
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${c.prefix}form-object`))
|
|
604
|
+
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) === i && t.getChildElementFragments().forEach((s) => {
|
|
605
|
+
r.push(...b.findFragmentByKeyParts(s, e.slice(1)));
|
|
606
606
|
});
|
|
607
|
-
else if (t.hasAttribute(`${
|
|
607
|
+
else if (t.hasAttribute(`${c.prefix}form-list`)) {
|
|
608
608
|
if (e.length > 1) {
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
611
|
-
const o = i.substring(0,
|
|
612
|
-
if (
|
|
613
|
-
const
|
|
609
|
+
const n = t.getAttribute(`${c.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
|
+
if (n === o) {
|
|
613
|
+
const u = i.substring(s + 1, a), m = Number(u);
|
|
614
614
|
if (isNaN(m))
|
|
615
|
-
|
|
615
|
+
d.error("Haori", `Invalid index: ${i}`);
|
|
616
616
|
else {
|
|
617
|
-
const y = t.getChildElementFragments().filter((E) => E.hasAttribute(`${
|
|
617
|
+
const y = t.getChildElementFragments().filter((E) => E.hasAttribute(`${c.prefix}row`));
|
|
618
618
|
m < y.length && r.push(
|
|
619
619
|
...b.findFragmentByKeyParts(y[m], e.slice(1))
|
|
620
620
|
);
|
|
@@ -623,8 +623,8 @@ class b {
|
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
} else
|
|
626
|
-
t.getChildElementFragments().forEach((
|
|
627
|
-
r.push(...b.findFragmentByKeyParts(
|
|
626
|
+
t.getChildElementFragments().forEach((n) => {
|
|
627
|
+
r.push(...b.findFragmentByKeyParts(n, e));
|
|
628
628
|
});
|
|
629
629
|
return r;
|
|
630
630
|
}
|
|
@@ -686,28 +686,28 @@ const M = class M {
|
|
|
686
686
|
*/
|
|
687
687
|
static evaluate(t, e = {}) {
|
|
688
688
|
if (t.trim() === "")
|
|
689
|
-
return
|
|
689
|
+
return d.warn("[Haori]", t, "Expression is empty"), null;
|
|
690
690
|
if (this.containsDangerousPatterns(t))
|
|
691
|
-
return
|
|
691
|
+
return d.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
692
692
|
if (this.containsForbiddenKeys(e))
|
|
693
|
-
return
|
|
693
|
+
return d.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
694
694
|
if (this.containsForbiddenBindingValues(e))
|
|
695
|
-
return
|
|
695
|
+
return d.warn(
|
|
696
696
|
"[Haori]",
|
|
697
697
|
e,
|
|
698
698
|
"Binded values contain forbidden values"
|
|
699
699
|
), null;
|
|
700
|
-
const r = Object.keys(e).filter((
|
|
701
|
-
let
|
|
702
|
-
if (!
|
|
703
|
-
const
|
|
704
|
-
${
|
|
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
|
+
if (!n) {
|
|
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
|
-
|
|
708
|
+
n = new Function(...r, a), this.EXPRESSION_CACHE.set(i, n);
|
|
709
709
|
} catch (o) {
|
|
710
|
-
return
|
|
710
|
+
return d.error(
|
|
711
711
|
"[Haori]",
|
|
712
712
|
"Failed to compile expression:",
|
|
713
713
|
t,
|
|
@@ -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(() =>
|
|
723
|
-
} catch (
|
|
724
|
-
return
|
|
721
|
+
s.push(a[o]);
|
|
722
|
+
}), this.withBlockedPropertyAccess(() => n(...s));
|
|
723
|
+
} catch (s) {
|
|
724
|
+
return d.error("[Haori]", "Expression evaluation error:", t, s), s instanceof ReferenceError ? void 0 : null;
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
/**
|
|
@@ -752,13 +752,13 @@ return (${t});`;
|
|
|
752
752
|
return !1;
|
|
753
753
|
const r = [];
|
|
754
754
|
let i = null;
|
|
755
|
-
for (let
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
this.decodeStringLiteral(
|
|
759
|
-
) ||
|
|
755
|
+
for (let n = 0; n < e.length; n++) {
|
|
756
|
+
const s = e[n], a = e[n + 1] || null, o = r[r.length - 1] || null;
|
|
757
|
+
if (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(
|
|
758
|
+
this.decodeStringLiteral(s.value)
|
|
759
|
+
) || s.value === "." && a?.type !== "identifier" || s.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
760
760
|
return !1;
|
|
761
|
-
switch (
|
|
761
|
+
switch (s.value) {
|
|
762
762
|
case "(":
|
|
763
763
|
r.push("paren");
|
|
764
764
|
break;
|
|
@@ -768,8 +768,8 @@ return (${t});`;
|
|
|
768
768
|
break;
|
|
769
769
|
}
|
|
770
770
|
case "[": {
|
|
771
|
-
const
|
|
772
|
-
r.push(
|
|
771
|
+
const u = this.startsMemberAccess(i) ? "member" : "array";
|
|
772
|
+
r.push(u);
|
|
773
773
|
break;
|
|
774
774
|
}
|
|
775
775
|
case "]": {
|
|
@@ -778,7 +778,7 @@ return (${t});`;
|
|
|
778
778
|
break;
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
|
-
i =
|
|
781
|
+
i = s;
|
|
782
782
|
}
|
|
783
783
|
return r.length === 0;
|
|
784
784
|
}
|
|
@@ -819,41 +819,41 @@ return (${t});`;
|
|
|
819
819
|
">",
|
|
820
820
|
"<"
|
|
821
821
|
]);
|
|
822
|
-
let
|
|
823
|
-
for (;
|
|
824
|
-
const
|
|
825
|
-
if (/\s/.test(
|
|
826
|
-
|
|
822
|
+
let n = 0;
|
|
823
|
+
for (; n < t.length; ) {
|
|
824
|
+
const s = t[n];
|
|
825
|
+
if (/\s/.test(s)) {
|
|
826
|
+
n += 1;
|
|
827
827
|
continue;
|
|
828
828
|
}
|
|
829
|
-
if (
|
|
829
|
+
if (s === "/" && (t[n + 1] === "/" || t[n + 1] === "*"))
|
|
830
830
|
return null;
|
|
831
|
-
if (
|
|
832
|
-
const o = this.readStringToken(t,
|
|
831
|
+
if (s === '"' || s === "'") {
|
|
832
|
+
const o = this.readStringToken(t, n);
|
|
833
833
|
if (o === null)
|
|
834
834
|
return null;
|
|
835
|
-
e.push(o.token),
|
|
835
|
+
e.push(o.token), n = o.nextIndex;
|
|
836
836
|
continue;
|
|
837
837
|
}
|
|
838
838
|
const a = r.find(
|
|
839
|
-
(o) => t.startsWith(o,
|
|
839
|
+
(o) => t.startsWith(o, n)
|
|
840
840
|
);
|
|
841
841
|
if (a) {
|
|
842
|
-
e.push({ type: "operator", value: a, position:
|
|
842
|
+
e.push({ type: "operator", value: a, position: n }), n += a.length;
|
|
843
843
|
continue;
|
|
844
844
|
}
|
|
845
|
-
if (/[0-9]/.test(
|
|
846
|
-
const o = this.readNumberToken(t,
|
|
847
|
-
e.push(o.token),
|
|
845
|
+
if (/[0-9]/.test(s)) {
|
|
846
|
+
const o = this.readNumberToken(t, n);
|
|
847
|
+
e.push(o.token), n = o.nextIndex;
|
|
848
848
|
continue;
|
|
849
849
|
}
|
|
850
|
-
if (/[A-Za-z_$]/.test(
|
|
851
|
-
const o = this.readIdentifierToken(t,
|
|
852
|
-
e.push(o.token),
|
|
850
|
+
if (/[A-Za-z_$]/.test(s)) {
|
|
851
|
+
const o = this.readIdentifierToken(t, n);
|
|
852
|
+
e.push(o.token), n = o.nextIndex;
|
|
853
853
|
continue;
|
|
854
854
|
}
|
|
855
|
-
if (i.has(
|
|
856
|
-
e.push({ type: "operator", value:
|
|
855
|
+
if (i.has(s)) {
|
|
856
|
+
e.push({ type: "operator", value: s, position: n }), n += 1;
|
|
857
857
|
continue;
|
|
858
858
|
}
|
|
859
859
|
return null;
|
|
@@ -871,12 +871,12 @@ return (${t});`;
|
|
|
871
871
|
const r = t[e];
|
|
872
872
|
let i = e + 1;
|
|
873
873
|
for (; i < t.length; ) {
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
874
|
+
const n = t[i];
|
|
875
|
+
if (n === "\\") {
|
|
876
876
|
i += 2;
|
|
877
877
|
continue;
|
|
878
878
|
}
|
|
879
|
-
if (
|
|
879
|
+
if (n === r)
|
|
880
880
|
return {
|
|
881
881
|
token: {
|
|
882
882
|
type: "string",
|
|
@@ -984,8 +984,8 @@ return (${t});`;
|
|
|
984
984
|
*/
|
|
985
985
|
static wrapBoundValues(t) {
|
|
986
986
|
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
987
|
-
return Object.entries(t).forEach(([i,
|
|
988
|
-
r[i] = this.wrapBoundValue(
|
|
987
|
+
return Object.entries(t).forEach(([i, n]) => {
|
|
988
|
+
r[i] = this.wrapBoundValue(n, e);
|
|
989
989
|
}), r;
|
|
990
990
|
}
|
|
991
991
|
/**
|
|
@@ -1001,39 +1001,39 @@ return (${t});`;
|
|
|
1001
1001
|
const r = t, i = e.get(r);
|
|
1002
1002
|
if (i !== void 0)
|
|
1003
1003
|
return i;
|
|
1004
|
-
const
|
|
1005
|
-
get: (
|
|
1004
|
+
const n = new Proxy(r, {
|
|
1005
|
+
get: (s, a, o) => {
|
|
1006
1006
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
1007
1007
|
return;
|
|
1008
|
-
const
|
|
1009
|
-
return typeof a == "symbol" ?
|
|
1010
|
-
|
|
1008
|
+
const u = Reflect.get(s, a, o);
|
|
1009
|
+
return typeof a == "symbol" ? u : this.wrapBoundValue(
|
|
1010
|
+
u,
|
|
1011
1011
|
e
|
|
1012
1012
|
);
|
|
1013
1013
|
},
|
|
1014
|
-
has: (
|
|
1015
|
-
getOwnPropertyDescriptor: (
|
|
1014
|
+
has: (s, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(s, a),
|
|
1015
|
+
getOwnPropertyDescriptor: (s, a) => {
|
|
1016
1016
|
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
1017
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
1017
|
+
return Reflect.getOwnPropertyDescriptor(s, a);
|
|
1018
1018
|
},
|
|
1019
|
-
apply: (
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1019
|
+
apply: (s, a, o) => {
|
|
1020
|
+
const u = Reflect.apply(
|
|
1021
|
+
s,
|
|
1022
1022
|
a,
|
|
1023
1023
|
o
|
|
1024
1024
|
);
|
|
1025
|
-
return this.isIteratorLike(
|
|
1025
|
+
return this.isIteratorLike(u) ? u : this.wrapBoundValue(u, e);
|
|
1026
1026
|
},
|
|
1027
|
-
construct: (
|
|
1027
|
+
construct: (s, a, o) => this.wrapBoundValue(
|
|
1028
1028
|
Reflect.construct(
|
|
1029
|
-
|
|
1029
|
+
s,
|
|
1030
1030
|
a,
|
|
1031
1031
|
o
|
|
1032
1032
|
),
|
|
1033
1033
|
e
|
|
1034
1034
|
)
|
|
1035
1035
|
});
|
|
1036
|
-
return e.set(r,
|
|
1036
|
+
return e.set(r, n), n;
|
|
1037
1037
|
}
|
|
1038
1038
|
/**
|
|
1039
1039
|
* Proxy ラップ対象の値かどうかを判定します。
|
|
@@ -1066,8 +1066,8 @@ return (${t});`;
|
|
|
1066
1066
|
...i,
|
|
1067
1067
|
descriptor: Object.getOwnPropertyDescriptor(i.target, i.property)
|
|
1068
1068
|
})).filter((i) => i.descriptor?.configurable === !0);
|
|
1069
|
-
r.forEach(({ target: i, property:
|
|
1070
|
-
Object.defineProperty(i,
|
|
1069
|
+
r.forEach(({ target: i, property: n }) => {
|
|
1070
|
+
Object.defineProperty(i, n, {
|
|
1071
1071
|
configurable: !0,
|
|
1072
1072
|
enumerable: !1,
|
|
1073
1073
|
get: () => {
|
|
@@ -1079,8 +1079,8 @@ return (${t});`;
|
|
|
1079
1079
|
try {
|
|
1080
1080
|
return t();
|
|
1081
1081
|
} finally {
|
|
1082
|
-
r.forEach(({ target: i, property:
|
|
1083
|
-
|
|
1082
|
+
r.forEach(({ target: i, property: n, descriptor: s }) => {
|
|
1083
|
+
s !== void 0 && Object.defineProperty(i, n, s);
|
|
1084
1084
|
});
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
@@ -1231,16 +1231,16 @@ const C = class C {
|
|
|
1231
1231
|
let e;
|
|
1232
1232
|
switch (t.nodeType) {
|
|
1233
1233
|
case Node.ELEMENT_NODE:
|
|
1234
|
-
e = new
|
|
1234
|
+
e = new x(t);
|
|
1235
1235
|
break;
|
|
1236
1236
|
case Node.TEXT_NODE:
|
|
1237
1237
|
e = new H(t);
|
|
1238
1238
|
break;
|
|
1239
1239
|
case Node.COMMENT_NODE:
|
|
1240
|
-
e = new
|
|
1240
|
+
e = new Z(t);
|
|
1241
1241
|
break;
|
|
1242
1242
|
default:
|
|
1243
|
-
return
|
|
1243
|
+
return d.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
1244
1244
|
}
|
|
1245
1245
|
return e;
|
|
1246
1246
|
}
|
|
@@ -1347,7 +1347,7 @@ const C = class C {
|
|
|
1347
1347
|
};
|
|
1348
1348
|
C.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1349
1349
|
let T = C;
|
|
1350
|
-
class
|
|
1350
|
+
class x extends T {
|
|
1351
1351
|
/**
|
|
1352
1352
|
* エレメントフラグメントのコンストラクタ。
|
|
1353
1353
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1396,7 +1396,7 @@ class R extends T {
|
|
|
1396
1396
|
*/
|
|
1397
1397
|
getChildElementFragments() {
|
|
1398
1398
|
return this.children.filter(
|
|
1399
|
-
(t) => t instanceof
|
|
1399
|
+
(t) => t instanceof x
|
|
1400
1400
|
);
|
|
1401
1401
|
}
|
|
1402
1402
|
/**
|
|
@@ -1417,7 +1417,7 @@ class R extends T {
|
|
|
1417
1417
|
removeChild(t) {
|
|
1418
1418
|
const e = this.children.indexOf(t);
|
|
1419
1419
|
if (e < 0) {
|
|
1420
|
-
|
|
1420
|
+
d.warn("[Haori]", "Child fragment not found.", t);
|
|
1421
1421
|
return;
|
|
1422
1422
|
}
|
|
1423
1423
|
this.children.splice(e, 1), t.setParent(null);
|
|
@@ -1428,7 +1428,7 @@ class R extends T {
|
|
|
1428
1428
|
* @returns クローンされたフラグメント
|
|
1429
1429
|
*/
|
|
1430
1430
|
clone() {
|
|
1431
|
-
const t = new
|
|
1431
|
+
const t = new x(
|
|
1432
1432
|
this.target.cloneNode(!1)
|
|
1433
1433
|
);
|
|
1434
1434
|
return this.attributeMap.forEach((e, r) => {
|
|
@@ -1496,7 +1496,7 @@ class R extends T {
|
|
|
1496
1496
|
*/
|
|
1497
1497
|
clearBindingDataCache() {
|
|
1498
1498
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1499
|
-
t instanceof
|
|
1499
|
+
t instanceof x && t.clearBindingDataCache();
|
|
1500
1500
|
});
|
|
1501
1501
|
}
|
|
1502
1502
|
/**
|
|
@@ -1564,10 +1564,10 @@ class R extends T {
|
|
|
1564
1564
|
return Promise.resolve();
|
|
1565
1565
|
const r = this.getTarget();
|
|
1566
1566
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1567
|
-
const i = this.getAttribute("value"),
|
|
1568
|
-
let
|
|
1569
|
-
return
|
|
1570
|
-
r.checked =
|
|
1567
|
+
const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
|
|
1568
|
+
let s;
|
|
1569
|
+
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, P.enqueue(() => {
|
|
1570
|
+
r.checked = s, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1571
1571
|
}).finally(() => {
|
|
1572
1572
|
this.skipChangeValue = !1;
|
|
1573
1573
|
}));
|
|
@@ -1575,7 +1575,7 @@ class R extends T {
|
|
|
1575
1575
|
r.value = t === null ? "" : String(t), e && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
1576
1576
|
}).finally(() => {
|
|
1577
1577
|
this.skipChangeValue = !1;
|
|
1578
|
-
})) : (
|
|
1578
|
+
})) : (d.warn(
|
|
1579
1579
|
"[Haori]",
|
|
1580
1580
|
"setValue is not supported for this element type.",
|
|
1581
1581
|
r
|
|
@@ -1671,15 +1671,15 @@ class R extends T {
|
|
|
1671
1671
|
return Promise.resolve();
|
|
1672
1672
|
if (r === null)
|
|
1673
1673
|
return t === e ? this.removeAttribute(t) : this.removeAliasedAttribute(t, e);
|
|
1674
|
-
const
|
|
1675
|
-
this.attributeMap.set(t,
|
|
1676
|
-
const
|
|
1674
|
+
const n = new U(t, r);
|
|
1675
|
+
this.attributeMap.set(t, n), this.skipMutationAttributes = !0;
|
|
1676
|
+
const s = this.getTarget(), a = n.isForceEvaluation() ? r : this.getAttribute(t);
|
|
1677
1677
|
return P.enqueue(() => {
|
|
1678
|
-
if (
|
|
1679
|
-
|
|
1678
|
+
if (s.getAttribute(t) !== r && s.setAttribute(t, r), a === null || a === !1)
|
|
1679
|
+
s.removeAttribute(e);
|
|
1680
1680
|
else {
|
|
1681
1681
|
const o = String(a);
|
|
1682
|
-
|
|
1682
|
+
s.getAttribute(e) !== o && s.setAttribute(e, o), i && n.isEvaluate && e === "value" && (s instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(s.type) || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement) && (this.value = o, s.value !== o && (s.value = o));
|
|
1683
1683
|
}
|
|
1684
1684
|
}).finally(() => {
|
|
1685
1685
|
this.skipMutationAttributes = !1;
|
|
@@ -1714,7 +1714,7 @@ class R extends T {
|
|
|
1714
1714
|
if (e === void 0)
|
|
1715
1715
|
return null;
|
|
1716
1716
|
const r = e.evaluate(this.getBindingData());
|
|
1717
|
-
return r.length === 1 ? r[0] :
|
|
1717
|
+
return r.length === 1 ? r[0] : L.joinEvaluateResults(r);
|
|
1718
1718
|
}
|
|
1719
1719
|
/**
|
|
1720
1720
|
* 属性の生の値を取得します。
|
|
@@ -1755,15 +1755,15 @@ class R extends T {
|
|
|
1755
1755
|
if (r.parentNode !== this.target)
|
|
1756
1756
|
return null;
|
|
1757
1757
|
const i = e ? r.nextSibling : r;
|
|
1758
|
-
let
|
|
1759
|
-
for (;
|
|
1760
|
-
const
|
|
1761
|
-
if (
|
|
1762
|
-
const a = this.children.indexOf(
|
|
1758
|
+
let n = e ? r.nextSibling : r;
|
|
1759
|
+
for (; n !== null; ) {
|
|
1760
|
+
const s = T.get(n);
|
|
1761
|
+
if (s !== null) {
|
|
1762
|
+
const a = this.children.indexOf(s);
|
|
1763
1763
|
if (a !== -1)
|
|
1764
1764
|
return { index: a, referenceNode: i };
|
|
1765
1765
|
}
|
|
1766
|
-
|
|
1766
|
+
n = n.nextSibling;
|
|
1767
1767
|
}
|
|
1768
1768
|
return { index: this.children.length, referenceNode: i };
|
|
1769
1769
|
}
|
|
@@ -1779,29 +1779,29 @@ class R extends T {
|
|
|
1779
1779
|
if (this.skipMutationNodes)
|
|
1780
1780
|
return Promise.resolve();
|
|
1781
1781
|
if (t === this)
|
|
1782
|
-
return
|
|
1782
|
+
return d.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1783
1783
|
const i = /* @__PURE__ */ new Set();
|
|
1784
|
-
let
|
|
1785
|
-
for (;
|
|
1786
|
-
i.add(
|
|
1784
|
+
let n = this.parent;
|
|
1785
|
+
for (; n; )
|
|
1786
|
+
i.add(n), n = n.getParent();
|
|
1787
1787
|
if (i.has(t))
|
|
1788
|
-
return
|
|
1789
|
-
const
|
|
1788
|
+
return d.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1789
|
+
const s = t.getParent() === this;
|
|
1790
1790
|
let a = -1, o = -1;
|
|
1791
|
-
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1791
|
+
s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1792
|
+
const u = t.getParent();
|
|
1793
|
+
u !== null && u.removeChild(t);
|
|
1794
1794
|
let m = r === void 0 ? e?.getTarget() || null : r;
|
|
1795
1795
|
if (e === null)
|
|
1796
1796
|
this.children.push(t);
|
|
1797
1797
|
else {
|
|
1798
1798
|
let E;
|
|
1799
|
-
if (
|
|
1799
|
+
if (s ? a !== -1 && a < o ? E = o - 1 : E = o : E = this.children.indexOf(e), E === -1) {
|
|
1800
1800
|
const S = this.resolveInsertionPointFromDom(
|
|
1801
1801
|
e,
|
|
1802
1802
|
!1
|
|
1803
1803
|
);
|
|
1804
|
-
S === null ? (
|
|
1804
|
+
S === null ? (d.warn(
|
|
1805
1805
|
"[Haori]",
|
|
1806
1806
|
"Reference child not found in children.",
|
|
1807
1807
|
e
|
|
@@ -1833,7 +1833,7 @@ class R extends T {
|
|
|
1833
1833
|
e,
|
|
1834
1834
|
!0
|
|
1835
1835
|
);
|
|
1836
|
-
return i === null ? (
|
|
1836
|
+
return i === null ? (d.warn(
|
|
1837
1837
|
"[Haori]",
|
|
1838
1838
|
"Reference child not found in children.",
|
|
1839
1839
|
e
|
|
@@ -1885,7 +1885,7 @@ class R extends T {
|
|
|
1885
1885
|
* @returns エレメントの非表示のPromise
|
|
1886
1886
|
*/
|
|
1887
1887
|
hide() {
|
|
1888
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1888
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${c.prefix}if-false`, ""), Promise.resolve();
|
|
1889
1889
|
}
|
|
1890
1890
|
/**
|
|
1891
1891
|
* エレメントを表示します。
|
|
@@ -1893,7 +1893,7 @@ class R extends T {
|
|
|
1893
1893
|
* @return エレメントの表示のPromise
|
|
1894
1894
|
*/
|
|
1895
1895
|
show() {
|
|
1896
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1896
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${c.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1897
1897
|
}
|
|
1898
1898
|
/**
|
|
1899
1899
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1917,7 +1917,7 @@ class H extends T {
|
|
|
1917
1917
|
* @param target 対象テキストノード
|
|
1918
1918
|
*/
|
|
1919
1919
|
constructor(t) {
|
|
1920
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1920
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new L(this.text);
|
|
1921
1921
|
}
|
|
1922
1922
|
/**
|
|
1923
1923
|
* フラグメントをクローンします。
|
|
@@ -1943,7 +1943,7 @@ class H extends T {
|
|
|
1943
1943
|
* @returns 更新のPromise
|
|
1944
1944
|
*/
|
|
1945
1945
|
setContent(t) {
|
|
1946
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1946
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new L(t), this.evaluate());
|
|
1947
1947
|
}
|
|
1948
1948
|
/**
|
|
1949
1949
|
* フラグメントを評価します。
|
|
@@ -1956,7 +1956,7 @@ class H extends T {
|
|
|
1956
1956
|
) : P.enqueue(() => {
|
|
1957
1957
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1958
1958
|
this.parent.getBindingData()
|
|
1959
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1959
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = L.joinEvaluateResults(
|
|
1960
1960
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1961
1961
|
) : this.target.textContent = this.text;
|
|
1962
1962
|
}).finally(() => {
|
|
@@ -1964,7 +1964,7 @@ class H extends T {
|
|
|
1964
1964
|
});
|
|
1965
1965
|
}
|
|
1966
1966
|
}
|
|
1967
|
-
class
|
|
1967
|
+
class Z extends T {
|
|
1968
1968
|
/**
|
|
1969
1969
|
* コメントフラグメントのコンストラクタ。
|
|
1970
1970
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1980,7 +1980,7 @@ class z extends T {
|
|
|
1980
1980
|
* @returns クローンされたフラグメント
|
|
1981
1981
|
*/
|
|
1982
1982
|
clone() {
|
|
1983
|
-
const t = new
|
|
1983
|
+
const t = new Z(this.target.cloneNode(!0));
|
|
1984
1984
|
return t.mounted = !1, t.text = this.text, t;
|
|
1985
1985
|
}
|
|
1986
1986
|
/**
|
|
@@ -2005,7 +2005,7 @@ class z extends T {
|
|
|
2005
2005
|
}));
|
|
2006
2006
|
}
|
|
2007
2007
|
}
|
|
2008
|
-
const
|
|
2008
|
+
const K = class K {
|
|
2009
2009
|
/**
|
|
2010
2010
|
* コンストラクタ。
|
|
2011
2011
|
*
|
|
@@ -2013,26 +2013,26 @@ const G = class G {
|
|
|
2013
2013
|
*/
|
|
2014
2014
|
constructor(t) {
|
|
2015
2015
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
2016
|
-
const e = [...t.matchAll(
|
|
2017
|
-
let r = 0, i = !1,
|
|
2018
|
-
for (const
|
|
2019
|
-
|
|
2020
|
-
text: t.slice(r,
|
|
2016
|
+
const e = [...t.matchAll(K.PLACEHOLDER_REGEX)];
|
|
2017
|
+
let r = 0, i = !1, n = !1;
|
|
2018
|
+
for (const s of e) {
|
|
2019
|
+
s.index > r && this.contents.push({
|
|
2020
|
+
text: t.slice(r, s.index),
|
|
2021
2021
|
type: 0
|
|
2022
2022
|
/* TEXT */
|
|
2023
2023
|
});
|
|
2024
2024
|
const a = {
|
|
2025
|
-
text:
|
|
2026
|
-
type:
|
|
2025
|
+
text: s[1] ?? s[2],
|
|
2026
|
+
type: s[1] ? 2 : 1
|
|
2027
2027
|
/* EXPRESSION */
|
|
2028
2028
|
};
|
|
2029
|
-
i = !0,
|
|
2029
|
+
i = !0, n = n || a.type === 2, this.contents.push(a), r = s.index + s[0].length;
|
|
2030
2030
|
}
|
|
2031
2031
|
r < t.length && this.contents.push({
|
|
2032
2032
|
text: t.slice(r),
|
|
2033
2033
|
type: 0
|
|
2034
2034
|
/* TEXT */
|
|
2035
|
-
}), this.isEvaluate = i, this.isRawEvaluate =
|
|
2035
|
+
}), this.isEvaluate = i, this.isRawEvaluate = n, this.checkRawExpressions();
|
|
2036
2036
|
}
|
|
2037
2037
|
/**
|
|
2038
2038
|
* 評価結果を結合して文字列にします。
|
|
@@ -2056,7 +2056,7 @@ const G = class G {
|
|
|
2056
2056
|
*/
|
|
2057
2057
|
checkRawExpressions() {
|
|
2058
2058
|
for (let t = 0; t < this.contents.length; t++)
|
|
2059
|
-
this.contents[t].type === 2 && this.contents.length > 1 && (
|
|
2059
|
+
this.contents[t].type === 2 && this.contents.length > 1 && (d.error(
|
|
2060
2060
|
"[Haori]",
|
|
2061
2061
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2062
2062
|
), this.contents[t].type = 1);
|
|
@@ -2079,7 +2079,7 @@ const G = class G {
|
|
|
2079
2079
|
} else
|
|
2080
2080
|
e.push(r.text);
|
|
2081
2081
|
} catch (i) {
|
|
2082
|
-
|
|
2082
|
+
d.error(
|
|
2083
2083
|
"[Haori]",
|
|
2084
2084
|
`Error evaluating text expression: ${r.text}`,
|
|
2085
2085
|
i
|
|
@@ -2088,9 +2088,9 @@ const G = class G {
|
|
|
2088
2088
|
}), e;
|
|
2089
2089
|
}
|
|
2090
2090
|
};
|
|
2091
|
-
|
|
2092
|
-
let
|
|
2093
|
-
const
|
|
2091
|
+
K.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2092
|
+
let L = K;
|
|
2093
|
+
const G = class G extends L {
|
|
2094
2094
|
/**
|
|
2095
2095
|
* コンストラクタ。
|
|
2096
2096
|
*
|
|
@@ -2098,7 +2098,7 @@ const K = class K extends $ {
|
|
|
2098
2098
|
* @param text 属性値
|
|
2099
2099
|
*/
|
|
2100
2100
|
constructor(t, e) {
|
|
2101
|
-
super(e), this.forceEvaluation =
|
|
2101
|
+
super(e), this.forceEvaluation = G.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
2102
2102
|
}
|
|
2103
2103
|
/**
|
|
2104
2104
|
* 強制評価フラグを取得します。
|
|
@@ -2126,26 +2126,26 @@ const K = class K extends $ {
|
|
|
2126
2126
|
} else
|
|
2127
2127
|
e.push(r.text);
|
|
2128
2128
|
} catch (i) {
|
|
2129
|
-
|
|
2129
|
+
d.error(
|
|
2130
2130
|
"[Haori]",
|
|
2131
2131
|
`Error evaluating attribute expression: ${r.text}`,
|
|
2132
2132
|
i
|
|
2133
2133
|
), e.push("");
|
|
2134
2134
|
}
|
|
2135
|
-
}), this.forceEvaluation && e.length > 1 ? (
|
|
2135
|
+
}), this.forceEvaluation && e.length > 1 ? (d.error(
|
|
2136
2136
|
"[Haori]",
|
|
2137
2137
|
"each or if expressions must have a single content.",
|
|
2138
2138
|
e
|
|
2139
2139
|
), [e[0]]) : e;
|
|
2140
2140
|
}
|
|
2141
2141
|
};
|
|
2142
|
-
|
|
2142
|
+
G.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2143
2143
|
"data-if",
|
|
2144
2144
|
"hor-if",
|
|
2145
2145
|
"data-each",
|
|
2146
2146
|
"hor-each"
|
|
2147
2147
|
];
|
|
2148
|
-
let U =
|
|
2148
|
+
let U = G;
|
|
2149
2149
|
class w {
|
|
2150
2150
|
/**
|
|
2151
2151
|
* カスタムイベントを発火します。
|
|
@@ -2156,13 +2156,13 @@ class w {
|
|
|
2156
2156
|
* @param options イベントオプション
|
|
2157
2157
|
*/
|
|
2158
2158
|
static dispatch(t, e, r, i) {
|
|
2159
|
-
const
|
|
2159
|
+
const n = new CustomEvent(`haori:${e}`, {
|
|
2160
2160
|
bubbles: i?.bubbles ?? !0,
|
|
2161
2161
|
cancelable: i?.cancelable ?? !1,
|
|
2162
2162
|
composed: i?.composed ?? !0,
|
|
2163
2163
|
detail: r
|
|
2164
2164
|
});
|
|
2165
|
-
return t.dispatchEvent(
|
|
2165
|
+
return t.dispatchEvent(n);
|
|
2166
2166
|
}
|
|
2167
2167
|
/**
|
|
2168
2168
|
* readyイベントを発火します。
|
|
@@ -2226,15 +2226,15 @@ class w {
|
|
|
2226
2226
|
* @param reason 変更理由
|
|
2227
2227
|
*/
|
|
2228
2228
|
static bindChange(t, e, r, i = "other") {
|
|
2229
|
-
const
|
|
2230
|
-
for (const
|
|
2231
|
-
const m = e?.[
|
|
2232
|
-
m !== y &&
|
|
2229
|
+
const n = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
|
|
2230
|
+
for (const u of o) {
|
|
2231
|
+
const m = e?.[u], y = r[u];
|
|
2232
|
+
m !== y && n.push(u);
|
|
2233
2233
|
}
|
|
2234
2234
|
w.dispatch(t, "bindchange", {
|
|
2235
2235
|
previous: e || {},
|
|
2236
2236
|
next: r,
|
|
2237
|
-
changedKeys:
|
|
2237
|
+
changedKeys: n,
|
|
2238
2238
|
reason: i
|
|
2239
2239
|
});
|
|
2240
2240
|
}
|
|
@@ -2312,13 +2312,13 @@ class w {
|
|
|
2312
2312
|
* @param metadata runtime とメソッド変換情報。
|
|
2313
2313
|
* @return 戻り値はありません。
|
|
2314
2314
|
*/
|
|
2315
|
-
static fetchStart(t, e, r, i,
|
|
2315
|
+
static fetchStart(t, e, r, i, n) {
|
|
2316
2316
|
w.dispatch(t, "fetchstart", {
|
|
2317
2317
|
url: e,
|
|
2318
2318
|
options: r || {},
|
|
2319
2319
|
payload: i,
|
|
2320
2320
|
startedAt: performance.now(),
|
|
2321
|
-
...
|
|
2321
|
+
...n
|
|
2322
2322
|
});
|
|
2323
2323
|
}
|
|
2324
2324
|
/**
|
|
@@ -2345,44 +2345,44 @@ class w {
|
|
|
2345
2345
|
* @param status HTTPステータス(存在する場合)
|
|
2346
2346
|
* @param startedAt 開始時刻(存在する場合)
|
|
2347
2347
|
*/
|
|
2348
|
-
static fetchError(t, e, r, i,
|
|
2348
|
+
static fetchError(t, e, r, i, n) {
|
|
2349
2349
|
w.dispatch(t, "fetcherror", {
|
|
2350
2350
|
url: e,
|
|
2351
2351
|
status: i,
|
|
2352
2352
|
error: r,
|
|
2353
|
-
durationMs:
|
|
2353
|
+
durationMs: n ? performance.now() - n : void 0
|
|
2354
2354
|
});
|
|
2355
2355
|
}
|
|
2356
2356
|
}
|
|
2357
|
-
const
|
|
2357
|
+
const at = [
|
|
2358
2358
|
"addErrorMessage",
|
|
2359
2359
|
"closeDialog",
|
|
2360
2360
|
"confirm",
|
|
2361
2361
|
"dialog",
|
|
2362
2362
|
"openDialog",
|
|
2363
2363
|
"toast"
|
|
2364
|
-
];
|
|
2365
|
-
function
|
|
2364
|
+
], ot = "__haoriHistoryState__";
|
|
2365
|
+
function Y() {
|
|
2366
2366
|
const t = globalThis.window?.Haori;
|
|
2367
|
-
return
|
|
2367
|
+
return at.every(
|
|
2368
2368
|
(r) => typeof t?.[r] == "function"
|
|
2369
|
-
) ? t :
|
|
2369
|
+
) ? t : J;
|
|
2370
2370
|
}
|
|
2371
|
-
const
|
|
2372
|
-
function
|
|
2373
|
-
return
|
|
2371
|
+
const lt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2372
|
+
function ct(F) {
|
|
2373
|
+
return lt.has(F.toUpperCase());
|
|
2374
2374
|
}
|
|
2375
|
-
function
|
|
2375
|
+
function ut(F, t) {
|
|
2376
2376
|
for (const [e, r] of Object.entries(t))
|
|
2377
2377
|
r !== void 0 && (r === null ? F.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2378
2378
|
F.append(e, String(i));
|
|
2379
2379
|
}) : typeof r == "object" || typeof r == "function" ? F.append(e, JSON.stringify(r)) : F.append(e, String(r)));
|
|
2380
2380
|
}
|
|
2381
|
-
function
|
|
2381
|
+
function ht(F, t) {
|
|
2382
2382
|
const e = new URL(F, window.location.href), r = new URLSearchParams(e.search);
|
|
2383
|
-
return
|
|
2383
|
+
return ut(r, t), e.search = r.toString(), e.toString();
|
|
2384
2384
|
}
|
|
2385
|
-
const
|
|
2385
|
+
const l = class l {
|
|
2386
2386
|
/**
|
|
2387
2387
|
* イベント属性名を正しく生成します。
|
|
2388
2388
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2391,7 +2391,7 @@ const c = class c {
|
|
|
2391
2391
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2392
2392
|
*/
|
|
2393
2393
|
static attrName(t, e, r = !1) {
|
|
2394
|
-
return t ? `${
|
|
2394
|
+
return t ? `${c.prefix}${t}-${e}` : r ? `${c.prefix}fetch-${e}` : `${c.prefix}${e}`;
|
|
2395
2395
|
}
|
|
2396
2396
|
/**
|
|
2397
2397
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2402,13 +2402,13 @@ const c = class c {
|
|
|
2402
2402
|
*/
|
|
2403
2403
|
static resolveDataParamString(t, e) {
|
|
2404
2404
|
return t.replace(
|
|
2405
|
-
|
|
2406
|
-
(r, i,
|
|
2407
|
-
const
|
|
2408
|
-
i ??
|
|
2405
|
+
l.DATA_PLACEHOLDER_REGEX,
|
|
2406
|
+
(r, i, n) => {
|
|
2407
|
+
const s = j.evaluate(
|
|
2408
|
+
i ?? n ?? "",
|
|
2409
2409
|
e
|
|
2410
2410
|
);
|
|
2411
|
-
return
|
|
2411
|
+
return s == null || Number.isNaN(s) ? "" : encodeURIComponent(typeof s == "object" ? JSON.stringify(s) : String(s));
|
|
2412
2412
|
}
|
|
2413
2413
|
);
|
|
2414
2414
|
}
|
|
@@ -2421,17 +2421,17 @@ const c = class c {
|
|
|
2421
2421
|
*/
|
|
2422
2422
|
static isJsonStringContext(t, e) {
|
|
2423
2423
|
let r = !1, i = !1;
|
|
2424
|
-
for (let
|
|
2425
|
-
const
|
|
2424
|
+
for (let n = 0; n < e; n += 1) {
|
|
2425
|
+
const s = t[n];
|
|
2426
2426
|
if (i) {
|
|
2427
2427
|
i = !1;
|
|
2428
2428
|
continue;
|
|
2429
2429
|
}
|
|
2430
|
-
if (
|
|
2430
|
+
if (s === "\\") {
|
|
2431
2431
|
i = !0;
|
|
2432
2432
|
continue;
|
|
2433
2433
|
}
|
|
2434
|
-
|
|
2434
|
+
s === '"' && (r = !r);
|
|
2435
2435
|
}
|
|
2436
2436
|
return r;
|
|
2437
2437
|
}
|
|
@@ -2459,7 +2459,7 @@ const c = class c {
|
|
|
2459
2459
|
static stringifyJsonTemplateStringContent(t) {
|
|
2460
2460
|
if (t == null || Number.isNaN(t))
|
|
2461
2461
|
return "";
|
|
2462
|
-
const e = typeof t == "object" ?
|
|
2462
|
+
const e = typeof t == "object" ? l.stringifyJsonTemplateValue(t) : String(t);
|
|
2463
2463
|
return JSON.stringify(e).slice(1, -1);
|
|
2464
2464
|
}
|
|
2465
2465
|
/**
|
|
@@ -2471,13 +2471,13 @@ const c = class c {
|
|
|
2471
2471
|
*/
|
|
2472
2472
|
static resolveDataJsonString(t, e) {
|
|
2473
2473
|
return t.replace(
|
|
2474
|
-
|
|
2475
|
-
(r, i,
|
|
2474
|
+
l.DATA_PLACEHOLDER_REGEX,
|
|
2475
|
+
(r, i, n, s) => {
|
|
2476
2476
|
const a = j.evaluate(
|
|
2477
|
-
i ??
|
|
2477
|
+
i ?? n ?? "",
|
|
2478
2478
|
e
|
|
2479
2479
|
);
|
|
2480
|
-
return
|
|
2480
|
+
return l.isJsonStringContext(t, s) ? l.stringifyJsonTemplateStringContent(a) : l.stringifyJsonTemplateValue(a);
|
|
2481
2481
|
}
|
|
2482
2482
|
);
|
|
2483
2483
|
}
|
|
@@ -2494,14 +2494,14 @@ const c = class c {
|
|
|
2494
2494
|
return i;
|
|
2495
2495
|
if (typeof i != "string" || r === null)
|
|
2496
2496
|
return null;
|
|
2497
|
-
const
|
|
2498
|
-
return
|
|
2499
|
-
|
|
2497
|
+
const n = r.trim();
|
|
2498
|
+
return l.SINGLE_PLACEHOLDER_REGEX.test(n) ? R.parseDataBind(i) : n.startsWith("{") || n.startsWith("[") ? R.parseDataBind(
|
|
2499
|
+
l.resolveDataJsonString(
|
|
2500
2500
|
r,
|
|
2501
2501
|
t.getBindingData()
|
|
2502
2502
|
)
|
|
2503
|
-
) :
|
|
2504
|
-
|
|
2503
|
+
) : R.parseDataBind(
|
|
2504
|
+
l.resolveDataParamString(r, t.getBindingData())
|
|
2505
2505
|
);
|
|
2506
2506
|
}
|
|
2507
2507
|
/**
|
|
@@ -2516,30 +2516,30 @@ const c = class c {
|
|
|
2516
2516
|
targetFragment: t
|
|
2517
2517
|
};
|
|
2518
2518
|
if (e) {
|
|
2519
|
-
if (t.hasAttribute(
|
|
2520
|
-
|
|
2519
|
+
if (t.hasAttribute(l.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(l.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2520
|
+
l.attrName(e, "confirm")
|
|
2521
2521
|
).replace(/\\n/g, `
|
|
2522
|
-
`)), t.hasAttribute(
|
|
2522
|
+
`)), t.hasAttribute(l.attrName(e, "data")) && (r.data = l.resolveDataAttribute(
|
|
2523
2523
|
t,
|
|
2524
|
-
|
|
2525
|
-
)), t.hasAttribute(
|
|
2526
|
-
const
|
|
2527
|
-
|
|
2524
|
+
l.attrName(e, "data")
|
|
2525
|
+
)), t.hasAttribute(l.attrName(e, "form"))) {
|
|
2526
|
+
const h = t.getRawAttribute(
|
|
2527
|
+
l.attrName(e, "form")
|
|
2528
2528
|
);
|
|
2529
|
-
if (
|
|
2530
|
-
const
|
|
2531
|
-
|
|
2532
|
-
T.get(
|
|
2533
|
-
) :
|
|
2529
|
+
if (h) {
|
|
2530
|
+
const f = document.body.querySelector(h);
|
|
2531
|
+
f !== null ? r.formFragment = b.getFormFragment(
|
|
2532
|
+
T.get(f)
|
|
2533
|
+
) : d.error(
|
|
2534
2534
|
"Haori",
|
|
2535
|
-
`Form element not found: ${
|
|
2535
|
+
`Form element not found: ${h} (${l.attrName(e, "form")})`
|
|
2536
2536
|
);
|
|
2537
2537
|
} else
|
|
2538
2538
|
r.formFragment = b.getFormFragment(t);
|
|
2539
2539
|
} else e === "change" && (r.formFragment = b.getFormFragment(t));
|
|
2540
|
-
if (t.hasAttribute(`${
|
|
2541
|
-
const
|
|
2542
|
-
`${
|
|
2540
|
+
if (t.hasAttribute(`${c.prefix}${e}-before-run`)) {
|
|
2541
|
+
const h = t.getRawAttribute(
|
|
2542
|
+
`${c.prefix}${e}-before-run`
|
|
2543
2543
|
);
|
|
2544
2544
|
try {
|
|
2545
2545
|
r.beforeCallback = new Function(
|
|
@@ -2547,211 +2547,213 @@ const c = class c {
|
|
|
2547
2547
|
"fetchOptions",
|
|
2548
2548
|
`
|
|
2549
2549
|
"use strict";
|
|
2550
|
-
${
|
|
2550
|
+
${h}
|
|
2551
2551
|
`
|
|
2552
2552
|
);
|
|
2553
|
-
} catch (
|
|
2554
|
-
|
|
2553
|
+
} catch (f) {
|
|
2554
|
+
d.error("Haori", `Invalid before script: ${f}`);
|
|
2555
2555
|
}
|
|
2556
2556
|
}
|
|
2557
2557
|
}
|
|
2558
|
-
const i =
|
|
2559
|
-
|
|
2560
|
-
const
|
|
2558
|
+
const i = l.attrName(e, "fetch"), n = t.hasAttribute(i);
|
|
2559
|
+
n && (r.fetchUrl = t.getAttribute(i));
|
|
2560
|
+
const s = {};
|
|
2561
2561
|
if (e) {
|
|
2562
|
-
const
|
|
2563
|
-
t.hasAttribute(
|
|
2564
|
-
|
|
2562
|
+
const h = l.attrName(e, "fetch-method");
|
|
2563
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2564
|
+
h
|
|
2565
2565
|
));
|
|
2566
2566
|
} else {
|
|
2567
|
-
const
|
|
2568
|
-
t.hasAttribute(
|
|
2569
|
-
|
|
2567
|
+
const h = l.attrName(null, "method", !0);
|
|
2568
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2569
|
+
h
|
|
2570
2570
|
));
|
|
2571
2571
|
}
|
|
2572
2572
|
if (e) {
|
|
2573
|
-
const
|
|
2574
|
-
if (t.hasAttribute(
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2573
|
+
const h = l.attrName(e, "fetch-headers");
|
|
2574
|
+
if (t.hasAttribute(h)) {
|
|
2575
|
+
const f = t.getRawAttribute(
|
|
2576
|
+
h
|
|
2577
2577
|
);
|
|
2578
2578
|
try {
|
|
2579
|
-
|
|
2579
|
+
s.headers = R.parseDataBind(f);
|
|
2580
2580
|
} catch (g) {
|
|
2581
|
-
|
|
2581
|
+
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2582
2582
|
}
|
|
2583
2583
|
}
|
|
2584
2584
|
} else {
|
|
2585
|
-
const
|
|
2585
|
+
const h = l.attrName(
|
|
2586
2586
|
null,
|
|
2587
2587
|
"headers",
|
|
2588
2588
|
!0
|
|
2589
2589
|
);
|
|
2590
|
-
if (t.hasAttribute(
|
|
2591
|
-
const
|
|
2592
|
-
|
|
2590
|
+
if (t.hasAttribute(h)) {
|
|
2591
|
+
const f = t.getRawAttribute(
|
|
2592
|
+
h
|
|
2593
2593
|
);
|
|
2594
2594
|
try {
|
|
2595
|
-
|
|
2595
|
+
s.headers = R.parseDataBind(f);
|
|
2596
2596
|
} catch (g) {
|
|
2597
|
-
|
|
2597
|
+
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2598
2598
|
}
|
|
2599
2599
|
}
|
|
2600
2600
|
}
|
|
2601
2601
|
if (e) {
|
|
2602
|
-
const
|
|
2602
|
+
const h = l.attrName(
|
|
2603
2603
|
e,
|
|
2604
2604
|
"fetch-content-type"
|
|
2605
2605
|
);
|
|
2606
|
-
if (t.hasAttribute(
|
|
2607
|
-
|
|
2608
|
-
...
|
|
2609
|
-
"Content-Type": t.getAttribute(
|
|
2606
|
+
if (t.hasAttribute(h))
|
|
2607
|
+
s.headers = {
|
|
2608
|
+
...s.headers,
|
|
2609
|
+
"Content-Type": t.getAttribute(h)
|
|
2610
2610
|
};
|
|
2611
|
-
else if (
|
|
2612
|
-
let
|
|
2613
|
-
|
|
2614
|
-
...
|
|
2611
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2612
|
+
let f = !1;
|
|
2613
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2614
|
+
...s.headers,
|
|
2615
2615
|
"Content-Type": "application/json"
|
|
2616
2616
|
});
|
|
2617
|
-
} else
|
|
2618
|
-
...
|
|
2617
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2618
|
+
...s.headers,
|
|
2619
2619
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2620
2620
|
});
|
|
2621
2621
|
} else {
|
|
2622
|
-
const
|
|
2622
|
+
const h = l.attrName(
|
|
2623
2623
|
null,
|
|
2624
2624
|
"content-type",
|
|
2625
2625
|
!0
|
|
2626
2626
|
);
|
|
2627
|
-
if (t.hasAttribute(
|
|
2628
|
-
|
|
2629
|
-
...
|
|
2630
|
-
"Content-Type": t.getAttribute(
|
|
2627
|
+
if (t.hasAttribute(h))
|
|
2628
|
+
s.headers = {
|
|
2629
|
+
...s.headers,
|
|
2630
|
+
"Content-Type": t.getAttribute(h)
|
|
2631
2631
|
};
|
|
2632
|
-
else if (
|
|
2633
|
-
let
|
|
2634
|
-
|
|
2635
|
-
...
|
|
2632
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2633
|
+
let f = !1;
|
|
2634
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2635
|
+
...s.headers,
|
|
2636
2636
|
"Content-Type": "application/json"
|
|
2637
2637
|
});
|
|
2638
|
-
} else
|
|
2639
|
-
...
|
|
2638
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2639
|
+
...s.headers,
|
|
2640
2640
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2641
2641
|
});
|
|
2642
2642
|
}
|
|
2643
|
-
Object.keys(
|
|
2644
|
-
const a = e ?
|
|
2643
|
+
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2644
|
+
const a = e ? l.attrName(e, "bind") : l.attrName(null, "bind", !0);
|
|
2645
2645
|
if (t.hasAttribute(a)) {
|
|
2646
|
-
const
|
|
2647
|
-
if (
|
|
2648
|
-
const
|
|
2649
|
-
|
|
2646
|
+
const h = t.getRawAttribute(a);
|
|
2647
|
+
if (h) {
|
|
2648
|
+
const f = document.body.querySelectorAll(h);
|
|
2649
|
+
f.length > 0 ? (r.bindFragments = [], f.forEach((g) => {
|
|
2650
2650
|
const A = T.get(g);
|
|
2651
2651
|
A && r.bindFragments.push(A);
|
|
2652
|
-
})) :
|
|
2652
|
+
})) : d.error(
|
|
2653
2653
|
"Haori",
|
|
2654
|
-
`Bind element not found: ${
|
|
2654
|
+
`Bind element not found: ${h} (${a})`
|
|
2655
2655
|
);
|
|
2656
2656
|
}
|
|
2657
2657
|
}
|
|
2658
|
-
const o =
|
|
2658
|
+
const o = l.attrName(e, "bind-arg"), u = l.attrName(
|
|
2659
2659
|
null,
|
|
2660
2660
|
"arg",
|
|
2661
2661
|
!0
|
|
2662
|
-
), m =
|
|
2662
|
+
), m = l.attrName(
|
|
2663
2663
|
null,
|
|
2664
2664
|
"bind-arg",
|
|
2665
2665
|
!0
|
|
2666
2666
|
);
|
|
2667
|
-
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(
|
|
2668
|
-
|
|
2667
|
+
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(u) ? r.bindArg = t.getRawAttribute(
|
|
2668
|
+
u
|
|
2669
2669
|
) : t.hasAttribute(m) && (r.bindArg = t.getRawAttribute(m));
|
|
2670
|
-
const y = e ?
|
|
2670
|
+
const y = e ? l.attrName(e, "bind-params") : l.attrName(null, "bind-params", !0);
|
|
2671
2671
|
if (t.hasAttribute(y)) {
|
|
2672
|
-
const
|
|
2673
|
-
r.bindParams =
|
|
2672
|
+
const h = t.getRawAttribute(y);
|
|
2673
|
+
r.bindParams = h.split("&").map((f) => f.trim());
|
|
2674
2674
|
}
|
|
2675
|
-
const E = e ?
|
|
2675
|
+
const E = e ? l.attrName(e, "bind-append") : l.attrName(null, "bind-append", !0);
|
|
2676
2676
|
if (t.hasAttribute(E)) {
|
|
2677
|
-
const
|
|
2678
|
-
r.bindAppendParams =
|
|
2677
|
+
const h = t.getRawAttribute(E);
|
|
2678
|
+
r.bindAppendParams = h.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2679
2679
|
}
|
|
2680
|
-
const S = e ?
|
|
2680
|
+
const S = e ? l.attrName(e, "copy-params") : null;
|
|
2681
2681
|
if (S && t.hasAttribute(S)) {
|
|
2682
|
-
const
|
|
2682
|
+
const h = t.getRawAttribute(
|
|
2683
2683
|
S
|
|
2684
2684
|
);
|
|
2685
|
-
r.copyParams =
|
|
2685
|
+
r.copyParams = h.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2686
2686
|
}
|
|
2687
2687
|
if (e) {
|
|
2688
|
-
if (t.hasAttribute(
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2688
|
+
if (t.hasAttribute(l.attrName(e, "adjust"))) {
|
|
2689
|
+
const f = t.getRawAttribute(
|
|
2690
|
+
l.attrName(e, "adjust")
|
|
2691
2691
|
);
|
|
2692
|
-
if (
|
|
2693
|
-
const g = document.body.querySelectorAll(
|
|
2692
|
+
if (f) {
|
|
2693
|
+
const g = document.body.querySelectorAll(f);
|
|
2694
2694
|
g.length > 0 ? (r.adjustFragments = [], g.forEach((A) => {
|
|
2695
2695
|
const v = T.get(A);
|
|
2696
2696
|
v && r.adjustFragments.push(v);
|
|
2697
|
-
})) :
|
|
2697
|
+
})) : d.error(
|
|
2698
2698
|
"Haori",
|
|
2699
|
-
`Adjust element not found: ${
|
|
2699
|
+
`Adjust element not found: ${f} (${l.attrName(e, "adjust")})`
|
|
2700
2700
|
);
|
|
2701
2701
|
}
|
|
2702
|
-
if (t.hasAttribute(
|
|
2702
|
+
if (t.hasAttribute(l.attrName(e, "adjust-value"))) {
|
|
2703
2703
|
const g = t.getRawAttribute(
|
|
2704
|
-
|
|
2704
|
+
l.attrName(e, "adjust-value")
|
|
2705
2705
|
), A = Number(g);
|
|
2706
2706
|
isNaN(A) || (r.adjustValue = A);
|
|
2707
2707
|
}
|
|
2708
2708
|
}
|
|
2709
|
-
if (t.hasAttribute(
|
|
2710
|
-
const
|
|
2711
|
-
`${
|
|
2709
|
+
if (t.hasAttribute(l.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(l.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(l.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(l.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${c.prefix}${e}-after-run`)) {
|
|
2710
|
+
const f = t.getRawAttribute(
|
|
2711
|
+
`${c.prefix}${e}-after-run`
|
|
2712
2712
|
);
|
|
2713
2713
|
try {
|
|
2714
2714
|
r.afterCallback = new Function(
|
|
2715
2715
|
"response",
|
|
2716
2716
|
`
|
|
2717
2717
|
"use strict";
|
|
2718
|
-
${
|
|
2718
|
+
${f}
|
|
2719
2719
|
`
|
|
2720
2720
|
);
|
|
2721
2721
|
} catch (g) {
|
|
2722
|
-
|
|
2722
|
+
d.error("Haori", `Invalid after script: ${g}`);
|
|
2723
2723
|
}
|
|
2724
2724
|
}
|
|
2725
|
-
if (t.hasAttribute(
|
|
2726
|
-
|
|
2725
|
+
if (t.hasAttribute(l.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2726
|
+
l.attrName(e, "dialog")
|
|
2727
2727
|
).replace(/\\n/g, `
|
|
2728
|
-
`)), t.hasAttribute(
|
|
2728
|
+
`)), t.hasAttribute(l.attrName(e, "toast"))) {
|
|
2729
2729
|
r.toastMessage = t.getAttribute(
|
|
2730
|
-
|
|
2730
|
+
l.attrName(e, "toast")
|
|
2731
2731
|
);
|
|
2732
|
-
const
|
|
2733
|
-
|
|
2734
|
-
), A = ["info", "warning", "error", "success"].includes(
|
|
2735
|
-
r.toastLevel = A ?
|
|
2732
|
+
const f = t.getRawAttribute(
|
|
2733
|
+
l.attrName(e, "toast-level")
|
|
2734
|
+
), A = ["info", "warning", "error", "success"].includes(f);
|
|
2735
|
+
r.toastLevel = A ? f : null;
|
|
2736
2736
|
}
|
|
2737
|
-
if (t.hasAttribute(
|
|
2738
|
-
|
|
2739
|
-
)), t.hasAttribute(
|
|
2740
|
-
|
|
2741
|
-
)), t.hasAttribute(
|
|
2737
|
+
if (t.hasAttribute(l.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2738
|
+
l.attrName(e, "redirect")
|
|
2739
|
+
)), t.hasAttribute(l.attrName(e, "scroll-error")) && (r.scrollOnError = !0), t.hasAttribute(l.attrName(e, "scroll")) && (r.scrollTarget = t.getAttribute(
|
|
2740
|
+
l.attrName(e, "scroll")
|
|
2741
|
+
)), t.hasAttribute(l.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2742
|
+
l.attrName(e, "history")
|
|
2743
|
+
)), t.hasAttribute(l.attrName(e, "history-data")) && (r.historyData = l.resolveDataAttribute(
|
|
2742
2744
|
t,
|
|
2743
|
-
|
|
2744
|
-
)), t.hasAttribute(
|
|
2745
|
-
const
|
|
2746
|
-
|
|
2745
|
+
l.attrName(e, "history-data")
|
|
2746
|
+
)), t.hasAttribute(l.attrName(e, "history-form"))) {
|
|
2747
|
+
const f = t.getRawAttribute(
|
|
2748
|
+
l.attrName(e, "history-form")
|
|
2747
2749
|
);
|
|
2748
|
-
if (
|
|
2749
|
-
const g = document.body.querySelector(
|
|
2750
|
+
if (f) {
|
|
2751
|
+
const g = document.body.querySelector(f);
|
|
2750
2752
|
g !== null ? r.historyFormFragment = b.getFormFragment(
|
|
2751
2753
|
T.get(g)
|
|
2752
|
-
) :
|
|
2754
|
+
) : d.error(
|
|
2753
2755
|
"Haori",
|
|
2754
|
-
`Form element not found: ${
|
|
2756
|
+
`Form element not found: ${f} (${l.attrName(e, "history-form")})`
|
|
2755
2757
|
);
|
|
2756
2758
|
} else
|
|
2757
2759
|
r.historyFormFragment = b.getFormFragment(t);
|
|
@@ -2763,16 +2765,16 @@ ${h}
|
|
|
2763
2765
|
"copy",
|
|
2764
2766
|
"open",
|
|
2765
2767
|
"close"
|
|
2766
|
-
].forEach((
|
|
2767
|
-
const g =
|
|
2768
|
+
].forEach((f) => {
|
|
2769
|
+
const g = l.attrName(e, f);
|
|
2768
2770
|
if (!t.hasAttribute(g))
|
|
2769
2771
|
return;
|
|
2770
2772
|
const A = t.getRawAttribute(g), v = [];
|
|
2771
|
-
if (A ? (document.body.querySelectorAll(A).forEach((
|
|
2772
|
-
const
|
|
2773
|
-
|
|
2774
|
-
}), v.length === 0 &&
|
|
2775
|
-
switch (
|
|
2773
|
+
if (A ? (document.body.querySelectorAll(A).forEach((W) => {
|
|
2774
|
+
const tt = T.get(W);
|
|
2775
|
+
tt && v.push(tt);
|
|
2776
|
+
}), v.length === 0 && d.error("Haori", `Element not found: ${A} (${g})`)) : v.push(t), v.length > 0)
|
|
2777
|
+
switch (f) {
|
|
2776
2778
|
case "reset":
|
|
2777
2779
|
r.resetFragments = v;
|
|
2778
2780
|
break;
|
|
@@ -2794,25 +2796,25 @@ ${h}
|
|
|
2794
2796
|
}
|
|
2795
2797
|
});
|
|
2796
2798
|
}
|
|
2797
|
-
if (!e && (t.hasAttribute(
|
|
2799
|
+
if (!e && (t.hasAttribute(l.attrName(null, "data", !0)) && (r.data = l.resolveDataAttribute(
|
|
2798
2800
|
t,
|
|
2799
|
-
|
|
2800
|
-
)), t.hasAttribute(
|
|
2801
|
-
const
|
|
2802
|
-
|
|
2801
|
+
l.attrName(null, "data", !0)
|
|
2802
|
+
)), t.hasAttribute(l.attrName(null, "form", !0)))) {
|
|
2803
|
+
const h = t.getRawAttribute(
|
|
2804
|
+
l.attrName(null, "form", !0)
|
|
2803
2805
|
);
|
|
2804
|
-
if (
|
|
2805
|
-
const
|
|
2806
|
-
|
|
2807
|
-
T.get(
|
|
2808
|
-
) :
|
|
2806
|
+
if (h) {
|
|
2807
|
+
const f = document.body.querySelector(h);
|
|
2808
|
+
f !== null ? r.formFragment = b.getFormFragment(
|
|
2809
|
+
T.get(f)
|
|
2810
|
+
) : d.error(
|
|
2809
2811
|
"Haori",
|
|
2810
|
-
`Form element not found: ${
|
|
2812
|
+
`Form element not found: ${h} (${l.attrName(null, "fetch-form", !0)})`
|
|
2811
2813
|
);
|
|
2812
2814
|
} else
|
|
2813
2815
|
r.formFragment = b.getFormFragment(t);
|
|
2814
2816
|
}
|
|
2815
|
-
return
|
|
2817
|
+
return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2816
2818
|
}
|
|
2817
2819
|
/**
|
|
2818
2820
|
* ElementFragment の構造的タイプガード。
|
|
@@ -2833,7 +2835,7 @@ ${h}
|
|
|
2833
2835
|
* @param arg2 イベント名
|
|
2834
2836
|
*/
|
|
2835
2837
|
constructor(t, e = null) {
|
|
2836
|
-
|
|
2838
|
+
l.isElementFragment(t) ? this.options = l.buildOptions(t, e) : this.options = t;
|
|
2837
2839
|
}
|
|
2838
2840
|
/**
|
|
2839
2841
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2878,42 +2880,42 @@ ${h}
|
|
|
2878
2880
|
Object.assign(i, o);
|
|
2879
2881
|
}
|
|
2880
2882
|
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2881
|
-
const
|
|
2883
|
+
const n = Object.keys(i).length > 0;
|
|
2882
2884
|
if (e) {
|
|
2883
|
-
const o = { ...r || {} },
|
|
2885
|
+
const o = { ...r || {} }, u = new Headers(
|
|
2884
2886
|
o.headers || void 0
|
|
2885
|
-
), m = (o.method || "GET").toUpperCase(), y =
|
|
2887
|
+
), m = (o.method || "GET").toUpperCase(), y = c.runtime === "demo" && !ct(m), E = y ? "GET" : m;
|
|
2886
2888
|
if (o.method = E, E === "GET" || E === "HEAD" || E === "OPTIONS")
|
|
2887
|
-
|
|
2888
|
-
else if (
|
|
2889
|
-
const
|
|
2890
|
-
if (/multipart\/form-data/i.test(
|
|
2891
|
-
|
|
2892
|
-
const
|
|
2889
|
+
n && (e = ht(e, i));
|
|
2890
|
+
else if (n) {
|
|
2891
|
+
const h = u.get("Content-Type") || "";
|
|
2892
|
+
if (/multipart\/form-data/i.test(h)) {
|
|
2893
|
+
u.delete("Content-Type");
|
|
2894
|
+
const f = new FormData();
|
|
2893
2895
|
for (const [g, A] of Object.entries(i))
|
|
2894
|
-
A == null ?
|
|
2895
|
-
o.body =
|
|
2896
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2897
|
-
const
|
|
2896
|
+
A == null ? f.append(g, "") : A instanceof Blob ? f.append(g, A) : Array.isArray(A) ? A.forEach((v) => f.append(g, String(v))) : typeof A == "object" ? f.append(g, JSON.stringify(A)) : f.append(g, String(A));
|
|
2897
|
+
o.body = f;
|
|
2898
|
+
} else if (/application\/x-www-form-urlencoded/i.test(h)) {
|
|
2899
|
+
const f = new URLSearchParams();
|
|
2898
2900
|
for (const [g, A] of Object.entries(i))
|
|
2899
|
-
A !== void 0 && (A === null ?
|
|
2900
|
-
o.body =
|
|
2901
|
+
A !== void 0 && (A === null ? f.append(g, "") : Array.isArray(A) ? A.forEach((v) => f.append(g, String(v))) : typeof A == "object" ? f.append(g, JSON.stringify(A)) : f.append(g, String(A)));
|
|
2902
|
+
o.body = f;
|
|
2901
2903
|
} else
|
|
2902
|
-
|
|
2904
|
+
u.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2903
2905
|
}
|
|
2904
|
-
o.headers =
|
|
2906
|
+
o.headers = u;
|
|
2905
2907
|
let S;
|
|
2906
|
-
if (y && (S = e && new URL(e, window.location.href).search || void 0,
|
|
2907
|
-
runtime:
|
|
2908
|
+
if (y && (S = e && new URL(e, window.location.href).search || void 0, u.delete("Content-Type"), d.info("Haori demo fetch normalization", {
|
|
2909
|
+
runtime: c.runtime,
|
|
2908
2910
|
requestedMethod: m,
|
|
2909
2911
|
effectiveMethod: E,
|
|
2910
2912
|
transportMode: "query-get",
|
|
2911
2913
|
url: e,
|
|
2912
|
-
payload:
|
|
2914
|
+
payload: n ? i : void 0,
|
|
2913
2915
|
queryString: S
|
|
2914
2916
|
})), this.options.targetFragment && e) {
|
|
2915
|
-
const
|
|
2916
|
-
runtime:
|
|
2917
|
+
const h = performance.now(), f = {
|
|
2918
|
+
runtime: c.runtime,
|
|
2917
2919
|
requestedMethod: m,
|
|
2918
2920
|
effectiveMethod: E,
|
|
2919
2921
|
transportMode: y ? "query-get" : "http",
|
|
@@ -2923,12 +2925,12 @@ ${h}
|
|
|
2923
2925
|
this.options.targetFragment.getTarget(),
|
|
2924
2926
|
e,
|
|
2925
2927
|
o,
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
+
n ? i : void 0,
|
|
2929
|
+
f
|
|
2928
2930
|
), fetch(e, o).then((g) => this.handleFetchResult(
|
|
2929
2931
|
g,
|
|
2930
2932
|
e || void 0,
|
|
2931
|
-
|
|
2933
|
+
h
|
|
2932
2934
|
)).catch((g) => {
|
|
2933
2935
|
throw e && w.fetchError(
|
|
2934
2936
|
this.options.targetFragment.getTarget(),
|
|
@@ -2937,18 +2939,18 @@ ${h}
|
|
|
2937
2939
|
), g;
|
|
2938
2940
|
});
|
|
2939
2941
|
}
|
|
2940
|
-
return fetch(e, o).then((
|
|
2942
|
+
return fetch(e, o).then((h) => this.handleFetchResult(h, e || void 0));
|
|
2941
2943
|
}
|
|
2942
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
2943
|
-
const o = this.options.formFragment,
|
|
2944
|
-
|
|
2945
|
-
`${
|
|
2944
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && n) {
|
|
2945
|
+
const o = this.options.formFragment, u = o.getTarget();
|
|
2946
|
+
u.setAttribute(
|
|
2947
|
+
`${c.prefix}bind`,
|
|
2946
2948
|
JSON.stringify(i)
|
|
2947
2949
|
);
|
|
2948
2950
|
const m = o.getBindingData();
|
|
2949
|
-
Object.assign(m, i), await
|
|
2951
|
+
Object.assign(m, i), await R.setBindingData(u, m);
|
|
2950
2952
|
}
|
|
2951
|
-
const
|
|
2953
|
+
const s = n ? i : {}, a = new Response(JSON.stringify(s), {
|
|
2952
2954
|
headers: { "Content-Type": "application/json" }
|
|
2953
2955
|
});
|
|
2954
2956
|
return this.handleFetchResult(a);
|
|
@@ -2957,7 +2959,7 @@ ${h}
|
|
|
2957
2959
|
* フェッチ後の処理を実行します。
|
|
2958
2960
|
*/
|
|
2959
2961
|
async handleFetchResult(t, e, r) {
|
|
2960
|
-
const i =
|
|
2962
|
+
const i = Y();
|
|
2961
2963
|
if (!t.ok)
|
|
2962
2964
|
return this.options.targetFragment && e && w.fetchError(
|
|
2963
2965
|
this.options.targetFragment.getTarget(),
|
|
@@ -2979,13 +2981,13 @@ ${h}
|
|
|
2979
2981
|
typeof a == "object" && "response" in a && (t = "response" in a ? a.response : t);
|
|
2980
2982
|
}
|
|
2981
2983
|
}
|
|
2982
|
-
const
|
|
2983
|
-
|
|
2984
|
+
const n = [];
|
|
2985
|
+
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(
|
|
2984
2986
|
this.options.resetFragments.map((a) => b.reset(a))
|
|
2985
2987
|
), await this.copy();
|
|
2986
|
-
const
|
|
2988
|
+
const s = [];
|
|
2987
2989
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
2988
|
-
|
|
2990
|
+
s.push(new l(a, null).run());
|
|
2989
2991
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
2990
2992
|
const o = a.getTarget();
|
|
2991
2993
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
@@ -2993,14 +2995,14 @@ ${h}
|
|
|
2993
2995
|
);
|
|
2994
2996
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
2995
2997
|
const o = a.getTarget();
|
|
2996
|
-
o instanceof HTMLElement ?
|
|
2998
|
+
o instanceof HTMLElement ? s.push(i.openDialog(o)) : d.error("Haori", "Element is not an HTML element: ", o);
|
|
2997
2999
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
2998
3000
|
const o = a.getTarget();
|
|
2999
|
-
o instanceof HTMLElement ?
|
|
3000
|
-
}), await Promise.all(
|
|
3001
|
+
o instanceof HTMLElement ? s.push(i.closeDialog(o)) : d.error("Haori", "Element is not an HTML element: ", o);
|
|
3002
|
+
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3001
3003
|
this.options.toastMessage,
|
|
3002
3004
|
this.options.toastLevel ?? "info"
|
|
3003
|
-
), this.pushHistory(), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
3005
|
+
), 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;
|
|
3004
3006
|
}
|
|
3005
3007
|
/**
|
|
3006
3008
|
* history.pushState を実行します。
|
|
@@ -3013,26 +3015,30 @@ ${h}
|
|
|
3013
3015
|
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;
|
|
3014
3016
|
if (!(!t && !e && !r))
|
|
3015
3017
|
try {
|
|
3016
|
-
const i = t ? this.options.historyUrl : window.location.pathname,
|
|
3017
|
-
if (
|
|
3018
|
-
const a = "history.pushState: cross-origin URL is not allowed: " +
|
|
3019
|
-
|
|
3018
|
+
const i = t ? this.options.historyUrl : window.location.pathname, n = new URL(i, window.location.href);
|
|
3019
|
+
if (n.origin !== window.location.origin) {
|
|
3020
|
+
const a = "history.pushState: cross-origin URL is not allowed: " + n.toString();
|
|
3021
|
+
d.error(
|
|
3020
3022
|
"Haori",
|
|
3021
3023
|
a
|
|
3022
3024
|
);
|
|
3023
3025
|
return;
|
|
3024
3026
|
}
|
|
3025
|
-
const
|
|
3026
|
-
for (const [o,
|
|
3027
|
-
|
|
3027
|
+
const s = (a) => {
|
|
3028
|
+
for (const [o, u] of Object.entries(a))
|
|
3029
|
+
u != null && (Array.isArray(u) ? u.forEach((m) => n.searchParams.append(o, String(m))) : typeof u == "object" ? n.searchParams.set(o, JSON.stringify(u)) : n.searchParams.set(o, String(u)));
|
|
3028
3030
|
};
|
|
3029
|
-
e &&
|
|
3031
|
+
e && s(this.options.historyData), r && s(
|
|
3030
3032
|
b.getValues(
|
|
3031
3033
|
this.options.historyFormFragment
|
|
3032
3034
|
)
|
|
3033
|
-
), history.pushState(
|
|
3035
|
+
), history.pushState(
|
|
3036
|
+
{ [ot]: !0 },
|
|
3037
|
+
"",
|
|
3038
|
+
n.toString()
|
|
3039
|
+
);
|
|
3034
3040
|
} catch (i) {
|
|
3035
|
-
|
|
3041
|
+
d.error("Haori", `history.pushState failed: ${i}`);
|
|
3036
3042
|
}
|
|
3037
3043
|
}
|
|
3038
3044
|
/**
|
|
@@ -3042,30 +3048,35 @@ ${h}
|
|
|
3042
3048
|
let e = null;
|
|
3043
3049
|
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = b.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3044
3050
|
const r = async (s) => {
|
|
3045
|
-
const
|
|
3046
|
-
await
|
|
3051
|
+
const a = e ? e.getTarget() : document.body;
|
|
3052
|
+
await Y().addErrorMessage(a, s);
|
|
3053
|
+
}, i = () => {
|
|
3054
|
+
if (!this.options.scrollOnError)
|
|
3055
|
+
return;
|
|
3056
|
+
const s = e ? e.getTarget() : document.body;
|
|
3057
|
+
(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" });
|
|
3047
3058
|
};
|
|
3048
3059
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
3049
3060
|
try {
|
|
3050
|
-
const s = await t.json(),
|
|
3061
|
+
const s = await t.json(), a = [];
|
|
3051
3062
|
if (s && typeof s == "object") {
|
|
3052
|
-
if (typeof s.message == "string" &&
|
|
3053
|
-
for (const
|
|
3054
|
-
typeof
|
|
3063
|
+
if (typeof s.message == "string" && a.push({ message: s.message }), Array.isArray(s.messages))
|
|
3064
|
+
for (const o of s.messages)
|
|
3065
|
+
typeof o == "string" && a.push({ message: o });
|
|
3055
3066
|
if (s.errors && typeof s.errors == "object")
|
|
3056
|
-
for (const [
|
|
3057
|
-
Array.isArray(
|
|
3058
|
-
`) }) : typeof
|
|
3059
|
-
if (
|
|
3060
|
-
for (const [
|
|
3061
|
-
|
|
3062
|
-
`) }) : typeof
|
|
3067
|
+
for (const [o, u] of Object.entries(s.errors))
|
|
3068
|
+
Array.isArray(u) ? a.push({ key: o, message: u.join(`
|
|
3069
|
+
`) }) : typeof u == "string" ? a.push({ key: o, message: u }) : u != null && a.push({ key: o, message: String(u) });
|
|
3070
|
+
if (a.length === 0)
|
|
3071
|
+
for (const [o, u] of Object.entries(s))
|
|
3072
|
+
o === "message" || o === "messages" || o === "errors" || (Array.isArray(u) ? a.push({ key: o, message: u.join(`
|
|
3073
|
+
`) }) : typeof u == "string" && a.push({ key: o, message: u }));
|
|
3063
3074
|
}
|
|
3064
|
-
if (
|
|
3065
|
-
return await r(`${t.status} ${t.statusText}`), !1;
|
|
3066
|
-
for (const
|
|
3067
|
-
|
|
3068
|
-
return !1;
|
|
3075
|
+
if (a.length === 0)
|
|
3076
|
+
return await r(`${t.status} ${t.statusText}`), i(), !1;
|
|
3077
|
+
for (const o of a)
|
|
3078
|
+
o.key && e ? await b.addErrorMessage(e, o.key, o.message) : await r(o.message);
|
|
3079
|
+
return i(), !1;
|
|
3069
3080
|
} catch {
|
|
3070
3081
|
}
|
|
3071
3082
|
try {
|
|
@@ -3074,7 +3085,7 @@ ${h}
|
|
|
3074
3085
|
} catch {
|
|
3075
3086
|
await r(`${t.status} ${t.statusText}`);
|
|
3076
3087
|
}
|
|
3077
|
-
return !1;
|
|
3088
|
+
return i(), !1;
|
|
3078
3089
|
}
|
|
3079
3090
|
/**
|
|
3080
3091
|
* 対象のフラグメント以下の入力要素に対してバリデーションを実行します。
|
|
@@ -3086,21 +3097,34 @@ ${h}
|
|
|
3086
3097
|
validate(t) {
|
|
3087
3098
|
if (this.options.valid !== !0)
|
|
3088
3099
|
return !0;
|
|
3089
|
-
const e =
|
|
3090
|
-
|
|
3091
|
-
return r || e.focus(), t.getChildElementFragments().reverse().forEach((i) => {
|
|
3092
|
-
r &&= this.validate(i);
|
|
3093
|
-
}), r;
|
|
3100
|
+
const e = this.findFirstInvalid(t);
|
|
3101
|
+
return e === null ? !0 : (e.reportValidity(), e.focus(), this.options.scrollOnError && e.scrollIntoView({ behavior: "smooth", block: "nearest" }), !1);
|
|
3094
3102
|
}
|
|
3095
3103
|
/**
|
|
3096
|
-
*
|
|
3104
|
+
* 対象フラグメント以下で DOM 順の最上部にある invalid 要素を返します。
|
|
3105
|
+
* 副作用のない checkValidity のみを使用し、検出のみを行います。
|
|
3097
3106
|
*
|
|
3098
3107
|
* @param fragment 対象のフラグメント
|
|
3099
|
-
* @returns
|
|
3108
|
+
* @returns 最初の invalid 要素、なければ null
|
|
3109
|
+
*/
|
|
3110
|
+
findFirstInvalid(t) {
|
|
3111
|
+
let e = null;
|
|
3112
|
+
for (const r of t.getChildElementFragments().reverse()) {
|
|
3113
|
+
const i = this.findFirstInvalid(r);
|
|
3114
|
+
i !== null && (e = i);
|
|
3115
|
+
}
|
|
3116
|
+
return this.checkOne(t) ? e : t.getTarget();
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* 対象のフラグメントに対して、副作用なく有効性を検査します。
|
|
3120
|
+
* reportValidity は使わず checkValidity のみ呼び出します。
|
|
3121
|
+
*
|
|
3122
|
+
* @param fragment 対象のフラグメント
|
|
3123
|
+
* @returns 有効なら true、無効なら false
|
|
3100
3124
|
*/
|
|
3101
|
-
|
|
3125
|
+
checkOne(t) {
|
|
3102
3126
|
const e = t.getTarget();
|
|
3103
|
-
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? e.
|
|
3127
|
+
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? e.checkValidity() : !0;
|
|
3104
3128
|
}
|
|
3105
3129
|
/**
|
|
3106
3130
|
* 確認メッセージを表示し、ユーザーの確認を求めます。
|
|
@@ -3110,7 +3134,7 @@ ${h}
|
|
|
3110
3134
|
*/
|
|
3111
3135
|
confirm() {
|
|
3112
3136
|
const t = this.options.confirmMessage;
|
|
3113
|
-
return t == null ? Promise.resolve(!0) :
|
|
3137
|
+
return t == null ? Promise.resolve(!0) : Y().confirm(t);
|
|
3114
3138
|
}
|
|
3115
3139
|
/**
|
|
3116
3140
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -3120,40 +3144,40 @@ ${h}
|
|
|
3120
3144
|
bindResult(t) {
|
|
3121
3145
|
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) => {
|
|
3122
3146
|
if (this.options.bindParams) {
|
|
3123
|
-
const
|
|
3124
|
-
this.options.bindParams.forEach((
|
|
3125
|
-
r && typeof r == "object" &&
|
|
3126
|
-
}), r =
|
|
3147
|
+
const n = {};
|
|
3148
|
+
this.options.bindParams.forEach((s) => {
|
|
3149
|
+
r && typeof r == "object" && s in r && (n[s] = r[s]);
|
|
3150
|
+
}), r = n;
|
|
3127
3151
|
}
|
|
3128
3152
|
const i = [];
|
|
3129
3153
|
if (this.options.bindArg)
|
|
3130
|
-
this.options.bindFragments.forEach((
|
|
3131
|
-
const
|
|
3154
|
+
this.options.bindFragments.forEach((n) => {
|
|
3155
|
+
const s = n.getBindingData(), a = this.options.bindArg;
|
|
3132
3156
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3133
|
-
const o =
|
|
3134
|
-
|
|
3135
|
-
|
|
3157
|
+
const o = s[a], u = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3158
|
+
s[a] = this.mergeAppendBindingData(
|
|
3159
|
+
n,
|
|
3136
3160
|
r,
|
|
3137
|
-
|
|
3161
|
+
u
|
|
3138
3162
|
);
|
|
3139
3163
|
} else
|
|
3140
|
-
|
|
3141
|
-
i.push(
|
|
3164
|
+
s[a] = r;
|
|
3165
|
+
i.push(R.setBindingData(n.getTarget(), s));
|
|
3142
3166
|
});
|
|
3143
3167
|
else {
|
|
3144
3168
|
if (typeof r == "string")
|
|
3145
|
-
return
|
|
3169
|
+
return d.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
3146
3170
|
new Error("string data cannot be bound without a bindArg.")
|
|
3147
3171
|
);
|
|
3148
|
-
this.options.bindFragments.forEach((
|
|
3149
|
-
const
|
|
3150
|
-
|
|
3172
|
+
this.options.bindFragments.forEach((n) => {
|
|
3173
|
+
const s = this.mergeAppendBindingData(
|
|
3174
|
+
n,
|
|
3151
3175
|
r
|
|
3152
3176
|
);
|
|
3153
3177
|
i.push(
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3178
|
+
R.setBindingData(
|
|
3179
|
+
n.getTarget(),
|
|
3180
|
+
s
|
|
3157
3181
|
)
|
|
3158
3182
|
);
|
|
3159
3183
|
});
|
|
@@ -3168,10 +3192,10 @@ ${h}
|
|
|
3168
3192
|
mergeAppendBindingData(t, e, r = t.getBindingData()) {
|
|
3169
3193
|
if (!this.options.bindAppendParams || this.options.bindAppendParams.length === 0)
|
|
3170
3194
|
return e;
|
|
3171
|
-
const i = { ...e },
|
|
3172
|
-
for (const
|
|
3173
|
-
const a = i[
|
|
3174
|
-
Array.isArray(o) && Array.isArray(a) && (i[
|
|
3195
|
+
const i = { ...e }, n = r;
|
|
3196
|
+
for (const s of this.options.bindAppendParams) {
|
|
3197
|
+
const a = i[s], o = n[s];
|
|
3198
|
+
Array.isArray(o) && Array.isArray(a) && (i[s] = o.concat(a));
|
|
3175
3199
|
}
|
|
3176
3200
|
return i;
|
|
3177
3201
|
}
|
|
@@ -3182,11 +3206,11 @@ ${h}
|
|
|
3182
3206
|
if (!this.options.copyFragments || this.options.copyFragments.length === 0)
|
|
3183
3207
|
return Promise.resolve();
|
|
3184
3208
|
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((i) => {
|
|
3185
|
-
const
|
|
3209
|
+
const n = {
|
|
3186
3210
|
...i.getBindingData(),
|
|
3187
3211
|
...e
|
|
3188
3212
|
};
|
|
3189
|
-
return
|
|
3213
|
+
return R.setBindingData(i.getTarget(), n);
|
|
3190
3214
|
});
|
|
3191
3215
|
return Promise.all(r).then(() => {
|
|
3192
3216
|
});
|
|
@@ -3218,8 +3242,8 @@ ${h}
|
|
|
3218
3242
|
for (const r of this.options.adjustFragments) {
|
|
3219
3243
|
let i = r.getValue();
|
|
3220
3244
|
(i == null || i === "") && (i = "0");
|
|
3221
|
-
let
|
|
3222
|
-
isNaN(
|
|
3245
|
+
let n = Number(i);
|
|
3246
|
+
isNaN(n) && (n = 0), n += t, e.push(r.setValue(String(n)));
|
|
3223
3247
|
}
|
|
3224
3248
|
return Promise.all(e).then(() => {
|
|
3225
3249
|
});
|
|
@@ -3231,11 +3255,11 @@ ${h}
|
|
|
3231
3255
|
*/
|
|
3232
3256
|
getRowFragment() {
|
|
3233
3257
|
if (!this.options.targetFragment)
|
|
3234
|
-
return
|
|
3258
|
+
return d.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3235
3259
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3236
|
-
`${
|
|
3260
|
+
`${c.prefix}row`
|
|
3237
3261
|
);
|
|
3238
|
-
return t || (
|
|
3262
|
+
return t || (d.error("Haori", "Row fragment not found."), null);
|
|
3239
3263
|
}
|
|
3240
3264
|
/**
|
|
3241
3265
|
* 行を追加します。
|
|
@@ -3251,7 +3275,7 @@ ${h}
|
|
|
3251
3275
|
const e = [], r = t.clone();
|
|
3252
3276
|
return e.push(
|
|
3253
3277
|
t.getParent().insertAfter(r, t)
|
|
3254
|
-
), e.push(
|
|
3278
|
+
), e.push(R.evaluateAll(r)), e.push(b.reset(r)), Promise.all(e).then(() => {
|
|
3255
3279
|
});
|
|
3256
3280
|
}
|
|
3257
3281
|
/**
|
|
@@ -3266,7 +3290,7 @@ ${h}
|
|
|
3266
3290
|
if (!t)
|
|
3267
3291
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3268
3292
|
const e = t.getParent();
|
|
3269
|
-
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
3293
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${c.prefix}each-before`) && !i.hasAttribute(`${c.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3270
3294
|
}
|
|
3271
3295
|
/**
|
|
3272
3296
|
* 前の行へ移動します。
|
|
@@ -3303,9 +3327,9 @@ ${h}
|
|
|
3303
3327
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3304
3328
|
}
|
|
3305
3329
|
};
|
|
3306
|
-
|
|
3307
|
-
let V =
|
|
3308
|
-
class
|
|
3330
|
+
l.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, l.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
3331
|
+
let V = l;
|
|
3332
|
+
class ft {
|
|
3309
3333
|
/**
|
|
3310
3334
|
* URLのクエリパラメータを取得します。
|
|
3311
3335
|
*
|
|
@@ -3313,12 +3337,12 @@ class ut {
|
|
|
3313
3337
|
*/
|
|
3314
3338
|
static readParams() {
|
|
3315
3339
|
const t = {}, e = window.location.search;
|
|
3316
|
-
return new URLSearchParams(e).forEach((i,
|
|
3317
|
-
t[
|
|
3340
|
+
return new URLSearchParams(e).forEach((i, n) => {
|
|
3341
|
+
t[n] = i;
|
|
3318
3342
|
}), t;
|
|
3319
3343
|
}
|
|
3320
3344
|
}
|
|
3321
|
-
class
|
|
3345
|
+
class dt {
|
|
3322
3346
|
/**
|
|
3323
3347
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3324
3348
|
*
|
|
@@ -3335,24 +3359,24 @@ class ct {
|
|
|
3335
3359
|
let r;
|
|
3336
3360
|
try {
|
|
3337
3361
|
r = await fetch(t, e);
|
|
3338
|
-
} catch (
|
|
3339
|
-
throw
|
|
3362
|
+
} catch (n) {
|
|
3363
|
+
throw d.error("[Haori]", "Failed to fetch import source:", t, n), new Error(`Failed to fetch: ${t}`);
|
|
3340
3364
|
}
|
|
3341
3365
|
if (!r.ok) {
|
|
3342
|
-
const
|
|
3343
|
-
throw
|
|
3366
|
+
const n = `${r.status} ${r.statusText}`;
|
|
3367
|
+
throw d.error("[Haori]", "Import HTTP error:", t, n), new Error(`Failed to load ${t}: ${n}`);
|
|
3344
3368
|
}
|
|
3345
3369
|
let i;
|
|
3346
3370
|
try {
|
|
3347
3371
|
i = await r.text();
|
|
3348
|
-
} catch (
|
|
3349
|
-
throw
|
|
3372
|
+
} catch (n) {
|
|
3373
|
+
throw d.error("[Haori]", "Failed to read response text:", t, n), new Error(`Failed to read response from: ${t}`);
|
|
3350
3374
|
}
|
|
3351
3375
|
try {
|
|
3352
|
-
const
|
|
3353
|
-
return
|
|
3354
|
-
} catch (
|
|
3355
|
-
return
|
|
3376
|
+
const s = new DOMParser().parseFromString(i, "text/html");
|
|
3377
|
+
return s && s.body ? s.body.innerHTML : (d.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3378
|
+
} catch (n) {
|
|
3379
|
+
return d.error("[Haori]", "Failed to parse imported HTML:", t, n), i;
|
|
3356
3380
|
}
|
|
3357
3381
|
}
|
|
3358
3382
|
}
|
|
@@ -3365,7 +3389,7 @@ const p = class p {
|
|
|
3365
3389
|
*/
|
|
3366
3390
|
static isDeferredAttributeName(t) {
|
|
3367
3391
|
return p.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3368
|
-
(e) => t === `${
|
|
3392
|
+
(e) => t === `${c.prefix}${e}`
|
|
3369
3393
|
);
|
|
3370
3394
|
}
|
|
3371
3395
|
/**
|
|
@@ -3376,7 +3400,7 @@ const p = class p {
|
|
|
3376
3400
|
*/
|
|
3377
3401
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3378
3402
|
return p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3379
|
-
(e) => t === `${
|
|
3403
|
+
(e) => t === `${c.prefix}${e}`
|
|
3380
3404
|
);
|
|
3381
3405
|
}
|
|
3382
3406
|
/**
|
|
@@ -3396,7 +3420,7 @@ const p = class p {
|
|
|
3396
3420
|
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
3397
3421
|
*/
|
|
3398
3422
|
static getAliasedAttributeName(t) {
|
|
3399
|
-
const e = `${
|
|
3423
|
+
const e = `${c.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
3400
3424
|
return !t.startsWith(e) || t.length <= e.length ? null : t.slice(e.length);
|
|
3401
3425
|
}
|
|
3402
3426
|
/**
|
|
@@ -3408,8 +3432,8 @@ const p = class p {
|
|
|
3408
3432
|
*/
|
|
3409
3433
|
static isAliasedAttributeReflection(t, e) {
|
|
3410
3434
|
const r = T.get(t);
|
|
3411
|
-
return r instanceof
|
|
3412
|
-
`${
|
|
3435
|
+
return r instanceof x ? r.hasAttribute(
|
|
3436
|
+
`${c.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}${e}`
|
|
3413
3437
|
) : !1;
|
|
3414
3438
|
}
|
|
3415
3439
|
/**
|
|
@@ -3443,39 +3467,39 @@ const p = class p {
|
|
|
3443
3467
|
t.parentNode && (T.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3444
3468
|
let r = Promise.resolve();
|
|
3445
3469
|
const i = /* @__PURE__ */ new Set();
|
|
3446
|
-
for (const
|
|
3447
|
-
const
|
|
3448
|
-
e.hasAttribute(
|
|
3470
|
+
for (const n of p.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3471
|
+
const s = c.prefix + n;
|
|
3472
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3449
3473
|
() => p.setAttribute(
|
|
3450
3474
|
e.getTarget(),
|
|
3451
|
-
|
|
3452
|
-
e.getRawAttribute(
|
|
3475
|
+
s,
|
|
3476
|
+
e.getRawAttribute(s)
|
|
3453
3477
|
)
|
|
3454
|
-
), i.add(
|
|
3478
|
+
), i.add(s));
|
|
3455
3479
|
}
|
|
3456
|
-
for (const
|
|
3457
|
-
if (i.has(
|
|
3480
|
+
for (const n of e.getAttributeNames()) {
|
|
3481
|
+
if (i.has(n) || p.isDeferredAttributeName(n))
|
|
3458
3482
|
continue;
|
|
3459
|
-
const
|
|
3460
|
-
|
|
3461
|
-
() => p.setAttribute(e.getTarget(),
|
|
3483
|
+
const s = e.getRawAttribute(n);
|
|
3484
|
+
s !== null && (r = r.then(
|
|
3485
|
+
() => p.setAttribute(e.getTarget(), n, s)
|
|
3462
3486
|
));
|
|
3463
3487
|
}
|
|
3464
|
-
for (const
|
|
3465
|
-
const
|
|
3466
|
-
e.hasAttribute(
|
|
3488
|
+
for (const n of p.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3489
|
+
const s = c.prefix + n;
|
|
3490
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3467
3491
|
() => p.setAttribute(
|
|
3468
3492
|
e.getTarget(),
|
|
3469
|
-
|
|
3470
|
-
e.getRawAttribute(
|
|
3493
|
+
s,
|
|
3494
|
+
e.getRawAttribute(s)
|
|
3471
3495
|
)
|
|
3472
|
-
), i.add(
|
|
3496
|
+
), i.add(s));
|
|
3473
3497
|
}
|
|
3474
3498
|
return r.then(() => {
|
|
3475
|
-
const
|
|
3476
|
-
return e.getChildren().forEach((
|
|
3477
|
-
|
|
3478
|
-
}), Promise.all(
|
|
3499
|
+
const n = [];
|
|
3500
|
+
return e.getChildren().forEach((s) => {
|
|
3501
|
+
s instanceof x ? n.push(p.scan(s.getTarget())) : s instanceof H && n.push(p.evaluateText(s));
|
|
3502
|
+
}), Promise.all(n).then(() => {
|
|
3479
3503
|
});
|
|
3480
3504
|
}).then(() => {
|
|
3481
3505
|
});
|
|
@@ -3490,57 +3514,57 @@ const p = class p {
|
|
|
3490
3514
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3491
3515
|
*/
|
|
3492
3516
|
static setAttribute(t, e, r) {
|
|
3493
|
-
const i = T.get(t),
|
|
3494
|
-
if (
|
|
3495
|
-
return r === null ? i.removeAliasedAttribute(e,
|
|
3496
|
-
const
|
|
3517
|
+
const i = T.get(t), n = p.getAliasedAttributeName(e);
|
|
3518
|
+
if (n !== null)
|
|
3519
|
+
return r === null ? i.removeAliasedAttribute(e, n) : i.setAliasedAttribute(e, n, r);
|
|
3520
|
+
const s = [];
|
|
3497
3521
|
switch (e) {
|
|
3498
|
-
case `${
|
|
3522
|
+
case `${c.prefix}bind`: {
|
|
3499
3523
|
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(p.parseDataBind(r));
|
|
3500
3524
|
break;
|
|
3501
3525
|
}
|
|
3502
|
-
case `${
|
|
3503
|
-
|
|
3526
|
+
case `${c.prefix}if`:
|
|
3527
|
+
s.push(p.evaluateIf(i));
|
|
3504
3528
|
break;
|
|
3505
|
-
case `${
|
|
3506
|
-
|
|
3529
|
+
case `${c.prefix}each`:
|
|
3530
|
+
s.push(p.evaluateEach(i));
|
|
3507
3531
|
break;
|
|
3508
|
-
case `${
|
|
3509
|
-
|
|
3532
|
+
case `${c.prefix}fetch`:
|
|
3533
|
+
s.push(
|
|
3510
3534
|
new V(i, null).run().then(() => {
|
|
3511
3535
|
})
|
|
3512
3536
|
);
|
|
3513
3537
|
break;
|
|
3514
|
-
case `${
|
|
3538
|
+
case `${c.prefix}import`: {
|
|
3515
3539
|
if (typeof r == "string") {
|
|
3516
3540
|
const a = i.getTarget(), o = performance.now();
|
|
3517
|
-
w.importStart(a, r),
|
|
3518
|
-
|
|
3519
|
-
const m = new TextEncoder().encode(
|
|
3541
|
+
w.importStart(a, r), s.push(
|
|
3542
|
+
dt.load(r).then((u) => {
|
|
3543
|
+
const m = new TextEncoder().encode(u).length;
|
|
3520
3544
|
return P.enqueue(() => {
|
|
3521
|
-
a.innerHTML =
|
|
3545
|
+
a.innerHTML = u;
|
|
3522
3546
|
}).then(() => {
|
|
3523
3547
|
w.importEnd(a, r, m, o);
|
|
3524
3548
|
});
|
|
3525
|
-
}).catch((
|
|
3526
|
-
w.importError(a, r,
|
|
3549
|
+
}).catch((u) => {
|
|
3550
|
+
w.importError(a, r, u), d.error("[Haori]", "Failed to import HTML:", r, u);
|
|
3527
3551
|
})
|
|
3528
3552
|
);
|
|
3529
3553
|
}
|
|
3530
3554
|
break;
|
|
3531
3555
|
}
|
|
3532
|
-
case `${
|
|
3533
|
-
const a = i.getAttribute(`${
|
|
3556
|
+
case `${c.prefix}url-param`: {
|
|
3557
|
+
const a = i.getAttribute(`${c.prefix}url-arg`), o = ft.readParams();
|
|
3534
3558
|
if (a === null)
|
|
3535
|
-
|
|
3559
|
+
s.push(p.setBindingData(t, o));
|
|
3536
3560
|
else {
|
|
3537
|
-
const
|
|
3538
|
-
|
|
3561
|
+
const u = i.getRawBindingData() || {};
|
|
3562
|
+
u[String(a)] = o, s.push(p.setBindingData(t, u));
|
|
3539
3563
|
}
|
|
3540
3564
|
break;
|
|
3541
3565
|
}
|
|
3542
3566
|
}
|
|
3543
|
-
return r === null ?
|
|
3567
|
+
return r === null ? s.push(i.removeAttribute(e)) : s.push(i.setAttribute(e, r)), Promise.all(s).then(() => {
|
|
3544
3568
|
});
|
|
3545
3569
|
}
|
|
3546
3570
|
/**
|
|
@@ -3554,15 +3578,15 @@ const p = class p {
|
|
|
3554
3578
|
static setBindingData(t, e) {
|
|
3555
3579
|
const r = T.get(t), i = r.getRawBindingData();
|
|
3556
3580
|
r.setBindingData(e);
|
|
3557
|
-
let
|
|
3558
|
-
`${
|
|
3581
|
+
let n = r.setAttribute(
|
|
3582
|
+
`${c.prefix}bind`,
|
|
3559
3583
|
JSON.stringify(e)
|
|
3560
3584
|
);
|
|
3561
3585
|
if (t.tagName === "FORM") {
|
|
3562
|
-
const
|
|
3563
|
-
|
|
3586
|
+
const s = r.getAttribute(`${c.prefix}form-arg`), a = s && e[String(s)] && typeof e[String(s)] == "object" && !Array.isArray(e[String(s)]) ? e[String(s)] : s ? {} : e;
|
|
3587
|
+
n = n.then(() => b.syncValues(r, a));
|
|
3564
3588
|
}
|
|
3565
|
-
return
|
|
3589
|
+
return n = n.then(() => p.evaluateAll(r)), w.bindChange(t, i, e, "manual"), n.then(() => {
|
|
3566
3590
|
});
|
|
3567
3591
|
}
|
|
3568
3592
|
/**
|
|
@@ -3576,12 +3600,12 @@ const p = class p {
|
|
|
3576
3600
|
try {
|
|
3577
3601
|
return JSON.parse(t);
|
|
3578
3602
|
} catch (e) {
|
|
3579
|
-
return
|
|
3603
|
+
return d.error("[Haori]", "Invalid JSON in data-bind:", e), {};
|
|
3580
3604
|
}
|
|
3581
3605
|
else {
|
|
3582
3606
|
const e = new URLSearchParams(t), r = {};
|
|
3583
|
-
for (const [i,
|
|
3584
|
-
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(
|
|
3607
|
+
for (const [i, n] of e.entries())
|
|
3608
|
+
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(n) : r[i] = [r[i], n] : r[i] = n;
|
|
3585
3609
|
return r;
|
|
3586
3610
|
}
|
|
3587
3611
|
}
|
|
@@ -3595,8 +3619,8 @@ const p = class p {
|
|
|
3595
3619
|
const r = T.get(t);
|
|
3596
3620
|
if (r.isSkipMutationNodes())
|
|
3597
3621
|
return;
|
|
3598
|
-
const i = T.get(e.nextSibling),
|
|
3599
|
-
|
|
3622
|
+
const i = T.get(e.nextSibling), n = T.get(e);
|
|
3623
|
+
n && (r.insertBefore(n, i), n instanceof x ? p.scan(n.getTarget()) : n instanceof H && p.evaluateText(n));
|
|
3600
3624
|
}
|
|
3601
3625
|
/**
|
|
3602
3626
|
* ノードを親要素から削除します。
|
|
@@ -3636,11 +3660,11 @@ const p = class p {
|
|
|
3636
3660
|
return Promise.resolve();
|
|
3637
3661
|
const i = [];
|
|
3638
3662
|
i.push(r.setValue(e));
|
|
3639
|
-
const
|
|
3640
|
-
if (
|
|
3641
|
-
const
|
|
3663
|
+
const n = p.getFormFragment(r);
|
|
3664
|
+
if (n) {
|
|
3665
|
+
const s = b.getValues(n), a = n.getAttribute(`${c.prefix}form-arg`);
|
|
3642
3666
|
let o;
|
|
3643
|
-
a ? (o =
|
|
3667
|
+
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(p.setBindingData(n.getTarget(), o));
|
|
3644
3668
|
}
|
|
3645
3669
|
return Promise.all(i).then(() => {
|
|
3646
3670
|
});
|
|
@@ -3665,14 +3689,14 @@ const p = class p {
|
|
|
3665
3689
|
*/
|
|
3666
3690
|
static evaluateAll(t) {
|
|
3667
3691
|
const e = [];
|
|
3668
|
-
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${
|
|
3692
|
+
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${c.prefix}if`) && e.push(p.evaluateIf(t)), t.hasAttribute(`${c.prefix}each`) ? Promise.all(e).then(() => p.evaluateEach(t)).then(() => {
|
|
3669
3693
|
const r = [];
|
|
3670
3694
|
return t.getChildren().forEach((i) => {
|
|
3671
|
-
i instanceof
|
|
3695
|
+
i instanceof x ? r.push(p.evaluateAll(i)) : i instanceof H && r.push(p.evaluateText(i));
|
|
3672
3696
|
}), Promise.all(r).then(() => {
|
|
3673
3697
|
});
|
|
3674
3698
|
}) : (t.getChildren().forEach((r) => {
|
|
3675
|
-
r instanceof
|
|
3699
|
+
r instanceof x ? e.push(p.evaluateAll(r)) : r instanceof H && e.push(p.evaluateText(r));
|
|
3676
3700
|
}), Promise.all(e).then(() => {
|
|
3677
3701
|
}));
|
|
3678
3702
|
}
|
|
@@ -3693,7 +3717,7 @@ const p = class p {
|
|
|
3693
3717
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3694
3718
|
*/
|
|
3695
3719
|
static evaluateIf(t) {
|
|
3696
|
-
const e = [], r = t.getAttribute(`${
|
|
3720
|
+
const e = [], r = t.getAttribute(`${c.prefix}if`);
|
|
3697
3721
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3698
3722
|
t.hide().then(() => {
|
|
3699
3723
|
w.hide(t.getTarget());
|
|
@@ -3717,20 +3741,20 @@ const p = class p {
|
|
|
3717
3741
|
let e = t.getTemplate();
|
|
3718
3742
|
if (e === null) {
|
|
3719
3743
|
let i = !1;
|
|
3720
|
-
t.getChildren().forEach((
|
|
3721
|
-
if (!i &&
|
|
3722
|
-
if (
|
|
3744
|
+
t.getChildren().forEach((s) => {
|
|
3745
|
+
if (!i && s instanceof x) {
|
|
3746
|
+
if (s.hasAttribute(`${c.prefix}each-before`) || s.hasAttribute(`${c.prefix}each-after`))
|
|
3723
3747
|
return;
|
|
3724
|
-
e =
|
|
3725
|
-
const a =
|
|
3726
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3748
|
+
e = s.clone(), t.setTemplate(e), i = !0, t.removeChild(s);
|
|
3749
|
+
const a = s.getTarget();
|
|
3750
|
+
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3727
3751
|
}
|
|
3728
3752
|
});
|
|
3729
|
-
const
|
|
3730
|
-
return Array.isArray(
|
|
3753
|
+
const n = t.getAttribute(`${c.prefix}each`);
|
|
3754
|
+
return Array.isArray(n) ? this.updateDiff(t, n) : (d.error("[Haori]", "Invalid each attribute:", n), Promise.reject(new Error("Invalid each attribute.")));
|
|
3731
3755
|
}
|
|
3732
|
-
const r = t.getAttribute(`${
|
|
3733
|
-
return Array.isArray(r) ? this.updateDiff(t, r) : (
|
|
3756
|
+
const r = t.getAttribute(`${c.prefix}each`);
|
|
3757
|
+
return Array.isArray(r) ? this.updateDiff(t, r) : (d.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3734
3758
|
}
|
|
3735
3759
|
/**
|
|
3736
3760
|
* 差分を更新します。
|
|
@@ -3741,27 +3765,27 @@ const p = class p {
|
|
|
3741
3765
|
static updateDiff(t, e) {
|
|
3742
3766
|
const r = t.getTemplate();
|
|
3743
3767
|
if (r === null)
|
|
3744
|
-
return
|
|
3745
|
-
let i = t.getAttribute(`${
|
|
3768
|
+
return d.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3769
|
+
let i = t.getAttribute(`${c.prefix}each-index`);
|
|
3746
3770
|
i && (i = String(i));
|
|
3747
|
-
const
|
|
3748
|
-
e.forEach((
|
|
3771
|
+
const n = t.getAttribute(`${c.prefix}each-key`), s = t.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3772
|
+
e.forEach((h, f) => {
|
|
3749
3773
|
const g = p.createListKey(
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3774
|
+
h,
|
|
3775
|
+
n ? String(n) : null,
|
|
3776
|
+
f
|
|
3753
3777
|
);
|
|
3754
|
-
o.push(g), a.set(g, { item:
|
|
3778
|
+
o.push(g), a.set(g, { item: h, itemIndex: f });
|
|
3755
3779
|
});
|
|
3756
|
-
const
|
|
3757
|
-
let m = t.getChildren().filter((
|
|
3758
|
-
(
|
|
3780
|
+
const u = [];
|
|
3781
|
+
let m = t.getChildren().filter((h) => h instanceof x).filter(
|
|
3782
|
+
(h) => !h.hasAttribute(`${c.prefix}each-before`) && !h.hasAttribute(`${c.prefix}each-after`)
|
|
3759
3783
|
);
|
|
3760
|
-
m = m.filter((
|
|
3761
|
-
const y = m.map((
|
|
3784
|
+
m = m.filter((h) => o.indexOf(String(h.getListKey())) === -1 ? (u.push(h.remove()), !1) : !0);
|
|
3785
|
+
const y = m.map((h) => h.getListKey()), E = t.getChildren().filter((h) => h instanceof x).filter((h) => h.hasAttribute(`${c.prefix}each-before`)).length;
|
|
3762
3786
|
let S = Promise.resolve();
|
|
3763
|
-
return o.forEach((
|
|
3764
|
-
const g = y.indexOf(
|
|
3787
|
+
return o.forEach((h, f) => {
|
|
3788
|
+
const g = y.indexOf(h), { item: A, itemIndex: v } = a.get(h);
|
|
3765
3789
|
let k;
|
|
3766
3790
|
if (g !== -1)
|
|
3767
3791
|
k = m[g], S = S.then(
|
|
@@ -3770,44 +3794,44 @@ const p = class p {
|
|
|
3770
3794
|
A,
|
|
3771
3795
|
i,
|
|
3772
3796
|
v,
|
|
3773
|
-
|
|
3774
|
-
|
|
3797
|
+
s ? String(s) : null,
|
|
3798
|
+
h
|
|
3775
3799
|
).then(() => p.evaluateAll(k))
|
|
3776
3800
|
);
|
|
3777
3801
|
else {
|
|
3778
3802
|
k = r.clone();
|
|
3779
|
-
const
|
|
3803
|
+
const W = E + f;
|
|
3780
3804
|
S = S.then(
|
|
3781
3805
|
() => p.updateRowFragment(
|
|
3782
3806
|
k,
|
|
3783
3807
|
A,
|
|
3784
3808
|
i,
|
|
3785
3809
|
v,
|
|
3786
|
-
|
|
3787
|
-
|
|
3810
|
+
s ? String(s) : null,
|
|
3811
|
+
h
|
|
3788
3812
|
).then(
|
|
3789
3813
|
() => t.insertBefore(
|
|
3790
3814
|
k,
|
|
3791
|
-
t.getChildren()[
|
|
3815
|
+
t.getChildren()[W] || null
|
|
3792
3816
|
).then(() => p.evaluateAll(k))
|
|
3793
3817
|
)
|
|
3794
3818
|
);
|
|
3795
3819
|
}
|
|
3796
|
-
}), Promise.all(
|
|
3797
|
-
const
|
|
3820
|
+
}), Promise.all(u).then(() => S).then(() => {
|
|
3821
|
+
const h = o.filter(
|
|
3798
3822
|
(v) => v !== null
|
|
3799
|
-
),
|
|
3823
|
+
), f = y.filter(
|
|
3800
3824
|
(v) => v !== null
|
|
3801
|
-
), g =
|
|
3825
|
+
), g = h.filter(
|
|
3826
|
+
(v) => !f.includes(v)
|
|
3827
|
+
), A = f.filter(
|
|
3802
3828
|
(v) => !h.includes(v)
|
|
3803
|
-
), A = h.filter(
|
|
3804
|
-
(v) => !u.includes(v)
|
|
3805
3829
|
);
|
|
3806
3830
|
w.eachUpdate(
|
|
3807
3831
|
t.getTarget(),
|
|
3808
3832
|
g,
|
|
3809
3833
|
A,
|
|
3810
|
-
|
|
3834
|
+
h
|
|
3811
3835
|
);
|
|
3812
3836
|
});
|
|
3813
3837
|
}
|
|
@@ -3823,8 +3847,8 @@ const p = class p {
|
|
|
3823
3847
|
let i;
|
|
3824
3848
|
if (typeof t == "object" && t !== null)
|
|
3825
3849
|
if (e) {
|
|
3826
|
-
const
|
|
3827
|
-
|
|
3850
|
+
const n = t[e];
|
|
3851
|
+
n == null ? i = `__index_${r}` : typeof n == "object" ? i = JSON.stringify(n) : i = String(n);
|
|
3828
3852
|
} else
|
|
3829
3853
|
i = `__index_${r}`;
|
|
3830
3854
|
else
|
|
@@ -3842,22 +3866,22 @@ const p = class p {
|
|
|
3842
3866
|
* @param listKey リストキー
|
|
3843
3867
|
* @returns 行メタデータの更新完了 Promise
|
|
3844
3868
|
*/
|
|
3845
|
-
static updateRowFragment(t, e, r, i,
|
|
3869
|
+
static updateRowFragment(t, e, r, i, n, s) {
|
|
3846
3870
|
let a = e;
|
|
3847
3871
|
if (typeof e == "object" && e !== null)
|
|
3848
|
-
a = { ...e }, r && (a[r] = i),
|
|
3849
|
-
[
|
|
3872
|
+
a = { ...e }, r && (a[r] = i), n && (a = {
|
|
3873
|
+
[n]: a
|
|
3850
3874
|
});
|
|
3851
|
-
else if (
|
|
3875
|
+
else if (n)
|
|
3852
3876
|
a = {
|
|
3853
|
-
[
|
|
3877
|
+
[n]: e
|
|
3854
3878
|
}, r && (a[r] = i);
|
|
3855
3879
|
else
|
|
3856
|
-
return
|
|
3880
|
+
return d.error(
|
|
3857
3881
|
"[Haori]",
|
|
3858
|
-
`Primitive value requires '${
|
|
3882
|
+
`Primitive value requires '${c.prefix}each-arg' attribute: ${e}`
|
|
3859
3883
|
), Promise.resolve();
|
|
3860
|
-
return t.setListKey(
|
|
3884
|
+
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${c.prefix}row`, s);
|
|
3861
3885
|
}
|
|
3862
3886
|
};
|
|
3863
3887
|
p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], p.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
@@ -3868,8 +3892,8 @@ p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if
|
|
|
3868
3892
|
"import",
|
|
3869
3893
|
"url-param"
|
|
3870
3894
|
], p.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3871
|
-
let
|
|
3872
|
-
class
|
|
3895
|
+
let R = p;
|
|
3896
|
+
const X = class X {
|
|
3873
3897
|
/**
|
|
3874
3898
|
* コンストラクタ。
|
|
3875
3899
|
*
|
|
@@ -3879,20 +3903,23 @@ class ht {
|
|
|
3879
3903
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
3880
3904
|
const e = document.documentElement, r = T.get(e);
|
|
3881
3905
|
r && new V(r, "load").run();
|
|
3906
|
+
}, this.onPopstate = (e) => {
|
|
3907
|
+
const r = e.state;
|
|
3908
|
+
!r || r[X.HISTORY_STATE_KEY] !== !0 || location.reload();
|
|
3882
3909
|
}, this.root = t;
|
|
3883
3910
|
}
|
|
3884
3911
|
/**
|
|
3885
3912
|
* イベントリスナーの登録を開始します。
|
|
3886
|
-
*
|
|
3913
|
+
* クリック、変更、ロード、popstate イベントを監視し、対応するProcedureを実行します。
|
|
3887
3914
|
*/
|
|
3888
3915
|
start() {
|
|
3889
|
-
this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 });
|
|
3916
|
+
this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 }), window.addEventListener("popstate", this.onPopstate);
|
|
3890
3917
|
}
|
|
3891
3918
|
/**
|
|
3892
3919
|
* イベントリスナーの登録を停止します。
|
|
3893
3920
|
*/
|
|
3894
3921
|
stop() {
|
|
3895
|
-
this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad);
|
|
3922
|
+
this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad), window.removeEventListener("popstate", this.onPopstate);
|
|
3896
3923
|
}
|
|
3897
3924
|
/**
|
|
3898
3925
|
* イベントを処理し、対応するProcedureを実行します。
|
|
@@ -3905,8 +3932,8 @@ class ht {
|
|
|
3905
3932
|
if (!r)
|
|
3906
3933
|
return;
|
|
3907
3934
|
const i = T.get(r);
|
|
3908
|
-
i && (e === "change" && i instanceof
|
|
3909
|
-
|
|
3935
|
+
i && (e === "change" && i instanceof x && i.syncValue(), new V(i, e).run().catch((n) => {
|
|
3936
|
+
d.error("[Haori]", "Procedure execution error:", n);
|
|
3910
3937
|
}));
|
|
3911
3938
|
}
|
|
3912
3939
|
/**
|
|
@@ -3918,7 +3945,9 @@ class ht {
|
|
|
3918
3945
|
getElementFromTarget(t) {
|
|
3919
3946
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3920
3947
|
}
|
|
3921
|
-
}
|
|
3948
|
+
};
|
|
3949
|
+
X.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
3950
|
+
let Q = X;
|
|
3922
3951
|
const N = class N {
|
|
3923
3952
|
static syncTree(t) {
|
|
3924
3953
|
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && N.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
@@ -3933,23 +3962,23 @@ const N = class N {
|
|
|
3933
3962
|
}
|
|
3934
3963
|
if (typeof IntersectionObserver > "u")
|
|
3935
3964
|
return;
|
|
3936
|
-
const i = N.resolveRoot(r),
|
|
3937
|
-
if (e && e.observer.root === i && e.observer.rootMargin ===
|
|
3965
|
+
const i = N.resolveRoot(r), n = N.resolveRootMargin(r), s = N.resolveThreshold(r), a = r.hasAttribute(`${c.prefix}intersect-once`);
|
|
3966
|
+
if (e && e.observer.root === i && e.observer.rootMargin === n && N.sameThreshold(
|
|
3938
3967
|
e.observer.thresholds,
|
|
3939
|
-
|
|
3968
|
+
s
|
|
3940
3969
|
) && e.once === a) {
|
|
3941
3970
|
e.fragment = r;
|
|
3942
3971
|
return;
|
|
3943
3972
|
}
|
|
3944
3973
|
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3945
3974
|
const o = new IntersectionObserver(
|
|
3946
|
-
(
|
|
3975
|
+
(u) => {
|
|
3947
3976
|
const m = N.registrations.get(t);
|
|
3948
|
-
m &&
|
|
3977
|
+
m && u.forEach((y) => {
|
|
3949
3978
|
!y.isIntersecting || m.running || N.isDisabled(m.fragment) || (m.running = !0, new V(m.fragment, "intersect").runWithResult().then((E) => {
|
|
3950
3979
|
E && m.once && (m.observer.disconnect(), N.registrations.delete(t));
|
|
3951
3980
|
}).catch((E) => {
|
|
3952
|
-
|
|
3981
|
+
d.error(
|
|
3953
3982
|
"[Haori]",
|
|
3954
3983
|
"Intersect procedure execution error:",
|
|
3955
3984
|
E
|
|
@@ -3962,8 +3991,8 @@ const N = class N {
|
|
|
3962
3991
|
},
|
|
3963
3992
|
{
|
|
3964
3993
|
root: i,
|
|
3965
|
-
rootMargin:
|
|
3966
|
-
threshold:
|
|
3994
|
+
rootMargin: n,
|
|
3995
|
+
threshold: s
|
|
3967
3996
|
}
|
|
3968
3997
|
);
|
|
3969
3998
|
o.observe(t), N.registrations.set(t, {
|
|
@@ -3990,32 +4019,32 @@ const N = class N {
|
|
|
3990
4019
|
}
|
|
3991
4020
|
static shouldObserve(t) {
|
|
3992
4021
|
return t.getAttributeNames().some((e) => {
|
|
3993
|
-
if (!e.startsWith(`${
|
|
4022
|
+
if (!e.startsWith(`${c.prefix}intersect-`))
|
|
3994
4023
|
return !1;
|
|
3995
|
-
const r = e.slice(`${
|
|
4024
|
+
const r = e.slice(`${c.prefix}intersect-`.length);
|
|
3996
4025
|
return !N.CONFIG_KEYS.has(r);
|
|
3997
4026
|
});
|
|
3998
4027
|
}
|
|
3999
4028
|
static resolveRoot(t) {
|
|
4000
|
-
const e = `${
|
|
4029
|
+
const e = `${c.prefix}intersect-root`;
|
|
4001
4030
|
if (!t.hasAttribute(e))
|
|
4002
4031
|
return null;
|
|
4003
4032
|
const r = t.getAttribute(e);
|
|
4004
4033
|
if (typeof r != "string" || r.trim() === "")
|
|
4005
4034
|
return null;
|
|
4006
4035
|
const i = document.querySelector(r);
|
|
4007
|
-
return i instanceof HTMLElement ? i : (
|
|
4036
|
+
return i instanceof HTMLElement ? i : (d.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
4008
4037
|
}
|
|
4009
4038
|
static resolveRootMargin(t) {
|
|
4010
|
-
const e = `${
|
|
4039
|
+
const e = `${c.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
4011
4040
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
4012
4041
|
}
|
|
4013
4042
|
static resolveThreshold(t) {
|
|
4014
|
-
const e = `${
|
|
4043
|
+
const e = `${c.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
4015
4044
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
4016
4045
|
}
|
|
4017
4046
|
static isDisabled(t) {
|
|
4018
|
-
const e = `${
|
|
4047
|
+
const e = `${c.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
4019
4048
|
if (r === null || r === !1)
|
|
4020
4049
|
return !1;
|
|
4021
4050
|
if (typeof r == "boolean")
|
|
@@ -4034,7 +4063,7 @@ N.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
4034
4063
|
"disabled",
|
|
4035
4064
|
"once"
|
|
4036
4065
|
]), N.registrations = /* @__PURE__ */ new Map();
|
|
4037
|
-
let
|
|
4066
|
+
let $ = N;
|
|
4038
4067
|
const I = class I {
|
|
4039
4068
|
/**
|
|
4040
4069
|
* 初期化メソッド。
|
|
@@ -4045,10 +4074,10 @@ const I = class I {
|
|
|
4045
4074
|
return;
|
|
4046
4075
|
I._initialized = !0;
|
|
4047
4076
|
const t = await Promise.allSettled([
|
|
4048
|
-
|
|
4049
|
-
|
|
4077
|
+
R.scan(document.head),
|
|
4078
|
+
R.scan(document.body)
|
|
4050
4079
|
]), [e, r] = t;
|
|
4051
|
-
e.status !== "fulfilled" &&
|
|
4080
|
+
e.status !== "fulfilled" && d.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && d.error("[Haori]", "Failed to build body fragment:", r.reason), I.observe(document.head), I.observe(document.body), new Q().start(), $.syncTree(document.body);
|
|
4052
4081
|
}
|
|
4053
4082
|
/**
|
|
4054
4083
|
* 指定された要素を監視します。
|
|
@@ -4061,45 +4090,45 @@ const I = class I {
|
|
|
4061
4090
|
try {
|
|
4062
4091
|
switch (i.type) {
|
|
4063
4092
|
case "attributes": {
|
|
4064
|
-
|
|
4093
|
+
d.info(
|
|
4065
4094
|
"[Haori]",
|
|
4066
4095
|
"Attribute changed:",
|
|
4067
4096
|
i.target,
|
|
4068
4097
|
i.attributeName
|
|
4069
4098
|
);
|
|
4070
|
-
const
|
|
4071
|
-
if (i.attributeName &&
|
|
4072
|
-
|
|
4099
|
+
const n = i.target;
|
|
4100
|
+
if (i.attributeName && R.isAliasedAttributeReflection(
|
|
4101
|
+
n,
|
|
4073
4102
|
i.attributeName
|
|
4074
4103
|
))
|
|
4075
4104
|
break;
|
|
4076
|
-
|
|
4077
|
-
|
|
4105
|
+
R.setAttribute(
|
|
4106
|
+
n,
|
|
4078
4107
|
i.attributeName,
|
|
4079
|
-
|
|
4080
|
-
),
|
|
4108
|
+
n.getAttribute(i.attributeName)
|
|
4109
|
+
), $.syncElement(n);
|
|
4081
4110
|
break;
|
|
4082
4111
|
}
|
|
4083
4112
|
case "childList": {
|
|
4084
|
-
|
|
4113
|
+
d.info(
|
|
4085
4114
|
"[Haori]",
|
|
4086
4115
|
"Child list changed:",
|
|
4087
|
-
Array.from(i.removedNodes).map((
|
|
4088
|
-
Array.from(i.addedNodes).map((
|
|
4089
|
-
), Array.from(i.removedNodes).forEach((
|
|
4090
|
-
|
|
4091
|
-
}), Array.from(i.addedNodes).forEach((
|
|
4092
|
-
|
|
4116
|
+
Array.from(i.removedNodes).map((n) => n.nodeName),
|
|
4117
|
+
Array.from(i.addedNodes).map((n) => n.nodeName)
|
|
4118
|
+
), Array.from(i.removedNodes).forEach((n) => {
|
|
4119
|
+
$.cleanupTree(n), R.removeNode(n);
|
|
4120
|
+
}), Array.from(i.addedNodes).forEach((n) => {
|
|
4121
|
+
n.parentElement instanceof HTMLElement && (R.addNode(n.parentElement, n), $.syncTree(n));
|
|
4093
4122
|
});
|
|
4094
4123
|
break;
|
|
4095
4124
|
}
|
|
4096
4125
|
case "characterData": {
|
|
4097
|
-
|
|
4126
|
+
d.info(
|
|
4098
4127
|
"[Haori]",
|
|
4099
4128
|
"Character data changed:",
|
|
4100
4129
|
i.target,
|
|
4101
4130
|
i.target.textContent
|
|
4102
|
-
), i.target instanceof Text || i.target instanceof Comment ?
|
|
4131
|
+
), i.target instanceof Text || i.target instanceof Comment ? R.changeText(i.target, i.target.textContent) : d.warn(
|
|
4103
4132
|
"[Haori]",
|
|
4104
4133
|
"Unsupported character data type:",
|
|
4105
4134
|
i.target
|
|
@@ -4107,33 +4136,33 @@ const I = class I {
|
|
|
4107
4136
|
break;
|
|
4108
4137
|
}
|
|
4109
4138
|
default:
|
|
4110
|
-
|
|
4139
|
+
d.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
4111
4140
|
continue;
|
|
4112
4141
|
}
|
|
4113
|
-
} catch (
|
|
4114
|
-
|
|
4142
|
+
} catch (n) {
|
|
4143
|
+
d.error("[Haori]", "Error processing mutation:", n);
|
|
4115
4144
|
}
|
|
4116
4145
|
}).observe(t, {
|
|
4117
4146
|
childList: !0,
|
|
4118
4147
|
subtree: !0,
|
|
4119
4148
|
attributes: !0,
|
|
4120
4149
|
characterData: !0
|
|
4121
|
-
}),
|
|
4150
|
+
}), d.info("[Haori]", "Observer initialized for", t);
|
|
4122
4151
|
}
|
|
4123
4152
|
};
|
|
4124
4153
|
I._initialized = !1;
|
|
4125
4154
|
let q = I;
|
|
4126
4155
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4127
|
-
const
|
|
4156
|
+
const pt = "0.4.3";
|
|
4128
4157
|
export {
|
|
4129
|
-
|
|
4130
|
-
|
|
4158
|
+
R as Core,
|
|
4159
|
+
c as Env,
|
|
4131
4160
|
b as Form,
|
|
4132
4161
|
T as Fragment,
|
|
4133
|
-
|
|
4134
|
-
|
|
4162
|
+
J as Haori,
|
|
4163
|
+
d as Log,
|
|
4135
4164
|
P as Queue,
|
|
4136
|
-
|
|
4137
|
-
|
|
4165
|
+
J as default,
|
|
4166
|
+
pt as version
|
|
4138
4167
|
};
|
|
4139
4168
|
//# sourceMappingURL=haori.es.js.map
|