@contentstack/studio-client 3.0.0 → 3.2.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.md +21 -0
- package/dist/breakpoints/BreakpointManager.js +1 -0
- package/dist/breakpoints/BreakpointManager.js.map +1 -1
- package/dist/canvas/canvas.utils.js +18 -1
- package/dist/canvas/canvas.utils.js.map +1 -1
- package/dist/composable-studio/build-scoped-data.js +58 -3
- package/dist/composable-studio/build-scoped-data.js.map +1 -1
- package/dist/composable-studio/collect-data-needs.js +24 -4
- package/dist/composable-studio/collect-data-needs.js.map +1 -1
- package/dist/composable-studio/data/pre-process-static-values.js +13 -0
- package/dist/composable-studio/data/pre-process-static-values.js.map +1 -1
- package/dist/composable-studio/sdk.js +496 -136
- package/dist/composable-studio/sdk.js.map +1 -1
- package/dist/composable-studio/section-data.js +316 -0
- package/dist/composable-studio/section-data.js.map +1 -0
- package/dist/composable-studio/studio-intelligence.manager.js +1 -0
- package/dist/composable-studio/studio-intelligence.manager.js.map +1 -1
- package/dist/config/config.schema.js +26 -0
- package/dist/config/config.schema.js.map +1 -1
- package/dist/config/process-user-config.js +6 -0
- package/dist/config/process-user-config.js.map +1 -1
- package/dist/config/stack-sdk-wrapper.js +36 -1
- package/dist/config/stack-sdk-wrapper.js.map +1 -1
- package/dist/context-menu/context-menu.js +1 -0
- package/dist/context-menu/context-menu.js.map +1 -1
- package/dist/dnd/dnd-manager.js +1 -0
- package/dist/dnd/dnd-manager.js.map +1 -1
- package/dist/get-active-node-screenshot/get-node-screenshot-event.js +45 -4
- package/dist/get-active-node-screenshot/get-node-screenshot-event.js.map +1 -1
- package/dist/highlight-node/highlight-node-manager.js +2 -4
- package/dist/highlight-node/highlight-node-manager.js.map +1 -1
- package/dist/highlight-node/highlight-node.js +1 -0
- package/dist/highlight-node/highlight-node.js.map +1 -1
- package/dist/index.d.ts +347 -25
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/url-metadata/build-template-query.js +13 -3
- package/dist/url-metadata/build-template-query.js.map +1 -1
- package/dist/utils/conditionBlock.js +132 -5
- package/dist/utils/conditionBlock.js.map +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/include-path-rules.js +102 -0
- package/dist/utils/include-path-rules.js.map +1 -0
- package/dist/utils/query-url-budget.js +79 -0
- package/dist/utils/query-url-budget.js.map +1 -0
- package/dist/utils/reference_fetcher.js +22 -2
- package/dist/utils/reference_fetcher.js.map +1 -1
- package/dist/utils/spec-analyzer.js +2 -2
- package/dist/utils/spec-analyzer.js.map +1 -1
- package/package.json +8 -9
- package/LICENSE +0 -21
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/** Binding `type` for a path into the page's template entry. */
|
|
2
|
+
const TEMPLATE_BINDING_TYPE = "template";
|
|
3
|
+
/**
|
|
4
|
+
* Split a dotted field path into binding-path segments, dropping the array
|
|
5
|
+
* indices and modular-block numeric prefixes that are not data keys. Mirrors
|
|
6
|
+
* `sanitizeFieldPath` in sdk.ts — kept local so this module stays dependency-free
|
|
7
|
+
* and usable from Studio.
|
|
8
|
+
*/
|
|
9
|
+
function splitFieldPath(path) {
|
|
10
|
+
return path
|
|
11
|
+
.split(".")
|
|
12
|
+
.map((seg) => seg.replace(/\[\d+\]$/, "").replace(/^\d+_/, ""))
|
|
13
|
+
.filter((seg) => seg.length > 0 && !/^\d+$/.test(seg) && seg !== "entries");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Nest dotted path segments into the object shape a binding `value.path` uses:
|
|
17
|
+
* `["a", "b"]` → `{ a: { b: {} } }`. An empty path nests to `{}`, which is what
|
|
18
|
+
* a scope-root binding carries.
|
|
19
|
+
*/
|
|
20
|
+
function nestPath(segments) {
|
|
21
|
+
let nested = {};
|
|
22
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
23
|
+
nested = { [segments[i]]: nested };
|
|
24
|
+
}
|
|
25
|
+
return nested;
|
|
26
|
+
}
|
|
27
|
+
/** The inverse of {@link nestPath}: walk the single-key chain back to segments. */
|
|
28
|
+
function flattenPath(path) {
|
|
29
|
+
const segments = [];
|
|
30
|
+
let current = path;
|
|
31
|
+
while (current && typeof current === "object") {
|
|
32
|
+
const keys = Object.keys(current);
|
|
33
|
+
if (keys.length !== 1 || keys[0] === "")
|
|
34
|
+
break;
|
|
35
|
+
// A key may itself be a DOTTED path. Template bindings nest one segment per
|
|
36
|
+
// level (`{ a: { b: {} } }`), but a contentstack binding stores the whole
|
|
37
|
+
// path as a single key (`{ "page_sections.17.keynote_speakers": {} }`).
|
|
38
|
+
// Field uids cannot contain a dot, so splitting is unambiguous — and
|
|
39
|
+
// without it the entire path arrives as one opaque segment.
|
|
40
|
+
for (const part of keys[0].split(".")) {
|
|
41
|
+
if (part)
|
|
42
|
+
segments.push(part);
|
|
43
|
+
}
|
|
44
|
+
current = current[keys[0]];
|
|
45
|
+
}
|
|
46
|
+
return segments;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build the template-typed Section data equivalent to a legacy `selectedField`.
|
|
50
|
+
*
|
|
51
|
+
* This is the whole migration: every placement saved before the Section data
|
|
52
|
+
* existed resolves to exactly the binding it behaved as, derived on read. No
|
|
53
|
+
* stored data changes.
|
|
54
|
+
*/
|
|
55
|
+
function synthesizeTemplateRootBinding(selectedField) {
|
|
56
|
+
return {
|
|
57
|
+
type: TEMPLATE_BINDING_TYPE,
|
|
58
|
+
value: { path: nestPath(splitFieldPath(selectedField ?? "")) },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Whether a resolved Section data means "deliberately cleared". */
|
|
62
|
+
function isDataRootCleared(root) {
|
|
63
|
+
return root === null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether a Section data points into the page's template entry — the only kind
|
|
67
|
+
* that extends a page-template prefix. A contentstack / query / repeater-typed
|
|
68
|
+
* root names its own document instead (see ADR 0017's fetch root).
|
|
69
|
+
*/
|
|
70
|
+
function isTemplateRootBinding(root) {
|
|
71
|
+
return !!root && root.type === TEMPLATE_BINDING_TYPE;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The path a Section data addresses **within the scope its placement already
|
|
75
|
+
* inherits** — the page template entry for a `template` root, the live
|
|
76
|
+
* iteration item for a `repeater` one (ADR 0006).
|
|
77
|
+
*
|
|
78
|
+
* This is what the renderer means by `selectedField`: the provider scopes the
|
|
79
|
+
* enclosing repeater item (or the template entry) by it. A root naming ANOTHER
|
|
80
|
+
* document carries its path in the fetch root's `prefix` instead, so it has no
|
|
81
|
+
* scope path — the two are never both in play.
|
|
82
|
+
*
|
|
83
|
+
* The `template`-only version of this test is what left a repeater-relative
|
|
84
|
+
* root unusable: its path (`hero_card` inside the item) was dropped on the way
|
|
85
|
+
* to the renderer, every iteration scoped to the whole item, and the section
|
|
86
|
+
* rendered component defaults.
|
|
87
|
+
*/
|
|
88
|
+
function getRootScopePath(root) {
|
|
89
|
+
if (!root)
|
|
90
|
+
return [];
|
|
91
|
+
if (root.type === TEMPLATE_BINDING_TYPE || root.type === "repeater") {
|
|
92
|
+
return getRootBindingPath(root);
|
|
93
|
+
}
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The dotted path a Section data addresses *within* its document.
|
|
98
|
+
*
|
|
99
|
+
* For a template root this is the old `selectedField`. For a contentstack root
|
|
100
|
+
* the first segment is the `<ct>:<uid>` pool key, which names the **document**
|
|
101
|
+
* rather than a field inside it — callers that need the in-document path must
|
|
102
|
+
* drop it (`dropDocumentSegment`).
|
|
103
|
+
*/
|
|
104
|
+
function getRootBindingPath(root) {
|
|
105
|
+
if (!root)
|
|
106
|
+
return [];
|
|
107
|
+
const value = root.value;
|
|
108
|
+
return flattenPath(value?.path);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The legacy `selectedField` ladder, verbatim: per-instance override → legacy
|
|
112
|
+
* `metadata.selectedField` → the `linked_schemas` default for the page content
|
|
113
|
+
* type → the first schema.
|
|
114
|
+
*
|
|
115
|
+
* Extracted so the Section data resolver and the existing page-template
|
|
116
|
+
* projection read the SAME ladder and cannot drift. Returns the path
|
|
117
|
+
* **unsanitised** — callers that need CDA-safe segments sanitise at the point
|
|
118
|
+
* of use, exactly as they did before the Section data existed.
|
|
119
|
+
*/
|
|
120
|
+
function resolveLegacySelectedField(node, linkedSchemasFor, pageContentTypeUid) {
|
|
121
|
+
return resolveLegacySelectedFieldWithProvenance(node, linkedSchemasFor, pageContentTypeUid).field;
|
|
122
|
+
}
|
|
123
|
+
function resolveLegacySelectedFieldWithProvenance(node, linkedSchemasFor, pageContentTypeUid) {
|
|
124
|
+
const override = node.metadata?.sectionBindingOverride;
|
|
125
|
+
if (typeof override?.selectedField === "string") {
|
|
126
|
+
return { field: override.selectedField, provenance: "override" };
|
|
127
|
+
}
|
|
128
|
+
if (typeof node.metadata?.selectedField === "string") {
|
|
129
|
+
return { field: node.metadata.selectedField, provenance: "legacy" };
|
|
130
|
+
}
|
|
131
|
+
const linked = linkedSchemasFor(node.metadata?.compositionUID) || [];
|
|
132
|
+
const declared = linked.find((s) => s.content_type_uid === pageContentTypeUid)
|
|
133
|
+
?.selected_field ??
|
|
134
|
+
linked[0]?.selected_field ??
|
|
135
|
+
"";
|
|
136
|
+
return { field: declared || "", provenance: "declared" };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Whether a resolved field is rooted at the page entry rather than at an
|
|
140
|
+
* enclosing wrapper section. A page-absolute field must REPLACE the inherited
|
|
141
|
+
* prefix, never be concatenated onto it.
|
|
142
|
+
*
|
|
143
|
+
* A scope-root field ("") is neither — it adds no segment either way — so it is
|
|
144
|
+
* reported as not absolute to keep the inherited prefix intact.
|
|
145
|
+
*/
|
|
146
|
+
function isPageAbsoluteField(field, provenance) {
|
|
147
|
+
if (!field)
|
|
148
|
+
return false;
|
|
149
|
+
return provenance === "declared" || provenance === "legacy";
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolve a section-composition node's effective **Section data**.
|
|
153
|
+
*
|
|
154
|
+
* Resolution order — the existing `selectedField` ladder with one tier added on
|
|
155
|
+
* top, so this is strictly a superset of today's behaviour:
|
|
156
|
+
*
|
|
157
|
+
* 1. `sectionBindingOverride.rootBinding` when the key is PRESENT (including
|
|
158
|
+
* an explicit `null`, which means cleared)
|
|
159
|
+
* 2. otherwise synthesise a template-typed binding from the legacy
|
|
160
|
+
* `selectedField` ladder: override → `metadata.selectedField` →
|
|
161
|
+
* `linked_schemas` default for the page content type → first schema
|
|
162
|
+
*
|
|
163
|
+
* The caller MUST NOT write the result back onto the node. Persisted state is
|
|
164
|
+
* structurally diffed against the save baseline (ADR 0007), so persisting a
|
|
165
|
+
* derived value would mark every pre-existing page dirty the moment it opens,
|
|
166
|
+
* and would freeze a live fallback into a copy.
|
|
167
|
+
*/
|
|
168
|
+
function resolveInstanceRootBinding(node, linkedSchemasFor, pageContentTypeUid) {
|
|
169
|
+
const override = node.metadata?.sectionBindingOverride;
|
|
170
|
+
// Presence, not truthiness — `null` is a real, distinct state.
|
|
171
|
+
if (override && "rootBinding" in override) {
|
|
172
|
+
return override.rootBinding;
|
|
173
|
+
}
|
|
174
|
+
// Seeding from `linked_schemas` only makes sense where a page template entry
|
|
175
|
+
// EXISTS to resolve the derived path against. A freeform composition has no
|
|
176
|
+
// connected content type, so a synthesised template root can never resolve —
|
|
177
|
+
// and worse, it renders in the Section data picker as though the placement were
|
|
178
|
+
// already bound (the label is the last path segment, e.g. "Page Sections"),
|
|
179
|
+
// so an author sees a bound control and no data with nothing to act on.
|
|
180
|
+
//
|
|
181
|
+
// Freeform placements therefore start genuinely EMPTY, which is also what the
|
|
182
|
+
// feature was asked for: the template seeds itself, freeform is picked by the
|
|
183
|
+
// page composer.
|
|
184
|
+
if (!pageContentTypeUid)
|
|
185
|
+
return undefined;
|
|
186
|
+
return synthesizeTemplateRootBinding(resolveLegacySelectedField(node, linkedSchemasFor, pageContentTypeUid));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Which `linked_schemas` entry a placement is bound to.
|
|
190
|
+
*
|
|
191
|
+
* Prefers the persisted `matchedSchemaCt` (the only answer available on a
|
|
192
|
+
* freeform page), falling back to matching the page content type the way the
|
|
193
|
+
* template path always has.
|
|
194
|
+
*/
|
|
195
|
+
function resolveMatchedSchema(node, linkedSchemas, pageContentTypeUid) {
|
|
196
|
+
const linked = linkedSchemas || [];
|
|
197
|
+
if (linked.length === 0)
|
|
198
|
+
return undefined;
|
|
199
|
+
const matchedCt = node.metadata?.sectionBindingOverride?.matchedSchemaCt;
|
|
200
|
+
if (matchedCt) {
|
|
201
|
+
const byMatch = linked.find((s) => s.content_type_uid === matchedCt);
|
|
202
|
+
if (byMatch)
|
|
203
|
+
return byMatch;
|
|
204
|
+
}
|
|
205
|
+
return (linked.find((s) => s.content_type_uid === pageContentTypeUid) ?? linked[0]);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Deep-compare two Section datas. Used by the stamp pass, which must compare a
|
|
209
|
+
* DERIVED binding against a DERIVED binding: comparing a `BindingType` object
|
|
210
|
+
* against a raw `selectedField` string never matches, so every template
|
|
211
|
+
* placement would stamp and every old page would go dirty on open.
|
|
212
|
+
*/
|
|
213
|
+
function sectionDataEqual(a, b) {
|
|
214
|
+
if (a === b)
|
|
215
|
+
return true;
|
|
216
|
+
if (a == null || b == null)
|
|
217
|
+
return a === b;
|
|
218
|
+
if (a.type !== b.type)
|
|
219
|
+
return false;
|
|
220
|
+
return stableStringify(a.value) === stableStringify(b.value);
|
|
221
|
+
}
|
|
222
|
+
function stableStringify(value) {
|
|
223
|
+
if (value === null || typeof value !== "object")
|
|
224
|
+
return JSON.stringify(value);
|
|
225
|
+
if (Array.isArray(value))
|
|
226
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
227
|
+
const keys = Object.keys(value).sort();
|
|
228
|
+
return `{${keys
|
|
229
|
+
.map((k) => `${JSON.stringify(k)}:${stableStringify(value[k])}`)
|
|
230
|
+
.join(",")}}`;
|
|
231
|
+
}
|
|
232
|
+
const TEMPLATE_FETCH_ROOT_KEY = "template";
|
|
233
|
+
const templateFetchRoot = (prefix = []) => ({
|
|
234
|
+
key: TEMPLATE_FETCH_ROOT_KEY,
|
|
235
|
+
prefix,
|
|
236
|
+
});
|
|
237
|
+
/** Whether a fetch-root key names the page template entry. */
|
|
238
|
+
function isTemplateFetchRoot(key) {
|
|
239
|
+
return key === TEMPLATE_FETCH_ROOT_KEY;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Parse a `<ct>:<uid>` fetch-root key back into its parts. Returns null for the
|
|
243
|
+
* template root and for query roots, neither of which is an entry.
|
|
244
|
+
*/
|
|
245
|
+
function parseEntryFetchRootKey(key) {
|
|
246
|
+
if (isTemplateFetchRoot(key) || key.startsWith("query:"))
|
|
247
|
+
return null;
|
|
248
|
+
const idx = key.indexOf(":");
|
|
249
|
+
if (idx <= 0 || idx === key.length - 1)
|
|
250
|
+
return null;
|
|
251
|
+
return {
|
|
252
|
+
contentTypeUid: key.slice(0, idx),
|
|
253
|
+
entryUid: key.slice(idx + 1),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Derive the fetch root a Section data addresses.
|
|
258
|
+
*
|
|
259
|
+
* The first path segment of a non-template binding names the **document**, not
|
|
260
|
+
* a field inside it, so it becomes the key and is dropped from the prefix:
|
|
261
|
+
*
|
|
262
|
+
* { contentstack, path: { "mkt_ct:blt1": { banner: {} } } }
|
|
263
|
+
* → { key: "mkt_ct:blt1", prefix: ["banner"] }
|
|
264
|
+
*
|
|
265
|
+
* A `repeater`-typed root inherits the enclosing document: the repeater re-scopes
|
|
266
|
+
* per iteration at render time, but the includes still belong to whichever
|
|
267
|
+
* document the repeater's own source was fetched from.
|
|
268
|
+
*
|
|
269
|
+
* Returns `inherited` unchanged for a cleared root — there is nothing to fetch,
|
|
270
|
+
* so nothing should be re-anchored.
|
|
271
|
+
*/
|
|
272
|
+
function fetchRootFromBinding(root, inherited) {
|
|
273
|
+
if (!root)
|
|
274
|
+
return inherited;
|
|
275
|
+
const path = getRootBindingPath(root);
|
|
276
|
+
if (root.type === TEMPLATE_BINDING_TYPE) {
|
|
277
|
+
return templateFetchRoot(path);
|
|
278
|
+
}
|
|
279
|
+
if (root.type === "repeater") {
|
|
280
|
+
return inherited;
|
|
281
|
+
}
|
|
282
|
+
// A contentstack binding identifies its document on `value` — NOT in the
|
|
283
|
+
// path. `{ uid, _content_type_uid, path: { "page_sections.17.keynote_speakers": {} } }`
|
|
284
|
+
// means "entry alpha_page:blt… , at that path inside it". Deriving the key
|
|
285
|
+
// from the first path segment instead produced a document key of
|
|
286
|
+
// `page_sections`, so nothing resolved and the section rendered no data.
|
|
287
|
+
const value = (root.value ?? {});
|
|
288
|
+
if (root.type === "contentstack") {
|
|
289
|
+
const ct = value._content_type_uid ?? value.content_type_uid;
|
|
290
|
+
if (ct && value.uid)
|
|
291
|
+
return { key: `${ct}:${value.uid}`, prefix: path };
|
|
292
|
+
// Older/looser shapes put the `ct:uid` composite in the first segment.
|
|
293
|
+
if (path.length === 0)
|
|
294
|
+
return inherited;
|
|
295
|
+
const [documentSegment, ...rest] = path;
|
|
296
|
+
return { key: documentSegment, prefix: rest };
|
|
297
|
+
}
|
|
298
|
+
if (root.type === "contentstack_queries") {
|
|
299
|
+
// A query binding is keyed by its data-source uid, which the picker writes
|
|
300
|
+
// as `queryUID` — NOT `uid`. Reading only `uid` fell through to the loose
|
|
301
|
+
// shape below and produced the key `query:entries` (the path's first
|
|
302
|
+
// segment), so no pooled query ever matched and a query-rooted section
|
|
303
|
+
// rendered component defaults.
|
|
304
|
+
const queryUid = value.queryUID ?? value.uid;
|
|
305
|
+
if (queryUid)
|
|
306
|
+
return { key: `query:${queryUid}`, prefix: path };
|
|
307
|
+
if (path.length === 0)
|
|
308
|
+
return inherited;
|
|
309
|
+
const [documentSegment, ...rest] = path;
|
|
310
|
+
return { key: `query:${documentSegment}`, prefix: rest };
|
|
311
|
+
}
|
|
312
|
+
return inherited;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export { TEMPLATE_BINDING_TYPE, TEMPLATE_FETCH_ROOT_KEY, fetchRootFromBinding, flattenPath, getRootBindingPath, getRootScopePath, isDataRootCleared, isPageAbsoluteField, isTemplateFetchRoot, isTemplateRootBinding, nestPath, parseEntryFetchRootKey, resolveInstanceRootBinding, resolveLegacySelectedField, resolveLegacySelectedFieldWithProvenance, resolveMatchedSchema, sectionDataEqual, splitFieldPath, synthesizeTemplateRootBinding, templateFetchRoot };
|
|
316
|
+
//# sourceMappingURL=section-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-data.js","sources":["../../src/composable-studio/section-data.ts"],"sourcesContent":[null],"names":[],"mappings":"AA8CA;AACO,MAAM,qBAAqB,GAAG;AAErC;;;;;AAKG;AACG,SAAU,cAAc,CAAC,IAAY,EAAA;AACzC,IAAA,OAAO;SACJ,KAAK,CAAC,GAAG;SACT,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;SAC7D,MAAM,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,SAAS,CAAC;AAC/E;AAEA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,QAAkB,EAAA;IACzC,IAAI,MAAM,GAA4B,EAAE;AACxC,IAAA,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE;IACpC;AACA,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AAG,EAAE,CAAA,EAAG,EAAE,CAAA,CAAA,EAAI,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;;AAEvE,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,SAAS;QACvC,MAAM,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI;QACvC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE;IAC/C;AAEA,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAsB,EAAE;;;;;;QAMxC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG;AAC5C,QAAA,IAAI,QAAQ;YAAE,OAAO,EAAE,GAAG,EAAE,CAAA,MAAA,EAAS,QAAQ,CAAA,CAAE,EAAE,MAAM,EAAE,IAAI,EAAE;AAC/D,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,SAAS;QACvC,MAAM,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI;QACvC,OAAO,EAAE,GAAG,EAAE,CAAA,MAAA,EAAS,eAAe,CAAA,CAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IAC1D;AAEA,IAAA,OAAO,SAAS;AAClB;;;;"}
|
|
@@ -3,6 +3,7 @@ import { SCHEMA_VERSION, SDK_VERSION } from '../utils/constants.js';
|
|
|
3
3
|
import 'lodash-es';
|
|
4
4
|
import '@contentstack/studio-registry';
|
|
5
5
|
import '../utils/editor-mode.js';
|
|
6
|
+
import '../utils/conditionBlock.js';
|
|
6
7
|
import { clientRendererModeUtil } from '../utils/canvas.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-intelligence.manager.js","sources":["../../src/composable-studio/studio-intelligence.manager.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studio-intelligence.manager.js","sources":["../../src/composable-studio/studio-intelligence.manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AAaA;;;AAGG;MACU,yBAAyB,CAAA;AAC5B,IAAA,OAAgB,UAAU,GAAG,IAAI;AAEzC;;;AAGG;AACH,IAAA,aAAa,qBAAqB,CAChC,OAAiC,EACjC,MAAY,EAAA;;AAGZ,QAAA,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE,EAAE;AACjD,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,IAAI;YACF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC;AACxE,YAAA,OAAO,YAAY;QACrB;AAAE,QAAA,MAAM;AACN,YAAA,OAAO,IAAI;QACb;IACF;AAEA;;;AAGG;AACH,IAAA,OAAO,oCAAoC,CACzC,eAAyC,EACzC,kBAA8C,EAAA;;QAG9C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO;AACL,gBAAA,GAAG,eAAe;AAClB,gBAAA,gBAAgB,EAAE,QAAQ;aACQ;QACtC;QAEA,OAAO;AACL,YAAA,GAAG,eAAe;AAClB,YAAA,mBAAmB,EAAE,kBAAkB;AACvC,YAAA,gBAAgB,EAAE,cAAc;;AAGhC,YAAA,MAAM,EAAE,eAAe,EAAE,MAAM,IAAI,kBAAkB,CAAC,MAAM;YAC5D,gBAAgB,EACd,eAAe,EAAE,gBAAgB;AACjC,gBAAA,kBAAkB,CAAC,gBAAgB;AACrC,YAAA,YAAY,EACV,eAAe,EAAE,YAAY,IAAI,kBAAkB,CAAC,YAAY;;AAGlE,YAAA,WAAW,EAAE,IAAI,CAAC,kBAAkB,CAClC,eAAe,EAAE,WAAW,EAC5B,kBAAkB,CAAC,WAAW,CAC/B;SACiC;IACtC;AAEA;;AAEG;AACK,IAAA,aAAa,uBAAuB,CAC1C,OAAiC,EACjC,MAAY,EAAA;AAEZ,QAAA,MAAM,OAAO,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AK,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE;gBAC3C;AAEA,gBAAA,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,GAAG;oBAChC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,IAAI,EAAE,CAAC;AAC1C,oBAAA,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC;iBACnC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD;QACF;AAEA,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,SAAS;IAC5D;AAEA;;AAEG;AACK,IAAA,OAAO,iBAAiB,GAAA;QAC9B,OAAO,CAAA,IAAA,EAAO,IAAI,CAAC,GAAG,EAAE,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAE;IACvE;AAEA;;AAEG;IACK,OAAO,cAAc,CAAI,EAAU,EAAA;QACzC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,KAC3B,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,EAAE,EAAE,CAAC,CACvE;IACH;;;;;"}
|
|
@@ -45,6 +45,32 @@ const userConfigSchema = z.object({
|
|
|
45
45
|
message: "fetchTemplateEntry must be a function",
|
|
46
46
|
})
|
|
47
47
|
.optional(),
|
|
48
|
+
/**
|
|
49
|
+
* Shared-state integration. Storage options: `"local"` / `"session"` use
|
|
50
|
+
* built-in web-storage stores; `"custom"` (or providing getState/setState
|
|
51
|
+
* with no `storage`) delegates to the user's own store. `state` present
|
|
52
|
+
* with neither → built-in SESSION store. Omit `state` entirely to keep the
|
|
53
|
+
* SDK's internal in-memory Map (fully backward compatible).
|
|
54
|
+
*/
|
|
55
|
+
state: z
|
|
56
|
+
.custom((val) => {
|
|
57
|
+
if (!val || typeof val !== "object")
|
|
58
|
+
return false;
|
|
59
|
+
const v = val;
|
|
60
|
+
const hasGet = typeof v.getState === "function";
|
|
61
|
+
const hasSet = typeof v.setState === "function";
|
|
62
|
+
if (hasGet !== hasSet)
|
|
63
|
+
return false; // one without the other
|
|
64
|
+
const storage = v.storage ?? (hasGet ? "custom" : "session");
|
|
65
|
+
if (!["local", "session", "custom"].includes(storage))
|
|
66
|
+
return false;
|
|
67
|
+
if (storage === "custom" && !hasGet)
|
|
68
|
+
return false;
|
|
69
|
+
return true;
|
|
70
|
+
}, {
|
|
71
|
+
message: 'state: invalid storage option — "custom" requires getState AND setState; "local"/"session" need neither',
|
|
72
|
+
})
|
|
73
|
+
.optional(),
|
|
48
74
|
});
|
|
49
75
|
|
|
50
76
|
export { editButtonInBuilderPosition, userConfigSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.schema.js","sources":["../../src/config/config.schema.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"config.schema.js","sources":["../../src/config/config.schema.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQO,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC;IAChD,KAAK;IACL,UAAU;IACV,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,cAAc;IACd,eAAe;AAChB,CAAA;AAEM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;AACvC;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACrC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAc,CAAC,GAAG,KAAI;QACtC,MAAM,yBAAyB,GAAG,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAA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MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,KAAK,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC5D,QAAA,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;AAAE,YAAA,OAAO,KAAK;AACnE,QAAA,IAAI,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM;AAAE,YAAA,OAAO,KAAK;AACjD,QAAA,OAAO,IAAI;AACb,IAAA,CAAC,EACD;AACE,QAAA,OAAO,EACL,yGAAyG;KAC5G;AAEF,SAAA,QAAQ,EAAE;AACd,CAAA;;;;"}
|
|
@@ -45,6 +45,12 @@ function processUserConfig(userConfig) {
|
|
|
45
45
|
if (userConfig.fetchTemplateEntry) {
|
|
46
46
|
config.fetchTemplateEntry = userConfig.fetchTemplateEntry;
|
|
47
47
|
}
|
|
48
|
+
// BYOS state config — passed through as-is so generateSdk can wire the
|
|
49
|
+
// shared state store (getDefaultConfig has no state entry; without this
|
|
50
|
+
// copy the user's getState/setState/variables silently vanish).
|
|
51
|
+
if (userConfig.state) {
|
|
52
|
+
config.state = userConfig.state;
|
|
53
|
+
}
|
|
48
54
|
return config;
|
|
49
55
|
}
|
|
50
56
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-user-config.js","sources":["../../src/config/process-user-config.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAOM,SAAU,iBAAiB,CAAC,UAAsB,EAAA;AACtD,IAAA,MAAM,MAAM,GAAG,gBAAgB,EAAE;AAEjC,IAAA,IAAI;AACF,QAAA,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC;IACpC;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,KAAK,YAAY,CAAC,CAAC,QAAQ,EAAE;YAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;AACxC,gBAAA,OAAO,CAA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,CAAC,IAAI,CAAC,UAAU;IACrD;AAEA,IAAA,IAAI,UAAU,CAAC,kBAAkB,EAAE;QACjC,IAAI,OAAO,UAAU,CAAC,kBAAkB,EAAE,MAAM,KAAK,WAAW,EAAE;YAChE,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAG,UAAU,CAAC,kBAAkB,CAAC,MAAM;QACzE;QACA,IAAI,OAAO,UAAU,CAAC,kBAAkB,EAAE,QAAQ,KAAK,WAAW,EAAE;YAClE,MAAM,CAAC,kBAAkB,CAAC,QAAQ;AAChC,gBAAA,UAAU,CAAC,kBAAkB,CAAC,QAAQ;QAC1C;IACF;AAEA,IAAA,IAAI,UAAU,CAAC,gBAAgB,EAAE;AAC/B,QAAA,MAAM,CAAC,gBAAgB,GAAG,UAAU,CAAC,gBAAgB;IACvD;AACA,IAAA,IAAI,UAAU,CAAC,kBAAkB,EAAE;AACjC,QAAA,MAAM,CAAC,kBAAkB,GAAG,UAAU,CAAC,kBAAkB;IAC3D;;;;AAKA,IAAA,IAAI,UAAU,CAAC,KAAK,EAAE;AACpB,QAAA,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK;IACjC;AAEA,IAAA,OAAO,MAAM;AACf;;;;"}
|
|
@@ -3,7 +3,14 @@ import 'lodash-es';
|
|
|
3
3
|
import { onlyParmasGenerator } from '../utils/query-param.js';
|
|
4
4
|
import '@contentstack/studio-registry';
|
|
5
5
|
import '../utils/editor-mode.js';
|
|
6
|
+
import '../utils/conditionBlock.js';
|
|
6
7
|
|
|
8
|
+
// Measured against cdn.contentstack.io: 15,092 bytes of request URI comes back
|
|
9
|
+
// 200, 15,292 comes back 431, and 16,469 comes back 414. So the first failure is
|
|
10
|
+
// a 431 at roughly 15.3KB, about a kilobyte earlier than the 414 the old note
|
|
11
|
+
// here described. Stay well under it — the count below is an estimate, and being
|
|
12
|
+
// optimistic costs the whole request.
|
|
13
|
+
const MAX_REQUEST_URL_CHARS = 12000;
|
|
7
14
|
class StackSDK {
|
|
8
15
|
sdk;
|
|
9
16
|
_locale;
|
|
@@ -32,7 +39,35 @@ class StackSDK {
|
|
|
32
39
|
}
|
|
33
40
|
ctQuery(contentTypeUid, options = {}) {
|
|
34
41
|
const references = options.references || [];
|
|
35
|
-
|
|
42
|
+
let only = options.only || [];
|
|
43
|
+
// A 414 surfaces as a fallback fetch with no includes, i.e. uid stubs.
|
|
44
|
+
// include[] is correctness, only[] is payload size — so when the two
|
|
45
|
+
// together exceed the cap, drop only[] and accept a larger response.
|
|
46
|
+
if (only.length > 0) {
|
|
47
|
+
const includeChars = references.reduce((n, r) => n + encodeURIComponent(r).length + 14, // include%5B%5D= + &
|
|
48
|
+
0);
|
|
49
|
+
const onlyChars = only.reduce((n, [ref, field]) => n +
|
|
50
|
+
encodeURIComponent(ref).length +
|
|
51
|
+
encodeURIComponent(field).length +
|
|
52
|
+
20, // only%5B..%5D%5B%5D= + &
|
|
53
|
+
0);
|
|
54
|
+
const queryChars = options.query
|
|
55
|
+
? encodeURIComponent(JSON.stringify(options.query)).length + 7
|
|
56
|
+
: 0;
|
|
57
|
+
const APPROX_BASE_CHARS = 500; // host, path, env/locale/branch params
|
|
58
|
+
if (APPROX_BASE_CHARS + includeChars + onlyChars + queryChars >
|
|
59
|
+
MAX_REQUEST_URL_CHARS) {
|
|
60
|
+
// Nothing is wrong from the reader's point of view — the page still
|
|
61
|
+
// renders, it just fetches more than it needs. A consuming site does not
|
|
62
|
+
// want that in its production logs on every render.
|
|
63
|
+
if (process.env.NODE_ENV === "development") {
|
|
64
|
+
console.warn(`[studio-sdk] Skipping only[] projections for ${contentTypeUid}: ` +
|
|
65
|
+
`estimated request URL exceeds ${MAX_REQUEST_URL_CHARS} chars ` +
|
|
66
|
+
`(includes: ${references.length}, only rows: ${only.length}).`);
|
|
67
|
+
}
|
|
68
|
+
only = [];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
36
71
|
const variantAlias = options.variantAlias;
|
|
37
72
|
const locale = options.locale; // Get locale from options, not from instance
|
|
38
73
|
const branch = options.branch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-sdk-wrapper.js","sources":["../../src/config/stack-sdk-wrapper.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stack-sdk-wrapper.js","sources":["../../src/config/stack-sdk-wrapper.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAKA;AACA;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,KAAK;MAKtB,QAAQ,CAAA;AACnB,IAAA,GAAG;AACK,IAAA,OAAO;IAEf,WAAA,CAAY,GAAsB,EAAE,MAAe,EAAA;AACjD,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;AACd,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;QAErB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;QACtD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;IAClE;AAEA,IAAA,eAAe,CACb,IAAuD,EAAA;AAEvD,QAAA,OAAO,aAAa,IAAI,IAAI,CAAC,GAAG;IAClC;AAEA,IAAA,gBAAgB,CAAC,eAAuB,EAAA;AACtC,QAAA,IAAI,CAAC,GAAG,CAAC,gBAAgB,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ACF;AAEA;;;AAGG;IACH,oBAAoB,CAClB,KAAU,EACV,mBAA2C,EAAA;AAE3C,QAAA,IAAI;;AAEF,YAAA,IAAI,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE;AAErC,YAAA,KAAK,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,MAAM,CAAC,OAAO,CACvD,mBAAmB,CACpB,EAAE;AACD,gBAAA,MAAM,aAAa,GAAG,CAAA,WAAA,EAAc,WAAW,EAAE;;AAGjD,gBAAA,IAAI,OAAO,aAAa,CAAC,KAAK,KAAK,UAAU,EAAE;oBAC7C,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,CAAC;gBACnE;YACF;;AAGA,YAAA,IACE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B,gBAAA,OAAO,aAAa,CAAC,MAAM,KAAK,UAAU,EAC1C;AACA,gBAAA,aAAa,GAAG,aAAa,CAAC,MAAM,EAAE;YACxC;AAEA,YAAA,OAAO,aAAa;QACtB;QAAE,OAAO,KAAK,EAAE;;AAEd,YAAA,OAAO,CAAC,IAAI,CACV,gEAAgE,EAChE,KAAK,CACN;YAED,IAAI,aAAa,GAAG,KAAK;AACzB,YAAA,KAAK,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,MAAM,CAAC,OAAO,CACvD,mBAAmB,CACpB,EAAE;AACD,gBAAA,MAAM,aAAa,GAAG,CAAA,WAAA,EAAc,WAAW,EAAE;gBACjD,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC;YACzE;AAEA,YAAA,OAAO,aAAa;QACtB;IACF;AACD;;;;"}
|
|
@@ -3,6 +3,7 @@ import { COMPOSABLE_DATA_ATTRIBUTES } from '../utils/constants.js';
|
|
|
3
3
|
import 'lodash-es';
|
|
4
4
|
import '@contentstack/studio-registry';
|
|
5
5
|
import '../utils/editor-mode.js';
|
|
6
|
+
import '../utils/conditionBlock.js';
|
|
6
7
|
import { getHitboxDetails, serializeEvent } from '../canvas/canvas.utils.js';
|
|
7
8
|
|
|
8
9
|
const handleContextMenu = (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.js","sources":["../../src/context-menu/context-menu.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-menu.js","sources":["../../src/context-menu/context-menu.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AAQA,MAAM,iBAAiB,GAAG,CAAC,CAAa,KAAI;IAC1C,CAAC,CAAC,cAAc,EAAE;AAClB,IAAA,MAAM,MAAM,GAAG,CAAC,CAAC,MAAqB;AACtC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAChC,CAAA,CAAA,EAAI,0BAA0B,CAAC,IAAI,CAAA,CAAA,CAAG,CACxB;AAChB,IAAA,IAAI,CAAC,WAAW;QAAE;AAClB,IAAA,4BAA4B,EAAE,IAAI,CAAC,mBAAmB,CAAC,YAAY,EAAE;AACnE,QAAA,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC;AACxB,QAAA,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAC7B,KAAA,CAAC;AACF,IAAA,OAAO,KAAK;AACd,CAAC;SAEe,4BAA4B,GAAA;AAC1C,IAAA,IAAI,CAAC,UAAU;QAAE;IACjB,MAAM,oBAAoB,GAIpB,EAAE;AAER,IAAA,SAAS,sBAAsB,CAC7B,IAAO,EACP,OAA2C,EAC3C,OAA2C,EAAA;QAE3C,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;QAC/C,oBAAoB,CAAC,IAAI,CAAC;YACxB,IAAI;AACJ,YAAA,OAAO,EAAE,OAAwB;YACjC,OAAO;AACR,SAAA,CAAC;IACJ;AAEA,IAAA,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAExD,OAAO;QACL,oBAAoB,EAAE,MAAK;AACzB,YAAA,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAI;gBAC1D,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;AACpD,YAAA,CAAC,CAAC;QACJ,CAAC;KACF;AACH;;;;"}
|
package/dist/dnd/dnd-manager.js
CHANGED
|
@@ -3,6 +3,7 @@ import { COMPOSABLE_DATA_ATTRIBUTES } from '../utils/constants.js';
|
|
|
3
3
|
import 'lodash-es';
|
|
4
4
|
import '@contentstack/studio-registry';
|
|
5
5
|
import '../utils/editor-mode.js';
|
|
6
|
+
import '../utils/conditionBlock.js';
|
|
6
7
|
import { dndEventManager } from '../shared/dnd-events.js';
|
|
7
8
|
import { getScrollableParent, calculateDynamicSpeed } from './scroll-utils.js';
|
|
8
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dnd-manager.js","sources":["../../src/dnd/dnd-manager.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dnd-manager.js","sources":["../../src/dnd/dnd-manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAIA;AAEO,MAAM,gBAAgB,GAAG;AACzB,MAAM,eAAe,GAAG;AACxB,MAAM,YAAY,GAAG;AAC5B,MAAM,cAAc,GAAG,EAAE;AAOzB,MAAM,UAAU,CAAA;IACd,OAAO,GAAY,KAAK;IACxB,QAAQ,GAAY,KAAK;IACzB,eAAe,GAAuB,IAAI;AAC1C,IAAA,cAAc;IACd,aAAa,GAAyB,IAAI;IAC1C,QAAQ,GAAY,KAAK;IACzB,SAAS,GAAY,KAAK;AAE1B,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,CAAC,UAAU;YAAE;AACjB,QAAA,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAA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;AAC1C,YAAA,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;AAC7B,QAAA,OAAO,QAAQ;IACjB;AACD;MAEY,UAAU,mBAAmB,IAAI,UAAU;;;;"}
|
|
@@ -11,11 +11,19 @@ function getNodeScreenshotEvent() {
|
|
|
11
11
|
screenshot: "",
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// modern-screenshot, not html2canvas: html2canvas reimplements CSS colour
|
|
15
|
+
// parsing and only understands rgb/rgba/hsl/hsla, so any node whose computed
|
|
16
|
+
// style resolves to a modern colour function throws
|
|
17
|
+
// `Attempting to parse an unsupported color function "lab"` and the whole
|
|
18
|
+
// capture is lost. That is not exotic — Tailwind v4's preflight sets
|
|
19
|
+
// border-color/outline-color on `*` from its oklch palette, which compiles to
|
|
20
|
+
// lab()/oklab(), so every element in a Tailwind v4 canvas app carries one.
|
|
21
|
+
// modern-screenshot serialises the subtree into an SVG <foreignObject> and
|
|
22
|
+
// lets the browser rasterise it, so there is no colour parser to outgrow.
|
|
23
|
+
const { domToCanvas } = await import('modern-screenshot');
|
|
24
|
+
const canvas = await domToCanvas(node, {
|
|
17
25
|
scale: 1,
|
|
18
|
-
|
|
26
|
+
backgroundColor: resolveBackdropColor(node),
|
|
19
27
|
}).finally(() => {
|
|
20
28
|
toggleNodeVisible(node, false);
|
|
21
29
|
});
|
|
@@ -25,6 +33,39 @@ function getNodeScreenshotEvent() {
|
|
|
25
33
|
};
|
|
26
34
|
});
|
|
27
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The nearest ancestor's opaque background colour, so the capture is composited
|
|
38
|
+
* on the backdrop the author actually sees on the canvas.
|
|
39
|
+
*
|
|
40
|
+
* modern-screenshot renders on TRANSPARENCY by default, and it only serialises
|
|
41
|
+
* the captured subtree. A canvas app that paints its page background on `<body>`
|
|
42
|
+
* (dark themes usually do) therefore loses it, because `<body>` sits outside the
|
|
43
|
+
* section root. The glyphs still render — in the theme's light text colour — so
|
|
44
|
+
* the thumbnail becomes white-on-transparent and reads as blank the moment it is
|
|
45
|
+
* drawn on a light surface like the Sections palette or the entry editor. Walking
|
|
46
|
+
* up to the first opaque background reproduces the authored contrast in both
|
|
47
|
+
* light and dark apps.
|
|
48
|
+
*/
|
|
49
|
+
function resolveBackdropColor(node) {
|
|
50
|
+
let current = node;
|
|
51
|
+
while (current) {
|
|
52
|
+
const background = window.getComputedStyle(current).backgroundColor;
|
|
53
|
+
if (isOpaqueColor(background))
|
|
54
|
+
return background;
|
|
55
|
+
current = current.parentElement;
|
|
56
|
+
}
|
|
57
|
+
return "#ffffff";
|
|
58
|
+
}
|
|
59
|
+
/** False for `transparent` and any `rgba()`/`hsla()` whose alpha channel is 0. */
|
|
60
|
+
function isOpaqueColor(color) {
|
|
61
|
+
if (!color || color === "transparent")
|
|
62
|
+
return false;
|
|
63
|
+
const channels = color.match(/^[a-z]+\(([^)]+)\)$/i);
|
|
64
|
+
if (!channels)
|
|
65
|
+
return true;
|
|
66
|
+
const parts = channels[1].split(/[,\s/]+/).filter(Boolean);
|
|
67
|
+
return parts.length < 4 || Number.parseFloat(parts[3]) > 0;
|
|
68
|
+
}
|
|
28
69
|
|
|
29
70
|
export { getNodeScreenshotEvent };
|
|
30
71
|
//# sourceMappingURL=get-node-screenshot-event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-node-screenshot-event.js","sources":["../../src/get-active-node-screenshot/get-node-screenshot-event.ts"],"sourcesContent":[null],"names":[],"mappings":";;;SAWgB,sBAAsB,GAAA;AACpC,IAAA,OAAO,4BAA4B,EAAE,EAAE,CAGrC,mBAAmB,CAAC,mBAAmB,EAAE,OAAO,KAAK,KAAI;AACzD,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG;AAC9B,QAAA,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,CAAC;AAC1C,QAAA,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC;QAC7B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;AACL,gBAAA,UAAU,EAAE,EAAE;aACf;QACH
|
|
1
|
+
{"version":3,"file":"get-node-screenshot-event.js","sources":["../../src/get-active-node-screenshot/get-node-screenshot-event.ts"],"sourcesContent":[null],"names":[],"mappings":";;;SAWgB,sBAAsB,GAAA;AACpC,IAAA,OAAO,4BAA4B,EAAE,EAAE,CAGrC,mBAAmB,CAAC,mBAAmB,EAAE,OAAO,KAAK,KAAI;AACzD,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG;AAC9B,QAAA,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,CAAC;AAC1C,QAAA,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC;QAC7B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;AACL,gBAAA,UAAU,EAAE,EAAE;aACf;QACH;;;;;;;;;;QAUA,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,mBAAmB,CAAC;AACzD,QAAA,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAmB,EAAE;AACpD,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,eAAe,EAAE,oBAAoB,CAAC,IAAmB,CAAC;AAC3D,SAAA,CAAC,CAAC,OAAO,CAAC,MAAK;AACd,YAAA,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC;AAChC,QAAA,CAAC,CAAC;QACF,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC;QAEjD,OAAO;AACL,YAAA,UAAU,EAAE,UAAU;SACvB;AACH,IAAA,CAAC,CAAC;AACJ;AAEA;;;;;;;;;;;;AAYG;AACH,SAAS,oBAAoB,CAAC,IAAiB,EAAA;IAC7C,IAAI,OAAO,GAAuB,IAAI;IACtC,OAAO,OAAO,EAAE;QACd,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,C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