@storystick/preview 0.0.0-stage → 0.2.0-rc.1
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/LICENSE +112 -0
- package/PUBLIC-API.md +56 -0
- package/README.md +42 -2
- package/dist/.source-hash +1 -0
- package/dist/authoring/runtime-contract.d.ts +92 -0
- package/dist/authoring/runtime-contract.js +28 -0
- package/dist/channel-taxonomy.d.ts +17 -0
- package/dist/channel-taxonomy.js +46 -0
- package/dist/context-command.d.ts +18 -0
- package/dist/context-command.js +38 -0
- package/dist/dev/suspicious-codeword-detector.d.ts +15 -0
- package/dist/dev/suspicious-codeword-detector.js +220 -0
- package/dist/dev/suspicious-codeword-detector.noop.d.ts +3 -0
- package/dist/dev/suspicious-codeword-detector.noop.js +4 -0
- package/dist/framework/browser-context.d.ts +2 -0
- package/dist/framework/browser-context.js +2 -0
- package/dist/framework/generation-refresh.d.ts +23 -0
- package/dist/framework/generation-refresh.js +82 -0
- package/dist/framework/generation-signal.d.ts +8 -0
- package/dist/framework/generation-signal.js +17 -0
- package/dist/framework/projection-generation-watch.d.ts +5 -0
- package/dist/framework/projection-generation-watch.js +53 -0
- package/dist/framework/render-receipt.d.ts +8 -0
- package/dist/framework/render-receipt.js +10 -0
- package/dist/framework/runtime-adapter-store.d.ts +30 -0
- package/dist/framework/runtime-adapter-store.js +81 -0
- package/dist/grant-coordinator.d.ts +53 -0
- package/dist/grant-coordinator.js +329 -0
- package/dist/grant-lifecycle.d.ts +52 -0
- package/dist/grant-lifecycle.js +74 -0
- package/dist/identity/__test-adapter.d.ts +34 -0
- package/dist/identity/__test-adapter.js +59 -0
- package/dist/identity/browser-context-gate.d.ts +4 -0
- package/dist/identity/browser-context-gate.js +22 -0
- package/dist/identity/browser-context.d.ts +13 -0
- package/dist/identity/browser-context.js +22 -0
- package/dist/identity/carriers/postmessage.d.ts +84 -0
- package/dist/identity/carriers/postmessage.js +177 -0
- package/dist/identity/carriers/storage-state.d.ts +41 -0
- package/dist/identity/carriers/storage-state.js +99 -0
- package/dist/identity/carriers/storage.d.ts +39 -0
- package/dist/identity/carriers/storage.js +182 -0
- package/dist/identity/carriers/url.d.ts +19 -0
- package/dist/identity/carriers/url.js +38 -0
- package/dist/identity/identity-state-machine.d.ts +70 -0
- package/dist/identity/identity-state-machine.js +244 -0
- package/dist/identity/identity-types.d.ts +192 -0
- package/dist/identity/identity-types.js +22 -0
- package/dist/identity/index.d.ts +18 -0
- package/dist/identity/index.js +16 -0
- package/dist/identity/preview-cookie.d.ts +9 -0
- package/dist/identity/preview-cookie.js +12 -0
- package/dist/identity/preview-draft.d.ts +6 -0
- package/dist/identity/preview-draft.js +25 -0
- package/dist/identity/preview-identity.d.ts +28 -0
- package/dist/identity/preview-identity.js +84 -0
- package/dist/identity/preview-scope.d.ts +28 -0
- package/dist/identity/preview-scope.js +47 -0
- package/dist/identity/resolver.d.ts +110 -0
- package/dist/identity/resolver.js +334 -0
- package/dist/identity/session-query.d.ts +4 -0
- package/dist/identity/session-query.js +19 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.js +788 -0
- package/dist/interaction-mode.d.ts +58 -0
- package/dist/interaction-mode.js +93 -0
- package/dist/nav-handler.d.ts +95 -0
- package/dist/nav-handler.js +84 -0
- package/dist/overlay-label.d.ts +79 -0
- package/dist/overlay-label.js +73 -0
- package/dist/page-presentation.d.ts +24 -0
- package/dist/page-presentation.js +32 -0
- package/dist/provenance/anchor-map.d.ts +95 -0
- package/dist/provenance/anchor-map.js +177 -0
- package/dist/provenance/carrier-plan.d.ts +51 -0
- package/dist/provenance/carrier-plan.js +90 -0
- package/dist/provenance/coded-text.d.ts +20 -0
- package/dist/provenance/coded-text.js +302 -0
- package/dist/provenance/direct-edit-locator.d.ts +29 -0
- package/dist/provenance/direct-edit-locator.js +218 -0
- package/dist/provenance/editable-leaf.d.ts +134 -0
- package/dist/provenance/editable-leaf.js +483 -0
- package/dist/provenance/editor-target.d.ts +29 -0
- package/dist/provenance/editor-target.js +46 -0
- package/dist/provenance/field-leaf-walker.d.ts +21 -0
- package/dist/provenance/field-leaf-walker.js +98 -0
- package/dist/provenance/frame-dependencies.d.ts +212 -0
- package/dist/provenance/frame-dependencies.js +550 -0
- package/dist/provenance/index.d.ts +26 -0
- package/dist/provenance/index.js +26 -0
- package/dist/provenance/local-events.d.ts +1 -0
- package/dist/provenance/local-events.js +1 -0
- package/dist/provenance/markers.d.ts +21 -0
- package/dist/provenance/markers.js +70 -0
- package/dist/provenance/multi-frame-anchor-map.d.ts +54 -0
- package/dist/provenance/multi-frame-anchor-map.js +109 -0
- package/dist/provenance/normalize.d.ts +2 -0
- package/dist/provenance/normalize.js +19 -0
- package/dist/provenance/overlay-focus-echo.d.ts +17 -0
- package/dist/provenance/overlay-focus-echo.js +16 -0
- package/dist/provenance/overlay-projection.d.ts +65 -0
- package/dist/provenance/overlay-projection.js +201 -0
- package/dist/provenance/owner-map.d.ts +55 -0
- package/dist/provenance/owner-map.js +239 -0
- package/dist/provenance/read-carrier.d.ts +22 -0
- package/dist/provenance/read-carrier.js +92 -0
- package/dist/provenance/recorder.d.ts +38 -0
- package/dist/provenance/recorder.js +82 -0
- package/dist/provenance/render-context.d.ts +106 -0
- package/dist/provenance/render-context.js +338 -0
- package/dist/provenance/reveal-contract.d.ts +44 -0
- package/dist/provenance/reveal-contract.js +1 -0
- package/dist/provenance/richtext-slice-embed-address.d.ts +20 -0
- package/dist/provenance/richtext-slice-embed-address.js +35 -0
- package/dist/provenance/runtime-script.d.ts +1 -0
- package/dist/provenance/runtime-script.js +2217 -0
- package/dist/provenance/sidecar-store.d.ts +63 -0
- package/dist/provenance/sidecar-store.js +151 -0
- package/dist/provenance/sidecar.d.ts +34 -0
- package/dist/provenance/sidecar.js +227 -0
- package/dist/provenance/slice-model.d.ts +28 -0
- package/dist/provenance/slice-model.js +86 -0
- package/dist/provenance/source-identity.d.ts +3 -0
- package/dist/provenance/source-identity.js +7 -0
- package/dist/provenance/source-map-materializer.d.ts +76 -0
- package/dist/provenance/source-map-materializer.js +286 -0
- package/dist/provenance/source-registry.d.ts +103 -0
- package/dist/provenance/source-registry.js +562 -0
- package/dist/provenance/transformed-output-gate.d.ts +161 -0
- package/dist/provenance/transformed-output-gate.js +171 -0
- package/dist/provenance/types.d.ts +102 -0
- package/dist/provenance/types.js +1 -0
- package/dist/refresh-policy.d.ts +11 -0
- package/dist/refresh-policy.js +14 -0
- package/dist/reveal-target.d.ts +8 -0
- package/dist/reveal-target.js +47 -0
- package/dist/route-paths.d.ts +11 -0
- package/dist/route-paths.js +14 -0
- package/dist/router-subscriber.d.ts +92 -0
- package/dist/router-subscriber.js +44 -0
- package/dist/runtime/anchor-types.d.ts +5 -0
- package/dist/runtime/anchor-types.js +1 -0
- package/dist/runtime/authority-store.d.ts +31 -0
- package/dist/runtime/authority-store.js +56 -0
- package/dist/runtime/boot.d.ts +52 -0
- package/dist/runtime/boot.js +379 -0
- package/dist/runtime/content-refresh.d.ts +30 -0
- package/dist/runtime/content-refresh.js +68 -0
- package/dist/runtime/emit-runtime-error.d.ts +51 -0
- package/dist/runtime/emit-runtime-error.js +64 -0
- package/dist/runtime/field-proxy.d.ts +112 -0
- package/dist/runtime/field-proxy.js +471 -0
- package/dist/runtime/form-contract-reporter.d.ts +99 -0
- package/dist/runtime/form-contract-reporter.js +391 -0
- package/dist/runtime/invalidation-adapter.d.ts +17 -0
- package/dist/runtime/invalidation-adapter.js +42 -0
- package/dist/runtime/live-query-overlay.d.ts +39 -0
- package/dist/runtime/live-query-overlay.js +345 -0
- package/dist/runtime/momentary-navigate.d.ts +16 -0
- package/dist/runtime/momentary-navigate.js +106 -0
- package/dist/runtime/observation-scheduler.d.ts +15 -0
- package/dist/runtime/observation-scheduler.js +42 -0
- package/dist/runtime/perf-metrics.d.ts +28 -0
- package/dist/runtime/perf-metrics.js +90 -0
- package/dist/runtime/preview-interaction-policy.d.ts +1 -0
- package/dist/runtime/preview-interaction-policy.js +103 -0
- package/dist/runtime/preview-overlay-painter.d.ts +27 -0
- package/dist/runtime/preview-overlay-painter.js +1732 -0
- package/dist/runtime/preview-overlay-sidecar.d.ts +26 -0
- package/dist/runtime/preview-overlay-sidecar.js +45 -0
- package/dist/runtime/preview-perspective-alignment.d.ts +15 -0
- package/dist/runtime/preview-perspective-alignment.js +40 -0
- package/dist/runtime/preview-perspective-intent-state.d.ts +23 -0
- package/dist/runtime/preview-perspective-intent-state.js +5 -0
- package/dist/runtime/preview-transition-state.d.ts +142 -0
- package/dist/runtime/preview-transition-state.js +257 -0
- package/dist/runtime/render-mode-state.d.ts +51 -0
- package/dist/runtime/render-mode-state.js +76 -0
- package/dist/runtime/request-id.d.ts +4 -0
- package/dist/runtime/request-id.js +8 -0
- package/dist/runtime/resolve-schema-field.d.ts +99 -0
- package/dist/runtime/resolve-schema-field.js +356 -0
- package/dist/runtime/runtime-error-dispatch.d.ts +23 -0
- package/dist/runtime/runtime-error-dispatch.js +75 -0
- package/dist/runtime/schema-store.d.ts +121 -0
- package/dist/runtime/schema-store.js +667 -0
- package/dist/runtime/snapshot-assembly.d.ts +104 -0
- package/dist/runtime/snapshot-assembly.js +553 -0
- package/dist/runtime/snapshot-reporter.d.ts +55 -0
- package/dist/runtime/snapshot-reporter.js +375 -0
- package/dist/runtime/standalone-overlay-controller.d.ts +33 -0
- package/dist/runtime/standalone-overlay-controller.js +281 -0
- package/dist/runtime/store.d.ts +307 -0
- package/dist/runtime/store.js +1026 -0
- package/dist/runtime/windowed-minimap-projection.d.ts +28 -0
- package/dist/runtime/windowed-minimap-projection.js +189 -0
- package/dist/runtime/workspace-shortcuts.d.ts +30 -0
- package/dist/runtime/workspace-shortcuts.js +188 -0
- package/dist/sdk-error-copy.d.ts +48 -0
- package/dist/sdk-error-copy.js +182 -0
- package/dist/select-cursor.d.ts +2 -0
- package/dist/select-cursor.js +23 -0
- package/dist/server/admission-cookie.d.ts +38 -0
- package/dist/server/admission-cookie.js +122 -0
- package/dist/server/control-client.d.ts +29 -0
- package/dist/server/control-client.js +22 -0
- package/dist/server/control-errors.d.ts +22 -0
- package/dist/server/control-errors.js +182 -0
- package/dist/server/draft-route.d.ts +12 -0
- package/dist/server/draft-route.js +45 -0
- package/dist/server/extract-token.d.ts +30 -0
- package/dist/server/extract-token.js +98 -0
- package/dist/server/grant.d.ts +128 -0
- package/dist/server/grant.js +395 -0
- package/dist/server/ordinary-read-provenance.d.ts +11 -0
- package/dist/server/ordinary-read-provenance.js +124 -0
- package/dist/server/preview-read-metadata.d.ts +10 -0
- package/dist/server/preview-read-metadata.js +27 -0
- package/dist/server/provenance-frame-builder.d.ts +53 -0
- package/dist/server/provenance-frame-builder.js +102 -0
- package/dist/server/provenance-runtime.d.ts +70 -0
- package/dist/server/provenance-runtime.js +46 -0
- package/dist/server/read-context-command.d.ts +11 -0
- package/dist/server/read-context-command.js +53 -0
- package/dist/server/read-identity.d.ts +3 -0
- package/dist/server/read-identity.js +63 -0
- package/dist/server/read-lifecycle.d.ts +17 -0
- package/dist/server/read-lifecycle.js +52 -0
- package/dist/server/render-frame-provenance.d.ts +133 -0
- package/dist/server/render-frame-provenance.js +676 -0
- package/dist/server/render-id.d.ts +15 -0
- package/dist/server/render-id.js +22 -0
- package/dist/server/route-document-provenance.d.ts +77 -0
- package/dist/server/route-document-provenance.js +1327 -0
- package/dist/server/route-session-cookie.d.ts +33 -0
- package/dist/server/route-session-cookie.js +54 -0
- package/dist/session-projections.d.ts +33 -0
- package/dist/session-projections.js +43 -0
- package/dist/session-subscriber.d.ts +124 -0
- package/dist/session-subscriber.js +79 -0
- package/dist/sha256-fallback.d.ts +30 -0
- package/dist/sha256-fallback.js +126 -0
- package/dist/types.d.ts +446 -0
- package/dist/types.js +85 -0
- package/dist/validators.d.ts +61 -0
- package/dist/validators.js +110 -0
- package/package.json +210 -3
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { normalizePreviewVariantId } from '../identity/preview-identity.js';
|
|
2
|
+
export function directEditLocatorForSourceSet(sourceSet) {
|
|
3
|
+
if (sourceSet?.editable !== 'single-field' ||
|
|
4
|
+
sourceSet.sources.length !== 1) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const source = sourceSet.primary ?? sourceSet.sources[0];
|
|
8
|
+
if (!source)
|
|
9
|
+
return null;
|
|
10
|
+
return directEditLocatorForSource(sourceSet.id, source);
|
|
11
|
+
}
|
|
12
|
+
export function directEditLocatorForSource(sourceSetId, source) {
|
|
13
|
+
const documentId = normalizedBoundedString(source.documentId, 256);
|
|
14
|
+
const canonicalPath = normalizedBoundedString(source.canonicalPath, 4_096);
|
|
15
|
+
const normalizedSourceSetId = normalizedBoundedString(sourceSetId, 512);
|
|
16
|
+
if (!documentId || !canonicalPath || !normalizedSourceSetId)
|
|
17
|
+
return null;
|
|
18
|
+
const pathAnchors = normalizePathAnchors(source.pathAnchors);
|
|
19
|
+
if (pathAnchors === null)
|
|
20
|
+
return null;
|
|
21
|
+
const navigationAnchors = source.navigationAnchors === undefined
|
|
22
|
+
? undefined
|
|
23
|
+
: normalizePathAnchors(source.navigationAnchors);
|
|
24
|
+
if (navigationAnchors === null)
|
|
25
|
+
return null;
|
|
26
|
+
const variantId = normalizePreviewVariantId(source.variantId);
|
|
27
|
+
if (source.variantId !== undefined && variantId === null)
|
|
28
|
+
return null;
|
|
29
|
+
let navigationPath;
|
|
30
|
+
if (source.navigationPath !== undefined) {
|
|
31
|
+
const normalized = normalizedBoundedString(source.navigationPath, 4_096);
|
|
32
|
+
if (normalized === null)
|
|
33
|
+
return null;
|
|
34
|
+
navigationPath = normalized;
|
|
35
|
+
}
|
|
36
|
+
const textNodeIndex = normalizeTextNodeIndex(source.textNodeIndex);
|
|
37
|
+
if (source.textNodeIndex !== undefined && textNodeIndex === undefined) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
version: 1,
|
|
42
|
+
sourceSetId: normalizedSourceSetId,
|
|
43
|
+
documentId,
|
|
44
|
+
...(variantId !== null ? { variantId } : {}),
|
|
45
|
+
canonicalPath,
|
|
46
|
+
pathAnchors,
|
|
47
|
+
...(navigationPath !== undefined ? { navigationPath } : {}),
|
|
48
|
+
...(navigationAnchors !== undefined ? { navigationAnchors } : {}),
|
|
49
|
+
...(textNodeIndex !== undefined ? { textNodeIndex } : {}),
|
|
50
|
+
sourceKind: source.sourceKind,
|
|
51
|
+
...(source.readScope !== undefined ? { readScope: source.readScope } : {}),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function normalizeDirectEditLocator(value) {
|
|
55
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const candidate = value;
|
|
59
|
+
if (candidate.version !== 1 || !isSourceKind(candidate.sourceKind))
|
|
60
|
+
return null;
|
|
61
|
+
const pathAnchors = normalizePathAnchors(candidate.pathAnchors);
|
|
62
|
+
if (pathAnchors === null)
|
|
63
|
+
return null;
|
|
64
|
+
const navigationAnchors = candidate.navigationAnchors === undefined
|
|
65
|
+
? undefined
|
|
66
|
+
: normalizePathAnchors(candidate.navigationAnchors);
|
|
67
|
+
if (navigationAnchors === null)
|
|
68
|
+
return null;
|
|
69
|
+
const sourceSetId = normalizedBoundedString(candidate.sourceSetId, 512);
|
|
70
|
+
const documentId = normalizedBoundedString(candidate.documentId, 256);
|
|
71
|
+
const canonicalPath = normalizedBoundedString(candidate.canonicalPath, 4_096);
|
|
72
|
+
if (!sourceSetId || !documentId || !canonicalPath)
|
|
73
|
+
return null;
|
|
74
|
+
const variantId = normalizePreviewVariantId(candidate.variantId);
|
|
75
|
+
if (candidate.variantId !== undefined &&
|
|
76
|
+
(typeof candidate.variantId !== 'string' || variantId === null)) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
let navigationPath;
|
|
80
|
+
if (candidate.navigationPath !== undefined) {
|
|
81
|
+
const normalized = normalizedBoundedString(candidate.navigationPath, 4_096);
|
|
82
|
+
if (normalized === null)
|
|
83
|
+
return null;
|
|
84
|
+
navigationPath = normalized;
|
|
85
|
+
}
|
|
86
|
+
const textNodeIndex = normalizeTextNodeIndex(candidate.textNodeIndex);
|
|
87
|
+
if (candidate.textNodeIndex !== undefined && textNodeIndex === undefined) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
let readScope;
|
|
91
|
+
if (candidate.readScope !== undefined) {
|
|
92
|
+
const normalized = normalizePreviewReadScopeEcho(candidate.readScope);
|
|
93
|
+
if (normalized === null)
|
|
94
|
+
return null;
|
|
95
|
+
readScope = normalized;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
version: 1,
|
|
99
|
+
sourceSetId,
|
|
100
|
+
documentId,
|
|
101
|
+
...(variantId !== null ? { variantId } : {}),
|
|
102
|
+
canonicalPath,
|
|
103
|
+
pathAnchors,
|
|
104
|
+
...(navigationPath !== undefined ? { navigationPath } : {}),
|
|
105
|
+
...(navigationAnchors !== undefined ? { navigationAnchors } : {}),
|
|
106
|
+
...(textNodeIndex !== undefined ? { textNodeIndex } : {}),
|
|
107
|
+
sourceKind: candidate.sourceKind,
|
|
108
|
+
...(readScope !== undefined ? { readScope } : {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export function normalizePreviewReadScopeEcho(value) {
|
|
112
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const scope = value;
|
|
116
|
+
if (!isNullableBoundedString(scope.requestedVariantId, 256) ||
|
|
117
|
+
!isNullableBoundedString(scope.requestedDocumentId, 256) ||
|
|
118
|
+
!(scope.requestedLocale === undefined || isNullableBoundedString(scope.requestedLocale, 128)) ||
|
|
119
|
+
!(scope.appliedLocale === undefined || isNullableBoundedString(scope.appliedLocale, 128)) ||
|
|
120
|
+
!(scope.appliesToDocument === null || typeof scope.appliesToDocument === 'boolean') ||
|
|
121
|
+
!isNullableBoundedString(scope.appliedVariantId, 256) ||
|
|
122
|
+
!isNullableBoundedString(scope.requestedReleaseId, 256) ||
|
|
123
|
+
!isReleaseScopeStatus(scope.releaseScopeStatus) ||
|
|
124
|
+
!(scope.releaseLifecycleStatus === undefined || isBoundedString(scope.releaseLifecycleStatus, 64)) ||
|
|
125
|
+
!isNullableBoundedString(scope.appliedReleaseId, 256) ||
|
|
126
|
+
!isReleaseMemberState(scope.releaseMemberState) ||
|
|
127
|
+
!isReleaseDegradedReason(scope.degradedReason)) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
requestedVariantId: scope.requestedVariantId,
|
|
132
|
+
requestedDocumentId: scope.requestedDocumentId,
|
|
133
|
+
...(scope.requestedLocale !== undefined
|
|
134
|
+
? { requestedLocale: scope.requestedLocale }
|
|
135
|
+
: {}),
|
|
136
|
+
...(scope.appliedLocale !== undefined
|
|
137
|
+
? { appliedLocale: scope.appliedLocale }
|
|
138
|
+
: {}),
|
|
139
|
+
appliesToDocument: scope.appliesToDocument,
|
|
140
|
+
appliedVariantId: scope.appliedVariantId,
|
|
141
|
+
requestedReleaseId: scope.requestedReleaseId,
|
|
142
|
+
releaseScopeStatus: scope.releaseScopeStatus,
|
|
143
|
+
...(scope.releaseLifecycleStatus !== undefined
|
|
144
|
+
? { releaseLifecycleStatus: scope.releaseLifecycleStatus }
|
|
145
|
+
: {}),
|
|
146
|
+
appliedReleaseId: scope.appliedReleaseId,
|
|
147
|
+
...(scope.releaseMemberState !== undefined
|
|
148
|
+
? { releaseMemberState: scope.releaseMemberState }
|
|
149
|
+
: {}),
|
|
150
|
+
...(scope.degradedReason !== undefined
|
|
151
|
+
? { degradedReason: scope.degradedReason }
|
|
152
|
+
: {}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function normalizePathAnchors(value) {
|
|
156
|
+
if (!Array.isArray(value) || value.length > 64)
|
|
157
|
+
return null;
|
|
158
|
+
const anchors = [];
|
|
159
|
+
for (const entry of value) {
|
|
160
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const candidate = entry;
|
|
164
|
+
const path = normalizedBoundedString(candidate.path, 4_096, true);
|
|
165
|
+
const key = normalizedBoundedString(candidate.key, 512);
|
|
166
|
+
if (path === null || !key)
|
|
167
|
+
return null;
|
|
168
|
+
anchors.push({ path, key });
|
|
169
|
+
}
|
|
170
|
+
return anchors;
|
|
171
|
+
}
|
|
172
|
+
function normalizedBoundedString(value, maxLength, allowEmpty = false) {
|
|
173
|
+
if (typeof value !== 'string' || value.length > maxLength)
|
|
174
|
+
return null;
|
|
175
|
+
const normalized = value.trim();
|
|
176
|
+
return normalized.length > 0 || allowEmpty ? normalized : null;
|
|
177
|
+
}
|
|
178
|
+
function normalizeTextNodeIndex(value) {
|
|
179
|
+
return Number.isInteger(value) && value >= 0
|
|
180
|
+
? value
|
|
181
|
+
: undefined;
|
|
182
|
+
}
|
|
183
|
+
function isSourceKind(value) {
|
|
184
|
+
return value === 'stored' ||
|
|
185
|
+
value === 'binding' ||
|
|
186
|
+
value === 'model' ||
|
|
187
|
+
value === 'computed' ||
|
|
188
|
+
value === 'richtext' ||
|
|
189
|
+
value === 'embed' ||
|
|
190
|
+
value === 'emptyFallback' ||
|
|
191
|
+
value === 'unknown';
|
|
192
|
+
}
|
|
193
|
+
function isNullableBoundedString(value, maxLength) {
|
|
194
|
+
return value === null || isBoundedString(value, maxLength);
|
|
195
|
+
}
|
|
196
|
+
function isBoundedString(value, maxLength) {
|
|
197
|
+
return typeof value === 'string' && value.length > 0 && value.length <= maxLength;
|
|
198
|
+
}
|
|
199
|
+
function isReleaseScopeStatus(value) {
|
|
200
|
+
return value === 'none' ||
|
|
201
|
+
value === 'active' ||
|
|
202
|
+
value === 'missing' ||
|
|
203
|
+
value === 'not-previewable' ||
|
|
204
|
+
value === 'unbound';
|
|
205
|
+
}
|
|
206
|
+
function isReleaseMemberState(value) {
|
|
207
|
+
return value === undefined ||
|
|
208
|
+
value === 'active' ||
|
|
209
|
+
value === 'archived' ||
|
|
210
|
+
value === 'missing' ||
|
|
211
|
+
value === 'locale-removed';
|
|
212
|
+
}
|
|
213
|
+
function isReleaseDegradedReason(value) {
|
|
214
|
+
return value === undefined ||
|
|
215
|
+
value === 'archived' ||
|
|
216
|
+
value === 'missing' ||
|
|
217
|
+
value === 'locale-removed';
|
|
218
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type PreviewReadScopeEcho } from '@storystick/client/internal';
|
|
2
|
+
import type { PreviewReadContext } from '@storystick/types/preview-query-targeting';
|
|
3
|
+
import { type PublicProvenanceSidecar } from './sidecar.js';
|
|
4
|
+
import type { MarkerRecord, PathAnchor, PreviewProvenanceCarrierPlan, ProvenanceAnchorKind, ProvenanceFrame, ProvenanceId, ProvenanceMarkerModality, SourceSet } from './types.js';
|
|
5
|
+
export { formatPreviewProvenanceCanonicalPath } from './field-leaf-walker.js';
|
|
6
|
+
export type PreviewProvenancePathPart = string | number;
|
|
7
|
+
export interface PreviewProvenanceEditableLeaf extends ProvenanceId {
|
|
8
|
+
readonly key: string;
|
|
9
|
+
readonly sourceSetId: string;
|
|
10
|
+
readonly outputKind: 'text' | 'element';
|
|
11
|
+
readonly modality: ProvenanceMarkerModality;
|
|
12
|
+
readonly anchorKind: ProvenanceAnchorKind;
|
|
13
|
+
readonly renderedText?: string;
|
|
14
|
+
readonly sourceSet?: PreviewProvenanceEditableLeafSourceSet;
|
|
15
|
+
readonly codedText?: boolean;
|
|
16
|
+
readonly codedTextRoot?: unknown;
|
|
17
|
+
readonly codedTextPath?: readonly PreviewProvenancePathPart[];
|
|
18
|
+
readonly codedRichTextTextNodeIndex?: number;
|
|
19
|
+
readonly anchorMultiplicity?: MarkerRecord['anchorMultiplicity'];
|
|
20
|
+
readonly presence?: MarkerRecord['presence'];
|
|
21
|
+
}
|
|
22
|
+
export interface PreviewProvenanceEditableLeafSourceSet {
|
|
23
|
+
readonly kind: SourceSet['kind'];
|
|
24
|
+
readonly sources: readonly ProvenanceId[];
|
|
25
|
+
readonly primary?: ProvenanceId;
|
|
26
|
+
readonly derivation?: SourceSet['derivation'];
|
|
27
|
+
readonly editable: SourceSet['editable'];
|
|
28
|
+
}
|
|
29
|
+
export interface CreatePreviewProvenanceEditableLeafInput {
|
|
30
|
+
readonly key: string;
|
|
31
|
+
readonly documentId: string;
|
|
32
|
+
readonly variantId?: string | null;
|
|
33
|
+
readonly readScope?: PreviewReadScopeEcho;
|
|
34
|
+
readonly rootPath?: readonly PreviewProvenancePathPart[];
|
|
35
|
+
readonly leafPath: readonly PreviewProvenancePathPart[];
|
|
36
|
+
readonly pathAnchors?: readonly PathAnchor[];
|
|
37
|
+
readonly navigationPath?: string;
|
|
38
|
+
readonly navigationAnchors?: readonly PathAnchor[];
|
|
39
|
+
readonly relativePathAnchors?: readonly PathAnchor[];
|
|
40
|
+
readonly sourceKind?: ProvenanceId['sourceKind'];
|
|
41
|
+
readonly sourceSetId: string;
|
|
42
|
+
readonly outputKind?: PreviewProvenanceEditableLeaf['outputKind'];
|
|
43
|
+
readonly modality?: ProvenanceMarkerModality;
|
|
44
|
+
readonly anchorKind?: ProvenanceAnchorKind;
|
|
45
|
+
readonly renderedText?: string;
|
|
46
|
+
readonly sourceSet?: PreviewProvenanceEditableLeafSourceSet;
|
|
47
|
+
readonly codedText?: boolean;
|
|
48
|
+
readonly codedTextRoot?: unknown;
|
|
49
|
+
readonly codedTextPath?: readonly PreviewProvenancePathPart[];
|
|
50
|
+
readonly codedRichTextTextNodeIndex?: number;
|
|
51
|
+
readonly anchorMultiplicity?: MarkerRecord['anchorMultiplicity'];
|
|
52
|
+
readonly presence?: MarkerRecord['presence'];
|
|
53
|
+
}
|
|
54
|
+
export interface RecordPreviewProvenanceEditableLeavesInput {
|
|
55
|
+
readonly sessionId?: string;
|
|
56
|
+
readonly readContext?: PreviewReadContext;
|
|
57
|
+
readonly routeHash: string;
|
|
58
|
+
readonly codeVersion: string;
|
|
59
|
+
readonly variantId?: string | null;
|
|
60
|
+
readonly previewScope?: PreviewReadScopeEcho;
|
|
61
|
+
readonly renderId: string;
|
|
62
|
+
readonly generation: number;
|
|
63
|
+
readonly renderNonce?: string;
|
|
64
|
+
readonly emissionRevision?: number;
|
|
65
|
+
readonly enabled?: boolean;
|
|
66
|
+
readonly leaves: readonly PreviewProvenanceEditableLeaf[];
|
|
67
|
+
readonly codedTextRoot?: unknown;
|
|
68
|
+
readonly codedTextRootPrefix?: readonly PreviewProvenancePathPart[];
|
|
69
|
+
readonly codedTextRootsByDocumentId?: PreviewProvenanceCodedTextRootsByDocumentId;
|
|
70
|
+
}
|
|
71
|
+
export type PreviewProvenanceCodedTextRootsByDocumentId = ReadonlyMap<string, unknown> | Readonly<Record<string, unknown>>;
|
|
72
|
+
export interface RecordedPreviewProvenanceEditableLeaves {
|
|
73
|
+
readonly attrsByKey: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
74
|
+
readonly carrierPlansByKey: Readonly<Record<string, readonly PreviewProvenanceCarrierPlan[]>>;
|
|
75
|
+
readonly renderFrame: ProvenanceFrame;
|
|
76
|
+
readonly publicSidecar: PublicProvenanceSidecar | null;
|
|
77
|
+
readonly codedTextWrites: PreviewProvenanceCodedTextWriteSummary;
|
|
78
|
+
}
|
|
79
|
+
export interface PreviewProvenanceCodedTextWriteSummary {
|
|
80
|
+
readonly attempted: number;
|
|
81
|
+
readonly written: number;
|
|
82
|
+
readonly failures: readonly PreviewProvenanceCodedTextWriteFailure[];
|
|
83
|
+
}
|
|
84
|
+
export interface PreviewProvenanceCodedTextWriteFailure {
|
|
85
|
+
readonly key: string;
|
|
86
|
+
readonly documentId: string;
|
|
87
|
+
readonly sourceSetId: string;
|
|
88
|
+
readonly canonicalPath: string;
|
|
89
|
+
readonly operation: 'text' | 'richtext' | 'object';
|
|
90
|
+
readonly reason: 'root-missing' | 'path-unresolvable' | 'path-or-text-mismatch' | 'path-or-object-mismatch' | 'coded-text-disallowed';
|
|
91
|
+
}
|
|
92
|
+
export interface PreviewProvenanceEditableTextLeafCandidate {
|
|
93
|
+
readonly path: readonly PreviewProvenancePathPart[];
|
|
94
|
+
readonly leaf: PreviewProvenanceEditableLeaf;
|
|
95
|
+
}
|
|
96
|
+
export interface PreviewProvenanceEditableTextLeafContext {
|
|
97
|
+
readonly path: readonly PreviewProvenancePathPart[];
|
|
98
|
+
readonly fieldName: string | null;
|
|
99
|
+
readonly value?: unknown;
|
|
100
|
+
readonly sourceKind: 'stored' | 'richtext';
|
|
101
|
+
readonly outputKind: 'text' | 'element';
|
|
102
|
+
readonly textNodeIndex?: number;
|
|
103
|
+
}
|
|
104
|
+
export type PreviewProvenanceEditableTextPathToken = PreviewProvenancePathPart | '*';
|
|
105
|
+
export interface PreviewProvenanceEditableTextPathPattern {
|
|
106
|
+
readonly path: readonly PreviewProvenanceEditableTextPathToken[];
|
|
107
|
+
readonly sourceKind?: PreviewProvenanceEditableTextLeafContext['sourceKind'];
|
|
108
|
+
readonly outputKind?: PreviewProvenanceEditableTextLeafContext['outputKind'];
|
|
109
|
+
readonly modality?: ProvenanceMarkerModality;
|
|
110
|
+
readonly anchorKind?: ProvenanceAnchorKind;
|
|
111
|
+
}
|
|
112
|
+
export type PreviewProvenanceEditableTextPathManifest = Readonly<Record<string, readonly PreviewProvenanceEditableTextPathPattern[]>>;
|
|
113
|
+
export interface PlanPreviewProvenanceEditableTextLeavesInput {
|
|
114
|
+
readonly documentId: string;
|
|
115
|
+
readonly variantId?: string | null;
|
|
116
|
+
readonly readScope?: PreviewReadScopeEcho;
|
|
117
|
+
readonly root: unknown;
|
|
118
|
+
readonly rootPath?: readonly PreviewProvenancePathPart[];
|
|
119
|
+
readonly pathAnchors?: readonly PathAnchor[];
|
|
120
|
+
readonly keyPrefix: string;
|
|
121
|
+
readonly sourceSetPrefix: string;
|
|
122
|
+
readonly presence?: MarkerRecord['presence'];
|
|
123
|
+
readonly include?: (context: PreviewProvenanceEditableTextLeafContext) => boolean;
|
|
124
|
+
readonly match?: (context: PreviewProvenanceEditableTextLeafContext) => PreviewProvenanceEditableTextPathPattern | null;
|
|
125
|
+
}
|
|
126
|
+
export declare function createPreviewProvenanceEditableLeaf(input: CreatePreviewProvenanceEditableLeafInput): PreviewProvenanceEditableLeaf;
|
|
127
|
+
export declare function planPreviewProvenanceEditableTextLeaves(input: PlanPreviewProvenanceEditableTextLeavesInput): readonly PreviewProvenanceEditableTextLeafCandidate[];
|
|
128
|
+
export declare function createPreviewProvenanceEditableTextManifestInclude(manifest: PreviewProvenanceEditableTextPathManifest, storyType: string | null | undefined): (context: PreviewProvenanceEditableTextLeafContext) => boolean;
|
|
129
|
+
export declare function createPreviewProvenanceEditableManifestMatcher(manifest: PreviewProvenanceEditableTextPathManifest, storyType: string | null | undefined): (context: PreviewProvenanceEditableTextLeafContext) => PreviewProvenanceEditableTextPathPattern | null;
|
|
130
|
+
export declare function previewProvenanceEditableTextPathPatternMatches(context: PreviewProvenanceEditableTextLeafContext, pattern: PreviewProvenanceEditableTextPathPattern): boolean;
|
|
131
|
+
export declare function matchingPreviewProvenanceEditablePathPattern(context: PreviewProvenanceEditableTextLeafContext, patterns: readonly PreviewProvenanceEditableTextPathPattern[]): PreviewProvenanceEditableTextPathPattern | null;
|
|
132
|
+
export declare function recordPreviewProvenanceEditableLeaves(input: RecordPreviewProvenanceEditableLeavesInput): Promise<RecordedPreviewProvenanceEditableLeaves>;
|
|
133
|
+
export declare function previewProvenanceSourceSetForLeaf(leaf: PreviewProvenanceEditableLeaf): SourceSet;
|
|
134
|
+
export declare function prefixPreviewProvenancePathAnchors(prefixPath: readonly PreviewProvenancePathPart[], anchors: readonly PathAnchor[]): readonly PathAnchor[];
|