haori 0.51.0 → 0.52.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 +1 -1
- package/README.md +1 -1
- package/dist/haori.cjs.js +3 -3
- package/dist/haori.es.js +105 -52
- package/dist/haori.iife.js +10 -10
- package/dist/index.d.ts +37 -4
- package/package.json +1 -1
package/dist/haori.es.js
CHANGED
|
@@ -197,7 +197,8 @@ const bt = /^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/, je = "new:
|
|
|
197
197
|
/**
|
|
198
198
|
* 対象要素とその子孫へ、まだ適用していない連携を適用します。
|
|
199
199
|
*
|
|
200
|
-
* 初期スキャン・新規ノードの追加・`data-each`
|
|
200
|
+
* 初期スキャン・新規ノードの追加・`data-each` の新規行・`data-if` の表示から
|
|
201
|
+
* 呼び出します。非表示の分岐の中の要素には適用しません(`applyElement()`)。
|
|
201
202
|
*
|
|
202
203
|
* @param root 走査の起点となる要素
|
|
203
204
|
* @returns 戻り値はありません。
|
|
@@ -220,8 +221,9 @@ const bt = /^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/, je = "new:
|
|
|
220
221
|
* 対象要素とその子孫の連携を再同期します。
|
|
221
222
|
*
|
|
222
223
|
* 適用済みの要素では `refresh` を呼びます。未適用の要素では、`applyPending` が
|
|
223
|
-
* true なら `init`
|
|
224
|
-
*
|
|
224
|
+
* true なら `init` を呼びます(非表示の分岐の中は除きます)。`data-each` の描画
|
|
225
|
+
* 確定、`data-if` の再表示、フォームのリセット、Haori が値を書いた入力欄の通知から
|
|
226
|
+
* 呼び出します。
|
|
225
227
|
*
|
|
226
228
|
* @param root 走査の起点となる要素
|
|
227
229
|
* @param applyPending 未適用の要素へ `init` を呼ぶかどうか
|
|
@@ -267,6 +269,8 @@ const bt = /^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/, je = "new:
|
|
|
267
269
|
* @returns 戻り値はありません。
|
|
268
270
|
*/
|
|
269
271
|
static applyElement(e) {
|
|
272
|
+
if (e.closest(`[${l.prefix}if-false]`))
|
|
273
|
+
return;
|
|
270
274
|
const t = k.instances.get(e) ?? null;
|
|
271
275
|
k.names(e, `${l.prefix}enhance`).forEach((r) => {
|
|
272
276
|
if (t?.has(r))
|
|
@@ -417,7 +421,7 @@ const bt = /^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/, je = "new:
|
|
|
417
421
|
}
|
|
418
422
|
};
|
|
419
423
|
k.enhancers = /* @__PURE__ */ new Map(), k.instances = /* @__PURE__ */ new WeakMap(), k.warnedUnknownNames = /* @__PURE__ */ new Set(), k.warnedMissingGlobals = /* @__PURE__ */ new Set(), k.visited = /* @__PURE__ */ new WeakSet(), k.mutationCapture = null;
|
|
420
|
-
let
|
|
424
|
+
let te = k;
|
|
421
425
|
const Qe = "yyyy/MM/dd HH:mm", Et = "en-US", Ke = 1e4;
|
|
422
426
|
function de(b) {
|
|
423
427
|
return String(b).padStart(2, "0");
|
|
@@ -3168,7 +3172,7 @@ const S = class S extends I {
|
|
|
3168
3172
|
*/
|
|
3169
3173
|
remove(e = !0) {
|
|
3170
3174
|
const t = [];
|
|
3171
|
-
return e &&
|
|
3175
|
+
return e && te.destroySubtree(this.getTarget()), this.getTarget().hasAttribute(`${l.prefix}external`) ? this.detachPreservingSubtree(e) : (this.children.slice().forEach((r) => {
|
|
3172
3176
|
t.push(r.remove(!1));
|
|
3173
3177
|
}), this.children.length = 0, this.attributeMap.clear(), this.bindingData = null, this.bindingDataCache = null, this.derivedBindingData = null, this.descendantBindingDataCache = null, this.template && (t.push(this.template.remove(!1)), this.template = null), this.eachInputSignature = null, this.deriveSubtreeSignature = null, this.deriveInputSignature = null, this.clearUnappliedValueWrite(), t.push(super.remove(e)), Promise.all(t).then(() => {
|
|
3174
3178
|
}));
|
|
@@ -3791,7 +3795,7 @@ const S = class S extends I {
|
|
|
3791
3795
|
* @returns 戻り値はありません。
|
|
3792
3796
|
*/
|
|
3793
3797
|
static notifyValueToEnhancers(e) {
|
|
3794
|
-
|
|
3798
|
+
te.isApplied(e) && te.refreshSubtree(e);
|
|
3795
3799
|
}
|
|
3796
3800
|
/**
|
|
3797
3801
|
* 「載らなかった書き込み」の記録を解除します。
|
|
@@ -5215,7 +5219,7 @@ const Me = class Me {
|
|
|
5215
5219
|
};
|
|
5216
5220
|
Me.PLACEHOLDER_REGEX = /\{\{\{([\s\S]+?)\}\}\}|\{\{([\s\S]+?)\}\}/g;
|
|
5217
5221
|
let he = Me;
|
|
5218
|
-
const
|
|
5222
|
+
const re = class re extends he {
|
|
5219
5223
|
/**
|
|
5220
5224
|
* コンストラクタ。
|
|
5221
5225
|
*
|
|
@@ -5223,7 +5227,7 @@ const te = class te extends he {
|
|
|
5223
5227
|
* @param text 属性値
|
|
5224
5228
|
*/
|
|
5225
5229
|
constructor(e, t) {
|
|
5226
|
-
super(t), this.forceEvaluation =
|
|
5230
|
+
super(t), this.forceEvaluation = re.needsForceEvaluation(e);
|
|
5227
5231
|
}
|
|
5228
5232
|
/**
|
|
5229
5233
|
* 属性名が強制評価の対象かどうかを判定します。
|
|
@@ -5236,17 +5240,17 @@ const te = class te extends he {
|
|
|
5236
5240
|
* @returns 強制評価の対象なら true
|
|
5237
5241
|
*/
|
|
5238
5242
|
static needsForceEvaluation(e) {
|
|
5239
|
-
if (
|
|
5243
|
+
if (re.forceEvaluationNames === null || re.forceEvaluationPrefix !== l.prefix) {
|
|
5240
5244
|
const t = /* @__PURE__ */ new Set();
|
|
5241
5245
|
for (const r of [
|
|
5242
5246
|
l.prefix,
|
|
5243
|
-
...
|
|
5247
|
+
...re.FORCE_EVALUATION_PREFIXES
|
|
5244
5248
|
])
|
|
5245
|
-
for (const i of
|
|
5249
|
+
for (const i of re.FORCE_EVALUATION_SUFFIXES)
|
|
5246
5250
|
t.add(`${r}${i}`);
|
|
5247
|
-
|
|
5251
|
+
re.forceEvaluationNames = t, re.forceEvaluationPrefix = l.prefix;
|
|
5248
5252
|
}
|
|
5249
|
-
return
|
|
5253
|
+
return re.forceEvaluationNames.has(e);
|
|
5250
5254
|
}
|
|
5251
5255
|
/**
|
|
5252
5256
|
* 強制評価フラグを取得します。
|
|
@@ -5293,8 +5297,8 @@ const te = class te extends he {
|
|
|
5293
5297
|
}) : r;
|
|
5294
5298
|
}
|
|
5295
5299
|
};
|
|
5296
|
-
|
|
5297
|
-
let Ce =
|
|
5300
|
+
re.FORCE_EVALUATION_SUFFIXES = ["if", "each", "derive"], re.FORCE_EVALUATION_PREFIXES = ["data-", "hor-"], re.forceEvaluationNames = null, re.forceEvaluationPrefix = null;
|
|
5301
|
+
let Ce = re;
|
|
5298
5302
|
const Se = class Se {
|
|
5299
5303
|
/**
|
|
5300
5304
|
* 実行モードを取得します。
|
|
@@ -5606,7 +5610,7 @@ Se.enhancers = {
|
|
|
5606
5610
|
* @return 戻り値はありません。
|
|
5607
5611
|
*/
|
|
5608
5612
|
register(e, t) {
|
|
5609
|
-
|
|
5613
|
+
te.register(e, t);
|
|
5610
5614
|
},
|
|
5611
5615
|
/**
|
|
5612
5616
|
* 登録済みの連携かどうかを返します。
|
|
@@ -5615,7 +5619,7 @@ Se.enhancers = {
|
|
|
5615
5619
|
* @return 登録済みなら true
|
|
5616
5620
|
*/
|
|
5617
5621
|
has(e) {
|
|
5618
|
-
return
|
|
5622
|
+
return te.has(e);
|
|
5619
5623
|
}
|
|
5620
5624
|
};
|
|
5621
5625
|
let Re = Se;
|
|
@@ -7502,7 +7506,7 @@ const f = class f {
|
|
|
7502
7506
|
sequence: t
|
|
7503
7507
|
});
|
|
7504
7508
|
}
|
|
7505
|
-
|
|
7509
|
+
te.refreshSubtree(e.getTarget());
|
|
7506
7510
|
}
|
|
7507
7511
|
/**
|
|
7508
7512
|
* 祖先が所有するキーを、リセットの書き込み対象から落とします。
|
|
@@ -11817,16 +11821,52 @@ const h = class h {
|
|
|
11817
11821
|
* @returns Promise (スキャンが完了したときに解決される)
|
|
11818
11822
|
*/
|
|
11819
11823
|
static scan(e) {
|
|
11820
|
-
|
|
11821
|
-
|
|
11824
|
+
return h.scanElement(e, !0);
|
|
11825
|
+
}
|
|
11826
|
+
/**
|
|
11827
|
+
* 指定された要素と、その子要素をスキャンします。
|
|
11828
|
+
*
|
|
11829
|
+
* `applyEnhancers` が false のときは、走査の最後に外部ライブラリ連携を適用しません。
|
|
11830
|
+
* `data-if` の分岐の子を走査するときに使います。適用は、分岐の外の初期値の反映
|
|
11831
|
+
* (外側の走査の最後)や、揃った選択肢への値の載せ直しの後に行います(課題 55)。
|
|
11832
|
+
*
|
|
11833
|
+
* @param element スキャン対象の要素
|
|
11834
|
+
* @param applyEnhancers 走査の最後に外部ライブラリ連携を適用するかどうか
|
|
11835
|
+
* @returns Promise (スキャンが完了したときに解決される)
|
|
11836
|
+
*/
|
|
11837
|
+
static scanElement(e, t) {
|
|
11838
|
+
const r = I.get(e);
|
|
11839
|
+
if (!r)
|
|
11822
11840
|
return Promise.resolve();
|
|
11823
|
-
const
|
|
11841
|
+
const i = h.initializeElementFragment(r, !1).then(
|
|
11824
11842
|
() => x.restoreInitialValues(e)
|
|
11825
|
-
),
|
|
11826
|
-
return h.initialValueRestore =
|
|
11827
|
-
h.initialValueRestore =
|
|
11843
|
+
), n = h.initialValueRestore;
|
|
11844
|
+
return h.initialValueRestore = i, i.then(() => {
|
|
11845
|
+
h.initialValueRestore = n, t && te.applySubtree(e);
|
|
11828
11846
|
});
|
|
11829
11847
|
}
|
|
11848
|
+
/**
|
|
11849
|
+
* 非表示から表示へ切り替わった分岐へ、外部ライブラリ連携を適用します。
|
|
11850
|
+
*
|
|
11851
|
+
* 表示と同じ更新で与えた値は、`data-each` の行が揃った後に載せ直されます
|
|
11852
|
+
* (`Core.setBindingData()` の載せ直しの段)。その前に `init` を呼ぶと、`<option>` を
|
|
11853
|
+
* 引き取る連携が値を受け取れないため、分岐の中の載せ直しを先に行います(仕様
|
|
11854
|
+
* 「`data-enhance`」の「表示と同じ更新で与えた値も、`data-each` が描いた選択肢へ
|
|
11855
|
+
* 載ってから呼びます」、課題 55)。
|
|
11856
|
+
*
|
|
11857
|
+
* @param fragment 表示へ切り替わった `data-if` のフラグメント
|
|
11858
|
+
* @param sequence 表示の評価を始めた時点の初期化の通番。これより後に初期化された
|
|
11859
|
+
* 入力欄へは載せ直しません
|
|
11860
|
+
* @returns 適用の完了 Promise
|
|
11861
|
+
*/
|
|
11862
|
+
static applyEnhancersOnShow(e, t) {
|
|
11863
|
+
const r = e.getTarget();
|
|
11864
|
+
return w.retryUnappliedValueWrites(r, t).then(
|
|
11865
|
+
() => {
|
|
11866
|
+
te.applySubtree(r);
|
|
11867
|
+
}
|
|
11868
|
+
);
|
|
11869
|
+
}
|
|
11830
11870
|
/**
|
|
11831
11871
|
* 新規 each 行を局所初期化します。
|
|
11832
11872
|
* 既存 scan の属性順序を保ちつつ、Fragment 木を直接たどります。
|
|
@@ -11836,7 +11876,7 @@ const h = class h {
|
|
|
11836
11876
|
*/
|
|
11837
11877
|
static initializeFreshEachRow(e) {
|
|
11838
11878
|
return h.initializeElementFragment(e, !0).then(() => {
|
|
11839
|
-
h.needsScheduledEvaluateAll(e) && h.scheduleEvaluateAll(e),
|
|
11879
|
+
h.needsScheduledEvaluateAll(e) && h.scheduleEvaluateAll(e), te.applySubtree(e.getTarget());
|
|
11840
11880
|
});
|
|
11841
11881
|
}
|
|
11842
11882
|
/**
|
|
@@ -12544,25 +12584,34 @@ const h = class h {
|
|
|
12544
12584
|
const i = e.hasAttribute(`${l.prefix}derive`), n = e.hasAttribute(`${l.prefix}if`), s = e.hasAttribute(`${l.prefix}each`), a = e.getRawAttribute(`${l.prefix}derive`), o = e.getRawAttribute(`${l.prefix}derive-name`);
|
|
12545
12585
|
let c = !1, u = !1, d = null;
|
|
12546
12586
|
if (!i && e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), !i && e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), i) {
|
|
12547
|
-
const
|
|
12587
|
+
const E = h.createDeriveInputSignature(
|
|
12548
12588
|
e,
|
|
12549
12589
|
a,
|
|
12550
12590
|
o
|
|
12551
12591
|
);
|
|
12552
|
-
|
|
12592
|
+
E === null ? (e.getDeriveInputSignature() !== null && e.setDeriveInputSignature(null), r = r.then(
|
|
12553
12593
|
() => h.evaluateDerive(e, a, o).then(
|
|
12554
12594
|
() => {
|
|
12555
12595
|
}
|
|
12556
12596
|
)
|
|
12557
|
-
)) : e.getDeriveInputSignature() !==
|
|
12597
|
+
)) : e.getDeriveInputSignature() !== E && (r = r.then(() => h.evaluateDerive(
|
|
12558
12598
|
e,
|
|
12559
12599
|
a,
|
|
12560
12600
|
o
|
|
12561
12601
|
).then(() => {
|
|
12562
|
-
e.setDeriveInputSignature(
|
|
12602
|
+
e.setDeriveInputSignature(E);
|
|
12563
12603
|
})));
|
|
12564
12604
|
}
|
|
12565
|
-
|
|
12605
|
+
let p = !1, y = 0;
|
|
12606
|
+
return n && (r = r.then(() => {
|
|
12607
|
+
const E = e.isVisible();
|
|
12608
|
+
return y = w.currentSequence(), h.evaluateIf(e).then(() => {
|
|
12609
|
+
p = !E && e.isVisible();
|
|
12610
|
+
});
|
|
12611
|
+
})), s ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => h.evaluateEachFixedChildren(e)).then(() => h.evaluateEach(e)).then(() => {
|
|
12612
|
+
if (p)
|
|
12613
|
+
return h.applyEnhancersOnShow(e, y);
|
|
12614
|
+
})) : n ? (e.getDeriveSubtreeSignature() !== null && e.setDeriveSubtreeSignature(null), r.then(() => {
|
|
12566
12615
|
})) : (i && (r = r.then(() => {
|
|
12567
12616
|
if (!h.canSkipStableDerivedSubtree(e)) {
|
|
12568
12617
|
e.setDeriveSubtreeSignature(null), h.logDerivedSubtreeProfileSnapshot(e, "skip-ineligible");
|
|
@@ -12578,14 +12627,14 @@ const h = class h {
|
|
|
12578
12627
|
})), r.then(() => {
|
|
12579
12628
|
if (c)
|
|
12580
12629
|
return;
|
|
12581
|
-
const
|
|
12582
|
-
return e.getChildren().forEach((
|
|
12583
|
-
if (
|
|
12584
|
-
if (h.canSkipUnchangedNestedEach(
|
|
12630
|
+
const E = [];
|
|
12631
|
+
return e.getChildren().forEach((A) => {
|
|
12632
|
+
if (A instanceof w) {
|
|
12633
|
+
if (h.canSkipUnchangedNestedEach(A))
|
|
12585
12634
|
return;
|
|
12586
|
-
|
|
12587
|
-
} else
|
|
12588
|
-
}), Promise.all(
|
|
12635
|
+
E.push(h.evaluateAll(A, t));
|
|
12636
|
+
} else A instanceof se && E.push(h.evaluateText(A));
|
|
12637
|
+
}), Promise.all(E).then(() => {
|
|
12589
12638
|
});
|
|
12590
12639
|
}).then(() => {
|
|
12591
12640
|
u && d !== null && e.setDeriveSubtreeSignature(d);
|
|
@@ -12752,21 +12801,25 @@ const h = class h {
|
|
|
12752
12801
|
);
|
|
12753
12802
|
else {
|
|
12754
12803
|
e.restoreFormControlsDisabledByIf();
|
|
12755
|
-
const i = e.isVisible(), n = [],
|
|
12756
|
-
e.getChildren().forEach((
|
|
12757
|
-
if (
|
|
12758
|
-
if (
|
|
12804
|
+
const i = e.isVisible(), n = w.currentSequence(), s = [], a = e.hasAttribute(`${l.prefix}each`);
|
|
12805
|
+
e.getChildren().forEach((o) => {
|
|
12806
|
+
if (o instanceof w) {
|
|
12807
|
+
if (a && !h.isEachFixedChild(o))
|
|
12759
12808
|
return;
|
|
12760
|
-
|
|
12761
|
-
|
|
12809
|
+
s.push(
|
|
12810
|
+
o.isMounted() ? h.evaluateAll(o) : h.scanElement(o.getTarget(), !1)
|
|
12762
12811
|
);
|
|
12763
|
-
} else
|
|
12812
|
+
} else o instanceof se && s.push(h.evaluateText(o));
|
|
12764
12813
|
}), t.push(
|
|
12765
12814
|
e.show().then(() => {
|
|
12766
|
-
B.show(e.getTarget()), i || (h.triggerLoadOnShow(e),
|
|
12815
|
+
B.show(e.getTarget()), i || (h.triggerLoadOnShow(e), te.refreshSubtree(e.getTarget(), !1));
|
|
12816
|
+
})
|
|
12817
|
+
), t.push(
|
|
12818
|
+
Promise.all(s).then(() => {
|
|
12819
|
+
if (!(i || a))
|
|
12820
|
+
return h.applyEnhancersOnShow(e, n);
|
|
12767
12821
|
})
|
|
12768
|
-
)
|
|
12769
|
-
}));
|
|
12822
|
+
);
|
|
12770
12823
|
}
|
|
12771
12824
|
return Promise.all(t).then(() => {
|
|
12772
12825
|
});
|
|
@@ -12860,7 +12913,7 @@ const h = class h {
|
|
|
12860
12913
|
t.rerunRequested = !1, await h.performEachUpdate(e);
|
|
12861
12914
|
while (t.rerunRequested);
|
|
12862
12915
|
const i = e.getTarget();
|
|
12863
|
-
i.setAttribute(`${l.prefix}each-done`, ""),
|
|
12916
|
+
i.setAttribute(`${l.prefix}each-done`, ""), te.refreshSubtree(i, !1), h.runEachRenderedScript(i);
|
|
12864
12917
|
} finally {
|
|
12865
12918
|
t.running = !1, t.settled = null;
|
|
12866
12919
|
}
|
|
@@ -13865,7 +13918,7 @@ const we = class we {
|
|
|
13865
13918
|
if (t.defaultPrevented || x.isResettingInternally())
|
|
13866
13919
|
return;
|
|
13867
13920
|
const r = t.target;
|
|
13868
|
-
r instanceof HTMLElement && setTimeout(() =>
|
|
13921
|
+
r instanceof HTMLElement && setTimeout(() => te.refreshSubtree(r), 0);
|
|
13869
13922
|
}, this.onChange = (t) => this.delegate(t, "change"), this.onInput = (t) => this.delegate(t, "input"), this.onLoadCapture = (t) => this.delegate(t, "load"), this.onWindowLoad = () => {
|
|
13870
13923
|
if (this.deferred) {
|
|
13871
13924
|
this.deferredProcedures.push(() => this.runWindowLoadProcedure());
|
|
@@ -14867,7 +14920,7 @@ v.CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
14867
14920
|
"state"
|
|
14868
14921
|
]), v.DEFAULT_INTERVAL_MS = 5e3, v.MIN_INTERVAL_MS = 100, v.registrations = /* @__PURE__ */ new Map(), v.visibilityListener = null;
|
|
14869
14922
|
let ve = v;
|
|
14870
|
-
const qt = "0.
|
|
14923
|
+
const qt = "0.52.0";
|
|
14871
14924
|
function Wt(b) {
|
|
14872
14925
|
typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => b()) : Promise.resolve().then(b);
|
|
14873
14926
|
}
|
|
@@ -15448,12 +15501,12 @@ const U = class U {
|
|
|
15448
15501
|
};
|
|
15449
15502
|
U._initialized = !1, U._mutationObservers = [], U._dispatcher = null, U._initialIntakes = null;
|
|
15450
15503
|
let xe = U;
|
|
15451
|
-
|
|
15504
|
+
te.setMutationCapture((b) => xe.captureMutations(b));
|
|
15452
15505
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", xe.init) : xe.init();
|
|
15453
15506
|
const jt = () => Re.waitForRenders(), Kt = Re.enhancers;
|
|
15454
15507
|
export {
|
|
15455
15508
|
M as Core,
|
|
15456
|
-
|
|
15509
|
+
te as Enhance,
|
|
15457
15510
|
l as Env,
|
|
15458
15511
|
x as Form,
|
|
15459
15512
|
I as Fragment,
|