@next-core/brick-kit 2.173.2 → 2.174.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
@@ -4,7 +4,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
4
4
  import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
5
5
  import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
6
6
  import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
7
- import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, isTrackAll, trackAll, trackContext, trackState, trackFormState, transformAndInject, transform, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, deepFreeze, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript as loadScript$1, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
7
+ import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, isTrackAll, trackAll, trackContext, trackState, trackFormState, transformAndInject, transform, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, deepFreeze, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, snippetEvaluate, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript as loadScript$1, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
8
8
  import React, { useState, useEffect, useRef, useMemo, useCallback, forwardRef, useImperativeHandle, useContext, createContext, useReducer } from 'react';
9
9
  import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
10
10
  import { Modal, message, Empty, ConfigProvider } from 'antd';
@@ -2738,7 +2738,7 @@ function setupTemplateProxy(proxyContext, ref, slots) {
2738
2738
  };
2739
2739
  }
2740
2740
 
2741
- var _excluded$7 = ["properties", "slots"];
2741
+ var _excluded$8 = ["properties", "slots"];
2742
2742
  function setupUseBrickInTemplate(props, proxyContext) {
2743
2743
  function walk(props) {
2744
2744
  if (Array.isArray(props)) {
@@ -2757,7 +2757,7 @@ function setupUseBrickInTemplate(props, proxyContext) {
2757
2757
  properties,
2758
2758
  slots: originalSlots
2759
2759
  } = item,
2760
- restConf = _objectWithoutProperties(item, _excluded$7);
2760
+ restConf = _objectWithoutProperties(item, _excluded$8);
2761
2761
  var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
2762
2762
  var _slotConf$bricks;
2763
2763
  var [slotName, slotConf] = _ref2;
@@ -2901,7 +2901,7 @@ function getNextInternalOptions(internalOptions, isArray, key) {
2901
2901
  }) : internalOptions;
2902
2902
  }
2903
2903
 
2904
- var _excluded$6 = ["children"],
2904
+ var _excluded$7 = ["children"],
2905
2905
  _excluded2$2 = ["children"],
2906
2906
  _excluded3 = ["items", "app"];
2907
2907
  var symbolAppId = Symbol("appId");
@@ -3168,7 +3168,7 @@ function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
3168
3168
  var {
3169
3169
  children
3170
3170
  } = _ref,
3171
- rest = _objectWithoutProperties(_ref, _excluded$6);
3171
+ rest = _objectWithoutProperties(_ref, _excluded$7);
3172
3172
  var overrideAppId = rest[symbolAppId];
3173
3173
  if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
3174
3174
  appIds.add(overrideAppId);
@@ -3455,8 +3455,8 @@ function _dev_only_updateTemplatePreviewSettings(appId, templateId, settings) {
3455
3455
  }
3456
3456
 
3457
3457
  /* istanbul ignore next */
3458
- function _dev_only_updateSnippetPreviewSettings(appId, snippetData) {
3459
- kernel._dev_only_updateSnippetPreviewSettings(appId, snippetData);
3458
+ function _dev_only_updateSnippetPreviewSettings(appId, snippetData, settings) {
3459
+ kernel._dev_only_updateSnippetPreviewSettings(appId, snippetData, settings);
3460
3460
  }
3461
3461
 
3462
3462
  /* istanbul ignore next */
@@ -3466,8 +3466,10 @@ function _dev_only_updateStoryboardByRoute(appId, newRoute) {
3466
3466
  function _dev_only_updateStoryboardByTemplate(appId, newTemplate, settings) {
3467
3467
  kernel._dev_only_updateStoryboardByTemplate(appId, newTemplate, settings);
3468
3468
  }
3469
- function _dev_only_updateStoryboardBySnippet(appId, newSnippet) {
3470
- kernel._dev_only_updateStoryboardBySnippet(appId, newSnippet);
3469
+
3470
+ /* istanbul ignore next */
3471
+ function _dev_only_updateStoryboardBySnippet(appId, newSnippet, settings) {
3472
+ kernel._dev_only_updateStoryboardBySnippet(appId, newSnippet, settings);
3471
3473
  }
3472
3474
 
3473
3475
  /* istanbul ignore next */
@@ -3823,7 +3825,7 @@ function _internalApiLoadDynamicBricksInBrickConf(brickConf) {
3823
3825
  return kernel.loadDynamicBricksInBrickConf(brickConf);
3824
3826
  }
3825
3827
 
3826
- var _excluded$5 = ["extraQuery", "clear", "keepHash"];
3828
+ var _excluded$6 = ["extraQuery", "clear", "keepHash"];
3827
3829
  var blocked = false;
3828
3830
  function getUserConfirmation(message, callback) {
3829
3831
  blocked = !confirm(message);
@@ -3853,7 +3855,7 @@ function historyExtended(browserHistory) {
3853
3855
  clear,
3854
3856
  keepHash
3855
3857
  } = options,
3856
- state = _objectWithoutProperties(options, _excluded$5);
3858
+ state = _objectWithoutProperties(options, _excluded$6);
3857
3859
  var urlSearchParams = new URLSearchParams(clear ? "" : browserHistory.location.search);
3858
3860
  var params = {};
3859
3861
  Object.assign(params, query, extraQuery);
@@ -7290,7 +7292,7 @@ var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
7290
7292
  };
7291
7293
  }();
7292
7294
 
7293
- var _excluded$4 = ["feature_flags"],
7295
+ var _excluded$5 = ["feature_flags"],
7294
7296
  _excluded2$1 = ["featureFlags", "misc"];
7295
7297
  function standaloneBootstrap() {
7296
7298
  return _standaloneBootstrap.apply(this, arguments);
@@ -7336,7 +7338,7 @@ function _standaloneBootstrap() {
7336
7338
  var {
7337
7339
  feature_flags: featureFlags
7338
7340
  } = sys_settings,
7339
- rest = _objectWithoutProperties(sys_settings, _excluded$4);
7341
+ rest = _objectWithoutProperties(sys_settings, _excluded$5);
7340
7342
  settings = _objectSpread({
7341
7343
  featureFlags
7342
7344
  }, rest);
@@ -8349,7 +8351,7 @@ function collectMergeBases(conf, mergeBases, contextInTemplate, refToBrickConf)
8349
8351
  }
8350
8352
  }
8351
8353
 
8352
- var _excluded$3 = ["properties", "slots"],
8354
+ var _excluded$4 = ["properties", "slots"],
8353
8355
  _excluded2 = ["ref", "slots"];
8354
8356
  function expandCustomTemplate(brickConf, proxyBrick, context) {
8355
8357
  var tplContext = new CustomTemplateContext(proxyBrick);
@@ -8393,7 +8395,7 @@ function lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context,
8393
8395
  properties: templateProperties,
8394
8396
  slots: externalSlots
8395
8397
  } = brickConf,
8396
- restBrickConf = _objectWithoutProperties(brickConf, _excluded$3);
8398
+ restBrickConf = _objectWithoutProperties(brickConf, _excluded$4);
8397
8399
  var newBrickConf = restBrickConf;
8398
8400
 
8399
8401
  // Get a copy of proxy for each instance of custom template.
@@ -8809,6 +8811,7 @@ function getRuntimeMisc() {
8809
8811
  return misc;
8810
8812
  }
8811
8813
 
8814
+ var _excluded$3 = ["params"];
8812
8815
  class Kernel {
8813
8816
  constructor() {
8814
8817
  var _this = this;
@@ -9096,8 +9099,18 @@ class Kernel {
9096
9099
  }
9097
9100
  postProcessStoryboard(storyboard) {
9098
9101
  storyboard.app.$$routeAliasMap = scanRouteAliasInStoryboard(storyboard);
9102
+ this.postProcessStoryboardImgSrc(storyboard);
9099
9103
  this.postProcessStoryboardI18n(storyboard);
9100
9104
  }
9105
+ postProcessStoryboardImgSrc(storyboard) {
9106
+ var _storyboard$app$menuI;
9107
+ if (storyboard.app.menuIcon && "imgSrc" in storyboard.app.menuIcon && (_storyboard$app$menuI = storyboard.app.menuIcon.imgSrc) !== null && _storyboard$app$menuI !== void 0 && _storyboard$app$menuI.startsWith("api/")) {
9108
+ var splittedImgSrc = storyboard.app.menuIcon.imgSrc.split("/");
9109
+ var imgSrc = splittedImgSrc[splittedImgSrc.length - 1];
9110
+ var result = imagesFactory(storyboard.app.id, storyboard.app.isBuildPush, storyboard.app.currentVersion).get(imgSrc);
9111
+ storyboard.app.menuIcon.imgSrc = result;
9112
+ }
9113
+ }
9101
9114
  postProcessStoryboardI18n(storyboard) {
9102
9115
  var _storyboard$meta;
9103
9116
  if ((_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 && _storyboard$meta.i18n) {
@@ -9192,27 +9205,42 @@ class Kernel {
9192
9205
  routes.splice(previewRouteIndex, 1, newPreviewRoute);
9193
9206
  }
9194
9207
  }
9195
- _dev_only_updateSnippetPreviewSettings(appId, snippetData) {
9196
- var _snippetData$bricks;
9208
+ _dev_only_updateSnippetPreviewSettings(appId, snippetData, settings) {
9197
9209
  var {
9198
9210
  routes,
9199
9211
  app
9200
9212
  } = this.bootstrapData.storyboards.find(item => item.app.id === appId);
9201
9213
  var previewPath = "${APP.homepage}/_dev_only_/snippet-preview/".concat(snippetData.snippetId);
9202
9214
  var previewRouteIndex = routes.findIndex(route => route.path === previewPath);
9203
- var newPreviewRoute = {
9204
- path: previewPath,
9205
- bricks: ((_snippetData$bricks = snippetData.bricks) === null || _snippetData$bricks === void 0 ? void 0 : _snippetData$bricks.length) > 0 ? snippetData.bricks : [{
9206
- brick: "span"
9207
- }],
9208
- menu: false,
9209
- exact: true,
9210
- hybrid: app.legacy === "iframe"
9211
- };
9212
- if (previewRouteIndex === -1) {
9213
- routes.unshift(newPreviewRoute);
9214
- } else {
9215
- routes.splice(previewRouteIndex, 1, newPreviewRoute);
9215
+ try {
9216
+ var _parsedSnippetData$br;
9217
+ var {
9218
+ params: declareParams
9219
+ } = snippetData,
9220
+ nodeData = _objectWithoutProperties(snippetData, _excluded$3);
9221
+ var parsedSnippetData = snippetEvaluate(nodeData, {
9222
+ rootType: "route",
9223
+ inputParams: settings === null || settings === void 0 ? void 0 : settings.params,
9224
+ declareParams
9225
+ });
9226
+ var newPreviewRoute = {
9227
+ path: previewPath,
9228
+ bricks: ((_parsedSnippetData$br = parsedSnippetData.bricks) === null || _parsedSnippetData$br === void 0 ? void 0 : _parsedSnippetData$br.length) > 0 ? parsedSnippetData.bricks : [{
9229
+ brick: "span"
9230
+ }],
9231
+ menu: false,
9232
+ exact: true,
9233
+ hybrid: app.legacy === "iframe",
9234
+ context: parsedSnippetData.data || []
9235
+ };
9236
+ if (previewRouteIndex === -1) {
9237
+ routes.unshift(newPreviewRoute);
9238
+ } else {
9239
+ routes.splice(previewRouteIndex, 1, newPreviewRoute);
9240
+ }
9241
+ } catch (error) {
9242
+ // eslint-disable-next-line no-console
9243
+ throw new Error(error);
9216
9244
  }
9217
9245
  }
9218
9246
  _dev_only_updateStoryboardByRoute(appId, newRoute) {
@@ -9248,8 +9276,8 @@ class Kernel {
9248
9276
  }, appId);
9249
9277
  this._dev_only_updateTemplatePreviewSettings(appId, newTemplate.name, settings);
9250
9278
  }
9251
- _dev_only_updateStoryboardBySnippet(appId, newSnippet) {
9252
- this._dev_only_updateSnippetPreviewSettings(appId, newSnippet);
9279
+ _dev_only_updateStoryboardBySnippet(appId, newSnippet, settings) {
9280
+ this._dev_only_updateSnippetPreviewSettings(appId, newSnippet, settings);
9253
9281
  }
9254
9282
  _dev_only_updateFormPreviewSettings(appId, formId, formData) {
9255
9283
  var {