@next-core/brick-kit 2.71.0 → 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
@@ -2302,58 +2302,77 @@ function i18nText(data) {
2302
2302
  }
2303
2303
  }
2304
2304
 
2305
- var registeredFunctions = new Map();
2306
- // Use `Proxy` with a frozen target, to make a readonly function registry.
2307
- var storyboardFunctions = new Proxy(Object.freeze({}), {
2308
- get(target, key) {
2309
- 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
+ }
2310
2329
  }
2311
2330
 
2312
- });
2313
- function registerStoryboardFunctions(storyboard) {
2314
- var _storyboard$meta;
2331
+ function getStoryboardFunction(name) {
2332
+ var fn = registeredFunctions.get(name);
2315
2333
 
2316
- registeredFunctions.clear();
2334
+ if (!fn) {
2335
+ return undefined;
2336
+ }
2317
2337
 
2318
- if (Array.isArray((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions)) {
2319
- for (var fn of storyboard.meta.functions) {
2320
- registeredFunctions.set(fn.name, {
2321
- source: fn.source,
2338
+ if (!fn.processed) {
2339
+ var precooked = precookFunction(fn.source, {
2322
2340
  typescript: fn.typescript
2323
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;
2324
2352
  }
2325
- }
2326
- }
2327
- function getStoryboardFunctions() {
2328
- return storyboardFunctions;
2329
- }
2330
-
2331
- function getStoryboardFunction(name) {
2332
- var fn = registeredFunctions.get(name);
2333
2353
 
2334
- if (!fn) {
2335
- throw new ReferenceError("Function not found: ".concat(name));
2354
+ return fn.cooked;
2336
2355
  }
2337
2356
 
2338
- if (!fn.processed) {
2339
- var precooked = precookFunction(fn.source, {
2340
- typescript: fn.typescript
2357
+ function updateStoryboardFunction(name, data) {
2358
+ registeredFunctions.set(name, {
2359
+ source: data.source,
2360
+ typescript: data.typescript
2341
2361
  });
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;
2352
2362
  }
2353
2363
 
2354
- return fn.cooked;
2364
+ return {
2365
+ storyboardFunctions,
2366
+ registerStoryboardFunctions,
2367
+ updateStoryboardFunction
2368
+ };
2355
2369
  }
2356
2370
 
2371
+ var {
2372
+ storyboardFunctions,
2373
+ registerStoryboardFunctions
2374
+ } = StoryboardFunctionRegistryFactory();
2375
+
2357
2376
  var symbolForRaw = Symbol.for("pre.evaluated.raw");
2358
2377
  var symbolForContext = Symbol.for("pre.evaluated.context");
2359
2378
  function isPreEvaluated(raw) {
@@ -2569,7 +2588,7 @@ runtimeContext = {}, options = {}) {
2569
2588
  }
2570
2589
 
2571
2590
  if (attemptToVisitGlobals.has("FN")) {
2572
- globalVariables.FN = getStoryboardFunctions();
2591
+ globalVariables.FN = storyboardFunctions;
2573
2592
  }
2574
2593
 
2575
2594
  try {
@@ -8567,6 +8586,8 @@ class Router {
8567
8586
  var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
8568
8587
 
8569
8588
  if (storyboard) {
8589
+ var _storyboard$meta;
8590
+
8570
8591
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
8571
8592
 
8572
8593
  restoreDynamicTemplates(storyboard); // 预加载权限信息
@@ -8582,7 +8603,7 @@ class Router {
8582
8603
 
8583
8604
  _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
8584
8605
 
8585
- registerStoryboardFunctions(storyboard);
8606
+ registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions);
8586
8607
  }
8587
8608
 
8588
8609
  var {
@@ -10642,5 +10663,5 @@ var ModalElement = _decorate(null, function (_initialize, _UpdatingElement) {
10642
10663
  };
10643
10664
  }, UpdatingElement);
10644
10665
 
10645
- 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 };
10646
10667
  //# sourceMappingURL=index.esm.js.map