@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
|
@@ -0,0 +1,160 @@
|
|
|
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 api_resources_client_exports = {};
|
|
30
|
+
__export(api_resources_client_exports, {
|
|
31
|
+
ApiResourcesClient: () => ApiResourcesClient,
|
|
32
|
+
CacheData: () => CacheData
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(api_resources_client_exports);
|
|
35
|
+
var ApiClientState = __toESM(require("../state/api-client/state"));
|
|
36
|
+
var import_types = require("./types");
|
|
37
|
+
const CacheData = {
|
|
38
|
+
empty() {
|
|
39
|
+
return {
|
|
40
|
+
apiResources: {},
|
|
41
|
+
localizedResourcesMap: {}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
class ApiResourcesClient {
|
|
46
|
+
store;
|
|
47
|
+
subscribe;
|
|
48
|
+
constructor({ store }) {
|
|
49
|
+
this.store = store;
|
|
50
|
+
this.subscribe = this.store.subscribe;
|
|
51
|
+
}
|
|
52
|
+
readSwatch(swatchId) {
|
|
53
|
+
return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Swatch, swatchId);
|
|
54
|
+
}
|
|
55
|
+
resolveSwatch(swatchId) {
|
|
56
|
+
return this.resolveResource(import_types.APIResourceType.Swatch, {
|
|
57
|
+
id: swatchId,
|
|
58
|
+
read: (id) => this.readSwatch(id),
|
|
59
|
+
fetch: (id) => this.fetchSwatch(id)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
readFile(fileId) {
|
|
63
|
+
return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.File, fileId);
|
|
64
|
+
}
|
|
65
|
+
resolveFile(fileId) {
|
|
66
|
+
return this.resolveResource(import_types.APIResourceType.File, {
|
|
67
|
+
id: fileId,
|
|
68
|
+
read: (id) => this.readFile(id),
|
|
69
|
+
fetch: (id) => this.fetchFile(id)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
readTypography(typographyId) {
|
|
73
|
+
return ApiClientState.getAPIResource(
|
|
74
|
+
this.store.getState(),
|
|
75
|
+
import_types.APIResourceType.Typography,
|
|
76
|
+
typographyId
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
resolveTypography(typographyId) {
|
|
80
|
+
return this.resolveResource(import_types.APIResourceType.Typography, {
|
|
81
|
+
id: typographyId,
|
|
82
|
+
read: (id) => this.readTypography(id),
|
|
83
|
+
fetch: (id) => this.fetchTypography(id)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
readGlobalElement(globalElementId) {
|
|
87
|
+
return ApiClientState.getAPIResource(
|
|
88
|
+
this.store.getState(),
|
|
89
|
+
import_types.APIResourceType.GlobalElement,
|
|
90
|
+
globalElementId
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
readLocalizedGlobalElement({
|
|
94
|
+
globalElementId,
|
|
95
|
+
locale
|
|
96
|
+
}) {
|
|
97
|
+
return ApiClientState.getAPIResource(
|
|
98
|
+
this.store.getState(),
|
|
99
|
+
import_types.APIResourceType.LocalizedGlobalElement,
|
|
100
|
+
globalElementId,
|
|
101
|
+
locale
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
readPagePathnameSlice({
|
|
105
|
+
pageId,
|
|
106
|
+
locale
|
|
107
|
+
}) {
|
|
108
|
+
return ApiClientState.getAPIResource(
|
|
109
|
+
this.store.getState(),
|
|
110
|
+
import_types.APIResourceType.PagePathnameSlice,
|
|
111
|
+
pageId,
|
|
112
|
+
locale
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
resolvePagePathnameSlice({
|
|
116
|
+
pageId,
|
|
117
|
+
locale
|
|
118
|
+
}) {
|
|
119
|
+
return this.resolveResource(import_types.APIResourceType.PagePathnameSlice, {
|
|
120
|
+
id: pageId,
|
|
121
|
+
read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
|
|
122
|
+
fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
resolveResource(type, {
|
|
126
|
+
id,
|
|
127
|
+
read,
|
|
128
|
+
fetch
|
|
129
|
+
}) {
|
|
130
|
+
const _read = () => id != null ? read(id) : null;
|
|
131
|
+
let lastValue = null;
|
|
132
|
+
return {
|
|
133
|
+
name: `${type}:${id}`,
|
|
134
|
+
readStable: () => lastValue = _read(),
|
|
135
|
+
subscribe: (onUpdate) => this.subscribe(() => {
|
|
136
|
+
if (_read() !== lastValue)
|
|
137
|
+
onUpdate();
|
|
138
|
+
}),
|
|
139
|
+
fetch: async () => id != null ? fetch(id) : null
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
readTable(tableId) {
|
|
143
|
+
return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Table, tableId);
|
|
144
|
+
}
|
|
145
|
+
readSite(siteId) {
|
|
146
|
+
return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Site, siteId);
|
|
147
|
+
}
|
|
148
|
+
readPage(pageId) {
|
|
149
|
+
return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Page, pageId);
|
|
150
|
+
}
|
|
151
|
+
readSnippet(snippetId) {
|
|
152
|
+
return ApiClientState.getAPIResource(this.store.getState(), import_types.APIResourceType.Snippet, snippetId);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
+
0 && (module.exports = {
|
|
157
|
+
ApiResourcesClient,
|
|
158
|
+
CacheData
|
|
159
|
+
});
|
|
160
|
+
//# sourceMappingURL=api-resources-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/api-resources-client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport { type Store as ApiClientStore } from '../state/api-client/store'\nimport * as ApiClientState from '../state/api-client/state'\n\nimport {\n type File,\n type GlobalElement,\n type LocalizedGlobalElement,\n type Page,\n type PagePathnameSlice,\n type Site,\n type Snippet,\n type Swatch,\n type Table,\n type Typography,\n APIResourceType,\n} from './types'\n\nexport type CacheData = ApiClientState.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\nexport abstract class ApiResourcesClient {\n readonly store: ApiClientStore\n readonly subscribe: ApiClientStore['subscribe']\n\n constructor({ store }: { store: ApiClientStore }) {\n this.store = store\n this.subscribe = this.store.subscribe\n }\n\n abstract fetchSwatch(swatchId: string): Promise<Swatch | null>\n\n readSwatch(swatchId: string): Swatch | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Swatch, swatchId)\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 abstract fetchFile(fileId: string): Promise<File | null>\n\n readFile(fileId: string): File | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.File, fileId)\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 abstract fetchTypography(typographyId: string): Promise<Typography | null>\n\n readTypography(typographyId: string): Typography | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.Typography,\n typographyId,\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 abstract fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null>\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n abstract fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null>\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return ApiClientState.getAPIResource(\n this.store.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n abstract fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null>\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 abstract fetchTable(tableId: string): Promise<Table | null>\n\n readTable(tableId: string): Table | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Table, tableId)\n }\n\n readSite(siteId: string): Site | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Site, siteId)\n }\n\n readPage(pageId: string): Page | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Page, pageId)\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Snippet, snippetId)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAgC;AAEhC,mBAYO;AAIA,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AACO,MAA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MAAM,MAAM;AAAA,EAC1F;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,6BAAgB,MAAM,MAAM;AAAA,EAC1F;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,6BAAgB,SAAS,SAAS;AAAA,EAChG;AACF;","names":[]}
|
package/dist/cjs/api/client.js
CHANGED
|
@@ -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,232 +15,72 @@ 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 client_exports = {};
|
|
30
20
|
__export(client_exports, {
|
|
31
|
-
CacheData: () => CacheData,
|
|
21
|
+
CacheData: () => import_api_resources_client2.CacheData,
|
|
32
22
|
MakeswiftHostApiClient: () => MakeswiftHostApiClient
|
|
33
23
|
});
|
|
34
24
|
module.exports = __toCommonJS(client_exports);
|
|
35
|
-
var
|
|
25
|
+
var import_fetch_api_resource = require("../state/api-client/fetch-api-resource");
|
|
26
|
+
var import_client_store = require("../state/api-client/client-store");
|
|
36
27
|
var import_types = require("./types");
|
|
37
28
|
var import_client = require("./graphql/client");
|
|
38
29
|
var import_documents = require("./graphql/documents");
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
apiResources: {},
|
|
43
|
-
localizedResourcesMap: {}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
class MakeswiftHostApiClient {
|
|
30
|
+
var import_api_resources_client = require("./api-resources-client");
|
|
31
|
+
var import_api_resources_client2 = require("./api-resources-client");
|
|
32
|
+
class MakeswiftHostApiClient extends import_api_resources_client.ApiResourcesClient {
|
|
48
33
|
graphqlClient;
|
|
49
|
-
makeswiftApiClient;
|
|
50
|
-
subscribe;
|
|
51
34
|
fetch;
|
|
52
35
|
constructor({
|
|
53
36
|
uri,
|
|
54
37
|
fetch,
|
|
55
38
|
preloadedState
|
|
56
39
|
}) {
|
|
40
|
+
super({
|
|
41
|
+
store: (0, import_client_store.configureClientStore)({ preloadedState })
|
|
42
|
+
});
|
|
57
43
|
this.graphqlClient = new import_client.GraphQLClient(uri);
|
|
58
|
-
this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState });
|
|
59
44
|
this.fetch = fetch;
|
|
60
|
-
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
61
|
-
}
|
|
62
|
-
readSwatch(swatchId) {
|
|
63
|
-
return MakeswiftApiClient.getAPIResource(
|
|
64
|
-
this.makeswiftApiClient.getState(),
|
|
65
|
-
import_types.APIResourceType.Swatch,
|
|
66
|
-
swatchId
|
|
67
|
-
);
|
|
68
45
|
}
|
|
69
46
|
async fetchSwatch(swatchId) {
|
|
70
|
-
return await this.
|
|
71
|
-
MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Swatch, swatchId, this.fetch)
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
resolveSwatch(swatchId) {
|
|
75
|
-
return this.resolveResource(import_types.APIResourceType.Swatch, {
|
|
76
|
-
id: swatchId,
|
|
77
|
-
read: (id) => this.readSwatch(id),
|
|
78
|
-
fetch: (id) => this.fetchSwatch(id)
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
readFile(fileId) {
|
|
82
|
-
return MakeswiftApiClient.getAPIResource(
|
|
83
|
-
this.makeswiftApiClient.getState(),
|
|
84
|
-
import_types.APIResourceType.File,
|
|
85
|
-
fileId
|
|
86
|
-
);
|
|
47
|
+
return await this.store.dispatch((0, import_fetch_api_resource.fetchAPIResource)(import_types.APIResourceType.Swatch, swatchId, this.fetch));
|
|
87
48
|
}
|
|
88
49
|
async fetchFile(fileId) {
|
|
89
|
-
return await this.
|
|
90
|
-
MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.File, fileId, this.fetch)
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
resolveFile(fileId) {
|
|
94
|
-
return this.resolveResource(import_types.APIResourceType.File, {
|
|
95
|
-
id: fileId,
|
|
96
|
-
read: (id) => this.readFile(id),
|
|
97
|
-
fetch: (id) => this.fetchFile(id)
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
readTypography(typographyId) {
|
|
101
|
-
return MakeswiftApiClient.getAPIResource(
|
|
102
|
-
this.makeswiftApiClient.getState(),
|
|
103
|
-
import_types.APIResourceType.Typography,
|
|
104
|
-
typographyId
|
|
105
|
-
);
|
|
50
|
+
return await this.store.dispatch((0, import_fetch_api_resource.fetchAPIResource)(import_types.APIResourceType.File, fileId, this.fetch));
|
|
106
51
|
}
|
|
107
52
|
async fetchTypography(typographyId) {
|
|
108
|
-
return await this.
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
resolveTypography(typographyId) {
|
|
113
|
-
return this.resolveResource(import_types.APIResourceType.Typography, {
|
|
114
|
-
id: typographyId,
|
|
115
|
-
read: (id) => this.readTypography(id),
|
|
116
|
-
fetch: (id) => this.fetchTypography(id)
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
readGlobalElement(globalElementId) {
|
|
120
|
-
return MakeswiftApiClient.getAPIResource(
|
|
121
|
-
this.makeswiftApiClient.getState(),
|
|
122
|
-
import_types.APIResourceType.GlobalElement,
|
|
123
|
-
globalElementId
|
|
53
|
+
return await this.store.dispatch(
|
|
54
|
+
(0, import_fetch_api_resource.fetchAPIResource)(import_types.APIResourceType.Typography, typographyId, this.fetch)
|
|
124
55
|
);
|
|
125
56
|
}
|
|
126
57
|
async fetchGlobalElement(globalElementId) {
|
|
127
|
-
return await this.
|
|
128
|
-
|
|
129
|
-
import_types.APIResourceType.GlobalElement,
|
|
130
|
-
globalElementId,
|
|
131
|
-
this.fetch
|
|
132
|
-
)
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
readLocalizedGlobalElement({
|
|
136
|
-
globalElementId,
|
|
137
|
-
locale
|
|
138
|
-
}) {
|
|
139
|
-
return MakeswiftApiClient.getAPIResource(
|
|
140
|
-
this.makeswiftApiClient.getState(),
|
|
141
|
-
import_types.APIResourceType.LocalizedGlobalElement,
|
|
142
|
-
globalElementId,
|
|
143
|
-
locale
|
|
58
|
+
return await this.store.dispatch(
|
|
59
|
+
(0, import_fetch_api_resource.fetchAPIResource)(import_types.APIResourceType.GlobalElement, globalElementId, this.fetch)
|
|
144
60
|
);
|
|
145
61
|
}
|
|
146
62
|
async fetchLocalizedGlobalElement({
|
|
147
63
|
globalElementId,
|
|
148
64
|
locale
|
|
149
65
|
}) {
|
|
150
|
-
return await this.
|
|
151
|
-
|
|
152
|
-
import_types.APIResourceType.LocalizedGlobalElement,
|
|
153
|
-
globalElementId,
|
|
154
|
-
this.fetch,
|
|
155
|
-
locale
|
|
156
|
-
)
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
readPagePathnameSlice({
|
|
160
|
-
pageId,
|
|
161
|
-
locale
|
|
162
|
-
}) {
|
|
163
|
-
return MakeswiftApiClient.getAPIResource(
|
|
164
|
-
this.makeswiftApiClient.getState(),
|
|
165
|
-
import_types.APIResourceType.PagePathnameSlice,
|
|
166
|
-
pageId,
|
|
167
|
-
locale
|
|
66
|
+
return await this.store.dispatch(
|
|
67
|
+
(0, import_fetch_api_resource.fetchAPIResource)(import_types.APIResourceType.LocalizedGlobalElement, globalElementId, this.fetch, locale)
|
|
168
68
|
);
|
|
169
69
|
}
|
|
170
70
|
async fetchPagePathnameSlice({
|
|
171
71
|
pageId,
|
|
172
72
|
locale
|
|
173
73
|
}) {
|
|
174
|
-
return await this.
|
|
175
|
-
|
|
176
|
-
import_types.APIResourceType.PagePathnameSlice,
|
|
177
|
-
pageId,
|
|
178
|
-
this.fetch,
|
|
179
|
-
locale
|
|
180
|
-
)
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
resolvePagePathnameSlice({
|
|
184
|
-
pageId,
|
|
185
|
-
locale
|
|
186
|
-
}) {
|
|
187
|
-
return this.resolveResource(import_types.APIResourceType.PagePathnameSlice, {
|
|
188
|
-
id: pageId,
|
|
189
|
-
read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
|
|
190
|
-
fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
resolveResource(type, {
|
|
194
|
-
id,
|
|
195
|
-
read,
|
|
196
|
-
fetch
|
|
197
|
-
}) {
|
|
198
|
-
const _read = () => id != null ? read(id) : null;
|
|
199
|
-
let lastValue = null;
|
|
200
|
-
return {
|
|
201
|
-
name: `${type}:${id}`,
|
|
202
|
-
readStable: () => lastValue = _read(),
|
|
203
|
-
subscribe: (onUpdate) => this.subscribe(() => {
|
|
204
|
-
if (_read() !== lastValue)
|
|
205
|
-
onUpdate();
|
|
206
|
-
}),
|
|
207
|
-
fetch: async () => id != null ? fetch(id) : null
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
readTable(tableId) {
|
|
211
|
-
return MakeswiftApiClient.getAPIResource(
|
|
212
|
-
this.makeswiftApiClient.getState(),
|
|
213
|
-
import_types.APIResourceType.Table,
|
|
214
|
-
tableId
|
|
74
|
+
return await this.store.dispatch(
|
|
75
|
+
(0, import_fetch_api_resource.fetchAPIResource)(import_types.APIResourceType.PagePathnameSlice, pageId, this.fetch, locale)
|
|
215
76
|
);
|
|
216
77
|
}
|
|
217
78
|
async fetchTable(tableId) {
|
|
218
|
-
return await this.
|
|
219
|
-
MakeswiftApiClient.fetchAPIResource(import_types.APIResourceType.Table, tableId, this.fetch)
|
|
220
|
-
);
|
|
79
|
+
return await this.store.dispatch((0, import_fetch_api_resource.fetchAPIResource)(import_types.APIResourceType.Table, tableId, this.fetch));
|
|
221
80
|
}
|
|
222
81
|
async createTableRecord(tableId, columns) {
|
|
223
82
|
await this.graphqlClient.request(import_documents.CreateTableRecordMutation, { input: { data: { tableId, columns } } });
|
|
224
83
|
}
|
|
225
|
-
readSite(siteId) {
|
|
226
|
-
return MakeswiftApiClient.getAPIResource(
|
|
227
|
-
this.makeswiftApiClient.getState(),
|
|
228
|
-
import_types.APIResourceType.Site,
|
|
229
|
-
siteId
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
readPage(pageId) {
|
|
233
|
-
return MakeswiftApiClient.getAPIResource(
|
|
234
|
-
this.makeswiftApiClient.getState(),
|
|
235
|
-
import_types.APIResourceType.Page,
|
|
236
|
-
pageId
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
readSnippet(snippetId) {
|
|
240
|
-
return MakeswiftApiClient.getAPIResource(
|
|
241
|
-
this.makeswiftApiClient.getState(),
|
|
242
|
-
import_types.APIResourceType.Snippet,
|
|
243
|
-
snippetId
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
84
|
}
|
|
247
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
248
86
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/client.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\n\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\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'\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 preloadedState,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n preloadedState: Partial<MakeswiftApiClient.State>\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState })\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;AAEA,yBAAoC;AAEpC,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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EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,6BAAgB,OAAO,SAAS,KAAK,KAAK;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,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 State as ApiClientState } from '../state/api-client/state'\nimport { type HttpFetch, fetchAPIResource } from '../state/api-client/fetch-api-resource'\nimport { configureClientStore } from '../state/api-client/client-store'\n\nimport {\n type File,\n type GlobalElement,\n type LocalizedGlobalElement,\n type PagePathnameSlice,\n type Swatch,\n type Table,\n type Typography,\n APIResourceType,\n} from './types'\n\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nimport { ApiResourcesClient } from './api-resources-client'\n\nexport { CacheData } from './api-resources-client'\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient extends ApiResourcesClient {\n readonly graphqlClient: GraphQLClient\n readonly fetch: HttpFetch\n\n constructor({\n uri,\n fetch,\n preloadedState,\n }: {\n uri: string\n fetch: HttpFetch\n preloadedState: Partial<ApiClientState>\n }) {\n super({\n store: configureClientStore({ preloadedState }),\n })\n\n this.graphqlClient = new GraphQLClient(uri)\n this.fetch = fetch\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch))\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.File, fileId, this.fetch))\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.GlobalElement, globalElementId, this.fetch),\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.LocalizedGlobalElement, globalElementId, this.fetch, locale),\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.store.dispatch(\n fetchAPIResource(APIResourceType.PagePathnameSlice, pageId, this.fetch, locale),\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.store.dispatch(fetchAPIResource(APIResourceType.Table, tableId, this.fetch))\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAAiD;AACjD,0BAAqC;AAErC,mBASO;AAEP,oBAA8B;AAC9B,uBAA0C;AAM1C,kCAAmC;AAEnC,IAAAA,+BAA0B;AAqBnB,MAAM,+BAA+B,+CAAmB;AAAA,EACpD;AAAA,EACA;AAAA,EAET,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM;AAAA,MACJ,WAAO,0CAAqB,EAAE,eAAe,CAAC;AAAA,IAChD,CAAC;AAED,SAAK,gBAAgB,IAAI,4BAAc,GAAG;AAC1C,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO,MAAM,KAAK,MAAM,aAAS,4CAAiB,6BAAgB,QAAQ,UAAU,KAAK,KAAK,CAAC;AAAA,EACjG;AAAA,EAEA,MAAM,UAAU,QAAsC;AACpD,WAAO,MAAM,KAAK,MAAM,aAAS,4CAAiB,6BAAgB,MAAM,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC7F;AAAA,EAEA,MAAM,gBAAgB,cAAkD;AACtE,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,YAAY,cAAc,KAAK,KAAK;AAAA,IACvE;AAAA,EACF;AAAA,EAEA,MAAM,mBAAmB,iBAAwD;AAC/E,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,eAAe,iBAAiB,KAAK,KAAK;AAAA,IAC7E;AAAA,EACF;AAAA,EAEA,MAAM,4BAA4B;AAAA,IAChC;AAAA,IACA;AAAA,EACF,GAG2C;AACzC,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,wBAAwB,iBAAiB,KAAK,OAAO,MAAM;AAAA,IAC9F;AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB;AAAA,IAC3B;AAAA,IACA;AAAA,EACF,GAGsC;AACpC,WAAO,MAAM,KAAK,MAAM;AAAA,UACtB,4CAAiB,6BAAgB,mBAAmB,QAAQ,KAAK,OAAO,MAAM;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,MAAM,aAAS,4CAAiB,6BAAgB,OAAO,SAAS,KAAK,KAAK,CAAC;AAAA,EAC/F;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,4CAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AACF;","names":["import_api_resources_client"]}
|
|
@@ -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.28.7-canary.
|
|
31
|
+
version: "0.28.7-canary.3",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -214,7 +214,7 @@ Received "${apiKey}" instead.`
|
|
|
214
214
|
}
|
|
215
215
|
this.apiKey = apiKey;
|
|
216
216
|
this.graphqlClient = new import_client.GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
|
|
217
|
-
"makeswift-runtime-version": "0.28.7-canary.
|
|
217
|
+
"makeswift-runtime-version": "0.28.7-canary.3"
|
|
218
218
|
});
|
|
219
219
|
this.runtime = runtime;
|
|
220
220
|
}
|
|
@@ -226,7 +226,7 @@ Received "${apiKey}" instead.`
|
|
|
226
226
|
const requestHeaders = new Headers({
|
|
227
227
|
"x-api-key": this.apiKey,
|
|
228
228
|
"makeswift-site-api-key": this.apiKey,
|
|
229
|
-
"makeswift-runtime-version": "0.28.7-canary.
|
|
229
|
+
"makeswift-runtime-version": "0.28.7-canary.3"
|
|
230
230
|
});
|
|
231
231
|
if (siteVersion?.token) {
|
|
232
232
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -953,7 +953,7 @@ Received "${apiKey}" instead.`
|
|
|
953
953
|
headers: {
|
|
954
954
|
"x-api-key": this.apiKey,
|
|
955
955
|
"makeswift-site-api-key": this.apiKey,
|
|
956
|
-
"makeswift-runtime-version": "0.28.7-canary.
|
|
956
|
+
"makeswift-runtime-version": "0.28.7-canary.3",
|
|
957
957
|
"content-type": "application/json"
|
|
958
958
|
},
|
|
959
959
|
body: JSON.stringify({ token }),
|
|
@@ -33,6 +33,7 @@ __export(controls_exports, {
|
|
|
33
33
|
Group: () => import_controls.Group,
|
|
34
34
|
GroupControl: () => import_controls.GroupControl,
|
|
35
35
|
GroupDefinition: () => import_controls.GroupDefinition,
|
|
36
|
+
IconRadioGroup: () => import_controls.IconRadioGroup,
|
|
36
37
|
IconRadioGroupDefinition: () => import_controls.IconRadioGroupDefinition,
|
|
37
38
|
Image: () => import_controls.Image,
|
|
38
39
|
ImageDefinition: () => import_controls.ImageDefinition,
|
|
@@ -67,7 +68,6 @@ __export(controls_exports, {
|
|
|
67
68
|
TextAreaDefinition: () => import_controls.TextAreaDefinition,
|
|
68
69
|
TextInput: () => import_controls.TextInput,
|
|
69
70
|
TextInputDefinition: () => import_controls.TextInputDefinition,
|
|
70
|
-
unstable_IconRadioGroup: () => import_controls.unstable_IconRadioGroup,
|
|
71
71
|
unstable_StyleV2: () => import_style_v2.unstable_StyleV2,
|
|
72
72
|
unstable_Typography: () => import_controls.unstable_Typography,
|
|
73
73
|
unstable_TypographyDefinition: () => import_controls.unstable_TypographyDefinition
|
|
@@ -96,6 +96,7 @@ var import_style_v2 = require("./style-v2/style-v2");
|
|
|
96
96
|
Group,
|
|
97
97
|
GroupControl,
|
|
98
98
|
GroupDefinition,
|
|
99
|
+
IconRadioGroup,
|
|
99
100
|
IconRadioGroupDefinition,
|
|
100
101
|
Image,
|
|
101
102
|
ImageDefinition,
|
|
@@ -130,7 +131,6 @@ var import_style_v2 = require("./style-v2/style-v2");
|
|
|
130
131
|
TextAreaDefinition,
|
|
131
132
|
TextInput,
|
|
132
133
|
TextInputDefinition,
|
|
133
|
-
unstable_IconRadioGroup,
|
|
134
134
|
unstable_StyleV2,
|
|
135
135
|
unstable_Typography,
|
|
136
136
|
unstable_TypographyDefinition,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/controls/index.ts"],"sourcesContent":["export * from './control'\n\nexport {\n ControlDefinition,\n Checkbox,\n CheckboxDefinition,\n Code,\n CodeDefinition,\n Color,\n ColorDefinition,\n Combobox,\n ComboboxDefinition,\n Font,\n FontDefinition,\n Group,\n GroupDefinition,\n GroupControl,\n IconRadioGroupDefinition,\n type IconRadioGroupIcon,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/controls/index.ts"],"sourcesContent":["export * from './control'\n\nexport {\n ControlDefinition,\n Checkbox,\n CheckboxDefinition,\n Code,\n CodeDefinition,\n Color,\n ColorDefinition,\n Combobox,\n ComboboxDefinition,\n Font,\n FontDefinition,\n Group,\n GroupDefinition,\n GroupControl,\n IconRadioGroup,\n IconRadioGroupDefinition,\n type IconRadioGroupIcon,\n Image,\n ImageDefinition,\n List,\n ListDefinition,\n ListControl,\n Number,\n NumberDefinition,\n Select,\n SelectDefinition,\n Shape,\n ShapeDefinition,\n ShapeControl,\n Slider,\n SliderDefinition,\n Style,\n StyleDefinition,\n type StyleProperty,\n StyleControl,\n TextInput,\n TextInputDefinition,\n TextArea,\n TextAreaDefinition,\n unstable_Typography,\n unstable_TypographyDefinition,\n} from '@makeswift/controls'\n\nexport { Link, LinkDefinition } from './link'\nexport { RichTextV1Definition, RichTextV1Control } from './rich-text'\nexport { RichText, RichTextV2Definition, RichTextV2Control } from './rich-text-v2'\nexport { Slot, SlotDefinition, SlotControl } from './slot'\nexport { unstable_StyleV2, StyleV2Definition, StyleV2Control } from './style-v2/style-v2'\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAc,sBAAd;AAEA,sBA0CO;AAEP,kBAAqC;AACrC,uBAAwD;AACxD,0BAAkE;AAClE,kBAAkD;AAClD,sBAAoE;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/fetch.ts"],"sourcesContent":["import { type HttpFetch } from '../state/
|
|
1
|
+
{"version":3,"sources":["../../../src/next/fetch.ts"],"sourcesContent":["import { type HttpFetch } from '../state/api-client/fetch-api-resource'\n\nimport { MAKESWIFT_CACHE_TAG } from './cache'\n\nexport const fetch: HttpFetch = (url, init) =>\n globalThis.fetch(url, { ...init, next: { tags: [MAKESWIFT_CACHE_TAG] } })\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoC;AAE7B,MAAM,QAAmB,CAAC,KAAK,SACpC,WAAW,MAAM,KAAK,EAAE,GAAG,MAAM,MAAM,EAAE,MAAM,CAAC,gCAAmB,EAAE,EAAE,CAAC;","names":[]}
|
|
@@ -25,7 +25,7 @@ var import_react = require("react");
|
|
|
25
25
|
var import_read_write_actions = require("../../../state/actions/internal/read-write-actions");
|
|
26
26
|
var import_host_api_client = require("../host-api-client");
|
|
27
27
|
function useCacheData(cacheData) {
|
|
28
|
-
const {
|
|
28
|
+
const { store: apiStore } = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
29
29
|
(0, import_react.useMemo)(() => apiStore.dispatch((0, import_read_write_actions.updateAPIClientCache)(cacheData)), [cacheData]);
|
|
30
30
|
}
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-cache-data.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type CacheData } from '../../../api/client'\nimport { updateAPIClientCache } from '../../../state/actions/internal/read-write-actions'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\n\nexport function useCacheData(cacheData: CacheData) {\n const {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-cache-data.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { type CacheData } from '../../../api/client'\nimport { updateAPIClientCache } from '../../../state/actions/internal/read-write-actions'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\n\nexport function useCacheData(cacheData: CacheData) {\n const { store: apiStore } = useMakeswiftHostApiClient()\n\n // We perform cache hydration immediately on render - this is safe to do per\n // render because updating the API cache is idempotent. For precedence, see:\n //\n // https://github.com/TanStack/query/blob/8f9f183f11df3709a1a38c4efce1452788041f88/packages/react-query/src/HydrationBoundary.tsx#L41\n useMemo(() => apiStore.dispatch(updateAPIClientCache(cacheData)), [cacheData])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AAExB,gCAAqC;AAErC,6BAA0C;AAEnC,SAAS,aAAa,WAAsB;AACjD,QAAM,EAAE,OAAO,SAAS,QAAI,kDAA0B;AAMtD,4BAAQ,MAAM,SAAS,aAAS,gDAAqB,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/E;","names":[]}
|