esp-js-react 8.1.1-next.0 → 9.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.dist/esp-react.esm.mjs +710 -0
  2. package/.dist/esp-react.esm.mjs.map +1 -0
  3. package/.dist/esp-react.js +695 -777
  4. package/.dist/esp-react.js.map +1 -1
  5. package/.dist/esp-react.min.js +2 -3
  6. package/.dist/esp-react.min.js.map +1 -1
  7. package/.dist/typings/connectableComponent.d.ts +8 -9
  8. package/.dist/typings/espApp.d.ts +25 -0
  9. package/.dist/typings/espEventBusContextProvider.d.ts +41 -0
  10. package/.dist/typings/espModulesContext.d.ts +3 -0
  11. package/.dist/typings/espStoreContextProvider.d.ts +62 -0
  12. package/.dist/typings/index.d.ts +13 -9
  13. package/.dist/typings/regionView.d.ts +19 -0
  14. package/.dist/typings/useSyncStoreModelWithSelector.d.ts +47 -0
  15. package/README.md +62 -22
  16. package/package.json +63 -45
  17. package/.dist/esp-react.min.js.LICENSE.txt +0 -9
  18. package/.dist/typings/connect.d.ts +0 -8
  19. package/.dist/typings/espModelContextProvider.d.ts +0 -63
  20. package/.dist/typings/espRouterContextProvider.d.ts +0 -54
  21. package/.dist/typings/polimer/polimerModelBuilderExtentsions.d.ts +0 -6
  22. package/.dist/typings/useSyncModelWithSelector.d.ts +0 -52
  23. package/.dist/typings/viewBinder.d.ts +0 -13
  24. package/.dist/typings/viewBindingDecorator.d.ts +0 -34
  25. package/.yarnignore +0 -15
  26. package/docs/images/esp-agile-demo.gif +0 -0
  27. package/jest.config.js +0 -19
  28. package/src/connect.tsx +0 -27
  29. package/src/connectableComponent.tsx +0 -99
  30. package/src/espModelContextProvider.tsx +0 -101
  31. package/src/espRouterContextProvider.tsx +0 -97
  32. package/src/index.ts +0 -68
  33. package/src/polimer/polimerModelBuilderExtentsions.ts +0 -36
  34. package/src/useSyncModelWithSelector.ts +0 -223
  35. package/src/viewBinder.tsx +0 -51
  36. package/src/viewBindingDecorator.ts +0 -113
  37. package/tests/connectableComponentTests.tsx +0 -477
  38. package/tests/espModelContextProviderTests.tsx +0 -150
  39. package/tests/espRouterContextProviderTests.tsx +0 -56
  40. package/tests/indexTests.ts +0 -47
  41. package/tests/testApi/asserts.ts +0 -102
  42. package/tests/testApi/routerSpy.ts +0 -24
  43. package/tests/testApi/testApi.tsx +0 -100
  44. package/tests/testApi/testModel.ts +0 -43
  45. package/tests/testApi/useStoreReceivedProps.ts +0 -14
  46. package/tests/testApi/viewFactory.tsx +0 -31
  47. package/tests/useSyncModelWithSelectorTests.tsx +0 -330
  48. package/tests/viewBinderTests.tsx +0 -61
  49. package/tsconfig.json +0 -14
  50. package/webpack.config.js +0 -27
@@ -1,810 +1,728 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("esp-js"), require("esp-js-polimer"), require("react"));
4
- else if(typeof define === 'function' && define.amd)
5
- define(["esp-js", "esp-js-polimer", "react"], factory);
6
- else if(typeof exports === 'object')
7
- exports["esp-js-react"] = factory(require("esp-js"), require("esp-js-polimer"), require("react"));
8
- else
9
- root["esp-js-react"] = factory(root["esp-js"], root["esp-js-polimer"], root["react"]);
10
- })(self, (__WEBPACK_EXTERNAL_MODULE__152__, __WEBPACK_EXTERNAL_MODULE__43__, __WEBPACK_EXTERNAL_MODULE__155__) => {
11
- return /******/ (() => { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ var __webpack_modules__ = ({
14
-
15
- /***/ 774:
16
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
17
-
18
- /**
19
- * @license React
20
- * use-sync-external-store-with-selector.production.min.js
21
- *
22
- * Copyright (c) Facebook, Inc. and its affiliates.
23
- *
24
- * This source code is licensed under the MIT license found in the
25
- * LICENSE file in the root directory of this source tree.
26
- */
27
- var g=__webpack_require__(155);function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p="function"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;
28
- exports.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,h]);var d=q(a,c[0],c[1]);
29
- t(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};
30
-
31
-
32
- /***/ }),
33
-
34
- /***/ 614:
35
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
36
-
37
-
38
-
39
- if (true) {
40
- module.exports = __webpack_require__(774);
41
- } else {}
42
-
43
-
44
- /***/ }),
45
-
46
- /***/ 746:
47
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
48
-
49
-
50
- var __rest = (this && this.__rest) || function (s, e) {
51
- var t = {};
52
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
- t[p] = s[p];
54
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
- t[p[i]] = s[p[i]];
1
+ (function(global, factory) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("esp-js")) : typeof define === "function" && define.amd ? define(["exports", "react", "esp-js"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.espReact = {}, global.React, global.espJs));
3
+ })(this, function(exports2, require$$0, espJs) {
4
+ "use strict";
5
+ function _interopNamespaceDefault(e) {
6
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
+ if (e) {
8
+ for (const k in e) {
9
+ if (k !== "default") {
10
+ const d = Object.getOwnPropertyDescriptor(e, k);
11
+ Object.defineProperty(n, k, d.get ? d : {
12
+ enumerable: true,
13
+ get: () => e[k]
14
+ });
58
15
  }
59
- return t;
60
- };
61
- Object.defineProperty(exports, "__esModule", ({ value: true }));
62
- exports.connect = void 0;
63
- const React = __webpack_require__(155);
64
- const connectableComponent_1 = __webpack_require__(397);
65
- /**
66
- * @param mapModelToProps - maps the model to a different structure, that structure is sent as props to the view.
67
- * @param createPublishEventProps - creates functions to publish events, the structure is sent as props to the view.
68
- */
69
- const connect = function (mapModelToProps, createPublishEventProps) {
70
- return function (view) {
71
- return function (props) {
72
- const { modelId, viewContext } = props, rest = __rest(props, ["modelId", "viewContext"]);
73
- return React.createElement(connectableComponent_1.ConnectableComponent, Object.assign({ modelId: modelId, view: view, viewContext: viewContext, createPublishEventProps: createPublishEventProps, mapModelToProps: mapModelToProps }, rest));
74
- };
75
- };
76
- };
77
- exports.connect = connect;
78
-
79
-
80
- /***/ }),
81
-
82
- /***/ 397:
83
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
84
-
85
-
86
- var __rest = (this && this.__rest) || function (s, e) {
87
- var t = {};
88
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
89
- t[p] = s[p];
90
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
91
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
92
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
93
- t[p[i]] = s[p[i]];
94
- }
95
- return t;
96
- };
97
- Object.defineProperty(exports, "__esModule", ({ value: true }));
98
- exports.ConnectableComponent = void 0;
99
- const React = __webpack_require__(155);
100
- const espRouterContextProvider_1 = __webpack_require__(169);
101
- const react_1 = __webpack_require__(155);
102
- const espModelContextProvider_1 = __webpack_require__(963);
103
- const viewBindingDecorator_1 = __webpack_require__(213);
104
- const useSyncModelWithSelector_1 = __webpack_require__(606);
105
- const esp_js_polimer_1 = __webpack_require__(43);
106
- const getChildProps = (router, modelId, restProps, initialModel, mapModelToProps, publishEventProps) => {
107
- const model = esp_js_polimer_1.PolimerModel.isPolimerModel(initialModel)
108
- ? initialModel.getEspPolimerImmutableModel()
109
- : initialModel;
110
- let childProps = Object.assign(Object.assign(Object.assign({ modelId, router: router }, restProps), publishEventProps), { model });
111
- if (mapModelToProps) {
112
- childProps = Object.assign(Object.assign({}, childProps), mapModelToProps(model, publishEventProps));
16
+ }
113
17
  }
114
- return childProps;
115
- };
116
- const ConnectableComponent = (_a) => {
117
- var { modelId, mapModelToProps, createPublishEventProps, view, viewContext } = _a, rest = __rest(_a, ["modelId", "mapModelToProps", "createPublishEventProps", "view", "viewContext"]);
118
- const router = (0, espRouterContextProvider_1.useRouter)();
119
- // Note: we always need to render the hooks else react will complain about a different count.
120
- let modelIdFromContext = (0, espModelContextProvider_1.useGetModelId)();
121
- modelId = modelId || modelIdFromContext;
122
- const publishEventProps = (0, react_1.useMemo)(() => {
123
- if (createPublishEventProps) {
124
- const publishModelEvent = (eventType, event) => {
125
- router.publishEvent(modelId, eventType, event);
126
- };
127
- return createPublishEventProps(publishModelEvent);
18
+ n.default = e;
19
+ return Object.freeze(n);
20
+ }
21
+ const require$$0__namespace = /* @__PURE__ */ _interopNamespaceDefault(require$$0);
22
+ var jsxRuntime = { exports: {} };
23
+ var reactJsxRuntime_production = {};
24
+ /**
25
+ * @license React
26
+ * react-jsx-runtime.production.js
27
+ *
28
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ */
33
+ var hasRequiredReactJsxRuntime_production;
34
+ function requireReactJsxRuntime_production() {
35
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
36
+ hasRequiredReactJsxRuntime_production = 1;
37
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
38
+ function jsxProd(type, config, maybeKey) {
39
+ var key = null;
40
+ void 0 !== maybeKey && (key = "" + maybeKey);
41
+ void 0 !== config.key && (key = "" + config.key);
42
+ if ("key" in config) {
43
+ maybeKey = {};
44
+ for (var propName in config)
45
+ "key" !== propName && (maybeKey[propName] = config[propName]);
46
+ } else maybeKey = config;
47
+ config = maybeKey.ref;
48
+ return {
49
+ $$typeof: REACT_ELEMENT_TYPE,
50
+ type,
51
+ key,
52
+ ref: void 0 !== config ? config : null,
53
+ props: maybeKey
54
+ };
55
+ }
56
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
57
+ reactJsxRuntime_production.jsx = jsxProd;
58
+ reactJsxRuntime_production.jsxs = jsxProd;
59
+ return reactJsxRuntime_production;
60
+ }
61
+ var reactJsxRuntime_development = {};
62
+ /**
63
+ * @license React
64
+ * react-jsx-runtime.development.js
65
+ *
66
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
67
+ *
68
+ * This source code is licensed under the MIT license found in the
69
+ * LICENSE file in the root directory of this source tree.
70
+ */
71
+ var hasRequiredReactJsxRuntime_development;
72
+ function requireReactJsxRuntime_development() {
73
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
74
+ hasRequiredReactJsxRuntime_development = 1;
75
+ "production" !== "development" && function() {
76
+ function getComponentNameFromType(type) {
77
+ if (null == type) return null;
78
+ if ("function" === typeof type)
79
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
80
+ if ("string" === typeof type) return type;
81
+ switch (type) {
82
+ case REACT_FRAGMENT_TYPE:
83
+ return "Fragment";
84
+ case REACT_PROFILER_TYPE:
85
+ return "Profiler";
86
+ case REACT_STRICT_MODE_TYPE:
87
+ return "StrictMode";
88
+ case REACT_SUSPENSE_TYPE:
89
+ return "Suspense";
90
+ case REACT_SUSPENSE_LIST_TYPE:
91
+ return "SuspenseList";
92
+ case REACT_ACTIVITY_TYPE:
93
+ return "Activity";
128
94
  }
129
- return {};
130
- }, [router, modelId]);
131
- const model = (0, useSyncModelWithSelector_1.useSyncModelWithSelector)(m => m, (0, useSyncModelWithSelector_1.syncModelWithSelectorOptions)()
132
- .setModelId(modelId)
133
- .setTryPreSelectPolimerImmutableModel(false));
134
- if (model == null) {
95
+ if ("object" === typeof type)
96
+ switch ("number" === typeof type.tag && console.error(
97
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
98
+ ), type.$$typeof) {
99
+ case REACT_PORTAL_TYPE:
100
+ return "Portal";
101
+ case REACT_CONTEXT_TYPE:
102
+ return type.displayName || "Context";
103
+ case REACT_CONSUMER_TYPE:
104
+ return (type._context.displayName || "Context") + ".Consumer";
105
+ case REACT_FORWARD_REF_TYPE:
106
+ var innerType = type.render;
107
+ type = type.displayName;
108
+ type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
109
+ return type;
110
+ case REACT_MEMO_TYPE:
111
+ return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
112
+ case REACT_LAZY_TYPE:
113
+ innerType = type._payload;
114
+ type = type._init;
115
+ try {
116
+ return getComponentNameFromType(type(innerType));
117
+ } catch (x) {
118
+ }
119
+ }
135
120
  return null;
136
- }
137
- let childProps = getChildProps(router, modelId, rest, model, mapModelToProps, publishEventProps);
138
- let viewElement = (0, viewBindingDecorator_1.createViewForModel)(model, childProps, viewContext, view);
139
- return (React.createElement(espModelContextProvider_1.EspModelContextProvider, Object.assign({ modelId: modelId, model: model, router: router }, childProps), viewElement));
140
- };
141
- exports.ConnectableComponent = ConnectableComponent;
142
-
143
-
144
- /***/ }),
145
-
146
- /***/ 963:
147
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
148
-
149
-
150
- Object.defineProperty(exports, "__esModule", ({ value: true }));
151
- exports.EspModelContextProvider = exports.usePublishModelEventWithEntityKey = exports.PublishModelEventWithEntityKeyContext = exports.usePublishModelEvent = exports.PublishModelEventContext = exports.useGetModel = exports.GetModelContext = exports.useGetModelId = exports.GetModelIdContext = void 0;
152
- const React = __webpack_require__(155);
153
- const esp_js_1 = __webpack_require__(152);
154
- const react_1 = __webpack_require__(155);
155
- const espRouterContextProvider_1 = __webpack_require__(169);
156
- exports.GetModelIdContext = (0, react_1.createContext)(null);
157
- /**
158
- * Returns a function to get the ID of the model connected at a higher point in the V-DOM.
159
- *
160
- * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
161
- */
162
- const useGetModelId = () => (0, react_1.useContext)(exports.GetModelIdContext);
163
- exports.useGetModelId = useGetModelId;
164
- exports.GetModelContext = (0, react_1.createContext)(null);
165
- /**
166
- * Returns a function which will return the model connected at a higher point in the V-DOM.
167
- *
168
- * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
169
- */
170
- const useGetModel = () => (0, react_1.useContext)(exports.GetModelContext);
171
- exports.useGetModel = useGetModel;
172
- const createPublishModelEvent = (router, modelId) => {
173
- function publishModelEvent(...args) {
174
- if (args.length === 1) {
175
- router.publishEvent(modelId, args[0].eventType, args[0].event);
121
+ }
122
+ function testStringCoercion(value) {
123
+ return "" + value;
124
+ }
125
+ function checkKeyStringCoercion(value) {
126
+ try {
127
+ testStringCoercion(value);
128
+ var JSCompiler_inline_result = false;
129
+ } catch (e) {
130
+ JSCompiler_inline_result = true;
176
131
  }
177
- else {
178
- router.publishEvent(modelId, args[0], args[1]);
132
+ if (JSCompiler_inline_result) {
133
+ JSCompiler_inline_result = console;
134
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
135
+ var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
136
+ JSCompiler_temp_const.call(
137
+ JSCompiler_inline_result,
138
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
139
+ JSCompiler_inline_result$jscomp$0
140
+ );
141
+ return testStringCoercion(value);
179
142
  }
180
- }
181
- return publishModelEvent;
182
- };
183
- exports.PublishModelEventContext = (0, react_1.createContext)(null);
184
- /**
185
- * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM.
186
- *
187
- * Effectively, this is a version of usePublishEvent() which closes over the relevant modelId.
188
- *
189
- * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
190
- */
191
- const usePublishModelEvent = () => (0, react_1.useContext)(exports.PublishModelEventContext);
192
- exports.usePublishModelEvent = usePublishModelEvent;
193
- const createPublishModelEventWithEntityKey = (router, modelId) => {
194
- function publishModelEventWithEntityKey(...args) {
195
- if (args.length === 1) {
196
- router.publishEvent(new esp_js_1.DefaultModelAddress(modelId, args[0].entityKey), args[0].eventType, args[0].event);
143
+ }
144
+ function getTaskName(type) {
145
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
146
+ if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
147
+ return "<...>";
148
+ try {
149
+ var name = getComponentNameFromType(type);
150
+ return name ? "<" + name + ">" : "<...>";
151
+ } catch (x) {
152
+ return "<...>";
197
153
  }
198
- else {
199
- router.publishEvent(new esp_js_1.DefaultModelAddress(modelId, args[0]), args[1], args[2]);
154
+ }
155
+ function getOwner() {
156
+ var dispatcher = ReactSharedInternals.A;
157
+ return null === dispatcher ? null : dispatcher.getOwner();
158
+ }
159
+ function UnknownOwner() {
160
+ return Error("react-stack-top-frame");
161
+ }
162
+ function hasValidKey(config) {
163
+ if (hasOwnProperty.call(config, "key")) {
164
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
165
+ if (getter && getter.isReactWarning) return false;
200
166
  }
201
- }
202
- return publishModelEventWithEntityKey;
203
- };
204
- exports.PublishModelEventWithEntityKeyContext = (0, react_1.createContext)(null);
205
- /**
206
- * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM, allows an entityKey to be specified.
207
- *
208
- * Effectively, this is a version of usePublishEvent() which closes over the modelId.
209
- *
210
- * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
211
- */
212
- const usePublishModelEventWithEntityKey = () => (0, react_1.useContext)(exports.PublishModelEventWithEntityKeyContext);
213
- exports.usePublishModelEventWithEntityKey = usePublishModelEventWithEntityKey;
214
- /**
215
- * Sets up various ESP context so ESP hooks are available below this point in the V-DOM
216
- *
217
- * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node.
218
- * @param modelId
219
- * @param children
220
- * @param model
221
- * @constructor
222
- */
223
- const EspModelContextProvider = ({ modelId, children, model }) => {
224
- const router = (0, espRouterContextProvider_1.useRouter)();
225
- // modelId may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
226
- let modelIdFromContext = (0, exports.useGetModelId)();
227
- modelId = modelId || modelIdFromContext;
228
- const publishModelEvent = (0, react_1.useCallback)(createPublishModelEvent(router, modelId), [router, modelId]);
229
- const publishModelEventWithEntityKey = (0, react_1.useCallback)(createPublishModelEventWithEntityKey(router, modelId), [router, modelId]);
230
- return (React.createElement(exports.GetModelIdContext.Provider, { value: modelId },
231
- React.createElement(exports.PublishModelEventContext.Provider, { value: publishModelEvent },
232
- React.createElement(exports.PublishModelEventWithEntityKeyContext.Provider, { value: publishModelEventWithEntityKey },
233
- React.createElement(exports.GetModelContext.Provider, { value: model }, children)))));
234
- };
235
- exports.EspModelContextProvider = EspModelContextProvider;
236
-
237
-
238
- /***/ }),
239
-
240
- /***/ 169:
241
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
242
-
243
-
244
- // notice_start
245
- /*
246
- * Copyright 2015 Dev Shop Limited
247
- *
248
- * Licensed under the Apache License, Version 2.0 (the "License");
249
- * you may not use this file except in compliance with the License.
250
- * You may obtain a copy of the License at
251
- *
252
- * http://www.apache.org/licenses/LICENSE-2.0
253
- *
254
- * Unless required by applicable law or agreed to in writing, software
255
- * distributed under the License is distributed on an "AS IS" BASIS,
256
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
257
- * See the License for the specific language governing permissions and
258
- * limitations under the License.
259
- */
260
- // notice_end
261
- Object.defineProperty(exports, "__esModule", ({ value: true }));
262
- exports.RouterProvider = exports.EspRouterContextProvider = exports.usePublishEvent = exports.PublishEventContext = exports.useRouter = exports.RouterContext = void 0;
263
- const React = __webpack_require__(155);
264
- const react_1 = __webpack_require__(155);
265
- exports.RouterContext = (0, react_1.createContext)(null);
266
- /**
267
- * Get the esp Router from context.
268
- *
269
- * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node:
270
- *
271
- * <EspRouterContextProvider router={router}>
272
- * <YourComponents />
273
- * </EspRouterContextProvider>
274
- */
275
- const useRouter = () => {
276
- return (0, react_1.useContext)(exports.RouterContext);
277
- };
278
- exports.useRouter = useRouter;
279
- const createPublishEvent = (router) => {
280
- function publishEvent(...args) {
281
- if (args.length === 1) {
282
- router.publishEvent(args[0].address, args[0].eventType, args[0].event);
167
+ return void 0 !== config.key;
168
+ }
169
+ function defineKeyPropWarningGetter(props, displayName) {
170
+ function warnAboutAccessingKey() {
171
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
172
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
173
+ displayName
174
+ ));
175
+ }
176
+ warnAboutAccessingKey.isReactWarning = true;
177
+ Object.defineProperty(props, "key", {
178
+ get: warnAboutAccessingKey,
179
+ configurable: true
180
+ });
181
+ }
182
+ function elementRefGetterWithDeprecationWarning() {
183
+ var componentName = getComponentNameFromType(this.type);
184
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
185
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
186
+ ));
187
+ componentName = this.props.ref;
188
+ return void 0 !== componentName ? componentName : null;
189
+ }
190
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
191
+ var refProp = props.ref;
192
+ type = {
193
+ $$typeof: REACT_ELEMENT_TYPE,
194
+ type,
195
+ key,
196
+ props,
197
+ _owner: owner
198
+ };
199
+ null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
200
+ enumerable: false,
201
+ get: elementRefGetterWithDeprecationWarning
202
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
203
+ type._store = {};
204
+ Object.defineProperty(type._store, "validated", {
205
+ configurable: false,
206
+ enumerable: false,
207
+ writable: true,
208
+ value: 0
209
+ });
210
+ Object.defineProperty(type, "_debugInfo", {
211
+ configurable: false,
212
+ enumerable: false,
213
+ writable: true,
214
+ value: null
215
+ });
216
+ Object.defineProperty(type, "_debugStack", {
217
+ configurable: false,
218
+ enumerable: false,
219
+ writable: true,
220
+ value: debugStack
221
+ });
222
+ Object.defineProperty(type, "_debugTask", {
223
+ configurable: false,
224
+ enumerable: false,
225
+ writable: true,
226
+ value: debugTask
227
+ });
228
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
229
+ return type;
230
+ }
231
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
232
+ var children = config.children;
233
+ if (void 0 !== children)
234
+ if (isStaticChildren)
235
+ if (isArrayImpl(children)) {
236
+ for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
237
+ validateChildKeys(children[isStaticChildren]);
238
+ Object.freeze && Object.freeze(children);
239
+ } else
240
+ console.error(
241
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
242
+ );
243
+ else validateChildKeys(children);
244
+ if (hasOwnProperty.call(config, "key")) {
245
+ children = getComponentNameFromType(type);
246
+ var keys = Object.keys(config).filter(function(k) {
247
+ return "key" !== k;
248
+ });
249
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
250
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
251
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
252
+ isStaticChildren,
253
+ children,
254
+ keys,
255
+ children
256
+ ), didWarnAboutKeySpread[children + isStaticChildren] = true);
283
257
  }
284
- else {
285
- router.publishEvent(args[0], args[1], args[2]);
258
+ children = null;
259
+ void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
260
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
261
+ if ("key" in config) {
262
+ maybeKey = {};
263
+ for (var propName in config)
264
+ "key" !== propName && (maybeKey[propName] = config[propName]);
265
+ } else maybeKey = config;
266
+ children && defineKeyPropWarningGetter(
267
+ maybeKey,
268
+ "function" === typeof type ? type.displayName || type.name || "Unknown" : type
269
+ );
270
+ return ReactElement(
271
+ type,
272
+ children,
273
+ maybeKey,
274
+ getOwner(),
275
+ debugStack,
276
+ debugTask
277
+ );
278
+ }
279
+ function validateChildKeys(node) {
280
+ isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
281
+ }
282
+ function isValidElement(object) {
283
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
284
+ }
285
+ var React = require$$0, REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
286
+ return null;
287
+ };
288
+ React = {
289
+ react_stack_bottom_frame: function(callStackForError) {
290
+ return callStackForError();
286
291
  }
292
+ };
293
+ var specialPropKeyWarningShown;
294
+ var didWarnAboutElementRef = {};
295
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
296
+ React,
297
+ UnknownOwner
298
+ )();
299
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
300
+ var didWarnAboutKeySpread = {};
301
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
302
+ reactJsxRuntime_development.jsx = function(type, config, maybeKey) {
303
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
304
+ return jsxDEVImpl(
305
+ type,
306
+ config,
307
+ maybeKey,
308
+ false,
309
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
310
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
311
+ );
312
+ };
313
+ reactJsxRuntime_development.jsxs = function(type, config, maybeKey) {
314
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
315
+ return jsxDEVImpl(
316
+ type,
317
+ config,
318
+ maybeKey,
319
+ true,
320
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
321
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
322
+ );
323
+ };
324
+ }();
325
+ return reactJsxRuntime_development;
326
+ }
327
+ if ("development" === "production") {
328
+ jsxRuntime.exports = requireReactJsxRuntime_production();
329
+ } else {
330
+ jsxRuntime.exports = requireReactJsxRuntime_development();
331
+ }
332
+ var jsxRuntimeExports = jsxRuntime.exports;
333
+ const EventBusContext = require$$0.createContext(null);
334
+ const useEventBus = () => {
335
+ return require$$0.useContext(EventBusContext);
336
+ };
337
+ const createPublishEvent = (bus) => {
338
+ function publishEvent(...args) {
339
+ if (args.length === 1) {
340
+ bus.publishEvent(args[0].address, args[0].eventType, args[0].event);
341
+ } else {
342
+ bus.publishEvent(args[0], args[1], args[2]);
343
+ }
287
344
  }
288
345
  return publishEvent;
289
- };
290
- exports.PublishEventContext = (0, react_1.createContext)(null);
291
- /**
292
- * Returns a function which can be used to publish an event.
293
- *
294
- * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node:
295
- *
296
- * <EspRouterContextProvider router={router}>
297
- * <YourComponents />
298
- * </EspRouterContextProvider>
299
- */
300
- const usePublishEvent = () => (0, react_1.useContext)(exports.PublishEventContext);
301
- exports.usePublishEvent = usePublishEvent;
302
- /**
303
- * Used to set the router on the RouterContext making it available to components down the tree via the useRouter() hook.
304
- *
305
- * Also sets up the usePublishEvent() hook so nested components can publish to the router.
306
- */
307
- const EspRouterContextProvider = ({ children, router }) => {
308
- // Router may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
309
- let routerFromContext = (0, exports.useRouter)();
310
- router = router || routerFromContext;
311
- const publishEvent = (0, react_1.useCallback)(createPublishEvent(router), [router]);
312
- return (React.createElement(exports.RouterContext.Provider, { value: router },
313
- React.createElement(exports.PublishEventContext.Provider, { value: publishEvent }, children)));
314
- };
315
- exports.EspRouterContextProvider = EspRouterContextProvider;
316
- /**
317
- * Used to set the router on the RouterContext making it available to components down the tree (via useRouter()).
318
- *
319
- * @deprecated use EspRouterContextProvider
320
- */
321
- exports.RouterProvider = exports.EspRouterContextProvider;
322
-
323
-
324
- /***/ }),
325
-
326
- /***/ 185:
327
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
328
-
329
-
330
- Object.defineProperty(exports, "__esModule", ({ value: true }));
331
- const esp_js_polimer_1 = __webpack_require__(43);
332
- const viewBindingDecorator_1 = __webpack_require__(213);
333
- esp_js_polimer_1.PolimerModelBuilder.prototype.withViewBindings = function (view, displayContext = viewBindingDecorator_1.DEFAULT_VIEW_KEY) {
334
- let builder = this;
335
- // store some metadata on the builder which we'll use later to tack onto the model
336
- let viewMappings = builder._viewMappings || {};
337
- viewMappings[displayContext] = view;
338
- builder._viewMappings = viewMappings;
339
- return this;
340
- };
341
- // we need to replace the registerWithRouter in order to dynamically add the
342
- // @viewBinding decorator to it
343
- let registerWithRouter = esp_js_polimer_1.PolimerModelBuilder.prototype.registerWithRouter;
344
- esp_js_polimer_1.PolimerModelBuilder.prototype.registerWithRouter = function () {
345
- let builder = this;
346
- let model = registerWithRouter.call(builder);
347
- let viewMappings = builder._viewMappings;
348
- if (viewMappings) {
349
- Object.keys(viewMappings).forEach(displayContext => {
350
- (0, viewBindingDecorator_1.viewBinding)(viewMappings[displayContext], displayContext)(model.constructor);
351
- });
346
+ };
347
+ const PublishEventContext = require$$0.createContext(null);
348
+ const usePublishEvent = () => require$$0.useContext(PublishEventContext);
349
+ const EspEventBusContextProvider = ({ children, bus }) => {
350
+ let busFromContext = useEventBus();
351
+ bus = bus || busFromContext;
352
+ const publishEvent = require$$0.useCallback(createPublishEvent(bus), [bus]);
353
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(EventBusContext.Provider, { value: bus, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishEventContext.Provider, { value: publishEvent, children }) });
354
+ };
355
+ const GetStoreIdContext = require$$0.createContext(null);
356
+ const useGetStoreId = () => require$$0.useContext(GetStoreIdContext);
357
+ const GetStoreModelContext = require$$0.createContext(null);
358
+ const useGetStoreModel = () => require$$0.useContext(GetStoreModelContext);
359
+ const createPublishStoreEvent = (bus, storeId) => {
360
+ function publishStoreEvent(...args) {
361
+ if (args.length === 1) {
362
+ bus.publishEvent(storeId, args[0].eventType, args[0].event);
363
+ } else {
364
+ bus.publishEvent(storeId, args[0], args[1]);
365
+ }
352
366
  }
353
- return model;
354
- };
355
-
356
-
357
- /***/ }),
358
-
359
- /***/ 606:
360
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
361
-
362
-
363
- Object.defineProperty(exports, "__esModule", ({ value: true }));
364
- exports.useSyncModelWithSelector = exports.syncModelWithSelectorOptions = exports.logger = void 0;
365
- const react_1 = __webpack_require__(155);
366
- const with_selector_1 = __webpack_require__(614);
367
- const esp_js_1 = __webpack_require__(152);
368
- const espRouterContextProvider_1 = __webpack_require__(169);
369
- const espModelContextProvider_1 = __webpack_require__(963);
370
- const esp_js_polimer_1 = __webpack_require__(43);
371
- exports.logger = esp_js_1.Logger.create('useSyncModelWithSelector');
372
- /**
373
- * Convenience API to create SyncModelWithSelectorOptions
374
- */
375
- const syncModelWithSelectorOptions = () => {
376
- let modelId = undefined;
377
- let equalityFn = (a, b) => a === b;
378
- let tryPreSelectPolimerImmutableModel = true;
379
- return {
380
- get modelId() {
381
- return modelId;
382
- },
383
- setModelId(value) {
384
- modelId = value;
385
- return this;
386
- },
387
- get equalityFn() {
388
- return equalityFn;
389
- },
390
- setEqualityFn(value) {
391
- equalityFn = value;
392
- return this;
367
+ return publishStoreEvent;
368
+ };
369
+ const PublishStoreEventContext = require$$0.createContext(null);
370
+ const usePublishStoreEvent = () => require$$0.useContext(PublishStoreEventContext);
371
+ const createPublishStoreEventWithEntityKey = (bus, storeId) => {
372
+ function publishStoreEventWithEntityKey(...args) {
373
+ if (args.length === 1) {
374
+ bus.publishEvent(new espJs.DefaultStoreAddress(storeId, args[0].entityKey), args[0].eventType, args[0].event);
375
+ } else {
376
+ bus.publishEvent(new espJs.DefaultStoreAddress(storeId, args[0]), args[1], args[2]);
377
+ }
378
+ }
379
+ return publishStoreEventWithEntityKey;
380
+ };
381
+ const PublishStoreEventWithEntityKeyContext = require$$0.createContext(null);
382
+ const usePublishStoreEventWithEntityKey = () => require$$0.useContext(PublishStoreEventWithEntityKeyContext);
383
+ const EspStoreContextProvider = ({ storeId, children, model }) => {
384
+ const bus = useEventBus();
385
+ let storeIdFromContext = useGetStoreId();
386
+ storeId = storeId || storeIdFromContext;
387
+ const publishStoreEvent = require$$0.useCallback(createPublishStoreEvent(bus, storeId), [bus, storeId]);
388
+ const publishStoreEventWithEntityKey = require$$0.useCallback(createPublishStoreEventWithEntityKey(bus, storeId), [bus, storeId]);
389
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreIdContext.Provider, { value: storeId, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventContext.Provider, { value: publishStoreEvent, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventWithEntityKeyContext.Provider, { value: publishStoreEventWithEntityKey, children: /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreModelContext.Provider, { value: model, children }) }) }) });
390
+ };
391
+ var withSelector = { exports: {} };
392
+ var useSyncExternalStoreWithSelector_production = {};
393
+ /**
394
+ * @license React
395
+ * use-sync-external-store-with-selector.production.js
396
+ *
397
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
398
+ *
399
+ * This source code is licensed under the MIT license found in the
400
+ * LICENSE file in the root directory of this source tree.
401
+ */
402
+ var hasRequiredUseSyncExternalStoreWithSelector_production;
403
+ function requireUseSyncExternalStoreWithSelector_production() {
404
+ if (hasRequiredUseSyncExternalStoreWithSelector_production) return useSyncExternalStoreWithSelector_production;
405
+ hasRequiredUseSyncExternalStoreWithSelector_production = 1;
406
+ var React = require$$0;
407
+ function is(x, y) {
408
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
409
+ }
410
+ var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React.useSyncExternalStore, useRef = React.useRef, useEffect = React.useEffect, useMemo = React.useMemo, useDebugValue = React.useDebugValue;
411
+ useSyncExternalStoreWithSelector_production.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
412
+ var instRef = useRef(null);
413
+ if (null === instRef.current) {
414
+ var inst = { hasValue: false, value: null };
415
+ instRef.current = inst;
416
+ } else inst = instRef.current;
417
+ instRef = useMemo(
418
+ function() {
419
+ function memoizedSelector(nextSnapshot) {
420
+ if (!hasMemo) {
421
+ hasMemo = true;
422
+ memoizedSnapshot = nextSnapshot;
423
+ nextSnapshot = selector(nextSnapshot);
424
+ if (void 0 !== isEqual && inst.hasValue) {
425
+ var currentSelection = inst.value;
426
+ if (isEqual(currentSelection, nextSnapshot))
427
+ return memoizedSelection = currentSelection;
428
+ }
429
+ return memoizedSelection = nextSnapshot;
430
+ }
431
+ currentSelection = memoizedSelection;
432
+ if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
433
+ var nextSelection = selector(nextSnapshot);
434
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
435
+ return memoizedSnapshot = nextSnapshot, currentSelection;
436
+ memoizedSnapshot = nextSnapshot;
437
+ return memoizedSelection = nextSelection;
438
+ }
439
+ var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
440
+ return [
441
+ function() {
442
+ return memoizedSelector(getSnapshot());
443
+ },
444
+ null === maybeGetServerSnapshot ? void 0 : function() {
445
+ return memoizedSelector(maybeGetServerSnapshot());
446
+ }
447
+ ];
393
448
  },
394
- get tryPreSelectPolimerImmutableModel() {
395
- return tryPreSelectPolimerImmutableModel;
449
+ [getSnapshot, getServerSnapshot, selector, isEqual]
450
+ );
451
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
452
+ useEffect(
453
+ function() {
454
+ inst.hasValue = true;
455
+ inst.value = value;
396
456
  },
397
- setTryPreSelectPolimerImmutableModel(value) {
398
- tryPreSelectPolimerImmutableModel = value;
399
- return this;
400
- }
457
+ [value]
458
+ );
459
+ useDebugValue(value);
460
+ return value;
401
461
  };
402
- };
403
- exports.syncModelWithSelectorOptions = syncModelWithSelectorOptions;
404
- const checkArguments = (selector, options) => {
405
- if (!esp_js_1.utils.isFunction(selector)) {
406
- throw new Error('You must pass a selector function to useSyncModelWithSelector');
462
+ return useSyncExternalStoreWithSelector_production;
463
+ }
464
+ var useSyncExternalStoreWithSelector_development = {};
465
+ /**
466
+ * @license React
467
+ * use-sync-external-store-with-selector.development.js
468
+ *
469
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
470
+ *
471
+ * This source code is licensed under the MIT license found in the
472
+ * LICENSE file in the root directory of this source tree.
473
+ */
474
+ var hasRequiredUseSyncExternalStoreWithSelector_development;
475
+ function requireUseSyncExternalStoreWithSelector_development() {
476
+ if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
477
+ hasRequiredUseSyncExternalStoreWithSelector_development = 1;
478
+ "production" !== "development" && function() {
479
+ function is(x, y) {
480
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
481
+ }
482
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
483
+ var React = require$$0, objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React.useSyncExternalStore, useRef = React.useRef, useEffect = React.useEffect, useMemo = React.useMemo, useDebugValue = React.useDebugValue;
484
+ useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
485
+ var instRef = useRef(null);
486
+ if (null === instRef.current) {
487
+ var inst = { hasValue: false, value: null };
488
+ instRef.current = inst;
489
+ } else inst = instRef.current;
490
+ instRef = useMemo(
491
+ function() {
492
+ function memoizedSelector(nextSnapshot) {
493
+ if (!hasMemo) {
494
+ hasMemo = true;
495
+ memoizedSnapshot = nextSnapshot;
496
+ nextSnapshot = selector(nextSnapshot);
497
+ if (void 0 !== isEqual && inst.hasValue) {
498
+ var currentSelection = inst.value;
499
+ if (isEqual(currentSelection, nextSnapshot))
500
+ return memoizedSelection = currentSelection;
501
+ }
502
+ return memoizedSelection = nextSnapshot;
503
+ }
504
+ currentSelection = memoizedSelection;
505
+ if (objectIs(memoizedSnapshot, nextSnapshot))
506
+ return currentSelection;
507
+ var nextSelection = selector(nextSnapshot);
508
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
509
+ return memoizedSnapshot = nextSnapshot, currentSelection;
510
+ memoizedSnapshot = nextSnapshot;
511
+ return memoizedSelection = nextSelection;
512
+ }
513
+ var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
514
+ return [
515
+ function() {
516
+ return memoizedSelector(getSnapshot());
517
+ },
518
+ null === maybeGetServerSnapshot ? void 0 : function() {
519
+ return memoizedSelector(maybeGetServerSnapshot());
520
+ }
521
+ ];
522
+ },
523
+ [getSnapshot, getServerSnapshot, selector, isEqual]
524
+ );
525
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
526
+ useEffect(
527
+ function() {
528
+ inst.hasValue = true;
529
+ inst.value = value;
530
+ },
531
+ [value]
532
+ );
533
+ useDebugValue(value);
534
+ return value;
535
+ };
536
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
537
+ }();
538
+ return useSyncExternalStoreWithSelector_development;
539
+ }
540
+ if ("development" === "production") {
541
+ withSelector.exports = requireUseSyncExternalStoreWithSelector_production();
542
+ } else {
543
+ withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
544
+ }
545
+ var withSelectorExports = withSelector.exports;
546
+ espJs.Logger.create("useSyncStoreModelWithSelector");
547
+ const syncStoreModelWithSelectorOptions = () => {
548
+ let storeId = void 0;
549
+ let equalityFn = (a, b) => a === b;
550
+ return {
551
+ get storeId() {
552
+ return storeId;
553
+ },
554
+ setStoreId(value) {
555
+ storeId = value;
556
+ return this;
557
+ },
558
+ get equalityFn() {
559
+ return equalityFn;
560
+ },
561
+ setEqualityFn(value) {
562
+ equalityFn = value;
563
+ return this;
564
+ }
565
+ };
566
+ };
567
+ const checkArguments = (selector, options) => {
568
+ if (!espJs.utils.isFunction(selector)) {
569
+ throw new Error("You must pass a selector function to useSyncStoreModelWithSelector");
407
570
  }
408
- if (!esp_js_1.utils.isObject(options)) {
409
- throw new Error('You must provide options when using useSyncModelWithSelector');
571
+ if (!espJs.utils.isObject(options)) {
572
+ throw new Error("You must provide options when using useSyncStoreModelWithSelector");
410
573
  }
411
- if (!esp_js_1.utils.isFunction(options.equalityFn)) {
412
- throw new Error('You must provide an equalityFn when using useSyncModelWithSelector');
574
+ if (!espJs.utils.isFunction(options.equalityFn)) {
575
+ throw new Error("You must provide an equalityFn when using useSyncStoreModelWithSelector");
413
576
  }
414
- };
415
- /**
416
- * A hook which returns model state from the esp Router.
417
- *
418
- * This hooks wih observe updates and re-render the component if the model changes.
419
- *
420
- * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node, and optionally EspModelContextProvider.
421
- *
422
- * @param selector - a function to select a selection of the model - the selector does not need to be memoized, this selector will be cached against the modelId.
423
- * @param options
424
- */
425
- const useSyncModelWithSelector = (selector, options = (0, exports.syncModelWithSelectorOptions)()) => {
577
+ };
578
+ const useSyncStoreModelWithSelector = (selector, options = syncStoreModelWithSelectorOptions()) => {
426
579
  checkArguments(selector, options);
427
- const router = (0, espRouterContextProvider_1.useRouter)();
428
- const modelIdFromContext = (0, espModelContextProvider_1.useGetModelId)();
429
- const modelId = (options === null || options === void 0 ? void 0 : options.modelId) || modelIdFromContext;
430
- const tryPreSelectPolimerImmutableModel = options === null || options === void 0 ? void 0 : options.tryPreSelectPolimerImmutableModel;
431
- const equalityFn = options === null || options === void 0 ? void 0 : options.equalityFn;
432
- const dependencies = (0, react_1.useMemo)(() => {
433
- const canSubscribe = router && esp_js_1.utils.isString(modelId) && router.isModelRegistered(modelId);
580
+ const bus = useEventBus();
581
+ const storeIdFromContext = useGetStoreId();
582
+ const storeId = (options == null ? void 0 : options.storeId) || storeIdFromContext;
583
+ const equalityFn = options == null ? void 0 : options.equalityFn;
584
+ const dependencies = require$$0.useMemo(
585
+ () => {
586
+ const canSubscribe = bus && espJs.utils.isString(storeId);
434
587
  if (canSubscribe) {
435
- return createSubscriptionState(router, modelId, selector, tryPreSelectPolimerImmutableModel);
588
+ return createSubscriptionState(bus, storeId);
436
589
  }
437
590
  return createNoopSubscriptionState();
438
- },
439
- // Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.
440
- [router, modelId]);
441
- // Docs on useSyncExternalStore https://github.com/reactwg/react-18/discussions/86
442
- // Redux's usage of this: https://github.com/reduxjs/react-redux/blob/master/src/hooks/useSelector.ts
443
- // Code: https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
444
- return (0, with_selector_1.useSyncExternalStoreWithSelector)(dependencies.subscribe, dependencies.getSnapshot, undefined, dependencies.wrappedSelector, equalityFn);
445
- };
446
- exports.useSyncModelWithSelector = useSyncModelWithSelector;
447
- const createSubscriptionState = (router, modelId, selector, tryPreSelectPolimerImmutableModel) => {
448
- // Because of how useSyncExternalStore works, there is an implicit dependency between the subscribe and getSnapshot functions.
449
- // When the subscription receives the new state from the Router, it can't pass this directly onto getSnapshot,
450
- // React calls that when it deems it needs to.
451
- // Given that, we need to cache the state which getSnapshot will return.
452
- //
453
- // Another edge case with useSyncExternalStore:
454
- // It will call getSnapshot before it calls subscribe, to account for this we need to fetch the model first.
591
+ },
592
+ [bus, storeId]
593
+ );
594
+ const wrappedSelector = (snapshot) => snapshot ? selector(snapshot) : null;
595
+ return withSelectorExports.useSyncExternalStoreWithSelector(
596
+ dependencies.subscribe,
597
+ dependencies.getSnapshot,
598
+ void 0,
599
+ wrappedSelector,
600
+ equalityFn
601
+ );
602
+ };
603
+ const createSubscriptionState = (bus, storeId) => {
455
604
  let currentModel;
456
- let onStateChanged = null;
457
- const modelSubscriptionDisposable = router
458
- .getModelObservable(modelId)
459
- .subscribe((m) => {
460
- // try and get the esp-js-polimer immutable model if possible, this should mutate when any state changes
461
- const nextModel = tryPreSelectPolimerImmutableModel && esp_js_polimer_1.PolimerModel.isPolimerModel(m)
462
- ? m.getEspPolimerImmutableModel()
463
- // If the above didn't manage to get a polimer model,
464
- // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change.
465
- // This should only affect older style OO models.
466
- : Object.create(m);
467
- warnIfModelInstanceHasNotChanged(modelId, currentModel, nextModel);
468
- currentModel = nextModel;
469
- if (onStateChanged) {
470
- onStateChanged();
471
- }
472
- });
473
605
  return {
474
- subscribe: (stateChanged) => {
475
- onStateChanged = stateChanged;
476
- return () => {
477
- onStateChanged = null;
478
- currentModel = null;
479
- modelSubscriptionDisposable.dispose();
480
- };
481
- },
482
- // React expects getSnapshot to be immutable, it'll only re-render if the instance changes
483
- getSnapshot: () => {
484
- return currentModel;
485
- },
486
- // While getSnapshot needs to model to be immutable,
487
- // useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.
488
- // The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.
489
- wrappedSelector: (snapshot) => {
490
- return snapshot
491
- ? selector(snapshot)
492
- : null;
606
+ subscribe: (stateChanged) => {
607
+ const modelSubscriptionDisposable = bus.getStoreModelObservable(storeId).subscribe(
608
+ (m) => {
609
+ if (m === currentModel) {
610
+ return;
611
+ }
612
+ currentModel = m;
613
+ stateChanged();
614
+ }
615
+ );
616
+ return () => {
617
+ currentModel = null;
618
+ modelSubscriptionDisposable.dispose();
619
+ };
620
+ },
621
+ // React expects getSnapshot to be pure and stable between renders unless the store has changed.
622
+ // We seed currentModel from bus.getStoreModel() on first call (before subscribe has been called),
623
+ // then keep it up-to-date via the subscription callback above.
624
+ // getStoreModel() throws for a store that's been observed but not registered yet, so check first; until then the snapshot is null.
625
+ getSnapshot: () => {
626
+ if (currentModel == null && bus.isStoreRegistered(storeId)) {
627
+ currentModel = bus.getStoreModel(storeId);
493
628
  }
629
+ return currentModel;
630
+ }
494
631
  };
495
- };
496
- const createNoopSubscriptionState = () => ({
632
+ };
633
+ const createNoopSubscriptionState = () => ({
497
634
  subscribe: () => {
498
- return () => { };
635
+ return () => {
636
+ };
499
637
  },
500
- getSnapshot: () => null,
501
- wrappedSelector: () => null
502
- });
503
- const warnIfModelInstanceHasNotChanged = (modelId, lastModel, nextModel) => {
504
- if (true) {
505
- return;
506
- }
507
- if (esp_js_1.utils.stringIsEmpty(modelId)) {
508
- return;
509
- }
510
- if (lastModel === nextModel) {
511
- let stack = undefined;
512
- try {
513
- // noinspection ExceptionCaughtLocallyJS
514
- throw new Error();
515
- }
516
- catch (e) {
517
- stack = e.stack;
518
- }
519
- exports.logger.warn(`useSyncModelWithSelector had detected the latest model update hasn't mutated. This will cause odd render bugs. modelId: ${modelId}`, stack);
520
- }
521
- };
522
-
523
-
524
- /***/ }),
525
-
526
- /***/ 453:
527
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
528
-
529
-
530
- // notice_start
531
- /*
532
- * Copyright 2015 Dev Shop Limited
533
- *
534
- * Licensed under the Apache License, Version 2.0 (the "License");
535
- * you may not use this file except in compliance with the License.
536
- * You may obtain a copy of the License at
537
- *
538
- * http://www.apache.org/licenses/LICENSE-2.0
539
- *
540
- * Unless required by applicable law or agreed to in writing, software
541
- * distributed under the License is distributed on an "AS IS" BASIS,
542
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
543
- * See the License for the specific language governing permissions and
544
- * limitations under the License.
545
- */
546
- // notice_end
547
- var __rest = (this && this.__rest) || function (s, e) {
548
- var t = {};
549
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
550
- t[p] = s[p];
551
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
552
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
553
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
554
- t[p[i]] = s[p[i]];
555
- }
556
- return t;
557
- };
558
- Object.defineProperty(exports, "__esModule", ({ value: true }));
559
- exports.ViewBinder = void 0;
560
- const viewBindingDecorator_1 = __webpack_require__(213);
561
- const espRouterContextProvider_1 = __webpack_require__(169);
562
- /**
563
- * Takes a model with a @viewBinding decorator and dynamically crates the view specified by the decorator
564
- */
565
- const ViewBinder = (_a) => {
566
- var { model, viewContext } = _a, rest = __rest(_a, ["model", "viewContext"]);
567
- if (model) {
568
- const router = (0, espRouterContextProvider_1.useRouter)();
569
- const newProps = Object.assign({ model,
570
- router }, rest);
571
- return (0, viewBindingDecorator_1.createViewForModel)(model, newProps, viewContext, null);
572
- }
573
- return null;
574
- };
575
- exports.ViewBinder = ViewBinder;
576
-
577
-
578
- /***/ }),
579
-
580
- /***/ 213:
581
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
582
-
583
-
584
- // notice_start
585
- /*
586
- * Copyright 2015 Dev Shop Limited
587
- *
588
- * Licensed under the Apache License, Version 2.0 (the "License");
589
- * you may not use this file except in compliance with the License.
590
- * You may obtain a copy of the License at
591
- *
592
- * http://www.apache.org/licenses/LICENSE-2.0
593
- *
594
- * Unless required by applicable law or agreed to in writing, software
595
- * distributed under the License is distributed on an "AS IS" BASIS,
596
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
597
- * See the License for the specific language governing permissions and
598
- * limitations under the License.
599
- */
600
- // notice_end
601
- Object.defineProperty(exports, "__esModule", ({ value: true }));
602
- exports.ViewMetadataRegistration = exports.ViewMetadata = exports.DEFAULT_VIEW_KEY = void 0;
603
- exports.createViewForModel = createViewForModel;
604
- exports.viewBinding = viewBinding;
605
- const React = __webpack_require__(155);
606
- const esp_js_1 = __webpack_require__(152);
607
- exports.DEFAULT_VIEW_KEY = 'default-view-key';
608
- function getMetadata(target) {
609
- if (!target._viewMetadata) {
610
- target._viewMetadata = new ViewMetadata();
611
- }
612
- return target._viewMetadata;
613
- }
614
- /**
615
- * Tries to get a view for the given model.
616
- *
617
- * It does this using the following order:
618
- * 1) If a @viewBinding decorator was used and a display context was given, try get a view for that
619
- * 2) Else if a view was explicitly provided use that
620
- * 3) Else if a @viewBinding decorator was used and there is a view associated with the default display context, use that view
621
- * @param model
622
- * @param props
623
- * @param displayContext
624
- * @param view
625
- */
626
- function createViewForModel(model, props, displayContext, view) {
627
- let finalView = view; // default to that passed in, if any.
628
- // displayContext = displayContext || DEFAULT_VIEW_KEY;
629
- // the view decorator isn't on the instance, it's on the constructor function that created that instance
630
- if (model) {
631
- let constructorFunction = model.constructor;
632
- if (constructorFunction._viewMetadata) {
633
- let viewMetadata = constructorFunction._viewMetadata;
634
- if (displayContext && viewMetadata.hasRegisteredViewContext(displayContext)) {
635
- let viewMetadataRegistration = viewMetadata.viewRegistrations[displayContext];
636
- // we've found a view for the display context, use that
637
- finalView = viewMetadataRegistration.view;
638
- }
639
- // if we've not found a view yet, and one wasn't provided, is there a default one?
640
- if (!finalView && viewMetadata.hasRegisteredViewContext(exports.DEFAULT_VIEW_KEY)) {
641
- let viewMetadataRegistration = viewMetadata.viewRegistrations[exports.DEFAULT_VIEW_KEY];
642
- finalView = viewMetadataRegistration.view;
643
- }
644
- }
645
- }
646
- if (!finalView) {
647
- throw new Error(`No suitable view found for model id '${model.modelId}' using context '${displayContext}'`);
648
- }
649
- return React.createElement(finalView, props);
650
- }
651
- /**
652
- * An ES7 style decorator that associates a model with a view
653
- * @param view the react component that will be used to display this model
654
- * @param displayContext an optional context allowing for different views to display the same model
655
- * @returns {Function}
656
- */
657
- function viewBinding(view, displayContext = exports.DEFAULT_VIEW_KEY) {
658
- esp_js_1.Guard.isDefined(view, 'view must be defined');
659
- esp_js_1.Guard.isString(displayContext, 'displayContext must be a string');
660
- return function (target) {
661
- let viewMetadata = getMetadata(target);
662
- if (viewMetadata.hasRegisteredViewContext(displayContext)) {
663
- throw new Error(`Context ${displayContext} already registered for view`);
664
- }
665
- viewMetadata.viewRegistrations[displayContext] = new ViewMetadataRegistration(view, displayContext);
638
+ getSnapshot: () => null
639
+ });
640
+ const getChildProps = (bus, storeId, restProps, model, mapStoreModelToProps, publishEventProps) => {
641
+ let childProps = {
642
+ storeId,
643
+ bus,
644
+ ...restProps,
645
+ ...publishEventProps,
646
+ model
666
647
  };
667
- }
668
- class ViewMetadata {
669
- constructor() {
670
- this._viewRegistrations = {};
671
- }
672
- get viewRegistrations() {
673
- return this._viewRegistrations;
648
+ if (mapStoreModelToProps) {
649
+ childProps = {
650
+ ...childProps,
651
+ ...mapStoreModelToProps(model, publishEventProps)
652
+ };
674
653
  }
675
- hasRegisteredViewContext(displayContext) {
676
- return typeof this._viewRegistrations[displayContext] !== 'undefined';
677
- }
678
- }
679
- exports.ViewMetadata = ViewMetadata;
680
- class ViewMetadataRegistration {
681
- constructor(_view, _displayContext) {
682
- this._view = _view;
683
- this._displayContext = _displayContext;
684
- }
685
- get view() {
686
- return this._view;
687
- }
688
- get displayContext() {
689
- return this._displayContext;
654
+ return childProps;
655
+ };
656
+ const ConnectableComponent = ({
657
+ storeId,
658
+ mapStoreModelToProps,
659
+ createPublishEventProps,
660
+ view,
661
+ ...rest
662
+ }) => {
663
+ const bus = useEventBus();
664
+ let storeIdFromContext = useGetStoreId();
665
+ storeId = storeId || storeIdFromContext;
666
+ const publishEventProps = require$$0.useMemo(
667
+ () => {
668
+ if (createPublishEventProps) {
669
+ const publishModelEvent = (eventType, event) => {
670
+ bus.publishEvent(storeId, eventType, event);
671
+ };
672
+ return createPublishEventProps(publishModelEvent);
673
+ }
674
+ return {};
675
+ },
676
+ [bus, storeId]
677
+ );
678
+ const model = useSyncStoreModelWithSelector(
679
+ (m) => m,
680
+ syncStoreModelWithSelectorOptions().setStoreId(storeId)
681
+ );
682
+ if (model == null) {
683
+ return null;
690
684
  }
691
- }
692
- exports.ViewMetadataRegistration = ViewMetadataRegistration;
693
-
694
-
695
- /***/ }),
696
-
697
- /***/ 152:
698
- /***/ ((module) => {
699
-
700
- module.exports = __WEBPACK_EXTERNAL_MODULE__152__;
701
-
702
- /***/ }),
703
-
704
- /***/ 43:
705
- /***/ ((module) => {
706
-
707
- module.exports = __WEBPACK_EXTERNAL_MODULE__43__;
708
-
709
- /***/ }),
710
-
711
- /***/ 155:
712
- /***/ ((module) => {
713
-
714
- module.exports = __WEBPACK_EXTERNAL_MODULE__155__;
715
-
716
- /***/ })
717
-
718
- /******/ });
719
- /************************************************************************/
720
- /******/ // The module cache
721
- /******/ var __webpack_module_cache__ = {};
722
- /******/
723
- /******/ // The require function
724
- /******/ function __webpack_require__(moduleId) {
725
- /******/ // Check if module is in cache
726
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
727
- /******/ if (cachedModule !== undefined) {
728
- /******/ return cachedModule.exports;
729
- /******/ }
730
- /******/ // Create a new module (and put it into the cache)
731
- /******/ var module = __webpack_module_cache__[moduleId] = {
732
- /******/ // no module.id needed
733
- /******/ // no module.loaded needed
734
- /******/ exports: {}
735
- /******/ };
736
- /******/
737
- /******/ // Execute the module function
738
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
739
- /******/
740
- /******/ // Return the exports of the module
741
- /******/ return module.exports;
742
- /******/ }
743
- /******/
744
- /************************************************************************/
745
- var __webpack_exports__ = {};
746
- // This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
747
- (() => {
748
- var exports = __webpack_exports__;
749
-
750
- // notice_start
751
- /*
752
- * Copyright 2015 Dev Shop Limited
753
- *
754
- * Licensed under the Apache License, Version 2.0 (the "License");
755
- * you may not use this file except in compliance with the License.
756
- * You may obtain a copy of the License at
757
- *
758
- * http://www.apache.org/licenses/LICENSE-2.0
759
- *
760
- * Unless required by applicable law or agreed to in writing, software
761
- * distributed under the License is distributed on an "AS IS" BASIS,
762
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
763
- * See the License for the specific language governing permissions and
764
- * limitations under the License.
765
- */
766
- // notice_end
767
- //
768
- Object.defineProperty(exports, "__esModule", ({ value: true }));
769
- exports.EspModelContextProvider = exports.usePublishModelEventWithEntityKey = exports.PublishModelEventWithEntityKeyContext = exports.usePublishModelEvent = exports.PublishModelEventContext = exports.GetModelContext = exports.useGetModel = exports.GetModelIdContext = exports.useGetModelId = exports.usePublishEvent = exports.PublishEventContext = exports.useRouter = exports.RouterContext = exports.EspRouterContextProvider = exports.RouterProvider = exports.syncModelWithSelectorOptions = exports.useSyncModelWithSelector = exports.ConnectableComponent = exports.connect = exports.createViewForModel = exports.DEFAULT_VIEW_KEY = exports.viewBinding = exports.ViewBinder = void 0;
770
- // import for side effects
771
- __webpack_require__(185);
772
- var viewBinder_1 = __webpack_require__(453);
773
- Object.defineProperty(exports, "ViewBinder", ({ enumerable: true, get: function () { return viewBinder_1.ViewBinder; } }));
774
- var viewBindingDecorator_1 = __webpack_require__(213);
775
- Object.defineProperty(exports, "viewBinding", ({ enumerable: true, get: function () { return viewBindingDecorator_1.viewBinding; } }));
776
- Object.defineProperty(exports, "DEFAULT_VIEW_KEY", ({ enumerable: true, get: function () { return viewBindingDecorator_1.DEFAULT_VIEW_KEY; } }));
777
- var viewBindingDecorator_2 = __webpack_require__(213);
778
- Object.defineProperty(exports, "createViewForModel", ({ enumerable: true, get: function () { return viewBindingDecorator_2.createViewForModel; } }));
779
- var connect_1 = __webpack_require__(746);
780
- Object.defineProperty(exports, "connect", ({ enumerable: true, get: function () { return connect_1.connect; } }));
781
- var connectableComponent_1 = __webpack_require__(397);
782
- Object.defineProperty(exports, "ConnectableComponent", ({ enumerable: true, get: function () { return connectableComponent_1.ConnectableComponent; } }));
783
- var useSyncModelWithSelector_1 = __webpack_require__(606);
784
- Object.defineProperty(exports, "useSyncModelWithSelector", ({ enumerable: true, get: function () { return useSyncModelWithSelector_1.useSyncModelWithSelector; } }));
785
- Object.defineProperty(exports, "syncModelWithSelectorOptions", ({ enumerable: true, get: function () { return useSyncModelWithSelector_1.syncModelWithSelectorOptions; } }));
786
- var espRouterContextProvider_1 = __webpack_require__(169);
787
- Object.defineProperty(exports, "RouterProvider", ({ enumerable: true, get: function () { return espRouterContextProvider_1.RouterProvider; } }));
788
- Object.defineProperty(exports, "EspRouterContextProvider", ({ enumerable: true, get: function () { return espRouterContextProvider_1.EspRouterContextProvider; } }));
789
- Object.defineProperty(exports, "RouterContext", ({ enumerable: true, get: function () { return espRouterContextProvider_1.RouterContext; } }));
790
- Object.defineProperty(exports, "useRouter", ({ enumerable: true, get: function () { return espRouterContextProvider_1.useRouter; } }));
791
- Object.defineProperty(exports, "PublishEventContext", ({ enumerable: true, get: function () { return espRouterContextProvider_1.PublishEventContext; } }));
792
- Object.defineProperty(exports, "usePublishEvent", ({ enumerable: true, get: function () { return espRouterContextProvider_1.usePublishEvent; } }));
793
- var espModelContextProvider_1 = __webpack_require__(963);
794
- Object.defineProperty(exports, "useGetModelId", ({ enumerable: true, get: function () { return espModelContextProvider_1.useGetModelId; } }));
795
- Object.defineProperty(exports, "GetModelIdContext", ({ enumerable: true, get: function () { return espModelContextProvider_1.GetModelIdContext; } }));
796
- Object.defineProperty(exports, "useGetModel", ({ enumerable: true, get: function () { return espModelContextProvider_1.useGetModel; } }));
797
- Object.defineProperty(exports, "GetModelContext", ({ enumerable: true, get: function () { return espModelContextProvider_1.GetModelContext; } }));
798
- Object.defineProperty(exports, "PublishModelEventContext", ({ enumerable: true, get: function () { return espModelContextProvider_1.PublishModelEventContext; } }));
799
- Object.defineProperty(exports, "usePublishModelEvent", ({ enumerable: true, get: function () { return espModelContextProvider_1.usePublishModelEvent; } }));
800
- Object.defineProperty(exports, "PublishModelEventWithEntityKeyContext", ({ enumerable: true, get: function () { return espModelContextProvider_1.PublishModelEventWithEntityKeyContext; } }));
801
- Object.defineProperty(exports, "usePublishModelEventWithEntityKey", ({ enumerable: true, get: function () { return espModelContextProvider_1.usePublishModelEventWithEntityKey; } }));
802
- Object.defineProperty(exports, "EspModelContextProvider", ({ enumerable: true, get: function () { return espModelContextProvider_1.EspModelContextProvider; } }));
803
-
804
- })();
805
-
806
- /******/ return __webpack_exports__;
807
- /******/ })()
808
- ;
685
+ let childProps = getChildProps(bus, storeId, rest, model, mapStoreModelToProps, publishEventProps);
686
+ let viewElement = view ? require$$0__namespace.createElement(view, childProps) : null;
687
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(EspStoreContextProvider, { storeId, model, bus, ...childProps, children: viewElement });
688
+ };
689
+ const EspModulesContext = require$$0__namespace.createContext([]);
690
+ const RegionView = ({ regionName }) => {
691
+ const modules = require$$0.useContext(EspModulesContext);
692
+ const bindings = require$$0.useMemo(
693
+ () => modules.flatMap((m) => m.viewBindings).filter((b) => b.region === regionName),
694
+ [modules, regionName]
695
+ );
696
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: bindings.map((binding, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
697
+ ConnectableComponent,
698
+ {
699
+ storeId: binding.storeId,
700
+ view: binding.viewComponent
701
+ },
702
+ `${binding.storeId}:${index}`
703
+ )) });
704
+ };
705
+ const EspApp = ({ app, children }) => /* @__PURE__ */ jsxRuntimeExports.jsx(EspEventBusContextProvider, { bus: app.eventBus, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EspModulesContext.Provider, { value: app.modules, children }) });
706
+ exports2.ConnectableComponent = ConnectableComponent;
707
+ exports2.EspApp = EspApp;
708
+ exports2.EspEventBusContextProvider = EspEventBusContextProvider;
709
+ exports2.EspModulesContext = EspModulesContext;
710
+ exports2.EspStoreContextProvider = EspStoreContextProvider;
711
+ exports2.EventBusContext = EventBusContext;
712
+ exports2.GetStoreIdContext = GetStoreIdContext;
713
+ exports2.GetStoreModelContext = GetStoreModelContext;
714
+ exports2.PublishEventContext = PublishEventContext;
715
+ exports2.PublishStoreEventContext = PublishStoreEventContext;
716
+ exports2.PublishStoreEventWithEntityKeyContext = PublishStoreEventWithEntityKeyContext;
717
+ exports2.RegionView = RegionView;
718
+ exports2.syncStoreModelWithSelectorOptions = syncStoreModelWithSelectorOptions;
719
+ exports2.useEventBus = useEventBus;
720
+ exports2.useGetStoreId = useGetStoreId;
721
+ exports2.useGetStoreModel = useGetStoreModel;
722
+ exports2.usePublishEvent = usePublishEvent;
723
+ exports2.usePublishStoreEvent = usePublishStoreEvent;
724
+ exports2.usePublishStoreEventWithEntityKey = usePublishStoreEventWithEntityKey;
725
+ exports2.useSyncStoreModelWithSelector = useSyncStoreModelWithSelector;
726
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
809
727
  });
810
- //# sourceMappingURL=esp-react.js.map
728
+ //# sourceMappingURL=esp-react.js.map