@makeswift/runtime 0.26.4-canary.0 → 0.26.4-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/client.js +10 -3
- package/dist/cjs/api/client.js.map +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +3 -3
- package/dist/cjs/next/components/framework-provider/index.js +1 -1
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js +4 -3
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js +3 -13
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/host-api-client.js +2 -1
- package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
- package/dist/cjs/state/actions/internal/read-only-actions.js +15 -1
- package/dist/cjs/state/actions/internal/read-only-actions.js.map +1 -1
- package/dist/cjs/state/makeswift-api-client.js +32 -18
- package/dist/cjs/state/makeswift-api-client.js.map +1 -1
- package/dist/cjs/state/modules/locale.js +53 -0
- package/dist/cjs/state/modules/locale.js.map +1 -0
- package/dist/cjs/state/modules/site-version.js +50 -0
- package/dist/cjs/state/modules/site-version.js.map +1 -0
- package/dist/cjs/unstable-framework-support/index.js +2 -4
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/api/client.js +10 -3
- package/dist/esm/api/client.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +3 -3
- package/dist/esm/next/components/framework-provider/index.js +2 -5
- package/dist/esm/next/components/framework-provider/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/RuntimeProvider.js +4 -3
- package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js +2 -14
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/host-api-client.js +2 -1
- package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
- package/dist/esm/state/actions/internal/read-only-actions.js +13 -1
- package/dist/esm/state/actions/internal/read-only-actions.js.map +1 -1
- package/dist/esm/state/makeswift-api-client.js +32 -18
- package/dist/esm/state/makeswift-api-client.js.map +1 -1
- package/dist/esm/state/modules/locale.js +27 -0
- package/dist/esm/state/modules/locale.js.map +1 -0
- package/dist/esm/state/modules/site-version.js +24 -0
- package/dist/esm/state/modules/site-version.js.map +1 -0
- package/dist/esm/unstable-framework-support/index.js +2 -4
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/types/api/client.d.ts +3 -1
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts +2 -4
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
- package/dist/types/state/actions/index.d.ts +2 -0
- package/dist/types/state/actions/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/index.d.ts +2 -0
- package/dist/types/state/actions/internal/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/read-only-actions.d.ts +13 -1
- package/dist/types/state/actions/internal/read-only-actions.d.ts.map +1 -1
- package/dist/types/state/makeswift-api-client.d.ts +11 -2
- package/dist/types/state/makeswift-api-client.d.ts.map +1 -1
- package/dist/types/state/modules/locale.d.ts +6 -0
- package/dist/types/state/modules/locale.d.ts.map +1 -0
- package/dist/types/state/modules/site-version.d.ts +7 -0
- package/dist/types/state/modules/site-version.d.ts.map +1 -0
- package/dist/types/unstable-framework-support/index.d.ts +1 -1
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/api/client.js
CHANGED
|
@@ -33,6 +33,9 @@ __export(client_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(client_exports);
|
|
35
35
|
var MakeswiftApiClient = __toESM(require("../state/makeswift-api-client"));
|
|
36
|
+
var import_shared_api = require("../state/shared-api");
|
|
37
|
+
var import_read_only_actions = require("../state/actions/internal/read-only-actions");
|
|
38
|
+
var import_read_only_actions2 = require("../state/actions/internal/read-only-actions");
|
|
36
39
|
var import_types = require("./types");
|
|
37
40
|
var import_client = require("./graphql/client");
|
|
38
41
|
var import_documents = require("./graphql/documents");
|
|
@@ -53,15 +56,19 @@ class MakeswiftHostApiClient {
|
|
|
53
56
|
uri,
|
|
54
57
|
fetch,
|
|
55
58
|
cacheData,
|
|
56
|
-
locale
|
|
59
|
+
locale,
|
|
60
|
+
siteVersion
|
|
57
61
|
}) {
|
|
58
62
|
this.graphqlClient = new import_client.GraphQLClient(uri);
|
|
59
63
|
this.makeswiftApiClient = MakeswiftApiClient.configureStore({
|
|
60
|
-
serializedState: cacheData
|
|
61
|
-
defaultLocale: locale
|
|
64
|
+
serializedState: cacheData
|
|
62
65
|
});
|
|
63
66
|
this.fetch = fetch;
|
|
64
67
|
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
68
|
+
this.makeswiftApiClient.dispatch(
|
|
69
|
+
locale != null ? (0, import_shared_api.setLocale)(new Intl.Locale(locale)) : (0, import_read_only_actions.resetLocaleState)()
|
|
70
|
+
);
|
|
71
|
+
this.makeswiftApiClient.dispatch((0, import_read_only_actions2.setSiteVersion)(siteVersion));
|
|
65
72
|
}
|
|
66
73
|
readSwatch(swatchId) {
|
|
67
74
|
return MakeswiftApiClient.getAPIResource(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\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 MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n cacheData,\n locale,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n defaultLocale: locale,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\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.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n 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.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\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 readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAAoC;AACpC,mBAYO;AACP,oBAA8B;AAC9B,uBAA0C;AAQnC,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AAqBO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKG;AACD,SAAK,gBAAgB,IAAI,4BAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe;AAAA,MAC1D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UAAM,KAAK,cAAc,QAGvB,4CAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/api/client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\nimport { setLocale } from '../state/shared-api'\nimport { resetLocaleState } from '../state/actions/internal/read-only-actions'\nimport { setSiteVersion } from '../state/actions/internal/read-only-actions'\n\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\nimport { SiteVersion } from './site-version'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\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 MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n cacheData,\n locale,\n siteVersion,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n siteVersion: SiteVersion | null\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n\n this.makeswiftApiClient.dispatch(\n locale != null ? setLocale(new Intl.Locale(locale)) : resetLocaleState(),\n )\n\n this.makeswiftApiClient.dispatch(setSiteVersion(siteVersion))\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\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.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n 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.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\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 readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAoC;AACpC,wBAA0B;AAC1B,+BAAiC;AACjC,IAAAA,4BAA+B;AAE/B,mBAYO;AACP,oBAA8B;AAC9B,uBAA0C;AASnC,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AAqBO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAMG;AACD,SAAK,gBAAgB,IAAI,4BAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe;AAAA,MAC1D,iBAAiB;AAAA,IACnB,CAAC;AACD,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,mBAAmB;AAEzC,SAAK,mBAAmB;AAAA,MACtB,UAAU,WAAO,6BAAU,IAAI,KAAK,OAAO,MAAM,CAAC,QAAI,2CAAiB;AAAA,IACzE;AAEA,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M,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,6BAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;","names":["import_read_only_actions"]}
|
|
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
28
28
|
return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
29
29
|
}
|
|
30
30
|
return import_request_response.ApiResponse.json({
|
|
31
|
-
version: "0.26.4-canary.
|
|
31
|
+
version: "0.26.4-canary.1",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -212,7 +212,7 @@ Received "${apiKey}" instead.`
|
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
this.graphqlClient = new import_client.GraphQLClient(new URL("graphql", apiOrigin).href, {
|
|
215
|
-
"makeswift-runtime-version": "0.26.4-canary.
|
|
215
|
+
"makeswift-runtime-version": "0.26.4-canary.1"
|
|
216
216
|
});
|
|
217
217
|
this.runtime = runtime;
|
|
218
218
|
}
|
|
@@ -221,7 +221,7 @@ Received "${apiKey}" instead.`
|
|
|
221
221
|
const requestHeaders = new Headers({
|
|
222
222
|
"x-api-key": this.apiKey,
|
|
223
223
|
"makeswift-site-api-key": this.apiKey,
|
|
224
|
-
"makeswift-runtime-version": "0.26.4-canary.
|
|
224
|
+
"makeswift-runtime-version": "0.26.4-canary.1"
|
|
225
225
|
});
|
|
226
226
|
if (siteVersion?.token) {
|
|
227
227
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -668,7 +668,7 @@ Received "${apiKey}" instead.`
|
|
|
668
668
|
headers: {
|
|
669
669
|
"x-api-key": this.apiKey,
|
|
670
670
|
"makeswift-site-api-key": this.apiKey,
|
|
671
|
-
"makeswift-runtime-version": "0.26.4-canary.
|
|
671
|
+
"makeswift-runtime-version": "0.26.4-canary.1",
|
|
672
672
|
"content-type": "application/json"
|
|
673
673
|
},
|
|
674
674
|
body: JSON.stringify({ token }),
|
|
@@ -51,7 +51,7 @@ function FrameworkProvider({
|
|
|
51
51
|
...isPagesRouter ? import_pages_router.context : import_app_router.context,
|
|
52
52
|
Image: import_image.default,
|
|
53
53
|
Link: import_link.Link,
|
|
54
|
-
|
|
54
|
+
fetch: (url, init) => fetch(url, { ...init, next: { tags: [import_cache.MAKESWIFT_CACHE_TAG] } })
|
|
55
55
|
}),
|
|
56
56
|
[isPagesRouter]
|
|
57
57
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/components/framework-provider/index.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useMemo } from 'react'\nimport NextImage from 'next/image'\n\nimport { useIsPagesRouter } from '../../hooks/use-is-pages-router'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/components/framework-provider/index.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useMemo } from 'react'\nimport NextImage from 'next/image'\n\nimport { useIsPagesRouter } from '../../hooks/use-is-pages-router'\nimport { FrameworkContext } from '../../../runtimes/react/components/framework-context'\nimport { MAKESWIFT_CACHE_TAG } from '../../cache'\n\nimport { context as appRouterContext } from './app-router'\nimport { context as pagesRouterContext } from './pages-router'\nimport { Link } from './link'\n\nexport function FrameworkProvider({\n children,\n forcePagesRouter,\n}: PropsWithChildren<{ forcePagesRouter?: boolean }>) {\n const isPagesRouter = useIsPagesRouter() || forcePagesRouter\n const context = useMemo<FrameworkContext>(\n () => ({\n ...(isPagesRouter ? pagesRouterContext : appRouterContext),\n Image: NextImage,\n Link,\n fetch: (url, init) => fetch(url, { ...init, next: { tags: [MAKESWIFT_CACHE_TAG] } }),\n }),\n [isPagesRouter],\n )\n\n return <FrameworkContext.Provider value={context}>{children}</FrameworkContext.Provider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BS;AA1BT,mBAAgD;AAChD,mBAAsB;AAEtB,iCAAiC;AACjC,+BAAiC;AACjC,mBAAoC;AAEpC,wBAA4C;AAC5C,0BAA8C;AAC9C,kBAAqB;AAEd,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAsD;AACpD,QAAM,oBAAgB,6CAAiB,KAAK;AAC5C,QAAM,cAAU;AAAA,IACd,OAAO;AAAA,MACL,GAAI,gBAAgB,oBAAAA,UAAqB,kBAAAC;AAAA,MACzC,OAAO,aAAAC;AAAA,MACP;AAAA,MACA,OAAO,CAAC,KAAK,SAAS,MAAM,KAAK,EAAE,GAAG,MAAM,MAAM,EAAE,MAAM,CAAC,gCAAmB,EAAE,EAAE,CAAC;AAAA,IACrF;AAAA,IACA,CAAC,aAAa;AAAA,EAChB;AAEA,SAAO,4CAAC,0CAAiB,UAAjB,EAA0B,OAAO,SAAU,UAAS;AAC9D;","names":["pagesRouterContext","appRouterContext","NextImage"]}
|
|
@@ -50,14 +50,15 @@ function RuntimeProvider({
|
|
|
50
50
|
apiOrigin = "https://api.makeswift.com",
|
|
51
51
|
locale = void 0
|
|
52
52
|
}) {
|
|
53
|
-
const {
|
|
53
|
+
const { fetch } = (0, import_use_framework_context.useFrameworkContext)();
|
|
54
54
|
const client = (0, import_react.useMemo)(
|
|
55
55
|
() => new import_client.MakeswiftHostApiClient({
|
|
56
56
|
uri: new URL("graphql", apiOrigin).href,
|
|
57
57
|
locale,
|
|
58
|
-
fetch
|
|
58
|
+
fetch,
|
|
59
|
+
siteVersion: siteVersion ?? null
|
|
59
60
|
}),
|
|
60
|
-
[apiOrigin, locale, siteVersion,
|
|
61
|
+
[apiOrigin, locale, siteVersion, fetch]
|
|
61
62
|
);
|
|
62
63
|
const isPreview = siteVersion != null;
|
|
63
64
|
const StoreProvider = isPreview ? PreviewProvider : LiveProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/RuntimeProvider.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, useMemo, lazy } from 'react'\n\nimport { MakeswiftHostApiClient } from '../../../api/client'\nimport { ReactRuntimeContext } from '../hooks/use-react-runtime'\nimport { type ReactRuntimeCore } from '../react-runtime-core'\nimport { MakeswiftHostApiClientProvider } from '../host-api-client'\nimport { type SiteVersion } from '../../../api/site-version'\nimport { PreviewSwitcher } from './preview-switcher/preview-switcher'\nimport { useBuilderConnectionPing } from './hooks/use-builder-connection-ping'\nimport { useFrameworkContext } from './hooks/use-framework-context'\n\nconst LiveProvider = lazy(() => import('./LiveProvider'))\nconst PreviewProvider = lazy(() => import('./PreviewProvider'))\n\nexport function RuntimeProvider({\n children,\n runtime,\n siteVersion,\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n locale = undefined,\n}: {\n children: ReactNode\n runtime: ReactRuntimeCore\n siteVersion: SiteVersion | null | undefined\n apiOrigin?: string\n appOrigin?: string\n locale?: string\n}) {\n const {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/RuntimeProvider.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, useMemo, lazy } from 'react'\n\nimport { MakeswiftHostApiClient } from '../../../api/client'\nimport { ReactRuntimeContext } from '../hooks/use-react-runtime'\nimport { type ReactRuntimeCore } from '../react-runtime-core'\nimport { MakeswiftHostApiClientProvider } from '../host-api-client'\nimport { type SiteVersion } from '../../../api/site-version'\nimport { PreviewSwitcher } from './preview-switcher/preview-switcher'\nimport { useBuilderConnectionPing } from './hooks/use-builder-connection-ping'\nimport { useFrameworkContext } from './hooks/use-framework-context'\n\nconst LiveProvider = lazy(() => import('./LiveProvider'))\nconst PreviewProvider = lazy(() => import('./PreviewProvider'))\n\nexport function RuntimeProvider({\n children,\n runtime,\n siteVersion,\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n locale = undefined,\n}: {\n children: ReactNode\n runtime: ReactRuntimeCore\n siteVersion: SiteVersion | null | undefined\n apiOrigin?: string\n appOrigin?: string\n locale?: string\n}) {\n const { fetch } = useFrameworkContext()\n\n const client = useMemo(\n () =>\n new MakeswiftHostApiClient({\n uri: new URL('graphql', apiOrigin).href,\n locale,\n fetch,\n siteVersion: siteVersion ?? null,\n }),\n [apiOrigin, locale, siteVersion, fetch],\n )\n\n const isPreview = siteVersion != null\n const StoreProvider = isPreview ? PreviewProvider : LiveProvider\n\n useBuilderConnectionPing({ appOrigin })\n\n return (\n <ReactRuntimeContext.Provider value={runtime}>\n <MakeswiftHostApiClientProvider client={client}>\n <StoreProvider appOrigin={appOrigin}>\n {children}\n <PreviewSwitcher isPreview={isPreview} />\n </StoreProvider>\n </MakeswiftHostApiClientProvider>\n </ReactRuntimeContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoDQ;AAlDR,mBAAyC;AAEzC,oBAAuC;AACvC,+BAAoC;AAEpC,6BAA+C;AAE/C,8BAAgC;AAChC,yCAAyC;AACzC,mCAAoC;AAEpC,MAAM,mBAAe,mBAAK,MAAM,6CAAO,gBAAgB,GAAC;AACxD,MAAM,sBAAkB,mBAAK,MAAM,6CAAO,mBAAmB,GAAC;AAEvD,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AACX,GAOG;AACD,QAAM,EAAE,MAAM,QAAI,kDAAoB;AAEtC,QAAM,aAAS;AAAA,IACb,MACE,IAAI,qCAAuB;AAAA,MACzB,KAAK,IAAI,IAAI,WAAW,SAAS,EAAE;AAAA,MACnC;AAAA,MACA;AAAA,MACA,aAAa,eAAe;AAAA,IAC9B,CAAC;AAAA,IACH,CAAC,WAAW,QAAQ,aAAa,KAAK;AAAA,EACxC;AAEA,QAAM,YAAY,eAAe;AACjC,QAAM,gBAAgB,YAAY,kBAAkB;AAEpD,mEAAyB,EAAE,UAAU,CAAC;AAEtC,SACE,4CAAC,6CAAoB,UAApB,EAA6B,OAAO,SACnC,sDAAC,yDAA+B,QAC9B,uDAAC,iBAAc,WACZ;AAAA;AAAA,IACD,4CAAC,2CAAgB,WAAsB;AAAA,KACzC,GACF,GACF;AAEJ;","names":[]}
|
|
@@ -22,13 +22,11 @@ __export(framework_context_exports, {
|
|
|
22
22
|
DefaultHeadSnippet: () => DefaultHeadSnippet,
|
|
23
23
|
DefaultImage: () => DefaultImage,
|
|
24
24
|
DefaultLink: () => DefaultLink,
|
|
25
|
-
FrameworkContext: () => FrameworkContext
|
|
26
|
-
versionedFetch: () => versionedFetch
|
|
25
|
+
FrameworkContext: () => FrameworkContext
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(framework_context_exports);
|
|
29
28
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
29
|
var import_react = require("react");
|
|
31
|
-
var import_site_version = require("../../../api/site-version");
|
|
32
30
|
var import_HeadSnippet = require("./page/HeadSnippet");
|
|
33
31
|
const DefaultHead = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
34
32
|
const DefaultHeadSnippet = import_HeadSnippet.BaseHeadSnippet;
|
|
@@ -50,19 +48,12 @@ const DefaultImage = ({ priority, fill, style, ...props }) => /* @__PURE__ */ (0
|
|
|
50
48
|
const DefaultLink = (0, import_react.forwardRef)(
|
|
51
49
|
({ linkType, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { ...props, ref })
|
|
52
50
|
);
|
|
53
|
-
const versionedFetch = (siteVersion) => (url, init) => fetch(url, {
|
|
54
|
-
...init,
|
|
55
|
-
headers: {
|
|
56
|
-
...init?.headers,
|
|
57
|
-
...siteVersion != null ? { [import_site_version.ApiHandlerHeaders.SiteVersion]: (0, import_site_version.serializeSiteVersion)(siteVersion) } : {}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
51
|
const FrameworkContext = (0, import_react.createContext)({
|
|
61
52
|
Head: DefaultHead,
|
|
62
53
|
HeadSnippet: DefaultHeadSnippet,
|
|
63
54
|
Image: DefaultImage,
|
|
64
55
|
Link: DefaultLink,
|
|
65
|
-
|
|
56
|
+
fetch: globalThis.fetch
|
|
66
57
|
});
|
|
67
58
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
59
|
0 && (module.exports = {
|
|
@@ -70,7 +61,6 @@ const FrameworkContext = (0, import_react.createContext)({
|
|
|
70
61
|
DefaultHeadSnippet,
|
|
71
62
|
DefaultImage,
|
|
72
63
|
DefaultLink,
|
|
73
|
-
FrameworkContext
|
|
74
|
-
versionedFetch
|
|
64
|
+
FrameworkContext
|
|
75
65
|
});
|
|
76
66
|
//# sourceMappingURL=framework-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n type PropsWithChildren,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ForwardRefExoticComponent,\n type RefAttributes,\n forwardRef,\n} from 'react'\n\nimport { type LinkData } from '@makeswift/prop-controllers'\n\nimport { type
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n type PropsWithChildren,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ForwardRefExoticComponent,\n type RefAttributes,\n forwardRef,\n} from 'react'\n\nimport { type LinkData } from '@makeswift/prop-controllers'\n\nimport { type HttpFetch } from '../../../state/makeswift-api-client'\nimport { type Snippet } from '../../../client'\n\nimport { BaseHeadSnippet } from './page/HeadSnippet'\n\ntype HeadComponent = (props: { children: ReactNode }) => ReactNode\ntype HeadSnippet = (props: { snippet: Snippet }) => ReactNode\ntype ImageComponent = (props: {\n src: string\n alt: string\n sizes?: string\n width?: number\n height?: number\n priority?: boolean\n fill?: boolean\n style?: CSSProperties\n}) => ReactNode\n\ntype LinkProps = Omit<ComponentPropsWithoutRef<'a'>, 'onClick'> & {\n linkType?: LinkData['type']\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype LinkComponent = ForwardRefExoticComponent<RefAttributes<HTMLAnchorElement> & LinkProps>\n\nexport type FrameworkContext = {\n Head: HeadComponent\n HeadSnippet: HeadSnippet\n Image: ImageComponent\n Link: LinkComponent\n fetch: HttpFetch\n}\n\n// React 19 automatically hoists metadata tags to the <head>\nexport const DefaultHead = ({ children }: PropsWithChildren) => <>{children}</>\n\nexport const DefaultHeadSnippet = BaseHeadSnippet\n\nexport const DefaultImage: ImageComponent = ({ priority, fill, style, ...props }) => (\n <img\n {...props}\n style={{\n ...(fill\n ? {\n height: '100%',\n width: '100%',\n objectFit: 'cover',\n }\n : {}),\n ...style,\n }}\n loading={priority ? 'eager' : 'lazy'}\n />\n)\n\nexport const DefaultLink: LinkComponent = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ linkType, ...props }, ref) => <a {...props} ref={ref} />,\n)\n\nexport const FrameworkContext = createContext<FrameworkContext>({\n Head: DefaultHead,\n HeadSnippet: DefaultHeadSnippet,\n Image: DefaultImage,\n Link: DefaultLink,\n fetch: globalThis.fetch,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDgE;AAhDhE,mBAUO;AAOP,yBAAgC;AA+BzB,MAAM,cAAc,CAAC,EAAE,SAAS,MAAyB,2EAAG,UAAS;AAErE,MAAM,qBAAqB;AAE3B,MAAM,eAA+B,CAAC,EAAE,UAAU,MAAM,OAAO,GAAG,MAAM,MAC7E;AAAA,EAAC;AAAA;AAAA,IACE,GAAG;AAAA,IACJ,OAAO;AAAA,MACL,GAAI,OACA;AAAA,QACE,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,WAAW;AAAA,MACb,IACA,CAAC;AAAA,MACL,GAAG;AAAA,IACL;AAAA,IACA,SAAS,WAAW,UAAU;AAAA;AAChC;AAGK,MAAM,kBAA6B;AAAA,EACxC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,4CAAC,OAAG,GAAG,OAAO,KAAU;AAC3D;AAEO,MAAM,uBAAmB,4BAAgC;AAAA,EAC9D,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO,WAAW;AACpB,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/host-api-client.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, createContext, useContext } from 'react'\nimport { MakeswiftHostApiClient } from '../../api/client'\n\nconst Context = createContext(\n new MakeswiftHostApiClient({\n uri: 'https://api.makeswift.com/graphql',\n fetch: async (url, init) => {\n console.warn(\n 'Using fallback `fetch` implementation, resource revalidation may not work as expected.',\n { url },\n )\n return fetch(url, init)\n },\n }),\n)\n\nexport function useMakeswiftHostApiClient(): MakeswiftHostApiClient {\n return useContext(Context)\n}\n\nexport function MakeswiftHostApiClientProvider({\n client,\n children,\n}: {\n client: MakeswiftHostApiClient\n children: ReactNode\n}) {\n return <Context.Provider value={client}>{children}</Context.Provider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/host-api-client.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, createContext, useContext } from 'react'\nimport { MakeswiftHostApiClient } from '../../api/client'\n\nconst Context = createContext(\n new MakeswiftHostApiClient({\n uri: 'https://api.makeswift.com/graphql',\n fetch: async (url, init) => {\n console.warn(\n 'Using fallback `fetch` implementation, resource revalidation may not work as expected.',\n { url },\n )\n return fetch(url, init)\n },\n siteVersion: null,\n }),\n)\n\nexport function useMakeswiftHostApiClient(): MakeswiftHostApiClient {\n return useContext(Context)\n}\n\nexport function MakeswiftHostApiClientProvider({\n client,\n children,\n}: {\n client: MakeswiftHostApiClient\n children: ReactNode\n}) {\n return <Context.Provider value={client}>{children}</Context.Provider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BS;AA5BT,mBAAqD;AACrD,oBAAuC;AAEvC,MAAM,cAAU;AAAA,EACd,IAAI,qCAAuB;AAAA,IACzB,KAAK;AAAA,IACL,OAAO,OAAO,KAAK,SAAS;AAC1B,cAAQ;AAAA,QACN;AAAA,QACA,EAAE,IAAI;AAAA,MACR;AACA,aAAO,MAAM,KAAK,IAAI;AAAA,IACxB;AAAA,IACA,aAAa;AAAA,EACf,CAAC;AACH;AAEO,SAAS,4BAAoD;AAClE,aAAO,yBAAW,OAAO;AAC3B;AAEO,SAAS,+BAA+B;AAAA,EAC7C;AAAA,EACA;AACF,GAGG;AACD,SAAO,4CAAC,QAAQ,UAAR,EAAiB,OAAO,QAAS,UAAS;AACpD;","names":[]}
|
|
@@ -29,8 +29,10 @@ __export(read_only_actions_exports, {
|
|
|
29
29
|
registerPropControllers: () => registerPropControllers,
|
|
30
30
|
registerPropControllersHandle: () => registerPropControllersHandle,
|
|
31
31
|
registerReactComponentEffect: () => registerReactComponentEffect,
|
|
32
|
+
resetLocaleState: () => resetLocaleState,
|
|
32
33
|
setIsInBuilder: () => setIsInBuilder,
|
|
33
34
|
setIsReadOnly: () => setIsReadOnly,
|
|
35
|
+
setSiteVersion: () => setSiteVersion,
|
|
34
36
|
unregisterComponent: () => unregisterComponent,
|
|
35
37
|
unregisterPropControllers: () => unregisterPropControllers,
|
|
36
38
|
unregisterPropControllersHandle: () => unregisterPropControllersHandle
|
|
@@ -53,7 +55,11 @@ const ReadOnlyActionTypes = {
|
|
|
53
55
|
REGISTER_REACT_COMPONENT: "REGISTER_REACT_COMPONENT",
|
|
54
56
|
UNREGISTER_REACT_COMPONENT: "UNREGISTER_REACT_COMPONENT",
|
|
55
57
|
SET_IS_IN_BUILDER: "SET_IS_IN_BUILDER",
|
|
56
|
-
SET_IS_READ_ONLY: "SET_IS_READ_ONLY"
|
|
58
|
+
SET_IS_READ_ONLY: "SET_IS_READ_ONLY",
|
|
59
|
+
SET_SITE_VERSION: "SET_SITE_VERSION",
|
|
60
|
+
// TODO: consolidate with `SET_LOCALE` action in `shared-api.ts`
|
|
61
|
+
// (requires changes to the builder to handle null locales)
|
|
62
|
+
RESET_LOCALE_STATE: "RESET_LOCALE_STATE"
|
|
57
63
|
};
|
|
58
64
|
function apiResourceFulfilled(resourceType, resourceId, resource, locale) {
|
|
59
65
|
return {
|
|
@@ -151,6 +157,12 @@ function setIsInBuilder(isInBuilder) {
|
|
|
151
157
|
function setIsReadOnly(isReadOnly) {
|
|
152
158
|
return { type: ReadOnlyActionTypes.SET_IS_READ_ONLY, payload: isReadOnly };
|
|
153
159
|
}
|
|
160
|
+
function setSiteVersion(siteVersion) {
|
|
161
|
+
return { type: ReadOnlyActionTypes.SET_SITE_VERSION, payload: siteVersion };
|
|
162
|
+
}
|
|
163
|
+
function resetLocaleState() {
|
|
164
|
+
return { type: ReadOnlyActionTypes.RESET_LOCALE_STATE };
|
|
165
|
+
}
|
|
154
166
|
// Annotate the CommonJS export names for ESM import in node:
|
|
155
167
|
0 && (module.exports = {
|
|
156
168
|
ReadOnlyActionTypes,
|
|
@@ -164,8 +176,10 @@ function setIsReadOnly(isReadOnly) {
|
|
|
164
176
|
registerPropControllers,
|
|
165
177
|
registerPropControllersHandle,
|
|
166
178
|
registerReactComponentEffect,
|
|
179
|
+
resetLocaleState,
|
|
167
180
|
setIsInBuilder,
|
|
168
181
|
setIsReadOnly,
|
|
182
|
+
setSiteVersion,
|
|
169
183
|
unregisterComponent,
|
|
170
184
|
unregisterPropControllers,
|
|
171
185
|
unregisterPropControllersHandle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/state/actions/internal/read-only-actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\n\nimport { type APIResource, APIResourceType, APIResourceLocale } from '../../../api/types'\nimport { type Descriptor as PropControllerDescriptor } from '../../../prop-controllers/descriptors'\n\nimport { type ComponentMeta } from '../../modules/components-meta'\nimport { type PropControllersHandle } from '../../modules/prop-controller-handles'\nimport { type ComponentType } from '../../modules/react-components'\nimport { type DescriptorsByComponentType } from '../../modules/prop-controllers'\n\nimport { type DocumentPayload } from '../../shared-api'\n\nexport const ReadOnlyActionTypes = {\n // TODO: this one should be a read-write action and we should refuse\n // to fetch resources on the client in read-only mode\n API_RESOURCE_FULFILLED: 'API_RESOURCE_FULFILLED',\n\n CREATE_ELEMENT_TREE: 'CREATE_ELEMENT_TREE',\n DELETE_ELEMENT_TREE: 'DELETE_ELEMENT_TREE',\n\n REGISTER_COMPONENT: 'REGISTER_COMPONENT',\n UNREGISTER_COMPONENT: 'UNREGISTER_COMPONENT',\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n\n REGISTER_REACT_COMPONENT: 'REGISTER_REACT_COMPONENT',\n UNREGISTER_REACT_COMPONENT: 'UNREGISTER_REACT_COMPONENT',\n\n SET_IS_IN_BUILDER: 'SET_IS_IN_BUILDER',\n SET_IS_READ_ONLY: 'SET_IS_READ_ONLY',\n} as const\n\ntype APIResourceFulfilledAction = {\n type: typeof ReadOnlyActionTypes.API_RESOURCE_FULFILLED\n payload: {\n resourceType: APIResourceType\n resourceId: string\n resource: APIResource | null\n locale?: string | null\n }\n}\n\ntype CreateElementTreeAction = {\n type: typeof ReadOnlyActionTypes.CREATE_ELEMENT_TREE\n payload: { document: DocumentPayload; descriptors: DescriptorsByComponentType }\n}\n\ntype DeleteElementTreeAction = {\n type: typeof ReadOnlyActionTypes.DELETE_ELEMENT_TREE\n payload: { documentKey: string }\n}\n\nexport type RegisterComponentAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n propControllerDescriptors: Record<string, PropControllerDescriptor>\n }\n}\n\nexport type UnregisterComponentAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterReactComponentAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_REACT_COMPONENT\n payload: { type: string; component: ComponentType }\n}\n\ntype UnregisterReactComponentAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT\n payload: { type: string }\n}\n\ntype SetIsInBuilderAction = {\n type: typeof ReadOnlyActionTypes.SET_IS_IN_BUILDER\n payload: boolean\n}\n\ntype SetIsReadOnlyAction = {\n type: typeof ReadOnlyActionTypes.SET_IS_READ_ONLY\n payload: boolean\n}\nexport type ReadOnlyAction =\n | APIResourceFulfilledAction\n | CreateElementTreeAction\n | DeleteElementTreeAction\n | RegisterComponentAction\n | UnregisterComponentAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | RegisterReactComponentAction\n | UnregisterReactComponentAction\n | SetIsInBuilderAction\n | SetIsReadOnlyAction\n\nexport function apiResourceFulfilled<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n resource: APIResource | null,\n locale?: APIResourceLocale<T>,\n): APIResourceFulfilledAction {\n return {\n type: ReadOnlyActionTypes.API_RESOURCE_FULFILLED,\n payload: { resourceType, resourceId, resource, locale },\n }\n}\n\nexport function createElementTree(\n payload: CreateElementTreeAction['payload'],\n): CreateElementTreeAction {\n return {\n type: ReadOnlyActionTypes.CREATE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function deleteElementTree(\n payload: DeleteElementTreeAction['payload'],\n): DeleteElementTreeAction {\n return { type: ReadOnlyActionTypes.DELETE_ELEMENT_TREE, payload }\n}\n\nexport function registerComponent(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): RegisterComponentAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_COMPONENT,\n payload: { type, meta, propControllerDescriptors },\n }\n}\n\nexport function unregisterComponent(type: string): UnregisterComponentAction {\n return { type: ReadOnlyActionTypes.UNREGISTER_COMPONENT, payload: { type } }\n}\n\nexport function registerComponentEffect(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerComponent(type, meta, propControllerDescriptors))\n\n return () => {\n dispatch(unregisterComponent(type))\n }\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nfunction unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey },\n }\n}\n\nfunction registerReactComponent(\n type: string,\n component: ComponentType,\n): RegisterReactComponentAction {\n return { type: ReadOnlyActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } }\n}\n\nfunction unregisterReactComponent(type: string): UnregisterReactComponentAction {\n return { type: ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } }\n}\n\nexport function registerReactComponentEffect(\n type: string,\n component: ComponentType,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerReactComponent(type, component))\n\n return () => {\n dispatch(unregisterReactComponent(type))\n }\n }\n}\n\nexport function setIsInBuilder(isInBuilder: boolean): SetIsInBuilderAction {\n return { type: ReadOnlyActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder }\n}\n\nexport function setIsReadOnly(isReadOnly: boolean): SetIsReadOnlyAction {\n return { type: ReadOnlyActionTypes.SET_IS_READ_ONLY, payload: isReadOnly }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,MAAM,sBAAsB;AAAA;AAAA;AAAA,EAGjC,wBAAwB;AAAA,EAExB,qB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AO,EAAE,MAAM,oBAAoB,kBAAkB,SAAS,WAAW;AAC3E;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/actions/internal/read-only-actions.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\n\nimport { type APIResource, APIResourceType, APIResourceLocale } from '../../../api/types'\nimport { type SiteVersion } from '../../../api/site-version'\nimport { type Descriptor as PropControllerDescriptor } from '../../../prop-controllers/descriptors'\n\nimport { type ComponentMeta } from '../../modules/components-meta'\nimport { type PropControllersHandle } from '../../modules/prop-controller-handles'\nimport { type ComponentType } from '../../modules/react-components'\nimport { type DescriptorsByComponentType } from '../../modules/prop-controllers'\n\nimport { type DocumentPayload } from '../../shared-api'\n\nexport const ReadOnlyActionTypes = {\n // TODO: this one should be a read-write action and we should refuse\n // to fetch resources on the client in read-only mode\n API_RESOURCE_FULFILLED: 'API_RESOURCE_FULFILLED',\n\n CREATE_ELEMENT_TREE: 'CREATE_ELEMENT_TREE',\n DELETE_ELEMENT_TREE: 'DELETE_ELEMENT_TREE',\n\n REGISTER_COMPONENT: 'REGISTER_COMPONENT',\n UNREGISTER_COMPONENT: 'UNREGISTER_COMPONENT',\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n\n REGISTER_REACT_COMPONENT: 'REGISTER_REACT_COMPONENT',\n UNREGISTER_REACT_COMPONENT: 'UNREGISTER_REACT_COMPONENT',\n\n SET_IS_IN_BUILDER: 'SET_IS_IN_BUILDER',\n SET_IS_READ_ONLY: 'SET_IS_READ_ONLY',\n SET_SITE_VERSION: 'SET_SITE_VERSION',\n\n // TODO: consolidate with `SET_LOCALE` action in `shared-api.ts`\n // (requires changes to the builder to handle null locales)\n RESET_LOCALE_STATE: 'RESET_LOCALE_STATE',\n} as const\n\ntype APIResourceFulfilledAction = {\n type: typeof ReadOnlyActionTypes.API_RESOURCE_FULFILLED\n payload: {\n resourceType: APIResourceType\n resourceId: string\n resource: APIResource | null\n locale?: string | null\n }\n}\n\ntype CreateElementTreeAction = {\n type: typeof ReadOnlyActionTypes.CREATE_ELEMENT_TREE\n payload: { document: DocumentPayload; descriptors: DescriptorsByComponentType }\n}\n\ntype DeleteElementTreeAction = {\n type: typeof ReadOnlyActionTypes.DELETE_ELEMENT_TREE\n payload: { documentKey: string }\n}\n\nexport type RegisterComponentAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_COMPONENT\n payload: {\n type: string\n meta: ComponentMeta\n propControllerDescriptors: Record<string, PropControllerDescriptor>\n }\n}\n\nexport type UnregisterComponentAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_COMPONENT\n payload: { type: string }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterReactComponentAction = {\n type: typeof ReadOnlyActionTypes.REGISTER_REACT_COMPONENT\n payload: { type: string; component: ComponentType }\n}\n\ntype UnregisterReactComponentAction = {\n type: typeof ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT\n payload: { type: string }\n}\n\ntype SetIsInBuilderAction = {\n type: typeof ReadOnlyActionTypes.SET_IS_IN_BUILDER\n payload: boolean\n}\n\ntype SetIsReadOnlyAction = {\n type: typeof ReadOnlyActionTypes.SET_IS_READ_ONLY\n payload: boolean\n}\n\ntype SetSiteVersionAction = {\n type: typeof ReadOnlyActionTypes.SET_SITE_VERSION\n payload: SiteVersion | null\n}\n\ntype ResetLocaleStateAction = {\n type: typeof ReadOnlyActionTypes.RESET_LOCALE_STATE\n}\n\nexport type ReadOnlyAction =\n | APIResourceFulfilledAction\n | CreateElementTreeAction\n | DeleteElementTreeAction\n | RegisterComponentAction\n | UnregisterComponentAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | RegisterReactComponentAction\n | UnregisterReactComponentAction\n | SetIsInBuilderAction\n | SetIsReadOnlyAction\n | SetSiteVersionAction\n | ResetLocaleStateAction\n\nexport function apiResourceFulfilled<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n resource: APIResource | null,\n locale?: APIResourceLocale<T>,\n): APIResourceFulfilledAction {\n return {\n type: ReadOnlyActionTypes.API_RESOURCE_FULFILLED,\n payload: { resourceType, resourceId, resource, locale },\n }\n}\n\nexport function createElementTree(\n payload: CreateElementTreeAction['payload'],\n): CreateElementTreeAction {\n return {\n type: ReadOnlyActionTypes.CREATE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function deleteElementTree(\n payload: DeleteElementTreeAction['payload'],\n): DeleteElementTreeAction {\n return { type: ReadOnlyActionTypes.DELETE_ELEMENT_TREE, payload }\n}\n\nexport function registerComponent(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): RegisterComponentAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_COMPONENT,\n payload: { type, meta, propControllerDescriptors },\n }\n}\n\nexport function unregisterComponent(type: string): UnregisterComponentAction {\n return { type: ReadOnlyActionTypes.UNREGISTER_COMPONENT, payload: { type } }\n}\n\nexport function registerComponentEffect(\n type: string,\n meta: ComponentMeta,\n propControllerDescriptors: Record<string, PropControllerDescriptor>,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerComponent(type, meta, propControllerDescriptors))\n\n return () => {\n dispatch(unregisterComponent(type))\n }\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nfunction unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: ReadOnlyActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return {\n type: ReadOnlyActionTypes.UNREGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey },\n }\n}\n\nfunction registerReactComponent(\n type: string,\n component: ComponentType,\n): RegisterReactComponentAction {\n return { type: ReadOnlyActionTypes.REGISTER_REACT_COMPONENT, payload: { type, component } }\n}\n\nfunction unregisterReactComponent(type: string): UnregisterReactComponentAction {\n return { type: ReadOnlyActionTypes.UNREGISTER_REACT_COMPONENT, payload: { type } }\n}\n\nexport function registerReactComponentEffect(\n type: string,\n component: ComponentType,\n): ThunkAction<() => void, unknown, unknown, ReadOnlyAction> {\n return dispatch => {\n dispatch(registerReactComponent(type, component))\n\n return () => {\n dispatch(unregisterReactComponent(type))\n }\n }\n}\n\nexport function setIsInBuilder(isInBuilder: boolean): SetIsInBuilderAction {\n return { type: ReadOnlyActionTypes.SET_IS_IN_BUILDER, payload: isInBuilder }\n}\n\nexport function setIsReadOnly(isReadOnly: boolean): SetIsReadOnlyAction {\n return { type: ReadOnlyActionTypes.SET_IS_READ_ONLY, payload: isReadOnly }\n}\n\nexport function setSiteVersion(siteVersion: SiteVersion | null): SetSiteVersionAction {\n return { type: ReadOnlyActionTypes.SET_SITE_VERSION, payload: siteVersion }\n}\n\nexport function resetLocaleState(): ResetLocaleStateAction {\n return { type: ReadOnlyActionTypes.RESET_LOCALE_STATE }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,MAAM,sBAAsB;AAAA;AAAA;AAAA,EAGjC,wBAAwB;AAAA,EAExB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EAErB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,kCAAkC;AAAA,EAClC,oCAAoC;AAAA,EAEpC,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA;AAAA;AAAA,EAIlB,oBAAoB;AACtB;AAsHO,SAAS,qBACd,cACA,YACA,UACA,QAC4B;AAC5B,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,cAAc,YAAY,UAAU,OAAO;AAAA,EACxD;AACF;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO,EAAE,MAAM,oBAAoB,qBAAqB,QAAQ;AAClE;AAEO,SAAS,kBACd,MACA,MACA,2BACyB;AACzB,SAAO;AAAA,IACL,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,MAAM,MAAM,0BAA0B;AAAA,EACnD;AACF;AAEO,SAAS,oBAAoB,MAAyC;AAC3E,SAAO,EAAE,MAAM,oBAAoB,sBAAsB,SAAS,EAAE,KAAK,EAAE;AAC7E;AAEO,SAAS,wBACd,MACA,MACA,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yB,MAA8C;AAC9E,SAAO,EAAE,MAAM,oBAAoB,4BAA4B,SAAS,EAAE,KAAK,EAAE;AACnF;AAEO,SAAS,6BACd,MACA,WAC2D;AAC3D,SAAO,cAAY;AACjB,aAAS,uBAAuB,MAAM,SAAS,CAAC;AAEhD,WAAO,MAAM;AACX,eAAS,yBAAyB,IAAI,CAAC;AAAA,IACzC;AAAA,EACF;AACF;AAEO,SAAS,eAAe,aAA4C;AACzE,SAAO,EAAE,MAAM,oBAAoB,mBAAmB,SAAS,YAAY;AAC7E;AAEO,SAAS,cAAc,YAA0C;AACtE,SAAO,EAAE,MAAM,oBAAoB,kBAAkB,SAAS,WAAW;AAC3E;AAEO,SAAS,eAAe,aAAuD;AACpF,SAAO,EAAE,MAAM,oBAAoB,kBAAkB,SAAS,YAAY;AAC5E;AAEO,SAAS,mBAA2C;AACzD,SAAO,EAAE,MAAM,oBAAoB,mBAAmB;AACxD;","names":[]}
|
|
@@ -35,6 +35,9 @@ __export(makeswift_api_client_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(makeswift_api_client_exports);
|
|
37
37
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
38
|
+
var import_site_version = require("../api/site-version");
|
|
39
|
+
var SiteVersionState = __toESM(require("./modules/site-version"));
|
|
40
|
+
var LocaleState = __toESM(require("./modules/locale"));
|
|
38
41
|
var APIResources = __toESM(require("./modules/api-resources"));
|
|
39
42
|
var LocalizedResourcesMap = __toESM(require("./modules/localized-resources-map"));
|
|
40
43
|
var import_actions = require("./actions");
|
|
@@ -43,6 +46,8 @@ var import_host_api = require("./host-api");
|
|
|
43
46
|
var import_toolkit2 = require("./toolkit");
|
|
44
47
|
var import_api = require("../api");
|
|
45
48
|
const reducer = (0, import_toolkit.combineReducers)({
|
|
49
|
+
siteVersion: SiteVersionState.reducer,
|
|
50
|
+
locale: LocaleState.reducer,
|
|
46
51
|
apiResources: APIResources.reducer,
|
|
47
52
|
localizedResourcesMap: LocalizedResourcesMap.reducer
|
|
48
53
|
});
|
|
@@ -80,10 +85,11 @@ function getAPIResource(state, resourceType, resourceId, locale) {
|
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
87
|
function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
83
|
-
const
|
|
88
|
+
const fetchVersioned = async (url, version) => {
|
|
84
89
|
const response = await fetch(url, {
|
|
85
90
|
headers: {
|
|
86
|
-
"Content-Type": "application/json"
|
|
91
|
+
"Content-Type": "application/json",
|
|
92
|
+
...version != null ? { [import_site_version.ApiHandlerHeaders.SiteVersion]: (0, import_site_version.serializeSiteVersion)(version) } : {}
|
|
87
93
|
}
|
|
88
94
|
});
|
|
89
95
|
if (response.status === 404)
|
|
@@ -99,22 +105,29 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
99
105
|
};
|
|
100
106
|
return async (dispatch, getState) => {
|
|
101
107
|
const state = getState();
|
|
108
|
+
const version = SiteVersionState.getSiteVersion(state.siteVersion);
|
|
102
109
|
if (getHasAPIResource(state, resourceType, resourceId, locale)) {
|
|
103
110
|
return getAPIResource(state, resourceType, resourceId, locale);
|
|
104
111
|
}
|
|
105
112
|
let resource;
|
|
106
113
|
switch (resourceType) {
|
|
107
114
|
case import_api.APIResourceType.Swatch:
|
|
108
|
-
resource = await
|
|
115
|
+
resource = await fetchVersioned(`/api/makeswift/swatches/${resourceId}`, version);
|
|
109
116
|
break;
|
|
110
117
|
case import_api.APIResourceType.File:
|
|
111
|
-
resource = await
|
|
118
|
+
resource = await fetchVersioned(`/api/makeswift/files/${resourceId}`, version);
|
|
112
119
|
break;
|
|
113
120
|
case import_api.APIResourceType.Typography:
|
|
114
|
-
resource = await
|
|
121
|
+
resource = await fetchVersioned(
|
|
122
|
+
`/api/makeswift/typographies/${resourceId}`,
|
|
123
|
+
version
|
|
124
|
+
);
|
|
115
125
|
break;
|
|
116
126
|
case import_api.APIResourceType.GlobalElement:
|
|
117
|
-
resource = await
|
|
127
|
+
resource = await fetchVersioned(
|
|
128
|
+
`/api/makeswift/global-elements/${resourceId}`,
|
|
129
|
+
version
|
|
130
|
+
);
|
|
118
131
|
break;
|
|
119
132
|
case import_api.APIResourceType.LocalizedGlobalElement: {
|
|
120
133
|
if (locale == null)
|
|
@@ -122,8 +135,9 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
122
135
|
if (getLocalizedResourceId(state, locale, resourceId) === null) {
|
|
123
136
|
return null;
|
|
124
137
|
}
|
|
125
|
-
resource = await
|
|
126
|
-
`/api/makeswift/localized-global-elements/${resourceId}/${locale}
|
|
138
|
+
resource = await fetchVersioned(
|
|
139
|
+
`/api/makeswift/localized-global-elements/${resourceId}/${locale}`,
|
|
140
|
+
version
|
|
127
141
|
);
|
|
128
142
|
dispatch(
|
|
129
143
|
(0, import_host_api.setLocalizedResourceId)({
|
|
@@ -138,11 +152,11 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
138
152
|
const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, "http://n");
|
|
139
153
|
if (locale != null)
|
|
140
154
|
url.searchParams.set("locale", locale);
|
|
141
|
-
resource = await
|
|
155
|
+
resource = await fetchVersioned(url.pathname + url.search, version);
|
|
142
156
|
break;
|
|
143
157
|
}
|
|
144
158
|
case import_api.APIResourceType.Table:
|
|
145
|
-
resource = await
|
|
159
|
+
resource = await fetchVersioned(`/api/makeswift/tables/${resourceId}`, version);
|
|
146
160
|
break;
|
|
147
161
|
default:
|
|
148
162
|
resource = null;
|
|
@@ -151,8 +165,8 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
151
165
|
return resource;
|
|
152
166
|
};
|
|
153
167
|
}
|
|
154
|
-
function defaultLocaleMiddleware(
|
|
155
|
-
return (0, import_toolkit2.actionMiddleware)(() => (next) => {
|
|
168
|
+
function defaultLocaleMiddleware() {
|
|
169
|
+
return (0, import_toolkit2.actionMiddleware)(({ getState }) => (next) => {
|
|
156
170
|
return (action) => {
|
|
157
171
|
switch (action.type) {
|
|
158
172
|
case import_actions.ActionTypes.CHANGE_API_RESOURCE:
|
|
@@ -161,7 +175,10 @@ function defaultLocaleMiddleware(defaultLocale) {
|
|
|
161
175
|
const { locale } = action.payload;
|
|
162
176
|
return next({
|
|
163
177
|
...action,
|
|
164
|
-
payload: {
|
|
178
|
+
payload: {
|
|
179
|
+
...action.payload,
|
|
180
|
+
locale: locale ?? LocaleState.getLocale(getState().locale)
|
|
181
|
+
}
|
|
165
182
|
});
|
|
166
183
|
}
|
|
167
184
|
}
|
|
@@ -169,10 +186,7 @@ function defaultLocaleMiddleware(defaultLocale) {
|
|
|
169
186
|
};
|
|
170
187
|
});
|
|
171
188
|
}
|
|
172
|
-
function configureStore({
|
|
173
|
-
defaultLocale,
|
|
174
|
-
serializedState
|
|
175
|
-
}) {
|
|
189
|
+
function configureStore({ serializedState }) {
|
|
176
190
|
return (0, import_toolkit.configureStore)({
|
|
177
191
|
reducer,
|
|
178
192
|
preloadedState: {
|
|
@@ -181,7 +195,7 @@ function configureStore({
|
|
|
181
195
|
serializedState?.localizedResourcesMap
|
|
182
196
|
)
|
|
183
197
|
},
|
|
184
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(defaultLocaleMiddleware(
|
|
198
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(defaultLocaleMiddleware()),
|
|
185
199
|
devTools: (0, import_toolkit2.devToolsConfig)({
|
|
186
200
|
name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
|
|
187
201
|
actionsDenylist: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal/read-only-actions'\nimport { setLocalizedResourceId } from './host-api'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../api'\n\nconst reducer = combineReducers({\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nfunction getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchJson = async <T>(url: string): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchJson<Swatch>(`/api/makeswift/swatches/${resourceId}`)\n break\n\n case APIResourceType.File:\n resource = await fetchJson<File>(`/api/makeswift/files/${resourceId}`)\n break\n\n case APIResourceType.Typography:\n resource = await fetchJson<Typography>(`/api/makeswift/typographies/${resourceId}`)\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchJson<GlobalElement>(`/api/makeswift/global-elements/${resourceId}`)\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchJson<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchJson<PagePathnameSlice>(url.pathname + url.search)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchJson<Table>(`/api/makeswift/tables/${resourceId}`)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(\n defaultLocale: string | undefined,\n): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: { ...action.payload, locale: locale ?? defaultLocale },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({\n defaultLocale,\n serializedState,\n}: {\n defaultLocale: string | undefined\n serializedState?: SerializedState\n}) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n apiResources: APIResources.getInitialState(serializedState?.apiResources),\n localizedResourcesMap: LocalizedResourcesMap.getInitialState(\n serializedState?.localizedResourcesMap,\n ),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware(defaultLocale)),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT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ACV,qBAAqB,iCAAiB,EAAE,OAAO,wBAAwB,aAAa,CAAC;AAAA,IAEvF,cAAU,gCAAe;AAAA,MACvB,MAAM,sBAAqB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MACnD,iBAAiB;AAAA,QACf,2BAAY;AAAA,QACZ,2BAAY;AAAA,QACZ,2BAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":["import_toolkit","configureReduxStore"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport { type SiteVersion, ApiHandlerHeaders, serializeSiteVersion } from '../api/site-version'\n\nimport * as SiteVersionState from './modules/site-version'\nimport * as LocaleState from './modules/locale'\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\n\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal/read-only-actions'\nimport { setLocalizedResourceId } from './host-api'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../api'\n\nconst reducer = combineReducers({\n siteVersion: SiteVersionState.reducer,\n locale: LocaleState.reducer,\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nfunction getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchVersioned = async <T>(url: string, version: SiteVersion | null): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n ...(version != null\n ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(version) }\n : {}),\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n const version = SiteVersionState.getSiteVersion(state.siteVersion)\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchVersioned<Swatch>(`/api/makeswift/swatches/${resourceId}`, version)\n break\n\n case APIResourceType.File:\n resource = await fetchVersioned<File>(`/api/makeswift/files/${resourceId}`, version)\n break\n\n case APIResourceType.Typography:\n resource = await fetchVersioned<Typography>(\n `/api/makeswift/typographies/${resourceId}`,\n version,\n )\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchVersioned<GlobalElement>(\n `/api/makeswift/global-elements/${resourceId}`,\n version,\n )\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchVersioned<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n version,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchVersioned<PagePathnameSlice>(url.pathname + url.search, version)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchVersioned<Table>(`/api/makeswift/tables/${resourceId}`, version)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(({ getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: {\n ...action.payload,\n locale: locale ?? LocaleState.getLocale(getState().locale),\n },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({ serializedState }: { serializedState?: SerializedState }) {\n return configureReduxStore({\n reducer,\n preloadedState: {\n apiResources: APIResources.getInitialState(serializedState?.apiResources),\n localizedResourcesMap: LocalizedResourcesMap.getInitialState(\n serializedState?.localizedResourcesMap,\n ),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware()),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAEP,0BAA0E;AAE1E,uBAAkC;AAClC,kBAA6B;AAC7B,mBAA8B;AAC9B,4BAAuC;AAEvC,qBAAyC;AACzC,+BAAqC;AACrC,sBAAuC;AACvC,IAAAA,kBAAoE;AAEpE,iBAWO;AAEP,MAAM,cAAU,gCAAgB;AAAA,EAC9B,aAAa,iBAAiB;AAAA,EAC9B,QAAQ,YAAY;AAAA,EACpB,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AA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