haori 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/haori.cjs.js +11 -11
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +727 -650
- package/dist/haori.es.js.map +1 -1
- package/dist/haori.iife.js +11 -11
- package/dist/haori.iife.js.map +1 -1
- package/dist/index.d.ts +46 -2
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts +45 -1
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +103 -10
- package/dist/src/core.js.map +1 -1
- package/dist/src/event.d.ts +12 -0
- package/dist/src/event.d.ts.map +1 -1
- package/dist/src/event.js +14 -0
- package/dist/src/event.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/procedure.d.ts +5 -0
- package/dist/src/procedure.d.ts.map +1 -1
- package/dist/src/procedure.js +21 -2
- package/dist/src/procedure.js.map +1 -1
- package/dist/tests/data-bind-arg-reeval.test.d.ts +2 -0
- package/dist/tests/data-bind-arg-reeval.test.d.ts.map +1 -0
- package/dist/tests/data-bind-arg-reeval.test.js +119 -0
- package/dist/tests/data-bind-arg-reeval.test.js.map +1 -0
- package/dist/tests/data-bind-merge.test.d.ts +2 -0
- package/dist/tests/data-bind-merge.test.d.ts.map +1 -0
- package/dist/tests/data-bind-merge.test.js +86 -0
- package/dist/tests/data-bind-merge.test.js.map +1 -0
- package/dist/tests/data-if-falsy.test.d.ts +2 -0
- package/dist/tests/data-if-falsy.test.d.ts.map +1 -0
- package/dist/tests/data-if-falsy.test.js +73 -0
- package/dist/tests/data-if-falsy.test.js.map +1 -0
- package/dist/tests/data-load-on-show.test.d.ts +2 -0
- package/dist/tests/data-load-on-show.test.d.ts.map +1 -0
- package/dist/tests/data-load-on-show.test.js +98 -0
- package/dist/tests/data-load-on-show.test.js.map +1 -0
- package/dist/tests/each-update-event.test.d.ts +2 -0
- package/dist/tests/each-update-event.test.d.ts.map +1 -0
- package/dist/tests/each-update-event.test.js +83 -0
- package/dist/tests/each-update-event.test.js.map +1 -0
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const z = class z {
|
|
2
2
|
/**
|
|
3
3
|
* 開発モードの状態を取得します。
|
|
4
4
|
*
|
|
5
5
|
* @returns 開発モードならtrue、そうでなければfalse
|
|
6
6
|
*/
|
|
7
7
|
static isEnabled() {
|
|
8
|
-
return
|
|
8
|
+
return z.devMode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 開発モードを有効化します。
|
|
12
12
|
*/
|
|
13
13
|
static enable() {
|
|
14
|
-
|
|
14
|
+
z.devMode = !0;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* 開発モードを無効化します。
|
|
18
18
|
*/
|
|
19
19
|
static disable() {
|
|
20
|
-
|
|
20
|
+
z.devMode = !1;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 開発モードを切り替えます。
|
|
@@ -25,17 +25,17 @@ const q = class q {
|
|
|
25
25
|
* @param enabled trueで有効化、falseで無効化
|
|
26
26
|
*/
|
|
27
27
|
static set(e) {
|
|
28
|
-
|
|
28
|
+
z.devMode = e;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
let
|
|
31
|
+
z.devMode = !1;
|
|
32
|
+
let L = z;
|
|
33
33
|
const se = "embedded";
|
|
34
|
-
function ue(
|
|
35
|
-
return
|
|
34
|
+
function ue(S) {
|
|
35
|
+
return S === "embedded" || S === "demo";
|
|
36
36
|
}
|
|
37
|
-
function he(
|
|
38
|
-
return
|
|
37
|
+
function he(S) {
|
|
38
|
+
return S === null ? null : ue(S) ? S : se;
|
|
39
39
|
}
|
|
40
40
|
const $ = class $ {
|
|
41
41
|
/**
|
|
@@ -73,15 +73,15 @@ const $ = class $ {
|
|
|
73
73
|
i !== null && ($._runtime = i);
|
|
74
74
|
}
|
|
75
75
|
if (e instanceof HTMLScriptElement && e.hasAttribute(`${$._prefix}dev`)) {
|
|
76
|
-
|
|
76
|
+
L.set(!0);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const t = window.location.hostname;
|
|
80
80
|
if (t === "localhost" || t.endsWith(".localhost") || t === "127.0.0.1" || t === "::1" || t.endsWith(".local")) {
|
|
81
|
-
|
|
81
|
+
L.set(!0);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
L.set(!1);
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -95,9 +95,9 @@ const $ = class $ {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
$._prefix = "data-", $._runtime = se;
|
|
98
|
-
let
|
|
99
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
100
|
-
class
|
|
98
|
+
let u = $;
|
|
99
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", u.detect) : u.detect();
|
|
100
|
+
class p {
|
|
101
101
|
/**
|
|
102
102
|
* 開発モードでのみコンソールに情報を出力します。
|
|
103
103
|
*
|
|
@@ -105,7 +105,7 @@ class g {
|
|
|
105
105
|
* @param args 追加の引数
|
|
106
106
|
*/
|
|
107
107
|
static info(e, ...t) {
|
|
108
|
-
|
|
108
|
+
L.isEnabled() && console.log && console.log(e, ...t);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* 開発モードでのみコンソールに警告を出力します。
|
|
@@ -114,7 +114,7 @@ class g {
|
|
|
114
114
|
* @param args 追加の引数
|
|
115
115
|
*/
|
|
116
116
|
static warn(e, ...t) {
|
|
117
|
-
|
|
117
|
+
L.isEnabled() && console.warn && console.warn(e, ...t);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* モードに関係なくコンソールにエラーを出力します。
|
|
@@ -126,7 +126,7 @@ class g {
|
|
|
126
126
|
console.error(e, ...t);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
const
|
|
129
|
+
const I = class I {
|
|
130
130
|
/**
|
|
131
131
|
* 明示バインド内に持ち込まれてはならない危険値を返します。
|
|
132
132
|
*
|
|
@@ -197,18 +197,18 @@ const C = class C {
|
|
|
197
197
|
*/
|
|
198
198
|
static evaluateDetailed(e, t = {}) {
|
|
199
199
|
if (this.scheduleForbiddenBindingValueCacheReset(), e.trim() === "")
|
|
200
|
-
return
|
|
200
|
+
return p.warn("[Haori]", e, "Expression is empty"), { value: null, unresolvedReference: !1 };
|
|
201
201
|
if (this.containsDangerousPatterns(e))
|
|
202
|
-
return
|
|
202
|
+
return p.warn("[Haori]", e, "Expression contains dangerous patterns"), { value: null, unresolvedReference: !1 };
|
|
203
203
|
if (this.containsForbiddenKeys(t))
|
|
204
|
-
return
|
|
204
|
+
return p.warn("[Haori]", t, "Binded values contain forbidden keys"), { value: null, unresolvedReference: !1 };
|
|
205
205
|
const r = this.getForbiddenBindingValueSet();
|
|
206
206
|
if (this.containsForbiddenBindingValues(
|
|
207
207
|
t,
|
|
208
208
|
/* @__PURE__ */ new WeakSet(),
|
|
209
209
|
r
|
|
210
210
|
))
|
|
211
|
-
return
|
|
211
|
+
return p.warn(
|
|
212
212
|
"[Haori]",
|
|
213
213
|
t,
|
|
214
214
|
"Binded values contain forbidden values"
|
|
@@ -236,10 +236,10 @@ const C = class C {
|
|
|
236
236
|
continue;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
return
|
|
239
|
+
return p.error("[Haori]", "Expression evaluation error:", e, o), o instanceof ReferenceError ? { value: void 0, unresolvedReference: !0 } : { value: null, unresolvedReference: !1 };
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
return
|
|
242
|
+
return p.error(
|
|
243
243
|
"[Haori]",
|
|
244
244
|
"Failed to recover missing identifiers:",
|
|
245
245
|
e,
|
|
@@ -273,7 +273,7 @@ return (${e});`;
|
|
|
273
273
|
compileFailed: !1
|
|
274
274
|
};
|
|
275
275
|
} catch (o) {
|
|
276
|
-
return
|
|
276
|
+
return p.error(
|
|
277
277
|
"[Haori]",
|
|
278
278
|
"Failed to compile expression:",
|
|
279
279
|
e,
|
|
@@ -755,7 +755,7 @@ return (${e});`;
|
|
|
755
755
|
return this.forbiddenBindingValueCache.set(e, !1), !1;
|
|
756
756
|
}
|
|
757
757
|
};
|
|
758
|
-
|
|
758
|
+
I.MAX_IDENTIFIER_RECOVERY_COUNT = 8, I.forbiddenBindingValueCache = /* @__PURE__ */ new WeakMap(), I.forbiddenBindingValueCacheResetScheduled = !1, I.FORBIDDEN_NAMES = [
|
|
759
759
|
// グローバルオブジェクト
|
|
760
760
|
"window",
|
|
761
761
|
"self",
|
|
@@ -787,23 +787,23 @@ C.MAX_IDENTIFIER_RECOVERY_COUNT = 8, C.forbiddenBindingValueCache = /* @__PURE__
|
|
|
787
787
|
"sessionStorage",
|
|
788
788
|
"IndexedDB",
|
|
789
789
|
"history"
|
|
790
|
-
],
|
|
791
|
-
...
|
|
792
|
-
(e) => !
|
|
790
|
+
], I.STRICT_FORBIDDEN_NAMES = ["eval", "arguments"], I.REBINDABLE_FORBIDDEN_NAMES = /* @__PURE__ */ new Set(["location"]), I.FORBIDDEN_BINDING_NAMES = /* @__PURE__ */ new Set([
|
|
791
|
+
...I.FORBIDDEN_NAMES.filter(
|
|
792
|
+
(e) => !I.REBINDABLE_FORBIDDEN_NAMES.has(e)
|
|
793
793
|
),
|
|
794
794
|
"constructor",
|
|
795
795
|
"__proto__",
|
|
796
796
|
"prototype",
|
|
797
|
-
...
|
|
798
|
-
]),
|
|
797
|
+
...I.STRICT_FORBIDDEN_NAMES
|
|
798
|
+
]), I.FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
799
799
|
"constructor",
|
|
800
800
|
"__proto__",
|
|
801
801
|
"prototype"
|
|
802
|
-
]),
|
|
802
|
+
]), I.OBJECT_PROPERTY_MODIFIERS = /* @__PURE__ */ new Set([
|
|
803
803
|
"get",
|
|
804
804
|
"set",
|
|
805
805
|
"async"
|
|
806
|
-
]),
|
|
806
|
+
]), I.DISALLOWED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
807
807
|
"await",
|
|
808
808
|
"break",
|
|
809
809
|
"case",
|
|
@@ -837,8 +837,8 @@ C.MAX_IDENTIFIER_RECOVERY_COUNT = 8, C.forbiddenBindingValueCache = /* @__PURE__
|
|
|
837
837
|
"while",
|
|
838
838
|
"with",
|
|
839
839
|
"yield"
|
|
840
|
-
]),
|
|
841
|
-
let
|
|
840
|
+
]), I.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
841
|
+
let Y = I;
|
|
842
842
|
class de {
|
|
843
843
|
constructor() {
|
|
844
844
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
@@ -881,13 +881,13 @@ class de {
|
|
|
881
881
|
const r = await t.task();
|
|
882
882
|
t.resolve(r);
|
|
883
883
|
} catch (r) {
|
|
884
|
-
t.reject(r),
|
|
884
|
+
t.reject(r), p.error("[Haori]", `Task ${t.timestamp} failed:`, r);
|
|
885
885
|
}
|
|
886
886
|
if (performance.now() - e > this.MAX_BUDGET)
|
|
887
887
|
break;
|
|
888
888
|
}
|
|
889
889
|
} catch (e) {
|
|
890
|
-
|
|
890
|
+
p.error("[Haori]", "Error processing queue:", e);
|
|
891
891
|
} finally {
|
|
892
892
|
this.processing = !1, this.queue.length > 0 && this.scheduleProcessing();
|
|
893
893
|
}
|
|
@@ -934,7 +934,7 @@ const oe = class oe {
|
|
|
934
934
|
}
|
|
935
935
|
};
|
|
936
936
|
oe.ASYNC_QUEUE = new de();
|
|
937
|
-
let
|
|
937
|
+
let M = oe;
|
|
938
938
|
class te {
|
|
939
939
|
/**
|
|
940
940
|
* 実行モードを取得します。
|
|
@@ -942,7 +942,7 @@ class te {
|
|
|
942
942
|
* @return 実行モード。
|
|
943
943
|
*/
|
|
944
944
|
static get runtime() {
|
|
945
|
-
return
|
|
945
|
+
return u.runtime;
|
|
946
946
|
}
|
|
947
947
|
/**
|
|
948
948
|
* 実行モードを設定します。
|
|
@@ -951,7 +951,7 @@ class te {
|
|
|
951
951
|
* @return 戻り値はありません。
|
|
952
952
|
*/
|
|
953
953
|
static setRuntime(e) {
|
|
954
|
-
|
|
954
|
+
u.setRuntime(e);
|
|
955
955
|
}
|
|
956
956
|
/**
|
|
957
957
|
* 通知ダイアログを表示します。
|
|
@@ -960,7 +960,7 @@ class te {
|
|
|
960
960
|
* @returns 通知が閉じられると解決されるPromise
|
|
961
961
|
*/
|
|
962
962
|
static dialog(e) {
|
|
963
|
-
return
|
|
963
|
+
return M.enqueue(() => {
|
|
964
964
|
window.alert(e);
|
|
965
965
|
}, !0);
|
|
966
966
|
}
|
|
@@ -988,7 +988,7 @@ class te {
|
|
|
988
988
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
989
989
|
*/
|
|
990
990
|
static confirm(e) {
|
|
991
|
-
return
|
|
991
|
+
return M.enqueue(() => window.confirm(e), !0);
|
|
992
992
|
}
|
|
993
993
|
/**
|
|
994
994
|
* ダイアログを開きます。
|
|
@@ -996,8 +996,8 @@ class te {
|
|
|
996
996
|
* @param element 開くダイアログのHTML要素
|
|
997
997
|
*/
|
|
998
998
|
static openDialog(e) {
|
|
999
|
-
return
|
|
1000
|
-
e instanceof HTMLDialogElement ? e.showModal() :
|
|
999
|
+
return M.enqueue(() => {
|
|
1000
|
+
e instanceof HTMLDialogElement ? e.showModal() : p.error("[Haori]", "Element is not a dialog: ", e);
|
|
1001
1001
|
}, !0);
|
|
1002
1002
|
}
|
|
1003
1003
|
/**
|
|
@@ -1006,8 +1006,8 @@ class te {
|
|
|
1006
1006
|
* @param element 閉じるダイアログのHTML要素
|
|
1007
1007
|
*/
|
|
1008
1008
|
static closeDialog(e) {
|
|
1009
|
-
return
|
|
1010
|
-
e instanceof HTMLDialogElement ? e.close() :
|
|
1009
|
+
return M.enqueue(() => {
|
|
1010
|
+
e instanceof HTMLDialogElement ? e.close() : p.error("[Haori]", "Element is not a dialog: ", e);
|
|
1011
1011
|
}, !0);
|
|
1012
1012
|
}
|
|
1013
1013
|
/**
|
|
@@ -1027,7 +1027,7 @@ class te {
|
|
|
1027
1027
|
* @param level メッセージのレベル(省略可能)
|
|
1028
1028
|
*/
|
|
1029
1029
|
static addMessage(e, t, r) {
|
|
1030
|
-
return
|
|
1030
|
+
return M.enqueue(() => {
|
|
1031
1031
|
const i = e instanceof HTMLFormElement ? e : e.parentElement ?? e;
|
|
1032
1032
|
i.setAttribute("data-message", t), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
1033
1033
|
}, !0);
|
|
@@ -1038,7 +1038,7 @@ class te {
|
|
|
1038
1038
|
* @param parent メッセージをクリアする親要素
|
|
1039
1039
|
*/
|
|
1040
1040
|
static clearMessages(e) {
|
|
1041
|
-
return
|
|
1041
|
+
return M.enqueue(() => {
|
|
1042
1042
|
e.removeAttribute("data-message"), e.removeAttribute("data-message-level"), e.querySelectorAll("[data-message]").forEach((t) => {
|
|
1043
1043
|
t.removeAttribute("data-message"), t.removeAttribute("data-message-level");
|
|
1044
1044
|
});
|
|
@@ -1052,7 +1052,7 @@ function le() {
|
|
|
1052
1052
|
(r) => typeof e?.[r] == "function"
|
|
1053
1053
|
) ? e : te;
|
|
1054
1054
|
}
|
|
1055
|
-
class
|
|
1055
|
+
class A {
|
|
1056
1056
|
/**
|
|
1057
1057
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
1058
1058
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -1063,7 +1063,7 @@ class E {
|
|
|
1063
1063
|
*/
|
|
1064
1064
|
static getValues(e) {
|
|
1065
1065
|
const t = {};
|
|
1066
|
-
return
|
|
1066
|
+
return A.getPartValues(e, t);
|
|
1067
1067
|
}
|
|
1068
1068
|
/**
|
|
1069
1069
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -1074,32 +1074,32 @@ class E {
|
|
|
1074
1074
|
* @returns values と同じオブジェクト
|
|
1075
1075
|
*/
|
|
1076
1076
|
static getPartValues(e, t) {
|
|
1077
|
-
const r = e.getAttribute("name"), i = e.getAttribute(`${
|
|
1077
|
+
const r = e.getAttribute("name"), i = e.getAttribute(`${u.prefix}form-object`), s = e.getAttribute(`${u.prefix}form-list`);
|
|
1078
1078
|
if (r) {
|
|
1079
|
-
s ? Array.isArray(t[String(r)]) ? t[String(r)].push(e.getValue()) : t[String(r)] = [e.getValue()] : t[String(r)] = e.getValue(), i &&
|
|
1079
|
+
s ? Array.isArray(t[String(r)]) ? t[String(r)].push(e.getValue()) : t[String(r)] = [e.getValue()] : t[String(r)] = e.getValue(), i && p.warn(
|
|
1080
1080
|
"Haori",
|
|
1081
|
-
`Element cannot have both ${
|
|
1081
|
+
`Element cannot have both ${u.prefix}form-object and name attributes.`
|
|
1082
1082
|
);
|
|
1083
1083
|
for (const n of e.getChildElementFragments())
|
|
1084
|
-
|
|
1084
|
+
A.getPartValues(n, t);
|
|
1085
1085
|
} else if (i) {
|
|
1086
1086
|
const n = {};
|
|
1087
1087
|
for (const a of e.getChildElementFragments())
|
|
1088
|
-
|
|
1089
|
-
Object.keys(n).length > 0 && (t[String(i)] = n), s &&
|
|
1088
|
+
A.getPartValues(a, n);
|
|
1089
|
+
Object.keys(n).length > 0 && (t[String(i)] = n), s && p.warn(
|
|
1090
1090
|
"Haori",
|
|
1091
|
-
`Element cannot have both ${
|
|
1091
|
+
`Element cannot have both ${u.prefix}form-list and ${u.prefix}form-object attributes.`
|
|
1092
1092
|
);
|
|
1093
1093
|
} else if (s) {
|
|
1094
1094
|
const n = [];
|
|
1095
1095
|
for (const a of e.getChildElementFragments()) {
|
|
1096
1096
|
const o = {};
|
|
1097
|
-
|
|
1097
|
+
A.getPartValues(a, o), Object.keys(o).length > 0 && n.push(o);
|
|
1098
1098
|
}
|
|
1099
1099
|
n.length > 0 && (t[String(s)] = n);
|
|
1100
1100
|
} else
|
|
1101
1101
|
for (const n of e.getChildElementFragments())
|
|
1102
|
-
|
|
1102
|
+
A.getPartValues(n, t);
|
|
1103
1103
|
return t;
|
|
1104
1104
|
}
|
|
1105
1105
|
/**
|
|
@@ -1112,7 +1112,7 @@ class E {
|
|
|
1112
1112
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
1113
1113
|
*/
|
|
1114
1114
|
static setValues(e, t, r = !1) {
|
|
1115
|
-
return
|
|
1115
|
+
return A.setPartValues(e, t, null, r, !0);
|
|
1116
1116
|
}
|
|
1117
1117
|
/**
|
|
1118
1118
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -1124,7 +1124,7 @@ class E {
|
|
|
1124
1124
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
1125
1125
|
*/
|
|
1126
1126
|
static syncValues(e, t, r = !1) {
|
|
1127
|
-
return
|
|
1127
|
+
return A.setPartValues(e, t, null, r, !1);
|
|
1128
1128
|
}
|
|
1129
1129
|
/**
|
|
1130
1130
|
* 単一フラグメントへ値を設定します。
|
|
@@ -1147,23 +1147,23 @@ class E {
|
|
|
1147
1147
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
1148
1148
|
*/
|
|
1149
1149
|
static setPartValues(e, t, r = null, i = !1, s = !0) {
|
|
1150
|
-
const n = [], a = e.getAttribute("name"), o = e.getAttribute(`${
|
|
1150
|
+
const n = [], a = e.getAttribute("name"), o = e.getAttribute(`${u.prefix}form-object`), c = e.getAttribute(`${u.prefix}form-list`), d = e.getAttribute(`${u.prefix}form-detach`);
|
|
1151
1151
|
if (a) {
|
|
1152
1152
|
if (!d || i) {
|
|
1153
1153
|
const f = t[String(a)];
|
|
1154
1154
|
c && Array.isArray(f) && r !== null ? n.push(
|
|
1155
|
-
|
|
1156
|
-
) : typeof f > "u" || (typeof f == "string" || typeof f == "number" || typeof f == "boolean" || f === null ? n.push(
|
|
1157
|
-
|
|
1155
|
+
A.applyFragmentValue(e, f[r] ?? null, s)
|
|
1156
|
+
) : typeof f > "u" || (typeof f == "string" || typeof f == "number" || typeof f == "boolean" || f === null ? n.push(A.applyFragmentValue(e, f, s)) : n.push(
|
|
1157
|
+
A.applyFragmentValue(e, String(f), s)
|
|
1158
1158
|
));
|
|
1159
1159
|
}
|
|
1160
1160
|
} else if (o) {
|
|
1161
1161
|
const f = t[String(o)];
|
|
1162
1162
|
if (f && typeof f == "object")
|
|
1163
|
-
for (const
|
|
1163
|
+
for (const g of e.getChildElementFragments())
|
|
1164
1164
|
n.push(
|
|
1165
|
-
|
|
1166
|
-
|
|
1165
|
+
A.setPartValues(
|
|
1166
|
+
g,
|
|
1167
1167
|
f,
|
|
1168
1168
|
null,
|
|
1169
1169
|
i,
|
|
@@ -1173,24 +1173,24 @@ class E {
|
|
|
1173
1173
|
} else if (c) {
|
|
1174
1174
|
const f = t[String(c)];
|
|
1175
1175
|
if (Array.isArray(f)) {
|
|
1176
|
-
const
|
|
1177
|
-
for (let
|
|
1178
|
-
const
|
|
1179
|
-
f.length >
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
f[
|
|
1183
|
-
|
|
1176
|
+
const g = e.getChildElementFragments();
|
|
1177
|
+
for (let y = 0; y < g.length; y++) {
|
|
1178
|
+
const T = g[y];
|
|
1179
|
+
f.length > y ? n.push(
|
|
1180
|
+
A.setPartValues(
|
|
1181
|
+
T,
|
|
1182
|
+
f[y],
|
|
1183
|
+
y,
|
|
1184
1184
|
i,
|
|
1185
1185
|
s
|
|
1186
1186
|
)
|
|
1187
|
-
) : n.push(
|
|
1187
|
+
) : n.push(A.setPartValues(T, {}, y, i, s));
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
1190
|
} else
|
|
1191
1191
|
for (const f of e.getChildElementFragments())
|
|
1192
1192
|
n.push(
|
|
1193
|
-
|
|
1193
|
+
A.setPartValues(f, t, null, i, s)
|
|
1194
1194
|
);
|
|
1195
1195
|
return Promise.all(n).then(() => {
|
|
1196
1196
|
});
|
|
@@ -1203,10 +1203,10 @@ class E {
|
|
|
1203
1203
|
* @returns すべての初期化処理が完了するPromise
|
|
1204
1204
|
*/
|
|
1205
1205
|
static async reset(e) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
]), await
|
|
1206
|
+
A.clearValues(e), await Promise.all([
|
|
1207
|
+
A.clearMessages(e),
|
|
1208
|
+
A.clearEachClones(e)
|
|
1209
|
+
]), await M.enqueue(() => {
|
|
1210
1210
|
const t = e.getTarget();
|
|
1211
1211
|
if (t instanceof HTMLFormElement)
|
|
1212
1212
|
t.reset();
|
|
@@ -1217,7 +1217,7 @@ class E {
|
|
|
1217
1217
|
s.appendChild(t), s.reset(), r.insertBefore(t, i);
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
|
-
}), await
|
|
1220
|
+
}), await P.evaluateAll(e);
|
|
1221
1221
|
}
|
|
1222
1222
|
/**
|
|
1223
1223
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -1227,9 +1227,9 @@ class E {
|
|
|
1227
1227
|
*/
|
|
1228
1228
|
static clearEachClones(e) {
|
|
1229
1229
|
const t = [], r = (s) => {
|
|
1230
|
-
if (s.hasAttribute(`${
|
|
1230
|
+
if (s.hasAttribute(`${u.prefix}each`))
|
|
1231
1231
|
for (const n of s.getChildElementFragments()) {
|
|
1232
|
-
const a = n.hasAttribute(`${
|
|
1232
|
+
const a = n.hasAttribute(`${u.prefix}each-before`), o = n.hasAttribute(`${u.prefix}each-after`);
|
|
1233
1233
|
!a && !o && t.push(n.remove());
|
|
1234
1234
|
}
|
|
1235
1235
|
}, i = (s) => {
|
|
@@ -1251,7 +1251,7 @@ class E {
|
|
|
1251
1251
|
static clearValues(e) {
|
|
1252
1252
|
e.clearValue();
|
|
1253
1253
|
for (const t of e.getChildElementFragments())
|
|
1254
|
-
|
|
1254
|
+
A.clearValues(t);
|
|
1255
1255
|
}
|
|
1256
1256
|
/**
|
|
1257
1257
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -1274,7 +1274,7 @@ class E {
|
|
|
1274
1274
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
1275
1275
|
*/
|
|
1276
1276
|
static addErrorMessage(e, t, r) {
|
|
1277
|
-
return
|
|
1277
|
+
return A.addMessage(e, t, r, "error");
|
|
1278
1278
|
}
|
|
1279
1279
|
/**
|
|
1280
1280
|
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
@@ -1287,7 +1287,7 @@ class E {
|
|
|
1287
1287
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
1288
1288
|
*/
|
|
1289
1289
|
static addMessage(e, t, r, i) {
|
|
1290
|
-
const s = [], n = le(), a = n.addMessage, o = (d) => typeof a == "function" ? a.call(n, d, r, i) : n.addErrorMessage(d, r), c =
|
|
1290
|
+
const s = [], n = le(), a = n.addMessage, o = (d) => typeof a == "function" ? a.call(n, d, r, i) : n.addErrorMessage(d, r), c = A.findFragmentsByKey(e, t);
|
|
1291
1291
|
return c.forEach((d) => {
|
|
1292
1292
|
s.push(o(d.getTarget()));
|
|
1293
1293
|
}), c.length === 0 && s.push(o(e.getTarget())), Promise.all(s).then(() => {
|
|
@@ -1301,7 +1301,7 @@ class E {
|
|
|
1301
1301
|
* @returns 一致するフラグメントの配列
|
|
1302
1302
|
*/
|
|
1303
1303
|
static findFragmentsByKey(e, t) {
|
|
1304
|
-
return
|
|
1304
|
+
return A.findFragmentByKeyParts(e, t.split("."));
|
|
1305
1305
|
}
|
|
1306
1306
|
/**
|
|
1307
1307
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -1313,23 +1313,23 @@ class E {
|
|
|
1313
1313
|
*/
|
|
1314
1314
|
static findFragmentByKeyParts(e, t) {
|
|
1315
1315
|
const r = [], i = t[0];
|
|
1316
|
-
if (t.length == 1 && e.getAttribute("name") === i && r.push(e), e.hasAttribute(`${
|
|
1317
|
-
t.length > 1 && e.getAttribute(`${
|
|
1318
|
-
r.push(...
|
|
1316
|
+
if (t.length == 1 && e.getAttribute("name") === i && r.push(e), e.hasAttribute(`${u.prefix}form-object`))
|
|
1317
|
+
t.length > 1 && e.getAttribute(`${u.prefix}form-object`) === i && e.getChildElementFragments().forEach((n) => {
|
|
1318
|
+
r.push(...A.findFragmentByKeyParts(n, t.slice(1)));
|
|
1319
1319
|
});
|
|
1320
|
-
else if (e.hasAttribute(`${
|
|
1320
|
+
else if (e.hasAttribute(`${u.prefix}form-list`)) {
|
|
1321
1321
|
if (t.length > 1) {
|
|
1322
|
-
const s = e.getAttribute(`${
|
|
1322
|
+
const s = e.getAttribute(`${u.prefix}form-list`), n = i.lastIndexOf("["), a = i.lastIndexOf("]");
|
|
1323
1323
|
if (n !== -1 && a !== -1 && n < a) {
|
|
1324
1324
|
const o = i.substring(0, n);
|
|
1325
1325
|
if (s === o) {
|
|
1326
1326
|
const c = i.substring(n + 1, a), d = Number(c);
|
|
1327
1327
|
if (isNaN(d))
|
|
1328
|
-
|
|
1328
|
+
p.error("Haori", `Invalid index: ${i}`);
|
|
1329
1329
|
else {
|
|
1330
|
-
const f = e.getChildElementFragments().filter((
|
|
1330
|
+
const f = e.getChildElementFragments().filter((g) => g.hasAttribute(`${u.prefix}row`));
|
|
1331
1331
|
d < f.length && r.push(
|
|
1332
|
-
...
|
|
1332
|
+
...A.findFragmentByKeyParts(f[d], t.slice(1))
|
|
1333
1333
|
);
|
|
1334
1334
|
}
|
|
1335
1335
|
}
|
|
@@ -1337,7 +1337,7 @@ class E {
|
|
|
1337
1337
|
}
|
|
1338
1338
|
} else
|
|
1339
1339
|
e.getChildElementFragments().forEach((s) => {
|
|
1340
|
-
r.push(...
|
|
1340
|
+
r.push(...A.findFragmentByKeyParts(s, t));
|
|
1341
1341
|
});
|
|
1342
1342
|
return r;
|
|
1343
1343
|
}
|
|
@@ -1402,7 +1402,7 @@ const N = class N {
|
|
|
1402
1402
|
* @param expressions 今回評価した式一覧
|
|
1403
1403
|
*/
|
|
1404
1404
|
static record(e, t, r) {
|
|
1405
|
-
if (!
|
|
1405
|
+
if (!L.isEnabled() || !e || t.length === 0)
|
|
1406
1406
|
return;
|
|
1407
1407
|
N.ensureGlobalAccess();
|
|
1408
1408
|
const i = N.getOrCreateElementStore(
|
|
@@ -1436,7 +1436,7 @@ const N = class N {
|
|
|
1436
1436
|
* globalThis から dev-only の取得窓口を参照できるようにします。
|
|
1437
1437
|
*/
|
|
1438
1438
|
static ensureGlobalAccess() {
|
|
1439
|
-
if (!
|
|
1439
|
+
if (!L.isEnabled())
|
|
1440
1440
|
return;
|
|
1441
1441
|
const e = globalThis;
|
|
1442
1442
|
e[N.GLOBAL_KEY] === void 0 && (e[N.GLOBAL_KEY] = {
|
|
@@ -1570,8 +1570,8 @@ const N = class N {
|
|
|
1570
1570
|
i += `#${s.trim()}`, t.unshift(i);
|
|
1571
1571
|
break;
|
|
1572
1572
|
}
|
|
1573
|
-
const n = r.getAttribute(`${
|
|
1574
|
-
n && n.trim() !== "" && (i += `[${
|
|
1573
|
+
const n = r.getAttribute(`${u.prefix}derive-name`);
|
|
1574
|
+
n && n.trim() !== "" && (i += `[${u.prefix}derive-name="${n.trim()}"]`);
|
|
1575
1575
|
const a = r.parentElement;
|
|
1576
1576
|
a && (i += `:nth-child(${[...a.children].indexOf(r) + 1})`), t.unshift(i), r = a;
|
|
1577
1577
|
}
|
|
@@ -1580,24 +1580,24 @@ const N = class N {
|
|
|
1580
1580
|
};
|
|
1581
1581
|
N.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", N.ELEMENT_STORES = /* @__PURE__ */ new Map();
|
|
1582
1582
|
let J = N;
|
|
1583
|
-
const
|
|
1583
|
+
const G = class G {
|
|
1584
1584
|
/**
|
|
1585
1585
|
* フラグメントのコンストラクタ。
|
|
1586
1586
|
*
|
|
1587
1587
|
* @param target 対象ノード
|
|
1588
1588
|
*/
|
|
1589
1589
|
constructor(e) {
|
|
1590
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e,
|
|
1590
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e, G.FRAGMENT_CACHE.set(e, this);
|
|
1591
1591
|
}
|
|
1592
1592
|
static get(e) {
|
|
1593
1593
|
if (e == null)
|
|
1594
1594
|
return null;
|
|
1595
|
-
if (
|
|
1596
|
-
return
|
|
1595
|
+
if (G.FRAGMENT_CACHE.has(e))
|
|
1596
|
+
return G.FRAGMENT_CACHE.get(e);
|
|
1597
1597
|
let t;
|
|
1598
1598
|
switch (e.nodeType) {
|
|
1599
1599
|
case Node.ELEMENT_NODE:
|
|
1600
|
-
t = new
|
|
1600
|
+
t = new C(e);
|
|
1601
1601
|
break;
|
|
1602
1602
|
case Node.TEXT_NODE:
|
|
1603
1603
|
t = new H(e);
|
|
@@ -1606,7 +1606,7 @@ const K = class K {
|
|
|
1606
1606
|
t = new ae(e);
|
|
1607
1607
|
break;
|
|
1608
1608
|
default:
|
|
1609
|
-
return
|
|
1609
|
+
return p.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
|
|
1610
1610
|
}
|
|
1611
1611
|
return t;
|
|
1612
1612
|
}
|
|
@@ -1628,7 +1628,7 @@ const K = class K {
|
|
|
1628
1628
|
return Promise.resolve();
|
|
1629
1629
|
if (this.parent) {
|
|
1630
1630
|
const e = this.parent, t = e.skipMutationNodes;
|
|
1631
|
-
return
|
|
1631
|
+
return M.enqueue(() => {
|
|
1632
1632
|
e.skipMutationNodes = !0, this.target.parentNode === e.getTarget() && e.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1633
1633
|
}).finally(() => {
|
|
1634
1634
|
e.skipMutationNodes = t;
|
|
@@ -1636,7 +1636,7 @@ const K = class K {
|
|
|
1636
1636
|
} else {
|
|
1637
1637
|
const e = this.target.parentNode;
|
|
1638
1638
|
if (e)
|
|
1639
|
-
return
|
|
1639
|
+
return M.enqueue(() => {
|
|
1640
1640
|
this.target.parentNode === e && e.removeChild(this.target), this.mounted = !1;
|
|
1641
1641
|
});
|
|
1642
1642
|
this.mounted = !1;
|
|
@@ -1653,7 +1653,7 @@ const K = class K {
|
|
|
1653
1653
|
return Promise.resolve();
|
|
1654
1654
|
if (this.parent) {
|
|
1655
1655
|
const e = this.parent, t = e.skipMutationNodes;
|
|
1656
|
-
return
|
|
1656
|
+
return M.enqueue(() => {
|
|
1657
1657
|
e.skipMutationNodes = !0, this.target.parentNode !== e.getTarget() && e.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1658
1658
|
}).finally(() => {
|
|
1659
1659
|
e.skipMutationNodes = t;
|
|
@@ -1684,7 +1684,7 @@ const K = class K {
|
|
|
1684
1684
|
* @return 除去のPromise
|
|
1685
1685
|
*/
|
|
1686
1686
|
remove(e = !0) {
|
|
1687
|
-
return this.parent && this.parent.removeChild(this),
|
|
1687
|
+
return this.parent && this.parent.removeChild(this), G.FRAGMENT_CACHE.delete(this.target), e ? this.unmount() : Promise.resolve();
|
|
1688
1688
|
}
|
|
1689
1689
|
/**
|
|
1690
1690
|
* 対象ノードを取得します。
|
|
@@ -1711,8 +1711,8 @@ const K = class K {
|
|
|
1711
1711
|
this.parent = e;
|
|
1712
1712
|
}
|
|
1713
1713
|
};
|
|
1714
|
-
|
|
1715
|
-
let w =
|
|
1714
|
+
G.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1715
|
+
let w = G;
|
|
1716
1716
|
const V = class V extends w {
|
|
1717
1717
|
/**
|
|
1718
1718
|
* エレメントフラグメントのコンストラクタ。
|
|
@@ -1783,7 +1783,7 @@ const V = class V extends w {
|
|
|
1783
1783
|
removeChild(e) {
|
|
1784
1784
|
const t = this.children.indexOf(e);
|
|
1785
1785
|
if (t < 0) {
|
|
1786
|
-
|
|
1786
|
+
p.warn("[Haori]", "Child fragment not found.", e);
|
|
1787
1787
|
return;
|
|
1788
1788
|
}
|
|
1789
1789
|
this.children.splice(t, 1), e.setParent(null);
|
|
@@ -1808,7 +1808,7 @@ const V = class V extends w {
|
|
|
1808
1808
|
* clone 時に runtime の hidden 状態だけを落とします。
|
|
1809
1809
|
*/
|
|
1810
1810
|
normalizeClonedVisibilityState() {
|
|
1811
|
-
(this.visible === !1 || this.getTarget().style.display === "none" || this.getTarget().hasAttribute(`${
|
|
1811
|
+
(this.visible === !1 || this.getTarget().style.display === "none" || this.getTarget().hasAttribute(`${u.prefix}if-false`)) && (this.visible = !0, this.display = null, this.displayPriority = null, this.getTarget().style.removeProperty("display"), this.getTarget().removeAttribute(`${u.prefix}if-false`)), this.children.forEach((e) => {
|
|
1812
1812
|
e instanceof V && e.normalizeClonedVisibilityState();
|
|
1813
1813
|
});
|
|
1814
1814
|
}
|
|
@@ -2047,16 +2047,16 @@ const V = class V extends w {
|
|
|
2047
2047
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
2048
2048
|
const i = this.getAttribute("value"), s = r.type === "checkbox" && i === "true";
|
|
2049
2049
|
let n;
|
|
2050
|
-
return s ? n = e === !0 || e === "true" : i === "false" ? n = e === !1 : n = i === String(e), this.value = s ? n : n ? e : null, r.checked === n ? Promise.resolve() : (this.skipChangeValue = !0,
|
|
2050
|
+
return s ? n = e === !0 || e === "true" : i === "false" ? n = e === !1 : n = i === String(e), this.value = s ? n : n ? e : null, r.checked === n ? Promise.resolve() : (this.skipChangeValue = !0, M.enqueue(() => {
|
|
2051
2051
|
r.checked = n, t && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2052
2052
|
}).finally(() => {
|
|
2053
2053
|
this.skipChangeValue = !1;
|
|
2054
2054
|
}));
|
|
2055
|
-
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = e, this.skipChangeValue = !0,
|
|
2055
|
+
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = e, this.skipChangeValue = !0, M.enqueue(() => {
|
|
2056
2056
|
r.value = e === null ? "" : String(e), t && ((r instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(r.type) || r instanceof HTMLTextAreaElement) && r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
2057
2057
|
}).finally(() => {
|
|
2058
2058
|
this.skipChangeValue = !1;
|
|
2059
|
-
})) : (
|
|
2059
|
+
})) : (p.warn(
|
|
2060
2060
|
"[Haori]",
|
|
2061
2061
|
"setValue is not supported for this element type.",
|
|
2062
2062
|
r
|
|
@@ -2138,7 +2138,7 @@ const V = class V extends w {
|
|
|
2138
2138
|
return Promise.resolve();
|
|
2139
2139
|
this.attributeMap.delete(e), this.skipMutationAttributes = !0;
|
|
2140
2140
|
const r = this.getTarget();
|
|
2141
|
-
return
|
|
2141
|
+
return M.enqueue(() => {
|
|
2142
2142
|
r.removeAttribute(e), t !== e && r.removeAttribute(t);
|
|
2143
2143
|
}).finally(() => {
|
|
2144
2144
|
this.skipMutationAttributes = !1;
|
|
@@ -2160,9 +2160,9 @@ const V = class V extends w {
|
|
|
2160
2160
|
return e === t ? this.removeAttribute(e) : this.removeAliasedAttribute(e, t);
|
|
2161
2161
|
const n = new X(e, r);
|
|
2162
2162
|
if (s) {
|
|
2163
|
-
const
|
|
2164
|
-
if (
|
|
2165
|
-
return this.skipMutationAttributes = !0,
|
|
2163
|
+
const U = this.attributeMap.get(e);
|
|
2164
|
+
if (U && (U.isEvaluate || U.isForceEvaluation()) && !n.isEvaluate && !n.isForceEvaluation())
|
|
2165
|
+
return this.skipMutationAttributes = !0, M.enqueue(() => {
|
|
2166
2166
|
}).finally(() => {
|
|
2167
2167
|
this.skipMutationAttributes = !1;
|
|
2168
2168
|
});
|
|
@@ -2173,9 +2173,9 @@ const V = class V extends w {
|
|
|
2173
2173
|
element: a,
|
|
2174
2174
|
rawName: e,
|
|
2175
2175
|
template: r
|
|
2176
|
-
}), c = n.isEvaluate || n.isRawEvaluate, d = e === t && V.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), f = n.isSingleExpression(),
|
|
2177
|
-
return !
|
|
2178
|
-
|
|
2176
|
+
}), c = n.isEvaluate || n.isRawEvaluate, d = e === t && V.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), f = n.isSingleExpression(), g = j.joinEvaluateResults(o.results), y = o.results.length === 1 ? o.results[0] : g, T = !n.isForceEvaluation() && (t !== e || d || f ? o.hasUnresolvedReference || y === null || y === void 0 || y === !1 : c && g === ""), m = n.isForceEvaluation() ? r : f ? y : g, b = i && n.isEvaluate && t === "value" && (a instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(a.type) || a instanceof HTMLTextAreaElement || a instanceof HTMLSelectElement), E = T || m === null || m === !1 ? null : String(m), v = e !== t && a.getAttribute(e) !== r, F = E === null ? a.hasAttribute(t) : a.getAttribute(t) !== E, x = b && E !== null && a.value !== E;
|
|
2177
|
+
return !v && !F && !x ? (b && E !== null && (this.value = E), Promise.resolve()) : (this.skipMutationAttributes = !0, M.enqueue(() => {
|
|
2178
|
+
v && a.setAttribute(e, r), E === null ? a.removeAttribute(t) : (F && a.setAttribute(t, E), b && (this.value = E, x && (a.value = E)));
|
|
2179
2179
|
}).finally(() => {
|
|
2180
2180
|
this.skipMutationAttributes = !1;
|
|
2181
2181
|
}));
|
|
@@ -2191,7 +2191,7 @@ const V = class V extends w {
|
|
|
2191
2191
|
return Promise.resolve();
|
|
2192
2192
|
this.attributeMap.delete(e), this.skipMutationAttributes = !0;
|
|
2193
2193
|
const t = this.getTarget();
|
|
2194
|
-
return
|
|
2194
|
+
return M.enqueue(() => {
|
|
2195
2195
|
t.removeAttribute(e);
|
|
2196
2196
|
}).finally(() => {
|
|
2197
2197
|
this.skipMutationAttributes = !1;
|
|
@@ -2294,13 +2294,13 @@ const V = class V extends w {
|
|
|
2294
2294
|
if (this.skipMutationNodes)
|
|
2295
2295
|
return Promise.resolve();
|
|
2296
2296
|
if (e === this)
|
|
2297
|
-
return
|
|
2297
|
+
return p.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
2298
2298
|
const i = /* @__PURE__ */ new Set();
|
|
2299
2299
|
let s = this.parent;
|
|
2300
2300
|
for (; s; )
|
|
2301
2301
|
i.add(s), s = s.getParent();
|
|
2302
2302
|
if (i.has(e))
|
|
2303
|
-
return
|
|
2303
|
+
return p.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
2304
2304
|
const n = e.getParent() === this;
|
|
2305
2305
|
let a = -1, o = -1;
|
|
2306
2306
|
n && (a = this.children.indexOf(e), t !== null && (o = this.children.indexOf(t)));
|
|
@@ -2310,23 +2310,23 @@ const V = class V extends w {
|
|
|
2310
2310
|
if (t === null)
|
|
2311
2311
|
this.children.push(e);
|
|
2312
2312
|
else {
|
|
2313
|
-
let
|
|
2314
|
-
if (n ? a !== -1 && a < o ?
|
|
2315
|
-
const
|
|
2313
|
+
let g;
|
|
2314
|
+
if (n ? a !== -1 && a < o ? g = o - 1 : g = o : g = this.children.indexOf(t), g === -1) {
|
|
2315
|
+
const y = this.resolveInsertionPointFromDom(
|
|
2316
2316
|
t,
|
|
2317
2317
|
!1
|
|
2318
2318
|
);
|
|
2319
|
-
|
|
2319
|
+
y === null ? (p.warn(
|
|
2320
2320
|
"[Haori]",
|
|
2321
2321
|
"Reference child not found in children.",
|
|
2322
2322
|
t
|
|
2323
|
-
), this.children.push(e)) : (this.children.splice(
|
|
2323
|
+
), this.children.push(e)) : (this.children.splice(y.index, 0, e), d = y.referenceNode);
|
|
2324
2324
|
} else
|
|
2325
|
-
this.children.splice(
|
|
2325
|
+
this.children.splice(g, 0, e);
|
|
2326
2326
|
}
|
|
2327
2327
|
e.setParent(this), e.setMounted(this.mounted);
|
|
2328
2328
|
const f = this.skipMutationNodes;
|
|
2329
|
-
return this.skipMutationNodes = !0,
|
|
2329
|
+
return this.skipMutationNodes = !0, M.enqueue(() => {
|
|
2330
2330
|
this.target.insertBefore(e.getTarget(), d);
|
|
2331
2331
|
}).finally(() => {
|
|
2332
2332
|
this.skipMutationNodes = f;
|
|
@@ -2348,7 +2348,7 @@ const V = class V extends w {
|
|
|
2348
2348
|
t,
|
|
2349
2349
|
!0
|
|
2350
2350
|
);
|
|
2351
|
-
return i === null ? (
|
|
2351
|
+
return i === null ? (p.warn(
|
|
2352
2352
|
"[Haori]",
|
|
2353
2353
|
"Reference child not found in children.",
|
|
2354
2354
|
t
|
|
@@ -2404,7 +2404,7 @@ const V = class V extends w {
|
|
|
2404
2404
|
return Promise.resolve();
|
|
2405
2405
|
this.visible = !1;
|
|
2406
2406
|
const e = this.getTarget();
|
|
2407
|
-
return this.display = e.style.getPropertyValue("display"), this.displayPriority = e.style.getPropertyPriority("display"), e.style.setProperty("display", "none", "important"), e.setAttribute(`${
|
|
2407
|
+
return this.display = e.style.getPropertyValue("display"), this.displayPriority = e.style.getPropertyPriority("display"), e.style.setProperty("display", "none", "important"), e.setAttribute(`${u.prefix}if-false`, ""), Promise.resolve();
|
|
2408
2408
|
}
|
|
2409
2409
|
/**
|
|
2410
2410
|
* エレメントを表示します。
|
|
@@ -2419,7 +2419,7 @@ const V = class V extends w {
|
|
|
2419
2419
|
"display",
|
|
2420
2420
|
this.display,
|
|
2421
2421
|
this.displayPriority ?? ""
|
|
2422
|
-
), this.display = null, this.displayPriority = null, e.removeAttribute(`${
|
|
2422
|
+
), this.display = null, this.displayPriority = null, e.removeAttribute(`${u.prefix}if-false`), this.visible = !0, Promise.resolve();
|
|
2423
2423
|
}
|
|
2424
2424
|
/**
|
|
2425
2425
|
* 指定した属性名を持つ最も近い親要素を返します。
|
|
@@ -2460,7 +2460,7 @@ V.BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
2460
2460
|
"reversed",
|
|
2461
2461
|
"selected"
|
|
2462
2462
|
]);
|
|
2463
|
-
let
|
|
2463
|
+
let C = V;
|
|
2464
2464
|
class H extends w {
|
|
2465
2465
|
/**
|
|
2466
2466
|
* テキストフラグメントのコンストラクタ。
|
|
@@ -2513,7 +2513,7 @@ class H extends w {
|
|
|
2513
2513
|
evaluate() {
|
|
2514
2514
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
2515
2515
|
new Error("Parent fragment is required for raw evaluation")
|
|
2516
|
-
) :
|
|
2516
|
+
) : M.enqueue(() => {
|
|
2517
2517
|
this.skipMutation = !0;
|
|
2518
2518
|
let e = this.text;
|
|
2519
2519
|
this.contents.isRawEvaluate ? e = this.contents.evaluate(
|
|
@@ -2573,7 +2573,7 @@ class ae extends w {
|
|
|
2573
2573
|
* @return 更新のPromise
|
|
2574
2574
|
*/
|
|
2575
2575
|
setContent(e) {
|
|
2576
|
-
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e,
|
|
2576
|
+
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, M.enqueue(() => {
|
|
2577
2577
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
2578
2578
|
}).finally(() => {
|
|
2579
2579
|
this.skipMutation = !1;
|
|
@@ -2639,7 +2639,7 @@ const Z = class Z {
|
|
|
2639
2639
|
*/
|
|
2640
2640
|
checkRawExpressions() {
|
|
2641
2641
|
for (let e = 0; e < this.contents.length; e++)
|
|
2642
|
-
this.contents[e].type === 2 && this.contents.length > 1 && (
|
|
2642
|
+
this.contents[e].type === 2 && this.contents.length > 1 && (p.error(
|
|
2643
2643
|
"[Haori]",
|
|
2644
2644
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2645
2645
|
), this.contents[e].type = 1);
|
|
@@ -2686,7 +2686,7 @@ const Z = class Z {
|
|
|
2686
2686
|
try {
|
|
2687
2687
|
if (r(c)) {
|
|
2688
2688
|
const d = J.measure(
|
|
2689
|
-
() =>
|
|
2689
|
+
() => Y.evaluateDetailed(c.text, e)
|
|
2690
2690
|
), f = d.value;
|
|
2691
2691
|
a += d.durationMs, n.push({
|
|
2692
2692
|
expression: c.text,
|
|
@@ -2695,7 +2695,7 @@ const Z = class Z {
|
|
|
2695
2695
|
} else
|
|
2696
2696
|
s.push(c.text);
|
|
2697
2697
|
} catch (d) {
|
|
2698
|
-
|
|
2698
|
+
p.error(
|
|
2699
2699
|
"[Haori]",
|
|
2700
2700
|
`Error evaluating ${i} expression: ${c.text}`,
|
|
2701
2701
|
d
|
|
@@ -2758,7 +2758,7 @@ const _ = class _ extends j {
|
|
|
2758
2758
|
(i) => this.forceEvaluation && i.type === 0 || i.type === 1 || i.type === 2,
|
|
2759
2759
|
"attribute"
|
|
2760
2760
|
);
|
|
2761
|
-
return this.forceEvaluation && r.results.length > 1 ? (
|
|
2761
|
+
return this.forceEvaluation && r.results.length > 1 ? (p.error(
|
|
2762
2762
|
"[Haori]",
|
|
2763
2763
|
"each or if expressions must have a single content.",
|
|
2764
2764
|
r.results
|
|
@@ -2777,7 +2777,7 @@ _.FORCE_EVALUATION_ATTRIBUTES = [
|
|
|
2777
2777
|
"hor-derive"
|
|
2778
2778
|
];
|
|
2779
2779
|
let X = _;
|
|
2780
|
-
class
|
|
2780
|
+
class R {
|
|
2781
2781
|
/**
|
|
2782
2782
|
* カスタムイベントを発火します。
|
|
2783
2783
|
*
|
|
@@ -2801,7 +2801,7 @@ class F {
|
|
|
2801
2801
|
* @param version ライブラリバージョン
|
|
2802
2802
|
*/
|
|
2803
2803
|
static ready(e) {
|
|
2804
|
-
|
|
2804
|
+
R.dispatch(document, "ready", { version: e });
|
|
2805
2805
|
}
|
|
2806
2806
|
/**
|
|
2807
2807
|
* renderイベントを発火します。
|
|
@@ -2809,7 +2809,7 @@ class F {
|
|
|
2809
2809
|
* @param target 評価対象要素
|
|
2810
2810
|
*/
|
|
2811
2811
|
static render(e) {
|
|
2812
|
-
|
|
2812
|
+
R.dispatch(e, "render", { target: e });
|
|
2813
2813
|
}
|
|
2814
2814
|
/**
|
|
2815
2815
|
* importstartイベントを発火します。
|
|
@@ -2818,7 +2818,7 @@ class F {
|
|
|
2818
2818
|
* @param url インポート対象URL
|
|
2819
2819
|
*/
|
|
2820
2820
|
static importStart(e, t) {
|
|
2821
|
-
|
|
2821
|
+
R.dispatch(e, "importstart", {
|
|
2822
2822
|
url: t,
|
|
2823
2823
|
startedAt: performance.now()
|
|
2824
2824
|
});
|
|
@@ -2832,7 +2832,7 @@ class F {
|
|
|
2832
2832
|
* @param startedAt 開始時刻
|
|
2833
2833
|
*/
|
|
2834
2834
|
static importEnd(e, t, r, i) {
|
|
2835
|
-
|
|
2835
|
+
R.dispatch(e, "importend", {
|
|
2836
2836
|
url: t,
|
|
2837
2837
|
bytes: r,
|
|
2838
2838
|
durationMs: performance.now() - i
|
|
@@ -2846,7 +2846,7 @@ class F {
|
|
|
2846
2846
|
* @param error エラー内容
|
|
2847
2847
|
*/
|
|
2848
2848
|
static importError(e, t, r) {
|
|
2849
|
-
|
|
2849
|
+
R.dispatch(e, "importerror", { url: t, error: r });
|
|
2850
2850
|
}
|
|
2851
2851
|
/**
|
|
2852
2852
|
* bindchangeイベントを発火します。
|
|
@@ -2862,13 +2862,27 @@ class F {
|
|
|
2862
2862
|
const d = t?.[c], f = r[c];
|
|
2863
2863
|
d !== f && s.push(c);
|
|
2864
2864
|
}
|
|
2865
|
-
|
|
2865
|
+
R.dispatch(e, "bindchange", {
|
|
2866
2866
|
previous: t || {},
|
|
2867
2867
|
next: r,
|
|
2868
2868
|
changedKeys: s,
|
|
2869
2869
|
reason: i
|
|
2870
2870
|
});
|
|
2871
2871
|
}
|
|
2872
|
+
/**
|
|
2873
|
+
* bindcompleteイベントを発火します。
|
|
2874
|
+
*
|
|
2875
|
+
* Procedure(data-*-bind / data-*-bind-arg など)によるバインドと、それに伴う
|
|
2876
|
+
* 対象要素配下の再評価(data-if / data-each 等)が完了したタイミングで発火します。
|
|
2877
|
+
* 外部スクリプトがバインド完了を契機に同期処理を行うために利用できます。
|
|
2878
|
+
*
|
|
2879
|
+
* @param target バインド対象要素
|
|
2880
|
+
* @param bindArg バインド時に使用したネストキー(指定がない場合は null)
|
|
2881
|
+
* @param reason 変更理由
|
|
2882
|
+
*/
|
|
2883
|
+
static bindComplete(e, t = null, r = "other") {
|
|
2884
|
+
R.dispatch(e, "bindcomplete", { bindArg: t, reason: r });
|
|
2885
|
+
}
|
|
2872
2886
|
/**
|
|
2873
2887
|
* eachupdateイベントを発火します。
|
|
2874
2888
|
*
|
|
@@ -2878,7 +2892,7 @@ class F {
|
|
|
2878
2892
|
* @param order 現在の順序
|
|
2879
2893
|
*/
|
|
2880
2894
|
static eachUpdate(e, t, r, i) {
|
|
2881
|
-
|
|
2895
|
+
R.dispatch(e, "eachupdate", {
|
|
2882
2896
|
added: t,
|
|
2883
2897
|
removed: r,
|
|
2884
2898
|
order: i,
|
|
@@ -2894,7 +2908,7 @@ class F {
|
|
|
2894
2908
|
* @param item 行データ
|
|
2895
2909
|
*/
|
|
2896
2910
|
static rowAdd(e, t, r, i) {
|
|
2897
|
-
|
|
2911
|
+
R.dispatch(e, "rowadd", { key: t, index: r, item: i });
|
|
2898
2912
|
}
|
|
2899
2913
|
/**
|
|
2900
2914
|
* rowremoveイベントを発火します。
|
|
@@ -2904,7 +2918,7 @@ class F {
|
|
|
2904
2918
|
* @param index インデックス
|
|
2905
2919
|
*/
|
|
2906
2920
|
static rowRemove(e, t, r) {
|
|
2907
|
-
|
|
2921
|
+
R.dispatch(e, "rowremove", { key: t, index: r });
|
|
2908
2922
|
}
|
|
2909
2923
|
/**
|
|
2910
2924
|
* rowmoveイベントを発火します。
|
|
@@ -2915,7 +2929,7 @@ class F {
|
|
|
2915
2929
|
* @param to 移動後インデックス
|
|
2916
2930
|
*/
|
|
2917
2931
|
static rowMove(e, t, r, i) {
|
|
2918
|
-
|
|
2932
|
+
R.dispatch(e, "rowmove", { key: t, from: r, to: i });
|
|
2919
2933
|
}
|
|
2920
2934
|
/**
|
|
2921
2935
|
* showイベントを発火します。
|
|
@@ -2923,7 +2937,7 @@ class F {
|
|
|
2923
2937
|
* @param target data-if要素
|
|
2924
2938
|
*/
|
|
2925
2939
|
static show(e) {
|
|
2926
|
-
|
|
2940
|
+
R.dispatch(e, "show", { visible: !0 });
|
|
2927
2941
|
}
|
|
2928
2942
|
/**
|
|
2929
2943
|
* hideイベントを発火します。
|
|
@@ -2931,7 +2945,7 @@ class F {
|
|
|
2931
2945
|
* @param target data-if要素
|
|
2932
2946
|
*/
|
|
2933
2947
|
static hide(e) {
|
|
2934
|
-
|
|
2948
|
+
R.dispatch(e, "hide", { visible: !1 });
|
|
2935
2949
|
}
|
|
2936
2950
|
/**
|
|
2937
2951
|
* fetchstartイベントを発火します。
|
|
@@ -2944,7 +2958,7 @@ class F {
|
|
|
2944
2958
|
* @return 戻り値はありません。
|
|
2945
2959
|
*/
|
|
2946
2960
|
static fetchStart(e, t, r, i, s) {
|
|
2947
|
-
|
|
2961
|
+
R.dispatch(e, "fetchstart", {
|
|
2948
2962
|
url: t,
|
|
2949
2963
|
options: r || {},
|
|
2950
2964
|
payload: i,
|
|
@@ -2961,7 +2975,7 @@ class F {
|
|
|
2961
2975
|
* @param startedAt 開始時刻
|
|
2962
2976
|
*/
|
|
2963
2977
|
static fetchEnd(e, t, r, i) {
|
|
2964
|
-
|
|
2978
|
+
R.dispatch(e, "fetchend", {
|
|
2965
2979
|
url: t,
|
|
2966
2980
|
status: r,
|
|
2967
2981
|
durationMs: performance.now() - i
|
|
@@ -2977,7 +2991,7 @@ class F {
|
|
|
2977
2991
|
* @param startedAt 開始時刻(存在する場合)
|
|
2978
2992
|
*/
|
|
2979
2993
|
static fetchError(e, t, r, i, s) {
|
|
2980
|
-
|
|
2994
|
+
R.dispatch(e, "fetcherror", {
|
|
2981
2995
|
url: t,
|
|
2982
2996
|
status: i,
|
|
2983
2997
|
error: r,
|
|
@@ -3000,21 +3014,21 @@ function ie() {
|
|
|
3000
3014
|
) ? e : te;
|
|
3001
3015
|
}
|
|
3002
3016
|
const me = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
3003
|
-
function be(
|
|
3004
|
-
return me.has(
|
|
3017
|
+
function be(S) {
|
|
3018
|
+
return me.has(S.toUpperCase());
|
|
3005
3019
|
}
|
|
3006
|
-
function ve(
|
|
3020
|
+
function ve(S, e) {
|
|
3007
3021
|
for (const [t, r] of Object.entries(e))
|
|
3008
|
-
r !== void 0 && (r === null ?
|
|
3009
|
-
|
|
3010
|
-
}) : typeof r == "object" || typeof r == "function" ?
|
|
3022
|
+
r !== void 0 && (r === null ? S.append(t, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
3023
|
+
S.append(t, String(i));
|
|
3024
|
+
}) : typeof r == "object" || typeof r == "function" ? S.append(t, JSON.stringify(r)) : S.append(t, String(r)));
|
|
3011
3025
|
}
|
|
3012
|
-
function ye(
|
|
3013
|
-
const t = new URL(
|
|
3026
|
+
function ye(S, e) {
|
|
3027
|
+
const t = new URL(S, window.location.href), r = new URLSearchParams(t.search);
|
|
3014
3028
|
return ve(r, e), t.search = r.toString(), t.toString();
|
|
3015
3029
|
}
|
|
3016
|
-
function Ee(
|
|
3017
|
-
return
|
|
3030
|
+
function Ee(S) {
|
|
3031
|
+
return S == null ? null : typeof S == "string" ? S : S instanceof URLSearchParams ? S.toString() : S instanceof FormData ? Array.from(S.entries()).map(([e, t]) => t instanceof File ? [
|
|
3018
3032
|
e,
|
|
3019
3033
|
{
|
|
3020
3034
|
type: "file",
|
|
@@ -3022,16 +3036,16 @@ function Ee(D) {
|
|
|
3022
3036
|
size: t.size,
|
|
3023
3037
|
mimeType: t.type
|
|
3024
3038
|
}
|
|
3025
|
-
] : [e, String(t)]) : String(
|
|
3039
|
+
] : [e, String(t)]) : String(S);
|
|
3026
3040
|
}
|
|
3027
|
-
function Ae(
|
|
3041
|
+
function Ae(S, e) {
|
|
3028
3042
|
const t = new Headers(
|
|
3029
3043
|
e.headers || void 0
|
|
3030
3044
|
), r = Array.from(t.entries()).sort(
|
|
3031
3045
|
([i], [s]) => i.localeCompare(s)
|
|
3032
3046
|
);
|
|
3033
3047
|
return JSON.stringify({
|
|
3034
|
-
url:
|
|
3048
|
+
url: S,
|
|
3035
3049
|
method: String(e.method || "GET").toUpperCase(),
|
|
3036
3050
|
headers: r,
|
|
3037
3051
|
body: Ee(e.body || null)
|
|
@@ -3046,7 +3060,7 @@ const h = class h {
|
|
|
3046
3060
|
* 非イベント変種が "data-fetch-xxx" として存在するものについては、event が null の場合にそちらを返します。
|
|
3047
3061
|
*/
|
|
3048
3062
|
static attrName(e, t, r = !1) {
|
|
3049
|
-
return e ? `${
|
|
3063
|
+
return e ? `${u.prefix}${e}-${t}` : r ? `${u.prefix}fetch-${t}` : `${u.prefix}${t}`;
|
|
3050
3064
|
}
|
|
3051
3065
|
/**
|
|
3052
3066
|
* data 属性のテンプレート式評価結果を URLSearchParams 向けに組み立てます。
|
|
@@ -3070,7 +3084,7 @@ const h = class h {
|
|
|
3070
3084
|
return { value: e.replace(
|
|
3071
3085
|
h.DATA_PLACEHOLDER_REGEX,
|
|
3072
3086
|
(s, n, a) => {
|
|
3073
|
-
const o =
|
|
3087
|
+
const o = Y.evaluateDetailed(
|
|
3074
3088
|
n ?? a ?? "",
|
|
3075
3089
|
t
|
|
3076
3090
|
);
|
|
@@ -3150,7 +3164,7 @@ const h = class h {
|
|
|
3150
3164
|
return { value: e.replace(
|
|
3151
3165
|
h.DATA_PLACEHOLDER_REGEX,
|
|
3152
3166
|
(s, n, a, o) => {
|
|
3153
|
-
const c =
|
|
3167
|
+
const c = Y.evaluateDetailed(
|
|
3154
3168
|
n ?? a ?? "",
|
|
3155
3169
|
t
|
|
3156
3170
|
);
|
|
@@ -3187,7 +3201,7 @@ const h = class h {
|
|
|
3187
3201
|
const a = r.trim();
|
|
3188
3202
|
if (h.SINGLE_PLACEHOLDER_REGEX.test(a))
|
|
3189
3203
|
return {
|
|
3190
|
-
value:
|
|
3204
|
+
value: P.parseDataBind(s),
|
|
3191
3205
|
hasUnresolvedReference: n
|
|
3192
3206
|
};
|
|
3193
3207
|
if (a.startsWith("{") || a.startsWith("[")) {
|
|
@@ -3196,7 +3210,7 @@ const h = class h {
|
|
|
3196
3210
|
e.getBindingData()
|
|
3197
3211
|
);
|
|
3198
3212
|
return {
|
|
3199
|
-
value:
|
|
3213
|
+
value: P.parseDataBind(c.value),
|
|
3200
3214
|
hasUnresolvedReference: n || c.hasUnresolvedReference
|
|
3201
3215
|
};
|
|
3202
3216
|
}
|
|
@@ -3205,7 +3219,7 @@ const h = class h {
|
|
|
3205
3219
|
e.getBindingData()
|
|
3206
3220
|
);
|
|
3207
3221
|
return {
|
|
3208
|
-
value:
|
|
3222
|
+
value: P.parseDataBind(o.value),
|
|
3209
3223
|
hasUnresolvedReference: n || o.hasUnresolvedReference
|
|
3210
3224
|
};
|
|
3211
3225
|
}
|
|
@@ -3223,23 +3237,23 @@ const h = class h {
|
|
|
3223
3237
|
if (t) {
|
|
3224
3238
|
if (e.hasAttribute(h.attrName(t, "validate")) && (r.valid = !0), e.hasAttribute(h.attrName(t, "confirm")) && (r.confirmMessage = e.getAttribute(h.attrName(t, "confirm")).replace(/\\n/g, `
|
|
3225
3239
|
`)), e.hasAttribute(h.attrName(t, "data")) && (r.dataAttrName = h.attrName(t, "data")), e.hasAttribute(h.attrName(t, "form"))) {
|
|
3226
|
-
const
|
|
3240
|
+
const m = e.getRawAttribute(
|
|
3227
3241
|
h.attrName(t, "form")
|
|
3228
3242
|
);
|
|
3229
|
-
if (
|
|
3230
|
-
const b = document.body.querySelector(
|
|
3231
|
-
b !== null ? r.formFragment =
|
|
3243
|
+
if (m) {
|
|
3244
|
+
const b = document.body.querySelector(m);
|
|
3245
|
+
b !== null ? r.formFragment = A.getFormFragment(
|
|
3232
3246
|
w.get(b)
|
|
3233
|
-
) :
|
|
3247
|
+
) : p.error(
|
|
3234
3248
|
"Haori",
|
|
3235
|
-
`Form element not found: ${
|
|
3249
|
+
`Form element not found: ${m} (${h.attrName(t, "form")})`
|
|
3236
3250
|
);
|
|
3237
3251
|
} else
|
|
3238
|
-
r.formFragment =
|
|
3239
|
-
} else t === "change" && (r.formFragment =
|
|
3240
|
-
if (e.hasAttribute(`${
|
|
3241
|
-
const
|
|
3242
|
-
`${
|
|
3252
|
+
r.formFragment = A.getFormFragment(e);
|
|
3253
|
+
} else t === "change" && (r.formFragment = A.getFormFragment(e));
|
|
3254
|
+
if (e.hasAttribute(`${u.prefix}${t}-before-run`)) {
|
|
3255
|
+
const m = e.getRawAttribute(
|
|
3256
|
+
`${u.prefix}${t}-before-run`
|
|
3243
3257
|
);
|
|
3244
3258
|
try {
|
|
3245
3259
|
r.beforeCallback = new Function(
|
|
@@ -3247,68 +3261,68 @@ const h = class h {
|
|
|
3247
3261
|
"fetchOptions",
|
|
3248
3262
|
`
|
|
3249
3263
|
"use strict";
|
|
3250
|
-
${
|
|
3264
|
+
${m}
|
|
3251
3265
|
`
|
|
3252
3266
|
);
|
|
3253
3267
|
} catch (b) {
|
|
3254
|
-
|
|
3268
|
+
p.error("Haori", `Invalid before script: ${b}`);
|
|
3255
3269
|
}
|
|
3256
3270
|
}
|
|
3257
3271
|
}
|
|
3258
3272
|
const i = h.attrName(t, "fetch"), s = e.hasAttribute(i);
|
|
3259
3273
|
if (s) {
|
|
3260
|
-
const
|
|
3261
|
-
|
|
3274
|
+
const m = e.getAttributeEvaluation(i);
|
|
3275
|
+
m && (r.fetchHasUnresolvedReference = m.hasUnresolvedReference, r.fetchUrl = m.hasUnresolvedReference ? null : m.value);
|
|
3262
3276
|
}
|
|
3263
3277
|
const n = {};
|
|
3264
3278
|
if (t) {
|
|
3265
|
-
const
|
|
3266
|
-
if (e.hasAttribute(
|
|
3267
|
-
const b = e.getAttributeEvaluation(
|
|
3279
|
+
const m = h.attrName(t, "fetch-method");
|
|
3280
|
+
if (e.hasAttribute(m)) {
|
|
3281
|
+
const b = e.getAttributeEvaluation(m);
|
|
3268
3282
|
b?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : n.method = b?.value;
|
|
3269
3283
|
}
|
|
3270
3284
|
} else {
|
|
3271
|
-
const
|
|
3272
|
-
if (e.hasAttribute(
|
|
3285
|
+
const m = h.attrName(null, "method", !0);
|
|
3286
|
+
if (e.hasAttribute(m)) {
|
|
3273
3287
|
const b = e.getAttributeEvaluation(
|
|
3274
|
-
|
|
3288
|
+
m
|
|
3275
3289
|
);
|
|
3276
3290
|
b?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : n.method = b?.value;
|
|
3277
3291
|
}
|
|
3278
3292
|
}
|
|
3279
3293
|
if (t) {
|
|
3280
|
-
const
|
|
3281
|
-
if (e.hasAttribute(
|
|
3294
|
+
const m = h.attrName(t, "fetch-headers");
|
|
3295
|
+
if (e.hasAttribute(m)) {
|
|
3282
3296
|
const b = e.getRawAttribute(
|
|
3283
|
-
|
|
3297
|
+
m
|
|
3284
3298
|
);
|
|
3285
3299
|
try {
|
|
3286
|
-
n.headers =
|
|
3287
|
-
} catch (
|
|
3288
|
-
|
|
3300
|
+
n.headers = P.parseDataBind(b);
|
|
3301
|
+
} catch (E) {
|
|
3302
|
+
p.error("Haori", `Invalid fetch headers: ${E}`);
|
|
3289
3303
|
}
|
|
3290
3304
|
}
|
|
3291
3305
|
} else {
|
|
3292
|
-
const
|
|
3306
|
+
const m = h.attrName(
|
|
3293
3307
|
null,
|
|
3294
3308
|
"headers",
|
|
3295
3309
|
!0
|
|
3296
3310
|
);
|
|
3297
|
-
if (e.hasAttribute(
|
|
3311
|
+
if (e.hasAttribute(m)) {
|
|
3298
3312
|
const b = e.getRawAttribute(
|
|
3299
|
-
|
|
3313
|
+
m
|
|
3300
3314
|
);
|
|
3301
3315
|
try {
|
|
3302
|
-
n.headers =
|
|
3303
|
-
} catch (
|
|
3304
|
-
|
|
3316
|
+
n.headers = P.parseDataBind(b);
|
|
3317
|
+
} catch (E) {
|
|
3318
|
+
p.error("Haori", `Invalid fetch headers: ${E}`);
|
|
3305
3319
|
}
|
|
3306
3320
|
}
|
|
3307
3321
|
}
|
|
3308
3322
|
if (t) {
|
|
3309
|
-
const
|
|
3310
|
-
if (e.hasAttribute(
|
|
3311
|
-
const b = e.getAttributeEvaluation(
|
|
3323
|
+
const m = h.attrName(t, "fetch-content-type");
|
|
3324
|
+
if (e.hasAttribute(m)) {
|
|
3325
|
+
const b = e.getAttributeEvaluation(m);
|
|
3312
3326
|
b?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), n.headers = {
|
|
3313
3327
|
...n.headers,
|
|
3314
3328
|
"Content-Type": b?.value
|
|
@@ -3324,13 +3338,13 @@ ${p}
|
|
|
3324
3338
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
3325
3339
|
});
|
|
3326
3340
|
} else {
|
|
3327
|
-
const
|
|
3341
|
+
const m = h.attrName(
|
|
3328
3342
|
null,
|
|
3329
3343
|
"content-type",
|
|
3330
3344
|
!0
|
|
3331
3345
|
);
|
|
3332
|
-
if (e.hasAttribute(
|
|
3333
|
-
const b = e.getAttributeEvaluation(
|
|
3346
|
+
if (e.hasAttribute(m)) {
|
|
3347
|
+
const b = e.getAttributeEvaluation(m);
|
|
3334
3348
|
b?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), n.headers = {
|
|
3335
3349
|
...n.headers,
|
|
3336
3350
|
"Content-Type": b?.value
|
|
@@ -3349,15 +3363,15 @@ ${p}
|
|
|
3349
3363
|
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
3350
3364
|
const a = t ? h.attrName(t, "bind") : h.attrName(null, "bind", !0);
|
|
3351
3365
|
if (e.hasAttribute(a)) {
|
|
3352
|
-
const
|
|
3353
|
-
if (
|
|
3354
|
-
const b = document.body.querySelectorAll(
|
|
3355
|
-
b.length > 0 ? (r.bindFragments = [], b.forEach((
|
|
3356
|
-
const
|
|
3357
|
-
|
|
3358
|
-
})) :
|
|
3366
|
+
const m = e.getRawAttribute(a);
|
|
3367
|
+
if (m) {
|
|
3368
|
+
const b = document.body.querySelectorAll(m);
|
|
3369
|
+
b.length > 0 ? (r.bindFragments = [], b.forEach((E) => {
|
|
3370
|
+
const v = w.get(E);
|
|
3371
|
+
v && r.bindFragments.push(v);
|
|
3372
|
+
})) : p.error(
|
|
3359
3373
|
"Haori",
|
|
3360
|
-
`Bind element not found: ${
|
|
3374
|
+
`Bind element not found: ${m} (${a})`
|
|
3361
3375
|
);
|
|
3362
3376
|
}
|
|
3363
3377
|
}
|
|
@@ -3375,55 +3389,57 @@ ${p}
|
|
|
3375
3389
|
) : e.hasAttribute(d) && (r.bindArg = e.getRawAttribute(d));
|
|
3376
3390
|
const f = t ? h.attrName(t, "bind-params") : h.attrName(null, "bind-params", !0);
|
|
3377
3391
|
if (e.hasAttribute(f)) {
|
|
3378
|
-
const
|
|
3379
|
-
r.bindParams =
|
|
3392
|
+
const m = e.getRawAttribute(f);
|
|
3393
|
+
r.bindParams = m.split("&").map((b) => b.trim());
|
|
3380
3394
|
}
|
|
3381
|
-
const
|
|
3382
|
-
if (e.hasAttribute(
|
|
3383
|
-
const
|
|
3384
|
-
r.bindAppendParams =
|
|
3395
|
+
const g = t ? h.attrName(t, "bind-append") : h.attrName(null, "bind-append", !0);
|
|
3396
|
+
if (e.hasAttribute(g)) {
|
|
3397
|
+
const m = e.getRawAttribute(g);
|
|
3398
|
+
r.bindAppendParams = m.split("&").map((b) => b.trim()).filter(Boolean);
|
|
3385
3399
|
}
|
|
3386
|
-
const
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3400
|
+
const y = t ? h.attrName(t, "bind-merge") : h.attrName(null, "bind-merge", !0);
|
|
3401
|
+
e.hasAttribute(y) && (r.bindMerge = !0);
|
|
3402
|
+
const T = t ? h.attrName(t, "copy-params") : null;
|
|
3403
|
+
if (T && e.hasAttribute(T)) {
|
|
3404
|
+
const m = e.getRawAttribute(T);
|
|
3405
|
+
r.copyParams = m.split("&").map((b) => b.trim()).filter(Boolean);
|
|
3390
3406
|
}
|
|
3391
3407
|
if (t) {
|
|
3392
3408
|
if (e.hasAttribute(h.attrName(t, "adjust"))) {
|
|
3393
|
-
const
|
|
3409
|
+
const E = e.getRawAttribute(
|
|
3394
3410
|
h.attrName(t, "adjust")
|
|
3395
3411
|
);
|
|
3396
|
-
if (
|
|
3397
|
-
const
|
|
3398
|
-
|
|
3399
|
-
const
|
|
3400
|
-
|
|
3401
|
-
})) :
|
|
3412
|
+
if (E) {
|
|
3413
|
+
const v = document.body.querySelectorAll(E);
|
|
3414
|
+
v.length > 0 ? (r.adjustFragments = [], v.forEach((F) => {
|
|
3415
|
+
const x = w.get(F);
|
|
3416
|
+
x && r.adjustFragments.push(x);
|
|
3417
|
+
})) : p.error(
|
|
3402
3418
|
"Haori",
|
|
3403
|
-
`Adjust element not found: ${
|
|
3419
|
+
`Adjust element not found: ${E} (${h.attrName(t, "adjust")})`
|
|
3404
3420
|
);
|
|
3405
3421
|
}
|
|
3406
3422
|
if (e.hasAttribute(h.attrName(t, "adjust-value"))) {
|
|
3407
|
-
const
|
|
3423
|
+
const v = e.getRawAttribute(
|
|
3408
3424
|
h.attrName(t, "adjust-value")
|
|
3409
|
-
),
|
|
3410
|
-
isNaN(
|
|
3425
|
+
), F = Number(v);
|
|
3426
|
+
isNaN(F) || (r.adjustValue = F);
|
|
3411
3427
|
}
|
|
3412
3428
|
}
|
|
3413
|
-
if (e.hasAttribute(h.attrName(t, "row-add")) && (r.rowAdd = !0), e.hasAttribute(h.attrName(t, "row-remove")) && (r.rowRemove = !0), e.hasAttribute(h.attrName(t, "row-prev")) && (r.rowMovePrev = !0), e.hasAttribute(h.attrName(t, "row-next")) && (r.rowMoveNext = !0), e.hasAttribute(`${
|
|
3414
|
-
const
|
|
3415
|
-
`${
|
|
3429
|
+
if (e.hasAttribute(h.attrName(t, "row-add")) && (r.rowAdd = !0), e.hasAttribute(h.attrName(t, "row-remove")) && (r.rowRemove = !0), e.hasAttribute(h.attrName(t, "row-prev")) && (r.rowMovePrev = !0), e.hasAttribute(h.attrName(t, "row-next")) && (r.rowMoveNext = !0), e.hasAttribute(`${u.prefix}${t}-after-run`)) {
|
|
3430
|
+
const E = e.getRawAttribute(
|
|
3431
|
+
`${u.prefix}${t}-after-run`
|
|
3416
3432
|
);
|
|
3417
3433
|
try {
|
|
3418
3434
|
r.afterCallback = new Function(
|
|
3419
3435
|
"response",
|
|
3420
3436
|
`
|
|
3421
3437
|
"use strict";
|
|
3422
|
-
${
|
|
3438
|
+
${E}
|
|
3423
3439
|
`
|
|
3424
3440
|
);
|
|
3425
|
-
} catch (
|
|
3426
|
-
|
|
3441
|
+
} catch (v) {
|
|
3442
|
+
p.error("Haori", `Invalid after script: ${v}`);
|
|
3427
3443
|
}
|
|
3428
3444
|
}
|
|
3429
3445
|
if (e.hasAttribute(h.attrName(t, "dialog")) && (r.dialogMessage = e.getAttribute(h.attrName(t, "dialog")).replace(/\\n/g, `
|
|
@@ -3431,10 +3447,10 @@ ${S}
|
|
|
3431
3447
|
r.toastMessage = e.getAttribute(
|
|
3432
3448
|
h.attrName(t, "toast")
|
|
3433
3449
|
);
|
|
3434
|
-
const
|
|
3450
|
+
const E = e.getRawAttribute(
|
|
3435
3451
|
h.attrName(t, "toast-level")
|
|
3436
|
-
),
|
|
3437
|
-
r.toastLevel =
|
|
3452
|
+
), F = ["info", "warning", "error", "success"].includes(E);
|
|
3453
|
+
r.toastLevel = F ? E : null;
|
|
3438
3454
|
}
|
|
3439
3455
|
if (e.hasAttribute(h.attrName(t, "redirect")) && (r.redirectUrl = e.getAttribute(
|
|
3440
3456
|
h.attrName(t, "redirect")
|
|
@@ -3443,19 +3459,19 @@ ${S}
|
|
|
3443
3459
|
)), e.hasAttribute(h.attrName(t, "history")) && (r.historyUrl = e.getAttribute(
|
|
3444
3460
|
h.attrName(t, "history")
|
|
3445
3461
|
)), e.hasAttribute(h.attrName(t, "history-data")) && (r.historyDataAttrName = h.attrName(t, "history-data")), e.hasAttribute(h.attrName(t, "history-form"))) {
|
|
3446
|
-
const
|
|
3462
|
+
const E = e.getRawAttribute(
|
|
3447
3463
|
h.attrName(t, "history-form")
|
|
3448
3464
|
);
|
|
3449
|
-
if (
|
|
3450
|
-
const
|
|
3451
|
-
|
|
3452
|
-
w.get(
|
|
3453
|
-
) :
|
|
3465
|
+
if (E) {
|
|
3466
|
+
const v = document.body.querySelector(E);
|
|
3467
|
+
v !== null ? r.historyFormFragment = A.getFormFragment(
|
|
3468
|
+
w.get(v)
|
|
3469
|
+
) : p.error(
|
|
3454
3470
|
"Haori",
|
|
3455
|
-
`Form element not found: ${
|
|
3471
|
+
`Form element not found: ${E} (${h.attrName(t, "history-form")})`
|
|
3456
3472
|
);
|
|
3457
3473
|
} else
|
|
3458
|
-
r.historyFormFragment =
|
|
3474
|
+
r.historyFormFragment = A.getFormFragment(e);
|
|
3459
3475
|
}
|
|
3460
3476
|
[
|
|
3461
3477
|
"reset-before",
|
|
@@ -3465,75 +3481,75 @@ ${S}
|
|
|
3465
3481
|
"copy",
|
|
3466
3482
|
"open",
|
|
3467
3483
|
"close"
|
|
3468
|
-
].forEach((
|
|
3469
|
-
const
|
|
3470
|
-
if (!e.hasAttribute(
|
|
3484
|
+
].forEach((E) => {
|
|
3485
|
+
const v = h.attrName(t, E);
|
|
3486
|
+
if (!e.hasAttribute(v))
|
|
3471
3487
|
return;
|
|
3472
|
-
const
|
|
3473
|
-
if (
|
|
3474
|
-
const
|
|
3475
|
-
|
|
3476
|
-
}),
|
|
3477
|
-
switch (
|
|
3488
|
+
const F = e.getRawAttribute(v), x = [];
|
|
3489
|
+
if (F ? (document.body.querySelectorAll(F).forEach((B) => {
|
|
3490
|
+
const K = w.get(B);
|
|
3491
|
+
K && x.push(K);
|
|
3492
|
+
}), x.length === 0 && p.error("Haori", `Element not found: ${F} (${v})`)) : x.push(e), x.length > 0)
|
|
3493
|
+
switch (E) {
|
|
3478
3494
|
case "reset-before":
|
|
3479
|
-
r.resetBeforeFragments =
|
|
3495
|
+
r.resetBeforeFragments = x;
|
|
3480
3496
|
break;
|
|
3481
3497
|
case "reset":
|
|
3482
|
-
r.resetFragments =
|
|
3498
|
+
r.resetFragments = x;
|
|
3483
3499
|
break;
|
|
3484
3500
|
case "refetch":
|
|
3485
|
-
r.refetchFragments =
|
|
3501
|
+
r.refetchFragments = x;
|
|
3486
3502
|
break;
|
|
3487
3503
|
case "click":
|
|
3488
|
-
r.clickFragments =
|
|
3504
|
+
r.clickFragments = x;
|
|
3489
3505
|
break;
|
|
3490
3506
|
case "copy":
|
|
3491
|
-
r.copyFragments =
|
|
3507
|
+
r.copyFragments = x;
|
|
3492
3508
|
break;
|
|
3493
3509
|
case "open":
|
|
3494
|
-
r.openFragments =
|
|
3510
|
+
r.openFragments = x;
|
|
3495
3511
|
break;
|
|
3496
3512
|
case "close":
|
|
3497
|
-
r.closeFragments =
|
|
3513
|
+
r.closeFragments = x;
|
|
3498
3514
|
break;
|
|
3499
3515
|
}
|
|
3500
3516
|
});
|
|
3501
3517
|
const b = h.attrName(t, "copy-source");
|
|
3502
3518
|
if (e.hasAttribute(b)) {
|
|
3503
|
-
const
|
|
3519
|
+
const E = e.getRawAttribute(
|
|
3504
3520
|
b
|
|
3505
3521
|
);
|
|
3506
|
-
if (
|
|
3507
|
-
const
|
|
3508
|
-
if (
|
|
3509
|
-
const
|
|
3510
|
-
|
|
3522
|
+
if (E) {
|
|
3523
|
+
const v = document.body.querySelector(E);
|
|
3524
|
+
if (v !== null) {
|
|
3525
|
+
const F = w.get(v);
|
|
3526
|
+
F ? r.copySourceFragment = F : p.error(
|
|
3511
3527
|
"Haori",
|
|
3512
|
-
`Element is not managed by Haori: ${
|
|
3528
|
+
`Element is not managed by Haori: ${E} (${b})`
|
|
3513
3529
|
);
|
|
3514
3530
|
} else
|
|
3515
|
-
|
|
3531
|
+
p.error(
|
|
3516
3532
|
"Haori",
|
|
3517
|
-
`Element not found: ${
|
|
3533
|
+
`Element not found: ${E} (${b})`
|
|
3518
3534
|
);
|
|
3519
3535
|
} else
|
|
3520
3536
|
r.copySourceFragment = e;
|
|
3521
3537
|
}
|
|
3522
3538
|
}
|
|
3523
3539
|
if (!t && (e.hasAttribute(h.attrName(null, "data", !0)) && (r.dataAttrName = h.attrName(null, "data", !0)), e.hasAttribute(h.attrName(null, "form", !0)))) {
|
|
3524
|
-
const
|
|
3540
|
+
const m = e.getRawAttribute(
|
|
3525
3541
|
h.attrName(null, "form", !0)
|
|
3526
3542
|
);
|
|
3527
|
-
if (
|
|
3528
|
-
const b = document.body.querySelector(
|
|
3529
|
-
b !== null ? r.formFragment =
|
|
3543
|
+
if (m) {
|
|
3544
|
+
const b = document.body.querySelector(m);
|
|
3545
|
+
b !== null ? r.formFragment = A.getFormFragment(
|
|
3530
3546
|
w.get(b)
|
|
3531
|
-
) :
|
|
3547
|
+
) : p.error(
|
|
3532
3548
|
"Haori",
|
|
3533
|
-
`Form element not found: ${
|
|
3549
|
+
`Form element not found: ${m} (${h.attrName(null, "fetch-form", !0)})`
|
|
3534
3550
|
);
|
|
3535
3551
|
} else
|
|
3536
|
-
r.formFragment =
|
|
3552
|
+
r.formFragment = A.getFormFragment(e);
|
|
3537
3553
|
}
|
|
3538
3554
|
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [e]), r;
|
|
3539
3555
|
}
|
|
@@ -3598,7 +3614,7 @@ ${S}
|
|
|
3598
3614
|
return !1;
|
|
3599
3615
|
this.options.resetBeforeFragments && this.options.resetBeforeFragments.length > 0 && (await Promise.all(
|
|
3600
3616
|
this.options.resetBeforeFragments.map(
|
|
3601
|
-
(d) =>
|
|
3617
|
+
(d) => A.reset(d)
|
|
3602
3618
|
)
|
|
3603
3619
|
), this.captureHistorySnapshots());
|
|
3604
3620
|
const r = this.prepareFetchRequest(), i = r.payload;
|
|
@@ -3616,48 +3632,48 @@ ${S}
|
|
|
3616
3632
|
}
|
|
3617
3633
|
const a = Object.keys(i).length > 0;
|
|
3618
3634
|
if (s) {
|
|
3619
|
-
const d = { ...n || {} }, f = r.requestedMethod,
|
|
3620
|
-
if (
|
|
3621
|
-
runtime:
|
|
3635
|
+
const d = { ...n || {} }, f = r.requestedMethod, g = r.effectiveMethod, y = r.transportMode === "query-get", T = r.queryString;
|
|
3636
|
+
if (y && p.info("Haori demo fetch normalization", {
|
|
3637
|
+
runtime: u.runtime,
|
|
3622
3638
|
requestedMethod: f,
|
|
3623
|
-
effectiveMethod:
|
|
3639
|
+
effectiveMethod: g,
|
|
3624
3640
|
transportMode: "query-get",
|
|
3625
3641
|
url: s,
|
|
3626
3642
|
payload: a ? i : void 0,
|
|
3627
|
-
queryString:
|
|
3643
|
+
queryString: T
|
|
3628
3644
|
}), this.options.targetFragment && s) {
|
|
3629
|
-
const
|
|
3630
|
-
runtime:
|
|
3645
|
+
const m = performance.now(), b = {
|
|
3646
|
+
runtime: u.runtime,
|
|
3631
3647
|
requestedMethod: f,
|
|
3632
|
-
effectiveMethod:
|
|
3633
|
-
transportMode:
|
|
3634
|
-
...
|
|
3648
|
+
effectiveMethod: g,
|
|
3649
|
+
transportMode: y ? "query-get" : "http",
|
|
3650
|
+
...y ? { queryString: T } : {}
|
|
3635
3651
|
};
|
|
3636
|
-
return
|
|
3652
|
+
return R.fetchStart(
|
|
3637
3653
|
this.options.targetFragment.getTarget(),
|
|
3638
3654
|
s,
|
|
3639
3655
|
d,
|
|
3640
3656
|
a ? i : void 0,
|
|
3641
|
-
S
|
|
3642
|
-
), fetch(s, d).then((A) => this.handleFetchResult(
|
|
3643
|
-
A,
|
|
3644
|
-
s || void 0,
|
|
3645
3657
|
b
|
|
3646
|
-
)).
|
|
3647
|
-
|
|
3658
|
+
), fetch(s, d).then((E) => this.handleFetchResult(
|
|
3659
|
+
E,
|
|
3660
|
+
s || void 0,
|
|
3661
|
+
m
|
|
3662
|
+
)).catch((E) => {
|
|
3663
|
+
throw s && R.fetchError(
|
|
3648
3664
|
this.options.targetFragment.getTarget(),
|
|
3649
3665
|
s,
|
|
3650
|
-
|
|
3651
|
-
),
|
|
3666
|
+
E
|
|
3667
|
+
), E;
|
|
3652
3668
|
});
|
|
3653
3669
|
}
|
|
3654
|
-
return fetch(s, d).then((
|
|
3670
|
+
return fetch(s, d).then((m) => this.handleFetchResult(m, s || void 0));
|
|
3655
3671
|
}
|
|
3656
3672
|
if ((!this.options.bindFragments || this.options.bindFragments.length === 0) && this.options.formFragment && a) {
|
|
3657
|
-
const d = this.options.formFragment, f = d.getTarget(),
|
|
3658
|
-
e && e.appliedDisabledAttribute && this.options.targetFragment &&
|
|
3659
|
-
const
|
|
3660
|
-
Object.assign(
|
|
3673
|
+
const d = this.options.formFragment, f = d.getTarget(), g = /* @__PURE__ */ new Set();
|
|
3674
|
+
e && e.appliedDisabledAttribute && this.options.targetFragment && g.add(this.options.targetFragment), f.setAttribute(`${u.prefix}bind`, JSON.stringify(i));
|
|
3675
|
+
const y = d.getBindingData();
|
|
3676
|
+
Object.assign(y, i), await P.setBindingData(f, y, g);
|
|
3661
3677
|
}
|
|
3662
3678
|
const o = a ? i : {}, c = new Response(JSON.stringify(o), {
|
|
3663
3679
|
headers: { "Content-Type": "application/json" }
|
|
@@ -3696,14 +3712,14 @@ ${S}
|
|
|
3696
3712
|
async handleFetchResult(e, t, r) {
|
|
3697
3713
|
const i = ie();
|
|
3698
3714
|
if (!e.ok)
|
|
3699
|
-
return this.options.targetFragment && t &&
|
|
3715
|
+
return this.options.targetFragment && t && R.fetchError(
|
|
3700
3716
|
this.options.targetFragment.getTarget(),
|
|
3701
3717
|
t,
|
|
3702
3718
|
new Error(`${e.status} ${e.statusText}`),
|
|
3703
3719
|
e.status,
|
|
3704
3720
|
r
|
|
3705
3721
|
), await this.handleFetchError(e), !1;
|
|
3706
|
-
if (this.options.targetFragment && t && r &&
|
|
3722
|
+
if (this.options.targetFragment && t && r && R.fetchEnd(
|
|
3707
3723
|
this.options.targetFragment.getTarget(),
|
|
3708
3724
|
t,
|
|
3709
3725
|
e.status,
|
|
@@ -3718,14 +3734,14 @@ ${S}
|
|
|
3718
3734
|
}
|
|
3719
3735
|
const s = [];
|
|
3720
3736
|
s.push(this.bindResult(e)), s.push(this.adjust()), s.push(this.addRow()), s.push(this.removeRow()), s.push(this.movePrevRow()), s.push(this.moveNextRow()), await Promise.all(s), this.options.resetFragments && this.options.resetFragments.length > 0 && await Promise.all(
|
|
3721
|
-
this.options.resetFragments.map((a) =>
|
|
3737
|
+
this.options.resetFragments.map((a) => A.reset(a))
|
|
3722
3738
|
), await this.copy();
|
|
3723
3739
|
const n = [];
|
|
3724
3740
|
if (this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
3725
3741
|
n.push(new h(a, null).run());
|
|
3726
3742
|
}), this.options.clickFragments && this.options.clickFragments.length > 0)
|
|
3727
3743
|
for (const a of this.options.clickFragments) {
|
|
3728
|
-
await
|
|
3744
|
+
await P.evaluateAll(a);
|
|
3729
3745
|
const o = a.getTarget();
|
|
3730
3746
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
3731
3747
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
@@ -3733,10 +3749,10 @@ ${S}
|
|
|
3733
3749
|
}
|
|
3734
3750
|
return this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
3735
3751
|
const o = a.getTarget();
|
|
3736
|
-
o instanceof HTMLElement ? n.push(i.openDialog(o)) :
|
|
3752
|
+
o instanceof HTMLElement ? n.push(i.openDialog(o)) : p.error("Haori", "Element is not an HTML element: ", o);
|
|
3737
3753
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
3738
3754
|
const o = a.getTarget();
|
|
3739
|
-
o instanceof HTMLElement ? n.push(i.closeDialog(o)) :
|
|
3755
|
+
o instanceof HTMLElement ? n.push(i.closeDialog(o)) : p.error("Haori", "Element is not an HTML element: ", o);
|
|
3740
3756
|
}), await Promise.all(n), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3741
3757
|
this.options.toastMessage,
|
|
3742
3758
|
this.options.toastLevel ?? "info"
|
|
@@ -3756,12 +3772,12 @@ ${S}
|
|
|
3756
3772
|
const n = e ? this.options.historyUrl : window.location.pathname, a = new URL(n, window.location.href);
|
|
3757
3773
|
if (a.origin !== window.location.origin) {
|
|
3758
3774
|
const c = "history.pushState: cross-origin URL is not allowed: " + a.toString();
|
|
3759
|
-
|
|
3775
|
+
p.error("Haori", c);
|
|
3760
3776
|
return;
|
|
3761
3777
|
}
|
|
3762
3778
|
const o = (c) => {
|
|
3763
3779
|
for (const [d, f] of Object.entries(c))
|
|
3764
|
-
f != null && (Array.isArray(f) ? f.forEach((
|
|
3780
|
+
f != null && (Array.isArray(f) ? f.forEach((g) => a.searchParams.append(d, String(g))) : typeof f == "object" ? a.searchParams.set(d, JSON.stringify(f)) : a.searchParams.set(d, String(f)));
|
|
3765
3781
|
};
|
|
3766
3782
|
i && o(t), s && o(r), history.pushState(
|
|
3767
3783
|
{ [ge]: !0 },
|
|
@@ -3769,7 +3785,7 @@ ${S}
|
|
|
3769
3785
|
a.toString()
|
|
3770
3786
|
);
|
|
3771
3787
|
} catch (n) {
|
|
3772
|
-
|
|
3788
|
+
p.error("Haori", `history.pushState failed: ${n}`);
|
|
3773
3789
|
}
|
|
3774
3790
|
}
|
|
3775
3791
|
/**
|
|
@@ -3777,7 +3793,7 @@ ${S}
|
|
|
3777
3793
|
*/
|
|
3778
3794
|
async handleFetchError(e) {
|
|
3779
3795
|
let t = null;
|
|
3780
|
-
this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t =
|
|
3796
|
+
this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3781
3797
|
const r = async (n) => {
|
|
3782
3798
|
const a = t ? t.getTarget() : document.body;
|
|
3783
3799
|
await ie().addErrorMessage(a, n);
|
|
@@ -3806,7 +3822,7 @@ ${S}
|
|
|
3806
3822
|
if (a.length === 0)
|
|
3807
3823
|
return await r(`${e.status} ${e.statusText}`), i(), !1;
|
|
3808
3824
|
for (const o of a)
|
|
3809
|
-
o.key && t ? await
|
|
3825
|
+
o.key && t ? await A.addErrorMessage(t, o.key, o.message) : await r(o.message);
|
|
3810
3826
|
return i(), !1;
|
|
3811
3827
|
} catch {
|
|
3812
3828
|
}
|
|
@@ -3893,24 +3909,26 @@ ${S}
|
|
|
3893
3909
|
);
|
|
3894
3910
|
} else
|
|
3895
3911
|
n[a] = r;
|
|
3896
|
-
i.push(
|
|
3912
|
+
i.push(P.setBindingData(s.getTarget(), n));
|
|
3897
3913
|
});
|
|
3898
3914
|
else {
|
|
3899
3915
|
if (typeof r == "string")
|
|
3900
|
-
return
|
|
3916
|
+
return p.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
3901
3917
|
new Error("string data cannot be bound without a bindArg.")
|
|
3902
3918
|
);
|
|
3903
3919
|
this.options.bindFragments.forEach((s) => {
|
|
3904
3920
|
const n = this.mergeAppendBindingData(
|
|
3905
3921
|
s,
|
|
3906
3922
|
r
|
|
3907
|
-
);
|
|
3908
|
-
i.push(
|
|
3909
|
-
M.setBindingData(s.getTarget(), n)
|
|
3910
|
-
);
|
|
3923
|
+
), a = this.options.bindMerge ? { ...s.getRawBindingData() ?? {}, ...n } : n;
|
|
3924
|
+
i.push(P.setBindingData(s.getTarget(), a));
|
|
3911
3925
|
});
|
|
3912
3926
|
}
|
|
3913
3927
|
return Promise.all(i).then(() => {
|
|
3928
|
+
const s = this.options.bindArg ?? null;
|
|
3929
|
+
this.options.bindFragments.forEach((n) => {
|
|
3930
|
+
R.bindComplete(n.getTarget(), s);
|
|
3931
|
+
});
|
|
3914
3932
|
});
|
|
3915
3933
|
});
|
|
3916
3934
|
}
|
|
@@ -3938,7 +3956,7 @@ ${S}
|
|
|
3938
3956
|
...i.getBindingData(),
|
|
3939
3957
|
...t
|
|
3940
3958
|
};
|
|
3941
|
-
return
|
|
3959
|
+
return P.setBindingData(i.getTarget(), s);
|
|
3942
3960
|
});
|
|
3943
3961
|
return Promise.all(r).then(() => {
|
|
3944
3962
|
});
|
|
@@ -3947,7 +3965,7 @@ ${S}
|
|
|
3947
3965
|
* copy のコピー元データを取得します。
|
|
3948
3966
|
*/
|
|
3949
3967
|
resolveCopySourceData() {
|
|
3950
|
-
return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ?
|
|
3968
|
+
return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ? A.getValues(this.options.copySourceFragment) : { ...this.options.copySourceFragment.getBindingData() } : this.options.formFragment ? A.getValues(this.options.formFragment) : this.options.targetFragment ? { ...this.options.targetFragment.getBindingData() } : {};
|
|
3951
3969
|
}
|
|
3952
3970
|
/**
|
|
3953
3971
|
* data 属性とフォーム値を統合した送信データを作成します。
|
|
@@ -3965,7 +3983,7 @@ ${S}
|
|
|
3965
3983
|
buildPayloadResolution() {
|
|
3966
3984
|
const e = {};
|
|
3967
3985
|
let t = !1;
|
|
3968
|
-
if (this.options.formFragment && Object.assign(e,
|
|
3986
|
+
if (this.options.formFragment && Object.assign(e, A.getValues(this.options.formFragment)), this.options.data && typeof this.options.data == "object" && Object.assign(e, this.options.data), this.options.targetFragment && this.options.dataAttrName) {
|
|
3969
3987
|
const r = h.resolveDataAttributeDetailed(
|
|
3970
3988
|
this.options.targetFragment,
|
|
3971
3989
|
this.options.dataAttrName
|
|
@@ -4007,22 +4025,22 @@ ${S}
|
|
|
4007
4025
|
let i = this.options.fetchUrl;
|
|
4008
4026
|
const s = { ...this.options.fetchOptions || {} }, n = new Headers(
|
|
4009
4027
|
s.headers || void 0
|
|
4010
|
-
), a = (s.method || "GET").toUpperCase(), o =
|
|
4028
|
+
), a = (s.method || "GET").toUpperCase(), o = u.runtime === "demo" && !be(a), c = o ? "GET" : a;
|
|
4011
4029
|
if (s.method = c, c === "GET" || c === "HEAD" || c === "OPTIONS")
|
|
4012
4030
|
Object.keys(t).length > 0 && (i = ye(i, t));
|
|
4013
4031
|
else if (Object.keys(t).length > 0) {
|
|
4014
4032
|
const f = n.get("Content-Type") || "";
|
|
4015
4033
|
if (/multipart\/form-data/i.test(f)) {
|
|
4016
4034
|
n.delete("Content-Type");
|
|
4017
|
-
const
|
|
4018
|
-
for (const [
|
|
4019
|
-
|
|
4020
|
-
s.body =
|
|
4035
|
+
const g = new FormData();
|
|
4036
|
+
for (const [y, T] of Object.entries(t))
|
|
4037
|
+
T == null ? g.append(y, "") : T instanceof Blob ? g.append(y, T) : Array.isArray(T) ? T.forEach((m) => g.append(y, String(m))) : typeof T == "object" ? g.append(y, JSON.stringify(T)) : g.append(y, String(T));
|
|
4038
|
+
s.body = g;
|
|
4021
4039
|
} else if (/application\/x-www-form-urlencoded/i.test(f)) {
|
|
4022
|
-
const
|
|
4023
|
-
for (const [
|
|
4024
|
-
|
|
4025
|
-
s.body =
|
|
4040
|
+
const g = new URLSearchParams();
|
|
4041
|
+
for (const [y, T] of Object.entries(t))
|
|
4042
|
+
T !== void 0 && (T === null ? g.append(y, "") : Array.isArray(T) ? T.forEach((m) => g.append(y, String(m))) : typeof T == "object" ? g.append(y, JSON.stringify(T)) : g.append(y, String(T)));
|
|
4043
|
+
s.body = g;
|
|
4026
4044
|
} else
|
|
4027
4045
|
n.set("Content-Type", "application/json"), s.body = JSON.stringify(t);
|
|
4028
4046
|
}
|
|
@@ -4047,7 +4065,7 @@ ${S}
|
|
|
4047
4065
|
this.options.targetFragment && this.options.historyDataAttrName ? this.historyDataSnapshot = h.resolveDataAttribute(
|
|
4048
4066
|
this.options.targetFragment,
|
|
4049
4067
|
this.options.historyDataAttrName
|
|
4050
|
-
) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ?
|
|
4068
|
+
) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? A.getValues(this.options.historyFormFragment) : void 0;
|
|
4051
4069
|
}
|
|
4052
4070
|
/**
|
|
4053
4071
|
* history-data の評価値を取得します。
|
|
@@ -4069,7 +4087,7 @@ ${S}
|
|
|
4069
4087
|
if (this.historyFormSnapshot !== void 0)
|
|
4070
4088
|
return this.historyFormSnapshot;
|
|
4071
4089
|
if (this.options.historyFormFragment)
|
|
4072
|
-
return
|
|
4090
|
+
return A.getValues(this.options.historyFormFragment);
|
|
4073
4091
|
}
|
|
4074
4092
|
/**
|
|
4075
4093
|
* copy-params が指定されている場合は include / exclude を考慮して抽出します。
|
|
@@ -4117,11 +4135,11 @@ ${S}
|
|
|
4117
4135
|
*/
|
|
4118
4136
|
getRowFragment() {
|
|
4119
4137
|
if (!this.options.targetFragment)
|
|
4120
|
-
return
|
|
4138
|
+
return p.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
4121
4139
|
const e = this.options.targetFragment.closestByAttribute(
|
|
4122
|
-
`${
|
|
4140
|
+
`${u.prefix}row`
|
|
4123
4141
|
);
|
|
4124
|
-
return e || (
|
|
4142
|
+
return e || (p.error("Haori", "Row fragment not found."), null);
|
|
4125
4143
|
}
|
|
4126
4144
|
/**
|
|
4127
4145
|
* 行を追加します。
|
|
@@ -4137,7 +4155,7 @@ ${S}
|
|
|
4137
4155
|
const t = [], r = e.clone();
|
|
4138
4156
|
return t.push(
|
|
4139
4157
|
e.getParent().insertAfter(r, e)
|
|
4140
|
-
), t.push(
|
|
4158
|
+
), t.push(P.evaluateAll(r)), t.push(A.reset(r)), Promise.all(t).then(() => {
|
|
4141
4159
|
});
|
|
4142
4160
|
}
|
|
4143
4161
|
/**
|
|
@@ -4152,7 +4170,7 @@ ${S}
|
|
|
4152
4170
|
if (!e)
|
|
4153
4171
|
return Promise.reject(new Error("Row fragment not found."));
|
|
4154
4172
|
const t = e.getParent();
|
|
4155
|
-
return t && t.getChildElementFragments().filter((i) => !i.hasAttribute(`${
|
|
4173
|
+
return t && t.getChildElementFragments().filter((i) => !i.hasAttribute(`${u.prefix}each-before`) && !i.hasAttribute(`${u.prefix}each-after`)).length <= 1 ? Promise.resolve() : e.remove();
|
|
4156
4174
|
}
|
|
4157
4175
|
/**
|
|
4158
4176
|
* 前の行へ移動します。
|
|
@@ -4190,7 +4208,7 @@ ${S}
|
|
|
4190
4208
|
}
|
|
4191
4209
|
};
|
|
4192
4210
|
h.DATA_PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g, h.SINGLE_PLACEHOLDER_REGEX = /^(\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\})$/, h.RUNNING_CLICK_TARGETS = /* @__PURE__ */ new WeakSet();
|
|
4193
|
-
let
|
|
4211
|
+
let q = h;
|
|
4194
4212
|
class Se {
|
|
4195
4213
|
/**
|
|
4196
4214
|
* URLのクエリパラメータを取得します。
|
|
@@ -4204,7 +4222,7 @@ class Se {
|
|
|
4204
4222
|
}), e;
|
|
4205
4223
|
}
|
|
4206
4224
|
}
|
|
4207
|
-
class
|
|
4225
|
+
class Te {
|
|
4208
4226
|
/**
|
|
4209
4227
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
4210
4228
|
*
|
|
@@ -4222,27 +4240,27 @@ class De {
|
|
|
4222
4240
|
try {
|
|
4223
4241
|
r = await fetch(e, t);
|
|
4224
4242
|
} catch (s) {
|
|
4225
|
-
throw
|
|
4243
|
+
throw p.error("[Haori]", "Failed to fetch import source:", e, s), new Error(`Failed to fetch: ${e}`);
|
|
4226
4244
|
}
|
|
4227
4245
|
if (!r.ok) {
|
|
4228
4246
|
const s = `${r.status} ${r.statusText}`;
|
|
4229
|
-
throw
|
|
4247
|
+
throw p.error("[Haori]", "Import HTTP error:", e, s), new Error(`Failed to load ${e}: ${s}`);
|
|
4230
4248
|
}
|
|
4231
4249
|
let i;
|
|
4232
4250
|
try {
|
|
4233
4251
|
i = await r.text();
|
|
4234
4252
|
} catch (s) {
|
|
4235
|
-
throw
|
|
4253
|
+
throw p.error("[Haori]", "Failed to read response text:", e, s), new Error(`Failed to read response from: ${e}`);
|
|
4236
4254
|
}
|
|
4237
4255
|
try {
|
|
4238
4256
|
const n = new DOMParser().parseFromString(i, "text/html");
|
|
4239
|
-
return n && n.body ? n.body.innerHTML : (
|
|
4257
|
+
return n && n.body ? n.body.innerHTML : (p.warn("[Haori]", "No body found in imported document:", e), i);
|
|
4240
4258
|
} catch (s) {
|
|
4241
|
-
return
|
|
4259
|
+
return p.error("[Haori]", "Failed to parse imported HTML:", e, s), i;
|
|
4242
4260
|
}
|
|
4243
4261
|
}
|
|
4244
4262
|
}
|
|
4245
|
-
const
|
|
4263
|
+
const l = class l {
|
|
4246
4264
|
/**
|
|
4247
4265
|
* 遅延属性かどうか(完全名で判定)を判定します。
|
|
4248
4266
|
*
|
|
@@ -4250,8 +4268,8 @@ const u = class u {
|
|
|
4250
4268
|
* @returns 遅延属性かどうか
|
|
4251
4269
|
*/
|
|
4252
4270
|
static isDeferredAttributeName(e) {
|
|
4253
|
-
return
|
|
4254
|
-
(t) => e === `${
|
|
4271
|
+
return l.DEFERRED_ATTRIBUTE_SUFFIXES.some(
|
|
4272
|
+
(t) => e === `${u.prefix}${t}`
|
|
4255
4273
|
);
|
|
4256
4274
|
}
|
|
4257
4275
|
/**
|
|
@@ -4261,8 +4279,8 @@ const u = class u {
|
|
|
4261
4279
|
* @returns 除外対象かどうか
|
|
4262
4280
|
*/
|
|
4263
4281
|
static isEvaluateAllExcludedAttributeName(e) {
|
|
4264
|
-
return
|
|
4265
|
-
(t) => e === `${
|
|
4282
|
+
return l.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES.some(
|
|
4283
|
+
(t) => e === `${u.prefix}${t}`
|
|
4266
4284
|
);
|
|
4267
4285
|
}
|
|
4268
4286
|
/**
|
|
@@ -4273,7 +4291,7 @@ const u = class u {
|
|
|
4273
4291
|
* @returns 再評価する場合は true
|
|
4274
4292
|
*/
|
|
4275
4293
|
static shouldReevaluateAttribute(e, t) {
|
|
4276
|
-
return t !== null && !
|
|
4294
|
+
return t !== null && !l.isEvaluateAllExcludedAttributeName(e) && l.ATTRIBUTE_PLACEHOLDER_REGEX.test(t);
|
|
4277
4295
|
}
|
|
4278
4296
|
/**
|
|
4279
4297
|
* data-attr-* 形式の属性名から実際に更新する属性名を取得します。
|
|
@@ -4282,7 +4300,7 @@ const u = class u {
|
|
|
4282
4300
|
* @returns 実際の属性名。data-attr-* でない場合は null
|
|
4283
4301
|
*/
|
|
4284
4302
|
static getAliasedAttributeName(e) {
|
|
4285
|
-
const t = `${
|
|
4303
|
+
const t = `${u.prefix}${l.ATTRIBUTE_ALIAS_SUFFIX}`;
|
|
4286
4304
|
return !e.startsWith(t) || e.length <= t.length ? null : e.slice(t.length);
|
|
4287
4305
|
}
|
|
4288
4306
|
/**
|
|
@@ -4294,8 +4312,8 @@ const u = class u {
|
|
|
4294
4312
|
*/
|
|
4295
4313
|
static isAliasedAttributeReflection(e, t) {
|
|
4296
4314
|
const r = w.get(e);
|
|
4297
|
-
return r instanceof
|
|
4298
|
-
`${
|
|
4315
|
+
return r instanceof C ? r.hasAttribute(
|
|
4316
|
+
`${u.prefix}${l.ATTRIBUTE_ALIAS_SUFFIX}${t}`
|
|
4299
4317
|
) : !1;
|
|
4300
4318
|
}
|
|
4301
4319
|
/**
|
|
@@ -4309,8 +4327,8 @@ const u = class u {
|
|
|
4309
4327
|
let t = Promise.resolve();
|
|
4310
4328
|
for (const r of e.getAttributeNames()) {
|
|
4311
4329
|
const i = e.getRawAttribute(r);
|
|
4312
|
-
|
|
4313
|
-
() =>
|
|
4330
|
+
l.shouldReevaluateAttribute(r, i) && (t = t.then(
|
|
4331
|
+
() => l.setAttribute(e.getTarget(), r, i)
|
|
4314
4332
|
));
|
|
4315
4333
|
}
|
|
4316
4334
|
return t.then(() => {
|
|
@@ -4325,7 +4343,7 @@ const u = class u {
|
|
|
4325
4343
|
static reevaluateChildren(e) {
|
|
4326
4344
|
const t = [];
|
|
4327
4345
|
return e.getChildren().forEach((r) => {
|
|
4328
|
-
r instanceof
|
|
4346
|
+
r instanceof C ? t.push(l.evaluateAll(r)) : r instanceof H && t.push(l.evaluateText(r));
|
|
4329
4347
|
}), Promise.all(t).then(() => {
|
|
4330
4348
|
});
|
|
4331
4349
|
}
|
|
@@ -4336,7 +4354,7 @@ const u = class u {
|
|
|
4336
4354
|
* @returns 再評価状態
|
|
4337
4355
|
*/
|
|
4338
4356
|
static getReactiveFetchState(e) {
|
|
4339
|
-
const t =
|
|
4357
|
+
const t = l.REACTIVE_FETCH_STATES.get(e);
|
|
4340
4358
|
if (t)
|
|
4341
4359
|
return t;
|
|
4342
4360
|
const r = {
|
|
@@ -4344,7 +4362,7 @@ const u = class u {
|
|
|
4344
4362
|
running: !1,
|
|
4345
4363
|
rerunRequested: !1
|
|
4346
4364
|
};
|
|
4347
|
-
return
|
|
4365
|
+
return l.REACTIVE_FETCH_STATES.set(e, r), r;
|
|
4348
4366
|
}
|
|
4349
4367
|
/**
|
|
4350
4368
|
* data-import の再評価状態を取得します。
|
|
@@ -4353,7 +4371,7 @@ const u = class u {
|
|
|
4353
4371
|
* @returns 再評価状態
|
|
4354
4372
|
*/
|
|
4355
4373
|
static getReactiveImportState(e) {
|
|
4356
|
-
const t =
|
|
4374
|
+
const t = l.REACTIVE_IMPORT_STATES.get(e);
|
|
4357
4375
|
if (t)
|
|
4358
4376
|
return t;
|
|
4359
4377
|
const r = {
|
|
@@ -4361,7 +4379,7 @@ const u = class u {
|
|
|
4361
4379
|
running: !1,
|
|
4362
4380
|
rerunRequested: !1
|
|
4363
4381
|
};
|
|
4364
|
-
return
|
|
4382
|
+
return l.REACTIVE_IMPORT_STATES.set(e, r), r;
|
|
4365
4383
|
}
|
|
4366
4384
|
/**
|
|
4367
4385
|
* bind 更新時に data-fetch / data-import を専用ルートで再評価します。
|
|
@@ -4374,9 +4392,9 @@ const u = class u {
|
|
|
4374
4392
|
if (t.has(e))
|
|
4375
4393
|
return Promise.resolve();
|
|
4376
4394
|
const r = [];
|
|
4377
|
-
return e.hasAttribute(`${
|
|
4378
|
-
i instanceof
|
|
4379
|
-
|
|
4395
|
+
return e.hasAttribute(`${u.prefix}fetch`) && r.push(l.executeManagedFetch(e)), e.hasAttribute(`${u.prefix}import`) && r.push(l.executeManagedImport(e)), e.getChildren().forEach((i) => {
|
|
4396
|
+
i instanceof C && r.push(
|
|
4397
|
+
l.reevaluateReactiveSpecialAttributes(i, t)
|
|
4380
4398
|
);
|
|
4381
4399
|
}), Promise.all(r).then(() => {
|
|
4382
4400
|
});
|
|
@@ -4388,11 +4406,11 @@ const u = class u {
|
|
|
4388
4406
|
* @returns 実行完了の Promise
|
|
4389
4407
|
*/
|
|
4390
4408
|
static executeManagedFetch(e) {
|
|
4391
|
-
const t = e.getTarget(), r =
|
|
4392
|
-
return r.running ? ((i.hasUnresolvedReference || i.signature !== r.lastSignature) && (r.rerunRequested = !0), Promise.resolve()) : i.hasUnresolvedReference || i.signature === null ? (r.lastSignature = null, Promise.resolve()) : r.lastSignature === i.signature ? Promise.resolve() : (r.lastSignature = i.signature, r.running = !0, new
|
|
4409
|
+
const t = e.getTarget(), r = l.getReactiveFetchState(t), i = q.resolveAutoFetchSignature(e);
|
|
4410
|
+
return r.running ? ((i.hasUnresolvedReference || i.signature !== r.lastSignature) && (r.rerunRequested = !0), Promise.resolve()) : i.hasUnresolvedReference || i.signature === null ? (r.lastSignature = null, Promise.resolve()) : r.lastSignature === i.signature ? Promise.resolve() : (r.lastSignature = i.signature, r.running = !0, new q(e, null).runWithResult().then(() => {
|
|
4393
4411
|
}).finally(() => {
|
|
4394
4412
|
if (r.running = !1, r.rerunRequested)
|
|
4395
|
-
return r.rerunRequested = !1,
|
|
4413
|
+
return r.rerunRequested = !1, l.executeManagedFetch(e);
|
|
4396
4414
|
}));
|
|
4397
4415
|
}
|
|
4398
4416
|
/**
|
|
@@ -4402,8 +4420,8 @@ const u = class u {
|
|
|
4402
4420
|
* @returns 実行完了の Promise
|
|
4403
4421
|
*/
|
|
4404
4422
|
static executeManagedImport(e) {
|
|
4405
|
-
const t = e.getTarget(), r =
|
|
4406
|
-
`${
|
|
4423
|
+
const t = e.getTarget(), r = l.getReactiveImportState(t), i = e.getAttributeEvaluation(
|
|
4424
|
+
`${u.prefix}import`
|
|
4407
4425
|
), s = i && !i.hasUnresolvedReference && typeof i.value == "string" && i.value !== "" ? i.value : null;
|
|
4408
4426
|
if (r.running)
|
|
4409
4427
|
return s !== r.lastUrl && (r.rerunRequested = !0), Promise.resolve();
|
|
@@ -4413,25 +4431,25 @@ const u = class u {
|
|
|
4413
4431
|
return Promise.resolve();
|
|
4414
4432
|
r.lastUrl = s, r.running = !0;
|
|
4415
4433
|
const n = performance.now();
|
|
4416
|
-
return t.setAttribute(`${
|
|
4434
|
+
return t.setAttribute(`${u.prefix}importing`, ""), R.importStart(t, s), Te.load(s).then((a) => {
|
|
4417
4435
|
const o = new TextEncoder().encode(a).length;
|
|
4418
|
-
return
|
|
4436
|
+
return M.enqueue(() => {
|
|
4419
4437
|
t.innerHTML = a;
|
|
4420
4438
|
}).then(() => {
|
|
4421
|
-
if (t.removeAttribute(`${
|
|
4439
|
+
if (t.removeAttribute(`${u.prefix}importing`), R.importEnd(t, s, o, n), !document.body.hasAttribute("data-haori-ready")) {
|
|
4422
4440
|
const c = [];
|
|
4423
4441
|
return t.childNodes.forEach((d) => {
|
|
4424
4442
|
const f = w.get(d);
|
|
4425
|
-
f instanceof
|
|
4443
|
+
f instanceof C ? c.push(l.scan(f.getTarget())) : f instanceof H && c.push(l.evaluateText(f));
|
|
4426
4444
|
}), Promise.all(c).then(() => {
|
|
4427
4445
|
});
|
|
4428
4446
|
}
|
|
4429
4447
|
});
|
|
4430
4448
|
}).catch((a) => {
|
|
4431
|
-
t.removeAttribute(`${
|
|
4449
|
+
t.removeAttribute(`${u.prefix}importing`), R.importError(t, s, a), p.error("[Haori]", "Failed to import HTML:", s, a);
|
|
4432
4450
|
}).finally(() => {
|
|
4433
4451
|
if (r.running = !1, r.rerunRequested)
|
|
4434
|
-
return r.rerunRequested = !1,
|
|
4452
|
+
return r.rerunRequested = !1, l.executeManagedImport(e);
|
|
4435
4453
|
});
|
|
4436
4454
|
}
|
|
4437
4455
|
/**
|
|
@@ -4442,7 +4460,7 @@ const u = class u {
|
|
|
4442
4460
|
*/
|
|
4443
4461
|
static scan(e) {
|
|
4444
4462
|
const t = w.get(e);
|
|
4445
|
-
return t ?
|
|
4463
|
+
return t ? l.initializeElementFragment(t, !1) : Promise.resolve();
|
|
4446
4464
|
}
|
|
4447
4465
|
/**
|
|
4448
4466
|
* 新規 each 行を局所初期化します。
|
|
@@ -4452,8 +4470,8 @@ const u = class u {
|
|
|
4452
4470
|
* @returns 初期化完了の Promise
|
|
4453
4471
|
*/
|
|
4454
4472
|
static initializeFreshEachRow(e) {
|
|
4455
|
-
return
|
|
4456
|
-
|
|
4473
|
+
return l.initializeElementFragment(e, !0).then(() => {
|
|
4474
|
+
l.needsScheduledEvaluateAll(e) && l.scheduleEvaluateAll(e);
|
|
4457
4475
|
});
|
|
4458
4476
|
}
|
|
4459
4477
|
/**
|
|
@@ -4464,16 +4482,16 @@ const u = class u {
|
|
|
4464
4482
|
* @returns 初期化完了の Promise
|
|
4465
4483
|
*/
|
|
4466
4484
|
static initializeElementFragment(e, t) {
|
|
4467
|
-
return
|
|
4468
|
-
if (
|
|
4469
|
-
|
|
4485
|
+
return l.syncMountedState(e), t && e.isFreshInitializationSkippable() ? Promise.resolve() : l.initializeElementAttributes(e).then(() => {
|
|
4486
|
+
if (l.shouldSkipChildInitialization(e, t)) {
|
|
4487
|
+
l.refreshDerivedSubtreeSignature(e);
|
|
4470
4488
|
return;
|
|
4471
4489
|
}
|
|
4472
4490
|
const r = [];
|
|
4473
4491
|
return e.getChildren().forEach((i) => {
|
|
4474
|
-
i instanceof
|
|
4492
|
+
i instanceof C ? r.push(l.initializeElementFragment(i, t)) : i instanceof H && r.push(l.evaluateText(i));
|
|
4475
4493
|
}), Promise.all(r).then(() => {
|
|
4476
|
-
|
|
4494
|
+
l.refreshDerivedSubtreeSignature(e);
|
|
4477
4495
|
});
|
|
4478
4496
|
});
|
|
4479
4497
|
}
|
|
@@ -4503,10 +4521,10 @@ const u = class u {
|
|
|
4503
4521
|
static initializeElementAttributes(e) {
|
|
4504
4522
|
let t = Promise.resolve();
|
|
4505
4523
|
const r = /* @__PURE__ */ new Set();
|
|
4506
|
-
for (const i of
|
|
4507
|
-
const s =
|
|
4524
|
+
for (const i of l.PRIORITY_ATTRIBUTE_SUFFIXES) {
|
|
4525
|
+
const s = u.prefix + i;
|
|
4508
4526
|
e.hasAttribute(s) && (t = t.then(
|
|
4509
|
-
() =>
|
|
4527
|
+
() => l.setAttribute(
|
|
4510
4528
|
e.getTarget(),
|
|
4511
4529
|
s,
|
|
4512
4530
|
e.getRawAttribute(s)
|
|
@@ -4514,17 +4532,17 @@ const u = class u {
|
|
|
4514
4532
|
), r.add(s));
|
|
4515
4533
|
}
|
|
4516
4534
|
for (const i of e.getAttributeNames()) {
|
|
4517
|
-
if (r.has(i) ||
|
|
4535
|
+
if (r.has(i) || l.isDeferredAttributeName(i))
|
|
4518
4536
|
continue;
|
|
4519
4537
|
const s = e.getRawAttribute(i);
|
|
4520
4538
|
s !== null && (t = t.then(
|
|
4521
|
-
() =>
|
|
4539
|
+
() => l.setAttribute(e.getTarget(), i, s)
|
|
4522
4540
|
));
|
|
4523
4541
|
}
|
|
4524
|
-
for (const i of
|
|
4525
|
-
const s =
|
|
4542
|
+
for (const i of l.DEFERRED_ATTRIBUTE_SUFFIXES) {
|
|
4543
|
+
const s = u.prefix + i;
|
|
4526
4544
|
e.hasAttribute(s) && (t = t.then(
|
|
4527
|
-
() =>
|
|
4545
|
+
() => l.setAttribute(
|
|
4528
4546
|
e.getTarget(),
|
|
4529
4547
|
s,
|
|
4530
4548
|
e.getRawAttribute(s)
|
|
@@ -4542,8 +4560,8 @@ const u = class u {
|
|
|
4542
4560
|
* @returns 子孫初期化をスキップするなら true
|
|
4543
4561
|
*/
|
|
4544
4562
|
static shouldSkipChildInitialization(e, t) {
|
|
4545
|
-
const r = e.getAttribute(`${
|
|
4546
|
-
return e.hasAttribute(`${
|
|
4563
|
+
const r = e.getAttribute(`${u.prefix}if`);
|
|
4564
|
+
return e.hasAttribute(`${u.prefix}if`) && l.isHiddenIfCondition(r) ? !0 : t && e.hasAttribute(`${u.prefix}each`);
|
|
4547
4565
|
}
|
|
4548
4566
|
/**
|
|
4549
4567
|
* エレメントに属性を設定します。
|
|
@@ -4555,7 +4573,7 @@ const u = class u {
|
|
|
4555
4573
|
* @returns Promise (DOM操作が完了したときに解決される)
|
|
4556
4574
|
*/
|
|
4557
4575
|
static setAttribute(e, t, r, i = !1) {
|
|
4558
|
-
const s = w.get(e), n =
|
|
4576
|
+
const s = w.get(e), n = l.getAliasedAttributeName(t);
|
|
4559
4577
|
if (n !== null)
|
|
4560
4578
|
return r === null ? s.removeAliasedAttribute(t, n) : s.setAliasedAttribute(
|
|
4561
4579
|
t,
|
|
@@ -4566,53 +4584,53 @@ const u = class u {
|
|
|
4566
4584
|
const a = [];
|
|
4567
4585
|
let o = null, c = null;
|
|
4568
4586
|
switch (t) {
|
|
4569
|
-
case `${
|
|
4570
|
-
r === null ? (s.clearBindingDataCache(), s.setBindingData({})) : s.setBindingData(
|
|
4587
|
+
case `${u.prefix}bind`: {
|
|
4588
|
+
r === null ? (s.clearBindingDataCache(), s.setBindingData({})) : s.setBindingData(l.parseDataBind(r));
|
|
4571
4589
|
break;
|
|
4572
4590
|
}
|
|
4573
|
-
case `${
|
|
4574
|
-
c =
|
|
4591
|
+
case `${u.prefix}derive`:
|
|
4592
|
+
c = l.createDeriveInputSignature(
|
|
4575
4593
|
s,
|
|
4576
4594
|
r,
|
|
4577
|
-
s.getRawAttribute(`${
|
|
4578
|
-
), o =
|
|
4595
|
+
s.getRawAttribute(`${u.prefix}derive-name`)
|
|
4596
|
+
), o = l.evaluateDerive(
|
|
4579
4597
|
s,
|
|
4580
4598
|
r,
|
|
4581
|
-
s.getRawAttribute(`${
|
|
4599
|
+
s.getRawAttribute(`${u.prefix}derive-name`)
|
|
4582
4600
|
), a.push(o.then(() => {
|
|
4583
4601
|
}));
|
|
4584
4602
|
break;
|
|
4585
|
-
case `${
|
|
4586
|
-
c =
|
|
4603
|
+
case `${u.prefix}derive-name`:
|
|
4604
|
+
c = l.createDeriveInputSignature(
|
|
4587
4605
|
s,
|
|
4588
|
-
s.getRawAttribute(`${
|
|
4606
|
+
s.getRawAttribute(`${u.prefix}derive`),
|
|
4589
4607
|
r
|
|
4590
|
-
), o =
|
|
4608
|
+
), o = l.evaluateDerive(
|
|
4591
4609
|
s,
|
|
4592
|
-
s.getRawAttribute(`${
|
|
4610
|
+
s.getRawAttribute(`${u.prefix}derive`),
|
|
4593
4611
|
r
|
|
4594
4612
|
), a.push(o.then(() => {
|
|
4595
4613
|
}));
|
|
4596
4614
|
break;
|
|
4597
|
-
case `${
|
|
4598
|
-
a.push(
|
|
4615
|
+
case `${u.prefix}if`:
|
|
4616
|
+
a.push(l.evaluateIf(s));
|
|
4599
4617
|
break;
|
|
4600
|
-
case `${
|
|
4601
|
-
a.push(
|
|
4618
|
+
case `${u.prefix}each`:
|
|
4619
|
+
a.push(l.evaluateEach(s));
|
|
4602
4620
|
break;
|
|
4603
|
-
case `${
|
|
4604
|
-
a.push(
|
|
4621
|
+
case `${u.prefix}fetch`:
|
|
4622
|
+
a.push(l.executeManagedFetch(s));
|
|
4605
4623
|
break;
|
|
4606
|
-
case `${
|
|
4607
|
-
typeof r == "string" && a.push(
|
|
4624
|
+
case `${u.prefix}import`:
|
|
4625
|
+
typeof r == "string" && a.push(l.executeManagedImport(s));
|
|
4608
4626
|
break;
|
|
4609
|
-
case `${
|
|
4610
|
-
const d = s.getAttribute(`${
|
|
4627
|
+
case `${u.prefix}url-param`: {
|
|
4628
|
+
const d = s.getAttribute(`${u.prefix}url-arg`), f = Se.readParams();
|
|
4611
4629
|
if (d === null)
|
|
4612
|
-
a.push(
|
|
4630
|
+
a.push(l.setBindingData(e, f));
|
|
4613
4631
|
else {
|
|
4614
|
-
const
|
|
4615
|
-
|
|
4632
|
+
const g = s.getRawBindingData() || {};
|
|
4633
|
+
g[String(d)] = f, a.push(l.setBindingData(e, g));
|
|
4616
4634
|
}
|
|
4617
4635
|
break;
|
|
4618
4636
|
}
|
|
@@ -4621,7 +4639,7 @@ const u = class u {
|
|
|
4621
4639
|
if (o !== null)
|
|
4622
4640
|
return s.setDeriveInputSignature(c), o.then((d) => {
|
|
4623
4641
|
if (d)
|
|
4624
|
-
return
|
|
4642
|
+
return l.reevaluateChildren(s);
|
|
4625
4643
|
});
|
|
4626
4644
|
}).then(() => {
|
|
4627
4645
|
});
|
|
@@ -4638,16 +4656,16 @@ const u = class u {
|
|
|
4638
4656
|
const i = w.get(e), s = i.getRawBindingData();
|
|
4639
4657
|
i.setBindingData(t);
|
|
4640
4658
|
let n = i.setAttribute(
|
|
4641
|
-
`${
|
|
4659
|
+
`${u.prefix}bind`,
|
|
4642
4660
|
JSON.stringify(t)
|
|
4643
4661
|
);
|
|
4644
4662
|
if (e.tagName === "FORM") {
|
|
4645
|
-
const a = i.getAttribute(`${
|
|
4646
|
-
n = n.then(() =>
|
|
4663
|
+
const a = i.getAttribute(`${u.prefix}form-arg`), o = a && t[String(a)] && typeof t[String(a)] == "object" && !Array.isArray(t[String(a)]) ? t[String(a)] : a ? {} : t;
|
|
4664
|
+
n = n.then(() => A.syncValues(i, o));
|
|
4647
4665
|
}
|
|
4648
|
-
return n = n.then(() =>
|
|
4649
|
-
() =>
|
|
4650
|
-
),
|
|
4666
|
+
return n = n.then(() => l.evaluateAll(i, r)), n = n.then(
|
|
4667
|
+
() => l.reevaluateReactiveSpecialAttributes(i, r)
|
|
4668
|
+
), R.bindChange(e, s, t, "manual"), n.then(() => {
|
|
4651
4669
|
});
|
|
4652
4670
|
}
|
|
4653
4671
|
/**
|
|
@@ -4661,7 +4679,7 @@ const u = class u {
|
|
|
4661
4679
|
try {
|
|
4662
4680
|
return JSON.parse(e);
|
|
4663
4681
|
} catch (t) {
|
|
4664
|
-
return
|
|
4682
|
+
return p.error("[Haori]", "Invalid JSON in data-bind:", t), {};
|
|
4665
4683
|
}
|
|
4666
4684
|
else {
|
|
4667
4685
|
const t = new URLSearchParams(e), r = {};
|
|
@@ -4681,7 +4699,7 @@ const u = class u {
|
|
|
4681
4699
|
if (r.isSkipMutationNodes())
|
|
4682
4700
|
return;
|
|
4683
4701
|
const i = w.get(t.nextSibling), s = w.get(t);
|
|
4684
|
-
s && (r.insertBefore(s, i), s instanceof
|
|
4702
|
+
s && (r.insertBefore(s, i), s instanceof C ? l.scan(s.getTarget()) : s instanceof H && l.evaluateText(s));
|
|
4685
4703
|
}
|
|
4686
4704
|
/**
|
|
4687
4705
|
* ノードを親要素から削除します。
|
|
@@ -4721,11 +4739,11 @@ const u = class u {
|
|
|
4721
4739
|
return Promise.resolve();
|
|
4722
4740
|
const i = [];
|
|
4723
4741
|
i.push(r.setValue(t));
|
|
4724
|
-
const s =
|
|
4742
|
+
const s = l.getFormFragment(r);
|
|
4725
4743
|
if (s) {
|
|
4726
|
-
const n =
|
|
4744
|
+
const n = A.getValues(s), a = s.getAttribute(`${u.prefix}form-arg`);
|
|
4727
4745
|
let o;
|
|
4728
|
-
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(
|
|
4746
|
+
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(l.setBindingData(s.getTarget(), o));
|
|
4729
4747
|
}
|
|
4730
4748
|
return Promise.all(i).then(() => {
|
|
4731
4749
|
});
|
|
@@ -4740,7 +4758,7 @@ const u = class u {
|
|
|
4740
4758
|
if (e.getTarget() instanceof HTMLFormElement)
|
|
4741
4759
|
return e;
|
|
4742
4760
|
const t = e.getParent();
|
|
4743
|
-
return t ?
|
|
4761
|
+
return t ? l.getFormFragment(t) : null;
|
|
4744
4762
|
}
|
|
4745
4763
|
/**
|
|
4746
4764
|
* フラグメントとその子要素を評価します。
|
|
@@ -4751,52 +4769,52 @@ const u = class u {
|
|
|
4751
4769
|
static evaluateAll(e, t = /* @__PURE__ */ new Set()) {
|
|
4752
4770
|
if (t.has(e))
|
|
4753
4771
|
return Promise.resolve();
|
|
4754
|
-
let r =
|
|
4755
|
-
const i = e.hasAttribute(`${
|
|
4772
|
+
let r = l.reevaluateInterpolatedAttributes(e);
|
|
4773
|
+
const i = e.hasAttribute(`${u.prefix}derive`), s = e.hasAttribute(`${u.prefix}if`), n = e.hasAttribute(`${u.prefix}each`), a = e.getRawAttribute(`${u.prefix}derive`), o = e.getRawAttribute(`${u.prefix}derive-name`);
|
|
4756
4774
|
let c = !1, d = !1, f = null;
|
|
4757
4775
|
if (!i && e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), !i && e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), i) {
|
|
4758
|
-
const
|
|
4776
|
+
const g = l.createDeriveInputSignature(
|
|
4759
4777
|
e,
|
|
4760
4778
|
a,
|
|
4761
4779
|
o
|
|
4762
4780
|
);
|
|
4763
|
-
|
|
4764
|
-
() =>
|
|
4781
|
+
g === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
|
|
4782
|
+
() => l.evaluateDerive(e, a, o).then(
|
|
4765
4783
|
() => {
|
|
4766
4784
|
}
|
|
4767
4785
|
)
|
|
4768
|
-
)) : e.getDeriveInputSignature() !==
|
|
4786
|
+
)) : e.getDeriveInputSignature() !== g && (r = r.then(() => l.evaluateDerive(
|
|
4769
4787
|
e,
|
|
4770
4788
|
a,
|
|
4771
4789
|
o
|
|
4772
4790
|
).then(() => {
|
|
4773
|
-
e.setDeriveInputSignature(
|
|
4791
|
+
e.setDeriveInputSignature(g);
|
|
4774
4792
|
})));
|
|
4775
4793
|
}
|
|
4776
|
-
return s && (r = r.then(() =>
|
|
4794
|
+
return s && (r = r.then(() => l.evaluateIf(e))), n ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => l.evaluateEach(e))) : s ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => {
|
|
4777
4795
|
})) : (i && (r = r.then(() => {
|
|
4778
|
-
if (!
|
|
4779
|
-
e.setDeriveSubtreeSignature(null),
|
|
4796
|
+
if (!l.canSkipStableDerivedSubtree(e)) {
|
|
4797
|
+
e.setDeriveSubtreeSignature(null), l.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
|
|
4780
4798
|
return;
|
|
4781
4799
|
}
|
|
4782
|
-
f =
|
|
4800
|
+
f = l.createDescendantBindingSignature(
|
|
4783
4801
|
e,
|
|
4784
4802
|
"evaluateAll"
|
|
4785
|
-
), d = !0, c = e.getDeriveSubtreeSignature() !== null && e.getDeriveSubtreeSignature() === f,
|
|
4803
|
+
), d = !0, c = e.getDeriveSubtreeSignature() !== null && e.getDeriveSubtreeSignature() === f, l.logDerivedSubtreeProfileSnapshot(
|
|
4786
4804
|
e,
|
|
4787
4805
|
c ? "skip-hit" : "skip-miss"
|
|
4788
4806
|
);
|
|
4789
4807
|
})), r.then(() => {
|
|
4790
4808
|
if (c)
|
|
4791
4809
|
return;
|
|
4792
|
-
const
|
|
4793
|
-
return e.getChildren().forEach((
|
|
4794
|
-
if (
|
|
4795
|
-
if (
|
|
4810
|
+
const g = [];
|
|
4811
|
+
return e.getChildren().forEach((y) => {
|
|
4812
|
+
if (y instanceof C) {
|
|
4813
|
+
if (l.canSkipUnchangedNestedEach(y))
|
|
4796
4814
|
return;
|
|
4797
|
-
|
|
4798
|
-
} else
|
|
4799
|
-
}), Promise.all(
|
|
4815
|
+
g.push(l.evaluateAll(y, t));
|
|
4816
|
+
} else y instanceof H && g.push(l.evaluateText(y));
|
|
4817
|
+
}), Promise.all(g).then(() => {
|
|
4800
4818
|
});
|
|
4801
4819
|
}).then(() => {
|
|
4802
4820
|
d && f !== null && e.setDeriveSubtreeSignature(f);
|
|
@@ -4811,14 +4829,14 @@ const u = class u {
|
|
|
4811
4829
|
* @returns Promise (評価完了時に解決)
|
|
4812
4830
|
*/
|
|
4813
4831
|
static evaluateDerive(e, t = e.getRawAttribute(
|
|
4814
|
-
`${
|
|
4832
|
+
`${u.prefix}derive`
|
|
4815
4833
|
), r = e.getRawAttribute(
|
|
4816
|
-
`${
|
|
4834
|
+
`${u.prefix}derive-name`
|
|
4817
4835
|
)) {
|
|
4818
4836
|
const i = e.getRawDerivedBindingData(), s = typeof r == "string" ? r.trim() : "";
|
|
4819
4837
|
if (!t || s === "")
|
|
4820
4838
|
return i === null ? Promise.resolve(!1) : (e.setDerivedBindingData(null), Promise.resolve(!0));
|
|
4821
|
-
const n =
|
|
4839
|
+
const n = Y.evaluateDetailed(
|
|
4822
4840
|
t,
|
|
4823
4841
|
e.getBindingData()
|
|
4824
4842
|
);
|
|
@@ -4827,7 +4845,7 @@ const u = class u {
|
|
|
4827
4845
|
const a = {
|
|
4828
4846
|
[s]: n.value
|
|
4829
4847
|
};
|
|
4830
|
-
return
|
|
4848
|
+
return l.createBindingSignature(i) === l.createBindingSignature(a) ? Promise.resolve(!1) : (e.setDerivedBindingData(a), Promise.resolve(!0));
|
|
4831
4849
|
}
|
|
4832
4850
|
/**
|
|
4833
4851
|
* テキストフラグメントを評価します。
|
|
@@ -4838,61 +4856,120 @@ const u = class u {
|
|
|
4838
4856
|
static evaluateText(e) {
|
|
4839
4857
|
return e.evaluate();
|
|
4840
4858
|
}
|
|
4859
|
+
/**
|
|
4860
|
+
* data-if の評価値が「非表示」とみなされるかどうかを判定します。
|
|
4861
|
+
*
|
|
4862
|
+
* JavaScript の falsy 判定に準拠し、`false`・`null`・`undefined`・`NaN` に加えて
|
|
4863
|
+
* `0`・空文字列 `''` も非表示とします(例: `data-if="items.length"` は要素数 0 で
|
|
4864
|
+
* 非表示)。空配列 `[]` や空オブジェクト `{}` は JavaScript 同様 truthy なので表示されます。
|
|
4865
|
+
*
|
|
4866
|
+
* @param condition data-if の評価結果
|
|
4867
|
+
* @return 非表示とみなす場合は true
|
|
4868
|
+
*/
|
|
4869
|
+
static isHiddenIfCondition(e) {
|
|
4870
|
+
return !e;
|
|
4871
|
+
}
|
|
4841
4872
|
/**
|
|
4842
4873
|
* if要素を評価します。
|
|
4843
|
-
* 値がfalse
|
|
4874
|
+
* 値が falsy(false・null・undefined・NaN・0・空文字列)の場合は非表示にし、
|
|
4875
|
+
* それ以外の場合は表示します。
|
|
4844
4876
|
*
|
|
4845
4877
|
* @param fragment 対象フラグメント
|
|
4846
4878
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
4847
4879
|
*/
|
|
4848
4880
|
static evaluateIf(e) {
|
|
4849
|
-
const t = [], r = e.getAttribute(`${
|
|
4850
|
-
if (
|
|
4881
|
+
const t = [], r = e.getAttribute(`${u.prefix}if`);
|
|
4882
|
+
if (l.isHiddenIfCondition(r))
|
|
4851
4883
|
t.push(
|
|
4852
4884
|
e.hide().then(() => {
|
|
4853
|
-
|
|
4885
|
+
R.hide(e.getTarget());
|
|
4854
4886
|
})
|
|
4855
4887
|
);
|
|
4856
4888
|
else {
|
|
4857
|
-
const i = [];
|
|
4858
|
-
e.getChildren().forEach((
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
) :
|
|
4889
|
+
const i = e.isVisible(), s = [];
|
|
4890
|
+
e.getChildren().forEach((n) => {
|
|
4891
|
+
n instanceof C ? s.push(
|
|
4892
|
+
n.isMounted() ? l.evaluateAll(n) : l.scan(n.getTarget())
|
|
4893
|
+
) : n instanceof H && s.push(l.evaluateText(n));
|
|
4862
4894
|
}), t.push(
|
|
4863
4895
|
e.show().then(() => {
|
|
4864
|
-
|
|
4896
|
+
R.show(e.getTarget()), i || l.triggerLoadOnShow(e);
|
|
4865
4897
|
})
|
|
4866
|
-
), t.push(Promise.all(
|
|
4898
|
+
), t.push(Promise.all(s).then(() => {
|
|
4867
4899
|
}));
|
|
4868
4900
|
}
|
|
4869
4901
|
return Promise.all(t).then(() => {
|
|
4870
4902
|
});
|
|
4871
4903
|
}
|
|
4904
|
+
/**
|
|
4905
|
+
* data-if 表示時に data-load-* 手続きを発火します。
|
|
4906
|
+
*
|
|
4907
|
+
* 対象要素が data-load-* 属性を持つ場合のみ、load 種別の Procedure を1回実行します。
|
|
4908
|
+
* 結果は待機せず(fire-and-forget)、表示処理の完了をブロックしません。
|
|
4909
|
+
*
|
|
4910
|
+
* @param fragment 対象フラグメント
|
|
4911
|
+
* @return 戻り値はありません。
|
|
4912
|
+
*/
|
|
4913
|
+
static triggerLoadOnShow(e) {
|
|
4914
|
+
const t = `${u.prefix}load-`;
|
|
4915
|
+
e.getTarget().getAttributeNames().some((i) => i.startsWith(t)) && new q(e, "load").run().catch((i) => {
|
|
4916
|
+
p.error("[Haori]", "data-load procedure error (on show):", i);
|
|
4917
|
+
});
|
|
4918
|
+
}
|
|
4919
|
+
/**
|
|
4920
|
+
* data-each フラグメントの差分更新の再入制御状態を取得します。
|
|
4921
|
+
*
|
|
4922
|
+
* @param fragment 対象フラグメント
|
|
4923
|
+
* @return 再入制御状態
|
|
4924
|
+
*/
|
|
4925
|
+
static getEachUpdateState(e) {
|
|
4926
|
+
let t = l.EACH_UPDATE_STATES.get(e);
|
|
4927
|
+
return t || (t = { running: !1, rerunRequested: !1 }, l.EACH_UPDATE_STATES.set(e, t)), t;
|
|
4928
|
+
}
|
|
4872
4929
|
/**
|
|
4873
4930
|
* each要素を評価します。
|
|
4874
4931
|
* 非表示または未マウントの場合は処理をスキップします。
|
|
4875
4932
|
*
|
|
4933
|
+
* 同一フラグメントに対する差分更新が並行・再入しないように直列化します。
|
|
4934
|
+
* 実行中に再度呼び出された場合は再評価要求だけを記録し、現在の更新完了後に
|
|
4935
|
+
* 最新データで一度だけ再実行します。これにより、bind 直後のリアクティブ再評価が
|
|
4936
|
+
* 重なっても data-each の描画が破壊されないようにします。
|
|
4937
|
+
*
|
|
4876
4938
|
* @param fragment 対象フラグメント
|
|
4939
|
+
* @return 差分更新完了の Promise
|
|
4877
4940
|
*/
|
|
4878
4941
|
static evaluateEach(e) {
|
|
4879
4942
|
if (!e.isVisible() || !e.isMounted())
|
|
4880
4943
|
return Promise.resolve();
|
|
4881
|
-
const t =
|
|
4944
|
+
const t = l.getEachUpdateState(e);
|
|
4945
|
+
return t.running ? (t.rerunRequested = !0, Promise.resolve()) : (t.running = !0, l.performEachUpdate(e).catch((r) => {
|
|
4946
|
+
throw r;
|
|
4947
|
+
}).finally(() => {
|
|
4948
|
+
t.running = !1, t.rerunRequested && (t.rerunRequested = !1, l.evaluateEach(e));
|
|
4949
|
+
}));
|
|
4950
|
+
}
|
|
4951
|
+
/**
|
|
4952
|
+
* data-each の差分更新本体を実行します(再入制御は呼び出し側で行います)。
|
|
4953
|
+
*
|
|
4954
|
+
* @param fragment 対象フラグメント
|
|
4955
|
+
* @return 差分更新完了の Promise
|
|
4956
|
+
*/
|
|
4957
|
+
static performEachUpdate(e) {
|
|
4958
|
+
const t = l.resolveEachItems(e);
|
|
4882
4959
|
if (t === null)
|
|
4883
4960
|
return Promise.reject(new Error("Invalid each attribute."));
|
|
4884
4961
|
let r = e.getTemplate();
|
|
4885
|
-
const i = e.getAttribute(`${
|
|
4962
|
+
const i = e.getAttribute(`${u.prefix}each-key`), s = l.createBindingSignature({
|
|
4886
4963
|
key: i ? String(i) : null,
|
|
4887
4964
|
items: t
|
|
4888
4965
|
});
|
|
4889
4966
|
if (r === null) {
|
|
4890
4967
|
let n = !1;
|
|
4891
4968
|
return e.getChildren().forEach((a) => {
|
|
4892
|
-
if (!n && a instanceof
|
|
4893
|
-
if (a.hasAttribute(`${
|
|
4969
|
+
if (!n && a instanceof C) {
|
|
4970
|
+
if (a.hasAttribute(`${u.prefix}each-before`) || a.hasAttribute(`${u.prefix}each-after`))
|
|
4894
4971
|
return;
|
|
4895
|
-
r = a.clone(),
|
|
4972
|
+
r = a.clone(), l.markFreshInitializationSkippable(r), e.setTemplate(r), n = !0, e.removeChild(a);
|
|
4896
4973
|
const o = a.getTarget();
|
|
4897
4974
|
o.parentNode && o.parentNode.removeChild(o), a.setMounted(!1);
|
|
4898
4975
|
}
|
|
@@ -4911,8 +4988,8 @@ const u = class u {
|
|
|
4911
4988
|
* @returns 配列。無効な場合は null
|
|
4912
4989
|
*/
|
|
4913
4990
|
static resolveEachItems(e) {
|
|
4914
|
-
const t = e.getAttributeEvaluation(`${
|
|
4915
|
-
return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (
|
|
4991
|
+
const t = e.getAttributeEvaluation(`${u.prefix}each`), r = t?.value;
|
|
4992
|
+
return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (p.error("[Haori]", "Invalid each attribute:", r), null);
|
|
4916
4993
|
}
|
|
4917
4994
|
/**
|
|
4918
4995
|
* nested data-each の入力が同値で、要素自身に他の動的要素が無い場合は
|
|
@@ -4922,15 +4999,15 @@ const u = class u {
|
|
|
4922
4999
|
* @returns 省略可能なら true
|
|
4923
5000
|
*/
|
|
4924
5001
|
static canSkipUnchangedNestedEach(e) {
|
|
4925
|
-
if (!e.hasAttribute(`${
|
|
5002
|
+
if (!e.hasAttribute(`${u.prefix}each`) || e.getEachInputSignature() === null)
|
|
4926
5003
|
return !1;
|
|
4927
5004
|
const t = e.getParent();
|
|
4928
|
-
if (t?.closestByAttribute(`${
|
|
5005
|
+
if (t?.closestByAttribute(`${u.prefix}derive`) || t?.closestByAttribute(`${u.prefix}derive-name`) || t?.closestByAttribute(`${u.prefix}if`) || t?.closestByAttribute(`${u.prefix}fetch`) || t?.closestByAttribute(`${u.prefix}import`) || l.hasNonEachDynamicElementState(e))
|
|
4929
5006
|
return !1;
|
|
4930
|
-
const r =
|
|
5007
|
+
const r = l.resolveEachItems(e);
|
|
4931
5008
|
if (r === null)
|
|
4932
5009
|
return !1;
|
|
4933
|
-
const i = e.getAttribute(`${
|
|
5010
|
+
const i = e.getAttribute(`${u.prefix}each-key`), s = l.createBindingSignature({
|
|
4934
5011
|
key: i ? String(i) : null,
|
|
4935
5012
|
items: r
|
|
4936
5013
|
});
|
|
@@ -4944,7 +5021,7 @@ const u = class u {
|
|
|
4944
5021
|
* @returns 省略可能なら true
|
|
4945
5022
|
*/
|
|
4946
5023
|
static canSkipStableDerivedSubtree(e) {
|
|
4947
|
-
return !e.hasAttribute(`${
|
|
5024
|
+
return !e.hasAttribute(`${u.prefix}derive`) || e.hasAttribute(`${u.prefix}if`) || e.hasAttribute(`${u.prefix}each`) || e.hasAttribute(`${u.prefix}fetch`) || e.hasAttribute(`${u.prefix}import`) ? !1 : !l.hasDisallowedDerivedSubtreeDescendant(e);
|
|
4948
5025
|
}
|
|
4949
5026
|
/**
|
|
4950
5027
|
* data-derive subtree skip の初期 PoC で扱わない子孫要素を含むかを返します。
|
|
@@ -4953,7 +5030,7 @@ const u = class u {
|
|
|
4953
5030
|
* @returns 含むなら true
|
|
4954
5031
|
*/
|
|
4955
5032
|
static hasDisallowedDerivedSubtreeDescendant(e) {
|
|
4956
|
-
return e.getChildren().some((t) => t instanceof
|
|
5033
|
+
return e.getChildren().some((t) => t instanceof C ? t.hasAttribute(`${u.prefix}derive`) || t.hasAttribute(`${u.prefix}derive-name`) || t.hasAttribute(`${u.prefix}fetch`) || t.hasAttribute(`${u.prefix}import`) ? !0 : l.hasDisallowedDerivedSubtreeDescendant(t) : !1);
|
|
4957
5034
|
}
|
|
4958
5035
|
/**
|
|
4959
5036
|
* data-derive host が子孫要素へ公開している binding の署名を返します。
|
|
@@ -4962,7 +5039,7 @@ const u = class u {
|
|
|
4962
5039
|
* @returns binding 署名
|
|
4963
5040
|
*/
|
|
4964
5041
|
static createDescendantBindingSignature(e, t) {
|
|
4965
|
-
return
|
|
5042
|
+
return l.recordDerivedSubtreeSignatureComputation(e, t), l.createBindingSignature(e.getDescendantBindingData());
|
|
4966
5043
|
}
|
|
4967
5044
|
/**
|
|
4968
5045
|
* data-derive 実行前の入力署名を返します。
|
|
@@ -4974,7 +5051,7 @@ const u = class u {
|
|
|
4974
5051
|
*/
|
|
4975
5052
|
static createDeriveInputSignature(e, t, r) {
|
|
4976
5053
|
const i = typeof r == "string" ? r.trim() : "";
|
|
4977
|
-
return !t || i === "" ? null :
|
|
5054
|
+
return !t || i === "" ? null : l.createBindingSignature({
|
|
4978
5055
|
expression: t,
|
|
4979
5056
|
name: i,
|
|
4980
5057
|
scope: e.getBindingData()
|
|
@@ -4986,13 +5063,13 @@ const u = class u {
|
|
|
4986
5063
|
* @param fragment 対象フラグメント
|
|
4987
5064
|
*/
|
|
4988
5065
|
static refreshDerivedSubtreeSignature(e) {
|
|
4989
|
-
if (!
|
|
4990
|
-
e.setDeriveSubtreeSignature(null),
|
|
5066
|
+
if (!l.canSkipStableDerivedSubtree(e)) {
|
|
5067
|
+
e.setDeriveSubtreeSignature(null), l.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
|
|
4991
5068
|
return;
|
|
4992
5069
|
}
|
|
4993
5070
|
e.setDeriveSubtreeSignature(
|
|
4994
|
-
|
|
4995
|
-
),
|
|
5071
|
+
l.createDescendantBindingSignature(e, "refresh")
|
|
5072
|
+
), l.logDerivedSubtreeProfileSnapshot(e, "refresh");
|
|
4996
5073
|
}
|
|
4997
5074
|
/**
|
|
4998
5075
|
* data-derive subtree skip のプロファイルを取得または初期化します。
|
|
@@ -5001,13 +5078,13 @@ const u = class u {
|
|
|
5001
5078
|
* @returns プロファイル
|
|
5002
5079
|
*/
|
|
5003
5080
|
static getOrCreateDerivedSubtreeProfile(e) {
|
|
5004
|
-
if (!
|
|
5081
|
+
if (!L.isEnabled() || !e.hasAttribute(`${u.prefix}derive`))
|
|
5005
5082
|
return null;
|
|
5006
|
-
const t =
|
|
5083
|
+
const t = l.DERIVE_SUBTREE_PROFILES.get(e);
|
|
5007
5084
|
if (t)
|
|
5008
5085
|
return t;
|
|
5009
5086
|
const r = {
|
|
5010
|
-
hostId:
|
|
5087
|
+
hostId: l.createDerivedSubtreeHostId(e),
|
|
5011
5088
|
signatureComputeTotal: 0,
|
|
5012
5089
|
signatureComputeFromEvaluateAll: 0,
|
|
5013
5090
|
signatureComputeFromRefresh: 0,
|
|
@@ -5015,7 +5092,7 @@ const u = class u {
|
|
|
5015
5092
|
skipMissCount: 0,
|
|
5016
5093
|
skipIneligibleCount: 0
|
|
5017
5094
|
};
|
|
5018
|
-
return
|
|
5095
|
+
return l.DERIVE_SUBTREE_PROFILES.set(e, r), r;
|
|
5019
5096
|
}
|
|
5020
5097
|
/**
|
|
5021
5098
|
* data-derive subtree host の識別子を作成します。
|
|
@@ -5035,11 +5112,11 @@ const u = class u {
|
|
|
5035
5112
|
s += `#${i.id.trim()}`, t.unshift(s);
|
|
5036
5113
|
break;
|
|
5037
5114
|
}
|
|
5038
|
-
const n = r.getRawAttribute(`${
|
|
5039
|
-
typeof n == "string" && n.trim() !== "" && (s += `[${
|
|
5115
|
+
const n = r.getRawAttribute(`${u.prefix}derive-name`);
|
|
5116
|
+
typeof n == "string" && n.trim() !== "" && (s += `[${u.prefix}derive-name="${n.trim()}"]`);
|
|
5040
5117
|
const a = r.getParent();
|
|
5041
5118
|
if (a) {
|
|
5042
|
-
const o = a.getChildren().filter((c) => c instanceof
|
|
5119
|
+
const o = a.getChildren().filter((c) => c instanceof C).findIndex((c) => c === r);
|
|
5043
5120
|
s += `:nth-child(${o + 1})`;
|
|
5044
5121
|
}
|
|
5045
5122
|
t.unshift(s), r = a;
|
|
@@ -5053,7 +5130,7 @@ const u = class u {
|
|
|
5053
5130
|
* @param source 計算元
|
|
5054
5131
|
*/
|
|
5055
5132
|
static recordDerivedSubtreeSignatureComputation(e, t) {
|
|
5056
|
-
const r =
|
|
5133
|
+
const r = l.getOrCreateDerivedSubtreeProfile(e);
|
|
5057
5134
|
if (r !== null) {
|
|
5058
5135
|
if (r.signatureComputeTotal += 1, t === "refresh") {
|
|
5059
5136
|
r.signatureComputeFromRefresh += 1;
|
|
@@ -5069,8 +5146,8 @@ const u = class u {
|
|
|
5069
5146
|
* @param reason ログ理由
|
|
5070
5147
|
*/
|
|
5071
5148
|
static logDerivedSubtreeProfileSnapshot(e, t) {
|
|
5072
|
-
const r =
|
|
5073
|
-
r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1),
|
|
5149
|
+
const r = l.getOrCreateDerivedSubtreeProfile(e);
|
|
5150
|
+
r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1), p.info("[Haori][derive-profile]", {
|
|
5074
5151
|
reason: t,
|
|
5075
5152
|
hostId: r.hostId,
|
|
5076
5153
|
signatureComputeTotal: r.signatureComputeTotal,
|
|
@@ -5089,15 +5166,15 @@ const u = class u {
|
|
|
5089
5166
|
*/
|
|
5090
5167
|
static hasNonEachDynamicElementState(e) {
|
|
5091
5168
|
const t = /* @__PURE__ */ new Set([
|
|
5092
|
-
`${
|
|
5093
|
-
`${
|
|
5094
|
-
`${
|
|
5095
|
-
`${
|
|
5169
|
+
`${u.prefix}each`,
|
|
5170
|
+
`${u.prefix}each-key`,
|
|
5171
|
+
`${u.prefix}each-arg`,
|
|
5172
|
+
`${u.prefix}each-index`
|
|
5096
5173
|
]);
|
|
5097
5174
|
return e.getAttributeNames().some((i) => {
|
|
5098
5175
|
if (t.has(i))
|
|
5099
5176
|
return !1;
|
|
5100
|
-
if (i.startsWith(`${
|
|
5177
|
+
if (i.startsWith(`${u.prefix}attr-`) || i.startsWith(u.prefix))
|
|
5101
5178
|
return !0;
|
|
5102
5179
|
const s = e.getRawAttribute(i);
|
|
5103
5180
|
return typeof s == "string" && s.includes("{{");
|
|
@@ -5112,7 +5189,7 @@ const u = class u {
|
|
|
5112
5189
|
* @returns subtree 全体を省略可能なら true
|
|
5113
5190
|
*/
|
|
5114
5191
|
static markFreshInitializationSkippable(e) {
|
|
5115
|
-
const t = e.getAttributeNames().some((s) =>
|
|
5192
|
+
const t = e.getAttributeNames().some((s) => l.isFreshInitializationDynamicAttribute(e, s)), r = e.getChildren().some((s) => s instanceof C ? !l.markFreshInitializationSkippable(s) : s instanceof H ? s.hasDynamicContent() : !1), i = !t && !r;
|
|
5116
5193
|
return e.setFreshInitializationSkippable(i), i;
|
|
5117
5194
|
}
|
|
5118
5195
|
/**
|
|
@@ -5123,7 +5200,7 @@ const u = class u {
|
|
|
5123
5200
|
* @returns 再評価が必要なら true
|
|
5124
5201
|
*/
|
|
5125
5202
|
static isFreshInitializationDynamicAttribute(e, t) {
|
|
5126
|
-
if (t.startsWith(`${
|
|
5203
|
+
if (t.startsWith(`${u.prefix}attr-`) || t.startsWith(u.prefix))
|
|
5127
5204
|
return !0;
|
|
5128
5205
|
const r = e.getRawAttribute(t);
|
|
5129
5206
|
return typeof r == "string" && r.includes("{{");
|
|
@@ -5137,85 +5214,85 @@ const u = class u {
|
|
|
5137
5214
|
static updateDiff(e, t) {
|
|
5138
5215
|
const r = e.getTemplate();
|
|
5139
5216
|
if (r === null)
|
|
5140
|
-
return
|
|
5141
|
-
let i = e.getAttribute(`${
|
|
5217
|
+
return p.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
5218
|
+
let i = e.getAttribute(`${u.prefix}each-index`);
|
|
5142
5219
|
i && (i = String(i));
|
|
5143
|
-
const s = e.getAttribute(`${
|
|
5144
|
-
t.forEach((
|
|
5145
|
-
const
|
|
5146
|
-
|
|
5220
|
+
const s = e.getAttribute(`${u.prefix}each-key`), n = e.getAttribute(`${u.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
5221
|
+
t.forEach((v, F) => {
|
|
5222
|
+
const x = l.createListKey(
|
|
5223
|
+
v,
|
|
5147
5224
|
s ? String(s) : null,
|
|
5148
|
-
|
|
5225
|
+
F
|
|
5149
5226
|
);
|
|
5150
|
-
o.push(
|
|
5227
|
+
o.push(x), a.set(x, { item: v, itemIndex: F });
|
|
5151
5228
|
});
|
|
5152
5229
|
const c = new Set(o), d = [];
|
|
5153
|
-
let f = e.getChildren().filter((
|
|
5154
|
-
(
|
|
5230
|
+
let f = e.getChildren().filter((v) => v instanceof C).filter(
|
|
5231
|
+
(v) => !v.hasAttribute(`${u.prefix}each-before`) && !v.hasAttribute(`${u.prefix}each-after`)
|
|
5155
5232
|
);
|
|
5156
|
-
const
|
|
5157
|
-
f = f.filter((
|
|
5158
|
-
const
|
|
5159
|
-
f.forEach((
|
|
5160
|
-
const
|
|
5161
|
-
|
|
5233
|
+
const g = f.map((v) => v.getListKey());
|
|
5234
|
+
f = f.filter((v) => c.has(String(v.getListKey())) ? !0 : (d.push(v.remove()), !1));
|
|
5235
|
+
const y = f.map((v) => v.getListKey()), T = /* @__PURE__ */ new Map();
|
|
5236
|
+
f.forEach((v) => {
|
|
5237
|
+
const F = v.getListKey();
|
|
5238
|
+
F !== null && !T.has(F) && T.set(F, v);
|
|
5162
5239
|
});
|
|
5163
|
-
const
|
|
5164
|
-
(
|
|
5240
|
+
const m = e.getChildElementFragments().slice(), b = m.filter(
|
|
5241
|
+
(v) => v.hasAttribute(`${u.prefix}each-before`)
|
|
5165
5242
|
).length;
|
|
5166
|
-
let
|
|
5167
|
-
return o.forEach((
|
|
5168
|
-
const { item:
|
|
5169
|
-
let
|
|
5170
|
-
const
|
|
5171
|
-
if (
|
|
5172
|
-
|
|
5173
|
-
() =>
|
|
5174
|
-
k,
|
|
5243
|
+
let E = Promise.resolve();
|
|
5244
|
+
return o.forEach((v, F) => {
|
|
5245
|
+
const { item: x, itemIndex: U } = a.get(v);
|
|
5246
|
+
let B;
|
|
5247
|
+
const K = T.get(v);
|
|
5248
|
+
if (K)
|
|
5249
|
+
B = K, E = E.then(
|
|
5250
|
+
() => l.updateRowFragment(
|
|
5175
5251
|
B,
|
|
5252
|
+
x,
|
|
5176
5253
|
i,
|
|
5177
|
-
|
|
5254
|
+
U,
|
|
5178
5255
|
n ? String(n) : null,
|
|
5179
|
-
|
|
5180
|
-
).then((
|
|
5181
|
-
if (
|
|
5182
|
-
return
|
|
5256
|
+
v
|
|
5257
|
+
).then((k) => {
|
|
5258
|
+
if (k)
|
|
5259
|
+
return l.evaluateAll(B);
|
|
5183
5260
|
})
|
|
5184
5261
|
);
|
|
5185
5262
|
else {
|
|
5186
|
-
|
|
5187
|
-
const
|
|
5188
|
-
|
|
5189
|
-
() =>
|
|
5190
|
-
k,
|
|
5263
|
+
B = r.clone();
|
|
5264
|
+
const k = b + F;
|
|
5265
|
+
E = E.then(
|
|
5266
|
+
() => l.updateRowFragment(
|
|
5191
5267
|
B,
|
|
5268
|
+
x,
|
|
5192
5269
|
i,
|
|
5193
|
-
|
|
5270
|
+
U,
|
|
5194
5271
|
n ? String(n) : null,
|
|
5195
|
-
|
|
5272
|
+
v
|
|
5196
5273
|
).then(() => {
|
|
5197
|
-
const ce =
|
|
5198
|
-
return e.insertBefore(
|
|
5199
|
-
|
|
5200
|
-
}).then(() =>
|
|
5274
|
+
const ce = m[k] ?? null;
|
|
5275
|
+
return e.insertBefore(B, ce).then(() => {
|
|
5276
|
+
m.splice(k, 0, B);
|
|
5277
|
+
}).then(() => l.initializeFreshEachRow(B));
|
|
5201
5278
|
})
|
|
5202
5279
|
);
|
|
5203
5280
|
}
|
|
5204
|
-
}), Promise.all(d).then(() =>
|
|
5205
|
-
const
|
|
5206
|
-
(
|
|
5207
|
-
),
|
|
5208
|
-
(
|
|
5209
|
-
),
|
|
5210
|
-
(
|
|
5281
|
+
}), Promise.all(d).then(() => E).then(() => {
|
|
5282
|
+
const v = o.filter(
|
|
5283
|
+
(k) => k !== null
|
|
5284
|
+
), F = y.filter(
|
|
5285
|
+
(k) => k !== null
|
|
5286
|
+
), x = new Set(F), U = v.filter((k) => !x.has(k)), K = g.filter(
|
|
5287
|
+
(k) => k !== null
|
|
5211
5288
|
).filter(
|
|
5212
|
-
(
|
|
5289
|
+
(k) => !c.has(k)
|
|
5213
5290
|
);
|
|
5214
|
-
|
|
5291
|
+
R.eachUpdate(
|
|
5215
5292
|
e.getTarget(),
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5293
|
+
U,
|
|
5294
|
+
K,
|
|
5295
|
+
v
|
|
5219
5296
|
);
|
|
5220
5297
|
});
|
|
5221
5298
|
}
|
|
@@ -5261,15 +5338,15 @@ const u = class u {
|
|
|
5261
5338
|
[s]: t
|
|
5262
5339
|
}, r && (a[r] = i);
|
|
5263
5340
|
else
|
|
5264
|
-
return
|
|
5341
|
+
return p.error(
|
|
5265
5342
|
"[Haori]",
|
|
5266
|
-
`Primitive value requires '${
|
|
5343
|
+
`Primitive value requires '${u.prefix}each-arg' attribute: ${t}`
|
|
5267
5344
|
), Promise.resolve(!1);
|
|
5268
|
-
const o = a, c =
|
|
5345
|
+
const o = a, c = l.createBindingSignature({
|
|
5269
5346
|
listKey: n,
|
|
5270
5347
|
bindingData: o
|
|
5271
5348
|
});
|
|
5272
|
-
return e.getListKey() === n && e.getRenderSignature() === c ? Promise.resolve(!1) : (e.setListKey(n), e.setRenderSignature(c), e.setBindingData(o), e.setAttribute(`${
|
|
5349
|
+
return e.getListKey() === n && e.getRenderSignature() === c ? Promise.resolve(!1) : (e.setListKey(n), e.setRenderSignature(c), e.setBindingData(o), e.setAttribute(`${u.prefix}row`, n).then(() => !0));
|
|
5273
5350
|
}
|
|
5274
5351
|
/**
|
|
5275
5352
|
* 新規挿入行に遅延再評価が必要かどうかを判定します。
|
|
@@ -5283,7 +5360,7 @@ const u = class u {
|
|
|
5283
5360
|
const r = t.pop();
|
|
5284
5361
|
if (r.getChildElementFragments().forEach((i) => {
|
|
5285
5362
|
t.push(i);
|
|
5286
|
-
}), r !== e && !r.isMounted() &&
|
|
5363
|
+
}), r !== e && !r.isMounted() && l.hasMountSensitiveAttribute(r))
|
|
5287
5364
|
return !0;
|
|
5288
5365
|
}
|
|
5289
5366
|
return !1;
|
|
@@ -5296,7 +5373,7 @@ const u = class u {
|
|
|
5296
5373
|
*/
|
|
5297
5374
|
static hasMountSensitiveAttribute(e) {
|
|
5298
5375
|
return ["fetch", "import"].some(
|
|
5299
|
-
(t) => e.hasAttribute(`${
|
|
5376
|
+
(t) => e.hasAttribute(`${u.prefix}${t}`)
|
|
5300
5377
|
);
|
|
5301
5378
|
}
|
|
5302
5379
|
/**
|
|
@@ -5326,7 +5403,7 @@ const u = class u {
|
|
|
5326
5403
|
if (t.has(e))
|
|
5327
5404
|
return `[Circular:${t.get(e)}]`;
|
|
5328
5405
|
const i = `array-${r.value}`;
|
|
5329
|
-
return r.value += 1, t.set(e, i), `[${e.map((s) =>
|
|
5406
|
+
return r.value += 1, t.set(e, i), `[${e.map((s) => l.createBindingSignature(s, t, r)).join(",")}]`;
|
|
5330
5407
|
}
|
|
5331
5408
|
if (typeof e == "object") {
|
|
5332
5409
|
if (t.has(e))
|
|
@@ -5335,7 +5412,7 @@ const u = class u {
|
|
|
5335
5412
|
r.value += 1, t.set(e, i);
|
|
5336
5413
|
const s = e;
|
|
5337
5414
|
return `{${Object.keys(s).sort().map(
|
|
5338
|
-
(n) => `${JSON.stringify(n)}:${
|
|
5415
|
+
(n) => `${JSON.stringify(n)}:${l.createBindingSignature(
|
|
5339
5416
|
s[n],
|
|
5340
5417
|
t,
|
|
5341
5418
|
r
|
|
@@ -5351,18 +5428,18 @@ const u = class u {
|
|
|
5351
5428
|
*/
|
|
5352
5429
|
static scheduleEvaluateAll(e) {
|
|
5353
5430
|
setTimeout(() => {
|
|
5354
|
-
|
|
5431
|
+
l.evaluateAll(e);
|
|
5355
5432
|
}, 100);
|
|
5356
5433
|
}
|
|
5357
5434
|
};
|
|
5358
|
-
|
|
5435
|
+
l.ATTRIBUTE_ALIAS_SUFFIX = "attr-", l.PRIORITY_ATTRIBUTE_SUFFIXES = [
|
|
5359
5436
|
"bind",
|
|
5360
5437
|
"url-param",
|
|
5361
5438
|
"derive-name",
|
|
5362
5439
|
"derive",
|
|
5363
5440
|
"if",
|
|
5364
5441
|
"each"
|
|
5365
|
-
],
|
|
5442
|
+
], l.DEFERRED_ATTRIBUTE_SUFFIXES = ["fetch"], l.EVALUATE_ALL_EXCLUDED_ATTRIBUTE_SUFFIXES = [
|
|
5366
5443
|
"bind",
|
|
5367
5444
|
"derive",
|
|
5368
5445
|
"derive-name",
|
|
@@ -5371,8 +5448,8 @@ u.ATTRIBUTE_ALIAS_SUFFIX = "attr-", u.PRIORITY_ATTRIBUTE_SUFFIXES = [
|
|
|
5371
5448
|
"fetch",
|
|
5372
5449
|
"import",
|
|
5373
5450
|
"url-param"
|
|
5374
|
-
],
|
|
5375
|
-
let
|
|
5451
|
+
], l.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/, l.REACTIVE_FETCH_STATES = /* @__PURE__ */ new WeakMap(), l.REACTIVE_IMPORT_STATES = /* @__PURE__ */ new WeakMap(), l.DERIVE_SUBTREE_PROFILES = /* @__PURE__ */ new WeakMap(), l.EACH_UPDATE_STATES = /* @__PURE__ */ new WeakMap();
|
|
5452
|
+
let P = l;
|
|
5376
5453
|
const ee = class ee {
|
|
5377
5454
|
/**
|
|
5378
5455
|
* コンストラクタ。
|
|
@@ -5382,7 +5459,7 @@ const ee = class ee {
|
|
|
5382
5459
|
constructor(e = document) {
|
|
5383
5460
|
this.onClick = (t) => this.delegate(t, "click"), this.onChange = (t) => this.delegate(t, "change"), this.onLoadCapture = (t) => this.delegate(t, "load"), this.onWindowLoad = () => {
|
|
5384
5461
|
const t = document.documentElement, r = w.get(t);
|
|
5385
|
-
r && new
|
|
5462
|
+
r && new q(r, "load").run();
|
|
5386
5463
|
}, this.onPopstate = (t) => {
|
|
5387
5464
|
const r = t.state;
|
|
5388
5465
|
!r || r[ee.HISTORY_STATE_KEY] !== !0 || location.reload();
|
|
@@ -5412,8 +5489,8 @@ const ee = class ee {
|
|
|
5412
5489
|
if (!r)
|
|
5413
5490
|
return;
|
|
5414
5491
|
const i = w.get(r);
|
|
5415
|
-
i && (t === "change" && i instanceof
|
|
5416
|
-
|
|
5492
|
+
i && (t === "change" && i instanceof C && i.syncValue(), new q(i, t).run().catch((s) => {
|
|
5493
|
+
p.error("[Haori]", "Procedure execution error:", s);
|
|
5417
5494
|
}));
|
|
5418
5495
|
}
|
|
5419
5496
|
/**
|
|
@@ -5452,7 +5529,7 @@ const ee = class ee {
|
|
|
5452
5529
|
};
|
|
5453
5530
|
ee.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
5454
5531
|
let ne = ee;
|
|
5455
|
-
const
|
|
5532
|
+
const D = class D {
|
|
5456
5533
|
/**
|
|
5457
5534
|
* ノードが現在の Window に属する HTMLElement かどうかを判定します。
|
|
5458
5535
|
*
|
|
@@ -5466,42 +5543,42 @@ const T = class T {
|
|
|
5466
5543
|
return typeof t < "u" && e instanceof t;
|
|
5467
5544
|
}
|
|
5468
5545
|
static syncTree(e) {
|
|
5469
|
-
(e instanceof Element || e instanceof DocumentFragment) && (
|
|
5470
|
-
|
|
5546
|
+
(e instanceof Element || e instanceof DocumentFragment) && (D.isHtmlElement(e) && D.syncElement(e), e.querySelectorAll("*").forEach((t) => {
|
|
5547
|
+
D.syncElement(t);
|
|
5471
5548
|
}));
|
|
5472
5549
|
}
|
|
5473
5550
|
static syncElement(e) {
|
|
5474
|
-
const t =
|
|
5475
|
-
if (!r || !
|
|
5476
|
-
t && (t.observer.disconnect(),
|
|
5551
|
+
const t = D.registrations.get(e), r = w.get(e);
|
|
5552
|
+
if (!r || !D.shouldObserve(r)) {
|
|
5553
|
+
t && (t.observer.disconnect(), D.registrations.delete(e));
|
|
5477
5554
|
return;
|
|
5478
5555
|
}
|
|
5479
5556
|
if (typeof IntersectionObserver > "u")
|
|
5480
5557
|
return;
|
|
5481
|
-
const i =
|
|
5482
|
-
if (t && t.observer.root === i && t.observer.rootMargin === s &&
|
|
5558
|
+
const i = D.resolveRoot(r), s = D.resolveRootMargin(r), n = D.resolveThreshold(r), a = r.hasAttribute(`${u.prefix}intersect-once`);
|
|
5559
|
+
if (t && t.observer.root === i && t.observer.rootMargin === s && D.sameThreshold(
|
|
5483
5560
|
t.observer.thresholds,
|
|
5484
5561
|
n
|
|
5485
5562
|
) && t.once === a) {
|
|
5486
5563
|
t.fragment = r;
|
|
5487
5564
|
return;
|
|
5488
5565
|
}
|
|
5489
|
-
t && (t.observer.disconnect(),
|
|
5566
|
+
t && (t.observer.disconnect(), D.registrations.delete(e));
|
|
5490
5567
|
const o = new IntersectionObserver(
|
|
5491
5568
|
(c) => {
|
|
5492
|
-
const d =
|
|
5569
|
+
const d = D.registrations.get(e);
|
|
5493
5570
|
d && c.forEach((f) => {
|
|
5494
|
-
!f.isIntersecting || d.running ||
|
|
5495
|
-
|
|
5496
|
-
}).catch((
|
|
5497
|
-
|
|
5571
|
+
!f.isIntersecting || d.running || D.isDisabled(d.fragment) || (d.running = !0, new q(d.fragment, "intersect").runWithResult().then((g) => {
|
|
5572
|
+
g && d.once && (d.observer.disconnect(), D.registrations.delete(e));
|
|
5573
|
+
}).catch((g) => {
|
|
5574
|
+
p.error(
|
|
5498
5575
|
"[Haori]",
|
|
5499
5576
|
"Intersect procedure execution error:",
|
|
5500
|
-
|
|
5577
|
+
g
|
|
5501
5578
|
);
|
|
5502
5579
|
}).finally(() => {
|
|
5503
|
-
const
|
|
5504
|
-
|
|
5580
|
+
const g = D.registrations.get(e);
|
|
5581
|
+
g && (g.running = !1);
|
|
5505
5582
|
}));
|
|
5506
5583
|
});
|
|
5507
5584
|
},
|
|
@@ -5511,7 +5588,7 @@ const T = class T {
|
|
|
5511
5588
|
threshold: n
|
|
5512
5589
|
}
|
|
5513
5590
|
);
|
|
5514
|
-
o.observe(e),
|
|
5591
|
+
o.observe(e), D.registrations.set(e, {
|
|
5515
5592
|
fragment: r,
|
|
5516
5593
|
observer: o,
|
|
5517
5594
|
once: a,
|
|
@@ -5519,48 +5596,48 @@ const T = class T {
|
|
|
5519
5596
|
});
|
|
5520
5597
|
}
|
|
5521
5598
|
static cleanupTree(e) {
|
|
5522
|
-
if (
|
|
5523
|
-
const t =
|
|
5524
|
-
t && (t.observer.disconnect(),
|
|
5599
|
+
if (D.isHtmlElement(e)) {
|
|
5600
|
+
const t = D.registrations.get(e);
|
|
5601
|
+
t && (t.observer.disconnect(), D.registrations.delete(e));
|
|
5525
5602
|
}
|
|
5526
5603
|
(e instanceof Element || e instanceof DocumentFragment) && e.querySelectorAll("*").forEach((t) => {
|
|
5527
|
-
const r =
|
|
5528
|
-
r && (r.observer.disconnect(),
|
|
5604
|
+
const r = D.registrations.get(t);
|
|
5605
|
+
r && (r.observer.disconnect(), D.registrations.delete(t));
|
|
5529
5606
|
});
|
|
5530
5607
|
}
|
|
5531
5608
|
static disconnectAll() {
|
|
5532
|
-
|
|
5609
|
+
D.registrations.forEach((e) => {
|
|
5533
5610
|
e.observer.disconnect();
|
|
5534
|
-
}),
|
|
5611
|
+
}), D.registrations.clear();
|
|
5535
5612
|
}
|
|
5536
5613
|
static shouldObserve(e) {
|
|
5537
5614
|
return e.getAttributeNames().some((t) => {
|
|
5538
|
-
if (!t.startsWith(`${
|
|
5615
|
+
if (!t.startsWith(`${u.prefix}intersect-`))
|
|
5539
5616
|
return !1;
|
|
5540
|
-
const r = t.slice(`${
|
|
5541
|
-
return !
|
|
5617
|
+
const r = t.slice(`${u.prefix}intersect-`.length);
|
|
5618
|
+
return !D.CONFIG_KEYS.has(r);
|
|
5542
5619
|
});
|
|
5543
5620
|
}
|
|
5544
5621
|
static resolveRoot(e) {
|
|
5545
|
-
const t = `${
|
|
5622
|
+
const t = `${u.prefix}intersect-root`;
|
|
5546
5623
|
if (!e.hasAttribute(t))
|
|
5547
5624
|
return null;
|
|
5548
5625
|
const r = e.getAttribute(t);
|
|
5549
5626
|
if (typeof r != "string" || r.trim() === "")
|
|
5550
5627
|
return null;
|
|
5551
5628
|
const i = document.querySelector(r);
|
|
5552
|
-
return
|
|
5629
|
+
return D.isHtmlElement(i) ? i : (p.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
5553
5630
|
}
|
|
5554
5631
|
static resolveRootMargin(e) {
|
|
5555
|
-
const t = `${
|
|
5632
|
+
const t = `${u.prefix}intersect-root-margin`, r = e.getAttribute(t);
|
|
5556
5633
|
return r === null || r === !1 || r === "" ? "0px" : String(r);
|
|
5557
5634
|
}
|
|
5558
5635
|
static resolveThreshold(e) {
|
|
5559
|
-
const t = `${
|
|
5636
|
+
const t = `${u.prefix}intersect-threshold`, r = e.getAttribute(t), i = typeof r == "number" ? r : Number.parseFloat(String(r ?? 0));
|
|
5560
5637
|
return Number.isNaN(i) ? 0 : Math.min(1, Math.max(0, i));
|
|
5561
5638
|
}
|
|
5562
5639
|
static isDisabled(e) {
|
|
5563
|
-
const t = `${
|
|
5640
|
+
const t = `${u.prefix}intersect-disabled`, r = e.getAttribute(t);
|
|
5564
5641
|
if (r === null || r === !1)
|
|
5565
5642
|
return !1;
|
|
5566
5643
|
if (typeof r == "boolean")
|
|
@@ -5572,14 +5649,14 @@ const T = class T {
|
|
|
5572
5649
|
return e.length === 1 && e[0] === t;
|
|
5573
5650
|
}
|
|
5574
5651
|
};
|
|
5575
|
-
|
|
5652
|
+
D.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
5576
5653
|
"root",
|
|
5577
5654
|
"root-margin",
|
|
5578
5655
|
"threshold",
|
|
5579
5656
|
"disabled",
|
|
5580
5657
|
"once"
|
|
5581
|
-
]),
|
|
5582
|
-
let
|
|
5658
|
+
]), D.registrations = /* @__PURE__ */ new Map();
|
|
5659
|
+
let W = D;
|
|
5583
5660
|
const O = class O {
|
|
5584
5661
|
/**
|
|
5585
5662
|
* 既存の MutationObserver をすべて停止します。
|
|
@@ -5598,10 +5675,10 @@ const O = class O {
|
|
|
5598
5675
|
return;
|
|
5599
5676
|
O._initialized = !0, O.disconnectMutationObservers();
|
|
5600
5677
|
const e = await Promise.allSettled([
|
|
5601
|
-
|
|
5602
|
-
|
|
5678
|
+
P.scan(document.head),
|
|
5679
|
+
P.scan(document.body)
|
|
5603
5680
|
]), [t, r] = e;
|
|
5604
|
-
t.status !== "fulfilled" &&
|
|
5681
|
+
t.status !== "fulfilled" && p.error("[Haori]", "Failed to build head fragment:", t.reason), r.status !== "fulfilled" && p.error("[Haori]", "Failed to build body fragment:", r.reason), await M.wait(), document.body.setAttribute("data-haori-ready", ""), O.observe(document.head), O.observe(document.body), new ne().start(), W.syncTree(document.body);
|
|
5605
5682
|
}
|
|
5606
5683
|
/**
|
|
5607
5684
|
* 指定された要素を監視します。
|
|
@@ -5615,29 +5692,29 @@ const O = class O {
|
|
|
5615
5692
|
switch (i.type) {
|
|
5616
5693
|
case "attributes": {
|
|
5617
5694
|
const s = i.target;
|
|
5618
|
-
if (i.attributeName && s.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName &&
|
|
5695
|
+
if (i.attributeName && s.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && P.isAliasedAttributeReflection(
|
|
5619
5696
|
s,
|
|
5620
5697
|
i.attributeName
|
|
5621
5698
|
))
|
|
5622
5699
|
break;
|
|
5623
|
-
|
|
5700
|
+
P.setAttribute(
|
|
5624
5701
|
s,
|
|
5625
5702
|
i.attributeName,
|
|
5626
5703
|
s.getAttribute(i.attributeName),
|
|
5627
5704
|
!0
|
|
5628
|
-
),
|
|
5705
|
+
), W.syncElement(s);
|
|
5629
5706
|
break;
|
|
5630
5707
|
}
|
|
5631
5708
|
case "childList": {
|
|
5632
5709
|
Array.from(i.removedNodes).forEach((s) => {
|
|
5633
|
-
|
|
5710
|
+
W.cleanupTree(s), P.removeNode(s);
|
|
5634
5711
|
}), Array.from(i.addedNodes).forEach((s) => {
|
|
5635
|
-
s.parentElement instanceof Element && (
|
|
5712
|
+
s.parentElement instanceof Element && (P.addNode(s.parentElement, s), W.syncTree(s));
|
|
5636
5713
|
});
|
|
5637
5714
|
break;
|
|
5638
5715
|
}
|
|
5639
5716
|
case "characterData": {
|
|
5640
|
-
i.target instanceof Text || i.target instanceof Comment ?
|
|
5717
|
+
i.target instanceof Text || i.target instanceof Comment ? P.changeText(i.target, i.target.textContent) : p.warn(
|
|
5641
5718
|
"[Haori]",
|
|
5642
5719
|
"Unsupported character data type:",
|
|
5643
5720
|
i.target
|
|
@@ -5645,11 +5722,11 @@ const O = class O {
|
|
|
5645
5722
|
break;
|
|
5646
5723
|
}
|
|
5647
5724
|
default:
|
|
5648
|
-
|
|
5725
|
+
p.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
5649
5726
|
continue;
|
|
5650
5727
|
}
|
|
5651
5728
|
} catch (s) {
|
|
5652
|
-
|
|
5729
|
+
p.error("[Haori]", "Error processing mutation:", s);
|
|
5653
5730
|
}
|
|
5654
5731
|
});
|
|
5655
5732
|
t.observe(e, {
|
|
@@ -5663,16 +5740,16 @@ const O = class O {
|
|
|
5663
5740
|
O._initialized = !1, O._mutationObservers = [];
|
|
5664
5741
|
let Q = O;
|
|
5665
5742
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Q.init) : Q.init();
|
|
5666
|
-
const
|
|
5743
|
+
const De = "0.8.0";
|
|
5667
5744
|
export {
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5745
|
+
P as Core,
|
|
5746
|
+
u as Env,
|
|
5747
|
+
A as Form,
|
|
5671
5748
|
w as Fragment,
|
|
5672
5749
|
te as Haori,
|
|
5673
|
-
|
|
5674
|
-
|
|
5750
|
+
p as Log,
|
|
5751
|
+
M as Queue,
|
|
5675
5752
|
te as default,
|
|
5676
|
-
|
|
5753
|
+
De as version
|
|
5677
5754
|
};
|
|
5678
5755
|
//# sourceMappingURL=haori.es.js.map
|