haori 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/haori.cjs.js +13 -13
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +830 -767
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +13 -13
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/package.json +1 -1
- package/dist/src/event_dispatcher.d.ts +10 -2
- package/dist/src/event_dispatcher.d.ts.map +1 -1
- package/dist/src/event_dispatcher.js +21 -3
- package/dist/src/event_dispatcher.js.map +1 -1
- package/dist/src/expression.d.ts +10 -0
- package/dist/src/expression.d.ts.map +1 -1
- package/dist/src/expression.js +63 -0
- package/dist/src/expression.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/procedure.d.ts +16 -3
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +71 -24
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/expression.test.js +59 -0
- package/dist/tests/expression.test.js.map +1 -1
- package/dist/tests/procedure-action-operations.test.js +272 -4
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/dist/tests/procedure.test.js +3 -2
- package/dist/tests/procedure.test.js.map +1 -1
- package/dist/tests/row-operations.test.js +21 -1
- package/dist/tests/row-operations.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -30,12 +30,12 @@ const O = class O {
|
|
|
30
30
|
};
|
|
31
31
|
O.devMode = !1;
|
|
32
32
|
let B = O;
|
|
33
|
-
const
|
|
34
|
-
function
|
|
33
|
+
const z = "embedded";
|
|
34
|
+
function rt(F) {
|
|
35
35
|
return F === "embedded" || F === "demo";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return F === null ? null :
|
|
37
|
+
function it(F) {
|
|
38
|
+
return F === null ? null : rt(F) ? F : z;
|
|
39
39
|
}
|
|
40
40
|
const D = class D {
|
|
41
41
|
/**
|
|
@@ -53,7 +53,7 @@ const D = class D {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(t) {
|
|
56
|
-
D._runtime =
|
|
56
|
+
D._runtime = rt(t) ? t : z;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -67,7 +67,7 @@ const D = class D {
|
|
|
67
67
|
if (t instanceof HTMLScriptElement) {
|
|
68
68
|
const r = t.getAttribute("data-prefix") || D._prefix;
|
|
69
69
|
D._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
-
const i =
|
|
70
|
+
const i = it(
|
|
71
71
|
t.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
73
73
|
i !== null && (D._runtime = i);
|
|
@@ -94,10 +94,10 @@ const D = class D {
|
|
|
94
94
|
return D._prefix;
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
D._prefix = "data-", D._runtime =
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
100
|
-
class
|
|
97
|
+
D._prefix = "data-", D._runtime = z;
|
|
98
|
+
let u = D;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", u.detect) : u.detect();
|
|
100
|
+
class d {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
103
103
|
*
|
|
@@ -126,7 +126,7 @@ class f {
|
|
|
126
126
|
console.error(t, ...e);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class
|
|
129
|
+
class st {
|
|
130
130
|
constructor() {
|
|
131
131
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
132
132
|
}
|
|
@@ -139,16 +139,16 @@ class rt {
|
|
|
139
139
|
*/
|
|
140
140
|
enqueue(t, e = !1) {
|
|
141
141
|
let r, i;
|
|
142
|
-
const
|
|
142
|
+
const n = new Promise((a, o) => {
|
|
143
143
|
r = a, i = o;
|
|
144
|
-
}),
|
|
144
|
+
}), s = {
|
|
145
145
|
task: t,
|
|
146
146
|
timestamp: performance.now(),
|
|
147
|
-
promise:
|
|
147
|
+
promise: n,
|
|
148
148
|
resolve: r,
|
|
149
149
|
reject: i
|
|
150
150
|
};
|
|
151
|
-
return e ? this.queue.unshift(
|
|
151
|
+
return e ? this.queue.unshift(s) : this.queue.push(s), this.scheduleProcessing(), n;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* キューを処理します。
|
|
@@ -168,13 +168,13 @@ class rt {
|
|
|
168
168
|
const r = await e.task();
|
|
169
169
|
e.resolve(r);
|
|
170
170
|
} catch (r) {
|
|
171
|
-
e.reject(r),
|
|
171
|
+
e.reject(r), d.error("[Haori]", `Task ${e.timestamp} failed:`, r);
|
|
172
172
|
}
|
|
173
173
|
if (performance.now() - t > this.MAX_BUDGET)
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
176
176
|
} catch (t) {
|
|
177
|
-
|
|
177
|
+
d.error("[Haori]", "Error processing queue:", t);
|
|
178
178
|
} finally {
|
|
179
179
|
this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
|
|
180
180
|
}
|
|
@@ -202,7 +202,7 @@ class rt {
|
|
|
202
202
|
t.length > 0 && await Promise.allSettled(t);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const _ = class _ {
|
|
206
206
|
/**
|
|
207
207
|
* タスクをキューに追加します。
|
|
208
208
|
*
|
|
@@ -220,8 +220,8 @@ const Q = class Q {
|
|
|
220
220
|
return this.ASYNC_QUEUE.wait();
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
|
-
|
|
224
|
-
let
|
|
223
|
+
_.ASYNC_QUEUE = new st();
|
|
224
|
+
let R = _;
|
|
225
225
|
class X {
|
|
226
226
|
/**
|
|
227
227
|
* 実行モードを取得します。
|
|
@@ -229,7 +229,7 @@ class X {
|
|
|
229
229
|
* @return 実行モード。
|
|
230
230
|
*/
|
|
231
231
|
static get runtime() {
|
|
232
|
-
return
|
|
232
|
+
return u.runtime;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* 実行モードを設定します。
|
|
@@ -238,7 +238,7 @@ class X {
|
|
|
238
238
|
* @return 戻り値はありません。
|
|
239
239
|
*/
|
|
240
240
|
static setRuntime(t) {
|
|
241
|
-
|
|
241
|
+
u.setRuntime(t);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* 通知ダイアログを表示します。
|
|
@@ -247,7 +247,7 @@ class X {
|
|
|
247
247
|
* @returns 通知が閉じられると解決されるPromise
|
|
248
248
|
*/
|
|
249
249
|
static dialog(t) {
|
|
250
|
-
return
|
|
250
|
+
return R.enqueue(() => {
|
|
251
251
|
window.alert(t);
|
|
252
252
|
}, !0);
|
|
253
253
|
}
|
|
@@ -275,7 +275,7 @@ class X {
|
|
|
275
275
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
276
276
|
*/
|
|
277
277
|
static confirm(t) {
|
|
278
|
-
return
|
|
278
|
+
return R.enqueue(() => window.confirm(t), !0);
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
281
|
* ダイアログを開きます。
|
|
@@ -283,8 +283,8 @@ class X {
|
|
|
283
283
|
* @param element 開くダイアログのHTML要素
|
|
284
284
|
*/
|
|
285
285
|
static openDialog(t) {
|
|
286
|
-
return
|
|
287
|
-
t instanceof HTMLDialogElement ? t.showModal() :
|
|
286
|
+
return R.enqueue(() => {
|
|
287
|
+
t instanceof HTMLDialogElement ? t.showModal() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
288
288
|
}, !0);
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
@@ -293,8 +293,8 @@ class X {
|
|
|
293
293
|
* @param element 閉じるダイアログのHTML要素
|
|
294
294
|
*/
|
|
295
295
|
static closeDialog(t) {
|
|
296
|
-
return
|
|
297
|
-
t instanceof HTMLDialogElement ? t.close() :
|
|
296
|
+
return R.enqueue(() => {
|
|
297
|
+
t instanceof HTMLDialogElement ? t.close() : d.error("[Haori]", "Element is not a dialog: ", t);
|
|
298
298
|
}, !0);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
@@ -314,7 +314,7 @@ class X {
|
|
|
314
314
|
* @param level メッセージのレベル(省略可能)
|
|
315
315
|
*/
|
|
316
316
|
static addMessage(t, e, r) {
|
|
317
|
-
return
|
|
317
|
+
return R.enqueue(() => {
|
|
318
318
|
const i = t instanceof HTMLFormElement ? t : t.parentElement ?? t;
|
|
319
319
|
i.setAttribute("data-message", e), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
320
320
|
}, !0);
|
|
@@ -325,21 +325,21 @@ class X {
|
|
|
325
325
|
* @param parent メッセージをクリアする親要素
|
|
326
326
|
*/
|
|
327
327
|
static clearMessages(t) {
|
|
328
|
-
return
|
|
328
|
+
return R.enqueue(() => {
|
|
329
329
|
t.removeAttribute("data-message"), t.removeAttribute("data-message-level"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
330
330
|
e.removeAttribute("data-message"), e.removeAttribute("data-message-level");
|
|
331
331
|
});
|
|
332
332
|
}, !0);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
const
|
|
336
|
-
function
|
|
335
|
+
const nt = ["addErrorMessage", "clearMessages"];
|
|
336
|
+
function et() {
|
|
337
337
|
const t = globalThis.window?.Haori;
|
|
338
|
-
return
|
|
338
|
+
return nt.every(
|
|
339
339
|
(r) => typeof t?.[r] == "function"
|
|
340
340
|
) ? t : X;
|
|
341
341
|
}
|
|
342
|
-
class
|
|
342
|
+
class y {
|
|
343
343
|
/**
|
|
344
344
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
345
345
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -350,7 +350,7 @@ class b {
|
|
|
350
350
|
*/
|
|
351
351
|
static getValues(t) {
|
|
352
352
|
const e = {};
|
|
353
|
-
return
|
|
353
|
+
return y.getPartValues(t, e);
|
|
354
354
|
}
|
|
355
355
|
/**
|
|
356
356
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -361,32 +361,32 @@ class b {
|
|
|
361
361
|
* @returns values と同じオブジェクト
|
|
362
362
|
*/
|
|
363
363
|
static getPartValues(t, e) {
|
|
364
|
-
const r = t.getAttribute("name"), i = t.getAttribute(`${
|
|
364
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${u.prefix}form-object`), n = t.getAttribute(`${u.prefix}form-list`);
|
|
365
365
|
if (r) {
|
|
366
|
-
|
|
366
|
+
n ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && d.warn(
|
|
367
367
|
"Haori",
|
|
368
|
-
`Element cannot have both ${
|
|
368
|
+
`Element cannot have both ${u.prefix}form-object and name attributes.`
|
|
369
369
|
);
|
|
370
|
-
for (const
|
|
371
|
-
|
|
370
|
+
for (const s of t.getChildElementFragments())
|
|
371
|
+
y.getPartValues(s, e);
|
|
372
372
|
} else if (i) {
|
|
373
|
-
const
|
|
373
|
+
const s = {};
|
|
374
374
|
for (const a of t.getChildElementFragments())
|
|
375
|
-
|
|
376
|
-
Object.keys(
|
|
375
|
+
y.getPartValues(a, s);
|
|
376
|
+
Object.keys(s).length > 0 && (e[String(i)] = s), n && d.warn(
|
|
377
377
|
"Haori",
|
|
378
|
-
`Element cannot have both ${
|
|
378
|
+
`Element cannot have both ${u.prefix}form-list and ${u.prefix}form-object attributes.`
|
|
379
379
|
);
|
|
380
|
-
} else if (
|
|
381
|
-
const
|
|
380
|
+
} else if (n) {
|
|
381
|
+
const s = [];
|
|
382
382
|
for (const a of t.getChildElementFragments()) {
|
|
383
383
|
const o = {};
|
|
384
|
-
|
|
384
|
+
y.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
|
|
385
385
|
}
|
|
386
|
-
|
|
386
|
+
s.length > 0 && (e[String(n)] = s);
|
|
387
387
|
} else
|
|
388
|
-
for (const
|
|
389
|
-
|
|
388
|
+
for (const s of t.getChildElementFragments())
|
|
389
|
+
y.getPartValues(s, e);
|
|
390
390
|
return e;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
@@ -399,7 +399,7 @@ class b {
|
|
|
399
399
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
400
400
|
*/
|
|
401
401
|
static setValues(t, e, r = !1) {
|
|
402
|
-
return
|
|
402
|
+
return y.setPartValues(t, e, null, r, !0);
|
|
403
403
|
}
|
|
404
404
|
/**
|
|
405
405
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -411,7 +411,7 @@ class b {
|
|
|
411
411
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
412
412
|
*/
|
|
413
413
|
static syncValues(t, e, r = !1) {
|
|
414
|
-
return
|
|
414
|
+
return y.setPartValues(t, e, null, r, !1);
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
417
|
* 単一フラグメントへ値を設定します。
|
|
@@ -433,53 +433,53 @@ class b {
|
|
|
433
433
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
434
434
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
435
435
|
*/
|
|
436
|
-
static setPartValues(t, e, r = null, i = !1,
|
|
437
|
-
const
|
|
436
|
+
static setPartValues(t, e, r = null, i = !1, n = !0) {
|
|
437
|
+
const s = [], a = t.getAttribute("name"), o = t.getAttribute(`${u.prefix}form-object`), h = t.getAttribute(`${u.prefix}form-list`), m = t.getAttribute(`${u.prefix}form-detach`);
|
|
438
438
|
if (a) {
|
|
439
439
|
if (!m || i) {
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
) : typeof
|
|
444
|
-
|
|
440
|
+
const b = e[String(a)];
|
|
441
|
+
h && Array.isArray(b) && r !== null ? s.push(
|
|
442
|
+
y.applyFragmentValue(t, b[r] ?? null, n)
|
|
443
|
+
) : typeof b > "u" || (typeof b == "string" || typeof b == "number" || typeof b == "boolean" || b === null ? s.push(y.applyFragmentValue(t, b, n)) : s.push(
|
|
444
|
+
y.applyFragmentValue(t, String(b), n)
|
|
445
445
|
));
|
|
446
446
|
}
|
|
447
447
|
} else if (o) {
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
448
|
+
const b = e[String(o)];
|
|
449
|
+
if (b && typeof b == "object")
|
|
450
450
|
for (const E of t.getChildElementFragments())
|
|
451
|
-
|
|
452
|
-
|
|
451
|
+
s.push(
|
|
452
|
+
y.setPartValues(
|
|
453
453
|
E,
|
|
454
|
-
|
|
454
|
+
b,
|
|
455
455
|
null,
|
|
456
456
|
i,
|
|
457
|
-
|
|
457
|
+
n
|
|
458
458
|
)
|
|
459
459
|
);
|
|
460
|
-
} else if (
|
|
461
|
-
const
|
|
462
|
-
if (Array.isArray(
|
|
460
|
+
} else if (h) {
|
|
461
|
+
const b = e[String(h)];
|
|
462
|
+
if (Array.isArray(b)) {
|
|
463
463
|
const E = t.getChildElementFragments();
|
|
464
464
|
for (let S = 0; S < E.length; S++) {
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
465
|
+
const c = E[S];
|
|
466
|
+
b.length > S ? s.push(
|
|
467
|
+
y.setPartValues(
|
|
468
|
+
c,
|
|
469
|
+
b[S],
|
|
470
470
|
S,
|
|
471
471
|
i,
|
|
472
|
-
|
|
472
|
+
n
|
|
473
473
|
)
|
|
474
|
-
) :
|
|
474
|
+
) : s.push(y.setPartValues(c, {}, S, i, n));
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
} else
|
|
478
|
-
for (const
|
|
479
|
-
|
|
480
|
-
|
|
478
|
+
for (const b of t.getChildElementFragments())
|
|
479
|
+
s.push(
|
|
480
|
+
y.setPartValues(b, e, null, i, n)
|
|
481
481
|
);
|
|
482
|
-
return Promise.all(
|
|
482
|
+
return Promise.all(s).then(() => {
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
/**
|
|
@@ -490,21 +490,21 @@ class b {
|
|
|
490
490
|
* @returns すべての初期化処理が完了するPromise
|
|
491
491
|
*/
|
|
492
492
|
static async reset(t) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
]), await
|
|
493
|
+
y.clearValues(t), await Promise.all([
|
|
494
|
+
y.clearMessages(t),
|
|
495
|
+
y.clearEachClones(t)
|
|
496
|
+
]), await R.enqueue(() => {
|
|
497
497
|
const e = t.getTarget();
|
|
498
498
|
if (e instanceof HTMLFormElement)
|
|
499
499
|
e.reset();
|
|
500
500
|
else {
|
|
501
501
|
const r = e.parentElement;
|
|
502
502
|
if (r) {
|
|
503
|
-
const i = e.nextElementSibling,
|
|
504
|
-
|
|
503
|
+
const i = e.nextElementSibling, n = document.createElement("form");
|
|
504
|
+
n.appendChild(e), n.reset(), r.insertBefore(e, i);
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
|
-
}), await
|
|
507
|
+
}), await P.evaluateAll(t);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -513,20 +513,20 @@ class b {
|
|
|
513
513
|
* 対象エレメント自体は削除しません。
|
|
514
514
|
*/
|
|
515
515
|
static clearEachClones(t) {
|
|
516
|
-
const e = [], r = (
|
|
517
|
-
if (
|
|
518
|
-
for (const
|
|
519
|
-
const a =
|
|
520
|
-
!a && !o && e.push(
|
|
516
|
+
const e = [], r = (n) => {
|
|
517
|
+
if (n.hasAttribute(`${u.prefix}each`))
|
|
518
|
+
for (const s of n.getChildElementFragments()) {
|
|
519
|
+
const a = s.hasAttribute(`${u.prefix}each-before`), o = s.hasAttribute(`${u.prefix}each-after`);
|
|
520
|
+
!a && !o && e.push(s.remove());
|
|
521
521
|
}
|
|
522
|
-
}, i = (
|
|
523
|
-
r(
|
|
524
|
-
for (const
|
|
525
|
-
i(
|
|
522
|
+
}, i = (n) => {
|
|
523
|
+
r(n);
|
|
524
|
+
for (const s of n.getChildElementFragments())
|
|
525
|
+
i(s);
|
|
526
526
|
};
|
|
527
527
|
r(t);
|
|
528
|
-
for (const
|
|
529
|
-
i(
|
|
528
|
+
for (const n of t.getChildElementFragments())
|
|
529
|
+
i(n);
|
|
530
530
|
return Promise.all(e).then(() => {
|
|
531
531
|
});
|
|
532
532
|
}
|
|
@@ -538,7 +538,7 @@ class b {
|
|
|
538
538
|
static clearValues(t) {
|
|
539
539
|
t.clearValue();
|
|
540
540
|
for (const e of t.getChildElementFragments())
|
|
541
|
-
|
|
541
|
+
y.clearValues(e);
|
|
542
542
|
}
|
|
543
543
|
/**
|
|
544
544
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -547,7 +547,7 @@ class b {
|
|
|
547
547
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
548
548
|
*/
|
|
549
549
|
static clearMessages(t) {
|
|
550
|
-
return
|
|
550
|
+
return et().clearMessages(
|
|
551
551
|
t.getTarget()
|
|
552
552
|
);
|
|
553
553
|
}
|
|
@@ -561,7 +561,7 @@ class b {
|
|
|
561
561
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
562
562
|
*/
|
|
563
563
|
static addErrorMessage(t, e, r) {
|
|
564
|
-
return
|
|
564
|
+
return y.addMessage(t, e, r, "error");
|
|
565
565
|
}
|
|
566
566
|
/**
|
|
567
567
|
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
@@ -574,10 +574,10 @@ class b {
|
|
|
574
574
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
575
575
|
*/
|
|
576
576
|
static addMessage(t, e, r, i) {
|
|
577
|
-
const
|
|
578
|
-
return
|
|
579
|
-
|
|
580
|
-
}),
|
|
577
|
+
const n = [], s = et(), a = s.addMessage, o = (m) => typeof a == "function" ? a.call(s, m, r, i) : s.addErrorMessage(m, r), h = y.findFragmentsByKey(t, e);
|
|
578
|
+
return h.forEach((m) => {
|
|
579
|
+
n.push(o(m.getTarget()));
|
|
580
|
+
}), h.length === 0 && n.push(o(t.getTarget())), Promise.all(n).then(() => {
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
583
|
/**
|
|
@@ -588,7 +588,7 @@ class b {
|
|
|
588
588
|
* @returns 一致するフラグメントの配列
|
|
589
589
|
*/
|
|
590
590
|
static findFragmentsByKey(t, e) {
|
|
591
|
-
return
|
|
591
|
+
return y.findFragmentByKeyParts(t, e.split("."));
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -600,31 +600,31 @@ class b {
|
|
|
600
600
|
*/
|
|
601
601
|
static findFragmentByKeyParts(t, e) {
|
|
602
602
|
const r = [], i = e[0];
|
|
603
|
-
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${
|
|
604
|
-
e.length > 1 && t.getAttribute(`${
|
|
605
|
-
r.push(...
|
|
603
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${u.prefix}form-object`))
|
|
604
|
+
e.length > 1 && t.getAttribute(`${u.prefix}form-object`) === i && t.getChildElementFragments().forEach((s) => {
|
|
605
|
+
r.push(...y.findFragmentByKeyParts(s, e.slice(1)));
|
|
606
606
|
});
|
|
607
|
-
else if (t.hasAttribute(`${
|
|
607
|
+
else if (t.hasAttribute(`${u.prefix}form-list`)) {
|
|
608
608
|
if (e.length > 1) {
|
|
609
|
-
const
|
|
610
|
-
if (
|
|
611
|
-
const o = i.substring(0,
|
|
612
|
-
if (
|
|
613
|
-
const
|
|
609
|
+
const n = t.getAttribute(`${u.prefix}form-list`), s = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
610
|
+
if (s !== -1 && a !== -1 && s < a) {
|
|
611
|
+
const o = i.substring(0, s);
|
|
612
|
+
if (n === o) {
|
|
613
|
+
const h = i.substring(s + 1, a), m = Number(h);
|
|
614
614
|
if (isNaN(m))
|
|
615
|
-
|
|
615
|
+
d.error("Haori", `Invalid index: ${i}`);
|
|
616
616
|
else {
|
|
617
|
-
const
|
|
618
|
-
m <
|
|
619
|
-
...
|
|
617
|
+
const b = t.getChildElementFragments().filter((E) => E.hasAttribute(`${u.prefix}row`));
|
|
618
|
+
m < b.length && r.push(
|
|
619
|
+
...y.findFragmentByKeyParts(b[m], e.slice(1))
|
|
620
620
|
);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
} else
|
|
626
|
-
t.getChildElementFragments().forEach((
|
|
627
|
-
r.push(...
|
|
626
|
+
t.getChildElementFragments().forEach((n) => {
|
|
627
|
+
r.push(...y.findFragmentByKeyParts(n, e));
|
|
628
628
|
});
|
|
629
629
|
return r;
|
|
630
630
|
}
|
|
@@ -686,28 +686,28 @@ const M = class M {
|
|
|
686
686
|
*/
|
|
687
687
|
static evaluate(t, e = {}) {
|
|
688
688
|
if (t.trim() === "")
|
|
689
|
-
return
|
|
689
|
+
return d.warn("[Haori]", t, "Expression is empty"), null;
|
|
690
690
|
if (this.containsDangerousPatterns(t))
|
|
691
|
-
return
|
|
691
|
+
return d.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
692
692
|
if (this.containsForbiddenKeys(e))
|
|
693
|
-
return
|
|
693
|
+
return d.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
694
694
|
if (this.containsForbiddenBindingValues(e))
|
|
695
|
-
return
|
|
695
|
+
return d.warn(
|
|
696
696
|
"[Haori]",
|
|
697
697
|
e,
|
|
698
698
|
"Binded values contain forbidden values"
|
|
699
699
|
), null;
|
|
700
|
-
const r = Object.keys(e).filter((
|
|
701
|
-
let
|
|
702
|
-
if (!
|
|
703
|
-
const
|
|
704
|
-
${
|
|
700
|
+
const r = Object.keys(e).filter((s) => !this.FORBIDDEN_BINDING_NAMES.has(s)).sort(), i = `${t}:${r.join(",")}`;
|
|
701
|
+
let n = this.EXPRESSION_CACHE.get(i);
|
|
702
|
+
if (!n) {
|
|
703
|
+
const s = this.buildAssignments(r), a = s ? `"use strict";
|
|
704
|
+
${s};
|
|
705
705
|
return (${t});` : `"use strict";
|
|
706
706
|
return (${t});`;
|
|
707
707
|
try {
|
|
708
|
-
|
|
708
|
+
n = new Function(...r, a), this.EXPRESSION_CACHE.set(i, n);
|
|
709
709
|
} catch (o) {
|
|
710
|
-
return
|
|
710
|
+
return d.error(
|
|
711
711
|
"[Haori]",
|
|
712
712
|
"Failed to compile expression:",
|
|
713
713
|
t,
|
|
@@ -716,12 +716,12 @@ return (${t});`;
|
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
718
|
try {
|
|
719
|
-
const
|
|
719
|
+
const s = [], a = this.wrapBoundValues(e);
|
|
720
720
|
return r.forEach((o) => {
|
|
721
|
-
|
|
722
|
-
}), this.withBlockedPropertyAccess(() =>
|
|
723
|
-
} catch (
|
|
724
|
-
return
|
|
721
|
+
s.push(a[o]);
|
|
722
|
+
}), this.withBlockedPropertyAccess(() => n(...s));
|
|
723
|
+
} catch (s) {
|
|
724
|
+
return d.error("[Haori]", "Expression evaluation error:", t, s), s instanceof ReferenceError ? void 0 : null;
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
/**
|
|
@@ -752,13 +752,20 @@ return (${t});`;
|
|
|
752
752
|
return !1;
|
|
753
753
|
const r = [];
|
|
754
754
|
let i = null;
|
|
755
|
-
for (let
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
|
|
759
|
-
|
|
755
|
+
for (let n = 0; n < e.length; n++) {
|
|
756
|
+
const s = e[n], a = e[n + 1] || null, o = r[r.length - 1] || null, h = e[n - 2] || null, m = e[n - 3] || null;
|
|
757
|
+
if (this.startsObjectKey(
|
|
758
|
+
o,
|
|
759
|
+
i,
|
|
760
|
+
h,
|
|
761
|
+
m
|
|
762
|
+
) && (s.value === "[" || s.type === "identifier" && this.FORBIDDEN_PROPERTY_NAMES.has(s.value) || s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
763
|
+
this.decodeStringLiteral(s.value)
|
|
764
|
+
)) || s.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(s.value) || this.STRICT_FORBIDDEN_NAMES.includes(s.value) || (i?.value === "." || i?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(s.value)) || o === "member" && s.value !== "]" && s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
765
|
+
this.decodeStringLiteral(s.value)
|
|
766
|
+
) || s.value === "." && a?.type !== "identifier" || s.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
760
767
|
return !1;
|
|
761
|
-
switch (
|
|
768
|
+
switch (s.value) {
|
|
762
769
|
case "(":
|
|
763
770
|
r.push("paren");
|
|
764
771
|
break;
|
|
@@ -768,17 +775,25 @@ return (${t});`;
|
|
|
768
775
|
break;
|
|
769
776
|
}
|
|
770
777
|
case "[": {
|
|
771
|
-
const
|
|
772
|
-
r.push(
|
|
778
|
+
const b = this.startsMemberAccess(i) ? "member" : "array";
|
|
779
|
+
r.push(b);
|
|
773
780
|
break;
|
|
774
781
|
}
|
|
782
|
+
case "{":
|
|
783
|
+
r.push("object");
|
|
784
|
+
break;
|
|
775
785
|
case "]": {
|
|
776
786
|
if (r.pop() === void 0)
|
|
777
787
|
return !1;
|
|
778
788
|
break;
|
|
779
789
|
}
|
|
790
|
+
case "}": {
|
|
791
|
+
if (r.pop() !== "object")
|
|
792
|
+
return !1;
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
780
795
|
}
|
|
781
|
-
i =
|
|
796
|
+
i = s;
|
|
782
797
|
}
|
|
783
798
|
return r.length === 0;
|
|
784
799
|
}
|
|
@@ -804,6 +819,8 @@ return (${t});`;
|
|
|
804
819
|
], i = /* @__PURE__ */ new Set([
|
|
805
820
|
"(",
|
|
806
821
|
")",
|
|
822
|
+
"{",
|
|
823
|
+
"}",
|
|
807
824
|
"[",
|
|
808
825
|
"]",
|
|
809
826
|
".",
|
|
@@ -819,41 +836,41 @@ return (${t});`;
|
|
|
819
836
|
">",
|
|
820
837
|
"<"
|
|
821
838
|
]);
|
|
822
|
-
let
|
|
823
|
-
for (;
|
|
824
|
-
const
|
|
825
|
-
if (/\s/.test(
|
|
826
|
-
|
|
839
|
+
let n = 0;
|
|
840
|
+
for (; n < t.length; ) {
|
|
841
|
+
const s = t[n];
|
|
842
|
+
if (/\s/.test(s)) {
|
|
843
|
+
n += 1;
|
|
827
844
|
continue;
|
|
828
845
|
}
|
|
829
|
-
if (
|
|
846
|
+
if (s === "/" && (t[n + 1] === "/" || t[n + 1] === "*"))
|
|
830
847
|
return null;
|
|
831
|
-
if (
|
|
832
|
-
const o = this.readStringToken(t,
|
|
848
|
+
if (s === '"' || s === "'") {
|
|
849
|
+
const o = this.readStringToken(t, n);
|
|
833
850
|
if (o === null)
|
|
834
851
|
return null;
|
|
835
|
-
e.push(o.token),
|
|
852
|
+
e.push(o.token), n = o.nextIndex;
|
|
836
853
|
continue;
|
|
837
854
|
}
|
|
838
855
|
const a = r.find(
|
|
839
|
-
(o) => t.startsWith(o,
|
|
856
|
+
(o) => t.startsWith(o, n)
|
|
840
857
|
);
|
|
841
858
|
if (a) {
|
|
842
|
-
e.push({ type: "operator", value: a, position:
|
|
859
|
+
e.push({ type: "operator", value: a, position: n }), n += a.length;
|
|
843
860
|
continue;
|
|
844
861
|
}
|
|
845
|
-
if (/[0-9]/.test(
|
|
846
|
-
const o = this.readNumberToken(t,
|
|
847
|
-
e.push(o.token),
|
|
862
|
+
if (/[0-9]/.test(s)) {
|
|
863
|
+
const o = this.readNumberToken(t, n);
|
|
864
|
+
e.push(o.token), n = o.nextIndex;
|
|
848
865
|
continue;
|
|
849
866
|
}
|
|
850
|
-
if (/[A-Za-z_$]/.test(
|
|
851
|
-
const o = this.readIdentifierToken(t,
|
|
852
|
-
e.push(o.token),
|
|
867
|
+
if (/[A-Za-z_$]/.test(s)) {
|
|
868
|
+
const o = this.readIdentifierToken(t, n);
|
|
869
|
+
e.push(o.token), n = o.nextIndex;
|
|
853
870
|
continue;
|
|
854
871
|
}
|
|
855
|
-
if (i.has(
|
|
856
|
-
e.push({ type: "operator", value:
|
|
872
|
+
if (i.has(s)) {
|
|
873
|
+
e.push({ type: "operator", value: s, position: n }), n += 1;
|
|
857
874
|
continue;
|
|
858
875
|
}
|
|
859
876
|
return null;
|
|
@@ -871,12 +888,12 @@ return (${t});`;
|
|
|
871
888
|
const r = t[e];
|
|
872
889
|
let i = e + 1;
|
|
873
890
|
for (; i < t.length; ) {
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
891
|
+
const n = t[i];
|
|
892
|
+
if (n === "\\") {
|
|
876
893
|
i += 2;
|
|
877
894
|
continue;
|
|
878
895
|
}
|
|
879
|
-
if (
|
|
896
|
+
if (n === r)
|
|
880
897
|
return {
|
|
881
898
|
token: {
|
|
882
899
|
type: "string",
|
|
@@ -941,6 +958,16 @@ return (${t});`;
|
|
|
941
958
|
static startsMemberAccess(t) {
|
|
942
959
|
return t === null ? !1 : t.type === "identifier" || t.type === "number" ? !0 : t.value === ")" || t.value === "]" || t.value === "?.";
|
|
943
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* object literal 内で次のトークンがキー位置かどうかを判定します。
|
|
963
|
+
*
|
|
964
|
+
* @param activeGroup 現在のグループ種別
|
|
965
|
+
* @param previous 直前のトークン
|
|
966
|
+
* @returns object literal のキー位置であれば true
|
|
967
|
+
*/
|
|
968
|
+
static startsObjectKey(t, e, r, i) {
|
|
969
|
+
return t !== "object" ? !1 : e?.value === "{" || e?.value === "," || e?.type === "identifier" && this.OBJECT_PROPERTY_MODIFIERS.has(e.value) && (r?.value === "{" || r?.value === ",") ? !0 : e?.value !== "*" ? !1 : r?.value === "{" || r?.value === "," ? !0 : r?.type === "identifier" && r.value === "async" && (i?.value === "{" || i?.value === ",");
|
|
970
|
+
}
|
|
944
971
|
/**
|
|
945
972
|
* 文字列リテラルをプレーン文字列へ変換します。
|
|
946
973
|
*
|
|
@@ -949,6 +976,9 @@ return (${t});`;
|
|
|
949
976
|
*/
|
|
950
977
|
static decodeStringLiteral(t) {
|
|
951
978
|
return t.slice(1, -1).replace(
|
|
979
|
+
/\\u\{([0-9a-fA-F]+)\}/g,
|
|
980
|
+
(e, r) => String.fromCodePoint(parseInt(r, 16))
|
|
981
|
+
).replace(
|
|
952
982
|
/\\u([0-9a-fA-F]{4})/g,
|
|
953
983
|
(e, r) => String.fromCharCode(parseInt(r, 16))
|
|
954
984
|
).replace(
|
|
@@ -984,8 +1014,8 @@ return (${t});`;
|
|
|
984
1014
|
*/
|
|
985
1015
|
static wrapBoundValues(t) {
|
|
986
1016
|
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
987
|
-
return Object.entries(t).forEach(([i,
|
|
988
|
-
r[i] = this.wrapBoundValue(
|
|
1017
|
+
return Object.entries(t).forEach(([i, n]) => {
|
|
1018
|
+
r[i] = this.wrapBoundValue(n, e);
|
|
989
1019
|
}), r;
|
|
990
1020
|
}
|
|
991
1021
|
/**
|
|
@@ -1001,39 +1031,39 @@ return (${t});`;
|
|
|
1001
1031
|
const r = t, i = e.get(r);
|
|
1002
1032
|
if (i !== void 0)
|
|
1003
1033
|
return i;
|
|
1004
|
-
const
|
|
1005
|
-
get: (
|
|
1034
|
+
const n = new Proxy(r, {
|
|
1035
|
+
get: (s, a, o) => {
|
|
1006
1036
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
1007
1037
|
return;
|
|
1008
|
-
const
|
|
1009
|
-
return typeof a == "symbol" ?
|
|
1010
|
-
|
|
1038
|
+
const h = Reflect.get(s, a, o);
|
|
1039
|
+
return typeof a == "symbol" ? h : this.wrapBoundValue(
|
|
1040
|
+
h,
|
|
1011
1041
|
e
|
|
1012
1042
|
);
|
|
1013
1043
|
},
|
|
1014
|
-
has: (
|
|
1015
|
-
getOwnPropertyDescriptor: (
|
|
1044
|
+
has: (s, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(s, a),
|
|
1045
|
+
getOwnPropertyDescriptor: (s, a) => {
|
|
1016
1046
|
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
1017
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
1047
|
+
return Reflect.getOwnPropertyDescriptor(s, a);
|
|
1018
1048
|
},
|
|
1019
|
-
apply: (
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1049
|
+
apply: (s, a, o) => {
|
|
1050
|
+
const h = Reflect.apply(
|
|
1051
|
+
s,
|
|
1022
1052
|
a,
|
|
1023
1053
|
o
|
|
1024
1054
|
);
|
|
1025
|
-
return this.isIteratorLike(
|
|
1055
|
+
return this.isIteratorLike(h) ? h : this.wrapBoundValue(h, e);
|
|
1026
1056
|
},
|
|
1027
|
-
construct: (
|
|
1057
|
+
construct: (s, a, o) => this.wrapBoundValue(
|
|
1028
1058
|
Reflect.construct(
|
|
1029
|
-
|
|
1059
|
+
s,
|
|
1030
1060
|
a,
|
|
1031
1061
|
o
|
|
1032
1062
|
),
|
|
1033
1063
|
e
|
|
1034
1064
|
)
|
|
1035
1065
|
});
|
|
1036
|
-
return e.set(r,
|
|
1066
|
+
return e.set(r, n), n;
|
|
1037
1067
|
}
|
|
1038
1068
|
/**
|
|
1039
1069
|
* Proxy ラップ対象の値かどうかを判定します。
|
|
@@ -1066,8 +1096,8 @@ return (${t});`;
|
|
|
1066
1096
|
...i,
|
|
1067
1097
|
descriptor: Object.getOwnPropertyDescriptor(i.target, i.property)
|
|
1068
1098
|
})).filter((i) => i.descriptor?.configurable === !0);
|
|
1069
|
-
r.forEach(({ target: i, property:
|
|
1070
|
-
Object.defineProperty(i,
|
|
1099
|
+
r.forEach(({ target: i, property: n }) => {
|
|
1100
|
+
Object.defineProperty(i, n, {
|
|
1071
1101
|
configurable: !0,
|
|
1072
1102
|
enumerable: !1,
|
|
1073
1103
|
get: () => {
|
|
@@ -1079,8 +1109,8 @@ return (${t});`;
|
|
|
1079
1109
|
try {
|
|
1080
1110
|
return t();
|
|
1081
1111
|
} finally {
|
|
1082
|
-
r.forEach(({ target: i, property:
|
|
1083
|
-
|
|
1112
|
+
r.forEach(({ target: i, property: n, descriptor: s }) => {
|
|
1113
|
+
s !== void 0 && Object.defineProperty(i, n, s);
|
|
1084
1114
|
});
|
|
1085
1115
|
}
|
|
1086
1116
|
}
|
|
@@ -1178,6 +1208,10 @@ M.FORBIDDEN_NAMES = [
|
|
|
1178
1208
|
"constructor",
|
|
1179
1209
|
"__proto__",
|
|
1180
1210
|
"prototype"
|
|
1211
|
+
]), M.OBJECT_PROPERTY_MODIFIERS = /* @__PURE__ */ new Set([
|
|
1212
|
+
"get",
|
|
1213
|
+
"set",
|
|
1214
|
+
"async"
|
|
1181
1215
|
]), M.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1182
1216
|
"await",
|
|
1183
1217
|
"break",
|
|
@@ -1214,33 +1248,33 @@ M.FORBIDDEN_NAMES = [
|
|
|
1214
1248
|
"yield"
|
|
1215
1249
|
]), M.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1216
1250
|
let j = M;
|
|
1217
|
-
const
|
|
1251
|
+
const I = class I {
|
|
1218
1252
|
/**
|
|
1219
1253
|
* フラグメントのコンストラクタ。
|
|
1220
1254
|
*
|
|
1221
1255
|
* @param target 対象ノード
|
|
1222
1256
|
*/
|
|
1223
1257
|
constructor(t) {
|
|
1224
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t,
|
|
1258
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t, I.FRAGMENT_CACHE.set(t, this);
|
|
1225
1259
|
}
|
|
1226
1260
|
static get(t) {
|
|
1227
1261
|
if (t == null)
|
|
1228
1262
|
return null;
|
|
1229
|
-
if (
|
|
1230
|
-
return
|
|
1263
|
+
if (I.FRAGMENT_CACHE.has(t))
|
|
1264
|
+
return I.FRAGMENT_CACHE.get(t);
|
|
1231
1265
|
let e;
|
|
1232
1266
|
switch (t.nodeType) {
|
|
1233
1267
|
case Node.ELEMENT_NODE:
|
|
1234
|
-
e = new
|
|
1268
|
+
e = new x(t);
|
|
1235
1269
|
break;
|
|
1236
1270
|
case Node.TEXT_NODE:
|
|
1237
1271
|
e = new H(t);
|
|
1238
1272
|
break;
|
|
1239
1273
|
case Node.COMMENT_NODE:
|
|
1240
|
-
e = new
|
|
1274
|
+
e = new Z(t);
|
|
1241
1275
|
break;
|
|
1242
1276
|
default:
|
|
1243
|
-
return
|
|
1277
|
+
return d.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
1244
1278
|
}
|
|
1245
1279
|
return e;
|
|
1246
1280
|
}
|
|
@@ -1262,7 +1296,7 @@ const C = class C {
|
|
|
1262
1296
|
return Promise.resolve();
|
|
1263
1297
|
if (this.parent) {
|
|
1264
1298
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1265
|
-
return
|
|
1299
|
+
return R.enqueue(() => {
|
|
1266
1300
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1267
1301
|
}).finally(() => {
|
|
1268
1302
|
t.skipMutationNodes = e;
|
|
@@ -1270,7 +1304,7 @@ const C = class C {
|
|
|
1270
1304
|
} else {
|
|
1271
1305
|
const t = this.target.parentNode;
|
|
1272
1306
|
if (t)
|
|
1273
|
-
return
|
|
1307
|
+
return R.enqueue(() => {
|
|
1274
1308
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
1275
1309
|
});
|
|
1276
1310
|
this.mounted = !1;
|
|
@@ -1287,7 +1321,7 @@ const C = class C {
|
|
|
1287
1321
|
return Promise.resolve();
|
|
1288
1322
|
if (this.parent) {
|
|
1289
1323
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1290
|
-
return
|
|
1324
|
+
return R.enqueue(() => {
|
|
1291
1325
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1292
1326
|
}).finally(() => {
|
|
1293
1327
|
t.skipMutationNodes = e;
|
|
@@ -1318,7 +1352,7 @@ const C = class C {
|
|
|
1318
1352
|
* @return 除去のPromise
|
|
1319
1353
|
*/
|
|
1320
1354
|
remove(t = !0) {
|
|
1321
|
-
return this.parent && this.parent.removeChild(this),
|
|
1355
|
+
return this.parent && this.parent.removeChild(this), I.FRAGMENT_CACHE.delete(this.target), t ? this.unmount() : Promise.resolve();
|
|
1322
1356
|
}
|
|
1323
1357
|
/**
|
|
1324
1358
|
* 対象ノードを取得します。
|
|
@@ -1345,9 +1379,9 @@ const C = class C {
|
|
|
1345
1379
|
this.parent = t;
|
|
1346
1380
|
}
|
|
1347
1381
|
};
|
|
1348
|
-
|
|
1349
|
-
let T =
|
|
1350
|
-
class
|
|
1382
|
+
I.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1383
|
+
let T = I;
|
|
1384
|
+
class x extends T {
|
|
1351
1385
|
/**
|
|
1352
1386
|
* エレメントフラグメントのコンストラクタ。
|
|
1353
1387
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1396,7 +1430,7 @@ class R extends T {
|
|
|
1396
1430
|
*/
|
|
1397
1431
|
getChildElementFragments() {
|
|
1398
1432
|
return this.children.filter(
|
|
1399
|
-
(t) => t instanceof
|
|
1433
|
+
(t) => t instanceof x
|
|
1400
1434
|
);
|
|
1401
1435
|
}
|
|
1402
1436
|
/**
|
|
@@ -1417,7 +1451,7 @@ class R extends T {
|
|
|
1417
1451
|
removeChild(t) {
|
|
1418
1452
|
const e = this.children.indexOf(t);
|
|
1419
1453
|
if (e < 0) {
|
|
1420
|
-
|
|
1454
|
+
d.warn("[Haori]", "Child fragment not found.", t);
|
|
1421
1455
|
return;
|
|
1422
1456
|
}
|
|
1423
1457
|
this.children.splice(e, 1), t.setParent(null);
|
|
@@ -1428,7 +1462,7 @@ class R extends T {
|
|
|
1428
1462
|
* @returns クローンされたフラグメント
|
|
1429
1463
|
*/
|
|
1430
1464
|
clone() {
|
|
1431
|
-
const t = new
|
|
1465
|
+
const t = new x(
|
|
1432
1466
|
this.target.cloneNode(!1)
|
|
1433
1467
|
);
|
|
1434
1468
|
return this.attributeMap.forEach((e, r) => {
|
|
@@ -1496,7 +1530,7 @@ class R extends T {
|
|
|
1496
1530
|
*/
|
|
1497
1531
|
clearBindingDataCache() {
|
|
1498
1532
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1499
|
-
t instanceof
|
|
1533
|
+
t instanceof x && t.clearBindingDataCache();
|
|
1500
1534
|
});
|
|
1501
1535
|
}
|
|
1502
1536
|
/**
|
|
@@ -1564,18 +1598,18 @@ class R extends T {
|
|
|
1564
1598
|
return Promise.resolve();
|
|
1565
1599
|
const r = this.getTarget();
|
|
1566
1600
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
1567
|
-
const i = this.getAttribute("value"),
|
|
1568
|
-
let
|
|
1569
|
-
return
|
|
1570
|
-
r.checked =
|
|
1601
|
+
const i = this.getAttribute("value"), n = r.type === "checkbox" && i === "true";
|
|
1602
|
+
let s;
|
|
1603
|
+
return n ? s = t === !0 || t === "true" : i === "false" ? s = t === !1 : s = i === String(t), this.value = n ? s : s ? t : null, r.checked === s ? Promise.resolve() : (this.skipChangeValue = !0, R.enqueue(() => {
|
|
1604
|
+
r.checked = s, e && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1571
1605
|
}).finally(() => {
|
|
1572
1606
|
this.skipChangeValue = !1;
|
|
1573
1607
|
}));
|
|
1574
|
-
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0,
|
|
1608
|
+
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, R.enqueue(() => {
|
|
1575
1609
|
r.value = t === null ? "" : String(t), e && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
1576
1610
|
}).finally(() => {
|
|
1577
1611
|
this.skipChangeValue = !1;
|
|
1578
|
-
})) : (
|
|
1612
|
+
})) : (d.warn(
|
|
1579
1613
|
"[Haori]",
|
|
1580
1614
|
"setValue is not supported for this element type.",
|
|
1581
1615
|
r
|
|
@@ -1651,7 +1685,7 @@ class R extends T {
|
|
|
1651
1685
|
return Promise.resolve();
|
|
1652
1686
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1653
1687
|
const r = this.getTarget();
|
|
1654
|
-
return
|
|
1688
|
+
return R.enqueue(() => {
|
|
1655
1689
|
r.removeAttribute(t), e !== t && r.removeAttribute(e);
|
|
1656
1690
|
}).finally(() => {
|
|
1657
1691
|
this.skipMutationAttributes = !1;
|
|
@@ -1671,15 +1705,15 @@ class R extends T {
|
|
|
1671
1705
|
return Promise.resolve();
|
|
1672
1706
|
if (r === null)
|
|
1673
1707
|
return t === e ? this.removeAttribute(t) : this.removeAliasedAttribute(t, e);
|
|
1674
|
-
const
|
|
1675
|
-
this.attributeMap.set(t,
|
|
1676
|
-
const
|
|
1677
|
-
return
|
|
1678
|
-
if (
|
|
1679
|
-
|
|
1708
|
+
const n = new U(t, r);
|
|
1709
|
+
this.attributeMap.set(t, n), this.skipMutationAttributes = !0;
|
|
1710
|
+
const s = this.getTarget(), a = n.isForceEvaluation() ? r : this.getAttribute(t);
|
|
1711
|
+
return R.enqueue(() => {
|
|
1712
|
+
if (s.getAttribute(t) !== r && s.setAttribute(t, r), a === null || a === !1)
|
|
1713
|
+
s.removeAttribute(e);
|
|
1680
1714
|
else {
|
|
1681
1715
|
const o = String(a);
|
|
1682
|
-
|
|
1716
|
+
s.getAttribute(e) !== o && s.setAttribute(e, o), i && n.isEvaluate && e === "value" && (s instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(s.type) || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement) && (this.value = o, s.value !== o && (s.value = o));
|
|
1683
1717
|
}
|
|
1684
1718
|
}).finally(() => {
|
|
1685
1719
|
this.skipMutationAttributes = !1;
|
|
@@ -1696,7 +1730,7 @@ class R extends T {
|
|
|
1696
1730
|
return Promise.resolve();
|
|
1697
1731
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1698
1732
|
const e = this.getTarget();
|
|
1699
|
-
return
|
|
1733
|
+
return R.enqueue(() => {
|
|
1700
1734
|
e.removeAttribute(t);
|
|
1701
1735
|
}).finally(() => {
|
|
1702
1736
|
this.skipMutationAttributes = !1;
|
|
@@ -1714,7 +1748,7 @@ class R extends T {
|
|
|
1714
1748
|
if (e === void 0)
|
|
1715
1749
|
return null;
|
|
1716
1750
|
const r = e.evaluate(this.getBindingData());
|
|
1717
|
-
return r.length === 1 ? r[0] :
|
|
1751
|
+
return r.length === 1 ? r[0] : L.joinEvaluateResults(r);
|
|
1718
1752
|
}
|
|
1719
1753
|
/**
|
|
1720
1754
|
* 属性の生の値を取得します。
|
|
@@ -1755,15 +1789,15 @@ class R extends T {
|
|
|
1755
1789
|
if (r.parentNode !== this.target)
|
|
1756
1790
|
return null;
|
|
1757
1791
|
const i = e ? r.nextSibling : r;
|
|
1758
|
-
let
|
|
1759
|
-
for (;
|
|
1760
|
-
const
|
|
1761
|
-
if (
|
|
1762
|
-
const a = this.children.indexOf(
|
|
1792
|
+
let n = e ? r.nextSibling : r;
|
|
1793
|
+
for (; n !== null; ) {
|
|
1794
|
+
const s = T.get(n);
|
|
1795
|
+
if (s !== null) {
|
|
1796
|
+
const a = this.children.indexOf(s);
|
|
1763
1797
|
if (a !== -1)
|
|
1764
1798
|
return { index: a, referenceNode: i };
|
|
1765
1799
|
}
|
|
1766
|
-
|
|
1800
|
+
n = n.nextSibling;
|
|
1767
1801
|
}
|
|
1768
1802
|
return { index: this.children.length, referenceNode: i };
|
|
1769
1803
|
}
|
|
@@ -1779,29 +1813,29 @@ class R extends T {
|
|
|
1779
1813
|
if (this.skipMutationNodes)
|
|
1780
1814
|
return Promise.resolve();
|
|
1781
1815
|
if (t === this)
|
|
1782
|
-
return
|
|
1816
|
+
return d.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1783
1817
|
const i = /* @__PURE__ */ new Set();
|
|
1784
|
-
let
|
|
1785
|
-
for (;
|
|
1786
|
-
i.add(
|
|
1818
|
+
let n = this.parent;
|
|
1819
|
+
for (; n; )
|
|
1820
|
+
i.add(n), n = n.getParent();
|
|
1787
1821
|
if (i.has(t))
|
|
1788
|
-
return
|
|
1789
|
-
const
|
|
1822
|
+
return d.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1823
|
+
const s = t.getParent() === this;
|
|
1790
1824
|
let a = -1, o = -1;
|
|
1791
|
-
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1825
|
+
s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1826
|
+
const h = t.getParent();
|
|
1827
|
+
h !== null && h.removeChild(t);
|
|
1794
1828
|
let m = r === void 0 ? e?.getTarget() || null : r;
|
|
1795
1829
|
if (e === null)
|
|
1796
1830
|
this.children.push(t);
|
|
1797
1831
|
else {
|
|
1798
1832
|
let E;
|
|
1799
|
-
if (
|
|
1833
|
+
if (s ? a !== -1 && a < o ? E = o - 1 : E = o : E = this.children.indexOf(e), E === -1) {
|
|
1800
1834
|
const S = this.resolveInsertionPointFromDom(
|
|
1801
1835
|
e,
|
|
1802
1836
|
!1
|
|
1803
1837
|
);
|
|
1804
|
-
S === null ? (
|
|
1838
|
+
S === null ? (d.warn(
|
|
1805
1839
|
"[Haori]",
|
|
1806
1840
|
"Reference child not found in children.",
|
|
1807
1841
|
e
|
|
@@ -1810,11 +1844,11 @@ class R extends T {
|
|
|
1810
1844
|
this.children.splice(E, 0, t);
|
|
1811
1845
|
}
|
|
1812
1846
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1813
|
-
const
|
|
1814
|
-
return this.skipMutationNodes = !0,
|
|
1847
|
+
const b = this.skipMutationNodes;
|
|
1848
|
+
return this.skipMutationNodes = !0, R.enqueue(() => {
|
|
1815
1849
|
this.target.insertBefore(t.getTarget(), m);
|
|
1816
1850
|
}).finally(() => {
|
|
1817
|
-
this.skipMutationNodes =
|
|
1851
|
+
this.skipMutationNodes = b;
|
|
1818
1852
|
});
|
|
1819
1853
|
}
|
|
1820
1854
|
/**
|
|
@@ -1833,7 +1867,7 @@ class R extends T {
|
|
|
1833
1867
|
e,
|
|
1834
1868
|
!0
|
|
1835
1869
|
);
|
|
1836
|
-
return i === null ? (
|
|
1870
|
+
return i === null ? (d.warn(
|
|
1837
1871
|
"[Haori]",
|
|
1838
1872
|
"Reference child not found in children.",
|
|
1839
1873
|
e
|
|
@@ -1885,7 +1919,7 @@ class R extends T {
|
|
|
1885
1919
|
* @returns エレメントの非表示のPromise
|
|
1886
1920
|
*/
|
|
1887
1921
|
hide() {
|
|
1888
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1922
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${u.prefix}if-false`, ""), Promise.resolve();
|
|
1889
1923
|
}
|
|
1890
1924
|
/**
|
|
1891
1925
|
* エレメントを表示します。
|
|
@@ -1893,7 +1927,7 @@ class R extends T {
|
|
|
1893
1927
|
* @return エレメントの表示のPromise
|
|
1894
1928
|
*/
|
|
1895
1929
|
show() {
|
|
1896
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1930
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${u.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1897
1931
|
}
|
|
1898
1932
|
/**
|
|
1899
1933
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1917,7 +1951,7 @@ class H extends T {
|
|
|
1917
1951
|
* @param target 対象テキストノード
|
|
1918
1952
|
*/
|
|
1919
1953
|
constructor(t) {
|
|
1920
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1954
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new L(this.text);
|
|
1921
1955
|
}
|
|
1922
1956
|
/**
|
|
1923
1957
|
* フラグメントをクローンします。
|
|
@@ -1943,7 +1977,7 @@ class H extends T {
|
|
|
1943
1977
|
* @returns 更新のPromise
|
|
1944
1978
|
*/
|
|
1945
1979
|
setContent(t) {
|
|
1946
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1980
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new L(t), this.evaluate());
|
|
1947
1981
|
}
|
|
1948
1982
|
/**
|
|
1949
1983
|
* フラグメントを評価します。
|
|
@@ -1953,10 +1987,10 @@ class H extends T {
|
|
|
1953
1987
|
evaluate() {
|
|
1954
1988
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1955
1989
|
new Error("Parent fragment is required for raw evaluation")
|
|
1956
|
-
) :
|
|
1990
|
+
) : R.enqueue(() => {
|
|
1957
1991
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1958
1992
|
this.parent.getBindingData()
|
|
1959
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1993
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = L.joinEvaluateResults(
|
|
1960
1994
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1961
1995
|
) : this.target.textContent = this.text;
|
|
1962
1996
|
}).finally(() => {
|
|
@@ -1964,7 +1998,7 @@ class H extends T {
|
|
|
1964
1998
|
});
|
|
1965
1999
|
}
|
|
1966
2000
|
}
|
|
1967
|
-
class
|
|
2001
|
+
class Z extends T {
|
|
1968
2002
|
/**
|
|
1969
2003
|
* コメントフラグメントのコンストラクタ。
|
|
1970
2004
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1980,7 +2014,7 @@ class z extends T {
|
|
|
1980
2014
|
* @returns クローンされたフラグメント
|
|
1981
2015
|
*/
|
|
1982
2016
|
clone() {
|
|
1983
|
-
const t = new
|
|
2017
|
+
const t = new Z(this.target.cloneNode(!0));
|
|
1984
2018
|
return t.mounted = !1, t.text = this.text, t;
|
|
1985
2019
|
}
|
|
1986
2020
|
/**
|
|
@@ -1998,14 +2032,14 @@ class z extends T {
|
|
|
1998
2032
|
* @return 更新のPromise
|
|
1999
2033
|
*/
|
|
2000
2034
|
setContent(t) {
|
|
2001
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
2035
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, R.enqueue(() => {
|
|
2002
2036
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
2003
2037
|
}).finally(() => {
|
|
2004
2038
|
this.skipMutation = !1;
|
|
2005
2039
|
}));
|
|
2006
2040
|
}
|
|
2007
2041
|
}
|
|
2008
|
-
const
|
|
2042
|
+
const K = class K {
|
|
2009
2043
|
/**
|
|
2010
2044
|
* コンストラクタ。
|
|
2011
2045
|
*
|
|
@@ -2013,26 +2047,26 @@ const G = class G {
|
|
|
2013
2047
|
*/
|
|
2014
2048
|
constructor(t) {
|
|
2015
2049
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
2016
|
-
const e = [...t.matchAll(
|
|
2017
|
-
let r = 0, i = !1,
|
|
2018
|
-
for (const
|
|
2019
|
-
|
|
2020
|
-
text: t.slice(r,
|
|
2050
|
+
const e = [...t.matchAll(K.PLACEHOLDER_REGEX)];
|
|
2051
|
+
let r = 0, i = !1, n = !1;
|
|
2052
|
+
for (const s of e) {
|
|
2053
|
+
s.index > r && this.contents.push({
|
|
2054
|
+
text: t.slice(r, s.index),
|
|
2021
2055
|
type: 0
|
|
2022
2056
|
/* TEXT */
|
|
2023
2057
|
});
|
|
2024
2058
|
const a = {
|
|
2025
|
-
text:
|
|
2026
|
-
type:
|
|
2059
|
+
text: s[1] ?? s[2],
|
|
2060
|
+
type: s[1] ? 2 : 1
|
|
2027
2061
|
/* EXPRESSION */
|
|
2028
2062
|
};
|
|
2029
|
-
i = !0,
|
|
2063
|
+
i = !0, n = n || a.type === 2, this.contents.push(a), r = s.index + s[0].length;
|
|
2030
2064
|
}
|
|
2031
2065
|
r < t.length && this.contents.push({
|
|
2032
2066
|
text: t.slice(r),
|
|
2033
2067
|
type: 0
|
|
2034
2068
|
/* TEXT */
|
|
2035
|
-
}), this.isEvaluate = i, this.isRawEvaluate =
|
|
2069
|
+
}), this.isEvaluate = i, this.isRawEvaluate = n, this.checkRawExpressions();
|
|
2036
2070
|
}
|
|
2037
2071
|
/**
|
|
2038
2072
|
* 評価結果を結合して文字列にします。
|
|
@@ -2056,7 +2090,7 @@ const G = class G {
|
|
|
2056
2090
|
*/
|
|
2057
2091
|
checkRawExpressions() {
|
|
2058
2092
|
for (let t = 0; t < this.contents.length; t++)
|
|
2059
|
-
this.contents[t].type === 2 && this.contents.length > 1 && (
|
|
2093
|
+
this.contents[t].type === 2 && this.contents.length > 1 && (d.error(
|
|
2060
2094
|
"[Haori]",
|
|
2061
2095
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2062
2096
|
), this.contents[t].type = 1);
|
|
@@ -2079,7 +2113,7 @@ const G = class G {
|
|
|
2079
2113
|
} else
|
|
2080
2114
|
e.push(r.text);
|
|
2081
2115
|
} catch (i) {
|
|
2082
|
-
|
|
2116
|
+
d.error(
|
|
2083
2117
|
"[Haori]",
|
|
2084
2118
|
`Error evaluating text expression: ${r.text}`,
|
|
2085
2119
|
i
|
|
@@ -2088,9 +2122,9 @@ const G = class G {
|
|
|
2088
2122
|
}), e;
|
|
2089
2123
|
}
|
|
2090
2124
|
};
|
|
2091
|
-
|
|
2092
|
-
let
|
|
2093
|
-
const
|
|
2125
|
+
K.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2126
|
+
let L = K;
|
|
2127
|
+
const G = class G extends L {
|
|
2094
2128
|
/**
|
|
2095
2129
|
* コンストラクタ。
|
|
2096
2130
|
*
|
|
@@ -2098,7 +2132,7 @@ const K = class K extends $ {
|
|
|
2098
2132
|
* @param text 属性値
|
|
2099
2133
|
*/
|
|
2100
2134
|
constructor(t, e) {
|
|
2101
|
-
super(e), this.forceEvaluation =
|
|
2135
|
+
super(e), this.forceEvaluation = G.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
2102
2136
|
}
|
|
2103
2137
|
/**
|
|
2104
2138
|
* 強制評価フラグを取得します。
|
|
@@ -2126,26 +2160,26 @@ const K = class K extends $ {
|
|
|
2126
2160
|
} else
|
|
2127
2161
|
e.push(r.text);
|
|
2128
2162
|
} catch (i) {
|
|
2129
|
-
|
|
2163
|
+
d.error(
|
|
2130
2164
|
"[Haori]",
|
|
2131
2165
|
`Error evaluating attribute expression: ${r.text}`,
|
|
2132
2166
|
i
|
|
2133
2167
|
), e.push("");
|
|
2134
2168
|
}
|
|
2135
|
-
}), this.forceEvaluation && e.length > 1 ? (
|
|
2169
|
+
}), this.forceEvaluation && e.length > 1 ? (d.error(
|
|
2136
2170
|
"[Haori]",
|
|
2137
2171
|
"each or if expressions must have a single content.",
|
|
2138
2172
|
e
|
|
2139
2173
|
), [e[0]]) : e;
|
|
2140
2174
|
}
|
|
2141
2175
|
};
|
|
2142
|
-
|
|
2176
|
+
G.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2143
2177
|
"data-if",
|
|
2144
2178
|
"hor-if",
|
|
2145
2179
|
"data-each",
|
|
2146
2180
|
"hor-each"
|
|
2147
2181
|
];
|
|
2148
|
-
let U =
|
|
2182
|
+
let U = G;
|
|
2149
2183
|
class w {
|
|
2150
2184
|
/**
|
|
2151
2185
|
* カスタムイベントを発火します。
|
|
@@ -2156,13 +2190,13 @@ class w {
|
|
|
2156
2190
|
* @param options イベントオプション
|
|
2157
2191
|
*/
|
|
2158
2192
|
static dispatch(t, e, r, i) {
|
|
2159
|
-
const
|
|
2193
|
+
const n = new CustomEvent(`haori:${e}`, {
|
|
2160
2194
|
bubbles: i?.bubbles ?? !0,
|
|
2161
2195
|
cancelable: i?.cancelable ?? !1,
|
|
2162
2196
|
composed: i?.composed ?? !0,
|
|
2163
2197
|
detail: r
|
|
2164
2198
|
});
|
|
2165
|
-
return t.dispatchEvent(
|
|
2199
|
+
return t.dispatchEvent(n);
|
|
2166
2200
|
}
|
|
2167
2201
|
/**
|
|
2168
2202
|
* readyイベントを発火します。
|
|
@@ -2226,15 +2260,15 @@ class w {
|
|
|
2226
2260
|
* @param reason 変更理由
|
|
2227
2261
|
*/
|
|
2228
2262
|
static bindChange(t, e, r, i = "other") {
|
|
2229
|
-
const
|
|
2230
|
-
for (const
|
|
2231
|
-
const m = e?.[
|
|
2232
|
-
m !==
|
|
2263
|
+
const n = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
|
|
2264
|
+
for (const h of o) {
|
|
2265
|
+
const m = e?.[h], b = r[h];
|
|
2266
|
+
m !== b && n.push(h);
|
|
2233
2267
|
}
|
|
2234
2268
|
w.dispatch(t, "bindchange", {
|
|
2235
2269
|
previous: e || {},
|
|
2236
2270
|
next: r,
|
|
2237
|
-
changedKeys:
|
|
2271
|
+
changedKeys: n,
|
|
2238
2272
|
reason: i
|
|
2239
2273
|
});
|
|
2240
2274
|
}
|
|
@@ -2312,13 +2346,13 @@ class w {
|
|
|
2312
2346
|
* @param metadata runtime とメソッド変換情報。
|
|
2313
2347
|
* @return 戻り値はありません。
|
|
2314
2348
|
*/
|
|
2315
|
-
static fetchStart(t, e, r, i,
|
|
2349
|
+
static fetchStart(t, e, r, i, n) {
|
|
2316
2350
|
w.dispatch(t, "fetchstart", {
|
|
2317
2351
|
url: e,
|
|
2318
2352
|
options: r || {},
|
|
2319
2353
|
payload: i,
|
|
2320
2354
|
startedAt: performance.now(),
|
|
2321
|
-
...
|
|
2355
|
+
...n
|
|
2322
2356
|
});
|
|
2323
2357
|
}
|
|
2324
2358
|
/**
|
|
@@ -2345,44 +2379,44 @@ class w {
|
|
|
2345
2379
|
* @param status HTTPステータス(存在する場合)
|
|
2346
2380
|
* @param startedAt 開始時刻(存在する場合)
|
|
2347
2381
|
*/
|
|
2348
|
-
static fetchError(t, e, r, i,
|
|
2382
|
+
static fetchError(t, e, r, i, n) {
|
|
2349
2383
|
w.dispatch(t, "fetcherror", {
|
|
2350
2384
|
url: e,
|
|
2351
2385
|
status: i,
|
|
2352
2386
|
error: r,
|
|
2353
|
-
durationMs:
|
|
2387
|
+
durationMs: n ? performance.now() - n : void 0
|
|
2354
2388
|
});
|
|
2355
2389
|
}
|
|
2356
2390
|
}
|
|
2357
|
-
const
|
|
2391
|
+
const at = [
|
|
2358
2392
|
"addErrorMessage",
|
|
2359
2393
|
"closeDialog",
|
|
2360
2394
|
"confirm",
|
|
2361
2395
|
"dialog",
|
|
2362
2396
|
"openDialog",
|
|
2363
2397
|
"toast"
|
|
2364
|
-
];
|
|
2398
|
+
], ot = "__haoriHistoryState__";
|
|
2365
2399
|
function W() {
|
|
2366
2400
|
const t = globalThis.window?.Haori;
|
|
2367
|
-
return
|
|
2401
|
+
return at.every(
|
|
2368
2402
|
(r) => typeof t?.[r] == "function"
|
|
2369
2403
|
) ? t : X;
|
|
2370
2404
|
}
|
|
2371
|
-
const
|
|
2372
|
-
function
|
|
2373
|
-
return
|
|
2405
|
+
const lt = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2406
|
+
function ut(F) {
|
|
2407
|
+
return lt.has(F.toUpperCase());
|
|
2374
2408
|
}
|
|
2375
|
-
function
|
|
2409
|
+
function ct(F, t) {
|
|
2376
2410
|
for (const [e, r] of Object.entries(t))
|
|
2377
2411
|
r !== void 0 && (r === null ? F.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2378
2412
|
F.append(e, String(i));
|
|
2379
2413
|
}) : typeof r == "object" || typeof r == "function" ? F.append(e, JSON.stringify(r)) : F.append(e, String(r)));
|
|
2380
2414
|
}
|
|
2381
|
-
function
|
|
2415
|
+
function ht(F, t) {
|
|
2382
2416
|
const e = new URL(F, window.location.href), r = new URLSearchParams(e.search);
|
|
2383
|
-
return
|
|
2417
|
+
return ct(r, t), e.search = r.toString(), e.toString();
|
|
2384
2418
|
}
|
|
2385
|
-
const
|
|
2419
|
+
const l = class l {
|
|
2386
2420
|
/**
|
|
2387
2421
|
* イベント属性名を正しく生成します。
|
|
2388
2422
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2391,7 +2425,7 @@ const c = class c {
|
|
|
2391
2425
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2392
2426
|
*/
|
|
2393
2427
|
static attrName(t, e, r = !1) {
|
|
2394
|
-
return t ? `${
|
|
2428
|
+
return t ? `${u.prefix}${t}-${e}` : r ? `${u.prefix}fetch-${e}` : `${u.prefix}${e}`;
|
|
2395
2429
|
}
|
|
2396
2430
|
/**
|
|
2397
2431
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2402,13 +2436,13 @@ const c = class c {
|
|
|
2402
2436
|
*/
|
|
2403
2437
|
static resolveDataParamString(t, e) {
|
|
2404
2438
|
return t.replace(
|
|
2405
|
-
|
|
2406
|
-
(r, i,
|
|
2407
|
-
const
|
|
2408
|
-
i ??
|
|
2439
|
+
l.DATA_PLACEHOLDER_REGEX,
|
|
2440
|
+
(r, i, n) => {
|
|
2441
|
+
const s = j.evaluate(
|
|
2442
|
+
i ?? n ?? "",
|
|
2409
2443
|
e
|
|
2410
2444
|
);
|
|
2411
|
-
return
|
|
2445
|
+
return s == null || Number.isNaN(s) ? "" : encodeURIComponent(typeof s == "object" ? JSON.stringify(s) : String(s));
|
|
2412
2446
|
}
|
|
2413
2447
|
);
|
|
2414
2448
|
}
|
|
@@ -2421,17 +2455,17 @@ const c = class c {
|
|
|
2421
2455
|
*/
|
|
2422
2456
|
static isJsonStringContext(t, e) {
|
|
2423
2457
|
let r = !1, i = !1;
|
|
2424
|
-
for (let
|
|
2425
|
-
const
|
|
2458
|
+
for (let n = 0; n < e; n += 1) {
|
|
2459
|
+
const s = t[n];
|
|
2426
2460
|
if (i) {
|
|
2427
2461
|
i = !1;
|
|
2428
2462
|
continue;
|
|
2429
2463
|
}
|
|
2430
|
-
if (
|
|
2464
|
+
if (s === "\\") {
|
|
2431
2465
|
i = !0;
|
|
2432
2466
|
continue;
|
|
2433
2467
|
}
|
|
2434
|
-
|
|
2468
|
+
s === '"' && (r = !r);
|
|
2435
2469
|
}
|
|
2436
2470
|
return r;
|
|
2437
2471
|
}
|
|
@@ -2459,7 +2493,7 @@ const c = class c {
|
|
|
2459
2493
|
static stringifyJsonTemplateStringContent(t) {
|
|
2460
2494
|
if (t == null || Number.isNaN(t))
|
|
2461
2495
|
return "";
|
|
2462
|
-
const e = typeof t == "object" ?
|
|
2496
|
+
const e = typeof t == "object" ? l.stringifyJsonTemplateValue(t) : String(t);
|
|
2463
2497
|
return JSON.stringify(e).slice(1, -1);
|
|
2464
2498
|
}
|
|
2465
2499
|
/**
|
|
@@ -2471,13 +2505,13 @@ const c = class c {
|
|
|
2471
2505
|
*/
|
|
2472
2506
|
static resolveDataJsonString(t, e) {
|
|
2473
2507
|
return t.replace(
|
|
2474
|
-
|
|
2475
|
-
(r, i,
|
|
2508
|
+
l.DATA_PLACEHOLDER_REGEX,
|
|
2509
|
+
(r, i, n, s) => {
|
|
2476
2510
|
const a = j.evaluate(
|
|
2477
|
-
i ??
|
|
2511
|
+
i ?? n ?? "",
|
|
2478
2512
|
e
|
|
2479
2513
|
);
|
|
2480
|
-
return
|
|
2514
|
+
return l.isJsonStringContext(t, s) ? l.stringifyJsonTemplateStringContent(a) : l.stringifyJsonTemplateValue(a);
|
|
2481
2515
|
}
|
|
2482
2516
|
);
|
|
2483
2517
|
}
|
|
@@ -2494,14 +2528,14 @@ const c = class c {
|
|
|
2494
2528
|
return i;
|
|
2495
2529
|
if (typeof i != "string" || r === null)
|
|
2496
2530
|
return null;
|
|
2497
|
-
const
|
|
2498
|
-
return
|
|
2499
|
-
|
|
2531
|
+
const n = r.trim();
|
|
2532
|
+
return l.SINGLE_PLACEHOLDER_REGEX.test(n) ? P.parseDataBind(i) : n.startsWith("{") || n.startsWith("[") ? P.parseDataBind(
|
|
2533
|
+
l.resolveDataJsonString(
|
|
2500
2534
|
r,
|
|
2501
2535
|
t.getBindingData()
|
|
2502
2536
|
)
|
|
2503
|
-
) :
|
|
2504
|
-
|
|
2537
|
+
) : P.parseDataBind(
|
|
2538
|
+
l.resolveDataParamString(r, t.getBindingData())
|
|
2505
2539
|
);
|
|
2506
2540
|
}
|
|
2507
2541
|
/**
|
|
@@ -2516,30 +2550,30 @@ const c = class c {
|
|
|
2516
2550
|
targetFragment: t
|
|
2517
2551
|
};
|
|
2518
2552
|
if (e) {
|
|
2519
|
-
if (t.hasAttribute(
|
|
2520
|
-
|
|
2553
|
+
if (t.hasAttribute(l.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(l.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2554
|
+
l.attrName(e, "confirm")
|
|
2521
2555
|
).replace(/\\n/g, `
|
|
2522
|
-
`)), t.hasAttribute(
|
|
2556
|
+
`)), t.hasAttribute(l.attrName(e, "data")) && (r.data = l.resolveDataAttribute(
|
|
2523
2557
|
t,
|
|
2524
|
-
|
|
2525
|
-
)), t.hasAttribute(
|
|
2526
|
-
const
|
|
2527
|
-
|
|
2558
|
+
l.attrName(e, "data")
|
|
2559
|
+
)), t.hasAttribute(l.attrName(e, "form"))) {
|
|
2560
|
+
const c = t.getRawAttribute(
|
|
2561
|
+
l.attrName(e, "form")
|
|
2528
2562
|
);
|
|
2529
|
-
if (
|
|
2530
|
-
const
|
|
2531
|
-
|
|
2532
|
-
T.get(
|
|
2533
|
-
) :
|
|
2563
|
+
if (c) {
|
|
2564
|
+
const f = document.body.querySelector(c);
|
|
2565
|
+
f !== null ? r.formFragment = y.getFormFragment(
|
|
2566
|
+
T.get(f)
|
|
2567
|
+
) : d.error(
|
|
2534
2568
|
"Haori",
|
|
2535
|
-
`Form element not found: ${
|
|
2569
|
+
`Form element not found: ${c} (${l.attrName(e, "form")})`
|
|
2536
2570
|
);
|
|
2537
2571
|
} else
|
|
2538
|
-
r.formFragment =
|
|
2539
|
-
} else e === "change" && (r.formFragment =
|
|
2540
|
-
if (t.hasAttribute(`${
|
|
2541
|
-
const
|
|
2542
|
-
`${
|
|
2572
|
+
r.formFragment = y.getFormFragment(t);
|
|
2573
|
+
} else e === "change" && (r.formFragment = y.getFormFragment(t));
|
|
2574
|
+
if (t.hasAttribute(`${u.prefix}${e}-before-run`)) {
|
|
2575
|
+
const c = t.getRawAttribute(
|
|
2576
|
+
`${u.prefix}${e}-before-run`
|
|
2543
2577
|
);
|
|
2544
2578
|
try {
|
|
2545
2579
|
r.beforeCallback = new Function(
|
|
@@ -2547,214 +2581,216 @@ const c = class c {
|
|
|
2547
2581
|
"fetchOptions",
|
|
2548
2582
|
`
|
|
2549
2583
|
"use strict";
|
|
2550
|
-
${
|
|
2584
|
+
${c}
|
|
2551
2585
|
`
|
|
2552
2586
|
);
|
|
2553
|
-
} catch (
|
|
2554
|
-
|
|
2587
|
+
} catch (f) {
|
|
2588
|
+
d.error("Haori", `Invalid before script: ${f}`);
|
|
2555
2589
|
}
|
|
2556
2590
|
}
|
|
2557
2591
|
}
|
|
2558
|
-
const i =
|
|
2559
|
-
|
|
2560
|
-
const
|
|
2592
|
+
const i = l.attrName(e, "fetch"), n = t.hasAttribute(i);
|
|
2593
|
+
n && (r.fetchUrl = t.getAttribute(i));
|
|
2594
|
+
const s = {};
|
|
2561
2595
|
if (e) {
|
|
2562
|
-
const
|
|
2563
|
-
t.hasAttribute(
|
|
2564
|
-
|
|
2596
|
+
const c = l.attrName(e, "fetch-method");
|
|
2597
|
+
t.hasAttribute(c) && (s.method = t.getAttribute(
|
|
2598
|
+
c
|
|
2565
2599
|
));
|
|
2566
2600
|
} else {
|
|
2567
|
-
const
|
|
2568
|
-
t.hasAttribute(
|
|
2569
|
-
|
|
2601
|
+
const c = l.attrName(null, "method", !0);
|
|
2602
|
+
t.hasAttribute(c) && (s.method = t.getAttribute(
|
|
2603
|
+
c
|
|
2570
2604
|
));
|
|
2571
2605
|
}
|
|
2572
2606
|
if (e) {
|
|
2573
|
-
const
|
|
2574
|
-
if (t.hasAttribute(
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2607
|
+
const c = l.attrName(e, "fetch-headers");
|
|
2608
|
+
if (t.hasAttribute(c)) {
|
|
2609
|
+
const f = t.getRawAttribute(
|
|
2610
|
+
c
|
|
2577
2611
|
);
|
|
2578
2612
|
try {
|
|
2579
|
-
|
|
2613
|
+
s.headers = P.parseDataBind(f);
|
|
2580
2614
|
} catch (g) {
|
|
2581
|
-
|
|
2615
|
+
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2582
2616
|
}
|
|
2583
2617
|
}
|
|
2584
2618
|
} else {
|
|
2585
|
-
const
|
|
2619
|
+
const c = l.attrName(
|
|
2586
2620
|
null,
|
|
2587
2621
|
"headers",
|
|
2588
2622
|
!0
|
|
2589
2623
|
);
|
|
2590
|
-
if (t.hasAttribute(
|
|
2591
|
-
const
|
|
2592
|
-
|
|
2624
|
+
if (t.hasAttribute(c)) {
|
|
2625
|
+
const f = t.getRawAttribute(
|
|
2626
|
+
c
|
|
2593
2627
|
);
|
|
2594
2628
|
try {
|
|
2595
|
-
|
|
2629
|
+
s.headers = P.parseDataBind(f);
|
|
2596
2630
|
} catch (g) {
|
|
2597
|
-
|
|
2631
|
+
d.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2598
2632
|
}
|
|
2599
2633
|
}
|
|
2600
2634
|
}
|
|
2601
2635
|
if (e) {
|
|
2602
|
-
const
|
|
2636
|
+
const c = l.attrName(
|
|
2603
2637
|
e,
|
|
2604
2638
|
"fetch-content-type"
|
|
2605
2639
|
);
|
|
2606
|
-
if (t.hasAttribute(
|
|
2607
|
-
|
|
2608
|
-
...
|
|
2609
|
-
"Content-Type": t.getAttribute(
|
|
2640
|
+
if (t.hasAttribute(c))
|
|
2641
|
+
s.headers = {
|
|
2642
|
+
...s.headers,
|
|
2643
|
+
"Content-Type": t.getAttribute(c)
|
|
2610
2644
|
};
|
|
2611
|
-
else if (
|
|
2612
|
-
let
|
|
2613
|
-
|
|
2614
|
-
...
|
|
2645
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2646
|
+
let f = !1;
|
|
2647
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2648
|
+
...s.headers,
|
|
2615
2649
|
"Content-Type": "application/json"
|
|
2616
2650
|
});
|
|
2617
|
-
} else
|
|
2618
|
-
...
|
|
2651
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2652
|
+
...s.headers,
|
|
2619
2653
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2620
2654
|
});
|
|
2621
2655
|
} else {
|
|
2622
|
-
const
|
|
2656
|
+
const c = l.attrName(
|
|
2623
2657
|
null,
|
|
2624
2658
|
"content-type",
|
|
2625
2659
|
!0
|
|
2626
2660
|
);
|
|
2627
|
-
if (t.hasAttribute(
|
|
2628
|
-
|
|
2629
|
-
...
|
|
2630
|
-
"Content-Type": t.getAttribute(
|
|
2661
|
+
if (t.hasAttribute(c))
|
|
2662
|
+
s.headers = {
|
|
2663
|
+
...s.headers,
|
|
2664
|
+
"Content-Type": t.getAttribute(c)
|
|
2631
2665
|
};
|
|
2632
|
-
else if (
|
|
2633
|
-
let
|
|
2634
|
-
|
|
2635
|
-
...
|
|
2666
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2667
|
+
let f = !1;
|
|
2668
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2669
|
+
...s.headers,
|
|
2636
2670
|
"Content-Type": "application/json"
|
|
2637
2671
|
});
|
|
2638
|
-
} else
|
|
2639
|
-
...
|
|
2672
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2673
|
+
...s.headers,
|
|
2640
2674
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2641
2675
|
});
|
|
2642
2676
|
}
|
|
2643
|
-
Object.keys(
|
|
2644
|
-
const a = e ?
|
|
2677
|
+
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2678
|
+
const a = e ? l.attrName(e, "bind") : l.attrName(null, "bind", !0);
|
|
2645
2679
|
if (t.hasAttribute(a)) {
|
|
2646
|
-
const
|
|
2647
|
-
if (
|
|
2648
|
-
const
|
|
2649
|
-
|
|
2680
|
+
const c = t.getRawAttribute(a);
|
|
2681
|
+
if (c) {
|
|
2682
|
+
const f = document.body.querySelectorAll(c);
|
|
2683
|
+
f.length > 0 ? (r.bindFragments = [], f.forEach((g) => {
|
|
2650
2684
|
const A = T.get(g);
|
|
2651
2685
|
A && r.bindFragments.push(A);
|
|
2652
|
-
})) :
|
|
2686
|
+
})) : d.error(
|
|
2653
2687
|
"Haori",
|
|
2654
|
-
`Bind element not found: ${
|
|
2688
|
+
`Bind element not found: ${c} (${a})`
|
|
2655
2689
|
);
|
|
2656
2690
|
}
|
|
2657
2691
|
}
|
|
2658
|
-
const o =
|
|
2692
|
+
const o = l.attrName(e, "bind-arg"), h = l.attrName(
|
|
2659
2693
|
null,
|
|
2660
2694
|
"arg",
|
|
2661
2695
|
!0
|
|
2662
|
-
), m =
|
|
2696
|
+
), m = l.attrName(
|
|
2663
2697
|
null,
|
|
2664
2698
|
"bind-arg",
|
|
2665
2699
|
!0
|
|
2666
2700
|
);
|
|
2667
|
-
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(
|
|
2668
|
-
|
|
2701
|
+
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(h) ? r.bindArg = t.getRawAttribute(
|
|
2702
|
+
h
|
|
2669
2703
|
) : t.hasAttribute(m) && (r.bindArg = t.getRawAttribute(m));
|
|
2670
|
-
const
|
|
2671
|
-
if (t.hasAttribute(
|
|
2672
|
-
const
|
|
2673
|
-
r.bindParams =
|
|
2704
|
+
const b = e ? l.attrName(e, "bind-params") : l.attrName(null, "bind-params", !0);
|
|
2705
|
+
if (t.hasAttribute(b)) {
|
|
2706
|
+
const c = t.getRawAttribute(b);
|
|
2707
|
+
r.bindParams = c.split("&").map((f) => f.trim());
|
|
2674
2708
|
}
|
|
2675
|
-
const E = e ?
|
|
2709
|
+
const E = e ? l.attrName(e, "bind-append") : l.attrName(null, "bind-append", !0);
|
|
2676
2710
|
if (t.hasAttribute(E)) {
|
|
2677
|
-
const
|
|
2678
|
-
r.bindAppendParams =
|
|
2711
|
+
const c = t.getRawAttribute(E);
|
|
2712
|
+
r.bindAppendParams = c.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2679
2713
|
}
|
|
2680
|
-
const S = e ?
|
|
2714
|
+
const S = e ? l.attrName(e, "copy-params") : null;
|
|
2681
2715
|
if (S && t.hasAttribute(S)) {
|
|
2682
|
-
const
|
|
2716
|
+
const c = t.getRawAttribute(
|
|
2683
2717
|
S
|
|
2684
2718
|
);
|
|
2685
|
-
r.copyParams =
|
|
2719
|
+
r.copyParams = c.split("&").map((f) => f.trim()).filter(Boolean);
|
|
2686
2720
|
}
|
|
2687
2721
|
if (e) {
|
|
2688
|
-
if (t.hasAttribute(
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2722
|
+
if (t.hasAttribute(l.attrName(e, "adjust"))) {
|
|
2723
|
+
const f = t.getRawAttribute(
|
|
2724
|
+
l.attrName(e, "adjust")
|
|
2691
2725
|
);
|
|
2692
|
-
if (
|
|
2693
|
-
const g = document.body.querySelectorAll(
|
|
2726
|
+
if (f) {
|
|
2727
|
+
const g = document.body.querySelectorAll(f);
|
|
2694
2728
|
g.length > 0 ? (r.adjustFragments = [], g.forEach((A) => {
|
|
2695
2729
|
const v = T.get(A);
|
|
2696
2730
|
v && r.adjustFragments.push(v);
|
|
2697
|
-
})) :
|
|
2731
|
+
})) : d.error(
|
|
2698
2732
|
"Haori",
|
|
2699
|
-
`Adjust element not found: ${
|
|
2733
|
+
`Adjust element not found: ${f} (${l.attrName(e, "adjust")})`
|
|
2700
2734
|
);
|
|
2701
2735
|
}
|
|
2702
|
-
if (t.hasAttribute(
|
|
2736
|
+
if (t.hasAttribute(l.attrName(e, "adjust-value"))) {
|
|
2703
2737
|
const g = t.getRawAttribute(
|
|
2704
|
-
|
|
2738
|
+
l.attrName(e, "adjust-value")
|
|
2705
2739
|
), A = Number(g);
|
|
2706
2740
|
isNaN(A) || (r.adjustValue = A);
|
|
2707
2741
|
}
|
|
2708
2742
|
}
|
|
2709
|
-
if (t.hasAttribute(
|
|
2710
|
-
const
|
|
2711
|
-
`${
|
|
2743
|
+
if (t.hasAttribute(l.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(l.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(l.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(l.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${u.prefix}${e}-after-run`)) {
|
|
2744
|
+
const f = t.getRawAttribute(
|
|
2745
|
+
`${u.prefix}${e}-after-run`
|
|
2712
2746
|
);
|
|
2713
2747
|
try {
|
|
2714
2748
|
r.afterCallback = new Function(
|
|
2715
2749
|
"response",
|
|
2716
2750
|
`
|
|
2717
2751
|
"use strict";
|
|
2718
|
-
${
|
|
2752
|
+
${f}
|
|
2719
2753
|
`
|
|
2720
2754
|
);
|
|
2721
2755
|
} catch (g) {
|
|
2722
|
-
|
|
2756
|
+
d.error("Haori", `Invalid after script: ${g}`);
|
|
2723
2757
|
}
|
|
2724
2758
|
}
|
|
2725
|
-
if (t.hasAttribute(
|
|
2726
|
-
|
|
2759
|
+
if (t.hasAttribute(l.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2760
|
+
l.attrName(e, "dialog")
|
|
2727
2761
|
).replace(/\\n/g, `
|
|
2728
|
-
`)), t.hasAttribute(
|
|
2762
|
+
`)), t.hasAttribute(l.attrName(e, "toast"))) {
|
|
2729
2763
|
r.toastMessage = t.getAttribute(
|
|
2730
|
-
|
|
2764
|
+
l.attrName(e, "toast")
|
|
2731
2765
|
);
|
|
2732
|
-
const
|
|
2733
|
-
|
|
2734
|
-
), A = ["info", "warning", "error", "success"].includes(
|
|
2735
|
-
r.toastLevel = A ?
|
|
2766
|
+
const f = t.getRawAttribute(
|
|
2767
|
+
l.attrName(e, "toast-level")
|
|
2768
|
+
), A = ["info", "warning", "error", "success"].includes(f);
|
|
2769
|
+
r.toastLevel = A ? f : null;
|
|
2736
2770
|
}
|
|
2737
|
-
if (t.hasAttribute(
|
|
2738
|
-
|
|
2739
|
-
)), t.hasAttribute(
|
|
2740
|
-
|
|
2741
|
-
)), t.hasAttribute(
|
|
2771
|
+
if (t.hasAttribute(l.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2772
|
+
l.attrName(e, "redirect")
|
|
2773
|
+
)), t.hasAttribute(l.attrName(e, "scroll-error")) && (r.scrollOnError = !0), t.hasAttribute(l.attrName(e, "scroll")) && (r.scrollTarget = t.getAttribute(
|
|
2774
|
+
l.attrName(e, "scroll")
|
|
2775
|
+
)), t.hasAttribute(l.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2776
|
+
l.attrName(e, "history")
|
|
2777
|
+
)), t.hasAttribute(l.attrName(e, "history-data")) && (r.historyData = l.resolveDataAttribute(
|
|
2742
2778
|
t,
|
|
2743
|
-
|
|
2744
|
-
)), t.hasAttribute(
|
|
2745
|
-
const
|
|
2746
|
-
|
|
2779
|
+
l.attrName(e, "history-data")
|
|
2780
|
+
)), t.hasAttribute(l.attrName(e, "history-form"))) {
|
|
2781
|
+
const f = t.getRawAttribute(
|
|
2782
|
+
l.attrName(e, "history-form")
|
|
2747
2783
|
);
|
|
2748
|
-
if (
|
|
2749
|
-
const g = document.body.querySelector(
|
|
2750
|
-
g !== null ? r.historyFormFragment =
|
|
2784
|
+
if (f) {
|
|
2785
|
+
const g = document.body.querySelector(f);
|
|
2786
|
+
g !== null ? r.historyFormFragment = y.getFormFragment(
|
|
2751
2787
|
T.get(g)
|
|
2752
|
-
) :
|
|
2788
|
+
) : d.error(
|
|
2753
2789
|
"Haori",
|
|
2754
|
-
`Form element not found: ${
|
|
2790
|
+
`Form element not found: ${f} (${l.attrName(e, "history-form")})`
|
|
2755
2791
|
);
|
|
2756
2792
|
} else
|
|
2757
|
-
r.historyFormFragment =
|
|
2793
|
+
r.historyFormFragment = y.getFormFragment(t);
|
|
2758
2794
|
}
|
|
2759
2795
|
[
|
|
2760
2796
|
"reset",
|
|
@@ -2763,16 +2799,16 @@ ${h}
|
|
|
2763
2799
|
"copy",
|
|
2764
2800
|
"open",
|
|
2765
2801
|
"close"
|
|
2766
|
-
].forEach((
|
|
2767
|
-
const g =
|
|
2802
|
+
].forEach((f) => {
|
|
2803
|
+
const g = l.attrName(e, f);
|
|
2768
2804
|
if (!t.hasAttribute(g))
|
|
2769
2805
|
return;
|
|
2770
2806
|
const A = t.getRawAttribute(g), v = [];
|
|
2771
2807
|
if (A ? (document.body.querySelectorAll(A).forEach((J) => {
|
|
2772
|
-
const
|
|
2773
|
-
|
|
2774
|
-
}), v.length === 0 &&
|
|
2775
|
-
switch (
|
|
2808
|
+
const tt = T.get(J);
|
|
2809
|
+
tt && v.push(tt);
|
|
2810
|
+
}), v.length === 0 && d.error("Haori", `Element not found: ${A} (${g})`)) : v.push(t), v.length > 0)
|
|
2811
|
+
switch (f) {
|
|
2776
2812
|
case "reset":
|
|
2777
2813
|
r.resetFragments = v;
|
|
2778
2814
|
break;
|
|
@@ -2794,25 +2830,25 @@ ${h}
|
|
|
2794
2830
|
}
|
|
2795
2831
|
});
|
|
2796
2832
|
}
|
|
2797
|
-
if (!e && (t.hasAttribute(
|
|
2833
|
+
if (!e && (t.hasAttribute(l.attrName(null, "data", !0)) && (r.data = l.resolveDataAttribute(
|
|
2798
2834
|
t,
|
|
2799
|
-
|
|
2800
|
-
)), t.hasAttribute(
|
|
2801
|
-
const
|
|
2802
|
-
|
|
2835
|
+
l.attrName(null, "data", !0)
|
|
2836
|
+
)), t.hasAttribute(l.attrName(null, "form", !0)))) {
|
|
2837
|
+
const c = t.getRawAttribute(
|
|
2838
|
+
l.attrName(null, "form", !0)
|
|
2803
2839
|
);
|
|
2804
|
-
if (
|
|
2805
|
-
const
|
|
2806
|
-
|
|
2807
|
-
T.get(
|
|
2808
|
-
) :
|
|
2840
|
+
if (c) {
|
|
2841
|
+
const f = document.body.querySelector(c);
|
|
2842
|
+
f !== null ? r.formFragment = y.getFormFragment(
|
|
2843
|
+
T.get(f)
|
|
2844
|
+
) : d.error(
|
|
2809
2845
|
"Haori",
|
|
2810
|
-
`Form element not found: ${
|
|
2846
|
+
`Form element not found: ${c} (${l.attrName(null, "fetch-form", !0)})`
|
|
2811
2847
|
);
|
|
2812
2848
|
} else
|
|
2813
|
-
r.formFragment =
|
|
2849
|
+
r.formFragment = y.getFormFragment(t);
|
|
2814
2850
|
}
|
|
2815
|
-
return
|
|
2851
|
+
return n && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2816
2852
|
}
|
|
2817
2853
|
/**
|
|
2818
2854
|
* ElementFragment の構造的タイプガード。
|
|
@@ -2833,7 +2869,7 @@ ${h}
|
|
|
2833
2869
|
* @param arg2 イベント名
|
|
2834
2870
|
*/
|
|
2835
2871
|
constructor(t, e = null) {
|
|
2836
|
-
|
|
2872
|
+
l.isElementFragment(t) ? this.options = l.buildOptions(t, e) : this.options = t;
|
|
2837
2873
|
}
|
|
2838
2874
|
/**
|
|
2839
2875
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2874,61 +2910,61 @@ ${h}
|
|
|
2874
2910
|
}
|
|
2875
2911
|
const i = {};
|
|
2876
2912
|
if (this.options.formFragment) {
|
|
2877
|
-
const o =
|
|
2913
|
+
const o = y.getValues(this.options.formFragment);
|
|
2878
2914
|
Object.assign(i, o);
|
|
2879
2915
|
}
|
|
2880
2916
|
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2881
|
-
const
|
|
2917
|
+
const n = Object.keys(i).length > 0;
|
|
2882
2918
|
if (e) {
|
|
2883
|
-
const o = { ...r || {} },
|
|
2919
|
+
const o = { ...r || {} }, h = new Headers(
|
|
2884
2920
|
o.headers || void 0
|
|
2885
|
-
), m = (o.method || "GET").toUpperCase(),
|
|
2921
|
+
), m = (o.method || "GET").toUpperCase(), b = u.runtime === "demo" && !ut(m), E = b ? "GET" : m;
|
|
2886
2922
|
if (o.method = E, E === "GET" || E === "HEAD" || E === "OPTIONS")
|
|
2887
|
-
|
|
2888
|
-
else if (
|
|
2889
|
-
const
|
|
2890
|
-
if (/multipart\/form-data/i.test(
|
|
2891
|
-
|
|
2892
|
-
const
|
|
2923
|
+
n && (e = ht(e, i));
|
|
2924
|
+
else if (n) {
|
|
2925
|
+
const c = h.get("Content-Type") || "";
|
|
2926
|
+
if (/multipart\/form-data/i.test(c)) {
|
|
2927
|
+
h.delete("Content-Type");
|
|
2928
|
+
const f = new FormData();
|
|
2893
2929
|
for (const [g, A] of Object.entries(i))
|
|
2894
|
-
A == null ?
|
|
2895
|
-
o.body =
|
|
2896
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2897
|
-
const
|
|
2930
|
+
A == null ? f.append(g, "") : A instanceof Blob ? f.append(g, A) : Array.isArray(A) ? A.forEach((v) => f.append(g, String(v))) : typeof A == "object" ? f.append(g, JSON.stringify(A)) : f.append(g, String(A));
|
|
2931
|
+
o.body = f;
|
|
2932
|
+
} else if (/application\/x-www-form-urlencoded/i.test(c)) {
|
|
2933
|
+
const f = new URLSearchParams();
|
|
2898
2934
|
for (const [g, A] of Object.entries(i))
|
|
2899
|
-
A !== void 0 && (A === null ?
|
|
2900
|
-
o.body =
|
|
2935
|
+
A !== void 0 && (A === null ? f.append(g, "") : Array.isArray(A) ? A.forEach((v) => f.append(g, String(v))) : typeof A == "object" ? f.append(g, JSON.stringify(A)) : f.append(g, String(A)));
|
|
2936
|
+
o.body = f;
|
|
2901
2937
|
} else
|
|
2902
|
-
|
|
2938
|
+
h.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2903
2939
|
}
|
|
2904
|
-
o.headers =
|
|
2940
|
+
o.headers = h;
|
|
2905
2941
|
let S;
|
|
2906
|
-
if (
|
|
2907
|
-
runtime:
|
|
2942
|
+
if (b && (S = e && new URL(e, window.location.href).search || void 0, h.delete("Content-Type"), d.info("Haori demo fetch normalization", {
|
|
2943
|
+
runtime: u.runtime,
|
|
2908
2944
|
requestedMethod: m,
|
|
2909
2945
|
effectiveMethod: E,
|
|
2910
2946
|
transportMode: "query-get",
|
|
2911
2947
|
url: e,
|
|
2912
|
-
payload:
|
|
2948
|
+
payload: n ? i : void 0,
|
|
2913
2949
|
queryString: S
|
|
2914
2950
|
})), this.options.targetFragment && e) {
|
|
2915
|
-
const
|
|
2916
|
-
runtime:
|
|
2951
|
+
const c = performance.now(), f = {
|
|
2952
|
+
runtime: u.runtime,
|
|
2917
2953
|
requestedMethod: m,
|
|
2918
2954
|
effectiveMethod: E,
|
|
2919
|
-
transportMode:
|
|
2920
|
-
...
|
|
2955
|
+
transportMode: b ? "query-get" : "http",
|
|
2956
|
+
...b ? { queryString: S } : {}
|
|
2921
2957
|
};
|
|
2922
2958
|
return w.fetchStart(
|
|
2923
2959
|
this.options.targetFragment.getTarget(),
|
|
2924
2960
|
e,
|
|
2925
2961
|
o,
|
|
2926
|
-
|
|
2927
|
-
|
|
2962
|
+
n ? i : void 0,
|
|
2963
|
+
f
|
|
2928
2964
|
), fetch(e, o).then((g) => this.handleFetchResult(
|
|
2929
2965
|
g,
|
|
2930
2966
|
e || void 0,
|
|
2931
|
-
|
|
2967
|
+
c
|
|
2932
2968
|
)).catch((g) => {
|
|
2933
2969
|
throw e && w.fetchError(
|
|
2934
2970
|
this.options.targetFragment.getTarget(),
|
|
@@ -2937,18 +2973,18 @@ ${h}
|
|
|
2937
2973
|
), g;
|
|
2938
2974
|
});
|
|
2939
2975
|
}
|
|
2940
|
-
return fetch(e, o).then((
|
|
2976
|
+
return fetch(e, o).then((c) => this.handleFetchResult(c, e || void 0));
|
|
2941
2977
|
}
|
|
2942
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
2943
|
-
const o = this.options.formFragment,
|
|
2944
|
-
|
|
2945
|
-
`${
|
|
2978
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && n) {
|
|
2979
|
+
const o = this.options.formFragment, h = o.getTarget();
|
|
2980
|
+
h.setAttribute(
|
|
2981
|
+
`${u.prefix}bind`,
|
|
2946
2982
|
JSON.stringify(i)
|
|
2947
2983
|
);
|
|
2948
2984
|
const m = o.getBindingData();
|
|
2949
|
-
Object.assign(m, i), await
|
|
2985
|
+
Object.assign(m, i), await P.setBindingData(h, m);
|
|
2950
2986
|
}
|
|
2951
|
-
const
|
|
2987
|
+
const s = n ? i : {}, a = new Response(JSON.stringify(s), {
|
|
2952
2988
|
headers: { "Content-Type": "application/json" }
|
|
2953
2989
|
});
|
|
2954
2990
|
return this.handleFetchResult(a);
|
|
@@ -2979,13 +3015,13 @@ ${h}
|
|
|
2979
3015
|
typeof a == "object" && "response" in a && (t = "response" in a ? a.response : t);
|
|
2980
3016
|
}
|
|
2981
3017
|
}
|
|
2982
|
-
const s = [];
|
|
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(
|
|
2984
|
-
this.options.resetFragments.map((a) => b.reset(a))
|
|
2985
|
-
), await this.copy();
|
|
2986
3018
|
const n = [];
|
|
3019
|
+
n.push(this.bindResult(t)), n.push(this.adjust()), n.push(this.addRow()), n.push(this.removeRow()), n.push(this.movePrevRow()), n.push(this.moveNextRow()), await Promise.all(n), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
3020
|
+
this.options.resetFragments.map((a) => y.reset(a))
|
|
3021
|
+
), await this.copy();
|
|
3022
|
+
const s = [];
|
|
2987
3023
|
return this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
2988
|
-
|
|
3024
|
+
s.push(new l(a, null).run());
|
|
2989
3025
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((a) => {
|
|
2990
3026
|
const o = a.getTarget();
|
|
2991
3027
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
@@ -2993,14 +3029,14 @@ ${h}
|
|
|
2993
3029
|
);
|
|
2994
3030
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
2995
3031
|
const o = a.getTarget();
|
|
2996
|
-
o instanceof HTMLElement ?
|
|
3032
|
+
o instanceof HTMLElement ? s.push(i.openDialog(o)) : d.error("Haori", "Element is not an HTML element: ", o);
|
|
2997
3033
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
2998
3034
|
const o = a.getTarget();
|
|
2999
|
-
o instanceof HTMLElement ?
|
|
3000
|
-
}), await Promise.all(
|
|
3035
|
+
o instanceof HTMLElement ? s.push(i.closeDialog(o)) : d.error("Haori", "Element is not an HTML element: ", o);
|
|
3036
|
+
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3001
3037
|
this.options.toastMessage,
|
|
3002
3038
|
this.options.toastLevel ?? "info"
|
|
3003
|
-
), this.pushHistory(), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
3039
|
+
), this.pushHistory(), this.options.scrollTarget && document.querySelector(this.options.scrollTarget)?.scrollIntoView({ behavior: "smooth", block: "nearest" }), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
3004
3040
|
}
|
|
3005
3041
|
/**
|
|
3006
3042
|
* history.pushState を実行します。
|
|
@@ -3013,26 +3049,30 @@ ${h}
|
|
|
3013
3049
|
const t = this.options.historyUrl !== void 0 && this.options.historyUrl !== null, e = this.options.historyData !== void 0 && this.options.historyData !== null, r = this.options.historyFormFragment !== void 0 && this.options.historyFormFragment !== null;
|
|
3014
3050
|
if (!(!t && !e && !r))
|
|
3015
3051
|
try {
|
|
3016
|
-
const i = t ? this.options.historyUrl : window.location.pathname,
|
|
3017
|
-
if (
|
|
3018
|
-
const a = "history.pushState: cross-origin URL is not allowed: " +
|
|
3019
|
-
|
|
3052
|
+
const i = t ? this.options.historyUrl : window.location.pathname, n = new URL(i, window.location.href);
|
|
3053
|
+
if (n.origin !== window.location.origin) {
|
|
3054
|
+
const a = "history.pushState: cross-origin URL is not allowed: " + n.toString();
|
|
3055
|
+
d.error(
|
|
3020
3056
|
"Haori",
|
|
3021
3057
|
a
|
|
3022
3058
|
);
|
|
3023
3059
|
return;
|
|
3024
3060
|
}
|
|
3025
|
-
const
|
|
3026
|
-
for (const [o,
|
|
3027
|
-
|
|
3061
|
+
const s = (a) => {
|
|
3062
|
+
for (const [o, h] of Object.entries(a))
|
|
3063
|
+
h != null && (Array.isArray(h) ? h.forEach((m) => n.searchParams.append(o, String(m))) : typeof h == "object" ? n.searchParams.set(o, JSON.stringify(h)) : n.searchParams.set(o, String(h)));
|
|
3028
3064
|
};
|
|
3029
|
-
e &&
|
|
3030
|
-
|
|
3065
|
+
e && s(this.options.historyData), r && s(
|
|
3066
|
+
y.getValues(
|
|
3031
3067
|
this.options.historyFormFragment
|
|
3032
3068
|
)
|
|
3033
|
-
), history.pushState(
|
|
3069
|
+
), history.pushState(
|
|
3070
|
+
{ [ot]: !0 },
|
|
3071
|
+
"",
|
|
3072
|
+
n.toString()
|
|
3073
|
+
);
|
|
3034
3074
|
} catch (i) {
|
|
3035
|
-
|
|
3075
|
+
d.error("Haori", `history.pushState failed: ${i}`);
|
|
3036
3076
|
}
|
|
3037
3077
|
}
|
|
3038
3078
|
/**
|
|
@@ -3040,32 +3080,37 @@ ${h}
|
|
|
3040
3080
|
*/
|
|
3041
3081
|
async handleFetchError(t) {
|
|
3042
3082
|
let e = null;
|
|
3043
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
3083
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = y.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3044
3084
|
const r = async (s) => {
|
|
3045
|
-
const
|
|
3046
|
-
await W().addErrorMessage(
|
|
3085
|
+
const a = e ? e.getTarget() : document.body;
|
|
3086
|
+
await W().addErrorMessage(a, s);
|
|
3087
|
+
}, i = () => {
|
|
3088
|
+
if (!this.options.scrollOnError)
|
|
3089
|
+
return;
|
|
3090
|
+
const s = e ? e.getTarget() : document.body;
|
|
3091
|
+
(s.getAttribute("data-message-level") === "error" ? s : s.parentElement?.getAttribute("data-message-level") === "error" ? s.parentElement : s.querySelector('[data-message-level="error"]'))?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
3047
3092
|
};
|
|
3048
3093
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
3049
3094
|
try {
|
|
3050
|
-
const s = await t.json(),
|
|
3095
|
+
const s = await t.json(), a = [];
|
|
3051
3096
|
if (s && typeof s == "object") {
|
|
3052
|
-
if (typeof s.message == "string" &&
|
|
3053
|
-
for (const
|
|
3054
|
-
typeof
|
|
3097
|
+
if (typeof s.message == "string" && a.push({ message: s.message }), Array.isArray(s.messages))
|
|
3098
|
+
for (const o of s.messages)
|
|
3099
|
+
typeof o == "string" && a.push({ message: o });
|
|
3055
3100
|
if (s.errors && typeof s.errors == "object")
|
|
3056
|
-
for (const [
|
|
3057
|
-
Array.isArray(
|
|
3058
|
-
`) }) : typeof
|
|
3059
|
-
if (
|
|
3060
|
-
for (const [
|
|
3061
|
-
|
|
3062
|
-
`) }) : typeof
|
|
3101
|
+
for (const [o, h] of Object.entries(s.errors))
|
|
3102
|
+
Array.isArray(h) ? a.push({ key: o, message: h.join(`
|
|
3103
|
+
`) }) : typeof h == "string" ? a.push({ key: o, message: h }) : h != null && a.push({ key: o, message: String(h) });
|
|
3104
|
+
if (a.length === 0)
|
|
3105
|
+
for (const [o, h] of Object.entries(s))
|
|
3106
|
+
o === "message" || o === "messages" || o === "errors" || (Array.isArray(h) ? a.push({ key: o, message: h.join(`
|
|
3107
|
+
`) }) : typeof h == "string" && a.push({ key: o, message: h }));
|
|
3063
3108
|
}
|
|
3064
|
-
if (
|
|
3065
|
-
return await r(`${t.status} ${t.statusText}`), !1;
|
|
3066
|
-
for (const
|
|
3067
|
-
|
|
3068
|
-
return !1;
|
|
3109
|
+
if (a.length === 0)
|
|
3110
|
+
return await r(`${t.status} ${t.statusText}`), i(), !1;
|
|
3111
|
+
for (const o of a)
|
|
3112
|
+
o.key && e ? await y.addErrorMessage(e, o.key, o.message) : await r(o.message);
|
|
3113
|
+
return i(), !1;
|
|
3069
3114
|
} catch {
|
|
3070
3115
|
}
|
|
3071
3116
|
try {
|
|
@@ -3074,7 +3119,7 @@ ${h}
|
|
|
3074
3119
|
} catch {
|
|
3075
3120
|
await r(`${t.status} ${t.statusText}`);
|
|
3076
3121
|
}
|
|
3077
|
-
return !1;
|
|
3122
|
+
return i(), !1;
|
|
3078
3123
|
}
|
|
3079
3124
|
/**
|
|
3080
3125
|
* 対象のフラグメント以下の入力要素に対してバリデーションを実行します。
|
|
@@ -3086,21 +3131,34 @@ ${h}
|
|
|
3086
3131
|
validate(t) {
|
|
3087
3132
|
if (this.options.valid !== !0)
|
|
3088
3133
|
return !0;
|
|
3089
|
-
const e =
|
|
3090
|
-
|
|
3091
|
-
return r || e.focus(), t.getChildElementFragments().reverse().forEach((i) => {
|
|
3092
|
-
r &&= this.validate(i);
|
|
3093
|
-
}), r;
|
|
3134
|
+
const e = this.findFirstInvalid(t);
|
|
3135
|
+
return e === null ? !0 : (e.reportValidity(), e.focus(), this.options.scrollOnError && e.scrollIntoView({ behavior: "smooth", block: "nearest" }), !1);
|
|
3094
3136
|
}
|
|
3095
3137
|
/**
|
|
3096
|
-
*
|
|
3138
|
+
* 対象フラグメント以下で DOM 順の最上部にある invalid 要素を返します。
|
|
3139
|
+
* 副作用のない checkValidity のみを使用し、検出のみを行います。
|
|
3097
3140
|
*
|
|
3098
3141
|
* @param fragment 対象のフラグメント
|
|
3099
|
-
* @returns
|
|
3142
|
+
* @returns 最初の invalid 要素、なければ null
|
|
3100
3143
|
*/
|
|
3101
|
-
|
|
3144
|
+
findFirstInvalid(t) {
|
|
3145
|
+
let e = null;
|
|
3146
|
+
for (const r of t.getChildElementFragments().reverse()) {
|
|
3147
|
+
const i = this.findFirstInvalid(r);
|
|
3148
|
+
i !== null && (e = i);
|
|
3149
|
+
}
|
|
3150
|
+
return this.checkOne(t) ? e : t.getTarget();
|
|
3151
|
+
}
|
|
3152
|
+
/**
|
|
3153
|
+
* 対象のフラグメントに対して、副作用なく有効性を検査します。
|
|
3154
|
+
* reportValidity は使わず checkValidity のみ呼び出します。
|
|
3155
|
+
*
|
|
3156
|
+
* @param fragment 対象のフラグメント
|
|
3157
|
+
* @returns 有効なら true、無効なら false
|
|
3158
|
+
*/
|
|
3159
|
+
checkOne(t) {
|
|
3102
3160
|
const e = t.getTarget();
|
|
3103
|
-
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? e.
|
|
3161
|
+
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? e.checkValidity() : !0;
|
|
3104
3162
|
}
|
|
3105
3163
|
/**
|
|
3106
3164
|
* 確認メッセージを表示し、ユーザーの確認を求めます。
|
|
@@ -3120,40 +3178,40 @@ ${h}
|
|
|
3120
3178
|
bindResult(t) {
|
|
3121
3179
|
return !this.options.bindFragments || this.options.bindFragments.length === 0 ? Promise.resolve() : (t.headers.get("Content-Type")?.includes("application/json") ? t.json() : t.text()).then((r) => {
|
|
3122
3180
|
if (this.options.bindParams) {
|
|
3123
|
-
const
|
|
3124
|
-
this.options.bindParams.forEach((
|
|
3125
|
-
r && typeof r == "object" &&
|
|
3126
|
-
}), r =
|
|
3181
|
+
const n = {};
|
|
3182
|
+
this.options.bindParams.forEach((s) => {
|
|
3183
|
+
r && typeof r == "object" && s in r && (n[s] = r[s]);
|
|
3184
|
+
}), r = n;
|
|
3127
3185
|
}
|
|
3128
3186
|
const i = [];
|
|
3129
3187
|
if (this.options.bindArg)
|
|
3130
|
-
this.options.bindFragments.forEach((
|
|
3131
|
-
const
|
|
3188
|
+
this.options.bindFragments.forEach((n) => {
|
|
3189
|
+
const s = n.getBindingData(), a = this.options.bindArg;
|
|
3132
3190
|
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3133
|
-
const o =
|
|
3134
|
-
|
|
3135
|
-
|
|
3191
|
+
const o = s[a], h = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3192
|
+
s[a] = this.mergeAppendBindingData(
|
|
3193
|
+
n,
|
|
3136
3194
|
r,
|
|
3137
|
-
|
|
3195
|
+
h
|
|
3138
3196
|
);
|
|
3139
3197
|
} else
|
|
3140
|
-
|
|
3141
|
-
i.push(
|
|
3198
|
+
s[a] = r;
|
|
3199
|
+
i.push(P.setBindingData(n.getTarget(), s));
|
|
3142
3200
|
});
|
|
3143
3201
|
else {
|
|
3144
3202
|
if (typeof r == "string")
|
|
3145
|
-
return
|
|
3203
|
+
return d.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
3146
3204
|
new Error("string data cannot be bound without a bindArg.")
|
|
3147
3205
|
);
|
|
3148
|
-
this.options.bindFragments.forEach((
|
|
3149
|
-
const
|
|
3150
|
-
|
|
3206
|
+
this.options.bindFragments.forEach((n) => {
|
|
3207
|
+
const s = this.mergeAppendBindingData(
|
|
3208
|
+
n,
|
|
3151
3209
|
r
|
|
3152
3210
|
);
|
|
3153
3211
|
i.push(
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3212
|
+
P.setBindingData(
|
|
3213
|
+
n.getTarget(),
|
|
3214
|
+
s
|
|
3157
3215
|
)
|
|
3158
3216
|
);
|
|
3159
3217
|
});
|
|
@@ -3168,10 +3226,10 @@ ${h}
|
|
|
3168
3226
|
mergeAppendBindingData(t, e, r = t.getBindingData()) {
|
|
3169
3227
|
if (!this.options.bindAppendParams || this.options.bindAppendParams.length === 0)
|
|
3170
3228
|
return e;
|
|
3171
|
-
const i = { ...e },
|
|
3172
|
-
for (const
|
|
3173
|
-
const a = i[
|
|
3174
|
-
Array.isArray(o) && Array.isArray(a) && (i[
|
|
3229
|
+
const i = { ...e }, n = r;
|
|
3230
|
+
for (const s of this.options.bindAppendParams) {
|
|
3231
|
+
const a = i[s], o = n[s];
|
|
3232
|
+
Array.isArray(o) && Array.isArray(a) && (i[s] = o.concat(a));
|
|
3175
3233
|
}
|
|
3176
3234
|
return i;
|
|
3177
3235
|
}
|
|
@@ -3182,11 +3240,11 @@ ${h}
|
|
|
3182
3240
|
if (!this.options.copyFragments || this.options.copyFragments.length === 0)
|
|
3183
3241
|
return Promise.resolve();
|
|
3184
3242
|
const t = this.resolveCopySourceData(), e = this.pickCopyData(t), r = this.options.copyFragments.map((i) => {
|
|
3185
|
-
const
|
|
3243
|
+
const n = {
|
|
3186
3244
|
...i.getBindingData(),
|
|
3187
3245
|
...e
|
|
3188
3246
|
};
|
|
3189
|
-
return
|
|
3247
|
+
return P.setBindingData(i.getTarget(), n);
|
|
3190
3248
|
});
|
|
3191
3249
|
return Promise.all(r).then(() => {
|
|
3192
3250
|
});
|
|
@@ -3195,7 +3253,7 @@ ${h}
|
|
|
3195
3253
|
* copy のコピー元データを取得します。
|
|
3196
3254
|
*/
|
|
3197
3255
|
resolveCopySourceData() {
|
|
3198
|
-
return this.options.formFragment ?
|
|
3256
|
+
return this.options.formFragment ? y.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3199
3257
|
}
|
|
3200
3258
|
/**
|
|
3201
3259
|
* copy-params が指定されている場合は対象キーだけ抽出します。
|
|
@@ -3218,8 +3276,8 @@ ${h}
|
|
|
3218
3276
|
for (const r of this.options.adjustFragments) {
|
|
3219
3277
|
let i = r.getValue();
|
|
3220
3278
|
(i == null || i === "") && (i = "0");
|
|
3221
|
-
let
|
|
3222
|
-
isNaN(
|
|
3279
|
+
let n = Number(i);
|
|
3280
|
+
isNaN(n) && (n = 0), n += t, e.push(r.setValue(String(n)));
|
|
3223
3281
|
}
|
|
3224
3282
|
return Promise.all(e).then(() => {
|
|
3225
3283
|
});
|
|
@@ -3231,11 +3289,11 @@ ${h}
|
|
|
3231
3289
|
*/
|
|
3232
3290
|
getRowFragment() {
|
|
3233
3291
|
if (!this.options.targetFragment)
|
|
3234
|
-
return
|
|
3292
|
+
return d.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
3235
3293
|
const t = this.options.targetFragment.closestByAttribute(
|
|
3236
|
-
`${
|
|
3294
|
+
`${u.prefix}row`
|
|
3237
3295
|
);
|
|
3238
|
-
return t || (
|
|
3296
|
+
return t || (d.error("Haori", "Row fragment not found."), null);
|
|
3239
3297
|
}
|
|
3240
3298
|
/**
|
|
3241
3299
|
* 行を追加します。
|
|
@@ -3251,7 +3309,7 @@ ${h}
|
|
|
3251
3309
|
const e = [], r = t.clone();
|
|
3252
3310
|
return e.push(
|
|
3253
3311
|
t.getParent().insertAfter(r, t)
|
|
3254
|
-
), e.push(
|
|
3312
|
+
), e.push(P.evaluateAll(r)), e.push(y.reset(r)), Promise.all(e).then(() => {
|
|
3255
3313
|
});
|
|
3256
3314
|
}
|
|
3257
3315
|
/**
|
|
@@ -3266,7 +3324,7 @@ ${h}
|
|
|
3266
3324
|
if (!t)
|
|
3267
3325
|
return Promise.reject(new Error("Row fragment not found."));
|
|
3268
3326
|
const e = t.getParent();
|
|
3269
|
-
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
3327
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${u.prefix}each-before`) && !i.hasAttribute(`${u.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
3270
3328
|
}
|
|
3271
3329
|
/**
|
|
3272
3330
|
* 前の行へ移動します。
|
|
@@ -3303,9 +3361,9 @@ ${h}
|
|
|
3303
3361
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3304
3362
|
}
|
|
3305
3363
|
};
|
|
3306
|
-
|
|
3307
|
-
let V =
|
|
3308
|
-
class
|
|
3364
|
+
l.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, l.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
3365
|
+
let V = l;
|
|
3366
|
+
class ft {
|
|
3309
3367
|
/**
|
|
3310
3368
|
* URLのクエリパラメータを取得します。
|
|
3311
3369
|
*
|
|
@@ -3313,12 +3371,12 @@ class ut {
|
|
|
3313
3371
|
*/
|
|
3314
3372
|
static readParams() {
|
|
3315
3373
|
const t = {}, e = window.location.search;
|
|
3316
|
-
return new URLSearchParams(e).forEach((i,
|
|
3317
|
-
t[
|
|
3374
|
+
return new URLSearchParams(e).forEach((i, n) => {
|
|
3375
|
+
t[n] = i;
|
|
3318
3376
|
}), t;
|
|
3319
3377
|
}
|
|
3320
3378
|
}
|
|
3321
|
-
class
|
|
3379
|
+
class dt {
|
|
3322
3380
|
/**
|
|
3323
3381
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3324
3382
|
*
|
|
@@ -3335,24 +3393,24 @@ class ct {
|
|
|
3335
3393
|
let r;
|
|
3336
3394
|
try {
|
|
3337
3395
|
r = await fetch(t, e);
|
|
3338
|
-
} catch (
|
|
3339
|
-
throw
|
|
3396
|
+
} catch (n) {
|
|
3397
|
+
throw d.error("[Haori]", "Failed to fetch import source:", t, n), new Error(`Failed to fetch: ${t}`);
|
|
3340
3398
|
}
|
|
3341
3399
|
if (!r.ok) {
|
|
3342
|
-
const
|
|
3343
|
-
throw
|
|
3400
|
+
const n = `${r.status} ${r.statusText}`;
|
|
3401
|
+
throw d.error("[Haori]", "Import HTTP error:", t, n), new Error(`Failed to load ${t}: ${n}`);
|
|
3344
3402
|
}
|
|
3345
3403
|
let i;
|
|
3346
3404
|
try {
|
|
3347
3405
|
i = await r.text();
|
|
3348
|
-
} catch (
|
|
3349
|
-
throw
|
|
3406
|
+
} catch (n) {
|
|
3407
|
+
throw d.error("[Haori]", "Failed to read response text:", t, n), new Error(`Failed to read response from: ${t}`);
|
|
3350
3408
|
}
|
|
3351
3409
|
try {
|
|
3352
|
-
const
|
|
3353
|
-
return
|
|
3354
|
-
} catch (
|
|
3355
|
-
return
|
|
3410
|
+
const s = new DOMParser().parseFromString(i, "text/html");
|
|
3411
|
+
return s && s.body ? s.body.innerHTML : (d.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3412
|
+
} catch (n) {
|
|
3413
|
+
return d.error("[Haori]", "Failed to parse imported HTML:", t, n), i;
|
|
3356
3414
|
}
|
|
3357
3415
|
}
|
|
3358
3416
|
}
|
|
@@ -3365,7 +3423,7 @@ const p = class p {
|
|
|
3365
3423
|
*/
|
|
3366
3424
|
static isDeferredAttributeName(t) {
|
|
3367
3425
|
return p.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3368
|
-
(e) => t === `${
|
|
3426
|
+
(e) => t === `${u.prefix}${e}`
|
|
3369
3427
|
);
|
|
3370
3428
|
}
|
|
3371
3429
|
/**
|
|
@@ -3376,7 +3434,7 @@ const p = class p {
|
|
|
3376
3434
|
*/
|
|
3377
3435
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3378
3436
|
return p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3379
|
-
(e) => t === `${
|
|
3437
|
+
(e) => t === `${u.prefix}${e}`
|
|
3380
3438
|
);
|
|
3381
3439
|
}
|
|
3382
3440
|
/**
|
|
@@ -3396,7 +3454,7 @@ const p = class p {
|
|
|
3396
3454
|
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
3397
3455
|
*/
|
|
3398
3456
|
static getAliasedAttributeName(t) {
|
|
3399
|
-
const e = `${
|
|
3457
|
+
const e = `${u.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
3400
3458
|
return !t.startsWith(e) || t.length <= e.length ? null : t.slice(e.length);
|
|
3401
3459
|
}
|
|
3402
3460
|
/**
|
|
@@ -3408,8 +3466,8 @@ const p = class p {
|
|
|
3408
3466
|
*/
|
|
3409
3467
|
static isAliasedAttributeReflection(t, e) {
|
|
3410
3468
|
const r = T.get(t);
|
|
3411
|
-
return r instanceof
|
|
3412
|
-
`${
|
|
3469
|
+
return r instanceof x ? r.hasAttribute(
|
|
3470
|
+
`${u.prefix}${p.ATTRIBUTE_ALIAS_SUFFIX}${e}`
|
|
3413
3471
|
) : !1;
|
|
3414
3472
|
}
|
|
3415
3473
|
/**
|
|
@@ -3443,39 +3501,39 @@ const p = class p {
|
|
|
3443
3501
|
t.parentNode && (T.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3444
3502
|
let r = Promise.resolve();
|
|
3445
3503
|
const i = /* @__PURE__ */ new Set();
|
|
3446
|
-
for (const
|
|
3447
|
-
const
|
|
3448
|
-
e.hasAttribute(
|
|
3504
|
+
for (const n of p.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3505
|
+
const s = u.prefix + n;
|
|
3506
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3449
3507
|
() => p.setAttribute(
|
|
3450
3508
|
e.getTarget(),
|
|
3451
|
-
|
|
3452
|
-
e.getRawAttribute(
|
|
3509
|
+
s,
|
|
3510
|
+
e.getRawAttribute(s)
|
|
3453
3511
|
)
|
|
3454
|
-
), i.add(
|
|
3512
|
+
), i.add(s));
|
|
3455
3513
|
}
|
|
3456
|
-
for (const
|
|
3457
|
-
if (i.has(
|
|
3514
|
+
for (const n of e.getAttributeNames()) {
|
|
3515
|
+
if (i.has(n) || p.isDeferredAttributeName(n))
|
|
3458
3516
|
continue;
|
|
3459
|
-
const
|
|
3460
|
-
|
|
3461
|
-
() => p.setAttribute(e.getTarget(),
|
|
3517
|
+
const s = e.getRawAttribute(n);
|
|
3518
|
+
s !== null && (r = r.then(
|
|
3519
|
+
() => p.setAttribute(e.getTarget(), n, s)
|
|
3462
3520
|
));
|
|
3463
3521
|
}
|
|
3464
|
-
for (const
|
|
3465
|
-
const
|
|
3466
|
-
e.hasAttribute(
|
|
3522
|
+
for (const n of p.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3523
|
+
const s = u.prefix + n;
|
|
3524
|
+
e.hasAttribute(s) && (r = r.then(
|
|
3467
3525
|
() => p.setAttribute(
|
|
3468
3526
|
e.getTarget(),
|
|
3469
|
-
|
|
3470
|
-
e.getRawAttribute(
|
|
3527
|
+
s,
|
|
3528
|
+
e.getRawAttribute(s)
|
|
3471
3529
|
)
|
|
3472
|
-
), i.add(
|
|
3530
|
+
), i.add(s));
|
|
3473
3531
|
}
|
|
3474
3532
|
return r.then(() => {
|
|
3475
|
-
const
|
|
3476
|
-
return e.getChildren().forEach((
|
|
3477
|
-
|
|
3478
|
-
}), Promise.all(
|
|
3533
|
+
const n = [];
|
|
3534
|
+
return e.getChildren().forEach((s) => {
|
|
3535
|
+
s instanceof x ? n.push(p.scan(s.getTarget())) : s instanceof H && n.push(p.evaluateText(s));
|
|
3536
|
+
}), Promise.all(n).then(() => {
|
|
3479
3537
|
});
|
|
3480
3538
|
}).then(() => {
|
|
3481
3539
|
});
|
|
@@ -3490,57 +3548,57 @@ const p = class p {
|
|
|
3490
3548
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3491
3549
|
*/
|
|
3492
3550
|
static setAttribute(t, e, r) {
|
|
3493
|
-
const i = T.get(t),
|
|
3494
|
-
if (
|
|
3495
|
-
return r === null ? i.removeAliasedAttribute(e,
|
|
3496
|
-
const
|
|
3551
|
+
const i = T.get(t), n = p.getAliasedAttributeName(e);
|
|
3552
|
+
if (n !== null)
|
|
3553
|
+
return r === null ? i.removeAliasedAttribute(e, n) : i.setAliasedAttribute(e, n, r);
|
|
3554
|
+
const s = [];
|
|
3497
3555
|
switch (e) {
|
|
3498
|
-
case `${
|
|
3556
|
+
case `${u.prefix}bind`: {
|
|
3499
3557
|
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(p.parseDataBind(r));
|
|
3500
3558
|
break;
|
|
3501
3559
|
}
|
|
3502
|
-
case `${
|
|
3503
|
-
|
|
3560
|
+
case `${u.prefix}if`:
|
|
3561
|
+
s.push(p.evaluateIf(i));
|
|
3504
3562
|
break;
|
|
3505
|
-
case `${
|
|
3506
|
-
|
|
3563
|
+
case `${u.prefix}each`:
|
|
3564
|
+
s.push(p.evaluateEach(i));
|
|
3507
3565
|
break;
|
|
3508
|
-
case `${
|
|
3509
|
-
|
|
3566
|
+
case `${u.prefix}fetch`:
|
|
3567
|
+
s.push(
|
|
3510
3568
|
new V(i, null).run().then(() => {
|
|
3511
3569
|
})
|
|
3512
3570
|
);
|
|
3513
3571
|
break;
|
|
3514
|
-
case `${
|
|
3572
|
+
case `${u.prefix}import`: {
|
|
3515
3573
|
if (typeof r == "string") {
|
|
3516
3574
|
const a = i.getTarget(), o = performance.now();
|
|
3517
|
-
w.importStart(a, r),
|
|
3518
|
-
|
|
3519
|
-
const m = new TextEncoder().encode(
|
|
3520
|
-
return
|
|
3521
|
-
a.innerHTML =
|
|
3575
|
+
w.importStart(a, r), s.push(
|
|
3576
|
+
dt.load(r).then((h) => {
|
|
3577
|
+
const m = new TextEncoder().encode(h).length;
|
|
3578
|
+
return R.enqueue(() => {
|
|
3579
|
+
a.innerHTML = h;
|
|
3522
3580
|
}).then(() => {
|
|
3523
3581
|
w.importEnd(a, r, m, o);
|
|
3524
3582
|
});
|
|
3525
|
-
}).catch((
|
|
3526
|
-
w.importError(a, r,
|
|
3583
|
+
}).catch((h) => {
|
|
3584
|
+
w.importError(a, r, h), d.error("[Haori]", "Failed to import HTML:", r, h);
|
|
3527
3585
|
})
|
|
3528
3586
|
);
|
|
3529
3587
|
}
|
|
3530
3588
|
break;
|
|
3531
3589
|
}
|
|
3532
|
-
case `${
|
|
3533
|
-
const a = i.getAttribute(`${
|
|
3590
|
+
case `${u.prefix}url-param`: {
|
|
3591
|
+
const a = i.getAttribute(`${u.prefix}url-arg`), o = ft.readParams();
|
|
3534
3592
|
if (a === null)
|
|
3535
|
-
|
|
3593
|
+
s.push(p.setBindingData(t, o));
|
|
3536
3594
|
else {
|
|
3537
|
-
const
|
|
3538
|
-
|
|
3595
|
+
const h = i.getRawBindingData() || {};
|
|
3596
|
+
h[String(a)] = o, s.push(p.setBindingData(t, h));
|
|
3539
3597
|
}
|
|
3540
3598
|
break;
|
|
3541
3599
|
}
|
|
3542
3600
|
}
|
|
3543
|
-
return r === null ?
|
|
3601
|
+
return r === null ? s.push(i.removeAttribute(e)) : s.push(i.setAttribute(e, r)), Promise.all(s).then(() => {
|
|
3544
3602
|
});
|
|
3545
3603
|
}
|
|
3546
3604
|
/**
|
|
@@ -3554,15 +3612,15 @@ const p = class p {
|
|
|
3554
3612
|
static setBindingData(t, e) {
|
|
3555
3613
|
const r = T.get(t), i = r.getRawBindingData();
|
|
3556
3614
|
r.setBindingData(e);
|
|
3557
|
-
let
|
|
3558
|
-
`${
|
|
3615
|
+
let n = r.setAttribute(
|
|
3616
|
+
`${u.prefix}bind`,
|
|
3559
3617
|
JSON.stringify(e)
|
|
3560
3618
|
);
|
|
3561
3619
|
if (t.tagName === "FORM") {
|
|
3562
|
-
const
|
|
3563
|
-
|
|
3620
|
+
const s = r.getAttribute(`${u.prefix}form-arg`), a = s && e[String(s)] && typeof e[String(s)] == "object" && !Array.isArray(e[String(s)]) ? e[String(s)] : s ? {} : e;
|
|
3621
|
+
n = n.then(() => y.syncValues(r, a));
|
|
3564
3622
|
}
|
|
3565
|
-
return
|
|
3623
|
+
return n = n.then(() => p.evaluateAll(r)), w.bindChange(t, i, e, "manual"), n.then(() => {
|
|
3566
3624
|
});
|
|
3567
3625
|
}
|
|
3568
3626
|
/**
|
|
@@ -3576,12 +3634,12 @@ const p = class p {
|
|
|
3576
3634
|
try {
|
|
3577
3635
|
return JSON.parse(t);
|
|
3578
3636
|
} catch (e) {
|
|
3579
|
-
return
|
|
3637
|
+
return d.error("[Haori]", "Invalid JSON in data-bind:", e), {};
|
|
3580
3638
|
}
|
|
3581
3639
|
else {
|
|
3582
3640
|
const e = new URLSearchParams(t), r = {};
|
|
3583
|
-
for (const [i,
|
|
3584
|
-
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(
|
|
3641
|
+
for (const [i, n] of e.entries())
|
|
3642
|
+
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(n) : r[i] = [r[i], n] : r[i] = n;
|
|
3585
3643
|
return r;
|
|
3586
3644
|
}
|
|
3587
3645
|
}
|
|
@@ -3595,8 +3653,8 @@ const p = class p {
|
|
|
3595
3653
|
const r = T.get(t);
|
|
3596
3654
|
if (r.isSkipMutationNodes())
|
|
3597
3655
|
return;
|
|
3598
|
-
const i = T.get(e.nextSibling),
|
|
3599
|
-
|
|
3656
|
+
const i = T.get(e.nextSibling), n = T.get(e);
|
|
3657
|
+
n && (r.insertBefore(n, i), n instanceof x ? p.scan(n.getTarget()) : n instanceof H && p.evaluateText(n));
|
|
3600
3658
|
}
|
|
3601
3659
|
/**
|
|
3602
3660
|
* ノードを親要素から削除します。
|
|
@@ -3636,11 +3694,11 @@ const p = class p {
|
|
|
3636
3694
|
return Promise.resolve();
|
|
3637
3695
|
const i = [];
|
|
3638
3696
|
i.push(r.setValue(e));
|
|
3639
|
-
const
|
|
3640
|
-
if (
|
|
3641
|
-
const
|
|
3697
|
+
const n = p.getFormFragment(r);
|
|
3698
|
+
if (n) {
|
|
3699
|
+
const s = y.getValues(n), a = n.getAttribute(`${u.prefix}form-arg`);
|
|
3642
3700
|
let o;
|
|
3643
|
-
a ? (o =
|
|
3701
|
+
a ? (o = n.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, i.push(p.setBindingData(n.getTarget(), o));
|
|
3644
3702
|
}
|
|
3645
3703
|
return Promise.all(i).then(() => {
|
|
3646
3704
|
});
|
|
@@ -3665,14 +3723,14 @@ const p = class p {
|
|
|
3665
3723
|
*/
|
|
3666
3724
|
static evaluateAll(t) {
|
|
3667
3725
|
const e = [];
|
|
3668
|
-
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${
|
|
3726
|
+
return e.push(p.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${u.prefix}if`) && e.push(p.evaluateIf(t)), t.hasAttribute(`${u.prefix}each`) ? Promise.all(e).then(() => p.evaluateEach(t)).then(() => {
|
|
3669
3727
|
const r = [];
|
|
3670
3728
|
return t.getChildren().forEach((i) => {
|
|
3671
|
-
i instanceof
|
|
3729
|
+
i instanceof x ? r.push(p.evaluateAll(i)) : i instanceof H && r.push(p.evaluateText(i));
|
|
3672
3730
|
}), Promise.all(r).then(() => {
|
|
3673
3731
|
});
|
|
3674
3732
|
}) : (t.getChildren().forEach((r) => {
|
|
3675
|
-
r instanceof
|
|
3733
|
+
r instanceof x ? e.push(p.evaluateAll(r)) : r instanceof H && e.push(p.evaluateText(r));
|
|
3676
3734
|
}), Promise.all(e).then(() => {
|
|
3677
3735
|
}));
|
|
3678
3736
|
}
|
|
@@ -3693,7 +3751,7 @@ const p = class p {
|
|
|
3693
3751
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3694
3752
|
*/
|
|
3695
3753
|
static evaluateIf(t) {
|
|
3696
|
-
const e = [], r = t.getAttribute(`${
|
|
3754
|
+
const e = [], r = t.getAttribute(`${u.prefix}if`);
|
|
3697
3755
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3698
3756
|
t.hide().then(() => {
|
|
3699
3757
|
w.hide(t.getTarget());
|
|
@@ -3717,20 +3775,20 @@ const p = class p {
|
|
|
3717
3775
|
let e = t.getTemplate();
|
|
3718
3776
|
if (e === null) {
|
|
3719
3777
|
let i = !1;
|
|
3720
|
-
t.getChildren().forEach((
|
|
3721
|
-
if (!i &&
|
|
3722
|
-
if (
|
|
3778
|
+
t.getChildren().forEach((s) => {
|
|
3779
|
+
if (!i && s instanceof x) {
|
|
3780
|
+
if (s.hasAttribute(`${u.prefix}each-before`) || s.hasAttribute(`${u.prefix}each-after`))
|
|
3723
3781
|
return;
|
|
3724
|
-
e =
|
|
3725
|
-
const a =
|
|
3726
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3782
|
+
e = s.clone(), t.setTemplate(e), i = !0, t.removeChild(s);
|
|
3783
|
+
const a = s.getTarget();
|
|
3784
|
+
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3727
3785
|
}
|
|
3728
3786
|
});
|
|
3729
|
-
const
|
|
3730
|
-
return Array.isArray(
|
|
3787
|
+
const n = t.getAttribute(`${u.prefix}each`);
|
|
3788
|
+
return Array.isArray(n) ? this.updateDiff(t, n) : (d.error("[Haori]", "Invalid each attribute:", n), Promise.reject(new Error("Invalid each attribute.")));
|
|
3731
3789
|
}
|
|
3732
|
-
const r = t.getAttribute(`${
|
|
3733
|
-
return Array.isArray(r) ? this.updateDiff(t, r) : (
|
|
3790
|
+
const r = t.getAttribute(`${u.prefix}each`);
|
|
3791
|
+
return Array.isArray(r) ? this.updateDiff(t, r) : (d.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3734
3792
|
}
|
|
3735
3793
|
/**
|
|
3736
3794
|
* 差分を更新します。
|
|
@@ -3741,27 +3799,27 @@ const p = class p {
|
|
|
3741
3799
|
static updateDiff(t, e) {
|
|
3742
3800
|
const r = t.getTemplate();
|
|
3743
3801
|
if (r === null)
|
|
3744
|
-
return
|
|
3745
|
-
let i = t.getAttribute(`${
|
|
3802
|
+
return d.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3803
|
+
let i = t.getAttribute(`${u.prefix}each-index`);
|
|
3746
3804
|
i && (i = String(i));
|
|
3747
|
-
const
|
|
3748
|
-
e.forEach((
|
|
3805
|
+
const n = t.getAttribute(`${u.prefix}each-key`), s = t.getAttribute(`${u.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3806
|
+
e.forEach((c, f) => {
|
|
3749
3807
|
const g = p.createListKey(
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3808
|
+
c,
|
|
3809
|
+
n ? String(n) : null,
|
|
3810
|
+
f
|
|
3753
3811
|
);
|
|
3754
|
-
o.push(g), a.set(g, { item:
|
|
3812
|
+
o.push(g), a.set(g, { item: c, itemIndex: f });
|
|
3755
3813
|
});
|
|
3756
|
-
const
|
|
3757
|
-
let m = t.getChildren().filter((
|
|
3758
|
-
(
|
|
3814
|
+
const h = [];
|
|
3815
|
+
let m = t.getChildren().filter((c) => c instanceof x).filter(
|
|
3816
|
+
(c) => !c.hasAttribute(`${u.prefix}each-before`) && !c.hasAttribute(`${u.prefix}each-after`)
|
|
3759
3817
|
);
|
|
3760
|
-
m = m.filter((
|
|
3761
|
-
const
|
|
3818
|
+
m = m.filter((c) => o.indexOf(String(c.getListKey())) === -1 ? (h.push(c.remove()), !1) : !0);
|
|
3819
|
+
const b = m.map((c) => c.getListKey()), E = t.getChildren().filter((c) => c instanceof x).filter((c) => c.hasAttribute(`${u.prefix}each-before`)).length;
|
|
3762
3820
|
let S = Promise.resolve();
|
|
3763
|
-
return o.forEach((
|
|
3764
|
-
const g =
|
|
3821
|
+
return o.forEach((c, f) => {
|
|
3822
|
+
const g = b.indexOf(c), { item: A, itemIndex: v } = a.get(c);
|
|
3765
3823
|
let k;
|
|
3766
3824
|
if (g !== -1)
|
|
3767
3825
|
k = m[g], S = S.then(
|
|
@@ -3770,21 +3828,21 @@ const p = class p {
|
|
|
3770
3828
|
A,
|
|
3771
3829
|
i,
|
|
3772
3830
|
v,
|
|
3773
|
-
|
|
3774
|
-
|
|
3831
|
+
s ? String(s) : null,
|
|
3832
|
+
c
|
|
3775
3833
|
).then(() => p.evaluateAll(k))
|
|
3776
3834
|
);
|
|
3777
3835
|
else {
|
|
3778
3836
|
k = r.clone();
|
|
3779
|
-
const J = E +
|
|
3837
|
+
const J = E + f;
|
|
3780
3838
|
S = S.then(
|
|
3781
3839
|
() => p.updateRowFragment(
|
|
3782
3840
|
k,
|
|
3783
3841
|
A,
|
|
3784
3842
|
i,
|
|
3785
3843
|
v,
|
|
3786
|
-
|
|
3787
|
-
|
|
3844
|
+
s ? String(s) : null,
|
|
3845
|
+
c
|
|
3788
3846
|
).then(
|
|
3789
3847
|
() => t.insertBefore(
|
|
3790
3848
|
k,
|
|
@@ -3793,21 +3851,21 @@ const p = class p {
|
|
|
3793
3851
|
)
|
|
3794
3852
|
);
|
|
3795
3853
|
}
|
|
3796
|
-
}), Promise.all(
|
|
3797
|
-
const
|
|
3854
|
+
}), Promise.all(h).then(() => S).then(() => {
|
|
3855
|
+
const c = o.filter(
|
|
3798
3856
|
(v) => v !== null
|
|
3799
|
-
),
|
|
3857
|
+
), f = b.filter(
|
|
3800
3858
|
(v) => v !== null
|
|
3801
|
-
), g =
|
|
3802
|
-
(v) => !
|
|
3803
|
-
), A =
|
|
3804
|
-
(v) => !
|
|
3859
|
+
), g = c.filter(
|
|
3860
|
+
(v) => !f.includes(v)
|
|
3861
|
+
), A = f.filter(
|
|
3862
|
+
(v) => !c.includes(v)
|
|
3805
3863
|
);
|
|
3806
3864
|
w.eachUpdate(
|
|
3807
3865
|
t.getTarget(),
|
|
3808
3866
|
g,
|
|
3809
3867
|
A,
|
|
3810
|
-
|
|
3868
|
+
c
|
|
3811
3869
|
);
|
|
3812
3870
|
});
|
|
3813
3871
|
}
|
|
@@ -3823,8 +3881,8 @@ const p = class p {
|
|
|
3823
3881
|
let i;
|
|
3824
3882
|
if (typeof t == "object" && t !== null)
|
|
3825
3883
|
if (e) {
|
|
3826
|
-
const
|
|
3827
|
-
|
|
3884
|
+
const n = t[e];
|
|
3885
|
+
n == null ? i = `__index_${r}` : typeof n == "object" ? i = JSON.stringify(n) : i = String(n);
|
|
3828
3886
|
} else
|
|
3829
3887
|
i = `__index_${r}`;
|
|
3830
3888
|
else
|
|
@@ -3842,22 +3900,22 @@ const p = class p {
|
|
|
3842
3900
|
* @param listKey リストキー
|
|
3843
3901
|
* @returns 行メタデータの更新完了 Promise
|
|
3844
3902
|
*/
|
|
3845
|
-
static updateRowFragment(t, e, r, i,
|
|
3903
|
+
static updateRowFragment(t, e, r, i, n, s) {
|
|
3846
3904
|
let a = e;
|
|
3847
3905
|
if (typeof e == "object" && e !== null)
|
|
3848
|
-
a = { ...e }, r && (a[r] = i),
|
|
3849
|
-
[
|
|
3906
|
+
a = { ...e }, r && (a[r] = i), n && (a = {
|
|
3907
|
+
[n]: a
|
|
3850
3908
|
});
|
|
3851
|
-
else if (
|
|
3909
|
+
else if (n)
|
|
3852
3910
|
a = {
|
|
3853
|
-
[
|
|
3911
|
+
[n]: e
|
|
3854
3912
|
}, r && (a[r] = i);
|
|
3855
3913
|
else
|
|
3856
|
-
return
|
|
3914
|
+
return d.error(
|
|
3857
3915
|
"[Haori]",
|
|
3858
|
-
`Primitive value requires '${
|
|
3916
|
+
`Primitive value requires '${u.prefix}each-arg' attribute: ${e}`
|
|
3859
3917
|
), Promise.resolve();
|
|
3860
|
-
return t.setListKey(
|
|
3918
|
+
return t.setListKey(s), t.setBindingData(a), t.setAttribute(`${u.prefix}row`, s);
|
|
3861
3919
|
}
|
|
3862
3920
|
};
|
|
3863
3921
|
p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], p.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], p.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
@@ -3868,8 +3926,8 @@ p.ATTRIBUTE_ALIAS_SUFFIX = "attr-", p.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if
|
|
|
3868
3926
|
"import",
|
|
3869
3927
|
"url-param"
|
|
3870
3928
|
], p.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3871
|
-
let
|
|
3872
|
-
class
|
|
3929
|
+
let P = p;
|
|
3930
|
+
const Y = class Y {
|
|
3873
3931
|
/**
|
|
3874
3932
|
* コンストラクタ。
|
|
3875
3933
|
*
|
|
@@ -3879,20 +3937,23 @@ class ht {
|
|
|
3879
3937
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
3880
3938
|
const e = document.documentElement, r = T.get(e);
|
|
3881
3939
|
r && new V(r, "load").run();
|
|
3940
|
+
}, this.onPopstate = (e) => {
|
|
3941
|
+
const r = e.state;
|
|
3942
|
+
!r || r[Y.HISTORY_STATE_KEY] !== !0 || location.reload();
|
|
3882
3943
|
}, this.root = t;
|
|
3883
3944
|
}
|
|
3884
3945
|
/**
|
|
3885
3946
|
* イベントリスナーの登録を開始します。
|
|
3886
|
-
*
|
|
3947
|
+
* クリック、変更、ロード、popstate イベントを監視し、対応するProcedureを実行します。
|
|
3887
3948
|
*/
|
|
3888
3949
|
start() {
|
|
3889
|
-
this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 });
|
|
3950
|
+
this.root.addEventListener("click", this.onClick), this.root.addEventListener("change", this.onChange), this.root.addEventListener("load", this.onLoadCapture, !0), window.addEventListener("load", this.onWindowLoad, { once: !0 }), window.addEventListener("popstate", this.onPopstate);
|
|
3890
3951
|
}
|
|
3891
3952
|
/**
|
|
3892
3953
|
* イベントリスナーの登録を停止します。
|
|
3893
3954
|
*/
|
|
3894
3955
|
stop() {
|
|
3895
|
-
this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad);
|
|
3956
|
+
this.root.removeEventListener("click", this.onClick), this.root.removeEventListener("change", this.onChange), this.root.removeEventListener("load", this.onLoadCapture, !0), window.removeEventListener("load", this.onWindowLoad), window.removeEventListener("popstate", this.onPopstate);
|
|
3896
3957
|
}
|
|
3897
3958
|
/**
|
|
3898
3959
|
* イベントを処理し、対応するProcedureを実行します。
|
|
@@ -3905,8 +3966,8 @@ class ht {
|
|
|
3905
3966
|
if (!r)
|
|
3906
3967
|
return;
|
|
3907
3968
|
const i = T.get(r);
|
|
3908
|
-
i && (e === "change" && i instanceof
|
|
3909
|
-
|
|
3969
|
+
i && (e === "change" && i instanceof x && i.syncValue(), new V(i, e).run().catch((n) => {
|
|
3970
|
+
d.error("[Haori]", "Procedure execution error:", n);
|
|
3910
3971
|
}));
|
|
3911
3972
|
}
|
|
3912
3973
|
/**
|
|
@@ -3918,7 +3979,9 @@ class ht {
|
|
|
3918
3979
|
getElementFromTarget(t) {
|
|
3919
3980
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3920
3981
|
}
|
|
3921
|
-
}
|
|
3982
|
+
};
|
|
3983
|
+
Y.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
3984
|
+
let Q = Y;
|
|
3922
3985
|
const N = class N {
|
|
3923
3986
|
static syncTree(t) {
|
|
3924
3987
|
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && N.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
@@ -3933,23 +3996,23 @@ const N = class N {
|
|
|
3933
3996
|
}
|
|
3934
3997
|
if (typeof IntersectionObserver > "u")
|
|
3935
3998
|
return;
|
|
3936
|
-
const i = N.resolveRoot(r),
|
|
3937
|
-
if (e && e.observer.root === i && e.observer.rootMargin ===
|
|
3999
|
+
const i = N.resolveRoot(r), n = N.resolveRootMargin(r), s = N.resolveThreshold(r), a = r.hasAttribute(`${u.prefix}intersect-once`);
|
|
4000
|
+
if (e && e.observer.root === i && e.observer.rootMargin === n && N.sameThreshold(
|
|
3938
4001
|
e.observer.thresholds,
|
|
3939
|
-
|
|
4002
|
+
s
|
|
3940
4003
|
) && e.once === a) {
|
|
3941
4004
|
e.fragment = r;
|
|
3942
4005
|
return;
|
|
3943
4006
|
}
|
|
3944
4007
|
e && (e.observer.disconnect(), N.registrations.delete(t));
|
|
3945
4008
|
const o = new IntersectionObserver(
|
|
3946
|
-
(
|
|
4009
|
+
(h) => {
|
|
3947
4010
|
const m = N.registrations.get(t);
|
|
3948
|
-
m &&
|
|
3949
|
-
!
|
|
4011
|
+
m && h.forEach((b) => {
|
|
4012
|
+
!b.isIntersecting || m.running || N.isDisabled(m.fragment) || (m.running = !0, new V(m.fragment, "intersect").runWithResult().then((E) => {
|
|
3950
4013
|
E && m.once && (m.observer.disconnect(), N.registrations.delete(t));
|
|
3951
4014
|
}).catch((E) => {
|
|
3952
|
-
|
|
4015
|
+
d.error(
|
|
3953
4016
|
"[Haori]",
|
|
3954
4017
|
"Intersect procedure execution error:",
|
|
3955
4018
|
E
|
|
@@ -3962,8 +4025,8 @@ const N = class N {
|
|
|
3962
4025
|
},
|
|
3963
4026
|
{
|
|
3964
4027
|
root: i,
|
|
3965
|
-
rootMargin:
|
|
3966
|
-
threshold:
|
|
4028
|
+
rootMargin: n,
|
|
4029
|
+
threshold: s
|
|
3967
4030
|
}
|
|
3968
4031
|
);
|
|
3969
4032
|
o.observe(t), N.registrations.set(t, {
|
|
@@ -3990,32 +4053,32 @@ const N = class N {
|
|
|
3990
4053
|
}
|
|
3991
4054
|
static shouldObserve(t) {
|
|
3992
4055
|
return t.getAttributeNames().some((e) => {
|
|
3993
|
-
if (!e.startsWith(`${
|
|
4056
|
+
if (!e.startsWith(`${u.prefix}intersect-`))
|
|
3994
4057
|
return !1;
|
|
3995
|
-
const r = e.slice(`${
|
|
4058
|
+
const r = e.slice(`${u.prefix}intersect-`.length);
|
|
3996
4059
|
return !N.CONFIG_KEYS.has(r);
|
|
3997
4060
|
});
|
|
3998
4061
|
}
|
|
3999
4062
|
static resolveRoot(t) {
|
|
4000
|
-
const e = `${
|
|
4063
|
+
const e = `${u.prefix}intersect-root`;
|
|
4001
4064
|
if (!t.hasAttribute(e))
|
|
4002
4065
|
return null;
|
|
4003
4066
|
const r = t.getAttribute(e);
|
|
4004
4067
|
if (typeof r != "string" || r.trim() === "")
|
|
4005
4068
|
return null;
|
|
4006
4069
|
const i = document.querySelector(r);
|
|
4007
|
-
return i instanceof HTMLElement ? i : (
|
|
4070
|
+
return i instanceof HTMLElement ? i : (d.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
4008
4071
|
}
|
|
4009
4072
|
static resolveRootMargin(t) {
|
|
4010
|
-
const e = `${
|
|
4073
|
+
const e = `${u.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
4011
4074
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
4012
4075
|
}
|
|
4013
4076
|
static resolveThreshold(t) {
|
|
4014
|
-
const e = `${
|
|
4077
|
+
const e = `${u.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
4015
4078
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
4016
4079
|
}
|
|
4017
4080
|
static isDisabled(t) {
|
|
4018
|
-
const e = `${
|
|
4081
|
+
const e = `${u.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
4019
4082
|
if (r === null || r === !1)
|
|
4020
4083
|
return !1;
|
|
4021
4084
|
if (typeof r == "boolean")
|
|
@@ -4034,21 +4097,21 @@ N.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
4034
4097
|
"disabled",
|
|
4035
4098
|
"once"
|
|
4036
4099
|
]), N.registrations = /* @__PURE__ */ new Map();
|
|
4037
|
-
let
|
|
4038
|
-
const
|
|
4100
|
+
let $ = N;
|
|
4101
|
+
const C = class C {
|
|
4039
4102
|
/**
|
|
4040
4103
|
* 初期化メソッド。
|
|
4041
4104
|
* ドキュメントのheadとbodyを監視対象として設定します。
|
|
4042
4105
|
*/
|
|
4043
4106
|
static async init() {
|
|
4044
|
-
if (
|
|
4107
|
+
if (C._initialized)
|
|
4045
4108
|
return;
|
|
4046
|
-
|
|
4109
|
+
C._initialized = !0;
|
|
4047
4110
|
const t = await Promise.allSettled([
|
|
4048
|
-
|
|
4049
|
-
|
|
4111
|
+
P.scan(document.head),
|
|
4112
|
+
P.scan(document.body)
|
|
4050
4113
|
]), [e, r] = t;
|
|
4051
|
-
e.status !== "fulfilled" &&
|
|
4114
|
+
e.status !== "fulfilled" && d.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && d.error("[Haori]", "Failed to build body fragment:", r.reason), C.observe(document.head), C.observe(document.body), new Q().start(), $.syncTree(document.body);
|
|
4052
4115
|
}
|
|
4053
4116
|
/**
|
|
4054
4117
|
* 指定された要素を監視します。
|
|
@@ -4061,45 +4124,45 @@ const I = class I {
|
|
|
4061
4124
|
try {
|
|
4062
4125
|
switch (i.type) {
|
|
4063
4126
|
case "attributes": {
|
|
4064
|
-
|
|
4127
|
+
d.info(
|
|
4065
4128
|
"[Haori]",
|
|
4066
4129
|
"Attribute changed:",
|
|
4067
4130
|
i.target,
|
|
4068
4131
|
i.attributeName
|
|
4069
4132
|
);
|
|
4070
|
-
const
|
|
4071
|
-
if (i.attributeName &&
|
|
4072
|
-
|
|
4133
|
+
const n = i.target;
|
|
4134
|
+
if (i.attributeName && P.isAliasedAttributeReflection(
|
|
4135
|
+
n,
|
|
4073
4136
|
i.attributeName
|
|
4074
4137
|
))
|
|
4075
4138
|
break;
|
|
4076
|
-
|
|
4077
|
-
|
|
4139
|
+
P.setAttribute(
|
|
4140
|
+
n,
|
|
4078
4141
|
i.attributeName,
|
|
4079
|
-
|
|
4080
|
-
),
|
|
4142
|
+
n.getAttribute(i.attributeName)
|
|
4143
|
+
), $.syncElement(n);
|
|
4081
4144
|
break;
|
|
4082
4145
|
}
|
|
4083
4146
|
case "childList": {
|
|
4084
|
-
|
|
4147
|
+
d.info(
|
|
4085
4148
|
"[Haori]",
|
|
4086
4149
|
"Child list changed:",
|
|
4087
|
-
Array.from(i.removedNodes).map((
|
|
4088
|
-
Array.from(i.addedNodes).map((
|
|
4089
|
-
), Array.from(i.removedNodes).forEach((
|
|
4090
|
-
|
|
4091
|
-
}), Array.from(i.addedNodes).forEach((
|
|
4092
|
-
|
|
4150
|
+
Array.from(i.removedNodes).map((n) => n.nodeName),
|
|
4151
|
+
Array.from(i.addedNodes).map((n) => n.nodeName)
|
|
4152
|
+
), Array.from(i.removedNodes).forEach((n) => {
|
|
4153
|
+
$.cleanupTree(n), P.removeNode(n);
|
|
4154
|
+
}), Array.from(i.addedNodes).forEach((n) => {
|
|
4155
|
+
n.parentElement instanceof HTMLElement && (P.addNode(n.parentElement, n), $.syncTree(n));
|
|
4093
4156
|
});
|
|
4094
4157
|
break;
|
|
4095
4158
|
}
|
|
4096
4159
|
case "characterData": {
|
|
4097
|
-
|
|
4160
|
+
d.info(
|
|
4098
4161
|
"[Haori]",
|
|
4099
4162
|
"Character data changed:",
|
|
4100
4163
|
i.target,
|
|
4101
4164
|
i.target.textContent
|
|
4102
|
-
), i.target instanceof Text || i.target instanceof Comment ?
|
|
4165
|
+
), i.target instanceof Text || i.target instanceof Comment ? P.changeText(i.target, i.target.textContent) : d.warn(
|
|
4103
4166
|
"[Haori]",
|
|
4104
4167
|
"Unsupported character data type:",
|
|
4105
4168
|
i.target
|
|
@@ -4107,33 +4170,33 @@ const I = class I {
|
|
|
4107
4170
|
break;
|
|
4108
4171
|
}
|
|
4109
4172
|
default:
|
|
4110
|
-
|
|
4173
|
+
d.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
4111
4174
|
continue;
|
|
4112
4175
|
}
|
|
4113
|
-
} catch (
|
|
4114
|
-
|
|
4176
|
+
} catch (n) {
|
|
4177
|
+
d.error("[Haori]", "Error processing mutation:", n);
|
|
4115
4178
|
}
|
|
4116
4179
|
}).observe(t, {
|
|
4117
4180
|
childList: !0,
|
|
4118
4181
|
subtree: !0,
|
|
4119
4182
|
attributes: !0,
|
|
4120
4183
|
characterData: !0
|
|
4121
|
-
}),
|
|
4184
|
+
}), d.info("[Haori]", "Observer initialized for", t);
|
|
4122
4185
|
}
|
|
4123
4186
|
};
|
|
4124
|
-
|
|
4125
|
-
let q =
|
|
4187
|
+
C._initialized = !1;
|
|
4188
|
+
let q = C;
|
|
4126
4189
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", q.init) : q.init();
|
|
4127
|
-
const
|
|
4190
|
+
const pt = "0.4.6";
|
|
4128
4191
|
export {
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4192
|
+
P as Core,
|
|
4193
|
+
u as Env,
|
|
4194
|
+
y as Form,
|
|
4132
4195
|
T as Fragment,
|
|
4133
4196
|
X as Haori,
|
|
4134
|
-
|
|
4135
|
-
|
|
4197
|
+
d as Log,
|
|
4198
|
+
R as Queue,
|
|
4136
4199
|
X as default,
|
|
4137
|
-
|
|
4200
|
+
pt as version
|
|
4138
4201
|
};
|
|
4139
4202
|
//# sourceMappingURL=haori.es.js.map
|