haori 0.4.7 → 0.4.9
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 +12 -12
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +657 -620
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +10 -10
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +16 -1
- package/dist/src/core.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/observer.d.ts.map +1 -1
- package/dist/src/observer.js +3 -0
- package/dist/src/observer.js.map +1 -1
- package/dist/src/procedure.d.ts +17 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +191 -142
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/observer.test.d.ts +2 -0
- package/dist/tests/observer.test.d.ts.map +1 -0
- package/dist/tests/observer.test.js +64 -0
- package/dist/tests/observer.test.js.map +1 -0
- package/dist/tests/procedure_events.test.d.ts.map +1 -1
- package/dist/tests/procedure_events.test.js +60 -0
- package/dist/tests/procedure_events.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -29,22 +29,22 @@ const C = class C {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
C.devMode = !1;
|
|
32
|
-
let
|
|
32
|
+
let L = C;
|
|
33
33
|
const z = "embedded";
|
|
34
|
-
function rt(
|
|
35
|
-
return
|
|
34
|
+
function rt(R) {
|
|
35
|
+
return R === "embedded" || R === "demo";
|
|
36
36
|
}
|
|
37
|
-
function it(
|
|
38
|
-
return
|
|
37
|
+
function it(R) {
|
|
38
|
+
return R === null ? null : rt(R) ? R : z;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const k = class k {
|
|
41
41
|
/**
|
|
42
42
|
* 実行モードを取得します。
|
|
43
43
|
*
|
|
44
44
|
* @returns 実行モード。
|
|
45
45
|
*/
|
|
46
46
|
static get runtime() {
|
|
47
|
-
return
|
|
47
|
+
return k._runtime;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 実行モードを設定します。
|
|
@@ -53,7 +53,7 @@ const D = class D {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
|
|
56
|
+
k._runtime = rt(t) ? t : z;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -65,23 +65,23 @@ const D = class D {
|
|
|
65
65
|
try {
|
|
66
66
|
const t = document.currentScript || document.querySelector('script[src*="haori"]');
|
|
67
67
|
if (t instanceof HTMLScriptElement) {
|
|
68
|
-
const r = t.getAttribute("data-prefix") ||
|
|
69
|
-
|
|
68
|
+
const r = t.getAttribute("data-prefix") || k._prefix;
|
|
69
|
+
k._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
70
|
const i = it(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
|
-
i !== null && (
|
|
73
|
+
i !== null && (k._runtime = i);
|
|
74
74
|
}
|
|
75
|
-
if (t instanceof HTMLScriptElement && t.hasAttribute(`${
|
|
76
|
-
|
|
75
|
+
if (t instanceof HTMLScriptElement && t.hasAttribute(`${k._prefix}dev`)) {
|
|
76
|
+
L.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const e = window.location.hostname;
|
|
80
80
|
if (e === "localhost" || e.endsWith(".localhost") || e === "127.0.0.1" || e === "::1" || e.endsWith(".local")) {
|
|
81
|
-
|
|
81
|
+
L.set(!0);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
L.set(!1);
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -91,13 +91,13 @@ const D = class D {
|
|
|
91
91
|
* @returns プレフィックス
|
|
92
92
|
*/
|
|
93
93
|
static get prefix() {
|
|
94
|
-
return
|
|
94
|
+
return k._prefix;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
100
|
-
class
|
|
97
|
+
k._prefix = "data-", k._runtime = z;
|
|
98
|
+
let u = k;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", u.detect) : u.detect();
|
|
100
|
+
class f {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
103
103
|
*
|
|
@@ -105,7 +105,7 @@ class d {
|
|
|
105
105
|
* @param args 追加の引数
|
|
106
106
|
*/
|
|
107
107
|
static info(t, ...e) {
|
|
108
|
-
|
|
108
|
+
L.isEnabled() && console.log && console.log(t, ...e);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* 開発モードでのみコンソールに警告を出力します。
|
|
@@ -114,7 +114,7 @@ class d {
|
|
|
114
114
|
* @param args 追加の引数
|
|
115
115
|
*/
|
|
116
116
|
static warn(t, ...e) {
|
|
117
|
-
|
|
117
|
+
L.isEnabled() && console.warn && console.warn(t, ...e);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* モードに関係なくコンソールにエラーを出力します。
|
|
@@ -168,13 +168,13 @@ class st {
|
|
|
168
168
|
const r = await e.task();
|
|
169
169
|
e.resolve(r);
|
|
170
170
|
} catch (r) {
|
|
171
|
-
e.reject(r),
|
|
171
|
+
e.reject(r), f.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
|
+
f.error("[Haori]", "Error processing queue:", t);
|
|
178
178
|
} finally {
|
|
179
179
|
this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
|
|
180
180
|
}
|
|
@@ -221,7 +221,7 @@ const _ = class _ {
|
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
_.ASYNC_QUEUE = new st();
|
|
224
|
-
let
|
|
224
|
+
let F = _;
|
|
225
225
|
class X {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
@@ -229,7 +229,7 @@ class X {
|
|
|
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 X {
|
|
|
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 X {
|
|
|
247
247
|
* @returns 通知が閉じられると解決されるPromise
|
|
248
248
|
*/
|
|
249
249
|
static dialog(t) {
|
|
250
|
-
return
|
|
250
|
+
return F.enqueue(() => {
|
|
251
251
|
window.alert(t);
|
|
252
252
|
}, !0);
|
|
253
253
|
}
|
|
@@ -275,7 +275,7 @@ class X {
|
|
|
275
275
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
276
276
|
*/
|
|
277
277
|
static confirm(t) {
|
|
278
|
-
return
|
|
278
|
+
return F.enqueue(() => window.confirm(t), !0);
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
281
|
* ダイアログを開きます。
|
|
@@ -283,8 +283,8 @@ class X {
|
|
|
283
283
|
* @param element 開くダイアログのHTML要素
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
|
-
return
|
|
287
|
-
t instanceof HTMLDialogElement ? t.showModal() :
|
|
286
|
+
return F.enqueue(() => {
|
|
287
|
+
t instanceof HTMLDialogElement ? t.showModal() : f.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
@@ -293,8 +293,8 @@ class X {
|
|
|
293
293
|
* @param element 閉じるダイアログのHTML要素
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
|
-
return
|
|
297
|
-
t instanceof HTMLDialogElement ? t.close() :
|
|
296
|
+
return F.enqueue(() => {
|
|
297
|
+
t instanceof HTMLDialogElement ? t.close() : f.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
@@ -314,7 +314,7 @@ class X {
|
|
|
314
314
|
* @param level メッセージのレベル(省略可能)
|
|
315
315
|
*/
|
|
316
316
|
static addMessage(t, e, r) {
|
|
317
|
-
return
|
|
317
|
+
return F.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 X {
|
|
|
325
325
|
* @param parent メッセージをクリアする親要素
|
|
326
326
|
*/
|
|
327
327
|
static clearMessages(t) {
|
|
328
|
-
return
|
|
328
|
+
return F.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
|
});
|
|
@@ -339,7 +339,7 @@ function et() {
|
|
|
339
339
|
(r) => typeof t?.[r] == "function"
|
|
340
340
|
) ? t : X;
|
|
341
341
|
}
|
|
342
|
-
class
|
|
342
|
+
class A {
|
|
343
343
|
/**
|
|
344
344
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
345
345
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -350,7 +350,7 @@ class y {
|
|
|
350
350
|
*/
|
|
351
351
|
static getValues(t) {
|
|
352
352
|
const e = {};
|
|
353
|
-
return
|
|
353
|
+
return A.getPartValues(t, e);
|
|
354
354
|
}
|
|
355
355
|
/**
|
|
356
356
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -361,32 +361,32 @@ class y {
|
|
|
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
|
-
n ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i &&
|
|
366
|
+
n ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && f.warn(
|
|
367
367
|
"Haori",
|
|
368
|
-
`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
|
+
A.getPartValues(s, e);
|
|
372
372
|
} else if (i) {
|
|
373
373
|
const s = {};
|
|
374
374
|
for (const a of t.getChildElementFragments())
|
|
375
|
-
|
|
376
|
-
Object.keys(s).length > 0 && (e[String(i)] = s), n &&
|
|
375
|
+
A.getPartValues(a, s);
|
|
376
|
+
Object.keys(s).length > 0 && (e[String(i)] = s), n && f.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
|
+
A.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
|
|
385
385
|
}
|
|
386
386
|
s.length > 0 && (e[String(n)] = s);
|
|
387
387
|
} else
|
|
388
388
|
for (const s of t.getChildElementFragments())
|
|
389
|
-
|
|
389
|
+
A.getPartValues(s, e);
|
|
390
390
|
return e;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
@@ -399,7 +399,7 @@ class y {
|
|
|
399
399
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
400
400
|
*/
|
|
401
401
|
static setValues(t, e, r = !1) {
|
|
402
|
-
return
|
|
402
|
+
return A.setPartValues(t, e, null, r, !0);
|
|
403
403
|
}
|
|
404
404
|
/**
|
|
405
405
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -411,7 +411,7 @@ class y {
|
|
|
411
411
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
412
412
|
*/
|
|
413
413
|
static syncValues(t, e, r = !1) {
|
|
414
|
-
return
|
|
414
|
+
return A.setPartValues(t, e, null, r, !1);
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
417
|
* 単一フラグメントへ値を設定します。
|
|
@@ -434,50 +434,50 @@ class y {
|
|
|
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`), l = 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 g = e[String(a)];
|
|
441
|
+
l && Array.isArray(g) && r !== null ? s.push(
|
|
442
|
+
A.applyFragmentValue(t, g[r] ?? null, n)
|
|
443
|
+
) : typeof g > "u" || (typeof g == "string" || typeof g == "number" || typeof g == "boolean" || g === null ? s.push(A.applyFragmentValue(t, g, n)) : s.push(
|
|
444
|
+
A.applyFragmentValue(t, String(g), n)
|
|
445
445
|
));
|
|
446
446
|
}
|
|
447
447
|
} else if (o) {
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
450
|
-
for (const
|
|
448
|
+
const g = e[String(o)];
|
|
449
|
+
if (g && typeof g == "object")
|
|
450
|
+
for (const T of t.getChildElementFragments())
|
|
451
451
|
s.push(
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
452
|
+
A.setPartValues(
|
|
453
|
+
T,
|
|
454
|
+
g,
|
|
455
455
|
null,
|
|
456
456
|
i,
|
|
457
457
|
n
|
|
458
458
|
)
|
|
459
459
|
);
|
|
460
|
-
} else if (
|
|
461
|
-
const
|
|
462
|
-
if (Array.isArray(
|
|
463
|
-
const
|
|
464
|
-
for (let
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
460
|
+
} else if (l) {
|
|
461
|
+
const g = e[String(l)];
|
|
462
|
+
if (Array.isArray(g)) {
|
|
463
|
+
const T = t.getChildElementFragments();
|
|
464
|
+
for (let v = 0; v < T.length; v++) {
|
|
465
|
+
const h = T[v];
|
|
466
|
+
g.length > v ? s.push(
|
|
467
|
+
A.setPartValues(
|
|
468
|
+
h,
|
|
469
|
+
g[v],
|
|
470
|
+
v,
|
|
471
471
|
i,
|
|
472
472
|
n
|
|
473
473
|
)
|
|
474
|
-
) : s.push(
|
|
474
|
+
) : s.push(A.setPartValues(h, {}, v, i, n));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
} else
|
|
478
|
-
for (const
|
|
478
|
+
for (const g of t.getChildElementFragments())
|
|
479
479
|
s.push(
|
|
480
|
-
|
|
480
|
+
A.setPartValues(g, e, null, i, n)
|
|
481
481
|
);
|
|
482
482
|
return Promise.all(s).then(() => {
|
|
483
483
|
});
|
|
@@ -490,10 +490,10 @@ class y {
|
|
|
490
490
|
* @returns すべての初期化処理が完了するPromise
|
|
491
491
|
*/
|
|
492
492
|
static async reset(t) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
]), await
|
|
493
|
+
A.clearValues(t), await Promise.all([
|
|
494
|
+
A.clearMessages(t),
|
|
495
|
+
A.clearEachClones(t)
|
|
496
|
+
]), await F.enqueue(() => {
|
|
497
497
|
const e = t.getTarget();
|
|
498
498
|
if (e instanceof HTMLFormElement)
|
|
499
499
|
e.reset();
|
|
@@ -504,7 +504,7 @@ class y {
|
|
|
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 y {
|
|
|
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 y {
|
|
|
538
538
|
static clearValues(t) {
|
|
539
539
|
t.clearValue();
|
|
540
540
|
for (const e of t.getChildElementFragments())
|
|
541
|
-
|
|
541
|
+
A.clearValues(e);
|
|
542
542
|
}
|
|
543
543
|
/**
|
|
544
544
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -561,7 +561,7 @@ class y {
|
|
|
561
561
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
562
562
|
*/
|
|
563
563
|
static addErrorMessage(t, e, r) {
|
|
564
|
-
return
|
|
564
|
+
return A.addMessage(t, e, r, "error");
|
|
565
565
|
}
|
|
566
566
|
/**
|
|
567
567
|
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
@@ -574,10 +574,10 @@ class y {
|
|
|
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), l = A.findFragmentsByKey(t, e);
|
|
578
|
+
return l.forEach((m) => {
|
|
579
579
|
n.push(o(m.getTarget()));
|
|
580
|
-
}),
|
|
580
|
+
}), l.length === 0 && n.push(o(t.getTarget())), Promise.all(n).then(() => {
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
583
|
/**
|
|
@@ -588,7 +588,7 @@ class y {
|
|
|
588
588
|
* @returns 一致するフラグメントの配列
|
|
589
589
|
*/
|
|
590
590
|
static findFragmentsByKey(t, e) {
|
|
591
|
-
return
|
|
591
|
+
return A.findFragmentByKeyParts(t, e.split("."));
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -600,23 +600,23 @@ class y {
|
|
|
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(...A.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 l = i.substring(s + 1, a), m = Number(l);
|
|
614
614
|
if (isNaN(m))
|
|
615
|
-
|
|
615
|
+
f.error("Haori", `Invalid index: ${i}`);
|
|
616
616
|
else {
|
|
617
|
-
const
|
|
618
|
-
m <
|
|
619
|
-
...
|
|
617
|
+
const g = t.getChildElementFragments().filter((T) => T.hasAttribute(`${u.prefix}row`));
|
|
618
|
+
m < g.length && r.push(
|
|
619
|
+
...A.findFragmentByKeyParts(g[m], e.slice(1))
|
|
620
620
|
);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
@@ -624,7 +624,7 @@ class y {
|
|
|
624
624
|
}
|
|
625
625
|
} else
|
|
626
626
|
t.getChildElementFragments().forEach((n) => {
|
|
627
|
-
r.push(...
|
|
627
|
+
r.push(...A.findFragmentByKeyParts(n, e));
|
|
628
628
|
});
|
|
629
629
|
return r;
|
|
630
630
|
}
|
|
@@ -686,13 +686,13 @@ const M = class M {
|
|
|
686
686
|
*/
|
|
687
687
|
static evaluate(t, e = {}) {
|
|
688
688
|
if (t.trim() === "")
|
|
689
|
-
return
|
|
689
|
+
return f.warn("[Haori]", t, "Expression is empty"), null;
|
|
690
690
|
if (this.containsDangerousPatterns(t))
|
|
691
|
-
return
|
|
691
|
+
return f.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
692
692
|
if (this.containsForbiddenKeys(e))
|
|
693
|
-
return
|
|
693
|
+
return f.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
694
694
|
if (this.containsForbiddenBindingValues(e))
|
|
695
|
-
return
|
|
695
|
+
return f.warn(
|
|
696
696
|
"[Haori]",
|
|
697
697
|
e,
|
|
698
698
|
"Binded values contain forbidden values"
|
|
@@ -707,7 +707,7 @@ 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 f.error(
|
|
711
711
|
"[Haori]",
|
|
712
712
|
"Failed to compile expression:",
|
|
713
713
|
t,
|
|
@@ -721,7 +721,7 @@ return (${t});`;
|
|
|
721
721
|
s.push(a[o]);
|
|
722
722
|
}), this.withBlockedPropertyAccess(() => n(...s));
|
|
723
723
|
} catch (s) {
|
|
724
|
-
return
|
|
724
|
+
return f.error("[Haori]", "Expression evaluation error:", t, s), s instanceof ReferenceError ? void 0 : null;
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
/**
|
|
@@ -753,11 +753,11 @@ 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,
|
|
756
|
+
const s = e[n], a = e[n + 1] || null, o = r[r.length - 1] || null, l = e[n - 2] || null, m = e[n - 3] || null;
|
|
757
757
|
if (this.startsObjectKey(
|
|
758
758
|
o,
|
|
759
759
|
i,
|
|
760
|
-
|
|
760
|
+
l,
|
|
761
761
|
m
|
|
762
762
|
) && (s.value === "[" || s.type === "identifier" && this.FORBIDDEN_PROPERTY_NAMES.has(s.value) || s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
763
763
|
this.decodeStringLiteral(s.value)
|
|
@@ -775,8 +775,8 @@ return (${t});`;
|
|
|
775
775
|
break;
|
|
776
776
|
}
|
|
777
777
|
case "[": {
|
|
778
|
-
const
|
|
779
|
-
r.push(
|
|
778
|
+
const g = this.startsMemberAccess(i) ? "member" : "array";
|
|
779
|
+
r.push(g);
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
782
|
case "{":
|
|
@@ -1035,9 +1035,9 @@ return (${t});`;
|
|
|
1035
1035
|
get: (s, a, o) => {
|
|
1036
1036
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
1037
1037
|
return;
|
|
1038
|
-
const
|
|
1039
|
-
return typeof a == "symbol" ?
|
|
1040
|
-
|
|
1038
|
+
const l = Reflect.get(s, a, o);
|
|
1039
|
+
return typeof a == "symbol" ? l : this.wrapBoundValue(
|
|
1040
|
+
l,
|
|
1041
1041
|
e
|
|
1042
1042
|
);
|
|
1043
1043
|
},
|
|
@@ -1047,12 +1047,12 @@ return (${t});`;
|
|
|
1047
1047
|
return Reflect.getOwnPropertyDescriptor(s, a);
|
|
1048
1048
|
},
|
|
1049
1049
|
apply: (s, a, o) => {
|
|
1050
|
-
const
|
|
1050
|
+
const l = Reflect.apply(
|
|
1051
1051
|
s,
|
|
1052
1052
|
a,
|
|
1053
1053
|
o
|
|
1054
1054
|
);
|
|
1055
|
-
return this.isIteratorLike(
|
|
1055
|
+
return this.isIteratorLike(l) ? l : this.wrapBoundValue(l, e);
|
|
1056
1056
|
},
|
|
1057
1057
|
construct: (s, a, o) => this.wrapBoundValue(
|
|
1058
1058
|
Reflect.construct(
|
|
@@ -1274,7 +1274,7 @@ const I = class I {
|
|
|
1274
1274
|
e = new Z(t);
|
|
1275
1275
|
break;
|
|
1276
1276
|
default:
|
|
1277
|
-
return
|
|
1277
|
+
return f.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
1278
1278
|
}
|
|
1279
1279
|
return e;
|
|
1280
1280
|
}
|
|
@@ -1296,7 +1296,7 @@ const I = class I {
|
|
|
1296
1296
|
return Promise.resolve();
|
|
1297
1297
|
if (this.parent) {
|
|
1298
1298
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1299
|
-
return
|
|
1299
|
+
return F.enqueue(() => {
|
|
1300
1300
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1301
1301
|
}).finally(() => {
|
|
1302
1302
|
t.skipMutationNodes = e;
|
|
@@ -1304,7 +1304,7 @@ const I = class I {
|
|
|
1304
1304
|
} else {
|
|
1305
1305
|
const t = this.target.parentNode;
|
|
1306
1306
|
if (t)
|
|
1307
|
-
return
|
|
1307
|
+
return F.enqueue(() => {
|
|
1308
1308
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
1309
1309
|
});
|
|
1310
1310
|
this.mounted = !1;
|
|
@@ -1321,7 +1321,7 @@ const I = class I {
|
|
|
1321
1321
|
return Promise.resolve();
|
|
1322
1322
|
if (this.parent) {
|
|
1323
1323
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1324
|
-
return
|
|
1324
|
+
return F.enqueue(() => {
|
|
1325
1325
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1326
1326
|
}).finally(() => {
|
|
1327
1327
|
t.skipMutationNodes = e;
|
|
@@ -1451,7 +1451,7 @@ class x extends w {
|
|
|
1451
1451
|
removeChild(t) {
|
|
1452
1452
|
const e = this.children.indexOf(t);
|
|
1453
1453
|
if (e < 0) {
|
|
1454
|
-
|
|
1454
|
+
f.warn("[Haori]", "Child fragment not found.", t);
|
|
1455
1455
|
return;
|
|
1456
1456
|
}
|
|
1457
1457
|
this.children.splice(e, 1), t.setParent(null);
|
|
@@ -1476,7 +1476,7 @@ class x extends w {
|
|
|
1476
1476
|
* clone 時に runtime の hidden 状態だけを落とします。
|
|
1477
1477
|
*/
|
|
1478
1478
|
normalizeClonedVisibilityState() {
|
|
1479
|
-
(this.visible === !1 || this.getTarget().style.display === "none" || this.getTarget().hasAttribute(`${
|
|
1479
|
+
(this.visible === !1 || this.getTarget().style.display === "none" || this.getTarget().hasAttribute(`${u.prefix}if-false`)) && (this.visible = !0, this.display = "", this.getTarget().style.display = "", this.getTarget().removeAttribute(`${u.prefix}if-false`)), this.children.forEach((t) => {
|
|
1480
1480
|
t instanceof x && t.normalizeClonedVisibilityState();
|
|
1481
1481
|
});
|
|
1482
1482
|
}
|
|
@@ -1608,16 +1608,16 @@ class x extends w {
|
|
|
1608
1608
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1609
1609
|
const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
|
|
1610
1610
|
let s;
|
|
1611
|
-
return n ? s = t === !0 || t === "true" : i === "false" ? s = t === !1 : s = i === String(t), this.value = n ? s : s ? t : null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0,
|
|
1611
|
+
return n ? s = t === !0 || t === "true" : i === "false" ? s = t === !1 : s = i === String(t), this.value = n ? s : s ? t : null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0, F.enqueue(() => {
|
|
1612
1612
|
r.checked = s, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1613
1613
|
}).finally(() => {
|
|
1614
1614
|
this.skipChangeValue = !1;
|
|
1615
1615
|
}));
|
|
1616
|
-
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0,
|
|
1616
|
+
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, F.enqueue(() => {
|
|
1617
1617
|
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 })));
|
|
1618
1618
|
}).finally(() => {
|
|
1619
1619
|
this.skipChangeValue = !1;
|
|
1620
|
-
})) : (
|
|
1620
|
+
})) : (f.warn(
|
|
1621
1621
|
"[Haori]",
|
|
1622
1622
|
"setValue is not supported for this element type.",
|
|
1623
1623
|
r
|
|
@@ -1693,7 +1693,7 @@ class x extends w {
|
|
|
1693
1693
|
return Promise.resolve();
|
|
1694
1694
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1695
1695
|
const r = this.getTarget();
|
|
1696
|
-
return
|
|
1696
|
+
return F.enqueue(() => {
|
|
1697
1697
|
r.removeAttribute(t), e !== t && r.removeAttribute(e);
|
|
1698
1698
|
}).finally(() => {
|
|
1699
1699
|
this.skipMutationAttributes = !1;
|
|
@@ -1716,7 +1716,7 @@ class x extends w {
|
|
|
1716
1716
|
const n = new U(t, r);
|
|
1717
1717
|
this.attributeMap.set(t, n), this.skipMutationAttributes = !0;
|
|
1718
1718
|
const s = this.getTarget(), a = n.isForceEvaluation() ? r : this.getAttribute(t);
|
|
1719
|
-
return
|
|
1719
|
+
return F.enqueue(() => {
|
|
1720
1720
|
if (s.getAttribute(t) !== r && s.setAttribute(t, r), a === null || a === !1)
|
|
1721
1721
|
s.removeAttribute(e);
|
|
1722
1722
|
else {
|
|
@@ -1738,7 +1738,7 @@ class x extends w {
|
|
|
1738
1738
|
return Promise.resolve();
|
|
1739
1739
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1740
1740
|
const e = this.getTarget();
|
|
1741
|
-
return
|
|
1741
|
+
return F.enqueue(() => {
|
|
1742
1742
|
e.removeAttribute(t);
|
|
1743
1743
|
}).finally(() => {
|
|
1744
1744
|
this.skipMutationAttributes = !1;
|
|
@@ -1756,7 +1756,7 @@ class x extends w {
|
|
|
1756
1756
|
if (e === void 0)
|
|
1757
1757
|
return null;
|
|
1758
1758
|
const r = e.evaluate(this.getBindingData());
|
|
1759
|
-
return r.length === 1 ? r[0] :
|
|
1759
|
+
return r.length === 1 ? r[0] : B.joinEvaluateResults(r);
|
|
1760
1760
|
}
|
|
1761
1761
|
/**
|
|
1762
1762
|
* 属性の生の値を取得します。
|
|
@@ -1821,42 +1821,42 @@ class x extends w {
|
|
|
1821
1821
|
if (this.skipMutationNodes)
|
|
1822
1822
|
return Promise.resolve();
|
|
1823
1823
|
if (t === this)
|
|
1824
|
-
return
|
|
1824
|
+
return f.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1825
1825
|
const i = /* @__PURE__ */ new Set();
|
|
1826
1826
|
let n = this.parent;
|
|
1827
1827
|
for (; n; )
|
|
1828
1828
|
i.add(n), n = n.getParent();
|
|
1829
1829
|
if (i.has(t))
|
|
1830
|
-
return
|
|
1830
|
+
return f.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1831
1831
|
const s = t.getParent() === this;
|
|
1832
1832
|
let a = -1, o = -1;
|
|
1833
1833
|
s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1834
|
+
const l = t.getParent();
|
|
1835
|
+
l !== null && l.removeChild(t);
|
|
1836
1836
|
let m = r === void 0 ? e?.getTarget() || null : r;
|
|
1837
1837
|
if (e === null)
|
|
1838
1838
|
this.children.push(t);
|
|
1839
1839
|
else {
|
|
1840
|
-
let
|
|
1841
|
-
if (s ? a !== -1 && a < o ?
|
|
1842
|
-
const
|
|
1840
|
+
let T;
|
|
1841
|
+
if (s ? a !== -1 && a < o ? T = o - 1 : T = o : T = this.children.indexOf(e), T === -1) {
|
|
1842
|
+
const v = this.resolveInsertionPointFromDom(
|
|
1843
1843
|
e,
|
|
1844
1844
|
!1
|
|
1845
1845
|
);
|
|
1846
|
-
|
|
1846
|
+
v === null ? (f.warn(
|
|
1847
1847
|
"[Haori]",
|
|
1848
1848
|
"Reference child not found in children.",
|
|
1849
1849
|
e
|
|
1850
|
-
), this.children.push(t)) : (this.children.splice(
|
|
1850
|
+
), this.children.push(t)) : (this.children.splice(v.index, 0, t), m = v.referenceNode);
|
|
1851
1851
|
} else
|
|
1852
|
-
this.children.splice(
|
|
1852
|
+
this.children.splice(T, 0, t);
|
|
1853
1853
|
}
|
|
1854
1854
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1855
|
-
const
|
|
1856
|
-
return this.skipMutationNodes = !0,
|
|
1855
|
+
const g = this.skipMutationNodes;
|
|
1856
|
+
return this.skipMutationNodes = !0, F.enqueue(() => {
|
|
1857
1857
|
this.target.insertBefore(t.getTarget(), m);
|
|
1858
1858
|
}).finally(() => {
|
|
1859
|
-
this.skipMutationNodes =
|
|
1859
|
+
this.skipMutationNodes = g;
|
|
1860
1860
|
});
|
|
1861
1861
|
}
|
|
1862
1862
|
/**
|
|
@@ -1875,7 +1875,7 @@ class x extends w {
|
|
|
1875
1875
|
e,
|
|
1876
1876
|
!0
|
|
1877
1877
|
);
|
|
1878
|
-
return i === null ? (
|
|
1878
|
+
return i === null ? (f.warn(
|
|
1879
1879
|
"[Haori]",
|
|
1880
1880
|
"Reference child not found in children.",
|
|
1881
1881
|
e
|
|
@@ -1927,7 +1927,7 @@ class x extends w {
|
|
|
1927
1927
|
* @returns エレメントの非表示のPromise
|
|
1928
1928
|
*/
|
|
1929
1929
|
hide() {
|
|
1930
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1930
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${u.prefix}if-false`, ""), Promise.resolve();
|
|
1931
1931
|
}
|
|
1932
1932
|
/**
|
|
1933
1933
|
* エレメントを表示します。
|
|
@@ -1935,7 +1935,7 @@ class x extends w {
|
|
|
1935
1935
|
* @return エレメントの表示のPromise
|
|
1936
1936
|
*/
|
|
1937
1937
|
show() {
|
|
1938
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1938
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${u.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1939
1939
|
}
|
|
1940
1940
|
/**
|
|
1941
1941
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1959,7 +1959,7 @@ class O extends w {
|
|
|
1959
1959
|
* @param target 対象テキストノード
|
|
1960
1960
|
*/
|
|
1961
1961
|
constructor(t) {
|
|
1962
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1962
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new B(this.text);
|
|
1963
1963
|
}
|
|
1964
1964
|
/**
|
|
1965
1965
|
* フラグメントをクローンします。
|
|
@@ -1985,7 +1985,7 @@ class O extends w {
|
|
|
1985
1985
|
* @returns 更新のPromise
|
|
1986
1986
|
*/
|
|
1987
1987
|
setContent(t) {
|
|
1988
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1988
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new B(t), this.evaluate());
|
|
1989
1989
|
}
|
|
1990
1990
|
/**
|
|
1991
1991
|
* フラグメントを評価します。
|
|
@@ -1995,10 +1995,10 @@ class O extends w {
|
|
|
1995
1995
|
evaluate() {
|
|
1996
1996
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1997
1997
|
new Error("Parent fragment is required for raw evaluation")
|
|
1998
|
-
) :
|
|
1998
|
+
) : F.enqueue(() => {
|
|
1999
1999
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
2000
2000
|
this.parent.getBindingData()
|
|
2001
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
2001
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = B.joinEvaluateResults(
|
|
2002
2002
|
this.contents.evaluate(this.parent.getBindingData())
|
|
2003
2003
|
) : this.target.textContent = this.text;
|
|
2004
2004
|
}).finally(() => {
|
|
@@ -2040,14 +2040,14 @@ class Z extends w {
|
|
|
2040
2040
|
* @return 更新のPromise
|
|
2041
2041
|
*/
|
|
2042
2042
|
setContent(t) {
|
|
2043
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
2043
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, F.enqueue(() => {
|
|
2044
2044
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
2045
2045
|
}).finally(() => {
|
|
2046
2046
|
this.skipMutation = !1;
|
|
2047
2047
|
}));
|
|
2048
2048
|
}
|
|
2049
2049
|
}
|
|
2050
|
-
const
|
|
2050
|
+
const G = class G {
|
|
2051
2051
|
/**
|
|
2052
2052
|
* コンストラクタ。
|
|
2053
2053
|
*
|
|
@@ -2055,7 +2055,7 @@ const K = class K {
|
|
|
2055
2055
|
*/
|
|
2056
2056
|
constructor(t) {
|
|
2057
2057
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
2058
|
-
const e = [...t.matchAll(
|
|
2058
|
+
const e = [...t.matchAll(G.PLACEHOLDER_REGEX)];
|
|
2059
2059
|
let r = 0, i = !1, n = !1;
|
|
2060
2060
|
for (const s of e) {
|
|
2061
2061
|
s.index > r && this.contents.push({
|
|
@@ -2098,7 +2098,7 @@ const K = class K {
|
|
|
2098
2098
|
*/
|
|
2099
2099
|
checkRawExpressions() {
|
|
2100
2100
|
for (let t = 0; t < this.contents.length; t++)
|
|
2101
|
-
this.contents[t].type === 2 && this.contents.length > 1 && (
|
|
2101
|
+
this.contents[t].type === 2 && this.contents.length > 1 && (f.error(
|
|
2102
2102
|
"[Haori]",
|
|
2103
2103
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2104
2104
|
), this.contents[t].type = 1);
|
|
@@ -2121,7 +2121,7 @@ const K = class K {
|
|
|
2121
2121
|
} else
|
|
2122
2122
|
e.push(r.text);
|
|
2123
2123
|
} catch (i) {
|
|
2124
|
-
|
|
2124
|
+
f.error(
|
|
2125
2125
|
"[Haori]",
|
|
2126
2126
|
`Error evaluating text expression: ${r.text}`,
|
|
2127
2127
|
i
|
|
@@ -2130,9 +2130,9 @@ const K = class K {
|
|
|
2130
2130
|
}), e;
|
|
2131
2131
|
}
|
|
2132
2132
|
};
|
|
2133
|
-
|
|
2134
|
-
let
|
|
2135
|
-
const
|
|
2133
|
+
G.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2134
|
+
let B = G;
|
|
2135
|
+
const K = class K extends B {
|
|
2136
2136
|
/**
|
|
2137
2137
|
* コンストラクタ。
|
|
2138
2138
|
*
|
|
@@ -2140,7 +2140,7 @@ const G = class G extends $ {
|
|
|
2140
2140
|
* @param text 属性値
|
|
2141
2141
|
*/
|
|
2142
2142
|
constructor(t, e) {
|
|
2143
|
-
super(e), this.forceEvaluation =
|
|
2143
|
+
super(e), this.forceEvaluation = K.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
2144
2144
|
}
|
|
2145
2145
|
/**
|
|
2146
2146
|
* 強制評価フラグを取得します。
|
|
@@ -2168,27 +2168,27 @@ const G = class G extends $ {
|
|
|
2168
2168
|
} else
|
|
2169
2169
|
e.push(r.text);
|
|
2170
2170
|
} catch (i) {
|
|
2171
|
-
|
|
2171
|
+
f.error(
|
|
2172
2172
|
"[Haori]",
|
|
2173
2173
|
`Error evaluating attribute expression: ${r.text}`,
|
|
2174
2174
|
i
|
|
2175
2175
|
), e.push("");
|
|
2176
2176
|
}
|
|
2177
|
-
}), this.forceEvaluation && e.length > 1 ? (
|
|
2177
|
+
}), this.forceEvaluation && e.length > 1 ? (f.error(
|
|
2178
2178
|
"[Haori]",
|
|
2179
2179
|
"each or if expressions must have a single content.",
|
|
2180
2180
|
e
|
|
2181
2181
|
), [e[0]]) : e;
|
|
2182
2182
|
}
|
|
2183
2183
|
};
|
|
2184
|
-
|
|
2184
|
+
K.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2185
2185
|
"data-if",
|
|
2186
2186
|
"hor-if",
|
|
2187
2187
|
"data-each",
|
|
2188
2188
|
"hor-each"
|
|
2189
2189
|
];
|
|
2190
|
-
let U =
|
|
2191
|
-
class
|
|
2190
|
+
let U = K;
|
|
2191
|
+
class N {
|
|
2192
2192
|
/**
|
|
2193
2193
|
* カスタムイベントを発火します。
|
|
2194
2194
|
*
|
|
@@ -2212,7 +2212,7 @@ class T {
|
|
|
2212
2212
|
* @param version ライブラリバージョン
|
|
2213
2213
|
*/
|
|
2214
2214
|
static ready(t) {
|
|
2215
|
-
|
|
2215
|
+
N.dispatch(document, "ready", { version: t });
|
|
2216
2216
|
}
|
|
2217
2217
|
/**
|
|
2218
2218
|
* renderイベントを発火します。
|
|
@@ -2220,7 +2220,7 @@ class T {
|
|
|
2220
2220
|
* @param target 評価対象要素
|
|
2221
2221
|
*/
|
|
2222
2222
|
static render(t) {
|
|
2223
|
-
|
|
2223
|
+
N.dispatch(t, "render", { target: t });
|
|
2224
2224
|
}
|
|
2225
2225
|
/**
|
|
2226
2226
|
* importstartイベントを発火します。
|
|
@@ -2229,7 +2229,7 @@ class T {
|
|
|
2229
2229
|
* @param url インポート対象URL
|
|
2230
2230
|
*/
|
|
2231
2231
|
static importStart(t, e) {
|
|
2232
|
-
|
|
2232
|
+
N.dispatch(t, "importstart", {
|
|
2233
2233
|
url: e,
|
|
2234
2234
|
startedAt: performance.now()
|
|
2235
2235
|
});
|
|
@@ -2243,7 +2243,7 @@ class T {
|
|
|
2243
2243
|
* @param startedAt 開始時刻
|
|
2244
2244
|
*/
|
|
2245
2245
|
static importEnd(t, e, r, i) {
|
|
2246
|
-
|
|
2246
|
+
N.dispatch(t, "importend", {
|
|
2247
2247
|
url: e,
|
|
2248
2248
|
bytes: r,
|
|
2249
2249
|
durationMs: performance.now() - i
|
|
@@ -2257,7 +2257,7 @@ class T {
|
|
|
2257
2257
|
* @param error エラー内容
|
|
2258
2258
|
*/
|
|
2259
2259
|
static importError(t, e, r) {
|
|
2260
|
-
|
|
2260
|
+
N.dispatch(t, "importerror", { url: e, error: r });
|
|
2261
2261
|
}
|
|
2262
2262
|
/**
|
|
2263
2263
|
* bindchangeイベントを発火します。
|
|
@@ -2269,11 +2269,11 @@ class T {
|
|
|
2269
2269
|
*/
|
|
2270
2270
|
static bindChange(t, e, r, i = "other") {
|
|
2271
2271
|
const n = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
|
|
2272
|
-
for (const
|
|
2273
|
-
const m = e?.[
|
|
2274
|
-
m !==
|
|
2272
|
+
for (const l of o) {
|
|
2273
|
+
const m = e?.[l], g = r[l];
|
|
2274
|
+
m !== g && n.push(l);
|
|
2275
2275
|
}
|
|
2276
|
-
|
|
2276
|
+
N.dispatch(t, "bindchange", {
|
|
2277
2277
|
previous: e || {},
|
|
2278
2278
|
next: r,
|
|
2279
2279
|
changedKeys: n,
|
|
@@ -2289,7 +2289,7 @@ class T {
|
|
|
2289
2289
|
* @param order 現在の順序
|
|
2290
2290
|
*/
|
|
2291
2291
|
static eachUpdate(t, e, r, i) {
|
|
2292
|
-
|
|
2292
|
+
N.dispatch(t, "eachupdate", {
|
|
2293
2293
|
added: e,
|
|
2294
2294
|
removed: r,
|
|
2295
2295
|
order: i,
|
|
@@ -2305,7 +2305,7 @@ class T {
|
|
|
2305
2305
|
* @param item 行データ
|
|
2306
2306
|
*/
|
|
2307
2307
|
static rowAdd(t, e, r, i) {
|
|
2308
|
-
|
|
2308
|
+
N.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
2309
2309
|
}
|
|
2310
2310
|
/**
|
|
2311
2311
|
* rowremoveイベントを発火します。
|
|
@@ -2315,7 +2315,7 @@ class T {
|
|
|
2315
2315
|
* @param index インデックス
|
|
2316
2316
|
*/
|
|
2317
2317
|
static rowRemove(t, e, r) {
|
|
2318
|
-
|
|
2318
|
+
N.dispatch(t, "rowremove", { key: e, index: r });
|
|
2319
2319
|
}
|
|
2320
2320
|
/**
|
|
2321
2321
|
* rowmoveイベントを発火します。
|
|
@@ -2326,7 +2326,7 @@ class T {
|
|
|
2326
2326
|
* @param to 移動後インデックス
|
|
2327
2327
|
*/
|
|
2328
2328
|
static rowMove(t, e, r, i) {
|
|
2329
|
-
|
|
2329
|
+
N.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
2330
2330
|
}
|
|
2331
2331
|
/**
|
|
2332
2332
|
* showイベントを発火します。
|
|
@@ -2334,7 +2334,7 @@ class T {
|
|
|
2334
2334
|
* @param target data-if要素
|
|
2335
2335
|
*/
|
|
2336
2336
|
static show(t) {
|
|
2337
|
-
|
|
2337
|
+
N.dispatch(t, "show", { visible: !0 });
|
|
2338
2338
|
}
|
|
2339
2339
|
/**
|
|
2340
2340
|
* hideイベントを発火します。
|
|
@@ -2342,7 +2342,7 @@ class T {
|
|
|
2342
2342
|
* @param target data-if要素
|
|
2343
2343
|
*/
|
|
2344
2344
|
static hide(t) {
|
|
2345
|
-
|
|
2345
|
+
N.dispatch(t, "hide", { visible: !1 });
|
|
2346
2346
|
}
|
|
2347
2347
|
/**
|
|
2348
2348
|
* fetchstartイベントを発火します。
|
|
@@ -2355,7 +2355,7 @@ class T {
|
|
|
2355
2355
|
* @return 戻り値はありません。
|
|
2356
2356
|
*/
|
|
2357
2357
|
static fetchStart(t, e, r, i, n) {
|
|
2358
|
-
|
|
2358
|
+
N.dispatch(t, "fetchstart", {
|
|
2359
2359
|
url: e,
|
|
2360
2360
|
options: r || {},
|
|
2361
2361
|
payload: i,
|
|
@@ -2372,7 +2372,7 @@ class T {
|
|
|
2372
2372
|
* @param startedAt 開始時刻
|
|
2373
2373
|
*/
|
|
2374
2374
|
static fetchEnd(t, e, r, i) {
|
|
2375
|
-
|
|
2375
|
+
N.dispatch(t, "fetchend", {
|
|
2376
2376
|
url: e,
|
|
2377
2377
|
status: r,
|
|
2378
2378
|
durationMs: performance.now() - i
|
|
@@ -2388,7 +2388,7 @@ class T {
|
|
|
2388
2388
|
* @param startedAt 開始時刻(存在する場合)
|
|
2389
2389
|
*/
|
|
2390
2390
|
static fetchError(t, e, r, i, n) {
|
|
2391
|
-
|
|
2391
|
+
N.dispatch(t, "fetcherror", {
|
|
2392
2392
|
url: e,
|
|
2393
2393
|
status: i,
|
|
2394
2394
|
error: r,
|
|
@@ -2411,20 +2411,20 @@ function W() {
|
|
|
2411
2411
|
) ? t : X;
|
|
2412
2412
|
}
|
|
2413
2413
|
const lt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2414
|
-
function ut(
|
|
2415
|
-
return lt.has(
|
|
2414
|
+
function ut(R) {
|
|
2415
|
+
return lt.has(R.toUpperCase());
|
|
2416
2416
|
}
|
|
2417
|
-
function ct(
|
|
2417
|
+
function ct(R, t) {
|
|
2418
2418
|
for (const [e, r] of Object.entries(t))
|
|
2419
|
-
r !== void 0 && (r === null ?
|
|
2420
|
-
|
|
2421
|
-
}) : typeof r == "object" || typeof r == "function" ?
|
|
2419
|
+
r !== void 0 && (r === null ? R.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2420
|
+
R.append(e, String(i));
|
|
2421
|
+
}) : typeof r == "object" || typeof r == "function" ? R.append(e, JSON.stringify(r)) : R.append(e, String(r)));
|
|
2422
2422
|
}
|
|
2423
|
-
function ht(
|
|
2424
|
-
const e = new URL(
|
|
2423
|
+
function ht(R, t) {
|
|
2424
|
+
const e = new URL(R, window.location.href), r = new URLSearchParams(e.search);
|
|
2425
2425
|
return ct(r, t), e.search = r.toString(), e.toString();
|
|
2426
2426
|
}
|
|
2427
|
-
const
|
|
2427
|
+
const c = class c {
|
|
2428
2428
|
/**
|
|
2429
2429
|
* イベント属性名を正しく生成します。
|
|
2430
2430
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2433,7 +2433,7 @@ const u = class u {
|
|
|
2433
2433
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2434
2434
|
*/
|
|
2435
2435
|
static attrName(t, e, r = !1) {
|
|
2436
|
-
return t ? `${
|
|
2436
|
+
return t ? `${u.prefix}${t}-${e}` : r ? `${u.prefix}fetch-${e}` : `${u.prefix}${e}`;
|
|
2437
2437
|
}
|
|
2438
2438
|
/**
|
|
2439
2439
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2444,7 +2444,7 @@ const u = class u {
|
|
|
2444
2444
|
*/
|
|
2445
2445
|
static resolveDataParamString(t, e) {
|
|
2446
2446
|
return t.replace(
|
|
2447
|
-
|
|
2447
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2448
2448
|
(r, i, n) => {
|
|
2449
2449
|
const s = j.evaluate(
|
|
2450
2450
|
i ?? n ?? "",
|
|
@@ -2501,7 +2501,7 @@ const u = class u {
|
|
|
2501
2501
|
static stringifyJsonTemplateStringContent(t) {
|
|
2502
2502
|
if (t == null || Number.isNaN(t))
|
|
2503
2503
|
return "";
|
|
2504
|
-
const e = typeof t == "object" ?
|
|
2504
|
+
const e = typeof t == "object" ? c.stringifyJsonTemplateValue(t) : String(t);
|
|
2505
2505
|
return JSON.stringify(e).slice(1, -1);
|
|
2506
2506
|
}
|
|
2507
2507
|
/**
|
|
@@ -2513,13 +2513,13 @@ const u = class u {
|
|
|
2513
2513
|
*/
|
|
2514
2514
|
static resolveDataJsonString(t, e) {
|
|
2515
2515
|
return t.replace(
|
|
2516
|
-
|
|
2516
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2517
2517
|
(r, i, n, s) => {
|
|
2518
2518
|
const a = j.evaluate(
|
|
2519
2519
|
i ?? n ?? "",
|
|
2520
2520
|
e
|
|
2521
2521
|
);
|
|
2522
|
-
return
|
|
2522
|
+
return c.isJsonStringContext(t, s) ? c.stringifyJsonTemplateStringContent(a) : c.stringifyJsonTemplateValue(a);
|
|
2523
2523
|
}
|
|
2524
2524
|
);
|
|
2525
2525
|
}
|
|
@@ -2537,13 +2537,13 @@ const u = class u {
|
|
|
2537
2537
|
if (typeof i != "string" || r === null)
|
|
2538
2538
|
return null;
|
|
2539
2539
|
const n = r.trim();
|
|
2540
|
-
return
|
|
2541
|
-
|
|
2540
|
+
return c.SINGLE_PLACEHOLDER_REGEX.test(n) ? P.parseDataBind(i) : n.startsWith("{") || n.startsWith("[") ? P.parseDataBind(
|
|
2541
|
+
c.resolveDataJsonString(
|
|
2542
2542
|
r,
|
|
2543
2543
|
t.getBindingData()
|
|
2544
2544
|
)
|
|
2545
|
-
) :
|
|
2546
|
-
|
|
2545
|
+
) : P.parseDataBind(
|
|
2546
|
+
c.resolveDataParamString(r, t.getBindingData())
|
|
2547
2547
|
);
|
|
2548
2548
|
}
|
|
2549
2549
|
/**
|
|
@@ -2558,30 +2558,30 @@ const u = class u {
|
|
|
2558
2558
|
targetFragment: t
|
|
2559
2559
|
};
|
|
2560
2560
|
if (e) {
|
|
2561
|
-
if (t.hasAttribute(
|
|
2562
|
-
|
|
2561
|
+
if (t.hasAttribute(c.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(c.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2562
|
+
c.attrName(e, "confirm")
|
|
2563
2563
|
).replace(/\\n/g, `
|
|
2564
|
-
`)), t.hasAttribute(
|
|
2564
|
+
`)), t.hasAttribute(c.attrName(e, "data")) && (r.data = c.resolveDataAttribute(
|
|
2565
2565
|
t,
|
|
2566
|
-
|
|
2567
|
-
)), t.hasAttribute(
|
|
2568
|
-
const
|
|
2569
|
-
|
|
2566
|
+
c.attrName(e, "data")
|
|
2567
|
+
)), t.hasAttribute(c.attrName(e, "form"))) {
|
|
2568
|
+
const h = t.getRawAttribute(
|
|
2569
|
+
c.attrName(e, "form")
|
|
2570
2570
|
);
|
|
2571
|
-
if (
|
|
2572
|
-
const
|
|
2573
|
-
|
|
2574
|
-
w.get(
|
|
2575
|
-
) :
|
|
2571
|
+
if (h) {
|
|
2572
|
+
const d = document.body.querySelector(h);
|
|
2573
|
+
d !== null ? r.formFragment = A.getFormFragment(
|
|
2574
|
+
w.get(d)
|
|
2575
|
+
) : f.error(
|
|
2576
2576
|
"Haori",
|
|
2577
|
-
`Form element not found: ${
|
|
2577
|
+
`Form element not found: ${h} (${c.attrName(e, "form")})`
|
|
2578
2578
|
);
|
|
2579
2579
|
} else
|
|
2580
|
-
r.formFragment =
|
|
2581
|
-
} else e === "change" && (r.formFragment =
|
|
2582
|
-
if (t.hasAttribute(`${
|
|
2583
|
-
const
|
|
2584
|
-
`${
|
|
2580
|
+
r.formFragment = A.getFormFragment(t);
|
|
2581
|
+
} else e === "change" && (r.formFragment = A.getFormFragment(t));
|
|
2582
|
+
if (t.hasAttribute(`${u.prefix}${e}-before-run`)) {
|
|
2583
|
+
const h = t.getRawAttribute(
|
|
2584
|
+
`${u.prefix}${e}-before-run`
|
|
2585
2585
|
);
|
|
2586
2586
|
try {
|
|
2587
2587
|
r.beforeCallback = new Function(
|
|
@@ -2589,70 +2589,70 @@ const u = class u {
|
|
|
2589
2589
|
"fetchOptions",
|
|
2590
2590
|
`
|
|
2591
2591
|
"use strict";
|
|
2592
|
-
${
|
|
2592
|
+
${h}
|
|
2593
2593
|
`
|
|
2594
2594
|
);
|
|
2595
|
-
} catch (
|
|
2596
|
-
|
|
2595
|
+
} catch (d) {
|
|
2596
|
+
f.error("Haori", `Invalid before script: ${d}`);
|
|
2597
2597
|
}
|
|
2598
2598
|
}
|
|
2599
2599
|
}
|
|
2600
|
-
const i =
|
|
2600
|
+
const i = c.attrName(e, "fetch"), n = t.hasAttribute(i);
|
|
2601
2601
|
n && (r.fetchUrl = t.getAttribute(i));
|
|
2602
2602
|
const s = {};
|
|
2603
2603
|
if (e) {
|
|
2604
|
-
const
|
|
2605
|
-
t.hasAttribute(
|
|
2606
|
-
|
|
2604
|
+
const h = c.attrName(e, "fetch-method");
|
|
2605
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2606
|
+
h
|
|
2607
2607
|
));
|
|
2608
2608
|
} else {
|
|
2609
|
-
const
|
|
2610
|
-
t.hasAttribute(
|
|
2611
|
-
|
|
2609
|
+
const h = c.attrName(null, "method", !0);
|
|
2610
|
+
t.hasAttribute(h) && (s.method = t.getAttribute(
|
|
2611
|
+
h
|
|
2612
2612
|
));
|
|
2613
2613
|
}
|
|
2614
2614
|
if (e) {
|
|
2615
|
-
const
|
|
2616
|
-
if (t.hasAttribute(
|
|
2617
|
-
const
|
|
2618
|
-
|
|
2615
|
+
const h = c.attrName(e, "fetch-headers");
|
|
2616
|
+
if (t.hasAttribute(h)) {
|
|
2617
|
+
const d = t.getRawAttribute(
|
|
2618
|
+
h
|
|
2619
2619
|
);
|
|
2620
2620
|
try {
|
|
2621
|
-
s.headers =
|
|
2622
|
-
} catch (
|
|
2623
|
-
|
|
2621
|
+
s.headers = P.parseDataBind(d);
|
|
2622
|
+
} catch (b) {
|
|
2623
|
+
f.error("Haori", `Invalid fetch headers: ${b}`);
|
|
2624
2624
|
}
|
|
2625
2625
|
}
|
|
2626
2626
|
} else {
|
|
2627
|
-
const
|
|
2627
|
+
const h = c.attrName(
|
|
2628
2628
|
null,
|
|
2629
2629
|
"headers",
|
|
2630
2630
|
!0
|
|
2631
2631
|
);
|
|
2632
|
-
if (t.hasAttribute(
|
|
2633
|
-
const
|
|
2634
|
-
|
|
2632
|
+
if (t.hasAttribute(h)) {
|
|
2633
|
+
const d = t.getRawAttribute(
|
|
2634
|
+
h
|
|
2635
2635
|
);
|
|
2636
2636
|
try {
|
|
2637
|
-
s.headers =
|
|
2638
|
-
} catch (
|
|
2639
|
-
|
|
2637
|
+
s.headers = P.parseDataBind(d);
|
|
2638
|
+
} catch (b) {
|
|
2639
|
+
f.error("Haori", `Invalid fetch headers: ${b}`);
|
|
2640
2640
|
}
|
|
2641
2641
|
}
|
|
2642
2642
|
}
|
|
2643
2643
|
if (e) {
|
|
2644
|
-
const
|
|
2644
|
+
const h = c.attrName(
|
|
2645
2645
|
e,
|
|
2646
2646
|
"fetch-content-type"
|
|
2647
2647
|
);
|
|
2648
|
-
if (t.hasAttribute(
|
|
2648
|
+
if (t.hasAttribute(h))
|
|
2649
2649
|
s.headers = {
|
|
2650
2650
|
...s.headers,
|
|
2651
|
-
"Content-Type": t.getAttribute(
|
|
2651
|
+
"Content-Type": t.getAttribute(h)
|
|
2652
2652
|
};
|
|
2653
2653
|
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2654
|
-
let
|
|
2655
|
-
s.headers && typeof s.headers == "object" && (
|
|
2654
|
+
let d = !1;
|
|
2655
|
+
s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
|
|
2656
2656
|
...s.headers,
|
|
2657
2657
|
"Content-Type": "application/json"
|
|
2658
2658
|
});
|
|
@@ -2661,19 +2661,19 @@ ${c}
|
|
|
2661
2661
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2662
2662
|
});
|
|
2663
2663
|
} else {
|
|
2664
|
-
const
|
|
2664
|
+
const h = c.attrName(
|
|
2665
2665
|
null,
|
|
2666
2666
|
"content-type",
|
|
2667
2667
|
!0
|
|
2668
2668
|
);
|
|
2669
|
-
if (t.hasAttribute(
|
|
2669
|
+
if (t.hasAttribute(h))
|
|
2670
2670
|
s.headers = {
|
|
2671
2671
|
...s.headers,
|
|
2672
|
-
"Content-Type": t.getAttribute(
|
|
2672
|
+
"Content-Type": t.getAttribute(h)
|
|
2673
2673
|
};
|
|
2674
2674
|
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2675
|
-
let
|
|
2676
|
-
s.headers && typeof s.headers == "object" && (
|
|
2675
|
+
let d = !1;
|
|
2676
|
+
s.headers && typeof s.headers == "object" && (d = "Content-Type" in s.headers), d || (s.headers = {
|
|
2677
2677
|
...s.headers,
|
|
2678
2678
|
"Content-Type": "application/json"
|
|
2679
2679
|
});
|
|
@@ -2683,122 +2683,122 @@ ${c}
|
|
|
2683
2683
|
});
|
|
2684
2684
|
}
|
|
2685
2685
|
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2686
|
-
const a = e ?
|
|
2686
|
+
const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
|
|
2687
2687
|
if (t.hasAttribute(a)) {
|
|
2688
|
-
const
|
|
2689
|
-
if (
|
|
2690
|
-
const
|
|
2691
|
-
|
|
2692
|
-
const
|
|
2693
|
-
|
|
2694
|
-
})) :
|
|
2688
|
+
const h = t.getRawAttribute(a);
|
|
2689
|
+
if (h) {
|
|
2690
|
+
const d = document.body.querySelectorAll(h);
|
|
2691
|
+
d.length > 0 ? (r.bindFragments = [], d.forEach((b) => {
|
|
2692
|
+
const E = w.get(b);
|
|
2693
|
+
E && r.bindFragments.push(E);
|
|
2694
|
+
})) : f.error(
|
|
2695
2695
|
"Haori",
|
|
2696
|
-
`Bind element not found: ${
|
|
2696
|
+
`Bind element not found: ${h} (${a})`
|
|
2697
2697
|
);
|
|
2698
2698
|
}
|
|
2699
2699
|
}
|
|
2700
|
-
const o =
|
|
2700
|
+
const o = c.attrName(e, "bind-arg"), l = c.attrName(
|
|
2701
2701
|
null,
|
|
2702
2702
|
"arg",
|
|
2703
2703
|
!0
|
|
2704
|
-
), m =
|
|
2704
|
+
), m = c.attrName(
|
|
2705
2705
|
null,
|
|
2706
2706
|
"bind-arg",
|
|
2707
2707
|
!0
|
|
2708
2708
|
);
|
|
2709
|
-
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(
|
|
2710
|
-
|
|
2709
|
+
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(l) ? r.bindArg = t.getRawAttribute(
|
|
2710
|
+
l
|
|
2711
2711
|
) : t.hasAttribute(m) && (r.bindArg = t.getRawAttribute(m));
|
|
2712
|
-
const
|
|
2713
|
-
if (t.hasAttribute(
|
|
2714
|
-
const
|
|
2715
|
-
r.bindParams =
|
|
2712
|
+
const g = e ? c.attrName(e, "bind-params") : c.attrName(null, "bind-params", !0);
|
|
2713
|
+
if (t.hasAttribute(g)) {
|
|
2714
|
+
const h = t.getRawAttribute(g);
|
|
2715
|
+
r.bindParams = h.split("&").map((d) => d.trim());
|
|
2716
2716
|
}
|
|
2717
|
-
const
|
|
2718
|
-
if (t.hasAttribute(
|
|
2719
|
-
const
|
|
2720
|
-
r.bindAppendParams =
|
|
2717
|
+
const T = e ? c.attrName(e, "bind-append") : c.attrName(null, "bind-append", !0);
|
|
2718
|
+
if (t.hasAttribute(T)) {
|
|
2719
|
+
const h = t.getRawAttribute(T);
|
|
2720
|
+
r.bindAppendParams = h.split("&").map((d) => d.trim()).filter(Boolean);
|
|
2721
2721
|
}
|
|
2722
|
-
const
|
|
2723
|
-
if (
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2722
|
+
const v = e ? c.attrName(e, "copy-params") : null;
|
|
2723
|
+
if (v && t.hasAttribute(v)) {
|
|
2724
|
+
const h = t.getRawAttribute(
|
|
2725
|
+
v
|
|
2726
2726
|
);
|
|
2727
|
-
r.copyParams =
|
|
2727
|
+
r.copyParams = h.split("&").map((d) => d.trim()).filter(Boolean);
|
|
2728
2728
|
}
|
|
2729
2729
|
if (e) {
|
|
2730
|
-
if (t.hasAttribute(
|
|
2731
|
-
const
|
|
2732
|
-
|
|
2730
|
+
if (t.hasAttribute(c.attrName(e, "adjust"))) {
|
|
2731
|
+
const d = t.getRawAttribute(
|
|
2732
|
+
c.attrName(e, "adjust")
|
|
2733
2733
|
);
|
|
2734
|
-
if (
|
|
2735
|
-
const
|
|
2736
|
-
|
|
2737
|
-
const
|
|
2738
|
-
|
|
2739
|
-
})) :
|
|
2734
|
+
if (d) {
|
|
2735
|
+
const b = document.body.querySelectorAll(d);
|
|
2736
|
+
b.length > 0 ? (r.adjustFragments = [], b.forEach((E) => {
|
|
2737
|
+
const y = w.get(E);
|
|
2738
|
+
y && r.adjustFragments.push(y);
|
|
2739
|
+
})) : f.error(
|
|
2740
2740
|
"Haori",
|
|
2741
|
-
`Adjust element not found: ${
|
|
2741
|
+
`Adjust element not found: ${d} (${c.attrName(e, "adjust")})`
|
|
2742
2742
|
);
|
|
2743
2743
|
}
|
|
2744
|
-
if (t.hasAttribute(
|
|
2745
|
-
const
|
|
2746
|
-
|
|
2747
|
-
),
|
|
2748
|
-
isNaN(
|
|
2744
|
+
if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
|
|
2745
|
+
const b = t.getRawAttribute(
|
|
2746
|
+
c.attrName(e, "adjust-value")
|
|
2747
|
+
), E = Number(b);
|
|
2748
|
+
isNaN(E) || (r.adjustValue = E);
|
|
2749
2749
|
}
|
|
2750
2750
|
}
|
|
2751
|
-
if (t.hasAttribute(
|
|
2752
|
-
const
|
|
2753
|
-
`${
|
|
2751
|
+
if (t.hasAttribute(c.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(c.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(c.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(c.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${u.prefix}${e}-after-run`)) {
|
|
2752
|
+
const d = t.getRawAttribute(
|
|
2753
|
+
`${u.prefix}${e}-after-run`
|
|
2754
2754
|
);
|
|
2755
2755
|
try {
|
|
2756
2756
|
r.afterCallback = new Function(
|
|
2757
2757
|
"response",
|
|
2758
2758
|
`
|
|
2759
2759
|
"use strict";
|
|
2760
|
-
${
|
|
2760
|
+
${d}
|
|
2761
2761
|
`
|
|
2762
2762
|
);
|
|
2763
|
-
} catch (
|
|
2764
|
-
|
|
2763
|
+
} catch (b) {
|
|
2764
|
+
f.error("Haori", `Invalid after script: ${b}`);
|
|
2765
2765
|
}
|
|
2766
2766
|
}
|
|
2767
|
-
if (t.hasAttribute(
|
|
2768
|
-
|
|
2767
|
+
if (t.hasAttribute(c.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2768
|
+
c.attrName(e, "dialog")
|
|
2769
2769
|
).replace(/\\n/g, `
|
|
2770
|
-
`)), t.hasAttribute(
|
|
2770
|
+
`)), t.hasAttribute(c.attrName(e, "toast"))) {
|
|
2771
2771
|
r.toastMessage = t.getAttribute(
|
|
2772
|
-
|
|
2772
|
+
c.attrName(e, "toast")
|
|
2773
2773
|
);
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2776
|
-
),
|
|
2777
|
-
r.toastLevel =
|
|
2774
|
+
const d = t.getRawAttribute(
|
|
2775
|
+
c.attrName(e, "toast-level")
|
|
2776
|
+
), E = ["info", "warning", "error", "success"].includes(d);
|
|
2777
|
+
r.toastLevel = E ? d : null;
|
|
2778
2778
|
}
|
|
2779
|
-
if (t.hasAttribute(
|
|
2780
|
-
|
|
2781
|
-
)), t.hasAttribute(
|
|
2782
|
-
|
|
2783
|
-
)), t.hasAttribute(
|
|
2784
|
-
|
|
2785
|
-
)), t.hasAttribute(
|
|
2779
|
+
if (t.hasAttribute(c.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2780
|
+
c.attrName(e, "redirect")
|
|
2781
|
+
)), t.hasAttribute(c.attrName(e, "scroll-error")) && (r.scrollOnError = !0), t.hasAttribute(c.attrName(e, "scroll")) && (r.scrollTarget = t.getAttribute(
|
|
2782
|
+
c.attrName(e, "scroll")
|
|
2783
|
+
)), t.hasAttribute(c.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2784
|
+
c.attrName(e, "history")
|
|
2785
|
+
)), t.hasAttribute(c.attrName(e, "history-data")) && (r.historyData = c.resolveDataAttribute(
|
|
2786
2786
|
t,
|
|
2787
|
-
|
|
2788
|
-
)), t.hasAttribute(
|
|
2789
|
-
const
|
|
2790
|
-
|
|
2787
|
+
c.attrName(e, "history-data")
|
|
2788
|
+
)), t.hasAttribute(c.attrName(e, "history-form"))) {
|
|
2789
|
+
const d = t.getRawAttribute(
|
|
2790
|
+
c.attrName(e, "history-form")
|
|
2791
2791
|
);
|
|
2792
|
-
if (
|
|
2793
|
-
const
|
|
2794
|
-
|
|
2795
|
-
w.get(
|
|
2796
|
-
) :
|
|
2792
|
+
if (d) {
|
|
2793
|
+
const b = document.body.querySelector(d);
|
|
2794
|
+
b !== null ? r.historyFormFragment = A.getFormFragment(
|
|
2795
|
+
w.get(b)
|
|
2796
|
+
) : f.error(
|
|
2797
2797
|
"Haori",
|
|
2798
|
-
`Form element not found: ${
|
|
2798
|
+
`Form element not found: ${d} (${c.attrName(e, "history-form")})`
|
|
2799
2799
|
);
|
|
2800
2800
|
} else
|
|
2801
|
-
r.historyFormFragment =
|
|
2801
|
+
r.historyFormFragment = A.getFormFragment(t);
|
|
2802
2802
|
}
|
|
2803
2803
|
[
|
|
2804
2804
|
"reset",
|
|
@@ -2807,54 +2807,54 @@ ${f}
|
|
|
2807
2807
|
"copy",
|
|
2808
2808
|
"open",
|
|
2809
2809
|
"close"
|
|
2810
|
-
].forEach((
|
|
2811
|
-
const
|
|
2812
|
-
if (!t.hasAttribute(
|
|
2810
|
+
].forEach((d) => {
|
|
2811
|
+
const b = c.attrName(e, d);
|
|
2812
|
+
if (!t.hasAttribute(b))
|
|
2813
2813
|
return;
|
|
2814
|
-
const
|
|
2815
|
-
if (
|
|
2814
|
+
const E = t.getRawAttribute(b), y = [];
|
|
2815
|
+
if (E ? (document.body.querySelectorAll(E).forEach((J) => {
|
|
2816
2816
|
const tt = w.get(J);
|
|
2817
|
-
tt &&
|
|
2818
|
-
}),
|
|
2819
|
-
switch (
|
|
2817
|
+
tt && y.push(tt);
|
|
2818
|
+
}), y.length === 0 && f.error("Haori", `Element not found: ${E} (${b})`)) : y.push(t), y.length > 0)
|
|
2819
|
+
switch (d) {
|
|
2820
2820
|
case "reset":
|
|
2821
|
-
r.resetFragments =
|
|
2821
|
+
r.resetFragments = y;
|
|
2822
2822
|
break;
|
|
2823
2823
|
case "refetch":
|
|
2824
|
-
r.refetchFragments =
|
|
2824
|
+
r.refetchFragments = y;
|
|
2825
2825
|
break;
|
|
2826
2826
|
case "click":
|
|
2827
|
-
r.clickFragments =
|
|
2827
|
+
r.clickFragments = y;
|
|
2828
2828
|
break;
|
|
2829
2829
|
case "copy":
|
|
2830
|
-
r.copyFragments =
|
|
2830
|
+
r.copyFragments = y;
|
|
2831
2831
|
break;
|
|
2832
2832
|
case "open":
|
|
2833
|
-
r.openFragments =
|
|
2833
|
+
r.openFragments = y;
|
|
2834
2834
|
break;
|
|
2835
2835
|
case "close":
|
|
2836
|
-
r.closeFragments =
|
|
2836
|
+
r.closeFragments = y;
|
|
2837
2837
|
break;
|
|
2838
2838
|
}
|
|
2839
2839
|
});
|
|
2840
2840
|
}
|
|
2841
|
-
if (!e && (t.hasAttribute(
|
|
2841
|
+
if (!e && (t.hasAttribute(c.attrName(null, "data", !0)) && (r.data = c.resolveDataAttribute(
|
|
2842
2842
|
t,
|
|
2843
|
-
|
|
2844
|
-
)), t.hasAttribute(
|
|
2845
|
-
const
|
|
2846
|
-
|
|
2843
|
+
c.attrName(null, "data", !0)
|
|
2844
|
+
)), t.hasAttribute(c.attrName(null, "form", !0)))) {
|
|
2845
|
+
const h = t.getRawAttribute(
|
|
2846
|
+
c.attrName(null, "form", !0)
|
|
2847
2847
|
);
|
|
2848
|
-
if (
|
|
2849
|
-
const
|
|
2850
|
-
|
|
2851
|
-
w.get(
|
|
2852
|
-
) :
|
|
2848
|
+
if (h) {
|
|
2849
|
+
const d = document.body.querySelector(h);
|
|
2850
|
+
d !== null ? r.formFragment = A.getFormFragment(
|
|
2851
|
+
w.get(d)
|
|
2852
|
+
) : f.error(
|
|
2853
2853
|
"Haori",
|
|
2854
|
-
`Form element not found: ${
|
|
2854
|
+
`Form element not found: ${h} (${c.attrName(null, "fetch-form", !0)})`
|
|
2855
2855
|
);
|
|
2856
2856
|
} else
|
|
2857
|
-
r.formFragment =
|
|
2857
|
+
r.formFragment = A.getFormFragment(t);
|
|
2858
2858
|
}
|
|
2859
2859
|
return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2860
2860
|
}
|
|
@@ -2877,7 +2877,7 @@ ${f}
|
|
|
2877
2877
|
* @param arg2 イベント名
|
|
2878
2878
|
*/
|
|
2879
2879
|
constructor(t, e = null) {
|
|
2880
|
-
|
|
2880
|
+
c.isElementFragment(t) ? (this.options = c.buildOptions(t, e), this.eventType = e) : (this.options = t, this.eventType = null);
|
|
2881
2881
|
}
|
|
2882
2882
|
/**
|
|
2883
2883
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2902,100 +2902,130 @@ ${f}
|
|
|
2902
2902
|
* @returns 実行成功時は true、停止や失敗時は false
|
|
2903
2903
|
*/
|
|
2904
2904
|
async execute() {
|
|
2905
|
-
|
|
2905
|
+
const t = this.acquireExecutionLock();
|
|
2906
|
+
if (t === !1)
|
|
2906
2907
|
return !1;
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2908
|
+
try {
|
|
2909
|
+
if (Object.keys(this.options).length === 0 || this.options.formFragment && this.validate(this.options.formFragment) === !1 || !await this.confirm())
|
|
2910
|
+
return !1;
|
|
2911
|
+
let r = this.options.fetchUrl, i = this.options.fetchOptions;
|
|
2912
|
+
if (this.options.beforeCallback) {
|
|
2913
|
+
const l = this.options.beforeCallback(
|
|
2914
|
+
r || null,
|
|
2915
|
+
i || null
|
|
2916
|
+
);
|
|
2917
|
+
if (l != null) {
|
|
2918
|
+
if (l === !1 || typeof l == "object" && l.stop)
|
|
2919
|
+
return !1;
|
|
2920
|
+
typeof l == "object" && (r = "fetchUrl" in l ? l.fetchUrl : r, i = "fetchOptions" in l ? l.fetchOptions : i);
|
|
2921
|
+
}
|
|
2917
2922
|
}
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
Object.assign(i, o);
|
|
2923
|
-
}
|
|
2924
|
-
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2925
|
-
const n = Object.keys(i).length > 0;
|
|
2926
|
-
if (e) {
|
|
2927
|
-
const o = { ...r || {} }, h = new Headers(
|
|
2928
|
-
o.headers || void 0
|
|
2929
|
-
), m = (o.method || "GET").toUpperCase(), b = l.runtime === "demo" && !ut(m), E = b ? "GET" : m;
|
|
2930
|
-
if (o.method = E, E === "GET" || E === "HEAD" || E === "OPTIONS")
|
|
2931
|
-
n && (e = ht(e, i));
|
|
2932
|
-
else if (n) {
|
|
2933
|
-
const c = h.get("Content-Type") || "";
|
|
2934
|
-
if (/multipart\/form-data/i.test(c)) {
|
|
2935
|
-
h.delete("Content-Type");
|
|
2936
|
-
const f = new FormData();
|
|
2937
|
-
for (const [g, A] of Object.entries(i))
|
|
2938
|
-
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));
|
|
2939
|
-
o.body = f;
|
|
2940
|
-
} else if (/application\/x-www-form-urlencoded/i.test(c)) {
|
|
2941
|
-
const f = new URLSearchParams();
|
|
2942
|
-
for (const [g, A] of Object.entries(i))
|
|
2943
|
-
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)));
|
|
2944
|
-
o.body = f;
|
|
2945
|
-
} else
|
|
2946
|
-
h.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2923
|
+
const n = {};
|
|
2924
|
+
if (this.options.formFragment) {
|
|
2925
|
+
const l = A.getValues(this.options.formFragment);
|
|
2926
|
+
Object.assign(n, l);
|
|
2947
2927
|
}
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
if (
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2928
|
+
this.options.data && typeof this.options.data == "object" && Object.assign(n, this.options.data);
|
|
2929
|
+
const s = Object.keys(n).length > 0;
|
|
2930
|
+
if (r) {
|
|
2931
|
+
const l = { ...i || {} }, m = new Headers(
|
|
2932
|
+
l.headers || void 0
|
|
2933
|
+
), g = (l.method || "GET").toUpperCase(), T = u.runtime === "demo" && !ut(g), v = T ? "GET" : g;
|
|
2934
|
+
if (l.method = v, v === "GET" || v === "HEAD" || v === "OPTIONS")
|
|
2935
|
+
s && (r = ht(r, n));
|
|
2936
|
+
else if (s) {
|
|
2937
|
+
const d = m.get("Content-Type") || "";
|
|
2938
|
+
if (/multipart\/form-data/i.test(d)) {
|
|
2939
|
+
m.delete("Content-Type");
|
|
2940
|
+
const b = new FormData();
|
|
2941
|
+
for (const [E, y] of Object.entries(n))
|
|
2942
|
+
y == null ? b.append(E, "") : y instanceof Blob ? b.append(E, y) : Array.isArray(y) ? y.forEach((D) => b.append(E, String(D))) : typeof y == "object" ? b.append(E, JSON.stringify(y)) : b.append(E, String(y));
|
|
2943
|
+
l.body = b;
|
|
2944
|
+
} else if (/application\/x-www-form-urlencoded/i.test(d)) {
|
|
2945
|
+
const b = new URLSearchParams();
|
|
2946
|
+
for (const [E, y] of Object.entries(n))
|
|
2947
|
+
y !== void 0 && (y === null ? b.append(E, "") : Array.isArray(y) ? y.forEach((D) => b.append(E, String(D))) : typeof y == "object" ? b.append(E, JSON.stringify(y)) : b.append(E, String(y)));
|
|
2948
|
+
l.body = b;
|
|
2949
|
+
} else
|
|
2950
|
+
m.set("Content-Type", "application/json"), l.body = JSON.stringify(n);
|
|
2951
|
+
}
|
|
2952
|
+
l.headers = m;
|
|
2953
|
+
let h;
|
|
2954
|
+
if (T && (h = r && new URL(r, window.location.href).search || void 0, m.delete("Content-Type"), f.info("Haori demo fetch normalization", {
|
|
2955
|
+
runtime: u.runtime,
|
|
2956
|
+
requestedMethod: g,
|
|
2957
|
+
effectiveMethod: v,
|
|
2958
|
+
transportMode: "query-get",
|
|
2959
|
+
url: r,
|
|
2960
|
+
payload: s ? n : void 0,
|
|
2961
|
+
queryString: h
|
|
2962
|
+
})), this.options.targetFragment && r) {
|
|
2963
|
+
const d = performance.now(), b = {
|
|
2964
|
+
runtime: u.runtime,
|
|
2965
|
+
requestedMethod: g,
|
|
2966
|
+
effectiveMethod: v,
|
|
2967
|
+
transportMode: T ? "query-get" : "http",
|
|
2968
|
+
...T ? { queryString: h } : {}
|
|
2969
|
+
};
|
|
2970
|
+
return N.fetchStart(
|
|
2978
2971
|
this.options.targetFragment.getTarget(),
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2972
|
+
r,
|
|
2973
|
+
l,
|
|
2974
|
+
s ? n : void 0,
|
|
2975
|
+
b
|
|
2976
|
+
), fetch(r, l).then((E) => this.handleFetchResult(
|
|
2977
|
+
E,
|
|
2978
|
+
r || void 0,
|
|
2979
|
+
d
|
|
2980
|
+
)).catch((E) => {
|
|
2981
|
+
throw r && N.fetchError(
|
|
2982
|
+
this.options.targetFragment.getTarget(),
|
|
2983
|
+
r,
|
|
2984
|
+
E
|
|
2985
|
+
), E;
|
|
2986
|
+
});
|
|
2987
|
+
}
|
|
2988
|
+
return fetch(r, l).then((d) => this.handleFetchResult(d, r || void 0));
|
|
2983
2989
|
}
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2990
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2991
|
+
const l = this.options.formFragment, m = l.getTarget();
|
|
2992
|
+
m.setAttribute(
|
|
2993
|
+
`${u.prefix}bind`,
|
|
2994
|
+
JSON.stringify(n)
|
|
2995
|
+
);
|
|
2996
|
+
const g = l.getBindingData();
|
|
2997
|
+
Object.assign(g, n), await P.setBindingData(m, g);
|
|
2998
|
+
}
|
|
2999
|
+
const a = s ? n : {}, o = new Response(JSON.stringify(a), {
|
|
3000
|
+
headers: { "Content-Type": "application/json" }
|
|
3001
|
+
});
|
|
3002
|
+
return this.handleFetchResult(o);
|
|
3003
|
+
} finally {
|
|
3004
|
+
this.releaseExecutionLock(t);
|
|
2994
3005
|
}
|
|
2995
|
-
|
|
2996
|
-
|
|
3006
|
+
}
|
|
3007
|
+
/**
|
|
3008
|
+
* click 手続きの重複実行を防ぐためのロックを取得します。
|
|
3009
|
+
*
|
|
3010
|
+
* @returns ロック情報。取得不要なら null、取得失敗なら false。
|
|
3011
|
+
*/
|
|
3012
|
+
acquireExecutionLock() {
|
|
3013
|
+
if (this.eventType !== "click" || !this.options.targetFragment)
|
|
3014
|
+
return null;
|
|
3015
|
+
const t = this.options.targetFragment.getTarget();
|
|
3016
|
+
return c.RUNNING_CLICK_TARGETS.has(t) || t.hasAttribute("disabled") ? !1 : (c.RUNNING_CLICK_TARGETS.add(t), t.setAttribute("disabled", ""), {
|
|
3017
|
+
target: t,
|
|
3018
|
+
appliedDisabledAttribute: !0
|
|
2997
3019
|
});
|
|
2998
|
-
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* 取得済みの実行ロックを解放します。
|
|
3023
|
+
*
|
|
3024
|
+
* @param executionLock 解放対象のロック情報。
|
|
3025
|
+
* @returns 戻り値はありません。
|
|
3026
|
+
*/
|
|
3027
|
+
releaseExecutionLock(t) {
|
|
3028
|
+
t && (c.RUNNING_CLICK_TARGETS.delete(t.target), t.appliedDisabledAttribute && t.target.removeAttribute("disabled"));
|
|
2999
3029
|
}
|
|
3000
3030
|
/**
|
|
3001
3031
|
* フェッチ後の処理を実行します。
|
|
@@ -3003,14 +3033,14 @@ ${f}
|
|
|
3003
3033
|
async handleFetchResult(t, e, r) {
|
|
3004
3034
|
const i = W();
|
|
3005
3035
|
if (!t.ok)
|
|
3006
|
-
return this.options.targetFragment && e &&
|
|
3036
|
+
return this.options.targetFragment && e && N.fetchError(
|
|
3007
3037
|
this.options.targetFragment.getTarget(),
|
|
3008
3038
|
e,
|
|
3009
3039
|
new Error(`${t.status} ${t.statusText}`),
|
|
3010
3040
|
t.status,
|
|
3011
3041
|
r
|
|
3012
3042
|
), await this.handleFetchError(t), !1;
|
|
3013
|
-
if (this.options.targetFragment && e && r &&
|
|
3043
|
+
if (this.options.targetFragment && e && r && N.fetchEnd(
|
|
3014
3044
|
this.options.targetFragment.getTarget(),
|
|
3015
3045
|
e,
|
|
3016
3046
|
t.status,
|
|
@@ -3025,11 +3055,11 @@ ${f}
|
|
|
3025
3055
|
}
|
|
3026
3056
|
const n = [];
|
|
3027
3057
|
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(
|
|
3028
|
-
this.options.resetFragments.map((a) =>
|
|
3058
|
+
this.options.resetFragments.map((a) => A.reset(a))
|
|
3029
3059
|
), await this.copy();
|
|
3030
3060
|
const s = [];
|
|
3031
3061
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
3032
|
-
s.push(new
|
|
3062
|
+
s.push(new c(a, null).run());
|
|
3033
3063
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
3034
3064
|
const o = a.getTarget();
|
|
3035
3065
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
@@ -3037,10 +3067,10 @@ ${f}
|
|
|
3037
3067
|
);
|
|
3038
3068
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
3039
3069
|
const o = a.getTarget();
|
|
3040
|
-
o instanceof HTMLElement ? s.push(i.openDialog(o)) :
|
|
3070
|
+
o instanceof HTMLElement ? s.push(i.openDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
3041
3071
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
3042
3072
|
const o = a.getTarget();
|
|
3043
|
-
o instanceof HTMLElement ? s.push(i.closeDialog(o)) :
|
|
3073
|
+
o instanceof HTMLElement ? s.push(i.closeDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
3044
3074
|
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3045
3075
|
this.options.toastMessage,
|
|
3046
3076
|
this.options.toastLevel ?? "info"
|
|
@@ -3060,18 +3090,18 @@ ${f}
|
|
|
3060
3090
|
const i = t ? this.options.historyUrl : window.location.pathname, n = new URL(i, window.location.href);
|
|
3061
3091
|
if (n.origin !== window.location.origin) {
|
|
3062
3092
|
const a = "history.pushState: cross-origin URL is not allowed: " + n.toString();
|
|
3063
|
-
|
|
3093
|
+
f.error(
|
|
3064
3094
|
"Haori",
|
|
3065
3095
|
a
|
|
3066
3096
|
);
|
|
3067
3097
|
return;
|
|
3068
3098
|
}
|
|
3069
3099
|
const s = (a) => {
|
|
3070
|
-
for (const [o,
|
|
3071
|
-
|
|
3100
|
+
for (const [o, l] of Object.entries(a))
|
|
3101
|
+
l != null && (Array.isArray(l) ? l.forEach((m) => n.searchParams.append(o, String(m))) : typeof l == "object" ? n.searchParams.set(o, JSON.stringify(l)) : n.searchParams.set(o, String(l)));
|
|
3072
3102
|
};
|
|
3073
3103
|
e && s(this.options.historyData), r && s(
|
|
3074
|
-
|
|
3104
|
+
A.getValues(
|
|
3075
3105
|
this.options.historyFormFragment
|
|
3076
3106
|
)
|
|
3077
3107
|
), history.pushState(
|
|
@@ -3080,7 +3110,7 @@ ${f}
|
|
|
3080
3110
|
n.toString()
|
|
3081
3111
|
);
|
|
3082
3112
|
} catch (i) {
|
|
3083
|
-
|
|
3113
|
+
f.error("Haori", `history.pushState failed: ${i}`);
|
|
3084
3114
|
}
|
|
3085
3115
|
}
|
|
3086
3116
|
/**
|
|
@@ -3088,7 +3118,7 @@ ${f}
|
|
|
3088
3118
|
*/
|
|
3089
3119
|
async handleFetchError(t) {
|
|
3090
3120
|
let e = null;
|
|
3091
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
3121
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3092
3122
|
const r = async (s) => {
|
|
3093
3123
|
const a = e ? e.getTarget() : document.body;
|
|
3094
3124
|
await W().addErrorMessage(a, s);
|
|
@@ -3106,18 +3136,18 @@ ${f}
|
|
|
3106
3136
|
for (const o of s.messages)
|
|
3107
3137
|
typeof o == "string" && a.push({ message: o });
|
|
3108
3138
|
if (s.errors && typeof s.errors == "object")
|
|
3109
|
-
for (const [o,
|
|
3110
|
-
Array.isArray(
|
|
3111
|
-
`) }) : typeof
|
|
3139
|
+
for (const [o, l] of Object.entries(s.errors))
|
|
3140
|
+
Array.isArray(l) ? a.push({ key: o, message: l.join(`
|
|
3141
|
+
`) }) : typeof l == "string" ? a.push({ key: o, message: l }) : l != null && a.push({ key: o, message: String(l) });
|
|
3112
3142
|
if (a.length === 0)
|
|
3113
|
-
for (const [o,
|
|
3114
|
-
o === "message" || o === "messages" || o === "errors" || (Array.isArray(
|
|
3115
|
-
`) }) : typeof
|
|
3143
|
+
for (const [o, l] of Object.entries(s))
|
|
3144
|
+
o === "message" || o === "messages" || o === "errors" || (Array.isArray(l) ? a.push({ key: o, message: l.join(`
|
|
3145
|
+
`) }) : typeof l == "string" && a.push({ key: o, message: l }));
|
|
3116
3146
|
}
|
|
3117
3147
|
if (a.length === 0)
|
|
3118
3148
|
return await r(`${t.status} ${t.statusText}`), i(), !1;
|
|
3119
3149
|
for (const o of a)
|
|
3120
|
-
o.key && e ? await
|
|
3150
|
+
o.key && e ? await A.addErrorMessage(e, o.key, o.message) : await r(o.message);
|
|
3121
3151
|
return i(), !1;
|
|
3122
3152
|
} catch {
|
|
3123
3153
|
}
|
|
@@ -3196,19 +3226,19 @@ ${f}
|
|
|
3196
3226
|
this.options.bindFragments.forEach((n) => {
|
|
3197
3227
|
const s = n.getBindingData(), a = this.options.bindArg;
|
|
3198
3228
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3199
|
-
const o = s[a],
|
|
3229
|
+
const o = s[a], l = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3200
3230
|
s[a] = this.mergeAppendBindingData(
|
|
3201
3231
|
n,
|
|
3202
3232
|
r,
|
|
3203
|
-
|
|
3233
|
+
l
|
|
3204
3234
|
);
|
|
3205
3235
|
} else
|
|
3206
3236
|
s[a] = r;
|
|
3207
|
-
i.push(
|
|
3237
|
+
i.push(P.setBindingData(n.getTarget(), s));
|
|
3208
3238
|
});
|
|
3209
3239
|
else {
|
|
3210
3240
|
if (typeof r == "string")
|
|
3211
|
-
return
|
|
3241
|
+
return f.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
3212
3242
|
new Error("string data cannot be bound without a bindArg.")
|
|
3213
3243
|
);
|
|
3214
3244
|
this.options.bindFragments.forEach((n) => {
|
|
@@ -3217,7 +3247,7 @@ ${f}
|
|
|
3217
3247
|
r
|
|
3218
3248
|
);
|
|
3219
3249
|
i.push(
|
|
3220
|
-
|
|
3250
|
+
P.setBindingData(
|
|
3221
3251
|
n.getTarget(),
|
|
3222
3252
|
s
|
|
3223
3253
|
)
|
|
@@ -3252,7 +3282,7 @@ ${f}
|
|
|
3252
3282
|
...i.getBindingData(),
|
|
3253
3283
|
...e
|
|
3254
3284
|
};
|
|
3255
|
-
return
|
|
3285
|
+
return P.setBindingData(i.getTarget(), n);
|
|
3256
3286
|
});
|
|
3257
3287
|
return Promise.all(r).then(() => {
|
|
3258
3288
|
});
|
|
@@ -3261,7 +3291,7 @@ ${f}
|
|
|
3261
3291
|
* copy のコピー元データを取得します。
|
|
3262
3292
|
*/
|
|
3263
3293
|
resolveCopySourceData() {
|
|
3264
|
-
return this.options.formFragment ?
|
|
3294
|
+
return this.options.formFragment ? A.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3265
3295
|
}
|
|
3266
3296
|
/**
|
|
3267
3297
|
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
@@ -3297,11 +3327,11 @@ ${f}
|
|
|
3297
3327
|
*/
|
|
3298
3328
|
getRowFragment() {
|
|
3299
3329
|
if (!this.options.targetFragment)
|
|
3300
|
-
return
|
|
3330
|
+
return f.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3301
3331
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3302
|
-
`${
|
|
3332
|
+
`${u.prefix}row`
|
|
3303
3333
|
);
|
|
3304
|
-
return t || (
|
|
3334
|
+
return t || (f.error("Haori", "Row fragment not found."), null);
|
|
3305
3335
|
}
|
|
3306
3336
|
/**
|
|
3307
3337
|
* 行を追加します。
|
|
@@ -3317,7 +3347,7 @@ ${f}
|
|
|
3317
3347
|
const e = [], r = t.clone();
|
|
3318
3348
|
return e.push(
|
|
3319
3349
|
t.getParent().insertAfter(r, t)
|
|
3320
|
-
), e.push(
|
|
3350
|
+
), e.push(P.evaluateAll(r)), e.push(A.reset(r)), Promise.all(e).then(() => {
|
|
3321
3351
|
});
|
|
3322
3352
|
}
|
|
3323
3353
|
/**
|
|
@@ -3332,7 +3362,7 @@ ${f}
|
|
|
3332
3362
|
if (!t)
|
|
3333
3363
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3334
3364
|
const e = t.getParent();
|
|
3335
|
-
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
3365
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${u.prefix}each-before`) && !i.hasAttribute(`${u.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3336
3366
|
}
|
|
3337
3367
|
/**
|
|
3338
3368
|
* 前の行へ移動します。
|
|
@@ -3369,8 +3399,8 @@ ${f}
|
|
|
3369
3399
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3370
3400
|
}
|
|
3371
3401
|
};
|
|
3372
|
-
|
|
3373
|
-
let V =
|
|
3402
|
+
c.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, c.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/, c.RUNNING_CLICK_TARGETS = /* @__PURE__ */ new WeakSet();
|
|
3403
|
+
let V = c;
|
|
3374
3404
|
class ft {
|
|
3375
3405
|
/**
|
|
3376
3406
|
* URLのクエリパラメータを取得します。
|
|
@@ -3402,23 +3432,23 @@ class dt {
|
|
|
3402
3432
|
try {
|
|
3403
3433
|
r = await fetch(t, e);
|
|
3404
3434
|
} catch (n) {
|
|
3405
|
-
throw
|
|
3435
|
+
throw f.error("[Haori]", "Failed to fetch import source:", t, n), new Error(`Failed to fetch: ${t}`);
|
|
3406
3436
|
}
|
|
3407
3437
|
if (!r.ok) {
|
|
3408
3438
|
const n = `${r.status} ${r.statusText}`;
|
|
3409
|
-
throw
|
|
3439
|
+
throw f.error("[Haori]", "Import HTTP error:", t, n), new Error(`Failed to load ${t}: ${n}`);
|
|
3410
3440
|
}
|
|
3411
3441
|
let i;
|
|
3412
3442
|
try {
|
|
3413
3443
|
i = await r.text();
|
|
3414
3444
|
} catch (n) {
|
|
3415
|
-
throw
|
|
3445
|
+
throw f.error("[Haori]", "Failed to read response text:", t, n), new Error(`Failed to read response from: ${t}`);
|
|
3416
3446
|
}
|
|
3417
3447
|
try {
|
|
3418
3448
|
const s = new DOMParser().parseFromString(i, "text/html");
|
|
3419
|
-
return s && s.body ? s.body.innerHTML : (
|
|
3449
|
+
return s && s.body ? s.body.innerHTML : (f.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3420
3450
|
} catch (n) {
|
|
3421
|
-
return
|
|
3451
|
+
return f.error("[Haori]", "Failed to parse imported HTML:", t, n), i;
|
|
3422
3452
|
}
|
|
3423
3453
|
}
|
|
3424
3454
|
}
|
|
@@ -3431,7 +3461,7 @@ const p = class p {
|
|
|
3431
3461
|
*/
|
|
3432
3462
|
static isDeferredAttributeName(t) {
|
|
3433
3463
|
return p.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3434
|
-
(e) => t === `${
|
|
3464
|
+
(e) => t === `${u.prefix}${e}`
|
|
3435
3465
|
);
|
|
3436
3466
|
}
|
|
3437
3467
|
/**
|
|
@@ -3442,7 +3472,7 @@ const p = class p {
|
|
|
3442
3472
|
*/
|
|
3443
3473
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3444
3474
|
return p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3445
|
-
(e) => t === `${
|
|
3475
|
+
(e) => t === `${u.prefix}${e}`
|
|
3446
3476
|
);
|
|
3447
3477
|
}
|
|
3448
3478
|
/**
|
|
@@ -3462,7 +3492,7 @@ const p = class p {
|
|
|
3462
3492
|
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
3463
3493
|
*/
|
|
3464
3494
|
static getAliasedAttributeName(t) {
|
|
3465
|
-
const e = `${
|
|
3495
|
+
const e = `${u.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
3466
3496
|
return !t.startsWith(e) || t.length <= e.length ? null : t.slice(e.length);
|
|
3467
3497
|
}
|
|
3468
3498
|
/**
|
|
@@ -3475,7 +3505,7 @@ const p = class p {
|
|
|
3475
3505
|
static isAliasedAttributeReflection(t, e) {
|
|
3476
3506
|
const r = w.get(t);
|
|
3477
3507
|
return r instanceof x ? r.hasAttribute(
|
|
3478
|
-
`${
|
|
3508
|
+
`${u.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}${e}`
|
|
3479
3509
|
) : !1;
|
|
3480
3510
|
}
|
|
3481
3511
|
/**
|
|
@@ -3510,7 +3540,7 @@ const p = class p {
|
|
|
3510
3540
|
let r = Promise.resolve();
|
|
3511
3541
|
const i = /* @__PURE__ */ new Set();
|
|
3512
3542
|
for (const n of p.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3513
|
-
const s =
|
|
3543
|
+
const s = u.prefix + n;
|
|
3514
3544
|
e.hasAttribute(s) && (r = r.then(
|
|
3515
3545
|
() => p.setAttribute(
|
|
3516
3546
|
e.getTarget(),
|
|
@@ -3528,7 +3558,7 @@ const p = class p {
|
|
|
3528
3558
|
));
|
|
3529
3559
|
}
|
|
3530
3560
|
for (const n of p.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3531
|
-
const s =
|
|
3561
|
+
const s = u.prefix + n;
|
|
3532
3562
|
e.hasAttribute(s) && (r = r.then(
|
|
3533
3563
|
() => p.setAttribute(
|
|
3534
3564
|
e.getTarget(),
|
|
@@ -3561,47 +3591,54 @@ const p = class p {
|
|
|
3561
3591
|
return r === null ? i.removeAliasedAttribute(e, n) : i.setAliasedAttribute(e, n, r);
|
|
3562
3592
|
const s = [];
|
|
3563
3593
|
switch (e) {
|
|
3564
|
-
case `${
|
|
3594
|
+
case `${u.prefix}bind`: {
|
|
3565
3595
|
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(p.parseDataBind(r));
|
|
3566
3596
|
break;
|
|
3567
3597
|
}
|
|
3568
|
-
case `${
|
|
3598
|
+
case `${u.prefix}if`:
|
|
3569
3599
|
s.push(p.evaluateIf(i));
|
|
3570
3600
|
break;
|
|
3571
|
-
case `${
|
|
3601
|
+
case `${u.prefix}each`:
|
|
3572
3602
|
s.push(p.evaluateEach(i));
|
|
3573
3603
|
break;
|
|
3574
|
-
case `${
|
|
3604
|
+
case `${u.prefix}fetch`:
|
|
3575
3605
|
s.push(
|
|
3576
3606
|
new V(i, null).run().then(() => {
|
|
3577
3607
|
})
|
|
3578
3608
|
);
|
|
3579
3609
|
break;
|
|
3580
|
-
case `${
|
|
3610
|
+
case `${u.prefix}import`: {
|
|
3581
3611
|
if (typeof r == "string") {
|
|
3582
3612
|
const a = i.getTarget(), o = performance.now();
|
|
3583
|
-
a.setAttribute(`${
|
|
3584
|
-
dt.load(r).then((
|
|
3585
|
-
const m = new TextEncoder().encode(
|
|
3586
|
-
return
|
|
3587
|
-
a.innerHTML =
|
|
3613
|
+
a.setAttribute(`${u.prefix}importing`, ""), N.importStart(a, r), s.push(
|
|
3614
|
+
dt.load(r).then((l) => {
|
|
3615
|
+
const m = new TextEncoder().encode(l).length;
|
|
3616
|
+
return F.enqueue(() => {
|
|
3617
|
+
a.innerHTML = l;
|
|
3588
3618
|
}).then(() => {
|
|
3589
|
-
a.removeAttribute(`${
|
|
3619
|
+
if (a.removeAttribute(`${u.prefix}importing`), N.importEnd(a, r, m, o), !document.body.hasAttribute("data-haori-ready")) {
|
|
3620
|
+
const g = [];
|
|
3621
|
+
return a.childNodes.forEach((T) => {
|
|
3622
|
+
const v = w.get(T);
|
|
3623
|
+
v instanceof x ? g.push(p.scan(v.getTarget())) : v instanceof O && g.push(p.evaluateText(v));
|
|
3624
|
+
}), Promise.all(g).then(() => {
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3590
3627
|
});
|
|
3591
|
-
}).catch((
|
|
3592
|
-
a.removeAttribute(`${
|
|
3628
|
+
}).catch((l) => {
|
|
3629
|
+
a.removeAttribute(`${u.prefix}importing`), N.importError(a, r, l), f.error("[Haori]", "Failed to import HTML:", r, l);
|
|
3593
3630
|
})
|
|
3594
3631
|
);
|
|
3595
3632
|
}
|
|
3596
3633
|
break;
|
|
3597
3634
|
}
|
|
3598
|
-
case `${
|
|
3599
|
-
const a = i.getAttribute(`${
|
|
3635
|
+
case `${u.prefix}url-param`: {
|
|
3636
|
+
const a = i.getAttribute(`${u.prefix}url-arg`), o = ft.readParams();
|
|
3600
3637
|
if (a === null)
|
|
3601
3638
|
s.push(p.setBindingData(t, o));
|
|
3602
3639
|
else {
|
|
3603
|
-
const
|
|
3604
|
-
|
|
3640
|
+
const l = i.getRawBindingData() || {};
|
|
3641
|
+
l[String(a)] = o, s.push(p.setBindingData(t, l));
|
|
3605
3642
|
}
|
|
3606
3643
|
break;
|
|
3607
3644
|
}
|
|
@@ -3621,14 +3658,14 @@ const p = class p {
|
|
|
3621
3658
|
const r = w.get(t), i = r.getRawBindingData();
|
|
3622
3659
|
r.setBindingData(e);
|
|
3623
3660
|
let n = r.setAttribute(
|
|
3624
|
-
`${
|
|
3661
|
+
`${u.prefix}bind`,
|
|
3625
3662
|
JSON.stringify(e)
|
|
3626
3663
|
);
|
|
3627
3664
|
if (t.tagName === "FORM") {
|
|
3628
|
-
const s = r.getAttribute(`${
|
|
3629
|
-
n = n.then(() =>
|
|
3665
|
+
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;
|
|
3666
|
+
n = n.then(() => A.syncValues(r, a));
|
|
3630
3667
|
}
|
|
3631
|
-
return n = n.then(() => p.evaluateAll(r)),
|
|
3668
|
+
return n = n.then(() => p.evaluateAll(r)), N.bindChange(t, i, e, "manual"), n.then(() => {
|
|
3632
3669
|
});
|
|
3633
3670
|
}
|
|
3634
3671
|
/**
|
|
@@ -3642,7 +3679,7 @@ const p = class p {
|
|
|
3642
3679
|
try {
|
|
3643
3680
|
return JSON.parse(t);
|
|
3644
3681
|
} catch (e) {
|
|
3645
|
-
return
|
|
3682
|
+
return f.error("[Haori]", "Invalid JSON in data-bind:", e), {};
|
|
3646
3683
|
}
|
|
3647
3684
|
else {
|
|
3648
3685
|
const e = new URLSearchParams(t), r = {};
|
|
@@ -3704,7 +3741,7 @@ const p = class p {
|
|
|
3704
3741
|
i.push(r.setValue(e));
|
|
3705
3742
|
const n = p.getFormFragment(r);
|
|
3706
3743
|
if (n) {
|
|
3707
|
-
const s =
|
|
3744
|
+
const s = A.getValues(n), a = n.getAttribute(`${u.prefix}form-arg`);
|
|
3708
3745
|
let o;
|
|
3709
3746
|
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(p.setBindingData(n.getTarget(), o));
|
|
3710
3747
|
}
|
|
@@ -3731,7 +3768,7 @@ const p = class p {
|
|
|
3731
3768
|
*/
|
|
3732
3769
|
static evaluateAll(t) {
|
|
3733
3770
|
const e = [];
|
|
3734
|
-
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${
|
|
3771
|
+
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(() => {
|
|
3735
3772
|
const r = [];
|
|
3736
3773
|
return t.getChildren().forEach((i) => {
|
|
3737
3774
|
i instanceof x ? r.push(p.evaluateAll(i)) : i instanceof O && r.push(p.evaluateText(i));
|
|
@@ -3759,11 +3796,11 @@ const p = class p {
|
|
|
3759
3796
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3760
3797
|
*/
|
|
3761
3798
|
static evaluateIf(t) {
|
|
3762
|
-
const e = [], r = t.getAttribute(`${
|
|
3799
|
+
const e = [], r = t.getAttribute(`${u.prefix}if`);
|
|
3763
3800
|
if (r === !1 || r === void 0 || r === null || Number.isNaN(r))
|
|
3764
3801
|
e.push(
|
|
3765
3802
|
t.hide().then(() => {
|
|
3766
|
-
|
|
3803
|
+
N.hide(t.getTarget());
|
|
3767
3804
|
})
|
|
3768
3805
|
);
|
|
3769
3806
|
else {
|
|
@@ -3772,7 +3809,7 @@ const p = class p {
|
|
|
3772
3809
|
n instanceof x ? i.push(p.evaluateAll(n)) : n instanceof O && i.push(p.evaluateText(n));
|
|
3773
3810
|
}), e.push(
|
|
3774
3811
|
t.show().then(() => {
|
|
3775
|
-
|
|
3812
|
+
N.show(t.getTarget());
|
|
3776
3813
|
})
|
|
3777
3814
|
), e.push(Promise.all(i).then(() => {
|
|
3778
3815
|
}));
|
|
@@ -3794,18 +3831,18 @@ const p = class p {
|
|
|
3794
3831
|
let i = !1;
|
|
3795
3832
|
t.getChildren().forEach((s) => {
|
|
3796
3833
|
if (!i && s instanceof x) {
|
|
3797
|
-
if (s.hasAttribute(`${
|
|
3834
|
+
if (s.hasAttribute(`${u.prefix}each-before`) || s.hasAttribute(`${u.prefix}each-after`))
|
|
3798
3835
|
return;
|
|
3799
3836
|
e = s.clone(), t.setTemplate(e), i = !0, t.removeChild(s);
|
|
3800
3837
|
const a = s.getTarget();
|
|
3801
3838
|
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3802
3839
|
}
|
|
3803
3840
|
});
|
|
3804
|
-
const n = t.getAttribute(`${
|
|
3805
|
-
return Array.isArray(n) ? this.updateDiff(t, n) : (
|
|
3841
|
+
const n = t.getAttribute(`${u.prefix}each`);
|
|
3842
|
+
return Array.isArray(n) ? this.updateDiff(t, n) : (f.error("[Haori]", "Invalid each attribute:", n), Promise.reject(new Error("Invalid each attribute.")));
|
|
3806
3843
|
}
|
|
3807
|
-
const r = t.getAttribute(`${
|
|
3808
|
-
return Array.isArray(r) ? this.updateDiff(t, r) : (
|
|
3844
|
+
const r = t.getAttribute(`${u.prefix}each`);
|
|
3845
|
+
return Array.isArray(r) ? this.updateDiff(t, r) : (f.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3809
3846
|
}
|
|
3810
3847
|
/**
|
|
3811
3848
|
* 差分を更新します。
|
|
@@ -3816,73 +3853,73 @@ const p = class p {
|
|
|
3816
3853
|
static updateDiff(t, e) {
|
|
3817
3854
|
const r = t.getTemplate();
|
|
3818
3855
|
if (r === null)
|
|
3819
|
-
return
|
|
3820
|
-
let i = t.getAttribute(`${
|
|
3856
|
+
return f.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3857
|
+
let i = t.getAttribute(`${u.prefix}each-index`);
|
|
3821
3858
|
i && (i = String(i));
|
|
3822
|
-
const n = t.getAttribute(`${
|
|
3823
|
-
e.forEach((
|
|
3824
|
-
const
|
|
3825
|
-
|
|
3859
|
+
const n = t.getAttribute(`${u.prefix}each-key`), s = t.getAttribute(`${u.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3860
|
+
e.forEach((h, d) => {
|
|
3861
|
+
const b = p.createListKey(
|
|
3862
|
+
h,
|
|
3826
3863
|
n ? String(n) : null,
|
|
3827
|
-
|
|
3864
|
+
d
|
|
3828
3865
|
);
|
|
3829
|
-
o.push(
|
|
3866
|
+
o.push(b), a.set(b, { item: h, itemIndex: d });
|
|
3830
3867
|
});
|
|
3831
|
-
const
|
|
3832
|
-
let m = t.getChildren().filter((
|
|
3833
|
-
(
|
|
3868
|
+
const l = [];
|
|
3869
|
+
let m = t.getChildren().filter((h) => h instanceof x).filter(
|
|
3870
|
+
(h) => !h.hasAttribute(`${u.prefix}each-before`) && !h.hasAttribute(`${u.prefix}each-after`)
|
|
3834
3871
|
);
|
|
3835
|
-
m = m.filter((
|
|
3836
|
-
const
|
|
3837
|
-
let
|
|
3838
|
-
return o.forEach((
|
|
3839
|
-
const
|
|
3840
|
-
let
|
|
3841
|
-
if (
|
|
3842
|
-
|
|
3872
|
+
m = m.filter((h) => o.indexOf(String(h.getListKey())) === -1 ? (l.push(h.remove()), !1) : !0);
|
|
3873
|
+
const g = m.map((h) => h.getListKey()), T = t.getChildren().filter((h) => h instanceof x).filter((h) => h.hasAttribute(`${u.prefix}each-before`)).length;
|
|
3874
|
+
let v = Promise.resolve();
|
|
3875
|
+
return o.forEach((h, d) => {
|
|
3876
|
+
const b = g.indexOf(h), { item: E, itemIndex: y } = a.get(h);
|
|
3877
|
+
let D;
|
|
3878
|
+
if (b !== -1)
|
|
3879
|
+
D = m[b], v = v.then(
|
|
3843
3880
|
() => p.updateRowFragment(
|
|
3844
|
-
|
|
3845
|
-
|
|
3881
|
+
D,
|
|
3882
|
+
E,
|
|
3846
3883
|
i,
|
|
3847
|
-
|
|
3884
|
+
y,
|
|
3848
3885
|
s ? String(s) : null,
|
|
3849
|
-
|
|
3850
|
-
).then(() => p.evaluateAll(
|
|
3886
|
+
h
|
|
3887
|
+
).then(() => p.evaluateAll(D)).then(() => p.scheduleEvaluateAll(D))
|
|
3851
3888
|
);
|
|
3852
3889
|
else {
|
|
3853
|
-
|
|
3854
|
-
const J =
|
|
3855
|
-
|
|
3890
|
+
D = r.clone();
|
|
3891
|
+
const J = T + d;
|
|
3892
|
+
v = v.then(
|
|
3856
3893
|
() => p.updateRowFragment(
|
|
3857
|
-
|
|
3858
|
-
|
|
3894
|
+
D,
|
|
3895
|
+
E,
|
|
3859
3896
|
i,
|
|
3860
|
-
|
|
3897
|
+
y,
|
|
3861
3898
|
s ? String(s) : null,
|
|
3862
|
-
|
|
3899
|
+
h
|
|
3863
3900
|
).then(
|
|
3864
3901
|
() => t.insertBefore(
|
|
3865
|
-
|
|
3902
|
+
D,
|
|
3866
3903
|
t.getChildren()[J] || null
|
|
3867
|
-
).then(() => p.evaluateAll(
|
|
3904
|
+
).then(() => p.evaluateAll(D)).then(() => p.scheduleEvaluateAll(D))
|
|
3868
3905
|
)
|
|
3869
3906
|
);
|
|
3870
3907
|
}
|
|
3871
|
-
}), Promise.all(
|
|
3872
|
-
const
|
|
3873
|
-
(
|
|
3874
|
-
),
|
|
3875
|
-
(
|
|
3876
|
-
),
|
|
3877
|
-
(
|
|
3878
|
-
),
|
|
3879
|
-
(
|
|
3908
|
+
}), Promise.all(l).then(() => v).then(() => {
|
|
3909
|
+
const h = o.filter(
|
|
3910
|
+
(y) => y !== null
|
|
3911
|
+
), d = g.filter(
|
|
3912
|
+
(y) => y !== null
|
|
3913
|
+
), b = h.filter(
|
|
3914
|
+
(y) => !d.includes(y)
|
|
3915
|
+
), E = d.filter(
|
|
3916
|
+
(y) => !h.includes(y)
|
|
3880
3917
|
);
|
|
3881
|
-
|
|
3918
|
+
N.eachUpdate(
|
|
3882
3919
|
t.getTarget(),
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3920
|
+
b,
|
|
3921
|
+
E,
|
|
3922
|
+
h
|
|
3886
3923
|
);
|
|
3887
3924
|
});
|
|
3888
3925
|
}
|
|
@@ -3928,11 +3965,11 @@ const p = class p {
|
|
|
3928
3965
|
[n]: e
|
|
3929
3966
|
}, r && (a[r] = i);
|
|
3930
3967
|
else
|
|
3931
|
-
return
|
|
3968
|
+
return f.error(
|
|
3932
3969
|
"[Haori]",
|
|
3933
|
-
`Primitive value requires '${
|
|
3970
|
+
`Primitive value requires '${u.prefix}each-arg' attribute: ${e}`
|
|
3934
3971
|
), Promise.resolve();
|
|
3935
|
-
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${
|
|
3972
|
+
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${u.prefix}row`, s);
|
|
3936
3973
|
}
|
|
3937
3974
|
/**
|
|
3938
3975
|
* フラグメントの再評価を次のイベントループで実行します。
|
|
@@ -3953,7 +3990,7 @@ p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if
|
|
|
3953
3990
|
"import",
|
|
3954
3991
|
"url-param"
|
|
3955
3992
|
], p.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3956
|
-
let
|
|
3993
|
+
let P = p;
|
|
3957
3994
|
const Y = class Y {
|
|
3958
3995
|
/**
|
|
3959
3996
|
* コンストラクタ。
|
|
@@ -3994,7 +4031,7 @@ const Y = class Y {
|
|
|
3994
4031
|
return;
|
|
3995
4032
|
const i = w.get(r);
|
|
3996
4033
|
i && (e === "change" && i instanceof x && i.syncValue(), new V(i, e).run().catch((n) => {
|
|
3997
|
-
|
|
4034
|
+
f.error("[Haori]", "Procedure execution error:", n);
|
|
3998
4035
|
}));
|
|
3999
4036
|
}
|
|
4000
4037
|
/**
|
|
@@ -4009,44 +4046,44 @@ const Y = class Y {
|
|
|
4009
4046
|
};
|
|
4010
4047
|
Y.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
4011
4048
|
let Q = Y;
|
|
4012
|
-
const
|
|
4049
|
+
const S = class S {
|
|
4013
4050
|
static syncTree(t) {
|
|
4014
|
-
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement &&
|
|
4015
|
-
|
|
4051
|
+
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && S.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
4052
|
+
S.syncElement(e);
|
|
4016
4053
|
}));
|
|
4017
4054
|
}
|
|
4018
4055
|
static syncElement(t) {
|
|
4019
|
-
const e =
|
|
4020
|
-
if (!r || !
|
|
4021
|
-
e && (e.observer.disconnect(),
|
|
4056
|
+
const e = S.registrations.get(t), r = w.get(t);
|
|
4057
|
+
if (!r || !S.shouldObserve(r)) {
|
|
4058
|
+
e && (e.observer.disconnect(), S.registrations.delete(t));
|
|
4022
4059
|
return;
|
|
4023
4060
|
}
|
|
4024
4061
|
if (typeof IntersectionObserver > "u")
|
|
4025
4062
|
return;
|
|
4026
|
-
const i =
|
|
4027
|
-
if (e && e.observer.root === i && e.observer.rootMargin === n &&
|
|
4063
|
+
const i = S.resolveRoot(r), n = S.resolveRootMargin(r), s = S.resolveThreshold(r), a = r.hasAttribute(`${u.prefix}intersect-once`);
|
|
4064
|
+
if (e && e.observer.root === i && e.observer.rootMargin === n && S.sameThreshold(
|
|
4028
4065
|
e.observer.thresholds,
|
|
4029
4066
|
s
|
|
4030
4067
|
) && e.once === a) {
|
|
4031
4068
|
e.fragment = r;
|
|
4032
4069
|
return;
|
|
4033
4070
|
}
|
|
4034
|
-
e && (e.observer.disconnect(),
|
|
4071
|
+
e && (e.observer.disconnect(), S.registrations.delete(t));
|
|
4035
4072
|
const o = new IntersectionObserver(
|
|
4036
|
-
(
|
|
4037
|
-
const m =
|
|
4038
|
-
m &&
|
|
4039
|
-
!
|
|
4040
|
-
|
|
4041
|
-
}).catch((
|
|
4042
|
-
|
|
4073
|
+
(l) => {
|
|
4074
|
+
const m = S.registrations.get(t);
|
|
4075
|
+
m && l.forEach((g) => {
|
|
4076
|
+
!g.isIntersecting || m.running || S.isDisabled(m.fragment) || (m.running = !0, new V(m.fragment, "intersect").runWithResult().then((T) => {
|
|
4077
|
+
T && m.once && (m.observer.disconnect(), S.registrations.delete(t));
|
|
4078
|
+
}).catch((T) => {
|
|
4079
|
+
f.error(
|
|
4043
4080
|
"[Haori]",
|
|
4044
4081
|
"Intersect procedure execution error:",
|
|
4045
|
-
|
|
4082
|
+
T
|
|
4046
4083
|
);
|
|
4047
4084
|
}).finally(() => {
|
|
4048
|
-
const
|
|
4049
|
-
|
|
4085
|
+
const T = S.registrations.get(t);
|
|
4086
|
+
T && (T.running = !1);
|
|
4050
4087
|
}));
|
|
4051
4088
|
});
|
|
4052
4089
|
},
|
|
@@ -4056,7 +4093,7 @@ const N = class N {
|
|
|
4056
4093
|
threshold: s
|
|
4057
4094
|
}
|
|
4058
4095
|
);
|
|
4059
|
-
o.observe(t),
|
|
4096
|
+
o.observe(t), S.registrations.set(t, {
|
|
4060
4097
|
fragment: r,
|
|
4061
4098
|
observer: o,
|
|
4062
4099
|
once: a,
|
|
@@ -4065,47 +4102,47 @@ const N = class N {
|
|
|
4065
4102
|
}
|
|
4066
4103
|
static cleanupTree(t) {
|
|
4067
4104
|
if (t instanceof HTMLElement) {
|
|
4068
|
-
const e =
|
|
4069
|
-
e && (e.observer.disconnect(),
|
|
4105
|
+
const e = S.registrations.get(t);
|
|
4106
|
+
e && (e.observer.disconnect(), S.registrations.delete(t));
|
|
4070
4107
|
}
|
|
4071
4108
|
(t instanceof Element || t instanceof DocumentFragment) && t.querySelectorAll("*").forEach((e) => {
|
|
4072
|
-
const r =
|
|
4073
|
-
r && (r.observer.disconnect(),
|
|
4109
|
+
const r = S.registrations.get(e);
|
|
4110
|
+
r && (r.observer.disconnect(), S.registrations.delete(e));
|
|
4074
4111
|
});
|
|
4075
4112
|
}
|
|
4076
4113
|
static disconnectAll() {
|
|
4077
|
-
|
|
4114
|
+
S.registrations.forEach((t) => {
|
|
4078
4115
|
t.observer.disconnect();
|
|
4079
|
-
}),
|
|
4116
|
+
}), S.registrations.clear();
|
|
4080
4117
|
}
|
|
4081
4118
|
static shouldObserve(t) {
|
|
4082
4119
|
return t.getAttributeNames().some((e) => {
|
|
4083
|
-
if (!e.startsWith(`${
|
|
4120
|
+
if (!e.startsWith(`${u.prefix}intersect-`))
|
|
4084
4121
|
return !1;
|
|
4085
|
-
const r = e.slice(`${
|
|
4086
|
-
return !
|
|
4122
|
+
const r = e.slice(`${u.prefix}intersect-`.length);
|
|
4123
|
+
return !S.CONFIG_KEYS.has(r);
|
|
4087
4124
|
});
|
|
4088
4125
|
}
|
|
4089
4126
|
static resolveRoot(t) {
|
|
4090
|
-
const e = `${
|
|
4127
|
+
const e = `${u.prefix}intersect-root`;
|
|
4091
4128
|
if (!t.hasAttribute(e))
|
|
4092
4129
|
return null;
|
|
4093
4130
|
const r = t.getAttribute(e);
|
|
4094
4131
|
if (typeof r != "string" || r.trim() === "")
|
|
4095
4132
|
return null;
|
|
4096
4133
|
const i = document.querySelector(r);
|
|
4097
|
-
return i instanceof HTMLElement ? i : (
|
|
4134
|
+
return i instanceof HTMLElement ? i : (f.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
4098
4135
|
}
|
|
4099
4136
|
static resolveRootMargin(t) {
|
|
4100
|
-
const e = `${
|
|
4137
|
+
const e = `${u.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
4101
4138
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
4102
4139
|
}
|
|
4103
4140
|
static resolveThreshold(t) {
|
|
4104
|
-
const e = `${
|
|
4141
|
+
const e = `${u.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
4105
4142
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
4106
4143
|
}
|
|
4107
4144
|
static isDisabled(t) {
|
|
4108
|
-
const e = `${
|
|
4145
|
+
const e = `${u.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
4109
4146
|
if (r === null || r === !1)
|
|
4110
4147
|
return !1;
|
|
4111
4148
|
if (typeof r == "boolean")
|
|
@@ -4117,14 +4154,14 @@ const N = class N {
|
|
|
4117
4154
|
return t.length === 1 && t[0] === e;
|
|
4118
4155
|
}
|
|
4119
4156
|
};
|
|
4120
|
-
|
|
4157
|
+
S.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
4121
4158
|
"root",
|
|
4122
4159
|
"root-margin",
|
|
4123
4160
|
"threshold",
|
|
4124
4161
|
"disabled",
|
|
4125
4162
|
"once"
|
|
4126
|
-
]),
|
|
4127
|
-
let
|
|
4163
|
+
]), S.registrations = /* @__PURE__ */ new Map();
|
|
4164
|
+
let $ = S;
|
|
4128
4165
|
const H = class H {
|
|
4129
4166
|
/**
|
|
4130
4167
|
* 初期化メソッド。
|
|
@@ -4135,10 +4172,10 @@ const H = class H {
|
|
|
4135
4172
|
return;
|
|
4136
4173
|
H._initialized = !0;
|
|
4137
4174
|
const t = await Promise.allSettled([
|
|
4138
|
-
|
|
4139
|
-
|
|
4175
|
+
P.scan(document.head),
|
|
4176
|
+
P.scan(document.body)
|
|
4140
4177
|
]), [e, r] = t;
|
|
4141
|
-
e.status !== "fulfilled" &&
|
|
4178
|
+
e.status !== "fulfilled" && f.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && f.error("[Haori]", "Failed to build body fragment:", r.reason), await F.wait(), document.body.setAttribute("data-haori-ready", ""), H.observe(document.head), H.observe(document.body), new Q().start(), $.syncTree(document.body);
|
|
4142
4179
|
}
|
|
4143
4180
|
/**
|
|
4144
4181
|
* 指定された要素を監視します。
|
|
@@ -4151,45 +4188,45 @@ const H = class H {
|
|
|
4151
4188
|
try {
|
|
4152
4189
|
switch (i.type) {
|
|
4153
4190
|
case "attributes": {
|
|
4154
|
-
|
|
4191
|
+
f.info(
|
|
4155
4192
|
"[Haori]",
|
|
4156
4193
|
"Attribute changed:",
|
|
4157
4194
|
i.target,
|
|
4158
4195
|
i.attributeName
|
|
4159
4196
|
);
|
|
4160
4197
|
const n = i.target;
|
|
4161
|
-
if (i.attributeName &&
|
|
4198
|
+
if (i.attributeName && P.isAliasedAttributeReflection(
|
|
4162
4199
|
n,
|
|
4163
4200
|
i.attributeName
|
|
4164
4201
|
))
|
|
4165
4202
|
break;
|
|
4166
|
-
|
|
4203
|
+
P.setAttribute(
|
|
4167
4204
|
n,
|
|
4168
4205
|
i.attributeName,
|
|
4169
4206
|
n.getAttribute(i.attributeName)
|
|
4170
|
-
),
|
|
4207
|
+
), $.syncElement(n);
|
|
4171
4208
|
break;
|
|
4172
4209
|
}
|
|
4173
4210
|
case "childList": {
|
|
4174
|
-
|
|
4211
|
+
f.info(
|
|
4175
4212
|
"[Haori]",
|
|
4176
4213
|
"Child list changed:",
|
|
4177
4214
|
Array.from(i.removedNodes).map((n) => n.nodeName),
|
|
4178
4215
|
Array.from(i.addedNodes).map((n) => n.nodeName)
|
|
4179
4216
|
), Array.from(i.removedNodes).forEach((n) => {
|
|
4180
|
-
|
|
4217
|
+
$.cleanupTree(n), P.removeNode(n);
|
|
4181
4218
|
}), Array.from(i.addedNodes).forEach((n) => {
|
|
4182
|
-
n.parentElement instanceof HTMLElement && (
|
|
4219
|
+
n.parentElement instanceof HTMLElement && (P.addNode(n.parentElement, n), $.syncTree(n));
|
|
4183
4220
|
});
|
|
4184
4221
|
break;
|
|
4185
4222
|
}
|
|
4186
4223
|
case "characterData": {
|
|
4187
|
-
|
|
4224
|
+
f.info(
|
|
4188
4225
|
"[Haori]",
|
|
4189
4226
|
"Character data changed:",
|
|
4190
4227
|
i.target,
|
|
4191
4228
|
i.target.textContent
|
|
4192
|
-
), i.target instanceof Text || i.target instanceof Comment ?
|
|
4229
|
+
), i.target instanceof Text || i.target instanceof Comment ? P.changeText(i.target, i.target.textContent) : f.warn(
|
|
4193
4230
|
"[Haori]",
|
|
4194
4231
|
"Unsupported character data type:",
|
|
4195
4232
|
i.target
|
|
@@ -4197,32 +4234,32 @@ const H = class H {
|
|
|
4197
4234
|
break;
|
|
4198
4235
|
}
|
|
4199
4236
|
default:
|
|
4200
|
-
|
|
4237
|
+
f.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
4201
4238
|
continue;
|
|
4202
4239
|
}
|
|
4203
4240
|
} catch (n) {
|
|
4204
|
-
|
|
4241
|
+
f.error("[Haori]", "Error processing mutation:", n);
|
|
4205
4242
|
}
|
|
4206
4243
|
}).observe(t, {
|
|
4207
4244
|
childList: !0,
|
|
4208
4245
|
subtree: !0,
|
|
4209
4246
|
attributes: !0,
|
|
4210
4247
|
characterData: !0
|
|
4211
|
-
}),
|
|
4248
|
+
}), f.info("[Haori]", "Observer initialized for", t);
|
|
4212
4249
|
}
|
|
4213
4250
|
};
|
|
4214
4251
|
H._initialized = !1;
|
|
4215
4252
|
let q = H;
|
|
4216
4253
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4217
|
-
const pt = "0.4.
|
|
4254
|
+
const pt = "0.4.9";
|
|
4218
4255
|
export {
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4256
|
+
P as Core,
|
|
4257
|
+
u as Env,
|
|
4258
|
+
A as Form,
|
|
4222
4259
|
w as Fragment,
|
|
4223
4260
|
X as Haori,
|
|
4224
|
-
|
|
4225
|
-
|
|
4261
|
+
f as Log,
|
|
4262
|
+
F as Queue,
|
|
4226
4263
|
X as default,
|
|
4227
4264
|
pt as version
|
|
4228
4265
|
};
|