haori 0.1.2 → 0.1.3
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/LICENSE +21 -21
- package/README.ja.md +182 -167
- package/README.md +184 -169
- package/dist/haori.cjs.js +10 -9
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +666 -569
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +10 -9
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/package.json +1 -1
- package/dist/src/expression.d.ts +27 -3
- package/dist/src/expression.d.ts.map +1 -1
- package/dist/src/expression.js +97 -24
- package/dist/src/expression.js.map +1 -1
- package/dist/src/form.d.ts.map +1 -1
- package/dist/src/form.js +17 -3
- package/dist/src/form.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +37 -16
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/core.test.js +46 -46
- package/dist/tests/data-each-browserlike.test.js +10 -10
- package/dist/tests/data-each-fragment-debug.test.js +36 -36
- package/dist/tests/data-each-table.test.js +93 -10
- package/dist/tests/data-each-table.test.js.map +1 -1
- package/dist/tests/data-fetch-tbody-dom.test.js +12 -12
- package/dist/tests/expression.test.js +37 -21
- package/dist/tests/expression.test.js.map +1 -1
- package/dist/tests/form.test.js +241 -241
- package/dist/tests/import.test.js +34 -34
- package/dist/tests/procedure-action-operations.test.js +85 -0
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/dist/tests/row-move.test.js +67 -67
- package/dist/tests/row-operations.test.js +84 -84
- package/package.json +70 -70
package/dist/haori.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const k = class k {
|
|
2
2
|
/**
|
|
3
3
|
* 開発モードの状態を取得します。
|
|
4
4
|
*
|
|
5
5
|
* @returns 開発モードならtrue、そうでなければfalse
|
|
6
6
|
*/
|
|
7
7
|
static isEnabled() {
|
|
8
|
-
return
|
|
8
|
+
return k.devMode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 開発モードを有効化します。
|
|
12
12
|
*/
|
|
13
13
|
static enable() {
|
|
14
|
-
|
|
14
|
+
k.devMode = !0;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 開発モードを無効化します。
|
|
18
18
|
*/
|
|
19
19
|
static disable() {
|
|
20
|
-
|
|
20
|
+
k.devMode = !1;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 開発モードを切り替えます。
|
|
@@ -25,11 +25,11 @@ const R = class R {
|
|
|
25
25
|
* @param enabled trueで有効化、falseで無効化
|
|
26
26
|
*/
|
|
27
27
|
static set(t) {
|
|
28
|
-
|
|
28
|
+
k.devMode = t;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
let O =
|
|
31
|
+
k.devMode = !1;
|
|
32
|
+
let O = k;
|
|
33
33
|
const D = class D {
|
|
34
34
|
/**
|
|
35
35
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -98,7 +98,7 @@ class h {
|
|
|
98
98
|
console.error(t, ...e);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
class
|
|
101
|
+
class J {
|
|
102
102
|
constructor() {
|
|
103
103
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
104
104
|
}
|
|
@@ -110,17 +110,17 @@ class Y {
|
|
|
110
110
|
* @returns 処理完了Promise
|
|
111
111
|
*/
|
|
112
112
|
enqueue(t, e = !1) {
|
|
113
|
-
let r,
|
|
114
|
-
const
|
|
115
|
-
r = a,
|
|
116
|
-
}),
|
|
113
|
+
let r, n;
|
|
114
|
+
const i = new Promise((a, o) => {
|
|
115
|
+
r = a, n = o;
|
|
116
|
+
}), s = {
|
|
117
117
|
task: t,
|
|
118
118
|
timestamp: performance.now(),
|
|
119
|
-
promise:
|
|
119
|
+
promise: i,
|
|
120
120
|
resolve: r,
|
|
121
|
-
reject:
|
|
121
|
+
reject: n
|
|
122
122
|
};
|
|
123
|
-
return e ? this.queue.unshift(
|
|
123
|
+
return e ? this.queue.unshift(s) : this.queue.push(s), this.scheduleProcessing(), i;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* キューを処理します。
|
|
@@ -192,9 +192,9 @@ const G = class G {
|
|
|
192
192
|
return this.ASYNC_QUEUE.wait();
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
|
-
G.ASYNC_QUEUE = new
|
|
196
|
-
let
|
|
197
|
-
class
|
|
195
|
+
G.ASYNC_QUEUE = new J();
|
|
196
|
+
let N = G;
|
|
197
|
+
class Y {
|
|
198
198
|
/**
|
|
199
199
|
* 通知ダイアログを表示します。
|
|
200
200
|
*
|
|
@@ -202,7 +202,7 @@ class M {
|
|
|
202
202
|
* @returns 通知が閉じられると解決されるPromise
|
|
203
203
|
*/
|
|
204
204
|
static dialog(t) {
|
|
205
|
-
return
|
|
205
|
+
return N.enqueue(() => {
|
|
206
206
|
window.alert(t);
|
|
207
207
|
}, !0);
|
|
208
208
|
}
|
|
@@ -230,7 +230,7 @@ class M {
|
|
|
230
230
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
231
231
|
*/
|
|
232
232
|
static confirm(t) {
|
|
233
|
-
return
|
|
233
|
+
return N.enqueue(() => window.confirm(t), !0);
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* ダイアログを開きます。
|
|
@@ -238,7 +238,7 @@ class M {
|
|
|
238
238
|
* @param element 開くダイアログのHTML要素
|
|
239
239
|
*/
|
|
240
240
|
static openDialog(t) {
|
|
241
|
-
return
|
|
241
|
+
return N.enqueue(() => {
|
|
242
242
|
t instanceof HTMLDialogElement ? t.showModal() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
243
243
|
}, !0);
|
|
244
244
|
}
|
|
@@ -248,7 +248,7 @@ class M {
|
|
|
248
248
|
* @param element 閉じるダイアログのHTML要素
|
|
249
249
|
*/
|
|
250
250
|
static closeDialog(t) {
|
|
251
|
-
return
|
|
251
|
+
return N.enqueue(() => {
|
|
252
252
|
t instanceof HTMLDialogElement ? t.close() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
253
253
|
}, !0);
|
|
254
254
|
}
|
|
@@ -259,7 +259,7 @@ class M {
|
|
|
259
259
|
* @param message エラーメッセージ
|
|
260
260
|
*/
|
|
261
261
|
static addErrorMessage(t, e) {
|
|
262
|
-
return
|
|
262
|
+
return N.enqueue(() => {
|
|
263
263
|
if (t instanceof HTMLFormElement) {
|
|
264
264
|
t.setAttribute("data-message", e);
|
|
265
265
|
return;
|
|
@@ -277,14 +277,21 @@ class M {
|
|
|
277
277
|
* @param parent メッセージをクリアする親要素
|
|
278
278
|
*/
|
|
279
279
|
static clearMessages(t) {
|
|
280
|
-
return
|
|
280
|
+
return N.enqueue(() => {
|
|
281
281
|
t.removeAttribute("data-message"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
282
282
|
e.removeAttribute("data-message");
|
|
283
283
|
});
|
|
284
284
|
}, !0);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
|
|
287
|
+
const z = ["addErrorMessage", "clearMessages"];
|
|
288
|
+
function W() {
|
|
289
|
+
const t = globalThis.window?.Haori;
|
|
290
|
+
return z.every(
|
|
291
|
+
(r) => typeof t?.[r] == "function"
|
|
292
|
+
) ? t : Y;
|
|
293
|
+
}
|
|
294
|
+
class E {
|
|
288
295
|
/**
|
|
289
296
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
290
297
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -295,7 +302,7 @@ class y {
|
|
|
295
302
|
*/
|
|
296
303
|
static getValues(t) {
|
|
297
304
|
const e = {};
|
|
298
|
-
return
|
|
305
|
+
return E.getPartValues(t, e);
|
|
299
306
|
}
|
|
300
307
|
/**
|
|
301
308
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -306,32 +313,32 @@ class y {
|
|
|
306
313
|
* @returns values と同じオブジェクト
|
|
307
314
|
*/
|
|
308
315
|
static getPartValues(t, e) {
|
|
309
|
-
const r = t.getAttribute("name"),
|
|
316
|
+
const r = t.getAttribute("name"), n = t.getAttribute(`${c.prefix}form-object`), i = t.getAttribute(`${c.prefix}form-list`);
|
|
310
317
|
if (r) {
|
|
311
|
-
|
|
318
|
+
i ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), n && h.warn(
|
|
312
319
|
"Haori",
|
|
313
320
|
`Element cannot have both ${c.prefix}form-object and name attributes.`
|
|
314
321
|
);
|
|
315
|
-
for (const
|
|
316
|
-
|
|
317
|
-
} else if (
|
|
318
|
-
const
|
|
322
|
+
for (const s of t.getChildElementFragments())
|
|
323
|
+
E.getPartValues(s, e);
|
|
324
|
+
} else if (n) {
|
|
325
|
+
const s = {};
|
|
319
326
|
for (const a of t.getChildElementFragments())
|
|
320
|
-
|
|
321
|
-
Object.keys(
|
|
327
|
+
E.getPartValues(a, s);
|
|
328
|
+
Object.keys(s).length > 0 && (e[String(n)] = s), i && h.warn(
|
|
322
329
|
"Haori",
|
|
323
330
|
`Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
|
|
324
331
|
);
|
|
325
|
-
} else if (
|
|
326
|
-
const
|
|
332
|
+
} else if (i) {
|
|
333
|
+
const s = [];
|
|
327
334
|
for (const a of t.getChildElementFragments()) {
|
|
328
335
|
const o = {};
|
|
329
|
-
|
|
336
|
+
E.getPartValues(a, o), Object.keys(o).length > 0 && s.push(o);
|
|
330
337
|
}
|
|
331
|
-
|
|
338
|
+
s.length > 0 && (e[String(i)] = s);
|
|
332
339
|
} else
|
|
333
|
-
for (const
|
|
334
|
-
|
|
340
|
+
for (const s of t.getChildElementFragments())
|
|
341
|
+
E.getPartValues(s, e);
|
|
335
342
|
return e;
|
|
336
343
|
}
|
|
337
344
|
/**
|
|
@@ -344,7 +351,7 @@ class y {
|
|
|
344
351
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
345
352
|
*/
|
|
346
353
|
static setValues(t, e, r = !1) {
|
|
347
|
-
return
|
|
354
|
+
return E.setPartValues(t, e, null, r);
|
|
348
355
|
}
|
|
349
356
|
/**
|
|
350
357
|
* フラグメント内にある各入力エレメントに値を設定します。
|
|
@@ -355,23 +362,23 @@ class y {
|
|
|
355
362
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
356
363
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
357
364
|
*/
|
|
358
|
-
static setPartValues(t, e, r = null,
|
|
359
|
-
const
|
|
360
|
-
if (
|
|
361
|
-
if (!g ||
|
|
362
|
-
const u = e[String(
|
|
363
|
-
o && Array.isArray(u) && r !== null ?
|
|
365
|
+
static setPartValues(t, e, r = null, n = !1) {
|
|
366
|
+
const i = [], s = t.getAttribute("name"), a = t.getAttribute(`${c.prefix}form-object`), o = t.getAttribute(`${c.prefix}form-list`), g = t.getAttribute(`${c.prefix}form-detach`);
|
|
367
|
+
if (s) {
|
|
368
|
+
if (!g || n) {
|
|
369
|
+
const u = e[String(s)];
|
|
370
|
+
o && Array.isArray(u) && r !== null ? i.push(t.setValue(u[r])) : typeof u == "string" || typeof u == "number" || typeof u == "boolean" || u === null ? i.push(t.setValue(u)) : i.push(t.setValue(String(u)));
|
|
364
371
|
}
|
|
365
372
|
} else if (a) {
|
|
366
373
|
const u = e[String(a)];
|
|
367
374
|
if (u && typeof u == "object")
|
|
368
375
|
for (const b of t.getChildElementFragments())
|
|
369
|
-
|
|
370
|
-
|
|
376
|
+
i.push(
|
|
377
|
+
E.setPartValues(
|
|
371
378
|
b,
|
|
372
379
|
u,
|
|
373
380
|
null,
|
|
374
|
-
|
|
381
|
+
n
|
|
375
382
|
)
|
|
376
383
|
);
|
|
377
384
|
} else if (o) {
|
|
@@ -380,20 +387,20 @@ class y {
|
|
|
380
387
|
const b = t.getChildElementFragments();
|
|
381
388
|
for (let l = 0; l < b.length; l++) {
|
|
382
389
|
const f = b[l];
|
|
383
|
-
u.length > l ?
|
|
384
|
-
|
|
390
|
+
u.length > l ? i.push(
|
|
391
|
+
E.setPartValues(
|
|
385
392
|
f,
|
|
386
393
|
u[l],
|
|
387
394
|
l,
|
|
388
|
-
|
|
395
|
+
n
|
|
389
396
|
)
|
|
390
|
-
) :
|
|
397
|
+
) : i.push(E.setPartValues(f, {}, l, n));
|
|
391
398
|
}
|
|
392
399
|
}
|
|
393
400
|
} else
|
|
394
401
|
for (const u of t.getChildElementFragments())
|
|
395
|
-
|
|
396
|
-
return Promise.all(
|
|
402
|
+
i.push(E.setPartValues(u, e, null, n));
|
|
403
|
+
return Promise.all(i).then(() => {
|
|
397
404
|
});
|
|
398
405
|
}
|
|
399
406
|
/**
|
|
@@ -404,21 +411,21 @@ class y {
|
|
|
404
411
|
* @returns すべての初期化処理が完了するPromise
|
|
405
412
|
*/
|
|
406
413
|
static async reset(t) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
]), await
|
|
414
|
+
E.clearValues(t), await Promise.all([
|
|
415
|
+
E.clearMessages(t),
|
|
416
|
+
E.clearEachClones(t)
|
|
417
|
+
]), await N.enqueue(() => {
|
|
411
418
|
const e = t.getTarget();
|
|
412
419
|
if (e instanceof HTMLFormElement)
|
|
413
420
|
e.reset();
|
|
414
421
|
else {
|
|
415
422
|
const r = e.parentElement;
|
|
416
423
|
if (r) {
|
|
417
|
-
const
|
|
418
|
-
|
|
424
|
+
const n = e.nextElementSibling, i = document.createElement("form");
|
|
425
|
+
i.appendChild(e), i.reset(), r.insertBefore(e, n);
|
|
419
426
|
}
|
|
420
427
|
}
|
|
421
|
-
}), await
|
|
428
|
+
}), await T.evaluateAll(t);
|
|
422
429
|
}
|
|
423
430
|
/**
|
|
424
431
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -427,20 +434,20 @@ class y {
|
|
|
427
434
|
* 対象エレメント自体は削除しません。
|
|
428
435
|
*/
|
|
429
436
|
static clearEachClones(t) {
|
|
430
|
-
const e = [], r = (
|
|
431
|
-
if (
|
|
432
|
-
for (const
|
|
433
|
-
const a =
|
|
434
|
-
!a && !o && e.push(
|
|
437
|
+
const e = [], r = (i) => {
|
|
438
|
+
if (i.hasAttribute(`${c.prefix}each`))
|
|
439
|
+
for (const s of i.getChildElementFragments()) {
|
|
440
|
+
const a = s.hasAttribute(`${c.prefix}each-before`), o = s.hasAttribute(`${c.prefix}each-after`);
|
|
441
|
+
!a && !o && e.push(s.remove());
|
|
435
442
|
}
|
|
436
|
-
},
|
|
437
|
-
r(
|
|
438
|
-
for (const
|
|
439
|
-
|
|
443
|
+
}, n = (i) => {
|
|
444
|
+
r(i);
|
|
445
|
+
for (const s of i.getChildElementFragments())
|
|
446
|
+
n(s);
|
|
440
447
|
};
|
|
441
448
|
r(t);
|
|
442
|
-
for (const
|
|
443
|
-
i
|
|
449
|
+
for (const i of t.getChildElementFragments())
|
|
450
|
+
n(i);
|
|
444
451
|
return Promise.all(e).then(() => {
|
|
445
452
|
});
|
|
446
453
|
}
|
|
@@ -452,7 +459,7 @@ class y {
|
|
|
452
459
|
static clearValues(t) {
|
|
453
460
|
t.clearValue();
|
|
454
461
|
for (const e of t.getChildElementFragments())
|
|
455
|
-
|
|
462
|
+
E.clearValues(e);
|
|
456
463
|
}
|
|
457
464
|
/**
|
|
458
465
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -461,7 +468,9 @@ class y {
|
|
|
461
468
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
462
469
|
*/
|
|
463
470
|
static clearMessages(t) {
|
|
464
|
-
return
|
|
471
|
+
return W().clearMessages(
|
|
472
|
+
t.getTarget()
|
|
473
|
+
);
|
|
465
474
|
}
|
|
466
475
|
/**
|
|
467
476
|
* キーに一致するフラグメントにエラーメッセージを追加します。
|
|
@@ -473,10 +482,14 @@ class y {
|
|
|
473
482
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
474
483
|
*/
|
|
475
484
|
static addErrorMessage(t, e, r) {
|
|
476
|
-
const
|
|
477
|
-
return s.forEach((
|
|
478
|
-
|
|
479
|
-
|
|
485
|
+
const n = [], i = W(), s = E.findFragmentsByKey(t, e);
|
|
486
|
+
return s.forEach((a) => {
|
|
487
|
+
n.push(
|
|
488
|
+
i.addErrorMessage(a.getTarget(), r)
|
|
489
|
+
);
|
|
490
|
+
}), s.length === 0 && n.push(
|
|
491
|
+
i.addErrorMessage(t.getTarget(), r)
|
|
492
|
+
), Promise.all(n).then(() => {
|
|
480
493
|
});
|
|
481
494
|
}
|
|
482
495
|
/**
|
|
@@ -487,7 +500,7 @@ class y {
|
|
|
487
500
|
* @returns 一致するフラグメントの配列
|
|
488
501
|
*/
|
|
489
502
|
static findFragmentsByKey(t, e) {
|
|
490
|
-
return
|
|
503
|
+
return E.findFragmentByKeyParts(t, e.split("."));
|
|
491
504
|
}
|
|
492
505
|
/**
|
|
493
506
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -498,32 +511,32 @@ class y {
|
|
|
498
511
|
* @returns 一致するフラグメントの配列
|
|
499
512
|
*/
|
|
500
513
|
static findFragmentByKeyParts(t, e) {
|
|
501
|
-
const r = [],
|
|
502
|
-
if (e.length == 1 && t.getAttribute("name") ===
|
|
503
|
-
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) ===
|
|
504
|
-
r.push(...
|
|
514
|
+
const r = [], n = e[0];
|
|
515
|
+
if (e.length == 1 && t.getAttribute("name") === n && r.push(t), t.hasAttribute(`${c.prefix}form-object`))
|
|
516
|
+
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) === n && t.getChildElementFragments().forEach((s) => {
|
|
517
|
+
r.push(...E.findFragmentByKeyParts(s, e.slice(1)));
|
|
505
518
|
});
|
|
506
519
|
else if (t.hasAttribute(`${c.prefix}form-list`)) {
|
|
507
520
|
if (e.length > 1) {
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
510
|
-
const o =
|
|
511
|
-
if (
|
|
512
|
-
const g =
|
|
521
|
+
const i = t.getAttribute(`${c.prefix}form-list`), s = n.lastIndexOf("["), a = n.lastIndexOf("]");
|
|
522
|
+
if (s !== -1 && a !== -1 && s < a) {
|
|
523
|
+
const o = n.substring(0, s);
|
|
524
|
+
if (i === o) {
|
|
525
|
+
const g = n.substring(s + 1, a), u = Number(g);
|
|
513
526
|
if (isNaN(u))
|
|
514
|
-
h.error("Haori", `Invalid index: ${
|
|
527
|
+
h.error("Haori", `Invalid index: ${n}`);
|
|
515
528
|
else {
|
|
516
529
|
const b = t.getChildElementFragments().filter((l) => l.hasAttribute(`${c.prefix}row`));
|
|
517
530
|
u < b.length && r.push(
|
|
518
|
-
...
|
|
531
|
+
...E.findFragmentByKeyParts(b[u], e.slice(1))
|
|
519
532
|
);
|
|
520
533
|
}
|
|
521
534
|
}
|
|
522
535
|
}
|
|
523
536
|
}
|
|
524
537
|
} else
|
|
525
|
-
t.getChildElementFragments().forEach((
|
|
526
|
-
r.push(...
|
|
538
|
+
t.getChildElementFragments().forEach((i) => {
|
|
539
|
+
r.push(...E.findFragmentByKeyParts(i, e));
|
|
527
540
|
});
|
|
528
541
|
return r;
|
|
529
542
|
}
|
|
@@ -540,7 +553,43 @@ class y {
|
|
|
540
553
|
return r ? this.getFormFragment(r) : null;
|
|
541
554
|
}
|
|
542
555
|
}
|
|
543
|
-
const
|
|
556
|
+
const S = class S {
|
|
557
|
+
/**
|
|
558
|
+
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
559
|
+
*
|
|
560
|
+
* @returns 危険値の配列
|
|
561
|
+
*/
|
|
562
|
+
static getForbiddenBindingValues() {
|
|
563
|
+
const t = globalThis, e = [
|
|
564
|
+
t,
|
|
565
|
+
t.window,
|
|
566
|
+
t.document,
|
|
567
|
+
t.navigator,
|
|
568
|
+
t.history,
|
|
569
|
+
t.localStorage,
|
|
570
|
+
t.sessionStorage,
|
|
571
|
+
t.fetch,
|
|
572
|
+
t.Function,
|
|
573
|
+
t.setTimeout,
|
|
574
|
+
t.setInterval,
|
|
575
|
+
t.requestAnimationFrame,
|
|
576
|
+
t.alert,
|
|
577
|
+
t.confirm,
|
|
578
|
+
t.prompt
|
|
579
|
+
];
|
|
580
|
+
return t.window?.location && e.push(t.window.location), e.filter((r) => r != null);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* 現在のバインド識別子に含まれない禁止グローバルを遮断するコードを生成します。
|
|
584
|
+
*
|
|
585
|
+
* @param bindKeys 現在の式で利用するバインド識別子一覧
|
|
586
|
+
* @returns 評価前に挿入する初期化コード
|
|
587
|
+
*/
|
|
588
|
+
static buildAssignments(t) {
|
|
589
|
+
const e = new Set(t);
|
|
590
|
+
return this.FORBIDDEN_NAMES.filter((r) => !e.has(r)).map((r) => `const ${r} = undefined`).join(`;
|
|
591
|
+
`);
|
|
592
|
+
}
|
|
544
593
|
/**
|
|
545
594
|
* 式を評価します。
|
|
546
595
|
*
|
|
@@ -554,32 +603,37 @@ const k = class k {
|
|
|
554
603
|
return h.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
555
604
|
if (this.containsForbiddenKeys(e))
|
|
556
605
|
return h.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
606
|
+
if (this.containsForbiddenBindingValues(e))
|
|
607
|
+
return h.warn(
|
|
608
|
+
"[Haori]",
|
|
609
|
+
e,
|
|
610
|
+
"Binded values contain forbidden values"
|
|
611
|
+
), null;
|
|
612
|
+
const r = Object.keys(e).filter((s) => !this.FORBIDDEN_BINDING_NAMES.has(s)).sort(), n = `${t}:${r.join(",")}`;
|
|
613
|
+
let i = this.EXPRESSION_CACHE.get(n);
|
|
614
|
+
if (!i) {
|
|
615
|
+
const s = this.buildAssignments(r), a = s ? `"use strict";
|
|
616
|
+
${s};
|
|
617
|
+
return (${t});` : `"use strict";
|
|
564
618
|
return (${t});`;
|
|
565
619
|
try {
|
|
566
|
-
|
|
567
|
-
} catch (
|
|
620
|
+
i = new Function(...r, a), this.EXPRESSION_CACHE.set(n, i);
|
|
621
|
+
} catch (o) {
|
|
568
622
|
return h.error(
|
|
569
623
|
"[Haori]",
|
|
570
624
|
"Failed to compile expression:",
|
|
571
625
|
t,
|
|
572
|
-
|
|
626
|
+
o
|
|
573
627
|
), null;
|
|
574
628
|
}
|
|
575
629
|
}
|
|
576
630
|
try {
|
|
577
|
-
const
|
|
631
|
+
const s = [], a = this.wrapBoundValues(e);
|
|
578
632
|
return r.forEach((o) => {
|
|
579
|
-
|
|
580
|
-
}), this.withBlockedPropertyAccess(() =>
|
|
581
|
-
} catch (
|
|
582
|
-
return h.error("[Haori]", "Expression evaluation error:", t,
|
|
633
|
+
s.push(a[o]);
|
|
634
|
+
}), this.withBlockedPropertyAccess(() => i(...s));
|
|
635
|
+
} catch (s) {
|
|
636
|
+
return h.error("[Haori]", "Expression evaluation error:", t, s), s instanceof ReferenceError ? void 0 : null;
|
|
583
637
|
}
|
|
584
638
|
}
|
|
585
639
|
/**
|
|
@@ -609,14 +663,14 @@ return (${t});`;
|
|
|
609
663
|
if (e === null || e.length === 0)
|
|
610
664
|
return !1;
|
|
611
665
|
const r = [];
|
|
612
|
-
let
|
|
613
|
-
for (let
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
-
this.decodeStringLiteral(
|
|
617
|
-
) ||
|
|
666
|
+
let n = null;
|
|
667
|
+
for (let i = 0; i < e.length; i++) {
|
|
668
|
+
const s = e[i], a = e[i + 1] || null, o = r[r.length - 1] || null;
|
|
669
|
+
if (s.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(s.value) || this.STRICT_FORBIDDEN_NAMES.includes(s.value) || (n?.value === "." || n?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(s.value)) || o === "member" && s.value !== "]" && s.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
670
|
+
this.decodeStringLiteral(s.value)
|
|
671
|
+
) || s.value === "." && a?.type !== "identifier" || s.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
618
672
|
return !1;
|
|
619
|
-
switch (
|
|
673
|
+
switch (s.value) {
|
|
620
674
|
case "(":
|
|
621
675
|
r.push("paren");
|
|
622
676
|
break;
|
|
@@ -626,7 +680,7 @@ return (${t});`;
|
|
|
626
680
|
break;
|
|
627
681
|
}
|
|
628
682
|
case "[": {
|
|
629
|
-
const g = this.startsMemberAccess(
|
|
683
|
+
const g = this.startsMemberAccess(n) ? "member" : "array";
|
|
630
684
|
r.push(g);
|
|
631
685
|
break;
|
|
632
686
|
}
|
|
@@ -636,7 +690,7 @@ return (${t});`;
|
|
|
636
690
|
break;
|
|
637
691
|
}
|
|
638
692
|
}
|
|
639
|
-
|
|
693
|
+
n = s;
|
|
640
694
|
}
|
|
641
695
|
return r.length === 0;
|
|
642
696
|
}
|
|
@@ -659,7 +713,7 @@ return (${t});`;
|
|
|
659
713
|
"==",
|
|
660
714
|
"!=",
|
|
661
715
|
"=>"
|
|
662
|
-
],
|
|
716
|
+
], n = /* @__PURE__ */ new Set([
|
|
663
717
|
"(",
|
|
664
718
|
")",
|
|
665
719
|
"[",
|
|
@@ -677,41 +731,41 @@ return (${t});`;
|
|
|
677
731
|
">",
|
|
678
732
|
"<"
|
|
679
733
|
]);
|
|
680
|
-
let
|
|
681
|
-
for (;
|
|
682
|
-
const
|
|
683
|
-
if (/\s/.test(
|
|
684
|
-
|
|
734
|
+
let i = 0;
|
|
735
|
+
for (; i < t.length; ) {
|
|
736
|
+
const s = t[i];
|
|
737
|
+
if (/\s/.test(s)) {
|
|
738
|
+
i += 1;
|
|
685
739
|
continue;
|
|
686
740
|
}
|
|
687
|
-
if (
|
|
741
|
+
if (s === "/" && (t[i + 1] === "/" || t[i + 1] === "*"))
|
|
688
742
|
return null;
|
|
689
|
-
if (
|
|
690
|
-
const o = this.readStringToken(t,
|
|
743
|
+
if (s === '"' || s === "'") {
|
|
744
|
+
const o = this.readStringToken(t, i);
|
|
691
745
|
if (o === null)
|
|
692
746
|
return null;
|
|
693
|
-
e.push(o.token),
|
|
747
|
+
e.push(o.token), i = o.nextIndex;
|
|
694
748
|
continue;
|
|
695
749
|
}
|
|
696
750
|
const a = r.find(
|
|
697
|
-
(o) => t.startsWith(o,
|
|
751
|
+
(o) => t.startsWith(o, i)
|
|
698
752
|
);
|
|
699
753
|
if (a) {
|
|
700
|
-
e.push({ type: "operator", value: a, position:
|
|
754
|
+
e.push({ type: "operator", value: a, position: i }), i += a.length;
|
|
701
755
|
continue;
|
|
702
756
|
}
|
|
703
|
-
if (/[0-9]/.test(
|
|
704
|
-
const o = this.readNumberToken(t,
|
|
705
|
-
e.push(o.token),
|
|
757
|
+
if (/[0-9]/.test(s)) {
|
|
758
|
+
const o = this.readNumberToken(t, i);
|
|
759
|
+
e.push(o.token), i = o.nextIndex;
|
|
706
760
|
continue;
|
|
707
761
|
}
|
|
708
|
-
if (/[A-Za-z_$]/.test(
|
|
709
|
-
const o = this.readIdentifierToken(t,
|
|
710
|
-
e.push(o.token),
|
|
762
|
+
if (/[A-Za-z_$]/.test(s)) {
|
|
763
|
+
const o = this.readIdentifierToken(t, i);
|
|
764
|
+
e.push(o.token), i = o.nextIndex;
|
|
711
765
|
continue;
|
|
712
766
|
}
|
|
713
|
-
if (
|
|
714
|
-
e.push({ type: "operator", value:
|
|
767
|
+
if (n.has(s)) {
|
|
768
|
+
e.push({ type: "operator", value: s, position: i }), i += 1;
|
|
715
769
|
continue;
|
|
716
770
|
}
|
|
717
771
|
return null;
|
|
@@ -727,23 +781,23 @@ return (${t});`;
|
|
|
727
781
|
*/
|
|
728
782
|
static readStringToken(t, e) {
|
|
729
783
|
const r = t[e];
|
|
730
|
-
let
|
|
731
|
-
for (;
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
734
|
-
|
|
784
|
+
let n = e + 1;
|
|
785
|
+
for (; n < t.length; ) {
|
|
786
|
+
const i = t[n];
|
|
787
|
+
if (i === "\\") {
|
|
788
|
+
n += 2;
|
|
735
789
|
continue;
|
|
736
790
|
}
|
|
737
|
-
if (
|
|
791
|
+
if (i === r)
|
|
738
792
|
return {
|
|
739
793
|
token: {
|
|
740
794
|
type: "string",
|
|
741
|
-
value: t.slice(e,
|
|
795
|
+
value: t.slice(e, n + 1),
|
|
742
796
|
position: e
|
|
743
797
|
},
|
|
744
|
-
nextIndex:
|
|
798
|
+
nextIndex: n + 1
|
|
745
799
|
};
|
|
746
|
-
|
|
800
|
+
n += 1;
|
|
747
801
|
}
|
|
748
802
|
return null;
|
|
749
803
|
}
|
|
@@ -842,8 +896,8 @@ return (${t});`;
|
|
|
842
896
|
*/
|
|
843
897
|
static wrapBoundValues(t) {
|
|
844
898
|
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
845
|
-
return Object.entries(t).forEach(([
|
|
846
|
-
r[
|
|
899
|
+
return Object.entries(t).forEach(([n, i]) => {
|
|
900
|
+
r[n] = this.wrapBoundValue(i, e);
|
|
847
901
|
}), r;
|
|
848
902
|
}
|
|
849
903
|
/**
|
|
@@ -856,42 +910,42 @@ return (${t});`;
|
|
|
856
910
|
static wrapBoundValue(t, e) {
|
|
857
911
|
if (!this.shouldWrapValue(t))
|
|
858
912
|
return t;
|
|
859
|
-
const r = t,
|
|
860
|
-
if (
|
|
861
|
-
return
|
|
862
|
-
const
|
|
863
|
-
get: (
|
|
913
|
+
const r = t, n = e.get(r);
|
|
914
|
+
if (n !== void 0)
|
|
915
|
+
return n;
|
|
916
|
+
const i = new Proxy(r, {
|
|
917
|
+
get: (s, a, o) => {
|
|
864
918
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
865
919
|
return;
|
|
866
|
-
const g = Reflect.get(
|
|
920
|
+
const g = Reflect.get(s, a, o);
|
|
867
921
|
return typeof a == "symbol" ? g : this.wrapBoundValue(
|
|
868
922
|
g,
|
|
869
923
|
e
|
|
870
924
|
);
|
|
871
925
|
},
|
|
872
|
-
has: (
|
|
873
|
-
getOwnPropertyDescriptor: (
|
|
926
|
+
has: (s, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(s, a),
|
|
927
|
+
getOwnPropertyDescriptor: (s, a) => {
|
|
874
928
|
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
875
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
929
|
+
return Reflect.getOwnPropertyDescriptor(s, a);
|
|
876
930
|
},
|
|
877
|
-
apply: (
|
|
931
|
+
apply: (s, a, o) => {
|
|
878
932
|
const g = Reflect.apply(
|
|
879
|
-
|
|
933
|
+
s,
|
|
880
934
|
a,
|
|
881
935
|
o
|
|
882
936
|
);
|
|
883
937
|
return this.isIteratorLike(g) ? g : this.wrapBoundValue(g, e);
|
|
884
938
|
},
|
|
885
|
-
construct: (
|
|
939
|
+
construct: (s, a, o) => this.wrapBoundValue(
|
|
886
940
|
Reflect.construct(
|
|
887
|
-
|
|
941
|
+
s,
|
|
888
942
|
a,
|
|
889
943
|
o
|
|
890
944
|
),
|
|
891
945
|
e
|
|
892
946
|
)
|
|
893
947
|
});
|
|
894
|
-
return e.set(r,
|
|
948
|
+
return e.set(r, i), i;
|
|
895
949
|
}
|
|
896
950
|
/**
|
|
897
951
|
* Proxy ラップ対象の値かどうかを判定します。
|
|
@@ -920,12 +974,12 @@ return (${t});`;
|
|
|
920
974
|
{ target: Object.prototype, property: "constructor" },
|
|
921
975
|
{ target: Function.prototype, property: "constructor" },
|
|
922
976
|
{ target: Object.prototype, property: "__proto__" }
|
|
923
|
-
].map((
|
|
924
|
-
...
|
|
925
|
-
descriptor: Object.getOwnPropertyDescriptor(
|
|
926
|
-
})).filter((
|
|
927
|
-
r.forEach(({ target:
|
|
928
|
-
Object.defineProperty(
|
|
977
|
+
].map((n) => ({
|
|
978
|
+
...n,
|
|
979
|
+
descriptor: Object.getOwnPropertyDescriptor(n.target, n.property)
|
|
980
|
+
})).filter((n) => n.descriptor?.configurable === !0);
|
|
981
|
+
r.forEach(({ target: n, property: i }) => {
|
|
982
|
+
Object.defineProperty(n, i, {
|
|
929
983
|
configurable: !0,
|
|
930
984
|
enumerable: !1,
|
|
931
985
|
get: () => {
|
|
@@ -937,8 +991,8 @@ return (${t});`;
|
|
|
937
991
|
try {
|
|
938
992
|
return t();
|
|
939
993
|
} finally {
|
|
940
|
-
r.forEach(({ target:
|
|
941
|
-
|
|
994
|
+
r.forEach(({ target: n, property: i, descriptor: s }) => {
|
|
995
|
+
s !== void 0 && Object.defineProperty(n, i, s);
|
|
942
996
|
});
|
|
943
997
|
}
|
|
944
998
|
}
|
|
@@ -952,21 +1006,47 @@ return (${t});`;
|
|
|
952
1006
|
return t === null || typeof t != "object" ? !1 : typeof t.next == "function";
|
|
953
1007
|
}
|
|
954
1008
|
/**
|
|
955
|
-
|
|
1009
|
+
* トップレベルのバインド識別子に拒否対象名が含まれていないかを判定します。
|
|
1010
|
+
* ネストしたオブジェクトのプロパティ名は識別子として評価されないため、ここでは拒否しません。
|
|
956
1011
|
*
|
|
957
1012
|
* @param obj チェック対象のオブジェクト
|
|
958
1013
|
* @return 禁止識別子が含まれていればtrue
|
|
959
1014
|
*/
|
|
960
1015
|
static containsForbiddenKeys(t) {
|
|
961
|
-
if (t
|
|
962
|
-
|
|
963
|
-
|
|
1016
|
+
if (!t || typeof t != "object")
|
|
1017
|
+
return !1;
|
|
1018
|
+
for (const e of Object.keys(t))
|
|
1019
|
+
if (this.FORBIDDEN_BINDING_NAMES.has(e))
|
|
1020
|
+
return !0;
|
|
1021
|
+
return !1;
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* バインド値に危険なホストオブジェクトやグローバル関数が含まれていないかを再帰的に判定します。
|
|
1025
|
+
*
|
|
1026
|
+
* @param obj チェック対象の値
|
|
1027
|
+
* @param seen 循環参照検出用の訪問済み集合
|
|
1028
|
+
* @return 危険値が含まれていればtrue
|
|
1029
|
+
*/
|
|
1030
|
+
static containsForbiddenBindingValues(t, e = /* @__PURE__ */ new WeakSet()) {
|
|
1031
|
+
if (!t || typeof t != "object" || e.has(t))
|
|
1032
|
+
return !1;
|
|
1033
|
+
if (e.add(t), this.getForbiddenBindingValues().some((r) => r === t))
|
|
1034
|
+
return !0;
|
|
1035
|
+
for (const r of Object.values(t)) {
|
|
1036
|
+
if (typeof r == "function") {
|
|
1037
|
+
if (this.getForbiddenBindingValues().some(
|
|
1038
|
+
(n) => n === r
|
|
1039
|
+
))
|
|
964
1040
|
return !0;
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
if (this.containsForbiddenBindingValues(r, e))
|
|
1044
|
+
return !0;
|
|
965
1045
|
}
|
|
966
1046
|
return !1;
|
|
967
1047
|
}
|
|
968
1048
|
};
|
|
969
|
-
|
|
1049
|
+
S.FORBIDDEN_NAMES = [
|
|
970
1050
|
// グローバルオブジェクト
|
|
971
1051
|
"window",
|
|
972
1052
|
"self",
|
|
@@ -998,11 +1078,19 @@ k.FORBIDDEN_NAMES = [
|
|
|
998
1078
|
"sessionStorage",
|
|
999
1079
|
"IndexedDB",
|
|
1000
1080
|
"history"
|
|
1001
|
-
],
|
|
1081
|
+
], S.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], S.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), S.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1082
|
+
...S.FORBIDDEN_NAMES.filter(
|
|
1083
|
+
(t) => !S.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1084
|
+
),
|
|
1085
|
+
"constructor",
|
|
1086
|
+
"__proto__",
|
|
1087
|
+
"prototype",
|
|
1088
|
+
...S.STRICT_FORBIDDEN_NAMES
|
|
1089
|
+
]), S.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1002
1090
|
"constructor",
|
|
1003
1091
|
"__proto__",
|
|
1004
1092
|
"prototype"
|
|
1005
|
-
]),
|
|
1093
|
+
]), S.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1006
1094
|
"await",
|
|
1007
1095
|
"break",
|
|
1008
1096
|
"case",
|
|
@@ -1036,14 +1124,8 @@ k.FORBIDDEN_NAMES = [
|
|
|
1036
1124
|
"while",
|
|
1037
1125
|
"with",
|
|
1038
1126
|
"yield"
|
|
1039
|
-
]),
|
|
1040
|
-
|
|
1041
|
-
k.FORBIDDEN_NAMES.forEach((e) => {
|
|
1042
|
-
t.push(`const ${e} = undefined`);
|
|
1043
|
-
}), k.assignments = t.join(`;
|
|
1044
|
-
`);
|
|
1045
|
-
})();
|
|
1046
|
-
let H = k;
|
|
1127
|
+
]), S.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1128
|
+
let H = S;
|
|
1047
1129
|
const P = class P {
|
|
1048
1130
|
/**
|
|
1049
1131
|
* フラグメントのコンストラクタ。
|
|
@@ -1061,10 +1143,10 @@ const P = class P {
|
|
|
1061
1143
|
let e;
|
|
1062
1144
|
switch (t.nodeType) {
|
|
1063
1145
|
case Node.ELEMENT_NODE:
|
|
1064
|
-
e = new
|
|
1146
|
+
e = new M(t);
|
|
1065
1147
|
break;
|
|
1066
1148
|
case Node.TEXT_NODE:
|
|
1067
|
-
e = new
|
|
1149
|
+
e = new $(t);
|
|
1068
1150
|
break;
|
|
1069
1151
|
case Node.COMMENT_NODE:
|
|
1070
1152
|
e = new K(t);
|
|
@@ -1092,7 +1174,7 @@ const P = class P {
|
|
|
1092
1174
|
return Promise.resolve();
|
|
1093
1175
|
if (this.parent) {
|
|
1094
1176
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1095
|
-
return
|
|
1177
|
+
return N.enqueue(() => {
|
|
1096
1178
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1097
1179
|
}).finally(() => {
|
|
1098
1180
|
t.skipMutationNodes = e;
|
|
@@ -1100,7 +1182,7 @@ const P = class P {
|
|
|
1100
1182
|
} else {
|
|
1101
1183
|
const t = this.target.parentNode;
|
|
1102
1184
|
if (t)
|
|
1103
|
-
return
|
|
1185
|
+
return N.enqueue(() => {
|
|
1104
1186
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
1105
1187
|
});
|
|
1106
1188
|
this.mounted = !1;
|
|
@@ -1117,7 +1199,7 @@ const P = class P {
|
|
|
1117
1199
|
return Promise.resolve();
|
|
1118
1200
|
if (this.parent) {
|
|
1119
1201
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1120
|
-
return
|
|
1202
|
+
return N.enqueue(() => {
|
|
1121
1203
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1122
1204
|
}).finally(() => {
|
|
1123
1205
|
t.skipMutationNodes = e;
|
|
@@ -1177,7 +1259,7 @@ const P = class P {
|
|
|
1177
1259
|
};
|
|
1178
1260
|
P.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1179
1261
|
let A = P;
|
|
1180
|
-
class
|
|
1262
|
+
class M extends A {
|
|
1181
1263
|
/**
|
|
1182
1264
|
* エレメントフラグメントのコンストラクタ。
|
|
1183
1265
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1203,8 +1285,8 @@ class S extends A {
|
|
|
1203
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) => {
|
|
1204
1286
|
const r = t.getAttribute(e);
|
|
1205
1287
|
if (r !== null && !this.attributeMap.has(e)) {
|
|
1206
|
-
const
|
|
1207
|
-
this.attributeMap.set(e,
|
|
1288
|
+
const n = new j(e, r);
|
|
1289
|
+
this.attributeMap.set(e, n);
|
|
1208
1290
|
}
|
|
1209
1291
|
}), t.childNodes.forEach((e) => {
|
|
1210
1292
|
const r = A.get(e);
|
|
@@ -1226,7 +1308,7 @@ class S extends A {
|
|
|
1226
1308
|
*/
|
|
1227
1309
|
getChildElementFragments() {
|
|
1228
1310
|
return this.children.filter(
|
|
1229
|
-
(t) => t instanceof
|
|
1311
|
+
(t) => t instanceof M
|
|
1230
1312
|
);
|
|
1231
1313
|
}
|
|
1232
1314
|
/**
|
|
@@ -1258,7 +1340,7 @@ class S extends A {
|
|
|
1258
1340
|
* @returns クローンされたフラグメント
|
|
1259
1341
|
*/
|
|
1260
1342
|
clone() {
|
|
1261
|
-
const t = new
|
|
1343
|
+
const t = new M(
|
|
1262
1344
|
this.target.cloneNode(!1)
|
|
1263
1345
|
);
|
|
1264
1346
|
return this.children.forEach((e) => {
|
|
@@ -1316,7 +1398,7 @@ class S extends A {
|
|
|
1316
1398
|
*/
|
|
1317
1399
|
clearBindingDataCache() {
|
|
1318
1400
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1319
|
-
t instanceof
|
|
1401
|
+
t instanceof M && t.clearBindingDataCache();
|
|
1320
1402
|
});
|
|
1321
1403
|
}
|
|
1322
1404
|
/**
|
|
@@ -1364,13 +1446,13 @@ class S extends A {
|
|
|
1364
1446
|
const e = this.getTarget();
|
|
1365
1447
|
if (e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio")) {
|
|
1366
1448
|
const r = this.getAttribute("value");
|
|
1367
|
-
let
|
|
1368
|
-
return r === "true" ?
|
|
1369
|
-
e.checked =
|
|
1449
|
+
let n;
|
|
1450
|
+
return r === "true" ? n = t === !0 : r === "false" ? n = t === !1 : n = r === String(t), this.value = n ? t : null, e.checked === n ? Promise.resolve() : (this.skipChangeValue = !0, N.enqueue(() => {
|
|
1451
|
+
e.checked = n, e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1370
1452
|
}).finally(() => {
|
|
1371
1453
|
this.skipChangeValue = !1;
|
|
1372
1454
|
}));
|
|
1373
|
-
} else return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0,
|
|
1455
|
+
} else return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, N.enqueue(() => {
|
|
1374
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 }));
|
|
1375
1457
|
}).finally(() => {
|
|
1376
1458
|
this.skipChangeValue = !1;
|
|
@@ -1428,15 +1510,15 @@ class S extends A {
|
|
|
1428
1510
|
return Promise.resolve();
|
|
1429
1511
|
if (e === null)
|
|
1430
1512
|
return this.removeAttribute(t);
|
|
1431
|
-
const r = new
|
|
1513
|
+
const r = new j(t, e);
|
|
1432
1514
|
this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
|
|
1433
|
-
const
|
|
1434
|
-
return
|
|
1435
|
-
if (
|
|
1436
|
-
|
|
1515
|
+
const n = this.getTarget(), i = r.isForceEvaluation() ? e : this.getAttribute(t);
|
|
1516
|
+
return N.enqueue(() => {
|
|
1517
|
+
if (i === null || i === !1)
|
|
1518
|
+
n.removeAttribute(t);
|
|
1437
1519
|
else {
|
|
1438
|
-
const
|
|
1439
|
-
|
|
1520
|
+
const s = String(i);
|
|
1521
|
+
n.getAttribute(t) !== s && n.setAttribute(t, s);
|
|
1440
1522
|
}
|
|
1441
1523
|
}).finally(() => {
|
|
1442
1524
|
this.skipMutationAttributes = !1;
|
|
@@ -1453,7 +1535,7 @@ class S extends A {
|
|
|
1453
1535
|
return Promise.resolve();
|
|
1454
1536
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1455
1537
|
const e = this.getTarget();
|
|
1456
|
-
return
|
|
1538
|
+
return N.enqueue(() => {
|
|
1457
1539
|
e.removeAttribute(t);
|
|
1458
1540
|
}).finally(() => {
|
|
1459
1541
|
this.skipMutationAttributes = !1;
|
|
@@ -1471,7 +1553,7 @@ class S extends A {
|
|
|
1471
1553
|
if (e === void 0)
|
|
1472
1554
|
return null;
|
|
1473
1555
|
const r = e.evaluate(this.getBindingData());
|
|
1474
|
-
return r.length === 1 ? r[0] :
|
|
1556
|
+
return r.length === 1 ? r[0] : B.joinEvaluateResults(r);
|
|
1475
1557
|
}
|
|
1476
1558
|
/**
|
|
1477
1559
|
* 属性の生の値を取得します。
|
|
@@ -1511,18 +1593,18 @@ class S extends A {
|
|
|
1511
1593
|
const r = t.getTarget();
|
|
1512
1594
|
if (r.parentNode !== this.target)
|
|
1513
1595
|
return null;
|
|
1514
|
-
const
|
|
1515
|
-
let
|
|
1516
|
-
for (;
|
|
1517
|
-
const
|
|
1518
|
-
if (
|
|
1519
|
-
const a = this.children.indexOf(
|
|
1596
|
+
const n = e ? r.nextSibling : r;
|
|
1597
|
+
let i = e ? r.nextSibling : r;
|
|
1598
|
+
for (; i !== null; ) {
|
|
1599
|
+
const s = A.get(i);
|
|
1600
|
+
if (s !== null) {
|
|
1601
|
+
const a = this.children.indexOf(s);
|
|
1520
1602
|
if (a !== -1)
|
|
1521
|
-
return { index: a, referenceNode:
|
|
1603
|
+
return { index: a, referenceNode: n };
|
|
1522
1604
|
}
|
|
1523
|
-
|
|
1605
|
+
i = i.nextSibling;
|
|
1524
1606
|
}
|
|
1525
|
-
return { index: this.children.length, referenceNode:
|
|
1607
|
+
return { index: this.children.length, referenceNode: n };
|
|
1526
1608
|
}
|
|
1527
1609
|
/**
|
|
1528
1610
|
* 子ノードを参照ノードの前に挿入します。
|
|
@@ -1537,15 +1619,15 @@ class S extends A {
|
|
|
1537
1619
|
return Promise.resolve();
|
|
1538
1620
|
if (t === this)
|
|
1539
1621
|
return h.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1540
|
-
const
|
|
1541
|
-
let
|
|
1542
|
-
for (;
|
|
1543
|
-
|
|
1544
|
-
if (
|
|
1622
|
+
const n = /* @__PURE__ */ new Set();
|
|
1623
|
+
let i = this.parent;
|
|
1624
|
+
for (; i; )
|
|
1625
|
+
n.add(i), i = i.getParent();
|
|
1626
|
+
if (n.has(t))
|
|
1545
1627
|
return h.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1546
|
-
const
|
|
1628
|
+
const s = t.getParent() === this;
|
|
1547
1629
|
let a = -1, o = -1;
|
|
1548
|
-
|
|
1630
|
+
s && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1549
1631
|
const g = t.getParent();
|
|
1550
1632
|
g !== null && g.removeChild(t);
|
|
1551
1633
|
let u = r === void 0 ? e?.getTarget() || null : r;
|
|
@@ -1553,7 +1635,7 @@ class S extends A {
|
|
|
1553
1635
|
this.children.push(t);
|
|
1554
1636
|
else {
|
|
1555
1637
|
let l;
|
|
1556
|
-
if (
|
|
1638
|
+
if (s ? a !== -1 && a < o ? l = o - 1 : l = o : l = this.children.indexOf(e), l === -1) {
|
|
1557
1639
|
const f = this.resolveInsertionPointFromDom(
|
|
1558
1640
|
e,
|
|
1559
1641
|
!1
|
|
@@ -1568,7 +1650,7 @@ class S extends A {
|
|
|
1568
1650
|
}
|
|
1569
1651
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1570
1652
|
const b = this.skipMutationNodes;
|
|
1571
|
-
return this.skipMutationNodes = !0,
|
|
1653
|
+
return this.skipMutationNodes = !0, N.enqueue(() => {
|
|
1572
1654
|
this.target.insertBefore(t.getTarget(), u);
|
|
1573
1655
|
}).finally(() => {
|
|
1574
1656
|
this.skipMutationNodes = b;
|
|
@@ -1586,18 +1668,18 @@ class S extends A {
|
|
|
1586
1668
|
return this.insertBefore(t, null);
|
|
1587
1669
|
const r = this.children.indexOf(e);
|
|
1588
1670
|
if (r === -1) {
|
|
1589
|
-
const
|
|
1671
|
+
const n = this.resolveInsertionPointFromDom(
|
|
1590
1672
|
e,
|
|
1591
1673
|
!0
|
|
1592
1674
|
);
|
|
1593
|
-
return
|
|
1675
|
+
return n === null ? (h.warn(
|
|
1594
1676
|
"[Haori]",
|
|
1595
1677
|
"Reference child not found in children.",
|
|
1596
1678
|
e
|
|
1597
1679
|
), this.insertBefore(t, null)) : this.insertBefore(
|
|
1598
1680
|
t,
|
|
1599
|
-
this.children[
|
|
1600
|
-
|
|
1681
|
+
this.children[n.index] || null,
|
|
1682
|
+
n.referenceNode
|
|
1601
1683
|
);
|
|
1602
1684
|
}
|
|
1603
1685
|
return this.insertBefore(t, this.children[r + 1] || null);
|
|
@@ -1666,7 +1748,7 @@ class S extends A {
|
|
|
1666
1748
|
return e === null ? null : e.closestByAttribute(t);
|
|
1667
1749
|
}
|
|
1668
1750
|
}
|
|
1669
|
-
class
|
|
1751
|
+
class $ extends A {
|
|
1670
1752
|
/**
|
|
1671
1753
|
* テキストフラグメントのコンストラクタ。
|
|
1672
1754
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -1674,7 +1756,7 @@ class j extends A {
|
|
|
1674
1756
|
* @param target 対象テキストノード
|
|
1675
1757
|
*/
|
|
1676
1758
|
constructor(t) {
|
|
1677
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1759
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new B(this.text);
|
|
1678
1760
|
}
|
|
1679
1761
|
/**
|
|
1680
1762
|
* フラグメントをクローンします。
|
|
@@ -1682,7 +1764,7 @@ class j extends A {
|
|
|
1682
1764
|
* @returns クローンされたフラグメント
|
|
1683
1765
|
*/
|
|
1684
1766
|
clone() {
|
|
1685
|
-
const t = new
|
|
1767
|
+
const t = new $(this.target.cloneNode(!0));
|
|
1686
1768
|
return t.mounted = !1, t.text = this.text, t.contents = this.contents, t;
|
|
1687
1769
|
}
|
|
1688
1770
|
/**
|
|
@@ -1700,7 +1782,7 @@ class j extends A {
|
|
|
1700
1782
|
* @returns 更新のPromise
|
|
1701
1783
|
*/
|
|
1702
1784
|
setContent(t) {
|
|
1703
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1785
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new B(t), this.evaluate());
|
|
1704
1786
|
}
|
|
1705
1787
|
/**
|
|
1706
1788
|
* フラグメントを評価します。
|
|
@@ -1710,10 +1792,10 @@ class j extends A {
|
|
|
1710
1792
|
evaluate() {
|
|
1711
1793
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1712
1794
|
new Error("Parent fragment is required for raw evaluation")
|
|
1713
|
-
) :
|
|
1795
|
+
) : N.enqueue(() => {
|
|
1714
1796
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1715
1797
|
this.parent.getBindingData()
|
|
1716
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1798
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = B.joinEvaluateResults(
|
|
1717
1799
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1718
1800
|
) : this.target.textContent = this.text;
|
|
1719
1801
|
}).finally(() => {
|
|
@@ -1755,14 +1837,14 @@ class K extends A {
|
|
|
1755
1837
|
* @return 更新のPromise
|
|
1756
1838
|
*/
|
|
1757
1839
|
setContent(t) {
|
|
1758
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
1840
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, N.enqueue(() => {
|
|
1759
1841
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
1760
1842
|
}).finally(() => {
|
|
1761
1843
|
this.skipMutation = !1;
|
|
1762
1844
|
}));
|
|
1763
1845
|
}
|
|
1764
1846
|
}
|
|
1765
|
-
const
|
|
1847
|
+
const V = class V {
|
|
1766
1848
|
/**
|
|
1767
1849
|
* コンストラクタ。
|
|
1768
1850
|
*
|
|
@@ -1770,26 +1852,26 @@ const q = class q {
|
|
|
1770
1852
|
*/
|
|
1771
1853
|
constructor(t) {
|
|
1772
1854
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
1773
|
-
const e = [...t.matchAll(
|
|
1774
|
-
let r = 0,
|
|
1775
|
-
for (const
|
|
1776
|
-
|
|
1777
|
-
text: t.slice(r,
|
|
1855
|
+
const e = [...t.matchAll(V.PLACEHOLDER_REGEX)];
|
|
1856
|
+
let r = 0, n = !1, i = !1;
|
|
1857
|
+
for (const s of e) {
|
|
1858
|
+
s.index > r && this.contents.push({
|
|
1859
|
+
text: t.slice(r, s.index),
|
|
1778
1860
|
type: 0
|
|
1779
1861
|
/* TEXT */
|
|
1780
1862
|
});
|
|
1781
1863
|
const a = {
|
|
1782
|
-
text:
|
|
1783
|
-
type:
|
|
1864
|
+
text: s[1] ?? s[2],
|
|
1865
|
+
type: s[1] ? 2 : 1
|
|
1784
1866
|
/* EXPRESSION */
|
|
1785
1867
|
};
|
|
1786
|
-
|
|
1868
|
+
n = !0, i = i || a.type === 2, this.contents.push(a), r = s.index + s[0].length;
|
|
1787
1869
|
}
|
|
1788
1870
|
r < t.length && this.contents.push({
|
|
1789
1871
|
text: t.slice(r),
|
|
1790
1872
|
type: 0
|
|
1791
1873
|
/* TEXT */
|
|
1792
|
-
}), this.isEvaluate =
|
|
1874
|
+
}), this.isEvaluate = n, this.isRawEvaluate = i, this.checkRawExpressions();
|
|
1793
1875
|
}
|
|
1794
1876
|
/**
|
|
1795
1877
|
* 評価結果を結合して文字列にします。
|
|
@@ -1831,23 +1913,23 @@ const q = class q {
|
|
|
1831
1913
|
return this.contents.forEach((r) => {
|
|
1832
1914
|
try {
|
|
1833
1915
|
if (r.type === 1 || r.type === 2) {
|
|
1834
|
-
const
|
|
1835
|
-
e.push(
|
|
1916
|
+
const n = H.evaluate(r.text, t);
|
|
1917
|
+
e.push(n);
|
|
1836
1918
|
} else
|
|
1837
1919
|
e.push(r.text);
|
|
1838
|
-
} catch (
|
|
1920
|
+
} catch (n) {
|
|
1839
1921
|
h.error(
|
|
1840
1922
|
"[Haori]",
|
|
1841
1923
|
`Error evaluating text expression: ${r.text}`,
|
|
1842
|
-
|
|
1924
|
+
n
|
|
1843
1925
|
), e.push("");
|
|
1844
1926
|
}
|
|
1845
1927
|
}), e;
|
|
1846
1928
|
}
|
|
1847
1929
|
};
|
|
1848
|
-
|
|
1849
|
-
let
|
|
1850
|
-
const
|
|
1930
|
+
V.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
1931
|
+
let B = V;
|
|
1932
|
+
const q = class q extends B {
|
|
1851
1933
|
/**
|
|
1852
1934
|
* コンストラクタ。
|
|
1853
1935
|
*
|
|
@@ -1855,7 +1937,7 @@ const U = class U extends $ {
|
|
|
1855
1937
|
* @param text 属性値
|
|
1856
1938
|
*/
|
|
1857
1939
|
constructor(t, e) {
|
|
1858
|
-
super(e), this.forceEvaluation =
|
|
1940
|
+
super(e), this.forceEvaluation = q.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
1859
1941
|
}
|
|
1860
1942
|
/**
|
|
1861
1943
|
* 強制評価フラグを取得します。
|
|
@@ -1878,15 +1960,15 @@ const U = class U extends $ {
|
|
|
1878
1960
|
return this.contents.forEach((r) => {
|
|
1879
1961
|
try {
|
|
1880
1962
|
if (this.forceEvaluation && r.type === 0 || r.type === 1 || r.type === 2) {
|
|
1881
|
-
const
|
|
1882
|
-
e.push(
|
|
1963
|
+
const n = H.evaluate(r.text, t);
|
|
1964
|
+
e.push(n);
|
|
1883
1965
|
} else
|
|
1884
1966
|
e.push(r.text);
|
|
1885
|
-
} catch (
|
|
1967
|
+
} catch (n) {
|
|
1886
1968
|
h.error(
|
|
1887
1969
|
"[Haori]",
|
|
1888
1970
|
`Error evaluating attribute expression: ${r.text}`,
|
|
1889
|
-
|
|
1971
|
+
n
|
|
1890
1972
|
), e.push("");
|
|
1891
1973
|
}
|
|
1892
1974
|
}), this.forceEvaluation && e.length > 1 ? (h.error(
|
|
@@ -1896,14 +1978,14 @@ const U = class U extends $ {
|
|
|
1896
1978
|
), [e[0]]) : e;
|
|
1897
1979
|
}
|
|
1898
1980
|
};
|
|
1899
|
-
|
|
1981
|
+
q.FORCE_EVALUATION_ATTRIBUTES = [
|
|
1900
1982
|
"data-if",
|
|
1901
1983
|
"hor-if",
|
|
1902
1984
|
"data-each",
|
|
1903
1985
|
"hor-each"
|
|
1904
1986
|
];
|
|
1905
|
-
let
|
|
1906
|
-
class
|
|
1987
|
+
let j = q;
|
|
1988
|
+
class y {
|
|
1907
1989
|
/**
|
|
1908
1990
|
* カスタムイベントを発火します。
|
|
1909
1991
|
*
|
|
@@ -1912,14 +1994,14 @@ class E {
|
|
|
1912
1994
|
* @param detail イベントの詳細データ
|
|
1913
1995
|
* @param options イベントオプション
|
|
1914
1996
|
*/
|
|
1915
|
-
static dispatch(t, e, r,
|
|
1916
|
-
const
|
|
1917
|
-
bubbles:
|
|
1918
|
-
cancelable:
|
|
1919
|
-
composed:
|
|
1997
|
+
static dispatch(t, e, r, n) {
|
|
1998
|
+
const i = new CustomEvent(`haori:${e}`, {
|
|
1999
|
+
bubbles: n?.bubbles ?? !0,
|
|
2000
|
+
cancelable: n?.cancelable ?? !1,
|
|
2001
|
+
composed: n?.composed ?? !0,
|
|
1920
2002
|
detail: r
|
|
1921
2003
|
});
|
|
1922
|
-
return t.dispatchEvent(
|
|
2004
|
+
return t.dispatchEvent(i);
|
|
1923
2005
|
}
|
|
1924
2006
|
/**
|
|
1925
2007
|
* readyイベントを発火します。
|
|
@@ -1927,7 +2009,7 @@ class E {
|
|
|
1927
2009
|
* @param version ライブラリバージョン
|
|
1928
2010
|
*/
|
|
1929
2011
|
static ready(t) {
|
|
1930
|
-
|
|
2012
|
+
y.dispatch(document, "ready", { version: t });
|
|
1931
2013
|
}
|
|
1932
2014
|
/**
|
|
1933
2015
|
* renderイベントを発火します。
|
|
@@ -1935,7 +2017,7 @@ class E {
|
|
|
1935
2017
|
* @param target 評価対象要素
|
|
1936
2018
|
*/
|
|
1937
2019
|
static render(t) {
|
|
1938
|
-
|
|
2020
|
+
y.dispatch(t, "render", { target: t });
|
|
1939
2021
|
}
|
|
1940
2022
|
/**
|
|
1941
2023
|
* importstartイベントを発火します。
|
|
@@ -1944,7 +2026,7 @@ class E {
|
|
|
1944
2026
|
* @param url インポート対象URL
|
|
1945
2027
|
*/
|
|
1946
2028
|
static importStart(t, e) {
|
|
1947
|
-
|
|
2029
|
+
y.dispatch(t, "importstart", {
|
|
1948
2030
|
url: e,
|
|
1949
2031
|
startedAt: performance.now()
|
|
1950
2032
|
});
|
|
@@ -1957,11 +2039,11 @@ class E {
|
|
|
1957
2039
|
* @param bytes 取得バイト数
|
|
1958
2040
|
* @param startedAt 開始時刻
|
|
1959
2041
|
*/
|
|
1960
|
-
static importEnd(t, e, r,
|
|
1961
|
-
|
|
2042
|
+
static importEnd(t, e, r, n) {
|
|
2043
|
+
y.dispatch(t, "importend", {
|
|
1962
2044
|
url: e,
|
|
1963
2045
|
bytes: r,
|
|
1964
|
-
durationMs: performance.now() -
|
|
2046
|
+
durationMs: performance.now() - n
|
|
1965
2047
|
});
|
|
1966
2048
|
}
|
|
1967
2049
|
/**
|
|
@@ -1972,7 +2054,7 @@ class E {
|
|
|
1972
2054
|
* @param error エラー内容
|
|
1973
2055
|
*/
|
|
1974
2056
|
static importError(t, e, r) {
|
|
1975
|
-
|
|
2057
|
+
y.dispatch(t, "importerror", { url: e, error: r });
|
|
1976
2058
|
}
|
|
1977
2059
|
/**
|
|
1978
2060
|
* bindchangeイベントを発火します。
|
|
@@ -1982,17 +2064,17 @@ class E {
|
|
|
1982
2064
|
* @param next 変更後のデータ
|
|
1983
2065
|
* @param reason 変更理由
|
|
1984
2066
|
*/
|
|
1985
|
-
static bindChange(t, e, r,
|
|
1986
|
-
const
|
|
2067
|
+
static bindChange(t, e, r, n = "other") {
|
|
2068
|
+
const i = [], s = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...s, ...a]);
|
|
1987
2069
|
for (const g of o) {
|
|
1988
2070
|
const u = e?.[g], b = r[g];
|
|
1989
|
-
u !== b &&
|
|
2071
|
+
u !== b && i.push(g);
|
|
1990
2072
|
}
|
|
1991
|
-
|
|
2073
|
+
y.dispatch(t, "bindchange", {
|
|
1992
2074
|
previous: e || {},
|
|
1993
2075
|
next: r,
|
|
1994
|
-
changedKeys:
|
|
1995
|
-
reason:
|
|
2076
|
+
changedKeys: i,
|
|
2077
|
+
reason: n
|
|
1996
2078
|
});
|
|
1997
2079
|
}
|
|
1998
2080
|
/**
|
|
@@ -2003,12 +2085,12 @@ class E {
|
|
|
2003
2085
|
* @param removed 削除された行のキー
|
|
2004
2086
|
* @param order 現在の順序
|
|
2005
2087
|
*/
|
|
2006
|
-
static eachUpdate(t, e, r,
|
|
2007
|
-
|
|
2088
|
+
static eachUpdate(t, e, r, n) {
|
|
2089
|
+
y.dispatch(t, "eachupdate", {
|
|
2008
2090
|
added: e,
|
|
2009
2091
|
removed: r,
|
|
2010
|
-
order:
|
|
2011
|
-
total:
|
|
2092
|
+
order: n,
|
|
2093
|
+
total: n.length
|
|
2012
2094
|
});
|
|
2013
2095
|
}
|
|
2014
2096
|
/**
|
|
@@ -2019,8 +2101,8 @@ class E {
|
|
|
2019
2101
|
* @param index インデックス
|
|
2020
2102
|
* @param item 行データ
|
|
2021
2103
|
*/
|
|
2022
|
-
static rowAdd(t, e, r,
|
|
2023
|
-
|
|
2104
|
+
static rowAdd(t, e, r, n) {
|
|
2105
|
+
y.dispatch(t, "rowadd", { key: e, index: r, item: n });
|
|
2024
2106
|
}
|
|
2025
2107
|
/**
|
|
2026
2108
|
* rowremoveイベントを発火します。
|
|
@@ -2030,7 +2112,7 @@ class E {
|
|
|
2030
2112
|
* @param index インデックス
|
|
2031
2113
|
*/
|
|
2032
2114
|
static rowRemove(t, e, r) {
|
|
2033
|
-
|
|
2115
|
+
y.dispatch(t, "rowremove", { key: e, index: r });
|
|
2034
2116
|
}
|
|
2035
2117
|
/**
|
|
2036
2118
|
* rowmoveイベントを発火します。
|
|
@@ -2040,8 +2122,8 @@ class E {
|
|
|
2040
2122
|
* @param from 移動前インデックス
|
|
2041
2123
|
* @param to 移動後インデックス
|
|
2042
2124
|
*/
|
|
2043
|
-
static rowMove(t, e, r,
|
|
2044
|
-
|
|
2125
|
+
static rowMove(t, e, r, n) {
|
|
2126
|
+
y.dispatch(t, "rowmove", { key: e, from: r, to: n });
|
|
2045
2127
|
}
|
|
2046
2128
|
/**
|
|
2047
2129
|
* showイベントを発火します。
|
|
@@ -2049,7 +2131,7 @@ class E {
|
|
|
2049
2131
|
* @param target data-if要素
|
|
2050
2132
|
*/
|
|
2051
2133
|
static show(t) {
|
|
2052
|
-
|
|
2134
|
+
y.dispatch(t, "show", { visible: !0 });
|
|
2053
2135
|
}
|
|
2054
2136
|
/**
|
|
2055
2137
|
* hideイベントを発火します。
|
|
@@ -2057,7 +2139,7 @@ class E {
|
|
|
2057
2139
|
* @param target data-if要素
|
|
2058
2140
|
*/
|
|
2059
2141
|
static hide(t) {
|
|
2060
|
-
|
|
2142
|
+
y.dispatch(t, "hide", { visible: !1 });
|
|
2061
2143
|
}
|
|
2062
2144
|
/**
|
|
2063
2145
|
* fetchstartイベントを発火します。
|
|
@@ -2067,11 +2149,11 @@ class E {
|
|
|
2067
2149
|
* @param options フェッチオプション
|
|
2068
2150
|
* @param payload 送信データ
|
|
2069
2151
|
*/
|
|
2070
|
-
static fetchStart(t, e, r,
|
|
2071
|
-
|
|
2152
|
+
static fetchStart(t, e, r, n) {
|
|
2153
|
+
y.dispatch(t, "fetchstart", {
|
|
2072
2154
|
url: e,
|
|
2073
2155
|
options: r || {},
|
|
2074
|
-
payload:
|
|
2156
|
+
payload: n,
|
|
2075
2157
|
startedAt: performance.now()
|
|
2076
2158
|
});
|
|
2077
2159
|
}
|
|
@@ -2083,11 +2165,11 @@ class E {
|
|
|
2083
2165
|
* @param status HTTPステータス
|
|
2084
2166
|
* @param startedAt 開始時刻
|
|
2085
2167
|
*/
|
|
2086
|
-
static fetchEnd(t, e, r,
|
|
2087
|
-
|
|
2168
|
+
static fetchEnd(t, e, r, n) {
|
|
2169
|
+
y.dispatch(t, "fetchend", {
|
|
2088
2170
|
url: e,
|
|
2089
2171
|
status: r,
|
|
2090
|
-
durationMs: performance.now() -
|
|
2172
|
+
durationMs: performance.now() - n
|
|
2091
2173
|
});
|
|
2092
2174
|
}
|
|
2093
2175
|
/**
|
|
@@ -2099,15 +2181,29 @@ class E {
|
|
|
2099
2181
|
* @param status HTTPステータス(存在する場合)
|
|
2100
2182
|
* @param startedAt 開始時刻(存在する場合)
|
|
2101
2183
|
*/
|
|
2102
|
-
static fetchError(t, e, r,
|
|
2103
|
-
|
|
2184
|
+
static fetchError(t, e, r, n, i) {
|
|
2185
|
+
y.dispatch(t, "fetcherror", {
|
|
2104
2186
|
url: e,
|
|
2105
|
-
status:
|
|
2187
|
+
status: n,
|
|
2106
2188
|
error: r,
|
|
2107
|
-
durationMs:
|
|
2189
|
+
durationMs: i ? performance.now() - i : void 0
|
|
2108
2190
|
});
|
|
2109
2191
|
}
|
|
2110
2192
|
}
|
|
2193
|
+
const Q = [
|
|
2194
|
+
"addErrorMessage",
|
|
2195
|
+
"closeDialog",
|
|
2196
|
+
"confirm",
|
|
2197
|
+
"dialog",
|
|
2198
|
+
"openDialog",
|
|
2199
|
+
"toast"
|
|
2200
|
+
];
|
|
2201
|
+
function U() {
|
|
2202
|
+
const t = globalThis.window?.Haori;
|
|
2203
|
+
return Q.every(
|
|
2204
|
+
(r) => typeof t?.[r] == "function"
|
|
2205
|
+
) ? t : Y;
|
|
2206
|
+
}
|
|
2111
2207
|
class d {
|
|
2112
2208
|
/**
|
|
2113
2209
|
* イベント属性名を正しく生成します。
|
|
@@ -2133,7 +2229,7 @@ class d {
|
|
|
2133
2229
|
if (e) {
|
|
2134
2230
|
if (t.hasAttribute(d.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(d.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2135
2231
|
d.attrName(e, "confirm")
|
|
2136
|
-
)), t.hasAttribute(d.attrName(e, "data")) && (r.data =
|
|
2232
|
+
)), t.hasAttribute(d.attrName(e, "data")) && (r.data = T.parseDataBind(
|
|
2137
2233
|
t.getRawAttribute(d.attrName(e, "data"))
|
|
2138
2234
|
)), t.hasAttribute(d.attrName(e, "form"))) {
|
|
2139
2235
|
const l = t.getRawAttribute(
|
|
@@ -2141,15 +2237,15 @@ class d {
|
|
|
2141
2237
|
);
|
|
2142
2238
|
if (l) {
|
|
2143
2239
|
const f = document.body.querySelector(l);
|
|
2144
|
-
f !== null ? r.formFragment =
|
|
2240
|
+
f !== null ? r.formFragment = E.getFormFragment(
|
|
2145
2241
|
A.get(f)
|
|
2146
2242
|
) : h.error(
|
|
2147
2243
|
"Haori",
|
|
2148
2244
|
`Form element not found: ${l} (${d.attrName(e, "form")})`
|
|
2149
2245
|
);
|
|
2150
2246
|
} else
|
|
2151
|
-
r.formFragment =
|
|
2152
|
-
} else e === "change" && (r.formFragment =
|
|
2247
|
+
r.formFragment = E.getFormFragment(t);
|
|
2248
|
+
} else e === "change" && (r.formFragment = E.getFormFragment(t));
|
|
2153
2249
|
if (t.hasAttribute(`${c.prefix}${e}-before-run`)) {
|
|
2154
2250
|
const l = t.getRawAttribute(
|
|
2155
2251
|
`${c.prefix}${e}-before-run`
|
|
@@ -2168,17 +2264,17 @@ ${l}
|
|
|
2168
2264
|
}
|
|
2169
2265
|
}
|
|
2170
2266
|
}
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
const
|
|
2267
|
+
const n = d.attrName(e, "fetch"), i = t.hasAttribute(n);
|
|
2268
|
+
i && (r.fetchUrl = t.getAttribute(n));
|
|
2269
|
+
const s = {};
|
|
2174
2270
|
if (e) {
|
|
2175
2271
|
const l = d.attrName(e, "fetch-method");
|
|
2176
|
-
t.hasAttribute(l) && (
|
|
2272
|
+
t.hasAttribute(l) && (s.method = t.getAttribute(
|
|
2177
2273
|
l
|
|
2178
2274
|
));
|
|
2179
2275
|
} else {
|
|
2180
2276
|
const l = d.attrName(null, "method", !0);
|
|
2181
|
-
t.hasAttribute(l) && (
|
|
2277
|
+
t.hasAttribute(l) && (s.method = t.getAttribute(
|
|
2182
2278
|
l
|
|
2183
2279
|
));
|
|
2184
2280
|
}
|
|
@@ -2189,7 +2285,7 @@ ${l}
|
|
|
2189
2285
|
l
|
|
2190
2286
|
);
|
|
2191
2287
|
try {
|
|
2192
|
-
|
|
2288
|
+
s.headers = T.parseDataBind(f);
|
|
2193
2289
|
} catch (p) {
|
|
2194
2290
|
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2195
2291
|
}
|
|
@@ -2205,7 +2301,7 @@ ${l}
|
|
|
2205
2301
|
l
|
|
2206
2302
|
);
|
|
2207
2303
|
try {
|
|
2208
|
-
|
|
2304
|
+
s.headers = T.parseDataBind(f);
|
|
2209
2305
|
} catch (p) {
|
|
2210
2306
|
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
2211
2307
|
}
|
|
@@ -2217,18 +2313,18 @@ ${l}
|
|
|
2217
2313
|
"fetch-content-type"
|
|
2218
2314
|
);
|
|
2219
2315
|
if (t.hasAttribute(l))
|
|
2220
|
-
|
|
2221
|
-
...
|
|
2316
|
+
s.headers = {
|
|
2317
|
+
...s.headers,
|
|
2222
2318
|
"Content-Type": t.getAttribute(l)
|
|
2223
2319
|
};
|
|
2224
|
-
else if (
|
|
2320
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2225
2321
|
let f = !1;
|
|
2226
|
-
|
|
2227
|
-
...
|
|
2322
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2323
|
+
...s.headers,
|
|
2228
2324
|
"Content-Type": "application/json"
|
|
2229
2325
|
});
|
|
2230
|
-
} else
|
|
2231
|
-
...
|
|
2326
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2327
|
+
...s.headers,
|
|
2232
2328
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2233
2329
|
});
|
|
2234
2330
|
} else {
|
|
@@ -2238,22 +2334,22 @@ ${l}
|
|
|
2238
2334
|
!0
|
|
2239
2335
|
);
|
|
2240
2336
|
if (t.hasAttribute(l))
|
|
2241
|
-
|
|
2242
|
-
...
|
|
2337
|
+
s.headers = {
|
|
2338
|
+
...s.headers,
|
|
2243
2339
|
"Content-Type": t.getAttribute(l)
|
|
2244
2340
|
};
|
|
2245
|
-
else if (
|
|
2341
|
+
else if (s.method && s.method !== "GET" && s.method !== "HEAD" && s.method !== "OPTIONS") {
|
|
2246
2342
|
let f = !1;
|
|
2247
|
-
|
|
2248
|
-
...
|
|
2343
|
+
s.headers && typeof s.headers == "object" && (f = "Content-Type" in s.headers), f || (s.headers = {
|
|
2344
|
+
...s.headers,
|
|
2249
2345
|
"Content-Type": "application/json"
|
|
2250
2346
|
});
|
|
2251
|
-
} else
|
|
2252
|
-
...
|
|
2347
|
+
} else s.method && (s.method === "GET" || s.method === "HEAD" || s.method === "OPTIONS") && (s.headers = {
|
|
2348
|
+
...s.headers,
|
|
2253
2349
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2254
2350
|
});
|
|
2255
2351
|
}
|
|
2256
|
-
Object.keys(
|
|
2352
|
+
Object.keys(s).length > 0 && (r.fetchOptions = s);
|
|
2257
2353
|
const a = e ? d.attrName(e, "bind") : d.attrName(null, "bind", !0);
|
|
2258
2354
|
if (t.hasAttribute(a)) {
|
|
2259
2355
|
const l = t.getRawAttribute(a);
|
|
@@ -2368,7 +2464,7 @@ ${f}
|
|
|
2368
2464
|
const l = t.getRawAttribute(
|
|
2369
2465
|
d.attrName(null, "data", !0)
|
|
2370
2466
|
);
|
|
2371
|
-
r.data =
|
|
2467
|
+
r.data = T.parseDataBind(l);
|
|
2372
2468
|
}
|
|
2373
2469
|
if (t.hasAttribute(d.attrName(null, "form", !0))) {
|
|
2374
2470
|
const l = t.getRawAttribute(
|
|
@@ -2376,17 +2472,17 @@ ${f}
|
|
|
2376
2472
|
);
|
|
2377
2473
|
if (l) {
|
|
2378
2474
|
const f = document.body.querySelector(l);
|
|
2379
|
-
f !== null ? r.formFragment =
|
|
2475
|
+
f !== null ? r.formFragment = E.getFormFragment(
|
|
2380
2476
|
A.get(f)
|
|
2381
2477
|
) : h.error(
|
|
2382
2478
|
"Haori",
|
|
2383
2479
|
`Form element not found: ${l} (${d.attrName(null, "fetch-form", !0)})`
|
|
2384
2480
|
);
|
|
2385
2481
|
} else
|
|
2386
|
-
r.formFragment =
|
|
2482
|
+
r.formFragment = E.getFormFragment(t);
|
|
2387
2483
|
}
|
|
2388
2484
|
}
|
|
2389
|
-
return
|
|
2485
|
+
return i && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2390
2486
|
}
|
|
2391
2487
|
/**
|
|
2392
2488
|
* ElementFragment の構造的タイプガード。
|
|
@@ -2420,82 +2516,82 @@ ${f}
|
|
|
2420
2516
|
return Promise.resolve();
|
|
2421
2517
|
let e = this.options.fetchUrl, r = this.options.fetchOptions;
|
|
2422
2518
|
if (this.options.beforeCallback) {
|
|
2423
|
-
const
|
|
2519
|
+
const s = this.options.beforeCallback(
|
|
2424
2520
|
e || null,
|
|
2425
2521
|
r || null
|
|
2426
2522
|
);
|
|
2427
|
-
if (
|
|
2428
|
-
if (
|
|
2523
|
+
if (s != null) {
|
|
2524
|
+
if (s === !1 || typeof s == "object" && s.stop)
|
|
2429
2525
|
return Promise.resolve();
|
|
2430
|
-
typeof
|
|
2526
|
+
typeof s == "object" && (e = "fetchUrl" in s ? s.fetchUrl : e, r = "fetchOptions" in s ? s.fetchOptions : r);
|
|
2431
2527
|
}
|
|
2432
2528
|
}
|
|
2433
|
-
const
|
|
2529
|
+
const n = {};
|
|
2434
2530
|
if (this.options.formFragment) {
|
|
2435
|
-
const
|
|
2436
|
-
Object.assign(
|
|
2531
|
+
const s = E.getValues(this.options.formFragment);
|
|
2532
|
+
Object.assign(n, s);
|
|
2437
2533
|
}
|
|
2438
|
-
this.options.data && typeof this.options.data == "object" && Object.assign(
|
|
2439
|
-
const
|
|
2534
|
+
this.options.data && typeof this.options.data == "object" && Object.assign(n, this.options.data);
|
|
2535
|
+
const i = Object.keys(n).length > 0;
|
|
2440
2536
|
if (e) {
|
|
2441
|
-
const
|
|
2442
|
-
|
|
2443
|
-
), o = (
|
|
2537
|
+
const s = { ...r || {} }, a = new Headers(
|
|
2538
|
+
s.headers || void 0
|
|
2539
|
+
), o = (s.method || "GET").toUpperCase();
|
|
2444
2540
|
if (o === "GET" || o === "HEAD" || o === "OPTIONS") {
|
|
2445
|
-
if (
|
|
2541
|
+
if (i) {
|
|
2446
2542
|
const g = new URL(e, window.location.href), u = new URLSearchParams(g.search);
|
|
2447
|
-
for (const [b, l] of Object.entries(
|
|
2543
|
+
for (const [b, l] of Object.entries(n))
|
|
2448
2544
|
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((f) => {
|
|
2449
2545
|
u.append(b, String(f));
|
|
2450
2546
|
}) : typeof l == "object" || typeof l == "function" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
|
|
2451
2547
|
g.search = u.toString(), e = g.toString();
|
|
2452
2548
|
}
|
|
2453
|
-
} else if (
|
|
2549
|
+
} else if (i) {
|
|
2454
2550
|
const g = a.get("Content-Type") || "";
|
|
2455
2551
|
if (/multipart\/form-data/i.test(g)) {
|
|
2456
2552
|
a.delete("Content-Type");
|
|
2457
2553
|
const u = new FormData();
|
|
2458
|
-
for (const [b, l] of Object.entries(
|
|
2554
|
+
for (const [b, l] of Object.entries(n))
|
|
2459
2555
|
l == null ? u.append(b, "") : l instanceof Blob ? u.append(b, l) : Array.isArray(l) ? l.forEach((f) => u.append(b, String(f))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l));
|
|
2460
|
-
|
|
2556
|
+
s.body = u;
|
|
2461
2557
|
} else if (/application\/x-www-form-urlencoded/i.test(g)) {
|
|
2462
2558
|
const u = new URLSearchParams();
|
|
2463
|
-
for (const [b, l] of Object.entries(
|
|
2559
|
+
for (const [b, l] of Object.entries(n))
|
|
2464
2560
|
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((f) => u.append(b, String(f))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
|
|
2465
|
-
|
|
2561
|
+
s.body = u;
|
|
2466
2562
|
} else
|
|
2467
|
-
a.set("Content-Type", "application/json"),
|
|
2563
|
+
a.set("Content-Type", "application/json"), s.body = JSON.stringify(n);
|
|
2468
2564
|
}
|
|
2469
|
-
if (
|
|
2565
|
+
if (s.headers = a, this.options.targetFragment && e) {
|
|
2470
2566
|
const g = performance.now();
|
|
2471
|
-
return
|
|
2567
|
+
return y.fetchStart(
|
|
2472
2568
|
this.options.targetFragment.getTarget(),
|
|
2473
2569
|
e,
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
), fetch(e,
|
|
2570
|
+
s,
|
|
2571
|
+
i ? n : void 0
|
|
2572
|
+
), fetch(e, s).then((u) => this.handleFetchResult(
|
|
2477
2573
|
u,
|
|
2478
2574
|
e || void 0,
|
|
2479
2575
|
g
|
|
2480
2576
|
)).catch((u) => {
|
|
2481
|
-
throw e &&
|
|
2577
|
+
throw e && y.fetchError(
|
|
2482
2578
|
this.options.targetFragment.getTarget(),
|
|
2483
2579
|
e,
|
|
2484
2580
|
u
|
|
2485
2581
|
), u;
|
|
2486
2582
|
});
|
|
2487
|
-
} else return e ? fetch(e,
|
|
2583
|
+
} else return e ? fetch(e, s).then((g) => this.handleFetchResult(g, e || void 0)) : Promise.resolve();
|
|
2488
2584
|
} else {
|
|
2489
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
2585
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && i) {
|
|
2490
2586
|
const o = this.options.formFragment, g = o.getTarget();
|
|
2491
2587
|
g.setAttribute(
|
|
2492
2588
|
`${c.prefix}bind`,
|
|
2493
|
-
JSON.stringify(
|
|
2589
|
+
JSON.stringify(n)
|
|
2494
2590
|
);
|
|
2495
2591
|
const u = o.getBindingData();
|
|
2496
|
-
return Object.assign(u,
|
|
2592
|
+
return Object.assign(u, n), T.setBindingData(g, u);
|
|
2497
2593
|
}
|
|
2498
|
-
const
|
|
2594
|
+
const s = i ? n : {}, a = new Response(JSON.stringify(s), {
|
|
2499
2595
|
headers: { "Content-Type": "application/json" }
|
|
2500
2596
|
});
|
|
2501
2597
|
return this.handleFetchResult(a);
|
|
@@ -2506,15 +2602,16 @@ ${f}
|
|
|
2506
2602
|
* フェッチ後の処理を実行します。
|
|
2507
2603
|
*/
|
|
2508
2604
|
handleFetchResult(t, e, r) {
|
|
2605
|
+
const n = U();
|
|
2509
2606
|
if (!t.ok)
|
|
2510
|
-
return this.options.targetFragment && e &&
|
|
2607
|
+
return this.options.targetFragment && e && y.fetchError(
|
|
2511
2608
|
this.options.targetFragment.getTarget(),
|
|
2512
2609
|
e,
|
|
2513
2610
|
new Error(`${t.status} ${t.statusText}`),
|
|
2514
2611
|
t.status,
|
|
2515
2612
|
r
|
|
2516
2613
|
), this.handleFetchError(t);
|
|
2517
|
-
if (this.options.targetFragment && e && r &&
|
|
2614
|
+
if (this.options.targetFragment && e && r && y.fetchEnd(
|
|
2518
2615
|
this.options.targetFragment.getTarget(),
|
|
2519
2616
|
e,
|
|
2520
2617
|
t.status,
|
|
@@ -2529,60 +2626,60 @@ ${f}
|
|
|
2529
2626
|
}
|
|
2530
2627
|
const i = [];
|
|
2531
2628
|
return i.push(this.bindResult(t)), i.push(this.adjust()), i.push(this.addRow()), i.push(this.removeRow()), i.push(this.movePrevRow()), i.push(this.moveNextRow()), this.options.resetFragments && this.options.resetFragments.length > 0 && this.options.resetFragments.forEach((s) => {
|
|
2532
|
-
i.push(
|
|
2629
|
+
i.push(E.reset(s));
|
|
2533
2630
|
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((s) => {
|
|
2534
2631
|
i.push(new d(s, null).run());
|
|
2535
2632
|
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((s) => {
|
|
2536
|
-
const
|
|
2537
|
-
typeof
|
|
2633
|
+
const a = s.getTarget();
|
|
2634
|
+
typeof a.click == "function" ? a.click() : a.dispatchEvent(
|
|
2538
2635
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
2539
2636
|
);
|
|
2540
2637
|
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((s) => {
|
|
2541
|
-
const
|
|
2542
|
-
|
|
2638
|
+
const a = s.getTarget();
|
|
2639
|
+
a instanceof HTMLElement ? i.push(n.openDialog(a)) : h.error("Haori", "Element is not an HTML element: ", a);
|
|
2543
2640
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((s) => {
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2546
|
-
}), Promise.all(i).then(() => this.options.dialogMessage ?
|
|
2641
|
+
const a = s.getTarget();
|
|
2642
|
+
a instanceof HTMLElement ? i.push(n.closeDialog(a)) : h.error("Haori", "Element is not an HTML element: ", a);
|
|
2643
|
+
}), Promise.all(i).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()));
|
|
2547
2644
|
}
|
|
2548
2645
|
/**
|
|
2549
2646
|
* フェッチエラー応答のメッセージを適切な要素へ伝播します。
|
|
2550
2647
|
*/
|
|
2551
2648
|
async handleFetchError(t) {
|
|
2552
2649
|
let e = null;
|
|
2553
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
2554
|
-
const r = async (
|
|
2555
|
-
const
|
|
2556
|
-
await
|
|
2650
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = E.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2651
|
+
const r = async (i) => {
|
|
2652
|
+
const s = e ? e.getTarget() : document.body;
|
|
2653
|
+
await U().addErrorMessage(s, i);
|
|
2557
2654
|
};
|
|
2558
2655
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
2559
2656
|
try {
|
|
2560
|
-
const
|
|
2561
|
-
if (
|
|
2562
|
-
if (typeof
|
|
2563
|
-
for (const a of
|
|
2564
|
-
typeof a == "string" &&
|
|
2565
|
-
if (
|
|
2566
|
-
for (const [a, o] of Object.entries(
|
|
2567
|
-
Array.isArray(o) ?
|
|
2568
|
-
`) }) : typeof o == "string" ?
|
|
2569
|
-
if (
|
|
2570
|
-
for (const [a, o] of Object.entries(
|
|
2571
|
-
a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ?
|
|
2572
|
-
`) }) : typeof o == "string" &&
|
|
2657
|
+
const i = await t.json(), s = [];
|
|
2658
|
+
if (i && typeof i == "object") {
|
|
2659
|
+
if (typeof i.message == "string" && s.push({ message: i.message }), Array.isArray(i.messages))
|
|
2660
|
+
for (const a of i.messages)
|
|
2661
|
+
typeof a == "string" && s.push({ message: a });
|
|
2662
|
+
if (i.errors && typeof i.errors == "object")
|
|
2663
|
+
for (const [a, o] of Object.entries(i.errors))
|
|
2664
|
+
Array.isArray(o) ? s.push({ key: a, message: o.join(`
|
|
2665
|
+
`) }) : typeof o == "string" ? s.push({ key: a, message: o }) : o != null && s.push({ key: a, message: String(o) });
|
|
2666
|
+
if (s.length === 0)
|
|
2667
|
+
for (const [a, o] of Object.entries(i))
|
|
2668
|
+
a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ? s.push({ key: a, message: o.join(`
|
|
2669
|
+
`) }) : typeof o == "string" && s.push({ key: a, message: o }));
|
|
2573
2670
|
}
|
|
2574
|
-
if (
|
|
2671
|
+
if (s.length === 0) {
|
|
2575
2672
|
await r(`${t.status} ${t.statusText}`);
|
|
2576
2673
|
return;
|
|
2577
2674
|
}
|
|
2578
|
-
for (const a of
|
|
2579
|
-
a.key && e ? await
|
|
2675
|
+
for (const a of s)
|
|
2676
|
+
a.key && e ? await E.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
2580
2677
|
return;
|
|
2581
2678
|
} catch {
|
|
2582
2679
|
}
|
|
2583
2680
|
try {
|
|
2584
|
-
const
|
|
2585
|
-
|
|
2681
|
+
const i = await t.text();
|
|
2682
|
+
i && i.trim().length > 0 ? await r(i.trim()) : await r(`${t.status} ${t.statusText}`);
|
|
2586
2683
|
} catch {
|
|
2587
2684
|
await r(`${t.status} ${t.statusText}`);
|
|
2588
2685
|
}
|
|
@@ -2599,8 +2696,8 @@ ${f}
|
|
|
2599
2696
|
return !0;
|
|
2600
2697
|
const e = t.getTarget();
|
|
2601
2698
|
let r = this.validateOne(t);
|
|
2602
|
-
return r || e.focus(), t.getChildElementFragments().reverse().forEach((
|
|
2603
|
-
r &&= this.validate(
|
|
2699
|
+
return r || e.focus(), t.getChildElementFragments().reverse().forEach((n) => {
|
|
2700
|
+
r &&= this.validate(n);
|
|
2604
2701
|
}), r;
|
|
2605
2702
|
}
|
|
2606
2703
|
/**
|
|
@@ -2621,7 +2718,7 @@ ${f}
|
|
|
2621
2718
|
*/
|
|
2622
2719
|
confirm() {
|
|
2623
2720
|
const t = this.options.confirmMessage;
|
|
2624
|
-
return t == null ? Promise.resolve(!0) :
|
|
2721
|
+
return t == null ? Promise.resolve(!0) : U().confirm(t);
|
|
2625
2722
|
}
|
|
2626
2723
|
/**
|
|
2627
2724
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -2631,32 +2728,32 @@ ${f}
|
|
|
2631
2728
|
bindResult(t) {
|
|
2632
2729
|
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) => {
|
|
2633
2730
|
if (this.options.bindParams) {
|
|
2634
|
-
const
|
|
2635
|
-
this.options.bindParams.forEach((
|
|
2636
|
-
r && typeof r == "object" &&
|
|
2637
|
-
}), r =
|
|
2731
|
+
const i = {};
|
|
2732
|
+
this.options.bindParams.forEach((s) => {
|
|
2733
|
+
r && typeof r == "object" && s in r && (i[s] = r[s]);
|
|
2734
|
+
}), r = i;
|
|
2638
2735
|
}
|
|
2639
|
-
const
|
|
2736
|
+
const n = [];
|
|
2640
2737
|
if (this.options.bindArg)
|
|
2641
|
-
this.options.bindFragments.forEach((
|
|
2642
|
-
const
|
|
2643
|
-
|
|
2738
|
+
this.options.bindFragments.forEach((i) => {
|
|
2739
|
+
const s = i.getBindingData();
|
|
2740
|
+
s[this.options.bindArg] = r, n.push(T.setBindingData(i.getTarget(), s));
|
|
2644
2741
|
});
|
|
2645
2742
|
else {
|
|
2646
2743
|
if (typeof r == "string")
|
|
2647
2744
|
return h.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
2648
2745
|
new Error("string data cannot be bound without a bindArg.")
|
|
2649
2746
|
);
|
|
2650
|
-
this.options.bindFragments.forEach((
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2747
|
+
this.options.bindFragments.forEach((i) => {
|
|
2748
|
+
n.push(
|
|
2749
|
+
T.setBindingData(
|
|
2750
|
+
i.getTarget(),
|
|
2654
2751
|
r
|
|
2655
2752
|
)
|
|
2656
2753
|
);
|
|
2657
2754
|
});
|
|
2658
2755
|
}
|
|
2659
|
-
return Promise.all(
|
|
2756
|
+
return Promise.all(n).then(() => {
|
|
2660
2757
|
});
|
|
2661
2758
|
});
|
|
2662
2759
|
}
|
|
@@ -2668,10 +2765,10 @@ ${f}
|
|
|
2668
2765
|
return Promise.resolve();
|
|
2669
2766
|
const t = this.options.adjustValue ?? 0, e = [];
|
|
2670
2767
|
for (const r of this.options.adjustFragments) {
|
|
2671
|
-
let
|
|
2672
|
-
(
|
|
2673
|
-
let
|
|
2674
|
-
isNaN(
|
|
2768
|
+
let n = r.getValue();
|
|
2769
|
+
(n == null || n === "") && (n = "0");
|
|
2770
|
+
let i = Number(n);
|
|
2771
|
+
isNaN(i) && (i = 0), i += t, e.push(r.setValue(String(i)));
|
|
2675
2772
|
}
|
|
2676
2773
|
return Promise.all(e).then(() => {
|
|
2677
2774
|
});
|
|
@@ -2703,7 +2800,7 @@ ${f}
|
|
|
2703
2800
|
const e = [], r = t.clone();
|
|
2704
2801
|
return e.push(
|
|
2705
2802
|
t.getParent().insertAfter(r, t)
|
|
2706
|
-
), e.push(
|
|
2803
|
+
), e.push(T.evaluateAll(r)), e.push(E.reset(r)), Promise.all(e).then(() => {
|
|
2707
2804
|
});
|
|
2708
2805
|
}
|
|
2709
2806
|
/**
|
|
@@ -2718,7 +2815,7 @@ ${f}
|
|
|
2718
2815
|
if (!t)
|
|
2719
2816
|
return Promise.reject(new Error("Row fragment not found."));
|
|
2720
2817
|
const e = t.getParent();
|
|
2721
|
-
return e && e.getChildElementFragments().filter((
|
|
2818
|
+
return e && e.getChildElementFragments().filter((n) => !n.hasAttribute(`${c.prefix}each-before`) && !n.hasAttribute(`${c.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
2722
2819
|
}
|
|
2723
2820
|
/**
|
|
2724
2821
|
* 前の行へ移動します。
|
|
@@ -2755,7 +2852,7 @@ ${f}
|
|
|
2755
2852
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
2756
2853
|
}
|
|
2757
2854
|
}
|
|
2758
|
-
class
|
|
2855
|
+
class Z {
|
|
2759
2856
|
/**
|
|
2760
2857
|
* URLのクエリパラメータを取得します。
|
|
2761
2858
|
*
|
|
@@ -2763,12 +2860,12 @@ class X {
|
|
|
2763
2860
|
*/
|
|
2764
2861
|
static readParams() {
|
|
2765
2862
|
const t = {}, e = window.location.search;
|
|
2766
|
-
return new URLSearchParams(e).forEach((
|
|
2767
|
-
t[
|
|
2863
|
+
return new URLSearchParams(e).forEach((n, i) => {
|
|
2864
|
+
t[i] = n;
|
|
2768
2865
|
}), t;
|
|
2769
2866
|
}
|
|
2770
2867
|
}
|
|
2771
|
-
class
|
|
2868
|
+
class _ {
|
|
2772
2869
|
/**
|
|
2773
2870
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
2774
2871
|
*
|
|
@@ -2785,24 +2882,24 @@ class J {
|
|
|
2785
2882
|
let r;
|
|
2786
2883
|
try {
|
|
2787
2884
|
r = await fetch(t, e);
|
|
2788
|
-
} catch (
|
|
2789
|
-
throw h.error("[Haori]", "Failed to fetch import source:", t,
|
|
2885
|
+
} catch (i) {
|
|
2886
|
+
throw h.error("[Haori]", "Failed to fetch import source:", t, i), new Error(`Failed to fetch: ${t}`);
|
|
2790
2887
|
}
|
|
2791
2888
|
if (!r.ok) {
|
|
2792
|
-
const
|
|
2793
|
-
throw h.error("[Haori]", "Import HTTP error:", t,
|
|
2889
|
+
const i = `${r.status} ${r.statusText}`;
|
|
2890
|
+
throw h.error("[Haori]", "Import HTTP error:", t, i), new Error(`Failed to load ${t}: ${i}`);
|
|
2794
2891
|
}
|
|
2795
|
-
let
|
|
2892
|
+
let n;
|
|
2796
2893
|
try {
|
|
2797
|
-
|
|
2798
|
-
} catch (
|
|
2799
|
-
throw h.error("[Haori]", "Failed to read response text:", t,
|
|
2894
|
+
n = await r.text();
|
|
2895
|
+
} catch (i) {
|
|
2896
|
+
throw h.error("[Haori]", "Failed to read response text:", t, i), new Error(`Failed to read response from: ${t}`);
|
|
2800
2897
|
}
|
|
2801
2898
|
try {
|
|
2802
|
-
const
|
|
2803
|
-
return
|
|
2804
|
-
} catch (
|
|
2805
|
-
return h.error("[Haori]", "Failed to parse imported HTML:", t,
|
|
2899
|
+
const s = new DOMParser().parseFromString(n, "text/html");
|
|
2900
|
+
return s && s.body ? s.body.innerHTML : (h.warn("[Haori]", "No body found in imported document:", t), n);
|
|
2901
|
+
} catch (i) {
|
|
2902
|
+
return h.error("[Haori]", "Failed to parse imported HTML:", t, i), n;
|
|
2806
2903
|
}
|
|
2807
2904
|
}
|
|
2808
2905
|
}
|
|
@@ -2829,35 +2926,35 @@ const m = class m {
|
|
|
2829
2926
|
if (!e)
|
|
2830
2927
|
return Promise.resolve();
|
|
2831
2928
|
t.parentNode && (A.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
2832
|
-
const r = [],
|
|
2833
|
-
for (const
|
|
2834
|
-
const
|
|
2835
|
-
e.hasAttribute(
|
|
2929
|
+
const r = [], n = /* @__PURE__ */ new Set();
|
|
2930
|
+
for (const i of m.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
2931
|
+
const s = c.prefix + i;
|
|
2932
|
+
e.hasAttribute(s) && (r.push(
|
|
2836
2933
|
m.setAttribute(
|
|
2837
2934
|
e.getTarget(),
|
|
2838
|
-
|
|
2839
|
-
e.getRawAttribute(
|
|
2935
|
+
s,
|
|
2936
|
+
e.getRawAttribute(s)
|
|
2840
2937
|
)
|
|
2841
|
-
),
|
|
2938
|
+
), n.add(s));
|
|
2842
2939
|
}
|
|
2843
|
-
for (const
|
|
2844
|
-
if (
|
|
2940
|
+
for (const i of e.getAttributeNames()) {
|
|
2941
|
+
if (n.has(i) || m.isDeferredAttributeName(i))
|
|
2845
2942
|
continue;
|
|
2846
|
-
const
|
|
2847
|
-
|
|
2943
|
+
const s = e.getRawAttribute(i);
|
|
2944
|
+
s !== null && r.push(m.setAttribute(e.getTarget(), i, s));
|
|
2848
2945
|
}
|
|
2849
|
-
for (const
|
|
2850
|
-
const
|
|
2851
|
-
e.hasAttribute(
|
|
2946
|
+
for (const i of m.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
2947
|
+
const s = c.prefix + i;
|
|
2948
|
+
e.hasAttribute(s) && (r.push(
|
|
2852
2949
|
m.setAttribute(
|
|
2853
2950
|
e.getTarget(),
|
|
2854
|
-
|
|
2855
|
-
e.getRawAttribute(
|
|
2951
|
+
s,
|
|
2952
|
+
e.getRawAttribute(s)
|
|
2856
2953
|
)
|
|
2857
|
-
),
|
|
2954
|
+
), n.add(s));
|
|
2858
2955
|
}
|
|
2859
|
-
return e.getChildren().forEach((
|
|
2860
|
-
|
|
2956
|
+
return e.getChildren().forEach((i) => {
|
|
2957
|
+
i instanceof M ? r.push(m.scan(i.getTarget())) : i instanceof $ && r.push(m.evaluateText(i));
|
|
2861
2958
|
}), Promise.all(r).then(() => {
|
|
2862
2959
|
});
|
|
2863
2960
|
}
|
|
@@ -2871,51 +2968,51 @@ const m = class m {
|
|
|
2871
2968
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
2872
2969
|
*/
|
|
2873
2970
|
static setAttribute(t, e, r) {
|
|
2874
|
-
const
|
|
2971
|
+
const n = A.get(t), i = [];
|
|
2875
2972
|
switch (e) {
|
|
2876
2973
|
case `${c.prefix}bind`: {
|
|
2877
|
-
r === null ? (
|
|
2974
|
+
r === null ? (n.clearBindingDataCache(), n.setBindingData({})) : n.setBindingData(m.parseDataBind(r));
|
|
2878
2975
|
break;
|
|
2879
2976
|
}
|
|
2880
2977
|
case `${c.prefix}if`:
|
|
2881
|
-
|
|
2978
|
+
i.push(m.evaluateIf(n));
|
|
2882
2979
|
break;
|
|
2883
2980
|
case `${c.prefix}each`:
|
|
2884
|
-
|
|
2981
|
+
i.push(m.evaluateEach(n));
|
|
2885
2982
|
break;
|
|
2886
2983
|
case `${c.prefix}fetch`:
|
|
2887
|
-
|
|
2984
|
+
i.push(new d(n, null).run());
|
|
2888
2985
|
break;
|
|
2889
2986
|
case `${c.prefix}import`: {
|
|
2890
2987
|
if (typeof r == "string") {
|
|
2891
|
-
const
|
|
2892
|
-
|
|
2893
|
-
|
|
2988
|
+
const s = n.getTarget(), a = performance.now();
|
|
2989
|
+
y.importStart(s, r), i.push(
|
|
2990
|
+
_.load(r).then((o) => {
|
|
2894
2991
|
const g = new TextEncoder().encode(o).length;
|
|
2895
|
-
return
|
|
2896
|
-
|
|
2992
|
+
return N.enqueue(() => {
|
|
2993
|
+
s.innerHTML = o;
|
|
2897
2994
|
}).then(() => {
|
|
2898
|
-
|
|
2995
|
+
y.importEnd(s, r, g, a);
|
|
2899
2996
|
});
|
|
2900
2997
|
}).catch((o) => {
|
|
2901
|
-
|
|
2998
|
+
y.importError(s, r, o), h.error("[Haori]", "Failed to import HTML:", r, o);
|
|
2902
2999
|
})
|
|
2903
3000
|
);
|
|
2904
3001
|
}
|
|
2905
3002
|
break;
|
|
2906
3003
|
}
|
|
2907
3004
|
case `${c.prefix}url-param`: {
|
|
2908
|
-
const
|
|
2909
|
-
if (
|
|
3005
|
+
const s = n.getAttribute(`${c.prefix}url-arg`), a = Z.readParams();
|
|
3006
|
+
if (s === null)
|
|
2910
3007
|
m.setBindingData(t, a);
|
|
2911
3008
|
else {
|
|
2912
|
-
const o =
|
|
2913
|
-
o[String(
|
|
3009
|
+
const o = n.getRawBindingData() || {};
|
|
3010
|
+
o[String(s)] = a, m.setBindingData(t, o);
|
|
2914
3011
|
}
|
|
2915
3012
|
break;
|
|
2916
3013
|
}
|
|
2917
3014
|
}
|
|
2918
|
-
return r === null ?
|
|
3015
|
+
return r === null ? i.push(n.removeAttribute(e)) : i.push(n.setAttribute(e, r)), Promise.all(i).then(() => {
|
|
2919
3016
|
});
|
|
2920
3017
|
}
|
|
2921
3018
|
/**
|
|
@@ -2927,12 +3024,12 @@ const m = class m {
|
|
|
2927
3024
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
2928
3025
|
*/
|
|
2929
3026
|
static setBindingData(t, e) {
|
|
2930
|
-
const r = A.get(t),
|
|
3027
|
+
const r = A.get(t), n = r.getRawBindingData();
|
|
2931
3028
|
r.setBindingData(e);
|
|
2932
|
-
const
|
|
2933
|
-
return
|
|
3029
|
+
const i = [];
|
|
3030
|
+
return i.push(
|
|
2934
3031
|
r.setAttribute(`${c.prefix}bind`, JSON.stringify(e))
|
|
2935
|
-
),
|
|
3032
|
+
), i.push(m.evaluateAll(r)), y.bindChange(t, n, e, "manual"), Promise.all(i).then(() => {
|
|
2936
3033
|
});
|
|
2937
3034
|
}
|
|
2938
3035
|
/**
|
|
@@ -2950,8 +3047,8 @@ const m = class m {
|
|
|
2950
3047
|
}
|
|
2951
3048
|
else {
|
|
2952
3049
|
const e = new URLSearchParams(t), r = {};
|
|
2953
|
-
for (const [
|
|
2954
|
-
r[
|
|
3050
|
+
for (const [n, i] of e.entries())
|
|
3051
|
+
r[n] !== void 0 ? Array.isArray(r[n]) ? r[n].push(i) : r[n] = [r[n], i] : r[n] = i;
|
|
2955
3052
|
return r;
|
|
2956
3053
|
}
|
|
2957
3054
|
}
|
|
@@ -2965,8 +3062,8 @@ const m = class m {
|
|
|
2965
3062
|
const r = A.get(t);
|
|
2966
3063
|
if (r.isSkipMutationNodes())
|
|
2967
3064
|
return;
|
|
2968
|
-
const
|
|
2969
|
-
|
|
3065
|
+
const n = A.get(e.nextSibling), i = A.get(e);
|
|
3066
|
+
i && (r.insertBefore(i, n), i instanceof M ? m.scan(i.getTarget()) : i instanceof $ && m.evaluateText(i));
|
|
2970
3067
|
}
|
|
2971
3068
|
/**
|
|
2972
3069
|
* ノードを親要素から削除します。
|
|
@@ -3004,15 +3101,15 @@ const m = class m {
|
|
|
3004
3101
|
const r = A.get(t);
|
|
3005
3102
|
if (r.getValue() === e)
|
|
3006
3103
|
return Promise.resolve();
|
|
3007
|
-
const
|
|
3008
|
-
|
|
3009
|
-
const
|
|
3010
|
-
if (
|
|
3011
|
-
const
|
|
3104
|
+
const n = [];
|
|
3105
|
+
n.push(r.setValue(e));
|
|
3106
|
+
const i = m.getFormFragment(r);
|
|
3107
|
+
if (i) {
|
|
3108
|
+
const s = E.getValues(i), a = i.getAttribute(`${c.prefix}form-arg`);
|
|
3012
3109
|
let o;
|
|
3013
|
-
a ? (o =
|
|
3110
|
+
a ? (o = i.getRawBindingData(), o || (o = {}), o[String(a)] = s) : o = s, n.push(m.setBindingData(i.getTarget(), o));
|
|
3014
3111
|
}
|
|
3015
|
-
return Promise.all(
|
|
3112
|
+
return Promise.all(n).then(() => {
|
|
3016
3113
|
});
|
|
3017
3114
|
}
|
|
3018
3115
|
/**
|
|
@@ -3036,7 +3133,7 @@ const m = class m {
|
|
|
3036
3133
|
static evaluateAll(t) {
|
|
3037
3134
|
const e = [];
|
|
3038
3135
|
return t.hasAttribute(`${c.prefix}if`) && e.push(m.evaluateIf(t)), t.hasAttribute(`${c.prefix}each`) && e.push(m.evaluateEach(t)), t.getChildren().forEach((r) => {
|
|
3039
|
-
r instanceof
|
|
3136
|
+
r instanceof M ? e.push(m.evaluateAll(r)) : r instanceof $ && e.push(m.evaluateText(r));
|
|
3040
3137
|
}), Promise.all(e).then(() => {
|
|
3041
3138
|
});
|
|
3042
3139
|
}
|
|
@@ -3060,11 +3157,11 @@ const m = class m {
|
|
|
3060
3157
|
const e = [], r = t.getAttribute(`${c.prefix}if`);
|
|
3061
3158
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3062
3159
|
t.hide().then(() => {
|
|
3063
|
-
|
|
3160
|
+
y.hide(t.getTarget());
|
|
3064
3161
|
})
|
|
3065
3162
|
) : t.isVisible() || (e.push(
|
|
3066
3163
|
t.show().then(() => {
|
|
3067
|
-
|
|
3164
|
+
y.show(t.getTarget());
|
|
3068
3165
|
})
|
|
3069
3166
|
), e.push(m.evaluateAll(t))), Promise.all(e).then(() => {
|
|
3070
3167
|
});
|
|
@@ -3080,18 +3177,18 @@ const m = class m {
|
|
|
3080
3177
|
return Promise.resolve();
|
|
3081
3178
|
let e = t.getTemplate();
|
|
3082
3179
|
if (e === null) {
|
|
3083
|
-
let
|
|
3084
|
-
t.getChildren().forEach((
|
|
3085
|
-
if (!
|
|
3086
|
-
if (
|
|
3180
|
+
let n = !1;
|
|
3181
|
+
t.getChildren().forEach((s) => {
|
|
3182
|
+
if (!n && s instanceof M) {
|
|
3183
|
+
if (s.hasAttribute(`${c.prefix}each-before`) || s.hasAttribute(`${c.prefix}each-after`))
|
|
3087
3184
|
return;
|
|
3088
|
-
e =
|
|
3089
|
-
const a =
|
|
3090
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3185
|
+
e = s.clone(), t.setTemplate(e), n = !0, t.removeChild(s);
|
|
3186
|
+
const a = s.getTarget();
|
|
3187
|
+
a.parentNode && a.parentNode.removeChild(a), s.setMounted(!1);
|
|
3091
3188
|
}
|
|
3092
3189
|
});
|
|
3093
|
-
const
|
|
3094
|
-
return Array.isArray(
|
|
3190
|
+
const i = t.getAttribute(`${c.prefix}each`);
|
|
3191
|
+
return Array.isArray(i) ? this.updateDiff(t, i) : (h.error("[Haori]", "Invalid each attribute:", i), Promise.reject(new Error("Invalid each attribute.")));
|
|
3095
3192
|
}
|
|
3096
3193
|
const r = t.getAttribute(`${c.prefix}each`);
|
|
3097
3194
|
return Array.isArray(r) ? this.updateDiff(t, r) : (h.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
@@ -3106,50 +3203,50 @@ const m = class m {
|
|
|
3106
3203
|
const r = t.getTemplate();
|
|
3107
3204
|
if (r === null)
|
|
3108
3205
|
return h.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3109
|
-
let
|
|
3110
|
-
|
|
3111
|
-
const
|
|
3206
|
+
let n = t.getAttribute(`${c.prefix}each-index`);
|
|
3207
|
+
n && (n = String(n));
|
|
3208
|
+
const i = t.getAttribute(`${c.prefix}each-key`), s = t.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3112
3209
|
e.forEach((p, w) => {
|
|
3113
3210
|
const v = m.createListKey(
|
|
3114
3211
|
p,
|
|
3115
|
-
|
|
3212
|
+
i ? String(i) : null,
|
|
3116
3213
|
w
|
|
3117
3214
|
);
|
|
3118
3215
|
o.push(v), a.set(v, { item: p, itemIndex: w });
|
|
3119
3216
|
});
|
|
3120
3217
|
const g = [];
|
|
3121
|
-
let u = t.getChildren().filter((p) => p instanceof
|
|
3218
|
+
let u = t.getChildren().filter((p) => p instanceof M).filter(
|
|
3122
3219
|
(p) => !p.hasAttribute(`${c.prefix}each-before`) && !p.hasAttribute(`${c.prefix}each-after`)
|
|
3123
3220
|
);
|
|
3124
3221
|
u = u.filter((p) => o.indexOf(String(p.getListKey())) === -1 ? (g.push(p.remove()), !1) : !0);
|
|
3125
|
-
const b = u.map((p) => p.getListKey()), l = t.getChildren().filter((p) => p instanceof
|
|
3222
|
+
const b = u.map((p) => p.getListKey()), l = t.getChildren().filter((p) => p instanceof M).filter((p) => p.hasAttribute(`${c.prefix}each-before`)).length;
|
|
3126
3223
|
let f = Promise.resolve();
|
|
3127
3224
|
return o.forEach((p, w) => {
|
|
3128
|
-
const v = b.indexOf(p), { item:
|
|
3225
|
+
const v = b.indexOf(p), { item: I, itemIndex: x } = a.get(p);
|
|
3129
3226
|
let F;
|
|
3130
3227
|
if (v !== -1)
|
|
3131
3228
|
F = u[v], m.updateRowFragment(
|
|
3132
3229
|
F,
|
|
3133
|
-
|
|
3134
|
-
|
|
3230
|
+
I,
|
|
3231
|
+
n,
|
|
3135
3232
|
x,
|
|
3136
|
-
|
|
3233
|
+
s ? String(s) : null,
|
|
3137
3234
|
p
|
|
3138
3235
|
), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache(), f = f.then(() => m.evaluateAll(F));
|
|
3139
3236
|
else {
|
|
3140
3237
|
F = r.clone(), m.updateRowFragment(
|
|
3141
3238
|
F,
|
|
3142
|
-
|
|
3143
|
-
|
|
3239
|
+
I,
|
|
3240
|
+
n,
|
|
3144
3241
|
x,
|
|
3145
|
-
|
|
3242
|
+
s ? String(s) : null,
|
|
3146
3243
|
p
|
|
3147
3244
|
), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache();
|
|
3148
|
-
const
|
|
3245
|
+
const X = l + w;
|
|
3149
3246
|
f = f.then(
|
|
3150
3247
|
() => t.insertBefore(
|
|
3151
3248
|
F,
|
|
3152
|
-
t.getChildren()[
|
|
3249
|
+
t.getChildren()[X] || null
|
|
3153
3250
|
).then(() => m.evaluateAll(F))
|
|
3154
3251
|
);
|
|
3155
3252
|
}
|
|
@@ -3160,13 +3257,13 @@ const m = class m {
|
|
|
3160
3257
|
(x) => x !== null
|
|
3161
3258
|
), v = p.filter(
|
|
3162
3259
|
(x) => !w.includes(x)
|
|
3163
|
-
),
|
|
3260
|
+
), I = w.filter(
|
|
3164
3261
|
(x) => !p.includes(x)
|
|
3165
3262
|
);
|
|
3166
|
-
|
|
3263
|
+
y.eachUpdate(
|
|
3167
3264
|
t.getTarget(),
|
|
3168
3265
|
v,
|
|
3169
|
-
|
|
3266
|
+
I,
|
|
3170
3267
|
p
|
|
3171
3268
|
);
|
|
3172
3269
|
});
|
|
@@ -3180,16 +3277,16 @@ const m = class m {
|
|
|
3180
3277
|
* @returns リストキー
|
|
3181
3278
|
*/
|
|
3182
3279
|
static createListKey(t, e, r) {
|
|
3183
|
-
let
|
|
3280
|
+
let n;
|
|
3184
3281
|
if (typeof t == "object" && t !== null)
|
|
3185
3282
|
if (e) {
|
|
3186
|
-
const
|
|
3187
|
-
|
|
3283
|
+
const i = t[e];
|
|
3284
|
+
i == null ? n = `__index_${r}` : typeof i == "object" ? n = JSON.stringify(i) : n = String(i);
|
|
3188
3285
|
} else
|
|
3189
|
-
|
|
3286
|
+
n = `__index_${r}`;
|
|
3190
3287
|
else
|
|
3191
|
-
|
|
3192
|
-
return
|
|
3288
|
+
n = String(t);
|
|
3289
|
+
return n;
|
|
3193
3290
|
}
|
|
3194
3291
|
/**
|
|
3195
3292
|
* 行フラグメントにデータを設定します。
|
|
@@ -3201,16 +3298,16 @@ const m = class m {
|
|
|
3201
3298
|
* @param arg バインドデータパラメータ名
|
|
3202
3299
|
* @param listKey リストキー
|
|
3203
3300
|
*/
|
|
3204
|
-
static updateRowFragment(t, e, r, i, s
|
|
3301
|
+
static updateRowFragment(t, e, r, n, i, s) {
|
|
3205
3302
|
let a = e;
|
|
3206
3303
|
if (typeof e == "object" && e !== null)
|
|
3207
|
-
a = { ...e }, r && (a[r] =
|
|
3208
|
-
[
|
|
3304
|
+
a = { ...e }, r && (a[r] = n), i && (a = {
|
|
3305
|
+
[i]: a
|
|
3209
3306
|
});
|
|
3210
|
-
else if (
|
|
3307
|
+
else if (i)
|
|
3211
3308
|
a = {
|
|
3212
|
-
[
|
|
3213
|
-
}, r && (a[r] =
|
|
3309
|
+
[i]: e
|
|
3310
|
+
}, r && (a[r] = n);
|
|
3214
3311
|
else {
|
|
3215
3312
|
h.error(
|
|
3216
3313
|
"[Haori]",
|
|
@@ -3218,12 +3315,12 @@ const m = class m {
|
|
|
3218
3315
|
);
|
|
3219
3316
|
return;
|
|
3220
3317
|
}
|
|
3221
|
-
t.setListKey(
|
|
3318
|
+
t.setListKey(s), t.setAttribute(`${c.prefix}row`, s), t.setBindingData(a);
|
|
3222
3319
|
}
|
|
3223
3320
|
};
|
|
3224
3321
|
m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"];
|
|
3225
|
-
let
|
|
3226
|
-
class
|
|
3322
|
+
let T = m;
|
|
3323
|
+
class tt {
|
|
3227
3324
|
/**
|
|
3228
3325
|
* コンストラクタ。
|
|
3229
3326
|
*
|
|
@@ -3258,9 +3355,9 @@ class z {
|
|
|
3258
3355
|
const r = this.getElementFromTarget(t.target);
|
|
3259
3356
|
if (!r)
|
|
3260
3357
|
return;
|
|
3261
|
-
const
|
|
3262
|
-
|
|
3263
|
-
h.error("[Haori]", "Procedure execution error:",
|
|
3358
|
+
const n = A.get(r);
|
|
3359
|
+
n && (e === "change" && n instanceof M && n.syncValue(), new d(n, e).run().catch((i) => {
|
|
3360
|
+
h.error("[Haori]", "Procedure execution error:", i);
|
|
3264
3361
|
}));
|
|
3265
3362
|
}
|
|
3266
3363
|
/**
|
|
@@ -3283,10 +3380,10 @@ const C = class C {
|
|
|
3283
3380
|
return;
|
|
3284
3381
|
C._initialized = !0;
|
|
3285
3382
|
const t = await Promise.allSettled([
|
|
3286
|
-
|
|
3287
|
-
|
|
3383
|
+
T.scan(document.head),
|
|
3384
|
+
T.scan(document.body)
|
|
3288
3385
|
]), [e, r] = t;
|
|
3289
|
-
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), C.observe(document.head), C.observe(document.body), new
|
|
3386
|
+
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), C.observe(document.head), C.observe(document.body), new tt().start();
|
|
3290
3387
|
}
|
|
3291
3388
|
/**
|
|
3292
3389
|
* 指定された要素を監視します。
|
|
@@ -3295,21 +3392,21 @@ const C = class C {
|
|
|
3295
3392
|
*/
|
|
3296
3393
|
static observe(t) {
|
|
3297
3394
|
new MutationObserver(async (r) => {
|
|
3298
|
-
for (const
|
|
3395
|
+
for (const n of r)
|
|
3299
3396
|
try {
|
|
3300
|
-
switch (
|
|
3397
|
+
switch (n.type) {
|
|
3301
3398
|
case "attributes": {
|
|
3302
3399
|
h.info(
|
|
3303
3400
|
"[Haori]",
|
|
3304
3401
|
"Attribute changed:",
|
|
3305
|
-
|
|
3306
|
-
|
|
3402
|
+
n.target,
|
|
3403
|
+
n.attributeName
|
|
3307
3404
|
);
|
|
3308
|
-
const
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3405
|
+
const i = n.target;
|
|
3406
|
+
T.setAttribute(
|
|
3407
|
+
i,
|
|
3408
|
+
n.attributeName,
|
|
3409
|
+
i.getAttribute(n.attributeName)
|
|
3313
3410
|
);
|
|
3314
3411
|
break;
|
|
3315
3412
|
}
|
|
@@ -3317,12 +3414,12 @@ const C = class C {
|
|
|
3317
3414
|
h.info(
|
|
3318
3415
|
"[Haori]",
|
|
3319
3416
|
"Child list changed:",
|
|
3320
|
-
Array.from(
|
|
3321
|
-
Array.from(
|
|
3322
|
-
), Array.from(
|
|
3323
|
-
|
|
3324
|
-
}), Array.from(
|
|
3325
|
-
|
|
3417
|
+
Array.from(n.removedNodes).map((i) => i.nodeName),
|
|
3418
|
+
Array.from(n.addedNodes).map((i) => i.nodeName)
|
|
3419
|
+
), Array.from(n.removedNodes).forEach((i) => {
|
|
3420
|
+
T.removeNode(i);
|
|
3421
|
+
}), Array.from(n.addedNodes).forEach((i) => {
|
|
3422
|
+
i.parentElement instanceof HTMLElement && T.addNode(i.parentElement, i);
|
|
3326
3423
|
});
|
|
3327
3424
|
break;
|
|
3328
3425
|
}
|
|
@@ -3330,21 +3427,21 @@ const C = class C {
|
|
|
3330
3427
|
h.info(
|
|
3331
3428
|
"[Haori]",
|
|
3332
3429
|
"Character data changed:",
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
),
|
|
3430
|
+
n.target,
|
|
3431
|
+
n.target.textContent
|
|
3432
|
+
), n.target instanceof Text || n.target instanceof Comment ? T.changeText(n.target, n.target.textContent) : h.warn(
|
|
3336
3433
|
"[Haori]",
|
|
3337
3434
|
"Unsupported character data type:",
|
|
3338
|
-
|
|
3435
|
+
n.target
|
|
3339
3436
|
);
|
|
3340
3437
|
break;
|
|
3341
3438
|
}
|
|
3342
3439
|
default:
|
|
3343
|
-
h.warn("[Haori]", "Unknown mutation type:",
|
|
3440
|
+
h.warn("[Haori]", "Unknown mutation type:", n.type);
|
|
3344
3441
|
continue;
|
|
3345
3442
|
}
|
|
3346
|
-
} catch (
|
|
3347
|
-
h.error("[Haori]", "Error processing mutation:",
|
|
3443
|
+
} catch (i) {
|
|
3444
|
+
h.error("[Haori]", "Error processing mutation:", i);
|
|
3348
3445
|
}
|
|
3349
3446
|
}).observe(t, {
|
|
3350
3447
|
childList: !0,
|
|
@@ -3355,18 +3452,18 @@ const C = class C {
|
|
|
3355
3452
|
}
|
|
3356
3453
|
};
|
|
3357
3454
|
C._initialized = !1;
|
|
3358
|
-
let
|
|
3359
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
3360
|
-
const
|
|
3455
|
+
let L = C;
|
|
3456
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", L.init) : L.init();
|
|
3457
|
+
const et = "0.1.3";
|
|
3361
3458
|
export {
|
|
3362
|
-
|
|
3459
|
+
T as Core,
|
|
3363
3460
|
c as Env,
|
|
3364
|
-
|
|
3461
|
+
E as Form,
|
|
3365
3462
|
A as Fragment,
|
|
3366
|
-
|
|
3463
|
+
Y as Haori,
|
|
3367
3464
|
h as Log,
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3465
|
+
N as Queue,
|
|
3466
|
+
Y as default,
|
|
3467
|
+
et as version
|
|
3371
3468
|
};
|
|
3372
3469
|
//# sourceMappingURL=haori.es.js.map
|