haori 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/haori.cjs.js +10 -10
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +709 -600
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +7 -7
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/package.json +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/procedure.d.ts +50 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +129 -4
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/procedure-fetch-options.test.js +58 -0
- package/dist/tests/procedure-fetch-options.test.js.map +1 -1
- package/dist/tests/procedure_events.test.d.ts.map +1 -1
- package/dist/tests/procedure_events.test.js +65 -0
- package/dist/tests/procedure_events.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const R = class R {
|
|
2
2
|
/**
|
|
3
3
|
* 開発モードの状態を取得します。
|
|
4
4
|
*
|
|
5
5
|
* @returns 開発モードならtrue、そうでなければfalse
|
|
6
6
|
*/
|
|
7
7
|
static isEnabled() {
|
|
8
|
-
return
|
|
8
|
+
return R.devMode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 開発モードを有効化します。
|
|
12
12
|
*/
|
|
13
13
|
static enable() {
|
|
14
|
-
|
|
14
|
+
R.devMode = !0;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 開発モードを無効化します。
|
|
18
18
|
*/
|
|
19
19
|
static disable() {
|
|
20
|
-
|
|
20
|
+
R.devMode = !1;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 開発モードを切り替えます。
|
|
@@ -25,12 +25,12 @@ const k = class k {
|
|
|
25
25
|
* @param enabled trueで有効化、falseで無効化
|
|
26
26
|
*/
|
|
27
27
|
static set(t) {
|
|
28
|
-
|
|
28
|
+
R.devMode = t;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
let O =
|
|
33
|
-
const
|
|
31
|
+
R.devMode = !1;
|
|
32
|
+
let O = R;
|
|
33
|
+
const M = class M {
|
|
34
34
|
/**
|
|
35
35
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
36
36
|
* scriptタグにdata-prefixがある場合は、その値+"-"をプレフィックスとして使用します。
|
|
@@ -41,10 +41,10 @@ const D = class D {
|
|
|
41
41
|
try {
|
|
42
42
|
const t = document.currentScript || document.querySelector('script[src*="haori"]');
|
|
43
43
|
if (t instanceof HTMLScriptElement) {
|
|
44
|
-
const r = t.getAttribute("data-prefix") ||
|
|
45
|
-
|
|
44
|
+
const r = t.getAttribute("data-prefix") || M._prefix;
|
|
45
|
+
M._prefix = r.endsWith("-") ? r : r + "-";
|
|
46
46
|
}
|
|
47
|
-
if (t instanceof HTMLScriptElement && t.hasAttribute(`${
|
|
47
|
+
if (t instanceof HTMLScriptElement && t.hasAttribute(`${M._prefix}dev`)) {
|
|
48
48
|
O.set(!0);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
@@ -63,13 +63,13 @@ const D = class D {
|
|
|
63
63
|
* @returns プレフィックス
|
|
64
64
|
*/
|
|
65
65
|
static get prefix() {
|
|
66
|
-
return
|
|
66
|
+
return M._prefix;
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
let
|
|
71
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
72
|
-
class
|
|
69
|
+
M._prefix = "data-";
|
|
70
|
+
let h = M;
|
|
71
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", h.detect) : h.detect();
|
|
72
|
+
class f {
|
|
73
73
|
/**
|
|
74
74
|
* 開発モードでのみコンソールに情報を出力します。
|
|
75
75
|
*
|
|
@@ -98,7 +98,7 @@ class h {
|
|
|
98
98
|
console.error(t, ...e);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
class
|
|
101
|
+
class z {
|
|
102
102
|
constructor() {
|
|
103
103
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
104
104
|
}
|
|
@@ -111,16 +111,16 @@ class J {
|
|
|
111
111
|
*/
|
|
112
112
|
enqueue(t, e = !1) {
|
|
113
113
|
let r, n;
|
|
114
|
-
const
|
|
114
|
+
const s = new Promise((a, o) => {
|
|
115
115
|
r = a, n = o;
|
|
116
|
-
}),
|
|
116
|
+
}), i = {
|
|
117
117
|
task: t,
|
|
118
118
|
timestamp: performance.now(),
|
|
119
|
-
promise:
|
|
119
|
+
promise: s,
|
|
120
120
|
resolve: r,
|
|
121
121
|
reject: n
|
|
122
122
|
};
|
|
123
|
-
return e ? this.queue.unshift(
|
|
123
|
+
return e ? this.queue.unshift(i) : this.queue.push(i), this.scheduleProcessing(), s;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* キューを処理します。
|
|
@@ -140,13 +140,13 @@ class J {
|
|
|
140
140
|
const r = await e.task();
|
|
141
141
|
e.resolve(r);
|
|
142
142
|
} catch (r) {
|
|
143
|
-
e.reject(r),
|
|
143
|
+
e.reject(r), f.error("[Haori]", `Task ${e.timestamp} failed:`, r);
|
|
144
144
|
}
|
|
145
145
|
if (performance.now() - t > this.MAX_BUDGET)
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
} catch (t) {
|
|
149
|
-
|
|
149
|
+
f.error("[Haori]", "Error processing queue:", t);
|
|
150
150
|
} finally {
|
|
151
151
|
this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
|
|
152
152
|
}
|
|
@@ -174,7 +174,7 @@ class J {
|
|
|
174
174
|
t.length > 0 && await Promise.allSettled(t);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
const
|
|
177
|
+
const J = class J {
|
|
178
178
|
/**
|
|
179
179
|
* タスクをキューに追加します。
|
|
180
180
|
*
|
|
@@ -192,9 +192,9 @@ const G = class G {
|
|
|
192
192
|
return this.ASYNC_QUEUE.wait();
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
|
-
|
|
196
|
-
let N =
|
|
197
|
-
class
|
|
195
|
+
J.ASYNC_QUEUE = new z();
|
|
196
|
+
let N = J;
|
|
197
|
+
class X {
|
|
198
198
|
/**
|
|
199
199
|
* 通知ダイアログを表示します。
|
|
200
200
|
*
|
|
@@ -239,7 +239,7 @@ class Y {
|
|
|
239
239
|
*/
|
|
240
240
|
static openDialog(t) {
|
|
241
241
|
return N.enqueue(() => {
|
|
242
|
-
t instanceof HTMLDialogElement ? t.showModal() :
|
|
242
|
+
t instanceof HTMLDialogElement ? t.showModal() : f.error("[Haori]", "Element is not a dialog: ", t);
|
|
243
243
|
}, !0);
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
@@ -249,7 +249,7 @@ class Y {
|
|
|
249
249
|
*/
|
|
250
250
|
static closeDialog(t) {
|
|
251
251
|
return N.enqueue(() => {
|
|
252
|
-
t instanceof HTMLDialogElement ? t.close() :
|
|
252
|
+
t instanceof HTMLDialogElement ? t.close() : f.error("[Haori]", "Element is not a dialog: ", t);
|
|
253
253
|
}, !0);
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
@@ -284,12 +284,12 @@ class Y {
|
|
|
284
284
|
}, !0);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
const
|
|
287
|
+
const Q = ["addErrorMessage", "clearMessages"];
|
|
288
288
|
function W() {
|
|
289
289
|
const t = globalThis.window?.Haori;
|
|
290
|
-
return
|
|
290
|
+
return Q.every(
|
|
291
291
|
(r) => typeof t?.[r] == "function"
|
|
292
|
-
) ? t :
|
|
292
|
+
) ? t : X;
|
|
293
293
|
}
|
|
294
294
|
class E {
|
|
295
295
|
/**
|
|
@@ -313,32 +313,32 @@ class E {
|
|
|
313
313
|
* @returns values と同じオブジェクト
|
|
314
314
|
*/
|
|
315
315
|
static getPartValues(t, e) {
|
|
316
|
-
const r = t.getAttribute("name"), n = t.getAttribute(`${
|
|
316
|
+
const r = t.getAttribute("name"), n = t.getAttribute(`${h.prefix}form-object`), s = t.getAttribute(`${h.prefix}form-list`);
|
|
317
317
|
if (r) {
|
|
318
|
-
|
|
318
|
+
s ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), n && f.warn(
|
|
319
319
|
"Haori",
|
|
320
|
-
`Element cannot have both ${
|
|
320
|
+
`Element cannot have both ${h.prefix}form-object and name attributes.`
|
|
321
321
|
);
|
|
322
|
-
for (const
|
|
323
|
-
E.getPartValues(
|
|
322
|
+
for (const i of t.getChildElementFragments())
|
|
323
|
+
E.getPartValues(i, e);
|
|
324
324
|
} else if (n) {
|
|
325
|
-
const
|
|
325
|
+
const i = {};
|
|
326
326
|
for (const a of t.getChildElementFragments())
|
|
327
|
-
E.getPartValues(a,
|
|
328
|
-
Object.keys(
|
|
327
|
+
E.getPartValues(a, i);
|
|
328
|
+
Object.keys(i).length > 0 && (e[String(n)] = i), s && f.warn(
|
|
329
329
|
"Haori",
|
|
330
|
-
`Element cannot have both ${
|
|
330
|
+
`Element cannot have both ${h.prefix}form-list and ${h.prefix}form-object attributes.`
|
|
331
331
|
);
|
|
332
|
-
} else if (
|
|
333
|
-
const
|
|
332
|
+
} else if (s) {
|
|
333
|
+
const i = [];
|
|
334
334
|
for (const a of t.getChildElementFragments()) {
|
|
335
335
|
const o = {};
|
|
336
|
-
E.getPartValues(a, o), Object.keys(o).length > 0 &&
|
|
336
|
+
E.getPartValues(a, o), Object.keys(o).length > 0 && i.push(o);
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
i.length > 0 && (e[String(s)] = i);
|
|
339
339
|
} else
|
|
340
|
-
for (const
|
|
341
|
-
E.getPartValues(
|
|
340
|
+
for (const i of t.getChildElementFragments())
|
|
341
|
+
E.getPartValues(i, e);
|
|
342
342
|
return e;
|
|
343
343
|
}
|
|
344
344
|
/**
|
|
@@ -363,17 +363,17 @@ class E {
|
|
|
363
363
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
364
364
|
*/
|
|
365
365
|
static setPartValues(t, e, r = null, n = !1) {
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
366
|
+
const s = [], i = t.getAttribute("name"), a = t.getAttribute(`${h.prefix}form-object`), o = t.getAttribute(`${h.prefix}form-list`), g = t.getAttribute(`${h.prefix}form-detach`);
|
|
367
|
+
if (i) {
|
|
368
368
|
if (!g || n) {
|
|
369
|
-
const u = e[String(
|
|
370
|
-
o && Array.isArray(u) && r !== null ?
|
|
369
|
+
const u = e[String(i)];
|
|
370
|
+
o && Array.isArray(u) && r !== null ? s.push(t.setValue(u[r])) : typeof u == "string" || typeof u == "number" || typeof u == "boolean" || u === null ? s.push(t.setValue(u)) : s.push(t.setValue(String(u)));
|
|
371
371
|
}
|
|
372
372
|
} else if (a) {
|
|
373
373
|
const u = e[String(a)];
|
|
374
374
|
if (u && typeof u == "object")
|
|
375
375
|
for (const b of t.getChildElementFragments())
|
|
376
|
-
|
|
376
|
+
s.push(
|
|
377
377
|
E.setPartValues(
|
|
378
378
|
b,
|
|
379
379
|
u,
|
|
@@ -386,21 +386,21 @@ class E {
|
|
|
386
386
|
if (Array.isArray(u)) {
|
|
387
387
|
const b = t.getChildElementFragments();
|
|
388
388
|
for (let l = 0; l < b.length; l++) {
|
|
389
|
-
const
|
|
390
|
-
u.length > l ?
|
|
389
|
+
const d = b[l];
|
|
390
|
+
u.length > l ? s.push(
|
|
391
391
|
E.setPartValues(
|
|
392
|
-
|
|
392
|
+
d,
|
|
393
393
|
u[l],
|
|
394
394
|
l,
|
|
395
395
|
n
|
|
396
396
|
)
|
|
397
|
-
) :
|
|
397
|
+
) : s.push(E.setPartValues(d, {}, l, n));
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
} else
|
|
401
401
|
for (const u of t.getChildElementFragments())
|
|
402
|
-
|
|
403
|
-
return Promise.all(
|
|
402
|
+
s.push(E.setPartValues(u, e, null, n));
|
|
403
|
+
return Promise.all(s).then(() => {
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
@@ -421,8 +421,8 @@ class E {
|
|
|
421
421
|
else {
|
|
422
422
|
const r = e.parentElement;
|
|
423
423
|
if (r) {
|
|
424
|
-
const n = e.nextElementSibling,
|
|
425
|
-
|
|
424
|
+
const n = e.nextElementSibling, s = document.createElement("form");
|
|
425
|
+
s.appendChild(e), s.reset(), r.insertBefore(e, n);
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
}), await T.evaluateAll(t);
|
|
@@ -434,20 +434,20 @@ class E {
|
|
|
434
434
|
* 対象エレメント自体は削除しません。
|
|
435
435
|
*/
|
|
436
436
|
static clearEachClones(t) {
|
|
437
|
-
const e = [], r = (
|
|
438
|
-
if (
|
|
439
|
-
for (const
|
|
440
|
-
const a =
|
|
441
|
-
!a && !o && e.push(
|
|
437
|
+
const e = [], r = (s) => {
|
|
438
|
+
if (s.hasAttribute(`${h.prefix}each`))
|
|
439
|
+
for (const i of s.getChildElementFragments()) {
|
|
440
|
+
const a = i.hasAttribute(`${h.prefix}each-before`), o = i.hasAttribute(`${h.prefix}each-after`);
|
|
441
|
+
!a && !o && e.push(i.remove());
|
|
442
442
|
}
|
|
443
|
-
}, n = (
|
|
444
|
-
r(
|
|
445
|
-
for (const
|
|
446
|
-
n(
|
|
443
|
+
}, n = (s) => {
|
|
444
|
+
r(s);
|
|
445
|
+
for (const i of s.getChildElementFragments())
|
|
446
|
+
n(i);
|
|
447
447
|
};
|
|
448
448
|
r(t);
|
|
449
|
-
for (const
|
|
450
|
-
n(
|
|
449
|
+
for (const s of t.getChildElementFragments())
|
|
450
|
+
n(s);
|
|
451
451
|
return Promise.all(e).then(() => {
|
|
452
452
|
});
|
|
453
453
|
}
|
|
@@ -482,13 +482,13 @@ class E {
|
|
|
482
482
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
483
483
|
*/
|
|
484
484
|
static addErrorMessage(t, e, r) {
|
|
485
|
-
const n = [],
|
|
486
|
-
return
|
|
485
|
+
const n = [], s = W(), i = E.findFragmentsByKey(t, e);
|
|
486
|
+
return i.forEach((a) => {
|
|
487
487
|
n.push(
|
|
488
|
-
|
|
488
|
+
s.addErrorMessage(a.getTarget(), r)
|
|
489
489
|
);
|
|
490
|
-
}),
|
|
491
|
-
|
|
490
|
+
}), i.length === 0 && n.push(
|
|
491
|
+
s.addErrorMessage(t.getTarget(), r)
|
|
492
492
|
), Promise.all(n).then(() => {
|
|
493
493
|
});
|
|
494
494
|
}
|
|
@@ -512,21 +512,21 @@ class E {
|
|
|
512
512
|
*/
|
|
513
513
|
static findFragmentByKeyParts(t, e) {
|
|
514
514
|
const r = [], n = e[0];
|
|
515
|
-
if (e.length == 1 && t.getAttribute("name") === n && r.push(t), t.hasAttribute(`${
|
|
516
|
-
e.length > 1 && t.getAttribute(`${
|
|
517
|
-
r.push(...E.findFragmentByKeyParts(
|
|
515
|
+
if (e.length == 1 && t.getAttribute("name") === n && r.push(t), t.hasAttribute(`${h.prefix}form-object`))
|
|
516
|
+
e.length > 1 && t.getAttribute(`${h.prefix}form-object`) === n && t.getChildElementFragments().forEach((i) => {
|
|
517
|
+
r.push(...E.findFragmentByKeyParts(i, e.slice(1)));
|
|
518
518
|
});
|
|
519
|
-
else if (t.hasAttribute(`${
|
|
519
|
+
else if (t.hasAttribute(`${h.prefix}form-list`)) {
|
|
520
520
|
if (e.length > 1) {
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
const o = n.substring(0,
|
|
524
|
-
if (
|
|
525
|
-
const g = n.substring(
|
|
521
|
+
const s = t.getAttribute(`${h.prefix}form-list`), i = n.lastIndexOf("["), a = n.lastIndexOf("]");
|
|
522
|
+
if (i !== -1 && a !== -1 && i < a) {
|
|
523
|
+
const o = n.substring(0, i);
|
|
524
|
+
if (s === o) {
|
|
525
|
+
const g = n.substring(i + 1, a), u = Number(g);
|
|
526
526
|
if (isNaN(u))
|
|
527
|
-
|
|
527
|
+
f.error("Haori", `Invalid index: ${n}`);
|
|
528
528
|
else {
|
|
529
|
-
const b = t.getChildElementFragments().filter((l) => l.hasAttribute(`${
|
|
529
|
+
const b = t.getChildElementFragments().filter((l) => l.hasAttribute(`${h.prefix}row`));
|
|
530
530
|
u < b.length && r.push(
|
|
531
531
|
...E.findFragmentByKeyParts(b[u], e.slice(1))
|
|
532
532
|
);
|
|
@@ -535,8 +535,8 @@ class E {
|
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
} else
|
|
538
|
-
t.getChildElementFragments().forEach((
|
|
539
|
-
r.push(...E.findFragmentByKeyParts(
|
|
538
|
+
t.getChildElementFragments().forEach((s) => {
|
|
539
|
+
r.push(...E.findFragmentByKeyParts(s, e));
|
|
540
540
|
});
|
|
541
541
|
return r;
|
|
542
542
|
}
|
|
@@ -553,7 +553,7 @@ class E {
|
|
|
553
553
|
return r ? this.getFormFragment(r) : null;
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
|
-
const
|
|
556
|
+
const P = class P {
|
|
557
557
|
/**
|
|
558
558
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
559
559
|
*
|
|
@@ -598,28 +598,28 @@ const S = class S {
|
|
|
598
598
|
*/
|
|
599
599
|
static evaluate(t, e = {}) {
|
|
600
600
|
if (t.trim() === "")
|
|
601
|
-
return
|
|
601
|
+
return f.warn("[Haori]", t, "Expression is empty"), null;
|
|
602
602
|
if (this.containsDangerousPatterns(t))
|
|
603
|
-
return
|
|
603
|
+
return f.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
604
604
|
if (this.containsForbiddenKeys(e))
|
|
605
|
-
return
|
|
605
|
+
return f.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
606
606
|
if (this.containsForbiddenBindingValues(e))
|
|
607
|
-
return
|
|
607
|
+
return f.warn(
|
|
608
608
|
"[Haori]",
|
|
609
609
|
e,
|
|
610
610
|
"Binded values contain forbidden values"
|
|
611
611
|
), null;
|
|
612
|
-
const r = Object.keys(e).filter((
|
|
613
|
-
let
|
|
614
|
-
if (!
|
|
615
|
-
const
|
|
616
|
-
${
|
|
612
|
+
const r = Object.keys(e).filter((i) => !this.FORBIDDEN_BINDING_NAMES.has(i)).sort(), n = `${t}:${r.join(",")}`;
|
|
613
|
+
let s = this.EXPRESSION_CACHE.get(n);
|
|
614
|
+
if (!s) {
|
|
615
|
+
const i = this.buildAssignments(r), a = i ? `"use strict";
|
|
616
|
+
${i};
|
|
617
617
|
return (${t});` : `"use strict";
|
|
618
618
|
return (${t});`;
|
|
619
619
|
try {
|
|
620
|
-
|
|
620
|
+
s = new Function(...r, a), this.EXPRESSION_CACHE.set(n, s);
|
|
621
621
|
} catch (o) {
|
|
622
|
-
return
|
|
622
|
+
return f.error(
|
|
623
623
|
"[Haori]",
|
|
624
624
|
"Failed to compile expression:",
|
|
625
625
|
t,
|
|
@@ -628,12 +628,12 @@ return (${t});`;
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
try {
|
|
631
|
-
const
|
|
631
|
+
const i = [], a = this.wrapBoundValues(e);
|
|
632
632
|
return r.forEach((o) => {
|
|
633
|
-
|
|
634
|
-
}), this.withBlockedPropertyAccess(() =>
|
|
635
|
-
} catch (
|
|
636
|
-
return
|
|
633
|
+
i.push(a[o]);
|
|
634
|
+
}), this.withBlockedPropertyAccess(() => s(...i));
|
|
635
|
+
} catch (i) {
|
|
636
|
+
return f.error("[Haori]", "Expression evaluation error:", t, i), i instanceof ReferenceError ? void 0 : null;
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
639
|
/**
|
|
@@ -664,13 +664,13 @@ return (${t});`;
|
|
|
664
664
|
return !1;
|
|
665
665
|
const r = [];
|
|
666
666
|
let n = null;
|
|
667
|
-
for (let
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
670
|
-
this.decodeStringLiteral(
|
|
671
|
-
) ||
|
|
667
|
+
for (let s = 0; s < e.length; s++) {
|
|
668
|
+
const i = e[s], a = e[s + 1] || null, o = r[r.length - 1] || null;
|
|
669
|
+
if (i.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(i.value) || this.STRICT_FORBIDDEN_NAMES.includes(i.value) || (n?.value === "." || n?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(i.value)) || o === "member" && i.value !== "]" && i.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
670
|
+
this.decodeStringLiteral(i.value)
|
|
671
|
+
) || i.value === "." && a?.type !== "identifier" || i.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
672
672
|
return !1;
|
|
673
|
-
switch (
|
|
673
|
+
switch (i.value) {
|
|
674
674
|
case "(":
|
|
675
675
|
r.push("paren");
|
|
676
676
|
break;
|
|
@@ -690,7 +690,7 @@ return (${t});`;
|
|
|
690
690
|
break;
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
n =
|
|
693
|
+
n = i;
|
|
694
694
|
}
|
|
695
695
|
return r.length === 0;
|
|
696
696
|
}
|
|
@@ -731,41 +731,41 @@ return (${t});`;
|
|
|
731
731
|
">",
|
|
732
732
|
"<"
|
|
733
733
|
]);
|
|
734
|
-
let
|
|
735
|
-
for (;
|
|
736
|
-
const
|
|
737
|
-
if (/\s/.test(
|
|
738
|
-
|
|
734
|
+
let s = 0;
|
|
735
|
+
for (; s < t.length; ) {
|
|
736
|
+
const i = t[s];
|
|
737
|
+
if (/\s/.test(i)) {
|
|
738
|
+
s += 1;
|
|
739
739
|
continue;
|
|
740
740
|
}
|
|
741
|
-
if (
|
|
741
|
+
if (i === "/" && (t[s + 1] === "/" || t[s + 1] === "*"))
|
|
742
742
|
return null;
|
|
743
|
-
if (
|
|
744
|
-
const o = this.readStringToken(t,
|
|
743
|
+
if (i === '"' || i === "'") {
|
|
744
|
+
const o = this.readStringToken(t, s);
|
|
745
745
|
if (o === null)
|
|
746
746
|
return null;
|
|
747
|
-
e.push(o.token),
|
|
747
|
+
e.push(o.token), s = o.nextIndex;
|
|
748
748
|
continue;
|
|
749
749
|
}
|
|
750
750
|
const a = r.find(
|
|
751
|
-
(o) => t.startsWith(o,
|
|
751
|
+
(o) => t.startsWith(o, s)
|
|
752
752
|
);
|
|
753
753
|
if (a) {
|
|
754
|
-
e.push({ type: "operator", value: a, position:
|
|
754
|
+
e.push({ type: "operator", value: a, position: s }), s += a.length;
|
|
755
755
|
continue;
|
|
756
756
|
}
|
|
757
|
-
if (/[0-9]/.test(
|
|
758
|
-
const o = this.readNumberToken(t,
|
|
759
|
-
e.push(o.token),
|
|
757
|
+
if (/[0-9]/.test(i)) {
|
|
758
|
+
const o = this.readNumberToken(t, s);
|
|
759
|
+
e.push(o.token), s = o.nextIndex;
|
|
760
760
|
continue;
|
|
761
761
|
}
|
|
762
|
-
if (/[A-Za-z_$]/.test(
|
|
763
|
-
const o = this.readIdentifierToken(t,
|
|
764
|
-
e.push(o.token),
|
|
762
|
+
if (/[A-Za-z_$]/.test(i)) {
|
|
763
|
+
const o = this.readIdentifierToken(t, s);
|
|
764
|
+
e.push(o.token), s = o.nextIndex;
|
|
765
765
|
continue;
|
|
766
766
|
}
|
|
767
|
-
if (n.has(
|
|
768
|
-
e.push({ type: "operator", value:
|
|
767
|
+
if (n.has(i)) {
|
|
768
|
+
e.push({ type: "operator", value: i, position: s }), s += 1;
|
|
769
769
|
continue;
|
|
770
770
|
}
|
|
771
771
|
return null;
|
|
@@ -783,12 +783,12 @@ return (${t});`;
|
|
|
783
783
|
const r = t[e];
|
|
784
784
|
let n = e + 1;
|
|
785
785
|
for (; n < t.length; ) {
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
786
|
+
const s = t[n];
|
|
787
|
+
if (s === "\\") {
|
|
788
788
|
n += 2;
|
|
789
789
|
continue;
|
|
790
790
|
}
|
|
791
|
-
if (
|
|
791
|
+
if (s === r)
|
|
792
792
|
return {
|
|
793
793
|
token: {
|
|
794
794
|
type: "string",
|
|
@@ -896,8 +896,8 @@ return (${t});`;
|
|
|
896
896
|
*/
|
|
897
897
|
static wrapBoundValues(t) {
|
|
898
898
|
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
899
|
-
return Object.entries(t).forEach(([n,
|
|
900
|
-
r[n] = this.wrapBoundValue(
|
|
899
|
+
return Object.entries(t).forEach(([n, s]) => {
|
|
900
|
+
r[n] = this.wrapBoundValue(s, e);
|
|
901
901
|
}), r;
|
|
902
902
|
}
|
|
903
903
|
/**
|
|
@@ -913,39 +913,39 @@ return (${t});`;
|
|
|
913
913
|
const r = t, n = e.get(r);
|
|
914
914
|
if (n !== void 0)
|
|
915
915
|
return n;
|
|
916
|
-
const
|
|
917
|
-
get: (
|
|
916
|
+
const s = new Proxy(r, {
|
|
917
|
+
get: (i, a, o) => {
|
|
918
918
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
919
919
|
return;
|
|
920
|
-
const g = Reflect.get(
|
|
920
|
+
const g = Reflect.get(i, a, o);
|
|
921
921
|
return typeof a == "symbol" ? g : this.wrapBoundValue(
|
|
922
922
|
g,
|
|
923
923
|
e
|
|
924
924
|
);
|
|
925
925
|
},
|
|
926
|
-
has: (
|
|
927
|
-
getOwnPropertyDescriptor: (
|
|
926
|
+
has: (i, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(i, a),
|
|
927
|
+
getOwnPropertyDescriptor: (i, a) => {
|
|
928
928
|
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
929
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
929
|
+
return Reflect.getOwnPropertyDescriptor(i, a);
|
|
930
930
|
},
|
|
931
|
-
apply: (
|
|
931
|
+
apply: (i, a, o) => {
|
|
932
932
|
const g = Reflect.apply(
|
|
933
|
-
|
|
933
|
+
i,
|
|
934
934
|
a,
|
|
935
935
|
o
|
|
936
936
|
);
|
|
937
937
|
return this.isIteratorLike(g) ? g : this.wrapBoundValue(g, e);
|
|
938
938
|
},
|
|
939
|
-
construct: (
|
|
939
|
+
construct: (i, a, o) => this.wrapBoundValue(
|
|
940
940
|
Reflect.construct(
|
|
941
|
-
|
|
941
|
+
i,
|
|
942
942
|
a,
|
|
943
943
|
o
|
|
944
944
|
),
|
|
945
945
|
e
|
|
946
946
|
)
|
|
947
947
|
});
|
|
948
|
-
return e.set(r,
|
|
948
|
+
return e.set(r, s), s;
|
|
949
949
|
}
|
|
950
950
|
/**
|
|
951
951
|
* Proxy ラップ対象の値かどうかを判定します。
|
|
@@ -978,8 +978,8 @@ return (${t});`;
|
|
|
978
978
|
...n,
|
|
979
979
|
descriptor: Object.getOwnPropertyDescriptor(n.target, n.property)
|
|
980
980
|
})).filter((n) => n.descriptor?.configurable === !0);
|
|
981
|
-
r.forEach(({ target: n, property:
|
|
982
|
-
Object.defineProperty(n,
|
|
981
|
+
r.forEach(({ target: n, property: s }) => {
|
|
982
|
+
Object.defineProperty(n, s, {
|
|
983
983
|
configurable: !0,
|
|
984
984
|
enumerable: !1,
|
|
985
985
|
get: () => {
|
|
@@ -991,8 +991,8 @@ return (${t});`;
|
|
|
991
991
|
try {
|
|
992
992
|
return t();
|
|
993
993
|
} finally {
|
|
994
|
-
r.forEach(({ target: n, property:
|
|
995
|
-
|
|
994
|
+
r.forEach(({ target: n, property: s, descriptor: i }) => {
|
|
995
|
+
i !== void 0 && Object.defineProperty(n, s, i);
|
|
996
996
|
});
|
|
997
997
|
}
|
|
998
998
|
}
|
|
@@ -1046,7 +1046,7 @@ return (${t});`;
|
|
|
1046
1046
|
return !1;
|
|
1047
1047
|
}
|
|
1048
1048
|
};
|
|
1049
|
-
|
|
1049
|
+
P.FORBIDDEN_NAMES = [
|
|
1050
1050
|
// グローバルオブジェクト
|
|
1051
1051
|
"window",
|
|
1052
1052
|
"self",
|
|
@@ -1078,19 +1078,19 @@ S.FORBIDDEN_NAMES = [
|
|
|
1078
1078
|
"sessionStorage",
|
|
1079
1079
|
"IndexedDB",
|
|
1080
1080
|
"history"
|
|
1081
|
-
],
|
|
1082
|
-
...
|
|
1083
|
-
(t) => !
|
|
1081
|
+
], P.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], P.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), P.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1082
|
+
...P.FORBIDDEN_NAMES.filter(
|
|
1083
|
+
(t) => !P.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1084
1084
|
),
|
|
1085
1085
|
"constructor",
|
|
1086
1086
|
"__proto__",
|
|
1087
1087
|
"prototype",
|
|
1088
|
-
...
|
|
1089
|
-
]),
|
|
1088
|
+
...P.STRICT_FORBIDDEN_NAMES
|
|
1089
|
+
]), P.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1090
1090
|
"constructor",
|
|
1091
1091
|
"__proto__",
|
|
1092
1092
|
"prototype"
|
|
1093
|
-
]),
|
|
1093
|
+
]), P.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1094
1094
|
"await",
|
|
1095
1095
|
"break",
|
|
1096
1096
|
"case",
|
|
@@ -1124,35 +1124,35 @@ S.FORBIDDEN_NAMES = [
|
|
|
1124
1124
|
"while",
|
|
1125
1125
|
"with",
|
|
1126
1126
|
"yield"
|
|
1127
|
-
]),
|
|
1128
|
-
let H =
|
|
1129
|
-
const
|
|
1127
|
+
]), P.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1128
|
+
let H = P;
|
|
1129
|
+
const k = class k {
|
|
1130
1130
|
/**
|
|
1131
1131
|
* フラグメントのコンストラクタ。
|
|
1132
1132
|
*
|
|
1133
1133
|
* @param target 対象ノード
|
|
1134
1134
|
*/
|
|
1135
1135
|
constructor(t) {
|
|
1136
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t,
|
|
1136
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t, k.FRAGMENT_CACHE.set(t, this);
|
|
1137
1137
|
}
|
|
1138
1138
|
static get(t) {
|
|
1139
1139
|
if (t == null)
|
|
1140
1140
|
return null;
|
|
1141
|
-
if (
|
|
1142
|
-
return
|
|
1141
|
+
if (k.FRAGMENT_CACHE.has(t))
|
|
1142
|
+
return k.FRAGMENT_CACHE.get(t);
|
|
1143
1143
|
let e;
|
|
1144
1144
|
switch (t.nodeType) {
|
|
1145
1145
|
case Node.ELEMENT_NODE:
|
|
1146
|
-
e = new
|
|
1146
|
+
e = new x(t);
|
|
1147
1147
|
break;
|
|
1148
1148
|
case Node.TEXT_NODE:
|
|
1149
|
-
e = new
|
|
1149
|
+
e = new I(t);
|
|
1150
1150
|
break;
|
|
1151
1151
|
case Node.COMMENT_NODE:
|
|
1152
|
-
e = new
|
|
1152
|
+
e = new G(t);
|
|
1153
1153
|
break;
|
|
1154
1154
|
default:
|
|
1155
|
-
return
|
|
1155
|
+
return f.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
1156
1156
|
}
|
|
1157
1157
|
return e;
|
|
1158
1158
|
}
|
|
@@ -1230,7 +1230,7 @@ const P = class P {
|
|
|
1230
1230
|
* @return 除去のPromise
|
|
1231
1231
|
*/
|
|
1232
1232
|
remove(t = !0) {
|
|
1233
|
-
return this.parent && this.parent.removeChild(this),
|
|
1233
|
+
return this.parent && this.parent.removeChild(this), k.FRAGMENT_CACHE.delete(this.target), t ? this.unmount() : Promise.resolve();
|
|
1234
1234
|
}
|
|
1235
1235
|
/**
|
|
1236
1236
|
* 対象ノードを取得します。
|
|
@@ -1257,9 +1257,9 @@ const P = class P {
|
|
|
1257
1257
|
this.parent = t;
|
|
1258
1258
|
}
|
|
1259
1259
|
};
|
|
1260
|
-
|
|
1261
|
-
let A =
|
|
1262
|
-
class
|
|
1260
|
+
k.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1261
|
+
let A = k;
|
|
1262
|
+
class x extends A {
|
|
1263
1263
|
/**
|
|
1264
1264
|
* エレメントフラグメントのコンストラクタ。
|
|
1265
1265
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1285,7 +1285,7 @@ class M extends A {
|
|
|
1285
1285
|
], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.bindingDataCache = null, this.visible = !0, this.display = null, this.template = null, this.listKey = null, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.syncValue(), t.getAttributeNames().forEach((e) => {
|
|
1286
1286
|
const r = t.getAttribute(e);
|
|
1287
1287
|
if (r !== null && !this.attributeMap.has(e)) {
|
|
1288
|
-
const n = new
|
|
1288
|
+
const n = new L(e, r);
|
|
1289
1289
|
this.attributeMap.set(e, n);
|
|
1290
1290
|
}
|
|
1291
1291
|
}), t.childNodes.forEach((e) => {
|
|
@@ -1308,7 +1308,7 @@ class M extends A {
|
|
|
1308
1308
|
*/
|
|
1309
1309
|
getChildElementFragments() {
|
|
1310
1310
|
return this.children.filter(
|
|
1311
|
-
(t) => t instanceof
|
|
1311
|
+
(t) => t instanceof x
|
|
1312
1312
|
);
|
|
1313
1313
|
}
|
|
1314
1314
|
/**
|
|
@@ -1329,7 +1329,7 @@ class M extends A {
|
|
|
1329
1329
|
removeChild(t) {
|
|
1330
1330
|
const e = this.children.indexOf(t);
|
|
1331
1331
|
if (e < 0) {
|
|
1332
|
-
|
|
1332
|
+
f.warn("[Haori]", "Child fragment not found.", t);
|
|
1333
1333
|
return;
|
|
1334
1334
|
}
|
|
1335
1335
|
this.children.splice(e, 1), t.setParent(null);
|
|
@@ -1340,7 +1340,7 @@ class M extends A {
|
|
|
1340
1340
|
* @returns クローンされたフラグメント
|
|
1341
1341
|
*/
|
|
1342
1342
|
clone() {
|
|
1343
|
-
const t = new
|
|
1343
|
+
const t = new x(
|
|
1344
1344
|
this.target.cloneNode(!1)
|
|
1345
1345
|
);
|
|
1346
1346
|
return this.children.forEach((e) => {
|
|
@@ -1398,7 +1398,7 @@ class M extends A {
|
|
|
1398
1398
|
*/
|
|
1399
1399
|
clearBindingDataCache() {
|
|
1400
1400
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1401
|
-
t instanceof
|
|
1401
|
+
t instanceof x && t.clearBindingDataCache();
|
|
1402
1402
|
});
|
|
1403
1403
|
}
|
|
1404
1404
|
/**
|
|
@@ -1456,7 +1456,7 @@ class M extends A {
|
|
|
1456
1456
|
e.value = t === null ? "" : String(t), (e instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(e.type) || e instanceof HTMLTextAreaElement) && e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1457
1457
|
}).finally(() => {
|
|
1458
1458
|
this.skipChangeValue = !1;
|
|
1459
|
-
})) : (
|
|
1459
|
+
})) : (f.warn(
|
|
1460
1460
|
"[Haori]",
|
|
1461
1461
|
"setValue is not supported for this element type.",
|
|
1462
1462
|
e
|
|
@@ -1510,15 +1510,15 @@ class M extends A {
|
|
|
1510
1510
|
return Promise.resolve();
|
|
1511
1511
|
if (e === null)
|
|
1512
1512
|
return this.removeAttribute(t);
|
|
1513
|
-
const r = new
|
|
1513
|
+
const r = new L(t, e);
|
|
1514
1514
|
this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
|
|
1515
|
-
const n = this.getTarget(),
|
|
1515
|
+
const n = this.getTarget(), s = r.isForceEvaluation() ? e : this.getAttribute(t);
|
|
1516
1516
|
return N.enqueue(() => {
|
|
1517
|
-
if (
|
|
1517
|
+
if (s === null || s === !1)
|
|
1518
1518
|
n.removeAttribute(t);
|
|
1519
1519
|
else {
|
|
1520
|
-
const
|
|
1521
|
-
n.getAttribute(t) !==
|
|
1520
|
+
const i = String(s);
|
|
1521
|
+
n.getAttribute(t) !== i && n.setAttribute(t, i);
|
|
1522
1522
|
}
|
|
1523
1523
|
}).finally(() => {
|
|
1524
1524
|
this.skipMutationAttributes = !1;
|
|
@@ -1594,15 +1594,15 @@ class M extends A {
|
|
|
1594
1594
|
if (r.parentNode !== this.target)
|
|
1595
1595
|
return null;
|
|
1596
1596
|
const n = e ? r.nextSibling : r;
|
|
1597
|
-
let
|
|
1598
|
-
for (;
|
|
1599
|
-
const
|
|
1600
|
-
if (
|
|
1601
|
-
const a = this.children.indexOf(
|
|
1597
|
+
let s = e ? r.nextSibling : r;
|
|
1598
|
+
for (; s !== null; ) {
|
|
1599
|
+
const i = A.get(s);
|
|
1600
|
+
if (i !== null) {
|
|
1601
|
+
const a = this.children.indexOf(i);
|
|
1602
1602
|
if (a !== -1)
|
|
1603
1603
|
return { index: a, referenceNode: n };
|
|
1604
1604
|
}
|
|
1605
|
-
|
|
1605
|
+
s = s.nextSibling;
|
|
1606
1606
|
}
|
|
1607
1607
|
return { index: this.children.length, referenceNode: n };
|
|
1608
1608
|
}
|
|
@@ -1618,16 +1618,16 @@ class M extends A {
|
|
|
1618
1618
|
if (this.skipMutationNodes)
|
|
1619
1619
|
return Promise.resolve();
|
|
1620
1620
|
if (t === this)
|
|
1621
|
-
return
|
|
1621
|
+
return f.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1622
1622
|
const n = /* @__PURE__ */ new Set();
|
|
1623
|
-
let
|
|
1624
|
-
for (;
|
|
1625
|
-
n.add(
|
|
1623
|
+
let s = this.parent;
|
|
1624
|
+
for (; s; )
|
|
1625
|
+
n.add(s), s = s.getParent();
|
|
1626
1626
|
if (n.has(t))
|
|
1627
|
-
return
|
|
1628
|
-
const
|
|
1627
|
+
return f.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1628
|
+
const i = t.getParent() === this;
|
|
1629
1629
|
let a = -1, o = -1;
|
|
1630
|
-
|
|
1630
|
+
i && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1631
1631
|
const g = t.getParent();
|
|
1632
1632
|
g !== null && g.removeChild(t);
|
|
1633
1633
|
let u = r === void 0 ? e?.getTarget() || null : r;
|
|
@@ -1635,16 +1635,16 @@ class M extends A {
|
|
|
1635
1635
|
this.children.push(t);
|
|
1636
1636
|
else {
|
|
1637
1637
|
let l;
|
|
1638
|
-
if (
|
|
1639
|
-
const
|
|
1638
|
+
if (i ? a !== -1 && a < o ? l = o - 1 : l = o : l = this.children.indexOf(e), l === -1) {
|
|
1639
|
+
const d = this.resolveInsertionPointFromDom(
|
|
1640
1640
|
e,
|
|
1641
1641
|
!1
|
|
1642
1642
|
);
|
|
1643
|
-
|
|
1643
|
+
d === null ? (f.warn(
|
|
1644
1644
|
"[Haori]",
|
|
1645
1645
|
"Reference child not found in children.",
|
|
1646
1646
|
e
|
|
1647
|
-
), this.children.push(t)) : (this.children.splice(
|
|
1647
|
+
), this.children.push(t)) : (this.children.splice(d.index, 0, t), u = d.referenceNode);
|
|
1648
1648
|
} else
|
|
1649
1649
|
this.children.splice(l, 0, t);
|
|
1650
1650
|
}
|
|
@@ -1672,7 +1672,7 @@ class M extends A {
|
|
|
1672
1672
|
e,
|
|
1673
1673
|
!0
|
|
1674
1674
|
);
|
|
1675
|
-
return n === null ? (
|
|
1675
|
+
return n === null ? (f.warn(
|
|
1676
1676
|
"[Haori]",
|
|
1677
1677
|
"Reference child not found in children.",
|
|
1678
1678
|
e
|
|
@@ -1724,7 +1724,7 @@ class M extends A {
|
|
|
1724
1724
|
* @returns エレメントの非表示のPromise
|
|
1725
1725
|
*/
|
|
1726
1726
|
hide() {
|
|
1727
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1727
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${h.prefix}if-false`, ""), Promise.resolve();
|
|
1728
1728
|
}
|
|
1729
1729
|
/**
|
|
1730
1730
|
* エレメントを表示します。
|
|
@@ -1732,7 +1732,7 @@ class M extends A {
|
|
|
1732
1732
|
* @return エレメントの表示のPromise
|
|
1733
1733
|
*/
|
|
1734
1734
|
show() {
|
|
1735
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1735
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${h.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1736
1736
|
}
|
|
1737
1737
|
/**
|
|
1738
1738
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1748,7 +1748,7 @@ class M extends A {
|
|
|
1748
1748
|
return e === null ? null : e.closestByAttribute(t);
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
|
-
class
|
|
1751
|
+
class I extends A {
|
|
1752
1752
|
/**
|
|
1753
1753
|
* テキストフラグメントのコンストラクタ。
|
|
1754
1754
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -1764,7 +1764,7 @@ class $ extends A {
|
|
|
1764
1764
|
* @returns クローンされたフラグメント
|
|
1765
1765
|
*/
|
|
1766
1766
|
clone() {
|
|
1767
|
-
const t = new
|
|
1767
|
+
const t = new I(this.target.cloneNode(!0));
|
|
1768
1768
|
return t.mounted = !1, t.text = this.text, t.contents = this.contents, t;
|
|
1769
1769
|
}
|
|
1770
1770
|
/**
|
|
@@ -1803,7 +1803,7 @@ class $ extends A {
|
|
|
1803
1803
|
});
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
|
-
class
|
|
1806
|
+
class G extends A {
|
|
1807
1807
|
/**
|
|
1808
1808
|
* コメントフラグメントのコンストラクタ。
|
|
1809
1809
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1819,7 +1819,7 @@ class K extends A {
|
|
|
1819
1819
|
* @returns クローンされたフラグメント
|
|
1820
1820
|
*/
|
|
1821
1821
|
clone() {
|
|
1822
|
-
const t = new
|
|
1822
|
+
const t = new G(this.target.cloneNode(!0));
|
|
1823
1823
|
return t.mounted = !1, t.text = this.text, t;
|
|
1824
1824
|
}
|
|
1825
1825
|
/**
|
|
@@ -1844,7 +1844,7 @@ class K extends A {
|
|
|
1844
1844
|
}));
|
|
1845
1845
|
}
|
|
1846
1846
|
}
|
|
1847
|
-
const
|
|
1847
|
+
const q = class q {
|
|
1848
1848
|
/**
|
|
1849
1849
|
* コンストラクタ。
|
|
1850
1850
|
*
|
|
@@ -1852,26 +1852,26 @@ const V = class V {
|
|
|
1852
1852
|
*/
|
|
1853
1853
|
constructor(t) {
|
|
1854
1854
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
1855
|
-
const e = [...t.matchAll(
|
|
1856
|
-
let r = 0, n = !1,
|
|
1857
|
-
for (const
|
|
1858
|
-
|
|
1859
|
-
text: t.slice(r,
|
|
1855
|
+
const e = [...t.matchAll(q.PLACEHOLDER_REGEX)];
|
|
1856
|
+
let r = 0, n = !1, s = !1;
|
|
1857
|
+
for (const i of e) {
|
|
1858
|
+
i.index > r && this.contents.push({
|
|
1859
|
+
text: t.slice(r, i.index),
|
|
1860
1860
|
type: 0
|
|
1861
1861
|
/* TEXT */
|
|
1862
1862
|
});
|
|
1863
1863
|
const a = {
|
|
1864
|
-
text:
|
|
1865
|
-
type:
|
|
1864
|
+
text: i[1] ?? i[2],
|
|
1865
|
+
type: i[1] ? 2 : 1
|
|
1866
1866
|
/* EXPRESSION */
|
|
1867
1867
|
};
|
|
1868
|
-
n = !0,
|
|
1868
|
+
n = !0, s = s || a.type === 2, this.contents.push(a), r = i.index + i[0].length;
|
|
1869
1869
|
}
|
|
1870
1870
|
r < t.length && this.contents.push({
|
|
1871
1871
|
text: t.slice(r),
|
|
1872
1872
|
type: 0
|
|
1873
1873
|
/* TEXT */
|
|
1874
|
-
}), this.isEvaluate = n, this.isRawEvaluate =
|
|
1874
|
+
}), this.isEvaluate = n, this.isRawEvaluate = s, this.checkRawExpressions();
|
|
1875
1875
|
}
|
|
1876
1876
|
/**
|
|
1877
1877
|
* 評価結果を結合して文字列にします。
|
|
@@ -1895,7 +1895,7 @@ const V = class V {
|
|
|
1895
1895
|
*/
|
|
1896
1896
|
checkRawExpressions() {
|
|
1897
1897
|
for (let t = 0; t < this.contents.length; t++)
|
|
1898
|
-
this.contents[t].type === 2 && this.contents.length > 1 && (
|
|
1898
|
+
this.contents[t].type === 2 && this.contents.length > 1 && (f.error(
|
|
1899
1899
|
"[Haori]",
|
|
1900
1900
|
"Raw expressions are not allowed in multi-content expressions."
|
|
1901
1901
|
), this.contents[t].type = 1);
|
|
@@ -1918,7 +1918,7 @@ const V = class V {
|
|
|
1918
1918
|
} else
|
|
1919
1919
|
e.push(r.text);
|
|
1920
1920
|
} catch (n) {
|
|
1921
|
-
|
|
1921
|
+
f.error(
|
|
1922
1922
|
"[Haori]",
|
|
1923
1923
|
`Error evaluating text expression: ${r.text}`,
|
|
1924
1924
|
n
|
|
@@ -1927,9 +1927,9 @@ const V = class V {
|
|
|
1927
1927
|
}), e;
|
|
1928
1928
|
}
|
|
1929
1929
|
};
|
|
1930
|
-
|
|
1931
|
-
let B =
|
|
1932
|
-
const
|
|
1930
|
+
q.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
1931
|
+
let B = q;
|
|
1932
|
+
const U = class U extends B {
|
|
1933
1933
|
/**
|
|
1934
1934
|
* コンストラクタ。
|
|
1935
1935
|
*
|
|
@@ -1937,7 +1937,7 @@ const q = class q extends B {
|
|
|
1937
1937
|
* @param text 属性値
|
|
1938
1938
|
*/
|
|
1939
1939
|
constructor(t, e) {
|
|
1940
|
-
super(e), this.forceEvaluation =
|
|
1940
|
+
super(e), this.forceEvaluation = U.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
1941
1941
|
}
|
|
1942
1942
|
/**
|
|
1943
1943
|
* 強制評価フラグを取得します。
|
|
@@ -1965,26 +1965,26 @@ const q = class q extends B {
|
|
|
1965
1965
|
} else
|
|
1966
1966
|
e.push(r.text);
|
|
1967
1967
|
} catch (n) {
|
|
1968
|
-
|
|
1968
|
+
f.error(
|
|
1969
1969
|
"[Haori]",
|
|
1970
1970
|
`Error evaluating attribute expression: ${r.text}`,
|
|
1971
1971
|
n
|
|
1972
1972
|
), e.push("");
|
|
1973
1973
|
}
|
|
1974
|
-
}), this.forceEvaluation && e.length > 1 ? (
|
|
1974
|
+
}), this.forceEvaluation && e.length > 1 ? (f.error(
|
|
1975
1975
|
"[Haori]",
|
|
1976
1976
|
"each or if expressions must have a single content.",
|
|
1977
1977
|
e
|
|
1978
1978
|
), [e[0]]) : e;
|
|
1979
1979
|
}
|
|
1980
1980
|
};
|
|
1981
|
-
|
|
1981
|
+
U.FORCE_EVALUATION_ATTRIBUTES = [
|
|
1982
1982
|
"data-if",
|
|
1983
1983
|
"hor-if",
|
|
1984
1984
|
"data-each",
|
|
1985
1985
|
"hor-each"
|
|
1986
1986
|
];
|
|
1987
|
-
let
|
|
1987
|
+
let L = U;
|
|
1988
1988
|
class y {
|
|
1989
1989
|
/**
|
|
1990
1990
|
* カスタムイベントを発火します。
|
|
@@ -1995,13 +1995,13 @@ class y {
|
|
|
1995
1995
|
* @param options イベントオプション
|
|
1996
1996
|
*/
|
|
1997
1997
|
static dispatch(t, e, r, n) {
|
|
1998
|
-
const
|
|
1998
|
+
const s = new CustomEvent(`haori:${e}`, {
|
|
1999
1999
|
bubbles: n?.bubbles ?? !0,
|
|
2000
2000
|
cancelable: n?.cancelable ?? !1,
|
|
2001
2001
|
composed: n?.composed ?? !0,
|
|
2002
2002
|
detail: r
|
|
2003
2003
|
});
|
|
2004
|
-
return t.dispatchEvent(
|
|
2004
|
+
return t.dispatchEvent(s);
|
|
2005
2005
|
}
|
|
2006
2006
|
/**
|
|
2007
2007
|
* readyイベントを発火します。
|
|
@@ -2065,15 +2065,15 @@ class y {
|
|
|
2065
2065
|
* @param reason 変更理由
|
|
2066
2066
|
*/
|
|
2067
2067
|
static bindChange(t, e, r, n = "other") {
|
|
2068
|
-
const
|
|
2068
|
+
const s = [], i = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...i, ...a]);
|
|
2069
2069
|
for (const g of o) {
|
|
2070
2070
|
const u = e?.[g], b = r[g];
|
|
2071
|
-
u !== b &&
|
|
2071
|
+
u !== b && s.push(g);
|
|
2072
2072
|
}
|
|
2073
2073
|
y.dispatch(t, "bindchange", {
|
|
2074
2074
|
previous: e || {},
|
|
2075
2075
|
next: r,
|
|
2076
|
-
changedKeys:
|
|
2076
|
+
changedKeys: s,
|
|
2077
2077
|
reason: n
|
|
2078
2078
|
});
|
|
2079
2079
|
}
|
|
@@ -2181,16 +2181,16 @@ class y {
|
|
|
2181
2181
|
* @param status HTTPステータス(存在する場合)
|
|
2182
2182
|
* @param startedAt 開始時刻(存在する場合)
|
|
2183
2183
|
*/
|
|
2184
|
-
static fetchError(t, e, r, n,
|
|
2184
|
+
static fetchError(t, e, r, n, s) {
|
|
2185
2185
|
y.dispatch(t, "fetcherror", {
|
|
2186
2186
|
url: e,
|
|
2187
2187
|
status: n,
|
|
2188
2188
|
error: r,
|
|
2189
|
-
durationMs:
|
|
2189
|
+
durationMs: s ? performance.now() - s : void 0
|
|
2190
2190
|
});
|
|
2191
2191
|
}
|
|
2192
2192
|
}
|
|
2193
|
-
const
|
|
2193
|
+
const Z = [
|
|
2194
2194
|
"addErrorMessage",
|
|
2195
2195
|
"closeDialog",
|
|
2196
2196
|
"confirm",
|
|
@@ -2198,13 +2198,13 @@ const Q = [
|
|
|
2198
2198
|
"openDialog",
|
|
2199
2199
|
"toast"
|
|
2200
2200
|
];
|
|
2201
|
-
function
|
|
2201
|
+
function K() {
|
|
2202
2202
|
const t = globalThis.window?.Haori;
|
|
2203
|
-
return
|
|
2203
|
+
return Z.every(
|
|
2204
2204
|
(r) => typeof t?.[r] == "function"
|
|
2205
|
-
) ? t :
|
|
2205
|
+
) ? t : X;
|
|
2206
2206
|
}
|
|
2207
|
-
class
|
|
2207
|
+
const c = class c {
|
|
2208
2208
|
/**
|
|
2209
2209
|
* イベント属性名を正しく生成します。
|
|
2210
2210
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2213,7 +2213,118 @@ class d {
|
|
|
2213
2213
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2214
2214
|
*/
|
|
2215
2215
|
static attrName(t, e, r = !1) {
|
|
2216
|
-
return t ? `${
|
|
2216
|
+
return t ? `${h.prefix}${t}-${e}` : r ? `${h.prefix}fetch-${e}` : `${h.prefix}${e}`;
|
|
2217
|
+
}
|
|
2218
|
+
/**
|
|
2219
|
+
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
2220
|
+
*
|
|
2221
|
+
* @param rawAttribute 生の属性値
|
|
2222
|
+
* @param bindingValues バインディング値
|
|
2223
|
+
* @returns パラメータ形式として扱える文字列
|
|
2224
|
+
*/
|
|
2225
|
+
static resolveDataParamString(t, e) {
|
|
2226
|
+
return t.replace(
|
|
2227
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2228
|
+
(r, n, s) => {
|
|
2229
|
+
const i = H.evaluate(
|
|
2230
|
+
n ?? s ?? "",
|
|
2231
|
+
e
|
|
2232
|
+
);
|
|
2233
|
+
return i == null || Number.isNaN(i) ? "" : encodeURIComponent(typeof i == "object" ? JSON.stringify(i) : String(i));
|
|
2234
|
+
}
|
|
2235
|
+
);
|
|
2236
|
+
}
|
|
2237
|
+
/**
|
|
2238
|
+
* JSON 文字列中のテンプレート式かどうかを判定します。
|
|
2239
|
+
*
|
|
2240
|
+
* @param source 生の属性値
|
|
2241
|
+
* @param offset プレースホルダ開始位置
|
|
2242
|
+
* @returns JSON 文字列中なら true
|
|
2243
|
+
*/
|
|
2244
|
+
static isJsonStringContext(t, e) {
|
|
2245
|
+
let r = !1, n = !1;
|
|
2246
|
+
for (let s = 0; s < e; s += 1) {
|
|
2247
|
+
const i = t[s];
|
|
2248
|
+
if (n) {
|
|
2249
|
+
n = !1;
|
|
2250
|
+
continue;
|
|
2251
|
+
}
|
|
2252
|
+
if (i === "\\") {
|
|
2253
|
+
n = !0;
|
|
2254
|
+
continue;
|
|
2255
|
+
}
|
|
2256
|
+
i === '"' && (r = !r);
|
|
2257
|
+
}
|
|
2258
|
+
return r;
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* JSON 値コンテキスト向けにテンプレート式の評価結果を直列化します。
|
|
2262
|
+
*
|
|
2263
|
+
* @param result テンプレート式の評価結果
|
|
2264
|
+
* @returns JSON 値として埋め込める文字列
|
|
2265
|
+
*/
|
|
2266
|
+
static stringifyJsonTemplateValue(t) {
|
|
2267
|
+
if (t === void 0 || Number.isNaN(t))
|
|
2268
|
+
return "null";
|
|
2269
|
+
try {
|
|
2270
|
+
return JSON.stringify(t) ?? JSON.stringify(String(t));
|
|
2271
|
+
} catch {
|
|
2272
|
+
return JSON.stringify(String(t));
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* JSON 文字列コンテキスト向けにテンプレート式の評価結果を直列化します。
|
|
2277
|
+
*
|
|
2278
|
+
* @param result テンプレート式の評価結果
|
|
2279
|
+
* @returns JSON 文字列へ安全に埋め込める文字列
|
|
2280
|
+
*/
|
|
2281
|
+
static stringifyJsonTemplateStringContent(t) {
|
|
2282
|
+
if (t == null || Number.isNaN(t))
|
|
2283
|
+
return "";
|
|
2284
|
+
const e = typeof t == "object" ? c.stringifyJsonTemplateValue(t) : String(t);
|
|
2285
|
+
return JSON.stringify(e).slice(1, -1);
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* JSON 形式 data 属性内のテンプレート式を安全に解決します。
|
|
2289
|
+
*
|
|
2290
|
+
* @param rawAttribute 生の属性値
|
|
2291
|
+
* @param bindingValues バインディング値
|
|
2292
|
+
* @returns JSON として解釈可能な文字列
|
|
2293
|
+
*/
|
|
2294
|
+
static resolveDataJsonString(t, e) {
|
|
2295
|
+
return t.replace(
|
|
2296
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2297
|
+
(r, n, s, i) => {
|
|
2298
|
+
const a = H.evaluate(
|
|
2299
|
+
n ?? s ?? "",
|
|
2300
|
+
e
|
|
2301
|
+
);
|
|
2302
|
+
return c.isJsonStringContext(t, i) ? c.stringifyJsonTemplateStringContent(a) : c.stringifyJsonTemplateValue(a);
|
|
2303
|
+
}
|
|
2304
|
+
);
|
|
2305
|
+
}
|
|
2306
|
+
/**
|
|
2307
|
+
* data 属性を評価済みの値として取得します。
|
|
2308
|
+
*
|
|
2309
|
+
* @param fragment フラグメント
|
|
2310
|
+
* @param attrName 属性名
|
|
2311
|
+
* @returns 送信データ
|
|
2312
|
+
*/
|
|
2313
|
+
static resolveDataAttribute(t, e) {
|
|
2314
|
+
const r = t.getRawAttribute(e), n = t.getAttribute(e);
|
|
2315
|
+
if (n && typeof n == "object" && !Array.isArray(n))
|
|
2316
|
+
return n;
|
|
2317
|
+
if (typeof n != "string" || r === null)
|
|
2318
|
+
return null;
|
|
2319
|
+
const s = r.trim();
|
|
2320
|
+
return c.SINGLE_PLACEHOLDER_REGEX.test(s) ? T.parseDataBind(n) : s.startsWith("{") || s.startsWith("[") ? T.parseDataBind(
|
|
2321
|
+
c.resolveDataJsonString(
|
|
2322
|
+
r,
|
|
2323
|
+
t.getBindingData()
|
|
2324
|
+
)
|
|
2325
|
+
) : T.parseDataBind(
|
|
2326
|
+
c.resolveDataParamString(r, t.getBindingData())
|
|
2327
|
+
);
|
|
2217
2328
|
}
|
|
2218
2329
|
/**
|
|
2219
2330
|
* オプションをフラグメントの属性から構築します。
|
|
@@ -2227,28 +2338,29 @@ class d {
|
|
|
2227
2338
|
targetFragment: t
|
|
2228
2339
|
};
|
|
2229
2340
|
if (e) {
|
|
2230
|
-
if (t.hasAttribute(
|
|
2231
|
-
|
|
2232
|
-
)), t.hasAttribute(
|
|
2233
|
-
t
|
|
2234
|
-
|
|
2341
|
+
if (t.hasAttribute(c.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(c.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2342
|
+
c.attrName(e, "confirm")
|
|
2343
|
+
)), t.hasAttribute(c.attrName(e, "data")) && (r.data = c.resolveDataAttribute(
|
|
2344
|
+
t,
|
|
2345
|
+
c.attrName(e, "data")
|
|
2346
|
+
)), t.hasAttribute(c.attrName(e, "form"))) {
|
|
2235
2347
|
const l = t.getRawAttribute(
|
|
2236
|
-
|
|
2348
|
+
c.attrName(e, "form")
|
|
2237
2349
|
);
|
|
2238
2350
|
if (l) {
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2241
|
-
A.get(
|
|
2242
|
-
) :
|
|
2351
|
+
const d = document.body.querySelector(l);
|
|
2352
|
+
d !== null ? r.formFragment = E.getFormFragment(
|
|
2353
|
+
A.get(d)
|
|
2354
|
+
) : f.error(
|
|
2243
2355
|
"Haori",
|
|
2244
|
-
`Form element not found: ${l} (${
|
|
2356
|
+
`Form element not found: ${l} (${c.attrName(e, "form")})`
|
|
2245
2357
|
);
|
|
2246
2358
|
} else
|
|
2247
2359
|
r.formFragment = E.getFormFragment(t);
|
|
2248
2360
|
} else e === "change" && (r.formFragment = E.getFormFragment(t));
|
|
2249
|
-
if (t.hasAttribute(`${
|
|
2361
|
+
if (t.hasAttribute(`${h.prefix}${e}-before-run`)) {
|
|
2250
2362
|
const l = t.getRawAttribute(
|
|
2251
|
-
`${
|
|
2363
|
+
`${h.prefix}${e}-before-run`
|
|
2252
2364
|
);
|
|
2253
2365
|
try {
|
|
2254
2366
|
r.beforeCallback = new Function(
|
|
@@ -2259,116 +2371,116 @@ class d {
|
|
|
2259
2371
|
${l}
|
|
2260
2372
|
`
|
|
2261
2373
|
);
|
|
2262
|
-
} catch (
|
|
2263
|
-
|
|
2374
|
+
} catch (d) {
|
|
2375
|
+
f.error("Haori", `Invalid before script: ${d}`);
|
|
2264
2376
|
}
|
|
2265
2377
|
}
|
|
2266
2378
|
}
|
|
2267
|
-
const n =
|
|
2268
|
-
|
|
2269
|
-
const
|
|
2379
|
+
const n = c.attrName(e, "fetch"), s = t.hasAttribute(n);
|
|
2380
|
+
s && (r.fetchUrl = t.getAttribute(n));
|
|
2381
|
+
const i = {};
|
|
2270
2382
|
if (e) {
|
|
2271
|
-
const l =
|
|
2272
|
-
t.hasAttribute(l) && (
|
|
2383
|
+
const l = c.attrName(e, "fetch-method");
|
|
2384
|
+
t.hasAttribute(l) && (i.method = t.getAttribute(
|
|
2273
2385
|
l
|
|
2274
2386
|
));
|
|
2275
2387
|
} else {
|
|
2276
|
-
const l =
|
|
2277
|
-
t.hasAttribute(l) && (
|
|
2388
|
+
const l = c.attrName(null, "method", !0);
|
|
2389
|
+
t.hasAttribute(l) && (i.method = t.getAttribute(
|
|
2278
2390
|
l
|
|
2279
2391
|
));
|
|
2280
2392
|
}
|
|
2281
2393
|
if (e) {
|
|
2282
|
-
const l =
|
|
2394
|
+
const l = c.attrName(e, "fetch-headers");
|
|
2283
2395
|
if (t.hasAttribute(l)) {
|
|
2284
|
-
const
|
|
2396
|
+
const d = t.getRawAttribute(
|
|
2285
2397
|
l
|
|
2286
2398
|
);
|
|
2287
2399
|
try {
|
|
2288
|
-
|
|
2400
|
+
i.headers = T.parseDataBind(d);
|
|
2289
2401
|
} catch (p) {
|
|
2290
|
-
|
|
2402
|
+
f.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2291
2403
|
}
|
|
2292
2404
|
}
|
|
2293
2405
|
} else {
|
|
2294
|
-
const l =
|
|
2406
|
+
const l = c.attrName(
|
|
2295
2407
|
null,
|
|
2296
2408
|
"headers",
|
|
2297
2409
|
!0
|
|
2298
2410
|
);
|
|
2299
2411
|
if (t.hasAttribute(l)) {
|
|
2300
|
-
const
|
|
2412
|
+
const d = t.getRawAttribute(
|
|
2301
2413
|
l
|
|
2302
2414
|
);
|
|
2303
2415
|
try {
|
|
2304
|
-
|
|
2416
|
+
i.headers = T.parseDataBind(d);
|
|
2305
2417
|
} catch (p) {
|
|
2306
|
-
|
|
2418
|
+
f.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2307
2419
|
}
|
|
2308
2420
|
}
|
|
2309
2421
|
}
|
|
2310
2422
|
if (e) {
|
|
2311
|
-
const l =
|
|
2423
|
+
const l = c.attrName(
|
|
2312
2424
|
e,
|
|
2313
2425
|
"fetch-content-type"
|
|
2314
2426
|
);
|
|
2315
2427
|
if (t.hasAttribute(l))
|
|
2316
|
-
|
|
2317
|
-
...
|
|
2428
|
+
i.headers = {
|
|
2429
|
+
...i.headers,
|
|
2318
2430
|
"Content-Type": t.getAttribute(l)
|
|
2319
2431
|
};
|
|
2320
|
-
else if (
|
|
2321
|
-
let
|
|
2322
|
-
|
|
2323
|
-
...
|
|
2432
|
+
else if (i.method && i.method !== "GET" && i.method !== "HEAD" && i.method !== "OPTIONS") {
|
|
2433
|
+
let d = !1;
|
|
2434
|
+
i.headers && typeof i.headers == "object" && (d = "Content-Type" in i.headers), d || (i.headers = {
|
|
2435
|
+
...i.headers,
|
|
2324
2436
|
"Content-Type": "application/json"
|
|
2325
2437
|
});
|
|
2326
|
-
} else
|
|
2327
|
-
...
|
|
2438
|
+
} else i.method && (i.method === "GET" || i.method === "HEAD" || i.method === "OPTIONS") && (i.headers = {
|
|
2439
|
+
...i.headers,
|
|
2328
2440
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2329
2441
|
});
|
|
2330
2442
|
} else {
|
|
2331
|
-
const l =
|
|
2443
|
+
const l = c.attrName(
|
|
2332
2444
|
null,
|
|
2333
2445
|
"content-type",
|
|
2334
2446
|
!0
|
|
2335
2447
|
);
|
|
2336
2448
|
if (t.hasAttribute(l))
|
|
2337
|
-
|
|
2338
|
-
...
|
|
2449
|
+
i.headers = {
|
|
2450
|
+
...i.headers,
|
|
2339
2451
|
"Content-Type": t.getAttribute(l)
|
|
2340
2452
|
};
|
|
2341
|
-
else if (
|
|
2342
|
-
let
|
|
2343
|
-
|
|
2344
|
-
...
|
|
2453
|
+
else if (i.method && i.method !== "GET" && i.method !== "HEAD" && i.method !== "OPTIONS") {
|
|
2454
|
+
let d = !1;
|
|
2455
|
+
i.headers && typeof i.headers == "object" && (d = "Content-Type" in i.headers), d || (i.headers = {
|
|
2456
|
+
...i.headers,
|
|
2345
2457
|
"Content-Type": "application/json"
|
|
2346
2458
|
});
|
|
2347
|
-
} else
|
|
2348
|
-
...
|
|
2459
|
+
} else i.method && (i.method === "GET" || i.method === "HEAD" || i.method === "OPTIONS") && (i.headers = {
|
|
2460
|
+
...i.headers,
|
|
2349
2461
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2350
2462
|
});
|
|
2351
2463
|
}
|
|
2352
|
-
Object.keys(
|
|
2353
|
-
const a = e ?
|
|
2464
|
+
Object.keys(i).length > 0 && (r.fetchOptions = i);
|
|
2465
|
+
const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
|
|
2354
2466
|
if (t.hasAttribute(a)) {
|
|
2355
2467
|
const l = t.getRawAttribute(a);
|
|
2356
2468
|
if (l) {
|
|
2357
|
-
const
|
|
2358
|
-
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
})) :
|
|
2469
|
+
const d = document.body.querySelectorAll(l);
|
|
2470
|
+
d.length > 0 ? (r.bindFragments = [], d.forEach((p) => {
|
|
2471
|
+
const v = A.get(p);
|
|
2472
|
+
v && r.bindFragments.push(v);
|
|
2473
|
+
})) : f.error(
|
|
2362
2474
|
"Haori",
|
|
2363
2475
|
`Bind element not found: ${l} (${a})`
|
|
2364
2476
|
);
|
|
2365
2477
|
}
|
|
2366
2478
|
}
|
|
2367
|
-
const o =
|
|
2479
|
+
const o = c.attrName(e, "bind-arg"), g = c.attrName(
|
|
2368
2480
|
null,
|
|
2369
2481
|
"arg",
|
|
2370
2482
|
!0
|
|
2371
|
-
), u =
|
|
2483
|
+
), u = c.attrName(
|
|
2372
2484
|
null,
|
|
2373
2485
|
"bind-arg",
|
|
2374
2486
|
!0
|
|
@@ -2376,113 +2488,108 @@ ${l}
|
|
|
2376
2488
|
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(g) ? r.bindArg = t.getRawAttribute(
|
|
2377
2489
|
g
|
|
2378
2490
|
) : t.hasAttribute(u) && (r.bindArg = t.getRawAttribute(u));
|
|
2379
|
-
const b = e ?
|
|
2491
|
+
const b = e ? c.attrName(e, "bind-params") : c.attrName(null, "bind-params", !0);
|
|
2380
2492
|
if (t.hasAttribute(b)) {
|
|
2381
2493
|
const l = t.getRawAttribute(b);
|
|
2382
|
-
r.bindParams = l.split("&").map((
|
|
2494
|
+
r.bindParams = l.split("&").map((d) => d.trim());
|
|
2383
2495
|
}
|
|
2384
2496
|
if (e) {
|
|
2385
|
-
if (t.hasAttribute(
|
|
2386
|
-
const
|
|
2387
|
-
|
|
2497
|
+
if (t.hasAttribute(c.attrName(e, "adjust"))) {
|
|
2498
|
+
const d = t.getRawAttribute(
|
|
2499
|
+
c.attrName(e, "adjust")
|
|
2388
2500
|
);
|
|
2389
|
-
if (
|
|
2390
|
-
const p = document.body.querySelectorAll(
|
|
2391
|
-
p.length > 0 ? (r.adjustFragments = [], p.forEach((
|
|
2392
|
-
const
|
|
2393
|
-
|
|
2394
|
-
})) :
|
|
2501
|
+
if (d) {
|
|
2502
|
+
const p = document.body.querySelectorAll(d);
|
|
2503
|
+
p.length > 0 ? (r.adjustFragments = [], p.forEach((v) => {
|
|
2504
|
+
const w = A.get(v);
|
|
2505
|
+
w && r.adjustFragments.push(w);
|
|
2506
|
+
})) : f.error(
|
|
2395
2507
|
"Haori",
|
|
2396
|
-
`Adjust element not found: ${
|
|
2508
|
+
`Adjust element not found: ${d} (${c.attrName(e, "adjust")})`
|
|
2397
2509
|
);
|
|
2398
2510
|
}
|
|
2399
|
-
if (t.hasAttribute(
|
|
2511
|
+
if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
|
|
2400
2512
|
const p = t.getRawAttribute(
|
|
2401
|
-
|
|
2402
|
-
),
|
|
2403
|
-
isNaN(
|
|
2513
|
+
c.attrName(e, "adjust-value")
|
|
2514
|
+
), v = Number(p);
|
|
2515
|
+
isNaN(v) || (r.adjustValue = v);
|
|
2404
2516
|
}
|
|
2405
2517
|
}
|
|
2406
|
-
if (t.hasAttribute(
|
|
2407
|
-
const
|
|
2408
|
-
`${
|
|
2518
|
+
if (t.hasAttribute(c.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(c.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(c.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(c.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${h.prefix}${e}-after-run`)) {
|
|
2519
|
+
const d = t.getRawAttribute(
|
|
2520
|
+
`${h.prefix}${e}-after-run`
|
|
2409
2521
|
);
|
|
2410
2522
|
try {
|
|
2411
2523
|
r.afterCallback = new Function(
|
|
2412
2524
|
"response",
|
|
2413
2525
|
`
|
|
2414
2526
|
"use strict";
|
|
2415
|
-
${
|
|
2527
|
+
${d}
|
|
2416
2528
|
`
|
|
2417
2529
|
);
|
|
2418
2530
|
} catch (p) {
|
|
2419
|
-
|
|
2531
|
+
f.error("Haori", `Invalid after script: ${p}`);
|
|
2420
2532
|
}
|
|
2421
2533
|
}
|
|
2422
|
-
t.hasAttribute(
|
|
2423
|
-
|
|
2424
|
-
)), t.hasAttribute(
|
|
2425
|
-
|
|
2426
|
-
)), t.hasAttribute(
|
|
2427
|
-
|
|
2534
|
+
t.hasAttribute(c.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2535
|
+
c.attrName(e, "dialog")
|
|
2536
|
+
)), t.hasAttribute(c.attrName(e, "toast")) && (r.toastMessage = t.getAttribute(
|
|
2537
|
+
c.attrName(e, "toast")
|
|
2538
|
+
)), t.hasAttribute(c.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2539
|
+
c.attrName(e, "redirect")
|
|
2428
2540
|
)), [
|
|
2429
2541
|
"reset",
|
|
2430
2542
|
"refetch",
|
|
2431
2543
|
"click",
|
|
2432
2544
|
"open",
|
|
2433
2545
|
"close"
|
|
2434
|
-
].forEach((
|
|
2435
|
-
const p =
|
|
2546
|
+
].forEach((d) => {
|
|
2547
|
+
const p = c.attrName(e, d);
|
|
2436
2548
|
if (!t.hasAttribute(p))
|
|
2437
2549
|
return;
|
|
2438
|
-
const
|
|
2439
|
-
if (
|
|
2440
|
-
const F = A.get(
|
|
2441
|
-
F &&
|
|
2442
|
-
}),
|
|
2443
|
-
switch (
|
|
2550
|
+
const v = t.getRawAttribute(p), w = [];
|
|
2551
|
+
if (v ? (document.body.querySelectorAll(v).forEach((S) => {
|
|
2552
|
+
const F = A.get(S);
|
|
2553
|
+
F && w.push(F);
|
|
2554
|
+
}), w.length === 0 && f.error("Haori", `Element not found: ${v} (${p})`)) : w.push(t), w.length > 0)
|
|
2555
|
+
switch (d) {
|
|
2444
2556
|
case "reset":
|
|
2445
|
-
r.resetFragments =
|
|
2557
|
+
r.resetFragments = w;
|
|
2446
2558
|
break;
|
|
2447
2559
|
case "refetch":
|
|
2448
|
-
r.refetchFragments =
|
|
2560
|
+
r.refetchFragments = w;
|
|
2449
2561
|
break;
|
|
2450
2562
|
case "click":
|
|
2451
|
-
r.clickFragments =
|
|
2563
|
+
r.clickFragments = w;
|
|
2452
2564
|
break;
|
|
2453
2565
|
case "open":
|
|
2454
|
-
r.openFragments =
|
|
2566
|
+
r.openFragments = w;
|
|
2455
2567
|
break;
|
|
2456
2568
|
case "close":
|
|
2457
|
-
r.closeFragments =
|
|
2569
|
+
r.closeFragments = w;
|
|
2458
2570
|
break;
|
|
2459
2571
|
}
|
|
2460
2572
|
});
|
|
2461
2573
|
}
|
|
2462
|
-
if (!e)
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
if (
|
|
2470
|
-
const
|
|
2471
|
-
|
|
2574
|
+
if (!e && (t.hasAttribute(c.attrName(null, "data", !0)) && (r.data = c.resolveDataAttribute(
|
|
2575
|
+
t,
|
|
2576
|
+
c.attrName(null, "data", !0)
|
|
2577
|
+
)), t.hasAttribute(c.attrName(null, "form", !0)))) {
|
|
2578
|
+
const l = t.getRawAttribute(
|
|
2579
|
+
c.attrName(null, "form", !0)
|
|
2580
|
+
);
|
|
2581
|
+
if (l) {
|
|
2582
|
+
const d = document.body.querySelector(l);
|
|
2583
|
+
d !== null ? r.formFragment = E.getFormFragment(
|
|
2584
|
+
A.get(d)
|
|
2585
|
+
) : f.error(
|
|
2586
|
+
"Haori",
|
|
2587
|
+
`Form element not found: ${l} (${c.attrName(null, "fetch-form", !0)})`
|
|
2472
2588
|
);
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
f !== null ? r.formFragment = E.getFormFragment(
|
|
2476
|
-
A.get(f)
|
|
2477
|
-
) : h.error(
|
|
2478
|
-
"Haori",
|
|
2479
|
-
`Form element not found: ${l} (${d.attrName(null, "fetch-form", !0)})`
|
|
2480
|
-
);
|
|
2481
|
-
} else
|
|
2482
|
-
r.formFragment = E.getFormFragment(t);
|
|
2483
|
-
}
|
|
2589
|
+
} else
|
|
2590
|
+
r.formFragment = E.getFormFragment(t);
|
|
2484
2591
|
}
|
|
2485
|
-
return
|
|
2592
|
+
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2486
2593
|
}
|
|
2487
2594
|
/**
|
|
2488
2595
|
* ElementFragment の構造的タイプガード。
|
|
@@ -2503,7 +2610,7 @@ ${f}
|
|
|
2503
2610
|
* @param arg2 イベント名
|
|
2504
2611
|
*/
|
|
2505
2612
|
constructor(t, e = null) {
|
|
2506
|
-
|
|
2613
|
+
c.isElementFragment(t) ? this.options = c.buildOptions(t, e) : this.options = t;
|
|
2507
2614
|
}
|
|
2508
2615
|
/**
|
|
2509
2616
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2516,60 +2623,60 @@ ${f}
|
|
|
2516
2623
|
return Promise.resolve();
|
|
2517
2624
|
let e = this.options.fetchUrl, r = this.options.fetchOptions;
|
|
2518
2625
|
if (this.options.beforeCallback) {
|
|
2519
|
-
const
|
|
2626
|
+
const i = this.options.beforeCallback(
|
|
2520
2627
|
e || null,
|
|
2521
2628
|
r || null
|
|
2522
2629
|
);
|
|
2523
|
-
if (
|
|
2524
|
-
if (
|
|
2630
|
+
if (i != null) {
|
|
2631
|
+
if (i === !1 || typeof i == "object" && i.stop)
|
|
2525
2632
|
return Promise.resolve();
|
|
2526
|
-
typeof
|
|
2633
|
+
typeof i == "object" && (e = "fetchUrl" in i ? i.fetchUrl : e, r = "fetchOptions" in i ? i.fetchOptions : r);
|
|
2527
2634
|
}
|
|
2528
2635
|
}
|
|
2529
2636
|
const n = {};
|
|
2530
2637
|
if (this.options.formFragment) {
|
|
2531
|
-
const
|
|
2532
|
-
Object.assign(n,
|
|
2638
|
+
const i = E.getValues(this.options.formFragment);
|
|
2639
|
+
Object.assign(n, i);
|
|
2533
2640
|
}
|
|
2534
2641
|
this.options.data && typeof this.options.data == "object" && Object.assign(n, this.options.data);
|
|
2535
|
-
const
|
|
2642
|
+
const s = Object.keys(n).length > 0;
|
|
2536
2643
|
if (e) {
|
|
2537
|
-
const
|
|
2538
|
-
|
|
2539
|
-
), o = (
|
|
2644
|
+
const i = { ...r || {} }, a = new Headers(
|
|
2645
|
+
i.headers || void 0
|
|
2646
|
+
), o = (i.method || "GET").toUpperCase();
|
|
2540
2647
|
if (o === "GET" || o === "HEAD" || o === "OPTIONS") {
|
|
2541
|
-
if (
|
|
2648
|
+
if (s) {
|
|
2542
2649
|
const g = new URL(e, window.location.href), u = new URLSearchParams(g.search);
|
|
2543
2650
|
for (const [b, l] of Object.entries(n))
|
|
2544
|
-
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((
|
|
2545
|
-
u.append(b, String(
|
|
2651
|
+
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((d) => {
|
|
2652
|
+
u.append(b, String(d));
|
|
2546
2653
|
}) : typeof l == "object" || typeof l == "function" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
|
|
2547
2654
|
g.search = u.toString(), e = g.toString();
|
|
2548
2655
|
}
|
|
2549
|
-
} else if (
|
|
2656
|
+
} else if (s) {
|
|
2550
2657
|
const g = a.get("Content-Type") || "";
|
|
2551
2658
|
if (/multipart\/form-data/i.test(g)) {
|
|
2552
2659
|
a.delete("Content-Type");
|
|
2553
2660
|
const u = new FormData();
|
|
2554
2661
|
for (const [b, l] of Object.entries(n))
|
|
2555
|
-
l == null ? u.append(b, "") : l instanceof Blob ? u.append(b, l) : Array.isArray(l) ? l.forEach((
|
|
2556
|
-
|
|
2662
|
+
l == null ? u.append(b, "") : l instanceof Blob ? u.append(b, l) : Array.isArray(l) ? l.forEach((d) => u.append(b, String(d))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l));
|
|
2663
|
+
i.body = u;
|
|
2557
2664
|
} else if (/application\/x-www-form-urlencoded/i.test(g)) {
|
|
2558
2665
|
const u = new URLSearchParams();
|
|
2559
2666
|
for (const [b, l] of Object.entries(n))
|
|
2560
|
-
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((
|
|
2561
|
-
|
|
2667
|
+
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((d) => u.append(b, String(d))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
|
|
2668
|
+
i.body = u;
|
|
2562
2669
|
} else
|
|
2563
|
-
a.set("Content-Type", "application/json"),
|
|
2670
|
+
a.set("Content-Type", "application/json"), i.body = JSON.stringify(n);
|
|
2564
2671
|
}
|
|
2565
|
-
if (
|
|
2672
|
+
if (i.headers = a, this.options.targetFragment && e) {
|
|
2566
2673
|
const g = performance.now();
|
|
2567
2674
|
return y.fetchStart(
|
|
2568
2675
|
this.options.targetFragment.getTarget(),
|
|
2569
2676
|
e,
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
), fetch(e,
|
|
2677
|
+
i,
|
|
2678
|
+
s ? n : void 0
|
|
2679
|
+
), fetch(e, i).then((u) => this.handleFetchResult(
|
|
2573
2680
|
u,
|
|
2574
2681
|
e || void 0,
|
|
2575
2682
|
g
|
|
@@ -2580,18 +2687,18 @@ ${f}
|
|
|
2580
2687
|
u
|
|
2581
2688
|
), u;
|
|
2582
2689
|
});
|
|
2583
|
-
} else return e ? fetch(e,
|
|
2690
|
+
} else return e ? fetch(e, i).then((g) => this.handleFetchResult(g, e || void 0)) : Promise.resolve();
|
|
2584
2691
|
} else {
|
|
2585
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
2692
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2586
2693
|
const o = this.options.formFragment, g = o.getTarget();
|
|
2587
2694
|
g.setAttribute(
|
|
2588
|
-
`${
|
|
2695
|
+
`${h.prefix}bind`,
|
|
2589
2696
|
JSON.stringify(n)
|
|
2590
2697
|
);
|
|
2591
2698
|
const u = o.getBindingData();
|
|
2592
2699
|
return Object.assign(u, n), T.setBindingData(g, u);
|
|
2593
2700
|
}
|
|
2594
|
-
const
|
|
2701
|
+
const i = s ? n : {}, a = new Response(JSON.stringify(i), {
|
|
2595
2702
|
headers: { "Content-Type": "application/json" }
|
|
2596
2703
|
});
|
|
2597
2704
|
return this.handleFetchResult(a);
|
|
@@ -2602,7 +2709,7 @@ ${f}
|
|
|
2602
2709
|
* フェッチ後の処理を実行します。
|
|
2603
2710
|
*/
|
|
2604
2711
|
handleFetchResult(t, e, r) {
|
|
2605
|
-
const n =
|
|
2712
|
+
const n = K();
|
|
2606
2713
|
if (!t.ok)
|
|
2607
2714
|
return this.options.targetFragment && e && y.fetchError(
|
|
2608
2715
|
this.options.targetFragment.getTarget(),
|
|
@@ -2617,30 +2724,30 @@ ${f}
|
|
|
2617
2724
|
t.status,
|
|
2618
2725
|
r
|
|
2619
2726
|
), this.options.afterCallback) {
|
|
2620
|
-
const
|
|
2621
|
-
if (
|
|
2622
|
-
if (
|
|
2727
|
+
const i = this.options.afterCallback(t);
|
|
2728
|
+
if (i != null) {
|
|
2729
|
+
if (i === !1 || typeof i == "object" && i.stop)
|
|
2623
2730
|
return Promise.resolve();
|
|
2624
|
-
typeof
|
|
2731
|
+
typeof i == "object" && "response" in i && (t = "response" in i ? i.response : t);
|
|
2625
2732
|
}
|
|
2626
2733
|
}
|
|
2627
|
-
const
|
|
2628
|
-
return
|
|
2629
|
-
|
|
2630
|
-
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((
|
|
2631
|
-
|
|
2632
|
-
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((
|
|
2633
|
-
const a =
|
|
2734
|
+
const s = [];
|
|
2735
|
+
return 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()), this.options.resetFragments && this.options.resetFragments.length > 0 && this.options.resetFragments.forEach((i) => {
|
|
2736
|
+
s.push(E.reset(i));
|
|
2737
|
+
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((i) => {
|
|
2738
|
+
s.push(new c(i, null).run());
|
|
2739
|
+
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((i) => {
|
|
2740
|
+
const a = i.getTarget();
|
|
2634
2741
|
typeof a.click == "function" ? a.click() : a.dispatchEvent(
|
|
2635
2742
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
2636
2743
|
);
|
|
2637
|
-
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((
|
|
2638
|
-
const a =
|
|
2639
|
-
a instanceof HTMLElement ?
|
|
2640
|
-
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((
|
|
2641
|
-
const a =
|
|
2642
|
-
a instanceof HTMLElement ?
|
|
2643
|
-
}), Promise.all(
|
|
2744
|
+
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((i) => {
|
|
2745
|
+
const a = i.getTarget();
|
|
2746
|
+
a instanceof HTMLElement ? s.push(n.openDialog(a)) : f.error("Haori", "Element is not an HTML element: ", a);
|
|
2747
|
+
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((i) => {
|
|
2748
|
+
const a = i.getTarget();
|
|
2749
|
+
a instanceof HTMLElement ? s.push(n.closeDialog(a)) : f.error("Haori", "Element is not an HTML element: ", a);
|
|
2750
|
+
}), Promise.all(s).then(() => this.options.dialogMessage ? n.dialog(this.options.dialogMessage) : Promise.resolve()).then(() => this.options.toastMessage ? n.toast(this.options.toastMessage, "info") : Promise.resolve()).then(() => (this.options.redirectUrl && (window.location.href = this.options.redirectUrl), Promise.resolve()));
|
|
2644
2751
|
}
|
|
2645
2752
|
/**
|
|
2646
2753
|
* フェッチエラー応答のメッセージを適切な要素へ伝播します。
|
|
@@ -2648,38 +2755,38 @@ ${f}
|
|
|
2648
2755
|
async handleFetchError(t) {
|
|
2649
2756
|
let e = null;
|
|
2650
2757
|
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = E.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2651
|
-
const r = async (
|
|
2652
|
-
const
|
|
2653
|
-
await
|
|
2758
|
+
const r = async (s) => {
|
|
2759
|
+
const i = e ? e.getTarget() : document.body;
|
|
2760
|
+
await K().addErrorMessage(i, s);
|
|
2654
2761
|
};
|
|
2655
2762
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
2656
2763
|
try {
|
|
2657
|
-
const
|
|
2658
|
-
if (
|
|
2659
|
-
if (typeof
|
|
2660
|
-
for (const a of
|
|
2661
|
-
typeof a == "string" &&
|
|
2662
|
-
if (
|
|
2663
|
-
for (const [a, o] of Object.entries(
|
|
2664
|
-
Array.isArray(o) ?
|
|
2665
|
-
`) }) : typeof o == "string" ?
|
|
2666
|
-
if (
|
|
2667
|
-
for (const [a, o] of Object.entries(
|
|
2668
|
-
a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ?
|
|
2669
|
-
`) }) : typeof o == "string" &&
|
|
2764
|
+
const s = await t.json(), i = [];
|
|
2765
|
+
if (s && typeof s == "object") {
|
|
2766
|
+
if (typeof s.message == "string" && i.push({ message: s.message }), Array.isArray(s.messages))
|
|
2767
|
+
for (const a of s.messages)
|
|
2768
|
+
typeof a == "string" && i.push({ message: a });
|
|
2769
|
+
if (s.errors && typeof s.errors == "object")
|
|
2770
|
+
for (const [a, o] of Object.entries(s.errors))
|
|
2771
|
+
Array.isArray(o) ? i.push({ key: a, message: o.join(`
|
|
2772
|
+
`) }) : typeof o == "string" ? i.push({ key: a, message: o }) : o != null && i.push({ key: a, message: String(o) });
|
|
2773
|
+
if (i.length === 0)
|
|
2774
|
+
for (const [a, o] of Object.entries(s))
|
|
2775
|
+
a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ? i.push({ key: a, message: o.join(`
|
|
2776
|
+
`) }) : typeof o == "string" && i.push({ key: a, message: o }));
|
|
2670
2777
|
}
|
|
2671
|
-
if (
|
|
2778
|
+
if (i.length === 0) {
|
|
2672
2779
|
await r(`${t.status} ${t.statusText}`);
|
|
2673
2780
|
return;
|
|
2674
2781
|
}
|
|
2675
|
-
for (const a of
|
|
2782
|
+
for (const a of i)
|
|
2676
2783
|
a.key && e ? await E.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
2677
2784
|
return;
|
|
2678
2785
|
} catch {
|
|
2679
2786
|
}
|
|
2680
2787
|
try {
|
|
2681
|
-
const
|
|
2682
|
-
|
|
2788
|
+
const s = await t.text();
|
|
2789
|
+
s && s.trim().length > 0 ? await r(s.trim()) : await r(`${t.status} ${t.statusText}`);
|
|
2683
2790
|
} catch {
|
|
2684
2791
|
await r(`${t.status} ${t.statusText}`);
|
|
2685
2792
|
}
|
|
@@ -2718,7 +2825,7 @@ ${f}
|
|
|
2718
2825
|
*/
|
|
2719
2826
|
confirm() {
|
|
2720
2827
|
const t = this.options.confirmMessage;
|
|
2721
|
-
return t == null ? Promise.resolve(!0) :
|
|
2828
|
+
return t == null ? Promise.resolve(!0) : K().confirm(t);
|
|
2722
2829
|
}
|
|
2723
2830
|
/**
|
|
2724
2831
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -2728,26 +2835,26 @@ ${f}
|
|
|
2728
2835
|
bindResult(t) {
|
|
2729
2836
|
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) => {
|
|
2730
2837
|
if (this.options.bindParams) {
|
|
2731
|
-
const
|
|
2732
|
-
this.options.bindParams.forEach((
|
|
2733
|
-
r && typeof r == "object" &&
|
|
2734
|
-
}), r =
|
|
2838
|
+
const s = {};
|
|
2839
|
+
this.options.bindParams.forEach((i) => {
|
|
2840
|
+
r && typeof r == "object" && i in r && (s[i] = r[i]);
|
|
2841
|
+
}), r = s;
|
|
2735
2842
|
}
|
|
2736
2843
|
const n = [];
|
|
2737
2844
|
if (this.options.bindArg)
|
|
2738
|
-
this.options.bindFragments.forEach((
|
|
2739
|
-
const
|
|
2740
|
-
|
|
2845
|
+
this.options.bindFragments.forEach((s) => {
|
|
2846
|
+
const i = s.getBindingData();
|
|
2847
|
+
i[this.options.bindArg] = r, n.push(T.setBindingData(s.getTarget(), i));
|
|
2741
2848
|
});
|
|
2742
2849
|
else {
|
|
2743
2850
|
if (typeof r == "string")
|
|
2744
|
-
return
|
|
2851
|
+
return f.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
2745
2852
|
new Error("string data cannot be bound without a bindArg.")
|
|
2746
2853
|
);
|
|
2747
|
-
this.options.bindFragments.forEach((
|
|
2854
|
+
this.options.bindFragments.forEach((s) => {
|
|
2748
2855
|
n.push(
|
|
2749
2856
|
T.setBindingData(
|
|
2750
|
-
|
|
2857
|
+
s.getTarget(),
|
|
2751
2858
|
r
|
|
2752
2859
|
)
|
|
2753
2860
|
);
|
|
@@ -2767,8 +2874,8 @@ ${f}
|
|
|
2767
2874
|
for (const r of this.options.adjustFragments) {
|
|
2768
2875
|
let n = r.getValue();
|
|
2769
2876
|
(n == null || n === "") && (n = "0");
|
|
2770
|
-
let
|
|
2771
|
-
isNaN(
|
|
2877
|
+
let s = Number(n);
|
|
2878
|
+
isNaN(s) && (s = 0), s += t, e.push(r.setValue(String(s)));
|
|
2772
2879
|
}
|
|
2773
2880
|
return Promise.all(e).then(() => {
|
|
2774
2881
|
});
|
|
@@ -2780,11 +2887,11 @@ ${f}
|
|
|
2780
2887
|
*/
|
|
2781
2888
|
getRowFragment() {
|
|
2782
2889
|
if (!this.options.targetFragment)
|
|
2783
|
-
return
|
|
2890
|
+
return f.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
2784
2891
|
const t = this.options.targetFragment.closestByAttribute(
|
|
2785
|
-
`${
|
|
2892
|
+
`${h.prefix}row`
|
|
2786
2893
|
);
|
|
2787
|
-
return t || (
|
|
2894
|
+
return t || (f.error("Haori", "Row fragment not found."), null);
|
|
2788
2895
|
}
|
|
2789
2896
|
/**
|
|
2790
2897
|
* 行を追加します。
|
|
@@ -2815,7 +2922,7 @@ ${f}
|
|
|
2815
2922
|
if (!t)
|
|
2816
2923
|
return Promise.reject(new Error("Row fragment not found."));
|
|
2817
2924
|
const e = t.getParent();
|
|
2818
|
-
return e && e.getChildElementFragments().filter((n) => !n.hasAttribute(`${
|
|
2925
|
+
return e && e.getChildElementFragments().filter((n) => !n.hasAttribute(`${h.prefix}each-before`) && !n.hasAttribute(`${h.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
2819
2926
|
}
|
|
2820
2927
|
/**
|
|
2821
2928
|
* 前の行へ移動します。
|
|
@@ -2851,8 +2958,10 @@ ${f}
|
|
|
2851
2958
|
const r = t.getParent();
|
|
2852
2959
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
2853
2960
|
}
|
|
2854
|
-
}
|
|
2855
|
-
|
|
2961
|
+
};
|
|
2962
|
+
c.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, c.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
2963
|
+
let j = c;
|
|
2964
|
+
class _ {
|
|
2856
2965
|
/**
|
|
2857
2966
|
* URLのクエリパラメータを取得します。
|
|
2858
2967
|
*
|
|
@@ -2860,12 +2969,12 @@ class Z {
|
|
|
2860
2969
|
*/
|
|
2861
2970
|
static readParams() {
|
|
2862
2971
|
const t = {}, e = window.location.search;
|
|
2863
|
-
return new URLSearchParams(e).forEach((n,
|
|
2864
|
-
t[
|
|
2972
|
+
return new URLSearchParams(e).forEach((n, s) => {
|
|
2973
|
+
t[s] = n;
|
|
2865
2974
|
}), t;
|
|
2866
2975
|
}
|
|
2867
2976
|
}
|
|
2868
|
-
class
|
|
2977
|
+
class tt {
|
|
2869
2978
|
/**
|
|
2870
2979
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
2871
2980
|
*
|
|
@@ -2882,24 +2991,24 @@ class _ {
|
|
|
2882
2991
|
let r;
|
|
2883
2992
|
try {
|
|
2884
2993
|
r = await fetch(t, e);
|
|
2885
|
-
} catch (
|
|
2886
|
-
throw
|
|
2994
|
+
} catch (s) {
|
|
2995
|
+
throw f.error("[Haori]", "Failed to fetch import source:", t, s), new Error(`Failed to fetch: ${t}`);
|
|
2887
2996
|
}
|
|
2888
2997
|
if (!r.ok) {
|
|
2889
|
-
const
|
|
2890
|
-
throw
|
|
2998
|
+
const s = `${r.status} ${r.statusText}`;
|
|
2999
|
+
throw f.error("[Haori]", "Import HTTP error:", t, s), new Error(`Failed to load ${t}: ${s}`);
|
|
2891
3000
|
}
|
|
2892
3001
|
let n;
|
|
2893
3002
|
try {
|
|
2894
3003
|
n = await r.text();
|
|
2895
|
-
} catch (
|
|
2896
|
-
throw
|
|
3004
|
+
} catch (s) {
|
|
3005
|
+
throw f.error("[Haori]", "Failed to read response text:", t, s), new Error(`Failed to read response from: ${t}`);
|
|
2897
3006
|
}
|
|
2898
3007
|
try {
|
|
2899
|
-
const
|
|
2900
|
-
return
|
|
2901
|
-
} catch (
|
|
2902
|
-
return
|
|
3008
|
+
const i = new DOMParser().parseFromString(n, "text/html");
|
|
3009
|
+
return i && i.body ? i.body.innerHTML : (f.warn("[Haori]", "No body found in imported document:", t), n);
|
|
3010
|
+
} catch (s) {
|
|
3011
|
+
return f.error("[Haori]", "Failed to parse imported HTML:", t, s), n;
|
|
2903
3012
|
}
|
|
2904
3013
|
}
|
|
2905
3014
|
}
|
|
@@ -2912,7 +3021,7 @@ const m = class m {
|
|
|
2912
3021
|
*/
|
|
2913
3022
|
static isDeferredAttributeName(t) {
|
|
2914
3023
|
return m.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
2915
|
-
(e) => t === `${
|
|
3024
|
+
(e) => t === `${h.prefix}${e}`
|
|
2916
3025
|
);
|
|
2917
3026
|
}
|
|
2918
3027
|
/**
|
|
@@ -2927,34 +3036,34 @@ const m = class m {
|
|
|
2927
3036
|
return Promise.resolve();
|
|
2928
3037
|
t.parentNode && (A.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
2929
3038
|
const r = [], n = /* @__PURE__ */ new Set();
|
|
2930
|
-
for (const
|
|
2931
|
-
const
|
|
2932
|
-
e.hasAttribute(
|
|
3039
|
+
for (const s of m.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3040
|
+
const i = h.prefix + s;
|
|
3041
|
+
e.hasAttribute(i) && (r.push(
|
|
2933
3042
|
m.setAttribute(
|
|
2934
3043
|
e.getTarget(),
|
|
2935
|
-
|
|
2936
|
-
e.getRawAttribute(
|
|
3044
|
+
i,
|
|
3045
|
+
e.getRawAttribute(i)
|
|
2937
3046
|
)
|
|
2938
|
-
), n.add(
|
|
3047
|
+
), n.add(i));
|
|
2939
3048
|
}
|
|
2940
|
-
for (const
|
|
2941
|
-
if (n.has(
|
|
3049
|
+
for (const s of e.getAttributeNames()) {
|
|
3050
|
+
if (n.has(s) || m.isDeferredAttributeName(s))
|
|
2942
3051
|
continue;
|
|
2943
|
-
const
|
|
2944
|
-
|
|
3052
|
+
const i = e.getRawAttribute(s);
|
|
3053
|
+
i !== null && r.push(m.setAttribute(e.getTarget(), s, i));
|
|
2945
3054
|
}
|
|
2946
|
-
for (const
|
|
2947
|
-
const
|
|
2948
|
-
e.hasAttribute(
|
|
3055
|
+
for (const s of m.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3056
|
+
const i = h.prefix + s;
|
|
3057
|
+
e.hasAttribute(i) && (r.push(
|
|
2949
3058
|
m.setAttribute(
|
|
2950
3059
|
e.getTarget(),
|
|
2951
|
-
|
|
2952
|
-
e.getRawAttribute(
|
|
3060
|
+
i,
|
|
3061
|
+
e.getRawAttribute(i)
|
|
2953
3062
|
)
|
|
2954
|
-
), n.add(
|
|
3063
|
+
), n.add(i));
|
|
2955
3064
|
}
|
|
2956
|
-
return e.getChildren().forEach((
|
|
2957
|
-
|
|
3065
|
+
return e.getChildren().forEach((s) => {
|
|
3066
|
+
s instanceof x ? r.push(m.scan(s.getTarget())) : s instanceof I && r.push(m.evaluateText(s));
|
|
2958
3067
|
}), Promise.all(r).then(() => {
|
|
2959
3068
|
});
|
|
2960
3069
|
}
|
|
@@ -2968,51 +3077,51 @@ const m = class m {
|
|
|
2968
3077
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
2969
3078
|
*/
|
|
2970
3079
|
static setAttribute(t, e, r) {
|
|
2971
|
-
const n = A.get(t),
|
|
3080
|
+
const n = A.get(t), s = [];
|
|
2972
3081
|
switch (e) {
|
|
2973
|
-
case `${
|
|
3082
|
+
case `${h.prefix}bind`: {
|
|
2974
3083
|
r === null ? (n.clearBindingDataCache(), n.setBindingData({})) : n.setBindingData(m.parseDataBind(r));
|
|
2975
3084
|
break;
|
|
2976
3085
|
}
|
|
2977
|
-
case `${
|
|
2978
|
-
|
|
3086
|
+
case `${h.prefix}if`:
|
|
3087
|
+
s.push(m.evaluateIf(n));
|
|
2979
3088
|
break;
|
|
2980
|
-
case `${
|
|
2981
|
-
|
|
3089
|
+
case `${h.prefix}each`:
|
|
3090
|
+
s.push(m.evaluateEach(n));
|
|
2982
3091
|
break;
|
|
2983
|
-
case `${
|
|
2984
|
-
|
|
3092
|
+
case `${h.prefix}fetch`:
|
|
3093
|
+
s.push(new j(n, null).run());
|
|
2985
3094
|
break;
|
|
2986
|
-
case `${
|
|
3095
|
+
case `${h.prefix}import`: {
|
|
2987
3096
|
if (typeof r == "string") {
|
|
2988
|
-
const
|
|
2989
|
-
y.importStart(
|
|
2990
|
-
|
|
3097
|
+
const i = n.getTarget(), a = performance.now();
|
|
3098
|
+
y.importStart(i, r), s.push(
|
|
3099
|
+
tt.load(r).then((o) => {
|
|
2991
3100
|
const g = new TextEncoder().encode(o).length;
|
|
2992
3101
|
return N.enqueue(() => {
|
|
2993
|
-
|
|
3102
|
+
i.innerHTML = o;
|
|
2994
3103
|
}).then(() => {
|
|
2995
|
-
y.importEnd(
|
|
3104
|
+
y.importEnd(i, r, g, a);
|
|
2996
3105
|
});
|
|
2997
3106
|
}).catch((o) => {
|
|
2998
|
-
y.importError(
|
|
3107
|
+
y.importError(i, r, o), f.error("[Haori]", "Failed to import HTML:", r, o);
|
|
2999
3108
|
})
|
|
3000
3109
|
);
|
|
3001
3110
|
}
|
|
3002
3111
|
break;
|
|
3003
3112
|
}
|
|
3004
|
-
case `${
|
|
3005
|
-
const
|
|
3006
|
-
if (
|
|
3113
|
+
case `${h.prefix}url-param`: {
|
|
3114
|
+
const i = n.getAttribute(`${h.prefix}url-arg`), a = _.readParams();
|
|
3115
|
+
if (i === null)
|
|
3007
3116
|
m.setBindingData(t, a);
|
|
3008
3117
|
else {
|
|
3009
3118
|
const o = n.getRawBindingData() || {};
|
|
3010
|
-
o[String(
|
|
3119
|
+
o[String(i)] = a, m.setBindingData(t, o);
|
|
3011
3120
|
}
|
|
3012
3121
|
break;
|
|
3013
3122
|
}
|
|
3014
3123
|
}
|
|
3015
|
-
return r === null ?
|
|
3124
|
+
return r === null ? s.push(n.removeAttribute(e)) : s.push(n.setAttribute(e, r)), Promise.all(s).then(() => {
|
|
3016
3125
|
});
|
|
3017
3126
|
}
|
|
3018
3127
|
/**
|
|
@@ -3026,10 +3135,10 @@ const m = class m {
|
|
|
3026
3135
|
static setBindingData(t, e) {
|
|
3027
3136
|
const r = A.get(t), n = r.getRawBindingData();
|
|
3028
3137
|
r.setBindingData(e);
|
|
3029
|
-
const
|
|
3030
|
-
return
|
|
3031
|
-
r.setAttribute(`${
|
|
3032
|
-
),
|
|
3138
|
+
const s = [];
|
|
3139
|
+
return s.push(
|
|
3140
|
+
r.setAttribute(`${h.prefix}bind`, JSON.stringify(e))
|
|
3141
|
+
), s.push(m.evaluateAll(r)), y.bindChange(t, n, e, "manual"), Promise.all(s).then(() => {
|
|
3033
3142
|
});
|
|
3034
3143
|
}
|
|
3035
3144
|
/**
|
|
@@ -3043,12 +3152,12 @@ const m = class m {
|
|
|
3043
3152
|
try {
|
|
3044
3153
|
return JSON.parse(t);
|
|
3045
3154
|
} catch (e) {
|
|
3046
|
-
return
|
|
3155
|
+
return f.error("[Haori]", "Invalid JSON in data-bind:", e), {};
|
|
3047
3156
|
}
|
|
3048
3157
|
else {
|
|
3049
3158
|
const e = new URLSearchParams(t), r = {};
|
|
3050
|
-
for (const [n,
|
|
3051
|
-
r[n] !== void 0 ? Array.isArray(r[n]) ? r[n].push(
|
|
3159
|
+
for (const [n, s] of e.entries())
|
|
3160
|
+
r[n] !== void 0 ? Array.isArray(r[n]) ? r[n].push(s) : r[n] = [r[n], s] : r[n] = s;
|
|
3052
3161
|
return r;
|
|
3053
3162
|
}
|
|
3054
3163
|
}
|
|
@@ -3062,8 +3171,8 @@ const m = class m {
|
|
|
3062
3171
|
const r = A.get(t);
|
|
3063
3172
|
if (r.isSkipMutationNodes())
|
|
3064
3173
|
return;
|
|
3065
|
-
const n = A.get(e.nextSibling),
|
|
3066
|
-
|
|
3174
|
+
const n = A.get(e.nextSibling), s = A.get(e);
|
|
3175
|
+
s && (r.insertBefore(s, n), s instanceof x ? m.scan(s.getTarget()) : s instanceof I && m.evaluateText(s));
|
|
3067
3176
|
}
|
|
3068
3177
|
/**
|
|
3069
3178
|
* ノードを親要素から削除します。
|
|
@@ -3103,11 +3212,11 @@ const m = class m {
|
|
|
3103
3212
|
return Promise.resolve();
|
|
3104
3213
|
const n = [];
|
|
3105
3214
|
n.push(r.setValue(e));
|
|
3106
|
-
const
|
|
3107
|
-
if (
|
|
3108
|
-
const
|
|
3215
|
+
const s = m.getFormFragment(r);
|
|
3216
|
+
if (s) {
|
|
3217
|
+
const i = E.getValues(s), a = s.getAttribute(`${h.prefix}form-arg`);
|
|
3109
3218
|
let o;
|
|
3110
|
-
a ? (o =
|
|
3219
|
+
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = i) : o = i, n.push(m.setBindingData(s.getTarget(), o));
|
|
3111
3220
|
}
|
|
3112
3221
|
return Promise.all(n).then(() => {
|
|
3113
3222
|
});
|
|
@@ -3132,8 +3241,8 @@ const m = class m {
|
|
|
3132
3241
|
*/
|
|
3133
3242
|
static evaluateAll(t) {
|
|
3134
3243
|
const e = [];
|
|
3135
|
-
return t.hasAttribute(`${
|
|
3136
|
-
r instanceof
|
|
3244
|
+
return t.hasAttribute(`${h.prefix}if`) && e.push(m.evaluateIf(t)), t.hasAttribute(`${h.prefix}each`) && e.push(m.evaluateEach(t)), t.getChildren().forEach((r) => {
|
|
3245
|
+
r instanceof x ? e.push(m.evaluateAll(r)) : r instanceof I && e.push(m.evaluateText(r));
|
|
3137
3246
|
}), Promise.all(e).then(() => {
|
|
3138
3247
|
});
|
|
3139
3248
|
}
|
|
@@ -3154,7 +3263,7 @@ const m = class m {
|
|
|
3154
3263
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3155
3264
|
*/
|
|
3156
3265
|
static evaluateIf(t) {
|
|
3157
|
-
const e = [], r = t.getAttribute(`${
|
|
3266
|
+
const e = [], r = t.getAttribute(`${h.prefix}if`);
|
|
3158
3267
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3159
3268
|
t.hide().then(() => {
|
|
3160
3269
|
y.hide(t.getTarget());
|
|
@@ -3178,20 +3287,20 @@ const m = class m {
|
|
|
3178
3287
|
let e = t.getTemplate();
|
|
3179
3288
|
if (e === null) {
|
|
3180
3289
|
let n = !1;
|
|
3181
|
-
t.getChildren().forEach((
|
|
3182
|
-
if (!n &&
|
|
3183
|
-
if (
|
|
3290
|
+
t.getChildren().forEach((i) => {
|
|
3291
|
+
if (!n && i instanceof x) {
|
|
3292
|
+
if (i.hasAttribute(`${h.prefix}each-before`) || i.hasAttribute(`${h.prefix}each-after`))
|
|
3184
3293
|
return;
|
|
3185
|
-
e =
|
|
3186
|
-
const a =
|
|
3187
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3294
|
+
e = i.clone(), t.setTemplate(e), n = !0, t.removeChild(i);
|
|
3295
|
+
const a = i.getTarget();
|
|
3296
|
+
a.parentNode && a.parentNode.removeChild(a), i.setMounted(!1);
|
|
3188
3297
|
}
|
|
3189
3298
|
});
|
|
3190
|
-
const
|
|
3191
|
-
return Array.isArray(
|
|
3299
|
+
const s = t.getAttribute(`${h.prefix}each`);
|
|
3300
|
+
return Array.isArray(s) ? this.updateDiff(t, s) : (f.error("[Haori]", "Invalid each attribute:", s), Promise.reject(new Error("Invalid each attribute.")));
|
|
3192
3301
|
}
|
|
3193
|
-
const r = t.getAttribute(`${
|
|
3194
|
-
return Array.isArray(r) ? this.updateDiff(t, r) : (
|
|
3302
|
+
const r = t.getAttribute(`${h.prefix}each`);
|
|
3303
|
+
return Array.isArray(r) ? this.updateDiff(t, r) : (f.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3195
3304
|
}
|
|
3196
3305
|
/**
|
|
3197
3306
|
* 差分を更新します。
|
|
@@ -3202,68 +3311,68 @@ const m = class m {
|
|
|
3202
3311
|
static updateDiff(t, e) {
|
|
3203
3312
|
const r = t.getTemplate();
|
|
3204
3313
|
if (r === null)
|
|
3205
|
-
return
|
|
3206
|
-
let n = t.getAttribute(`${
|
|
3314
|
+
return f.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3315
|
+
let n = t.getAttribute(`${h.prefix}each-index`);
|
|
3207
3316
|
n && (n = String(n));
|
|
3208
|
-
const
|
|
3209
|
-
e.forEach((p,
|
|
3210
|
-
const
|
|
3317
|
+
const s = t.getAttribute(`${h.prefix}each-key`), i = t.getAttribute(`${h.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3318
|
+
e.forEach((p, v) => {
|
|
3319
|
+
const w = m.createListKey(
|
|
3211
3320
|
p,
|
|
3212
|
-
|
|
3213
|
-
|
|
3321
|
+
s ? String(s) : null,
|
|
3322
|
+
v
|
|
3214
3323
|
);
|
|
3215
|
-
o.push(
|
|
3324
|
+
o.push(w), a.set(w, { item: p, itemIndex: v });
|
|
3216
3325
|
});
|
|
3217
3326
|
const g = [];
|
|
3218
|
-
let u = t.getChildren().filter((p) => p instanceof
|
|
3219
|
-
(p) => !p.hasAttribute(`${
|
|
3327
|
+
let u = t.getChildren().filter((p) => p instanceof x).filter(
|
|
3328
|
+
(p) => !p.hasAttribute(`${h.prefix}each-before`) && !p.hasAttribute(`${h.prefix}each-after`)
|
|
3220
3329
|
);
|
|
3221
3330
|
u = u.filter((p) => o.indexOf(String(p.getListKey())) === -1 ? (g.push(p.remove()), !1) : !0);
|
|
3222
|
-
const b = u.map((p) => p.getListKey()), l = t.getChildren().filter((p) => p instanceof
|
|
3223
|
-
let
|
|
3224
|
-
return o.forEach((p,
|
|
3225
|
-
const
|
|
3331
|
+
const b = u.map((p) => p.getListKey()), l = t.getChildren().filter((p) => p instanceof x).filter((p) => p.hasAttribute(`${h.prefix}each-before`)).length;
|
|
3332
|
+
let d = Promise.resolve();
|
|
3333
|
+
return o.forEach((p, v) => {
|
|
3334
|
+
const w = b.indexOf(p), { item: $, itemIndex: S } = a.get(p);
|
|
3226
3335
|
let F;
|
|
3227
|
-
if (
|
|
3228
|
-
F = u[
|
|
3336
|
+
if (w !== -1)
|
|
3337
|
+
F = u[w], m.updateRowFragment(
|
|
3229
3338
|
F,
|
|
3230
|
-
|
|
3339
|
+
$,
|
|
3231
3340
|
n,
|
|
3232
|
-
|
|
3233
|
-
|
|
3341
|
+
S,
|
|
3342
|
+
i ? String(i) : null,
|
|
3234
3343
|
p
|
|
3235
|
-
), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache(),
|
|
3344
|
+
), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache(), d = d.then(() => m.evaluateAll(F));
|
|
3236
3345
|
else {
|
|
3237
3346
|
F = r.clone(), m.updateRowFragment(
|
|
3238
3347
|
F,
|
|
3239
|
-
|
|
3348
|
+
$,
|
|
3240
3349
|
n,
|
|
3241
|
-
|
|
3242
|
-
|
|
3350
|
+
S,
|
|
3351
|
+
i ? String(i) : null,
|
|
3243
3352
|
p
|
|
3244
3353
|
), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache();
|
|
3245
|
-
const
|
|
3246
|
-
|
|
3354
|
+
const Y = l + v;
|
|
3355
|
+
d = d.then(
|
|
3247
3356
|
() => t.insertBefore(
|
|
3248
3357
|
F,
|
|
3249
|
-
t.getChildren()[
|
|
3358
|
+
t.getChildren()[Y] || null
|
|
3250
3359
|
).then(() => m.evaluateAll(F))
|
|
3251
3360
|
);
|
|
3252
3361
|
}
|
|
3253
|
-
}), Promise.all(g).then(() =>
|
|
3362
|
+
}), Promise.all(g).then(() => d).then(() => {
|
|
3254
3363
|
const p = o.filter(
|
|
3255
|
-
(
|
|
3256
|
-
),
|
|
3257
|
-
(
|
|
3258
|
-
),
|
|
3259
|
-
(
|
|
3260
|
-
),
|
|
3261
|
-
(
|
|
3364
|
+
(S) => S !== null
|
|
3365
|
+
), v = b.filter(
|
|
3366
|
+
(S) => S !== null
|
|
3367
|
+
), w = p.filter(
|
|
3368
|
+
(S) => !v.includes(S)
|
|
3369
|
+
), $ = v.filter(
|
|
3370
|
+
(S) => !p.includes(S)
|
|
3262
3371
|
);
|
|
3263
3372
|
y.eachUpdate(
|
|
3264
3373
|
t.getTarget(),
|
|
3265
|
-
|
|
3266
|
-
|
|
3374
|
+
w,
|
|
3375
|
+
$,
|
|
3267
3376
|
p
|
|
3268
3377
|
);
|
|
3269
3378
|
});
|
|
@@ -3280,8 +3389,8 @@ const m = class m {
|
|
|
3280
3389
|
let n;
|
|
3281
3390
|
if (typeof t == "object" && t !== null)
|
|
3282
3391
|
if (e) {
|
|
3283
|
-
const
|
|
3284
|
-
|
|
3392
|
+
const s = t[e];
|
|
3393
|
+
s == null ? n = `__index_${r}` : typeof s == "object" ? n = JSON.stringify(s) : n = String(s);
|
|
3285
3394
|
} else
|
|
3286
3395
|
n = `__index_${r}`;
|
|
3287
3396
|
else
|
|
@@ -3298,29 +3407,29 @@ const m = class m {
|
|
|
3298
3407
|
* @param arg バインドデータパラメータ名
|
|
3299
3408
|
* @param listKey リストキー
|
|
3300
3409
|
*/
|
|
3301
|
-
static updateRowFragment(t, e, r, n,
|
|
3410
|
+
static updateRowFragment(t, e, r, n, s, i) {
|
|
3302
3411
|
let a = e;
|
|
3303
3412
|
if (typeof e == "object" && e !== null)
|
|
3304
|
-
a = { ...e }, r && (a[r] = n),
|
|
3305
|
-
[
|
|
3413
|
+
a = { ...e }, r && (a[r] = n), s && (a = {
|
|
3414
|
+
[s]: a
|
|
3306
3415
|
});
|
|
3307
|
-
else if (
|
|
3416
|
+
else if (s)
|
|
3308
3417
|
a = {
|
|
3309
|
-
[
|
|
3418
|
+
[s]: e
|
|
3310
3419
|
}, r && (a[r] = n);
|
|
3311
3420
|
else {
|
|
3312
|
-
|
|
3421
|
+
f.error(
|
|
3313
3422
|
"[Haori]",
|
|
3314
|
-
`Primitive value requires '${
|
|
3423
|
+
`Primitive value requires '${h.prefix}each-arg' attribute: ${e}`
|
|
3315
3424
|
);
|
|
3316
3425
|
return;
|
|
3317
3426
|
}
|
|
3318
|
-
t.setListKey(
|
|
3427
|
+
t.setListKey(i), t.setAttribute(`${h.prefix}row`, i), t.setBindingData(a);
|
|
3319
3428
|
}
|
|
3320
3429
|
};
|
|
3321
3430
|
m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"];
|
|
3322
3431
|
let T = m;
|
|
3323
|
-
class
|
|
3432
|
+
class et {
|
|
3324
3433
|
/**
|
|
3325
3434
|
* コンストラクタ。
|
|
3326
3435
|
*
|
|
@@ -3329,7 +3438,7 @@ class tt {
|
|
|
3329
3438
|
constructor(t = document) {
|
|
3330
3439
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
3331
3440
|
const e = document.documentElement, r = A.get(e);
|
|
3332
|
-
r && new
|
|
3441
|
+
r && new j(r, "load").run();
|
|
3333
3442
|
}, this.root = t;
|
|
3334
3443
|
}
|
|
3335
3444
|
/**
|
|
@@ -3356,8 +3465,8 @@ class tt {
|
|
|
3356
3465
|
if (!r)
|
|
3357
3466
|
return;
|
|
3358
3467
|
const n = A.get(r);
|
|
3359
|
-
n && (e === "change" && n instanceof
|
|
3360
|
-
|
|
3468
|
+
n && (e === "change" && n instanceof x && n.syncValue(), new j(n, e).run().catch((s) => {
|
|
3469
|
+
f.error("[Haori]", "Procedure execution error:", s);
|
|
3361
3470
|
}));
|
|
3362
3471
|
}
|
|
3363
3472
|
/**
|
|
@@ -3383,7 +3492,7 @@ const C = class C {
|
|
|
3383
3492
|
T.scan(document.head),
|
|
3384
3493
|
T.scan(document.body)
|
|
3385
3494
|
]), [e, r] = t;
|
|
3386
|
-
e.status !== "fulfilled" &&
|
|
3495
|
+
e.status !== "fulfilled" && f.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && f.error("[Haori]", "Failed to build body fragment:", r.reason), C.observe(document.head), C.observe(document.body), new et().start();
|
|
3387
3496
|
}
|
|
3388
3497
|
/**
|
|
3389
3498
|
* 指定された要素を監視します。
|
|
@@ -3396,40 +3505,40 @@ const C = class C {
|
|
|
3396
3505
|
try {
|
|
3397
3506
|
switch (n.type) {
|
|
3398
3507
|
case "attributes": {
|
|
3399
|
-
|
|
3508
|
+
f.info(
|
|
3400
3509
|
"[Haori]",
|
|
3401
3510
|
"Attribute changed:",
|
|
3402
3511
|
n.target,
|
|
3403
3512
|
n.attributeName
|
|
3404
3513
|
);
|
|
3405
|
-
const
|
|
3514
|
+
const s = n.target;
|
|
3406
3515
|
T.setAttribute(
|
|
3407
|
-
|
|
3516
|
+
s,
|
|
3408
3517
|
n.attributeName,
|
|
3409
|
-
|
|
3518
|
+
s.getAttribute(n.attributeName)
|
|
3410
3519
|
);
|
|
3411
3520
|
break;
|
|
3412
3521
|
}
|
|
3413
3522
|
case "childList": {
|
|
3414
|
-
|
|
3523
|
+
f.info(
|
|
3415
3524
|
"[Haori]",
|
|
3416
3525
|
"Child list changed:",
|
|
3417
|
-
Array.from(n.removedNodes).map((
|
|
3418
|
-
Array.from(n.addedNodes).map((
|
|
3419
|
-
), Array.from(n.removedNodes).forEach((
|
|
3420
|
-
T.removeNode(
|
|
3421
|
-
}), Array.from(n.addedNodes).forEach((
|
|
3422
|
-
|
|
3526
|
+
Array.from(n.removedNodes).map((s) => s.nodeName),
|
|
3527
|
+
Array.from(n.addedNodes).map((s) => s.nodeName)
|
|
3528
|
+
), Array.from(n.removedNodes).forEach((s) => {
|
|
3529
|
+
T.removeNode(s);
|
|
3530
|
+
}), Array.from(n.addedNodes).forEach((s) => {
|
|
3531
|
+
s.parentElement instanceof HTMLElement && T.addNode(s.parentElement, s);
|
|
3423
3532
|
});
|
|
3424
3533
|
break;
|
|
3425
3534
|
}
|
|
3426
3535
|
case "characterData": {
|
|
3427
|
-
|
|
3536
|
+
f.info(
|
|
3428
3537
|
"[Haori]",
|
|
3429
3538
|
"Character data changed:",
|
|
3430
3539
|
n.target,
|
|
3431
3540
|
n.target.textContent
|
|
3432
|
-
), n.target instanceof Text || n.target instanceof Comment ? T.changeText(n.target, n.target.textContent) :
|
|
3541
|
+
), n.target instanceof Text || n.target instanceof Comment ? T.changeText(n.target, n.target.textContent) : f.warn(
|
|
3433
3542
|
"[Haori]",
|
|
3434
3543
|
"Unsupported character data type:",
|
|
3435
3544
|
n.target
|
|
@@ -3437,33 +3546,33 @@ const C = class C {
|
|
|
3437
3546
|
break;
|
|
3438
3547
|
}
|
|
3439
3548
|
default:
|
|
3440
|
-
|
|
3549
|
+
f.warn("[Haori]", "Unknown mutation type:", n.type);
|
|
3441
3550
|
continue;
|
|
3442
3551
|
}
|
|
3443
|
-
} catch (
|
|
3444
|
-
|
|
3552
|
+
} catch (s) {
|
|
3553
|
+
f.error("[Haori]", "Error processing mutation:", s);
|
|
3445
3554
|
}
|
|
3446
3555
|
}).observe(t, {
|
|
3447
3556
|
childList: !0,
|
|
3448
3557
|
subtree: !0,
|
|
3449
3558
|
attributes: !0,
|
|
3450
3559
|
characterData: !0
|
|
3451
|
-
}),
|
|
3560
|
+
}), f.info("[Haori]", "Observer initialized for", t);
|
|
3452
3561
|
}
|
|
3453
3562
|
};
|
|
3454
3563
|
C._initialized = !1;
|
|
3455
|
-
let
|
|
3456
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
3457
|
-
const
|
|
3564
|
+
let V = C;
|
|
3565
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", V.init) : V.init();
|
|
3566
|
+
const rt = "0.1.4";
|
|
3458
3567
|
export {
|
|
3459
3568
|
T as Core,
|
|
3460
|
-
|
|
3569
|
+
h as Env,
|
|
3461
3570
|
E as Form,
|
|
3462
3571
|
A as Fragment,
|
|
3463
|
-
|
|
3464
|
-
|
|
3572
|
+
X as Haori,
|
|
3573
|
+
f as Log,
|
|
3465
3574
|
N as Queue,
|
|
3466
|
-
|
|
3467
|
-
|
|
3575
|
+
X as default,
|
|
3576
|
+
rt as version
|
|
3468
3577
|
};
|
|
3469
3578
|
//# sourceMappingURL=haori.es.js.map
|