haori 0.4.5 → 0.4.6
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 +11 -11
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +339 -305
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +9 -9
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/package.json +1 -1
- package/dist/src/expression.d.ts +10 -0
- package/dist/src/expression.d.ts.map +1 -1
- package/dist/src/expression.js +63 -0
- package/dist/src/expression.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/tests/expression.test.js +59 -0
- package/dist/tests/expression.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -95,8 +95,8 @@ const D = class D {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
D._prefix = "data-", D._runtime = z;
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
98
|
+
let u = D;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", u.detect) : u.detect();
|
|
100
100
|
class d {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
@@ -221,15 +221,15 @@ const _ = class _ {
|
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
_.ASYNC_QUEUE = new st();
|
|
224
|
-
let
|
|
225
|
-
class
|
|
224
|
+
let R = _;
|
|
225
|
+
class X {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
228
228
|
*
|
|
229
229
|
* @return 実行モード。
|
|
230
230
|
*/
|
|
231
231
|
static get runtime() {
|
|
232
|
-
return
|
|
232
|
+
return u.runtime;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* 実行モードを設定します。
|
|
@@ -238,7 +238,7 @@ class J {
|
|
|
238
238
|
* @return 戻り値はありません。
|
|
239
239
|
*/
|
|
240
240
|
static setRuntime(t) {
|
|
241
|
-
|
|
241
|
+
u.setRuntime(t);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* 通知ダイアログを表示します。
|
|
@@ -247,7 +247,7 @@ class J {
|
|
|
247
247
|
* @returns 通知が閉じられると解決されるPromise
|
|
248
248
|
*/
|
|
249
249
|
static dialog(t) {
|
|
250
|
-
return
|
|
250
|
+
return R.enqueue(() => {
|
|
251
251
|
window.alert(t);
|
|
252
252
|
}, !0);
|
|
253
253
|
}
|
|
@@ -275,7 +275,7 @@ class J {
|
|
|
275
275
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
276
276
|
*/
|
|
277
277
|
static confirm(t) {
|
|
278
|
-
return
|
|
278
|
+
return R.enqueue(() => window.confirm(t), !0);
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
281
|
* ダイアログを開きます。
|
|
@@ -283,7 +283,7 @@ class J {
|
|
|
283
283
|
* @param element 開くダイアログのHTML要素
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
|
-
return
|
|
286
|
+
return R.enqueue(() => {
|
|
287
287
|
t instanceof HTMLDialogElement ? t.showModal() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
@@ -293,7 +293,7 @@ class J {
|
|
|
293
293
|
* @param element 閉じるダイアログのHTML要素
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
|
-
return
|
|
296
|
+
return R.enqueue(() => {
|
|
297
297
|
t instanceof HTMLDialogElement ? t.close() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
@@ -304,7 +304,7 @@ class J {
|
|
|
304
304
|
* @param message エラーメッセージ
|
|
305
305
|
*/
|
|
306
306
|
static addErrorMessage(t, e) {
|
|
307
|
-
return
|
|
307
|
+
return X.addMessage(t, e, "error");
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* メッセージをレベル付きで追加します。
|
|
@@ -314,7 +314,7 @@ class J {
|
|
|
314
314
|
* @param level メッセージのレベル(省略可能)
|
|
315
315
|
*/
|
|
316
316
|
static addMessage(t, e, r) {
|
|
317
|
-
return
|
|
317
|
+
return R.enqueue(() => {
|
|
318
318
|
const i = t instanceof HTMLFormElement ? t : t.parentElement ?? t;
|
|
319
319
|
i.setAttribute("data-message", e), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
320
320
|
}, !0);
|
|
@@ -325,7 +325,7 @@ class J {
|
|
|
325
325
|
* @param parent メッセージをクリアする親要素
|
|
326
326
|
*/
|
|
327
327
|
static clearMessages(t) {
|
|
328
|
-
return
|
|
328
|
+
return R.enqueue(() => {
|
|
329
329
|
t.removeAttribute("data-message"), t.removeAttribute("data-message-level"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
330
330
|
e.removeAttribute("data-message"), e.removeAttribute("data-message-level");
|
|
331
331
|
});
|
|
@@ -337,9 +337,9 @@ function et() {
|
|
|
337
337
|
const t = globalThis.window?.Haori;
|
|
338
338
|
return nt.every(
|
|
339
339
|
(r) => typeof t?.[r] == "function"
|
|
340
|
-
) ? t :
|
|
340
|
+
) ? t : X;
|
|
341
341
|
}
|
|
342
|
-
class
|
|
342
|
+
class y {
|
|
343
343
|
/**
|
|
344
344
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
345
345
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -350,7 +350,7 @@ class b {
|
|
|
350
350
|
*/
|
|
351
351
|
static getValues(t) {
|
|
352
352
|
const e = {};
|
|
353
|
-
return
|
|
353
|
+
return y.getPartValues(t, e);
|
|
354
354
|
}
|
|
355
355
|
/**
|
|
356
356
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -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(`${u.prefix}form-object`), n = t.getAttribute(`${u.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 ${u.prefix}form-object and name attributes.`
|
|
369
369
|
);
|
|
370
370
|
for (const s of t.getChildElementFragments())
|
|
371
|
-
|
|
371
|
+
y.getPartValues(s, e);
|
|
372
372
|
} else if (i) {
|
|
373
373
|
const s = {};
|
|
374
374
|
for (const a of t.getChildElementFragments())
|
|
375
|
-
|
|
375
|
+
y.getPartValues(a, s);
|
|
376
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 ${u.prefix}form-list and ${u.prefix}form-object attributes.`
|
|
379
379
|
);
|
|
380
380
|
} else if (n) {
|
|
381
381
|
const s = [];
|
|
382
382
|
for (const a of t.getChildElementFragments()) {
|
|
383
383
|
const o = {};
|
|
384
|
-
|
|
384
|
+
y.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
388
|
for (const s of t.getChildElementFragments())
|
|
389
|
-
|
|
389
|
+
y.getPartValues(s, e);
|
|
390
390
|
return e;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
@@ -399,7 +399,7 @@ class b {
|
|
|
399
399
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
400
400
|
*/
|
|
401
401
|
static setValues(t, e, r = !1) {
|
|
402
|
-
return
|
|
402
|
+
return y.setPartValues(t, e, null, r, !0);
|
|
403
403
|
}
|
|
404
404
|
/**
|
|
405
405
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -411,7 +411,7 @@ class b {
|
|
|
411
411
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
412
412
|
*/
|
|
413
413
|
static syncValues(t, e, r = !1) {
|
|
414
|
-
return
|
|
414
|
+
return y.setPartValues(t, e, null, r, !1);
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
417
|
* 単一フラグメントへ値を設定します。
|
|
@@ -434,50 +434,50 @@ class b {
|
|
|
434
434
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
435
435
|
*/
|
|
436
436
|
static setPartValues(t, e, r = null, i = !1, n = !0) {
|
|
437
|
-
const s = [], a = t.getAttribute("name"), o = t.getAttribute(`${
|
|
437
|
+
const s = [], a = t.getAttribute("name"), o = t.getAttribute(`${u.prefix}form-object`), h = t.getAttribute(`${u.prefix}form-list`), m = t.getAttribute(`${u.prefix}form-detach`);
|
|
438
438
|
if (a) {
|
|
439
439
|
if (!m || i) {
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
) : typeof
|
|
444
|
-
|
|
440
|
+
const b = e[String(a)];
|
|
441
|
+
h && Array.isArray(b) && r !== null ? s.push(
|
|
442
|
+
y.applyFragmentValue(t, b[r] ?? null, n)
|
|
443
|
+
) : typeof b > "u" || (typeof b == "string" || typeof b == "number" || typeof b == "boolean" || b === null ? s.push(y.applyFragmentValue(t, b, n)) : s.push(
|
|
444
|
+
y.applyFragmentValue(t, String(b), n)
|
|
445
445
|
));
|
|
446
446
|
}
|
|
447
447
|
} else if (o) {
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
448
|
+
const b = e[String(o)];
|
|
449
|
+
if (b && typeof b == "object")
|
|
450
450
|
for (const E of t.getChildElementFragments())
|
|
451
451
|
s.push(
|
|
452
|
-
|
|
452
|
+
y.setPartValues(
|
|
453
453
|
E,
|
|
454
|
-
|
|
454
|
+
b,
|
|
455
455
|
null,
|
|
456
456
|
i,
|
|
457
457
|
n
|
|
458
458
|
)
|
|
459
459
|
);
|
|
460
|
-
} else if (
|
|
461
|
-
const
|
|
462
|
-
if (Array.isArray(
|
|
460
|
+
} else if (h) {
|
|
461
|
+
const b = e[String(h)];
|
|
462
|
+
if (Array.isArray(b)) {
|
|
463
463
|
const E = t.getChildElementFragments();
|
|
464
464
|
for (let S = 0; S < E.length; S++) {
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
465
|
+
const c = E[S];
|
|
466
|
+
b.length > S ? s.push(
|
|
467
|
+
y.setPartValues(
|
|
468
|
+
c,
|
|
469
|
+
b[S],
|
|
470
470
|
S,
|
|
471
471
|
i,
|
|
472
472
|
n
|
|
473
473
|
)
|
|
474
|
-
) : s.push(
|
|
474
|
+
) : s.push(y.setPartValues(c, {}, S, i, n));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
} else
|
|
478
|
-
for (const
|
|
478
|
+
for (const b of t.getChildElementFragments())
|
|
479
479
|
s.push(
|
|
480
|
-
|
|
480
|
+
y.setPartValues(b, e, null, i, n)
|
|
481
481
|
);
|
|
482
482
|
return Promise.all(s).then(() => {
|
|
483
483
|
});
|
|
@@ -490,10 +490,10 @@ class b {
|
|
|
490
490
|
* @returns すべての初期化処理が完了するPromise
|
|
491
491
|
*/
|
|
492
492
|
static async reset(t) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
]), await
|
|
493
|
+
y.clearValues(t), await Promise.all([
|
|
494
|
+
y.clearMessages(t),
|
|
495
|
+
y.clearEachClones(t)
|
|
496
|
+
]), await R.enqueue(() => {
|
|
497
497
|
const e = t.getTarget();
|
|
498
498
|
if (e instanceof HTMLFormElement)
|
|
499
499
|
e.reset();
|
|
@@ -504,7 +504,7 @@ class b {
|
|
|
504
504
|
n.appendChild(e), n.reset(), r.insertBefore(e, i);
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
}), await
|
|
507
|
+
}), await P.evaluateAll(t);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -514,9 +514,9 @@ class b {
|
|
|
514
514
|
*/
|
|
515
515
|
static clearEachClones(t) {
|
|
516
516
|
const e = [], r = (n) => {
|
|
517
|
-
if (n.hasAttribute(`${
|
|
517
|
+
if (n.hasAttribute(`${u.prefix}each`))
|
|
518
518
|
for (const s of n.getChildElementFragments()) {
|
|
519
|
-
const a = s.hasAttribute(`${
|
|
519
|
+
const a = s.hasAttribute(`${u.prefix}each-before`), o = s.hasAttribute(`${u.prefix}each-after`);
|
|
520
520
|
!a && !o && e.push(s.remove());
|
|
521
521
|
}
|
|
522
522
|
}, i = (n) => {
|
|
@@ -538,7 +538,7 @@ class b {
|
|
|
538
538
|
static clearValues(t) {
|
|
539
539
|
t.clearValue();
|
|
540
540
|
for (const e of t.getChildElementFragments())
|
|
541
|
-
|
|
541
|
+
y.clearValues(e);
|
|
542
542
|
}
|
|
543
543
|
/**
|
|
544
544
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -561,7 +561,7 @@ class b {
|
|
|
561
561
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
562
562
|
*/
|
|
563
563
|
static addErrorMessage(t, e, r) {
|
|
564
|
-
return
|
|
564
|
+
return y.addMessage(t, e, r, "error");
|
|
565
565
|
}
|
|
566
566
|
/**
|
|
567
567
|
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
@@ -574,10 +574,10 @@ class b {
|
|
|
574
574
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
575
575
|
*/
|
|
576
576
|
static addMessage(t, e, r, i) {
|
|
577
|
-
const n = [], s = et(), a = s.addMessage, o = (m) => typeof a == "function" ? a.call(s, m, r, i) : s.addErrorMessage(m, r),
|
|
578
|
-
return
|
|
577
|
+
const n = [], s = et(), a = s.addMessage, o = (m) => typeof a == "function" ? a.call(s, m, r, i) : s.addErrorMessage(m, r), h = y.findFragmentsByKey(t, e);
|
|
578
|
+
return h.forEach((m) => {
|
|
579
579
|
n.push(o(m.getTarget()));
|
|
580
|
-
}),
|
|
580
|
+
}), h.length === 0 && n.push(o(t.getTarget())), Promise.all(n).then(() => {
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
583
|
/**
|
|
@@ -588,7 +588,7 @@ class b {
|
|
|
588
588
|
* @returns 一致するフラグメントの配列
|
|
589
589
|
*/
|
|
590
590
|
static findFragmentsByKey(t, e) {
|
|
591
|
-
return
|
|
591
|
+
return y.findFragmentByKeyParts(t, e.split("."));
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -600,23 +600,23 @@ 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(...
|
|
603
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${u.prefix}form-object`))
|
|
604
|
+
e.length > 1 && t.getAttribute(`${u.prefix}form-object`) === i && t.getChildElementFragments().forEach((s) => {
|
|
605
|
+
r.push(...y.findFragmentByKeyParts(s, e.slice(1)));
|
|
606
606
|
});
|
|
607
|
-
else if (t.hasAttribute(`${
|
|
607
|
+
else if (t.hasAttribute(`${u.prefix}form-list`)) {
|
|
608
608
|
if (e.length > 1) {
|
|
609
|
-
const n = t.getAttribute(`${
|
|
609
|
+
const n = t.getAttribute(`${u.prefix}form-list`), s = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
610
610
|
if (s !== -1 && a !== -1 && s < a) {
|
|
611
611
|
const o = i.substring(0, s);
|
|
612
612
|
if (n === o) {
|
|
613
|
-
const
|
|
613
|
+
const h = i.substring(s + 1, a), m = Number(h);
|
|
614
614
|
if (isNaN(m))
|
|
615
615
|
d.error("Haori", `Invalid index: ${i}`);
|
|
616
616
|
else {
|
|
617
|
-
const
|
|
618
|
-
m <
|
|
619
|
-
...
|
|
617
|
+
const b = t.getChildElementFragments().filter((E) => E.hasAttribute(`${u.prefix}row`));
|
|
618
|
+
m < b.length && r.push(
|
|
619
|
+
...y.findFragmentByKeyParts(b[m], e.slice(1))
|
|
620
620
|
);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
@@ -624,7 +624,7 @@ class b {
|
|
|
624
624
|
}
|
|
625
625
|
} else
|
|
626
626
|
t.getChildElementFragments().forEach((n) => {
|
|
627
|
-
r.push(...
|
|
627
|
+
r.push(...y.findFragmentByKeyParts(n, e));
|
|
628
628
|
});
|
|
629
629
|
return r;
|
|
630
630
|
}
|
|
@@ -753,8 +753,15 @@ return (${t});`;
|
|
|
753
753
|
const r = [];
|
|
754
754
|
let i = null;
|
|
755
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 (
|
|
756
|
+
const s = e[n], a = e[n + 1] || null, o = r[r.length - 1] || null, h = e[n - 2] || null, m = e[n - 3] || null;
|
|
757
|
+
if (this.startsObjectKey(
|
|
758
|
+
o,
|
|
759
|
+
i,
|
|
760
|
+
h,
|
|
761
|
+
m
|
|
762
|
+
) && (s.value === "[" || s.type === "identifier" && this.FORBIDDEN_PROPERTY_NAMES.has(s.value) || s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
763
|
+
this.decodeStringLiteral(s.value)
|
|
764
|
+
)) || s.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(s.value) || this.STRICT_FORBIDDEN_NAMES.includes(s.value) || (i?.value === "." || i?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(s.value)) || o === "member" && s.value !== "]" && s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
758
765
|
this.decodeStringLiteral(s.value)
|
|
759
766
|
) || s.value === "." && a?.type !== "identifier" || s.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
760
767
|
return !1;
|
|
@@ -768,15 +775,23 @@ return (${t});`;
|
|
|
768
775
|
break;
|
|
769
776
|
}
|
|
770
777
|
case "[": {
|
|
771
|
-
const
|
|
772
|
-
r.push(
|
|
778
|
+
const b = this.startsMemberAccess(i) ? "member" : "array";
|
|
779
|
+
r.push(b);
|
|
773
780
|
break;
|
|
774
781
|
}
|
|
782
|
+
case "{":
|
|
783
|
+
r.push("object");
|
|
784
|
+
break;
|
|
775
785
|
case "]": {
|
|
776
786
|
if (r.pop() === void 0)
|
|
777
787
|
return !1;
|
|
778
788
|
break;
|
|
779
789
|
}
|
|
790
|
+
case "}": {
|
|
791
|
+
if (r.pop() !== "object")
|
|
792
|
+
return !1;
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
780
795
|
}
|
|
781
796
|
i = s;
|
|
782
797
|
}
|
|
@@ -804,6 +819,8 @@ return (${t});`;
|
|
|
804
819
|
], i = /* @__PURE__ */ new Set([
|
|
805
820
|
"(",
|
|
806
821
|
")",
|
|
822
|
+
"{",
|
|
823
|
+
"}",
|
|
807
824
|
"[",
|
|
808
825
|
"]",
|
|
809
826
|
".",
|
|
@@ -941,6 +958,16 @@ return (${t});`;
|
|
|
941
958
|
static startsMemberAccess(t) {
|
|
942
959
|
return t === null ? !1 : t.type === "identifier" || t.type === "number" ? !0 : t.value === ")" || t.value === "]" || t.value === "?.";
|
|
943
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* object literal 内で次のトークンがキー位置かどうかを判定します。
|
|
963
|
+
*
|
|
964
|
+
* @param activeGroup 現在のグループ種別
|
|
965
|
+
* @param previous 直前のトークン
|
|
966
|
+
* @returns object literal のキー位置であれば true
|
|
967
|
+
*/
|
|
968
|
+
static startsObjectKey(t, e, r, i) {
|
|
969
|
+
return t !== "object" ? !1 : e?.value === "{" || e?.value === "," || e?.type === "identifier" && this.OBJECT_PROPERTY_MODIFIERS.has(e.value) && (r?.value === "{" || r?.value === ",") ? !0 : e?.value !== "*" ? !1 : r?.value === "{" || r?.value === "," ? !0 : r?.type === "identifier" && r.value === "async" && (i?.value === "{" || i?.value === ",");
|
|
970
|
+
}
|
|
944
971
|
/**
|
|
945
972
|
* 文字列リテラルをプレーン文字列へ変換します。
|
|
946
973
|
*
|
|
@@ -949,6 +976,9 @@ return (${t});`;
|
|
|
949
976
|
*/
|
|
950
977
|
static decodeStringLiteral(t) {
|
|
951
978
|
return t.slice(1, -1).replace(
|
|
979
|
+
/\\u\{([0-9a-fA-F]+)\}/g,
|
|
980
|
+
(e, r) => String.fromCodePoint(parseInt(r, 16))
|
|
981
|
+
).replace(
|
|
952
982
|
/\\u([0-9a-fA-F]{4})/g,
|
|
953
983
|
(e, r) => String.fromCharCode(parseInt(r, 16))
|
|
954
984
|
).replace(
|
|
@@ -1005,9 +1035,9 @@ return (${t});`;
|
|
|
1005
1035
|
get: (s, a, o) => {
|
|
1006
1036
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
1007
1037
|
return;
|
|
1008
|
-
const
|
|
1009
|
-
return typeof a == "symbol" ?
|
|
1010
|
-
|
|
1038
|
+
const h = Reflect.get(s, a, o);
|
|
1039
|
+
return typeof a == "symbol" ? h : this.wrapBoundValue(
|
|
1040
|
+
h,
|
|
1011
1041
|
e
|
|
1012
1042
|
);
|
|
1013
1043
|
},
|
|
@@ -1017,12 +1047,12 @@ return (${t});`;
|
|
|
1017
1047
|
return Reflect.getOwnPropertyDescriptor(s, a);
|
|
1018
1048
|
},
|
|
1019
1049
|
apply: (s, a, o) => {
|
|
1020
|
-
const
|
|
1050
|
+
const h = Reflect.apply(
|
|
1021
1051
|
s,
|
|
1022
1052
|
a,
|
|
1023
1053
|
o
|
|
1024
1054
|
);
|
|
1025
|
-
return this.isIteratorLike(
|
|
1055
|
+
return this.isIteratorLike(h) ? h : this.wrapBoundValue(h, e);
|
|
1026
1056
|
},
|
|
1027
1057
|
construct: (s, a, o) => this.wrapBoundValue(
|
|
1028
1058
|
Reflect.construct(
|
|
@@ -1178,6 +1208,10 @@ M.FORBIDDEN_NAMES = [
|
|
|
1178
1208
|
"constructor",
|
|
1179
1209
|
"__proto__",
|
|
1180
1210
|
"prototype"
|
|
1211
|
+
]), M.OBJECT_PROPERTY_MODIFIERS = /* @__PURE__ */ new Set([
|
|
1212
|
+
"get",
|
|
1213
|
+
"set",
|
|
1214
|
+
"async"
|
|
1181
1215
|
]), M.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1182
1216
|
"await",
|
|
1183
1217
|
"break",
|
|
@@ -1214,20 +1248,20 @@ M.FORBIDDEN_NAMES = [
|
|
|
1214
1248
|
"yield"
|
|
1215
1249
|
]), M.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1216
1250
|
let j = M;
|
|
1217
|
-
const
|
|
1251
|
+
const I = class I {
|
|
1218
1252
|
/**
|
|
1219
1253
|
* フラグメントのコンストラクタ。
|
|
1220
1254
|
*
|
|
1221
1255
|
* @param target 対象ノード
|
|
1222
1256
|
*/
|
|
1223
1257
|
constructor(t) {
|
|
1224
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t,
|
|
1258
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t, I.FRAGMENT_CACHE.set(t, this);
|
|
1225
1259
|
}
|
|
1226
1260
|
static get(t) {
|
|
1227
1261
|
if (t == null)
|
|
1228
1262
|
return null;
|
|
1229
|
-
if (
|
|
1230
|
-
return
|
|
1263
|
+
if (I.FRAGMENT_CACHE.has(t))
|
|
1264
|
+
return I.FRAGMENT_CACHE.get(t);
|
|
1231
1265
|
let e;
|
|
1232
1266
|
switch (t.nodeType) {
|
|
1233
1267
|
case Node.ELEMENT_NODE:
|
|
@@ -1262,7 +1296,7 @@ const C = class C {
|
|
|
1262
1296
|
return Promise.resolve();
|
|
1263
1297
|
if (this.parent) {
|
|
1264
1298
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1265
|
-
return
|
|
1299
|
+
return R.enqueue(() => {
|
|
1266
1300
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1267
1301
|
}).finally(() => {
|
|
1268
1302
|
t.skipMutationNodes = e;
|
|
@@ -1270,7 +1304,7 @@ const C = class C {
|
|
|
1270
1304
|
} else {
|
|
1271
1305
|
const t = this.target.parentNode;
|
|
1272
1306
|
if (t)
|
|
1273
|
-
return
|
|
1307
|
+
return R.enqueue(() => {
|
|
1274
1308
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
1275
1309
|
});
|
|
1276
1310
|
this.mounted = !1;
|
|
@@ -1287,7 +1321,7 @@ const C = class C {
|
|
|
1287
1321
|
return Promise.resolve();
|
|
1288
1322
|
if (this.parent) {
|
|
1289
1323
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1290
|
-
return
|
|
1324
|
+
return R.enqueue(() => {
|
|
1291
1325
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1292
1326
|
}).finally(() => {
|
|
1293
1327
|
t.skipMutationNodes = e;
|
|
@@ -1318,7 +1352,7 @@ const C = class C {
|
|
|
1318
1352
|
* @return 除去のPromise
|
|
1319
1353
|
*/
|
|
1320
1354
|
remove(t = !0) {
|
|
1321
|
-
return this.parent && this.parent.removeChild(this),
|
|
1355
|
+
return this.parent && this.parent.removeChild(this), I.FRAGMENT_CACHE.delete(this.target), t ? this.unmount() : Promise.resolve();
|
|
1322
1356
|
}
|
|
1323
1357
|
/**
|
|
1324
1358
|
* 対象ノードを取得します。
|
|
@@ -1345,8 +1379,8 @@ const C = class C {
|
|
|
1345
1379
|
this.parent = t;
|
|
1346
1380
|
}
|
|
1347
1381
|
};
|
|
1348
|
-
|
|
1349
|
-
let T =
|
|
1382
|
+
I.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1383
|
+
let T = I;
|
|
1350
1384
|
class x extends T {
|
|
1351
1385
|
/**
|
|
1352
1386
|
* エレメントフラグメントのコンストラクタ。
|
|
@@ -1566,12 +1600,12 @@ class x extends T {
|
|
|
1566
1600
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1567
1601
|
const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
|
|
1568
1602
|
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,
|
|
1603
|
+
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, R.enqueue(() => {
|
|
1570
1604
|
r.checked = s, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1571
1605
|
}).finally(() => {
|
|
1572
1606
|
this.skipChangeValue = !1;
|
|
1573
1607
|
}));
|
|
1574
|
-
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0,
|
|
1608
|
+
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, R.enqueue(() => {
|
|
1575
1609
|
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
1610
|
}).finally(() => {
|
|
1577
1611
|
this.skipChangeValue = !1;
|
|
@@ -1651,7 +1685,7 @@ class x extends T {
|
|
|
1651
1685
|
return Promise.resolve();
|
|
1652
1686
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1653
1687
|
const r = this.getTarget();
|
|
1654
|
-
return
|
|
1688
|
+
return R.enqueue(() => {
|
|
1655
1689
|
r.removeAttribute(t), e !== t && r.removeAttribute(e);
|
|
1656
1690
|
}).finally(() => {
|
|
1657
1691
|
this.skipMutationAttributes = !1;
|
|
@@ -1674,7 +1708,7 @@ class x extends T {
|
|
|
1674
1708
|
const n = new U(t, r);
|
|
1675
1709
|
this.attributeMap.set(t, n), this.skipMutationAttributes = !0;
|
|
1676
1710
|
const s = this.getTarget(), a = n.isForceEvaluation() ? r : this.getAttribute(t);
|
|
1677
|
-
return
|
|
1711
|
+
return R.enqueue(() => {
|
|
1678
1712
|
if (s.getAttribute(t) !== r && s.setAttribute(t, r), a === null || a === !1)
|
|
1679
1713
|
s.removeAttribute(e);
|
|
1680
1714
|
else {
|
|
@@ -1696,7 +1730,7 @@ class x extends T {
|
|
|
1696
1730
|
return Promise.resolve();
|
|
1697
1731
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1698
1732
|
const e = this.getTarget();
|
|
1699
|
-
return
|
|
1733
|
+
return R.enqueue(() => {
|
|
1700
1734
|
e.removeAttribute(t);
|
|
1701
1735
|
}).finally(() => {
|
|
1702
1736
|
this.skipMutationAttributes = !1;
|
|
@@ -1789,8 +1823,8 @@ class x extends T {
|
|
|
1789
1823
|
const s = t.getParent() === this;
|
|
1790
1824
|
let a = -1, o = -1;
|
|
1791
1825
|
s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1826
|
+
const h = t.getParent();
|
|
1827
|
+
h !== null && h.removeChild(t);
|
|
1794
1828
|
let m = r === void 0 ? e?.getTarget() || null : r;
|
|
1795
1829
|
if (e === null)
|
|
1796
1830
|
this.children.push(t);
|
|
@@ -1810,11 +1844,11 @@ class x extends T {
|
|
|
1810
1844
|
this.children.splice(E, 0, t);
|
|
1811
1845
|
}
|
|
1812
1846
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1813
|
-
const
|
|
1814
|
-
return this.skipMutationNodes = !0,
|
|
1847
|
+
const b = this.skipMutationNodes;
|
|
1848
|
+
return this.skipMutationNodes = !0, R.enqueue(() => {
|
|
1815
1849
|
this.target.insertBefore(t.getTarget(), m);
|
|
1816
1850
|
}).finally(() => {
|
|
1817
|
-
this.skipMutationNodes =
|
|
1851
|
+
this.skipMutationNodes = b;
|
|
1818
1852
|
});
|
|
1819
1853
|
}
|
|
1820
1854
|
/**
|
|
@@ -1885,7 +1919,7 @@ class x extends T {
|
|
|
1885
1919
|
* @returns エレメントの非表示のPromise
|
|
1886
1920
|
*/
|
|
1887
1921
|
hide() {
|
|
1888
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1922
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${u.prefix}if-false`, ""), Promise.resolve();
|
|
1889
1923
|
}
|
|
1890
1924
|
/**
|
|
1891
1925
|
* エレメントを表示します。
|
|
@@ -1893,7 +1927,7 @@ class x extends T {
|
|
|
1893
1927
|
* @return エレメントの表示のPromise
|
|
1894
1928
|
*/
|
|
1895
1929
|
show() {
|
|
1896
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1930
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${u.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1897
1931
|
}
|
|
1898
1932
|
/**
|
|
1899
1933
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1953,7 +1987,7 @@ class H extends T {
|
|
|
1953
1987
|
evaluate() {
|
|
1954
1988
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1955
1989
|
new Error("Parent fragment is required for raw evaluation")
|
|
1956
|
-
) :
|
|
1990
|
+
) : R.enqueue(() => {
|
|
1957
1991
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1958
1992
|
this.parent.getBindingData()
|
|
1959
1993
|
)[0] : this.contents.isEvaluate ? this.target.textContent = L.joinEvaluateResults(
|
|
@@ -1998,7 +2032,7 @@ class Z extends T {
|
|
|
1998
2032
|
* @return 更新のPromise
|
|
1999
2033
|
*/
|
|
2000
2034
|
setContent(t) {
|
|
2001
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
2035
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, R.enqueue(() => {
|
|
2002
2036
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
2003
2037
|
}).finally(() => {
|
|
2004
2038
|
this.skipMutation = !1;
|
|
@@ -2227,9 +2261,9 @@ class w {
|
|
|
2227
2261
|
*/
|
|
2228
2262
|
static bindChange(t, e, r, i = "other") {
|
|
2229
2263
|
const n = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
|
|
2230
|
-
for (const
|
|
2231
|
-
const m = e?.[
|
|
2232
|
-
m !==
|
|
2264
|
+
for (const h of o) {
|
|
2265
|
+
const m = e?.[h], b = r[h];
|
|
2266
|
+
m !== b && n.push(h);
|
|
2233
2267
|
}
|
|
2234
2268
|
w.dispatch(t, "bindchange", {
|
|
2235
2269
|
previous: e || {},
|
|
@@ -2362,17 +2396,17 @@ const at = [
|
|
|
2362
2396
|
"openDialog",
|
|
2363
2397
|
"toast"
|
|
2364
2398
|
], ot = "__haoriHistoryState__";
|
|
2365
|
-
function
|
|
2399
|
+
function W() {
|
|
2366
2400
|
const t = globalThis.window?.Haori;
|
|
2367
2401
|
return at.every(
|
|
2368
2402
|
(r) => typeof t?.[r] == "function"
|
|
2369
|
-
) ? t :
|
|
2403
|
+
) ? t : X;
|
|
2370
2404
|
}
|
|
2371
2405
|
const lt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2372
|
-
function
|
|
2406
|
+
function ut(F) {
|
|
2373
2407
|
return lt.has(F.toUpperCase());
|
|
2374
2408
|
}
|
|
2375
|
-
function
|
|
2409
|
+
function ct(F, t) {
|
|
2376
2410
|
for (const [e, r] of Object.entries(t))
|
|
2377
2411
|
r !== void 0 && (r === null ? F.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2378
2412
|
F.append(e, String(i));
|
|
@@ -2380,7 +2414,7 @@ function ut(F, t) {
|
|
|
2380
2414
|
}
|
|
2381
2415
|
function ht(F, t) {
|
|
2382
2416
|
const e = new URL(F, window.location.href), r = new URLSearchParams(e.search);
|
|
2383
|
-
return
|
|
2417
|
+
return ct(r, t), e.search = r.toString(), e.toString();
|
|
2384
2418
|
}
|
|
2385
2419
|
const l = class l {
|
|
2386
2420
|
/**
|
|
@@ -2391,7 +2425,7 @@ const l = class l {
|
|
|
2391
2425
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2392
2426
|
*/
|
|
2393
2427
|
static attrName(t, e, r = !1) {
|
|
2394
|
-
return t ? `${
|
|
2428
|
+
return t ? `${u.prefix}${t}-${e}` : r ? `${u.prefix}fetch-${e}` : `${u.prefix}${e}`;
|
|
2395
2429
|
}
|
|
2396
2430
|
/**
|
|
2397
2431
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2495,12 +2529,12 @@ const l = class l {
|
|
|
2495
2529
|
if (typeof i != "string" || r === null)
|
|
2496
2530
|
return null;
|
|
2497
2531
|
const n = r.trim();
|
|
2498
|
-
return l.SINGLE_PLACEHOLDER_REGEX.test(n) ?
|
|
2532
|
+
return l.SINGLE_PLACEHOLDER_REGEX.test(n) ? P.parseDataBind(i) : n.startsWith("{") || n.startsWith("[") ? P.parseDataBind(
|
|
2499
2533
|
l.resolveDataJsonString(
|
|
2500
2534
|
r,
|
|
2501
2535
|
t.getBindingData()
|
|
2502
2536
|
)
|
|
2503
|
-
) :
|
|
2537
|
+
) : P.parseDataBind(
|
|
2504
2538
|
l.resolveDataParamString(r, t.getBindingData())
|
|
2505
2539
|
);
|
|
2506
2540
|
}
|
|
@@ -2523,23 +2557,23 @@ const l = class l {
|
|
|
2523
2557
|
t,
|
|
2524
2558
|
l.attrName(e, "data")
|
|
2525
2559
|
)), t.hasAttribute(l.attrName(e, "form"))) {
|
|
2526
|
-
const
|
|
2560
|
+
const c = t.getRawAttribute(
|
|
2527
2561
|
l.attrName(e, "form")
|
|
2528
2562
|
);
|
|
2529
|
-
if (
|
|
2530
|
-
const f = document.body.querySelector(
|
|
2531
|
-
f !== null ? r.formFragment =
|
|
2563
|
+
if (c) {
|
|
2564
|
+
const f = document.body.querySelector(c);
|
|
2565
|
+
f !== null ? r.formFragment = y.getFormFragment(
|
|
2532
2566
|
T.get(f)
|
|
2533
2567
|
) : d.error(
|
|
2534
2568
|
"Haori",
|
|
2535
|
-
`Form element not found: ${
|
|
2569
|
+
`Form element not found: ${c} (${l.attrName(e, "form")})`
|
|
2536
2570
|
);
|
|
2537
2571
|
} else
|
|
2538
|
-
r.formFragment =
|
|
2539
|
-
} else e === "change" && (r.formFragment =
|
|
2540
|
-
if (t.hasAttribute(`${
|
|
2541
|
-
const
|
|
2542
|
-
`${
|
|
2572
|
+
r.formFragment = y.getFormFragment(t);
|
|
2573
|
+
} else e === "change" && (r.formFragment = y.getFormFragment(t));
|
|
2574
|
+
if (t.hasAttribute(`${u.prefix}${e}-before-run`)) {
|
|
2575
|
+
const c = t.getRawAttribute(
|
|
2576
|
+
`${u.prefix}${e}-before-run`
|
|
2543
2577
|
);
|
|
2544
2578
|
try {
|
|
2545
2579
|
r.beforeCallback = new Function(
|
|
@@ -2547,7 +2581,7 @@ const l = class l {
|
|
|
2547
2581
|
"fetchOptions",
|
|
2548
2582
|
`
|
|
2549
2583
|
"use strict";
|
|
2550
|
-
${
|
|
2584
|
+
${c}
|
|
2551
2585
|
`
|
|
2552
2586
|
);
|
|
2553
2587
|
} catch (f) {
|
|
@@ -2559,54 +2593,54 @@ ${h}
|
|
|
2559
2593
|
n && (r.fetchUrl = t.getAttribute(i));
|
|
2560
2594
|
const s = {};
|
|
2561
2595
|
if (e) {
|
|
2562
|
-
const
|
|
2563
|
-
t.hasAttribute(
|
|
2564
|
-
|
|
2596
|
+
const c = l.attrName(e, "fetch-method");
|
|
2597
|
+
t.hasAttribute(c) && (s.method = t.getAttribute(
|
|
2598
|
+
c
|
|
2565
2599
|
));
|
|
2566
2600
|
} else {
|
|
2567
|
-
const
|
|
2568
|
-
t.hasAttribute(
|
|
2569
|
-
|
|
2601
|
+
const c = l.attrName(null, "method", !0);
|
|
2602
|
+
t.hasAttribute(c) && (s.method = t.getAttribute(
|
|
2603
|
+
c
|
|
2570
2604
|
));
|
|
2571
2605
|
}
|
|
2572
2606
|
if (e) {
|
|
2573
|
-
const
|
|
2574
|
-
if (t.hasAttribute(
|
|
2607
|
+
const c = l.attrName(e, "fetch-headers");
|
|
2608
|
+
if (t.hasAttribute(c)) {
|
|
2575
2609
|
const f = t.getRawAttribute(
|
|
2576
|
-
|
|
2610
|
+
c
|
|
2577
2611
|
);
|
|
2578
2612
|
try {
|
|
2579
|
-
s.headers =
|
|
2613
|
+
s.headers = P.parseDataBind(f);
|
|
2580
2614
|
} catch (g) {
|
|
2581
2615
|
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2582
2616
|
}
|
|
2583
2617
|
}
|
|
2584
2618
|
} else {
|
|
2585
|
-
const
|
|
2619
|
+
const c = l.attrName(
|
|
2586
2620
|
null,
|
|
2587
2621
|
"headers",
|
|
2588
2622
|
!0
|
|
2589
2623
|
);
|
|
2590
|
-
if (t.hasAttribute(
|
|
2624
|
+
if (t.hasAttribute(c)) {
|
|
2591
2625
|
const f = t.getRawAttribute(
|
|
2592
|
-
|
|
2626
|
+
c
|
|
2593
2627
|
);
|
|
2594
2628
|
try {
|
|
2595
|
-
s.headers =
|
|
2629
|
+
s.headers = P.parseDataBind(f);
|
|
2596
2630
|
} catch (g) {
|
|
2597
2631
|
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2598
2632
|
}
|
|
2599
2633
|
}
|
|
2600
2634
|
}
|
|
2601
2635
|
if (e) {
|
|
2602
|
-
const
|
|
2636
|
+
const c = l.attrName(
|
|
2603
2637
|
e,
|
|
2604
2638
|
"fetch-content-type"
|
|
2605
2639
|
);
|
|
2606
|
-
if (t.hasAttribute(
|
|
2640
|
+
if (t.hasAttribute(c))
|
|
2607
2641
|
s.headers = {
|
|
2608
2642
|
...s.headers,
|
|
2609
|
-
"Content-Type": t.getAttribute(
|
|
2643
|
+
"Content-Type": t.getAttribute(c)
|
|
2610
2644
|
};
|
|
2611
2645
|
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2612
2646
|
let f = !1;
|
|
@@ -2619,15 +2653,15 @@ ${h}
|
|
|
2619
2653
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2620
2654
|
});
|
|
2621
2655
|
} else {
|
|
2622
|
-
const
|
|
2656
|
+
const c = l.attrName(
|
|
2623
2657
|
null,
|
|
2624
2658
|
"content-type",
|
|
2625
2659
|
!0
|
|
2626
2660
|
);
|
|
2627
|
-
if (t.hasAttribute(
|
|
2661
|
+
if (t.hasAttribute(c))
|
|
2628
2662
|
s.headers = {
|
|
2629
2663
|
...s.headers,
|
|
2630
|
-
"Content-Type": t.getAttribute(
|
|
2664
|
+
"Content-Type": t.getAttribute(c)
|
|
2631
2665
|
};
|
|
2632
2666
|
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2633
2667
|
let f = !1;
|
|
@@ -2643,19 +2677,19 @@ ${h}
|
|
|
2643
2677
|
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2644
2678
|
const a = e ? l.attrName(e, "bind") : l.attrName(null, "bind", !0);
|
|
2645
2679
|
if (t.hasAttribute(a)) {
|
|
2646
|
-
const
|
|
2647
|
-
if (
|
|
2648
|
-
const f = document.body.querySelectorAll(
|
|
2680
|
+
const c = t.getRawAttribute(a);
|
|
2681
|
+
if (c) {
|
|
2682
|
+
const f = document.body.querySelectorAll(c);
|
|
2649
2683
|
f.length > 0 ? (r.bindFragments = [], f.forEach((g) => {
|
|
2650
2684
|
const A = T.get(g);
|
|
2651
2685
|
A && r.bindFragments.push(A);
|
|
2652
2686
|
})) : d.error(
|
|
2653
2687
|
"Haori",
|
|
2654
|
-
`Bind element not found: ${
|
|
2688
|
+
`Bind element not found: ${c} (${a})`
|
|
2655
2689
|
);
|
|
2656
2690
|
}
|
|
2657
2691
|
}
|
|
2658
|
-
const o = l.attrName(e, "bind-arg"),
|
|
2692
|
+
const o = l.attrName(e, "bind-arg"), h = l.attrName(
|
|
2659
2693
|
null,
|
|
2660
2694
|
"arg",
|
|
2661
2695
|
!0
|
|
@@ -2664,25 +2698,25 @@ ${h}
|
|
|
2664
2698
|
"bind-arg",
|
|
2665
2699
|
!0
|
|
2666
2700
|
);
|
|
2667
|
-
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(
|
|
2668
|
-
|
|
2701
|
+
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(h) ? r.bindArg = t.getRawAttribute(
|
|
2702
|
+
h
|
|
2669
2703
|
) : t.hasAttribute(m) && (r.bindArg = t.getRawAttribute(m));
|
|
2670
|
-
const
|
|
2671
|
-
if (t.hasAttribute(
|
|
2672
|
-
const
|
|
2673
|
-
r.bindParams =
|
|
2704
|
+
const b = e ? l.attrName(e, "bind-params") : l.attrName(null, "bind-params", !0);
|
|
2705
|
+
if (t.hasAttribute(b)) {
|
|
2706
|
+
const c = t.getRawAttribute(b);
|
|
2707
|
+
r.bindParams = c.split("&").map((f) => f.trim());
|
|
2674
2708
|
}
|
|
2675
2709
|
const E = e ? l.attrName(e, "bind-append") : l.attrName(null, "bind-append", !0);
|
|
2676
2710
|
if (t.hasAttribute(E)) {
|
|
2677
|
-
const
|
|
2678
|
-
r.bindAppendParams =
|
|
2711
|
+
const c = t.getRawAttribute(E);
|
|
2712
|
+
r.bindAppendParams = c.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2679
2713
|
}
|
|
2680
2714
|
const S = e ? l.attrName(e, "copy-params") : null;
|
|
2681
2715
|
if (S && t.hasAttribute(S)) {
|
|
2682
|
-
const
|
|
2716
|
+
const c = t.getRawAttribute(
|
|
2683
2717
|
S
|
|
2684
2718
|
);
|
|
2685
|
-
r.copyParams =
|
|
2719
|
+
r.copyParams = c.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2686
2720
|
}
|
|
2687
2721
|
if (e) {
|
|
2688
2722
|
if (t.hasAttribute(l.attrName(e, "adjust"))) {
|
|
@@ -2706,9 +2740,9 @@ ${h}
|
|
|
2706
2740
|
isNaN(A) || (r.adjustValue = A);
|
|
2707
2741
|
}
|
|
2708
2742
|
}
|
|
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(`${
|
|
2743
|
+
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(`${u.prefix}${e}-after-run`)) {
|
|
2710
2744
|
const f = t.getRawAttribute(
|
|
2711
|
-
`${
|
|
2745
|
+
`${u.prefix}${e}-after-run`
|
|
2712
2746
|
);
|
|
2713
2747
|
try {
|
|
2714
2748
|
r.afterCallback = new Function(
|
|
@@ -2749,14 +2783,14 @@ ${f}
|
|
|
2749
2783
|
);
|
|
2750
2784
|
if (f) {
|
|
2751
2785
|
const g = document.body.querySelector(f);
|
|
2752
|
-
g !== null ? r.historyFormFragment =
|
|
2786
|
+
g !== null ? r.historyFormFragment = y.getFormFragment(
|
|
2753
2787
|
T.get(g)
|
|
2754
2788
|
) : d.error(
|
|
2755
2789
|
"Haori",
|
|
2756
2790
|
`Form element not found: ${f} (${l.attrName(e, "history-form")})`
|
|
2757
2791
|
);
|
|
2758
2792
|
} else
|
|
2759
|
-
r.historyFormFragment =
|
|
2793
|
+
r.historyFormFragment = y.getFormFragment(t);
|
|
2760
2794
|
}
|
|
2761
2795
|
[
|
|
2762
2796
|
"reset",
|
|
@@ -2770,8 +2804,8 @@ ${f}
|
|
|
2770
2804
|
if (!t.hasAttribute(g))
|
|
2771
2805
|
return;
|
|
2772
2806
|
const A = t.getRawAttribute(g), v = [];
|
|
2773
|
-
if (A ? (document.body.querySelectorAll(A).forEach((
|
|
2774
|
-
const tt = T.get(
|
|
2807
|
+
if (A ? (document.body.querySelectorAll(A).forEach((J) => {
|
|
2808
|
+
const tt = T.get(J);
|
|
2775
2809
|
tt && v.push(tt);
|
|
2776
2810
|
}), v.length === 0 && d.error("Haori", `Element not found: ${A} (${g})`)) : v.push(t), v.length > 0)
|
|
2777
2811
|
switch (f) {
|
|
@@ -2800,19 +2834,19 @@ ${f}
|
|
|
2800
2834
|
t,
|
|
2801
2835
|
l.attrName(null, "data", !0)
|
|
2802
2836
|
)), t.hasAttribute(l.attrName(null, "form", !0)))) {
|
|
2803
|
-
const
|
|
2837
|
+
const c = t.getRawAttribute(
|
|
2804
2838
|
l.attrName(null, "form", !0)
|
|
2805
2839
|
);
|
|
2806
|
-
if (
|
|
2807
|
-
const f = document.body.querySelector(
|
|
2808
|
-
f !== null ? r.formFragment =
|
|
2840
|
+
if (c) {
|
|
2841
|
+
const f = document.body.querySelector(c);
|
|
2842
|
+
f !== null ? r.formFragment = y.getFormFragment(
|
|
2809
2843
|
T.get(f)
|
|
2810
2844
|
) : d.error(
|
|
2811
2845
|
"Haori",
|
|
2812
|
-
`Form element not found: ${
|
|
2846
|
+
`Form element not found: ${c} (${l.attrName(null, "fetch-form", !0)})`
|
|
2813
2847
|
);
|
|
2814
2848
|
} else
|
|
2815
|
-
r.formFragment =
|
|
2849
|
+
r.formFragment = y.getFormFragment(t);
|
|
2816
2850
|
}
|
|
2817
2851
|
return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2818
2852
|
}
|
|
@@ -2876,37 +2910,37 @@ ${f}
|
|
|
2876
2910
|
}
|
|
2877
2911
|
const i = {};
|
|
2878
2912
|
if (this.options.formFragment) {
|
|
2879
|
-
const o =
|
|
2913
|
+
const o = y.getValues(this.options.formFragment);
|
|
2880
2914
|
Object.assign(i, o);
|
|
2881
2915
|
}
|
|
2882
2916
|
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2883
2917
|
const n = Object.keys(i).length > 0;
|
|
2884
2918
|
if (e) {
|
|
2885
|
-
const o = { ...r || {} },
|
|
2919
|
+
const o = { ...r || {} }, h = new Headers(
|
|
2886
2920
|
o.headers || void 0
|
|
2887
|
-
), m = (o.method || "GET").toUpperCase(),
|
|
2921
|
+
), m = (o.method || "GET").toUpperCase(), b = u.runtime === "demo" && !ut(m), E = b ? "GET" : m;
|
|
2888
2922
|
if (o.method = E, E === "GET" || E === "HEAD" || E === "OPTIONS")
|
|
2889
2923
|
n && (e = ht(e, i));
|
|
2890
2924
|
else if (n) {
|
|
2891
|
-
const
|
|
2892
|
-
if (/multipart\/form-data/i.test(
|
|
2893
|
-
|
|
2925
|
+
const c = h.get("Content-Type") || "";
|
|
2926
|
+
if (/multipart\/form-data/i.test(c)) {
|
|
2927
|
+
h.delete("Content-Type");
|
|
2894
2928
|
const f = new FormData();
|
|
2895
2929
|
for (const [g, A] of Object.entries(i))
|
|
2896
2930
|
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
2931
|
o.body = f;
|
|
2898
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2932
|
+
} else if (/application\/x-www-form-urlencoded/i.test(c)) {
|
|
2899
2933
|
const f = new URLSearchParams();
|
|
2900
2934
|
for (const [g, A] of Object.entries(i))
|
|
2901
2935
|
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
2936
|
o.body = f;
|
|
2903
2937
|
} else
|
|
2904
|
-
|
|
2938
|
+
h.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2905
2939
|
}
|
|
2906
|
-
o.headers =
|
|
2940
|
+
o.headers = h;
|
|
2907
2941
|
let S;
|
|
2908
|
-
if (
|
|
2909
|
-
runtime:
|
|
2942
|
+
if (b && (S = e && new URL(e, window.location.href).search || void 0, h.delete("Content-Type"), d.info("Haori demo fetch normalization", {
|
|
2943
|
+
runtime: u.runtime,
|
|
2910
2944
|
requestedMethod: m,
|
|
2911
2945
|
effectiveMethod: E,
|
|
2912
2946
|
transportMode: "query-get",
|
|
@@ -2914,12 +2948,12 @@ ${f}
|
|
|
2914
2948
|
payload: n ? i : void 0,
|
|
2915
2949
|
queryString: S
|
|
2916
2950
|
})), this.options.targetFragment && e) {
|
|
2917
|
-
const
|
|
2918
|
-
runtime:
|
|
2951
|
+
const c = performance.now(), f = {
|
|
2952
|
+
runtime: u.runtime,
|
|
2919
2953
|
requestedMethod: m,
|
|
2920
2954
|
effectiveMethod: E,
|
|
2921
|
-
transportMode:
|
|
2922
|
-
...
|
|
2955
|
+
transportMode: b ? "query-get" : "http",
|
|
2956
|
+
...b ? { queryString: S } : {}
|
|
2923
2957
|
};
|
|
2924
2958
|
return w.fetchStart(
|
|
2925
2959
|
this.options.targetFragment.getTarget(),
|
|
@@ -2930,7 +2964,7 @@ ${f}
|
|
|
2930
2964
|
), fetch(e, o).then((g) => this.handleFetchResult(
|
|
2931
2965
|
g,
|
|
2932
2966
|
e || void 0,
|
|
2933
|
-
|
|
2967
|
+
c
|
|
2934
2968
|
)).catch((g) => {
|
|
2935
2969
|
throw e && w.fetchError(
|
|
2936
2970
|
this.options.targetFragment.getTarget(),
|
|
@@ -2939,16 +2973,16 @@ ${f}
|
|
|
2939
2973
|
), g;
|
|
2940
2974
|
});
|
|
2941
2975
|
}
|
|
2942
|
-
return fetch(e, o).then((
|
|
2976
|
+
return fetch(e, o).then((c) => this.handleFetchResult(c, e || void 0));
|
|
2943
2977
|
}
|
|
2944
2978
|
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && n) {
|
|
2945
|
-
const o = this.options.formFragment,
|
|
2946
|
-
|
|
2947
|
-
`${
|
|
2979
|
+
const o = this.options.formFragment, h = o.getTarget();
|
|
2980
|
+
h.setAttribute(
|
|
2981
|
+
`${u.prefix}bind`,
|
|
2948
2982
|
JSON.stringify(i)
|
|
2949
2983
|
);
|
|
2950
2984
|
const m = o.getBindingData();
|
|
2951
|
-
Object.assign(m, i), await
|
|
2985
|
+
Object.assign(m, i), await P.setBindingData(h, m);
|
|
2952
2986
|
}
|
|
2953
2987
|
const s = n ? i : {}, a = new Response(JSON.stringify(s), {
|
|
2954
2988
|
headers: { "Content-Type": "application/json" }
|
|
@@ -2959,7 +2993,7 @@ ${f}
|
|
|
2959
2993
|
* フェッチ後の処理を実行します。
|
|
2960
2994
|
*/
|
|
2961
2995
|
async handleFetchResult(t, e, r) {
|
|
2962
|
-
const i =
|
|
2996
|
+
const i = W();
|
|
2963
2997
|
if (!t.ok)
|
|
2964
2998
|
return this.options.targetFragment && e && w.fetchError(
|
|
2965
2999
|
this.options.targetFragment.getTarget(),
|
|
@@ -2983,7 +3017,7 @@ ${f}
|
|
|
2983
3017
|
}
|
|
2984
3018
|
const n = [];
|
|
2985
3019
|
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(
|
|
2986
|
-
this.options.resetFragments.map((a) =>
|
|
3020
|
+
this.options.resetFragments.map((a) => y.reset(a))
|
|
2987
3021
|
), await this.copy();
|
|
2988
3022
|
const s = [];
|
|
2989
3023
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
@@ -3025,11 +3059,11 @@ ${f}
|
|
|
3025
3059
|
return;
|
|
3026
3060
|
}
|
|
3027
3061
|
const s = (a) => {
|
|
3028
|
-
for (const [o,
|
|
3029
|
-
|
|
3062
|
+
for (const [o, h] of Object.entries(a))
|
|
3063
|
+
h != null && (Array.isArray(h) ? h.forEach((m) => n.searchParams.append(o, String(m))) : typeof h == "object" ? n.searchParams.set(o, JSON.stringify(h)) : n.searchParams.set(o, String(h)));
|
|
3030
3064
|
};
|
|
3031
3065
|
e && s(this.options.historyData), r && s(
|
|
3032
|
-
|
|
3066
|
+
y.getValues(
|
|
3033
3067
|
this.options.historyFormFragment
|
|
3034
3068
|
)
|
|
3035
3069
|
), history.pushState(
|
|
@@ -3046,10 +3080,10 @@ ${f}
|
|
|
3046
3080
|
*/
|
|
3047
3081
|
async handleFetchError(t) {
|
|
3048
3082
|
let e = null;
|
|
3049
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
3083
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = y.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3050
3084
|
const r = async (s) => {
|
|
3051
3085
|
const a = e ? e.getTarget() : document.body;
|
|
3052
|
-
await
|
|
3086
|
+
await W().addErrorMessage(a, s);
|
|
3053
3087
|
}, i = () => {
|
|
3054
3088
|
if (!this.options.scrollOnError)
|
|
3055
3089
|
return;
|
|
@@ -3064,18 +3098,18 @@ ${f}
|
|
|
3064
3098
|
for (const o of s.messages)
|
|
3065
3099
|
typeof o == "string" && a.push({ message: o });
|
|
3066
3100
|
if (s.errors && typeof s.errors == "object")
|
|
3067
|
-
for (const [o,
|
|
3068
|
-
Array.isArray(
|
|
3069
|
-
`) }) : typeof
|
|
3101
|
+
for (const [o, h] of Object.entries(s.errors))
|
|
3102
|
+
Array.isArray(h) ? a.push({ key: o, message: h.join(`
|
|
3103
|
+
`) }) : typeof h == "string" ? a.push({ key: o, message: h }) : h != null && a.push({ key: o, message: String(h) });
|
|
3070
3104
|
if (a.length === 0)
|
|
3071
|
-
for (const [o,
|
|
3072
|
-
o === "message" || o === "messages" || o === "errors" || (Array.isArray(
|
|
3073
|
-
`) }) : typeof
|
|
3105
|
+
for (const [o, h] of Object.entries(s))
|
|
3106
|
+
o === "message" || o === "messages" || o === "errors" || (Array.isArray(h) ? a.push({ key: o, message: h.join(`
|
|
3107
|
+
`) }) : typeof h == "string" && a.push({ key: o, message: h }));
|
|
3074
3108
|
}
|
|
3075
3109
|
if (a.length === 0)
|
|
3076
3110
|
return await r(`${t.status} ${t.statusText}`), i(), !1;
|
|
3077
3111
|
for (const o of a)
|
|
3078
|
-
o.key && e ? await
|
|
3112
|
+
o.key && e ? await y.addErrorMessage(e, o.key, o.message) : await r(o.message);
|
|
3079
3113
|
return i(), !1;
|
|
3080
3114
|
} catch {
|
|
3081
3115
|
}
|
|
@@ -3134,7 +3168,7 @@ ${f}
|
|
|
3134
3168
|
*/
|
|
3135
3169
|
confirm() {
|
|
3136
3170
|
const t = this.options.confirmMessage;
|
|
3137
|
-
return t == null ? Promise.resolve(!0) :
|
|
3171
|
+
return t == null ? Promise.resolve(!0) : W().confirm(t);
|
|
3138
3172
|
}
|
|
3139
3173
|
/**
|
|
3140
3174
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -3154,15 +3188,15 @@ ${f}
|
|
|
3154
3188
|
this.options.bindFragments.forEach((n) => {
|
|
3155
3189
|
const s = n.getBindingData(), a = this.options.bindArg;
|
|
3156
3190
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3157
|
-
const o = s[a],
|
|
3191
|
+
const o = s[a], h = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3158
3192
|
s[a] = this.mergeAppendBindingData(
|
|
3159
3193
|
n,
|
|
3160
3194
|
r,
|
|
3161
|
-
|
|
3195
|
+
h
|
|
3162
3196
|
);
|
|
3163
3197
|
} else
|
|
3164
3198
|
s[a] = r;
|
|
3165
|
-
i.push(
|
|
3199
|
+
i.push(P.setBindingData(n.getTarget(), s));
|
|
3166
3200
|
});
|
|
3167
3201
|
else {
|
|
3168
3202
|
if (typeof r == "string")
|
|
@@ -3175,7 +3209,7 @@ ${f}
|
|
|
3175
3209
|
r
|
|
3176
3210
|
);
|
|
3177
3211
|
i.push(
|
|
3178
|
-
|
|
3212
|
+
P.setBindingData(
|
|
3179
3213
|
n.getTarget(),
|
|
3180
3214
|
s
|
|
3181
3215
|
)
|
|
@@ -3210,7 +3244,7 @@ ${f}
|
|
|
3210
3244
|
...i.getBindingData(),
|
|
3211
3245
|
...e
|
|
3212
3246
|
};
|
|
3213
|
-
return
|
|
3247
|
+
return P.setBindingData(i.getTarget(), n);
|
|
3214
3248
|
});
|
|
3215
3249
|
return Promise.all(r).then(() => {
|
|
3216
3250
|
});
|
|
@@ -3219,7 +3253,7 @@ ${f}
|
|
|
3219
3253
|
* copy のコピー元データを取得します。
|
|
3220
3254
|
*/
|
|
3221
3255
|
resolveCopySourceData() {
|
|
3222
|
-
return this.options.formFragment ?
|
|
3256
|
+
return this.options.formFragment ? y.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3223
3257
|
}
|
|
3224
3258
|
/**
|
|
3225
3259
|
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
@@ -3257,7 +3291,7 @@ ${f}
|
|
|
3257
3291
|
if (!this.options.targetFragment)
|
|
3258
3292
|
return d.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3259
3293
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3260
|
-
`${
|
|
3294
|
+
`${u.prefix}row`
|
|
3261
3295
|
);
|
|
3262
3296
|
return t || (d.error("Haori", "Row fragment not found."), null);
|
|
3263
3297
|
}
|
|
@@ -3275,7 +3309,7 @@ ${f}
|
|
|
3275
3309
|
const e = [], r = t.clone();
|
|
3276
3310
|
return e.push(
|
|
3277
3311
|
t.getParent().insertAfter(r, t)
|
|
3278
|
-
), e.push(
|
|
3312
|
+
), e.push(P.evaluateAll(r)), e.push(y.reset(r)), Promise.all(e).then(() => {
|
|
3279
3313
|
});
|
|
3280
3314
|
}
|
|
3281
3315
|
/**
|
|
@@ -3290,7 +3324,7 @@ ${f}
|
|
|
3290
3324
|
if (!t)
|
|
3291
3325
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3292
3326
|
const e = t.getParent();
|
|
3293
|
-
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
3327
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${u.prefix}each-before`) && !i.hasAttribute(`${u.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3294
3328
|
}
|
|
3295
3329
|
/**
|
|
3296
3330
|
* 前の行へ移動します。
|
|
@@ -3389,7 +3423,7 @@ const p = class p {
|
|
|
3389
3423
|
*/
|
|
3390
3424
|
static isDeferredAttributeName(t) {
|
|
3391
3425
|
return p.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3392
|
-
(e) => t === `${
|
|
3426
|
+
(e) => t === `${u.prefix}${e}`
|
|
3393
3427
|
);
|
|
3394
3428
|
}
|
|
3395
3429
|
/**
|
|
@@ -3400,7 +3434,7 @@ const p = class p {
|
|
|
3400
3434
|
*/
|
|
3401
3435
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3402
3436
|
return p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3403
|
-
(e) => t === `${
|
|
3437
|
+
(e) => t === `${u.prefix}${e}`
|
|
3404
3438
|
);
|
|
3405
3439
|
}
|
|
3406
3440
|
/**
|
|
@@ -3420,7 +3454,7 @@ const p = class p {
|
|
|
3420
3454
|
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
3421
3455
|
*/
|
|
3422
3456
|
static getAliasedAttributeName(t) {
|
|
3423
|
-
const e = `${
|
|
3457
|
+
const e = `${u.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
3424
3458
|
return !t.startsWith(e) || t.length <= e.length ? null : t.slice(e.length);
|
|
3425
3459
|
}
|
|
3426
3460
|
/**
|
|
@@ -3433,7 +3467,7 @@ const p = class p {
|
|
|
3433
3467
|
static isAliasedAttributeReflection(t, e) {
|
|
3434
3468
|
const r = T.get(t);
|
|
3435
3469
|
return r instanceof x ? r.hasAttribute(
|
|
3436
|
-
`${
|
|
3470
|
+
`${u.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}${e}`
|
|
3437
3471
|
) : !1;
|
|
3438
3472
|
}
|
|
3439
3473
|
/**
|
|
@@ -3468,7 +3502,7 @@ const p = class p {
|
|
|
3468
3502
|
let r = Promise.resolve();
|
|
3469
3503
|
const i = /* @__PURE__ */ new Set();
|
|
3470
3504
|
for (const n of p.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3471
|
-
const s =
|
|
3505
|
+
const s = u.prefix + n;
|
|
3472
3506
|
e.hasAttribute(s) && (r = r.then(
|
|
3473
3507
|
() => p.setAttribute(
|
|
3474
3508
|
e.getTarget(),
|
|
@@ -3486,7 +3520,7 @@ const p = class p {
|
|
|
3486
3520
|
));
|
|
3487
3521
|
}
|
|
3488
3522
|
for (const n of p.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3489
|
-
const s =
|
|
3523
|
+
const s = u.prefix + n;
|
|
3490
3524
|
e.hasAttribute(s) && (r = r.then(
|
|
3491
3525
|
() => p.setAttribute(
|
|
3492
3526
|
e.getTarget(),
|
|
@@ -3519,47 +3553,47 @@ const p = class p {
|
|
|
3519
3553
|
return r === null ? i.removeAliasedAttribute(e, n) : i.setAliasedAttribute(e, n, r);
|
|
3520
3554
|
const s = [];
|
|
3521
3555
|
switch (e) {
|
|
3522
|
-
case `${
|
|
3556
|
+
case `${u.prefix}bind`: {
|
|
3523
3557
|
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(p.parseDataBind(r));
|
|
3524
3558
|
break;
|
|
3525
3559
|
}
|
|
3526
|
-
case `${
|
|
3560
|
+
case `${u.prefix}if`:
|
|
3527
3561
|
s.push(p.evaluateIf(i));
|
|
3528
3562
|
break;
|
|
3529
|
-
case `${
|
|
3563
|
+
case `${u.prefix}each`:
|
|
3530
3564
|
s.push(p.evaluateEach(i));
|
|
3531
3565
|
break;
|
|
3532
|
-
case `${
|
|
3566
|
+
case `${u.prefix}fetch`:
|
|
3533
3567
|
s.push(
|
|
3534
3568
|
new V(i, null).run().then(() => {
|
|
3535
3569
|
})
|
|
3536
3570
|
);
|
|
3537
3571
|
break;
|
|
3538
|
-
case `${
|
|
3572
|
+
case `${u.prefix}import`: {
|
|
3539
3573
|
if (typeof r == "string") {
|
|
3540
3574
|
const a = i.getTarget(), o = performance.now();
|
|
3541
3575
|
w.importStart(a, r), s.push(
|
|
3542
|
-
dt.load(r).then((
|
|
3543
|
-
const m = new TextEncoder().encode(
|
|
3544
|
-
return
|
|
3545
|
-
a.innerHTML =
|
|
3576
|
+
dt.load(r).then((h) => {
|
|
3577
|
+
const m = new TextEncoder().encode(h).length;
|
|
3578
|
+
return R.enqueue(() => {
|
|
3579
|
+
a.innerHTML = h;
|
|
3546
3580
|
}).then(() => {
|
|
3547
3581
|
w.importEnd(a, r, m, o);
|
|
3548
3582
|
});
|
|
3549
|
-
}).catch((
|
|
3550
|
-
w.importError(a, r,
|
|
3583
|
+
}).catch((h) => {
|
|
3584
|
+
w.importError(a, r, h), d.error("[Haori]", "Failed to import HTML:", r, h);
|
|
3551
3585
|
})
|
|
3552
3586
|
);
|
|
3553
3587
|
}
|
|
3554
3588
|
break;
|
|
3555
3589
|
}
|
|
3556
|
-
case `${
|
|
3557
|
-
const a = i.getAttribute(`${
|
|
3590
|
+
case `${u.prefix}url-param`: {
|
|
3591
|
+
const a = i.getAttribute(`${u.prefix}url-arg`), o = ft.readParams();
|
|
3558
3592
|
if (a === null)
|
|
3559
3593
|
s.push(p.setBindingData(t, o));
|
|
3560
3594
|
else {
|
|
3561
|
-
const
|
|
3562
|
-
|
|
3595
|
+
const h = i.getRawBindingData() || {};
|
|
3596
|
+
h[String(a)] = o, s.push(p.setBindingData(t, h));
|
|
3563
3597
|
}
|
|
3564
3598
|
break;
|
|
3565
3599
|
}
|
|
@@ -3579,12 +3613,12 @@ const p = class p {
|
|
|
3579
3613
|
const r = T.get(t), i = r.getRawBindingData();
|
|
3580
3614
|
r.setBindingData(e);
|
|
3581
3615
|
let n = r.setAttribute(
|
|
3582
|
-
`${
|
|
3616
|
+
`${u.prefix}bind`,
|
|
3583
3617
|
JSON.stringify(e)
|
|
3584
3618
|
);
|
|
3585
3619
|
if (t.tagName === "FORM") {
|
|
3586
|
-
const s = r.getAttribute(`${
|
|
3587
|
-
n = n.then(() =>
|
|
3620
|
+
const s = r.getAttribute(`${u.prefix}form-arg`), a = s && e[String(s)] && typeof e[String(s)] == "object" && !Array.isArray(e[String(s)]) ? e[String(s)] : s ? {} : e;
|
|
3621
|
+
n = n.then(() => y.syncValues(r, a));
|
|
3588
3622
|
}
|
|
3589
3623
|
return n = n.then(() => p.evaluateAll(r)), w.bindChange(t, i, e, "manual"), n.then(() => {
|
|
3590
3624
|
});
|
|
@@ -3662,7 +3696,7 @@ const p = class p {
|
|
|
3662
3696
|
i.push(r.setValue(e));
|
|
3663
3697
|
const n = p.getFormFragment(r);
|
|
3664
3698
|
if (n) {
|
|
3665
|
-
const s =
|
|
3699
|
+
const s = y.getValues(n), a = n.getAttribute(`${u.prefix}form-arg`);
|
|
3666
3700
|
let o;
|
|
3667
3701
|
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(p.setBindingData(n.getTarget(), o));
|
|
3668
3702
|
}
|
|
@@ -3689,7 +3723,7 @@ const p = class p {
|
|
|
3689
3723
|
*/
|
|
3690
3724
|
static evaluateAll(t) {
|
|
3691
3725
|
const e = [];
|
|
3692
|
-
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${
|
|
3726
|
+
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${u.prefix}if`) && e.push(p.evaluateIf(t)), t.hasAttribute(`${u.prefix}each`) ? Promise.all(e).then(() => p.evaluateEach(t)).then(() => {
|
|
3693
3727
|
const r = [];
|
|
3694
3728
|
return t.getChildren().forEach((i) => {
|
|
3695
3729
|
i instanceof x ? r.push(p.evaluateAll(i)) : i instanceof H && r.push(p.evaluateText(i));
|
|
@@ -3717,7 +3751,7 @@ const p = class p {
|
|
|
3717
3751
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3718
3752
|
*/
|
|
3719
3753
|
static evaluateIf(t) {
|
|
3720
|
-
const e = [], r = t.getAttribute(`${
|
|
3754
|
+
const e = [], r = t.getAttribute(`${u.prefix}if`);
|
|
3721
3755
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3722
3756
|
t.hide().then(() => {
|
|
3723
3757
|
w.hide(t.getTarget());
|
|
@@ -3743,17 +3777,17 @@ const p = class p {
|
|
|
3743
3777
|
let i = !1;
|
|
3744
3778
|
t.getChildren().forEach((s) => {
|
|
3745
3779
|
if (!i && s instanceof x) {
|
|
3746
|
-
if (s.hasAttribute(`${
|
|
3780
|
+
if (s.hasAttribute(`${u.prefix}each-before`) || s.hasAttribute(`${u.prefix}each-after`))
|
|
3747
3781
|
return;
|
|
3748
3782
|
e = s.clone(), t.setTemplate(e), i = !0, t.removeChild(s);
|
|
3749
3783
|
const a = s.getTarget();
|
|
3750
3784
|
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3751
3785
|
}
|
|
3752
3786
|
});
|
|
3753
|
-
const n = t.getAttribute(`${
|
|
3787
|
+
const n = t.getAttribute(`${u.prefix}each`);
|
|
3754
3788
|
return Array.isArray(n) ? this.updateDiff(t, n) : (d.error("[Haori]", "Invalid each attribute:", n), Promise.reject(new Error("Invalid each attribute.")));
|
|
3755
3789
|
}
|
|
3756
|
-
const r = t.getAttribute(`${
|
|
3790
|
+
const r = t.getAttribute(`${u.prefix}each`);
|
|
3757
3791
|
return Array.isArray(r) ? this.updateDiff(t, r) : (d.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3758
3792
|
}
|
|
3759
3793
|
/**
|
|
@@ -3766,26 +3800,26 @@ const p = class p {
|
|
|
3766
3800
|
const r = t.getTemplate();
|
|
3767
3801
|
if (r === null)
|
|
3768
3802
|
return d.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3769
|
-
let i = t.getAttribute(`${
|
|
3803
|
+
let i = t.getAttribute(`${u.prefix}each-index`);
|
|
3770
3804
|
i && (i = String(i));
|
|
3771
|
-
const n = t.getAttribute(`${
|
|
3772
|
-
e.forEach((
|
|
3805
|
+
const n = t.getAttribute(`${u.prefix}each-key`), s = t.getAttribute(`${u.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3806
|
+
e.forEach((c, f) => {
|
|
3773
3807
|
const g = p.createListKey(
|
|
3774
|
-
|
|
3808
|
+
c,
|
|
3775
3809
|
n ? String(n) : null,
|
|
3776
3810
|
f
|
|
3777
3811
|
);
|
|
3778
|
-
o.push(g), a.set(g, { item:
|
|
3812
|
+
o.push(g), a.set(g, { item: c, itemIndex: f });
|
|
3779
3813
|
});
|
|
3780
|
-
const
|
|
3781
|
-
let m = t.getChildren().filter((
|
|
3782
|
-
(
|
|
3814
|
+
const h = [];
|
|
3815
|
+
let m = t.getChildren().filter((c) => c instanceof x).filter(
|
|
3816
|
+
(c) => !c.hasAttribute(`${u.prefix}each-before`) && !c.hasAttribute(`${u.prefix}each-after`)
|
|
3783
3817
|
);
|
|
3784
|
-
m = m.filter((
|
|
3785
|
-
const
|
|
3818
|
+
m = m.filter((c) => o.indexOf(String(c.getListKey())) === -1 ? (h.push(c.remove()), !1) : !0);
|
|
3819
|
+
const b = m.map((c) => c.getListKey()), E = t.getChildren().filter((c) => c instanceof x).filter((c) => c.hasAttribute(`${u.prefix}each-before`)).length;
|
|
3786
3820
|
let S = Promise.resolve();
|
|
3787
|
-
return o.forEach((
|
|
3788
|
-
const g =
|
|
3821
|
+
return o.forEach((c, f) => {
|
|
3822
|
+
const g = b.indexOf(c), { item: A, itemIndex: v } = a.get(c);
|
|
3789
3823
|
let k;
|
|
3790
3824
|
if (g !== -1)
|
|
3791
3825
|
k = m[g], S = S.then(
|
|
@@ -3795,12 +3829,12 @@ const p = class p {
|
|
|
3795
3829
|
i,
|
|
3796
3830
|
v,
|
|
3797
3831
|
s ? String(s) : null,
|
|
3798
|
-
|
|
3832
|
+
c
|
|
3799
3833
|
).then(() => p.evaluateAll(k))
|
|
3800
3834
|
);
|
|
3801
3835
|
else {
|
|
3802
3836
|
k = r.clone();
|
|
3803
|
-
const
|
|
3837
|
+
const J = E + f;
|
|
3804
3838
|
S = S.then(
|
|
3805
3839
|
() => p.updateRowFragment(
|
|
3806
3840
|
k,
|
|
@@ -3808,30 +3842,30 @@ const p = class p {
|
|
|
3808
3842
|
i,
|
|
3809
3843
|
v,
|
|
3810
3844
|
s ? String(s) : null,
|
|
3811
|
-
|
|
3845
|
+
c
|
|
3812
3846
|
).then(
|
|
3813
3847
|
() => t.insertBefore(
|
|
3814
3848
|
k,
|
|
3815
|
-
t.getChildren()[
|
|
3849
|
+
t.getChildren()[J] || null
|
|
3816
3850
|
).then(() => p.evaluateAll(k))
|
|
3817
3851
|
)
|
|
3818
3852
|
);
|
|
3819
3853
|
}
|
|
3820
|
-
}), Promise.all(
|
|
3821
|
-
const
|
|
3854
|
+
}), Promise.all(h).then(() => S).then(() => {
|
|
3855
|
+
const c = o.filter(
|
|
3822
3856
|
(v) => v !== null
|
|
3823
|
-
), f =
|
|
3857
|
+
), f = b.filter(
|
|
3824
3858
|
(v) => v !== null
|
|
3825
|
-
), g =
|
|
3859
|
+
), g = c.filter(
|
|
3826
3860
|
(v) => !f.includes(v)
|
|
3827
3861
|
), A = f.filter(
|
|
3828
|
-
(v) => !
|
|
3862
|
+
(v) => !c.includes(v)
|
|
3829
3863
|
);
|
|
3830
3864
|
w.eachUpdate(
|
|
3831
3865
|
t.getTarget(),
|
|
3832
3866
|
g,
|
|
3833
3867
|
A,
|
|
3834
|
-
|
|
3868
|
+
c
|
|
3835
3869
|
);
|
|
3836
3870
|
});
|
|
3837
3871
|
}
|
|
@@ -3879,9 +3913,9 @@ const p = class p {
|
|
|
3879
3913
|
else
|
|
3880
3914
|
return d.error(
|
|
3881
3915
|
"[Haori]",
|
|
3882
|
-
`Primitive value requires '${
|
|
3916
|
+
`Primitive value requires '${u.prefix}each-arg' attribute: ${e}`
|
|
3883
3917
|
), Promise.resolve();
|
|
3884
|
-
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${
|
|
3918
|
+
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${u.prefix}row`, s);
|
|
3885
3919
|
}
|
|
3886
3920
|
};
|
|
3887
3921
|
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 = [
|
|
@@ -3892,8 +3926,8 @@ p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if
|
|
|
3892
3926
|
"import",
|
|
3893
3927
|
"url-param"
|
|
3894
3928
|
], p.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3895
|
-
let
|
|
3896
|
-
const
|
|
3929
|
+
let P = p;
|
|
3930
|
+
const Y = class Y {
|
|
3897
3931
|
/**
|
|
3898
3932
|
* コンストラクタ。
|
|
3899
3933
|
*
|
|
@@ -3905,7 +3939,7 @@ const X = class X {
|
|
|
3905
3939
|
r && new V(r, "load").run();
|
|
3906
3940
|
}, this.onPopstate = (e) => {
|
|
3907
3941
|
const r = e.state;
|
|
3908
|
-
!r || r[
|
|
3942
|
+
!r || r[Y.HISTORY_STATE_KEY] !== !0 || location.reload();
|
|
3909
3943
|
}, this.root = t;
|
|
3910
3944
|
}
|
|
3911
3945
|
/**
|
|
@@ -3946,8 +3980,8 @@ const X = class X {
|
|
|
3946
3980
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3947
3981
|
}
|
|
3948
3982
|
};
|
|
3949
|
-
|
|
3950
|
-
let Q =
|
|
3983
|
+
Y.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
3984
|
+
let Q = Y;
|
|
3951
3985
|
const N = class N {
|
|
3952
3986
|
static syncTree(t) {
|
|
3953
3987
|
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && N.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
@@ -3962,7 +3996,7 @@ const N = class N {
|
|
|
3962
3996
|
}
|
|
3963
3997
|
if (typeof IntersectionObserver > "u")
|
|
3964
3998
|
return;
|
|
3965
|
-
const i = N.resolveRoot(r), n = N.resolveRootMargin(r), s = N.resolveThreshold(r), a = r.hasAttribute(`${
|
|
3999
|
+
const i = N.resolveRoot(r), n = N.resolveRootMargin(r), s = N.resolveThreshold(r), a = r.hasAttribute(`${u.prefix}intersect-once`);
|
|
3966
4000
|
if (e && e.observer.root === i && e.observer.rootMargin === n && N.sameThreshold(
|
|
3967
4001
|
e.observer.thresholds,
|
|
3968
4002
|
s
|
|
@@ -3972,10 +4006,10 @@ const N = class N {
|
|
|
3972
4006
|
}
|
|
3973
4007
|
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3974
4008
|
const o = new IntersectionObserver(
|
|
3975
|
-
(
|
|
4009
|
+
(h) => {
|
|
3976
4010
|
const m = N.registrations.get(t);
|
|
3977
|
-
m &&
|
|
3978
|
-
!
|
|
4011
|
+
m && h.forEach((b) => {
|
|
4012
|
+
!b.isIntersecting || m.running || N.isDisabled(m.fragment) || (m.running = !0, new V(m.fragment, "intersect").runWithResult().then((E) => {
|
|
3979
4013
|
E && m.once && (m.observer.disconnect(), N.registrations.delete(t));
|
|
3980
4014
|
}).catch((E) => {
|
|
3981
4015
|
d.error(
|
|
@@ -4019,14 +4053,14 @@ const N = class N {
|
|
|
4019
4053
|
}
|
|
4020
4054
|
static shouldObserve(t) {
|
|
4021
4055
|
return t.getAttributeNames().some((e) => {
|
|
4022
|
-
if (!e.startsWith(`${
|
|
4056
|
+
if (!e.startsWith(`${u.prefix}intersect-`))
|
|
4023
4057
|
return !1;
|
|
4024
|
-
const r = e.slice(`${
|
|
4058
|
+
const r = e.slice(`${u.prefix}intersect-`.length);
|
|
4025
4059
|
return !N.CONFIG_KEYS.has(r);
|
|
4026
4060
|
});
|
|
4027
4061
|
}
|
|
4028
4062
|
static resolveRoot(t) {
|
|
4029
|
-
const e = `${
|
|
4063
|
+
const e = `${u.prefix}intersect-root`;
|
|
4030
4064
|
if (!t.hasAttribute(e))
|
|
4031
4065
|
return null;
|
|
4032
4066
|
const r = t.getAttribute(e);
|
|
@@ -4036,15 +4070,15 @@ const N = class N {
|
|
|
4036
4070
|
return i instanceof HTMLElement ? i : (d.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
4037
4071
|
}
|
|
4038
4072
|
static resolveRootMargin(t) {
|
|
4039
|
-
const e = `${
|
|
4073
|
+
const e = `${u.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
4040
4074
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
4041
4075
|
}
|
|
4042
4076
|
static resolveThreshold(t) {
|
|
4043
|
-
const e = `${
|
|
4077
|
+
const e = `${u.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
4044
4078
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
4045
4079
|
}
|
|
4046
4080
|
static isDisabled(t) {
|
|
4047
|
-
const e = `${
|
|
4081
|
+
const e = `${u.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
4048
4082
|
if (r === null || r === !1)
|
|
4049
4083
|
return !1;
|
|
4050
4084
|
if (typeof r == "boolean")
|
|
@@ -4064,20 +4098,20 @@ N.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
4064
4098
|
"once"
|
|
4065
4099
|
]), N.registrations = /* @__PURE__ */ new Map();
|
|
4066
4100
|
let $ = N;
|
|
4067
|
-
const
|
|
4101
|
+
const C = class C {
|
|
4068
4102
|
/**
|
|
4069
4103
|
* 初期化メソッド。
|
|
4070
4104
|
* ドキュメントのheadとbodyを監視対象として設定します。
|
|
4071
4105
|
*/
|
|
4072
4106
|
static async init() {
|
|
4073
|
-
if (
|
|
4107
|
+
if (C._initialized)
|
|
4074
4108
|
return;
|
|
4075
|
-
|
|
4109
|
+
C._initialized = !0;
|
|
4076
4110
|
const t = await Promise.allSettled([
|
|
4077
|
-
|
|
4078
|
-
|
|
4111
|
+
P.scan(document.head),
|
|
4112
|
+
P.scan(document.body)
|
|
4079
4113
|
]), [e, r] = t;
|
|
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),
|
|
4114
|
+
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), C.observe(document.head), C.observe(document.body), new Q().start(), $.syncTree(document.body);
|
|
4081
4115
|
}
|
|
4082
4116
|
/**
|
|
4083
4117
|
* 指定された要素を監視します。
|
|
@@ -4097,12 +4131,12 @@ const I = class I {
|
|
|
4097
4131
|
i.attributeName
|
|
4098
4132
|
);
|
|
4099
4133
|
const n = i.target;
|
|
4100
|
-
if (i.attributeName &&
|
|
4134
|
+
if (i.attributeName && P.isAliasedAttributeReflection(
|
|
4101
4135
|
n,
|
|
4102
4136
|
i.attributeName
|
|
4103
4137
|
))
|
|
4104
4138
|
break;
|
|
4105
|
-
|
|
4139
|
+
P.setAttribute(
|
|
4106
4140
|
n,
|
|
4107
4141
|
i.attributeName,
|
|
4108
4142
|
n.getAttribute(i.attributeName)
|
|
@@ -4116,9 +4150,9 @@ const I = class I {
|
|
|
4116
4150
|
Array.from(i.removedNodes).map((n) => n.nodeName),
|
|
4117
4151
|
Array.from(i.addedNodes).map((n) => n.nodeName)
|
|
4118
4152
|
), Array.from(i.removedNodes).forEach((n) => {
|
|
4119
|
-
$.cleanupTree(n),
|
|
4153
|
+
$.cleanupTree(n), P.removeNode(n);
|
|
4120
4154
|
}), Array.from(i.addedNodes).forEach((n) => {
|
|
4121
|
-
n.parentElement instanceof HTMLElement && (
|
|
4155
|
+
n.parentElement instanceof HTMLElement && (P.addNode(n.parentElement, n), $.syncTree(n));
|
|
4122
4156
|
});
|
|
4123
4157
|
break;
|
|
4124
4158
|
}
|
|
@@ -4128,7 +4162,7 @@ const I = class I {
|
|
|
4128
4162
|
"Character data changed:",
|
|
4129
4163
|
i.target,
|
|
4130
4164
|
i.target.textContent
|
|
4131
|
-
), i.target instanceof Text || i.target instanceof Comment ?
|
|
4165
|
+
), i.target instanceof Text || i.target instanceof Comment ? P.changeText(i.target, i.target.textContent) : d.warn(
|
|
4132
4166
|
"[Haori]",
|
|
4133
4167
|
"Unsupported character data type:",
|
|
4134
4168
|
i.target
|
|
@@ -4150,19 +4184,19 @@ const I = class I {
|
|
|
4150
4184
|
}), d.info("[Haori]", "Observer initialized for", t);
|
|
4151
4185
|
}
|
|
4152
4186
|
};
|
|
4153
|
-
|
|
4154
|
-
let q =
|
|
4187
|
+
C._initialized = !1;
|
|
4188
|
+
let q = C;
|
|
4155
4189
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4156
|
-
const pt = "0.4.
|
|
4190
|
+
const pt = "0.4.6";
|
|
4157
4191
|
export {
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4192
|
+
P as Core,
|
|
4193
|
+
u as Env,
|
|
4194
|
+
y as Form,
|
|
4161
4195
|
T as Fragment,
|
|
4162
|
-
|
|
4196
|
+
X as Haori,
|
|
4163
4197
|
d as Log,
|
|
4164
|
-
|
|
4165
|
-
|
|
4198
|
+
R as Queue,
|
|
4199
|
+
X as default,
|
|
4166
4200
|
pt as version
|
|
4167
4201
|
};
|
|
4168
4202
|
//# sourceMappingURL=haori.es.js.map
|