@makeswift/runtime 0.28.7-canary.4 → 0.28.7-canary.5

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 (132) hide show
  1. package/dist/cjs/api/graphql/documents/queries.js +6 -6
  2. package/dist/cjs/api/graphql/documents/queries.js.map +1 -1
  3. package/dist/cjs/api/graphql/generated/types.js.map +1 -1
  4. package/dist/cjs/api/graphql-api-client.js +23 -1
  5. package/dist/cjs/api/graphql-api-client.js.map +1 -1
  6. package/dist/cjs/api/{client.js → host-api-resources-client.js} +7 -7
  7. package/dist/cjs/api/host-api-resources-client.js.map +1 -0
  8. package/dist/cjs/api/rest-api-client.js +187 -0
  9. package/dist/cjs/api/rest-api-client.js.map +1 -0
  10. package/dist/cjs/api/schema/index.js +23 -0
  11. package/dist/cjs/api/schema/index.js.map +1 -0
  12. package/dist/cjs/api/schema/page-pathname-slice.js +38 -0
  13. package/dist/cjs/api/schema/page-pathname-slice.js.map +1 -0
  14. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  15. package/dist/cjs/client/component-snapshot.js +63 -0
  16. package/dist/cjs/client/component-snapshot.js.map +1 -0
  17. package/dist/cjs/client/index.js +102 -360
  18. package/dist/cjs/client/index.js.map +1 -1
  19. package/dist/cjs/client/page-snapshot.js +33 -0
  20. package/dist/cjs/client/page-snapshot.js.map +1 -0
  21. package/dist/cjs/client/schema/component-document.js +45 -0
  22. package/dist/cjs/client/schema/component-document.js.map +1 -0
  23. package/dist/cjs/client/schema/fonts.js +38 -0
  24. package/dist/cjs/client/schema/fonts.js.map +1 -0
  25. package/dist/cjs/client/schema/get-page.js +39 -0
  26. package/dist/cjs/client/schema/get-page.js.map +1 -0
  27. package/dist/cjs/client/schema/get-pages.js +68 -0
  28. package/dist/cjs/client/schema/get-pages.js.map +1 -0
  29. package/dist/cjs/client/schema/index.js +31 -0
  30. package/dist/cjs/client/schema/index.js.map +1 -0
  31. package/dist/cjs/client/schema/preview-token-payload.js +34 -0
  32. package/dist/cjs/client/schema/preview-token-payload.js.map +1 -0
  33. package/dist/cjs/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  34. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  35. package/dist/cjs/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  36. package/dist/cjs/next/testing/element-data.js +3 -3
  37. package/dist/cjs/next/testing/element-data.js.map +1 -1
  38. package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
  39. package/dist/cjs/runtimes/react/runtime-core.js +2 -2
  40. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  41. package/dist/esm/api/graphql/documents/queries.js +4 -4
  42. package/dist/esm/api/graphql/documents/queries.js.map +1 -1
  43. package/dist/esm/api/graphql/generated/types.js.map +1 -1
  44. package/dist/esm/api/graphql-api-client.js +29 -2
  45. package/dist/esm/api/graphql-api-client.js.map +1 -1
  46. package/dist/esm/api/{client.js → host-api-resources-client.js} +3 -3
  47. package/dist/esm/api/host-api-resources-client.js.map +1 -0
  48. package/dist/esm/api/rest-api-client.js +152 -0
  49. package/dist/esm/api/rest-api-client.js.map +1 -0
  50. package/dist/esm/api/schema/index.js +2 -0
  51. package/dist/esm/api/schema/index.js.map +1 -0
  52. package/dist/esm/api/schema/page-pathname-slice.js +14 -0
  53. package/dist/esm/api/schema/page-pathname-slice.js.map +1 -0
  54. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  55. package/dist/esm/client/component-snapshot.js +39 -0
  56. package/dist/esm/client/component-snapshot.js.map +1 -0
  57. package/dist/esm/client/index.js +67 -329
  58. package/dist/esm/client/index.js.map +1 -1
  59. package/dist/esm/client/page-snapshot.js +9 -0
  60. package/dist/esm/client/page-snapshot.js.map +1 -0
  61. package/dist/esm/client/schema/component-document.js +20 -0
  62. package/dist/esm/client/schema/component-document.js.map +1 -0
  63. package/dist/esm/client/schema/fonts.js +14 -0
  64. package/dist/esm/client/schema/fonts.js.map +1 -0
  65. package/dist/esm/client/schema/get-page.js +15 -0
  66. package/dist/esm/client/schema/get-page.js.map +1 -0
  67. package/dist/esm/client/schema/get-pages.js +42 -0
  68. package/dist/esm/client/schema/get-pages.js.map +1 -0
  69. package/dist/esm/client/schema/index.js +6 -0
  70. package/dist/esm/client/schema/index.js.map +1 -0
  71. package/dist/esm/client/schema/preview-token-payload.js +10 -0
  72. package/dist/esm/client/schema/preview-token-payload.js.map +1 -0
  73. package/dist/esm/next/components/tests/controls/color-control/fixtures.js.map +1 -1
  74. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  75. package/dist/esm/next/components/tests/controls/rich-text-v2-control/fixtures.js.map +1 -1
  76. package/dist/esm/next/testing/element-data.js +1 -1
  77. package/dist/esm/next/testing/element-data.js.map +1 -1
  78. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
  79. package/dist/esm/runtimes/react/runtime-core.js +2 -2
  80. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  81. package/dist/types/api/__tests__/rest-api-client.error-handling.test.d.ts +2 -0
  82. package/dist/types/api/__tests__/rest-api-client.error-handling.test.d.ts.map +1 -0
  83. package/dist/types/api/__tests__/rest-api-client.get-resources.test.d.ts +2 -0
  84. package/dist/types/api/__tests__/rest-api-client.get-resources.test.d.ts.map +1 -0
  85. package/dist/types/api/graphql/documents/queries.d.ts +1 -1
  86. package/dist/types/api/graphql/documents/queries.d.ts.map +1 -1
  87. package/dist/types/api/graphql/generated/types.d.ts +2 -2
  88. package/dist/types/api/graphql/generated/types.d.ts.map +1 -1
  89. package/dist/types/api/graphql-api-client.d.ts +5 -0
  90. package/dist/types/api/graphql-api-client.d.ts.map +1 -1
  91. package/dist/types/api/{client.d.ts → host-api-resources-client.d.ts} +2 -2
  92. package/dist/types/api/host-api-resources-client.d.ts.map +1 -0
  93. package/dist/types/api/rest-api-client.d.ts +27 -0
  94. package/dist/types/api/rest-api-client.d.ts.map +1 -0
  95. package/dist/types/api/schema/index.d.ts +2 -0
  96. package/dist/types/api/schema/index.d.ts.map +1 -0
  97. package/dist/types/api/schema/page-pathname-slice.d.ts +21 -0
  98. package/dist/types/api/schema/page-pathname-slice.d.ts.map +1 -0
  99. package/dist/types/client/component-snapshot.d.ts +25 -0
  100. package/dist/types/client/component-snapshot.d.ts.map +1 -0
  101. package/dist/types/client/index.d.ts +19 -640
  102. package/dist/types/client/index.d.ts.map +1 -1
  103. package/dist/types/client/page-snapshot.d.ts +62 -0
  104. package/dist/types/client/page-snapshot.d.ts.map +1 -0
  105. package/dist/types/client/schema/component-document.d.ts +285 -0
  106. package/dist/types/client/schema/component-document.d.ts.map +1 -0
  107. package/dist/types/client/schema/fonts.d.ts +27 -0
  108. package/dist/types/client/schema/fonts.d.ts.map +1 -0
  109. package/dist/types/client/schema/get-page.d.ts +30 -0
  110. package/dist/types/client/schema/get-page.d.ts.map +1 -0
  111. package/dist/types/client/schema/get-pages.d.ts +202 -0
  112. package/dist/types/client/schema/get-pages.d.ts.map +1 -0
  113. package/dist/types/client/schema/index.d.ts +6 -0
  114. package/dist/types/client/schema/index.d.ts.map +1 -0
  115. package/dist/types/client/schema/preview-token-payload.d.ts +19 -0
  116. package/dist/types/client/schema/preview-token-payload.d.ts.map +1 -0
  117. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts +1 -1
  118. package/dist/types/next/components/tests/controls/color-control/fixtures.d.ts.map +1 -1
  119. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts +1 -1
  120. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
  121. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts +1 -1
  122. package/dist/types/next/components/tests/controls/rich-text-v2-control/fixtures.d.ts.map +1 -1
  123. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts +1 -1
  124. package/dist/types/runtimes/react/hooks/use-cache-data.d.ts.map +1 -1
  125. package/package.json +1 -1
  126. package/dist/cjs/api/client.js.map +0 -1
  127. package/dist/esm/api/client.js.map +0 -1
  128. package/dist/types/api/client.d.ts.map +0 -1
  129. package/dist/types/client/tests/client.error-handling.test.d.ts +0 -2
  130. package/dist/types/client/tests/client.error-handling.test.d.ts.map +0 -1
  131. package/dist/types/client/tests/client.get-resources.test.d.ts +0 -2
  132. package/dist/types/client/tests/client.get-resources.test.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/next/components/tests/controls/color-control/fixtures.ts"],"sourcesContent":["import { type ValueType } from '@makeswift/controls'\nimport { ColorDefinition } from '@makeswift/controls'\n\nimport { APIResourceType, type Swatch } from '../../../../../api'\nimport { type CacheData } from '../../../../../api/client'\n\ntype SwatchData = Omit<Swatch, 'id'>\n\nexport const swatchId = '[swatch-test-id]'\nexport const swatch: SwatchData = {\n __typename: APIResourceType.Swatch,\n hue: 238,\n saturation: 87,\n lightness: 49,\n}\n\nexport const value: ValueType<ColorDefinition> = {\n swatchId,\n alpha: 0.5,\n}\n\nexport const cacheData = (swatch: SwatchData | null): Partial<CacheData> => ({\n apiResources: {\n Swatch: [{ id: swatchId, value: swatch == null ? null : { id: swatchId, ...swatch } }],\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA6C;AAKtC,MAAM,WAAW;AACjB,MAAM,SAAqB;AAAA,EAChC,YAAY,2BAAgB;AAAA,EAC5B,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,WAAW;AACb;AAEO,MAAM,QAAoC;AAAA,EAC/C;AAAA,EACA,OAAO;AACT;AAEO,MAAM,YAAY,CAACA,aAAmD;AAAA,EAC3E,cAAc;AAAA,IACZ,QAAQ,CAAC,EAAE,IAAI,UAAU,OAAOA,WAAU,OAAO,OAAO,EAAE,IAAI,UAAU,GAAGA,QAAO,EAAE,CAAC;AAAA,EACvF;AACF;","names":["swatch"]}
1
+ {"version":3,"sources":["../../../../../../../src/next/components/tests/controls/color-control/fixtures.ts"],"sourcesContent":["import { type ValueType } from '@makeswift/controls'\nimport { ColorDefinition } from '@makeswift/controls'\n\nimport { APIResourceType, type Swatch } from '../../../../../api'\nimport { type CacheData } from '../../../../../api/api-resources-client'\n\ntype SwatchData = Omit<Swatch, 'id'>\n\nexport const swatchId = '[swatch-test-id]'\nexport const swatch: SwatchData = {\n __typename: APIResourceType.Swatch,\n hue: 238,\n saturation: 87,\n lightness: 49,\n}\n\nexport const value: ValueType<ColorDefinition> = {\n swatchId,\n alpha: 0.5,\n}\n\nexport const cacheData = (swatch: SwatchData | null): Partial<CacheData> => ({\n apiResources: {\n Swatch: [{ id: swatchId, value: swatch == null ? null : { id: swatchId, ...swatch } }],\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAA6C;AAKtC,MAAM,WAAW;AACjB,MAAM,SAAqB;AAAA,EAChC,YAAY,2BAAgB;AAAA,EAC5B,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,WAAW;AACb;AAEO,MAAM,QAAoC;AAAA,EAC/C;AAAA,EACA,OAAO;AACT;AAEO,MAAM,YAAY,CAACA,aAAmD;AAAA,EAC3E,cAAc;AAAA,IACZ,QAAQ,CAAC,EAAE,IAAI,UAAU,OAAOA,WAAU,OAAO,OAAO,EAAE,IAAI,UAAU,GAAGA,QAAO,EAAE,CAAC;AAAA,EACvF;AACF;","names":["swatch"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/next/components/tests/controls/page-control-prop-rendering.tsx"],"sourcesContent":["import { type ReactNode, Fragment, forwardRef, useRef, isValidElement, act } from 'react'\nimport { renderToReadableStream } from 'react-dom/server'\nimport { JSDOM } from 'jsdom'\nimport { render, screen } from '@testing-library/react'\nimport '@testing-library/jest-dom'\nimport { ServerInsertedHTMLContext } from 'next/navigation'\n\nimport { type Data, type ValueType, type DataType, ControlDefinition } from '@makeswift/controls'\n\nimport { type CacheData } from '../../../../api/client'\nimport { ElementData } from '../../../../state/read-only-state'\nimport { setIsInBuilder } from '../../../../state/actions/internal/read-only-actions'\nimport { ReactRuntime } from '../../../../runtimes/react/react-runtime'\nimport { MakeswiftComponent } from '../../../../runtimes/react/components/MakeswiftComponent'\nimport { Page } from '../../page'\nimport { isServer } from '../../../../utils/is-server'\nimport * as Testing from '../../../testing'\n\nconst ROOT_ID = '00000000-0000-0000-0000-000000000000'\nconst ELEMENT_ID = '11111111-1111-1111-1111-111111111111'\n\nconst renderProp = (prop: any) =>\n prop === undefined ? 'undefined' : isValidElement(prop) ? prop : JSON.stringify(prop)\n\nconst propSnapshot = (prop: HTMLElement | null) =>\n prop?.childElementCount ? prop.childNodes : parseStringifiedProp(prop?.textContent ?? '')\n\nconst parseStringifiedProp = (prop: string) => (prop === 'undefined' ? undefined : JSON.parse(prop))\n\nasync function streamToString(stream: ReadableStream) {\n const reader = stream.getReader()\n const decoder = new TextDecoder()\n\n let result = ''\n\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n result += decoder.decode(value, { stream: true })\n }\n\n return result\n}\n\nasync function renderToString(element: ReactNode) {\n return await streamToString(await renderToReadableStream(element))\n}\n\nasync function serverSideRender(children: ReactNode) {\n // wrap the children in a context provider to capture server-inserted HTML, see\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/server-inserted-html.tsx\n const serverInsertedCallbacks: (() => React.ReactNode)[] = []\n\n const elementTree = (\n <ServerInsertedHTMLContext.Provider value={handler => serverInsertedCallbacks.push(handler)}>\n {children}\n </ServerInsertedHTMLContext.Provider>\n )\n\n const elementsHTML = await renderToString(elementTree)\n\n const serverInsertedNodes = serverInsertedCallbacks.map((callback, index) => (\n <Fragment key={'__next_server_inserted__' + index}>{callback()}</Fragment>\n ))\n\n const headHTML = await renderToString(serverInsertedNodes)\n\n const dom = new JSDOM(\n `<!DOCTYPE html><head>${headHTML}</head><body><div id=\"root\">${elementsHTML}</div></body></div>`,\n {\n runScripts: 'dangerously',\n },\n )\n\n return dom.window.document\n}\n\nexport async function testPageControlPropRendering<D extends ControlDefinition>(\n controlDefinition: D,\n {\n toData,\n value,\n locale,\n cacheData,\n expectedRenders,\n registerComponents,\n action,\n rootElements = [],\n isInBuilder = false,\n }: {\n toData?: (value: ValueType<D>) => DataType<D>\n value: ValueType<D> | undefined\n locale?: string | null\n cacheData?: Partial<CacheData>\n expectedRenders?: number\n registerComponents?: (runtime: ReactRuntime) => void\n action?: (element: HTMLElement) => Promise<void>\n rootElements?: ElementData[]\n isInBuilder?: boolean\n },\n) {\n // Arrange\n const controlData: DataType<D> | Data =\n value !== undefined ? (toData ? toData(value) : controlDefinition.toData(value)) : undefined\n\n const testComponentMeta = {\n type: 'TestComponent',\n label: 'Test Component',\n }\n\n const testId = 'test-id'\n const renderCountTestId = 'render-count-test-id'\n const elementData: ElementData = {\n key: ELEMENT_ID,\n type: testComponentMeta.type,\n props: {\n propKey: controlData,\n },\n }\n\n const runtime = Testing.createReactRuntime()\n runtime.protoStore.dispatch(setIsInBuilder(isInBuilder))\n registerComponents?.(runtime)\n\n // Act\n runtime.registerComponent(\n forwardRef<HTMLDivElement, { propKey?: any }>(({ propKey }, ref) => {\n const renderCount = useRef(0)\n ++renderCount.current\n\n return (\n <div ref={ref}>\n <div data-testid={renderCountTestId}>{renderCount.current}</div>\n <div data-testid={testId}>{renderProp(propKey)}</div>\n </div>\n )\n }),\n {\n ...testComponentMeta,\n props: {\n propKey: controlDefinition as any,\n },\n },\n )\n\n const testElementTree = (component: ReactNode) => (\n <Testing.ReactProvider runtime={runtime}>{component}</Testing.ReactProvider>\n )\n\n if (!isServer()) {\n const rootElementData: ElementData = Testing.createRootComponent(\n [elementData, ...rootElements],\n ROOT_ID,\n )\n\n const snapshot = Testing.createMakeswiftPageSnapshot(rootElementData, { locale, cacheData })\n\n // Assert\n await act(async () => render(testElementTree(<Page snapshot={snapshot} />)))\n\n if (action) {\n await act(async () => {\n await action(screen.getByTestId(testId))\n })\n }\n\n expect(snapshot).toMatchSnapshot('snapshot')\n expect(propSnapshot(screen.getByTestId(testId))).toMatchSnapshot('resolvedValue')\n\n if (expectedRenders != null) {\n expect(Number(screen.getByTestId(renderCountTestId).textContent)).toBe(expectedRenders)\n }\n } else {\n // test server-side rendering using a component snapshot\n console.assert(action == null)\n console.assert(rootElements.length === 0)\n\n const snapshot = Testing.createMakeswiftComponentSnapshot(elementData, { locale, cacheData })\n const elementTree = testElementTree(\n <MakeswiftComponent snapshot={snapshot} {...testComponentMeta} />,\n )\n\n const document = await serverSideRender(elementTree)\n const getByTestId = (id: string): HTMLElement | null =>\n document.querySelector(`[data-testid=\"${id}\"]`)\n\n expect(propSnapshot(getByTestId(testId))).toMatchSnapshot('resolvedValue')\n expect([...document.querySelectorAll('style')].map(n => n.textContent)).toMatchSnapshot(\n 'component styles',\n )\n expect(Number(getByTestId(renderCountTestId)?.textContent)).toBe(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDI;AAtDJ,mBAAkF;AAClF,oBAAuC;AACvC,mBAAsB;AACtB,IAAAA,gBAA+B;AAC/B,sBAAO;AACP,wBAA0C;AAM1C,+BAA+B;AAE/B,gCAAmC;AACnC,kBAAqB;AACrB,uBAAyB;AACzB,cAAyB;AAEzB,MAAM,UAAU;AAChB,MAAM,aAAa;AAEnB,MAAM,aAAa,CAAC,SAClB,SAAS,SAAY,kBAAc,6BAAe,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI;AAEtF,MAAM,eAAe,CAAC,SACpB,MAAM,oBAAoB,KAAK,aAAa,qBAAqB,MAAM,eAAe,EAAE;AAE1F,MAAM,uBAAuB,CAAC,SAAkB,SAAS,cAAc,SAAY,KAAK,MAAM,IAAI;AAElG,eAAe,eAAe,QAAwB;AACpD,QAAM,SAAS,OAAO,UAAU;AAChC,QAAM,UAAU,IAAI,YAAY;AAEhC,MAAI,SAAS;AAEb,SAAO,MAAM;AACX,U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AE,QAAQ,UAAU,CAAC;AAC5F,UAAM,cAAc;AAAA,MAClB,4CAAC,gDAAmB,UAAqB,GAAG,mBAAmB;AAAA,IACjE;AAEA,UAAM,WAAW,MAAM,iBAAiB,WAAW;AACnD,UAAM,cAAc,CAAC,OACnB,SAAS,cAAc,iBAAiB,EAAE,IAAI;AAEhD,WAAO,aAAa,YAAY,MAAM,CAAC,CAAC,EAAE,gBAAgB,eAAe;AACzE,WAAO,CAAC,GAAG,SAAS,iBAAiB,OAAO,CAAC,EAAE,IAAI,OAAK,EAAE,WAAW,CAAC,EAAE;AAAA,MACtE;AAAA,IACF;AACA,WAAO,OAAO,YAAY,iBAAiB,GAAG,WAAW,CAAC,EAAE,KAAK,CAAC;AAAA,EACpE;AACF;","names":["import_react"]}
1
+ {"version":3,"sources":["../../../../../../src/next/components/tests/controls/page-control-prop-rendering.tsx"],"sourcesContent":["import { type ReactNode, Fragment, forwardRef, useRef, isValidElement, act } from 'react'\nimport { renderToReadableStream } from 'react-dom/server'\nimport { JSDOM } from 'jsdom'\nimport { render, screen } from '@testing-library/react'\nimport '@testing-library/jest-dom'\nimport { ServerInsertedHTMLContext } from 'next/navigation'\n\nimport { type Data, type ValueType, type DataType, ControlDefinition } from '@makeswift/controls'\n\nimport { type CacheData } from '../../../../api/api-resources-client'\nimport { ElementData } from '../../../../state/read-only-state'\nimport { setIsInBuilder } from '../../../../state/actions/internal/read-only-actions'\nimport { ReactRuntime } from '../../../../runtimes/react/react-runtime'\nimport { MakeswiftComponent } from '../../../../runtimes/react/components/MakeswiftComponent'\nimport { Page } from '../../page'\nimport { isServer } from '../../../../utils/is-server'\nimport * as Testing from '../../../testing'\n\nconst ROOT_ID = '00000000-0000-0000-0000-000000000000'\nconst ELEMENT_ID = '11111111-1111-1111-1111-111111111111'\n\nconst renderProp = (prop: any) =>\n prop === undefined ? 'undefined' : isValidElement(prop) ? prop : JSON.stringify(prop)\n\nconst propSnapshot = (prop: HTMLElement | null) =>\n prop?.childElementCount ? prop.childNodes : parseStringifiedProp(prop?.textContent ?? '')\n\nconst parseStringifiedProp = (prop: string) => (prop === 'undefined' ? undefined : JSON.parse(prop))\n\nasync function streamToString(stream: ReadableStream) {\n const reader = stream.getReader()\n const decoder = new TextDecoder()\n\n let result = ''\n\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n result += decoder.decode(value, { stream: true })\n }\n\n return result\n}\n\nasync function renderToString(element: ReactNode) {\n return await streamToString(await renderToReadableStream(element))\n}\n\nasync function serverSideRender(children: ReactNode) {\n // wrap the children in a context provider to capture server-inserted HTML, see\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/server-inserted-html.tsx\n const serverInsertedCallbacks: (() => React.ReactNode)[] = []\n\n const elementTree = (\n <ServerInsertedHTMLContext.Provider value={handler => serverInsertedCallbacks.push(handler)}>\n {children}\n </ServerInsertedHTMLContext.Provider>\n )\n\n const elementsHTML = await renderToString(elementTree)\n\n const serverInsertedNodes = serverInsertedCallbacks.map((callback, index) => (\n <Fragment key={'__next_server_inserted__' + index}>{callback()}</Fragment>\n ))\n\n const headHTML = await renderToString(serverInsertedNodes)\n\n const dom = new JSDOM(\n `<!DOCTYPE html><head>${headHTML}</head><body><div id=\"root\">${elementsHTML}</div></body></div>`,\n {\n runScripts: 'dangerously',\n },\n )\n\n return dom.window.document\n}\n\nexport async function testPageControlPropRendering<D extends ControlDefinition>(\n controlDefinition: D,\n {\n toData,\n value,\n locale,\n cacheData,\n expectedRenders,\n registerComponents,\n action,\n rootElements = [],\n isInBuilder = false,\n }: {\n toData?: (value: ValueType<D>) => DataType<D>\n value: ValueType<D> | undefined\n locale?: string | null\n cacheData?: Partial<CacheData>\n expectedRenders?: number\n registerComponents?: (runtime: ReactRuntime) => void\n action?: (element: HTMLElement) => Promise<void>\n rootElements?: ElementData[]\n isInBuilder?: boolean\n },\n) {\n // Arrange\n const controlData: DataType<D> | Data =\n value !== undefined ? (toData ? toData(value) : controlDefinition.toData(value)) : undefined\n\n const testComponentMeta = {\n type: 'TestComponent',\n label: 'Test Component',\n }\n\n const testId = 'test-id'\n const renderCountTestId = 'render-count-test-id'\n const elementData: ElementData = {\n key: ELEMENT_ID,\n type: testComponentMeta.type,\n props: {\n propKey: controlData,\n },\n }\n\n const runtime = Testing.createReactRuntime()\n runtime.protoStore.dispatch(setIsInBuilder(isInBuilder))\n registerComponents?.(runtime)\n\n // Act\n runtime.registerComponent(\n forwardRef<HTMLDivElement, { propKey?: any }>(({ propKey }, ref) => {\n const renderCount = useRef(0)\n ++renderCount.current\n\n return (\n <div ref={ref}>\n <div data-testid={renderCountTestId}>{renderCount.current}</div>\n <div data-testid={testId}>{renderProp(propKey)}</div>\n </div>\n )\n }),\n {\n ...testComponentMeta,\n props: {\n propKey: controlDefinition as any,\n },\n },\n )\n\n const testElementTree = (component: ReactNode) => (\n <Testing.ReactProvider runtime={runtime}>{component}</Testing.ReactProvider>\n )\n\n if (!isServer()) {\n const rootElementData: ElementData = Testing.createRootComponent(\n [elementData, ...rootElements],\n ROOT_ID,\n )\n\n const snapshot = Testing.createMakeswiftPageSnapshot(rootElementData, { locale, cacheData })\n\n // Assert\n await act(async () => render(testElementTree(<Page snapshot={snapshot} />)))\n\n if (action) {\n await act(async () => {\n await action(screen.getByTestId(testId))\n })\n }\n\n expect(snapshot).toMatchSnapshot('snapshot')\n expect(propSnapshot(screen.getByTestId(testId))).toMatchSnapshot('resolvedValue')\n\n if (expectedRenders != null) {\n expect(Number(screen.getByTestId(renderCountTestId).textContent)).toBe(expectedRenders)\n }\n } else {\n // test server-side rendering using a component snapshot\n console.assert(action == null)\n console.assert(rootElements.length === 0)\n\n const snapshot = Testing.createMakeswiftComponentSnapshot(elementData, { locale, cacheData })\n const elementTree = testElementTree(\n <MakeswiftComponent snapshot={snapshot} {...testComponentMeta} />,\n )\n\n const document = await serverSideRender(elementTree)\n const getByTestId = (id: string): HTMLElement | null =>\n document.querySelector(`[data-testid=\"${id}\"]`)\n\n expect(propSnapshot(getByTestId(testId))).toMatchSnapshot('resolvedValue')\n expect([...document.querySelectorAll('style')].map(n => n.textContent)).toMatchSnapshot(\n 'component styles',\n )\n expect(Number(getByTestId(renderCountTestId)?.textContent)).toBe(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDI;AAtDJ,mBAAkF;AAClF,oBAAuC;AACvC,mBAAsB;AACtB,IAAAA,gBAA+B;AAC/B,sBAAO;AACP,wBAA0C;AAM1C,+BAA+B;AAE/B,gCAAmC;AACnC,kBAAqB;AACrB,uBAAyB;AACzB,cAAyB;AAEzB,MAAM,UAAU;AAChB,MAAM,aAAa;AAEnB,MAAM,aAAa,CAAC,SAClB,SAAS,SAAY,kBAAc,6BAAe,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI;AAEtF,MAAM,eAAe,CAAC,SACpB,MAAM,oBAAoB,KAAK,aAAa,qBAAqB,MAAM,eAAe,EAAE;AAE1F,MAAM,uBAAuB,CAAC,SAAkB,SAAS,cAAc,SAAY,KAAK,MAAM,IAAI;AAElG,eAAe,eAAe,QAAwB;AACpD,QAAM,SAAS,OAAO,UAAU;AAChC,QAAM,UAAU,IAAI,YAAY;AAEhC,MAAI,SAAS;AAEb,SAAO,MAAM;AACX,UAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,QAAI;AAAM;AACV,cAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;AAEA,eAAe,eAAe,SAAoB;AAChD,SAAO,MAAM,eAAe,UAAM,sCAAuB,OAAO,CAAC;AACnE;AAEA,eAAe,iBAAiB,UAAqB;AAGnD,QAAM,0BAAqD,CAAC;AAE5D,QAAM,cACJ,4CAAC,4CAA0B,UAA1B,EAAmC,OAAO,aAAW,wBAAwB,KAAK,OAAO,GACvF,UACH;AAGF,QAAM,eAAe,MAAM,eAAe,WAAW;AAErD,QAAM,sBAAsB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AE,KAAK,CAAC;AAAA,EACpE;AACF;","names":["import_react"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/next/components/tests/controls/rich-text-v2-control/fixtures.tsx"],"sourcesContent":["import { APIResourceType, type Swatch, type Typography } from '../../../../../api'\n\nimport * as Fixture from '../fixtures/rich-text-v2'\nimport { type CacheData } from '../../../../../api/client'\n\nconst swatchId = 'U3dhdGNoOmJkODYxMWM5LTNiZjItNDM3MS1iMmU4LTBmMmNlMDZjNDE1OA=='\nconst swatch: Swatch = {\n __typename: APIResourceType.Swatch,\n id: swatchId,\n hue: 238,\n saturation: 87,\n lightness: 49,\n}\n\nconst typographyId = 'VHlwb2dyYXBoeTowNGI4OTZlMC0wZWEyLTRkMTMtYmU3ZS0xYmY1M2VmMjBiZjc='\nconst typography: Typography = {\n __typename: APIResourceType.Typography,\n id: typographyId,\n name: 'Body',\n style: [\n {\n deviceId: 'desktop',\n value: {\n fontFamily: 'Lato',\n fontSize: { value: 16, unit: 'px' },\n color: null,\n lineHeight: null,\n letterSpacing: null,\n fontWeight: null,\n textAlign: null,\n uppercase: null,\n underline: null,\n strikethrough: null,\n italic: null,\n },\n },\n ],\n}\n\nexport const value = Fixture.data\nexport const cacheData = (): Partial<CacheData> => ({\n apiResources: {\n Swatch: [\n {\n id: swatchId,\n value: swatch,\n },\n ],\n Typography: [\n {\n id: typographyId,\n value: typography,\n },\n ],\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA8D;AAE9D,cAAyB;AAGzB,MAAM,WAAW;AACjB,MAAM,SAAiB;AAAA,EACrB,YAAY,2BAAgB;AAAA,EAC5B,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,WAAW;AACb;AAEA,MAAM,eAAe;AACrB,MAAM,aAAyB;AAAA,EAC7B,YAAY,2BAAgB;AAAA,EAC5B,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,IACL;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK;AAAA,QAClC,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,WAAW;AAAA,QACX,WAAW;AAAA,QACX,eAAe;AAAA,QACf,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAEO,MAAM,QAAQ,QAAQ;AACtB,MAAM,YAAY,OAA2B;AAAA,EAClD,cAAc;AAAA,IACZ,QAAQ;AAAA,MACN;AAAA,QACE,IAAI;AAAA,QACJ,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,YAAY;AAAA,MACV;AAAA,QACE,IAAI;AAAA,QACJ,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../../../src/next/components/tests/controls/rich-text-v2-control/fixtures.tsx"],"sourcesContent":["import { APIResourceType, type Swatch, type Typography } from '../../../../../api'\n\nimport * as Fixture from '../fixtures/rich-text-v2'\nimport { type CacheData } from '../../../../../api/api-resources-client'\n\nconst swatchId = 'U3dhdGNoOmJkODYxMWM5LTNiZjItNDM3MS1iMmU4LTBmMmNlMDZjNDE1OA=='\nconst swatch: Swatch = {\n __typename: APIResourceType.Swatch,\n id: swatchId,\n hue: 238,\n saturation: 87,\n lightness: 49,\n}\n\nconst typographyId = 'VHlwb2dyYXBoeTowNGI4OTZlMC0wZWEyLTRkMTMtYmU3ZS0xYmY1M2VmMjBiZjc='\nconst typography: Typography = {\n __typename: APIResourceType.Typography,\n id: typographyId,\n name: 'Body',\n style: [\n {\n deviceId: 'desktop',\n value: {\n fontFamily: 'Lato',\n fontSize: { value: 16, unit: 'px' },\n color: null,\n lineHeight: null,\n letterSpacing: null,\n fontWeight: null,\n textAlign: null,\n uppercase: null,\n underline: null,\n strikethrough: null,\n italic: null,\n },\n },\n ],\n}\n\nexport const value = Fixture.data\nexport const cacheData = (): Partial<CacheData> => ({\n apiResources: {\n Swatch: [\n {\n id: swatchId,\n value: swatch,\n },\n ],\n Typography: [\n {\n id: typographyId,\n value: typography,\n },\n ],\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA8D;AAE9D,cAAyB;AAGzB,MAAM,WAAW;AACjB,MAAM,SAAiB;AAAA,EACrB,YAAY,2BAAgB;AAAA,EAC5B,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,WAAW;AACb;AAEA,MAAM,eAAe;AACrB,MAAM,aAAyB;AAAA,EAC7B,YAAY,2BAAgB;AAAA,EAC5B,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO;AAAA,IACL;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,QACL,YAAY;AAAA,QACZ,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK;AAAA,QAClC,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,WAAW;AAAA,QACX,WAAW;AAAA,QACX,eAAe;AAAA,QACf,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;AAEO,MAAM,QAAQ,QAAQ;AACtB,MAAM,YAAY,OAA2B;AAAA,EAClD,cAAc;AAAA,IACZ,QAAQ;AAAA,MACN;AAAA,QACE,IAAI;AAAA,QACJ,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,YAAY;AAAA,MACV;AAAA,QACE,IAAI;AAAA,QACJ,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -24,7 +24,7 @@ __export(element_data_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(element_data_exports);
26
26
  var import_crypto = require("crypto");
27
- var import_client2 = require("../../api/client");
27
+ var import_api_resources_client = require("../../api/api-resources-client");
28
28
  var import_constants = require("../../components/builtin/constants");
29
29
  function createRootComponent(elements, rootId) {
30
30
  return {
@@ -64,7 +64,7 @@ function createMakeswiftPageSnapshot(elementDataOrDocument, {
64
64
  locale
65
65
  },
66
66
  cacheData: {
67
- ...import_client2.CacheData.empty(),
67
+ ...import_api_resources_client.CacheData.empty(),
68
68
  ...cacheData
69
69
  }
70
70
  };
@@ -88,7 +88,7 @@ function createMakeswiftComponentSnapshot(elementData, {
88
88
  requestedLocale: locale
89
89
  },
90
90
  cacheData: {
91
- ...import_client2.CacheData.empty(),
91
+ ...import_api_resources_client.CacheData.empty(),
92
92
  ...cacheData
93
93
  }
94
94
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/next/testing/element-data.ts"],"sourcesContent":["import { randomUUID } from 'crypto'\n\nimport {\n type MakeswiftPageSnapshot,\n type MakeswiftPageDocument,\n type MakeswiftComponentSnapshot,\n} from '../../client'\nimport { CacheData } from '../../api/client'\nimport { type ElementData } from '../../state/read-only-state'\nimport { MakeswiftComponentType } from '../../components/builtin/constants'\n\nexport function createRootComponent(elements: ElementData[], rootId?: string) {\n return {\n key: rootId ?? randomUUID(),\n type: MakeswiftComponentType.Root,\n props: {\n children: {\n columns: [\n {\n deviceId: 'desktop',\n value: {\n count: 12,\n spans: elements?.map(() => [12]),\n },\n },\n ],\n elements,\n },\n },\n }\n}\n\nconst isDocument = (\n elementDataOrDocument: ElementData | MakeswiftPageDocument,\n): elementDataOrDocument is MakeswiftPageDocument =>\n 'snippets' in elementDataOrDocument ||\n 'fonts' in elementDataOrDocument ||\n 'meta' in elementDataOrDocument ||\n 'seo' in elementDataOrDocument\n\nexport function createMakeswiftPageSnapshot(\n elementDataOrDocument: ElementData | MakeswiftPageDocument,\n {\n cacheData = {},\n locale = null,\n }: { cacheData?: Partial<MakeswiftPageSnapshot['cacheData']>; locale?: string | null } = {},\n): MakeswiftPageSnapshot {\n return {\n document: isDocument(elementDataOrDocument)\n ? elementDataOrDocument\n : {\n id: 'test-page-id',\n site: { id: 'test-site-id' },\n data: elementDataOrDocument,\n snippets: [],\n fonts: [],\n meta: {},\n seo: {},\n localizedPages: [],\n locale,\n },\n cacheData: {\n ...CacheData.empty(),\n ...cacheData,\n },\n }\n}\n\nexport function createMakeswiftComponentSnapshot(\n elementData: ElementData | null,\n {\n cacheData = {},\n locale = null,\n }: { cacheData?: Partial<MakeswiftComponentSnapshot['cacheData']>; locale?: string | null } = {},\n): MakeswiftComponentSnapshot {\n return {\n key: randomUUID(),\n document: {\n id: 'test-component-id',\n name: 'Test Component Document',\n siteId: 'test-site-id',\n data: elementData,\n inheritsFromParent: false,\n locale,\n },\n meta: {\n allowLocaleFallback: false,\n requestedLocale: locale,\n },\n cacheData: {\n ...CacheData.empty(),\n ...cacheData,\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAO3B,IAAAA,iBAA0B;AAE1B,uBAAuC;AAEhC,SAAS,oBAAoB,UAAyB,QAAiB;AAC5E,SAAO;AAAA,IACL,KAAK,cAAU,0BAAW;AAAA,IAC1B,MAAM,wCAAuB;AAAA,IAC7B,OAAO;AAAA,MACL,UAAU;AAAA,QACR,SAAS;AAAA,UACP;AAAA,YACE,UAAU;AAAA,YACV,OAAO;AAAA,cACL,OAAO;AAAA,cACP,OAAO,UAAU,IAAI,MAAM,CAAC,EAAE,CAAC;AAAA,YACjC;AAAA,UACF;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,MAAM,aAAa,CACjB,0BAEA,cAAc,yBACd,WAAW,yBACX,UAAU,yBACV,SAAS;AAEJ,SAAS,4BACd,uBACA;AAAA,EACE,YAAY,CAAC;AAAA,EACb,SAAS;AACX,IAAyF,CAAC,GACnE;AACvB,SAAO;AAAA,IACL,UAAU,WAAW,qBAAqB,IACtC,wBACA;AAAA,MACE,IAAI;AAAA,MACJ,MAAM,EAAE,IAAI,eAAe;AAAA,MAC3B,MAAM;AAAA,MACN,UAAU,CAAC;AAAA,MACX,OAAO,CAAC;AAAA,MACR,MAAM,CAAC;AAAA,MACP,KAAK,CAAC;AAAA,MACN,gBAAgB,CAAC;AAAA,MACjB;AAAA,IACF;AAAA,IACJ,WAAW;AAAA,MACT,GAAG,yBAAU,MAAM;AAAA,MACnB,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAEO,SAAS,iCACd,aACA;AAAA,EACE,YAAY,CAAC;AAAA,EACb,SAAS;AACX,IAA8F,CAAC,GACnE;AAC5B,SAAO;AAAA,IACL,SAAK,0BAAW;AAAA,IAChB,UAAU;AAAA,MACR,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,oBAAoB;AAAA,MACpB;AAAA,IACF;AAAA,IACA,MAAM;AAAA,MACJ,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,IACnB;AAAA,IACA,WAAW;AAAA,MACT,GAAG,yBAAU,MAAM;AAAA,MACnB,GAAG;AAAA,IACL;AAAA,EACF;AACF;","names":["import_client"]}
1
+ {"version":3,"sources":["../../../../src/next/testing/element-data.ts"],"sourcesContent":["import { randomUUID } from 'crypto'\n\nimport {\n type MakeswiftPageSnapshot,\n type MakeswiftPageDocument,\n type MakeswiftComponentSnapshot,\n} from '../../client'\nimport { CacheData } from '../../api/api-resources-client'\nimport { type ElementData } from '../../state/read-only-state'\nimport { MakeswiftComponentType } from '../../components/builtin/constants'\n\nexport function createRootComponent(elements: ElementData[], rootId?: string) {\n return {\n key: rootId ?? randomUUID(),\n type: MakeswiftComponentType.Root,\n props: {\n children: {\n columns: [\n {\n deviceId: 'desktop',\n value: {\n count: 12,\n spans: elements?.map(() => [12]),\n },\n },\n ],\n elements,\n },\n },\n }\n}\n\nconst isDocument = (\n elementDataOrDocument: ElementData | MakeswiftPageDocument,\n): elementDataOrDocument is MakeswiftPageDocument =>\n 'snippets' in elementDataOrDocument ||\n 'fonts' in elementDataOrDocument ||\n 'meta' in elementDataOrDocument ||\n 'seo' in elementDataOrDocument\n\nexport function createMakeswiftPageSnapshot(\n elementDataOrDocument: ElementData | MakeswiftPageDocument,\n {\n cacheData = {},\n locale = null,\n }: { cacheData?: Partial<MakeswiftPageSnapshot['cacheData']>; locale?: string | null } = {},\n): MakeswiftPageSnapshot {\n return {\n document: isDocument(elementDataOrDocument)\n ? elementDataOrDocument\n : {\n id: 'test-page-id',\n site: { id: 'test-site-id' },\n data: elementDataOrDocument,\n snippets: [],\n fonts: [],\n meta: {},\n seo: {},\n localizedPages: [],\n locale,\n },\n cacheData: {\n ...CacheData.empty(),\n ...cacheData,\n },\n }\n}\n\nexport function createMakeswiftComponentSnapshot(\n elementData: ElementData | null,\n {\n cacheData = {},\n locale = null,\n }: { cacheData?: Partial<MakeswiftComponentSnapshot['cacheData']>; locale?: string | null } = {},\n): MakeswiftComponentSnapshot {\n return {\n key: randomUUID(),\n document: {\n id: 'test-component-id',\n name: 'Test Component Document',\n siteId: 'test-site-id',\n data: elementData,\n inheritsFromParent: false,\n locale,\n },\n meta: {\n allowLocaleFallback: false,\n requestedLocale: locale,\n },\n cacheData: {\n ...CacheData.empty(),\n ...cacheData,\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAO3B,kCAA0B;AAE1B,uBAAuC;AAEhC,SAAS,oBAAoB,UAAyB,QAAiB;AAC5E,SAAO;AAAA,IACL,KAAK,cAAU,0BAAW;AAAA,IAC1B,MAAM,wCAAuB;AAAA,IAC7B,OAAO;AAAA,MACL,UAAU;AAAA,QACR,SAAS;AAAA,UACP;AAAA,YACE,UAAU;AAAA,YACV,OAAO;AAAA,cACL,OAAO;AAAA,cACP,OAAO,UAAU,IAAI,MAAM,CAAC,EAAE,CAAC;AAAA,YACjC;AAAA,UACF;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,MAAM,aAAa,CACjB,0BAEA,cAAc,yBACd,WAAW,yBACX,UAAU,yBACV,SAAS;AAEJ,SAAS,4BACd,uBACA;AAAA,EACE,YAAY,CAAC;AAAA,EACb,SAAS;AACX,IAAyF,CAAC,GACnE;AACvB,SAAO;AAAA,IACL,UAAU,WAAW,qBAAqB,IACtC,wBACA;AAAA,MACE,IAAI;AAAA,MACJ,MAAM,EAAE,IAAI,eAAe;AAAA,MAC3B,MAAM;AAAA,MACN,UAAU,CAAC;AAAA,MACX,OAAO,CAAC;AAAA,MACR,MAAM,CAAC;AAAA,MACP,KAAK,CAAC;AAAA,MACN,gBAAgB,CAAC;AAAA,MACjB;AAAA,IACF;AAAA,IACJ,WAAW;AAAA,MACT,GAAG,sCAAU,MAAM;AAAA,MACnB,GAAG;AAAA,IACL;AAAA,EACF;AACF;AAEO,SAAS,iCACd,aACA;AAAA,EACE,YAAY,CAAC;AAAA,EACb,SAAS;AACX,IAA8F,CAAC,GACnE;AAC5B,SAAO;AAAA,IACL,SAAK,0BAAW;AAAA,IAChB,UAAU;AAAA,MACR,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,oBAAoB;AAAA,MACpB;AAAA,IACF;AAAA,IACA,MAAM;AAAA,MACJ,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,IACnB;AAAA,IACA,WAAW;AAAA,MACT,GAAG,sCAAU,MAAM;AAAA,MACnB,GAAG;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-cache-data.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type CacheData } from '../../../api/client'\nimport { updateAPIClientCache } from '../../../state/actions/internal/read-write-actions'\n\nimport { useApiResourcesClient } from './use-api-resources-client'\n\nexport function useCacheData(cacheData: CacheData) {\n const { store: apiStore } = useApiResourcesClient()\n\n // We perform cache hydration immediately on render - this is safe to do per\n // render because updating the API cache is idempotent. For precedence, see:\n //\n // https://github.com/TanStack/query/blob/8f9f183f11df3709a1a38c4efce1452788041f88/packages/react-query/src/HydrationBoundary.tsx#L41\n useMemo(() => apiStore.dispatch(updateAPIClientCache(cacheData)), [cacheData])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AAExB,gCAAqC;AAErC,sCAAsC;AAE/B,SAAS,aAAa,WAAsB;AACjD,QAAM,EAAE,OAAO,SAAS,QAAI,uDAAsB;AAMlD,4BAAQ,MAAM,SAAS,aAAS,gDAAqB,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/E;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-cache-data.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type CacheData } from '../../../api/api-resources-client'\nimport { updateAPIClientCache } from '../../../state/actions/internal/read-write-actions'\n\nimport { useApiResourcesClient } from './use-api-resources-client'\n\nexport function useCacheData(cacheData: CacheData) {\n const { store: apiStore } = useApiResourcesClient()\n\n // We perform cache hydration immediately on render - this is safe to do per\n // render because updating the API cache is idempotent. For precedence, see:\n //\n // https://github.com/TanStack/query/blob/8f9f183f11df3709a1a38c4efce1452788041f88/packages/react-query/src/HydrationBoundary.tsx#L41\n useMemo(() => apiStore.dispatch(updateAPIClientCache(cacheData)), [cacheData])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AAExB,gCAAqC;AAErC,sCAAsC;AAE/B,SAAS,aAAa,WAAsB;AACjD,QAAM,EAAE,OAAO,SAAS,QAAI,uDAAsB;AAMlD,4BAAQ,MAAM,SAAS,aAAS,gDAAqB,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/E;","names":[]}
@@ -21,7 +21,7 @@ __export(runtime_core_exports, {
21
21
  RuntimeCore: () => RuntimeCore
22
22
  });
23
23
  module.exports = __toCommonJS(runtime_core_exports);
24
- var import_client = require("../../api/client");
24
+ var import_host_api_resources_client = require("../../api/host-api-resources-client");
25
25
  var import_breakpoints = require("../../state/modules/breakpoints");
26
26
  var import_copy_element_tree = require("../../state/ops/copy-element-tree");
27
27
  var import_read_only_state = require("../../state/read-only-state");
@@ -107,7 +107,7 @@ class RuntimeCore {
107
107
  return new URL("graphql", this.apiOrigin).href;
108
108
  }
109
109
  createApiResourcesClient(preloadedState) {
110
- return new import_client.MakeswiftHostApiClient({
110
+ return new import_host_api_resources_client.HostApiResourcesClient({
111
111
  fetch: this.fetch,
112
112
  preloadedState
113
113
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/react/runtime-core.ts"],"sourcesContent":["import { type SerializableReplacementContext } from '@makeswift/controls'\n\nimport { MakeswiftHostApiClient } from '../../api/client'\nimport { type HttpFetch } from '../../state/api-client/fetch-api-resource'\nimport { type SiteVersion } from '../../api/site-version'\n\nimport {\n Breakpoints,\n BreakpointsInput,\n parseBreakpointsInput,\n} from '../../state/modules/breakpoints'\n\nimport { copyElementTree } from '../../state/ops/copy-element-tree'\n\nimport { getBreakpoints, type Element, type ElementData } from '../../state/read-only-state'\nimport {\n configureProtoStore,\n configureReadWriteStore,\n type ProtoStore,\n type Store,\n} from '../../state/store'\n\nimport { RefCountedMap } from '../../utils/ref-counted-map'\nimport { isServer } from '../../utils/is-server'\n\nexport type StoreKey = {\n siteVersion: SiteVersion | null\n locale: string | undefined\n}\n\nconst VERSION_TAG_LIVE = 'ref:live'\n\nexport class RuntimeCore {\n // The unowned entry TTL affects performance, not correctness. The TTL controls how long an unretained store stays\n // in the map. If an entry expires and is removed from the map before React commits, the store remains retained\n // via `<StoreContext.Provider>`. The only impact is that future lookups will create a new store instance instead of\n // reusing the existing one, reducing cache efficiency.\n private readonly activeStores = new RefCountedMap<string | null, Store>({\n unownedEntryTtlMs: 1000,\n // Checking on retain/release is sufficient on the client, and we don't need to check on get on the server\n // as the only scenario in which we add the store to the map is when the runtime is already bound to the\n // requested site version, which should be the only site version for which the store is requested\n ttlCheck: RefCountedMap.TTLCheck.ON_RETAIN | RefCountedMap.TTLCheck.ON_RELEASE,\n })\n\n readonly protoStore: ProtoStore\n readonly appOrigin: string\n readonly apiOrigin: string\n readonly requestKey: StoreKey | undefined\n readonly fetch: HttpFetch\n\n constructor({\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n breakpoints,\n requestKey,\n fetch,\n }: {\n appOrigin?: string\n apiOrigin?: string\n breakpoints?: BreakpointsInput\n requestKey?: StoreKey\n fetch: HttpFetch\n }) {\n this.appOrigin = validateOrigin(appOrigin, 'appOrigin')\n this.apiOrigin = validateOrigin(apiOrigin, 'apiOrigin')\n this.requestKey = requestKey\n this.fetch = fetch\n\n this.protoStore = configureProtoStore({\n name: 'Runtime proto-store',\n breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : undefined,\n })\n }\n\n getOrCreateStore({ siteVersion, locale }: StoreKey): Store {\n const key = storeCacheKey({ siteVersion, locale })\n\n const createStore = () => {\n // API resources client includes an in-memory cache of the site's resources and thus also has to be versioned\n const apiResourcesClient = this.createApiResourcesClient({ siteVersion, locale })\n\n // TODO: we need to decouple editability from the site version; specifically, previewing\n // a draft version of the site should not lead to switching to the read-write state\n const isReadOnly = siteVersion == null\n\n return configureReadWriteStore({\n name: `Runtime read-write store (site version: ${key})`,\n appOrigin: this.appOrigin,\n apiResourcesClient,\n preloadedState: { ...this.protoStore.getState(), siteVersion, isReadOnly, locale },\n })\n }\n\n // On the server, stores are ephemeral by default so SSR does not retain them in a long-lived runtime.\n // The exception is a runtime that is already bound to the requested site version & locale, where we\n // can safely reuse the store across multiple root regions and benefit from the host API client's\n // in-memory cache.\n //\n // On the client, stores are reference-counted by site version so multiple root regions can share a store\n // instance, which preserves the pre-v0.17 per-site-version store behavior without requiring a separate\n // runtime per root.\n const usePersistentStore = this.shouldUsePersistentStore(key)\n return usePersistentStore ? this.activeStores.getOrCreate(key, createStore) : createStore()\n }\n\n retainStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to retain an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.retain(key, store)) {\n store.startBreakpointWatch()\n }\n }\n\n releaseStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to release an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.release(key, store)) {\n store.stopBreakpointWatch()\n }\n }\n\n copyElementTree(\n elementTree: ElementData,\n replacementContext: SerializableReplacementContext,\n ): Element {\n return copyElementTree(this.protoStore.getState(), elementTree, replacementContext)\n }\n\n getBreakpoints(): Breakpoints {\n return getBreakpoints(this.protoStore.getState())\n }\n\n get graphqlApiEndpoint(): string {\n return new URL('graphql', this.apiOrigin).href\n }\n\n private createApiResourcesClient(preloadedState: {\n siteVersion: SiteVersion | null\n locale: string | undefined\n }) {\n return new MakeswiftHostApiClient({\n fetch: this.fetch,\n preloadedState,\n })\n }\n\n private shouldUsePersistentStore(key: string): boolean {\n // don't persist stores on the server unless the runtime instance is bound to a request\n // and the requested store matches the request's site version and locale\n return !isServer() || (this.requestKey !== undefined && storeCacheKey(this.requestKey) === key)\n }\n}\n\nconst storeCacheKey = ({ siteVersion, locale }: StoreKey): string =>\n `${siteVersionTag(siteVersion)}/${locale ?? 'default'}`\n\nconst siteVersionTag = (siteVersion: SiteVersion | null): string =>\n siteVersion?.version ?? VERSION_TAG_LIVE\n\nfunction validateOrigin(url: string, name: string): string {\n try {\n return new URL(url).origin\n } catch {\n throw new Error(`The Makeswift runtime received an invalid \\`${name}\\` parameter: \"${url}\".`)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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AW;AAE1B,SAAS,eAAe,KAAa,MAAsB;AACzD,MAAI;AACF,WAAO,IAAI,IAAI,GAAG,EAAE;AAAA,EACtB,QAAQ;AACN,UAAM,IAAI,MAAM,+CAA+C,IAAI,kBAAkB,GAAG,IAAI;AAAA,EAC9F;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/react/runtime-core.ts"],"sourcesContent":["import { type SerializableReplacementContext } from '@makeswift/controls'\n\nimport { HostApiResourcesClient } from '../../api/host-api-resources-client'\nimport { type HttpFetch } from '../../state/api-client/fetch-api-resource'\nimport { type SiteVersion } from '../../api/site-version'\n\nimport {\n Breakpoints,\n BreakpointsInput,\n parseBreakpointsInput,\n} from '../../state/modules/breakpoints'\n\nimport { copyElementTree } from '../../state/ops/copy-element-tree'\n\nimport { getBreakpoints, type Element, type ElementData } from '../../state/read-only-state'\nimport {\n configureProtoStore,\n configureReadWriteStore,\n type ProtoStore,\n type Store,\n} from '../../state/store'\n\nimport { RefCountedMap } from '../../utils/ref-counted-map'\nimport { isServer } from '../../utils/is-server'\n\nexport type StoreKey = {\n siteVersion: SiteVersion | null\n locale: string | undefined\n}\n\nconst VERSION_TAG_LIVE = 'ref:live'\n\nexport class RuntimeCore {\n // The unowned entry TTL affects performance, not correctness. The TTL controls how long an unretained store stays\n // in the map. If an entry expires and is removed from the map before React commits, the store remains retained\n // via `<StoreContext.Provider>`. The only impact is that future lookups will create a new store instance instead of\n // reusing the existing one, reducing cache efficiency.\n private readonly activeStores = new RefCountedMap<string | null, Store>({\n unownedEntryTtlMs: 1000,\n // Checking on retain/release is sufficient on the client, and we don't need to check on get on the server\n // as the only scenario in which we add the store to the map is when the runtime is already bound to the\n // requested site version, which should be the only site version for which the store is requested\n ttlCheck: RefCountedMap.TTLCheck.ON_RETAIN | RefCountedMap.TTLCheck.ON_RELEASE,\n })\n\n readonly protoStore: ProtoStore\n readonly appOrigin: string\n readonly apiOrigin: string\n readonly requestKey: StoreKey | undefined\n readonly fetch: HttpFetch\n\n constructor({\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n breakpoints,\n requestKey,\n fetch,\n }: {\n appOrigin?: string\n apiOrigin?: string\n breakpoints?: BreakpointsInput\n requestKey?: StoreKey\n fetch: HttpFetch\n }) {\n this.appOrigin = validateOrigin(appOrigin, 'appOrigin')\n this.apiOrigin = validateOrigin(apiOrigin, 'apiOrigin')\n this.requestKey = requestKey\n this.fetch = fetch\n\n this.protoStore = configureProtoStore({\n name: 'Runtime proto-store',\n breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : undefined,\n })\n }\n\n getOrCreateStore({ siteVersion, locale }: StoreKey): Store {\n const key = storeCacheKey({ siteVersion, locale })\n\n const createStore = () => {\n // API resources client includes an in-memory cache of the site's resources and thus also has to be versioned\n const apiResourcesClient = this.createApiResourcesClient({ siteVersion, locale })\n\n // TODO: we need to decouple editability from the site version; specifically, previewing\n // a draft version of the site should not lead to switching to the read-write state\n const isReadOnly = siteVersion == null\n\n return configureReadWriteStore({\n name: `Runtime read-write store (site version: ${key})`,\n appOrigin: this.appOrigin,\n apiResourcesClient,\n preloadedState: { ...this.protoStore.getState(), siteVersion, isReadOnly, locale },\n })\n }\n\n // On the server, stores are ephemeral by default so SSR does not retain them in a long-lived runtime.\n // The exception is a runtime that is already bound to the requested site version & locale, where we\n // can safely reuse the store across multiple root regions and benefit from the host API client's\n // in-memory cache.\n //\n // On the client, stores are reference-counted by site version so multiple root regions can share a store\n // instance, which preserves the pre-v0.17 per-site-version store behavior without requiring a separate\n // runtime per root.\n const usePersistentStore = this.shouldUsePersistentStore(key)\n return usePersistentStore ? this.activeStores.getOrCreate(key, createStore) : createStore()\n }\n\n retainStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to retain an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.retain(key, store)) {\n store.startBreakpointWatch()\n }\n }\n\n releaseStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to release an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.release(key, store)) {\n store.stopBreakpointWatch()\n }\n }\n\n copyElementTree(\n elementTree: ElementData,\n replacementContext: SerializableReplacementContext,\n ): Element {\n return copyElementTree(this.protoStore.getState(), elementTree, replacementContext)\n }\n\n getBreakpoints(): Breakpoints {\n return getBreakpoints(this.protoStore.getState())\n }\n\n get graphqlApiEndpoint(): string {\n return new URL('graphql', this.apiOrigin).href\n }\n\n private createApiResourcesClient(preloadedState: {\n siteVersion: SiteVersion | null\n locale: string | undefined\n }) {\n return new HostApiResourcesClient({\n fetch: this.fetch,\n preloadedState,\n })\n }\n\n private shouldUsePersistentStore(key: string): boolean {\n // don't persist stores on the server unless the runtime instance is bound to a request\n // and the requested store matches the request's site version and locale\n return !isServer() || (this.requestKey !== undefined && storeCacheKey(this.requestKey) === key)\n }\n}\n\nconst storeCacheKey = ({ siteVersion, locale }: StoreKey): string =>\n `${siteVersionTag(siteVersion)}/${locale ?? 'default'}`\n\nconst siteVersionTag = (siteVersion: SiteVersion | null): string =>\n siteVersion?.version ?? VERSION_TAG_LIVE\n\nfunction validateOrigin(url: string, name: string): string {\n try {\n return new URL(url).origin\n } catch {\n throw new Error(`The Makeswift runtime received an invalid \\`${name}\\` parameter: \"${url}\".`)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uCAAuC;AAIvC,yBAIO;AAEP,+BAAgC;AAEhC,6BAA+D;AAC/D,mBAKO;AAEP,6BAA8B;AAC9B,uBAAyB;AAOzB,MAAM,mBAAmB;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,EAKN,eAAe,IAAI,qCAAoC;AAAA,IACtE,mBAAmB;AAAA;AAAA;AAAA;AAAA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8
- const IntrospectedResourcesQuery = (
8
+ const UnversionedResourcesQuery = (
9
9
  /* GraphQL */
10
10
  `
11
- query IntrospectedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {
11
+ query UnversionedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {
12
12
  files(ids: $fileIds) {
13
13
  ...File
14
14
  }
@@ -110,10 +110,10 @@ export {
110
110
  CreateTableRecordMutation,
111
111
  FileQuery,
112
112
  GlobalElementQuery,
113
- IntrospectedResourcesQuery,
114
113
  SwatchQuery,
115
114
  TableQuery,
116
115
  TypographiesQuery,
117
- TypographyQuery
116
+ TypographyQuery,
117
+ UnversionedResourcesQuery
118
118
  };
119
119
  //# sourceMappingURL=queries.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/api/graphql/documents/queries.ts"],"sourcesContent":["import {\n FileFragment,\n GlobalElementFragment,\n SwatchFragment,\n TableFragment,\n TypographyFragment,\n} from './fragments'\n\nexport const IntrospectedResourcesQuery = /* GraphQL */ `\n query IntrospectedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {\n files(ids: $fileIds) {\n ...File\n }\n\n tables(ids: $tableIds) {\n ...Table\n }\n }\n\n ${FileFragment}\n ${TableFragment}\n`\n\nexport const SwatchQuery = /* GraphQL */ `\n query Swatch($swatchId: ID!) {\n swatch(id: $swatchId) {\n ...Swatch\n }\n }\n\n ${SwatchFragment}\n`\n\nexport const FileQuery = /* GraphQL */ `\n query File($fileId: ID!) {\n file(id: $fileId) {\n ...File\n }\n }\n\n ${FileFragment}\n`\n\nexport const TypographyQuery = /* GraphQL */ `\n query Typography($typographyId: ID!) {\n typography(id: $typographyId) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const TableQuery = /* GraphQL */ `\n query Table($tableId: ID!) {\n table(id: $tableId) {\n ...Table\n }\n }\n\n ${TableFragment}\n`\n\nexport const TypographiesQuery = /* GraphQL */ `\n query Typographies($typographyIds: [ID!]!) {\n typographies(ids: $typographyIds) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const GlobalElementQuery = /* GraphQL */ `\n query GlobalElement($globalElementId: ID!) {\n globalElement(id: $globalElementId) {\n ...GlobalElement\n }\n }\n\n ${GlobalElementFragment}\n`\n\nexport const CreateTableRecordMutation = /* GraphQL */ `\n mutation CreateTableRecord($input: CreateTableRecordInput!) {\n createTableRecord(input: $input) {\n tableRecord {\n id\n }\n }\n }\n`\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM;AAAA;AAAA,EAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWpD,YAAY;AAAA,IACZ,aAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOrC,cAAc;AAAA;AAAA;AAGX,MAAM;AAAA;AAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOnC,YAAY;AAAA;AAAA;AAGT,MAAM;AAAA;AAAA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOzC,kBAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOpC,aAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO3C,kBAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO5C,qBAAqB;AAAA;AAAA;AAGlB,MAAM;AAAA;AAAA,EAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/api/graphql/documents/queries.ts"],"sourcesContent":["import {\n FileFragment,\n GlobalElementFragment,\n SwatchFragment,\n TableFragment,\n TypographyFragment,\n} from './fragments'\n\nexport const UnversionedResourcesQuery = /* GraphQL */ `\n query UnversionedResources($fileIds: [ID!]!, $tableIds: [ID!]!) {\n files(ids: $fileIds) {\n ...File\n }\n\n tables(ids: $tableIds) {\n ...Table\n }\n }\n\n ${FileFragment}\n ${TableFragment}\n`\n\nexport const SwatchQuery = /* GraphQL */ `\n query Swatch($swatchId: ID!) {\n swatch(id: $swatchId) {\n ...Swatch\n }\n }\n\n ${SwatchFragment}\n`\n\nexport const FileQuery = /* GraphQL */ `\n query File($fileId: ID!) {\n file(id: $fileId) {\n ...File\n }\n }\n\n ${FileFragment}\n`\n\nexport const TypographyQuery = /* GraphQL */ `\n query Typography($typographyId: ID!) {\n typography(id: $typographyId) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const TableQuery = /* GraphQL */ `\n query Table($tableId: ID!) {\n table(id: $tableId) {\n ...Table\n }\n }\n\n ${TableFragment}\n`\n\nexport const TypographiesQuery = /* GraphQL */ `\n query Typographies($typographyIds: [ID!]!) {\n typographies(ids: $typographyIds) {\n ...Typography\n }\n }\n\n ${TypographyFragment}\n`\n\nexport const GlobalElementQuery = /* GraphQL */ `\n query GlobalElement($globalElementId: ID!) {\n globalElement(id: $globalElementId) {\n ...GlobalElement\n }\n }\n\n ${GlobalElementFragment}\n`\n\nexport const CreateTableRecordMutation = /* GraphQL */ `\n mutation CreateTableRecord($input: CreateTableRecordInput!) {\n createTableRecord(input: $input) {\n tableRecord {\n id\n }\n }\n }\n`\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM;AAAA;AAAA,EAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWnD,YAAY;AAAA,IACZ,aAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOrC,cAAc;AAAA;AAAA;AAGX,MAAM;AAAA;AAAA,EAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOnC,YAAY;AAAA;AAAA;AAGT,MAAM;AAAA;AAAA,EAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOzC,kBAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOpC,aAAa;AAAA;AAAA;AAGV,MAAM;AAAA;AAAA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO3C,kBAAkB;AAAA;AAAA;AAGf,MAAM;AAAA;AAAA,EAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO5C,qBAAqB;AAAA;AAAA;AAGlB,MAAM;AAAA;AAAA,EAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/api/graphql/generated/types.ts"],"sourcesContent":["export type Maybe<T> = T | null\nexport type InputMaybe<T> = Maybe<T>\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\ntype Scalars = {\n ID: string\n JSON: Json\n Locale: string\n}\n\nexport type CreateTableRecordInput = {\n data: CreateTableRecordInputData\n}\n\nexport type CreateTableRecordInputData = {\n columns: Array<CreateTableRecordInputDataColumn>\n tableId?: InputMaybe<Scalars['ID']>\n}\n\nexport type CreateTableRecordInputDataColumn = {\n columnId: Scalars['ID']\n data: Scalars['JSON']\n}\n\nexport const SnippetLocation = {\n Body: 'BODY',\n Head: 'HEAD',\n} as const\n\nexport type SnippetLocation = (typeof SnippetLocation)[keyof typeof SnippetLocation]\n\nexport type SwatchFragment = {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n}\n\nexport type FileFragment = {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n}\n\nexport type TypographyFragment = {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n}\n\nexport type PagePathnameSliceFragment = {\n __typename: 'PagePathnameSlice'\n id: string\n pathname: string\n}\n\nexport type GlobalElementFragment = { __typename: 'GlobalElement'; id: string; data: Json }\n\nexport type LocalizedGlobalElementFragment = {\n __typename: 'LocalizedGlobalElement'\n id: string\n data: Json\n}\n\nexport type TableFragment = {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n}\n\nexport type SnippetFragment = {\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n}\n\nexport type PageFragment = {\n __typename: 'Page'\n id: string\n snippets: Array<{\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n }>\n}\n\nexport type SiteFragment = {\n __typename: 'Site'\n id: string\n googleFonts: {\n edges: Array<{\n activeVariants: Array<{ specifier: string }>\n node: { family: string; variants: Array<{ specifier: string }> }\n } | null>\n }\n}\n\nexport type IntrospectedResourcesQueryVariables = Exact<{\n fileIds: Array<Scalars['ID']> | Scalars['ID']\n tableIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type IntrospectedResourcesQueryResult = {\n files: Array<{\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null>\n tables: Array<{\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null>\n}\n\nexport type SwatchQueryVariables = Exact<{\n swatchId: Scalars['ID']\n}>\n\nexport type SwatchQueryResult = {\n swatch: {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n } | null\n}\n\nexport type FileQueryVariables = Exact<{\n fileId: Scalars['ID']\n}>\n\nexport type FileQueryResult = {\n file: {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null\n}\n\nexport type TypographyQueryVariables = Exact<{\n typographyId: Scalars['ID']\n}>\n\nexport type TypographyQueryResult = {\n typography: {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null\n}\n\nexport type TableQueryVariables = Exact<{\n tableId: Scalars['ID']\n}>\n\nexport type TableQueryResult = {\n table: {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null\n}\n\nexport type TypographiesQueryVariables = Exact<{\n typographyIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type TypographiesQueryResult = {\n typographies: Array<{\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null>\n}\n\nexport type GlobalElementQueryVariables = Exact<{\n globalElementId: Scalars['ID']\n}>\n\nexport type GlobalElementQueryResult = {\n globalElement: { __typename: 'GlobalElement'; id: string; data: Json } | null\n}\n\nexport type CreateTableRecordMutationVariables = Exact<{\n input: CreateTableRecordInput\n}>\n\nexport type CreateTableRecordMutationResult = { createTableRecord: { tableRecord: { id: string } } }\n"],"mappings":"AA0BO,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,MAAM;AACR;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/api/graphql/generated/types.ts"],"sourcesContent":["export type Maybe<T> = T | null\nexport type InputMaybe<T> = Maybe<T>\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\ntype Scalars = {\n ID: string\n JSON: Json\n Locale: string\n}\n\nexport type CreateTableRecordInput = {\n data: CreateTableRecordInputData\n}\n\nexport type CreateTableRecordInputData = {\n columns: Array<CreateTableRecordInputDataColumn>\n tableId?: InputMaybe<Scalars['ID']>\n}\n\nexport type CreateTableRecordInputDataColumn = {\n columnId: Scalars['ID']\n data: Scalars['JSON']\n}\n\nexport const SnippetLocation = {\n Body: 'BODY',\n Head: 'HEAD',\n} as const\n\nexport type SnippetLocation = (typeof SnippetLocation)[keyof typeof SnippetLocation]\n\nexport type SwatchFragment = {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n}\n\nexport type FileFragment = {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n}\n\nexport type TypographyFragment = {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n}\n\nexport type PagePathnameSliceFragment = {\n __typename: 'PagePathnameSlice'\n id: string\n pathname: string\n}\n\nexport type GlobalElementFragment = { __typename: 'GlobalElement'; id: string; data: Json }\n\nexport type LocalizedGlobalElementFragment = {\n __typename: 'LocalizedGlobalElement'\n id: string\n data: Json\n}\n\nexport type TableFragment = {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n}\n\nexport type SnippetFragment = {\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n}\n\nexport type PageFragment = {\n __typename: 'Page'\n id: string\n snippets: Array<{\n __typename: 'Snippet'\n id: string\n name: string\n code: string\n cleanup: string | null\n location: SnippetLocation\n shouldAddToNewPages: boolean\n liveEnabled: boolean\n builderEnabled: boolean\n }>\n}\n\nexport type SiteFragment = {\n __typename: 'Site'\n id: string\n googleFonts: {\n edges: Array<{\n activeVariants: Array<{ specifier: string }>\n node: { family: string; variants: Array<{ specifier: string }> }\n } | null>\n }\n}\n\nexport type UnversionedResourcesQueryVariables = Exact<{\n fileIds: Array<Scalars['ID']> | Scalars['ID']\n tableIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type UnversionedResourcesQueryResult = {\n files: Array<{\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null>\n tables: Array<{\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null>\n}\n\nexport type SwatchQueryVariables = Exact<{\n swatchId: Scalars['ID']\n}>\n\nexport type SwatchQueryResult = {\n swatch: {\n __typename: 'Swatch'\n id: string\n hue: number\n saturation: number\n lightness: number\n } | null\n}\n\nexport type FileQueryVariables = Exact<{\n fileId: Scalars['ID']\n}>\n\nexport type FileQueryResult = {\n file: {\n __typename: 'File'\n id: string\n name: string\n extension: string | null\n publicUrl: string\n dimensions: { width: number; height: number } | null\n } | null\n}\n\nexport type TypographyQueryVariables = Exact<{\n typographyId: Scalars['ID']\n}>\n\nexport type TypographyQueryResult = {\n typography: {\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null\n}\n\nexport type TableQueryVariables = Exact<{\n tableId: Scalars['ID']\n}>\n\nexport type TableQueryResult = {\n table: {\n __typename: 'Table'\n id: string\n name: string\n columns: Array<\n | { __typename: 'CheckboxTableColumn'; id: string; name: string }\n | { __typename: 'EmailTableColumn'; id: string; name: string }\n | { __typename: 'LongTextTableColumn'; id: string; name: string }\n | {\n __typename: 'MultipleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'NumberTableColumn'; id: string; name: string }\n | { __typename: 'PhoneNumberTableColumn'; id: string; name: string }\n | { __typename: 'SingleLineTextTableColumn'; id: string; name: string }\n | {\n __typename: 'SingleSelectTableColumn'\n id: string\n name: string\n options: Array<{ id: string; name: string }>\n }\n | { __typename: 'URLTableColumn'; id: string; name: string }\n >\n } | null\n}\n\nexport type TypographiesQueryVariables = Exact<{\n typographyIds: Array<Scalars['ID']> | Scalars['ID']\n}>\n\nexport type TypographiesQueryResult = {\n typographies: Array<{\n __typename: 'Typography'\n id: string\n name: string\n style: Array<{\n deviceId: string\n value: {\n fontFamily: string | null\n lineHeight: number | null\n letterSpacing: number | null\n fontWeight: number | null\n textAlign: string | null\n uppercase: boolean | null\n underline: boolean | null\n strikethrough: boolean | null\n italic: boolean | null\n fontSize: { value: number | null; unit: string | null } | null\n color: { swatchId: string | null; alpha: number | null } | null\n }\n }>\n } | null>\n}\n\nexport type GlobalElementQueryVariables = Exact<{\n globalElementId: Scalars['ID']\n}>\n\nexport type GlobalElementQueryResult = {\n globalElement: { __typename: 'GlobalElement'; id: string; data: Json } | null\n}\n\nexport type CreateTableRecordMutationVariables = Exact<{\n input: CreateTableRecordInput\n}>\n\nexport type CreateTableRecordMutationResult = { createTableRecord: { tableRecord: { id: string } } }\n"],"mappings":"AA0BO,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,MAAM;AACR;","names":[]}
@@ -1,13 +1,40 @@
1
1
  import { GraphQLClient } from "./graphql/client";
2
- import { CreateTableRecordMutation } from "./graphql/documents";
2
+ import {
3
+ CreateTableRecordMutation,
4
+ FileQuery,
5
+ TableQuery,
6
+ UnversionedResourcesQuery
7
+ } from "./graphql/documents";
3
8
  class MakeswiftGraphQLApiClient {
4
9
  graphqlClient;
5
10
  constructor({ endpoint }) {
6
- this.graphqlClient = new GraphQLClient(endpoint);
11
+ this.graphqlClient = new GraphQLClient(endpoint, {
12
+ "makeswift-runtime-version": "0.28.7-canary.5"
13
+ });
7
14
  }
8
15
  async createTableRecord(tableId, columns) {
9
16
  await this.graphqlClient.request(CreateTableRecordMutation, { input: { data: { tableId, columns } } });
10
17
  }
18
+ async getUnversionedResources({
19
+ fileIds,
20
+ tableIds
21
+ }) {
22
+ return await this.graphqlClient.request(UnversionedResourcesQuery, { fileIds, tableIds });
23
+ }
24
+ async getFile(fileId) {
25
+ const result = await this.graphqlClient.request(
26
+ FileQuery,
27
+ { fileId }
28
+ );
29
+ return result.file;
30
+ }
31
+ async getTable(tableId) {
32
+ const result = await this.graphqlClient.request(
33
+ TableQuery,
34
+ { tableId }
35
+ );
36
+ return result.table;
37
+ }
11
38
  }
12
39
  export {
13
40
  MakeswiftGraphQLApiClient
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/api/graphql-api-client.ts"],"sourcesContent":["import { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport class MakeswiftGraphQLApiClient {\n readonly graphqlClient: GraphQLClient\n\n constructor({ endpoint }: { endpoint: string }) {\n this.graphqlClient = new GraphQLClient(endpoint)\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AAMnC,MAAM,0BAA0B;AAAA,EAC5B;AAAA,EAET,YAAY,EAAE,SAAS,GAAyB;AAC9C,SAAK,gBAAgB,IAAI,cAAc,QAAQ;AAAA,EACjD;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,2BAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/api/graphql-api-client.ts"],"sourcesContent":["import { GraphQLClient } from './graphql/client'\n\nimport {\n CreateTableRecordMutation,\n FileQuery,\n TableQuery,\n UnversionedResourcesQuery,\n} from './graphql/documents'\n\nimport {\n type CreateTableRecordMutationResult,\n type CreateTableRecordMutationVariables,\n type FileQueryResult,\n type FileQueryVariables,\n type TableQueryResult,\n type TableQueryVariables,\n type UnversionedResourcesQueryResult,\n type UnversionedResourcesQueryVariables,\n} from './graphql/generated/types'\n\nimport { type File, type Table } from './types'\n\nexport class MakeswiftGraphQLApiClient {\n readonly graphqlClient: GraphQLClient\n\n constructor({ endpoint }: { endpoint: string }) {\n this.graphqlClient = new GraphQLClient(endpoint, {\n 'makeswift-runtime-version': PACKAGE_VERSION,\n })\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n async getUnversionedResources({\n fileIds,\n tableIds,\n }: UnversionedResourcesQueryVariables): Promise<UnversionedResourcesQueryResult> {\n return await this.graphqlClient.request<\n UnversionedResourcesQueryResult,\n UnversionedResourcesQueryVariables\n >(UnversionedResourcesQuery, { fileIds, tableIds })\n }\n\n async getFile(fileId: string): Promise<File | null> {\n const result = await this.graphqlClient.request<FileQueryResult, FileQueryVariables>(\n FileQuery,\n { fileId },\n )\n\n return result.file\n }\n\n async getTable(tableId: string): Promise<Table | null> {\n const result = await this.graphqlClient.request<TableQueryResult, TableQueryVariables>(\n TableQuery,\n { tableId },\n )\n\n return result.table\n }\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeA,MAAM,0BAA0B;AAAA,EAC5B;AAAA,EAET,YAAY,EAAE,SAAS,GAAyB;AAC9C,SAAK,gBAAgB,IAAI,cAAc,UAAU;AAAA,MAC/C,6BAA6B;AAAA,IAC/B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,2BAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,MAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF,GAAiF;AAC/E,WAAO,MAAM,KAAK,cAAc,QAG9B,2BAA2B,EAAE,SAAS,SAAS,CAAC;AAAA,EACpD;AAAA,EAEA,MAAM,QAAQ,QAAsC;AAClD,UAAM,SAAS,MAAM,KAAK,cAAc;AAAA,MACtC;AAAA,MACA,EAAE,OAAO;AAAA,IACX;AAEA,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,SAAS,SAAwC;AACrD,UAAM,SAAS,MAAM,KAAK,cAAc;AAAA,MACtC;AAAA,MACA,EAAE,QAAQ;AAAA,IACZ;AAEA,WAAO,OAAO;AAAA,EAChB;AACF;","names":[]}
@@ -5,7 +5,7 @@ import {
5
5
  } from "./types";
6
6
  import { ApiResourcesClient } from "./api-resources-client";
7
7
  import { CacheData } from "./api-resources-client";
8
- class MakeswiftHostApiClient extends ApiResourcesClient {
8
+ class HostApiResourcesClient extends ApiResourcesClient {
9
9
  fetch;
10
10
  constructor({
11
11
  fetch,
@@ -54,6 +54,6 @@ class MakeswiftHostApiClient extends ApiResourcesClient {
54
54
  }
55
55
  export {
56
56
  CacheData,
57
- MakeswiftHostApiClient
57
+ HostApiResourcesClient
58
58
  };
59
- //# sourceMappingURL=client.js.map
59
+ //# sourceMappingURL=host-api-resources-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/host-api-resources-client.ts"],"sourcesContent":["import { type State as ApiClientState } from '../state/api-client/state'\nimport { type HttpFetch, fetchAPIResource } from '../state/api-client/fetch-api-resource'\nimport { configureClientStore } from '../state/api-client/client-store'\n\nimport {\n type File,\n type GlobalElement,\n type LocalizedGlobalElement,\n type PagePathnameSlice,\n type Swatch,\n type Table,\n type Typography,\n APIResourceType,\n} from './types'\n\nimport { ApiResourcesClient } from './api-resources-client'\n\nexport { CacheData } from './api-resources-client'\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class HostApiResourcesClient extends ApiResourcesClient {\n readonly fetch: HttpFetch\n\n constructor({\n fetch,\n preloadedState,\n }: {\n fetch: HttpFetch\n preloadedState: Partial<ApiClientState>\n }) {\n super({\n store: configureClientStore({ preloadedState }),\n })\n\n this.fetch = fetch\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch))\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.File, fileId, this.fetch))\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.GlobalElement, globalElementId, this.fetch),\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.LocalizedGlobalElement, globalElementId, this.fetch, locale),\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.PagePathnameSlice, pageId, this.fetch, locale),\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.Table, tableId, this.fetch))\n }\n}\n"],"mappings":"AACA,SAAyB,wBAAwB;AACjD,SAAS,4BAA4B;AAErC;AAAA,EAQE;AAAA,OACK;AAEP,SAAS,0BAA0B;AAEnC,SAAS,iBAAiB;AAqBnB,MAAM,+BAA+B,mBAAmB;AAAA,EACpD;AAAA,EAET,YAAY;AAAA,IACV;AAAA,IACA;AAAA,EACF,GAGG;AACD,UAAM;AAAA,MACJ,OAAO,qBAAqB,EAAE,eAAe,CAAC;AAAA,IAChD,CAAC;AAED,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO,MAAM,KAAK,MAAM,SAAS,iBAAiB,gBAAgB,QAAQ,UAAU,KAAK,KAAK,CAAC;AAAA,EACjG;AAAA,EAEA,MAAM,UAAU,QAAsC;AACpD,WAAO,MAAM,KAAK,MAAM,SAAS,iBAAiB,gBAAgB,MAAM,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC7F;AAAA,EAEA,MAAM,gBAAgB,cAAkD;AACtE,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,YAAY,cAAc,KAAK,KAAK;AAAA,IACvE;AAAA,EACF;AAAA,EAEA,MAAM,mBAAmB,iBAAwD;AAC/E,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,eAAe,iBAAiB,KAAK,KAAK;AAAA,IAC7E;AAAA,EACF;AAAA,EAEA,MAAM,4BAA4B;AAAA,IAChC;AAAA,IACA;AAAA,EACF,GAG2C;AACzC,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,wBAAwB,iBAAiB,KAAK,OAAO,MAAM;AAAA,IAC9F;AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB;AAAA,IAC3B;AAAA,IACA;AAAA,EACF,GAGsC;AACpC,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,mBAAmB,QAAQ,KAAK,OAAO,MAAM;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,MAAM,SAAS,iBAAiB,gBAAgB,OAAO,SAAS,KAAK,KAAK,CAAC;AAAA,EAC/F;AACF;","names":[]}
@@ -0,0 +1,152 @@
1
+ import * as Schema from "./schema";
2
+ class MakeswiftRestAPIClient {
3
+ apiKey;
4
+ apiOrigin;
5
+ constructor({ apiKey, apiOrigin }) {
6
+ this.apiKey = apiKey;
7
+ this.apiOrigin = apiOrigin;
8
+ }
9
+ async getSwatch(swatchId, siteVersion) {
10
+ const response = await this.fetch(`v3/swatches/${swatchId}`, siteVersion);
11
+ if (!response.ok) {
12
+ const failedBody = await failedResponseBody(response);
13
+ if (response.status !== 404) {
14
+ console.error(`Failed to get swatch '${swatchId}'`, {
15
+ response: failedBody,
16
+ siteVersion
17
+ });
18
+ }
19
+ return null;
20
+ }
21
+ const swatch = await response.json();
22
+ return swatch;
23
+ }
24
+ async getTypography(typographyId, siteVersion) {
25
+ const response = await this.fetch(`v3/typographies/${typographyId}`, siteVersion);
26
+ if (!response.ok) {
27
+ const failedBody = await failedResponseBody(response);
28
+ if (response.status !== 404) {
29
+ console.error(`Failed to get typography '${typographyId}'`, {
30
+ response: failedBody,
31
+ siteVersion
32
+ });
33
+ }
34
+ return null;
35
+ }
36
+ const typography = await response.json();
37
+ return typography;
38
+ }
39
+ async getGlobalElement(globalElementId, siteVersion) {
40
+ const response = await this.fetch(`v3/global-elements/${globalElementId}`, siteVersion);
41
+ if (!response.ok) {
42
+ const failedBody = await failedResponseBody(response);
43
+ if (response.status !== 404) {
44
+ console.error(`Failed to get global element '${globalElementId}'`, {
45
+ response: failedBody,
46
+ siteVersion
47
+ });
48
+ }
49
+ return null;
50
+ }
51
+ const globalElement = await response.json();
52
+ return globalElement;
53
+ }
54
+ async getLocalizedGlobalElement(globalElementId, locale, siteVersion) {
55
+ const response = await this.fetch(
56
+ `v3/localized-global-elements/${globalElementId}?locale=${locale}`,
57
+ siteVersion
58
+ );
59
+ if (!response.ok) {
60
+ const failedBody = await failedResponseBody(response);
61
+ if (response.status !== 404) {
62
+ console.error(`Failed to get localized global element '${globalElementId}'`, {
63
+ response: failedBody,
64
+ siteVersion,
65
+ locale
66
+ });
67
+ }
68
+ return null;
69
+ }
70
+ const localizedGlobalElement = await response.json();
71
+ return localizedGlobalElement;
72
+ }
73
+ async getPagePathnameSlices(pageIds, siteVersion, { locale }) {
74
+ if (pageIds.length === 0)
75
+ return [];
76
+ const url = new URL(`v3/page-pathname-slices/bulk`, this.apiOrigin);
77
+ pageIds.forEach((id) => url.searchParams.append("ids", id));
78
+ if (locale != null)
79
+ url.searchParams.set("locale", locale);
80
+ const response = await this.fetch(url.pathname + url.search, siteVersion);
81
+ if (!response.ok) {
82
+ console.error(`Failed to get page pathname slice(s) for ${pageIds.join(", ")}`, {
83
+ response: await failedResponseBody(response),
84
+ siteVersion,
85
+ locale
86
+ });
87
+ return [];
88
+ }
89
+ const json = await response.json();
90
+ const pagePathnameSlices = Schema.pagePathnameSlices.parse(json);
91
+ return pagePathnameSlices.map((pagePathnameSlice) => {
92
+ if (pagePathnameSlice == null)
93
+ return null;
94
+ return {
95
+ ...pagePathnameSlice,
96
+ id: pagePathnameSlice.basePageId,
97
+ localizedPathname: pagePathnameSlice.localizedPathname ?? null
98
+ };
99
+ });
100
+ }
101
+ async getPagePathnameSlice(pageId, siteVersion, { locale } = {}) {
102
+ const pagePathnameSlices = await this.getPagePathnameSlices([pageId], siteVersion, { locale });
103
+ return pagePathnameSlices.at(0) ?? null;
104
+ }
105
+ async fetch(path, siteVersion, init) {
106
+ const requestUrl = new URL(path, this.apiOrigin);
107
+ const requestHeaders = new Headers({
108
+ "x-api-key": this.apiKey,
109
+ "makeswift-site-api-key": this.apiKey,
110
+ "makeswift-runtime-version": "0.28.7-canary.5"
111
+ });
112
+ if (siteVersion?.token) {
113
+ requestUrl.searchParams.set("version", siteVersion.version);
114
+ requestHeaders.set("makeswift-preview-token", siteVersion.token);
115
+ }
116
+ if (init?.headers) {
117
+ new Headers(init.headers).forEach((value, key) => {
118
+ requestHeaders.set(key, value);
119
+ });
120
+ }
121
+ const response = await fetch(requestUrl.toString(), {
122
+ ...init,
123
+ headers: requestHeaders,
124
+ ...siteVersion != null ? { cache: "no-store" } : {},
125
+ ...this.fetchOptions(siteVersion)
126
+ });
127
+ return response;
128
+ }
129
+ /**
130
+ * Override this method to provide additional fetch options, e.g. revalidation, cache tags, etc.
131
+ */
132
+ fetchOptions(_siteVersion) {
133
+ return {};
134
+ }
135
+ }
136
+ async function failedResponseBody(response) {
137
+ try {
138
+ const text = await response.text();
139
+ try {
140
+ return JSON.parse(text);
141
+ } catch {
142
+ return text;
143
+ }
144
+ } catch (e) {
145
+ return `Failed to extract response body: ${e}`;
146
+ }
147
+ }
148
+ export {
149
+ MakeswiftRestAPIClient,
150
+ failedResponseBody
151
+ };
152
+ //# sourceMappingURL=rest-api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/rest-api-client.ts"],"sourcesContent":["import {\n type GlobalElement,\n type LocalizedGlobalElement,\n type PagePathnameSlice,\n type Swatch,\n type Typography,\n} from './types'\n\nimport { type SiteVersion } from './site-version'\nimport * as Schema from './schema'\n\nexport class MakeswiftRestAPIClient {\n readonly apiKey: string\n readonly apiOrigin: string\n\n constructor({ apiKey, apiOrigin }: { apiKey: string; apiOrigin: string }) {\n this.apiKey = apiKey\n this.apiOrigin = apiOrigin\n }\n\n async getSwatch(swatchId: string, siteVersion: SiteVersion | null): Promise<Swatch | null> {\n const response = await this.fetch(`v3/swatches/${swatchId}`, siteVersion)\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get swatch '${swatchId}'`, {\n response: failedBody,\n siteVersion,\n })\n }\n\n return null\n }\n\n const swatch = await response.json()\n\n return swatch\n }\n\n async getTypography(\n typographyId: string,\n siteVersion: SiteVersion | null,\n ): Promise<Typography | null> {\n const response = await this.fetch(`v3/typographies/${typographyId}`, siteVersion)\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get typography '${typographyId}'`, {\n response: failedBody,\n siteVersion,\n })\n }\n\n return null\n }\n\n const typography = await response.json()\n\n return typography\n }\n\n async getGlobalElement(\n globalElementId: string,\n siteVersion: SiteVersion | null,\n ): Promise<GlobalElement | null> {\n const response = await this.fetch(`v3/global-elements/${globalElementId}`, siteVersion)\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get global element '${globalElementId}'`, {\n response: failedBody,\n siteVersion,\n })\n }\n\n return null\n }\n\n const globalElement = await response.json()\n\n return globalElement\n }\n\n async getLocalizedGlobalElement(\n globalElementId: string,\n locale: string,\n siteVersion: SiteVersion | null,\n ): Promise<LocalizedGlobalElement | null> {\n const response = await this.fetch(\n `v3/localized-global-elements/${globalElementId}?locale=${locale}`,\n siteVersion,\n )\n\n if (!response.ok) {\n const failedBody = await failedResponseBody(response)\n if (response.status !== 404) {\n console.error(`Failed to get localized global element '${globalElementId}'`, {\n response: failedBody,\n siteVersion,\n locale,\n })\n }\n\n return null\n }\n\n const localizedGlobalElement = await response.json()\n\n return localizedGlobalElement\n }\n\n async getPagePathnameSlices(\n pageIds: string[],\n siteVersion: SiteVersion | null,\n { locale }: { locale?: string | null },\n ): Promise<(PagePathnameSlice | null)[]> {\n if (pageIds.length === 0) return []\n\n const url = new URL(`v3/page-pathname-slices/bulk`, this.apiOrigin)\n\n pageIds.forEach(id => url.searchParams.append('ids', id))\n if (locale != null) url.searchParams.set('locale', locale)\n\n const response = await this.fetch(url.pathname + url.search, siteVersion)\n\n if (!response.ok) {\n console.error(`Failed to get page pathname slice(s) for ${pageIds.join(', ')}`, {\n response: await failedResponseBody(response),\n siteVersion,\n locale,\n })\n\n return []\n }\n\n const json = await response.json()\n\n const pagePathnameSlices = Schema.pagePathnameSlices.parse(json)\n\n // We're mapping the basePageId to be the id, because we're still using the GraphQL\n // fragment as our APIResource. The id on the APIResource needs to match the pageId\n // so that we can find the corresponding page pathname slice when we call getPagePathnameSlice(pageId).\n // TODO: Update this once we move away from the GraphQL fragments.\n return pagePathnameSlices.map(pagePathnameSlice => {\n if (pagePathnameSlice == null) return null\n\n return {\n ...pagePathnameSlice,\n id: pagePathnameSlice.basePageId,\n localizedPathname: pagePathnameSlice.localizedPathname ?? null,\n }\n })\n }\n\n async getPagePathnameSlice(\n pageId: string,\n siteVersion: SiteVersion | null,\n { locale }: { locale?: string } = {},\n ): Promise<PagePathnameSlice | null> {\n const pagePathnameSlices = await this.getPagePathnameSlices([pageId], siteVersion, { locale })\n\n return pagePathnameSlices.at(0) ?? null\n }\n\n protected async fetch(\n path: string,\n siteVersion: SiteVersion | null,\n init?: RequestInit,\n ): Promise<Response> {\n const requestUrl = new URL(path, this.apiOrigin)\n\n const requestHeaders = new Headers({\n 'x-api-key': this.apiKey,\n 'makeswift-site-api-key': this.apiKey,\n 'makeswift-runtime-version': PACKAGE_VERSION,\n })\n\n if (siteVersion?.token) {\n requestUrl.searchParams.set('version', siteVersion.version)\n requestHeaders.set('makeswift-preview-token', siteVersion.token)\n }\n\n if (init?.headers) {\n new Headers(init.headers).forEach((value, key) => {\n requestHeaders.set(key, value)\n })\n }\n\n const response = await fetch(requestUrl.toString(), {\n ...init,\n headers: requestHeaders,\n ...(siteVersion != null ? { cache: 'no-store' } : {}),\n ...this.fetchOptions(siteVersion),\n })\n\n return response\n }\n\n /**\n * Override this method to provide additional fetch options, e.g. revalidation, cache tags, etc.\n */\n protected fetchOptions(_siteVersion: SiteVersion | null): Record<string, unknown> {\n return {}\n }\n}\n\n// This function attempts to consume the response body of a failed response, and\n// returns either the parsed JSON or raw text. This is useful for logging more\n// detailed error information when an API request fails.\n//\n// Cloudflare Worker Note: The Cloudflare Worker runtime has automatic deadlock\n// prevention (in the form of auto-cancelling responses) that triggers when too\n// many response bodies are unconsumed. This applies for error responses as\n// well. As such, in this client we use this function to consume the response\n// body whenever the request fails, even if we don't end up logging the body\n// itself, to avoid hitting the deadlock prevention.\nexport async function failedResponseBody(response: Response): Promise<unknown> {\n try {\n const text = await response.text()\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n } catch (e) {\n return `Failed to extract response body: ${e}`\n }\n}\n"],"mappings":"AASA,YAAY,YAAY;AAEjB,MAAM,uBAAuB;AAAA,EACzB;AAAA,EACA;AAAA,EAET,YAAY,EAAE,QAAQ,UAAU,GAA0C;AACxE,SAAK,SAAS;AACd,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,MAAM,UAAU,UAAkB,aAAyD;AACzF,UAAM,WAAW,MAAM,KAAK,MAAM,eAAe,QAAQ,IAAI,WAAW;AAExE,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,aAAa,MAAM,mBAAmB,QAAQ;AACpD,UAAI,SAAS,WAAW,KAAK;AAC3B,gBAAQ,MAAM,yBAAyB,QAAQ,KAAK;AAAA,UAClD,UAAU;AAAA,UACV;AAAA,QACF,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,MAAM,SAAS,KAAK;AAEnC,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cACJ,cACA,aA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AAO;AAC1D,qBAAe,IAAI,2BAA2B,YAAY,KAAK;AAAA,IACjE;AAEA,QAAI,MAAM,SAAS;AACjB,UAAI,QAAQ,KAAK,OAAO,EAAE,QAAQ,CAAC,OAAO,QAAQ;AAChD,uBAAe,IAAI,KAAK,KAAK;AAAA,MAC/B,CAAC;AAAA,IACH;AAEA,UAAM,WAAW,MAAM,MAAM,WAAW,SAAS,GAAG;AAAA,MAClD,GAAG;AAAA,MACH,SAAS;AAAA,MACT,GAAI,eAAe,OAAO,EAAE,OAAO,WAAW,IAAI,CAAC;AAAA,MACnD,GAAG,KAAK,aAAa,WAAW;AAAA,IAClC,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKU,aAAa,cAA2D;AAChF,WAAO,CAAC;AAAA,EACV;AACF;AAYA,eAAsB,mBAAmB,UAAsC;AAC7E,MAAI;AACF,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAI;AACF,aAAO,KAAK,MAAM,IAAI;AAAA,IACxB,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AACV,WAAO,oCAAoC,CAAC;AAAA,EAC9C;AACF;","names":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./page-pathname-slice";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/api/schema/index.ts"],"sourcesContent":["export * from './page-pathname-slice'\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ const pagePathnameSlices = z.array(
3
+ z.object({
4
+ id: z.string(),
5
+ basePageId: z.string(),
6
+ pathname: z.string(),
7
+ localizedPathname: z.string().optional(),
8
+ __typename: z.literal("PagePathnameSlice")
9
+ }).nullable()
10
+ );
11
+ export {
12
+ pagePathnameSlices
13
+ };
14
+ //# sourceMappingURL=page-pathname-slice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/api/schema/page-pathname-slice.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const pagePathnameSlices = z.array(\n z\n .object({\n id: z.string(),\n basePageId: z.string(),\n pathname: z.string(),\n localizedPathname: z.string().optional(),\n __typename: z.literal('PagePathnameSlice'),\n })\n .nullable(),\n)\n"],"mappings":"AAAA,SAAS,SAAS;AAEX,MAAM,qBAAqB,EAAE;AAAA,EAClC,EACG,OAAO;AAAA,IACN,IAAI,EAAE,OAAO;AAAA,IACb,YAAY,EAAE,OAAO;AAAA,IACrB,UAAU,EAAE,OAAO;AAAA,IACnB,mBAAmB,EAAE,OAAO,EAAE,SAAS;AAAA,IACvC,YAAY,EAAE,QAAQ,mBAAmB;AAAA,EAC3C,CAAC,EACA,SAAS;AACd;","names":[]}
@@ -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.7-canary.4",
11
+ version: "0.28.7-canary.5",
12
12
  interactionMode: true,
13
13
  clientSideNavigation: false,
14
14
  elementFromPoint: false,