@storystick/preview 0.0.0-stage → 0.2.0-rc.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.
Files changed (245) hide show
  1. package/LICENSE +112 -0
  2. package/PUBLIC-API.md +55 -0
  3. package/README.md +42 -2
  4. package/dist/.source-hash +1 -0
  5. package/dist/authoring/runtime-contract.d.ts +89 -0
  6. package/dist/authoring/runtime-contract.js +28 -0
  7. package/dist/channel-taxonomy.d.ts +17 -0
  8. package/dist/channel-taxonomy.js +46 -0
  9. package/dist/context-command.d.ts +18 -0
  10. package/dist/context-command.js +38 -0
  11. package/dist/dev/suspicious-codeword-detector.d.ts +15 -0
  12. package/dist/dev/suspicious-codeword-detector.js +220 -0
  13. package/dist/dev/suspicious-codeword-detector.noop.d.ts +3 -0
  14. package/dist/dev/suspicious-codeword-detector.noop.js +4 -0
  15. package/dist/framework/browser-context.d.ts +2 -0
  16. package/dist/framework/browser-context.js +2 -0
  17. package/dist/framework/generation-refresh.d.ts +23 -0
  18. package/dist/framework/generation-refresh.js +82 -0
  19. package/dist/framework/generation-signal.d.ts +8 -0
  20. package/dist/framework/generation-signal.js +17 -0
  21. package/dist/framework/projection-generation-watch.d.ts +5 -0
  22. package/dist/framework/projection-generation-watch.js +53 -0
  23. package/dist/framework/render-receipt.d.ts +8 -0
  24. package/dist/framework/render-receipt.js +10 -0
  25. package/dist/framework/runtime-adapter-store.d.ts +30 -0
  26. package/dist/framework/runtime-adapter-store.js +81 -0
  27. package/dist/grant-coordinator.d.ts +53 -0
  28. package/dist/grant-coordinator.js +329 -0
  29. package/dist/grant-lifecycle.d.ts +52 -0
  30. package/dist/grant-lifecycle.js +74 -0
  31. package/dist/identity/__test-adapter.d.ts +34 -0
  32. package/dist/identity/__test-adapter.js +59 -0
  33. package/dist/identity/browser-context-gate.d.ts +4 -0
  34. package/dist/identity/browser-context-gate.js +22 -0
  35. package/dist/identity/browser-context.d.ts +13 -0
  36. package/dist/identity/browser-context.js +22 -0
  37. package/dist/identity/carriers/postmessage.d.ts +84 -0
  38. package/dist/identity/carriers/postmessage.js +177 -0
  39. package/dist/identity/carriers/storage-state.d.ts +41 -0
  40. package/dist/identity/carriers/storage-state.js +99 -0
  41. package/dist/identity/carriers/storage.d.ts +39 -0
  42. package/dist/identity/carriers/storage.js +182 -0
  43. package/dist/identity/carriers/url.d.ts +19 -0
  44. package/dist/identity/carriers/url.js +38 -0
  45. package/dist/identity/identity-state-machine.d.ts +70 -0
  46. package/dist/identity/identity-state-machine.js +244 -0
  47. package/dist/identity/identity-types.d.ts +192 -0
  48. package/dist/identity/identity-types.js +22 -0
  49. package/dist/identity/index.d.ts +18 -0
  50. package/dist/identity/index.js +16 -0
  51. package/dist/identity/preview-cookie.d.ts +9 -0
  52. package/dist/identity/preview-cookie.js +12 -0
  53. package/dist/identity/preview-draft.d.ts +6 -0
  54. package/dist/identity/preview-draft.js +25 -0
  55. package/dist/identity/preview-identity.d.ts +28 -0
  56. package/dist/identity/preview-identity.js +84 -0
  57. package/dist/identity/preview-scope.d.ts +28 -0
  58. package/dist/identity/preview-scope.js +47 -0
  59. package/dist/identity/resolver.d.ts +110 -0
  60. package/dist/identity/resolver.js +334 -0
  61. package/dist/identity/session-query.d.ts +4 -0
  62. package/dist/identity/session-query.js +19 -0
  63. package/dist/index.d.ts +90 -0
  64. package/dist/index.js +788 -0
  65. package/dist/interaction-mode.d.ts +58 -0
  66. package/dist/interaction-mode.js +93 -0
  67. package/dist/nav-handler.d.ts +95 -0
  68. package/dist/nav-handler.js +84 -0
  69. package/dist/overlay-label.d.ts +79 -0
  70. package/dist/overlay-label.js +73 -0
  71. package/dist/provenance/anchor-map.d.ts +95 -0
  72. package/dist/provenance/anchor-map.js +177 -0
  73. package/dist/provenance/carrier-plan.d.ts +51 -0
  74. package/dist/provenance/carrier-plan.js +90 -0
  75. package/dist/provenance/coded-text.d.ts +20 -0
  76. package/dist/provenance/coded-text.js +302 -0
  77. package/dist/provenance/direct-edit-locator.d.ts +29 -0
  78. package/dist/provenance/direct-edit-locator.js +218 -0
  79. package/dist/provenance/editable-leaf.d.ts +134 -0
  80. package/dist/provenance/editable-leaf.js +483 -0
  81. package/dist/provenance/editor-target.d.ts +29 -0
  82. package/dist/provenance/editor-target.js +46 -0
  83. package/dist/provenance/field-leaf-walker.d.ts +21 -0
  84. package/dist/provenance/field-leaf-walker.js +98 -0
  85. package/dist/provenance/frame-dependencies.d.ts +212 -0
  86. package/dist/provenance/frame-dependencies.js +550 -0
  87. package/dist/provenance/index.d.ts +26 -0
  88. package/dist/provenance/index.js +26 -0
  89. package/dist/provenance/local-events.d.ts +1 -0
  90. package/dist/provenance/local-events.js +1 -0
  91. package/dist/provenance/markers.d.ts +21 -0
  92. package/dist/provenance/markers.js +70 -0
  93. package/dist/provenance/multi-frame-anchor-map.d.ts +54 -0
  94. package/dist/provenance/multi-frame-anchor-map.js +109 -0
  95. package/dist/provenance/normalize.d.ts +2 -0
  96. package/dist/provenance/normalize.js +19 -0
  97. package/dist/provenance/overlay-focus-echo.d.ts +17 -0
  98. package/dist/provenance/overlay-focus-echo.js +16 -0
  99. package/dist/provenance/overlay-projection.d.ts +65 -0
  100. package/dist/provenance/overlay-projection.js +201 -0
  101. package/dist/provenance/owner-map.d.ts +55 -0
  102. package/dist/provenance/owner-map.js +239 -0
  103. package/dist/provenance/read-carrier.d.ts +22 -0
  104. package/dist/provenance/read-carrier.js +92 -0
  105. package/dist/provenance/recorder.d.ts +38 -0
  106. package/dist/provenance/recorder.js +82 -0
  107. package/dist/provenance/render-context.d.ts +106 -0
  108. package/dist/provenance/render-context.js +338 -0
  109. package/dist/provenance/reveal-contract.d.ts +44 -0
  110. package/dist/provenance/reveal-contract.js +1 -0
  111. package/dist/provenance/richtext-slice-embed-address.d.ts +20 -0
  112. package/dist/provenance/richtext-slice-embed-address.js +35 -0
  113. package/dist/provenance/runtime-script.d.ts +1 -0
  114. package/dist/provenance/runtime-script.js +2217 -0
  115. package/dist/provenance/sidecar-store.d.ts +63 -0
  116. package/dist/provenance/sidecar-store.js +151 -0
  117. package/dist/provenance/sidecar.d.ts +34 -0
  118. package/dist/provenance/sidecar.js +227 -0
  119. package/dist/provenance/slice-model.d.ts +28 -0
  120. package/dist/provenance/slice-model.js +86 -0
  121. package/dist/provenance/source-identity.d.ts +3 -0
  122. package/dist/provenance/source-identity.js +7 -0
  123. package/dist/provenance/source-map-materializer.d.ts +76 -0
  124. package/dist/provenance/source-map-materializer.js +286 -0
  125. package/dist/provenance/source-registry.d.ts +103 -0
  126. package/dist/provenance/source-registry.js +562 -0
  127. package/dist/provenance/transformed-output-gate.d.ts +161 -0
  128. package/dist/provenance/transformed-output-gate.js +171 -0
  129. package/dist/provenance/types.d.ts +102 -0
  130. package/dist/provenance/types.js +1 -0
  131. package/dist/refresh-policy.d.ts +11 -0
  132. package/dist/refresh-policy.js +14 -0
  133. package/dist/reveal-target.d.ts +8 -0
  134. package/dist/reveal-target.js +47 -0
  135. package/dist/route-paths.d.ts +11 -0
  136. package/dist/route-paths.js +14 -0
  137. package/dist/router-subscriber.d.ts +92 -0
  138. package/dist/router-subscriber.js +44 -0
  139. package/dist/runtime/anchor-types.d.ts +5 -0
  140. package/dist/runtime/anchor-types.js +1 -0
  141. package/dist/runtime/authority-store.d.ts +31 -0
  142. package/dist/runtime/authority-store.js +56 -0
  143. package/dist/runtime/boot.d.ts +52 -0
  144. package/dist/runtime/boot.js +379 -0
  145. package/dist/runtime/content-refresh.d.ts +30 -0
  146. package/dist/runtime/content-refresh.js +68 -0
  147. package/dist/runtime/emit-runtime-error.d.ts +51 -0
  148. package/dist/runtime/emit-runtime-error.js +64 -0
  149. package/dist/runtime/field-proxy.d.ts +112 -0
  150. package/dist/runtime/field-proxy.js +471 -0
  151. package/dist/runtime/form-contract-reporter.d.ts +99 -0
  152. package/dist/runtime/form-contract-reporter.js +391 -0
  153. package/dist/runtime/invalidation-adapter.d.ts +17 -0
  154. package/dist/runtime/invalidation-adapter.js +42 -0
  155. package/dist/runtime/live-query-overlay.d.ts +39 -0
  156. package/dist/runtime/live-query-overlay.js +345 -0
  157. package/dist/runtime/momentary-navigate.d.ts +16 -0
  158. package/dist/runtime/momentary-navigate.js +106 -0
  159. package/dist/runtime/observation-scheduler.d.ts +15 -0
  160. package/dist/runtime/observation-scheduler.js +42 -0
  161. package/dist/runtime/perf-metrics.d.ts +28 -0
  162. package/dist/runtime/perf-metrics.js +90 -0
  163. package/dist/runtime/preview-interaction-policy.d.ts +1 -0
  164. package/dist/runtime/preview-interaction-policy.js +103 -0
  165. package/dist/runtime/preview-overlay-painter.d.ts +27 -0
  166. package/dist/runtime/preview-overlay-painter.js +1732 -0
  167. package/dist/runtime/preview-overlay-sidecar.d.ts +26 -0
  168. package/dist/runtime/preview-overlay-sidecar.js +45 -0
  169. package/dist/runtime/preview-perspective-alignment.d.ts +15 -0
  170. package/dist/runtime/preview-perspective-alignment.js +40 -0
  171. package/dist/runtime/preview-perspective-intent-state.d.ts +23 -0
  172. package/dist/runtime/preview-perspective-intent-state.js +5 -0
  173. package/dist/runtime/preview-transition-state.d.ts +142 -0
  174. package/dist/runtime/preview-transition-state.js +257 -0
  175. package/dist/runtime/render-mode-state.d.ts +51 -0
  176. package/dist/runtime/render-mode-state.js +76 -0
  177. package/dist/runtime/request-id.d.ts +4 -0
  178. package/dist/runtime/request-id.js +8 -0
  179. package/dist/runtime/resolve-schema-field.d.ts +99 -0
  180. package/dist/runtime/resolve-schema-field.js +356 -0
  181. package/dist/runtime/runtime-error-dispatch.d.ts +23 -0
  182. package/dist/runtime/runtime-error-dispatch.js +75 -0
  183. package/dist/runtime/schema-store.d.ts +121 -0
  184. package/dist/runtime/schema-store.js +667 -0
  185. package/dist/runtime/snapshot-assembly.d.ts +104 -0
  186. package/dist/runtime/snapshot-assembly.js +553 -0
  187. package/dist/runtime/snapshot-reporter.d.ts +55 -0
  188. package/dist/runtime/snapshot-reporter.js +375 -0
  189. package/dist/runtime/standalone-overlay-controller.d.ts +33 -0
  190. package/dist/runtime/standalone-overlay-controller.js +281 -0
  191. package/dist/runtime/store.d.ts +307 -0
  192. package/dist/runtime/store.js +1026 -0
  193. package/dist/runtime/windowed-minimap-projection.d.ts +28 -0
  194. package/dist/runtime/windowed-minimap-projection.js +189 -0
  195. package/dist/runtime/workspace-shortcuts.d.ts +30 -0
  196. package/dist/runtime/workspace-shortcuts.js +188 -0
  197. package/dist/sdk-error-copy.d.ts +48 -0
  198. package/dist/sdk-error-copy.js +182 -0
  199. package/dist/select-cursor.d.ts +2 -0
  200. package/dist/select-cursor.js +23 -0
  201. package/dist/server/admission-cookie.d.ts +38 -0
  202. package/dist/server/admission-cookie.js +122 -0
  203. package/dist/server/control-client.d.ts +29 -0
  204. package/dist/server/control-client.js +22 -0
  205. package/dist/server/control-errors.d.ts +22 -0
  206. package/dist/server/control-errors.js +165 -0
  207. package/dist/server/draft-route.d.ts +12 -0
  208. package/dist/server/draft-route.js +45 -0
  209. package/dist/server/extract-token.d.ts +30 -0
  210. package/dist/server/extract-token.js +98 -0
  211. package/dist/server/grant.d.ts +128 -0
  212. package/dist/server/grant.js +395 -0
  213. package/dist/server/ordinary-read-provenance.d.ts +11 -0
  214. package/dist/server/ordinary-read-provenance.js +124 -0
  215. package/dist/server/preview-read-metadata.d.ts +10 -0
  216. package/dist/server/preview-read-metadata.js +27 -0
  217. package/dist/server/provenance-frame-builder.d.ts +53 -0
  218. package/dist/server/provenance-frame-builder.js +102 -0
  219. package/dist/server/provenance-runtime.d.ts +70 -0
  220. package/dist/server/provenance-runtime.js +46 -0
  221. package/dist/server/read-context-command.d.ts +11 -0
  222. package/dist/server/read-context-command.js +53 -0
  223. package/dist/server/read-identity.d.ts +3 -0
  224. package/dist/server/read-identity.js +63 -0
  225. package/dist/server/read-lifecycle.d.ts +17 -0
  226. package/dist/server/read-lifecycle.js +52 -0
  227. package/dist/server/render-frame-provenance.d.ts +133 -0
  228. package/dist/server/render-frame-provenance.js +676 -0
  229. package/dist/server/render-id.d.ts +15 -0
  230. package/dist/server/render-id.js +22 -0
  231. package/dist/server/route-document-provenance.d.ts +77 -0
  232. package/dist/server/route-document-provenance.js +1327 -0
  233. package/dist/server/route-session-cookie.d.ts +33 -0
  234. package/dist/server/route-session-cookie.js +54 -0
  235. package/dist/session-projections.d.ts +33 -0
  236. package/dist/session-projections.js +43 -0
  237. package/dist/session-subscriber.d.ts +124 -0
  238. package/dist/session-subscriber.js +79 -0
  239. package/dist/sha256-fallback.d.ts +30 -0
  240. package/dist/sha256-fallback.js +126 -0
  241. package/dist/types.d.ts +446 -0
  242. package/dist/types.js +85 -0
  243. package/dist/validators.d.ts +61 -0
  244. package/dist/validators.js +110 -0
  245. package/package.json +206 -3
@@ -0,0 +1,51 @@
1
+ /**
2
+ * ADR-134 §D4 + §9.T6 — SDK-side emitter for the iframe→Studio
3
+ * `storystick.preview.runtime-error` envelope.
4
+ *
5
+ * One-way iframe→Studio channel for D-category post-auth runtime
6
+ * failures (Layer1 cache unavailable, schema delivery failed, code
7
+ * version unknown — see boot.ts and schema-store.ts). Studio renders
8
+ * `severity:'warning'` as an inline band above the iframe (auto-
9
+ * dismissed) and `severity:'error'` as a full PreviewStageError panel
10
+ * takeover. The envelope rides the same validator as the auth
11
+ * envelopes ; no trust elevation.
12
+ *
13
+ * Two security properties enforced here :
14
+ *
15
+ * 1. **`runtime.*` prefix gate (§9.T6 defense in depth).** The helper
16
+ * THROWS synchronously when `code` does not start with `runtime.`.
17
+ * A customer-customized SDK shim that accidentally sends a
18
+ * non-runtime code surfaces as a visible call-site error in the
19
+ * customer's dev console instead of a silent drop. The transport
20
+ * validator independently rejects unprefixed codes (defense in
21
+ * depth — both layers needed).
22
+ *
23
+ * 2. **identity gate (§D4 chicken-and-egg).** Without a locked
24
+ * `parentOrigin`, the envelope cannot target a sane recipient —
25
+ * the caller has no proof anyone trusted is listening. We
26
+ * short-circuit (no-op) under this condition. The chicken-and-egg
27
+ * edge case is D4 itself : `identity_unresolved` cannot signal via
28
+ * this channel and falls back to Studio's `T_handshake` deadline
29
+ * observation ("iframe loaded but SDK never spoke").
30
+ *
31
+ * Pure — does not touch storage, network, or DOM. Only side effect is
32
+ * the `window.parent.postMessage` call on the happy path.
33
+ */
34
+ import type { RuntimeErrorPayload } from '@storystick/transport-allowlist';
35
+ export interface EmitRuntimeErrorOpts {
36
+ /** Must start with `runtime.` — emitter throws otherwise. */
37
+ code: string;
38
+ message: string;
39
+ severity: RuntimeErrorPayload['severity'];
40
+ retryable?: boolean;
41
+ retryNotBefore?: number;
42
+ persistence?: RuntimeErrorPayload['persistence'];
43
+ }
44
+ /**
45
+ * Build + dispatch a `storystick.preview.runtime-error` envelope to
46
+ * the locked parent origin. No-op when identity has not resolved yet
47
+ * (see §D4 chicken-and-egg). Throws synchronously on unprefixed `code`.
48
+ */
49
+ export declare function emitRuntimeError(opts: EmitRuntimeErrorOpts): void;
50
+ /** Clear one runtime diagnostic after the underlying authority recovered. */
51
+ export declare function emitRuntimeRecovered(code: string): void;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * ADR-134 §D4 + §9.T6 — SDK-side emitter for the iframe→Studio
3
+ * `storystick.preview.runtime-error` envelope.
4
+ *
5
+ * One-way iframe→Studio channel for D-category post-auth runtime
6
+ * failures (Layer1 cache unavailable, schema delivery failed, code
7
+ * version unknown — see boot.ts and schema-store.ts). Studio renders
8
+ * `severity:'warning'` as an inline band above the iframe (auto-
9
+ * dismissed) and `severity:'error'` as a full PreviewStageError panel
10
+ * takeover. The envelope rides the same validator as the auth
11
+ * envelopes ; no trust elevation.
12
+ *
13
+ * Two security properties enforced here :
14
+ *
15
+ * 1. **`runtime.*` prefix gate (§9.T6 defense in depth).** The helper
16
+ * THROWS synchronously when `code` does not start with `runtime.`.
17
+ * A customer-customized SDK shim that accidentally sends a
18
+ * non-runtime code surfaces as a visible call-site error in the
19
+ * customer's dev console instead of a silent drop. The transport
20
+ * validator independently rejects unprefixed codes (defense in
21
+ * depth — both layers needed).
22
+ *
23
+ * 2. **identity gate (§D4 chicken-and-egg).** Without a locked
24
+ * `parentOrigin`, the envelope cannot target a sane recipient —
25
+ * the caller has no proof anyone trusted is listening. We
26
+ * short-circuit (no-op) under this condition. The chicken-and-egg
27
+ * edge case is D4 itself : `identity_unresolved` cannot signal via
28
+ * this channel and falls back to Studio's `T_handshake` deadline
29
+ * observation ("iframe loaded but SDK never spoke").
30
+ *
31
+ * Pure — does not touch storage, network, or DOM. Only side effect is
32
+ * the `window.parent.postMessage` call on the happy path.
33
+ */
34
+ import { previewRuntime } from './store.js';
35
+ import { dispatchRuntimeError, dispatchRuntimeRecovered, } from './runtime-error-dispatch.js';
36
+ /**
37
+ * Build + dispatch a `storystick.preview.runtime-error` envelope to
38
+ * the locked parent origin. No-op when identity has not resolved yet
39
+ * (see §D4 chicken-and-egg). Throws synchronously on unprefixed `code`.
40
+ */
41
+ export function emitRuntimeError(opts) {
42
+ const state = previewRuntime.getState();
43
+ const identity = state.identity;
44
+ dispatchRuntimeError({
45
+ ...opts,
46
+ retryable: opts.retryable ?? false,
47
+ persistence: opts.persistence ??
48
+ (opts.severity === 'warning' ? 'transient' : 'until-recovered'),
49
+ }, {
50
+ parentOrigin: identity?.parentOrigin ?? null,
51
+ sessionId: state.sessionId,
52
+ projectId: identity?.projectId ?? null,
53
+ });
54
+ }
55
+ /** Clear one runtime diagnostic after the underlying authority recovered. */
56
+ export function emitRuntimeRecovered(code) {
57
+ const state = previewRuntime.getState();
58
+ const identity = state.identity;
59
+ dispatchRuntimeRecovered(code, {
60
+ parentOrigin: identity?.parentOrigin ?? null,
61
+ sessionId: state.sessionId,
62
+ projectId: identity?.projectId ?? null,
63
+ });
64
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * ADR-125 D3 — query-builder field Proxy + (path, value, docId) model.
3
+ *
4
+ * The parent overlay layer (PR1b) resolves a click to a field path +
5
+ * owning document. To do that **with zero developer annotation**
6
+ * (ADR-125 §6 rejects mandatory annotation / composite attrs) the SDK
7
+ * must learn, per rendered document, which canonical field path produced
8
+ * which value — and, crucially, propagate the *originating* docId across
9
+ * resolved references so a click on an author-bio fragment on an article
10
+ * page resolves to the AUTHOR document, not the article (ADR-125 §1.2 #3).
11
+ *
12
+ * `wrapWithProxy(data, docId, basePath)` returns a recursive Proxy over a
13
+ * query-builder result. Two views of the same structure are available:
14
+ *
15
+ * 1. **Lazy / precise** — the get-trap records every accessed leaf
16
+ * `{ path, value, docId }` into the module accumulator. This is the
17
+ * literal "Proxy records access" of ADR-125 D3 and is exactly the
18
+ * set the customer's component touched (sharp for client-rendered
19
+ * customers).
20
+ * 2. **Eager / structural** — `collectFieldModel()` walks registered
21
+ * roots and enumerates every leaf. Conserved deliberately as the
22
+ * field inventory primitive for the annotation model; it does not
23
+ * mutate customer DOM.
24
+ *
25
+ * docId propagation (ADR-125 D3, reuse-don't-reinvent): a resolved
26
+ * reference materialises client-side as `QueryResult.resolved[field]` —
27
+ * a child `QueryResult` whose `documentId` IS the walker's `toTargetId`
28
+ * for that ref (the Convex `_refExtractors` server walker already
29
+ * populated it; we read it, we do not re-derive a ref graph client-side).
30
+ * Crossing into `.resolved[field]` opens a NEW scope: child docId =
31
+ * `child.documentId`, path RESET to `''` (canonical paths are relative
32
+ * to the nearest `data-ss-doc`, ADR-125 D2).
33
+ *
34
+ * Canonical path grammar = ADR-068 / `_fromFieldGrammar` walker-canonical
35
+ * (the SAME grammar `data-field-path` / `refs.fromField` use, so the
36
+ * arrival service resolves Proxy-recorded paths byte-for-byte): segments
37
+ * joined by `.`, array hops `[i]`, groups FLATTENED (no group marker —
38
+ * natural object recursion already yields `hero.title`), the `QueryResult`
39
+ * `.fields` container hop STRIPPED (content root is path `''`).
40
+ *
41
+ * Production posture (ADR-125 D3 / ADR-031): `@storystick/preview` is a
42
+ * `private` package, dynamic-imported only by preview-aware adapters and
43
+ * never bundled into a production customer app. Belt-and-braces, every
44
+ * entry point is also gated on `isFieldTrackingActive()` (embedded iframe
45
+ * or explicitly activated standalone preview, non-SSR) so even if reached
46
+ * from an ordinary page it is a referential no-op — wrap
47
+ * returns its argument by reference, zero allocation, zero traps. Lane G
48
+ * asserts this explicitly.
49
+ */
50
+ /** A recorded leaf — `path` is walker-canonical, relative to `docId`'s
51
+ * `data-ss-doc` scope. `docId` is the originating document (propagated
52
+ * across resolved refs); `null` when the root carried no documentId. */
53
+ export interface TrackedField {
54
+ path: string;
55
+ value: unknown;
56
+ docId: string | null;
57
+ }
58
+ export declare function __setFieldTrackingForcedForTests(v: boolean | null): void;
59
+ export declare function isFieldTrackingActive(): boolean;
60
+ export interface RegisteredRoot {
61
+ data: unknown;
62
+ docId: string | null;
63
+ basePath: string;
64
+ }
65
+ /**
66
+ * Wrap a query-builder result. Returns `data` unchanged (by reference,
67
+ * zero allocation) when tracking is inactive or `data` is a primitive.
68
+ * Registers the root for the eager `collectFieldModel()` walk and
69
+ * returns a recursive get-trap Proxy for the lazy accessed-leaf path.
70
+ *
71
+ * `docId` scopes recorded paths; pass the document's `documentId` (or
72
+ * omit — `collectFieldModel` re-derives it when the root is itself a
73
+ * `QueryResult`). `basePath` prefixes recorded paths (a sliceZone item
74
+ * wrap passes e.g. `sections[2]`); defaults to the content root `''`.
75
+ */
76
+ export declare function wrapWithProxy<T>(data: T, docId?: string | null, basePath?: string): T;
77
+ /**
78
+ * Walk every registered root and return all canonical leaves
79
+ * `{ path, value, docId }`, deduped + bounded. RSC-safe: does not depend
80
+ * on any get-trap having fired. Resolved-ref boundaries re-scope exactly
81
+ * like the lazy path (docId = child `documentId`, path reset).
82
+ */
83
+ export declare function collectFieldModel(): TrackedField[];
84
+ /**
85
+ * ADR-126 — pure extraction of the eager walk. No module singleton, no
86
+ * `window`: callable with any explicit `RegisteredRoot[]`. Behaviour for
87
+ * the module `roots` is byte-identical to the prior `collectFieldModel`
88
+ * (a strict no-behaviour-change extraction — pinned by a parity test).
89
+ */
90
+ export declare function collectFieldModelFromRoots(rootsList: readonly RegisteredRoot[]): TrackedField[];
91
+ /** ADR-126 — drop the whole island snapshot. It reflects ONE render;
92
+ * callers replace it wholesale so a doc removed from the rendered
93
+ * context on an RSC refresh cannot linger and
94
+ * re-introduce the non-rendered-doc false-positive class γ′ exists to
95
+ * kill (cross-model /review R1, codex #2). Also called by
96
+ * `clearTrackedFields()` on the render-mode epoch bump. */
97
+ export declare function clearIslandRoots(): void;
98
+ export declare function registerIslandRoots(entries: readonly unknown[]): void;
99
+ /** Accessed leaves (lazy path). The matcher prefers `collectFieldModel`
100
+ * (RSC-safe) but this stays for client-render precision + tests. */
101
+ export declare function getTrackedFields(): TrackedField[];
102
+ /**
103
+ * Hard reset — clears the accessed set AND every registered root.
104
+ * NOT called per-publish (scope-keyed `registerRoot` already bounds
105
+ * `roots` and keeps it current; a per-publish clear would race the
106
+ * customer render that registers roots). It is the test reset and the
107
+ * teardown hook a future generation-scoped reset would call if the
108
+ * model ever needs hard isolation across a doc swap (today scope-keying
109
+ * makes the swap self-correct: the new doc replaces its scope entry,
110
+ * cross-model /review P1 fix).
111
+ */
112
+ export declare function clearTrackedFields(): void;