@makeswift/runtime 0.27.1 → 0.27.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/react.js +256 -0
- package/dist/cjs/api/react.js.map +1 -0
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +3 -3
- package/dist/cjs/next/api-handler/config/app-router.js +10 -1
- package/dist/cjs/next/api-handler/config/app-router.js.map +1 -1
- package/dist/cjs/runtimes/react/components/LiveProvider.js +50 -0
- package/dist/cjs/runtimes/react/components/LiveProvider.js.map +1 -0
- package/dist/cjs/runtimes/react/components/PreviewProvider.js +63 -0
- package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +1 -0
- package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js +62 -0
- package/dist/cjs/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-is-preview.js +33 -0
- package/dist/cjs/runtimes/react/hooks/use-is-preview.js.map +1 -0
- package/dist/cjs/state/actions/internal.js +205 -0
- package/dist/cjs/state/actions/internal.js.map +1 -0
- package/dist/cjs/state/mixins/setup-teardown.js +35 -0
- package/dist/cjs/state/mixins/setup-teardown.js.map +1 -0
- package/dist/cjs/state/modules/box-models.js +127 -0
- package/dist/cjs/state/modules/box-models.js.map +1 -0
- package/dist/cjs/state/modules/element-imperative-handles.js +60 -0
- package/dist/cjs/state/modules/element-imperative-handles.js.map +1 -0
- package/dist/cjs/state/modules/is-preview.js +47 -0
- package/dist/cjs/state/modules/is-preview.js.map +1 -0
- package/dist/cjs/state/modules/pointer.js +47 -0
- package/dist/cjs/state/modules/pointer.js.map +1 -0
- package/dist/cjs/state/modules/read-write-documents.js +98 -0
- package/dist/cjs/state/modules/read-write-documents.js.map +1 -0
- package/dist/cjs/state/react-builder-preview.js +586 -0
- package/dist/cjs/state/react-builder-preview.js.map +1 -0
- package/dist/cjs/state/react-page.js +313 -0
- package/dist/cjs/state/react-page.js.map +1 -0
- package/dist/esm/api/react.js +223 -0
- package/dist/esm/api/react.js.map +1 -0
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +3 -3
- package/dist/esm/next/api-handler/config/app-router.js +10 -1
- package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
- package/dist/esm/runtimes/react/components/LiveProvider.js +20 -0
- package/dist/esm/runtimes/react/components/LiveProvider.js.map +1 -0
- package/dist/esm/runtimes/react/components/PreviewProvider.js +33 -0
- package/dist/esm/runtimes/react/components/PreviewProvider.js.map +1 -0
- package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js +38 -0
- package/dist/esm/runtimes/react/components/hooks/use-builder-connection-ping.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-is-preview.js +9 -0
- package/dist/esm/runtimes/react/hooks/use-is-preview.js.map +1 -0
- package/dist/esm/state/actions/internal.js +162 -0
- package/dist/esm/state/actions/internal.js.map +1 -0
- package/dist/esm/state/mixins/setup-teardown.js +11 -0
- package/dist/esm/state/mixins/setup-teardown.js.map +1 -0
- package/dist/esm/state/modules/box-models.js +98 -0
- package/dist/esm/state/modules/box-models.js.map +1 -0
- package/dist/esm/state/modules/element-imperative-handles.js +35 -0
- package/dist/esm/state/modules/element-imperative-handles.js.map +1 -0
- package/dist/esm/state/modules/is-preview.js +21 -0
- package/dist/esm/state/modules/is-preview.js.map +1 -0
- package/dist/esm/state/modules/pointer.js +22 -0
- package/dist/esm/state/modules/pointer.js.map +1 -0
- package/dist/esm/state/modules/read-write-documents.js +60 -0
- package/dist/esm/state/modules/read-write-documents.js.map +1 -0
- package/dist/esm/state/react-builder-preview.js +547 -0
- package/dist/esm/state/react-builder-preview.js.map +1 -0
- package/dist/esm/state/react-page.js +268 -0
- package/dist/esm/state/react-page.js.map +1 -0
- package/dist/types/api/react.d.ts +82 -0
- package/dist/types/api/react.d.ts.map +1 -0
- package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/LiveProvider.d.ts +3 -0
- package/dist/types/runtimes/react/components/LiveProvider.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts +5 -0
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts +4 -0
- package/dist/types/runtimes/react/components/hooks/use-builder-connection-ping.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-is-preview.d.ts +2 -0
- package/dist/types/runtimes/react/hooks/use-is-preview.d.ts.map +1 -0
- package/dist/types/state/__tests__/react-page.test.d.ts +2 -0
- package/dist/types/state/__tests__/react-page.test.d.ts.map +1 -0
- package/dist/types/state/actions/internal.d.ts +181 -0
- package/dist/types/state/actions/internal.d.ts.map +1 -0
- package/dist/types/state/mixins/setup-teardown.d.ts +7 -0
- package/dist/types/state/mixins/setup-teardown.d.ts.map +1 -0
- package/dist/types/state/modules/box-models.d.ts +23 -0
- package/dist/types/state/modules/box-models.d.ts.map +1 -0
- package/dist/types/state/modules/element-imperative-handles.d.ts +7 -0
- package/dist/types/state/modules/element-imperative-handles.d.ts.map +1 -0
- package/dist/types/state/modules/is-preview.d.ts +6 -0
- package/dist/types/state/modules/is-preview.d.ts.map +1 -0
- package/dist/types/state/modules/pointer.d.ts +12 -0
- package/dist/types/state/modules/pointer.d.ts.map +1 -0
- package/dist/types/state/modules/read-write-documents.d.ts +14 -0
- package/dist/types/state/modules/read-write-documents.d.ts.map +1 -0
- package/dist/types/state/react-builder-preview.d.ts +108 -0
- package/dist/types/state/react-builder-preview.d.ts.map +1 -0
- package/dist/types/state/react-page.d.ts +149 -0
- package/dist/types/state/react-page.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,98 @@
|
|
|
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 read_write_documents_exports = {};
|
|
30
|
+
__export(read_write_documents_exports, {
|
|
31
|
+
getDocument: () => getDocument,
|
|
32
|
+
getDocuments: () => getDocuments,
|
|
33
|
+
getInitialState: () => getInitialState,
|
|
34
|
+
isElementReference: () => import_read_only_documents.isElementReference,
|
|
35
|
+
reducer: () => reducer
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(read_write_documents_exports);
|
|
38
|
+
var import_immutable = require("immutable");
|
|
39
|
+
var ReadOnlyDocuments = __toESM(require("./read-only-documents"));
|
|
40
|
+
var import_actions = require("../actions");
|
|
41
|
+
var import_read_only_documents = require("./read-only-documents");
|
|
42
|
+
function apply(data, operation) {
|
|
43
|
+
let applied = data;
|
|
44
|
+
operation.forEach((component) => {
|
|
45
|
+
if (component.ld != null)
|
|
46
|
+
applied = (0, import_immutable.removeIn)(applied, component.p);
|
|
47
|
+
if (component.od != null)
|
|
48
|
+
applied = (0, import_immutable.removeIn)(applied, component.p);
|
|
49
|
+
if (component.li != null)
|
|
50
|
+
applied = (0, import_immutable.setIn)(applied, component.p, component.li);
|
|
51
|
+
if (component.oi != null)
|
|
52
|
+
applied = (0, import_immutable.setIn)(applied, component.p, component.oi);
|
|
53
|
+
});
|
|
54
|
+
return applied;
|
|
55
|
+
}
|
|
56
|
+
function getInitialState({
|
|
57
|
+
documents = []
|
|
58
|
+
} = {}) {
|
|
59
|
+
return ReadOnlyDocuments.getInitialState({ documents });
|
|
60
|
+
}
|
|
61
|
+
function getReadOnlyDocumentsStateSlice(state) {
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
function getDocument(state, documentKey) {
|
|
65
|
+
return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey);
|
|
66
|
+
}
|
|
67
|
+
function getDocuments(state) {
|
|
68
|
+
return ReadOnlyDocuments.getDocuments(getReadOnlyDocumentsStateSlice(state));
|
|
69
|
+
}
|
|
70
|
+
function reducer(state = getInitialState(), action) {
|
|
71
|
+
const nextState = ReadOnlyDocuments.reducer(state, action);
|
|
72
|
+
if (!(0, import_actions.isKnownAction)(action))
|
|
73
|
+
return state;
|
|
74
|
+
switch (action.type) {
|
|
75
|
+
case import_actions.ActionTypes.CHANGE_DOCUMENT: {
|
|
76
|
+
const document = getDocument(nextState, action.payload.documentKey);
|
|
77
|
+
if (document == null)
|
|
78
|
+
return nextState;
|
|
79
|
+
const currentRootElement = ReadOnlyDocuments.getRootElement(document);
|
|
80
|
+
const nextRootElement = apply(currentRootElement, action.payload.operation);
|
|
81
|
+
return currentRootElement === nextRootElement ? nextState : new Map(nextState).set(action.payload.documentKey, {
|
|
82
|
+
...document,
|
|
83
|
+
rootElement: nextRootElement
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
return nextState;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
getDocument,
|
|
93
|
+
getDocuments,
|
|
94
|
+
getInitialState,
|
|
95
|
+
isElementReference,
|
|
96
|
+
reducer
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=read-write-documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/read-write-documents.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { removeIn, setIn } from 'immutable'\n\nimport * as ReadOnlyDocuments from './read-only-documents'\nimport { type Action, type UnknownAction, ActionTypes, isKnownAction } from '../actions'\n\nexport type { Document, Element, ElementData, ElementReference } from './read-only-documents'\nexport { isElementReference } from './read-only-documents'\nexport type { Operation }\n\nfunction apply(data: ReadOnlyDocuments.Element, operation: Operation): ReadOnlyDocuments.Element {\n let applied = data\n\n operation.forEach(component => {\n // @ts-expect-error: `ld` isn't in all possible values of `component`\n if (component.ld != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `od` isn't in all possible values of `component`\n if (component.od != null) applied = removeIn(applied, component.p)\n\n // @ts-expect-error: `li` isn't in all possible values of `component`\n if (component.li != null) applied = setIn(applied, component.p, component.li)\n\n // @ts-expect-error: `oi` isn't in all possible values of `component`\n if (component.oi != null) applied = setIn(applied, component.p, component.oi)\n })\n\n return applied\n}\n\nexport type State = ReadOnlyDocuments.State\n\nexport function getInitialState({\n documents = [],\n}: { documents?: ReadOnlyDocuments.Document[] } = {}): State {\n return ReadOnlyDocuments.getInitialState({ documents })\n}\n\nfunction getReadOnlyDocumentsStateSlice(state: State): ReadOnlyDocuments.State {\n return state\n}\n\nexport function getDocument(state: State, documentKey: string): ReadOnlyDocuments.Document | null {\n return ReadOnlyDocuments.getDocument(getReadOnlyDocumentsStateSlice(state), documentKey)\n}\n\nexport function getDocuments(state: State): ReadOnlyDocuments.State {\n return ReadOnlyDocuments.getDocuments(getReadOnlyDocumentsStateSlice(state))\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n const nextState = ReadOnlyDocuments.reducer(state, action)\n\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ActionTypes.CHANGE_DOCUMENT: {\n const document = getDocument(nextState, action.payload.documentKey)\n if (document == null) return nextState\n\n const currentRootElement = ReadOnlyDocuments.getRootElement(document)\n\n const nextRootElement = apply(currentRootElement, action.payload.operation)\n\n return currentRootElement === nextRootElement\n ? nextState\n : new Map(nextState).set(action.payload.documentKey, {\n ...document,\n rootElement: nextRootElement,\n })\n }\n\n default:\n return nextState\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAgC;AAEhC,wBAAmC;AACnC,qBAA4E;AAG5E,iCAAmC;AAGnC,SAAS,MAAM,MAAiC,WAAiD;AAC/F,MAAI,UAAU;AAEd,YAAU,QAAQ,eAAa;AAE7B,QAAI,UAAU,MAAM;AAAM,oBAAU,2BAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,oBAAU,2BAAS,SAAS,UAAU,CAAC;AAGjE,QAAI,UAAU,MAAM;AAAM,oBAAU,wBAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAG5E,QAAI,UAAU,MAAM;AAAM,oBAAU,wBAAM,SAAS,UAAU,GAAG,UAAU,EAAE;AAAA,EAC9E,CAAC;AAED,SAAO;AACT;AAIO,SAAS,gBAAgB;AAAA,EAC9B,YAAY,CAAC;AACf,IAAkD,CAAC,GAAU;AAC3D,SAAO,kBAAkB,gBAAgB,EAAE,UAAU,CAAC;AACxD;AAEA,SAAS,+BAA+B,OAAuC;AAC7E,SAAO;AACT;AAEO,SAAS,YAAY,OAAc,aAAwD;AAChG,SAAO,kBAAkB,YAAY,+BAA+B,KAAK,GAAG,WAAW;AACzF;AAEO,SAAS,aAAa,OAAuC;AAClE,SAAO,kBAAkB,aAAa,+BAA+B,KAAK,CAAC;AAC7E;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,QAAM,YAAY,kBAAkB,QAAQ,OAAO,MAAM;AAEzD,MAAI,KAAC,8BAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,2BAAY,iBAAiB;AAChC,YAAM,WAAW,YAAY,WAAW,OAAO,QAAQ,WAAW;AAClE,UAAI,YAAY;AAAM,eAAO;AAE7B,YAAM,qBAAqB,kBAAkB,eAAe,QAAQ;AAEpE,YAAM,kBAAkB,MAAM,oBAAoB,OAAO,QAAQ,SAAS;AAE1E,aAAO,uBAAuB,kBAC1B,YACA,IAAI,IAAI,SAAS,EAAE,IAAI,OAAO,QAAQ,aAAa;AAAA,QACjD,GAAG;AAAA,QACH,aAAa;AAAA,MACf,CAAC;AAAA,IACP;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1,586 @@
|
|
|
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 react_builder_preview_exports = {};
|
|
30
|
+
__export(react_builder_preview_exports, {
|
|
31
|
+
builderAPIMiddleware: () => builderAPIMiddleware,
|
|
32
|
+
configureStore: () => configureStore,
|
|
33
|
+
createBox: () => import_box_models.createBox,
|
|
34
|
+
getBox: () => import_box_models.getBox,
|
|
35
|
+
initialize: () => initialize,
|
|
36
|
+
parse: () => import_box_models.parse,
|
|
37
|
+
propControllerHandlesMiddleware: () => propControllerHandlesMiddleware,
|
|
38
|
+
reducer: () => reducer,
|
|
39
|
+
startMeasuringElements: () => startMeasuringElements
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(react_builder_preview_exports);
|
|
42
|
+
var import_toolkit = require("@reduxjs/toolkit");
|
|
43
|
+
var import_deepEqual = __toESM(require("../utils/deepEqual"));
|
|
44
|
+
var Documents = __toESM(require("./modules/read-write-documents"));
|
|
45
|
+
var ElementTrees = __toESM(require("./modules/element-trees"));
|
|
46
|
+
var ReactComponents = __toESM(require("./modules/react-components"));
|
|
47
|
+
var BoxModels = __toESM(require("./modules/box-models"));
|
|
48
|
+
var ComponentsMeta = __toESM(require("./modules/components-meta"));
|
|
49
|
+
var PropControllers = __toESM(require("./modules/prop-controllers"));
|
|
50
|
+
var PropControllerHandles = __toESM(require("./modules/prop-controller-handles"));
|
|
51
|
+
var IsInBuilder = __toESM(require("./modules/is-in-builder"));
|
|
52
|
+
var IsPreview = __toESM(require("./modules/is-preview"));
|
|
53
|
+
var BuilderEditMode = __toESM(require("./modules/builder-edit-mode"));
|
|
54
|
+
var Pointer = __toESM(require("./modules/pointer"));
|
|
55
|
+
var ElementImperativeHandles = __toESM(require("./modules/element-imperative-handles"));
|
|
56
|
+
var Breakpoints = __toESM(require("./modules/breakpoints"));
|
|
57
|
+
var import_setup_teardown = require("./mixins/setup-teardown");
|
|
58
|
+
var ReactPage = __toESM(require("./react-page"));
|
|
59
|
+
var Shared = __toESM(require("./shared-api"));
|
|
60
|
+
var import_actions2 = require("./builder-api/actions");
|
|
61
|
+
var Builder = __toESM(require("./builder-api/actions"));
|
|
62
|
+
var import_internal = require("./actions/internal");
|
|
63
|
+
var Internal = __toESM(require("./actions/internal"));
|
|
64
|
+
var import_toolkit2 = require("./toolkit");
|
|
65
|
+
var import_instances = require("../prop-controllers/instances");
|
|
66
|
+
var import_builder = require("../builder");
|
|
67
|
+
var import_host_api = require("./host-api");
|
|
68
|
+
var import_box_models = require("./modules/box-models");
|
|
69
|
+
const reducer = (0, import_toolkit.combineReducers)({
|
|
70
|
+
documents: Documents.reducer,
|
|
71
|
+
elementTrees: ElementTrees.reducer,
|
|
72
|
+
reactComponents: ReactComponents.reducer,
|
|
73
|
+
boxModels: BoxModels.reducer,
|
|
74
|
+
componentsMeta: ComponentsMeta.reducer,
|
|
75
|
+
propControllers: PropControllers.reducer,
|
|
76
|
+
propControllerHandles: PropControllerHandles.reducer,
|
|
77
|
+
isInBuilder: IsInBuilder.reducer,
|
|
78
|
+
isPreview: IsPreview.reducer,
|
|
79
|
+
builderEditMode: BuilderEditMode.reducer,
|
|
80
|
+
pointer: Pointer.reducer,
|
|
81
|
+
elementImperativeHandles: ElementImperativeHandles.reducer,
|
|
82
|
+
breakpoints: Breakpoints.reducer
|
|
83
|
+
});
|
|
84
|
+
function getDocumentsStateSlice(state) {
|
|
85
|
+
return state.documents;
|
|
86
|
+
}
|
|
87
|
+
function getBoxModelsStateSlice(state) {
|
|
88
|
+
return state.boxModels;
|
|
89
|
+
}
|
|
90
|
+
function getMeasurables(state) {
|
|
91
|
+
return BoxModels.getMeasurables(getBoxModelsStateSlice(state));
|
|
92
|
+
}
|
|
93
|
+
function getBoxModels(state) {
|
|
94
|
+
return BoxModels.getBoxModels(getBoxModelsStateSlice(state));
|
|
95
|
+
}
|
|
96
|
+
function getBoxModel(state, documentKey, elementKey) {
|
|
97
|
+
return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey);
|
|
98
|
+
}
|
|
99
|
+
function getComponentsMetaStateSlice(state) {
|
|
100
|
+
return state.componentsMeta;
|
|
101
|
+
}
|
|
102
|
+
function getComponentsMeta(state) {
|
|
103
|
+
return ComponentsMeta.getComponentsMeta(getComponentsMetaStateSlice(state));
|
|
104
|
+
}
|
|
105
|
+
function getPropControllersStateSlice(state) {
|
|
106
|
+
return state.propControllers;
|
|
107
|
+
}
|
|
108
|
+
function getComponentPropControllerDescriptors(state, componentType) {
|
|
109
|
+
return PropControllers.getComponentPropControllerDescriptors(
|
|
110
|
+
getPropControllersStateSlice(state),
|
|
111
|
+
componentType
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
function getPropControllerHandlesStateSlice(state) {
|
|
115
|
+
return state.propControllerHandles;
|
|
116
|
+
}
|
|
117
|
+
function getPointer(state) {
|
|
118
|
+
return Pointer.getPointer(state.pointer);
|
|
119
|
+
}
|
|
120
|
+
function getElementImperativeHandles(state) {
|
|
121
|
+
return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles);
|
|
122
|
+
}
|
|
123
|
+
function getElementImperativeHandlesContainingElement(state, element) {
|
|
124
|
+
const elementImperativeHandles = getElementImperativeHandles(state);
|
|
125
|
+
const filteredElementImperativeHandles = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const [documentKey, byElementKey] of elementImperativeHandles) {
|
|
127
|
+
const filteredByElementKey = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const [elementKey, elementImperativeHandle] of byElementKey) {
|
|
129
|
+
const handleElement = elementImperativeHandle.getDomNode();
|
|
130
|
+
if (handleElement?.contains(element)) {
|
|
131
|
+
filteredByElementKey.set(elementKey, elementImperativeHandle);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (filteredByElementKey.size > 0) {
|
|
135
|
+
filteredElementImperativeHandles.set(documentKey, filteredByElementKey);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return filteredElementImperativeHandles;
|
|
139
|
+
}
|
|
140
|
+
function measureElements() {
|
|
141
|
+
return (dispatch, getState) => {
|
|
142
|
+
const measurables = getMeasurables(getState());
|
|
143
|
+
const currentBoxModels = getBoxModels(getState());
|
|
144
|
+
const measuredBoxModels = /* @__PURE__ */ new Map();
|
|
145
|
+
measurables.forEach((documentMeasurables, documentKey) => {
|
|
146
|
+
const measuredDocumentBoxModels = /* @__PURE__ */ new Map();
|
|
147
|
+
documentMeasurables.forEach((measurable, elementKey) => {
|
|
148
|
+
const boxModel = BoxModels.measure(measurable);
|
|
149
|
+
if (boxModel != null)
|
|
150
|
+
measuredDocumentBoxModels.set(elementKey, boxModel);
|
|
151
|
+
});
|
|
152
|
+
if (measuredDocumentBoxModels.size > 0) {
|
|
153
|
+
measuredBoxModels.set(documentKey, measuredDocumentBoxModels);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const changedBoxModels = /* @__PURE__ */ new Map();
|
|
157
|
+
currentBoxModels.forEach((currentDocumentBoxModels, documentKey) => {
|
|
158
|
+
const changedDocumentBoxModels = /* @__PURE__ */ new Map();
|
|
159
|
+
currentDocumentBoxModels.forEach((_boxModel, elementKey) => {
|
|
160
|
+
if (!measuredBoxModels.get(documentKey)?.has(elementKey)) {
|
|
161
|
+
changedDocumentBoxModels.set(elementKey, null);
|
|
162
|
+
}
|
|
163
|
+
if (changedDocumentBoxModels.size > 0) {
|
|
164
|
+
changedBoxModels.set(documentKey, changedDocumentBoxModels);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
measuredBoxModels.forEach((measuredDocumentBoxModels, documentKey) => {
|
|
169
|
+
const changedDocumentBoxModels = /* @__PURE__ */ new Map();
|
|
170
|
+
measuredDocumentBoxModels.forEach((measuredBoxModel, elementKey) => {
|
|
171
|
+
const currentBoxModel = getBoxModel(getState(), documentKey, elementKey);
|
|
172
|
+
if (currentBoxModel == null || !(0, import_deepEqual.default)(currentBoxModel, measuredBoxModel)) {
|
|
173
|
+
changedDocumentBoxModels.set(elementKey, measuredBoxModel);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
if (changedDocumentBoxModels.size > 0) {
|
|
177
|
+
changedBoxModels.set(documentKey, changedDocumentBoxModels);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
if (changedBoxModels.size > 0)
|
|
181
|
+
dispatch(Builder.changeElementBoxModels(changedBoxModels));
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function startMeasuringElements() {
|
|
185
|
+
return (dispatch) => {
|
|
186
|
+
let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
187
|
+
return () => {
|
|
188
|
+
cancelAnimationFrame(animationFrameHandle);
|
|
189
|
+
};
|
|
190
|
+
function handleAnimationFrameRequest() {
|
|
191
|
+
dispatch(measureElements());
|
|
192
|
+
animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function getElementSize(element) {
|
|
197
|
+
return {
|
|
198
|
+
offsetWidth: element.offsetWidth,
|
|
199
|
+
offsetHeight: element.offsetHeight,
|
|
200
|
+
clientWidth: element.clientWidth,
|
|
201
|
+
clientHeight: element.clientHeight,
|
|
202
|
+
scrollWidth: element.scrollWidth,
|
|
203
|
+
scrollHeight: element.scrollHeight,
|
|
204
|
+
scrollTop: element.scrollTop,
|
|
205
|
+
scrollLeft: element.scrollLeft
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function lockDocumentScroll() {
|
|
209
|
+
return (dispatch) => {
|
|
210
|
+
const lastDocumentOverflow = window.document.documentElement.style.overflow;
|
|
211
|
+
window.document.documentElement.style.overflow = "hidden";
|
|
212
|
+
window.document.documentElement.addEventListener("wheel", handleWheelEvent);
|
|
213
|
+
return () => {
|
|
214
|
+
window.document.documentElement.style.overflow = lastDocumentOverflow;
|
|
215
|
+
window.document.documentElement.removeEventListener("wheel", handleWheelEvent);
|
|
216
|
+
};
|
|
217
|
+
function handleWheelEvent({ deltaX, deltaY }) {
|
|
218
|
+
dispatch(Builder.handleWheel({ deltaX, deltaY }));
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function startHandlingPointerMoveEvent() {
|
|
223
|
+
return (dispatch) => {
|
|
224
|
+
window.document.documentElement.addEventListener("pointermove", handlePointerMoveEvent);
|
|
225
|
+
return () => {
|
|
226
|
+
window.document.documentElement.removeEventListener("pointermove", handlePointerMoveEvent);
|
|
227
|
+
};
|
|
228
|
+
function handlePointerMoveEvent({ clientX, clientY }) {
|
|
229
|
+
dispatch(Builder.handlePointerMove({ clientX, clientY }));
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function startHandlingFocusEvents() {
|
|
234
|
+
return (_dispatch, getState) => {
|
|
235
|
+
window.addEventListener("focusin", handleFocusIn);
|
|
236
|
+
window.addEventListener("focusout", handleFocusOut);
|
|
237
|
+
return () => {
|
|
238
|
+
window.removeEventListener("focusin", handleFocusIn);
|
|
239
|
+
window.removeEventListener("focusout", handleFocusOut);
|
|
240
|
+
};
|
|
241
|
+
function handleFocusIn(event) {
|
|
242
|
+
if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (!(event.target instanceof window.HTMLElement) || !event.target.isContentEditable) {
|
|
246
|
+
window.parent.focus();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function handleFocusOut(event) {
|
|
250
|
+
if (ReactPage.getBuilderEditMode(getState()) === BuilderEditMode.BuilderEditMode.INTERACT) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (!(event.relatedTarget instanceof window.HTMLElement) || !event.relatedTarget.isContentEditable) {
|
|
254
|
+
window.parent.focus();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function startMeasuringDocumentElement() {
|
|
260
|
+
return (dispatch) => {
|
|
261
|
+
let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
262
|
+
let lastSize;
|
|
263
|
+
return () => {
|
|
264
|
+
cancelAnimationFrame(animationFrameHandle);
|
|
265
|
+
};
|
|
266
|
+
function handleAnimationFrameRequest() {
|
|
267
|
+
const nextSize = getElementSize(window.document.documentElement);
|
|
268
|
+
if (!(0, import_deepEqual.default)(lastSize, nextSize)) {
|
|
269
|
+
lastSize = nextSize;
|
|
270
|
+
dispatch(Builder.changeDocumentElementSize(nextSize));
|
|
271
|
+
}
|
|
272
|
+
animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function elementKeysFromElementFromPoint(elementFromPoint) {
|
|
277
|
+
return (_dispatch, getState) => {
|
|
278
|
+
if (elementFromPoint == null)
|
|
279
|
+
return null;
|
|
280
|
+
const elementImperativeHandles = getElementImperativeHandlesContainingElement(
|
|
281
|
+
getState(),
|
|
282
|
+
elementFromPoint
|
|
283
|
+
);
|
|
284
|
+
const ascendingDepthDocumentKeys = ReactPage.getDocumentKeysSortedByDepth(getState());
|
|
285
|
+
const descendingDepthDocumentKeys = ascendingDepthDocumentKeys.slice().reverse();
|
|
286
|
+
let currentElement = elementFromPoint;
|
|
287
|
+
let keys = null;
|
|
288
|
+
while (currentElement != null) {
|
|
289
|
+
for (const documentKey of descendingDepthDocumentKeys) {
|
|
290
|
+
const byElementKey = elementImperativeHandles.get(documentKey);
|
|
291
|
+
if (byElementKey == null)
|
|
292
|
+
continue;
|
|
293
|
+
for (const [elementKey, elementImperativeHandle] of byElementKey) {
|
|
294
|
+
if (elementImperativeHandle.getDomNode() === currentElement) {
|
|
295
|
+
return { documentKey, elementKey };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
currentElement = currentElement.parentElement;
|
|
300
|
+
}
|
|
301
|
+
return keys;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function startPollingElementFromPoint() {
|
|
305
|
+
return (dispatch, getState) => {
|
|
306
|
+
let lastElementFromPoint = null;
|
|
307
|
+
let animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest);
|
|
308
|
+
return () => {
|
|
309
|
+
cancelAnimationFrame(animationFrameRequestId);
|
|
310
|
+
};
|
|
311
|
+
function handleAnimationFrameRequest() {
|
|
312
|
+
const pointer = getPointer(getState());
|
|
313
|
+
const elementFromPoint = pointer == null ? null : document.elementFromPoint(pointer.x, pointer.y);
|
|
314
|
+
if (elementFromPoint !== lastElementFromPoint) {
|
|
315
|
+
lastElementFromPoint = elementFromPoint;
|
|
316
|
+
const keys = dispatch(elementKeysFromElementFromPoint(elementFromPoint));
|
|
317
|
+
dispatch(Builder.elementFromPointChange(keys));
|
|
318
|
+
}
|
|
319
|
+
animationFrameRequestId = requestAnimationFrame(handleAnimationFrameRequest);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function registerBuilderComponents() {
|
|
324
|
+
return (dispatch, getState) => {
|
|
325
|
+
const state = getState();
|
|
326
|
+
const componentsMeta = getComponentsMeta(state);
|
|
327
|
+
componentsMeta.forEach((meta, type) => {
|
|
328
|
+
const descriptors = getComponentPropControllerDescriptors(state, type);
|
|
329
|
+
if (descriptors != null) {
|
|
330
|
+
const [serializedControls, transferables] = (0, import_builder.serializeControls)(descriptors);
|
|
331
|
+
dispatch(
|
|
332
|
+
Builder.registerBuilderComponent({ type, meta, serializedControls }, transferables)
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
return () => {
|
|
337
|
+
componentsMeta.forEach((_, type) => {
|
|
338
|
+
dispatch(Builder.unregisterBuilderComponent({ type }));
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function registerBuilderDocuments() {
|
|
344
|
+
return (dispatch, getState) => {
|
|
345
|
+
const documents = Documents.getDocuments(getDocumentsStateSlice(getState()));
|
|
346
|
+
documents.forEach((document2) => {
|
|
347
|
+
dispatch(Builder.registerBuilderDocument(document2));
|
|
348
|
+
});
|
|
349
|
+
return () => {
|
|
350
|
+
documents.forEach((_document, documentKey) => {
|
|
351
|
+
dispatch(Builder.unregisterBuilderDocument(documentKey));
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function initialize(builderProxy) {
|
|
357
|
+
return (dispatch, getState) => {
|
|
358
|
+
const unregisterBuilderDocuments = dispatch(registerBuilderDocuments());
|
|
359
|
+
const stopMeasuringElements = dispatch(startMeasuringElements());
|
|
360
|
+
const stopMeasuringDocumentElement = dispatch(startMeasuringDocumentElement());
|
|
361
|
+
const stopHandlingFocusEvent = dispatch(startHandlingFocusEvents());
|
|
362
|
+
const unlockDocumentScroll = dispatch(lockDocumentScroll());
|
|
363
|
+
const stopHandlingPointerMoveEvent = dispatch(startHandlingPointerMoveEvent());
|
|
364
|
+
const stopPollingElementFromPoint = dispatch(startPollingElementFromPoint());
|
|
365
|
+
const unregisterBuilderComponents = dispatch(registerBuilderComponents());
|
|
366
|
+
const breakpoints = ReactPage.getBreakpoints(getState());
|
|
367
|
+
dispatch(Shared.setBreakpoints(breakpoints));
|
|
368
|
+
dispatch(Internal.setIsInBuilder(true));
|
|
369
|
+
builderProxy.dispatchBuffered();
|
|
370
|
+
return () => {
|
|
371
|
+
unregisterBuilderDocuments();
|
|
372
|
+
stopMeasuringElements();
|
|
373
|
+
stopMeasuringDocumentElement();
|
|
374
|
+
stopHandlingFocusEvent();
|
|
375
|
+
unlockDocumentScroll();
|
|
376
|
+
stopHandlingPointerMoveEvent();
|
|
377
|
+
stopPollingElementFromPoint();
|
|
378
|
+
unregisterBuilderComponents();
|
|
379
|
+
dispatch(Internal.setIsInBuilder(false));
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function measureBoxModelsMiddleware() {
|
|
384
|
+
return (0, import_toolkit2.actionMiddleware)(({ dispatch }) => (next) => {
|
|
385
|
+
return (action) => {
|
|
386
|
+
switch (action.type) {
|
|
387
|
+
case import_internal.InternalActionTypes.REGISTER_COMPONENT_HANDLE: {
|
|
388
|
+
if (BoxModels.isMeasurable(action.payload.componentHandle)) {
|
|
389
|
+
dispatch(
|
|
390
|
+
Internal.registerMeasurable(
|
|
391
|
+
action.payload.documentKey,
|
|
392
|
+
action.payload.elementKey,
|
|
393
|
+
action.payload.componentHandle
|
|
394
|
+
)
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
case import_internal.InternalActionTypes.UNREGISTER_COMPONENT_HANDLE:
|
|
400
|
+
dispatch(
|
|
401
|
+
Internal.unregisterMeasurable(action.payload.documentKey, action.payload.elementKey)
|
|
402
|
+
);
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
return next(action);
|
|
406
|
+
};
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
function builderAPIMiddleware(builderProxy) {
|
|
410
|
+
return (0, import_toolkit2.actionMiddleware)(({ dispatch }) => (next) => {
|
|
411
|
+
if (typeof window === "undefined")
|
|
412
|
+
return (action) => next(action);
|
|
413
|
+
let cleanUp = () => {
|
|
414
|
+
};
|
|
415
|
+
return (action) => {
|
|
416
|
+
switch (action.type) {
|
|
417
|
+
case import_actions2.BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:
|
|
418
|
+
case import_actions2.BuilderActionTypes.MOUNT_COMPONENT:
|
|
419
|
+
case import_actions2.BuilderActionTypes.UNMOUNT_COMPONENT:
|
|
420
|
+
case import_actions2.BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:
|
|
421
|
+
case import_actions2.BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:
|
|
422
|
+
case import_actions2.BuilderActionTypes.HANDLE_WHEEL:
|
|
423
|
+
case import_actions2.BuilderActionTypes.HANDLE_POINTER_MOVE:
|
|
424
|
+
case import_actions2.BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:
|
|
425
|
+
case import_actions2.BuilderActionTypes.SET_LOCALE:
|
|
426
|
+
case import_actions2.BuilderActionTypes.SET_BREAKPOINTS:
|
|
427
|
+
case import_actions2.BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:
|
|
428
|
+
case import_actions2.BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:
|
|
429
|
+
case import_actions2.BuilderActionTypes.REGISTER_BUILDER_COMPONENT:
|
|
430
|
+
case import_actions2.BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:
|
|
431
|
+
builderProxy.execute(action);
|
|
432
|
+
break;
|
|
433
|
+
case import_host_api.HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:
|
|
434
|
+
window.document.documentElement.scrollTop = action.payload.scrollTop;
|
|
435
|
+
break;
|
|
436
|
+
case import_host_api.HostActionTypes.SCROLL_DOCUMENT_ELEMENT:
|
|
437
|
+
window.document.documentElement.scrollTop += action.payload.scrollTopDelta;
|
|
438
|
+
break;
|
|
439
|
+
case import_host_api.HostActionTypes.SET_BUILDER_EDIT_MODE:
|
|
440
|
+
window.getSelection()?.removeAllRanges();
|
|
441
|
+
break;
|
|
442
|
+
case import_host_api.HostActionTypes.INIT:
|
|
443
|
+
cleanUp = dispatch(initialize(builderProxy));
|
|
444
|
+
break;
|
|
445
|
+
case import_host_api.HostActionTypes.CLEAN_UP:
|
|
446
|
+
cleanUp();
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
return next(action);
|
|
450
|
+
};
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
function createAndRegisterPropControllers(documentKey, elementKey) {
|
|
454
|
+
return (dispatch, getState) => {
|
|
455
|
+
const descriptors = ReactPage.getElementPropControllerDescriptors(
|
|
456
|
+
getState(),
|
|
457
|
+
documentKey,
|
|
458
|
+
elementKey
|
|
459
|
+
);
|
|
460
|
+
if (descriptors == null)
|
|
461
|
+
return null;
|
|
462
|
+
const propControllers = Object.entries(descriptors).reduce(
|
|
463
|
+
(acc, [propName, descriptor]) => {
|
|
464
|
+
const propController = (0, import_instances.createPropController)(
|
|
465
|
+
descriptor,
|
|
466
|
+
(message) => dispatch(
|
|
467
|
+
Builder.messageBuilderPropController(documentKey, elementKey, propName, message)
|
|
468
|
+
)
|
|
469
|
+
);
|
|
470
|
+
return { ...acc, [propName]: propController };
|
|
471
|
+
},
|
|
472
|
+
{}
|
|
473
|
+
);
|
|
474
|
+
dispatch(Internal.registerPropControllers(documentKey, elementKey, propControllers));
|
|
475
|
+
return propControllers;
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function propControllerHandlesMiddleware() {
|
|
479
|
+
return (0, import_toolkit2.actionMiddleware)(({ dispatch, getState }) => (next) => {
|
|
480
|
+
return (action) => {
|
|
481
|
+
switch (action.type) {
|
|
482
|
+
case import_internal.InternalActionTypes.REGISTER_COMPONENT_HANDLE: {
|
|
483
|
+
const { documentKey, elementKey, componentHandle } = action.payload;
|
|
484
|
+
const element = ReactPage.getElement(getState(), documentKey, elementKey);
|
|
485
|
+
const propControllers = dispatch(
|
|
486
|
+
createAndRegisterPropControllers(documentKey, elementKey)
|
|
487
|
+
);
|
|
488
|
+
if (element != null && !ReactPage.isElementReference(element) && PropControllerHandles.isPropControllersHandle(componentHandle)) {
|
|
489
|
+
dispatch(
|
|
490
|
+
Internal.registerPropControllersHandle(documentKey, elementKey, componentHandle)
|
|
491
|
+
);
|
|
492
|
+
componentHandle.setPropControllers(propControllers);
|
|
493
|
+
}
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
case import_internal.InternalActionTypes.UNREGISTER_COMPONENT_HANDLE: {
|
|
497
|
+
const { documentKey, elementKey } = action.payload;
|
|
498
|
+
const handle = PropControllerHandles.getPropControllersHandle(
|
|
499
|
+
getPropControllerHandlesStateSlice(getState()),
|
|
500
|
+
documentKey,
|
|
501
|
+
elementKey
|
|
502
|
+
);
|
|
503
|
+
handle?.setPropControllers(null);
|
|
504
|
+
dispatch(Internal.unregisterPropControllers(documentKey, elementKey));
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
case import_host_api.HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {
|
|
508
|
+
const propController = PropControllerHandles.getPropController(
|
|
509
|
+
getPropControllerHandlesStateSlice(getState()),
|
|
510
|
+
action.payload.documentKey,
|
|
511
|
+
action.payload.elementKey,
|
|
512
|
+
action.payload.propName
|
|
513
|
+
);
|
|
514
|
+
if (propController)
|
|
515
|
+
propController.recv(action.payload.message);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return next(action);
|
|
519
|
+
};
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
function makeswiftApiClientSyncMiddleware(client) {
|
|
523
|
+
return (0, import_toolkit2.actionMiddleware)(() => (next) => {
|
|
524
|
+
return (action) => {
|
|
525
|
+
client.makeswiftApiClient.dispatch(action);
|
|
526
|
+
return next(action);
|
|
527
|
+
};
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function setupBuilderProxy(builderProxy) {
|
|
531
|
+
return (dispatch) => {
|
|
532
|
+
builderProxy.setup({ onHostAction: (action) => dispatch(action) });
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function configureStore({
|
|
536
|
+
preloadedState,
|
|
537
|
+
client,
|
|
538
|
+
builderProxy
|
|
539
|
+
}) {
|
|
540
|
+
const initialState = {
|
|
541
|
+
...preloadedState,
|
|
542
|
+
isPreview: IsPreview.getInitialState(true)
|
|
543
|
+
};
|
|
544
|
+
const store = (0, import_toolkit.configureStore)({
|
|
545
|
+
reducer,
|
|
546
|
+
preloadedState: initialState,
|
|
547
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware(import_toolkit2.middlewareOptions).concat(
|
|
548
|
+
ReactPage.elementTreeMiddleware(),
|
|
549
|
+
measureBoxModelsMiddleware(),
|
|
550
|
+
builderAPIMiddleware(builderProxy),
|
|
551
|
+
propControllerHandlesMiddleware(),
|
|
552
|
+
makeswiftApiClientSyncMiddleware(client)
|
|
553
|
+
),
|
|
554
|
+
enhancers: (getDefaultEnhancers) => getDefaultEnhancers().concat(
|
|
555
|
+
(0, import_setup_teardown.withSetupTeardown)(
|
|
556
|
+
() => {
|
|
557
|
+
const dispatch = store.dispatch;
|
|
558
|
+
dispatch(setupBuilderProxy(builderProxy));
|
|
559
|
+
},
|
|
560
|
+
() => builderProxy.teardown()
|
|
561
|
+
)
|
|
562
|
+
),
|
|
563
|
+
devTools: (0, import_toolkit2.devToolsConfig)({
|
|
564
|
+
name: `Host store (${(/* @__PURE__ */ new Date()).toISOString()})`,
|
|
565
|
+
actionsDenylist: [
|
|
566
|
+
import_host_api.HostActionTypes.BUILDER_POINTER_MOVE,
|
|
567
|
+
import_actions2.BuilderActionTypes.HANDLE_POINTER_MOVE,
|
|
568
|
+
import_actions2.BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE
|
|
569
|
+
]
|
|
570
|
+
})
|
|
571
|
+
});
|
|
572
|
+
return store;
|
|
573
|
+
}
|
|
574
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
575
|
+
0 && (module.exports = {
|
|
576
|
+
builderAPIMiddleware,
|
|
577
|
+
configureStore,
|
|
578
|
+
createBox,
|
|
579
|
+
getBox,
|
|
580
|
+
initialize,
|
|
581
|
+
parse,
|
|
582
|
+
propControllerHandlesMiddleware,
|
|
583
|
+
reducer,
|
|
584
|
+
startMeasuringElements
|
|
585
|
+
});
|
|
586
|
+
//# sourceMappingURL=react-builder-preview.js.map
|