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.esm.js
DELETED
|
@@ -1,713 +0,0 @@
|
|
|
1
|
-
import * as require$$0 from "react";
|
|
2
|
-
import require$$0__default, { createContext, useCallback, useContext, useMemo } from "react";
|
|
3
|
-
import { DefaultStoreAddress, Logger, utils } from "esp-js";
|
|
4
|
-
var jsxRuntime = { exports: {} };
|
|
5
|
-
var reactJsxRuntime_production = {};
|
|
6
|
-
/**
|
|
7
|
-
* @license React
|
|
8
|
-
* react-jsx-runtime.production.js
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
-
*
|
|
12
|
-
* This source code is licensed under the MIT license found in the
|
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/
|
|
15
|
-
var hasRequiredReactJsxRuntime_production;
|
|
16
|
-
function requireReactJsxRuntime_production() {
|
|
17
|
-
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
18
|
-
hasRequiredReactJsxRuntime_production = 1;
|
|
19
|
-
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
20
|
-
function jsxProd(type, config, maybeKey) {
|
|
21
|
-
var key = null;
|
|
22
|
-
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
23
|
-
void 0 !== config.key && (key = "" + config.key);
|
|
24
|
-
if ("key" in config) {
|
|
25
|
-
maybeKey = {};
|
|
26
|
-
for (var propName in config)
|
|
27
|
-
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
28
|
-
} else maybeKey = config;
|
|
29
|
-
config = maybeKey.ref;
|
|
30
|
-
return {
|
|
31
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
32
|
-
type,
|
|
33
|
-
key,
|
|
34
|
-
ref: void 0 !== config ? config : null,
|
|
35
|
-
props: maybeKey
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
39
|
-
reactJsxRuntime_production.jsx = jsxProd;
|
|
40
|
-
reactJsxRuntime_production.jsxs = jsxProd;
|
|
41
|
-
return reactJsxRuntime_production;
|
|
42
|
-
}
|
|
43
|
-
var reactJsxRuntime_development = {};
|
|
44
|
-
/**
|
|
45
|
-
* @license React
|
|
46
|
-
* react-jsx-runtime.development.js
|
|
47
|
-
*
|
|
48
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
49
|
-
*
|
|
50
|
-
* This source code is licensed under the MIT license found in the
|
|
51
|
-
* LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/
|
|
53
|
-
var hasRequiredReactJsxRuntime_development;
|
|
54
|
-
function requireReactJsxRuntime_development() {
|
|
55
|
-
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
56
|
-
hasRequiredReactJsxRuntime_development = 1;
|
|
57
|
-
"production" !== process.env.NODE_ENV && function() {
|
|
58
|
-
function getComponentNameFromType(type) {
|
|
59
|
-
if (null == type) return null;
|
|
60
|
-
if ("function" === typeof type)
|
|
61
|
-
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
62
|
-
if ("string" === typeof type) return type;
|
|
63
|
-
switch (type) {
|
|
64
|
-
case REACT_FRAGMENT_TYPE:
|
|
65
|
-
return "Fragment";
|
|
66
|
-
case REACT_PROFILER_TYPE:
|
|
67
|
-
return "Profiler";
|
|
68
|
-
case REACT_STRICT_MODE_TYPE:
|
|
69
|
-
return "StrictMode";
|
|
70
|
-
case REACT_SUSPENSE_TYPE:
|
|
71
|
-
return "Suspense";
|
|
72
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
73
|
-
return "SuspenseList";
|
|
74
|
-
case REACT_ACTIVITY_TYPE:
|
|
75
|
-
return "Activity";
|
|
76
|
-
}
|
|
77
|
-
if ("object" === typeof type)
|
|
78
|
-
switch ("number" === typeof type.tag && console.error(
|
|
79
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
80
|
-
), type.$$typeof) {
|
|
81
|
-
case REACT_PORTAL_TYPE:
|
|
82
|
-
return "Portal";
|
|
83
|
-
case REACT_CONTEXT_TYPE:
|
|
84
|
-
return type.displayName || "Context";
|
|
85
|
-
case REACT_CONSUMER_TYPE:
|
|
86
|
-
return (type._context.displayName || "Context") + ".Consumer";
|
|
87
|
-
case REACT_FORWARD_REF_TYPE:
|
|
88
|
-
var innerType = type.render;
|
|
89
|
-
type = type.displayName;
|
|
90
|
-
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
91
|
-
return type;
|
|
92
|
-
case REACT_MEMO_TYPE:
|
|
93
|
-
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
94
|
-
case REACT_LAZY_TYPE:
|
|
95
|
-
innerType = type._payload;
|
|
96
|
-
type = type._init;
|
|
97
|
-
try {
|
|
98
|
-
return getComponentNameFromType(type(innerType));
|
|
99
|
-
} catch (x) {
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
function testStringCoercion(value) {
|
|
105
|
-
return "" + value;
|
|
106
|
-
}
|
|
107
|
-
function checkKeyStringCoercion(value) {
|
|
108
|
-
try {
|
|
109
|
-
testStringCoercion(value);
|
|
110
|
-
var JSCompiler_inline_result = false;
|
|
111
|
-
} catch (e) {
|
|
112
|
-
JSCompiler_inline_result = true;
|
|
113
|
-
}
|
|
114
|
-
if (JSCompiler_inline_result) {
|
|
115
|
-
JSCompiler_inline_result = console;
|
|
116
|
-
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
117
|
-
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
118
|
-
JSCompiler_temp_const.call(
|
|
119
|
-
JSCompiler_inline_result,
|
|
120
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
121
|
-
JSCompiler_inline_result$jscomp$0
|
|
122
|
-
);
|
|
123
|
-
return testStringCoercion(value);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function getTaskName(type) {
|
|
127
|
-
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
128
|
-
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
129
|
-
return "<...>";
|
|
130
|
-
try {
|
|
131
|
-
var name = getComponentNameFromType(type);
|
|
132
|
-
return name ? "<" + name + ">" : "<...>";
|
|
133
|
-
} catch (x) {
|
|
134
|
-
return "<...>";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function getOwner() {
|
|
138
|
-
var dispatcher = ReactSharedInternals.A;
|
|
139
|
-
return null === dispatcher ? null : dispatcher.getOwner();
|
|
140
|
-
}
|
|
141
|
-
function UnknownOwner() {
|
|
142
|
-
return Error("react-stack-top-frame");
|
|
143
|
-
}
|
|
144
|
-
function hasValidKey(config) {
|
|
145
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
146
|
-
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
147
|
-
if (getter && getter.isReactWarning) return false;
|
|
148
|
-
}
|
|
149
|
-
return void 0 !== config.key;
|
|
150
|
-
}
|
|
151
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
152
|
-
function warnAboutAccessingKey() {
|
|
153
|
-
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
154
|
-
"%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)",
|
|
155
|
-
displayName
|
|
156
|
-
));
|
|
157
|
-
}
|
|
158
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
159
|
-
Object.defineProperty(props, "key", {
|
|
160
|
-
get: warnAboutAccessingKey,
|
|
161
|
-
configurable: true
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
function elementRefGetterWithDeprecationWarning() {
|
|
165
|
-
var componentName = getComponentNameFromType(this.type);
|
|
166
|
-
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
167
|
-
"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."
|
|
168
|
-
));
|
|
169
|
-
componentName = this.props.ref;
|
|
170
|
-
return void 0 !== componentName ? componentName : null;
|
|
171
|
-
}
|
|
172
|
-
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
173
|
-
var refProp = props.ref;
|
|
174
|
-
type = {
|
|
175
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
176
|
-
type,
|
|
177
|
-
key,
|
|
178
|
-
props,
|
|
179
|
-
_owner: owner
|
|
180
|
-
};
|
|
181
|
-
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
182
|
-
enumerable: false,
|
|
183
|
-
get: elementRefGetterWithDeprecationWarning
|
|
184
|
-
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
185
|
-
type._store = {};
|
|
186
|
-
Object.defineProperty(type._store, "validated", {
|
|
187
|
-
configurable: false,
|
|
188
|
-
enumerable: false,
|
|
189
|
-
writable: true,
|
|
190
|
-
value: 0
|
|
191
|
-
});
|
|
192
|
-
Object.defineProperty(type, "_debugInfo", {
|
|
193
|
-
configurable: false,
|
|
194
|
-
enumerable: false,
|
|
195
|
-
writable: true,
|
|
196
|
-
value: null
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(type, "_debugStack", {
|
|
199
|
-
configurable: false,
|
|
200
|
-
enumerable: false,
|
|
201
|
-
writable: true,
|
|
202
|
-
value: debugStack
|
|
203
|
-
});
|
|
204
|
-
Object.defineProperty(type, "_debugTask", {
|
|
205
|
-
configurable: false,
|
|
206
|
-
enumerable: false,
|
|
207
|
-
writable: true,
|
|
208
|
-
value: debugTask
|
|
209
|
-
});
|
|
210
|
-
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
211
|
-
return type;
|
|
212
|
-
}
|
|
213
|
-
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
|
|
214
|
-
var children = config.children;
|
|
215
|
-
if (void 0 !== children)
|
|
216
|
-
if (isStaticChildren)
|
|
217
|
-
if (isArrayImpl(children)) {
|
|
218
|
-
for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
|
|
219
|
-
validateChildKeys(children[isStaticChildren]);
|
|
220
|
-
Object.freeze && Object.freeze(children);
|
|
221
|
-
} else
|
|
222
|
-
console.error(
|
|
223
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
224
|
-
);
|
|
225
|
-
else validateChildKeys(children);
|
|
226
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
227
|
-
children = getComponentNameFromType(type);
|
|
228
|
-
var keys = Object.keys(config).filter(function(k) {
|
|
229
|
-
return "key" !== k;
|
|
230
|
-
});
|
|
231
|
-
isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
232
|
-
didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
233
|
-
'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} />',
|
|
234
|
-
isStaticChildren,
|
|
235
|
-
children,
|
|
236
|
-
keys,
|
|
237
|
-
children
|
|
238
|
-
), didWarnAboutKeySpread[children + isStaticChildren] = true);
|
|
239
|
-
}
|
|
240
|
-
children = null;
|
|
241
|
-
void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
|
|
242
|
-
hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
|
|
243
|
-
if ("key" in config) {
|
|
244
|
-
maybeKey = {};
|
|
245
|
-
for (var propName in config)
|
|
246
|
-
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
247
|
-
} else maybeKey = config;
|
|
248
|
-
children && defineKeyPropWarningGetter(
|
|
249
|
-
maybeKey,
|
|
250
|
-
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
251
|
-
);
|
|
252
|
-
return ReactElement(
|
|
253
|
-
type,
|
|
254
|
-
children,
|
|
255
|
-
maybeKey,
|
|
256
|
-
getOwner(),
|
|
257
|
-
debugStack,
|
|
258
|
-
debugTask
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
function validateChildKeys(node) {
|
|
262
|
-
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));
|
|
263
|
-
}
|
|
264
|
-
function isValidElement(object) {
|
|
265
|
-
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
266
|
-
}
|
|
267
|
-
var React = require$$0__default, 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() {
|
|
268
|
-
return null;
|
|
269
|
-
};
|
|
270
|
-
React = {
|
|
271
|
-
react_stack_bottom_frame: function(callStackForError) {
|
|
272
|
-
return callStackForError();
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
var specialPropKeyWarningShown;
|
|
276
|
-
var didWarnAboutElementRef = {};
|
|
277
|
-
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
|
|
278
|
-
React,
|
|
279
|
-
UnknownOwner
|
|
280
|
-
)();
|
|
281
|
-
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
282
|
-
var didWarnAboutKeySpread = {};
|
|
283
|
-
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
284
|
-
reactJsxRuntime_development.jsx = function(type, config, maybeKey) {
|
|
285
|
-
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
286
|
-
return jsxDEVImpl(
|
|
287
|
-
type,
|
|
288
|
-
config,
|
|
289
|
-
maybeKey,
|
|
290
|
-
false,
|
|
291
|
-
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
292
|
-
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
293
|
-
);
|
|
294
|
-
};
|
|
295
|
-
reactJsxRuntime_development.jsxs = function(type, config, maybeKey) {
|
|
296
|
-
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
297
|
-
return jsxDEVImpl(
|
|
298
|
-
type,
|
|
299
|
-
config,
|
|
300
|
-
maybeKey,
|
|
301
|
-
true,
|
|
302
|
-
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
303
|
-
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
304
|
-
);
|
|
305
|
-
};
|
|
306
|
-
}();
|
|
307
|
-
return reactJsxRuntime_development;
|
|
308
|
-
}
|
|
309
|
-
if (process.env.NODE_ENV === "production") {
|
|
310
|
-
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
311
|
-
} else {
|
|
312
|
-
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
313
|
-
}
|
|
314
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
315
|
-
const EventBusContext = createContext(null);
|
|
316
|
-
const useEventBus = () => {
|
|
317
|
-
return useContext(EventBusContext);
|
|
318
|
-
};
|
|
319
|
-
const createPublishEvent = (bus) => {
|
|
320
|
-
function publishEvent(...args) {
|
|
321
|
-
if (args.length === 1) {
|
|
322
|
-
bus.publishEvent(args[0].address, args[0].eventType, args[0].event);
|
|
323
|
-
} else {
|
|
324
|
-
bus.publishEvent(args[0], args[1], args[2]);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return publishEvent;
|
|
328
|
-
};
|
|
329
|
-
const PublishEventContext = createContext(null);
|
|
330
|
-
const usePublishEvent = () => useContext(PublishEventContext);
|
|
331
|
-
const EspEventBusContextProvider = ({ children, bus }) => {
|
|
332
|
-
let busFromContext = useEventBus();
|
|
333
|
-
bus = bus || busFromContext;
|
|
334
|
-
const publishEvent = useCallback(createPublishEvent(bus), [bus]);
|
|
335
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(EventBusContext.Provider, { value: bus, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PublishEventContext.Provider, { value: publishEvent, children }) });
|
|
336
|
-
};
|
|
337
|
-
const GetStoreIdContext = createContext(null);
|
|
338
|
-
const useGetStoreId = () => useContext(GetStoreIdContext);
|
|
339
|
-
const GetStoreContext = createContext(null);
|
|
340
|
-
const useGetStore = () => useContext(GetStoreContext);
|
|
341
|
-
const createPublishStoreEvent = (bus, storeId) => {
|
|
342
|
-
function publishStoreEvent(...args) {
|
|
343
|
-
if (args.length === 1) {
|
|
344
|
-
bus.publishEvent(storeId, args[0].eventType, args[0].event);
|
|
345
|
-
} else {
|
|
346
|
-
bus.publishEvent(storeId, args[0], args[1]);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return publishStoreEvent;
|
|
350
|
-
};
|
|
351
|
-
const PublishStoreEventContext = createContext(null);
|
|
352
|
-
const usePublishStoreEvent = () => useContext(PublishStoreEventContext);
|
|
353
|
-
const createPublishStoreEventWithEntityKey = (bus, storeId) => {
|
|
354
|
-
function publishStoreEventWithEntityKey(...args) {
|
|
355
|
-
if (args.length === 1) {
|
|
356
|
-
bus.publishEvent(new DefaultStoreAddress(storeId, args[0].entityKey), args[0].eventType, args[0].event);
|
|
357
|
-
} else {
|
|
358
|
-
bus.publishEvent(new DefaultStoreAddress(storeId, args[0]), args[1], args[2]);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return publishStoreEventWithEntityKey;
|
|
362
|
-
};
|
|
363
|
-
const PublishStoreEventWithEntityKeyContext = createContext(null);
|
|
364
|
-
const usePublishStoreEventWithEntityKey = () => useContext(PublishStoreEventWithEntityKeyContext);
|
|
365
|
-
const EspStoreContextProvider = ({ storeId, children, model }) => {
|
|
366
|
-
const bus = useEventBus();
|
|
367
|
-
let storeIdFromContext = useGetStoreId();
|
|
368
|
-
storeId = storeId || storeIdFromContext;
|
|
369
|
-
const publishStoreEvent = useCallback(createPublishStoreEvent(bus, storeId), [bus, storeId]);
|
|
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(GetStoreContext.Provider, { value: model, children }) }) }) });
|
|
372
|
-
};
|
|
373
|
-
var withSelector = { exports: {} };
|
|
374
|
-
var useSyncExternalStoreWithSelector_production = {};
|
|
375
|
-
/**
|
|
376
|
-
* @license React
|
|
377
|
-
* use-sync-external-store-with-selector.production.js
|
|
378
|
-
*
|
|
379
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
380
|
-
*
|
|
381
|
-
* This source code is licensed under the MIT license found in the
|
|
382
|
-
* LICENSE file in the root directory of this source tree.
|
|
383
|
-
*/
|
|
384
|
-
var hasRequiredUseSyncExternalStoreWithSelector_production;
|
|
385
|
-
function requireUseSyncExternalStoreWithSelector_production() {
|
|
386
|
-
if (hasRequiredUseSyncExternalStoreWithSelector_production) return useSyncExternalStoreWithSelector_production;
|
|
387
|
-
hasRequiredUseSyncExternalStoreWithSelector_production = 1;
|
|
388
|
-
var React = require$$0__default;
|
|
389
|
-
function is(x, y) {
|
|
390
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
391
|
-
}
|
|
392
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React.useSyncExternalStore, useRef = React.useRef, useEffect = React.useEffect, useMemo2 = React.useMemo, useDebugValue = React.useDebugValue;
|
|
393
|
-
useSyncExternalStoreWithSelector_production.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
394
|
-
var instRef = useRef(null);
|
|
395
|
-
if (null === instRef.current) {
|
|
396
|
-
var inst = { hasValue: false, value: null };
|
|
397
|
-
instRef.current = inst;
|
|
398
|
-
} else inst = instRef.current;
|
|
399
|
-
instRef = useMemo2(
|
|
400
|
-
function() {
|
|
401
|
-
function memoizedSelector(nextSnapshot) {
|
|
402
|
-
if (!hasMemo) {
|
|
403
|
-
hasMemo = true;
|
|
404
|
-
memoizedSnapshot = nextSnapshot;
|
|
405
|
-
nextSnapshot = selector(nextSnapshot);
|
|
406
|
-
if (void 0 !== isEqual && inst.hasValue) {
|
|
407
|
-
var currentSelection = inst.value;
|
|
408
|
-
if (isEqual(currentSelection, nextSnapshot))
|
|
409
|
-
return memoizedSelection = currentSelection;
|
|
410
|
-
}
|
|
411
|
-
return memoizedSelection = nextSnapshot;
|
|
412
|
-
}
|
|
413
|
-
currentSelection = memoizedSelection;
|
|
414
|
-
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
|
415
|
-
var nextSelection = selector(nextSnapshot);
|
|
416
|
-
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
417
|
-
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
418
|
-
memoizedSnapshot = nextSnapshot;
|
|
419
|
-
return memoizedSelection = nextSelection;
|
|
420
|
-
}
|
|
421
|
-
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
422
|
-
return [
|
|
423
|
-
function() {
|
|
424
|
-
return memoizedSelector(getSnapshot());
|
|
425
|
-
},
|
|
426
|
-
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
427
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
|
428
|
-
}
|
|
429
|
-
];
|
|
430
|
-
},
|
|
431
|
-
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
432
|
-
);
|
|
433
|
-
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
434
|
-
useEffect(
|
|
435
|
-
function() {
|
|
436
|
-
inst.hasValue = true;
|
|
437
|
-
inst.value = value;
|
|
438
|
-
},
|
|
439
|
-
[value]
|
|
440
|
-
);
|
|
441
|
-
useDebugValue(value);
|
|
442
|
-
return value;
|
|
443
|
-
};
|
|
444
|
-
return useSyncExternalStoreWithSelector_production;
|
|
445
|
-
}
|
|
446
|
-
var useSyncExternalStoreWithSelector_development = {};
|
|
447
|
-
/**
|
|
448
|
-
* @license React
|
|
449
|
-
* use-sync-external-store-with-selector.development.js
|
|
450
|
-
*
|
|
451
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
452
|
-
*
|
|
453
|
-
* This source code is licensed under the MIT license found in the
|
|
454
|
-
* LICENSE file in the root directory of this source tree.
|
|
455
|
-
*/
|
|
456
|
-
var hasRequiredUseSyncExternalStoreWithSelector_development;
|
|
457
|
-
function requireUseSyncExternalStoreWithSelector_development() {
|
|
458
|
-
if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
|
|
459
|
-
hasRequiredUseSyncExternalStoreWithSelector_development = 1;
|
|
460
|
-
"production" !== process.env.NODE_ENV && function() {
|
|
461
|
-
function is(x, y) {
|
|
462
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
463
|
-
}
|
|
464
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
465
|
-
var React = require$$0__default, objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = React.useSyncExternalStore, useRef = React.useRef, useEffect = React.useEffect, useMemo2 = React.useMemo, useDebugValue = React.useDebugValue;
|
|
466
|
-
useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
467
|
-
var instRef = useRef(null);
|
|
468
|
-
if (null === instRef.current) {
|
|
469
|
-
var inst = { hasValue: false, value: null };
|
|
470
|
-
instRef.current = inst;
|
|
471
|
-
} else inst = instRef.current;
|
|
472
|
-
instRef = useMemo2(
|
|
473
|
-
function() {
|
|
474
|
-
function memoizedSelector(nextSnapshot) {
|
|
475
|
-
if (!hasMemo) {
|
|
476
|
-
hasMemo = true;
|
|
477
|
-
memoizedSnapshot = nextSnapshot;
|
|
478
|
-
nextSnapshot = selector(nextSnapshot);
|
|
479
|
-
if (void 0 !== isEqual && inst.hasValue) {
|
|
480
|
-
var currentSelection = inst.value;
|
|
481
|
-
if (isEqual(currentSelection, nextSnapshot))
|
|
482
|
-
return memoizedSelection = currentSelection;
|
|
483
|
-
}
|
|
484
|
-
return memoizedSelection = nextSnapshot;
|
|
485
|
-
}
|
|
486
|
-
currentSelection = memoizedSelection;
|
|
487
|
-
if (objectIs(memoizedSnapshot, nextSnapshot))
|
|
488
|
-
return currentSelection;
|
|
489
|
-
var nextSelection = selector(nextSnapshot);
|
|
490
|
-
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
491
|
-
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
492
|
-
memoizedSnapshot = nextSnapshot;
|
|
493
|
-
return memoizedSelection = nextSelection;
|
|
494
|
-
}
|
|
495
|
-
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
496
|
-
return [
|
|
497
|
-
function() {
|
|
498
|
-
return memoizedSelector(getSnapshot());
|
|
499
|
-
},
|
|
500
|
-
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
501
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
|
502
|
-
}
|
|
503
|
-
];
|
|
504
|
-
},
|
|
505
|
-
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
506
|
-
);
|
|
507
|
-
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
508
|
-
useEffect(
|
|
509
|
-
function() {
|
|
510
|
-
inst.hasValue = true;
|
|
511
|
-
inst.value = value;
|
|
512
|
-
},
|
|
513
|
-
[value]
|
|
514
|
-
);
|
|
515
|
-
useDebugValue(value);
|
|
516
|
-
return value;
|
|
517
|
-
};
|
|
518
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
519
|
-
}();
|
|
520
|
-
return useSyncExternalStoreWithSelector_development;
|
|
521
|
-
}
|
|
522
|
-
if (process.env.NODE_ENV === "production") {
|
|
523
|
-
withSelector.exports = requireUseSyncExternalStoreWithSelector_production();
|
|
524
|
-
} else {
|
|
525
|
-
withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
|
|
526
|
-
}
|
|
527
|
-
var withSelectorExports = withSelector.exports;
|
|
528
|
-
Logger.create("useSyncModelWithSelector");
|
|
529
|
-
const syncModelWithSelectorOptions = () => {
|
|
530
|
-
let storeId = void 0;
|
|
531
|
-
let equalityFn = (a, b) => a === b;
|
|
532
|
-
return {
|
|
533
|
-
get storeId() {
|
|
534
|
-
return storeId;
|
|
535
|
-
},
|
|
536
|
-
setStoreId(value) {
|
|
537
|
-
storeId = value;
|
|
538
|
-
return this;
|
|
539
|
-
},
|
|
540
|
-
get equalityFn() {
|
|
541
|
-
return equalityFn;
|
|
542
|
-
},
|
|
543
|
-
setEqualityFn(value) {
|
|
544
|
-
equalityFn = value;
|
|
545
|
-
return this;
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
};
|
|
549
|
-
const checkArguments = (selector, options) => {
|
|
550
|
-
if (!utils.isFunction(selector)) {
|
|
551
|
-
throw new Error("You must pass a selector function to useSyncModelWithSelector");
|
|
552
|
-
}
|
|
553
|
-
if (!utils.isObject(options)) {
|
|
554
|
-
throw new Error("You must provide options when using useSyncModelWithSelector");
|
|
555
|
-
}
|
|
556
|
-
if (!utils.isFunction(options.equalityFn)) {
|
|
557
|
-
throw new Error("You must provide an equalityFn when using useSyncModelWithSelector");
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
const useSyncModelWithSelector = (selector, options = syncModelWithSelectorOptions()) => {
|
|
561
|
-
checkArguments(selector, options);
|
|
562
|
-
const bus = useEventBus();
|
|
563
|
-
const storeIdFromContext = useGetStoreId();
|
|
564
|
-
const storeId = (options == null ? void 0 : options.storeId) || storeIdFromContext;
|
|
565
|
-
const equalityFn = options == null ? void 0 : options.equalityFn;
|
|
566
|
-
const dependencies = useMemo(
|
|
567
|
-
() => {
|
|
568
|
-
const canSubscribe = bus && utils.isString(storeId) && bus.isModelRegistered(storeId);
|
|
569
|
-
if (canSubscribe) {
|
|
570
|
-
return createSubscriptionState(bus, storeId, selector);
|
|
571
|
-
}
|
|
572
|
-
return createNoopSubscriptionState();
|
|
573
|
-
},
|
|
574
|
-
// Don't add 'selector' to the dependency list as that will likely change unless the caller memoizes it.
|
|
575
|
-
[bus, storeId]
|
|
576
|
-
);
|
|
577
|
-
return withSelectorExports.useSyncExternalStoreWithSelector(
|
|
578
|
-
dependencies.subscribe,
|
|
579
|
-
dependencies.getSnapshot,
|
|
580
|
-
void 0,
|
|
581
|
-
dependencies.wrappedSelector,
|
|
582
|
-
equalityFn
|
|
583
|
-
);
|
|
584
|
-
};
|
|
585
|
-
const createSubscriptionState = (bus, storeId, selector) => {
|
|
586
|
-
let currentModel;
|
|
587
|
-
return {
|
|
588
|
-
subscribe: (stateChanged) => {
|
|
589
|
-
const modelSubscriptionDisposable = bus.getModelObservable(storeId).subscribe(
|
|
590
|
-
(m) => {
|
|
591
|
-
currentModel = m;
|
|
592
|
-
stateChanged();
|
|
593
|
-
}
|
|
594
|
-
);
|
|
595
|
-
return () => {
|
|
596
|
-
currentModel = null;
|
|
597
|
-
modelSubscriptionDisposable.dispose();
|
|
598
|
-
};
|
|
599
|
-
},
|
|
600
|
-
// React expects getSnapshot to be pure and stable between renders unless the store has changed.
|
|
601
|
-
// We seed currentModel from bus.getModel() on first call (before subscribe has been called),
|
|
602
|
-
// then keep it up-to-date via the subscription callback above.
|
|
603
|
-
getSnapshot: () => {
|
|
604
|
-
if (currentModel == null) {
|
|
605
|
-
currentModel = bus.getModel(storeId);
|
|
606
|
-
}
|
|
607
|
-
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
|
-
}
|
|
615
|
-
};
|
|
616
|
-
};
|
|
617
|
-
const createNoopSubscriptionState = () => ({
|
|
618
|
-
subscribe: () => {
|
|
619
|
-
return () => {
|
|
620
|
-
};
|
|
621
|
-
},
|
|
622
|
-
getSnapshot: () => null,
|
|
623
|
-
wrappedSelector: () => null
|
|
624
|
-
});
|
|
625
|
-
const getChildProps = (bus, storeId, restProps, model, mapModelToProps, publishEventProps) => {
|
|
626
|
-
let childProps = {
|
|
627
|
-
storeId,
|
|
628
|
-
bus,
|
|
629
|
-
...restProps,
|
|
630
|
-
...publishEventProps,
|
|
631
|
-
model
|
|
632
|
-
};
|
|
633
|
-
if (mapModelToProps) {
|
|
634
|
-
childProps = {
|
|
635
|
-
...childProps,
|
|
636
|
-
...mapModelToProps(model, publishEventProps)
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
return childProps;
|
|
640
|
-
};
|
|
641
|
-
const ConnectableComponent = ({
|
|
642
|
-
storeId,
|
|
643
|
-
mapModelToProps,
|
|
644
|
-
createPublishEventProps,
|
|
645
|
-
view,
|
|
646
|
-
...rest
|
|
647
|
-
}) => {
|
|
648
|
-
const bus = useEventBus();
|
|
649
|
-
let storeIdFromContext = useGetStoreId();
|
|
650
|
-
storeId = storeId || storeIdFromContext;
|
|
651
|
-
const publishEventProps = useMemo(
|
|
652
|
-
() => {
|
|
653
|
-
if (createPublishEventProps) {
|
|
654
|
-
const publishModelEvent = (eventType, event) => {
|
|
655
|
-
bus.publishEvent(storeId, eventType, event);
|
|
656
|
-
};
|
|
657
|
-
return createPublishEventProps(publishModelEvent);
|
|
658
|
-
}
|
|
659
|
-
return {};
|
|
660
|
-
},
|
|
661
|
-
[bus, storeId]
|
|
662
|
-
);
|
|
663
|
-
const model = useSyncModelWithSelector(
|
|
664
|
-
(m) => m,
|
|
665
|
-
syncModelWithSelectorOptions().setStoreId(storeId)
|
|
666
|
-
);
|
|
667
|
-
if (model == null) {
|
|
668
|
-
return null;
|
|
669
|
-
}
|
|
670
|
-
let childProps = getChildProps(bus, storeId, rest, model, mapModelToProps, publishEventProps);
|
|
671
|
-
let viewElement = view ? require$$0.createElement(view, childProps) : null;
|
|
672
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(EspStoreContextProvider, { storeId, model, bus, ...childProps, children: viewElement });
|
|
673
|
-
};
|
|
674
|
-
const EspModulesContext = require$$0__default.createContext([]);
|
|
675
|
-
const RegionView = ({ regionName }) => {
|
|
676
|
-
const modules = useContext(EspModulesContext);
|
|
677
|
-
const bindings = useMemo(
|
|
678
|
-
() => modules.flatMap((m) => m.viewBindings).filter((b) => b.region === regionName),
|
|
679
|
-
[modules, regionName]
|
|
680
|
-
);
|
|
681
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: bindings.map((binding) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
682
|
-
ConnectableComponent,
|
|
683
|
-
{
|
|
684
|
-
storeId: binding.storeId,
|
|
685
|
-
view: binding.viewComponent
|
|
686
|
-
},
|
|
687
|
-
binding.storeId
|
|
688
|
-
)) });
|
|
689
|
-
};
|
|
690
|
-
const EspApp = ({ app, children }) => /* @__PURE__ */ jsxRuntimeExports.jsx(EspEventBusContextProvider, { bus: app.eventBus, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EspModulesContext.Provider, { value: app.modules, children }) });
|
|
691
|
-
export {
|
|
692
|
-
ConnectableComponent,
|
|
693
|
-
EspApp,
|
|
694
|
-
EspEventBusContextProvider,
|
|
695
|
-
EspModulesContext,
|
|
696
|
-
EspStoreContextProvider,
|
|
697
|
-
EventBusContext,
|
|
698
|
-
GetStoreContext,
|
|
699
|
-
GetStoreIdContext,
|
|
700
|
-
PublishEventContext,
|
|
701
|
-
PublishStoreEventContext,
|
|
702
|
-
PublishStoreEventWithEntityKeyContext,
|
|
703
|
-
RegionView,
|
|
704
|
-
syncModelWithSelectorOptions,
|
|
705
|
-
useEventBus,
|
|
706
|
-
useGetStore,
|
|
707
|
-
useGetStoreId,
|
|
708
|
-
usePublishEvent,
|
|
709
|
-
usePublishStoreEvent,
|
|
710
|
-
usePublishStoreEventWithEntityKey,
|
|
711
|
-
useSyncModelWithSelector
|
|
712
|
-
};
|
|
713
|
-
//# sourceMappingURL=esp-react.esm.js.map
|