esp-js-react 8.0.15 → 8.1.1-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.
@@ -169,6 +169,17 @@ exports.GetModelContext = (0, react_1.createContext)(null);
169
169
  */
170
170
  const useGetModel = () => (0, react_1.useContext)(exports.GetModelContext);
171
171
  exports.useGetModel = useGetModel;
172
+ const createPublishModelEvent = (router, modelId) => {
173
+ function publishModelEvent(...args) {
174
+ if (args.length === 1) {
175
+ router.publishEvent(modelId, args[0].eventType, args[0].event);
176
+ }
177
+ else {
178
+ router.publishEvent(modelId, args[0], args[1]);
179
+ }
180
+ }
181
+ return publishModelEvent;
182
+ };
172
183
  exports.PublishModelEventContext = (0, react_1.createContext)(null);
173
184
  /**
174
185
  * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM.
@@ -179,6 +190,17 @@ exports.PublishModelEventContext = (0, react_1.createContext)(null);
179
190
  */
180
191
  const usePublishModelEvent = () => (0, react_1.useContext)(exports.PublishModelEventContext);
181
192
  exports.usePublishModelEvent = usePublishModelEvent;
193
+ const createPublishModelEventWithEntityKey = (router, modelId) => {
194
+ function publishModelEventWithEntityKey(...args) {
195
+ if (args.length === 1) {
196
+ router.publishEvent(new esp_js_1.DefaultModelAddress(modelId, args[0].entityKey), args[0].eventType, args[0].event);
197
+ }
198
+ else {
199
+ router.publishEvent(new esp_js_1.DefaultModelAddress(modelId, args[0]), args[1], args[2]);
200
+ }
201
+ }
202
+ return publishModelEventWithEntityKey;
203
+ };
182
204
  exports.PublishModelEventWithEntityKeyContext = (0, react_1.createContext)(null);
183
205
  /**
184
206
  * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM, allows an entityKey to be specified.
@@ -203,12 +225,8 @@ const EspModelContextProvider = ({ modelId, children, model }) => {
203
225
  // modelId may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
204
226
  let modelIdFromContext = (0, exports.useGetModelId)();
205
227
  modelId = modelId || modelIdFromContext;
206
- const publishModelEvent = (0, react_1.useCallback)((eventType, event) => {
207
- router.publishEvent(modelId, eventType, event);
208
- }, [router, modelId]);
209
- const publishModelEventWithEntityKey = (0, react_1.useCallback)((entityKey, eventType, event) => {
210
- router.publishEvent(new esp_js_1.DefaultModelAddress(modelId, entityKey), eventType, event);
211
- }, [router, modelId]);
228
+ const publishModelEvent = (0, react_1.useCallback)(createPublishModelEvent(router, modelId), [router, modelId]);
229
+ const publishModelEventWithEntityKey = (0, react_1.useCallback)(createPublishModelEventWithEntityKey(router, modelId), [router, modelId]);
212
230
  return (React.createElement(exports.GetModelIdContext.Provider, { value: modelId },
213
231
  React.createElement(exports.PublishModelEventContext.Provider, { value: publishModelEvent },
214
232
  React.createElement(exports.PublishModelEventWithEntityKeyContext.Provider, { value: publishModelEventWithEntityKey },
@@ -258,6 +276,17 @@ const useRouter = () => {
258
276
  return (0, react_1.useContext)(exports.RouterContext);
259
277
  };
260
278
  exports.useRouter = useRouter;
279
+ const createPublishEvent = (router) => {
280
+ function publishEvent(...args) {
281
+ if (args.length === 1) {
282
+ router.publishEvent(args[0].address, args[0].eventType, args[0].event);
283
+ }
284
+ else {
285
+ router.publishEvent(args[0], args[1], args[2]);
286
+ }
287
+ }
288
+ return publishEvent;
289
+ };
261
290
  exports.PublishEventContext = (0, react_1.createContext)(null);
262
291
  /**
263
292
  * Returns a function which can be used to publish an event.
@@ -279,9 +308,7 @@ const EspRouterContextProvider = ({ children, router }) => {
279
308
  // Router may have been set by a higher level version of this component, so we try and get it from context if it's not set by props.
280
309
  let routerFromContext = (0, exports.useRouter)();
281
310
  router = router || routerFromContext;
282
- const publishEvent = (0, react_1.useCallback)((modelIdOrModelAddress, eventType, event) => {
283
- router.publishEvent(modelIdOrModelAddress, eventType, event);
284
- }, [router]);
311
+ const publishEvent = (0, react_1.useCallback)(createPublishEvent(router), [router]);
285
312
  return (React.createElement(exports.RouterContext.Provider, { value: router },
286
313
  React.createElement(exports.PublishEventContext.Provider, { value: publishEv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;AAElD,4CAAwC;AAAhC,mHAAU;AAClB,sDAAqE;AAA7D,+HAAW;AAAE,yIAAgB;AACrC,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/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} from 'esp-js';\nimport {EspModelContextProvider, useGetModelId} from './espModelContextProvider';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\nimport {PolimerModel} from 'esp-js-polimer';\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 = PolimerModel.isPolimerModel(initialModel)\n ? initialModel.getEspPolimerImmutableModel()\n : 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 {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 {Logger, Router, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {PolimerModel} from 'esp-js-polimer';\n\nexport type SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\nexport const logger = Logger.create('useSyncModelWithSelector');\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,\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 let currentModel: TModel;\n let onStateChanged: () => void = null;\n const modelSubscriptionDisposable = router\n .getModelObservable<TModel>(modelId)\n .subscribe(\n (m: any) => {\n // try and get the esp-js-polimer immutable model if possible, this should mutate when any state changes\n const nextModel = tryPreSelectPolimerImmutableModel && PolimerModel.isPolimerModel(m)\n ? m.getEspPolimerImmutableModel()\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 : Object.create(m);\n warnIfModelInstanceHasNotChanged(modelId, currentModel, nextModel);\n currentModel = nextModel;\n if (onStateChanged) {\n onStateChanged();\n }\n }\n );\n return {\n subscribe: (stateChanged: () => void) => {\n onStateChanged = stateChanged;\n return () => {\n onStateChanged = null;\n currentModel = 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 currentModel;\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});\n\nconst warnIfModelInstanceHasNotChanged = (modelId: string, lastModel: any, nextModel: string) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (utils.stringIsEmpty(modelId)) {\n return;\n }\n if (lastModel === nextModel) {\n let stack: string | undefined = undefined;\n try {\n // noinspection ExceptionCaughtLocallyJS\n throw new Error();\n } catch (e) {\n stack = (e as Error).stack;\n }\n logger.warn(\n `useSyncModelWithSelector had detected the latest model update hasn't mutated. This will cause odd render bugs. modelId: ${modelId}`,\n stack\n );\n }\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {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 {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';"],"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,CA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,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/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} from 'esp-js';\nimport {EspModelContextProvider, useGetModelId} from './espModelContextProvider';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\nimport {PolimerModel} from 'esp-js-polimer';\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 = PolimerModel.isPolimerModel(initialModel)\n ? initialModel.getEspPolimerImmutableModel()\n : 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, Router} 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; (eventData: {eventType: string, event: any}): void; };\nconst createPublishModelEvent = (router: Router, modelId: string) => {\n function publishModelEvent(eventType: string, event: any): void;\n function publishModelEvent(eventData: {eventType: string, event: any}): void;\n function publishModelEvent(...args: any[]) {\n if (args.length === 1) {\n router.publishEvent(modelId, args[0].eventType, args[0].event);\n } else {\n router.publishEvent(modelId, args[0], args[1]);\n }\n }\n return publishModelEvent;\n};\nexport const PublishModelEventContext = createContext<PublishModelEventDelegate>(null);\n\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; (eventData: {entityKey: string, eventType: string, event: any}): void; };\nconst createPublishModelEventWithEntityKey = (router: Router, modelId: string) => {\n function publishModelEventWithEntityKey(entityKey: string, eventType: string, event: any): void;\n function publishModelEventWithEntityKey(eventData: {entityKey: string, eventType: string, event: any}): void;\n function publishModelEventWithEntityKey(...args: any[]) {\n if (args.length === 1) {\n router.publishEvent(new DefaultModelAddress(modelId, args[0].entityKey), args[0].eventType, args[0].event);\n } else {\n router.publishEvent(new DefaultModelAddress(modelId, args[0]), args[1], args[2]);\n }\n }\n return publishModelEventWithEntityKey;\n};\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(createPublishModelEvent(router, modelId), [router, modelId]);\n const publishModelEventWithEntityKey: PublishModelEventWithEntityKeyDelegate = useCallback(createPublishModelEventWithEntityKey(router, modelId), [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; (eventData: { address: string | ModelAddress, eventType: string, event: any }): void; };\nconst createPublishEvent = (router: Router) => {\n function publishEvent(modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any): void;\n function publishEvent(eventData: { address: string | ModelAddress, eventType: string, event: any }): void;\n function publishEvent(...args: any[]): void {\n if (args.length === 1) {\n router.publishEvent(args[0].address, args[0].eventType, args[0].event);\n } else {\n router.publishEvent(args[0], args[1], args[2]);\n }\n }\n return publishEvent;\n};\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(createPublishEvent(router), [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 {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 {Logger, Router, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {PolimerModel} from 'esp-js-polimer';\n\nexport type SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\nexport const logger = Logger.create('useSyncModelWithSelector');\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,\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 let currentModel: TModel;\n let onStateChanged: () => void = null;\n const modelSubscriptionDisposable = router\n .getModelObservable<TModel>(modelId)\n .subscribe(\n (m: any) => {\n // try and get the esp-js-polimer immutable model if possible, this should mutate when any state changes\n const nextModel = tryPreSelectPolimerImmutableModel && PolimerModel.isPolimerModel(m)\n ? m.getEspPolimerImmutableModel()\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 : Object.create(m);\n warnIfModelInstanceHasNotChanged(modelId, currentModel, nextModel);\n currentModel = nextModel;\n if (onStateChanged) {\n onStateChanged();\n }\n }\n );\n return {\n subscribe: (stateChanged: () => void) => {\n onStateChanged = stateChanged;\n return () => {\n onStateChanged = null;\n currentModel = 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 currentModel;\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});\n\nconst warnIfModelInstanceHasNotChanged = (modelId: string, lastModel: any, nextModel: string) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (utils.stringIsEmpty(modelId)) {\n return;\n }\n if (lastModel === nextModel) {\n let stack: string | undefined = undefined;\n try {\n // noinspection ExceptionCaughtLocallyJS\n throw new Error();\n } catch (e) {\n stack = (e as Error).stack;\n }\n logger.warn(\n `useSyncModelWithSelector had detected the latest model update hasn't mutated. This will cause odd render bugs. modelId: ${modelId}`,\n stack\n );\n }\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {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 {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';"],"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,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,c){var a=l(null);if(null===a.current){var v={hasValue:!1,value:null};a.current=v}else v=a.current;a=s((function(){function e(e){if(!u){if(u=!0,i=e,e=r(e),void 0!==c&&v.hasValue){var t=v.value;if(c(t,e))return l=t}return l=e}if(t=l,n(i,e))return t;var o=r(e);return void 0!==c&&c(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,c]);var b=i(e,a[0],a[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(606),c=o(43);t.ConnectableComponent=e=>{var{modelId:t,mapModelToProps:o,createPublishEventProps:a,view:v,viewContext:b}=e,p=r(e,["modelId","mapModelToProps","createPublishEventProps","view","viewContext"]);const f=(0,i.useRouter)();let y=(0,u.useGetModelId)();t=t||y;const P=(0,l.useMemo)((()=>{if(a){return a(((e,o)=>{f.publishEvent(t,e,o)}))}return{}}),[f,t]),M=(0,d.useSyncModelWithSelector)((e=>e),(0,d.syncModelWithSelectorOptions)().setModelId(t).setTryPreSelectPolimerImmutableModel(!1));if(null==M)return null;let h=((e,t,o,r,n,i)=>{const l=c.PolimerModel.isPolimerModel(r)?r.getEspPolimerImmutableModel():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})(f,t,p,M,o,P),E=(0,s.createViewForModel)(M,h,b,v);return n.createElement(u.EspModelContextProvider,Object.assign({modelId:t,model:M,router:f},h),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 c=(0,i.useCallback)(((t,o)=>{s.publishEvent(e,t,o)}),[s,e]),a=(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:c},r.createElement(t.PublishModelEventWithEntityKeyContext.Provider,{value:a},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},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=t.logger=void 0;const r=o(155),n=o(614),i=o(152),l=o(169),u=o(963),s=o(43);t.logger=i.Logger.create("useSyncModelWithSelector");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)(),a=(0,u.useGetModelId)(),v=(null==o?void 0:o.modelId)||a,b=null==o?void 0:o.tryPreSelectPolimerImmutableModel,p=null==o?void 0:o.equalityFn,f=(0,r.useMemo)((()=>s&&i.utils.isString(v)&&s.isModelRegistered(v)?d(s,v,e,b):c()),[s,v]);return(0,n.useSyncExternalStoreWithSelector)(f.subscribe,f.getSnapshot,void 0,f.wrappedSelector,p)};const d=(e,t,o,r)=>{let n,i=null;const l=e.getModelObservable(t).subscribe((e=>{const o=r&&s.PolimerModel.isPolimerModel(e)?e.getEspPolimerImmutableModel():Object.create(e);a(t,n,o),n=o,i&&i()}));return{subscribe:e=>(i=e,()=>{i=null,n=null,l.dispose()}),getSnapshot:()=>n,wrappedSelector:e=>e?o(e):null}},c=()=>({subscribe:()=>()=>{},getSnapshot:()=>null,wrappedSelector:()=>null}),a=(e,t,o)=>{}},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.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(213);Object.defineProperty(e,"createViewForModel",{enumerable:!0,get:function(){return r.createViewForModel}});var n=i(746);Object.defineProperty(e,"connect",{enumerable:!0,get:function(){return n.connect}});var u=i(397);Object.defineProperty(e,"ConnectableComponent",{enumerable:!0,get:function(){return u.ConnectableComponent}});var s=i(606);Object.defineProperty(e,"useSyncModelWithSelector",{enumerable:!0,get:function(){return s.useSyncModelWithSelector}}),Object.defineProperty(e,"syncModelWithSelectorOptions",{enumerable:!0,get:function(){return s.syncModelWithSelectorOptions}});var d=i(169);Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return d.RouterProvider}}),Object.defineProperty(e,"EspRouterContextProvider",{enumerable:!0,get:function(){return d.EspRouterContextProvider}}),Object.defineProperty(e,"RouterContext",{enumerable:!0,get:function(){return d.RouterContext}}),Object.defineProperty(e,"useRouter",{enumerable:!0,get:function(){return d.useRouter}}),Object.defineProperty(e,"PublishEventContext",{enumerable:!0,get:function(){return d.PublishEventContext}}),Object.defineProperty(e,"usePublishEvent",{enumerable:!0,get:function(){return d.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,n)=>(()=>{"use strict";var o={774:(e,t,n)=>{var o=n(155);var r="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,n,o,c){var a=l(null);if(null===a.current){var v={hasValue:!1,value:null};a.current=v}else v=a.current;a=s((function(){function e(e){if(!u){if(u=!0,i=e,e=o(e),void 0!==c&&v.hasValue){var t=v.value;if(c(t,e))return l=t}return l=e}if(t=l,r(i,e))return t;var n=o(e);return void 0!==c&&c(t,n)?t:(i=e,l=n)}var i,l,u=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,o,c]);var p=i(e,a[0],a[1]);return u((function(){v.hasValue=!0,v.value=p}),[p]),d(p),p}},614:(e,t,n)=>{e.exports=n(774)},746:function(e,t,n){var o=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.connect=void 0;const r=n(155),i=n(397);t.connect=function(e,t){return function(n){return function(l){const{modelId:u,viewContext:s}=l,d=o(l,["modelId","viewContext"]);return r.createElement(i.ConnectableComponent,Object.assign({modelId:u,view:n,viewContext:s,createPublishEventProps:t,mapModelToProps:e},d))}}}},397:function(e,t,n){var o=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectableComponent=void 0;const r=n(155),i=n(169),l=n(155),u=n(963),s=n(213),d=n(606),c=n(43);t.ConnectableComponent=e=>{var{modelId:t,mapModelToProps:n,createPublishEventProps:a,view:v,viewContext:p}=e,b=o(e,["modelId","mapModelToProps","createPublishEventProps","view","viewContext"]);const f=(0,i.useRouter)();let y=(0,u.useGetModelId)();t=t||y;const h=(0,l.useMemo)((()=>{if(a){return a(((e,n)=>{f.publishEvent(t,e,n)}))}return{}}),[f,t]),M=(0,d.useSyncModelWithSelector)((e=>e),(0,d.syncModelWithSelectorOptions)().setModelId(t).setTryPreSelectPolimerImmutableModel(!1));if(null==M)return null;let P=((e,t,n,o,r,i)=>{const l=c.PolimerModel.isPolimerModel(o)?o.getEspPolimerImmutableModel():o;let u=Object.assign(Object.assign(Object.assign({modelId:t,router:e},n),i),{model:l});return r&&(u=Object.assign(Object.assign({},u),r(l,i))),u})(f,t,b,M,n,h),E=(0,s.createViewForModel)(M,P,p,v);return r.createElement(u.EspModelContextProvider,Object.assign({modelId:t,model:M,router:f},P),E)}},963:(e,t,n)=>{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=n(155),r=n(152),i=n(155),l=n(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:n,model:u})=>{const s=(0,l.useRouter)();let d=(0,t.useGetModelId)();e=e||d;const c=(0,i.useCallback)(((e,t)=>function(...n){1===n.length?e.publishEvent(t,n[0].eventType,n[0].event):e.publishEvent(t,n[0],n[1])})(s,e),[s,e]),a=(0,i.useCallback)(((e,t)=>function(...n){1===n.length?e.publishEvent(new r.DefaultModelAddress(t,n[0].entityKey),n[0].eventType,n[0].event):e.publishEvent(new r.DefaultModelAddress(t,n[0]),n[1],n[2])})(s,e),[s,e]);return o.createElement(t.GetModelIdContext.Provider,{value:e},o.createElement(t.PublishModelEventContext.Provider,{value:c},o.createElement(t.PublishModelEventWithEntityKeyContext.Provider,{value:a},o.createElement(t.GetModelContext.Provider,{value:u},n))))}},169:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RouterProvider=t.EspRouterContextProvider=t.usePublishEvent=t.PublishEventContext=t.useRouter=t.RouterContext=void 0;const o=n(155),r=n(155);t.RouterContext=(0,r.createContext)(null);t.useRouter=()=>(0,r.useContext)(t.RouterContext);t.PublishEventContext=(0,r.createContext)(null);t.usePublishEvent=()=>(0,r.useContext)(t.PublishEventContext);t.EspRouterContextProvider=({children:e,router:n})=>{let i=(0,t.useRouter)();n=n||i;const l=(0,r.useCallback)((e=>function(...t){1===t.length?e.publishEvent(t[0].address,t[0].eventType,t[0].event):e.publishEvent(t[0],t[1],t[2])})(n),[n]);return o.createElement(t.RouterContext.Provider,{value:n},o.createElement(t.PublishEventContext.Provider,{value:l},e))},t.RouterProvider=t.EspRouterContextProvider},185:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const o=n(43),r=n(213);o.PolimerModelBuilder.prototype.withViewBindings=function(e,t=r.DEFAULT_VIEW_KEY){let n=this._viewMappings||{};return n[t]=e,this._viewMappings=n,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((n=>{(0,r.viewBinding)(t[n],n)(e.constructor)})),e}},606:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useSyncModelWithSelector=t.syncModelWithSelectorOptions=t.logger=void 0;const o=n(155),r=n(614),i=n(152),l=n(169),u=n(963),s=n(43);t.logger=i.Logger.create("useSyncModelWithSelector");t.syncModelWithSelectorOptions=()=>{let e,t=(e,t)=>e===t,n=!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 n},setTryPreSelectPolimerImmutableModel(e){return n=e,this}}};t.useSyncModelWithSelector=(e,n=(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,n);const s=(0,l.useRouter)(),a=(0,u.useGetModelId)(),v=(null==n?void 0:n.modelId)||a,p=null==n?void 0:n.tryPreSelectPolimerImmutableModel,b=null==n?void 0:n.equalityFn,f=(0,o.useMemo)((()=>s&&i.utils.isString(v)&&s.isModelRegistered(v)?d(s,v,e,p):c()),[s,v]);return(0,r.useSyncExternalStoreWithSelector)(f.subscribe,f.getSnapshot,void 0,f.wrappedSelector,b)};const d=(e,t,n,o)=>{let r,i=null;const l=e.getModelObservable(t).subscribe((e=>{const n=o&&s.PolimerModel.isPolimerModel(e)?e.getEspPolimerImmutableModel():Object.create(e);a(t,r,n),r=n,i&&i()}));return{subscribe:e=>(i=e,()=>{i=null,r=null,l.dispose()}),getSnapshot:()=>r,wrappedSelector:e=>e?n(e):null}},c=()=>({subscribe:()=>()=>{},getSnapshot:()=>null,wrappedSelector:()=>null}),a=(e,t,n)=>{}},453:function(e,t,n){var o=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.ViewBinder=void 0;const r=n(213),i=n(169);t.ViewBinder=e=>{var{model:t,viewContext:n}=e,l=o(e,["model","viewContext"]);if(t){const e=(0,i.useRouter)(),o=Object.assign({model:t,router:e},l);return(0,r.createViewForModel)(t,o,n,null)}return null}},213:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ViewMetadataRegistration=t.ViewMetadata=t.DEFAULT_VIEW_KEY=void 0,t.createViewForModel=function(e,n,r,i){let l=i;if(e){let n=e.constructor;if(n._viewMetadata){let e=n._viewMetadata;if(r&&e.hasRegisteredViewContext(r)){l=e.viewRegistrations[r].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 '${r}'`);return o.createElement(l,n)},t.viewBinding=function(e,n=t.DEFAULT_VIEW_KEY){return r.Guard.isDefined(e,"view must be defined"),r.Guard.isString(n,"displayContext must be a string"),function(t){let o=function(e){e._viewMetadata||(e._viewMetadata=new i);return e._viewMetadata}(t);if(o.hasRegisteredViewContext(n))throw new Error(`Context ${n} already registered for view`);o.viewRegistrations[n]=new l(e,n)}};const o=n(155),r=n(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=n}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var n=r[e]={exports:{}};return o[e].call(n.exports,n,n.exports,i),n.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.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 n=i(213);Object.defineProperty(e,"viewBinding",{enumerable:!0,get:function(){return n.viewBinding}}),Object.defineProperty(e,"DEFAULT_VIEW_KEY",{enumerable:!0,get:function(){return n.DEFAULT_VIEW_KEY}});var o=i(213);Object.defineProperty(e,"createViewForModel",{enumerable:!0,get:function(){return o.createViewForModel}});var r=i(746);Object.defineProperty(e,"connect",{enumerable:!0,get:function(){return r.connect}});var u=i(397);Object.defineProperty(e,"ConnectableComponent",{enumerable:!0,get:function(){return u.ConnectableComponent}});var s=i(606);Object.defineProperty(e,"useSyncModelWithSelector",{enumerable:!0,get:function(){return s.useSyncModelWithSelector}}),Object.defineProperty(e,"syncModelWithSelectorOptions",{enumerable:!0,get:function(){return s.syncModelWithSelectorOptions}});var d=i(169);Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return d.RouterProvider}}),Object.defineProperty(e,"EspRouterContextProvider",{enumerable:!0,get:function(){return d.EspRouterContextProvider}}),Object.defineProperty(e,"RouterContext",{enumerable:!0,get:function(){return d.RouterContext}}),Object.defineProperty(e,"useRouter",{enumerable:!0,get:function(){return d.useRouter}}),Object.defineProperty(e,"PublishEventContext",{enumerable:!0,get:function(){return d.PublishEventContext}}),Object.defineProperty(e,"usePublishEvent",{enumerable:!0,get:function(){return d.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,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,aAAQ,oFAAA7B,kBAAkB,IAC1B,aACI,yEAAA9B,OAAO,IAGX,aAKI,sFAAAQ,oBAAoB,IAExB,aACI,0FAAAU,wBAAwB,IAExB,8FAAAC,4BAA4B,IAIhC,aACI,gFAAAmC,cAAc,IAEd,0FAAAH,wBAAwB,IAExB,+EAAAH,aAAa,IACb,2EAAAtC,SAAS,IAET,qFAAAuC,mBAAmB,IACnB,iFAAAC,eAAe,IAEnB,aACI,+EAAAtC,aAAa,IACb,mFAAAoB,iBAAiB,IACjB,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/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} from 'esp-js';\nimport {EspModelContextProvider, useGetModelId} from './espModelContextProvider';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\nimport {PolimerModel} from 'esp-js-polimer';\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 = PolimerModel.isPolimerModel(initialModel)\n ? initialModel.getEspPolimerImmutableModel()\n : 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 {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 {Logger, Router, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {PolimerModel} from 'esp-js-polimer';\n\nexport type SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\nexport const logger = Logger.create('useSyncModelWithSelector');\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,\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 let currentModel: TModel;\n let onStateChanged: () => void = null;\n const modelSubscriptionDisposable = router\n .getModelObservable<TModel>(modelId)\n .subscribe(\n (m: any) => {\n // try and get the esp-js-polimer immutable model if possible, this should mutate when any state changes\n const nextModel = tryPreSelectPolimerImmutableModel && PolimerModel.isPolimerModel(m)\n ? m.getEspPolimerImmutableModel()\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 : Object.create(m);\n warnIfModelInstanceHasNotChanged(modelId, currentModel, nextModel);\n currentModel = nextModel;\n if (onStateChanged) {\n onStateChanged();\n }\n }\n );\n return {\n subscribe: (stateChanged: () => void) => {\n onStateChanged = stateChanged;\n return () => {\n onStateChanged = null;\n currentModel = 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 currentModel;\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});\n\nconst warnIfModelInstanceHasNotChanged = (modelId: string, lastModel: any, nextModel: string) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (utils.stringIsEmpty(modelId)) {\n return;\n }\n if (lastModel === nextModel) {\n let stack: string | undefined = undefined;\n try {\n // noinspection ExceptionCaughtLocallyJS\n throw new Error();\n } catch (e) {\n stack = (e as Error).stack;\n }\n logger.warn(\n `useSyncModelWithSelector had detected the latest model update hasn't mutated. This will cause odd render bugs. modelId: ${modelId}`,\n stack\n );\n }\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {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 {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';"],"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","PolimerModel","isPolimerModel","getEspPolimerImmutableModel","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","PolimerModelBuilder","prototype","withViewBindings","displayContext","DEFAULT_VIEW_KEY","viewMappings","this","_viewMappings","registerWithRouter","call","keys","forEach","viewBinding","constructor","logger","Logger","create","equalityFn","tryPreSelectPolimerImmutableModel","setEqualityFn","selector","options","utils","isFunction","Error","isObject","checkArguments","dependencies","isString","isModelRegistered","createSubscriptionState","createNoopSubscriptionState","subscribe","getSnapshot","undefined","wrappedSelector","currentModel","onStateChanged","modelSubscriptionDisposable","getModelObservable","nextModel","warnIfModelInstanceHasNotChanged","stateChanged","dispose","snapshot","lastModel","ViewBinder","newProps","finalView","constructorFunction","_viewMetadata","viewMetadata","hasRegisteredViewContext","viewRegistrations","React","createElement","Guard","isDefined","target","ViewMetadata","getMetadata","ViewMetadataRegistration","_viewRegistrations","_view","_displayContext","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
1
+ {"version":3,"file":"esp-react.min.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,UA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,KAAAC,gBAAAA,CACnC,CAEA,QAAIzH,GACA,OAAO+D,KAAKyD,KAChB,CAEA,kBAAI5D,GACA,OAAOG,KAAK0D,eAChB,EAXJ,sCCpGAhK,EAAOD,QAAUM,UCAjBL,EAAOD,QAAUO,WCAjBN,EAAOD,QAAUQ,ICCb0J,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBjC,IAAjBkC,EACH,OAAOA,EAAarK,QAGrB,IAAIC,EAASiK,EAAyBE,GAAY,CAGjDpK,QAAS,CAAC,GAOX,OAHAsK,EAAoBF,GAAU1D,KAAKzG,EAAOD,QAASC,EAAQA,EAAOD,QAASmK,GAGpElK,EAAOD,OACf,gkBCFA,OAEA,aAAQ,4EAAA+I,UAAU,IAClB,aAAQ,6EAAAlC,WAAW,IAAE,kFAAAR,gBAAgB,IACrC,aAAQ,oFAAAlC,kBAAkB,IAC1B,aACI,yEAAA9B,OAAO,IAGX,aAKI,sFAAAQ,oBAAoB,IAExB,aACI,0FAAAU,wBAAwB,IAExB,8FAAAC,4BAA4B,IAIhC,aACI,gFAAAwC,cAAc,IAEd,0FAAAJ,wBAAwB,IAExB,+EAAAH,aAAa,IACb,2EAAA1C,SAAS,IAET,qFAAA2C,mBAAmB,IACnB,iFAAAC,eAAe,IAEnB,aACI,+EAAA1C,aAAa,IACb,mFAAAoB,iBAAiB,IACjB,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/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} from 'esp-js';\nimport {EspModelContextProvider, useGetModelId} from './espModelContextProvider';\nimport {createViewForModel} from './viewBindingDecorator';\nimport {syncModelWithSelectorOptions, useSyncModelWithSelector} from './useSyncModelWithSelector';\nimport {PolimerModel} from 'esp-js-polimer';\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 = PolimerModel.isPolimerModel(initialModel)\n ? initialModel.getEspPolimerImmutableModel()\n : 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, Router} 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; (eventData: {eventType: string, event: any}): void; };\nconst createPublishModelEvent = (router: Router, modelId: string) => {\n function publishModelEvent(eventType: string, event: any): void;\n function publishModelEvent(eventData: {eventType: string, event: any}): void;\n function publishModelEvent(...args: any[]) {\n if (args.length === 1) {\n router.publishEvent(modelId, args[0].eventType, args[0].event);\n } else {\n router.publishEvent(modelId, args[0], args[1]);\n }\n }\n return publishModelEvent;\n};\nexport const PublishModelEventContext = createContext<PublishModelEventDelegate>(null);\n\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; (eventData: {entityKey: string, eventType: string, event: any}): void; };\nconst createPublishModelEventWithEntityKey = (router: Router, modelId: string) => {\n function publishModelEventWithEntityKey(entityKey: string, eventType: string, event: any): void;\n function publishModelEventWithEntityKey(eventData: {entityKey: string, eventType: string, event: any}): void;\n function publishModelEventWithEntityKey(...args: any[]) {\n if (args.length === 1) {\n router.publishEvent(new DefaultModelAddress(modelId, args[0].entityKey), args[0].eventType, args[0].event);\n } else {\n router.publishEvent(new DefaultModelAddress(modelId, args[0]), args[1], args[2]);\n }\n }\n return publishModelEventWithEntityKey;\n};\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(createPublishModelEvent(router, modelId), [router, modelId]);\n const publishModelEventWithEntityKey: PublishModelEventWithEntityKeyDelegate = useCallback(createPublishModelEventWithEntityKey(router, modelId), [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; (eventData: { address: string | ModelAddress, eventType: string, event: any }): void; };\nconst createPublishEvent = (router: Router) => {\n function publishEvent(modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any): void;\n function publishEvent(eventData: { address: string | ModelAddress, eventType: string, event: any }): void;\n function publishEvent(...args: any[]): void {\n if (args.length === 1) {\n router.publishEvent(args[0].address, args[0].eventType, args[0].event);\n } else {\n router.publishEvent(args[0], args[1], args[2]);\n }\n }\n return publishEvent;\n};\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(createPublishEvent(router), [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 {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 {Logger, Router, utils} from 'esp-js';\nimport {useRouter} from './espRouterContextProvider';\nimport {useGetModelId} from './espModelContextProvider';\nimport {PolimerModel} from 'esp-js-polimer';\n\nexport type SyncModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\nexport const logger = Logger.create('useSyncModelWithSelector');\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,\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 let currentModel: TModel;\n let onStateChanged: () => void = null;\n const modelSubscriptionDisposable = router\n .getModelObservable<TModel>(modelId)\n .subscribe(\n (m: any) => {\n // try and get the esp-js-polimer immutable model if possible, this should mutate when any state changes\n const nextModel = tryPreSelectPolimerImmutableModel && PolimerModel.isPolimerModel(m)\n ? m.getEspPolimerImmutableModel()\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 : Object.create(m);\n warnIfModelInstanceHasNotChanged(modelId, currentModel, nextModel);\n currentModel = nextModel;\n if (onStateChanged) {\n onStateChanged();\n }\n }\n );\n return {\n subscribe: (stateChanged: () => void) => {\n onStateChanged = stateChanged;\n return () => {\n onStateChanged = null;\n currentModel = 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 currentModel;\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});\n\nconst warnIfModelInstanceHasNotChanged = (modelId: string, lastModel: any, nextModel: string) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n if (utils.stringIsEmpty(modelId)) {\n return;\n }\n if (lastModel === nextModel) {\n let stack: string | undefined = undefined;\n try {\n // noinspection ExceptionCaughtLocallyJS\n throw new Error();\n } catch (e) {\n stack = (e as Error).stack;\n }\n logger.warn(\n `useSyncModelWithSelector had detected the latest model update hasn't mutated. This will cause odd render bugs. modelId: ${modelId}`,\n stack\n );\n }\n};","// notice_start\n/*\n * Copyright 2015 Dev Shop Limited\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// notice_end\n\nimport * as React from 'react';\nimport {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 {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';"],"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","PolimerModel","isPolimerModel","getEspPolimerImmutableModel","getChildProps","viewElement","createViewForModel","EspModelContextProvider","GetModelIdContext","createContext","useContext","GetModelContext","useGetModel","PublishModelEventContext","usePublishModelEvent","PublishModelEventWithEntityKeyContext","usePublishModelEventWithEntityKey","children","publishModelEvent","useCallback","args","length","createPublishModelEvent","publishModelEventWithEntityKey","DefaultModelAddress","entityKey","createPublishModelEventWithEntityKey","Provider","RouterContext","PublishEventContext","usePublishEvent","EspRouterContextProvider","routerFromContext","address","createPublishEvent","RouterProvider","PolimerModelBuilder","prototype","withViewBindings","displayContext","DEFAULT_VIEW_KEY","viewMappings","this","_viewMappings","registerWithRouter","call","keys","forEach","viewBinding","constructor","logger","Logger","create","equalityFn","tryPreSelectPolimerImmutableModel","setEqualityFn","selector","options","utils","isFunction","Error","isObject","checkArguments","dependencies","isString","isModelRegistered","createSubscriptionState","createNoopSubscriptionState","subscribe","getSnapshot","undefined","wrappedSelector","currentModel","onStateChanged","modelSubscriptionDisposable","getModelObservable","nextModel","warnIfModelInstanceHasNotChanged","stateChanged","dispose","snapshot","lastModel","ViewBinder","newProps","finalView","constructorFunction","_viewMetadata","viewMetadata","hasRegisteredViewContext","viewRegistrations","React","createElement","Guard","isDefined","target","ViewMetadata","getMetadata","ViewMetadataRegistration","_viewRegistrations","_view","_displayContext","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
@@ -14,7 +14,13 @@ export declare const GetModelContext: React.Context<object>;
14
14
  * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
15
15
  */
16
16
  export declare const useGetModel: <TModel>() => TModel;
17
- export type PublishModelEventDelegate = (eventType: string, event: any) => void;
17
+ export type PublishModelEventDelegate = {
18
+ (eventType: string, event: any): void;
19
+ (eventData: {
20
+ eventType: string;
21
+ event: any;
22
+ }): void;
23
+ };
18
24
  export declare const PublishModelEventContext: React.Context<PublishModelEventDelegate>;
19
25
  /**
20
26
  * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM.
@@ -24,7 +30,14 @@ export declare const PublishModelEventContext: React.Context<PublishModelEventDe
24
30
  * To use this, please ensure your V-DOM has the EspModelContextProvider at a higher node.
25
31
  */
26
32
  export declare const usePublishModelEvent: () => PublishModelEventDelegate;
27
- export type PublishModelEventWithEntityKeyDelegate = (entityKey: string, eventType: string, event: any) => void;
33
+ export type PublishModelEventWithEntityKeyDelegate = {
34
+ (entityKey: string, eventType: string, event: any): void;
35
+ (eventData: {
36
+ entityKey: string;
37
+ eventType: string;
38
+ event: any;
39
+ }): void;
40
+ };
28
41
  export declare const PublishModelEventWithEntityKeyContext: React.Context<PublishModelEventWithEntityKeyDelegate>;
29
42
  /**
30
43
  * 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.
@@ -12,7 +12,14 @@ export declare const RouterContext: React.Context<Router>;
12
12
  * </EspRouterContextProvider>
13
13
  */
14
14
  export declare const useRouter: () => Router;
15
- export type PublishEventDelegate = (modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any) => void;
15
+ export type PublishEventDelegate = {
16
+ (modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any): void;
17
+ (eventData: {
18
+ address: string | ModelAddress;
19
+ eventType: string;
20
+ event: any;
21
+ }): void;
22
+ };
16
23
  export declare const PublishEventContext: React.Context<PublishEventDelegate>;
17
24
  /**
18
25
  * Returns a function which can be used to publish an event.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esp-js-react",
3
- "version": "8.0.15",
3
+ "version": "8.1.1-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.15",
28
- "esp-js-polimer": "^8.0.15",
27
+ "esp-js": "^8.1.1-next.0",
28
+ "esp-js-polimer": "^8.1.1-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 || ^19.0.0"
45
45
  },
46
- "gitHead": "d6df2e18e14bedeae9f7ce2335a6f44c2d68cb55"
46
+ "gitHead": "1b8516a4343d01d879d899b8cf12caf373447fbd"
47
47
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {DefaultModelAddress} from 'esp-js';
2
+ import {DefaultModelAddress, Router} from 'esp-js';
3
3
  import {useContext, useCallback, createContext, PropsWithChildren} from 'react';
4
4
  import {useRouter} from './espRouterContextProvider';
5
5
 
@@ -19,8 +19,21 @@ export const GetModelContext = createContext<object>(null);
19
19
  */
20
20
  export const useGetModel = <TModel,>() => useContext(GetModelContext) as TModel;
21
21
 
22
- export type PublishModelEventDelegate = (eventType: string, event: any) => void;
22
+ export type PublishModelEventDelegate = { (eventType: string, event: any): void; (eventData: {eventType: string, event: any}): void; };
23
+ const createPublishModelEvent = (router: Router, modelId: string) => {
24
+ function publishModelEvent(eventType: string, event: any): void;
25
+ function publishModelEvent(eventData: {eventType: string, event: any}): void;
26
+ function publishModelEvent(...args: any[]) {
27
+ if (args.length === 1) {
28
+ router.publishEvent(modelId, args[0].eventType, args[0].event);
29
+ } else {
30
+ router.publishEvent(modelId, args[0], args[1]);
31
+ }
32
+ }
33
+ return publishModelEvent;
34
+ };
23
35
  export const PublishModelEventContext = createContext<PublishModelEventDelegate>(null);
36
+
24
37
  /**
25
38
  * Returns a function which can be used to publish an event to the model connected at a higher point in the V-DOM.
26
39
  *
@@ -30,7 +43,19 @@ export const PublishModelEventContext = createContext<PublishModelEventDelegate>
30
43
  */
31
44
  export const usePublishModelEvent = () => useContext(PublishModelEventContext);
32
45
 
33
- export type PublishModelEventWithEntityKeyDelegate = (entityKey: string, eventType: string, event: any) => void;
46
+ export type PublishModelEventWithEntityKeyDelegate = {(entityKey: string, eventType: string, event: any): void; (eventData: {entityKey: string, eventType: string, event: any}): void; };
47
+ const createPublishModelEventWithEntityKey = (router: Router, modelId: string) => {
48
+ function publishModelEventWithEntityKey(entityKey: string, eventType: string, event: any): void;
49
+ function publishModelEventWithEntityKey(eventData: {entityKey: string, eventType: string, event: any}): void;
50
+ function publishModelEventWithEntityKey(...args: any[]) {
51
+ if (args.length === 1) {
52
+ router.publishEvent(new DefaultModelAddress(modelId, args[0].entityKey), args[0].eventType, args[0].event);
53
+ } else {
54
+ router.publishEvent(new DefaultModelAddress(modelId, args[0]), args[1], args[2]);
55
+ }
56
+ }
57
+ return publishModelEventWithEntityKey;
58
+ };
34
59
  export const PublishModelEventWithEntityKeyContext = createContext<PublishModelEventWithEntityKeyDelegate>(null);
35
60
  /**
36
61
  * 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.
@@ -60,12 +85,8 @@ export const EspModelContextProvider = ({modelId, children, model}: PropsWithChi
60
85
  // 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
86
  let modelIdFromContext = useGetModelId();
62
87
  modelId = modelId || modelIdFromContext;
63
- const publishModelEvent: PublishModelEventDelegate = useCallback((eventType: string, event: any) => {
64
- router.publishEvent(modelId, eventType, event);
65
- }, [router, modelId]);
66
- const publishModelEventWithEntityKey: PublishModelEventWithEntityKeyDelegate = useCallback((entityKey: string, eventType: string, event: any) => {
67
- router.publishEvent(new DefaultModelAddress(modelId, entityKey), eventType, event);
68
- }, [router, modelId]);
88
+ const publishModelEvent: PublishModelEventDelegate = useCallback(createPublishModelEvent(router, modelId), [router, modelId]);
89
+ const publishModelEventWithEntityKey: PublishModelEventWithEntityKeyDelegate = useCallback(createPublishModelEventWithEntityKey(router, modelId), [router, modelId]);
69
90
  return (
70
91
  <GetModelIdContext.Provider value={modelId}>
71
92
  <PublishModelEventContext.Provider value={publishModelEvent}>
@@ -35,7 +35,19 @@ export const useRouter = () => {
35
35
  return useContext(RouterContext);
36
36
  };
37
37
 
38
- export type PublishEventDelegate = (modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any) => void;
38
+ export type PublishEventDelegate = {(modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any): void; (eventData: { address: string | ModelAddress, eventType: string, event: any }): void; };
39
+ const createPublishEvent = (router: Router) => {
40
+ function publishEvent(modelIdOrModelAddress: string | ModelAddress, eventType: string, event: any): void;
41
+ function publishEvent(eventData: { address: string | ModelAddress, eventType: string, event: any }): void;
42
+ function publishEvent(...args: any[]): void {
43
+ if (args.length === 1) {
44
+ router.publishEvent(args[0].address, args[0].eventType, args[0].event);
45
+ } else {
46
+ router.publishEvent(args[0], args[1], args[2]);
47
+ }
48
+ }
49
+ return publishEvent;
50
+ };
39
51
  export const PublishEventContext = createContext<PublishEventDelegate>(null);
40
52
 
41
53
  /**
@@ -60,9 +72,7 @@ export const EspRouterContextProvider = ({children, router}: EspRouterContextPro
60
72
  // 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
73
  let routerFromContext = useRouter();
62
74
  router = router || routerFromContext;
63
- const publishEvent: PublishEventDelegate = useCallback((modelIdOrModelAddress: string, eventType: string, event: any) => {
64
- router.publishEvent(modelIdOrModelAddress, eventType, event);
65
- }, [router]);
75
+ const publishEvent: PublishEventDelegate = useCallback(createPublishEvent(router), [router]);
66
76
  return (
67
77
  <RouterContext.Provider value={router}>
68
78
  <PublishEventContext.Provider value={publishEvent}>
@@ -103,12 +103,16 @@ describe('EspModelContextProviderTests tests', () => {
103
103
  expect(testModel1.state.value).toBe('initial-value');
104
104
  result.current('test-event', 'updated');
105
105
  expect(testModel1.state.value).toBe('updated');
106
+ result.current({eventType: 'test-event', event: 'updated2' });
107
+ expect(testModel1.state.value).toBe('updated2');
106
108
 
107
109
  rerender();
108
110
 
109
111
  expect(testModel2.state.value).toBe('initial-value');
110
112
  result.current('test-event', 'updated');
111
113
  expect(testModel2.state.value).toBe('updated');
114
+ result.current({eventType: 'test-event', event: 'updated2' });
115
+ expect(testModel2.state.value).toBe('updated2');
112
116
  });
113
117
 
114
118
  it('publishModelEventWithEntityKey publishes to correct model and changes on re-render', () => {
@@ -130,6 +134,8 @@ describe('EspModelContextProviderTests tests', () => {
130
134
  result.current('the-entity-key', 'test-event-with-entity-key', 'updated');
131
135
  expect(testModel1.state.value).toBe('updated');
132
136
  expect(testModel1.state.entityKey).toBe('the-entity-key');
137
+ result.current({ entityKey: 'the-entity-key', eventType: 'test-event-with-entity-key', event: 'updated2'});
138
+ expect(testModel1.state.value).toBe('updated2');
133
139
 
134
140
  rerender();
135
141
 
@@ -138,5 +144,7 @@ describe('EspModelContextProviderTests tests', () => {
138
144
  result.current('the-entity-key', 'test-event-with-entity-key', 'updated');
139
145
  expect(testModel2.state.value).toBe('updated');
140
146
  expect(testModel2.state.entityKey).toBe('the-entity-key');
147
+ result.current({ entityKey: 'the-entity-key', eventType: 'test-event-with-entity-key', event: 'updated2'});
148
+ expect(testModel2.state.value).toBe('updated2');
141
149
  });
142
150
  });
@@ -50,5 +50,7 @@ describe('EspRouterContextProvider tests', () => {
50
50
  expect(testModel.state.value).toBe('initial-value');
51
51
  result.current('model-id', 'test-event', 'updated');
52
52
  expect(testModel.state.value).toBe('updated');
53
+ result.current({ address: 'model-id', eventType: 'test-event', event: 'updated2'});
54
+ expect(testModel.state.value).toBe('updated2');
53
55
  });
54
56
  });