@next-core/brick-kit 2.178.4 → 2.178.5

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('history'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/asyncToGenerator'), require('lodash'), require('@next-core/brick-utils'), require('react'), require('@next-core/brick-http'), require('antd'), require('@ant-design/icons'), require('i18next'), require('moment'), require('@next-core/pipes'), require('@next-core/easyops-analytics'), require('js-yaml'), require('react-i18next'), require('@babel/runtime/helpers/esm/extends'), require('@next-core/illustrations'), require('@babel/runtime/helpers/decorate')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'history', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/defineProperty', '@babel/runtime/helpers/asyncToGenerator', 'lodash', '@next-core/brick-utils', 'react', '@next-core/brick-http', 'antd', '@ant-design/icons', 'i18next', 'moment', '@next-core/pipes', '@next-core/easyops-analytics', 'js-yaml', 'react-i18next', '@babel/runtime/helpers/esm/extends', '@next-core/illustrations', '@babel/runtime/helpers/decorate'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._defineProperty$1, global._asyncToGenerator$3, global._, global.brickUtils, global.React, global.brickHttp, global.antd, global.icons, global.i18next, global.moment, global.pipes, global.easyopsAnalytics, global.yaml, global.reactI18next, global._extends, global.illustrations, global._decorate));
5
- })(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _defineProperty$1, _asyncToGenerator$3, _, brickUtils, React, brickHttp, antd, icons, i18next, moment, pipes, easyopsAnalytics, yaml, reactI18next, _extends, illustrations, _decorate) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('history'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/asyncToGenerator'), require('lodash'), require('@next-core/brick-utils'), require('react'), require('@next-core/brick-http'), require('antd'), require('@ant-design/icons'), require('i18next'), require('moment'), require('@next-core/pipes'), require('@next-core/easyops-analytics'), require('js-yaml'), require('@next-core/loader'), require('react-i18next'), require('@babel/runtime/helpers/esm/extends'), require('@next-core/illustrations'), require('@babel/runtime/helpers/decorate')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'history', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/defineProperty', '@babel/runtime/helpers/asyncToGenerator', 'lodash', '@next-core/brick-utils', 'react', '@next-core/brick-http', 'antd', '@ant-design/icons', 'i18next', 'moment', '@next-core/pipes', '@next-core/easyops-analytics', 'js-yaml', '@next-core/loader', 'react-i18next', '@babel/runtime/helpers/esm/extends', '@next-core/illustrations', '@babel/runtime/helpers/decorate'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._defineProperty$1, global._asyncToGenerator$3, global._, global.brickUtils, global.React, global.brickHttp, global.antd, global.icons, global.i18next, global.moment, global.pipes, global.easyopsAnalytics, global.yaml, global.loader, global.reactI18next, global._extends, global.illustrations, global._decorate));
5
+ })(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _defineProperty$1, _asyncToGenerator$3, _, brickUtils, React, brickHttp, antd, icons, i18next, moment, pipes, easyopsAnalytics, yaml, loader, reactI18next, _extends, illustrations, _decorate) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -6883,267 +6883,6 @@
6883
6883
  };
6884
6884
  }();
6885
6885
 
6886
- var cache$1 = new Map();
6887
- function loadScript(src, prefix) {
6888
- if (Array.isArray(src)) {
6889
- return Promise.all(src.map(item => loadScript(item, prefix)));
6890
- }
6891
- var fixedSrc = prefix ? "".concat(prefix).concat(src) : src;
6892
- var cachedPromise = cache$1.get(fixedSrc);
6893
- if (cachedPromise) {
6894
- return cachedPromise;
6895
- }
6896
- var promise = new Promise((resolve, reject) => {
6897
- var end = () => {
6898
- window.dispatchEvent(new Event("request.end"));
6899
- };
6900
- var script = document.createElement("script");
6901
- script.src = fixedSrc;
6902
- script.type = "text/javascript";
6903
- script.async = true;
6904
- script.onload = () => {
6905
- resolve(fixedSrc);
6906
- end();
6907
- };
6908
- script.onerror = e => {
6909
- reject(e);
6910
- end();
6911
- };
6912
- var firstScript = document.currentScript || document.getElementsByTagName("script")[0];
6913
- firstScript.parentNode.insertBefore(script, firstScript);
6914
- window.dispatchEvent(new Event("request.start"));
6915
- });
6916
- cache$1.set(fixedSrc, promise);
6917
- return promise;
6918
- }
6919
-
6920
- // https://github.com/module-federation/module-federation-examples/blob/eda9493f3991a423479fd834cfb1d7b241d9d1f0/advanced-api/dynamic-remotes/app1/src/App.js
6921
- function loadSharedModule(_x, _x2) {
6922
- return _loadSharedModule.apply(this, arguments);
6923
- }
6924
- function _loadSharedModule() {
6925
- _loadSharedModule = _asyncToGenerator__default["default"](function* (scope, module) {
6926
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
6927
- yield __webpack_init_sharing__("default");
6928
- var container = window[scope]; // or get the container somewhere else
6929
- // Initialize the container, it may provide shared modules
6930
- yield container.init(__webpack_share_scopes__.default);
6931
- var factory = yield container.get(module);
6932
- return factory();
6933
- });
6934
- return _loadSharedModule.apply(this, arguments);
6935
- }
6936
-
6937
- var resolveBasicPkg;
6938
- var basicPkgWillBeResolved = false;
6939
- var waitBasicPkg = new Promise(resolve => {
6940
- resolveBasicPkg = resolve;
6941
- });
6942
- function flushStableLoadBricks() {
6943
- if (!basicPkgWillBeResolved) {
6944
- resolveBasicPkg();
6945
- }
6946
- }
6947
- function loadBricksImperatively(_x, _x2) {
6948
- return _loadBricksImperatively.apply(this, arguments);
6949
- }
6950
- function _loadBricksImperatively() {
6951
- _loadBricksImperatively = _asyncToGenerator__default["default"](function* (bricks, brickPackages) {
6952
- var promise = enqueueStableLoad("bricks", bricks, brickPackages);
6953
- flushStableLoadBricks();
6954
- return dispatchRequestStatus(promise);
6955
- });
6956
- return _loadBricksImperatively.apply(this, arguments);
6957
- }
6958
- function loadProcessorsImperatively(processors, brickPackages) {
6959
- var promise = enqueueStableLoad("processors", processors, brickPackages);
6960
- flushStableLoadBricks();
6961
- return dispatchRequestStatus(promise);
6962
- }
6963
- var v2AdapterPromise;
6964
- var V2_ADAPTER_LOAD_BRICKS = "v2-adapter.load-bricks";
6965
-
6966
- // Get brick/processor items including their dependencies
6967
- function getItemsByPkg(type, list, brickPackagesMap) {
6968
- var itemsByPkg = new Map();
6969
- var listToLoad = new Set();
6970
- var add = item => {
6971
- var _pkg$dependencies;
6972
- if (listToLoad.has(item)) {
6973
- return;
6974
- }
6975
- listToLoad.add(item);
6976
- var pkg;
6977
- var namespace;
6978
- var itemName;
6979
- if (type === "processors" || item.includes(".")) {
6980
- [namespace, itemName] = item.split(".");
6981
- var pkgId = "bricks/".concat(type === "processors" ? getProcessorPackageName(namespace) : namespace);
6982
- pkg = brickPackagesMap.get(pkgId);
6983
- } else {
6984
- itemName = item;
6985
- for (var p of brickPackagesMap.values()) {
6986
- var _p$elements;
6987
- if ((_p$elements = p.elements) !== null && _p$elements !== void 0 && _p$elements.some(e => e === itemName)) {
6988
- pkg = p;
6989
- break;
6990
- }
6991
- }
6992
- }
6993
- if (!pkg) {
6994
- throw new Error("Package for ".concat(item, " not found."));
6995
- }
6996
- var groupItems = itemsByPkg.get(pkg);
6997
- if (!groupItems) {
6998
- groupItems = [];
6999
- itemsByPkg.set(pkg, groupItems);
7000
- }
7001
- groupItems.push(itemName);
7002
-
7003
- // Load their dependencies too
7004
- var deps = (_pkg$dependencies = pkg.dependencies) === null || _pkg$dependencies === void 0 ? void 0 : _pkg$dependencies[item];
7005
- if (deps) {
7006
- for (var dep of deps) {
7007
- add(dep);
7008
- }
7009
- }
7010
- };
7011
- for (var item of list) {
7012
- add(item);
7013
- }
7014
- return itemsByPkg;
7015
- }
7016
- function loadBrickModule(_x3, _x4, _x5) {
7017
- return _loadBrickModule.apply(this, arguments);
7018
- }
7019
- function _loadBrickModule() {
7020
- _loadBrickModule = _asyncToGenerator__default["default"](function* (type, pkgId, itemName) {
7021
- var moduleName = "".concat(type === "processors" ? "./processors/" : "./").concat(itemName);
7022
- try {
7023
- yield loadSharedModule(pkgId, moduleName);
7024
- } catch (error) {
7025
- // eslint-disable-next-line no-console
7026
- console.error(error);
7027
- throw new Error("Load ".concat(type, " of \"").concat(pkgId.split("/").pop(), ".").concat(moduleName.split("/").pop(), "\" failed"));
7028
- }
7029
- });
7030
- return _loadBrickModule.apply(this, arguments);
7031
- }
7032
- function loadRestBricks(type, pkgs, itemsMap) {
7033
- return pkgs.map( /*#__PURE__*/function () {
7034
- var _ref = _asyncToGenerator__default["default"](function* (pkg) {
7035
- var _window$PUBLIC_ROOT;
7036
- yield loadScript(pkg.filePath, (_window$PUBLIC_ROOT = window.PUBLIC_ROOT) !== null && _window$PUBLIC_ROOT !== void 0 ? _window$PUBLIC_ROOT : "");
7037
- yield waitBasicPkg;
7038
- return Promise.all(
7039
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7040
- itemsMap.get(pkg).map(itemName => loadBrickModule(type, pkg.id, itemName)));
7041
- });
7042
- return function (_x6) {
7043
- return _ref.apply(this, arguments);
7044
- };
7045
- }());
7046
- }
7047
- function enqueueStableLoad(_x7, _x8, _x9) {
7048
- return _enqueueStableLoad.apply(this, arguments);
7049
- }
7050
- function _enqueueStableLoad() {
7051
- _enqueueStableLoad = _asyncToGenerator__default["default"](function* (type, list, brickPackages) {
7052
- var brickPackagesMap = new Map();
7053
- for (var pkg of brickPackages) {
7054
- var _pkg$id;
7055
- var pkgId = (_pkg$id = pkg.id) !== null && _pkg$id !== void 0 ? _pkg$id : getPkgIdByFilePath(pkg.filePath);
7056
- brickPackagesMap.set(pkgId, pkg);
7057
- }
7058
- var itemsByPkg = getItemsByPkg(type, list, brickPackagesMap);
7059
- var foundBasicPkg;
7060
- var v2Packages = [];
7061
- var v3PackagesOtherThanBasic = [];
7062
- var maybeV2Adapter;
7063
- for (var _pkg of itemsByPkg.keys()) {
7064
- if (_pkg.id) {
7065
- if (_pkg.id === "bricks/basic") {
7066
- foundBasicPkg = _pkg;
7067
- } else {
7068
- v3PackagesOtherThanBasic.push(_pkg);
7069
- }
7070
- } else {
7071
- // Brick packages of v2 has no `id`
7072
- v2Packages.push(_pkg);
7073
- maybeV2Adapter = brickPackagesMap.get("bricks/v2-adapter");
7074
- if (!maybeV2Adapter) {
7075
- // eslint-disable-next-line no-console
7076
- console.error("Using v2 bricks, but v2-adapter not found");
7077
- }
7078
- }
7079
- }
7080
- var v2Adapter = maybeV2Adapter;
7081
- var basicPkgPromise;
7082
- var basicPkg = foundBasicPkg;
7083
- if (basicPkg) {
7084
- var _window$PUBLIC_ROOT2;
7085
- var tempPromise = loadScript(basicPkg.filePath, (_window$PUBLIC_ROOT2 = window.PUBLIC_ROOT) !== null && _window$PUBLIC_ROOT2 !== void 0 ? _window$PUBLIC_ROOT2 : "");
7086
- // Packages other than BASIC will wait for an extra micro-task tick.
7087
- if (!basicPkgWillBeResolved) {
7088
- basicPkgWillBeResolved = true;
7089
- tempPromise.then(() => Promise.resolve()).then(resolveBasicPkg);
7090
- }
7091
- basicPkgPromise = tempPromise.then(() => Promise.all(
7092
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7093
- itemsByPkg.get(basicPkg).map(itemName => loadBrickModule(type, basicPkg.id, itemName))));
7094
- }
7095
- var pkgPromises = [basicPkgPromise].concat(loadRestBricks(type, v3PackagesOtherThanBasic, itemsByPkg));
7096
- if (v2Adapter && v2Packages.length > 0) {
7097
- if (!v2AdapterPromise) {
7098
- // Load `v2-adapter.load-bricks` and its dependencies
7099
- var v2AdapterItemsByPkg = getItemsByPkg("bricks", [V2_ADAPTER_LOAD_BRICKS], brickPackagesMap);
7100
- var v2AdapterPackages = [...v2AdapterItemsByPkg.keys()];
7101
- var loadV2Adapter = /*#__PURE__*/function () {
7102
- var _ref2 = _asyncToGenerator__default["default"](function* () {
7103
- yield Promise.all(loadRestBricks("bricks", v2AdapterPackages, v2AdapterItemsByPkg));
7104
- return document.createElement(V2_ADAPTER_LOAD_BRICKS);
7105
- });
7106
- return function loadV2Adapter() {
7107
- return _ref2.apply(this, arguments);
7108
- };
7109
- }();
7110
- v2AdapterPromise = loadV2Adapter();
7111
- }
7112
- pkgPromises.push(v2AdapterPromise.then(adapter => Promise.all(v2Packages.map(pkg => {
7113
- var pkgId = getPkgIdByFilePath(pkg.filePath);
7114
- var pkgNamespace = pkgId.split("/")[1];
7115
- return adapter.resolve(v2Adapter.filePath, pkg.filePath, type === "bricks" ?
7116
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7117
- itemsByPkg.get(pkg).map(itemName => "".concat(pkgNamespace, ".").concat(itemName)) : [], pkg.dll,
7118
- // Todo: remove `brickPackages` as an argument
7119
- brickPackages);
7120
- }))));
7121
- }
7122
- yield Promise.all(pkgPromises);
7123
- });
7124
- return _enqueueStableLoad.apply(this, arguments);
7125
- }
7126
- function dispatchRequestStatus(_x10) {
7127
- return _dispatchRequestStatus.apply(this, arguments);
7128
- }
7129
- function _dispatchRequestStatus() {
7130
- _dispatchRequestStatus = _asyncToGenerator__default["default"](function* (promise) {
7131
- window.dispatchEvent(new Event("request.start"));
7132
- try {
7133
- yield promise;
7134
- } finally {
7135
- window.dispatchEvent(new Event("request.end"));
7136
- }
7137
- });
7138
- return _dispatchRequestStatus.apply(this, arguments);
7139
- }
7140
- function getProcessorPackageName(camelPackageName) {
7141
- return camelPackageName.replace(/[A-Z]/g, match => "-".concat(match[0].toLocaleLowerCase())).replace(/_[0-9]/g, match => "-".concat(match[1]));
7142
- }
7143
- function getPkgIdByFilePath(filePath) {
7144
- return filePath.split("/").slice(0, 2).join("/");
7145
- }
7146
-
7147
6886
  /**
7148
6887
  * Merge `app.defaultConfig` and `app.userConfig` to `app.config`.
7149
6888
  *
@@ -8931,13 +8670,13 @@
8931
8670
  yield loadScriptOfDll(eager.dll);
8932
8671
  yield loadScriptOfBricksOrTemplates(eager.deps);
8933
8672
  if ((_eager$v3Bricks = eager.v3Bricks) !== null && _eager$v3Bricks !== void 0 && _eager$v3Bricks.length) {
8934
- yield loadBricksImperatively(eager.v3Bricks, brickPackages);
8673
+ yield loader.loadBricksImperatively(eager.v3Bricks, brickPackages);
8935
8674
  }
8936
8675
  // 加载构件资源时,不再阻塞后续业务数据的加载,在挂载构件时再等待该任务完成。
8937
8676
  // 挂载构件可能包括:Provider 构件实时挂载、路由准备完成后的统一挂载等。
8938
8677
  return {
8939
8678
  pendingTask: loadScriptOfDll(dll).then(() => loadScriptOfBricksOrTemplates(deps)).then( /*#__PURE__*/_asyncToGenerator__default["default"](function* () {
8940
- yield Promise.all([loadLazyBricks(bricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loadProcessorsImperatively(v3Processors, brickPackages)]);
8679
+ yield Promise.all([loadLazyBricks(bricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loader.loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loader.loadProcessorsImperatively(v3Processors, brickPackages)]);
8941
8680
  }))
8942
8681
  };
8943
8682
  }
@@ -8966,7 +8705,7 @@
8966
8705
  }, _this.bootstrapData.brickPackages);
8967
8706
  yield loadScriptOfDll(dll);
8968
8707
  yield loadScriptOfBricksOrTemplates(deps);
8969
- yield Promise.all([loadLazyBricks(filteredBricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loadProcessorsImperatively(v3Processors, brickPackages)]);
8708
+ yield Promise.all([loadLazyBricks(filteredBricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loader.loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loader.loadProcessorsImperatively(v3Processors, brickPackages)]);
8970
8709
  });
8971
8710
  return function (_x2, _x3) {
8972
8711
  return _ref3.apply(this, arguments);