@makeswift/runtime 0.28.3-canary.6 → 0.28.3-canary.8

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.
@@ -97,12 +97,8 @@ function registerComponent(runtime) {
97
97
  border: (0, import_prop_controllers.Border)({ format: import_prop_controllers.Border.Format.ClassName }),
98
98
  borderRadius: (0, import_prop_controllers.BorderRadius)({ format: import_prop_controllers.BorderRadius.Format.ClassName }),
99
99
  boxShadow: (0, import_prop_controllers.Shadows)({ format: import_prop_controllers.Shadows.Format.ClassName }),
100
- rowGap: (0, import_prop_controllers.GapY)((props) => ({
101
- hidden: props.children == null
102
- })),
103
- columnGap: (0, import_prop_controllers.GapX)((props) => ({
104
- hidden: props.children == null
105
- })),
100
+ rowGap: (0, import_prop_controllers.GapY)(),
101
+ columnGap: (0, import_prop_controllers.GapX)(),
106
102
  boxAnimateType: (0, import_prop_controllers.ResponsiveSelect)({
107
103
  label: "Animate box in",
108
104
  labelOrientation: "vertical",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/builtin/Box/register.ts"],"sourcesContent":["import {\n Backgrounds,\n Border,\n BorderRadius,\n Checkbox,\n ElementID,\n GapX,\n GapY,\n Grid,\n Margin,\n Padding,\n ResponsiveIconRadioGroup,\n ResponsiveNumber,\n ResponsiveSelect,\n Shadows,\n Width,\n type PropData,\n} from '@makeswift/prop-controllers'\nimport { findBreakpointOverride, getBaseBreakpoint } from '@makeswift/controls'\n\nimport { type ReactRuntimeCore } from '../../../runtimes/react/react-runtime-core'\nimport { MakeswiftComponentType } from '../constants'\nimport {\n BoxAnimateIn,\n DEFAULT_BOX_ANIMATE_DELAY,\n DEFAULT_BOX_ANIMATE_DURATION,\n DEFAULT_ITEM_ANIMATE_DELAY,\n DEFAULT_ITEM_STAGGER_DURATION,\n} from './constants'\nimport { lazy } from 'react'\n\nexport function registerComponent(runtime: ReactRuntimeCore) {\n function isHiddenBasedOnAnimationType(\n props: Record<string, unknown>,\n deviceId: string,\n property: 'boxAnimateType' | 'itemAnimateType',\n ): boolean {\n const animateIn = ResponsiveSelect.fromPropData<BoxAnimateIn>(\n props[property] as PropData<typeof ResponsiveSelect> | undefined,\n )\n return (\n (findBreakpointOverride<BoxAnimateIn>(runtime.getBreakpoints(), animateIn, deviceId)?.value ??\n 'none') === 'none'\n )\n }\n const isHiddenBasedOnBoxAnimation = (props: Record<string, unknown>, deviceId: string) =>\n isHiddenBasedOnAnimationType(props, deviceId, 'boxAnimateType')\n const isHiddenBasedOnItemAnimation = (props: Record<string, unknown>, deviceId: string) =>\n isHiddenBasedOnAnimationType(props, deviceId, 'itemAnimateType')\n\n return runtime.registerComponent(\n lazy(() => import('./Box')),\n {\n type: MakeswiftComponentType.Box,\n label: 'Box',\n props: {\n id: ElementID(),\n backgrounds: Backgrounds(),\n width: Width({\n format: Width.Format.ClassName,\n defaultValue: { value: 100, unit: '%' },\n }),\n height: ResponsiveIconRadioGroup({\n label: 'Height',\n options: [\n { value: 'auto', label: 'Auto', icon: 'HeightAuto16' },\n { value: 'stretch', label: 'Stretch', icon: 'HeightMatch16' },\n ],\n defaultValue: 'auto',\n }),\n verticalAlign: ResponsiveIconRadioGroup({\n label: 'Align items',\n options: [\n { value: 'flex-start', label: 'Top', icon: 'VerticalAlignStart16' },\n { value: 'center', label: 'Middle', icon: 'VerticalAlignMiddle16' },\n { value: 'flex-end', label: 'Bottom', icon: 'VerticalAlignEnd16' },\n {\n value: 'space-between',\n label: 'Space between',\n icon: 'VerticalAlignSpaceBetween16',\n },\n ],\n defaultValue: 'flex-start',\n }),\n margin: Margin({ format: Margin.Format.ClassName }),\n padding: Padding({\n format: Padding.Format.ClassName,\n preset: [\n {\n deviceId: getBaseBreakpoint(runtime.getBreakpoints()).id,\n value: {\n paddingTop: { value: 10, unit: 'px' },\n paddingRight: { value: 10, unit: 'px' },\n paddingBottom: { value: 10, unit: 'px' },\n paddingLeft: { value: 10, unit: 'px' },\n },\n },\n ],\n }),\n border: Border({ format: Border.Format.ClassName }),\n borderRadius: BorderRadius({ format: BorderRadius.Format.ClassName }),\n boxShadow: Shadows({ format: Shadows.Format.ClassName }),\n rowGap: GapY(props => ({\n hidden: props.children == null,\n })),\n columnGap: GapX(props => ({\n hidden: props.children == null,\n })),\n boxAnimateType: ResponsiveSelect({\n label: 'Animate box in',\n labelOrientation: 'vertical',\n options: [\n { value: 'none', label: 'None' },\n { value: 'fadeIn', label: 'Fade in' },\n { value: 'fadeRight', label: 'Fade right' },\n { value: 'fadeDown', label: 'Fade down' },\n { value: 'fadeLeft', label: 'Fade left' },\n { value: 'fadeUp', label: 'Fade up' },\n { value: 'blurIn', label: 'Blur in' },\n { value: 'scaleUp', label: 'Scale up' },\n { value: 'scaleDown', label: 'Scale down' },\n ],\n defaultValue: 'none',\n }),\n boxAnimateDuration: ResponsiveNumber((props, device) => ({\n label: 'Box duration',\n defaultValue: DEFAULT_BOX_ANIMATE_DURATION,\n min: 0.1,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnBoxAnimation(props, device),\n })),\n boxAnimateDelay: ResponsiveNumber((props, device) => ({\n label: 'Box delay',\n defaultValue: DEFAULT_BOX_ANIMATE_DELAY,\n min: 0,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnBoxAnimation(props, device),\n })),\n itemAnimateType: ResponsiveSelect({\n label: 'Animate items in',\n labelOrientation: 'vertical',\n options: [\n { value: 'none', label: 'None' },\n { value: 'fadeIn', label: 'Fade in' },\n { value: 'fadeRight', label: 'Fade right' },\n { value: 'fadeDown', label: 'Fade down' },\n { value: 'fadeLeft', label: 'Fade left' },\n { value: 'fadeUp', label: 'Fade up' },\n { value: 'blurIn', label: 'Blur in' },\n { value: 'scaleUp', label: 'Scale up' },\n { value: 'scaleDown', label: 'Scale down' },\n ],\n defaultValue: 'none',\n }),\n itemAnimateDuration: ResponsiveNumber((props, device) => ({\n label: 'Items duration',\n defaultValue: DEFAULT_BOX_ANIMATE_DURATION,\n min: 0.1,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnItemAnimation(props, device),\n })),\n itemAnimateDelay: ResponsiveNumber((props, device) => ({\n label: 'Items delay',\n defaultValue: DEFAULT_ITEM_ANIMATE_DELAY,\n min: 0,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnItemAnimation(props, device),\n })),\n itemStaggerDuration: ResponsiveNumber((props, device) => ({\n label: 'Stagger',\n min: 0,\n step: 0.05,\n suffix: 's',\n defaultValue: DEFAULT_ITEM_STAGGER_DURATION,\n hidden: isHiddenBasedOnItemAnimation(props, device),\n })),\n hidePlaceholder: Checkbox(props => ({\n label: 'Hide placeholder',\n hidden: props.children != null,\n })),\n children: Grid(),\n },\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAiBO;AACP,sBAA0D;AAG1D,uBAAuC;AACvC,IAAAA,oBAMO;AACP,mBAAqB;AAEd,SAAS,kBAAkB,SAA2B;AAC3D,WAAS,6BACP,OACA,UACA,UACS;AACT,UAAM,YAAY,yCAAiB;AAAA,MACjC,MAAM,QAAQ;AAAA,IAChB;AACA,gBACG,wCAAqC,QAAQ,eAAe,GAAG,WAAW,QAAQ,GAAG,SACpF,YAAY;AAAA,EAElB;AACA,QAAM,8BAA8B,CAAC,OAAgC,aACnE,6BAA6B,OAAO,UAAU,gBAAgB;AAChE,QAAM,+BAA+B,CAAC,OAAgC,aACpE,6BAA6B,OAAO,UAAU,iBAAiB;AAEjE,SAAO,QAAQ;AAAA,QACb,mBAAK,MAAM,6CAAO,OAAO,GAAC;AAAA,IAC1B;AAAA,MACE,MAAM,wCAAuB;AAAA,MAC7B,OAAO;AAAA,MACP,OAAO;AAAA,QACL,QAAI,mCAAU;AAAA,QACd,iBAAa,qCAAY;AAAA,QACzB,WAAO,+BAAM;AAAA,UACX,QAAQ,8BAAM,OAAO;AAAA,UACrB,cAAc,EAAE,OAAO,KAAK,MA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AO,UAAU,OAAO,UAAU;AAAA,YACpC,EAAE,OAAO,aAAa,OAAO,aAAa;AAAA,YAC1C,EAAE,OAAO,YAAY,OAAO,YAAY;AAAA,YACxC,EAAE,OAAO,YAAY,OAAO,YAAY;AAAA,YACxC,EAAE,OAAO,UAAU,OAAO,UAAU;AAAA,YACpC,EAAE,OAAO,UAAU,OAAO,UAAU;AAAA,YACpC,EAAE,OAAO,WAAW,OAAO,WAAW;AAAA,YACtC,EAAE,OAAO,aAAa,OAAO,aAAa;AAAA,UAC5C;AAAA,UACA,cAAc;AAAA,QAChB,CAAC;AAAA,QACD,yBAAqB,0CAAiB,CAAC,OAAO,YAAY;AAAA,UACxD,OAAO;AAAA,UACP,cAAc;AAAA,UACd,KAAK;AAAA,UACL,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,QAAQ,6BAA6B,OAAO,MAAM;AAAA,QACpD,EAAE;AAAA,QACF,sBAAkB,0CAAiB,CAAC,OAAO,YAAY;AAAA,UACrD,OAAO;AAAA,UACP,cAAc;AAAA,UACd,KAAK;AAAA,UACL,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,QAAQ,6BAA6B,OAAO,MAAM;AAAA,QACpD,EAAE;AAAA,QACF,yBAAqB,0CAAiB,CAAC,OAAO,YAAY;AAAA,UACxD,OAAO;AAAA,UACP,KAAK;AAAA,UACL,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,QAAQ,6BAA6B,OAAO,MAAM;AAAA,QACpD,EAAE;AAAA,QACF,qBAAiB,kCAAS,YAAU;AAAA,UAClC,OAAO;AAAA,UACP,QAAQ,MAAM,YAAY;AAAA,QAC5B,EAAE;AAAA,QACF,cAAU,8BAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;","names":["import_constants"]}
1
+ {"version":3,"sources":["../../../../../src/components/builtin/Box/register.ts"],"sourcesContent":["import {\n Backgrounds,\n Border,\n BorderRadius,\n Checkbox,\n ElementID,\n GapX,\n GapY,\n Grid,\n Margin,\n Padding,\n ResponsiveIconRadioGroup,\n ResponsiveNumber,\n ResponsiveSelect,\n Shadows,\n Width,\n type PropData,\n} from '@makeswift/prop-controllers'\nimport { findBreakpointOverride, getBaseBreakpoint } from '@makeswift/controls'\n\nimport { type ReactRuntimeCore } from '../../../runtimes/react/react-runtime-core'\nimport { MakeswiftComponentType } from '../constants'\nimport {\n BoxAnimateIn,\n DEFAULT_BOX_ANIMATE_DELAY,\n DEFAULT_BOX_ANIMATE_DURATION,\n DEFAULT_ITEM_ANIMATE_DELAY,\n DEFAULT_ITEM_STAGGER_DURATION,\n} from './constants'\nimport { lazy } from 'react'\n\nexport function registerComponent(runtime: ReactRuntimeCore) {\n function isHiddenBasedOnAnimationType(\n props: Record<string, unknown>,\n deviceId: string,\n property: 'boxAnimateType' | 'itemAnimateType',\n ): boolean {\n const animateIn = ResponsiveSelect.fromPropData<BoxAnimateIn>(\n props[property] as PropData<typeof ResponsiveSelect> | undefined,\n )\n return (\n (findBreakpointOverride<BoxAnimateIn>(runtime.getBreakpoints(), animateIn, deviceId)?.value ??\n 'none') === 'none'\n )\n }\n const isHiddenBasedOnBoxAnimation = (props: Record<string, unknown>, deviceId: string) =>\n isHiddenBasedOnAnimationType(props, deviceId, 'boxAnimateType')\n const isHiddenBasedOnItemAnimation = (props: Record<string, unknown>, deviceId: string) =>\n isHiddenBasedOnAnimationType(props, deviceId, 'itemAnimateType')\n\n return runtime.registerComponent(\n lazy(() => import('./Box')),\n {\n type: MakeswiftComponentType.Box,\n label: 'Box',\n props: {\n id: ElementID(),\n backgrounds: Backgrounds(),\n width: Width({\n format: Width.Format.ClassName,\n defaultValue: { value: 100, unit: '%' },\n }),\n height: ResponsiveIconRadioGroup({\n label: 'Height',\n options: [\n { value: 'auto', label: 'Auto', icon: 'HeightAuto16' },\n { value: 'stretch', label: 'Stretch', icon: 'HeightMatch16' },\n ],\n defaultValue: 'auto',\n }),\n verticalAlign: ResponsiveIconRadioGroup({\n label: 'Align items',\n options: [\n { value: 'flex-start', label: 'Top', icon: 'VerticalAlignStart16' },\n { value: 'center', label: 'Middle', icon: 'VerticalAlignMiddle16' },\n { value: 'flex-end', label: 'Bottom', icon: 'VerticalAlignEnd16' },\n {\n value: 'space-between',\n label: 'Space between',\n icon: 'VerticalAlignSpaceBetween16',\n },\n ],\n defaultValue: 'flex-start',\n }),\n margin: Margin({ format: Margin.Format.ClassName }),\n padding: Padding({\n format: Padding.Format.ClassName,\n preset: [\n {\n deviceId: getBaseBreakpoint(runtime.getBreakpoints()).id,\n value: {\n paddingTop: { value: 10, unit: 'px' },\n paddingRight: { value: 10, unit: 'px' },\n paddingBottom: { value: 10, unit: 'px' },\n paddingLeft: { value: 10, unit: 'px' },\n },\n },\n ],\n }),\n border: Border({ format: Border.Format.ClassName }),\n borderRadius: BorderRadius({ format: BorderRadius.Format.ClassName }),\n boxShadow: Shadows({ format: Shadows.Format.ClassName }),\n rowGap: GapY(),\n columnGap: GapX(),\n boxAnimateType: ResponsiveSelect({\n label: 'Animate box in',\n labelOrientation: 'vertical',\n options: [\n { value: 'none', label: 'None' },\n { value: 'fadeIn', label: 'Fade in' },\n { value: 'fadeRight', label: 'Fade right' },\n { value: 'fadeDown', label: 'Fade down' },\n { value: 'fadeLeft', label: 'Fade left' },\n { value: 'fadeUp', label: 'Fade up' },\n { value: 'blurIn', label: 'Blur in' },\n { value: 'scaleUp', label: 'Scale up' },\n { value: 'scaleDown', label: 'Scale down' },\n ],\n defaultValue: 'none',\n }),\n boxAnimateDuration: ResponsiveNumber((props, device) => ({\n label: 'Box duration',\n defaultValue: DEFAULT_BOX_ANIMATE_DURATION,\n min: 0.1,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnBoxAnimation(props, device),\n })),\n boxAnimateDelay: ResponsiveNumber((props, device) => ({\n label: 'Box delay',\n defaultValue: DEFAULT_BOX_ANIMATE_DELAY,\n min: 0,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnBoxAnimation(props, device),\n })),\n itemAnimateType: ResponsiveSelect({\n label: 'Animate items in',\n labelOrientation: 'vertical',\n options: [\n { value: 'none', label: 'None' },\n { value: 'fadeIn', label: 'Fade in' },\n { value: 'fadeRight', label: 'Fade right' },\n { value: 'fadeDown', label: 'Fade down' },\n { value: 'fadeLeft', label: 'Fade left' },\n { value: 'fadeUp', label: 'Fade up' },\n { value: 'blurIn', label: 'Blur in' },\n { value: 'scaleUp', label: 'Scale up' },\n { value: 'scaleDown', label: 'Scale down' },\n ],\n defaultValue: 'none',\n }),\n itemAnimateDuration: ResponsiveNumber((props, device) => ({\n label: 'Items duration',\n defaultValue: DEFAULT_BOX_ANIMATE_DURATION,\n min: 0.1,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnItemAnimation(props, device),\n })),\n itemAnimateDelay: ResponsiveNumber((props, device) => ({\n label: 'Items delay',\n defaultValue: DEFAULT_ITEM_ANIMATE_DELAY,\n min: 0,\n step: 0.05,\n suffix: 's',\n hidden: isHiddenBasedOnItemAnimation(props, device),\n })),\n itemStaggerDuration: ResponsiveNumber((props, device) => ({\n label: 'Stagger',\n min: 0,\n step: 0.05,\n suffix: 's',\n defaultValue: DEFAULT_ITEM_STAGGER_DURATION,\n hidden: isHiddenBasedOnItemAnimation(props, device),\n })),\n hidePlaceholder: Checkbox(props => ({\n label: 'Hide placeholder',\n hidden: props.children != null,\n })),\n children: Grid(),\n },\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAiBO;AACP,sBAA0D;AAG1D,uBAAuC;AACvC,IAAAA,oBAMO;AACP,mBAAqB;AAEd,SAAS,kBAAkB,SAA2B;AAC3D,WAAS,6BACP,OACA,UACA,UACS;AACT,UAAM,YAAY,yCAAiB;AAAA,MACjC,MAAM,QAAQ;AAAA,IAChB;AACA,gBACG,wCAAqC,QAAQ,eAAe,GAAG,WAAW,QAAQ,GAAG,SACpF,YAAY;AAAA,EA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ACpD,EAAE;AAAA,QACF,qBAAiB,kCAAS,YAAU;AAAA,UAClC,OAAO;AAAA,UACP,QAAQ,MAAM,YAAY;AAAA,QAC5B,EAAE;AAAA,QACF,cAAU,8BAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;","names":["import_constants"]}
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
8
8
  return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
9
9
  }
10
10
  return ApiResponse.json({
11
- version: "0.28.3-canary.6",
11
+ version: "0.28.3-canary.8",
12
12
  interactionMode: true,
13
13
  clientSideNavigation: false,
14
14
  elementFromPoint: false,
@@ -23,6 +23,7 @@ import { Schema } from "@makeswift/controls";
23
23
  import { EMBEDDED_DOCUMENT_TYPE } from "../state/modules/read-only-documents";
24
24
  import { mergeTranslatedContent } from "../state/translations/merge";
25
25
  import { getTranslatableContent } from "../state/translations/get";
26
+ import { isNonNullable } from "../utils/isNonNullable";
26
27
  import { SnippetLocation as SnippetLocation2 } from "../api/graphql/generated/types";
27
28
  const makeswiftPageResultSchema = z.object({
28
29
  id: z.string(),
@@ -197,25 +198,31 @@ Received "${apiKey}" instead.`
197
198
  }
198
199
  this.apiKey = apiKey;
199
200
  this.graphqlClient = new GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
200
- "makeswift-runtime-version": "0.28.3-canary.6"
201
+ "makeswift-runtime-version": "0.28.3-canary.8"
201
202
  });
202
203
  this.runtime = runtime;
203
204
  }
204
205
  get apiOrigin() {
205
206
  return this.runtime.apiOrigin;
206
207
  }
207
- async fetch(path, siteVersion) {
208
+ async fetch(path, siteVersion, init) {
208
209
  const requestUrl = new URL(path, this.apiOrigin);
209
210
  const requestHeaders = new Headers({
210
211
  "x-api-key": this.apiKey,
211
212
  "makeswift-site-api-key": this.apiKey,
212
- "makeswift-runtime-version": "0.28.3-canary.6"
213
+ "makeswift-runtime-version": "0.28.3-canary.8"
213
214
  });
214
215
  if (siteVersion?.token) {
215
216
  requestUrl.searchParams.set("version", siteVersion.version);
216
217
  requestHeaders.set("makeswift-preview-token", siteVersion.token);
217
218
  }
219
+ if (init?.headers) {
220
+ new Headers(init.headers).forEach((value, key) => {
221
+ requestHeaders.set(key, value);
222
+ });
223
+ }
218
224
  const response = await fetch(requestUrl.toString(), {
225
+ ...init,
219
226
  headers: requestHeaders,
220
227
  ...siteVersion != null ? { cache: "no-store" } : {},
221
228
  ...this.fetchOptions(siteVersion)
@@ -306,6 +313,31 @@ Received "${apiKey}" instead.`
306
313
  }
307
314
  return await response.json();
308
315
  }
316
+ async getElementTreesBulk(ids, siteVersion, locale) {
317
+ if (ids.length === 0)
318
+ return [];
319
+ const requestBody = { ids };
320
+ if (locale != null)
321
+ requestBody.locale = locale;
322
+ const response = await this.fetch("v0/element-trees/bulk", siteVersion, {
323
+ method: "POST",
324
+ headers: { "Content-Type": "application/json" },
325
+ body: JSON.stringify(requestBody)
326
+ });
327
+ if (!response.ok) {
328
+ const failedBody = await failedResponseBody(response);
329
+ console.error(`Failed to get element trees for [${ids.join(", ")}]`, {
330
+ response: failedBody,
331
+ siteVersion,
332
+ locale
333
+ });
334
+ throw new Error(`Failed to get element trees: ${responseError(response)}`);
335
+ }
336
+ const responseBody = await response.json();
337
+ return responseBody.map(
338
+ (item) => item != null ? makeswiftComponentDocumentSchema.parse(item) : null
339
+ );
340
+ }
309
341
  async getIntrospectedResources({
310
342
  swatchIds,
311
343
  ...introspectedResourceIds
@@ -314,6 +346,8 @@ Received "${apiKey}" instead.`
314
346
  const swatches = await this.getSwatches(swatchIds, siteVersion);
315
347
  return { ...result, swatches };
316
348
  }
349
+ // TODO: Consolidate this method with the introspectMany method once the
350
+ // unstable_getComponentSnapshots method is stable and tested in production.
317
351
  async introspect(element, siteVersion, locale) {
318
352
  const descriptors = this.getElementDescriptors();
319
353
  const swatchIds = /* @__PURE__ */ new Set();
@@ -435,6 +469,194 @@ Received "${apiKey}" instead.`
435
469
  localizedResourcesMap: locale != null ? { [locale]: Object.fromEntries(localizedResourcesMap.entries()) } : {}
436
470
  };
437
471
  }
472
+ async introspectMany(trees, siteVersion, locale) {
473
+ if (trees.length === 0)
474
+ return /* @__PURE__ */ new Map();
475
+ const descriptors = this.getElementDescriptors();
476
+ const globalElementCache = /* @__PURE__ */ new Map();
477
+ const localizedGlobalElementCache = /* @__PURE__ */ new Map();
478
+ const treeCaches = new Map(
479
+ trees.map((tree) => [
480
+ tree.id,
481
+ {
482
+ data: tree.data,
483
+ swatchIds: /* @__PURE__ */ new Set(),
484
+ fileIds: /* @__PURE__ */ new Set(),
485
+ typographyIds: /* @__PURE__ */ new Set(),
486
+ tableIds: /* @__PURE__ */ new Set(),
487
+ pageIds: /* @__PURE__ */ new Set(),
488
+ globalElements: /* @__PURE__ */ new Map(),
489
+ localizedGlobalElements: /* @__PURE__ */ new Map(),
490
+ localizedResourcesMap: /* @__PURE__ */ new Map()
491
+ }
492
+ ])
493
+ );
494
+ for (const currentTreeCache of treeCaches.values()) {
495
+ const remaining = [currentTreeCache.data];
496
+ const seen = /* @__PURE__ */ new Set();
497
+ let current;
498
+ while (current = remaining.pop()) {
499
+ let getResourcesFromElementDescriptors2 = function(elementDescriptors2, props) {
500
+ Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
501
+ getSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
502
+ currentTreeCache.swatchIds.add(swatchId);
503
+ });
504
+ getFileIds(descriptor, props[propName]).forEach((fileId) => {
505
+ currentTreeCache.fileIds.add(fileId);
506
+ });
507
+ getTypographyIds(descriptor, props[propName]).forEach((typographyId) => {
508
+ currentTreeCache.typographyIds.add(typographyId);
509
+ });
510
+ getTableIds(descriptor, props[propName]).forEach((tableId) => {
511
+ currentTreeCache.tableIds.add(tableId);
512
+ });
513
+ getPageIds(descriptor, props[propName]).forEach((pageId) => {
514
+ currentTreeCache.pageIds.add(pageId);
515
+ });
516
+ getElementChildren(descriptor, props[propName]).forEach((child) => {
517
+ if (!seen.has(child.key)) {
518
+ seen.add(child.key);
519
+ remaining.push(child);
520
+ }
521
+ });
522
+ });
523
+ };
524
+ var getResourcesFromElementDescriptors = getResourcesFromElementDescriptors2;
525
+ let element;
526
+ if (isElementReference(current)) {
527
+ const globalElementId = current.value;
528
+ let globalElement;
529
+ if (globalElementCache.has(globalElementId)) {
530
+ globalElement = globalElementCache.get(globalElementId);
531
+ } else {
532
+ globalElement = await this.getGlobalElement(globalElementId, siteVersion);
533
+ globalElementCache.set(globalElementId, globalElement);
534
+ }
535
+ let elementData = globalElement?.data;
536
+ if (locale) {
537
+ let localizedGlobalElement;
538
+ if (localizedGlobalElementCache.has(globalElementId)) {
539
+ localizedGlobalElement = localizedGlobalElementCache.get(globalElementId);
540
+ } else {
541
+ localizedGlobalElement = await this.getLocalizedGlobalElement(
542
+ globalElementId,
543
+ locale,
544
+ siteVersion
545
+ );
546
+ localizedGlobalElementCache.set(globalElementId, localizedGlobalElement);
547
+ }
548
+ if (localizedGlobalElement) {
549
+ elementData = localizedGlobalElement.data;
550
+ currentTreeCache.localizedResourcesMap.set(globalElementId, localizedGlobalElement.id);
551
+ currentTreeCache.localizedGlobalElements.set(
552
+ localizedGlobalElement.id,
553
+ localizedGlobalElement
554
+ );
555
+ } else {
556
+ currentTreeCache.localizedResourcesMap.set(globalElementId, null);
557
+ }
558
+ }
559
+ currentTreeCache.globalElements.set(globalElementId, globalElement);
560
+ if (elementData == null)
561
+ continue;
562
+ element = elementData;
563
+ } else {
564
+ element = current;
565
+ }
566
+ const elementDescriptors = descriptors.get(element.type);
567
+ if (elementDescriptors == null)
568
+ continue;
569
+ getResourcesFromElementDescriptors2(elementDescriptors, element.props);
570
+ }
571
+ }
572
+ const allSwatchIds = /* @__PURE__ */ new Set();
573
+ const allFileIds = /* @__PURE__ */ new Set();
574
+ const allTypographyIds = /* @__PURE__ */ new Set();
575
+ const allTableIds = /* @__PURE__ */ new Set();
576
+ const allPageIds = /* @__PURE__ */ new Set();
577
+ for (const currentTreeCache of treeCaches.values()) {
578
+ currentTreeCache.swatchIds.forEach((id) => allSwatchIds.add(id));
579
+ currentTreeCache.fileIds.forEach((id) => allFileIds.add(id));
580
+ currentTreeCache.typographyIds.forEach((id) => allTypographyIds.add(id));
581
+ currentTreeCache.tableIds.forEach((id) => allTableIds.add(id));
582
+ currentTreeCache.pageIds.forEach((id) => allPageIds.add(id));
583
+ }
584
+ const typographies = await this.getTypographies([...allTypographyIds], siteVersion);
585
+ typographies.forEach((typography) => {
586
+ if (typography == null)
587
+ return;
588
+ const secondarySwatchIds = [];
589
+ typography.style.forEach((style) => {
590
+ const swatchId = style.value.color?.swatchId;
591
+ if (swatchId != null) {
592
+ secondarySwatchIds.push(swatchId);
593
+ allSwatchIds.add(swatchId);
594
+ }
595
+ });
596
+ if (secondarySwatchIds.length > 0) {
597
+ for (const currentTreeCache of treeCaches.values()) {
598
+ if (currentTreeCache.typographyIds.has(typography.id)) {
599
+ secondarySwatchIds.forEach((id) => currentTreeCache.swatchIds.add(id));
600
+ }
601
+ }
602
+ }
603
+ });
604
+ const [pagePathnames, { swatches, files, tables }] = await Promise.all([
605
+ this.getPagePathnameSlices([...allPageIds], siteVersion, { locale }),
606
+ this.getIntrospectedResources(
607
+ {
608
+ swatchIds: [...allSwatchIds],
609
+ fileIds: [...allFileIds],
610
+ tableIds: [...allTableIds]
611
+ },
612
+ siteVersion
613
+ )
614
+ ]);
615
+ const result = /* @__PURE__ */ new Map();
616
+ for (const [treeId, currentTreeCache] of treeCaches) {
617
+ const apiResources = {
618
+ [APIResourceType.Swatch]: [...currentTreeCache.swatchIds].map((id) => ({
619
+ id,
620
+ value: swatches.find((swatch) => swatch?.id === id) ?? null
621
+ })),
622
+ [APIResourceType.File]: [...currentTreeCache.fileIds].map((id) => ({
623
+ id,
624
+ value: files.find((file) => file?.id === id) ?? null
625
+ })),
626
+ [APIResourceType.Typography]: [...currentTreeCache.typographyIds].map((id) => ({
627
+ id,
628
+ value: typographies.find((typography) => typography?.id === id) ?? null
629
+ })),
630
+ [APIResourceType.Table]: [...currentTreeCache.tableIds].map((id) => ({
631
+ id,
632
+ value: tables.find((table) => table?.id === id) ?? null
633
+ })),
634
+ [APIResourceType.PagePathnameSlice]: [...currentTreeCache.pageIds].map((id) => ({
635
+ id,
636
+ value: pagePathnames.find((pagePathnameSlice) => pagePathnameSlice?.id === id) ?? null,
637
+ locale
638
+ })),
639
+ [APIResourceType.GlobalElement]: [...currentTreeCache.globalElements.entries()].map(
640
+ ([id, value]) => ({
641
+ id,
642
+ value
643
+ })
644
+ ),
645
+ [APIResourceType.LocalizedGlobalElement]: [
646
+ ...currentTreeCache.localizedGlobalElements.entries()
647
+ ].map(([id, value]) => ({
648
+ id,
649
+ value,
650
+ locale
651
+ }))
652
+ };
653
+ result.set(treeId, {
654
+ apiResources,
655
+ localizedResourcesMap: locale != null ? { [locale]: Object.fromEntries(currentTreeCache.localizedResourcesMap.entries()) } : {}
656
+ });
657
+ }
658
+ return result;
659
+ }
438
660
  async getPageSnapshot(pathname, {
439
661
  siteVersion: siteVersionPromise,
440
662
  locale,
@@ -539,6 +761,58 @@ Received "${apiKey}" instead.`
539
761
  }
540
762
  };
541
763
  }
764
+ /**
765
+ * Fetches multiple component snapshots in a single bulk request with unified introspection.
766
+ *
767
+ * @param ids - Element tree IDs to fetch. Maximum 100 IDs per call.
768
+ */
769
+ // TODO: Make getComponentSnapshot use this method under the hood once the v0 bulk endpoint is stable.
770
+ async unstable_getComponentSnapshots(ids, {
771
+ siteVersion: siteVersionPromise,
772
+ locale,
773
+ allowLocaleFallback = true
774
+ }) {
775
+ if (ids.length === 0)
776
+ return [];
777
+ const siteVersion = await siteVersionPromise;
778
+ let documents = await this.getElementTreesBulk(ids, siteVersion, locale);
779
+ const baseLocaleWasRequested = locale == null;
780
+ const canAttemptLocaleFallback = !baseLocaleWasRequested && allowLocaleFallback;
781
+ const fallbackIndices = [];
782
+ if (canAttemptLocaleFallback) {
783
+ documents.forEach((doc, i) => {
784
+ if (doc == null)
785
+ fallbackIndices.push(i);
786
+ });
787
+ if (fallbackIndices.length > 0) {
788
+ const fallbackIds = fallbackIndices.map((i) => ids[i]);
789
+ const fallbackDocuments = await this.getElementTreesBulk(fallbackIds, siteVersion);
790
+ fallbackIndices.forEach((originalIndex, fallbackIndex) => {
791
+ documents[originalIndex] = fallbackDocuments[fallbackIndex];
792
+ });
793
+ }
794
+ }
795
+ const treesToIntrospect = documents.map((doc) => doc?.data != null ? { id: doc.id, data: doc.data } : null).filter(isNonNullable);
796
+ const cacheDataMap = await this.introspectMany(treesToIntrospect, siteVersion, locale ?? null);
797
+ return ids.map((id, i) => {
798
+ const document = documents[i];
799
+ const key = deterministicUUID({ id, locale, seed: this.apiKey.split("-").at(0) });
800
+ if (document == null || document.data == null) {
801
+ return {
802
+ document: { id, locale: locale ?? null, data: null },
803
+ key,
804
+ cacheData: CacheData.empty(),
805
+ meta: { allowLocaleFallback, requestedLocale: locale ?? null }
806
+ };
807
+ }
808
+ return {
809
+ document,
810
+ key,
811
+ cacheData: cacheDataMap.get(id) ?? CacheData.empty(),
812
+ meta: { allowLocaleFallback, requestedLocale: locale ?? null }
813
+ };
814
+ });
815
+ }
542
816
  async getSwatch(swatchId, siteVersion) {
543
817
  const response = await this.fetch(`v3/swatches/${swatchId}`, siteVersion);
544
818
  if (!response.ok) {
@@ -661,7 +935,7 @@ Received "${apiKey}" instead.`
661
935
  headers: {
662
936
  "x-api-key": this.apiKey,
663
937
  "makeswift-site-api-key": this.apiKey,
664
- "makeswift-runtime-version": "0.28.3-canary.6",
938
+ "makeswift-runtime-version": "0.28.3-canary.8",
665
939
  "content-type": "application/json"
666
940
  },
667
941
  body: JSON.stringify({ token }),