haori 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +15 -2
- package/README.md +15 -2
- package/dist/haori.cjs.js +11 -11
- package/dist/haori.cjs.js.map +1 -1
- package/dist/haori.es.js +760 -564
- 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 +118 -5
- package/dist/package.json +1 -1
- package/dist/src/core.d.ts +80 -1
- package/dist/src/core.d.ts.map +1 -1
- package/dist/src/core.js +184 -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/form.d.ts +8 -3
- package/dist/src/form.d.ts.map +1 -1
- package/dist/src/form.js +11 -4
- package/dist/src/form.js.map +1 -1
- package/dist/src/haori.d.ts +12 -0
- package/dist/src/haori.d.ts.map +1 -1
- package/dist/src/haori.js +14 -0
- package/dist/src/haori.js.map +1 -1
- package/dist/src/index.d.ts +10 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -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 +31 -5
- package/dist/src/procedure.js.map +1 -1
- package/dist/src/queue.d.ts +7 -0
- package/dist/src/queue.d.ts.map +1 -1
- package/dist/src/queue.js +52 -0
- package/dist/src/queue.js.map +1 -1
- package/dist/tests/bindcomplete-and-scope.test.d.ts +2 -0
- package/dist/tests/bindcomplete-and-scope.test.d.ts.map +1 -0
- package/dist/tests/bindcomplete-and-scope.test.js +115 -0
- package/dist/tests/bindcomplete-and-scope.test.js.map +1 -0
- package/dist/tests/click-no-disabled.test.d.ts +2 -0
- package/dist/tests/click-no-disabled.test.d.ts.map +1 -0
- package/dist/tests/click-no-disabled.test.js +67 -0
- package/dist/tests/click-no-disabled.test.js.map +1 -0
- 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-form-container.test.d.ts +2 -0
- package/dist/tests/data-form-container.test.d.ts.map +1 -0
- package/dist/tests/data-form-container.test.js +87 -0
- package/dist/tests/data-form-container.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/dist/tests/render-wait.test.d.ts +2 -0
- package/dist/tests/render-wait.test.d.ts.map +1 -0
- package/dist/tests/render-wait.test.js +68 -0
- package/dist/tests/render-wait.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
|
|
35
|
-
return
|
|
34
|
+
function ce(T) {
|
|
35
|
+
return T === "embedded" || T === "demo";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
37
|
+
function de(T) {
|
|
38
|
+
return T === null ? null : ce(T) ? T : se;
|
|
39
39
|
}
|
|
40
40
|
const $ = class $ {
|
|
41
41
|
/**
|
|
@@ -53,7 +53,7 @@ const $ = class $ {
|
|
|
53
53
|
* @return 戻り値はありません。
|
|
54
54
|
*/
|
|
55
55
|
static setRuntime(e) {
|
|
56
|
-
$._runtime =
|
|
56
|
+
$._runtime = ce(e) ? e : se;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* 実行環境からプレフィックスと開発モードかどうかを自動検出します。
|
|
@@ -67,21 +67,21 @@ const $ = class $ {
|
|
|
67
67
|
if (e instanceof HTMLScriptElement) {
|
|
68
68
|
const r = e.getAttribute("data-prefix") || $._prefix;
|
|
69
69
|
$._prefix = r.endsWith("-") ? r : r + "-";
|
|
70
|
-
const i =
|
|
70
|
+
const i = de(
|
|
71
71
|
e.getAttribute("data-runtime")
|
|
72
72
|
);
|
|
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
|
}
|
|
@@ -97,7 +97,7 @@ const $ = class $ {
|
|
|
97
97
|
$._prefix = "data-", $._runtime = se;
|
|
98
98
|
let l = $;
|
|
99
99
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l.detect) : l.detect();
|
|
100
|
-
class
|
|
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,9 +837,9 @@ C.MAX_IDENTIFIER_RECOVERY_COUNT = 8, C.forbiddenBindingValueCache = /* @__PURE__
|
|
|
837
837
|
"while",
|
|
838
838
|
"with",
|
|
839
839
|
"yield"
|
|
840
|
-
]),
|
|
841
|
-
let
|
|
842
|
-
class
|
|
840
|
+
]), I.EXPRESSION_CACHE = /* @__PURE__ */ new Map();
|
|
841
|
+
let Y = I;
|
|
842
|
+
class ae {
|
|
843
843
|
constructor() {
|
|
844
844
|
this.MAX_BUDGET = 8, this.queue = [], this.processing = !1;
|
|
845
845
|
}
|
|
@@ -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
|
}
|
|
@@ -914,8 +914,35 @@ class de {
|
|
|
914
914
|
const e = this.queue.map((t) => t.promise);
|
|
915
915
|
e.length > 0 && await Promise.allSettled(e);
|
|
916
916
|
}
|
|
917
|
+
/**
|
|
918
|
+
* 現在処理中・待機中のタスクに加えて、その完了に追従して投入されるタスクも含め、
|
|
919
|
+
* キューが安定して空になるまで待機します。
|
|
920
|
+
*
|
|
921
|
+
* `wait()` は呼び出し時点のキュー内容だけを待つため、複数フレームに分割される描画
|
|
922
|
+
* (`data-each` の大量行など)では完了前に解決し得ます。本メソッドは、空かつ非処理の
|
|
923
|
+
* 状態が 1 フレームを跨いでも維持されるまでループして待つことで、レンダリング全体の
|
|
924
|
+
* 完了を待てるようにします。
|
|
925
|
+
*
|
|
926
|
+
* @param maxIterations 無限ループ防止の最大反復回数(連続アニメーション等への保険)
|
|
927
|
+
* @returns レンダリングが安定するまで解決されない Promise
|
|
928
|
+
*/
|
|
929
|
+
async waitForIdle(e = 1e3) {
|
|
930
|
+
let t = 0, r = 0;
|
|
931
|
+
for (; t < 2 && r < e; )
|
|
932
|
+
this.processing || this.queue.length > 0 ? (await this.wait(), t = 0) : t += 1, await ae.nextTick(), r += 1;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* 次のフレーム(または 1 マクロタスク)まで待機します。
|
|
936
|
+
*
|
|
937
|
+
* @returns 次フレームで解決される Promise
|
|
938
|
+
*/
|
|
939
|
+
static nextTick() {
|
|
940
|
+
return new Promise((e) => {
|
|
941
|
+
typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => e()) : setTimeout(e, 0);
|
|
942
|
+
});
|
|
943
|
+
}
|
|
917
944
|
}
|
|
918
|
-
const
|
|
945
|
+
const le = class le {
|
|
919
946
|
/**
|
|
920
947
|
* タスクをキューに追加します。
|
|
921
948
|
*
|
|
@@ -932,10 +959,19 @@ const oe = class oe {
|
|
|
932
959
|
static wait() {
|
|
933
960
|
return this.ASYNC_QUEUE.wait();
|
|
934
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* レンダリング(追従して投入されるタスクを含む)が安定して完了するまで待機します。
|
|
964
|
+
*
|
|
965
|
+
* @param maxIterations 無限ループ防止の最大反復回数
|
|
966
|
+
* @returns レンダリングが安定するまで解決されない Promise
|
|
967
|
+
*/
|
|
968
|
+
static waitForIdle(e = 1e3) {
|
|
969
|
+
return this.ASYNC_QUEUE.waitForIdle(e);
|
|
970
|
+
}
|
|
935
971
|
};
|
|
936
|
-
|
|
937
|
-
let
|
|
938
|
-
class
|
|
972
|
+
le.ASYNC_QUEUE = new ae();
|
|
973
|
+
let M = le;
|
|
974
|
+
class J {
|
|
939
975
|
/**
|
|
940
976
|
* 実行モードを取得します。
|
|
941
977
|
*
|
|
@@ -953,6 +989,20 @@ class te {
|
|
|
953
989
|
static setRuntime(e) {
|
|
954
990
|
l.setRuntime(e);
|
|
955
991
|
}
|
|
992
|
+
/**
|
|
993
|
+
* 進行中・追従して投入されるものを含め、すべてのレンダリングタスクの完了を待ちます。
|
|
994
|
+
*
|
|
995
|
+
* `data-each` の大量行のように複数フレームに分割される描画でも、安定して完了する
|
|
996
|
+
* まで待機します。Playwright などの外部テストから、タブ切り替えやクリック後に
|
|
997
|
+
* 描画完了を安全に待機するために利用できます。
|
|
998
|
+
*
|
|
999
|
+
* 例: `await page.evaluate(() => Haori.waitForRenders())`
|
|
1000
|
+
*
|
|
1001
|
+
* @return すべてのレンダリングが完了したら解決される Promise
|
|
1002
|
+
*/
|
|
1003
|
+
static waitForRenders() {
|
|
1004
|
+
return M.waitForIdle();
|
|
1005
|
+
}
|
|
956
1006
|
/**
|
|
957
1007
|
* 通知ダイアログを表示します。
|
|
958
1008
|
*
|
|
@@ -960,7 +1010,7 @@ class te {
|
|
|
960
1010
|
* @returns 通知が閉じられると解決されるPromise
|
|
961
1011
|
*/
|
|
962
1012
|
static dialog(e) {
|
|
963
|
-
return
|
|
1013
|
+
return M.enqueue(() => {
|
|
964
1014
|
window.alert(e);
|
|
965
1015
|
}, !0);
|
|
966
1016
|
}
|
|
@@ -988,7 +1038,7 @@ class te {
|
|
|
988
1038
|
* @returns ユーザーがOKをクリックした場合はtrue、キャンセルした場合はfalseが解決されるPromise
|
|
989
1039
|
*/
|
|
990
1040
|
static confirm(e) {
|
|
991
|
-
return
|
|
1041
|
+
return M.enqueue(() => window.confirm(e), !0);
|
|
992
1042
|
}
|
|
993
1043
|
/**
|
|
994
1044
|
* ダイアログを開きます。
|
|
@@ -996,8 +1046,8 @@ class te {
|
|
|
996
1046
|
* @param element 開くダイアログのHTML要素
|
|
997
1047
|
*/
|
|
998
1048
|
static openDialog(e) {
|
|
999
|
-
return
|
|
1000
|
-
e instanceof HTMLDialogElement ? e.showModal() :
|
|
1049
|
+
return M.enqueue(() => {
|
|
1050
|
+
e instanceof HTMLDialogElement ? e.showModal() : p.error("[Haori]", "Element is not a dialog: ", e);
|
|
1001
1051
|
}, !0);
|
|
1002
1052
|
}
|
|
1003
1053
|
/**
|
|
@@ -1006,8 +1056,8 @@ class te {
|
|
|
1006
1056
|
* @param element 閉じるダイアログのHTML要素
|
|
1007
1057
|
*/
|
|
1008
1058
|
static closeDialog(e) {
|
|
1009
|
-
return
|
|
1010
|
-
e instanceof HTMLDialogElement ? e.close() :
|
|
1059
|
+
return M.enqueue(() => {
|
|
1060
|
+
e instanceof HTMLDialogElement ? e.close() : p.error("[Haori]", "Element is not a dialog: ", e);
|
|
1011
1061
|
}, !0);
|
|
1012
1062
|
}
|
|
1013
1063
|
/**
|
|
@@ -1017,7 +1067,7 @@ class te {
|
|
|
1017
1067
|
* @param message エラーメッセージ
|
|
1018
1068
|
*/
|
|
1019
1069
|
static addErrorMessage(e, t) {
|
|
1020
|
-
return
|
|
1070
|
+
return J.addMessage(e, t, "error");
|
|
1021
1071
|
}
|
|
1022
1072
|
/**
|
|
1023
1073
|
* メッセージをレベル付きで追加します。
|
|
@@ -1027,7 +1077,7 @@ class te {
|
|
|
1027
1077
|
* @param level メッセージのレベル(省略可能)
|
|
1028
1078
|
*/
|
|
1029
1079
|
static addMessage(e, t, r) {
|
|
1030
|
-
return
|
|
1080
|
+
return M.enqueue(() => {
|
|
1031
1081
|
const i = e instanceof HTMLFormElement ? e : e.parentElement ?? e;
|
|
1032
1082
|
i.setAttribute("data-message", t), r !== void 0 ? i.setAttribute("data-message-level", r) : i.removeAttribute("data-message-level");
|
|
1033
1083
|
}, !0);
|
|
@@ -1038,7 +1088,7 @@ class te {
|
|
|
1038
1088
|
* @param parent メッセージをクリアする親要素
|
|
1039
1089
|
*/
|
|
1040
1090
|
static clearMessages(e) {
|
|
1041
|
-
return
|
|
1091
|
+
return M.enqueue(() => {
|
|
1042
1092
|
e.removeAttribute("data-message"), e.removeAttribute("data-message-level"), e.querySelectorAll("[data-message]").forEach((t) => {
|
|
1043
1093
|
t.removeAttribute("data-message"), t.removeAttribute("data-message-level");
|
|
1044
1094
|
});
|
|
@@ -1046,13 +1096,13 @@ class te {
|
|
|
1046
1096
|
}
|
|
1047
1097
|
}
|
|
1048
1098
|
const fe = ["addErrorMessage", "clearMessages"];
|
|
1049
|
-
function
|
|
1099
|
+
function ue() {
|
|
1050
1100
|
const e = globalThis.window?.Haori;
|
|
1051
1101
|
return fe.every(
|
|
1052
1102
|
(r) => typeof e?.[r] == "function"
|
|
1053
|
-
) ? e :
|
|
1103
|
+
) ? e : J;
|
|
1054
1104
|
}
|
|
1055
|
-
class
|
|
1105
|
+
class A {
|
|
1056
1106
|
/**
|
|
1057
1107
|
* フォーム内にある入力エレメントの値をオブジェクトとして取得します。
|
|
1058
1108
|
* data-form-object属性があると、そのエレメント内の値はオブジェクトとして処理されます。
|
|
@@ -1063,7 +1113,7 @@ class E {
|
|
|
1063
1113
|
*/
|
|
1064
1114
|
static getValues(e) {
|
|
1065
1115
|
const t = {};
|
|
1066
|
-
return
|
|
1116
|
+
return A.getPartValues(e, t);
|
|
1067
1117
|
}
|
|
1068
1118
|
/**
|
|
1069
1119
|
* フォーム内の各入力エレメントから値を取得し、オブジェクトとして返します。
|
|
@@ -1076,17 +1126,17 @@ class E {
|
|
|
1076
1126
|
static getPartValues(e, t) {
|
|
1077
1127
|
const r = e.getAttribute("name"), i = e.getAttribute(`${l.prefix}form-object`), s = e.getAttribute(`${l.prefix}form-list`);
|
|
1078
1128
|
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 &&
|
|
1129
|
+
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
1130
|
"Haori",
|
|
1081
1131
|
`Element cannot have both ${l.prefix}form-object and name attributes.`
|
|
1082
1132
|
);
|
|
1083
1133
|
for (const n of e.getChildElementFragments())
|
|
1084
|
-
|
|
1134
|
+
A.getPartValues(n, t);
|
|
1085
1135
|
} else if (i) {
|
|
1086
1136
|
const n = {};
|
|
1087
1137
|
for (const a of e.getChildElementFragments())
|
|
1088
|
-
|
|
1089
|
-
Object.keys(n).length > 0 && (t[String(i)] = n), s &&
|
|
1138
|
+
A.getPartValues(a, n);
|
|
1139
|
+
Object.keys(n).length > 0 && (t[String(i)] = n), s && p.warn(
|
|
1090
1140
|
"Haori",
|
|
1091
1141
|
`Element cannot have both ${l.prefix}form-list and ${l.prefix}form-object attributes.`
|
|
1092
1142
|
);
|
|
@@ -1094,12 +1144,12 @@ class E {
|
|
|
1094
1144
|
const n = [];
|
|
1095
1145
|
for (const a of e.getChildElementFragments()) {
|
|
1096
1146
|
const o = {};
|
|
1097
|
-
|
|
1147
|
+
A.getPartValues(a, o), Object.keys(o).length > 0 && n.push(o);
|
|
1098
1148
|
}
|
|
1099
1149
|
n.length > 0 && (t[String(s)] = n);
|
|
1100
1150
|
} else
|
|
1101
1151
|
for (const n of e.getChildElementFragments())
|
|
1102
|
-
|
|
1152
|
+
A.getPartValues(n, t);
|
|
1103
1153
|
return t;
|
|
1104
1154
|
}
|
|
1105
1155
|
/**
|
|
@@ -1112,7 +1162,7 @@ class E {
|
|
|
1112
1162
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
1113
1163
|
*/
|
|
1114
1164
|
static setValues(e, t, r = !1) {
|
|
1115
|
-
return
|
|
1165
|
+
return A.setPartValues(e, t, null, r, !0);
|
|
1116
1166
|
}
|
|
1117
1167
|
/**
|
|
1118
1168
|
* フォーム内にある入力エレメントに値をイベントなしで設定します。
|
|
@@ -1124,7 +1174,7 @@ class E {
|
|
|
1124
1174
|
* @returns Promise(DOMの更新が完了したら解決される)
|
|
1125
1175
|
*/
|
|
1126
1176
|
static syncValues(e, t, r = !1) {
|
|
1127
|
-
return
|
|
1177
|
+
return A.setPartValues(e, t, null, r, !1);
|
|
1128
1178
|
}
|
|
1129
1179
|
/**
|
|
1130
1180
|
* 単一フラグメントへ値を設定します。
|
|
@@ -1152,18 +1202,18 @@ class E {
|
|
|
1152
1202
|
if (!d || i) {
|
|
1153
1203
|
const f = t[String(a)];
|
|
1154
1204
|
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
|
-
|
|
1205
|
+
A.applyFragmentValue(e, f[r] ?? null, s)
|
|
1206
|
+
) : typeof f > "u" || (typeof f == "string" || typeof f == "number" || typeof f == "boolean" || f === null ? n.push(A.applyFragmentValue(e, f, s)) : n.push(
|
|
1207
|
+
A.applyFragmentValue(e, String(f), s)
|
|
1158
1208
|
));
|
|
1159
1209
|
}
|
|
1160
1210
|
} else if (o) {
|
|
1161
1211
|
const f = t[String(o)];
|
|
1162
1212
|
if (f && typeof f == "object")
|
|
1163
|
-
for (const
|
|
1213
|
+
for (const g of e.getChildElementFragments())
|
|
1164
1214
|
n.push(
|
|
1165
|
-
|
|
1166
|
-
|
|
1215
|
+
A.setPartValues(
|
|
1216
|
+
g,
|
|
1167
1217
|
f,
|
|
1168
1218
|
null,
|
|
1169
1219
|
i,
|
|
@@ -1173,24 +1223,24 @@ class E {
|
|
|
1173
1223
|
} else if (c) {
|
|
1174
1224
|
const f = t[String(c)];
|
|
1175
1225
|
if (Array.isArray(f)) {
|
|
1176
|
-
const
|
|
1177
|
-
for (let
|
|
1178
|
-
const
|
|
1179
|
-
f.length >
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
f[
|
|
1183
|
-
|
|
1226
|
+
const g = e.getChildElementFragments();
|
|
1227
|
+
for (let b = 0; b < g.length; b++) {
|
|
1228
|
+
const S = g[b];
|
|
1229
|
+
f.length > b ? n.push(
|
|
1230
|
+
A.setPartValues(
|
|
1231
|
+
S,
|
|
1232
|
+
f[b],
|
|
1233
|
+
b,
|
|
1184
1234
|
i,
|
|
1185
1235
|
s
|
|
1186
1236
|
)
|
|
1187
|
-
) : n.push(
|
|
1237
|
+
) : n.push(A.setPartValues(S, {}, b, i, s));
|
|
1188
1238
|
}
|
|
1189
1239
|
}
|
|
1190
1240
|
} else
|
|
1191
1241
|
for (const f of e.getChildElementFragments())
|
|
1192
1242
|
n.push(
|
|
1193
|
-
|
|
1243
|
+
A.setPartValues(f, t, null, i, s)
|
|
1194
1244
|
);
|
|
1195
1245
|
return Promise.all(n).then(() => {
|
|
1196
1246
|
});
|
|
@@ -1203,10 +1253,10 @@ class E {
|
|
|
1203
1253
|
* @returns すべての初期化処理が完了するPromise
|
|
1204
1254
|
*/
|
|
1205
1255
|
static async reset(e) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
]), await
|
|
1256
|
+
A.clearValues(e), await Promise.all([
|
|
1257
|
+
A.clearMessages(e),
|
|
1258
|
+
A.clearEachClones(e)
|
|
1259
|
+
]), await M.enqueue(() => {
|
|
1210
1260
|
const t = e.getTarget();
|
|
1211
1261
|
if (t instanceof HTMLFormElement)
|
|
1212
1262
|
t.reset();
|
|
@@ -1217,7 +1267,7 @@ class E {
|
|
|
1217
1267
|
s.appendChild(t), s.reset(), r.insertBefore(t, i);
|
|
1218
1268
|
}
|
|
1219
1269
|
}
|
|
1220
|
-
}), await
|
|
1270
|
+
}), await P.evaluateAll(e);
|
|
1221
1271
|
}
|
|
1222
1272
|
/**
|
|
1223
1273
|
* data-each によって生成された複製(テンプレート以外)を削除します。
|
|
@@ -1251,7 +1301,7 @@ class E {
|
|
|
1251
1301
|
static clearValues(e) {
|
|
1252
1302
|
e.clearValue();
|
|
1253
1303
|
for (const t of e.getChildElementFragments())
|
|
1254
|
-
|
|
1304
|
+
A.clearValues(t);
|
|
1255
1305
|
}
|
|
1256
1306
|
/**
|
|
1257
1307
|
* フラグメントとその子要素のメッセージをクリアします。
|
|
@@ -1260,7 +1310,7 @@ class E {
|
|
|
1260
1310
|
* @returns Promise(メッセージのクリアが完了したら解決される)
|
|
1261
1311
|
*/
|
|
1262
1312
|
static clearMessages(e) {
|
|
1263
|
-
return
|
|
1313
|
+
return ue().clearMessages(
|
|
1264
1314
|
e.getTarget()
|
|
1265
1315
|
);
|
|
1266
1316
|
}
|
|
@@ -1274,7 +1324,7 @@ class E {
|
|
|
1274
1324
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
1275
1325
|
*/
|
|
1276
1326
|
static addErrorMessage(e, t, r) {
|
|
1277
|
-
return
|
|
1327
|
+
return A.addMessage(e, t, r, "error");
|
|
1278
1328
|
}
|
|
1279
1329
|
/**
|
|
1280
1330
|
* キーに一致するフラグメントにレベル付きメッセージを追加します。
|
|
@@ -1287,7 +1337,7 @@ class E {
|
|
|
1287
1337
|
* @return Promise(メッセージの追加が完了したら解決される)
|
|
1288
1338
|
*/
|
|
1289
1339
|
static addMessage(e, t, r, i) {
|
|
1290
|
-
const s = [], n =
|
|
1340
|
+
const s = [], n = ue(), a = n.addMessage, o = (d) => typeof a == "function" ? a.call(n, d, r, i) : n.addErrorMessage(d, r), c = A.findFragmentsByKey(e, t);
|
|
1291
1341
|
return c.forEach((d) => {
|
|
1292
1342
|
s.push(o(d.getTarget()));
|
|
1293
1343
|
}), c.length === 0 && s.push(o(e.getTarget())), Promise.all(s).then(() => {
|
|
@@ -1301,7 +1351,7 @@ class E {
|
|
|
1301
1351
|
* @returns 一致するフラグメントの配列
|
|
1302
1352
|
*/
|
|
1303
1353
|
static findFragmentsByKey(e, t) {
|
|
1304
|
-
return
|
|
1354
|
+
return A.findFragmentByKeyParts(e, t.split("."));
|
|
1305
1355
|
}
|
|
1306
1356
|
/**
|
|
1307
1357
|
* 指定されたキーに一致するフラグメントを検索します。
|
|
@@ -1315,7 +1365,7 @@ class E {
|
|
|
1315
1365
|
const r = [], i = t[0];
|
|
1316
1366
|
if (t.length == 1 && e.getAttribute("name") === i && r.push(e), e.hasAttribute(`${l.prefix}form-object`))
|
|
1317
1367
|
t.length > 1 && e.getAttribute(`${l.prefix}form-object`) === i && e.getChildElementFragments().forEach((n) => {
|
|
1318
|
-
r.push(...
|
|
1368
|
+
r.push(...A.findFragmentByKeyParts(n, t.slice(1)));
|
|
1319
1369
|
});
|
|
1320
1370
|
else if (e.hasAttribute(`${l.prefix}form-list`)) {
|
|
1321
1371
|
if (t.length > 1) {
|
|
@@ -1325,11 +1375,11 @@ class E {
|
|
|
1325
1375
|
if (s === o) {
|
|
1326
1376
|
const c = i.substring(n + 1, a), d = Number(c);
|
|
1327
1377
|
if (isNaN(d))
|
|
1328
|
-
|
|
1378
|
+
p.error("Haori", `Invalid index: ${i}`);
|
|
1329
1379
|
else {
|
|
1330
|
-
const f = e.getChildElementFragments().filter((
|
|
1380
|
+
const f = e.getChildElementFragments().filter((g) => g.hasAttribute(`${l.prefix}row`));
|
|
1331
1381
|
d < f.length && r.push(
|
|
1332
|
-
...
|
|
1382
|
+
...A.findFragmentByKeyParts(f[d], t.slice(1))
|
|
1333
1383
|
);
|
|
1334
1384
|
}
|
|
1335
1385
|
}
|
|
@@ -1337,29 +1387,35 @@ class E {
|
|
|
1337
1387
|
}
|
|
1338
1388
|
} else
|
|
1339
1389
|
e.getChildElementFragments().forEach((s) => {
|
|
1340
|
-
r.push(...
|
|
1390
|
+
r.push(...A.findFragmentByKeyParts(s, t));
|
|
1341
1391
|
});
|
|
1342
1392
|
return r;
|
|
1343
1393
|
}
|
|
1344
1394
|
/**
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1395
|
+
* 対象のフラグメントがフォームコンテナであればそれを返し、
|
|
1396
|
+
* そうでなければ先祖要素をたどってフォームコンテナを探します。
|
|
1397
|
+
*
|
|
1398
|
+
* フォームコンテナは `<form>` 要素、または `data-form` 属性を持つ任意の要素です。
|
|
1399
|
+
* 後者は `<table>` 内など `<form>` を直接置けない箇所で、`<tr>` などを値収集の
|
|
1400
|
+
* コンテナとして扱うために使用します(`data-click-form` 等が対象を探す際に利用)。
|
|
1347
1401
|
*
|
|
1348
|
-
* @param fragment
|
|
1402
|
+
* @param fragment 探索の起点フラグメント
|
|
1403
|
+
* @returns フォームコンテナのフラグメント。見つからなければ null
|
|
1349
1404
|
*/
|
|
1350
1405
|
static getFormFragment(e) {
|
|
1351
|
-
|
|
1406
|
+
const t = e.getTarget();
|
|
1407
|
+
if (t instanceof HTMLFormElement || t instanceof HTMLElement && t.hasAttribute(`${l.prefix}form`))
|
|
1352
1408
|
return e;
|
|
1353
1409
|
const r = e.getParent();
|
|
1354
1410
|
return r ? this.getFormFragment(r) : null;
|
|
1355
1411
|
}
|
|
1356
1412
|
}
|
|
1357
|
-
const
|
|
1413
|
+
const x = class x {
|
|
1358
1414
|
/**
|
|
1359
1415
|
* 集計状態を初期化します。
|
|
1360
1416
|
*/
|
|
1361
1417
|
static reset() {
|
|
1362
|
-
|
|
1418
|
+
x.ELEMENT_STORES.clear(), x.ensureGlobalAccess();
|
|
1363
1419
|
}
|
|
1364
1420
|
/**
|
|
1365
1421
|
* 現在の集計結果スナップショットを返します。
|
|
@@ -1367,7 +1423,7 @@ const N = class N {
|
|
|
1367
1423
|
* @returns エレメントごとの集計結果
|
|
1368
1424
|
*/
|
|
1369
1425
|
static snapshot() {
|
|
1370
|
-
return
|
|
1426
|
+
return x.ensureGlobalAccess(), [...x.ELEMENT_STORES.entries()].map(([e, t]) => ({
|
|
1371
1427
|
elementId: e,
|
|
1372
1428
|
tagName: t.tagName,
|
|
1373
1429
|
attributes: [...t.attributes.entries()].map(([r, i]) => ({
|
|
@@ -1376,7 +1432,7 @@ const N = class N {
|
|
|
1376
1432
|
calls: i.calls,
|
|
1377
1433
|
totalDurationMs: i.totalDurationMs,
|
|
1378
1434
|
maxDurationMs: i.maxDurationMs,
|
|
1379
|
-
placeholders:
|
|
1435
|
+
placeholders: x.sortPlaceholders(
|
|
1380
1436
|
i.placeholders
|
|
1381
1437
|
)
|
|
1382
1438
|
})).sort((r, i) => i.calls - r.calls),
|
|
@@ -1386,7 +1442,7 @@ const N = class N {
|
|
|
1386
1442
|
calls: i.calls,
|
|
1387
1443
|
totalDurationMs: i.totalDurationMs,
|
|
1388
1444
|
maxDurationMs: i.maxDurationMs,
|
|
1389
|
-
placeholders:
|
|
1445
|
+
placeholders: x.sortPlaceholders(
|
|
1390
1446
|
i.placeholders
|
|
1391
1447
|
)
|
|
1392
1448
|
})).sort((r, i) => i.calls - r.calls)
|
|
@@ -1402,31 +1458,31 @@ const N = class N {
|
|
|
1402
1458
|
* @param expressions 今回評価した式一覧
|
|
1403
1459
|
*/
|
|
1404
1460
|
static record(e, t, r) {
|
|
1405
|
-
if (!
|
|
1461
|
+
if (!L.isEnabled() || !e || t.length === 0)
|
|
1406
1462
|
return;
|
|
1407
|
-
|
|
1408
|
-
const i =
|
|
1463
|
+
x.ensureGlobalAccess();
|
|
1464
|
+
const i = x.getOrCreateElementStore(
|
|
1409
1465
|
e.element
|
|
1410
1466
|
);
|
|
1411
1467
|
if (e.kind === "attribute") {
|
|
1412
|
-
const n =
|
|
1468
|
+
const n = x.getOrCreateCounter(
|
|
1413
1469
|
i.attributes,
|
|
1414
1470
|
e.rawName,
|
|
1415
1471
|
e.template
|
|
1416
1472
|
);
|
|
1417
|
-
|
|
1473
|
+
x.updateCounter(
|
|
1418
1474
|
n,
|
|
1419
1475
|
t,
|
|
1420
1476
|
r
|
|
1421
1477
|
);
|
|
1422
1478
|
return;
|
|
1423
1479
|
}
|
|
1424
|
-
const s =
|
|
1480
|
+
const s = x.getOrCreateCounter(
|
|
1425
1481
|
i.texts,
|
|
1426
1482
|
String(e.childIndex),
|
|
1427
1483
|
e.template
|
|
1428
1484
|
);
|
|
1429
|
-
|
|
1485
|
+
x.updateCounter(
|
|
1430
1486
|
s,
|
|
1431
1487
|
t,
|
|
1432
1488
|
r
|
|
@@ -1436,12 +1492,12 @@ const N = class N {
|
|
|
1436
1492
|
* globalThis から dev-only の取得窓口を参照できるようにします。
|
|
1437
1493
|
*/
|
|
1438
1494
|
static ensureGlobalAccess() {
|
|
1439
|
-
if (!
|
|
1495
|
+
if (!L.isEnabled())
|
|
1440
1496
|
return;
|
|
1441
1497
|
const e = globalThis;
|
|
1442
|
-
e[
|
|
1443
|
-
reset: () =>
|
|
1444
|
-
snapshot: () =>
|
|
1498
|
+
e[x.GLOBAL_KEY] === void 0 && (e[x.GLOBAL_KEY] = {
|
|
1499
|
+
reset: () => x.reset(),
|
|
1500
|
+
snapshot: () => x.snapshot()
|
|
1445
1501
|
});
|
|
1446
1502
|
}
|
|
1447
1503
|
/**
|
|
@@ -1451,7 +1507,7 @@ const N = class N {
|
|
|
1451
1507
|
* @returns 集計ストア
|
|
1452
1508
|
*/
|
|
1453
1509
|
static getOrCreateElementStore(e) {
|
|
1454
|
-
const t =
|
|
1510
|
+
const t = x.createElementId(e), r = x.ELEMENT_STORES.get(t);
|
|
1455
1511
|
if (r)
|
|
1456
1512
|
return r;
|
|
1457
1513
|
const i = {
|
|
@@ -1459,7 +1515,7 @@ const N = class N {
|
|
|
1459
1515
|
attributes: /* @__PURE__ */ new Map(),
|
|
1460
1516
|
texts: /* @__PURE__ */ new Map()
|
|
1461
1517
|
};
|
|
1462
|
-
return
|
|
1518
|
+
return x.ELEMENT_STORES.set(t, i), i;
|
|
1463
1519
|
}
|
|
1464
1520
|
/**
|
|
1465
1521
|
* カウンタを取得または初期化します。
|
|
@@ -1509,7 +1565,7 @@ const N = class N {
|
|
|
1509
1565
|
*/
|
|
1510
1566
|
static updateCounter(e, t, r) {
|
|
1511
1567
|
e.calls += 1, e.totalDurationMs += r, e.maxDurationMs = Math.max(e.maxDurationMs, r), t.forEach((i) => {
|
|
1512
|
-
const s =
|
|
1568
|
+
const s = x.getOrCreatePlaceholder(
|
|
1513
1569
|
e.placeholders,
|
|
1514
1570
|
i.expression
|
|
1515
1571
|
);
|
|
@@ -1548,10 +1604,10 @@ const N = class N {
|
|
|
1548
1604
|
* @returns 結果と所要時間
|
|
1549
1605
|
*/
|
|
1550
1606
|
static measure(e) {
|
|
1551
|
-
const t =
|
|
1607
|
+
const t = x.now();
|
|
1552
1608
|
return {
|
|
1553
1609
|
value: e(),
|
|
1554
|
-
durationMs:
|
|
1610
|
+
durationMs: x.now() - t
|
|
1555
1611
|
};
|
|
1556
1612
|
}
|
|
1557
1613
|
/**
|
|
@@ -1578,35 +1634,35 @@ const N = class N {
|
|
|
1578
1634
|
return t.join(" > ");
|
|
1579
1635
|
}
|
|
1580
1636
|
};
|
|
1581
|
-
|
|
1582
|
-
let
|
|
1583
|
-
const
|
|
1637
|
+
x.GLOBAL_KEY = "__HAORI_EVALUATION_PROFILE__", x.ELEMENT_STORES = /* @__PURE__ */ new Map();
|
|
1638
|
+
let X = x;
|
|
1639
|
+
const G = class G {
|
|
1584
1640
|
/**
|
|
1585
1641
|
* フラグメントのコンストラクタ。
|
|
1586
1642
|
*
|
|
1587
1643
|
* @param target 対象ノード
|
|
1588
1644
|
*/
|
|
1589
1645
|
constructor(e) {
|
|
1590
|
-
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e,
|
|
1646
|
+
this.parent = null, this.mounted = !1, this.skipMutationNodes = !1, this.target = e, G.FRAGMENT_CACHE.set(e, this);
|
|
1591
1647
|
}
|
|
1592
1648
|
static get(e) {
|
|
1593
1649
|
if (e == null)
|
|
1594
1650
|
return null;
|
|
1595
|
-
if (
|
|
1596
|
-
return
|
|
1651
|
+
if (G.FRAGMENT_CACHE.has(e))
|
|
1652
|
+
return G.FRAGMENT_CACHE.get(e);
|
|
1597
1653
|
let t;
|
|
1598
1654
|
switch (e.nodeType) {
|
|
1599
1655
|
case Node.ELEMENT_NODE:
|
|
1600
|
-
t = new
|
|
1656
|
+
t = new C(e);
|
|
1601
1657
|
break;
|
|
1602
1658
|
case Node.TEXT_NODE:
|
|
1603
1659
|
t = new H(e);
|
|
1604
1660
|
break;
|
|
1605
1661
|
case Node.COMMENT_NODE:
|
|
1606
|
-
t = new
|
|
1662
|
+
t = new oe(e);
|
|
1607
1663
|
break;
|
|
1608
1664
|
default:
|
|
1609
|
-
return
|
|
1665
|
+
return p.warn("[Haori]", "Unsupported node type:", e.nodeType), null;
|
|
1610
1666
|
}
|
|
1611
1667
|
return t;
|
|
1612
1668
|
}
|
|
@@ -1628,7 +1684,7 @@ const K = class K {
|
|
|
1628
1684
|
return Promise.resolve();
|
|
1629
1685
|
if (this.parent) {
|
|
1630
1686
|
const e = this.parent, t = e.skipMutationNodes;
|
|
1631
|
-
return
|
|
1687
|
+
return M.enqueue(() => {
|
|
1632
1688
|
e.skipMutationNodes = !0, this.target.parentNode === e.getTarget() && e.getTarget().removeChild(this.target), this.mounted = !1;
|
|
1633
1689
|
}).finally(() => {
|
|
1634
1690
|
e.skipMutationNodes = t;
|
|
@@ -1636,7 +1692,7 @@ const K = class K {
|
|
|
1636
1692
|
} else {
|
|
1637
1693
|
const e = this.target.parentNode;
|
|
1638
1694
|
if (e)
|
|
1639
|
-
return
|
|
1695
|
+
return M.enqueue(() => {
|
|
1640
1696
|
this.target.parentNode === e && e.removeChild(this.target), this.mounted = !1;
|
|
1641
1697
|
});
|
|
1642
1698
|
this.mounted = !1;
|
|
@@ -1653,7 +1709,7 @@ const K = class K {
|
|
|
1653
1709
|
return Promise.resolve();
|
|
1654
1710
|
if (this.parent) {
|
|
1655
1711
|
const e = this.parent, t = e.skipMutationNodes;
|
|
1656
|
-
return
|
|
1712
|
+
return M.enqueue(() => {
|
|
1657
1713
|
e.skipMutationNodes = !0, this.target.parentNode !== e.getTarget() && e.getTarget().appendChild(this.target), this.mounted = !0;
|
|
1658
1714
|
}).finally(() => {
|
|
1659
1715
|
e.skipMutationNodes = t;
|
|
@@ -1684,7 +1740,7 @@ const K = class K {
|
|
|
1684
1740
|
* @return 除去のPromise
|
|
1685
1741
|
*/
|
|
1686
1742
|
remove(e = !0) {
|
|
1687
|
-
return this.parent && this.parent.removeChild(this),
|
|
1743
|
+
return this.parent && this.parent.removeChild(this), G.FRAGMENT_CACHE.delete(this.target), e ? this.unmount() : Promise.resolve();
|
|
1688
1744
|
}
|
|
1689
1745
|
/**
|
|
1690
1746
|
* 対象ノードを取得します。
|
|
@@ -1711,8 +1767,8 @@ const K = class K {
|
|
|
1711
1767
|
this.parent = e;
|
|
1712
1768
|
}
|
|
1713
1769
|
};
|
|
1714
|
-
|
|
1715
|
-
let w =
|
|
1770
|
+
G.FRAGMENT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
1771
|
+
let w = G;
|
|
1716
1772
|
const V = class V extends w {
|
|
1717
1773
|
/**
|
|
1718
1774
|
* エレメントフラグメントのコンストラクタ。
|
|
@@ -1739,7 +1795,7 @@ const V = class V extends w {
|
|
|
1739
1795
|
], this.children = [], this.attributeMap = /* @__PURE__ */ new Map(), this.bindingData = null, this.derivedBindingData = null, this.bindingDataCache = null, this.descendantBindingDataCache = null, this.visible = !0, this.display = null, this.displayPriority = null, this.template = null, this.listKey = null, this.renderSignature = null, this.eachInputSignature = null, this.deriveSubtreeSignature = null, this.deriveInputSignature = null, this.freshInitializationSkippable = !1, this.value = null, this.skipMutationAttributes = !1, this.skipChangeValue = !1, this.syncValue(), e.getAttributeNames().forEach((t) => {
|
|
1740
1796
|
const r = e.getAttribute(t);
|
|
1741
1797
|
if (r !== null && !this.attributeMap.has(t)) {
|
|
1742
|
-
const i = new
|
|
1798
|
+
const i = new Q(t, r);
|
|
1743
1799
|
this.attributeMap.set(t, i);
|
|
1744
1800
|
}
|
|
1745
1801
|
}), e.childNodes.forEach((t) => {
|
|
@@ -1783,7 +1839,7 @@ const V = class V extends w {
|
|
|
1783
1839
|
removeChild(e) {
|
|
1784
1840
|
const t = this.children.indexOf(e);
|
|
1785
1841
|
if (t < 0) {
|
|
1786
|
-
|
|
1842
|
+
p.warn("[Haori]", "Child fragment not found.", e);
|
|
1787
1843
|
return;
|
|
1788
1844
|
}
|
|
1789
1845
|
this.children.splice(t, 1), e.setParent(null);
|
|
@@ -2047,16 +2103,16 @@ const V = class V extends w {
|
|
|
2047
2103
|
if (r instanceof HTMLInputElement && (r.type === "checkbox" || r.type === "radio")) {
|
|
2048
2104
|
const i = this.getAttribute("value"), s = r.type === "checkbox" && i === "true";
|
|
2049
2105
|
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,
|
|
2106
|
+
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
2107
|
r.checked = n, t && r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2052
2108
|
}).finally(() => {
|
|
2053
2109
|
this.skipChangeValue = !1;
|
|
2054
2110
|
}));
|
|
2055
|
-
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = e, this.skipChangeValue = !0,
|
|
2111
|
+
} else return r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement || r instanceof HTMLSelectElement ? (this.value = e, this.skipChangeValue = !0, M.enqueue(() => {
|
|
2056
2112
|
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
2113
|
}).finally(() => {
|
|
2058
2114
|
this.skipChangeValue = !1;
|
|
2059
|
-
})) : (
|
|
2115
|
+
})) : (p.warn(
|
|
2060
2116
|
"[Haori]",
|
|
2061
2117
|
"setValue is not supported for this element type.",
|
|
2062
2118
|
r
|
|
@@ -2138,7 +2194,7 @@ const V = class V extends w {
|
|
|
2138
2194
|
return Promise.resolve();
|
|
2139
2195
|
this.attributeMap.delete(e), this.skipMutationAttributes = !0;
|
|
2140
2196
|
const r = this.getTarget();
|
|
2141
|
-
return
|
|
2197
|
+
return M.enqueue(() => {
|
|
2142
2198
|
r.removeAttribute(e), t !== e && r.removeAttribute(t);
|
|
2143
2199
|
}).finally(() => {
|
|
2144
2200
|
this.skipMutationAttributes = !1;
|
|
@@ -2158,11 +2214,11 @@ const V = class V extends w {
|
|
|
2158
2214
|
return Promise.resolve();
|
|
2159
2215
|
if (r === null)
|
|
2160
2216
|
return e === t ? this.removeAttribute(e) : this.removeAliasedAttribute(e, t);
|
|
2161
|
-
const n = new
|
|
2217
|
+
const n = new Q(e, r);
|
|
2162
2218
|
if (s) {
|
|
2163
|
-
const
|
|
2164
|
-
if (
|
|
2165
|
-
return this.skipMutationAttributes = !0,
|
|
2219
|
+
const U = this.attributeMap.get(e);
|
|
2220
|
+
if (U && (U.isEvaluate || U.isForceEvaluation()) && !n.isEvaluate && !n.isForceEvaluation())
|
|
2221
|
+
return this.skipMutationAttributes = !0, M.enqueue(() => {
|
|
2166
2222
|
}).finally(() => {
|
|
2167
2223
|
this.skipMutationAttributes = !1;
|
|
2168
2224
|
});
|
|
@@ -2173,9 +2229,9 @@ const V = class V extends w {
|
|
|
2173
2229
|
element: a,
|
|
2174
2230
|
rawName: e,
|
|
2175
2231
|
template: r
|
|
2176
|
-
}), c = n.isEvaluate || n.isRawEvaluate, d = e === t && V.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), f = n.isSingleExpression(),
|
|
2177
|
-
return !y && !
|
|
2178
|
-
y && a.setAttribute(e, r),
|
|
2232
|
+
}), c = n.isEvaluate || n.isRawEvaluate, d = e === t && V.BOOLEAN_ATTRIBUTES.has(t.toLowerCase()), f = n.isSingleExpression(), g = j.joinEvaluateResults(o.results), b = o.results.length === 1 ? o.results[0] : g, S = !n.isForceEvaluation() && (t !== e || d || f ? o.hasUnresolvedReference || b === null || b === void 0 || b === !1 : c && g === ""), m = n.isForceEvaluation() ? r : f ? b : g, v = i && n.isEvaluate && t === "value" && (a instanceof HTMLInputElement && this.INPUT_EVENT_TYPES.includes(a.type) || a instanceof HTMLTextAreaElement || a instanceof HTMLSelectElement), E = S || m === null || m === !1 ? null : String(m), y = e !== t && a.getAttribute(e) !== r, F = E === null ? a.hasAttribute(t) : a.getAttribute(t) !== E, N = v && E !== null && a.value !== E;
|
|
2233
|
+
return !y && !F && !N ? (v && E !== null && (this.value = E), Promise.resolve()) : (this.skipMutationAttributes = !0, M.enqueue(() => {
|
|
2234
|
+
y && a.setAttribute(e, r), E === null ? a.removeAttribute(t) : (F && a.setAttribute(t, E), v && (this.value = E, N && (a.value = E)));
|
|
2179
2235
|
}).finally(() => {
|
|
2180
2236
|
this.skipMutationAttributes = !1;
|
|
2181
2237
|
}));
|
|
@@ -2191,7 +2247,7 @@ const V = class V extends w {
|
|
|
2191
2247
|
return Promise.resolve();
|
|
2192
2248
|
this.attributeMap.delete(e), this.skipMutationAttributes = !0;
|
|
2193
2249
|
const t = this.getTarget();
|
|
2194
|
-
return
|
|
2250
|
+
return M.enqueue(() => {
|
|
2195
2251
|
t.removeAttribute(e);
|
|
2196
2252
|
}).finally(() => {
|
|
2197
2253
|
this.skipMutationAttributes = !1;
|
|
@@ -2294,13 +2350,13 @@ const V = class V extends w {
|
|
|
2294
2350
|
if (this.skipMutationNodes)
|
|
2295
2351
|
return Promise.resolve();
|
|
2296
2352
|
if (e === this)
|
|
2297
|
-
return
|
|
2353
|
+
return p.error("[Haori]", "Cannot insert element as child of itself"), Promise.reject(new Error("Self-insertion not allowed"));
|
|
2298
2354
|
const i = /* @__PURE__ */ new Set();
|
|
2299
2355
|
let s = this.parent;
|
|
2300
2356
|
for (; s; )
|
|
2301
2357
|
i.add(s), s = s.getParent();
|
|
2302
2358
|
if (i.has(e))
|
|
2303
|
-
return
|
|
2359
|
+
return p.error("[Haori]", "Cannot create circular reference"), Promise.reject(new Error("Circular reference detected"));
|
|
2304
2360
|
const n = e.getParent() === this;
|
|
2305
2361
|
let a = -1, o = -1;
|
|
2306
2362
|
n && (a = this.children.indexOf(e), t !== null && (o = this.children.indexOf(t)));
|
|
@@ -2310,23 +2366,23 @@ const V = class V extends w {
|
|
|
2310
2366
|
if (t === null)
|
|
2311
2367
|
this.children.push(e);
|
|
2312
2368
|
else {
|
|
2313
|
-
let
|
|
2314
|
-
if (n ? a !== -1 && a < o ?
|
|
2315
|
-
const
|
|
2369
|
+
let g;
|
|
2370
|
+
if (n ? a !== -1 && a < o ? g = o - 1 : g = o : g = this.children.indexOf(t), g === -1) {
|
|
2371
|
+
const b = this.resolveInsertionPointFromDom(
|
|
2316
2372
|
t,
|
|
2317
2373
|
!1
|
|
2318
2374
|
);
|
|
2319
|
-
|
|
2375
|
+
b === null ? (p.warn(
|
|
2320
2376
|
"[Haori]",
|
|
2321
2377
|
"Reference child not found in children.",
|
|
2322
2378
|
t
|
|
2323
|
-
), this.children.push(e)) : (this.children.splice(
|
|
2379
|
+
), this.children.push(e)) : (this.children.splice(b.index, 0, e), d = b.referenceNode);
|
|
2324
2380
|
} else
|
|
2325
|
-
this.children.splice(
|
|
2381
|
+
this.children.splice(g, 0, e);
|
|
2326
2382
|
}
|
|
2327
2383
|
e.setParent(this), e.setMounted(this.mounted);
|
|
2328
2384
|
const f = this.skipMutationNodes;
|
|
2329
|
-
return this.skipMutationNodes = !0,
|
|
2385
|
+
return this.skipMutationNodes = !0, M.enqueue(() => {
|
|
2330
2386
|
this.target.insertBefore(e.getTarget(), d);
|
|
2331
2387
|
}).finally(() => {
|
|
2332
2388
|
this.skipMutationNodes = f;
|
|
@@ -2348,7 +2404,7 @@ const V = class V extends w {
|
|
|
2348
2404
|
t,
|
|
2349
2405
|
!0
|
|
2350
2406
|
);
|
|
2351
|
-
return i === null ? (
|
|
2407
|
+
return i === null ? (p.warn(
|
|
2352
2408
|
"[Haori]",
|
|
2353
2409
|
"Reference child not found in children.",
|
|
2354
2410
|
t
|
|
@@ -2460,7 +2516,7 @@ V.BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
2460
2516
|
"reversed",
|
|
2461
2517
|
"selected"
|
|
2462
2518
|
]);
|
|
2463
|
-
let
|
|
2519
|
+
let C = V;
|
|
2464
2520
|
class H extends w {
|
|
2465
2521
|
/**
|
|
2466
2522
|
* テキストフラグメントのコンストラクタ。
|
|
@@ -2513,7 +2569,7 @@ class H extends w {
|
|
|
2513
2569
|
evaluate() {
|
|
2514
2570
|
return this.contents.isRawEvaluate && this.parent === null ? Promise.reject(
|
|
2515
2571
|
new Error("Parent fragment is required for raw evaluation")
|
|
2516
|
-
) :
|
|
2572
|
+
) : M.enqueue(() => {
|
|
2517
2573
|
this.skipMutation = !0;
|
|
2518
2574
|
let e = this.text;
|
|
2519
2575
|
this.contents.isRawEvaluate ? e = this.contents.evaluate(
|
|
@@ -2539,7 +2595,7 @@ class H extends w {
|
|
|
2539
2595
|
});
|
|
2540
2596
|
}
|
|
2541
2597
|
}
|
|
2542
|
-
class
|
|
2598
|
+
class oe extends w {
|
|
2543
2599
|
/**
|
|
2544
2600
|
* コメントフラグメントのコンストラクタ。
|
|
2545
2601
|
* 対象コメントノードの内容を初期化します。
|
|
@@ -2555,7 +2611,7 @@ class ae extends w {
|
|
|
2555
2611
|
* @returns クローンされたフラグメント
|
|
2556
2612
|
*/
|
|
2557
2613
|
clone() {
|
|
2558
|
-
const e = new
|
|
2614
|
+
const e = new oe(this.target.cloneNode(!0));
|
|
2559
2615
|
return e.mounted = !1, e.text = this.text, e;
|
|
2560
2616
|
}
|
|
2561
2617
|
/**
|
|
@@ -2573,14 +2629,14 @@ class ae extends w {
|
|
|
2573
2629
|
* @return 更新のPromise
|
|
2574
2630
|
*/
|
|
2575
2631
|
setContent(e) {
|
|
2576
|
-
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e,
|
|
2632
|
+
return this.skipMutation || this.text === e ? Promise.resolve() : (this.text = e, M.enqueue(() => {
|
|
2577
2633
|
this.skipMutation = !0, this.target.textContent = this.text;
|
|
2578
2634
|
}).finally(() => {
|
|
2579
2635
|
this.skipMutation = !1;
|
|
2580
2636
|
}));
|
|
2581
2637
|
}
|
|
2582
2638
|
}
|
|
2583
|
-
const
|
|
2639
|
+
const _ = class _ {
|
|
2584
2640
|
/**
|
|
2585
2641
|
* コンストラクタ。
|
|
2586
2642
|
*
|
|
@@ -2588,7 +2644,7 @@ const Z = class Z {
|
|
|
2588
2644
|
*/
|
|
2589
2645
|
constructor(e) {
|
|
2590
2646
|
this.contents = [], this.isEvaluate = !1, this.isRawEvaluate = !1, this.value = e;
|
|
2591
|
-
const t = [...e.matchAll(
|
|
2647
|
+
const t = [...e.matchAll(_.PLACEHOLDER_REGEX)];
|
|
2592
2648
|
let r = 0, i = !1, s = !1;
|
|
2593
2649
|
for (const n of t) {
|
|
2594
2650
|
n.index > r && this.contents.push({
|
|
@@ -2639,7 +2695,7 @@ const Z = class Z {
|
|
|
2639
2695
|
*/
|
|
2640
2696
|
checkRawExpressions() {
|
|
2641
2697
|
for (let e = 0; e < this.contents.length; e++)
|
|
2642
|
-
this.contents[e].type === 2 && this.contents.length > 1 && (
|
|
2698
|
+
this.contents[e].type === 2 && this.contents.length > 1 && (p.error(
|
|
2643
2699
|
"[Haori]",
|
|
2644
2700
|
"Raw expressions are not allowed in multi-content expressions."
|
|
2645
2701
|
), this.contents[e].type = 1);
|
|
@@ -2685,8 +2741,8 @@ const Z = class Z {
|
|
|
2685
2741
|
return this.contents.forEach((c) => {
|
|
2686
2742
|
try {
|
|
2687
2743
|
if (r(c)) {
|
|
2688
|
-
const d =
|
|
2689
|
-
() =>
|
|
2744
|
+
const d = X.measure(
|
|
2745
|
+
() => Y.evaluateDetailed(c.text, e)
|
|
2690
2746
|
), f = d.value;
|
|
2691
2747
|
a += d.durationMs, n.push({
|
|
2692
2748
|
expression: c.text,
|
|
@@ -2695,7 +2751,7 @@ const Z = class Z {
|
|
|
2695
2751
|
} else
|
|
2696
2752
|
s.push(c.text);
|
|
2697
2753
|
} catch (d) {
|
|
2698
|
-
|
|
2754
|
+
p.error(
|
|
2699
2755
|
"[Haori]",
|
|
2700
2756
|
`Error evaluating ${i} expression: ${c.text}`,
|
|
2701
2757
|
d
|
|
@@ -2704,16 +2760,16 @@ const Z = class Z {
|
|
|
2704
2760
|
durationMs: 0
|
|
2705
2761
|
}), s.push("");
|
|
2706
2762
|
}
|
|
2707
|
-
}),
|
|
2763
|
+
}), X.record(
|
|
2708
2764
|
t,
|
|
2709
2765
|
n,
|
|
2710
2766
|
a
|
|
2711
2767
|
), { results: s, hasUnresolvedReference: o };
|
|
2712
2768
|
}
|
|
2713
2769
|
};
|
|
2714
|
-
|
|
2715
|
-
let j =
|
|
2716
|
-
const
|
|
2770
|
+
_.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
2771
|
+
let j = _;
|
|
2772
|
+
const ee = class ee extends j {
|
|
2717
2773
|
/**
|
|
2718
2774
|
* コンストラクタ。
|
|
2719
2775
|
*
|
|
@@ -2721,7 +2777,7 @@ const _ = class _ extends j {
|
|
|
2721
2777
|
* @param text 属性値
|
|
2722
2778
|
*/
|
|
2723
2779
|
constructor(e, t) {
|
|
2724
|
-
super(t), this.forceEvaluation =
|
|
2780
|
+
super(t), this.forceEvaluation = ee.FORCE_EVALUATION_ATTRIBUTES.includes(e);
|
|
2725
2781
|
}
|
|
2726
2782
|
/**
|
|
2727
2783
|
* 強制評価フラグを取得します。
|
|
@@ -2758,7 +2814,7 @@ const _ = class _ extends j {
|
|
|
2758
2814
|
(i) => this.forceEvaluation && i.type === 0 || i.type === 1 || i.type === 2,
|
|
2759
2815
|
"attribute"
|
|
2760
2816
|
);
|
|
2761
|
-
return this.forceEvaluation && r.results.length > 1 ? (
|
|
2817
|
+
return this.forceEvaluation && r.results.length > 1 ? (p.error(
|
|
2762
2818
|
"[Haori]",
|
|
2763
2819
|
"each or if expressions must have a single content.",
|
|
2764
2820
|
r.results
|
|
@@ -2768,7 +2824,7 @@ const _ = class _ extends j {
|
|
|
2768
2824
|
}) : r;
|
|
2769
2825
|
}
|
|
2770
2826
|
};
|
|
2771
|
-
|
|
2827
|
+
ee.FORCE_EVALUATION_ATTRIBUTES = [
|
|
2772
2828
|
"data-if",
|
|
2773
2829
|
"hor-if",
|
|
2774
2830
|
"data-each",
|
|
@@ -2776,8 +2832,8 @@ _.FORCE_EVALUATION_ATTRIBUTES = [
|
|
|
2776
2832
|
"data-derive",
|
|
2777
2833
|
"hor-derive"
|
|
2778
2834
|
];
|
|
2779
|
-
let
|
|
2780
|
-
class
|
|
2835
|
+
let Q = ee;
|
|
2836
|
+
class R {
|
|
2781
2837
|
/**
|
|
2782
2838
|
* カスタムイベントを発火します。
|
|
2783
2839
|
*
|
|
@@ -2801,7 +2857,7 @@ class F {
|
|
|
2801
2857
|
* @param version ライブラリバージョン
|
|
2802
2858
|
*/
|
|
2803
2859
|
static ready(e) {
|
|
2804
|
-
|
|
2860
|
+
R.dispatch(document, "ready", { version: e });
|
|
2805
2861
|
}
|
|
2806
2862
|
/**
|
|
2807
2863
|
* renderイベントを発火します。
|
|
@@ -2809,7 +2865,7 @@ class F {
|
|
|
2809
2865
|
* @param target 評価対象要素
|
|
2810
2866
|
*/
|
|
2811
2867
|
static render(e) {
|
|
2812
|
-
|
|
2868
|
+
R.dispatch(e, "render", { target: e });
|
|
2813
2869
|
}
|
|
2814
2870
|
/**
|
|
2815
2871
|
* importstartイベントを発火します。
|
|
@@ -2818,7 +2874,7 @@ class F {
|
|
|
2818
2874
|
* @param url インポート対象URL
|
|
2819
2875
|
*/
|
|
2820
2876
|
static importStart(e, t) {
|
|
2821
|
-
|
|
2877
|
+
R.dispatch(e, "importstart", {
|
|
2822
2878
|
url: t,
|
|
2823
2879
|
startedAt: performance.now()
|
|
2824
2880
|
});
|
|
@@ -2832,7 +2888,7 @@ class F {
|
|
|
2832
2888
|
* @param startedAt 開始時刻
|
|
2833
2889
|
*/
|
|
2834
2890
|
static importEnd(e, t, r, i) {
|
|
2835
|
-
|
|
2891
|
+
R.dispatch(e, "importend", {
|
|
2836
2892
|
url: t,
|
|
2837
2893
|
bytes: r,
|
|
2838
2894
|
durationMs: performance.now() - i
|
|
@@ -2846,7 +2902,7 @@ class F {
|
|
|
2846
2902
|
* @param error エラー内容
|
|
2847
2903
|
*/
|
|
2848
2904
|
static importError(e, t, r) {
|
|
2849
|
-
|
|
2905
|
+
R.dispatch(e, "importerror", { url: t, error: r });
|
|
2850
2906
|
}
|
|
2851
2907
|
/**
|
|
2852
2908
|
* bindchangeイベントを発火します。
|
|
@@ -2862,13 +2918,27 @@ class F {
|
|
|
2862
2918
|
const d = t?.[c], f = r[c];
|
|
2863
2919
|
d !== f && s.push(c);
|
|
2864
2920
|
}
|
|
2865
|
-
|
|
2921
|
+
R.dispatch(e, "bindchange", {
|
|
2866
2922
|
previous: t || {},
|
|
2867
2923
|
next: r,
|
|
2868
2924
|
changedKeys: s,
|
|
2869
2925
|
reason: i
|
|
2870
2926
|
});
|
|
2871
2927
|
}
|
|
2928
|
+
/**
|
|
2929
|
+
* bindcompleteイベントを発火します。
|
|
2930
|
+
*
|
|
2931
|
+
* Procedure(data-*-bind / data-*-bind-arg など)によるバインドと、それに伴う
|
|
2932
|
+
* 対象要素配下の再評価(data-if / data-each 等)が完了したタイミングで発火します。
|
|
2933
|
+
* 外部スクリプトがバインド完了を契機に同期処理を行うために利用できます。
|
|
2934
|
+
*
|
|
2935
|
+
* @param target バインド対象要素
|
|
2936
|
+
* @param bindArg バインド時に使用したネストキー(指定がない場合は null)
|
|
2937
|
+
* @param reason 変更理由
|
|
2938
|
+
*/
|
|
2939
|
+
static bindComplete(e, t = null, r = "other") {
|
|
2940
|
+
R.dispatch(e, "bindcomplete", { bindArg: t, reason: r });
|
|
2941
|
+
}
|
|
2872
2942
|
/**
|
|
2873
2943
|
* eachupdateイベントを発火します。
|
|
2874
2944
|
*
|
|
@@ -2878,7 +2948,7 @@ class F {
|
|
|
2878
2948
|
* @param order 現在の順序
|
|
2879
2949
|
*/
|
|
2880
2950
|
static eachUpdate(e, t, r, i) {
|
|
2881
|
-
|
|
2951
|
+
R.dispatch(e, "eachupdate", {
|
|
2882
2952
|
added: t,
|
|
2883
2953
|
removed: r,
|
|
2884
2954
|
order: i,
|
|
@@ -2894,7 +2964,7 @@ class F {
|
|
|
2894
2964
|
* @param item 行データ
|
|
2895
2965
|
*/
|
|
2896
2966
|
static rowAdd(e, t, r, i) {
|
|
2897
|
-
|
|
2967
|
+
R.dispatch(e, "rowadd", { key: t, index: r, item: i });
|
|
2898
2968
|
}
|
|
2899
2969
|
/**
|
|
2900
2970
|
* rowremoveイベントを発火します。
|
|
@@ -2904,7 +2974,7 @@ class F {
|
|
|
2904
2974
|
* @param index インデックス
|
|
2905
2975
|
*/
|
|
2906
2976
|
static rowRemove(e, t, r) {
|
|
2907
|
-
|
|
2977
|
+
R.dispatch(e, "rowremove", { key: t, index: r });
|
|
2908
2978
|
}
|
|
2909
2979
|
/**
|
|
2910
2980
|
* rowmoveイベントを発火します。
|
|
@@ -2915,7 +2985,7 @@ class F {
|
|
|
2915
2985
|
* @param to 移動後インデックス
|
|
2916
2986
|
*/
|
|
2917
2987
|
static rowMove(e, t, r, i) {
|
|
2918
|
-
|
|
2988
|
+
R.dispatch(e, "rowmove", { key: t, from: r, to: i });
|
|
2919
2989
|
}
|
|
2920
2990
|
/**
|
|
2921
2991
|
* showイベントを発火します。
|
|
@@ -2923,7 +2993,7 @@ class F {
|
|
|
2923
2993
|
* @param target data-if要素
|
|
2924
2994
|
*/
|
|
2925
2995
|
static show(e) {
|
|
2926
|
-
|
|
2996
|
+
R.dispatch(e, "show", { visible: !0 });
|
|
2927
2997
|
}
|
|
2928
2998
|
/**
|
|
2929
2999
|
* hideイベントを発火します。
|
|
@@ -2931,7 +3001,7 @@ class F {
|
|
|
2931
3001
|
* @param target data-if要素
|
|
2932
3002
|
*/
|
|
2933
3003
|
static hide(e) {
|
|
2934
|
-
|
|
3004
|
+
R.dispatch(e, "hide", { visible: !1 });
|
|
2935
3005
|
}
|
|
2936
3006
|
/**
|
|
2937
3007
|
* fetchstartイベントを発火します。
|
|
@@ -2944,7 +3014,7 @@ class F {
|
|
|
2944
3014
|
* @return 戻り値はありません。
|
|
2945
3015
|
*/
|
|
2946
3016
|
static fetchStart(e, t, r, i, s) {
|
|
2947
|
-
|
|
3017
|
+
R.dispatch(e, "fetchstart", {
|
|
2948
3018
|
url: t,
|
|
2949
3019
|
options: r || {},
|
|
2950
3020
|
payload: i,
|
|
@@ -2961,7 +3031,7 @@ class F {
|
|
|
2961
3031
|
* @param startedAt 開始時刻
|
|
2962
3032
|
*/
|
|
2963
3033
|
static fetchEnd(e, t, r, i) {
|
|
2964
|
-
|
|
3034
|
+
R.dispatch(e, "fetchend", {
|
|
2965
3035
|
url: t,
|
|
2966
3036
|
status: r,
|
|
2967
3037
|
durationMs: performance.now() - i
|
|
@@ -2977,7 +3047,7 @@ class F {
|
|
|
2977
3047
|
* @param startedAt 開始時刻(存在する場合)
|
|
2978
3048
|
*/
|
|
2979
3049
|
static fetchError(e, t, r, i, s) {
|
|
2980
|
-
|
|
3050
|
+
R.dispatch(e, "fetcherror", {
|
|
2981
3051
|
url: t,
|
|
2982
3052
|
status: i,
|
|
2983
3053
|
error: r,
|
|
@@ -2997,24 +3067,24 @@ function ie() {
|
|
|
2997
3067
|
const e = globalThis.window?.Haori;
|
|
2998
3068
|
return pe.every(
|
|
2999
3069
|
(r) => typeof e?.[r] == "function"
|
|
3000
|
-
) ? e :
|
|
3070
|
+
) ? e : J;
|
|
3001
3071
|
}
|
|
3002
3072
|
const me = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
3003
|
-
function be(
|
|
3004
|
-
return me.has(
|
|
3073
|
+
function be(T) {
|
|
3074
|
+
return me.has(T.toUpperCase());
|
|
3005
3075
|
}
|
|
3006
|
-
function ve(
|
|
3076
|
+
function ve(T, e) {
|
|
3007
3077
|
for (const [t, r] of Object.entries(e))
|
|
3008
|
-
r !== void 0 && (r === null ?
|
|
3009
|
-
|
|
3010
|
-
}) : typeof r == "object" || typeof r == "function" ?
|
|
3078
|
+
r !== void 0 && (r === null ? T.append(t, "") : Array.isArray(r) ? r.forEach((i) => {
|
|
3079
|
+
T.append(t, String(i));
|
|
3080
|
+
}) : typeof r == "object" || typeof r == "function" ? T.append(t, JSON.stringify(r)) : T.append(t, String(r)));
|
|
3011
3081
|
}
|
|
3012
|
-
function ye(
|
|
3013
|
-
const t = new URL(
|
|
3082
|
+
function ye(T, e) {
|
|
3083
|
+
const t = new URL(T, window.location.href), r = new URLSearchParams(t.search);
|
|
3014
3084
|
return ve(r, e), t.search = r.toString(), t.toString();
|
|
3015
3085
|
}
|
|
3016
|
-
function Ee(
|
|
3017
|
-
return
|
|
3086
|
+
function Ee(T) {
|
|
3087
|
+
return T == null ? null : typeof T == "string" ? T : T instanceof URLSearchParams ? T.toString() : T instanceof FormData ? Array.from(T.entries()).map(([e, t]) => t instanceof File ? [
|
|
3018
3088
|
e,
|
|
3019
3089
|
{
|
|
3020
3090
|
type: "file",
|
|
@@ -3022,16 +3092,16 @@ function Ee(D) {
|
|
|
3022
3092
|
size: t.size,
|
|
3023
3093
|
mimeType: t.type
|
|
3024
3094
|
}
|
|
3025
|
-
] : [e, String(t)]) : String(
|
|
3095
|
+
] : [e, String(t)]) : String(T);
|
|
3026
3096
|
}
|
|
3027
|
-
function Ae(
|
|
3097
|
+
function Ae(T, e) {
|
|
3028
3098
|
const t = new Headers(
|
|
3029
3099
|
e.headers || void 0
|
|
3030
3100
|
), r = Array.from(t.entries()).sort(
|
|
3031
3101
|
([i], [s]) => i.localeCompare(s)
|
|
3032
3102
|
);
|
|
3033
3103
|
return JSON.stringify({
|
|
3034
|
-
url:
|
|
3104
|
+
url: T,
|
|
3035
3105
|
method: String(e.method || "GET").toUpperCase(),
|
|
3036
3106
|
headers: r,
|
|
3037
3107
|
body: Ee(e.body || null)
|
|
@@ -3070,7 +3140,7 @@ const h = class h {
|
|
|
3070
3140
|
return { value: e.replace(
|
|
3071
3141
|
h.DATA_PLACEHOLDER_REGEX,
|
|
3072
3142
|
(s, n, a) => {
|
|
3073
|
-
const o =
|
|
3143
|
+
const o = Y.evaluateDetailed(
|
|
3074
3144
|
n ?? a ?? "",
|
|
3075
3145
|
t
|
|
3076
3146
|
);
|
|
@@ -3150,7 +3220,7 @@ const h = class h {
|
|
|
3150
3220
|
return { value: e.replace(
|
|
3151
3221
|
h.DATA_PLACEHOLDER_REGEX,
|
|
3152
3222
|
(s, n, a, o) => {
|
|
3153
|
-
const c =
|
|
3223
|
+
const c = Y.evaluateDetailed(
|
|
3154
3224
|
n ?? a ?? "",
|
|
3155
3225
|
t
|
|
3156
3226
|
);
|
|
@@ -3187,7 +3257,7 @@ const h = class h {
|
|
|
3187
3257
|
const a = r.trim();
|
|
3188
3258
|
if (h.SINGLE_PLACEHOLDER_REGEX.test(a))
|
|
3189
3259
|
return {
|
|
3190
|
-
value:
|
|
3260
|
+
value: P.parseDataBind(s),
|
|
3191
3261
|
hasUnresolvedReference: n
|
|
3192
3262
|
};
|
|
3193
3263
|
if (a.startsWith("{") || a.startsWith("[")) {
|
|
@@ -3196,7 +3266,7 @@ const h = class h {
|
|
|
3196
3266
|
e.getBindingData()
|
|
3197
3267
|
);
|
|
3198
3268
|
return {
|
|
3199
|
-
value:
|
|
3269
|
+
value: P.parseDataBind(c.value),
|
|
3200
3270
|
hasUnresolvedReference: n || c.hasUnresolvedReference
|
|
3201
3271
|
};
|
|
3202
3272
|
}
|
|
@@ -3205,7 +3275,7 @@ const h = class h {
|
|
|
3205
3275
|
e.getBindingData()
|
|
3206
3276
|
);
|
|
3207
3277
|
return {
|
|
3208
|
-
value:
|
|
3278
|
+
value: P.parseDataBind(o.value),
|
|
3209
3279
|
hasUnresolvedReference: n || o.hasUnresolvedReference
|
|
3210
3280
|
};
|
|
3211
3281
|
}
|
|
@@ -3223,22 +3293,22 @@ const h = class h {
|
|
|
3223
3293
|
if (t) {
|
|
3224
3294
|
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
3295
|
`)), e.hasAttribute(h.attrName(t, "data")) && (r.dataAttrName = h.attrName(t, "data")), e.hasAttribute(h.attrName(t, "form"))) {
|
|
3226
|
-
const
|
|
3296
|
+
const m = e.getRawAttribute(
|
|
3227
3297
|
h.attrName(t, "form")
|
|
3228
3298
|
);
|
|
3229
|
-
if (
|
|
3230
|
-
const
|
|
3231
|
-
|
|
3232
|
-
w.get(
|
|
3233
|
-
) :
|
|
3299
|
+
if (m) {
|
|
3300
|
+
const v = document.body.querySelector(m);
|
|
3301
|
+
v !== null ? r.formFragment = A.getFormFragment(
|
|
3302
|
+
w.get(v)
|
|
3303
|
+
) : p.error(
|
|
3234
3304
|
"Haori",
|
|
3235
|
-
`Form element not found: ${
|
|
3305
|
+
`Form element not found: ${m} (${h.attrName(t, "form")})`
|
|
3236
3306
|
);
|
|
3237
3307
|
} else
|
|
3238
|
-
r.formFragment =
|
|
3239
|
-
} else t === "change" && (r.formFragment =
|
|
3308
|
+
r.formFragment = A.getFormFragment(e);
|
|
3309
|
+
} else t === "change" && (r.formFragment = A.getFormFragment(e));
|
|
3240
3310
|
if (e.hasAttribute(`${l.prefix}${t}-before-run`)) {
|
|
3241
|
-
const
|
|
3311
|
+
const m = e.getRawAttribute(
|
|
3242
3312
|
`${l.prefix}${t}-before-run`
|
|
3243
3313
|
);
|
|
3244
3314
|
try {
|
|
@@ -3247,75 +3317,75 @@ const h = class h {
|
|
|
3247
3317
|
"fetchOptions",
|
|
3248
3318
|
`
|
|
3249
3319
|
"use strict";
|
|
3250
|
-
${
|
|
3320
|
+
${m}
|
|
3251
3321
|
`
|
|
3252
3322
|
);
|
|
3253
|
-
} catch (
|
|
3254
|
-
|
|
3323
|
+
} catch (v) {
|
|
3324
|
+
p.error("Haori", `Invalid before script: ${v}`);
|
|
3255
3325
|
}
|
|
3256
3326
|
}
|
|
3257
3327
|
}
|
|
3258
3328
|
const i = h.attrName(t, "fetch"), s = e.hasAttribute(i);
|
|
3259
3329
|
if (s) {
|
|
3260
|
-
const
|
|
3261
|
-
|
|
3330
|
+
const m = e.getAttributeEvaluation(i);
|
|
3331
|
+
m && (r.fetchHasUnresolvedReference = m.hasUnresolvedReference, r.fetchUrl = m.hasUnresolvedReference ? null : m.value);
|
|
3262
3332
|
}
|
|
3263
3333
|
const n = {};
|
|
3264
3334
|
if (t) {
|
|
3265
|
-
const
|
|
3266
|
-
if (e.hasAttribute(
|
|
3267
|
-
const
|
|
3268
|
-
|
|
3335
|
+
const m = h.attrName(t, "fetch-method");
|
|
3336
|
+
if (e.hasAttribute(m)) {
|
|
3337
|
+
const v = e.getAttributeEvaluation(m);
|
|
3338
|
+
v?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : n.method = v?.value;
|
|
3269
3339
|
}
|
|
3270
3340
|
} else {
|
|
3271
|
-
const
|
|
3272
|
-
if (e.hasAttribute(
|
|
3273
|
-
const
|
|
3274
|
-
|
|
3341
|
+
const m = h.attrName(null, "method", !0);
|
|
3342
|
+
if (e.hasAttribute(m)) {
|
|
3343
|
+
const v = e.getAttributeEvaluation(
|
|
3344
|
+
m
|
|
3275
3345
|
);
|
|
3276
|
-
|
|
3346
|
+
v?.hasUnresolvedReference ? r.fetchHasUnresolvedReference = !0 : n.method = v?.value;
|
|
3277
3347
|
}
|
|
3278
3348
|
}
|
|
3279
3349
|
if (t) {
|
|
3280
|
-
const
|
|
3281
|
-
if (e.hasAttribute(
|
|
3282
|
-
const
|
|
3283
|
-
|
|
3350
|
+
const m = h.attrName(t, "fetch-headers");
|
|
3351
|
+
if (e.hasAttribute(m)) {
|
|
3352
|
+
const v = e.getRawAttribute(
|
|
3353
|
+
m
|
|
3284
3354
|
);
|
|
3285
3355
|
try {
|
|
3286
|
-
n.headers =
|
|
3287
|
-
} catch (
|
|
3288
|
-
|
|
3356
|
+
n.headers = P.parseDataBind(v);
|
|
3357
|
+
} catch (E) {
|
|
3358
|
+
p.error("Haori", `Invalid fetch headers: ${E}`);
|
|
3289
3359
|
}
|
|
3290
3360
|
}
|
|
3291
3361
|
} else {
|
|
3292
|
-
const
|
|
3362
|
+
const m = h.attrName(
|
|
3293
3363
|
null,
|
|
3294
3364
|
"headers",
|
|
3295
3365
|
!0
|
|
3296
3366
|
);
|
|
3297
|
-
if (e.hasAttribute(
|
|
3298
|
-
const
|
|
3299
|
-
|
|
3367
|
+
if (e.hasAttribute(m)) {
|
|
3368
|
+
const v = e.getRawAttribute(
|
|
3369
|
+
m
|
|
3300
3370
|
);
|
|
3301
3371
|
try {
|
|
3302
|
-
n.headers =
|
|
3303
|
-
} catch (
|
|
3304
|
-
|
|
3372
|
+
n.headers = P.parseDataBind(v);
|
|
3373
|
+
} catch (E) {
|
|
3374
|
+
p.error("Haori", `Invalid fetch headers: ${E}`);
|
|
3305
3375
|
}
|
|
3306
3376
|
}
|
|
3307
3377
|
}
|
|
3308
3378
|
if (t) {
|
|
3309
|
-
const
|
|
3310
|
-
if (e.hasAttribute(
|
|
3311
|
-
const
|
|
3312
|
-
|
|
3379
|
+
const m = h.attrName(t, "fetch-content-type");
|
|
3380
|
+
if (e.hasAttribute(m)) {
|
|
3381
|
+
const v = e.getAttributeEvaluation(m);
|
|
3382
|
+
v?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), n.headers = {
|
|
3313
3383
|
...n.headers,
|
|
3314
|
-
"Content-Type":
|
|
3384
|
+
"Content-Type": v?.value
|
|
3315
3385
|
};
|
|
3316
3386
|
} else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
3317
|
-
let
|
|
3318
|
-
n.headers && typeof n.headers == "object" && (
|
|
3387
|
+
let v = !1;
|
|
3388
|
+
n.headers && typeof n.headers == "object" && (v = "Content-Type" in n.headers), v || (n.headers = {
|
|
3319
3389
|
...n.headers,
|
|
3320
3390
|
"Content-Type": "application/json"
|
|
3321
3391
|
});
|
|
@@ -3324,20 +3394,20 @@ ${p}
|
|
|
3324
3394
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
3325
3395
|
});
|
|
3326
3396
|
} else {
|
|
3327
|
-
const
|
|
3397
|
+
const m = h.attrName(
|
|
3328
3398
|
null,
|
|
3329
3399
|
"content-type",
|
|
3330
3400
|
!0
|
|
3331
3401
|
);
|
|
3332
|
-
if (e.hasAttribute(
|
|
3333
|
-
const
|
|
3334
|
-
|
|
3402
|
+
if (e.hasAttribute(m)) {
|
|
3403
|
+
const v = e.getAttributeEvaluation(m);
|
|
3404
|
+
v?.hasUnresolvedReference && (r.fetchHasUnresolvedReference = !0), n.headers = {
|
|
3335
3405
|
...n.headers,
|
|
3336
|
-
"Content-Type":
|
|
3406
|
+
"Content-Type": v?.value
|
|
3337
3407
|
};
|
|
3338
3408
|
} else if (n.method && n.method !== "GET" && n.method !== "HEAD" && n.method !== "OPTIONS") {
|
|
3339
|
-
let
|
|
3340
|
-
n.headers && typeof n.headers == "object" && (
|
|
3409
|
+
let v = !1;
|
|
3410
|
+
n.headers && typeof n.headers == "object" && (v = "Content-Type" in n.headers), v || (n.headers = {
|
|
3341
3411
|
...n.headers,
|
|
3342
3412
|
"Content-Type": "application/json"
|
|
3343
3413
|
});
|
|
@@ -3349,15 +3419,15 @@ ${p}
|
|
|
3349
3419
|
Object.keys(n).length > 0 && (r.fetchOptions = n);
|
|
3350
3420
|
const a = t ? h.attrName(t, "bind") : h.attrName(null, "bind", !0);
|
|
3351
3421
|
if (e.hasAttribute(a)) {
|
|
3352
|
-
const
|
|
3353
|
-
if (
|
|
3354
|
-
const
|
|
3355
|
-
|
|
3356
|
-
const
|
|
3357
|
-
|
|
3358
|
-
})) :
|
|
3422
|
+
const m = e.getRawAttribute(a);
|
|
3423
|
+
if (m) {
|
|
3424
|
+
const v = document.body.querySelectorAll(m);
|
|
3425
|
+
v.length > 0 ? (r.bindFragments = [], v.forEach((E) => {
|
|
3426
|
+
const y = w.get(E);
|
|
3427
|
+
y && r.bindFragments.push(y);
|
|
3428
|
+
})) : p.error(
|
|
3359
3429
|
"Haori",
|
|
3360
|
-
`Bind element not found: ${
|
|
3430
|
+
`Bind element not found: ${m} (${a})`
|
|
3361
3431
|
);
|
|
3362
3432
|
}
|
|
3363
3433
|
}
|
|
@@ -3375,43 +3445,45 @@ ${p}
|
|
|
3375
3445
|
) : e.hasAttribute(d) && (r.bindArg = e.getRawAttribute(d));
|
|
3376
3446
|
const f = t ? h.attrName(t, "bind-params") : h.attrName(null, "bind-params", !0);
|
|
3377
3447
|
if (e.hasAttribute(f)) {
|
|
3378
|
-
const
|
|
3379
|
-
r.bindParams =
|
|
3448
|
+
const m = e.getRawAttribute(f);
|
|
3449
|
+
r.bindParams = m.split("&").map((v) => v.trim());
|
|
3380
3450
|
}
|
|
3381
|
-
const
|
|
3382
|
-
if (e.hasAttribute(
|
|
3383
|
-
const
|
|
3384
|
-
r.bindAppendParams =
|
|
3451
|
+
const g = t ? h.attrName(t, "bind-append") : h.attrName(null, "bind-append", !0);
|
|
3452
|
+
if (e.hasAttribute(g)) {
|
|
3453
|
+
const m = e.getRawAttribute(g);
|
|
3454
|
+
r.bindAppendParams = m.split("&").map((v) => v.trim()).filter(Boolean);
|
|
3385
3455
|
}
|
|
3386
|
-
const
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3456
|
+
const b = t ? h.attrName(t, "bind-merge") : h.attrName(null, "bind-merge", !0);
|
|
3457
|
+
e.hasAttribute(b) && (r.bindMerge = !0);
|
|
3458
|
+
const S = t ? h.attrName(t, "copy-params") : null;
|
|
3459
|
+
if (S && e.hasAttribute(S)) {
|
|
3460
|
+
const m = e.getRawAttribute(S);
|
|
3461
|
+
r.copyParams = m.split("&").map((v) => v.trim()).filter(Boolean);
|
|
3390
3462
|
}
|
|
3391
3463
|
if (t) {
|
|
3392
3464
|
if (e.hasAttribute(h.attrName(t, "adjust"))) {
|
|
3393
|
-
const
|
|
3465
|
+
const E = e.getRawAttribute(
|
|
3394
3466
|
h.attrName(t, "adjust")
|
|
3395
3467
|
);
|
|
3396
|
-
if (
|
|
3397
|
-
const
|
|
3398
|
-
|
|
3399
|
-
const
|
|
3400
|
-
|
|
3401
|
-
})) :
|
|
3468
|
+
if (E) {
|
|
3469
|
+
const y = document.body.querySelectorAll(E);
|
|
3470
|
+
y.length > 0 ? (r.adjustFragments = [], y.forEach((F) => {
|
|
3471
|
+
const N = w.get(F);
|
|
3472
|
+
N && r.adjustFragments.push(N);
|
|
3473
|
+
})) : p.error(
|
|
3402
3474
|
"Haori",
|
|
3403
|
-
`Adjust element not found: ${
|
|
3475
|
+
`Adjust element not found: ${E} (${h.attrName(t, "adjust")})`
|
|
3404
3476
|
);
|
|
3405
3477
|
}
|
|
3406
3478
|
if (e.hasAttribute(h.attrName(t, "adjust-value"))) {
|
|
3407
|
-
const
|
|
3479
|
+
const y = e.getRawAttribute(
|
|
3408
3480
|
h.attrName(t, "adjust-value")
|
|
3409
|
-
),
|
|
3410
|
-
isNaN(
|
|
3481
|
+
), F = Number(y);
|
|
3482
|
+
isNaN(F) || (r.adjustValue = F);
|
|
3411
3483
|
}
|
|
3412
3484
|
}
|
|
3413
3485
|
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(`${l.prefix}${t}-after-run`)) {
|
|
3414
|
-
const
|
|
3486
|
+
const E = e.getRawAttribute(
|
|
3415
3487
|
`${l.prefix}${t}-after-run`
|
|
3416
3488
|
);
|
|
3417
3489
|
try {
|
|
@@ -3419,11 +3491,11 @@ ${p}
|
|
|
3419
3491
|
"response",
|
|
3420
3492
|
`
|
|
3421
3493
|
"use strict";
|
|
3422
|
-
${
|
|
3494
|
+
${E}
|
|
3423
3495
|
`
|
|
3424
3496
|
);
|
|
3425
|
-
} catch (
|
|
3426
|
-
|
|
3497
|
+
} catch (y) {
|
|
3498
|
+
p.error("Haori", `Invalid after script: ${y}`);
|
|
3427
3499
|
}
|
|
3428
3500
|
}
|
|
3429
3501
|
if (e.hasAttribute(h.attrName(t, "dialog")) && (r.dialogMessage = e.getAttribute(h.attrName(t, "dialog")).replace(/\\n/g, `
|
|
@@ -3431,10 +3503,10 @@ ${S}
|
|
|
3431
3503
|
r.toastMessage = e.getAttribute(
|
|
3432
3504
|
h.attrName(t, "toast")
|
|
3433
3505
|
);
|
|
3434
|
-
const
|
|
3506
|
+
const E = e.getRawAttribute(
|
|
3435
3507
|
h.attrName(t, "toast-level")
|
|
3436
|
-
),
|
|
3437
|
-
r.toastLevel =
|
|
3508
|
+
), F = ["info", "warning", "error", "success"].includes(E);
|
|
3509
|
+
r.toastLevel = F ? E : null;
|
|
3438
3510
|
}
|
|
3439
3511
|
if (e.hasAttribute(h.attrName(t, "redirect")) && (r.redirectUrl = e.getAttribute(
|
|
3440
3512
|
h.attrName(t, "redirect")
|
|
@@ -3443,19 +3515,19 @@ ${S}
|
|
|
3443
3515
|
)), e.hasAttribute(h.attrName(t, "history")) && (r.historyUrl = e.getAttribute(
|
|
3444
3516
|
h.attrName(t, "history")
|
|
3445
3517
|
)), e.hasAttribute(h.attrName(t, "history-data")) && (r.historyDataAttrName = h.attrName(t, "history-data")), e.hasAttribute(h.attrName(t, "history-form"))) {
|
|
3446
|
-
const
|
|
3518
|
+
const E = e.getRawAttribute(
|
|
3447
3519
|
h.attrName(t, "history-form")
|
|
3448
3520
|
);
|
|
3449
|
-
if (
|
|
3450
|
-
const
|
|
3451
|
-
|
|
3452
|
-
w.get(
|
|
3453
|
-
) :
|
|
3521
|
+
if (E) {
|
|
3522
|
+
const y = document.body.querySelector(E);
|
|
3523
|
+
y !== null ? r.historyFormFragment = A.getFormFragment(
|
|
3524
|
+
w.get(y)
|
|
3525
|
+
) : p.error(
|
|
3454
3526
|
"Haori",
|
|
3455
|
-
`Form element not found: ${
|
|
3527
|
+
`Form element not found: ${E} (${h.attrName(t, "history-form")})`
|
|
3456
3528
|
);
|
|
3457
3529
|
} else
|
|
3458
|
-
r.historyFormFragment =
|
|
3530
|
+
r.historyFormFragment = A.getFormFragment(e);
|
|
3459
3531
|
}
|
|
3460
3532
|
[
|
|
3461
3533
|
"reset-before",
|
|
@@ -3465,75 +3537,75 @@ ${S}
|
|
|
3465
3537
|
"copy",
|
|
3466
3538
|
"open",
|
|
3467
3539
|
"close"
|
|
3468
|
-
].forEach((
|
|
3469
|
-
const
|
|
3470
|
-
if (!e.hasAttribute(
|
|
3540
|
+
].forEach((E) => {
|
|
3541
|
+
const y = h.attrName(t, E);
|
|
3542
|
+
if (!e.hasAttribute(y))
|
|
3471
3543
|
return;
|
|
3472
|
-
const
|
|
3473
|
-
if (
|
|
3474
|
-
const
|
|
3475
|
-
|
|
3476
|
-
}),
|
|
3477
|
-
switch (
|
|
3544
|
+
const F = e.getRawAttribute(y), N = [];
|
|
3545
|
+
if (F ? (document.body.querySelectorAll(F).forEach((B) => {
|
|
3546
|
+
const K = w.get(B);
|
|
3547
|
+
K && N.push(K);
|
|
3548
|
+
}), N.length === 0 && p.error("Haori", `Element not found: ${F} (${y})`)) : N.push(e), N.length > 0)
|
|
3549
|
+
switch (E) {
|
|
3478
3550
|
case "reset-before":
|
|
3479
|
-
r.resetBeforeFragments =
|
|
3551
|
+
r.resetBeforeFragments = N;
|
|
3480
3552
|
break;
|
|
3481
3553
|
case "reset":
|
|
3482
|
-
r.resetFragments =
|
|
3554
|
+
r.resetFragments = N;
|
|
3483
3555
|
break;
|
|
3484
3556
|
case "refetch":
|
|
3485
|
-
r.refetchFragments =
|
|
3557
|
+
r.refetchFragments = N;
|
|
3486
3558
|
break;
|
|
3487
3559
|
case "click":
|
|
3488
|
-
r.clickFragments =
|
|
3560
|
+
r.clickFragments = N;
|
|
3489
3561
|
break;
|
|
3490
3562
|
case "copy":
|
|
3491
|
-
r.copyFragments =
|
|
3563
|
+
r.copyFragments = N;
|
|
3492
3564
|
break;
|
|
3493
3565
|
case "open":
|
|
3494
|
-
r.openFragments =
|
|
3566
|
+
r.openFragments = N;
|
|
3495
3567
|
break;
|
|
3496
3568
|
case "close":
|
|
3497
|
-
r.closeFragments =
|
|
3569
|
+
r.closeFragments = N;
|
|
3498
3570
|
break;
|
|
3499
3571
|
}
|
|
3500
3572
|
});
|
|
3501
|
-
const
|
|
3502
|
-
if (e.hasAttribute(
|
|
3503
|
-
const
|
|
3504
|
-
|
|
3573
|
+
const v = h.attrName(t, "copy-source");
|
|
3574
|
+
if (e.hasAttribute(v)) {
|
|
3575
|
+
const E = e.getRawAttribute(
|
|
3576
|
+
v
|
|
3505
3577
|
);
|
|
3506
|
-
if (
|
|
3507
|
-
const
|
|
3508
|
-
if (
|
|
3509
|
-
const
|
|
3510
|
-
|
|
3578
|
+
if (E) {
|
|
3579
|
+
const y = document.body.querySelector(E);
|
|
3580
|
+
if (y !== null) {
|
|
3581
|
+
const F = w.get(y);
|
|
3582
|
+
F ? r.copySourceFragment = F : p.error(
|
|
3511
3583
|
"Haori",
|
|
3512
|
-
`Element is not managed by Haori: ${
|
|
3584
|
+
`Element is not managed by Haori: ${E} (${v})`
|
|
3513
3585
|
);
|
|
3514
3586
|
} else
|
|
3515
|
-
|
|
3587
|
+
p.error(
|
|
3516
3588
|
"Haori",
|
|
3517
|
-
`Element not found: ${
|
|
3589
|
+
`Element not found: ${E} (${v})`
|
|
3518
3590
|
);
|
|
3519
3591
|
} else
|
|
3520
3592
|
r.copySourceFragment = e;
|
|
3521
3593
|
}
|
|
3522
3594
|
}
|
|
3523
3595
|
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
|
|
3596
|
+
const m = e.getRawAttribute(
|
|
3525
3597
|
h.attrName(null, "form", !0)
|
|
3526
3598
|
);
|
|
3527
|
-
if (
|
|
3528
|
-
const
|
|
3529
|
-
|
|
3530
|
-
w.get(
|
|
3531
|
-
) :
|
|
3599
|
+
if (m) {
|
|
3600
|
+
const v = document.body.querySelector(m);
|
|
3601
|
+
v !== null ? r.formFragment = A.getFormFragment(
|
|
3602
|
+
w.get(v)
|
|
3603
|
+
) : p.error(
|
|
3532
3604
|
"Haori",
|
|
3533
|
-
`Form element not found: ${
|
|
3605
|
+
`Form element not found: ${m} (${h.attrName(null, "fetch-form", !0)})`
|
|
3534
3606
|
);
|
|
3535
3607
|
} else
|
|
3536
|
-
r.formFragment =
|
|
3608
|
+
r.formFragment = A.getFormFragment(e);
|
|
3537
3609
|
}
|
|
3538
3610
|
return s && (!r.bindFragments || r.bindFragments.length === 0) && (r.bindFragments = [e]), r;
|
|
3539
3611
|
}
|
|
@@ -3598,7 +3670,7 @@ ${S}
|
|
|
3598
3670
|
return !1;
|
|
3599
3671
|
this.options.resetBeforeFragments && this.options.resetBeforeFragments.length > 0 && (await Promise.all(
|
|
3600
3672
|
this.options.resetBeforeFragments.map(
|
|
3601
|
-
(d) =>
|
|
3673
|
+
(d) => A.reset(d)
|
|
3602
3674
|
)
|
|
3603
3675
|
), this.captureHistorySnapshots());
|
|
3604
3676
|
const r = this.prepareFetchRequest(), i = r.payload;
|
|
@@ -3616,48 +3688,48 @@ ${S}
|
|
|
3616
3688
|
}
|
|
3617
3689
|
const a = Object.keys(i).length > 0;
|
|
3618
3690
|
if (s) {
|
|
3619
|
-
const d = { ...n || {} }, f = r.requestedMethod,
|
|
3620
|
-
if (
|
|
3691
|
+
const d = { ...n || {} }, f = r.requestedMethod, g = r.effectiveMethod, b = r.transportMode === "query-get", S = r.queryString;
|
|
3692
|
+
if (b && p.info("Haori demo fetch normalization", {
|
|
3621
3693
|
runtime: l.runtime,
|
|
3622
3694
|
requestedMethod: f,
|
|
3623
|
-
effectiveMethod:
|
|
3695
|
+
effectiveMethod: g,
|
|
3624
3696
|
transportMode: "query-get",
|
|
3625
3697
|
url: s,
|
|
3626
3698
|
payload: a ? i : void 0,
|
|
3627
|
-
queryString:
|
|
3699
|
+
queryString: S
|
|
3628
3700
|
}), this.options.targetFragment && s) {
|
|
3629
|
-
const
|
|
3701
|
+
const m = performance.now(), v = {
|
|
3630
3702
|
runtime: l.runtime,
|
|
3631
3703
|
requestedMethod: f,
|
|
3632
|
-
effectiveMethod:
|
|
3633
|
-
transportMode:
|
|
3634
|
-
...
|
|
3704
|
+
effectiveMethod: g,
|
|
3705
|
+
transportMode: b ? "query-get" : "http",
|
|
3706
|
+
...b ? { queryString: S } : {}
|
|
3635
3707
|
};
|
|
3636
|
-
return
|
|
3708
|
+
return R.fetchStart(
|
|
3637
3709
|
this.options.targetFragment.getTarget(),
|
|
3638
3710
|
s,
|
|
3639
3711
|
d,
|
|
3640
3712
|
a ? i : void 0,
|
|
3641
|
-
|
|
3642
|
-
), fetch(s, d).then((
|
|
3643
|
-
|
|
3713
|
+
v
|
|
3714
|
+
), fetch(s, d).then((E) => this.handleFetchResult(
|
|
3715
|
+
E,
|
|
3644
3716
|
s || void 0,
|
|
3645
|
-
|
|
3646
|
-
)).catch((
|
|
3647
|
-
throw s &&
|
|
3717
|
+
m
|
|
3718
|
+
)).catch((E) => {
|
|
3719
|
+
throw s && R.fetchError(
|
|
3648
3720
|
this.options.targetFragment.getTarget(),
|
|
3649
3721
|
s,
|
|
3650
|
-
|
|
3651
|
-
),
|
|
3722
|
+
E
|
|
3723
|
+
), E;
|
|
3652
3724
|
});
|
|
3653
3725
|
}
|
|
3654
|
-
return fetch(s, d).then((
|
|
3726
|
+
return fetch(s, d).then((m) => this.handleFetchResult(m, s || void 0));
|
|
3655
3727
|
}
|
|
3656
3728
|
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(
|
|
3729
|
+
const d = this.options.formFragment, f = d.getTarget(), g = /* @__PURE__ */ new Set();
|
|
3730
|
+
e && e.appliedDisabledAttribute && this.options.targetFragment && g.add(this.options.targetFragment), f.setAttribute(`${l.prefix}bind`, JSON.stringify(i));
|
|
3731
|
+
const b = d.getBindingData();
|
|
3732
|
+
Object.assign(b, i), await P.setBindingData(f, b, g);
|
|
3661
3733
|
}
|
|
3662
3734
|
const o = a ? i : {}, c = new Response(JSON.stringify(o), {
|
|
3663
3735
|
headers: { "Content-Type": "application/json" }
|
|
@@ -3676,10 +3748,15 @@ ${S}
|
|
|
3676
3748
|
if (this.eventType !== "click" || !this.options.targetFragment)
|
|
3677
3749
|
return null;
|
|
3678
3750
|
const t = this.options.targetFragment.getTarget();
|
|
3679
|
-
|
|
3751
|
+
if (h.RUNNING_CLICK_TARGETS.has(t) || t.matches(":disabled") || t.hasAttribute("disabled") || t.hasAttribute(re))
|
|
3752
|
+
return !1;
|
|
3753
|
+
const r = t.hasAttribute(
|
|
3754
|
+
`${l.prefix}click-no-disabled`
|
|
3755
|
+
);
|
|
3756
|
+
return h.RUNNING_CLICK_TARGETS.add(t), t.setAttribute(re, ""), r || t.setAttribute("disabled", ""), {
|
|
3680
3757
|
target: t,
|
|
3681
|
-
appliedDisabledAttribute: !
|
|
3682
|
-
}
|
|
3758
|
+
appliedDisabledAttribute: !r
|
|
3759
|
+
};
|
|
3683
3760
|
}
|
|
3684
3761
|
/**
|
|
3685
3762
|
* 取得済みの実行ロックを解放します。
|
|
@@ -3688,7 +3765,7 @@ ${S}
|
|
|
3688
3765
|
* @returns 戻り値はありません。
|
|
3689
3766
|
*/
|
|
3690
3767
|
releaseExecutionLock(e) {
|
|
3691
|
-
e && (h.RUNNING_CLICK_TARGETS.delete(e.target), e.appliedDisabledAttribute &&
|
|
3768
|
+
e && (h.RUNNING_CLICK_TARGETS.delete(e.target), e.target.removeAttribute(re), e.appliedDisabledAttribute && e.target.removeAttribute("disabled"));
|
|
3692
3769
|
}
|
|
3693
3770
|
/**
|
|
3694
3771
|
* フェッチ後の処理を実行します。
|
|
@@ -3696,14 +3773,14 @@ ${S}
|
|
|
3696
3773
|
async handleFetchResult(e, t, r) {
|
|
3697
3774
|
const i = ie();
|
|
3698
3775
|
if (!e.ok)
|
|
3699
|
-
return this.options.targetFragment && t &&
|
|
3776
|
+
return this.options.targetFragment && t && R.fetchError(
|
|
3700
3777
|
this.options.targetFragment.getTarget(),
|
|
3701
3778
|
t,
|
|
3702
3779
|
new Error(`${e.status} ${e.statusText}`),
|
|
3703
3780
|
e.status,
|
|
3704
3781
|
r
|
|
3705
3782
|
), await this.handleFetchError(e), !1;
|
|
3706
|
-
if (this.options.targetFragment && t && r &&
|
|
3783
|
+
if (this.options.targetFragment && t && r && R.fetchEnd(
|
|
3707
3784
|
this.options.targetFragment.getTarget(),
|
|
3708
3785
|
t,
|
|
3709
3786
|
e.status,
|
|
@@ -3718,14 +3795,14 @@ ${S}
|
|
|
3718
3795
|
}
|
|
3719
3796
|
const s = [];
|
|
3720
3797
|
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) =>
|
|
3798
|
+
this.options.resetFragments.map((a) => A.reset(a))
|
|
3722
3799
|
), await this.copy();
|
|
3723
3800
|
const n = [];
|
|
3724
3801
|
if (this.options.refetchFragments && this.options.refetchFragments.length > 0 && this.options.refetchFragments.forEach((a) => {
|
|
3725
3802
|
n.push(new h(a, null).run());
|
|
3726
3803
|
}), this.options.clickFragments && this.options.clickFragments.length > 0)
|
|
3727
3804
|
for (const a of this.options.clickFragments) {
|
|
3728
|
-
await
|
|
3805
|
+
await P.evaluateAll(a);
|
|
3729
3806
|
const o = a.getTarget();
|
|
3730
3807
|
typeof o.click == "function" ? o.click() : o.dispatchEvent(
|
|
3731
3808
|
new MouseEvent("click", { bubbles: !0, cancelable: !0 })
|
|
@@ -3733,10 +3810,10 @@ ${S}
|
|
|
3733
3810
|
}
|
|
3734
3811
|
return this.options.openFragments && this.options.openFragments.length > 0 && this.options.openFragments.forEach((a) => {
|
|
3735
3812
|
const o = a.getTarget();
|
|
3736
|
-
o instanceof HTMLElement ? n.push(i.openDialog(o)) :
|
|
3813
|
+
o instanceof HTMLElement ? n.push(i.openDialog(o)) : p.error("Haori", "Element is not an HTML element: ", o);
|
|
3737
3814
|
}), this.options.closeFragments && this.options.closeFragments.length > 0 && this.options.closeFragments.forEach((a) => {
|
|
3738
3815
|
const o = a.getTarget();
|
|
3739
|
-
o instanceof HTMLElement ? n.push(i.closeDialog(o)) :
|
|
3816
|
+
o instanceof HTMLElement ? n.push(i.closeDialog(o)) : p.error("Haori", "Element is not an HTML element: ", o);
|
|
3740
3817
|
}), await Promise.all(n), this.options.dialogMessage && await i.dialog(this.options.dialogMessage), this.options.toastMessage && await i.toast(
|
|
3741
3818
|
this.options.toastMessage,
|
|
3742
3819
|
this.options.toastLevel ?? "info"
|
|
@@ -3756,12 +3833,12 @@ ${S}
|
|
|
3756
3833
|
const n = e ? this.options.historyUrl : window.location.pathname, a = new URL(n, window.location.href);
|
|
3757
3834
|
if (a.origin !== window.location.origin) {
|
|
3758
3835
|
const c = "history.pushState: cross-origin URL is not allowed: " + a.toString();
|
|
3759
|
-
|
|
3836
|
+
p.error("Haori", c);
|
|
3760
3837
|
return;
|
|
3761
3838
|
}
|
|
3762
3839
|
const o = (c) => {
|
|
3763
3840
|
for (const [d, f] of Object.entries(c))
|
|
3764
|
-
f != null && (Array.isArray(f) ? f.forEach((
|
|
3841
|
+
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
3842
|
};
|
|
3766
3843
|
i && o(t), s && o(r), history.pushState(
|
|
3767
3844
|
{ [ge]: !0 },
|
|
@@ -3769,7 +3846,7 @@ ${S}
|
|
|
3769
3846
|
a.toString()
|
|
3770
3847
|
);
|
|
3771
3848
|
} catch (n) {
|
|
3772
|
-
|
|
3849
|
+
p.error("Haori", `history.pushState failed: ${n}`);
|
|
3773
3850
|
}
|
|
3774
3851
|
}
|
|
3775
3852
|
/**
|
|
@@ -3777,7 +3854,7 @@ ${S}
|
|
|
3777
3854
|
*/
|
|
3778
3855
|
async handleFetchError(e) {
|
|
3779
3856
|
let t = null;
|
|
3780
|
-
this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t =
|
|
3857
|
+
this.options.formFragment ? t = this.options.formFragment : this.options.targetFragment && (t = A.getFormFragment(this.options.targetFragment) || this.options.targetFragment);
|
|
3781
3858
|
const r = async (n) => {
|
|
3782
3859
|
const a = t ? t.getTarget() : document.body;
|
|
3783
3860
|
await ie().addErrorMessage(a, n);
|
|
@@ -3806,7 +3883,7 @@ ${S}
|
|
|
3806
3883
|
if (a.length === 0)
|
|
3807
3884
|
return await r(`${e.status} ${e.statusText}`), i(), !1;
|
|
3808
3885
|
for (const o of a)
|
|
3809
|
-
o.key && t ? await
|
|
3886
|
+
o.key && t ? await A.addErrorMessage(t, o.key, o.message) : await r(o.message);
|
|
3810
3887
|
return i(), !1;
|
|
3811
3888
|
} catch {
|
|
3812
3889
|
}
|
|
@@ -3893,24 +3970,26 @@ ${S}
|
|
|
3893
3970
|
);
|
|
3894
3971
|
} else
|
|
3895
3972
|
n[a] = r;
|
|
3896
|
-
i.push(
|
|
3973
|
+
i.push(P.setBindingData(s.getTarget(), n));
|
|
3897
3974
|
});
|
|
3898
3975
|
else {
|
|
3899
3976
|
if (typeof r == "string")
|
|
3900
|
-
return
|
|
3977
|
+
return p.error("Haori", "string data cannot be bound without a bindArg."), Promise.reject(
|
|
3901
3978
|
new Error("string data cannot be bound without a bindArg.")
|
|
3902
3979
|
);
|
|
3903
3980
|
this.options.bindFragments.forEach((s) => {
|
|
3904
3981
|
const n = this.mergeAppendBindingData(
|
|
3905
3982
|
s,
|
|
3906
3983
|
r
|
|
3907
|
-
);
|
|
3908
|
-
i.push(
|
|
3909
|
-
M.setBindingData(s.getTarget(), n)
|
|
3910
|
-
);
|
|
3984
|
+
), a = this.options.bindMerge ? { ...s.getRawBindingData() ?? {}, ...n } : n;
|
|
3985
|
+
i.push(P.setBindingData(s.getTarget(), a));
|
|
3911
3986
|
});
|
|
3912
3987
|
}
|
|
3913
3988
|
return Promise.all(i).then(() => {
|
|
3989
|
+
const s = this.options.bindArg ?? null;
|
|
3990
|
+
this.options.bindFragments.forEach((n) => {
|
|
3991
|
+
R.bindComplete(n.getTarget(), s);
|
|
3992
|
+
});
|
|
3914
3993
|
});
|
|
3915
3994
|
});
|
|
3916
3995
|
}
|
|
@@ -3938,7 +4017,7 @@ ${S}
|
|
|
3938
4017
|
...i.getBindingData(),
|
|
3939
4018
|
...t
|
|
3940
4019
|
};
|
|
3941
|
-
return
|
|
4020
|
+
return P.setBindingData(i.getTarget(), s);
|
|
3942
4021
|
});
|
|
3943
4022
|
return Promise.all(r).then(() => {
|
|
3944
4023
|
});
|
|
@@ -3947,7 +4026,7 @@ ${S}
|
|
|
3947
4026
|
* copy のコピー元データを取得します。
|
|
3948
4027
|
*/
|
|
3949
4028
|
resolveCopySourceData() {
|
|
3950
|
-
return this.options.copySourceFragment ? this.options.copySourceFragment.getTarget().tagName === "FORM" ?
|
|
4029
|
+
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
4030
|
}
|
|
3952
4031
|
/**
|
|
3953
4032
|
* data 属性とフォーム値を統合した送信データを作成します。
|
|
@@ -3965,7 +4044,7 @@ ${S}
|
|
|
3965
4044
|
buildPayloadResolution() {
|
|
3966
4045
|
const e = {};
|
|
3967
4046
|
let t = !1;
|
|
3968
|
-
if (this.options.formFragment && Object.assign(e,
|
|
4047
|
+
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
4048
|
const r = h.resolveDataAttributeDetailed(
|
|
3970
4049
|
this.options.targetFragment,
|
|
3971
4050
|
this.options.dataAttrName
|
|
@@ -4014,15 +4093,15 @@ ${S}
|
|
|
4014
4093
|
const f = n.get("Content-Type") || "";
|
|
4015
4094
|
if (/multipart\/form-data/i.test(f)) {
|
|
4016
4095
|
n.delete("Content-Type");
|
|
4017
|
-
const
|
|
4018
|
-
for (const [
|
|
4019
|
-
|
|
4020
|
-
s.body =
|
|
4096
|
+
const g = new FormData();
|
|
4097
|
+
for (const [b, S] of Object.entries(t))
|
|
4098
|
+
S == null ? g.append(b, "") : S instanceof Blob ? g.append(b, S) : Array.isArray(S) ? S.forEach((m) => g.append(b, String(m))) : typeof S == "object" ? g.append(b, JSON.stringify(S)) : g.append(b, String(S));
|
|
4099
|
+
s.body = g;
|
|
4021
4100
|
} else if (/application\/x-www-form-urlencoded/i.test(f)) {
|
|
4022
|
-
const
|
|
4023
|
-
for (const [
|
|
4024
|
-
|
|
4025
|
-
s.body =
|
|
4101
|
+
const g = new URLSearchParams();
|
|
4102
|
+
for (const [b, S] of Object.entries(t))
|
|
4103
|
+
S !== void 0 && (S === null ? g.append(b, "") : Array.isArray(S) ? S.forEach((m) => g.append(b, String(m))) : typeof S == "object" ? g.append(b, JSON.stringify(S)) : g.append(b, String(S)));
|
|
4104
|
+
s.body = g;
|
|
4026
4105
|
} else
|
|
4027
4106
|
n.set("Content-Type", "application/json"), s.body = JSON.stringify(t);
|
|
4028
4107
|
}
|
|
@@ -4047,7 +4126,7 @@ ${S}
|
|
|
4047
4126
|
this.options.targetFragment && this.options.historyDataAttrName ? this.historyDataSnapshot = h.resolveDataAttribute(
|
|
4048
4127
|
this.options.targetFragment,
|
|
4049
4128
|
this.options.historyDataAttrName
|
|
4050
|
-
) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ?
|
|
4129
|
+
) : this.historyDataSnapshot = void 0, this.historyFormSnapshot = this.options.historyFormFragment ? A.getValues(this.options.historyFormFragment) : void 0;
|
|
4051
4130
|
}
|
|
4052
4131
|
/**
|
|
4053
4132
|
* history-data の評価値を取得します。
|
|
@@ -4069,7 +4148,7 @@ ${S}
|
|
|
4069
4148
|
if (this.historyFormSnapshot !== void 0)
|
|
4070
4149
|
return this.historyFormSnapshot;
|
|
4071
4150
|
if (this.options.historyFormFragment)
|
|
4072
|
-
return
|
|
4151
|
+
return A.getValues(this.options.historyFormFragment);
|
|
4073
4152
|
}
|
|
4074
4153
|
/**
|
|
4075
4154
|
* copy-params が指定されている場合は include / exclude を考慮して抽出します。
|
|
@@ -4117,11 +4196,11 @@ ${S}
|
|
|
4117
4196
|
*/
|
|
4118
4197
|
getRowFragment() {
|
|
4119
4198
|
if (!this.options.targetFragment)
|
|
4120
|
-
return
|
|
4199
|
+
return p.error("Haori", "Target fragment is not specified for row operation."), null;
|
|
4121
4200
|
const e = this.options.targetFragment.closestByAttribute(
|
|
4122
4201
|
`${l.prefix}row`
|
|
4123
4202
|
);
|
|
4124
|
-
return e || (
|
|
4203
|
+
return e || (p.error("Haori", "Row fragment not found."), null);
|
|
4125
4204
|
}
|
|
4126
4205
|
/**
|
|
4127
4206
|
* 行を追加します。
|
|
@@ -4137,7 +4216,7 @@ ${S}
|
|
|
4137
4216
|
const t = [], r = e.clone();
|
|
4138
4217
|
return t.push(
|
|
4139
4218
|
e.getParent().insertAfter(r, e)
|
|
4140
|
-
), t.push(
|
|
4219
|
+
), t.push(P.evaluateAll(r)), t.push(A.reset(r)), Promise.all(t).then(() => {
|
|
4141
4220
|
});
|
|
4142
4221
|
}
|
|
4143
4222
|
/**
|
|
@@ -4190,7 +4269,7 @@ ${S}
|
|
|
4190
4269
|
}
|
|
4191
4270
|
};
|
|
4192
4271
|
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
|
|
4272
|
+
let q = h;
|
|
4194
4273
|
class Se {
|
|
4195
4274
|
/**
|
|
4196
4275
|
* URLのクエリパラメータを取得します。
|
|
@@ -4204,7 +4283,7 @@ class Se {
|
|
|
4204
4283
|
}), e;
|
|
4205
4284
|
}
|
|
4206
4285
|
}
|
|
4207
|
-
class
|
|
4286
|
+
class Te {
|
|
4208
4287
|
/**
|
|
4209
4288
|
* 指定URLから HTML を取得し、body 内の HTML 文字列を返します。
|
|
4210
4289
|
*
|
|
@@ -4222,23 +4301,23 @@ class De {
|
|
|
4222
4301
|
try {
|
|
4223
4302
|
r = await fetch(e, t);
|
|
4224
4303
|
} catch (s) {
|
|
4225
|
-
throw
|
|
4304
|
+
throw p.error("[Haori]", "Failed to fetch import source:", e, s), new Error(`Failed to fetch: ${e}`);
|
|
4226
4305
|
}
|
|
4227
4306
|
if (!r.ok) {
|
|
4228
4307
|
const s = `${r.status} ${r.statusText}`;
|
|
4229
|
-
throw
|
|
4308
|
+
throw p.error("[Haori]", "Import HTTP error:", e, s), new Error(`Failed to load ${e}: ${s}`);
|
|
4230
4309
|
}
|
|
4231
4310
|
let i;
|
|
4232
4311
|
try {
|
|
4233
4312
|
i = await r.text();
|
|
4234
4313
|
} catch (s) {
|
|
4235
|
-
throw
|
|
4314
|
+
throw p.error("[Haori]", "Failed to read response text:", e, s), new Error(`Failed to read response from: ${e}`);
|
|
4236
4315
|
}
|
|
4237
4316
|
try {
|
|
4238
4317
|
const n = new DOMParser().parseFromString(i, "text/html");
|
|
4239
|
-
return n && n.body ? n.body.innerHTML : (
|
|
4318
|
+
return n && n.body ? n.body.innerHTML : (p.warn("[Haori]", "No body found in imported document:", e), i);
|
|
4240
4319
|
} catch (s) {
|
|
4241
|
-
return
|
|
4320
|
+
return p.error("[Haori]", "Failed to parse imported HTML:", e, s), i;
|
|
4242
4321
|
}
|
|
4243
4322
|
}
|
|
4244
4323
|
}
|
|
@@ -4294,7 +4373,7 @@ const u = class u {
|
|
|
4294
4373
|
*/
|
|
4295
4374
|
static isAliasedAttributeReflection(e, t) {
|
|
4296
4375
|
const r = w.get(e);
|
|
4297
|
-
return r instanceof
|
|
4376
|
+
return r instanceof C ? r.hasAttribute(
|
|
4298
4377
|
`${l.prefix}${u.ATTRIBUTE_ALIAS_SUFFIX}${t}`
|
|
4299
4378
|
) : !1;
|
|
4300
4379
|
}
|
|
@@ -4325,7 +4404,7 @@ const u = class u {
|
|
|
4325
4404
|
static reevaluateChildren(e) {
|
|
4326
4405
|
const t = [];
|
|
4327
4406
|
return e.getChildren().forEach((r) => {
|
|
4328
|
-
r instanceof
|
|
4407
|
+
r instanceof C ? t.push(u.evaluateAll(r)) : r instanceof H && t.push(u.evaluateText(r));
|
|
4329
4408
|
}), Promise.all(t).then(() => {
|
|
4330
4409
|
});
|
|
4331
4410
|
}
|
|
@@ -4375,7 +4454,7 @@ const u = class u {
|
|
|
4375
4454
|
return Promise.resolve();
|
|
4376
4455
|
const r = [];
|
|
4377
4456
|
return e.hasAttribute(`${l.prefix}fetch`) && r.push(u.executeManagedFetch(e)), e.hasAttribute(`${l.prefix}import`) && r.push(u.executeManagedImport(e)), e.getChildren().forEach((i) => {
|
|
4378
|
-
i instanceof
|
|
4457
|
+
i instanceof C && r.push(
|
|
4379
4458
|
u.reevaluateReactiveSpecialAttributes(i, t)
|
|
4380
4459
|
);
|
|
4381
4460
|
}), Promise.all(r).then(() => {
|
|
@@ -4388,8 +4467,8 @@ const u = class u {
|
|
|
4388
4467
|
* @returns 実行完了の Promise
|
|
4389
4468
|
*/
|
|
4390
4469
|
static executeManagedFetch(e) {
|
|
4391
|
-
const t = e.getTarget(), r = u.getReactiveFetchState(t), i =
|
|
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
|
|
4470
|
+
const t = e.getTarget(), r = u.getReactiveFetchState(t), i = q.resolveAutoFetchSignature(e);
|
|
4471
|
+
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
4472
|
}).finally(() => {
|
|
4394
4473
|
if (r.running = !1, r.rerunRequested)
|
|
4395
4474
|
return r.rerunRequested = !1, u.executeManagedFetch(e);
|
|
@@ -4413,22 +4492,22 @@ const u = class u {
|
|
|
4413
4492
|
return Promise.resolve();
|
|
4414
4493
|
r.lastUrl = s, r.running = !0;
|
|
4415
4494
|
const n = performance.now();
|
|
4416
|
-
return t.setAttribute(`${l.prefix}importing`, ""),
|
|
4495
|
+
return t.setAttribute(`${l.prefix}importing`, ""), R.importStart(t, s), Te.load(s).then((a) => {
|
|
4417
4496
|
const o = new TextEncoder().encode(a).length;
|
|
4418
|
-
return
|
|
4497
|
+
return M.enqueue(() => {
|
|
4419
4498
|
t.innerHTML = a;
|
|
4420
4499
|
}).then(() => {
|
|
4421
|
-
if (t.removeAttribute(`${l.prefix}importing`),
|
|
4500
|
+
if (t.removeAttribute(`${l.prefix}importing`), R.importEnd(t, s, o, n), !document.body.hasAttribute("data-haori-ready")) {
|
|
4422
4501
|
const c = [];
|
|
4423
4502
|
return t.childNodes.forEach((d) => {
|
|
4424
4503
|
const f = w.get(d);
|
|
4425
|
-
f instanceof
|
|
4504
|
+
f instanceof C ? c.push(u.scan(f.getTarget())) : f instanceof H && c.push(u.evaluateText(f));
|
|
4426
4505
|
}), Promise.all(c).then(() => {
|
|
4427
4506
|
});
|
|
4428
4507
|
}
|
|
4429
4508
|
});
|
|
4430
4509
|
}).catch((a) => {
|
|
4431
|
-
t.removeAttribute(`${l.prefix}importing`),
|
|
4510
|
+
t.removeAttribute(`${l.prefix}importing`), R.importError(t, s, a), p.error("[Haori]", "Failed to import HTML:", s, a);
|
|
4432
4511
|
}).finally(() => {
|
|
4433
4512
|
if (r.running = !1, r.rerunRequested)
|
|
4434
4513
|
return r.rerunRequested = !1, u.executeManagedImport(e);
|
|
@@ -4471,7 +4550,7 @@ const u = class u {
|
|
|
4471
4550
|
}
|
|
4472
4551
|
const r = [];
|
|
4473
4552
|
return e.getChildren().forEach((i) => {
|
|
4474
|
-
i instanceof
|
|
4553
|
+
i instanceof C ? r.push(u.initializeElementFragment(i, t)) : i instanceof H && r.push(u.evaluateText(i));
|
|
4475
4554
|
}), Promise.all(r).then(() => {
|
|
4476
4555
|
u.refreshDerivedSubtreeSignature(e);
|
|
4477
4556
|
});
|
|
@@ -4543,7 +4622,7 @@ const u = class u {
|
|
|
4543
4622
|
*/
|
|
4544
4623
|
static shouldSkipChildInitialization(e, t) {
|
|
4545
4624
|
const r = e.getAttribute(`${l.prefix}if`);
|
|
4546
|
-
return e.hasAttribute(`${l.prefix}if`) &&
|
|
4625
|
+
return e.hasAttribute(`${l.prefix}if`) && u.isHiddenIfCondition(r) ? !0 : t && e.hasAttribute(`${l.prefix}each`);
|
|
4547
4626
|
}
|
|
4548
4627
|
/**
|
|
4549
4628
|
* エレメントに属性を設定します。
|
|
@@ -4611,8 +4690,8 @@ const u = class u {
|
|
|
4611
4690
|
if (d === null)
|
|
4612
4691
|
a.push(u.setBindingData(e, f));
|
|
4613
4692
|
else {
|
|
4614
|
-
const
|
|
4615
|
-
|
|
4693
|
+
const g = s.getRawBindingData() || {};
|
|
4694
|
+
g[String(d)] = f, a.push(u.setBindingData(e, g));
|
|
4616
4695
|
}
|
|
4617
4696
|
break;
|
|
4618
4697
|
}
|
|
@@ -4643,13 +4722,50 @@ const u = class u {
|
|
|
4643
4722
|
);
|
|
4644
4723
|
if (e.tagName === "FORM") {
|
|
4645
4724
|
const a = i.getAttribute(`${l.prefix}form-arg`), o = a && t[String(a)] && typeof t[String(a)] == "object" && !Array.isArray(t[String(a)]) ? t[String(a)] : a ? {} : t;
|
|
4646
|
-
n = n.then(() =>
|
|
4725
|
+
n = n.then(() => A.syncValues(i, o));
|
|
4647
4726
|
}
|
|
4648
4727
|
return n = n.then(() => u.evaluateAll(i, r)), n = n.then(
|
|
4649
4728
|
() => u.reevaluateReactiveSpecialAttributes(i, r)
|
|
4650
|
-
),
|
|
4729
|
+
), R.bindChange(e, s, t, "manual"), n.then(() => {
|
|
4651
4730
|
});
|
|
4652
4731
|
}
|
|
4732
|
+
/**
|
|
4733
|
+
* 指定要素の式評価で見えるバインディングスコープをダンプします(デバッグ用)。
|
|
4734
|
+
*
|
|
4735
|
+
* 式(`data-if` / `{{...}}` など)の識別子は、その要素を起点に DOM のネストを
|
|
4736
|
+
* たどって解決されます(内側のスコープが外側を上書き)。本メソッドは解決済みの
|
|
4737
|
+
* スコープ(`resolved`)と、各キーがどの要素・どの種類(`bind` または `derive`)に
|
|
4738
|
+
* 由来するか(`sources`)を返します。開発モード時はコンソールにも出力します。
|
|
4739
|
+
*
|
|
4740
|
+
* 注意: フォームの入力値(`name` 属性)は、変更(change)や明示的な同期が行われる
|
|
4741
|
+
* までフォームの binding data に反映されません。したがって初期表示時点では、入力名と
|
|
4742
|
+
* 同名の識別子は**外側のスコープ**にフォールバックして解決されます。
|
|
4743
|
+
*
|
|
4744
|
+
* @param element 対象要素
|
|
4745
|
+
* @return 解決済みスコープと各キーの由来情報
|
|
4746
|
+
*/
|
|
4747
|
+
static dumpScope(e) {
|
|
4748
|
+
const t = w.get(e);
|
|
4749
|
+
if (!t)
|
|
4750
|
+
return { resolved: {}, sources: {} };
|
|
4751
|
+
const r = t.getBindingData(), i = {}, s = (c) => {
|
|
4752
|
+
const d = c.getTarget();
|
|
4753
|
+
return d.id ? `#${d.id}` : d.tagName.toLowerCase();
|
|
4754
|
+
}, n = (c, d, f, g) => {
|
|
4755
|
+
if (c)
|
|
4756
|
+
for (const b of Object.keys(c))
|
|
4757
|
+
b in i || (i[b] = {
|
|
4758
|
+
value: c[b],
|
|
4759
|
+
source: s(d),
|
|
4760
|
+
kind: f,
|
|
4761
|
+
depth: g
|
|
4762
|
+
});
|
|
4763
|
+
};
|
|
4764
|
+
let a = t, o = 0;
|
|
4765
|
+
for (; a; )
|
|
4766
|
+
a !== t && n(a.getRawDerivedBindingData(), a, "derive", o), n(a.getRawBindingData(), a, "bind", o), a = a.getParent(), o += 1;
|
|
4767
|
+
return L.isEnabled() && p.info("[Haori]", "scope dump for", e, { resolved: r, sources: i }), { resolved: r, sources: i };
|
|
4768
|
+
}
|
|
4653
4769
|
/**
|
|
4654
4770
|
* data-bind 属性の値をパースします。
|
|
4655
4771
|
*
|
|
@@ -4661,7 +4777,7 @@ const u = class u {
|
|
|
4661
4777
|
try {
|
|
4662
4778
|
return JSON.parse(e);
|
|
4663
4779
|
} catch (t) {
|
|
4664
|
-
return
|
|
4780
|
+
return p.error("[Haori]", "Invalid JSON in data-bind:", t), {};
|
|
4665
4781
|
}
|
|
4666
4782
|
else {
|
|
4667
4783
|
const t = new URLSearchParams(e), r = {};
|
|
@@ -4681,7 +4797,7 @@ const u = class u {
|
|
|
4681
4797
|
if (r.isSkipMutationNodes())
|
|
4682
4798
|
return;
|
|
4683
4799
|
const i = w.get(t.nextSibling), s = w.get(t);
|
|
4684
|
-
s && (r.insertBefore(s, i), s instanceof
|
|
4800
|
+
s && (r.insertBefore(s, i), s instanceof C ? u.scan(s.getTarget()) : s instanceof H && u.evaluateText(s));
|
|
4685
4801
|
}
|
|
4686
4802
|
/**
|
|
4687
4803
|
* ノードを親要素から削除します。
|
|
@@ -4723,7 +4839,7 @@ const u = class u {
|
|
|
4723
4839
|
i.push(r.setValue(t));
|
|
4724
4840
|
const s = u.getFormFragment(r);
|
|
4725
4841
|
if (s) {
|
|
4726
|
-
const n =
|
|
4842
|
+
const n = A.getValues(s), a = s.getAttribute(`${l.prefix}form-arg`);
|
|
4727
4843
|
let o;
|
|
4728
4844
|
a ? (o = s.getRawBindingData(), o || (o = {}), o[String(a)] = n) : o = n, i.push(u.setBindingData(s.getTarget(), o));
|
|
4729
4845
|
}
|
|
@@ -4755,22 +4871,22 @@ const u = class u {
|
|
|
4755
4871
|
const i = e.hasAttribute(`${l.prefix}derive`), s = e.hasAttribute(`${l.prefix}if`), n = e.hasAttribute(`${l.prefix}each`), a = e.getRawAttribute(`${l.prefix}derive`), o = e.getRawAttribute(`${l.prefix}derive-name`);
|
|
4756
4872
|
let c = !1, d = !1, f = null;
|
|
4757
4873
|
if (!i && e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), !i && e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), i) {
|
|
4758
|
-
const
|
|
4874
|
+
const g = u.createDeriveInputSignature(
|
|
4759
4875
|
e,
|
|
4760
4876
|
a,
|
|
4761
4877
|
o
|
|
4762
4878
|
);
|
|
4763
|
-
|
|
4879
|
+
g === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
|
|
4764
4880
|
() => u.evaluateDerive(e, a, o).then(
|
|
4765
4881
|
() => {
|
|
4766
4882
|
}
|
|
4767
4883
|
)
|
|
4768
|
-
)) : e.getDeriveInputSignature() !==
|
|
4884
|
+
)) : e.getDeriveInputSignature() !== g && (r = r.then(() => u.evaluateDerive(
|
|
4769
4885
|
e,
|
|
4770
4886
|
a,
|
|
4771
4887
|
o
|
|
4772
4888
|
).then(() => {
|
|
4773
|
-
e.setDeriveInputSignature(
|
|
4889
|
+
e.setDeriveInputSignature(g);
|
|
4774
4890
|
})));
|
|
4775
4891
|
}
|
|
4776
4892
|
return s && (r = r.then(() => u.evaluateIf(e))), n ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => u.evaluateEach(e))) : s ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => {
|
|
@@ -4789,14 +4905,14 @@ const u = class u {
|
|
|
4789
4905
|
})), r.then(() => {
|
|
4790
4906
|
if (c)
|
|
4791
4907
|
return;
|
|
4792
|
-
const
|
|
4793
|
-
return e.getChildren().forEach((
|
|
4794
|
-
if (
|
|
4795
|
-
if (u.canSkipUnchangedNestedEach(
|
|
4908
|
+
const g = [];
|
|
4909
|
+
return e.getChildren().forEach((b) => {
|
|
4910
|
+
if (b instanceof C) {
|
|
4911
|
+
if (u.canSkipUnchangedNestedEach(b))
|
|
4796
4912
|
return;
|
|
4797
|
-
|
|
4798
|
-
} else
|
|
4799
|
-
}), Promise.all(
|
|
4913
|
+
g.push(u.evaluateAll(b, t));
|
|
4914
|
+
} else b instanceof H && g.push(u.evaluateText(b));
|
|
4915
|
+
}), Promise.all(g).then(() => {
|
|
4800
4916
|
});
|
|
4801
4917
|
}).then(() => {
|
|
4802
4918
|
d && f !== null && e.setDeriveSubtreeSignature(f);
|
|
@@ -4818,7 +4934,7 @@ const u = class u {
|
|
|
4818
4934
|
const i = e.getRawDerivedBindingData(), s = typeof r == "string" ? r.trim() : "";
|
|
4819
4935
|
if (!t || s === "")
|
|
4820
4936
|
return i === null ? Promise.resolve(!1) : (e.setDerivedBindingData(null), Promise.resolve(!0));
|
|
4821
|
-
const n =
|
|
4937
|
+
const n = Y.evaluateDetailed(
|
|
4822
4938
|
t,
|
|
4823
4939
|
e.getBindingData()
|
|
4824
4940
|
);
|
|
@@ -4838,46 +4954,125 @@ const u = class u {
|
|
|
4838
4954
|
static evaluateText(e) {
|
|
4839
4955
|
return e.evaluate();
|
|
4840
4956
|
}
|
|
4957
|
+
/**
|
|
4958
|
+
* data-if の評価値が「非表示」とみなされるかどうかを判定します。
|
|
4959
|
+
*
|
|
4960
|
+
* JavaScript の falsy 判定に準拠し、`false`・`null`・`undefined`・`NaN` に加えて
|
|
4961
|
+
* `0`・空文字列 `''` も非表示とします(例: `data-if="items.length"` は要素数 0 で
|
|
4962
|
+
* 非表示)。空配列 `[]` や空オブジェクト `{}` は JavaScript 同様 truthy なので表示されます。
|
|
4963
|
+
*
|
|
4964
|
+
* @param condition data-if の評価結果
|
|
4965
|
+
* @return 非表示とみなす場合は true
|
|
4966
|
+
*/
|
|
4967
|
+
static isHiddenIfCondition(e) {
|
|
4968
|
+
return !e;
|
|
4969
|
+
}
|
|
4841
4970
|
/**
|
|
4842
4971
|
* if要素を評価します。
|
|
4843
|
-
* 値がfalse
|
|
4972
|
+
* 値が falsy(false・null・undefined・NaN・0・空文字列)の場合は非表示にし、
|
|
4973
|
+
* それ以外の場合は表示します。
|
|
4844
4974
|
*
|
|
4845
4975
|
* @param fragment 対象フラグメント
|
|
4846
4976
|
* @return Promise (DOM操作が完了したときに解決される)
|
|
4847
4977
|
*/
|
|
4848
4978
|
static evaluateIf(e) {
|
|
4849
4979
|
const t = [], r = e.getAttribute(`${l.prefix}if`);
|
|
4850
|
-
if (
|
|
4980
|
+
if (u.isHiddenIfCondition(r))
|
|
4851
4981
|
t.push(
|
|
4852
4982
|
e.hide().then(() => {
|
|
4853
|
-
|
|
4983
|
+
R.hide(e.getTarget());
|
|
4854
4984
|
})
|
|
4855
4985
|
);
|
|
4856
4986
|
else {
|
|
4857
|
-
const i = [];
|
|
4858
|
-
e.getChildren().forEach((
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
) :
|
|
4987
|
+
const i = e.isVisible(), s = [];
|
|
4988
|
+
e.getChildren().forEach((n) => {
|
|
4989
|
+
n instanceof C ? s.push(
|
|
4990
|
+
n.isMounted() ? u.evaluateAll(n) : u.scan(n.getTarget())
|
|
4991
|
+
) : n instanceof H && s.push(u.evaluateText(n));
|
|
4862
4992
|
}), t.push(
|
|
4863
4993
|
e.show().then(() => {
|
|
4864
|
-
|
|
4994
|
+
R.show(e.getTarget()), i || u.triggerLoadOnShow(e);
|
|
4865
4995
|
})
|
|
4866
|
-
), t.push(Promise.all(
|
|
4996
|
+
), t.push(Promise.all(s).then(() => {
|
|
4867
4997
|
}));
|
|
4868
4998
|
}
|
|
4869
4999
|
return Promise.all(t).then(() => {
|
|
4870
5000
|
});
|
|
4871
5001
|
}
|
|
5002
|
+
/**
|
|
5003
|
+
* data-if 表示時に data-load-* 手続きを発火します。
|
|
5004
|
+
*
|
|
5005
|
+
* 対象要素が data-load-* 属性を持つ場合のみ、load 種別の Procedure を1回実行します。
|
|
5006
|
+
* 結果は待機せず(fire-and-forget)、表示処理の完了をブロックしません。
|
|
5007
|
+
*
|
|
5008
|
+
* @param fragment 対象フラグメント
|
|
5009
|
+
* @return 戻り値はありません。
|
|
5010
|
+
*/
|
|
5011
|
+
static triggerLoadOnShow(e) {
|
|
5012
|
+
const t = `${l.prefix}load-`;
|
|
5013
|
+
e.getTarget().getAttributeNames().some((i) => i.startsWith(t)) && new q(e, "load").run().catch((i) => {
|
|
5014
|
+
p.error("[Haori]", "data-load procedure error (on show):", i);
|
|
5015
|
+
});
|
|
5016
|
+
}
|
|
5017
|
+
/**
|
|
5018
|
+
* data-each フラグメントの差分更新の再入制御状態を取得します。
|
|
5019
|
+
*
|
|
5020
|
+
* @param fragment 対象フラグメント
|
|
5021
|
+
* @return 再入制御状態
|
|
5022
|
+
*/
|
|
5023
|
+
static getEachUpdateState(e) {
|
|
5024
|
+
let t = u.EACH_UPDATE_STATES.get(e);
|
|
5025
|
+
return t || (t = { running: !1, rerunRequested: !1, settled: null }, u.EACH_UPDATE_STATES.set(e, t)), t;
|
|
5026
|
+
}
|
|
4872
5027
|
/**
|
|
4873
5028
|
* each要素を評価します。
|
|
4874
5029
|
* 非表示または未マウントの場合は処理をスキップします。
|
|
4875
5030
|
*
|
|
5031
|
+
* 同一フラグメントに対する差分更新が並行・再入しないように直列化します。
|
|
5032
|
+
* 実行中に再度呼び出された場合は再評価要求を記録し、現在進行中の更新の完了
|
|
5033
|
+
* Promise(後続の再実行も含む)を返します。これにより、bind 直後のリアクティブ
|
|
5034
|
+
* 再評価が重なっても data-each の描画が破壊されず、かつ呼び出し元(`evaluateAll`→
|
|
5035
|
+
* `setBindingData`→`haori:bindcomplete`)が**最終的な DOM 反映まで確実に待機**できます。
|
|
5036
|
+
*
|
|
4876
5037
|
* @param fragment 対象フラグメント
|
|
5038
|
+
* @return 差分更新(再実行を含む)の完了 Promise
|
|
4877
5039
|
*/
|
|
4878
5040
|
static evaluateEach(e) {
|
|
4879
5041
|
if (!e.isVisible() || !e.isMounted())
|
|
4880
5042
|
return Promise.resolve();
|
|
5043
|
+
const t = u.getEachUpdateState(e);
|
|
5044
|
+
return t.running ? (t.rerunRequested = !0, t.settled ?? Promise.resolve()) : u.runEachUpdateLoop(e, t);
|
|
5045
|
+
}
|
|
5046
|
+
/**
|
|
5047
|
+
* data-each の差分更新を、再評価要求が無くなるまで直列に繰り返し実行します。
|
|
5048
|
+
* 進行中・後続の再実行を含む完了 Promise を state に保持し、再入した呼び出し元が
|
|
5049
|
+
* 同じ Promise を待てるようにします。
|
|
5050
|
+
*
|
|
5051
|
+
* @param fragment 対象フラグメント
|
|
5052
|
+
* @param state 再入制御状態
|
|
5053
|
+
* @return すべての差分更新が安定するまでの完了 Promise
|
|
5054
|
+
*/
|
|
5055
|
+
static runEachUpdateLoop(e, t) {
|
|
5056
|
+
t.running = !0, e.getTarget().removeAttribute(`${l.prefix}each-done`);
|
|
5057
|
+
const r = (async () => {
|
|
5058
|
+
try {
|
|
5059
|
+
do
|
|
5060
|
+
t.rerunRequested = !1, await u.performEachUpdate(e);
|
|
5061
|
+
while (t.rerunRequested);
|
|
5062
|
+
e.getTarget().setAttribute(`${l.prefix}each-done`, "");
|
|
5063
|
+
} finally {
|
|
5064
|
+
t.running = !1, t.settled = null;
|
|
5065
|
+
}
|
|
5066
|
+
})();
|
|
5067
|
+
return t.settled = r, r;
|
|
5068
|
+
}
|
|
5069
|
+
/**
|
|
5070
|
+
* data-each の差分更新本体を実行します(再入制御は呼び出し側で行います)。
|
|
5071
|
+
*
|
|
5072
|
+
* @param fragment 対象フラグメント
|
|
5073
|
+
* @return 差分更新完了の Promise
|
|
5074
|
+
*/
|
|
5075
|
+
static performEachUpdate(e) {
|
|
4881
5076
|
const t = u.resolveEachItems(e);
|
|
4882
5077
|
if (t === null)
|
|
4883
5078
|
return Promise.reject(new Error("Invalid each attribute."));
|
|
@@ -4889,7 +5084,7 @@ const u = class u {
|
|
|
4889
5084
|
if (r === null) {
|
|
4890
5085
|
let n = !1;
|
|
4891
5086
|
return e.getChildren().forEach((a) => {
|
|
4892
|
-
if (!n && a instanceof
|
|
5087
|
+
if (!n && a instanceof C) {
|
|
4893
5088
|
if (a.hasAttribute(`${l.prefix}each-before`) || a.hasAttribute(`${l.prefix}each-after`))
|
|
4894
5089
|
return;
|
|
4895
5090
|
r = a.clone(), u.markFreshInitializationSkippable(r), e.setTemplate(r), n = !0, e.removeChild(a);
|
|
@@ -4912,7 +5107,7 @@ const u = class u {
|
|
|
4912
5107
|
*/
|
|
4913
5108
|
static resolveEachItems(e) {
|
|
4914
5109
|
const t = e.getAttributeEvaluation(`${l.prefix}each`), r = t?.value;
|
|
4915
|
-
return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (
|
|
5110
|
+
return t?.hasUnresolvedReference || r === !1 || r === null || r === void 0 ? [] : Array.isArray(r) ? r : (p.error("[Haori]", "Invalid each attribute:", r), null);
|
|
4916
5111
|
}
|
|
4917
5112
|
/**
|
|
4918
5113
|
* nested data-each の入力が同値で、要素自身に他の動的要素が無い場合は
|
|
@@ -4953,7 +5148,7 @@ const u = class u {
|
|
|
4953
5148
|
* @returns 含むなら true
|
|
4954
5149
|
*/
|
|
4955
5150
|
static hasDisallowedDerivedSubtreeDescendant(e) {
|
|
4956
|
-
return e.getChildren().some((t) => t instanceof
|
|
5151
|
+
return e.getChildren().some((t) => t instanceof C ? t.hasAttribute(`${l.prefix}derive`) || t.hasAttribute(`${l.prefix}derive-name`) || t.hasAttribute(`${l.prefix}fetch`) || t.hasAttribute(`${l.prefix}import`) ? !0 : u.hasDisallowedDerivedSubtreeDescendant(t) : !1);
|
|
4957
5152
|
}
|
|
4958
5153
|
/**
|
|
4959
5154
|
* data-derive host が子孫要素へ公開している binding の署名を返します。
|
|
@@ -5001,7 +5196,7 @@ const u = class u {
|
|
|
5001
5196
|
* @returns プロファイル
|
|
5002
5197
|
*/
|
|
5003
5198
|
static getOrCreateDerivedSubtreeProfile(e) {
|
|
5004
|
-
if (!
|
|
5199
|
+
if (!L.isEnabled() || !e.hasAttribute(`${l.prefix}derive`))
|
|
5005
5200
|
return null;
|
|
5006
5201
|
const t = u.DERIVE_SUBTREE_PROFILES.get(e);
|
|
5007
5202
|
if (t)
|
|
@@ -5039,7 +5234,7 @@ const u = class u {
|
|
|
5039
5234
|
typeof n == "string" && n.trim() !== "" && (s += `[${l.prefix}derive-name="${n.trim()}"]`);
|
|
5040
5235
|
const a = r.getParent();
|
|
5041
5236
|
if (a) {
|
|
5042
|
-
const o = a.getChildren().filter((c) => c instanceof
|
|
5237
|
+
const o = a.getChildren().filter((c) => c instanceof C).findIndex((c) => c === r);
|
|
5043
5238
|
s += `:nth-child(${o + 1})`;
|
|
5044
5239
|
}
|
|
5045
5240
|
t.unshift(s), r = a;
|
|
@@ -5070,7 +5265,7 @@ const u = class u {
|
|
|
5070
5265
|
*/
|
|
5071
5266
|
static logDerivedSubtreeProfileSnapshot(e, t) {
|
|
5072
5267
|
const r = u.getOrCreateDerivedSubtreeProfile(e);
|
|
5073
|
-
r !== null && (t === "skip-hit" ? r.skipHitCount += 1 : t === "skip-miss" ? r.skipMissCount += 1 : t === "skip-ineligible" && (r.skipIneligibleCount += 1),
|
|
5268
|
+
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
5269
|
reason: t,
|
|
5075
5270
|
hostId: r.hostId,
|
|
5076
5271
|
signatureComputeTotal: r.signatureComputeTotal,
|
|
@@ -5112,7 +5307,7 @@ const u = class u {
|
|
|
5112
5307
|
* @returns subtree 全体を省略可能なら true
|
|
5113
5308
|
*/
|
|
5114
5309
|
static markFreshInitializationSkippable(e) {
|
|
5115
|
-
const t = e.getAttributeNames().some((s) => u.isFreshInitializationDynamicAttribute(e, s)), r = e.getChildren().some((s) => s instanceof
|
|
5310
|
+
const t = e.getAttributeNames().some((s) => u.isFreshInitializationDynamicAttribute(e, s)), r = e.getChildren().some((s) => s instanceof C ? !u.markFreshInitializationSkippable(s) : s instanceof H ? s.hasDynamicContent() : !1), i = !t && !r;
|
|
5116
5311
|
return e.setFreshInitializationSkippable(i), i;
|
|
5117
5312
|
}
|
|
5118
5313
|
/**
|
|
@@ -5137,84 +5332,84 @@ const u = class u {
|
|
|
5137
5332
|
static updateDiff(e, t) {
|
|
5138
5333
|
const r = e.getTemplate();
|
|
5139
5334
|
if (r === null)
|
|
5140
|
-
return
|
|
5335
|
+
return p.error("[Haori]", "Template is not set for each element."), Promise.resolve();
|
|
5141
5336
|
let i = e.getAttribute(`${l.prefix}each-index`);
|
|
5142
5337
|
i && (i = String(i));
|
|
5143
5338
|
const s = e.getAttribute(`${l.prefix}each-key`), n = e.getAttribute(`${l.prefix}each-arg`), a = /* @__PURE__ */ new Map(), o = [];
|
|
5144
|
-
t.forEach((y,
|
|
5145
|
-
const
|
|
5339
|
+
t.forEach((y, F) => {
|
|
5340
|
+
const N = u.createListKey(
|
|
5146
5341
|
y,
|
|
5147
5342
|
s ? String(s) : null,
|
|
5148
|
-
|
|
5343
|
+
F
|
|
5149
5344
|
);
|
|
5150
|
-
o.push(
|
|
5345
|
+
o.push(N), a.set(N, { item: y, itemIndex: F });
|
|
5151
5346
|
});
|
|
5152
5347
|
const c = new Set(o), d = [];
|
|
5153
|
-
let f = e.getChildren().filter((y) => y instanceof
|
|
5348
|
+
let f = e.getChildren().filter((y) => y instanceof C).filter(
|
|
5154
5349
|
(y) => !y.hasAttribute(`${l.prefix}each-before`) && !y.hasAttribute(`${l.prefix}each-after`)
|
|
5155
5350
|
);
|
|
5156
|
-
const
|
|
5351
|
+
const g = f.map((y) => y.getListKey());
|
|
5157
5352
|
f = f.filter((y) => c.has(String(y.getListKey())) ? !0 : (d.push(y.remove()), !1));
|
|
5158
|
-
const
|
|
5353
|
+
const b = f.map((y) => y.getListKey()), S = /* @__PURE__ */ new Map();
|
|
5159
5354
|
f.forEach((y) => {
|
|
5160
|
-
const
|
|
5161
|
-
|
|
5355
|
+
const F = y.getListKey();
|
|
5356
|
+
F !== null && !S.has(F) && S.set(F, y);
|
|
5162
5357
|
});
|
|
5163
|
-
const
|
|
5358
|
+
const m = e.getChildElementFragments().slice(), v = m.filter(
|
|
5164
5359
|
(y) => y.hasAttribute(`${l.prefix}each-before`)
|
|
5165
5360
|
).length;
|
|
5166
|
-
let
|
|
5167
|
-
return o.forEach((y,
|
|
5168
|
-
const { item:
|
|
5169
|
-
let
|
|
5170
|
-
const
|
|
5171
|
-
if (
|
|
5172
|
-
|
|
5361
|
+
let E = Promise.resolve();
|
|
5362
|
+
return o.forEach((y, F) => {
|
|
5363
|
+
const { item: N, itemIndex: U } = a.get(y);
|
|
5364
|
+
let B;
|
|
5365
|
+
const K = S.get(y);
|
|
5366
|
+
if (K)
|
|
5367
|
+
B = K, E = E.then(
|
|
5173
5368
|
() => u.updateRowFragment(
|
|
5174
|
-
k,
|
|
5175
5369
|
B,
|
|
5370
|
+
N,
|
|
5176
5371
|
i,
|
|
5177
|
-
|
|
5372
|
+
U,
|
|
5178
5373
|
n ? String(n) : null,
|
|
5179
5374
|
y
|
|
5180
|
-
).then((
|
|
5181
|
-
if (
|
|
5182
|
-
return u.evaluateAll(
|
|
5375
|
+
).then((k) => {
|
|
5376
|
+
if (k)
|
|
5377
|
+
return u.evaluateAll(B);
|
|
5183
5378
|
})
|
|
5184
5379
|
);
|
|
5185
5380
|
else {
|
|
5186
|
-
|
|
5187
|
-
const
|
|
5188
|
-
|
|
5381
|
+
B = r.clone();
|
|
5382
|
+
const k = v + F;
|
|
5383
|
+
E = E.then(
|
|
5189
5384
|
() => u.updateRowFragment(
|
|
5190
|
-
k,
|
|
5191
5385
|
B,
|
|
5386
|
+
N,
|
|
5192
5387
|
i,
|
|
5193
|
-
|
|
5388
|
+
U,
|
|
5194
5389
|
n ? String(n) : null,
|
|
5195
5390
|
y
|
|
5196
5391
|
).then(() => {
|
|
5197
|
-
const
|
|
5198
|
-
return e.insertBefore(
|
|
5199
|
-
|
|
5200
|
-
}).then(() => u.initializeFreshEachRow(
|
|
5392
|
+
const he = m[k] ?? null;
|
|
5393
|
+
return e.insertBefore(B, he).then(() => {
|
|
5394
|
+
m.splice(k, 0, B);
|
|
5395
|
+
}).then(() => u.initializeFreshEachRow(B));
|
|
5201
5396
|
})
|
|
5202
5397
|
);
|
|
5203
5398
|
}
|
|
5204
|
-
}), Promise.all(d).then(() =>
|
|
5399
|
+
}), Promise.all(d).then(() => E).then(() => {
|
|
5205
5400
|
const y = o.filter(
|
|
5206
|
-
(
|
|
5207
|
-
),
|
|
5208
|
-
(
|
|
5209
|
-
),
|
|
5210
|
-
(
|
|
5401
|
+
(k) => k !== null
|
|
5402
|
+
), F = b.filter(
|
|
5403
|
+
(k) => k !== null
|
|
5404
|
+
), N = new Set(F), U = y.filter((k) => !N.has(k)), K = g.filter(
|
|
5405
|
+
(k) => k !== null
|
|
5211
5406
|
).filter(
|
|
5212
|
-
(
|
|
5407
|
+
(k) => !c.has(k)
|
|
5213
5408
|
);
|
|
5214
|
-
|
|
5409
|
+
R.eachUpdate(
|
|
5215
5410
|
e.getTarget(),
|
|
5216
|
-
|
|
5217
|
-
|
|
5411
|
+
U,
|
|
5412
|
+
K,
|
|
5218
5413
|
y
|
|
5219
5414
|
);
|
|
5220
5415
|
});
|
|
@@ -5261,7 +5456,7 @@ const u = class u {
|
|
|
5261
5456
|
[s]: t
|
|
5262
5457
|
}, r && (a[r] = i);
|
|
5263
5458
|
else
|
|
5264
|
-
return
|
|
5459
|
+
return p.error(
|
|
5265
5460
|
"[Haori]",
|
|
5266
5461
|
`Primitive value requires '${l.prefix}each-arg' attribute: ${t}`
|
|
5267
5462
|
), Promise.resolve(!1);
|
|
@@ -5371,9 +5566,9 @@ u.ATTRIBUTE_ALIAS_SUFFIX = "attr-", u.PRIORITY_ATTRIBUTE_SUFFIXES = [
|
|
|
5371
5566
|
"fetch",
|
|
5372
5567
|
"import",
|
|
5373
5568
|
"url-param"
|
|
5374
|
-
], u.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/, u.REACTIVE_FETCH_STATES = /* @__PURE__ */ new WeakMap(), u.REACTIVE_IMPORT_STATES = /* @__PURE__ */ new WeakMap(), u.DERIVE_SUBTREE_PROFILES = /* @__PURE__ */ new WeakMap();
|
|
5375
|
-
let
|
|
5376
|
-
const
|
|
5569
|
+
], u.ATTRIBUTE_PLACEHOLDER_REGEX = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/, u.REACTIVE_FETCH_STATES = /* @__PURE__ */ new WeakMap(), u.REACTIVE_IMPORT_STATES = /* @__PURE__ */ new WeakMap(), u.DERIVE_SUBTREE_PROFILES = /* @__PURE__ */ new WeakMap(), u.EACH_UPDATE_STATES = /* @__PURE__ */ new WeakMap();
|
|
5570
|
+
let P = u;
|
|
5571
|
+
const te = class te {
|
|
5377
5572
|
/**
|
|
5378
5573
|
* コンストラクタ。
|
|
5379
5574
|
*
|
|
@@ -5382,10 +5577,10 @@ const ee = class ee {
|
|
|
5382
5577
|
constructor(e = document) {
|
|
5383
5578
|
this.onClick = (t) => this.delegate(t, "click"), this.onChange = (t) => this.delegate(t, "change"), this.onLoadCapture = (t) => this.delegate(t, "load"), this.onWindowLoad = () => {
|
|
5384
5579
|
const t = document.documentElement, r = w.get(t);
|
|
5385
|
-
r && new
|
|
5580
|
+
r && new q(r, "load").run();
|
|
5386
5581
|
}, this.onPopstate = (t) => {
|
|
5387
5582
|
const r = t.state;
|
|
5388
|
-
!r || r[
|
|
5583
|
+
!r || r[te.HISTORY_STATE_KEY] !== !0 || location.reload();
|
|
5389
5584
|
}, this.root = e;
|
|
5390
5585
|
}
|
|
5391
5586
|
/**
|
|
@@ -5412,8 +5607,8 @@ const ee = class ee {
|
|
|
5412
5607
|
if (!r)
|
|
5413
5608
|
return;
|
|
5414
5609
|
const i = w.get(r);
|
|
5415
|
-
i && (t === "change" && i instanceof
|
|
5416
|
-
|
|
5610
|
+
i && (t === "change" && i instanceof C && i.syncValue(), new q(i, t).run().catch((s) => {
|
|
5611
|
+
p.error("[Haori]", "Procedure execution error:", s);
|
|
5417
5612
|
}));
|
|
5418
5613
|
}
|
|
5419
5614
|
/**
|
|
@@ -5450,9 +5645,9 @@ const ee = class ee {
|
|
|
5450
5645
|
return null;
|
|
5451
5646
|
}
|
|
5452
5647
|
};
|
|
5453
|
-
|
|
5454
|
-
let ne =
|
|
5455
|
-
const
|
|
5648
|
+
te.HISTORY_STATE_KEY = "__haoriHistoryState__";
|
|
5649
|
+
let ne = te;
|
|
5650
|
+
const D = class D {
|
|
5456
5651
|
/**
|
|
5457
5652
|
* ノードが現在の Window に属する HTMLElement かどうかを判定します。
|
|
5458
5653
|
*
|
|
@@ -5466,42 +5661,42 @@ const T = class T {
|
|
|
5466
5661
|
return typeof t < "u" && e instanceof t;
|
|
5467
5662
|
}
|
|
5468
5663
|
static syncTree(e) {
|
|
5469
|
-
(e instanceof Element || e instanceof DocumentFragment) && (
|
|
5470
|
-
|
|
5664
|
+
(e instanceof Element || e instanceof DocumentFragment) && (D.isHtmlElement(e) && D.syncElement(e), e.querySelectorAll("*").forEach((t) => {
|
|
5665
|
+
D.syncElement(t);
|
|
5471
5666
|
}));
|
|
5472
5667
|
}
|
|
5473
5668
|
static syncElement(e) {
|
|
5474
|
-
const t =
|
|
5475
|
-
if (!r || !
|
|
5476
|
-
t && (t.observer.disconnect(),
|
|
5669
|
+
const t = D.registrations.get(e), r = w.get(e);
|
|
5670
|
+
if (!r || !D.shouldObserve(r)) {
|
|
5671
|
+
t && (t.observer.disconnect(), D.registrations.delete(e));
|
|
5477
5672
|
return;
|
|
5478
5673
|
}
|
|
5479
5674
|
if (typeof IntersectionObserver > "u")
|
|
5480
5675
|
return;
|
|
5481
|
-
const i =
|
|
5482
|
-
if (t && t.observer.root === i && t.observer.rootMargin === s &&
|
|
5676
|
+
const i = D.resolveRoot(r), s = D.resolveRootMargin(r), n = D.resolveThreshold(r), a = r.hasAttribute(`${l.prefix}intersect-once`);
|
|
5677
|
+
if (t && t.observer.root === i && t.observer.rootMargin === s && D.sameThreshold(
|
|
5483
5678
|
t.observer.thresholds,
|
|
5484
5679
|
n
|
|
5485
5680
|
) && t.once === a) {
|
|
5486
5681
|
t.fragment = r;
|
|
5487
5682
|
return;
|
|
5488
5683
|
}
|
|
5489
|
-
t && (t.observer.disconnect(),
|
|
5684
|
+
t && (t.observer.disconnect(), D.registrations.delete(e));
|
|
5490
5685
|
const o = new IntersectionObserver(
|
|
5491
5686
|
(c) => {
|
|
5492
|
-
const d =
|
|
5687
|
+
const d = D.registrations.get(e);
|
|
5493
5688
|
d && c.forEach((f) => {
|
|
5494
|
-
!f.isIntersecting || d.running ||
|
|
5495
|
-
|
|
5496
|
-
}).catch((
|
|
5497
|
-
|
|
5689
|
+
!f.isIntersecting || d.running || D.isDisabled(d.fragment) || (d.running = !0, new q(d.fragment, "intersect").runWithResult().then((g) => {
|
|
5690
|
+
g && d.once && (d.observer.disconnect(), D.registrations.delete(e));
|
|
5691
|
+
}).catch((g) => {
|
|
5692
|
+
p.error(
|
|
5498
5693
|
"[Haori]",
|
|
5499
5694
|
"Intersect procedure execution error:",
|
|
5500
|
-
|
|
5695
|
+
g
|
|
5501
5696
|
);
|
|
5502
5697
|
}).finally(() => {
|
|
5503
|
-
const
|
|
5504
|
-
|
|
5698
|
+
const g = D.registrations.get(e);
|
|
5699
|
+
g && (g.running = !1);
|
|
5505
5700
|
}));
|
|
5506
5701
|
});
|
|
5507
5702
|
},
|
|
@@ -5511,7 +5706,7 @@ const T = class T {
|
|
|
5511
5706
|
threshold: n
|
|
5512
5707
|
}
|
|
5513
5708
|
);
|
|
5514
|
-
o.observe(e),
|
|
5709
|
+
o.observe(e), D.registrations.set(e, {
|
|
5515
5710
|
fragment: r,
|
|
5516
5711
|
observer: o,
|
|
5517
5712
|
once: a,
|
|
@@ -5519,26 +5714,26 @@ const T = class T {
|
|
|
5519
5714
|
});
|
|
5520
5715
|
}
|
|
5521
5716
|
static cleanupTree(e) {
|
|
5522
|
-
if (
|
|
5523
|
-
const t =
|
|
5524
|
-
t && (t.observer.disconnect(),
|
|
5717
|
+
if (D.isHtmlElement(e)) {
|
|
5718
|
+
const t = D.registrations.get(e);
|
|
5719
|
+
t && (t.observer.disconnect(), D.registrations.delete(e));
|
|
5525
5720
|
}
|
|
5526
5721
|
(e instanceof Element || e instanceof DocumentFragment) && e.querySelectorAll("*").forEach((t) => {
|
|
5527
|
-
const r =
|
|
5528
|
-
r && (r.observer.disconnect(),
|
|
5722
|
+
const r = D.registrations.get(t);
|
|
5723
|
+
r && (r.observer.disconnect(), D.registrations.delete(t));
|
|
5529
5724
|
});
|
|
5530
5725
|
}
|
|
5531
5726
|
static disconnectAll() {
|
|
5532
|
-
|
|
5727
|
+
D.registrations.forEach((e) => {
|
|
5533
5728
|
e.observer.disconnect();
|
|
5534
|
-
}),
|
|
5729
|
+
}), D.registrations.clear();
|
|
5535
5730
|
}
|
|
5536
5731
|
static shouldObserve(e) {
|
|
5537
5732
|
return e.getAttributeNames().some((t) => {
|
|
5538
5733
|
if (!t.startsWith(`${l.prefix}intersect-`))
|
|
5539
5734
|
return !1;
|
|
5540
5735
|
const r = t.slice(`${l.prefix}intersect-`.length);
|
|
5541
|
-
return !
|
|
5736
|
+
return !D.CONFIG_KEYS.has(r);
|
|
5542
5737
|
});
|
|
5543
5738
|
}
|
|
5544
5739
|
static resolveRoot(e) {
|
|
@@ -5549,7 +5744,7 @@ const T = class T {
|
|
|
5549
5744
|
if (typeof r != "string" || r.trim() === "")
|
|
5550
5745
|
return null;
|
|
5551
5746
|
const i = document.querySelector(r);
|
|
5552
|
-
return
|
|
5747
|
+
return D.isHtmlElement(i) ? i : (p.error("[Haori]", `Intersect root element not found: ${r}`), null);
|
|
5553
5748
|
}
|
|
5554
5749
|
static resolveRootMargin(e) {
|
|
5555
5750
|
const t = `${l.prefix}intersect-root-margin`, r = e.getAttribute(t);
|
|
@@ -5572,14 +5767,14 @@ const T = class T {
|
|
|
5572
5767
|
return e.length === 1 && e[0] === t;
|
|
5573
5768
|
}
|
|
5574
5769
|
};
|
|
5575
|
-
|
|
5770
|
+
D.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
5576
5771
|
"root",
|
|
5577
5772
|
"root-margin",
|
|
5578
5773
|
"threshold",
|
|
5579
5774
|
"disabled",
|
|
5580
5775
|
"once"
|
|
5581
|
-
]),
|
|
5582
|
-
let
|
|
5776
|
+
]), D.registrations = /* @__PURE__ */ new Map();
|
|
5777
|
+
let W = D;
|
|
5583
5778
|
const O = class O {
|
|
5584
5779
|
/**
|
|
5585
5780
|
* 既存の MutationObserver をすべて停止します。
|
|
@@ -5598,10 +5793,10 @@ const O = class O {
|
|
|
5598
5793
|
return;
|
|
5599
5794
|
O._initialized = !0, O.disconnectMutationObservers();
|
|
5600
5795
|
const e = await Promise.allSettled([
|
|
5601
|
-
|
|
5602
|
-
|
|
5796
|
+
P.scan(document.head),
|
|
5797
|
+
P.scan(document.body)
|
|
5603
5798
|
]), [t, r] = e;
|
|
5604
|
-
t.status !== "fulfilled" &&
|
|
5799
|
+
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
5800
|
}
|
|
5606
5801
|
/**
|
|
5607
5802
|
* 指定された要素を監視します。
|
|
@@ -5615,29 +5810,29 @@ const O = class O {
|
|
|
5615
5810
|
switch (i.type) {
|
|
5616
5811
|
case "attributes": {
|
|
5617
5812
|
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 &&
|
|
5813
|
+
if (i.attributeName && s.hasAttribute("data-haori-click-lock") && (i.attributeName === "disabled" || i.attributeName === "data-haori-click-lock") || i.attributeName && P.isAliasedAttributeReflection(
|
|
5619
5814
|
s,
|
|
5620
5815
|
i.attributeName
|
|
5621
5816
|
))
|
|
5622
5817
|
break;
|
|
5623
|
-
|
|
5818
|
+
P.setAttribute(
|
|
5624
5819
|
s,
|
|
5625
5820
|
i.attributeName,
|
|
5626
5821
|
s.getAttribute(i.attributeName),
|
|
5627
5822
|
!0
|
|
5628
|
-
),
|
|
5823
|
+
), W.syncElement(s);
|
|
5629
5824
|
break;
|
|
5630
5825
|
}
|
|
5631
5826
|
case "childList": {
|
|
5632
5827
|
Array.from(i.removedNodes).forEach((s) => {
|
|
5633
|
-
|
|
5828
|
+
W.cleanupTree(s), P.removeNode(s);
|
|
5634
5829
|
}), Array.from(i.addedNodes).forEach((s) => {
|
|
5635
|
-
s.parentElement instanceof Element && (
|
|
5830
|
+
s.parentElement instanceof Element && (P.addNode(s.parentElement, s), W.syncTree(s));
|
|
5636
5831
|
});
|
|
5637
5832
|
break;
|
|
5638
5833
|
}
|
|
5639
5834
|
case "characterData": {
|
|
5640
|
-
i.target instanceof Text || i.target instanceof Comment ?
|
|
5835
|
+
i.target instanceof Text || i.target instanceof Comment ? P.changeText(i.target, i.target.textContent) : p.warn(
|
|
5641
5836
|
"[Haori]",
|
|
5642
5837
|
"Unsupported character data type:",
|
|
5643
5838
|
i.target
|
|
@@ -5645,11 +5840,11 @@ const O = class O {
|
|
|
5645
5840
|
break;
|
|
5646
5841
|
}
|
|
5647
5842
|
default:
|
|
5648
|
-
|
|
5843
|
+
p.warn("[Haori]", "Unknown mutation type:", i.type);
|
|
5649
5844
|
continue;
|
|
5650
5845
|
}
|
|
5651
5846
|
} catch (s) {
|
|
5652
|
-
|
|
5847
|
+
p.error("[Haori]", "Error processing mutation:", s);
|
|
5653
5848
|
}
|
|
5654
5849
|
});
|
|
5655
5850
|
t.observe(e, {
|
|
@@ -5661,18 +5856,19 @@ const O = class O {
|
|
|
5661
5856
|
}
|
|
5662
5857
|
};
|
|
5663
5858
|
O._initialized = !1, O._mutationObservers = [];
|
|
5664
|
-
let
|
|
5665
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
5666
|
-
const
|
|
5859
|
+
let Z = O;
|
|
5860
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Z.init) : Z.init();
|
|
5861
|
+
const De = () => J.waitForRenders(), Re = "0.9.0";
|
|
5667
5862
|
export {
|
|
5668
|
-
|
|
5863
|
+
P as Core,
|
|
5669
5864
|
l as Env,
|
|
5670
|
-
|
|
5865
|
+
A as Form,
|
|
5671
5866
|
w as Fragment,
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5867
|
+
J as Haori,
|
|
5868
|
+
p as Log,
|
|
5869
|
+
M as Queue,
|
|
5870
|
+
J as default,
|
|
5871
|
+
Re as version,
|
|
5872
|
+
De as waitForRenders
|
|
5677
5873
|
};
|
|
5678
5874
|
//# sourceMappingURL=haori.es.js.map
|