esp-js-react 8.0.4-next.0 → 8.0.5-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.
@@ -99,7 +99,6 @@ exports.ConnectableComponent = void 0;
99
99
  const React = __webpack_require__(155);
100
100
  const espRouterContextProvider_1 = __webpack_require__(169);
101
101
  const react_1 = __webpack_require__(155);
102
- const esp_js_1 = __webpack_require__(152);
103
102
  const espModelContextProvider_1 = __webpack_require__(963);
104
103
  const viewBindingDecorator_1 = __webpack_require__(213);
105
104
  const getEspPolimerImmutableModel_1 = __webpack_require__(894);
@@ -115,10 +114,9 @@ const getChildProps = (router, modelId, restProps, initialModel, mapModelToProps
115
114
  const ConnectableComponent = (_a) => {
116
115
  var { modelId, mapModelToProps, createPublishEventProps, view, viewContext } = _a, rest = __rest(_a, ["modelId", "mapModelToProps", "createPublishEventProps", "view", "viewContext"]);
117
116
  const router = (0, espRouterContextProvider_1.useRouter)();
118
- modelId = modelId || (0, espModelContextProvider_1.useGetModelId)();
119
- if (esp_js_1.utils.stringIsEmpty(modelId) || !router) {
120
- return null;
121
- }
117
+ // Note: we always need to render the hooks else react will complain about a different count.
118
+ let modelIdFromContext = (0, espModelContextProvider_1.useGetModelId)();
119
+ modelId = modelId || modelIdFromContext;
122
120
  const publishEventProps = (0, react_1.useMemo)(() => {
123
121
  if (createPublishEventProps) {
124
122
  const publishModelEvent = (eventType, event) => {
@@ -153,7 +151,6 @@ const React = __webpack_require__(155);
153
151
  const esp_js_1 = __webpack_require__(152);
154
152
  const react_1 = __webpack_require__(155);
155
153
  const espRouterContextProvider_1 = __webpack_require__(169);
156
- const _log = esp_js_1.Logger.create('EspModelContextProvider');
157
154
  exports.GetModelIdContext = (0, react_1.createContext)(null);
158
155
  /**
159
156
  * Returns a function to get the ID of the model connected at a higher point in the V-DOM.
@@ -201,6 +198,9 @@ exports.usePublishModelEventWithEntityKey = usePublishModelEventWithEntityKey;
201
198
  */
202
199
  const EspModelContextProvider = ({ modelId, children, model }) => {
203
200
  const router = (0, espRouterContextProvider_1.useRouter)();
201
+ // modelId may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
202
+ let modelIdFromContext = (0, exports.useGetModelId)();
203
+ modelId = modelId || modelIdFromContext;
204
204
  const publishModelEvent = (0, react_1.useCallback)((eventType, event) => {
205
205
  router.publishEvent(modelId, eventType, event);
206
206
  }, [router, modelId]);
@@ -253,11 +253,7 @@ exports.RouterContext = (0, react_1.createContext)(null);
253
253
  * </EspRouterContextProvider>
254
254
  */
255
255
  const useRouter = () => {
256
- const context = (0, react_1.useContext)(exports.RouterContext);
257
- if (context === undefined) {
258
- throw new Error('useRouter must be used within a RouterContext.Provider');
259
- }
260
- return context;
256
+ return (0, react_1.useContext)(exports.RouterContext);
261
257
  };
262
258
  exports.useRouter = useRouter;
263
259
  exports.PublishEventContext = (0, react_1.createContext)(null);
@@ -278,6 +274,9 @@ exports.usePublishEvent = usePublishEvent;
278
274
  * Also sets up the usePublishEvent() hook so nested components can publish to the router.
279
275
  */
280
276
  const EspRouterContextProvider = ({ children, router }) => {
277
+ // Router may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
278
+ let routerFromContext = (0, exports.useRouter)();
279
+ router = router || routerFromContext;
281
280
  const publishEvent = (0, react_1.useCallback)((modelIdOrModelAddress, eventType, event) => {
282
281
  router.publishEvent(modelIdOrModelAddress, eventType, event);
283
282
  }, [router]);
@@ -449,71 +448,91 @@ const checkArguments = (selector, options) => {
449
448
  const useSyncModelWithSelector = (selector, options = (0, exports.syncModelWithSelectorOptions)()) => {
450
449
  checkArguments(selector, options);
451
450
  const router = (0, espRouterContextProvider_1.useRouter)();
452
- const modelId = (options === null || options === void 0 ? void 0 : options.modelId) || (0, espModelContextProvider_1.useGetModelId)();
451
+ const modelIdFromContext = (0, espModelContextProvider_1.useGetModelId)();
452
+ const modelId = (options === null || options === void 0 ? void 0 : options.modelId) || modelIdFromContext;
453
453
  const tryPreSelectPolimerImmutableModel = options === null || options === void 0 ? void 0 : options.tryPreSelectPolimerImmutableModel;
454
454
  const equalityFn = options === null || options === void 0 ? void 0 : options.equalityFn;
455
455
  const dependencies = (0, react_1.useMemo)(() => {
456
- // Because of how useSyncExternalStore works, there is an implicit dependency between the subscribe and getSnapshot functions.
457
- // 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.
458
- // Given that, we need to cache the state which getSnapshot will return.
459
- //
460
- // It's not ideal but shouldn't be a problem as here we've wrapped all these dependent functions inside a single useMemo()
461
- let model = null;
462
- return {
463
- subscribe: (stateChanged) => {
464
- const modelSubscriptionDisposable = router
465
- .getModelObservable(modelId)
466
- .subscribe((m) => {
467
- // try and get a submodel to render
468
- const nextModel = tryPreSelectPolimerImmutableModel
469
- ? (0, getEspPolimerImmutableModel_1.tryGetPolimerImmutableModel)(m)
470
- : m;
471
- // if the above didn't manage to get a submodel,
472
- // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change
473
- model = nextModel === m
474
- ? Object.create(nextModel)
475
- : nextModel;
476
- stateChanged();
477
- });
478
- return () => {
479
- model = null;
480
- modelSubscriptionDisposable.dispose();
481
- };
482
- },
483
- // React expects getSnapshot to be immutable, it'll only re-render if the instance changes
484
- getSnapshot: () => {
485
- return model;
486
- },
487
- // While getSnapshot needs to model to be immutable,
488
- // useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.
489
- // The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.
490
- wrappedSelector: (snapshot) => {
491
- // The first time this renders, react calls getSnapshot and the selector before the router has pushed a change.
492
- // In that case, there is no state for any component to process, therefore, we return null;
493
- return snapshot
494
- ? selector(snapshot)
495
- : null;
496
- }
497
- };
456
+ const canSubscribe = router && esp_js_1.utils.isString(modelId) && router.isModelRegistered(modelId);
457
+ if (canSubscribe) {
458
+ return createSubscriptionState(router, modelId, selector, tryPreSelectPolimerImmutableModel);
459
+ }
460
+ return createNoopSubscriptionState();
498
461
  },
499
- // Don't cache check against 'selector' argument as that will likely change unless the caller memoizes it.
462
+ // Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.
500
463
  [router, modelId]);
501
- // If we don't have a modelId, we still need to return a hook so React doesn't complain.
502
- // Additionally, we need to let the above expiration (dependencies) run to unsubscribe from any previous subscription.
503
- if (esp_js_1.utils.stringIsEmpty(modelId)) {
504
- return (0, with_selector_1.useSyncExternalStoreWithSelector)(noopSubscription.subscribe, noopSubscription.getSnapshot, undefined, noopSubscription.wrappedSelector, equalityFn);
505
- }
506
464
  // Docs on useSyncExternalStore https://github.com/reactwg/react-18/discussions/86
507
465
  // Redux's usage of this: https://github.com/reduxjs/react-redux/blob/master/src/hooks/useSelector.ts
508
466
  // Code: https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
509
- return (0, with_selector_1.useSyncExternalStoreWithSelector)(dependencies.subscribe, dependencies.getSnapshot, undefined, dependencies.wrappedSelector, equalityFn);
467
+ return (0, with_selector_1.useSyncExternalStoreWithSelector)(dependencies.subscribe, dependencies.getSnapshot, undefined, dependencies.wrappedSelector,
468
+ // equalityFn can't be cached (needs to be a new fn each time)
469
+ // It seems that if it is, you get the last value regardless of if dependencies (and it's associated functions) changes.
470
+ equalityFn);
510
471
  };
511
472
  exports.useSyncModelWithSelector = useSyncModelWithSelector;
512
- const noopSubscription = {
513
- subscribe: () => { },
514
- getSnapshot: () => null,
515
- wrappedSelector: () => true
473
+ const createSubscriptionState = (router, modelId, selector, tryPreSelectPolimerImmutableModel) => {
474
+ // Because of how useSyncExternalStore works, there is an implicit dependency between the subscribe and getSnapshot functions.
475
+ // When the subscription receives the new state from the Router, it can't pass this directly onto getSnapshot,
476
+ // React calls that when it deems it needs to.
477
+ // Given that, we need to cache the state which getSnapshot will return.
478
+ //
479
+ // Another edge case with useSyncExternalStore:
480
+ // It will call getSnapshot before it calls subscribe, to account for this we need to fetch the model first.
481
+ // ESP will always dispatch the model when you initially observe it, because we pre-fetched it, the first updated is ignored below.
482
+ const selectModelOrPolimerModel = (m) => {
483
+ // try use get the esp-js-polimer immutable model if possible.
484
+ const nextModel = tryPreSelectPolimerImmutableModel
485
+ ? (0, getEspPolimerImmutableModel_1.tryGetPolimerImmutableModel)(m)
486
+ : m;
487
+ // If the above didn't manage to get a polimer model,
488
+ // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change.
489
+ // This should only affect older style OO models.
490
+ let modelHasNotMutated = nextModel === m;
491
+ return modelHasNotMutated
492
+ ? Object.create(nextModel)
493
+ : nextModel;
494
+ };
495
+ let isFirstRun = true;
496
+ let model = selectModelOrPolimerModel(router.getModel(modelId));
497
+ return {
498
+ subscribe: (stateChanged) => {
499
+ const modelSubscriptionDisposable = router
500
+ .getModelObservable(modelId)
501
+ .map(m => selectModelOrPolimerModel(m))
502
+ .subscribe((m) => {
503
+ if (isFirstRun) {
504
+ isFirstRun = false;
505
+ return;
506
+ }
507
+ model = m;
508
+ stateChanged();
509
+ });
510
+ return () => {
511
+ model = null;
512
+ modelSubscriptionDisposable.dispose();
513
+ };
514
+ },
515
+ // React expects getSnapshot to be immutable, it'll only re-render if the instance changes
516
+ getSnapshot: () => {
517
+ return model;
518
+ },
519
+ // While getSnapshot needs to model to be immutable,
520
+ // useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.
521
+ // The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.
522
+ wrappedSelector: (snapshot) => {
523
+ return snapshot
524
+ ? selector(snapshot)
525
+ : null;
526
+ }
527
+ };
516
528
  };
529
+ const createNoopSubscriptionState = () => ({
530
+ subscribe: () => {
531
+ return () => { };
532
+ },
533
+ getSnapshot: () => null,
534
+ wrappedSelector: () => null
535
+ });
517
536
 
518
537
 
519
538
  /***/ }),
@@ -1 +1 @@
1
- {"version":3,"file":"esp-react.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;A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AEF,0BAA0B;AAC1B,yBAAkD;AAElD,4CAAwC;AAAhC,mHAAU;AAClB,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,0DAMoC;AALhC,6JAAwB;AAExB,qKAA4B;AAIhC,0DAUoC;AAThC,yIAAc;AAEd,6JAAwB;AAExB,uIAAa;AACb,+HAAS;AAET,mJAAmB;AACnB,2IAAe;AAEnB,yDAamC;AAZ/B,sIAAa;AACb,8IAAiB;AACjB,kIAAW;AACX,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/useSyncModelWithSelector.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 {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\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 = useSyncModelWithSelector<TModel, TModel>(\n m => m,\n syncModelWithSelectorOptions()\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 const GetModelIdContext = createContext<string>(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 const GetModelContext = createContext<object>(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?: any;\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 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={modelId}>\n <PublishModelEventContext.Provider value={publishModelEvent}>\n <PublishModelEventWithEntityKeyContext.Provider value={publishModelEventWithEntityKey}>\n <GetModelContext.Provider value={model}>\n {children}\n </GetModelContext.Provider>\n </PublishModelEventWithEntityKeyContext.Provider>\n </PublishModelEventContext.Provider>\n </GetModelIdContext.Provider>\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 SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\n/**\n * Options affecting the subscription of the model to the Router.\n *\n * Use syncModelWithSelectorOptions() 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 SyncModelWithSelectorOptions<TSelected> = {\n modelId?: string,\n tryPreSelectPolimerImmutableModel: boolean,\n equalityFn: SyncModelWithSelectorEqualityFn<TSelected>\n};\n\n/**\n * Convenience API to build SyncModelWithSelectorOptions<TSelected>, has sensible defaulting.\n */\nexport interface SyncModelWithSelectorOptionsBuilder<TSelected> extends SyncModelWithSelectorOptions<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 SyncModelWithSelectorOptions\n */\nexport const syncModelWithSelectorOptions = <TSelected>() => {\n let modelId = undefined;\n let equalityFn: SyncModelWithSelectorEqualityFn<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: SyncModelWithSelectorEqualityFn<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 SyncModelWithSelectorOptionsBuilder<TSelected>;\n};\n\nconst checkArguments = (selector: (model: any) => any, options: SyncModelWithSelectorOptions<any> ) => {\n if (!utils.isFunction(selector)) {\n throw new Error('You must pass a selector function to useSyncModelWithSelector');\n }\n if (!utils.isObject(options)) {\n throw new Error('You must provide options when using useSyncModelWithSelector');\n }\n if (!utils.isFunction(options.equalityFn)) {\n throw new Error('You must provide an equalityFn when using useSyncModelWithSelector');\n }\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 const useSyncModelWithSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options: SyncModelWithSelectorOptions<TSelected> = syncModelWithSelectorOptions<TSelected>()\n): TSelected => {\n checkArguments(selector, options);\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 useSyncModelWithSelector,\n SyncModelWithSelectorOptionsBuilder,\n syncModelWithSelectorOptions,\n SyncModelWithSelectorOptions,\n SyncModelWithSelectorEqualityFn,\n} from './useSyncModelWithSelector';\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 GetModelIdContext,\n useGetModel,\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,MA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B,yBAAkD;AAElD,4CAAwC;AAAhC,mHAAU;AAClB,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,0DAMoC;AALhC,6JAAwB;AAExB,qKAA4B;AAIhC,0DAUoC;AAThC,yIAAc;AAEd,6JAAwB;AAExB,uIAAa;AACb,+HAAS;AAET,mJAAmB;AACnB,2IAAe;AAEnB,yDAamC;AAZ/B,sIAAa;AACb,8IAAiB;AACjB,kIAAW;AACX,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/useSyncModelWithSelector.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 {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\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 // Note: we always need to render the hooks else react will complain about a different count.\n let modelIdFromContext = useGetModelId();\n modelId = modelId || modelIdFromContext;\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 = useSyncModelWithSelector<TModel, TModel>(\n m => m,\n syncModelWithSelectorOptions()\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} from 'esp-js';\nimport {useContext, useCallback, createContext, PropsWithChildren} from 'react';\nimport {useRouter} from './espRouterContextProvider';\n\nexport const GetModelIdContext = createContext<string>(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 const GetModelContext = createContext<object>(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?: any;\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 // modelId may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.\n let modelIdFromContext = useGetModelId();\n modelId = modelId || modelIdFromContext;\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={modelId}>\n <PublishModelEventContext.Provider value={publishModelEvent}>\n <PublishModelEventWithEntityKeyContext.Provider value={publishModelEventWithEntityKey}>\n <GetModelContext.Provider value={model}>\n {children}\n </GetModelContext.Provider>\n </PublishModelEventWithEntityKeyContext.Provider>\n </PublishModelEventContext.Provider>\n </GetModelIdContext.Provider>\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 return useContext(RouterContext);\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 // Router may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.\n let routerFromContext = useRouter();\n router = router || routerFromContext;\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 {Router, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';\n\nexport type SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\n/**\n * Options affecting the subscription of the model to the Router.\n *\n * Use syncModelWithSelectorOptions() 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 SyncModelWithSelectorOptions<TSelected> = {\n modelId?: string,\n tryPreSelectPolimerImmutableModel: boolean,\n equalityFn: SyncModelWithSelectorEqualityFn<TSelected>\n};\n\n/**\n * Convenience API to build SyncModelWithSelectorOptions<TSelected>, has sensible defaulting.\n */\nexport interface SyncModelWithSelectorOptionsBuilder<TSelected> extends SyncModelWithSelectorOptions<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 SyncModelWithSelectorOptions\n */\nexport const syncModelWithSelectorOptions = <TSelected>() => {\n let modelId = undefined;\n let equalityFn: SyncModelWithSelectorEqualityFn<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: SyncModelWithSelectorEqualityFn<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 SyncModelWithSelectorOptionsBuilder<TSelected>;\n};\n\nconst checkArguments = (selector: (model: any) => any, options: SyncModelWithSelectorOptions<any> ) => {\n if (!utils.isFunction(selector)) {\n throw new Error('You must pass a selector function to useSyncModelWithSelector');\n }\n if (!utils.isObject(options)) {\n throw new Error('You must provide options when using useSyncModelWithSelector');\n }\n if (!utils.isFunction(options.equalityFn)) {\n throw new Error('You must provide an equalityFn when using useSyncModelWithSelector');\n }\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 const useSyncModelWithSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options: SyncModelWithSelectorOptions<TSelected> = syncModelWithSelectorOptions<TSelected>()\n): TSelected => {\n checkArguments(selector, options);\n const router = useRouter();\n const modelIdFromContext = useGetModelId();\n const modelId = options?.modelId || modelIdFromContext;\n const tryPreSelectPolimerImmutableModel = options?.tryPreSelectPolimerImmutableModel;\n const equalityFn = options?.equalityFn;\n const dependencies = useMemo(\n () => {\n const canSubscribe = router && utils.isString(modelId) && router.isModelRegistered(modelId);\n if (canSubscribe) {\n return createSubscriptionState(router, modelId, selector, tryPreSelectPolimerImmutableModel);\n }\n return createNoopSubscriptionState();\n },\n // Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.\n [router, modelId]\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 can't be cached (needs to be a new fn each time)\n // It seems that if it is, you get the last value regardless of if dependencies (and it's associated functions) changes.\n equalityFn,\n );\n};\n\nconst createSubscriptionState = <TModel, TSelected>(\n router: Router,\n modelId: string,\n selector: (model: TModel) => TSelected,\n tryPreSelectPolimerImmutableModel: boolean\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,\n // React calls that when it deems it needs to.\n // Given that, we need to cache the state which getSnapshot will return.\n //\n // Another edge case with useSyncExternalStore:\n // It will call getSnapshot before it calls subscribe, to account for this we need to fetch the model first.\n // ESP will always dispatch the model when you initially observe it, because we pre-fetched it, the first updated is ignored below.\n const selectModelOrPolimerModel = (m: any): TModel => {\n // try use get the esp-js-polimer immutable model if possible.\n const nextModel = tryPreSelectPolimerImmutableModel\n ? tryGetPolimerImmutableModel(m)\n : m;\n // If the above didn't manage to get a polimer model,\n // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change.\n // This should only affect older style OO models.\n let modelHasNotMutated = nextModel === m;\n return modelHasNotMutated\n ? Object.create(nextModel)\n : nextModel;\n };\n let isFirstRun = true;\n let model: TModel = selectModelOrPolimerModel(router.getModel(modelId));\n return {\n subscribe: (stateChanged: () => void) => {\n const modelSubscriptionDisposable = router\n .getModelObservable<TModel>(modelId)\n .map(m => selectModelOrPolimerModel(m))\n .subscribe(\n (m: any) => {\n if (isFirstRun) {\n isFirstRun = false;\n return;\n }\n model = m;\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 return snapshot\n ? selector(snapshot)\n : null;\n }\n };\n};\n\nconst createNoopSubscriptionState = () => ({\n subscribe: () => {\n return () => {};\n },\n getSnapshot: () => null,\n wrappedSelector: () => 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 {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 useSyncModelWithSelector,\n SyncModelWithSelectorOptionsBuilder,\n syncModelWithSelectorOptions,\n SyncModelWithSelectorOptions,\n SyncModelWithSelectorEqualityFn,\n} from './useSyncModelWithSelector';\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 GetModelIdContext,\n useGetModel,\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 v={hasValue:!1,value:null};c.current=v}else v=c.current;c=s((function(){function e(e){if(!u){if(u=!0,i=e,e=o(e),void 0!==a&&v.hasValue){var t=v.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 b=i(e,c[0],c[1]);return u((function(){v.hasValue=!0,v.value=b}),[b]),d(b),b}},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(606);t.ConnectableComponent=e=>{var{modelId:t,mapModelToProps:r,createPublishEventProps:v,view:b,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 y=(0,l.useMemo)((()=>{if(v){return v(((e,r)=>{f.publishEvent(t,e,r)}))}return{}}),[f,t]),P=(0,c.useSyncModelWithSelector)((e=>e),(0,c.syncModelWithSelectorOptions)().setModelId(t).setTryPreSelectPolimerImmutableModel(!1));if(null==P)return null;let E=((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,P,r,y),M=(0,d.createViewForModel)(P,E,p,b);return n.createElement(s.EspModelContextProvider,Object.assign({modelId:t,model:P,router:f},E),M)}},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:u})=>{const s=(0,l.useRouter)(),d=(0,i.useCallback)(((t,r)=>{s.publishEvent(e,t,r)}),[s,e]),a=(0,i.useCallback)(((t,r,o)=>{s.publishEvent(new n.DefaultModelAddress(e,t),r,o)}),[s,e]);return o.createElement(t.GetModelIdContext.Provider,{value:e},o.createElement(t.PublishModelEventContext.Provider,{value:d},o.createElement(t.PublishModelEventWithEntityKeyContext.Provider,{value:a},o.createElement(t.GetModelContext.Provider,{value:u},r))))}},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}},606:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useSyncModelWithSelector=t.syncModelWithSelectorOptions=void 0;const o=r(155),n=r(614),i=r(152),l=r(169),u=r(963),s=r(894);t.syncModelWithSelectorOptions=()=>{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.useSyncModelWithSelector=(e,r=(0,t.syncModelWithSelectorOptions)())=>{((e,t)=>{if(!i.utils.isFunction(e))throw new Error("You must pass a selector function to useSyncModelWithSelector");if(!i.utils.isObject(t))throw new Error("You must provide options when using useSyncModelWithSelector");if(!i.utils.isFunction(t.equalityFn))throw new Error("You must provide an equalityFn when using useSyncModelWithSelector")})(e,r);const a=(0,l.useRouter)(),c=(null==r?void 0:r.modelId)||(0,u.useGetModelId)(),v=null==r?void 0:r.tryPreSelectPolimerImmutableModel,b=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=v?(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,b):(0,n.useSyncExternalStoreWithSelector)(p.subscribe,p.getSnapshot,void 0,p.wrappedSelector,b)};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.syncModelWithSelectorOptions=e.useSyncModelWithSelector=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(606);Object.defineProperty(e,"useSyncModelWithSelector",{enumerable:!0,get:function(){return d.useSyncModelWithSelector}}),Object.defineProperty(e,"syncModelWithSelectorOptions",{enumerable:!0,get:function(){return d.syncModelWithSelectorOptions}});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})()));
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,o)=>(()=>{"use strict";var r={774:(e,t,o)=>{var r=o(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=r.useSyncExternalStore,l=r.useRef,u=r.useEffect,s=r.useMemo,d=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,o,r,a){var c=l(null);if(null===c.current){var v={hasValue:!1,value:null};c.current=v}else v=c.current;c=s((function(){function e(e){if(!u){if(u=!0,i=e,e=r(e),void 0!==a&&v.hasValue){var t=v.value;if(a(t,e))return l=t}return l=e}if(t=l,n(i,e))return t;var o=r(e);return void 0!==a&&a(t,o)?t:(i=e,l=o)}var i,l,u=!1,s=void 0===o?null:o;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,o,r,a]);var b=i(e,c[0],c[1]);return u((function(){v.hasValue=!0,v.value=b}),[b]),d(b),b}},614:(e,t,o)=>{e.exports=o(774)},746:function(e,t,o){var r=this&&this.__rest||function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(o[r[n]]=e[r[n]])}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.connect=void 0;const n=o(155),i=o(397);t.connect=function(e,t){return function(o){return function(l){const{modelId:u,viewContext:s}=l,d=r(l,["modelId","viewContext"]);return n.createElement(i.ConnectableComponent,Object.assign({modelId:u,view:o,viewContext:s,createPublishEventProps:t,mapModelToProps:e},d))}}}},397:function(e,t,o){var r=this&&this.__rest||function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(o[r[n]]=e[r[n]])}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectableComponent=void 0;const n=o(155),i=o(169),l=o(155),u=o(963),s=o(213),d=o(894),a=o(606);t.ConnectableComponent=e=>{var{modelId:t,mapModelToProps:o,createPublishEventProps:c,view:v,viewContext:b}=e,p=r(e,["modelId","mapModelToProps","createPublishEventProps","view","viewContext"]);const m=(0,i.useRouter)();let f=(0,u.useGetModelId)();t=t||f;const y=(0,l.useMemo)((()=>{if(c){return c(((e,o)=>{m.publishEvent(t,e,o)}))}return{}}),[m,t]),M=(0,a.useSyncModelWithSelector)((e=>e),(0,a.syncModelWithSelectorOptions)().setModelId(t).setTryPreSelectPolimerImmutableModel(!1));if(null==M)return null;let P=((e,t,o,r,n,i)=>{const l=(0,d.tryGetPolimerImmutableModel)(r);let u=Object.assign(Object.assign(Object.assign({modelId:t,router:e},o),i),{model:l});return n&&(u=Object.assign(Object.assign({},u),n(l,i))),u})(m,t,p,M,o,y),E=(0,s.createViewForModel)(M,P,b,v);return n.createElement(u.EspModelContextProvider,Object.assign({modelId:t,model:M,router:m},P),E)}},963:(e,t,o)=>{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 r=o(155),n=o(152),i=o(155),l=o(169);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:o,model:u})=>{const s=(0,l.useRouter)();let d=(0,t.useGetModelId)();e=e||d;const a=(0,i.useCallback)(((t,o)=>{s.publishEvent(e,t,o)}),[s,e]),c=(0,i.useCallback)(((t,o,r)=>{s.publishEvent(new n.DefaultModelAddress(e,t),o,r)}),[s,e]);return r.createElement(t.GetModelIdContext.Provider,{value:e},r.createElement(t.PublishModelEventContext.Provider,{value:a},r.createElement(t.PublishModelEventWithEntityKeyContext.Provider,{value:c},r.createElement(t.GetModelContext.Provider,{value:u},o))))}},169:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RouterProvider=t.EspRouterContextProvider=t.usePublishEvent=t.PublishEventContext=t.useRouter=t.RouterContext=void 0;const r=o(155),n=o(155);t.RouterContext=(0,n.createContext)(null);t.useRouter=()=>(0,n.useContext)(t.RouterContext),t.PublishEventContext=(0,n.createContext)(null);t.usePublishEvent=()=>(0,n.useContext)(t.PublishEventContext);t.EspRouterContextProvider=({children:e,router:o})=>{let i=(0,t.useRouter)();o=o||i;const l=(0,n.useCallback)(((e,t,r)=>{o.publishEvent(e,t,r)}),[o]);return r.createElement(t.RouterContext.Provider,{value:o},r.createElement(t.PublishEventContext.Provider,{value:l},e))},t.RouterProvider=t.EspRouterContextProvider},894:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tryGetPolimerImmutableModel=t.GetEspPolimerImmutableModelConsts=void 0,t.getEspPolimerImmutableModel=function(){return function(e,t,o){return r.EspDecoratorUtil.getOrCreateMetaData(e.constructor).addCustomData(n.CustomDataKey,{functionName:t}),o}};const r=o(152);var n;!function(e){e.CustomDataKey="GetEspReactImmutableModelCustomDataKey",e.HandlerFunctionName="getEspPolimerImmutableModel"}(n||(t.GetEspPolimerImmutableModelConsts=n={}));t.tryGetPolimerImmutableModel=e=>{if(r.EspDecoratorUtil.hasMetadata(e)){let t=r.EspDecoratorUtil.getCustomData(e,n.CustomDataKey);if(t)return e[t.functionName]()}let t=e[n.HandlerFunctionName];return t&&r.utils.isFunction(t)?t.call(e):e}},185:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=o(43),n=o(213);r.PolimerModelBuilder.prototype.withViewBindings=function(e,t=n.DEFAULT_VIEW_KEY){let o=this._viewMappings||{};return o[t]=e,this._viewMappings=o,this};let i=r.PolimerModelBuilder.prototype.registerWithRouter;r.PolimerModelBuilder.prototype.registerWithRouter=function(){let e=i.call(this),t=this._viewMappings;return t&&Object.keys(t).forEach((o=>{(0,n.viewBinding)(t[o],o)(e.constructor)})),e}},606:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useSyncModelWithSelector=t.syncModelWithSelectorOptions=void 0;const r=o(155),n=o(614),i=o(152),l=o(169),u=o(963),s=o(894);t.syncModelWithSelectorOptions=()=>{let e,t=(e,t)=>e===t,o=!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 o},setTryPreSelectPolimerImmutableModel(e){return o=e,this}}};t.useSyncModelWithSelector=(e,o=(0,t.syncModelWithSelectorOptions)())=>{((e,t)=>{if(!i.utils.isFunction(e))throw new Error("You must pass a selector function to useSyncModelWithSelector");if(!i.utils.isObject(t))throw new Error("You must provide options when using useSyncModelWithSelector");if(!i.utils.isFunction(t.equalityFn))throw new Error("You must provide an equalityFn when using useSyncModelWithSelector")})(e,o);const s=(0,l.useRouter)(),c=(0,u.useGetModelId)(),v=(null==o?void 0:o.modelId)||c,b=null==o?void 0:o.tryPreSelectPolimerImmutableModel,p=null==o?void 0:o.equalityFn,m=(0,r.useMemo)((()=>s&&i.utils.isString(v)&&s.isModelRegistered(v)?d(s,v,e,b):a()),[s,v]);return(0,n.useSyncExternalStoreWithSelector)(m.subscribe,m.getSnapshot,void 0,m.wrappedSelector,p)};const d=(e,t,o,r)=>{const n=e=>{const t=r?(0,s.tryGetPolimerImmutableModel)(e):e;return t===e?Object.create(t):t};let i=!0,l=n(e.getModel(t));return{subscribe:o=>{const r=e.getModelObservable(t).map((e=>n(e))).subscribe((e=>{i?i=!1:(l=e,o())}));return()=>{l=null,r.dispose()}},getSnapshot:()=>l,wrappedSelector:e=>e?o(e):null}},a=()=>({subscribe:()=>()=>{},getSnapshot:()=>null,wrappedSelector:()=>null})},453:function(e,t,o){var r=this&&this.__rest||function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(o[r[n]]=e[r[n]])}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.ViewBinder=void 0;const n=o(213),i=o(169);t.ViewBinder=e=>{var{model:t,viewContext:o}=e,l=r(e,["model","viewContext"]);if(t){const e=(0,i.useRouter)(),r=Object.assign({model:t,router:e},l);return(0,n.createViewForModel)(t,r,o,null)}return null}},213:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ViewMetadataRegistration=t.ViewMetadata=t.DEFAULT_VIEW_KEY=void 0,t.createViewForModel=function(e,o,n,i){let l=i;if(e){let o=e.constructor;if(o._viewMetadata){let e=o._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 r.createElement(l,o)},t.viewBinding=function(e,o=t.DEFAULT_VIEW_KEY){return n.Guard.isDefined(e,"view must be defined"),n.Guard.isString(o,"displayContext must be a string"),function(t){let r=function(e){e._viewMetadata||(e._viewMetadata=new i);return e._viewMetadata}(t);if(r.hasRegisteredViewContext(o))throw new Error(`Context ${o} already registered for view`);r.viewRegistrations[o]=new l(e,o)}};const r=o(155),n=o(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=o}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e].call(o.exports,o,o.exports,i),o.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.syncModelWithSelectorOptions=e.useSyncModelWithSelector=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 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 r=i(894);Object.defineProperty(e,"GetEspPolimerImmutableModelConsts",{enumerable:!0,get:function(){return r.GetEspPolimerImmutableModelConsts}}),Object.defineProperty(e,"getEspPolimerImmutableModel",{enumerable:!0,get:function(){return r.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(606);Object.defineProperty(e,"useSyncModelWithSelector",{enumerable:!0,get:function(){return d.useSyncModelWithSelector}}),Object.defineProperty(e,"syncModelWithSelectorOptions",{enumerable:!0,get:function(){return d.syncModelWithSelectorOptions}});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
@@ -1 +1 @@
1
- {"version":3,"file":"esp-react.min.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,UAAWA,QAAQ,kBAAmBA,QAAQ,UACtD,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,SAAU,iBAAkB,SAAUJ,GACpB,iBAAZC,QACdA,QAAQ,gBAAkBD,EAAQG,QAAQ,UAAWA,QAAQ,kBAAmBA,QAAQ,UAExFJ,EAAK,gBAAkBC,EAAQD,EAAK,UAAWA,EAAK,kBAAmBA,EAAY,MACpF,CATD,CASGO,MAAM,CAACC,EAAkCC,EAAiCC,4CCAhE,IAAIC,EAAE,EAAQ,KAAwE,IAAIC,EAAE,mBAAoBC,OAAOC,GAAGD,OAAOC,GAA1G,SAAWC,EAAEC,GAAG,OAAOD,IAAIC,IAAI,IAAID,GAAG,EAAEA,GAAI,EAAEC,IAAID,GAAIA,GAAGC,GAAIA,CAAC,EAAiDC,EAAEN,EAAEO,qBAAqBC,EAAER,EAAES,OAAOC,EAAEV,EAAEW,UAAUC,EAAEZ,EAAEa,QAAQC,EAAEd,EAAEe,cACrNxB,EAAQyB,iCAAiC,SAASZ,EAAEC,EAAEY,EAAEC,EAAEC,GAAG,IAAIC,EAAEZ,EAAE,MAAM,GAAG,OAAOY,EAAEC,QAAQ,CAAC,IAAIC,EAAE,CAACC,UAAS,EAAGC,MAAM,MAAMJ,EAAEC,QAAQC,CAAC,MAAMA,EAAEF,EAAEC,QAAQD,EAAER,GAAE,WAAW,SAASR,EAAEA,GAAG,IAAIgB,EAAE,CAAiB,GAAhBA,GAAE,EAAGK,EAAErB,EAAEA,EAAEc,EAAEd,QAAM,IAASe,GAAGG,EAAEC,SAAS,CAAC,IAAIlB,EAAEiB,EA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ACjC,yFAAAX,uBAAuB","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/useSyncModelWithSelector.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 {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\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 = useSyncModelWithSelector<TModel, TModel>(\n m => m,\n syncModelWithSelectorOptions()\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 const GetModelIdContext = createContext<string>(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 const GetModelContext = createContext<object>(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?: any;\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 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={modelId}>\n <PublishModelEventContext.Provider value={publishModelEvent}>\n <PublishModelEventWithEntityKeyContext.Provider value={publishModelEventWithEntityKey}>\n <GetModelContext.Provider value={model}>\n {children}\n </GetModelContext.Provider>\n </PublishModelEventWithEntityKeyContext.Provider>\n </PublishModelEventContext.Provider>\n </GetModelIdContext.Provider>\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 SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\n/**\n * Options affecting the subscription of the model to the Router.\n *\n * Use syncModelWithSelectorOptions() 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 SyncModelWithSelectorOptions<TSelected> = {\n modelId?: string,\n tryPreSelectPolimerImmutableModel: boolean,\n equalityFn: SyncModelWithSelectorEqualityFn<TSelected>\n};\n\n/**\n * Convenience API to build SyncModelWithSelectorOptions<TSelected>, has sensible defaulting.\n */\nexport interface SyncModelWithSelectorOptionsBuilder<TSelected> extends SyncModelWithSelectorOptions<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 SyncModelWithSelectorOptions\n */\nexport const syncModelWithSelectorOptions = <TSelected>() => {\n let modelId = undefined;\n let equalityFn: SyncModelWithSelectorEqualityFn<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: SyncModelWithSelectorEqualityFn<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 SyncModelWithSelectorOptionsBuilder<TSelected>;\n};\n\nconst checkArguments = (selector: (model: any) => any, options: SyncModelWithSelectorOptions<any> ) => {\n if (!utils.isFunction(selector)) {\n throw new Error('You must pass a selector function to useSyncModelWithSelector');\n }\n if (!utils.isObject(options)) {\n throw new Error('You must provide options when using useSyncModelWithSelector');\n }\n if (!utils.isFunction(options.equalityFn)) {\n throw new Error('You must provide an equalityFn when using useSyncModelWithSelector');\n }\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 const useSyncModelWithSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options: SyncModelWithSelectorOptions<TSelected> = syncModelWithSelectorOptions<TSelected>()\n): TSelected => {\n checkArguments(selector, options);\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 useSyncModelWithSelector,\n SyncModelWithSelectorOptionsBuilder,\n syncModelWithSelectorOptions,\n SyncModelWithSelectorOptions,\n SyncModelWithSelectorEqualityFn,\n} from './useSyncModelWithSelector';\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 GetModelIdContext,\n useGetModel,\n GetModelContext,\n PublishModelEventDelegate,\n PublishModelEventContext,\n usePublishModelEvent,\n PublishModelEventWithEntityKeyDelegate,\n PublishModelEventWithEntityKeyContext,\n usePublishModelEventWithEntityKey,\n EspModelContextProvider,\n EspModelContextProviderProps,\n} from './espModelContextProvider';\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__152__","__WEBPACK_EXTERNAL_MODULE__43__","__WEBPACK_EXTERNAL_MODULE__155__","g","p","Object","is","a","b","q","useSyncExternalStore","r","useRef","t","useEffect","u","useMemo","v","useDebugValue","useSyncExternalStoreWithSelector","e","l","h","c","current","f","hasValue","value","d","k","m","connect","mapModelToProps","createPublishEventProps","view","props","modelId","viewContext","rest","ConnectableComponent","router","useRouter","useGetModelId","utils","stringIsEmpty","publishEventProps","eventType","event","publishEvent","model","useSyncModelWithSelector","syncModelWithSelectorOptions","setModelId","setTryPreSelectPolimerImmutableModel","childProps","restProps","initialModel","tryGetPolimerImmutableModel","getChildProps","viewElement","createViewForModel","EspModelContextProvider","Logger","create","GetModelIdContext","createContext","useContext","GetModelContext","useGetModel","PublishModelEventContext","usePublishModelEvent","PublishModelEventWithEntityKeyContext","usePublishModelEventWithEntityKey","children","publishModelEvent","useCallback","publishModelEventWithEntityKey","entityKey","DefaultModelAddress","Provider","RouterContext","context","undefined","Error","PublishEventContext","usePublishEvent","EspRouterContextProvider","modelIdOrModelAddress","RouterProvider","target","name","descriptor","EspDecoratorUtil","getOrCreateMetaData","constructor","addCustomData","GetEspPolimerImmutableModelConsts","CustomDataKey","functionName","HandlerFunctionName","hasMetadata","metadata","getCustomData","immutableModel","isFunction","call","PolimerModelBuilder","prototype","withViewBindings","displayContext","DEFAULT_VIEW_KEY","viewMappings","this","_viewMappings","registerWithRouter","keys","forEach","viewBinding","equalityFn","tryPreSelectPolimerImmutableModel","setEqualityFn","selector","options","isObject","checkArguments","dependencies","subscribe","stateChanged","modelSubscriptionDisposable","getModelObservable","nextModel","dispose","getSnapshot","wrappedSelector","snapshot","noopSubscription","ViewBinder","newProps","finalView","constructorFunction","_viewMetadata","viewMetadata","hasRegisteredViewContext","viewRegistrations","React","createElement","Guard","isDefined","isString","ViewMetadata","getMetadata","ViewMetadataRegistration","_viewRegistrations","_view","_displayContext","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","get","getEspPolimerImmutableModel"],"sourceRoot":""}
1
+ {"version":3,"file":"esp-react.min.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,UAAWA,QAAQ,kBAAmBA,QAAQ,UACtD,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,SAAU,iBAAkB,SAAUJ,GACpB,iBAAZC,QACdA,QAAQ,gBAAkBD,EAAQG,QAAQ,UAAWA,QAAQ,kBAAmBA,QAAQ,UAExFJ,EAAK,gBAAkBC,EAAQD,EAAK,UAAWA,EAAK,kBAAmBA,EAAY,MACpF,CATD,CASGO,MAAM,CAACC,EAAkCC,EAAiCC,4CCAhE,IAAIC,EAAE,EAAQ,KAAwE,IAAIC,EAAE,mBAAoBC,OAAOC,GAAGD,OAAOC,GAA1G,SAAWC,EAAEC,GAAG,OAAOD,IAAIC,IAAI,IAAID,GAAG,EAAEA,GAAI,EAAEC,IAAID,GAAIA,GAAGC,GAAIA,CAAC,EAAiDC,EAAEN,EAAEO,qBAAqBC,EAAER,EAAES,OAAOC,EAAEV,EAAEW,UAAUC,EAAEZ,EAAEa,QAAQC,EAAEd,EAAEe,cACrNxB,EAAQyB,iCAAiC,SAASZ,EAAEC,EAAEY,EAAEC,EAAEC,GAAG,IAAIC,EAAEZ,EAAE,MAAM,GAAG,OAAOY,EAAEC,QAAQ,CAAC,IAAIC,EAAE,CAACC,UAAS,EAAGC,MAAM,MAAMJ,EAAEC,QAAQC,CAAC,MAAMA,EAAEF,EAAEC,QAAQD,EAAER,GAAE,WAAW,SAASR,EAAEA,GAAG,IAAIgB,EAAE,CAAiB,GAAhBA,GAAE,EAAGK,EAAErB,EAAEA,EAAEc,EAAEd,QAAM,IAASe,GAAGG,EAAEC,SAAS,CAAC,IAAIlB,EAAEiB,EAAEE,MAAM,GAAGL,EAAEd,EAAED,GAAG,OAA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6EAAAI,WAAW,IACX,iFAAAD,eAAe,IAEf,0FAAAE,wBAAwB,IACxB,sFAAAC,oBAAoB,IAEpB,uGAAAC,qCAAqC,IACrC,mGAAAC,iCAAiC,IACjC,yFAAAT,uBAAuB","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/useSyncModelWithSelector.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 {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\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 // Note: we always need to render the hooks else react will complain about a different count.\n let modelIdFromContext = useGetModelId();\n modelId = modelId || modelIdFromContext;\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 = useSyncModelWithSelector<TModel, TModel>(\n m => m,\n syncModelWithSelectorOptions()\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} from 'esp-js';\nimport {useContext, useCallback, createContext, PropsWithChildren} from 'react';\nimport {useRouter} from './espRouterContextProvider';\n\nexport const GetModelIdContext = createContext<string>(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 const GetModelContext = createContext<object>(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?: any;\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 // modelId may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.\n let modelIdFromContext = useGetModelId();\n modelId = modelId || modelIdFromContext;\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={modelId}>\n <PublishModelEventContext.Provider value={publishModelEvent}>\n <PublishModelEventWithEntityKeyContext.Provider value={publishModelEventWithEntityKey}>\n <GetModelContext.Provider value={model}>\n {children}\n </GetModelContext.Provider>\n </PublishModelEventWithEntityKeyContext.Provider>\n </PublishModelEventContext.Provider>\n </GetModelIdContext.Provider>\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 return useContext(RouterContext);\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 // Router may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.\n let routerFromContext = useRouter();\n router = router || routerFromContext;\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 {Router, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';\n\nexport type SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\n/**\n * Options affecting the subscription of the model to the Router.\n *\n * Use syncModelWithSelectorOptions() 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 SyncModelWithSelectorOptions<TSelected> = {\n modelId?: string,\n tryPreSelectPolimerImmutableModel: boolean,\n equalityFn: SyncModelWithSelectorEqualityFn<TSelected>\n};\n\n/**\n * Convenience API to build SyncModelWithSelectorOptions<TSelected>, has sensible defaulting.\n */\nexport interface SyncModelWithSelectorOptionsBuilder<TSelected> extends SyncModelWithSelectorOptions<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 SyncModelWithSelectorOptions\n */\nexport const syncModelWithSelectorOptions = <TSelected>() => {\n let modelId = undefined;\n let equalityFn: SyncModelWithSelectorEqualityFn<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: SyncModelWithSelectorEqualityFn<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 SyncModelWithSelectorOptionsBuilder<TSelected>;\n};\n\nconst checkArguments = (selector: (model: any) => any, options: SyncModelWithSelectorOptions<any> ) => {\n if (!utils.isFunction(selector)) {\n throw new Error('You must pass a selector function to useSyncModelWithSelector');\n }\n if (!utils.isObject(options)) {\n throw new Error('You must provide options when using useSyncModelWithSelector');\n }\n if (!utils.isFunction(options.equalityFn)) {\n throw new Error('You must provide an equalityFn when using useSyncModelWithSelector');\n }\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 const useSyncModelWithSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options: SyncModelWithSelectorOptions<TSelected> = syncModelWithSelectorOptions<TSelected>()\n): TSelected => {\n checkArguments(selector, options);\n const router = useRouter();\n const modelIdFromContext = useGetModelId();\n const modelId = options?.modelId || modelIdFromContext;\n const tryPreSelectPolimerImmutableModel = options?.tryPreSelectPolimerImmutableModel;\n const equalityFn = options?.equalityFn;\n const dependencies = useMemo(\n () => {\n const canSubscribe = router && utils.isString(modelId) && router.isModelRegistered(modelId);\n if (canSubscribe) {\n return createSubscriptionState(router, modelId, selector, tryPreSelectPolimerImmutableModel);\n }\n return createNoopSubscriptionState();\n },\n // Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.\n [router, modelId]\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 can't be cached (needs to be a new fn each time)\n // It seems that if it is, you get the last value regardless of if dependencies (and it's associated functions) changes.\n equalityFn,\n );\n};\n\nconst createSubscriptionState = <TModel, TSelected>(\n router: Router,\n modelId: string,\n selector: (model: TModel) => TSelected,\n tryPreSelectPolimerImmutableModel: boolean\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,\n // React calls that when it deems it needs to.\n // Given that, we need to cache the state which getSnapshot will return.\n //\n // Another edge case with useSyncExternalStore:\n // It will call getSnapshot before it calls subscribe, to account for this we need to fetch the model first.\n // ESP will always dispatch the model when you initially observe it, because we pre-fetched it, the first updated is ignored below.\n const selectModelOrPolimerModel = (m: any): TModel => {\n // try use get the esp-js-polimer immutable model if possible.\n const nextModel = tryPreSelectPolimerImmutableModel\n ? tryGetPolimerImmutableModel(m)\n : m;\n // If the above didn't manage to get a polimer model,\n // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change.\n // This should only affect older style OO models.\n let modelHasNotMutated = nextModel === m;\n return modelHasNotMutated\n ? Object.create(nextModel)\n : nextModel;\n };\n let isFirstRun = true;\n let model: TModel = selectModelOrPolimerModel(router.getModel(modelId));\n return {\n subscribe: (stateChanged: () => void) => {\n const modelSubscriptionDisposable = router\n .getModelObservable<TModel>(modelId)\n .map(m => selectModelOrPolimerModel(m))\n .subscribe(\n (m: any) => {\n if (isFirstRun) {\n isFirstRun = false;\n return;\n }\n model = m;\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 return snapshot\n ? selector(snapshot)\n : null;\n }\n };\n};\n\nconst createNoopSubscriptionState = () => ({\n subscribe: () => {\n return () => {};\n },\n getSnapshot: () => null,\n wrappedSelector: () => 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 {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 useSyncModelWithSelector,\n SyncModelWithSelectorOptionsBuilder,\n syncModelWithSelectorOptions,\n SyncModelWithSelectorOptions,\n SyncModelWithSelectorEqualityFn,\n} from './useSyncModelWithSelector';\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 GetModelIdContext,\n useGetModel,\n GetModelContext,\n PublishModelEventDelegate,\n PublishModelEventContext,\n usePublishModelEvent,\n PublishModelEventWithEntityKeyDelegate,\n PublishModelEventWithEntityKeyContext,\n usePublishModelEventWithEntityKey,\n EspModelContextProvider,\n EspModelContextProviderProps,\n} from './espModelContextProvider';\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__152__","__WEBPACK_EXTERNAL_MODULE__43__","__WEBPACK_EXTERNAL_MODULE__155__","g","p","Object","is","a","b","q","useSyncExternalStore","r","useRef","t","useEffect","u","useMemo","v","useDebugValue","useSyncExternalStoreWithSelector","e","l","h","c","current","f","hasValue","value","d","k","m","connect","mapModelToProps","createPublishEventProps","view","props","modelId","viewContext","rest","ConnectableComponent","router","useRouter","modelIdFromContext","useGetModelId","publishEventProps","eventType","event","publishEvent","model","useSyncModelWithSelector","syncModelWithSelectorOptions","setModelId","setTryPreSelectPolimerImmutableModel","childProps","restProps","initialModel","tryGetPolimerImmutableModel","getChildProps","viewElement","createViewForModel","EspModelContextProvider","GetModelIdContext","createContext","useContext","GetModelContext","useGetModel","PublishModelEventContext","usePublishModelEvent","PublishModelEventWithEntityKeyContext","usePublishModelEventWithEntityKey","children","publishModelEvent","useCallback","publishModelEventWithEntityKey","entityKey","DefaultModelAddress","Provider","RouterContext","PublishEventContext","usePublishEvent","EspRouterContextProvider","routerFromContext","modelIdOrModelAddress","RouterProvider","target","name","descriptor","EspDecoratorUtil","getOrCreateMetaData","constructor","addCustomData","GetEspPolimerImmutableModelConsts","CustomDataKey","functionName","HandlerFunctionName","hasMetadata","metadata","getCustomData","immutableModel","utils","isFunction","call","PolimerModelBuilder","prototype","withViewBindings","displayContext","DEFAULT_VIEW_KEY","viewMappings","this","_viewMappings","registerWithRouter","keys","forEach","viewBinding","equalityFn","tryPreSelectPolimerImmutableModel","setEqualityFn","selector","options","Error","isObject","checkArguments","dependencies","isString","isModelRegistered","createSubscriptionState","createNoopSubscriptionState","subscribe","getSnapshot","undefined","wrappedSelector","selectModelOrPolimerModel","nextModel","create","isFirstRun","getModel","stateChanged","modelSubscriptionDisposable","getModelObservable","map","dispose","snapshot","ViewBinder","newProps","finalView","constructorFunction","_viewMetadata","viewMetadata","hasRegisteredViewContext","viewRegistrations","React","createElement","Guard","isDefined","ViewMetadata","getMetadata","ViewMetadataRegistration","_viewRegistrations","_view","_displayContext","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","get","getEspPolimerImmutableModel"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esp-js-react",
3
- "version": "8.0.4-next.0",
3
+ "version": "8.0.5-next.0",
4
4
  "description": "Evented State Processor (ESP) React Components",
5
5
  "keywords": [
6
6
  "esp",
@@ -24,8 +24,8 @@
24
24
  "dev": "nps dev"
25
25
  },
26
26
  "dependencies": {
27
- "esp-js": "^8.0.4-next.0",
28
- "esp-js-polimer": "^8.0.4-next.0",
27
+ "esp-js": "^8.0.5-next.0",
28
+ "esp-js-polimer": "^8.0.5-next.0",
29
29
  "prop-types": "^15.7.2",
30
30
  "react": "^18.3.1",
31
31
  "use-sync-external-store": "^1.2.2"
@@ -43,5 +43,5 @@
43
43
  "prop-types": "^15.0.0",
44
44
  "react": "^18.0.0"
45
45
  },
46
- "gitHead": "9685330192bf6c83ca1864e2d812e07d3cc98b64"
46
+ "gitHead": "3c1d7eba72cf4aa6c25883d211c62cb2a4804a48"
47
47
  }
@@ -63,10 +63,9 @@ export const ConnectableComponent = <TModel = {}, TPublishEventProps = {}, TMode
63
63
  }: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>
64
64
  ) => {
65
65
  const router = useRouter();
66
- modelId = modelId || useGetModelId();
67
- if (utils.stringIsEmpty(modelId) || !router) {
68
- return null;
69
- }
66
+ // Note: we always need to render the hooks else react will complain about a different count.
67
+ let modelIdFromContext = useGetModelId();
68
+ modelId = modelId || modelIdFromContext;
70
69
  const publishEventProps: TPublishEventProps = useMemo(
71
70
  () => {
72
71
  if (createPublishEventProps) {
@@ -1,10 +1,8 @@
1
1
  import * as React from 'react';
2
- import {DefaultModelAddress, Router, Status, Logger, utils} from 'esp-js';
2
+ import {DefaultModelAddress} from 'esp-js';
3
3
  import {useContext, useCallback, createContext, PropsWithChildren} from 'react';
4
4
  import {useRouter} from './espRouterContextProvider';
5
5
 
6
- const _log = Logger.create('EspModelContextProvider');
7
-
8
6
  export const GetModelIdContext = createContext<string>(null);
9
7
  /**
10
8
  * Returns a function to get the ID of the model connected at a higher point in the V-DOM.
@@ -59,6 +57,9 @@ export interface EspModelContextProviderProps {
59
57
  */
60
58
  export const EspModelContextProvider = ({modelId, children, model}: PropsWithChildren<EspModelContextProviderProps>) => {
61
59
  const router = useRouter();
60
+ // modelId may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
61
+ let modelIdFromContext = useGetModelId();
62
+ modelId = modelId || modelIdFromContext;
62
63
  const publishModelEvent: PublishModelEventDelegate = useCallback((eventType: string, event: any) => {
63
64
  router.publishEvent(modelId, eventType, event);
64
65
  }, [router, modelId]);
@@ -32,11 +32,7 @@ export const RouterContext = createContext<Router>(null);
32
32
  * </EspRouterContextProvider>
33
33
  */
34
34
  export const useRouter = () => {
35
- const context: Router = useContext(RouterContext);
36
- if (context === undefined) {
37
- throw new Error('useRouter must be used within a RouterContext.Provider');
38
- }
39
- return context;
35
+ return useContext(RouterContext);
40
36
  };
41
37
 
42
38
  export type PublishEventDelegate = (modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any) => void;
@@ -61,6 +57,9 @@ export type EspRouterContextProviderProps = PropsWithChildren<{ router: Router;
61
57
  * Also sets up the usePublishEvent() hook so nested components can publish to the router.
62
58
  */
63
59
  export const EspRouterContextProvider = ({children, router}: EspRouterContextProviderProps) => {
60
+ // Router may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
61
+ let routerFromContext = useRouter();
62
+ router = router || routerFromContext;
64
63
  const publishEvent: PublishEventDelegate = useCallback((modelIdOrModelAddress: string, eventType: string, event: any) => {
65
64
  router.publishEvent(modelIdOrModelAddress, eventType, event);
66
65
  }, [router]);
@@ -1,6 +1,6 @@
1
1
  import {useMemo} from 'react';
2
2
  import {useSyncExternalStoreWithSelector} from 'use-sync-external-store/with-selector';
3
- import {Guard, utils} from 'esp-js';
3
+ import {Router, utils} from 'esp-js';
4
4
  import {useRouter} from './espRouterContextProvider';
5
5
  import {useGetModelId} from './espModelContextProvider';
6
6
  import {tryGetPolimerImmutableModel} from './polimer/getEspPolimerImmutableModel';
@@ -105,72 +105,22 @@ export const useSyncModelWithSelector = <TModel, TSelected>(
105
105
  ): TSelected => {
106
106
  checkArguments(selector, options);
107
107
  const router = useRouter();
108
- const modelId = options?.modelId || useGetModelId();
108
+ const modelIdFromContext = useGetModelId();
109
+ const modelId = options?.modelId || modelIdFromContext;
109
110
  const tryPreSelectPolimerImmutableModel = options?.tryPreSelectPolimerImmutableModel;
110
111
  const equalityFn = options?.equalityFn;
111
112
  const dependencies = useMemo(
112
113
  () => {
113
- // Because of how useSyncExternalStore works, there is an implicit dependency between the subscribe and getSnapshot functions.
114
- // 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.
115
- // Given that, we need to cache the state which getSnapshot will return.
116
- //
117
- // It's not ideal but shouldn't be a problem as here we've wrapped all these dependent functions inside a single useMemo()
118
- let model: TModel = null;
119
- return {
120
- subscribe: (stateChanged: () => void) => {
121
- const modelSubscriptionDisposable = router
122
- .getModelObservable(modelId)
123
- .subscribe(
124
- (m: any) => {
125
- // try and get a submodel to render
126
- const nextModel = tryPreSelectPolimerImmutableModel
127
- ? tryGetPolimerImmutableModel(m)
128
- : m;
129
- // if the above didn't manage to get a submodel,
130
- // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change
131
- model = nextModel === m
132
- ? Object.create(nextModel)
133
- : nextModel;
134
- stateChanged();
135
- }
136
- );
137
- return () => {
138
- model = null;
139
- modelSubscriptionDisposable.dispose();
140
- };
141
- },
142
- // React expects getSnapshot to be immutable, it'll only re-render if the instance changes
143
- getSnapshot: () => {
144
- return model;
145
- },
146
- // While getSnapshot needs to model to be immutable,
147
- // useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.
148
- // The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.
149
- wrappedSelector: (snapshot: TModel) => {
150
- // The first time this renders, react calls getSnapshot and the selector before the router has pushed a change.
151
- // In that case, there is no state for any component to process, therefore, we return null;
152
- return snapshot
153
- ? selector(snapshot)
154
- : null;
155
- }
156
- };
114
+ const canSubscribe = router && utils.isString(modelId) && router.isModelRegistered(modelId);
115
+ if (canSubscribe) {
116
+ return createSubscriptionState(router, modelId, selector, tryPreSelectPolimerImmutableModel);
117
+ }
118
+ return createNoopSubscriptionState();
157
119
  },
158
- // Don't cache check against 'selector' argument as that will likely change unless the caller memoizes it.
120
+ // Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.
159
121
  [router, modelId]
160
122
  );
161
123
 
162
- // If we don't have a modelId, we still need to return a hook so React doesn't complain.
163
- // Additionally, we need to let the above expiration (dependencies) run to unsubscribe from any previous subscription.
164
- if (utils.stringIsEmpty(modelId)) {
165
- return useSyncExternalStoreWithSelector(
166
- noopSubscription.subscribe,
167
- noopSubscription.getSnapshot,
168
- undefined,
169
- noopSubscription.wrappedSelector,
170
- equalityFn
171
- );
172
- }
173
-
174
124
  // Docs on useSyncExternalStore https://github.com/reactwg/react-18/discussions/86
175
125
  // Redux's usage of this: https://github.com/reduxjs/react-redux/blob/master/src/hooks/useSelector.ts
176
126
  // Code: https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
@@ -179,12 +129,80 @@ export const useSyncModelWithSelector = <TModel, TSelected>(
179
129
  dependencies.getSnapshot,
180
130
  undefined,
181
131
  dependencies.wrappedSelector,
132
+ // equalityFn can't be cached (needs to be a new fn each time)
133
+ // It seems that if it is, you get the last value regardless of if dependencies (and it's associated functions) changes.
182
134
  equalityFn,
183
135
  );
184
136
  };
185
137
 
186
- const noopSubscription = {
187
- subscribe: () => { },
138
+ const createSubscriptionState = <TModel, TSelected>(
139
+ router: Router,
140
+ modelId: string,
141
+ selector: (model: TModel) => TSelected,
142
+ tryPreSelectPolimerImmutableModel: boolean
143
+ ) => {
144
+ // Because of how useSyncExternalStore works, there is an implicit dependency between the subscribe and getSnapshot functions.
145
+ // When the subscription receives the new state from the Router, it can't pass this directly onto getSnapshot,
146
+ // React calls that when it deems it needs to.
147
+ // Given that, we need to cache the state which getSnapshot will return.
148
+ //
149
+ // Another edge case with useSyncExternalStore:
150
+ // It will call getSnapshot before it calls subscribe, to account for this we need to fetch the model first.
151
+ // ESP will always dispatch the model when you initially observe it, because we pre-fetched it, the first updated is ignored below.
152
+ const selectModelOrPolimerModel = (m: any): TModel => {
153
+ // try use get the esp-js-polimer immutable model if possible.
154
+ const nextModel = tryPreSelectPolimerImmutableModel
155
+ ? tryGetPolimerImmutableModel(m)
156
+ : m;
157
+ // If the above didn't manage to get a polimer model,
158
+ // we need to mutate to force useSyncExternalStoreWithSelector to pick up the change.
159
+ // This should only affect older style OO models.
160
+ let modelHasNotMutated = nextModel === m;
161
+ return modelHasNotMutated
162
+ ? Object.create(nextModel)
163
+ : nextModel;
164
+ };
165
+ let isFirstRun = true;
166
+ let model: TModel = selectModelOrPolimerModel(router.getModel(modelId));
167
+ return {
168
+ subscribe: (stateChanged: () => void) => {
169
+ const modelSubscriptionDisposable = router
170
+ .getModelObservable<TModel>(modelId)
171
+ .map(m => selectModelOrPolimerModel(m))
172
+ .subscribe(
173
+ (m: any) => {
174
+ if (isFirstRun) {
175
+ isFirstRun = false;
176
+ return;
177
+ }
178
+ model = m;
179
+ stateChanged();
180
+ }
181
+ );
182
+ return () => {
183
+ model = null;
184
+ modelSubscriptionDisposable.dispose();
185
+ };
186
+ },
187
+ // React expects getSnapshot to be immutable, it'll only re-render if the instance changes
188
+ getSnapshot: () => {
189
+ return model;
190
+ },
191
+ // While getSnapshot needs to model to be immutable,
192
+ // useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.
193
+ // The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.
194
+ wrappedSelector: (snapshot: TModel) => {
195
+ return snapshot
196
+ ? selector(snapshot)
197
+ : null;
198
+ }
199
+ };
200
+ };
201
+
202
+ const createNoopSubscriptionState = () => ({
203
+ subscribe: () => {
204
+ return () => {};
205
+ },
188
206
  getSnapshot: () => null,
189
- wrappedSelector: () => true
190
- };
207
+ wrappedSelector: () => null
208
+ });
@@ -5,8 +5,10 @@ import {RouterSpy} from './routerSpy';
5
5
  import {TestPropStore} from './useStoreReceivedProps';
6
6
 
7
7
  export type ViewAsserts = {
8
- valueIs(expected: string): ViewAsserts;
9
8
  modelIdIs(expected: string): ViewAsserts
9
+ modelIdIsNotInDom(): ViewAsserts
10
+ valueIs(expected: string): ViewAsserts;
11
+ valueIsNotInDom(): ViewAsserts;
10
12
  propIs(propName: string, expected: string): ViewAsserts
11
13
  viewNameElementTextIs(viewName: string);
12
14
  htmlElementInnerTextIs(elementsTestId: string, expectedText: string): ViewAsserts
@@ -19,11 +21,21 @@ export const viewAsserts = (renderResult: RenderResult) => {
19
21
  expect(idElement).toHaveTextContent(expected);
20
22
  return this;
21
23
  },
24
+ modelIdIsNotInDom() {
25
+ let idElement = renderResult.queryByTestId('modelIdDisplay');
26
+ expect(idElement).not.toBeInTheDocument();
27
+ return this;
28
+ },
22
29
  valueIs(expected: string) {
23
30
  let valueElement = renderResult.getByTestId('valueDisplay');
24
31
  expect(valueElement).toHaveTextContent(expected);
25
32
  return this;
26
33
  },
34
+ valueIsNotInDom() {
35
+ let idElement = renderResult.queryByTestId('valueDisplay');
36
+ expect(idElement).not.toBeInTheDocument();
37
+ return this;
38
+ },
27
39
  propIs(propName: string, expected: string) {
28
40
  let span = renderResult.getByTestId('span-with-props-as-attributes');
29
41
  let attributeName = `data-${propName}`;
@@ -2,7 +2,7 @@ import {useTestPropStore} from './useStoreReceivedProps';
2
2
  import * as React from 'react';
3
3
 
4
4
  export const viewFactory = (name: string) => {
5
- return (props: { modelId: string; value: string, [key: string]: any }) => {
5
+ return (props: { modelId?: string; value?: string, [key: string]: any }) => {
6
6
  let testPropStore = useTestPropStore();
7
7
  testPropStore.pushProps(props);
8
8
  return (
@@ -1,11 +1,12 @@
1
1
  import 'jest';
2
2
  import * as React from 'react';
3
3
  import {act} from 'react';
4
- import {syncModelWithSelectorOptions, useSyncModelWithSelector} from '../src';
4
+ import {EspModelContextProvider, EspRouterContextProvider, syncModelWithSelectorOptions, useSyncModelWithSelector} from '../src';
5
5
  import {TestModel, TestModelImmutableState} from './testApi/testModel';
6
- import {ViewMetadata} from './testApi/viewFactory';
6
+ import {viewFactory, ViewMetadata} from './testApi/viewFactory';
7
7
  import {routerAsserts} from './testApi/asserts';
8
8
  import {testApi, TestApi} from './testApi/testApi';
9
+ import {TestPropStoreContext} from './testApi/useStoreReceivedProps';
9
10
 
10
11
  type SelectedObject = { id: string, value: string };
11
12
 
@@ -171,8 +172,8 @@ describe('useSyncModelWithSelector', () => {
171
172
  .valueIs('initial-value');
172
173
  api.doReRender(View, undefined);
173
174
  api.asserts.view
174
- .modelIdIs('')
175
- .valueIs('');
175
+ .modelIdIsNotInDom()
176
+ .valueIsNotInDom();
176
177
  api.setupTestModel(modelId2);
177
178
  api.doReRender(View, modelId2);
178
179
  api.asserts.view
@@ -253,6 +254,48 @@ describe('useSyncModelWithSelector', () => {
253
254
  });
254
255
  });
255
256
 
257
+ describe('noop argument edge cases', () => {
258
+ const View = viewFactory('View1');
259
+
260
+ it('falsey router', () => {
261
+ api.doRender((
262
+ <TestPropStoreContext.Provider value={api.propStore}>
263
+ <EspRouterContextProvider router={undefined}>
264
+ <EspModelContextProvider modelId={'some-modelId'}>
265
+ <View />,
266
+ </EspModelContextProvider>
267
+ </EspRouterContextProvider>
268
+ </TestPropStoreContext.Provider>
269
+ ));
270
+ api.asserts.props
271
+ .receivedPropCountIs(1)
272
+ .propAtIndexHasModelId(0, undefined)
273
+ .propAtIndex(0, props => {
274
+ expect(props.modelId).not.toBeDefined();
275
+ expect(props.value).not.toBeDefined();
276
+ });
277
+ });
278
+
279
+ it('falsey modelId', () => {
280
+ api.doRender((
281
+ <TestPropStoreContext.Provider value={api.propStore}>
282
+ <EspRouterContextProvider router={api.router}>
283
+ <EspModelContextProvider modelId={undefined}>
284
+ <View />,
285
+ </EspModelContextProvider>
286
+ </EspRouterContextProvider>
287
+ </TestPropStoreContext.Provider>
288
+ ));
289
+ api.asserts.props
290
+ .receivedPropCountIs(1)
291
+ .propAtIndexHasModelId(0, undefined)
292
+ .propAtIndex(0, props => {
293
+ expect(props.modelId).not.toBeDefined();
294
+ expect(props.value).not.toBeDefined();
295
+ });
296
+ });
297
+ });
298
+
256
299
  describe('argument checking', () => {
257
300
  it('throws if selector incorrect', () => {
258
301
  expect(() => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  viewBinding,
3
- ViewBinder, ViewBinderConnectable
3
+ ViewBinder,
4
4
  } from '../src';
5
5
  import {testApi, TestApi} from './testApi/testApi';
6
6
  import * as React from 'react';