esp-js-react 8.0.2-next.0 → 8.0.3-next.0

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 (36) hide show
  1. package/.dist/esp-react.js +41 -77
  2. package/.dist/esp-react.js.map +1 -1
  3. package/.dist/esp-react.min.js +1 -1
  4. package/.dist/esp-react.min.js.map +1 -1
  5. package/.dist/typings/connect.d.ts +2 -6
  6. package/.dist/typings/connectableComponent.d.ts +0 -16
  7. package/.dist/typings/espModelContextProvider.d.ts +24 -7
  8. package/.dist/typings/espRouterContextProvider.d.ts +5 -5
  9. package/.dist/typings/index.d.ts +0 -1
  10. package/.dist/typings/useModelSelector.d.ts +25 -1
  11. package/.dist/typings/viewBinder.d.ts +8 -1
  12. package/.dist/typings/viewBindingDecorator.d.ts +1 -1
  13. package/package.json +4 -4
  14. package/src/connect.tsx +2 -6
  15. package/src/connectableComponent.tsx +0 -17
  16. package/src/espModelContextProvider.tsx +26 -9
  17. package/src/espRouterContextProvider.tsx +5 -5
  18. package/src/index.ts +0 -4
  19. package/src/useModelSelector.ts +29 -5
  20. package/src/viewBinder.tsx +13 -2
  21. package/src/viewBindingDecorator.ts +2 -2
  22. package/tests/connectableComponentTests.tsx +323 -246
  23. package/tests/espModelContextProviderTests.tsx +142 -0
  24. package/tests/espRouterContextProviderTests.tsx +54 -0
  25. package/tests/indexTests.ts +1 -2
  26. package/tests/testApi/asserts.ts +17 -2
  27. package/tests/testApi/testApi.tsx +37 -21
  28. package/tests/testApi/testModel.ts +15 -8
  29. package/tests/testApi/useStoreReceivedProps.ts +3 -0
  30. package/tests/testApi/viewFactory.tsx +31 -0
  31. package/tests/useModelSelectorTests.tsx +6 -8
  32. package/tests/viewBinderTests.tsx +61 -0
  33. package/.dist/typings/viewBinderConnectable.d.ts +0 -15
  34. package/src/viewBinderConnectable.tsx +0 -54
  35. package/tests/connectableComponentLegacyTests.tsx +0 -405
  36. package/tests/testApi/viewMetadata.tsx +0 -46
@@ -63,9 +63,8 @@ exports.connect = void 0;
63
63
  const React = __webpack_require__(155);
64
64
  const connectableComponent_1 = __webpack_require__(397);
65
65
  /**
66
- * @deprecated
67
- * @param mapModelToProps
68
- * @param createPublishEventProps
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.
69
68
  */
70
69
  const connect = function (mapModelToProps, createPublishEventProps) {
71
70
  return function (view) {
@@ -106,7 +105,6 @@ const viewBindingDecorator_1 = __webpack_require__(213);
106
105
  const getEspPolimerImmutableModel_1 = __webpack_require__(894);
107
106
  const useModelSelector_1 = __webpack_require__(743);
108
107
  const getChildProps = (router, modelId, restProps, initialModel, mapModelToProps, publishEventProps) => {
109
- // consume what this component owns, and let the rest end up in `...rest`
110
108
  const model = (0, getEspPolimerImmutableModel_1.tryGetPolimerImmutableModel)(initialModel);
111
109
  let childProps = Object.assign(Object.assign(Object.assign({ modelId, router: router }, restProps), publishEventProps), { model });
112
110
  if (mapModelToProps) {
@@ -114,10 +112,6 @@ const getChildProps = (router, modelId, restProps, initialModel, mapModelToProps
114
112
  }
115
113
  return childProps;
116
114
  };
117
- /**
118
- * @deprecated - use ViewBinderConnectable and ESP hooks if you need to dynamically bind a view to a model
119
- * or useModelSelector with other ESP hooks for direct model subscription.
120
- */
121
115
  const ConnectableComponent = (_a) => {
122
116
  var { modelId, mapModelToProps, createPublishEventProps, view, viewContext } = _a, rest = __rest(_a, ["modelId", "mapModelToProps", "createPublishEventProps", "view", "viewContext"]);
123
117
  const router = (0, espRouterContextProvider_1.useRouter)();
@@ -162,32 +156,49 @@ const espRouterContextProvider_1 = __webpack_require__(169);
162
156
  const _log = esp_js_1.Logger.create('EspModelContextProvider');
163
157
  exports.GetModelIdContext = (0, react_1.createContext)(null);
164
158
  /**
165
- * Returns a function which will return the ID of the model currently being rendered.
159
+ * Returns a function to get the ID of the model connected at a higher point in the V-DOM.
160
+ *
161
+ * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
166
162
  */
167
163
  const useGetModelId = () => (0, react_1.useContext)(exports.GetModelIdContext)();
168
164
  exports.useGetModelId = useGetModelId;
169
165
  exports.GetModelContext = (0, react_1.createContext)(null);
170
166
  /**
171
- * Returns a function which will return the model set at last dispatch.
167
+ * Returns a function which will return the model connected at a higher point in the V-DOM.
168
+ *
169
+ * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
172
170
  */
173
171
  const useGetModel = () => (0, react_1.useContext)(exports.GetModelContext)();
174
172
  exports.useGetModel = useGetModel;
175
173
  exports.PublishModelEventContext = (0, react_1.createContext)(null);
176
174
  /**
177
- * Returns a function which can be used to publish an event to the current model being rendered.
175
+ * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM.
178
176
  *
179
- * Effectively, this is a version of usePublishEvent() which closes over the current modelId.
177
+ * Effectively, this is a version of usePublishEvent() which closes over the relevant modelId.
178
+ *
179
+ * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
180
180
  */
181
181
  const usePublishModelEvent = () => (0, react_1.useContext)(exports.PublishModelEventContext);
182
182
  exports.usePublishModelEvent = usePublishModelEvent;
183
183
  exports.PublishModelEventWithEntityKeyContext = (0, react_1.createContext)(null);
184
184
  /**
185
- * Returns a function which can be used to publish an event to the current model being rendered, allows an entityKey to be specified.
185
+ * 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.
186
+ *
187
+ * Effectively, this is a version of usePublishEvent() which closes over the modelId.
186
188
  *
187
- * Effectively, this is a version of usePublishEvent() which closes over the current modelId.
189
+ * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
188
190
  */
189
191
  const usePublishModelEventWithEntityKey = () => (0, react_1.useContext)(exports.PublishModelEventWithEntityKeyContext);
190
192
  exports.usePublishModelEventWithEntityKey = usePublishModelEventWithEntityKey;
193
+ /**
194
+ * Sets up various ESP context so ESP hooks are available below this point in the V-DOM
195
+ *
196
+ * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node.
197
+ * @param modelId
198
+ * @param children
199
+ * @param model
200
+ * @constructor
201
+ */
191
202
  const EspModelContextProvider = ({ modelId, children, model }) => {
192
203
  const router = (0, espRouterContextProvider_1.useRouter)();
193
204
  const getModelId = (0, react_1.useCallback)(() => {
@@ -226,8 +237,8 @@ const warnIfModelAccessedOutSideDispatchLoop = (router, modelId) => {
226
237
  catch (e) {
227
238
  stack = e.stack;
228
239
  }
229
- _log.warn(`EspModelContextProvider useGetModelId has been invoked outside of the models (${modelId}) dispatch loop.` +
230
- `This may have unknown state state issues.` +
240
+ _log.warn(`EspModelContextProvider useGetModelId has been invoked outside of the models (${modelId}) dispatch loop. ` +
241
+ `This may have unknown state issues.` +
231
242
  stack);
232
243
  }
233
244
  };
@@ -262,13 +273,13 @@ const React = __webpack_require__(155);
262
273
  const react_1 = __webpack_require__(155);
263
274
  exports.RouterContext = (0, react_1.createContext)(null);
264
275
  /**
265
- * Get the esp Router from the RouterContext
276
+ * Get the esp Router from context.
266
277
  *
267
- * To use this, please ensure your V-DOM has the EspRouterContext at a higher node:
278
+ * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node:
268
279
  *
269
- * <EspRouterContext router={router}>
280
+ * <EspRouterContextProvider router={router}>
270
281
  * <YourComponents />
271
- * </EspRouterContext>
282
+ * </EspRouterContextProvider>
272
283
  */
273
284
  const useRouter = () => {
274
285
  const context = (0, react_1.useContext)(exports.RouterContext);
@@ -282,7 +293,7 @@ exports.PublishEventContext = (0, react_1.createContext)(null);
282
293
  /**
283
294
  * Returns a function which can be used to publish an event.
284
295
  *
285
- * To use this, please ensure your V-DOM has the EspRouterContext at a higher node:
296
+ * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node:
286
297
  *
287
298
  * <EspRouterContextProvider router={router}>
288
299
  * <YourComponents />
@@ -411,6 +422,9 @@ const esp_js_1 = __webpack_require__(152);
411
422
  const espRouterContextProvider_1 = __webpack_require__(169);
412
423
  const espModelContextProvider_1 = __webpack_require__(963);
413
424
  const getEspPolimerImmutableModel_1 = __webpack_require__(894);
425
+ /**
426
+ * Convenience API to create ModelSelectorOptions
427
+ */
414
428
  const modelSelectorOptions = () => {
415
429
  let modelId = undefined;
416
430
  let equalityFn = (a, b) => a === b;
@@ -440,14 +454,6 @@ const modelSelectorOptions = () => {
440
454
  };
441
455
  };
442
456
  exports.modelSelectorOptions = modelSelectorOptions;
443
- /**
444
- * A hook which returns model state from the esp Router.
445
- *
446
- * This hooks wih observe updates and re-render the component if the model changes.
447
- *
448
- * @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.
449
- * @param options
450
- */
451
457
  const useModelSelector = (selector, options = (0, exports.modelSelectorOptions)()) => {
452
458
  esp_js_1.Guard.isFunction(selector, 'You must pass a selector function to connectSelector');
453
459
  const router = (0, espRouterContextProvider_1.useRouter)();
@@ -556,11 +562,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
556
562
  exports.ViewBinder = void 0;
557
563
  const viewBindingDecorator_1 = __webpack_require__(213);
558
564
  const espRouterContextProvider_1 = __webpack_require__(169);
565
+ /**
566
+ * Takes a model with a @viewBinding decorator and dynamically crates the view specified by the decorator
567
+ */
559
568
  const ViewBinder = (_a) => {
560
569
  var { model, viewContext } = _a, rest = __rest(_a, ["model", "viewContext"]);
561
570
  if (model) {
562
571
  const router = (0, espRouterContextProvider_1.useRouter)();
563
- const newProps = Object.assign({}, { model, router }, rest);
572
+ const newProps = Object.assign({ model,
573
+ router }, rest);
564
574
  return (0, viewBindingDecorator_1.createViewForModel)(model, newProps, viewContext, null);
565
575
  }
566
576
  return null;
@@ -568,50 +578,6 @@ const ViewBinder = (_a) => {
568
578
  exports.ViewBinder = ViewBinder;
569
579
 
570
580
 
571
- /***/ }),
572
-
573
- /***/ 639:
574
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
575
-
576
-
577
- Object.defineProperty(exports, "__esModule", ({ value: true }));
578
- exports.ViewBinderConnectable = void 0;
579
- const espRouterContextProvider_1 = __webpack_require__(169);
580
- const espModelContextProvider_1 = __webpack_require__(963);
581
- const esp_js_1 = __webpack_require__(152);
582
- const React = __webpack_require__(155);
583
- const useModelSelector_1 = __webpack_require__(743);
584
- const viewBindingDecorator_1 = __webpack_require__(213);
585
- const getEspPolimerImmutableModel_1 = __webpack_require__(894);
586
- const _log = esp_js_1.Logger.create('ViewBinderConnectable');
587
- /**
588
- * Dynamically binds a view found via @viewBinder(SomeJsXView) to a model managed by the Router.
589
- * Optionally provide a view override and/or a viewContext
590
- * @param modelId
591
- * @param viewContext
592
- * @param view
593
- * @constructor
594
- */
595
- const ViewBinderConnectable = ({ modelId, viewContext, view }) => {
596
- const router = (0, espRouterContextProvider_1.useRouter)();
597
- const model = (0, useModelSelector_1.useModelSelector)(m => m, (0, useModelSelector_1.modelSelectorOptions)()
598
- .setModelId(modelId)
599
- .setTryPreSelectPolimerImmutableModel(false));
600
- if (!model) {
601
- return null;
602
- }
603
- let immutableModel = (0, getEspPolimerImmutableModel_1.tryGetPolimerImmutableModel)(model);
604
- const childProps = {
605
- modelId,
606
- router: router,
607
- model: immutableModel
608
- };
609
- let viewElement = (0, viewBindingDecorator_1.createViewForModel)(model, childProps, viewContext, view);
610
- return (React.createElement(espModelContextProvider_1.EspModelContextProvider, Object.assign({ modelId: modelId, router: router, model: immutableModel }, childProps), viewElement));
611
- };
612
- exports.ViewBinderConnectable = ViewBinderConnectable;
613
-
614
-
615
581
  /***/ }),
616
582
 
617
583
  /***/ 213:
@@ -803,13 +769,11 @@ var exports = __webpack_exports__;
803
769
  // notice_end
804
770
  //
805
771
  Object.defineProperty(exports, "__esModule", ({ value: true }));
806
- 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.modelSelectorOptions = exports.useModelSelector = exports.ConnectableComponent = exports.connect = exports.createViewForModel = exports.getEspPolimerImmutableModel = exports.GetEspPolimerImmutableModelConsts = exports.DEFAULT_VIEW_KEY = exports.viewBinding = exports.ViewBinderConnectable = exports.ViewBinder = void 0;
772
+ 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.modelSelectorOptions = exports.useModelSelector = exports.ConnectableComponent = exports.connect = exports.createViewForModel = exports.getEspPolimerImmutableModel = exports.GetEspPolimerImmutableModelConsts = exports.DEFAULT_VIEW_KEY = exports.viewBinding = exports.ViewBinder = void 0;
807
773
  // import for side effects
808
774
  __webpack_require__(185);
809
775
  var viewBinder_1 = __webpack_require__(453);
810
776
  Object.defineProperty(exports, "ViewBinder", ({ enumerable: true, get: function () { return viewBinder_1.ViewBinder; } }));
811
- var viewBinderConnectable_1 = __webpack_require__(639);
812
- Object.defineProperty(exports, "ViewBinderConnectable", ({ enumerable: true, get: function () { return viewBinderConnectable_1.ViewBinderConnectable; } }));
813
777
  var viewBindingDecorator_1 = __webpack_require__(213);
814
778
  Object.defineProperty(exports, "viewBinding", ({ enumerable: true, get: function () { return viewBindingDecorator_1.viewBinding; } }));
815
779
  Object.defineProperty(exports, "DEFAULT_VIEW_KEY", ({ enumerable: true, get: function () { return viewBindingDecorator_1.DEFAULT_VIEW_KEY; } }));
@@ -1 +1 @@
1
- {"version":3,"file":"esp-react.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACa,MAAM,m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AAC,eAAe,CAAC;IAChC,CAAC;CACJ;AAZD,4DAYC;;;;;;;;AChHD;;;;;;;ACAA;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;;;;ACtBA,eAAe;AACf;;;;;;;;;;;;;;GAcG;AACH,aAAa;AACb,EAAE;;;AAEF,0BAA0B;AAC1B,yBAAkD;AAElD,4CAAwC;AAAhC,mHAAU;AAClB,uDAGiC;AAD7B,oJAAqB;AAEzB,sDAAqE;AAA7D,+HAAW;AAAE,yIAAgB;AACrC,6DAI+C;AAF3C,kLAAiC;AACjC,sKAA2B;AAE/B,sDAA0D;AAAlD,6IAAkB;AAC1B,yCAGmB;AAFf,0GAAO;AAGX,sDAMgC;AAD5B,iJAAoB;AAExB,kDAO4B;AALxB,qIAAgB;AAEhB,6IAAoB;AAIxB,0DAUoC;AAThC,yIAAc;AAEd,6JAAwB;AAExB,uIAAa;AACb,+HAAS;AAET,mJAAmB;AACnB,2IAAe;AAEnB,yDAemC;AAd/B,sIAAa;AAEb,8IAAiB;AACjB,kIAAW;AAEX,0IAAe;AAEf,4JAAwB;AACxB,oJAAoB;AAEpB,sLAAqC;AACrC,8KAAiC;AACjC,0JAAuB","sources":["webpack://esp-js-react/webpack/universalModuleDefinition","webpack://esp-js-react/../../node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.min.js","webpack://esp-js-react/../../node_modules/use-sync-external-store/with-selector.js","webpack://esp-js-react/./src/connect.tsx","webpack://esp-js-react/./src/connectableComponent.tsx","webpack://esp-js-react/./src/espModelContextProvider.tsx","webpack://esp-js-react/./src/espRouterContextProvider.tsx","webpack://esp-js-react/./src/polimer/getEspPolimerImmutableModel.ts","webpack://esp-js-react/./src/polimer/polimerModelBuilderExtentsions.ts","webpack://esp-js-react/./src/useModelSelector.ts","webpack://esp-js-react/./src/viewBinder.tsx","webpack://esp-js-react/./src/viewBinderConnectable.tsx","webpack://esp-js-react/./src/viewBindingDecorator.ts","webpack://esp-js-react/external umd \"esp-js\"","webpack://esp-js-react/external umd \"esp-js-polimer\"","webpack://esp-js-react/external umd \"react\"","webpack://esp-js-react/webpack/bootstrap","webpack://esp-js-react/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"esp-js\"), require(\"esp-js-polimer\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"esp-js\", \"esp-js-polimer\", \"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"esp-js-react\"] = factory(require(\"esp-js\"), require(\"esp-js-polimer\"), require(\"react\"));\n\telse\n\t\troot[\"esp-js-react\"] = factory(root[\"esp-js\"], root[\"esp-js-polimer\"], root[\"react\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__152__, __WEBPACK_EXTERNAL_MODULE__43__, __WEBPACK_EXTERNAL_MODULE__155__) => {\nreturn ","/**\n * @license React\n * use-sync-external-store-with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var g=require(\"react\");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;\nexports.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]);\nt(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/use-sync-external-store-with-selector.production.min.js');\n} else {\n module.exports = require('./cjs/use-sync-external-store-with-selector.development.js');\n}\n","import * as React from 'react';\nimport {ConnectableComponent, ConnectableComponentProps, CreatePublishEventProps, MapModelToProps} from './connectableComponent';\n\n/**\n * @deprecated\n */\nexport type ConnectableComponentFactory<TModel, TPublishEventProps, TModelMappedToProps = {}> = (view: React.ComponentType) => (props: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>) => React.JSX.Element;\n\n/**\n * @deprecated\n * @param mapModelToProps\n * @param createPublishEventProps\n */\nexport const connect = function <TModel, TPublishEventProps, TModelMappedToProps = {}>(\n mapModelToProps?: MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps>,\n createPublishEventProps?: CreatePublishEventProps<TPublishEventProps>\n): ConnectableComponentFactory<TModel, TPublishEventProps, TModelMappedToProps> {\n return function (view: React.ComponentType) {\n return function (props: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>) {\n const {modelId, viewContext, ...rest} = props;\n return <ConnectableComponent\n modelId={modelId}\n view={view}\n viewContext={viewContext}\n createPublishEventProps={createPublishEventProps}\n mapModelToProps={mapModelToProps}\n {...rest}\n />;\n };\n };\n};","import * as React from 'react';\nimport {useRouter} from './espRouterContextProvider';\nimport {useMemo} from 'react';\nimport {Router, utils} from 'esp-js';\nimport {EspModelContextProvider, useGetModelId} from './espModelContextProvider';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';\nimport {modelSelectorOptions, useModelSelector} from './useModelSelector';\n\n/**\n * @deprecated\n */\nexport type CreatePublishEventProps<TPublishEventProps> = (publishModelEvent: (eventType: string, event: any) => void) => TPublishEventProps;\n\n/**\n * @deprecated\n */\nexport type MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps = {}> = (model: TModel, publishEventProps: TPublishEventProps) => TModelMappedToProps;\n\n/**\n * @deprecated\n */\nexport interface ConnectableComponentProps<TModel = {}, TPublishEventProps = {}, TModelMappedToProps = {}> {\n modelId?: string;\n viewContext?: string;\n view?: React.ComponentType;\n createPublishEventProps?: CreatePublishEventProps<TPublishEventProps>;\n mapModelToProps?: MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps>;\n [key: string]: any; // ...rest props, including the result of mapPublish and mapPublish if 'connect' was used\n}\n\n/**\n * @deprecated\n */\nexport interface ConnectableComponentChildProps<TModel = object> {\n modelId: string;\n model: TModel;\n router: Router;\n [key: string]: any; // ...rest props\n}\n\nconst getChildProps = <TModel, TModelMappedToProps, TPublishEventProps>(\n router: Router,\n modelId: string,\n restProps: object,\n initialModel: TModel,\n mapModelToProps: MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps>,\n publishEventProps: TPublishEventProps\n): ConnectableComponentChildProps<TModel> => {\n // consume what this component owns, and let the rest end up in `...rest`\n const model = tryGetPolimerImmutableModel<TModel>(initialModel);\n let childProps = {\n modelId,\n router: router,\n ...restProps,\n ...publishEventProps,\n model\n };\n if (mapModelToProps) {\n childProps = {\n ...childProps,\n ...(mapModelToProps(model, publishEventProps) as TModelMappedToProps)\n };\n }\n return childProps;\n};\n\n/**\n * @deprecated - use ViewBinderConnectable and ESP hooks if you need to dynamically bind a view to a model\n * or useModelSelector with other ESP hooks for direct model subscription.\n */\nexport const ConnectableComponent = <TModel = {}, TPublishEventProps = {}, TModelMappedToProps = {}>(\n {\n modelId,\n mapModelToProps,\n createPublishEventProps,\n view,\n viewContext,\n ...rest\n }: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>\n) => {\n const router = useRouter();\n modelId = modelId || useGetModelId();\n if (utils.stringIsEmpty(modelId) || !router) {\n return null;\n }\n const publishEventProps: TPublishEventProps = useMemo(\n () => {\n if (createPublishEventProps) {\n const publishModelEvent = (eventType: string, event: any) => {\n router.publishEvent(modelId, eventType, event);\n };\n return createPublishEventProps(publishModelEvent);\n }\n return {} as TPublishEventProps;\n },\n [router, modelId]\n );\n const model = useModelSelector<TModel, TModel>(\n m => m,\n modelSelectorOptions()\n .setModelId(modelId)\n .setTryPreSelectPolimerImmutableModel(false)\n );\n if (model == null) {\n return null;\n }\n let childProps = getChildProps(router, modelId, rest, model, mapModelToProps, publishEventProps);\n let viewElement = createViewForModel(model, childProps, viewContext, view);\n return (\n <EspModelContextProvider modelId={modelId} model={model} router={router} {...childProps}>\n {viewElement}\n </EspModelContextProvider>\n );\n};","import * as React from 'react';\nimport {DefaultModelAddress, Router, Status, Logger, utils} from 'esp-js';\nimport {useContext, useCallback, createContext, PropsWithChildren} from 'react';\nimport {useRouter} from './espRouterContextProvider';\n\nconst _log = Logger.create('EspModelContextProvider');\n\nexport type GetModelIdDelegate = () => string;\nexport const GetModelIdContext = createContext<GetModelIdDelegate>(null);\n/**\n * Returns a function which will return the ID of the model currently being rendered.\n */\nexport const useGetModelId = () => useContext(GetModelIdContext)();\n\nexport type GetModelDelegate = <TModel = any, >() => TModel;\nexport const GetModelContext = createContext<GetModelDelegate>(null);\n/**\n * Returns a function which will return the model set at last dispatch.\n */\nexport const useGetModel = () => useContext(GetModelContext)();\n\nexport type PublishModelEventDelegate = (eventType: string, event: any) => void;\nexport const PublishModelEventContext = createContext<PublishModelEventDelegate>(null);\n/**\n * Returns a function which can be used to publish an event to the current model being rendered.\n *\n * Effectively, this is a version of usePublishEvent() which closes over the current modelId.\n */\nexport const usePublishModelEvent = () => useContext(PublishModelEventContext);\n\nexport type PublishModelEventWithEntityKeyDelegate = (entityKey: string, eventType: string, event: any) => void;\nexport const PublishModelEventWithEntityKeyContext = createContext<PublishModelEventWithEntityKeyDelegate>(null);\n/**\n * Returns a function which can be used to publish an event to the current model being rendered, allows an entityKey to be specified.\n *\n * Effectively, this is a version of usePublishEvent() which closes over the current modelId.\n */\nexport const usePublishModelEventWithEntityKey = () => useContext(PublishModelEventWithEntityKeyContext);\n\nexport interface EspModelContextProviderProps {\n modelId: string;\n model?: unknown;\n}\n\nexport const EspModelContextProvider = ({modelId, children, model}: PropsWithChildren<EspModelContextProviderProps>) => {\n const router = useRouter();\n const getModelId: () => string = useCallback(() => {\n return modelId;\n }, [router, modelId]);\n const getModel: () => any = useCallback(() => {\n warnIfModelAccessedOutSideDispatchLoop(router, modelId);\n return model;\n }, [model, router, modelId]);\n const publishModelEvent: PublishModelEventDelegate = useCallback((eventType: string, event: any) => {\n router.publishEvent(modelId, eventType, event);\n }, [router, modelId]);\n const publishModelEventWithEntityKey: PublishModelEventWithEntityKeyDelegate = useCallback((entityKey: string, eventType: string, event: any) => {\n router.publishEvent(new DefaultModelAddress(modelId, entityKey), eventType, event);\n }, [router, modelId]);\n return (\n <GetModelIdContext.Provider value={getModelId}>\n <PublishModelEventContext.Provider value={publishModelEvent}>\n <PublishModelEventWithEntityKeyContext.Provider value={publishModelEventWithEntityKey}>\n <GetModelContext.Provider value={getModel}>\n {children}\n </GetModelContext.Provider>\n </PublishModelEventWithEntityKeyContext.Provider>\n </PublishModelEventContext.Provider>\n </GetModelIdContext.Provider>\n );\n};\n\nconst warnIfModelAccessedOutSideDispatchLoop = (router: Router, modelId: string) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (utils.stringIsEmpty(modelId)) {\n return;\n }\n let isDispatchModelUpdateStatus = router.isModelDispatchStatus(modelId, Status.DispatchModelUpdates);\n if (!isDispatchModelUpdateStatus) {\n let stack: string | undefined = undefined;\n try {\n // noinspection ExceptionCaughtLocallyJS\n throw new Error();\n } catch (e) {\n stack = (e as Error).stack;\n }\n _log.warn(\n `EspModelContextProvider useGetModelId has been invoked outside of the models (${modelId}) dispatch loop.` +\n `This may have unknown state state issues.` +\n stack\n );\n }\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {ModelAddress, Router} from 'esp-js';\nimport {PropsWithChildren, createContext, useContext, useCallback} from 'react';\n\nexport const RouterContext = createContext<Router>(null);\n\n/**\n * Get the esp Router from the RouterContext\n *\n * To use this, please ensure your V-DOM has the EspRouterContext at a higher node:\n *\n * <EspRouterContext router={router}>\n * <YourComponents />\n * </EspRouterContext>\n */\nexport const useRouter = () => {\n const context: Router = useContext(RouterContext);\n if (context === undefined) {\n throw new Error('useRouter must be used within a RouterContext.Provider');\n }\n return context;\n};\n\nexport type PublishEventDelegate = (modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any) => void;\nexport const PublishEventContext = createContext<PublishEventDelegate>(null);\n\n/**\n * Returns a function which can be used to publish an event.\n *\n * To use this, please ensure your V-DOM has the EspRouterContext at a higher node:\n *\n * <EspRouterContextProvider router={router}>\n * <YourComponents />\n * </EspRouterContextProvider>\n */\nexport const usePublishEvent = () => useContext(PublishEventContext);\n\nexport type EspRouterContextProviderProps = PropsWithChildren<{ router: Router; }>;\n\n/**\n * Used to set the router on the RouterContext making it available to components down the tree via the useRouter() hook.\n *\n * Also sets up the usePublishEvent() hook so nested components can publish to the router.\n */\nexport const EspRouterContextProvider = ({children, router}: EspRouterContextProviderProps) => {\n const publishEvent: PublishEventDelegate = useCallback((modelIdOrModelAddress: string, eventType: string, event: any) => {\n router.publishEvent(modelIdOrModelAddress, eventType, event);\n }, [router]);\n return (\n <RouterContext.Provider value={router}>\n <PublishEventContext.Provider value={publishEvent}>\n {children}\n </PublishEventContext.Provider>\n </RouterContext.Provider>\n );\n};\n\n/**\n * Used to set the router on the RouterContext making it available to components down the tree (via useRouter()).\n *\n * @deprecated use EspRouterContextProvider\n */\nexport const RouterProvider = EspRouterContextProvider;\n\n/**\n * Props for RouterProvider\n *\n * @deprecated use EspRouterContextProviderProps\n */\nexport type RouterProviderProps = EspRouterContextProviderProps;\n","import {EspMetadata, EspDecoratorUtil, utils} from 'esp-js';\n\nexport interface GetEspPolimerImmutableModelMetadata {\n functionName: string;\n}\n\nexport namespace GetEspPolimerImmutableModelConsts {\n export const CustomDataKey = 'GetEspReactImmutableModelCustomDataKey';\n /**\n * If there is no @getEspPolimerImmutableModel decorator and a function by this name exists on a model, then it will be invoked to identify the sub model which will replaced the `model` prop passed to the child view of a ConnectableComponent\n */\n export const HandlerFunctionName = 'getEspPolimerImmutableModel';\n}\n\n/**\n * A decorator which can be used to identify the render model which will replaced the `model` prop passed to the child view of a ConnectableComponent\n */\nexport function getEspPolimerImmutableModel() {\n return function (target, name, descriptor) {\n let metadata: EspMetadata = EspDecoratorUtil.getOrCreateMetaData(target.constructor);\n metadata.addCustomData(\n GetEspPolimerImmutableModelConsts.CustomDataKey,\n <GetEspPolimerImmutableModelMetadata>{ functionName: name }\n );\n return descriptor;\n };\n}\n\n/**\n * Returns the model which will be used to pluck state/props for the current view.\n *\n * This is basically a hook (not a React 'hook') to call a function on `model` and get a new subgraph to use as state.\n *\n */\nexport const tryGetPolimerImmutableModel = <TImmutableModel>(model: any): TImmutableModel => {\n // does the given model have a decorated function we can invoke to get a different model to render?\n if (EspDecoratorUtil.hasMetadata(model)) {\n let metadata: GetEspPolimerImmutableModelMetadata = EspDecoratorUtil.getCustomData(model, GetEspPolimerImmutableModelConsts.CustomDataKey);\n if (metadata) {\n return model[metadata.functionName]();\n }\n }\n // else see if there is a function with name GetEspPolimerImmutableModelConsts.HandlerFunctionName we can invoke to get a different model to render?\n let immutableModel = model[GetEspPolimerImmutableModelConsts.HandlerFunctionName];\n if (immutableModel && utils.isFunction(immutableModel)) {\n return immutableModel.call(model);\n }\n // else return the initial model passed in\n return model;\n};","import {PolimerModelBuilder, PolimerModel} from 'esp-js-polimer';\nimport {DEFAULT_VIEW_KEY, viewBinding} from '../viewBindingDecorator';\n\ndeclare module 'esp-js-polimer/.dist/typings/modelBuilderUpdater' {\n export interface PolimerModelBuilder<TModel> {\n withViewBindings?(view: any, displayContext?: string): PolimerModelBuilder<TModel>;\n }\n}\n\ninterface ViewMappings {\n [displayContext: string]: any;\n}\n\nPolimerModelBuilder.prototype.withViewBindings = function (view: any, displayContext: string = DEFAULT_VIEW_KEY): PolimerModelBuilder<any> {\n let builder = this;\n // store some metadata on the builder which we'll use later to tack onto the model\n let viewMappings: ViewMappings = builder._viewMappings || { };\n viewMappings[displayContext] = view;\n builder._viewMappings = viewMappings;\n return this;\n};\n\n// we need to replace the registerWithRouter in order to dynamically add the\n// @viewBinding decorator to it\nlet registerWithRouter = PolimerModelBuilder.prototype.registerWithRouter;\nPolimerModelBuilder.prototype.registerWithRouter = function (): PolimerModel<any> {\n let builder = this;\n let model = registerWithRouter.call(builder);\n let viewMappings: ViewMappings = builder._viewMappings;\n if (viewMappings) {\n Object.keys(viewMappings).forEach(displayContext => {\n viewBinding(viewMappings[displayContext], displayContext)(model.constructor);\n });\n }\n return model;\n};\n","import {useMemo} from 'react';\nimport {useSyncExternalStoreWithSelector} from 'use-sync-external-store/with-selector';\nimport {Guard, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';\n\nexport type ModelSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\n/**\n * @param modelId - the modelId of the model to be observed via the esp Router.\n * @param tryPreSelectPolimerImmutableModel - if true, and the esp model is an esp-js-polimer model, the immutable model will be used when calling the selector.\n * @param equalityFn - Equality function which will be applied against TSelected, defaults to instance equality (a === b).\n */\nexport type ModelSelectorOptions<TSelected> = {\n modelId?: string,\n tryPreSelectPolimerImmutableModel: boolean,\n equalityFn: ModelSelectorEqualityFn<TSelected>\n};\n\nexport interface EditableModelSelectorOptions<TSelected> extends ModelSelectorOptions<TSelected> {\n setModelId(modelId: string): this;\n\n setTryPreSelectPolimerImmutableModel(value: boolean): this;\n\n setEqualityFn(fn: (a: TSelected, b: TSelected) => boolean): this;\n}\n\nexport const modelSelectorOptions = <TSelected>() => {\n let modelId = undefined;\n let equalityFn: ModelSelectorEqualityFn<TSelected> = (a: TSelected, b: TSelected) => a === b;\n let tryPreSelectPolimerImmutableModel = true;\n return {\n get modelId() {\n return modelId;\n },\n setModelId(value: string) {\n modelId = value;\n return this;\n },\n get equalityFn() {\n return equalityFn;\n },\n setEqualityFn(value: ModelSelectorEqualityFn<TSelected>) {\n equalityFn = value;\n return this;\n },\n get tryPreSelectPolimerImmutableModel() {\n return tryPreSelectPolimerImmutableModel;\n },\n setTryPreSelectPolimerImmutableModel(value: boolean) {\n tryPreSelectPolimerImmutableModel = value;\n return this;\n }\n } as EditableModelSelectorOptions<TSelected>;\n};\n\nexport type UseModelSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options?: ModelSelectorOptions<TSelected>\n) => TSelected;\n\n/**\n * A hook which returns model state from the esp Router.\n *\n * This hooks wih observe updates and re-render the component if the model changes.\n *\n * @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.\n * @param options\n */\nexport const useModelSelector: UseModelSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options: ModelSelectorOptions<TSelected> = modelSelectorOptions<TSelected>()\n) => {\n Guard.isFunction(selector, 'You must pass a selector function to connectSelector');\n const router = useRouter();\n const modelId = options?.modelId || useGetModelId();\n const tryPreSelectPolimerImmutableModel = options?.tryPreSelectPolimerImmutableModel;\n const equalityFn = options?.equalityFn;\n const dependencies = useMemo(\n () => {\n // Because of how useSyncExternalStore works, there is an implicit dependency between the subscribe and getSnapshot functions.\n // When the subscription receives the new state from the Router, it can't pass this directly onto getSnapshot, React calls that when it deems it needs to.\n // Given that, we need to cache the state which getSnapshot will return.\n //\n // It's not ideal but shouldn't be a problem as here we've wrapped all these dependent functions inside a single useMemo()\n let model: TModel = null;\n return {\n subscribe: (stateChanged: () => void) => {\n const modelSubscriptionDisposable = router\n .getModelObservable(modelId)\n .subscribe(\n (m: any) => {\n // try and get a submodel to render\n const nextModel = tryPreSelectPolimerImmutableModel\n ? tryGetPolimerImmutableModel(m)\n : m;\n // if the above didn't manage to get a submodel,\n // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change\n model = nextModel === m\n ? Object.create(nextModel)\n : nextModel;\n stateChanged();\n }\n );\n return () => {\n model = null;\n modelSubscriptionDisposable.dispose();\n };\n },\n // React expects getSnapshot to be immutable, it'll only re-render if the instance changes\n getSnapshot: () => {\n return model;\n },\n // While getSnapshot needs to model to be immutable,\n // useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.\n // The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.\n wrappedSelector: (snapshot: TModel) => {\n // The first time this renders, react calls getSnapshot and the selector before the router has pushed a change.\n // In that case, there is no state for any component to process, therefore, we return null;\n return snapshot\n ? selector(snapshot)\n : null;\n }\n };\n },\n // Don't cache check against 'selector' argument as that will likely change unless the caller memoizes it.\n [router, modelId]\n );\n\n // If we don't have a modelId, we still need to return a hook so React doesn't complain.\n // Additionally, we need to let the above expiration (dependencies) run to unsubscribe from any previous subscription.\n if (utils.stringIsEmpty(modelId)) {\n return useSyncExternalStoreWithSelector(\n noopSubscription.subscribe,\n noopSubscription.getSnapshot,\n undefined,\n noopSubscription.wrappedSelector,\n equalityFn\n );\n }\n\n // Docs on useSyncExternalStore https://github.com/reactwg/react-18/discussions/86\n // Redux's usage of this: https://github.com/reduxjs/react-redux/blob/master/src/hooks/useSelector.ts\n // Code: https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js\n return useSyncExternalStoreWithSelector(\n dependencies.subscribe,\n dependencies.getSnapshot,\n undefined,\n dependencies.wrappedSelector,\n equalityFn,\n );\n};\n\nconst noopSubscription = {\n subscribe: () => { },\n getSnapshot: () => null,\n wrappedSelector: () => true\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {useRouter} from './espRouterContextProvider';\n\nexport interface ViewBinderProps {\n model: any;\n viewContext: string;\n}\n\nexport const ViewBinder: React.FC<ViewBinderProps> = ({model, viewContext, ...rest}) => {\n if (model) {\n const router = useRouter();\n const newProps = Object.assign({}, {model, router}, rest);\n return createViewForModel(\n model,\n newProps,\n viewContext,\n null\n );\n }\n return null;\n};","import {useRouter} from './espRouterContextProvider';\nimport {EspModelContextProvider} from './espModelContextProvider';\nimport {Logger, Router} from 'esp-js';\nimport * as React from 'react';\nimport {modelSelectorOptions, useModelSelector} from './useModelSelector';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';\n\nconst _log = Logger.create('ViewBinderConnectable');\n\nexport interface ViewBinderConnectableProps {\n modelId?: string;\n viewContext?: string;\n view?: React.ComponentType;\n}\n\ninterface ViewBinderConnectableChildProps {\n modelId: string;\n model: object;\n router: Router;\n}\n\n/**\n * Dynamically binds a view found via @viewBinder(SomeJsXView) to a model managed by the Router.\n * Optionally provide a view override and/or a viewContext\n * @param modelId\n * @param viewContext\n * @param view\n * @constructor\n */\nexport const ViewBinderConnectable = ({modelId, viewContext, view}: ViewBinderConnectableProps) => {\n const router = useRouter();\n const model = useModelSelector<object, object>(\n m => m,\n modelSelectorOptions()\n .setModelId(modelId)\n .setTryPreSelectPolimerImmutableModel(false)\n );\n if (!model) {\n return null;\n }\n let immutableModel = tryGetPolimerImmutableModel<object>(model);\n const childProps: ViewBinderConnectableChildProps = {\n modelId,\n router: router,\n model: immutableModel\n };\n let viewElement = createViewForModel(model, childProps, viewContext, view);\n return (\n <EspModelContextProvider modelId={modelId} router={router} model={immutableModel} {...childProps}>\n {viewElement}\n </EspModelContextProvider>\n );\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {Guard} from 'esp-js';\n\nexport const DEFAULT_VIEW_KEY = 'default-view-key';\n\nfunction getMetadata(target) {\n if (!target._viewMetadata) {\n target._viewMetadata = new ViewMetadata();\n }\n return target._viewMetadata;\n}\n\n/**\n * Tries to get a view for the given model.\n *\n * It does this using the following order:\n * 1) If a @viewBinding decorator was used and a display context was given, try get a view for that\n * 2) Else if a view was explicitly provided use that\n * 3) Else if a @viewBinding decorator was used and there is a view associated with the default display context, use that view\n * @param model\n * @param props\n * @param displayContext\n * @param view\n */\nexport function createViewForModel(model: any, props, displayContext: string, view: React.ComponentType) {\n let finalView: React.ComponentType = view; // default to that passed in, if any.\n\n // displayContext = displayContext || DEFAULT_VIEW_KEY;\n // the view decorator isn't on the instance, it's on the constructor function that created that instance\n if (model) {\n let constructorFunction = model.constructor;\n if (constructorFunction._viewMetadata) {\n let viewMetadata = constructorFunction._viewMetadata;\n if (displayContext && viewMetadata.hasRegisteredViewContext(displayContext)) {\n let viewMetadataRegistration = viewMetadata.viewRegistrations[displayContext];\n // we've found a view for the display context, use that\n finalView = viewMetadataRegistration.view;\n }\n\n // if we've not found a view yet, and one wasn't provided, is there a default one?\n if (!finalView && viewMetadata.hasRegisteredViewContext(DEFAULT_VIEW_KEY)) {\n let viewMetadataRegistration = viewMetadata.viewRegistrations[DEFAULT_VIEW_KEY];\n finalView = viewMetadataRegistration.view;\n }\n }\n }\n if (!finalView) {\n throw new Error(`No suitable view found for model id '${model.modelId}' using context '${displayContext}'`);\n }\n return React.createElement(finalView, props);\n}\n\n/**\n * An ES7 style decorator that associates a model with a view\n * @param view the react component that will be used to display this model\n * @param displayContext an optional context allowing for different views to display the same model\n * @returns {Function}\n */\nexport function viewBinding(view: any, displayContext: string = DEFAULT_VIEW_KEY) {\n Guard.isDefined(view, 'view must be defined');\n Guard.isString(displayContext, 'displayContext must be a string');\n return function (target) {\n let viewMetadata = getMetadata(target);\n if (viewMetadata.hasRegisteredViewContext(displayContext)) {\n throw new Error(`Context ${displayContext} already registered for view`);\n }\n viewMetadata.viewRegistrations[displayContext] = new ViewMetadataRegistration(view, displayContext);\n };\n}\n\nexport class ViewMetadata {\n private _viewRegistrations = {};\n\n get viewRegistrations() {\n return this._viewRegistrations;\n }\n\n hasRegisteredViewContext(displayContext) {\n return typeof this._viewRegistrations[displayContext] !== 'undefined';\n }\n}\n\nexport class ViewMetadataRegistration {\n\n constructor(private _view, private _displayContext) {\n }\n\n get view() {\n return this._view;\n }\n\n get displayContext() {\n return this._displayContext;\n }\n}","module.exports = __WEBPACK_EXTERNAL_MODULE__152__;","module.exports = __WEBPACK_EXTERNAL_MODULE__43__;","module.exports = __WEBPACK_EXTERNAL_MODULE__155__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n//\n\n// import for side effects\nimport './polimer/polimerModelBuilderExtentsions';\n\nexport {ViewBinder} from './viewBinder';\nexport {\n ViewBinderConnectableProps,\n ViewBinderConnectable\n} from './viewBinderConnectable';\nexport {viewBinding, DEFAULT_VIEW_KEY} from './viewBindingDecorator';\nexport {\n GetEspPolimerImmutableModelMetadata,\n GetEspPolimerImmutableModelConsts,\n getEspPolimerImmutableModel\n} from './polimer/getEspPolimerImmutableModel';\nexport {createViewForModel} from './viewBindingDecorator';\nexport {\n connect,\n ConnectableComponentFactory\n} from './connect';\nexport {\n CreatePublishEventProps,\n MapModelToProps,\n ConnectableComponentProps,\n ConnectableComponentChildProps,\n ConnectableComponent,\n} from './connectableComponent';\nexport {\n UseModelSelector,\n useModelSelector,\n EditableModelSelectorOptions,\n modelSelectorOptions,\n ModelSelectorOptions,\n ModelSelectorEqualityFn,\n} from './useModelSelector';\nexport {\n RouterProvider,\n RouterProviderProps,\n EspRouterContextProvider,\n EspRouterContextProviderProps,\n RouterContext,\n useRouter,\n PublishEventDelegate,\n PublishEventContext,\n usePublishEvent,\n} from './espRouterContextProvider';\nexport {\n useGetModelId,\n GetModelIdDelegate,\n GetModelIdContext,\n useGetModel,\n GetModelDelegate,\n GetModelContext,\n PublishModelEventDelegate,\n PublishModelEventContext,\n usePublishModelEvent,\n PublishModelEventWithEntityKeyDelegate,\n PublishModelEventWithEntityKeyContext,\n usePublishModelEventWithEntityKey,\n EspModelContextProvider,\n EspModelContextProviderProps,\n} from './espModelContextProvider';\n"],"names":[],"sourceRoot":""}
1
+ {"version":3,"file":"esp-react.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACa,MAAM,mBAAO,CAAC,GAAO,EAAE,gBAAgB,+CAA+C;AACnG,wCAAwC,qBAAqB,cAAc,qBAAqB,OAAO,wBAAwB,YAAY,iBAAiB,eAAe,cAAc,OAAO,KAAK,IAAI,OAAO,2BAA2B,cAAc,qBAAqB,WAAW,IAAI,mBAAmB,WAAW,+BAA+B,IAAI,WAAW,iCAAiC,kBAAkB,cAAc,4BAA4B,cAAc,EAAE,YAAY;AACle,aAAa,cAAc,UAAU,MAAM,KAAK;;;;;;;;ACXnC;;AAEb,IAAI,IAAqC;AACzC,EAAE,yCAAyF;AAC3F,EAAE,KAAK,EAEN;;;;;;;;;;;;;;;;;;;;;;ACND,uCAA+B;AAC/B,wDAAiI;AAIjI;;;GAGG;AACI,MAAM,OAAO,GAAG,UACnB,eAAkF,EAClF,uBAAqE;IAErE,OAAO,UAAU,IAAyB;QACtC,OAAO,UAAU,KAAiF;YAC9F,MAAM,EAAC,OAAO,EAAE,WAAW,KAAa,KAAK,EAAb,IAAI,UAAI,KAAK,EAAvC,0BAA+B,CAAQ,CAAC;YAC9C,OAAO,oBAAC,2CAAoB,kBACxB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,uBAAuB,EAChD,eAAe,EAAE,eAAe,IAC5B,IAAI,EACV,CAAC;QACP,CAAC,CAAC;IACN,CAAC,C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Eb,8IAAiB;AACjB,kIAAW;AAEX,0IAAe;AAEf,4JAAwB;AACxB,oJAAoB;AAEpB,sLAAqC;AACrC,8KAAiC;AACjC,0JAAuB","sources":["webpack://esp-js-react/webpack/universalModuleDefinition","webpack://esp-js-react/../../node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.min.js","webpack://esp-js-react/../../node_modules/use-sync-external-store/with-selector.js","webpack://esp-js-react/./src/connect.tsx","webpack://esp-js-react/./src/connectableComponent.tsx","webpack://esp-js-react/./src/espModelContextProvider.tsx","webpack://esp-js-react/./src/espRouterContextProvider.tsx","webpack://esp-js-react/./src/polimer/getEspPolimerImmutableModel.ts","webpack://esp-js-react/./src/polimer/polimerModelBuilderExtentsions.ts","webpack://esp-js-react/./src/useModelSelector.ts","webpack://esp-js-react/./src/viewBinder.tsx","webpack://esp-js-react/./src/viewBindingDecorator.ts","webpack://esp-js-react/external umd \"esp-js\"","webpack://esp-js-react/external umd \"esp-js-polimer\"","webpack://esp-js-react/external umd \"react\"","webpack://esp-js-react/webpack/bootstrap","webpack://esp-js-react/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"esp-js\"), require(\"esp-js-polimer\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"esp-js\", \"esp-js-polimer\", \"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"esp-js-react\"] = factory(require(\"esp-js\"), require(\"esp-js-polimer\"), require(\"react\"));\n\telse\n\t\troot[\"esp-js-react\"] = factory(root[\"esp-js\"], root[\"esp-js-polimer\"], root[\"react\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__152__, __WEBPACK_EXTERNAL_MODULE__43__, __WEBPACK_EXTERNAL_MODULE__155__) => {\nreturn ","/**\n * @license React\n * use-sync-external-store-with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var g=require(\"react\");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;\nexports.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]);\nt(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/use-sync-external-store-with-selector.production.min.js');\n} else {\n module.exports = require('./cjs/use-sync-external-store-with-selector.development.js');\n}\n","import * as React from 'react';\nimport {ConnectableComponent, ConnectableComponentProps, CreatePublishEventProps, MapModelToProps} from './connectableComponent';\n\nexport type ConnectableComponentFactory<TModel, TPublishEventProps, TModelMappedToProps = {}> = (view: React.ComponentType) => (props: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>) => React.JSX.Element;\n\n/**\n * @param mapModelToProps - maps the model to a different structure, that structure is sent as props to the view.\n * @param createPublishEventProps - creates functions to publish events, the structure is sent as props to the view.\n */\nexport const connect = function <TModel, TPublishEventProps, TModelMappedToProps = {}>(\n mapModelToProps?: MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps>,\n createPublishEventProps?: CreatePublishEventProps<TPublishEventProps>\n): ConnectableComponentFactory<TModel, TPublishEventProps, TModelMappedToProps> {\n return function (view: React.ComponentType) {\n return function (props: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>) {\n const {modelId, viewContext, ...rest} = props;\n return <ConnectableComponent\n modelId={modelId}\n view={view}\n viewContext={viewContext}\n createPublishEventProps={createPublishEventProps}\n mapModelToProps={mapModelToProps}\n {...rest}\n />;\n };\n };\n};","import * as React from 'react';\nimport {useRouter} from './espRouterContextProvider';\nimport {useMemo} from 'react';\nimport {Router, utils} from 'esp-js';\nimport {EspModelContextProvider, useGetModelId} from './espModelContextProvider';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';\nimport {modelSelectorOptions, useModelSelector} from './useModelSelector';\n\nexport type CreatePublishEventProps<TPublishEventProps> = (publishModelEvent: (eventType: string, event: any) => void) => TPublishEventProps;\n\nexport type MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps = {}> = (model: TModel, publishEventProps: TPublishEventProps) => TModelMappedToProps;\n\nexport interface ConnectableComponentProps<TModel = {}, TPublishEventProps = {}, TModelMappedToProps = {}> {\n modelId?: string;\n viewContext?: string;\n view?: React.ComponentType;\n createPublishEventProps?: CreatePublishEventProps<TPublishEventProps>;\n mapModelToProps?: MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps>;\n [key: string]: any; // ...rest props, including the result of mapPublish and mapPublish if 'connect' was used\n}\n\nexport interface ConnectableComponentChildProps<TModel = object> {\n modelId: string;\n model: TModel;\n router: Router;\n [key: string]: any; // ...rest props\n}\n\nconst getChildProps = <TModel, TModelMappedToProps, TPublishEventProps>(\n router: Router,\n modelId: string,\n restProps: object,\n initialModel: TModel,\n mapModelToProps: MapModelToProps<TModel, TModelMappedToProps, TPublishEventProps>,\n publishEventProps: TPublishEventProps\n): ConnectableComponentChildProps<TModel> => {\n const model = tryGetPolimerImmutableModel<TModel>(initialModel);\n let childProps = {\n modelId,\n router: router,\n ...restProps,\n ...publishEventProps,\n model\n };\n if (mapModelToProps) {\n childProps = {\n ...childProps,\n ...(mapModelToProps(model, publishEventProps) as TModelMappedToProps)\n };\n }\n return childProps;\n};\n\nexport const ConnectableComponent = <TModel = {}, TPublishEventProps = {}, TModelMappedToProps = {}>(\n {\n modelId,\n mapModelToProps,\n createPublishEventProps,\n view,\n viewContext,\n ...rest\n }: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>\n) => {\n const router = useRouter();\n modelId = modelId || useGetModelId();\n if (utils.stringIsEmpty(modelId) || !router) {\n return null;\n }\n const publishEventProps: TPublishEventProps = useMemo(\n () => {\n if (createPublishEventProps) {\n const publishModelEvent = (eventType: string, event: any) => {\n router.publishEvent(modelId, eventType, event);\n };\n return createPublishEventProps(publishModelEvent);\n }\n return {} as TPublishEventProps;\n },\n [router, modelId]\n );\n const model = useModelSelector<TModel, TModel>(\n m => m,\n modelSelectorOptions()\n .setModelId(modelId)\n .setTryPreSelectPolimerImmutableModel(false)\n );\n if (model == null) {\n return null;\n }\n let childProps = getChildProps(router, modelId, rest, model, mapModelToProps, publishEventProps);\n let viewElement = createViewForModel(model, childProps, viewContext, view);\n return (\n <EspModelContextProvider modelId={modelId} model={model} router={router} {...childProps}>\n {viewElement}\n </EspModelContextProvider>\n );\n};","import * as React from 'react';\nimport {DefaultModelAddress, Router, Status, Logger, utils} from 'esp-js';\nimport {useContext, useCallback, createContext, PropsWithChildren} from 'react';\nimport {useRouter} from './espRouterContextProvider';\n\nconst _log = Logger.create('EspModelContextProvider');\n\nexport type GetModelIdDelegate = () => string;\nexport const GetModelIdContext = createContext<GetModelIdDelegate>(null);\n/**\n * Returns a function to get the ID of the model connected at a higher point in the V-DOM.\n *\n * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.\n */\nexport const useGetModelId = () => useContext(GetModelIdContext)();\n\nexport type GetModelDelegate = <TModel = any, >() => TModel;\nexport const GetModelContext = createContext<GetModelDelegate>(null);\n/**\n * Returns a function which will return the model connected at a higher point in the V-DOM.\n *\n * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.\n */\nexport const useGetModel = <TModel,>() => useContext(GetModelContext)() as TModel;\n\nexport type PublishModelEventDelegate = (eventType: string, event: any) => void;\nexport const PublishModelEventContext = createContext<PublishModelEventDelegate>(null);\n/**\n * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM.\n *\n * Effectively, this is a version of usePublishEvent() which closes over the relevant modelId.\n *\n * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.\n */\nexport const usePublishModelEvent = () => useContext(PublishModelEventContext);\n\nexport type PublishModelEventWithEntityKeyDelegate = (entityKey: string, eventType: string, event: any) => void;\nexport const PublishModelEventWithEntityKeyContext = createContext<PublishModelEventWithEntityKeyDelegate>(null);\n/**\n * 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.\n *\n * Effectively, this is a version of usePublishEvent() which closes over the modelId.\n *\n * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.\n */\nexport const usePublishModelEventWithEntityKey = () => useContext(PublishModelEventWithEntityKeyContext);\n\nexport interface EspModelContextProviderProps {\n modelId: string;\n model?: unknown;\n}\n\n/**\n * Sets up various ESP context so ESP hooks are available below this point in the V-DOM\n *\n * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node.\n * @param modelId\n * @param children\n * @param model\n * @constructor\n */\nexport const EspModelContextProvider = ({modelId, children, model}: PropsWithChildren<EspModelContextProviderProps>) => {\n const router = useRouter();\n const getModelId: () => string = useCallback(() => {\n return modelId;\n }, [router, modelId]);\n const getModel: () => any = useCallback(() => {\n warnIfModelAccessedOutSideDispatchLoop(router, modelId);\n return model;\n }, [model, router, modelId]);\n const publishModelEvent: PublishModelEventDelegate = useCallback((eventType: string, event: any) => {\n router.publishEvent(modelId, eventType, event);\n }, [router, modelId]);\n const publishModelEventWithEntityKey: PublishModelEventWithEntityKeyDelegate = useCallback((entityKey: string, eventType: string, event: any) => {\n router.publishEvent(new DefaultModelAddress(modelId, entityKey), eventType, event);\n }, [router, modelId]);\n return (\n <GetModelIdContext.Provider value={getModelId}>\n <PublishModelEventContext.Provider value={publishModelEvent}>\n <PublishModelEventWithEntityKeyContext.Provider value={publishModelEventWithEntityKey}>\n <GetModelContext.Provider value={getModel}>\n {children}\n </GetModelContext.Provider>\n </PublishModelEventWithEntityKeyContext.Provider>\n </PublishModelEventContext.Provider>\n </GetModelIdContext.Provider>\n );\n};\n\nconst warnIfModelAccessedOutSideDispatchLoop = (router: Router, modelId: string) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (utils.stringIsEmpty(modelId)) {\n return;\n }\n let isDispatchModelUpdateStatus = router.isModelDispatchStatus(modelId, Status.DispatchModelUpdates);\n if (!isDispatchModelUpdateStatus) {\n let stack: string | undefined = undefined;\n try {\n // noinspection ExceptionCaughtLocallyJS\n throw new Error();\n } catch (e) {\n stack = (e as Error).stack;\n }\n _log.warn(\n `EspModelContextProvider useGetModelId has been invoked outside of the models (${modelId}) dispatch loop. ` +\n `This may have unknown state issues.` +\n stack\n );\n }\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {ModelAddress, Router} from 'esp-js';\nimport {PropsWithChildren, createContext, useContext, useCallback} from 'react';\n\nexport const RouterContext = createContext<Router>(null);\n\n/**\n * Get the esp Router from context.\n *\n * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node:\n *\n * <EspRouterContextProvider router={router}>\n * <YourComponents />\n * </EspRouterContextProvider>\n */\nexport const useRouter = () => {\n const context: Router = useContext(RouterContext);\n if (context === undefined) {\n throw new Error('useRouter must be used within a RouterContext.Provider');\n }\n return context;\n};\n\nexport type PublishEventDelegate = (modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any) => void;\nexport const PublishEventContext = createContext<PublishEventDelegate>(null);\n\n/**\n * Returns a function which can be used to publish an event.\n *\n * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node:\n *\n * <EspRouterContextProvider router={router}>\n * <YourComponents />\n * </EspRouterContextProvider>\n */\nexport const usePublishEvent = () => useContext(PublishEventContext);\n\nexport type EspRouterContextProviderProps = PropsWithChildren<{ router: Router; }>;\n\n/**\n * Used to set the router on the RouterContext making it available to components down the tree via the useRouter() hook.\n *\n * Also sets up the usePublishEvent() hook so nested components can publish to the router.\n */\nexport const EspRouterContextProvider = ({children, router}: EspRouterContextProviderProps) => {\n const publishEvent: PublishEventDelegate = useCallback((modelIdOrModelAddress: string, eventType: string, event: any) => {\n router.publishEvent(modelIdOrModelAddress, eventType, event);\n }, [router]);\n return (\n <RouterContext.Provider value={router}>\n <PublishEventContext.Provider value={publishEvent}>\n {children}\n </PublishEventContext.Provider>\n </RouterContext.Provider>\n );\n};\n\n/**\n * Used to set the router on the RouterContext making it available to components down the tree (via useRouter()).\n *\n * @deprecated use EspRouterContextProvider\n */\nexport const RouterProvider = EspRouterContextProvider;\n\n/**\n * Props for RouterProvider\n *\n * @deprecated use EspRouterContextProviderProps\n */\nexport type RouterProviderProps = EspRouterContextProviderProps;\n","import {EspMetadata, EspDecoratorUtil, utils} from 'esp-js';\n\nexport interface GetEspPolimerImmutableModelMetadata {\n functionName: string;\n}\n\nexport namespace GetEspPolimerImmutableModelConsts {\n export const CustomDataKey = 'GetEspReactImmutableModelCustomDataKey';\n /**\n * If there is no @getEspPolimerImmutableModel decorator and a function by this name exists on a model, then it will be invoked to identify the sub model which will replaced the `model` prop passed to the child view of a ConnectableComponent\n */\n export const HandlerFunctionName = 'getEspPolimerImmutableModel';\n}\n\n/**\n * A decorator which can be used to identify the render model which will replaced the `model` prop passed to the child view of a ConnectableComponent\n */\nexport function getEspPolimerImmutableModel() {\n return function (target, name, descriptor) {\n let metadata: EspMetadata = EspDecoratorUtil.getOrCreateMetaData(target.constructor);\n metadata.addCustomData(\n GetEspPolimerImmutableModelConsts.CustomDataKey,\n <GetEspPolimerImmutableModelMetadata>{ functionName: name }\n );\n return descriptor;\n };\n}\n\n/**\n * Returns the model which will be used to pluck state/props for the current view.\n *\n * This is basically a hook (not a React 'hook') to call a function on `model` and get a new subgraph to use as state.\n *\n */\nexport const tryGetPolimerImmutableModel = <TImmutableModel>(model: any): TImmutableModel => {\n // does the given model have a decorated function we can invoke to get a different model to render?\n if (EspDecoratorUtil.hasMetadata(model)) {\n let metadata: GetEspPolimerImmutableModelMetadata = EspDecoratorUtil.getCustomData(model, GetEspPolimerImmutableModelConsts.CustomDataKey);\n if (metadata) {\n return model[metadata.functionName]();\n }\n }\n // else see if there is a function with name GetEspPolimerImmutableModelConsts.HandlerFunctionName we can invoke to get a different model to render?\n let immutableModel = model[GetEspPolimerImmutableModelConsts.HandlerFunctionName];\n if (immutableModel && utils.isFunction(immutableModel)) {\n return immutableModel.call(model);\n }\n // else return the initial model passed in\n return model;\n};","import {PolimerModelBuilder, PolimerModel} from 'esp-js-polimer';\nimport {DEFAULT_VIEW_KEY, viewBinding} from '../viewBindingDecorator';\n\ndeclare module 'esp-js-polimer/.dist/typings/modelBuilderUpdater' {\n export interface PolimerModelBuilder<TModel> {\n withViewBindings?(view: any, displayContext?: string): PolimerModelBuilder<TModel>;\n }\n}\n\ninterface ViewMappings {\n [displayContext: string]: any;\n}\n\nPolimerModelBuilder.prototype.withViewBindings = function (view: any, displayContext: string = DEFAULT_VIEW_KEY): PolimerModelBuilder<any> {\n let builder = this;\n // store some metadata on the builder which we'll use later to tack onto the model\n let viewMappings: ViewMappings = builder._viewMappings || { };\n viewMappings[displayContext] = view;\n builder._viewMappings = viewMappings;\n return this;\n};\n\n// we need to replace the registerWithRouter in order to dynamically add the\n// @viewBinding decorator to it\nlet registerWithRouter = PolimerModelBuilder.prototype.registerWithRouter;\nPolimerModelBuilder.prototype.registerWithRouter = function (): PolimerModel<any> {\n let builder = this;\n let model = registerWithRouter.call(builder);\n let viewMappings: ViewMappings = builder._viewMappings;\n if (viewMappings) {\n Object.keys(viewMappings).forEach(displayContext => {\n viewBinding(viewMappings[displayContext], displayContext)(model.constructor);\n });\n }\n return model;\n};\n","import {useMemo} from 'react';\nimport {useSyncExternalStoreWithSelector} from 'use-sync-external-store/with-selector';\nimport {Guard, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';\n\nexport type ModelSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\n/**\n * Options affecting the subscription of the model to the Router.\n *\n * Use modelSelectorOptions() to create an instance of this type with sensible defaults.\n *\n * @param modelId - the modelId of the model to be observed via the esp Router.\n * @param tryPreSelectPolimerImmutableModel - if true, and the esp model is an esp-js-polimer model, the immutable model will be used when calling the selector.\n * @param equalityFn - Equality function which will be applied against TSelected, defaults to instance equality (a === b).\n */\nexport type ModelSelectorOptions<TSelected> = {\n modelId?: string,\n tryPreSelectPolimerImmutableModel: boolean,\n equalityFn: ModelSelectorEqualityFn<TSelected>\n};\n\n/**\n * Convenience API to build ModelSelectorOptions<TSelected>, has sensible defaulting.\n */\nexport interface EditableModelSelectorOptions<TSelected> extends ModelSelectorOptions<TSelected> {\n /**\n * Sets the model ID\n * @param modelId - default if unset: undefined\n */\n setModelId(modelId: string): this;\n\n /**\n * If the model is a PolimerModel and this set true, PolimerModel.getImmutableModel() will be selected by default.\n * @param value - default if unset: true\n */\n setTryPreSelectPolimerImmutableModel(value: boolean): this;\n\n /**\n * Equality function used when comparing the last TSelected with the next.\n * @param fn - default if unset: obj instance equality (e.g. a===b)\n */\n setEqualityFn(fn: (a: TSelected, b: TSelected) => boolean): this;\n}\n\n/**\n * Convenience API to create ModelSelectorOptions\n */\nexport const modelSelectorOptions = <TSelected>() => {\n let modelId = undefined;\n let equalityFn: ModelSelectorEqualityFn<TSelected> = (a: TSelected, b: TSelected) => a === b;\n let tryPreSelectPolimerImmutableModel = true;\n return {\n get modelId() {\n return modelId;\n },\n setModelId(value: string) {\n modelId = value;\n return this;\n },\n get equalityFn() {\n return equalityFn;\n },\n setEqualityFn(value: ModelSelectorEqualityFn<TSelected>) {\n equalityFn = value;\n return this;\n },\n get tryPreSelectPolimerImmutableModel() {\n return tryPreSelectPolimerImmutableModel;\n },\n setTryPreSelectPolimerImmutableModel(value: boolean) {\n tryPreSelectPolimerImmutableModel = value;\n return this;\n }\n } as EditableModelSelectorOptions<TSelected>;\n};\n\n/**\n * A hook which returns model state from the esp Router.\n *\n * This hooks wih observe updates and re-render the component if the model changes.\n *\n * To use this, please ensure your V-DOM has the EspRouterContextProvider at a higher node, and optionally EspModelContextProvider.\n *\n * @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.\n * @param options\n */\nexport type UseModelSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options?: ModelSelectorOptions<TSelected>\n) => TSelected;\n\nexport const useModelSelector: UseModelSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options: ModelSelectorOptions<TSelected> = modelSelectorOptions<TSelected>()\n) => {\n Guard.isFunction(selector, 'You must pass a selector function to connectSelector');\n const router = useRouter();\n const modelId = options?.modelId || useGetModelId();\n const tryPreSelectPolimerImmutableModel = options?.tryPreSelectPolimerImmutableModel;\n const equalityFn = options?.equalityFn;\n const dependencies = useMemo(\n () => {\n // Because of how useSyncExternalStore works, there is an implicit dependency between the subscribe and getSnapshot functions.\n // When the subscription receives the new state from the Router, it can't pass this directly onto getSnapshot, React calls that when it deems it needs to.\n // Given that, we need to cache the state which getSnapshot will return.\n //\n // It's not ideal but shouldn't be a problem as here we've wrapped all these dependent functions inside a single useMemo()\n let model: TModel = null;\n return {\n subscribe: (stateChanged: () => void) => {\n const modelSubscriptionDisposable = router\n .getModelObservable(modelId)\n .subscribe(\n (m: any) => {\n // try and get a submodel to render\n const nextModel = tryPreSelectPolimerImmutableModel\n ? tryGetPolimerImmutableModel(m)\n : m;\n // if the above didn't manage to get a submodel,\n // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change\n model = nextModel === m\n ? Object.create(nextModel)\n : nextModel;\n stateChanged();\n }\n );\n return () => {\n model = null;\n modelSubscriptionDisposable.dispose();\n };\n },\n // React expects getSnapshot to be immutable, it'll only re-render if the instance changes\n getSnapshot: () => {\n return model;\n },\n // While getSnapshot needs to model to be immutable,\n // useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.\n // The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.\n wrappedSelector: (snapshot: TModel) => {\n // The first time this renders, react calls getSnapshot and the selector before the router has pushed a change.\n // In that case, there is no state for any component to process, therefore, we return null;\n return snapshot\n ? selector(snapshot)\n : null;\n }\n };\n },\n // Don't cache check against 'selector' argument as that will likely change unless the caller memoizes it.\n [router, modelId]\n );\n\n // If we don't have a modelId, we still need to return a hook so React doesn't complain.\n // Additionally, we need to let the above expiration (dependencies) run to unsubscribe from any previous subscription.\n if (utils.stringIsEmpty(modelId)) {\n return useSyncExternalStoreWithSelector(\n noopSubscription.subscribe,\n noopSubscription.getSnapshot,\n undefined,\n noopSubscription.wrappedSelector,\n equalityFn\n );\n }\n\n // Docs on useSyncExternalStore https://github.com/reactwg/react-18/discussions/86\n // Redux's usage of this: https://github.com/reduxjs/react-redux/blob/master/src/hooks/useSelector.ts\n // Code: https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js\n return useSyncExternalStoreWithSelector(\n dependencies.subscribe,\n dependencies.getSnapshot,\n undefined,\n dependencies.wrappedSelector,\n equalityFn,\n );\n};\n\nconst noopSubscription = {\n subscribe: () => { },\n getSnapshot: () => null,\n wrappedSelector: () => true\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {useRouter} from './espRouterContextProvider';\n\nexport interface ViewBinderProps {\n model: any;\n viewContext?: string;\n /**\n * ...rest props, these will be passed to the child\n */\n [key: string]: any;\n}\n\n/**\n * Takes a model with a @viewBinding decorator and dynamically crates the view specified by the decorator\n */\nexport const ViewBinder: React.FC<ViewBinderProps> = ({model, viewContext, ...rest}) => {\n if (model) {\n const router = useRouter();\n const newProps = {\n model,\n router,\n ...rest\n };\n return createViewForModel(\n model,\n newProps,\n viewContext,\n null\n );\n }\n return null;\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {Guard} from 'esp-js';\n\nexport const DEFAULT_VIEW_KEY = 'default-view-key';\n\nfunction getMetadata(target) {\n if (!target._viewMetadata) {\n target._viewMetadata = new ViewMetadata();\n }\n return target._viewMetadata;\n}\n\n/**\n * Tries to get a view for the given model.\n *\n * It does this using the following order:\n * 1) If a @viewBinding decorator was used and a display context was given, try get a view for that\n * 2) Else if a view was explicitly provided use that\n * 3) Else if a @viewBinding decorator was used and there is a view associated with the default display context, use that view\n * @param model\n * @param props\n * @param displayContext\n * @param view\n */\nexport function createViewForModel(model: any, props: object, displayContext: string, view: React.ComponentType) {\n let finalView: React.ComponentType = view; // default to that passed in, if any.\n\n // displayContext = displayContext || DEFAULT_VIEW_KEY;\n // the view decorator isn't on the instance, it's on the constructor function that created that instance\n if (model) {\n let constructorFunction = model.constructor;\n if (constructorFunction._viewMetadata) {\n let viewMetadata = constructorFunction._viewMetadata;\n if (displayContext && viewMetadata.hasRegisteredViewContext(displayContext)) {\n let viewMetadataRegistration = viewMetadata.viewRegistrations[displayContext];\n // we've found a view for the display context, use that\n finalView = viewMetadataRegistration.view;\n }\n\n // if we've not found a view yet, and one wasn't provided, is there a default one?\n if (!finalView && viewMetadata.hasRegisteredViewContext(DEFAULT_VIEW_KEY)) {\n let viewMetadataRegistration = viewMetadata.viewRegistrations[DEFAULT_VIEW_KEY];\n finalView = viewMetadataRegistration.view;\n }\n }\n }\n if (!finalView) {\n throw new Error(`No suitable view found for model id '${model.modelId}' using context '${displayContext}'`);\n }\n return React.createElement(finalView, props);\n}\n\n/**\n * An ES7 style decorator that associates a model with a view\n * @param view the react component that will be used to display this model\n * @param displayContext an optional context allowing for different views to display the same model\n * @returns {Function}\n */\nexport function viewBinding(view: any, displayContext: string = DEFAULT_VIEW_KEY) {\n Guard.isDefined(view, 'view must be defined');\n Guard.isString(displayContext, 'displayContext must be a string');\n return function (target: any) {\n let viewMetadata = getMetadata(target);\n if (viewMetadata.hasRegisteredViewContext(displayContext)) {\n throw new Error(`Context ${displayContext} already registered for view`);\n }\n viewMetadata.viewRegistrations[displayContext] = new ViewMetadataRegistration(view, displayContext);\n };\n}\n\nexport class ViewMetadata {\n private _viewRegistrations = {};\n\n get viewRegistrations() {\n return this._viewRegistrations;\n }\n\n hasRegisteredViewContext(displayContext) {\n return typeof this._viewRegistrations[displayContext] !== 'undefined';\n }\n}\n\nexport class ViewMetadataRegistration {\n\n constructor(private _view, private _displayContext) {\n }\n\n get view() {\n return this._view;\n }\n\n get displayContext() {\n return this._displayContext;\n }\n}","module.exports = __WEBPACK_EXTERNAL_MODULE__152__;","module.exports = __WEBPACK_EXTERNAL_MODULE__43__;","module.exports = __WEBPACK_EXTERNAL_MODULE__155__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n//\n\n// import for side effects\nimport './polimer/polimerModelBuilderExtentsions';\n\nexport {ViewBinder} from './viewBinder';\nexport {viewBinding, DEFAULT_VIEW_KEY} from './viewBindingDecorator';\nexport {\n GetEspPolimerImmutableModelMetadata,\n GetEspPolimerImmutableModelConsts,\n getEspPolimerImmutableModel\n} from './polimer/getEspPolimerImmutableModel';\nexport {createViewForModel} from './viewBindingDecorator';\nexport {\n connect,\n ConnectableComponentFactory\n} from './connect';\nexport {\n CreatePublishEventProps,\n MapModelToProps,\n ConnectableComponentProps,\n ConnectableComponentChildProps,\n ConnectableComponent,\n} from './connectableComponent';\nexport {\n UseModelSelector,\n useModelSelector,\n EditableModelSelectorOptions,\n modelSelectorOptions,\n ModelSelectorOptions,\n ModelSelectorEqualityFn,\n} from './useModelSelector';\nexport {\n RouterProvider,\n RouterProviderProps,\n EspRouterContextProvider,\n EspRouterContextProviderProps,\n RouterContext,\n useRouter,\n PublishEventDelegate,\n PublishEventContext,\n usePublishEvent,\n} from './espRouterContextProvider';\nexport {\n useGetModelId,\n GetModelIdDelegate,\n GetModelIdContext,\n useGetModel,\n GetModelDelegate,\n GetModelContext,\n PublishModelEventDelegate,\n PublishModelEventContext,\n usePublishModelEvent,\n PublishModelEventWithEntityKeyDelegate,\n PublishModelEventWithEntityKeyContext,\n usePublishModelEventWithEntityKey,\n EspModelContextProvider,\n EspModelContextProviderProps,\n} from './espModelContextProvider';\n"],"names":[],"sourceRoot":""}
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see esp-react.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("esp-js"),require("esp-js-polimer"),require("react")):"function"==typeof define&&define.amd?define(["esp-js","esp-js-polimer","react"],t):"object"==typeof exports?exports["esp-js-react"]=t(require("esp-js"),require("esp-js-polimer"),require("react")):e["esp-js-react"]=t(e["esp-js"],e["esp-js-polimer"],e.react)}(self,((e,t,r)=>(()=>{"use strict";var o={774:(e,t,r)=>{var o=r(155);var n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=o.useSyncExternalStore,l=o.useRef,u=o.useEffect,s=o.useMemo,d=o.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,r,o,a){var c=l(null);if(null===c.current){var b={hasValue:!1,value:null};c.current=b}else b=c.current;c=s((function(){function e(e){if(!u){if(u=!0,i=e,e=o(e),void 0!==a&&b.hasValue){var t=b.value;if(a(t,e))return l=t}return l=e}if(t=l,n(i,e))return t;var r=o(e);return void 0!==a&&a(t,r)?t:(i=e,l=r)}var i,l,u=!1,s=void 0===r?null:r;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,r,o,a]);var v=i(e,c[0],c[1]);return u((function(){b.hasValue=!0,b.value=v}),[v]),d(v),v}},614:(e,t,r)=>{e.exports=r(774)},746:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.connect=void 0;const n=r(155),i=r(397);t.connect=function(e,t){return function(r){return function(l){const{modelId:u,viewContext:s}=l,d=o(l,["modelId","viewContext"]);return n.createElement(i.ConnectableComponent,Object.assign({modelId:u,view:r,viewContext:s,createPublishEventProps:t,mapModelToProps:e},d))}}}},397:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectableComponent=void 0;const n=r(155),i=r(169),l=r(155),u=r(152),s=r(963),d=r(213),a=r(894),c=r(743);t.ConnectableComponent=e=>{var{modelId:t,mapModelToProps:r,createPublishEventProps:b,view:v,viewContext:p}=e,m=o(e,["modelId","mapModelToProps","createPublishEventProps","view","viewContext"]);const f=(0,i.useRouter)();if(t=t||(0,s.useGetModelId)(),u.utils.stringIsEmpty(t)||!f)return null;const P=(0,l.useMemo)((()=>{if(b){return b(((e,r)=>{f.publishEvent(t,e,r)}))}return{}}),[f,t]),E=(0,c.useModelSelector)((e=>e),(0,c.modelSelectorOptions)().setModelId(t).setTryPreSelectPolimerImmutableModel(!1));if(null==E)return null;let M=((e,t,r,o,n,i)=>{const l=(0,a.tryGetPolimerImmutableModel)(o);let u=Object.assign(Object.assign(Object.assign({modelId:t,router:e},r),i),{model:l});return n&&(u=Object.assign(Object.assign({},u),n(l,i))),u})(f,t,m,E,r,P),y=(0,d.createViewForModel)(E,M,p,v);return n.createElement(s.EspModelContextProvider,Object.assign({modelId:t,model:E,router:f},M),y)}},963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EspModelContextProvider=t.usePublishModelEventWithEntityKey=t.PublishModelEventWithEntityKeyContext=t.usePublishModelEvent=t.PublishModelEventContext=t.useGetModel=t.GetModelContext=t.useGetModelId=t.GetModelIdContext=void 0;const o=r(155),n=r(152),i=r(155),l=r(169);n.Logger.create("EspModelContextProvider");t.GetModelIdContext=(0,i.createContext)(null);t.useGetModelId=()=>(0,i.useContext)(t.GetModelIdContext)(),t.GetModelContext=(0,i.createContext)(null);t.useGetModel=()=>(0,i.useContext)(t.GetModelContext)(),t.PublishModelEventContext=(0,i.createContext)(null);t.usePublishModelEvent=()=>(0,i.useContext)(t.PublishModelEventContext),t.PublishModelEventWithEntityKeyContext=(0,i.createContext)(null);t.usePublishModelEventWithEntityKey=()=>(0,i.useContext)(t.PublishModelEventWithEntityKeyContext);t.EspModelContextProvider=({modelId:e,children:r,model:s})=>{const d=(0,l.useRouter)(),a=(0,i.useCallback)((()=>e),[d,e]),c=(0,i.useCallback)((()=>(u(d,e),s)),[s,d,e]),b=(0,i.useCallback)(((t,r)=>{d.publishEvent(e,t,r)}),[d,e]),v=(0,i.useCallback)(((t,r,o)=>{d.publishEvent(new n.DefaultModelAddress(e,t),r,o)}),[d,e]);return o.createElement(t.GetModelIdContext.Provider,{value:a},o.createElement(t.PublishModelEventContext.Provider,{value:b},o.createElement(t.PublishModelEventWithEntityKeyContext.Provider,{value:v},o.createElement(t.GetModelContext.Provider,{value:c},r))))};const u=(e,t)=>{}},169:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RouterProvider=t.EspRouterContextProvider=t.usePublishEvent=t.PublishEventContext=t.useRouter=t.RouterContext=void 0;const o=r(155),n=r(155);t.RouterContext=(0,n.createContext)(null);t.useRouter=()=>{const e=(0,n.useContext)(t.RouterContext);if(void 0===e)throw new Error("useRouter must be used within a RouterContext.Provider");return e},t.PublishEventContext=(0,n.createContext)(null);t.usePublishEvent=()=>(0,n.useContext)(t.PublishEventContext);t.EspRouterContextProvider=({children:e,router:r})=>{const i=(0,n.useCallback)(((e,t,o)=>{r.publishEvent(e,t,o)}),[r]);return o.createElement(t.RouterContext.Provider,{value:r},o.createElement(t.PublishEventContext.Provider,{value:i},e))},t.RouterProvider=t.EspRouterContextProvider},894:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tryGetPolimerImmutableModel=t.GetEspPolimerImmutableModelConsts=void 0,t.getEspPolimerImmutableModel=function(){return function(e,t,r){return o.EspDecoratorUtil.getOrCreateMetaData(e.constructor).addCustomData(n.CustomDataKey,{functionName:t}),r}};const o=r(152);var n;!function(e){e.CustomDataKey="GetEspReactImmutableModelCustomDataKey",e.HandlerFunctionName="getEspPolimerImmutableModel"}(n||(t.GetEspPolimerImmutableModelConsts=n={}));t.tryGetPolimerImmutableModel=e=>{if(o.EspDecoratorUtil.hasMetadata(e)){let t=o.EspDecoratorUtil.getCustomData(e,n.CustomDataKey);if(t)return e[t.functionName]()}let t=e[n.HandlerFunctionName];return t&&o.utils.isFunction(t)?t.call(e):e}},185:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const o=r(43),n=r(213);o.PolimerModelBuilder.prototype.withViewBindings=function(e,t=n.DEFAULT_VIEW_KEY){let r=this._viewMappings||{};return r[t]=e,this._viewMappings=r,this};let i=o.PolimerModelBuilder.prototype.registerWithRouter;o.PolimerModelBuilder.prototype.registerWithRouter=function(){let e=i.call(this),t=this._viewMappings;return t&&Object.keys(t).forEach((r=>{(0,n.viewBinding)(t[r],r)(e.constructor)})),e}},743:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useModelSelector=t.modelSelectorOptions=void 0;const o=r(155),n=r(614),i=r(152),l=r(169),u=r(963),s=r(894);t.modelSelectorOptions=()=>{let e,t=(e,t)=>e===t,r=!0;return{get modelId(){return e},setModelId(t){return e=t,this},get equalityFn(){return t},setEqualityFn(e){return t=e,this},get tryPreSelectPolimerImmutableModel(){return r},setTryPreSelectPolimerImmutableModel(e){return r=e,this}}};t.useModelSelector=(e,r=(0,t.modelSelectorOptions)())=>{i.Guard.isFunction(e,"You must pass a selector function to connectSelector");const a=(0,l.useRouter)(),c=(null==r?void 0:r.modelId)||(0,u.useGetModelId)(),b=null==r?void 0:r.tryPreSelectPolimerImmutableModel,v=null==r?void 0:r.equalityFn,p=(0,o.useMemo)((()=>{let t=null;return{subscribe:e=>{const r=a.getModelObservable(c).subscribe((r=>{const o=b?(0,s.tryGetPolimerImmutableModel)(r):r;t=o===r?Object.create(o):o,e()}));return()=>{t=null,r.dispose()}},getSnapshot:()=>t,wrappedSelector:t=>t?e(t):null}}),[a,c]);return i.utils.stringIsEmpty(c)?(0,n.useSyncExternalStoreWithSelector)(d.subscribe,d.getSnapshot,void 0,d.wrappedSelector,v):(0,n.useSyncExternalStoreWithSelector)(p.subscribe,p.getSnapshot,void 0,p.wrappedSelector,v)};const d={subscribe:()=>{},getSnapshot:()=>null,wrappedSelector:()=>!0}},453:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.ViewBinder=void 0;const n=r(213),i=r(169);t.ViewBinder=e=>{var{model:t,viewContext:r}=e,l=o(e,["model","viewContext"]);if(t){const e=(0,i.useRouter)(),o=Object.assign({},{model:t,router:e},l);return(0,n.createViewForModel)(t,o,r,null)}return null}},639:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ViewBinderConnectable=void 0;const o=r(169),n=r(963),i=r(152),l=r(155),u=r(743),s=r(213),d=r(894);i.Logger.create("ViewBinderConnectable");t.ViewBinderConnectable=({modelId:e,viewContext:t,view:r})=>{const i=(0,o.useRouter)(),a=(0,u.useModelSelector)((e=>e),(0,u.modelSelectorOptions)().setModelId(e).setTryPreSelectPolimerImmutableModel(!1));if(!a)return null;let c=(0,d.tryGetPolimerImmutableModel)(a);const b={modelId:e,router:i,model:c};let v=(0,s.createViewForModel)(a,b,t,r);return l.createElement(n.EspModelContextProvider,Object.assign({modelId:e,router:i,model:c},b),v)}},213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ViewMetadataRegistration=t.ViewMetadata=t.DEFAULT_VIEW_KEY=void 0,t.createViewForModel=function(e,r,n,i){let l=i;if(e){let r=e.constructor;if(r._viewMetadata){let e=r._viewMetadata;if(n&&e.hasRegisteredViewContext(n)){l=e.viewRegistrations[n].view}if(!l&&e.hasRegisteredViewContext(t.DEFAULT_VIEW_KEY)){l=e.viewRegistrations[t.DEFAULT_VIEW_KEY].view}}}if(!l)throw new Error(`No suitable view found for model id '${e.modelId}' using context '${n}'`);return o.createElement(l,r)},t.viewBinding=function(e,r=t.DEFAULT_VIEW_KEY){return n.Guard.isDefined(e,"view must be defined"),n.Guard.isString(r,"displayContext must be a string"),function(t){let o=function(e){e._viewMetadata||(e._viewMetadata=new i);return e._viewMetadata}(t);if(o.hasRegisteredViewContext(r))throw new Error(`Context ${r} already registered for view`);o.viewRegistrations[r]=new l(e,r)}};const o=r(155),n=r(152);t.DEFAULT_VIEW_KEY="default-view-key";class i{constructor(){this._viewRegistrations={}}get viewRegistrations(){return this._viewRegistrations}hasRegisteredViewContext(e){return void 0!==this._viewRegistrations[e]}}t.ViewMetadata=i;class l{constructor(e,t){this._view=e,this._displayContext=t}get view(){return this._view}get displayContext(){return this._displayContext}}t.ViewMetadataRegistration=l},152:t=>{t.exports=e},43:e=>{e.exports=t},155:e=>{e.exports=r}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e].call(r.exports,r,r.exports,i),r.exports}var l={};return(()=>{var e=l;Object.defineProperty(e,"__esModule",{value:!0}),e.EspModelContextProvider=e.usePublishModelEventWithEntityKey=e.PublishModelEventWithEntityKeyContext=e.usePublishModelEvent=e.PublishModelEventContext=e.GetModelContext=e.useGetModel=e.GetModelIdContext=e.useGetModelId=e.usePublishEvent=e.PublishEventContext=e.useRouter=e.RouterContext=e.EspRouterContextProvider=e.RouterProvider=e.modelSelectorOptions=e.useModelSelector=e.ConnectableComponent=e.connect=e.createViewForModel=e.getEspPolimerImmutableModel=e.GetEspPolimerImmutableModelConsts=e.DEFAULT_VIEW_KEY=e.viewBinding=e.ViewBinderConnectable=e.ViewBinder=void 0,i(185);var t=i(453);Object.defineProperty(e,"ViewBinder",{enumerable:!0,get:function(){return t.ViewBinder}});var r=i(639);Object.defineProperty(e,"ViewBinderConnectable",{enumerable:!0,get:function(){return r.ViewBinderConnectable}});var o=i(213);Object.defineProperty(e,"viewBinding",{enumerable:!0,get:function(){return o.viewBinding}}),Object.defineProperty(e,"DEFAULT_VIEW_KEY",{enumerable:!0,get:function(){return o.DEFAULT_VIEW_KEY}});var n=i(894);Object.defineProperty(e,"GetEspPolimerImmutableModelConsts",{enumerable:!0,get:function(){return n.GetEspPolimerImmutableModelConsts}}),Object.defineProperty(e,"getEspPolimerImmutableModel",{enumerable:!0,get:function(){return n.getEspPolimerImmutableModel}});var u=i(213);Object.defineProperty(e,"createViewForModel",{enumerable:!0,get:function(){return u.createViewForModel}});var s=i(746);Object.defineProperty(e,"connect",{enumerable:!0,get:function(){return s.connect}});var d=i(397);Object.defineProperty(e,"ConnectableComponent",{enumerable:!0,get:function(){return d.ConnectableComponent}});var a=i(743);Object.defineProperty(e,"useModelSelector",{enumerable:!0,get:function(){return a.useModelSelector}}),Object.defineProperty(e,"modelSelectorOptions",{enumerable:!0,get:function(){return a.modelSelectorOptions}});var c=i(169);Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return c.RouterProvider}}),Object.defineProperty(e,"EspRouterContextProvider",{enumerable:!0,get:function(){return c.EspRouterContextProvider}}),Object.defineProperty(e,"RouterContext",{enumerable:!0,get:function(){return c.RouterContext}}),Object.defineProperty(e,"useRouter",{enumerable:!0,get:function(){return c.useRouter}}),Object.defineProperty(e,"PublishEventContext",{enumerable:!0,get:function(){return c.PublishEventContext}}),Object.defineProperty(e,"usePublishEvent",{enumerable:!0,get:function(){return c.usePublishEvent}});var b=i(963);Object.defineProperty(e,"useGetModelId",{enumerable:!0,get:function(){return b.useGetModelId}}),Object.defineProperty(e,"GetModelIdContext",{enumerable:!0,get:function(){return b.GetModelIdContext}}),Object.defineProperty(e,"useGetModel",{enumerable:!0,get:function(){return b.useGetModel}}),Object.defineProperty(e,"GetModelContext",{enumerable:!0,get:function(){return b.GetModelContext}}),Object.defineProperty(e,"PublishModelEventContext",{enumerable:!0,get:function(){return b.PublishModelEventContext}}),Object.defineProperty(e,"usePublishModelEvent",{enumerable:!0,get:function(){return b.usePublishModelEvent}}),Object.defineProperty(e,"PublishModelEventWithEntityKeyContext",{enumerable:!0,get:function(){return b.PublishModelEventWithEntityKeyContext}}),Object.defineProperty(e,"usePublishModelEventWithEntityKey",{enumerable:!0,get:function(){return b.usePublishModelEventWithEntityKey}}),Object.defineProperty(e,"EspModelContextProvider",{enumerable:!0,get:function(){return b.EspModelContextProvider}})})(),l})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("esp-js"),require("esp-js-polimer"),require("react")):"function"==typeof define&&define.amd?define(["esp-js","esp-js-polimer","react"],t):"object"==typeof exports?exports["esp-js-react"]=t(require("esp-js"),require("esp-js-polimer"),require("react")):e["esp-js-react"]=t(e["esp-js"],e["esp-js-polimer"],e.react)}(self,((e,t,r)=>(()=>{"use strict";var o={774:(e,t,r)=>{var o=r(155);var n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=o.useSyncExternalStore,l=o.useRef,u=o.useEffect,s=o.useMemo,d=o.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,r,o,a){var c=l(null);if(null===c.current){var b={hasValue:!1,value:null};c.current=b}else b=c.current;c=s((function(){function e(e){if(!u){if(u=!0,i=e,e=o(e),void 0!==a&&b.hasValue){var t=b.value;if(a(t,e))return l=t}return l=e}if(t=l,n(i,e))return t;var r=o(e);return void 0!==a&&a(t,r)?t:(i=e,l=r)}var i,l,u=!1,s=void 0===r?null:r;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,r,o,a]);var v=i(e,c[0],c[1]);return u((function(){b.hasValue=!0,b.value=v}),[v]),d(v),v}},614:(e,t,r)=>{e.exports=r(774)},746:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.connect=void 0;const n=r(155),i=r(397);t.connect=function(e,t){return function(r){return function(l){const{modelId:u,viewContext:s}=l,d=o(l,["modelId","viewContext"]);return n.createElement(i.ConnectableComponent,Object.assign({modelId:u,view:r,viewContext:s,createPublishEventProps:t,mapModelToProps:e},d))}}}},397:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectableComponent=void 0;const n=r(155),i=r(169),l=r(155),u=r(152),s=r(963),d=r(213),a=r(894),c=r(743);t.ConnectableComponent=e=>{var{modelId:t,mapModelToProps:r,createPublishEventProps:b,view:v,viewContext:p}=e,m=o(e,["modelId","mapModelToProps","createPublishEventProps","view","viewContext"]);const f=(0,i.useRouter)();if(t=t||(0,s.useGetModelId)(),u.utils.stringIsEmpty(t)||!f)return null;const P=(0,l.useMemo)((()=>{if(b){return b(((e,r)=>{f.publishEvent(t,e,r)}))}return{}}),[f,t]),E=(0,c.useModelSelector)((e=>e),(0,c.modelSelectorOptions)().setModelId(t).setTryPreSelectPolimerImmutableModel(!1));if(null==E)return null;let M=((e,t,r,o,n,i)=>{const l=(0,a.tryGetPolimerImmutableModel)(o);let u=Object.assign(Object.assign(Object.assign({modelId:t,router:e},r),i),{model:l});return n&&(u=Object.assign(Object.assign({},u),n(l,i))),u})(f,t,m,E,r,P),y=(0,d.createViewForModel)(E,M,p,v);return n.createElement(s.EspModelContextProvider,Object.assign({modelId:t,model:E,router:f},M),y)}},963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EspModelContextProvider=t.usePublishModelEventWithEntityKey=t.PublishModelEventWithEntityKeyContext=t.usePublishModelEvent=t.PublishModelEventContext=t.useGetModel=t.GetModelContext=t.useGetModelId=t.GetModelIdContext=void 0;const o=r(155),n=r(152),i=r(155),l=r(169);n.Logger.create("EspModelContextProvider");t.GetModelIdContext=(0,i.createContext)(null);t.useGetModelId=()=>(0,i.useContext)(t.GetModelIdContext)(),t.GetModelContext=(0,i.createContext)(null);t.useGetModel=()=>(0,i.useContext)(t.GetModelContext)(),t.PublishModelEventContext=(0,i.createContext)(null);t.usePublishModelEvent=()=>(0,i.useContext)(t.PublishModelEventContext),t.PublishModelEventWithEntityKeyContext=(0,i.createContext)(null);t.usePublishModelEventWithEntityKey=()=>(0,i.useContext)(t.PublishModelEventWithEntityKeyContext);t.EspModelContextProvider=({modelId:e,children:r,model:s})=>{const d=(0,l.useRouter)(),a=(0,i.useCallback)((()=>e),[d,e]),c=(0,i.useCallback)((()=>(u(d,e),s)),[s,d,e]),b=(0,i.useCallback)(((t,r)=>{d.publishEvent(e,t,r)}),[d,e]),v=(0,i.useCallback)(((t,r,o)=>{d.publishEvent(new n.DefaultModelAddress(e,t),r,o)}),[d,e]);return o.createElement(t.GetModelIdContext.Provider,{value:a},o.createElement(t.PublishModelEventContext.Provider,{value:b},o.createElement(t.PublishModelEventWithEntityKeyContext.Provider,{value:v},o.createElement(t.GetModelContext.Provider,{value:c},r))))};const u=(e,t)=>{}},169:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RouterProvider=t.EspRouterContextProvider=t.usePublishEvent=t.PublishEventContext=t.useRouter=t.RouterContext=void 0;const o=r(155),n=r(155);t.RouterContext=(0,n.createContext)(null);t.useRouter=()=>{const e=(0,n.useContext)(t.RouterContext);if(void 0===e)throw new Error("useRouter must be used within a RouterContext.Provider");return e},t.PublishEventContext=(0,n.createContext)(null);t.usePublishEvent=()=>(0,n.useContext)(t.PublishEventContext);t.EspRouterContextProvider=({children:e,router:r})=>{const i=(0,n.useCallback)(((e,t,o)=>{r.publishEvent(e,t,o)}),[r]);return o.createElement(t.RouterContext.Provider,{value:r},o.createElement(t.PublishEventContext.Provider,{value:i},e))},t.RouterProvider=t.EspRouterContextProvider},894:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tryGetPolimerImmutableModel=t.GetEspPolimerImmutableModelConsts=void 0,t.getEspPolimerImmutableModel=function(){return function(e,t,r){return o.EspDecoratorUtil.getOrCreateMetaData(e.constructor).addCustomData(n.CustomDataKey,{functionName:t}),r}};const o=r(152);var n;!function(e){e.CustomDataKey="GetEspReactImmutableModelCustomDataKey",e.HandlerFunctionName="getEspPolimerImmutableModel"}(n||(t.GetEspPolimerImmutableModelConsts=n={}));t.tryGetPolimerImmutableModel=e=>{if(o.EspDecoratorUtil.hasMetadata(e)){let t=o.EspDecoratorUtil.getCustomData(e,n.CustomDataKey);if(t)return e[t.functionName]()}let t=e[n.HandlerFunctionName];return t&&o.utils.isFunction(t)?t.call(e):e}},185:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const o=r(43),n=r(213);o.PolimerModelBuilder.prototype.withViewBindings=function(e,t=n.DEFAULT_VIEW_KEY){let r=this._viewMappings||{};return r[t]=e,this._viewMappings=r,this};let i=o.PolimerModelBuilder.prototype.registerWithRouter;o.PolimerModelBuilder.prototype.registerWithRouter=function(){let e=i.call(this),t=this._viewMappings;return t&&Object.keys(t).forEach((r=>{(0,n.viewBinding)(t[r],r)(e.constructor)})),e}},743:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useModelSelector=t.modelSelectorOptions=void 0;const o=r(155),n=r(614),i=r(152),l=r(169),u=r(963),s=r(894);t.modelSelectorOptions=()=>{let e,t=(e,t)=>e===t,r=!0;return{get modelId(){return e},setModelId(t){return e=t,this},get equalityFn(){return t},setEqualityFn(e){return t=e,this},get tryPreSelectPolimerImmutableModel(){return r},setTryPreSelectPolimerImmutableModel(e){return r=e,this}}};t.useModelSelector=(e,r=(0,t.modelSelectorOptions)())=>{i.Guard.isFunction(e,"You must pass a selector function to connectSelector");const a=(0,l.useRouter)(),c=(null==r?void 0:r.modelId)||(0,u.useGetModelId)(),b=null==r?void 0:r.tryPreSelectPolimerImmutableModel,v=null==r?void 0:r.equalityFn,p=(0,o.useMemo)((()=>{let t=null;return{subscribe:e=>{const r=a.getModelObservable(c).subscribe((r=>{const o=b?(0,s.tryGetPolimerImmutableModel)(r):r;t=o===r?Object.create(o):o,e()}));return()=>{t=null,r.dispose()}},getSnapshot:()=>t,wrappedSelector:t=>t?e(t):null}}),[a,c]);return i.utils.stringIsEmpty(c)?(0,n.useSyncExternalStoreWithSelector)(d.subscribe,d.getSnapshot,void 0,d.wrappedSelector,v):(0,n.useSyncExternalStoreWithSelector)(p.subscribe,p.getSnapshot,void 0,p.wrappedSelector,v)};const d={subscribe:()=>{},getSnapshot:()=>null,wrappedSelector:()=>!0}},453:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.ViewBinder=void 0;const n=r(213),i=r(169);t.ViewBinder=e=>{var{model:t,viewContext:r}=e,l=o(e,["model","viewContext"]);if(t){const e=(0,i.useRouter)(),o=Object.assign({model:t,router:e},l);return(0,n.createViewForModel)(t,o,r,null)}return null}},213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ViewMetadataRegistration=t.ViewMetadata=t.DEFAULT_VIEW_KEY=void 0,t.createViewForModel=function(e,r,n,i){let l=i;if(e){let r=e.constructor;if(r._viewMetadata){let e=r._viewMetadata;if(n&&e.hasRegisteredViewContext(n)){l=e.viewRegistrations[n].view}if(!l&&e.hasRegisteredViewContext(t.DEFAULT_VIEW_KEY)){l=e.viewRegistrations[t.DEFAULT_VIEW_KEY].view}}}if(!l)throw new Error(`No suitable view found for model id '${e.modelId}' using context '${n}'`);return o.createElement(l,r)},t.viewBinding=function(e,r=t.DEFAULT_VIEW_KEY){return n.Guard.isDefined(e,"view must be defined"),n.Guard.isString(r,"displayContext must be a string"),function(t){let o=function(e){e._viewMetadata||(e._viewMetadata=new i);return e._viewMetadata}(t);if(o.hasRegisteredViewContext(r))throw new Error(`Context ${r} already registered for view`);o.viewRegistrations[r]=new l(e,r)}};const o=r(155),n=r(152);t.DEFAULT_VIEW_KEY="default-view-key";class i{constructor(){this._viewRegistrations={}}get viewRegistrations(){return this._viewRegistrations}hasRegisteredViewContext(e){return void 0!==this._viewRegistrations[e]}}t.ViewMetadata=i;class l{constructor(e,t){this._view=e,this._displayContext=t}get view(){return this._view}get displayContext(){return this._displayContext}}t.ViewMetadataRegistration=l},152:t=>{t.exports=e},43:e=>{e.exports=t},155:e=>{e.exports=r}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e].call(r.exports,r,r.exports,i),r.exports}var l={};return(()=>{var e=l;Object.defineProperty(e,"__esModule",{value:!0}),e.EspModelContextProvider=e.usePublishModelEventWithEntityKey=e.PublishModelEventWithEntityKeyContext=e.usePublishModelEvent=e.PublishModelEventContext=e.GetModelContext=e.useGetModel=e.GetModelIdContext=e.useGetModelId=e.usePublishEvent=e.PublishEventContext=e.useRouter=e.RouterContext=e.EspRouterContextProvider=e.RouterProvider=e.modelSelectorOptions=e.useModelSelector=e.ConnectableComponent=e.connect=e.createViewForModel=e.getEspPolimerImmutableModel=e.GetEspPolimerImmutableModelConsts=e.DEFAULT_VIEW_KEY=e.viewBinding=e.ViewBinder=void 0,i(185);var t=i(453);Object.defineProperty(e,"ViewBinder",{enumerable:!0,get:function(){return t.ViewBinder}});var r=i(213);Object.defineProperty(e,"viewBinding",{enumerable:!0,get:function(){return r.viewBinding}}),Object.defineProperty(e,"DEFAULT_VIEW_KEY",{enumerable:!0,get:function(){return r.DEFAULT_VIEW_KEY}});var o=i(894);Object.defineProperty(e,"GetEspPolimerImmutableModelConsts",{enumerable:!0,get:function(){return o.GetEspPolimerImmutableModelConsts}}),Object.defineProperty(e,"getEspPolimerImmutableModel",{enumerable:!0,get:function(){return o.getEspPolimerImmutableModel}});var n=i(213);Object.defineProperty(e,"createViewForModel",{enumerable:!0,get:function(){return n.createViewForModel}});var u=i(746);Object.defineProperty(e,"connect",{enumerable:!0,get:function(){return u.connect}});var s=i(397);Object.defineProperty(e,"ConnectableComponent",{enumerable:!0,get:function(){return s.ConnectableComponent}});var d=i(743);Object.defineProperty(e,"useModelSelector",{enumerable:!0,get:function(){return d.useModelSelector}}),Object.defineProperty(e,"modelSelectorOptions",{enumerable:!0,get:function(){return d.modelSelectorOptions}});var a=i(169);Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return a.RouterProvider}}),Object.defineProperty(e,"EspRouterContextProvider",{enumerable:!0,get:function(){return a.EspRouterContextProvider}}),Object.defineProperty(e,"RouterContext",{enumerable:!0,get:function(){return a.RouterContext}}),Object.defineProperty(e,"useRouter",{enumerable:!0,get:function(){return a.useRouter}}),Object.defineProperty(e,"PublishEventContext",{enumerable:!0,get:function(){return a.PublishEventContext}}),Object.defineProperty(e,"usePublishEvent",{enumerable:!0,get:function(){return a.usePublishEvent}});var c=i(963);Object.defineProperty(e,"useGetModelId",{enumerable:!0,get:function(){return c.useGetModelId}}),Object.defineProperty(e,"GetModelIdContext",{enumerable:!0,get:function(){return c.GetModelIdContext}}),Object.defineProperty(e,"useGetModel",{enumerable:!0,get:function(){return c.useGetModel}}),Object.defineProperty(e,"GetModelContext",{enumerable:!0,get:function(){return c.GetModelContext}}),Object.defineProperty(e,"PublishModelEventContext",{enumerable:!0,get:function(){return c.PublishModelEventContext}}),Object.defineProperty(e,"usePublishModelEvent",{enumerable:!0,get:function(){return c.usePublishModelEvent}}),Object.defineProperty(e,"PublishModelEventWithEntityKeyContext",{enumerable:!0,get:function(){return c.PublishModelEventWithEntityKeyContext}}),Object.defineProperty(e,"usePublishModelEventWithEntityKey",{enumerable:!0,get:function(){return c.usePublishModelEventWithEntityKey}}),Object.defineProperty(e,"EspModelContextProvider",{enumerable:!0,get:function(){return c.EspModelContextProvider}})})(),l})()));
3
3
  //# sourceMappingURL=esp-react.min.js.map