@contentstack/studio-core 1.4.4 → 1.5.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/dist/index.d.ts CHANGED
@@ -1,24 +1,55 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _contentstack_studio_client from '@contentstack/studio-client';
3
3
  import { StudioSpec, FontVariants, LightConfig, ComposableStudioLightSdk, StudioSdk, UserConfig } from '@contentstack/studio-client';
4
+ import { ExposedPropRegistryLike } from '@contentstack/studio-registry';
5
+ import { css as css$1 } from 'goober';
4
6
  import { NodeStyles } from '@contentstack/studio-internal';
5
7
 
6
8
  declare const Button: (props: React.ButtonHTMLAttributes<HTMLButtonElement>) => react_jsx_runtime.JSX.Element;
7
9
 
10
+ interface ExtractStylesOptions {
11
+ /**
12
+ * Registry that decides which exposed section props are design props
13
+ * (ADR 0004). Defaults to the client graph's registry; the RSC entry passes
14
+ * its server-graph registry.
15
+ */
16
+ componentRegistry?: ExposedPropRegistryLike;
17
+ }
8
18
  /**
9
- * Extracts and concatenates CSS styles from a list of composition specifications.
19
+ * The CSS a server render of the given compositions needs: every node's
20
+ * responsive classes, the sections each embeds included (with each placement's
21
+ * exposed design props), and the Open in Studio button's.
10
22
  *
11
- * @param {(StudioSpec | null)[]} specs - Array of composition specifications to extract styles from
12
- * @returns {string} Combined CSS styles string including root styles and composition-specific styles
23
+ * Collected into a private sheet ({@link collectCss}): exactly these
24
+ * compositions' rules, each once — the same string for the same compositions,
25
+ * on the server and in the browser. goober's shared sheet is neither read nor
26
+ * emptied: on the server it holds other renders' and other libraries' CSS,
27
+ * and in the browser it is the page's `<style id="_goober">`, which every
28
+ * goober user on the page writes to.
29
+ */
30
+ declare const extractStyles: (specs: (StudioSpec | null)[], options?: ExtractStylesOptions) => string;
31
+
32
+ /**
33
+ * goober's `css`, for Studio's own styles: the same class names, but
13
34
  *
14
- * @description
15
- * This function performs the following:
16
- * 1. Extracts root CSS styles if not already extracted
17
- * 2. Flushes any previously collected styles
18
- * 3. Extracts styles from each valid composition specification
19
- * 4. Combines root styles with composition-specific styles
35
+ * - while {@link collectCss} runs, it writes to that collection's sheet;
36
+ * - on the server, outside a collection, it writes nowhere — a render needs
37
+ * only the class names, and its CSS comes from a collection, so Studio's
38
+ * rules do not pile up in goober's per-process buffer (or reach another
39
+ * library's `extractCss()`);
40
+ * - in the browser, outside a collection, it writes to the page's sheet, as
41
+ * goober does.
42
+ */
43
+ declare const css: typeof css$1;
44
+ /**
45
+ * Runs `fn` with Studio's goober calls ({@link css}) writing to a private
46
+ * sheet, and returns the CSS they wrote: the rules `fn` generated, each once,
47
+ * whatever else the process or page has generated — so the same compositions
48
+ * give the same CSS every time, on the server and in the browser. goober's
49
+ * shared buffer and the page's `<style id="_goober">` are neither read nor
50
+ * changed. `fn` runs synchronously, so nothing else writes in between.
20
51
  */
21
- declare const extractStyles: (specs: (StudioSpec | null)[]) => string;
52
+ declare function collectCss(fn: () => void): string;
22
53
 
23
54
  declare function handleNodeStyles(nodeStyles: NodeStyles, nodeUid: string): [string, Record<string, string>, Set<string>, Map<string, FontVariants>];
24
55
 
@@ -78,16 +109,17 @@ declare const studioSdk: {
78
109
  init(userConfig: UserConfig): {
79
110
  fetchCompositionData: (queryOptions: _contentstack_studio_client.CompositionQueryForSSRInput, options?: _contentstack_studio_client.CompositionQueryOptions) => Promise<_contentstack_studio_client.StudioComponentSpecOptions>;
80
111
  fetchComposition: (queryOptions: _contentstack_studio_client.CompositionQueryForSSRInput, options?: _contentstack_studio_client.CompositionQueryOptions) => Promise<_contentstack_studio_client.StudioSpec>;
81
- getConfig: () => Pick<_contentstack_studio_client.Config, "contentTypeUid" | "cslp" | "openInStudioButton">;
112
+ getConfig: () => Pick<_contentstack_studio_client.Config, "openInStudioButton" | "contentTypeUid" | "cslp">;
82
113
  };
83
114
  };
84
115
  declare function lightInit(userConfig?: LightConfig): {
85
116
  internal: {
86
- getConfig: () => Pick<LightConfig, "contentTypeUid" | "cslp" | "openInStudioButton">;
117
+ getConfig: () => Pick<LightConfig, "openInStudioButton" | "contentTypeUid" | "cslp">;
87
118
  };
88
119
  } | null;
89
120
 
90
121
  declare const EDIT_COMPOSITION_LABEL = "Edit Composition";
91
122
  declare const EDIT_SECTIONS_LABEL = "Edit Sections";
92
123
 
93
- export { Button, EDIT_COMPOSITION_LABEL, EDIT_SECTIONS_LABEL, extractStyles, handleNodeStyles, lightInit, lightSdk, sdk, studioSdk };
124
+ export { Button, EDIT_COMPOSITION_LABEL, EDIT_SECTIONS_LABEL, collectCss, extractStyles, handleNodeStyles, lightInit, lightSdk, sdk, css as studioCss, studioSdk };
125
+ export type { ExtractStylesOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { Button } from './internal-components/Button.js';
2
2
  export { extractStyles } from './style-extractor/extract-styles.js';
3
+ export { collectCss, css as studioCss } from './style-extractor/style-sheet.js';
3
4
  export { handleNodeStyles } from './utils/handle-responsive-styles.util.js';
4
5
  export { lightInit, lightSdk, sdk, studioSdk } from './sdk/index.js';
5
6
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AACO,MAAM,sBAAsB,GAAG;AAC/B,MAAM,mBAAmB,GAAG;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AACO,MAAM,sBAAsB,GAAG;AAC/B,MAAM,mBAAmB,GAAG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { css } from 'goober';
2
+ import { css } from '../style-extractor/style-sheet.js';
3
3
  import { styleFactory } from './styles.js';
4
4
 
5
5
  const INTER_FONT_ID = "cs-studio-inter-font";
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../src/internal-components/Button.tsx"],"sourcesContent":[null],"names":["_jsx","gooberCss"],"mappings":";;;;AAGA,MAAM,aAAa,GAAG,sBAAsB;AAE5C,SAAS,qBAAqB,GAAA;IAC5B,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE;AACrC,IAAA,IAAI,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC;QAAE;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;AAC3C,IAAA,IAAI,CAAC,EAAE,GAAG,aAAa;AACvB,IAAA,IAAI,CAAC,GAAG,GAAG,YAAY;;;;AAIvB,IAAA,IAAI,CAAC,IAAI;AACP,QAAA,2EAA2E;AAC7E,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;AACjC;AAEO,MAAM,MAAM,GAAG,CACpB,KAAoD,KAClD;AACF,IAAA,qBAAqB,EAAE;IACvB,QACEA,mBACM,KAAK,EACT,SAAS,EAAE,CAAA,EAAG,YAAY,CAACC,GAAS,CAAC,CAAC,kBAAkB,CAAA,CAAA,EAAI,KAAK,CAAC,SAAS,IAAI,EAAE,CAAA,CAAE,EAAA,CACnF;AAEN;;;;"}
1
+ {"version":3,"file":"Button.js","sources":["../../src/internal-components/Button.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;AAGA,MAAM,aAAa,GAAG,sBAAsB;AAE5C,SAAS,qBAAqB,GAAA;IAC5B,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE;AACrC,IAAA,IAAI,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC;QAAE;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;AAC3C,IAAA,IAAI,CAAC,EAAE,GAAG,aAAa;AACvB,IAAA,IAAI,CAAC,GAAG,GAAG,YAAY;;;;AAIvB,IAAA,IAAI,CAAC,IAAI;AACP,QAAA,2EAA2E;AAC7E,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;AACjC;AAEO,MAAM,MAAM,GAAG,CACpB,KAAoD,KAClD;AACF,IAAA,qBAAqB,EAAE;IACvB,QACEA,mBACM,KAAK,EACT,SAAS,EAAE,CAAA,EAAG,YAAY,CAAC,GAAG,CAAC,CAAC,kBAAkB,CAAA,CAAA,EAAI,KAAK,CAAC,SAAS,IAAI,EAAE,CAAA,CAAE,EAAA,CAC7E;AAEN;;;;"}
@@ -55,12 +55,12 @@ export declare const studioSdk: {
55
55
  init(userConfig: UserConfig): {
56
56
  fetchCompositionData: (queryOptions: import("@contentstack/studio-client").CompositionQueryForSSRInput, options?: import("@contentstack/studio-client").CompositionQueryOptions) => Promise<import("@contentstack/studio-client").StudioComponentSpecOptions>;
57
57
  fetchComposition: (queryOptions: import("@contentstack/studio-client").CompositionQueryForSSRInput, options?: import("@contentstack/studio-client").CompositionQueryOptions) => Promise<import("@contentstack/studio-client").StudioSpec>;
58
- getConfig: () => Pick<import("@contentstack/studio-client").Config, "contentTypeUid" | "cslp" | "openInStudioButton">;
58
+ getConfig: () => Pick<import("@contentstack/studio-client").Config, "openInStudioButton" | "contentTypeUid" | "cslp">;
59
59
  };
60
60
  };
61
61
  export declare function lightInit(userConfig?: LightConfig): {
62
62
  internal: {
63
- getConfig: () => Pick<LightConfig, "contentTypeUid" | "cslp" | "openInStudioButton">;
63
+ getConfig: () => Pick<LightConfig, "openInStudioButton" | "contentTypeUid" | "cslp">;
64
64
  };
65
65
  } | null;
66
66
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAkC,EAChC,UAAU,EACV,SAAS,EACT,WAAW,EACX,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AAErC,eAAO,IAAI,GAAG,EAAE,SAAS,GAAG,IAAW,CAAC;AACxC,eAAO,IAAI,QAAQ,EAAE,wBAAwB,GAAG,IAAW,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,SAAS;qBACH,UAAU;uHAgBw+9D,CAAC;mHAAoJ,CAAC;;;CAP1p+D,CAAC;AAEF,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,WAAW;;;;SAIjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAkC,EAChC,UAAU,EACV,SAAS,EACT,WAAW,EACX,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AAErC,eAAO,IAAI,GAAG,EAAE,SAAS,GAAG,IAAW,CAAC;AACxC,eAAO,IAAI,QAAQ,EAAE,wBAAwB,GAAG,IAAW,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,SAAS;qBACH,UAAU;uHAgB81nE,CAAC;mHAAoJ,CAAC;;;CAPhhoE,CAAC;AAEF,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,WAAW;;;;SAIjD"}
@@ -1,16 +1,24 @@
1
1
  import { StudioSpec } from "@contentstack/studio-client";
2
+ import { type ExposedPropRegistryLike } from "@contentstack/studio-registry";
3
+ export interface ExtractStylesOptions {
4
+ /**
5
+ * Registry that decides which exposed section props are design props
6
+ * (ADR 0004). Defaults to the client graph's registry; the RSC entry passes
7
+ * its server-graph registry.
8
+ */
9
+ componentRegistry?: ExposedPropRegistryLike;
10
+ }
2
11
  /**
3
- * Extracts and concatenates CSS styles from a list of composition specifications.
12
+ * The CSS a server render of the given compositions needs: every node's
13
+ * responsive classes, the sections each embeds included (with each placement's
14
+ * exposed design props), and the Open in Studio button's.
4
15
  *
5
- * @param {(StudioSpec | null)[]} specs - Array of composition specifications to extract styles from
6
- * @returns {string} Combined CSS styles string including root styles and composition-specific styles
7
- *
8
- * @description
9
- * This function performs the following:
10
- * 1. Extracts root CSS styles if not already extracted
11
- * 2. Flushes any previously collected styles
12
- * 3. Extracts styles from each valid composition specification
13
- * 4. Combines root styles with composition-specific styles
16
+ * Collected into a private sheet ({@link collectCss}): exactly these
17
+ * compositions' rules, each once — the same string for the same compositions,
18
+ * on the server and in the browser. goober's shared sheet is neither read nor
19
+ * emptied: on the server it holds other renders' and other libraries' CSS,
20
+ * and in the browser it is the page's `<style id="_goober">`, which every
21
+ * goober user on the page writes to.
14
22
  */
15
- export declare const extractStyles: (specs: (StudioSpec | null)[]) => string;
23
+ export declare const extractStyles: (specs: (StudioSpec | null)[], options?: ExtractStylesOptions) => string;
16
24
  //# sourceMappingURL=extract-styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract-styles.d.ts","sourceRoot":"","sources":["../../src/style-extractor/extract-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAkDzD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,KAAG,MAwD5D,CAAC"}
1
+ {"version":3,"file":"extract-styles.d.ts","sourceRoot":"","sources":["../../src/style-extractor/extract-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAOzD,OAAO,EAWL,KAAK,uBAAuB,EAC7B,MAAM,+BAA+B,CAAC;AAIvC,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;CAC7C;AAsED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,EAC5B,UAAS,oBAAyB,KACjC,MAkDF,CAAC"}
@@ -1,115 +1,121 @@
1
- import { extractCss, css } from 'goober';
2
1
  import { handleNodeStyles } from '../utils/handle-responsive-styles.util.js';
3
- import { decompressSpec } from '@contentstack/studio-internal';
4
- import { Button } from '../internal-components/Button.js';
2
+ import { normalizeSpec } from '@contentstack/studio-internal';
3
+ import { getComponentRegistryInstance, isSectionCompositionNode, getNodeRenderStyles, getSectionUIDFromNode, partitionSectionExposedProps, getSectionExposedPropDefinitions, buildSectionExposedStyleOverrides, getSectionExposedStyleGroups, indexSectionNodes, applyExposedStyleOverrides } from '@contentstack/studio-registry';
4
+ import { styleFactory } from '../internal-components/styles.js';
5
+ import { collectCss, css } from './style-sheet.js';
5
6
 
6
- let rootExtracted = "";
7
- const extractStylesInternal = (node, collectedStyleSheet = "") => {
8
- const nodeProps = node.props;
9
- const { styles, uid } = node;
10
- // loop through the slot nodes to further extract style
11
- Object.entries(nodeProps).forEach(([field, prop]) => {
12
- if (prop.type === "slot") {
13
- const currentSlotNode = nodeProps[field];
14
- const currentSlotUid = currentSlotNode.slot;
15
- const slots = node.slots?.[currentSlotUid] ?? [];
16
- slots.forEach((slotNode) => {
17
- if (slotNode.metadata?.visible === false) {
18
- return;
19
- }
20
- collectedStyleSheet =
21
- extractStylesInternal(slotNode, collectedStyleSheet) || "";
22
- });
23
- }
24
- });
25
- handleNodeStyles(styles, uid);
26
- const generatedStyles = extractCss();
27
- return collectedStyleSheet + generatedStyles;
7
+ const findSectionEntry = (node, ctx) => {
8
+ const compositionUID = getSectionUIDFromNode(node) ?? node.type;
9
+ return ctx.sections.find((section) => section?.uid === compositionUID ||
10
+ section?.composable_uid === compositionUID);
28
11
  };
29
12
  /**
30
- * A composition entry's `ui` is typed as a `Node` but is persisted compressed,
31
- * so at runtime it arrives as a `"zlib:"` string. Mirrors the same normalisation
32
- * the SDK does before rendering.
13
+ * A placed section whose placement sets exposed design props renders its
14
+ * overridden inner nodes with MERGED styles, i.e. different classes from the
15
+ * section's own (goober names by content). The section's own pass (once per
16
+ * section) only generates the unmerged ones, so generate the merged ones here.
33
17
  */
34
- const resolveUiNode = (ui) => {
35
- if (!ui)
36
- return null;
37
- return typeof ui === "string" ? decompressSpec(ui) : ui;
18
+ const generatePlacedSectionStyles = (node, ctx) => {
19
+ const entry = findSectionEntry(node, ctx);
20
+ const sectionUi = entry?.ui;
21
+ if (!sectionUi || typeof sectionUi !== "object")
22
+ return;
23
+ const { designDefs } = partitionSectionExposedProps(getSectionExposedPropDefinitions(sectionUi), sectionUi, ctx.registry);
24
+ const overrides = buildSectionExposedStyleOverrides(designDefs, getSectionExposedStyleGroups(node.styles));
25
+ if (!overrides)
26
+ return;
27
+ const innerNodes = indexSectionNodes(sectionUi);
28
+ for (const [nodeUid, forNode] of Object.entries(overrides)) {
29
+ const inner = innerNodes.get(nodeUid);
30
+ if (!inner)
31
+ continue;
32
+ handleNodeStyles(applyExposedStyleOverrides(inner.styles, forNode), nodeUid);
33
+ }
34
+ };
35
+ /** Generates a node's responsive classes, its visible slot children's first. */
36
+ const generateNodeStyles = (node, ctx) => {
37
+ Object.values(node.props ?? {}).forEach((prop) => {
38
+ if (prop.type !== "slot")
39
+ return;
40
+ const slotUid = prop.slot;
41
+ (node.slots?.[slotUid] ?? []).forEach((slotNode) => {
42
+ if (slotNode.metadata?.visible === false)
43
+ return;
44
+ generateNodeStyles(slotNode, ctx);
45
+ });
46
+ });
47
+ // A placed section generates only its `default` group (its other groups are
48
+ // exposed-design-prop values), plus its inner nodes' merged classes.
49
+ const isPlacedSection = isSectionCompositionNode(node) ||
50
+ (!!ctx.sections.length && !!findSectionEntry(node, ctx));
51
+ handleNodeStyles(getNodeRenderStyles(node, undefined, isPlacedSection), node.uid);
52
+ if (isPlacedSection)
53
+ generatePlacedSectionStyles(node, ctx);
38
54
  };
39
55
  /**
40
- * Extracts and concatenates CSS styles from a list of composition specifications.
56
+ * The CSS a server render of the given compositions needs: every node's
57
+ * responsive classes, the sections each embeds included (with each placement's
58
+ * exposed design props), and the Open in Studio button's.
41
59
  *
42
- * @param {(StudioSpec | null)[]} specs - Array of composition specifications to extract styles from
43
- * @returns {string} Combined CSS styles string including root styles and composition-specific styles
44
- *
45
- * @description
46
- * This function performs the following:
47
- * 1. Extracts root CSS styles if not already extracted
48
- * 2. Flushes any previously collected styles
49
- * 3. Extracts styles from each valid composition specification
50
- * 4. Combines root styles with composition-specific styles
60
+ * Collected into a private sheet ({@link collectCss}): exactly these
61
+ * compositions' rules, each once — the same string for the same compositions,
62
+ * on the server and in the browser. goober's shared sheet is neither read nor
63
+ * emptied: on the server it holds other renders' and other libraries' CSS,
64
+ * and in the browser it is the page's `<style id="_goober">`, which every
65
+ * goober user on the page writes to.
51
66
  */
52
- const extractStyles = (specs) => {
67
+ const extractStyles = (specs, options = {}) => {
53
68
  if (!specs || !specs.length)
54
69
  return "";
55
- if (!rootExtracted) {
56
- rootExtracted = extractCss();
57
- }
58
- else {
59
- // flush any styles collected in previous render
60
- extractCss();
61
- }
62
- // extract styles for each composition
63
- const styles = [];
64
- // Section compositions are shared, so the same one can appear many times on a
65
- // page. Extract each distinct composition once.
66
- const seenSections = new Set();
67
- specs.forEach((compositionSpec) => {
68
- if (!compositionSpec)
69
- return;
70
- // Use the UI node directly as it's now the page node
71
- const node = compositionSpec.ui;
72
- const style = extractStylesInternal(node);
73
- if (style)
74
- styles.push(style);
75
- // A page's `ui` only covers the page's own nodes. Every section it embeds
76
- // is a separate composition carrying its own `ui` tree, and its styles are
77
- // registered nowhere else — so without this the browser paints all
78
- // section content unstyled until goober re-injects after hydration.
79
- compositionSpec.sectionCompositions?.forEach((sectionEntry) => {
80
- if (!sectionEntry)
70
+ return collectCss(() => {
71
+ // Section compositions are shared, so the same one can appear many times
72
+ // on a page. Generate each distinct composition once.
73
+ const seenSections = new Set();
74
+ specs.forEach((rawSpec) => {
75
+ // Layouts read into the shape the walk assumes (normalizeSpec): a section
76
+ // whose `ui` is still compressed text is decoded, an unreadable one left out.
77
+ const compositionSpec = normalizeSpec(rawSpec);
78
+ if (!compositionSpec?.ui)
81
79
  return;
82
- const sectionKey = sectionEntry.uid;
83
- if (sectionKey) {
84
- if (seenSections.has(sectionKey))
80
+ const ctx = {
81
+ sections: (compositionSpec.sectionCompositions ?? []),
82
+ registry: options.componentRegistry ?? getComponentRegistryInstance(),
83
+ };
84
+ generateNodeStyles(compositionSpec.ui, ctx);
85
+ // A page's `ui` only covers the page's own nodes. Every section it embeds
86
+ // is a separate composition carrying its own `ui` tree, and its styles are
87
+ // registered nowhere else — so without this the browser paints all
88
+ // section content unstyled until goober re-injects after hydration.
89
+ compositionSpec.sectionCompositions?.forEach((sectionEntry) => {
90
+ if (!sectionEntry)
85
91
  return;
86
- seenSections.add(sectionKey);
87
- }
88
- const sectionNode = resolveUiNode(sectionEntry.ui);
89
- if (!sectionNode)
90
- return;
91
- const sectionStyle = extractStylesInternal(sectionNode);
92
- if (sectionStyle)
93
- styles.push(sectionStyle);
92
+ const sectionKey = sectionEntry.uid;
93
+ if (sectionKey) {
94
+ if (seenSections.has(sectionKey))
95
+ return;
96
+ seenSections.add(sectionKey);
97
+ }
98
+ const sectionNode = sectionEntry.ui;
99
+ if (sectionNode)
100
+ generateNodeStyles(sectionNode, ctx);
101
+ });
94
102
  });
95
- });
96
- // style for open in studio button
97
- css({
98
- position: "relative",
99
- height: "100%",
100
- ".open-in-studio-btn": {
101
- position: "absolute",
102
- display: "none",
103
- },
104
- "&:hover": {
103
+ // The Open in Studio button, and the wrapper that reveals it on hover.
104
+ css({
105
+ position: "relative",
106
+ height: "100%",
105
107
  ".open-in-studio-btn": {
106
- display: "flex",
108
+ position: "absolute",
109
+ display: "none",
107
110
  },
108
- },
111
+ "&:hover": {
112
+ ".open-in-studio-btn": {
113
+ display: "flex",
114
+ },
115
+ },
116
+ });
117
+ styleFactory(css);
109
118
  });
110
- Button({});
111
- styles.push(extractCss());
112
- return rootExtracted + styles.join("");
113
119
  };
114
120
 
115
121
  export { extractStyles };
@@ -1 +1 @@
1
- {"version":3,"file":"extract-styles.js","sources":["../../src/style-extractor/extract-styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAUA,IAAI,aAAa,GAAW,EAAE;AAC9B,MAAM,qBAAqB,GAAG,CAC5B,IAAU,EACV,mBAAA,GAA8B,EAAE,KAC9B;AACF,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK;AAC5B,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI;;AAG5B,IAAA,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAI;AAClD,QAAA,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;AACxB,YAAA,MAAM,eAAe,GAAG,SAAS,CAAC,KAAK,CAAiC;AACxE,YAA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GAAG,qBAAqB,CAAC,IAAI,CAAC;AACzC,QAAA,IAAI,KAAK;AAAE,YAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;QAM7B,eAAe,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,YAAY,KAAI;AAC5D,YAAA,IAAI,CAAC,YAAY;gBAAE;AACnB,YAAA,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG;YACnC,IAAI,UAAU,EAAE;AACd,gBAAA,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC;oBAAE;AAClC,gBAAA,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC;YAC9B;YACA,MAAM,WAAW,GAAG,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;AAClD,YAAA,IAAI,CAAC,WAAW;gBAAE;AAClB,YAAA,MAAM,YAAY,GAAG,qBAAqB,CAAC,WAAW,CAAC;AACvD,YAAA,IAAI,YAAY;AAAE,gBAAA,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;AAC7C,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;;AAEF,IAAA,GAAG,CAAC;AACF,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,qBAAqB,EAAE;AACrB,YAAA,QAAQ,EAAE,UAAU;AACpB,YAAA,OAAO,EAAE,MAAM;AAChB,SAAA;AACD,QAAA,SAAS,EAAE;AACT,YAAA,qBAAqB,EAAE;AACrB,gBAAA,OAAO,EAAE,MAAM;AAChB,aAAA;AACF,SAAA;AACF,KAAA,CAAC;IACF,MAAM,CAAC,EAAE,CAAC;AACV,IAAA,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;IACzB,OAAO,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;AACxC;;;;"}
1
+ {"version":3,"file":"extract-styles.js","sources":["../../src/style-extractor/extract-styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAqCA,M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IAAI,CAAC,eAAe,EAAE,EAAE;gBAAE;AAC1B,YAAA,MAAM,GAAG,GAAe;AACtB,gBAAA,QAAQ,GAAG,eAAe,CAAC,mBAAmB,IAAI,EAAE,CAAU;AAC9D,gBAAA,QAAQ,EAAE,OAAO,CAAC,iBAAiB,IAAI,4BAA4B,EAAE;aACtE;AACD,YAAA,kBAAkB,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC;;;;;YAM3C,eAAe,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,YAAY,KAAI;AAC5D,gBAAA,IAAI,CAAC,YAAY;oBAAE;AACnB,gBAAA,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG;gBACnC,IAAI,UAAU,EAAE;AACd,oBAAA,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC;wBAAE;AAClC,oBAAA,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC;gBAC9B;AACA,gBAAA,MAAM,WAAW,GAAG,YAAY,CAAC,EAAiB;AAClD,gBAAA,IAAI,WAAW;AAAE,oBAAA,kBAAkB,CAAC,WAAW,EAAE,GAAG,CAAC;AACvD,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;;AAGF,QAAA,GAAG,CAAC;AACF,YAAA,QAAQ,EAAE,UAAU;AACpB,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,qBAAqB,EAAE;AACrB,gBAAA,QAAQ,EAAE,UAAU;AACpB,gBAAA,OAAO,EAAE,MAAM;AAChB,aAAA;AACD,YAAA,SAAS,EAAE;AACT,gBAAA,qBAAqB,EAAE;AACrB,oBAAA,OAAO,EAAE,MAAM;AAChB,iBAAA;AACF,aAAA;AACF,SAAA,CAAC;QACF,YAAY,CAAC,GAAG,CAAC;AACnB,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,23 @@
1
+ import { css as gooberCss } from "goober";
2
+ /**
3
+ * goober's `css`, for Studio's own styles: the same class names, but
4
+ *
5
+ * - while {@link collectCss} runs, it writes to that collection's sheet;
6
+ * - on the server, outside a collection, it writes nowhere — a render needs
7
+ * only the class names, and its CSS comes from a collection, so Studio's
8
+ * rules do not pile up in goober's per-process buffer (or reach another
9
+ * library's `extractCss()`);
10
+ * - in the browser, outside a collection, it writes to the page's sheet, as
11
+ * goober does.
12
+ */
13
+ export declare const css: typeof gooberCss;
14
+ /**
15
+ * Runs `fn` with Studio's goober calls ({@link css}) writing to a private
16
+ * sheet, and returns the CSS they wrote: the rules `fn` generated, each once,
17
+ * whatever else the process or page has generated — so the same compositions
18
+ * give the same CSS every time, on the server and in the browser. goober's
19
+ * shared buffer and the page's `<style id="_goober">` are neither read nor
20
+ * changed. `fn` runs synchronously, so nothing else writes in between.
21
+ */
22
+ export declare function collectCss(fn: () => void): string;
23
+ //# sourceMappingURL=style-sheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-sheet.d.ts","sourceRoot":"","sources":["../../src/style-extractor/style-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAmB1C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,EAMX,OAAO,SAAS,CAAC;AAEtB;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,CAcjD"}
@@ -0,0 +1,45 @@
1
+ import { css as css$1 } from 'goober';
2
+
3
+ const inBrowser = () => typeof window === "object";
4
+ /** The private sheet of the collection running now, if any. */
5
+ let collecting;
6
+ /**
7
+ * goober's `css`, for Studio's own styles: the same class names, but
8
+ *
9
+ * - while {@link collectCss} runs, it writes to that collection's sheet;
10
+ * - on the server, outside a collection, it writes nowhere — a render needs
11
+ * only the class names, and its CSS comes from a collection, so Studio's
12
+ * rules do not pile up in goober's per-process buffer (or reach another
13
+ * library's `extractCss()`);
14
+ * - in the browser, outside a collection, it writes to the page's sheet, as
15
+ * goober does.
16
+ */
17
+ const css = function (...args) {
18
+ const target = collecting ?? (inBrowser() ? undefined : { data: "" });
19
+ return css$1.apply(target ? { target } : this, args);
20
+ };
21
+ /**
22
+ * Runs `fn` with Studio's goober calls ({@link css}) writing to a private
23
+ * sheet, and returns the CSS they wrote: the rules `fn` generated, each once,
24
+ * whatever else the process or page has generated — so the same compositions
25
+ * give the same CSS every time, on the server and in the browser. goober's
26
+ * shared buffer and the page's `<style id="_goober">` are neither read nor
27
+ * changed. `fn` runs synchronously, so nothing else writes in between.
28
+ */
29
+ function collectCss(fn) {
30
+ const sheet = inBrowser()
31
+ ? document.createElement("div")
32
+ : { data: "" };
33
+ const previous = collecting;
34
+ collecting = sheet;
35
+ try {
36
+ fn();
37
+ }
38
+ finally {
39
+ collecting = previous;
40
+ }
41
+ return (("textContent" in sheet ? sheet.textContent : sheet.data)?.trim() ?? "");
42
+ }
43
+
44
+ export { collectCss, css };
45
+ //# sourceMappingURL=style-sheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-sheet.js","sources":["../../src/style-extractor/style-sheet.ts"],"sourcesContent":[null],"names":["gooberCss"],"mappings":";;AAcA,MAAM,SAAS,GAAG,MAAe,OAAO,MAAM,KAAK,QAAQ;AAE3D;AACA,IAAI,UAAoC;AAExC;;;;;;;;;;AAUG;AACI,MAAM,GAAG,GAAG,UAAyB,GAAG,IAAe,EAAA;IAC5D,MAAM,MAAM,GAAG,UAAU,KAAK,SAAS,EAAE,GAAG,SAAS,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACrE,IAAA,OAAQA,KAAyC,CAAC,KAAK,CACrD,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAC1B,IAAI,CACL;AACH;AAEA;;;;;;;AAOG;AACG,SAAU,UAAU,CAAC,EAAc,EAAA;IACvC,MAAM,KAAK,GAAiB,SAAS;AACnC,UAAE,QAAQ,CAAC,aAAa,CAAC,KAAK;AAC9B,UAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAChB,MAAM,QAAQ,GAAG,UAAU;IAC3B,UAAU,GAAG,KAAK;AAClB,IAAA,IAAI;AACF,QAAA,EAAE,EAAE;IACN;YAAU;QACR,UAAU,GAAG,QAAQ;IACvB;IACA,QACE,CAAC,aAAa,IAAI,KAAK,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,EAAE;AAE3E;;;;"}
@@ -0,0 +1,5 @@
1
+ /** A one-node composition whose text has a unique colour, to count its rule. */
2
+ export declare const specWithColor: (uid: string, color: string) => never;
3
+ /** How many times `color` appears in `css`. */
4
+ export declare const occurrences: (css: string, color: string) => number;
5
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/style-extractor/tests/fixtures.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KA0BhD,KAAK,CAAC;AAEd,+CAA+C;AAC/C,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,MAC5B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"handle-responsive-styles.util.d.ts","sourceRoot":"","sources":["../../src/utils/handle-responsive-styles.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAchE,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GACd,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAsE1E"}
1
+ {"version":3,"file":"handle-responsive-styles.util.d.ts","sourceRoot":"","sources":["../../src/utils/handle-responsive-styles.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAehE,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GACd,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAsE1E"}
@@ -1,6 +1,6 @@
1
1
  import { BreakpointManager, createClassNameUid } from '@contentstack/studio-client';
2
2
  import classNames from 'classnames';
3
- import { css } from 'goober';
3
+ import { css } from '../style-extractor/style-sheet.js';
4
4
 
5
5
  /**
6
6
  * Processes node styles and generates responsive styles based on the provided style configuration.
@@ -35,7 +35,7 @@ function handleNodeStyles(nodeStyles, nodeUid) {
35
35
  : { ...styles, [`@media ${breakpointQuery}`]: breakpointStyles };
36
36
  }
37
37
  // load the google fonts
38
- if (breakpointStyles?.fontFamily) {
38
+ if (typeof breakpointStyles?.fontFamily === "string") {
39
39
  const fontFamily = breakpointStyles.fontFamily.split(",")[0].trim();
40
40
  /**
41
41
  * NOTE: We are collecting the font families here to load them in the
@@ -1 +1 @@
1
- {"version":3,"file":"handle-responsive-styles.util.js","sources":["../../src/utils/handle-responsive-styles.util.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;AAQG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwB;AAC9C,SAAU,gBAAgB,CAC9B,UAAsB,EACtB,OAAe,EAAA;AAEf,IAAA,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;AAClD,QAAA,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,GAAG,EAAU,EAAE,IAAI,GAAG,EAAwB,CAAC;IACrE;AACA,IA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AAO,EAAE,IAAI,GAAG,EAAU;AAC1B,wBAAA,MAAM,EAAE,KAAK;AACd,qBAAA,CAAC;gBACJ;AACA,gBAAA,IAAI,gBAAgB,CAAC,UAAU,EAAE;oBAC/B,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,OAAO;oBACrD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;gBAClD;AACA,gBAAA,IAAI,gBAAgB,CAAC,SAAS,KAAK,QAAQ,EAAE;oBAC3C,YAAY,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,MAAM,GAAG,IAAI;gBAC7C;YACF;AACF,QAAA,CAAC,CAAC;AAEF,QAAA,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC;QACnC,OAAO;YACL,OAAO;YACP,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,EAAE,YAAY,CAAC;SACnE;AACH,IAAA,CAAC,CACF;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC;IAEvD,MAAM,iBAAiB,GAAG,SAAS;IAEnC,MAAM,YAAY,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;AACzD,IAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC;IAErC,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC;AAChE;;;;"}
1
+ {"version":3,"file":"handle-responsive-styles.util.js","sources":["../../src/utils/handle-responsive-styles.util.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUA;;;;;;;;AAQG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwB;AAC9C,SAAU,gBAAgB,CAC9B,UAAsB,EACtB,OAAe,EAAA;AAEf,IAAA,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;AAClD,QAA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BAC5B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;AACjC,oBAAA,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE;wBAC3B,OAAO,EAAE,IAAI,GAAG,EAAU;AAC1B,wBAAA,MAAM,EAAE,KAAK;AACd,qBAAA,CAAC;gBACJ;AACA,gBAAA,IAAI,gBAAgB,CAAC,UAAU,EAAE;oBAC/B,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,OAAO;oBACrD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;gBAClD;AACA,gBAAA,IAAI,gBAAgB,CAAC,SAAS,KAAK,QAAQ,EAAE;oBAC3C,YAAY,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,MAAM,GAAG,IAAI;gBAC7C;YACF;AACF,QAAA,CAAC,CAAC;AAEF,QAAA,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC;QACnC,OAAO;YACL,OAAO;YACP,UAAU,CAAC,eAAe,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,EAAE,YAAY,CAAC;SACnE;AACH,IAAA,CAAC,CACF;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC;IAEvD,MAAM,iBAAiB,GAAG,SAAS;IAEnC,MAAM,YAAY,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;AACzD,IAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC;IAErC,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC;AAChE;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-core",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
4
4
  "description": "Provides utility to fetch spec for composable component",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,9 +40,9 @@
40
40
  "tsup": "^8.5.0"
41
41
  },
42
42
  "dependencies": {
43
- "@contentstack/studio-client": "^4.1.0",
44
- "@contentstack/studio-internal": "^1.8.1",
45
- "@contentstack/studio-registry": "^2.0.1",
43
+ "@contentstack/studio-client": "^4.2.0",
44
+ "@contentstack/studio-internal": "^1.9.0",
45
+ "@contentstack/studio-registry": "^2.1.0",
46
46
  "classnames": "^2.5.1",
47
47
  "goober": "^2.1.16"
48
48
  },