@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.
Files changed (99) hide show
  1. package/dist/cjs/api/api-resources-client.js +160 -0
  2. package/dist/cjs/api/api-resources-client.js.map +1 -0
  3. package/dist/cjs/api/client.js +20 -182
  4. package/dist/cjs/api/client.js.map +1 -1
  5. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  6. package/dist/cjs/client/index.js +3 -3
  7. package/dist/cjs/controls/index.js +2 -2
  8. package/dist/cjs/controls/index.js.map +1 -1
  9. package/dist/cjs/next/fetch.js.map +1 -1
  10. package/dist/cjs/runtimes/react/hooks/use-cache-data.js +1 -1
  11. package/dist/cjs/runtimes/react/hooks/use-cache-data.js.map +1 -1
  12. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js +11 -32
  13. package/dist/cjs/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  14. package/dist/cjs/runtimes/react/resource-resolver.js +52 -0
  15. package/dist/cjs/runtimes/react/resource-resolver.js.map +1 -0
  16. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  17. package/dist/cjs/slate/InlinePlugin/index.js +1 -1
  18. package/dist/cjs/slate/InlinePlugin/index.js.map +1 -1
  19. package/dist/cjs/slate/InlinePlugin/types.js +3 -3
  20. package/dist/cjs/slate/InlinePlugin/types.js.map +1 -1
  21. package/dist/cjs/slate/TextAlignPlugin/index.js +5 -5
  22. package/dist/cjs/slate/TextAlignPlugin/index.js.map +1 -1
  23. package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
  24. package/dist/cjs/state/api-client/client-store.js +81 -0
  25. package/dist/cjs/state/api-client/client-store.js.map +1 -0
  26. package/dist/cjs/state/{makeswift-api-client.js → api-client/fetch-api-resource.js} +15 -101
  27. package/dist/cjs/state/api-client/fetch-api-resource.js.map +1 -0
  28. package/dist/cjs/state/api-client/state.js +89 -0
  29. package/dist/cjs/state/api-client/state.js.map +1 -0
  30. package/dist/cjs/state/api-client/store.js +36 -0
  31. package/dist/cjs/state/api-client/store.js.map +1 -0
  32. package/dist/cjs/state/middleware/makeswift-api-client-sync.js +1 -1
  33. package/dist/cjs/state/middleware/makeswift-api-client-sync.js.map +1 -1
  34. package/dist/esm/api/api-resources-client.js +127 -0
  35. package/dist/esm/api/api-resources-client.js.map +1 -0
  36. package/dist/esm/api/client.js +19 -171
  37. package/dist/esm/api/client.js.map +1 -1
  38. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  39. package/dist/esm/client/index.js +3 -3
  40. package/dist/esm/controls/index.js +2 -2
  41. package/dist/esm/controls/index.js.map +1 -1
  42. package/dist/esm/next/fetch.js.map +1 -1
  43. package/dist/esm/runtimes/react/hooks/use-cache-data.js +1 -1
  44. package/dist/esm/runtimes/react/hooks/use-cache-data.js.map +1 -1
  45. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js +11 -22
  46. package/dist/esm/runtimes/react/hooks/use-resource-resolver.js.map +1 -1
  47. package/dist/esm/runtimes/react/resource-resolver.js +28 -0
  48. package/dist/esm/runtimes/react/resource-resolver.js.map +1 -0
  49. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  50. package/dist/esm/slate/InlinePlugin/index.js +2 -2
  51. package/dist/esm/slate/InlinePlugin/index.js.map +1 -1
  52. package/dist/esm/slate/InlinePlugin/types.js +4 -4
  53. package/dist/esm/slate/InlinePlugin/types.js.map +1 -1
  54. package/dist/esm/slate/TextAlignPlugin/index.js +6 -6
  55. package/dist/esm/slate/TextAlignPlugin/index.js.map +1 -1
  56. package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
  57. package/dist/esm/state/api-client/client-store.js +49 -0
  58. package/dist/esm/state/api-client/client-store.js.map +1 -0
  59. package/dist/esm/state/api-client/fetch-api-resource.js +93 -0
  60. package/dist/esm/state/api-client/fetch-api-resource.js.map +1 -0
  61. package/dist/esm/state/api-client/state.js +52 -0
  62. package/dist/esm/state/api-client/state.js.map +1 -0
  63. package/dist/esm/state/api-client/store.js +12 -0
  64. package/dist/esm/state/api-client/store.js.map +1 -0
  65. package/dist/esm/state/middleware/makeswift-api-client-sync.js +1 -1
  66. package/dist/esm/state/middleware/makeswift-api-client-sync.js.map +1 -1
  67. package/dist/types/api/api-resources-client.d.ts +57 -0
  68. package/dist/types/api/api-resources-client.d.ts.map +1 -0
  69. package/dist/types/api/client.d.ts +10 -42
  70. package/dist/types/api/client.d.ts.map +1 -1
  71. package/dist/types/client/index.d.ts +9 -9
  72. package/dist/types/controls/index.d.ts +1 -1
  73. package/dist/types/controls/index.d.ts.map +1 -1
  74. package/dist/types/next/fetch.d.ts +1 -1
  75. package/dist/types/next/fetch.d.ts.map +1 -1
  76. package/dist/types/runtimes/react/hooks/use-resource-resolver.d.ts.map +1 -1
  77. package/dist/types/runtimes/react/resource-resolver.d.ts +10 -0
  78. package/dist/types/runtimes/react/resource-resolver.d.ts.map +1 -0
  79. package/dist/types/runtimes/react/runtime-core.d.ts +3 -3
  80. package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
  81. package/dist/types/slate/InlinePlugin/types.d.ts +3 -3
  82. package/dist/types/slate/InlinePlugin/types.d.ts.map +1 -1
  83. package/dist/types/slate/TextAlignPlugin/index.d.ts.map +1 -1
  84. package/dist/types/state/actions/internal/read-write-actions.d.ts +1 -1
  85. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
  86. package/dist/types/state/api-client/client-store.d.ts +6 -0
  87. package/dist/types/state/api-client/client-store.d.ts.map +1 -0
  88. package/dist/types/state/api-client/fetch-api-resource.d.ts +11 -0
  89. package/dist/types/state/api-client/fetch-api-resource.d.ts.map +1 -0
  90. package/dist/types/state/api-client/state.d.ts +30 -0
  91. package/dist/types/state/api-client/state.d.ts.map +1 -0
  92. package/dist/types/state/api-client/store.d.ts +18 -0
  93. package/dist/types/state/api-client/store.d.ts.map +1 -0
  94. package/package.json +3 -3
  95. package/dist/cjs/state/makeswift-api-client.js.map +0 -1
  96. package/dist/esm/state/makeswift-api-client.js +0 -179
  97. package/dist/esm/state/makeswift-api-client.js.map +0 -1
  98. package/dist/types/state/makeswift-api-client.d.ts +0 -51
  99. package/dist/types/state/makeswift-api-client.d.ts.map +0 -1
@@ -0,0 +1,89 @@
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 state_exports = {};
30
+ __export(state_exports, {
31
+ getAPIResource: () => getAPIResource,
32
+ getHasAPIResource: () => getHasAPIResource,
33
+ getLocalizedResourceId: () => getLocalizedResourceId,
34
+ reducer: () => reducer
35
+ });
36
+ module.exports = __toCommonJS(state_exports);
37
+ var import_toolkit = require("@reduxjs/toolkit");
38
+ var SiteVersionState = __toESM(require("../modules/site-version"));
39
+ var LocaleState = __toESM(require("../modules/locale"));
40
+ var APIResources = __toESM(require("../modules/api-resources"));
41
+ var LocalizedResourcesMap = __toESM(require("../modules/localized-resources-map"));
42
+ var import_api = require("../../api");
43
+ const reducer = (0, import_toolkit.combineReducers)({
44
+ siteVersion: SiteVersionState.reducer,
45
+ locale: LocaleState.reducer,
46
+ apiResources: APIResources.reducer,
47
+ localizedResourcesMap: LocalizedResourcesMap.reducer
48
+ });
49
+ function getLocalizedResourceId(state, locale, resourceId) {
50
+ return LocalizedResourcesMap.getLocalizedResourceId(
51
+ state.localizedResourcesMap,
52
+ locale,
53
+ resourceId
54
+ );
55
+ }
56
+ function getHasAPIResource(state, resourceType, resourceId, locale) {
57
+ switch (resourceType) {
58
+ case import_api.APIResourceType.LocalizedGlobalElement:
59
+ if (locale == null) {
60
+ console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
61
+ return false;
62
+ }
63
+ const localizedId = getLocalizedResourceId(state, locale, resourceId);
64
+ return localizedId != null && APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale);
65
+ default:
66
+ return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale);
67
+ }
68
+ }
69
+ function getAPIResource(state, resourceType, resourceId, locale) {
70
+ switch (resourceType) {
71
+ case import_api.APIResourceType.LocalizedGlobalElement:
72
+ if (locale == null) {
73
+ console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
74
+ return null;
75
+ }
76
+ const localizedId = getLocalizedResourceId(state, locale, resourceId);
77
+ return localizedId != null ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale) : null;
78
+ default:
79
+ return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale);
80
+ }
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ getAPIResource,
85
+ getHasAPIResource,
86
+ getLocalizedResourceId,
87
+ reducer
88
+ });
89
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/api-client/state.ts"],"sourcesContent":["import { combineReducers, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as SiteVersionState from '../modules/site-version'\nimport * as LocaleState from '../modules/locale'\nimport * as APIResources from '../modules/api-resources'\nimport * as LocalizedResourcesMap from '../modules/localized-resources-map'\n\nimport { type Action } from '../actions'\n\nimport { APIResourceType, type APIResource, type APIResourceLocale } from '../../api'\n\nexport const reducer = combineReducers({\n siteVersion: SiteVersionState.reducer,\n locale: LocaleState.reducer,\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nexport function getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoD;AAEpD,uBAAkC;AAClC,kBAA6B;AAC7B,mBAA8B;AAC9B,4BAAuC;AAIvC,iBAA0E;AAEnE,MAAM,cAAU,gCAAgB;AAAA,EACrC,aAAa,iBAAiB;AAAA,EAC9B,QAAQ,YAAY;AAAA,EACpB,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AAC/C,CAAC;AAUM,SAAS,uBACd,OACA,QACA,YAC2B;AAC3B,SAAO,sBAAsB;AAAA,IAC3B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,kBACd,OACA,cACA,YACA,QACS;AACT,UAAQ,cAAc;AAAA,IACpB,KAAK,2BAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAAO,QAAQ,UAAU;AACpE,aACE,eAAe,QACf,aAAa,kBAAkB,MAAM,cAAc,cAAc,aAAa,MAAM;AAAA,IAGxF;AACE,aAAO,aAAa,kBAAkB,MAAM,cAAc,cAAc,YAAY,MAAM;AAAA,EAC9F;AACF;AAEO,SAAS,eACd,OACA,cACA,YACA,QACgD;AAChD,UAAQ,cAAc;AAAA,IACpB,KAAK,2BAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAAO,QAAQ,UAAU;AACpE,aAAO,eAAe,OAClB,aAAa,eAAe,MAAM,cAAc,cAAc,aAAa,MAAM,IACjF;AAAA,IAEN;AACE,aAAO,aAAa,eAAe,MAAM,cAAc,cAAc,YAAY,MAAM;AAAA,EAC3F;AACF;","names":[]}
@@ -0,0 +1,36 @@
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 store_exports = {};
20
+ __export(store_exports, {
21
+ configureStore: () => configureStore
22
+ });
23
+ module.exports = __toCommonJS(store_exports);
24
+ var import_toolkit = require("@reduxjs/toolkit");
25
+ var import_state = require("./state");
26
+ function configureStore({ preloadedState }) {
27
+ return (0, import_toolkit.configureStore)({
28
+ reducer: import_state.reducer,
29
+ preloadedState
30
+ });
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ configureStore
35
+ });
36
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/state/api-client/store.ts"],"sourcesContent":["import { configureStore as configureReduxStore } from '@reduxjs/toolkit'\n\nimport { type State, reducer } from './state'\n\nexport function configureStore({ preloadedState }: { preloadedState: Partial<State> }) {\n return configureReduxStore({\n reducer,\n preloadedState,\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsD;AAEtD,mBAAoC;AAE7B,SAAS,eAAe,EAAE,eAAe,GAAuC;AACrF,aAAO,eAAAA,gBAAoB;AAAA,IACzB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":["configureReduxStore"]}
@@ -25,7 +25,7 @@ var import_toolkit2 = require("../toolkit");
25
25
  function makeswiftApiClientSyncMiddleware(client) {
26
26
  return (0, import_toolkit2.actionMiddleware)(() => (next) => {
27
27
  return (action) => {
28
- client.makeswiftApiClient.dispatch(action);
28
+ client.store.dispatch(action);
29
29
  return next(action);
30
30
  };
31
31
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/middleware/makeswift-api-client-sync.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../../api/client'\n\nimport { type Action } from '../actions'\nimport { actionMiddleware } from '../toolkit'\nimport { type State, type Dispatch } from '../unified-state'\n\nexport function makeswiftApiClientSyncMiddleware(\n client: MakeswiftHostApiClient,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAAA,kBAAiC;AAG1B,SAAS,iCACd,QACuC;AACvC,aAAO,kCAAiB,MAAM,UAAQ;AACpC,WAAO,CAAC,WAAmB;AACzB,aAAO,mBAAmB,SAAS,MAAM;AAEzC,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
1
+ {"version":3,"sources":["../../../../src/state/middleware/makeswift-api-client-sync.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../../api/client'\n\nimport { type Action } from '../actions'\nimport { actionMiddleware } from '../toolkit'\nimport { type State, type Dispatch } from '../unified-state'\n\nexport function makeswiftApiClientSyncMiddleware(\n client: MakeswiftHostApiClient,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n client.store.dispatch(action)\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAAA,kBAAiC;AAG1B,SAAS,iCACd,QACuC;AACvC,aAAO,kCAAiB,MAAM,UAAQ;AACpC,WAAO,CAAC,WAAmB;AACzB,aAAO,MAAM,SAAS,MAAM;AAE5B,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
@@ -0,0 +1,127 @@
1
+ import * as ApiClientState from "../state/api-client/state";
2
+ import {
3
+ APIResourceType
4
+ } from "./types";
5
+ const CacheData = {
6
+ empty() {
7
+ return {
8
+ apiResources: {},
9
+ localizedResourcesMap: {}
10
+ };
11
+ }
12
+ };
13
+ class ApiResourcesClient {
14
+ store;
15
+ subscribe;
16
+ constructor({ store }) {
17
+ this.store = store;
18
+ this.subscribe = this.store.subscribe;
19
+ }
20
+ readSwatch(swatchId) {
21
+ return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Swatch, swatchId);
22
+ }
23
+ resolveSwatch(swatchId) {
24
+ return this.resolveResource(APIResourceType.Swatch, {
25
+ id: swatchId,
26
+ read: (id) => this.readSwatch(id),
27
+ fetch: (id) => this.fetchSwatch(id)
28
+ });
29
+ }
30
+ readFile(fileId) {
31
+ return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.File, fileId);
32
+ }
33
+ resolveFile(fileId) {
34
+ return this.resolveResource(APIResourceType.File, {
35
+ id: fileId,
36
+ read: (id) => this.readFile(id),
37
+ fetch: (id) => this.fetchFile(id)
38
+ });
39
+ }
40
+ readTypography(typographyId) {
41
+ return ApiClientState.getAPIResource(
42
+ this.store.getState(),
43
+ APIResourceType.Typography,
44
+ typographyId
45
+ );
46
+ }
47
+ resolveTypography(typographyId) {
48
+ return this.resolveResource(APIResourceType.Typography, {
49
+ id: typographyId,
50
+ read: (id) => this.readTypography(id),
51
+ fetch: (id) => this.fetchTypography(id)
52
+ });
53
+ }
54
+ readGlobalElement(globalElementId) {
55
+ return ApiClientState.getAPIResource(
56
+ this.store.getState(),
57
+ APIResourceType.GlobalElement,
58
+ globalElementId
59
+ );
60
+ }
61
+ readLocalizedGlobalElement({
62
+ globalElementId,
63
+ locale
64
+ }) {
65
+ return ApiClientState.getAPIResource(
66
+ this.store.getState(),
67
+ APIResourceType.LocalizedGlobalElement,
68
+ globalElementId,
69
+ locale
70
+ );
71
+ }
72
+ readPagePathnameSlice({
73
+ pageId,
74
+ locale
75
+ }) {
76
+ return ApiClientState.getAPIResource(
77
+ this.store.getState(),
78
+ APIResourceType.PagePathnameSlice,
79
+ pageId,
80
+ locale
81
+ );
82
+ }
83
+ resolvePagePathnameSlice({
84
+ pageId,
85
+ locale
86
+ }) {
87
+ return this.resolveResource(APIResourceType.PagePathnameSlice, {
88
+ id: pageId,
89
+ read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
90
+ fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
91
+ });
92
+ }
93
+ resolveResource(type, {
94
+ id,
95
+ read,
96
+ fetch
97
+ }) {
98
+ const _read = () => id != null ? read(id) : null;
99
+ let lastValue = null;
100
+ return {
101
+ name: `${type}:${id}`,
102
+ readStable: () => lastValue = _read(),
103
+ subscribe: (onUpdate) => this.subscribe(() => {
104
+ if (_read() !== lastValue)
105
+ onUpdate();
106
+ }),
107
+ fetch: async () => id != null ? fetch(id) : null
108
+ };
109
+ }
110
+ readTable(tableId) {
111
+ return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Table, tableId);
112
+ }
113
+ readSite(siteId) {
114
+ return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Site, siteId);
115
+ }
116
+ readPage(pageId) {
117
+ return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Page, pageId);
118
+ }
119
+ readSnippet(snippetId) {
120
+ return ApiClientState.getAPIResource(this.store.getState(), APIResourceType.Snippet, snippetId);
121
+ }
122
+ }
123
+ export {
124
+ ApiResourcesClient,
125
+ CacheData
126
+ };
127
+ //# 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":"AAGA,YAAY,oBAAoB;AAEhC;AAAA,EAWE;AAAA,OACK;AAIA,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AACO,MAAe,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EAET,YAAY,EAAE,MAAM,GAA8B;AAChD,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,MAAM;AAAA,EAC9B;AAAA,EAIA,WAAW,UAAiC;AAC1C,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,gBAAgB,QAAQ,QAAQ;AAAA,EAC9F;AAAA,EAEA,cAAc,UAA6D;AACzE,WAAO,KAAK,gBAAgB,gBAAgB,QAAQ;AAAA,MAClD,IAAI;AAAA,MACJ,MAAM,QAAM,KAAK,WAAW,EAAE;AAAA,MAC9B,OAAO,QAAM,KAAK,YAAY,EAAE;AAAA,IAClC,CAAC;AAAA,EACH;AAAA,EAIA,SAAS,QAA6B;AACpC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,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,OAAO,CAAC;AAAA,MAC7D,OAAO,QAAM,KAAK,uBAAuB,EAAE,QAAQ,IAAI,OAAO,CAAC;AAAA,IACjE,CAAC;AAAA,EACH;AAAA,EAEA,gBACE,MACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAK0B;AAC1B,UAAM,QAAQ,MAAO,MAAM,OAAO,KAAK,EAAE,IAAI;AAC7C,QAAI,YAAsB;AAC1B,WAAO;AAAA,MACL,MAAM,GAAG,IAAI,IAAI,EAAE;AAAA,MACnB,YAAY,MAAO,YAAY,MAAM;AAAA,MACrC,WAAW,CAAC,aACV,KAAK,UAAU,MAAM;AACnB,YAAI,MAAM,MAAM;AAAW,mBAAS;AAAA,MACtC,CAAC;AAAA,MACH,OAAO,YAAa,MAAM,OAAO,MAAM,EAAE,IAAI;AAAA,IAC/C;AAAA,EACF;AAAA,EAIA,UAAU,SAA+B;AACvC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,gBAAgB,OAAO,OAAO;AAAA,EAC5F;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,gBAAgB,MAAM,MAAM;AAAA,EAC1F;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,gBAAgB,MAAM,MAAM;AAAA,EAC1F;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,eAAe,eAAe,KAAK,MAAM,SAAS,GAAG,gBAAgB,SAAS,SAAS;AAAA,EAChG;AACF;","names":[]}
@@ -1,216 +1,64 @@
1
- import * as MakeswiftApiClient from "../state/makeswift-api-client";
1
+ import { fetchAPIResource } from "../state/api-client/fetch-api-resource";
2
+ import { configureClientStore } from "../state/api-client/client-store";
2
3
  import {
3
4
  APIResourceType
4
5
  } from "./types";
5
6
  import { GraphQLClient } from "./graphql/client";
6
7
  import { CreateTableRecordMutation } from "./graphql/documents";
7
- const CacheData = {
8
- empty() {
9
- return {
10
- apiResources: {},
11
- localizedResourcesMap: {}
12
- };
13
- }
14
- };
15
- class MakeswiftHostApiClient {
8
+ import { ApiResourcesClient } from "./api-resources-client";
9
+ import { CacheData } from "./api-resources-client";
10
+ class MakeswiftHostApiClient extends ApiResourcesClient {
16
11
  graphqlClient;
17
- makeswiftApiClient;
18
- subscribe;
19
12
  fetch;
20
13
  constructor({
21
14
  uri,
22
15
  fetch,
23
16
  preloadedState
24
17
  }) {
18
+ super({
19
+ store: configureClientStore({ preloadedState })
20
+ });
25
21
  this.graphqlClient = new GraphQLClient(uri);
26
- this.makeswiftApiClient = MakeswiftApiClient.configureStore({ preloadedState });
27
22
  this.fetch = fetch;
28
- this.subscribe = this.makeswiftApiClient.subscribe;
29
- }
30
- readSwatch(swatchId) {
31
- return MakeswiftApiClient.getAPIResource(
32
- this.makeswiftApiClient.getState(),
33
- APIResourceType.Swatch,
34
- swatchId
35
- );
36
23
  }
37
24
  async fetchSwatch(swatchId) {
38
- return await this.makeswiftApiClient.dispatch(
39
- MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch)
40
- );
41
- }
42
- resolveSwatch(swatchId) {
43
- return this.resolveResource(APIResourceType.Swatch, {
44
- id: swatchId,
45
- read: (id) => this.readSwatch(id),
46
- fetch: (id) => this.fetchSwatch(id)
47
- });
48
- }
49
- readFile(fileId) {
50
- return MakeswiftApiClient.getAPIResource(
51
- this.makeswiftApiClient.getState(),
52
- APIResourceType.File,
53
- fileId
54
- );
25
+ return await this.store.dispatch(fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch));
55
26
  }
56
27
  async fetchFile(fileId) {
57
- return await this.makeswiftApiClient.dispatch(
58
- MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch)
59
- );
60
- }
61
- resolveFile(fileId) {
62
- return this.resolveResource(APIResourceType.File, {
63
- id: fileId,
64
- read: (id) => this.readFile(id),
65
- fetch: (id) => this.fetchFile(id)
66
- });
67
- }
68
- readTypography(typographyId) {
69
- return MakeswiftApiClient.getAPIResource(
70
- this.makeswiftApiClient.getState(),
71
- APIResourceType.Typography,
72
- typographyId
73
- );
28
+ return await this.store.dispatch(fetchAPIResource(APIResourceType.File, fileId, this.fetch));
74
29
  }
75
30
  async fetchTypography(typographyId) {
76
- return await this.makeswiftApiClient.dispatch(
77
- MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch)
78
- );
79
- }
80
- resolveTypography(typographyId) {
81
- return this.resolveResource(APIResourceType.Typography, {
82
- id: typographyId,
83
- read: (id) => this.readTypography(id),
84
- fetch: (id) => this.fetchTypography(id)
85
- });
86
- }
87
- readGlobalElement(globalElementId) {
88
- return MakeswiftApiClient.getAPIResource(
89
- this.makeswiftApiClient.getState(),
90
- APIResourceType.GlobalElement,
91
- globalElementId
31
+ return await this.store.dispatch(
32
+ fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch)
92
33
  );
93
34
  }
94
35
  async fetchGlobalElement(globalElementId) {
95
- return await this.makeswiftApiClient.dispatch(
96
- MakeswiftApiClient.fetchAPIResource(
97
- APIResourceType.GlobalElement,
98
- globalElementId,
99
- this.fetch
100
- )
101
- );
102
- }
103
- readLocalizedGlobalElement({
104
- globalElementId,
105
- locale
106
- }) {
107
- return MakeswiftApiClient.getAPIResource(
108
- this.makeswiftApiClient.getState(),
109
- APIResourceType.LocalizedGlobalElement,
110
- globalElementId,
111
- locale
36
+ return await this.store.dispatch(
37
+ fetchAPIResource(APIResourceType.GlobalElement, globalElementId, this.fetch)
112
38
  );
113
39
  }
114
40
  async fetchLocalizedGlobalElement({
115
41
  globalElementId,
116
42
  locale
117
43
  }) {
118
- return await this.makeswiftApiClient.dispatch(
119
- MakeswiftApiClient.fetchAPIResource(
120
- APIResourceType.LocalizedGlobalElement,
121
- globalElementId,
122
- this.fetch,
123
- locale
124
- )
125
- );
126
- }
127
- readPagePathnameSlice({
128
- pageId,
129
- locale
130
- }) {
131
- return MakeswiftApiClient.getAPIResource(
132
- this.makeswiftApiClient.getState(),
133
- APIResourceType.PagePathnameSlice,
134
- pageId,
135
- locale
44
+ return await this.store.dispatch(
45
+ fetchAPIResource(APIResourceType.LocalizedGlobalElement, globalElementId, this.fetch, locale)
136
46
  );
137
47
  }
138
48
  async fetchPagePathnameSlice({
139
49
  pageId,
140
50
  locale
141
51
  }) {
142
- return await this.makeswiftApiClient.dispatch(
143
- MakeswiftApiClient.fetchAPIResource(
144
- APIResourceType.PagePathnameSlice,
145
- pageId,
146
- this.fetch,
147
- locale
148
- )
149
- );
150
- }
151
- resolvePagePathnameSlice({
152
- pageId,
153
- locale
154
- }) {
155
- return this.resolveResource(APIResourceType.PagePathnameSlice, {
156
- id: pageId,
157
- read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
158
- fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
159
- });
160
- }
161
- resolveResource(type, {
162
- id,
163
- read,
164
- fetch
165
- }) {
166
- const _read = () => id != null ? read(id) : null;
167
- let lastValue = null;
168
- return {
169
- name: `${type}:${id}`,
170
- readStable: () => lastValue = _read(),
171
- subscribe: (onUpdate) => this.subscribe(() => {
172
- if (_read() !== lastValue)
173
- onUpdate();
174
- }),
175
- fetch: async () => id != null ? fetch(id) : null
176
- };
177
- }
178
- readTable(tableId) {
179
- return MakeswiftApiClient.getAPIResource(
180
- this.makeswiftApiClient.getState(),
181
- APIResourceType.Table,
182
- tableId
52
+ return await this.store.dispatch(
53
+ fetchAPIResource(APIResourceType.PagePathnameSlice, pageId, this.fetch, locale)
183
54
  );
184
55
  }
185
56
  async fetchTable(tableId) {
186
- return await this.makeswiftApiClient.dispatch(
187
- MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch)
188
- );
57
+ return await this.store.dispatch(fetchAPIResource(APIResourceType.Table, tableId, this.fetch));
189
58
  }
190
59
  async createTableRecord(tableId, columns) {
191
60
  await this.graphqlClient.request(CreateTableRecordMutation, { input: { data: { tableId, columns } } });
192
61
  }
193
- readSite(siteId) {
194
- return MakeswiftApiClient.getAPIResource(
195
- this.makeswiftApiClient.getState(),
196
- APIResourceType.Site,
197
- siteId
198
- );
199
- }
200
- readPage(pageId) {
201
- return MakeswiftApiClient.getAPIResource(
202
- this.makeswiftApiClient.getState(),
203
- APIResourceType.Page,
204
- pageId
205
- );
206
- }
207
- readSnippet(snippetId) {
208
- return MakeswiftApiClient.getAPIResource(
209
- this.makeswiftApiClient.getState(),
210
- APIResourceType.Snippet,
211
- snippetId
212
- );
213
- }
214
62
  }
215
63
  export {
216
64
  CacheData,
@@ -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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U,MAAM;AACnB,YAAI,MAAM,MAAM;AAAW,mBAAS;AAAA,MACtC,CAAC;AAAA,MACH,OAAO,YAAa,MAAM,OAAO,MAAM,EAAE,IAAI;AAAA,IAC/C;AAAA,EACF;AAAA,EAEA,UAAU,SAA+B;AACvC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,gBAAgB,OAAO,SAAS,KAAK,KAAK;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,2BAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY,WAAmC;AAC7C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;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":"AACA,SAAyB,wBAAwB;AACjD,SAAS,4BAA4B;AAErC;AAAA,EAQE;AAAA,OACK;AAEP,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AAM1C,SAAS,0BAA0B;AAEnC,SAAS,iBAAiB;AAqBnB,MAAM,+BAA+B,mBAAmB;AAAA,EACpD;AAAA,EACA;AAAA,EAET,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM;AAAA,MACJ,OAAO,qBAAqB,EAAE,eAAe,CAAC;AAAA,IAChD,CAAC;AAED,SAAK,gBAAgB,IAAI,cAAc,GAAG;AAC1C,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO,MAAM,KAAK,MAAM,SAAS,iBAAiB,gBAAgB,QAAQ,UAAU,KAAK,KAAK,CAAC;AAAA,EACjG;AAAA,EAEA,MAAM,UAAU,QAAsC;AACpD,WAAO,MAAM,KAAK,MAAM,SAAS,iBAAiB,gBAAgB,MAAM,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC7F;AAAA,EAEA,MAAM,gBAAgB,cAAkD;AACtE,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,YAAY,cAAc,KAAK,KAAK;AAAA,IACvE;AAAA,EACF;AAAA,EAEA,MAAM,mBAAmB,iBAAwD;AAC/E,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,eAAe,iBAAiB,KAAK,KAAK;AAAA,IAC7E;AAAA,EACF;AAAA,EAEA,MAAM,4BAA4B;AAAA,IAChC;AAAA,IACA;AAAA,EACF,GAG2C;AACzC,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,wBAAwB,iBAAiB,KAAK,OAAO,MAAM;AAAA,IAC9F;AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB;AAAA,IAC3B;AAAA,IACA;AAAA,EACF,GAGsC;AACpC,WAAO,MAAM,KAAK,MAAM;AAAA,MACtB,iBAAiB,gBAAgB,mBAAmB,QAAQ,KAAK,OAAO,MAAM;AAAA,IAChF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW,SAAwC;AACvD,WAAO,MAAM,KAAK,MAAM,SAAS,iBAAiB,gBAAgB,OAAO,SAAS,KAAK,KAAK,CAAC;AAAA,EAC/F;AAAA,EAEA,MAAM,kBAAkB,SAAiB,SAA6B;AACpE,UAAM,KAAK,cAAc,QAGvB,2BAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,CAAC;AAAA,EACxE;AACF;","names":[]}
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
8
8
  return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
9
9
  }
10
10
  return ApiResponse.json({
11
- version: "0.28.7-canary.2",
11
+ version: "0.28.7-canary.3",
12
12
  interactionMode: true,
13
13
  clientSideNavigation: false,
14
14
  elementFromPoint: false,
@@ -198,7 +198,7 @@ Received "${apiKey}" instead.`
198
198
  }
199
199
  this.apiKey = apiKey;
200
200
  this.graphqlClient = new GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
201
- "makeswift-runtime-version": "0.28.7-canary.2"
201
+ "makeswift-runtime-version": "0.28.7-canary.3"
202
202
  });
203
203
  this.runtime = runtime;
204
204
  }
@@ -210,7 +210,7 @@ Received "${apiKey}" instead.`
210
210
  const requestHeaders = new Headers({
211
211
  "x-api-key": this.apiKey,
212
212
  "makeswift-site-api-key": this.apiKey,
213
- "makeswift-runtime-version": "0.28.7-canary.2"
213
+ "makeswift-runtime-version": "0.28.7-canary.3"
214
214
  });
215
215
  if (siteVersion?.token) {
216
216
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -937,7 +937,7 @@ Received "${apiKey}" instead.`
937
937
  headers: {
938
938
  "x-api-key": this.apiKey,
939
939
  "makeswift-site-api-key": this.apiKey,
940
- "makeswift-runtime-version": "0.28.7-canary.2",
940
+ "makeswift-runtime-version": "0.28.7-canary.3",
941
941
  "content-type": "application/json"
942
942
  },
943
943
  body: JSON.stringify({ token }),
@@ -14,8 +14,8 @@ import {
14
14
  Group,
15
15
  GroupDefinition,
16
16
  GroupControl,
17
+ IconRadioGroup,
17
18
  IconRadioGroupDefinition,
18
- unstable_IconRadioGroup,
19
19
  Image,
20
20
  ImageDefinition,
21
21
  List,
@@ -60,6 +60,7 @@ export {
60
60
  Group,
61
61
  GroupControl,
62
62
  GroupDefinition,
63
+ IconRadioGroup,
63
64
  IconRadioGroupDefinition,
64
65
  Image,
65
66
  ImageDefinition,
@@ -94,7 +95,6 @@ export {
94
95
  TextAreaDefinition,
95
96
  TextInput,
96
97
  TextInputDefinition,
97
- unstable_IconRadioGroup,
98
98
  unstable_StyleV2,
99
99
  unstable_Typography,
100
100
  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 unstable_IconRadioGroup,\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,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,MAAM,sBAAsB;AACrC,SAAS,sBAAsB,yBAAyB;AACxD,SAAS,UAAU,sBAAsB,yBAAyB;AAClE,SAAS,MAAM,gBAAgB,mBAAmB;AAClD,SAAS,kBAAkB,mBAAmB,sBAAsB;","names":[]}
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,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,MAAM,sBAAsB;AACrC,SAAS,sBAAsB,yBAAyB;AACxD,SAAS,UAAU,sBAAsB,yBAAyB;AAClE,SAAS,MAAM,gBAAgB,mBAAmB;AAClD,SAAS,kBAAkB,mBAAmB,sBAAsB;","names":[]}