@next-core/brick-kit 2.70.2 → 2.72.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/index.esm.js CHANGED
@@ -759,9 +759,13 @@ function recursiveMarkAsInjected(value) {
759
759
 
760
760
  if (Array.isArray(value)) {
761
761
  value.forEach(recursiveMarkAsInjected);
762
- } else if (value.constructor === Object) {
762
+ } else {
763
763
  // Only mark pure objects.
764
- Object.values(value).forEach(recursiveMarkAsInjected);
764
+ var proto = Object.getPrototypeOf(value);
765
+
766
+ if (!proto || proto.constructor === Object) {
767
+ Object.values(value).forEach(recursiveMarkAsInjected);
768
+ }
765
769
  }
766
770
  }
767
771
  }
@@ -2298,58 +2302,77 @@ function i18nText(data) {
2298
2302
  }
2299
2303
  }
2300
2304
 
2301
- var registeredFunctions = new Map();
2302
- // Use `Proxy` with a frozen target, to make a readonly function registry.
2303
- var storyboardFunctions = new Proxy(Object.freeze({}), {
2304
- get(target, key) {
2305
- return getStoryboardFunction(key);
2305
+ /** @internal */
2306
+
2307
+ /** @internal */
2308
+ function StoryboardFunctionRegistryFactory() {
2309
+ var registeredFunctions = new Map(); // Use `Proxy` with a frozen target, to make a readonly function registry.
2310
+
2311
+ var storyboardFunctions = new Proxy(Object.freeze({}), {
2312
+ get(target, key) {
2313
+ return getStoryboardFunction(key);
2314
+ }
2315
+
2316
+ });
2317
+
2318
+ function registerStoryboardFunctions(functions) {
2319
+ registeredFunctions.clear();
2320
+
2321
+ if (Array.isArray(functions)) {
2322
+ for (var fn of functions) {
2323
+ registeredFunctions.set(fn.name, {
2324
+ source: fn.source,
2325
+ typescript: fn.typescript
2326
+ });
2327
+ }
2328
+ }
2306
2329
  }
2307
2330
 
2308
- });
2309
- function registerStoryboardFunctions(storyboard) {
2310
- var _storyboard$meta;
2331
+ function getStoryboardFunction(name) {
2332
+ var fn = registeredFunctions.get(name);
2311
2333
 
2312
- registeredFunctions.clear();
2334
+ if (!fn) {
2335
+ return undefined;
2336
+ }
2313
2337
 
2314
- if (Array.isArray((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions)) {
2315
- for (var fn of storyboard.meta.functions) {
2316
- registeredFunctions.set(fn.name, {
2317
- source: fn.source,
2338
+ if (!fn.processed) {
2339
+ var precooked = precookFunction(fn.source, {
2318
2340
  typescript: fn.typescript
2319
2341
  });
2342
+ fn.cooked = cook(precooked.function, fn.source, {
2343
+ rules: {
2344
+ noVar: true
2345
+ },
2346
+ globalVariables: supply(precooked.attemptToVisitGlobals, {
2347
+ // Functions can call other functions.
2348
+ FN: storyboardFunctions
2349
+ })
2350
+ });
2351
+ fn.processed = true;
2320
2352
  }
2321
- }
2322
- }
2323
- function getStoryboardFunctions() {
2324
- return storyboardFunctions;
2325
- }
2326
2353
 
2327
- function getStoryboardFunction(name) {
2328
- var fn = registeredFunctions.get(name);
2329
-
2330
- if (!fn) {
2331
- throw new ReferenceError("Function not found: ".concat(name));
2354
+ return fn.cooked;
2332
2355
  }
2333
2356
 
2334
- if (!fn.processed) {
2335
- var precooked = precookFunction(fn.source, {
2336
- typescript: fn.typescript
2357
+ function updateStoryboardFunction(name, data) {
2358
+ registeredFunctions.set(name, {
2359
+ source: data.source,
2360
+ typescript: data.typescript
2337
2361
  });
2338
- fn.cooked = cook(precooked.function, fn.source, {
2339
- rules: {
2340
- noVar: true
2341
- },
2342
- globalVariables: supply(precooked.attemptToVisitGlobals, {
2343
- // Functions can call other functions.
2344
- FN: storyboardFunctions
2345
- })
2346
- });
2347
- fn.processed = true;
2348
2362
  }
2349
2363
 
2350
- return fn.cooked;
2364
+ return {
2365
+ storyboardFunctions,
2366
+ registerStoryboardFunctions,
2367
+ updateStoryboardFunction
2368
+ };
2351
2369
  }
2352
2370
 
2371
+ var {
2372
+ storyboardFunctions,
2373
+ registerStoryboardFunctions
2374
+ } = StoryboardFunctionRegistryFactory();
2375
+
2353
2376
  var symbolForRaw = Symbol.for("pre.evaluated.raw");
2354
2377
  var symbolForContext = Symbol.for("pre.evaluated.context");
2355
2378
  function isPreEvaluated(raw) {
@@ -2565,7 +2588,7 @@ runtimeContext = {}, options = {}) {
2565
2588
  }
2566
2589
 
2567
2590
  if (attemptToVisitGlobals.has("FN")) {
2568
- globalVariables.FN = getStoryboardFunctions();
2591
+ globalVariables.FN = storyboardFunctions;
2569
2592
  }
2570
2593
 
2571
2594
  try {
@@ -7870,7 +7893,10 @@ class LocationContext {
7870
7893
  }
7871
7894
 
7872
7895
  handlePageLoad() {
7873
- this.dispatchLifeCycleEvent(new CustomEvent("page.load"), this.pageLoadHandlers);
7896
+ var event = new CustomEvent("page.load");
7897
+ this.dispatchLifeCycleEvent(event, this.pageLoadHandlers); // Currently only for e2e testing
7898
+
7899
+ window.dispatchEvent(event);
7874
7900
  }
7875
7901
 
7876
7902
  handleBeforePageLeave(detail) {
@@ -8560,6 +8586,8 @@ class Router {
8560
8586
  var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
8561
8587
 
8562
8588
  if (storyboard) {
8589
+ var _storyboard$meta;
8590
+
8563
8591
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
8564
8592
 
8565
8593
  restoreDynamicTemplates(storyboard); // 预加载权限信息
@@ -8575,7 +8603,7 @@ class Router {
8575
8603
 
8576
8604
  _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
8577
8605
 
8578
- registerStoryboardFunctions(storyboard);
8606
+ registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions);
8579
8607
  }
8580
8608
 
8581
8609
  var {
@@ -10635,5 +10663,5 @@ var ModalElement = _decorate(null, function (_initialize, _UpdatingElement) {
10635
10663
  };
10636
10664
  }, UpdatingElement);
10637
10665
 
10638
- export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, UpdatingElement, authenticate, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getHistory, getRuntime, handleHttpError, httpErrorToString, i18nText, initI18n, isLoggedIn, logout, looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useRecentApps };
10666
+ export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, StoryboardFunctionRegistryFactory, UpdatingElement, authenticate, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getHistory, getRuntime, handleHttpError, httpErrorToString, i18nText, initI18n, isLoggedIn, logout, looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useRecentApps };
10639
10667
  //# sourceMappingURL=index.esm.js.map