@makeswift/runtime 0.26.4-canary.1 → 0.27.0-canary.2
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/client.js +1 -10
- package/dist/cjs/api/client.js.map +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/api-handler/index.js +1 -2
- package/dist/cjs/api-handler/index.js.map +1 -1
- package/dist/cjs/client/index.js +8 -13
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/next/api-handler/index.js +2 -2
- package/dist/cjs/next/api-handler/index.js.map +1 -1
- package/dist/cjs/next/components/framework-provider/index.js +1 -3
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/style-control/fixtures.js.map +1 -1
- package/dist/cjs/next/index.js +3 -0
- package/dist/cjs/next/index.js.map +1 -1
- package/dist/cjs/next/runtime.js +38 -0
- package/dist/cjs/next/runtime.js.map +1 -0
- package/dist/cjs/next/tests/test-utils.js +3 -6
- package/dist/cjs/next/tests/test-utils.js.map +1 -1
- package/dist/cjs/react/index.js +0 -3
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js +13 -33
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js +1 -2
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-async-effect.js +55 -0
- package/dist/cjs/runtimes/react/hooks/use-async-effect.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-store.js +2 -9
- package/dist/cjs/runtimes/react/hooks/use-store.js.map +1 -1
- package/dist/cjs/runtimes/react/host-api-client.js +2 -25
- package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
- package/dist/cjs/runtimes/react/index.js +0 -5
- package/dist/cjs/runtimes/react/index.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js +0 -3
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime.js +2 -2
- package/dist/cjs/runtimes/react/react-runtime.js.map +1 -1
- package/dist/cjs/runtimes/react/runtime-core.js +42 -3
- package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/testing/react-runtime.js +2 -1
- package/dist/cjs/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/cjs/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
- package/dist/cjs/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/index.js +40 -0
- package/dist/cjs/state/middleware/read-write/index.js.map +1 -0
- package/dist/cjs/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
- package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/cjs/state/read-only-state.js +2 -0
- package/dist/cjs/state/read-only-state.js.map +1 -1
- package/dist/cjs/state/read-write-state.js +9 -2
- package/dist/cjs/state/read-write-state.js.map +1 -1
- package/dist/cjs/state/store.js +184 -0
- package/dist/cjs/state/store.js.map +1 -0
- package/dist/cjs/state/unified-state.js +17 -0
- package/dist/cjs/state/unified-state.js.map +1 -0
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/cjs/{state/mixins/setup-teardown.js → utils/deferred.js} +15 -11
- package/dist/cjs/utils/deferred.js.map +1 -0
- package/dist/esm/api/client.js +1 -10
- package/dist/esm/api/client.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/api-handler/index.js +1 -2
- package/dist/esm/api-handler/index.js.map +1 -1
- package/dist/esm/client/index.js +8 -13
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/next/api-handler/index.js +2 -2
- package/dist/esm/next/api-handler/index.js.map +1 -1
- package/dist/esm/next/components/framework-provider/index.js +1 -3
- package/dist/esm/next/components/framework-provider/index.js.map +1 -1
- package/dist/esm/next/components/tests/controls/style-control/fixtures.js.map +1 -1
- package/dist/esm/next/index.js +2 -0
- package/dist/esm/next/index.js.map +1 -1
- package/dist/esm/next/runtime.js +14 -0
- package/dist/esm/next/runtime.js.map +1 -0
- package/dist/esm/next/tests/test-utils.js +3 -6
- package/dist/esm/next/tests/test-utils.js.map +1 -1
- package/dist/esm/react/index.js +0 -2
- package/dist/esm/react/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/RuntimeProvider.js +14 -24
- package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js +1 -2
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-async-effect.js +31 -0
- package/dist/esm/runtimes/react/hooks/use-async-effect.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-store.js +2 -8
- package/dist/esm/runtimes/react/hooks/use-store.js.map +1 -1
- package/dist/esm/runtimes/react/host-api-client.js +2 -24
- package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
- package/dist/esm/runtimes/react/index.js +1 -4
- package/dist/esm/runtimes/react/index.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js +0 -3
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime.js +2 -2
- package/dist/esm/runtimes/react/react-runtime.js.map +1 -1
- package/dist/esm/runtimes/react/runtime-core.js +45 -2
- package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/testing/react-runtime.js +2 -1
- package/dist/esm/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/esm/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
- package/dist/esm/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/esm/state/middleware/read-write/index.js +16 -0
- package/dist/esm/state/middleware/read-write/index.js.map +1 -0
- package/dist/esm/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
- package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/esm/state/read-only-state.js +2 -0
- package/dist/esm/state/read-only-state.js.map +1 -1
- package/dist/esm/state/read-write-state.js +7 -1
- package/dist/esm/state/read-write-state.js.map +1 -1
- package/dist/esm/state/store.js +153 -0
- package/dist/esm/state/store.js.map +1 -0
- package/dist/esm/state/unified-state.js +1 -0
- package/dist/esm/state/unified-state.js.map +1 -0
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/utils/deferred.js +15 -0
- package/dist/esm/utils/deferred.js.map +1 -0
- package/dist/types/api/client.d.ts +1 -4
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api-handler/handlers/webhook/types.d.ts +4 -4
- package/dist/types/api-handler/index.d.ts +1 -3
- package/dist/types/api-handler/index.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +10 -11
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/next/api-handler/index.d.ts +1 -1
- package/dist/types/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts +1 -1
- package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts.map +1 -1
- package/dist/types/next/index.d.ts +1 -0
- package/dist/types/next/index.d.ts.map +1 -1
- package/dist/types/next/runtime.d.ts +10 -0
- package/dist/types/next/runtime.d.ts.map +1 -0
- package/dist/types/next/tests/test-utils.d.ts.map +1 -1
- package/dist/types/react/index.d.ts +0 -1
- package/dist/types/react/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +2 -4
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts +0 -2
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts +2 -0
- package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-async-effect.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/use-async-effect.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-store.d.ts +1 -26
- package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
- package/dist/types/runtimes/react/host-api-client.d.ts +0 -5
- package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
- package/dist/types/runtimes/react/index.d.ts +1 -2
- package/dist/types/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts +0 -4
- package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/react-runtime.d.ts +1 -4
- package/dist/types/runtimes/react/react-runtime.d.ts.map +1 -1
- package/dist/types/runtimes/react/runtime-core.d.ts +20 -3
- package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +1 -1
- package/dist/types/state/__tests__/store.read-write-state.test.d.ts +2 -0
- package/dist/types/state/__tests__/store.read-write-state.test.d.ts.map +1 -0
- package/dist/types/state/__tests__/test-store.d.ts +29 -0
- package/dist/types/state/__tests__/test-store.d.ts.map +1 -0
- package/dist/types/state/middleware/makeswift-api-client-sync.d.ts +5 -0
- package/dist/types/state/middleware/makeswift-api-client-sync.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/index.d.ts +5 -0
- package/dist/types/state/middleware/read-write/index.d.ts.map +1 -0
- package/dist/types/state/middleware/{prop-controller-handles.d.ts → read-write/prop-controller-handles.d.ts} +1 -1
- package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -0
- package/dist/types/state/read-only-state.d.ts +3 -0
- package/dist/types/state/read-only-state.d.ts.map +1 -1
- package/dist/types/state/read-write-state.d.ts +5 -1
- package/dist/types/state/read-write-state.d.ts.map +1 -1
- package/dist/types/state/{react-page.d.ts → store.d.ts} +25 -6
- package/dist/types/state/store.d.ts.map +1 -0
- package/dist/types/state/unified-state.d.ts +9 -0
- package/dist/types/state/unified-state.d.ts.map +1 -0
- package/dist/types/unstable-framework-support/index.d.ts +1 -0
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/dist/types/utils/deferred.d.ts +7 -0
- package/dist/types/utils/deferred.d.ts.map +1 -0
- package/package.json +2 -2
- 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/PreviewProvider.js +0 -63
- package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +0 -1
- package/dist/cjs/state/middleware/prop-controller-handles.js.map +0 -1
- package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
- package/dist/cjs/state/mixins/setup-teardown.js.map +0 -1
- package/dist/cjs/state/react-builder-preview.js +0 -96
- package/dist/cjs/state/react-builder-preview.js.map +0 -1
- package/dist/cjs/state/react-page.js +0 -69
- package/dist/cjs/state/react-page.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/PreviewProvider.js +0 -33
- package/dist/esm/runtimes/react/components/PreviewProvider.js.map +0 -1
- package/dist/esm/state/middleware/prop-controller-handles.js.map +0 -1
- package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.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/react-builder-preview.js +0 -62
- package/dist/esm/state/react-builder-preview.js.map +0 -1
- package/dist/esm/state/react-page.js +0 -35
- package/dist/esm/state/react-page.js.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/PreviewProvider.d.ts +0 -5
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +0 -1
- package/dist/types/state/middleware/prop-controller-handles.d.ts.map +0 -1
- package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts +0 -5
- package/dist/types/state/middleware/read-write/makeswift-api-client-sync.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/react-builder-preview.d.ts +0 -41
- package/dist/types/state/react-builder-preview.d.ts.map +0 -1
- package/dist/types/state/react-page.d.ts.map +0 -1
|
@@ -31,14 +31,14 @@ __export(prop_controller_handles_exports, {
|
|
|
31
31
|
propControllerHandlesMiddleware: () => propControllerHandlesMiddleware
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(prop_controller_handles_exports);
|
|
34
|
-
var PropControllerHandles = __toESM(require("
|
|
35
|
-
var Builder = __toESM(require("
|
|
36
|
-
var import_read_only_actions = require("
|
|
37
|
-
var ReadOnly = __toESM(require("
|
|
38
|
-
var import_toolkit2 = require("
|
|
39
|
-
var import_instances = require("
|
|
40
|
-
var import_host_api = require("
|
|
41
|
-
var ReadOnlyState = __toESM(require("
|
|
34
|
+
var PropControllerHandles = __toESM(require("../../modules/prop-controller-handles"));
|
|
35
|
+
var Builder = __toESM(require("../../builder-api/actions"));
|
|
36
|
+
var import_read_only_actions = require("../../actions/internal/read-only-actions");
|
|
37
|
+
var ReadOnly = __toESM(require("../../actions/internal/read-only-actions"));
|
|
38
|
+
var import_toolkit2 = require("../../toolkit");
|
|
39
|
+
var import_instances = require("../../../prop-controllers/instances");
|
|
40
|
+
var import_host_api = require("../../host-api");
|
|
41
|
+
var ReadOnlyState = __toESM(require("../../read-only-state"));
|
|
42
42
|
function createAndRegisterPropControllers(documentKey, elementKey) {
|
|
43
43
|
return (dispatch, getState) => {
|
|
44
44
|
const descriptors = ReadOnlyState.getElementPropControllerDescriptors(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware, type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport * as PropControllerHandles from '../../modules/prop-controller-handles'\n\nimport { type Action } from '../../actions'\n\nimport * as Builder from '../../builder-api/actions'\n\nimport { ReadOnlyActionTypes } from '../../actions/internal/read-only-actions'\nimport * as ReadOnly from '../../actions/internal/read-only-actions'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { createPropController } from '../../../prop-controllers/instances'\nimport { HostActionTypes } from '../../host-api'\n\nimport * as ReadOnlyState from '../../read-only-state'\nimport { type State, type Dispatch } from '../../read-write-state'\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, ControlInstance> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReadOnlyState.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce(\n (acc, [propName, descriptor]) => {\n const propController = createPropController(descriptor, message =>\n dispatch(\n Builder.messageBuilderPropController(documentKey, elementKey, propName, message),\n ),\n ) as ControlInstance\n\n return { ...acc, [propName]: propController }\n },\n {} as Record<string, ControlInstance>,\n )\n\n dispatch(ReadOnly.registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nexport function propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReadOnlyState.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReadOnlyState.isElementReference(element) &&\n PropControllerHandles.isPropControllersHandle(componentHandle)\n ) {\n dispatch(\n ReadOnly.registerPropControllersHandle(documentKey, elementKey, componentHandle),\n )\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = ReadOnlyState.getPropControllersHandle(getState(), {\n documentKey,\n elementKey,\n })\n\n handle?.setPropControllers(null)\n\n dispatch(ReadOnly.unregisterPropControllers(documentKey, elementKey))\n\n break\n }\n\n case HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const { documentKey, elementKey, propName, message } = action.payload\n const propController = ReadOnlyState.getPropController(getState(), {\n documentKey,\n elementKey,\n propName,\n })\n\n if (propController) propController.recv(message)\n }\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,4BAAuC;AAIvC,cAAyB;AAEzB,+BAAoC;AACpC,eAA0B;AAE1B,IAAAA,kBAAiC;AAEjC,uBAAqC;AACrC,sBAAgC;AAEhC,oBAA+B;AAG/B,SAAS,iCACP,aACA,YAC6E;AAC7E,SAAO,CAAC,UAAU,aAAa;AAC7B,UAAM,cAAc,cAAc;AAAA,MAChC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAEA,QAAI,eAAe;AAAM,aAAO;AAEhC,UAAM,kBAAkB,OAAO,QAAQ,WAAW,EAAE;AAAA,MAClD,CAAC,KAAK,CAAC,UAAU,UAAU,MAAM;AAC/B,cAAM,qBAAiB;AAAA,UAAqB;AAAA,UAAY,aACtD;AAAA,YACE,QAAQ,6BAA6B,aAAa,YAAY,UAAU,OAAO;AAAA,UACjF;AAAA,QACF;AAEA,eAAO,EAAE,GAAG,KAAK,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;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
|
|
@@ -55,6 +55,7 @@ __export(read_only_state_exports, {
|
|
|
55
55
|
});
|
|
56
56
|
module.exports = __toCommonJS(read_only_state_exports);
|
|
57
57
|
var import_reselect = require("reselect");
|
|
58
|
+
var SiteVersion = __toESM(require("./modules/site-version"));
|
|
58
59
|
var Documents = __toESM(require("./modules/read-only-documents"));
|
|
59
60
|
var ElementTrees = __toESM(require("./modules/element-trees"));
|
|
60
61
|
var ReactComponents = __toESM(require("./modules/react-components"));
|
|
@@ -68,6 +69,7 @@ var Breakpoints = __toESM(require("./modules/breakpoints"));
|
|
|
68
69
|
var import_read_only_documents = require("./modules/read-only-documents");
|
|
69
70
|
const reducers = {
|
|
70
71
|
isReadOnly: IsReadOnly.reducer,
|
|
72
|
+
siteVersion: SiteVersion.reducer,
|
|
71
73
|
documents: Documents.reducer,
|
|
72
74
|
elementTrees: ElementTrees.reducer,
|
|
73
75
|
reactComponents: ReactComponents.reducer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n isReadOnly: IsReadOnly.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n isReadOnly: IsReadOnly.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllers: PropControllers.State\n propControllerHandles: PropControllerHandles.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nexport function getPropControllers(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropControllersHandle(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropController(\n state: State,\n {\n documentKey,\n elementKey,\n propName,\n }: { documentKey: string; elementKey: string; propName: string },\n) {\n return PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n propName,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nexport function getBreakpoints(state: State): Breakpoints.State {\n return state.breakpoints\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAA+B;AAE/B,gBAA2B;AAC3B,mBAA8B;AAC9B,sBAAiC;AACjC,qBAAgC;AAChC,sBAAiC;AACjC,4BAAuC;AACvC,kBAA6B;AAC7B,iBAA4B;AAC5B,sBAAiC;AACjC,kBAA6B;AAa7B,iCAKO;AAKA,MAAM,WAAW;AAAA,EACtB,YAAY,WAAW;AAAA,EACvB,WAAW,UAAU;AAAA,EACrB,cAAc,aAAa;AAAA,EAC3B,iBAAiB,gBAAgB;AAAA,EACjC,gBAAgB,eAAe;AAAA,EAC/B,iBAAiB,gBAAgB;AAAA,EACjC,uBAAuB,sBAAsB;AAAA,EAC7C,aAAa,YAAY;AAAA,EACzB,iBAAiB,gBAAgB;AAAA,EACjC,aAAa,YAAY;AAC3B;
|
|
1
|
+
{"version":3,"sources":["../../../src/state/read-only-state.ts"],"sourcesContent":["import { type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport { createSelector } from 'reselect'\n\nimport * as SiteVersion from './modules/site-version'\nimport * as Documents from './modules/read-only-documents'\nimport * as ElementTrees from './modules/element-trees'\nimport * as ReactComponents from './modules/react-components'\nimport * as ComponentsMeta from './modules/components-meta'\nimport * as PropControllers from './modules/prop-controllers'\nimport * as PropControllerHandles from './modules/prop-controller-handles'\nimport * as IsInBuilder from './modules/is-in-builder'\nimport * as IsReadOnly from './modules/is-read-only'\nimport * as BuilderEditMode from './modules/builder-edit-mode'\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { type Action } from './actions'\n\nexport type {\n Data,\n Document,\n DocumentReference,\n Element,\n ElementData,\n ElementReference,\n} from './modules/read-only-documents'\n\nexport {\n createBaseDocument,\n createDocumentReference,\n getRootElement,\n isElementReference,\n} from './modules/read-only-documents'\n\nexport type { ComponentType } from './modules/react-components'\nexport type { ComponentMeta } from './modules/components-meta'\n\nexport const reducers = {\n isReadOnly: IsReadOnly.reducer,\n siteVersion: SiteVersion.reducer,\n documents: Documents.reducer,\n elementTrees: ElementTrees.reducer,\n reactComponents: ReactComponents.reducer,\n componentsMeta: ComponentsMeta.reducer,\n propControllers: PropControllers.reducer,\n propControllerHandles: PropControllerHandles.reducer,\n isInBuilder: IsInBuilder.reducer,\n builderEditMode: BuilderEditMode.reducer,\n breakpoints: Breakpoints.reducer,\n}\n\nexport type State = {\n isReadOnly: IsReadOnly.State\n siteVersion: SiteVersion.State\n documents: Documents.State\n elementTrees: ElementTrees.State\n reactComponents: ReactComponents.State\n componentsMeta: ComponentsMeta.State\n propControllers: PropControllers.State\n propControllerHandles: PropControllerHandles.State\n isInBuilder: IsInBuilder.State\n builderEditMode: BuilderEditMode.State\n breakpoints: Breakpoints.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getElementTreesSlice(state: State): ElementTrees.State {\n return state.elementTrees\n}\n\nexport function getElements(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elements'] {\n return ElementTrees.getElements(getElementTreesSlice(state), documentKey)\n}\n\nexport function getElementIds(\n state: State,\n documentKey: string,\n): ElementTrees.ElementTree['elementIds'] {\n return ElementTrees.getElementIds(getElementTreesSlice(state), documentKey)\n}\n\nfunction getReactComponentsStateSlice(state: State): ReactComponents.State {\n return state.reactComponents\n}\n\nexport function getReactComponent(\n state: State,\n type: string,\n): ReactComponents.ComponentType | null {\n return ReactComponents.getReactComponent(getReactComponentsStateSlice(state), type)\n}\n\nfunction getComponentsMetaStateSlice(state: State): ComponentsMeta.State {\n return state.componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentsMeta.ComponentMeta> {\n return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state))\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentsMeta.ComponentMeta | null {\n return ComponentsMeta.getComponentMeta(getComponentsMetaStateSlice(state), type)\n}\n\nfunction getPropControllersStateSlice(state: State): PropControllers.State {\n return state.propControllers\n}\n\nexport function getPropControllerDescriptors(state: State): PropControllers.State {\n return PropControllers.getPropControllerDescriptors(getPropControllersStateSlice(state))\n}\n\nexport function getComponentPropControllerDescriptors(\n state: State,\n componentType: string,\n): PropControllers.DescriptorsByProp | null {\n return PropControllers.getComponentPropControllerDescriptors(\n getPropControllersStateSlice(state),\n componentType,\n )\n}\n\nfunction getPropControllerHandlesStateSlice(state: State): PropControllerHandles.State {\n return state.propControllerHandles\n}\n\nexport function getPropControllers(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllers(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropControllersHandle(\n state: State,\n { documentKey, elementKey }: { documentKey: string; elementKey: string },\n) {\n return PropControllerHandles.getPropControllersHandle(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n )\n}\n\nexport function getPropController(\n state: State,\n {\n documentKey,\n elementKey,\n propName,\n }: { documentKey: string; elementKey: string; propName: string },\n) {\n return PropControllerHandles.getPropController(\n getPropControllerHandlesStateSlice(state),\n documentKey,\n elementKey,\n propName,\n )\n}\n\n/**\n * Returns all document keys sorted by depth, i.e., parent documents come before child documents.\n */\nexport const getDocumentKeysSortedByDepth: (state: State) => string[] = createSelector(\n [getDocumentsStateSlice, getElementTreesSlice],\n (documents, elementTrees) => {\n return [...documents.keys()].sort((a, b) => (elementTrees.get(a)?.elements.has(b) ? -1 : 1))\n },\n)\n\nexport function getElement(\n state: State,\n documentKey: string,\n elementKey: string,\n): Documents.Element | null {\n return ElementTrees.getElement(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementId(state: State, documentKey: string, elementKey: string): string | null {\n return ElementTrees.getElementId(getElementTreesSlice(state), documentKey, elementKey)\n}\n\nexport function getElementPropControllerDescriptors(\n state: State,\n documentKey: string,\n elementKey: string,\n): Record<string, PropControllers.PropControllerDescriptor> | null {\n const element = getElement(state, documentKey, elementKey)\n\n if (element == null || Documents.isElementReference(element)) return null\n\n return getComponentPropControllerDescriptors(state, element.type)\n}\n\nexport function getIsInBuilder(state: State): boolean {\n return state.isInBuilder\n}\n\nexport function getIsReadOnly(state: State): boolean {\n return state.isReadOnly\n}\n\nexport function getBuilderEditMode(state: State): BuilderEditMode.State {\n return state.builderEditMode\n}\n\nexport function getBreakpoints(state: State): Breakpoints.State {\n return state.breakpoints\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAA+B;AAE/B,kBAA6B;AAC7B,gBAA2B;AAC3B,mBAA8B;AAC9B,sBAAiC;AACjC,qBAAgC;AAChC,sBAAiC;AACj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ClE;AAEO,SAAS,eAAe,OAAuB;AACpD,SAAO,MAAM;AACf;AAEO,SAAS,cAAc,OAAuB;AACnD,SAAO,MAAM;AACf;AAEO,SAAS,mBAAmB,OAAqC;AACtE,SAAO,MAAM;AACf;AAEO,SAAS,eAAe,OAAiC;AAC9D,SAAO,MAAM;AACf;","names":[]}
|
|
@@ -39,7 +39,8 @@ __export(read_write_state_exports, {
|
|
|
39
39
|
getElementImperativeHandlesContainingElement: () => getElementImperativeHandlesContainingElement,
|
|
40
40
|
getMeasurables: () => getMeasurables,
|
|
41
41
|
getPointer: () => getPointer,
|
|
42
|
-
parse: () => import_box_models.parse
|
|
42
|
+
parse: () => import_box_models.parse,
|
|
43
|
+
setupBuilderProxy: () => setupBuilderProxy
|
|
43
44
|
});
|
|
44
45
|
module.exports = __toCommonJS(read_write_state_exports);
|
|
45
46
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
@@ -103,6 +104,11 @@ function getElementImperativeHandlesContainingElement(state, element) {
|
|
|
103
104
|
}
|
|
104
105
|
return filteredElementImperativeHandles;
|
|
105
106
|
}
|
|
107
|
+
function setupBuilderProxy(builderProxy) {
|
|
108
|
+
return (dispatch) => {
|
|
109
|
+
builderProxy.setup({ onHostAction: (action) => dispatch(action) });
|
|
110
|
+
};
|
|
111
|
+
}
|
|
106
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
113
|
0 && (module.exports = {
|
|
108
114
|
createBox,
|
|
@@ -116,6 +122,7 @@ function getElementImperativeHandlesContainingElement(state, element) {
|
|
|
116
122
|
getElementImperativeHandlesContainingElement,
|
|
117
123
|
getMeasurables,
|
|
118
124
|
getPointer,
|
|
119
|
-
parse
|
|
125
|
+
parse,
|
|
126
|
+
setupBuilderProxy
|
|
120
127
|
});
|
|
121
128
|
//# sourceMappingURL=read-write-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/state/read-write-state.ts"],"sourcesContent":["import { combineReducers, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/state/read-write-state.ts"],"sourcesContent":["import { combineReducers, type ThunkAction, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport { BuilderAPIProxy } from './builder-api/proxy'\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nexport function setupBuilderProxy(\n builderProxy: BuilderAPIProxy,\n): ThunkAction<void, State, unknown, Action> {\n return dispatch => {\n builderProxy.setup({ onHostAction: action => dispatch(action) })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsE;AAEtE,gBAA2B;AAC3B,gBAA2B;AAC3B,cAAyB;AACzB,+BAA0C;AAO1C,oBAA+B;AAI/B,wBAAyC;AAEzC,MAAM,WAAW;AAAA,EACf,GAAG,cAAc;AAAA,EACjB,WAAW,UAAU;AAAA,EACrB,WAAW,UAAU;AAAA,EACrB,SAAS,QAAQ;AAAA,EACjB,0BAA0B,yBAAyB;AACrD;AAEO,SAAS,oBAAoB;AAClC,aAAO,gCAAgB,QAAQ;AACjC;AAWA,SAAS,uBAAuB,OAA+B;AAC7D,SAAO,MAAM;AACf;AAEO,SAAS,aAAa,OAA+B;AAC1D,SAAO,UAAU,aAAa,uBAAuB,KAAK,CAAC;AAC7D;AAEO,SAAS,YAAY,OAAc,aAAgD;AACxF,SAAO,UAAU,YAAY,uBAAuB,KAAK,GAAG,WAAW;AACzE;AAEA,SAAS,uBAAuB,OAA+B;AAC7D,SAAO,MAAM;AACf;AAEO,SAAS,eAAe,OAA8D;AAC3F,SAAO,UAAU,eAAe,uBAAuB,KAAK,CAAC;AAC/D;AAEO,SAAS,aAAa,OAA4D;AACvF,SAAO,UAAU,aAAa,uBAAuB,KAAK,CAAC;AAC7D;AAEO,SAAS,YACd,OACA,aACA,YAC2B;AAC3B,SAAO,UAAU,YAAY,uBAAuB,KAAK,GAAG,aAAa,UAAU;AACrF;AAEO,SAAS,WAAW,OAAoC;AAC7D,SAAO,QAAQ,WAAW,MAAM,OAAO;AACzC;AAEO,SAAS,4BACd,OACmD;AACnD,SAAO,yBAAyB,4BAA4B,MAAM,wBAAwB;AAC5F;AAEO,SAAS,6CACd,OACA,SACmD;AACnD,QAAM,2BAA2B,4BAA4B,KAAK;AAClE,QAAM,mCAAmC,oBAAI,IAAkD;AAE/F,aAAW,CAAC,aAAa,YAAY,KAAK,0BAA0B;AAClE,UAAM,uBAAuB,oBAAI,IAAqC;AAEtE,eAAW,CAAC,YAAY,uBAAuB,KAAK,cAAc;AAChE,YAAM,gBAAgB,wBAAwB,WAAW;AAEzD,UAAI,eAAe,SAAS,OAAO,GAAG;AACpC,6BAAqB,IAAI,YAAY,uBAAuB;AAAA,MAC9D;AAAA,IACF;AAEA,QAAI,qBAAqB,OAAO,GAAG;AACjC,uCAAiC,IAAI,aAAa,oBAAoB;AAAA,IACxE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,kBACd,cAC2C;AAC3C,SAAO,cAAY;AACjB,iBAAa,MAAM,EAAE,cAAc,YAAU,SAAS,MAAM,EAAE,CAAC;AAAA,EACjE;AACF;","names":[]}
|
|
@@ -0,0 +1,184 @@
|
|
|
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 store_exports = {};
|
|
30
|
+
__export(store_exports, {
|
|
31
|
+
conditionalReadWriteMiddleware: () => conditionalReadWriteMiddleware,
|
|
32
|
+
configureStore: () => configureStore
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(store_exports);
|
|
35
|
+
var import_toolkit = require("@reduxjs/toolkit");
|
|
36
|
+
var import_toolkit2 = require("./toolkit");
|
|
37
|
+
var import_actions = require("./builder-api/actions");
|
|
38
|
+
var import_host_api = require("./host-api");
|
|
39
|
+
var Breakpoints = __toESM(require("./modules/breakpoints"));
|
|
40
|
+
var import_read_only_element_tree = require("./middleware/read-only-element-tree");
|
|
41
|
+
var ReadOnlyState = __toESM(require("./read-only-state"));
|
|
42
|
+
var import_makeswift_api_client_sync = require("./middleware/makeswift-api-client-sync");
|
|
43
|
+
function conditionalReadWriteMiddleware(middlewareRef) {
|
|
44
|
+
let readWriteActionBuffer = [];
|
|
45
|
+
let middlewares = null;
|
|
46
|
+
let enhancedDispatch = null;
|
|
47
|
+
return (0, import_toolkit2.actionMiddleware)(({ dispatch, getState }) => (next) => {
|
|
48
|
+
return (action) => {
|
|
49
|
+
const state = getState();
|
|
50
|
+
if (middlewareRef.current == null) {
|
|
51
|
+
if (!state.isReadOnly) {
|
|
52
|
+
readWriteActionBuffer.push(action);
|
|
53
|
+
}
|
|
54
|
+
return next(action);
|
|
55
|
+
}
|
|
56
|
+
if (state.isReadOnly) {
|
|
57
|
+
console.error("Read-write state mismatch", {
|
|
58
|
+
isReadOnly: state.isReadOnly,
|
|
59
|
+
middlewareRef: middlewareRef.current,
|
|
60
|
+
siteVersion: state.siteVersion
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (enhancedDispatch == null || middlewares !== middlewareRef.current) {
|
|
64
|
+
middlewares = middlewareRef.current;
|
|
65
|
+
const middlewareApi = { dispatch, getState };
|
|
66
|
+
enhancedDispatch = (0, import_toolkit.compose)(...middlewares.map((mw) => mw(middlewareApi)))(next);
|
|
67
|
+
}
|
|
68
|
+
if (readWriteActionBuffer.length > 0) {
|
|
69
|
+
const readWriteActions = [...readWriteActionBuffer];
|
|
70
|
+
readWriteActionBuffer = [];
|
|
71
|
+
for (const bufferedAction of readWriteActions) {
|
|
72
|
+
enhancedDispatch(bufferedAction);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return enhancedDispatch(action);
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function withReadWriteState(loadReadWriteState) {
|
|
80
|
+
return (next) => (reducer, preloadedState) => ({
|
|
81
|
+
...next(reducer, preloadedState),
|
|
82
|
+
loadReadWriteState
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function configureStore({
|
|
86
|
+
name,
|
|
87
|
+
appOrigin,
|
|
88
|
+
hostApiClient,
|
|
89
|
+
preloadedState,
|
|
90
|
+
breakpoints
|
|
91
|
+
}) {
|
|
92
|
+
const readWriteMiddlewareRef = {
|
|
93
|
+
current: null
|
|
94
|
+
};
|
|
95
|
+
let refCount = 0;
|
|
96
|
+
let readWriteCleanup = null;
|
|
97
|
+
let readWriteSetupPromise = null;
|
|
98
|
+
const loadReadWriteState = async () => {
|
|
99
|
+
if (readWriteCleanup != null) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (readWriteSetupPromise != null) {
|
|
103
|
+
await readWriteSetupPromise;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
readWriteSetupPromise = (async () => {
|
|
107
|
+
const { BuilderAPIProxy } = await Promise.resolve().then(() => __toESM(require("./builder-api/proxy")));
|
|
108
|
+
const { createRootReducer, setupBuilderProxy } = await Promise.resolve().then(() => __toESM(require("./read-write-state")));
|
|
109
|
+
const { createReadWriteMiddleware } = await Promise.resolve().then(() => __toESM(require("./middleware/read-write")));
|
|
110
|
+
if (readWriteMiddlewareRef.current != null) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
store.replaceReducer(createRootReducer());
|
|
114
|
+
const builderProxy = new BuilderAPIProxy({ appOrigin });
|
|
115
|
+
readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy });
|
|
116
|
+
const dispatch = store.dispatch;
|
|
117
|
+
dispatch(setupBuilderProxy(builderProxy));
|
|
118
|
+
readWriteCleanup = () => {
|
|
119
|
+
readWriteMiddlewareRef.current = null;
|
|
120
|
+
builderProxy.teardown();
|
|
121
|
+
};
|
|
122
|
+
})();
|
|
123
|
+
try {
|
|
124
|
+
await readWriteSetupPromise;
|
|
125
|
+
} finally {
|
|
126
|
+
readWriteSetupPromise = null;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const store = (0, import_toolkit.configureStore)({
|
|
130
|
+
reducer: (0, import_toolkit.combineReducers)(ReadOnlyState.reducers),
|
|
131
|
+
preloadedState: {
|
|
132
|
+
...preloadedState,
|
|
133
|
+
breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints)
|
|
134
|
+
},
|
|
135
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat([
|
|
136
|
+
(0, import_read_only_element_tree.readOnlyElementTreeMiddleware)(),
|
|
137
|
+
(0, import_makeswift_api_client_sync.makeswiftApiClientSyncMiddleware)(hostApiClient),
|
|
138
|
+
conditionalReadWriteMiddleware(readWriteMiddlewareRef)
|
|
139
|
+
]),
|
|
140
|
+
enhancers: (getDefaultEnhancers) => getDefaultEnhancers().concat(
|
|
141
|
+
withReadWriteState(async ({ isReadOnly }) => {
|
|
142
|
+
if (isReadOnly) {
|
|
143
|
+
if (refCount > 0) {
|
|
144
|
+
console.error("Read-write state mismatch", {
|
|
145
|
+
isReadOnly,
|
|
146
|
+
refCount
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return () => {
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
await loadReadWriteState();
|
|
153
|
+
refCount += 1;
|
|
154
|
+
let didCleanup = false;
|
|
155
|
+
return () => {
|
|
156
|
+
if (didCleanup) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
didCleanup = true;
|
|
160
|
+
refCount -= 1;
|
|
161
|
+
if (refCount === 0 && readWriteCleanup != null) {
|
|
162
|
+
readWriteCleanup();
|
|
163
|
+
readWriteCleanup = null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
})
|
|
167
|
+
),
|
|
168
|
+
devTools: (0, import_toolkit2.devToolsConfig)({
|
|
169
|
+
name: `${name} (${(/* @__PURE__ */ new Date()).toISOString()})`,
|
|
170
|
+
actionsDenylist: [
|
|
171
|
+
import_host_api.HostActionTypes.BUILDER_POINTER_MOVE,
|
|
172
|
+
import_actions.BuilderActionTypes.HANDLE_POINTER_MOVE,
|
|
173
|
+
import_actions.BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE
|
|
174
|
+
]
|
|
175
|
+
})
|
|
176
|
+
});
|
|
177
|
+
return store;
|
|
178
|
+
}
|
|
179
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
180
|
+
0 && (module.exports = {
|
|
181
|
+
conditionalReadWriteMiddleware,
|
|
182
|
+
configureStore
|
|
183
|
+
});
|
|
184
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../api/client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\n\nimport { type Action } from './actions'\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\n\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\ninterface ReadWriteStateMixin {\n loadReadWriteState: ({ isReadOnly }: { isReadOnly: boolean }) => Promise<() => void>\n}\n\nfunction withReadWriteState(\n loadReadWriteState: ReadWriteStateMixin['loadReadWriteState'],\n): StoreEnhancer<ReadWriteStateMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n loadReadWriteState,\n })\n}\n\nexport function configureStore({\n name,\n appOrigin,\n hostApiClient,\n preloadedState,\n breakpoints,\n}: {\n name: string\n appOrigin: string\n hostApiClient: MakeswiftHostApiClient\n preloadedState: Partial<State> | null\n breakpoints?: Breakpoints.State\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxy.teardown()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n\n preloadedState: {\n ...preloadedState,\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n makeswiftApiClientSyncMiddleware(hostApiClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ]),\n\n enhancers: getDefaultEnhancers =>\n getDefaultEnhancers().concat(\n withReadWriteState(async ({ isReadOnly }) => {\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', {\n isReadOnly,\n refCount,\n })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n }),\n ),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAIP,IAAAA,kBAAoE;AACpE,qBAAmC;AACnC,sBAAgC;AAEhC,kBAA6B;AAE7B,oCAA8C;AAI9C,oBAA+B;AAQ/B,uCAAiD;AAU1C,SAAS,+BACd,eACuC;AACvC,MAAI,wBAAkC,CAAC;AACvC,MAAI,cAA0C;AAC9C,MAAI,mBAAoC;AAExC,aAAO,kCAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,CAAC,WAAmB;AACzB,YAAM,QAAQ,SAAS;AAEvB,UAAI,cAAc,WAAW,MAAM;AACjC,YAAI,CAAC,MAAM,YAAY;AAIrB,gCAAsB,KAAK,MAAM;AAAA,QACnC;AAEA,eAAO,KAAK,MAAM;AAAA,MACpB;AAEA,UAAI,MAAM,YAAY;AACpB,gBAAQ,MAAM,6BAA6B;AAAA,UACzC,YAAY,MAAM;AAAA,UAClB,eAAe,cAAc;AAAA,UAC7B,aAAa,MAAM;AAAA,QACrB,CAAC;AAAA,MACH;AAGA,UAAI,oBAAoB,QAAQ,gBAAgB,cAAc,SAAS;AACrE,sBAAc,cAAc;AAE5B,cAAM,gBAAgB,EAAE,UAAU,SAAS;AAK3C,+BAAmB,wBAAkB,GAAG,YAAY,IAAI,QAAM,GAAG,aAAa,CAAC,CAAC,EAAE,IAAI;AAAA,MACxF;AAGA,UAAI,sBAAsB,SAAS,GAAG;AACpC,cAAM,mBAAmB,CAAC,GAAG,qBAAqB;AAClD,gCAAwB,CAAC;AAMzB,mBAAW,kBAAkB,kBAAkB;AAC7C,2BAAiB,cAAc;AAAA,QACjC;A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;AAAA,MACH,aAAa,YAAY,gBAAgB,eAAe,gBAAgB,WAAW;AAAA,IACrF;AAAA,IAEA,YAAY,0BACV,qBAAqB,iCAAiB,EAAE,OAAO;AAAA,UAC7C,6DAA8B;AAAA,UAC9B,mEAAiC,aAAa;AAAA,MAC9C,+BAA+B,sBAAsB;AAAA,IACvD,CAAC;AAAA,IAEH,WAAW,yBACT,oBAAoB,EAAE;AAAA,MACpB,mBAAmB,OAAO,EAAE,WAAW,MAAM;AAC3C,YAAI,YAAY;AACd,cAAI,WAAW,GAAG;AAChB,oBAAQ,MAAM,6BAA6B;AAAA,cACzC;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH;AAEA,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAEA,cAAM,mBAAmB;AACzB,oBAAY;AAEZ,YAAI,aAAa;AACjB,eAAO,MAAM;AACX,cAAI,YAAY;AACd;AAAA,UACF;AAEA,uBAAa;AACb,sBAAY;AACZ,cAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,6BAAiB;AACjB,+BAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEF,cAAU,gCAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MAC1C,iBAAiB;AAAA,QACf,gCAAgB;AAAA,QAChB,kCAAmB;AAAA,QACnB,kCAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;","names":["import_toolkit","configureReduxStore"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var unified_state_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(unified_state_exports);
|
|
17
|
+
//# sourceMappingURL=unified-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/state/unified-state.ts"],"sourcesContent":["import { type ThunkDispatch, type Reducer } from '@reduxjs/toolkit'\n\nimport { type State as ReadOnlyState } from './read-only-state'\nimport { type State as ReadWriteState } from './read-write-state'\nimport { type Action } from './actions'\n\nexport type State = ReadOnlyState | ReadWriteState\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\nexport type ReadOnlyReducer = Reducer<ReadOnlyState>\nexport type ReadWriteDispatch = ThunkDispatch<ReadWriteState, unknown, Action>\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport { type ApiHandlerUserConfig, createApiHandler } from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime } from '../runtimes/react/react-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,yBAA4D;AAC5D,qBAAwD;AACxD,2BAA2D;AAC3D,mCAA6C;AAC7C,qBAA4D;AAE5D,oBAAgC;
|
|
1
|
+
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport { type ApiHandlerUserConfig, createApiHandler } from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime } from '../runtimes/react/react-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,yBAA4D;AAC5D,qBAAwD;AACxD,2BAA2D;AAC3D,mCAA6C;AAC7C,qBAA4D;AAE5D,oBAAgC;AAIhC,+BAKO;AAEP,gCAAmC;AACnC,kBAAqB;AACrB,6BAAgC;AAChC,kBAAqB;AAErB,iCAMO;AAEP,2BAA6B;","names":[]}
|
|
@@ -16,20 +16,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var deferred_exports = {};
|
|
20
|
+
__export(deferred_exports, {
|
|
21
|
+
createDeferred: () => createDeferred
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
module.exports = __toCommonJS(deferred_exports);
|
|
24
|
+
function createDeferred() {
|
|
25
|
+
let resolve = () => {
|
|
26
|
+
};
|
|
27
|
+
let reject = () => {
|
|
28
|
+
};
|
|
29
|
+
const promise = new Promise((resolveFn, rejectFn) => {
|
|
30
|
+
resolve = resolveFn;
|
|
31
|
+
reject = rejectFn;
|
|
29
32
|
});
|
|
33
|
+
return { promise, resolve, reject };
|
|
30
34
|
}
|
|
31
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
36
|
0 && (module.exports = {
|
|
33
|
-
|
|
37
|
+
createDeferred
|
|
34
38
|
});
|
|
35
|
-
//# sourceMappingURL=
|
|
39
|
+
//# sourceMappingURL=deferred.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/deferred.ts"],"sourcesContent":["export type Deferred<T> = {\n promise: Promise<T>\n resolve: (value: T) => void\n reject: (reason?: unknown) => void\n}\n\nexport function createDeferred<T>(): Deferred<T> {\n let resolve: (value: T) => void = () => {}\n let reject: (reason?: unknown) => void = () => {}\n\n const promise = new Promise<T>((resolveFn, rejectFn) => {\n resolve = resolveFn\n reject = rejectFn\n })\n\n return { promise, resolve, reject }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,iBAAiC;AAC/C,MAAI,UAA8B,MAAM;AAAA,EAAC;AACzC,MAAI,SAAqC,MAAM;AAAA,EAAC;AAEhD,QAAM,UAAU,IAAI,QAAW,CAAC,WAAW,aAAa;AACtD,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,SAAO,EAAE,SAAS,SAAS,OAAO;AACpC;","names":[]}
|
package/dist/esm/api/client.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import * as MakeswiftApiClient from "../state/makeswift-api-client";
|
|
2
|
-
import { setLocale } from "../state/shared-api";
|
|
3
|
-
import { resetLocaleState } from "../state/actions/internal/read-only-actions";
|
|
4
|
-
import { setSiteVersion } from "../state/actions/internal/read-only-actions";
|
|
5
2
|
import {
|
|
6
3
|
APIResourceType
|
|
7
4
|
} from "./types";
|
|
@@ -23,9 +20,7 @@ class MakeswiftHostApiClient {
|
|
|
23
20
|
constructor({
|
|
24
21
|
uri,
|
|
25
22
|
fetch,
|
|
26
|
-
cacheData
|
|
27
|
-
locale,
|
|
28
|
-
siteVersion
|
|
23
|
+
cacheData
|
|
29
24
|
}) {
|
|
30
25
|
this.graphqlClient = new GraphQLClient(uri);
|
|
31
26
|
this.makeswiftApiClient = MakeswiftApiClient.configureStore({
|
|
@@ -33,10 +28,6 @@ class MakeswiftHostApiClient {
|
|
|
33
28
|
});
|
|
34
29
|
this.fetch = fetch;
|
|
35
30
|
this.subscribe = this.makeswiftApiClient.subscribe;
|
|
36
|
-
this.makeswiftApiClient.dispatch(
|
|
37
|
-
locale != null ? setLocale(new Intl.Locale(locale)) : resetLocaleState()
|
|
38
|
-
);
|
|
39
|
-
this.makeswiftApiClient.dispatch(setSiteVersion(siteVersion));
|
|
40
31
|
}
|
|
41
32
|
readSwatch(swatchId) {
|
|
42
33
|
return MakeswiftApiClient.getAPIResource(
|
|
@@ -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'\nimport { setLocale } from '../state/shared-api'\nimport { resetLocaleState } from '../state/actions/internal/read-only-actions'\nimport { setSiteVersion } from '../state/actions/internal/read-only-actions'\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'\nimport { SiteVersion } from './site-version'\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 siteVersion,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n locale?: string\n siteVersion: SiteVersion | null\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\n })\n this.fetch = fetch\n this.subscribe = this.makeswiftApiClient.subscribe\n\n this.makeswiftApiClient.dispatch(\n locale != null ? setLocale(new Intl.Locale(locale)) : resetLocaleState(),\n )\n\n this.makeswiftApiClient.dispatch(setSiteVersion(siteVersion))\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":"AAEA,YAAY,wBAAwB;AACpC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAE/B;AAAA,EACE;AAAA,OAWK;AACP,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AASnC,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,IACA;AAAA,EACF,GAMG;AACD,SAAK,gBAAgB,IAAI,cAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe;AAAA,MAC1D,iBAAiB;AAAA,IACnB,CAAC;AACD,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,mBAAmB;AAEzC,SAAK,mBAAmB;AAAA,MACtB,UAAU,OAAO,UAAU,IAAI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,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 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 cacheData,\n }: {\n uri: string\n fetch: MakeswiftApiClient.HttpFetch\n cacheData?: CacheData\n }) {\n this.graphqlClient = new GraphQLClient(uri)\n this.makeswiftApiClient = MakeswiftApiClient.configureStore({\n serializedState: cacheData,\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":"AAEA,YAAY,wBAAwB;AAEpC;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,EACF,GAIG;AACD,SAAK,gBAAgB,IAAI,cAAc,GAAG;AAC1C,SAAK,qBAAqB,mBAAmB,eAAe;AAAA,MAC1D,iBAAiB;AAAA,IACnB,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;AAA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json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.
|
|
11
|
+
version: "0.27.0-canary.2",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
import { applyCorsHeaders } from "./cors";
|
|
16
16
|
function createApiHandler(apiKey, {
|
|
17
17
|
runtime,
|
|
18
|
-
appOrigin = "https://app.makeswift.com",
|
|
19
18
|
getFonts,
|
|
20
19
|
events,
|
|
21
20
|
client,
|
|
@@ -31,7 +30,7 @@ function createApiHandler(apiKey, {
|
|
|
31
30
|
return async function(req, route) {
|
|
32
31
|
const res = req.method.toUpperCase() !== "OPTIONS" ? await apiRouteHandler(req, route) : new Response(null, { status: 204, headers: [["Content-Length", "0"]] });
|
|
33
32
|
applyCorsHeaders(res.headers, {
|
|
34
|
-
origin: appOrigin,
|
|
33
|
+
origin: runtime.appOrigin,
|
|
35
34
|
allowedHeaders: ["Content-Type", "Authorization"]
|
|
36
35
|
});
|
|
37
36
|
return res;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api-handler/index.ts"],"sourcesContent":["import { Match, match as matchPattern } from 'path-to-regexp'\n\nimport { APIResource } from '../api'\nimport { ApiHandlerHeaders, deserializeSiteVersion } from '../api/site-version'\n\nimport { MakeswiftClient } from '../client'\nimport { type ReactRuntimeCore } from '../runtimes/react/react-runtime-core'\n\nimport { redirectLiveHandler } from './handlers/redirect-live'\nimport { elementTreeHandler } from './handlers/element-tree'\nimport { fontsHandler, type Font, type GetFonts } from './handlers/fonts'\nimport { manifestHandler, type Manifest } from './handlers/manifest'\nimport { mergeTranslatedDataHandler } from './handlers/merge-translated-data'\nimport { revalidateHandler } from './handlers/revalidate'\nimport { translatableDataHandler } from './handlers/translatable-data'\nimport { webhookHandler } from './handlers/webhook'\nimport { type OnPublish } from './handlers/webhook/types'\n\nimport {\n type ApiRequest,\n type ErrorResponseBody,\n ApiResponse,\n searchParams,\n} from './request-response'\n\nimport { applyCorsHeaders } from './cors'\n\nexport type { Manifest, Font }\n\ntype Events = { onPublish: OnPublish }\n\nexport type ApiHandlerUserConfig = {\n runtime: ReactRuntimeCore\n
|
|
1
|
+
{"version":3,"sources":["../../../src/api-handler/index.ts"],"sourcesContent":["import { Match, match as matchPattern } from 'path-to-regexp'\n\nimport { APIResource } from '../api'\nimport { ApiHandlerHeaders, deserializeSiteVersion } from '../api/site-version'\n\nimport { MakeswiftClient } from '../client'\nimport { type ReactRuntimeCore } from '../runtimes/react/react-runtime-core'\n\nimport { redirectLiveHandler } from './handlers/redirect-live'\nimport { elementTreeHandler } from './handlers/element-tree'\nimport { fontsHandler, type Font, type GetFonts } from './handlers/fonts'\nimport { manifestHandler, type Manifest } from './handlers/manifest'\nimport { mergeTranslatedDataHandler } from './handlers/merge-translated-data'\nimport { revalidateHandler } from './handlers/revalidate'\nimport { translatableDataHandler } from './handlers/translatable-data'\nimport { webhookHandler } from './handlers/webhook'\nimport { type OnPublish } from './handlers/webhook/types'\n\nimport {\n type ApiRequest,\n type ErrorResponseBody,\n ApiResponse,\n searchParams,\n} from './request-response'\n\nimport { applyCorsHeaders } from './cors'\n\nexport type { Manifest, Font }\n\ntype Events = { onPublish: OnPublish }\n\nexport type ApiHandlerUserConfig = {\n runtime: ReactRuntimeCore\n getFonts?: GetFonts\n events?: Events\n}\n\nexport type ApiHandlerInternalConfig = {\n client: MakeswiftClient\n manifest?: Partial<Manifest>\n revalidationHandler: (path?: string) => Promise<void>\n previewCookieNames: string[]\n}\n\ntype ApiHandlerConfig = ApiHandlerUserConfig & ApiHandlerInternalConfig\n\ntype ResponseType =\n | Awaited<\n | ReturnType<typeof redirectLiveHandler>\n | ReturnType<typeof elementTreeHandler>\n | ReturnType<typeof fontsHandler>\n | ReturnType<typeof manifestHandler>\n | ReturnType<typeof mergeTranslatedDataHandler>\n | ReturnType<typeof revalidateHandler>\n | ReturnType<typeof translatableDataHandler>\n | ReturnType<typeof webhookHandler>\n >\n | ApiResponse<APIResource>\n | ApiResponse<ErrorResponseBody>\n | Response\n\ntype ApiHandler = (req: ApiRequest, route: string) => Promise<ResponseType>\n\nexport function createApiHandler(\n apiKey: string,\n {\n runtime,\n getFonts,\n events,\n client,\n manifest,\n revalidationHandler,\n previewCookieNames,\n }: ApiHandlerConfig,\n): ApiHandler {\n if (typeof apiKey !== 'string') {\n throw new Error(\n 'The Makeswift API handler must be passed a valid Makeswift site API key. ' +\n `Received \"${apiKey}\" instead.`,\n )\n }\n\n return async function (req: ApiRequest, route: string): Promise<ResponseType> {\n const res =\n req.method.toUpperCase() !== 'OPTIONS'\n ? await apiRouteHandler(req, route)\n : new Response(null, { status: 204, headers: [['Content-Length', '0']] })\n\n applyCorsHeaders(res.headers, {\n origin: runtime.appOrigin,\n allowedHeaders: ['Content-Type', 'Authorization'],\n })\n\n return res\n }\n\n async function apiRouteHandler(req: ApiRequest, route: string): Promise<ResponseType> {\n const versionHeader = req.headers.get(ApiHandlerHeaders.SiteVersion)\n\n const siteVersion = versionHeader != null ? deserializeSiteVersion(versionHeader) : null\n\n const matches = <T extends object>(pattern: string): Match<T> =>\n matchPattern<T>(pattern, { decode: decodeURIComponent })(route)\n\n if (matches('/redirect-live')) return redirectLiveHandler(req, { previewCookieNames })\n if (matches('/element-tree')) return elementTreeHandler(req, { runtime })\n if (matches('/fonts')) return fontsHandler(req, { getFonts })\n if (matches('/manifest')) return manifestHandler(req, { apiKey, manifest })\n if (matches('/merge-translated-data')) return mergeTranslatedDataHandler(req, { client })\n if (matches('/revalidate')) {\n return revalidateHandler(req, { apiKey, revalidatePath: revalidationHandler })\n }\n\n if (matches('/translatable-data')) return translatableDataHandler(req, { client })\n if (matches('/webhook')) {\n return webhookHandler(req, { apiKey, events, revalidate: revalidationHandler })\n }\n\n const handleResource = <T extends APIResource>(\n resource: T | null,\n ): ApiResponse<APIResource | ErrorResponseBody> => {\n return resource !== null\n ? ApiResponse.json(resource)\n : ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n\n let m\n\n if ((m = matches<{ id: string }>('/swatches/:id'))) {\n return client.getSwatch(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/files/:id'))) {\n return client.getFile(m.params.id).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/typographies/:id'))) {\n return client.getTypography(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/global-elements/:id'))) {\n return client.getGlobalElement(m.params.id, siteVersion).then(handleResource)\n }\n\n if (\n (m = matches<{ globalElementId: string; locale: string }>(\n '/localized-global-elements/:globalElementId/:locale',\n ))\n ) {\n return client\n .getLocalizedGlobalElement(m.params.globalElementId, m.params.locale, siteVersion)\n .then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/page-pathname-slices/:id'))) {\n const localeParam = searchParams(req).get('locale')\n const locale = typeof localeParam === 'string' ? localeParam : undefined\n\n return client.getPagePathnameSlice(m.params.id, siteVersion, { locale }).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/tables/:id'))) {\n return client.getTable(m.params.id).then(handleResource)\n }\n\n return ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n}\n"],"mappings":"AAAA,SAAgB,SAAS,oBAAoB;AAG7C,SAAS,mBAAmB,8BAA8B;AAK1D,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,oBAA8C;AACvD,SAAS,uBAAsC;AAC/C,SAAS,kCAAkC;AAC3C,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,sBAAsB;AAG/B;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;AAsC1B,SAAS,iBACd,QACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACY;AACZ,MAAI,OAAO,WAA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