@wcstack/state 3.1.0 → 3.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 +128 -90
- package/README.md +129 -91
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/define.d.ts +11 -7
- package/dist/index.d.ts +58 -15
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/manifest.d.ts +39 -5
- package/dist/manifest.esm.js +315 -253
- package/dist/parser.d.ts +16 -2
- package/dist/parser.esm.js +223 -50
- package/dist/split/chunks/binder.js +1 -1
- package/dist/split/chunks/binder.js.map +1 -1
- package/dist/split/chunks/checkDependency.js +1 -1
- package/dist/split/chunks/declarationAliases.js +2 -0
- package/dist/split/chunks/declarationAliases.js.map +1 -0
- package/dist/split/chunks/declarationHooks.js +2 -0
- package/dist/split/chunks/declarationHooks.js.map +1 -0
- package/dist/split/chunks/featureBridge.js +2 -0
- package/dist/split/chunks/featureBridge.js.map +1 -0
- package/dist/split/chunks/filterRegistry.js +1 -1
- package/dist/split/chunks/filterRegistry.js.map +1 -1
- package/dist/split/chunks/getAllPropertyDescriptors.js +1 -1
- package/dist/split/chunks/getAllPropertyDescriptors.js.map +1 -1
- package/dist/split/chunks/lifecycleHooks.js +1 -1
- package/dist/split/chunks/pathDiagnostics.js +1 -1
- package/dist/split/chunks/pathDiagnostics.js.map +1 -1
- package/dist/split/chunks/registerComponents.js +1 -1
- package/dist/split/chunks/registerComponents.js.map +1 -1
- package/dist/split/chunks/setAll.js +1 -1
- package/dist/split/chunks/setAll.js.map +1 -1
- package/dist/split/chunks/version.js +1 -1
- package/dist/split/core.d.ts +21 -9
- package/dist/split/core.js +1 -1
- package/dist/split/core.js.map +1 -1
- package/dist/split/features/devtools.js +1 -1
- package/dist/split/features/devtools.js.map +1 -1
- package/dist/split/features/diagnostics.js +1 -1
- package/dist/split/features/diagnostics.js.map +1 -1
- package/dist/split/features/formats.js +1 -1
- package/dist/split/features/formats.js.map +1 -1
- package/dist/split/features/recursion.js +1 -1
- package/dist/split/features/recursion.js.map +1 -1
- package/dist/split/features/scopes.js +1 -1
- package/dist/split/features/scopes.js.map +1 -1
- package/dist/split/features/ssr.js +1 -1
- package/dist/split/features/ssr.js.map +1 -1
- package/dist/split/features/temporal.js +1 -1
- package/dist/split/features/temporal.js.map +1 -1
- package/dist/wcs-manifest.json +98 -44
- package/package.json +1 -1
- package/dist/split/chunks/mount.js +0 -2
- package/dist/split/chunks/mount.js.map +0 -1
- package/dist/split/chunks/watchRuntime.js +0 -2
- package/dist/split/chunks/watchRuntime.js.map +0 -1
package/dist/wcs-manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"syntax": {
|
|
4
4
|
"bindAttribute": "data-wcs",
|
|
5
5
|
"tagName": "wcs-state",
|
|
@@ -55,24 +55,25 @@
|
|
|
55
55
|
"le",
|
|
56
56
|
"gt",
|
|
57
57
|
"ge",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
58
|
+
"add",
|
|
59
|
+
"sub",
|
|
60
60
|
"mul",
|
|
61
61
|
"div",
|
|
62
62
|
"mod",
|
|
63
63
|
"abs",
|
|
64
64
|
"clamp",
|
|
65
|
-
"
|
|
65
|
+
"toFixed",
|
|
66
66
|
"locale",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
67
|
+
"upper",
|
|
68
|
+
"lower",
|
|
69
|
+
"capitalize",
|
|
70
70
|
"trim",
|
|
71
71
|
"slice",
|
|
72
72
|
"substr",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
73
|
+
"padStart",
|
|
74
|
+
"padEnd",
|
|
75
|
+
"repeat",
|
|
76
|
+
"reverse",
|
|
76
77
|
"truncate",
|
|
77
78
|
"join",
|
|
78
79
|
"int",
|
|
@@ -90,10 +91,11 @@
|
|
|
90
91
|
"falsy",
|
|
91
92
|
"truthy",
|
|
92
93
|
"defaults",
|
|
94
|
+
"coalesce",
|
|
93
95
|
"boolean",
|
|
94
96
|
"number",
|
|
95
97
|
"string",
|
|
96
|
-
"
|
|
98
|
+
"nullIfEmpty"
|
|
97
99
|
],
|
|
98
100
|
"filterMeta": {
|
|
99
101
|
"eq": {
|
|
@@ -119,12 +121,10 @@
|
|
|
119
121
|
]
|
|
120
122
|
},
|
|
121
123
|
"not": {
|
|
122
|
-
"description": "
|
|
124
|
+
"description": "真偽性を反転(falsy → true)",
|
|
123
125
|
"hasArgs": false,
|
|
124
126
|
"resultType": "boolean",
|
|
125
|
-
"acceptTypes":
|
|
126
|
-
"boolean"
|
|
127
|
-
],
|
|
127
|
+
"acceptTypes": "any",
|
|
128
128
|
"minArgs": 0,
|
|
129
129
|
"maxArgs": 0
|
|
130
130
|
},
|
|
@@ -184,27 +184,27 @@
|
|
|
184
184
|
"number"
|
|
185
185
|
]
|
|
186
186
|
},
|
|
187
|
-
"
|
|
187
|
+
"add": {
|
|
188
188
|
"description": "加算",
|
|
189
189
|
"hasArgs": true,
|
|
190
190
|
"resultType": "number",
|
|
191
191
|
"acceptTypes": [
|
|
192
192
|
"number"
|
|
193
193
|
],
|
|
194
|
-
"minArgs":
|
|
194
|
+
"minArgs": 1,
|
|
195
195
|
"maxArgs": 1,
|
|
196
196
|
"argTypes": [
|
|
197
197
|
"number"
|
|
198
198
|
]
|
|
199
199
|
},
|
|
200
|
-
"
|
|
200
|
+
"sub": {
|
|
201
201
|
"description": "減算",
|
|
202
202
|
"hasArgs": true,
|
|
203
203
|
"resultType": "number",
|
|
204
204
|
"acceptTypes": [
|
|
205
205
|
"number"
|
|
206
206
|
],
|
|
207
|
-
"minArgs":
|
|
207
|
+
"minArgs": 1,
|
|
208
208
|
"maxArgs": 1,
|
|
209
209
|
"argTypes": [
|
|
210
210
|
"number"
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
"number"
|
|
274
274
|
]
|
|
275
275
|
},
|
|
276
|
-
"
|
|
276
|
+
"toFixed": {
|
|
277
277
|
"description": "固定小数点表記",
|
|
278
278
|
"hasArgs": true,
|
|
279
279
|
"resultType": "string",
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
"string"
|
|
300
300
|
]
|
|
301
301
|
},
|
|
302
|
-
"
|
|
302
|
+
"upper": {
|
|
303
303
|
"description": "大文字に変換",
|
|
304
304
|
"hasArgs": false,
|
|
305
305
|
"resultType": "string",
|
|
@@ -309,7 +309,7 @@
|
|
|
309
309
|
"minArgs": 0,
|
|
310
310
|
"maxArgs": 0
|
|
311
311
|
},
|
|
312
|
-
"
|
|
312
|
+
"lower": {
|
|
313
313
|
"description": "小文字に変換",
|
|
314
314
|
"hasArgs": false,
|
|
315
315
|
"resultType": "string",
|
|
@@ -319,7 +319,7 @@
|
|
|
319
319
|
"minArgs": 0,
|
|
320
320
|
"maxArgs": 0
|
|
321
321
|
},
|
|
322
|
-
"
|
|
322
|
+
"capitalize": {
|
|
323
323
|
"description": "先頭文字を大文字に",
|
|
324
324
|
"hasArgs": false,
|
|
325
325
|
"resultType": "string",
|
|
@@ -360,15 +360,15 @@
|
|
|
360
360
|
"acceptTypes": [
|
|
361
361
|
"string"
|
|
362
362
|
],
|
|
363
|
-
"minArgs":
|
|
363
|
+
"minArgs": 2,
|
|
364
364
|
"maxArgs": 2,
|
|
365
365
|
"argTypes": [
|
|
366
366
|
"number",
|
|
367
367
|
"number"
|
|
368
368
|
]
|
|
369
369
|
},
|
|
370
|
-
"
|
|
371
|
-
"description": "
|
|
370
|
+
"padStart": {
|
|
371
|
+
"description": "先頭を埋める (length[,char]。char の既定は 0 — JS の既定は空白なので注意)",
|
|
372
372
|
"hasArgs": true,
|
|
373
373
|
"resultType": "string",
|
|
374
374
|
"acceptTypes": [
|
|
@@ -381,7 +381,21 @@
|
|
|
381
381
|
"string"
|
|
382
382
|
]
|
|
383
383
|
},
|
|
384
|
-
"
|
|
384
|
+
"padEnd": {
|
|
385
|
+
"description": "末尾を埋める (length[,char]。char の既定は空白 — JS と同じ)",
|
|
386
|
+
"hasArgs": true,
|
|
387
|
+
"resultType": "string",
|
|
388
|
+
"acceptTypes": [
|
|
389
|
+
"string"
|
|
390
|
+
],
|
|
391
|
+
"minArgs": 1,
|
|
392
|
+
"maxArgs": 2,
|
|
393
|
+
"argTypes": [
|
|
394
|
+
"number",
|
|
395
|
+
"string"
|
|
396
|
+
]
|
|
397
|
+
},
|
|
398
|
+
"repeat": {
|
|
385
399
|
"description": "繰り返し (count)",
|
|
386
400
|
"hasArgs": true,
|
|
387
401
|
"resultType": "string",
|
|
@@ -394,7 +408,7 @@
|
|
|
394
408
|
"number"
|
|
395
409
|
]
|
|
396
410
|
},
|
|
397
|
-
"
|
|
411
|
+
"reverse": {
|
|
398
412
|
"description": "文字順を反転",
|
|
399
413
|
"hasArgs": false,
|
|
400
414
|
"resultType": "string",
|
|
@@ -405,7 +419,7 @@
|
|
|
405
419
|
"maxArgs": 0
|
|
406
420
|
},
|
|
407
421
|
"truncate": {
|
|
408
|
-
"description": "切り詰めて省略記号 (length[,suffix])",
|
|
422
|
+
"description": "切り詰めて省略記号 (length[,suffix]。suffix の既定は … — U+2026 の 1 文字)",
|
|
409
423
|
"hasArgs": true,
|
|
410
424
|
"resultType": "string",
|
|
411
425
|
"acceptTypes": [
|
|
@@ -419,7 +433,7 @@
|
|
|
419
433
|
]
|
|
420
434
|
},
|
|
421
435
|
"join": {
|
|
422
|
-
"description": "配列を連結 ([separator])",
|
|
436
|
+
"description": "配列を連結 ([separator]。既定はカンマ + 空白)",
|
|
423
437
|
"hasArgs": true,
|
|
424
438
|
"resultType": "string",
|
|
425
439
|
"acceptTypes": [
|
|
@@ -520,31 +534,40 @@
|
|
|
520
534
|
]
|
|
521
535
|
},
|
|
522
536
|
"date": {
|
|
523
|
-
"description": "ロケール形式の日付",
|
|
524
|
-
"hasArgs":
|
|
537
|
+
"description": "ロケール形式の日付 ([locale]。既定は config.locale)",
|
|
538
|
+
"hasArgs": true,
|
|
525
539
|
"resultType": "string",
|
|
526
540
|
"acceptTypes": "any",
|
|
527
541
|
"minArgs": 0,
|
|
528
|
-
"maxArgs":
|
|
542
|
+
"maxArgs": 1,
|
|
543
|
+
"argTypes": [
|
|
544
|
+
"string"
|
|
545
|
+
]
|
|
529
546
|
},
|
|
530
547
|
"time": {
|
|
531
|
-
"description": "ロケール形式の時刻",
|
|
532
|
-
"hasArgs":
|
|
548
|
+
"description": "ロケール形式の時刻 ([locale]。既定は config.locale)",
|
|
549
|
+
"hasArgs": true,
|
|
533
550
|
"resultType": "string",
|
|
534
551
|
"acceptTypes": "any",
|
|
535
552
|
"minArgs": 0,
|
|
536
|
-
"maxArgs":
|
|
553
|
+
"maxArgs": 1,
|
|
554
|
+
"argTypes": [
|
|
555
|
+
"string"
|
|
556
|
+
]
|
|
537
557
|
},
|
|
538
558
|
"datetime": {
|
|
539
|
-
"description": "ロケール形式の日時",
|
|
540
|
-
"hasArgs":
|
|
559
|
+
"description": "ロケール形式の日時 ([locale]。既定は config.locale)",
|
|
560
|
+
"hasArgs": true,
|
|
541
561
|
"resultType": "string",
|
|
542
562
|
"acceptTypes": "any",
|
|
543
563
|
"minArgs": 0,
|
|
544
|
-
"maxArgs":
|
|
564
|
+
"maxArgs": 1,
|
|
565
|
+
"argTypes": [
|
|
566
|
+
"string"
|
|
567
|
+
]
|
|
545
568
|
},
|
|
546
569
|
"ymd": {
|
|
547
|
-
"description": "YYYY-MM-DD 形式",
|
|
570
|
+
"description": "YYYY-MM-DD 形式 ([separator]。既定は -)",
|
|
548
571
|
"hasArgs": true,
|
|
549
572
|
"resultType": "string",
|
|
550
573
|
"acceptTypes": "any",
|
|
@@ -555,7 +578,7 @@
|
|
|
555
578
|
]
|
|
556
579
|
},
|
|
557
580
|
"hms": {
|
|
558
|
-
"description": "HH:MM:SS 形式",
|
|
581
|
+
"description": "HH:MM:SS 形式 ([separator]。既定は :)",
|
|
559
582
|
"hasArgs": true,
|
|
560
583
|
"resultType": "string",
|
|
561
584
|
"acceptTypes": "any",
|
|
@@ -592,6 +615,17 @@
|
|
|
592
615
|
"any"
|
|
593
616
|
]
|
|
594
617
|
},
|
|
618
|
+
"coalesce": {
|
|
619
|
+
"description": "null / undefined の場合デフォルト値",
|
|
620
|
+
"hasArgs": true,
|
|
621
|
+
"resultType": "passthrough",
|
|
622
|
+
"acceptTypes": "any",
|
|
623
|
+
"minArgs": 1,
|
|
624
|
+
"maxArgs": 1,
|
|
625
|
+
"argTypes": [
|
|
626
|
+
"any"
|
|
627
|
+
]
|
|
628
|
+
},
|
|
595
629
|
"boolean": {
|
|
596
630
|
"description": "ブール値に変換",
|
|
597
631
|
"hasArgs": false,
|
|
@@ -616,7 +650,7 @@
|
|
|
616
650
|
"minArgs": 0,
|
|
617
651
|
"maxArgs": 0
|
|
618
652
|
},
|
|
619
|
-
"
|
|
653
|
+
"nullIfEmpty": {
|
|
620
654
|
"description": "空文字列をnullに変換",
|
|
621
655
|
"hasArgs": false,
|
|
622
656
|
"resultType": "passthrough",
|
|
@@ -627,10 +661,30 @@
|
|
|
627
661
|
"maxArgs": 0
|
|
628
662
|
}
|
|
629
663
|
},
|
|
664
|
+
"filterAliases": {
|
|
665
|
+
"inc": "add",
|
|
666
|
+
"dec": "sub",
|
|
667
|
+
"fix": "toFixed",
|
|
668
|
+
"uc": "upper",
|
|
669
|
+
"lc": "lower",
|
|
670
|
+
"cap": "capitalize",
|
|
671
|
+
"rep": "repeat",
|
|
672
|
+
"rev": "reverse",
|
|
673
|
+
"pad": "padStart",
|
|
674
|
+
"null": "nullIfEmpty"
|
|
675
|
+
},
|
|
676
|
+
"declarationAliases": {
|
|
677
|
+
"$updatedCallback": "$renderedCallback",
|
|
678
|
+
"$streams": "$stream"
|
|
679
|
+
},
|
|
680
|
+
"apiAliases": {
|
|
681
|
+
"$trackDependency": "$dependOn",
|
|
682
|
+
"$untrackDependency": "$untracked"
|
|
683
|
+
},
|
|
630
684
|
"reservedLifecycle": [
|
|
631
685
|
"$connectedCallback",
|
|
632
686
|
"$disconnectedCallback",
|
|
633
|
-
"$
|
|
687
|
+
"$renderedCallback",
|
|
634
688
|
"$errorCallback",
|
|
635
689
|
"$stateReadyCallback"
|
|
636
690
|
],
|
|
@@ -641,7 +695,7 @@
|
|
|
641
695
|
"$command",
|
|
642
696
|
"$eventTokens",
|
|
643
697
|
"$on",
|
|
644
|
-
"$
|
|
698
|
+
"$stream",
|
|
645
699
|
"$watch",
|
|
646
700
|
"$scan",
|
|
647
701
|
"$listKeys",
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{D as t,j as e,g as n,W as r,R as o}from"./pathDiagnostics.js";import{aS as s}from"./binder.js";import{r as a}from"./errorGuidance.js";function i(t,e){if(e.length>t.length)return!1;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function c(t,e){for(const n of t)if(i(e,n.innerSegments))return n;return null}function l(e,n){const r=n.slice(e.innerSegments.length);return 0===r.length?e.outerPathInfo.path:e.outerPathInfo.path+t+r.join(t)}let u=0;const d=["$watch","$streams","$scan","$listKeys","$updatedCallback","$commandTokens","$eventTokens","$on","$recursion","$errorCallback"],f=new Set;function h(t){const e=d.filter(e=>void 0!==t.stateObject[e]);for(const n of t.getterKeys)-1!==n.indexOf(o)&&e.push(`"${n}"`);if(0===e.length)return;const n=`${t.component.tagName.toLowerCase()}|${t.stateProp}`;f.has(n)||(f.add(n),console.warn(`[@wcstack/state] [wcs/mount-dollar-declaration] <${n.split("|")[0]}>.${t.stateProp} declares ${e.join(", ")}, which mounted components do not run. Declare them on the root state instead (a volume <wcs-state mount="..."> can host $watch / $listKeys / $updatedCallback; $recursion and "**" getters expand against the root tree). See docs/state-mount-design.md §4-6.`))}function m(t,e){const n=t.stateObject[e];if("function"==typeof n)try{const r=t.component[t.stateProp],o=n.call(r);o instanceof Promise&&o.catch(n=>{console.error(`[@wcstack/state] mounted <${t.component.tagName.toLowerCase()}> ${e} failed.`,n)})}catch(n){console.error(`[@wcstack/state] mounted <${t.component.tagName.toLowerCase()}> ${e} failed.`,n)}}function p(n,r,o,s,i,c=new Set){0===o.length&&a(`Cannot build a mount record without host bindings for "${r}".`);const l=[],d=new Set;let f=null;for(const n of o){const r=n.propSegments.slice(1),o=r.join(t);d.has(o)&&a("Duplicate mapping rule for web component."),d.add(o);const s={innerSegments:r,outerPathInfo:n.statePathInfo,readonly:!0===n.propModifiers?.includes(e)};l.push(s),0===r.length&&(f=s)}l.sort((t,e)=>e.innerSegments.length-t.innerSegments.length);const h=++u,m=`#m${h}`,{getterKeys:p,setterKeys:g}=function(t){const e=new Set,n=new Set,r=Object.getOwnPropertyDescriptors(t);for(const[t,o]of Object.entries(r))"function"==typeof o.get&&e.add(t),"function"==typeof o.set&&n.add(t);return{getterKeys:e,setterKeys:n}}(i),y=new Set;for(const t of l)t.innerSegments.length>0&&y.add(t.innerSegments[0]);const w={};for(const t of Object.keys(i))t.startsWith("$")||p.has(t)||g.has(t)||"function"!=typeof i[t]&&(c.has(t)||y.has(t)||(w[t]=i[t]));return{id:h,marker:m,component:n,stateProp:r,parentStateElement:s,entries:l,rootEntry:f,delta:null===f?0:f.outerPathInfo.wildcardCount,markerBasePath:null===f?m:f.outerPathInfo.path+t+m,stateObject:i,getterKeys:p,setterKeys:g,injectedKeys:c,mappedKeys:y,privateSnapshot:w,accessorBySuffixByMarkerParent:new Map,indexShiftByLoopElementPath:new Map,addedGetterPaths:new Set,exports:new Map}}function g(e){const n=e.indexOf(t);return-1===n?e:e.slice(0,n)}function y(t,e){const n=c(t.entries,e);return null===n?null:l(n,e)}function w(e,n){return e.markerBasePath+t+n}function $(e,r,o,s){let a=e.accessorBySuffixByMarkerParent.get(r);void 0===a&&(a=new Map,e.accessorBySuffixByMarkerParent.set(r,a));const i=r+t+o;a.set(o,{accessorName:s,indexShift:n(i).wildcardCount-n(s).wildcardCount}),e.getterKeys.has(s)&&(e.parentStateElement.getterPaths?.add(i),e.addedGetterPaths.add(i))}function P(t,e){return!t.injectedKeys.has(e)&&!t.mappedKeys.has(e)&&("function"==typeof t.stateObject[e]&&!t.getterKeys.has(e)||Object.prototype.hasOwnProperty.call(t.stateObject,e)&&!t.getterKeys.has(e)&&!t.setterKeys.has(e))}function k(e,n){return`Path "${n}" in <${e.component.tagName.toLowerCase()}> does not resolve: it is not an own key of the component state and no mount entry covers it (mounted prefixes: ${e.entries.filter(t=>t.innerSegments.length>0).map(e=>e.innerSegments.join(t)).join(", ")}). Mount it from the host ("${e.stateProp}: path" / "${e.stateProp}.${g(n)}: path") or declare the key on the component state.`}const S=/^\$(\d+)$/;function v(e,n){const r=n[0];if("$"===r||"#"===r)return null;if(e.getterKeys.has(n)||e.setterKeys.has(n))return null;const o=g(n);if(e.getterKeys.has(o)||e.setterKeys.has(o)||P(e,o))return null;const s=function(t,e){return c(t.entries,e)}(e,n.split(t));return null!==s&&s.readonly?s:null}function b(n,r){const o=v(n,r);if(null!==o){const s=0===o.innerSegments.length?"":t+o.innerSegments.join(t);a(`[wcs/mount-readonly] <${n.component.tagName.toLowerCase()}> cannot write "${r}": it is mounted read-only ("${n.stateProp}${s}#${e}: ${o.outerPathInfo.path}"). Write it on the host, or drop #${e} from the mount.`)}return K(n,r)}function K(e,n){const o=n[0];if("$"===o||"#"===o)return n;if(e.getterKeys.has(n)||e.setterKeys.has(n))return function(e,n){const o=n.split(t);let s=-1;for(let t=o.length-1;t>=0;t--)if(o[t]===r){s=t;break}if(-1===s)return $(e,e.markerBasePath,n,n),w(e,n);if(P(e,o[0]))return $(e,e.markerBasePath,n,n),w(e,n);const i=o.slice(0,s+1),c=o.slice(s+1),l=y(e,i);null===l&&a(k(e,n)),0===c.length&&a(`Wildcard-terminal accessor "${n}" on mounted <${e.component.tagName.toLowerCase()}> is not supported: it translates to a marker-terminal path where the mount overlay would shadow the accessor. Declare the row value as a getter on the host tree, or back it with a component-own array (a private key makes the whole path private).`);const u=l+t+e.marker;return $(e,u,c.join(t),n),u+t+c.join(t)}(e,n);const s=g(n);if(e.getterKeys.has(s)||e.setterKeys.has(s))return w(e,n);if(P(e,s))return w(e,n);const i=y(e,n.split(t));if(null!==i)return i;a(k(e,n))}function j(o,s,a){let i;const c=S.exec(s.statePathName);if(null!==c){const t=function(t,e){if(void 0===e)return t.delta;const r=K(t,e);return n(r).wildcardCount-n(e).wildcardCount}(o,a);i=0===t?s.statePathName:`$${Number(c[1])+t}`}else if(i=K(o,s.statePathName),"for"===s.bindingType){const e=n(i).wildcardCount-s.statePathInfo.wildcardCount;o.indexShiftByLoopElementPath.set(i+t+r,e)}const l=s.propModifiers,u=null===c&&Array.isArray(l)&&!l.includes(e)&&null!==v(o,s.statePathName);return i!==s.statePathName||u?{...s,statePathName:i,statePathInfo:n(i),...u?{propModifiers:[...l,e]}:{}}:s}function x(e,n){const r=n.lastIndexOf("#");if(-1===r)return e.delta;const o=n.indexOf(t,r);if((-1===o?n.slice(r):n.slice(r,o))!==e.marker)return e.delta;const s=-1===o?n:n.slice(0,o),a=-1===o?"":n.slice(o+1),i=e.accessorBySuffixByMarkerParent.get(s)?.get(a);return void 0!==i?i.indexShift:e.delta}function M(t,e,r,o,s){if(void 0===o)return;const i=n(r).wildcardCount-n(e).wildcardCount;return 0===i?o:(s.length<i&&a(`Cannot resolve "${e}" from this mount: the mounted prefix has ${i} wildcard(s) but the host context provides only ${s.length} index(es).`),[...s.slice(0,i),...o])}const C=new WeakMap,O=new WeakMap;function N(t,e){return O.get(t)?.get(e)??null}const B=new WeakMap;const I=new FinalizationRegistry(function(t){const e=t.byMarker.get(t.marker);if(void 0!==e&&void 0===e.deref()&&t.byMarker.delete(t.marker),void 0!==t.getterPaths)for(const e of t.addedGetterPaths)t.getterPaths.delete(e)}),E=new WeakMap;function W(t){return E.get(t)??null}let L=!1;function D(t,e){L||(L=!0,s(t=>C.has(t)?t.host:null)),C.set(t,e),E.set(e,t);let n=B.get(e.parentStateElement);void 0===n&&(n=new Map,B.set(e.parentStateElement,n)),n.set(e.marker,new WeakRef(e));let r=O.get(e.component);void 0===r&&(r=new Map,O.set(e.component,r));const o=r.get(e.stateProp)!==e;r.set(e.stateProp,e),o&&I.register(e,{byMarker:n,marker:e.marker,getterPaths:e.parentStateElement.getterPaths,addedGetterPaths:e.addedGetterPaths}),e.parentStateElement.markHasMounts?.()}function G(t){return C.get(t)??null}function R(t,e){let n=t;for(;null!==n&&n!==e;){const t=C.get(n);if(void 0!==t)return t;n=n.parentNode}return C.get(e)??null}function T(t){const e=B.get(t);if(void 0===e)return[];const n=[];for(const t of e.values()){const e=t.deref();void 0!==e&&n.push(e)}return n}function z(t){const e=B.get(t);return void 0!==e&&e.size>0}function A(e,n){const r=n.lastIndexOf("#");if(-1===r)return null;const o=B.get(e);if(void 0===o)return null;const s=n.indexOf(t,r),a=-1===s?n.slice(r):n.slice(r,s),i=o.get(a);if(void 0===i)return null;const c=i.deref();return void 0===c?(o.delete(a),null):c}export{K as a,b,M as c,W as d,G as e,c as f,T as g,j as h,R as i,A as j,x as k,m as l,N as m,p as n,D as r,z as s,l as t,h as w};
|
|
2
|
-
//# sourceMappingURL=mount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sources":["../../../../../src/webComponent/mountEntries.ts","../../../../../src/webComponent/mount.ts"],"sourcesContent":["/**\n * webComponent/mountEntries.ts — マウントのエントリ表(内側接頭辞 → 外側パス)と、その一致。\n *\n * コンポーネントのマウント記録(mount.ts)とボリュームの注入口(volumeShared.ts、要件 B14③)が\n * 同じ表と同じ一致規則を使う。書き込み翻訳の単一点(要件 §3.4)はこの 2 つの関数に集まる —\n * 読み取り専用(`#ro`)の判定もエントリが持つ。\n */\nimport { IPathInfo } from \"../address/types\";\nimport { DELIMITER } from \"../define\";\n\nexport interface IMountEntry {\n /** 内側接頭辞のセグメント(ルートエントリは 0 個 — あらゆる内側パスに一致する) */\n readonly innerSegments: readonly string[];\n readonly outerPathInfo: IPathInfo;\n /**\n * `#ro` が付いたか(`state#ro: user` / `state.name#ro: user.name`、要件 B14 ①)。\n * 真なら、内側からこのエントリを通るツリーへの書き込みは拒否される(外側自身の書き込みは止めない)。\n */\n readonly readonly: boolean;\n}\n\nfunction startsWithSegments(segments: readonly string[], prefix: readonly string[]): boolean {\n if (prefix.length > segments.length) return false;\n for (let i = 0; i < prefix.length; i++) {\n if (segments[i] !== prefix[i]) return false;\n }\n return true;\n}\n\n/** 最長接頭辞のエントリ(entries は内側接頭辞の長い順に並べておくこと)。一致しなければ null。 */\nexport function findMountEntry(entries: readonly IMountEntry[], segments: readonly string[]): IMountEntry | null {\n for (const entry of entries) {\n if (startsWithSegments(segments, entry.innerSegments)) {\n return entry;\n }\n }\n return null;\n}\n\n/** 一致したエントリで内側パスを外側の絶対パスへ書き換える(`segments` は entry に一致していること)。 */\nexport function translateByMountEntry(entry: IMountEntry, segments: readonly string[]): string {\n const rest = segments.slice(entry.innerSegments.length);\n return rest.length === 0\n ? entry.outerPathInfo.path\n : entry.outerPathInfo.path + DELIMITER + rest.join(DELIMITER);\n}\n","import { getPathInfo } from \"../address/PathInfo\";\nimport { IPathInfo } from \"../address/types\";\nimport { IStateElement } from \"../components/types\";\nimport { setMountedScopeHost } from \"../list/loopContextByNode\";\nimport { DELIMITER, MODIFIER_READONLY, RECURSION_WILDCARD, WILDCARD } from \"../define\";\nimport { raiseError } from \"../raiseError\";\nimport { IBindingInfo } from \"../types\";\nimport { findMountEntry, IMountEntry, translateByMountEntry } from \"./mountEntries\";\n\n/**\n * webComponent/mount.ts — マウント記録(Phase 2・docs/state-mount-design.md §5、impl-plan §3-0)。\n *\n * v2 の不変条件「マウントされたコンポーネントのバインディングは、その位置にテンプレートを\n * 展開してパスに接頭辞を付けたものと区別できない」を、**バインディングの変換**として実装する。\n * マウントされたスコープのバインディングは登録時にここの `translateInnerPath` で\n * 親ツリーの絶対パスへ書き換えられ、以後は台帳・依存グラフ・キャッシュ・LIS・プールの\n * どれから見ても「親スコープにインラインで書かれた binding」と同一になる。\n *\n * 例外は私有キーと getter / メソッド(展開したテンプレートには存在しないもの)で、\n * これらは **予約セグメント**(D20・`#m<id>` — `#` はパス文法で書けない)を挟んだ\n * 絶対アドレスに載る。ツリーのアドレスと構造的に衝突せず、親 handler のオーバーレイ\n * dispatch はマーカーを含む読み書きだけに掛かる。D10(スコープ外から見えない)は\n * このアドレス空間の帰結になる。\n *\n * マーカーの位置は「ワイルドカード接頭辞の直後」:\n * - 単純な getter / 私有キー(`display` / `editing`)→ `<rootOuter>.#m.display`\n * (ルートエントリが無い部分マウントのみの形では `#m.display`)\n * - ツリーのリストの上のワイルドカード getter(`get \"children.*.label\"`、`state: group`)\n * → `group.children.*.#m.label` — ワイルドカード親がツリーのリストと一致するので、\n * ループ文脈の解決(indexByWildcardPath)と listIndex の arity が素の getter と同じに保たれる\n * - 私有配列の上のワイルドカード getter(`state = { drafts: [] }` + `get \"drafts.*.title\"`)\n * → `<rootOuter>.#m.drafts.*.title` — 配列ごと私有側に閉じる\n */\n\nexport type { IMountEntry } from \"./mountEntries\";\n\nexport interface IMountRecord {\n readonly id: number;\n /** D20 の予約セグメント(`#m<id>`) */\n readonly marker: string;\n readonly component: Element;\n readonly stateProp: string;\n readonly parentStateElement: IStateElement;\n /** マウント表(内側接頭辞の長い順 — 最長接頭辞一致は先頭ヒットで決まる) */\n readonly entries: readonly IMountEntry[];\n /** ルートエントリ(`state: path`)。無ければ null(部分マウントのみ) */\n readonly rootEntry: IMountEntry | null;\n /** Δ = ルート接頭辞のワイルドカード数(`$n` のスコープ補正が読む唯一の値) */\n readonly delta: number;\n /** 私有キー・単純 getter を載せるマーカーパス(`users.*.#m3` / `#m3`) */\n readonly markerBasePath: string;\n /** 作者の state オブジェクト(私有キー・getter・メソッドの実体) */\n readonly stateObject: Record<string, any>;\n readonly getterKeys: ReadonlySet<string>;\n readonly setterKeys: ReadonlySet<string>;\n /**\n * 完了前の親の初期適用(積み)が作者のオブジェクトに**注入した**キー\n * (webComponent/preCompletionWrites.ts)。作者のものではないので私有にしない\n * (v2 は厳格 R1: 作者が宣言した own data key は部分マウントに覆われていても私有 —\n * 設計書 §4-1 規則 2。1.x の「マッピングが勝つ」からの反転は D19 が予告済み)。\n */\n readonly injectedKeys: ReadonlySet<string>;\n /** 部分エントリが明示したキー(先頭セグメント)。同名の own data key より優先する(要件 B14 ②) */\n readonly mappedKeys: ReadonlySet<string>;\n /**\n * 私有データの初期スナップショット(own data key の浅い複製・D21)。\n * マウントインスタンス(listIndex)ごとの私有オブジェクトはここから複製される。\n */\n readonly privateSnapshot: Readonly<Record<string, unknown>>;\n /**\n * マーカーの親パス(翻訳後) → { 接尾キー → 作者のアクセサ情報 }。\n * `display` は markerBase の親に `display → display`、\n * ワイルドカード getter `\"children.*.label\"` は `group.children.*` に `label → children.*.label`。\n * `indexShift` は翻訳で増えたワイルドカード数(アクセサ内の `$n` のスコープ補正が読む)。\n * translateInnerPath のマーカー化で遅延登録され、オーバーレイの get とトラップが引く。\n */\n readonly accessorBySuffixByMarkerParent: Map<string, Map<string, IAccessorEntry>>;\n /**\n * 翻訳された `for` のループ要素パス(`groups.*.children.*`)→ 翻訳で増えた\n * ワイルドカード数。イベントハンドラの「スコープ相対の添字」(§4-4 / P2-9)が\n * 引く — 添字列の末尾から (総数 − shift) 本だけが作者の見える添字。\n * translateParsedForMount が for の翻訳時に埋める。\n */\n readonly indexShiftByLoopElementPath: Map<string, number>;\n /**\n * この記録が親の getterPaths に追加したマーカーパス(recordAccessorSuffix)。\n * 記録の恒久破棄時に cleanupCollectedMountRecord が親から回収する。\n * record の外の消費者(FinalizationRegistry の held 値)も参照するため、\n * record 本体が回収された後も held 経由で読める独立オブジェクトにしてある。\n */\n readonly addedGetterPaths: Set<string>;\n /**\n * 公開 getter(docs/state-overlay-export-design.md X2 / X3): 公開パス(マーカー無し・\n * `users.*.display`)→ マーカー親パス・接尾キー・マーカーパス。registerExports が\n * 初回登録で getter / setter キーから作る(翻訳できないアクセサは載らない)。\n */\n readonly exports: Map<string, IExportEntry>;\n}\n\nexport interface IExportEntry {\n /** マーカーで終わるパス(`users.*.#m7` — overlay.ts の「マーカー親」。accessorBySuffixByMarkerParent の鍵) */\n readonly markerTerminalPath: string;\n readonly suffix: string;\n readonly markerPath: string;\n readonly exportedPath: string;\n}\n\nexport interface IAccessorEntry {\n readonly accessorName: string;\n readonly indexShift: number;\n}\n\nlet nextMountId = 0;\n\nconst MOUNT_DOLLAR_DECLARATIONS = [\n \"$watch\", \"$streams\", \"$scan\", \"$listKeys\", \"$updatedCallback\", \"$commandTokens\", \"$eventTokens\", \"$on\",\n // $errorCallback もルート専用(要件 B11 — 以前は無言で無視していた)\n \"$recursion\", \"$errorCallback\",\n] as const;\nconst dollarDeclarationWarned = new Set<string>();\n\n/** テスト用: 宣言 warn の 1 回性台帳を空にする。 */\nexport function clearMountDollarWarnsForTesting(): void {\n dollarDeclarationWarned.clear();\n}\n\n/**\n * マウントされたコンポーネントは宣言面(`$watch` / `$streams` / `$listKeys` /\n * `$updatedCallback` / `$commandTokens` / `$eventTokens` / `$on`)を実行しない\n * (v1 の mapped も同じ — innerState が `$` を遮っていた)。無言に捨てず、\n * (tag, prop) につき 1 回だけ「ルート(または対応する宣言はボリューム)に宣言する」\n * 誘導を出す。テンプレート側の `$command.*` の**参照**(バインディングのパス)は\n * ルート宣言のトークンに解決される(`$` 頭のパスは翻訳しない — translateInnerPath)。\n * `$connectedCallback` / `$disconnectedCallback` / `$stateReadyCallback` は要素の\n * ライフサイクルとしてスコープごとに残る(設計書 §4-6)。\n */\nexport function warnMountedDollarDeclarations(record: IMountRecord): void {\n const declared: string[] = MOUNT_DOLLAR_DECLARATIONS.filter(\n (name) => typeof (record.stateObject as Record<string, unknown>)[name] !== \"undefined\",\n );\n // `**` getter(`get \"node.**.total\"()`)も同じ扱い。`markerizeAccessorPath` は `*` セグメントしか\n // 探さないので `**` を含むキーは私有アンカーに落ち、参照されないまま永久に登録されない\n // (ボリュームは接ぎ木前に拒否し、`$recursion` はこの誘導が出るのに、`**` getter だけが\n // 無言だった — 第 3 サイクルのレビューで実測)。\n for (const accessor of record.getterKeys) {\n if (accessor.indexOf(RECURSION_WILDCARD) !== -1) {\n declared.push(`\"${accessor}\"`);\n }\n }\n if (declared.length === 0) {\n return;\n }\n const key = `${record.component.tagName.toLowerCase()}|${record.stateProp}`;\n if (dollarDeclarationWarned.has(key)) {\n return;\n }\n dollarDeclarationWarned.add(key);\n console.warn(\n `[@wcstack/state] [wcs/mount-dollar-declaration] <${key.split(\"|\")[0]}>.${record.stateProp} declares ` +\n `${declared.join(\", \")}, which mounted components do not run. Declare them on the root state instead ` +\n `(a volume <wcs-state mount=\"...\"> can host $watch / $listKeys / $updatedCallback; $recursion and ` +\n `\"**\" getters expand against the root tree). See docs/state-mount-design.md §4-6.`,\n );\n}\n\n/**\n * マウントされたコンポーネントのライフサイクル呼び出し(`$connectedCallback` /\n * `$disconnectedCallback`)。`this` は公開 chroot(`element[stateProp]`)。\n * 例外・reject は 1 コンポーネントに閉じる(切断時は親も切断中でありうる)。\n */\nexport function callMountLifecycleCallback(record: IMountRecord, name: string): void {\n const callback = (record.stateObject as Record<string, unknown>)[name];\n if (typeof callback !== \"function\") {\n return;\n }\n try {\n const chroot = (record.component as unknown as Record<string, unknown>)[record.stateProp];\n const result = (callback as (this: unknown) => unknown).call(chroot);\n if (result instanceof Promise) {\n result.catch((error) => {\n console.error(`[@wcstack/state] mounted <${record.component.tagName.toLowerCase()}> ${name} failed.`, error);\n });\n }\n } catch (error) {\n console.error(`[@wcstack/state] mounted <${record.component.tagName.toLowerCase()}> ${name} failed.`, error);\n }\n}\n\n/** テスト用: マーカー id を初期化する(マーカー文字列の安定化) */\nexport function resetMountIdForTesting(): void {\n nextMountId = 0;\n}\n\nfunction collectAccessorKeys(stateObject: Record<string, any>): { getterKeys: Set<string>, setterKeys: Set<string> } {\n const getterKeys = new Set<string>();\n const setterKeys = new Set<string>();\n const descriptors = Object.getOwnPropertyDescriptors(stateObject);\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (typeof descriptor.get === \"function\") getterKeys.add(key);\n if (typeof descriptor.set === \"function\") setterKeys.add(key);\n }\n return { getterKeys, setterKeys };\n}\n\n/**\n * ホストの `state[.sub]: path` バインディング群からマウント記録を組む。\n * `bindings` は propSegments[0] === stateProp で選別済みであること\n * (bindWebComponent が v1 の buildPrimaryMappingRule に渡すものと同じ集合)。\n */\nexport function buildMountRecord(\n component: Element,\n stateProp: string,\n bindings: readonly IBindingInfo[],\n parentStateElement: IStateElement,\n stateObject: Record<string, any>,\n injectedKeys: ReadonlySet<string> = new Set<string>(),\n): IMountRecord {\n if (bindings.length === 0) {\n raiseError(`Cannot build a mount record without host bindings for \"${stateProp}\".`);\n }\n const entries: IMountEntry[] = [];\n const seenInnerPaths = new Set<string>();\n let rootEntry: IMountEntry | null = null;\n for (const binding of bindings) {\n const innerSegments = binding.propSegments.slice(1);\n const innerPath = innerSegments.join(DELIMITER);\n if (seenInnerPaths.has(innerPath)) {\n // 同じ内側パスを 2 つの規則が指す形はどちらが勝つか書き手に見えない(M6・Phase 1 と同じ)\n raiseError('Duplicate mapping rule for web component.');\n }\n seenInnerPaths.add(innerPath);\n const entry: IMountEntry = {\n innerSegments,\n outerPathInfo: binding.statePathInfo,\n readonly: binding.propModifiers?.includes(MODIFIER_READONLY) === true,\n };\n entries.push(entry);\n if (innerSegments.length === 0) {\n rootEntry = entry;\n }\n }\n entries.sort((a, b) => b.innerSegments.length - a.innerSegments.length);\n const id = ++nextMountId;\n const marker = `#m${id}`;\n const { getterKeys, setterKeys } = collectAccessorKeys(stateObject);\n // ホストが部分エントリで明示したキー(`state.theme: theme`)は、同名の own data key があっても\n // 私有にしない — 明示した配線が作者の既定値に勝つ(要件 B14 ②。以前は own key が勝ち、\n // ホストの値が届かなかった)\n const mappedKeys = new Set<string>();\n for (const entry of entries) {\n if (entry.innerSegments.length > 0) mappedKeys.add(entry.innerSegments[0]);\n }\n const privateSnapshot: Record<string, unknown> = {};\n for (const key of Object.keys(stateObject)) {\n if (key.startsWith(\"$\")) continue;\n if (getterKeys.has(key) || setterKeys.has(key)) continue;\n if (typeof stateObject[key] === \"function\") continue;\n if (injectedKeys.has(key)) continue;\n if (mappedKeys.has(key)) continue;\n privateSnapshot[key] = stateObject[key];\n }\n return {\n id,\n marker,\n component,\n stateProp,\n parentStateElement,\n entries,\n rootEntry,\n delta: rootEntry === null ? 0 : rootEntry.outerPathInfo.wildcardCount,\n markerBasePath: rootEntry === null ? marker : rootEntry.outerPathInfo.path + DELIMITER + marker,\n stateObject,\n getterKeys,\n setterKeys,\n injectedKeys,\n mappedKeys,\n privateSnapshot,\n accessorBySuffixByMarkerParent: new Map(),\n indexShiftByLoopElementPath: new Map(),\n addedGetterPaths: new Set(),\n exports: new Map(),\n };\n}\n\nfunction firstSegmentOf(path: string): string {\n const dot = path.indexOf(DELIMITER);\n return dot === -1 ? path : path.slice(0, dot);\n}\n\n/** 規則 3 の一致: 最長接頭辞のエントリ(entries は長い順)。一致しなければ null。 */\nfunction findTreeEntry(record: IMountRecord, segments: readonly string[]): IMountEntry | null {\n return findMountEntry(record.entries, segments);\n}\n\n/** 規則 3: 最長接頭辞一致でツリーの絶対パスへ翻訳する。一致しなければ null。 */\nfunction translateTreePath(record: IMountRecord, segments: readonly string[]): string | null {\n const entry = findMountEntry(record.entries, segments);\n return entry === null ? null : translateByMountEntry(entry, segments);\n}\n\n/** 私有アンカー: パス全体をマーカーの下に置く(`users.*.#m.editing` / `users.*.#m.drafts.*.title`) */\nfunction markerizePrivate(record: IMountRecord, innerPath: string): string {\n return record.markerBasePath + DELIMITER + innerPath;\n}\n\n/**\n * アクセサの逆引き(マーカー親 → 接尾キー → 作者のアクセサ名と $n シフト)を登録する。\n * suffix は常に非空(ワイルドカード終端アクセサは markerizeAccessorPath が raise 済み —\n * 空を許すと trailing dot の不正パスが getterPaths に載る)。\n */\nfunction recordAccessorSuffix(record: IMountRecord, markerParentPath: string, suffix: string, accessorName: string): void {\n let bySuffix = record.accessorBySuffixByMarkerParent.get(markerParentPath);\n if (typeof bySuffix === \"undefined\") {\n bySuffix = new Map();\n record.accessorBySuffixByMarkerParent.set(markerParentPath, bySuffix);\n }\n const translatedPath = markerParentPath + DELIMITER + suffix;\n bySuffix.set(suffix, {\n accessorName,\n indexShift: getPathInfo(translatedPath).wildcardCount - getPathInfo(accessorName).wildcardCount,\n });\n if (record.getterKeys.has(accessorName)) {\n // マーカーパスを親の getterPaths に載せる。checkDependency(評価中の読み →\n // このアクセサの動的エッジ登録)と isCacheable(getter 値のキャッシュ)が\n // getterPaths を正本にしているため、載せないと再評価もキャッシュも効かない。\n // モック互換のため optional に扱う。追加分は記録の恒久破棄時に回収する\n // ため addedGetterPaths にも控える(cleanupCollectedMountRecord)。\n // suffix 空を素朴に結合すると trailing dot の不正パスになる — translatedPath を使う\n (record.parentStateElement.getterPaths as Set<string> | undefined)?.add(translatedPath);\n record.addedGetterPaths.add(translatedPath);\n }\n}\n\n/**\n * ワイルドカードを含む getter / setter のマーカー位置決め。ワイルドカード接頭辞が\n * ツリーに翻訳できるなら、その直後にマーカーを挟む(ループ文脈と listIndex の arity を\n * 素の wildcard getter と同一に保つ)。先頭セグメントが私有ならパスごと私有アンカー。\n */\nfunction markerizeAccessorPath(record: IMountRecord, innerPath: string): string {\n const segments = innerPath.split(DELIMITER);\n let lastWildcard = -1;\n for (let i = segments.length - 1; i >= 0; i--) {\n if (segments[i] === WILDCARD) {\n lastWildcard = i;\n break;\n }\n }\n if (lastWildcard === -1) {\n recordAccessorSuffix(record, record.markerBasePath, innerPath, innerPath);\n return markerizePrivate(record, innerPath);\n }\n const first = segments[0];\n if (isPrivateAnchor(record, first)) {\n recordAccessorSuffix(record, record.markerBasePath, innerPath, innerPath);\n return markerizePrivate(record, innerPath);\n }\n const treeSegments = segments.slice(0, lastWildcard + 1);\n const rest = segments.slice(lastWildcard + 1);\n const translated = translateTreePath(record, treeSegments);\n if (translated === null) {\n // 部分マウントのみで、どの接頭辞にも含まれないツリー部(§4-1 の 4b)\n raiseError(noMountEntryMessage(record, innerPath));\n }\n if (rest.length === 0) {\n // ワイルドカード終端アクセサ(行 getter `get \"tags.*\"()`)がツリーのリストへ翻訳される形:\n // 翻訳結果がマーカー終端パス(`users.*.tags.*.#m`)になり、getByAddress のオーバーレイ\n // dispatch が getter 評価より先に掛かってオーバーレイ proxy が値として返る\n // (作者の getter は評価されない)。無言で壊れる形なのでサポート外として loud に落とす\n raiseError(\n `Wildcard-terminal accessor \"${innerPath}\" on mounted <${record.component.tagName.toLowerCase()}> ` +\n `is not supported: it translates to a marker-terminal path where the mount overlay would shadow ` +\n `the accessor. Declare the row value as a getter on the host tree, or back it with a ` +\n `component-own array (a private key makes the whole path private).`,\n );\n }\n const markerParent = translated + DELIMITER + record.marker;\n recordAccessorSuffix(record, markerParent, rest.join(DELIMITER), innerPath);\n return markerParent + DELIMITER + rest.join(DELIMITER);\n}\n\n/** 先頭セグメントが「作者のもの」(own data key・メソッド。積みで注入されたキーは除く)か */\nfunction isPrivateAnchor(record: IMountRecord, firstSegment: string): boolean {\n if (record.injectedKeys.has(firstSegment) || record.mappedKeys.has(firstSegment)) {\n return false;\n }\n if (typeof record.stateObject[firstSegment] === \"function\" && !record.getterKeys.has(firstSegment)) {\n return true;\n }\n return Object.prototype.hasOwnProperty.call(record.stateObject, firstSegment)\n && !record.getterKeys.has(firstSegment)\n && !record.setterKeys.has(firstSegment);\n}\n\nfunction noMountEntryMessage(record: IMountRecord, innerPath: string): string {\n return `Path \"${innerPath}\" in <${record.component.tagName.toLowerCase()}> does not resolve: ` +\n `it is not an own key of the component state and no mount entry covers it ` +\n `(mounted prefixes: ${record.entries.filter(e => e.innerSegments.length > 0).map(e => e.innerSegments.join(DELIMITER)).join(\", \")}). ` +\n `Mount it from the host (\"${record.stateProp}: path\" / \"${record.stateProp}.${firstSegmentOf(innerPath)}: path\") or declare the key on the component state.`;\n}\n\n/**\n * コンポーネントスコープの内側パスを、親ツリーの絶対パスへ翻訳する(設計書 §4-1)。\n *\n * 1. getter / setter(完全一致・またはワイルドカード getter)→ マーカーパス(chroot 評価)\n * 2. own data key(部分規則が覆わないもの)・メソッド → マーカーパス(私有)\n * 3. それ以外 → 最長接頭辞一致でツリーへ\n * 4. 一致なし: ルートエントリがあれば必ず 3 で一致する。無ければ throw(4b)\n *\n * `$`(予約名前空間・`$1` 等)と `#`(構造プレースホルダ)で始まるパスは翻訳しない。\n */\nconst INDEX_PATH_REGEX = /^\\$(\\d+)$/;\n\n/**\n * `$n` バインディングのスコープ補正量(D9・設計書 §4-4)。\n * 囲む `for` の内側なら「その for パスが翻訳で得たワイルドカード数」— 行マウント\n * (`state: .`)の `for: tags` は `users.*.tags` になり +1、部分マウント\n * `state.items: groups.*.children` の `for: items` も +1。for の外(スコープ直下)は\n * ルート接頭辞の Δ。翻訳がワイルドカードを増やさないマウント(`state: user`)は 0。\n */\nexport function getIndexShiftForScope(record: IMountRecord, forPath: string | undefined): number {\n if (typeof forPath === \"undefined\") {\n return record.delta;\n }\n const translated = translateInnerPath(record, forPath);\n return getPathInfo(translated).wildcardCount - getPathInfo(forPath).wildcardCount;\n}\n\n/**\n * `innerPath` がツリーへ翻訳され、その先のエントリが読み取り専用(`#ro`)か(要件 B14 ①)。\n * 私有キー・アクセサ・`$` / `#` で始まるパスはコンポーネント自身のものなので対象外。\n */\nfunction isReadonlyTreePath(record: IMountRecord, innerPath: string): IMountEntry | null {\n const head = innerPath[0];\n if (head === \"$\" || head === \"#\") return null;\n if (record.getterKeys.has(innerPath) || record.setterKeys.has(innerPath)) return null;\n const first = firstSegmentOf(innerPath);\n if (record.getterKeys.has(first) || record.setterKeys.has(first) || isPrivateAnchor(record, first)) return null;\n const entry = findTreeEntry(record, innerPath.split(DELIMITER));\n return entry !== null && entry.readonly ? entry : null;\n}\n\n/**\n * 書き込みの翻訳(要件 B14 ①)。`translateInnerPath` と同じ行き先を返すが、読み取り専用で\n * マウントされたエントリ(`state#ro: user`)を通るツリーへの書き込みは名指しで拒否する。\n * コンポーネント側の書き込みの入口(`element.state`・オーバーレイ・`$setAll` / `$resolve`)が呼ぶ。\n */\nexport function translateInnerWritePath(record: IMountRecord, innerPath: string): string {\n const readonlyEntry = isReadonlyTreePath(record, innerPath);\n if (readonlyEntry !== null) {\n const suffix = readonlyEntry.innerSegments.length === 0 ? \"\" : DELIMITER + readonlyEntry.innerSegments.join(DELIMITER);\n raiseError(\n `[wcs/mount-readonly] <${record.component.tagName.toLowerCase()}> cannot write \"${innerPath}\": ` +\n `it is mounted read-only (\"${record.stateProp}${suffix}#${MODIFIER_READONLY}: ${readonlyEntry.outerPathInfo.path}\"). ` +\n `Write it on the host, or drop #${MODIFIER_READONLY} from the mount.`,\n );\n }\n return translateInnerPath(record, innerPath);\n}\n\nexport function translateInnerPath(record: IMountRecord, innerPath: string): string {\n const head = innerPath[0];\n if (head === \"$\" || head === \"#\") {\n // `$` の予約名前空間はパスとしては翻訳しない(`$n` のスコープ補正は\n // translateParsedForMount が囲む for の文脈で行う。getter 内の `this.$1` は\n // 親トラップがアクセサの indexShift で補正する)\n return innerPath;\n }\n // 規則 1: 完全一致の getter / setter(`display`・`\"children.*.label\"`)\n if (record.getterKeys.has(innerPath) || record.setterKeys.has(innerPath)) {\n return markerizeAccessorPath(record, innerPath);\n }\n const first = firstSegmentOf(innerPath);\n // 規則 1'/2: 先頭セグメントが getter / setter / メソッド / own data key → マーカー配下\n if (record.getterKeys.has(first) || record.setterKeys.has(first)) {\n return markerizePrivate(record, innerPath);\n }\n if (isPrivateAnchor(record, first)) {\n return markerizePrivate(record, innerPath);\n }\n // 規則 3: ツリー\n const translated = translateTreePath(record, innerPath.split(DELIMITER));\n if (translated !== null) {\n return translated;\n }\n // 規則 4b: 部分マウントのみで一致なし\n raiseError(noMountEntryMessage(record, innerPath));\n}\n\ninterface ITranslatable {\n readonly statePathName: string;\n readonly statePathInfo: IPathInfo;\n}\n\n/**\n * パース結果 / バインディングをマウント先の形へ変換した複製を返す\n * (パース結果キャッシュは触らない)。解決サイト(applyChangeFromBindings /\n * getAbsoluteStateAddressByBinding / fragmentInfoByUUID)は rootNode で\n * state element を引く — スコープ根は台帳エイリアスで親ツリーに到達する。\n */\nexport function translateParsedForMount<T extends ITranslatable>(record: IMountRecord, parsed: T, forPath?: string): T {\n let translated: string;\n const indexMatch = INDEX_PATH_REGEX.exec(parsed.statePathName);\n if (indexMatch !== null) {\n // `$n` はスコープ相対(D9・§4-4): 囲む for の翻訳で増えたワイルドカード数だけ繰り上げる\n const shift = getIndexShiftForScope(record, forPath);\n translated = shift === 0 ? parsed.statePathName : `$${Number(indexMatch[1]) + shift}`;\n } else {\n translated = translateInnerPath(record, parsed.statePathName);\n if ((parsed as { bindingType?: string }).bindingType === \"for\") {\n // スコープ相対の添字(P2-9)用: この for の行に立つループ文脈の要素パスと、\n // 翻訳で増えたワイルドカード数を控える。shift 0(Δ=0 の丸ごとマウント\n // `state: user` や同名翻訳の部分マウント)でも必ず載せる —\n // event/handler.ts は台帳に無いループ文脈を「外側スコープの借用行=\n // 添字 0 本」と解釈するため、登録漏れは自スコープの for の添字を\n // 丸ごと落とす(§4-4 違反)\n const shift = getPathInfo(translated).wildcardCount - parsed.statePathInfo.wildcardCount;\n record.indexShiftByLoopElementPath.set(translated + DELIMITER + WILDCARD, shift);\n }\n }\n // 読み取り専用のマウント(要件 B14 ①)を通る束縛は、要素 → state の書き戻しを止める(`#ro` と同じ)\n const modifiers = (parsed as { propModifiers?: readonly string[] }).propModifiers;\n const forceReadonly = indexMatch === null && Array.isArray(modifiers)\n && !modifiers.includes(MODIFIER_READONLY)\n && isReadonlyTreePath(record, parsed.statePathName) !== null;\n if (translated === parsed.statePathName && !forceReadonly) {\n return parsed;\n }\n return {\n ...parsed,\n statePathName: translated,\n statePathInfo: getPathInfo(translated),\n ...(forceReadonly ? { propModifiers: [...modifiers!, MODIFIER_READONLY] } : {}),\n };\n}\n\nexport function translateBindingForMount(record: IMountRecord, binding: IBindingInfo, forPath?: string): IBindingInfo {\n return translateParsedForMount(record, binding, forPath);\n}\n\n/**\n * マーカーパスのアクセサ評価中の `$n` シフト(トラップの補正が引く)。\n * アクセサとして登録されたパスならその indexShift、そうでなければルートの Δ。\n */\nexport function getIndexShiftForMarkerPath(record: IMountRecord, markerPath: string): number {\n // 末尾マーカーをセグメント単位で正確に切り出す(getMountRecordByPath と同じ規則)。\n // indexOf(record.marker) の前方一致だと `#m2` が別記録の `#m21` の中に誤ヒットし、\n // 親パスをセグメント途中で切って登録簿の照会を外す(Δ への誤フォールバック)\n const hashIndex = markerPath.lastIndexOf(\"#\");\n if (hashIndex === -1) {\n return record.delta;\n }\n const end = markerPath.indexOf(DELIMITER, hashIndex);\n const marker = end === -1 ? markerPath.slice(hashIndex) : markerPath.slice(hashIndex, end);\n if (marker !== record.marker) {\n return record.delta;\n }\n const parent = end === -1 ? markerPath : markerPath.slice(0, end);\n const suffix = end === -1 ? \"\" : markerPath.slice(end + 1);\n const entry = record.accessorBySuffixByMarkerParent.get(parent)?.get(suffix);\n return typeof entry !== \"undefined\" ? entry.indexShift : record.delta;\n}\n\n/**\n * `$getAll` / `$setAll` / `$resolve` の接頭辞翻訳(§4-6 / P2-9): 作者のスコープ相対\n * indexes の先頭に、翻訳で増えたワイルドカード分の文脈添字を合成する。\n * contextIndexes はホスト要素(chroot)またはマーカーアドレス(オーバーレイ)の\n * listIndex 添字列。プレフィックスが増えないパス(Δ=0 の翻訳)は素通し。\n */\nexport function composeMountIndexes(\n record: IMountRecord,\n innerPath: string,\n translatedPath: string,\n indexes: readonly number[] | undefined,\n contextIndexes: readonly number[],\n): readonly number[] | undefined {\n if (typeof indexes === \"undefined\") {\n return undefined;\n }\n const prefixWildcards = getPathInfo(translatedPath).wildcardCount - getPathInfo(innerPath).wildcardCount;\n if (prefixWildcards === 0) {\n return indexes;\n }\n if (contextIndexes.length < prefixWildcards) {\n raiseError(\n `Cannot resolve \"${innerPath}\" from this mount: the mounted prefix has ${prefixWildcards} wildcard(s) ` +\n `but the host context provides only ${contextIndexes.length} index(es).`,\n );\n }\n return [...contextIndexes.slice(0, prefixWildcards), ...indexes];\n}\n\n// ---------------------------------------------------------------------------\n// 登録簿\n// ---------------------------------------------------------------------------\n\n/**\n * スコープ根 → マウント記録。キーは Shadow DOM 形ならコンポーネントの shadowRoot、\n * Light DOM 形ならコンポーネント要素自身(そのサブツリーがスコープ)。\n */\nconst mountRecordByScopeRoot = new WeakMap<Node, IMountRecord>();\n\n/**\n * コンポーネント要素 → stateProp → マウント記録。\n * connectedCallback で shadow の innerHTML を張り直す作りのコンポーネントでは、\n * 再接続のたびに新しい <wcs-state> が同じ shadowRoot に入り、スコープが再初期化される。\n * 記録を要素単位で再利用することでマーカーが安定し、親側の登録簿\n * (byMarker・getterPaths)が再接続のたびに増えない。stateObject はクラスフィールド\n * なので要素と同寿命 — 記録の前提(作者のオブジェクトの同一性)が保たれる。\n */\nconst mountRecordByComponent = new WeakMap<Element, Map<string, IMountRecord>>();\n\n/** 再初期化用: この要素の stateProp に対して登録済みの記録を引く。 */\nexport function getRegisteredMountRecord(component: Element, stateProp: string): IMountRecord | null {\n return mountRecordByComponent.get(component)?.get(stateProp) ?? null;\n}\n\n/**\n * 親 state element → マーカー → マウント記録(オーバーレイ dispatch と Δ 補正が引く)。\n *\n * 値は **WeakRef**(B6)。記録への強参照は要素キーの WeakMap\n * (mountRecordByComponent / mountRecordByScopeRoot)だけが持つので、記録は\n * コンポーネント要素と同寿命になる — プール返却では要素が生きているので記録も生き、\n * 恒久破棄(route swap / `if` で捨てた形)では要素ごと回収可能になる。\n * ここを強参照にすると、長寿命の親 state 要素に破棄済み要素(と Shadow サブツリー)が\n * 際限なく蓄積する。\n */\nconst mountRecordsByStateElement = new WeakMap<IStateElement, Map<string, WeakRef<IMountRecord>>>();\n\n/** FinalizationRegistry の held 値: 記録が回収された後に台帳から掃除するもの。 */\nexport interface ICollectedMountLedgers {\n readonly byMarker: Map<string, WeakRef<IMountRecord>>;\n readonly marker: string;\n readonly getterPaths: Set<string> | undefined;\n readonly addedGetterPaths: ReadonlySet<string>;\n}\n\n/**\n * 恒久破棄されたマウント記録の台帳掃除(FinalizationRegistry のコールバック本体)。\n * マーカーは記録ごとに一意(`#m<id>` 単調増加)なので、発火時点でこのマーカーの\n * エントリは死んだ WeakRef のはず — 生きていれば触らない(防御)。\n * エクスポートしているのは GC を強制できないテスト環境で直接検証するため。\n */\nexport function cleanupCollectedMountRecord(held: ICollectedMountLedgers): void {\n const ref = held.byMarker.get(held.marker);\n if (typeof ref !== \"undefined\" && typeof ref.deref() === \"undefined\") {\n held.byMarker.delete(held.marker);\n }\n if (typeof held.getterPaths !== \"undefined\") {\n for (const path of held.addedGetterPaths) {\n held.getterPaths.delete(path);\n }\n }\n}\n\nconst collectedMountRegistry = new FinalizationRegistry<ICollectedMountLedgers>(cleanupCollectedMountRecord);\n\n/** マウント記録 → スコープ根。行 content をその場で使い回したときの張り直しが引く(#4) */\nconst scopeRootByMountRecord: WeakMap<IMountRecord, Node> = new WeakMap();\n\nexport function getScopeRootByMountRecord(record: IMountRecord): Node | null {\n return scopeRootByMountRecord.get(record) ?? null;\n}\n\n// ループ文脈の探索がマウントされた ShadowRoot でホストへ抜ける受け口(list/loopContextByNode.ts)。\n// 最初の記録の登録で 1 回だけ注入する(マウントの無いページでは探索は境界で止まったまま)\nlet scopeHostInstalled = false;\nfunction installMountedScopeHost(): void {\n if (scopeHostInstalled) return;\n scopeHostInstalled = true;\n setMountedScopeHost((root) => mountRecordByScopeRoot.has(root) ? root.host : null);\n}\n\nexport function registerMountRecord(scopeRoot: Node, record: IMountRecord): void {\n installMountedScopeHost();\n mountRecordByScopeRoot.set(scopeRoot, record);\n scopeRootByMountRecord.set(record, scopeRoot);\n let byMarker = mountRecordsByStateElement.get(record.parentStateElement);\n if (typeof byMarker === \"undefined\") {\n byMarker = new Map();\n mountRecordsByStateElement.set(record.parentStateElement, byMarker);\n }\n byMarker.set(record.marker, new WeakRef(record));\n let byProp = mountRecordByComponent.get(record.component);\n if (typeof byProp === 'undefined') {\n byProp = new Map();\n mountRecordByComponent.set(record.component, byProp);\n }\n const isFirstRegistration = byProp.get(record.stateProp) !== record;\n byProp.set(record.stateProp, record);\n if (isFirstRegistration) {\n // 恒久破棄で台帳(byMarker・親 getterPaths への追加分)を回収する(B6)。\n // 再初期化(同一 record の再登録 — マーカー安定のための再利用)では二重登録しない\n collectedMountRegistry.register(record, {\n byMarker,\n marker: record.marker,\n getterPaths: record.parentStateElement.getterPaths as Set<string> | undefined,\n addedGetterPaths: record.addedGetterPaths,\n });\n }\n // D18: マウントの無い state はオーバーレイ dispatch を boolean 1 個で抜ける\n record.parentStateElement.markHasMounts?.();\n}\n\nexport function getMountRecordByScopeRoot(scopeRoot: Node): IMountRecord | null {\n return mountRecordByScopeRoot.get(scopeRoot) ?? null;\n}\n\n/**\n * ノードから最も近いマウントスコープ根の記録を引く(event/handler.ts のスコープ相対\n * 添字が使う)。Light DOM 形はスコープ根=**コンポーネント要素自身**(D7・\n * mountScope.ts)で rootNode の内側に入れ子になりうる(Shadow 形のスコープの中の\n * Light DOM マウント)ため、**祖先を先に**辿って最初のスコープ根を探す — rootNode\n * 直ヒットを先に返すと外側の記録を取り違える。祖先に無ければ rootNode 自身\n * (Shadow DOM 形のスコープ根=shadowRoot)で引く。入れ子マウントでは\n * 最も内側(=そのノードのバインディングを翻訳した記録)が返る。\n * `hasMounts` が真のときだけ呼ぶこと(無マウントの経路にこの走査を載せない — D18)。\n */\nexport function findMountRecordForNode(node: Node, rootNode: Node): IMountRecord | null {\n let current: Node | null = node;\n while (current !== null && current !== rootNode) {\n const record = mountRecordByScopeRoot.get(current);\n if (typeof record !== \"undefined\") {\n return record;\n }\n current = current.parentNode;\n }\n return mountRecordByScopeRoot.get(rootNode) ?? null;\n}\n\n/** この state element に登録済みのマウント記録を列挙する(devtools の overlays が読む)。 */\nexport function getMountRecordsForStateElement(stateElement: IStateElement): IMountRecord[] {\n const byMarker = mountRecordsByStateElement.get(stateElement);\n if (typeof byMarker === \"undefined\") {\n return [];\n }\n const records: IMountRecord[] = [];\n for (const ref of byMarker.values()) {\n const record = ref.deref();\n if (typeof record !== \"undefined\") {\n records.push(record);\n }\n }\n return records;\n}\n\n/** 親 state element がマウントを 1 つでも持つか(D18: 無ければ dispatch は分岐 1 つで抜ける) */\nexport function stateElementHasMounts(stateElement: IStateElement): boolean {\n const byMarker = mountRecordsByStateElement.get(stateElement);\n return typeof byMarker !== \"undefined\" && byMarker.size > 0;\n}\n\n/**\n * パスに含まれるマーカーからマウント記録を引く。`hasMounts` が真のときだけ呼ぶこと。\n * `#` を含まないパス(圧倒的多数)は lastIndexOf 1 回で抜ける。\n * 入れ子マウント(外側の私有キーの上に内側マウントが載る形)ではパスに複数の\n * マーカーが並ぶ(`users.*.#m1.drafts.#m2`)— オーバーレイ dispatch と $n 補正が\n * 要るのは**末尾**のマーカーの記録なので、先頭でなく最後の `#` で切る\n * (先頭で切ると外側の記録が返り誤翻訳する)。\n */\nexport function getMountRecordByPath(stateElement: IStateElement, path: string): IMountRecord | null {\n const hashIndex = path.lastIndexOf(\"#\");\n if (hashIndex === -1) {\n return null;\n }\n const byMarker = mountRecordsByStateElement.get(stateElement);\n if (typeof byMarker === \"undefined\") {\n return null;\n }\n const end = path.indexOf(DELIMITER, hashIndex);\n const marker = end === -1 ? path.slice(hashIndex) : path.slice(hashIndex, end);\n const ref = byMarker.get(marker);\n if (typeof ref === \"undefined\") {\n return null;\n }\n const record = ref.deref();\n if (typeof record === \"undefined\") {\n // 記録は回収済み(finalizer 発火前の窓)— 遅延 prune\n byMarker.delete(marker);\n return null;\n }\n return record;\n}\n\n/** テスト用: マーカー台帳の WeakRef を差し替える(GC を強制できない環境で死んだ参照を再現する)。 */\nexport function _setMountRecordRefForTesting(\n stateElement: IStateElement,\n marker: string,\n ref: WeakRef<IMountRecord>,\n): void {\n mountRecordsByStateElement.get(stateElement)?.set(marker, ref);\n}\n"],"names":["startsWithSegments","segments","prefix","length","i","findMountEntry","entries","entry","innerSegments","translateByMountEntry","rest","slice","outerPathInfo","path","DELIMITER","join","nextMountId","MOUNT_DOLLAR_DECLARATIONS","dollarDeclarationWarned","Set","warnMountedDollarDeclarations","record","declared","filter","name","stateObject","accessor","getterKeys","indexOf","RECURSION_WILDCARD","push","key","component","tagName","toLowerCase","stateProp","has","add","console","warn","split","callMountLifecycleCallback","callback","chroot","result","call","Promise","catch","error","buildMountRecord","bindings","parentStateElement","injectedKeys","raiseError","seenInnerPaths","rootEntry","binding","propSegments","innerPath","statePathInfo","readonly","propModifiers","includes","MODIFIER_READONLY","sort","a","b","id","marker","setterKeys","descriptors","Object","getOwnPropertyDescriptors","descriptor","get","set","collectAccessorKeys","mappedKeys","privateSnapshot","keys","startsWith","delta","wildcardCount","markerBasePath","accessorBySuffixByMarkerParent","Map","indexShiftByLoopElementPath","addedGetterPaths","exports","firstSegmentOf","dot","translateTreePath","markerizePrivate","recordAccessorSuffix","markerParentPath","suffix","accessorName","bySuffix","translatedPath","indexShift","getPathInfo","getterPaths","isPrivateAnchor","firstSegment","prototype","hasOwnProperty","noMountEntryMessage","e","map","INDEX_PATH_REGEX","isReadonlyTreePath","head","first","findTreeEntry","translateInnerWritePath","readonlyEntry","translateInnerPath","lastWildcard","WILDCARD","treeSegments","translated","markerParent","markerizeAccessorPath","translateParsedForMount","parsed","forPath","indexMatch","exec","statePathName","shift","getIndexShiftForScope","Number","bindingType","modifiers","forceReadonly","Array","isArray","getIndexShiftForMarkerPath","markerPath","hashIndex","lastIndexOf","end","parent","composeMountIndexes","indexes","contextIndexes","prefixWildcards","mountRecordByScopeRoot","WeakMap","mountRecordByComponent","getRegisteredMountRecord","mountRecordsByStateElement","collectedMountRegistry","FinalizationRegistry","held","ref","byMarker","deref","delete","scopeRootByMountRecord","getScopeRootByMountRecord","scopeHostInstalled","registerMountRecord","scopeRoot","setMountedScopeHost","root","host","WeakRef","byProp","isFirstRegistration","register","markHasMounts","getMountRecordByScopeRoot","findMountRecordForNode","node","rootNode","current","parentNode","getMountRecordsForStateElement","stateElement","records","values","stateElementHasMounts","size","getMountRecordByPath"],"mappings":"6IAqBA,SAASA,EAAmBC,EAA6BC,GACvD,GAAIA,EAAOC,OAASF,EAASE,OAAQ,OAAO,EAC5C,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAOC,OAAQC,IACjC,GAAIH,EAASG,KAAOF,EAAOE,GAAI,OAAO,EAExC,OAAO,CACT,CAGM,SAAUC,EAAeC,EAAiCL,GAC9D,IAAK,MAAMM,KAASD,EAClB,GAAIN,EAAmBC,EAAUM,EAAMC,eACrC,OAAOD,EAGX,OAAO,IACT,CAGM,SAAUE,EAAsBF,EAAoBN,GACxD,MAAMS,EAAOT,EAASU,MAAMJ,EAAMC,cAAcL,QAChD,OAAuB,IAAhBO,EAAKP,OACRI,EAAMK,cAAcC,KACpBN,EAAMK,cAAcC,KAAOC,EAAYJ,EAAKK,KAAKD,EACvD,CCmEA,IAAIE,EAAc,EAElB,MAAMC,EAA4B,CAChC,SAAU,WAAY,QAAS,YAAa,mBAAoB,iBAAkB,eAAgB,MAElG,aAAc,kBAEVC,EAA0B,IAAIC,IAiB9B,SAAUC,EAA8BC,GAC5C,MAAMC,EAAqBL,EAA0BM,OAClDC,QAA0E,IAAzDH,EAAOI,YAAwCD,IAMnE,IAAK,MAAME,KAAYL,EAAOM,YACiB,IAAzCD,EAASE,QAAQC,IACnBP,EAASQ,KAAK,IAAIJ,MAGtB,GAAwB,IAApBJ,EAASnB,OACX,OAEF,MAAM4B,EAAM,GAAGV,EAAOW,UAAUC,QAAQC,iBAAiBb,EAAOc,YAC5DjB,EAAwBkB,IAAIL,KAGhCb,EAAwBmB,IAAIN,GAC5BO,QAAQC,KACN,oDAAoDR,EAAIS,MAAM,KAAK,OAAOnB,EAAOc,sBAC9Eb,EAASP,KAAK,wQAIrB,CAOM,SAAU0B,EAA2BpB,EAAsBG,GAC/D,MAAMkB,EAAYrB,EAAOI,YAAwCD,GACjE,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js";import{S as l,p as d,l as h,g as p,M as w,q as y,r as m}from"./pathDiagnostics.js";import{a as g,r as v}from"./getAllPropertyDescriptors.js";import{i as b}from"./filterRegistry.js";import{r as $,L as x}from"./errorGuidance.js";const I=new WeakMap,P=new Set,j=new Set;function k(t){return t.byFromPath.size>0||t.byResetPath.size>0}function O(t,e,n){const o=t.get(e);void 0===o?t.set(e,[n]):o.push(n)}function M(t,e){E(t);const n=new Map,o=new Map,r=new Map;for(const t of e){"path"===t.source.kind&&O(n,t.source.path,t);for(const e of t.resetOn)O(o,e,t),"event"===t.source.kind&&O(r,e,t)}const s={entries:new Set(e),byFromPath:n,byResetPath:o,eventResetByPath:r};return I.set(t,s),s}function A(t){return I.get(t)}function E(t){S(t),I.delete(t)}function S(t){P.delete(t),j.delete(t)}const z=new WeakSet;let C=0;function W(t){return A(t.absolutePathInfo.stateElement)?.eventResetByPath.get(t.absolutePathInfo.pathInfo.path)}function R(t){if(0===j.size)return;if(e=t.absolutePathInfo.stateElement,!j.has(e))return;var e;const n=W(t);if(void 0!==n)for(const t of n)F(t)}function F(t){z.has(t)||(z.add(t),C++)}function D(t){return z.has(t)}function _(t){return!!z.delete(t)&&(C--,!0)}const B=/^(?:0|[1-9]\d*)$/;function G(t,e){const n=Object.getOwnPropertyDescriptor(t,e);return!0===n.enumerable&&"value"in n}function K(t){if("object"!=typeof t||null===t||Object.isFrozen(t))return null;const e=Object.getPrototypeOf(t);if(Array.isArray(t)){return e===Array.prototype&&Reflect.ownKeys(t).every(e=>"length"===e||"string"==typeof e&&B.test(e)&&G(t,e))?"array":null}return(e===Object.prototype||null===e)&&Reflect.ownKeys(t).every(e=>"string"==typeof e&&G(t,e))?"object":null}function T(t,e){const n=K(t);if(null===n)return t;const o=t,r=e.get(o);if(void 0!==r)return r;let s;s="array"===n?new Array(t.length):null===Object.getPrototypeOf(t)?Object.create(null):{},e.set(o,s);for(const t of Object.keys(o))s[t]=T(o[t],e);return s}function q(t){return T(t,new Map)}function H(t,e,n){if(Object.is(t,e))return!0;const o=K(e);if(null===o||"object"!=typeof t||null===t)return!1;const r=t,s=e;if("array"===o){if(!Array.isArray(t)||t.length!==e.length)return!1}else if(Array.isArray(t)||Object.keys(r).length!==Object.keys(s).length)return!1;if(K(t)!==o)return!1;let a=n.get(r);if(void 0===a)a=new Set,n.set(r,a);else if(a.has(s))return!0;if(a.add(s),"array"===o){for(let e=0;e<t.length;e++)if(!H(r[e],s[e],n))return!1;return!0}return Object.keys(s).every(t=>Object.prototype.hasOwnProperty.call(r,t)&&H(r[t],s[t],n))}function L(t,e){return H(t,e,new Map)}const N=new WeakMap;function J(t,e){if("function"!=typeof e)return;const n=N.get(e);void 0===n?N.set(e,new Set([t])):n.add(t)}function Q(t,e){return"function"==typeof e&&!0===N.get(e)?.has(t)}const U={"read-source":t=>`${l} could not read a "from" value for "${t}". That landing was not folded; the other landings of the batch still were.`,"read-output":t=>`${l} could not read the output "${t}". Nothing was folded or written.`,threw:t=>`${l} fold for "${t}" threw. The output was not written.`,"returned-promise":t=>`${l} fold for "${t}" returned a Promise. fold must be synchronous and return the next value; the output was not written.`,write:t=>`${l} could not write the output "${t}".`},V={"read-source":"evaluate","read-output":"evaluate",threw:"fold","returned-promise":"fold",write:"write"};function X(t,e,n){null!==d&&d({type:"state:watch-error",phase:e,path:`${l}.${t}`,error:n})}function Y(t,e,n){console.error(`[@wcstack/state] ${U[n](t)}`,e),X(t,V[n],e)}function Z(t){return null!==t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function tt(t,e){e.then(void 0,()=>{}),Y(t,new TypeError(`${l} fold for "${t}" returned a Promise. fold must be synchronous and return the next value.`),"returned-promise")}const et=new WeakSet;const nt=Symbol("wcs-stream-last-notified-uncertain"),ot=new WeakMap;function rt(t,e){return ot.get(t)?.get(e)??{status:"idle",error:null}}function st(t,e,n,o){let r=ot.get(t);void 0===r&&(r=new Map,ot.set(t,r)),r.set(e,{status:n,error:o})}function at(t,e){const n=ot.get(t);if(void 0!==n)for(const t of n.keys())e.has(t)||n.delete(t)}function it(t,e){const n=ot.get(t);if(void 0===n)return;const o=n.get(e);void 0!==o&&n.set(e,{status:"idle"===o.status?o.status:nt,error:Object.is(o.error,null)?null:nt})}const ct=new Set;function ut(t){ct.add(t)}function ft(t){ct.delete(t)}function lt(){return ct}const dt=new WeakMap;function ht(t,e){dt.set(t,e)}function pt(t){return dt.get(t)??new Map}function wt(t){ft(t);const e=dt.get(t);if(void 0!==e)for(const n of e.values())n.controller?.abort(),n.controller=null,n.status="idle",n.error=null,it(t,n.name)}function yt(t){wt(t),ft(t),dt.delete(t)}let mt=0,gt=0;function vt(t){mt=t+1}function bt(){mt=0}function $t(){mt>gt&&(gt=mt)}const xt=new WeakMap;function It(t,e,n){let o=xt.get(t);void 0===o&&(o=new Map,xt.set(t,o)),o.set(e,n)}const Pt=new Map;function jt(t,e){Pt.has(t)||Pt.set(t,e)}function kt(t){return Pt.get(t)}const Ot=new WeakMap,Mt=new WeakMap,At=new Set,Et=new Map;function St(t){return Ot.get(t)??Et}function zt(t){At.add(t),function(t){const e=I.get(t);void 0!==e&&(k(e)&&P.add(t),function(t){return t.eventResetByPath.size>0}(e)&&j.add(t))}(t)}function Ct(){return At}function Wt(t,e){let n=Mt.get(t);void 0===n&&(n=new Map,Mt.set(t,n));for(const t of e){const e=n.get(t.path);void 0===e?n.set(t.path,[t]):e.push(t)}}const Rt=new Map;function Ft(t){return Mt.get(t)??Rt}function Dt(t){0===t.length&&$(`[wcs/watch-declaration-invalid] ${h} entry name must be a non-empty state path.`),t.startsWith("$")&&$(`[wcs/watch-declaration-invalid] ${h} entry "${t}" must not start with "$" (reserved namespace).${x}`),t.includes("@")&&$(`[wcs/watch-declaration-invalid] ${h} entry "${t}" must not contain "@" — the name selector was removed in v2; watch only paths of the state tree.${x}`),t in Object.prototype&&$(`[wcs/watch-declaration-invalid] ${h} entry "${t}" must not be a property name inherited from Object.prototype (e.g. "__proto__", "constructor").`);const e=p(t);for(const n of e.segments)0===n.length&&$(`[wcs/watch-declaration-invalid] ${h} entry "${t}" has an empty path segment.${x}`);return e.wildcardCount>w&&$(`[wcs/watch-declaration-invalid] ${h} entry "${t}" exceeds the maximum wildcard depth (${w}).`),e}function _t(t,e){const n=e[h];if(void 0===n)return null;"object"==typeof n&&null!==n||$(`[wcs/watch-declaration-invalid] ${h} must be an object mapping state paths to handler functions.${x}`);const o=new Map,r=new Set;let s=0;for(const[e,a]of Object.entries(n)){"function"!=typeof a&&$(`[wcs/watch-declaration-invalid] ${h} entry "${e}" must be a function.${x}`);const n=Dt(e);o.set(e,{path:e,pathInfo:n,handler:a,order:s++}),r.add(e),t.setPathInfo(e,"prop","watch")}return function(t,e){Ot.set(t,e)}(t,o),r.size>0?r:null}const Bt={writeObserve(t,e,n,o,r){if(!r)return;const s=t.watchPaths,a=t.scanPaths;!0!==s?.has(e)&&!0!==a?.has(e)||jt(n,o)},swapped(t,e,n){var o;o=n,Pt.has(o)&&jt(e,kt(n))}};function Gt(e){for(let n=e;null!==n;n=n.parentListIndex)if(t(n))return!0;return!1}function Kt(a,i,c){const u=c.absAddress.listIndex;let f="current",l=null;for(let d=0;d<i.wildcardCount;d++){const h=a[e](n(i.wildcardParentPathInfos[d],l)),p=o(h)?.[c.indexes[d]];if(void 0===p)return"gone";const w=r(u,d,i.wildcardCount);if(p!==w&&!s(p,w)){if(t(w))return"gone";f="replaced"}l=p}return f}function Tt(t,e,n){const o=new Map;for(const r of n){const n=Kt(t,e,r);if("gone"===n)continue;const s="current"===n?1:0,a=r.indexes.join(","),i=o.get(a);(void 0===i||s>i.rank)&&o.set(a,{row:r,rank:s})}return Array.from(o.values(),t=>t.row)}const qt=Object.freeze([]);function Ht(t,e,n){let o=t.get(n);return void 0===o&&(o={stateElement:e,entry:n,rows:[],reset:!1},t.set(n,o)),o}function Lt(t,e){let n=0;for(;n<t.indexes.length-1&&t.indexes[n]===e.indexes[n];)n++;return t.indexes[n]-e.indexes[n]}function Nt(t,e){return e.has(t.stateElement)&&!0===A(t.stateElement)?.entries.has(t.entry)}function Jt(t){const{entry:e,stateElement:n}=t;"event"!==e.source.kind||e.resetOn.some(t=>Qt(n,t))||_(e)}function Qt(t,e){return i().hasQueuedPath(t,e)}function Ut(t,e){!function(t,e,n){if(0!==C)for(const o of t){const t=o.absolutePathInfo.stateElement;if(!0===e?.has(t))continue;const r=W(o);if(void 0!==r)for(const e of r)e.resetOn.some(e=>n(t,e))||_(e)}}(t,e,Qt)}function Vt(t,e,n){return 0===e.pathInfo.wildcardCount?t[e.path]:t.$resolve(e.path,n.indexes)}function Xt(t,e,n){if(!Nt(t,n))return Jt(t),null;const{stateElement:o,entry:r}=t;if(t.reset)return{group:t,next:r.initial};const s=r.source;if(function(t,e){for(const n of e.pathInfo.cumulativePaths)if(t.getterPaths.has(n))return!0;return!1}(o,s))return function(t,e,n){if(et.has(t))return;et.add(t);const o=`[wcs/scan-source-computed] ${l} entry "${e}" from "${n}" is now backed by a getter (registered after the declaration, e.g. by a volume). A getter re-evaluates whenever its inputs change, so this scan stopped folding. Fold the plain value the getter reads instead.`;console.error(`[@wcstack/state] ${o}`),X(e,"fold",new Error(o))}(r,r.name,s.path),null;if(function(t,e,n){const o=pt(t).get(e);if(void 0===o)return!1;for(const t of o.depAddresses)if(n.has(t))return!0;return!1}(o,s.pathInfo.segments[0],e))return null;const a={plan:null,failure:"read-output"};try{o.createState("readonly",e=>{const n=e[r.name],o=0===s.pathInfo.wildcardCount?t.rows:Tt(e,s.pathInfo,t.rows);a.failure="threw";const i=r.fold;let c=n;for(const t of o.sort(Lt)){let n;try{n=Vt(e,s,t)}catch(t){Y(r.name,t,"read-source");continue}const o=i(c,n,kt(t.absAddress),...t.indexes);if(Z(o))return void tt(r.name,o);c=o}Object.is(c,n)||(a.plan={group:t,next:c})})}catch(t){Y(r.name,t,a.failure)}return a.plan}function Yt(t,e){const{group:n}=t;if(!Nt(n,e))return void Jt(n);const{stateElement:o,entry:r}=n;if(!n.reset||"event"!==r.source.kind||_(r))try{o.createState("writable",e=>{const o=e[r.name];if(n.reset?!L(o,r.initial):!Object.is(o,t.next)){const o=n.reset?q(r.initial):t.next;e[r.name]=o,J(r.name,o)}})}catch(t){Y(r.name,t,"write")}}function Zt(t,e,n){if(Ut(t,e),0===P.size)return qt;const o=new Map;for(const n of t){const t=n.absolutePathInfo.stateElement;if(!e.has(t))continue;const r=A(t);if(void 0===r)continue;const s=n.absolutePathInfo.pathInfo,i=r.byFromPath.get(s.path);if(void 0!==i){let e=[];if(s.wildcardCount>0){if(null===n.listIndex)continue;e=a(n.listIndex,s.wildcardCount)}for(const r of i)Ht(o,t,r).rows.push({absAddress:n,indexes:e})}const c=r.byResetPath.get(s.path);if(void 0!==c)for(const e of c)Ht(o,t,e).reset=!0}if(0===o.size)return qt;const r=Array.from(o.values()).sort((t,e)=>t.entry.order-e.entry.order),s=[];vt(n);try{for(const n of r){const o=Xt(n,t,e);null!==o&&s.push(o)}}finally{bt()}return s}function te(t){ue(),(0!==St(t).size||0!==Ft(t).size||function(t){const e=I.get(t);return void 0!==e&&k(e)}(t))&&(zt(t),function(t){const e=[];for(const n of St(t).values())ee(t,n)&&e.push(n);for(const n of Ft(t).values())for(const o of n)ee(t,o)&&e.push(o);if(0===e.length)return;t.createState("readonly",n=>{for(const o of e)try{It(t,f(t,o.pathInfo,null),n[o.path])}catch(e){oe(t,o.path,"prime",e)}})}(t))}function ee(t,e){return 0===e.pathInfo.wildcardCount&&t.getterPaths.has(e.path)}const ne={prime:"initial evaluation of",evaluate:"evaluation of",handler:"handler for"};function oe(t,e,n,o){console.error(`[@wcstack/state] $watch ${ne[n]} "${e}" threw.`,o),null!==d&&d({type:"state:watch-error",phase:n,path:e,error:o})}function re(t){const e=Ct();try{if(0===e.size)return void Ut(t,e);const n=function(){const t=gt;return gt=0,t}();if(n>m){Ut(t,null);const e=Array.from(t,t=>t.absolutePathInfo.pathInfo.path);return console.error("[@wcstack/state] $watch chain depth limit exceeded; $scan folds and $watch handlers for this batch were skipped.",{maxDepth:m,paths:e}),void(null!==d&&d({type:"state:watch-chain-limit",maxDepth:m,paths:e}))}!function(t,e,n){if(0!==t.length){vt(n);try{for(const n of t)Yt(n,e)}finally{bt()}}}(Zt(t,e,n),e,n),function(t,e,n){const o=[];for(const n of t){const t=n.absolutePathInfo.stateElement;if(!e.has(t))continue;const r=n.absolutePathInfo.pathInfo.path,s=St(t).get(r),i=Ft(t).get(r);if(void 0===s&&void 0===i)continue;const c=void 0===s?[]:[s];void 0!==i&&c.push(...i);for(const e of c){let r=[];if(e.pathInfo.wildcardCount>0){if(null===n.listIndex)continue;r=a(n.listIndex,e.pathInfo.wildcardCount)}o.push({stateElement:t,entry:e,absAddress:n,indexes:r})}}if(0===o.length)return;o.sort(ae);const r=function(t){let e=null;for(let n=0;n<t.length;n++){const o=t[n];if(0===o.entry.pathInfo.wildcardCount)continue;const r=t[n-1];(Gt(o.absAddress.listIndex)||r?.entry===o.entry&&se(r.indexes,o.indexes))&&(e??=new Set).add(o.entry)}if(null===e)return t;const n=new Set;for(const o of e){const e=t.filter(t=>t.entry===o),r=e[0].stateElement;try{r.createState("readonly",t=>{const r=new Set(Tt(t,o.pathInfo,e));for(const t of e)r.has(t)||n.add(t)})}catch(t){oe(0,o.path,"evaluate",t);for(const t of e)n.add(t)}}return t.filter(t=>!n.has(t))}(o);vt(n);try{for(const t of r){if(!e.has(t.stateElement))continue;const n=St(t.stateElement).get(t.entry.path)===t.entry,o=!0===Ft(t.stateElement).get(t.entry.path)?.includes(t.entry);(n||o)&&ie(t)}}finally{bt()}}(t,e,n)}finally{Pt.clear()}}function se(t,e){for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function ae(t,e){if(t.entry.order!==e.entry.order)return t.entry.order-e.entry.order;const n=Math.min(t.indexes.length,e.indexes.length);for(let o=0;o<n;o++)if(t.indexes[o]!==e.indexes[o])return t.indexes[o]-e.indexes[o];return t.indexes.length-e.indexes.length}function ie(t){const{stateElement:e,entry:n,absAddress:o,indexes:r}=t,s=ee(e,n);try{e.createState("writable",t=>{let a;try{a=function(t,e,n){if(0===e.pathInfo.wildcardCount)return t[e.path];return t.$resolve(e.path,n)}(t,n,r)}catch(t){return void oe(0,n.path,"evaluate",t)}const i=s?function(t,e){return xt.get(t)?.get(e)}(e,o):kt(o);s&&It(e,o,a),null!==d&&d({type:"state:watch-fired",path:n.path,stateElement:e}),n.handler.call(t,a,i,...r)})}catch(t){oe(0,n.path,"handler",t)}}let ce=!1;function ue(){ce||(ce=!0,g("watch",Bt),v("watch",fe),c(re,y),u($t))}const fe={order:10,register(t,e){var n;n=t,At.delete(n),S(n),Ot.delete(n),function(t){xt.delete(t)}(t);const o=_t(t,e);t.setWatchPaths?.(o),null===o&&null==t.scanPaths||t.attachAddressHooks?.("watch",null!==o?h:l)},activate(t,e){b()||null==t.connectedRootNode||(null===e?!0===t.initialized:e===t.connectGeneration)&&te(t)},deactivate(t){var e;e=t,At.delete(e),S(e)}};export{te as A,E as a,q as b,_ as c,Z as d,tt as e,Y as f,A as g,D as h,L as i,ht as j,pt as k,wt as l,F as m,R as n,yt as o,at as p,ut as q,J as r,M as s,lt as t,rt as u,st as v,Q as w,ue as x,Dt as y,Wt as z};
|
|
2
|
-
//# sourceMappingURL=watchRuntime.js.map
|