@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
@@ -1,179 +0,0 @@
1
- import {
2
- configureStore as configureReduxStore,
3
- combineReducers
4
- } from "@reduxjs/toolkit";
5
- import { ApiHandlerHeaders, serializeSiteVersion } from "../api/site-version";
6
- import * as SiteVersionState from "./modules/site-version";
7
- import * as LocaleState from "./modules/locale";
8
- import * as APIResources from "./modules/api-resources";
9
- import * as LocalizedResourcesMap from "./modules/localized-resources-map";
10
- import { ActionTypes } from "./actions";
11
- import { apiResourceFulfilled } from "./actions/internal/read-only-actions";
12
- import { setLocalizedResourceId } from "./host-api";
13
- import { actionMiddleware, middlewareOptions, devToolsConfig } from "./toolkit";
14
- import {
15
- APIResourceType
16
- } from "../api";
17
- const reducer = combineReducers({
18
- siteVersion: SiteVersionState.reducer,
19
- locale: LocaleState.reducer,
20
- apiResources: APIResources.reducer,
21
- localizedResourcesMap: LocalizedResourcesMap.reducer
22
- });
23
- function getLocalizedResourceId(state, locale, resourceId) {
24
- return LocalizedResourcesMap.getLocalizedResourceId(
25
- state.localizedResourcesMap,
26
- locale,
27
- resourceId
28
- );
29
- }
30
- function getHasAPIResource(state, resourceType, resourceId, locale) {
31
- switch (resourceType) {
32
- case APIResourceType.LocalizedGlobalElement:
33
- if (locale == null) {
34
- console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
35
- return false;
36
- }
37
- const localizedId = getLocalizedResourceId(state, locale, resourceId);
38
- return localizedId != null && APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale);
39
- default:
40
- return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale);
41
- }
42
- }
43
- function getAPIResource(state, resourceType, resourceId, locale) {
44
- switch (resourceType) {
45
- case APIResourceType.LocalizedGlobalElement:
46
- if (locale == null) {
47
- console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`);
48
- return null;
49
- }
50
- const localizedId = getLocalizedResourceId(state, locale, resourceId);
51
- return localizedId != null ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale) : null;
52
- default:
53
- return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale);
54
- }
55
- }
56
- function fetchAPIResource(resourceType, resourceId, fetch, locale) {
57
- const fetchVersioned = async (url, version) => {
58
- const response = await fetch(url, {
59
- headers: {
60
- "Content-Type": "application/json",
61
- ...version != null ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(version) } : {}
62
- }
63
- });
64
- if (response.status === 404)
65
- return null;
66
- if (!response.ok)
67
- throw new Error(response.statusText);
68
- if (response.headers.get("content-type")?.includes("application/json") !== true) {
69
- throw new Error(
70
- `Expected JSON response from "${url}" but got "${response.headers.get("content-type")}"`
71
- );
72
- }
73
- return response.json();
74
- };
75
- return async (dispatch, getState) => {
76
- const state = getState();
77
- const version = SiteVersionState.getSiteVersion(state.siteVersion);
78
- if (getHasAPIResource(state, resourceType, resourceId, locale)) {
79
- return getAPIResource(state, resourceType, resourceId, locale);
80
- }
81
- let resource;
82
- switch (resourceType) {
83
- case APIResourceType.Swatch:
84
- resource = await fetchVersioned(`/api/makeswift/swatches/${resourceId}`, version);
85
- break;
86
- case APIResourceType.File:
87
- resource = await fetchVersioned(`/api/makeswift/files/${resourceId}`, version);
88
- break;
89
- case APIResourceType.Typography:
90
- resource = await fetchVersioned(
91
- `/api/makeswift/typographies/${resourceId}`,
92
- version
93
- );
94
- break;
95
- case APIResourceType.GlobalElement:
96
- resource = await fetchVersioned(
97
- `/api/makeswift/global-elements/${resourceId}`,
98
- version
99
- );
100
- break;
101
- case APIResourceType.LocalizedGlobalElement: {
102
- if (locale == null)
103
- throw new Error("Locale is required to fetch LocalizedGlobalElement");
104
- if (getLocalizedResourceId(state, locale, resourceId) === null) {
105
- return null;
106
- }
107
- resource = await fetchVersioned(
108
- `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,
109
- version
110
- );
111
- dispatch(
112
- setLocalizedResourceId({
113
- locale,
114
- resourceId,
115
- localizedResourceId: resource?.id ?? null
116
- })
117
- );
118
- break;
119
- }
120
- case APIResourceType.PagePathnameSlice: {
121
- const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, "http://n");
122
- if (locale != null)
123
- url.searchParams.set("locale", locale);
124
- resource = await fetchVersioned(url.pathname + url.search, version);
125
- break;
126
- }
127
- case APIResourceType.Table:
128
- resource = await fetchVersioned(`/api/makeswift/tables/${resourceId}`, version);
129
- break;
130
- default:
131
- resource = null;
132
- }
133
- dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale));
134
- return resource;
135
- };
136
- }
137
- function defaultLocaleMiddleware() {
138
- return actionMiddleware(({ getState }) => (next) => {
139
- return (action) => {
140
- switch (action.type) {
141
- case ActionTypes.CHANGE_API_RESOURCE:
142
- case ActionTypes.EVICT_API_RESOURCE:
143
- case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {
144
- const { locale } = action.payload;
145
- return next({
146
- ...action,
147
- payload: {
148
- ...action.payload,
149
- locale: locale ?? LocaleState.getLocale(getState().locale)
150
- }
151
- });
152
- }
153
- }
154
- return next(action);
155
- };
156
- });
157
- }
158
- function configureStore({ preloadedState }) {
159
- return configureReduxStore({
160
- reducer,
161
- preloadedState,
162
- middleware: (getDefaultMiddleware) => getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware()),
163
- devTools: devToolsConfig({
164
- name: `API client store (${(/* @__PURE__ */ new Date()).toISOString()})`,
165
- actionsDenylist: [
166
- ActionTypes.BUILDER_POINTER_MOVE,
167
- ActionTypes.HANDLE_POINTER_MOVE,
168
- ActionTypes.ELEMENT_FROM_POINT_CHANGE
169
- ]
170
- })
171
- });
172
- }
173
- export {
174
- configureStore,
175
- fetchAPIResource,
176
- getAPIResource,
177
- getHasAPIResource
178
- };
179
- //# sourceMappingURL=makeswift-api-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/state/makeswift-api-client.ts"],"sourcesContent":["import {\n configureStore as configureReduxStore,\n combineReducers,\n type ThunkAction,\n type ThunkMiddleware,\n type ThunkDispatch,\n UnknownAction,\n} from '@reduxjs/toolkit'\n\nimport { type SiteVersion, ApiHandlerHeaders, serializeSiteVersion } from '../api/site-version'\n\nimport * as SiteVersionState from './modules/site-version'\nimport * as LocaleState from './modules/locale'\nimport * as APIResources from './modules/api-resources'\nimport * as LocalizedResourcesMap from './modules/localized-resources-map'\n\nimport { type Action, ActionTypes } from './actions'\nimport { apiResourceFulfilled } from './actions/internal/read-only-actions'\nimport { setLocalizedResourceId } from './host-api'\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\n\nimport {\n APIResourceType,\n type APIResource,\n type Swatch,\n type File,\n type Typography,\n type GlobalElement,\n type PagePathnameSlice,\n type Table,\n type LocalizedGlobalElement,\n type APIResourceLocale,\n} from '../api'\n\nconst reducer = combineReducers({\n siteVersion: SiteVersionState.reducer,\n locale: LocaleState.reducer,\n apiResources: APIResources.reducer,\n localizedResourcesMap: LocalizedResourcesMap.reducer,\n})\n\nexport type State = ReturnType<typeof reducer>\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>\n\nexport type SerializedState = {\n apiResources: APIResources.SerializedState\n localizedResourcesMap: LocalizedResourcesMap.SerializedState\n}\n\nfunction getLocalizedResourceId(\n state: State,\n locale: string,\n resourceId: string,\n): string | undefined | null {\n return LocalizedResourcesMap.getLocalizedResourceId(\n state.localizedResourcesMap,\n locale,\n resourceId,\n )\n}\n\nexport function getHasAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: APIResourceType,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): boolean {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return false\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return (\n localizedId != null &&\n APIResources.getHasAPIResource(state.apiResources, resourceType, localizedId, locale)\n )\n\n default:\n return APIResources.getHasAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\nexport function getAPIResource<T extends APIResourceType>(\n state: State,\n resourceType: T,\n resourceId: string,\n locale?: APIResourceLocale<T>,\n): Extract<APIResource, { __typename: T }> | null {\n switch (resourceType) {\n case APIResourceType.LocalizedGlobalElement:\n if (locale == null) {\n console.error(`Attempt to access ${resourceType} ${resourceId} without a locale`)\n return null\n }\n\n const localizedId = getLocalizedResourceId(state, locale, resourceId)\n return localizedId != null\n ? APIResources.getAPIResource(state.apiResources, resourceType, localizedId, locale)\n : null\n\n default:\n return APIResources.getAPIResource(state.apiResources, resourceType, resourceId, locale)\n }\n}\n\ntype Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>\n\nexport function fetchAPIResource<T extends APIResourceType>(\n resourceType: T,\n resourceId: string,\n fetch: HttpFetch,\n locale?: APIResourceLocale<T>,\n): Thunk<Promise<Extract<APIResource, { __typename: T }> | null>> {\n const fetchVersioned = async <T>(url: string, version: SiteVersion | null): Promise<T | null> => {\n const response = await fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n ...(version != null\n ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(version) }\n : {}),\n },\n })\n\n if (response.status === 404) return null\n if (!response.ok) throw new Error(response.statusText)\n\n if (response.headers.get('content-type')?.includes('application/json') !== true) {\n throw new Error(\n `Expected JSON response from \"${url}\" but got \"${response.headers.get('content-type')}\"`,\n )\n }\n\n return response.json()\n }\n\n return async (dispatch, getState) => {\n const state = getState()\n const version = SiteVersionState.getSiteVersion(state.siteVersion)\n\n if (getHasAPIResource(state, resourceType, resourceId, locale)) {\n return getAPIResource(state, resourceType, resourceId, locale)\n }\n\n let resource: APIResource | null\n\n switch (resourceType) {\n case APIResourceType.Swatch:\n resource = await fetchVersioned<Swatch>(`/api/makeswift/swatches/${resourceId}`, version)\n break\n\n case APIResourceType.File:\n resource = await fetchVersioned<File>(`/api/makeswift/files/${resourceId}`, version)\n break\n\n case APIResourceType.Typography:\n resource = await fetchVersioned<Typography>(\n `/api/makeswift/typographies/${resourceId}`,\n version,\n )\n break\n\n case APIResourceType.GlobalElement:\n resource = await fetchVersioned<GlobalElement>(\n `/api/makeswift/global-elements/${resourceId}`,\n version,\n )\n break\n\n case APIResourceType.LocalizedGlobalElement: {\n if (locale == null) throw new Error('Locale is required to fetch LocalizedGlobalElement')\n\n // If `getLocalizedResourceId` returns null, it means we have tried to fetch the resource,\n // but the resource is not available. If we haven't fetched it yet, it'll return undefined.\n if (getLocalizedResourceId(state, locale, resourceId) === null) {\n return null\n }\n\n resource = await fetchVersioned<LocalizedGlobalElement>(\n `/api/makeswift/localized-global-elements/${resourceId}/${locale}`,\n version,\n )\n\n dispatch(\n setLocalizedResourceId({\n locale,\n resourceId,\n localizedResourceId: resource?.id ?? null,\n }),\n )\n\n break\n }\n\n case APIResourceType.PagePathnameSlice: {\n const url = new URL(`/api/makeswift/page-pathname-slices/${resourceId}`, 'http://n')\n\n if (locale != null) url.searchParams.set('locale', locale)\n\n resource = await fetchVersioned<PagePathnameSlice>(url.pathname + url.search, version)\n break\n }\n\n case APIResourceType.Table:\n resource = await fetchVersioned<Table>(`/api/makeswift/tables/${resourceId}`, version)\n break\n\n default:\n resource = null\n }\n\n dispatch(apiResourceFulfilled(resourceType, resourceId, resource, locale))\n\n return resource as Extract<APIResource, { __typename: T }> | null\n }\n}\n\n// FIXME: this middleware can be removed once we've upgraded the builder\n// to always provide the locale when dispatching resource actions\nfunction defaultLocaleMiddleware(): ThunkMiddleware<State, UnknownAction> {\n return actionMiddleware(({ getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ActionTypes.CHANGE_API_RESOURCE:\n case ActionTypes.EVICT_API_RESOURCE:\n case ActionTypes.SET_LOCALIZED_RESOURCE_ID: {\n const { locale } = action.payload\n return next({\n ...action,\n payload: {\n ...action.payload,\n locale: locale ?? LocaleState.getLocale(getState().locale),\n },\n } as Action)\n }\n }\n\n return next(action)\n }\n })\n}\n\nexport function configureStore({ preloadedState }: { preloadedState: Partial<State> }) {\n return configureReduxStore({\n reducer,\n preloadedState,\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat(defaultLocaleMiddleware()),\n\n devTools: devToolsConfig({\n name: `API client store (${new Date().toISOString()})`,\n actionsDenylist: [\n ActionTypes.BUILDER_POINTER_MOVE,\n ActionTypes.HANDLE_POINTER_MOVE,\n ActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":"AAAA;AAAA,EACE,kBAAkB;AAAA,EAClB;AAAA,OAKK;AAEP,SAA2B,mBAAmB,4BAA4B;AAE1E,YAAY,sBAAsB;AAClC,YAAY,iBAAiB;AAC7B,YAAY,kBAAkB;AAC9B,YAAY,2BAA2B;AAEvC,SAAsB,mBAAmB;AACzC,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,kBAAkB,mBAAmB,sBAAsB;AAEpE;AAAA,EACE;AAAA,OAUK;AAEP,MAAM,UAAU,gBAAgB;AAAA,EAC9B,aAAa,iBAAiB;AAAA,EAC9B,QAAQ,YAAY;AAAA,EACpB,cAAc,aAAa;AAAA,EAC3B,uBAAuB,sBAAsB;AAC/C,CAAC;AAWD,SAAS,uBACP,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,gBAAgB;AACnB,UAAI,UAAU,MAAM;AAClB,gBAAQ,MAAM,qBAAqB,YAAY,IAAI,UAAU,mBAAmB;AAChF,eAAO;AAAA,MACT;AAEA,YAAM,cAAc,uBAAuB,OAA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aAAS,qBAAqB,cAAc,YAAY,UAAU,MAAM,CAAC;AAEzE,WAAO;AAAA,EACT;AACF;AAIA,SAAS,0BAAiE;AACxE,SAAO,iBAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,YAAY;AAAA,QACjB,KAAK,YAAY;AAAA,QACjB,KAAK,YAAY,2BAA2B;AAC1C,gBAAM,EAAE,OAAO,IAAI,OAAO;AAC1B,iBAAO,KAAK;AAAA,YACV,GAAG;AAAA,YACH,SAAS;AAAA,cACP,GAAG,OAAO;AAAA,cACV,QAAQ,UAAU,YAAY,UAAU,SAAS,EAAE,MAAM;AAAA,YAC3D;AAAA,UACF,CAAW;AAAA,QACb;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;AAEO,SAAS,eAAe,EAAE,eAAe,GAAuC;AACrF,SAAO,oBAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IAEA,YAAY,0BACV,qBAAqB,iBAAiB,EAAE,OAAO,wBAAwB,CAAC;AAAA,IAE1E,UAAU,eAAe;AAAA,MACvB,MAAM,sBAAqB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MACnD,iBAAiB;AAAA,QACf,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,YAAY;AAAA,MACd;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
@@ -1,51 +0,0 @@
1
- import { type ThunkAction, type ThunkDispatch, UnknownAction } from '@reduxjs/toolkit';
2
- import * as SiteVersionState from './modules/site-version';
3
- import * as LocaleState from './modules/locale';
4
- import * as APIResources from './modules/api-resources';
5
- import * as LocalizedResourcesMap from './modules/localized-resources-map';
6
- import { type Action } from './actions';
7
- import { APIResourceType, type APIResource, type APIResourceLocale } from '../api';
8
- declare const reducer: import("@reduxjs/toolkit").Reducer<{
9
- siteVersion: SiteVersionState.State;
10
- locale: LocaleState.State;
11
- apiResources: APIResources.State;
12
- localizedResourcesMap: Map<string, Map<string, string | null>>;
13
- }, Action | UnknownAction, Partial<{
14
- siteVersion: SiteVersionState.State | undefined;
15
- locale: LocaleState.State | undefined;
16
- apiResources: APIResources.State | undefined;
17
- localizedResourcesMap: Map<string, Map<string, string | null>> | undefined;
18
- }>>;
19
- export type State = ReturnType<typeof reducer>;
20
- export type Dispatch = ThunkDispatch<State, unknown, Action>;
21
- export type HttpFetch = (url: string | URL, init?: RequestInit) => Promise<Response>;
22
- export type SerializedState = {
23
- apiResources: APIResources.SerializedState;
24
- localizedResourcesMap: LocalizedResourcesMap.SerializedState;
25
- };
26
- export declare function getHasAPIResource<T extends APIResourceType>(state: State, resourceType: APIResourceType, resourceId: string, locale?: APIResourceLocale<T>): boolean;
27
- export declare function getAPIResource<T extends APIResourceType>(state: State, resourceType: T, resourceId: string, locale?: APIResourceLocale<T>): Extract<APIResource, {
28
- __typename: T;
29
- }> | null;
30
- type Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>;
31
- export declare function fetchAPIResource<T extends APIResourceType>(resourceType: T, resourceId: string, fetch: HttpFetch, locale?: APIResourceLocale<T>): Thunk<Promise<Extract<APIResource, {
32
- __typename: T;
33
- }> | null>>;
34
- export declare function configureStore({ preloadedState }: {
35
- preloadedState: Partial<State>;
36
- }): import("@reduxjs/toolkit").EnhancedStore<{
37
- siteVersion: SiteVersionState.State;
38
- locale: LocaleState.State;
39
- apiResources: APIResources.State;
40
- localizedResourcesMap: Map<string, Map<string, string | null>>;
41
- }, Action | UnknownAction, import("@reduxjs/toolkit").Tuple<[import("@reduxjs/toolkit").StoreEnhancer<{
42
- dispatch: ThunkDispatch<{
43
- siteVersion: SiteVersionState.State;
44
- locale: LocaleState.State;
45
- apiResources: APIResources.State;
46
- localizedResourcesMap: Map<string, Map<string, string | null>>;
47
- }, undefined, UnknownAction>;
48
- }>, import("@reduxjs/toolkit").StoreEnhancer]>>;
49
- export type Store = ReturnType<typeof configureStore>;
50
- export {};
51
- //# sourceMappingURL=makeswift-api-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"makeswift-api-client.d.ts","sourceRoot":"","sources":["../../../src/state/makeswift-api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAClB,aAAa,EACd,MAAM,kBAAkB,CAAA;AAIzB,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAA;AACvD,OAAO,KAAK,qBAAqB,MAAM,mCAAmC,CAAA;AAE1E,OAAO,EAAE,KAAK,MAAM,EAAe,MAAM,WAAW,CAAA;AAKpD,OAAO,EACL,eAAe,EACf,KAAK,WAAW,EAQhB,KAAK,iBAAiB,EACvB,MAAM,QAAQ,CAAA;AAEf,QAAA,MAAM,OAAO;;;;;;;;;;GAKX,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAA;AAC9C,MAAM,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAC5D,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEpF,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,YAAY,CAAC,eAAe,CAAA;IAC1C,qBAAqB,EAAE,qBAAqB,CAAC,eAAe,CAAA;CAC7D,CAAA;AAcD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,eAAe,EACzD,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,eAAe,EAC7B,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,OAAO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