esp-js-react 9.0.0-beta.1 → 9.0.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.
- package/.dist/esp-react.esm.mjs +399 -0
- package/.dist/esp-react.esm.mjs.map +1 -0
- package/.dist/esp-react.js +68 -382
- 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 +2 -2
- package/.dist/typings/espEventBusContextProvider.d.ts +4 -3
- package/.dist/typings/espModulesContext.d.ts +1 -1
- package/.dist/typings/espStoreContextProvider.d.ts +8 -7
- package/.dist/typings/index.d.ts +4 -4
- package/.dist/typings/regionView.d.ts +2 -1
- package/.dist/typings/useSyncStoreModelWithSelector.d.ts +47 -0
- package/README.md +2 -2
- package/package.json +19 -11
- package/.dist/esp-react.esm.js +0 -713
- package/.dist/esp-react.esm.js.map +0 -1
- package/.dist/typings/useSyncModelWithSelector.d.ts +0 -45
package/.dist/esp-react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.
|
|
3
|
-
})(this, function(exports2,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("esp-js")) : typeof define === "function" && define.amd ? define(["exports", "react", "esp-js"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.espReact = {}, global.React, global.espJs));
|
|
3
|
+
})(this, function(exports2, React, espJs) {
|
|
4
4
|
"use strict";
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -18,321 +18,10 @@
|
|
|
18
18
|
n.default = e;
|
|
19
19
|
return Object.freeze(n);
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
var reactJsxRuntime_production = {};
|
|
24
|
-
/**
|
|
25
|
-
* @license React
|
|
26
|
-
* react-jsx-runtime.production.js
|
|
27
|
-
*
|
|
28
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the MIT license found in the
|
|
31
|
-
* LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/
|
|
33
|
-
var hasRequiredReactJsxRuntime_production;
|
|
34
|
-
function requireReactJsxRuntime_production() {
|
|
35
|
-
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
36
|
-
hasRequiredReactJsxRuntime_production = 1;
|
|
37
|
-
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
38
|
-
function jsxProd(type, config, maybeKey) {
|
|
39
|
-
var key = null;
|
|
40
|
-
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
41
|
-
void 0 !== config.key && (key = "" + config.key);
|
|
42
|
-
if ("key" in config) {
|
|
43
|
-
maybeKey = {};
|
|
44
|
-
for (var propName in config)
|
|
45
|
-
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
46
|
-
} else maybeKey = config;
|
|
47
|
-
config = maybeKey.ref;
|
|
48
|
-
return {
|
|
49
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
50
|
-
type,
|
|
51
|
-
key,
|
|
52
|
-
ref: void 0 !== config ? config : null,
|
|
53
|
-
props: maybeKey
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
57
|
-
reactJsxRuntime_production.jsx = jsxProd;
|
|
58
|
-
reactJsxRuntime_production.jsxs = jsxProd;
|
|
59
|
-
return reactJsxRuntime_production;
|
|
60
|
-
}
|
|
61
|
-
var reactJsxRuntime_development = {};
|
|
62
|
-
/**
|
|
63
|
-
* @license React
|
|
64
|
-
* react-jsx-runtime.development.js
|
|
65
|
-
*
|
|
66
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
67
|
-
*
|
|
68
|
-
* This source code is licensed under the MIT license found in the
|
|
69
|
-
* LICENSE file in the root directory of this source tree.
|
|
70
|
-
*/
|
|
71
|
-
var hasRequiredReactJsxRuntime_development;
|
|
72
|
-
function requireReactJsxRuntime_development() {
|
|
73
|
-
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
74
|
-
hasRequiredReactJsxRuntime_development = 1;
|
|
75
|
-
"production" !== process.env.NODE_ENV && function() {
|
|
76
|
-
function getComponentNameFromType(type) {
|
|
77
|
-
if (null == type) return null;
|
|
78
|
-
if ("function" === typeof type)
|
|
79
|
-
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
80
|
-
if ("string" === typeof type) return type;
|
|
81
|
-
switch (type) {
|
|
82
|
-
case REACT_FRAGMENT_TYPE:
|
|
83
|
-
return "Fragment";
|
|
84
|
-
case REACT_PROFILER_TYPE:
|
|
85
|
-
return "Profiler";
|
|
86
|
-
case REACT_STRICT_MODE_TYPE:
|
|
87
|
-
return "StrictMode";
|
|
88
|
-
case REACT_SUSPENSE_TYPE:
|
|
89
|
-
return "Suspense";
|
|
90
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
91
|
-
return "SuspenseList";
|
|
92
|
-
case REACT_ACTIVITY_TYPE:
|
|
93
|
-
return "Activity";
|
|
94
|
-
}
|
|
95
|
-
if ("object" === typeof type)
|
|
96
|
-
switch ("number" === typeof type.tag && console.error(
|
|
97
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
98
|
-
), type.$$typeof) {
|
|
99
|
-
case REACT_PORTAL_TYPE:
|
|
100
|
-
return "Portal";
|
|
101
|
-
case REACT_CONTEXT_TYPE:
|
|
102
|
-
return type.displayName || "Context";
|
|
103
|
-
case REACT_CONSUMER_TYPE:
|
|
104
|
-
return (type._context.displayName || "Context") + ".Consumer";
|
|
105
|
-
case REACT_FORWARD_REF_TYPE:
|
|
106
|
-
var innerType = type.render;
|
|
107
|
-
type = type.displayName;
|
|
108
|
-
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
109
|
-
return type;
|
|
110
|
-
case REACT_MEMO_TYPE:
|
|
111
|
-
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
112
|
-
case REACT_LAZY_TYPE:
|
|
113
|
-
innerType = type._payload;
|
|
114
|
-
type = type._init;
|
|
115
|
-
try {
|
|
116
|
-
return getComponentNameFromType(type(innerType));
|
|
117
|
-
} catch (x) {
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
function testStringCoercion(value) {
|
|
123
|
-
return "" + value;
|
|
124
|
-
}
|
|
125
|
-
function checkKeyStringCoercion(value) {
|
|
126
|
-
try {
|
|
127
|
-
testStringCoercion(value);
|
|
128
|
-
var JSCompiler_inline_result = false;
|
|
129
|
-
} catch (e) {
|
|
130
|
-
JSCompiler_inline_result = true;
|
|
131
|
-
}
|
|
132
|
-
if (JSCompiler_inline_result) {
|
|
133
|
-
JSCompiler_inline_result = console;
|
|
134
|
-
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
135
|
-
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
136
|
-
JSCompiler_temp_const.call(
|
|
137
|
-
JSCompiler_inline_result,
|
|
138
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
139
|
-
JSCompiler_inline_result$jscomp$0
|
|
140
|
-
);
|
|
141
|
-
return testStringCoercion(value);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function getTaskName(type) {
|
|
145
|
-
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
146
|
-
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
147
|
-
return "<...>";
|
|
148
|
-
try {
|
|
149
|
-
var name = getComponentNameFromType(type);
|
|
150
|
-
return name ? "<" + name + ">" : "<...>";
|
|
151
|
-
} catch (x) {
|
|
152
|
-
return "<...>";
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function getOwner() {
|
|
156
|
-
var dispatcher = ReactSharedInternals.A;
|
|
157
|
-
return null === dispatcher ? null : dispatcher.getOwner();
|
|
158
|
-
}
|
|
159
|
-
function UnknownOwner() {
|
|
160
|
-
return Error("react-stack-top-frame");
|
|
161
|
-
}
|
|
162
|
-
function hasValidKey(config) {
|
|
163
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
164
|
-
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
165
|
-
if (getter && getter.isReactWarning) return false;
|
|
166
|
-
}
|
|
167
|
-
return void 0 !== config.key;
|
|
168
|
-
}
|
|
169
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
170
|
-
function warnAboutAccessingKey() {
|
|
171
|
-
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
172
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
173
|
-
displayName
|
|
174
|
-
));
|
|
175
|
-
}
|
|
176
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
177
|
-
Object.defineProperty(props, "key", {
|
|
178
|
-
get: warnAboutAccessingKey,
|
|
179
|
-
configurable: true
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
function elementRefGetterWithDeprecationWarning() {
|
|
183
|
-
var componentName = getComponentNameFromType(this.type);
|
|
184
|
-
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
185
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
186
|
-
));
|
|
187
|
-
componentName = this.props.ref;
|
|
188
|
-
return void 0 !== componentName ? componentName : null;
|
|
189
|
-
}
|
|
190
|
-
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
191
|
-
var refProp = props.ref;
|
|
192
|
-
type = {
|
|
193
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
194
|
-
type,
|
|
195
|
-
key,
|
|
196
|
-
props,
|
|
197
|
-
_owner: owner
|
|
198
|
-
};
|
|
199
|
-
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
200
|
-
enumerable: false,
|
|
201
|
-
get: elementRefGetterWithDeprecationWarning
|
|
202
|
-
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
203
|
-
type._store = {};
|
|
204
|
-
Object.defineProperty(type._store, "validated", {
|
|
205
|
-
configurable: false,
|
|
206
|
-
enumerable: false,
|
|
207
|
-
writable: true,
|
|
208
|
-
value: 0
|
|
209
|
-
});
|
|
210
|
-
Object.defineProperty(type, "_debugInfo", {
|
|
211
|
-
configurable: false,
|
|
212
|
-
enumerable: false,
|
|
213
|
-
writable: true,
|
|
214
|
-
value: null
|
|
215
|
-
});
|
|
216
|
-
Object.defineProperty(type, "_debugStack", {
|
|
217
|
-
configurable: false,
|
|
218
|
-
enumerable: false,
|
|
219
|
-
writable: true,
|
|
220
|
-
value: debugStack
|
|
221
|
-
});
|
|
222
|
-
Object.defineProperty(type, "_debugTask", {
|
|
223
|
-
configurable: false,
|
|
224
|
-
enumerable: false,
|
|
225
|
-
writable: true,
|
|
226
|
-
value: debugTask
|
|
227
|
-
});
|
|
228
|
-
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
229
|
-
return type;
|
|
230
|
-
}
|
|
231
|
-
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
|
|
232
|
-
var children = config.children;
|
|
233
|
-
if (void 0 !== children)
|
|
234
|
-
if (isStaticChildren)
|
|
235
|
-
if (isArrayImpl(children)) {
|
|
236
|
-
for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
|
|
237
|
-
validateChildKeys(children[isStaticChildren]);
|
|
238
|
-
Object.freeze && Object.freeze(children);
|
|
239
|
-
} else
|
|
240
|
-
console.error(
|
|
241
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
242
|
-
);
|
|
243
|
-
else validateChildKeys(children);
|
|
244
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
245
|
-
children = getComponentNameFromType(type);
|
|
246
|
-
var keys = Object.keys(config).filter(function(k) {
|
|
247
|
-
return "key" !== k;
|
|
248
|
-
});
|
|
249
|
-
isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
250
|
-
didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
251
|
-
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
252
|
-
isStaticChildren,
|
|
253
|
-
children,
|
|
254
|
-
keys,
|
|
255
|
-
children
|
|
256
|
-
), didWarnAboutKeySpread[children + isStaticChildren] = true);
|
|
257
|
-
}
|
|
258
|
-
children = null;
|
|
259
|
-
void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
|
|
260
|
-
hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
|
|
261
|
-
if ("key" in config) {
|
|
262
|
-
maybeKey = {};
|
|
263
|
-
for (var propName in config)
|
|
264
|
-
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
265
|
-
} else maybeKey = config;
|
|
266
|
-
children && defineKeyPropWarningGetter(
|
|
267
|
-
maybeKey,
|
|
268
|
-
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
269
|
-
);
|
|
270
|
-
return ReactElement(
|
|
271
|
-
type,
|
|
272
|
-
children,
|
|
273
|
-
maybeKey,
|
|
274
|
-
getOwner(),
|
|
275
|
-
debugStack,
|
|
276
|
-
debugTask
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
function validateChildKeys(node) {
|
|
280
|
-
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
281
|
-
}
|
|
282
|
-
function isValidElement(object) {
|
|
283
|
-
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
284
|
-
}
|
|
285
|
-
var React = require$$0, REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
|
|
286
|
-
return null;
|
|
287
|
-
};
|
|
288
|
-
React = {
|
|
289
|
-
react_stack_bottom_frame: function(callStackForError) {
|
|
290
|
-
return callStackForError();
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
var specialPropKeyWarningShown;
|
|
294
|
-
var didWarnAboutElementRef = {};
|
|
295
|
-
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
|
|
296
|
-
React,
|
|
297
|
-
UnknownOwner
|
|
298
|
-
)();
|
|
299
|
-
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
300
|
-
var didWarnAboutKeySpread = {};
|
|
301
|
-
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
302
|
-
reactJsxRuntime_development.jsx = function(type, config, maybeKey) {
|
|
303
|
-
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
304
|
-
return jsxDEVImpl(
|
|
305
|
-
type,
|
|
306
|
-
config,
|
|
307
|
-
maybeKey,
|
|
308
|
-
false,
|
|
309
|
-
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
310
|
-
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
311
|
-
);
|
|
312
|
-
};
|
|
313
|
-
reactJsxRuntime_development.jsxs = function(type, config, maybeKey) {
|
|
314
|
-
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
315
|
-
return jsxDEVImpl(
|
|
316
|
-
type,
|
|
317
|
-
config,
|
|
318
|
-
maybeKey,
|
|
319
|
-
true,
|
|
320
|
-
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
321
|
-
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
322
|
-
);
|
|
323
|
-
};
|
|
324
|
-
}();
|
|
325
|
-
return reactJsxRuntime_development;
|
|
326
|
-
}
|
|
327
|
-
if (process.env.NODE_ENV === "production") {
|
|
328
|
-
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
329
|
-
} else {
|
|
330
|
-
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
331
|
-
}
|
|
332
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
333
|
-
const EventBusContext = require$$0.createContext(null);
|
|
21
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
22
|
+
const EventBusContext = React.createContext(null);
|
|
334
23
|
const useEventBus = () => {
|
|
335
|
-
return
|
|
24
|
+
return React.useContext(EventBusContext);
|
|
336
25
|
};
|
|
337
26
|
const createPublishEvent = (bus) => {
|
|
338
27
|
function publishEvent(...args) {
|
|
@@ -344,18 +33,18 @@
|
|
|
344
33
|
}
|
|
345
34
|
return publishEvent;
|
|
346
35
|
};
|
|
347
|
-
const PublishEventContext =
|
|
348
|
-
const usePublishEvent = () =>
|
|
36
|
+
const PublishEventContext = React.createContext(null);
|
|
37
|
+
const usePublishEvent = () => React.useContext(PublishEventContext);
|
|
349
38
|
const EspEventBusContextProvider = ({ children, bus }) => {
|
|
350
39
|
let busFromContext = useEventBus();
|
|
351
40
|
bus = bus || busFromContext;
|
|
352
|
-
const publishEvent =
|
|
353
|
-
return /* @__PURE__ */
|
|
41
|
+
const publishEvent = React.useCallback(createPublishEvent(bus), [bus]);
|
|
42
|
+
return /* @__PURE__ */ React__namespace.createElement(EventBusContext.Provider, { value: bus }, /* @__PURE__ */ React__namespace.createElement(PublishEventContext.Provider, { value: publishEvent }, children));
|
|
354
43
|
};
|
|
355
|
-
const GetStoreIdContext =
|
|
356
|
-
const useGetStoreId = () =>
|
|
357
|
-
const
|
|
358
|
-
const
|
|
44
|
+
const GetStoreIdContext = React.createContext(null);
|
|
45
|
+
const useGetStoreId = () => React.useContext(GetStoreIdContext);
|
|
46
|
+
const GetStoreModelContext = React.createContext(null);
|
|
47
|
+
const useGetStoreModel = () => React.useContext(GetStoreModelContext);
|
|
359
48
|
const createPublishStoreEvent = (bus, storeId) => {
|
|
360
49
|
function publishStoreEvent(...args) {
|
|
361
50
|
if (args.length === 1) {
|
|
@@ -366,8 +55,8 @@
|
|
|
366
55
|
}
|
|
367
56
|
return publishStoreEvent;
|
|
368
57
|
};
|
|
369
|
-
const PublishStoreEventContext =
|
|
370
|
-
const usePublishStoreEvent = () =>
|
|
58
|
+
const PublishStoreEventContext = React.createContext(null);
|
|
59
|
+
const usePublishStoreEvent = () => React.useContext(PublishStoreEventContext);
|
|
371
60
|
const createPublishStoreEventWithEntityKey = (bus, storeId) => {
|
|
372
61
|
function publishStoreEventWithEntityKey(...args) {
|
|
373
62
|
if (args.length === 1) {
|
|
@@ -378,15 +67,15 @@
|
|
|
378
67
|
}
|
|
379
68
|
return publishStoreEventWithEntityKey;
|
|
380
69
|
};
|
|
381
|
-
const PublishStoreEventWithEntityKeyContext =
|
|
382
|
-
const usePublishStoreEventWithEntityKey = () =>
|
|
70
|
+
const PublishStoreEventWithEntityKeyContext = React.createContext(null);
|
|
71
|
+
const usePublishStoreEventWithEntityKey = () => React.useContext(PublishStoreEventWithEntityKeyContext);
|
|
383
72
|
const EspStoreContextProvider = ({ storeId, children, model }) => {
|
|
384
73
|
const bus = useEventBus();
|
|
385
74
|
let storeIdFromContext = useGetStoreId();
|
|
386
75
|
storeId = storeId || storeIdFromContext;
|
|
387
|
-
const publishStoreEvent =
|
|
388
|
-
const publishStoreEventWithEntityKey =
|
|
389
|
-
return /* @__PURE__ */
|
|
76
|
+
const publishStoreEvent = React.useCallback(createPublishStoreEvent(bus, storeId), [bus, storeId]);
|
|
77
|
+
const publishStoreEventWithEntityKey = React.useCallback(createPublishStoreEventWithEntityKey(bus, storeId), [bus, storeId]);
|
|
78
|
+
return /* @__PURE__ */ React__namespace.createElement(GetStoreIdContext.Provider, { value: storeId }, /* @__PURE__ */ React__namespace.createElement(PublishStoreEventContext.Provider, { value: publishStoreEvent }, /* @__PURE__ */ React__namespace.createElement(PublishStoreEventWithEntityKeyContext.Provider, { value: publishStoreEventWithEntityKey }, /* @__PURE__ */ React__namespace.createElement(GetStoreModelContext.Provider, { value: model }, children))));
|
|
390
79
|
};
|
|
391
80
|
var withSelector = { exports: {} };
|
|
392
81
|
var useSyncExternalStoreWithSelector_production = {};
|
|
@@ -403,11 +92,11 @@
|
|
|
403
92
|
function requireUseSyncExternalStoreWithSelector_production() {
|
|
404
93
|
if (hasRequiredUseSyncExternalStoreWithSelector_production) return useSyncExternalStoreWithSelector_production;
|
|
405
94
|
hasRequiredUseSyncExternalStoreWithSelector_production = 1;
|
|
406
|
-
var React =
|
|
95
|
+
var React$1 = React;
|
|
407
96
|
function is(x, y) {
|
|
408
97
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
409
98
|
}
|
|
410
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React.useSyncExternalStore, useRef = React.useRef, useEffect = React.useEffect, useMemo = React.useMemo, useDebugValue = React.useDebugValue;
|
|
99
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React$1.useSyncExternalStore, useRef = React$1.useRef, useEffect = React$1.useEffect, useMemo = React$1.useMemo, useDebugValue = React$1.useDebugValue;
|
|
411
100
|
useSyncExternalStoreWithSelector_production.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
412
101
|
var instRef = useRef(null);
|
|
413
102
|
if (null === instRef.current) {
|
|
@@ -475,12 +164,12 @@
|
|
|
475
164
|
function requireUseSyncExternalStoreWithSelector_development() {
|
|
476
165
|
if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
|
|
477
166
|
hasRequiredUseSyncExternalStoreWithSelector_development = 1;
|
|
478
|
-
"production" !==
|
|
167
|
+
"production" !== "development" && function() {
|
|
479
168
|
function is(x, y) {
|
|
480
169
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
481
170
|
}
|
|
482
171
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
483
|
-
var React =
|
|
172
|
+
var React$1 = React, objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React$1.useSyncExternalStore, useRef = React$1.useRef, useEffect = React$1.useEffect, useMemo = React$1.useMemo, useDebugValue = React$1.useDebugValue;
|
|
484
173
|
useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
485
174
|
var instRef = useRef(null);
|
|
486
175
|
if (null === instRef.current) {
|
|
@@ -537,14 +226,14 @@
|
|
|
537
226
|
}();
|
|
538
227
|
return useSyncExternalStoreWithSelector_development;
|
|
539
228
|
}
|
|
540
|
-
if (
|
|
229
|
+
if ("development" === "production") {
|
|
541
230
|
withSelector.exports = requireUseSyncExternalStoreWithSelector_production();
|
|
542
231
|
} else {
|
|
543
232
|
withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
|
|
544
233
|
}
|
|
545
234
|
var withSelectorExports = withSelector.exports;
|
|
546
|
-
espJs.Logger.create("
|
|
547
|
-
const
|
|
235
|
+
espJs.Logger.create("useSyncStoreModelWithSelector");
|
|
236
|
+
const syncStoreModelWithSelectorOptions = () => {
|
|
548
237
|
let storeId = void 0;
|
|
549
238
|
let equalityFn = (a, b) => a === b;
|
|
550
239
|
return {
|
|
@@ -566,46 +255,49 @@
|
|
|
566
255
|
};
|
|
567
256
|
const checkArguments = (selector, options) => {
|
|
568
257
|
if (!espJs.utils.isFunction(selector)) {
|
|
569
|
-
throw new Error("You must pass a selector function to
|
|
258
|
+
throw new Error("You must pass a selector function to useSyncStoreModelWithSelector");
|
|
570
259
|
}
|
|
571
260
|
if (!espJs.utils.isObject(options)) {
|
|
572
|
-
throw new Error("You must provide options when using
|
|
261
|
+
throw new Error("You must provide options when using useSyncStoreModelWithSelector");
|
|
573
262
|
}
|
|
574
263
|
if (!espJs.utils.isFunction(options.equalityFn)) {
|
|
575
|
-
throw new Error("You must provide an equalityFn when using
|
|
264
|
+
throw new Error("You must provide an equalityFn when using useSyncStoreModelWithSelector");
|
|
576
265
|
}
|
|
577
266
|
};
|
|
578
|
-
const
|
|
267
|
+
const useSyncStoreModelWithSelector = (selector, options = syncStoreModelWithSelectorOptions()) => {
|
|
579
268
|
checkArguments(selector, options);
|
|
580
269
|
const bus = useEventBus();
|
|
581
270
|
const storeIdFromContext = useGetStoreId();
|
|
582
271
|
const storeId = (options == null ? void 0 : options.storeId) || storeIdFromContext;
|
|
583
272
|
const equalityFn = options == null ? void 0 : options.equalityFn;
|
|
584
|
-
const dependencies =
|
|
273
|
+
const dependencies = React.useMemo(
|
|
585
274
|
() => {
|
|
586
|
-
const canSubscribe = bus && espJs.utils.isString(storeId)
|
|
275
|
+
const canSubscribe = bus && espJs.utils.isString(storeId);
|
|
587
276
|
if (canSubscribe) {
|
|
588
|
-
return createSubscriptionState(bus, storeId
|
|
277
|
+
return createSubscriptionState(bus, storeId);
|
|
589
278
|
}
|
|
590
279
|
return createNoopSubscriptionState();
|
|
591
280
|
},
|
|
592
|
-
// Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.
|
|
593
281
|
[bus, storeId]
|
|
594
282
|
);
|
|
283
|
+
const wrappedSelector = (snapshot) => snapshot ? selector(snapshot) : null;
|
|
595
284
|
return withSelectorExports.useSyncExternalStoreWithSelector(
|
|
596
285
|
dependencies.subscribe,
|
|
597
286
|
dependencies.getSnapshot,
|
|
598
287
|
void 0,
|
|
599
|
-
|
|
288
|
+
wrappedSelector,
|
|
600
289
|
equalityFn
|
|
601
290
|
);
|
|
602
291
|
};
|
|
603
|
-
const createSubscriptionState = (bus, storeId
|
|
292
|
+
const createSubscriptionState = (bus, storeId) => {
|
|
604
293
|
let currentModel;
|
|
605
294
|
return {
|
|
606
295
|
subscribe: (stateChanged) => {
|
|
607
|
-
const modelSubscriptionDisposable = bus.
|
|
296
|
+
const modelSubscriptionDisposable = bus.getStoreModelObservable(storeId).subscribe(
|
|
608
297
|
(m) => {
|
|
298
|
+
if (m === currentModel) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
609
301
|
currentModel = m;
|
|
610
302
|
stateChanged();
|
|
611
303
|
}
|
|
@@ -616,19 +308,14 @@
|
|
|
616
308
|
};
|
|
617
309
|
},
|
|
618
310
|
// React expects getSnapshot to be pure and stable between renders unless the store has changed.
|
|
619
|
-
// We seed currentModel from bus.
|
|
311
|
+
// We seed currentModel from bus.getStoreModel() on first call (before subscribe has been called),
|
|
620
312
|
// then keep it up-to-date via the subscription callback above.
|
|
313
|
+
// getStoreModel() throws for a store that's been observed but not registered yet, so check first; until then the snapshot is null.
|
|
621
314
|
getSnapshot: () => {
|
|
622
|
-
if (currentModel == null) {
|
|
623
|
-
currentModel = bus.
|
|
315
|
+
if (currentModel == null && bus.isStoreRegistered(storeId)) {
|
|
316
|
+
currentModel = bus.getStoreModel(storeId);
|
|
624
317
|
}
|
|
625
318
|
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
319
|
}
|
|
633
320
|
};
|
|
634
321
|
};
|
|
@@ -637,10 +324,9 @@
|
|
|
637
324
|
return () => {
|
|
638
325
|
};
|
|
639
326
|
},
|
|
640
|
-
getSnapshot: () => null
|
|
641
|
-
wrappedSelector: () => null
|
|
327
|
+
getSnapshot: () => null
|
|
642
328
|
});
|
|
643
|
-
const getChildProps = (bus, storeId, restProps, model,
|
|
329
|
+
const getChildProps = (bus, storeId, restProps, model, mapStoreModelToProps, publishEventProps) => {
|
|
644
330
|
let childProps = {
|
|
645
331
|
storeId,
|
|
646
332
|
bus,
|
|
@@ -648,17 +334,17 @@
|
|
|
648
334
|
...publishEventProps,
|
|
649
335
|
model
|
|
650
336
|
};
|
|
651
|
-
if (
|
|
337
|
+
if (mapStoreModelToProps) {
|
|
652
338
|
childProps = {
|
|
653
339
|
...childProps,
|
|
654
|
-
...
|
|
340
|
+
...mapStoreModelToProps(model, publishEventProps)
|
|
655
341
|
};
|
|
656
342
|
}
|
|
657
343
|
return childProps;
|
|
658
344
|
};
|
|
659
345
|
const ConnectableComponent = ({
|
|
660
346
|
storeId,
|
|
661
|
-
|
|
347
|
+
mapStoreModelToProps,
|
|
662
348
|
createPublishEventProps,
|
|
663
349
|
view,
|
|
664
350
|
...rest
|
|
@@ -666,7 +352,7 @@
|
|
|
666
352
|
const bus = useEventBus();
|
|
667
353
|
let storeIdFromContext = useGetStoreId();
|
|
668
354
|
storeId = storeId || storeIdFromContext;
|
|
669
|
-
const publishEventProps =
|
|
355
|
+
const publishEventProps = React.useMemo(
|
|
670
356
|
() => {
|
|
671
357
|
if (createPublishEventProps) {
|
|
672
358
|
const publishModelEvent = (eventType, event) => {
|
|
@@ -678,54 +364,54 @@
|
|
|
678
364
|
},
|
|
679
365
|
[bus, storeId]
|
|
680
366
|
);
|
|
681
|
-
const model =
|
|
367
|
+
const model = useSyncStoreModelWithSelector(
|
|
682
368
|
(m) => m,
|
|
683
|
-
|
|
369
|
+
syncStoreModelWithSelectorOptions().setStoreId(storeId)
|
|
684
370
|
);
|
|
685
371
|
if (model == null) {
|
|
686
372
|
return null;
|
|
687
373
|
}
|
|
688
|
-
let childProps = getChildProps(bus, storeId, rest, model,
|
|
689
|
-
let viewElement = view ?
|
|
690
|
-
return /* @__PURE__ */
|
|
374
|
+
let childProps = getChildProps(bus, storeId, rest, model, mapStoreModelToProps, publishEventProps);
|
|
375
|
+
let viewElement = view ? React__namespace.createElement(view, childProps) : null;
|
|
376
|
+
return /* @__PURE__ */ React__namespace.createElement(EspStoreContextProvider, { storeId, model, bus, ...childProps }, viewElement);
|
|
691
377
|
};
|
|
692
|
-
const EspModulesContext =
|
|
378
|
+
const EspModulesContext = React__namespace.createContext([]);
|
|
693
379
|
const RegionView = ({ regionName }) => {
|
|
694
|
-
const modules =
|
|
695
|
-
const bindings =
|
|
380
|
+
const modules = React.useContext(EspModulesContext);
|
|
381
|
+
const bindings = React.useMemo(
|
|
696
382
|
() => modules.flatMap((m) => m.viewBindings).filter((b) => b.region === regionName),
|
|
697
383
|
[modules, regionName]
|
|
698
384
|
);
|
|
699
|
-
return /* @__PURE__ */
|
|
385
|
+
return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, bindings.map((binding, index) => /* @__PURE__ */ React__namespace.createElement(
|
|
700
386
|
ConnectableComponent,
|
|
701
387
|
{
|
|
388
|
+
key: `${binding.storeId}:${index}`,
|
|
702
389
|
storeId: binding.storeId,
|
|
703
390
|
view: binding.viewComponent
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
)) });
|
|
391
|
+
}
|
|
392
|
+
)));
|
|
707
393
|
};
|
|
708
|
-
const EspApp = ({ app, children }) => /* @__PURE__ */
|
|
394
|
+
const EspApp = ({ app, children }) => /* @__PURE__ */ React__namespace.createElement(EspEventBusContextProvider, { bus: app.eventBus }, /* @__PURE__ */ React__namespace.createElement(EspModulesContext.Provider, { value: app.modules }, children));
|
|
709
395
|
exports2.ConnectableComponent = ConnectableComponent;
|
|
710
396
|
exports2.EspApp = EspApp;
|
|
711
397
|
exports2.EspEventBusContextProvider = EspEventBusContextProvider;
|
|
712
398
|
exports2.EspModulesContext = EspModulesContext;
|
|
713
399
|
exports2.EspStoreContextProvider = EspStoreContextProvider;
|
|
714
400
|
exports2.EventBusContext = EventBusContext;
|
|
715
|
-
exports2.GetStoreContext = GetStoreContext;
|
|
716
401
|
exports2.GetStoreIdContext = GetStoreIdContext;
|
|
402
|
+
exports2.GetStoreModelContext = GetStoreModelContext;
|
|
717
403
|
exports2.PublishEventContext = PublishEventContext;
|
|
718
404
|
exports2.PublishStoreEventContext = PublishStoreEventContext;
|
|
719
405
|
exports2.PublishStoreEventWithEntityKeyContext = PublishStoreEventWithEntityKeyContext;
|
|
720
406
|
exports2.RegionView = RegionView;
|
|
721
|
-
exports2.
|
|
407
|
+
exports2.syncStoreModelWithSelectorOptions = syncStoreModelWithSelectorOptions;
|
|
722
408
|
exports2.useEventBus = useEventBus;
|
|
723
|
-
exports2.useGetStore = useGetStore;
|
|
724
409
|
exports2.useGetStoreId = useGetStoreId;
|
|
410
|
+
exports2.useGetStoreModel = useGetStoreModel;
|
|
725
411
|
exports2.usePublishEvent = usePublishEvent;
|
|
726
412
|
exports2.usePublishStoreEvent = usePublishStoreEvent;
|
|
727
413
|
exports2.usePublishStoreEventWithEntityKey = usePublishStoreEventWithEntityKey;
|
|
728
|
-
exports2.
|
|
414
|
+
exports2.useSyncStoreModelWithSelector = useSyncStoreModelWithSelector;
|
|
729
415
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
730
416
|
});
|
|
731
417
|
//# sourceMappingURL=esp-react.js.map
|