haori 0.4.3 → 0.4.4
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 +4 -1
- package/README.md +4 -1
- package/dist/haori.cjs.js +11 -9
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +715 -603
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +8 -6
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +66 -3
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts +17 -0
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +75 -22
- package/dist/src/core.js.map +1 -1
- package/dist/src/form.d.ts +12 -1
- package/dist/src/form.d.ts.map +1 -1
- package/dist/src/form.js +20 -3
- package/dist/src/form.js.map +1 -1
- package/dist/src/fragment.d.ts +27 -0
- package/dist/src/fragment.d.ts.map +1 -1
- package/dist/src/fragment.js +62 -8
- package/dist/src/fragment.js.map +1 -1
- package/dist/src/haori.d.ts +10 -2
- package/dist/src/haori.d.ts.map +1 -1
- package/dist/src/haori.js +23 -11
- package/dist/src/haori.js.map +1 -1
- package/dist/src/observer.d.ts.map +1 -1
- package/dist/src/observer.js +4 -0
- package/dist/src/observer.js.map +1 -1
- package/dist/src/procedure.d.ts +2 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +7 -3
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/core.test.js +40 -0
- package/dist/tests/core.test.js.map +1 -1
- package/dist/tests/fetch-and-procedure-scenarios.test.js +54 -0
- package/dist/tests/fetch-and-procedure-scenarios.test.js.map +1 -1
- package/dist/tests/haori.test.d.ts +2 -0
- package/dist/tests/haori.test.d.ts.map +1 -0
- package/dist/tests/haori.test.js +149 -0
- package/dist/tests/haori.test.js.map +1 -0
- package/dist/tests/helpers/async.d.ts.map +1 -1
- package/dist/tests/helpers/async.js +1 -0
- package/dist/tests/helpers/async.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +1 -0
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -30,21 +30,21 @@ const O = class O {
|
|
|
30
30
|
};
|
|
31
31
|
O.devMode = !1;
|
|
32
32
|
let B = O;
|
|
33
|
-
const
|
|
34
|
-
function
|
|
33
|
+
const Y = "embedded";
|
|
34
|
+
function tt(F) {
|
|
35
35
|
return F === "embedded" || F === "demo";
|
|
36
36
|
}
|
|
37
37
|
function et(F) {
|
|
38
|
-
return F === null ? null :
|
|
38
|
+
return F === null ? null : tt(F) ? F : Y;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const D = class D {
|
|
41
41
|
/**
|
|
42
42
|
* 実行モードを取得します。
|
|
43
43
|
*
|
|
44
44
|
* @returns 実行モード。
|
|
45
45
|
*/
|
|
46
46
|
static get runtime() {
|
|
47
|
-
return
|
|
47
|
+
return D._runtime;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 実行モードを設定します。
|
|
@@ -53,7 +53,7 @@ const M = class M {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
|
|
56
|
+
D._runtime = tt(t) ? t : Y;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -65,14 +65,14 @@ const M = class M {
|
|
|
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") || D._prefix;
|
|
69
|
+
D._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
70
|
const i = et(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
|
-
i !== null && (
|
|
73
|
+
i !== null && (D._runtime = i);
|
|
74
74
|
}
|
|
75
|
-
if (t instanceof HTMLScriptElement && t.hasAttribute(`${
|
|
75
|
+
if (t instanceof HTMLScriptElement && t.hasAttribute(`${D._prefix}dev`)) {
|
|
76
76
|
B.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
@@ -91,13 +91,13 @@ const M = class M {
|
|
|
91
91
|
* @returns プレフィックス
|
|
92
92
|
*/
|
|
93
93
|
static get prefix() {
|
|
94
|
-
return
|
|
94
|
+
return D._prefix;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
100
|
-
class
|
|
97
|
+
D._prefix = "data-", D._runtime = Y;
|
|
98
|
+
let l = D;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l.detect) : l.detect();
|
|
100
|
+
class f {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
103
103
|
*
|
|
@@ -168,13 +168,13 @@ class rt {
|
|
|
168
168
|
const r = await e.task();
|
|
169
169
|
e.resolve(r);
|
|
170
170
|
} catch (r) {
|
|
171
|
-
e.reject(r),
|
|
171
|
+
e.reject(r), 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
|
}
|
|
@@ -202,7 +202,7 @@ class rt {
|
|
|
202
202
|
t.length > 0 && await Promise.allSettled(t);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const Q = class Q {
|
|
206
206
|
/**
|
|
207
207
|
* タスクをキューに追加します。
|
|
208
208
|
*
|
|
@@ -220,16 +220,16 @@ const z = class z {
|
|
|
220
220
|
return this.ASYNC_QUEUE.wait();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
|
|
224
|
-
let P =
|
|
225
|
-
class
|
|
223
|
+
Q.ASYNC_QUEUE = new rt();
|
|
224
|
+
let P = Q;
|
|
225
|
+
class X {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
228
228
|
*
|
|
229
229
|
* @return 実行モード。
|
|
230
230
|
*/
|
|
231
231
|
static get runtime() {
|
|
232
|
-
return
|
|
232
|
+
return l.runtime;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* 実行モードを設定します。
|
|
@@ -238,7 +238,7 @@ class tt {
|
|
|
238
238
|
* @return 戻り値はありません。
|
|
239
239
|
*/
|
|
240
240
|
static setRuntime(t) {
|
|
241
|
-
|
|
241
|
+
l.setRuntime(t);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* 通知ダイアログを表示します。
|
|
@@ -255,12 +255,12 @@ class tt {
|
|
|
255
255
|
* 通知トーストを表示します。
|
|
256
256
|
*
|
|
257
257
|
* @param message 表示メッセージ
|
|
258
|
-
* @param level
|
|
258
|
+
* @param level メッセージのレベル(省略時は 'info')
|
|
259
259
|
* @return 通知が表示されると解決されるPromise
|
|
260
260
|
*/
|
|
261
|
-
static async toast(t, e) {
|
|
261
|
+
static async toast(t, e = "info") {
|
|
262
262
|
const r = document.createElement("div");
|
|
263
|
-
r.className = `haori-toast haori-toast-${e}`, r.textContent = t, r.setAttribute("popover", "manual"), r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite"), document.body.appendChild(r), r.showPopover(), setTimeout(() => {
|
|
263
|
+
r.className = `haori-toast haori-toast-${e}`, r.textContent = t, r.setAttribute("popover", "manual"), r.setAttribute("role", "status"), r.setAttribute("aria-live", e === "error" ? "assertive" : "polite"), document.body.appendChild(r), r.showPopover(), setTimeout(() => {
|
|
264
264
|
try {
|
|
265
265
|
r.hidePopover();
|
|
266
266
|
} finally {
|
|
@@ -284,7 +284,7 @@ class tt {
|
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
286
|
return P.enqueue(() => {
|
|
287
|
-
t instanceof HTMLDialogElement ? t.showModal() :
|
|
287
|
+
t instanceof HTMLDialogElement ? t.showModal() : f.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
@@ -294,7 +294,7 @@ class tt {
|
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
296
|
return P.enqueue(() => {
|
|
297
|
-
t instanceof HTMLDialogElement ? t.close() :
|
|
297
|
+
t instanceof HTMLDialogElement ? t.close() : f.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
@@ -304,16 +304,19 @@ class tt {
|
|
|
304
304
|
* @param message エラーメッセージ
|
|
305
305
|
*/
|
|
306
306
|
static addErrorMessage(t, e) {
|
|
307
|
+
return X.addMessage(t, e, "error");
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* メッセージをレベル付きで追加します。
|
|
311
|
+
*
|
|
312
|
+
* @param target メッセージを表示する要素
|
|
313
|
+
* @param message メッセージ
|
|
314
|
+
* @param level メッセージのレベル(省略可能)
|
|
315
|
+
*/
|
|
316
|
+
static addMessage(t, e, r) {
|
|
307
317
|
return P.enqueue(() => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
if (t.parentElement) {
|
|
313
|
-
t.parentElement.setAttribute("data-message", e);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
t.setAttribute("data-message", e);
|
|
318
|
+
const i = t instanceof HTMLFormElement ? t : t.parentElement ?? t;
|
|
319
|
+
i.setAttribute("data-message", e), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
317
320
|
}, !0);
|
|
318
321
|
}
|
|
319
322
|
/**
|
|
@@ -323,20 +326,20 @@ class tt {
|
|
|
323
326
|
*/
|
|
324
327
|
static clearMessages(t) {
|
|
325
328
|
return P.enqueue(() => {
|
|
326
|
-
t.removeAttribute("data-message"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
327
|
-
e.removeAttribute("data-message");
|
|
329
|
+
t.removeAttribute("data-message"), t.removeAttribute("data-message-level"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
330
|
+
e.removeAttribute("data-message"), e.removeAttribute("data-message-level");
|
|
328
331
|
});
|
|
329
332
|
}, !0);
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
335
|
const it = ["addErrorMessage", "clearMessages"];
|
|
333
|
-
function
|
|
336
|
+
function _() {
|
|
334
337
|
const t = globalThis.window?.Haori;
|
|
335
338
|
return it.every(
|
|
336
339
|
(r) => typeof t?.[r] == "function"
|
|
337
|
-
) ? t :
|
|
340
|
+
) ? t : X;
|
|
338
341
|
}
|
|
339
|
-
class
|
|
342
|
+
class b {
|
|
340
343
|
/**
|
|
341
344
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
342
345
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -347,7 +350,7 @@ class m {
|
|
|
347
350
|
*/
|
|
348
351
|
static getValues(t) {
|
|
349
352
|
const e = {};
|
|
350
|
-
return
|
|
353
|
+
return b.getPartValues(t, e);
|
|
351
354
|
}
|
|
352
355
|
/**
|
|
353
356
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -358,32 +361,32 @@ class m {
|
|
|
358
361
|
* @returns values と同じオブジェクト
|
|
359
362
|
*/
|
|
360
363
|
static getPartValues(t, e) {
|
|
361
|
-
const r = t.getAttribute("name"), i = t.getAttribute(`${
|
|
364
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${l.prefix}form-object`), s = t.getAttribute(`${l.prefix}form-list`);
|
|
362
365
|
if (r) {
|
|
363
|
-
s ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i &&
|
|
366
|
+
s ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && f.warn(
|
|
364
367
|
"Haori",
|
|
365
|
-
`Element cannot have both ${
|
|
368
|
+
`Element cannot have both ${l.prefix}form-object and name attributes.`
|
|
366
369
|
);
|
|
367
370
|
for (const n of t.getChildElementFragments())
|
|
368
|
-
|
|
371
|
+
b.getPartValues(n, e);
|
|
369
372
|
} else if (i) {
|
|
370
373
|
const n = {};
|
|
371
374
|
for (const a of t.getChildElementFragments())
|
|
372
|
-
|
|
373
|
-
Object.keys(n).length > 0 && (e[String(i)] = n), s &&
|
|
375
|
+
b.getPartValues(a, n);
|
|
376
|
+
Object.keys(n).length > 0 && (e[String(i)] = n), s && f.warn(
|
|
374
377
|
"Haori",
|
|
375
|
-
`Element cannot have both ${
|
|
378
|
+
`Element cannot have both ${l.prefix}form-list and ${l.prefix}form-object attributes.`
|
|
376
379
|
);
|
|
377
380
|
} else if (s) {
|
|
378
381
|
const n = [];
|
|
379
382
|
for (const a of t.getChildElementFragments()) {
|
|
380
383
|
const o = {};
|
|
381
|
-
|
|
384
|
+
b.getPartValues(a, o), Object.keys(o).length > 0 && n.push(o);
|
|
382
385
|
}
|
|
383
386
|
n.length > 0 && (e[String(s)] = n);
|
|
384
387
|
} else
|
|
385
388
|
for (const n of t.getChildElementFragments())
|
|
386
|
-
|
|
389
|
+
b.getPartValues(n, e);
|
|
387
390
|
return e;
|
|
388
391
|
}
|
|
389
392
|
/**
|
|
@@ -396,7 +399,7 @@ class m {
|
|
|
396
399
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
397
400
|
*/
|
|
398
401
|
static setValues(t, e, r = !1) {
|
|
399
|
-
return
|
|
402
|
+
return b.setPartValues(t, e, null, r, !0);
|
|
400
403
|
}
|
|
401
404
|
/**
|
|
402
405
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -408,7 +411,7 @@ class m {
|
|
|
408
411
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
409
412
|
*/
|
|
410
413
|
static syncValues(t, e, r = !1) {
|
|
411
|
-
return
|
|
414
|
+
return b.setPartValues(t, e, null, r, !1);
|
|
412
415
|
}
|
|
413
416
|
/**
|
|
414
417
|
* 単一フラグメントへ値を設定します。
|
|
@@ -431,50 +434,50 @@ class m {
|
|
|
431
434
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
432
435
|
*/
|
|
433
436
|
static setPartValues(t, e, r = null, i = !1, s = !0) {
|
|
434
|
-
const n = [], a = t.getAttribute("name"), o = t.getAttribute(`${
|
|
437
|
+
const n = [], a = t.getAttribute("name"), o = t.getAttribute(`${l.prefix}form-object`), d = t.getAttribute(`${l.prefix}form-list`), m = t.getAttribute(`${l.prefix}form-detach`);
|
|
435
438
|
if (a) {
|
|
436
|
-
if (!
|
|
437
|
-
const
|
|
438
|
-
d && Array.isArray(
|
|
439
|
-
|
|
440
|
-
) : typeof
|
|
441
|
-
|
|
439
|
+
if (!m || i) {
|
|
440
|
+
const y = e[String(a)];
|
|
441
|
+
d && Array.isArray(y) && r !== null ? n.push(
|
|
442
|
+
b.applyFragmentValue(t, y[r] ?? null, s)
|
|
443
|
+
) : typeof y > "u" || (typeof y == "string" || typeof y == "number" || typeof y == "boolean" || y === null ? n.push(b.applyFragmentValue(t, y, s)) : n.push(
|
|
444
|
+
b.applyFragmentValue(t, String(y), s)
|
|
442
445
|
));
|
|
443
446
|
}
|
|
444
447
|
} else if (o) {
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
for (const
|
|
448
|
+
const y = e[String(o)];
|
|
449
|
+
if (y && typeof y == "object")
|
|
450
|
+
for (const E of t.getChildElementFragments())
|
|
448
451
|
n.push(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
+
b.setPartValues(
|
|
453
|
+
E,
|
|
454
|
+
y,
|
|
452
455
|
null,
|
|
453
456
|
i,
|
|
454
457
|
s
|
|
455
458
|
)
|
|
456
459
|
);
|
|
457
460
|
} else if (d) {
|
|
458
|
-
const
|
|
459
|
-
if (Array.isArray(
|
|
460
|
-
const
|
|
461
|
-
for (let S = 0; S <
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
461
|
+
const y = e[String(d)];
|
|
462
|
+
if (Array.isArray(y)) {
|
|
463
|
+
const E = t.getChildElementFragments();
|
|
464
|
+
for (let S = 0; S < E.length; S++) {
|
|
465
|
+
const u = E[S];
|
|
466
|
+
y.length > S ? n.push(
|
|
467
|
+
b.setPartValues(
|
|
468
|
+
u,
|
|
469
|
+
y[S],
|
|
467
470
|
S,
|
|
468
471
|
i,
|
|
469
472
|
s
|
|
470
473
|
)
|
|
471
|
-
) : n.push(
|
|
474
|
+
) : n.push(b.setPartValues(u, {}, S, i, s));
|
|
472
475
|
}
|
|
473
476
|
}
|
|
474
477
|
} else
|
|
475
|
-
for (const
|
|
478
|
+
for (const y of t.getChildElementFragments())
|
|
476
479
|
n.push(
|
|
477
|
-
|
|
480
|
+
b.setPartValues(y, e, null, i, s)
|
|
478
481
|
);
|
|
479
482
|
return Promise.all(n).then(() => {
|
|
480
483
|
});
|
|
@@ -487,9 +490,9 @@ class m {
|
|
|
487
490
|
* @returns すべての初期化処理が完了するPromise
|
|
488
491
|
*/
|
|
489
492
|
static async reset(t) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
+
b.clearValues(t), await Promise.all([
|
|
494
|
+
b.clearMessages(t),
|
|
495
|
+
b.clearEachClones(t)
|
|
493
496
|
]), await P.enqueue(() => {
|
|
494
497
|
const e = t.getTarget();
|
|
495
498
|
if (e instanceof HTMLFormElement)
|
|
@@ -511,9 +514,9 @@ class m {
|
|
|
511
514
|
*/
|
|
512
515
|
static clearEachClones(t) {
|
|
513
516
|
const e = [], r = (s) => {
|
|
514
|
-
if (s.hasAttribute(`${
|
|
517
|
+
if (s.hasAttribute(`${l.prefix}each`))
|
|
515
518
|
for (const n of s.getChildElementFragments()) {
|
|
516
|
-
const a = n.hasAttribute(`${
|
|
519
|
+
const a = n.hasAttribute(`${l.prefix}each-before`), o = n.hasAttribute(`${l.prefix}each-after`);
|
|
517
520
|
!a && !o && e.push(n.remove());
|
|
518
521
|
}
|
|
519
522
|
}, i = (s) => {
|
|
@@ -535,7 +538,7 @@ class m {
|
|
|
535
538
|
static clearValues(t) {
|
|
536
539
|
t.clearValue();
|
|
537
540
|
for (const e of t.getChildElementFragments())
|
|
538
|
-
|
|
541
|
+
b.clearValues(e);
|
|
539
542
|
}
|
|
540
543
|
/**
|
|
541
544
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -544,7 +547,7 @@ class m {
|
|
|
544
547
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
545
548
|
*/
|
|
546
549
|
static clearMessages(t) {
|
|
547
|
-
return
|
|
550
|
+
return _().clearMessages(
|
|
548
551
|
t.getTarget()
|
|
549
552
|
);
|
|
550
553
|
}
|
|
@@ -554,18 +557,27 @@ class m {
|
|
|
554
557
|
*
|
|
555
558
|
* @param fragment 対象フラグメント
|
|
556
559
|
* @param key キー(ドット区切りの文字列)
|
|
557
|
-
* @param message 追加するエラーメッセージ
|
|
560
|
+
* @param message 追加するエラーメッセージ
|
|
558
561
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
559
562
|
*/
|
|
560
563
|
static addErrorMessage(t, e, r) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
564
|
+
return b.addMessage(t, e, r, "error");
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
568
|
+
* キーに一致するフラグメントが見つからない場合は、指定されたフラグメントにメッセージを追加します。
|
|
569
|
+
*
|
|
570
|
+
* @param fragment 対象フラグメント
|
|
571
|
+
* @param key キー(ドット区切りの文字列)
|
|
572
|
+
* @param message 追加するメッセージ
|
|
573
|
+
* @param level メッセージのレベル(省略可能)
|
|
574
|
+
* @return Promise(メッセージの追加が完了したら解決される)
|
|
575
|
+
*/
|
|
576
|
+
static addMessage(t, e, r, i) {
|
|
577
|
+
const s = [], n = _(), a = n.addMessage, o = (m) => typeof a == "function" ? a.call(n, m, r, i) : n.addErrorMessage(m, r), d = b.findFragmentsByKey(t, e);
|
|
578
|
+
return d.forEach((m) => {
|
|
579
|
+
s.push(o(m.getTarget()));
|
|
580
|
+
}), d.length === 0 && s.push(o(t.getTarget())), Promise.all(s).then(() => {
|
|
569
581
|
});
|
|
570
582
|
}
|
|
571
583
|
/**
|
|
@@ -576,7 +588,7 @@ class m {
|
|
|
576
588
|
* @returns 一致するフラグメントの配列
|
|
577
589
|
*/
|
|
578
590
|
static findFragmentsByKey(t, e) {
|
|
579
|
-
return
|
|
591
|
+
return b.findFragmentByKeyParts(t, e.split("."));
|
|
580
592
|
}
|
|
581
593
|
/**
|
|
582
594
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -588,23 +600,23 @@ class m {
|
|
|
588
600
|
*/
|
|
589
601
|
static findFragmentByKeyParts(t, e) {
|
|
590
602
|
const r = [], i = e[0];
|
|
591
|
-
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${
|
|
592
|
-
e.length > 1 && t.getAttribute(`${
|
|
593
|
-
r.push(...
|
|
603
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${l.prefix}form-object`))
|
|
604
|
+
e.length > 1 && t.getAttribute(`${l.prefix}form-object`) === i && t.getChildElementFragments().forEach((n) => {
|
|
605
|
+
r.push(...b.findFragmentByKeyParts(n, e.slice(1)));
|
|
594
606
|
});
|
|
595
|
-
else if (t.hasAttribute(`${
|
|
607
|
+
else if (t.hasAttribute(`${l.prefix}form-list`)) {
|
|
596
608
|
if (e.length > 1) {
|
|
597
|
-
const s = t.getAttribute(`${
|
|
609
|
+
const s = t.getAttribute(`${l.prefix}form-list`), n = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
598
610
|
if (n !== -1 && a !== -1 && n < a) {
|
|
599
611
|
const o = i.substring(0, n);
|
|
600
612
|
if (s === o) {
|
|
601
|
-
const d = i.substring(n + 1, a),
|
|
602
|
-
if (isNaN(
|
|
603
|
-
|
|
613
|
+
const d = i.substring(n + 1, a), m = Number(d);
|
|
614
|
+
if (isNaN(m))
|
|
615
|
+
f.error("Haori", `Invalid index: ${i}`);
|
|
604
616
|
else {
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
...
|
|
617
|
+
const y = t.getChildElementFragments().filter((E) => E.hasAttribute(`${l.prefix}row`));
|
|
618
|
+
m < y.length && r.push(
|
|
619
|
+
...b.findFragmentByKeyParts(y[m], e.slice(1))
|
|
608
620
|
);
|
|
609
621
|
}
|
|
610
622
|
}
|
|
@@ -612,7 +624,7 @@ class m {
|
|
|
612
624
|
}
|
|
613
625
|
} else
|
|
614
626
|
t.getChildElementFragments().forEach((s) => {
|
|
615
|
-
r.push(...
|
|
627
|
+
r.push(...b.findFragmentByKeyParts(s, e));
|
|
616
628
|
});
|
|
617
629
|
return r;
|
|
618
630
|
}
|
|
@@ -629,7 +641,7 @@ class m {
|
|
|
629
641
|
return r ? this.getFormFragment(r) : null;
|
|
630
642
|
}
|
|
631
643
|
}
|
|
632
|
-
const
|
|
644
|
+
const M = class M {
|
|
633
645
|
/**
|
|
634
646
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
635
647
|
*
|
|
@@ -674,13 +686,13 @@ const R = class R {
|
|
|
674
686
|
*/
|
|
675
687
|
static evaluate(t, e = {}) {
|
|
676
688
|
if (t.trim() === "")
|
|
677
|
-
return
|
|
689
|
+
return f.warn("[Haori]", t, "Expression is empty"), null;
|
|
678
690
|
if (this.containsDangerousPatterns(t))
|
|
679
|
-
return
|
|
691
|
+
return f.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
680
692
|
if (this.containsForbiddenKeys(e))
|
|
681
|
-
return
|
|
693
|
+
return f.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
682
694
|
if (this.containsForbiddenBindingValues(e))
|
|
683
|
-
return
|
|
695
|
+
return f.warn(
|
|
684
696
|
"[Haori]",
|
|
685
697
|
e,
|
|
686
698
|
"Binded values contain forbidden values"
|
|
@@ -695,7 +707,7 @@ return (${t});`;
|
|
|
695
707
|
try {
|
|
696
708
|
s = new Function(...r, a), this.EXPRESSION_CACHE.set(i, s);
|
|
697
709
|
} catch (o) {
|
|
698
|
-
return
|
|
710
|
+
return f.error(
|
|
699
711
|
"[Haori]",
|
|
700
712
|
"Failed to compile expression:",
|
|
701
713
|
t,
|
|
@@ -709,7 +721,7 @@ return (${t});`;
|
|
|
709
721
|
n.push(a[o]);
|
|
710
722
|
}), this.withBlockedPropertyAccess(() => s(...n));
|
|
711
723
|
} catch (n) {
|
|
712
|
-
return
|
|
724
|
+
return f.error("[Haori]", "Expression evaluation error:", t, n), n instanceof ReferenceError ? void 0 : null;
|
|
713
725
|
}
|
|
714
726
|
}
|
|
715
727
|
/**
|
|
@@ -1122,7 +1134,7 @@ return (${t});`;
|
|
|
1122
1134
|
return !1;
|
|
1123
1135
|
}
|
|
1124
1136
|
};
|
|
1125
|
-
|
|
1137
|
+
M.FORBIDDEN_NAMES = [
|
|
1126
1138
|
// グローバルオブジェクト
|
|
1127
1139
|
"window",
|
|
1128
1140
|
"self",
|
|
@@ -1154,19 +1166,19 @@ R.FORBIDDEN_NAMES = [
|
|
|
1154
1166
|
"sessionStorage",
|
|
1155
1167
|
"IndexedDB",
|
|
1156
1168
|
"history"
|
|
1157
|
-
],
|
|
1158
|
-
...
|
|
1159
|
-
(t) => !
|
|
1169
|
+
], M.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], M.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), M.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1170
|
+
...M.FORBIDDEN_NAMES.filter(
|
|
1171
|
+
(t) => !M.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1160
1172
|
),
|
|
1161
1173
|
"constructor",
|
|
1162
1174
|
"__proto__",
|
|
1163
1175
|
"prototype",
|
|
1164
|
-
...
|
|
1165
|
-
]),
|
|
1176
|
+
...M.STRICT_FORBIDDEN_NAMES
|
|
1177
|
+
]), M.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1166
1178
|
"constructor",
|
|
1167
1179
|
"__proto__",
|
|
1168
1180
|
"prototype"
|
|
1169
|
-
]),
|
|
1181
|
+
]), M.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1170
1182
|
"await",
|
|
1171
1183
|
"break",
|
|
1172
1184
|
"case",
|
|
@@ -1200,8 +1212,8 @@ R.FORBIDDEN_NAMES = [
|
|
|
1200
1212
|
"while",
|
|
1201
1213
|
"with",
|
|
1202
1214
|
"yield"
|
|
1203
|
-
]),
|
|
1204
|
-
let j =
|
|
1215
|
+
]), M.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1216
|
+
let j = M;
|
|
1205
1217
|
const C = class C {
|
|
1206
1218
|
/**
|
|
1207
1219
|
* フラグメントのコンストラクタ。
|
|
@@ -1219,16 +1231,16 @@ const C = class C {
|
|
|
1219
1231
|
let e;
|
|
1220
1232
|
switch (t.nodeType) {
|
|
1221
1233
|
case Node.ELEMENT_NODE:
|
|
1222
|
-
e = new
|
|
1234
|
+
e = new R(t);
|
|
1223
1235
|
break;
|
|
1224
1236
|
case Node.TEXT_NODE:
|
|
1225
|
-
e = new
|
|
1237
|
+
e = new H(t);
|
|
1226
1238
|
break;
|
|
1227
1239
|
case Node.COMMENT_NODE:
|
|
1228
|
-
e = new
|
|
1240
|
+
e = new z(t);
|
|
1229
1241
|
break;
|
|
1230
1242
|
default:
|
|
1231
|
-
return
|
|
1243
|
+
return f.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
1232
1244
|
}
|
|
1233
1245
|
return e;
|
|
1234
1246
|
}
|
|
@@ -1334,8 +1346,8 @@ const C = class C {
|
|
|
1334
1346
|
}
|
|
1335
1347
|
};
|
|
1336
1348
|
C.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1337
|
-
let
|
|
1338
|
-
class
|
|
1349
|
+
let T = C;
|
|
1350
|
+
class R extends T {
|
|
1339
1351
|
/**
|
|
1340
1352
|
* エレメントフラグメントのコンストラクタ。
|
|
1341
1353
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1365,7 +1377,7 @@ class D extends N {
|
|
|
1365
1377
|
this.attributeMap.set(e, i);
|
|
1366
1378
|
}
|
|
1367
1379
|
}), t.childNodes.forEach((e) => {
|
|
1368
|
-
const r =
|
|
1380
|
+
const r = T.get(e);
|
|
1369
1381
|
r.setParent(this), this.children.push(r);
|
|
1370
1382
|
});
|
|
1371
1383
|
}
|
|
@@ -1384,7 +1396,7 @@ class D extends N {
|
|
|
1384
1396
|
*/
|
|
1385
1397
|
getChildElementFragments() {
|
|
1386
1398
|
return this.children.filter(
|
|
1387
|
-
(t) => t instanceof
|
|
1399
|
+
(t) => t instanceof R
|
|
1388
1400
|
);
|
|
1389
1401
|
}
|
|
1390
1402
|
/**
|
|
@@ -1405,7 +1417,7 @@ class D extends N {
|
|
|
1405
1417
|
removeChild(t) {
|
|
1406
1418
|
const e = this.children.indexOf(t);
|
|
1407
1419
|
if (e < 0) {
|
|
1408
|
-
|
|
1420
|
+
f.warn("[Haori]", "Child fragment not found.", t);
|
|
1409
1421
|
return;
|
|
1410
1422
|
}
|
|
1411
1423
|
this.children.splice(e, 1), t.setParent(null);
|
|
@@ -1416,7 +1428,7 @@ class D extends N {
|
|
|
1416
1428
|
* @returns クローンされたフラグメント
|
|
1417
1429
|
*/
|
|
1418
1430
|
clone() {
|
|
1419
|
-
const t = new
|
|
1431
|
+
const t = new R(
|
|
1420
1432
|
this.target.cloneNode(!1)
|
|
1421
1433
|
);
|
|
1422
1434
|
return this.attributeMap.forEach((e, r) => {
|
|
@@ -1484,7 +1496,7 @@ class D extends N {
|
|
|
1484
1496
|
*/
|
|
1485
1497
|
clearBindingDataCache() {
|
|
1486
1498
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1487
|
-
t instanceof
|
|
1499
|
+
t instanceof R && t.clearBindingDataCache();
|
|
1488
1500
|
});
|
|
1489
1501
|
}
|
|
1490
1502
|
/**
|
|
@@ -1563,7 +1575,7 @@ class D extends N {
|
|
|
1563
1575
|
r.value = t === null ? "" : String(t), e && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
1564
1576
|
}).finally(() => {
|
|
1565
1577
|
this.skipChangeValue = !1;
|
|
1566
|
-
})) : (
|
|
1578
|
+
})) : (f.warn(
|
|
1567
1579
|
"[Haori]",
|
|
1568
1580
|
"setValue is not supported for this element type.",
|
|
1569
1581
|
r
|
|
@@ -1614,19 +1626,60 @@ class D extends N {
|
|
|
1614
1626
|
* @returns 属性の更新のPromise
|
|
1615
1627
|
*/
|
|
1616
1628
|
setAttribute(t, e) {
|
|
1629
|
+
return this.setAttributeInternal(t, t, e, !0);
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* data-attr-* の生値を保持しつつ、別名の属性へ評価結果を反映します。
|
|
1633
|
+
*
|
|
1634
|
+
* @param rawName 生の属性名
|
|
1635
|
+
* @param targetName 反映先の属性名
|
|
1636
|
+
* @param value 生の属性値
|
|
1637
|
+
* @returns 属性更新の Promise
|
|
1638
|
+
*/
|
|
1639
|
+
setAliasedAttribute(t, e, r) {
|
|
1640
|
+
return this.setAttributeInternal(t, e, r, !1);
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* data-attr-* の生属性と反映先属性を同時に削除します。
|
|
1644
|
+
*
|
|
1645
|
+
* @param rawName 生の属性名
|
|
1646
|
+
* @param targetName 反映先の属性名
|
|
1647
|
+
* @returns 属性削除の Promise
|
|
1648
|
+
*/
|
|
1649
|
+
removeAliasedAttribute(t, e) {
|
|
1617
1650
|
if (this.skipMutationAttributes)
|
|
1618
1651
|
return Promise.resolve();
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1652
|
+
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1653
|
+
const r = this.getTarget();
|
|
1654
|
+
return P.enqueue(() => {
|
|
1655
|
+
r.removeAttribute(t), e !== t && r.removeAttribute(e);
|
|
1656
|
+
}).finally(() => {
|
|
1657
|
+
this.skipMutationAttributes = !1;
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* 生の属性値を保持しつつ、必要に応じて別名属性へ評価結果を反映します。
|
|
1662
|
+
*
|
|
1663
|
+
* @param rawName 生の属性名
|
|
1664
|
+
* @param targetName 反映先の属性名
|
|
1665
|
+
* @param value 生の属性値
|
|
1666
|
+
* @param syncValueProperty value 属性更新時に DOM property も同期するかどうか
|
|
1667
|
+
* @returns 属性更新の Promise
|
|
1668
|
+
*/
|
|
1669
|
+
setAttributeInternal(t, e, r, i) {
|
|
1670
|
+
if (this.skipMutationAttributes)
|
|
1671
|
+
return Promise.resolve();
|
|
1672
|
+
if (r === null)
|
|
1673
|
+
return t === e ? this.removeAttribute(t) : this.removeAliasedAttribute(t, e);
|
|
1674
|
+
const s = new U(t, r);
|
|
1675
|
+
this.attributeMap.set(t, s), this.skipMutationAttributes = !0;
|
|
1676
|
+
const n = this.getTarget(), a = s.isForceEvaluation() ? r : this.getAttribute(t);
|
|
1624
1677
|
return P.enqueue(() => {
|
|
1625
|
-
if (
|
|
1626
|
-
|
|
1678
|
+
if (n.getAttribute(t) !== r && n.setAttribute(t, r), a === null || a === !1)
|
|
1679
|
+
n.removeAttribute(e);
|
|
1627
1680
|
else {
|
|
1628
|
-
const
|
|
1629
|
-
|
|
1681
|
+
const o = String(a);
|
|
1682
|
+
n.getAttribute(e) !== o && n.setAttribute(e, o), i && s.isEvaluate && e === "value" && (n instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(n.type) || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement) && (this.value = o, n.value !== o && (n.value = o));
|
|
1630
1683
|
}
|
|
1631
1684
|
}).finally(() => {
|
|
1632
1685
|
this.skipMutationAttributes = !1;
|
|
@@ -1661,7 +1714,7 @@ class D extends N {
|
|
|
1661
1714
|
if (e === void 0)
|
|
1662
1715
|
return null;
|
|
1663
1716
|
const r = e.evaluate(this.getBindingData());
|
|
1664
|
-
return r.length === 1 ? r[0] :
|
|
1717
|
+
return r.length === 1 ? r[0] : $.joinEvaluateResults(r);
|
|
1665
1718
|
}
|
|
1666
1719
|
/**
|
|
1667
1720
|
* 属性の生の値を取得します。
|
|
@@ -1704,7 +1757,7 @@ class D extends N {
|
|
|
1704
1757
|
const i = e ? r.nextSibling : r;
|
|
1705
1758
|
let s = e ? r.nextSibling : r;
|
|
1706
1759
|
for (; s !== null; ) {
|
|
1707
|
-
const n =
|
|
1760
|
+
const n = T.get(s);
|
|
1708
1761
|
if (n !== null) {
|
|
1709
1762
|
const a = this.children.indexOf(n);
|
|
1710
1763
|
if (a !== -1)
|
|
@@ -1726,42 +1779,42 @@ class D extends N {
|
|
|
1726
1779
|
if (this.skipMutationNodes)
|
|
1727
1780
|
return Promise.resolve();
|
|
1728
1781
|
if (t === this)
|
|
1729
|
-
return
|
|
1782
|
+
return f.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1730
1783
|
const i = /* @__PURE__ */ new Set();
|
|
1731
1784
|
let s = this.parent;
|
|
1732
1785
|
for (; s; )
|
|
1733
1786
|
i.add(s), s = s.getParent();
|
|
1734
1787
|
if (i.has(t))
|
|
1735
|
-
return
|
|
1788
|
+
return f.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1736
1789
|
const n = t.getParent() === this;
|
|
1737
1790
|
let a = -1, o = -1;
|
|
1738
1791
|
n && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1739
1792
|
const d = t.getParent();
|
|
1740
1793
|
d !== null && d.removeChild(t);
|
|
1741
|
-
let
|
|
1794
|
+
let m = r === void 0 ? e?.getTarget() || null : r;
|
|
1742
1795
|
if (e === null)
|
|
1743
1796
|
this.children.push(t);
|
|
1744
1797
|
else {
|
|
1745
|
-
let
|
|
1746
|
-
if (n ? a !== -1 && a < o ?
|
|
1798
|
+
let E;
|
|
1799
|
+
if (n ? a !== -1 && a < o ? E = o - 1 : E = o : E = this.children.indexOf(e), E === -1) {
|
|
1747
1800
|
const S = this.resolveInsertionPointFromDom(
|
|
1748
1801
|
e,
|
|
1749
1802
|
!1
|
|
1750
1803
|
);
|
|
1751
|
-
S === null ? (
|
|
1804
|
+
S === null ? (f.warn(
|
|
1752
1805
|
"[Haori]",
|
|
1753
1806
|
"Reference child not found in children.",
|
|
1754
1807
|
e
|
|
1755
|
-
), this.children.push(t)) : (this.children.splice(S.index, 0, t),
|
|
1808
|
+
), this.children.push(t)) : (this.children.splice(S.index, 0, t), m = S.referenceNode);
|
|
1756
1809
|
} else
|
|
1757
|
-
this.children.splice(
|
|
1810
|
+
this.children.splice(E, 0, t);
|
|
1758
1811
|
}
|
|
1759
1812
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1760
|
-
const
|
|
1813
|
+
const y = this.skipMutationNodes;
|
|
1761
1814
|
return this.skipMutationNodes = !0, P.enqueue(() => {
|
|
1762
|
-
this.target.insertBefore(t.getTarget(),
|
|
1815
|
+
this.target.insertBefore(t.getTarget(), m);
|
|
1763
1816
|
}).finally(() => {
|
|
1764
|
-
this.skipMutationNodes =
|
|
1817
|
+
this.skipMutationNodes = y;
|
|
1765
1818
|
});
|
|
1766
1819
|
}
|
|
1767
1820
|
/**
|
|
@@ -1780,7 +1833,7 @@ class D extends N {
|
|
|
1780
1833
|
e,
|
|
1781
1834
|
!0
|
|
1782
1835
|
);
|
|
1783
|
-
return i === null ? (
|
|
1836
|
+
return i === null ? (f.warn(
|
|
1784
1837
|
"[Haori]",
|
|
1785
1838
|
"Reference child not found in children.",
|
|
1786
1839
|
e
|
|
@@ -1832,7 +1885,7 @@ class D extends N {
|
|
|
1832
1885
|
* @returns エレメントの非表示のPromise
|
|
1833
1886
|
*/
|
|
1834
1887
|
hide() {
|
|
1835
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1888
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${l.prefix}if-false`, ""), Promise.resolve();
|
|
1836
1889
|
}
|
|
1837
1890
|
/**
|
|
1838
1891
|
* エレメントを表示します。
|
|
@@ -1840,7 +1893,7 @@ class D extends N {
|
|
|
1840
1893
|
* @return エレメントの表示のPromise
|
|
1841
1894
|
*/
|
|
1842
1895
|
show() {
|
|
1843
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1896
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${l.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1844
1897
|
}
|
|
1845
1898
|
/**
|
|
1846
1899
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1856,7 +1909,7 @@ class D extends N {
|
|
|
1856
1909
|
return e === null ? null : e.closestByAttribute(t);
|
|
1857
1910
|
}
|
|
1858
1911
|
}
|
|
1859
|
-
class
|
|
1912
|
+
class H extends T {
|
|
1860
1913
|
/**
|
|
1861
1914
|
* テキストフラグメントのコンストラクタ。
|
|
1862
1915
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -1864,7 +1917,7 @@ class L extends N {
|
|
|
1864
1917
|
* @param target 対象テキストノード
|
|
1865
1918
|
*/
|
|
1866
1919
|
constructor(t) {
|
|
1867
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1920
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new $(this.text);
|
|
1868
1921
|
}
|
|
1869
1922
|
/**
|
|
1870
1923
|
* フラグメントをクローンします。
|
|
@@ -1872,7 +1925,7 @@ class L extends N {
|
|
|
1872
1925
|
* @returns クローンされたフラグメント
|
|
1873
1926
|
*/
|
|
1874
1927
|
clone() {
|
|
1875
|
-
const t = new
|
|
1928
|
+
const t = new H(this.target.cloneNode(!0));
|
|
1876
1929
|
return t.mounted = !1, t.text = this.text, t.contents = this.contents, t;
|
|
1877
1930
|
}
|
|
1878
1931
|
/**
|
|
@@ -1890,7 +1943,7 @@ class L extends N {
|
|
|
1890
1943
|
* @returns 更新のPromise
|
|
1891
1944
|
*/
|
|
1892
1945
|
setContent(t) {
|
|
1893
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1946
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new $(t), this.evaluate());
|
|
1894
1947
|
}
|
|
1895
1948
|
/**
|
|
1896
1949
|
* フラグメントを評価します。
|
|
@@ -1903,7 +1956,7 @@ class L extends N {
|
|
|
1903
1956
|
) : P.enqueue(() => {
|
|
1904
1957
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1905
1958
|
this.parent.getBindingData()
|
|
1906
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1959
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = $.joinEvaluateResults(
|
|
1907
1960
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1908
1961
|
) : this.target.textContent = this.text;
|
|
1909
1962
|
}).finally(() => {
|
|
@@ -1911,7 +1964,7 @@ class L extends N {
|
|
|
1911
1964
|
});
|
|
1912
1965
|
}
|
|
1913
1966
|
}
|
|
1914
|
-
class
|
|
1967
|
+
class z extends T {
|
|
1915
1968
|
/**
|
|
1916
1969
|
* コメントフラグメントのコンストラクタ。
|
|
1917
1970
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1927,7 +1980,7 @@ class Y extends N {
|
|
|
1927
1980
|
* @returns クローンされたフラグメント
|
|
1928
1981
|
*/
|
|
1929
1982
|
clone() {
|
|
1930
|
-
const t = new
|
|
1983
|
+
const t = new z(this.target.cloneNode(!0));
|
|
1931
1984
|
return t.mounted = !1, t.text = this.text, t;
|
|
1932
1985
|
}
|
|
1933
1986
|
/**
|
|
@@ -2003,7 +2056,7 @@ const G = class G {
|
|
|
2003
2056
|
*/
|
|
2004
2057
|
checkRawExpressions() {
|
|
2005
2058
|
for (let t = 0; t < this.contents.length; t++)
|
|
2006
|
-
this.contents[t].type === 2 && this.contents.length > 1 && (
|
|
2059
|
+
this.contents[t].type === 2 && this.contents.length > 1 && (f.error(
|
|
2007
2060
|
"[Haori]",
|
|
2008
2061
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2009
2062
|
), this.contents[t].type = 1);
|
|
@@ -2026,7 +2079,7 @@ const G = class G {
|
|
|
2026
2079
|
} else
|
|
2027
2080
|
e.push(r.text);
|
|
2028
2081
|
} catch (i) {
|
|
2029
|
-
|
|
2082
|
+
f.error(
|
|
2030
2083
|
"[Haori]",
|
|
2031
2084
|
`Error evaluating text expression: ${r.text}`,
|
|
2032
2085
|
i
|
|
@@ -2036,8 +2089,8 @@ const G = class G {
|
|
|
2036
2089
|
}
|
|
2037
2090
|
};
|
|
2038
2091
|
G.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2039
|
-
let
|
|
2040
|
-
const K = class K extends
|
|
2092
|
+
let $ = G;
|
|
2093
|
+
const K = class K extends $ {
|
|
2041
2094
|
/**
|
|
2042
2095
|
* コンストラクタ。
|
|
2043
2096
|
*
|
|
@@ -2073,13 +2126,13 @@ const K = class K extends I {
|
|
|
2073
2126
|
} else
|
|
2074
2127
|
e.push(r.text);
|
|
2075
2128
|
} catch (i) {
|
|
2076
|
-
|
|
2129
|
+
f.error(
|
|
2077
2130
|
"[Haori]",
|
|
2078
2131
|
`Error evaluating attribute expression: ${r.text}`,
|
|
2079
2132
|
i
|
|
2080
2133
|
), e.push("");
|
|
2081
2134
|
}
|
|
2082
|
-
}), this.forceEvaluation && e.length > 1 ? (
|
|
2135
|
+
}), this.forceEvaluation && e.length > 1 ? (f.error(
|
|
2083
2136
|
"[Haori]",
|
|
2084
2137
|
"each or if expressions must have a single content.",
|
|
2085
2138
|
e
|
|
@@ -2093,7 +2146,7 @@ K.FORCE_EVALUATION_ATTRIBUTES = [
|
|
|
2093
2146
|
"hor-each"
|
|
2094
2147
|
];
|
|
2095
2148
|
let U = K;
|
|
2096
|
-
class
|
|
2149
|
+
class w {
|
|
2097
2150
|
/**
|
|
2098
2151
|
* カスタムイベントを発火します。
|
|
2099
2152
|
*
|
|
@@ -2117,7 +2170,7 @@ class v {
|
|
|
2117
2170
|
* @param version ライブラリバージョン
|
|
2118
2171
|
*/
|
|
2119
2172
|
static ready(t) {
|
|
2120
|
-
|
|
2173
|
+
w.dispatch(document, "ready", { version: t });
|
|
2121
2174
|
}
|
|
2122
2175
|
/**
|
|
2123
2176
|
* renderイベントを発火します。
|
|
@@ -2125,7 +2178,7 @@ class v {
|
|
|
2125
2178
|
* @param target 評価対象要素
|
|
2126
2179
|
*/
|
|
2127
2180
|
static render(t) {
|
|
2128
|
-
|
|
2181
|
+
w.dispatch(t, "render", { target: t });
|
|
2129
2182
|
}
|
|
2130
2183
|
/**
|
|
2131
2184
|
* importstartイベントを発火します。
|
|
@@ -2134,7 +2187,7 @@ class v {
|
|
|
2134
2187
|
* @param url インポート対象URL
|
|
2135
2188
|
*/
|
|
2136
2189
|
static importStart(t, e) {
|
|
2137
|
-
|
|
2190
|
+
w.dispatch(t, "importstart", {
|
|
2138
2191
|
url: e,
|
|
2139
2192
|
startedAt: performance.now()
|
|
2140
2193
|
});
|
|
@@ -2148,7 +2201,7 @@ class v {
|
|
|
2148
2201
|
* @param startedAt 開始時刻
|
|
2149
2202
|
*/
|
|
2150
2203
|
static importEnd(t, e, r, i) {
|
|
2151
|
-
|
|
2204
|
+
w.dispatch(t, "importend", {
|
|
2152
2205
|
url: e,
|
|
2153
2206
|
bytes: r,
|
|
2154
2207
|
durationMs: performance.now() - i
|
|
@@ -2162,7 +2215,7 @@ class v {
|
|
|
2162
2215
|
* @param error エラー内容
|
|
2163
2216
|
*/
|
|
2164
2217
|
static importError(t, e, r) {
|
|
2165
|
-
|
|
2218
|
+
w.dispatch(t, "importerror", { url: e, error: r });
|
|
2166
2219
|
}
|
|
2167
2220
|
/**
|
|
2168
2221
|
* bindchangeイベントを発火します。
|
|
@@ -2175,10 +2228,10 @@ class v {
|
|
|
2175
2228
|
static bindChange(t, e, r, i = "other") {
|
|
2176
2229
|
const s = [], n = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...n, ...a]);
|
|
2177
2230
|
for (const d of o) {
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2231
|
+
const m = e?.[d], y = r[d];
|
|
2232
|
+
m !== y && s.push(d);
|
|
2180
2233
|
}
|
|
2181
|
-
|
|
2234
|
+
w.dispatch(t, "bindchange", {
|
|
2182
2235
|
previous: e || {},
|
|
2183
2236
|
next: r,
|
|
2184
2237
|
changedKeys: s,
|
|
@@ -2194,7 +2247,7 @@ class v {
|
|
|
2194
2247
|
* @param order 現在の順序
|
|
2195
2248
|
*/
|
|
2196
2249
|
static eachUpdate(t, e, r, i) {
|
|
2197
|
-
|
|
2250
|
+
w.dispatch(t, "eachupdate", {
|
|
2198
2251
|
added: e,
|
|
2199
2252
|
removed: r,
|
|
2200
2253
|
order: i,
|
|
@@ -2210,7 +2263,7 @@ class v {
|
|
|
2210
2263
|
* @param item 行データ
|
|
2211
2264
|
*/
|
|
2212
2265
|
static rowAdd(t, e, r, i) {
|
|
2213
|
-
|
|
2266
|
+
w.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
2214
2267
|
}
|
|
2215
2268
|
/**
|
|
2216
2269
|
* rowremoveイベントを発火します。
|
|
@@ -2220,7 +2273,7 @@ class v {
|
|
|
2220
2273
|
* @param index インデックス
|
|
2221
2274
|
*/
|
|
2222
2275
|
static rowRemove(t, e, r) {
|
|
2223
|
-
|
|
2276
|
+
w.dispatch(t, "rowremove", { key: e, index: r });
|
|
2224
2277
|
}
|
|
2225
2278
|
/**
|
|
2226
2279
|
* rowmoveイベントを発火します。
|
|
@@ -2231,7 +2284,7 @@ class v {
|
|
|
2231
2284
|
* @param to 移動後インデックス
|
|
2232
2285
|
*/
|
|
2233
2286
|
static rowMove(t, e, r, i) {
|
|
2234
|
-
|
|
2287
|
+
w.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
2235
2288
|
}
|
|
2236
2289
|
/**
|
|
2237
2290
|
* showイベントを発火します。
|
|
@@ -2239,7 +2292,7 @@ class v {
|
|
|
2239
2292
|
* @param target data-if要素
|
|
2240
2293
|
*/
|
|
2241
2294
|
static show(t) {
|
|
2242
|
-
|
|
2295
|
+
w.dispatch(t, "show", { visible: !0 });
|
|
2243
2296
|
}
|
|
2244
2297
|
/**
|
|
2245
2298
|
* hideイベントを発火します。
|
|
@@ -2247,7 +2300,7 @@ class v {
|
|
|
2247
2300
|
* @param target data-if要素
|
|
2248
2301
|
*/
|
|
2249
2302
|
static hide(t) {
|
|
2250
|
-
|
|
2303
|
+
w.dispatch(t, "hide", { visible: !1 });
|
|
2251
2304
|
}
|
|
2252
2305
|
/**
|
|
2253
2306
|
* fetchstartイベントを発火します。
|
|
@@ -2260,7 +2313,7 @@ class v {
|
|
|
2260
2313
|
* @return 戻り値はありません。
|
|
2261
2314
|
*/
|
|
2262
2315
|
static fetchStart(t, e, r, i, s) {
|
|
2263
|
-
|
|
2316
|
+
w.dispatch(t, "fetchstart", {
|
|
2264
2317
|
url: e,
|
|
2265
2318
|
options: r || {},
|
|
2266
2319
|
payload: i,
|
|
@@ -2277,7 +2330,7 @@ class v {
|
|
|
2277
2330
|
* @param startedAt 開始時刻
|
|
2278
2331
|
*/
|
|
2279
2332
|
static fetchEnd(t, e, r, i) {
|
|
2280
|
-
|
|
2333
|
+
w.dispatch(t, "fetchend", {
|
|
2281
2334
|
url: e,
|
|
2282
2335
|
status: r,
|
|
2283
2336
|
durationMs: performance.now() - i
|
|
@@ -2293,7 +2346,7 @@ class v {
|
|
|
2293
2346
|
* @param startedAt 開始時刻(存在する場合)
|
|
2294
2347
|
*/
|
|
2295
2348
|
static fetchError(t, e, r, i, s) {
|
|
2296
|
-
|
|
2349
|
+
w.dispatch(t, "fetcherror", {
|
|
2297
2350
|
url: e,
|
|
2298
2351
|
status: i,
|
|
2299
2352
|
error: r,
|
|
@@ -2309,11 +2362,11 @@ const st = [
|
|
|
2309
2362
|
"openDialog",
|
|
2310
2363
|
"toast"
|
|
2311
2364
|
];
|
|
2312
|
-
function
|
|
2365
|
+
function W() {
|
|
2313
2366
|
const t = globalThis.window?.Haori;
|
|
2314
2367
|
return st.every(
|
|
2315
2368
|
(r) => typeof t?.[r] == "function"
|
|
2316
|
-
) ? t :
|
|
2369
|
+
) ? t : X;
|
|
2317
2370
|
}
|
|
2318
2371
|
const nt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2319
2372
|
function at(F) {
|
|
@@ -2329,7 +2382,7 @@ function lt(F, t) {
|
|
|
2329
2382
|
const e = new URL(F, window.location.href), r = new URLSearchParams(e.search);
|
|
2330
2383
|
return ot(r, t), e.search = r.toString(), e.toString();
|
|
2331
2384
|
}
|
|
2332
|
-
const
|
|
2385
|
+
const c = class c {
|
|
2333
2386
|
/**
|
|
2334
2387
|
* イベント属性名を正しく生成します。
|
|
2335
2388
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2338,7 +2391,7 @@ const u = class u {
|
|
|
2338
2391
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2339
2392
|
*/
|
|
2340
2393
|
static attrName(t, e, r = !1) {
|
|
2341
|
-
return t ? `${
|
|
2394
|
+
return t ? `${l.prefix}${t}-${e}` : r ? `${l.prefix}fetch-${e}` : `${l.prefix}${e}`;
|
|
2342
2395
|
}
|
|
2343
2396
|
/**
|
|
2344
2397
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2349,7 +2402,7 @@ const u = class u {
|
|
|
2349
2402
|
*/
|
|
2350
2403
|
static resolveDataParamString(t, e) {
|
|
2351
2404
|
return t.replace(
|
|
2352
|
-
|
|
2405
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2353
2406
|
(r, i, s) => {
|
|
2354
2407
|
const n = j.evaluate(
|
|
2355
2408
|
i ?? s ?? "",
|
|
@@ -2406,7 +2459,7 @@ const u = class u {
|
|
|
2406
2459
|
static stringifyJsonTemplateStringContent(t) {
|
|
2407
2460
|
if (t == null || Number.isNaN(t))
|
|
2408
2461
|
return "";
|
|
2409
|
-
const e = typeof t == "object" ?
|
|
2462
|
+
const e = typeof t == "object" ? c.stringifyJsonTemplateValue(t) : String(t);
|
|
2410
2463
|
return JSON.stringify(e).slice(1, -1);
|
|
2411
2464
|
}
|
|
2412
2465
|
/**
|
|
@@ -2418,13 +2471,13 @@ const u = class u {
|
|
|
2418
2471
|
*/
|
|
2419
2472
|
static resolveDataJsonString(t, e) {
|
|
2420
2473
|
return t.replace(
|
|
2421
|
-
|
|
2474
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2422
2475
|
(r, i, s, n) => {
|
|
2423
2476
|
const a = j.evaluate(
|
|
2424
2477
|
i ?? s ?? "",
|
|
2425
2478
|
e
|
|
2426
2479
|
);
|
|
2427
|
-
return
|
|
2480
|
+
return c.isJsonStringContext(t, n) ? c.stringifyJsonTemplateStringContent(a) : c.stringifyJsonTemplateValue(a);
|
|
2428
2481
|
}
|
|
2429
2482
|
);
|
|
2430
2483
|
}
|
|
@@ -2442,13 +2495,13 @@ const u = class u {
|
|
|
2442
2495
|
if (typeof i != "string" || r === null)
|
|
2443
2496
|
return null;
|
|
2444
2497
|
const s = r.trim();
|
|
2445
|
-
return
|
|
2446
|
-
|
|
2498
|
+
return c.SINGLE_PLACEHOLDER_REGEX.test(s) ? x.parseDataBind(i) : s.startsWith("{") || s.startsWith("[") ? x.parseDataBind(
|
|
2499
|
+
c.resolveDataJsonString(
|
|
2447
2500
|
r,
|
|
2448
2501
|
t.getBindingData()
|
|
2449
2502
|
)
|
|
2450
2503
|
) : x.parseDataBind(
|
|
2451
|
-
|
|
2504
|
+
c.resolveDataParamString(r, t.getBindingData())
|
|
2452
2505
|
);
|
|
2453
2506
|
}
|
|
2454
2507
|
/**
|
|
@@ -2463,29 +2516,30 @@ const u = class u {
|
|
|
2463
2516
|
targetFragment: t
|
|
2464
2517
|
};
|
|
2465
2518
|
if (e) {
|
|
2466
|
-
if (t.hasAttribute(
|
|
2467
|
-
|
|
2468
|
-
)
|
|
2519
|
+
if (t.hasAttribute(c.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(c.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2520
|
+
c.attrName(e, "confirm")
|
|
2521
|
+
).replace(/\\n/g, `
|
|
2522
|
+
`)), t.hasAttribute(c.attrName(e, "data")) && (r.data = c.resolveDataAttribute(
|
|
2469
2523
|
t,
|
|
2470
|
-
|
|
2471
|
-
)), t.hasAttribute(
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2524
|
+
c.attrName(e, "data")
|
|
2525
|
+
)), t.hasAttribute(c.attrName(e, "form"))) {
|
|
2526
|
+
const u = t.getRawAttribute(
|
|
2527
|
+
c.attrName(e, "form")
|
|
2474
2528
|
);
|
|
2475
|
-
if (
|
|
2476
|
-
const
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
) :
|
|
2529
|
+
if (u) {
|
|
2530
|
+
const h = document.body.querySelector(u);
|
|
2531
|
+
h !== null ? r.formFragment = b.getFormFragment(
|
|
2532
|
+
T.get(h)
|
|
2533
|
+
) : f.error(
|
|
2480
2534
|
"Haori",
|
|
2481
|
-
`Form element not found: ${
|
|
2535
|
+
`Form element not found: ${u} (${c.attrName(e, "form")})`
|
|
2482
2536
|
);
|
|
2483
2537
|
} else
|
|
2484
|
-
r.formFragment =
|
|
2485
|
-
} else e === "change" && (r.formFragment =
|
|
2486
|
-
if (t.hasAttribute(`${
|
|
2487
|
-
const
|
|
2488
|
-
`${
|
|
2538
|
+
r.formFragment = b.getFormFragment(t);
|
|
2539
|
+
} else e === "change" && (r.formFragment = b.getFormFragment(t));
|
|
2540
|
+
if (t.hasAttribute(`${l.prefix}${e}-before-run`)) {
|
|
2541
|
+
const u = t.getRawAttribute(
|
|
2542
|
+
`${l.prefix}${e}-before-run`
|
|
2489
2543
|
);
|
|
2490
2544
|
try {
|
|
2491
2545
|
r.beforeCallback = new Function(
|
|
@@ -2493,70 +2547,70 @@ const u = class u {
|
|
|
2493
2547
|
"fetchOptions",
|
|
2494
2548
|
`
|
|
2495
2549
|
"use strict";
|
|
2496
|
-
${
|
|
2550
|
+
${u}
|
|
2497
2551
|
`
|
|
2498
2552
|
);
|
|
2499
|
-
} catch (
|
|
2500
|
-
|
|
2553
|
+
} catch (h) {
|
|
2554
|
+
f.error("Haori", `Invalid before script: ${h}`);
|
|
2501
2555
|
}
|
|
2502
2556
|
}
|
|
2503
2557
|
}
|
|
2504
|
-
const i =
|
|
2558
|
+
const i = c.attrName(e, "fetch"), s = t.hasAttribute(i);
|
|
2505
2559
|
s && (r.fetchUrl = t.getAttribute(i));
|
|
2506
2560
|
const n = {};
|
|
2507
2561
|
if (e) {
|
|
2508
|
-
const
|
|
2509
|
-
t.hasAttribute(
|
|
2510
|
-
|
|
2562
|
+
const u = c.attrName(e, "fetch-method");
|
|
2563
|
+
t.hasAttribute(u) && (n.method = t.getAttribute(
|
|
2564
|
+
u
|
|
2511
2565
|
));
|
|
2512
2566
|
} else {
|
|
2513
|
-
const
|
|
2514
|
-
t.hasAttribute(
|
|
2515
|
-
|
|
2567
|
+
const u = c.attrName(null, "method", !0);
|
|
2568
|
+
t.hasAttribute(u) && (n.method = t.getAttribute(
|
|
2569
|
+
u
|
|
2516
2570
|
));
|
|
2517
2571
|
}
|
|
2518
2572
|
if (e) {
|
|
2519
|
-
const
|
|
2520
|
-
if (t.hasAttribute(
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2573
|
+
const u = c.attrName(e, "fetch-headers");
|
|
2574
|
+
if (t.hasAttribute(u)) {
|
|
2575
|
+
const h = t.getRawAttribute(
|
|
2576
|
+
u
|
|
2523
2577
|
);
|
|
2524
2578
|
try {
|
|
2525
|
-
n.headers = x.parseDataBind(
|
|
2526
|
-
} catch (
|
|
2527
|
-
|
|
2579
|
+
n.headers = x.parseDataBind(h);
|
|
2580
|
+
} catch (g) {
|
|
2581
|
+
f.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2528
2582
|
}
|
|
2529
2583
|
}
|
|
2530
2584
|
} else {
|
|
2531
|
-
const
|
|
2585
|
+
const u = c.attrName(
|
|
2532
2586
|
null,
|
|
2533
2587
|
"headers",
|
|
2534
2588
|
!0
|
|
2535
2589
|
);
|
|
2536
|
-
if (t.hasAttribute(
|
|
2537
|
-
const
|
|
2538
|
-
|
|
2590
|
+
if (t.hasAttribute(u)) {
|
|
2591
|
+
const h = t.getRawAttribute(
|
|
2592
|
+
u
|
|
2539
2593
|
);
|
|
2540
2594
|
try {
|
|
2541
|
-
n.headers = x.parseDataBind(
|
|
2542
|
-
} catch (
|
|
2543
|
-
|
|
2595
|
+
n.headers = x.parseDataBind(h);
|
|
2596
|
+
} catch (g) {
|
|
2597
|
+
f.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2544
2598
|
}
|
|
2545
2599
|
}
|
|
2546
2600
|
}
|
|
2547
2601
|
if (e) {
|
|
2548
|
-
const
|
|
2602
|
+
const u = c.attrName(
|
|
2549
2603
|
e,
|
|
2550
2604
|
"fetch-content-type"
|
|
2551
2605
|
);
|
|
2552
|
-
if (t.hasAttribute(
|
|
2606
|
+
if (t.hasAttribute(u))
|
|
2553
2607
|
n.headers = {
|
|
2554
2608
|
...n.headers,
|
|
2555
|
-
"Content-Type": t.getAttribute(
|
|
2609
|
+
"Content-Type": t.getAttribute(u)
|
|
2556
2610
|
};
|
|
2557
2611
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2558
|
-
let
|
|
2559
|
-
n.headers && typeof n.headers == "object" && (
|
|
2612
|
+
let h = !1;
|
|
2613
|
+
n.headers && typeof n.headers == "object" && (h = "Content-Type" in n.headers), h || (n.headers = {
|
|
2560
2614
|
...n.headers,
|
|
2561
2615
|
"Content-Type": "application/json"
|
|
2562
2616
|
});
|
|
@@ -2565,19 +2619,19 @@ ${l}
|
|
|
2565
2619
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2566
2620
|
});
|
|
2567
2621
|
} else {
|
|
2568
|
-
const
|
|
2622
|
+
const u = c.attrName(
|
|
2569
2623
|
null,
|
|
2570
2624
|
"content-type",
|
|
2571
2625
|
!0
|
|
2572
2626
|
);
|
|
2573
|
-
if (t.hasAttribute(
|
|
2627
|
+
if (t.hasAttribute(u))
|
|
2574
2628
|
n.headers = {
|
|
2575
2629
|
...n.headers,
|
|
2576
|
-
"Content-Type": t.getAttribute(
|
|
2630
|
+
"Content-Type": t.getAttribute(u)
|
|
2577
2631
|
};
|
|
2578
2632
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2579
|
-
let
|
|
2580
|
-
n.headers && typeof n.headers == "object" && (
|
|
2633
|
+
let h = !1;
|
|
2634
|
+
n.headers && typeof n.headers == "object" && (h = "Content-Type" in n.headers), h || (n.headers = {
|
|
2581
2635
|
...n.headers,
|
|
2582
2636
|
"Content-Type": "application/json"
|
|
2583
2637
|
});
|
|
@@ -2587,112 +2641,120 @@ ${l}
|
|
|
2587
2641
|
});
|
|
2588
2642
|
}
|
|
2589
2643
|
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
2590
|
-
const a = e ?
|
|
2644
|
+
const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
|
|
2591
2645
|
if (t.hasAttribute(a)) {
|
|
2592
|
-
const
|
|
2593
|
-
if (
|
|
2594
|
-
const
|
|
2595
|
-
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2598
|
-
})) :
|
|
2646
|
+
const u = t.getRawAttribute(a);
|
|
2647
|
+
if (u) {
|
|
2648
|
+
const h = document.body.querySelectorAll(u);
|
|
2649
|
+
h.length > 0 ? (r.bindFragments = [], h.forEach((g) => {
|
|
2650
|
+
const A = T.get(g);
|
|
2651
|
+
A && r.bindFragments.push(A);
|
|
2652
|
+
})) : f.error(
|
|
2599
2653
|
"Haori",
|
|
2600
|
-
`Bind element not found: ${
|
|
2654
|
+
`Bind element not found: ${u} (${a})`
|
|
2601
2655
|
);
|
|
2602
2656
|
}
|
|
2603
2657
|
}
|
|
2604
|
-
const o =
|
|
2658
|
+
const o = c.attrName(e, "bind-arg"), d = c.attrName(
|
|
2605
2659
|
null,
|
|
2606
2660
|
"arg",
|
|
2607
2661
|
!0
|
|
2608
|
-
),
|
|
2662
|
+
), m = c.attrName(
|
|
2609
2663
|
null,
|
|
2610
2664
|
"bind-arg",
|
|
2611
2665
|
!0
|
|
2612
2666
|
);
|
|
2613
2667
|
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(d) ? r.bindArg = t.getRawAttribute(
|
|
2614
2668
|
d
|
|
2615
|
-
) : t.hasAttribute(
|
|
2616
|
-
const
|
|
2617
|
-
if (t.hasAttribute(
|
|
2618
|
-
const
|
|
2619
|
-
r.bindParams =
|
|
2669
|
+
) : t.hasAttribute(m) && (r.bindArg = t.getRawAttribute(m));
|
|
2670
|
+
const y = e ? c.attrName(e, "bind-params") : c.attrName(null, "bind-params", !0);
|
|
2671
|
+
if (t.hasAttribute(y)) {
|
|
2672
|
+
const u = t.getRawAttribute(y);
|
|
2673
|
+
r.bindParams = u.split("&").map((h) => h.trim());
|
|
2620
2674
|
}
|
|
2621
|
-
const
|
|
2622
|
-
if (t.hasAttribute(
|
|
2623
|
-
const
|
|
2624
|
-
r.bindAppendParams =
|
|
2675
|
+
const E = e ? c.attrName(e, "bind-append") : c.attrName(null, "bind-append", !0);
|
|
2676
|
+
if (t.hasAttribute(E)) {
|
|
2677
|
+
const u = t.getRawAttribute(E);
|
|
2678
|
+
r.bindAppendParams = u.split("&").map((h) => h.trim()).filter(Boolean);
|
|
2625
2679
|
}
|
|
2626
|
-
const S = e ?
|
|
2680
|
+
const S = e ? c.attrName(e, "copy-params") : null;
|
|
2627
2681
|
if (S && t.hasAttribute(S)) {
|
|
2628
|
-
const
|
|
2682
|
+
const u = t.getRawAttribute(
|
|
2629
2683
|
S
|
|
2630
2684
|
);
|
|
2631
|
-
r.copyParams =
|
|
2685
|
+
r.copyParams = u.split("&").map((h) => h.trim()).filter(Boolean);
|
|
2632
2686
|
}
|
|
2633
2687
|
if (e) {
|
|
2634
|
-
if (t.hasAttribute(
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2688
|
+
if (t.hasAttribute(c.attrName(e, "adjust"))) {
|
|
2689
|
+
const h = t.getRawAttribute(
|
|
2690
|
+
c.attrName(e, "adjust")
|
|
2637
2691
|
);
|
|
2638
|
-
if (
|
|
2639
|
-
const
|
|
2640
|
-
|
|
2641
|
-
const
|
|
2642
|
-
|
|
2643
|
-
})) :
|
|
2692
|
+
if (h) {
|
|
2693
|
+
const g = document.body.querySelectorAll(h);
|
|
2694
|
+
g.length > 0 ? (r.adjustFragments = [], g.forEach((A) => {
|
|
2695
|
+
const v = T.get(A);
|
|
2696
|
+
v && r.adjustFragments.push(v);
|
|
2697
|
+
})) : f.error(
|
|
2644
2698
|
"Haori",
|
|
2645
|
-
`Adjust element not found: ${
|
|
2699
|
+
`Adjust element not found: ${h} (${c.attrName(e, "adjust")})`
|
|
2646
2700
|
);
|
|
2647
2701
|
}
|
|
2648
|
-
if (t.hasAttribute(
|
|
2649
|
-
const
|
|
2650
|
-
|
|
2651
|
-
),
|
|
2652
|
-
isNaN(
|
|
2702
|
+
if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
|
|
2703
|
+
const g = t.getRawAttribute(
|
|
2704
|
+
c.attrName(e, "adjust-value")
|
|
2705
|
+
), A = Number(g);
|
|
2706
|
+
isNaN(A) || (r.adjustValue = A);
|
|
2653
2707
|
}
|
|
2654
2708
|
}
|
|
2655
|
-
if (t.hasAttribute(
|
|
2656
|
-
const
|
|
2657
|
-
`${
|
|
2709
|
+
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(`${l.prefix}${e}-after-run`)) {
|
|
2710
|
+
const h = t.getRawAttribute(
|
|
2711
|
+
`${l.prefix}${e}-after-run`
|
|
2658
2712
|
);
|
|
2659
2713
|
try {
|
|
2660
2714
|
r.afterCallback = new Function(
|
|
2661
2715
|
"response",
|
|
2662
2716
|
`
|
|
2663
2717
|
"use strict";
|
|
2664
|
-
${
|
|
2718
|
+
${h}
|
|
2665
2719
|
`
|
|
2666
2720
|
);
|
|
2667
|
-
} catch (
|
|
2668
|
-
|
|
2721
|
+
} catch (g) {
|
|
2722
|
+
f.error("Haori", `Invalid after script: ${g}`);
|
|
2669
2723
|
}
|
|
2670
2724
|
}
|
|
2671
|
-
if (t.hasAttribute(
|
|
2672
|
-
|
|
2673
|
-
)
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2725
|
+
if (t.hasAttribute(c.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2726
|
+
c.attrName(e, "dialog")
|
|
2727
|
+
).replace(/\\n/g, `
|
|
2728
|
+
`)), t.hasAttribute(c.attrName(e, "toast"))) {
|
|
2729
|
+
r.toastMessage = t.getAttribute(
|
|
2730
|
+
c.attrName(e, "toast")
|
|
2731
|
+
);
|
|
2732
|
+
const h = t.getRawAttribute(
|
|
2733
|
+
c.attrName(e, "toast-level")
|
|
2734
|
+
), A = ["info", "warning", "error", "success"].includes(h);
|
|
2735
|
+
r.toastLevel = A ? h : null;
|
|
2736
|
+
}
|
|
2737
|
+
if (t.hasAttribute(c.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2738
|
+
c.attrName(e, "redirect")
|
|
2739
|
+
)), t.hasAttribute(c.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2740
|
+
c.attrName(e, "history")
|
|
2741
|
+
)), t.hasAttribute(c.attrName(e, "history-data")) && (r.historyData = c.resolveDataAttribute(
|
|
2680
2742
|
t,
|
|
2681
|
-
|
|
2682
|
-
)), t.hasAttribute(
|
|
2683
|
-
const
|
|
2684
|
-
|
|
2743
|
+
c.attrName(e, "history-data")
|
|
2744
|
+
)), t.hasAttribute(c.attrName(e, "history-form"))) {
|
|
2745
|
+
const h = t.getRawAttribute(
|
|
2746
|
+
c.attrName(e, "history-form")
|
|
2685
2747
|
);
|
|
2686
|
-
if (
|
|
2687
|
-
const
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
) :
|
|
2748
|
+
if (h) {
|
|
2749
|
+
const g = document.body.querySelector(h);
|
|
2750
|
+
g !== null ? r.historyFormFragment = b.getFormFragment(
|
|
2751
|
+
T.get(g)
|
|
2752
|
+
) : f.error(
|
|
2691
2753
|
"Haori",
|
|
2692
|
-
`Form element not found: ${
|
|
2754
|
+
`Form element not found: ${h} (${c.attrName(e, "history-form")})`
|
|
2693
2755
|
);
|
|
2694
2756
|
} else
|
|
2695
|
-
r.historyFormFragment =
|
|
2757
|
+
r.historyFormFragment = b.getFormFragment(t);
|
|
2696
2758
|
}
|
|
2697
2759
|
[
|
|
2698
2760
|
"reset",
|
|
@@ -2701,54 +2763,54 @@ ${f}
|
|
|
2701
2763
|
"copy",
|
|
2702
2764
|
"open",
|
|
2703
2765
|
"close"
|
|
2704
|
-
].forEach((
|
|
2705
|
-
const
|
|
2706
|
-
if (!t.hasAttribute(
|
|
2766
|
+
].forEach((h) => {
|
|
2767
|
+
const g = c.attrName(e, h);
|
|
2768
|
+
if (!t.hasAttribute(g))
|
|
2707
2769
|
return;
|
|
2708
|
-
const
|
|
2709
|
-
if (
|
|
2710
|
-
const
|
|
2711
|
-
|
|
2712
|
-
}),
|
|
2713
|
-
switch (
|
|
2770
|
+
const A = t.getRawAttribute(g), v = [];
|
|
2771
|
+
if (A ? (document.body.querySelectorAll(A).forEach((J) => {
|
|
2772
|
+
const Z = T.get(J);
|
|
2773
|
+
Z && v.push(Z);
|
|
2774
|
+
}), v.length === 0 && f.error("Haori", `Element not found: ${A} (${g})`)) : v.push(t), v.length > 0)
|
|
2775
|
+
switch (h) {
|
|
2714
2776
|
case "reset":
|
|
2715
|
-
r.resetFragments =
|
|
2777
|
+
r.resetFragments = v;
|
|
2716
2778
|
break;
|
|
2717
2779
|
case "refetch":
|
|
2718
|
-
r.refetchFragments =
|
|
2780
|
+
r.refetchFragments = v;
|
|
2719
2781
|
break;
|
|
2720
2782
|
case "click":
|
|
2721
|
-
r.clickFragments =
|
|
2783
|
+
r.clickFragments = v;
|
|
2722
2784
|
break;
|
|
2723
2785
|
case "copy":
|
|
2724
|
-
r.copyFragments =
|
|
2786
|
+
r.copyFragments = v;
|
|
2725
2787
|
break;
|
|
2726
2788
|
case "open":
|
|
2727
|
-
r.openFragments =
|
|
2789
|
+
r.openFragments = v;
|
|
2728
2790
|
break;
|
|
2729
2791
|
case "close":
|
|
2730
|
-
r.closeFragments =
|
|
2792
|
+
r.closeFragments = v;
|
|
2731
2793
|
break;
|
|
2732
2794
|
}
|
|
2733
2795
|
});
|
|
2734
2796
|
}
|
|
2735
|
-
if (!e && (t.hasAttribute(
|
|
2797
|
+
if (!e && (t.hasAttribute(c.attrName(null, "data", !0)) && (r.data = c.resolveDataAttribute(
|
|
2736
2798
|
t,
|
|
2737
|
-
|
|
2738
|
-
)), t.hasAttribute(
|
|
2739
|
-
const
|
|
2740
|
-
|
|
2799
|
+
c.attrName(null, "data", !0)
|
|
2800
|
+
)), t.hasAttribute(c.attrName(null, "form", !0)))) {
|
|
2801
|
+
const u = t.getRawAttribute(
|
|
2802
|
+
c.attrName(null, "form", !0)
|
|
2741
2803
|
);
|
|
2742
|
-
if (
|
|
2743
|
-
const
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
) :
|
|
2804
|
+
if (u) {
|
|
2805
|
+
const h = document.body.querySelector(u);
|
|
2806
|
+
h !== null ? r.formFragment = b.getFormFragment(
|
|
2807
|
+
T.get(h)
|
|
2808
|
+
) : f.error(
|
|
2747
2809
|
"Haori",
|
|
2748
|
-
`Form element not found: ${
|
|
2810
|
+
`Form element not found: ${u} (${c.attrName(null, "fetch-form", !0)})`
|
|
2749
2811
|
);
|
|
2750
2812
|
} else
|
|
2751
|
-
r.formFragment =
|
|
2813
|
+
r.formFragment = b.getFormFragment(t);
|
|
2752
2814
|
}
|
|
2753
2815
|
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2754
2816
|
}
|
|
@@ -2771,7 +2833,7 @@ ${f}
|
|
|
2771
2833
|
* @param arg2 イベント名
|
|
2772
2834
|
*/
|
|
2773
2835
|
constructor(t, e = null) {
|
|
2774
|
-
|
|
2836
|
+
c.isElementFragment(t) ? this.options = c.buildOptions(t, e) : this.options = t;
|
|
2775
2837
|
}
|
|
2776
2838
|
/**
|
|
2777
2839
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2812,7 +2874,7 @@ ${f}
|
|
|
2812
2874
|
}
|
|
2813
2875
|
const i = {};
|
|
2814
2876
|
if (this.options.formFragment) {
|
|
2815
|
-
const o =
|
|
2877
|
+
const o = b.getValues(this.options.formFragment);
|
|
2816
2878
|
Object.assign(i, o);
|
|
2817
2879
|
}
|
|
2818
2880
|
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
@@ -2820,71 +2882,71 @@ ${f}
|
|
|
2820
2882
|
if (e) {
|
|
2821
2883
|
const o = { ...r || {} }, d = new Headers(
|
|
2822
2884
|
o.headers || void 0
|
|
2823
|
-
),
|
|
2824
|
-
if (o.method =
|
|
2885
|
+
), m = (o.method || "GET").toUpperCase(), y = l.runtime === "demo" && !at(m), E = y ? "GET" : m;
|
|
2886
|
+
if (o.method = E, E === "GET" || E === "HEAD" || E === "OPTIONS")
|
|
2825
2887
|
s && (e = lt(e, i));
|
|
2826
2888
|
else if (s) {
|
|
2827
|
-
const
|
|
2828
|
-
if (/multipart\/form-data/i.test(
|
|
2889
|
+
const u = d.get("Content-Type") || "";
|
|
2890
|
+
if (/multipart\/form-data/i.test(u)) {
|
|
2829
2891
|
d.delete("Content-Type");
|
|
2830
|
-
const
|
|
2831
|
-
for (const [
|
|
2832
|
-
|
|
2833
|
-
o.body =
|
|
2834
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2835
|
-
const
|
|
2836
|
-
for (const [
|
|
2837
|
-
|
|
2838
|
-
o.body =
|
|
2892
|
+
const h = new FormData();
|
|
2893
|
+
for (const [g, A] of Object.entries(i))
|
|
2894
|
+
A == null ? h.append(g, "") : A instanceof Blob ? h.append(g, A) : Array.isArray(A) ? A.forEach((v) => h.append(g, String(v))) : typeof A == "object" ? h.append(g, JSON.stringify(A)) : h.append(g, String(A));
|
|
2895
|
+
o.body = h;
|
|
2896
|
+
} else if (/application\/x-www-form-urlencoded/i.test(u)) {
|
|
2897
|
+
const h = new URLSearchParams();
|
|
2898
|
+
for (const [g, A] of Object.entries(i))
|
|
2899
|
+
A !== void 0 && (A === null ? h.append(g, "") : Array.isArray(A) ? A.forEach((v) => h.append(g, String(v))) : typeof A == "object" ? h.append(g, JSON.stringify(A)) : h.append(g, String(A)));
|
|
2900
|
+
o.body = h;
|
|
2839
2901
|
} else
|
|
2840
2902
|
d.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2841
2903
|
}
|
|
2842
2904
|
o.headers = d;
|
|
2843
2905
|
let S;
|
|
2844
|
-
if (
|
|
2845
|
-
runtime:
|
|
2846
|
-
requestedMethod:
|
|
2847
|
-
effectiveMethod:
|
|
2906
|
+
if (y && (S = e && new URL(e, window.location.href).search || void 0, d.delete("Content-Type"), f.info("Haori demo fetch normalization", {
|
|
2907
|
+
runtime: l.runtime,
|
|
2908
|
+
requestedMethod: m,
|
|
2909
|
+
effectiveMethod: E,
|
|
2848
2910
|
transportMode: "query-get",
|
|
2849
2911
|
url: e,
|
|
2850
2912
|
payload: s ? i : void 0,
|
|
2851
2913
|
queryString: S
|
|
2852
2914
|
})), this.options.targetFragment && e) {
|
|
2853
|
-
const
|
|
2854
|
-
runtime:
|
|
2855
|
-
requestedMethod:
|
|
2856
|
-
effectiveMethod:
|
|
2857
|
-
transportMode:
|
|
2858
|
-
...
|
|
2915
|
+
const u = performance.now(), h = {
|
|
2916
|
+
runtime: l.runtime,
|
|
2917
|
+
requestedMethod: m,
|
|
2918
|
+
effectiveMethod: E,
|
|
2919
|
+
transportMode: y ? "query-get" : "http",
|
|
2920
|
+
...y ? { queryString: S } : {}
|
|
2859
2921
|
};
|
|
2860
|
-
return
|
|
2922
|
+
return w.fetchStart(
|
|
2861
2923
|
this.options.targetFragment.getTarget(),
|
|
2862
2924
|
e,
|
|
2863
2925
|
o,
|
|
2864
2926
|
s ? i : void 0,
|
|
2865
|
-
|
|
2866
|
-
), fetch(e, o).then((
|
|
2867
|
-
|
|
2927
|
+
h
|
|
2928
|
+
), fetch(e, o).then((g) => this.handleFetchResult(
|
|
2929
|
+
g,
|
|
2868
2930
|
e || void 0,
|
|
2869
|
-
|
|
2870
|
-
)).catch((
|
|
2871
|
-
throw e &&
|
|
2931
|
+
u
|
|
2932
|
+
)).catch((g) => {
|
|
2933
|
+
throw e && w.fetchError(
|
|
2872
2934
|
this.options.targetFragment.getTarget(),
|
|
2873
2935
|
e,
|
|
2874
|
-
|
|
2875
|
-
),
|
|
2936
|
+
g
|
|
2937
|
+
), g;
|
|
2876
2938
|
});
|
|
2877
2939
|
}
|
|
2878
|
-
return fetch(e, o).then((
|
|
2940
|
+
return fetch(e, o).then((u) => this.handleFetchResult(u, e || void 0));
|
|
2879
2941
|
}
|
|
2880
2942
|
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2881
2943
|
const o = this.options.formFragment, d = o.getTarget();
|
|
2882
2944
|
d.setAttribute(
|
|
2883
|
-
`${
|
|
2945
|
+
`${l.prefix}bind`,
|
|
2884
2946
|
JSON.stringify(i)
|
|
2885
2947
|
);
|
|
2886
|
-
const
|
|
2887
|
-
Object.assign(
|
|
2948
|
+
const m = o.getBindingData();
|
|
2949
|
+
Object.assign(m, i), await x.setBindingData(d, m);
|
|
2888
2950
|
}
|
|
2889
2951
|
const n = s ? i : {}, a = new Response(JSON.stringify(n), {
|
|
2890
2952
|
headers: { "Content-Type": "application/json" }
|
|
@@ -2895,16 +2957,16 @@ ${f}
|
|
|
2895
2957
|
* フェッチ後の処理を実行します。
|
|
2896
2958
|
*/
|
|
2897
2959
|
async handleFetchResult(t, e, r) {
|
|
2898
|
-
const i =
|
|
2960
|
+
const i = W();
|
|
2899
2961
|
if (!t.ok)
|
|
2900
|
-
return this.options.targetFragment && e &&
|
|
2962
|
+
return this.options.targetFragment && e && w.fetchError(
|
|
2901
2963
|
this.options.targetFragment.getTarget(),
|
|
2902
2964
|
e,
|
|
2903
2965
|
new Error(`${t.status} ${t.statusText}`),
|
|
2904
2966
|
t.status,
|
|
2905
2967
|
r
|
|
2906
2968
|
), await this.handleFetchError(t), !1;
|
|
2907
|
-
if (this.options.targetFragment && e && r &&
|
|
2969
|
+
if (this.options.targetFragment && e && r && w.fetchEnd(
|
|
2908
2970
|
this.options.targetFragment.getTarget(),
|
|
2909
2971
|
e,
|
|
2910
2972
|
t.status,
|
|
@@ -2919,11 +2981,11 @@ ${f}
|
|
|
2919
2981
|
}
|
|
2920
2982
|
const s = [];
|
|
2921
2983
|
s.push(this.bindResult(t)), s.push(this.adjust()), s.push(this.addRow()), s.push(this.removeRow()), s.push(this.movePrevRow()), s.push(this.moveNextRow()), await Promise.all(s), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
2922
|
-
this.options.resetFragments.map((a) =>
|
|
2984
|
+
this.options.resetFragments.map((a) => b.reset(a))
|
|
2923
2985
|
), await this.copy();
|
|
2924
2986
|
const n = [];
|
|
2925
2987
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
2926
|
-
n.push(new
|
|
2988
|
+
n.push(new c(a, null).run());
|
|
2927
2989
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
2928
2990
|
const o = a.getTarget();
|
|
2929
2991
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
@@ -2931,11 +2993,14 @@ ${f}
|
|
|
2931
2993
|
);
|
|
2932
2994
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
2933
2995
|
const o = a.getTarget();
|
|
2934
|
-
o instanceof HTMLElement ? n.push(i.openDialog(o)) :
|
|
2996
|
+
o instanceof HTMLElement ? n.push(i.openDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
2935
2997
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
2936
2998
|
const o = a.getTarget();
|
|
2937
|
-
o instanceof HTMLElement ? n.push(i.closeDialog(o)) :
|
|
2938
|
-
}), await Promise.all(n), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
2999
|
+
o instanceof HTMLElement ? n.push(i.closeDialog(o)) : f.error("Haori", "Element is not an HTML element: ", o);
|
|
3000
|
+
}), await Promise.all(n), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3001
|
+
this.options.toastMessage,
|
|
3002
|
+
this.options.toastLevel ?? "info"
|
|
3003
|
+
), this.pushHistory(), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
2939
3004
|
}
|
|
2940
3005
|
/**
|
|
2941
3006
|
* history.pushState を実行します。
|
|
@@ -2951,7 +3016,7 @@ ${f}
|
|
|
2951
3016
|
const i = t ? this.options.historyUrl : window.location.pathname, s = new URL(i, window.location.href);
|
|
2952
3017
|
if (s.origin !== window.location.origin) {
|
|
2953
3018
|
const a = "history.pushState: cross-origin URL is not allowed: " + s.toString();
|
|
2954
|
-
|
|
3019
|
+
f.error(
|
|
2955
3020
|
"Haori",
|
|
2956
3021
|
a
|
|
2957
3022
|
);
|
|
@@ -2959,15 +3024,15 @@ ${f}
|
|
|
2959
3024
|
}
|
|
2960
3025
|
const n = (a) => {
|
|
2961
3026
|
for (const [o, d] of Object.entries(a))
|
|
2962
|
-
d != null && (Array.isArray(d) ? d.forEach((
|
|
3027
|
+
d != null && (Array.isArray(d) ? d.forEach((m) => s.searchParams.append(o, String(m))) : typeof d == "object" ? s.searchParams.set(o, JSON.stringify(d)) : s.searchParams.set(o, String(d)));
|
|
2963
3028
|
};
|
|
2964
3029
|
e && n(this.options.historyData), r && n(
|
|
2965
|
-
|
|
3030
|
+
b.getValues(
|
|
2966
3031
|
this.options.historyFormFragment
|
|
2967
3032
|
)
|
|
2968
3033
|
), history.pushState({}, "", s.toString());
|
|
2969
3034
|
} catch (i) {
|
|
2970
|
-
|
|
3035
|
+
f.error("Haori", `history.pushState failed: ${i}`);
|
|
2971
3036
|
}
|
|
2972
3037
|
}
|
|
2973
3038
|
/**
|
|
@@ -2975,10 +3040,10 @@ ${f}
|
|
|
2975
3040
|
*/
|
|
2976
3041
|
async handleFetchError(t) {
|
|
2977
3042
|
let e = null;
|
|
2978
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
3043
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = b.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2979
3044
|
const r = async (s) => {
|
|
2980
3045
|
const n = e ? e.getTarget() : document.body;
|
|
2981
|
-
await
|
|
3046
|
+
await W().addErrorMessage(n, s);
|
|
2982
3047
|
};
|
|
2983
3048
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
2984
3049
|
try {
|
|
@@ -2999,7 +3064,7 @@ ${f}
|
|
|
2999
3064
|
if (n.length === 0)
|
|
3000
3065
|
return await r(`${t.status} ${t.statusText}`), !1;
|
|
3001
3066
|
for (const a of n)
|
|
3002
|
-
a.key && e ? await
|
|
3067
|
+
a.key && e ? await b.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
3003
3068
|
return !1;
|
|
3004
3069
|
} catch {
|
|
3005
3070
|
}
|
|
@@ -3045,7 +3110,7 @@ ${f}
|
|
|
3045
3110
|
*/
|
|
3046
3111
|
confirm() {
|
|
3047
3112
|
const t = this.options.confirmMessage;
|
|
3048
|
-
return t == null ? Promise.resolve(!0) :
|
|
3113
|
+
return t == null ? Promise.resolve(!0) : W().confirm(t);
|
|
3049
3114
|
}
|
|
3050
3115
|
/**
|
|
3051
3116
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -3077,7 +3142,7 @@ ${f}
|
|
|
3077
3142
|
});
|
|
3078
3143
|
else {
|
|
3079
3144
|
if (typeof r == "string")
|
|
3080
|
-
return
|
|
3145
|
+
return f.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
3081
3146
|
new Error("string data cannot be bound without a bindArg.")
|
|
3082
3147
|
);
|
|
3083
3148
|
this.options.bindFragments.forEach((s) => {
|
|
@@ -3130,7 +3195,7 @@ ${f}
|
|
|
3130
3195
|
* copy のコピー元データを取得します。
|
|
3131
3196
|
*/
|
|
3132
3197
|
resolveCopySourceData() {
|
|
3133
|
-
return this.options.formFragment ?
|
|
3198
|
+
return this.options.formFragment ? b.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3134
3199
|
}
|
|
3135
3200
|
/**
|
|
3136
3201
|
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
@@ -3166,11 +3231,11 @@ ${f}
|
|
|
3166
3231
|
*/
|
|
3167
3232
|
getRowFragment() {
|
|
3168
3233
|
if (!this.options.targetFragment)
|
|
3169
|
-
return
|
|
3234
|
+
return f.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3170
3235
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3171
|
-
`${
|
|
3236
|
+
`${l.prefix}row`
|
|
3172
3237
|
);
|
|
3173
|
-
return t || (
|
|
3238
|
+
return t || (f.error("Haori", "Row fragment not found."), null);
|
|
3174
3239
|
}
|
|
3175
3240
|
/**
|
|
3176
3241
|
* 行を追加します。
|
|
@@ -3186,7 +3251,7 @@ ${f}
|
|
|
3186
3251
|
const e = [], r = t.clone();
|
|
3187
3252
|
return e.push(
|
|
3188
3253
|
t.getParent().insertAfter(r, t)
|
|
3189
|
-
), e.push(x.evaluateAll(r)), e.push(
|
|
3254
|
+
), e.push(x.evaluateAll(r)), e.push(b.reset(r)), Promise.all(e).then(() => {
|
|
3190
3255
|
});
|
|
3191
3256
|
}
|
|
3192
3257
|
/**
|
|
@@ -3201,7 +3266,7 @@ ${f}
|
|
|
3201
3266
|
if (!t)
|
|
3202
3267
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3203
3268
|
const e = t.getParent();
|
|
3204
|
-
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
3269
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${l.prefix}each-before`) && !i.hasAttribute(`${l.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3205
3270
|
}
|
|
3206
3271
|
/**
|
|
3207
3272
|
* 前の行へ移動します。
|
|
@@ -3238,9 +3303,9 @@ ${f}
|
|
|
3238
3303
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3239
3304
|
}
|
|
3240
3305
|
};
|
|
3241
|
-
|
|
3242
|
-
let V =
|
|
3243
|
-
class
|
|
3306
|
+
c.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, c.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
3307
|
+
let V = c;
|
|
3308
|
+
class ut {
|
|
3244
3309
|
/**
|
|
3245
3310
|
* URLのクエリパラメータを取得します。
|
|
3246
3311
|
*
|
|
@@ -3253,7 +3318,7 @@ class ct {
|
|
|
3253
3318
|
}), t;
|
|
3254
3319
|
}
|
|
3255
3320
|
}
|
|
3256
|
-
class
|
|
3321
|
+
class ct {
|
|
3257
3322
|
/**
|
|
3258
3323
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3259
3324
|
*
|
|
@@ -3271,27 +3336,27 @@ class ut {
|
|
|
3271
3336
|
try {
|
|
3272
3337
|
r = await fetch(t, e);
|
|
3273
3338
|
} catch (s) {
|
|
3274
|
-
throw
|
|
3339
|
+
throw f.error("[Haori]", "Failed to fetch import source:", t, s), new Error(`Failed to fetch: ${t}`);
|
|
3275
3340
|
}
|
|
3276
3341
|
if (!r.ok) {
|
|
3277
3342
|
const s = `${r.status} ${r.statusText}`;
|
|
3278
|
-
throw
|
|
3343
|
+
throw f.error("[Haori]", "Import HTTP error:", t, s), new Error(`Failed to load ${t}: ${s}`);
|
|
3279
3344
|
}
|
|
3280
3345
|
let i;
|
|
3281
3346
|
try {
|
|
3282
3347
|
i = await r.text();
|
|
3283
3348
|
} catch (s) {
|
|
3284
|
-
throw
|
|
3349
|
+
throw f.error("[Haori]", "Failed to read response text:", t, s), new Error(`Failed to read response from: ${t}`);
|
|
3285
3350
|
}
|
|
3286
3351
|
try {
|
|
3287
3352
|
const n = new DOMParser().parseFromString(i, "text/html");
|
|
3288
|
-
return n && n.body ? n.body.innerHTML : (
|
|
3353
|
+
return n && n.body ? n.body.innerHTML : (f.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3289
3354
|
} catch (s) {
|
|
3290
|
-
return
|
|
3355
|
+
return f.error("[Haori]", "Failed to parse imported HTML:", t, s), i;
|
|
3291
3356
|
}
|
|
3292
3357
|
}
|
|
3293
3358
|
}
|
|
3294
|
-
const
|
|
3359
|
+
const p = class p {
|
|
3295
3360
|
/**
|
|
3296
3361
|
* 遅延属性かどうか(完全名で判定)を判定します。
|
|
3297
3362
|
*
|
|
@@ -3299,8 +3364,8 @@ const g = class g {
|
|
|
3299
3364
|
* @returns 遅延属性かどうか
|
|
3300
3365
|
*/
|
|
3301
3366
|
static isDeferredAttributeName(t) {
|
|
3302
|
-
return
|
|
3303
|
-
(e) => t === `${
|
|
3367
|
+
return p.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3368
|
+
(e) => t === `${l.prefix}${e}`
|
|
3304
3369
|
);
|
|
3305
3370
|
}
|
|
3306
3371
|
/**
|
|
@@ -3310,8 +3375,8 @@ const g = class g {
|
|
|
3310
3375
|
* @returns 除外対象かどうか
|
|
3311
3376
|
*/
|
|
3312
3377
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3313
|
-
return
|
|
3314
|
-
(e) => t === `${
|
|
3378
|
+
return p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3379
|
+
(e) => t === `${l.prefix}${e}`
|
|
3315
3380
|
);
|
|
3316
3381
|
}
|
|
3317
3382
|
/**
|
|
@@ -3322,7 +3387,30 @@ const g = class g {
|
|
|
3322
3387
|
* @returns 再評価する場合は true
|
|
3323
3388
|
*/
|
|
3324
3389
|
static shouldReevaluateAttribute(t, e) {
|
|
3325
|
-
return e !== null && !
|
|
3390
|
+
return e !== null && !p.isEvaluateAllExcludedAttributeName(t) && p.ATTRIBUTE_PLACEHOLDER_REGEX.test(e);
|
|
3391
|
+
}
|
|
3392
|
+
/**
|
|
3393
|
+
* data-attr-* 形式の属性名から実際に更新する属性名を取得します。
|
|
3394
|
+
*
|
|
3395
|
+
* @param name 属性名
|
|
3396
|
+
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
3397
|
+
*/
|
|
3398
|
+
static getAliasedAttributeName(t) {
|
|
3399
|
+
const e = `${l.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
3400
|
+
return !t.startsWith(e) || t.length <= e.length ? null : t.slice(e.length);
|
|
3401
|
+
}
|
|
3402
|
+
/**
|
|
3403
|
+
* 実属性の変更が data-attr-* の内部反映かどうかを判定します。
|
|
3404
|
+
*
|
|
3405
|
+
* @param element 対象要素
|
|
3406
|
+
* @param name 変更された属性名
|
|
3407
|
+
* @returns data-attr-* の内部反映なら true
|
|
3408
|
+
*/
|
|
3409
|
+
static isAliasedAttributeReflection(t, e) {
|
|
3410
|
+
const r = T.get(t);
|
|
3411
|
+
return r instanceof R ? r.hasAttribute(
|
|
3412
|
+
`${l.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}${e}`
|
|
3413
|
+
) : !1;
|
|
3326
3414
|
}
|
|
3327
3415
|
/**
|
|
3328
3416
|
* プレースホルダを含む通常属性を再評価します。
|
|
@@ -3335,7 +3423,9 @@ const g = class g {
|
|
|
3335
3423
|
let e = Promise.resolve();
|
|
3336
3424
|
for (const r of t.getAttributeNames()) {
|
|
3337
3425
|
const i = t.getRawAttribute(r);
|
|
3338
|
-
|
|
3426
|
+
p.shouldReevaluateAttribute(r, i) && (e = e.then(
|
|
3427
|
+
() => p.setAttribute(t.getTarget(), r, i)
|
|
3428
|
+
));
|
|
3339
3429
|
}
|
|
3340
3430
|
return e.then(() => {
|
|
3341
3431
|
});
|
|
@@ -3347,15 +3437,16 @@ const g = class g {
|
|
|
3347
3437
|
* @returns Promise (スキャンが完了したときに解決される)
|
|
3348
3438
|
*/
|
|
3349
3439
|
static scan(t) {
|
|
3350
|
-
const e =
|
|
3440
|
+
const e = T.get(t);
|
|
3351
3441
|
if (!e)
|
|
3352
3442
|
return Promise.resolve();
|
|
3353
|
-
t.parentNode && (
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3443
|
+
t.parentNode && (T.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3444
|
+
let r = Promise.resolve();
|
|
3445
|
+
const i = /* @__PURE__ */ new Set();
|
|
3446
|
+
for (const s of p.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3447
|
+
const n = l.prefix + s;
|
|
3448
|
+
e.hasAttribute(n) && (r = r.then(
|
|
3449
|
+
() => p.setAttribute(
|
|
3359
3450
|
e.getTarget(),
|
|
3360
3451
|
n,
|
|
3361
3452
|
e.getRawAttribute(n)
|
|
@@ -3363,24 +3454,30 @@ const g = class g {
|
|
|
3363
3454
|
), i.add(n));
|
|
3364
3455
|
}
|
|
3365
3456
|
for (const s of e.getAttributeNames()) {
|
|
3366
|
-
if (i.has(s) ||
|
|
3457
|
+
if (i.has(s) || p.isDeferredAttributeName(s))
|
|
3367
3458
|
continue;
|
|
3368
3459
|
const n = e.getRawAttribute(s);
|
|
3369
|
-
n !== null && r.
|
|
3460
|
+
n !== null && (r = r.then(
|
|
3461
|
+
() => p.setAttribute(e.getTarget(), s, n)
|
|
3462
|
+
));
|
|
3370
3463
|
}
|
|
3371
|
-
for (const s of
|
|
3372
|
-
const n =
|
|
3373
|
-
e.hasAttribute(n) && (r.
|
|
3374
|
-
|
|
3464
|
+
for (const s of p.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3465
|
+
const n = l.prefix + s;
|
|
3466
|
+
e.hasAttribute(n) && (r = r.then(
|
|
3467
|
+
() => p.setAttribute(
|
|
3375
3468
|
e.getTarget(),
|
|
3376
3469
|
n,
|
|
3377
3470
|
e.getRawAttribute(n)
|
|
3378
3471
|
)
|
|
3379
3472
|
), i.add(n));
|
|
3380
3473
|
}
|
|
3381
|
-
return
|
|
3382
|
-
|
|
3383
|
-
|
|
3474
|
+
return r.then(() => {
|
|
3475
|
+
const s = [];
|
|
3476
|
+
return e.getChildren().forEach((n) => {
|
|
3477
|
+
n instanceof R ? s.push(p.scan(n.getTarget())) : n instanceof H && s.push(p.evaluateText(n));
|
|
3478
|
+
}), Promise.all(s).then(() => {
|
|
3479
|
+
});
|
|
3480
|
+
}).then(() => {
|
|
3384
3481
|
});
|
|
3385
3482
|
}
|
|
3386
3483
|
/**
|
|
@@ -3393,54 +3490,57 @@ const g = class g {
|
|
|
3393
3490
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3394
3491
|
*/
|
|
3395
3492
|
static setAttribute(t, e, r) {
|
|
3396
|
-
const i =
|
|
3493
|
+
const i = T.get(t), s = p.getAliasedAttributeName(e);
|
|
3494
|
+
if (s !== null)
|
|
3495
|
+
return r === null ? i.removeAliasedAttribute(e, s) : i.setAliasedAttribute(e, s, r);
|
|
3496
|
+
const n = [];
|
|
3397
3497
|
switch (e) {
|
|
3398
|
-
case `${
|
|
3399
|
-
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(
|
|
3498
|
+
case `${l.prefix}bind`: {
|
|
3499
|
+
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(p.parseDataBind(r));
|
|
3400
3500
|
break;
|
|
3401
3501
|
}
|
|
3402
|
-
case `${
|
|
3403
|
-
|
|
3502
|
+
case `${l.prefix}if`:
|
|
3503
|
+
n.push(p.evaluateIf(i));
|
|
3404
3504
|
break;
|
|
3405
|
-
case `${
|
|
3406
|
-
|
|
3505
|
+
case `${l.prefix}each`:
|
|
3506
|
+
n.push(p.evaluateEach(i));
|
|
3407
3507
|
break;
|
|
3408
|
-
case `${
|
|
3409
|
-
|
|
3508
|
+
case `${l.prefix}fetch`:
|
|
3509
|
+
n.push(
|
|
3410
3510
|
new V(i, null).run().then(() => {
|
|
3411
3511
|
})
|
|
3412
3512
|
);
|
|
3413
3513
|
break;
|
|
3414
|
-
case `${
|
|
3514
|
+
case `${l.prefix}import`: {
|
|
3415
3515
|
if (typeof r == "string") {
|
|
3416
|
-
const
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
const
|
|
3516
|
+
const a = i.getTarget(), o = performance.now();
|
|
3517
|
+
w.importStart(a, r), n.push(
|
|
3518
|
+
ct.load(r).then((d) => {
|
|
3519
|
+
const m = new TextEncoder().encode(d).length;
|
|
3420
3520
|
return P.enqueue(() => {
|
|
3421
|
-
|
|
3521
|
+
a.innerHTML = d;
|
|
3422
3522
|
}).then(() => {
|
|
3423
|
-
|
|
3523
|
+
w.importEnd(a, r, m, o);
|
|
3424
3524
|
});
|
|
3425
|
-
}).catch((
|
|
3426
|
-
|
|
3525
|
+
}).catch((d) => {
|
|
3526
|
+
w.importError(a, r, d), f.error("[Haori]", "Failed to import HTML:", r, d);
|
|
3427
3527
|
})
|
|
3428
3528
|
);
|
|
3429
3529
|
}
|
|
3430
3530
|
break;
|
|
3431
3531
|
}
|
|
3432
|
-
case `${
|
|
3433
|
-
const
|
|
3434
|
-
if (
|
|
3435
|
-
|
|
3532
|
+
case `${l.prefix}url-param`: {
|
|
3533
|
+
const a = i.getAttribute(`${l.prefix}url-arg`), o = ut.readParams();
|
|
3534
|
+
if (a === null)
|
|
3535
|
+
n.push(p.setBindingData(t, o));
|
|
3436
3536
|
else {
|
|
3437
|
-
const
|
|
3438
|
-
|
|
3537
|
+
const d = i.getRawBindingData() || {};
|
|
3538
|
+
d[String(a)] = o, n.push(p.setBindingData(t, d));
|
|
3439
3539
|
}
|
|
3440
3540
|
break;
|
|
3441
3541
|
}
|
|
3442
3542
|
}
|
|
3443
|
-
return r === null ?
|
|
3543
|
+
return r === null ? n.push(i.removeAttribute(e)) : n.push(i.setAttribute(e, r)), Promise.all(n).then(() => {
|
|
3444
3544
|
});
|
|
3445
3545
|
}
|
|
3446
3546
|
/**
|
|
@@ -3452,16 +3552,17 @@ const g = class g {
|
|
|
3452
3552
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3453
3553
|
*/
|
|
3454
3554
|
static setBindingData(t, e) {
|
|
3455
|
-
const r =
|
|
3555
|
+
const r = T.get(t), i = r.getRawBindingData();
|
|
3456
3556
|
r.setBindingData(e);
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
)
|
|
3461
|
-
|
|
3462
|
-
|
|
3557
|
+
let s = r.setAttribute(
|
|
3558
|
+
`${l.prefix}bind`,
|
|
3559
|
+
JSON.stringify(e)
|
|
3560
|
+
);
|
|
3561
|
+
if (t.tagName === "FORM") {
|
|
3562
|
+
const n = r.getAttribute(`${l.prefix}form-arg`), a = n && e[String(n)] && typeof e[String(n)] == "object" && !Array.isArray(e[String(n)]) ? e[String(n)] : n ? {} : e;
|
|
3563
|
+
s = s.then(() => b.syncValues(r, a));
|
|
3463
3564
|
}
|
|
3464
|
-
return s.
|
|
3565
|
+
return s = s.then(() => p.evaluateAll(r)), w.bindChange(t, i, e, "manual"), s.then(() => {
|
|
3465
3566
|
});
|
|
3466
3567
|
}
|
|
3467
3568
|
/**
|
|
@@ -3475,7 +3576,7 @@ const g = class g {
|
|
|
3475
3576
|
try {
|
|
3476
3577
|
return JSON.parse(t);
|
|
3477
3578
|
} catch (e) {
|
|
3478
|
-
return
|
|
3579
|
+
return f.error("[Haori]", "Invalid JSON in data-bind:", e), {};
|
|
3479
3580
|
}
|
|
3480
3581
|
else {
|
|
3481
3582
|
const e = new URLSearchParams(t), r = {};
|
|
@@ -3491,11 +3592,11 @@ const g = class g {
|
|
|
3491
3592
|
* @param node 追加するノード
|
|
3492
3593
|
*/
|
|
3493
3594
|
static addNode(t, e) {
|
|
3494
|
-
const r =
|
|
3595
|
+
const r = T.get(t);
|
|
3495
3596
|
if (r.isSkipMutationNodes())
|
|
3496
3597
|
return;
|
|
3497
|
-
const i =
|
|
3498
|
-
s && (r.insertBefore(s, i), s instanceof
|
|
3598
|
+
const i = T.get(e.nextSibling), s = T.get(e);
|
|
3599
|
+
s && (r.insertBefore(s, i), s instanceof R ? p.scan(s.getTarget()) : s instanceof H && p.evaluateText(s));
|
|
3499
3600
|
}
|
|
3500
3601
|
/**
|
|
3501
3602
|
* ノードを親要素から削除します。
|
|
@@ -3503,7 +3604,7 @@ const g = class g {
|
|
|
3503
3604
|
* @param node 削除するノード
|
|
3504
3605
|
*/
|
|
3505
3606
|
static removeNode(t) {
|
|
3506
|
-
const e =
|
|
3607
|
+
const e = T.get(t);
|
|
3507
3608
|
if (e) {
|
|
3508
3609
|
const r = e.getParent();
|
|
3509
3610
|
if (r && r.isSkipMutationNodes())
|
|
@@ -3518,7 +3619,7 @@ const g = class g {
|
|
|
3518
3619
|
* @param text 新しいテキスト
|
|
3519
3620
|
*/
|
|
3520
3621
|
static changeText(t, e) {
|
|
3521
|
-
const r =
|
|
3622
|
+
const r = T.get(t);
|
|
3522
3623
|
r && r.setContent(e);
|
|
3523
3624
|
}
|
|
3524
3625
|
/**
|
|
@@ -3530,16 +3631,16 @@ const g = class g {
|
|
|
3530
3631
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3531
3632
|
*/
|
|
3532
3633
|
static changeValue(t, e) {
|
|
3533
|
-
const r =
|
|
3634
|
+
const r = T.get(t);
|
|
3534
3635
|
if (r.getValue() === e)
|
|
3535
3636
|
return Promise.resolve();
|
|
3536
3637
|
const i = [];
|
|
3537
3638
|
i.push(r.setValue(e));
|
|
3538
|
-
const s =
|
|
3639
|
+
const s = p.getFormFragment(r);
|
|
3539
3640
|
if (s) {
|
|
3540
|
-
const n =
|
|
3641
|
+
const n = b.getValues(s), a = s.getAttribute(`${l.prefix}form-arg`);
|
|
3541
3642
|
let o;
|
|
3542
|
-
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(
|
|
3643
|
+
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(p.setBindingData(s.getTarget(), o));
|
|
3543
3644
|
}
|
|
3544
3645
|
return Promise.all(i).then(() => {
|
|
3545
3646
|
});
|
|
@@ -3554,7 +3655,7 @@ const g = class g {
|
|
|
3554
3655
|
if (t.getTarget() instanceof HTMLFormElement)
|
|
3555
3656
|
return t;
|
|
3556
3657
|
const e = t.getParent();
|
|
3557
|
-
return e ?
|
|
3658
|
+
return e ? p.getFormFragment(e) : null;
|
|
3558
3659
|
}
|
|
3559
3660
|
/**
|
|
3560
3661
|
* フラグメントとその子要素を評価します。
|
|
@@ -3564,10 +3665,16 @@ const g = class g {
|
|
|
3564
3665
|
*/
|
|
3565
3666
|
static evaluateAll(t) {
|
|
3566
3667
|
const e = [];
|
|
3567
|
-
return e.push(
|
|
3568
|
-
|
|
3668
|
+
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${l.prefix}if`) && e.push(p.evaluateIf(t)), t.hasAttribute(`${l.prefix}each`) ? Promise.all(e).then(() => p.evaluateEach(t)).then(() => {
|
|
3669
|
+
const r = [];
|
|
3670
|
+
return t.getChildren().forEach((i) => {
|
|
3671
|
+
i instanceof R ? r.push(p.evaluateAll(i)) : i instanceof H && r.push(p.evaluateText(i));
|
|
3672
|
+
}), Promise.all(r).then(() => {
|
|
3673
|
+
});
|
|
3674
|
+
}) : (t.getChildren().forEach((r) => {
|
|
3675
|
+
r instanceof R ? e.push(p.evaluateAll(r)) : r instanceof H && e.push(p.evaluateText(r));
|
|
3569
3676
|
}), Promise.all(e).then(() => {
|
|
3570
|
-
});
|
|
3677
|
+
}));
|
|
3571
3678
|
}
|
|
3572
3679
|
/**
|
|
3573
3680
|
* テキストフラグメントを評価します。
|
|
@@ -3586,16 +3693,16 @@ const g = class g {
|
|
|
3586
3693
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3587
3694
|
*/
|
|
3588
3695
|
static evaluateIf(t) {
|
|
3589
|
-
const e = [], r = t.getAttribute(`${
|
|
3696
|
+
const e = [], r = t.getAttribute(`${l.prefix}if`);
|
|
3590
3697
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3591
3698
|
t.hide().then(() => {
|
|
3592
|
-
|
|
3699
|
+
w.hide(t.getTarget());
|
|
3593
3700
|
})
|
|
3594
3701
|
) : t.isVisible() || (e.push(
|
|
3595
3702
|
t.show().then(() => {
|
|
3596
|
-
|
|
3703
|
+
w.show(t.getTarget());
|
|
3597
3704
|
})
|
|
3598
|
-
), e.push(
|
|
3705
|
+
), e.push(p.evaluateAll(t))), Promise.all(e).then(() => {
|
|
3599
3706
|
});
|
|
3600
3707
|
}
|
|
3601
3708
|
/**
|
|
@@ -3611,19 +3718,19 @@ const g = class g {
|
|
|
3611
3718
|
if (e === null) {
|
|
3612
3719
|
let i = !1;
|
|
3613
3720
|
t.getChildren().forEach((n) => {
|
|
3614
|
-
if (!i && n instanceof
|
|
3615
|
-
if (n.hasAttribute(`${
|
|
3721
|
+
if (!i && n instanceof R) {
|
|
3722
|
+
if (n.hasAttribute(`${l.prefix}each-before`) || n.hasAttribute(`${l.prefix}each-after`))
|
|
3616
3723
|
return;
|
|
3617
3724
|
e = n.clone(), t.setTemplate(e), i = !0, t.removeChild(n);
|
|
3618
3725
|
const a = n.getTarget();
|
|
3619
3726
|
a.parentNode && a.parentNode.removeChild(a), n.setMounted(!1);
|
|
3620
3727
|
}
|
|
3621
3728
|
});
|
|
3622
|
-
const s = t.getAttribute(`${
|
|
3623
|
-
return Array.isArray(s) ? this.updateDiff(t, s) : (
|
|
3729
|
+
const s = t.getAttribute(`${l.prefix}each`);
|
|
3730
|
+
return Array.isArray(s) ? this.updateDiff(t, s) : (f.error("[Haori]", "Invalid each attribute:", s), Promise.reject(new Error("Invalid each attribute.")));
|
|
3624
3731
|
}
|
|
3625
|
-
const r = t.getAttribute(`${
|
|
3626
|
-
return Array.isArray(r) ? this.updateDiff(t, r) : (
|
|
3732
|
+
const r = t.getAttribute(`${l.prefix}each`);
|
|
3733
|
+
return Array.isArray(r) ? this.updateDiff(t, r) : (f.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3627
3734
|
}
|
|
3628
3735
|
/**
|
|
3629
3736
|
* 差分を更新します。
|
|
@@ -3634,73 +3741,73 @@ const g = class g {
|
|
|
3634
3741
|
static updateDiff(t, e) {
|
|
3635
3742
|
const r = t.getTemplate();
|
|
3636
3743
|
if (r === null)
|
|
3637
|
-
return
|
|
3638
|
-
let i = t.getAttribute(`${
|
|
3744
|
+
return f.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3745
|
+
let i = t.getAttribute(`${l.prefix}each-index`);
|
|
3639
3746
|
i && (i = String(i));
|
|
3640
|
-
const s = t.getAttribute(`${
|
|
3641
|
-
e.forEach((
|
|
3642
|
-
const
|
|
3643
|
-
|
|
3747
|
+
const s = t.getAttribute(`${l.prefix}each-key`), n = t.getAttribute(`${l.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3748
|
+
e.forEach((u, h) => {
|
|
3749
|
+
const g = p.createListKey(
|
|
3750
|
+
u,
|
|
3644
3751
|
s ? String(s) : null,
|
|
3645
|
-
|
|
3752
|
+
h
|
|
3646
3753
|
);
|
|
3647
|
-
o.push(
|
|
3754
|
+
o.push(g), a.set(g, { item: u, itemIndex: h });
|
|
3648
3755
|
});
|
|
3649
3756
|
const d = [];
|
|
3650
|
-
let
|
|
3651
|
-
(
|
|
3757
|
+
let m = t.getChildren().filter((u) => u instanceof R).filter(
|
|
3758
|
+
(u) => !u.hasAttribute(`${l.prefix}each-before`) && !u.hasAttribute(`${l.prefix}each-after`)
|
|
3652
3759
|
);
|
|
3653
|
-
|
|
3654
|
-
const
|
|
3760
|
+
m = m.filter((u) => o.indexOf(String(u.getListKey())) === -1 ? (d.push(u.remove()), !1) : !0);
|
|
3761
|
+
const y = m.map((u) => u.getListKey()), E = t.getChildren().filter((u) => u instanceof R).filter((u) => u.hasAttribute(`${l.prefix}each-before`)).length;
|
|
3655
3762
|
let S = Promise.resolve();
|
|
3656
|
-
return o.forEach((
|
|
3657
|
-
const
|
|
3763
|
+
return o.forEach((u, h) => {
|
|
3764
|
+
const g = y.indexOf(u), { item: A, itemIndex: v } = a.get(u);
|
|
3658
3765
|
let k;
|
|
3659
|
-
if (
|
|
3660
|
-
k =
|
|
3661
|
-
() =>
|
|
3766
|
+
if (g !== -1)
|
|
3767
|
+
k = m[g], S = S.then(
|
|
3768
|
+
() => p.updateRowFragment(
|
|
3662
3769
|
k,
|
|
3663
|
-
|
|
3770
|
+
A,
|
|
3664
3771
|
i,
|
|
3665
|
-
|
|
3772
|
+
v,
|
|
3666
3773
|
n ? String(n) : null,
|
|
3667
|
-
|
|
3668
|
-
).then(() =>
|
|
3774
|
+
u
|
|
3775
|
+
).then(() => p.evaluateAll(k))
|
|
3669
3776
|
);
|
|
3670
3777
|
else {
|
|
3671
3778
|
k = r.clone();
|
|
3672
|
-
const J =
|
|
3779
|
+
const J = E + h;
|
|
3673
3780
|
S = S.then(
|
|
3674
|
-
() =>
|
|
3781
|
+
() => p.updateRowFragment(
|
|
3675
3782
|
k,
|
|
3676
|
-
|
|
3783
|
+
A,
|
|
3677
3784
|
i,
|
|
3678
|
-
|
|
3785
|
+
v,
|
|
3679
3786
|
n ? String(n) : null,
|
|
3680
|
-
|
|
3787
|
+
u
|
|
3681
3788
|
).then(
|
|
3682
3789
|
() => t.insertBefore(
|
|
3683
3790
|
k,
|
|
3684
3791
|
t.getChildren()[J] || null
|
|
3685
|
-
).then(() =>
|
|
3792
|
+
).then(() => p.evaluateAll(k))
|
|
3686
3793
|
)
|
|
3687
3794
|
);
|
|
3688
3795
|
}
|
|
3689
3796
|
}), Promise.all(d).then(() => S).then(() => {
|
|
3690
|
-
const
|
|
3691
|
-
(
|
|
3692
|
-
),
|
|
3693
|
-
(
|
|
3694
|
-
),
|
|
3695
|
-
(
|
|
3696
|
-
),
|
|
3697
|
-
(
|
|
3797
|
+
const u = o.filter(
|
|
3798
|
+
(v) => v !== null
|
|
3799
|
+
), h = y.filter(
|
|
3800
|
+
(v) => v !== null
|
|
3801
|
+
), g = u.filter(
|
|
3802
|
+
(v) => !h.includes(v)
|
|
3803
|
+
), A = h.filter(
|
|
3804
|
+
(v) => !u.includes(v)
|
|
3698
3805
|
);
|
|
3699
|
-
|
|
3806
|
+
w.eachUpdate(
|
|
3700
3807
|
t.getTarget(),
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3808
|
+
g,
|
|
3809
|
+
A,
|
|
3810
|
+
u
|
|
3704
3811
|
);
|
|
3705
3812
|
});
|
|
3706
3813
|
}
|
|
@@ -3746,22 +3853,22 @@ const g = class g {
|
|
|
3746
3853
|
[s]: e
|
|
3747
3854
|
}, r && (a[r] = i);
|
|
3748
3855
|
else
|
|
3749
|
-
return
|
|
3856
|
+
return f.error(
|
|
3750
3857
|
"[Haori]",
|
|
3751
|
-
`Primitive value requires '${
|
|
3858
|
+
`Primitive value requires '${l.prefix}each-arg' attribute: ${e}`
|
|
3752
3859
|
), Promise.resolve();
|
|
3753
|
-
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${
|
|
3860
|
+
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${l.prefix}row`, n);
|
|
3754
3861
|
}
|
|
3755
3862
|
};
|
|
3756
|
-
|
|
3863
|
+
p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], p.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
3757
3864
|
"bind",
|
|
3758
3865
|
"if",
|
|
3759
3866
|
"each",
|
|
3760
3867
|
"fetch",
|
|
3761
3868
|
"import",
|
|
3762
3869
|
"url-param"
|
|
3763
|
-
],
|
|
3764
|
-
let x =
|
|
3870
|
+
], p.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3871
|
+
let x = p;
|
|
3765
3872
|
class ht {
|
|
3766
3873
|
/**
|
|
3767
3874
|
* コンストラクタ。
|
|
@@ -3770,7 +3877,7 @@ class ht {
|
|
|
3770
3877
|
*/
|
|
3771
3878
|
constructor(t = document) {
|
|
3772
3879
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
3773
|
-
const e = document.documentElement, r =
|
|
3880
|
+
const e = document.documentElement, r = T.get(e);
|
|
3774
3881
|
r && new V(r, "load").run();
|
|
3775
3882
|
}, this.root = t;
|
|
3776
3883
|
}
|
|
@@ -3797,9 +3904,9 @@ class ht {
|
|
|
3797
3904
|
const r = this.getElementFromTarget(t.target);
|
|
3798
3905
|
if (!r)
|
|
3799
3906
|
return;
|
|
3800
|
-
const i =
|
|
3801
|
-
i && (e === "change" && i instanceof
|
|
3802
|
-
|
|
3907
|
+
const i = T.get(r);
|
|
3908
|
+
i && (e === "change" && i instanceof R && i.syncValue(), new V(i, e).run().catch((s) => {
|
|
3909
|
+
f.error("[Haori]", "Procedure execution error:", s);
|
|
3803
3910
|
}));
|
|
3804
3911
|
}
|
|
3805
3912
|
/**
|
|
@@ -3812,44 +3919,44 @@ class ht {
|
|
|
3812
3919
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3813
3920
|
}
|
|
3814
3921
|
}
|
|
3815
|
-
const
|
|
3922
|
+
const N = class N {
|
|
3816
3923
|
static syncTree(t) {
|
|
3817
|
-
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement &&
|
|
3818
|
-
|
|
3924
|
+
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && N.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
3925
|
+
N.syncElement(e);
|
|
3819
3926
|
}));
|
|
3820
3927
|
}
|
|
3821
3928
|
static syncElement(t) {
|
|
3822
|
-
const e =
|
|
3823
|
-
if (!r || !
|
|
3824
|
-
e && (e.observer.disconnect(),
|
|
3929
|
+
const e = N.registrations.get(t), r = T.get(t);
|
|
3930
|
+
if (!r || !N.shouldObserve(r)) {
|
|
3931
|
+
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3825
3932
|
return;
|
|
3826
3933
|
}
|
|
3827
3934
|
if (typeof IntersectionObserver > "u")
|
|
3828
3935
|
return;
|
|
3829
|
-
const i =
|
|
3830
|
-
if (e && e.observer.root === i && e.observer.rootMargin === s &&
|
|
3936
|
+
const i = N.resolveRoot(r), s = N.resolveRootMargin(r), n = N.resolveThreshold(r), a = r.hasAttribute(`${l.prefix}intersect-once`);
|
|
3937
|
+
if (e && e.observer.root === i && e.observer.rootMargin === s && N.sameThreshold(
|
|
3831
3938
|
e.observer.thresholds,
|
|
3832
3939
|
n
|
|
3833
3940
|
) && e.once === a) {
|
|
3834
3941
|
e.fragment = r;
|
|
3835
3942
|
return;
|
|
3836
3943
|
}
|
|
3837
|
-
e && (e.observer.disconnect(),
|
|
3944
|
+
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3838
3945
|
const o = new IntersectionObserver(
|
|
3839
3946
|
(d) => {
|
|
3840
|
-
const
|
|
3841
|
-
|
|
3842
|
-
!
|
|
3843
|
-
|
|
3844
|
-
}).catch((
|
|
3845
|
-
|
|
3947
|
+
const m = N.registrations.get(t);
|
|
3948
|
+
m && d.forEach((y) => {
|
|
3949
|
+
!y.isIntersecting || m.running || N.isDisabled(m.fragment) || (m.running = !0, new V(m.fragment, "intersect").runWithResult().then((E) => {
|
|
3950
|
+
E && m.once && (m.observer.disconnect(), N.registrations.delete(t));
|
|
3951
|
+
}).catch((E) => {
|
|
3952
|
+
f.error(
|
|
3846
3953
|
"[Haori]",
|
|
3847
3954
|
"Intersect procedure execution error:",
|
|
3848
|
-
|
|
3955
|
+
E
|
|
3849
3956
|
);
|
|
3850
3957
|
}).finally(() => {
|
|
3851
|
-
const
|
|
3852
|
-
|
|
3958
|
+
const E = N.registrations.get(t);
|
|
3959
|
+
E && (E.running = !1);
|
|
3853
3960
|
}));
|
|
3854
3961
|
});
|
|
3855
3962
|
},
|
|
@@ -3859,7 +3966,7 @@ const T = class T {
|
|
|
3859
3966
|
threshold: n
|
|
3860
3967
|
}
|
|
3861
3968
|
);
|
|
3862
|
-
o.observe(t),
|
|
3969
|
+
o.observe(t), N.registrations.set(t, {
|
|
3863
3970
|
fragment: r,
|
|
3864
3971
|
observer: o,
|
|
3865
3972
|
once: a,
|
|
@@ -3868,47 +3975,47 @@ const T = class T {
|
|
|
3868
3975
|
}
|
|
3869
3976
|
static cleanupTree(t) {
|
|
3870
3977
|
if (t instanceof HTMLElement) {
|
|
3871
|
-
const e =
|
|
3872
|
-
e && (e.observer.disconnect(),
|
|
3978
|
+
const e = N.registrations.get(t);
|
|
3979
|
+
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3873
3980
|
}
|
|
3874
3981
|
(t instanceof Element || t instanceof DocumentFragment) && t.querySelectorAll("*").forEach((e) => {
|
|
3875
|
-
const r =
|
|
3876
|
-
r && (r.observer.disconnect(),
|
|
3982
|
+
const r = N.registrations.get(e);
|
|
3983
|
+
r && (r.observer.disconnect(), N.registrations.delete(e));
|
|
3877
3984
|
});
|
|
3878
3985
|
}
|
|
3879
3986
|
static disconnectAll() {
|
|
3880
|
-
|
|
3987
|
+
N.registrations.forEach((t) => {
|
|
3881
3988
|
t.observer.disconnect();
|
|
3882
|
-
}),
|
|
3989
|
+
}), N.registrations.clear();
|
|
3883
3990
|
}
|
|
3884
3991
|
static shouldObserve(t) {
|
|
3885
3992
|
return t.getAttributeNames().some((e) => {
|
|
3886
|
-
if (!e.startsWith(`${
|
|
3993
|
+
if (!e.startsWith(`${l.prefix}intersect-`))
|
|
3887
3994
|
return !1;
|
|
3888
|
-
const r = e.slice(`${
|
|
3889
|
-
return !
|
|
3995
|
+
const r = e.slice(`${l.prefix}intersect-`.length);
|
|
3996
|
+
return !N.CONFIG_KEYS.has(r);
|
|
3890
3997
|
});
|
|
3891
3998
|
}
|
|
3892
3999
|
static resolveRoot(t) {
|
|
3893
|
-
const e = `${
|
|
4000
|
+
const e = `${l.prefix}intersect-root`;
|
|
3894
4001
|
if (!t.hasAttribute(e))
|
|
3895
4002
|
return null;
|
|
3896
4003
|
const r = t.getAttribute(e);
|
|
3897
4004
|
if (typeof r != "string" || r.trim() === "")
|
|
3898
4005
|
return null;
|
|
3899
4006
|
const i = document.querySelector(r);
|
|
3900
|
-
return i instanceof HTMLElement ? i : (
|
|
4007
|
+
return i instanceof HTMLElement ? i : (f.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
3901
4008
|
}
|
|
3902
4009
|
static resolveRootMargin(t) {
|
|
3903
|
-
const e = `${
|
|
4010
|
+
const e = `${l.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
3904
4011
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
3905
4012
|
}
|
|
3906
4013
|
static resolveThreshold(t) {
|
|
3907
|
-
const e = `${
|
|
4014
|
+
const e = `${l.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
3908
4015
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
3909
4016
|
}
|
|
3910
4017
|
static isDisabled(t) {
|
|
3911
|
-
const e = `${
|
|
4018
|
+
const e = `${l.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
3912
4019
|
if (r === null || r === !1)
|
|
3913
4020
|
return !1;
|
|
3914
4021
|
if (typeof r == "boolean")
|
|
@@ -3920,28 +4027,28 @@ const T = class T {
|
|
|
3920
4027
|
return t.length === 1 && t[0] === e;
|
|
3921
4028
|
}
|
|
3922
4029
|
};
|
|
3923
|
-
|
|
4030
|
+
N.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
3924
4031
|
"root",
|
|
3925
4032
|
"root-margin",
|
|
3926
4033
|
"threshold",
|
|
3927
4034
|
"disabled",
|
|
3928
4035
|
"once"
|
|
3929
|
-
]),
|
|
3930
|
-
let
|
|
3931
|
-
const
|
|
4036
|
+
]), N.registrations = /* @__PURE__ */ new Map();
|
|
4037
|
+
let L = N;
|
|
4038
|
+
const I = class I {
|
|
3932
4039
|
/**
|
|
3933
4040
|
* 初期化メソッド。
|
|
3934
4041
|
* ドキュメントのheadとbodyを監視対象として設定します。
|
|
3935
4042
|
*/
|
|
3936
4043
|
static async init() {
|
|
3937
|
-
if (
|
|
4044
|
+
if (I._initialized)
|
|
3938
4045
|
return;
|
|
3939
|
-
|
|
4046
|
+
I._initialized = !0;
|
|
3940
4047
|
const t = await Promise.allSettled([
|
|
3941
4048
|
x.scan(document.head),
|
|
3942
4049
|
x.scan(document.body)
|
|
3943
4050
|
]), [e, r] = t;
|
|
3944
|
-
e.status !== "fulfilled" &&
|
|
4051
|
+
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), I.observe(document.head), I.observe(document.body), new ht().start(), L.syncTree(document.body);
|
|
3945
4052
|
}
|
|
3946
4053
|
/**
|
|
3947
4054
|
* 指定された要素を監視します。
|
|
@@ -3954,40 +4061,45 @@ const H = class H {
|
|
|
3954
4061
|
try {
|
|
3955
4062
|
switch (i.type) {
|
|
3956
4063
|
case "attributes": {
|
|
3957
|
-
|
|
4064
|
+
f.info(
|
|
3958
4065
|
"[Haori]",
|
|
3959
4066
|
"Attribute changed:",
|
|
3960
4067
|
i.target,
|
|
3961
4068
|
i.attributeName
|
|
3962
4069
|
);
|
|
3963
4070
|
const s = i.target;
|
|
4071
|
+
if (i.attributeName && x.isAliasedAttributeReflection(
|
|
4072
|
+
s,
|
|
4073
|
+
i.attributeName
|
|
4074
|
+
))
|
|
4075
|
+
break;
|
|
3964
4076
|
x.setAttribute(
|
|
3965
4077
|
s,
|
|
3966
4078
|
i.attributeName,
|
|
3967
4079
|
s.getAttribute(i.attributeName)
|
|
3968
|
-
),
|
|
4080
|
+
), L.syncElement(s);
|
|
3969
4081
|
break;
|
|
3970
4082
|
}
|
|
3971
4083
|
case "childList": {
|
|
3972
|
-
|
|
4084
|
+
f.info(
|
|
3973
4085
|
"[Haori]",
|
|
3974
4086
|
"Child list changed:",
|
|
3975
4087
|
Array.from(i.removedNodes).map((s) => s.nodeName),
|
|
3976
4088
|
Array.from(i.addedNodes).map((s) => s.nodeName)
|
|
3977
4089
|
), Array.from(i.removedNodes).forEach((s) => {
|
|
3978
|
-
|
|
4090
|
+
L.cleanupTree(s), x.removeNode(s);
|
|
3979
4091
|
}), Array.from(i.addedNodes).forEach((s) => {
|
|
3980
|
-
s.parentElement instanceof HTMLElement && (x.addNode(s.parentElement, s),
|
|
4092
|
+
s.parentElement instanceof HTMLElement && (x.addNode(s.parentElement, s), L.syncTree(s));
|
|
3981
4093
|
});
|
|
3982
4094
|
break;
|
|
3983
4095
|
}
|
|
3984
4096
|
case "characterData": {
|
|
3985
|
-
|
|
4097
|
+
f.info(
|
|
3986
4098
|
"[Haori]",
|
|
3987
4099
|
"Character data changed:",
|
|
3988
4100
|
i.target,
|
|
3989
4101
|
i.target.textContent
|
|
3990
|
-
), i.target instanceof Text || i.target instanceof Comment ? x.changeText(i.target, i.target.textContent) :
|
|
4102
|
+
), i.target instanceof Text || i.target instanceof Comment ? x.changeText(i.target, i.target.textContent) : f.warn(
|
|
3991
4103
|
"[Haori]",
|
|
3992
4104
|
"Unsupported character data type:",
|
|
3993
4105
|
i.target
|
|
@@ -3995,33 +4107,33 @@ const H = class H {
|
|
|
3995
4107
|
break;
|
|
3996
4108
|
}
|
|
3997
4109
|
default:
|
|
3998
|
-
|
|
4110
|
+
f.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
3999
4111
|
continue;
|
|
4000
4112
|
}
|
|
4001
4113
|
} catch (s) {
|
|
4002
|
-
|
|
4114
|
+
f.error("[Haori]", "Error processing mutation:", s);
|
|
4003
4115
|
}
|
|
4004
4116
|
}).observe(t, {
|
|
4005
4117
|
childList: !0,
|
|
4006
4118
|
subtree: !0,
|
|
4007
4119
|
attributes: !0,
|
|
4008
4120
|
characterData: !0
|
|
4009
|
-
}),
|
|
4121
|
+
}), f.info("[Haori]", "Observer initialized for", t);
|
|
4010
4122
|
}
|
|
4011
4123
|
};
|
|
4012
|
-
|
|
4013
|
-
let q =
|
|
4124
|
+
I._initialized = !1;
|
|
4125
|
+
let q = I;
|
|
4014
4126
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4015
4127
|
const ft = "0.4.3";
|
|
4016
4128
|
export {
|
|
4017
4129
|
x as Core,
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4130
|
+
l as Env,
|
|
4131
|
+
b as Form,
|
|
4132
|
+
T as Fragment,
|
|
4133
|
+
X as Haori,
|
|
4134
|
+
f as Log,
|
|
4023
4135
|
P as Queue,
|
|
4024
|
-
|
|
4136
|
+
X as default,
|
|
4025
4137
|
ft as version
|
|
4026
4138
|
};
|
|
4027
4139
|
//# sourceMappingURL=haori.es.js.map
|