haori 0.1.0 → 0.1.2
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 +26 -15
- package/README.md +26 -15
- package/dist/haori.cjs.js +10 -9
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +1194 -751
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +9 -8
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/package.json +70 -0
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +31 -26
- package/dist/src/core.js.map +1 -1
- package/dist/src/expression.d.ts +92 -0
- package/dist/src/expression.d.ts.map +1 -1
- package/dist/src/expression.js +475 -2
- package/dist/src/expression.js.map +1 -1
- package/dist/src/fragment.d.ts +9 -1
- package/dist/src/fragment.d.ts.map +1 -1
- package/dist/src/fragment.js +50 -6
- package/dist/src/fragment.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/observer.d.ts +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/tests/data-each-table.test.js +5 -20
- package/dist/tests/data-each-table.test.js.map +1 -1
- package/dist/tests/data-fetch-tbody-dom.test.d.ts +2 -0
- package/dist/tests/data-fetch-tbody-dom.test.d.ts.map +1 -0
- package/dist/tests/data-fetch-tbody-dom.test.js +99 -0
- package/dist/tests/data-fetch-tbody-dom.test.js.map +1 -0
- package/dist/tests/event.test.js +3 -2
- package/dist/tests/event.test.js.map +1 -1
- package/dist/tests/expression.test.js +92 -0
- package/dist/tests/expression.test.js.map +1 -1
- package/dist/tests/form.test.js +35 -34
- package/dist/tests/form.test.js.map +1 -1
- package/dist/tests/fragment.test.js +51 -1
- package/dist/tests/fragment.test.js.map +1 -1
- package/dist/tests/helpers/async.d.ts +19 -0
- package/dist/tests/helpers/async.d.ts.map +1 -0
- package/dist/tests/helpers/async.js +31 -0
- package/dist/tests/helpers/async.js.map +1 -0
- package/dist/tests/procedure-action-operations.test.js +15 -12
- package/dist/tests/procedure-action-operations.test.js.map +1 -1
- package/dist/tests/row-move.test.js +36 -13
- package/dist/tests/row-move.test.js.map +1 -1
- package/dist/tests/row-operations.test.js +21 -20
- package/dist/tests/row-operations.test.js.map +1 -1
- package/package.json +70 -68
package/dist/haori.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const R = class R {
|
|
2
2
|
/**
|
|
3
3
|
* 開発モードの状態を取得します。
|
|
4
4
|
*
|
|
5
5
|
* @returns 開発モードならtrue、そうでなければfalse
|
|
6
6
|
*/
|
|
7
7
|
static isEnabled() {
|
|
8
|
-
return
|
|
8
|
+
return R.devMode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 開発モードを有効化します。
|
|
12
12
|
*/
|
|
13
13
|
static enable() {
|
|
14
|
-
|
|
14
|
+
R.devMode = !0;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 開発モードを無効化します。
|
|
18
18
|
*/
|
|
19
19
|
static disable() {
|
|
20
|
-
|
|
20
|
+
R.devMode = !1;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 開発モードを切り替えます。
|
|
@@ -25,12 +25,12 @@ const C = class C {
|
|
|
25
25
|
* @param enabled trueで有効化、falseで無効化
|
|
26
26
|
*/
|
|
27
27
|
static set(t) {
|
|
28
|
-
|
|
28
|
+
R.devMode = t;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
let
|
|
33
|
-
const
|
|
31
|
+
R.devMode = !1;
|
|
32
|
+
let O = R;
|
|
33
|
+
const D = class D {
|
|
34
34
|
/**
|
|
35
35
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
36
36
|
* scriptタグにdata-prefixがある場合は、その値+"-"をプレフィックスとして使用します。
|
|
@@ -41,19 +41,19 @@ const k = class k {
|
|
|
41
41
|
try {
|
|
42
42
|
const t = document.currentScript || document.querySelector('script[src*="haori"]');
|
|
43
43
|
if (t instanceof HTMLScriptElement) {
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const r = t.getAttribute("data-prefix") || D._prefix;
|
|
45
|
+
D._prefix = r.endsWith("-") ? r : r + "-";
|
|
46
46
|
}
|
|
47
|
-
if (t instanceof HTMLScriptElement && t.hasAttribute(`${
|
|
48
|
-
|
|
47
|
+
if (t instanceof HTMLScriptElement && t.hasAttribute(`${D._prefix}dev`)) {
|
|
48
|
+
O.set(!0);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
const e = window.location.hostname;
|
|
52
52
|
if (e === "localhost" || e.endsWith(".localhost") || e === "127.0.0.1" || e === "::1" || e.endsWith(".local")) {
|
|
53
|
-
|
|
53
|
+
O.set(!0);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
O.set(!1);
|
|
57
57
|
} catch {
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -63,11 +63,11 @@ const k = class k {
|
|
|
63
63
|
* @returns プレフィックス
|
|
64
64
|
*/
|
|
65
65
|
static get prefix() {
|
|
66
|
-
return
|
|
66
|
+
return D._prefix;
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
let c =
|
|
69
|
+
D._prefix = "data-";
|
|
70
|
+
let c = D;
|
|
71
71
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c.detect) : c.detect();
|
|
72
72
|
class h {
|
|
73
73
|
/**
|
|
@@ -77,7 +77,7 @@ class h {
|
|
|
77
77
|
* @param args 追加の引数
|
|
78
78
|
*/
|
|
79
79
|
static info(t, ...e) {
|
|
80
|
-
|
|
80
|
+
O.isEnabled() && console.log && console.log(t, ...e);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* 開発モードでのみコンソールに警告を出力します。
|
|
@@ -86,7 +86,7 @@ class h {
|
|
|
86
86
|
* @param args 追加の引数
|
|
87
87
|
*/
|
|
88
88
|
static warn(t, ...e) {
|
|
89
|
-
|
|
89
|
+
O.isEnabled() && console.warn && console.warn(t, ...e);
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* モードに関係なくコンソールにエラーを出力します。
|
|
@@ -98,7 +98,7 @@ class h {
|
|
|
98
98
|
console.error(t, ...e);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
class
|
|
101
|
+
class Y {
|
|
102
102
|
constructor() {
|
|
103
103
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
104
104
|
}
|
|
@@ -110,17 +110,17 @@ class X {
|
|
|
110
110
|
* @returns 処理完了Promise
|
|
111
111
|
*/
|
|
112
112
|
enqueue(t, e = !1) {
|
|
113
|
-
let
|
|
114
|
-
const
|
|
115
|
-
|
|
113
|
+
let r, i;
|
|
114
|
+
const s = new Promise((a, o) => {
|
|
115
|
+
r = a, i = o;
|
|
116
116
|
}), n = {
|
|
117
117
|
task: t,
|
|
118
118
|
timestamp: performance.now(),
|
|
119
|
-
promise:
|
|
120
|
-
resolve:
|
|
121
|
-
reject:
|
|
119
|
+
promise: s,
|
|
120
|
+
resolve: r,
|
|
121
|
+
reject: i
|
|
122
122
|
};
|
|
123
|
-
return e ? this.queue.unshift(n) : this.queue.push(n), this.scheduleProcessing(),
|
|
123
|
+
return e ? this.queue.unshift(n) : this.queue.push(n), this.scheduleProcessing(), s;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* キューを処理します。
|
|
@@ -137,10 +137,10 @@ class X {
|
|
|
137
137
|
if (!e)
|
|
138
138
|
return;
|
|
139
139
|
try {
|
|
140
|
-
const
|
|
141
|
-
e.resolve(
|
|
142
|
-
} catch (
|
|
143
|
-
e.reject(
|
|
140
|
+
const r = await e.task();
|
|
141
|
+
e.resolve(r);
|
|
142
|
+
} catch (r) {
|
|
143
|
+
e.reject(r), h.error("[Haori]", `Task ${e.timestamp} failed:`, r);
|
|
144
144
|
}
|
|
145
145
|
if (performance.now() - t > this.MAX_BUDGET)
|
|
146
146
|
break;
|
|
@@ -174,7 +174,7 @@ class X {
|
|
|
174
174
|
t.length > 0 && await Promise.allSettled(t);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
const
|
|
177
|
+
const G = class G {
|
|
178
178
|
/**
|
|
179
179
|
* タスクをキューに追加します。
|
|
180
180
|
*
|
|
@@ -192,8 +192,8 @@ const K = class K {
|
|
|
192
192
|
return this.ASYNC_QUEUE.wait();
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
|
-
|
|
196
|
-
let
|
|
195
|
+
G.ASYNC_QUEUE = new Y();
|
|
196
|
+
let T = G;
|
|
197
197
|
class M {
|
|
198
198
|
/**
|
|
199
199
|
* 通知ダイアログを表示します。
|
|
@@ -202,7 +202,7 @@ class M {
|
|
|
202
202
|
* @returns 通知が閉じられると解決されるPromise
|
|
203
203
|
*/
|
|
204
204
|
static dialog(t) {
|
|
205
|
-
return
|
|
205
|
+
return T.enqueue(() => {
|
|
206
206
|
window.alert(t);
|
|
207
207
|
}, !0);
|
|
208
208
|
}
|
|
@@ -214,12 +214,12 @@ class M {
|
|
|
214
214
|
* @return 通知が表示されると解決されるPromise
|
|
215
215
|
*/
|
|
216
216
|
static async toast(t, e) {
|
|
217
|
-
const
|
|
218
|
-
|
|
217
|
+
const r = document.createElement("div");
|
|
218
|
+
r.className = `haori-toast haori-toast-${e}`, r.textContent = t, r.setAttribute("popover", "manual"), r.setAttribute("role", "status"), r.setAttribute("aria-live", "polite"), document.body.appendChild(r), r.showPopover(), setTimeout(() => {
|
|
219
219
|
try {
|
|
220
|
-
|
|
220
|
+
r.hidePopover();
|
|
221
221
|
} finally {
|
|
222
|
-
|
|
222
|
+
r.remove();
|
|
223
223
|
}
|
|
224
224
|
}, 3e3);
|
|
225
225
|
}
|
|
@@ -230,7 +230,7 @@ class M {
|
|
|
230
230
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
231
231
|
*/
|
|
232
232
|
static confirm(t) {
|
|
233
|
-
return
|
|
233
|
+
return T.enqueue(() => window.confirm(t), !0);
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* ダイアログを開きます。
|
|
@@ -238,7 +238,7 @@ class M {
|
|
|
238
238
|
* @param element 開くダイアログのHTML要素
|
|
239
239
|
*/
|
|
240
240
|
static openDialog(t) {
|
|
241
|
-
return
|
|
241
|
+
return T.enqueue(() => {
|
|
242
242
|
t instanceof HTMLDialogElement ? t.showModal() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
243
243
|
}, !0);
|
|
244
244
|
}
|
|
@@ -248,7 +248,7 @@ class M {
|
|
|
248
248
|
* @param element 閉じるダイアログのHTML要素
|
|
249
249
|
*/
|
|
250
250
|
static closeDialog(t) {
|
|
251
|
-
return
|
|
251
|
+
return T.enqueue(() => {
|
|
252
252
|
t instanceof HTMLDialogElement ? t.close() : h.error("[Haori]", "Element is not a dialog: ", t);
|
|
253
253
|
}, !0);
|
|
254
254
|
}
|
|
@@ -259,7 +259,7 @@ class M {
|
|
|
259
259
|
* @param message エラーメッセージ
|
|
260
260
|
*/
|
|
261
261
|
static addErrorMessage(t, e) {
|
|
262
|
-
return
|
|
262
|
+
return T.enqueue(() => {
|
|
263
263
|
if (t instanceof HTMLFormElement) {
|
|
264
264
|
t.setAttribute("data-message", e);
|
|
265
265
|
return;
|
|
@@ -277,14 +277,14 @@ class M {
|
|
|
277
277
|
* @param parent メッセージをクリアする親要素
|
|
278
278
|
*/
|
|
279
279
|
static clearMessages(t) {
|
|
280
|
-
return
|
|
280
|
+
return T.enqueue(() => {
|
|
281
281
|
t.removeAttribute("data-message"), t.querySelectorAll("[data-message]").forEach((e) => {
|
|
282
282
|
e.removeAttribute("data-message");
|
|
283
283
|
});
|
|
284
284
|
}, !0);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
class
|
|
287
|
+
class y {
|
|
288
288
|
/**
|
|
289
289
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
290
290
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -295,7 +295,7 @@ class E {
|
|
|
295
295
|
*/
|
|
296
296
|
static getValues(t) {
|
|
297
297
|
const e = {};
|
|
298
|
-
return
|
|
298
|
+
return y.getPartValues(t, e);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
301
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -306,32 +306,32 @@ class E {
|
|
|
306
306
|
* @returns values と同じオブジェクト
|
|
307
307
|
*/
|
|
308
308
|
static getPartValues(t, e) {
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
|
|
309
|
+
const r = t.getAttribute("name"), i = t.getAttribute(`${c.prefix}form-object`), s = t.getAttribute(`${c.prefix}form-list`);
|
|
310
|
+
if (r) {
|
|
311
|
+
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(
|
|
312
312
|
"Haori",
|
|
313
313
|
`Element cannot have both ${c.prefix}form-object and name attributes.`
|
|
314
314
|
);
|
|
315
315
|
for (const n of t.getChildElementFragments())
|
|
316
|
-
|
|
317
|
-
} else if (
|
|
316
|
+
y.getPartValues(n, e);
|
|
317
|
+
} else if (i) {
|
|
318
318
|
const n = {};
|
|
319
319
|
for (const a of t.getChildElementFragments())
|
|
320
|
-
|
|
321
|
-
Object.keys(n).length > 0 && (e[String(
|
|
320
|
+
y.getPartValues(a, n);
|
|
321
|
+
Object.keys(n).length > 0 && (e[String(i)] = n), s && h.warn(
|
|
322
322
|
"Haori",
|
|
323
323
|
`Element cannot have both ${c.prefix}form-list and ${c.prefix}form-object attributes.`
|
|
324
324
|
);
|
|
325
|
-
} else if (
|
|
325
|
+
} else if (s) {
|
|
326
326
|
const n = [];
|
|
327
327
|
for (const a of t.getChildElementFragments()) {
|
|
328
|
-
const
|
|
329
|
-
|
|
328
|
+
const o = {};
|
|
329
|
+
y.getPartValues(a, o), Object.keys(o).length > 0 && n.push(o);
|
|
330
330
|
}
|
|
331
|
-
n.length > 0 && (e[String(
|
|
331
|
+
n.length > 0 && (e[String(s)] = n);
|
|
332
332
|
} else
|
|
333
333
|
for (const n of t.getChildElementFragments())
|
|
334
|
-
|
|
334
|
+
y.getPartValues(n, e);
|
|
335
335
|
return e;
|
|
336
336
|
}
|
|
337
337
|
/**
|
|
@@ -343,8 +343,8 @@ class E {
|
|
|
343
343
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
344
344
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
345
345
|
*/
|
|
346
|
-
static setValues(t, e,
|
|
347
|
-
return
|
|
346
|
+
static setValues(t, e, r = !1) {
|
|
347
|
+
return y.setPartValues(t, e, null, r);
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
350
|
* フラグメント内にある各入力エレメントに値を設定します。
|
|
@@ -355,45 +355,45 @@ class E {
|
|
|
355
355
|
* @param force data-form-detach属性があるエレメントにも値を反映するかどうか
|
|
356
356
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
357
357
|
*/
|
|
358
|
-
static setPartValues(t, e,
|
|
359
|
-
const
|
|
358
|
+
static setPartValues(t, e, r = null, i = !1) {
|
|
359
|
+
const s = [], n = t.getAttribute("name"), a = t.getAttribute(`${c.prefix}form-object`), o = t.getAttribute(`${c.prefix}form-list`), g = t.getAttribute(`${c.prefix}form-detach`);
|
|
360
360
|
if (n) {
|
|
361
|
-
if (!
|
|
362
|
-
const
|
|
363
|
-
|
|
361
|
+
if (!g || i) {
|
|
362
|
+
const u = e[String(n)];
|
|
363
|
+
o && Array.isArray(u) && r !== null ? s.push(t.setValue(u[r])) : typeof u == "string" || typeof u == "number" || typeof u == "boolean" || u === null ? s.push(t.setValue(u)) : s.push(t.setValue(String(u)));
|
|
364
364
|
}
|
|
365
365
|
} else if (a) {
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
366
|
+
const u = e[String(a)];
|
|
367
|
+
if (u && typeof u == "object")
|
|
368
368
|
for (const b of t.getChildElementFragments())
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
s.push(
|
|
370
|
+
y.setPartValues(
|
|
371
371
|
b,
|
|
372
|
-
|
|
372
|
+
u,
|
|
373
373
|
null,
|
|
374
|
-
|
|
374
|
+
i
|
|
375
375
|
)
|
|
376
376
|
);
|
|
377
|
-
} else if (
|
|
378
|
-
const
|
|
379
|
-
if (Array.isArray(
|
|
377
|
+
} else if (o) {
|
|
378
|
+
const u = e[String(o)];
|
|
379
|
+
if (Array.isArray(u)) {
|
|
380
380
|
const b = t.getChildElementFragments();
|
|
381
|
-
for (let
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
l
|
|
387
|
-
|
|
388
|
-
|
|
381
|
+
for (let l = 0; l < b.length; l++) {
|
|
382
|
+
const f = b[l];
|
|
383
|
+
u.length > l ? s.push(
|
|
384
|
+
y.setPartValues(
|
|
385
|
+
f,
|
|
386
|
+
u[l],
|
|
387
|
+
l,
|
|
388
|
+
i
|
|
389
389
|
)
|
|
390
|
-
) :
|
|
390
|
+
) : s.push(y.setPartValues(f, {}, l, i));
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
} else
|
|
394
|
-
for (const
|
|
395
|
-
|
|
396
|
-
return Promise.all(
|
|
394
|
+
for (const u of t.getChildElementFragments())
|
|
395
|
+
s.push(y.setPartValues(u, e, null, i));
|
|
396
|
+
return Promise.all(s).then(() => {
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
@@ -404,18 +404,18 @@ class E {
|
|
|
404
404
|
* @returns すべての初期化処理が完了するPromise
|
|
405
405
|
*/
|
|
406
406
|
static async reset(t) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
]), await
|
|
407
|
+
y.clearValues(t), await Promise.all([
|
|
408
|
+
y.clearMessages(t),
|
|
409
|
+
y.clearEachClones(t)
|
|
410
|
+
]), await T.enqueue(() => {
|
|
411
411
|
const e = t.getTarget();
|
|
412
412
|
if (e instanceof HTMLFormElement)
|
|
413
413
|
e.reset();
|
|
414
414
|
else {
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
417
|
-
const
|
|
418
|
-
|
|
415
|
+
const r = e.parentElement;
|
|
416
|
+
if (r) {
|
|
417
|
+
const i = e.nextElementSibling, s = document.createElement("form");
|
|
418
|
+
s.appendChild(e), s.reset(), r.insertBefore(e, i);
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
}), await N.evaluateAll(t);
|
|
@@ -427,20 +427,20 @@ class E {
|
|
|
427
427
|
* 対象エレメント自体は削除しません。
|
|
428
428
|
*/
|
|
429
429
|
static clearEachClones(t) {
|
|
430
|
-
const e = [],
|
|
431
|
-
if (
|
|
432
|
-
for (const n of
|
|
433
|
-
const a = n.hasAttribute(`${c.prefix}each-before`),
|
|
434
|
-
!a && !
|
|
430
|
+
const e = [], r = (s) => {
|
|
431
|
+
if (s.hasAttribute(`${c.prefix}each`))
|
|
432
|
+
for (const n of s.getChildElementFragments()) {
|
|
433
|
+
const a = n.hasAttribute(`${c.prefix}each-before`), o = n.hasAttribute(`${c.prefix}each-after`);
|
|
434
|
+
!a && !o && e.push(n.remove());
|
|
435
435
|
}
|
|
436
|
-
},
|
|
437
|
-
s
|
|
438
|
-
for (const n of
|
|
439
|
-
|
|
436
|
+
}, i = (s) => {
|
|
437
|
+
r(s);
|
|
438
|
+
for (const n of s.getChildElementFragments())
|
|
439
|
+
i(n);
|
|
440
440
|
};
|
|
441
|
-
|
|
442
|
-
for (const
|
|
443
|
-
|
|
441
|
+
r(t);
|
|
442
|
+
for (const s of t.getChildElementFragments())
|
|
443
|
+
i(s);
|
|
444
444
|
return Promise.all(e).then(() => {
|
|
445
445
|
});
|
|
446
446
|
}
|
|
@@ -452,7 +452,7 @@ class E {
|
|
|
452
452
|
static clearValues(t) {
|
|
453
453
|
t.clearValue();
|
|
454
454
|
for (const e of t.getChildElementFragments())
|
|
455
|
-
|
|
455
|
+
y.clearValues(e);
|
|
456
456
|
}
|
|
457
457
|
/**
|
|
458
458
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -472,11 +472,11 @@ class E {
|
|
|
472
472
|
* @param message 追加するエラーメッセージ]
|
|
473
473
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
474
474
|
*/
|
|
475
|
-
static addErrorMessage(t, e,
|
|
476
|
-
const
|
|
477
|
-
return
|
|
478
|
-
|
|
479
|
-
}),
|
|
475
|
+
static addErrorMessage(t, e, r) {
|
|
476
|
+
const i = [], s = y.findFragmentsByKey(t, e);
|
|
477
|
+
return s.forEach((n) => {
|
|
478
|
+
i.push(M.addErrorMessage(n.getTarget(), r));
|
|
479
|
+
}), s.length === 0 && i.push(M.addErrorMessage(t.getTarget(), r)), Promise.all(i).then(() => {
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
@@ -487,7 +487,7 @@ class E {
|
|
|
487
487
|
* @returns 一致するフラグメントの配列
|
|
488
488
|
*/
|
|
489
489
|
static findFragmentsByKey(t, e) {
|
|
490
|
-
return
|
|
490
|
+
return y.findFragmentByKeyParts(t, e.split("."));
|
|
491
491
|
}
|
|
492
492
|
/**
|
|
493
493
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -498,34 +498,34 @@ class E {
|
|
|
498
498
|
* @returns 一致するフラグメントの配列
|
|
499
499
|
*/
|
|
500
500
|
static findFragmentByKeyParts(t, e) {
|
|
501
|
-
const
|
|
502
|
-
if (e.length == 1 && t.getAttribute("name") ===
|
|
503
|
-
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) ===
|
|
504
|
-
|
|
501
|
+
const r = [], i = e[0];
|
|
502
|
+
if (e.length == 1 && t.getAttribute("name") === i && r.push(t), t.hasAttribute(`${c.prefix}form-object`))
|
|
503
|
+
e.length > 1 && t.getAttribute(`${c.prefix}form-object`) === i && t.getChildElementFragments().forEach((n) => {
|
|
504
|
+
r.push(...y.findFragmentByKeyParts(n, e.slice(1)));
|
|
505
505
|
});
|
|
506
506
|
else if (t.hasAttribute(`${c.prefix}form-list`)) {
|
|
507
507
|
if (e.length > 1) {
|
|
508
|
-
const
|
|
508
|
+
const s = t.getAttribute(`${c.prefix}form-list`), n = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
509
509
|
if (n !== -1 && a !== -1 && n < a) {
|
|
510
|
-
const
|
|
511
|
-
if (
|
|
512
|
-
const
|
|
513
|
-
if (isNaN(
|
|
514
|
-
h.error("Haori", `Invalid index: ${
|
|
510
|
+
const o = i.substring(0, n);
|
|
511
|
+
if (s === o) {
|
|
512
|
+
const g = i.substring(n + 1, a), u = Number(g);
|
|
513
|
+
if (isNaN(u))
|
|
514
|
+
h.error("Haori", `Invalid index: ${i}`);
|
|
515
515
|
else {
|
|
516
|
-
const b = t.getChildElementFragments().filter((
|
|
517
|
-
|
|
518
|
-
...
|
|
516
|
+
const b = t.getChildElementFragments().filter((l) => l.hasAttribute(`${c.prefix}row`));
|
|
517
|
+
u < b.length && r.push(
|
|
518
|
+
...y.findFragmentByKeyParts(b[u], e.slice(1))
|
|
519
519
|
);
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
} else
|
|
525
|
-
t.getChildElementFragments().forEach((
|
|
526
|
-
|
|
525
|
+
t.getChildElementFragments().forEach((s) => {
|
|
526
|
+
r.push(...y.findFragmentByKeyParts(s, e));
|
|
527
527
|
});
|
|
528
|
-
return
|
|
528
|
+
return r;
|
|
529
529
|
}
|
|
530
530
|
/**
|
|
531
531
|
* 対象のフラグメントがフォームフラグメントであればそれを返し、
|
|
@@ -536,11 +536,11 @@ class E {
|
|
|
536
536
|
static getFormFragment(t) {
|
|
537
537
|
if (t.getTarget() instanceof HTMLFormElement)
|
|
538
538
|
return t;
|
|
539
|
-
const
|
|
540
|
-
return
|
|
539
|
+
const r = t.getParent();
|
|
540
|
+
return r ? this.getFormFragment(r) : null;
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
const
|
|
543
|
+
const k = class k {
|
|
544
544
|
/**
|
|
545
545
|
* 式を評価します。
|
|
546
546
|
*
|
|
@@ -554,16 +554,16 @@ const P = class P {
|
|
|
554
554
|
return h.warn("[Haori]", t, "Expression contains dangerous patterns"), null;
|
|
555
555
|
if (this.containsForbiddenKeys(e))
|
|
556
556
|
return h.warn("[Haori]", e, "Binded values contain forbidden keys"), null;
|
|
557
|
-
const
|
|
557
|
+
const r = Object.keys(e).filter(
|
|
558
558
|
(n) => !this.FORBIDDEN_NAMES.includes(n) && !this.STRICT_FORBIDDEN_NAMES.includes(n)
|
|
559
|
-
).sort(),
|
|
560
|
-
let
|
|
561
|
-
if (!
|
|
559
|
+
).sort(), i = `${t}:${r.join(",")}`;
|
|
560
|
+
let s = this.EXPRESSION_CACHE.get(i);
|
|
561
|
+
if (!s) {
|
|
562
562
|
const n = `"use strict";
|
|
563
563
|
${this.assignments};
|
|
564
564
|
return (${t});`;
|
|
565
565
|
try {
|
|
566
|
-
|
|
566
|
+
s = new Function(...r, n), this.EXPRESSION_CACHE.set(i, s);
|
|
567
567
|
} catch (a) {
|
|
568
568
|
return h.error(
|
|
569
569
|
"[Haori]",
|
|
@@ -574,10 +574,10 @@ return (${t});`;
|
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
try {
|
|
577
|
-
const n = [];
|
|
578
|
-
return
|
|
579
|
-
n.push(
|
|
580
|
-
}),
|
|
577
|
+
const n = [], a = this.wrapBoundValues(e);
|
|
578
|
+
return r.forEach((o) => {
|
|
579
|
+
n.push(a[o]);
|
|
580
|
+
}), this.withBlockedPropertyAccess(() => s(...n));
|
|
581
581
|
} catch (n) {
|
|
582
582
|
return h.error("[Haori]", "Expression evaluation error:", t, n), n instanceof ReferenceError ? void 0 : null;
|
|
583
583
|
}
|
|
@@ -589,14 +589,367 @@ return (${t});`;
|
|
|
589
589
|
* @return 危険なパターンが含まれている場合はtrue
|
|
590
590
|
*/
|
|
591
591
|
static containsDangerousPatterns(t) {
|
|
592
|
-
return [
|
|
592
|
+
return this.hasAllowedSyntax(t) ? [
|
|
593
593
|
/\beval\s*\(/,
|
|
594
594
|
// eval(...)
|
|
595
595
|
/\barguments\s*\[/,
|
|
596
596
|
// arguments[...]
|
|
597
597
|
/\barguments\s*\./
|
|
598
598
|
// arguments.xxx
|
|
599
|
-
].some((
|
|
599
|
+
].some((r) => r.test(t)) : !0;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* 許可する式構文かどうかを検証します。
|
|
603
|
+
*
|
|
604
|
+
* @param expression 検証対象の式
|
|
605
|
+
* @returns 許可する構文であればtrue
|
|
606
|
+
*/
|
|
607
|
+
static hasAllowedSyntax(t) {
|
|
608
|
+
const e = this.tokenizeExpression(t);
|
|
609
|
+
if (e === null || e.length === 0)
|
|
610
|
+
return !1;
|
|
611
|
+
const r = [];
|
|
612
|
+
let i = null;
|
|
613
|
+
for (let s = 0; s < e.length; s++) {
|
|
614
|
+
const n = e[s], a = e[s + 1] || null, o = r[r.length - 1] || null;
|
|
615
|
+
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(
|
|
616
|
+
this.decodeStringLiteral(n.value)
|
|
617
|
+
) || n.value === "." && a?.type !== "identifier" || n.value === "?." && a?.type !== "identifier" && a?.value !== "[" && a?.value !== "(")
|
|
618
|
+
return !1;
|
|
619
|
+
switch (n.value) {
|
|
620
|
+
case "(":
|
|
621
|
+
r.push("paren");
|
|
622
|
+
break;
|
|
623
|
+
case ")": {
|
|
624
|
+
if (r.pop() !== "paren")
|
|
625
|
+
return !1;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
case "[": {
|
|
629
|
+
const g = this.startsMemberAccess(i) ? "member" : "array";
|
|
630
|
+
r.push(g);
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
case "]": {
|
|
634
|
+
if (r.pop() === void 0)
|
|
635
|
+
return !1;
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
i = n;
|
|
640
|
+
}
|
|
641
|
+
return r.length === 0;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* 式をトークン列に分解します。
|
|
645
|
+
*
|
|
646
|
+
* @param expression 評価前に検証する式
|
|
647
|
+
* @returns 分解結果。未対応構文を含む場合はnull
|
|
648
|
+
*/
|
|
649
|
+
static tokenizeExpression(t) {
|
|
650
|
+
const e = [], r = [
|
|
651
|
+
"===",
|
|
652
|
+
"!==",
|
|
653
|
+
"...",
|
|
654
|
+
"?.",
|
|
655
|
+
"&&",
|
|
656
|
+
"||",
|
|
657
|
+
">=",
|
|
658
|
+
"<=",
|
|
659
|
+
"==",
|
|
660
|
+
"!=",
|
|
661
|
+
"=>"
|
|
662
|
+
], i = /* @__PURE__ */ new Set([
|
|
663
|
+
"(",
|
|
664
|
+
")",
|
|
665
|
+
"[",
|
|
666
|
+
"]",
|
|
667
|
+
".",
|
|
668
|
+
",",
|
|
669
|
+
"?",
|
|
670
|
+
":",
|
|
671
|
+
"+",
|
|
672
|
+
"-",
|
|
673
|
+
"*",
|
|
674
|
+
"/",
|
|
675
|
+
"%",
|
|
676
|
+
"!",
|
|
677
|
+
">",
|
|
678
|
+
"<"
|
|
679
|
+
]);
|
|
680
|
+
let s = 0;
|
|
681
|
+
for (; s < t.length; ) {
|
|
682
|
+
const n = t[s];
|
|
683
|
+
if (/\s/.test(n)) {
|
|
684
|
+
s += 1;
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
if (n === "/" && (t[s + 1] === "/" || t[s + 1] === "*"))
|
|
688
|
+
return null;
|
|
689
|
+
if (n === '"' || n === "'") {
|
|
690
|
+
const o = this.readStringToken(t, s);
|
|
691
|
+
if (o === null)
|
|
692
|
+
return null;
|
|
693
|
+
e.push(o.token), s = o.nextIndex;
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
const a = r.find(
|
|
697
|
+
(o) => t.startsWith(o, s)
|
|
698
|
+
);
|
|
699
|
+
if (a) {
|
|
700
|
+
e.push({ type: "operator", value: a, position: s }), s += a.length;
|
|
701
|
+
continue;
|
|
702
|
+
}
|
|
703
|
+
if (/[0-9]/.test(n)) {
|
|
704
|
+
const o = this.readNumberToken(t, s);
|
|
705
|
+
e.push(o.token), s = o.nextIndex;
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
if (/[A-Za-z_$]/.test(n)) {
|
|
709
|
+
const o = this.readIdentifierToken(t, s);
|
|
710
|
+
e.push(o.token), s = o.nextIndex;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (i.has(n)) {
|
|
714
|
+
e.push({ type: "operator", value: n, position: s }), s += 1;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
return null;
|
|
718
|
+
}
|
|
719
|
+
return e;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* 文字列リテラルを読み取ります。
|
|
723
|
+
*
|
|
724
|
+
* @param expression 式全体
|
|
725
|
+
* @param start 開始位置
|
|
726
|
+
* @returns トークンと次の位置
|
|
727
|
+
*/
|
|
728
|
+
static readStringToken(t, e) {
|
|
729
|
+
const r = t[e];
|
|
730
|
+
let i = e + 1;
|
|
731
|
+
for (; i < t.length; ) {
|
|
732
|
+
const s = t[i];
|
|
733
|
+
if (s === "\\") {
|
|
734
|
+
i += 2;
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
if (s === r)
|
|
738
|
+
return {
|
|
739
|
+
token: {
|
|
740
|
+
type: "string",
|
|
741
|
+
value: t.slice(e, i + 1),
|
|
742
|
+
position: e
|
|
743
|
+
},
|
|
744
|
+
nextIndex: i + 1
|
|
745
|
+
};
|
|
746
|
+
i += 1;
|
|
747
|
+
}
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* 数値リテラルを読み取ります。
|
|
752
|
+
*
|
|
753
|
+
* @param expression 式全体
|
|
754
|
+
* @param start 開始位置
|
|
755
|
+
* @returns トークンと次の位置
|
|
756
|
+
*/
|
|
757
|
+
static readNumberToken(t, e) {
|
|
758
|
+
let r = e;
|
|
759
|
+
for (; r < t.length && /[0-9_]/.test(t[r]); )
|
|
760
|
+
r += 1;
|
|
761
|
+
if (t[r] === ".")
|
|
762
|
+
for (r += 1; r < t.length && /[0-9_]/.test(t[r]); )
|
|
763
|
+
r += 1;
|
|
764
|
+
return {
|
|
765
|
+
token: {
|
|
766
|
+
type: "number",
|
|
767
|
+
value: t.slice(e, r),
|
|
768
|
+
position: e
|
|
769
|
+
},
|
|
770
|
+
nextIndex: r
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* 識別子を読み取ります。
|
|
775
|
+
*
|
|
776
|
+
* @param expression 式全体
|
|
777
|
+
* @param start 開始位置
|
|
778
|
+
* @returns トークンと次の位置
|
|
779
|
+
*/
|
|
780
|
+
static readIdentifierToken(t, e) {
|
|
781
|
+
let r = e;
|
|
782
|
+
for (; r < t.length && /[A-Za-z0-9_$]/.test(t[r]); )
|
|
783
|
+
r += 1;
|
|
784
|
+
return {
|
|
785
|
+
token: {
|
|
786
|
+
type: "identifier",
|
|
787
|
+
value: t.slice(e, r),
|
|
788
|
+
position: e
|
|
789
|
+
},
|
|
790
|
+
nextIndex: r
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* 角括弧がメンバーアクセスかどうかを判定します。
|
|
795
|
+
*
|
|
796
|
+
* @param previous 直前のトークン
|
|
797
|
+
* @returns メンバーアクセスであればtrue
|
|
798
|
+
*/
|
|
799
|
+
static startsMemberAccess(t) {
|
|
800
|
+
return t === null ? !1 : t.type === "identifier" || t.type === "number" ? !0 : t.value === ")" || t.value === "]" || t.value === "?.";
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* 文字列リテラルをプレーン文字列へ変換します。
|
|
804
|
+
*
|
|
805
|
+
* @param literal 文字列リテラル
|
|
806
|
+
* @returns デコード後の文字列
|
|
807
|
+
*/
|
|
808
|
+
static decodeStringLiteral(t) {
|
|
809
|
+
return t.slice(1, -1).replace(
|
|
810
|
+
/\\u([0-9a-fA-F]{4})/g,
|
|
811
|
+
(e, r) => String.fromCharCode(parseInt(r, 16))
|
|
812
|
+
).replace(
|
|
813
|
+
/\\x([0-9a-fA-F]{2})/g,
|
|
814
|
+
(e, r) => String.fromCharCode(parseInt(r, 16))
|
|
815
|
+
).replace(/\\(["'\\bfnrtv0])/g, (e, r) => {
|
|
816
|
+
switch (r) {
|
|
817
|
+
case "b":
|
|
818
|
+
return "\b";
|
|
819
|
+
case "f":
|
|
820
|
+
return "\f";
|
|
821
|
+
case "n":
|
|
822
|
+
return `
|
|
823
|
+
`;
|
|
824
|
+
case "r":
|
|
825
|
+
return "\r";
|
|
826
|
+
case "t":
|
|
827
|
+
return " ";
|
|
828
|
+
case "v":
|
|
829
|
+
return "\v";
|
|
830
|
+
case "0":
|
|
831
|
+
return "\0";
|
|
832
|
+
default:
|
|
833
|
+
return r;
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* バインド値を安全なProxyでラップします。
|
|
839
|
+
*
|
|
840
|
+
* @param bindedValues バインド値
|
|
841
|
+
* @returns ラップ済みのバインド値
|
|
842
|
+
*/
|
|
843
|
+
static wrapBoundValues(t) {
|
|
844
|
+
const e = /* @__PURE__ */ new WeakMap(), r = {};
|
|
845
|
+
return Object.entries(t).forEach(([i, s]) => {
|
|
846
|
+
r[i] = this.wrapBoundValue(s, e);
|
|
847
|
+
}), r;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* 危険なプロパティアクセスを防ぐために値を再帰的にラップします。
|
|
851
|
+
*
|
|
852
|
+
* @param value ラップ対象の値
|
|
853
|
+
* @param cache 既存Proxyのキャッシュ
|
|
854
|
+
* @returns ラップ済みの値
|
|
855
|
+
*/
|
|
856
|
+
static wrapBoundValue(t, e) {
|
|
857
|
+
if (!this.shouldWrapValue(t))
|
|
858
|
+
return t;
|
|
859
|
+
const r = t, i = e.get(r);
|
|
860
|
+
if (i !== void 0)
|
|
861
|
+
return i;
|
|
862
|
+
const s = new Proxy(r, {
|
|
863
|
+
get: (n, a, o) => {
|
|
864
|
+
if (typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a))
|
|
865
|
+
return;
|
|
866
|
+
const g = Reflect.get(n, a, o);
|
|
867
|
+
return typeof a == "symbol" ? g : this.wrapBoundValue(
|
|
868
|
+
g,
|
|
869
|
+
e
|
|
870
|
+
);
|
|
871
|
+
},
|
|
872
|
+
has: (n, a) => typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a) ? !1 : Reflect.has(n, a),
|
|
873
|
+
getOwnPropertyDescriptor: (n, a) => {
|
|
874
|
+
if (!(typeof a == "string" && this.FORBIDDEN_PROPERTY_NAMES.has(a)))
|
|
875
|
+
return Reflect.getOwnPropertyDescriptor(n, a);
|
|
876
|
+
},
|
|
877
|
+
apply: (n, a, o) => {
|
|
878
|
+
const g = Reflect.apply(
|
|
879
|
+
n,
|
|
880
|
+
a,
|
|
881
|
+
o
|
|
882
|
+
);
|
|
883
|
+
return this.isIteratorLike(g) ? g : this.wrapBoundValue(g, e);
|
|
884
|
+
},
|
|
885
|
+
construct: (n, a, o) => this.wrapBoundValue(
|
|
886
|
+
Reflect.construct(
|
|
887
|
+
n,
|
|
888
|
+
a,
|
|
889
|
+
o
|
|
890
|
+
),
|
|
891
|
+
e
|
|
892
|
+
)
|
|
893
|
+
});
|
|
894
|
+
return e.set(r, s), s;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Proxy ラップ対象の値かどうかを判定します。
|
|
898
|
+
*
|
|
899
|
+
* @param value 判定対象
|
|
900
|
+
* @returns ラップ対象であればtrue
|
|
901
|
+
*/
|
|
902
|
+
static shouldWrapValue(t) {
|
|
903
|
+
if (typeof t == "function")
|
|
904
|
+
return !0;
|
|
905
|
+
if (t === null || typeof t != "object")
|
|
906
|
+
return !1;
|
|
907
|
+
if (Array.isArray(t))
|
|
908
|
+
return !0;
|
|
909
|
+
const e = Object.getPrototypeOf(t);
|
|
910
|
+
return e === Object.prototype || e === null;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* 評価中のみ prototype 系プロパティへの生アクセスを抑止します。
|
|
914
|
+
*
|
|
915
|
+
* @param callback 実行する処理
|
|
916
|
+
* @returns 処理結果
|
|
917
|
+
*/
|
|
918
|
+
static withBlockedPropertyAccess(t) {
|
|
919
|
+
const r = [
|
|
920
|
+
{ target: Object.prototype, property: "constructor" },
|
|
921
|
+
{ target: Function.prototype, property: "constructor" },
|
|
922
|
+
{ target: Object.prototype, property: "__proto__" }
|
|
923
|
+
].map((i) => ({
|
|
924
|
+
...i,
|
|
925
|
+
descriptor: Object.getOwnPropertyDescriptor(i.target, i.property)
|
|
926
|
+
})).filter((i) => i.descriptor?.configurable === !0);
|
|
927
|
+
r.forEach(({ target: i, property: s }) => {
|
|
928
|
+
Object.defineProperty(i, s, {
|
|
929
|
+
configurable: !0,
|
|
930
|
+
enumerable: !1,
|
|
931
|
+
get: () => {
|
|
932
|
+
},
|
|
933
|
+
set: () => {
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
try {
|
|
938
|
+
return t();
|
|
939
|
+
} finally {
|
|
940
|
+
r.forEach(({ target: i, property: s, descriptor: n }) => {
|
|
941
|
+
n !== void 0 && Object.defineProperty(i, s, n);
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* イテレータ互換オブジェクトかどうかを判定します。
|
|
947
|
+
*
|
|
948
|
+
* @param value 判定対象
|
|
949
|
+
* @returns イテレータ互換であればtrue
|
|
950
|
+
*/
|
|
951
|
+
static isIteratorLike(t) {
|
|
952
|
+
return t === null || typeof t != "object" ? !1 : typeof t.next == "function";
|
|
600
953
|
}
|
|
601
954
|
/**
|
|
602
955
|
* valuesオブジェクトに禁止識別子が含まれていないか再帰的にチェックします。
|
|
@@ -613,7 +966,7 @@ return (${t});`;
|
|
|
613
966
|
return !1;
|
|
614
967
|
}
|
|
615
968
|
};
|
|
616
|
-
|
|
969
|
+
k.FORBIDDEN_NAMES = [
|
|
617
970
|
// グローバルオブジェクト
|
|
618
971
|
"window",
|
|
619
972
|
"self",
|
|
@@ -631,6 +984,7 @@ P.FORBIDDEN_NAMES = [
|
|
|
631
984
|
"prompt",
|
|
632
985
|
"fetch",
|
|
633
986
|
"XMLHttpRequest",
|
|
987
|
+
"Reflect",
|
|
634
988
|
// 脱出経路・プロトタイプ
|
|
635
989
|
"constructor",
|
|
636
990
|
"__proto__",
|
|
@@ -644,38 +998,76 @@ P.FORBIDDEN_NAMES = [
|
|
|
644
998
|
"sessionStorage",
|
|
645
999
|
"IndexedDB",
|
|
646
1000
|
"history"
|
|
647
|
-
],
|
|
1001
|
+
], k.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], k.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1002
|
+
"constructor",
|
|
1003
|
+
"__proto__",
|
|
1004
|
+
"prototype"
|
|
1005
|
+
]), k.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1006
|
+
"await",
|
|
1007
|
+
"break",
|
|
1008
|
+
"case",
|
|
1009
|
+
"catch",
|
|
1010
|
+
"class",
|
|
1011
|
+
"const",
|
|
1012
|
+
"continue",
|
|
1013
|
+
"debugger",
|
|
1014
|
+
"default",
|
|
1015
|
+
"delete",
|
|
1016
|
+
"do",
|
|
1017
|
+
"else",
|
|
1018
|
+
"export",
|
|
1019
|
+
"finally",
|
|
1020
|
+
"for",
|
|
1021
|
+
"function",
|
|
1022
|
+
"if",
|
|
1023
|
+
"import",
|
|
1024
|
+
"in",
|
|
1025
|
+
"instanceof",
|
|
1026
|
+
"let",
|
|
1027
|
+
"new",
|
|
1028
|
+
"return",
|
|
1029
|
+
"switch",
|
|
1030
|
+
"this",
|
|
1031
|
+
"throw",
|
|
1032
|
+
"try",
|
|
1033
|
+
"typeof",
|
|
1034
|
+
"var",
|
|
1035
|
+
"void",
|
|
1036
|
+
"while",
|
|
1037
|
+
"with",
|
|
1038
|
+
"yield"
|
|
1039
|
+
]), k.EXPRESSION_CACHE = /* @__PURE__ */ new Map(), (() => {
|
|
648
1040
|
const t = [];
|
|
649
|
-
|
|
1041
|
+
k.FORBIDDEN_NAMES.forEach((e) => {
|
|
650
1042
|
t.push(`const ${e} = undefined`);
|
|
651
|
-
}),
|
|
1043
|
+
}), k.assignments = t.join(`;
|
|
652
1044
|
`);
|
|
653
1045
|
})();
|
|
654
|
-
let
|
|
655
|
-
const
|
|
1046
|
+
let H = k;
|
|
1047
|
+
const P = class P {
|
|
656
1048
|
/**
|
|
657
1049
|
* フラグメントのコンストラクタ。
|
|
658
1050
|
*
|
|
659
1051
|
* @param target 対象ノード
|
|
660
1052
|
*/
|
|
661
1053
|
constructor(t) {
|
|
662
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t,
|
|
1054
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = t, P.FRAGMENT_CACHE.set(t, this);
|
|
663
1055
|
}
|
|
664
1056
|
static get(t) {
|
|
665
1057
|
if (t == null)
|
|
666
1058
|
return null;
|
|
667
|
-
if (
|
|
668
|
-
return
|
|
1059
|
+
if (P.FRAGMENT_CACHE.has(t))
|
|
1060
|
+
return P.FRAGMENT_CACHE.get(t);
|
|
669
1061
|
let e;
|
|
670
1062
|
switch (t.nodeType) {
|
|
671
1063
|
case Node.ELEMENT_NODE:
|
|
672
|
-
e = new
|
|
1064
|
+
e = new S(t);
|
|
673
1065
|
break;
|
|
674
1066
|
case Node.TEXT_NODE:
|
|
675
1067
|
e = new j(t);
|
|
676
1068
|
break;
|
|
677
1069
|
case Node.COMMENT_NODE:
|
|
678
|
-
e = new
|
|
1070
|
+
e = new K(t);
|
|
679
1071
|
break;
|
|
680
1072
|
default:
|
|
681
1073
|
return h.warn("[Haori]", "Unsupported node type:", t.nodeType), null;
|
|
@@ -700,7 +1092,7 @@ const R = class R {
|
|
|
700
1092
|
return Promise.resolve();
|
|
701
1093
|
if (this.parent) {
|
|
702
1094
|
const t = this.parent, e = t.skipMutationNodes;
|
|
703
|
-
return
|
|
1095
|
+
return T.enqueue(() => {
|
|
704
1096
|
t.skipMutationNodes = !0, this.target.parentNode === t.getTarget() && t.getTarget().removeChild(this.target), this.mounted = !1;
|
|
705
1097
|
}).finally(() => {
|
|
706
1098
|
t.skipMutationNodes = e;
|
|
@@ -708,7 +1100,7 @@ const R = class R {
|
|
|
708
1100
|
} else {
|
|
709
1101
|
const t = this.target.parentNode;
|
|
710
1102
|
if (t)
|
|
711
|
-
return
|
|
1103
|
+
return T.enqueue(() => {
|
|
712
1104
|
this.target.parentNode === t && t.removeChild(this.target), this.mounted = !1;
|
|
713
1105
|
});
|
|
714
1106
|
this.mounted = !1;
|
|
@@ -725,7 +1117,7 @@ const R = class R {
|
|
|
725
1117
|
return Promise.resolve();
|
|
726
1118
|
if (this.parent) {
|
|
727
1119
|
const t = this.parent, e = t.skipMutationNodes;
|
|
728
|
-
return
|
|
1120
|
+
return T.enqueue(() => {
|
|
729
1121
|
t.skipMutationNodes = !0, this.target.parentNode !== t.getTarget() && t.getTarget().appendChild(this.target), this.mounted = !0;
|
|
730
1122
|
}).finally(() => {
|
|
731
1123
|
t.skipMutationNodes = e;
|
|
@@ -756,7 +1148,7 @@ const R = class R {
|
|
|
756
1148
|
* @return 除去のPromise
|
|
757
1149
|
*/
|
|
758
1150
|
remove(t = !0) {
|
|
759
|
-
return this.parent && this.parent.removeChild(this),
|
|
1151
|
+
return this.parent && this.parent.removeChild(this), P.FRAGMENT_CACHE.delete(this.target), t ? this.unmount() : Promise.resolve();
|
|
760
1152
|
}
|
|
761
1153
|
/**
|
|
762
1154
|
* 対象ノードを取得します。
|
|
@@ -783,9 +1175,9 @@ const R = class R {
|
|
|
783
1175
|
this.parent = t;
|
|
784
1176
|
}
|
|
785
1177
|
};
|
|
786
|
-
|
|
787
|
-
let A =
|
|
788
|
-
class
|
|
1178
|
+
P.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1179
|
+
let A = P;
|
|
1180
|
+
class S extends A {
|
|
789
1181
|
/**
|
|
790
1182
|
* エレメントフラグメントのコンストラクタ。
|
|
791
1183
|
* アトリビュートや子フラグメントの作成も行います。
|
|
@@ -809,14 +1201,14 @@ class F extends A {
|
|
|
809
1201
|
"time",
|
|
810
1202
|
"week"
|
|
811
1203
|
], 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) => {
|
|
812
|
-
const
|
|
813
|
-
if (
|
|
814
|
-
const
|
|
815
|
-
this.attributeMap.set(e,
|
|
1204
|
+
const r = t.getAttribute(e);
|
|
1205
|
+
if (r !== null && !this.attributeMap.has(e)) {
|
|
1206
|
+
const i = new L(e, r);
|
|
1207
|
+
this.attributeMap.set(e, i);
|
|
816
1208
|
}
|
|
817
1209
|
}), t.childNodes.forEach((e) => {
|
|
818
|
-
const
|
|
819
|
-
|
|
1210
|
+
const r = A.get(e);
|
|
1211
|
+
r.setParent(this), this.children.push(r);
|
|
820
1212
|
});
|
|
821
1213
|
}
|
|
822
1214
|
/**
|
|
@@ -834,7 +1226,7 @@ class F extends A {
|
|
|
834
1226
|
*/
|
|
835
1227
|
getChildElementFragments() {
|
|
836
1228
|
return this.children.filter(
|
|
837
|
-
(t) => t instanceof
|
|
1229
|
+
(t) => t instanceof S
|
|
838
1230
|
);
|
|
839
1231
|
}
|
|
840
1232
|
/**
|
|
@@ -866,12 +1258,12 @@ class F extends A {
|
|
|
866
1258
|
* @returns クローンされたフラグメント
|
|
867
1259
|
*/
|
|
868
1260
|
clone() {
|
|
869
|
-
const t = new
|
|
1261
|
+
const t = new S(
|
|
870
1262
|
this.target.cloneNode(!1)
|
|
871
1263
|
);
|
|
872
1264
|
return this.children.forEach((e) => {
|
|
873
|
-
const
|
|
874
|
-
t.getTarget().appendChild(
|
|
1265
|
+
const r = e.clone();
|
|
1266
|
+
t.getTarget().appendChild(r.getTarget()), t.pushChild(r);
|
|
875
1267
|
}), t.mounted = !1, t.bindingData = this.bindingData, t.clearBindingDataCache(), t.visible = this.visible, t.display = this.display, t.template = this.template, t;
|
|
876
1268
|
}
|
|
877
1269
|
/**
|
|
@@ -882,8 +1274,8 @@ class F extends A {
|
|
|
882
1274
|
*/
|
|
883
1275
|
remove(t = !0) {
|
|
884
1276
|
const e = [];
|
|
885
|
-
return this.children.forEach((
|
|
886
|
-
e.push(
|
|
1277
|
+
return this.children.forEach((r) => {
|
|
1278
|
+
e.push(r.remove(!1));
|
|
887
1279
|
}), this.children.length = 0, this.attributeMap.clear(), this.bindingData = null, this.bindingDataCache = null, this.template && (e.push(this.template.remove(!1)), this.template = null), e.push(super.remove(t)), Promise.all(e).then(() => {
|
|
888
1280
|
});
|
|
889
1281
|
}
|
|
@@ -924,7 +1316,7 @@ class F extends A {
|
|
|
924
1316
|
*/
|
|
925
1317
|
clearBindingDataCache() {
|
|
926
1318
|
this.bindingDataCache = null, this.children.forEach((t) => {
|
|
927
|
-
t instanceof
|
|
1319
|
+
t instanceof S && t.clearBindingDataCache();
|
|
928
1320
|
});
|
|
929
1321
|
}
|
|
930
1322
|
/**
|
|
@@ -971,14 +1363,14 @@ class F extends A {
|
|
|
971
1363
|
return Promise.resolve();
|
|
972
1364
|
const e = this.getTarget();
|
|
973
1365
|
if (e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio")) {
|
|
974
|
-
const
|
|
975
|
-
let
|
|
976
|
-
return
|
|
977
|
-
e.checked =
|
|
1366
|
+
const r = this.getAttribute("value");
|
|
1367
|
+
let i;
|
|
1368
|
+
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, T.enqueue(() => {
|
|
1369
|
+
e.checked = i, e.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
978
1370
|
}).finally(() => {
|
|
979
1371
|
this.skipChangeValue = !1;
|
|
980
1372
|
}));
|
|
981
|
-
} else return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0,
|
|
1373
|
+
} else return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? (this.value = t, this.skipChangeValue = !0, T.enqueue(() => {
|
|
982
1374
|
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 }));
|
|
983
1375
|
}).finally(() => {
|
|
984
1376
|
this.skipChangeValue = !1;
|
|
@@ -1036,15 +1428,15 @@ class F extends A {
|
|
|
1036
1428
|
return Promise.resolve();
|
|
1037
1429
|
if (e === null)
|
|
1038
1430
|
return this.removeAttribute(t);
|
|
1039
|
-
const
|
|
1040
|
-
this.attributeMap.set(t,
|
|
1041
|
-
const
|
|
1042
|
-
return
|
|
1043
|
-
if (
|
|
1044
|
-
|
|
1431
|
+
const r = new L(t, e);
|
|
1432
|
+
this.attributeMap.set(t, r), this.skipMutationAttributes = !0;
|
|
1433
|
+
const i = this.getTarget(), s = r.isForceEvaluation() ? e : this.getAttribute(t);
|
|
1434
|
+
return T.enqueue(() => {
|
|
1435
|
+
if (s === null || s === !1)
|
|
1436
|
+
i.removeAttribute(t);
|
|
1045
1437
|
else {
|
|
1046
|
-
const n = String(
|
|
1047
|
-
|
|
1438
|
+
const n = String(s);
|
|
1439
|
+
i.getAttribute(t) !== n && i.setAttribute(t, n);
|
|
1048
1440
|
}
|
|
1049
1441
|
}).finally(() => {
|
|
1050
1442
|
this.skipMutationAttributes = !1;
|
|
@@ -1061,7 +1453,7 @@ class F extends A {
|
|
|
1061
1453
|
return Promise.resolve();
|
|
1062
1454
|
this.attributeMap.delete(t), this.skipMutationAttributes = !0;
|
|
1063
1455
|
const e = this.getTarget();
|
|
1064
|
-
return
|
|
1456
|
+
return T.enqueue(() => {
|
|
1065
1457
|
e.removeAttribute(t);
|
|
1066
1458
|
}).finally(() => {
|
|
1067
1459
|
this.skipMutationAttributes = !1;
|
|
@@ -1078,8 +1470,8 @@ class F extends A {
|
|
|
1078
1470
|
const e = this.attributeMap.get(t);
|
|
1079
1471
|
if (e === void 0)
|
|
1080
1472
|
return null;
|
|
1081
|
-
const
|
|
1082
|
-
return
|
|
1473
|
+
const r = e.evaluate(this.getBindingData());
|
|
1474
|
+
return r.length === 1 ? r[0] : $.joinEvaluateResults(r);
|
|
1083
1475
|
}
|
|
1084
1476
|
/**
|
|
1085
1477
|
* 属性の生の値を取得します。
|
|
@@ -1108,6 +1500,30 @@ class F extends A {
|
|
|
1108
1500
|
hasAttribute(t) {
|
|
1109
1501
|
return this.attributeMap.has(t);
|
|
1110
1502
|
}
|
|
1503
|
+
/**
|
|
1504
|
+
* DOM上の順序から、参照フラグメントに対応する children 配列の挿入位置を推定します。
|
|
1505
|
+
*
|
|
1506
|
+
* @param referenceChild 参照フラグメント
|
|
1507
|
+
* @param insertAfter 参照位置の後ろに挿入するかどうか
|
|
1508
|
+
* @returns 挿入位置。解決できない場合はnull
|
|
1509
|
+
*/
|
|
1510
|
+
resolveInsertionPointFromDom(t, e) {
|
|
1511
|
+
const r = t.getTarget();
|
|
1512
|
+
if (r.parentNode !== this.target)
|
|
1513
|
+
return null;
|
|
1514
|
+
const i = e ? r.nextSibling : r;
|
|
1515
|
+
let s = e ? r.nextSibling : r;
|
|
1516
|
+
for (; s !== null; ) {
|
|
1517
|
+
const n = A.get(s);
|
|
1518
|
+
if (n !== null) {
|
|
1519
|
+
const a = this.children.indexOf(n);
|
|
1520
|
+
if (a !== -1)
|
|
1521
|
+
return { index: a, referenceNode: i };
|
|
1522
|
+
}
|
|
1523
|
+
s = s.nextSibling;
|
|
1524
|
+
}
|
|
1525
|
+
return { index: this.children.length, referenceNode: i };
|
|
1526
|
+
}
|
|
1111
1527
|
/**
|
|
1112
1528
|
* 子ノードを参照ノードの前に挿入します。
|
|
1113
1529
|
* 参照ノードがnullの場合、親の最後に追加されます。
|
|
@@ -1116,40 +1532,46 @@ class F extends A {
|
|
|
1116
1532
|
* @param referenceChild 参照ノード
|
|
1117
1533
|
* @return 挿入のPromise
|
|
1118
1534
|
*/
|
|
1119
|
-
insertBefore(t, e) {
|
|
1535
|
+
insertBefore(t, e, r) {
|
|
1120
1536
|
if (this.skipMutationNodes)
|
|
1121
1537
|
return Promise.resolve();
|
|
1122
1538
|
if (t === this)
|
|
1123
1539
|
return h.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
1124
|
-
const
|
|
1125
|
-
let
|
|
1126
|
-
for (;
|
|
1127
|
-
|
|
1128
|
-
if (
|
|
1540
|
+
const i = /* @__PURE__ */ new Set();
|
|
1541
|
+
let s = this.parent;
|
|
1542
|
+
for (; s; )
|
|
1543
|
+
i.add(s), s = s.getParent();
|
|
1544
|
+
if (i.has(t))
|
|
1129
1545
|
return h.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
1130
|
-
const
|
|
1131
|
-
let
|
|
1132
|
-
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1546
|
+
const n = t.getParent() === this;
|
|
1547
|
+
let a = -1, o = -1;
|
|
1548
|
+
n && (a = this.children.indexOf(t), e !== null && (o = this.children.indexOf(e)));
|
|
1549
|
+
const g = t.getParent();
|
|
1550
|
+
g !== null && g.removeChild(t);
|
|
1551
|
+
let u = r === void 0 ? e?.getTarget() || null : r;
|
|
1552
|
+
if (e === null)
|
|
1135
1553
|
this.children.push(t);
|
|
1136
1554
|
else {
|
|
1137
1555
|
let l;
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1556
|
+
if (n ? a !== -1 && a < o ? l = o - 1 : l = o : l = this.children.indexOf(e), l === -1) {
|
|
1557
|
+
const f = this.resolveInsertionPointFromDom(
|
|
1558
|
+
e,
|
|
1559
|
+
!1
|
|
1560
|
+
);
|
|
1561
|
+
f === null ? (h.warn(
|
|
1562
|
+
"[Haori]",
|
|
1563
|
+
"Reference child not found in children.",
|
|
1564
|
+
e
|
|
1565
|
+
), this.children.push(t)) : (this.children.splice(f.index, 0, t), u = f.referenceNode);
|
|
1566
|
+
} else
|
|
1567
|
+
this.children.splice(l, 0, t);
|
|
1143
1568
|
}
|
|
1144
1569
|
t.setParent(this), t.setMounted(this.mounted);
|
|
1145
|
-
const
|
|
1146
|
-
return this.skipMutationNodes = !0,
|
|
1147
|
-
this.target.insertBefore(
|
|
1148
|
-
t.getTarget(),
|
|
1149
|
-
e?.getTarget() || null
|
|
1150
|
-
);
|
|
1570
|
+
const b = this.skipMutationNodes;
|
|
1571
|
+
return this.skipMutationNodes = !0, T.enqueue(() => {
|
|
1572
|
+
this.target.insertBefore(t.getTarget(), u);
|
|
1151
1573
|
}).finally(() => {
|
|
1152
|
-
this.skipMutationNodes =
|
|
1574
|
+
this.skipMutationNodes = b;
|
|
1153
1575
|
});
|
|
1154
1576
|
}
|
|
1155
1577
|
/**
|
|
@@ -1162,12 +1584,23 @@ class F extends A {
|
|
|
1162
1584
|
insertAfter(t, e) {
|
|
1163
1585
|
if (e == null)
|
|
1164
1586
|
return this.insertBefore(t, null);
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1587
|
+
const r = this.children.indexOf(e);
|
|
1588
|
+
if (r === -1) {
|
|
1589
|
+
const i = this.resolveInsertionPointFromDom(
|
|
1590
|
+
e,
|
|
1591
|
+
!0
|
|
1592
|
+
);
|
|
1593
|
+
return i === null ? (h.warn(
|
|
1594
|
+
"[Haori]",
|
|
1595
|
+
"Reference child not found in children.",
|
|
1596
|
+
e
|
|
1597
|
+
), this.insertBefore(t, null)) : this.insertBefore(
|
|
1598
|
+
t,
|
|
1599
|
+
this.children[i.index] || null,
|
|
1600
|
+
i.referenceNode
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
return this.insertBefore(t, this.children[r + 1] || null);
|
|
1171
1604
|
}
|
|
1172
1605
|
/**
|
|
1173
1606
|
* 前のエレメントフラグメントを取得します。
|
|
@@ -1179,8 +1612,8 @@ class F extends A {
|
|
|
1179
1612
|
const t = this.getParent();
|
|
1180
1613
|
if (t === null)
|
|
1181
1614
|
return null;
|
|
1182
|
-
const e = t.getChildElementFragments(),
|
|
1183
|
-
return
|
|
1615
|
+
const e = t.getChildElementFragments(), r = e.indexOf(this);
|
|
1616
|
+
return r <= 0 ? null : e[r - 1];
|
|
1184
1617
|
}
|
|
1185
1618
|
/**
|
|
1186
1619
|
* 次のエレメントフラグメントを取得します。
|
|
@@ -1192,8 +1625,8 @@ class F extends A {
|
|
|
1192
1625
|
const t = this.getParent();
|
|
1193
1626
|
if (t === null)
|
|
1194
1627
|
return null;
|
|
1195
|
-
const e = t.getChildElementFragments(),
|
|
1196
|
-
return
|
|
1628
|
+
const e = t.getChildElementFragments(), r = e.indexOf(this);
|
|
1629
|
+
return r < 0 || r + 1 >= e.length ? null : e[r + 1];
|
|
1197
1630
|
}
|
|
1198
1631
|
/**
|
|
1199
1632
|
* 表示状態を返します。
|
|
@@ -1277,7 +1710,7 @@ class j extends A {
|
|
|
1277
1710
|
evaluate() {
|
|
1278
1711
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
1279
1712
|
new Error("Parent fragment is required for raw evaluation")
|
|
1280
|
-
) :
|
|
1713
|
+
) : T.enqueue(() => {
|
|
1281
1714
|
this.skipMutation = !0, this.contents.isRawEvaluate ? this.parent.getTarget().innerHTML = this.contents.evaluate(
|
|
1282
1715
|
this.parent.getBindingData()
|
|
1283
1716
|
)[0] : this.contents.isEvaluate ? this.target.textContent = $.joinEvaluateResults(
|
|
@@ -1288,7 +1721,7 @@ class j extends A {
|
|
|
1288
1721
|
});
|
|
1289
1722
|
}
|
|
1290
1723
|
}
|
|
1291
|
-
class
|
|
1724
|
+
class K extends A {
|
|
1292
1725
|
/**
|
|
1293
1726
|
* コメントフラグメントのコンストラクタ。
|
|
1294
1727
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -1304,7 +1737,7 @@ class U extends A {
|
|
|
1304
1737
|
* @returns クローンされたフラグメント
|
|
1305
1738
|
*/
|
|
1306
1739
|
clone() {
|
|
1307
|
-
const t = new
|
|
1740
|
+
const t = new K(this.target.cloneNode(!0));
|
|
1308
1741
|
return t.mounted = !1, t.text = this.text, t;
|
|
1309
1742
|
}
|
|
1310
1743
|
/**
|
|
@@ -1322,14 +1755,14 @@ class U extends A {
|
|
|
1322
1755
|
* @return 更新のPromise
|
|
1323
1756
|
*/
|
|
1324
1757
|
setContent(t) {
|
|
1325
|
-
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t,
|
|
1758
|
+
return this.skipMutation || this.text === t ? Promise.resolve() : (this.text = t, T.enqueue(() => {
|
|
1326
1759
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
1327
1760
|
}).finally(() => {
|
|
1328
1761
|
this.skipMutation = !1;
|
|
1329
1762
|
}));
|
|
1330
1763
|
}
|
|
1331
1764
|
}
|
|
1332
|
-
const
|
|
1765
|
+
const q = class q {
|
|
1333
1766
|
/**
|
|
1334
1767
|
* コンストラクタ。
|
|
1335
1768
|
*
|
|
@@ -1337,11 +1770,11 @@ const V = class V {
|
|
|
1337
1770
|
*/
|
|
1338
1771
|
constructor(t) {
|
|
1339
1772
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = t;
|
|
1340
|
-
const e = [...t.matchAll(
|
|
1341
|
-
let
|
|
1773
|
+
const e = [...t.matchAll(q.PLACEHOLDER_REGEX)];
|
|
1774
|
+
let r = 0, i = !1, s = !1;
|
|
1342
1775
|
for (const n of e) {
|
|
1343
|
-
n.index >
|
|
1344
|
-
text: t.slice(
|
|
1776
|
+
n.index > r && this.contents.push({
|
|
1777
|
+
text: t.slice(r, n.index),
|
|
1345
1778
|
type: 0
|
|
1346
1779
|
/* TEXT */
|
|
1347
1780
|
});
|
|
@@ -1350,13 +1783,13 @@ const V = class V {
|
|
|
1350
1783
|
type: n[1] ? 2 : 1
|
|
1351
1784
|
/* EXPRESSION */
|
|
1352
1785
|
};
|
|
1353
|
-
|
|
1786
|
+
i = !0, s = s || a.type === 2, this.contents.push(a), r = n.index + n[0].length;
|
|
1354
1787
|
}
|
|
1355
|
-
|
|
1356
|
-
text: t.slice(
|
|
1788
|
+
r < t.length && this.contents.push({
|
|
1789
|
+
text: t.slice(r),
|
|
1357
1790
|
type: 0
|
|
1358
1791
|
/* TEXT */
|
|
1359
|
-
}), this.isEvaluate =
|
|
1792
|
+
}), this.isEvaluate = i, this.isRawEvaluate = s, this.checkRawExpressions();
|
|
1360
1793
|
}
|
|
1361
1794
|
/**
|
|
1362
1795
|
* 評価結果を結合して文字列にします。
|
|
@@ -1393,28 +1826,28 @@ const V = class V {
|
|
|
1393
1826
|
*/
|
|
1394
1827
|
evaluate(t) {
|
|
1395
1828
|
if (!this.isEvaluate && !this.isRawEvaluate)
|
|
1396
|
-
return this.contents.map((
|
|
1829
|
+
return this.contents.map((r) => r.text);
|
|
1397
1830
|
const e = [];
|
|
1398
|
-
return this.contents.forEach((
|
|
1831
|
+
return this.contents.forEach((r) => {
|
|
1399
1832
|
try {
|
|
1400
|
-
if (
|
|
1401
|
-
const
|
|
1402
|
-
e.push(
|
|
1833
|
+
if (r.type === 1 || r.type === 2) {
|
|
1834
|
+
const i = H.evaluate(r.text, t);
|
|
1835
|
+
e.push(i);
|
|
1403
1836
|
} else
|
|
1404
|
-
e.push(
|
|
1405
|
-
} catch (
|
|
1837
|
+
e.push(r.text);
|
|
1838
|
+
} catch (i) {
|
|
1406
1839
|
h.error(
|
|
1407
1840
|
"[Haori]",
|
|
1408
|
-
`Error evaluating text expression: ${
|
|
1409
|
-
|
|
1841
|
+
`Error evaluating text expression: ${r.text}`,
|
|
1842
|
+
i
|
|
1410
1843
|
), e.push("");
|
|
1411
1844
|
}
|
|
1412
1845
|
}), e;
|
|
1413
1846
|
}
|
|
1414
1847
|
};
|
|
1415
|
-
|
|
1416
|
-
let $ =
|
|
1417
|
-
const
|
|
1848
|
+
q.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
1849
|
+
let $ = q;
|
|
1850
|
+
const U = class U extends $ {
|
|
1418
1851
|
/**
|
|
1419
1852
|
* コンストラクタ。
|
|
1420
1853
|
*
|
|
@@ -1422,7 +1855,7 @@ const q = class q extends $ {
|
|
|
1422
1855
|
* @param text 属性値
|
|
1423
1856
|
*/
|
|
1424
1857
|
constructor(t, e) {
|
|
1425
|
-
super(e), this.forceEvaluation =
|
|
1858
|
+
super(e), this.forceEvaluation = U.FORCE_EVALUATION_ATTRIBUTES.includes(t);
|
|
1426
1859
|
}
|
|
1427
1860
|
/**
|
|
1428
1861
|
* 強制評価フラグを取得します。
|
|
@@ -1440,20 +1873,20 @@ const q = class q extends $ {
|
|
|
1440
1873
|
*/
|
|
1441
1874
|
evaluate(t) {
|
|
1442
1875
|
if (!this.isEvaluate && !this.forceEvaluation)
|
|
1443
|
-
return this.contents.map((
|
|
1876
|
+
return this.contents.map((r) => r.text);
|
|
1444
1877
|
const e = [];
|
|
1445
|
-
return this.contents.forEach((
|
|
1878
|
+
return this.contents.forEach((r) => {
|
|
1446
1879
|
try {
|
|
1447
|
-
if (this.forceEvaluation &&
|
|
1448
|
-
const
|
|
1449
|
-
e.push(
|
|
1880
|
+
if (this.forceEvaluation && r.type === 0 || r.type === 1 || r.type === 2) {
|
|
1881
|
+
const i = H.evaluate(r.text, t);
|
|
1882
|
+
e.push(i);
|
|
1450
1883
|
} else
|
|
1451
|
-
e.push(
|
|
1452
|
-
} catch (
|
|
1884
|
+
e.push(r.text);
|
|
1885
|
+
} catch (i) {
|
|
1453
1886
|
h.error(
|
|
1454
1887
|
"[Haori]",
|
|
1455
|
-
`Error evaluating attribute expression: ${
|
|
1456
|
-
|
|
1888
|
+
`Error evaluating attribute expression: ${r.text}`,
|
|
1889
|
+
i
|
|
1457
1890
|
), e.push("");
|
|
1458
1891
|
}
|
|
1459
1892
|
}), this.forceEvaluation && e.length > 1 ? (h.error(
|
|
@@ -1463,14 +1896,14 @@ const q = class q extends $ {
|
|
|
1463
1896
|
), [e[0]]) : e;
|
|
1464
1897
|
}
|
|
1465
1898
|
};
|
|
1466
|
-
|
|
1899
|
+
U.FORCE_EVALUATION_ATTRIBUTES = [
|
|
1467
1900
|
"data-if",
|
|
1468
1901
|
"hor-if",
|
|
1469
1902
|
"data-each",
|
|
1470
1903
|
"hor-each"
|
|
1471
1904
|
];
|
|
1472
|
-
let
|
|
1473
|
-
class
|
|
1905
|
+
let L = U;
|
|
1906
|
+
class E {
|
|
1474
1907
|
/**
|
|
1475
1908
|
* カスタムイベントを発火します。
|
|
1476
1909
|
*
|
|
@@ -1479,14 +1912,14 @@ class y {
|
|
|
1479
1912
|
* @param detail イベントの詳細データ
|
|
1480
1913
|
* @param options イベントオプション
|
|
1481
1914
|
*/
|
|
1482
|
-
static dispatch(t, e,
|
|
1483
|
-
const
|
|
1484
|
-
bubbles:
|
|
1485
|
-
cancelable:
|
|
1486
|
-
composed:
|
|
1487
|
-
detail:
|
|
1915
|
+
static dispatch(t, e, r, i) {
|
|
1916
|
+
const s = new CustomEvent(`haori:${e}`, {
|
|
1917
|
+
bubbles: i?.bubbles ?? !0,
|
|
1918
|
+
cancelable: i?.cancelable ?? !1,
|
|
1919
|
+
composed: i?.composed ?? !0,
|
|
1920
|
+
detail: r
|
|
1488
1921
|
});
|
|
1489
|
-
return t.dispatchEvent(
|
|
1922
|
+
return t.dispatchEvent(s);
|
|
1490
1923
|
}
|
|
1491
1924
|
/**
|
|
1492
1925
|
* readyイベントを発火します。
|
|
@@ -1494,7 +1927,7 @@ class y {
|
|
|
1494
1927
|
* @param version ライブラリバージョン
|
|
1495
1928
|
*/
|
|
1496
1929
|
static ready(t) {
|
|
1497
|
-
|
|
1930
|
+
E.dispatch(document, "ready", { version: t });
|
|
1498
1931
|
}
|
|
1499
1932
|
/**
|
|
1500
1933
|
* renderイベントを発火します。
|
|
@@ -1502,7 +1935,7 @@ class y {
|
|
|
1502
1935
|
* @param target 評価対象要素
|
|
1503
1936
|
*/
|
|
1504
1937
|
static render(t) {
|
|
1505
|
-
|
|
1938
|
+
E.dispatch(t, "render", { target: t });
|
|
1506
1939
|
}
|
|
1507
1940
|
/**
|
|
1508
1941
|
* importstartイベントを発火します。
|
|
@@ -1511,7 +1944,7 @@ class y {
|
|
|
1511
1944
|
* @param url インポート対象URL
|
|
1512
1945
|
*/
|
|
1513
1946
|
static importStart(t, e) {
|
|
1514
|
-
|
|
1947
|
+
E.dispatch(t, "importstart", {
|
|
1515
1948
|
url: e,
|
|
1516
1949
|
startedAt: performance.now()
|
|
1517
1950
|
});
|
|
@@ -1524,11 +1957,11 @@ class y {
|
|
|
1524
1957
|
* @param bytes 取得バイト数
|
|
1525
1958
|
* @param startedAt 開始時刻
|
|
1526
1959
|
*/
|
|
1527
|
-
static importEnd(t, e,
|
|
1528
|
-
|
|
1960
|
+
static importEnd(t, e, r, i) {
|
|
1961
|
+
E.dispatch(t, "importend", {
|
|
1529
1962
|
url: e,
|
|
1530
|
-
bytes:
|
|
1531
|
-
durationMs: performance.now() -
|
|
1963
|
+
bytes: r,
|
|
1964
|
+
durationMs: performance.now() - i
|
|
1532
1965
|
});
|
|
1533
1966
|
}
|
|
1534
1967
|
/**
|
|
@@ -1538,8 +1971,8 @@ class y {
|
|
|
1538
1971
|
* @param url インポート対象URL
|
|
1539
1972
|
* @param error エラー内容
|
|
1540
1973
|
*/
|
|
1541
|
-
static importError(t, e,
|
|
1542
|
-
|
|
1974
|
+
static importError(t, e, r) {
|
|
1975
|
+
E.dispatch(t, "importerror", { url: e, error: r });
|
|
1543
1976
|
}
|
|
1544
1977
|
/**
|
|
1545
1978
|
* bindchangeイベントを発火します。
|
|
@@ -1549,17 +1982,17 @@ class y {
|
|
|
1549
1982
|
* @param next 変更後のデータ
|
|
1550
1983
|
* @param reason 変更理由
|
|
1551
1984
|
*/
|
|
1552
|
-
static bindChange(t, e,
|
|
1553
|
-
const
|
|
1554
|
-
for (const
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1985
|
+
static bindChange(t, e, r, i = "other") {
|
|
1986
|
+
const s = [], n = new Set(Object.keys(e || {})), a = new Set(Object.keys(r)), o = /* @__PURE__ */ new Set([...n, ...a]);
|
|
1987
|
+
for (const g of o) {
|
|
1988
|
+
const u = e?.[g], b = r[g];
|
|
1989
|
+
u !== b && s.push(g);
|
|
1557
1990
|
}
|
|
1558
|
-
|
|
1991
|
+
E.dispatch(t, "bindchange", {
|
|
1559
1992
|
previous: e || {},
|
|
1560
|
-
next:
|
|
1561
|
-
changedKeys:
|
|
1562
|
-
reason:
|
|
1993
|
+
next: r,
|
|
1994
|
+
changedKeys: s,
|
|
1995
|
+
reason: i
|
|
1563
1996
|
});
|
|
1564
1997
|
}
|
|
1565
1998
|
/**
|
|
@@ -1570,12 +2003,12 @@ class y {
|
|
|
1570
2003
|
* @param removed 削除された行のキー
|
|
1571
2004
|
* @param order 現在の順序
|
|
1572
2005
|
*/
|
|
1573
|
-
static eachUpdate(t, e,
|
|
1574
|
-
|
|
2006
|
+
static eachUpdate(t, e, r, i) {
|
|
2007
|
+
E.dispatch(t, "eachupdate", {
|
|
1575
2008
|
added: e,
|
|
1576
|
-
removed:
|
|
1577
|
-
order:
|
|
1578
|
-
total:
|
|
2009
|
+
removed: r,
|
|
2010
|
+
order: i,
|
|
2011
|
+
total: i.length
|
|
1579
2012
|
});
|
|
1580
2013
|
}
|
|
1581
2014
|
/**
|
|
@@ -1586,8 +2019,8 @@ class y {
|
|
|
1586
2019
|
* @param index インデックス
|
|
1587
2020
|
* @param item 行データ
|
|
1588
2021
|
*/
|
|
1589
|
-
static rowAdd(t, e,
|
|
1590
|
-
|
|
2022
|
+
static rowAdd(t, e, r, i) {
|
|
2023
|
+
E.dispatch(t, "rowadd", { key: e, index: r, item: i });
|
|
1591
2024
|
}
|
|
1592
2025
|
/**
|
|
1593
2026
|
* rowremoveイベントを発火します。
|
|
@@ -1596,8 +2029,8 @@ class y {
|
|
|
1596
2029
|
* @param key 行キー
|
|
1597
2030
|
* @param index インデックス
|
|
1598
2031
|
*/
|
|
1599
|
-
static rowRemove(t, e,
|
|
1600
|
-
|
|
2032
|
+
static rowRemove(t, e, r) {
|
|
2033
|
+
E.dispatch(t, "rowremove", { key: e, index: r });
|
|
1601
2034
|
}
|
|
1602
2035
|
/**
|
|
1603
2036
|
* rowmoveイベントを発火します。
|
|
@@ -1607,8 +2040,8 @@ class y {
|
|
|
1607
2040
|
* @param from 移動前インデックス
|
|
1608
2041
|
* @param to 移動後インデックス
|
|
1609
2042
|
*/
|
|
1610
|
-
static rowMove(t, e,
|
|
1611
|
-
|
|
2043
|
+
static rowMove(t, e, r, i) {
|
|
2044
|
+
E.dispatch(t, "rowmove", { key: e, from: r, to: i });
|
|
1612
2045
|
}
|
|
1613
2046
|
/**
|
|
1614
2047
|
* showイベントを発火します。
|
|
@@ -1616,7 +2049,7 @@ class y {
|
|
|
1616
2049
|
* @param target data-if要素
|
|
1617
2050
|
*/
|
|
1618
2051
|
static show(t) {
|
|
1619
|
-
|
|
2052
|
+
E.dispatch(t, "show", { visible: !0 });
|
|
1620
2053
|
}
|
|
1621
2054
|
/**
|
|
1622
2055
|
* hideイベントを発火します。
|
|
@@ -1624,7 +2057,7 @@ class y {
|
|
|
1624
2057
|
* @param target data-if要素
|
|
1625
2058
|
*/
|
|
1626
2059
|
static hide(t) {
|
|
1627
|
-
|
|
2060
|
+
E.dispatch(t, "hide", { visible: !1 });
|
|
1628
2061
|
}
|
|
1629
2062
|
/**
|
|
1630
2063
|
* fetchstartイベントを発火します。
|
|
@@ -1634,11 +2067,11 @@ class y {
|
|
|
1634
2067
|
* @param options フェッチオプション
|
|
1635
2068
|
* @param payload 送信データ
|
|
1636
2069
|
*/
|
|
1637
|
-
static fetchStart(t, e,
|
|
1638
|
-
|
|
2070
|
+
static fetchStart(t, e, r, i) {
|
|
2071
|
+
E.dispatch(t, "fetchstart", {
|
|
1639
2072
|
url: e,
|
|
1640
|
-
options:
|
|
1641
|
-
payload:
|
|
2073
|
+
options: r || {},
|
|
2074
|
+
payload: i,
|
|
1642
2075
|
startedAt: performance.now()
|
|
1643
2076
|
});
|
|
1644
2077
|
}
|
|
@@ -1650,11 +2083,11 @@ class y {
|
|
|
1650
2083
|
* @param status HTTPステータス
|
|
1651
2084
|
* @param startedAt 開始時刻
|
|
1652
2085
|
*/
|
|
1653
|
-
static fetchEnd(t, e,
|
|
1654
|
-
|
|
2086
|
+
static fetchEnd(t, e, r, i) {
|
|
2087
|
+
E.dispatch(t, "fetchend", {
|
|
1655
2088
|
url: e,
|
|
1656
|
-
status:
|
|
1657
|
-
durationMs: performance.now() -
|
|
2089
|
+
status: r,
|
|
2090
|
+
durationMs: performance.now() - i
|
|
1658
2091
|
});
|
|
1659
2092
|
}
|
|
1660
2093
|
/**
|
|
@@ -1666,16 +2099,16 @@ class y {
|
|
|
1666
2099
|
* @param status HTTPステータス(存在する場合)
|
|
1667
2100
|
* @param startedAt 開始時刻(存在する場合)
|
|
1668
2101
|
*/
|
|
1669
|
-
static fetchError(t, e,
|
|
1670
|
-
|
|
2102
|
+
static fetchError(t, e, r, i, s) {
|
|
2103
|
+
E.dispatch(t, "fetcherror", {
|
|
1671
2104
|
url: e,
|
|
1672
|
-
status:
|
|
1673
|
-
error:
|
|
1674
|
-
durationMs:
|
|
2105
|
+
status: i,
|
|
2106
|
+
error: r,
|
|
2107
|
+
durationMs: s ? performance.now() - s : void 0
|
|
1675
2108
|
});
|
|
1676
2109
|
}
|
|
1677
2110
|
}
|
|
1678
|
-
class
|
|
2111
|
+
class d {
|
|
1679
2112
|
/**
|
|
1680
2113
|
* イベント属性名を正しく生成します。
|
|
1681
2114
|
* 例: ("click", "fetch") => "data-click-fetch"
|
|
@@ -1683,8 +2116,8 @@ class f {
|
|
|
1683
2116
|
* ("change", "bind-arg") => "data-change-bind-arg"
|
|
1684
2117
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
1685
2118
|
*/
|
|
1686
|
-
static attrName(t, e,
|
|
1687
|
-
return t ? `${c.prefix}${t}-${e}` :
|
|
2119
|
+
static attrName(t, e, r = !1) {
|
|
2120
|
+
return t ? `${c.prefix}${t}-${e}` : r ? `${c.prefix}fetch-${e}` : `${c.prefix}${e}`;
|
|
1688
2121
|
}
|
|
1689
2122
|
/**
|
|
1690
2123
|
* オプションをフラグメントの属性から構築します。
|
|
@@ -1694,103 +2127,103 @@ class f {
|
|
|
1694
2127
|
* @return 構築されたオプション
|
|
1695
2128
|
*/
|
|
1696
2129
|
static buildOptions(t, e) {
|
|
1697
|
-
const
|
|
2130
|
+
const r = {
|
|
1698
2131
|
targetFragment: t
|
|
1699
2132
|
};
|
|
1700
2133
|
if (e) {
|
|
1701
|
-
if (t.hasAttribute(
|
|
1702
|
-
|
|
1703
|
-
)), t.hasAttribute(
|
|
1704
|
-
t.getRawAttribute(
|
|
1705
|
-
)), t.hasAttribute(
|
|
1706
|
-
const
|
|
1707
|
-
|
|
2134
|
+
if (t.hasAttribute(d.attrName(e, "validate")) && (r.valid = !0), t.hasAttribute(d.attrName(e, "confirm")) && (r.confirmMessage = t.getAttribute(
|
|
2135
|
+
d.attrName(e, "confirm")
|
|
2136
|
+
)), t.hasAttribute(d.attrName(e, "data")) && (r.data = N.parseDataBind(
|
|
2137
|
+
t.getRawAttribute(d.attrName(e, "data"))
|
|
2138
|
+
)), t.hasAttribute(d.attrName(e, "form"))) {
|
|
2139
|
+
const l = t.getRawAttribute(
|
|
2140
|
+
d.attrName(e, "form")
|
|
1708
2141
|
);
|
|
1709
|
-
if (
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1712
|
-
A.get(
|
|
2142
|
+
if (l) {
|
|
2143
|
+
const f = document.body.querySelector(l);
|
|
2144
|
+
f !== null ? r.formFragment = y.getFormFragment(
|
|
2145
|
+
A.get(f)
|
|
1713
2146
|
) : h.error(
|
|
1714
2147
|
"Haori",
|
|
1715
|
-
`Form element not found: ${
|
|
2148
|
+
`Form element not found: ${l} (${d.attrName(e, "form")})`
|
|
1716
2149
|
);
|
|
1717
2150
|
} else
|
|
1718
|
-
|
|
1719
|
-
} else e === "change" && (
|
|
2151
|
+
r.formFragment = y.getFormFragment(t);
|
|
2152
|
+
} else e === "change" && (r.formFragment = y.getFormFragment(t));
|
|
1720
2153
|
if (t.hasAttribute(`${c.prefix}${e}-before-run`)) {
|
|
1721
|
-
const
|
|
2154
|
+
const l = t.getRawAttribute(
|
|
1722
2155
|
`${c.prefix}${e}-before-run`
|
|
1723
2156
|
);
|
|
1724
2157
|
try {
|
|
1725
|
-
|
|
2158
|
+
r.beforeCallback = new Function(
|
|
1726
2159
|
"fetchUrl",
|
|
1727
2160
|
"fetchOptions",
|
|
1728
2161
|
`
|
|
1729
2162
|
"use strict";
|
|
1730
|
-
${
|
|
2163
|
+
${l}
|
|
1731
2164
|
`
|
|
1732
2165
|
);
|
|
1733
|
-
} catch (
|
|
1734
|
-
h.error("Haori", `Invalid before script: ${
|
|
2166
|
+
} catch (f) {
|
|
2167
|
+
h.error("Haori", `Invalid before script: ${f}`);
|
|
1735
2168
|
}
|
|
1736
2169
|
}
|
|
1737
2170
|
}
|
|
1738
|
-
const
|
|
1739
|
-
|
|
2171
|
+
const i = d.attrName(e, "fetch"), s = t.hasAttribute(i);
|
|
2172
|
+
s && (r.fetchUrl = t.getAttribute(i));
|
|
1740
2173
|
const n = {};
|
|
1741
2174
|
if (e) {
|
|
1742
|
-
const
|
|
1743
|
-
t.hasAttribute(
|
|
1744
|
-
|
|
2175
|
+
const l = d.attrName(e, "fetch-method");
|
|
2176
|
+
t.hasAttribute(l) && (n.method = t.getAttribute(
|
|
2177
|
+
l
|
|
1745
2178
|
));
|
|
1746
2179
|
} else {
|
|
1747
|
-
const
|
|
1748
|
-
t.hasAttribute(
|
|
1749
|
-
|
|
2180
|
+
const l = d.attrName(null, "method", !0);
|
|
2181
|
+
t.hasAttribute(l) && (n.method = t.getAttribute(
|
|
2182
|
+
l
|
|
1750
2183
|
));
|
|
1751
2184
|
}
|
|
1752
2185
|
if (e) {
|
|
1753
|
-
const
|
|
1754
|
-
if (t.hasAttribute(
|
|
1755
|
-
const
|
|
1756
|
-
|
|
2186
|
+
const l = d.attrName(e, "fetch-headers");
|
|
2187
|
+
if (t.hasAttribute(l)) {
|
|
2188
|
+
const f = t.getRawAttribute(
|
|
2189
|
+
l
|
|
1757
2190
|
);
|
|
1758
2191
|
try {
|
|
1759
|
-
n.headers = N.parseDataBind(
|
|
2192
|
+
n.headers = N.parseDataBind(f);
|
|
1760
2193
|
} catch (p) {
|
|
1761
2194
|
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
1762
2195
|
}
|
|
1763
2196
|
}
|
|
1764
2197
|
} else {
|
|
1765
|
-
const
|
|
2198
|
+
const l = d.attrName(
|
|
1766
2199
|
null,
|
|
1767
2200
|
"headers",
|
|
1768
2201
|
!0
|
|
1769
2202
|
);
|
|
1770
|
-
if (t.hasAttribute(
|
|
1771
|
-
const
|
|
1772
|
-
|
|
2203
|
+
if (t.hasAttribute(l)) {
|
|
2204
|
+
const f = t.getRawAttribute(
|
|
2205
|
+
l
|
|
1773
2206
|
);
|
|
1774
2207
|
try {
|
|
1775
|
-
n.headers = N.parseDataBind(
|
|
2208
|
+
n.headers = N.parseDataBind(f);
|
|
1776
2209
|
} catch (p) {
|
|
1777
2210
|
h.error("Haori", `Invalid fetch headers: ${p}`);
|
|
1778
2211
|
}
|
|
1779
2212
|
}
|
|
1780
2213
|
}
|
|
1781
2214
|
if (e) {
|
|
1782
|
-
const
|
|
2215
|
+
const l = d.attrName(
|
|
1783
2216
|
e,
|
|
1784
2217
|
"fetch-content-type"
|
|
1785
2218
|
);
|
|
1786
|
-
if (t.hasAttribute(
|
|
2219
|
+
if (t.hasAttribute(l))
|
|
1787
2220
|
n.headers = {
|
|
1788
2221
|
...n.headers,
|
|
1789
|
-
"Content-Type": t.getAttribute(
|
|
2222
|
+
"Content-Type": t.getAttribute(l)
|
|
1790
2223
|
};
|
|
1791
2224
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
1792
|
-
let
|
|
1793
|
-
n.headers && typeof n.headers == "object" && (
|
|
2225
|
+
let f = !1;
|
|
2226
|
+
n.headers && typeof n.headers == "object" && (f = "Content-Type" in n.headers), f || (n.headers = {
|
|
1794
2227
|
...n.headers,
|
|
1795
2228
|
"Content-Type": "application/json"
|
|
1796
2229
|
});
|
|
@@ -1799,19 +2232,19 @@ ${o}
|
|
|
1799
2232
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
1800
2233
|
});
|
|
1801
2234
|
} else {
|
|
1802
|
-
const
|
|
2235
|
+
const l = d.attrName(
|
|
1803
2236
|
null,
|
|
1804
2237
|
"content-type",
|
|
1805
2238
|
!0
|
|
1806
2239
|
);
|
|
1807
|
-
if (t.hasAttribute(
|
|
2240
|
+
if (t.hasAttribute(l))
|
|
1808
2241
|
n.headers = {
|
|
1809
2242
|
...n.headers,
|
|
1810
|
-
"Content-Type": t.getAttribute(
|
|
2243
|
+
"Content-Type": t.getAttribute(l)
|
|
1811
2244
|
};
|
|
1812
2245
|
else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
1813
|
-
let
|
|
1814
|
-
n.headers && typeof n.headers == "object" && (
|
|
2246
|
+
let f = !1;
|
|
2247
|
+
n.headers && typeof n.headers == "object" && (f = "Content-Type" in n.headers), f || (n.headers = {
|
|
1815
2248
|
...n.headers,
|
|
1816
2249
|
"Content-Type": "application/json"
|
|
1817
2250
|
});
|
|
@@ -1820,140 +2253,140 @@ ${o}
|
|
|
1820
2253
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
1821
2254
|
});
|
|
1822
2255
|
}
|
|
1823
|
-
Object.keys(n).length > 0 && (
|
|
1824
|
-
const a = e ?
|
|
2256
|
+
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
2257
|
+
const a = e ? d.attrName(e, "bind") : d.attrName(null, "bind", !0);
|
|
1825
2258
|
if (t.hasAttribute(a)) {
|
|
1826
|
-
const
|
|
1827
|
-
if (
|
|
1828
|
-
const
|
|
1829
|
-
|
|
2259
|
+
const l = t.getRawAttribute(a);
|
|
2260
|
+
if (l) {
|
|
2261
|
+
const f = document.body.querySelectorAll(l);
|
|
2262
|
+
f.length > 0 ? (r.bindFragments = [], f.forEach((p) => {
|
|
1830
2263
|
const w = A.get(p);
|
|
1831
|
-
w &&
|
|
2264
|
+
w && r.bindFragments.push(w);
|
|
1832
2265
|
})) : h.error(
|
|
1833
2266
|
"Haori",
|
|
1834
|
-
`Bind element not found: ${
|
|
2267
|
+
`Bind element not found: ${l} (${a})`
|
|
1835
2268
|
);
|
|
1836
2269
|
}
|
|
1837
2270
|
}
|
|
1838
|
-
const
|
|
2271
|
+
const o = d.attrName(e, "bind-arg"), g = d.attrName(
|
|
1839
2272
|
null,
|
|
1840
2273
|
"arg",
|
|
1841
2274
|
!0
|
|
1842
|
-
),
|
|
2275
|
+
), u = d.attrName(
|
|
1843
2276
|
null,
|
|
1844
2277
|
"bind-arg",
|
|
1845
2278
|
!0
|
|
1846
2279
|
);
|
|
1847
|
-
e ? t.hasAttribute(
|
|
1848
|
-
|
|
1849
|
-
) : t.hasAttribute(
|
|
1850
|
-
const b = e ?
|
|
2280
|
+
e ? t.hasAttribute(o) && (r.bindArg = t.getRawAttribute(o)) : t.hasAttribute(g) ? r.bindArg = t.getRawAttribute(
|
|
2281
|
+
g
|
|
2282
|
+
) : t.hasAttribute(u) && (r.bindArg = t.getRawAttribute(u));
|
|
2283
|
+
const b = e ? d.attrName(e, "bind-params") : d.attrName(null, "bind-params", !0);
|
|
1851
2284
|
if (t.hasAttribute(b)) {
|
|
1852
|
-
const
|
|
1853
|
-
|
|
2285
|
+
const l = t.getRawAttribute(b);
|
|
2286
|
+
r.bindParams = l.split("&").map((f) => f.trim());
|
|
1854
2287
|
}
|
|
1855
2288
|
if (e) {
|
|
1856
|
-
if (t.hasAttribute(
|
|
1857
|
-
const
|
|
1858
|
-
|
|
2289
|
+
if (t.hasAttribute(d.attrName(e, "adjust"))) {
|
|
2290
|
+
const f = t.getRawAttribute(
|
|
2291
|
+
d.attrName(e, "adjust")
|
|
1859
2292
|
);
|
|
1860
|
-
if (
|
|
1861
|
-
const p = document.body.querySelectorAll(
|
|
1862
|
-
p.length > 0 ? (
|
|
1863
|
-
const
|
|
1864
|
-
|
|
2293
|
+
if (f) {
|
|
2294
|
+
const p = document.body.querySelectorAll(f);
|
|
2295
|
+
p.length > 0 ? (r.adjustFragments = [], p.forEach((w) => {
|
|
2296
|
+
const v = A.get(w);
|
|
2297
|
+
v && r.adjustFragments.push(v);
|
|
1865
2298
|
})) : h.error(
|
|
1866
2299
|
"Haori",
|
|
1867
|
-
`Adjust element not found: ${
|
|
2300
|
+
`Adjust element not found: ${f} (${d.attrName(e, "adjust")})`
|
|
1868
2301
|
);
|
|
1869
2302
|
}
|
|
1870
|
-
if (t.hasAttribute(
|
|
2303
|
+
if (t.hasAttribute(d.attrName(e, "adjust-value"))) {
|
|
1871
2304
|
const p = t.getRawAttribute(
|
|
1872
|
-
|
|
2305
|
+
d.attrName(e, "adjust-value")
|
|
1873
2306
|
), w = Number(p);
|
|
1874
|
-
isNaN(w) || (
|
|
2307
|
+
isNaN(w) || (r.adjustValue = w);
|
|
1875
2308
|
}
|
|
1876
2309
|
}
|
|
1877
|
-
if (t.hasAttribute(
|
|
1878
|
-
const
|
|
2310
|
+
if (t.hasAttribute(d.attrName(e, "row-add")) && (r.rowAdd = !0), t.hasAttribute(d.attrName(e, "row-remove")) && (r.rowRemove = !0), t.hasAttribute(d.attrName(e, "row-prev")) && (r.rowMovePrev = !0), t.hasAttribute(d.attrName(e, "row-next")) && (r.rowMoveNext = !0), t.hasAttribute(`${c.prefix}${e}-after-run`)) {
|
|
2311
|
+
const f = t.getRawAttribute(
|
|
1879
2312
|
`${c.prefix}${e}-after-run`
|
|
1880
2313
|
);
|
|
1881
2314
|
try {
|
|
1882
|
-
|
|
2315
|
+
r.afterCallback = new Function(
|
|
1883
2316
|
"response",
|
|
1884
2317
|
`
|
|
1885
2318
|
"use strict";
|
|
1886
|
-
${
|
|
2319
|
+
${f}
|
|
1887
2320
|
`
|
|
1888
2321
|
);
|
|
1889
2322
|
} catch (p) {
|
|
1890
2323
|
h.error("Haori", `Invalid after script: ${p}`);
|
|
1891
2324
|
}
|
|
1892
2325
|
}
|
|
1893
|
-
t.hasAttribute(
|
|
1894
|
-
|
|
1895
|
-
)), t.hasAttribute(
|
|
1896
|
-
|
|
1897
|
-
)), t.hasAttribute(
|
|
1898
|
-
|
|
2326
|
+
t.hasAttribute(d.attrName(e, "dialog")) && (r.dialogMessage = t.getAttribute(
|
|
2327
|
+
d.attrName(e, "dialog")
|
|
2328
|
+
)), t.hasAttribute(d.attrName(e, "toast")) && (r.toastMessage = t.getAttribute(
|
|
2329
|
+
d.attrName(e, "toast")
|
|
2330
|
+
)), t.hasAttribute(d.attrName(e, "redirect")) && (r.redirectUrl = t.getAttribute(
|
|
2331
|
+
d.attrName(e, "redirect")
|
|
1899
2332
|
)), [
|
|
1900
2333
|
"reset",
|
|
1901
2334
|
"refetch",
|
|
1902
2335
|
"click",
|
|
1903
2336
|
"open",
|
|
1904
2337
|
"close"
|
|
1905
|
-
].forEach((
|
|
1906
|
-
const p =
|
|
2338
|
+
].forEach((f) => {
|
|
2339
|
+
const p = d.attrName(e, f);
|
|
1907
2340
|
if (!t.hasAttribute(p))
|
|
1908
2341
|
return;
|
|
1909
|
-
const w = t.getRawAttribute(p),
|
|
2342
|
+
const w = t.getRawAttribute(p), v = [];
|
|
1910
2343
|
if (w ? (document.body.querySelectorAll(w).forEach((x) => {
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1913
|
-
}),
|
|
1914
|
-
switch (
|
|
2344
|
+
const F = A.get(x);
|
|
2345
|
+
F && v.push(F);
|
|
2346
|
+
}), v.length === 0 && h.error("Haori", `Element not found: ${w} (${p})`)) : v.push(t), v.length > 0)
|
|
2347
|
+
switch (f) {
|
|
1915
2348
|
case "reset":
|
|
1916
|
-
|
|
2349
|
+
r.resetFragments = v;
|
|
1917
2350
|
break;
|
|
1918
2351
|
case "refetch":
|
|
1919
|
-
|
|
2352
|
+
r.refetchFragments = v;
|
|
1920
2353
|
break;
|
|
1921
2354
|
case "click":
|
|
1922
|
-
|
|
2355
|
+
r.clickFragments = v;
|
|
1923
2356
|
break;
|
|
1924
2357
|
case "open":
|
|
1925
|
-
|
|
2358
|
+
r.openFragments = v;
|
|
1926
2359
|
break;
|
|
1927
2360
|
case "close":
|
|
1928
|
-
|
|
2361
|
+
r.closeFragments = v;
|
|
1929
2362
|
break;
|
|
1930
2363
|
}
|
|
1931
2364
|
});
|
|
1932
2365
|
}
|
|
1933
2366
|
if (!e) {
|
|
1934
|
-
if (t.hasAttribute(
|
|
1935
|
-
const
|
|
1936
|
-
|
|
2367
|
+
if (t.hasAttribute(d.attrName(null, "data", !0))) {
|
|
2368
|
+
const l = t.getRawAttribute(
|
|
2369
|
+
d.attrName(null, "data", !0)
|
|
1937
2370
|
);
|
|
1938
|
-
|
|
2371
|
+
r.data = N.parseDataBind(l);
|
|
1939
2372
|
}
|
|
1940
|
-
if (t.hasAttribute(
|
|
1941
|
-
const
|
|
1942
|
-
|
|
2373
|
+
if (t.hasAttribute(d.attrName(null, "form", !0))) {
|
|
2374
|
+
const l = t.getRawAttribute(
|
|
2375
|
+
d.attrName(null, "form", !0)
|
|
1943
2376
|
);
|
|
1944
|
-
if (
|
|
1945
|
-
const
|
|
1946
|
-
|
|
1947
|
-
A.get(
|
|
2377
|
+
if (l) {
|
|
2378
|
+
const f = document.body.querySelector(l);
|
|
2379
|
+
f !== null ? r.formFragment = y.getFormFragment(
|
|
2380
|
+
A.get(f)
|
|
1948
2381
|
) : h.error(
|
|
1949
2382
|
"Haori",
|
|
1950
|
-
`Form element not found: ${
|
|
2383
|
+
`Form element not found: ${l} (${d.attrName(null, "fetch-form", !0)})`
|
|
1951
2384
|
);
|
|
1952
2385
|
} else
|
|
1953
|
-
|
|
2386
|
+
r.formFragment = y.getFormFragment(t);
|
|
1954
2387
|
}
|
|
1955
2388
|
}
|
|
1956
|
-
return
|
|
2389
|
+
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [t]), r;
|
|
1957
2390
|
}
|
|
1958
2391
|
/**
|
|
1959
2392
|
* ElementFragment の構造的タイプガード。
|
|
@@ -1974,7 +2407,7 @@ ${d}
|
|
|
1974
2407
|
* @param arg2 イベント名
|
|
1975
2408
|
*/
|
|
1976
2409
|
constructor(t, e = null) {
|
|
1977
|
-
|
|
2410
|
+
d.isElementFragment(t) ? this.options = d.buildOptions(t, e) : this.options = t;
|
|
1978
2411
|
}
|
|
1979
2412
|
/**
|
|
1980
2413
|
* 一連の処理を実行します。オプションが空の場合は即座にresolveされます。
|
|
@@ -1985,84 +2418,84 @@ ${d}
|
|
|
1985
2418
|
return Object.keys(this.options).length === 0 || this.options.formFragment && this.validate(this.options.formFragment) === !1 ? Promise.resolve() : this.confirm().then((t) => {
|
|
1986
2419
|
if (!t)
|
|
1987
2420
|
return Promise.resolve();
|
|
1988
|
-
let e = this.options.fetchUrl,
|
|
2421
|
+
let e = this.options.fetchUrl, r = this.options.fetchOptions;
|
|
1989
2422
|
if (this.options.beforeCallback) {
|
|
1990
2423
|
const n = this.options.beforeCallback(
|
|
1991
2424
|
e || null,
|
|
1992
|
-
|
|
2425
|
+
r || null
|
|
1993
2426
|
);
|
|
1994
2427
|
if (n != null) {
|
|
1995
2428
|
if (n === !1 || typeof n == "object" && n.stop)
|
|
1996
2429
|
return Promise.resolve();
|
|
1997
|
-
typeof n == "object" && (e = "fetchUrl" in n ? n.fetchUrl : e,
|
|
2430
|
+
typeof n == "object" && (e = "fetchUrl" in n ? n.fetchUrl : e, r = "fetchOptions" in n ? n.fetchOptions : r);
|
|
1998
2431
|
}
|
|
1999
2432
|
}
|
|
2000
|
-
const
|
|
2433
|
+
const i = {};
|
|
2001
2434
|
if (this.options.formFragment) {
|
|
2002
|
-
const n =
|
|
2003
|
-
Object.assign(
|
|
2435
|
+
const n = y.getValues(this.options.formFragment);
|
|
2436
|
+
Object.assign(i, n);
|
|
2004
2437
|
}
|
|
2005
|
-
this.options.data && typeof this.options.data == "object" && Object.assign(
|
|
2006
|
-
const
|
|
2438
|
+
this.options.data && typeof this.options.data == "object" && Object.assign(i, this.options.data);
|
|
2439
|
+
const s = Object.keys(i).length > 0;
|
|
2007
2440
|
if (e) {
|
|
2008
|
-
const n = { ...
|
|
2441
|
+
const n = { ...r || {} }, a = new Headers(
|
|
2009
2442
|
n.headers || void 0
|
|
2010
|
-
),
|
|
2011
|
-
if (
|
|
2012
|
-
if (
|
|
2013
|
-
const
|
|
2014
|
-
for (const [b,
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}) : typeof
|
|
2018
|
-
|
|
2443
|
+
), o = (n.method || "GET").toUpperCase();
|
|
2444
|
+
if (o === "GET" || o === "HEAD" || o === "OPTIONS") {
|
|
2445
|
+
if (s) {
|
|
2446
|
+
const g = new URL(e, window.location.href), u = new URLSearchParams(g.search);
|
|
2447
|
+
for (const [b, l] of Object.entries(i))
|
|
2448
|
+
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((f) => {
|
|
2449
|
+
u.append(b, String(f));
|
|
2450
|
+
}) : typeof l == "object" || typeof l == "function" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
|
|
2451
|
+
g.search = u.toString(), e = g.toString();
|
|
2019
2452
|
}
|
|
2020
|
-
} else if (
|
|
2021
|
-
const
|
|
2022
|
-
if (/multipart\/form-data/i.test(
|
|
2453
|
+
} else if (s) {
|
|
2454
|
+
const g = a.get("Content-Type") || "";
|
|
2455
|
+
if (/multipart\/form-data/i.test(g)) {
|
|
2023
2456
|
a.delete("Content-Type");
|
|
2024
|
-
const
|
|
2025
|
-
for (const [b,
|
|
2026
|
-
|
|
2027
|
-
n.body =
|
|
2028
|
-
} else if (/application\/x-www-form-urlencoded/i.test(
|
|
2029
|
-
const
|
|
2030
|
-
for (const [b,
|
|
2031
|
-
|
|
2032
|
-
n.body =
|
|
2457
|
+
const u = new FormData();
|
|
2458
|
+
for (const [b, l] of Object.entries(i))
|
|
2459
|
+
l == null ? u.append(b, "") : l instanceof Blob ? u.append(b, l) : Array.isArray(l) ? l.forEach((f) => u.append(b, String(f))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l));
|
|
2460
|
+
n.body = u;
|
|
2461
|
+
} else if (/application\/x-www-form-urlencoded/i.test(g)) {
|
|
2462
|
+
const u = new URLSearchParams();
|
|
2463
|
+
for (const [b, l] of Object.entries(i))
|
|
2464
|
+
l !== void 0 && (l === null ? u.append(b, "") : Array.isArray(l) ? l.forEach((f) => u.append(b, String(f))) : typeof l == "object" ? u.append(b, JSON.stringify(l)) : u.append(b, String(l)));
|
|
2465
|
+
n.body = u;
|
|
2033
2466
|
} else
|
|
2034
|
-
a.set("Content-Type", "application/json"), n.body = JSON.stringify(
|
|
2467
|
+
a.set("Content-Type", "application/json"), n.body = JSON.stringify(i);
|
|
2035
2468
|
}
|
|
2036
2469
|
if (n.headers = a, this.options.targetFragment && e) {
|
|
2037
|
-
const
|
|
2038
|
-
return
|
|
2470
|
+
const g = performance.now();
|
|
2471
|
+
return E.fetchStart(
|
|
2039
2472
|
this.options.targetFragment.getTarget(),
|
|
2040
2473
|
e,
|
|
2041
2474
|
n,
|
|
2042
|
-
|
|
2043
|
-
), fetch(e, n).then((
|
|
2044
|
-
|
|
2475
|
+
s ? i : void 0
|
|
2476
|
+
), fetch(e, n).then((u) => this.handleFetchResult(
|
|
2477
|
+
u,
|
|
2045
2478
|
e || void 0,
|
|
2046
|
-
|
|
2047
|
-
)).catch((
|
|
2048
|
-
throw e &&
|
|
2479
|
+
g
|
|
2480
|
+
)).catch((u) => {
|
|
2481
|
+
throw e && E.fetchError(
|
|
2049
2482
|
this.options.targetFragment.getTarget(),
|
|
2050
2483
|
e,
|
|
2051
|
-
|
|
2052
|
-
),
|
|
2484
|
+
u
|
|
2485
|
+
), u;
|
|
2053
2486
|
});
|
|
2054
|
-
} else return e ? fetch(e, n).then((
|
|
2487
|
+
} else return e ? fetch(e, n).then((g) => this.handleFetchResult(g, e || void 0)) : Promise.resolve();
|
|
2055
2488
|
} else {
|
|
2056
|
-
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment &&
|
|
2057
|
-
const
|
|
2058
|
-
|
|
2489
|
+
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && s) {
|
|
2490
|
+
const o = this.options.formFragment, g = o.getTarget();
|
|
2491
|
+
g.setAttribute(
|
|
2059
2492
|
`${c.prefix}bind`,
|
|
2060
|
-
JSON.stringify(
|
|
2493
|
+
JSON.stringify(i)
|
|
2061
2494
|
);
|
|
2062
|
-
const
|
|
2063
|
-
return Object.assign(
|
|
2495
|
+
const u = o.getBindingData();
|
|
2496
|
+
return Object.assign(u, i), N.setBindingData(g, u);
|
|
2064
2497
|
}
|
|
2065
|
-
const n =
|
|
2498
|
+
const n = s ? i : {}, a = new Response(JSON.stringify(n), {
|
|
2066
2499
|
headers: { "Content-Type": "application/json" }
|
|
2067
2500
|
});
|
|
2068
2501
|
return this.handleFetchResult(a);
|
|
@@ -2072,86 +2505,86 @@ ${d}
|
|
|
2072
2505
|
/**
|
|
2073
2506
|
* フェッチ後の処理を実行します。
|
|
2074
2507
|
*/
|
|
2075
|
-
handleFetchResult(t, e,
|
|
2508
|
+
handleFetchResult(t, e, r) {
|
|
2076
2509
|
if (!t.ok)
|
|
2077
|
-
return this.options.targetFragment && e &&
|
|
2510
|
+
return this.options.targetFragment && e && E.fetchError(
|
|
2078
2511
|
this.options.targetFragment.getTarget(),
|
|
2079
2512
|
e,
|
|
2080
2513
|
new Error(`${t.status} ${t.statusText}`),
|
|
2081
2514
|
t.status,
|
|
2082
|
-
|
|
2515
|
+
r
|
|
2083
2516
|
), this.handleFetchError(t);
|
|
2084
|
-
if (this.options.targetFragment && e &&
|
|
2517
|
+
if (this.options.targetFragment && e && r && E.fetchEnd(
|
|
2085
2518
|
this.options.targetFragment.getTarget(),
|
|
2086
2519
|
e,
|
|
2087
2520
|
t.status,
|
|
2088
|
-
|
|
2521
|
+
r
|
|
2089
2522
|
), this.options.afterCallback) {
|
|
2090
|
-
const
|
|
2091
|
-
if (
|
|
2092
|
-
if (
|
|
2523
|
+
const s = this.options.afterCallback(t);
|
|
2524
|
+
if (s != null) {
|
|
2525
|
+
if (s === !1 || typeof s == "object" && s.stop)
|
|
2093
2526
|
return Promise.resolve();
|
|
2094
|
-
typeof
|
|
2527
|
+
typeof s == "object" && "response" in s && (t = "response" in s ? s.response : t);
|
|
2095
2528
|
}
|
|
2096
2529
|
}
|
|
2097
|
-
const
|
|
2098
|
-
return
|
|
2099
|
-
|
|
2100
|
-
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((
|
|
2101
|
-
|
|
2102
|
-
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((
|
|
2103
|
-
const n =
|
|
2530
|
+
const i = [];
|
|
2531
|
+
return i.push(this.bindResult(t)), i.push(this.adjust()), i.push(this.addRow()), i.push(this.removeRow()), i.push(this.movePrevRow()), i.push(this.moveNextRow()), this.options.resetFragments && this.options.resetFragments.length > 0 && this.options.resetFragments.forEach((s) => {
|
|
2532
|
+
i.push(y.reset(s));
|
|
2533
|
+
}), this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((s) => {
|
|
2534
|
+
i.push(new d(s, null).run());
|
|
2535
|
+
}), this.options.clickFragments && this.options.clickFragments.length > 0 && this.options.clickFragments.forEach((s) => {
|
|
2536
|
+
const n = s.getTarget();
|
|
2104
2537
|
typeof n.click == "function" ? n.click() : n.dispatchEvent(
|
|
2105
2538
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
2106
2539
|
);
|
|
2107
|
-
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((
|
|
2108
|
-
const n =
|
|
2109
|
-
n instanceof HTMLDialogElement ?
|
|
2110
|
-
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((
|
|
2111
|
-
const n =
|
|
2112
|
-
n instanceof HTMLDialogElement ?
|
|
2113
|
-
}), Promise.all(
|
|
2540
|
+
}), this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((s) => {
|
|
2541
|
+
const n = s.getTarget();
|
|
2542
|
+
n instanceof HTMLDialogElement ? i.push(M.openDialog(n)) : h.error("Haori", "Element is not a dialog: ", n);
|
|
2543
|
+
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((s) => {
|
|
2544
|
+
const n = s.getTarget();
|
|
2545
|
+
n instanceof HTMLDialogElement ? i.push(M.closeDialog(n)) : h.error("Haori", "Element is not a dialog: ", n);
|
|
2546
|
+
}), Promise.all(i).then(() => this.options.dialogMessage ? M.dialog(this.options.dialogMessage) : Promise.resolve()).then(() => this.options.toastMessage ? M.toast(this.options.toastMessage, "info") : Promise.resolve()).then(() => (this.options.redirectUrl && (window.location.href = this.options.redirectUrl), Promise.resolve()));
|
|
2114
2547
|
}
|
|
2115
2548
|
/**
|
|
2116
2549
|
* フェッチエラー応答のメッセージを適切な要素へ伝播します。
|
|
2117
2550
|
*/
|
|
2118
2551
|
async handleFetchError(t) {
|
|
2119
2552
|
let e = null;
|
|
2120
|
-
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e =
|
|
2121
|
-
const
|
|
2553
|
+
this.options.formFragment ? e = this.options.formFragment : this.options.targetFragment && (e = y.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
2554
|
+
const r = async (s) => {
|
|
2122
2555
|
const n = e ? e.getTarget() : document.body;
|
|
2123
|
-
await M.addErrorMessage(n,
|
|
2556
|
+
await M.addErrorMessage(n, s);
|
|
2124
2557
|
};
|
|
2125
2558
|
if ((t.headers.get("Content-Type") || "").includes("application/json"))
|
|
2126
2559
|
try {
|
|
2127
|
-
const
|
|
2128
|
-
if (
|
|
2129
|
-
if (typeof
|
|
2130
|
-
for (const a of
|
|
2560
|
+
const s = await t.json(), n = [];
|
|
2561
|
+
if (s && typeof s == "object") {
|
|
2562
|
+
if (typeof s.message == "string" && n.push({ message: s.message }), Array.isArray(s.messages))
|
|
2563
|
+
for (const a of s.messages)
|
|
2131
2564
|
typeof a == "string" && n.push({ message: a });
|
|
2132
|
-
if (
|
|
2133
|
-
for (const [a,
|
|
2134
|
-
Array.isArray(
|
|
2135
|
-
`) }) : typeof
|
|
2565
|
+
if (s.errors && typeof s.errors == "object")
|
|
2566
|
+
for (const [a, o] of Object.entries(s.errors))
|
|
2567
|
+
Array.isArray(o) ? n.push({ key: a, message: o.join(`
|
|
2568
|
+
`) }) : typeof o == "string" ? n.push({ key: a, message: o }) : o != null && n.push({ key: a, message: String(o) });
|
|
2136
2569
|
if (n.length === 0)
|
|
2137
|
-
for (const [a,
|
|
2138
|
-
a === "message" || a === "messages" || a === "errors" || (Array.isArray(
|
|
2139
|
-
`) }) : typeof
|
|
2570
|
+
for (const [a, o] of Object.entries(s))
|
|
2571
|
+
a === "message" || a === "messages" || a === "errors" || (Array.isArray(o) ? n.push({ key: a, message: o.join(`
|
|
2572
|
+
`) }) : typeof o == "string" && n.push({ key: a, message: o }));
|
|
2140
2573
|
}
|
|
2141
2574
|
if (n.length === 0) {
|
|
2142
|
-
await
|
|
2575
|
+
await r(`${t.status} ${t.statusText}`);
|
|
2143
2576
|
return;
|
|
2144
2577
|
}
|
|
2145
2578
|
for (const a of n)
|
|
2146
|
-
a.key && e ? await
|
|
2579
|
+
a.key && e ? await y.addErrorMessage(e, a.key, a.message) : await r(a.message);
|
|
2147
2580
|
return;
|
|
2148
2581
|
} catch {
|
|
2149
2582
|
}
|
|
2150
2583
|
try {
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2584
|
+
const s = await t.text();
|
|
2585
|
+
s && s.trim().length > 0 ? await r(s.trim()) : await r(`${t.status} ${t.statusText}`);
|
|
2153
2586
|
} catch {
|
|
2154
|
-
await
|
|
2587
|
+
await r(`${t.status} ${t.statusText}`);
|
|
2155
2588
|
}
|
|
2156
2589
|
}
|
|
2157
2590
|
/**
|
|
@@ -2165,10 +2598,10 @@ ${d}
|
|
|
2165
2598
|
if (this.options.valid !== !0)
|
|
2166
2599
|
return !0;
|
|
2167
2600
|
const e = t.getTarget();
|
|
2168
|
-
let
|
|
2169
|
-
return
|
|
2170
|
-
|
|
2171
|
-
}),
|
|
2601
|
+
let r = this.validateOne(t);
|
|
2602
|
+
return r || e.focus(), t.getChildElementFragments().reverse().forEach((i) => {
|
|
2603
|
+
r &&= this.validate(i);
|
|
2604
|
+
}), r;
|
|
2172
2605
|
}
|
|
2173
2606
|
/**
|
|
2174
2607
|
* 対象のフラグメントに対してバリデーションを実行します。
|
|
@@ -2196,34 +2629,34 @@ ${d}
|
|
|
2196
2629
|
* @param response フェッチのレスポンスオブジェクト
|
|
2197
2630
|
*/
|
|
2198
2631
|
bindResult(t) {
|
|
2199
|
-
return !this.options.bindFragments || this.options.bindFragments.length === 0 ? Promise.resolve() : (t.headers.get("Content-Type")?.includes("application/json") ? t.json() : t.text()).then((
|
|
2632
|
+
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) => {
|
|
2200
2633
|
if (this.options.bindParams) {
|
|
2201
|
-
const
|
|
2634
|
+
const s = {};
|
|
2202
2635
|
this.options.bindParams.forEach((n) => {
|
|
2203
|
-
|
|
2204
|
-
}),
|
|
2636
|
+
r && typeof r == "object" && n in r && (s[n] = r[n]);
|
|
2637
|
+
}), r = s;
|
|
2205
2638
|
}
|
|
2206
|
-
const
|
|
2639
|
+
const i = [];
|
|
2207
2640
|
if (this.options.bindArg)
|
|
2208
|
-
this.options.bindFragments.forEach((
|
|
2209
|
-
const n =
|
|
2210
|
-
n[this.options.bindArg] =
|
|
2641
|
+
this.options.bindFragments.forEach((s) => {
|
|
2642
|
+
const n = s.getBindingData();
|
|
2643
|
+
n[this.options.bindArg] = r, i.push(N.setBindingData(s.getTarget(), n));
|
|
2211
2644
|
});
|
|
2212
2645
|
else {
|
|
2213
|
-
if (typeof
|
|
2646
|
+
if (typeof r == "string")
|
|
2214
2647
|
return h.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
2215
2648
|
new Error("string data cannot be bound without a bindArg.")
|
|
2216
2649
|
);
|
|
2217
|
-
this.options.bindFragments.forEach((
|
|
2218
|
-
|
|
2650
|
+
this.options.bindFragments.forEach((s) => {
|
|
2651
|
+
i.push(
|
|
2219
2652
|
N.setBindingData(
|
|
2220
|
-
|
|
2221
|
-
|
|
2653
|
+
s.getTarget(),
|
|
2654
|
+
r
|
|
2222
2655
|
)
|
|
2223
2656
|
);
|
|
2224
2657
|
});
|
|
2225
2658
|
}
|
|
2226
|
-
return Promise.all(
|
|
2659
|
+
return Promise.all(i).then(() => {
|
|
2227
2660
|
});
|
|
2228
2661
|
});
|
|
2229
2662
|
}
|
|
@@ -2234,11 +2667,11 @@ ${d}
|
|
|
2234
2667
|
if (!this.options.adjustFragments || this.options.adjustFragments.length === 0)
|
|
2235
2668
|
return Promise.resolve();
|
|
2236
2669
|
const t = this.options.adjustValue ?? 0, e = [];
|
|
2237
|
-
for (const
|
|
2238
|
-
let
|
|
2239
|
-
(
|
|
2240
|
-
let
|
|
2241
|
-
isNaN(
|
|
2670
|
+
for (const r of this.options.adjustFragments) {
|
|
2671
|
+
let i = r.getValue();
|
|
2672
|
+
(i == null || i === "") && (i = "0");
|
|
2673
|
+
let s = Number(i);
|
|
2674
|
+
isNaN(s) && (s = 0), s += t, e.push(r.setValue(String(s)));
|
|
2242
2675
|
}
|
|
2243
2676
|
return Promise.all(e).then(() => {
|
|
2244
2677
|
});
|
|
@@ -2267,10 +2700,10 @@ ${d}
|
|
|
2267
2700
|
const t = this.getRowFragment();
|
|
2268
2701
|
if (!t)
|
|
2269
2702
|
return Promise.reject(new Error("Row fragment not found."));
|
|
2270
|
-
const e = [],
|
|
2703
|
+
const e = [], r = t.clone();
|
|
2271
2704
|
return e.push(
|
|
2272
|
-
t.getParent().insertAfter(
|
|
2273
|
-
), e.push(N.evaluateAll(
|
|
2705
|
+
t.getParent().insertAfter(r, t)
|
|
2706
|
+
), e.push(N.evaluateAll(r)), e.push(y.reset(r)), Promise.all(e).then(() => {
|
|
2274
2707
|
});
|
|
2275
2708
|
}
|
|
2276
2709
|
/**
|
|
@@ -2285,7 +2718,7 @@ ${d}
|
|
|
2285
2718
|
if (!t)
|
|
2286
2719
|
return Promise.reject(new Error("Row fragment not found."));
|
|
2287
2720
|
const e = t.getParent();
|
|
2288
|
-
return e && e.getChildElementFragments().filter((
|
|
2721
|
+
return e && e.getChildElementFragments().filter((i) => !i.hasAttribute(`${c.prefix}each-before`) && !i.hasAttribute(`${c.prefix}each-after`)).length <= 1 ? Promise.resolve() : t.remove();
|
|
2289
2722
|
}
|
|
2290
2723
|
/**
|
|
2291
2724
|
* 前の行へ移動します。
|
|
@@ -2301,8 +2734,8 @@ ${d}
|
|
|
2301
2734
|
const e = t.getPrevious();
|
|
2302
2735
|
if (!e)
|
|
2303
2736
|
return Promise.resolve();
|
|
2304
|
-
const
|
|
2305
|
-
return
|
|
2737
|
+
const r = t.getParent();
|
|
2738
|
+
return r ? r.insertBefore(t, e) : Promise.resolve();
|
|
2306
2739
|
}
|
|
2307
2740
|
/**
|
|
2308
2741
|
* 次の行へ移動します。
|
|
@@ -2318,11 +2751,11 @@ ${d}
|
|
|
2318
2751
|
const e = t.getNext();
|
|
2319
2752
|
if (!e)
|
|
2320
2753
|
return Promise.resolve();
|
|
2321
|
-
const
|
|
2322
|
-
return
|
|
2754
|
+
const r = t.getParent();
|
|
2755
|
+
return r ? r.insertAfter(t, e) : Promise.resolve();
|
|
2323
2756
|
}
|
|
2324
2757
|
}
|
|
2325
|
-
class
|
|
2758
|
+
class X {
|
|
2326
2759
|
/**
|
|
2327
2760
|
* URLのクエリパラメータを取得します。
|
|
2328
2761
|
*
|
|
@@ -2330,12 +2763,12 @@ class J {
|
|
|
2330
2763
|
*/
|
|
2331
2764
|
static readParams() {
|
|
2332
2765
|
const t = {}, e = window.location.search;
|
|
2333
|
-
return new URLSearchParams(e).forEach((
|
|
2334
|
-
t[
|
|
2766
|
+
return new URLSearchParams(e).forEach((i, s) => {
|
|
2767
|
+
t[s] = i;
|
|
2335
2768
|
}), t;
|
|
2336
2769
|
}
|
|
2337
2770
|
}
|
|
2338
|
-
class
|
|
2771
|
+
class J {
|
|
2339
2772
|
/**
|
|
2340
2773
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
2341
2774
|
*
|
|
@@ -2349,31 +2782,31 @@ class W {
|
|
|
2349
2782
|
* @returns body 内の HTML 文字列
|
|
2350
2783
|
*/
|
|
2351
2784
|
static async load(t, e) {
|
|
2352
|
-
let
|
|
2785
|
+
let r;
|
|
2353
2786
|
try {
|
|
2354
|
-
|
|
2355
|
-
} catch (
|
|
2356
|
-
throw h.error("[Haori]", "Failed to fetch import source:", t,
|
|
2787
|
+
r = await fetch(t, e);
|
|
2788
|
+
} catch (s) {
|
|
2789
|
+
throw h.error("[Haori]", "Failed to fetch import source:", t, s), new Error(`Failed to fetch: ${t}`);
|
|
2357
2790
|
}
|
|
2358
|
-
if (!
|
|
2359
|
-
const
|
|
2360
|
-
throw h.error("[Haori]", "Import HTTP error:", t,
|
|
2791
|
+
if (!r.ok) {
|
|
2792
|
+
const s = `${r.status} ${r.statusText}`;
|
|
2793
|
+
throw h.error("[Haori]", "Import HTTP error:", t, s), new Error(`Failed to load ${t}: ${s}`);
|
|
2361
2794
|
}
|
|
2362
|
-
let
|
|
2795
|
+
let i;
|
|
2363
2796
|
try {
|
|
2364
|
-
|
|
2365
|
-
} catch (
|
|
2366
|
-
throw h.error("[Haori]", "Failed to read response text:", t,
|
|
2797
|
+
i = await r.text();
|
|
2798
|
+
} catch (s) {
|
|
2799
|
+
throw h.error("[Haori]", "Failed to read response text:", t, s), new Error(`Failed to read response from: ${t}`);
|
|
2367
2800
|
}
|
|
2368
2801
|
try {
|
|
2369
|
-
const n = new DOMParser().parseFromString(
|
|
2370
|
-
return n && n.body ? n.body.innerHTML : (h.warn("[Haori]", "No body found in imported document:", t),
|
|
2371
|
-
} catch (
|
|
2372
|
-
return h.error("[Haori]", "Failed to parse imported HTML:", t,
|
|
2802
|
+
const n = new DOMParser().parseFromString(i, "text/html");
|
|
2803
|
+
return n && n.body ? n.body.innerHTML : (h.warn("[Haori]", "No body found in imported document:", t), i);
|
|
2804
|
+
} catch (s) {
|
|
2805
|
+
return h.error("[Haori]", "Failed to parse imported HTML:", t, s), i;
|
|
2373
2806
|
}
|
|
2374
2807
|
}
|
|
2375
2808
|
}
|
|
2376
|
-
const
|
|
2809
|
+
const m = class m {
|
|
2377
2810
|
/**
|
|
2378
2811
|
* 遅延属性かどうか(完全名で判定)を判定します。
|
|
2379
2812
|
*
|
|
@@ -2381,7 +2814,7 @@ const g = class g {
|
|
|
2381
2814
|
* @returns 遅延属性かどうか
|
|
2382
2815
|
*/
|
|
2383
2816
|
static isDeferredAttributeName(t) {
|
|
2384
|
-
return
|
|
2817
|
+
return m.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
2385
2818
|
(e) => t === `${c.prefix}${e}`
|
|
2386
2819
|
);
|
|
2387
2820
|
}
|
|
@@ -2396,36 +2829,36 @@ const g = class g {
|
|
|
2396
2829
|
if (!e)
|
|
2397
2830
|
return Promise.resolve();
|
|
2398
2831
|
t.parentNode && (A.get(t.parentNode)?.isMounted() || document.body.contains(t) ? e.setMounted(!0) : e.setMounted(!1));
|
|
2399
|
-
const
|
|
2400
|
-
for (const
|
|
2401
|
-
const n = c.prefix +
|
|
2402
|
-
e.hasAttribute(n) && (
|
|
2403
|
-
|
|
2832
|
+
const r = [], i = /* @__PURE__ */ new Set();
|
|
2833
|
+
for (const s of m.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
2834
|
+
const n = c.prefix + s;
|
|
2835
|
+
e.hasAttribute(n) && (r.push(
|
|
2836
|
+
m.setAttribute(
|
|
2404
2837
|
e.getTarget(),
|
|
2405
2838
|
n,
|
|
2406
2839
|
e.getRawAttribute(n)
|
|
2407
2840
|
)
|
|
2408
|
-
),
|
|
2841
|
+
), i.add(n));
|
|
2409
2842
|
}
|
|
2410
|
-
for (const
|
|
2411
|
-
if (
|
|
2843
|
+
for (const s of e.getAttributeNames()) {
|
|
2844
|
+
if (i.has(s) || m.isDeferredAttributeName(s))
|
|
2412
2845
|
continue;
|
|
2413
|
-
const n = e.getRawAttribute(
|
|
2414
|
-
n !== null &&
|
|
2846
|
+
const n = e.getRawAttribute(s);
|
|
2847
|
+
n !== null && r.push(m.setAttribute(e.getTarget(), s, n));
|
|
2415
2848
|
}
|
|
2416
|
-
for (const
|
|
2417
|
-
const n = c.prefix +
|
|
2418
|
-
e.hasAttribute(n) && (
|
|
2419
|
-
|
|
2849
|
+
for (const s of m.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
2850
|
+
const n = c.prefix + s;
|
|
2851
|
+
e.hasAttribute(n) && (r.push(
|
|
2852
|
+
m.setAttribute(
|
|
2420
2853
|
e.getTarget(),
|
|
2421
2854
|
n,
|
|
2422
2855
|
e.getRawAttribute(n)
|
|
2423
2856
|
)
|
|
2424
|
-
),
|
|
2857
|
+
), i.add(n));
|
|
2425
2858
|
}
|
|
2426
|
-
return e.getChildren().forEach((
|
|
2427
|
-
|
|
2428
|
-
}), Promise.all(
|
|
2859
|
+
return e.getChildren().forEach((s) => {
|
|
2860
|
+
s instanceof S ? r.push(m.scan(s.getTarget())) : s instanceof j && r.push(m.evaluateText(s));
|
|
2861
|
+
}), Promise.all(r).then(() => {
|
|
2429
2862
|
});
|
|
2430
2863
|
}
|
|
2431
2864
|
/**
|
|
@@ -2437,52 +2870,52 @@ const g = class g {
|
|
|
2437
2870
|
* @param value 属性値
|
|
2438
2871
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
2439
2872
|
*/
|
|
2440
|
-
static setAttribute(t, e,
|
|
2441
|
-
const
|
|
2873
|
+
static setAttribute(t, e, r) {
|
|
2874
|
+
const i = A.get(t), s = [];
|
|
2442
2875
|
switch (e) {
|
|
2443
2876
|
case `${c.prefix}bind`: {
|
|
2444
|
-
|
|
2877
|
+
r === null ? (i.clearBindingDataCache(), i.setBindingData({})) : i.setBindingData(m.parseDataBind(r));
|
|
2445
2878
|
break;
|
|
2446
2879
|
}
|
|
2447
2880
|
case `${c.prefix}if`:
|
|
2448
|
-
|
|
2881
|
+
s.push(m.evaluateIf(i));
|
|
2449
2882
|
break;
|
|
2450
2883
|
case `${c.prefix}each`:
|
|
2451
|
-
|
|
2884
|
+
s.push(m.evaluateEach(i));
|
|
2452
2885
|
break;
|
|
2453
2886
|
case `${c.prefix}fetch`:
|
|
2454
|
-
|
|
2887
|
+
s.push(new d(i, null).run());
|
|
2455
2888
|
break;
|
|
2456
2889
|
case `${c.prefix}import`: {
|
|
2457
|
-
if (typeof
|
|
2458
|
-
const n =
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
const
|
|
2462
|
-
return
|
|
2463
|
-
n.innerHTML =
|
|
2890
|
+
if (typeof r == "string") {
|
|
2891
|
+
const n = i.getTarget(), a = performance.now();
|
|
2892
|
+
E.importStart(n, r), s.push(
|
|
2893
|
+
J.load(r).then((o) => {
|
|
2894
|
+
const g = new TextEncoder().encode(o).length;
|
|
2895
|
+
return T.enqueue(() => {
|
|
2896
|
+
n.innerHTML = o;
|
|
2464
2897
|
}).then(() => {
|
|
2465
|
-
|
|
2898
|
+
E.importEnd(n, r, g, a);
|
|
2466
2899
|
});
|
|
2467
|
-
}).catch((
|
|
2468
|
-
|
|
2900
|
+
}).catch((o) => {
|
|
2901
|
+
E.importError(n, r, o), h.error("[Haori]", "Failed to import HTML:", r, o);
|
|
2469
2902
|
})
|
|
2470
2903
|
);
|
|
2471
2904
|
}
|
|
2472
2905
|
break;
|
|
2473
2906
|
}
|
|
2474
2907
|
case `${c.prefix}url-param`: {
|
|
2475
|
-
const n =
|
|
2908
|
+
const n = i.getAttribute(`${c.prefix}url-arg`), a = X.readParams();
|
|
2476
2909
|
if (n === null)
|
|
2477
|
-
|
|
2910
|
+
m.setBindingData(t, a);
|
|
2478
2911
|
else {
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2912
|
+
const o = i.getRawBindingData() || {};
|
|
2913
|
+
o[String(n)] = a, m.setBindingData(t, o);
|
|
2481
2914
|
}
|
|
2482
2915
|
break;
|
|
2483
2916
|
}
|
|
2484
2917
|
}
|
|
2485
|
-
return
|
|
2918
|
+
return r === null ? s.push(i.removeAttribute(e)) : s.push(i.setAttribute(e, r)), Promise.all(s).then(() => {
|
|
2486
2919
|
});
|
|
2487
2920
|
}
|
|
2488
2921
|
/**
|
|
@@ -2494,12 +2927,12 @@ const g = class g {
|
|
|
2494
2927
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
2495
2928
|
*/
|
|
2496
2929
|
static setBindingData(t, e) {
|
|
2497
|
-
const
|
|
2498
|
-
|
|
2499
|
-
const
|
|
2500
|
-
return
|
|
2501
|
-
|
|
2502
|
-
),
|
|
2930
|
+
const r = A.get(t), i = r.getRawBindingData();
|
|
2931
|
+
r.setBindingData(e);
|
|
2932
|
+
const s = [];
|
|
2933
|
+
return s.push(
|
|
2934
|
+
r.setAttribute(`${c.prefix}bind`, JSON.stringify(e))
|
|
2935
|
+
), s.push(m.evaluateAll(r)), E.bindChange(t, i, e, "manual"), Promise.all(s).then(() => {
|
|
2503
2936
|
});
|
|
2504
2937
|
}
|
|
2505
2938
|
/**
|
|
@@ -2516,10 +2949,10 @@ const g = class g {
|
|
|
2516
2949
|
return h.error("[Haori]", "Invalid JSON in data-bind:", e), {};
|
|
2517
2950
|
}
|
|
2518
2951
|
else {
|
|
2519
|
-
const e = new URLSearchParams(t),
|
|
2520
|
-
for (const [
|
|
2521
|
-
|
|
2522
|
-
return
|
|
2952
|
+
const e = new URLSearchParams(t), r = {};
|
|
2953
|
+
for (const [i, s] of e.entries())
|
|
2954
|
+
r[i] !== void 0 ? Array.isArray(r[i]) ? r[i].push(s) : r[i] = [r[i], s] : r[i] = s;
|
|
2955
|
+
return r;
|
|
2523
2956
|
}
|
|
2524
2957
|
}
|
|
2525
2958
|
/**
|
|
@@ -2529,11 +2962,11 @@ const g = class g {
|
|
|
2529
2962
|
* @param node 追加するノード
|
|
2530
2963
|
*/
|
|
2531
2964
|
static addNode(t, e) {
|
|
2532
|
-
const
|
|
2533
|
-
if (
|
|
2965
|
+
const r = A.get(t);
|
|
2966
|
+
if (r.isSkipMutationNodes())
|
|
2534
2967
|
return;
|
|
2535
|
-
const
|
|
2536
|
-
|
|
2968
|
+
const i = A.get(e.nextSibling), s = A.get(e);
|
|
2969
|
+
s && (r.insertBefore(s, i), s instanceof S ? m.scan(s.getTarget()) : s instanceof j && m.evaluateText(s));
|
|
2537
2970
|
}
|
|
2538
2971
|
/**
|
|
2539
2972
|
* ノードを親要素から削除します。
|
|
@@ -2543,8 +2976,8 @@ const g = class g {
|
|
|
2543
2976
|
static removeNode(t) {
|
|
2544
2977
|
const e = A.get(t);
|
|
2545
2978
|
if (e) {
|
|
2546
|
-
const
|
|
2547
|
-
if (
|
|
2979
|
+
const r = e.getParent();
|
|
2980
|
+
if (r && r.isSkipMutationNodes())
|
|
2548
2981
|
return;
|
|
2549
2982
|
e.remove();
|
|
2550
2983
|
}
|
|
@@ -2556,8 +2989,8 @@ const g = class g {
|
|
|
2556
2989
|
* @param text 新しいテキスト
|
|
2557
2990
|
*/
|
|
2558
2991
|
static changeText(t, e) {
|
|
2559
|
-
const
|
|
2560
|
-
|
|
2992
|
+
const r = A.get(t);
|
|
2993
|
+
r && r.setContent(e);
|
|
2561
2994
|
}
|
|
2562
2995
|
/**
|
|
2563
2996
|
* エレメントの値を変更します。
|
|
@@ -2568,18 +3001,18 @@ const g = class g {
|
|
|
2568
3001
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
2569
3002
|
*/
|
|
2570
3003
|
static changeValue(t, e) {
|
|
2571
|
-
const
|
|
2572
|
-
if (
|
|
3004
|
+
const r = A.get(t);
|
|
3005
|
+
if (r.getValue() === e)
|
|
2573
3006
|
return Promise.resolve();
|
|
2574
|
-
const
|
|
2575
|
-
|
|
2576
|
-
const
|
|
2577
|
-
if (
|
|
2578
|
-
const n =
|
|
2579
|
-
let
|
|
2580
|
-
a ? (
|
|
3007
|
+
const i = [];
|
|
3008
|
+
i.push(r.setValue(e));
|
|
3009
|
+
const s = m.getFormFragment(r);
|
|
3010
|
+
if (s) {
|
|
3011
|
+
const n = y.getValues(s), a = s.getAttribute(`${c.prefix}form-arg`);
|
|
3012
|
+
let o;
|
|
3013
|
+
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(m.setBindingData(s.getTarget(), o));
|
|
2581
3014
|
}
|
|
2582
|
-
return Promise.all(
|
|
3015
|
+
return Promise.all(i).then(() => {
|
|
2583
3016
|
});
|
|
2584
3017
|
}
|
|
2585
3018
|
/**
|
|
@@ -2592,7 +3025,7 @@ const g = class g {
|
|
|
2592
3025
|
if (t.getTarget() instanceof HTMLFormElement)
|
|
2593
3026
|
return t;
|
|
2594
3027
|
const e = t.getParent();
|
|
2595
|
-
return e ?
|
|
3028
|
+
return e ? m.getFormFragment(e) : null;
|
|
2596
3029
|
}
|
|
2597
3030
|
/**
|
|
2598
3031
|
* フラグメントとその子要素を評価します。
|
|
@@ -2602,8 +3035,8 @@ const g = class g {
|
|
|
2602
3035
|
*/
|
|
2603
3036
|
static evaluateAll(t) {
|
|
2604
3037
|
const e = [];
|
|
2605
|
-
return t.hasAttribute(`${c.prefix}if`) && e.push(
|
|
2606
|
-
|
|
3038
|
+
return t.hasAttribute(`${c.prefix}if`) && e.push(m.evaluateIf(t)), t.hasAttribute(`${c.prefix}each`) && e.push(m.evaluateEach(t)), t.getChildren().forEach((r) => {
|
|
3039
|
+
r instanceof S ? e.push(m.evaluateAll(r)) : r instanceof j && e.push(m.evaluateText(r));
|
|
2607
3040
|
}), Promise.all(e).then(() => {
|
|
2608
3041
|
});
|
|
2609
3042
|
}
|
|
@@ -2624,16 +3057,16 @@ const g = class g {
|
|
|
2624
3057
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
2625
3058
|
*/
|
|
2626
3059
|
static evaluateIf(t) {
|
|
2627
|
-
const e = [],
|
|
2628
|
-
return
|
|
3060
|
+
const e = [], r = t.getAttribute(`${c.prefix}if`);
|
|
3061
|
+
return r === !1 || r === void 0 || r === null || Number.isNaN(r) ? t.isVisible() && e.push(
|
|
2629
3062
|
t.hide().then(() => {
|
|
2630
|
-
|
|
3063
|
+
E.hide(t.getTarget());
|
|
2631
3064
|
})
|
|
2632
3065
|
) : t.isVisible() || (e.push(
|
|
2633
3066
|
t.show().then(() => {
|
|
2634
|
-
|
|
3067
|
+
E.show(t.getTarget());
|
|
2635
3068
|
})
|
|
2636
|
-
), e.push(
|
|
3069
|
+
), e.push(m.evaluateAll(t))), Promise.all(e).then(() => {
|
|
2637
3070
|
});
|
|
2638
3071
|
}
|
|
2639
3072
|
/**
|
|
@@ -2647,30 +3080,21 @@ const g = class g {
|
|
|
2647
3080
|
return Promise.resolve();
|
|
2648
3081
|
let e = t.getTemplate();
|
|
2649
3082
|
if (e === null) {
|
|
2650
|
-
|
|
3083
|
+
let i = !1;
|
|
2651
3084
|
t.getChildren().forEach((n) => {
|
|
2652
|
-
if (n instanceof
|
|
3085
|
+
if (!i && n instanceof S) {
|
|
2653
3086
|
if (n.hasAttribute(`${c.prefix}each-before`) || n.hasAttribute(`${c.prefix}each-after`))
|
|
2654
3087
|
return;
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
a.parentNode && r.push(
|
|
2659
|
-
v.enqueue(() => {
|
|
2660
|
-
a.parentNode && a.parentNode.removeChild(a), n.setMounted(!1);
|
|
2661
|
-
})
|
|
2662
|
-
);
|
|
2663
|
-
} else
|
|
2664
|
-
h.warn("[Haori]", "Template must be a single child element.");
|
|
3088
|
+
e = n.clone(), t.setTemplate(e), i = !0, t.removeChild(n);
|
|
3089
|
+
const a = n.getTarget();
|
|
3090
|
+
a.parentNode && a.parentNode.removeChild(a), n.setMounted(!1);
|
|
2665
3091
|
}
|
|
2666
|
-
})
|
|
2667
|
-
const
|
|
2668
|
-
return Array.isArray(
|
|
2669
|
-
() => this.updateDiff(t, i)
|
|
2670
|
-
) : (h.error("[Haori]", "Invalid each attribute:", i), Promise.reject(new Error("Invalid each attribute.")));
|
|
3092
|
+
});
|
|
3093
|
+
const s = t.getAttribute(`${c.prefix}each`);
|
|
3094
|
+
return Array.isArray(s) ? this.updateDiff(t, s) : (h.error("[Haori]", "Invalid each attribute:", s), Promise.reject(new Error("Invalid each attribute.")));
|
|
2671
3095
|
}
|
|
2672
|
-
const
|
|
2673
|
-
return Array.isArray(
|
|
3096
|
+
const r = t.getAttribute(`${c.prefix}each`);
|
|
3097
|
+
return Array.isArray(r) ? this.updateDiff(t, r) : (h.error("[Haori]", "Invalid each attribute:", r), Promise.reject(new Error("Invalid each attribute.")));
|
|
2674
3098
|
}
|
|
2675
3099
|
/**
|
|
2676
3100
|
* 差分を更新します。
|
|
@@ -2679,55 +3103,69 @@ const g = class g {
|
|
|
2679
3103
|
* @param newList 新しいリスト
|
|
2680
3104
|
*/
|
|
2681
3105
|
static updateDiff(t, e) {
|
|
2682
|
-
const
|
|
2683
|
-
if (
|
|
3106
|
+
const r = t.getTemplate();
|
|
3107
|
+
if (r === null)
|
|
2684
3108
|
return h.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
2685
|
-
let
|
|
2686
|
-
|
|
2687
|
-
const
|
|
3109
|
+
let i = t.getAttribute(`${c.prefix}each-index`);
|
|
3110
|
+
i && (i = String(i));
|
|
3111
|
+
const s = t.getAttribute(`${c.prefix}each-key`), n = t.getAttribute(`${c.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
2688
3112
|
e.forEach((p, w) => {
|
|
2689
|
-
const
|
|
3113
|
+
const v = m.createListKey(
|
|
2690
3114
|
p,
|
|
2691
|
-
|
|
3115
|
+
s ? String(s) : null,
|
|
2692
3116
|
w
|
|
2693
3117
|
);
|
|
2694
|
-
|
|
3118
|
+
o.push(v), a.set(v, { item: p, itemIndex: w });
|
|
2695
3119
|
});
|
|
2696
|
-
const
|
|
2697
|
-
let
|
|
3120
|
+
const g = [];
|
|
3121
|
+
let u = t.getChildren().filter((p) => p instanceof S).filter(
|
|
2698
3122
|
(p) => !p.hasAttribute(`${c.prefix}each-before`) && !p.hasAttribute(`${c.prefix}each-after`)
|
|
2699
3123
|
);
|
|
2700
|
-
|
|
2701
|
-
const b =
|
|
2702
|
-
let
|
|
2703
|
-
return
|
|
2704
|
-
const
|
|
2705
|
-
let
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
3124
|
+
u = u.filter((p) => o.indexOf(String(p.getListKey())) === -1 ? (g.push(p.remove()), !1) : !0);
|
|
3125
|
+
const b = u.map((p) => p.getListKey()), l = t.getChildren().filter((p) => p instanceof S).filter((p) => p.hasAttribute(`${c.prefix}each-before`)).length;
|
|
3126
|
+
let f = Promise.resolve();
|
|
3127
|
+
return o.forEach((p, w) => {
|
|
3128
|
+
const v = b.indexOf(p), { item: B, itemIndex: x } = a.get(p);
|
|
3129
|
+
let F;
|
|
3130
|
+
if (v !== -1)
|
|
3131
|
+
F = u[v], m.updateRowFragment(
|
|
3132
|
+
F,
|
|
3133
|
+
B,
|
|
3134
|
+
i,
|
|
3135
|
+
x,
|
|
3136
|
+
n ? String(n) : null,
|
|
3137
|
+
p
|
|
3138
|
+
), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache(), f = f.then(() => m.evaluateAll(F));
|
|
3139
|
+
else {
|
|
3140
|
+
F = r.clone(), m.updateRowFragment(
|
|
3141
|
+
F,
|
|
3142
|
+
B,
|
|
3143
|
+
i,
|
|
3144
|
+
x,
|
|
3145
|
+
n ? String(n) : null,
|
|
3146
|
+
p
|
|
3147
|
+
), typeof F.clearBindingDataCache == "function" && F.clearBindingDataCache();
|
|
3148
|
+
const W = l + w;
|
|
3149
|
+
f = f.then(
|
|
3150
|
+
() => t.insertBefore(
|
|
3151
|
+
F,
|
|
3152
|
+
t.getChildren()[W] || null
|
|
3153
|
+
).then(() => m.evaluateAll(F))
|
|
3154
|
+
);
|
|
3155
|
+
}
|
|
3156
|
+
}), Promise.all(g).then(() => f).then(() => {
|
|
3157
|
+
const p = o.filter(
|
|
2720
3158
|
(x) => x !== null
|
|
2721
3159
|
), w = b.filter(
|
|
2722
3160
|
(x) => x !== null
|
|
2723
|
-
),
|
|
3161
|
+
), v = p.filter(
|
|
2724
3162
|
(x) => !w.includes(x)
|
|
2725
3163
|
), B = w.filter(
|
|
2726
3164
|
(x) => !p.includes(x)
|
|
2727
3165
|
);
|
|
2728
|
-
|
|
3166
|
+
E.eachUpdate(
|
|
2729
3167
|
t.getTarget(),
|
|
2730
|
-
|
|
3168
|
+
v,
|
|
2731
3169
|
B,
|
|
2732
3170
|
p
|
|
2733
3171
|
);
|
|
@@ -2741,17 +3179,17 @@ const g = class g {
|
|
|
2741
3179
|
* @param index 配列のインデックス
|
|
2742
3180
|
* @returns リストキー
|
|
2743
3181
|
*/
|
|
2744
|
-
static createListKey(t, e,
|
|
2745
|
-
let
|
|
3182
|
+
static createListKey(t, e, r) {
|
|
3183
|
+
let i;
|
|
2746
3184
|
if (typeof t == "object" && t !== null)
|
|
2747
3185
|
if (e) {
|
|
2748
|
-
const
|
|
2749
|
-
|
|
3186
|
+
const s = t[e];
|
|
3187
|
+
s == null ? i = `__index_${r}` : typeof s == "object" ? i = JSON.stringify(s) : i = String(s);
|
|
2750
3188
|
} else
|
|
2751
|
-
|
|
3189
|
+
i = `__index_${r}`;
|
|
2752
3190
|
else
|
|
2753
|
-
|
|
2754
|
-
return
|
|
3191
|
+
i = String(t);
|
|
3192
|
+
return i;
|
|
2755
3193
|
}
|
|
2756
3194
|
/**
|
|
2757
3195
|
* 行フラグメントにデータを設定します。
|
|
@@ -2763,16 +3201,16 @@ const g = class g {
|
|
|
2763
3201
|
* @param arg バインドデータパラメータ名
|
|
2764
3202
|
* @param listKey リストキー
|
|
2765
3203
|
*/
|
|
2766
|
-
static updateRowFragment(t, e,
|
|
3204
|
+
static updateRowFragment(t, e, r, i, s, n) {
|
|
2767
3205
|
let a = e;
|
|
2768
3206
|
if (typeof e == "object" && e !== null)
|
|
2769
|
-
a = { ...e },
|
|
2770
|
-
[
|
|
3207
|
+
a = { ...e }, r && (a[r] = i), s && (a = {
|
|
3208
|
+
[s]: a
|
|
2771
3209
|
});
|
|
2772
|
-
else if (
|
|
3210
|
+
else if (s)
|
|
2773
3211
|
a = {
|
|
2774
|
-
[
|
|
2775
|
-
},
|
|
3212
|
+
[s]: e
|
|
3213
|
+
}, r && (a[r] = i);
|
|
2776
3214
|
else {
|
|
2777
3215
|
h.error(
|
|
2778
3216
|
"[Haori]",
|
|
@@ -2783,9 +3221,9 @@ const g = class g {
|
|
|
2783
3221
|
t.setListKey(n), t.setAttribute(`${c.prefix}row`, n), t.setBindingData(a);
|
|
2784
3222
|
}
|
|
2785
3223
|
};
|
|
2786
|
-
|
|
2787
|
-
let N =
|
|
2788
|
-
class
|
|
3224
|
+
m.PRIORITY_ATTRIBUTE_SUFFIXES = ["bind", "if", "each"], m.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch", "url-param"];
|
|
3225
|
+
let N = m;
|
|
3226
|
+
class z {
|
|
2789
3227
|
/**
|
|
2790
3228
|
* コンストラクタ。
|
|
2791
3229
|
*
|
|
@@ -2793,8 +3231,8 @@ class Y {
|
|
|
2793
3231
|
*/
|
|
2794
3232
|
constructor(t = document) {
|
|
2795
3233
|
this.onClick = (e) => this.delegate(e, "click"), this.onChange = (e) => this.delegate(e, "change"), this.onLoadCapture = (e) => this.delegate(e, "load"), this.onWindowLoad = () => {
|
|
2796
|
-
const e = document.documentElement,
|
|
2797
|
-
|
|
3234
|
+
const e = document.documentElement, r = A.get(e);
|
|
3235
|
+
r && new d(r, "load").run();
|
|
2798
3236
|
}, this.root = t;
|
|
2799
3237
|
}
|
|
2800
3238
|
/**
|
|
@@ -2817,12 +3255,12 @@ class Y {
|
|
|
2817
3255
|
* @param type イベントタイプ('click', 'change', 'load'など)
|
|
2818
3256
|
*/
|
|
2819
3257
|
delegate(t, e) {
|
|
2820
|
-
const
|
|
2821
|
-
if (!
|
|
3258
|
+
const r = this.getElementFromTarget(t.target);
|
|
3259
|
+
if (!r)
|
|
2822
3260
|
return;
|
|
2823
|
-
const
|
|
2824
|
-
|
|
2825
|
-
h.error("[Haori]", "Procedure execution error:",
|
|
3261
|
+
const i = A.get(r);
|
|
3262
|
+
i && (e === "change" && i instanceof S && i.syncValue(), new d(i, e).run().catch((s) => {
|
|
3263
|
+
h.error("[Haori]", "Procedure execution error:", s);
|
|
2826
3264
|
}));
|
|
2827
3265
|
}
|
|
2828
3266
|
/**
|
|
@@ -2835,17 +3273,20 @@ class Y {
|
|
|
2835
3273
|
return t ? t instanceof HTMLElement ? t : t instanceof Node ? t.parentElement : null : null;
|
|
2836
3274
|
}
|
|
2837
3275
|
}
|
|
2838
|
-
class
|
|
3276
|
+
const C = class C {
|
|
2839
3277
|
/**
|
|
2840
3278
|
* 初期化メソッド。
|
|
2841
3279
|
* ドキュメントのheadとbodyを監視対象として設定します。
|
|
2842
3280
|
*/
|
|
2843
3281
|
static async init() {
|
|
3282
|
+
if (C._initialized)
|
|
3283
|
+
return;
|
|
3284
|
+
C._initialized = !0;
|
|
2844
3285
|
const t = await Promise.allSettled([
|
|
2845
3286
|
N.scan(document.head),
|
|
2846
3287
|
N.scan(document.body)
|
|
2847
|
-
]), [e,
|
|
2848
|
-
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason),
|
|
3288
|
+
]), [e, r] = t;
|
|
3289
|
+
e.status !== "fulfilled" && h.error("[Haori]", "Failed to build head fragment:", e.reason), r.status !== "fulfilled" && h.error("[Haori]", "Failed to build body fragment:", r.reason), C.observe(document.head), C.observe(document.body), new z().start();
|
|
2849
3290
|
}
|
|
2850
3291
|
/**
|
|
2851
3292
|
* 指定された要素を監視します。
|
|
@@ -2853,22 +3294,22 @@ class O {
|
|
|
2853
3294
|
* @param root 監視対象の要素
|
|
2854
3295
|
*/
|
|
2855
3296
|
static observe(t) {
|
|
2856
|
-
new MutationObserver(async (
|
|
2857
|
-
for (const
|
|
3297
|
+
new MutationObserver(async (r) => {
|
|
3298
|
+
for (const i of r)
|
|
2858
3299
|
try {
|
|
2859
|
-
switch (
|
|
3300
|
+
switch (i.type) {
|
|
2860
3301
|
case "attributes": {
|
|
2861
3302
|
h.info(
|
|
2862
3303
|
"[Haori]",
|
|
2863
3304
|
"Attribute changed:",
|
|
2864
|
-
|
|
2865
|
-
|
|
3305
|
+
i.target,
|
|
3306
|
+
i.attributeName
|
|
2866
3307
|
);
|
|
2867
|
-
const
|
|
3308
|
+
const s = i.target;
|
|
2868
3309
|
N.setAttribute(
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
3310
|
+
s,
|
|
3311
|
+
i.attributeName,
|
|
3312
|
+
s.getAttribute(i.attributeName)
|
|
2872
3313
|
);
|
|
2873
3314
|
break;
|
|
2874
3315
|
}
|
|
@@ -2876,12 +3317,12 @@ class O {
|
|
|
2876
3317
|
h.info(
|
|
2877
3318
|
"[Haori]",
|
|
2878
3319
|
"Child list changed:",
|
|
2879
|
-
Array.from(
|
|
2880
|
-
Array.from(
|
|
2881
|
-
), Array.from(
|
|
2882
|
-
N.removeNode(
|
|
2883
|
-
}), Array.from(
|
|
2884
|
-
|
|
3320
|
+
Array.from(i.removedNodes).map((s) => s.nodeName),
|
|
3321
|
+
Array.from(i.addedNodes).map((s) => s.nodeName)
|
|
3322
|
+
), Array.from(i.removedNodes).forEach((s) => {
|
|
3323
|
+
N.removeNode(s);
|
|
3324
|
+
}), Array.from(i.addedNodes).forEach((s) => {
|
|
3325
|
+
s.parentElement instanceof HTMLElement && N.addNode(s.parentElement, s);
|
|
2885
3326
|
});
|
|
2886
3327
|
break;
|
|
2887
3328
|
}
|
|
@@ -2889,21 +3330,21 @@ class O {
|
|
|
2889
3330
|
h.info(
|
|
2890
3331
|
"[Haori]",
|
|
2891
3332
|
"Character data changed:",
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
),
|
|
3333
|
+
i.target,
|
|
3334
|
+
i.target.textContent
|
|
3335
|
+
), i.target instanceof Text || i.target instanceof Comment ? N.changeText(i.target, i.target.textContent) : h.warn(
|
|
2895
3336
|
"[Haori]",
|
|
2896
3337
|
"Unsupported character data type:",
|
|
2897
|
-
|
|
3338
|
+
i.target
|
|
2898
3339
|
);
|
|
2899
3340
|
break;
|
|
2900
3341
|
}
|
|
2901
3342
|
default:
|
|
2902
|
-
h.warn("[Haori]", "Unknown mutation type:",
|
|
3343
|
+
h.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
2903
3344
|
continue;
|
|
2904
3345
|
}
|
|
2905
|
-
} catch (
|
|
2906
|
-
h.error("[Haori]", "Error processing mutation:",
|
|
3346
|
+
} catch (s) {
|
|
3347
|
+
h.error("[Haori]", "Error processing mutation:", s);
|
|
2907
3348
|
}
|
|
2908
3349
|
}).observe(t, {
|
|
2909
3350
|
childList: !0,
|
|
@@ -2912,17 +3353,19 @@ class O {
|
|
|
2912
3353
|
characterData: !0
|
|
2913
3354
|
}), h.info("[Haori]", "Observer initialized for", t);
|
|
2914
3355
|
}
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
|
-
|
|
3356
|
+
};
|
|
3357
|
+
C._initialized = !1;
|
|
3358
|
+
let V = C;
|
|
3359
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", V.init) : V.init();
|
|
3360
|
+
const Q = "0.1.2";
|
|
2918
3361
|
export {
|
|
2919
3362
|
N as Core,
|
|
2920
3363
|
c as Env,
|
|
2921
|
-
|
|
3364
|
+
y as Form,
|
|
2922
3365
|
A as Fragment,
|
|
2923
3366
|
M as Haori,
|
|
2924
3367
|
h as Log,
|
|
2925
|
-
|
|
3368
|
+
T as Queue,
|
|
2926
3369
|
M as default,
|
|
2927
3370
|
Q as version
|
|
2928
3371
|
};
|