@makeswift/runtime 0.27.3 → 0.27.4
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-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +3 -3
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +3 -3
- package/package.json +3 -3
- package/dist/cjs/api/api-resources-client.js +0 -160
- package/dist/cjs/api/api-resources-client.js.map +0 -1
- package/dist/cjs/api/react.js +0 -256
- package/dist/cjs/api/react.js.map +0 -1
- package/dist/cjs/api-handler/handlers/webhook/diff-projection.js +0 -62
- package/dist/cjs/api-handler/handlers/webhook/diff-projection.js.map +0 -1
- package/dist/cjs/box-model.js +0 -33
- package/dist/cjs/box-model.js.map +0 -1
- package/dist/cjs/builder/serialization.js +0 -78
- package/dist/cjs/builder/serialization.js.map +0 -1
- package/dist/cjs/components/builtin/index.js +0 -84
- package/dist/cjs/components/builtin/index.js.map +0 -1
- package/dist/cjs/components/index.js +0 -25
- package/dist/cjs/components/index.js.map +0 -1
- package/dist/cjs/controls/rich-text-v2/translation.js +0 -187
- package/dist/cjs/controls/rich-text-v2/translation.js.map +0 -1
- package/dist/cjs/controls/serialization/base/index.js +0 -78
- package/dist/cjs/controls/serialization/base/index.js.map +0 -1
- package/dist/cjs/controls/serialization/base/visitor.js +0 -59
- package/dist/cjs/controls/serialization/base/visitor.js.map +0 -1
- package/dist/cjs/controls/serialization/index.js +0 -55
- package/dist/cjs/controls/serialization/index.js.map +0 -1
- package/dist/cjs/controls/serialization/message-port/function-serialization.js +0 -79
- package/dist/cjs/controls/serialization/message-port/function-serialization.js.map +0 -1
- package/dist/cjs/controls/serialization/message-port/index.js +0 -25
- package/dist/cjs/controls/serialization/message-port/index.js.map +0 -1
- package/dist/cjs/controls/serialization/message-port/visitor.js +0 -48
- package/dist/cjs/controls/serialization/message-port/visitor.js.map +0 -1
- package/dist/cjs/core/index.js +0 -57
- package/dist/cjs/core/index.js.map +0 -1
- package/dist/cjs/next/fetch.js +0 -30
- package/dist/cjs/next/fetch.js.map +0 -1
- package/dist/cjs/prop-controllers/index.js +0 -48
- package/dist/cjs/prop-controllers/index.js.map +0 -1
- package/dist/cjs/prop-controllers/serialization.js +0 -355
- package/dist/cjs/prop-controllers/serialization.js.map +0 -1
- package/dist/cjs/react.js +0 -40
- package/dist/cjs/react.js.map +0 -1
- package/dist/cjs/runtimes/react/components/LiveProvider.js +0 -50
- package/dist/cjs/runtimes/react/components/LiveProvider.js.map +0 -1
- package/dist/cjs/runtimes/react/components/MakeswiftFonts.js +0 -33
- package/dist/cjs/runtimes/react/components/MakeswiftFonts.js.map +0 -1
- package/dist/cjs/runtimes/react/components/PreviewProvider.js +0 -57
- package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +0 -1
- package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js +0 -67
- package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js.map +0 -1
- package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js +0 -39
- package/dist/cjs/runtimes/react/hooks/use-current-breakpoint.js.map +0 -1
- package/dist/cjs/runtimes/react/hooks/use-is-preview.js +0 -33
- package/dist/cjs/runtimes/react/hooks/use-is-preview.js.map +0 -1
- package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js +0 -59
- package/dist/cjs/runtimes/react/lib/resolved-style-to-css.js.map +0 -1
- package/dist/cjs/runtimes/react/resource-resolver.js +0 -52
- package/dist/cjs/runtimes/react/resource-resolver.js.map +0 -1
- package/dist/cjs/state/actions/internal.js +0 -205
- package/dist/cjs/state/actions/internal.js.map +0 -1
- package/dist/cjs/state/actions.js +0 -423
- package/dist/cjs/state/actions.js.map +0 -1
- package/dist/cjs/state/api-client/client-store.js +0 -81
- package/dist/cjs/state/api-client/client-store.js.map +0 -1
- package/dist/cjs/state/api-client/fetch-api-resource.js +0 -125
- package/dist/cjs/state/api-client/fetch-api-resource.js.map +0 -1
- package/dist/cjs/state/api-client/state.js +0 -89
- package/dist/cjs/state/api-client/state.js.map +0 -1
- package/dist/cjs/state/api-client/store.js +0 -36
- package/dist/cjs/state/api-client/store.js.map +0 -1
- package/dist/cjs/state/builder-api/api.js +0 -17
- package/dist/cjs/state/builder-api/api.js.map +0 -1
- package/dist/cjs/state/builder-api/navigation-listener.js +0 -110
- package/dist/cjs/state/builder-api/navigation-listener.js.map +0 -1
- package/dist/cjs/state/mixins/breakpoint-watch.js +0 -72
- package/dist/cjs/state/mixins/breakpoint-watch.js.map +0 -1
- package/dist/cjs/state/mixins/setup-teardown.js +0 -35
- package/dist/cjs/state/mixins/setup-teardown.js.map +0 -1
- package/dist/cjs/state/modules/box-models.js +0 -127
- package/dist/cjs/state/modules/box-models.js.map +0 -1
- package/dist/cjs/state/modules/element-imperative-handles.js +0 -60
- package/dist/cjs/state/modules/element-imperative-handles.js.map +0 -1
- package/dist/cjs/state/modules/is-preview.js +0 -47
- package/dist/cjs/state/modules/is-preview.js.map +0 -1
- package/dist/cjs/state/modules/pointer.js +0 -47
- package/dist/cjs/state/modules/pointer.js.map +0 -1
- package/dist/cjs/state/modules/read-write-documents.js +0 -98
- package/dist/cjs/state/modules/read-write-documents.js.map +0 -1
- package/dist/cjs/state/react-builder-preview.js +0 -610
- package/dist/cjs/state/react-builder-preview.js.map +0 -1
- package/dist/cjs/state/react-page.js +0 -355
- package/dist/cjs/state/react-page.js.map +0 -1
- package/dist/cjs/utils/ref-counted-map.js +0 -120
- package/dist/cjs/utils/ref-counted-map.js.map +0 -1
- package/dist/esm/api/api-resources-client.js +0 -127
- package/dist/esm/api/api-resources-client.js.map +0 -1
- package/dist/esm/api/react.js +0 -223
- package/dist/esm/api/react.js.map +0 -1
- package/dist/esm/api-handler/handlers/webhook/diff-projection.js +0 -38
- package/dist/esm/api-handler/handlers/webhook/diff-projection.js.map +0 -1
- package/dist/esm/box-model.js +0 -7
- package/dist/esm/box-model.js.map +0 -1
- package/dist/esm/builder/serialization.js +0 -59
- package/dist/esm/builder/serialization.js.map +0 -1
- package/dist/esm/components/builtin/index.js +0 -34
- package/dist/esm/components/builtin/index.js.map +0 -1
- package/dist/esm/components/index.js +0 -3
- package/dist/esm/components/index.js.map +0 -1
- package/dist/esm/controls/rich-text-v2/translation.js +0 -152
- package/dist/esm/controls/rich-text-v2/translation.js.map +0 -1
- package/dist/esm/controls/serialization/base/index.js +0 -78
- package/dist/esm/controls/serialization/base/index.js.map +0 -1
- package/dist/esm/controls/serialization/base/visitor.js +0 -39
- package/dist/esm/controls/serialization/base/visitor.js.map +0 -1
- package/dist/esm/controls/serialization/index.js +0 -30
- package/dist/esm/controls/serialization/index.js.map +0 -1
- package/dist/esm/controls/serialization/message-port/function-serialization.js +0 -52
- package/dist/esm/controls/serialization/message-port/function-serialization.js.map +0 -1
- package/dist/esm/controls/serialization/message-port/index.js +0 -3
- package/dist/esm/controls/serialization/message-port/index.js.map +0 -1
- package/dist/esm/controls/serialization/message-port/visitor.js +0 -24
- package/dist/esm/controls/serialization/message-port/visitor.js.map +0 -1
- package/dist/esm/core/index.js +0 -35
- package/dist/esm/core/index.js.map +0 -1
- package/dist/esm/next/fetch.js +0 -6
- package/dist/esm/next/fetch.js.map +0 -1
- package/dist/esm/prop-controllers/index.js +0 -11
- package/dist/esm/prop-controllers/index.js.map +0 -1
- package/dist/esm/prop-controllers/serialization.js +0 -338
- package/dist/esm/prop-controllers/serialization.js.map +0 -1
- package/dist/esm/react.js +0 -11
- package/dist/esm/react.js.map +0 -1
- package/dist/esm/runtimes/react/components/LiveProvider.js +0 -20
- package/dist/esm/runtimes/react/components/LiveProvider.js.map +0 -1
- package/dist/esm/runtimes/react/components/MakeswiftFonts.js +0 -9
- package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +0 -1
- package/dist/esm/runtimes/react/components/PreviewProvider.js +0 -27
- package/dist/esm/runtimes/react/components/PreviewProvider.js.map +0 -1
- package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js +0 -43
- package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js.map +0 -1
- package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js +0 -15
- package/dist/esm/runtimes/react/hooks/use-current-breakpoint.js.map +0 -1
- package/dist/esm/runtimes/react/hooks/use-is-preview.js +0 -9
- package/dist/esm/runtimes/react/hooks/use-is-preview.js.map +0 -1
- package/dist/esm/runtimes/react/lib/resolved-style-to-css.js +0 -38
- package/dist/esm/runtimes/react/lib/resolved-style-to-css.js.map +0 -1
- package/dist/esm/runtimes/react/resource-resolver.js +0 -28
- package/dist/esm/runtimes/react/resource-resolver.js.map +0 -1
- package/dist/esm/state/actions/internal.js +0 -162
- package/dist/esm/state/actions/internal.js.map +0 -1
- package/dist/esm/state/actions.js +0 -349
- package/dist/esm/state/actions.js.map +0 -1
- package/dist/esm/state/api-client/client-store.js +0 -49
- package/dist/esm/state/api-client/client-store.js.map +0 -1
- package/dist/esm/state/api-client/fetch-api-resource.js +0 -93
- package/dist/esm/state/api-client/fetch-api-resource.js.map +0 -1
- package/dist/esm/state/api-client/state.js +0 -52
- package/dist/esm/state/api-client/state.js.map +0 -1
- package/dist/esm/state/api-client/store.js +0 -12
- package/dist/esm/state/api-client/store.js.map +0 -1
- package/dist/esm/state/builder-api/api.js +0 -1
- package/dist/esm/state/builder-api/api.js.map +0 -1
- package/dist/esm/state/builder-api/navigation-listener.js +0 -86
- package/dist/esm/state/builder-api/navigation-listener.js.map +0 -1
- package/dist/esm/state/mixins/breakpoint-watch.js +0 -48
- package/dist/esm/state/mixins/breakpoint-watch.js.map +0 -1
- package/dist/esm/state/mixins/setup-teardown.js +0 -11
- package/dist/esm/state/mixins/setup-teardown.js.map +0 -1
- package/dist/esm/state/modules/box-models.js +0 -98
- package/dist/esm/state/modules/box-models.js.map +0 -1
- package/dist/esm/state/modules/element-imperative-handles.js +0 -35
- package/dist/esm/state/modules/element-imperative-handles.js.map +0 -1
- package/dist/esm/state/modules/is-preview.js +0 -21
- package/dist/esm/state/modules/is-preview.js.map +0 -1
- package/dist/esm/state/modules/pointer.js +0 -22
- package/dist/esm/state/modules/pointer.js.map +0 -1
- package/dist/esm/state/modules/read-write-documents.js +0 -60
- package/dist/esm/state/modules/read-write-documents.js.map +0 -1
- package/dist/esm/state/react-builder-preview.js +0 -590
- package/dist/esm/state/react-builder-preview.js.map +0 -1
- package/dist/esm/state/react-page.js +0 -319
- package/dist/esm/state/react-page.js.map +0 -1
- package/dist/esm/utils/ref-counted-map.js +0 -96
- package/dist/esm/utils/ref-counted-map.js.map +0 -1
- package/dist/types/api/api-resources-client.d.ts +0 -57
- package/dist/types/api/api-resources-client.d.ts.map +0 -1
- package/dist/types/api/react.d.ts +0 -82
- package/dist/types/api/react.d.ts.map +0 -1
- package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +0 -201
- package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts.map +0 -1
- package/dist/types/box-model.d.ts +0 -3
- package/dist/types/box-model.d.ts.map +0 -1
- package/dist/types/builder/serialization.d.ts +0 -23
- package/dist/types/builder/serialization.d.ts.map +0 -1
- package/dist/types/builder/serialization.test.d.ts +0 -2
- package/dist/types/builder/serialization.test.d.ts.map +0 -1
- package/dist/types/client/tests/client.get-component-snapshots.test.d.ts +0 -2
- package/dist/types/client/tests/client.get-component-snapshots.test.d.ts.map +0 -1
- package/dist/types/client/tests/client.introspect-many.test.d.ts +0 -2
- package/dist/types/client/tests/client.introspect-many.test.d.ts.map +0 -1
- package/dist/types/components/builtin/index.d.ts +0 -17
- package/dist/types/components/builtin/index.d.ts.map +0 -1
- package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts +0 -3
- package/dist/types/components/hooks/__tests__/useMediaQuery.test.d.ts.map +0 -1
- package/dist/types/components/index.d.ts +0 -3
- package/dist/types/components/index.d.ts.map +0 -1
- package/dist/types/controls/rich-text-v2/translation.d.ts +0 -6
- package/dist/types/controls/rich-text-v2/translation.d.ts.map +0 -1
- package/dist/types/controls/serialization/base/index.d.ts +0 -10
- package/dist/types/controls/serialization/base/index.d.ts.map +0 -1
- package/dist/types/controls/serialization/base/visitor.d.ts +0 -7
- package/dist/types/controls/serialization/base/visitor.d.ts.map +0 -1
- package/dist/types/controls/serialization/index.d.ts +0 -10
- package/dist/types/controls/serialization/index.d.ts.map +0 -1
- package/dist/types/controls/serialization/message-port/function-serialization.d.ts +0 -16
- package/dist/types/controls/serialization/message-port/function-serialization.d.ts.map +0 -1
- package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts +0 -2
- package/dist/types/controls/serialization/message-port/function-serialization.test.d.ts.map +0 -1
- package/dist/types/controls/serialization/message-port/index.d.ts +0 -3
- package/dist/types/controls/serialization/message-port/index.d.ts.map +0 -1
- package/dist/types/controls/serialization/message-port/visitor.d.ts +0 -7
- package/dist/types/controls/serialization/message-port/visitor.d.ts.map +0 -1
- package/dist/types/core/index.d.ts +0 -2
- package/dist/types/core/index.d.ts.map +0 -1
- package/dist/types/next/api-handler/config/pages-router.test.d.ts +0 -2
- package/dist/types/next/api-handler/config/pages-router.test.d.ts.map +0 -1
- package/dist/types/next/components/tests/controls/code-control.test.d.ts +0 -2
- package/dist/types/next/components/tests/controls/code-control.test.d.ts.map +0 -1
- package/dist/types/next/components/tests/makeswift-component-rendering.test.d.ts +0 -3
- package/dist/types/next/components/tests/makeswift-component-rendering.test.d.ts.map +0 -1
- package/dist/types/next/fetch.d.ts +0 -3
- package/dist/types/next/fetch.d.ts.map +0 -1
- package/dist/types/prop-controllers/index.d.ts +0 -8
- package/dist/types/prop-controllers/index.d.ts.map +0 -1
- package/dist/types/prop-controllers/serialization.d.ts +0 -228
- package/dist/types/prop-controllers/serialization.d.ts.map +0 -1
- package/dist/types/react.d.ts +0 -4
- package/dist/types/react.d.ts.map +0 -1
- package/dist/types/runtimes/react/components/LiveProvider.d.ts +0 -3
- package/dist/types/runtimes/react/components/LiveProvider.d.ts.map +0 -1
- package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts +0 -7
- package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts.map +0 -1
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts +0 -3
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +0 -1
- package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts +0 -4
- package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts.map +0 -1
- package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts +0 -3
- package/dist/types/runtimes/react/hooks/use-current-breakpoint.d.ts.map +0 -1
- package/dist/types/runtimes/react/hooks/use-is-preview.d.ts +0 -2
- package/dist/types/runtimes/react/hooks/use-is-preview.d.ts.map +0 -1
- package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts +0 -4
- package/dist/types/runtimes/react/lib/resolved-style-to-css.d.ts.map +0 -1
- package/dist/types/runtimes/react/resource-resolver.d.ts +0 -10
- package/dist/types/runtimes/react/resource-resolver.d.ts.map +0 -1
- package/dist/types/state/__tests__/react-page.test.d.ts +0 -2
- package/dist/types/state/__tests__/react-page.test.d.ts.map +0 -1
- package/dist/types/state/actions/internal.d.ts +0 -181
- package/dist/types/state/actions/internal.d.ts.map +0 -1
- package/dist/types/state/actions.d.ts +0 -461
- package/dist/types/state/actions.d.ts.map +0 -1
- package/dist/types/state/api-client/client-store.d.ts +0 -6
- package/dist/types/state/api-client/client-store.d.ts.map +0 -1
- package/dist/types/state/api-client/fetch-api-resource.d.ts +0 -11
- package/dist/types/state/api-client/fetch-api-resource.d.ts.map +0 -1
- package/dist/types/state/api-client/state.d.ts +0 -30
- package/dist/types/state/api-client/state.d.ts.map +0 -1
- package/dist/types/state/api-client/store.d.ts +0 -18
- package/dist/types/state/api-client/store.d.ts.map +0 -1
- package/dist/types/state/builder-api/api.d.ts +0 -9
- package/dist/types/state/builder-api/api.d.ts.map +0 -1
- package/dist/types/state/builder-api/navigation-listener.d.ts +0 -3
- package/dist/types/state/builder-api/navigation-listener.d.ts.map +0 -1
- package/dist/types/state/mixins/breakpoint-watch.d.ts +0 -11
- package/dist/types/state/mixins/breakpoint-watch.d.ts.map +0 -1
- package/dist/types/state/mixins/setup-teardown.d.ts +0 -7
- package/dist/types/state/mixins/setup-teardown.d.ts.map +0 -1
- package/dist/types/state/modules/box-models.d.ts +0 -23
- package/dist/types/state/modules/box-models.d.ts.map +0 -1
- package/dist/types/state/modules/element-imperative-handles.d.ts +0 -7
- package/dist/types/state/modules/element-imperative-handles.d.ts.map +0 -1
- package/dist/types/state/modules/is-preview.d.ts +0 -6
- package/dist/types/state/modules/is-preview.d.ts.map +0 -1
- package/dist/types/state/modules/pointer.d.ts +0 -12
- package/dist/types/state/modules/pointer.d.ts.map +0 -1
- package/dist/types/state/modules/read-write-documents.d.ts +0 -14
- package/dist/types/state/modules/read-write-documents.d.ts.map +0 -1
- package/dist/types/state/react-builder-preview.d.ts +0 -110
- package/dist/types/state/react-builder-preview.d.ts.map +0 -1
- package/dist/types/state/react-page.d.ts +0 -149
- package/dist/types/state/react-page.d.ts.map +0 -1
- package/dist/types/utils/__tests__/ref-counted-map.test.d.ts +0 -2
- package/dist/types/utils/__tests__/ref-counted-map.test.d.ts.map +0 -1
- package/dist/types/utils/ref-counted-map.d.ts +0 -32
- package/dist/types/utils/ref-counted-map.d.ts.map +0 -1
|
@@ -1,127 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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":"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","names":[]}
|
package/dist/esm/api/react.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import * as MakeswiftApiClient from "../state/makeswift-api-client";
|
|
2
|
-
import {
|
|
3
|
-
APIResourceType
|
|
4
|
-
} from "./types";
|
|
5
|
-
import { GraphQLClient } from "./graphql/client";
|
|
6
|
-
import { CreateTableRecordMutation } from "./graphql/documents";
|
|
7
|
-
const CacheData = {
|
|
8
|
-
empty() {
|
|
9
|
-
return {
|
|
10
|
-
apiResources: {},
|
|
11
|
-
localizedResourcesMap: {}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
class MakeswiftHostApiClient {
|
|
16
|
-
graphqlClient;
|
|
17
|
-
makeswiftApiClient;
|
|
18
|
-
subscribe;
|
|
19
|
-
fetch;
|
|
20
|
-
constructor({
|
|
21
|
-
uri,
|
|
22
|
-
fetch,
|
|
23
|
-
cacheData,
|
|
24
|
-
locale
|
|
25
|
-
}) {
|
|
26
|
-
this.graphqlClient = new GraphQLClient(uri);
|
|
27
|
-
this.makeswiftApiClient = MakeswiftApiClient.configureStore({
|
|
28
|
-
serializedState: cacheData,
|
|
29
|
-
defaultLocale: locale
|
|
30
|
-
});
|
|
31
|
-
this.fetch = fetch;
|
|
32
|
-
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
33
|
-
}
|
|
34
|
-
readSwatch(swatchId) {
|
|
35
|
-
return MakeswiftApiClient.getAPIResource(
|
|
36
|
-
this.makeswiftApiClient.getState(),
|
|
37
|
-
APIResourceType.Swatch,
|
|
38
|
-
swatchId
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
async fetchSwatch(swatchId) {
|
|
42
|
-
return await this.makeswiftApiClient.dispatch(
|
|
43
|
-
MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch)
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
resolveSwatch(swatchId) {
|
|
47
|
-
return this.resolveResource(APIResourceType.Swatch, {
|
|
48
|
-
id: swatchId,
|
|
49
|
-
read: (id) => this.readSwatch(id),
|
|
50
|
-
fetch: (id) => this.fetchSwatch(id)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
readFile(fileId) {
|
|
54
|
-
return MakeswiftApiClient.getAPIResource(
|
|
55
|
-
this.makeswiftApiClient.getState(),
|
|
56
|
-
APIResourceType.File,
|
|
57
|
-
fileId
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
async fetchFile(fileId) {
|
|
61
|
-
return await this.makeswiftApiClient.dispatch(
|
|
62
|
-
MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch)
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
resolveFile(fileId) {
|
|
66
|
-
return this.resolveResource(APIResourceType.File, {
|
|
67
|
-
id: fileId,
|
|
68
|
-
read: (id) => this.readFile(id),
|
|
69
|
-
fetch: (id) => this.fetchFile(id)
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
readTypography(typographyId) {
|
|
73
|
-
return MakeswiftApiClient.getAPIResource(
|
|
74
|
-
this.makeswiftApiClient.getState(),
|
|
75
|
-
APIResourceType.Typography,
|
|
76
|
-
typographyId
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
async fetchTypography(typographyId) {
|
|
80
|
-
return await this.makeswiftApiClient.dispatch(
|
|
81
|
-
MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
resolveTypography(typographyId) {
|
|
85
|
-
return this.resolveResource(APIResourceType.Typography, {
|
|
86
|
-
id: typographyId,
|
|
87
|
-
read: (id) => this.readTypography(id),
|
|
88
|
-
fetch: (id) => this.fetchTypography(id)
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
readGlobalElement(globalElementId) {
|
|
92
|
-
return MakeswiftApiClient.getAPIResource(
|
|
93
|
-
this.makeswiftApiClient.getState(),
|
|
94
|
-
APIResourceType.GlobalElement,
|
|
95
|
-
globalElementId
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
async fetchGlobalElement(globalElementId) {
|
|
99
|
-
return await this.makeswiftApiClient.dispatch(
|
|
100
|
-
MakeswiftApiClient.fetchAPIResource(
|
|
101
|
-
APIResourceType.GlobalElement,
|
|
102
|
-
globalElementId,
|
|
103
|
-
this.fetch
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
readLocalizedGlobalElement({
|
|
108
|
-
globalElementId,
|
|
109
|
-
locale
|
|
110
|
-
}) {
|
|
111
|
-
return MakeswiftApiClient.getAPIResource(
|
|
112
|
-
this.makeswiftApiClient.getState(),
|
|
113
|
-
APIResourceType.LocalizedGlobalElement,
|
|
114
|
-
globalElementId,
|
|
115
|
-
locale
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
async fetchLocalizedGlobalElement({
|
|
119
|
-
globalElementId,
|
|
120
|
-
locale
|
|
121
|
-
}) {
|
|
122
|
-
return await this.makeswiftApiClient.dispatch(
|
|
123
|
-
MakeswiftApiClient.fetchAPIResource(
|
|
124
|
-
APIResourceType.LocalizedGlobalElement,
|
|
125
|
-
globalElementId,
|
|
126
|
-
this.fetch,
|
|
127
|
-
locale
|
|
128
|
-
)
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
readPagePathnameSlice({
|
|
132
|
-
pageId,
|
|
133
|
-
locale
|
|
134
|
-
}) {
|
|
135
|
-
return MakeswiftApiClient.getAPIResource(
|
|
136
|
-
this.makeswiftApiClient.getState(),
|
|
137
|
-
APIResourceType.PagePathnameSlice,
|
|
138
|
-
pageId,
|
|
139
|
-
locale
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
async fetchPagePathnameSlice({
|
|
143
|
-
pageId,
|
|
144
|
-
locale
|
|
145
|
-
}) {
|
|
146
|
-
return await this.makeswiftApiClient.dispatch(
|
|
147
|
-
MakeswiftApiClient.fetchAPIResource(
|
|
148
|
-
APIResourceType.PagePathnameSlice,
|
|
149
|
-
pageId,
|
|
150
|
-
this.fetch,
|
|
151
|
-
locale
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
resolvePagePathnameSlice({
|
|
156
|
-
pageId,
|
|
157
|
-
locale
|
|
158
|
-
}) {
|
|
159
|
-
return this.resolveResource(APIResourceType.PagePathnameSlice, {
|
|
160
|
-
id: pageId,
|
|
161
|
-
read: (id) => this.readPagePathnameSlice({ pageId: id, locale }),
|
|
162
|
-
fetch: (id) => this.fetchPagePathnameSlice({ pageId: id, locale })
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
resolveResource(type, {
|
|
166
|
-
id,
|
|
167
|
-
read,
|
|
168
|
-
fetch
|
|
169
|
-
}) {
|
|
170
|
-
const _read = () => id != null ? read(id) : null;
|
|
171
|
-
let lastValue = null;
|
|
172
|
-
return {
|
|
173
|
-
name: `${type}:${id}`,
|
|
174
|
-
readStable: () => lastValue = _read(),
|
|
175
|
-
subscribe: (onUpdate) => this.subscribe(() => {
|
|
176
|
-
if (_read() !== lastValue)
|
|
177
|
-
onUpdate();
|
|
178
|
-
}),
|
|
179
|
-
fetch: async () => id != null ? fetch(id) : null
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
readTable(tableId) {
|
|
183
|
-
return MakeswiftApiClient.getAPIResource(
|
|
184
|
-
this.makeswiftApiClient.getState(),
|
|
185
|
-
APIResourceType.Table,
|
|
186
|
-
tableId
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
async fetchTable(tableId) {
|
|
190
|
-
return await this.makeswiftApiClient.dispatch(
|
|
191
|
-
MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch)
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
async createTableRecord(tableId, columns) {
|
|
195
|
-
await this.graphqlClient.request(CreateTableRecordMutation, { input: { data: { tableId, columns } } });
|
|
196
|
-
}
|
|
197
|
-
readSite(siteId) {
|
|
198
|
-
return MakeswiftApiClient.getAPIResource(
|
|
199
|
-
this.makeswiftApiClient.getState(),
|
|
200
|
-
APIResourceType.Site,
|
|
201
|
-
siteId
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
readPage(pageId) {
|
|
205
|
-
return MakeswiftApiClient.getAPIResource(
|
|
206
|
-
this.makeswiftApiClient.getState(),
|
|
207
|
-
APIResourceType.Page,
|
|
208
|
-
pageId
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
readSnippet(snippetId) {
|
|
212
|
-
return MakeswiftApiClient.getAPIResource(
|
|
213
|
-
this.makeswiftApiClient.getState(),
|
|
214
|
-
APIResourceType.Snippet,
|
|
215
|
-
snippetId
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
export {
|
|
220
|
-
CacheData,
|
|
221
|
-
MakeswiftHostApiClient
|
|
222
|
-
};
|
|
223
|
-
//# sourceMappingURL=react.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/react.ts"],"sourcesContent":["import { type FetchableValue } from '@makeswift/controls'\nimport * as MakeswiftApiClient from '../state/makeswift-api-client'\nimport {\n APIResourceType,\n File,\n GlobalElement,\n LocalizedGlobalElement,\n Page,\n PagePathnameSlice,\n Site,\n Snippet,\n Swatch,\n Table,\n Typography,\n} from './types'\nimport { GraphQLClient } from './graphql/client'\nimport { CreateTableRecordMutation } from './graphql/documents'\nimport {\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables,\n} from './graphql/generated/types'\n\nexport type CacheData = MakeswiftApiClient.SerializedState\n\nexport const CacheData = {\n empty(): CacheData {\n return {\n apiResources: {},\n localizedResourcesMap: {},\n }\n },\n}\n\n/**\n * NOTE(miguel): This \"client\" is used to fetch Makeswift API resources needed for the host. For\n * example, swatches, files, typographies, etc. Ideally it's internal to the runtime and is only\n * used by controls to transform API references to API resources.\n *\n * Moreover, its use should be reserved for the builder only, since for live pages all Makeswift\n * API resources should be embedded in the \"page snapshot\". In the builder, this client serves the\n * purpose of sending requests for API resources and keeping a cache so that changes that happen in\n * the builder, like modifying a swatch, can be sent via `postMessage` to the host and the cache can\n * immediately update the value and re-render.\n *\n * Furthermore, the API resources requested shouldn't be requested directly from the Makeswift API\n * as that would require those resources to not be authenticated since the requests come from the\n * browser when running the host. Instead, the requests should go to the host directly, at the\n * Makeswift API endpoint (i.g., `/api/makeswift/[...makeswift]` dynamic route) where the host's\n * API key can be used, securely, in the server. For this reason, this client should really be a\n * client of the host's API, not Makeswift's, intended to build and continuously maintain a realtime\n * snapshot for use in the builder, not the lives pages.\n */\nexport class MakeswiftHostApiClient {\n graphqlClient: GraphQLClient\n makeswiftApiClient: MakeswiftApiClient.Store\n subscribe: MakeswiftApiClient.Store['subscribe']\n fetch: MakeswiftApiClient.HttpFetch\n\n constructor({\n uri,\n fetch,\n cacheData,\n locale,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n defaultLocale: locale,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n }\n\n readSwatch(swatchId: string): Swatch | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Swatch,\n swatchId,\n )\n }\n\n async fetchSwatch(swatchId: string): Promise<Swatch | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Swatch, swatchId, this.fetch),\n )\n }\n\n resolveSwatch(swatchId: string | undefined): FetchableValue<Swatch | null> {\n return this.resolveResource(APIResourceType.Swatch, {\n id: swatchId,\n read: id => this.readSwatch(id),\n fetch: id => this.fetchSwatch(id),\n })\n }\n\n readFile(fileId: string): File | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.File,\n fileId,\n )\n }\n\n async fetchFile(fileId: string): Promise<File | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.File, fileId, this.fetch),\n )\n }\n\n resolveFile(fileId: string | undefined): FetchableValue<File | null> {\n return this.resolveResource(APIResourceType.File, {\n id: fileId,\n read: id => this.readFile(id),\n fetch: id => this.fetchFile(id),\n })\n }\n\n readTypography(typographyId: string): Typography | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Typography,\n typographyId,\n )\n }\n\n async fetchTypography(typographyId: string): Promise<Typography | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Typography, typographyId, this.fetch),\n )\n }\n\n resolveTypography(typographyId: string | undefined): FetchableValue<Typography | null> {\n return this.resolveResource(APIResourceType.Typography, {\n id: typographyId,\n read: id => this.readTypography(id),\n fetch: id => this.fetchTypography(id),\n })\n }\n\n readGlobalElement(globalElementId: string): GlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.GlobalElement,\n globalElementId,\n )\n }\n\n async fetchGlobalElement(globalElementId: string): Promise<GlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.GlobalElement,\n globalElementId,\n this.fetch,\n ),\n )\n }\n\n readLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): LocalizedGlobalElement | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n locale,\n )\n }\n\n async fetchLocalizedGlobalElement({\n globalElementId,\n locale,\n }: {\n globalElementId: string\n locale: string\n }): Promise<LocalizedGlobalElement | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.LocalizedGlobalElement,\n globalElementId,\n this.fetch,\n locale,\n ),\n )\n }\n\n readPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): PagePathnameSlice | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.PagePathnameSlice,\n pageId,\n locale,\n )\n }\n\n async fetchPagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string\n locale: string | null\n }): Promise<PagePathnameSlice | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(\n APIResourceType.PagePathnameSlice,\n pageId,\n this.fetch,\n locale,\n ),\n )\n }\n\n resolvePagePathnameSlice({\n pageId,\n locale,\n }: {\n pageId: string | undefined\n locale: string | null\n }): FetchableValue<PagePathnameSlice | null> {\n return this.resolveResource(APIResourceType.PagePathnameSlice, {\n id: pageId,\n read: id => this.readPagePathnameSlice({ pageId: id, locale }),\n fetch: id => this.fetchPagePathnameSlice({ pageId: id, locale }),\n })\n }\n\n resolveResource<R>(\n type: APIResourceType,\n {\n id,\n read,\n fetch,\n }: {\n id: string | undefined\n read: (id: string) => R | null\n fetch: (id: string) => Promise<R | null>\n },\n ): FetchableValue<R | null> {\n const _read = () => (id != null ? read(id) : null)\n let lastValue: R | null = null\n return {\n name: `${type}:${id}`,\n readStable: () => (lastValue = _read()),\n subscribe: (onUpdate: () => void) =>\n this.subscribe(() => {\n if (_read() !== lastValue) onUpdate()\n }),\n fetch: async () => (id != null ? fetch(id) : null),\n }\n }\n\n readTable(tableId: string): Table | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Table,\n tableId,\n )\n }\n\n async fetchTable(tableId: string): Promise<Table | null> {\n return await this.makeswiftApiClient.dispatch(\n MakeswiftApiClient.fetchAPIResource(APIResourceType.Table, tableId, this.fetch),\n )\n }\n\n async createTableRecord(tableId: string, columns: any): Promise<void> {\n await this.graphqlClient.request<\n CreateTableRecordMutationResult,\n CreateTableRecordMutationVariables\n >(CreateTableRecordMutation, { input: { data: { tableId, columns } } })\n }\n\n readSite(siteId: string): Site | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Site,\n siteId,\n )\n }\n\n readPage(pageId: string): Page | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Page,\n pageId,\n )\n }\n\n readSnippet(snippetId: string): Snippet | null {\n return MakeswiftApiClient.getAPIResource(\n this.makeswiftApiClient.getState(),\n APIResourceType.Snippet,\n snippetId,\n )\n }\n}\n"],"mappings":"AACA,YAAY,wBAAwB;AACpC;AAAA,EACE;AAAA,OAWK;AACP,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AAQnC,MAAM,YAAY;AAAA,EACvB,QAAmB;AACjB,WAAO;AAAA,MACL,cAAc,CAAC;AAAA,MACf,uBAAuB,CAAC;AAAA,IAC1B;AAAA,EACF;AACF;AAqBO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKG;AACD,SAAK,gBAAgB,IAAI,cAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe;AAAA,MAC1D,iBAAiB;AAAA,MACjB,eAAe;AAAA,IACjB,CAAC;AACD,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,mBAAmB;AAAA,EAC3C;AAAA,EAEA,WAAW,UAAiC;AAC1C,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,YAAY,UAA0C;AAC1D,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,gBAAgB,QAAQ,UAAU,KAAK,KAAK;AAAA,IAClF;AAAA,EACF;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,EAEA,SAAS,QAA6B;AACpC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,UAAU,QAAsC;AACpD,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,gBAAgB,MAAM,QAAQ,KAAK,KAAK;AAAA,IAC9E;AAAA,EACF;AAAA,EAEA,YAAY,QAAyD;AACnE,WAAO,KAAK,gBAAgB,gBAAgB,MAAM;AAAA,MAChD,IAAI;AAAA,MACJ,MAAM,QAAM,KAAK,SAAS,EAAE;AAAA,MAC5B,OAAO,QAAM,KAAK,UAAU,EAAE;AAAA,IAChC,CAAC;AAAA,EACH;AAAA,EAEA,eAAe,cAAyC;AACtD,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,gBAAgB,cAAkD;AACtE,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB,iBAAiB,gBAAgB,YAAY,cAAc,KAAK,KAAK;AAAA,IAC1F;AAAA,EACF;AAAA,EAEA,kBAAkB,cAAqE;AACrF,WAAO,KAAK,gBAAgB,gBAAgB,YAAY;AAAA,MACtD,IAAI;AAAA,MACJ,MAAM,QAAM,KAAK,eAAe,EAAE;AAAA,MAClC,OAAO,QAAM,KAAK,gBAAgB,EAAE;AAAA,IACtC,CAAC;AAAA,EACH;AAAA,EAEA,kBAAkB,iBAA+C;AAC/D,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,mBAAmB,iBAAwD;AAC/E,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB;AAAA,QACjB,gBAAgB;AAAA,QAChB;AAAA,QACA,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,2BAA2B;AAAA,IACzB;AAAA,IACA;AAAA,EACF,GAGkC;AAChC,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,4BAA4B;AAAA,IAChC;AAAA,IACA;AAAA,EACF,GAG2C;AACzC,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB;AAAA,QACjB,gBAAgB;AAAA,QAChB;AAAA,QACA,KAAK;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,sBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,EACF,GAG6B;AAC3B,WAAO,mBAAmB;AAAA,MACxB,KAAK,mBAAmB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,uBAAuB;AAAA,IAC3B;AAAA,IACA;AAAA,EACF,GAGsC;AACpC,WAAO,MAAM,KAAK,mBAAmB;AAAA,MACnC,mBAAmB;AAAA,QACjB,gBAAgB;AAAA,QAChB;AAAA,QACA,KAAK;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,yBAAyB;AAAA,IACvB;AAAA,IACA;AAAA,EACF,GAG6C;AAC3C,WAAO,KAAK,gBAAgB,gBAAgB,mBAAmB;AAAA,MAC7D,IAAI;AAAA,MACJ,MAAM,QAAM,KAAK,sBAAsB,EAAE,QAAQ,IAAI,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,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,38 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
const changeTypeSchema = z.enum(["created", "updated", "deleted"]);
|
|
3
|
-
const componentChangeSchema = z.object({
|
|
4
|
-
id: z.string(),
|
|
5
|
-
locale: z.string().nullable(),
|
|
6
|
-
changeType: changeTypeSchema
|
|
7
|
-
});
|
|
8
|
-
const pageChangeSchema = z.object({
|
|
9
|
-
pageId: z.string().uuid(),
|
|
10
|
-
locale: z.string().nullable(),
|
|
11
|
-
changeType: changeTypeSchema,
|
|
12
|
-
pathname: z.string(),
|
|
13
|
-
previousPathname: z.string().optional()
|
|
14
|
-
});
|
|
15
|
-
const globalElementChangeSchema = z.object({
|
|
16
|
-
id: z.string().uuid(),
|
|
17
|
-
locale: z.string().nullable(),
|
|
18
|
-
changeType: changeTypeSchema
|
|
19
|
-
});
|
|
20
|
-
const swatchChangeSchema = z.object({
|
|
21
|
-
id: z.string().uuid(),
|
|
22
|
-
changeType: changeTypeSchema
|
|
23
|
-
});
|
|
24
|
-
const typographyChangeSchema = z.object({
|
|
25
|
-
id: z.string().uuid(),
|
|
26
|
-
changeType: changeTypeSchema
|
|
27
|
-
});
|
|
28
|
-
const diffProjectionSchema = z.object({
|
|
29
|
-
components: z.array(componentChangeSchema),
|
|
30
|
-
pages: z.array(pageChangeSchema),
|
|
31
|
-
globalElements: z.array(globalElementChangeSchema),
|
|
32
|
-
swatches: z.array(swatchChangeSchema),
|
|
33
|
-
typographies: z.array(typographyChangeSchema)
|
|
34
|
-
}).passthrough();
|
|
35
|
-
export {
|
|
36
|
-
diffProjectionSchema
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=diff-projection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/diff-projection.ts"],"sourcesContent":["import { z } from 'zod'\n\nconst changeTypeSchema = z.enum(['created', 'updated', 'deleted'])\n\n// `locale` is null for the default locale. We'd prefer explicit locale strings\n// (e.g. \"en-US\"), but both server and runtime treat the default locale as null\n// today — changing that requires a broader localization rework.\nconst componentChangeSchema = z.object({\n id: z.string(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst pageChangeSchema = z.object({\n pageId: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n pathname: z.string(),\n previousPathname: z.string().optional(),\n})\n\nconst globalElementChangeSchema = z.object({\n id: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst swatchChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nconst typographyChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nexport const diffProjectionSchema = z\n .object({\n components: z.array(componentChangeSchema),\n pages: z.array(pageChangeSchema),\n globalElements: z.array(globalElementChangeSchema),\n swatches: z.array(swatchChangeSchema),\n typographies: z.array(typographyChangeSchema),\n })\n // passthrough() preserves unknown resource types the server may add in the\n // future (e.g. `fonts`), so onPublish consumers can access them without a\n // runtime upgrade.\n .passthrough()\n"],"mappings":"AAAA,SAAS,SAAS;AAElB,MAAM,mBAAmB,EAAE,KAAK,CAAC,WAAW,WAAW,SAAS,CAAC;AAKjE,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,IAAI,EAAE,OAAO;AAAA,EACb,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,QAAQ,EAAE,OAAO,EAAE,KAAK;AAAA,EACxB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AAAA,EACZ,UAAU,EAAE,OAAO;AAAA,EACnB,kBAAkB,EAAE,OAAO,EAAE,SAAS;AACxC,CAAC;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAED,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAEM,MAAM,uBAAuB,EACjC,OAAO;AAAA,EACN,YAAY,EAAE,MAAM,qBAAqB;AAAA,EACzC,OAAO,EAAE,MAAM,gBAAgB;AAAA,EAC/B,gBAAgB,EAAE,MAAM,yBAAyB;AAAA,EACjD,UAAU,EAAE,MAAM,kBAAkB;AAAA,EACpC,cAAc,EAAE,MAAM,sBAAsB;AAC9C,CAAC,EAIA,YAAY;","names":[]}
|
package/dist/esm/box-model.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/box-model.ts"],"sourcesContent":["export { createBox, getBox, parse } from './state/modules/box-models'\nexport type { BoxModelHandle, BoxModel } from './state/modules/box-models'\n"],"mappings":"AAAA,SAAS,WAAW,QAAQ,aAAa;","names":[]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deserializeObject
|
|
3
|
-
} from "@makeswift/controls";
|
|
4
|
-
import {
|
|
5
|
-
serializeLegacyControl,
|
|
6
|
-
deserializeLegacyControl
|
|
7
|
-
} from "../prop-controllers/serialization";
|
|
8
|
-
import { isLegacyDescriptor } from "../prop-controllers/descriptors";
|
|
9
|
-
import { deserializeControl as deserializeUnifiedControl } from "../controls/serialization/base";
|
|
10
|
-
import {
|
|
11
|
-
ClientMessagePortSerializationVisitor,
|
|
12
|
-
functionDeserializationPlugin
|
|
13
|
-
} from "../controls/serialization/message-port";
|
|
14
|
-
import {
|
|
15
|
-
deserializeControlRecords
|
|
16
|
-
} from "../controls/serialization";
|
|
17
|
-
export * from "../prop-controllers/serialization";
|
|
18
|
-
function serializeControl(control) {
|
|
19
|
-
if (isLegacyDescriptor(control)) {
|
|
20
|
-
return serializeLegacyControl(control);
|
|
21
|
-
}
|
|
22
|
-
const messagePortVisitor = new ClientMessagePortSerializationVisitor();
|
|
23
|
-
const serializedControl = control.accept(messagePortVisitor);
|
|
24
|
-
return [serializedControl, messagePortVisitor.getTransferables()];
|
|
25
|
-
}
|
|
26
|
-
function isSerializedLegacyControl(control) {
|
|
27
|
-
return "options" in control;
|
|
28
|
-
}
|
|
29
|
-
function deserializeControl(serializedControl, options) {
|
|
30
|
-
if (isSerializedLegacyControl(serializedControl)) {
|
|
31
|
-
const record = options?.plugins ? deserializeObject(serializedControl, options?.plugins) : serializedControl;
|
|
32
|
-
return deserializeLegacyControl(record);
|
|
33
|
-
}
|
|
34
|
-
const plugins = [functionDeserializationPlugin, ...options?.plugins ?? []];
|
|
35
|
-
return deserializeUnifiedControl(serializedControl, { plugins });
|
|
36
|
-
}
|
|
37
|
-
function serializeControls(controls) {
|
|
38
|
-
return Object.entries(controls).reduce(
|
|
39
|
-
([accControls, accTransferables], [key, control]) => {
|
|
40
|
-
const [serializedControl, transferables] = serializeControl(control);
|
|
41
|
-
return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]];
|
|
42
|
-
},
|
|
43
|
-
[{}, []]
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
function deserializeControls(serializedControls, { onError, plugins } = {}) {
|
|
47
|
-
return deserializeControlRecords(
|
|
48
|
-
serializedControls,
|
|
49
|
-
(serializedControl, options) => deserializeControl(serializedControl, options),
|
|
50
|
-
{ onError, plugins }
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
deserializeControl,
|
|
55
|
-
deserializeControls,
|
|
56
|
-
serializeControl,
|
|
57
|
-
serializeControls
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=serialization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/builder/serialization.ts"],"sourcesContent":["import {\n type Data,\n ControlDefinition as UnifiedControlDefinition,\n type SerializedRecord,\n DeserializationPlugin,\n deserializeObject,\n} from '@makeswift/controls'\n\nimport {\n type SerializedLegacyControl,\n type DeserializedLegacyControl,\n serializeLegacyControl,\n deserializeLegacyControl,\n} from '../prop-controllers/serialization'\n\nimport { type Descriptor, isLegacyDescriptor } from '../prop-controllers/descriptors'\n\nimport { deserializeControl as deserializeUnifiedControl } from '../controls/serialization/base'\nimport {\n type DeserializedFunction,\n type SerializedFunction,\n ClientMessagePortSerializationVisitor,\n functionDeserializationPlugin,\n} from '../controls/serialization/message-port'\n\nimport {\n type DeserializeControlRecordsOptions,\n deserializeControlRecords,\n} from '../controls/serialization'\n\nexport * from '../prop-controllers/serialization'\n\nexport type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord\n\nexport type DeserializedControl<T extends Data = Data> =\n | DeserializedLegacyControl<T>\n | UnifiedControlDefinition\n\nexport function serializeControl<T extends Data>(\n control: Descriptor<T>,\n): [SerializedControl<T>, Transferable[]] {\n if (isLegacyDescriptor(control)) {\n return serializeLegacyControl(control)\n }\n\n const messagePortVisitor = new ClientMessagePortSerializationVisitor()\n const serializedControl = control.accept(messagePortVisitor)\n return [serializedControl, messagePortVisitor.getTransferables()]\n}\n\nfunction isSerializedLegacyControl<T extends Data>(\n control: SerializedControl<T>,\n): control is SerializedLegacyControl<T> {\n return 'options' in control\n}\n\nexport type DeserializeControlOptions = {\n plugins?: DeserializationPlugin<any>[]\n}\n\nexport function deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n options?: DeserializeControlOptions,\n): DeserializedControl<T> {\n if (isSerializedLegacyControl(serializedControl)) {\n // Parity with controls deserialization logic below: \"preprocess\" serialized\n // legacy controls if the caller provided custom deserialization plugins\n const record = options?.plugins\n ? deserializeObject(serializedControl, options?.plugins)\n : serializedControl\n return deserializeLegacyControl(record as SerializedLegacyControl<T>)\n }\n\n const plugins = [functionDeserializationPlugin, ...(options?.plugins ?? [])]\n return deserializeUnifiedControl(serializedControl, { plugins })\n}\n\nexport function serializeControls(\n controls: Record<string, Descriptor>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, unknown>,\n { onError, plugins }: DeserializeControlRecordsOptions = {},\n): Record<string, DeserializedControl> {\n return deserializeControlRecords<DeserializedControl>(\n serializedControls,\n (serializedControl, options) => deserializeControl(serializedControl, options),\n { onError, plugins },\n )\n}\n\ntype AnyFunction = (...args: any[]) => any\n\nexport type Serialize<T> = T extends AnyFunction\n ? SerializedFunction<T>\n : T extends Record<string, unknown>\n ? { [K in keyof T]: Serialize<T[K]> }\n : T\n\nexport type Deserialize<T> =\n T extends SerializedFunction<infer U>\n ? DeserializedFunction<U>\n : T extends Record<string, unknown>\n ? { [K in keyof T]: Deserialize<T[K]> }\n : T\n"],"mappings":"AAAA;AAAA,EAKE;AAAA,OACK;AAEP;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAEP,SAA0B,0BAA0B;AAEpD,SAAS,sBAAsB,iCAAiC;AAChE;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,OACK;AAEP,cAAc;AAQP,SAAS,iBACd,SACwC;AACxC,MAAI,mBAAmB,OAAO,GAAG;AAC/B,WAAO,uBAAuB,OAAO;AAAA,EACvC;AAEA,QAAM,qBAAqB,IAAI,sCAAsC;AACrE,QAAM,oBAAoB,QAAQ,OAAO,kBAAkB;AAC3D,SAAO,CAAC,mBAAmB,mBAAmB,iBAAiB,CAAC;AAClE;AAEA,SAAS,0BACP,SACuC;AACvC,SAAO,aAAa;AACtB;AAMO,SAAS,mBACd,mBACA,SACwB;AACxB,MAAI,0BAA0B,iBAAiB,GAAG;AAGhD,UAAM,SAAS,SAAS,UACpB,kBAAkB,mBAAmB,SAAS,OAAO,IACrD;AACJ,WAAO,yBAAyB,MAAoC;AAAA,EACtE;AAEA,QAAM,UAAU,CAAC,+BAA+B,GAAI,SAAS,WAAW,CAAC,CAAE;AAC3E,SAAO,0BAA0B,mBAAmB,EAAE,QAAQ,CAAC;AACjE;AAEO,SAAS,kBACd,UACqD;AACrD,SAAO,OAAO,QAAQ,QAAQ,EAAE;AAAA,IAC9B,CAAC,CAAC,aAAa,gBAAgB,GAAG,CAAC,KAAK,OAAO,MAAM;AACnD,YAAM,CAAC,mBAAmB,aAAa,IAAI,iBAAiB,OAAO;AAEnE,aAAO,CAAC,EAAE,GAAG,aAAa,CAAC,GAAG,GAAG,kBAAkB,GAAG,CAAC,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAAA,IAC/F;AAAA,IACA,CAAC,CAAC,GAAG,CAAC,CAAC;AAAA,EACT;AACF;AAEO,SAAS,oBACd,oBACA,EAAE,SAAS,QAAQ,IAAsC,CAAC,GACrB;AACrC,SAAO;AAAA,IACL;AAAA,IACA,CAAC,mBAAmB,YAAY,mBAAmB,mBAAmB,OAAO;AAAA,IAC7E,EAAE,SAAS,QAAQ;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export * from "./Box";
|
|
2
|
-
import { default as default2 } from "./Box";
|
|
3
|
-
import { default as default3 } from "./Button";
|
|
4
|
-
import { default as default4 } from "./Carousel";
|
|
5
|
-
import { default as default5 } from "./Countdown";
|
|
6
|
-
import { default as default6 } from "./Divider";
|
|
7
|
-
import { default as default7 } from "./Embed";
|
|
8
|
-
import { default as default8 } from "./Form";
|
|
9
|
-
import { default as default9 } from "./Image";
|
|
10
|
-
import { default as default10 } from "./Navigation";
|
|
11
|
-
import { default as default11 } from "./Root";
|
|
12
|
-
import { default as default12 } from "./Slot";
|
|
13
|
-
import { default as default13 } from "./SocialLinks";
|
|
14
|
-
import { default as default14 } from "./Text";
|
|
15
|
-
import { default as default15 } from "./Video";
|
|
16
|
-
import { MakeswiftComponentType } from "./constants";
|
|
17
|
-
export {
|
|
18
|
-
default2 as Box,
|
|
19
|
-
default3 as Button,
|
|
20
|
-
default4 as Carousel,
|
|
21
|
-
default5 as Countdown,
|
|
22
|
-
default6 as Divider,
|
|
23
|
-
default7 as Embed,
|
|
24
|
-
default8 as Form,
|
|
25
|
-
default9 as Image,
|
|
26
|
-
MakeswiftComponentType,
|
|
27
|
-
default10 as Navigation,
|
|
28
|
-
default11 as Root,
|
|
29
|
-
default12 as Slot,
|
|
30
|
-
default13 as SocialLinks,
|
|
31
|
-
default14 as Text,
|
|
32
|
-
default15 as Video
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/builtin/index.ts"],"sourcesContent":["export * from './Box'\nexport { default as Box } from './Box'\nexport { default as Button } from './Button'\nexport { default as Carousel } from './Carousel'\nexport { default as Countdown } from './Countdown'\nexport { default as Divider } from './Divider'\nexport { default as Embed } from './Embed'\nexport { default as Form } from './Form'\nexport { default as Image } from './Image'\nexport { default as Navigation } from './Navigation'\nexport { default as Root } from './Root'\nexport { default as Slot } from './Slot'\nexport { default as SocialLinks } from './SocialLinks'\nexport { default as Text } from './Text'\nexport { default as Video } from './Video'\n\nexport { MakeswiftComponentType } from './constants'\n"],"mappings":"AAAA,cAAc;AACd,SAAoB,WAAXA,gBAAsB;AAC/B,SAAoB,WAAXA,gBAAyB;AAClC,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAA4B;AACrC,SAAoB,WAAXA,gBAA0B;AACnC,SAAoB,WAAXA,gBAAwB;AACjC,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAAwB;AACjC,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAAuB;AAChC,SAAoB,WAAXA,iBAAuB;AAChC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAuB;AAChC,SAAoB,WAAXA,iBAAwB;AAEjC,SAAS,8BAA8B;","names":["default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from './builtin'\nexport * from './hooks'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|