@makeswift/runtime 0.28.7-canary.2 → 0.28.7-canary.3
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/api-resources-client.js +160 -0
- package/dist/cjs/api/api-resources-client.js.map +1 -0
- package/dist/cjs/api/client.js +20 -182
- 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/controls/index.js +2 -2
- package/dist/cjs/controls/index.js.map +1 -1
- package/dist/cjs/next/fetch.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-cache-data.js +1 -1
- package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js +11 -32
- package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
- package/dist/cjs/runtimes/react/resource-resolver.js +52 -0
- package/dist/cjs/runtimes/react/resource-resolver.js.map +1 -0
- package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
- package/dist/cjs/slate/InlinePlugin/index.js +1 -1
- package/dist/cjs/slate/InlinePlugin/index.js.map +1 -1
- package/dist/cjs/slate/InlinePlugin/types.js +3 -3
- package/dist/cjs/slate/InlinePlugin/types.js.map +1 -1
- package/dist/cjs/slate/TextAlignPlugin/index.js +5 -5
- package/dist/cjs/slate/TextAlignPlugin/index.js.map +1 -1
- package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
- package/dist/cjs/state/api-client/client-store.js +81 -0
- package/dist/cjs/state/api-client/client-store.js.map +1 -0
- package/dist/cjs/state/{makeswift-api-client.js → api-client/fetch-api-resource.js} +15 -101
- package/dist/cjs/state/api-client/fetch-api-resource.js.map +1 -0
- package/dist/cjs/state/api-client/state.js +89 -0
- package/dist/cjs/state/api-client/state.js.map +1 -0
- package/dist/cjs/state/api-client/store.js +36 -0
- package/dist/cjs/state/api-client/store.js.map +1 -0
- package/dist/cjs/state/middleware/makeswift-api-client-sync.js +1 -1
- package/dist/cjs/state/middleware/makeswift-api-client-sync.js.map +1 -1
- package/dist/esm/api/api-resources-client.js +127 -0
- package/dist/esm/api/api-resources-client.js.map +1 -0
- package/dist/esm/api/client.js +19 -171
- 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/controls/index.js +2 -2
- package/dist/esm/controls/index.js.map +1 -1
- package/dist/esm/next/fetch.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-resource-resolver.js +11 -22
- package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
- package/dist/esm/runtimes/react/resource-resolver.js +28 -0
- package/dist/esm/runtimes/react/resource-resolver.js.map +1 -0
- package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
- package/dist/esm/slate/InlinePlugin/index.js +2 -2
- package/dist/esm/slate/InlinePlugin/index.js.map +1 -1
- package/dist/esm/slate/InlinePlugin/types.js +4 -4
- package/dist/esm/slate/InlinePlugin/types.js.map +1 -1
- package/dist/esm/slate/TextAlignPlugin/index.js +6 -6
- package/dist/esm/slate/TextAlignPlugin/index.js.map +1 -1
- package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
- package/dist/esm/state/api-client/client-store.js +49 -0
- package/dist/esm/state/api-client/client-store.js.map +1 -0
- package/dist/esm/state/api-client/fetch-api-resource.js +93 -0
- package/dist/esm/state/api-client/fetch-api-resource.js.map +1 -0
- package/dist/esm/state/api-client/state.js +52 -0
- package/dist/esm/state/api-client/state.js.map +1 -0
- package/dist/esm/state/api-client/store.js +12 -0
- package/dist/esm/state/api-client/store.js.map +1 -0
- package/dist/esm/state/middleware/makeswift-api-client-sync.js +1 -1
- package/dist/esm/state/middleware/makeswift-api-client-sync.js.map +1 -1
- package/dist/types/api/api-resources-client.d.ts +57 -0
- package/dist/types/api/api-resources-client.d.ts.map +1 -0
- package/dist/types/api/client.d.ts +10 -42
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +9 -9
- package/dist/types/controls/index.d.ts +1 -1
- package/dist/types/controls/index.d.ts.map +1 -1
- package/dist/types/next/fetch.d.ts +1 -1
- package/dist/types/next/fetch.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-resource-resolver.d.ts.map +1 -1
- package/dist/types/runtimes/react/resource-resolver.d.ts +10 -0
- package/dist/types/runtimes/react/resource-resolver.d.ts.map +1 -0
- package/dist/types/runtimes/react/runtime-core.d.ts +3 -3
- package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
- package/dist/types/slate/InlinePlugin/types.d.ts +3 -3
- package/dist/types/slate/InlinePlugin/types.d.ts.map +1 -1
- package/dist/types/slate/TextAlignPlugin/index.d.ts.map +1 -1
- package/dist/types/state/actions/internal/read-write-actions.d.ts +1 -1
- package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
- package/dist/types/state/api-client/client-store.d.ts +6 -0
- package/dist/types/state/api-client/client-store.d.ts.map +1 -0
- package/dist/types/state/api-client/fetch-api-resource.d.ts +11 -0
- package/dist/types/state/api-client/fetch-api-resource.d.ts.map +1 -0
- package/dist/types/state/api-client/state.d.ts +30 -0
- package/dist/types/state/api-client/state.d.ts.map +1 -0
- package/dist/types/state/api-client/store.d.ts +18 -0
- package/dist/types/state/api-client/store.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/state/makeswift-api-client.js.map +0 -1
- package/dist/esm/state/makeswift-api-client.js +0 -179
- package/dist/esm/state/makeswift-api-client.js.map +0 -1
- package/dist/types/state/makeswift-api-client.d.ts +0 -51
- package/dist/types/state/makeswift-api-client.d.ts.map +0 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var use_resource_resolver_exports = {};
|
|
30
20
|
__export(use_resource_resolver_exports, {
|
|
@@ -32,35 +22,24 @@ __export(use_resource_resolver_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(use_resource_resolver_exports);
|
|
34
24
|
var import_react = require("react");
|
|
35
|
-
var ReactPage = __toESM(require("../../../state/read-only-state"));
|
|
36
25
|
var import_host_api_client = require("../host-api-client");
|
|
26
|
+
var import_resource_resolver = require("../resource-resolver");
|
|
37
27
|
var import_use_store = require("./use-store");
|
|
38
28
|
var import_use_document_context = require("./use-document-context");
|
|
39
29
|
function useResourceResolver() {
|
|
40
30
|
const store = (0, import_use_store.useStore)();
|
|
41
|
-
const
|
|
31
|
+
const apiClient = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
42
32
|
const documentKey = (0, import_use_document_context.useDocumentKey)();
|
|
43
33
|
const locale = (0, import_use_document_context.useDocumentLocale)();
|
|
44
|
-
return (0, import_react.useMemo)(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
name: `element-id:${documentKey}:${elementKey}`,
|
|
55
|
-
readStable: () => lastValue = read(),
|
|
56
|
-
subscribe: (onUpdate) => store.subscribe(() => {
|
|
57
|
-
if (read() !== lastValue)
|
|
58
|
-
onUpdate();
|
|
59
|
-
})
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}, [client, store, documentKey, locale]);
|
|
34
|
+
return (0, import_react.useMemo)(
|
|
35
|
+
() => (0, import_resource_resolver.createResourceResolver)({
|
|
36
|
+
store,
|
|
37
|
+
apiClient,
|
|
38
|
+
documentKey,
|
|
39
|
+
locale
|
|
40
|
+
}),
|
|
41
|
+
[store, apiClient, documentKey, locale]
|
|
42
|
+
);
|
|
64
43
|
}
|
|
65
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
45
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resource-resolver.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type ResourceResolver } from '@makeswift/controls'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resource-resolver.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type ResourceResolver } from '@makeswift/controls'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\nimport { createResourceResolver } from '../resource-resolver'\n\nimport { useStore } from './use-store'\nimport { useDocumentKey, useDocumentLocale } from './use-document-context'\n\nexport function useResourceResolver(): ResourceResolver {\n const store = useStore()\n const apiClient = useMakeswiftHostApiClient()\n\n const documentKey = useDocumentKey()\n const locale = useDocumentLocale()\n\n return useMemo<ResourceResolver>(\n () =>\n createResourceResolver({\n store,\n apiClient,\n documentKey,\n locale,\n }),\n [store, apiClient, documentKey, locale],\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AAGxB,6BAA0C;AAC1C,+BAAuC;AAEvC,uBAAyB;AACzB,kCAAkD;AAE3C,SAAS,sBAAwC;AACtD,QAAM,YAAQ,2BAAS;AACvB,QAAM,gBAAY,kDAA0B;AAE5C,QAAM,kBAAc,4CAAe;AACnC,QAAM,aAAS,+CAAkB;AAEjC,aAAO;AAAA,IACL,UACE,iDAAuB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,OAAO,WAAW,aAAa,MAAM;AAAA,EACxC;AACF;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var resource_resolver_exports = {};
|
|
20
|
+
__export(resource_resolver_exports, {
|
|
21
|
+
createResourceResolver: () => createResourceResolver
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(resource_resolver_exports);
|
|
24
|
+
var import_read_only_state = require("../../state/read-only-state");
|
|
25
|
+
const createResourceResolver = ({
|
|
26
|
+
store,
|
|
27
|
+
apiClient,
|
|
28
|
+
documentKey,
|
|
29
|
+
locale
|
|
30
|
+
}) => ({
|
|
31
|
+
resolveSwatch: (swatchId) => apiClient.resolveSwatch(swatchId),
|
|
32
|
+
resolveFile: (fileId) => apiClient.resolveFile(fileId),
|
|
33
|
+
resolveTypography: (typographyId) => apiClient.resolveTypography(typographyId),
|
|
34
|
+
resolvePagePathnameSlice: (pageId) => apiClient.resolvePagePathnameSlice({ pageId, locale }),
|
|
35
|
+
resolveElementId: (elementKey) => {
|
|
36
|
+
const read = () => documentKey == null ? null : (0, import_read_only_state.getElementId)(store.getState(), documentKey, elementKey);
|
|
37
|
+
let lastValue = null;
|
|
38
|
+
return {
|
|
39
|
+
name: `element-id:${documentKey}:${elementKey}`,
|
|
40
|
+
readStable: () => lastValue = read(),
|
|
41
|
+
subscribe: (onUpdate) => store.subscribe(() => {
|
|
42
|
+
if (read() !== lastValue)
|
|
43
|
+
onUpdate();
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
createResourceResolver
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=resource-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/resource-resolver.ts"],"sourcesContent":["import { type ResourceResolver } from '@makeswift/controls'\n\nimport { getElementId } from '../../state/read-only-state'\nimport { ApiResourcesClient } from '../../api/api-resources-client'\nimport { Store } from '../../state/store'\n\nexport const createResourceResolver = ({\n store,\n apiClient,\n documentKey,\n locale,\n}: {\n store: Store\n apiClient: ApiResourcesClient\n documentKey: string | null\n locale: string | null\n}): ResourceResolver => ({\n resolveSwatch: swatchId => apiClient.resolveSwatch(swatchId),\n resolveFile: fileId => apiClient.resolveFile(fileId),\n resolveTypography: typographyId => apiClient.resolveTypography(typographyId),\n resolvePagePathnameSlice: pageId => apiClient.resolvePagePathnameSlice({ pageId, locale }),\n resolveElementId: elementKey => {\n const read = () =>\n documentKey == null ? null : getElementId(store.getState(), documentKey, elementKey)\n\n let lastValue: string | null = null\n return {\n name: `element-id:${documentKey}:${elementKey}`,\n readStable: () => (lastValue = read()),\n subscribe: (onUpdate: () => void) =>\n store.subscribe(() => {\n if (read() !== lastValue) onUpdate()\n }),\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAA6B;AAItB,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,OAKyB;AAAA,EACvB,eAAe,cAAY,UAAU,cAAc,QAAQ;AAAA,EAC3D,aAAa,YAAU,UAAU,YAAY,MAAM;AAAA,EACnD,mBAAmB,kBAAgB,UAAU,kBAAkB,YAAY;AAAA,EAC3E,0BAA0B,YAAU,UAAU,yBAAyB,EAAE,QAAQ,OAAO,CAAC;AAAA,EACzF,kBAAkB,gBAAc;AAC9B,UAAM,OAAO,MACX,eAAe,OAAO,WAAO,qCAAa,MAAM,SAAS,GAAG,aAAa,UAAU;AAErF,QAAI,YAA2B;AAC/B,WAAO;AAAA,MACL,MAAM,cAAc,WAAW,IAAI,UAAU;AAAA,MAC7C,YAAY,MAAO,YAAY,KAAK;AAAA,MACpC,WAAW,CAAC,aACV,MAAM,UAAU,MAAM;AACpB,YAAI,KAAK,MAAM;AAAW,mBAAS;AAAA,MACrC,CAAC;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
|
|
@@ -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
|
|
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 // host API client includes an in-memory cache of the site's resources and thus also has to be versioned\n const hostApiClient = new MakeswiftHostApiClient({\n uri: new URL('graphql', this.apiOrigin).href,\n fetch: this.fetch,\n preloadedState: { siteVersion, locale },\n })\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 hostApiClient,\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 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,oBAAuC;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,IAInB,UAAU,qCAAc,SAAS,YAAY,qCAAc,SAAS;AAAA,EACtE,CAAC;AAAA,EAEQ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY;AAAA,IACV,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ;AAAA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B;AAClE,UAAM,MAAM,cAAc,EAAE,aAAa,OAAO,CAAC;AAEjD,QAAI,CAAC,KAAK,yBAAyB,GAAG,GAAG;AACvC,cAAQ,MAAM,sDAAsD,EAAE,IAAI,CAAC;AAC3E;AAAA,IACF;AAEA,QAAI,KAAK,aAAa,QAAQ,KAAK,KAAK,GAAG;AACzC,YAAM,oBAAoB;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,gBACE,aACA,oBACS;AACT,eAAO,0CAAgB,KAAK,WAAW,SAAS,GAAG,aAAa,kBAAkB;AAAA,EACpF;AAAA,EAEA,iBAA8B;AAC5B,eAAO,uCAAe,KAAK,WAAW,SAAS,CAAC;AAAA,EAClD;AAAA,EAEQ,yBAAyB,KAAsB;AAGrD,WAAO,KAAC,2BAAS,KAAM,KAAK,eAAe,UAAa,cAAc,KAAK,UAAU,MAAM;AAAA,EAC7F;AACF;AAEA,MAAM,gBAAgB,CAAC,EAAE,aAAa,OAAO,MAC3C,GAAG,eAAe,WAAW,CAAC,IAAI,UAAU,SAAS;AAEvD,MAAM,iBAAiB,CAAC,gBACtB,aAAa,WAAW;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":[]}
|
|
@@ -38,7 +38,7 @@ const withInline = (editor) => {
|
|
|
38
38
|
function InlinePlugin() {
|
|
39
39
|
return (0, import_plugin.Plugin)({
|
|
40
40
|
control: {
|
|
41
|
-
definition: (0, import_controls.
|
|
41
|
+
definition: (0, import_controls.IconRadioGroup)({
|
|
42
42
|
label: "Inline",
|
|
43
43
|
options: import_types.supportedInlineOptions
|
|
44
44
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/InlinePlugin/index.tsx"],"sourcesContent":["import { type Editor, type Element } from 'slate'\nimport { type RenderElementProps } from 'slate-react'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/InlinePlugin/index.tsx"],"sourcesContent":["import { type Editor, type Element } from 'slate'\nimport { type RenderElementProps } from 'slate-react'\nimport { IconRadioGroup, Slate } from '@makeswift/controls'\n\nimport { type RenderElement, Plugin } from '../../controls/rich-text-v2/plugin'\n\nimport { supportedInlineOptions, isSupportedInlineNode } from './types'\nimport { onChange } from './onChange'\nimport { getValue } from './getValue'\n\nexport const withInline = (editor: Editor) => {\n const { isInline } = editor\n\n editor.isInline = entry => {\n return Slate.isInline(entry) && isInline(entry)\n }\n\n return editor\n}\n\nexport function InlinePlugin() {\n return Plugin({\n control: {\n definition: IconRadioGroup({\n label: 'Inline',\n options: supportedInlineOptions,\n }),\n onChange,\n getValue,\n getElementValue: (element: Element) =>\n isSupportedInlineNode(element) ? element.type : undefined,\n },\n withPlugin: withInline,\n renderElement: renderElement => props => {\n return <InlinePluginComponent {...props} renderElement={renderElement} />\n },\n })\n}\n\nfunction InlinePluginComponent({\n renderElement,\n ...props\n}: RenderElementProps & { renderElement: RenderElement }) {\n switch (props.element.type) {\n case Slate.InlineType.Code:\n return <code {...props.attributes}>{renderElement(props)}</code>\n\n case Slate.InlineType.SuperScript:\n return <sup {...props.attributes}>{renderElement(props)}</sup>\n\n case Slate.InlineType.SubScript:\n return <sub {...props.attributes}>{renderElement(props)}</sub>\n\n default:\n return <>{renderElement(props)}</>\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCa;AAhCb,sBAAsC;AAEtC,oBAA2C;AAE3C,mBAA8D;AAC9D,sBAAyB;AACzB,sBAAyB;AAElB,MAAM,aAAa,CAAC,WAAmB;AAC5C,QAAM,EAAE,SAAS,IAAI;AAErB,SAAO,WAAW,WAAS;AACzB,WAAO,sBAAM,SAAS,KAAK,KAAK,SAAS,KAAK;AAAA,EAChD;AAEA,SAAO;AACT;AAEO,SAAS,eAAe;AAC7B,aAAO,sBAAO;AAAA,IACZ,SAAS;AAAA,MACP,gBAAY,gCAAe;AAAA,QACzB,OAAO;AAAA,QACP,SAAS;AAAA,MACX,CAAC;AAAA,MACD;AAAA,MACA;AAAA,MACA,iBAAiB,CAAC,gBAChB,oCAAsB,OAAO,IAAI,QAAQ,OAAO;AAAA,IACpD;AAAA,IACA,YAAY;AAAA,IACZ,eAAe,mBAAiB,WAAS;AACvC,aAAO,4CAAC,yBAAuB,GAAG,OAAO,eAA8B;AAAA,IACzE;AAAA,EACF,CAAC;AACH;AAEA,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA,GAAG;AACL,GAA0D;AACxD,UAAQ,MAAM,QAAQ,MAAM;AAAA,IAC1B,KAAK,sBAAM,WAAW;AACpB,aAAO,4CAAC,UAAM,GAAG,MAAM,YAAa,wBAAc,KAAK,GAAE;AAAA,IAE3D,KAAK,sBAAM,WAAW;AACpB,aAAO,4CAAC,SAAK,GAAG,MAAM,YAAa,wBAAc,KAAK,GAAE;AAAA,IAE1D,KAAK,sBAAM,WAAW;AACpB,aAAO,4CAAC,SAAK,GAAG,MAAM,YAAa,wBAAc,KAAK,GAAE;AAAA,IAE1D;AACE,aAAO,2EAAG,wBAAc,KAAK,GAAE;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -27,17 +27,17 @@ module.exports = __toCommonJS(types_exports);
|
|
|
27
27
|
var import_controls = require("@makeswift/controls");
|
|
28
28
|
const supportedInlineOptions = [
|
|
29
29
|
{
|
|
30
|
-
icon: import_controls.
|
|
30
|
+
icon: import_controls.IconRadioGroup.Icon.Superscript,
|
|
31
31
|
label: "Superscript",
|
|
32
32
|
value: "superscript"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
icon: import_controls.
|
|
35
|
+
icon: import_controls.IconRadioGroup.Icon.Subscript,
|
|
36
36
|
label: "Subscript",
|
|
37
37
|
value: "subscript"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
icon: import_controls.
|
|
40
|
+
icon: import_controls.IconRadioGroup.Icon.Code,
|
|
41
41
|
label: "Code",
|
|
42
42
|
value: "code"
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/InlinePlugin/types.ts"],"sourcesContent":["import { Slate,
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/InlinePlugin/types.ts"],"sourcesContent":["import { Slate, IconRadioGroup } from '@makeswift/controls'\nimport { Node, NodeEntry } from 'slate'\n\nexport type SupportedInlineType = Exclude<Slate.InlineType, 'link'>\nexport type SupportedInline = Exclude<Slate.Inline, Slate.LinkElement>\n\nexport const supportedInlineOptions = [\n {\n icon: IconRadioGroup.Icon.Superscript,\n label: 'Superscript',\n value: 'superscript',\n },\n {\n icon: IconRadioGroup.Icon.Subscript,\n label: 'Subscript',\n value: 'subscript',\n },\n {\n icon: IconRadioGroup.Icon.Code,\n label: 'Code',\n value: 'code',\n },\n] as const\n\nexport function isSupportedInlineType(inline: Slate.InlineType): inline is SupportedInlineType {\n return supportedInlineOptions.findIndex(option => option.value === inline) !== -1\n}\n\nexport function isSupportedInlineNode(node: Node): node is SupportedInline {\n return Slate.isInline(node) && isSupportedInlineType(node.type)\n}\n\nexport function isSupportedInlineEntry(\n entry: NodeEntry<Node>,\n): entry is NodeEntry<SupportedInline> {\n return isSupportedInlineNode(entry[0])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsC;AAM/B,MAAM,yBAAyB;AAAA,EACpC;AAAA,IACE,MAAM,+BAAe,KAAK;AAAA,IAC1B,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM,+BAAe,KAAK;AAAA,IAC1B,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM,+BAAe,KAAK;AAAA,IAC1B,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AACF;AAEO,SAAS,sBAAsB,QAAyD;AAC7F,SAAO,uBAAuB,UAAU,YAAU,OAAO,UAAU,MAAM,MAAM;AACjF;AAEO,SAAS,sBAAsB,MAAqC;AACzE,SAAO,sBAAM,SAAS,IAAI,KAAK,sBAAsB,KAAK,IAAI;AAChE;AAEO,SAAS,uBACd,OACqC;AACrC,SAAO,sBAAsB,MAAM,CAAC,CAAC;AACvC;","names":[]}
|
|
@@ -44,26 +44,26 @@ function TextAlignPlugin() {
|
|
|
44
44
|
return (0, import_plugin.Plugin)({
|
|
45
45
|
control: {
|
|
46
46
|
definition: (0, import_style_v2.unstable_StyleV2)({
|
|
47
|
-
type: (0, import_controls.
|
|
47
|
+
type: (0, import_controls.IconRadioGroup)({
|
|
48
48
|
label: "Alignment",
|
|
49
49
|
options: [
|
|
50
50
|
{
|
|
51
|
-
icon: import_controls.
|
|
51
|
+
icon: import_controls.IconRadioGroup.Icon.TextAlignLeft,
|
|
52
52
|
label: "Left Align",
|
|
53
53
|
value: "left"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
icon: import_controls.
|
|
56
|
+
icon: import_controls.IconRadioGroup.Icon.TextAlignCenter,
|
|
57
57
|
label: "Center Align",
|
|
58
58
|
value: "center"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
icon: import_controls.
|
|
61
|
+
icon: import_controls.IconRadioGroup.Icon.TextAlignRight,
|
|
62
62
|
label: "Right Align",
|
|
63
63
|
value: "right"
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
|
-
icon: import_controls.
|
|
66
|
+
icon: import_controls.IconRadioGroup.Icon.TextAlignJustify,
|
|
67
67
|
label: "Justify",
|
|
68
68
|
value: "justify"
|
|
69
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/slate/TextAlignPlugin/index.tsx"],"sourcesContent":["import { Editor, Element, NodeEntry } from 'slate'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/slate/TextAlignPlugin/index.tsx"],"sourcesContent":["import { Editor, Element, NodeEntry } from 'slate'\nimport { IconRadioGroup, Slate } from '@makeswift/controls'\n\nimport { unstable_StyleV2 } from '../../controls/style-v2/style-v2'\nimport { normalizeResponsiveValue, setResponsiveValue } from '../utils/responsive'\nimport { getValue } from './getValue'\nimport { Plugin } from '../../controls/rich-text-v2/plugin'\n\nconst TEXT_ALIGN_KEY = 'textAlign'\n\nexport const withTextAlign = (editor: Editor) => {\n const { normalizeNode } = editor\n editor.normalizeNode = entry => {\n if (\n normalizeResponsiveValue(editor, TEXT_ALIGN_KEY, { match: Slate.isRootBlock })(\n entry as NodeEntry<Slate.RootBlock>,\n )\n ) {\n return\n }\n normalizeNode(entry)\n }\n\n return editor\n}\n\nexport function TextAlignPlugin() {\n return Plugin({\n control: {\n definition: unstable_StyleV2({\n type: IconRadioGroup({\n label: 'Alignment',\n options: [\n {\n icon: IconRadioGroup.Icon.TextAlignLeft,\n label: 'Left Align',\n value: 'left',\n },\n {\n icon: IconRadioGroup.Icon.TextAlignCenter,\n label: 'Center Align',\n value: 'center',\n },\n {\n icon: IconRadioGroup.Icon.TextAlignRight,\n label: 'Right Align',\n value: 'right',\n },\n {\n icon: IconRadioGroup.Icon.TextAlignJustify,\n label: 'Justify',\n value: 'justify',\n },\n ],\n defaultValue: 'left',\n }),\n getStyle(textAlign) {\n return { textAlign }\n },\n }),\n onChange: (editor, value) =>\n setResponsiveValue(editor, TEXT_ALIGN_KEY, value, {\n match: Slate.isRootBlock,\n split: false,\n }),\n getValue,\n getElementValue: (element: Element) => {\n return Slate.isRootBlock(element) ? element.textAlign : undefined\n },\n },\n withPlugin: withTextAlign,\n renderElement: (renderElement, className) => props => {\n return renderElement({\n ...props,\n element: {\n ...props.element,\n className,\n },\n })\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAsC;AAEtC,sBAAiC;AACjC,wBA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ACpD,aAAO,cAAc;AAAA,QACnB,GAAG;AAAA,QACH,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/state/actions/internal/read-write-actions.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type Measurable } from '../../modules/read-write/box-models'\nimport { type DescriptorsByComponentType } from '../../modules/prop-controllers'\n\nimport { type DocumentPayload } from '../../shared-api'\nimport { type SerializedState as APIClientCache } from '../../
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/actions/internal/read-write-actions.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type Measurable } from '../../modules/read-write/box-models'\nimport { type DescriptorsByComponentType } from '../../modules/prop-controllers'\n\nimport { type DocumentPayload } from '../../shared-api'\nimport { type SerializedState as APIClientCache } from '../../api-client/state'\n\nexport const ReadWriteActionTypes = {\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n CLEAR_API_CLIENT_CACHE: 'CLEAR_API_CLIENT_CACHE',\n} as const\n\ntype ChangeElementTreeAction = {\n type: typeof ReadWriteActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UpdateAPIClientCache = {\n type: typeof ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\ntype ClearAPIClientCache = {\n type: typeof ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE\n}\n\nexport type ReadWriteAction =\n | ChangeElementTreeAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | UpdateAPIClientCache\n | ClearAPIClientCache\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: ReadWriteActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return {\n type: ReadWriteActionTypes.REGISTER_MEASURABLE,\n payload: { documentKey, elementKey, measurable },\n }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: ReadWriteActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, ReadWriteAction> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\n\nexport function clearAPIClientCache(): ClearAPIClientCache {\n return { type: ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,uBAAuB;AAAA,EAClC,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EAEvB,yBAAyB;AAAA,EACzB,wBAAwB;AAC1B;AAsCO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,qBAAqB;AAAA,IAC3B;AAAA,EACF;AACF;AAEO,SAAS,mBACd,aACA,YACA,YAC0B;AAC1B,SAAO;AAAA,IACL,MAAM,qBAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,WAAW;AAAA,EACjD;AACF;AAEO,SAAS,qBACd,aACA,YAC4B;AAC5B,SAAO,EAAE,MAAM,qBAAqB,uBAAuB,SAAS,EAAE,aAAa,WAAW,EAAE;AAClG;AAEO,SAAS,yBACd,aACA,YACA,YAC4D;AAC5D,SAAO,cAAY;AACjB,aAAS,mBAAmB,aAAa,YAAY,UAAU,CAAC;AAEhE,WAAO,MAAM;AACX,eAAS,qBAAqB,aAAa,UAAU,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,qBAAqB,yBAAyB,QAAQ;AACvE;AAEO,SAAS,sBAA2C;AACzD,SAAO,EAAE,MAAM,qBAAqB,uBAAuB;AAC7D;","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var client_store_exports = {};
|
|
30
|
+
__export(client_store_exports, {
|
|
31
|
+
configureClientStore: () => configureClientStore
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(client_store_exports);
|
|
34
|
+
var import_toolkit = require("@reduxjs/toolkit");
|
|
35
|
+
var LocaleState = __toESM(require("../modules/locale"));
|
|
36
|
+
var import_actions = require("../actions");
|
|
37
|
+
var import_toolkit2 = require("../toolkit");
|
|
38
|
+
var import_state = require("./state");
|
|
39
|
+
function defaultLocaleMiddleware() {
|
|
40
|
+
return (0, import_toolkit2.actionMiddleware)(({ getState }) => (next) => {
|
|
41
|
+
return (action) => {
|
|
42
|
+
switch (action.type) {
|
|
43
|
+
case import_actions.ActionTypes.CHANGE_API_RESOURCE:
|
|
44
|
+
case import_actions.ActionTypes.EVICT_API_RESOURCE:
|
|
45
|
+
case import_actions.ActionTypes.SET_LOCALIZED_RESOURCE_ID: {
|
|
46
|
+
const { locale } = action.payload;
|
|
47
|
+
return next({
|
|
48
|
+
...action,
|
|
49
|
+
payload: {
|
|
50
|
+
...action.payload,
|
|
51
|
+
locale: locale ?? LocaleState.getLocale(getState().locale)
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return next(action);
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function configureClientStore({
|
|
61
|
+
preloadedState
|
|
62
|
+
}) {
|
|
63
|
+
return (0, import_toolkit.configureStore)({
|
|
64
|
+
reducer: import_state.reducer,
|
|
65
|
+
preloadedState,
|
|
66
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(defaultLocaleMiddleware()),
|
|
67
|
+
devTools: (0, import_toolkit2.devToolsConfig)({
|
|
68
|
+
name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
|
|
69
|
+
actionsDenylist: [
|
|
70
|
+
import_actions.ActionTypes.BUILDER_POINTER_MOVE,
|
|
71
|
+
import_actions.ActionTypes.HANDLE_POINTER_MOVE,
|
|
72
|
+
import_actions.ActionTypes.ELEMENT_FROM_POINT_CHANGE
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
configureClientStore
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=client-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/api-client/client-store.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n type ThunkMiddleware,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport * as LocaleState from '../modules/locale'\n\nimport { type Action, ActionTypes } from '../actions'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from '../toolkit'\n\nimport { type State, reducer } from './state'\nimport { type Store } from './store'\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 configureClientStore({\n preloadedState,\n}: {\n preloadedState: Partial<State>\n}): Store {\n return configureReduxStore({\n reducer,\n preloadedState,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAIO;AAEP,kBAA6B;AAE7B,qBAAyC;AACzC,IAAAA,kBAAoE;AAEpE,mBAAoC;AAKpC,SAAS,0BAAiE;AACxE,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,2BAAY;AAAA,QACjB,KAAK,2BAAY;AAAA,QACjB,KAAK,2BAAY,2BAA2B;AAC1C,gBAAM,EAAE,OAAO,IAAI,OAAO;AAC1B,iBAAO,KAAK;AAAA,YACV,GAAG;AAAA,YACH,SAAS;AAAA,cACP,GAAG,OAAO;AAAA,cACV,QAAQ,UAAU,YAAY,UAAU,SAAS,EAAE,MAAM;AAAA,YAC3D;AAAA,UACF,CAAW;AAAA,QACb;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEO,SAAS,qBAAqB;AAAA,EACnC;AACF,GAEU;AACR,aAAO,eAAAC,gBAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IAEA,YAAY,0BACV,qBAAqB,iCAAiB,EAAE,OAAO,wBAAwB,CAAC;AAAA,IAE1E,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"]}
|
|
@@ -26,64 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
32
|
-
fetchAPIResource: () => fetchAPIResource,
|
|
33
|
-
getAPIResource: () => getAPIResource,
|
|
34
|
-
getHasAPIResource: () => getHasAPIResource
|
|
29
|
+
var fetch_api_resource_exports = {};
|
|
30
|
+
__export(fetch_api_resource_exports, {
|
|
31
|
+
fetchAPIResource: () => fetchAPIResource
|
|
35
32
|
});
|
|
36
|
-
module.exports = __toCommonJS(
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var import_actions = require("./actions");
|
|
44
|
-
var import_read_only_actions = require("./actions/internal/read-only-actions");
|
|
45
|
-
var import_host_api = require("./host-api");
|
|
46
|
-
var import_toolkit2 = require("./toolkit");
|
|
47
|
-
var import_api = require("../api");
|
|
48
|
-
const reducer = (0, import_toolkit.combineReducers)({
|
|
49
|
-
siteVersion: SiteVersionState.reducer,
|
|
50
|
-
locale: LocaleState.reducer,
|
|
51
|
-
apiResources: APIResources.reducer,
|
|
52
|
-
localizedResourcesMap: LocalizedResourcesMap.reducer
|
|
53
|
-
});
|
|
54
|
-
function getLocalizedResourceId(state, locale, resourceId) {
|
|
55
|
-
return LocalizedResourcesMap.getLocalizedResourceId(
|
|
56
|
-
state.localizedResourcesMap,
|
|
57
|
-
locale,
|
|
58
|
-
resourceId
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
function getHasAPIResource(state, resourceType, resourceId, locale) {
|
|
62
|
-
switch (resourceType) {
|
|
63
|
-
case import_api.APIResourceType.LocalizedGlobalElement:
|
|
64
|
-
if (locale == null) {
|
|
65
|
-
console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
const localizedId = getLocalizedResourceId(state, locale, resourceId);
|
|
69
|
-
return localizedId != null && APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale);
|
|
70
|
-
default:
|
|
71
|
-
return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function getAPIResource(state, resourceType, resourceId, locale) {
|
|
75
|
-
switch (resourceType) {
|
|
76
|
-
case import_api.APIResourceType.LocalizedGlobalElement:
|
|
77
|
-
if (locale == null) {
|
|
78
|
-
console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
const localizedId = getLocalizedResourceId(state, locale, resourceId);
|
|
82
|
-
return localizedId != null ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale) : null;
|
|
83
|
-
default:
|
|
84
|
-
return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
33
|
+
module.exports = __toCommonJS(fetch_api_resource_exports);
|
|
34
|
+
var import_site_version = require("../../api/site-version");
|
|
35
|
+
var SiteVersionState = __toESM(require("../modules/site-version"));
|
|
36
|
+
var import_read_only_actions = require("../actions/internal/read-only-actions");
|
|
37
|
+
var import_host_api = require("../host-api");
|
|
38
|
+
var import_api = require("../../api");
|
|
39
|
+
var import_state = require("./state");
|
|
87
40
|
function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
88
41
|
const fetchVersioned = async (url, version) => {
|
|
89
42
|
const response = await fetch(url, {
|
|
@@ -106,8 +59,8 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
106
59
|
return async (dispatch, getState) => {
|
|
107
60
|
const state = getState();
|
|
108
61
|
const version = SiteVersionState.getSiteVersion(state.siteVersion);
|
|
109
|
-
if (getHasAPIResource(state, resourceType, resourceId, locale)) {
|
|
110
|
-
return getAPIResource(state, resourceType, resourceId, locale);
|
|
62
|
+
if ((0, import_state.getHasAPIResource)(state, resourceType, resourceId, locale)) {
|
|
63
|
+
return (0, import_state.getAPIResource)(state, resourceType, resourceId, locale);
|
|
111
64
|
}
|
|
112
65
|
let resource;
|
|
113
66
|
switch (resourceType) {
|
|
@@ -132,7 +85,7 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
132
85
|
case import_api.APIResourceType.LocalizedGlobalElement: {
|
|
133
86
|
if (locale == null)
|
|
134
87
|
throw new Error("Locale is required to fetch LocalizedGlobalElement");
|
|
135
|
-
if (getLocalizedResourceId(state, locale, resourceId) === null) {
|
|
88
|
+
if ((0, import_state.getLocalizedResourceId)(state, locale, resourceId) === null) {
|
|
136
89
|
return null;
|
|
137
90
|
}
|
|
138
91
|
resource = await fetchVersioned(
|
|
@@ -165,47 +118,8 @@ function fetchAPIResource(resourceType, resourceId, fetch, locale) {
|
|
|
165
118
|
return resource;
|
|
166
119
|
};
|
|
167
120
|
}
|
|
168
|
-
function defaultLocaleMiddleware() {
|
|
169
|
-
return (0, import_toolkit2.actionMiddleware)(({ getState }) => (next) => {
|
|
170
|
-
return (action) => {
|
|
171
|
-
switch (action.type) {
|
|
172
|
-
case import_actions.ActionTypes.CHANGE_API_RESOURCE:
|
|
173
|
-
case import_actions.ActionTypes.EVICT_API_RESOURCE:
|
|
174
|
-
case import_actions.ActionTypes.SET_LOCALIZED_RESOURCE_ID: {
|
|
175
|
-
const { locale } = action.payload;
|
|
176
|
-
return next({
|
|
177
|
-
...action,
|
|
178
|
-
payload: {
|
|
179
|
-
...action.payload,
|
|
180
|
-
locale: locale ?? LocaleState.getLocale(getState().locale)
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return next(action);
|
|
186
|
-
};
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
function configureStore({ preloadedState }) {
|
|
190
|
-
return (0, import_toolkit.configureStore)({
|
|
191
|
-
reducer,
|
|
192
|
-
preloadedState,
|
|
193
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(defaultLocaleMiddleware()),
|
|
194
|
-
devTools: (0, import_toolkit2.devToolsConfig)({
|
|
195
|
-
name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
|
|
196
|
-
actionsDenylist: [
|
|
197
|
-
import_actions.ActionTypes.BUILDER_POINTER_MOVE,
|
|
198
|
-
import_actions.ActionTypes.HANDLE_POINTER_MOVE,
|
|
199
|
-
import_actions.ActionTypes.ELEMENT_FROM_POINT_CHANGE
|
|
200
|
-
]
|
|
201
|
-
})
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
121
|
// Annotate the CommonJS export names for ESM import in node:
|
|
205
122
|
0 && (module.exports = {
|
|
206
|
-
|
|
207
|
-
fetchAPIResource,
|
|
208
|
-
getAPIResource,
|
|
209
|
-
getHasAPIResource
|
|
123
|
+
fetchAPIResource
|
|
210
124
|
});
|
|
211
|
-
//# sourceMappingURL=
|
|
125
|
+
//# sourceMappingURL=fetch-api-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/api-client/fetch-api-resource.ts"],"sourcesContent":["import { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { type SiteVersion, ApiHandlerHeaders, serializeSiteVersion } from '../../api/site-version'\n\nimport * as SiteVersionState from '../modules/site-version'\n\nimport { type Action } from '../actions'\nimport { apiResourceFulfilled } from '../actions/internal/read-only-actions'\nimport { setLocalizedResourceId } from '../host-api'\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\nimport { type State, getHasAPIResource, getAPIResource, getLocalizedResourceId } from './state'\n\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAA0E;AAE1E,uBAAkC;AAGlC,+BAAqC;AACrC,sBAAuC;AAEvC,iBAWO;AAEP,mBAAsF;AAM/E,SAAS,iBACd,cACA,YACA,OACA,QACgE;AAChE,QAAM,iBAAiB,OAAU,KAAa,YAAmD;AAC/F,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,GAAI,WAAW,OACX,EAAE,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