esp-js-react 9.0.0-beta.1 → 9.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/{esp-react.esm.js → esp-react.esm.mjs} +38 -41
- package/.dist/esp-react.esm.mjs.map +1 -0
- package/.dist/esp-react.js +42 -45
- package/.dist/esp-react.js.map +1 -1
- package/.dist/esp-react.min.js +1 -19
- package/.dist/esp-react.min.js.map +1 -1
- package/.dist/typings/connectableComponent.d.ts +4 -4
- package/.dist/typings/espApp.d.ts +1 -1
- package/.dist/typings/espModulesContext.d.ts +1 -1
- package/.dist/typings/espStoreContextProvider.d.ts +3 -3
- package/.dist/typings/index.d.ts +4 -4
- package/.dist/typings/useSyncStoreModelWithSelector.d.ts +47 -0
- package/README.md +2 -2
- package/package.json +18 -8
- package/.dist/esp-react.esm.js.map +0 -1
- package/.dist/typings/useSyncModelWithSelector.d.ts +0 -45
|
@@ -336,8 +336,8 @@ const EspEventBusContextProvider = ({ children, bus }) => {
|
|
|
336
336
|
};
|
|
337
337
|
const GetStoreIdContext = createContext(null);
|
|
338
338
|
const useGetStoreId = () => useContext(GetStoreIdContext);
|
|
339
|
-
const
|
|
340
|
-
const
|
|
339
|
+
const GetStoreModelContext = createContext(null);
|
|
340
|
+
const useGetStoreModel = () => useContext(GetStoreModelContext);
|
|
341
341
|
const createPublishStoreEvent = (bus, storeId) => {
|
|
342
342
|
function publishStoreEvent(...args) {
|
|
343
343
|
if (args.length === 1) {
|
|
@@ -368,7 +368,7 @@ const EspStoreContextProvider = ({ storeId, children, model }) => {
|
|
|
368
368
|
storeId = storeId || storeIdFromContext;
|
|
369
369
|
const publishStoreEvent = useCallback(createPublishStoreEvent(bus, storeId), [bus, storeId]);
|
|
370
370
|
const publishStoreEventWithEntityKey = useCallback(createPublishStoreEventWithEntityKey(bus, storeId), [bus, storeId]);
|
|
371
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreIdContext.Provider, { value: storeId, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventContext.Provider, { value: publishStoreEvent, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventWithEntityKeyContext.Provider, { value: publishStoreEventWithEntityKey, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
371
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreIdContext.Provider, { value: storeId, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventContext.Provider, { value: publishStoreEvent, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventWithEntityKeyContext.Provider, { value: publishStoreEventWithEntityKey, children: /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreModelContext.Provider, { value: model, children }) }) }) });
|
|
372
372
|
};
|
|
373
373
|
var withSelector = { exports: {} };
|
|
374
374
|
var useSyncExternalStoreWithSelector_production = {};
|
|
@@ -525,8 +525,8 @@ if (process.env.NODE_ENV === "production") {
|
|
|
525
525
|
withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
|
|
526
526
|
}
|
|
527
527
|
var withSelectorExports = withSelector.exports;
|
|
528
|
-
Logger.create("
|
|
529
|
-
const
|
|
528
|
+
Logger.create("useSyncStoreModelWithSelector");
|
|
529
|
+
const syncStoreModelWithSelectorOptions = () => {
|
|
530
530
|
let storeId = void 0;
|
|
531
531
|
let equalityFn = (a, b) => a === b;
|
|
532
532
|
return {
|
|
@@ -548,16 +548,16 @@ const syncModelWithSelectorOptions = () => {
|
|
|
548
548
|
};
|
|
549
549
|
const checkArguments = (selector, options) => {
|
|
550
550
|
if (!utils.isFunction(selector)) {
|
|
551
|
-
throw new Error("You must pass a selector function to
|
|
551
|
+
throw new Error("You must pass a selector function to useSyncStoreModelWithSelector");
|
|
552
552
|
}
|
|
553
553
|
if (!utils.isObject(options)) {
|
|
554
|
-
throw new Error("You must provide options when using
|
|
554
|
+
throw new Error("You must provide options when using useSyncStoreModelWithSelector");
|
|
555
555
|
}
|
|
556
556
|
if (!utils.isFunction(options.equalityFn)) {
|
|
557
|
-
throw new Error("You must provide an equalityFn when using
|
|
557
|
+
throw new Error("You must provide an equalityFn when using useSyncStoreModelWithSelector");
|
|
558
558
|
}
|
|
559
559
|
};
|
|
560
|
-
const
|
|
560
|
+
const useSyncStoreModelWithSelector = (selector, options = syncStoreModelWithSelectorOptions()) => {
|
|
561
561
|
checkArguments(selector, options);
|
|
562
562
|
const bus = useEventBus();
|
|
563
563
|
const storeIdFromContext = useGetStoreId();
|
|
@@ -565,29 +565,32 @@ const useSyncModelWithSelector = (selector, options = syncModelWithSelectorOptio
|
|
|
565
565
|
const equalityFn = options == null ? void 0 : options.equalityFn;
|
|
566
566
|
const dependencies = useMemo(
|
|
567
567
|
() => {
|
|
568
|
-
const canSubscribe = bus && utils.isString(storeId)
|
|
568
|
+
const canSubscribe = bus && utils.isString(storeId);
|
|
569
569
|
if (canSubscribe) {
|
|
570
|
-
return createSubscriptionState(bus, storeId
|
|
570
|
+
return createSubscriptionState(bus, storeId);
|
|
571
571
|
}
|
|
572
572
|
return createNoopSubscriptionState();
|
|
573
573
|
},
|
|
574
|
-
// Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.
|
|
575
574
|
[bus, storeId]
|
|
576
575
|
);
|
|
576
|
+
const wrappedSelector = (snapshot) => snapshot ? selector(snapshot) : null;
|
|
577
577
|
return withSelectorExports.useSyncExternalStoreWithSelector(
|
|
578
578
|
dependencies.subscribe,
|
|
579
579
|
dependencies.getSnapshot,
|
|
580
580
|
void 0,
|
|
581
|
-
|
|
581
|
+
wrappedSelector,
|
|
582
582
|
equalityFn
|
|
583
583
|
);
|
|
584
584
|
};
|
|
585
|
-
const createSubscriptionState = (bus, storeId
|
|
585
|
+
const createSubscriptionState = (bus, storeId) => {
|
|
586
586
|
let currentModel;
|
|
587
587
|
return {
|
|
588
588
|
subscribe: (stateChanged) => {
|
|
589
|
-
const modelSubscriptionDisposable = bus.
|
|
589
|
+
const modelSubscriptionDisposable = bus.getStoreModelObservable(storeId).subscribe(
|
|
590
590
|
(m) => {
|
|
591
|
+
if (m === currentModel) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
591
594
|
currentModel = m;
|
|
592
595
|
stateChanged();
|
|
593
596
|
}
|
|
@@ -598,19 +601,14 @@ const createSubscriptionState = (bus, storeId, selector) => {
|
|
|
598
601
|
};
|
|
599
602
|
},
|
|
600
603
|
// React expects getSnapshot to be pure and stable between renders unless the store has changed.
|
|
601
|
-
// We seed currentModel from bus.
|
|
604
|
+
// We seed currentModel from bus.getStoreModel() on first call (before subscribe has been called),
|
|
602
605
|
// then keep it up-to-date via the subscription callback above.
|
|
606
|
+
// getStoreModel() throws for a store that's been observed but not registered yet, so check first; until then the snapshot is null.
|
|
603
607
|
getSnapshot: () => {
|
|
604
|
-
if (currentModel == null) {
|
|
605
|
-
currentModel = bus.
|
|
608
|
+
if (currentModel == null && bus.isStoreRegistered(storeId)) {
|
|
609
|
+
currentModel = bus.getStoreModel(storeId);
|
|
606
610
|
}
|
|
607
611
|
return currentModel;
|
|
608
|
-
},
|
|
609
|
-
// While getSnapshot needs to model to be immutable,
|
|
610
|
-
// useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.
|
|
611
|
-
// The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.
|
|
612
|
-
wrappedSelector: (snapshot) => {
|
|
613
|
-
return snapshot ? selector(snapshot) : null;
|
|
614
612
|
}
|
|
615
613
|
};
|
|
616
614
|
};
|
|
@@ -619,10 +617,9 @@ const createNoopSubscriptionState = () => ({
|
|
|
619
617
|
return () => {
|
|
620
618
|
};
|
|
621
619
|
},
|
|
622
|
-
getSnapshot: () => null
|
|
623
|
-
wrappedSelector: () => null
|
|
620
|
+
getSnapshot: () => null
|
|
624
621
|
});
|
|
625
|
-
const getChildProps = (bus, storeId, restProps, model,
|
|
622
|
+
const getChildProps = (bus, storeId, restProps, model, mapStoreModelToProps, publishEventProps) => {
|
|
626
623
|
let childProps = {
|
|
627
624
|
storeId,
|
|
628
625
|
bus,
|
|
@@ -630,17 +627,17 @@ const getChildProps = (bus, storeId, restProps, model, mapModelToProps, publishE
|
|
|
630
627
|
...publishEventProps,
|
|
631
628
|
model
|
|
632
629
|
};
|
|
633
|
-
if (
|
|
630
|
+
if (mapStoreModelToProps) {
|
|
634
631
|
childProps = {
|
|
635
632
|
...childProps,
|
|
636
|
-
...
|
|
633
|
+
...mapStoreModelToProps(model, publishEventProps)
|
|
637
634
|
};
|
|
638
635
|
}
|
|
639
636
|
return childProps;
|
|
640
637
|
};
|
|
641
638
|
const ConnectableComponent = ({
|
|
642
639
|
storeId,
|
|
643
|
-
|
|
640
|
+
mapStoreModelToProps,
|
|
644
641
|
createPublishEventProps,
|
|
645
642
|
view,
|
|
646
643
|
...rest
|
|
@@ -660,31 +657,31 @@ const ConnectableComponent = ({
|
|
|
660
657
|
},
|
|
661
658
|
[bus, storeId]
|
|
662
659
|
);
|
|
663
|
-
const model =
|
|
660
|
+
const model = useSyncStoreModelWithSelector(
|
|
664
661
|
(m) => m,
|
|
665
|
-
|
|
662
|
+
syncStoreModelWithSelectorOptions().setStoreId(storeId)
|
|
666
663
|
);
|
|
667
664
|
if (model == null) {
|
|
668
665
|
return null;
|
|
669
666
|
}
|
|
670
|
-
let childProps = getChildProps(bus, storeId, rest, model,
|
|
667
|
+
let childProps = getChildProps(bus, storeId, rest, model, mapStoreModelToProps, publishEventProps);
|
|
671
668
|
let viewElement = view ? require$$0.createElement(view, childProps) : null;
|
|
672
669
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(EspStoreContextProvider, { storeId, model, bus, ...childProps, children: viewElement });
|
|
673
670
|
};
|
|
674
|
-
const EspModulesContext = require$$
|
|
671
|
+
const EspModulesContext = require$$0.createContext([]);
|
|
675
672
|
const RegionView = ({ regionName }) => {
|
|
676
673
|
const modules = useContext(EspModulesContext);
|
|
677
674
|
const bindings = useMemo(
|
|
678
675
|
() => modules.flatMap((m) => m.viewBindings).filter((b) => b.region === regionName),
|
|
679
676
|
[modules, regionName]
|
|
680
677
|
);
|
|
681
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: bindings.map((binding) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
678
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: bindings.map((binding, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
682
679
|
ConnectableComponent,
|
|
683
680
|
{
|
|
684
681
|
storeId: binding.storeId,
|
|
685
682
|
view: binding.viewComponent
|
|
686
683
|
},
|
|
687
|
-
binding.storeId
|
|
684
|
+
`${binding.storeId}:${index}`
|
|
688
685
|
)) });
|
|
689
686
|
};
|
|
690
687
|
const EspApp = ({ app, children }) => /* @__PURE__ */ jsxRuntimeExports.jsx(EspEventBusContextProvider, { bus: app.eventBus, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EspModulesContext.Provider, { value: app.modules, children }) });
|
|
@@ -695,19 +692,19 @@ export {
|
|
|
695
692
|
EspModulesContext,
|
|
696
693
|
EspStoreContextProvider,
|
|
697
694
|
EventBusContext,
|
|
698
|
-
GetStoreContext,
|
|
699
695
|
GetStoreIdContext,
|
|
696
|
+
GetStoreModelContext,
|
|
700
697
|
PublishEventContext,
|
|
701
698
|
PublishStoreEventContext,
|
|
702
699
|
PublishStoreEventWithEntityKeyContext,
|
|
703
700
|
RegionView,
|
|
704
|
-
|
|
701
|
+
syncStoreModelWithSelectorOptions,
|
|
705
702
|
useEventBus,
|
|
706
|
-
useGetStore,
|
|
707
703
|
useGetStoreId,
|
|
704
|
+
useGetStoreModel,
|
|
708
705
|
usePublishEvent,
|
|
709
706
|
usePublishStoreEvent,
|
|
710
707
|
usePublishStoreEventWithEntityKey,
|
|
711
|
-
|
|
708
|
+
useSyncStoreModelWithSelector
|
|
712
709
|
};
|
|
713
|
-
//# sourceMappingURL=esp-react.esm.
|
|
710
|
+
//# sourceMappingURL=esp-react.esm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esp-react.esm.mjs","sources":["../../../node_modules/react/cjs/react-jsx-runtime.production.js","../../../node_modules/react/cjs/react-jsx-runtime.development.js","../../../node_modules/react/jsx-runtime.js","../src/espEventBusContextProvider.tsx","../src/espStoreContextProvider.tsx","../../../node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js","../../../node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js","../../../node_modules/use-sync-external-store/with-selector.js","../src/useSyncStoreModelWithSelector.ts","../src/connectableComponent.tsx","../src/espModulesContext.ts","../src/regionView.tsx","../src/espApp.tsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and 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\n\"use strict\";\nvar REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\");\nfunction jsxProd(type, config, maybeKey) {\n var key = null;\n void 0 !== maybeKey && (key = \"\" + maybeKey);\n void 0 !== config.key && (key = \"\" + config.key);\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n config = maybeKey.ref;\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n ref: void 0 !== config ? config : null,\n props: maybeKey\n };\n}\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsxProd;\nexports.jsxs = jsxProd;\n","/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Meta Platforms, Inc. and 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\n\"use strict\";\n\"production\" !== process.env.NODE_ENV &&\n (function () {\n function getComponentNameFromType(type) {\n if (null == type) return null;\n if (\"function\" === typeof type)\n return type.$$typeof === REACT_CLIENT_REFERENCE\n ? null\n : type.displayName || type.name || null;\n if (\"string\" === typeof type) return type;\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return \"Fragment\";\n case REACT_PROFILER_TYPE:\n return \"Profiler\";\n case REACT_STRICT_MODE_TYPE:\n return \"StrictMode\";\n case REACT_SUSPENSE_TYPE:\n return \"Suspense\";\n case REACT_SUSPENSE_LIST_TYPE:\n return \"SuspenseList\";\n case REACT_ACTIVITY_TYPE:\n return \"Activity\";\n }\n if (\"object\" === typeof type)\n switch (\n (\"number\" === typeof type.tag &&\n console.error(\n \"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.\"\n ),\n type.$$typeof)\n ) {\n case REACT_PORTAL_TYPE:\n return \"Portal\";\n case REACT_CONTEXT_TYPE:\n return type.displayName || \"Context\";\n case REACT_CONSUMER_TYPE:\n return (type._context.displayName || \"Context\") + \".Consumer\";\n case REACT_FORWARD_REF_TYPE:\n var innerType = type.render;\n type = type.displayName;\n type ||\n ((type = innerType.displayName || innerType.name || \"\"),\n (type = \"\" !== type ? \"ForwardRef(\" + type + \")\" : \"ForwardRef\"));\n return type;\n case REACT_MEMO_TYPE:\n return (\n (innerType = type.displayName || null),\n null !== innerType\n ? innerType\n : getComponentNameFromType(type.type) || \"Memo\"\n );\n case REACT_LAZY_TYPE:\n innerType = type._payload;\n type = type._init;\n try {\n return getComponentNameFromType(type(innerType));\n } catch (x) {}\n }\n return null;\n }\n function testStringCoercion(value) {\n return \"\" + value;\n }\n function checkKeyStringCoercion(value) {\n try {\n testStringCoercion(value);\n var JSCompiler_inline_result = !1;\n } catch (e) {\n JSCompiler_inline_result = !0;\n }\n if (JSCompiler_inline_result) {\n JSCompiler_inline_result = console;\n var JSCompiler_temp_const = JSCompiler_inline_result.error;\n var JSCompiler_inline_result$jscomp$0 =\n (\"function\" === typeof Symbol &&\n Symbol.toStringTag &&\n value[Symbol.toStringTag]) ||\n value.constructor.name ||\n \"Object\";\n JSCompiler_temp_const.call(\n JSCompiler_inline_result,\n \"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.\",\n JSCompiler_inline_result$jscomp$0\n );\n return testStringCoercion(value);\n }\n }\n function getTaskName(type) {\n if (type === REACT_FRAGMENT_TYPE) return \"<>\";\n if (\n \"object\" === typeof type &&\n null !== type &&\n type.$$typeof === REACT_LAZY_TYPE\n )\n return \"<...>\";\n try {\n var name = getComponentNameFromType(type);\n return name ? \"<\" + name + \">\" : \"<...>\";\n } catch (x) {\n return \"<...>\";\n }\n }\n function getOwner() {\n var dispatcher = ReactSharedInternals.A;\n return null === dispatcher ? null : dispatcher.getOwner();\n }\n function UnknownOwner() {\n return Error(\"react-stack-top-frame\");\n }\n function hasValidKey(config) {\n if (hasOwnProperty.call(config, \"key\")) {\n var getter = Object.getOwnPropertyDescriptor(config, \"key\").get;\n if (getter && getter.isReactWarning) return !1;\n }\n return void 0 !== config.key;\n }\n function defineKeyPropWarningGetter(props, displayName) {\n function warnAboutAccessingKey() {\n specialPropKeyWarningShown ||\n ((specialPropKeyWarningShown = !0),\n console.error(\n \"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)\",\n displayName\n ));\n }\n warnAboutAccessingKey.isReactWarning = !0;\n Object.defineProperty(props, \"key\", {\n get: warnAboutAccessingKey,\n configurable: !0\n });\n }\n function elementRefGetterWithDeprecationWarning() {\n var componentName = getComponentNameFromType(this.type);\n didWarnAboutElementRef[componentName] ||\n ((didWarnAboutElementRef[componentName] = !0),\n console.error(\n \"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.\"\n ));\n componentName = this.props.ref;\n return void 0 !== componentName ? componentName : null;\n }\n function ReactElement(type, key, props, owner, debugStack, debugTask) {\n var refProp = props.ref;\n type = {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n props: props,\n _owner: owner\n };\n null !== (void 0 !== refProp ? refProp : null)\n ? Object.defineProperty(type, \"ref\", {\n enumerable: !1,\n get: elementRefGetterWithDeprecationWarning\n })\n : Object.defineProperty(type, \"ref\", { enumerable: !1, value: null });\n type._store = {};\n Object.defineProperty(type._store, \"validated\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: 0\n });\n Object.defineProperty(type, \"_debugInfo\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: null\n });\n Object.defineProperty(type, \"_debugStack\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: debugStack\n });\n Object.defineProperty(type, \"_debugTask\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: debugTask\n });\n Object.freeze && (Object.freeze(type.props), Object.freeze(type));\n return type;\n }\n function jsxDEVImpl(\n type,\n config,\n maybeKey,\n isStaticChildren,\n debugStack,\n debugTask\n ) {\n var children = config.children;\n if (void 0 !== children)\n if (isStaticChildren)\n if (isArrayImpl(children)) {\n for (\n isStaticChildren = 0;\n isStaticChildren < children.length;\n isStaticChildren++\n )\n validateChildKeys(children[isStaticChildren]);\n Object.freeze && Object.freeze(children);\n } else\n console.error(\n \"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.\"\n );\n else validateChildKeys(children);\n if (hasOwnProperty.call(config, \"key\")) {\n children = getComponentNameFromType(type);\n var keys = Object.keys(config).filter(function (k) {\n return \"key\" !== k;\n });\n isStaticChildren =\n 0 < keys.length\n ? \"{key: someKey, \" + keys.join(\": ..., \") + \": ...}\"\n : \"{key: someKey}\";\n didWarnAboutKeySpread[children + isStaticChildren] ||\n ((keys =\n 0 < keys.length ? \"{\" + keys.join(\": ..., \") + \": ...}\" : \"{}\"),\n console.error(\n 'A props object containing a \"key\" prop is being spread into JSX:\\n let props = %s;\\n <%s {...props} />\\nReact keys must be passed directly to JSX without using spread:\\n let props = %s;\\n <%s key={someKey} {...props} />',\n isStaticChildren,\n children,\n keys,\n children\n ),\n (didWarnAboutKeySpread[children + isStaticChildren] = !0));\n }\n children = null;\n void 0 !== maybeKey &&\n (checkKeyStringCoercion(maybeKey), (children = \"\" + maybeKey));\n hasValidKey(config) &&\n (checkKeyStringCoercion(config.key), (children = \"\" + config.key));\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n children &&\n defineKeyPropWarningGetter(\n maybeKey,\n \"function\" === typeof type\n ? type.displayName || type.name || \"Unknown\"\n : type\n );\n return ReactElement(\n type,\n children,\n maybeKey,\n getOwner(),\n debugStack,\n debugTask\n );\n }\n function validateChildKeys(node) {\n isValidElement(node)\n ? node._store && (node._store.validated = 1)\n : \"object\" === typeof node &&\n null !== node &&\n node.$$typeof === REACT_LAZY_TYPE &&\n (\"fulfilled\" === node._payload.status\n ? isValidElement(node._payload.value) &&\n node._payload.value._store &&\n (node._payload.value._store.validated = 1)\n : node._store && (node._store.validated = 1));\n }\n function isValidElement(object) {\n return (\n \"object\" === typeof object &&\n null !== object &&\n object.$$typeof === REACT_ELEMENT_TYPE\n );\n }\n var React = require(\"react\"),\n REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_PORTAL_TYPE = Symbol.for(\"react.portal\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\"),\n REACT_STRICT_MODE_TYPE = Symbol.for(\"react.strict_mode\"),\n REACT_PROFILER_TYPE = Symbol.for(\"react.profiler\"),\n REACT_CONSUMER_TYPE = Symbol.for(\"react.consumer\"),\n REACT_CONTEXT_TYPE = Symbol.for(\"react.context\"),\n REACT_FORWARD_REF_TYPE = Symbol.for(\"react.forward_ref\"),\n REACT_SUSPENSE_TYPE = Symbol.for(\"react.suspense\"),\n REACT_SUSPENSE_LIST_TYPE = Symbol.for(\"react.suspense_list\"),\n REACT_MEMO_TYPE = Symbol.for(\"react.memo\"),\n REACT_LAZY_TYPE = Symbol.for(\"react.lazy\"),\n REACT_ACTIVITY_TYPE = Symbol.for(\"react.activity\"),\n REACT_CLIENT_REFERENCE = Symbol.for(\"react.client.reference\"),\n ReactSharedInternals =\n React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n isArrayImpl = Array.isArray,\n createTask = console.createTask\n ? console.createTask\n : function () {\n return null;\n };\n React = {\n react_stack_bottom_frame: function (callStackForError) {\n return callStackForError();\n }\n };\n var specialPropKeyWarningShown;\n var didWarnAboutElementRef = {};\n var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(\n React,\n UnknownOwner\n )();\n var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));\n var didWarnAboutKeySpread = {};\n exports.Fragment = REACT_FRAGMENT_TYPE;\n exports.jsx = function (type, config, maybeKey) {\n var trackActualOwner =\n 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;\n return jsxDEVImpl(\n type,\n config,\n maybeKey,\n !1,\n trackActualOwner\n ? Error(\"react-stack-top-frame\")\n : unknownOwnerDebugStack,\n trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask\n );\n };\n exports.jsxs = function (type, config, maybeKey) {\n var trackActualOwner =\n 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;\n return jsxDEVImpl(\n type,\n config,\n maybeKey,\n !0,\n trackActualOwner\n ? Error(\"react-stack-top-frame\")\n : unknownOwnerDebugStack,\n trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask\n );\n };\n })();\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\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 {StoreAddress, EventBus} from 'esp-js';\nimport {PropsWithChildren, createContext, useContext, useCallback} from 'react';\n\nexport const EventBusContext = createContext<EventBus>(null);\n\n/**\n * Get the esp EventBus from context.\n *\n * To use this, please ensure your V-DOM has the EspEventBusContextProvider at a higher node:\n *\n * <EspEventBusContextProvider bus={bus}>\n * <YourComponents />\n * </EspEventBusContextProvider>\n */\nexport const useEventBus = () => {\n return useContext(EventBusContext);\n};\n\nexport type PublishEventDelegate = {(storeIdOrStoreAddress: string | StoreAddress, eventType: string, event: any): void; (eventData: { address: string | StoreAddress, eventType: string, event: any }): void; };\nconst createPublishEvent = (bus: EventBus) => {\n function publishEvent(storeIdOrStoreAddress: string | StoreAddress, eventType: string, event: any): void;\n function publishEvent(eventData: { address: string | StoreAddress, eventType: string, event: any }): void;\n function publishEvent(...args: any[]): void {\n if (args.length === 1) {\n bus.publishEvent(args[0].address, args[0].eventType, args[0].event);\n } else {\n bus.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 EspEventBusContextProvider at a higher node:\n *\n * <EspEventBusContextProvider bus={bus}>\n * <YourComponents />\n * </EspEventBusContextProvider>\n */\nexport const usePublishEvent = () => useContext(PublishEventContext);\n\nexport type EspEventBusContextProviderProps = PropsWithChildren<{ bus: EventBus; }>;\n\n/**\n * Used to set the bus on the EventBusContext making it available to components down the tree via the useEventBus() hook.\n *\n * Also sets up the usePublishEvent() hook so nested components can publish to the bus.\n */\nexport const EspEventBusContextProvider = ({children, bus}: EspEventBusContextProviderProps) => {\n // EventBus 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 busFromContext = useEventBus();\n bus = bus || busFromContext;\n const publishEvent: PublishEventDelegate = useCallback(createPublishEvent(bus), [bus]);\n return (\n <EventBusContext.Provider value={bus}>\n <PublishEventContext.Provider value={publishEvent}>\n {children}\n </PublishEventContext.Provider>\n </EventBusContext.Provider>\n );\n};","import {DefaultStoreAddress, EventBus} from 'esp-js';\nimport {useContext, useCallback, createContext, PropsWithChildren} from 'react';\nimport {useEventBus} from './espEventBusContextProvider';\n\nexport const GetStoreIdContext = createContext<string>(null);\n/**\n * Returns a function to get the ID of the store connected at a higher point in the V-DOM.\n *\n * To use this, please ensure your V-DOM has the EspStoreContextProvider at a higher node.\n */\nexport const useGetStoreId = () => useContext(GetStoreIdContext);\n\nexport const GetStoreModelContext = createContext<object>(null);\n/**\n * Returns the current model (frozen snapshot) of the store connected at a higher point in the V-DOM.\n *\n * To use this, please ensure your V-DOM has the EspStoreContextProvider at a higher node.\n */\nexport const useGetStoreModel = <TModel,>() => useContext(GetStoreModelContext) as TModel;\n\nexport type PublishStoreEventDelegate = { (eventType: string, event: any): void; (eventData: {eventType: string, event: any}): void; };\nconst createPublishStoreEvent = (bus: EventBus, storeId: string) => {\n function publishStoreEvent(eventType: string, event: any): void;\n function publishStoreEvent(eventData: {eventType: string, event: any}): void;\n function publishStoreEvent(...args: any[]) {\n if (args.length === 1) {\n bus.publishEvent(storeId, args[0].eventType, args[0].event);\n } else {\n bus.publishEvent(storeId, args[0], args[1]);\n }\n }\n return publishStoreEvent;\n};\nexport const PublishStoreEventContext = createContext<PublishStoreEventDelegate>(null);\n\n/**\n * Returns a function which can be used to publish an event to the store connected at a higher point in the V-DOM.\n *\n * Effectively, this is a version of usePublishEvent() which closes over the relevant storeId.\n *\n * To use this, please ensure your V-DOM has the EspStoreContextProvider at a higher node.\n */\nexport const usePublishStoreEvent = () => useContext(PublishStoreEventContext);\n\nexport type PublishStoreEventWithEntityKeyDelegate = {(entityKey: string, eventType: string, event: any): void; (eventData: {entityKey: string, eventType: string, event: any}): void; };\nconst createPublishStoreEventWithEntityKey = (bus: EventBus, storeId: string) => {\n function publishStoreEventWithEntityKey(entityKey: string, eventType: string, event: any): void;\n function publishStoreEventWithEntityKey(eventData: {entityKey: string, eventType: string, event: any}): void;\n function publishStoreEventWithEntityKey(...args: any[]) {\n if (args.length === 1) {\n bus.publishEvent(new DefaultStoreAddress(storeId, args[0].entityKey), args[0].eventType, args[0].event);\n } else {\n bus.publishEvent(new DefaultStoreAddress(storeId, args[0]), args[1], args[2]);\n }\n }\n return publishStoreEventWithEntityKey;\n};\nexport const PublishStoreEventWithEntityKeyContext = createContext<PublishStoreEventWithEntityKeyDelegate>(null);\n/**\n * Returns a function which can be used to publish an event to the store 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 storeId.\n *\n * To use this, please ensure your V-DOM has the EspStoreContextProvider at a higher node.\n */\nexport const usePublishStoreEventWithEntityKey = () => useContext(PublishStoreEventWithEntityKeyContext);\n\nexport interface EspStoreContextProviderProps {\n storeId: 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 EspEventBusContextProvider at a higher node.\n * @param storeId\n * @param children\n * @param model\n * @constructor\n */\nexport const EspStoreContextProvider = ({storeId, children, model}: PropsWithChildren<EspStoreContextProviderProps>) => {\n const bus = useEventBus();\n // storeId 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 storeIdFromContext = useGetStoreId();\n storeId = storeId || storeIdFromContext;\n const publishStoreEvent: PublishStoreEventDelegate = useCallback(createPublishStoreEvent(bus, storeId), [bus, storeId]);\n const publishStoreEventWithEntityKey: PublishStoreEventWithEntityKeyDelegate = useCallback(createPublishStoreEventWithEntityKey(bus, storeId), [bus, storeId]);\n return (\n <GetStoreIdContext.Provider value={storeId}>\n <PublishStoreEventContext.Provider value={publishStoreEvent}>\n <PublishStoreEventWithEntityKeyContext.Provider value={publishStoreEventWithEntityKey}>\n <GetStoreModelContext.Provider value={model}>\n {children}\n </GetStoreModelContext.Provider>\n </PublishStoreEventWithEntityKeyContext.Provider>\n </PublishStoreEventContext.Provider>\n </GetStoreIdContext.Provider>\n );\n};\n","/**\n * @license React\n * use-sync-external-store-with-selector.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and 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\n\"use strict\";\nvar React = require(\"react\");\nfunction is(x, y) {\n return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);\n}\nvar objectIs = \"function\" === typeof Object.is ? Object.is : is,\n useSyncExternalStore = React.useSyncExternalStore,\n useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue;\nexports.useSyncExternalStoreWithSelector = function (\n subscribe,\n getSnapshot,\n getServerSnapshot,\n selector,\n isEqual\n) {\n var instRef = useRef(null);\n if (null === instRef.current) {\n var inst = { hasValue: !1, value: null };\n instRef.current = inst;\n } else inst = instRef.current;\n instRef = useMemo(\n function () {\n function memoizedSelector(nextSnapshot) {\n if (!hasMemo) {\n hasMemo = !0;\n memoizedSnapshot = nextSnapshot;\n nextSnapshot = selector(nextSnapshot);\n if (void 0 !== isEqual && inst.hasValue) {\n var currentSelection = inst.value;\n if (isEqual(currentSelection, nextSnapshot))\n return (memoizedSelection = currentSelection);\n }\n return (memoizedSelection = nextSnapshot);\n }\n currentSelection = memoizedSelection;\n if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;\n var nextSelection = selector(nextSnapshot);\n if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))\n return (memoizedSnapshot = nextSnapshot), currentSelection;\n memoizedSnapshot = nextSnapshot;\n return (memoizedSelection = nextSelection);\n }\n var hasMemo = !1,\n memoizedSnapshot,\n memoizedSelection,\n maybeGetServerSnapshot =\n void 0 === getServerSnapshot ? null : getServerSnapshot;\n return [\n function () {\n return memoizedSelector(getSnapshot());\n },\n null === maybeGetServerSnapshot\n ? void 0\n : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n }\n ];\n },\n [getSnapshot, getServerSnapshot, selector, isEqual]\n );\n var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);\n useEffect(\n function () {\n inst.hasValue = !0;\n inst.value = value;\n },\n [value]\n );\n useDebugValue(value);\n return value;\n};\n","/**\n * @license React\n * use-sync-external-store-with-selector.development.js\n *\n * Copyright (c) Meta Platforms, Inc. and 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\n\"use strict\";\n\"production\" !== process.env.NODE_ENV &&\n (function () {\n function is(x, y) {\n return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);\n }\n \"undefined\" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&\n \"function\" ===\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());\n var React = require(\"react\"),\n objectIs = \"function\" === typeof Object.is ? Object.is : is,\n useSyncExternalStore = React.useSyncExternalStore,\n useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue;\n exports.useSyncExternalStoreWithSelector = function (\n subscribe,\n getSnapshot,\n getServerSnapshot,\n selector,\n isEqual\n ) {\n var instRef = useRef(null);\n if (null === instRef.current) {\n var inst = { hasValue: !1, value: null };\n instRef.current = inst;\n } else inst = instRef.current;\n instRef = useMemo(\n function () {\n function memoizedSelector(nextSnapshot) {\n if (!hasMemo) {\n hasMemo = !0;\n memoizedSnapshot = nextSnapshot;\n nextSnapshot = selector(nextSnapshot);\n if (void 0 !== isEqual && inst.hasValue) {\n var currentSelection = inst.value;\n if (isEqual(currentSelection, nextSnapshot))\n return (memoizedSelection = currentSelection);\n }\n return (memoizedSelection = nextSnapshot);\n }\n currentSelection = memoizedSelection;\n if (objectIs(memoizedSnapshot, nextSnapshot))\n return currentSelection;\n var nextSelection = selector(nextSnapshot);\n if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))\n return (memoizedSnapshot = nextSnapshot), currentSelection;\n memoizedSnapshot = nextSnapshot;\n return (memoizedSelection = nextSelection);\n }\n var hasMemo = !1,\n memoizedSnapshot,\n memoizedSelection,\n maybeGetServerSnapshot =\n void 0 === getServerSnapshot ? null : getServerSnapshot;\n return [\n function () {\n return memoizedSelector(getSnapshot());\n },\n null === maybeGetServerSnapshot\n ? void 0\n : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n }\n ];\n },\n [getSnapshot, getServerSnapshot, selector, isEqual]\n );\n var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);\n useEffect(\n function () {\n inst.hasValue = !0;\n inst.value = value;\n },\n [value]\n );\n useDebugValue(value);\n return value;\n };\n \"undefined\" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&\n \"function\" ===\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());\n })();\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/use-sync-external-store-with-selector.production.js');\n} else {\n module.exports = require('./cjs/use-sync-external-store-with-selector.development.js');\n}\n","import {useMemo} from 'react';\nimport {useSyncExternalStoreWithSelector} from 'use-sync-external-store/with-selector';\nimport {Logger, EventBus, utils} from 'esp-js';\nimport {useEventBus} from './espEventBusContextProvider';\nimport {useGetStoreId} from './espStoreContextProvider';\n\nexport type SyncStoreModelWithSelectorEqualityFn<T> = (last: T, next: T) => boolean;\n\nexport const logger = Logger.create('useSyncStoreModelWithSelector');\n\n/**\n * Options affecting the subscription of the model to the EventBus.\n *\n * Use syncStoreModelWithSelectorOptions() to create an instance of this type with sensible defaults.\n *\n * @param storeId - the storeId of the store to be observed via the esp EventBus.\n * @param equalityFn - Equality function which will be applied against TSelected, defaults to instance equality (a === b).\n */\nexport type SyncStoreModelWithSelectorOptions<TSelected> = {\n storeId?: string,\n equalityFn: SyncStoreModelWithSelectorEqualityFn<TSelected>\n};\n\n/**\n * Convenience API to build SyncStoreModelWithSelectorOptions<TSelected>, has sensible defaulting.\n */\nexport interface SyncStoreModelWithSelectorOptionsBuilder<TSelected> extends SyncStoreModelWithSelectorOptions<TSelected> {\n /**\n * Sets the store ID\n * @param storeId - default if unset: undefined\n */\n setStoreId(storeId: string): 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 SyncStoreModelWithSelectorOptions\n */\nexport const syncStoreModelWithSelectorOptions = <TSelected>() => {\n let storeId = undefined;\n let equalityFn: SyncStoreModelWithSelectorEqualityFn<TSelected> = (a: TSelected, b: TSelected) => a === b;\n return {\n get storeId() {\n return storeId;\n },\n setStoreId(value: string) {\n storeId = value;\n return this;\n },\n get equalityFn() {\n return equalityFn;\n },\n setEqualityFn(value: SyncStoreModelWithSelectorEqualityFn<TSelected>) {\n equalityFn = value;\n return this;\n }\n } as SyncStoreModelWithSelectorOptionsBuilder<TSelected>;\n};\n\nconst checkArguments = (selector: (model: any) => any, options: SyncStoreModelWithSelectorOptions<any> ) => {\n if (!utils.isFunction(selector)) {\n throw new Error('You must pass a selector function to useSyncStoreModelWithSelector');\n }\n if (!utils.isObject(options)) {\n throw new Error('You must provide options when using useSyncStoreModelWithSelector');\n }\n if (!utils.isFunction(options.equalityFn)) {\n throw new Error('You must provide an equalityFn when using useSyncStoreModelWithSelector');\n }\n};\n\n/**\n * A hook which returns model state from the esp EventBus.\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 EspEventBusContextProvider at a higher node, and optionally EspStoreContextProvider.\n *\n * If the store isn't registered yet, the hook returns null and picks up the model once the store is registered.\n *\n * @param selector - a function to select a selection of the model. It does not need to be memoized: the latest selector is used on each render, and the equalityFn (if any) decides whether a new selection re-renders.\n * @param options\n */\nexport const useSyncStoreModelWithSelector = <TModel, TSelected>(\n selector: (model: TModel) => TSelected,\n options: SyncStoreModelWithSelectorOptions<TSelected> = syncStoreModelWithSelectorOptions<TSelected>()\n): TSelected => {\n checkArguments(selector, options);\n const bus = useEventBus();\n const storeIdFromContext = useGetStoreId();\n const storeId = options?.storeId || storeIdFromContext;\n const equalityFn = options?.equalityFn;\n const dependencies = useMemo(\n () => {\n // Subscribe even if the store isn't registered yet: getStoreModelObservable() supports stores registered later,\n // and emits the model when the store is added.\n const canSubscribe = bus && utils.isString(storeId);\n if (canSubscribe) {\n return createSubscriptionState(bus, storeId);\n }\n return createNoopSubscriptionState();\n },\n [bus, storeId]\n );\n // Wrap the caller's selector on every render so a selector that closes over props/state is never stale.\n // useSyncExternalStoreWithSelector re-runs it when it changes and applies the equalityFn to the result.\n const wrappedSelector = (snapshot: TModel) => snapshot ? selector(snapshot) : null;\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 wrappedSelector,\n equalityFn,\n );\n};\n\nconst createSubscriptionState = <TModel>(\n bus: EventBus,\n storeId: string,\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 EventBus, 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 // Note: the bus subscription is created inside the `subscribe` callback (not here at factory time).\n // This is important for correctness with React StrictMode: StrictMode intentionally unmounts and remounts\n // components to surface side-effect bugs. When the cleanup returned by `subscribe` is called, it disposes\n // the bus subscription and clears `currentModel`. Because the `dependencies` object created by useMemo is\n // reused across the remount (deps haven't changed), any bus subscription created eagerly at useMemo time\n // would already be disposed on remount, leaving `currentModel` permanently null.\n //\n // useSyncExternalStore guarantees that `getSnapshot` is called before `subscribe`, so we initialise\n // `currentModel` lazily from `bus.getStoreModel()` inside `getSnapshot` when it is still null.\n let currentModel: TModel;\n return {\n subscribe: (stateChanged: () => void) => {\n // Subscribe to future model updates from the EventBus.\n // This is called by React when the component mounts (and remounts after StrictMode teardown).\n const modelSubscriptionDisposable = bus\n .getStoreModelObservable<TModel>(storeId)\n .subscribe(\n (m: TModel) => {\n // The model is a frozen immutable snapshot produced by immer after each dispatch cycle.\n // immer only creates a new reference when something changed, so the same reference means no change.\n // This also covers the replay of the current model when we subscribe, which getSnapshot() already returned.\n if (m === currentModel) {\n return;\n }\n currentModel = m;\n stateChanged();\n }\n );\n return () => {\n currentModel = null;\n modelSubscriptionDisposable.dispose();\n };\n },\n // React expects getSnapshot to be pure and stable between renders unless the store has changed.\n // We seed currentModel from bus.getStoreModel() on first call (before subscribe has been called),\n // then keep it up-to-date via the subscription callback above.\n // getStoreModel() throws for a store that's been observed but not registered yet, so check first; until then the snapshot is null.\n getSnapshot: () => {\n if (currentModel == null && bus.isStoreRegistered(storeId)) {\n currentModel = bus.getStoreModel<TModel>(storeId);\n }\n return currentModel;\n },\n };\n};\n\nconst createNoopSubscriptionState = () => ({\n subscribe: () => {\n return () => {};\n },\n getSnapshot: (): null => null,\n});\n","import * as React from 'react';\nimport {useEventBus} from './espEventBusContextProvider';\nimport {useMemo} from 'react';\nimport {EventBus} from 'esp-js';\nimport {EspStoreContextProvider, useGetStoreId} from './espStoreContextProvider';\nimport {syncStoreModelWithSelectorOptions, useSyncStoreModelWithSelector} from './useSyncStoreModelWithSelector';\n\nexport type CreatePublishEventProps<TPublishEventProps> = (publishModelEvent: (eventType: string, event: any) => void) => TPublishEventProps;\n\nexport type MapStoreModelToProps<TModel, TModelMappedToProps, TPublishEventProps = {}> = (model: TModel, publishEventProps: TPublishEventProps) => TModelMappedToProps;\n\nexport interface ConnectableComponentProps<TModel = {}, TPublishEventProps = {}, TModelMappedToProps = {}> {\n storeId?: string;\n view?: React.ComponentType<any>;\n createPublishEventProps?: CreatePublishEventProps<TPublishEventProps>;\n mapStoreModelToProps?: MapStoreModelToProps<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 storeId: string;\n model: TModel;\n bus: EventBus;\n [key: string]: any; // ...rest props\n}\n\nconst getChildProps = <TModel, TModelMappedToProps, TPublishEventProps>(\n bus: EventBus,\n storeId: string,\n restProps: object,\n model: TModel,\n mapStoreModelToProps: MapStoreModelToProps<TModel, TModelMappedToProps, TPublishEventProps>,\n publishEventProps: TPublishEventProps\n): ConnectableComponentChildProps<TModel> => {\n let childProps = {\n storeId,\n bus: bus,\n ...restProps,\n ...publishEventProps,\n model\n };\n if (mapStoreModelToProps) {\n childProps = {\n ...childProps,\n ...(mapStoreModelToProps(model, publishEventProps) as TModelMappedToProps)\n };\n }\n return childProps;\n};\n\nexport const ConnectableComponent = <TModel = {}, TPublishEventProps = {}, TModelMappedToProps = {}>(\n {\n storeId,\n mapStoreModelToProps,\n createPublishEventProps,\n view,\n ...rest\n }: ConnectableComponentProps<TModel, TPublishEventProps, TModelMappedToProps>\n) => {\n const bus = useEventBus();\n // Note: we always need to render the hooks else react will complain about a different count.\n let storeIdFromContext = useGetStoreId();\n storeId = storeId || storeIdFromContext;\n // createPublishEventProps is captured once per bus/storeId (not re-run when the prop changes),\n // so callers can pass an inline function and still get stable publish props.\n const publishEventProps: TPublishEventProps = useMemo(\n () => {\n if (createPublishEventProps) {\n const publishModelEvent = (eventType: string, event: any) => {\n bus.publishEvent(storeId, eventType, event);\n };\n return createPublishEventProps(publishModelEvent);\n }\n return {} as TPublishEventProps;\n },\n [bus, storeId]\n );\n const model = useSyncStoreModelWithSelector<TModel, TModel>(\n m => m,\n syncStoreModelWithSelectorOptions()\n .setStoreId(storeId)\n );\n if (model == null) {\n return null;\n }\n let childProps = getChildProps(bus, storeId, rest, model, mapStoreModelToProps, publishEventProps);\n let viewElement = view ? React.createElement(view, childProps) : null;\n return (\n <EspStoreContextProvider storeId={storeId} model={model} bus={bus} {...childProps}>\n {viewElement}\n </EspStoreContextProvider>\n );\n};\n","import * as React from 'react';\nimport type { Module } from 'esp-js-ui';\n\nexport const EspModulesContext = React.createContext<ReadonlyArray<Module>>([]);\n","import * as React from 'react';\nimport {useContext, useMemo} from 'react';\nimport { ConnectableComponent } from './connectableComponent';\nimport { EspModulesContext } from './espModulesContext';\n\nexport interface RegionViewProps {\n regionName: string;\n}\n\n/**\n * Renders all view bindings registered for a given region across all loaded modules.\n *\n * Each module declares views with a region token (ModuleBuilder.withView in esp-js-ui).\n * RegionView reads EspModulesContext (populated by EspApp), finds all bindings\n * matching regionName, and mounts a ConnectableComponent for each.\n *\n * Example:\n * const AppRoot = () => (\n * <div>\n * <RegionView regionName='main' />\n * <RegionView regionName='sidebar' />\n * </div>\n * );\n */\nexport const RegionView = ({ regionName }: RegionViewProps) => {\n const modules = useContext(EspModulesContext);\n const bindings = useMemo(\n () => modules\n .flatMap(m => m.viewBindings)\n .filter(b => b.region === regionName),\n [modules, regionName]\n );\n return (\n <>\n {bindings.map((binding, index) => (\n <ConnectableComponent\n // storeId alone isn't unique: a region can hold several views over the same store.\n // Bindings are fixed once the modules are built, so the index is a stable key.\n key={`${binding.storeId}:${index}`}\n storeId={binding.storeId}\n view={binding.viewComponent}\n />\n ))}\n </>\n );\n};\n","import * as React from 'react';\nimport type { App } from 'esp-js-ui';\nimport { EspEventBusContextProvider } from './espEventBusContextProvider';\nimport { EspModulesContext } from './espModulesContext';\n\nexport interface EspAppProps {\n app: App;\n children: React.ReactNode;\n}\n\n/**\n * Wraps an application root with the ESP context providers.\n *\n * Provides the EventBus (via EspEventBusContextProvider) and the loaded\n * modules list (via EspModulesContext) so that RegionView and any\n * esp-js-react hooks work without additional setup in the root component.\n *\n * Multiple EspApp instances can be mounted independently in the same DOM\n * for multi-app scenarios.\n *\n * Example:\n * await app.start();\n * ReactDOM.createRoot(document.getElementById('root')).render(\n * <EspApp app={app}>\n * <AppShell />\n * </EspApp>\n * );\n */\nexport const EspApp = ({ app, children }: EspAppProps) => (\n <EspEventBusContextProvider bus={app.eventBus}>\n <EspModulesContext.Provider value={app.modules}>\n {children}\n </EspModulesContext.Provider>\n </EspEventBusContextProvider>\n);\n"],"names":["require$$0","jsxRuntimeModule","require$$1","jsx","useMemo","withSelectorModule","useSyncExternalStoreWithSelector","React","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;AAWA,MAAI,qBAAqB,OAAO,IAAI,4BAA4B,GAC9D,sBAAsB,OAAO,IAAI,gBAAgB;AACnD,WAAS,QAAQ,MAAM,QAAQ,UAAU;AACvC,QAAI,MAAM;AACV,eAAW,aAAa,MAAM,KAAK;AACnC,eAAW,OAAO,QAAQ,MAAM,KAAK,OAAO;AAC5C,QAAI,SAAS,QAAQ;AACnB,iBAAW,CAAA;AACX,eAAS,YAAY;AACnB,kBAAU,aAAa,SAAS,QAAQ,IAAI,OAAO,QAAQ;AAAA,IACjE,MAAS,YAAW;AAClB,aAAS,SAAS;AAClB,WAAO;AAAA,MACL,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,KAAK,WAAW,SAAS,SAAS;AAAA,MAClC,OAAO;AAAA,IACX;AAAA,EACA;AACA,6BAAA,WAAmB;AACnB,6BAAA,MAAc;AACd,6BAAA,OAAe;;;;;;;;;;;;;;;;;ACtBf,mBAAiB,QAAQ,IAAI,YAC1B,WAAY;AACX,aAAS,yBAAyB,MAAM;AACtC,UAAI,QAAQ,KAAM,QAAO;AACzB,UAAI,eAAe,OAAO;AACxB,eAAO,KAAK,aAAa,yBACrB,OACA,KAAK,eAAe,KAAK,QAAQ;AACvC,UAAI,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C,KAAK,OAAO;AAAA,EAAA;AAEjB,QAAM,QAAQ;AAAA,IACV,CAAA,MAAK;AAAA,IACL,kCAAA,EACK,WAAW,OAAO;AAAA,EAAA;AAE3B,MAAI,SAAS,MAAM;AACf,WAAO;AAAA,EACX;AACA,MAAI,aAAa,cAAc,KAAK,SAAS,MAAM,OAAO,sBAAsB,iBAAiB;AACjG,MAAI,cAAc,OAAOC,WAAM,cAAc,MAAM,UAAU,IAAI;AACjE,+CACK,yBAAA,EAAwB,SAAkB,OAAc,KAAW,GAAG,YAClE,UAAA,aACL;AAER;ACzFO,MAAM,oBAAoBA,WAAM,cAAqC,CAAA,CAAE;ACqBvE,MAAM,aAAa,CAAC,EAAE,iBAAkC;AAC3D,QAAM,UAAU,WAAW,iBAAiB;AAC5C,QAAM,WAAW;AAAA,IACb,MAAM,QACD,QAAQ,CAAA,MAAK,EAAE,YAAY,EAC3B,OAAO,CAAA,MAAK,EAAE,WAAW,UAAU;AAAA,IACxC,CAAC,SAAS,UAAU;AAAA,EAAA;AAExB,SACIJ,kCAAAA,IAAAK,kBAAAA,UAAA,EACK,UAAA,SAAS,IAAI,CAAC,SAAS,UACpBL,kCAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MAIG,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,IAAA;AAAA,IAFT,GAAG,QAAQ,OAAO,IAAI,KAAK;AAAA,EAAA,CAIvC,GACL;AAER;ACjBO,MAAM,SAAS,CAAC,EAAE,KAAK,SAAA,4CACzB,4BAAA,EAA2B,KAAK,IAAI,UACjC,UAAAA,kCAAAA,IAAC,kBAAkB,UAAlB,EAA2B,OAAO,IAAI,SAClC,UACL,EAAA,CACJ;","x_google_ignoreList":[0,1,2,5,6,7]}
|
package/.dist/esp-react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("esp-js")) : typeof define === "function" && define.amd ? define(["exports", "react", "esp-js"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.espReact = {}, global.
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("esp-js")) : typeof define === "function" && define.amd ? define(["exports", "react", "esp-js"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.espReact = {}, global.React, global.espJs));
|
|
3
3
|
})(this, function(exports2, require$$0, espJs) {
|
|
4
4
|
"use strict";
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
function requireReactJsxRuntime_development() {
|
|
73
73
|
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
74
74
|
hasRequiredReactJsxRuntime_development = 1;
|
|
75
|
-
"production" !==
|
|
75
|
+
"production" !== "development" && function() {
|
|
76
76
|
function getComponentNameFromType(type) {
|
|
77
77
|
if (null == type) return null;
|
|
78
78
|
if ("function" === typeof type)
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
}();
|
|
325
325
|
return reactJsxRuntime_development;
|
|
326
326
|
}
|
|
327
|
-
if (
|
|
327
|
+
if ("development" === "production") {
|
|
328
328
|
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
329
329
|
} else {
|
|
330
330
|
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
@@ -354,8 +354,8 @@
|
|
|
354
354
|
};
|
|
355
355
|
const GetStoreIdContext = require$$0.createContext(null);
|
|
356
356
|
const useGetStoreId = () => require$$0.useContext(GetStoreIdContext);
|
|
357
|
-
const
|
|
358
|
-
const
|
|
357
|
+
const GetStoreModelContext = require$$0.createContext(null);
|
|
358
|
+
const useGetStoreModel = () => require$$0.useContext(GetStoreModelContext);
|
|
359
359
|
const createPublishStoreEvent = (bus, storeId) => {
|
|
360
360
|
function publishStoreEvent(...args) {
|
|
361
361
|
if (args.length === 1) {
|
|
@@ -386,7 +386,7 @@
|
|
|
386
386
|
storeId = storeId || storeIdFromContext;
|
|
387
387
|
const publishStoreEvent = require$$0.useCallback(createPublishStoreEvent(bus, storeId), [bus, storeId]);
|
|
388
388
|
const publishStoreEventWithEntityKey = require$$0.useCallback(createPublishStoreEventWithEntityKey(bus, storeId), [bus, storeId]);
|
|
389
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreIdContext.Provider, { value: storeId, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventContext.Provider, { value: publishStoreEvent, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventWithEntityKeyContext.Provider, { value: publishStoreEventWithEntityKey, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
389
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreIdContext.Provider, { value: storeId, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventContext.Provider, { value: publishStoreEvent, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishStoreEventWithEntityKeyContext.Provider, { value: publishStoreEventWithEntityKey, children: /* @__PURE__ */ jsxRuntimeExports.jsx(GetStoreModelContext.Provider, { value: model, children }) }) }) });
|
|
390
390
|
};
|
|
391
391
|
var withSelector = { exports: {} };
|
|
392
392
|
var useSyncExternalStoreWithSelector_production = {};
|
|
@@ -475,7 +475,7 @@
|
|
|
475
475
|
function requireUseSyncExternalStoreWithSelector_development() {
|
|
476
476
|
if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
|
|
477
477
|
hasRequiredUseSyncExternalStoreWithSelector_development = 1;
|
|
478
|
-
"production" !==
|
|
478
|
+
"production" !== "development" && function() {
|
|
479
479
|
function is(x, y) {
|
|
480
480
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
481
481
|
}
|
|
@@ -537,14 +537,14 @@
|
|
|
537
537
|
}();
|
|
538
538
|
return useSyncExternalStoreWithSelector_development;
|
|
539
539
|
}
|
|
540
|
-
if (
|
|
540
|
+
if ("development" === "production") {
|
|
541
541
|
withSelector.exports = requireUseSyncExternalStoreWithSelector_production();
|
|
542
542
|
} else {
|
|
543
543
|
withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
|
|
544
544
|
}
|
|
545
545
|
var withSelectorExports = withSelector.exports;
|
|
546
|
-
espJs.Logger.create("
|
|
547
|
-
const
|
|
546
|
+
espJs.Logger.create("useSyncStoreModelWithSelector");
|
|
547
|
+
const syncStoreModelWithSelectorOptions = () => {
|
|
548
548
|
let storeId = void 0;
|
|
549
549
|
let equalityFn = (a, b) => a === b;
|
|
550
550
|
return {
|
|
@@ -566,16 +566,16 @@
|
|
|
566
566
|
};
|
|
567
567
|
const checkArguments = (selector, options) => {
|
|
568
568
|
if (!espJs.utils.isFunction(selector)) {
|
|
569
|
-
throw new Error("You must pass a selector function to
|
|
569
|
+
throw new Error("You must pass a selector function to useSyncStoreModelWithSelector");
|
|
570
570
|
}
|
|
571
571
|
if (!espJs.utils.isObject(options)) {
|
|
572
|
-
throw new Error("You must provide options when using
|
|
572
|
+
throw new Error("You must provide options when using useSyncStoreModelWithSelector");
|
|
573
573
|
}
|
|
574
574
|
if (!espJs.utils.isFunction(options.equalityFn)) {
|
|
575
|
-
throw new Error("You must provide an equalityFn when using
|
|
575
|
+
throw new Error("You must provide an equalityFn when using useSyncStoreModelWithSelector");
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
|
-
const
|
|
578
|
+
const useSyncStoreModelWithSelector = (selector, options = syncStoreModelWithSelectorOptions()) => {
|
|
579
579
|
checkArguments(selector, options);
|
|
580
580
|
const bus = useEventBus();
|
|
581
581
|
const storeIdFromContext = useGetStoreId();
|
|
@@ -583,29 +583,32 @@
|
|
|
583
583
|
const equalityFn = options == null ? void 0 : options.equalityFn;
|
|
584
584
|
const dependencies = require$$0.useMemo(
|
|
585
585
|
() => {
|
|
586
|
-
const canSubscribe = bus && espJs.utils.isString(storeId)
|
|
586
|
+
const canSubscribe = bus && espJs.utils.isString(storeId);
|
|
587
587
|
if (canSubscribe) {
|
|
588
|
-
return createSubscriptionState(bus, storeId
|
|
588
|
+
return createSubscriptionState(bus, storeId);
|
|
589
589
|
}
|
|
590
590
|
return createNoopSubscriptionState();
|
|
591
591
|
},
|
|
592
|
-
// Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.
|
|
593
592
|
[bus, storeId]
|
|
594
593
|
);
|
|
594
|
+
const wrappedSelector = (snapshot) => snapshot ? selector(snapshot) : null;
|
|
595
595
|
return withSelectorExports.useSyncExternalStoreWithSelector(
|
|
596
596
|
dependencies.subscribe,
|
|
597
597
|
dependencies.getSnapshot,
|
|
598
598
|
void 0,
|
|
599
|
-
|
|
599
|
+
wrappedSelector,
|
|
600
600
|
equalityFn
|
|
601
601
|
);
|
|
602
602
|
};
|
|
603
|
-
const createSubscriptionState = (bus, storeId
|
|
603
|
+
const createSubscriptionState = (bus, storeId) => {
|
|
604
604
|
let currentModel;
|
|
605
605
|
return {
|
|
606
606
|
subscribe: (stateChanged) => {
|
|
607
|
-
const modelSubscriptionDisposable = bus.
|
|
607
|
+
const modelSubscriptionDisposable = bus.getStoreModelObservable(storeId).subscribe(
|
|
608
608
|
(m) => {
|
|
609
|
+
if (m === currentModel) {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
609
612
|
currentModel = m;
|
|
610
613
|
stateChanged();
|
|
611
614
|
}
|
|
@@ -616,19 +619,14 @@
|
|
|
616
619
|
};
|
|
617
620
|
},
|
|
618
621
|
// React expects getSnapshot to be pure and stable between renders unless the store has changed.
|
|
619
|
-
// We seed currentModel from bus.
|
|
622
|
+
// We seed currentModel from bus.getStoreModel() on first call (before subscribe has been called),
|
|
620
623
|
// then keep it up-to-date via the subscription callback above.
|
|
624
|
+
// getStoreModel() throws for a store that's been observed but not registered yet, so check first; until then the snapshot is null.
|
|
621
625
|
getSnapshot: () => {
|
|
622
|
-
if (currentModel == null) {
|
|
623
|
-
currentModel = bus.
|
|
626
|
+
if (currentModel == null && bus.isStoreRegistered(storeId)) {
|
|
627
|
+
currentModel = bus.getStoreModel(storeId);
|
|
624
628
|
}
|
|
625
629
|
return currentModel;
|
|
626
|
-
},
|
|
627
|
-
// While getSnapshot needs to model to be immutable,
|
|
628
|
-
// useSyncExternalStoreWithSelector builds on top of this, so the TSelected can defer to an equality check to determine if the change is propagated.
|
|
629
|
-
// The selector here just maps the TSelected, useSyncExternalStoreWithSelector internally does the equality check.
|
|
630
|
-
wrappedSelector: (snapshot) => {
|
|
631
|
-
return snapshot ? selector(snapshot) : null;
|
|
632
630
|
}
|
|
633
631
|
};
|
|
634
632
|
};
|
|
@@ -637,10 +635,9 @@
|
|
|
637
635
|
return () => {
|
|
638
636
|
};
|
|
639
637
|
},
|
|
640
|
-
getSnapshot: () => null
|
|
641
|
-
wrappedSelector: () => null
|
|
638
|
+
getSnapshot: () => null
|
|
642
639
|
});
|
|
643
|
-
const getChildProps = (bus, storeId, restProps, model,
|
|
640
|
+
const getChildProps = (bus, storeId, restProps, model, mapStoreModelToProps, publishEventProps) => {
|
|
644
641
|
let childProps = {
|
|
645
642
|
storeId,
|
|
646
643
|
bus,
|
|
@@ -648,17 +645,17 @@
|
|
|
648
645
|
...publishEventProps,
|
|
649
646
|
model
|
|
650
647
|
};
|
|
651
|
-
if (
|
|
648
|
+
if (mapStoreModelToProps) {
|
|
652
649
|
childProps = {
|
|
653
650
|
...childProps,
|
|
654
|
-
...
|
|
651
|
+
...mapStoreModelToProps(model, publishEventProps)
|
|
655
652
|
};
|
|
656
653
|
}
|
|
657
654
|
return childProps;
|
|
658
655
|
};
|
|
659
656
|
const ConnectableComponent = ({
|
|
660
657
|
storeId,
|
|
661
|
-
|
|
658
|
+
mapStoreModelToProps,
|
|
662
659
|
createPublishEventProps,
|
|
663
660
|
view,
|
|
664
661
|
...rest
|
|
@@ -678,31 +675,31 @@
|
|
|
678
675
|
},
|
|
679
676
|
[bus, storeId]
|
|
680
677
|
);
|
|
681
|
-
const model =
|
|
678
|
+
const model = useSyncStoreModelWithSelector(
|
|
682
679
|
(m) => m,
|
|
683
|
-
|
|
680
|
+
syncStoreModelWithSelectorOptions().setStoreId(storeId)
|
|
684
681
|
);
|
|
685
682
|
if (model == null) {
|
|
686
683
|
return null;
|
|
687
684
|
}
|
|
688
|
-
let childProps = getChildProps(bus, storeId, rest, model,
|
|
685
|
+
let childProps = getChildProps(bus, storeId, rest, model, mapStoreModelToProps, publishEventProps);
|
|
689
686
|
let viewElement = view ? require$$0__namespace.createElement(view, childProps) : null;
|
|
690
687
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(EspStoreContextProvider, { storeId, model, bus, ...childProps, children: viewElement });
|
|
691
688
|
};
|
|
692
|
-
const EspModulesContext = require$$
|
|
689
|
+
const EspModulesContext = require$$0__namespace.createContext([]);
|
|
693
690
|
const RegionView = ({ regionName }) => {
|
|
694
691
|
const modules = require$$0.useContext(EspModulesContext);
|
|
695
692
|
const bindings = require$$0.useMemo(
|
|
696
693
|
() => modules.flatMap((m) => m.viewBindings).filter((b) => b.region === regionName),
|
|
697
694
|
[modules, regionName]
|
|
698
695
|
);
|
|
699
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: bindings.map((binding) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
696
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: bindings.map((binding, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
700
697
|
ConnectableComponent,
|
|
701
698
|
{
|
|
702
699
|
storeId: binding.storeId,
|
|
703
700
|
view: binding.viewComponent
|
|
704
701
|
},
|
|
705
|
-
binding.storeId
|
|
702
|
+
`${binding.storeId}:${index}`
|
|
706
703
|
)) });
|
|
707
704
|
};
|
|
708
705
|
const EspApp = ({ app, children }) => /* @__PURE__ */ jsxRuntimeExports.jsx(EspEventBusContextProvider, { bus: app.eventBus, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EspModulesContext.Provider, { value: app.modules, children }) });
|
|
@@ -712,20 +709,20 @@
|
|
|
712
709
|
exports2.EspModulesContext = EspModulesContext;
|
|
713
710
|
exports2.EspStoreContextProvider = EspStoreContextProvider;
|
|
714
711
|
exports2.EventBusContext = EventBusContext;
|
|
715
|
-
exports2.GetStoreContext = GetStoreContext;
|
|
716
712
|
exports2.GetStoreIdContext = GetStoreIdContext;
|
|
713
|
+
exports2.GetStoreModelContext = GetStoreModelContext;
|
|
717
714
|
exports2.PublishEventContext = PublishEventContext;
|
|
718
715
|
exports2.PublishStoreEventContext = PublishStoreEventContext;
|
|
719
716
|
exports2.PublishStoreEventWithEntityKeyContext = PublishStoreEventWithEntityKeyContext;
|
|
720
717
|
exports2.RegionView = RegionView;
|
|
721
|
-
exports2.
|
|
718
|
+
exports2.syncStoreModelWithSelectorOptions = syncStoreModelWithSelectorOptions;
|
|
722
719
|
exports2.useEventBus = useEventBus;
|
|
723
|
-
exports2.useGetStore = useGetStore;
|
|
724
720
|
exports2.useGetStoreId = useGetStoreId;
|
|
721
|
+
exports2.useGetStoreModel = useGetStoreModel;
|
|
725
722
|
exports2.usePublishEvent = usePublishEvent;
|
|
726
723
|
exports2.usePublishStoreEvent = usePublishStoreEvent;
|
|
727
724
|
exports2.usePublishStoreEventWithEntityKey = usePublishStoreEventWithEntityKey;
|
|
728
|
-
exports2.
|
|
725
|
+
exports2.useSyncStoreModelWithSelector = useSyncStoreModelWithSelector;
|
|
729
726
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
730
727
|
});
|
|
731
728
|
//# sourceMappingURL=esp-react.js.map
|