@wcstack/state 2.2.0 → 2.3.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 +217 -2
- package/README.md +217 -2
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +232 -0
- package/dist/index.esm.js +1581 -66
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.esm.js +2 -0
- package/dist/parser.esm.js +21 -4
- package/dist/wcs-manifest.json +1 -0
- package/package.json +1 -1
package/dist/manifest.esm.js
CHANGED
|
@@ -1079,6 +1079,7 @@ const STATE_EVENT_TOKENS_NAME = "$eventTokens";
|
|
|
1079
1079
|
const STATE_ON_NAME = "$on";
|
|
1080
1080
|
const STATE_STREAMS_NAME = "$streams";
|
|
1081
1081
|
const STATE_WATCH_NAME = "$watch";
|
|
1082
|
+
const STATE_RECURSION_NAME = "$recursion";
|
|
1082
1083
|
const STATE_LIST_KEYS_NAME = "$listKeys";
|
|
1083
1084
|
const STATE_STREAM_STATUS_NAMESPACE_NAME = "$streamStatus";
|
|
1084
1085
|
const STATE_STREAM_ERROR_NAMESPACE_NAME = "$streamError";
|
|
@@ -1157,6 +1158,7 @@ function getWcsManifest() {
|
|
|
1157
1158
|
STATE_STREAMS_NAME,
|
|
1158
1159
|
STATE_WATCH_NAME,
|
|
1159
1160
|
STATE_LIST_KEYS_NAME,
|
|
1161
|
+
STATE_RECURSION_NAME,
|
|
1160
1162
|
STATE_STREAM_STATUS_NAMESPACE_NAME,
|
|
1161
1163
|
STATE_STREAM_ERROR_NAMESPACE_NAME,
|
|
1162
1164
|
],
|
package/dist/parser.esm.js
CHANGED
|
@@ -33,6 +33,17 @@ for (let i = 0; i < MAX_WILDCARD_DEPTH; i++) {
|
|
|
33
33
|
tmpIndexByIndexName[`${INDEX_PARAM_PREFIX}${i + 1}`] = i;
|
|
34
34
|
}
|
|
35
35
|
Object.freeze(tmpIndexByIndexName);
|
|
36
|
+
/**
|
|
37
|
+
* 再帰ワイルドカード。オーサリング層($recursion 宣言・getter キー・API 引数)にだけ
|
|
38
|
+
* 現れ、PathInfo には決して降ろさない — wildcardCount が不定になると ListIndex 連鎖長・
|
|
39
|
+
* $1..$n・$resolve の厳密一致・走査の段数が同時に壊れる
|
|
40
|
+
* (docs/state-recursive-path-design.md §2-1)。
|
|
41
|
+
*/
|
|
42
|
+
const RECURSION_WILDCARD = "**";
|
|
43
|
+
|
|
44
|
+
function raiseError(message) {
|
|
45
|
+
throw new Error(`[@wcstack/state] ${message}`);
|
|
46
|
+
}
|
|
36
47
|
|
|
37
48
|
const _cache = new Map();
|
|
38
49
|
/**
|
|
@@ -51,6 +62,16 @@ function getPathInfo(path) {
|
|
|
51
62
|
if (typeof pathInfo !== "undefined") {
|
|
52
63
|
return pathInfo;
|
|
53
64
|
}
|
|
65
|
+
// 再帰ワイルドカードはオーサリング層の記号で、ここへ降りてきてはならない
|
|
66
|
+
// (降ろすと wildcardCount が不定になり ListIndex 連鎖長・$1..$n・$resolve の
|
|
67
|
+
// 厳密一致・走査の段数が同時に壊れる。設計書 D2)。到達したということは、
|
|
68
|
+
// `**` を解釈しない消費者に `**` パスが渡ったということ。通常のパスはこの検査を
|
|
69
|
+
// 初回 intern のときにしか払わない(`**` パスは intern されないので読むたびに落ちる)。
|
|
70
|
+
if (path.indexOf(RECURSION_WILDCARD) !== -1) {
|
|
71
|
+
raiseError(`[wcs/recursion-unsupported] "${path}" uses "${RECURSION_WILDCARD}", which is not accepted here. ` +
|
|
72
|
+
`It is only meaningful in a $recursion declaration, in a recursive getter key, and in the path ` +
|
|
73
|
+
`argument of $getAll / $setAll — and only when the state declares a $recursion anchor.`);
|
|
74
|
+
}
|
|
54
75
|
pathInfo = Object.freeze(new PathInfo(path));
|
|
55
76
|
_cache.set(path, pathInfo);
|
|
56
77
|
return pathInfo;
|
|
@@ -219,10 +240,6 @@ function didYouMean(input, candidates) {
|
|
|
219
240
|
*/
|
|
220
241
|
const LINT_HINT = " Validate statically: npx @wcstack/lint <file>.";
|
|
221
242
|
|
|
222
|
-
function raiseError(message) {
|
|
223
|
-
throw new Error(`[@wcstack/state] ${message}`);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
243
|
const STRUCTURAL_BINDING_TYPE_SET = new Set([
|
|
227
244
|
"if",
|
|
228
245
|
"elseif",
|
package/dist/wcs-manifest.json
CHANGED
package/package.json
CHANGED