@next-core/brick-kit 2.191.1 → 2.193.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.bundle.js +2005 -1974
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +1967 -1936
- package/dist/index.esm.js.map +1 -1
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/core/Runtime.d.ts +2 -1
- package/dist/types/core/Runtime.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +5 -1
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/developHelper.d.ts +2 -1
- package/dist/types/developHelper.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.bundle.js
CHANGED
|
@@ -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('
|
|
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', '
|
|
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.
|
|
5
|
-
})(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _defineProperty$1, _asyncToGenerator$3, _, brickUtils,
|
|
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('moment'), require('@next-core/pipes'), require('i18next'), require('react'), require('@next-core/brick-http'), require('@next-core/easyops-analytics'), require('antd'), require('@ant-design/icons'), 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', 'moment', '@next-core/pipes', 'i18next', 'react', '@next-core/brick-http', '@next-core/easyops-analytics', 'antd', '@ant-design/icons', '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.moment, global.pipes, global.i18next, global.React, global.brickHttp, global.easyopsAnalytics, global.antd, global.icons, 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, moment, pipes, i18next, React, brickHttp, easyopsAnalytics, antd, icons, 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
|
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty$1);
|
|
12
12
|
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator$3);
|
|
13
13
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
14
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
|
-
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
16
14
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
15
|
+
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
16
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
17
|
var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
|
|
18
18
|
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
19
19
|
var _decorate__default = /*#__PURE__*/_interopDefaultLegacy(_decorate);
|
|
@@ -289,658 +289,391 @@
|
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
292
|
+
function supply(attemptToVisitGlobals, providedGlobalVariables, mock) {
|
|
293
|
+
var globalVariables = _objectSpread__default["default"]({}, providedGlobalVariables);
|
|
294
|
+
// Allow limited browser builtin values.
|
|
295
|
+
globalVariables["undefined"] = undefined;
|
|
296
|
+
for (var variableName of attemptToVisitGlobals) {
|
|
297
|
+
if (!Object.prototype.hasOwnProperty.call(globalVariables, variableName)) {
|
|
298
|
+
var variable = supplyIndividual(variableName, mock);
|
|
299
|
+
if (variable !== undefined) {
|
|
300
|
+
globalVariables[variableName] = variable;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
298
303
|
}
|
|
299
|
-
|
|
304
|
+
return globalVariables;
|
|
300
305
|
}
|
|
306
|
+
var shouldOmitInLodash = new Set([
|
|
307
|
+
// Omit all mutable methods from lodash.
|
|
308
|
+
// But allow sequence methods like `_.chain`.
|
|
309
|
+
"fill", "pull", "pullAll", "pullAllBy", "pullAllWith", "pullAt", "remove", "reverse", "assign", "assignIn", "assignInWith", "assignWith", "defaults", "defaultsDeep", "merge", "mergeWith", "set", "setWith", "unset", "update", "updateWith",
|
|
310
|
+
/**
|
|
311
|
+
* Ignore `Function` methods from lodash, too.
|
|
312
|
+
* There are chances to invoke `Object.assign`, etc.
|
|
313
|
+
*
|
|
314
|
+
* E.g.:
|
|
315
|
+
*
|
|
316
|
+
* ```
|
|
317
|
+
* _.wrap(_.method('constructor.assign',{b:2},{b:3}),(func,...a) => func(...a))({})
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
"after", "ary", "before", "bind", "bindKey", "curry", "curryRight", "debounce", "defer", "delay", "flip", "memoize", "negate", "once", "overArgs", "partial", "partialRight", "rearg", "rest", "spread", "throttle", "unary", "wrap"]);
|
|
301
321
|
|
|
302
|
-
//
|
|
303
|
-
var
|
|
304
|
-
var
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
322
|
+
// Omit all mutable methods from moment.
|
|
323
|
+
var shouldOmitInMoment = new Set(["lang", "langData", "locale", "localeData", "defineLocale", "updateLocale", "updateOffset"]);
|
|
324
|
+
var allowedGlobalObjects = new Set(["Array", "Boolean", "Date", "Infinity", "JSON", "Math", "NaN", "Number", "String", "RegExp", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "isFinite", "isNaN", "parseFloat", "parseInt", "Map", "Set", "URLSearchParams", "WeakMap", "WeakSet", "atob", "btoa"]);
|
|
325
|
+
function supplyIndividual(variableName, mock) {
|
|
326
|
+
switch (variableName) {
|
|
327
|
+
case "Object":
|
|
328
|
+
// Do not allow mutable methods like `Object.assign`.
|
|
329
|
+
return delegateMethods(Object, ["entries", "fromEntries", "keys", "values"]);
|
|
330
|
+
case "_":
|
|
331
|
+
return Object.fromEntries(Object.entries(___default["default"]).filter(entry => !shouldOmitInLodash.has(entry[0])).concat(mock ? [["uniqueId", prefix => "".concat(prefix !== null && prefix !== void 0 ? prefix : "", "42")]] : []));
|
|
332
|
+
case "moment":
|
|
333
|
+
return Object.assign(function () {
|
|
334
|
+
return moment__default["default"](...arguments);
|
|
335
|
+
}, Object.fromEntries(Object.entries(moment__default["default"]).filter(entry => !shouldOmitInMoment.has(entry[0]))));
|
|
336
|
+
case "PIPES":
|
|
337
|
+
return pipes.pipes;
|
|
338
|
+
case "TAG_URL":
|
|
339
|
+
return tagUrlFactory(true);
|
|
340
|
+
case "SAFE_TAG_URL":
|
|
341
|
+
return tagUrlFactory();
|
|
342
|
+
default:
|
|
343
|
+
if (allowedGlobalObjects.has(variableName)) {
|
|
344
|
+
return window[variableName];
|
|
345
|
+
}
|
|
310
346
|
}
|
|
311
|
-
theme = value;
|
|
312
347
|
}
|
|
313
|
-
function
|
|
314
|
-
return
|
|
348
|
+
function delegateMethods(target, methods) {
|
|
349
|
+
return Object.fromEntries(methods.map(method => [method, function () {
|
|
350
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
351
|
+
args[_key] = arguments[_key];
|
|
352
|
+
}
|
|
353
|
+
return target[method].apply(target, args);
|
|
354
|
+
}]));
|
|
315
355
|
}
|
|
316
|
-
|
|
317
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Pass `ignoreSlashes` as `true` to encode all tagged expressions
|
|
358
|
+
* as URL components, except for `/` which maybe used in `APP.homepage`.
|
|
359
|
+
*
|
|
360
|
+
* Otherwise encode all tagged expressions as URL components.
|
|
361
|
+
* This will encode `/` as `%2F`. So do not use it directly
|
|
362
|
+
* with `APP.homepage` as in template expressions.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
*
|
|
366
|
+
* ```js
|
|
367
|
+
* TAG_URL`${APP.homepage}/list?q=${q}&redirect=${redirect}`
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* ```js
|
|
371
|
+
* SAFE_TAG_URL`file/${path}?q=${q}`
|
|
372
|
+
* // `path` will be fully transformed by `encodeURIComponent`.
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* ```js
|
|
376
|
+
* // Wrap `APP.homepage` outside of `SAFE_TAG_URL`.
|
|
377
|
+
* `${APP.homepage}/${SAFE_TAG_URL`file/${path}?q=${q}`}`
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
function tagUrlFactory(ignoreSlashes) {
|
|
381
|
+
return function (strings) {
|
|
382
|
+
for (var _len2 = arguments.length, partials = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
383
|
+
partials[_key2 - 1] = arguments[_key2];
|
|
384
|
+
}
|
|
385
|
+
var result = [];
|
|
386
|
+
strings.forEach((str, index) => {
|
|
387
|
+
result.push(str);
|
|
388
|
+
if (index < partials.length) {
|
|
389
|
+
result.push(ignoreSlashes ? String(partials[index]).replace(/[^/]+/g, p => encodeURIComponent(p)) : encodeURIComponent(String(partials[index])));
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
return result.join("");
|
|
393
|
+
};
|
|
318
394
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
395
|
+
|
|
396
|
+
function getUrlByAliasFactory(app) {
|
|
397
|
+
return function getUrlByAlias(alias, pathParams, query) {
|
|
398
|
+
if (!(app !== null && app !== void 0 && app.$$routeAliasMap.has(alias))) {
|
|
399
|
+
// eslint-disable-next-line no-console
|
|
400
|
+
throw new Error("Route alias not found: ".concat(alias));
|
|
401
|
+
}
|
|
402
|
+
var routeConf = app.$$routeAliasMap.get(alias);
|
|
403
|
+
var url = brickUtils.toPath(brickUtils.computeRealRoutePath(routeConf.path, app), pathParams);
|
|
404
|
+
if (query) {
|
|
405
|
+
var urlSearchParams = new URLSearchParams();
|
|
406
|
+
for (var [key, value] of Object.entries(query)) {
|
|
407
|
+
if (Array.isArray(value)) {
|
|
408
|
+
for (var item of value) {
|
|
409
|
+
urlSearchParams.append(key, item);
|
|
410
|
+
}
|
|
411
|
+
} else if (value !== undefined && value !== null && value !== "") {
|
|
412
|
+
urlSearchParams.set(key, value);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
var queryString = urlSearchParams.toString();
|
|
416
|
+
if (queryString.length > 0) {
|
|
417
|
+
url += "?".concat(queryString);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return url;
|
|
421
|
+
};
|
|
331
422
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}, []);
|
|
343
|
-
return currentTheme;
|
|
423
|
+
|
|
424
|
+
function getUrlBySegueFactory(app, segues) {
|
|
425
|
+
return function getUrlBySegue(segueId, pathParams, query) {
|
|
426
|
+
if (!brickUtils.hasOwnProperty(segues, segueId)) {
|
|
427
|
+
// eslint-disable-next-line no-console
|
|
428
|
+
throw new Error("Segue not found: ".concat(segueId));
|
|
429
|
+
}
|
|
430
|
+
var segue = segues[segueId];
|
|
431
|
+
return getUrlByAliasFactory(app)(segue.target, pathParams, query);
|
|
432
|
+
};
|
|
344
433
|
}
|
|
345
|
-
|
|
346
|
-
|
|
434
|
+
|
|
435
|
+
function imagesFactory(appId, isBuildPush, version) {
|
|
436
|
+
return {
|
|
437
|
+
get(name) {
|
|
438
|
+
var getSuffix = () => {
|
|
439
|
+
var suffix = window.APP_ROOT ? "".concat(window.APP_ROOT).concat(window.BOOTSTRAP_UNION_FILE && window.PUBLIC_DEPS ? "" : "-/") : "";
|
|
440
|
+
if (!suffix.startsWith("/")) {
|
|
441
|
+
suffix = getBasePath() + suffix;
|
|
442
|
+
}
|
|
443
|
+
if (window.APP_ID && window.APP_ID !== appId) {
|
|
444
|
+
return suffix.replace(new RegExp("(^|/)".concat(_.escapeRegExp(window.APP_ID), "/")), "$1".concat(appId, "/")).replace(/\/\d+\.\d+\.\d+\//, "/".concat(version, "/"));
|
|
445
|
+
}
|
|
446
|
+
return suffix;
|
|
447
|
+
};
|
|
448
|
+
return isBuildPush ? "".concat(getBasePath(), "api/gateway/object_store.object_store.GetObject/api/v1/objectStore/bucket/next-builder/object/").concat(name) : window.BOOTSTRAP_UNION_FILE && window.PUBLIC_DEPS ? "".concat(getSuffix(), "images/").concat(name) : "".concat(getSuffix(), "micro-apps/").concat(appId, "/images/").concat(name);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
347
451
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
return result || {};
|
|
452
|
+
function widgetImagesFactory(widgetId, widgetVersion) {
|
|
453
|
+
return {
|
|
454
|
+
get(name) {
|
|
455
|
+
var _window$PUBLIC_ROOT;
|
|
456
|
+
return "".concat((_window$PUBLIC_ROOT = window.PUBLIC_ROOT) !== null && _window$PUBLIC_ROOT !== void 0 ? _window$PUBLIC_ROOT : "", "bricks/").concat(widgetId, "/").concat(window.PUBLIC_ROOT_WITH_VERSION && widgetVersion ? "".concat(widgetVersion, "/") : "", "dist/assets/").concat(name);
|
|
457
|
+
}
|
|
458
|
+
};
|
|
357
459
|
}
|
|
358
460
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
461
|
+
var injected = new WeakSet();
|
|
462
|
+
|
|
463
|
+
// The injected (or transformed) result should never be *injected* again.
|
|
464
|
+
// So does the fetched data from a remote api.
|
|
465
|
+
function recursiveMarkAsInjected(value) {
|
|
466
|
+
if (brickUtils.isObject(value)) {
|
|
467
|
+
if (!haveBeenInjected(value)) {
|
|
468
|
+
injected.add(value);
|
|
469
|
+
if (Array.isArray(value)) {
|
|
470
|
+
value.forEach(recursiveMarkAsInjected);
|
|
471
|
+
} else {
|
|
472
|
+
// Only mark pure objects.
|
|
473
|
+
var proto = Object.getPrototypeOf(value);
|
|
474
|
+
if (!proto || proto.constructor === Object) {
|
|
475
|
+
Object.values(value).forEach(recursiveMarkAsInjected);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
365
479
|
}
|
|
366
|
-
mode = value;
|
|
367
480
|
}
|
|
368
|
-
function
|
|
369
|
-
return
|
|
481
|
+
function haveBeenInjected(object) {
|
|
482
|
+
return injected.has(object);
|
|
370
483
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
484
|
+
function resetAllInjected() {
|
|
485
|
+
injected = new WeakSet();
|
|
373
486
|
}
|
|
374
|
-
function
|
|
375
|
-
if (value) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
value
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
487
|
+
function cloneDeepWithInjectedMark(value) {
|
|
488
|
+
if (brickUtils.isObject(value) && !isPreEvaluated(value)) {
|
|
489
|
+
var clone = Array.isArray(value) ? value.map(item => cloneDeepWithInjectedMark(item)) : Object.fromEntries(
|
|
490
|
+
// Get both string and symbol keys.
|
|
491
|
+
Object.entries(value).map(_ref => {
|
|
492
|
+
var [k, v] = _ref;
|
|
493
|
+
return [k, cloneDeepWithInjectedMark(v)];
|
|
494
|
+
}).concat(Object.getOwnPropertySymbols(value).map(k => [k, value[k]])));
|
|
495
|
+
if (haveBeenInjected(value)) {
|
|
496
|
+
injected.add(clone);
|
|
497
|
+
}
|
|
498
|
+
return clone;
|
|
385
499
|
}
|
|
386
|
-
|
|
387
|
-
function useCurrentMode() {
|
|
388
|
-
var [currentMode, setCurrentMode] = React.useState(getCurrentMode());
|
|
389
|
-
React.useEffect(() => {
|
|
390
|
-
var listenToModeChange = event => {
|
|
391
|
-
setCurrentMode(event.detail);
|
|
392
|
-
};
|
|
393
|
-
window.addEventListener("mode.change", listenToModeChange);
|
|
394
|
-
return () => {
|
|
395
|
-
window.removeEventListener("mode.change", listenToModeChange);
|
|
396
|
-
};
|
|
397
|
-
}, []);
|
|
398
|
-
return currentMode;
|
|
399
|
-
}
|
|
400
|
-
function getCssPropertyValue(name) {
|
|
401
|
-
var _window$getComputedSt;
|
|
402
|
-
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.documentElement;
|
|
403
|
-
if (!el) return "";
|
|
404
|
-
return ((_window$getComputedSt = window.getComputedStyle(el)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue(name)) || "";
|
|
500
|
+
return value;
|
|
405
501
|
}
|
|
406
502
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
503
|
+
var StateOfUseBrick;
|
|
504
|
+
(function (StateOfUseBrick) {
|
|
505
|
+
StateOfUseBrick[StateOfUseBrick["INITIAL"] = 0] = "INITIAL";
|
|
506
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK"] = 1] = "USE_BRICK";
|
|
507
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_ITEM"] = 2] = "USE_BRICK_ITEM";
|
|
508
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_PROPERTIES"] = 3] = "USE_BRICK_PROPERTIES";
|
|
509
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_TRANSFORM"] = 4] = "USE_BRICK_TRANSFORM";
|
|
510
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_EVENTS"] = 5] = "USE_BRICK_EVENTS";
|
|
511
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_IF"] = 6] = "USE_BRICK_IF";
|
|
512
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS"] = 7] = "USE_BRICK_SLOTS";
|
|
513
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM"] = 8] = "USE_BRICK_SLOTS_ITEM";
|
|
514
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM_BRICKS"] = 9] = "USE_BRICK_SLOTS_ITEM_BRICKS";
|
|
515
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM_BRICKS_ITEM"] = 10] = "USE_BRICK_SLOTS_ITEM_BRICKS_ITEM";
|
|
516
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE"] = 11] = "USE_BRICK_LIFECYCLE";
|
|
517
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES"] = 12] = "USE_BRICK_LIFECYCLE_USERESOLVES";
|
|
518
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM"] = 13] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM";
|
|
519
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM"] = 14] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM";
|
|
520
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT"] = 15] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT";
|
|
521
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM"] = 16] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM";
|
|
522
|
+
})(StateOfUseBrick || (StateOfUseBrick = {}));
|
|
523
|
+
function isLazyContentInUseBrick(state) {
|
|
524
|
+
switch (state) {
|
|
525
|
+
case StateOfUseBrick.USE_BRICK_PROPERTIES:
|
|
526
|
+
case StateOfUseBrick.USE_BRICK_TRANSFORM:
|
|
527
|
+
case StateOfUseBrick.USE_BRICK_EVENTS:
|
|
528
|
+
case StateOfUseBrick.USE_BRICK_IF:
|
|
529
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM:
|
|
530
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM:
|
|
531
|
+
return true;
|
|
414
532
|
}
|
|
415
|
-
|
|
416
|
-
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
function getNextStateOfUseBrick(state, isArray, key) {
|
|
536
|
+
if (isLazyContentInUseBrick(state)) {
|
|
537
|
+
return state;
|
|
538
|
+
}
|
|
539
|
+
if (isArray) {
|
|
540
|
+
switch (state) {
|
|
541
|
+
case StateOfUseBrick.USE_BRICK:
|
|
542
|
+
return StateOfUseBrick.USE_BRICK_ITEM;
|
|
543
|
+
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS:
|
|
544
|
+
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS_ITEM;
|
|
545
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES:
|
|
546
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM;
|
|
547
|
+
}
|
|
417
548
|
} else {
|
|
418
|
-
|
|
549
|
+
switch (state) {
|
|
550
|
+
case StateOfUseBrick.INITIAL:
|
|
551
|
+
if (key === "useBrick") {
|
|
552
|
+
return StateOfUseBrick.USE_BRICK;
|
|
553
|
+
}
|
|
554
|
+
break;
|
|
555
|
+
case StateOfUseBrick.USE_BRICK:
|
|
556
|
+
case StateOfUseBrick.USE_BRICK_ITEM:
|
|
557
|
+
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS_ITEM:
|
|
558
|
+
{
|
|
559
|
+
switch (key) {
|
|
560
|
+
case "properties":
|
|
561
|
+
return StateOfUseBrick.USE_BRICK_PROPERTIES;
|
|
562
|
+
case "transform":
|
|
563
|
+
return StateOfUseBrick.USE_BRICK_TRANSFORM;
|
|
564
|
+
case "events":
|
|
565
|
+
return StateOfUseBrick.USE_BRICK_EVENTS;
|
|
566
|
+
case "slots":
|
|
567
|
+
return StateOfUseBrick.USE_BRICK_SLOTS;
|
|
568
|
+
case "if":
|
|
569
|
+
return StateOfUseBrick.USE_BRICK_IF;
|
|
570
|
+
case "lifeCycle":
|
|
571
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE;
|
|
572
|
+
}
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
case StateOfUseBrick.USE_BRICK_SLOTS:
|
|
576
|
+
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM;
|
|
577
|
+
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM:
|
|
578
|
+
if (key === "bricks") {
|
|
579
|
+
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS;
|
|
580
|
+
}
|
|
581
|
+
break;
|
|
582
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE:
|
|
583
|
+
if (key === "useResolves") {
|
|
584
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES;
|
|
585
|
+
}
|
|
586
|
+
break;
|
|
587
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM:
|
|
588
|
+
{
|
|
589
|
+
switch (key) {
|
|
590
|
+
case "transform":
|
|
591
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM;
|
|
592
|
+
case "onReject":
|
|
593
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT;
|
|
594
|
+
}
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT:
|
|
598
|
+
if (key === "transform") {
|
|
599
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM;
|
|
600
|
+
}
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
419
603
|
}
|
|
604
|
+
return StateOfUseBrick.INITIAL;
|
|
420
605
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
606
|
+
|
|
607
|
+
function getTracks(value) {
|
|
608
|
+
var contextNames = false;
|
|
609
|
+
var stateNames = false;
|
|
610
|
+
var formStateNames = false;
|
|
611
|
+
if (typeof value === "string" ? brickUtils.isEvaluable(value) : isPreEvaluated(value)) {
|
|
612
|
+
var raw = typeof value === "string" ? value : getPreEvaluatedRaw(value);
|
|
613
|
+
if (brickUtils.isTrackAll(raw)) {
|
|
614
|
+
var result = brickUtils.trackAll(raw);
|
|
615
|
+
if (result) {
|
|
616
|
+
contextNames = result.context;
|
|
617
|
+
stateNames = result.state;
|
|
618
|
+
formStateNames = result.formState;
|
|
432
619
|
}
|
|
433
|
-
|
|
434
|
-
|
|
620
|
+
} else {
|
|
621
|
+
contextNames = brickUtils.trackContext(raw);
|
|
622
|
+
stateNames = brickUtils.trackState(raw);
|
|
623
|
+
formStateNames = brickUtils.trackFormState(raw);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return {
|
|
627
|
+
contextNames,
|
|
628
|
+
stateNames,
|
|
629
|
+
formStateNames
|
|
435
630
|
};
|
|
436
631
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
configurable: true,
|
|
443
|
-
writable: true
|
|
444
|
-
});
|
|
445
|
-
} else {
|
|
446
|
-
obj[key] = value;
|
|
447
|
-
}
|
|
448
|
-
return obj;
|
|
632
|
+
|
|
633
|
+
/** @internal */
|
|
634
|
+
function transformElementProperties(element, data, to, from, mapArray) {
|
|
635
|
+
var result = preprocessTransformProperties(data, to, from, mapArray);
|
|
636
|
+
setRealProperties(element, result, true);
|
|
449
637
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
});
|
|
457
|
-
keys.push.apply(keys, symbols);
|
|
638
|
+
|
|
639
|
+
/** @internal */
|
|
640
|
+
function transformProperties(props, data, to, from, mapArray, options) {
|
|
641
|
+
var result = preprocessTransformProperties(data, to, from, mapArray, options);
|
|
642
|
+
for (var [propName, propValue] of Object.entries(result)) {
|
|
643
|
+
_.set(props, propName, propValue);
|
|
458
644
|
}
|
|
459
|
-
return
|
|
645
|
+
return props;
|
|
460
646
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
647
|
+
|
|
648
|
+
/** @internal */
|
|
649
|
+
function doTransform(data, to, options) {
|
|
650
|
+
var preEvaluated = isPreEvaluated(to);
|
|
651
|
+
if (preEvaluated || typeof to === "string") {
|
|
652
|
+
// For `useBrick`, some fields such as `properties`/`transform`/`events`,
|
|
653
|
+
// are kept and to be transformed later.
|
|
654
|
+
var lazy = (options === null || options === void 0 ? void 0 : options.$$lazyForUseBrick) && isLazyContentInUseBrick(options.$$stateOfUseBrick);
|
|
655
|
+
if (lazy) {
|
|
656
|
+
// The current data context is not memoized, since a new data context
|
|
657
|
+
// should always be provided before later transformations.
|
|
658
|
+
return to;
|
|
659
|
+
}
|
|
660
|
+
var result;
|
|
661
|
+
var dismissRecursiveMarkingInjected = false;
|
|
662
|
+
if (preEvaluated || brickUtils.isEvaluable(to)) {
|
|
663
|
+
var runtimeContext = {
|
|
664
|
+
data
|
|
665
|
+
};
|
|
666
|
+
if (options !== null && options !== void 0 && options.tplContextId) runtimeContext.tplContextId = options.tplContextId;
|
|
667
|
+
if (options !== null && options !== void 0 && options.formContextId) runtimeContext.formContextId = options.formContextId;
|
|
668
|
+
result = evaluate(to, runtimeContext, options === null || options === void 0 ? void 0 : options.evaluateOptions);
|
|
669
|
+
dismissRecursiveMarkingInjected = shouldDismissRecursiveMarkingInjected(to);
|
|
470
670
|
} else {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
671
|
+
result = options !== null && options !== void 0 && options.allowInject ? brickUtils.transformAndInject(to, data, _internalApiGetCurrentContext()) : brickUtils.transform(to, data);
|
|
672
|
+
}
|
|
673
|
+
if (!dismissRecursiveMarkingInjected) {
|
|
674
|
+
recursiveMarkAsInjected(result);
|
|
474
675
|
}
|
|
475
|
-
|
|
476
|
-
return target;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* @description 获取实例详情
|
|
481
|
-
* @endpoint GET /object/:objectId/instance/:instanceId
|
|
482
|
-
*/
|
|
483
|
-
var InstanceApi_getDetail = /*#__PURE__*/function () {
|
|
484
|
-
var _ref = _asyncToGenerator$2(function* (objectId, instanceId, params, options) {
|
|
485
|
-
return (/**! @contract easyops.api.cmdb.instance.GetDetail */
|
|
486
|
-
(yield brickHttp.http.get("api/gateway/cmdb.instance.GetDetail/object/".concat(objectId, "/instance/").concat(instanceId), _objectSpread2(_objectSpread2({}, options), {}, {
|
|
487
|
-
params
|
|
488
|
-
}))).data
|
|
489
|
-
);
|
|
490
|
-
});
|
|
491
|
-
return function InstanceApi_getDetail(_x, _x2, _x3, _x4) {
|
|
492
|
-
return _ref.apply(this, arguments);
|
|
493
|
-
};
|
|
494
|
-
}();
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* @description 搜索实例
|
|
498
|
-
* @endpoint POST /object/:objectId/instance/_search
|
|
499
|
-
*/
|
|
500
|
-
var InstanceApi_postSearch = /*#__PURE__*/function () {
|
|
501
|
-
var _ref = _asyncToGenerator$2(function* (objectId, data, options) {
|
|
502
|
-
return (/**! @contract easyops.api.cmdb.instance.PostSearch */
|
|
503
|
-
(yield brickHttp.http.post("api/gateway/cmdb.instance.PostSearch/object/".concat(objectId, "/instance/_search"), data, options)).data
|
|
504
|
-
);
|
|
505
|
-
});
|
|
506
|
-
return function InstanceApi_postSearch(_x, _x2, _x3) {
|
|
507
|
-
return _ref.apply(this, arguments);
|
|
508
|
-
};
|
|
509
|
-
}();
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* @description 获取菜单信息
|
|
513
|
-
* @endpoint GET /api/v1/micro-app/menus/:menuId
|
|
514
|
-
*/
|
|
515
|
-
var InstalledMicroAppApi_getMenusInfo = /*#__PURE__*/function () {
|
|
516
|
-
var _ref = _asyncToGenerator__default["default"](function* (menuId, params, options) {
|
|
517
|
-
return (/**! @contract easyops.api.micro_app.installed_micro_app.GetMenusInfo@1.0.0 */(yield brickHttp.http.get("api/gateway/micro_app.installed_micro_app.GetMenusInfo/api/v1/micro-app/menus/".concat(menuId), _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
|
|
518
|
-
params
|
|
519
|
-
}))).data
|
|
520
|
-
);
|
|
521
|
-
});
|
|
522
|
-
return function InstalledMicroAppApi_getMenusInfo(_x, _x2, _x3) {
|
|
523
|
-
return _ref.apply(this, arguments);
|
|
524
|
-
};
|
|
525
|
-
}();
|
|
526
|
-
|
|
527
|
-
/** 微应用的i18n信息 */
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* @description 获取微应用的i18n数据
|
|
531
|
-
* @endpoint GET /api/v1/micro-app/i18n
|
|
532
|
-
*/
|
|
533
|
-
var InstalledMicroAppApi_getI18NData = /*#__PURE__*/function () {
|
|
534
|
-
var _ref = _asyncToGenerator__default["default"](function* (params, options) {
|
|
535
|
-
return (/**! @contract easyops.api.micro_app.installed_micro_app.GetI18NData@1.0.0 */(yield brickHttp.http.get("api/gateway/micro_app.installed_micro_app.GetI18NData/api/v1/micro-app/i18n", _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
|
|
536
|
-
params
|
|
537
|
-
}))).data
|
|
538
|
-
);
|
|
539
|
-
});
|
|
540
|
-
return function InstalledMicroAppApi_getI18NData(_x, _x2) {
|
|
541
|
-
return _ref.apply(this, arguments);
|
|
542
|
-
};
|
|
543
|
-
}();
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* @description 校验系统权限
|
|
547
|
-
* @endpoint POST /api/micro_app/v1/permission/validate
|
|
548
|
-
*/
|
|
549
|
-
var PermissionApi_validatePermissions = /*#__PURE__*/function () {
|
|
550
|
-
var _ref = _asyncToGenerator__default["default"](function* (data, options) {
|
|
551
|
-
return (/**! @contract easyops.api.micro_app.permission.ValidatePermissions@1.0.0 */(yield brickHttp.http.post("api/gateway/micro_app.permission.ValidatePermissions/api/micro_app/v1/permission/validate", data, options)).data
|
|
552
|
-
);
|
|
553
|
-
});
|
|
554
|
-
return function PermissionApi_validatePermissions(_x, _x2) {
|
|
555
|
-
return _ref.apply(this, arguments);
|
|
556
|
-
};
|
|
557
|
-
}();
|
|
558
|
-
|
|
559
|
-
function supply(attemptToVisitGlobals, providedGlobalVariables, mock) {
|
|
560
|
-
var globalVariables = _objectSpread__default["default"]({}, providedGlobalVariables);
|
|
561
|
-
// Allow limited browser builtin values.
|
|
562
|
-
globalVariables["undefined"] = undefined;
|
|
563
|
-
for (var variableName of attemptToVisitGlobals) {
|
|
564
|
-
if (!Object.prototype.hasOwnProperty.call(globalVariables, variableName)) {
|
|
565
|
-
var variable = supplyIndividual(variableName, mock);
|
|
566
|
-
if (variable !== undefined) {
|
|
567
|
-
globalVariables[variableName] = variable;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
return globalVariables;
|
|
572
|
-
}
|
|
573
|
-
var shouldOmitInLodash = new Set([
|
|
574
|
-
// Omit all mutable methods from lodash.
|
|
575
|
-
// But allow sequence methods like `_.chain`.
|
|
576
|
-
"fill", "pull", "pullAll", "pullAllBy", "pullAllWith", "pullAt", "remove", "reverse", "assign", "assignIn", "assignInWith", "assignWith", "defaults", "defaultsDeep", "merge", "mergeWith", "set", "setWith", "unset", "update", "updateWith",
|
|
577
|
-
/**
|
|
578
|
-
* Ignore `Function` methods from lodash, too.
|
|
579
|
-
* There are chances to invoke `Object.assign`, etc.
|
|
580
|
-
*
|
|
581
|
-
* E.g.:
|
|
582
|
-
*
|
|
583
|
-
* ```
|
|
584
|
-
* _.wrap(_.method('constructor.assign',{b:2},{b:3}),(func,...a) => func(...a))({})
|
|
585
|
-
* ```
|
|
586
|
-
*/
|
|
587
|
-
"after", "ary", "before", "bind", "bindKey", "curry", "curryRight", "debounce", "defer", "delay", "flip", "memoize", "negate", "once", "overArgs", "partial", "partialRight", "rearg", "rest", "spread", "throttle", "unary", "wrap"]);
|
|
588
|
-
|
|
589
|
-
// Omit all mutable methods from moment.
|
|
590
|
-
var shouldOmitInMoment = new Set(["lang", "langData", "locale", "localeData", "defineLocale", "updateLocale", "updateOffset"]);
|
|
591
|
-
var allowedGlobalObjects = new Set(["Array", "Boolean", "Date", "Infinity", "JSON", "Math", "NaN", "Number", "String", "RegExp", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "isFinite", "isNaN", "parseFloat", "parseInt", "Map", "Set", "URLSearchParams", "WeakMap", "WeakSet", "atob", "btoa"]);
|
|
592
|
-
function supplyIndividual(variableName, mock) {
|
|
593
|
-
switch (variableName) {
|
|
594
|
-
case "Object":
|
|
595
|
-
// Do not allow mutable methods like `Object.assign`.
|
|
596
|
-
return delegateMethods(Object, ["entries", "fromEntries", "keys", "values"]);
|
|
597
|
-
case "_":
|
|
598
|
-
return Object.fromEntries(Object.entries(___default["default"]).filter(entry => !shouldOmitInLodash.has(entry[0])).concat(mock ? [["uniqueId", prefix => "".concat(prefix !== null && prefix !== void 0 ? prefix : "", "42")]] : []));
|
|
599
|
-
case "moment":
|
|
600
|
-
return Object.assign(function () {
|
|
601
|
-
return moment__default["default"](...arguments);
|
|
602
|
-
}, Object.fromEntries(Object.entries(moment__default["default"]).filter(entry => !shouldOmitInMoment.has(entry[0]))));
|
|
603
|
-
case "PIPES":
|
|
604
|
-
return pipes.pipes;
|
|
605
|
-
case "TAG_URL":
|
|
606
|
-
return tagUrlFactory(true);
|
|
607
|
-
case "SAFE_TAG_URL":
|
|
608
|
-
return tagUrlFactory();
|
|
609
|
-
default:
|
|
610
|
-
if (allowedGlobalObjects.has(variableName)) {
|
|
611
|
-
return window[variableName];
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
function delegateMethods(target, methods) {
|
|
616
|
-
return Object.fromEntries(methods.map(method => [method, function () {
|
|
617
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
618
|
-
args[_key] = arguments[_key];
|
|
619
|
-
}
|
|
620
|
-
return target[method].apply(target, args);
|
|
621
|
-
}]));
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Pass `ignoreSlashes` as `true` to encode all tagged expressions
|
|
625
|
-
* as URL components, except for `/` which maybe used in `APP.homepage`.
|
|
626
|
-
*
|
|
627
|
-
* Otherwise encode all tagged expressions as URL components.
|
|
628
|
-
* This will encode `/` as `%2F`. So do not use it directly
|
|
629
|
-
* with `APP.homepage` as in template expressions.
|
|
630
|
-
*
|
|
631
|
-
* @example
|
|
632
|
-
*
|
|
633
|
-
* ```js
|
|
634
|
-
* TAG_URL`${APP.homepage}/list?q=${q}&redirect=${redirect}`
|
|
635
|
-
* ```
|
|
636
|
-
*
|
|
637
|
-
* ```js
|
|
638
|
-
* SAFE_TAG_URL`file/${path}?q=${q}`
|
|
639
|
-
* // `path` will be fully transformed by `encodeURIComponent`.
|
|
640
|
-
* ```
|
|
641
|
-
*
|
|
642
|
-
* ```js
|
|
643
|
-
* // Wrap `APP.homepage` outside of `SAFE_TAG_URL`.
|
|
644
|
-
* `${APP.homepage}/${SAFE_TAG_URL`file/${path}?q=${q}`}`
|
|
645
|
-
* ```
|
|
646
|
-
*/
|
|
647
|
-
function tagUrlFactory(ignoreSlashes) {
|
|
648
|
-
return function (strings) {
|
|
649
|
-
for (var _len2 = arguments.length, partials = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
650
|
-
partials[_key2 - 1] = arguments[_key2];
|
|
651
|
-
}
|
|
652
|
-
var result = [];
|
|
653
|
-
strings.forEach((str, index) => {
|
|
654
|
-
result.push(str);
|
|
655
|
-
if (index < partials.length) {
|
|
656
|
-
result.push(ignoreSlashes ? String(partials[index]).replace(/[^/]+/g, p => encodeURIComponent(p)) : encodeURIComponent(String(partials[index])));
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
return result.join("");
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
function getUrlByAliasFactory(app) {
|
|
664
|
-
return function getUrlByAlias(alias, pathParams, query) {
|
|
665
|
-
if (!(app !== null && app !== void 0 && app.$$routeAliasMap.has(alias))) {
|
|
666
|
-
// eslint-disable-next-line no-console
|
|
667
|
-
throw new Error("Route alias not found: ".concat(alias));
|
|
668
|
-
}
|
|
669
|
-
var routeConf = app.$$routeAliasMap.get(alias);
|
|
670
|
-
var url = brickUtils.toPath(brickUtils.computeRealRoutePath(routeConf.path, app), pathParams);
|
|
671
|
-
if (query) {
|
|
672
|
-
var urlSearchParams = new URLSearchParams();
|
|
673
|
-
for (var [key, value] of Object.entries(query)) {
|
|
674
|
-
if (Array.isArray(value)) {
|
|
675
|
-
for (var item of value) {
|
|
676
|
-
urlSearchParams.append(key, item);
|
|
677
|
-
}
|
|
678
|
-
} else if (value !== undefined && value !== null && value !== "") {
|
|
679
|
-
urlSearchParams.set(key, value);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
var queryString = urlSearchParams.toString();
|
|
683
|
-
if (queryString.length > 0) {
|
|
684
|
-
url += "?".concat(queryString);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return url;
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function getUrlBySegueFactory(app, segues) {
|
|
692
|
-
return function getUrlBySegue(segueId, pathParams, query) {
|
|
693
|
-
if (!brickUtils.hasOwnProperty(segues, segueId)) {
|
|
694
|
-
// eslint-disable-next-line no-console
|
|
695
|
-
throw new Error("Segue not found: ".concat(segueId));
|
|
696
|
-
}
|
|
697
|
-
var segue = segues[segueId];
|
|
698
|
-
return getUrlByAliasFactory(app)(segue.target, pathParams, query);
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
function imagesFactory(appId, isBuildPush, version) {
|
|
703
|
-
return {
|
|
704
|
-
get(name) {
|
|
705
|
-
var getSuffix = () => {
|
|
706
|
-
var suffix = window.APP_ROOT ? "".concat(window.APP_ROOT).concat(window.BOOTSTRAP_UNION_FILE && window.PUBLIC_DEPS ? "" : "-/") : "";
|
|
707
|
-
if (!suffix.startsWith("/")) {
|
|
708
|
-
suffix = getBasePath() + suffix;
|
|
709
|
-
}
|
|
710
|
-
if (window.APP_ID && window.APP_ID !== appId) {
|
|
711
|
-
return suffix.replace(new RegExp("(^|/)".concat(_.escapeRegExp(window.APP_ID), "/")), "$1".concat(appId, "/")).replace(/\/\d+\.\d+\.\d+\//, "/".concat(version, "/"));
|
|
712
|
-
}
|
|
713
|
-
return suffix;
|
|
714
|
-
};
|
|
715
|
-
return isBuildPush ? "".concat(getBasePath(), "api/gateway/object_store.object_store.GetObject/api/v1/objectStore/bucket/next-builder/object/").concat(name) : window.BOOTSTRAP_UNION_FILE && window.PUBLIC_DEPS ? "".concat(getSuffix(), "images/").concat(name) : "".concat(getSuffix(), "micro-apps/").concat(appId, "/images/").concat(name);
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
function widgetImagesFactory(widgetId, widgetVersion) {
|
|
720
|
-
return {
|
|
721
|
-
get(name) {
|
|
722
|
-
var _window$PUBLIC_ROOT;
|
|
723
|
-
return "".concat((_window$PUBLIC_ROOT = window.PUBLIC_ROOT) !== null && _window$PUBLIC_ROOT !== void 0 ? _window$PUBLIC_ROOT : "", "bricks/").concat(widgetId, "/").concat(window.PUBLIC_ROOT_WITH_VERSION && widgetVersion ? "".concat(widgetVersion, "/") : "", "dist/assets/").concat(name);
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
var injected = new WeakSet();
|
|
729
|
-
|
|
730
|
-
// The injected (or transformed) result should never be *injected* again.
|
|
731
|
-
// So does the fetched data from a remote api.
|
|
732
|
-
function recursiveMarkAsInjected(value) {
|
|
733
|
-
if (brickUtils.isObject(value)) {
|
|
734
|
-
if (!haveBeenInjected(value)) {
|
|
735
|
-
injected.add(value);
|
|
736
|
-
if (Array.isArray(value)) {
|
|
737
|
-
value.forEach(recursiveMarkAsInjected);
|
|
738
|
-
} else {
|
|
739
|
-
// Only mark pure objects.
|
|
740
|
-
var proto = Object.getPrototypeOf(value);
|
|
741
|
-
if (!proto || proto.constructor === Object) {
|
|
742
|
-
Object.values(value).forEach(recursiveMarkAsInjected);
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
function haveBeenInjected(object) {
|
|
749
|
-
return injected.has(object);
|
|
750
|
-
}
|
|
751
|
-
function resetAllInjected() {
|
|
752
|
-
injected = new WeakSet();
|
|
753
|
-
}
|
|
754
|
-
function cloneDeepWithInjectedMark(value) {
|
|
755
|
-
if (brickUtils.isObject(value) && !isPreEvaluated(value)) {
|
|
756
|
-
var clone = Array.isArray(value) ? value.map(item => cloneDeepWithInjectedMark(item)) : Object.fromEntries(
|
|
757
|
-
// Get both string and symbol keys.
|
|
758
|
-
Object.entries(value).map(_ref => {
|
|
759
|
-
var [k, v] = _ref;
|
|
760
|
-
return [k, cloneDeepWithInjectedMark(v)];
|
|
761
|
-
}).concat(Object.getOwnPropertySymbols(value).map(k => [k, value[k]])));
|
|
762
|
-
if (haveBeenInjected(value)) {
|
|
763
|
-
injected.add(clone);
|
|
764
|
-
}
|
|
765
|
-
return clone;
|
|
766
|
-
}
|
|
767
|
-
return value;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
var StateOfUseBrick;
|
|
771
|
-
(function (StateOfUseBrick) {
|
|
772
|
-
StateOfUseBrick[StateOfUseBrick["INITIAL"] = 0] = "INITIAL";
|
|
773
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK"] = 1] = "USE_BRICK";
|
|
774
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_ITEM"] = 2] = "USE_BRICK_ITEM";
|
|
775
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_PROPERTIES"] = 3] = "USE_BRICK_PROPERTIES";
|
|
776
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_TRANSFORM"] = 4] = "USE_BRICK_TRANSFORM";
|
|
777
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_EVENTS"] = 5] = "USE_BRICK_EVENTS";
|
|
778
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_IF"] = 6] = "USE_BRICK_IF";
|
|
779
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS"] = 7] = "USE_BRICK_SLOTS";
|
|
780
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM"] = 8] = "USE_BRICK_SLOTS_ITEM";
|
|
781
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM_BRICKS"] = 9] = "USE_BRICK_SLOTS_ITEM_BRICKS";
|
|
782
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM_BRICKS_ITEM"] = 10] = "USE_BRICK_SLOTS_ITEM_BRICKS_ITEM";
|
|
783
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE"] = 11] = "USE_BRICK_LIFECYCLE";
|
|
784
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES"] = 12] = "USE_BRICK_LIFECYCLE_USERESOLVES";
|
|
785
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM"] = 13] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM";
|
|
786
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM"] = 14] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM";
|
|
787
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT"] = 15] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT";
|
|
788
|
-
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM"] = 16] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM";
|
|
789
|
-
})(StateOfUseBrick || (StateOfUseBrick = {}));
|
|
790
|
-
function isLazyContentInUseBrick(state) {
|
|
791
|
-
switch (state) {
|
|
792
|
-
case StateOfUseBrick.USE_BRICK_PROPERTIES:
|
|
793
|
-
case StateOfUseBrick.USE_BRICK_TRANSFORM:
|
|
794
|
-
case StateOfUseBrick.USE_BRICK_EVENTS:
|
|
795
|
-
case StateOfUseBrick.USE_BRICK_IF:
|
|
796
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM:
|
|
797
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM:
|
|
798
|
-
return true;
|
|
799
|
-
}
|
|
800
|
-
return false;
|
|
801
|
-
}
|
|
802
|
-
function getNextStateOfUseBrick(state, isArray, key) {
|
|
803
|
-
if (isLazyContentInUseBrick(state)) {
|
|
804
|
-
return state;
|
|
805
|
-
}
|
|
806
|
-
if (isArray) {
|
|
807
|
-
switch (state) {
|
|
808
|
-
case StateOfUseBrick.USE_BRICK:
|
|
809
|
-
return StateOfUseBrick.USE_BRICK_ITEM;
|
|
810
|
-
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS:
|
|
811
|
-
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS_ITEM;
|
|
812
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES:
|
|
813
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM;
|
|
814
|
-
}
|
|
815
|
-
} else {
|
|
816
|
-
switch (state) {
|
|
817
|
-
case StateOfUseBrick.INITIAL:
|
|
818
|
-
if (key === "useBrick") {
|
|
819
|
-
return StateOfUseBrick.USE_BRICK;
|
|
820
|
-
}
|
|
821
|
-
break;
|
|
822
|
-
case StateOfUseBrick.USE_BRICK:
|
|
823
|
-
case StateOfUseBrick.USE_BRICK_ITEM:
|
|
824
|
-
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS_ITEM:
|
|
825
|
-
{
|
|
826
|
-
switch (key) {
|
|
827
|
-
case "properties":
|
|
828
|
-
return StateOfUseBrick.USE_BRICK_PROPERTIES;
|
|
829
|
-
case "transform":
|
|
830
|
-
return StateOfUseBrick.USE_BRICK_TRANSFORM;
|
|
831
|
-
case "events":
|
|
832
|
-
return StateOfUseBrick.USE_BRICK_EVENTS;
|
|
833
|
-
case "slots":
|
|
834
|
-
return StateOfUseBrick.USE_BRICK_SLOTS;
|
|
835
|
-
case "if":
|
|
836
|
-
return StateOfUseBrick.USE_BRICK_IF;
|
|
837
|
-
case "lifeCycle":
|
|
838
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE;
|
|
839
|
-
}
|
|
840
|
-
break;
|
|
841
|
-
}
|
|
842
|
-
case StateOfUseBrick.USE_BRICK_SLOTS:
|
|
843
|
-
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM;
|
|
844
|
-
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM:
|
|
845
|
-
if (key === "bricks") {
|
|
846
|
-
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS;
|
|
847
|
-
}
|
|
848
|
-
break;
|
|
849
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE:
|
|
850
|
-
if (key === "useResolves") {
|
|
851
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES;
|
|
852
|
-
}
|
|
853
|
-
break;
|
|
854
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM:
|
|
855
|
-
{
|
|
856
|
-
switch (key) {
|
|
857
|
-
case "transform":
|
|
858
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM;
|
|
859
|
-
case "onReject":
|
|
860
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT;
|
|
861
|
-
}
|
|
862
|
-
break;
|
|
863
|
-
}
|
|
864
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT:
|
|
865
|
-
if (key === "transform") {
|
|
866
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM;
|
|
867
|
-
}
|
|
868
|
-
break;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
return StateOfUseBrick.INITIAL;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function getTracks(value) {
|
|
875
|
-
var contextNames = false;
|
|
876
|
-
var stateNames = false;
|
|
877
|
-
var formStateNames = false;
|
|
878
|
-
if (typeof value === "string" ? brickUtils.isEvaluable(value) : isPreEvaluated(value)) {
|
|
879
|
-
var raw = typeof value === "string" ? value : getPreEvaluatedRaw(value);
|
|
880
|
-
if (brickUtils.isTrackAll(raw)) {
|
|
881
|
-
var result = brickUtils.trackAll(raw);
|
|
882
|
-
if (result) {
|
|
883
|
-
contextNames = result.context;
|
|
884
|
-
stateNames = result.state;
|
|
885
|
-
formStateNames = result.formState;
|
|
886
|
-
}
|
|
887
|
-
} else {
|
|
888
|
-
contextNames = brickUtils.trackContext(raw);
|
|
889
|
-
stateNames = brickUtils.trackState(raw);
|
|
890
|
-
formStateNames = brickUtils.trackFormState(raw);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
return {
|
|
894
|
-
contextNames,
|
|
895
|
-
stateNames,
|
|
896
|
-
formStateNames
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
/** @internal */
|
|
901
|
-
function transformElementProperties(element, data, to, from, mapArray) {
|
|
902
|
-
var result = preprocessTransformProperties(data, to, from, mapArray);
|
|
903
|
-
setRealProperties(element, result, true);
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
/** @internal */
|
|
907
|
-
function transformProperties(props, data, to, from, mapArray, options) {
|
|
908
|
-
var result = preprocessTransformProperties(data, to, from, mapArray, options);
|
|
909
|
-
for (var [propName, propValue] of Object.entries(result)) {
|
|
910
|
-
_.set(props, propName, propValue);
|
|
911
|
-
}
|
|
912
|
-
return props;
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
/** @internal */
|
|
916
|
-
function doTransform(data, to, options) {
|
|
917
|
-
var preEvaluated = isPreEvaluated(to);
|
|
918
|
-
if (preEvaluated || typeof to === "string") {
|
|
919
|
-
// For `useBrick`, some fields such as `properties`/`transform`/`events`,
|
|
920
|
-
// are kept and to be transformed later.
|
|
921
|
-
var lazy = (options === null || options === void 0 ? void 0 : options.$$lazyForUseBrick) && isLazyContentInUseBrick(options.$$stateOfUseBrick);
|
|
922
|
-
if (lazy) {
|
|
923
|
-
// The current data context is not memoized, since a new data context
|
|
924
|
-
// should always be provided before later transformations.
|
|
925
|
-
return to;
|
|
926
|
-
}
|
|
927
|
-
var result;
|
|
928
|
-
var dismissRecursiveMarkingInjected = false;
|
|
929
|
-
if (preEvaluated || brickUtils.isEvaluable(to)) {
|
|
930
|
-
var runtimeContext = {
|
|
931
|
-
data
|
|
932
|
-
};
|
|
933
|
-
if (options !== null && options !== void 0 && options.tplContextId) runtimeContext.tplContextId = options.tplContextId;
|
|
934
|
-
if (options !== null && options !== void 0 && options.formContextId) runtimeContext.formContextId = options.formContextId;
|
|
935
|
-
result = evaluate(to, runtimeContext, options === null || options === void 0 ? void 0 : options.evaluateOptions);
|
|
936
|
-
dismissRecursiveMarkingInjected = shouldDismissRecursiveMarkingInjected(to);
|
|
937
|
-
} else {
|
|
938
|
-
result = options !== null && options !== void 0 && options.allowInject ? brickUtils.transformAndInject(to, data, _internalApiGetCurrentContext()) : brickUtils.transform(to, data);
|
|
939
|
-
}
|
|
940
|
-
if (!dismissRecursiveMarkingInjected) {
|
|
941
|
-
recursiveMarkAsInjected(result);
|
|
942
|
-
}
|
|
943
|
-
return result;
|
|
676
|
+
return result;
|
|
944
677
|
}
|
|
945
678
|
if (!brickUtils.isObject(to) || haveBeenInjected(to)) {
|
|
946
679
|
return to;
|
|
@@ -1244,44 +977,197 @@
|
|
|
1244
977
|
return "$".concat(type, "-").concat(id);
|
|
1245
978
|
}
|
|
1246
979
|
|
|
1247
|
-
function registerWidgetI18n(widgetId, i18n) {
|
|
1248
|
-
var ns = getI18nNamespace("widget", widgetId);
|
|
1249
|
-
Object.entries(i18n).forEach(_ref => {
|
|
1250
|
-
var [lang, resources] = _ref;
|
|
1251
|
-
i18next__default["default"].addResourceBundle(lang, ns, resources);
|
|
980
|
+
function registerWidgetI18n(widgetId, i18n) {
|
|
981
|
+
var ns = getI18nNamespace("widget", widgetId);
|
|
982
|
+
Object.entries(i18n).forEach(_ref => {
|
|
983
|
+
var [lang, resources] = _ref;
|
|
984
|
+
i18next__default["default"].addResourceBundle(lang, ns, resources);
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
function widgetI18nFactory(widgetId) {
|
|
988
|
+
return i18next.getFixedT(null, getI18nNamespace("widget", widgetId));
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
function i18nText(data) {
|
|
992
|
+
var _i18next$language;
|
|
993
|
+
if (!data) {
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
var language = (_i18next$language = i18next__default["default"].language) !== null && _i18next$language !== void 0 ? _i18next$language : "zh-CN";
|
|
997
|
+
// First, make a perfect match.
|
|
998
|
+
if (brickUtils.hasOwnProperty(data, language)) {
|
|
999
|
+
return data[language];
|
|
1000
|
+
}
|
|
1001
|
+
// https://en.wikipedia.org/wiki/IETF_language_tag
|
|
1002
|
+
var primaryLanguage = language.split("-")[0];
|
|
1003
|
+
if (primaryLanguage !== language) {
|
|
1004
|
+
// Then, match the primary language (which omits other subtags).
|
|
1005
|
+
// E.g., match `zh` if the current language is `zh-CN`.
|
|
1006
|
+
return brickUtils.hasOwnProperty(data, primaryLanguage) ? data[primaryLanguage] : undefined;
|
|
1007
|
+
}
|
|
1008
|
+
// At last, match the first key which starts with the primary language,
|
|
1009
|
+
// if the current language contains primary subtag only.
|
|
1010
|
+
// E.g., match `zh-CN` if the current language is `zh`.
|
|
1011
|
+
var prefix = "".concat(primaryLanguage, "-");
|
|
1012
|
+
for (var key of Object.keys(data)) {
|
|
1013
|
+
if (key.startsWith(prefix)) {
|
|
1014
|
+
return data[key];
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// Themes.
|
|
1020
|
+
var DEFAULT_THEME = "light";
|
|
1021
|
+
var theme = DEFAULT_THEME;
|
|
1022
|
+
var storage = new brickUtils.JsonStorage(localStorage);
|
|
1023
|
+
var LOCAL_STORAGE_APPS_THEME_KEY = "apps-theme";
|
|
1024
|
+
function setTheme(value) {
|
|
1025
|
+
if (value !== "dark" && value !== "light" && value !== "dark-v2") {
|
|
1026
|
+
throw new Error("Unsupported theme: ".concat(value));
|
|
1027
|
+
}
|
|
1028
|
+
theme = value;
|
|
1029
|
+
}
|
|
1030
|
+
function getTheme() {
|
|
1031
|
+
return theme;
|
|
1032
|
+
}
|
|
1033
|
+
function getCurrentTheme() {
|
|
1034
|
+
return document.documentElement.dataset.theme;
|
|
1035
|
+
}
|
|
1036
|
+
function applyTheme(value) {
|
|
1037
|
+
if (value) {
|
|
1038
|
+
setTheme(value);
|
|
1039
|
+
} else {
|
|
1040
|
+
value = getTheme();
|
|
1041
|
+
}
|
|
1042
|
+
if (value !== getCurrentTheme()) {
|
|
1043
|
+
document.documentElement.dataset.theme = value;
|
|
1044
|
+
window.dispatchEvent(new CustomEvent("theme.change", {
|
|
1045
|
+
detail: value
|
|
1046
|
+
}));
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function useCurrentTheme() {
|
|
1050
|
+
var [currentTheme, setCurrentTheme] = React.useState(getCurrentTheme());
|
|
1051
|
+
React.useEffect(() => {
|
|
1052
|
+
var listenToThemeChange = event => {
|
|
1053
|
+
setCurrentTheme(event.detail);
|
|
1054
|
+
};
|
|
1055
|
+
window.addEventListener("theme.change", listenToThemeChange);
|
|
1056
|
+
return () => {
|
|
1057
|
+
window.removeEventListener("theme.change", listenToThemeChange);
|
|
1058
|
+
};
|
|
1059
|
+
}, []);
|
|
1060
|
+
return currentTheme;
|
|
1061
|
+
}
|
|
1062
|
+
function batchSetAppsLocalTheme(appsTheme) {
|
|
1063
|
+
storage.setItem(LOCAL_STORAGE_APPS_THEME_KEY, _objectSpread__default["default"](_objectSpread__default["default"]({}, getLocalAppsTheme()), appsTheme));
|
|
1064
|
+
}
|
|
1065
|
+
function getLocalAppsTheme() {
|
|
1066
|
+
var result;
|
|
1067
|
+
try {
|
|
1068
|
+
result = storage.getItem(LOCAL_STORAGE_APPS_THEME_KEY);
|
|
1069
|
+
} catch (_unused) {
|
|
1070
|
+
// eslint-disable-next-line no-console
|
|
1071
|
+
console.error("JSON parse error inside `getLocalAppsTheme()`");
|
|
1072
|
+
}
|
|
1073
|
+
return result || {};
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// Modes.
|
|
1077
|
+
var DEFAULT_MODE = "default";
|
|
1078
|
+
var mode = DEFAULT_MODE;
|
|
1079
|
+
function setMode(value) {
|
|
1080
|
+
if (value !== "dashboard" && value !== "default") {
|
|
1081
|
+
throw new Error("Unsupported mode: ".concat(value));
|
|
1082
|
+
}
|
|
1083
|
+
mode = value;
|
|
1084
|
+
}
|
|
1085
|
+
function getMode() {
|
|
1086
|
+
return mode;
|
|
1087
|
+
}
|
|
1088
|
+
function getCurrentMode() {
|
|
1089
|
+
return document.documentElement.dataset.mode;
|
|
1090
|
+
}
|
|
1091
|
+
function applyMode(value) {
|
|
1092
|
+
if (value) {
|
|
1093
|
+
setMode(value);
|
|
1094
|
+
} else {
|
|
1095
|
+
value = getMode();
|
|
1096
|
+
}
|
|
1097
|
+
if (value !== getCurrentMode()) {
|
|
1098
|
+
document.documentElement.dataset.mode = value;
|
|
1099
|
+
window.dispatchEvent(new CustomEvent("mode.change", {
|
|
1100
|
+
detail: value
|
|
1101
|
+
}));
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
function useCurrentMode() {
|
|
1105
|
+
var [currentMode, setCurrentMode] = React.useState(getCurrentMode());
|
|
1106
|
+
React.useEffect(() => {
|
|
1107
|
+
var listenToModeChange = event => {
|
|
1108
|
+
setCurrentMode(event.detail);
|
|
1109
|
+
};
|
|
1110
|
+
window.addEventListener("mode.change", listenToModeChange);
|
|
1111
|
+
return () => {
|
|
1112
|
+
window.removeEventListener("mode.change", listenToModeChange);
|
|
1113
|
+
};
|
|
1114
|
+
}, []);
|
|
1115
|
+
return currentMode;
|
|
1116
|
+
}
|
|
1117
|
+
function getCssPropertyValue(name) {
|
|
1118
|
+
var _window$getComputedSt;
|
|
1119
|
+
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.documentElement;
|
|
1120
|
+
if (!el) return "";
|
|
1121
|
+
return ((_window$getComputedSt = window.getComputedStyle(el)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue(name)) || "";
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* @description 获取菜单信息
|
|
1126
|
+
* @endpoint GET /api/v1/micro-app/menus/:menuId
|
|
1127
|
+
*/
|
|
1128
|
+
var InstalledMicroAppApi_getMenusInfo = /*#__PURE__*/function () {
|
|
1129
|
+
var _ref = _asyncToGenerator__default["default"](function* (menuId, params, options) {
|
|
1130
|
+
return (/**! @contract easyops.api.micro_app.installed_micro_app.GetMenusInfo@1.0.0 */(yield brickHttp.http.get("api/gateway/micro_app.installed_micro_app.GetMenusInfo/api/v1/micro-app/menus/".concat(menuId), _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
|
|
1131
|
+
params
|
|
1132
|
+
}))).data
|
|
1133
|
+
);
|
|
1252
1134
|
});
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
}
|
|
1135
|
+
return function InstalledMicroAppApi_getMenusInfo(_x, _x2, _x3) {
|
|
1136
|
+
return _ref.apply(this, arguments);
|
|
1137
|
+
};
|
|
1138
|
+
}();
|
|
1257
1139
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
return
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1140
|
+
/** 微应用的i18n信息 */
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* @description 获取微应用的i18n数据
|
|
1144
|
+
* @endpoint GET /api/v1/micro-app/i18n
|
|
1145
|
+
*/
|
|
1146
|
+
var InstalledMicroAppApi_getI18NData = /*#__PURE__*/function () {
|
|
1147
|
+
var _ref = _asyncToGenerator__default["default"](function* (params, options) {
|
|
1148
|
+
return (/**! @contract easyops.api.micro_app.installed_micro_app.GetI18NData@1.0.0 */(yield brickHttp.http.get("api/gateway/micro_app.installed_micro_app.GetI18NData/api/v1/micro-app/i18n", _objectSpread__default["default"](_objectSpread__default["default"]({}, options), {}, {
|
|
1149
|
+
params
|
|
1150
|
+
}))).data
|
|
1151
|
+
);
|
|
1152
|
+
});
|
|
1153
|
+
return function InstalledMicroAppApi_getI18NData(_x, _x2) {
|
|
1154
|
+
return _ref.apply(this, arguments);
|
|
1155
|
+
};
|
|
1156
|
+
}();
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* @description 校验系统权限
|
|
1160
|
+
* @endpoint POST /api/micro_app/v1/permission/validate
|
|
1161
|
+
*/
|
|
1162
|
+
var PermissionApi_validatePermissions = /*#__PURE__*/function () {
|
|
1163
|
+
var _ref = _asyncToGenerator__default["default"](function* (data, options) {
|
|
1164
|
+
return (/**! @contract easyops.api.micro_app.permission.ValidatePermissions@1.0.0 */(yield brickHttp.http.post("api/gateway/micro_app.permission.ValidatePermissions/api/micro_app/v1/permission/validate", data, options)).data
|
|
1165
|
+
);
|
|
1166
|
+
});
|
|
1167
|
+
return function PermissionApi_validatePermissions(_x, _x2) {
|
|
1168
|
+
return _ref.apply(this, arguments);
|
|
1169
|
+
};
|
|
1170
|
+
}();
|
|
1285
1171
|
|
|
1286
1172
|
var auth = {};
|
|
1287
1173
|
|
|
@@ -1296,6 +1182,7 @@
|
|
|
1296
1182
|
isAdmin: newAuth.isAdmin,
|
|
1297
1183
|
csrfToken: newAuth.csrfToken,
|
|
1298
1184
|
license: newAuth.license,
|
|
1185
|
+
accessToken: newAuth.accessToken,
|
|
1299
1186
|
userShowValue: newAuth.userShowValue
|
|
1300
1187
|
});
|
|
1301
1188
|
|
|
@@ -1930,419 +1817,950 @@
|
|
|
1930
1817
|
}));
|
|
1931
1818
|
}
|
|
1932
1819
|
};
|
|
1933
|
-
triggerEvent(updateContexts);
|
|
1934
|
-
triggerEvent(affectContexts);
|
|
1935
|
-
this.batchUpdate = false;
|
|
1936
|
-
return;
|
|
1820
|
+
triggerEvent(updateContexts);
|
|
1821
|
+
triggerEvent(affectContexts);
|
|
1822
|
+
this.batchUpdate = false;
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
updateValue(name, value, method, callback) {
|
|
1826
|
+
var _item$eventTarget;
|
|
1827
|
+
if (!this.data.has(name)) {
|
|
1828
|
+
if (this.tplContextId) {
|
|
1829
|
+
throw new Error("State not found: ".concat(name));
|
|
1830
|
+
} else {
|
|
1831
|
+
// eslint-disable-next-line no-console
|
|
1832
|
+
console.warn("Context \"".concat(name, "\" is not declared, we recommend declaring it first."));
|
|
1833
|
+
this.set(name, {
|
|
1834
|
+
type: "free-variable",
|
|
1835
|
+
value
|
|
1836
|
+
});
|
|
1837
|
+
return;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
var item = this.data.get(name);
|
|
1841
|
+
if (item.type !== "free-variable") {
|
|
1842
|
+
// eslint-disable-next-line no-console
|
|
1843
|
+
console.error("Unexpected storyboard context \"".concat(name, "\", expected \"free-variable\", received \"").concat(item.type, "\"."));
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
if (method === "refresh" || method === "load") {
|
|
1847
|
+
if (!item.useResolve) {
|
|
1848
|
+
throw new Error("You can not ".concat(method, " the storyboard context \"").concat(name, "\" which is not using resolve."));
|
|
1849
|
+
}
|
|
1850
|
+
var promise;
|
|
1851
|
+
if (method === "load") {
|
|
1852
|
+
// Try to reuse previous request when calling `load`.
|
|
1853
|
+
if (item.loaded) {
|
|
1854
|
+
promise = Promise.resolve(item.value);
|
|
1855
|
+
} else if (item.loading) {
|
|
1856
|
+
promise = item.loading;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
var shouldDismiss = error => {
|
|
1860
|
+
// If render twice immediately, flow API contracts maybe cleared before
|
|
1861
|
+
// the second rendering, while the page load handlers of the first
|
|
1862
|
+
// rendering can't be cancelled, which throws `FlowApiNotFoundError`.
|
|
1863
|
+
// So we ignore error reporting for this case.
|
|
1864
|
+
return (error === null || error === void 0 ? void 0 : error.name) === "FlowApiNotFoundError" && this.renderId && this.renderId !== _internalApiGetRouterRenderId();
|
|
1865
|
+
};
|
|
1866
|
+
if (!promise) {
|
|
1867
|
+
promise = item.loading = item.load(_objectSpread__default["default"]({
|
|
1868
|
+
cache: method === "load" ? "default" : "reload"
|
|
1869
|
+
}, value));
|
|
1870
|
+
// Do not use the chained promise, since the callbacks need the original promise.
|
|
1871
|
+
promise.then(val => {
|
|
1872
|
+
this.finishLoad(item, val);
|
|
1873
|
+
}, err => {
|
|
1874
|
+
// Let users to override error handling.
|
|
1875
|
+
if (!shouldDismiss(err) && !(callback !== null && callback !== void 0 && callback.error)) {
|
|
1876
|
+
handleHttpError(err);
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
if (callback) {
|
|
1881
|
+
var callbackFactory = eventCallbackFactory(callback, () => this.getResolveOptions(_internalApiGetCurrentContext()).mergedContext, null);
|
|
1882
|
+
promise.then(val => {
|
|
1883
|
+
callbackFactory("success")({
|
|
1884
|
+
value: val
|
|
1885
|
+
});
|
|
1886
|
+
callbackFactory("finally")();
|
|
1887
|
+
}, err => {
|
|
1888
|
+
if (!shouldDismiss(err) && callback.error) {
|
|
1889
|
+
callbackFactory("error")(err);
|
|
1890
|
+
}
|
|
1891
|
+
callbackFactory("finally")();
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
if (method === "replace") {
|
|
1897
|
+
item.value = value;
|
|
1898
|
+
} else {
|
|
1899
|
+
if (brickUtils.isObject(item.value)) {
|
|
1900
|
+
Object.assign(item.value, value);
|
|
1901
|
+
} else {
|
|
1902
|
+
// eslint-disable-next-line no-console
|
|
1903
|
+
console.warn("Non-object current value of context \"".concat(name, "\" for \"context.assign\", try \"context.replace\" instead."));
|
|
1904
|
+
item.value = value;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
if (this.batchUpdate) return;
|
|
1908
|
+
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.eventName, {
|
|
1909
|
+
detail: item.value
|
|
1910
|
+
}));
|
|
1911
|
+
}
|
|
1912
|
+
finishLoad(item, value) {
|
|
1913
|
+
var _item$eventTarget2;
|
|
1914
|
+
if (!item.useResolve) {
|
|
1915
|
+
// This happens when a tracked conditional resolve switches from
|
|
1916
|
+
// resolve to fallback after an dep update triggered refresh but
|
|
1917
|
+
// before it's been resolved.
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
item.loaded = true;
|
|
1921
|
+
item.value = value;
|
|
1922
|
+
(_item$eventTarget2 = item.eventTarget) === null || _item$eventTarget2 === void 0 ? void 0 : _item$eventTarget2.dispatchEvent(new CustomEvent(this.eventName, {
|
|
1923
|
+
detail: value
|
|
1924
|
+
}));
|
|
1925
|
+
}
|
|
1926
|
+
waitForUsedContext(data) {
|
|
1927
|
+
var _this = this;
|
|
1928
|
+
return _asyncToGenerator__default["default"](function* () {
|
|
1929
|
+
if (_this.tplContextId || _this.formContextId) {
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
var usage = brickUtils.collectContextUsage(data, "CTX");
|
|
1933
|
+
if (usage.includesComputed) {
|
|
1934
|
+
for (var pending of _this.pendingStack) {
|
|
1935
|
+
yield pending.pendingResult;
|
|
1936
|
+
}
|
|
1937
|
+
} else if (usage.usedContexts.length > 0) {
|
|
1938
|
+
var _loop = function* (pendingContexts) {
|
|
1939
|
+
yield Promise.all(usage.usedContexts.map(ctx => pendingContexts.get(ctx)));
|
|
1940
|
+
};
|
|
1941
|
+
for (var {
|
|
1942
|
+
pendingContexts
|
|
1943
|
+
} of _this.pendingStack) {
|
|
1944
|
+
yield* _loop(pendingContexts);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
})();
|
|
1948
|
+
}
|
|
1949
|
+
waitForAllContext() {
|
|
1950
|
+
var _this2 = this;
|
|
1951
|
+
return _asyncToGenerator__default["default"](function* () {
|
|
1952
|
+
if (_this2.tplContextId || _this2.formContextId) {
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1955
|
+
for (var pending of _this2.pendingStack) {
|
|
1956
|
+
yield pending.pendingResult;
|
|
1957
|
+
}
|
|
1958
|
+
})();
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
/** After mount, dispatch the change event when an async data is loaded */
|
|
1962
|
+
handleAsyncAfterMount() {
|
|
1963
|
+
this.data.forEach(item => {
|
|
1964
|
+
if (item.type === "free-variable" && item.async) {
|
|
1965
|
+
// An async data always has `loading`
|
|
1966
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1967
|
+
item.loading.then(value => {
|
|
1968
|
+
this.finishLoad(item, value);
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
deferDefine(contextConfs, coreContext, brick) {
|
|
1974
|
+
var {
|
|
1975
|
+
mergedContext,
|
|
1976
|
+
keyword
|
|
1977
|
+
} = this.getResolveOptions(coreContext);
|
|
1978
|
+
if (Array.isArray(contextConfs) && contextConfs.length > 0) {
|
|
1979
|
+
var pending = brickUtils.deferResolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
|
|
1980
|
+
this.pendingStack.push(pending);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
define(contextConfs, coreContext, brick) {
|
|
1984
|
+
var _this3 = this;
|
|
1985
|
+
return _asyncToGenerator__default["default"](function* () {
|
|
1986
|
+
if (Array.isArray(contextConfs)) {
|
|
1987
|
+
var {
|
|
1988
|
+
mergedContext,
|
|
1989
|
+
keyword
|
|
1990
|
+
} = _this3.getResolveOptions(coreContext);
|
|
1991
|
+
yield brickUtils.resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, _this3, brick), keyword);
|
|
1992
|
+
}
|
|
1993
|
+
})();
|
|
1994
|
+
}
|
|
1995
|
+
syncDefine(contextConfs, coreContext, brick) {
|
|
1996
|
+
if (Array.isArray(contextConfs)) {
|
|
1997
|
+
var {
|
|
1998
|
+
mergedContext,
|
|
1999
|
+
keyword
|
|
2000
|
+
} = this.getResolveOptions(coreContext);
|
|
2001
|
+
brickUtils.syncResolveContextConcurrently(contextConfs, contextConf => syncResolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
getResolveOptions(coreContext) {
|
|
2005
|
+
return this.formContextId ? {
|
|
2006
|
+
mergedContext: _objectSpread__default["default"](_objectSpread__default["default"]({}, coreContext), {}, {
|
|
2007
|
+
formContextId: this.formContextId
|
|
2008
|
+
}),
|
|
2009
|
+
keyword: "FORM_STATE"
|
|
2010
|
+
} : this.tplContextId ? {
|
|
2011
|
+
mergedContext: _objectSpread__default["default"](_objectSpread__default["default"]({}, coreContext), {}, {
|
|
2012
|
+
tplContextId: this.tplContextId
|
|
2013
|
+
}),
|
|
2014
|
+
keyword: "STATE"
|
|
2015
|
+
} : {
|
|
2016
|
+
mergedContext: coreContext,
|
|
2017
|
+
keyword: "CTX"
|
|
2018
|
+
};
|
|
1937
2019
|
}
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
2020
|
+
getContextTriggerSetByLifecycle(lifecycle) {
|
|
2021
|
+
return this.batchTriggerContextsNamesMap.get(lifecycle) || [];
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
function resolveStoryboardContext(_x, _x2, _x3, _x4) {
|
|
2025
|
+
return _resolveStoryboardContext.apply(this, arguments);
|
|
2026
|
+
}
|
|
2027
|
+
function _resolveStoryboardContext() {
|
|
2028
|
+
_resolveStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf, coreContext, storyboardContextWrapper, brick) {
|
|
2029
|
+
if (contextConf.property) {
|
|
2030
|
+
if (storyboardContextWrapper.tplContextId) {
|
|
2031
|
+
throw new Error("Setting `property` is not allowed in template scoped context");
|
|
2032
|
+
}
|
|
2033
|
+
if (brick) {
|
|
2034
|
+
storyboardContextWrapper.set(contextConf.name, {
|
|
2035
|
+
type: "brick-property",
|
|
2036
|
+
brick,
|
|
2037
|
+
prop: contextConf.property
|
|
1949
2038
|
});
|
|
1950
|
-
return;
|
|
1951
2039
|
}
|
|
2040
|
+
return true;
|
|
1952
2041
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
2042
|
+
return resolveNormalStoryboardContext(contextConf, coreContext, storyboardContextWrapper, brick);
|
|
2043
|
+
});
|
|
2044
|
+
return _resolveStoryboardContext.apply(this, arguments);
|
|
2045
|
+
}
|
|
2046
|
+
var supportContextResolveTriggerBrickLifeCycle = ["onBeforePageLoad", "onPageLoad", "onBeforePageLeave", "onPageLeave", "onAnchorLoad", "onAnchorUnload"];
|
|
2047
|
+
function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
|
|
2048
|
+
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
2049
|
+
}
|
|
2050
|
+
function _resolveNormalStoryboardContext() {
|
|
2051
|
+
_resolveNormalStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2052
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.if);
|
|
2053
|
+
if (!looseCheckIf$1(contextConf, mergedContext)) {
|
|
2054
|
+
return false;
|
|
1958
2055
|
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2056
|
+
var isTemplateState = !!storyboardContextWrapper.tplContextId;
|
|
2057
|
+
var isFormState = !!storyboardContextWrapper.formContextId;
|
|
2058
|
+
var value = getDefinedTemplateState(isTemplateState, contextConf, brick);
|
|
2059
|
+
var load = null;
|
|
2060
|
+
var loading;
|
|
2061
|
+
var useResolve;
|
|
2062
|
+
var trackConditionalResolve;
|
|
2063
|
+
var resolvePolicy;
|
|
2064
|
+
if (value === undefined) {
|
|
2065
|
+
if (contextConf.resolve) {
|
|
2066
|
+
var hasFallbackValue = brickUtils.hasOwnProperty(contextConf, "value");
|
|
2067
|
+
// Track conditional resolve only if all matches:
|
|
2068
|
+
// - Track enabled
|
|
2069
|
+
// - Has fallback value
|
|
2070
|
+
// - Referencing other data in `resolve.if`
|
|
2071
|
+
trackConditionalResolve = contextConf.track && hasFallbackValue && brickUtils.hasOwnProperty(contextConf.resolve, "if") && brickUtils.collectContextUsage(contextConf.resolve.if, isTemplateState ? "STATE" : isFormState ? "FORM_STATE" : "CTX").usedContexts.length > 0;
|
|
2072
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.resolve.if);
|
|
2073
|
+
useResolve = looseCheckIf$1(contextConf.resolve, mergedContext);
|
|
2074
|
+
if (useResolve || trackConditionalResolve) {
|
|
2075
|
+
load = /*#__PURE__*/function () {
|
|
2076
|
+
var _ref = _asyncToGenerator__default["default"](function* (options) {
|
|
2077
|
+
var valueConf = {};
|
|
2078
|
+
yield _internalApiGetResolver().resolveOne("reference", _objectSpread__default["default"]({
|
|
2079
|
+
transform: "value",
|
|
2080
|
+
transformMapArray: false
|
|
2081
|
+
}, contextConf.resolve), valueConf, null, mergedContext, options);
|
|
2082
|
+
return valueConf.value;
|
|
2083
|
+
});
|
|
2084
|
+
return function load(_x9) {
|
|
2085
|
+
return _ref.apply(this, arguments);
|
|
2086
|
+
};
|
|
2087
|
+
}();
|
|
1970
2088
|
}
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2089
|
+
if (useResolve) {
|
|
2090
|
+
// `async` take precedence over `lazy`
|
|
2091
|
+
resolvePolicy = contextConf.resolve.async && !isTemplateState ? "async" : contextConf.resolve.lazy ? "lazy" : "eager";
|
|
2092
|
+
if (resolvePolicy === "eager") {
|
|
2093
|
+
value = yield load();
|
|
2094
|
+
} else if (resolvePolicy === "async") {
|
|
2095
|
+
loading = load();
|
|
2096
|
+
} else if (contextConf.resolve.trigger) {
|
|
2097
|
+
var lifecycleName = contextConf.resolve.trigger;
|
|
2098
|
+
if (supportContextResolveTriggerBrickLifeCycle.includes(lifecycleName)) {
|
|
2099
|
+
var contextNameArray = storyboardContextWrapper.batchTriggerContextsNamesMap.get(lifecycleName) || [];
|
|
2100
|
+
contextNameArray.push({
|
|
2101
|
+
name: contextConf.name,
|
|
2102
|
+
type: storyboardContextWrapper.tplContextId ? "state" : "context",
|
|
2103
|
+
tplContextId: storyboardContextWrapper.tplContextId
|
|
2104
|
+
});
|
|
2105
|
+
storyboardContextWrapper.batchTriggerContextsNamesMap.set(lifecycleName, contextNameArray);
|
|
2106
|
+
} else {
|
|
2107
|
+
// eslint-disable-next-line no-console
|
|
2108
|
+
console.error("unsupported lifecycle: \"".concat(lifecycleName, "\""));
|
|
2109
|
+
}
|
|
1990
2110
|
}
|
|
1991
|
-
})
|
|
2111
|
+
} else if (!hasFallbackValue) {
|
|
2112
|
+
return false;
|
|
2113
|
+
}
|
|
1992
2114
|
}
|
|
1993
|
-
if (
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
});
|
|
1999
|
-
callbackFactory("finally")();
|
|
2000
|
-
}, err => {
|
|
2001
|
-
if (!shouldDismiss(err) && callback.error) {
|
|
2002
|
-
callbackFactory("error")(err);
|
|
2003
|
-
}
|
|
2004
|
-
callbackFactory("finally")();
|
|
2005
|
-
});
|
|
2115
|
+
if ((!useResolve || resolvePolicy !== "eager") && contextConf.value !== undefined) {
|
|
2116
|
+
yield storyboardContextWrapper.waitForUsedContext(contextConf.value);
|
|
2117
|
+
// If the context has no resolve, just use its `value`.
|
|
2118
|
+
// Or if the resolve is ignored or lazy, use its `value` as a fallback.
|
|
2119
|
+
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
2006
2120
|
}
|
|
2007
|
-
return;
|
|
2008
2121
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2122
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, resolvePolicy === "eager", loading, resolvePolicy === "async", useResolve, trackConditionalResolve);
|
|
2123
|
+
return true;
|
|
2124
|
+
});
|
|
2125
|
+
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
2126
|
+
}
|
|
2127
|
+
function syncResolveStoryboardContext(contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2128
|
+
if (!looseCheckIf$1(contextConf, mergedContext)) {
|
|
2129
|
+
return false;
|
|
2130
|
+
}
|
|
2131
|
+
if (contextConf.resolve) {
|
|
2132
|
+
throw new Error("resolve is not allowed here");
|
|
2133
|
+
}
|
|
2134
|
+
var value = getDefinedTemplateState(!!storyboardContextWrapper.tplContextId, contextConf, brick);
|
|
2135
|
+
if (value === undefined) {
|
|
2136
|
+
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
2137
|
+
}
|
|
2138
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick);
|
|
2139
|
+
return true;
|
|
2140
|
+
}
|
|
2141
|
+
function getDefinedTemplateState(isTemplateState, contextConf, brick) {
|
|
2142
|
+
if (isTemplateState && brick.properties && brickUtils.hasOwnProperty(brick.properties, contextConf.name)) {
|
|
2143
|
+
return brick.properties[contextConf.name];
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, loaded, loading, async, useResolve, trackConditionalResolve) {
|
|
2147
|
+
var newContext = {
|
|
2148
|
+
type: "free-variable",
|
|
2149
|
+
value,
|
|
2150
|
+
// This is required for tracking context, even if no `onChange` is specified.
|
|
2151
|
+
eventTarget: new EventTarget$1(),
|
|
2152
|
+
useResolve,
|
|
2153
|
+
load,
|
|
2154
|
+
loaded,
|
|
2155
|
+
loading,
|
|
2156
|
+
async,
|
|
2157
|
+
deps: []
|
|
2158
|
+
};
|
|
2159
|
+
var eventName = storyboardContextWrapper.formContextId ? "formstate.change" : storyboardContextWrapper.tplContextId ? "state.change" : "context.change";
|
|
2160
|
+
if (contextConf.onChange) {
|
|
2161
|
+
for (var handler of [].concat(contextConf.onChange)) {
|
|
2162
|
+
newContext.eventTarget.addEventListener(eventName, listenerFactory(handler, mergedContext, brick));
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
newContext.eventTarget.addEventListener(eventName, e => {
|
|
2166
|
+
storyboardContextWrapper.notifyRealTimeDataChange(contextConf.name, e.detail);
|
|
2167
|
+
});
|
|
2168
|
+
if (contextConf.track) {
|
|
2169
|
+
var isTemplateState = !!storyboardContextWrapper.tplContextId;
|
|
2170
|
+
var isFormState = !!storyboardContextWrapper.formContextId;
|
|
2171
|
+
// Track its dependencies and auto update when each of them changed.
|
|
2172
|
+
var deps = (isFormState ? brickUtils.trackUsedFormState : isTemplateState ? brickUtils.trackUsedState : brickUtils.trackUsedContext)(trackConditionalResolve ? [contextConf.resolve, contextConf.value] : load ? contextConf.resolve : contextConf.value);
|
|
2173
|
+
!load && (newContext.deps = deps);
|
|
2174
|
+
for (var dep of deps) {
|
|
2175
|
+
var _eventTarget;
|
|
2176
|
+
var ctx = storyboardContextWrapper.get().get(dep);
|
|
2177
|
+
ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(eventName, batchAddListener(() => {
|
|
2178
|
+
newContext.useResolve = trackConditionalResolve ? looseCheckIf$1(contextConf.resolve, mergedContext) : !!load;
|
|
2179
|
+
if (newContext.useResolve) {
|
|
2180
|
+
storyboardContextWrapper.updateValue(contextConf.name, {
|
|
2181
|
+
cache: "default"
|
|
2182
|
+
}, "refresh");
|
|
2183
|
+
} else {
|
|
2184
|
+
storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
|
|
2185
|
+
}
|
|
2186
|
+
}, contextConf, storyboardContextWrapper));
|
|
2019
2187
|
}
|
|
2020
|
-
if (this.batchUpdate) return;
|
|
2021
|
-
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.eventName, {
|
|
2022
|
-
detail: item.value
|
|
2023
|
-
}));
|
|
2024
2188
|
}
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
// before it's been resolved.
|
|
2189
|
+
storyboardContextWrapper.set(contextConf.name, newContext);
|
|
2190
|
+
}
|
|
2191
|
+
function batchAddListener(listener, contextConf, storyboardContextWrapper) {
|
|
2192
|
+
return event => {
|
|
2193
|
+
if (storyboardContextWrapper.batchUpdate && storyboardContextWrapper.batchUpdateContextsNames.includes(contextConf.name)) {
|
|
2031
2194
|
return;
|
|
2032
2195
|
}
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2196
|
+
listener(event);
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
var tplContextMap = new Map();
|
|
2201
|
+
class CustomTemplateContext {
|
|
2202
|
+
constructor(brick, renderId) {
|
|
2203
|
+
_defineProperty__default["default"](this, "variables", void 0);
|
|
2204
|
+
_defineProperty__default["default"](this, "state", void 0);
|
|
2205
|
+
_defineProperty__default["default"](this, "id", _.uniqueId("tpl-ctx-"));
|
|
2206
|
+
this.brick = brick;
|
|
2207
|
+
tplContextMap.set(this.id, this);
|
|
2208
|
+
this.state = new StoryboardContextWrapper(this.id, undefined, renderId);
|
|
2209
|
+
brick.tplContextId = this.id;
|
|
2038
2210
|
}
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
if (_this.tplContextId || _this.formContextId) {
|
|
2043
|
-
return;
|
|
2044
|
-
}
|
|
2045
|
-
var usage = brickUtils.collectContextUsage(data, "CTX");
|
|
2046
|
-
if (usage.includesComputed) {
|
|
2047
|
-
for (var pending of _this.pendingStack) {
|
|
2048
|
-
yield pending.pendingResult;
|
|
2049
|
-
}
|
|
2050
|
-
} else if (usage.usedContexts.length > 0) {
|
|
2051
|
-
var _loop = function* (pendingContexts) {
|
|
2052
|
-
yield Promise.all(usage.usedContexts.map(ctx => pendingContexts.get(ctx)));
|
|
2053
|
-
};
|
|
2054
|
-
for (var {
|
|
2055
|
-
pendingContexts
|
|
2056
|
-
} of _this.pendingStack) {
|
|
2057
|
-
yield* _loop(pendingContexts);
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
})();
|
|
2211
|
+
setVariables(variables) {
|
|
2212
|
+
this.variables = variables;
|
|
2213
|
+
Object.freeze(variables);
|
|
2061
2214
|
}
|
|
2062
|
-
|
|
2063
|
-
var
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2215
|
+
getVariables() {
|
|
2216
|
+
var {
|
|
2217
|
+
element
|
|
2218
|
+
} = this.brick;
|
|
2219
|
+
if (element) {
|
|
2220
|
+
return Object.fromEntries(Object.keys(this.variables).map(prop => [prop, element[prop]]));
|
|
2221
|
+
}
|
|
2222
|
+
return this.variables;
|
|
2223
|
+
}
|
|
2224
|
+
getBrick() {
|
|
2225
|
+
return this.brick;
|
|
2072
2226
|
}
|
|
2227
|
+
}
|
|
2228
|
+
function getCustomTemplateContext(tplContextId) {
|
|
2229
|
+
return tplContextMap.get(tplContextId);
|
|
2230
|
+
}
|
|
2231
|
+
function getCustomContextTriggerListByLifecycle(lifecycle) {
|
|
2232
|
+
return [...tplContextMap.values()].map(tplContext => tplContext.state.getContextTriggerSetByLifecycle(lifecycle)).filter(trigger => trigger.length > 0).flat(1);
|
|
2233
|
+
}
|
|
2073
2234
|
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2235
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2236
|
+
try {
|
|
2237
|
+
var info = gen[key](arg);
|
|
2238
|
+
var value = info.value;
|
|
2239
|
+
} catch (error) {
|
|
2240
|
+
reject(error);
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
if (info.done) {
|
|
2244
|
+
resolve(value);
|
|
2245
|
+
} else {
|
|
2246
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
function _asyncToGenerator$2(fn) {
|
|
2250
|
+
return function () {
|
|
2251
|
+
var self = this,
|
|
2252
|
+
args = arguments;
|
|
2253
|
+
return new Promise(function (resolve, reject) {
|
|
2254
|
+
var gen = fn.apply(self, args);
|
|
2255
|
+
function _next(value) {
|
|
2256
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2083
2257
|
}
|
|
2258
|
+
function _throw(err) {
|
|
2259
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2260
|
+
}
|
|
2261
|
+
_next(undefined);
|
|
2262
|
+
});
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
function _defineProperty(obj, key, value) {
|
|
2266
|
+
if (key in obj) {
|
|
2267
|
+
Object.defineProperty(obj, key, {
|
|
2268
|
+
value: value,
|
|
2269
|
+
enumerable: true,
|
|
2270
|
+
configurable: true,
|
|
2271
|
+
writable: true
|
|
2084
2272
|
});
|
|
2273
|
+
} else {
|
|
2274
|
+
obj[key] = value;
|
|
2085
2275
|
}
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2276
|
+
return obj;
|
|
2277
|
+
}
|
|
2278
|
+
function ownKeys(object, enumerableOnly) {
|
|
2279
|
+
var keys = Object.keys(object);
|
|
2280
|
+
if (Object.getOwnPropertySymbols) {
|
|
2281
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
2282
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
2283
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2284
|
+
});
|
|
2285
|
+
keys.push.apply(keys, symbols);
|
|
2286
|
+
}
|
|
2287
|
+
return keys;
|
|
2288
|
+
}
|
|
2289
|
+
function _objectSpread2(target) {
|
|
2290
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2291
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2292
|
+
if (i % 2) {
|
|
2293
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
2294
|
+
_defineProperty(target, key, source[key]);
|
|
2295
|
+
});
|
|
2296
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
2297
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
2298
|
+
} else {
|
|
2299
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
2300
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
return target;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
/**
|
|
2308
|
+
* @description 获取实例详情
|
|
2309
|
+
* @endpoint GET /object/:objectId/instance/:instanceId
|
|
2310
|
+
*/
|
|
2311
|
+
var InstanceApi_getDetail = /*#__PURE__*/function () {
|
|
2312
|
+
var _ref = _asyncToGenerator$2(function* (objectId, instanceId, params, options) {
|
|
2313
|
+
return (/**! @contract easyops.api.cmdb.instance.GetDetail */
|
|
2314
|
+
(yield brickHttp.http.get("api/gateway/cmdb.instance.GetDetail/object/".concat(objectId, "/instance/").concat(instanceId), _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2315
|
+
params
|
|
2316
|
+
}))).data
|
|
2317
|
+
);
|
|
2318
|
+
});
|
|
2319
|
+
return function InstanceApi_getDetail(_x, _x2, _x3, _x4) {
|
|
2320
|
+
return _ref.apply(this, arguments);
|
|
2321
|
+
};
|
|
2322
|
+
}();
|
|
2323
|
+
|
|
2324
|
+
/**
|
|
2325
|
+
* @description 搜索实例
|
|
2326
|
+
* @endpoint POST /object/:objectId/instance/_search
|
|
2327
|
+
*/
|
|
2328
|
+
var InstanceApi_postSearch = /*#__PURE__*/function () {
|
|
2329
|
+
var _ref = _asyncToGenerator$2(function* (objectId, data, options) {
|
|
2330
|
+
return (/**! @contract easyops.api.cmdb.instance.PostSearch */
|
|
2331
|
+
(yield brickHttp.http.post("api/gateway/cmdb.instance.PostSearch/object/".concat(objectId, "/instance/_search"), data, options)).data
|
|
2332
|
+
);
|
|
2333
|
+
});
|
|
2334
|
+
return function InstanceApi_postSearch(_x, _x2, _x3) {
|
|
2335
|
+
return _ref.apply(this, arguments);
|
|
2336
|
+
};
|
|
2337
|
+
}();
|
|
2338
|
+
|
|
2339
|
+
var _excluded$8 = ["children"],
|
|
2340
|
+
_excluded2$2 = ["children"],
|
|
2341
|
+
_excluded3 = ["items", "app"];
|
|
2342
|
+
var symbolAppId = Symbol("appId");
|
|
2343
|
+
var symbolMenuI18nNamespace = Symbol("menuI18nNamespace");
|
|
2344
|
+
var symbolOverrideApp = Symbol("overrideApp");
|
|
2345
|
+
var symbolShouldCache = Symbol("shouldCache");
|
|
2346
|
+
// Caching menu requests to avoid flicker.
|
|
2347
|
+
var menuCache = new Map();
|
|
2348
|
+
var menuTitleCache = new Map();
|
|
2349
|
+
var processMenuCache = new Map();
|
|
2350
|
+
function constructMenu(_x, _x2, _x3) {
|
|
2351
|
+
return _constructMenu.apply(this, arguments);
|
|
2352
|
+
}
|
|
2353
|
+
function _constructMenu() {
|
|
2354
|
+
_constructMenu = _asyncToGenerator__default["default"](function* (menuBar, context, kernel) {
|
|
2355
|
+
var hasSubMenu = !!menuBar.subMenuId;
|
|
2356
|
+
yield Promise.all([_asyncToGenerator__default["default"](function* () {
|
|
2357
|
+
if (menuBar.menuId) {
|
|
2358
|
+
var _menuBar$menu;
|
|
2359
|
+
var defaultCollapsed = (_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed;
|
|
2360
|
+
var menu = yield processMenu(menuBar.menuId, context, kernel, hasSubMenu);
|
|
2361
|
+
if (!_.isNil(defaultCollapsed)) {
|
|
2362
|
+
menu.defaultCollapsed = defaultCollapsed;
|
|
2363
|
+
}
|
|
2364
|
+
menuBar.menu = menu;
|
|
2365
|
+
}
|
|
2366
|
+
})(), _asyncToGenerator__default["default"](function* () {
|
|
2367
|
+
if (hasSubMenu) {
|
|
2368
|
+
menuBar.subMenu = yield processMenu(menuBar.subMenuId, context, kernel);
|
|
2369
|
+
} else {
|
|
2370
|
+
menuBar.subMenu = null;
|
|
2371
|
+
}
|
|
2372
|
+
})()]);
|
|
2373
|
+
});
|
|
2374
|
+
return _constructMenu.apply(this, arguments);
|
|
2375
|
+
}
|
|
2376
|
+
function preConstructMenus(_x4, _x5, _x6) {
|
|
2377
|
+
return _preConstructMenus.apply(this, arguments);
|
|
2378
|
+
}
|
|
2379
|
+
function _preConstructMenus() {
|
|
2380
|
+
_preConstructMenus = _asyncToGenerator__default["default"](function* (menus, context, kernel) {
|
|
2381
|
+
var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel, undefined, true)));
|
|
2382
|
+
data.forEach((item, index) => processMenuCache.set(menus[index], item));
|
|
2383
|
+
});
|
|
2384
|
+
return _preConstructMenus.apply(this, arguments);
|
|
2385
|
+
}
|
|
2386
|
+
var getMenu = menuId => processMenuCache.get(menuId);
|
|
2387
|
+
function fetchMenuById(_x7, _x8, _x9) {
|
|
2388
|
+
return _fetchMenuById.apply(this, arguments);
|
|
2389
|
+
}
|
|
2390
|
+
function _fetchMenuById() {
|
|
2391
|
+
_fetchMenuById = _asyncToGenerator__default["default"](function* (menuId, kernel, isPreFetch) {
|
|
2392
|
+
if (menuCache.has(menuId)) {
|
|
2393
|
+
return menuCache.get(menuId);
|
|
2094
2394
|
}
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2395
|
+
var menuList = window.STANDALONE_MICRO_APPS ? yield kernel.getStandaloneMenus(menuId, isPreFetch) : kernel.getFeatureFlags()["three-level-menu-layout"] ? (yield InstalledMicroAppApi_getMenusInfo(menuId, {
|
|
2396
|
+
menuObjectId: "EASYOPS_STORYBOARD_MENU"
|
|
2397
|
+
})).menus : (yield InstanceApi_postSearch("EASYOPS_STORYBOARD_MENU", {
|
|
2398
|
+
page: 1,
|
|
2399
|
+
page_size: 200,
|
|
2400
|
+
fields: {
|
|
2401
|
+
menuId: true,
|
|
2402
|
+
title: true,
|
|
2403
|
+
icon: true,
|
|
2404
|
+
link: true,
|
|
2405
|
+
titleDataSource: true,
|
|
2406
|
+
defaultCollapsed: true,
|
|
2407
|
+
defaultCollapsedBreakpoint: true,
|
|
2408
|
+
type: true,
|
|
2409
|
+
injectMenuGroupId: true,
|
|
2410
|
+
dynamicItems: true,
|
|
2411
|
+
itemsResolve: true,
|
|
2412
|
+
items: true,
|
|
2413
|
+
i18n: true,
|
|
2414
|
+
"items.children": true,
|
|
2415
|
+
"app.appId": true
|
|
2416
|
+
},
|
|
2417
|
+
query: {
|
|
2418
|
+
menuId: {
|
|
2419
|
+
$eq: menuId
|
|
2420
|
+
},
|
|
2421
|
+
app: {
|
|
2422
|
+
$size: {
|
|
2423
|
+
$gt: 0
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2105
2426
|
}
|
|
2106
|
-
})
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
var {
|
|
2111
|
-
mergedContext,
|
|
2112
|
-
keyword
|
|
2113
|
-
} = this.getResolveOptions(coreContext);
|
|
2114
|
-
brickUtils.syncResolveContextConcurrently(contextConfs, contextConf => syncResolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
|
|
2427
|
+
})).list;
|
|
2428
|
+
var menuData = yield mergeMenu(menuList, kernel);
|
|
2429
|
+
if (!menuData) {
|
|
2430
|
+
throw new Error("Menu not found: ".concat(menuId));
|
|
2115
2431
|
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
return
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
}),
|
|
2122
|
-
keyword: "FORM_STATE"
|
|
2123
|
-
} : this.tplContextId ? {
|
|
2124
|
-
mergedContext: _objectSpread__default["default"](_objectSpread__default["default"]({}, coreContext), {}, {
|
|
2125
|
-
tplContextId: this.tplContextId
|
|
2126
|
-
}),
|
|
2127
|
-
keyword: "STATE"
|
|
2128
|
-
} : {
|
|
2129
|
-
mergedContext: coreContext,
|
|
2130
|
-
keyword: "CTX"
|
|
2131
|
-
};
|
|
2132
|
-
}
|
|
2133
|
-
getContextTriggerSetByLifecycle(lifecycle) {
|
|
2134
|
-
return this.batchTriggerContextsNamesMap.get(lifecycle) || [];
|
|
2135
|
-
}
|
|
2432
|
+
reorderMenu(menuData);
|
|
2433
|
+
menuData[symbolShouldCache] && menuCache.set(menuId, menuData);
|
|
2434
|
+
return menuData;
|
|
2435
|
+
});
|
|
2436
|
+
return _fetchMenuById.apply(this, arguments);
|
|
2136
2437
|
}
|
|
2137
|
-
function
|
|
2138
|
-
return
|
|
2438
|
+
function mergeMenu(_x10, _x11) {
|
|
2439
|
+
return _mergeMenu.apply(this, arguments);
|
|
2139
2440
|
}
|
|
2140
|
-
function
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2441
|
+
function _mergeMenu() {
|
|
2442
|
+
_mergeMenu = _asyncToGenerator__default["default"](function* (menuList, kernel) {
|
|
2443
|
+
var mainMenu = menuList.find(menu => menu.type !== "inject");
|
|
2444
|
+
if (!mainMenu) {
|
|
2445
|
+
return undefined;
|
|
2446
|
+
}
|
|
2447
|
+
var validMenuList = [];
|
|
2448
|
+
var injectWithMenus = new Map();
|
|
2449
|
+
var menuWithI18n = new WeakMap();
|
|
2450
|
+
for (var menu of menuList) {
|
|
2451
|
+
if (menu.i18n) {
|
|
2452
|
+
(function () {
|
|
2453
|
+
var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId));
|
|
2454
|
+
// Support any language in `meta.i18n`.
|
|
2455
|
+
Object.entries(menu.i18n).forEach(_ref6 => {
|
|
2456
|
+
var [lang, resources] = _ref6;
|
|
2457
|
+
i18next__default["default"].addResourceBundle(lang, menuI18nNamespace, resources);
|
|
2458
|
+
});
|
|
2459
|
+
menuWithI18n.set(menu, menuI18nNamespace);
|
|
2460
|
+
})();
|
|
2145
2461
|
}
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2462
|
+
}
|
|
2463
|
+
var shouldCacheList = yield Promise.all(menuList.map(menu => loadDynamicMenuItems(menu, kernel, menuWithI18n)));
|
|
2464
|
+
for (var _menu of menuList) {
|
|
2465
|
+
var _menu$items;
|
|
2466
|
+
if (((_menu$items = _menu.items) === null || _menu$items === void 0 ? void 0 : _menu$items.length) > 0) {
|
|
2467
|
+
if (_menu.type === "inject" && _menu.injectMenuGroupId) {
|
|
2468
|
+
var injectingMenus = injectWithMenus.get(_menu.injectMenuGroupId);
|
|
2469
|
+
if (!injectingMenus) {
|
|
2470
|
+
injectingMenus = [];
|
|
2471
|
+
injectWithMenus.set(_menu.injectMenuGroupId, injectingMenus);
|
|
2472
|
+
}
|
|
2473
|
+
injectingMenus.push(_menu);
|
|
2474
|
+
} else {
|
|
2475
|
+
validMenuList.push(_menu);
|
|
2476
|
+
}
|
|
2152
2477
|
}
|
|
2153
|
-
return true;
|
|
2154
2478
|
}
|
|
2155
|
-
return
|
|
2479
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, mainMenu), {}, {
|
|
2480
|
+
items: validMenuList.flatMap(menu => processGroupInject(menu.items, menu, injectWithMenus, menuWithI18n)),
|
|
2481
|
+
[symbolShouldCache]: shouldCacheList.every(Boolean),
|
|
2482
|
+
[symbolMenuI18nNamespace]: menuWithI18n.get(mainMenu),
|
|
2483
|
+
[symbolOverrideApp]: mainMenu.overrideApp
|
|
2484
|
+
});
|
|
2156
2485
|
});
|
|
2157
|
-
return
|
|
2158
|
-
}
|
|
2159
|
-
var supportContextResolveTriggerBrickLifeCycle = ["onBeforePageLoad", "onPageLoad", "onBeforePageLeave", "onPageLeave", "onAnchorLoad", "onAnchorUnload"];
|
|
2160
|
-
function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
|
|
2161
|
-
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
2486
|
+
return _mergeMenu.apply(this, arguments);
|
|
2162
2487
|
}
|
|
2163
|
-
function
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2488
|
+
function processGroupInject(items, menu, injectWithMenus, menuWithI18n) {
|
|
2489
|
+
return items === null || items === void 0 ? void 0 : items.map(item => {
|
|
2490
|
+
var _processGroupInject;
|
|
2491
|
+
var foundInjectingMenus = item.groupId && injectWithMenus.get(item.groupId);
|
|
2492
|
+
if (foundInjectingMenus) {
|
|
2493
|
+
// Each menu to be injected with should be injected only once.
|
|
2494
|
+
injectWithMenus.delete(item.groupId);
|
|
2168
2495
|
}
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
transform: "value",
|
|
2193
|
-
transformMapArray: false
|
|
2194
|
-
}, contextConf.resolve), valueConf, null, mergedContext, options);
|
|
2195
|
-
return valueConf.value;
|
|
2196
|
-
});
|
|
2197
|
-
return function load(_x9) {
|
|
2198
|
-
return _ref.apply(this, arguments);
|
|
2199
|
-
};
|
|
2200
|
-
}();
|
|
2201
|
-
}
|
|
2202
|
-
if (useResolve) {
|
|
2203
|
-
// `async` take precedence over `lazy`
|
|
2204
|
-
resolvePolicy = contextConf.resolve.async && !isTemplateState ? "async" : contextConf.resolve.lazy ? "lazy" : "eager";
|
|
2205
|
-
if (resolvePolicy === "eager") {
|
|
2206
|
-
value = yield load();
|
|
2207
|
-
} else if (resolvePolicy === "async") {
|
|
2208
|
-
loading = load();
|
|
2209
|
-
} else if (contextConf.resolve.trigger) {
|
|
2210
|
-
var lifecycleName = contextConf.resolve.trigger;
|
|
2211
|
-
if (supportContextResolveTriggerBrickLifeCycle.includes(lifecycleName)) {
|
|
2212
|
-
var contextNameArray = storyboardContextWrapper.batchTriggerContextsNamesMap.get(lifecycleName) || [];
|
|
2213
|
-
contextNameArray.push({
|
|
2214
|
-
name: contextConf.name,
|
|
2215
|
-
type: storyboardContextWrapper.tplContextId ? "state" : "context",
|
|
2216
|
-
tplContextId: storyboardContextWrapper.tplContextId
|
|
2217
|
-
});
|
|
2218
|
-
storyboardContextWrapper.batchTriggerContextsNamesMap.set(lifecycleName, contextNameArray);
|
|
2219
|
-
} else {
|
|
2220
|
-
// eslint-disable-next-line no-console
|
|
2221
|
-
console.error("unsupported lifecycle: \"".concat(lifecycleName, "\""));
|
|
2222
|
-
}
|
|
2496
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
|
|
2497
|
+
children: ((_processGroupInject = processGroupInject(item.children || item.items, menu, injectWithMenus, menuWithI18n)) !== null && _processGroupInject !== void 0 ? _processGroupInject : []).concat(foundInjectingMenus ? foundInjectingMenus.flatMap(injectingMenu => processGroupInject(injectingMenu.items, injectingMenu, injectWithMenus, menuWithI18n)) : []),
|
|
2498
|
+
[symbolAppId]: menu.app[0].appId,
|
|
2499
|
+
[symbolMenuI18nNamespace]: menuWithI18n.get(menu),
|
|
2500
|
+
[symbolOverrideApp]: menu.overrideApp
|
|
2501
|
+
});
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
function loadDynamicMenuItems(_x12, _x13, _x14) {
|
|
2505
|
+
return _loadDynamicMenuItems.apply(this, arguments);
|
|
2506
|
+
}
|
|
2507
|
+
function _loadDynamicMenuItems() {
|
|
2508
|
+
_loadDynamicMenuItems = _asyncToGenerator__default["default"](function* (menu, kernel, menuWithI18n) {
|
|
2509
|
+
if (menu.dynamicItems && menu.itemsResolve) {
|
|
2510
|
+
var _menu$itemsResolve;
|
|
2511
|
+
var itemsConf = {};
|
|
2512
|
+
var overrideAppId = menu.app[0].appId;
|
|
2513
|
+
var context = _internalApiGetCurrentContext();
|
|
2514
|
+
var newContext = context;
|
|
2515
|
+
if (overrideAppId !== context.app.id && attemptToVisit(menu.itemsResolve, ["APP", "I18N"])) {
|
|
2516
|
+
if (window.STANDALONE_MICRO_APPS) {
|
|
2517
|
+
if (menu.overrideApp) {
|
|
2518
|
+
menu.overrideApp.config = brickUtils.deepFreeze(_.merge({}, menu.overrideApp.defaultConfig, menu.overrideApp.userConfig));
|
|
2223
2519
|
}
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2520
|
+
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
2521
|
+
overrideApp: menu.overrideApp,
|
|
2522
|
+
appendI18nNamespace: menuWithI18n.get(menu)
|
|
2523
|
+
});
|
|
2524
|
+
} else {
|
|
2525
|
+
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
2526
|
+
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
2527
|
+
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
2528
|
+
appendI18nNamespace: menuWithI18n.get(menu)
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
var usedActions = brickUtils.scanPermissionActionsInAny(menu.itemsResolve);
|
|
2533
|
+
yield validatePermissions(usedActions);
|
|
2534
|
+
yield _internalApiGetResolver().resolveOne("reference", _objectSpread__default["default"]({
|
|
2535
|
+
transform: "items",
|
|
2536
|
+
transformMapArray: false
|
|
2537
|
+
}, menu.itemsResolve), itemsConf, null, newContext);
|
|
2538
|
+
menu.items = itemsConf.items;
|
|
2539
|
+
if ((_menu$itemsResolve = menu.itemsResolve) !== null && _menu$itemsResolve !== void 0 && _menu$itemsResolve.args) {
|
|
2540
|
+
var _menu$itemsResolve2;
|
|
2541
|
+
return !attemptToVisit((_menu$itemsResolve2 = menu.itemsResolve) === null || _menu$itemsResolve2 === void 0 ? void 0 : _menu$itemsResolve2.args, ["QUERY", "PATH"]);
|
|
2233
2542
|
}
|
|
2234
2543
|
}
|
|
2235
|
-
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick, load, resolvePolicy === "eager", loading, resolvePolicy === "async", useResolve, trackConditionalResolve);
|
|
2236
2544
|
return true;
|
|
2237
2545
|
});
|
|
2238
|
-
return
|
|
2546
|
+
return _loadDynamicMenuItems.apply(this, arguments);
|
|
2239
2547
|
}
|
|
2240
|
-
function
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2548
|
+
function walkMenuItems(menuItems) {
|
|
2549
|
+
return menuItems === null || menuItems === void 0 ? void 0 : menuItems.filter(
|
|
2550
|
+
// `if` is already evaluated.
|
|
2551
|
+
looseCheckIfOfComputed).map(item => {
|
|
2552
|
+
var children = walkMenuItems(item.children || item.items);
|
|
2553
|
+
return item.type === "group" ? {
|
|
2554
|
+
type: "group",
|
|
2555
|
+
childLayout: item.childLayout,
|
|
2556
|
+
title: item.text || item.title,
|
|
2557
|
+
items: children,
|
|
2558
|
+
groupId: item.groupId,
|
|
2559
|
+
groupFrom: item.groupFrom
|
|
2560
|
+
} : children !== null && children !== void 0 && children.length ? {
|
|
2561
|
+
type: "subMenu",
|
|
2562
|
+
childLayout: item.childLayout,
|
|
2563
|
+
title: item.text || item.title,
|
|
2564
|
+
icon: item.icon,
|
|
2565
|
+
items: children,
|
|
2566
|
+
defaultExpanded: item.defaultExpanded
|
|
2567
|
+
} : item;
|
|
2568
|
+
});
|
|
2253
2569
|
}
|
|
2254
|
-
function
|
|
2255
|
-
|
|
2256
|
-
return brick.properties[contextConf.name];
|
|
2257
|
-
}
|
|
2570
|
+
function processMenu(_x15, _x16, _x17, _x18, _x19) {
|
|
2571
|
+
return _processMenu.apply(this, arguments);
|
|
2258
2572
|
}
|
|
2259
|
-
function
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
if (contextConf.onChange) {
|
|
2274
|
-
for (var handler of [].concat(contextConf.onChange)) {
|
|
2275
|
-
newContext.eventTarget.addEventListener(eventName, listenerFactory(handler, mergedContext, brick));
|
|
2573
|
+
function _processMenu() {
|
|
2574
|
+
_processMenu = _asyncToGenerator__default["default"](function* (menuId, context, kernel, hasSubMenu, isPreFetch) {
|
|
2575
|
+
var _yield$fetchMenuById = yield fetchMenuById(menuId, kernel, isPreFetch),
|
|
2576
|
+
{
|
|
2577
|
+
items,
|
|
2578
|
+
app
|
|
2579
|
+
} = _yield$fetchMenuById,
|
|
2580
|
+
restMenuData = _objectWithoutProperties__default["default"](_yield$fetchMenuById, _excluded3);
|
|
2581
|
+
var usedActions = brickUtils.scanPermissionActionsInAny([items, restMenuData]);
|
|
2582
|
+
yield validatePermissions(usedActions);
|
|
2583
|
+
var appsRequireI18nFulfilled = new Set();
|
|
2584
|
+
var rootAppId = app[0].appId;
|
|
2585
|
+
if (rootAppId !== context.app.id && !restMenuData[symbolMenuI18nNamespace]) {
|
|
2586
|
+
appsRequireI18nFulfilled.add(rootAppId);
|
|
2276
2587
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2588
|
+
collectAppsRequireI18nFulfilled(items, context.app.id, appsRequireI18nFulfilled);
|
|
2589
|
+
yield kernel.fulfilStoryboardI18n([...appsRequireI18nFulfilled]);
|
|
2590
|
+
var menuData = _objectSpread__default["default"](_objectSpread__default["default"]({}, yield computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
2591
|
+
items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
2592
|
+
});
|
|
2593
|
+
return {
|
|
2594
|
+
title: yield processMenuTitle(menuData),
|
|
2595
|
+
icon: menuData.icon,
|
|
2596
|
+
link: menuData.link,
|
|
2597
|
+
menuItems: walkMenuItems(menuData.items),
|
|
2598
|
+
defaultCollapsed: menuData.defaultCollapsed || hasSubMenu,
|
|
2599
|
+
defaultCollapsedBreakpoint: menuData.defaultCollapsedBreakpoint
|
|
2600
|
+
};
|
|
2280
2601
|
});
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
}, "refresh");
|
|
2296
|
-
} else {
|
|
2297
|
-
storyboardContextWrapper.updateValue(contextConf.name, computeRealValue(contextConf.value, mergedContext, true), "replace");
|
|
2298
|
-
}
|
|
2299
|
-
}, contextConf, storyboardContextWrapper));
|
|
2602
|
+
return _processMenu.apply(this, arguments);
|
|
2603
|
+
}
|
|
2604
|
+
function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
|
|
2605
|
+
function collect(items) {
|
|
2606
|
+
for (var _ref of items) {
|
|
2607
|
+
var {
|
|
2608
|
+
children
|
|
2609
|
+
} = _ref,
|
|
2610
|
+
rest = _objectWithoutProperties__default["default"](_ref, _excluded$8);
|
|
2611
|
+
var overrideAppId = rest[symbolAppId];
|
|
2612
|
+
if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
|
|
2613
|
+
appIds.add(overrideAppId);
|
|
2614
|
+
}
|
|
2615
|
+
children && collect(children);
|
|
2300
2616
|
}
|
|
2301
2617
|
}
|
|
2302
|
-
|
|
2618
|
+
collect(items);
|
|
2303
2619
|
}
|
|
2304
|
-
function
|
|
2305
|
-
return
|
|
2306
|
-
|
|
2307
|
-
|
|
2620
|
+
function computeMenuItemsWithOverrideApp(items, context, kernel) {
|
|
2621
|
+
return Promise.all(items.map( /*#__PURE__*/function () {
|
|
2622
|
+
var _ref3 = _asyncToGenerator__default["default"](function* (_ref2) {
|
|
2623
|
+
var {
|
|
2624
|
+
children
|
|
2625
|
+
} = _ref2,
|
|
2626
|
+
rest = _objectWithoutProperties__default["default"](_ref2, _excluded2$2);
|
|
2627
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, yield computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
|
|
2628
|
+
children: children && (yield computeMenuItemsWithOverrideApp(children, context, kernel))
|
|
2629
|
+
});
|
|
2630
|
+
});
|
|
2631
|
+
return function (_x20) {
|
|
2632
|
+
return _ref3.apply(this, arguments);
|
|
2633
|
+
};
|
|
2634
|
+
}()));
|
|
2635
|
+
}
|
|
2636
|
+
function processMenuTitle(_x21) {
|
|
2637
|
+
return _processMenuTitle.apply(this, arguments);
|
|
2638
|
+
}
|
|
2639
|
+
function _processMenuTitle() {
|
|
2640
|
+
_processMenuTitle = _asyncToGenerator__default["default"](function* (menuData) {
|
|
2641
|
+
if (menuData.title || _.isEmpty(menuData.titleDataSource)) {
|
|
2642
|
+
return menuData.title;
|
|
2308
2643
|
}
|
|
2309
|
-
|
|
2310
|
-
|
|
2644
|
+
var cacheKey = JSON.stringify(menuData.titleDataSource);
|
|
2645
|
+
if (menuTitleCache.has(cacheKey)) {
|
|
2646
|
+
return menuTitleCache.get(cacheKey);
|
|
2647
|
+
}
|
|
2648
|
+
var {
|
|
2649
|
+
objectId,
|
|
2650
|
+
instanceId,
|
|
2651
|
+
attributeId
|
|
2652
|
+
} = menuData.titleDataSource;
|
|
2653
|
+
var attr = attributeId !== null && attributeId !== void 0 ? attributeId : "name";
|
|
2654
|
+
var instanceData = yield InstanceApi_getDetail(objectId, instanceId, {
|
|
2655
|
+
fields: attr
|
|
2656
|
+
});
|
|
2657
|
+
var title;
|
|
2658
|
+
if (attributeId === "#showKey" && Array.isArray(instanceData[attr])) {
|
|
2659
|
+
var [primary, ...rest] = instanceData[attr];
|
|
2660
|
+
title = rest.length > 0 ? "".concat(primary, "(").concat(rest.join(","), ")") : String(primary);
|
|
2661
|
+
} else {
|
|
2662
|
+
title = String(instanceData[attr]);
|
|
2663
|
+
}
|
|
2664
|
+
menuTitleCache.set(cacheKey, title);
|
|
2665
|
+
return title;
|
|
2666
|
+
});
|
|
2667
|
+
return _processMenuTitle.apply(this, arguments);
|
|
2668
|
+
}
|
|
2669
|
+
function clearMenuTitleCache() {
|
|
2670
|
+
menuTitleCache.clear();
|
|
2671
|
+
}
|
|
2672
|
+
function clearMenuCache() {
|
|
2673
|
+
menuCache.clear();
|
|
2674
|
+
}
|
|
2675
|
+
function reorderMenu(menuData) {
|
|
2676
|
+
menuData.items = reorderMenuItems(menuData.items);
|
|
2677
|
+
}
|
|
2678
|
+
function reorderMenuItems(list) {
|
|
2679
|
+
return sortMenuItems(list).map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
|
|
2680
|
+
children: reorderMenuItems(item.children)
|
|
2681
|
+
}));
|
|
2682
|
+
}
|
|
2683
|
+
function sortMenuItems(list) {
|
|
2684
|
+
return _.sortBy(list, item => {
|
|
2685
|
+
var _item$sort;
|
|
2686
|
+
return (_item$sort = item.sort) !== null && _item$sort !== void 0 ? _item$sort : -Infinity;
|
|
2687
|
+
});
|
|
2311
2688
|
}
|
|
2312
2689
|
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
var {
|
|
2330
|
-
element
|
|
2331
|
-
} = this.brick;
|
|
2332
|
-
if (element) {
|
|
2333
|
-
return Object.fromEntries(Object.keys(this.variables).map(prop => [prop, element[prop]]));
|
|
2690
|
+
/**
|
|
2691
|
+
* If the menu contains evaluations which use `APP` or `I18N`,
|
|
2692
|
+
* we have to override app in context when computing real values.
|
|
2693
|
+
*/
|
|
2694
|
+
function attemptToVisit(data, globals) {
|
|
2695
|
+
var memo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakSet();
|
|
2696
|
+
if (typeof data === "string") {
|
|
2697
|
+
if (brickUtils.isEvaluable(data)) {
|
|
2698
|
+
if (globals.some(key => data.includes(key))) {
|
|
2699
|
+
var {
|
|
2700
|
+
attemptToVisitGlobals
|
|
2701
|
+
} = brickUtils.preevaluate(data);
|
|
2702
|
+
return globals.some(key => attemptToVisitGlobals.has(key));
|
|
2703
|
+
}
|
|
2704
|
+
} else if (globals.includes("APP")) {
|
|
2705
|
+
return /\${\s*APP\s*\./.test(data);
|
|
2334
2706
|
}
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2707
|
+
} else if (brickUtils.isObject(data)) {
|
|
2708
|
+
// Avoid call stack overflow.
|
|
2709
|
+
// istanbul ignore next
|
|
2710
|
+
if (memo.has(data)) {
|
|
2711
|
+
return false;
|
|
2712
|
+
}
|
|
2713
|
+
memo.add(data);
|
|
2714
|
+
return (Array.isArray(data) ? data : Object.values(data)).some(item => attemptToVisit(item, globals, memo));
|
|
2339
2715
|
}
|
|
2716
|
+
return false;
|
|
2340
2717
|
}
|
|
2341
|
-
function
|
|
2342
|
-
return
|
|
2718
|
+
function computeRealValueWithOverrideApp(_x22, _x23, _x24, _x25) {
|
|
2719
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
2343
2720
|
}
|
|
2344
|
-
function
|
|
2345
|
-
|
|
2721
|
+
function _computeRealValueWithOverrideApp() {
|
|
2722
|
+
_computeRealValueWithOverrideApp = _asyncToGenerator__default["default"](function* (data, overrideAppId, context, kernel) {
|
|
2723
|
+
if ("titleDataSource" in data && brickUtils.isObject(data.titleDataSource) && Object.entries(data.titleDataSource).every(_ref7 => {
|
|
2724
|
+
var [key, value] = _ref7;
|
|
2725
|
+
return value === null || value === "";
|
|
2726
|
+
})) {
|
|
2727
|
+
delete data.titleDataSource;
|
|
2728
|
+
}
|
|
2729
|
+
if ("if" in data && data.if === null) {
|
|
2730
|
+
delete data.if;
|
|
2731
|
+
}
|
|
2732
|
+
if ("to" in data && data.to && !brickUtils.isEvaluable(data.to)) {
|
|
2733
|
+
var yaml = pipes.pipes.yaml(data.to);
|
|
2734
|
+
if (brickUtils.isObject(yaml) && ["pathname", "search", "hash"].some(key => brickUtils.hasOwnProperty(yaml, key))) {
|
|
2735
|
+
data.to = yaml;
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
var newContext = context;
|
|
2739
|
+
if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N", "IMG"])) {
|
|
2740
|
+
if (window.STANDALONE_MICRO_APPS) {
|
|
2741
|
+
if (data[symbolOverrideApp]) {
|
|
2742
|
+
data[symbolOverrideApp].config = brickUtils.deepFreeze(_.merge({}, data[symbolOverrideApp].defaultConfig, data[symbolOverrideApp].userConfig));
|
|
2743
|
+
}
|
|
2744
|
+
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
2745
|
+
overrideApp: data[symbolOverrideApp],
|
|
2746
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
2747
|
+
});
|
|
2748
|
+
} else {
|
|
2749
|
+
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
2750
|
+
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
2751
|
+
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
2752
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
var processors = brickUtils.scanProcessorsInAny(data);
|
|
2757
|
+
yield kernel.loadDynamicBricks([], processors);
|
|
2758
|
+
yield kernel.router.waitForUsedContext(data);
|
|
2759
|
+
return computeRealValue(data, newContext, true, {
|
|
2760
|
+
ignoreSymbols: true
|
|
2761
|
+
});
|
|
2762
|
+
});
|
|
2763
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
2346
2764
|
}
|
|
2347
2765
|
|
|
2348
2766
|
var MediaBreakpoint;
|
|
@@ -2440,1027 +2858,610 @@
|
|
|
2440
2858
|
return;
|
|
2441
2859
|
}
|
|
2442
2860
|
if (typeof raw !== "string") {
|
|
2443
|
-
// If the `raw` is not a string, it must be a pre-evaluated object.
|
|
2444
|
-
// Then fulfil the context, and restore the original `raw`.
|
|
2445
|
-
runtimeContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, raw[symbolForContext]), runtimeContext);
|
|
2446
|
-
raw = raw[symbolForRaw];
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
// A `SyntaxError` maybe thrown.
|
|
2450
|
-
var precooked;
|
|
2451
|
-
try {
|
|
2452
|
-
precooked = brickUtils.preevaluate(raw);
|
|
2453
|
-
} catch (error) {
|
|
2454
|
-
var message = "".concat(error.message, ", in \"").concat(raw, "\"");
|
|
2455
|
-
if (options.isReEvaluation) {
|
|
2456
|
-
devtoolsHookEmit("re-evaluation", {
|
|
2457
|
-
id: options.evaluationId,
|
|
2458
|
-
detail: {
|
|
2459
|
-
raw,
|
|
2460
|
-
context: {}
|
|
2461
|
-
},
|
|
2462
|
-
error: message
|
|
2463
|
-
});
|
|
2464
|
-
return;
|
|
2465
|
-
} else {
|
|
2466
|
-
var errorConstructor = getCookErrorConstructor(error);
|
|
2467
|
-
throw new errorConstructor(message);
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
var globalVariables = {};
|
|
2471
|
-
var attemptToVisitGlobals = precooked.attemptToVisitGlobals;
|
|
2472
|
-
var attemptToVisitEvent = attemptToVisitGlobals.has("EVENT");
|
|
2473
|
-
var attemptToVisitData = attemptToVisitGlobals.has("DATA");
|
|
2474
|
-
var attemptToVisitTpl = attemptToVisitGlobals.has("TPL");
|
|
2475
|
-
var attemptToVisitState = attemptToVisitGlobals.has("STATE");
|
|
2476
|
-
var attemptToVisitFormState = attemptToVisitGlobals.has("FORM_STATE");
|
|
2477
|
-
var attemptToVisitTplOrState = attemptToVisitTpl || attemptToVisitState;
|
|
2478
|
-
|
|
2479
|
-
// Ignore evaluating if `event` is missing in context.
|
|
2480
|
-
// Since it should be evaluated during events handling.
|
|
2481
|
-
var missingEvent = options.lazy === true;
|
|
2482
|
-
if (attemptToVisitEvent) {
|
|
2483
|
-
if (brickUtils.hasOwnProperty(runtimeContext, "event")) {
|
|
2484
|
-
globalVariables.EVENT = runtimeContext.event;
|
|
2485
|
-
} else {
|
|
2486
|
-
// Let's see if pre-evaluation is required (store the `data` in context).
|
|
2487
|
-
missingEvent = true;
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
var missingTplOrState = attemptToVisitTplOrState && !brickUtils.hasOwnProperty(runtimeContext, "tplContextId");
|
|
2491
|
-
var missingData = attemptToVisitData && !brickUtils.hasOwnProperty(runtimeContext, "data");
|
|
2492
|
-
var rawWithContext = Object.keys(runtimeContext).length > 0 ? {
|
|
2493
|
-
[symbolForRaw]: raw,
|
|
2494
|
-
[symbolForContext]: runtimeContext
|
|
2495
|
-
} : raw;
|
|
2496
|
-
|
|
2497
|
-
// Since `EVENT`, `DATA`, `TPL` and `STATE` are provided in different context,
|
|
2498
|
-
// whenever missing one of them, memorize the current context for later consuming.
|
|
2499
|
-
if (missingEvent || missingData || missingTplOrState) {
|
|
2500
|
-
return rawWithContext;
|
|
2501
|
-
}
|
|
2502
|
-
if (attemptToVisitData) {
|
|
2503
|
-
globalVariables.DATA = runtimeContext.data;
|
|
2504
|
-
}
|
|
2505
|
-
if (attemptToVisitTplOrState && runtimeContext.tplContextId) {
|
|
2506
|
-
var tplContext = getCustomTemplateContext(runtimeContext.tplContextId);
|
|
2507
|
-
if (attemptToVisitTpl) {
|
|
2508
|
-
globalVariables.TPL = tplContext.getVariables();
|
|
2509
|
-
}
|
|
2510
|
-
if (attemptToVisitState) {
|
|
2511
|
-
globalVariables.STATE = getDynamicReadOnlyProxy({
|
|
2512
|
-
get(target, key) {
|
|
2513
|
-
return tplContext.state.getValue(key);
|
|
2514
|
-
},
|
|
2515
|
-
ownKeys() {
|
|
2516
|
-
return Array.from(tplContext.state.get().keys());
|
|
2517
|
-
}
|
|
2518
|
-
});
|
|
2519
|
-
}
|
|
2520
|
-
}
|
|
2521
|
-
if (attemptToVisitFormState && runtimeContext.formContextId) {
|
|
2522
|
-
var formContext = getCustomFormContext(runtimeContext.formContextId);
|
|
2523
|
-
globalVariables.FORM_STATE = getDynamicReadOnlyProxy({
|
|
2524
|
-
get(target, key) {
|
|
2525
|
-
return formContext.formState.getValue(key);
|
|
2526
|
-
},
|
|
2527
|
-
ownKeys() {
|
|
2528
|
-
return Array.from(formContext.formState.get().keys());
|
|
2529
|
-
}
|
|
2530
|
-
});
|
|
2531
|
-
}
|
|
2532
|
-
var internalContext = _internalApiGetCurrentContext();
|
|
2533
|
-
var mergedContext = {};
|
|
2534
|
-
|
|
2535
|
-
// Use runtime context over internal context.
|
|
2536
|
-
// Internal context such as `match`, maybe change after `history.push`.
|
|
2537
|
-
// So we prefer memoized runtime context.
|
|
2538
|
-
for (var key of ["query", "match", "hash", "pathname", "app", "segues"]) {
|
|
2539
|
-
mergedContext[key] = (brickUtils.hasOwnProperty(runtimeContext, key) ? runtimeContext : internalContext)[key];
|
|
2540
|
-
}
|
|
2541
|
-
var {
|
|
2542
|
-
app: currentApp,
|
|
2543
|
-
query,
|
|
2544
|
-
match,
|
|
2545
|
-
hash,
|
|
2546
|
-
pathname,
|
|
2547
|
-
segues
|
|
2548
|
-
} = mergedContext;
|
|
2549
|
-
var {
|
|
2550
|
-
sys,
|
|
2551
|
-
flags,
|
|
2552
|
-
storyboardContext
|
|
2553
|
-
} = internalContext;
|
|
2554
|
-
var app = (_runtimeContext$overr = runtimeContext.overrideApp) !== null && _runtimeContext$overr !== void 0 ? _runtimeContext$overr : currentApp;
|
|
2555
|
-
function getIndividualGlobal(variableName) {
|
|
2556
|
-
switch (variableName) {
|
|
2557
|
-
case "ALIAS":
|
|
2558
|
-
return {
|
|
2559
|
-
getUrl: getUrlByAliasFactory(app)
|
|
2560
|
-
};
|
|
2561
|
-
case "ANCHOR":
|
|
2562
|
-
return hash ? hash.substr(1) : null;
|
|
2563
|
-
case "APP":
|
|
2564
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, _.cloneDeep(app)), {}, {
|
|
2565
|
-
getMenu
|
|
2566
|
-
});
|
|
2567
|
-
case "CTX":
|
|
2568
|
-
return getDynamicReadOnlyProxy({
|
|
2569
|
-
get(target, key) {
|
|
2570
|
-
var _item$brick$element;
|
|
2571
|
-
var item = storyboardContext.get(key);
|
|
2572
|
-
return !item ? item : item.type === "brick-property" ? (_item$brick$element = item.brick.element) === null || _item$brick$element === void 0 ? void 0 : _item$brick$element[item.prop] : item.value;
|
|
2573
|
-
},
|
|
2574
|
-
ownKeys() {
|
|
2575
|
-
return Array.from(storyboardContext.keys());
|
|
2576
|
-
}
|
|
2577
|
-
});
|
|
2578
|
-
case "FLAGS":
|
|
2579
|
-
return getReadOnlyProxy(flags);
|
|
2580
|
-
case "HASH":
|
|
2581
|
-
return hash;
|
|
2582
|
-
case "PATH_NAME":
|
|
2583
|
-
return pathname;
|
|
2584
|
-
case "INSTALLED_APPS":
|
|
2585
|
-
return {
|
|
2586
|
-
has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
|
|
2587
|
-
};
|
|
2588
|
-
case "LOCAL_STORAGE":
|
|
2589
|
-
return {
|
|
2590
|
-
getItem: getItemFactory("local")
|
|
2591
|
-
};
|
|
2592
|
-
case "MISC":
|
|
2593
|
-
return getRuntime().getMiscSettings();
|
|
2594
|
-
case "PARAMS":
|
|
2595
|
-
return new URLSearchParams(query);
|
|
2596
|
-
case "PATH":
|
|
2597
|
-
return getReadOnlyProxy(match.params);
|
|
2598
|
-
case "PROCESSORS":
|
|
2599
|
-
return getDynamicReadOnlyProxy({
|
|
2600
|
-
get(target, key) {
|
|
2601
|
-
var pkg = customProcessorRegistry.get(key);
|
|
2602
|
-
if (!pkg) {
|
|
2603
|
-
throw new Error("'PROCESSORS.".concat(key, "' is not registered! Have you installed the relevant brick package of '").concat(key.replace(/[A-Z]/g, m => "-".concat(m.toLowerCase())), "-NB'?"));
|
|
2604
|
-
}
|
|
2605
|
-
return getDynamicReadOnlyProxy({
|
|
2606
|
-
get(t, k) {
|
|
2607
|
-
return pkg.get(k);
|
|
2608
|
-
},
|
|
2609
|
-
ownKeys() {
|
|
2610
|
-
return Array.from(pkg.keys());
|
|
2611
|
-
}
|
|
2612
|
-
});
|
|
2613
|
-
},
|
|
2614
|
-
ownKeys() {
|
|
2615
|
-
return Array.from(customProcessorRegistry.keys());
|
|
2616
|
-
}
|
|
2617
|
-
});
|
|
2618
|
-
case "QUERY":
|
|
2619
|
-
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
|
|
2620
|
-
case "QUERY_ARRAY":
|
|
2621
|
-
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
|
|
2622
|
-
case "SEGUE":
|
|
2623
|
-
return {
|
|
2624
|
-
getUrl: getUrlBySegueFactory(app, segues)
|
|
2625
|
-
};
|
|
2626
|
-
case "SESSION_STORAGE":
|
|
2627
|
-
return {
|
|
2628
|
-
getItem: getItemFactory("session")
|
|
2629
|
-
};
|
|
2630
|
-
case "SYS":
|
|
2631
|
-
return getReadOnlyProxy(sys);
|
|
2632
|
-
case "MEDIA":
|
|
2633
|
-
return getReadOnlyProxy(getMedia());
|
|
2634
|
-
case "__WIDGET_FN__":
|
|
2635
|
-
return widgetFunctions;
|
|
2636
|
-
case "__WIDGET_IMG__":
|
|
2637
|
-
return widgetImagesFactory;
|
|
2638
|
-
case "__WIDGET_I18N__":
|
|
2639
|
-
return widgetI18nFactory;
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
for (var variableName of attemptToVisitGlobals) {
|
|
2643
|
-
var variable = getIndividualGlobal(variableName);
|
|
2644
|
-
if (variable !== undefined) {
|
|
2645
|
-
globalVariables[variableName] = variable;
|
|
2646
|
-
}
|
|
2861
|
+
// If the `raw` is not a string, it must be a pre-evaluated object.
|
|
2862
|
+
// Then fulfil the context, and restore the original `raw`.
|
|
2863
|
+
runtimeContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, raw[symbolForContext]), runtimeContext);
|
|
2864
|
+
raw = raw[symbolForRaw];
|
|
2647
2865
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
appendI18nNamespace: runtimeContext.appendI18nNamespace
|
|
2652
|
-
}));
|
|
2866
|
+
|
|
2867
|
+
// A `SyntaxError` maybe thrown.
|
|
2868
|
+
var precooked;
|
|
2653
2869
|
try {
|
|
2654
|
-
|
|
2655
|
-
globalVariables: supply(precooked.attemptToVisitGlobals, globalVariables)
|
|
2656
|
-
});
|
|
2657
|
-
var detail = {
|
|
2658
|
-
raw,
|
|
2659
|
-
context: globalVariables,
|
|
2660
|
-
result
|
|
2661
|
-
};
|
|
2662
|
-
if (options.isReEvaluation) {
|
|
2663
|
-
devtoolsHookEmit("re-evaluation", {
|
|
2664
|
-
id: options.evaluationId,
|
|
2665
|
-
detail
|
|
2666
|
-
});
|
|
2667
|
-
} else {
|
|
2668
|
-
devtoolsHookEmit("evaluation", detail);
|
|
2669
|
-
}
|
|
2670
|
-
return result;
|
|
2870
|
+
precooked = brickUtils.preevaluate(raw);
|
|
2671
2871
|
} catch (error) {
|
|
2672
|
-
var
|
|
2872
|
+
var message = "".concat(error.message, ", in \"").concat(raw, "\"");
|
|
2673
2873
|
if (options.isReEvaluation) {
|
|
2674
2874
|
devtoolsHookEmit("re-evaluation", {
|
|
2675
2875
|
id: options.evaluationId,
|
|
2676
2876
|
detail: {
|
|
2677
2877
|
raw,
|
|
2678
|
-
context:
|
|
2878
|
+
context: {}
|
|
2679
2879
|
},
|
|
2680
|
-
error:
|
|
2880
|
+
error: message
|
|
2681
2881
|
});
|
|
2882
|
+
return;
|
|
2682
2883
|
} else {
|
|
2683
|
-
var
|
|
2684
|
-
throw new
|
|
2884
|
+
var errorConstructor = getCookErrorConstructor(error);
|
|
2885
|
+
throw new errorConstructor(message);
|
|
2685
2886
|
}
|
|
2686
2887
|
}
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
function isMergeableProperty(propRef) {
|
|
2696
|
-
return !!propRef.mergeProperty;
|
|
2697
|
-
}
|
|
2698
|
-
function isRefProperty(propRef) {
|
|
2699
|
-
return !!propRef.ref;
|
|
2700
|
-
}
|
|
2701
|
-
function isVariableProperty(propRef) {
|
|
2702
|
-
return !!propRef.asVariable;
|
|
2703
|
-
}
|
|
2704
|
-
|
|
2705
|
-
var customTemplateRegistry = new Map();
|
|
2706
|
-
var appRegistered = new Set();
|
|
2707
|
-
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
2708
|
-
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
2709
|
-
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
2888
|
+
var globalVariables = {};
|
|
2889
|
+
var attemptToVisitGlobals = precooked.attemptToVisitGlobals;
|
|
2890
|
+
var attemptToVisitEvent = attemptToVisitGlobals.has("EVENT");
|
|
2891
|
+
var attemptToVisitData = attemptToVisitGlobals.has("DATA");
|
|
2892
|
+
var attemptToVisitTpl = attemptToVisitGlobals.has("TPL");
|
|
2893
|
+
var attemptToVisitState = attemptToVisitGlobals.has("STATE");
|
|
2894
|
+
var attemptToVisitFormState = attemptToVisitGlobals.has("FORM_STATE");
|
|
2895
|
+
var attemptToVisitTplOrState = attemptToVisitTpl || attemptToVisitState;
|
|
2710
2896
|
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
}
|
|
2721
|
-
// istanbul ignore next: should never reach
|
|
2722
|
-
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
2723
|
-
}
|
|
2724
|
-
function propertyMergeAllOfArray(_ref, object) {
|
|
2725
|
-
var _$1, _proxy$mergeArgs;
|
|
2726
|
-
var {
|
|
2727
|
-
baseValue,
|
|
2728
|
-
context,
|
|
2729
|
-
proxies
|
|
2730
|
-
} = _ref;
|
|
2731
|
-
// Use an approach like template-literal's quasis:
|
|
2732
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
2733
|
-
// Every quasi can be merged with multiple items.
|
|
2734
|
-
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
2735
|
-
$$lazyForUseBrick: true
|
|
2736
|
-
}) : [];
|
|
2737
|
-
var quasis = [];
|
|
2738
|
-
var size = computedBaseValue.length + 1;
|
|
2739
|
-
for (var i = 0; i < size; i += 1) {
|
|
2740
|
-
quasis.push([]);
|
|
2741
|
-
}
|
|
2742
|
-
for (var proxy of proxies) {
|
|
2743
|
-
var position = void 0;
|
|
2744
|
-
switch (proxy.mergeMethod) {
|
|
2745
|
-
case "append":
|
|
2746
|
-
position = computedBaseValue.length;
|
|
2747
|
-
break;
|
|
2748
|
-
case "prepend":
|
|
2749
|
-
position = 0;
|
|
2750
|
-
break;
|
|
2751
|
-
case "insertAt":
|
|
2752
|
-
// Defaults to `-1`.
|
|
2753
|
-
position = (_$1 = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _$1 !== void 0 ? _$1 : -1;
|
|
2754
|
-
if (position < 0) {
|
|
2755
|
-
// It's counted from the end if position is negative.
|
|
2756
|
-
position += quasis.length;
|
|
2757
|
-
}
|
|
2758
|
-
position = _.clamp(position, 0, computedBaseValue.length);
|
|
2759
|
-
break;
|
|
2760
|
-
// istanbul ignore next: should never reach
|
|
2761
|
-
default:
|
|
2762
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2763
|
-
}
|
|
2764
|
-
var patchValue = object[proxy.$$reversedRef];
|
|
2765
|
-
if (!Array.isArray(patchValue)) {
|
|
2766
|
-
patchValue = [];
|
|
2897
|
+
// Ignore evaluating if `event` is missing in context.
|
|
2898
|
+
// Since it should be evaluated during events handling.
|
|
2899
|
+
var missingEvent = options.lazy === true;
|
|
2900
|
+
if (attemptToVisitEvent) {
|
|
2901
|
+
if (brickUtils.hasOwnProperty(runtimeContext, "event")) {
|
|
2902
|
+
globalVariables.EVENT = runtimeContext.event;
|
|
2903
|
+
} else {
|
|
2904
|
+
// Let's see if pre-evaluation is required (store the `data` in context).
|
|
2905
|
+
missingEvent = true;
|
|
2767
2906
|
}
|
|
2768
|
-
quasis[position].push(...patchValue);
|
|
2769
2907
|
}
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
context
|
|
2777
|
-
} = _ref2;
|
|
2778
|
-
var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
2779
|
-
return proxies.reduce((acc, proxy) => {
|
|
2780
|
-
switch (proxy.mergeMethod) {
|
|
2781
|
-
case "extend":
|
|
2782
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
|
|
2783
|
-
// istanbul ignore next: should never reach
|
|
2784
|
-
default:
|
|
2785
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2786
|
-
}
|
|
2787
|
-
}, computedBaseValue);
|
|
2788
|
-
}
|
|
2789
|
-
|
|
2790
|
-
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
2791
|
-
var computedPropsFromProxy = {};
|
|
2792
|
-
var refForProxy;
|
|
2793
|
-
var {
|
|
2794
|
-
reversedProxies,
|
|
2795
|
-
templateProperties,
|
|
2796
|
-
externalSlots,
|
|
2797
|
-
templateContextId,
|
|
2798
|
-
proxyBrick
|
|
2799
|
-
} = proxyContext;
|
|
2800
|
-
if (ref && reversedProxies) {
|
|
2801
|
-
refForProxy = {};
|
|
2802
|
-
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
2803
|
-
|
|
2804
|
-
// Reversed proxies are used for expand storyboard before rendering page.
|
|
2805
|
-
if (reversedProxies.properties.has(ref)) {
|
|
2806
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
2807
|
-
// `propValue` is computed.
|
|
2808
|
-
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
2809
|
-
if (isTransformableProperty(propRef)) {
|
|
2810
|
-
return Object.entries(preprocessTransformProperties({
|
|
2811
|
-
[propRef.$$reversedRef]: propValue
|
|
2812
|
-
}, propRef.refTransform));
|
|
2813
|
-
}
|
|
2814
|
-
if (isBasicProperty(propRef)) {
|
|
2815
|
-
return [[propRef.refProperty, propValue]];
|
|
2816
|
-
}
|
|
2817
|
-
// Ignore Variable properties.
|
|
2818
|
-
// And mergeable properties are processed later.
|
|
2819
|
-
return [];
|
|
2820
|
-
}).filter(propRef => propRef[1] !== undefined)));
|
|
2821
|
-
|
|
2822
|
-
// Brick properties can be merged multiple times.
|
|
2823
|
-
if (reversedProxies.mergeBases.has(ref)) {
|
|
2824
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
2825
|
-
var [mergeProperty, mergeBase] = _ref;
|
|
2826
|
-
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
2827
|
-
}).filter(item => item[1] !== undefined)));
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2908
|
+
var missingTplOrState = attemptToVisitTplOrState && !brickUtils.hasOwnProperty(runtimeContext, "tplContextId");
|
|
2909
|
+
var missingData = attemptToVisitData && !brickUtils.hasOwnProperty(runtimeContext, "data");
|
|
2910
|
+
var rawWithContext = Object.keys(runtimeContext).length > 0 ? {
|
|
2911
|
+
[symbolForRaw]: raw,
|
|
2912
|
+
[symbolForContext]: runtimeContext
|
|
2913
|
+
} : raw;
|
|
2830
2914
|
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
if (reversedProxies.slots.has(ref)) {
|
|
2836
|
-
for (var item of reversedProxies.slots.get(ref)) {
|
|
2837
|
-
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
2838
|
-
if (!quasisMap.has(item.refSlot)) {
|
|
2839
|
-
var quasis = [];
|
|
2840
|
-
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
2841
|
-
var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
2842
|
-
for (var i = 0; i < size; i += 1) {
|
|
2843
|
-
quasis.push([]);
|
|
2844
|
-
}
|
|
2845
|
-
quasisMap.set(item.refSlot, quasis);
|
|
2846
|
-
}
|
|
2847
|
-
var expandableSlot = quasisMap.get(item.refSlot);
|
|
2848
|
-
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
2849
|
-
expandableSlot[_.clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
|
|
2850
|
-
}
|
|
2851
|
-
}
|
|
2852
|
-
var _loop = function (slotName, _quasis) {
|
|
2853
|
-
if (!brickUtils.hasOwnProperty(slots, slotName)) {
|
|
2854
|
-
slots[slotName] = {
|
|
2855
|
-
type: "bricks",
|
|
2856
|
-
bricks: []
|
|
2857
|
-
};
|
|
2858
|
-
}
|
|
2859
|
-
var slotConf = slots[slotName];
|
|
2860
|
-
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
2861
|
-
if (slotConf.bricks.length === 0) {
|
|
2862
|
-
delete slots[slotName];
|
|
2863
|
-
}
|
|
2864
|
-
};
|
|
2865
|
-
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
2866
|
-
_loop(slotName, _quasis);
|
|
2867
|
-
}
|
|
2915
|
+
// Since `EVENT`, `DATA`, `TPL` and `STATE` are provided in different context,
|
|
2916
|
+
// whenever missing one of them, memorize the current context for later consuming.
|
|
2917
|
+
if (missingEvent || missingData || missingTplOrState) {
|
|
2918
|
+
return rawWithContext;
|
|
2868
2919
|
}
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
var _excluded$8 = ["properties", "slots"];
|
|
2877
|
-
function setupUseBrickInTemplate(props, proxyContext) {
|
|
2878
|
-
function walk(props) {
|
|
2879
|
-
if (Array.isArray(props)) {
|
|
2880
|
-
return props.map(walk);
|
|
2920
|
+
if (attemptToVisitData) {
|
|
2921
|
+
globalVariables.DATA = runtimeContext.data;
|
|
2922
|
+
}
|
|
2923
|
+
if (attemptToVisitTplOrState && runtimeContext.tplContextId) {
|
|
2924
|
+
var tplContext = getCustomTemplateContext(runtimeContext.tplContextId);
|
|
2925
|
+
if (attemptToVisitTpl) {
|
|
2926
|
+
globalVariables.TPL = tplContext.getVariables();
|
|
2881
2927
|
}
|
|
2882
|
-
if (
|
|
2883
|
-
|
|
2928
|
+
if (attemptToVisitState) {
|
|
2929
|
+
globalVariables.STATE = getDynamicReadOnlyProxy({
|
|
2930
|
+
get(target, key) {
|
|
2931
|
+
return tplContext.state.getValue(key);
|
|
2932
|
+
},
|
|
2933
|
+
ownKeys() {
|
|
2934
|
+
return Array.from(tplContext.state.get().keys());
|
|
2935
|
+
}
|
|
2936
|
+
});
|
|
2884
2937
|
}
|
|
2885
|
-
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
2886
|
-
var [key, value] = _ref;
|
|
2887
|
-
return brickUtils.isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
2888
|
-
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
2889
2938
|
}
|
|
2890
|
-
|
|
2891
|
-
var
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
type: "bricks",
|
|
2901
|
-
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
2902
|
-
}];
|
|
2903
|
-
}));
|
|
2904
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, restConf), {}, {
|
|
2905
|
-
properties: walk(properties),
|
|
2906
|
-
slots
|
|
2907
|
-
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
2939
|
+
if (attemptToVisitFormState && runtimeContext.formContextId) {
|
|
2940
|
+
var formContext = getCustomFormContext(runtimeContext.formContextId);
|
|
2941
|
+
globalVariables.FORM_STATE = getDynamicReadOnlyProxy({
|
|
2942
|
+
get(target, key) {
|
|
2943
|
+
return formContext.formState.getValue(key);
|
|
2944
|
+
},
|
|
2945
|
+
ownKeys() {
|
|
2946
|
+
return Array.from(formContext.formState.get().keys());
|
|
2947
|
+
}
|
|
2948
|
+
});
|
|
2908
2949
|
}
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
function isPlainObject(object) {
|
|
2912
|
-
return Object.prototype.toString.call(object) === "[object Object]";
|
|
2913
|
-
}
|
|
2950
|
+
var internalContext = _internalApiGetCurrentContext();
|
|
2951
|
+
var mergedContext = {};
|
|
2914
2952
|
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2953
|
+
// Use runtime context over internal context.
|
|
2954
|
+
// Internal context such as `match`, maybe change after `history.push`.
|
|
2955
|
+
// So we prefer memoized runtime context.
|
|
2956
|
+
for (var key of ["query", "match", "hash", "pathname", "app", "segues"]) {
|
|
2957
|
+
mergedContext[key] = (brickUtils.hasOwnProperty(runtimeContext, key) ? runtimeContext : internalContext)[key];
|
|
2958
|
+
}
|
|
2959
|
+
var {
|
|
2960
|
+
app: currentApp,
|
|
2961
|
+
query,
|
|
2962
|
+
match,
|
|
2963
|
+
hash,
|
|
2964
|
+
pathname,
|
|
2965
|
+
segues
|
|
2966
|
+
} = mergedContext;
|
|
2967
|
+
var {
|
|
2968
|
+
sys,
|
|
2969
|
+
flags,
|
|
2970
|
+
storyboardContext
|
|
2971
|
+
} = internalContext;
|
|
2972
|
+
var app = (_runtimeContext$overr = runtimeContext.overrideApp) !== null && _runtimeContext$overr !== void 0 ? _runtimeContext$overr : currentApp;
|
|
2973
|
+
function getIndividualGlobal(variableName) {
|
|
2974
|
+
switch (variableName) {
|
|
2975
|
+
case "ALIAS":
|
|
2976
|
+
return {
|
|
2977
|
+
getUrl: getUrlByAliasFactory(app)
|
|
2978
|
+
};
|
|
2979
|
+
case "ANCHOR":
|
|
2980
|
+
return hash ? hash.substr(1) : null;
|
|
2981
|
+
case "APP":
|
|
2982
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, _.cloneDeep(app)), {}, {
|
|
2983
|
+
getMenu
|
|
2984
|
+
});
|
|
2985
|
+
case "CTX":
|
|
2986
|
+
return getDynamicReadOnlyProxy({
|
|
2987
|
+
get(target, key) {
|
|
2988
|
+
var _item$brick$element;
|
|
2989
|
+
var item = storyboardContext.get(key);
|
|
2990
|
+
return !item ? item : item.type === "brick-property" ? (_item$brick$element = item.brick.element) === null || _item$brick$element === void 0 ? void 0 : _item$brick$element[item.prop] : item.value;
|
|
2991
|
+
},
|
|
2992
|
+
ownKeys() {
|
|
2993
|
+
return Array.from(storyboardContext.keys());
|
|
2930
2994
|
}
|
|
2931
|
-
}
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2995
|
+
});
|
|
2996
|
+
case "FLAGS":
|
|
2997
|
+
return getReadOnlyProxy(flags);
|
|
2998
|
+
case "HASH":
|
|
2999
|
+
return hash;
|
|
3000
|
+
case "PATH_NAME":
|
|
3001
|
+
return pathname;
|
|
3002
|
+
case "INSTALLED_APPS":
|
|
3003
|
+
return {
|
|
3004
|
+
has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
|
|
3005
|
+
};
|
|
3006
|
+
case "LOCAL_STORAGE":
|
|
3007
|
+
return {
|
|
3008
|
+
getItem: getItemFactory("local")
|
|
3009
|
+
};
|
|
3010
|
+
case "MISC":
|
|
3011
|
+
return getRuntime().getMiscSettings();
|
|
3012
|
+
case "PARAMS":
|
|
3013
|
+
return new URLSearchParams(query);
|
|
3014
|
+
case "PATH":
|
|
3015
|
+
return getReadOnlyProxy(match.params);
|
|
3016
|
+
case "PROCESSORS":
|
|
3017
|
+
return getDynamicReadOnlyProxy({
|
|
3018
|
+
get(target, key) {
|
|
3019
|
+
var pkg = customProcessorRegistry.get(key);
|
|
3020
|
+
if (!pkg) {
|
|
3021
|
+
throw new Error("'PROCESSORS.".concat(key, "' is not registered! Have you installed the relevant brick package of '").concat(key.replace(/[A-Z]/g, m => "-".concat(m.toLowerCase())), "-NB'?"));
|
|
3022
|
+
}
|
|
3023
|
+
return getDynamicReadOnlyProxy({
|
|
3024
|
+
get(t, k) {
|
|
3025
|
+
return pkg.get(k);
|
|
3026
|
+
},
|
|
3027
|
+
ownKeys() {
|
|
3028
|
+
return Array.from(pkg.keys());
|
|
3029
|
+
}
|
|
3030
|
+
});
|
|
3031
|
+
},
|
|
3032
|
+
ownKeys() {
|
|
3033
|
+
return Array.from(customProcessorRegistry.keys());
|
|
2936
3034
|
}
|
|
2937
|
-
}
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
3035
|
+
});
|
|
3036
|
+
case "QUERY":
|
|
3037
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
|
|
3038
|
+
case "QUERY_ARRAY":
|
|
3039
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
|
|
3040
|
+
case "SEGUE":
|
|
3041
|
+
return {
|
|
3042
|
+
getUrl: getUrlBySegueFactory(app, segues)
|
|
3043
|
+
};
|
|
3044
|
+
case "SESSION_STORAGE":
|
|
3045
|
+
return {
|
|
3046
|
+
getItem: getItemFactory("session")
|
|
3047
|
+
};
|
|
3048
|
+
case "SYS":
|
|
3049
|
+
return getReadOnlyProxy(sys);
|
|
3050
|
+
case "MEDIA":
|
|
3051
|
+
return getReadOnlyProxy(getMedia());
|
|
3052
|
+
case "__WIDGET_FN__":
|
|
3053
|
+
return widgetFunctions;
|
|
3054
|
+
case "__WIDGET_IMG__":
|
|
3055
|
+
return widgetImagesFactory;
|
|
3056
|
+
case "__WIDGET_I18N__":
|
|
3057
|
+
return widgetI18nFactory;
|
|
2949
3058
|
}
|
|
2950
|
-
return result;
|
|
2951
3059
|
}
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
return value.map(v => computeRealValue(v, context, injectDeep, nextOptions));
|
|
3060
|
+
for (var variableName of attemptToVisitGlobals) {
|
|
3061
|
+
var variable = getIndividualGlobal(variableName);
|
|
3062
|
+
if (variable !== undefined) {
|
|
3063
|
+
globalVariables[variableName] = variable;
|
|
3064
|
+
}
|
|
2958
3065
|
}
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
realProps = setupUseBrickInTemplate(realProps, {
|
|
2968
|
-
templateContextId: context.tplContextId
|
|
3066
|
+
Object.assign(globalVariables, getGeneralGlobals(precooked.attemptToVisitGlobals, {
|
|
3067
|
+
storyboardFunctions,
|
|
3068
|
+
app,
|
|
3069
|
+
appendI18nNamespace: runtimeContext.appendI18nNamespace
|
|
3070
|
+
}));
|
|
3071
|
+
try {
|
|
3072
|
+
var result = brickUtils.cook(precooked.expression, precooked.source, {
|
|
3073
|
+
globalVariables: supply(precooked.attemptToVisitGlobals, globalVariables)
|
|
2969
3074
|
});
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
brick[propName][k] = v;
|
|
2983
|
-
}
|
|
2984
|
-
} else if (propName === "innerHTML") {
|
|
2985
|
-
// `innerHTML` is dangerous, use `textContent` instead.
|
|
2986
|
-
// eslint-disable-next-line no-console
|
|
2987
|
-
console.error("Please use `textContent` instead of `innerHTML`.");
|
|
2988
|
-
brick.textContent = propValue;
|
|
2989
|
-
} else {
|
|
2990
|
-
if (extractProps) {
|
|
2991
|
-
_.set(brick, propName, propValue);
|
|
2992
|
-
} else {
|
|
2993
|
-
brick[propName] = propValue;
|
|
2994
|
-
}
|
|
3075
|
+
var detail = {
|
|
3076
|
+
raw,
|
|
3077
|
+
context: globalVariables,
|
|
3078
|
+
result
|
|
3079
|
+
};
|
|
3080
|
+
if (options.isReEvaluation) {
|
|
3081
|
+
devtoolsHookEmit("re-evaluation", {
|
|
3082
|
+
id: options.evaluationId,
|
|
3083
|
+
detail
|
|
3084
|
+
});
|
|
3085
|
+
} else {
|
|
3086
|
+
devtoolsHookEmit("evaluation", detail);
|
|
2995
3087
|
}
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3088
|
+
return result;
|
|
3089
|
+
} catch (error) {
|
|
3090
|
+
var _message = "".concat(error.message, ", in \"").concat(raw, "\"");
|
|
3091
|
+
if (options.isReEvaluation) {
|
|
3092
|
+
devtoolsHookEmit("re-evaluation", {
|
|
3093
|
+
id: options.evaluationId,
|
|
3094
|
+
detail: {
|
|
3095
|
+
raw,
|
|
3096
|
+
context: globalVariables
|
|
3097
|
+
},
|
|
3098
|
+
error: _message
|
|
3006
3099
|
});
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
result[propName] = realValue;
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
if (Array.isArray(trackingContextList)) {
|
|
3014
|
-
var {
|
|
3015
|
-
contextNames,
|
|
3016
|
-
stateNames,
|
|
3017
|
-
formStateNames
|
|
3018
|
-
} = getTracks(propValue);
|
|
3019
|
-
if (contextNames || stateNames || formStateNames) {
|
|
3020
|
-
trackingContextList.push({
|
|
3021
|
-
contextNames,
|
|
3022
|
-
stateNames,
|
|
3023
|
-
formStateNames,
|
|
3024
|
-
propName,
|
|
3025
|
-
propValue
|
|
3026
|
-
});
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3100
|
+
} else {
|
|
3101
|
+
var _errorConstructor = getCookErrorConstructor(error);
|
|
3102
|
+
throw new _errorConstructor(_message);
|
|
3029
3103
|
}
|
|
3030
3104
|
}
|
|
3031
|
-
return result;
|
|
3032
|
-
}
|
|
3033
|
-
function getNextInternalOptions(internalOptions, isArray, key) {
|
|
3034
|
-
return internalOptions !== null && internalOptions !== void 0 && internalOptions.$$lazyForUseBrick ? _objectSpread__default["default"](_objectSpread__default["default"]({}, internalOptions), {}, {
|
|
3035
|
-
$$stateOfUseBrick: getNextStateOfUseBrick(internalOptions.$$stateOfUseBrick, isArray, key)
|
|
3036
|
-
}) : internalOptions;
|
|
3037
3105
|
}
|
|
3038
3106
|
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
_excluded3 = ["items", "app"];
|
|
3042
|
-
var symbolAppId = Symbol("appId");
|
|
3043
|
-
var symbolMenuI18nNamespace = Symbol("menuI18nNamespace");
|
|
3044
|
-
var symbolOverrideApp = Symbol("overrideApp");
|
|
3045
|
-
var symbolShouldCache = Symbol("shouldCache");
|
|
3046
|
-
// Caching menu requests to avoid flicker.
|
|
3047
|
-
var menuCache = new Map();
|
|
3048
|
-
var menuTitleCache = new Map();
|
|
3049
|
-
var processMenuCache = new Map();
|
|
3050
|
-
function constructMenu(_x, _x2, _x3) {
|
|
3051
|
-
return _constructMenu.apply(this, arguments);
|
|
3107
|
+
function isBasicProperty(propRef) {
|
|
3108
|
+
return !!propRef.refProperty;
|
|
3052
3109
|
}
|
|
3053
|
-
function
|
|
3054
|
-
|
|
3055
|
-
var hasSubMenu = !!menuBar.subMenuId;
|
|
3056
|
-
yield Promise.all([_asyncToGenerator__default["default"](function* () {
|
|
3057
|
-
if (menuBar.menuId) {
|
|
3058
|
-
var _menuBar$menu;
|
|
3059
|
-
var defaultCollapsed = (_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed;
|
|
3060
|
-
var menu = yield processMenu(menuBar.menuId, context, kernel, hasSubMenu);
|
|
3061
|
-
if (!_.isNil(defaultCollapsed)) {
|
|
3062
|
-
menu.defaultCollapsed = defaultCollapsed;
|
|
3063
|
-
}
|
|
3064
|
-
menuBar.menu = menu;
|
|
3065
|
-
}
|
|
3066
|
-
})(), _asyncToGenerator__default["default"](function* () {
|
|
3067
|
-
if (hasSubMenu) {
|
|
3068
|
-
menuBar.subMenu = yield processMenu(menuBar.subMenuId, context, kernel);
|
|
3069
|
-
} else {
|
|
3070
|
-
menuBar.subMenu = null;
|
|
3071
|
-
}
|
|
3072
|
-
})()]);
|
|
3073
|
-
});
|
|
3074
|
-
return _constructMenu.apply(this, arguments);
|
|
3110
|
+
function isTransformableProperty(propRef) {
|
|
3111
|
+
return !!propRef.refTransform;
|
|
3075
3112
|
}
|
|
3076
|
-
function
|
|
3077
|
-
return
|
|
3113
|
+
function isMergeableProperty(propRef) {
|
|
3114
|
+
return !!propRef.mergeProperty;
|
|
3078
3115
|
}
|
|
3079
|
-
function
|
|
3080
|
-
|
|
3081
|
-
var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel, undefined, true)));
|
|
3082
|
-
data.forEach((item, index) => processMenuCache.set(menus[index], item));
|
|
3083
|
-
});
|
|
3084
|
-
return _preConstructMenus.apply(this, arguments);
|
|
3116
|
+
function isRefProperty(propRef) {
|
|
3117
|
+
return !!propRef.ref;
|
|
3085
3118
|
}
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
return _fetchMenuById.apply(this, arguments);
|
|
3119
|
+
function isVariableProperty(propRef) {
|
|
3120
|
+
return !!propRef.asVariable;
|
|
3089
3121
|
}
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3122
|
+
|
|
3123
|
+
var customTemplateRegistry = new Map();
|
|
3124
|
+
var appRegistered = new Set();
|
|
3125
|
+
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
3126
|
+
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
3127
|
+
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
3128
|
+
|
|
3129
|
+
function propertyMerge(conf, value, object) {
|
|
3130
|
+
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
3131
|
+
}
|
|
3132
|
+
function propertyMergeAll(mergeBase, object) {
|
|
3133
|
+
if (mergeBase.mergeType === "array") {
|
|
3134
|
+
return propertyMergeAllOfArray(mergeBase, object);
|
|
3135
|
+
}
|
|
3136
|
+
if (mergeBase.mergeType === "object") {
|
|
3137
|
+
return propertyMergeAllOfObject(mergeBase, object);
|
|
3138
|
+
}
|
|
3139
|
+
// istanbul ignore next: should never reach
|
|
3140
|
+
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
3141
|
+
}
|
|
3142
|
+
function propertyMergeAllOfArray(_ref, object) {
|
|
3143
|
+
var _$1, _proxy$mergeArgs;
|
|
3144
|
+
var {
|
|
3145
|
+
baseValue,
|
|
3146
|
+
context,
|
|
3147
|
+
proxies
|
|
3148
|
+
} = _ref;
|
|
3149
|
+
// Use an approach like template-literal's quasis:
|
|
3150
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
3151
|
+
// Every quasi can be merged with multiple items.
|
|
3152
|
+
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
3153
|
+
$$lazyForUseBrick: true
|
|
3154
|
+
}) : [];
|
|
3155
|
+
var quasis = [];
|
|
3156
|
+
var size = computedBaseValue.length + 1;
|
|
3157
|
+
for (var i = 0; i < size; i += 1) {
|
|
3158
|
+
quasis.push([]);
|
|
3159
|
+
}
|
|
3160
|
+
for (var proxy of proxies) {
|
|
3161
|
+
var position = void 0;
|
|
3162
|
+
switch (proxy.mergeMethod) {
|
|
3163
|
+
case "append":
|
|
3164
|
+
position = computedBaseValue.length;
|
|
3165
|
+
break;
|
|
3166
|
+
case "prepend":
|
|
3167
|
+
position = 0;
|
|
3168
|
+
break;
|
|
3169
|
+
case "insertAt":
|
|
3170
|
+
// Defaults to `-1`.
|
|
3171
|
+
position = (_$1 = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _$1 !== void 0 ? _$1 : -1;
|
|
3172
|
+
if (position < 0) {
|
|
3173
|
+
// It's counted from the end if position is negative.
|
|
3174
|
+
position += quasis.length;
|
|
3125
3175
|
}
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3176
|
+
position = _.clamp(position, 0, computedBaseValue.length);
|
|
3177
|
+
break;
|
|
3178
|
+
// istanbul ignore next: should never reach
|
|
3179
|
+
default:
|
|
3180
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
3131
3181
|
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
return _mergeMenu.apply(this, arguments);
|
|
3182
|
+
var patchValue = object[proxy.$$reversedRef];
|
|
3183
|
+
if (!Array.isArray(patchValue)) {
|
|
3184
|
+
patchValue = [];
|
|
3185
|
+
}
|
|
3186
|
+
quasis[position].push(...patchValue);
|
|
3187
|
+
}
|
|
3188
|
+
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
3140
3189
|
}
|
|
3141
|
-
function
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3190
|
+
function propertyMergeAllOfObject(_ref2, object) {
|
|
3191
|
+
var {
|
|
3192
|
+
baseValue,
|
|
3193
|
+
proxies,
|
|
3194
|
+
context
|
|
3195
|
+
} = _ref2;
|
|
3196
|
+
var computedBaseValue = brickUtils.isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
3197
|
+
return proxies.reduce((acc, proxy) => {
|
|
3198
|
+
switch (proxy.mergeMethod) {
|
|
3199
|
+
case "extend":
|
|
3200
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, acc), object[proxy.$$reversedRef]);
|
|
3201
|
+
// istanbul ignore next: should never reach
|
|
3202
|
+
default:
|
|
3203
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
3146
3204
|
}
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3205
|
+
}, computedBaseValue);
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
3209
|
+
var computedPropsFromProxy = {};
|
|
3210
|
+
var refForProxy;
|
|
3211
|
+
var {
|
|
3212
|
+
reversedProxies,
|
|
3213
|
+
templateProperties,
|
|
3214
|
+
externalSlots,
|
|
3215
|
+
templateContextId,
|
|
3216
|
+
proxyBrick
|
|
3217
|
+
} = proxyContext;
|
|
3218
|
+
if (ref && reversedProxies) {
|
|
3219
|
+
refForProxy = {};
|
|
3220
|
+
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
3221
|
+
|
|
3222
|
+
// Reversed proxies are used for expand storyboard before rendering page.
|
|
3223
|
+
if (reversedProxies.properties.has(ref)) {
|
|
3224
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
3225
|
+
// `propValue` is computed.
|
|
3226
|
+
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
3227
|
+
if (isTransformableProperty(propRef)) {
|
|
3228
|
+
return Object.entries(preprocessTransformProperties({
|
|
3229
|
+
[propRef.$$reversedRef]: propValue
|
|
3230
|
+
}, propRef.refTransform));
|
|
3231
|
+
}
|
|
3232
|
+
if (isBasicProperty(propRef)) {
|
|
3233
|
+
return [[propRef.refProperty, propValue]];
|
|
3234
|
+
}
|
|
3235
|
+
// Ignore Variable properties.
|
|
3236
|
+
// And mergeable properties are processed later.
|
|
3237
|
+
return [];
|
|
3238
|
+
}).filter(propRef => propRef[1] !== undefined)));
|
|
3239
|
+
|
|
3240
|
+
// Brick properties can be merged multiple times.
|
|
3241
|
+
if (reversedProxies.mergeBases.has(ref)) {
|
|
3242
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
3243
|
+
var [mergeProperty, mergeBase] = _ref;
|
|
3244
|
+
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
3245
|
+
}).filter(item => item[1] !== undefined)));
|
|
3161
3246
|
}
|
|
3162
3247
|
}
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3248
|
+
|
|
3249
|
+
// Use an approach like template-literal's quasis:
|
|
3250
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
3251
|
+
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
3252
|
+
var quasisMap = new Map();
|
|
3253
|
+
if (reversedProxies.slots.has(ref)) {
|
|
3254
|
+
for (var item of reversedProxies.slots.get(ref)) {
|
|
3255
|
+
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
3256
|
+
if (!quasisMap.has(item.refSlot)) {
|
|
3257
|
+
var quasis = [];
|
|
3258
|
+
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
3259
|
+
var size = brickUtils.hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
3260
|
+
for (var i = 0; i < size; i += 1) {
|
|
3261
|
+
quasis.push([]);
|
|
3172
3262
|
}
|
|
3173
|
-
|
|
3174
|
-
} else {
|
|
3175
|
-
validMenuList.push(_menu);
|
|
3263
|
+
quasisMap.set(item.refSlot, quasis);
|
|
3176
3264
|
}
|
|
3265
|
+
var expandableSlot = quasisMap.get(item.refSlot);
|
|
3266
|
+
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
3267
|
+
expandableSlot[_.clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
|
|
3177
3268
|
}
|
|
3178
3269
|
}
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
});
|
|
3186
|
-
return _mergeMenu.apply(this, arguments);
|
|
3187
|
-
}
|
|
3188
|
-
function processGroupInject(items, menu, injectWithMenus, menuWithI18n) {
|
|
3189
|
-
return items === null || items === void 0 ? void 0 : items.map(item => {
|
|
3190
|
-
var _processGroupInject;
|
|
3191
|
-
var foundInjectingMenus = item.groupId && injectWithMenus.get(item.groupId);
|
|
3192
|
-
if (foundInjectingMenus) {
|
|
3193
|
-
// Each menu to be injected with should be injected only once.
|
|
3194
|
-
injectWithMenus.delete(item.groupId);
|
|
3195
|
-
}
|
|
3196
|
-
return _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
|
|
3197
|
-
children: ((_processGroupInject = processGroupInject(item.children || item.items, menu, injectWithMenus, menuWithI18n)) !== null && _processGroupInject !== void 0 ? _processGroupInject : []).concat(foundInjectingMenus ? foundInjectingMenus.flatMap(injectingMenu => processGroupInject(injectingMenu.items, injectingMenu, injectWithMenus, menuWithI18n)) : []),
|
|
3198
|
-
[symbolAppId]: menu.app[0].appId,
|
|
3199
|
-
[symbolMenuI18nNamespace]: menuWithI18n.get(menu),
|
|
3200
|
-
[symbolOverrideApp]: menu.overrideApp
|
|
3201
|
-
});
|
|
3202
|
-
});
|
|
3203
|
-
}
|
|
3204
|
-
function loadDynamicMenuItems(_x12, _x13, _x14) {
|
|
3205
|
-
return _loadDynamicMenuItems.apply(this, arguments);
|
|
3206
|
-
}
|
|
3207
|
-
function _loadDynamicMenuItems() {
|
|
3208
|
-
_loadDynamicMenuItems = _asyncToGenerator__default["default"](function* (menu, kernel, menuWithI18n) {
|
|
3209
|
-
if (menu.dynamicItems && menu.itemsResolve) {
|
|
3210
|
-
var _menu$itemsResolve;
|
|
3211
|
-
var itemsConf = {};
|
|
3212
|
-
var overrideAppId = menu.app[0].appId;
|
|
3213
|
-
var context = _internalApiGetCurrentContext();
|
|
3214
|
-
var newContext = context;
|
|
3215
|
-
if (overrideAppId !== context.app.id && attemptToVisit(menu.itemsResolve, ["APP", "I18N"])) {
|
|
3216
|
-
if (window.STANDALONE_MICRO_APPS) {
|
|
3217
|
-
if (menu.overrideApp) {
|
|
3218
|
-
menu.overrideApp.config = brickUtils.deepFreeze(_.merge({}, menu.overrideApp.defaultConfig, menu.overrideApp.userConfig));
|
|
3219
|
-
}
|
|
3220
|
-
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
3221
|
-
overrideApp: menu.overrideApp,
|
|
3222
|
-
appendI18nNamespace: menuWithI18n.get(menu)
|
|
3223
|
-
});
|
|
3224
|
-
} else {
|
|
3225
|
-
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
3226
|
-
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
3227
|
-
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
3228
|
-
appendI18nNamespace: menuWithI18n.get(menu)
|
|
3229
|
-
});
|
|
3230
|
-
}
|
|
3270
|
+
var _loop = function (slotName, _quasis) {
|
|
3271
|
+
if (!brickUtils.hasOwnProperty(slots, slotName)) {
|
|
3272
|
+
slots[slotName] = {
|
|
3273
|
+
type: "bricks",
|
|
3274
|
+
bricks: []
|
|
3275
|
+
};
|
|
3231
3276
|
}
|
|
3232
|
-
var
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
transformMapArray: false
|
|
3237
|
-
}, menu.itemsResolve), itemsConf, null, newContext);
|
|
3238
|
-
menu.items = itemsConf.items;
|
|
3239
|
-
if ((_menu$itemsResolve = menu.itemsResolve) !== null && _menu$itemsResolve !== void 0 && _menu$itemsResolve.args) {
|
|
3240
|
-
var _menu$itemsResolve2;
|
|
3241
|
-
return !attemptToVisit((_menu$itemsResolve2 = menu.itemsResolve) === null || _menu$itemsResolve2 === void 0 ? void 0 : _menu$itemsResolve2.args, ["QUERY", "PATH"]);
|
|
3277
|
+
var slotConf = slots[slotName];
|
|
3278
|
+
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
3279
|
+
if (slotConf.bricks.length === 0) {
|
|
3280
|
+
delete slots[slotName];
|
|
3242
3281
|
}
|
|
3282
|
+
};
|
|
3283
|
+
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
3284
|
+
_loop(slotName, _quasis);
|
|
3243
3285
|
}
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
// `if` is already evaluated.
|
|
3251
|
-
looseCheckIfOfComputed).map(item => {
|
|
3252
|
-
var children = walkMenuItems(item.children || item.items);
|
|
3253
|
-
return item.type === "group" ? {
|
|
3254
|
-
type: "group",
|
|
3255
|
-
childLayout: item.childLayout,
|
|
3256
|
-
title: item.text || item.title,
|
|
3257
|
-
items: children,
|
|
3258
|
-
groupId: item.groupId,
|
|
3259
|
-
groupFrom: item.groupFrom
|
|
3260
|
-
} : children !== null && children !== void 0 && children.length ? {
|
|
3261
|
-
type: "subMenu",
|
|
3262
|
-
childLayout: item.childLayout,
|
|
3263
|
-
title: item.text || item.title,
|
|
3264
|
-
icon: item.icon,
|
|
3265
|
-
items: children,
|
|
3266
|
-
defaultExpanded: item.defaultExpanded
|
|
3267
|
-
} : item;
|
|
3268
|
-
});
|
|
3269
|
-
}
|
|
3270
|
-
function processMenu(_x15, _x16, _x17, _x18, _x19) {
|
|
3271
|
-
return _processMenu.apply(this, arguments);
|
|
3286
|
+
}
|
|
3287
|
+
return {
|
|
3288
|
+
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
3289
|
+
[symbolForRefForProxy]: refForProxy,
|
|
3290
|
+
[symbolForTplContextId]: templateContextId
|
|
3291
|
+
};
|
|
3272
3292
|
}
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
} = _yield$fetchMenuById,
|
|
3280
|
-
restMenuData = _objectWithoutProperties__default["default"](_yield$fetchMenuById, _excluded3);
|
|
3281
|
-
var usedActions = brickUtils.scanPermissionActionsInAny([items, restMenuData]);
|
|
3282
|
-
yield validatePermissions(usedActions);
|
|
3283
|
-
var appsRequireI18nFulfilled = new Set();
|
|
3284
|
-
var rootAppId = app[0].appId;
|
|
3285
|
-
if (rootAppId !== context.app.id && !restMenuData[symbolMenuI18nNamespace]) {
|
|
3286
|
-
appsRequireI18nFulfilled.add(rootAppId);
|
|
3293
|
+
|
|
3294
|
+
var _excluded$7 = ["properties", "slots"];
|
|
3295
|
+
function setupUseBrickInTemplate(props, proxyContext) {
|
|
3296
|
+
function walk(props) {
|
|
3297
|
+
if (Array.isArray(props)) {
|
|
3298
|
+
return props.map(walk);
|
|
3287
3299
|
}
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
var menuData = _objectSpread__default["default"](_objectSpread__default["default"]({}, yield computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
3291
|
-
items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
3292
|
-
});
|
|
3293
|
-
return {
|
|
3294
|
-
title: yield processMenuTitle(menuData),
|
|
3295
|
-
icon: menuData.icon,
|
|
3296
|
-
link: menuData.link,
|
|
3297
|
-
menuItems: walkMenuItems(menuData.items),
|
|
3298
|
-
defaultCollapsed: menuData.defaultCollapsed || hasSubMenu,
|
|
3299
|
-
defaultCollapsedBreakpoint: menuData.defaultCollapsedBreakpoint
|
|
3300
|
-
};
|
|
3301
|
-
});
|
|
3302
|
-
return _processMenu.apply(this, arguments);
|
|
3303
|
-
}
|
|
3304
|
-
function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
|
|
3305
|
-
function collect(items) {
|
|
3306
|
-
for (var _ref of items) {
|
|
3307
|
-
var {
|
|
3308
|
-
children
|
|
3309
|
-
} = _ref,
|
|
3310
|
-
rest = _objectWithoutProperties__default["default"](_ref, _excluded$7);
|
|
3311
|
-
var overrideAppId = rest[symbolAppId];
|
|
3312
|
-
if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
|
|
3313
|
-
appIds.add(overrideAppId);
|
|
3314
|
-
}
|
|
3315
|
-
children && collect(children);
|
|
3300
|
+
if (!brickUtils.isObject(props) || !isPlainObject(props)) {
|
|
3301
|
+
return props;
|
|
3316
3302
|
}
|
|
3303
|
+
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
3304
|
+
var [key, value] = _ref;
|
|
3305
|
+
return brickUtils.isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
3306
|
+
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
3317
3307
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
return
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3308
|
+
function setup(item) {
|
|
3309
|
+
var {
|
|
3310
|
+
properties,
|
|
3311
|
+
slots: originalSlots
|
|
3312
|
+
} = item,
|
|
3313
|
+
restConf = _objectWithoutProperties__default["default"](item, _excluded$7);
|
|
3314
|
+
var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
|
|
3315
|
+
var _slotConf$bricks;
|
|
3316
|
+
var [slotName, slotConf] = _ref2;
|
|
3317
|
+
return [slotName, {
|
|
3318
|
+
type: "bricks",
|
|
3319
|
+
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
3320
|
+
}];
|
|
3321
|
+
}));
|
|
3322
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, restConf), {}, {
|
|
3323
|
+
properties: walk(properties),
|
|
3324
|
+
slots
|
|
3325
|
+
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
3326
|
+
}
|
|
3327
|
+
return walk(props);
|
|
3335
3328
|
}
|
|
3336
|
-
function
|
|
3337
|
-
return
|
|
3329
|
+
function isPlainObject(object) {
|
|
3330
|
+
return Object.prototype.toString.call(object) === "[object Object]";
|
|
3338
3331
|
}
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3332
|
+
|
|
3333
|
+
var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
3334
|
+
var preEvaluated = isPreEvaluated(value);
|
|
3335
|
+
if (preEvaluated || typeof value === "string") {
|
|
3336
|
+
// For `useBrick`, some fields such as `properties`/`transform`/`events`/`if`,
|
|
3337
|
+
// are kept and to be evaluated later.
|
|
3338
|
+
var lazy = (internalOptions === null || internalOptions === void 0 ? void 0 : internalOptions.$$lazyForUseBrick) && isLazyContentInUseBrick(internalOptions.$$stateOfUseBrick);
|
|
3339
|
+
var result;
|
|
3340
|
+
var dismissRecursiveMarkingInjected = lazy;
|
|
3341
|
+
if (preEvaluated || brickUtils.isEvaluable(value)) {
|
|
3342
|
+
var runtimeContext = {};
|
|
3343
|
+
if (context) {
|
|
3344
|
+
var keys = ["event", "tplContextId", "overrideApp", "appendI18nNamespace", "formContextId", "query", "match", "app", "segues"];
|
|
3345
|
+
for (var key of keys) {
|
|
3346
|
+
if (context[key]) {
|
|
3347
|
+
runtimeContext[key] = context[key];
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
var simpleKeys = ["hash", "pathname"];
|
|
3351
|
+
for (var _key of simpleKeys) {
|
|
3352
|
+
if (brickUtils.hasOwnProperty(context, _key)) {
|
|
3353
|
+
runtimeContext[_key] = context[_key];
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
// The current runtime context is memoized even if the evaluation maybe lazy.
|
|
3358
|
+
result = evaluate(value, runtimeContext, {
|
|
3359
|
+
lazy
|
|
3360
|
+
});
|
|
3361
|
+
dismissRecursiveMarkingInjected = shouldDismissRecursiveMarkingInjected(value);
|
|
3362
|
+
} else {
|
|
3363
|
+
result = lazy ? value : brickUtils.inject(value, context);
|
|
3343
3364
|
}
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
return menuTitleCache.get(cacheKey);
|
|
3365
|
+
if (!dismissRecursiveMarkingInjected) {
|
|
3366
|
+
recursiveMarkAsInjected(result);
|
|
3347
3367
|
}
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
var
|
|
3355
|
-
|
|
3368
|
+
return result;
|
|
3369
|
+
}
|
|
3370
|
+
if (!(injectDeep && brickUtils.isObject(value)) || haveBeenInjected(value)) {
|
|
3371
|
+
return value;
|
|
3372
|
+
}
|
|
3373
|
+
if (Array.isArray(value)) {
|
|
3374
|
+
var nextOptions = getNextInternalOptions(internalOptions, true);
|
|
3375
|
+
return value.map(v => computeRealValue(v, context, injectDeep, nextOptions));
|
|
3376
|
+
}
|
|
3377
|
+
return Object.fromEntries(Object.entries(value).map(_ref => {
|
|
3378
|
+
var [k, v] = _ref;
|
|
3379
|
+
return [computeRealValue(k, context, false), computeRealValue(v, context, injectDeep, getNextInternalOptions(internalOptions, false, k))];
|
|
3380
|
+
}).concat(internalOptions !== null && internalOptions !== void 0 && internalOptions.ignoreSymbols ? [] : Object.getOwnPropertySymbols(value).map(k => [k, value[k]])));
|
|
3381
|
+
};
|
|
3382
|
+
function setProperties(bricks, properties, context, injectDeep) {
|
|
3383
|
+
var realProps = computeRealProperties(properties, context, injectDeep);
|
|
3384
|
+
if (context.tplContextId) {
|
|
3385
|
+
realProps = setupUseBrickInTemplate(realProps, {
|
|
3386
|
+
templateContextId: context.tplContextId
|
|
3356
3387
|
});
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
}
|
|
3364
|
-
menuTitleCache.set(cacheKey, title);
|
|
3365
|
-
return title;
|
|
3366
|
-
});
|
|
3367
|
-
return _processMenuTitle.apply(this, arguments);
|
|
3368
|
-
}
|
|
3369
|
-
function clearMenuTitleCache() {
|
|
3370
|
-
menuTitleCache.clear();
|
|
3371
|
-
}
|
|
3372
|
-
function clearMenuCache() {
|
|
3373
|
-
menuCache.clear();
|
|
3374
|
-
}
|
|
3375
|
-
function reorderMenu(menuData) {
|
|
3376
|
-
menuData.items = reorderMenuItems(menuData.items);
|
|
3377
|
-
}
|
|
3378
|
-
function reorderMenuItems(list) {
|
|
3379
|
-
return sortMenuItems(list).map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
|
|
3380
|
-
children: reorderMenuItems(item.children)
|
|
3381
|
-
}));
|
|
3382
|
-
}
|
|
3383
|
-
function sortMenuItems(list) {
|
|
3384
|
-
return _.sortBy(list, item => {
|
|
3385
|
-
var _item$sort;
|
|
3386
|
-
return (_item$sort = item.sort) !== null && _item$sort !== void 0 ? _item$sort : -Infinity;
|
|
3388
|
+
}
|
|
3389
|
+
if (!Array.isArray(bricks)) {
|
|
3390
|
+
bricks = [bricks];
|
|
3391
|
+
}
|
|
3392
|
+
bricks.forEach(brick => {
|
|
3393
|
+
setRealProperties(brick, realProps);
|
|
3387
3394
|
});
|
|
3388
3395
|
}
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3396
|
+
function setRealProperties(brick, realProps, extractProps) {
|
|
3397
|
+
for (var [propName, propValue] of Object.entries(realProps)) {
|
|
3398
|
+
if (propName === "style" || propName === "dataset") {
|
|
3399
|
+
for (var [k, v] of Object.entries(propValue)) {
|
|
3400
|
+
brick[propName][k] = v;
|
|
3401
|
+
}
|
|
3402
|
+
} else if (propName === "innerHTML") {
|
|
3403
|
+
// `innerHTML` is dangerous, use `textContent` instead.
|
|
3404
|
+
// eslint-disable-next-line no-console
|
|
3405
|
+
console.error("Please use `textContent` instead of `innerHTML`.");
|
|
3406
|
+
brick.textContent = propValue;
|
|
3407
|
+
} else {
|
|
3408
|
+
if (extractProps) {
|
|
3409
|
+
_.set(brick, propName, propValue);
|
|
3410
|
+
} else {
|
|
3411
|
+
brick[propName] = propValue;
|
|
3403
3412
|
}
|
|
3404
|
-
} else if (globals.includes("APP")) {
|
|
3405
|
-
return /\${\s*APP\s*\./.test(data);
|
|
3406
|
-
}
|
|
3407
|
-
} else if (brickUtils.isObject(data)) {
|
|
3408
|
-
// Avoid call stack overflow.
|
|
3409
|
-
// istanbul ignore next
|
|
3410
|
-
if (memo.has(data)) {
|
|
3411
|
-
return false;
|
|
3412
3413
|
}
|
|
3413
|
-
memo.add(data);
|
|
3414
|
-
return (Array.isArray(data) ? data : Object.values(data)).some(item => attemptToVisit(item, globals, memo));
|
|
3415
3414
|
}
|
|
3416
|
-
return false;
|
|
3417
3415
|
}
|
|
3418
|
-
function
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
if ("to" in data && data.to && !brickUtils.isEvaluable(data.to)) {
|
|
3433
|
-
var yaml = pipes.pipes.yaml(data.to);
|
|
3434
|
-
if (brickUtils.isObject(yaml) && ["pathname", "search", "hash"].some(key => brickUtils.hasOwnProperty(yaml, key))) {
|
|
3435
|
-
data.to = yaml;
|
|
3416
|
+
function computeRealProperties(properties, context, injectDeep, trackingContextList) {
|
|
3417
|
+
var result = {};
|
|
3418
|
+
if (brickUtils.isObject(properties)) {
|
|
3419
|
+
for (var [propName, propValue] of Object.entries(properties)) {
|
|
3420
|
+
// Related: https://github.com/facebook/react/issues/11347
|
|
3421
|
+
var realValue = computeRealValue(propValue, context, injectDeep, {
|
|
3422
|
+
$$lazyForUseBrick: true,
|
|
3423
|
+
$$stateOfUseBrick: propName === "useBrick" ? StateOfUseBrick.USE_BRICK : StateOfUseBrick.INITIAL
|
|
3424
|
+
});
|
|
3425
|
+
if (realValue !== undefined) {
|
|
3426
|
+
// For `style` and `dataset`, only object is acceptable.
|
|
3427
|
+
if (propName !== "style" && propName !== "dataset" || brickUtils.isObject(realValue)) {
|
|
3428
|
+
result[propName] = realValue;
|
|
3429
|
+
}
|
|
3436
3430
|
}
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3431
|
+
if (Array.isArray(trackingContextList)) {
|
|
3432
|
+
var {
|
|
3433
|
+
contextNames,
|
|
3434
|
+
stateNames,
|
|
3435
|
+
formStateNames
|
|
3436
|
+
} = getTracks(propValue);
|
|
3437
|
+
if (contextNames || stateNames || formStateNames) {
|
|
3438
|
+
trackingContextList.push({
|
|
3439
|
+
contextNames,
|
|
3440
|
+
stateNames,
|
|
3441
|
+
formStateNames,
|
|
3442
|
+
propName,
|
|
3443
|
+
propValue
|
|
3444
|
+
});
|
|
3443
3445
|
}
|
|
3444
|
-
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
3445
|
-
overrideApp: data[symbolOverrideApp],
|
|
3446
|
-
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3447
|
-
});
|
|
3448
|
-
} else {
|
|
3449
|
-
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
3450
|
-
newContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, context), {}, {
|
|
3451
|
-
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
3452
|
-
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3453
|
-
});
|
|
3454
3446
|
}
|
|
3455
3447
|
}
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
});
|
|
3463
|
-
|
|
3448
|
+
}
|
|
3449
|
+
return result;
|
|
3450
|
+
}
|
|
3451
|
+
function getNextInternalOptions(internalOptions, isArray, key) {
|
|
3452
|
+
return internalOptions !== null && internalOptions !== void 0 && internalOptions.$$lazyForUseBrick ? _objectSpread__default["default"](_objectSpread__default["default"]({}, internalOptions), {}, {
|
|
3453
|
+
$$stateOfUseBrick: getNextStateOfUseBrick(internalOptions.$$stateOfUseBrick, isArray, key)
|
|
3454
|
+
}) : internalOptions;
|
|
3455
|
+
}
|
|
3456
|
+
|
|
3457
|
+
var brickTemplateRegistry = new Map();
|
|
3458
|
+
function registerBrickTemplate(name, factory) {
|
|
3459
|
+
if (brickTemplateRegistry.has(name)) {
|
|
3460
|
+
// eslint-disable-next-line no-console
|
|
3461
|
+
console.error("Brick template of \"".concat(name, "\" already registered."));
|
|
3462
|
+
return;
|
|
3463
|
+
}
|
|
3464
|
+
brickTemplateRegistry.set(name, factory);
|
|
3464
3465
|
}
|
|
3465
3466
|
|
|
3466
3467
|
var lazyBrickRegistry = new Map();
|
|
@@ -3652,10 +3653,39 @@
|
|
|
3652
3653
|
}
|
|
3653
3654
|
|
|
3654
3655
|
/* istanbul ignore next */
|
|
3656
|
+
function _dev_only_debugDataValue(_x, _x2) {
|
|
3657
|
+
return _dev_only_debugDataValue2.apply(this, arguments);
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
/* istanbul ignore next */
|
|
3661
|
+
function _dev_only_debugDataValue2() {
|
|
3662
|
+
_dev_only_debugDataValue2 = _asyncToGenerator__default["default"](function* (debugData, _ref3) {
|
|
3663
|
+
var {
|
|
3664
|
+
tplContextId
|
|
3665
|
+
} = _ref3;
|
|
3666
|
+
var runtimeContext = _objectSpread__default["default"](_objectSpread__default["default"]({}, _internalApiGetCurrentContext()), {}, {
|
|
3667
|
+
tplContextId
|
|
3668
|
+
});
|
|
3669
|
+
if (debugData.value) {
|
|
3670
|
+
return computeRealValue(debugData.value, runtimeContext, true);
|
|
3671
|
+
}
|
|
3672
|
+
var hasTransform = debugData.resolve.transform;
|
|
3673
|
+
var result = {};
|
|
3674
|
+
yield _internalApiGetResolver().resolveOne("reference", hasTransform ? debugData.resolve : _objectSpread__default["default"](_objectSpread__default["default"]({}, debugData.resolve), {}, {
|
|
3675
|
+
transform: "value"
|
|
3676
|
+
}), result, null, runtimeContext, {
|
|
3677
|
+
cache: "reload"
|
|
3678
|
+
});
|
|
3679
|
+
|
|
3680
|
+
// 跟 v3 的数据结构保持一致,有 transform 时返回完整定义,无 transform 时直接返回数据
|
|
3681
|
+
return hasTransform ? result : result.value;
|
|
3682
|
+
});
|
|
3683
|
+
return _dev_only_debugDataValue2.apply(this, arguments);
|
|
3684
|
+
}
|
|
3655
3685
|
function _dev_only_updateFormPreviewSettings(appId, formId, settings) {
|
|
3656
3686
|
kernel._dev_only_updateFormPreviewSettings(appId, formId, settings);
|
|
3657
3687
|
}
|
|
3658
|
-
function _dev_only_render(
|
|
3688
|
+
function _dev_only_render(_x3, _x4) {
|
|
3659
3689
|
return _dev_only_render2.apply(this, arguments);
|
|
3660
3690
|
}
|
|
3661
3691
|
function _dev_only_render2() {
|
|
@@ -14444,6 +14474,7 @@
|
|
|
14444
14474
|
getAddedContracts: _dev_only_getAddedContracts,
|
|
14445
14475
|
getContextValue: _dev_only_getContextValue,
|
|
14446
14476
|
getAllContextValues: _dev_only_getAllContextValues,
|
|
14477
|
+
debugDataValue: _dev_only_debugDataValue,
|
|
14447
14478
|
render: _dev_only_render,
|
|
14448
14479
|
setRealTimeDataInspectRoot,
|
|
14449
14480
|
addRealTimeDataInspectHook
|