@wcstack/state 1.31.0 → 1.32.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 +124 -7
- package/README.md +126 -7
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.esm.js +970 -108
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.esm.js +28 -8
- package/dist/parser.esm.js +28 -8
- package/package.json +1 -1
package/dist/manifest.esm.js
CHANGED
|
@@ -388,16 +388,33 @@ const fix = (options) => {
|
|
|
388
388
|
/**
|
|
389
389
|
* Locale number filter - formats number according to locale.
|
|
390
390
|
*
|
|
391
|
+
* ロケール依存フィルタ(`locale` / `date` / `time` / `datetime`)は
|
|
392
|
+
* **明示引数だけを構築時に確定し、既定の `config.locale` は適用のたびに読む**。
|
|
393
|
+
*
|
|
394
|
+
* 以前は `options?.[0] ?? config.locale` を返り値の関数の**外**で解決していた。
|
|
395
|
+
* フィルタ関数はバインド構築時に一度だけ作られるので、これはロケールを
|
|
396
|
+
* クロージャに焼き込むことを意味する。`config.locale` の確定がバインド構築より
|
|
397
|
+
* 遅れると、それ以降どう直しても「同じページの中で日付だけ既定ロケール」が
|
|
398
|
+
* 永続し、しかも `config.locale` は依存グラフに載らないので再描画で回復もしない。
|
|
399
|
+
* 症状(日付だけ英語)は原因(起動順序)から遠く、追いにくい。
|
|
400
|
+
*
|
|
401
|
+
* 適用のたびに読めば、少なくとも**再適用されたバインドは回復する**。ロケールは
|
|
402
|
+
* 起動時に確定する前提(docs/i18n-design.md D1)なので通常この差は現れず、
|
|
403
|
+
* これは順序事故から復帰できるようにするための保険である。
|
|
404
|
+
*
|
|
405
|
+
* 明示引数(`|date(ja-JP)`)は構築時に固定でよい — バインド式の一部であり、
|
|
406
|
+
* 実行中に変わらない。
|
|
407
|
+
*
|
|
391
408
|
* @param options - Array with locale string as first element (default: config.locale)
|
|
392
409
|
* @returns Filter function that returns localized number string
|
|
393
410
|
*/
|
|
394
411
|
const locale = (options) => {
|
|
395
|
-
const
|
|
412
|
+
const explicit = options?.[0];
|
|
396
413
|
return (value) => {
|
|
397
414
|
if (typeof value !== 'number') {
|
|
398
415
|
valueMustBeNumber('locale');
|
|
399
416
|
}
|
|
400
|
-
return value.toLocaleString(
|
|
417
|
+
return value.toLocaleString(explicit ?? config.locale);
|
|
401
418
|
};
|
|
402
419
|
};
|
|
403
420
|
/**
|
|
@@ -710,12 +727,13 @@ const truncate = (options) => {
|
|
|
710
727
|
* @returns Filter function that returns date string
|
|
711
728
|
*/
|
|
712
729
|
const date = (options) => {
|
|
713
|
-
|
|
730
|
+
// 既定ロケールは適用のたびに読む(`locale` フィルタの注記を参照)
|
|
731
|
+
const explicit = options?.[0];
|
|
714
732
|
return (value) => {
|
|
715
733
|
if (!(value instanceof Date)) {
|
|
716
734
|
valueMustBeDate('date');
|
|
717
735
|
}
|
|
718
|
-
return value.toLocaleDateString(
|
|
736
|
+
return value.toLocaleDateString(explicit ?? config.locale);
|
|
719
737
|
};
|
|
720
738
|
};
|
|
721
739
|
/**
|
|
@@ -725,12 +743,13 @@ const date = (options) => {
|
|
|
725
743
|
* @returns Filter function that returns time string
|
|
726
744
|
*/
|
|
727
745
|
const time = (options) => {
|
|
728
|
-
|
|
746
|
+
// 既定ロケールは適用のたびに読む(`locale` フィルタの注記を参照)
|
|
747
|
+
const explicit = options?.[0];
|
|
729
748
|
return (value) => {
|
|
730
749
|
if (!(value instanceof Date)) {
|
|
731
750
|
valueMustBeDate('time');
|
|
732
751
|
}
|
|
733
|
-
return value.toLocaleTimeString(
|
|
752
|
+
return value.toLocaleTimeString(explicit ?? config.locale);
|
|
734
753
|
};
|
|
735
754
|
};
|
|
736
755
|
/**
|
|
@@ -740,12 +759,13 @@ const time = (options) => {
|
|
|
740
759
|
* @returns Filter function that returns datetime string
|
|
741
760
|
*/
|
|
742
761
|
const datetime = (options) => {
|
|
743
|
-
|
|
762
|
+
// 既定ロケールは適用のたびに読む(`locale` フィルタの注記を参照)
|
|
763
|
+
const explicit = options?.[0];
|
|
744
764
|
return (value) => {
|
|
745
765
|
if (!(value instanceof Date)) {
|
|
746
766
|
valueMustBeDate('datetime');
|
|
747
767
|
}
|
|
748
|
-
return value.toLocaleString(
|
|
768
|
+
return value.toLocaleString(explicit ?? config.locale);
|
|
749
769
|
};
|
|
750
770
|
};
|
|
751
771
|
/**
|
package/dist/parser.esm.js
CHANGED
|
@@ -614,16 +614,33 @@ const fix = (options) => {
|
|
|
614
614
|
/**
|
|
615
615
|
* Locale number filter - formats number according to locale.
|
|
616
616
|
*
|
|
617
|
+
* ロケール依存フィルタ(`locale` / `date` / `time` / `datetime`)は
|
|
618
|
+
* **明示引数だけを構築時に確定し、既定の `config.locale` は適用のたびに読む**。
|
|
619
|
+
*
|
|
620
|
+
* 以前は `options?.[0] ?? config.locale` を返り値の関数の**外**で解決していた。
|
|
621
|
+
* フィルタ関数はバインド構築時に一度だけ作られるので、これはロケールを
|
|
622
|
+
* クロージャに焼き込むことを意味する。`config.locale` の確定がバインド構築より
|
|
623
|
+
* 遅れると、それ以降どう直しても「同じページの中で日付だけ既定ロケール」が
|
|
624
|
+
* 永続し、しかも `config.locale` は依存グラフに載らないので再描画で回復もしない。
|
|
625
|
+
* 症状(日付だけ英語)は原因(起動順序)から遠く、追いにくい。
|
|
626
|
+
*
|
|
627
|
+
* 適用のたびに読めば、少なくとも**再適用されたバインドは回復する**。ロケールは
|
|
628
|
+
* 起動時に確定する前提(docs/i18n-design.md D1)なので通常この差は現れず、
|
|
629
|
+
* これは順序事故から復帰できるようにするための保険である。
|
|
630
|
+
*
|
|
631
|
+
* 明示引数(`|date(ja-JP)`)は構築時に固定でよい — バインド式の一部であり、
|
|
632
|
+
* 実行中に変わらない。
|
|
633
|
+
*
|
|
617
634
|
* @param options - Array with locale string as first element (default: config.locale)
|
|
618
635
|
* @returns Filter function that returns localized number string
|
|
619
636
|
*/
|
|
620
637
|
const locale = (options) => {
|
|
621
|
-
const
|
|
638
|
+
const explicit = options?.[0];
|
|
622
639
|
return (value) => {
|
|
623
640
|
if (typeof value !== 'number') {
|
|
624
641
|
valueMustBeNumber('locale');
|
|
625
642
|
}
|
|
626
|
-
return value.toLocaleString(
|
|
643
|
+
return value.toLocaleString(explicit ?? config.locale);
|
|
627
644
|
};
|
|
628
645
|
};
|
|
629
646
|
/**
|
|
@@ -936,12 +953,13 @@ const truncate = (options) => {
|
|
|
936
953
|
* @returns Filter function that returns date string
|
|
937
954
|
*/
|
|
938
955
|
const date = (options) => {
|
|
939
|
-
|
|
956
|
+
// 既定ロケールは適用のたびに読む(`locale` フィルタの注記を参照)
|
|
957
|
+
const explicit = options?.[0];
|
|
940
958
|
return (value) => {
|
|
941
959
|
if (!(value instanceof Date)) {
|
|
942
960
|
valueMustBeDate('date');
|
|
943
961
|
}
|
|
944
|
-
return value.toLocaleDateString(
|
|
962
|
+
return value.toLocaleDateString(explicit ?? config.locale);
|
|
945
963
|
};
|
|
946
964
|
};
|
|
947
965
|
/**
|
|
@@ -951,12 +969,13 @@ const date = (options) => {
|
|
|
951
969
|
* @returns Filter function that returns time string
|
|
952
970
|
*/
|
|
953
971
|
const time = (options) => {
|
|
954
|
-
|
|
972
|
+
// 既定ロケールは適用のたびに読む(`locale` フィルタの注記を参照)
|
|
973
|
+
const explicit = options?.[0];
|
|
955
974
|
return (value) => {
|
|
956
975
|
if (!(value instanceof Date)) {
|
|
957
976
|
valueMustBeDate('time');
|
|
958
977
|
}
|
|
959
|
-
return value.toLocaleTimeString(
|
|
978
|
+
return value.toLocaleTimeString(explicit ?? config.locale);
|
|
960
979
|
};
|
|
961
980
|
};
|
|
962
981
|
/**
|
|
@@ -966,12 +985,13 @@ const time = (options) => {
|
|
|
966
985
|
* @returns Filter function that returns datetime string
|
|
967
986
|
*/
|
|
968
987
|
const datetime = (options) => {
|
|
969
|
-
|
|
988
|
+
// 既定ロケールは適用のたびに読む(`locale` フィルタの注記を参照)
|
|
989
|
+
const explicit = options?.[0];
|
|
970
990
|
return (value) => {
|
|
971
991
|
if (!(value instanceof Date)) {
|
|
972
992
|
valueMustBeDate('datetime');
|
|
973
993
|
}
|
|
974
|
-
return value.toLocaleString(
|
|
994
|
+
return value.toLocaleString(explicit ?? config.locale);
|
|
975
995
|
};
|
|
976
996
|
};
|
|
977
997
|
/**
|
package/package.json
CHANGED