haori 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +3 -1
- package/README.md +3 -1
- package/dist/haori.cjs.js +11 -11
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +1134 -898
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +11 -11
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +38 -6
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +1 -1
- package/dist/src/core.js.map +1 -1
- package/dist/src/env.d.ts +18 -0
- package/dist/src/env.d.ts.map +1 -1
- package/dist/src/env.js +44 -0
- package/dist/src/env.js.map +1 -1
- package/dist/src/event.d.ts +16 -1
- package/dist/src/event.d.ts.map +1 -1
- package/dist/src/event.js +4 -4
- package/dist/src/event.js.map +1 -1
- package/dist/src/haori.d.ts +13 -0
- package/dist/src/haori.d.ts.map +1 -1
- package/dist/src/haori.js +18 -0
- package/dist/src/haori.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/intersect.d.ts +21 -0
- package/dist/src/intersect.d.ts.map +1 -0
- package/dist/src/intersect.js +188 -0
- package/dist/src/intersect.js.map +1 -0
- package/dist/src/observer.d.ts.map +1 -1
- package/dist/src/observer.js +5 -0
- package/dist/src/observer.js.map +1 -1
- package/dist/src/procedure.d.ts +18 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +272 -172
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/env.test.js +28 -0
- package/dist/tests/env.test.js.map +1 -1
- package/dist/tests/event.test.js +13 -1
- package/dist/tests/event.test.js.map +1 -1
- package/dist/tests/intersect.test.d.ts +2 -0
- package/dist/tests/intersect.test.d.ts.map +1 -0
- package/dist/tests/intersect.test.js +173 -0
- package/dist/tests/intersect.test.js.map +1 -0
- package/dist/tests/procedure-bind-append.test.d.ts +2 -0
- package/dist/tests/procedure-bind-append.test.d.ts.map +1 -0
- package/dist/tests/procedure-bind-append.test.js +80 -0
- package/dist/tests/procedure-bind-append.test.js.map +1 -0
- package/dist/tests/procedure-fetch-options.test.js +58 -0
- package/dist/tests/procedure-fetch-options.test.js.map +1 -1
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const O = class O {
|
|
2
2
|
/**
|
|
3
3
|
* 開発モードの状態を取得します。
|
|
4
4
|
*
|
|
5
5
|
* @returns 開発モードならtrue、そうでなければfalse
|
|
6
6
|
*/
|
|
7
7
|
static isEnabled() {
|
|
8
|
-
return
|
|
8
|
+
return O.devMode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 開発モードを有効化します。
|
|
12
12
|
*/
|
|
13
13
|
static enable() {
|
|
14
|
-
|
|
14
|
+
O.devMode = !0;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 開発モードを無効化します。
|
|
18
18
|
*/
|
|
19
19
|
static disable() {
|
|
20
|
-
|
|
20
|
+
O.devMode = !1;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 開発モードを切り替えます。
|
|
@@ -25,12 +25,36 @@ const D = class D {
|
|
|
25
25
|
* @param enabled trueで有効化、falseで無効化
|
|
26
26
|
*/
|
|
27
27
|
static set(t) {
|
|
28
|
-
|
|
28
|
+
O.devMode = t;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
let
|
|
31
|
+
O.devMode = !1;
|
|
32
|
+
let I = O;
|
|
33
|
+
const W = "embedded";
|
|
34
|
+
function Z(S) {
|
|
35
|
+
return S === "embedded" || S === "demo";
|
|
36
|
+
}
|
|
37
|
+
function tt(S) {
|
|
38
|
+
return S === null ? null : Z(S) ? S : W;
|
|
39
|
+
}
|
|
33
40
|
const M = class M {
|
|
41
|
+
/**
|
|
42
|
+
* 実行モードを取得します。
|
|
43
|
+
*
|
|
44
|
+
* @returns 実行モード。
|
|
45
|
+
*/
|
|
46
|
+
static get runtime() {
|
|
47
|
+
return M._runtime;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 実行モードを設定します。
|
|
51
|
+
*
|
|
52
|
+
* @param runtime 設定する実行モード。
|
|
53
|
+
* @return 戻り値はありません。
|
|
54
|
+
*/
|
|
55
|
+
static setRuntime(t) {
|
|
56
|
+
M._runtime = Z(t) ? t : W;
|
|
57
|
+
}
|
|
34
58
|
/**
|
|
35
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
36
60
|
* scriptタグにdata-prefixがある場合は、その値+"-"をプレフィックスとして使用します。
|
|
@@ -43,17 +67,21 @@ const M = class M {
|
|
|
43
67
|
if (t instanceof HTMLScriptElement) {
|
|
44
68
|
const r = t.getAttribute("data-prefix") || M._prefix;
|
|
45
69
|
M._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
+
const i = tt(
|
|
71
|
+
t.getAttribute("data-runtime")
|
|
72
|
+
);
|
|
73
|
+
i !== null && (M._runtime = i);
|
|
46
74
|
}
|
|
47
75
|
if (t instanceof HTMLScriptElement && t.hasAttribute(`${M._prefix}dev`)) {
|
|
48
|
-
|
|
76
|
+
I.set(!0);
|
|
49
77
|
return;
|
|
50
78
|
}
|
|
51
79
|
const e = window.location.hostname;
|
|
52
80
|
if (e === "localhost" || e.endsWith(".localhost") || e === "127.0.0.1" || e === "::1" || e.endsWith(".local")) {
|
|
53
|
-
|
|
81
|
+
I.set(!0);
|
|
54
82
|
return;
|
|
55
83
|
}
|
|
56
|
-
|
|
84
|
+
I.set(!1);
|
|
57
85
|
} catch {
|
|
58
86
|
}
|
|
59
87
|
}
|
|
@@ -66,9 +94,9 @@ const M = class M {
|
|
|
66
94
|
return M._prefix;
|
|
67
95
|
}
|
|
68
96
|
};
|
|
69
|
-
M._prefix = "data-";
|
|
70
|
-
let
|
|
71
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
97
|
+
M._prefix = "data-", M._runtime = W;
|
|
98
|
+
let l = M;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l.detect) : l.detect();
|
|
72
100
|
class h {
|
|
73
101
|
/**
|
|
74
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
@@ -77,7 +105,7 @@ class h {
|
|
|
77
105
|
* @param args 追加の引数
|
|
78
106
|
*/
|
|
79
107
|
static info(t, ...e) {
|
|
80
|
-
|
|
108
|
+
I.isEnabled() && console.log && console.log(t, ...e);
|
|
81
109
|
}
|
|
82
110
|
/**
|
|
83
111
|
* 開発モードでのみコンソールに警告を出力します。
|
|
@@ -86,7 +114,7 @@ class h {
|
|
|
86
114
|
* @param args 追加の引数
|
|
87
115
|
*/
|
|
88
116
|
static warn(t, ...e) {
|
|
89
|
-
|
|
117
|
+
I.isEnabled() && console.warn && console.warn(t, ...e);
|
|
90
118
|
}
|
|
91
119
|
/**
|
|
92
120
|
* モードに関係なくコンソールにエラーを出力します。
|
|
@@ -98,7 +126,7 @@ class h {
|
|
|
98
126
|
console.error(t, ...e);
|
|
99
127
|
}
|
|
100
128
|
}
|
|
101
|
-
class
|
|
129
|
+
class et {
|
|
102
130
|
constructor() {
|
|
103
131
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
104
132
|
}
|
|
@@ -110,17 +138,17 @@ class z {
|
|
|
110
138
|
* @returns 処理完了Promise
|
|
111
139
|
*/
|
|
112
140
|
enqueue(t, e = !1) {
|
|
113
|
-
let r,
|
|
114
|
-
const
|
|
115
|
-
r = a,
|
|
116
|
-
}),
|
|
141
|
+
let r, i;
|
|
142
|
+
const s = new Promise((a, o) => {
|
|
143
|
+
r = a, i = o;
|
|
144
|
+
}), n = {
|
|
117
145
|
task: t,
|
|
118
146
|
timestamp: performance.now(),
|
|
119
|
-
promise:
|
|
147
|
+
promise: s,
|
|
120
148
|
resolve: r,
|
|
121
|
-
reject:
|
|
149
|
+
reject: i
|
|
122
150
|
};
|
|
123
|
-
return e ? this.queue.unshift(
|
|
151
|
+
return e ? this.queue.unshift(n) : this.queue.push(n), this.scheduleProcessing(), s;
|
|
124
152
|
}
|
|
125
153
|
/**
|
|
126
154
|
* キューを処理します。
|
|
@@ -174,7 +202,7 @@ class z {
|
|
|
174
202
|
t.length > 0 && await Promise.allSettled(t);
|
|
175
203
|
}
|
|
176
204
|
}
|
|
177
|
-
const
|
|
205
|
+
const z = class z {
|
|
178
206
|
/**
|
|
179
207
|
* タスクをキューに追加します。
|
|
180
208
|
*
|
|
@@ -192,9 +220,26 @@ const J = class J {
|
|
|
192
220
|
return this.ASYNC_QUEUE.wait();
|
|
193
221
|
}
|
|
194
222
|
};
|
|
195
|
-
|
|
196
|
-
let
|
|
197
|
-
class
|
|
223
|
+
z.ASYNC_QUEUE = new et();
|
|
224
|
+
let F = z;
|
|
225
|
+
class _ {
|
|
226
|
+
/**
|
|
227
|
+
* 実行モードを取得します。
|
|
228
|
+
*
|
|
229
|
+
* @return 実行モード。
|
|
230
|
+
*/
|
|
231
|
+
static get runtime() {
|
|
232
|
+
return l.runtime;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 実行モードを設定します。
|
|
236
|
+
*
|
|
237
|
+
* @param runtime 設定する実行モード。
|
|
238
|
+
* @return 戻り値はありません。
|
|
239
|
+
*/
|
|
240
|
+
static setRuntime(t) {
|
|
241
|
+
l.setRuntime(t);
|
|
242
|
+
}
|
|
198
243
|
/**
|
|
199
244
|
* 通知ダイアログを表示します。
|
|
200
245
|
*
|
|
@@ -202,7 +247,7 @@ class W {
|
|
|
202
247
|
* @returns 通知が閉じられると解決されるPromise
|
|
203
248
|
*/
|
|
204
249
|
static dialog(t) {
|
|
205
|
-
return
|
|
250
|
+
return F.enqueue(() => {
|
|
206
251
|
window.alert(t);
|
|
207
252
|
}, !0);
|
|
208
253
|
}
|
|
@@ -230,7 +275,7 @@ class W {
|
|
|
230
275
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
231
276
|
*/
|
|
232
277
|
static confirm(t) {
|
|
233
|
-
return
|
|
278
|
+
return F.enqueue(() => window.confirm(t), !0);
|
|
234
279
|
}
|
|
235
280
|
/**
|
|
236
281
|
* ダイアログを開きます。
|
|
@@ -238,7 +283,7 @@ class W {
|
|
|
238
283
|
* @param element 開くダイアログのHTML要素
|
|
239
284
|
*/
|
|
240
285
|
static openDialog(t) {
|
|
241
|
-
return
|
|
286
|
+
return F.enqueue(() => {
|
|
242
287
|
t instanceof HTMLDialogElement ? t.showModal() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
243
288
|
}, !0);
|
|
244
289
|
}
|
|
@@ -248,7 +293,7 @@ class W {
|
|
|
248
293
|
* @param element 閉じるダイアログのHTML要素
|
|
249
294
|
*/
|
|
250
295
|
static closeDialog(t) {
|
|
251
|
-
return
|
|
296
|
+
return F.enqueue(() => {
|
|
252
297
|
t instanceof HTMLDialogElement ? t.close() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
253
298
|
}, !0);
|
|
254
299
|
}
|
|
@@ -259,7 +304,7 @@ class W {
|
|
|
259
304
|
* @param message エラーメッセージ
|
|
260
305
|
*/
|
|
261
306
|
static addErrorMessage(t, e) {
|
|
262
|
-
return
|
|
307
|
+
return F.enqueue(() => {
|
|
263
308
|
if (t instanceof HTMLFormElement) {
|
|
264
309
|
t.setAttribute("data-message", e);
|
|
265
310
|
return;
|
|
@@ -277,21 +322,21 @@ class W {
|
|
|
277
322
|
* @param parent メッセージをクリアする親要素
|
|
278
323
|
*/
|
|
279
324
|
static clearMessages(t) {
|
|
280
|
-
return
|
|
325
|
+
return F.enqueue(() => {
|
|
281
326
|
t.removeAttribute("data-message"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
282
327
|
e.removeAttribute("data-message");
|
|
283
328
|
});
|
|
284
329
|
}, !0);
|
|
285
330
|
}
|
|
286
331
|
}
|
|
287
|
-
const
|
|
288
|
-
function
|
|
332
|
+
const rt = ["addErrorMessage", "clearMessages"];
|
|
333
|
+
function Q() {
|
|
289
334
|
const t = globalThis.window?.Haori;
|
|
290
|
-
return
|
|
335
|
+
return rt.every(
|
|
291
336
|
(r) => typeof t?.[r] == "function"
|
|
292
|
-
) ? t :
|
|
337
|
+
) ? t : _;
|
|
293
338
|
}
|
|
294
|
-
class
|
|
339
|
+
class A {
|
|
295
340
|
/**
|
|
296
341
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
297
342
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -302,7 +347,7 @@ class b {
|
|
|
302
347
|
*/
|
|
303
348
|
static getValues(t) {
|
|
304
349
|
const e = {};
|
|
305
|
-
return
|
|
350
|
+
return A.getPartValues(t, e);
|
|
306
351
|
}
|
|
307
352
|
/**
|
|
308
353
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -313,32 +358,32 @@ class b {
|
|
|
313
358
|
* @returns values と同じオブジェクト
|
|
314
359
|
*/
|
|
315
360
|
static getPartValues(t, e) {
|
|
316
|
-
const r = t.getAttribute("name"),
|
|
361
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${l.prefix}form-object`), s = t.getAttribute(`${l.prefix}form-list`);
|
|
317
362
|
if (r) {
|
|
318
|
-
|
|
363
|
+
s ? Array.isArray(e[String(r)]) ? e[String(r)].push(t.getValue()) : e[String(r)] = [t.getValue()] : e[String(r)] = t.getValue(), i && h.warn(
|
|
319
364
|
"Haori",
|
|
320
|
-
`Element cannot have both ${
|
|
365
|
+
`Element cannot have both ${l.prefix}form-object and name attributes.`
|
|
321
366
|
);
|
|
322
|
-
for (const
|
|
323
|
-
|
|
324
|
-
} else if (
|
|
325
|
-
const
|
|
367
|
+
for (const n of t.getChildElementFragments())
|
|
368
|
+
A.getPartValues(n, e);
|
|
369
|
+
} else if (i) {
|
|
370
|
+
const n = {};
|
|
326
371
|
for (const a of t.getChildElementFragments())
|
|
327
|
-
|
|
328
|
-
Object.keys(
|
|
372
|
+
A.getPartValues(a, n);
|
|
373
|
+
Object.keys(n).length > 0 && (e[String(i)] = n), s && h.warn(
|
|
329
374
|
"Haori",
|
|
330
|
-
`Element cannot have both ${
|
|
375
|
+
`Element cannot have both ${l.prefix}form-list and ${l.prefix}form-object attributes.`
|
|
331
376
|
);
|
|
332
|
-
} else if (
|
|
333
|
-
const
|
|
377
|
+
} else if (s) {
|
|
378
|
+
const n = [];
|
|
334
379
|
for (const a of t.getChildElementFragments()) {
|
|
335
380
|
const o = {};
|
|
336
|
-
|
|
381
|
+
A.getPartValues(a, o), Object.keys(o).length > 0 && n.push(o);
|
|
337
382
|
}
|
|
338
|
-
|
|
383
|
+
n.length > 0 && (e[String(s)] = n);
|
|
339
384
|
} else
|
|
340
|
-
for (const
|
|
341
|
-
|
|
385
|
+
for (const n of t.getChildElementFragments())
|
|
386
|
+
A.getPartValues(n, e);
|
|
342
387
|
return e;
|
|
343
388
|
}
|
|
344
389
|
/**
|
|
@@ -351,7 +396,7 @@ class b {
|
|
|
351
396
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
352
397
|
*/
|
|
353
398
|
static setValues(t, e, r = !1) {
|
|
354
|
-
return
|
|
399
|
+
return A.setPartValues(t, e, null, r);
|
|
355
400
|
}
|
|
356
401
|
/**
|
|
357
402
|
* フラグメント内にある各入力エレメントに値を設定します。
|
|
@@ -362,45 +407,45 @@ class b {
|
|
|
362
407
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
363
408
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
364
409
|
*/
|
|
365
|
-
static setPartValues(t, e, r = null,
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
if (!p ||
|
|
369
|
-
const
|
|
370
|
-
o && Array.isArray(
|
|
410
|
+
static setPartValues(t, e, r = null, i = !1) {
|
|
411
|
+
const s = [], n = t.getAttribute("name"), a = t.getAttribute(`${l.prefix}form-object`), o = t.getAttribute(`${l.prefix}form-list`), p = t.getAttribute(`${l.prefix}form-detach`);
|
|
412
|
+
if (n) {
|
|
413
|
+
if (!p || i) {
|
|
414
|
+
const f = e[String(n)];
|
|
415
|
+
o && Array.isArray(f) && r !== null ? s.push(t.setValue(f[r])) : typeof f == "string" || typeof f == "number" || typeof f == "boolean" || f === null ? s.push(t.setValue(f)) : s.push(t.setValue(String(f)));
|
|
371
416
|
}
|
|
372
417
|
} else if (a) {
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
375
|
-
for (const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
418
|
+
const f = e[String(a)];
|
|
419
|
+
if (f && typeof f == "object")
|
|
420
|
+
for (const T of t.getChildElementFragments())
|
|
421
|
+
s.push(
|
|
422
|
+
A.setPartValues(
|
|
423
|
+
T,
|
|
424
|
+
f,
|
|
380
425
|
null,
|
|
381
|
-
|
|
426
|
+
i
|
|
382
427
|
)
|
|
383
428
|
);
|
|
384
429
|
} else if (o) {
|
|
385
|
-
const
|
|
386
|
-
if (Array.isArray(
|
|
387
|
-
const
|
|
388
|
-
for (let
|
|
389
|
-
const d =
|
|
390
|
-
|
|
391
|
-
|
|
430
|
+
const f = e[String(o)];
|
|
431
|
+
if (Array.isArray(f)) {
|
|
432
|
+
const T = t.getChildElementFragments();
|
|
433
|
+
for (let E = 0; E < T.length; E++) {
|
|
434
|
+
const d = T[E];
|
|
435
|
+
f.length > E ? s.push(
|
|
436
|
+
A.setPartValues(
|
|
392
437
|
d,
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
438
|
+
f[E],
|
|
439
|
+
E,
|
|
440
|
+
i
|
|
396
441
|
)
|
|
397
|
-
) :
|
|
442
|
+
) : s.push(A.setPartValues(d, {}, E, i));
|
|
398
443
|
}
|
|
399
444
|
}
|
|
400
445
|
} else
|
|
401
|
-
for (const
|
|
402
|
-
|
|
403
|
-
return Promise.all(
|
|
446
|
+
for (const f of t.getChildElementFragments())
|
|
447
|
+
s.push(A.setPartValues(f, e, null, i));
|
|
448
|
+
return Promise.all(s).then(() => {
|
|
404
449
|
});
|
|
405
450
|
}
|
|
406
451
|
/**
|
|
@@ -411,21 +456,21 @@ class b {
|
|
|
411
456
|
* @returns すべての初期化処理が完了するPromise
|
|
412
457
|
*/
|
|
413
458
|
static async reset(t) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
]), await
|
|
459
|
+
A.clearValues(t), await Promise.all([
|
|
460
|
+
A.clearMessages(t),
|
|
461
|
+
A.clearEachClones(t)
|
|
462
|
+
]), await F.enqueue(() => {
|
|
418
463
|
const e = t.getTarget();
|
|
419
464
|
if (e instanceof HTMLFormElement)
|
|
420
465
|
e.reset();
|
|
421
466
|
else {
|
|
422
467
|
const r = e.parentElement;
|
|
423
468
|
if (r) {
|
|
424
|
-
const
|
|
425
|
-
|
|
469
|
+
const i = e.nextElementSibling, s = document.createElement("form");
|
|
470
|
+
s.appendChild(e), s.reset(), r.insertBefore(e, i);
|
|
426
471
|
}
|
|
427
472
|
}
|
|
428
|
-
}), await
|
|
473
|
+
}), await R.evaluateAll(t);
|
|
429
474
|
}
|
|
430
475
|
/**
|
|
431
476
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -434,20 +479,20 @@ class b {
|
|
|
434
479
|
* 対象エレメント自体は削除しません。
|
|
435
480
|
*/
|
|
436
481
|
static clearEachClones(t) {
|
|
437
|
-
const e = [], r = (
|
|
438
|
-
if (
|
|
439
|
-
for (const
|
|
440
|
-
const a =
|
|
441
|
-
!a && !o && e.push(
|
|
482
|
+
const e = [], r = (s) => {
|
|
483
|
+
if (s.hasAttribute(`${l.prefix}each`))
|
|
484
|
+
for (const n of s.getChildElementFragments()) {
|
|
485
|
+
const a = n.hasAttribute(`${l.prefix}each-before`), o = n.hasAttribute(`${l.prefix}each-after`);
|
|
486
|
+
!a && !o && e.push(n.remove());
|
|
442
487
|
}
|
|
443
|
-
},
|
|
444
|
-
r(
|
|
445
|
-
for (const
|
|
446
|
-
n
|
|
488
|
+
}, i = (s) => {
|
|
489
|
+
r(s);
|
|
490
|
+
for (const n of s.getChildElementFragments())
|
|
491
|
+
i(n);
|
|
447
492
|
};
|
|
448
493
|
r(t);
|
|
449
|
-
for (const
|
|
450
|
-
|
|
494
|
+
for (const s of t.getChildElementFragments())
|
|
495
|
+
i(s);
|
|
451
496
|
return Promise.all(e).then(() => {
|
|
452
497
|
});
|
|
453
498
|
}
|
|
@@ -459,7 +504,7 @@ class b {
|
|
|
459
504
|
static clearValues(t) {
|
|
460
505
|
t.clearValue();
|
|
461
506
|
for (const e of t.getChildElementFragments())
|
|
462
|
-
|
|
507
|
+
A.clearValues(e);
|
|
463
508
|
}
|
|
464
509
|
/**
|
|
465
510
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -468,7 +513,7 @@ class b {
|
|
|
468
513
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
469
514
|
*/
|
|
470
515
|
static clearMessages(t) {
|
|
471
|
-
return
|
|
516
|
+
return Q().clearMessages(
|
|
472
517
|
t.getTarget()
|
|
473
518
|
);
|
|
474
519
|
}
|
|
@@ -482,14 +527,14 @@ class b {
|
|
|
482
527
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
483
528
|
*/
|
|
484
529
|
static addErrorMessage(t, e, r) {
|
|
485
|
-
const
|
|
486
|
-
return
|
|
487
|
-
|
|
488
|
-
|
|
530
|
+
const i = [], s = Q(), n = A.findFragmentsByKey(t, e);
|
|
531
|
+
return n.forEach((a) => {
|
|
532
|
+
i.push(
|
|
533
|
+
s.addErrorMessage(a.getTarget(), r)
|
|
489
534
|
);
|
|
490
|
-
}),
|
|
491
|
-
|
|
492
|
-
), Promise.all(
|
|
535
|
+
}), n.length === 0 && i.push(
|
|
536
|
+
s.addErrorMessage(t.getTarget(), r)
|
|
537
|
+
), Promise.all(i).then(() => {
|
|
493
538
|
});
|
|
494
539
|
}
|
|
495
540
|
/**
|
|
@@ -500,7 +545,7 @@ class b {
|
|
|
500
545
|
* @returns 一致するフラグメントの配列
|
|
501
546
|
*/
|
|
502
547
|
static findFragmentsByKey(t, e) {
|
|
503
|
-
return
|
|
548
|
+
return A.findFragmentByKeyParts(t, e.split("."));
|
|
504
549
|
}
|
|
505
550
|
/**
|
|
506
551
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -511,32 +556,32 @@ class b {
|
|
|
511
556
|
* @returns 一致するフラグメントの配列
|
|
512
557
|
*/
|
|
513
558
|
static findFragmentByKeyParts(t, e) {
|
|
514
|
-
const r = [],
|
|
515
|
-
if (e.length == 1 && t.getAttribute("name") ===
|
|
516
|
-
e.length > 1 && t.getAttribute(`${
|
|
517
|
-
r.push(...
|
|
559
|
+
const r = [], i = e[0];
|
|
560
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${l.prefix}form-object`))
|
|
561
|
+
e.length > 1 && t.getAttribute(`${l.prefix}form-object`) === i && t.getChildElementFragments().forEach((n) => {
|
|
562
|
+
r.push(...A.findFragmentByKeyParts(n, e.slice(1)));
|
|
518
563
|
});
|
|
519
|
-
else if (t.hasAttribute(`${
|
|
564
|
+
else if (t.hasAttribute(`${l.prefix}form-list`)) {
|
|
520
565
|
if (e.length > 1) {
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
const o =
|
|
524
|
-
if (
|
|
525
|
-
const p =
|
|
526
|
-
if (isNaN(
|
|
527
|
-
h.error("Haori", `Invalid index: ${
|
|
566
|
+
const s = t.getAttribute(`${l.prefix}form-list`), n = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
567
|
+
if (n !== -1 && a !== -1 && n < a) {
|
|
568
|
+
const o = i.substring(0, n);
|
|
569
|
+
if (s === o) {
|
|
570
|
+
const p = i.substring(n + 1, a), f = Number(p);
|
|
571
|
+
if (isNaN(f))
|
|
572
|
+
h.error("Haori", `Invalid index: ${i}`);
|
|
528
573
|
else {
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
...
|
|
574
|
+
const T = t.getChildElementFragments().filter((E) => E.hasAttribute(`${l.prefix}row`));
|
|
575
|
+
f < T.length && r.push(
|
|
576
|
+
...A.findFragmentByKeyParts(T[f], e.slice(1))
|
|
532
577
|
);
|
|
533
578
|
}
|
|
534
579
|
}
|
|
535
580
|
}
|
|
536
581
|
}
|
|
537
582
|
} else
|
|
538
|
-
t.getChildElementFragments().forEach((
|
|
539
|
-
r.push(...
|
|
583
|
+
t.getChildElementFragments().forEach((s) => {
|
|
584
|
+
r.push(...A.findFragmentByKeyParts(s, e));
|
|
540
585
|
});
|
|
541
586
|
return r;
|
|
542
587
|
}
|
|
@@ -553,7 +598,7 @@ class b {
|
|
|
553
598
|
return r ? this.getFormFragment(r) : null;
|
|
554
599
|
}
|
|
555
600
|
}
|
|
556
|
-
const
|
|
601
|
+
const P = class P {
|
|
557
602
|
/**
|
|
558
603
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
559
604
|
*
|
|
@@ -609,15 +654,15 @@ const S = class S {
|
|
|
609
654
|
e,
|
|
610
655
|
"Binded values contain forbidden values"
|
|
611
656
|
), null;
|
|
612
|
-
const r = Object.keys(e).filter((
|
|
613
|
-
let
|
|
614
|
-
if (!
|
|
615
|
-
const
|
|
616
|
-
${
|
|
657
|
+
const r = Object.keys(e).filter((n) => !this.FORBIDDEN_BINDING_NAMES.has(n)).sort(), i = `${t}:${r.join(",")}`;
|
|
658
|
+
let s = this.EXPRESSION_CACHE.get(i);
|
|
659
|
+
if (!s) {
|
|
660
|
+
const n = this.buildAssignments(r), a = n ? `"use strict";
|
|
661
|
+
${n};
|
|
617
662
|
return (${t});` : `"use strict";
|
|
618
663
|
return (${t});`;
|
|
619
664
|
try {
|
|
620
|
-
|
|
665
|
+
s = new Function(...r, a), this.EXPRESSION_CACHE.set(i, s);
|
|
621
666
|
} catch (o) {
|
|
622
667
|
return h.error(
|
|
623
668
|
"[Haori]",
|
|
@@ -628,12 +673,12 @@ return (${t});`;
|
|
|
628
673
|
}
|
|
629
674
|
}
|
|
630
675
|
try {
|
|
631
|
-
const
|
|
676
|
+
const n = [], a = this.wrapBoundValues(e);
|
|
632
677
|
return r.forEach((o) => {
|
|
633
|
-
|
|
634
|
-
}), this.withBlockedPropertyAccess(() =>
|
|
635
|
-
} catch (
|
|
636
|
-
return h.error("[Haori]", "Expression evaluation error:", t,
|
|
678
|
+
n.push(a[o]);
|
|
679
|
+
}), this.withBlockedPropertyAccess(() => s(...n));
|
|
680
|
+
} catch (n) {
|
|
681
|
+
return h.error("[Haori]", "Expression evaluation error:", t, n), n instanceof ReferenceError ? void 0 : null;
|
|
637
682
|
}
|
|
638
683
|
}
|
|
639
684
|
/**
|
|
@@ -663,14 +708,14 @@ return (${t});`;
|
|
|
663
708
|
if (e === null || e.length === 0)
|
|
664
709
|
return !1;
|
|
665
710
|
const r = [];
|
|
666
|
-
let
|
|
667
|
-
for (let
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
670
|
-
this.decodeStringLiteral(
|
|
671
|
-
) ||
|
|
711
|
+
let i = null;
|
|
712
|
+
for (let s = 0; s < e.length; s++) {
|
|
713
|
+
const n = e[s], a = e[s + 1] || null, o = r[r.length - 1] || null;
|
|
714
|
+
if (n.type === "identifier" && (this.DISALLOWED_KEYWORDS.has(n.value) || this.STRICT_FORBIDDEN_NAMES.includes(n.value) || (i?.value === "." || i?.value === "?.") && this.FORBIDDEN_PROPERTY_NAMES.has(n.value)) || o === "member" && n.value !== "]" && n.type === "string" && this.FORBIDDEN_PROPERTY_NAMES.has(
|
|
715
|
+
this.decodeStringLiteral(n.value)
|
|
716
|
+
) || n.value === "." && a?.type !== "identifier" || n.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
672
717
|
return !1;
|
|
673
|
-
switch (
|
|
718
|
+
switch (n.value) {
|
|
674
719
|
case "(":
|
|
675
720
|
r.push("paren");
|
|
676
721
|
break;
|
|
@@ -680,7 +725,7 @@ return (${t});`;
|
|
|
680
725
|
break;
|
|
681
726
|
}
|
|
682
727
|
case "[": {
|
|
683
|
-
const p = this.startsMemberAccess(
|
|
728
|
+
const p = this.startsMemberAccess(i) ? "member" : "array";
|
|
684
729
|
r.push(p);
|
|
685
730
|
break;
|
|
686
731
|
}
|
|
@@ -690,7 +735,7 @@ return (${t});`;
|
|
|
690
735
|
break;
|
|
691
736
|
}
|
|
692
737
|
}
|
|
693
|
-
|
|
738
|
+
i = n;
|
|
694
739
|
}
|
|
695
740
|
return r.length === 0;
|
|
696
741
|
}
|
|
@@ -713,7 +758,7 @@ return (${t});`;
|
|
|
713
758
|
"==",
|
|
714
759
|
"!=",
|
|
715
760
|
"=>"
|
|
716
|
-
],
|
|
761
|
+
], i = /* @__PURE__ */ new Set([
|
|
717
762
|
"(",
|
|
718
763
|
")",
|
|
719
764
|
"[",
|
|
@@ -731,41 +776,41 @@ return (${t});`;
|
|
|
731
776
|
">",
|
|
732
777
|
"<"
|
|
733
778
|
]);
|
|
734
|
-
let
|
|
735
|
-
for (;
|
|
736
|
-
const
|
|
737
|
-
if (/\s/.test(
|
|
738
|
-
|
|
779
|
+
let s = 0;
|
|
780
|
+
for (; s < t.length; ) {
|
|
781
|
+
const n = t[s];
|
|
782
|
+
if (/\s/.test(n)) {
|
|
783
|
+
s += 1;
|
|
739
784
|
continue;
|
|
740
785
|
}
|
|
741
|
-
if (
|
|
786
|
+
if (n === "/" && (t[s + 1] === "/" || t[s + 1] === "*"))
|
|
742
787
|
return null;
|
|
743
|
-
if (
|
|
744
|
-
const o = this.readStringToken(t,
|
|
788
|
+
if (n === '"' || n === "'") {
|
|
789
|
+
const o = this.readStringToken(t, s);
|
|
745
790
|
if (o === null)
|
|
746
791
|
return null;
|
|
747
|
-
e.push(o.token),
|
|
792
|
+
e.push(o.token), s = o.nextIndex;
|
|
748
793
|
continue;
|
|
749
794
|
}
|
|
750
795
|
const a = r.find(
|
|
751
|
-
(o) => t.startsWith(o,
|
|
796
|
+
(o) => t.startsWith(o, s)
|
|
752
797
|
);
|
|
753
798
|
if (a) {
|
|
754
|
-
e.push({ type: "operator", value: a, position:
|
|
799
|
+
e.push({ type: "operator", value: a, position: s }), s += a.length;
|
|
755
800
|
continue;
|
|
756
801
|
}
|
|
757
|
-
if (/[0-9]/.test(
|
|
758
|
-
const o = this.readNumberToken(t,
|
|
759
|
-
e.push(o.token),
|
|
802
|
+
if (/[0-9]/.test(n)) {
|
|
803
|
+
const o = this.readNumberToken(t, s);
|
|
804
|
+
e.push(o.token), s = o.nextIndex;
|
|
760
805
|
continue;
|
|
761
806
|
}
|
|
762
|
-
if (/[A-Za-z_$]/.test(
|
|
763
|
-
const o = this.readIdentifierToken(t,
|
|
764
|
-
e.push(o.token),
|
|
807
|
+
if (/[A-Za-z_$]/.test(n)) {
|
|
808
|
+
const o = this.readIdentifierToken(t, s);
|
|
809
|
+
e.push(o.token), s = o.nextIndex;
|
|
765
810
|
continue;
|
|
766
811
|
}
|
|
767
|
-
if (
|
|
768
|
-
e.push({ type: "operator", value:
|
|
812
|
+
if (i.has(n)) {
|
|
813
|
+
e.push({ type: "operator", value: n, position: s }), s += 1;
|
|
769
814
|
continue;
|
|
770
815
|
}
|
|
771
816
|
return null;
|
|
@@ -781,23 +826,23 @@ return (${t});`;
|
|
|
781
826
|
*/
|
|
782
827
|
static readStringToken(t, e) {
|
|
783
828
|
const r = t[e];
|
|
784
|
-
let
|
|
785
|
-
for (;
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
788
|
-
|
|
829
|
+
let i = e + 1;
|
|
830
|
+
for (; i < t.length; ) {
|
|
831
|
+
const s = t[i];
|
|
832
|
+
if (s === "\\") {
|
|
833
|
+
i += 2;
|
|
789
834
|
continue;
|
|
790
835
|
}
|
|
791
|
-
if (
|
|
836
|
+
if (s === r)
|
|
792
837
|
return {
|
|
793
838
|
token: {
|
|
794
839
|
type: "string",
|
|
795
|
-
value: t.slice(e,
|
|
840
|
+
value: t.slice(e, i + 1),
|
|
796
841
|
position: e
|
|
797
842
|
},
|
|
798
|
-
nextIndex:
|
|
843
|
+
nextIndex: i + 1
|
|
799
844
|
};
|
|
800
|
-
|
|
845
|
+
i += 1;
|
|
801
846
|
}
|
|
802
847
|
return null;
|
|
803
848
|
}
|
|
@@ -896,8 +941,8 @@ return (${t});`;
|
|
|
896
941
|
*/
|
|
897
942
|
static wrapBoundValues(t) {
|
|
898
943
|
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
899
|
-
return Object.entries(t).forEach(([
|
|
900
|
-
r[
|
|
944
|
+
return Object.entries(t).forEach(([i, s]) => {
|
|
945
|
+
r[i] = this.wrapBoundValue(s, e);
|
|
901
946
|
}), r;
|
|
902
947
|
}
|
|
903
948
|
/**
|
|
@@ -910,42 +955,42 @@ return (${t});`;
|
|
|
910
955
|
static wrapBoundValue(t, e) {
|
|
911
956
|
if (!this.shouldWrapValue(t))
|
|
912
957
|
return t;
|
|
913
|
-
const r = t,
|
|
914
|
-
if (
|
|
915
|
-
return
|
|
916
|
-
const
|
|
917
|
-
get: (
|
|
958
|
+
const r = t, i = e.get(r);
|
|
959
|
+
if (i !== void 0)
|
|
960
|
+
return i;
|
|
961
|
+
const s = new Proxy(r, {
|
|
962
|
+
get: (n, a, o) => {
|
|
918
963
|
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
919
964
|
return;
|
|
920
|
-
const p = Reflect.get(
|
|
965
|
+
const p = Reflect.get(n, a, o);
|
|
921
966
|
return typeof a == "symbol" ? p : this.wrapBoundValue(
|
|
922
967
|
p,
|
|
923
968
|
e
|
|
924
969
|
);
|
|
925
970
|
},
|
|
926
|
-
has: (
|
|
927
|
-
getOwnPropertyDescriptor: (
|
|
971
|
+
has: (n, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(n, a),
|
|
972
|
+
getOwnPropertyDescriptor: (n, a) => {
|
|
928
973
|
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
929
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
974
|
+
return Reflect.getOwnPropertyDescriptor(n, a);
|
|
930
975
|
},
|
|
931
|
-
apply: (
|
|
976
|
+
apply: (n, a, o) => {
|
|
932
977
|
const p = Reflect.apply(
|
|
933
|
-
|
|
978
|
+
n,
|
|
934
979
|
a,
|
|
935
980
|
o
|
|
936
981
|
);
|
|
937
982
|
return this.isIteratorLike(p) ? p : this.wrapBoundValue(p, e);
|
|
938
983
|
},
|
|
939
|
-
construct: (
|
|
984
|
+
construct: (n, a, o) => this.wrapBoundValue(
|
|
940
985
|
Reflect.construct(
|
|
941
|
-
|
|
986
|
+
n,
|
|
942
987
|
a,
|
|
943
988
|
o
|
|
944
989
|
),
|
|
945
990
|
e
|
|
946
991
|
)
|
|
947
992
|
});
|
|
948
|
-
return e.set(r,
|
|
993
|
+
return e.set(r, s), s;
|
|
949
994
|
}
|
|
950
995
|
/**
|
|
951
996
|
* Proxy ラップ対象の値かどうかを判定します。
|
|
@@ -974,12 +1019,12 @@ return (${t});`;
|
|
|
974
1019
|
{ target: Object.prototype, property: "constructor" },
|
|
975
1020
|
{ target: Function.prototype, property: "constructor" },
|
|
976
1021
|
{ target: Object.prototype, property: "__proto__" }
|
|
977
|
-
].map((
|
|
978
|
-
...
|
|
979
|
-
descriptor: Object.getOwnPropertyDescriptor(
|
|
980
|
-
})).filter((
|
|
981
|
-
r.forEach(({ target:
|
|
982
|
-
Object.defineProperty(
|
|
1022
|
+
].map((i) => ({
|
|
1023
|
+
...i,
|
|
1024
|
+
descriptor: Object.getOwnPropertyDescriptor(i.target, i.property)
|
|
1025
|
+
})).filter((i) => i.descriptor?.configurable === !0);
|
|
1026
|
+
r.forEach(({ target: i, property: s }) => {
|
|
1027
|
+
Object.defineProperty(i, s, {
|
|
983
1028
|
configurable: !0,
|
|
984
1029
|
enumerable: !1,
|
|
985
1030
|
get: () => {
|
|
@@ -991,8 +1036,8 @@ return (${t});`;
|
|
|
991
1036
|
try {
|
|
992
1037
|
return t();
|
|
993
1038
|
} finally {
|
|
994
|
-
r.forEach(({ target:
|
|
995
|
-
|
|
1039
|
+
r.forEach(({ target: i, property: s, descriptor: n }) => {
|
|
1040
|
+
n !== void 0 && Object.defineProperty(i, s, n);
|
|
996
1041
|
});
|
|
997
1042
|
}
|
|
998
1043
|
}
|
|
@@ -1035,7 +1080,7 @@ return (${t});`;
|
|
|
1035
1080
|
for (const r of Object.values(t)) {
|
|
1036
1081
|
if (typeof r == "function") {
|
|
1037
1082
|
if (this.getForbiddenBindingValues().some(
|
|
1038
|
-
(
|
|
1083
|
+
(i) => i === r
|
|
1039
1084
|
))
|
|
1040
1085
|
return !0;
|
|
1041
1086
|
continue;
|
|
@@ -1046,7 +1091,7 @@ return (${t});`;
|
|
|
1046
1091
|
return !1;
|
|
1047
1092
|
}
|
|
1048
1093
|
};
|
|
1049
|
-
|
|
1094
|
+
P.FORBIDDEN_NAMES = [
|
|
1050
1095
|
// グローバルオブジェクト
|
|
1051
1096
|
"window",
|
|
1052
1097
|
"self",
|
|
@@ -1078,19 +1123,19 @@ S.FORBIDDEN_NAMES = [
|
|
|
1078
1123
|
"sessionStorage",
|
|
1079
1124
|
"IndexedDB",
|
|
1080
1125
|
"history"
|
|
1081
|
-
],
|
|
1082
|
-
...
|
|
1083
|
-
(t) => !
|
|
1126
|
+
], P.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], P.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), P.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
1127
|
+
...P.FORBIDDEN_NAMES.filter(
|
|
1128
|
+
(t) => !P.REBINDABLE_FORBIDDEN_NAMES.has(t)
|
|
1084
1129
|
),
|
|
1085
1130
|
"constructor",
|
|
1086
1131
|
"__proto__",
|
|
1087
1132
|
"prototype",
|
|
1088
|
-
...
|
|
1089
|
-
]),
|
|
1133
|
+
...P.STRICT_FORBIDDEN_NAMES
|
|
1134
|
+
]), P.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1090
1135
|
"constructor",
|
|
1091
1136
|
"__proto__",
|
|
1092
1137
|
"prototype"
|
|
1093
|
-
]),
|
|
1138
|
+
]), P.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1094
1139
|
"await",
|
|
1095
1140
|
"break",
|
|
1096
1141
|
"case",
|
|
@@ -1124,32 +1169,32 @@ S.FORBIDDEN_NAMES = [
|
|
|
1124
1169
|
"while",
|
|
1125
1170
|
"with",
|
|
1126
1171
|
"yield"
|
|
1127
|
-
]),
|
|
1128
|
-
let
|
|
1129
|
-
const
|
|
1172
|
+
]), P.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
1173
|
+
let j = P;
|
|
1174
|
+
const C = class C {
|
|
1130
1175
|
/**
|
|
1131
1176
|
* フラグメントのコンストラクタ。
|
|
1132
1177
|
*
|
|
1133
1178
|
* @param target 対象ノード
|
|
1134
1179
|
*/
|
|
1135
1180
|
constructor(t) {
|
|
1136
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t,
|
|
1181
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t, C.FRAGMENT_CACHE.set(t, this);
|
|
1137
1182
|
}
|
|
1138
1183
|
static get(t) {
|
|
1139
1184
|
if (t == null)
|
|
1140
1185
|
return null;
|
|
1141
|
-
if (
|
|
1142
|
-
return
|
|
1186
|
+
if (C.FRAGMENT_CACHE.has(t))
|
|
1187
|
+
return C.FRAGMENT_CACHE.get(t);
|
|
1143
1188
|
let e;
|
|
1144
1189
|
switch (t.nodeType) {
|
|
1145
1190
|
case Node.ELEMENT_NODE:
|
|
1146
|
-
e = new
|
|
1191
|
+
e = new D(t);
|
|
1147
1192
|
break;
|
|
1148
1193
|
case Node.TEXT_NODE:
|
|
1149
|
-
e = new
|
|
1194
|
+
e = new L(t);
|
|
1150
1195
|
break;
|
|
1151
1196
|
case Node.COMMENT_NODE:
|
|
1152
|
-
e = new
|
|
1197
|
+
e = new Y(t);
|
|
1153
1198
|
break;
|
|
1154
1199
|
default:
|
|
1155
1200
|
return h.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
@@ -1174,7 +1219,7 @@ const k = class k {
|
|
|
1174
1219
|
return Promise.resolve();
|
|
1175
1220
|
if (this.parent) {
|
|
1176
1221
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1177
|
-
return
|
|
1222
|
+
return F.enqueue(() => {
|
|
1178
1223
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1179
1224
|
}).finally(() => {
|
|
1180
1225
|
t.skipMutationNodes = e;
|
|
@@ -1182,7 +1227,7 @@ const k = class k {
|
|
|
1182
1227
|
} else {
|
|
1183
1228
|
const t = this.target.parentNode;
|
|
1184
1229
|
if (t)
|
|
1185
|
-
return
|
|
1230
|
+
return F.enqueue(() => {
|
|
1186
1231
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
1187
1232
|
});
|
|
1188
1233
|
this.mounted = !1;
|
|
@@ -1199,7 +1244,7 @@ const k = class k {
|
|
|
1199
1244
|
return Promise.resolve();
|
|
1200
1245
|
if (this.parent) {
|
|
1201
1246
|
const t = this.parent, e = t.skipMutationNodes;
|
|
1202
|
-
return
|
|
1247
|
+
return F.enqueue(() => {
|
|
1203
1248
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1204
1249
|
}).finally(() => {
|
|
1205
1250
|
t.skipMutationNodes = e;
|
|
@@ -1230,7 +1275,7 @@ const k = class k {
|
|
|
1230
1275
|
* @return 除去のPromise
|
|
1231
1276
|
*/
|
|
1232
1277
|
remove(t = !0) {
|
|
1233
|
-
return this.parent && this.parent.removeChild(this),
|
|
1278
|
+
return this.parent && this.parent.removeChild(this), C.FRAGMENT_CACHE.delete(this.target), t ? this.unmount() : Promise.resolve();
|
|
1234
1279
|
}
|
|
1235
1280
|
/**
|
|
1236
1281
|
* 対象ノードを取得します。
|
|
@@ -1257,9 +1302,9 @@ const k = class k {
|
|
|
1257
1302
|
this.parent = t;
|
|
1258
1303
|
}
|
|
1259
1304
|
};
|
|
1260
|
-
|
|
1261
|
-
let
|
|
1262
|
-
class
|
|
1305
|
+
C.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1306
|
+
let N = C;
|
|
1307
|
+
class D extends N {
|
|
1263
1308
|
/**
|
|
1264
1309
|
* エレメントフラグメントのコンストラクタ。
|
|
1265
1310
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -1285,11 +1330,11 @@ class P extends A {
|
|
|
1285
1330
|
], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.bindingDataCache = null, this.visible = !0, this.display = null, this.template = null, this.listKey = null, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.syncValue(), t.getAttributeNames().forEach((e) => {
|
|
1286
1331
|
const r = t.getAttribute(e);
|
|
1287
1332
|
if (r !== null && !this.attributeMap.has(e)) {
|
|
1288
|
-
const
|
|
1289
|
-
this.attributeMap.set(e,
|
|
1333
|
+
const i = new q(e, r);
|
|
1334
|
+
this.attributeMap.set(e, i);
|
|
1290
1335
|
}
|
|
1291
1336
|
}), t.childNodes.forEach((e) => {
|
|
1292
|
-
const r =
|
|
1337
|
+
const r = N.get(e);
|
|
1293
1338
|
r.setParent(this), this.children.push(r);
|
|
1294
1339
|
});
|
|
1295
1340
|
}
|
|
@@ -1308,7 +1353,7 @@ class P extends A {
|
|
|
1308
1353
|
*/
|
|
1309
1354
|
getChildElementFragments() {
|
|
1310
1355
|
return this.children.filter(
|
|
1311
|
-
(t) => t instanceof
|
|
1356
|
+
(t) => t instanceof D
|
|
1312
1357
|
);
|
|
1313
1358
|
}
|
|
1314
1359
|
/**
|
|
@@ -1340,7 +1385,7 @@ class P extends A {
|
|
|
1340
1385
|
* @returns クローンされたフラグメント
|
|
1341
1386
|
*/
|
|
1342
1387
|
clone() {
|
|
1343
|
-
const t = new
|
|
1388
|
+
const t = new D(
|
|
1344
1389
|
this.target.cloneNode(!1)
|
|
1345
1390
|
);
|
|
1346
1391
|
return this.attributeMap.forEach((e, r) => {
|
|
@@ -1408,7 +1453,7 @@ class P extends A {
|
|
|
1408
1453
|
*/
|
|
1409
1454
|
clearBindingDataCache() {
|
|
1410
1455
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
1411
|
-
t instanceof
|
|
1456
|
+
t instanceof D && t.clearBindingDataCache();
|
|
1412
1457
|
});
|
|
1413
1458
|
}
|
|
1414
1459
|
/**
|
|
@@ -1456,13 +1501,13 @@ class P extends A {
|
|
|
1456
1501
|
const e = this.getTarget();
|
|
1457
1502
|
if (e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio")) {
|
|
1458
1503
|
const r = this.getAttribute("value");
|
|
1459
|
-
let
|
|
1460
|
-
return r === "true" ?
|
|
1461
|
-
e.checked =
|
|
1504
|
+
let i;
|
|
1505
|
+
return r === "true" ? i = t === !0 : r === "false" ? i = t === !1 : i = r === String(t), this.value = i ? t : null, e.checked === i ? Promise.resolve() : (this.skipChangeValue = !0, F.enqueue(() => {
|
|
1506
|
+
e.checked = i, e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1462
1507
|
}).finally(() => {
|
|
1463
1508
|
this.skipChangeValue = !1;
|
|
1464
1509
|
}));
|
|
1465
|
-
} else return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0,
|
|
1510
|
+
} else return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, F.enqueue(() => {
|
|
1466
1511
|
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 }));
|
|
1467
1512
|
}).finally(() => {
|
|
1468
1513
|
this.skipChangeValue = !1;
|
|
@@ -1520,15 +1565,15 @@ class P extends A {
|
|
|
1520
1565
|
return Promise.resolve();
|
|
1521
1566
|
if (e === null)
|
|
1522
1567
|
return this.removeAttribute(t);
|
|
1523
|
-
const r = new
|
|
1568
|
+
const r = new q(t, e);
|
|
1524
1569
|
this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
|
|
1525
|
-
const
|
|
1526
|
-
return
|
|
1527
|
-
if (
|
|
1528
|
-
|
|
1570
|
+
const i = this.getTarget(), s = r.isForceEvaluation() ? e : this.getAttribute(t);
|
|
1571
|
+
return F.enqueue(() => {
|
|
1572
|
+
if (s === null || s === !1)
|
|
1573
|
+
i.removeAttribute(t);
|
|
1529
1574
|
else {
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1575
|
+
const n = String(s);
|
|
1576
|
+
i.getAttribute(t) !== n && i.setAttribute(t, n);
|
|
1532
1577
|
}
|
|
1533
1578
|
}).finally(() => {
|
|
1534
1579
|
this.skipMutationAttributes = !1;
|
|
@@ -1545,7 +1590,7 @@ class P extends A {
|
|
|
1545
1590
|
return Promise.resolve();
|
|
1546
1591
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1547
1592
|
const e = this.getTarget();
|
|
1548
|
-
return
|
|
1593
|
+
return F.enqueue(() => {
|
|
1549
1594
|
e.removeAttribute(t);
|
|
1550
1595
|
}).finally(() => {
|
|
1551
1596
|
this.skipMutationAttributes = !1;
|
|
@@ -1563,7 +1608,7 @@ class P extends A {
|
|
|
1563
1608
|
if (e === void 0)
|
|
1564
1609
|
return null;
|
|
1565
1610
|
const r = e.evaluate(this.getBindingData());
|
|
1566
|
-
return r.length === 1 ? r[0] :
|
|
1611
|
+
return r.length === 1 ? r[0] : $.joinEvaluateResults(r);
|
|
1567
1612
|
}
|
|
1568
1613
|
/**
|
|
1569
1614
|
* 属性の生の値を取得します。
|
|
@@ -1603,18 +1648,18 @@ class P extends A {
|
|
|
1603
1648
|
const r = t.getTarget();
|
|
1604
1649
|
if (r.parentNode !== this.target)
|
|
1605
1650
|
return null;
|
|
1606
|
-
const
|
|
1607
|
-
let
|
|
1608
|
-
for (;
|
|
1609
|
-
const
|
|
1610
|
-
if (
|
|
1611
|
-
const a = this.children.indexOf(
|
|
1651
|
+
const i = e ? r.nextSibling : r;
|
|
1652
|
+
let s = e ? r.nextSibling : r;
|
|
1653
|
+
for (; s !== null; ) {
|
|
1654
|
+
const n = N.get(s);
|
|
1655
|
+
if (n !== null) {
|
|
1656
|
+
const a = this.children.indexOf(n);
|
|
1612
1657
|
if (a !== -1)
|
|
1613
|
-
return { index: a, referenceNode:
|
|
1658
|
+
return { index: a, referenceNode: i };
|
|
1614
1659
|
}
|
|
1615
|
-
|
|
1660
|
+
s = s.nextSibling;
|
|
1616
1661
|
}
|
|
1617
|
-
return { index: this.children.length, referenceNode:
|
|
1662
|
+
return { index: this.children.length, referenceNode: i };
|
|
1618
1663
|
}
|
|
1619
1664
|
/**
|
|
1620
1665
|
* 子ノードを参照ノードの前に挿入します。
|
|
@@ -1629,23 +1674,23 @@ class P extends A {
|
|
|
1629
1674
|
return Promise.resolve();
|
|
1630
1675
|
if (t === this)
|
|
1631
1676
|
return h.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1632
|
-
const
|
|
1633
|
-
let
|
|
1634
|
-
for (;
|
|
1635
|
-
|
|
1636
|
-
if (
|
|
1677
|
+
const i = /* @__PURE__ */ new Set();
|
|
1678
|
+
let s = this.parent;
|
|
1679
|
+
for (; s; )
|
|
1680
|
+
i.add(s), s = s.getParent();
|
|
1681
|
+
if (i.has(t))
|
|
1637
1682
|
return h.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1638
|
-
const
|
|
1683
|
+
const n = t.getParent() === this;
|
|
1639
1684
|
let a = -1, o = -1;
|
|
1640
|
-
|
|
1685
|
+
n && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1641
1686
|
const p = t.getParent();
|
|
1642
1687
|
p !== null && p.removeChild(t);
|
|
1643
|
-
let
|
|
1688
|
+
let f = r === void 0 ? e?.getTarget() || null : r;
|
|
1644
1689
|
if (e === null)
|
|
1645
1690
|
this.children.push(t);
|
|
1646
1691
|
else {
|
|
1647
|
-
let
|
|
1648
|
-
if (
|
|
1692
|
+
let E;
|
|
1693
|
+
if (n ? a !== -1 && a < o ? E = o - 1 : E = o : E = this.children.indexOf(e), E === -1) {
|
|
1649
1694
|
const d = this.resolveInsertionPointFromDom(
|
|
1650
1695
|
e,
|
|
1651
1696
|
!1
|
|
@@ -1654,16 +1699,16 @@ class P extends A {
|
|
|
1654
1699
|
"[Haori]",
|
|
1655
1700
|
"Reference child not found in children.",
|
|
1656
1701
|
e
|
|
1657
|
-
), this.children.push(t)) : (this.children.splice(d.index, 0, t),
|
|
1702
|
+
), this.children.push(t)) : (this.children.splice(d.index, 0, t), f = d.referenceNode);
|
|
1658
1703
|
} else
|
|
1659
|
-
this.children.splice(
|
|
1704
|
+
this.children.splice(E, 0, t);
|
|
1660
1705
|
}
|
|
1661
1706
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1662
|
-
const
|
|
1663
|
-
return this.skipMutationNodes = !0,
|
|
1664
|
-
this.target.insertBefore(t.getTarget(),
|
|
1707
|
+
const T = this.skipMutationNodes;
|
|
1708
|
+
return this.skipMutationNodes = !0, F.enqueue(() => {
|
|
1709
|
+
this.target.insertBefore(t.getTarget(), f);
|
|
1665
1710
|
}).finally(() => {
|
|
1666
|
-
this.skipMutationNodes =
|
|
1711
|
+
this.skipMutationNodes = T;
|
|
1667
1712
|
});
|
|
1668
1713
|
}
|
|
1669
1714
|
/**
|
|
@@ -1678,18 +1723,18 @@ class P extends A {
|
|
|
1678
1723
|
return this.insertBefore(t, null);
|
|
1679
1724
|
const r = this.children.indexOf(e);
|
|
1680
1725
|
if (r === -1) {
|
|
1681
|
-
const
|
|
1726
|
+
const i = this.resolveInsertionPointFromDom(
|
|
1682
1727
|
e,
|
|
1683
1728
|
!0
|
|
1684
1729
|
);
|
|
1685
|
-
return
|
|
1730
|
+
return i === null ? (h.warn(
|
|
1686
1731
|
"[Haori]",
|
|
1687
1732
|
"Reference child not found in children.",
|
|
1688
1733
|
e
|
|
1689
1734
|
), this.insertBefore(t, null)) : this.insertBefore(
|
|
1690
1735
|
t,
|
|
1691
|
-
this.children[
|
|
1692
|
-
|
|
1736
|
+
this.children[i.index] || null,
|
|
1737
|
+
i.referenceNode
|
|
1693
1738
|
);
|
|
1694
1739
|
}
|
|
1695
1740
|
return this.insertBefore(t, this.children[r + 1] || null);
|
|
@@ -1734,7 +1779,7 @@ class P extends A {
|
|
|
1734
1779
|
* @returns エレメントの非表示のPromise
|
|
1735
1780
|
*/
|
|
1736
1781
|
hide() {
|
|
1737
|
-
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${
|
|
1782
|
+
return this.visible = !1, this.display = this.getTarget().style.display, this.getTarget().style.display = "none", this.getTarget().setAttribute(`${l.prefix}if-false`, ""), Promise.resolve();
|
|
1738
1783
|
}
|
|
1739
1784
|
/**
|
|
1740
1785
|
* エレメントを表示します。
|
|
@@ -1742,7 +1787,7 @@ class P extends A {
|
|
|
1742
1787
|
* @return エレメントの表示のPromise
|
|
1743
1788
|
*/
|
|
1744
1789
|
show() {
|
|
1745
|
-
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${
|
|
1790
|
+
return this.getTarget().style.display = this.display ?? "", this.getTarget().removeAttribute(`${l.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
1746
1791
|
}
|
|
1747
1792
|
/**
|
|
1748
1793
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -1758,7 +1803,7 @@ class P extends A {
|
|
|
1758
1803
|
return e === null ? null : e.closestByAttribute(t);
|
|
1759
1804
|
}
|
|
1760
1805
|
}
|
|
1761
|
-
class
|
|
1806
|
+
class L extends N {
|
|
1762
1807
|
/**
|
|
1763
1808
|
* テキストフラグメントのコンストラクタ。
|
|
1764
1809
|
* 対象テキストノードの内容を初期化します。
|
|
@@ -1766,7 +1811,7 @@ class I extends A {
|
|
|
1766
1811
|
* @param target 対象テキストノード
|
|
1767
1812
|
*/
|
|
1768
1813
|
constructor(t) {
|
|
1769
|
-
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new
|
|
1814
|
+
super(t), this.skipMutation = !1, this.text = t.textContent || "", this.contents = new $(this.text);
|
|
1770
1815
|
}
|
|
1771
1816
|
/**
|
|
1772
1817
|
* フラグメントをクローンします。
|
|
@@ -1774,7 +1819,7 @@ class I extends A {
|
|
|
1774
1819
|
* @returns クローンされたフラグメント
|
|
1775
1820
|
*/
|
|
1776
1821
|
clone() {
|
|
1777
|
-
const t = new
|
|
1822
|
+
const t = new L(this.target.cloneNode(!0));
|
|
1778
1823
|
return t.mounted = !1, t.text = this.text, t.contents = this.contents, t;
|
|
1779
1824
|
}
|
|
1780
1825
|
/**
|
|
@@ -1792,7 +1837,7 @@ class I extends A {
|
|
|
1792
1837
|
* @returns 更新のPromise
|
|
1793
1838
|
*/
|
|
1794
1839
|
setContent(t) {
|
|
1795
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new
|
|
1840
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, this.contents = new $(t), this.evaluate());
|
|
1796
1841
|
}
|
|
1797
1842
|
/**
|
|
1798
1843
|
* フラグメントを評価します。
|
|
@@ -1802,10 +1847,10 @@ class I extends A {
|
|
|
1802
1847
|
evaluate() {
|
|
1803
1848
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1804
1849
|
new Error("Parent fragment is required for raw evaluation")
|
|
1805
|
-
) :
|
|
1850
|
+
) : F.enqueue(() => {
|
|
1806
1851
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1807
1852
|
this.parent.getBindingData()
|
|
1808
|
-
)[0] : this.contents.isEvaluate ? this.target.textContent =
|
|
1853
|
+
)[0] : this.contents.isEvaluate ? this.target.textContent = $.joinEvaluateResults(
|
|
1809
1854
|
this.contents.evaluate(this.parent.getBindingData())
|
|
1810
1855
|
) : this.target.textContent = this.text;
|
|
1811
1856
|
}).finally(() => {
|
|
@@ -1813,7 +1858,7 @@ class I extends A {
|
|
|
1813
1858
|
});
|
|
1814
1859
|
}
|
|
1815
1860
|
}
|
|
1816
|
-
class
|
|
1861
|
+
class Y extends N {
|
|
1817
1862
|
/**
|
|
1818
1863
|
* コメントフラグメントのコンストラクタ。
|
|
1819
1864
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1829,7 +1874,7 @@ class G extends A {
|
|
|
1829
1874
|
* @returns クローンされたフラグメント
|
|
1830
1875
|
*/
|
|
1831
1876
|
clone() {
|
|
1832
|
-
const t = new
|
|
1877
|
+
const t = new Y(this.target.cloneNode(!0));
|
|
1833
1878
|
return t.mounted = !1, t.text = this.text, t;
|
|
1834
1879
|
}
|
|
1835
1880
|
/**
|
|
@@ -1847,14 +1892,14 @@ class G extends A {
|
|
|
1847
1892
|
* @return 更新のPromise
|
|
1848
1893
|
*/
|
|
1849
1894
|
setContent(t) {
|
|
1850
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
1895
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, F.enqueue(() => {
|
|
1851
1896
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
1852
1897
|
}).finally(() => {
|
|
1853
1898
|
this.skipMutation = !1;
|
|
1854
1899
|
}));
|
|
1855
1900
|
}
|
|
1856
1901
|
}
|
|
1857
|
-
const
|
|
1902
|
+
const K = class K {
|
|
1858
1903
|
/**
|
|
1859
1904
|
* コンストラクタ。
|
|
1860
1905
|
*
|
|
@@ -1862,26 +1907,26 @@ const U = class U {
|
|
|
1862
1907
|
*/
|
|
1863
1908
|
constructor(t) {
|
|
1864
1909
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
1865
|
-
const e = [...t.matchAll(
|
|
1866
|
-
let r = 0,
|
|
1867
|
-
for (const
|
|
1868
|
-
|
|
1869
|
-
text: t.slice(r,
|
|
1910
|
+
const e = [...t.matchAll(K.PLACEHOLDER_REGEX)];
|
|
1911
|
+
let r = 0, i = !1, s = !1;
|
|
1912
|
+
for (const n of e) {
|
|
1913
|
+
n.index > r && this.contents.push({
|
|
1914
|
+
text: t.slice(r, n.index),
|
|
1870
1915
|
type: 0
|
|
1871
1916
|
/* TEXT */
|
|
1872
1917
|
});
|
|
1873
1918
|
const a = {
|
|
1874
|
-
text:
|
|
1875
|
-
type:
|
|
1919
|
+
text: n[1] ?? n[2],
|
|
1920
|
+
type: n[1] ? 2 : 1
|
|
1876
1921
|
/* EXPRESSION */
|
|
1877
1922
|
};
|
|
1878
|
-
|
|
1923
|
+
i = !0, s = s || a.type === 2, this.contents.push(a), r = n.index + n[0].length;
|
|
1879
1924
|
}
|
|
1880
1925
|
r < t.length && this.contents.push({
|
|
1881
1926
|
text: t.slice(r),
|
|
1882
1927
|
type: 0
|
|
1883
1928
|
/* TEXT */
|
|
1884
|
-
}), this.isEvaluate =
|
|
1929
|
+
}), this.isEvaluate = i, this.isRawEvaluate = s, this.checkRawExpressions();
|
|
1885
1930
|
}
|
|
1886
1931
|
/**
|
|
1887
1932
|
* 評価結果を結合して文字列にします。
|
|
@@ -1923,23 +1968,23 @@ const U = class U {
|
|
|
1923
1968
|
return this.contents.forEach((r) => {
|
|
1924
1969
|
try {
|
|
1925
1970
|
if (r.type === 1 || r.type === 2) {
|
|
1926
|
-
const
|
|
1927
|
-
e.push(
|
|
1971
|
+
const i = j.evaluate(r.text, t);
|
|
1972
|
+
e.push(i);
|
|
1928
1973
|
} else
|
|
1929
1974
|
e.push(r.text);
|
|
1930
|
-
} catch (
|
|
1975
|
+
} catch (i) {
|
|
1931
1976
|
h.error(
|
|
1932
1977
|
"[Haori]",
|
|
1933
1978
|
`Error evaluating text expression: ${r.text}`,
|
|
1934
|
-
|
|
1979
|
+
i
|
|
1935
1980
|
), e.push("");
|
|
1936
1981
|
}
|
|
1937
1982
|
}), e;
|
|
1938
1983
|
}
|
|
1939
1984
|
};
|
|
1940
|
-
|
|
1941
|
-
let
|
|
1942
|
-
const
|
|
1985
|
+
K.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
1986
|
+
let $ = K;
|
|
1987
|
+
const J = class J extends $ {
|
|
1943
1988
|
/**
|
|
1944
1989
|
* コンストラクタ。
|
|
1945
1990
|
*
|
|
@@ -1947,7 +1992,7 @@ const q = class q extends H {
|
|
|
1947
1992
|
* @param text 属性値
|
|
1948
1993
|
*/
|
|
1949
1994
|
constructor(t, e) {
|
|
1950
|
-
super(e), this.forceEvaluation =
|
|
1995
|
+
super(e), this.forceEvaluation = J.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
1951
1996
|
}
|
|
1952
1997
|
/**
|
|
1953
1998
|
* 強制評価フラグを取得します。
|
|
@@ -1970,15 +2015,15 @@ const q = class q extends H {
|
|
|
1970
2015
|
return this.contents.forEach((r) => {
|
|
1971
2016
|
try {
|
|
1972
2017
|
if (this.forceEvaluation && r.type === 0 || r.type === 1 || r.type === 2) {
|
|
1973
|
-
const
|
|
1974
|
-
e.push(
|
|
2018
|
+
const i = j.evaluate(r.text, t);
|
|
2019
|
+
e.push(i);
|
|
1975
2020
|
} else
|
|
1976
2021
|
e.push(r.text);
|
|
1977
|
-
} catch (
|
|
2022
|
+
} catch (i) {
|
|
1978
2023
|
h.error(
|
|
1979
2024
|
"[Haori]",
|
|
1980
2025
|
`Error evaluating attribute expression: ${r.text}`,
|
|
1981
|
-
|
|
2026
|
+
i
|
|
1982
2027
|
), e.push("");
|
|
1983
2028
|
}
|
|
1984
2029
|
}), this.forceEvaluation && e.length > 1 ? (h.error(
|
|
@@ -1988,14 +2033,14 @@ const q = class q extends H {
|
|
|
1988
2033
|
), [e[0]]) : e;
|
|
1989
2034
|
}
|
|
1990
2035
|
};
|
|
1991
|
-
|
|
2036
|
+
J.FORCE_EVALUATION_ATTRIBUTES = [
|
|
1992
2037
|
"data-if",
|
|
1993
2038
|
"hor-if",
|
|
1994
2039
|
"data-each",
|
|
1995
2040
|
"hor-each"
|
|
1996
2041
|
];
|
|
1997
|
-
let
|
|
1998
|
-
class
|
|
2042
|
+
let q = J;
|
|
2043
|
+
class v {
|
|
1999
2044
|
/**
|
|
2000
2045
|
* カスタムイベントを発火します。
|
|
2001
2046
|
*
|
|
@@ -2004,14 +2049,14 @@ class E {
|
|
|
2004
2049
|
* @param detail イベントの詳細データ
|
|
2005
2050
|
* @param options イベントオプション
|
|
2006
2051
|
*/
|
|
2007
|
-
static dispatch(t, e, r,
|
|
2008
|
-
const
|
|
2009
|
-
bubbles:
|
|
2010
|
-
cancelable:
|
|
2011
|
-
composed:
|
|
2052
|
+
static dispatch(t, e, r, i) {
|
|
2053
|
+
const s = new CustomEvent(`haori:${e}`, {
|
|
2054
|
+
bubbles: i?.bubbles ?? !0,
|
|
2055
|
+
cancelable: i?.cancelable ?? !1,
|
|
2056
|
+
composed: i?.composed ?? !0,
|
|
2012
2057
|
detail: r
|
|
2013
2058
|
});
|
|
2014
|
-
return t.dispatchEvent(
|
|
2059
|
+
return t.dispatchEvent(s);
|
|
2015
2060
|
}
|
|
2016
2061
|
/**
|
|
2017
2062
|
* readyイベントを発火します。
|
|
@@ -2019,7 +2064,7 @@ class E {
|
|
|
2019
2064
|
* @param version ライブラリバージョン
|
|
2020
2065
|
*/
|
|
2021
2066
|
static ready(t) {
|
|
2022
|
-
|
|
2067
|
+
v.dispatch(document, "ready", { version: t });
|
|
2023
2068
|
}
|
|
2024
2069
|
/**
|
|
2025
2070
|
* renderイベントを発火します。
|
|
@@ -2027,7 +2072,7 @@ class E {
|
|
|
2027
2072
|
* @param target 評価対象要素
|
|
2028
2073
|
*/
|
|
2029
2074
|
static render(t) {
|
|
2030
|
-
|
|
2075
|
+
v.dispatch(t, "render", { target: t });
|
|
2031
2076
|
}
|
|
2032
2077
|
/**
|
|
2033
2078
|
* importstartイベントを発火します。
|
|
@@ -2036,7 +2081,7 @@ class E {
|
|
|
2036
2081
|
* @param url インポート対象URL
|
|
2037
2082
|
*/
|
|
2038
2083
|
static importStart(t, e) {
|
|
2039
|
-
|
|
2084
|
+
v.dispatch(t, "importstart", {
|
|
2040
2085
|
url: e,
|
|
2041
2086
|
startedAt: performance.now()
|
|
2042
2087
|
});
|
|
@@ -2049,11 +2094,11 @@ class E {
|
|
|
2049
2094
|
* @param bytes 取得バイト数
|
|
2050
2095
|
* @param startedAt 開始時刻
|
|
2051
2096
|
*/
|
|
2052
|
-
static importEnd(t, e, r,
|
|
2053
|
-
|
|
2097
|
+
static importEnd(t, e, r, i) {
|
|
2098
|
+
v.dispatch(t, "importend", {
|
|
2054
2099
|
url: e,
|
|
2055
2100
|
bytes: r,
|
|
2056
|
-
durationMs: performance.now() -
|
|
2101
|
+
durationMs: performance.now() - i
|
|
2057
2102
|
});
|
|
2058
2103
|
}
|
|
2059
2104
|
/**
|
|
@@ -2064,7 +2109,7 @@ class E {
|
|
|
2064
2109
|
* @param error エラー内容
|
|
2065
2110
|
*/
|
|
2066
2111
|
static importError(t, e, r) {
|
|
2067
|
-
|
|
2112
|
+
v.dispatch(t, "importerror", { url: e, error: r });
|
|
2068
2113
|
}
|
|
2069
2114
|
/**
|
|
2070
2115
|
* bindchangeイベントを発火します。
|
|
@@ -2074,17 +2119,17 @@ class E {
|
|
|
2074
2119
|
* @param next 変更後のデータ
|
|
2075
2120
|
* @param reason 変更理由
|
|
2076
2121
|
*/
|
|
2077
|
-
static bindChange(t, e, r,
|
|
2078
|
-
const
|
|
2122
|
+
static bindChange(t, e, r, i = "other") {
|
|
2123
|
+
const s = [], n = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...n, ...a]);
|
|
2079
2124
|
for (const p of o) {
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2125
|
+
const f = e?.[p], T = r[p];
|
|
2126
|
+
f !== T && s.push(p);
|
|
2082
2127
|
}
|
|
2083
|
-
|
|
2128
|
+
v.dispatch(t, "bindchange", {
|
|
2084
2129
|
previous: e || {},
|
|
2085
2130
|
next: r,
|
|
2086
|
-
changedKeys:
|
|
2087
|
-
reason:
|
|
2131
|
+
changedKeys: s,
|
|
2132
|
+
reason: i
|
|
2088
2133
|
});
|
|
2089
2134
|
}
|
|
2090
2135
|
/**
|
|
@@ -2095,12 +2140,12 @@ class E {
|
|
|
2095
2140
|
* @param removed 削除された行のキー
|
|
2096
2141
|
* @param order 現在の順序
|
|
2097
2142
|
*/
|
|
2098
|
-
static eachUpdate(t, e, r,
|
|
2099
|
-
|
|
2143
|
+
static eachUpdate(t, e, r, i) {
|
|
2144
|
+
v.dispatch(t, "eachupdate", {
|
|
2100
2145
|
added: e,
|
|
2101
2146
|
removed: r,
|
|
2102
|
-
order:
|
|
2103
|
-
total:
|
|
2147
|
+
order: i,
|
|
2148
|
+
total: i.length
|
|
2104
2149
|
});
|
|
2105
2150
|
}
|
|
2106
2151
|
/**
|
|
@@ -2111,8 +2156,8 @@ class E {
|
|
|
2111
2156
|
* @param index インデックス
|
|
2112
2157
|
* @param item 行データ
|
|
2113
2158
|
*/
|
|
2114
|
-
static rowAdd(t, e, r,
|
|
2115
|
-
|
|
2159
|
+
static rowAdd(t, e, r, i) {
|
|
2160
|
+
v.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
2116
2161
|
}
|
|
2117
2162
|
/**
|
|
2118
2163
|
* rowremoveイベントを発火します。
|
|
@@ -2122,7 +2167,7 @@ class E {
|
|
|
2122
2167
|
* @param index インデックス
|
|
2123
2168
|
*/
|
|
2124
2169
|
static rowRemove(t, e, r) {
|
|
2125
|
-
|
|
2170
|
+
v.dispatch(t, "rowremove", { key: e, index: r });
|
|
2126
2171
|
}
|
|
2127
2172
|
/**
|
|
2128
2173
|
* rowmoveイベントを発火します。
|
|
@@ -2132,8 +2177,8 @@ class E {
|
|
|
2132
2177
|
* @param from 移動前インデックス
|
|
2133
2178
|
* @param to 移動後インデックス
|
|
2134
2179
|
*/
|
|
2135
|
-
static rowMove(t, e, r,
|
|
2136
|
-
|
|
2180
|
+
static rowMove(t, e, r, i) {
|
|
2181
|
+
v.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
2137
2182
|
}
|
|
2138
2183
|
/**
|
|
2139
2184
|
* showイベントを発火します。
|
|
@@ -2141,7 +2186,7 @@ class E {
|
|
|
2141
2186
|
* @param target data-if要素
|
|
2142
2187
|
*/
|
|
2143
2188
|
static show(t) {
|
|
2144
|
-
|
|
2189
|
+
v.dispatch(t, "show", { visible: !0 });
|
|
2145
2190
|
}
|
|
2146
2191
|
/**
|
|
2147
2192
|
* hideイベントを発火します。
|
|
@@ -2149,7 +2194,7 @@ class E {
|
|
|
2149
2194
|
* @param target data-if要素
|
|
2150
2195
|
*/
|
|
2151
2196
|
static hide(t) {
|
|
2152
|
-
|
|
2197
|
+
v.dispatch(t, "hide", { visible: !1 });
|
|
2153
2198
|
}
|
|
2154
2199
|
/**
|
|
2155
2200
|
* fetchstartイベントを発火します。
|
|
@@ -2158,13 +2203,16 @@ class E {
|
|
|
2158
2203
|
* @param url フェッチURL
|
|
2159
2204
|
* @param options フェッチオプション
|
|
2160
2205
|
* @param payload 送信データ
|
|
2206
|
+
* @param metadata runtime とメソッド変換情報。
|
|
2207
|
+
* @return 戻り値はありません。
|
|
2161
2208
|
*/
|
|
2162
|
-
static fetchStart(t, e, r,
|
|
2163
|
-
|
|
2209
|
+
static fetchStart(t, e, r, i, s) {
|
|
2210
|
+
v.dispatch(t, "fetchstart", {
|
|
2164
2211
|
url: e,
|
|
2165
2212
|
options: r || {},
|
|
2166
|
-
payload:
|
|
2167
|
-
startedAt: performance.now()
|
|
2213
|
+
payload: i,
|
|
2214
|
+
startedAt: performance.now(),
|
|
2215
|
+
...s
|
|
2168
2216
|
});
|
|
2169
2217
|
}
|
|
2170
2218
|
/**
|
|
@@ -2175,11 +2223,11 @@ class E {
|
|
|
2175
2223
|
* @param status HTTPステータス
|
|
2176
2224
|
* @param startedAt 開始時刻
|
|
2177
2225
|
*/
|
|
2178
|
-
static fetchEnd(t, e, r,
|
|
2179
|
-
|
|
2226
|
+
static fetchEnd(t, e, r, i) {
|
|
2227
|
+
v.dispatch(t, "fetchend", {
|
|
2180
2228
|
url: e,
|
|
2181
2229
|
status: r,
|
|
2182
|
-
durationMs: performance.now() -
|
|
2230
|
+
durationMs: performance.now() - i
|
|
2183
2231
|
});
|
|
2184
2232
|
}
|
|
2185
2233
|
/**
|
|
@@ -2191,16 +2239,16 @@ class E {
|
|
|
2191
2239
|
* @param status HTTPステータス(存在する場合)
|
|
2192
2240
|
* @param startedAt 開始時刻(存在する場合)
|
|
2193
2241
|
*/
|
|
2194
|
-
static fetchError(t, e, r,
|
|
2195
|
-
|
|
2242
|
+
static fetchError(t, e, r, i, s) {
|
|
2243
|
+
v.dispatch(t, "fetcherror", {
|
|
2196
2244
|
url: e,
|
|
2197
|
-
status:
|
|
2245
|
+
status: i,
|
|
2198
2246
|
error: r,
|
|
2199
|
-
durationMs:
|
|
2247
|
+
durationMs: s ? performance.now() - s : void 0
|
|
2200
2248
|
});
|
|
2201
2249
|
}
|
|
2202
2250
|
}
|
|
2203
|
-
const
|
|
2251
|
+
const it = [
|
|
2204
2252
|
"addErrorMessage",
|
|
2205
2253
|
"closeDialog",
|
|
2206
2254
|
"confirm",
|
|
@@ -2208,13 +2256,27 @@ const Z = [
|
|
|
2208
2256
|
"openDialog",
|
|
2209
2257
|
"toast"
|
|
2210
2258
|
];
|
|
2211
|
-
function
|
|
2259
|
+
function X() {
|
|
2212
2260
|
const t = globalThis.window?.Haori;
|
|
2213
|
-
return
|
|
2261
|
+
return it.every(
|
|
2214
2262
|
(r) => typeof t?.[r] == "function"
|
|
2215
|
-
) ? t :
|
|
2263
|
+
) ? t : _;
|
|
2264
|
+
}
|
|
2265
|
+
const st = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2266
|
+
function nt(S) {
|
|
2267
|
+
return st.has(S.toUpperCase());
|
|
2268
|
+
}
|
|
2269
|
+
function at(S, t) {
|
|
2270
|
+
for (const [e, r] of Object.entries(t))
|
|
2271
|
+
r !== void 0 && (r === null ? S.append(e, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
2272
|
+
S.append(e, String(i));
|
|
2273
|
+
}) : typeof r == "object" || typeof r == "function" ? S.append(e, JSON.stringify(r)) : S.append(e, String(r)));
|
|
2216
2274
|
}
|
|
2217
|
-
|
|
2275
|
+
function ot(S, t) {
|
|
2276
|
+
const e = new URL(S, window.location.href), r = new URLSearchParams(e.search);
|
|
2277
|
+
return at(r, t), e.search = r.toString(), e.toString();
|
|
2278
|
+
}
|
|
2279
|
+
const c = class c {
|
|
2218
2280
|
/**
|
|
2219
2281
|
* イベント属性名を正しく生成します。
|
|
2220
2282
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -2223,7 +2285,7 @@ const u = class u {
|
|
|
2223
2285
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
2224
2286
|
*/
|
|
2225
2287
|
static attrName(t, e, r = !1) {
|
|
2226
|
-
return t ? `${
|
|
2288
|
+
return t ? `${l.prefix}${t}-${e}` : r ? `${l.prefix}fetch-${e}` : `${l.prefix}${e}`;
|
|
2227
2289
|
}
|
|
2228
2290
|
/**
|
|
2229
2291
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -2234,13 +2296,13 @@ const u = class u {
|
|
|
2234
2296
|
*/
|
|
2235
2297
|
static resolveDataParamString(t, e) {
|
|
2236
2298
|
return t.replace(
|
|
2237
|
-
|
|
2238
|
-
(r,
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2299
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2300
|
+
(r, i, s) => {
|
|
2301
|
+
const n = j.evaluate(
|
|
2302
|
+
i ?? s ?? "",
|
|
2241
2303
|
e
|
|
2242
2304
|
);
|
|
2243
|
-
return
|
|
2305
|
+
return n == null || Number.isNaN(n) ? "" : encodeURIComponent(typeof n == "object" ? JSON.stringify(n) : String(n));
|
|
2244
2306
|
}
|
|
2245
2307
|
);
|
|
2246
2308
|
}
|
|
@@ -2252,18 +2314,18 @@ const u = class u {
|
|
|
2252
2314
|
* @returns JSON 文字列中なら true
|
|
2253
2315
|
*/
|
|
2254
2316
|
static isJsonStringContext(t, e) {
|
|
2255
|
-
let r = !1,
|
|
2256
|
-
for (let
|
|
2257
|
-
const
|
|
2258
|
-
if (
|
|
2259
|
-
|
|
2317
|
+
let r = !1, i = !1;
|
|
2318
|
+
for (let s = 0; s < e; s += 1) {
|
|
2319
|
+
const n = t[s];
|
|
2320
|
+
if (i) {
|
|
2321
|
+
i = !1;
|
|
2260
2322
|
continue;
|
|
2261
2323
|
}
|
|
2262
|
-
if (
|
|
2263
|
-
|
|
2324
|
+
if (n === "\\") {
|
|
2325
|
+
i = !0;
|
|
2264
2326
|
continue;
|
|
2265
2327
|
}
|
|
2266
|
-
|
|
2328
|
+
n === '"' && (r = !r);
|
|
2267
2329
|
}
|
|
2268
2330
|
return r;
|
|
2269
2331
|
}
|
|
@@ -2291,7 +2353,7 @@ const u = class u {
|
|
|
2291
2353
|
static stringifyJsonTemplateStringContent(t) {
|
|
2292
2354
|
if (t == null || Number.isNaN(t))
|
|
2293
2355
|
return "";
|
|
2294
|
-
const e = typeof t == "object" ?
|
|
2356
|
+
const e = typeof t == "object" ? c.stringifyJsonTemplateValue(t) : String(t);
|
|
2295
2357
|
return JSON.stringify(e).slice(1, -1);
|
|
2296
2358
|
}
|
|
2297
2359
|
/**
|
|
@@ -2303,13 +2365,13 @@ const u = class u {
|
|
|
2303
2365
|
*/
|
|
2304
2366
|
static resolveDataJsonString(t, e) {
|
|
2305
2367
|
return t.replace(
|
|
2306
|
-
|
|
2307
|
-
(r,
|
|
2308
|
-
const a =
|
|
2309
|
-
|
|
2368
|
+
c.DATA_PLACEHOLDER_REGEX,
|
|
2369
|
+
(r, i, s, n) => {
|
|
2370
|
+
const a = j.evaluate(
|
|
2371
|
+
i ?? s ?? "",
|
|
2310
2372
|
e
|
|
2311
2373
|
);
|
|
2312
|
-
return
|
|
2374
|
+
return c.isJsonStringContext(t, n) ? c.stringifyJsonTemplateStringContent(a) : c.stringifyJsonTemplateValue(a);
|
|
2313
2375
|
}
|
|
2314
2376
|
);
|
|
2315
2377
|
}
|
|
@@ -2321,19 +2383,19 @@ const u = class u {
|
|
|
2321
2383
|
* @returns 送信データ
|
|
2322
2384
|
*/
|
|
2323
2385
|
static resolveDataAttribute(t, e) {
|
|
2324
|
-
const r = t.getRawAttribute(e),
|
|
2325
|
-
if (
|
|
2326
|
-
return
|
|
2327
|
-
if (typeof
|
|
2386
|
+
const r = t.getRawAttribute(e), i = t.getAttribute(e);
|
|
2387
|
+
if (i && typeof i == "object" && !Array.isArray(i))
|
|
2388
|
+
return i;
|
|
2389
|
+
if (typeof i != "string" || r === null)
|
|
2328
2390
|
return null;
|
|
2329
|
-
const
|
|
2330
|
-
return
|
|
2331
|
-
|
|
2391
|
+
const s = r.trim();
|
|
2392
|
+
return c.SINGLE_PLACEHOLDER_REGEX.test(s) ? R.parseDataBind(i) : s.startsWith("{") || s.startsWith("[") ? R.parseDataBind(
|
|
2393
|
+
c.resolveDataJsonString(
|
|
2332
2394
|
r,
|
|
2333
2395
|
t.getBindingData()
|
|
2334
2396
|
)
|
|
2335
|
-
) :
|
|
2336
|
-
|
|
2397
|
+
) : R.parseDataBind(
|
|
2398
|
+
c.resolveDataParamString(r, t.getBindingData())
|
|
2337
2399
|
);
|
|
2338
2400
|
}
|
|
2339
2401
|
/**
|
|
@@ -2348,29 +2410,29 @@ const u = class u {
|
|
|
2348
2410
|
targetFragment: t
|
|
2349
2411
|
};
|
|
2350
2412
|
if (e) {
|
|
2351
|
-
if (t.hasAttribute(
|
|
2352
|
-
|
|
2353
|
-
)), t.hasAttribute(
|
|
2413
|
+
if (t.hasAttribute(c.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(c.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2414
|
+
c.attrName(e, "confirm")
|
|
2415
|
+
)), t.hasAttribute(c.attrName(e, "data")) && (r.data = c.resolveDataAttribute(
|
|
2354
2416
|
t,
|
|
2355
|
-
|
|
2356
|
-
)), t.hasAttribute(
|
|
2357
|
-
const
|
|
2358
|
-
|
|
2417
|
+
c.attrName(e, "data")
|
|
2418
|
+
)), t.hasAttribute(c.attrName(e, "form"))) {
|
|
2419
|
+
const d = t.getRawAttribute(
|
|
2420
|
+
c.attrName(e, "form")
|
|
2359
2421
|
);
|
|
2360
|
-
if (
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2363
|
-
|
|
2422
|
+
if (d) {
|
|
2423
|
+
const u = document.body.querySelector(d);
|
|
2424
|
+
u !== null ? r.formFragment = A.getFormFragment(
|
|
2425
|
+
N.get(u)
|
|
2364
2426
|
) : h.error(
|
|
2365
2427
|
"Haori",
|
|
2366
|
-
`Form element not found: ${
|
|
2428
|
+
`Form element not found: ${d} (${c.attrName(e, "form")})`
|
|
2367
2429
|
);
|
|
2368
2430
|
} else
|
|
2369
|
-
r.formFragment =
|
|
2370
|
-
} else e === "change" && (r.formFragment =
|
|
2371
|
-
if (t.hasAttribute(`${
|
|
2372
|
-
const
|
|
2373
|
-
`${
|
|
2431
|
+
r.formFragment = A.getFormFragment(t);
|
|
2432
|
+
} else e === "change" && (r.formFragment = A.getFormFragment(t));
|
|
2433
|
+
if (t.hasAttribute(`${l.prefix}${e}-before-run`)) {
|
|
2434
|
+
const d = t.getRawAttribute(
|
|
2435
|
+
`${l.prefix}${e}-before-run`
|
|
2374
2436
|
);
|
|
2375
2437
|
try {
|
|
2376
2438
|
r.beforeCallback = new Function(
|
|
@@ -2378,194 +2440,199 @@ const u = class u {
|
|
|
2378
2440
|
"fetchOptions",
|
|
2379
2441
|
`
|
|
2380
2442
|
"use strict";
|
|
2381
|
-
${
|
|
2443
|
+
${d}
|
|
2382
2444
|
`
|
|
2383
2445
|
);
|
|
2384
|
-
} catch (
|
|
2385
|
-
h.error("Haori", `Invalid before script: ${
|
|
2446
|
+
} catch (u) {
|
|
2447
|
+
h.error("Haori", `Invalid before script: ${u}`);
|
|
2386
2448
|
}
|
|
2387
2449
|
}
|
|
2388
2450
|
}
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2391
|
-
const
|
|
2451
|
+
const i = c.attrName(e, "fetch"), s = t.hasAttribute(i);
|
|
2452
|
+
s && (r.fetchUrl = t.getAttribute(i));
|
|
2453
|
+
const n = {};
|
|
2392
2454
|
if (e) {
|
|
2393
|
-
const
|
|
2394
|
-
t.hasAttribute(
|
|
2395
|
-
|
|
2455
|
+
const d = c.attrName(e, "fetch-method");
|
|
2456
|
+
t.hasAttribute(d) && (n.method = t.getAttribute(
|
|
2457
|
+
d
|
|
2396
2458
|
));
|
|
2397
2459
|
} else {
|
|
2398
|
-
const
|
|
2399
|
-
t.hasAttribute(
|
|
2400
|
-
|
|
2460
|
+
const d = c.attrName(null, "method", !0);
|
|
2461
|
+
t.hasAttribute(d) && (n.method = t.getAttribute(
|
|
2462
|
+
d
|
|
2401
2463
|
));
|
|
2402
2464
|
}
|
|
2403
2465
|
if (e) {
|
|
2404
|
-
const
|
|
2405
|
-
if (t.hasAttribute(
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2466
|
+
const d = c.attrName(e, "fetch-headers");
|
|
2467
|
+
if (t.hasAttribute(d)) {
|
|
2468
|
+
const u = t.getRawAttribute(
|
|
2469
|
+
d
|
|
2408
2470
|
);
|
|
2409
2471
|
try {
|
|
2410
|
-
|
|
2472
|
+
n.headers = R.parseDataBind(u);
|
|
2411
2473
|
} catch (g) {
|
|
2412
2474
|
h.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2413
2475
|
}
|
|
2414
2476
|
}
|
|
2415
2477
|
} else {
|
|
2416
|
-
const
|
|
2478
|
+
const d = c.attrName(
|
|
2417
2479
|
null,
|
|
2418
2480
|
"headers",
|
|
2419
2481
|
!0
|
|
2420
2482
|
);
|
|
2421
|
-
if (t.hasAttribute(
|
|
2422
|
-
const
|
|
2423
|
-
|
|
2483
|
+
if (t.hasAttribute(d)) {
|
|
2484
|
+
const u = t.getRawAttribute(
|
|
2485
|
+
d
|
|
2424
2486
|
);
|
|
2425
2487
|
try {
|
|
2426
|
-
|
|
2488
|
+
n.headers = R.parseDataBind(u);
|
|
2427
2489
|
} catch (g) {
|
|
2428
2490
|
h.error("Haori", `Invalid fetch headers: ${g}`);
|
|
2429
2491
|
}
|
|
2430
2492
|
}
|
|
2431
2493
|
}
|
|
2432
2494
|
if (e) {
|
|
2433
|
-
const
|
|
2495
|
+
const d = c.attrName(
|
|
2434
2496
|
e,
|
|
2435
2497
|
"fetch-content-type"
|
|
2436
2498
|
);
|
|
2437
|
-
if (t.hasAttribute(
|
|
2438
|
-
|
|
2439
|
-
...
|
|
2440
|
-
"Content-Type": t.getAttribute(
|
|
2499
|
+
if (t.hasAttribute(d))
|
|
2500
|
+
n.headers = {
|
|
2501
|
+
...n.headers,
|
|
2502
|
+
"Content-Type": t.getAttribute(d)
|
|
2441
2503
|
};
|
|
2442
|
-
else if (
|
|
2443
|
-
let
|
|
2444
|
-
|
|
2445
|
-
...
|
|
2504
|
+
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2505
|
+
let u = !1;
|
|
2506
|
+
n.headers && typeof n.headers == "object" && (u = "Content-Type" in n.headers), u || (n.headers = {
|
|
2507
|
+
...n.headers,
|
|
2446
2508
|
"Content-Type": "application/json"
|
|
2447
2509
|
});
|
|
2448
|
-
} else
|
|
2449
|
-
...
|
|
2510
|
+
} else n.method && (n.method === "GET" || n.method === "HEAD" || n.method === "OPTIONS") && (n.headers = {
|
|
2511
|
+
...n.headers,
|
|
2450
2512
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2451
2513
|
});
|
|
2452
2514
|
} else {
|
|
2453
|
-
const
|
|
2515
|
+
const d = c.attrName(
|
|
2454
2516
|
null,
|
|
2455
2517
|
"content-type",
|
|
2456
2518
|
!0
|
|
2457
2519
|
);
|
|
2458
|
-
if (t.hasAttribute(
|
|
2459
|
-
|
|
2460
|
-
...
|
|
2461
|
-
"Content-Type": t.getAttribute(
|
|
2520
|
+
if (t.hasAttribute(d))
|
|
2521
|
+
n.headers = {
|
|
2522
|
+
...n.headers,
|
|
2523
|
+
"Content-Type": t.getAttribute(d)
|
|
2462
2524
|
};
|
|
2463
|
-
else if (
|
|
2464
|
-
let
|
|
2465
|
-
|
|
2466
|
-
...
|
|
2525
|
+
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
2526
|
+
let u = !1;
|
|
2527
|
+
n.headers && typeof n.headers == "object" && (u = "Content-Type" in n.headers), u || (n.headers = {
|
|
2528
|
+
...n.headers,
|
|
2467
2529
|
"Content-Type": "application/json"
|
|
2468
2530
|
});
|
|
2469
|
-
} else
|
|
2470
|
-
...
|
|
2531
|
+
} else n.method && (n.method === "GET" || n.method === "HEAD" || n.method === "OPTIONS") && (n.headers = {
|
|
2532
|
+
...n.headers,
|
|
2471
2533
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2472
2534
|
});
|
|
2473
2535
|
}
|
|
2474
|
-
Object.keys(
|
|
2475
|
-
const a = e ?
|
|
2536
|
+
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
2537
|
+
const a = e ? c.attrName(e, "bind") : c.attrName(null, "bind", !0);
|
|
2476
2538
|
if (t.hasAttribute(a)) {
|
|
2477
|
-
const
|
|
2478
|
-
if (
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2481
|
-
const
|
|
2482
|
-
|
|
2539
|
+
const d = t.getRawAttribute(a);
|
|
2540
|
+
if (d) {
|
|
2541
|
+
const u = document.body.querySelectorAll(d);
|
|
2542
|
+
u.length > 0 ? (r.bindFragments = [], u.forEach((g) => {
|
|
2543
|
+
const b = N.get(g);
|
|
2544
|
+
b && r.bindFragments.push(b);
|
|
2483
2545
|
})) : h.error(
|
|
2484
2546
|
"Haori",
|
|
2485
|
-
`Bind element not found: ${
|
|
2547
|
+
`Bind element not found: ${d} (${a})`
|
|
2486
2548
|
);
|
|
2487
2549
|
}
|
|
2488
2550
|
}
|
|
2489
|
-
const o =
|
|
2551
|
+
const o = c.attrName(e, "bind-arg"), p = c.attrName(
|
|
2490
2552
|
null,
|
|
2491
2553
|
"arg",
|
|
2492
2554
|
!0
|
|
2493
|
-
),
|
|
2555
|
+
), f = c.attrName(
|
|
2494
2556
|
null,
|
|
2495
2557
|
"bind-arg",
|
|
2496
2558
|
!0
|
|
2497
2559
|
);
|
|
2498
2560
|
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(p) ? r.bindArg = t.getRawAttribute(
|
|
2499
2561
|
p
|
|
2500
|
-
) : t.hasAttribute(
|
|
2501
|
-
const
|
|
2502
|
-
if (t.hasAttribute(
|
|
2503
|
-
const
|
|
2504
|
-
r.bindParams =
|
|
2562
|
+
) : t.hasAttribute(f) && (r.bindArg = t.getRawAttribute(f));
|
|
2563
|
+
const T = e ? c.attrName(e, "bind-params") : c.attrName(null, "bind-params", !0);
|
|
2564
|
+
if (t.hasAttribute(T)) {
|
|
2565
|
+
const d = t.getRawAttribute(T);
|
|
2566
|
+
r.bindParams = d.split("&").map((u) => u.trim());
|
|
2567
|
+
}
|
|
2568
|
+
const E = e ? c.attrName(e, "bind-append") : c.attrName(null, "bind-append", !0);
|
|
2569
|
+
if (t.hasAttribute(E)) {
|
|
2570
|
+
const d = t.getRawAttribute(E);
|
|
2571
|
+
r.bindAppendParams = d.split("&").map((u) => u.trim()).filter(Boolean);
|
|
2505
2572
|
}
|
|
2506
2573
|
if (e) {
|
|
2507
|
-
if (t.hasAttribute(
|
|
2508
|
-
const
|
|
2509
|
-
|
|
2574
|
+
if (t.hasAttribute(c.attrName(e, "adjust"))) {
|
|
2575
|
+
const u = t.getRawAttribute(
|
|
2576
|
+
c.attrName(e, "adjust")
|
|
2510
2577
|
);
|
|
2511
|
-
if (
|
|
2512
|
-
const g = document.body.querySelectorAll(
|
|
2513
|
-
g.length > 0 ? (r.adjustFragments = [], g.forEach((
|
|
2514
|
-
const
|
|
2515
|
-
|
|
2578
|
+
if (u) {
|
|
2579
|
+
const g = document.body.querySelectorAll(u);
|
|
2580
|
+
g.length > 0 ? (r.adjustFragments = [], g.forEach((b) => {
|
|
2581
|
+
const y = N.get(b);
|
|
2582
|
+
y && r.adjustFragments.push(y);
|
|
2516
2583
|
})) : h.error(
|
|
2517
2584
|
"Haori",
|
|
2518
|
-
`Adjust element not found: ${
|
|
2585
|
+
`Adjust element not found: ${u} (${c.attrName(e, "adjust")})`
|
|
2519
2586
|
);
|
|
2520
2587
|
}
|
|
2521
|
-
if (t.hasAttribute(
|
|
2588
|
+
if (t.hasAttribute(c.attrName(e, "adjust-value"))) {
|
|
2522
2589
|
const g = t.getRawAttribute(
|
|
2523
|
-
|
|
2524
|
-
),
|
|
2525
|
-
isNaN(
|
|
2590
|
+
c.attrName(e, "adjust-value")
|
|
2591
|
+
), b = Number(g);
|
|
2592
|
+
isNaN(b) || (r.adjustValue = b);
|
|
2526
2593
|
}
|
|
2527
2594
|
}
|
|
2528
|
-
if (t.hasAttribute(
|
|
2529
|
-
const
|
|
2530
|
-
`${
|
|
2595
|
+
if (t.hasAttribute(c.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(c.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(c.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(c.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${l.prefix}${e}-after-run`)) {
|
|
2596
|
+
const u = t.getRawAttribute(
|
|
2597
|
+
`${l.prefix}${e}-after-run`
|
|
2531
2598
|
);
|
|
2532
2599
|
try {
|
|
2533
2600
|
r.afterCallback = new Function(
|
|
2534
2601
|
"response",
|
|
2535
2602
|
`
|
|
2536
2603
|
"use strict";
|
|
2537
|
-
${
|
|
2604
|
+
${u}
|
|
2538
2605
|
`
|
|
2539
2606
|
);
|
|
2540
2607
|
} catch (g) {
|
|
2541
2608
|
h.error("Haori", `Invalid after script: ${g}`);
|
|
2542
2609
|
}
|
|
2543
2610
|
}
|
|
2544
|
-
if (t.hasAttribute(
|
|
2545
|
-
|
|
2546
|
-
)), t.hasAttribute(
|
|
2547
|
-
|
|
2548
|
-
)), t.hasAttribute(
|
|
2549
|
-
|
|
2550
|
-
)), t.hasAttribute(
|
|
2551
|
-
|
|
2552
|
-
)), t.hasAttribute(
|
|
2611
|
+
if (t.hasAttribute(c.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2612
|
+
c.attrName(e, "dialog")
|
|
2613
|
+
)), t.hasAttribute(c.attrName(e, "toast")) && (r.toastMessage = t.getAttribute(
|
|
2614
|
+
c.attrName(e, "toast")
|
|
2615
|
+
)), t.hasAttribute(c.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2616
|
+
c.attrName(e, "redirect")
|
|
2617
|
+
)), t.hasAttribute(c.attrName(e, "history")) && (r.historyUrl = t.getAttribute(
|
|
2618
|
+
c.attrName(e, "history")
|
|
2619
|
+
)), t.hasAttribute(c.attrName(e, "history-data")) && (r.historyData = c.resolveDataAttribute(
|
|
2553
2620
|
t,
|
|
2554
|
-
|
|
2555
|
-
)), t.hasAttribute(
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2621
|
+
c.attrName(e, "history-data")
|
|
2622
|
+
)), t.hasAttribute(c.attrName(e, "history-form"))) {
|
|
2623
|
+
const u = t.getRawAttribute(
|
|
2624
|
+
c.attrName(e, "history-form")
|
|
2558
2625
|
);
|
|
2559
|
-
if (
|
|
2560
|
-
const g = document.body.querySelector(
|
|
2561
|
-
g !== null ? r.historyFormFragment =
|
|
2562
|
-
|
|
2626
|
+
if (u) {
|
|
2627
|
+
const g = document.body.querySelector(u);
|
|
2628
|
+
g !== null ? r.historyFormFragment = A.getFormFragment(
|
|
2629
|
+
N.get(g)
|
|
2563
2630
|
) : h.error(
|
|
2564
2631
|
"Haori",
|
|
2565
|
-
`Form element not found: ${
|
|
2632
|
+
`Form element not found: ${u} (${c.attrName(e, "history-form")})`
|
|
2566
2633
|
);
|
|
2567
2634
|
} else
|
|
2568
|
-
r.historyFormFragment =
|
|
2635
|
+
r.historyFormFragment = A.getFormFragment(t);
|
|
2569
2636
|
}
|
|
2570
2637
|
[
|
|
2571
2638
|
"reset",
|
|
@@ -2573,53 +2640,53 @@ ${d}
|
|
|
2573
2640
|
"click",
|
|
2574
2641
|
"open",
|
|
2575
2642
|
"close"
|
|
2576
|
-
].forEach((
|
|
2577
|
-
const g =
|
|
2643
|
+
].forEach((u) => {
|
|
2644
|
+
const g = c.attrName(e, u);
|
|
2578
2645
|
if (!t.hasAttribute(g))
|
|
2579
2646
|
return;
|
|
2580
|
-
const
|
|
2581
|
-
if (
|
|
2582
|
-
const
|
|
2583
|
-
|
|
2584
|
-
}),
|
|
2585
|
-
switch (
|
|
2647
|
+
const b = t.getRawAttribute(g), y = [];
|
|
2648
|
+
if (b ? (document.body.querySelectorAll(b).forEach((k) => {
|
|
2649
|
+
const U = N.get(k);
|
|
2650
|
+
U && y.push(U);
|
|
2651
|
+
}), y.length === 0 && h.error("Haori", `Element not found: ${b} (${g})`)) : y.push(t), y.length > 0)
|
|
2652
|
+
switch (u) {
|
|
2586
2653
|
case "reset":
|
|
2587
|
-
r.resetFragments =
|
|
2654
|
+
r.resetFragments = y;
|
|
2588
2655
|
break;
|
|
2589
2656
|
case "refetch":
|
|
2590
|
-
r.refetchFragments =
|
|
2657
|
+
r.refetchFragments = y;
|
|
2591
2658
|
break;
|
|
2592
2659
|
case "click":
|
|
2593
|
-
r.clickFragments =
|
|
2660
|
+
r.clickFragments = y;
|
|
2594
2661
|
break;
|
|
2595
2662
|
case "open":
|
|
2596
|
-
r.openFragments =
|
|
2663
|
+
r.openFragments = y;
|
|
2597
2664
|
break;
|
|
2598
2665
|
case "close":
|
|
2599
|
-
r.closeFragments =
|
|
2666
|
+
r.closeFragments = y;
|
|
2600
2667
|
break;
|
|
2601
2668
|
}
|
|
2602
2669
|
});
|
|
2603
2670
|
}
|
|
2604
|
-
if (!e && (t.hasAttribute(
|
|
2671
|
+
if (!e && (t.hasAttribute(c.attrName(null, "data", !0)) && (r.data = c.resolveDataAttribute(
|
|
2605
2672
|
t,
|
|
2606
|
-
|
|
2607
|
-
)), t.hasAttribute(
|
|
2608
|
-
const
|
|
2609
|
-
|
|
2673
|
+
c.attrName(null, "data", !0)
|
|
2674
|
+
)), t.hasAttribute(c.attrName(null, "form", !0)))) {
|
|
2675
|
+
const d = t.getRawAttribute(
|
|
2676
|
+
c.attrName(null, "form", !0)
|
|
2610
2677
|
);
|
|
2611
|
-
if (
|
|
2612
|
-
const
|
|
2613
|
-
|
|
2614
|
-
|
|
2678
|
+
if (d) {
|
|
2679
|
+
const u = document.body.querySelector(d);
|
|
2680
|
+
u !== null ? r.formFragment = A.getFormFragment(
|
|
2681
|
+
N.get(u)
|
|
2615
2682
|
) : h.error(
|
|
2616
2683
|
"Haori",
|
|
2617
|
-
`Form element not found: ${
|
|
2684
|
+
`Form element not found: ${d} (${c.attrName(null, "fetch-form", !0)})`
|
|
2618
2685
|
);
|
|
2619
2686
|
} else
|
|
2620
|
-
r.formFragment =
|
|
2687
|
+
r.formFragment = A.getFormFragment(t);
|
|
2621
2688
|
}
|
|
2622
|
-
return
|
|
2689
|
+
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
2623
2690
|
}
|
|
2624
2691
|
/**
|
|
2625
2692
|
* ElementFragment の構造的タイプガード。
|
|
@@ -2640,7 +2707,7 @@ ${d}
|
|
|
2640
2707
|
* @param arg2 イベント名
|
|
2641
2708
|
*/
|
|
2642
2709
|
constructor(t, e = null) {
|
|
2643
|
-
|
|
2710
|
+
c.isElementFragment(t) ? this.options = c.buildOptions(t, e) : this.options = t;
|
|
2644
2711
|
}
|
|
2645
2712
|
/**
|
|
2646
2713
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -2648,136 +2715,161 @@ ${d}
|
|
|
2648
2715
|
* @returns 実行結果のPromise
|
|
2649
2716
|
*/
|
|
2650
2717
|
run() {
|
|
2651
|
-
return
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2718
|
+
return this.runWithResult().then(() => {
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
/**
|
|
2722
|
+
* 一連の処理を実行し、成功したかどうかを返します。
|
|
2723
|
+
*
|
|
2724
|
+
* @returns 成功した場合は true、途中停止や失敗時は false
|
|
2725
|
+
*/
|
|
2726
|
+
runWithResult() {
|
|
2727
|
+
return this.execute();
|
|
2728
|
+
}
|
|
2729
|
+
/**
|
|
2730
|
+
* 一連の処理を実行します。成功結果を内部で扱うための実体です。
|
|
2731
|
+
*
|
|
2732
|
+
* @returns 実行成功時は true、停止や失敗時は false
|
|
2733
|
+
*/
|
|
2734
|
+
async execute() {
|
|
2735
|
+
if (Object.keys(this.options).length === 0 || this.options.formFragment && this.validate(this.options.formFragment) === !1 || !await this.confirm())
|
|
2736
|
+
return !1;
|
|
2737
|
+
let e = this.options.fetchUrl, r = this.options.fetchOptions;
|
|
2738
|
+
if (this.options.beforeCallback) {
|
|
2739
|
+
const o = this.options.beforeCallback(
|
|
2740
|
+
e || null,
|
|
2741
|
+
r || null
|
|
2742
|
+
);
|
|
2743
|
+
if (o != null) {
|
|
2744
|
+
if (o === !1 || typeof o == "object" && o.stop)
|
|
2745
|
+
return !1;
|
|
2746
|
+
typeof o == "object" && (e = "fetchUrl" in o ? o.fetchUrl : e, r = "fetchOptions" in o ? o.fetchOptions : r);
|
|
2665
2747
|
}
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2748
|
+
}
|
|
2749
|
+
const i = {};
|
|
2750
|
+
if (this.options.formFragment) {
|
|
2751
|
+
const o = A.getValues(this.options.formFragment);
|
|
2752
|
+
Object.assign(i, o);
|
|
2753
|
+
}
|
|
2754
|
+
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2755
|
+
const s = Object.keys(i).length > 0;
|
|
2756
|
+
if (e) {
|
|
2757
|
+
const o = { ...r || {} }, p = new Headers(
|
|
2758
|
+
o.headers || void 0
|
|
2759
|
+
), f = (o.method || "GET").toUpperCase(), T = l.runtime === "demo" && !nt(f), E = T ? "GET" : f;
|
|
2760
|
+
if (o.method = E, E === "GET" || E === "HEAD" || E === "OPTIONS")
|
|
2761
|
+
s && (e = ot(e, i));
|
|
2762
|
+
else if (s) {
|
|
2763
|
+
const u = p.get("Content-Type") || "";
|
|
2764
|
+
if (/multipart\/form-data/i.test(u)) {
|
|
2765
|
+
p.delete("Content-Type");
|
|
2766
|
+
const g = new FormData();
|
|
2767
|
+
for (const [b, y] of Object.entries(i))
|
|
2768
|
+
y == null ? g.append(b, "") : y instanceof Blob ? g.append(b, y) : Array.isArray(y) ? y.forEach((x) => g.append(b, String(x))) : typeof y == "object" ? g.append(b, JSON.stringify(y)) : g.append(b, String(y));
|
|
2769
|
+
o.body = g;
|
|
2770
|
+
} else if (/application\/x-www-form-urlencoded/i.test(u)) {
|
|
2771
|
+
const g = new URLSearchParams();
|
|
2772
|
+
for (const [b, y] of Object.entries(i))
|
|
2773
|
+
y !== void 0 && (y === null ? g.append(b, "") : Array.isArray(y) ? y.forEach((x) => g.append(b, String(x))) : typeof y == "object" ? g.append(b, JSON.stringify(y)) : g.append(b, String(y)));
|
|
2774
|
+
o.body = g;
|
|
2775
|
+
} else
|
|
2776
|
+
p.set("Content-Type", "application/json"), o.body = JSON.stringify(i);
|
|
2670
2777
|
}
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
if (e) {
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
}
|
|
2702
|
-
if (s.headers = a, this.options.targetFragment && e) {
|
|
2703
|
-
const p = performance.now();
|
|
2704
|
-
return E.fetchStart(
|
|
2778
|
+
o.headers = p;
|
|
2779
|
+
let d;
|
|
2780
|
+
if (T && (d = e && new URL(e, window.location.href).search || void 0, p.delete("Content-Type"), h.info("Haori demo fetch normalization", {
|
|
2781
|
+
runtime: l.runtime,
|
|
2782
|
+
requestedMethod: f,
|
|
2783
|
+
effectiveMethod: E,
|
|
2784
|
+
transportMode: "query-get",
|
|
2785
|
+
url: e,
|
|
2786
|
+
payload: s ? i : void 0,
|
|
2787
|
+
queryString: d
|
|
2788
|
+
})), this.options.targetFragment && e) {
|
|
2789
|
+
const u = performance.now(), g = {
|
|
2790
|
+
runtime: l.runtime,
|
|
2791
|
+
requestedMethod: f,
|
|
2792
|
+
effectiveMethod: E,
|
|
2793
|
+
transportMode: T ? "query-get" : "http",
|
|
2794
|
+
...T ? { queryString: d } : {}
|
|
2795
|
+
};
|
|
2796
|
+
return v.fetchStart(
|
|
2797
|
+
this.options.targetFragment.getTarget(),
|
|
2798
|
+
e,
|
|
2799
|
+
o,
|
|
2800
|
+
s ? i : void 0,
|
|
2801
|
+
g
|
|
2802
|
+
), fetch(e, o).then((b) => this.handleFetchResult(
|
|
2803
|
+
b,
|
|
2804
|
+
e || void 0,
|
|
2805
|
+
u
|
|
2806
|
+
)).catch((b) => {
|
|
2807
|
+
throw e && v.fetchError(
|
|
2705
2808
|
this.options.targetFragment.getTarget(),
|
|
2706
2809
|
e,
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
), fetch(e, s).then((c) => this.handleFetchResult(
|
|
2710
|
-
c,
|
|
2711
|
-
e || void 0,
|
|
2712
|
-
p
|
|
2713
|
-
)).catch((c) => {
|
|
2714
|
-
throw e && E.fetchError(
|
|
2715
|
-
this.options.targetFragment.getTarget(),
|
|
2716
|
-
e,
|
|
2717
|
-
c
|
|
2718
|
-
), c;
|
|
2719
|
-
});
|
|
2720
|
-
} else return e ? fetch(e, s).then((p) => this.handleFetchResult(p, e || void 0)) : Promise.resolve();
|
|
2721
|
-
} else {
|
|
2722
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && i) {
|
|
2723
|
-
const o = this.options.formFragment, p = o.getTarget();
|
|
2724
|
-
p.setAttribute(
|
|
2725
|
-
`${f.prefix}bind`,
|
|
2726
|
-
JSON.stringify(n)
|
|
2727
|
-
);
|
|
2728
|
-
const c = o.getBindingData();
|
|
2729
|
-
return Object.assign(c, n), T.setBindingData(p, c);
|
|
2730
|
-
}
|
|
2731
|
-
const s = i ? n : {}, a = new Response(JSON.stringify(s), {
|
|
2732
|
-
headers: { "Content-Type": "application/json" }
|
|
2810
|
+
b
|
|
2811
|
+
), b;
|
|
2733
2812
|
});
|
|
2734
|
-
return this.handleFetchResult(a);
|
|
2735
2813
|
}
|
|
2814
|
+
return fetch(e, o).then((u) => this.handleFetchResult(u, e || void 0));
|
|
2815
|
+
}
|
|
2816
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2817
|
+
const o = this.options.formFragment, p = o.getTarget();
|
|
2818
|
+
p.setAttribute(
|
|
2819
|
+
`${l.prefix}bind`,
|
|
2820
|
+
JSON.stringify(i)
|
|
2821
|
+
);
|
|
2822
|
+
const f = o.getBindingData();
|
|
2823
|
+
return Object.assign(f, i), await R.setBindingData(p, f), !0;
|
|
2824
|
+
}
|
|
2825
|
+
const n = s ? i : {}, a = new Response(JSON.stringify(n), {
|
|
2826
|
+
headers: { "Content-Type": "application/json" }
|
|
2736
2827
|
});
|
|
2828
|
+
return this.handleFetchResult(a);
|
|
2737
2829
|
}
|
|
2738
2830
|
/**
|
|
2739
2831
|
* フェッチ後の処理を実行します。
|
|
2740
2832
|
*/
|
|
2741
|
-
handleFetchResult(t, e, r) {
|
|
2742
|
-
const
|
|
2833
|
+
async handleFetchResult(t, e, r) {
|
|
2834
|
+
const i = X();
|
|
2743
2835
|
if (!t.ok)
|
|
2744
|
-
return this.options.targetFragment && e &&
|
|
2836
|
+
return this.options.targetFragment && e && v.fetchError(
|
|
2745
2837
|
this.options.targetFragment.getTarget(),
|
|
2746
2838
|
e,
|
|
2747
2839
|
new Error(`${t.status} ${t.statusText}`),
|
|
2748
2840
|
t.status,
|
|
2749
2841
|
r
|
|
2750
|
-
), this.handleFetchError(t);
|
|
2751
|
-
if (this.options.targetFragment && e && r &&
|
|
2842
|
+
), await this.handleFetchError(t), !1;
|
|
2843
|
+
if (this.options.targetFragment && e && r && v.fetchEnd(
|
|
2752
2844
|
this.options.targetFragment.getTarget(),
|
|
2753
2845
|
e,
|
|
2754
2846
|
t.status,
|
|
2755
2847
|
r
|
|
2756
2848
|
), this.options.afterCallback) {
|
|
2757
|
-
const
|
|
2758
|
-
if (
|
|
2759
|
-
if (
|
|
2760
|
-
return
|
|
2761
|
-
typeof
|
|
2849
|
+
const n = this.options.afterCallback(t);
|
|
2850
|
+
if (n != null) {
|
|
2851
|
+
if (n === !1 || typeof n == "object" && n.stop)
|
|
2852
|
+
return !1;
|
|
2853
|
+
typeof n == "object" && "response" in n && (t = "response" in n ? n.response : t);
|
|
2762
2854
|
}
|
|
2763
2855
|
}
|
|
2764
|
-
const
|
|
2765
|
-
return
|
|
2766
|
-
|
|
2767
|
-
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((
|
|
2768
|
-
|
|
2769
|
-
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((
|
|
2770
|
-
const a =
|
|
2856
|
+
const s = [];
|
|
2857
|
+
return s.push(this.bindResult(t)), s.push(this.adjust()), s.push(this.addRow()), s.push(this.removeRow()), s.push(this.movePrevRow()), s.push(this.moveNextRow()), this.options.resetFragments && this.options.resetFragments.length > 0 && this.options.resetFragments.forEach((n) => {
|
|
2858
|
+
s.push(A.reset(n));
|
|
2859
|
+
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((n) => {
|
|
2860
|
+
s.push(new c(n, null).run());
|
|
2861
|
+
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((n) => {
|
|
2862
|
+
const a = n.getTarget();
|
|
2771
2863
|
typeof a.click == "function" ? a.click() : a.dispatchEvent(
|
|
2772
2864
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
2773
2865
|
);
|
|
2774
|
-
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((
|
|
2775
|
-
const a =
|
|
2776
|
-
a instanceof HTMLElement ?
|
|
2777
|
-
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((
|
|
2778
|
-
const a =
|
|
2779
|
-
a instanceof HTMLElement ?
|
|
2780
|
-
}), Promise.all(
|
|
2866
|
+
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((n) => {
|
|
2867
|
+
const a = n.getTarget();
|
|
2868
|
+
a instanceof HTMLElement ? s.push(i.openDialog(a)) : h.error("Haori", "Element is not an HTML element: ", a);
|
|
2869
|
+
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((n) => {
|
|
2870
|
+
const a = n.getTarget();
|
|
2871
|
+
a instanceof HTMLElement ? s.push(i.closeDialog(a)) : h.error("Haori", "Element is not an HTML element: ", a);
|
|
2872
|
+
}), await Promise.all(s), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(this.options.toastMessage, "info"), this.pushHistory(), this.options.redirectUrl && (window.location.href = this.options.redirectUrl), !0;
|
|
2781
2873
|
}
|
|
2782
2874
|
/**
|
|
2783
2875
|
* history.pushState を実行します。
|
|
@@ -2790,26 +2882,26 @@ ${d}
|
|
|
2790
2882
|
const t = this.options.historyUrl !== void 0 && this.options.historyUrl !== null, e = this.options.historyData !== void 0 && this.options.historyData !== null, r = this.options.historyFormFragment !== void 0 && this.options.historyFormFragment !== null;
|
|
2791
2883
|
if (!(!t && !e && !r))
|
|
2792
2884
|
try {
|
|
2793
|
-
const
|
|
2794
|
-
if (
|
|
2795
|
-
const a = "history.pushState: cross-origin URL is not allowed: " +
|
|
2885
|
+
const i = t ? this.options.historyUrl : window.location.pathname, s = new URL(i, window.location.href);
|
|
2886
|
+
if (s.origin !== window.location.origin) {
|
|
2887
|
+
const a = "history.pushState: cross-origin URL is not allowed: " + s.toString();
|
|
2796
2888
|
h.error(
|
|
2797
2889
|
"Haori",
|
|
2798
2890
|
a
|
|
2799
2891
|
);
|
|
2800
2892
|
return;
|
|
2801
2893
|
}
|
|
2802
|
-
const
|
|
2894
|
+
const n = (a) => {
|
|
2803
2895
|
for (const [o, p] of Object.entries(a))
|
|
2804
|
-
p != null && (Array.isArray(p) ? p.forEach((
|
|
2896
|
+
p != null && (Array.isArray(p) ? p.forEach((f) => s.searchParams.append(o, String(f))) : typeof p == "object" ? s.searchParams.set(o, JSON.stringify(p)) : s.searchParams.set(o, String(p)));
|
|
2805
2897
|
};
|
|
2806
|
-
e &&
|
|
2807
|
-
|
|
2898
|
+
e && n(this.options.historyData), r && n(
|
|
2899
|
+
A.getValues(
|
|
2808
2900
|
this.options.historyFormFragment
|
|
2809
2901
|
)
|
|
2810
|
-
), history.pushState({}, "",
|
|
2811
|
-
} catch (
|
|
2812
|
-
h.error("Haori", `history.pushState failed: ${
|
|
2902
|
+
), history.pushState({}, "", s.toString());
|
|
2903
|
+
} catch (i) {
|
|
2904
|
+
h.error("Haori", `history.pushState failed: ${i}`);
|
|
2813
2905
|
}
|
|
2814
2906
|
}
|
|
2815
2907
|
/**
|
|
@@ -2817,42 +2909,41 @@ ${d}
|
|
|
2817
2909
|
*/
|
|
2818
2910
|
async handleFetchError(t) {
|
|
2819
2911
|
let e = null;
|
|
2820
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
2821
|
-
const r = async (
|
|
2822
|
-
const
|
|
2823
|
-
await
|
|
2912
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2913
|
+
const r = async (s) => {
|
|
2914
|
+
const n = e ? e.getTarget() : document.body;
|
|
2915
|
+
await X().addErrorMessage(n, s);
|
|
2824
2916
|
};
|
|
2825
2917
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
2826
2918
|
try {
|
|
2827
|
-
const
|
|
2828
|
-
if (
|
|
2829
|
-
if (typeof
|
|
2830
|
-
for (const a of
|
|
2831
|
-
typeof a == "string" &&
|
|
2832
|
-
if (
|
|
2833
|
-
for (const [a, o] of Object.entries(
|
|
2834
|
-
Array.isArray(o) ?
|
|
2835
|
-
`) }) : typeof o == "string" ?
|
|
2836
|
-
if (
|
|
2837
|
-
for (const [a, o] of Object.entries(
|
|
2838
|
-
a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ?
|
|
2839
|
-
`) }) : typeof o == "string" &&
|
|
2919
|
+
const s = await t.json(), n = [];
|
|
2920
|
+
if (s && typeof s == "object") {
|
|
2921
|
+
if (typeof s.message == "string" && n.push({ message: s.message }), Array.isArray(s.messages))
|
|
2922
|
+
for (const a of s.messages)
|
|
2923
|
+
typeof a == "string" && n.push({ message: a });
|
|
2924
|
+
if (s.errors && typeof s.errors == "object")
|
|
2925
|
+
for (const [a, o] of Object.entries(s.errors))
|
|
2926
|
+
Array.isArray(o) ? n.push({ key: a, message: o.join(`
|
|
2927
|
+
`) }) : typeof o == "string" ? n.push({ key: a, message: o }) : o != null && n.push({ key: a, message: String(o) });
|
|
2928
|
+
if (n.length === 0)
|
|
2929
|
+
for (const [a, o] of Object.entries(s))
|
|
2930
|
+
a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ? n.push({ key: a, message: o.join(`
|
|
2931
|
+
`) }) : typeof o == "string" && n.push({ key: a, message: o }));
|
|
2840
2932
|
}
|
|
2841
|
-
if (
|
|
2842
|
-
await r(`${t.status} ${t.statusText}`);
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
a.key && e ? await b.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
2847
|
-
return;
|
|
2933
|
+
if (n.length === 0)
|
|
2934
|
+
return await r(`${t.status} ${t.statusText}`), !1;
|
|
2935
|
+
for (const a of n)
|
|
2936
|
+
a.key && e ? await A.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
2937
|
+
return !1;
|
|
2848
2938
|
} catch {
|
|
2849
2939
|
}
|
|
2850
2940
|
try {
|
|
2851
|
-
const
|
|
2852
|
-
|
|
2941
|
+
const s = await t.text();
|
|
2942
|
+
s && s.trim().length > 0 ? await r(s.trim()) : await r(`${t.status} ${t.statusText}`);
|
|
2853
2943
|
} catch {
|
|
2854
2944
|
await r(`${t.status} ${t.statusText}`);
|
|
2855
2945
|
}
|
|
2946
|
+
return !1;
|
|
2856
2947
|
}
|
|
2857
2948
|
/**
|
|
2858
2949
|
* 対象のフラグメント以下の入力要素に対してバリデーションを実行します。
|
|
@@ -2866,8 +2957,8 @@ ${d}
|
|
|
2866
2957
|
return !0;
|
|
2867
2958
|
const e = t.getTarget();
|
|
2868
2959
|
let r = this.validateOne(t);
|
|
2869
|
-
return r || e.focus(), t.getChildElementFragments().reverse().forEach((
|
|
2870
|
-
r &&= this.validate(
|
|
2960
|
+
return r || e.focus(), t.getChildElementFragments().reverse().forEach((i) => {
|
|
2961
|
+
r &&= this.validate(i);
|
|
2871
2962
|
}), r;
|
|
2872
2963
|
}
|
|
2873
2964
|
/**
|
|
@@ -2888,7 +2979,7 @@ ${d}
|
|
|
2888
2979
|
*/
|
|
2889
2980
|
confirm() {
|
|
2890
2981
|
const t = this.options.confirmMessage;
|
|
2891
|
-
return t == null ? Promise.resolve(!0) :
|
|
2982
|
+
return t == null ? Promise.resolve(!0) : X().confirm(t);
|
|
2892
2983
|
}
|
|
2893
2984
|
/**
|
|
2894
2985
|
* 結果データを対象のフラグメントにバインドします。
|
|
@@ -2898,35 +2989,61 @@ ${d}
|
|
|
2898
2989
|
bindResult(t) {
|
|
2899
2990
|
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) => {
|
|
2900
2991
|
if (this.options.bindParams) {
|
|
2901
|
-
const
|
|
2902
|
-
this.options.bindParams.forEach((
|
|
2903
|
-
r && typeof r == "object" &&
|
|
2904
|
-
}), r =
|
|
2992
|
+
const s = {};
|
|
2993
|
+
this.options.bindParams.forEach((n) => {
|
|
2994
|
+
r && typeof r == "object" && n in r && (s[n] = r[n]);
|
|
2995
|
+
}), r = s;
|
|
2905
2996
|
}
|
|
2906
|
-
const
|
|
2997
|
+
const i = [];
|
|
2907
2998
|
if (this.options.bindArg)
|
|
2908
|
-
this.options.bindFragments.forEach((
|
|
2909
|
-
const
|
|
2910
|
-
|
|
2999
|
+
this.options.bindFragments.forEach((s) => {
|
|
3000
|
+
const n = s.getBindingData(), a = this.options.bindArg;
|
|
3001
|
+
if (r && typeof r == "object" && !Array.isArray(r)) {
|
|
3002
|
+
const o = n[a], p = o && typeof o == "object" && !Array.isArray(o) ? o : {};
|
|
3003
|
+
n[a] = this.mergeAppendBindingData(
|
|
3004
|
+
s,
|
|
3005
|
+
r,
|
|
3006
|
+
p
|
|
3007
|
+
);
|
|
3008
|
+
} else
|
|
3009
|
+
n[a] = r;
|
|
3010
|
+
i.push(R.setBindingData(s.getTarget(), n));
|
|
2911
3011
|
});
|
|
2912
3012
|
else {
|
|
2913
3013
|
if (typeof r == "string")
|
|
2914
3014
|
return h.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
2915
3015
|
new Error("string data cannot be bound without a bindArg.")
|
|
2916
3016
|
);
|
|
2917
|
-
this.options.bindFragments.forEach((
|
|
2918
|
-
n.
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
3017
|
+
this.options.bindFragments.forEach((s) => {
|
|
3018
|
+
const n = this.mergeAppendBindingData(
|
|
3019
|
+
s,
|
|
3020
|
+
r
|
|
3021
|
+
);
|
|
3022
|
+
i.push(
|
|
3023
|
+
R.setBindingData(
|
|
3024
|
+
s.getTarget(),
|
|
3025
|
+
n
|
|
2922
3026
|
)
|
|
2923
3027
|
);
|
|
2924
3028
|
});
|
|
2925
3029
|
}
|
|
2926
|
-
return Promise.all(
|
|
3030
|
+
return Promise.all(i).then(() => {
|
|
2927
3031
|
});
|
|
2928
3032
|
});
|
|
2929
3033
|
}
|
|
3034
|
+
/**
|
|
3035
|
+
* bind-append 指定があるキーについて、既存配列と結合したデータを返します。
|
|
3036
|
+
*/
|
|
3037
|
+
mergeAppendBindingData(t, e, r = t.getBindingData()) {
|
|
3038
|
+
if (!this.options.bindAppendParams || this.options.bindAppendParams.length === 0)
|
|
3039
|
+
return e;
|
|
3040
|
+
const i = { ...e }, s = r;
|
|
3041
|
+
for (const n of this.options.bindAppendParams) {
|
|
3042
|
+
const a = i[n], o = s[n];
|
|
3043
|
+
Array.isArray(o) && Array.isArray(a) && (i[n] = o.concat(a));
|
|
3044
|
+
}
|
|
3045
|
+
return i;
|
|
3046
|
+
}
|
|
2930
3047
|
/**
|
|
2931
3048
|
* 値の増減を行います。
|
|
2932
3049
|
*/
|
|
@@ -2935,10 +3052,10 @@ ${d}
|
|
|
2935
3052
|
return Promise.resolve();
|
|
2936
3053
|
const t = this.options.adjustValue ?? 0, e = [];
|
|
2937
3054
|
for (const r of this.options.adjustFragments) {
|
|
2938
|
-
let
|
|
2939
|
-
(
|
|
2940
|
-
let
|
|
2941
|
-
isNaN(
|
|
3055
|
+
let i = r.getValue();
|
|
3056
|
+
(i == null || i === "") && (i = "0");
|
|
3057
|
+
let s = Number(i);
|
|
3058
|
+
isNaN(s) && (s = 0), s += t, e.push(r.setValue(String(s)));
|
|
2942
3059
|
}
|
|
2943
3060
|
return Promise.all(e).then(() => {
|
|
2944
3061
|
});
|
|
@@ -2952,7 +3069,7 @@ ${d}
|
|
|
2952
3069
|
if (!this.options.targetFragment)
|
|
2953
3070
|
return h.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
2954
3071
|
const t = this.options.targetFragment.closestByAttribute(
|
|
2955
|
-
`${
|
|
3072
|
+
`${l.prefix}row`
|
|
2956
3073
|
);
|
|
2957
3074
|
return t || (h.error("Haori", "Row fragment not found."), null);
|
|
2958
3075
|
}
|
|
@@ -2970,7 +3087,7 @@ ${d}
|
|
|
2970
3087
|
const e = [], r = t.clone();
|
|
2971
3088
|
return e.push(
|
|
2972
3089
|
t.getParent().insertAfter(r, t)
|
|
2973
|
-
), e.push(
|
|
3090
|
+
), e.push(R.evaluateAll(r)), e.push(A.reset(r)), Promise.all(e).then(() => {
|
|
2974
3091
|
});
|
|
2975
3092
|
}
|
|
2976
3093
|
/**
|
|
@@ -2985,7 +3102,7 @@ ${d}
|
|
|
2985
3102
|
if (!t)
|
|
2986
3103
|
return Promise.reject(new Error("Row fragment not found."));
|
|
2987
3104
|
const e = t.getParent();
|
|
2988
|
-
return e && e.getChildElementFragments().filter((
|
|
3105
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${l.prefix}each-before`) && !i.hasAttribute(`${l.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
2989
3106
|
}
|
|
2990
3107
|
/**
|
|
2991
3108
|
* 前の行へ移動します。
|
|
@@ -3022,9 +3139,9 @@ ${d}
|
|
|
3022
3139
|
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
3023
3140
|
}
|
|
3024
3141
|
};
|
|
3025
|
-
|
|
3026
|
-
let
|
|
3027
|
-
class
|
|
3142
|
+
c.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, c.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/;
|
|
3143
|
+
let V = c;
|
|
3144
|
+
class lt {
|
|
3028
3145
|
/**
|
|
3029
3146
|
* URLのクエリパラメータを取得します。
|
|
3030
3147
|
*
|
|
@@ -3032,12 +3149,12 @@ class _ {
|
|
|
3032
3149
|
*/
|
|
3033
3150
|
static readParams() {
|
|
3034
3151
|
const t = {}, e = window.location.search;
|
|
3035
|
-
return new URLSearchParams(e).forEach((
|
|
3036
|
-
t[
|
|
3152
|
+
return new URLSearchParams(e).forEach((i, s) => {
|
|
3153
|
+
t[s] = i;
|
|
3037
3154
|
}), t;
|
|
3038
3155
|
}
|
|
3039
3156
|
}
|
|
3040
|
-
class
|
|
3157
|
+
class ct {
|
|
3041
3158
|
/**
|
|
3042
3159
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
3043
3160
|
*
|
|
@@ -3054,24 +3171,24 @@ class tt {
|
|
|
3054
3171
|
let r;
|
|
3055
3172
|
try {
|
|
3056
3173
|
r = await fetch(t, e);
|
|
3057
|
-
} catch (
|
|
3058
|
-
throw h.error("[Haori]", "Failed to fetch import source:", t,
|
|
3174
|
+
} catch (s) {
|
|
3175
|
+
throw h.error("[Haori]", "Failed to fetch import source:", t, s), new Error(`Failed to fetch: ${t}`);
|
|
3059
3176
|
}
|
|
3060
3177
|
if (!r.ok) {
|
|
3061
|
-
const
|
|
3062
|
-
throw h.error("[Haori]", "Import HTTP error:", t,
|
|
3178
|
+
const s = `${r.status} ${r.statusText}`;
|
|
3179
|
+
throw h.error("[Haori]", "Import HTTP error:", t, s), new Error(`Failed to load ${t}: ${s}`);
|
|
3063
3180
|
}
|
|
3064
|
-
let
|
|
3181
|
+
let i;
|
|
3065
3182
|
try {
|
|
3066
|
-
|
|
3067
|
-
} catch (
|
|
3068
|
-
throw h.error("[Haori]", "Failed to read response text:", t,
|
|
3183
|
+
i = await r.text();
|
|
3184
|
+
} catch (s) {
|
|
3185
|
+
throw h.error("[Haori]", "Failed to read response text:", t, s), new Error(`Failed to read response from: ${t}`);
|
|
3069
3186
|
}
|
|
3070
3187
|
try {
|
|
3071
|
-
const
|
|
3072
|
-
return
|
|
3073
|
-
} catch (
|
|
3074
|
-
return h.error("[Haori]", "Failed to parse imported HTML:", t,
|
|
3188
|
+
const n = new DOMParser().parseFromString(i, "text/html");
|
|
3189
|
+
return n && n.body ? n.body.innerHTML : (h.warn("[Haori]", "No body found in imported document:", t), i);
|
|
3190
|
+
} catch (s) {
|
|
3191
|
+
return h.error("[Haori]", "Failed to parse imported HTML:", t, s), i;
|
|
3075
3192
|
}
|
|
3076
3193
|
}
|
|
3077
3194
|
}
|
|
@@ -3084,7 +3201,7 @@ const m = class m {
|
|
|
3084
3201
|
*/
|
|
3085
3202
|
static isDeferredAttributeName(t) {
|
|
3086
3203
|
return m.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
3087
|
-
(e) => t === `${
|
|
3204
|
+
(e) => t === `${l.prefix}${e}`
|
|
3088
3205
|
);
|
|
3089
3206
|
}
|
|
3090
3207
|
/**
|
|
@@ -3095,7 +3212,7 @@ const m = class m {
|
|
|
3095
3212
|
*/
|
|
3096
3213
|
static isEvaluateAllExcludedAttributeName(t) {
|
|
3097
3214
|
return m.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
3098
|
-
(e) => t === `${
|
|
3215
|
+
(e) => t === `${l.prefix}${e}`
|
|
3099
3216
|
);
|
|
3100
3217
|
}
|
|
3101
3218
|
/**
|
|
@@ -3118,8 +3235,8 @@ const m = class m {
|
|
|
3118
3235
|
static reevaluateInterpolatedAttributes(t) {
|
|
3119
3236
|
let e = Promise.resolve();
|
|
3120
3237
|
for (const r of t.getAttributeNames()) {
|
|
3121
|
-
const
|
|
3122
|
-
m.shouldReevaluateAttribute(r,
|
|
3238
|
+
const i = t.getRawAttribute(r);
|
|
3239
|
+
m.shouldReevaluateAttribute(r, i) && (e = e.then(() => t.setAttribute(r, i)));
|
|
3123
3240
|
}
|
|
3124
3241
|
return e.then(() => {
|
|
3125
3242
|
});
|
|
@@ -3131,39 +3248,39 @@ const m = class m {
|
|
|
3131
3248
|
* @returns Promise (スキャンが完了したときに解決される)
|
|
3132
3249
|
*/
|
|
3133
3250
|
static scan(t) {
|
|
3134
|
-
const e =
|
|
3251
|
+
const e = N.get(t);
|
|
3135
3252
|
if (!e)
|
|
3136
3253
|
return Promise.resolve();
|
|
3137
|
-
t.parentNode && (
|
|
3138
|
-
const r = [],
|
|
3139
|
-
for (const
|
|
3140
|
-
const
|
|
3141
|
-
e.hasAttribute(
|
|
3254
|
+
t.parentNode && (N.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
3255
|
+
const r = [], i = /* @__PURE__ */ new Set();
|
|
3256
|
+
for (const s of m.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
3257
|
+
const n = l.prefix + s;
|
|
3258
|
+
e.hasAttribute(n) && (r.push(
|
|
3142
3259
|
m.setAttribute(
|
|
3143
3260
|
e.getTarget(),
|
|
3144
|
-
|
|
3145
|
-
e.getRawAttribute(
|
|
3261
|
+
n,
|
|
3262
|
+
e.getRawAttribute(n)
|
|
3146
3263
|
)
|
|
3147
|
-
),
|
|
3264
|
+
), i.add(n));
|
|
3148
3265
|
}
|
|
3149
|
-
for (const
|
|
3150
|
-
if (
|
|
3266
|
+
for (const s of e.getAttributeNames()) {
|
|
3267
|
+
if (i.has(s) || m.isDeferredAttributeName(s))
|
|
3151
3268
|
continue;
|
|
3152
|
-
const
|
|
3153
|
-
|
|
3269
|
+
const n = e.getRawAttribute(s);
|
|
3270
|
+
n !== null && r.push(m.setAttribute(e.getTarget(), s, n));
|
|
3154
3271
|
}
|
|
3155
|
-
for (const
|
|
3156
|
-
const
|
|
3157
|
-
e.hasAttribute(
|
|
3272
|
+
for (const s of m.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
3273
|
+
const n = l.prefix + s;
|
|
3274
|
+
e.hasAttribute(n) && (r.push(
|
|
3158
3275
|
m.setAttribute(
|
|
3159
3276
|
e.getTarget(),
|
|
3160
|
-
|
|
3161
|
-
e.getRawAttribute(
|
|
3277
|
+
n,
|
|
3278
|
+
e.getRawAttribute(n)
|
|
3162
3279
|
)
|
|
3163
|
-
),
|
|
3280
|
+
), i.add(n));
|
|
3164
3281
|
}
|
|
3165
|
-
return e.getChildren().forEach((
|
|
3166
|
-
|
|
3282
|
+
return e.getChildren().forEach((s) => {
|
|
3283
|
+
s instanceof D ? r.push(m.scan(s.getTarget())) : s instanceof L && r.push(m.evaluateText(s));
|
|
3167
3284
|
}), Promise.all(r).then(() => {
|
|
3168
3285
|
});
|
|
3169
3286
|
}
|
|
@@ -3177,51 +3294,54 @@ const m = class m {
|
|
|
3177
3294
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3178
3295
|
*/
|
|
3179
3296
|
static setAttribute(t, e, r) {
|
|
3180
|
-
const
|
|
3297
|
+
const i = N.get(t), s = [];
|
|
3181
3298
|
switch (e) {
|
|
3182
|
-
case `${
|
|
3183
|
-
r === null ? (
|
|
3299
|
+
case `${l.prefix}bind`: {
|
|
3300
|
+
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(m.parseDataBind(r));
|
|
3184
3301
|
break;
|
|
3185
3302
|
}
|
|
3186
|
-
case `${
|
|
3187
|
-
|
|
3303
|
+
case `${l.prefix}if`:
|
|
3304
|
+
s.push(m.evaluateIf(i));
|
|
3188
3305
|
break;
|
|
3189
|
-
case `${
|
|
3190
|
-
|
|
3306
|
+
case `${l.prefix}each`:
|
|
3307
|
+
s.push(m.evaluateEach(i));
|
|
3191
3308
|
break;
|
|
3192
|
-
case `${
|
|
3193
|
-
|
|
3309
|
+
case `${l.prefix}fetch`:
|
|
3310
|
+
s.push(
|
|
3311
|
+
new V(i, null).run().then(() => {
|
|
3312
|
+
})
|
|
3313
|
+
);
|
|
3194
3314
|
break;
|
|
3195
|
-
case `${
|
|
3315
|
+
case `${l.prefix}import`: {
|
|
3196
3316
|
if (typeof r == "string") {
|
|
3197
|
-
const
|
|
3198
|
-
|
|
3199
|
-
|
|
3317
|
+
const n = i.getTarget(), a = performance.now();
|
|
3318
|
+
v.importStart(n, r), s.push(
|
|
3319
|
+
ct.load(r).then((o) => {
|
|
3200
3320
|
const p = new TextEncoder().encode(o).length;
|
|
3201
|
-
return
|
|
3202
|
-
|
|
3321
|
+
return F.enqueue(() => {
|
|
3322
|
+
n.innerHTML = o;
|
|
3203
3323
|
}).then(() => {
|
|
3204
|
-
|
|
3324
|
+
v.importEnd(n, r, p, a);
|
|
3205
3325
|
});
|
|
3206
3326
|
}).catch((o) => {
|
|
3207
|
-
|
|
3327
|
+
v.importError(n, r, o), h.error("[Haori]", "Failed to import HTML:", r, o);
|
|
3208
3328
|
})
|
|
3209
3329
|
);
|
|
3210
3330
|
}
|
|
3211
3331
|
break;
|
|
3212
3332
|
}
|
|
3213
|
-
case `${
|
|
3214
|
-
const
|
|
3215
|
-
if (
|
|
3333
|
+
case `${l.prefix}url-param`: {
|
|
3334
|
+
const n = i.getAttribute(`${l.prefix}url-arg`), a = lt.readParams();
|
|
3335
|
+
if (n === null)
|
|
3216
3336
|
m.setBindingData(t, a);
|
|
3217
3337
|
else {
|
|
3218
|
-
const o =
|
|
3219
|
-
o[String(
|
|
3338
|
+
const o = i.getRawBindingData() || {};
|
|
3339
|
+
o[String(n)] = a, m.setBindingData(t, o);
|
|
3220
3340
|
}
|
|
3221
3341
|
break;
|
|
3222
3342
|
}
|
|
3223
3343
|
}
|
|
3224
|
-
return r === null ?
|
|
3344
|
+
return r === null ? s.push(i.removeAttribute(e)) : s.push(i.setAttribute(e, r)), Promise.all(s).then(() => {
|
|
3225
3345
|
});
|
|
3226
3346
|
}
|
|
3227
3347
|
/**
|
|
@@ -3233,12 +3353,12 @@ const m = class m {
|
|
|
3233
3353
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3234
3354
|
*/
|
|
3235
3355
|
static setBindingData(t, e) {
|
|
3236
|
-
const r =
|
|
3356
|
+
const r = N.get(t), i = r.getRawBindingData();
|
|
3237
3357
|
r.setBindingData(e);
|
|
3238
|
-
const
|
|
3239
|
-
return
|
|
3240
|
-
r.setAttribute(`${
|
|
3241
|
-
),
|
|
3358
|
+
const s = [];
|
|
3359
|
+
return s.push(
|
|
3360
|
+
r.setAttribute(`${l.prefix}bind`, JSON.stringify(e))
|
|
3361
|
+
), s.push(m.evaluateAll(r)), v.bindChange(t, i, e, "manual"), Promise.all(s).then(() => {
|
|
3242
3362
|
});
|
|
3243
3363
|
}
|
|
3244
3364
|
/**
|
|
@@ -3256,8 +3376,8 @@ const m = class m {
|
|
|
3256
3376
|
}
|
|
3257
3377
|
else {
|
|
3258
3378
|
const e = new URLSearchParams(t), r = {};
|
|
3259
|
-
for (const [
|
|
3260
|
-
r[
|
|
3379
|
+
for (const [i, s] of e.entries())
|
|
3380
|
+
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(s) : r[i] = [r[i], s] : r[i] = s;
|
|
3261
3381
|
return r;
|
|
3262
3382
|
}
|
|
3263
3383
|
}
|
|
@@ -3268,11 +3388,11 @@ const m = class m {
|
|
|
3268
3388
|
* @param node 追加するノード
|
|
3269
3389
|
*/
|
|
3270
3390
|
static addNode(t, e) {
|
|
3271
|
-
const r =
|
|
3391
|
+
const r = N.get(t);
|
|
3272
3392
|
if (r.isSkipMutationNodes())
|
|
3273
3393
|
return;
|
|
3274
|
-
const
|
|
3275
|
-
|
|
3394
|
+
const i = N.get(e.nextSibling), s = N.get(e);
|
|
3395
|
+
s && (r.insertBefore(s, i), s instanceof D ? m.scan(s.getTarget()) : s instanceof L && m.evaluateText(s));
|
|
3276
3396
|
}
|
|
3277
3397
|
/**
|
|
3278
3398
|
* ノードを親要素から削除します。
|
|
@@ -3280,7 +3400,7 @@ const m = class m {
|
|
|
3280
3400
|
* @param node 削除するノード
|
|
3281
3401
|
*/
|
|
3282
3402
|
static removeNode(t) {
|
|
3283
|
-
const e =
|
|
3403
|
+
const e = N.get(t);
|
|
3284
3404
|
if (e) {
|
|
3285
3405
|
const r = e.getParent();
|
|
3286
3406
|
if (r && r.isSkipMutationNodes())
|
|
@@ -3295,7 +3415,7 @@ const m = class m {
|
|
|
3295
3415
|
* @param text 新しいテキスト
|
|
3296
3416
|
*/
|
|
3297
3417
|
static changeText(t, e) {
|
|
3298
|
-
const r =
|
|
3418
|
+
const r = N.get(t);
|
|
3299
3419
|
r && r.setContent(e);
|
|
3300
3420
|
}
|
|
3301
3421
|
/**
|
|
@@ -3307,18 +3427,18 @@ const m = class m {
|
|
|
3307
3427
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
3308
3428
|
*/
|
|
3309
3429
|
static changeValue(t, e) {
|
|
3310
|
-
const r =
|
|
3430
|
+
const r = N.get(t);
|
|
3311
3431
|
if (r.getValue() === e)
|
|
3312
3432
|
return Promise.resolve();
|
|
3313
|
-
const
|
|
3314
|
-
|
|
3315
|
-
const
|
|
3316
|
-
if (
|
|
3317
|
-
const
|
|
3433
|
+
const i = [];
|
|
3434
|
+
i.push(r.setValue(e));
|
|
3435
|
+
const s = m.getFormFragment(r);
|
|
3436
|
+
if (s) {
|
|
3437
|
+
const n = A.getValues(s), a = s.getAttribute(`${l.prefix}form-arg`);
|
|
3318
3438
|
let o;
|
|
3319
|
-
a ? (o =
|
|
3439
|
+
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(m.setBindingData(s.getTarget(), o));
|
|
3320
3440
|
}
|
|
3321
|
-
return Promise.all(
|
|
3441
|
+
return Promise.all(i).then(() => {
|
|
3322
3442
|
});
|
|
3323
3443
|
}
|
|
3324
3444
|
/**
|
|
@@ -3341,8 +3461,8 @@ const m = class m {
|
|
|
3341
3461
|
*/
|
|
3342
3462
|
static evaluateAll(t) {
|
|
3343
3463
|
const e = [];
|
|
3344
|
-
return e.push(m.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${
|
|
3345
|
-
r instanceof
|
|
3464
|
+
return e.push(m.reevaluateInterpolatedAttributes(t)), t.hasAttribute(`${l.prefix}if`) && e.push(m.evaluateIf(t)), t.hasAttribute(`${l.prefix}each`) && e.push(m.evaluateEach(t)), t.getChildren().forEach((r) => {
|
|
3465
|
+
r instanceof D ? e.push(m.evaluateAll(r)) : r instanceof L && e.push(m.evaluateText(r));
|
|
3346
3466
|
}), Promise.all(e).then(() => {
|
|
3347
3467
|
});
|
|
3348
3468
|
}
|
|
@@ -3363,14 +3483,14 @@ const m = class m {
|
|
|
3363
3483
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
3364
3484
|
*/
|
|
3365
3485
|
static evaluateIf(t) {
|
|
3366
|
-
const e = [], r = t.getAttribute(`${
|
|
3486
|
+
const e = [], r = t.getAttribute(`${l.prefix}if`);
|
|
3367
3487
|
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
3368
3488
|
t.hide().then(() => {
|
|
3369
|
-
|
|
3489
|
+
v.hide(t.getTarget());
|
|
3370
3490
|
})
|
|
3371
3491
|
) : t.isVisible() || (e.push(
|
|
3372
3492
|
t.show().then(() => {
|
|
3373
|
-
|
|
3493
|
+
v.show(t.getTarget());
|
|
3374
3494
|
})
|
|
3375
3495
|
), e.push(m.evaluateAll(t))), Promise.all(e).then(() => {
|
|
3376
3496
|
});
|
|
@@ -3386,20 +3506,20 @@ const m = class m {
|
|
|
3386
3506
|
return Promise.resolve();
|
|
3387
3507
|
let e = t.getTemplate();
|
|
3388
3508
|
if (e === null) {
|
|
3389
|
-
let
|
|
3390
|
-
t.getChildren().forEach((
|
|
3391
|
-
if (!
|
|
3392
|
-
if (
|
|
3509
|
+
let i = !1;
|
|
3510
|
+
t.getChildren().forEach((n) => {
|
|
3511
|
+
if (!i && n instanceof D) {
|
|
3512
|
+
if (n.hasAttribute(`${l.prefix}each-before`) || n.hasAttribute(`${l.prefix}each-after`))
|
|
3393
3513
|
return;
|
|
3394
|
-
e =
|
|
3395
|
-
const a =
|
|
3396
|
-
a.parentNode && a.parentNode.removeChild(a),
|
|
3514
|
+
e = n.clone(), t.setTemplate(e), i = !0, t.removeChild(n);
|
|
3515
|
+
const a = n.getTarget();
|
|
3516
|
+
a.parentNode && a.parentNode.removeChild(a), n.setMounted(!1);
|
|
3397
3517
|
}
|
|
3398
3518
|
});
|
|
3399
|
-
const
|
|
3400
|
-
return Array.isArray(
|
|
3519
|
+
const s = t.getAttribute(`${l.prefix}each`);
|
|
3520
|
+
return Array.isArray(s) ? this.updateDiff(t, s) : (h.error("[Haori]", "Invalid each attribute:", s), Promise.reject(new Error("Invalid each attribute.")));
|
|
3401
3521
|
}
|
|
3402
|
-
const r = t.getAttribute(`${
|
|
3522
|
+
const r = t.getAttribute(`${l.prefix}each`);
|
|
3403
3523
|
return Array.isArray(r) ? this.updateDiff(t, r) : (h.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
3404
3524
|
}
|
|
3405
3525
|
/**
|
|
@@ -3412,72 +3532,72 @@ const m = class m {
|
|
|
3412
3532
|
const r = t.getTemplate();
|
|
3413
3533
|
if (r === null)
|
|
3414
3534
|
return h.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
3415
|
-
let
|
|
3416
|
-
|
|
3417
|
-
const
|
|
3418
|
-
e.forEach((
|
|
3419
|
-
const
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3535
|
+
let i = t.getAttribute(`${l.prefix}each-index`);
|
|
3536
|
+
i && (i = String(i));
|
|
3537
|
+
const s = t.getAttribute(`${l.prefix}each-key`), n = t.getAttribute(`${l.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
3538
|
+
e.forEach((u, g) => {
|
|
3539
|
+
const b = m.createListKey(
|
|
3540
|
+
u,
|
|
3541
|
+
s ? String(s) : null,
|
|
3542
|
+
g
|
|
3423
3543
|
);
|
|
3424
|
-
o.push(
|
|
3544
|
+
o.push(b), a.set(b, { item: u, itemIndex: g });
|
|
3425
3545
|
});
|
|
3426
3546
|
const p = [];
|
|
3427
|
-
let
|
|
3428
|
-
(
|
|
3547
|
+
let f = t.getChildren().filter((u) => u instanceof D).filter(
|
|
3548
|
+
(u) => !u.hasAttribute(`${l.prefix}each-before`) && !u.hasAttribute(`${l.prefix}each-after`)
|
|
3429
3549
|
);
|
|
3430
|
-
|
|
3431
|
-
const
|
|
3550
|
+
f = f.filter((u) => o.indexOf(String(u.getListKey())) === -1 ? (p.push(u.remove()), !1) : !0);
|
|
3551
|
+
const T = f.map((u) => u.getListKey()), E = t.getChildren().filter((u) => u instanceof D).filter((u) => u.hasAttribute(`${l.prefix}each-before`)).length;
|
|
3432
3552
|
let d = Promise.resolve();
|
|
3433
|
-
return o.forEach((
|
|
3434
|
-
const
|
|
3435
|
-
let
|
|
3436
|
-
if (
|
|
3437
|
-
|
|
3553
|
+
return o.forEach((u, g) => {
|
|
3554
|
+
const b = T.indexOf(u), { item: y, itemIndex: x } = a.get(u);
|
|
3555
|
+
let k;
|
|
3556
|
+
if (b !== -1)
|
|
3557
|
+
k = f[b], d = d.then(
|
|
3438
3558
|
() => m.updateRowFragment(
|
|
3559
|
+
k,
|
|
3560
|
+
y,
|
|
3561
|
+
i,
|
|
3439
3562
|
x,
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
s ? String(s) : null,
|
|
3444
|
-
g
|
|
3445
|
-
).then(() => m.evaluateAll(x))
|
|
3563
|
+
n ? String(n) : null,
|
|
3564
|
+
u
|
|
3565
|
+
).then(() => m.evaluateAll(k))
|
|
3446
3566
|
);
|
|
3447
3567
|
else {
|
|
3448
|
-
|
|
3449
|
-
const
|
|
3568
|
+
k = r.clone();
|
|
3569
|
+
const U = E + g;
|
|
3450
3570
|
d = d.then(
|
|
3451
3571
|
() => m.updateRowFragment(
|
|
3572
|
+
k,
|
|
3573
|
+
y,
|
|
3574
|
+
i,
|
|
3452
3575
|
x,
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
F,
|
|
3456
|
-
s ? String(s) : null,
|
|
3457
|
-
g
|
|
3576
|
+
n ? String(n) : null,
|
|
3577
|
+
u
|
|
3458
3578
|
).then(
|
|
3459
3579
|
() => t.insertBefore(
|
|
3460
|
-
|
|
3461
|
-
t.getChildren()[
|
|
3462
|
-
).then(() => m.evaluateAll(
|
|
3580
|
+
k,
|
|
3581
|
+
t.getChildren()[U] || null
|
|
3582
|
+
).then(() => m.evaluateAll(k))
|
|
3463
3583
|
)
|
|
3464
3584
|
);
|
|
3465
3585
|
}
|
|
3466
3586
|
}), Promise.all(p).then(() => d).then(() => {
|
|
3467
|
-
const
|
|
3468
|
-
(
|
|
3469
|
-
),
|
|
3470
|
-
(
|
|
3471
|
-
),
|
|
3472
|
-
(
|
|
3473
|
-
),
|
|
3474
|
-
(
|
|
3587
|
+
const u = o.filter(
|
|
3588
|
+
(x) => x !== null
|
|
3589
|
+
), g = T.filter(
|
|
3590
|
+
(x) => x !== null
|
|
3591
|
+
), b = u.filter(
|
|
3592
|
+
(x) => !g.includes(x)
|
|
3593
|
+
), y = g.filter(
|
|
3594
|
+
(x) => !u.includes(x)
|
|
3475
3595
|
);
|
|
3476
|
-
|
|
3596
|
+
v.eachUpdate(
|
|
3477
3597
|
t.getTarget(),
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3598
|
+
b,
|
|
3599
|
+
y,
|
|
3600
|
+
u
|
|
3481
3601
|
);
|
|
3482
3602
|
});
|
|
3483
3603
|
}
|
|
@@ -3490,16 +3610,16 @@ const m = class m {
|
|
|
3490
3610
|
* @returns リストキー
|
|
3491
3611
|
*/
|
|
3492
3612
|
static createListKey(t, e, r) {
|
|
3493
|
-
let
|
|
3613
|
+
let i;
|
|
3494
3614
|
if (typeof t == "object" && t !== null)
|
|
3495
3615
|
if (e) {
|
|
3496
|
-
const
|
|
3497
|
-
|
|
3616
|
+
const s = t[e];
|
|
3617
|
+
s == null ? i = `__index_${r}` : typeof s == "object" ? i = JSON.stringify(s) : i = String(s);
|
|
3498
3618
|
} else
|
|
3499
|
-
|
|
3619
|
+
i = `__index_${r}`;
|
|
3500
3620
|
else
|
|
3501
|
-
|
|
3502
|
-
return
|
|
3621
|
+
i = String(t);
|
|
3622
|
+
return i;
|
|
3503
3623
|
}
|
|
3504
3624
|
/**
|
|
3505
3625
|
* 行フラグメントにデータを設定します。
|
|
@@ -3512,22 +3632,22 @@ const m = class m {
|
|
|
3512
3632
|
* @param listKey リストキー
|
|
3513
3633
|
* @returns 行メタデータの更新完了 Promise
|
|
3514
3634
|
*/
|
|
3515
|
-
static updateRowFragment(t, e, r,
|
|
3635
|
+
static updateRowFragment(t, e, r, i, s, n) {
|
|
3516
3636
|
let a = e;
|
|
3517
3637
|
if (typeof e == "object" && e !== null)
|
|
3518
|
-
a = { ...e }, r && (a[r] =
|
|
3519
|
-
[
|
|
3638
|
+
a = { ...e }, r && (a[r] = i), s && (a = {
|
|
3639
|
+
[s]: a
|
|
3520
3640
|
});
|
|
3521
|
-
else if (
|
|
3641
|
+
else if (s)
|
|
3522
3642
|
a = {
|
|
3523
|
-
[
|
|
3524
|
-
}, r && (a[r] =
|
|
3643
|
+
[s]: e
|
|
3644
|
+
}, r && (a[r] = i);
|
|
3525
3645
|
else
|
|
3526
3646
|
return h.error(
|
|
3527
3647
|
"[Haori]",
|
|
3528
|
-
`Primitive value requires '${
|
|
3648
|
+
`Primitive value requires '${l.prefix}each-arg' attribute: ${e}`
|
|
3529
3649
|
), Promise.resolve();
|
|
3530
|
-
return t.setListKey(
|
|
3650
|
+
return t.setListKey(n), t.setBindingData(a), t.setAttribute(`${l.prefix}row`, n);
|
|
3531
3651
|
}
|
|
3532
3652
|
};
|
|
3533
3653
|
m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"], m.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
@@ -3538,8 +3658,8 @@ m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUF
|
|
|
3538
3658
|
"import",
|
|
3539
3659
|
"url-param"
|
|
3540
3660
|
], m.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/;
|
|
3541
|
-
let
|
|
3542
|
-
class
|
|
3661
|
+
let R = m;
|
|
3662
|
+
class ut {
|
|
3543
3663
|
/**
|
|
3544
3664
|
* コンストラクタ。
|
|
3545
3665
|
*
|
|
@@ -3547,8 +3667,8 @@ class et {
|
|
|
3547
3667
|
*/
|
|
3548
3668
|
constructor(t = document) {
|
|
3549
3669
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
3550
|
-
const e = document.documentElement, r =
|
|
3551
|
-
r && new
|
|
3670
|
+
const e = document.documentElement, r = N.get(e);
|
|
3671
|
+
r && new V(r, "load").run();
|
|
3552
3672
|
}, this.root = t;
|
|
3553
3673
|
}
|
|
3554
3674
|
/**
|
|
@@ -3574,9 +3694,9 @@ class et {
|
|
|
3574
3694
|
const r = this.getElementFromTarget(t.target);
|
|
3575
3695
|
if (!r)
|
|
3576
3696
|
return;
|
|
3577
|
-
const
|
|
3578
|
-
|
|
3579
|
-
h.error("[Haori]", "Procedure execution error:",
|
|
3697
|
+
const i = N.get(r);
|
|
3698
|
+
i && (e === "change" && i instanceof D && i.syncValue(), new V(i, e).run().catch((s) => {
|
|
3699
|
+
h.error("[Haori]", "Procedure execution error:", s);
|
|
3580
3700
|
}));
|
|
3581
3701
|
}
|
|
3582
3702
|
/**
|
|
@@ -3589,20 +3709,136 @@ class et {
|
|
|
3589
3709
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
3590
3710
|
}
|
|
3591
3711
|
}
|
|
3592
|
-
const
|
|
3712
|
+
const w = class w {
|
|
3713
|
+
static syncTree(t) {
|
|
3714
|
+
(t instanceof Element || t instanceof DocumentFragment) && (t instanceof HTMLElement && w.syncElement(t), t.querySelectorAll("*").forEach((e) => {
|
|
3715
|
+
w.syncElement(e);
|
|
3716
|
+
}));
|
|
3717
|
+
}
|
|
3718
|
+
static syncElement(t) {
|
|
3719
|
+
const e = w.registrations.get(t), r = N.get(t);
|
|
3720
|
+
if (!r || !w.shouldObserve(r)) {
|
|
3721
|
+
e && (e.observer.disconnect(), w.registrations.delete(t));
|
|
3722
|
+
return;
|
|
3723
|
+
}
|
|
3724
|
+
if (typeof IntersectionObserver > "u")
|
|
3725
|
+
return;
|
|
3726
|
+
const i = w.resolveRoot(r), s = w.resolveRootMargin(r), n = w.resolveThreshold(r), a = r.hasAttribute(`${l.prefix}intersect-once`);
|
|
3727
|
+
if (e && e.observer.root === i && e.observer.rootMargin === s && w.sameThreshold(
|
|
3728
|
+
e.observer.thresholds,
|
|
3729
|
+
n
|
|
3730
|
+
) && e.once === a) {
|
|
3731
|
+
e.fragment = r;
|
|
3732
|
+
return;
|
|
3733
|
+
}
|
|
3734
|
+
e && (e.observer.disconnect(), w.registrations.delete(t));
|
|
3735
|
+
const o = new IntersectionObserver(
|
|
3736
|
+
(p) => {
|
|
3737
|
+
const f = w.registrations.get(t);
|
|
3738
|
+
f && p.forEach((T) => {
|
|
3739
|
+
!T.isIntersecting || f.running || w.isDisabled(f.fragment) || (f.running = !0, new V(f.fragment, "intersect").runWithResult().then((E) => {
|
|
3740
|
+
E && f.once && (f.observer.disconnect(), w.registrations.delete(t));
|
|
3741
|
+
}).catch((E) => {
|
|
3742
|
+
h.error(
|
|
3743
|
+
"[Haori]",
|
|
3744
|
+
"Intersect procedure execution error:",
|
|
3745
|
+
E
|
|
3746
|
+
);
|
|
3747
|
+
}).finally(() => {
|
|
3748
|
+
const E = w.registrations.get(t);
|
|
3749
|
+
E && (E.running = !1);
|
|
3750
|
+
}));
|
|
3751
|
+
});
|
|
3752
|
+
},
|
|
3753
|
+
{
|
|
3754
|
+
root: i,
|
|
3755
|
+
rootMargin: s,
|
|
3756
|
+
threshold: n
|
|
3757
|
+
}
|
|
3758
|
+
);
|
|
3759
|
+
o.observe(t), w.registrations.set(t, {
|
|
3760
|
+
fragment: r,
|
|
3761
|
+
observer: o,
|
|
3762
|
+
once: a,
|
|
3763
|
+
running: !1
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3766
|
+
static cleanupTree(t) {
|
|
3767
|
+
if (t instanceof HTMLElement) {
|
|
3768
|
+
const e = w.registrations.get(t);
|
|
3769
|
+
e && (e.observer.disconnect(), w.registrations.delete(t));
|
|
3770
|
+
}
|
|
3771
|
+
(t instanceof Element || t instanceof DocumentFragment) && t.querySelectorAll("*").forEach((e) => {
|
|
3772
|
+
const r = w.registrations.get(e);
|
|
3773
|
+
r && (r.observer.disconnect(), w.registrations.delete(e));
|
|
3774
|
+
});
|
|
3775
|
+
}
|
|
3776
|
+
static disconnectAll() {
|
|
3777
|
+
w.registrations.forEach((t) => {
|
|
3778
|
+
t.observer.disconnect();
|
|
3779
|
+
}), w.registrations.clear();
|
|
3780
|
+
}
|
|
3781
|
+
static shouldObserve(t) {
|
|
3782
|
+
return t.getAttributeNames().some((e) => {
|
|
3783
|
+
if (!e.startsWith(`${l.prefix}intersect-`))
|
|
3784
|
+
return !1;
|
|
3785
|
+
const r = e.slice(`${l.prefix}intersect-`.length);
|
|
3786
|
+
return !w.CONFIG_KEYS.has(r);
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
static resolveRoot(t) {
|
|
3790
|
+
const e = `${l.prefix}intersect-root`;
|
|
3791
|
+
if (!t.hasAttribute(e))
|
|
3792
|
+
return null;
|
|
3793
|
+
const r = t.getAttribute(e);
|
|
3794
|
+
if (typeof r != "string" || r.trim() === "")
|
|
3795
|
+
return null;
|
|
3796
|
+
const i = document.querySelector(r);
|
|
3797
|
+
return i instanceof HTMLElement ? i : (h.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
3798
|
+
}
|
|
3799
|
+
static resolveRootMargin(t) {
|
|
3800
|
+
const e = `${l.prefix}intersect-root-margin`, r = t.getAttribute(e);
|
|
3801
|
+
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
3802
|
+
}
|
|
3803
|
+
static resolveThreshold(t) {
|
|
3804
|
+
const e = `${l.prefix}intersect-threshold`, r = t.getAttribute(e), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
3805
|
+
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
3806
|
+
}
|
|
3807
|
+
static isDisabled(t) {
|
|
3808
|
+
const e = `${l.prefix}intersect-disabled`, r = t.getAttribute(e);
|
|
3809
|
+
if (r === null || r === !1)
|
|
3810
|
+
return !1;
|
|
3811
|
+
if (typeof r == "boolean")
|
|
3812
|
+
return r;
|
|
3813
|
+
const i = String(r).trim().toLowerCase();
|
|
3814
|
+
return i !== "" && i !== "false" && i !== "0";
|
|
3815
|
+
}
|
|
3816
|
+
static sameThreshold(t, e) {
|
|
3817
|
+
return t.length === 1 && t[0] === e;
|
|
3818
|
+
}
|
|
3819
|
+
};
|
|
3820
|
+
w.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
3821
|
+
"root",
|
|
3822
|
+
"root-margin",
|
|
3823
|
+
"threshold",
|
|
3824
|
+
"disabled",
|
|
3825
|
+
"once"
|
|
3826
|
+
]), w.registrations = /* @__PURE__ */ new Map();
|
|
3827
|
+
let B = w;
|
|
3828
|
+
const H = class H {
|
|
3593
3829
|
/**
|
|
3594
3830
|
* 初期化メソッド。
|
|
3595
3831
|
* ドキュメントのheadとbodyを監視対象として設定します。
|
|
3596
3832
|
*/
|
|
3597
3833
|
static async init() {
|
|
3598
|
-
if (
|
|
3834
|
+
if (H._initialized)
|
|
3599
3835
|
return;
|
|
3600
|
-
|
|
3836
|
+
H._initialized = !0;
|
|
3601
3837
|
const t = await Promise.allSettled([
|
|
3602
|
-
|
|
3603
|
-
|
|
3838
|
+
R.scan(document.head),
|
|
3839
|
+
R.scan(document.body)
|
|
3604
3840
|
]), [e, r] = t;
|
|
3605
|
-
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),
|
|
3841
|
+
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), H.observe(document.head), H.observe(document.body), new ut().start(), B.syncTree(document.body);
|
|
3606
3842
|
}
|
|
3607
3843
|
/**
|
|
3608
3844
|
* 指定された要素を監視します。
|
|
@@ -3611,34 +3847,34 @@ const O = class O {
|
|
|
3611
3847
|
*/
|
|
3612
3848
|
static observe(t) {
|
|
3613
3849
|
new MutationObserver(async (r) => {
|
|
3614
|
-
for (const
|
|
3850
|
+
for (const i of r)
|
|
3615
3851
|
try {
|
|
3616
|
-
switch (
|
|
3852
|
+
switch (i.type) {
|
|
3617
3853
|
case "attributes": {
|
|
3618
3854
|
h.info(
|
|
3619
3855
|
"[Haori]",
|
|
3620
3856
|
"Attribute changed:",
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
);
|
|
3624
|
-
const i = n.target;
|
|
3625
|
-
T.setAttribute(
|
|
3626
|
-
i,
|
|
3627
|
-
n.attributeName,
|
|
3628
|
-
i.getAttribute(n.attributeName)
|
|
3857
|
+
i.target,
|
|
3858
|
+
i.attributeName
|
|
3629
3859
|
);
|
|
3860
|
+
const s = i.target;
|
|
3861
|
+
R.setAttribute(
|
|
3862
|
+
s,
|
|
3863
|
+
i.attributeName,
|
|
3864
|
+
s.getAttribute(i.attributeName)
|
|
3865
|
+
), B.syncElement(s);
|
|
3630
3866
|
break;
|
|
3631
3867
|
}
|
|
3632
3868
|
case "childList": {
|
|
3633
3869
|
h.info(
|
|
3634
3870
|
"[Haori]",
|
|
3635
3871
|
"Child list changed:",
|
|
3636
|
-
Array.from(
|
|
3637
|
-
Array.from(
|
|
3638
|
-
), Array.from(
|
|
3639
|
-
|
|
3640
|
-
}), Array.from(
|
|
3641
|
-
|
|
3872
|
+
Array.from(i.removedNodes).map((s) => s.nodeName),
|
|
3873
|
+
Array.from(i.addedNodes).map((s) => s.nodeName)
|
|
3874
|
+
), Array.from(i.removedNodes).forEach((s) => {
|
|
3875
|
+
B.cleanupTree(s), R.removeNode(s);
|
|
3876
|
+
}), Array.from(i.addedNodes).forEach((s) => {
|
|
3877
|
+
s.parentElement instanceof HTMLElement && (R.addNode(s.parentElement, s), B.syncTree(s));
|
|
3642
3878
|
});
|
|
3643
3879
|
break;
|
|
3644
3880
|
}
|
|
@@ -3646,21 +3882,21 @@ const O = class O {
|
|
|
3646
3882
|
h.info(
|
|
3647
3883
|
"[Haori]",
|
|
3648
3884
|
"Character data changed:",
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
),
|
|
3885
|
+
i.target,
|
|
3886
|
+
i.target.textContent
|
|
3887
|
+
), i.target instanceof Text || i.target instanceof Comment ? R.changeText(i.target, i.target.textContent) : h.warn(
|
|
3652
3888
|
"[Haori]",
|
|
3653
3889
|
"Unsupported character data type:",
|
|
3654
|
-
|
|
3890
|
+
i.target
|
|
3655
3891
|
);
|
|
3656
3892
|
break;
|
|
3657
3893
|
}
|
|
3658
3894
|
default:
|
|
3659
|
-
h.warn("[Haori]", "Unknown mutation type:",
|
|
3895
|
+
h.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
3660
3896
|
continue;
|
|
3661
3897
|
}
|
|
3662
|
-
} catch (
|
|
3663
|
-
h.error("[Haori]", "Error processing mutation:",
|
|
3898
|
+
} catch (s) {
|
|
3899
|
+
h.error("[Haori]", "Error processing mutation:", s);
|
|
3664
3900
|
}
|
|
3665
3901
|
}).observe(t, {
|
|
3666
3902
|
childList: !0,
|
|
@@ -3670,19 +3906,19 @@ const O = class O {
|
|
|
3670
3906
|
}), h.info("[Haori]", "Observer initialized for", t);
|
|
3671
3907
|
}
|
|
3672
3908
|
};
|
|
3673
|
-
|
|
3674
|
-
let
|
|
3675
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
3676
|
-
const
|
|
3909
|
+
H._initialized = !1;
|
|
3910
|
+
let G = H;
|
|
3911
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", G.init) : G.init();
|
|
3912
|
+
const ht = "0.4.0";
|
|
3677
3913
|
export {
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3914
|
+
R as Core,
|
|
3915
|
+
l as Env,
|
|
3916
|
+
A as Form,
|
|
3917
|
+
N as Fragment,
|
|
3918
|
+
_ as Haori,
|
|
3683
3919
|
h as Log,
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3920
|
+
F as Queue,
|
|
3921
|
+
_ as default,
|
|
3922
|
+
ht as version
|
|
3687
3923
|
};
|
|
3688
3924
|
//# sourceMappingURL=haori.es.js.map
|