@contentstack/studio-client 1.7.0 → 1.7.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.
Files changed (36) hide show
  1. package/dist/breakpoints/BreakpointManager.js +1 -0
  2. package/dist/breakpoints/BreakpointManager.js.map +1 -1
  3. package/dist/composable-studio/collect-data-needs.js +78 -4
  4. package/dist/composable-studio/collect-data-needs.js.map +1 -1
  5. package/dist/composable-studio/composition-metadata.js +75 -0
  6. package/dist/composable-studio/composition-metadata.js.map +1 -0
  7. package/dist/composable-studio/sdk.js +682 -191
  8. package/dist/composable-studio/sdk.js.map +1 -1
  9. package/dist/composable-studio/studio-intelligence.manager.js +1 -0
  10. package/dist/composable-studio/studio-intelligence.manager.js.map +1 -1
  11. package/dist/config/stack-sdk-wrapper.js +1 -0
  12. package/dist/config/stack-sdk-wrapper.js.map +1 -1
  13. package/dist/context-menu/context-menu.js +1 -0
  14. package/dist/context-menu/context-menu.js.map +1 -1
  15. package/dist/dnd/dnd-manager.js +1 -0
  16. package/dist/dnd/dnd-manager.js.map +1 -1
  17. package/dist/highlight-node/highlight-node-manager.js +1 -0
  18. package/dist/highlight-node/highlight-node-manager.js.map +1 -1
  19. package/dist/highlight-node/highlight-node.js +1 -0
  20. package/dist/highlight-node/highlight-node.js.map +1 -1
  21. package/dist/index.d.ts +396 -229
  22. package/dist/index.js +3 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/studio-internal/dist/utils/section-slot-walker.js.map +1 -0
  25. package/dist/{packages/studio-internal → studio-internal}/dist/utils/spec-compression.js +1 -1
  26. package/dist/studio-internal/dist/utils/spec-compression.js.map +1 -0
  27. package/dist/utils/constants.js +1 -1
  28. package/dist/utils/editor-mode.js +142 -0
  29. package/dist/utils/editor-mode.js.map +1 -0
  30. package/dist/utils/reference_fetcher.js +1 -1
  31. package/package.json +8 -7
  32. package/dist/node_modules/fflate/esm/browser.js +0 -378
  33. package/dist/node_modules/fflate/esm/browser.js.map +0 -1
  34. package/dist/packages/studio-internal/dist/utils/section-slot-walker.js.map +0 -1
  35. package/dist/packages/studio-internal/dist/utils/spec-compression.js.map +0 -1
  36. /package/dist/{packages/studio-internal → studio-internal}/dist/utils/section-slot-walker.js +0 -0
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { studioSdk } from './composable-studio/initializer-sdk.js';
2
2
  export { ELEMENT_TO_NODE, NODE_TO_ELEMENT, NODE_TO_PARENT, NODE_TO_PATH_NODE } from './composable-studio/weak-maps.js';
3
+ export { buildSectionScopedData, getSeoMetadataPure } from './composable-studio/sdk.js';
4
+ export { getCompositionMetadata, renderMetadataToHtml } from './composable-studio/composition-metadata.js';
3
5
  export { parseStringValue, preProcessStaticValues } from './composable-studio/data/pre-process-static-values.js';
4
6
  export { COMPOSITION_PLACEMENT_OPTIONS } from './composable-studio/composition-placement.types.js';
5
7
  export { addContextMenuEventListeners } from './context-menu/context-menu.js';
@@ -24,6 +26,7 @@ export { onlyParmasGenerator, queryParam } from './utils/query-param.js';
24
26
  export { SECTION_COMPOSITIONS_KEY, TEMPLATE_FULL_ENTRY_KEY, batchFetchEntries, entriesFromResponse, getBindingStringForCS, removeStaticEntryFromDS, setStaticEntryInDS, setTemplateEntryInDS } from './utils/sdk.js';
25
27
  export { isInsideVisualBuilderFrame } from './utils/is-inside-visual-builder-frame.js';
26
28
  export { isInsideIframe } from './utils/is-inside-iframe.js';
29
+ export { STUDIO_CANVAS_QUERY_PARAM, STUDIO_MODE_HTML_CLASS, detectStudioMode, isStudioCanvas, isStudioEditorMode, markStudioMode } from './utils/editor-mode.js';
27
30
  export { ComposableStudioError, ComposableStudioErrors } from './utils/composable-studio-error.js';
28
31
  export { evaluateCondition } from './utils/conditionBlock.js';
29
32
  export { RendererModeUtil, clientRendererModeUtil, serializeComputedStyles } from './utils/canvas.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section-slot-walker.js","sources":["../../../../../studio-internal/dist/utils/section-slot-walker.js"],"sourcesContent":["/**\n * Shared section-UI walker for section-slot context resolution.\n *\n * Sections expose `section-slot` placeholders inside their authored UI. When\n * those slots are filled on a page composition, the slot children render\n * inside the section's body — surrounded by whatever Repeater /\n * ConditionBlock chain wraps the matching `section-slot` in the section's\n * authored UI.\n *\n * Three call sites historically each rolled their own walker:\n *\n * - Studio's `findSectionCompositionInstances` (auto-binder) — needs\n * parentRepeaterUid + cumulative schema-path segments for the\n * auto-binder's contextSchemaPath input.\n * - Studio's picker `getRepeatersWrappingSectionSlot` — needs the actual\n * Repeater node references for a SPECIFIC slot (to feed the picker's\n * repeater adapters and to surface the section title as the picker\n * header label).\n * - SDK's `indexSectionInternalSlotRepeaters` — needs only the nearest\n * ancestor Repeater uid per slot, for the per-instance binding seeder.\n *\n * All three did the same walk with different output shapes. This module\n * does the walk ONCE and exposes the raw ancestor-node chain per slot;\n * each consumer derives the shape it needs. Lives in `studio-internal`\n * because that's the only SDK package both Studio and the SDK packages\n * symlink to.\n */\n/**\n * Walks `sectionUI` and returns, for every `section-slot` encountered, the\n * chain of ancestor Repeater and ConditionBlock nodes wrapping it.\n *\n * The returned arrays preserve root→leaf order so callers can either\n * - read the LAST entry as the nearest ancestor (e.g. parentRepeaterUid), or\n * - join their bindings to derive the cumulative schema path.\n *\n * Returns a map keyed by section-slot uid. If a slot uid is missing from the\n * map the slot isn't wrapped by any Repeater / ConditionBlock in the section\n * (or doesn't exist in this section).\n */\nfunction indexSectionSlotContexts(sectionUI) {\n const out = {};\n const walk = (node, ancestors) => {\n if (!node || typeof node !== \"object\")\n return;\n if (node.type === \"section-slot\" && typeof node.uid === \"string\") {\n out[node.uid] = { ancestorNodes: ancestors };\n }\n const nextAncestors = node.type === \"repeater\" || node.type === \"condition-block\"\n ? [...ancestors, node]\n : ancestors;\n const slots = node.slots || {};\n for (const slotId of Object.keys(slots)) {\n for (const child of slots[slotId] || []) {\n walk(child, nextAncestors);\n }\n }\n };\n walk(sectionUI, []);\n return out;\n}\n\nexport { indexSectionSlotContexts };\n//# sourceMappingURL=section-slot-walker.js.map\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,wBAAwB,CAAC,SAAS,EAAE;AAC7C,IAAI,MAAM,GAAG,GAAG,EAAE;AAClB,IAAI,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK;AACtC,QAAQ,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;AAC7C,YAAY;AACZ,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,EAAE;AAC1E,YAAY,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE;AACxD,QAAQ;AACR,QAAQ,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK;AACxE,cAAc,CAAC,GAAG,SAAS,EAAE,IAAI;AACjC,cAAc,SAAS;AACvB,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;AACtC,QAAQ,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AACjD,YAAY,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE;AACrD,gBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC;AAC1C,YAAY;AACZ,QAAQ;AACR,IAAI,CAAC;AACL,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;AACvB,IAAI,OAAO,GAAG;AACd;;;;"}
@@ -1,4 +1,4 @@
1
- import { unzlibSync } from '../../../../node_modules/fflate/esm/browser.js';
1
+ import { unzlibSync } from 'fflate';
2
2
 
3
3
  /**
4
4
  * Decompress a UI spec from storage.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-compression.js","sources":["../../../../../studio-internal/dist/utils/spec-compression.js"],"sourcesContent":["import { zlibSync, unzlibSync } from 'fflate';\n\n/**\n * Compress a UI spec using zlib compression for storage.\n *\n * The compressed output is base64-encoded and prefixed with \"zlib:\" for format detection.\n * This achieves 77-90% size reduction on typical UI specs.\n * Uses fflate library which works in both Node.js and browser environments.\n *\n * @param spec - The UI spec Node to compress\n * @returns Base64-encoded compressed string prefixed with \"zlib:\"\n *\n * @example\n * const compressed = compressSpec(editor.getUI());\n * // Returns: \"zlib:eJzt3Vtv2...\"\n */\nfunction compressSpec(spec) {\n const json = JSON.stringify(spec);\n const encoder = new TextEncoder();\n const uint8Array = encoder.encode(json);\n // Level 9 = max compression\n const compressed = zlibSync(uint8Array, { level: 9 });\n // Convert to base64\n const base64 = btoa(String.fromCharCode(...compressed));\n return \"zlib:\" + base64;\n}\n/**\n * Decompress a UI spec from storage.\n *\n * Automatically detects and handles both formats:\n * - Compressed format: \"zlib:...\" (base64-encoded zlib)\n * - Legacy format: Raw JSON string\n *\n * This provides backward compatibility with existing uncompressed specs.\n *\n * @param data - Compressed or legacy JSON string from storage\n * @returns Parsed Node object\n *\n * @example\n * // Compressed format\n * const spec = decompressSpec(\"zlib:eJzt3Vtv2...\");\n *\n * // Legacy format (backward compatible)\n * const spec = decompressSpec('{\"uid\":\"abc\",\"type\":\"page\",...}');\n */\nfunction decompressSpec(data) {\n // Detect compressed format\n if (data.startsWith(\"zlib:\")) {\n const base64 = data.slice(5);\n // Decode base64 to Uint8Array\n const binaryString = atob(base64);\n const uint8Array = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n uint8Array[i] = binaryString.charCodeAt(i);\n }\n // Decompress\n const decompressed = unzlibSync(uint8Array);\n const decoder = new TextDecoder();\n const json = decoder.decode(decompressed);\n return JSON.parse(json);\n }\n // Legacy uncompressed format\n return JSON.parse(data);\n}\n/**\n * Validate compression with round-trip test.\n * Use this during development to ensure data integrity.\n *\n * @param spec - The spec to validate\n * @returns Object with validation results\n *\n * @example\n * const result = validateCompression(editor.getUI());\n * console.log(`Compression: ${result.compressionRatio}%`);\n * console.log(`Integrity: ${result.isIdentical ? 'PASS' : 'FAIL'}`);\n */\nfunction validateCompression(spec) {\n const original = JSON.stringify(spec);\n const encoder = new TextEncoder();\n const originalSize = encoder.encode(original).length;\n // Compress\n const compressed = compressSpec(spec);\n const compressedSize = encoder.encode(compressed).length;\n // Decompress\n const restored = decompressSpec(compressed);\n const restoredStr = JSON.stringify(restored);\n // Verify integrity\n const isIdentical = original === restoredStr;\n const compressionRatio = parseFloat(((1 - compressedSize / originalSize) * 100).toFixed(2));\n return {\n originalSize,\n compressedSize,\n compressionRatio,\n isIdentical,\n };\n}\n\nexport { compressSpec, decompressSpec, validateCompression };\n//# sourceMappingURL=spec-compression.js.map\n"],"names":[],"mappings":";;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,IAAI,EAAE;AAC9B;AACA,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;AAClC,QAAQ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACpC;AACA,QAAQ,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;AACzC,QAAQ,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC;AAC9D,QAAQ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtD,YAAY,UAAU,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;AACtD,QAAQ;AACR;AACA,QAAQ,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,CAAC;AACnD,QAAQ,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE;AACzC,QAAQ,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;AACjD,QAAQ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AAC/B,IAAI;AACJ;AACA,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AAC3B;;;;"}
@@ -22,7 +22,7 @@ const isBrowser = () => {
22
22
  */
23
23
  const INCLUDE_DEPTH_COUNT = 3;
24
24
  // SDK Version constants for Studio Intelligence
25
- const SDK_VERSION = "1.7.0";
25
+ const SDK_VERSION = "1.7.1";
26
26
  const SCHEMA_VERSION = "1.0.0";
27
27
  const COMPOSABLE_DATA_ATTRIBUTES = {
28
28
  BUILDER: "data-composable-studio-builder",
@@ -0,0 +1,142 @@
1
+ import { COMPOSABLE_STUDIO_QUERY_PARAM, IS_BROWSER } from '@contentstack/studio-messenger';
2
+
3
+ /**
4
+ * Stable editor-mode detection contract.
5
+ *
6
+ * The Studio canvas loads the host app in an iframe, which drags the host's
7
+ * third-party baggage into the authoring surface: cookie banners (OneTrust),
8
+ * chat widgets (Intercom/Qualified/Drift) overlapping Studio's panels, GTM /
9
+ * analytics / marketing pixels counting author sessions as real visitors,
10
+ * and feature-flag SDKs throwing origin errors. Every enterprise ends up
11
+ * hand-rolling detection from undocumented signals.
12
+ *
13
+ * This module is the canonical answer. Three STABLE signals — versioned,
14
+ * non-breaking — any of which a customer may rely on:
15
+ *
16
+ * 1. Query param: `cs-composable-studio` is always present on canvas and
17
+ * template-preview iframe loads (exported as {@link STUDIO_CANVAS_QUERY_PARAM}).
18
+ * 2. `<html>` class: {@link STUDIO_MODE_HTML_CLASS} (`cs-studio-canvas`),
19
+ * added by the SDK bootstrap at first module evaluation in the browser.
20
+ * 3. `window.__CS_STUDIO_MODE__`: `'canvas' | 'preview' | 'visitor'`, set
21
+ * synchronously by the same bootstrap — and readable before it runs via
22
+ * the same logic {@link detectStudioMode} applies.
23
+ *
24
+ * And one helper that combines them: {@link isStudioCanvas}. SSR-safe —
25
+ * returns false on the server unless you pass the request's search params.
26
+ *
27
+ * @example Gate third-party scripts
28
+ * ```ts
29
+ * import { isStudioCanvas } from "@contentstack/studio-react";
30
+ *
31
+ * if (!isStudioCanvas()) {
32
+ * OneTrust.init(config);
33
+ * window.dataLayer?.push({ event: "pageview" });
34
+ * posthog.init(POSTHOG_KEY);
35
+ * }
36
+ * ```
37
+ *
38
+ * @example GTM (injects before the SDK loads — inline the check)
39
+ * ```html
40
+ * <script>
41
+ * window.dataLayer = window.dataLayer || [];
42
+ * window.dataLayer.push({
43
+ * cs_studio_canvas:
44
+ * new URLSearchParams(location.search).has("cs-composable-studio"),
45
+ * });
46
+ * </script>
47
+ * <!-- GTM snippet here; gate every tag on {{cs_studio_canvas}} equals false -->
48
+ * ```
49
+ */
50
+ /**
51
+ * The query param Studio always appends to canvas / template-preview iframe
52
+ * URLs. Part of the stable contract — changing its value is a breaking
53
+ * change and will be release-noted as such.
54
+ */
55
+ const STUDIO_CANVAS_QUERY_PARAM = COMPOSABLE_STUDIO_QUERY_PARAM.ENABLED;
56
+ /**
57
+ * Class the SDK bootstrap adds to `<html>` when running inside the Studio
58
+ * canvas. Available for CSS-only gating (e.g. `html.cs-studio-canvas
59
+ * #onetrust-banner-sdk { display: none }`).
60
+ */
61
+ const STUDIO_MODE_HTML_CLASS = "cs-studio-canvas";
62
+ const toParams = (searchQuery) => {
63
+ if (searchQuery !== undefined) {
64
+ return searchQuery instanceof URLSearchParams
65
+ ? searchQuery
66
+ : new URLSearchParams(searchQuery);
67
+ }
68
+ if (!IS_BROWSER)
69
+ return null;
70
+ return new URLSearchParams(window.location.search);
71
+ };
72
+ const modeFromParams = (params) => {
73
+ if (params.has(COMPOSABLE_STUDIO_QUERY_PARAM.ENABLED) ||
74
+ params.get(COMPOSABLE_STUDIO_QUERY_PARAM.VISUAL_BUILDER) === "true") {
75
+ return "canvas";
76
+ }
77
+ if (params.has(COMPOSABLE_STUDIO_QUERY_PARAM.PREVIEW_HASH) ||
78
+ params.has(COMPOSABLE_STUDIO_QUERY_PARAM.LIVE_PREVIEW_HASH)) {
79
+ return "preview";
80
+ }
81
+ return "visitor";
82
+ };
83
+ /**
84
+ * Detects the current Studio mode.
85
+ *
86
+ * Browser: the `window.__CS_STUDIO_MODE__` marker wins when present (it
87
+ * survives client-side navigations that strip query params); otherwise the
88
+ * URL's query params decide.
89
+ *
90
+ * Server: pass the request's search params (string or URLSearchParams) to
91
+ * get a real answer; with no arguments it safely reports `"visitor"`.
92
+ */
93
+ function detectStudioMode(searchQuery) {
94
+ if (searchQuery === undefined && IS_BROWSER && window.__CS_STUDIO_MODE__) {
95
+ return window.__CS_STUDIO_MODE__;
96
+ }
97
+ const params = toParams(searchQuery);
98
+ if (!params)
99
+ return "visitor";
100
+ return modeFromParams(params);
101
+ }
102
+ /**
103
+ * True when the host app is rendering inside the Studio canvas (or Visual
104
+ * Builder frame) — the one check to gate cookie banners, chat widgets,
105
+ * analytics, marketing pixels, and feature-flag bootstraps behind.
106
+ *
107
+ * SSR-safe: returns false on the server unless the request's search params
108
+ * are passed explicitly.
109
+ */
110
+ function isStudioCanvas(searchQuery) {
111
+ return detectStudioMode(searchQuery) === "canvas";
112
+ }
113
+ /**
114
+ * True in any Studio-driven context (canvas OR live-preview pane). Use when
115
+ * a third-party should also stay out of preview sessions — e.g. analytics.
116
+ */
117
+ function isStudioEditorMode(searchQuery) {
118
+ return detectStudioMode(searchQuery) !== "visitor";
119
+ }
120
+ /**
121
+ * Bootstrap: computes the mode from the current URL, stamps
122
+ * `window.__CS_STUDIO_MODE__`, and (for canvas mode) adds
123
+ * {@link STUDIO_MODE_HTML_CLASS} to `<html>`. Idempotent; no-op on the
124
+ * server. Invoked automatically when `@contentstack/studio-react` loads in
125
+ * the browser — call it manually only if you gate scripts that run before
126
+ * the SDK's module graph is evaluated.
127
+ */
128
+ function markStudioMode() {
129
+ if (!IS_BROWSER)
130
+ return "visitor";
131
+ if (window.__CS_STUDIO_MODE__)
132
+ return window.__CS_STUDIO_MODE__;
133
+ const mode = modeFromParams(new URLSearchParams(window.location.search));
134
+ window.__CS_STUDIO_MODE__ = mode;
135
+ if (mode === "canvas") {
136
+ document.documentElement.classList.add(STUDIO_MODE_HTML_CLASS);
137
+ }
138
+ return mode;
139
+ }
140
+
141
+ export { STUDIO_CANVAS_QUERY_PARAM, STUDIO_MODE_HTML_CLASS, detectStudioMode, isStudioCanvas, isStudioEditorMode, markStudioMode };
142
+ //# sourceMappingURL=editor-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-mode.js","sources":["../../src/utils/editor-mode.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CG;AASH;;;;AAIG;AACI,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEvE;;;;AAIG;AACI,MAAM,sBAAsB,GAAG;AAQtC,MAAM,QAAQ,GAAG,CACf,WAAsC,KACZ;AAC1B,IAAA,IAAI,WAAW,KAAK,SAAS,EAAE;QAC7B,OAAO,WAAW,YAAY;AAC5B,cAAE;AACF,cAAE,IAAI,eAAe,CAAC,WAAW,CAAC;IACtC;AACA,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,IAAI;IAC5B,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;AACpD,CAAC;AAED,MAAM,cAAc,GAAG,CAAC,MAAuB,KAAgB;AAC7D,IAAA,IACE,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,OAAO,CAAC;QACjD,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,cAAc,CAAC,KAAK,MAAM,EACnE;AACA,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IACE,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,YAAY,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,iBAAiB,CAAC,EAC3D;AACA,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,OAAO,SAAS;AAClB,CAAC;AAED;;;;;;;;;AASG;AACG,SAAU,gBAAgB,CAC9B,WAAsC,EAAA;IAEtC,IAAI,WAAW,KAAK,SAAS,IAAI,UAAU,IAAI,MAAM,CAAC,kBAAkB,EAAE;QACxE,OAAO,MAAM,CAAC,kBAAkB;IAClC;AACA,IAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC;AACpC,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,SAAS;AAC7B,IAAA,OAAO,cAAc,CAAC,MAAM,CAAC;AAC/B;AAEA;;;;;;;AAOG;AACG,SAAU,cAAc,CAC5B,WAAsC,EAAA;AAEtC,IAAA,OAAO,gBAAgB,CAAC,WAAW,CAAC,KAAK,QAAQ;AACnD;AAEA;;;AAGG;AACG,SAAU,kBAAkB,CAChC,WAAsC,EAAA;AAEtC,IAAA,OAAO,gBAAgB,CAAC,WAAW,CAAC,KAAK,SAAS;AACpD;AAEA;;;;;;;AAOG;SACa,cAAc,GAAA;AAC5B,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,SAAS;IACjC,IAAI,MAAM,CAAC,kBAAkB;QAAE,OAAO,MAAM,CAAC,kBAAkB;AAC/D,IAAA,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACxE,IAAA,MAAM,CAAC,kBAAkB,GAAG,IAAI;AAChC,IAAA,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAChE;AACA,IAAA,OAAO,IAAI;AACb;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { DATA_SOURCES } from '@contentstack/studio-registry';
2
2
  import { uniq, merge } from 'lodash-es';
3
3
  import { getBindingStringForCS } from './sdk.js';
4
- import { decompressSpec } from '../packages/studio-internal/dist/utils/spec-compression.js';
4
+ import { decompressSpec } from '../studio-internal/dist/utils/spec-compression.js';
5
5
 
6
6
  // Strip numeric array indexes and "entries" array-wrapper segments so that
7
7
  // binding-traversal paths like "entries.0.cross_links" or "entries.cross_links"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-client",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -30,9 +30,9 @@
30
30
  "url": "https://github.com/contentstack/composable-studio-sdk/issues"
31
31
  },
32
32
  "devDependencies": {
33
- "@contentstack/common-config": "^1.2.0",
33
+ "@contentstack/common-config": "^1.2.1",
34
34
  "@contentstack/delivery-sdk": "^4.5.0",
35
- "@contentstack/studio-internal": "^1.3.0",
35
+ "@contentstack/studio-internal": "^1.3.1",
36
36
  "@rollup/plugin-commonjs": "^28.0.6",
37
37
  "@rollup/plugin-node-resolve": "^16.0.1",
38
38
  "@rollup/plugin-replace": "^6.0.3",
@@ -48,13 +48,14 @@
48
48
  "typescript": "^5.5.4"
49
49
  },
50
50
  "dependencies": {
51
- "@contentstack/studio-message-types": "^1.3.0",
52
- "@contentstack/studio-messenger": "^1.5.0",
53
- "@contentstack/studio-registry": "^1.6.0",
51
+ "@contentstack/studio-message-types": "^1.3.1",
52
+ "@contentstack/studio-messenger": "^1.5.1",
53
+ "@contentstack/studio-registry": "^1.6.1",
54
54
  "eventemitter3": "^5.0.1",
55
+ "fflate": "^0.8.2",
55
56
  "html2canvas": "^1.4.1",
56
57
  "lodash-es": "^4.18.1",
57
58
  "zod": "^3.23.8"
58
59
  },
59
- "gitHead": "8ac2eaeeeab2403708cf075475d8553832fb7866"
60
+ "gitHead": "27539dc404d9358c9aa334ccbe6cd98e0405c205"
60
61
  }
@@ -1,378 +0,0 @@
1
- // DEFLATE is a complex format; to read this code, you should probably check the RFC first:
2
- // https://tools.ietf.org/html/rfc1951
3
- // You may also wish to take a look at the guide I made about this program:
4
- // https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad
5
- // Some of the following code is similar to that of UZIP.js:
6
- // https://github.com/photopea/UZIP.js
7
- // However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
8
- // Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
9
- // is better for memory in most engines (I *think*).
10
-
11
- // aliases for shorter compressed code (most minifers don't do this)
12
- var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
13
- // fixed length extra bits
14
- var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);
15
- // fixed distance extra bits
16
- var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);
17
- // code length index map
18
- var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
19
- // get base, reverse index map from extra bits
20
- var freb = function (eb, start) {
21
- var b = new u16(31);
22
- for (var i = 0; i < 31; ++i) {
23
- b[i] = start += 1 << eb[i - 1];
24
- }
25
- // numbers here are at max 18 bits
26
- var r = new i32(b[30]);
27
- for (var i = 1; i < 30; ++i) {
28
- for (var j = b[i]; j < b[i + 1]; ++j) {
29
- r[j] = ((j - b[i]) << 5) | i;
30
- }
31
- }
32
- return { b: b, r: r };
33
- };
34
- var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
35
- // we can ignore the fact that the other numbers are wrong; they never happen anyway
36
- fl[28] = 258, revfl[258] = 28;
37
- var _b = freb(fdeb, 0), fd = _b.b;
38
- // map of value to reverse (assuming 16 bits)
39
- var rev = new u16(32768);
40
- for (var i = 0; i < 32768; ++i) {
41
- // reverse table algorithm from SO
42
- var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);
43
- x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);
44
- x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);
45
- rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;
46
- }
47
- // create huffman tree from u8 "map": index -> code length for code index
48
- // mb (max bits) must be at most 15
49
- // TODO: optimize/split up?
50
- var hMap = (function (cd, mb, r) {
51
- var s = cd.length;
52
- // index
53
- var i = 0;
54
- // u16 "map": index -> # of codes with bit length = index
55
- var l = new u16(mb);
56
- // length of cd must be 288 (total # of codes)
57
- for (; i < s; ++i) {
58
- if (cd[i])
59
- ++l[cd[i] - 1];
60
- }
61
- // u16 "map": index -> minimum code for bit length = index
62
- var le = new u16(mb);
63
- for (i = 1; i < mb; ++i) {
64
- le[i] = (le[i - 1] + l[i - 1]) << 1;
65
- }
66
- var co;
67
- if (r) {
68
- // u16 "map": index -> number of actual bits, symbol for code
69
- co = new u16(1 << mb);
70
- // bits to remove for reverser
71
- var rvb = 15 - mb;
72
- for (i = 0; i < s; ++i) {
73
- // ignore 0 lengths
74
- if (cd[i]) {
75
- // num encoding both symbol and bits read
76
- var sv = (i << 4) | cd[i];
77
- // free bits
78
- var r_1 = mb - cd[i];
79
- // start value
80
- var v = le[cd[i] - 1]++ << r_1;
81
- // m is end value
82
- for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {
83
- // every 16 bit value starting with the code yields the same result
84
- co[rev[v] >> rvb] = sv;
85
- }
86
- }
87
- }
88
- }
89
- else {
90
- co = new u16(s);
91
- for (i = 0; i < s; ++i) {
92
- if (cd[i]) {
93
- co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);
94
- }
95
- }
96
- }
97
- return co;
98
- });
99
- // fixed length tree
100
- var flt = new u8(288);
101
- for (var i = 0; i < 144; ++i)
102
- flt[i] = 8;
103
- for (var i = 144; i < 256; ++i)
104
- flt[i] = 9;
105
- for (var i = 256; i < 280; ++i)
106
- flt[i] = 7;
107
- for (var i = 280; i < 288; ++i)
108
- flt[i] = 8;
109
- // fixed distance tree
110
- var fdt = new u8(32);
111
- for (var i = 0; i < 32; ++i)
112
- fdt[i] = 5;
113
- // fixed length map
114
- var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
115
- // fixed distance map
116
- var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
117
- // find max of array
118
- var max = function (a) {
119
- var m = a[0];
120
- for (var i = 1; i < a.length; ++i) {
121
- if (a[i] > m)
122
- m = a[i];
123
- }
124
- return m;
125
- };
126
- // read d, starting at bit p and mask with m
127
- var bits = function (d, p, m) {
128
- var o = (p / 8) | 0;
129
- return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
130
- };
131
- // read d, starting at bit p continuing for at least 16 bits
132
- var bits16 = function (d, p) {
133
- var o = (p / 8) | 0;
134
- return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
135
- };
136
- // get end of byte
137
- var shft = function (p) { return ((p + 7) / 8) | 0; };
138
- // typed array slice - allows garbage collector to free original reference,
139
- // while being more compatible than .slice
140
- var slc = function (v, s, e) {
141
- if (e == null || e > v.length)
142
- e = v.length;
143
- // can't use .constructor in case user-supplied
144
- return new u8(v.subarray(s, e));
145
- };
146
- // error codes
147
- var ec = [
148
- 'unexpected EOF',
149
- 'invalid block type',
150
- 'invalid length/literal',
151
- 'invalid distance',
152
- 'stream finished',
153
- 'no stream handler',
154
- , // determined by compression function
155
- 'no callback',
156
- 'invalid UTF-8 data',
157
- 'extra field too long',
158
- 'date not in range 1980-2099',
159
- 'filename too long',
160
- 'stream finishing',
161
- 'invalid zip data'
162
- // determined by unknown compression method
163
- ];
164
- var err = function (ind, msg, nt) {
165
- var e = new Error(msg || ec[ind]);
166
- e.code = ind;
167
- if (Error.captureStackTrace)
168
- Error.captureStackTrace(e, err);
169
- if (!nt)
170
- throw e;
171
- return e;
172
- };
173
- // expands raw DEFLATE data
174
- var inflt = function (dat, st, buf, dict) {
175
- // source length dict length
176
- var sl = dat.length, dl = 0;
177
- if (!sl || st.f && !st.l)
178
- return buf || new u8(0);
179
- var noBuf = !buf;
180
- // have to estimate size
181
- var resize = noBuf || st.i != 2;
182
- // no state
183
- var noSt = st.i;
184
- // Assumes roughly 33% compression ratio average
185
- if (noBuf)
186
- buf = new u8(sl * 3);
187
- // ensure buffer can fit at least l elements
188
- var cbuf = function (l) {
189
- var bl = buf.length;
190
- // need to increase size to fit
191
- if (l > bl) {
192
- // Double or set to necessary, whichever is greater
193
- var nbuf = new u8(Math.max(bl * 2, l));
194
- nbuf.set(buf);
195
- buf = nbuf;
196
- }
197
- };
198
- // last chunk bitpos bytes
199
- var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
200
- // total bits
201
- var tbts = sl * 8;
202
- do {
203
- if (!lm) {
204
- // BFINAL - this is only 1 when last chunk is next
205
- final = bits(dat, pos, 1);
206
- // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
207
- var type = bits(dat, pos + 1, 3);
208
- pos += 3;
209
- if (!type) {
210
- // go to end of byte boundary
211
- var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
212
- if (t > sl) {
213
- if (noSt)
214
- err(0);
215
- break;
216
- }
217
- // ensure size
218
- if (resize)
219
- cbuf(bt + l);
220
- // Copy over uncompressed data
221
- buf.set(dat.subarray(s, t), bt);
222
- // Get new bitpos, update byte count
223
- st.b = bt += l, st.p = pos = t * 8, st.f = final;
224
- continue;
225
- }
226
- else if (type == 1)
227
- lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
228
- else if (type == 2) {
229
- // literal lengths
230
- var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
231
- var tl = hLit + bits(dat, pos + 5, 31) + 1;
232
- pos += 14;
233
- // length+distance tree
234
- var ldt = new u8(tl);
235
- // code length tree
236
- var clt = new u8(19);
237
- for (var i = 0; i < hcLen; ++i) {
238
- // use index map to get real code
239
- clt[clim[i]] = bits(dat, pos + i * 3, 7);
240
- }
241
- pos += hcLen * 3;
242
- // code lengths bits
243
- var clb = max(clt), clbmsk = (1 << clb) - 1;
244
- // code lengths map
245
- var clm = hMap(clt, clb, 1);
246
- for (var i = 0; i < tl;) {
247
- var r = clm[bits(dat, pos, clbmsk)];
248
- // bits read
249
- pos += r & 15;
250
- // symbol
251
- var s = r >> 4;
252
- // code length to copy
253
- if (s < 16) {
254
- ldt[i++] = s;
255
- }
256
- else {
257
- // copy count
258
- var c = 0, n = 0;
259
- if (s == 16)
260
- n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
261
- else if (s == 17)
262
- n = 3 + bits(dat, pos, 7), pos += 3;
263
- else if (s == 18)
264
- n = 11 + bits(dat, pos, 127), pos += 7;
265
- while (n--)
266
- ldt[i++] = c;
267
- }
268
- }
269
- // length tree distance tree
270
- var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
271
- // max length bits
272
- lbt = max(lt);
273
- // max dist bits
274
- dbt = max(dt);
275
- lm = hMap(lt, lbt, 1);
276
- dm = hMap(dt, dbt, 1);
277
- }
278
- else
279
- err(1);
280
- if (pos > tbts) {
281
- if (noSt)
282
- err(0);
283
- break;
284
- }
285
- }
286
- // Make sure the buffer can hold this + the largest possible addition
287
- // Maximum chunk size (practically, theoretically infinite) is 2^17
288
- if (resize)
289
- cbuf(bt + 131072);
290
- var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
291
- var lpos = pos;
292
- for (;; lpos = pos) {
293
- // bits read, code
294
- var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
295
- pos += c & 15;
296
- if (pos > tbts) {
297
- if (noSt)
298
- err(0);
299
- break;
300
- }
301
- if (!c)
302
- err(2);
303
- if (sym < 256)
304
- buf[bt++] = sym;
305
- else if (sym == 256) {
306
- lpos = pos, lm = null;
307
- break;
308
- }
309
- else {
310
- var add = sym - 254;
311
- // no extra bits needed if less
312
- if (sym > 264) {
313
- // index
314
- var i = sym - 257, b = fleb[i];
315
- add = bits(dat, pos, (1 << b) - 1) + fl[i];
316
- pos += b;
317
- }
318
- // dist
319
- var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
320
- if (!d)
321
- err(3);
322
- pos += d & 15;
323
- var dt = fd[dsym];
324
- if (dsym > 3) {
325
- var b = fdeb[dsym];
326
- dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
327
- }
328
- if (pos > tbts) {
329
- if (noSt)
330
- err(0);
331
- break;
332
- }
333
- if (resize)
334
- cbuf(bt + 131072);
335
- var end = bt + add;
336
- if (bt < dt) {
337
- var shift = dl - dt, dend = Math.min(dt, end);
338
- if (shift + bt < 0)
339
- err(3);
340
- for (; bt < dend; ++bt)
341
- buf[bt] = dict[shift + bt];
342
- }
343
- for (; bt < end; ++bt)
344
- buf[bt] = buf[bt - dt];
345
- }
346
- }
347
- st.l = lm, st.p = lpos, st.b = bt, st.f = final;
348
- if (lm)
349
- final = 1, st.m = lbt, st.d = dm, st.n = dbt;
350
- } while (!final);
351
- // don't reallocate for streams or user buffers
352
- return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
353
- };
354
- // empty
355
- var et = /*#__PURE__*/ new u8(0);
356
- // zlib start
357
- var zls = function (d, dict) {
358
- if ((d[0] & 15) != 8 || (d[0] >> 4) > 7 || ((d[0] << 8 | d[1]) % 31))
359
- err(6, 'invalid zlib data');
360
- if ((d[1] >> 5 & 1) == 1)
361
- err(6, 'invalid zlib data: ' + (d[1] & 32 ? 'need' : 'unexpected') + ' dictionary');
362
- return (d[1] >> 3 & 4) + 2;
363
- };
364
- function unzlibSync(data, opts) {
365
- return inflt(data.subarray(zls(data), -4), { i: 2 }, opts, opts);
366
- }
367
- // text decoder
368
- var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();
369
- // text decoder stream
370
- var tds = 0;
371
- try {
372
- td.decode(et, { stream: true });
373
- tds = 1;
374
- }
375
- catch (e) { }
376
-
377
- export { unzlibSync };
378
- //# sourceMappingURL=browser.js.map