@next-core/brick-kit 2.192.0 → 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 +2004 -1974
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +1966 -1936
- package/dist/index.esm.js.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 +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -3,16 +3,16 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
4
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
|
|
6
|
-
import _, { escapeRegExp, set, get, difference, identity, uniqueId,
|
|
7
|
-
import {
|
|
6
|
+
import _, { escapeRegExp, set, get, difference, identity, uniqueId, isNil, isEmpty, merge, sortBy, cloneDeep, clamp, orderBy, pick, isObject as isObject$1, uniq, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
|
|
7
|
+
import { toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, isTrackAll, trackAll, trackContext, trackState, trackFormState, transformAndInject, transform, JsonStorage, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, scanPermissionActionsInAny, deepFreeze, scanProcessorsInAny, preevaluate, shouldAllowRecursiveEvaluations, inject, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, snippetEvaluate, scanCustomApisInStoryboard, prefetchScript, scanBricksInBrickConf, loadScript, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
8
|
+
import moment from 'moment';
|
|
9
|
+
import { pipes } from '@next-core/pipes';
|
|
10
|
+
import i18next, { getFixedT } from 'i18next';
|
|
8
11
|
import React, { useState, useEffect, useMemo, useContext, createContext, useRef, useReducer, useCallback } from 'react';
|
|
9
12
|
import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
|
|
13
|
+
import { userAnalytics, apiAnalyzer } from '@next-core/easyops-analytics';
|
|
10
14
|
import { Modal, message, Empty, ConfigProvider } from 'antd';
|
|
11
15
|
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
|
12
|
-
import i18next, { getFixedT } from 'i18next';
|
|
13
|
-
import moment from 'moment';
|
|
14
|
-
import { pipes } from '@next-core/pipes';
|
|
15
|
-
import { userAnalytics, apiAnalyzer } from '@next-core/easyops-analytics';
|
|
16
16
|
import yaml from 'js-yaml';
|
|
17
17
|
import { loadBricksImperatively, loadProcessorsImperatively } from '@next-core/loader';
|
|
18
18
|
import { withTranslation } from 'react-i18next';
|
|
@@ -291,999 +291,885 @@ var assertValidOperator = op => {
|
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
294
|
+
function supply(attemptToVisitGlobals, providedGlobalVariables, mock) {
|
|
295
|
+
var globalVariables = _objectSpread({}, providedGlobalVariables);
|
|
296
|
+
// Allow limited browser builtin values.
|
|
297
|
+
globalVariables["undefined"] = undefined;
|
|
298
|
+
for (var variableName of attemptToVisitGlobals) {
|
|
299
|
+
if (!Object.prototype.hasOwnProperty.call(globalVariables, variableName)) {
|
|
300
|
+
var variable = supplyIndividual(variableName, mock);
|
|
301
|
+
if (variable !== undefined) {
|
|
302
|
+
globalVariables[variableName] = variable;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
300
305
|
}
|
|
301
|
-
|
|
306
|
+
return globalVariables;
|
|
302
307
|
}
|
|
308
|
+
var shouldOmitInLodash = new Set([
|
|
309
|
+
// Omit all mutable methods from lodash.
|
|
310
|
+
// But allow sequence methods like `_.chain`.
|
|
311
|
+
"fill", "pull", "pullAll", "pullAllBy", "pullAllWith", "pullAt", "remove", "reverse", "assign", "assignIn", "assignInWith", "assignWith", "defaults", "defaultsDeep", "merge", "mergeWith", "set", "setWith", "unset", "update", "updateWith",
|
|
312
|
+
/**
|
|
313
|
+
* Ignore `Function` methods from lodash, too.
|
|
314
|
+
* There are chances to invoke `Object.assign`, etc.
|
|
315
|
+
*
|
|
316
|
+
* E.g.:
|
|
317
|
+
*
|
|
318
|
+
* ```
|
|
319
|
+
* _.wrap(_.method('constructor.assign',{b:2},{b:3}),(func,...a) => func(...a))({})
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
"after", "ary", "before", "bind", "bindKey", "curry", "curryRight", "debounce", "defer", "delay", "flip", "memoize", "negate", "once", "overArgs", "partial", "partialRight", "rearg", "rest", "spread", "throttle", "unary", "wrap"]);
|
|
303
323
|
|
|
304
|
-
//
|
|
305
|
-
var
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
324
|
+
// Omit all mutable methods from moment.
|
|
325
|
+
var shouldOmitInMoment = new Set(["lang", "langData", "locale", "localeData", "defineLocale", "updateLocale", "updateOffset"]);
|
|
326
|
+
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"]);
|
|
327
|
+
function supplyIndividual(variableName, mock) {
|
|
328
|
+
switch (variableName) {
|
|
329
|
+
case "Object":
|
|
330
|
+
// Do not allow mutable methods like `Object.assign`.
|
|
331
|
+
return delegateMethods(Object, ["entries", "fromEntries", "keys", "values"]);
|
|
332
|
+
case "_":
|
|
333
|
+
return Object.fromEntries(Object.entries(_).filter(entry => !shouldOmitInLodash.has(entry[0])).concat(mock ? [["uniqueId", prefix => "".concat(prefix !== null && prefix !== void 0 ? prefix : "", "42")]] : []));
|
|
334
|
+
case "moment":
|
|
335
|
+
return Object.assign(function () {
|
|
336
|
+
return moment(...arguments);
|
|
337
|
+
}, Object.fromEntries(Object.entries(moment).filter(entry => !shouldOmitInMoment.has(entry[0]))));
|
|
338
|
+
case "PIPES":
|
|
339
|
+
return pipes;
|
|
340
|
+
case "TAG_URL":
|
|
341
|
+
return tagUrlFactory(true);
|
|
342
|
+
case "SAFE_TAG_URL":
|
|
343
|
+
return tagUrlFactory();
|
|
344
|
+
default:
|
|
345
|
+
if (allowedGlobalObjects.has(variableName)) {
|
|
346
|
+
return window[variableName];
|
|
347
|
+
}
|
|
312
348
|
}
|
|
313
|
-
theme = value;
|
|
314
349
|
}
|
|
315
|
-
function
|
|
316
|
-
return
|
|
350
|
+
function delegateMethods(target, methods) {
|
|
351
|
+
return Object.fromEntries(methods.map(method => [method, function () {
|
|
352
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
353
|
+
args[_key] = arguments[_key];
|
|
354
|
+
}
|
|
355
|
+
return target[method].apply(target, args);
|
|
356
|
+
}]));
|
|
317
357
|
}
|
|
318
|
-
|
|
319
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Pass `ignoreSlashes` as `true` to encode all tagged expressions
|
|
360
|
+
* as URL components, except for `/` which maybe used in `APP.homepage`.
|
|
361
|
+
*
|
|
362
|
+
* Otherwise encode all tagged expressions as URL components.
|
|
363
|
+
* This will encode `/` as `%2F`. So do not use it directly
|
|
364
|
+
* with `APP.homepage` as in template expressions.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
*
|
|
368
|
+
* ```js
|
|
369
|
+
* TAG_URL`${APP.homepage}/list?q=${q}&redirect=${redirect}`
|
|
370
|
+
* ```
|
|
371
|
+
*
|
|
372
|
+
* ```js
|
|
373
|
+
* SAFE_TAG_URL`file/${path}?q=${q}`
|
|
374
|
+
* // `path` will be fully transformed by `encodeURIComponent`.
|
|
375
|
+
* ```
|
|
376
|
+
*
|
|
377
|
+
* ```js
|
|
378
|
+
* // Wrap `APP.homepage` outside of `SAFE_TAG_URL`.
|
|
379
|
+
* `${APP.homepage}/${SAFE_TAG_URL`file/${path}?q=${q}`}`
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
function tagUrlFactory(ignoreSlashes) {
|
|
383
|
+
return function (strings) {
|
|
384
|
+
for (var _len2 = arguments.length, partials = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
385
|
+
partials[_key2 - 1] = arguments[_key2];
|
|
386
|
+
}
|
|
387
|
+
var result = [];
|
|
388
|
+
strings.forEach((str, index) => {
|
|
389
|
+
result.push(str);
|
|
390
|
+
if (index < partials.length) {
|
|
391
|
+
result.push(ignoreSlashes ? String(partials[index]).replace(/[^/]+/g, p => encodeURIComponent(p)) : encodeURIComponent(String(partials[index])));
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
return result.join("");
|
|
395
|
+
};
|
|
320
396
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
397
|
+
|
|
398
|
+
function getUrlByAliasFactory(app) {
|
|
399
|
+
return function getUrlByAlias(alias, pathParams, query) {
|
|
400
|
+
if (!(app !== null && app !== void 0 && app.$$routeAliasMap.has(alias))) {
|
|
401
|
+
// eslint-disable-next-line no-console
|
|
402
|
+
throw new Error("Route alias not found: ".concat(alias));
|
|
403
|
+
}
|
|
404
|
+
var routeConf = app.$$routeAliasMap.get(alias);
|
|
405
|
+
var url = toPath(computeRealRoutePath(routeConf.path, app), pathParams);
|
|
406
|
+
if (query) {
|
|
407
|
+
var urlSearchParams = new URLSearchParams();
|
|
408
|
+
for (var [key, value] of Object.entries(query)) {
|
|
409
|
+
if (Array.isArray(value)) {
|
|
410
|
+
for (var item of value) {
|
|
411
|
+
urlSearchParams.append(key, item);
|
|
412
|
+
}
|
|
413
|
+
} else if (value !== undefined && value !== null && value !== "") {
|
|
414
|
+
urlSearchParams.set(key, value);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
var queryString = urlSearchParams.toString();
|
|
418
|
+
if (queryString.length > 0) {
|
|
419
|
+
url += "?".concat(queryString);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return url;
|
|
423
|
+
};
|
|
333
424
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}, []);
|
|
345
|
-
return currentTheme;
|
|
425
|
+
|
|
426
|
+
function getUrlBySegueFactory(app, segues) {
|
|
427
|
+
return function getUrlBySegue(segueId, pathParams, query) {
|
|
428
|
+
if (!hasOwnProperty(segues, segueId)) {
|
|
429
|
+
// eslint-disable-next-line no-console
|
|
430
|
+
throw new Error("Segue not found: ".concat(segueId));
|
|
431
|
+
}
|
|
432
|
+
var segue = segues[segueId];
|
|
433
|
+
return getUrlByAliasFactory(app)(segue.target, pathParams, query);
|
|
434
|
+
};
|
|
346
435
|
}
|
|
347
|
-
|
|
348
|
-
|
|
436
|
+
|
|
437
|
+
function imagesFactory(appId, isBuildPush, version) {
|
|
438
|
+
return {
|
|
439
|
+
get(name) {
|
|
440
|
+
var getSuffix = () => {
|
|
441
|
+
var suffix = window.APP_ROOT ? "".concat(window.APP_ROOT).concat(window.BOOTSTRAP_UNION_FILE && window.PUBLIC_DEPS ? "" : "-/") : "";
|
|
442
|
+
if (!suffix.startsWith("/")) {
|
|
443
|
+
suffix = getBasePath() + suffix;
|
|
444
|
+
}
|
|
445
|
+
if (window.APP_ID && window.APP_ID !== appId) {
|
|
446
|
+
return suffix.replace(new RegExp("(^|/)".concat(escapeRegExp(window.APP_ID), "/")), "$1".concat(appId, "/")).replace(/\/\d+\.\d+\.\d+\//, "/".concat(version, "/"));
|
|
447
|
+
}
|
|
448
|
+
return suffix;
|
|
449
|
+
};
|
|
450
|
+
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);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
349
453
|
}
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
return result || {};
|
|
454
|
+
function widgetImagesFactory(widgetId, widgetVersion) {
|
|
455
|
+
return {
|
|
456
|
+
get(name) {
|
|
457
|
+
var _window$PUBLIC_ROOT;
|
|
458
|
+
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);
|
|
459
|
+
}
|
|
460
|
+
};
|
|
359
461
|
}
|
|
360
462
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
463
|
+
var injected = new WeakSet();
|
|
464
|
+
|
|
465
|
+
// The injected (or transformed) result should never be *injected* again.
|
|
466
|
+
// So does the fetched data from a remote api.
|
|
467
|
+
function recursiveMarkAsInjected(value) {
|
|
468
|
+
if (isObject(value)) {
|
|
469
|
+
if (!haveBeenInjected(value)) {
|
|
470
|
+
injected.add(value);
|
|
471
|
+
if (Array.isArray(value)) {
|
|
472
|
+
value.forEach(recursiveMarkAsInjected);
|
|
473
|
+
} else {
|
|
474
|
+
// Only mark pure objects.
|
|
475
|
+
var proto = Object.getPrototypeOf(value);
|
|
476
|
+
if (!proto || proto.constructor === Object) {
|
|
477
|
+
Object.values(value).forEach(recursiveMarkAsInjected);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
367
481
|
}
|
|
368
|
-
mode = value;
|
|
369
482
|
}
|
|
370
|
-
function
|
|
371
|
-
return
|
|
483
|
+
function haveBeenInjected(object) {
|
|
484
|
+
return injected.has(object);
|
|
372
485
|
}
|
|
373
|
-
function
|
|
374
|
-
|
|
486
|
+
function resetAllInjected() {
|
|
487
|
+
injected = new WeakSet();
|
|
375
488
|
}
|
|
376
|
-
function
|
|
377
|
-
if (value) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
value
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
489
|
+
function cloneDeepWithInjectedMark(value) {
|
|
490
|
+
if (isObject(value) && !isPreEvaluated(value)) {
|
|
491
|
+
var clone = Array.isArray(value) ? value.map(item => cloneDeepWithInjectedMark(item)) : Object.fromEntries(
|
|
492
|
+
// Get both string and symbol keys.
|
|
493
|
+
Object.entries(value).map(_ref => {
|
|
494
|
+
var [k, v] = _ref;
|
|
495
|
+
return [k, cloneDeepWithInjectedMark(v)];
|
|
496
|
+
}).concat(Object.getOwnPropertySymbols(value).map(k => [k, value[k]])));
|
|
497
|
+
if (haveBeenInjected(value)) {
|
|
498
|
+
injected.add(clone);
|
|
499
|
+
}
|
|
500
|
+
return clone;
|
|
387
501
|
}
|
|
388
|
-
|
|
389
|
-
function useCurrentMode() {
|
|
390
|
-
var [currentMode, setCurrentMode] = useState(getCurrentMode());
|
|
391
|
-
useEffect(() => {
|
|
392
|
-
var listenToModeChange = event => {
|
|
393
|
-
setCurrentMode(event.detail);
|
|
394
|
-
};
|
|
395
|
-
window.addEventListener("mode.change", listenToModeChange);
|
|
396
|
-
return () => {
|
|
397
|
-
window.removeEventListener("mode.change", listenToModeChange);
|
|
398
|
-
};
|
|
399
|
-
}, []);
|
|
400
|
-
return currentMode;
|
|
401
|
-
}
|
|
402
|
-
function getCssPropertyValue(name) {
|
|
403
|
-
var _window$getComputedSt;
|
|
404
|
-
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.documentElement;
|
|
405
|
-
if (!el) return "";
|
|
406
|
-
return ((_window$getComputedSt = window.getComputedStyle(el)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue(name)) || "";
|
|
502
|
+
return value;
|
|
407
503
|
}
|
|
408
504
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
505
|
+
var StateOfUseBrick;
|
|
506
|
+
(function (StateOfUseBrick) {
|
|
507
|
+
StateOfUseBrick[StateOfUseBrick["INITIAL"] = 0] = "INITIAL";
|
|
508
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK"] = 1] = "USE_BRICK";
|
|
509
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_ITEM"] = 2] = "USE_BRICK_ITEM";
|
|
510
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_PROPERTIES"] = 3] = "USE_BRICK_PROPERTIES";
|
|
511
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_TRANSFORM"] = 4] = "USE_BRICK_TRANSFORM";
|
|
512
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_EVENTS"] = 5] = "USE_BRICK_EVENTS";
|
|
513
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_IF"] = 6] = "USE_BRICK_IF";
|
|
514
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS"] = 7] = "USE_BRICK_SLOTS";
|
|
515
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM"] = 8] = "USE_BRICK_SLOTS_ITEM";
|
|
516
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM_BRICKS"] = 9] = "USE_BRICK_SLOTS_ITEM_BRICKS";
|
|
517
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_SLOTS_ITEM_BRICKS_ITEM"] = 10] = "USE_BRICK_SLOTS_ITEM_BRICKS_ITEM";
|
|
518
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE"] = 11] = "USE_BRICK_LIFECYCLE";
|
|
519
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES"] = 12] = "USE_BRICK_LIFECYCLE_USERESOLVES";
|
|
520
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM"] = 13] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM";
|
|
521
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM"] = 14] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM";
|
|
522
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT"] = 15] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT";
|
|
523
|
+
StateOfUseBrick[StateOfUseBrick["USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM"] = 16] = "USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM";
|
|
524
|
+
})(StateOfUseBrick || (StateOfUseBrick = {}));
|
|
525
|
+
function isLazyContentInUseBrick(state) {
|
|
526
|
+
switch (state) {
|
|
527
|
+
case StateOfUseBrick.USE_BRICK_PROPERTIES:
|
|
528
|
+
case StateOfUseBrick.USE_BRICK_TRANSFORM:
|
|
529
|
+
case StateOfUseBrick.USE_BRICK_EVENTS:
|
|
530
|
+
case StateOfUseBrick.USE_BRICK_IF:
|
|
531
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM:
|
|
532
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM:
|
|
533
|
+
return true;
|
|
416
534
|
}
|
|
417
|
-
|
|
418
|
-
|
|
535
|
+
return false;
|
|
536
|
+
}
|
|
537
|
+
function getNextStateOfUseBrick(state, isArray, key) {
|
|
538
|
+
if (isLazyContentInUseBrick(state)) {
|
|
539
|
+
return state;
|
|
540
|
+
}
|
|
541
|
+
if (isArray) {
|
|
542
|
+
switch (state) {
|
|
543
|
+
case StateOfUseBrick.USE_BRICK:
|
|
544
|
+
return StateOfUseBrick.USE_BRICK_ITEM;
|
|
545
|
+
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS:
|
|
546
|
+
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS_ITEM;
|
|
547
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES:
|
|
548
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM;
|
|
549
|
+
}
|
|
419
550
|
} else {
|
|
420
|
-
|
|
551
|
+
switch (state) {
|
|
552
|
+
case StateOfUseBrick.INITIAL:
|
|
553
|
+
if (key === "useBrick") {
|
|
554
|
+
return StateOfUseBrick.USE_BRICK;
|
|
555
|
+
}
|
|
556
|
+
break;
|
|
557
|
+
case StateOfUseBrick.USE_BRICK:
|
|
558
|
+
case StateOfUseBrick.USE_BRICK_ITEM:
|
|
559
|
+
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS_ITEM:
|
|
560
|
+
{
|
|
561
|
+
switch (key) {
|
|
562
|
+
case "properties":
|
|
563
|
+
return StateOfUseBrick.USE_BRICK_PROPERTIES;
|
|
564
|
+
case "transform":
|
|
565
|
+
return StateOfUseBrick.USE_BRICK_TRANSFORM;
|
|
566
|
+
case "events":
|
|
567
|
+
return StateOfUseBrick.USE_BRICK_EVENTS;
|
|
568
|
+
case "slots":
|
|
569
|
+
return StateOfUseBrick.USE_BRICK_SLOTS;
|
|
570
|
+
case "if":
|
|
571
|
+
return StateOfUseBrick.USE_BRICK_IF;
|
|
572
|
+
case "lifeCycle":
|
|
573
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE;
|
|
574
|
+
}
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
case StateOfUseBrick.USE_BRICK_SLOTS:
|
|
578
|
+
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM;
|
|
579
|
+
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM:
|
|
580
|
+
if (key === "bricks") {
|
|
581
|
+
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS;
|
|
582
|
+
}
|
|
583
|
+
break;
|
|
584
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE:
|
|
585
|
+
if (key === "useResolves") {
|
|
586
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES;
|
|
587
|
+
}
|
|
588
|
+
break;
|
|
589
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM:
|
|
590
|
+
{
|
|
591
|
+
switch (key) {
|
|
592
|
+
case "transform":
|
|
593
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM;
|
|
594
|
+
case "onReject":
|
|
595
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT;
|
|
596
|
+
}
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT:
|
|
600
|
+
if (key === "transform") {
|
|
601
|
+
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM;
|
|
602
|
+
}
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
421
605
|
}
|
|
606
|
+
return StateOfUseBrick.INITIAL;
|
|
422
607
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
608
|
+
|
|
609
|
+
function getTracks(value) {
|
|
610
|
+
var contextNames = false;
|
|
611
|
+
var stateNames = false;
|
|
612
|
+
var formStateNames = false;
|
|
613
|
+
if (typeof value === "string" ? isEvaluable(value) : isPreEvaluated(value)) {
|
|
614
|
+
var raw = typeof value === "string" ? value : getPreEvaluatedRaw(value);
|
|
615
|
+
if (isTrackAll(raw)) {
|
|
616
|
+
var result = trackAll(raw);
|
|
617
|
+
if (result) {
|
|
618
|
+
contextNames = result.context;
|
|
619
|
+
stateNames = result.state;
|
|
620
|
+
formStateNames = result.formState;
|
|
434
621
|
}
|
|
435
|
-
|
|
436
|
-
|
|
622
|
+
} else {
|
|
623
|
+
contextNames = trackContext(raw);
|
|
624
|
+
stateNames = trackState(raw);
|
|
625
|
+
formStateNames = trackFormState(raw);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
contextNames,
|
|
630
|
+
stateNames,
|
|
631
|
+
formStateNames
|
|
437
632
|
};
|
|
438
633
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
configurable: true,
|
|
445
|
-
writable: true
|
|
446
|
-
});
|
|
447
|
-
} else {
|
|
448
|
-
obj[key] = value;
|
|
449
|
-
}
|
|
450
|
-
return obj;
|
|
634
|
+
|
|
635
|
+
/** @internal */
|
|
636
|
+
function transformElementProperties(element, data, to, from, mapArray) {
|
|
637
|
+
var result = preprocessTransformProperties(data, to, from, mapArray);
|
|
638
|
+
setRealProperties(element, result, true);
|
|
451
639
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
});
|
|
459
|
-
keys.push.apply(keys, symbols);
|
|
640
|
+
|
|
641
|
+
/** @internal */
|
|
642
|
+
function transformProperties(props, data, to, from, mapArray, options) {
|
|
643
|
+
var result = preprocessTransformProperties(data, to, from, mapArray, options);
|
|
644
|
+
for (var [propName, propValue] of Object.entries(result)) {
|
|
645
|
+
set(props, propName, propValue);
|
|
460
646
|
}
|
|
461
|
-
return
|
|
647
|
+
return props;
|
|
462
648
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
649
|
+
|
|
650
|
+
/** @internal */
|
|
651
|
+
function doTransform(data, to, options) {
|
|
652
|
+
var preEvaluated = isPreEvaluated(to);
|
|
653
|
+
if (preEvaluated || typeof to === "string") {
|
|
654
|
+
// For `useBrick`, some fields such as `properties`/`transform`/`events`,
|
|
655
|
+
// are kept and to be transformed later.
|
|
656
|
+
var lazy = (options === null || options === void 0 ? void 0 : options.$$lazyForUseBrick) && isLazyContentInUseBrick(options.$$stateOfUseBrick);
|
|
657
|
+
if (lazy) {
|
|
658
|
+
// The current data context is not memoized, since a new data context
|
|
659
|
+
// should always be provided before later transformations.
|
|
660
|
+
return to;
|
|
661
|
+
}
|
|
662
|
+
var result;
|
|
663
|
+
var dismissRecursiveMarkingInjected = false;
|
|
664
|
+
if (preEvaluated || isEvaluable(to)) {
|
|
665
|
+
var runtimeContext = {
|
|
666
|
+
data
|
|
667
|
+
};
|
|
668
|
+
if (options !== null && options !== void 0 && options.tplContextId) runtimeContext.tplContextId = options.tplContextId;
|
|
669
|
+
if (options !== null && options !== void 0 && options.formContextId) runtimeContext.formContextId = options.formContextId;
|
|
670
|
+
result = evaluate(to, runtimeContext, options === null || options === void 0 ? void 0 : options.evaluateOptions);
|
|
671
|
+
dismissRecursiveMarkingInjected = shouldDismissRecursiveMarkingInjected(to);
|
|
472
672
|
} else {
|
|
473
|
-
|
|
474
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
475
|
-
});
|
|
673
|
+
result = options !== null && options !== void 0 && options.allowInject ? transformAndInject(to, data, _internalApiGetCurrentContext()) : transform(to, data);
|
|
476
674
|
}
|
|
477
|
-
|
|
478
|
-
|
|
675
|
+
if (!dismissRecursiveMarkingInjected) {
|
|
676
|
+
recursiveMarkAsInjected(result);
|
|
677
|
+
}
|
|
678
|
+
return result;
|
|
679
|
+
}
|
|
680
|
+
if (!isObject(to) || haveBeenInjected(to)) {
|
|
681
|
+
return to;
|
|
682
|
+
}
|
|
683
|
+
if (Array.isArray(to)) {
|
|
684
|
+
var nextOptions = getNextDoTransformOptions(options, true);
|
|
685
|
+
return to.map(item => doTransform(data, item, nextOptions));
|
|
686
|
+
}
|
|
687
|
+
return Object.fromEntries(
|
|
688
|
+
// Get both string and symbol keys.
|
|
689
|
+
Object.entries(to).map(_ref => {
|
|
690
|
+
var [k, v] = _ref;
|
|
691
|
+
if (Array.isArray(options === null || options === void 0 ? void 0 : options.trackingContextList) && (typeof v === "string" ? isEvaluable(v) : isPreEvaluated(v))) {
|
|
692
|
+
var raw;
|
|
693
|
+
if (typeof v === "string") {
|
|
694
|
+
raw = v;
|
|
695
|
+
} else {
|
|
696
|
+
raw = getPreEvaluatedRaw(v);
|
|
697
|
+
addDataToPreEvaluated(v, data);
|
|
698
|
+
}
|
|
699
|
+
var {
|
|
700
|
+
contextNames,
|
|
701
|
+
stateNames,
|
|
702
|
+
formStateNames
|
|
703
|
+
} = getTracks(raw);
|
|
704
|
+
if (contextNames || stateNames || formStateNames) {
|
|
705
|
+
options.trackingContextList.push({
|
|
706
|
+
contextNames,
|
|
707
|
+
stateNames,
|
|
708
|
+
formStateNames,
|
|
709
|
+
propName: k,
|
|
710
|
+
propValue: v
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return [k, doTransform(data, v, getNextDoTransformOptions(options, false, k))];
|
|
715
|
+
}).concat(Object.getOwnPropertySymbols(to).map(k => [k, to[k]])));
|
|
479
716
|
}
|
|
480
717
|
|
|
481
|
-
/**
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
718
|
+
/** @internal */
|
|
719
|
+
function reTransformForDevtools(transformationId, data, to, from, mapArray, allowInject) {
|
|
720
|
+
try {
|
|
721
|
+
preprocessTransformProperties(data, to, from, mapArray, {
|
|
722
|
+
isReTransformation: true,
|
|
723
|
+
transformationId,
|
|
724
|
+
allowInject
|
|
725
|
+
});
|
|
726
|
+
} catch (error) {
|
|
727
|
+
devtoolsHookEmit("re-transformation", {
|
|
728
|
+
id: transformationId,
|
|
729
|
+
error: error.message,
|
|
730
|
+
detail: {
|
|
731
|
+
transform: to,
|
|
732
|
+
data,
|
|
733
|
+
options: {
|
|
734
|
+
from,
|
|
735
|
+
mapArray,
|
|
736
|
+
allowInject
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
}
|
|
497
742
|
|
|
498
|
-
/**
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
743
|
+
/** @internal */
|
|
744
|
+
function preprocessTransformProperties(data, to, from, mapArray, options) {
|
|
745
|
+
var props = {};
|
|
746
|
+
var processedData = from ? get(data, from) : data;
|
|
747
|
+
if (Array.isArray(to)) {
|
|
748
|
+
for (var item of to) {
|
|
749
|
+
pipeableTransform(props, processedData, item.to, item.from, item.mapArray, {
|
|
750
|
+
allowInject: options === null || options === void 0 ? void 0 : options.allowInject
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
} else {
|
|
754
|
+
pipeableTransform(props, processedData, to, undefined, mapArray, {
|
|
755
|
+
allowInject: options === null || options === void 0 ? void 0 : options.allowInject
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
var detail = {
|
|
759
|
+
transform: to,
|
|
760
|
+
data,
|
|
761
|
+
options: {
|
|
762
|
+
from,
|
|
763
|
+
mapArray,
|
|
764
|
+
allowInject: options === null || options === void 0 ? void 0 : options.allowInject
|
|
765
|
+
},
|
|
766
|
+
result: props
|
|
510
767
|
};
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
768
|
+
if (options !== null && options !== void 0 && options.isReTransformation) {
|
|
769
|
+
devtoolsHookEmit("re-transformation", {
|
|
770
|
+
id: options.transformationId,
|
|
771
|
+
detail
|
|
772
|
+
});
|
|
773
|
+
} else {
|
|
774
|
+
devtoolsHookEmit("transformation", detail);
|
|
775
|
+
}
|
|
776
|
+
return props;
|
|
777
|
+
}
|
|
778
|
+
function pipeableTransform(props, data, to, from, mapArray, options) {
|
|
779
|
+
if (!to) {
|
|
780
|
+
// Do nothing if `to` is falsy.
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
var fromData = from ? get(data, from) : data;
|
|
784
|
+
var isArray = Array.isArray(fromData);
|
|
785
|
+
if (!isArray && mapArray === true) {
|
|
786
|
+
isArray = true;
|
|
787
|
+
fromData = [fromData];
|
|
788
|
+
} else if (isArray && mapArray === false) {
|
|
789
|
+
isArray = false;
|
|
790
|
+
}
|
|
791
|
+
if (typeof to === "string") {
|
|
792
|
+
props[to] = fromData;
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
var _loop = function (transformedPropName, transformTo) {
|
|
796
|
+
// If `fromData` is an array, mapping it's items.
|
|
797
|
+
props[transformedPropName] = isArray ? fromData.map(item => doTransform(item, transformTo, options)) : doTransform(fromData, transformTo, options);
|
|
526
798
|
};
|
|
527
|
-
|
|
799
|
+
for (var [transformedPropName, transformTo] of Object.entries(to)) {
|
|
800
|
+
_loop(transformedPropName, transformTo);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
528
803
|
|
|
529
|
-
/**
|
|
804
|
+
/** @internal */
|
|
805
|
+
function transformIntermediateData(data, to, from, mapArray) {
|
|
806
|
+
var intermediateData = from ? get(data, from) : data;
|
|
807
|
+
if (!to) {
|
|
808
|
+
return intermediateData;
|
|
809
|
+
}
|
|
810
|
+
return transformProperties({}, intermediateData, to, undefined, mapArray);
|
|
811
|
+
}
|
|
812
|
+
function getNextDoTransformOptions(options, isArray, key) {
|
|
813
|
+
var _options$$$stateOfUse;
|
|
814
|
+
return options ? _objectSpread(_objectSpread({}, options), {}, {
|
|
815
|
+
// Collect tracking context in first level only.
|
|
816
|
+
trackingContextList: undefined,
|
|
817
|
+
$$stateOfUseBrick: options.$$lazyForUseBrick ? getNextStateOfUseBrick((_options$$$stateOfUse = options.$$stateOfUseBrick) !== null && _options$$$stateOfUse !== void 0 ? _options$$$stateOfUse : StateOfUseBrick.INITIAL, isArray, key) : undefined
|
|
818
|
+
}) : options;
|
|
819
|
+
}
|
|
530
820
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
var
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
params
|
|
539
|
-
}))).data
|
|
540
|
-
);
|
|
541
|
-
});
|
|
542
|
-
return function InstalledMicroAppApi_getI18NData(_x, _x2) {
|
|
543
|
-
return _ref.apply(this, arguments);
|
|
544
|
-
};
|
|
545
|
-
}();
|
|
821
|
+
var MESSAGE_SOURCE_PANEL = "brick-next-devtools-panel";
|
|
822
|
+
var EVALUATION_EDIT = "devtools-evaluation-edit";
|
|
823
|
+
var TRANSFORMATION_EDIT = "devtools-transformation-edit";
|
|
824
|
+
var FRAME_ACTIVE_CHANGE = "devtools-frame-active-change";
|
|
825
|
+
var PANEL_CHANGE = "devtools-panel-change";
|
|
826
|
+
var frameIsActive = true;
|
|
827
|
+
var selectedPanel;
|
|
546
828
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
829
|
+
/* istanbul ignore next */
|
|
830
|
+
function devtoolsHookEmit(type, payload) {
|
|
831
|
+
var devtools = getDevHook();
|
|
832
|
+
if (!devtools || !(type === "evaluation" ? frameIsActive && (!selectedPanel || selectedPanel === "Evaluations") : type === "transformation" ? frameIsActive && (!selectedPanel || selectedPanel === "Transformations") : true)) {
|
|
833
|
+
// Ignore messages if current devtools panel is not relevant.
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
var emit = () => {
|
|
837
|
+
var _devtools$emit;
|
|
838
|
+
(_devtools$emit = devtools.emit) === null || _devtools$emit === void 0 ? void 0 : _devtools$emit.call(devtools, {
|
|
839
|
+
type,
|
|
840
|
+
payload
|
|
841
|
+
});
|
|
558
842
|
};
|
|
559
|
-
}();
|
|
560
843
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (!Object.prototype.hasOwnProperty.call(globalVariables, variableName)) {
|
|
567
|
-
var variable = supplyIndividual(variableName, mock);
|
|
568
|
-
if (variable !== undefined) {
|
|
569
|
-
globalVariables[variableName] = variable;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
844
|
+
// Try to emit only in idle time.
|
|
845
|
+
if (typeof window.requestIdleCallback === "function") {
|
|
846
|
+
window.requestIdleCallback(emit);
|
|
847
|
+
} else {
|
|
848
|
+
setTimeout(emit, 0);
|
|
572
849
|
}
|
|
573
|
-
return globalVariables;
|
|
574
850
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
*
|
|
583
|
-
* E.g.:
|
|
584
|
-
*
|
|
585
|
-
* ```
|
|
586
|
-
* _.wrap(_.method('constructor.assign',{b:2},{b:3}),(func,...a) => func(...a))({})
|
|
587
|
-
* ```
|
|
588
|
-
*/
|
|
589
|
-
"after", "ary", "before", "bind", "bindKey", "curry", "curryRight", "debounce", "defer", "delay", "flip", "memoize", "negate", "once", "overArgs", "partial", "partialRight", "rearg", "rest", "spread", "throttle", "unary", "wrap"]);
|
|
590
|
-
|
|
591
|
-
// Omit all mutable methods from moment.
|
|
592
|
-
var shouldOmitInMoment = new Set(["lang", "langData", "locale", "localeData", "defineLocale", "updateLocale", "updateOffset"]);
|
|
593
|
-
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"]);
|
|
594
|
-
function supplyIndividual(variableName, mock) {
|
|
595
|
-
switch (variableName) {
|
|
596
|
-
case "Object":
|
|
597
|
-
// Do not allow mutable methods like `Object.assign`.
|
|
598
|
-
return delegateMethods(Object, ["entries", "fromEntries", "keys", "values"]);
|
|
599
|
-
case "_":
|
|
600
|
-
return Object.fromEntries(Object.entries(_).filter(entry => !shouldOmitInLodash.has(entry[0])).concat(mock ? [["uniqueId", prefix => "".concat(prefix !== null && prefix !== void 0 ? prefix : "", "42")]] : []));
|
|
601
|
-
case "moment":
|
|
602
|
-
return Object.assign(function () {
|
|
603
|
-
return moment(...arguments);
|
|
604
|
-
}, Object.fromEntries(Object.entries(moment).filter(entry => !shouldOmitInMoment.has(entry[0]))));
|
|
605
|
-
case "PIPES":
|
|
606
|
-
return pipes;
|
|
607
|
-
case "TAG_URL":
|
|
608
|
-
return tagUrlFactory(true);
|
|
609
|
-
case "SAFE_TAG_URL":
|
|
610
|
-
return tagUrlFactory();
|
|
611
|
-
default:
|
|
612
|
-
if (allowedGlobalObjects.has(variableName)) {
|
|
613
|
-
return window[variableName];
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
function delegateMethods(target, methods) {
|
|
618
|
-
return Object.fromEntries(methods.map(method => [method, function () {
|
|
619
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
620
|
-
args[_key] = arguments[_key];
|
|
621
|
-
}
|
|
622
|
-
return target[method].apply(target, args);
|
|
623
|
-
}]));
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Pass `ignoreSlashes` as `true` to encode all tagged expressions
|
|
627
|
-
* as URL components, except for `/` which maybe used in `APP.homepage`.
|
|
628
|
-
*
|
|
629
|
-
* Otherwise encode all tagged expressions as URL components.
|
|
630
|
-
* This will encode `/` as `%2F`. So do not use it directly
|
|
631
|
-
* with `APP.homepage` as in template expressions.
|
|
632
|
-
*
|
|
633
|
-
* @example
|
|
634
|
-
*
|
|
635
|
-
* ```js
|
|
636
|
-
* TAG_URL`${APP.homepage}/list?q=${q}&redirect=${redirect}`
|
|
637
|
-
* ```
|
|
638
|
-
*
|
|
639
|
-
* ```js
|
|
640
|
-
* SAFE_TAG_URL`file/${path}?q=${q}`
|
|
641
|
-
* // `path` will be fully transformed by `encodeURIComponent`.
|
|
642
|
-
* ```
|
|
643
|
-
*
|
|
644
|
-
* ```js
|
|
645
|
-
* // Wrap `APP.homepage` outside of `SAFE_TAG_URL`.
|
|
646
|
-
* `${APP.homepage}/${SAFE_TAG_URL`file/${path}?q=${q}`}`
|
|
647
|
-
* ```
|
|
648
|
-
*/
|
|
649
|
-
function tagUrlFactory(ignoreSlashes) {
|
|
650
|
-
return function (strings) {
|
|
651
|
-
for (var _len2 = arguments.length, partials = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
652
|
-
partials[_key2 - 1] = arguments[_key2];
|
|
653
|
-
}
|
|
654
|
-
var result = [];
|
|
655
|
-
strings.forEach((str, index) => {
|
|
656
|
-
result.push(str);
|
|
657
|
-
if (index < partials.length) {
|
|
658
|
-
result.push(ignoreSlashes ? String(partials[index]).replace(/[^/]+/g, p => encodeURIComponent(p)) : encodeURIComponent(String(partials[index])));
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
return result.join("");
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
function getUrlByAliasFactory(app) {
|
|
666
|
-
return function getUrlByAlias(alias, pathParams, query) {
|
|
667
|
-
if (!(app !== null && app !== void 0 && app.$$routeAliasMap.has(alias))) {
|
|
668
|
-
// eslint-disable-next-line no-console
|
|
669
|
-
throw new Error("Route alias not found: ".concat(alias));
|
|
670
|
-
}
|
|
671
|
-
var routeConf = app.$$routeAliasMap.get(alias);
|
|
672
|
-
var url = toPath(computeRealRoutePath(routeConf.path, app), pathParams);
|
|
673
|
-
if (query) {
|
|
674
|
-
var urlSearchParams = new URLSearchParams();
|
|
675
|
-
for (var [key, value] of Object.entries(query)) {
|
|
676
|
-
if (Array.isArray(value)) {
|
|
677
|
-
for (var item of value) {
|
|
678
|
-
urlSearchParams.append(key, item);
|
|
679
|
-
}
|
|
680
|
-
} else if (value !== undefined && value !== null && value !== "") {
|
|
681
|
-
urlSearchParams.set(key, value);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
var queryString = urlSearchParams.toString();
|
|
685
|
-
if (queryString.length > 0) {
|
|
686
|
-
url += "?".concat(queryString);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
return url;
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
function getUrlBySegueFactory(app, segues) {
|
|
694
|
-
return function getUrlBySegue(segueId, pathParams, query) {
|
|
695
|
-
if (!hasOwnProperty(segues, segueId)) {
|
|
696
|
-
// eslint-disable-next-line no-console
|
|
697
|
-
throw new Error("Segue not found: ".concat(segueId));
|
|
851
|
+
function listenDevtoolsEagerly() {
|
|
852
|
+
window.addEventListener("message", _ref => {
|
|
853
|
+
var {
|
|
854
|
+
data
|
|
855
|
+
} = _ref;
|
|
856
|
+
if ((data === null || data === void 0 ? void 0 : data.source) !== MESSAGE_SOURCE_PANEL) {
|
|
857
|
+
return;
|
|
698
858
|
}
|
|
699
|
-
var
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
return {
|
|
706
|
-
get(name) {
|
|
707
|
-
var getSuffix = () => {
|
|
708
|
-
var suffix = window.APP_ROOT ? "".concat(window.APP_ROOT).concat(window.BOOTSTRAP_UNION_FILE && window.PUBLIC_DEPS ? "" : "-/") : "";
|
|
709
|
-
if (!suffix.startsWith("/")) {
|
|
710
|
-
suffix = getBasePath() + suffix;
|
|
859
|
+
var payload = data.payload;
|
|
860
|
+
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
861
|
+
case FRAME_ACTIVE_CHANGE:
|
|
862
|
+
{
|
|
863
|
+
frameIsActive = payload.active;
|
|
864
|
+
break;
|
|
711
865
|
}
|
|
712
|
-
|
|
713
|
-
|
|
866
|
+
case PANEL_CHANGE:
|
|
867
|
+
{
|
|
868
|
+
selectedPanel = payload.panel;
|
|
869
|
+
break;
|
|
714
870
|
}
|
|
715
|
-
return suffix;
|
|
716
|
-
};
|
|
717
|
-
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);
|
|
718
871
|
}
|
|
719
|
-
};
|
|
872
|
+
});
|
|
720
873
|
}
|
|
721
|
-
function
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
874
|
+
function listenDevtools() {
|
|
875
|
+
window.addEventListener("message", _ref2 => {
|
|
876
|
+
var {
|
|
877
|
+
data
|
|
878
|
+
} = _ref2;
|
|
879
|
+
if ((data === null || data === void 0 ? void 0 : data.source) !== MESSAGE_SOURCE_PANEL) {
|
|
880
|
+
return;
|
|
726
881
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
882
|
+
var payload = data.payload;
|
|
883
|
+
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
884
|
+
case EVALUATION_EDIT:
|
|
885
|
+
{
|
|
886
|
+
var {
|
|
887
|
+
raw,
|
|
888
|
+
context,
|
|
889
|
+
id
|
|
890
|
+
} = payload;
|
|
891
|
+
evaluate(raw, {
|
|
892
|
+
data: context.data,
|
|
893
|
+
event: restoreDehydrated(context.event)
|
|
894
|
+
}, {
|
|
895
|
+
isReEvaluation: true,
|
|
896
|
+
evaluationId: id
|
|
897
|
+
});
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
case TRANSFORMATION_EDIT:
|
|
901
|
+
{
|
|
902
|
+
var {
|
|
903
|
+
data: _data,
|
|
904
|
+
transform,
|
|
905
|
+
id: _id,
|
|
906
|
+
options: {
|
|
907
|
+
from,
|
|
908
|
+
mapArray,
|
|
909
|
+
allowInject
|
|
910
|
+
}
|
|
911
|
+
} = payload;
|
|
912
|
+
reTransformForDevtools(_id, _data, transform, from, mapArray, allowInject);
|
|
913
|
+
break;
|
|
745
914
|
}
|
|
746
|
-
}
|
|
747
915
|
}
|
|
748
|
-
}
|
|
916
|
+
});
|
|
749
917
|
}
|
|
750
|
-
function
|
|
751
|
-
return
|
|
918
|
+
function getDevHook() {
|
|
919
|
+
return window.__BRICK_NEXT_DEVTOOLS_HOOK__;
|
|
752
920
|
}
|
|
753
|
-
function
|
|
754
|
-
|
|
921
|
+
function restoreDehydrated(value) {
|
|
922
|
+
var _getDevHook$restoreDe, _getDevHook;
|
|
923
|
+
return (_getDevHook$restoreDe = (_getDevHook = getDevHook()) === null || _getDevHook === void 0 ? void 0 : _getDevHook.restoreDehydrated(value)) !== null && _getDevHook$restoreDe !== void 0 ? _getDevHook$restoreDe : value;
|
|
755
924
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
return [k, cloneDeepWithInjectedMark(v)];
|
|
763
|
-
}).concat(Object.getOwnPropertySymbols(value).map(k => [k, value[k]])));
|
|
764
|
-
if (haveBeenInjected(value)) {
|
|
765
|
-
injected.add(clone);
|
|
766
|
-
}
|
|
767
|
-
return clone;
|
|
768
|
-
}
|
|
769
|
-
return value;
|
|
925
|
+
|
|
926
|
+
function getItemFactory(storageType) {
|
|
927
|
+
return function (name) {
|
|
928
|
+
var storage = storageType === "local" ? localStorage : sessionStorage;
|
|
929
|
+
return JSON.parse(storage.getItem(name));
|
|
930
|
+
};
|
|
770
931
|
}
|
|
771
932
|
|
|
772
|
-
var
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
933
|
+
var locale$7 = {
|
|
934
|
+
[K.REQUEST_FAILED]: "Request Failed",
|
|
935
|
+
[K.MODAL_OK]: "Ok",
|
|
936
|
+
[K.MODAL_CANCEL]: "Cancel",
|
|
937
|
+
[K.SOMETHING_WENT_WRONG]: "Something went wrong!",
|
|
938
|
+
[K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
|
|
939
|
+
[K.NETWORK_ERROR]: "Network error, please check your network.",
|
|
940
|
+
[K.PAGE_NOT_FOUND]: "Page not found, please check the URL",
|
|
941
|
+
[K.APP_NOT_FOUND]: "App not found, maybe the URL is wrong or you don't have permission to access",
|
|
942
|
+
[K.LICENSE_EXPIRED]: "The license authorization has expired, please contact the platform administrator",
|
|
943
|
+
[K.NO_PERMISSION]: "Unauthorized access, unable to retrieve the required resources for this page",
|
|
944
|
+
[K.OTHER_ERROR]: "Oops! Something went wrong",
|
|
945
|
+
[K.GO_BACK_PREVIOUS_PAGE]: "Go back to previous page",
|
|
946
|
+
[K.GO_BACK_HOME_PAGE]: "Back to home page",
|
|
947
|
+
[K.LOGIN_CHANGED]: "You have logged in as another account, click OK to refresh the page.",
|
|
948
|
+
[K.LOGOUT_APPLIED]: "Your account has been logged out, click OK to refresh the page."
|
|
949
|
+
};
|
|
950
|
+
var en = locale$7;
|
|
951
|
+
|
|
952
|
+
var locale$6 = {
|
|
953
|
+
[K.REQUEST_FAILED]: "请求失败",
|
|
954
|
+
[K.MODAL_OK]: "确认",
|
|
955
|
+
[K.MODAL_CANCEL]: "取消",
|
|
956
|
+
[K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
|
|
957
|
+
[K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
|
|
958
|
+
[K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。",
|
|
959
|
+
[K.PAGE_NOT_FOUND]: "请求的页面未找到,请确认 URL 是否正确",
|
|
960
|
+
[K.APP_NOT_FOUND]: "请求的微应用无法找到, 可能是 URL 错误或者无权限访问",
|
|
961
|
+
[K.LICENSE_EXPIRED]: "License 授权失效,请联系平台管理员",
|
|
962
|
+
[K.NO_PERMISSION]: "没有权限,无法获取页面所需要的资源",
|
|
963
|
+
[K.OTHER_ERROR]: "糟糕!页面出现了一些问题",
|
|
964
|
+
[K.GO_BACK_PREVIOUS_PAGE]: "回到上一页",
|
|
965
|
+
[K.GO_BACK_HOME_PAGE]: "回到首页",
|
|
966
|
+
[K.LOGIN_CHANGED]: "您已经登录另一个账号,点击确定刷新页面。",
|
|
967
|
+
[K.LOGOUT_APPLIED]: "您的账号已经登出,点击确定刷新页面。"
|
|
968
|
+
};
|
|
969
|
+
var zh = locale$6;
|
|
970
|
+
|
|
971
|
+
/** @internal */
|
|
972
|
+
var initI18n = () => {
|
|
973
|
+
i18next.addResourceBundle("en", NS_BRICK_KIT, en);
|
|
974
|
+
i18next.addResourceBundle("zh", NS_BRICK_KIT, zh);
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
/** @internal */
|
|
978
|
+
function getI18nNamespace(type, id) {
|
|
979
|
+
return "$".concat(type, "-").concat(id);
|
|
803
980
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
981
|
+
|
|
982
|
+
function registerWidgetI18n(widgetId, i18n) {
|
|
983
|
+
var ns = getI18nNamespace("widget", widgetId);
|
|
984
|
+
Object.entries(i18n).forEach(_ref => {
|
|
985
|
+
var [lang, resources] = _ref;
|
|
986
|
+
i18next.addResourceBundle(lang, ns, resources);
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function widgetI18nFactory(widgetId) {
|
|
990
|
+
return getFixedT(null, getI18nNamespace("widget", widgetId));
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
function i18nText(data) {
|
|
994
|
+
var _i18next$language;
|
|
995
|
+
if (!data) {
|
|
996
|
+
return;
|
|
807
997
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
{
|
|
828
|
-
switch (key) {
|
|
829
|
-
case "properties":
|
|
830
|
-
return StateOfUseBrick.USE_BRICK_PROPERTIES;
|
|
831
|
-
case "transform":
|
|
832
|
-
return StateOfUseBrick.USE_BRICK_TRANSFORM;
|
|
833
|
-
case "events":
|
|
834
|
-
return StateOfUseBrick.USE_BRICK_EVENTS;
|
|
835
|
-
case "slots":
|
|
836
|
-
return StateOfUseBrick.USE_BRICK_SLOTS;
|
|
837
|
-
case "if":
|
|
838
|
-
return StateOfUseBrick.USE_BRICK_IF;
|
|
839
|
-
case "lifeCycle":
|
|
840
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE;
|
|
841
|
-
}
|
|
842
|
-
break;
|
|
843
|
-
}
|
|
844
|
-
case StateOfUseBrick.USE_BRICK_SLOTS:
|
|
845
|
-
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM;
|
|
846
|
-
case StateOfUseBrick.USE_BRICK_SLOTS_ITEM:
|
|
847
|
-
if (key === "bricks") {
|
|
848
|
-
return StateOfUseBrick.USE_BRICK_SLOTS_ITEM_BRICKS;
|
|
849
|
-
}
|
|
850
|
-
break;
|
|
851
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE:
|
|
852
|
-
if (key === "useResolves") {
|
|
853
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES;
|
|
854
|
-
}
|
|
855
|
-
break;
|
|
856
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM:
|
|
857
|
-
{
|
|
858
|
-
switch (key) {
|
|
859
|
-
case "transform":
|
|
860
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_TRANSFORM;
|
|
861
|
-
case "onReject":
|
|
862
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT;
|
|
863
|
-
}
|
|
864
|
-
break;
|
|
865
|
-
}
|
|
866
|
-
case StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT:
|
|
867
|
-
if (key === "transform") {
|
|
868
|
-
return StateOfUseBrick.USE_BRICK_LIFECYCLE_USERESOLVES_ITEM_ONREJECT_TRANSFORM;
|
|
869
|
-
}
|
|
870
|
-
break;
|
|
998
|
+
var language = (_i18next$language = i18next.language) !== null && _i18next$language !== void 0 ? _i18next$language : "zh-CN";
|
|
999
|
+
// First, make a perfect match.
|
|
1000
|
+
if (hasOwnProperty(data, language)) {
|
|
1001
|
+
return data[language];
|
|
1002
|
+
}
|
|
1003
|
+
// https://en.wikipedia.org/wiki/IETF_language_tag
|
|
1004
|
+
var primaryLanguage = language.split("-")[0];
|
|
1005
|
+
if (primaryLanguage !== language) {
|
|
1006
|
+
// Then, match the primary language (which omits other subtags).
|
|
1007
|
+
// E.g., match `zh` if the current language is `zh-CN`.
|
|
1008
|
+
return hasOwnProperty(data, primaryLanguage) ? data[primaryLanguage] : undefined;
|
|
1009
|
+
}
|
|
1010
|
+
// At last, match the first key which starts with the primary language,
|
|
1011
|
+
// if the current language contains primary subtag only.
|
|
1012
|
+
// E.g., match `zh-CN` if the current language is `zh`.
|
|
1013
|
+
var prefix = "".concat(primaryLanguage, "-");
|
|
1014
|
+
for (var key of Object.keys(data)) {
|
|
1015
|
+
if (key.startsWith(prefix)) {
|
|
1016
|
+
return data[key];
|
|
871
1017
|
}
|
|
872
1018
|
}
|
|
873
|
-
return StateOfUseBrick.INITIAL;
|
|
874
1019
|
}
|
|
875
1020
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (result) {
|
|
885
|
-
contextNames = result.context;
|
|
886
|
-
stateNames = result.state;
|
|
887
|
-
formStateNames = result.formState;
|
|
888
|
-
}
|
|
889
|
-
} else {
|
|
890
|
-
contextNames = trackContext(raw);
|
|
891
|
-
stateNames = trackState(raw);
|
|
892
|
-
formStateNames = trackFormState(raw);
|
|
893
|
-
}
|
|
1021
|
+
// Themes.
|
|
1022
|
+
var DEFAULT_THEME = "light";
|
|
1023
|
+
var theme = DEFAULT_THEME;
|
|
1024
|
+
var storage = new JsonStorage(localStorage);
|
|
1025
|
+
var LOCAL_STORAGE_APPS_THEME_KEY = "apps-theme";
|
|
1026
|
+
function setTheme(value) {
|
|
1027
|
+
if (value !== "dark" && value !== "light" && value !== "dark-v2") {
|
|
1028
|
+
throw new Error("Unsupported theme: ".concat(value));
|
|
894
1029
|
}
|
|
895
|
-
|
|
896
|
-
contextNames,
|
|
897
|
-
stateNames,
|
|
898
|
-
formStateNames
|
|
899
|
-
};
|
|
1030
|
+
theme = value;
|
|
900
1031
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
function transformElementProperties(element, data, to, from, mapArray) {
|
|
904
|
-
var result = preprocessTransformProperties(data, to, from, mapArray);
|
|
905
|
-
setRealProperties(element, result, true);
|
|
1032
|
+
function getTheme() {
|
|
1033
|
+
return theme;
|
|
906
1034
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1035
|
+
function getCurrentTheme() {
|
|
1036
|
+
return document.documentElement.dataset.theme;
|
|
1037
|
+
}
|
|
1038
|
+
function applyTheme(value) {
|
|
1039
|
+
if (value) {
|
|
1040
|
+
setTheme(value);
|
|
1041
|
+
} else {
|
|
1042
|
+
value = getTheme();
|
|
913
1043
|
}
|
|
914
|
-
|
|
1044
|
+
if (value !== getCurrentTheme()) {
|
|
1045
|
+
document.documentElement.dataset.theme = value;
|
|
1046
|
+
window.dispatchEvent(new CustomEvent("theme.change", {
|
|
1047
|
+
detail: value
|
|
1048
|
+
}));
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
function useCurrentTheme() {
|
|
1052
|
+
var [currentTheme, setCurrentTheme] = useState(getCurrentTheme());
|
|
1053
|
+
useEffect(() => {
|
|
1054
|
+
var listenToThemeChange = event => {
|
|
1055
|
+
setCurrentTheme(event.detail);
|
|
1056
|
+
};
|
|
1057
|
+
window.addEventListener("theme.change", listenToThemeChange);
|
|
1058
|
+
return () => {
|
|
1059
|
+
window.removeEventListener("theme.change", listenToThemeChange);
|
|
1060
|
+
};
|
|
1061
|
+
}, []);
|
|
1062
|
+
return currentTheme;
|
|
1063
|
+
}
|
|
1064
|
+
function batchSetAppsLocalTheme(appsTheme) {
|
|
1065
|
+
storage.setItem(LOCAL_STORAGE_APPS_THEME_KEY, _objectSpread(_objectSpread({}, getLocalAppsTheme()), appsTheme));
|
|
1066
|
+
}
|
|
1067
|
+
function getLocalAppsTheme() {
|
|
1068
|
+
var result;
|
|
1069
|
+
try {
|
|
1070
|
+
result = storage.getItem(LOCAL_STORAGE_APPS_THEME_KEY);
|
|
1071
|
+
} catch (_unused) {
|
|
1072
|
+
// eslint-disable-next-line no-console
|
|
1073
|
+
console.error("JSON parse error inside `getLocalAppsTheme()`");
|
|
1074
|
+
}
|
|
1075
|
+
return result || {};
|
|
915
1076
|
}
|
|
916
1077
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
var lazy = (options === null || options === void 0 ? void 0 : options.$$lazyForUseBrick) && isLazyContentInUseBrick(options.$$stateOfUseBrick);
|
|
924
|
-
if (lazy) {
|
|
925
|
-
// The current data context is not memoized, since a new data context
|
|
926
|
-
// should always be provided before later transformations.
|
|
927
|
-
return to;
|
|
928
|
-
}
|
|
929
|
-
var result;
|
|
930
|
-
var dismissRecursiveMarkingInjected = false;
|
|
931
|
-
if (preEvaluated || isEvaluable(to)) {
|
|
932
|
-
var runtimeContext = {
|
|
933
|
-
data
|
|
934
|
-
};
|
|
935
|
-
if (options !== null && options !== void 0 && options.tplContextId) runtimeContext.tplContextId = options.tplContextId;
|
|
936
|
-
if (options !== null && options !== void 0 && options.formContextId) runtimeContext.formContextId = options.formContextId;
|
|
937
|
-
result = evaluate(to, runtimeContext, options === null || options === void 0 ? void 0 : options.evaluateOptions);
|
|
938
|
-
dismissRecursiveMarkingInjected = shouldDismissRecursiveMarkingInjected(to);
|
|
939
|
-
} else {
|
|
940
|
-
result = options !== null && options !== void 0 && options.allowInject ? transformAndInject(to, data, _internalApiGetCurrentContext()) : transform(to, data);
|
|
941
|
-
}
|
|
942
|
-
if (!dismissRecursiveMarkingInjected) {
|
|
943
|
-
recursiveMarkAsInjected(result);
|
|
944
|
-
}
|
|
945
|
-
return result;
|
|
946
|
-
}
|
|
947
|
-
if (!isObject(to) || haveBeenInjected(to)) {
|
|
948
|
-
return to;
|
|
949
|
-
}
|
|
950
|
-
if (Array.isArray(to)) {
|
|
951
|
-
var nextOptions = getNextDoTransformOptions(options, true);
|
|
952
|
-
return to.map(item => doTransform(data, item, nextOptions));
|
|
1078
|
+
// Modes.
|
|
1079
|
+
var DEFAULT_MODE = "default";
|
|
1080
|
+
var mode = DEFAULT_MODE;
|
|
1081
|
+
function setMode(value) {
|
|
1082
|
+
if (value !== "dashboard" && value !== "default") {
|
|
1083
|
+
throw new Error("Unsupported mode: ".concat(value));
|
|
953
1084
|
}
|
|
954
|
-
|
|
955
|
-
// Get both string and symbol keys.
|
|
956
|
-
Object.entries(to).map(_ref => {
|
|
957
|
-
var [k, v] = _ref;
|
|
958
|
-
if (Array.isArray(options === null || options === void 0 ? void 0 : options.trackingContextList) && (typeof v === "string" ? isEvaluable(v) : isPreEvaluated(v))) {
|
|
959
|
-
var raw;
|
|
960
|
-
if (typeof v === "string") {
|
|
961
|
-
raw = v;
|
|
962
|
-
} else {
|
|
963
|
-
raw = getPreEvaluatedRaw(v);
|
|
964
|
-
addDataToPreEvaluated(v, data);
|
|
965
|
-
}
|
|
966
|
-
var {
|
|
967
|
-
contextNames,
|
|
968
|
-
stateNames,
|
|
969
|
-
formStateNames
|
|
970
|
-
} = getTracks(raw);
|
|
971
|
-
if (contextNames || stateNames || formStateNames) {
|
|
972
|
-
options.trackingContextList.push({
|
|
973
|
-
contextNames,
|
|
974
|
-
stateNames,
|
|
975
|
-
formStateNames,
|
|
976
|
-
propName: k,
|
|
977
|
-
propValue: v
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
return [k, doTransform(data, v, getNextDoTransformOptions(options, false, k))];
|
|
982
|
-
}).concat(Object.getOwnPropertySymbols(to).map(k => [k, to[k]])));
|
|
1085
|
+
mode = value;
|
|
983
1086
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
function reTransformForDevtools(transformationId, data, to, from, mapArray, allowInject) {
|
|
987
|
-
try {
|
|
988
|
-
preprocessTransformProperties(data, to, from, mapArray, {
|
|
989
|
-
isReTransformation: true,
|
|
990
|
-
transformationId,
|
|
991
|
-
allowInject
|
|
992
|
-
});
|
|
993
|
-
} catch (error) {
|
|
994
|
-
devtoolsHookEmit("re-transformation", {
|
|
995
|
-
id: transformationId,
|
|
996
|
-
error: error.message,
|
|
997
|
-
detail: {
|
|
998
|
-
transform: to,
|
|
999
|
-
data,
|
|
1000
|
-
options: {
|
|
1001
|
-
from,
|
|
1002
|
-
mapArray,
|
|
1003
|
-
allowInject
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1087
|
+
function getMode() {
|
|
1088
|
+
return mode;
|
|
1008
1089
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
function preprocessTransformProperties(data, to, from, mapArray, options) {
|
|
1012
|
-
var props = {};
|
|
1013
|
-
var processedData = from ? get(data, from) : data;
|
|
1014
|
-
if (Array.isArray(to)) {
|
|
1015
|
-
for (var item of to) {
|
|
1016
|
-
pipeableTransform(props, processedData, item.to, item.from, item.mapArray, {
|
|
1017
|
-
allowInject: options === null || options === void 0 ? void 0 : options.allowInject
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
} else {
|
|
1021
|
-
pipeableTransform(props, processedData, to, undefined, mapArray, {
|
|
1022
|
-
allowInject: options === null || options === void 0 ? void 0 : options.allowInject
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
var detail = {
|
|
1026
|
-
transform: to,
|
|
1027
|
-
data,
|
|
1028
|
-
options: {
|
|
1029
|
-
from,
|
|
1030
|
-
mapArray,
|
|
1031
|
-
allowInject: options === null || options === void 0 ? void 0 : options.allowInject
|
|
1032
|
-
},
|
|
1033
|
-
result: props
|
|
1034
|
-
};
|
|
1035
|
-
if (options !== null && options !== void 0 && options.isReTransformation) {
|
|
1036
|
-
devtoolsHookEmit("re-transformation", {
|
|
1037
|
-
id: options.transformationId,
|
|
1038
|
-
detail
|
|
1039
|
-
});
|
|
1040
|
-
} else {
|
|
1041
|
-
devtoolsHookEmit("transformation", detail);
|
|
1042
|
-
}
|
|
1043
|
-
return props;
|
|
1090
|
+
function getCurrentMode() {
|
|
1091
|
+
return document.documentElement.dataset.mode;
|
|
1044
1092
|
}
|
|
1045
|
-
function
|
|
1046
|
-
if (
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
var fromData = from ? get(data, from) : data;
|
|
1051
|
-
var isArray = Array.isArray(fromData);
|
|
1052
|
-
if (!isArray && mapArray === true) {
|
|
1053
|
-
isArray = true;
|
|
1054
|
-
fromData = [fromData];
|
|
1055
|
-
} else if (isArray && mapArray === false) {
|
|
1056
|
-
isArray = false;
|
|
1057
|
-
}
|
|
1058
|
-
if (typeof to === "string") {
|
|
1059
|
-
props[to] = fromData;
|
|
1060
|
-
return;
|
|
1093
|
+
function applyMode(value) {
|
|
1094
|
+
if (value) {
|
|
1095
|
+
setMode(value);
|
|
1096
|
+
} else {
|
|
1097
|
+
value = getMode();
|
|
1061
1098
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
_loop(transformedPropName, transformTo);
|
|
1099
|
+
if (value !== getCurrentMode()) {
|
|
1100
|
+
document.documentElement.dataset.mode = value;
|
|
1101
|
+
window.dispatchEvent(new CustomEvent("mode.change", {
|
|
1102
|
+
detail: value
|
|
1103
|
+
}));
|
|
1068
1104
|
}
|
|
1069
1105
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1106
|
+
function useCurrentMode() {
|
|
1107
|
+
var [currentMode, setCurrentMode] = useState(getCurrentMode());
|
|
1108
|
+
useEffect(() => {
|
|
1109
|
+
var listenToModeChange = event => {
|
|
1110
|
+
setCurrentMode(event.detail);
|
|
1111
|
+
};
|
|
1112
|
+
window.addEventListener("mode.change", listenToModeChange);
|
|
1113
|
+
return () => {
|
|
1114
|
+
window.removeEventListener("mode.change", listenToModeChange);
|
|
1115
|
+
};
|
|
1116
|
+
}, []);
|
|
1117
|
+
return currentMode;
|
|
1078
1118
|
}
|
|
1079
|
-
function
|
|
1080
|
-
var
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
$$stateOfUseBrick: options.$$lazyForUseBrick ? getNextStateOfUseBrick((_options$$$stateOfUse = options.$$stateOfUseBrick) !== null && _options$$$stateOfUse !== void 0 ? _options$$$stateOfUse : StateOfUseBrick.INITIAL, isArray, key) : undefined
|
|
1085
|
-
}) : options;
|
|
1119
|
+
function getCssPropertyValue(name) {
|
|
1120
|
+
var _window$getComputedSt;
|
|
1121
|
+
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.documentElement;
|
|
1122
|
+
if (!el) return "";
|
|
1123
|
+
return ((_window$getComputedSt = window.getComputedStyle(el)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue(name)) || "";
|
|
1086
1124
|
}
|
|
1087
1125
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
var
|
|
1093
|
-
var
|
|
1094
|
-
|
|
1126
|
+
/**
|
|
1127
|
+
* @description 获取菜单信息
|
|
1128
|
+
* @endpoint GET /api/v1/micro-app/menus/:menuId
|
|
1129
|
+
*/
|
|
1130
|
+
var InstalledMicroAppApi_getMenusInfo = /*#__PURE__*/function () {
|
|
1131
|
+
var _ref = _asyncToGenerator$3(function* (menuId, params, options) {
|
|
1132
|
+
return (/**! @contract easyops.api.micro_app.installed_micro_app.GetMenusInfo@1.0.0 */(yield http.get("api/gateway/micro_app.installed_micro_app.GetMenusInfo/api/v1/micro-app/menus/".concat(menuId), _objectSpread(_objectSpread({}, options), {}, {
|
|
1133
|
+
params
|
|
1134
|
+
}))).data
|
|
1135
|
+
);
|
|
1136
|
+
});
|
|
1137
|
+
return function InstalledMicroAppApi_getMenusInfo(_x, _x2, _x3) {
|
|
1138
|
+
return _ref.apply(this, arguments);
|
|
1139
|
+
};
|
|
1140
|
+
}();
|
|
1095
1141
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
var
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1142
|
+
/** 微应用的i18n信息 */
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* @description 获取微应用的i18n数据
|
|
1146
|
+
* @endpoint GET /api/v1/micro-app/i18n
|
|
1147
|
+
*/
|
|
1148
|
+
var InstalledMicroAppApi_getI18NData = /*#__PURE__*/function () {
|
|
1149
|
+
var _ref = _asyncToGenerator$3(function* (params, options) {
|
|
1150
|
+
return (/**! @contract easyops.api.micro_app.installed_micro_app.GetI18NData@1.0.0 */(yield http.get("api/gateway/micro_app.installed_micro_app.GetI18NData/api/v1/micro-app/i18n", _objectSpread(_objectSpread({}, options), {}, {
|
|
1151
|
+
params
|
|
1152
|
+
}))).data
|
|
1153
|
+
);
|
|
1154
|
+
});
|
|
1155
|
+
return function InstalledMicroAppApi_getI18NData(_x, _x2) {
|
|
1156
|
+
return _ref.apply(this, arguments);
|
|
1109
1157
|
};
|
|
1158
|
+
}();
|
|
1110
1159
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
window.addEventListener("message", _ref => {
|
|
1120
|
-
var {
|
|
1121
|
-
data
|
|
1122
|
-
} = _ref;
|
|
1123
|
-
if ((data === null || data === void 0 ? void 0 : data.source) !== MESSAGE_SOURCE_PANEL) {
|
|
1124
|
-
return;
|
|
1125
|
-
}
|
|
1126
|
-
var payload = data.payload;
|
|
1127
|
-
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
1128
|
-
case FRAME_ACTIVE_CHANGE:
|
|
1129
|
-
{
|
|
1130
|
-
frameIsActive = payload.active;
|
|
1131
|
-
break;
|
|
1132
|
-
}
|
|
1133
|
-
case PANEL_CHANGE:
|
|
1134
|
-
{
|
|
1135
|
-
selectedPanel = payload.panel;
|
|
1136
|
-
break;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
function listenDevtools() {
|
|
1142
|
-
window.addEventListener("message", _ref2 => {
|
|
1143
|
-
var {
|
|
1144
|
-
data
|
|
1145
|
-
} = _ref2;
|
|
1146
|
-
if ((data === null || data === void 0 ? void 0 : data.source) !== MESSAGE_SOURCE_PANEL) {
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
var payload = data.payload;
|
|
1150
|
-
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
1151
|
-
case EVALUATION_EDIT:
|
|
1152
|
-
{
|
|
1153
|
-
var {
|
|
1154
|
-
raw,
|
|
1155
|
-
context,
|
|
1156
|
-
id
|
|
1157
|
-
} = payload;
|
|
1158
|
-
evaluate(raw, {
|
|
1159
|
-
data: context.data,
|
|
1160
|
-
event: restoreDehydrated(context.event)
|
|
1161
|
-
}, {
|
|
1162
|
-
isReEvaluation: true,
|
|
1163
|
-
evaluationId: id
|
|
1164
|
-
});
|
|
1165
|
-
break;
|
|
1166
|
-
}
|
|
1167
|
-
case TRANSFORMATION_EDIT:
|
|
1168
|
-
{
|
|
1169
|
-
var {
|
|
1170
|
-
data: _data,
|
|
1171
|
-
transform,
|
|
1172
|
-
id: _id,
|
|
1173
|
-
options: {
|
|
1174
|
-
from,
|
|
1175
|
-
mapArray,
|
|
1176
|
-
allowInject
|
|
1177
|
-
}
|
|
1178
|
-
} = payload;
|
|
1179
|
-
reTransformForDevtools(_id, _data, transform, from, mapArray, allowInject);
|
|
1180
|
-
break;
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1160
|
+
/**
|
|
1161
|
+
* @description 校验系统权限
|
|
1162
|
+
* @endpoint POST /api/micro_app/v1/permission/validate
|
|
1163
|
+
*/
|
|
1164
|
+
var PermissionApi_validatePermissions = /*#__PURE__*/function () {
|
|
1165
|
+
var _ref = _asyncToGenerator$3(function* (data, options) {
|
|
1166
|
+
return (/**! @contract easyops.api.micro_app.permission.ValidatePermissions@1.0.0 */(yield http.post("api/gateway/micro_app.permission.ValidatePermissions/api/micro_app/v1/permission/validate", data, options)).data
|
|
1167
|
+
);
|
|
1183
1168
|
});
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
return window.__BRICK_NEXT_DEVTOOLS_HOOK__;
|
|
1187
|
-
}
|
|
1188
|
-
function restoreDehydrated(value) {
|
|
1189
|
-
var _getDevHook$restoreDe, _getDevHook;
|
|
1190
|
-
return (_getDevHook$restoreDe = (_getDevHook = getDevHook()) === null || _getDevHook === void 0 ? void 0 : _getDevHook.restoreDehydrated(value)) !== null && _getDevHook$restoreDe !== void 0 ? _getDevHook$restoreDe : value;
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
function getItemFactory(storageType) {
|
|
1194
|
-
return function (name) {
|
|
1195
|
-
var storage = storageType === "local" ? localStorage : sessionStorage;
|
|
1196
|
-
return JSON.parse(storage.getItem(name));
|
|
1169
|
+
return function PermissionApi_validatePermissions(_x, _x2) {
|
|
1170
|
+
return _ref.apply(this, arguments);
|
|
1197
1171
|
};
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
var locale$7 = {
|
|
1201
|
-
[K.REQUEST_FAILED]: "Request Failed",
|
|
1202
|
-
[K.MODAL_OK]: "Ok",
|
|
1203
|
-
[K.MODAL_CANCEL]: "Cancel",
|
|
1204
|
-
[K.SOMETHING_WENT_WRONG]: "Something went wrong!",
|
|
1205
|
-
[K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
|
|
1206
|
-
[K.NETWORK_ERROR]: "Network error, please check your network.",
|
|
1207
|
-
[K.PAGE_NOT_FOUND]: "Page not found, please check the URL",
|
|
1208
|
-
[K.APP_NOT_FOUND]: "App not found, maybe the URL is wrong or you don't have permission to access",
|
|
1209
|
-
[K.LICENSE_EXPIRED]: "The license authorization has expired, please contact the platform administrator",
|
|
1210
|
-
[K.NO_PERMISSION]: "Unauthorized access, unable to retrieve the required resources for this page",
|
|
1211
|
-
[K.OTHER_ERROR]: "Oops! Something went wrong",
|
|
1212
|
-
[K.GO_BACK_PREVIOUS_PAGE]: "Go back to previous page",
|
|
1213
|
-
[K.GO_BACK_HOME_PAGE]: "Back to home page",
|
|
1214
|
-
[K.LOGIN_CHANGED]: "You have logged in as another account, click OK to refresh the page.",
|
|
1215
|
-
[K.LOGOUT_APPLIED]: "Your account has been logged out, click OK to refresh the page."
|
|
1216
|
-
};
|
|
1217
|
-
var en = locale$7;
|
|
1218
|
-
|
|
1219
|
-
var locale$6 = {
|
|
1220
|
-
[K.REQUEST_FAILED]: "请求失败",
|
|
1221
|
-
[K.MODAL_OK]: "确认",
|
|
1222
|
-
[K.MODAL_CANCEL]: "取消",
|
|
1223
|
-
[K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
|
|
1224
|
-
[K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
|
|
1225
|
-
[K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。",
|
|
1226
|
-
[K.PAGE_NOT_FOUND]: "请求的页面未找到,请确认 URL 是否正确",
|
|
1227
|
-
[K.APP_NOT_FOUND]: "请求的微应用无法找到, 可能是 URL 错误或者无权限访问",
|
|
1228
|
-
[K.LICENSE_EXPIRED]: "License 授权失效,请联系平台管理员",
|
|
1229
|
-
[K.NO_PERMISSION]: "没有权限,无法获取页面所需要的资源",
|
|
1230
|
-
[K.OTHER_ERROR]: "糟糕!页面出现了一些问题",
|
|
1231
|
-
[K.GO_BACK_PREVIOUS_PAGE]: "回到上一页",
|
|
1232
|
-
[K.GO_BACK_HOME_PAGE]: "回到首页",
|
|
1233
|
-
[K.LOGIN_CHANGED]: "您已经登录另一个账号,点击确定刷新页面。",
|
|
1234
|
-
[K.LOGOUT_APPLIED]: "您的账号已经登出,点击确定刷新页面。"
|
|
1235
|
-
};
|
|
1236
|
-
var zh = locale$6;
|
|
1237
|
-
|
|
1238
|
-
/** @internal */
|
|
1239
|
-
var initI18n = () => {
|
|
1240
|
-
i18next.addResourceBundle("en", NS_BRICK_KIT, en);
|
|
1241
|
-
i18next.addResourceBundle("zh", NS_BRICK_KIT, zh);
|
|
1242
|
-
};
|
|
1243
|
-
|
|
1244
|
-
/** @internal */
|
|
1245
|
-
function getI18nNamespace(type, id) {
|
|
1246
|
-
return "$".concat(type, "-").concat(id);
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
function registerWidgetI18n(widgetId, i18n) {
|
|
1250
|
-
var ns = getI18nNamespace("widget", widgetId);
|
|
1251
|
-
Object.entries(i18n).forEach(_ref => {
|
|
1252
|
-
var [lang, resources] = _ref;
|
|
1253
|
-
i18next.addResourceBundle(lang, ns, resources);
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
|
-
function widgetI18nFactory(widgetId) {
|
|
1257
|
-
return getFixedT(null, getI18nNamespace("widget", widgetId));
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
function i18nText(data) {
|
|
1261
|
-
var _i18next$language;
|
|
1262
|
-
if (!data) {
|
|
1263
|
-
return;
|
|
1264
|
-
}
|
|
1265
|
-
var language = (_i18next$language = i18next.language) !== null && _i18next$language !== void 0 ? _i18next$language : "zh-CN";
|
|
1266
|
-
// First, make a perfect match.
|
|
1267
|
-
if (hasOwnProperty(data, language)) {
|
|
1268
|
-
return data[language];
|
|
1269
|
-
}
|
|
1270
|
-
// https://en.wikipedia.org/wiki/IETF_language_tag
|
|
1271
|
-
var primaryLanguage = language.split("-")[0];
|
|
1272
|
-
if (primaryLanguage !== language) {
|
|
1273
|
-
// Then, match the primary language (which omits other subtags).
|
|
1274
|
-
// E.g., match `zh` if the current language is `zh-CN`.
|
|
1275
|
-
return hasOwnProperty(data, primaryLanguage) ? data[primaryLanguage] : undefined;
|
|
1276
|
-
}
|
|
1277
|
-
// At last, match the first key which starts with the primary language,
|
|
1278
|
-
// if the current language contains primary subtag only.
|
|
1279
|
-
// E.g., match `zh-CN` if the current language is `zh`.
|
|
1280
|
-
var prefix = "".concat(primaryLanguage, "-");
|
|
1281
|
-
for (var key of Object.keys(data)) {
|
|
1282
|
-
if (key.startsWith(prefix)) {
|
|
1283
|
-
return data[key];
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1172
|
+
}();
|
|
1287
1173
|
|
|
1288
1174
|
var auth = {};
|
|
1289
1175
|
|
|
@@ -2348,1122 +2234,1236 @@ function getCustomContextTriggerListByLifecycle(lifecycle) {
|
|
|
2348
2234
|
return [...tplContextMap.values()].map(tplContext => tplContext.state.getContextTriggerSetByLifecycle(lifecycle)).filter(trigger => trigger.length > 0).flat(1);
|
|
2349
2235
|
}
|
|
2350
2236
|
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
})(MediaBreakpoint || (MediaBreakpoint = {}));
|
|
2359
|
-
var mediaBreakpointMinWidthMap = new Map([[MediaBreakpoint.xLarge, "1920px"], [MediaBreakpoint.large, "1600px"], [MediaBreakpoint.medium, "1280px"], [MediaBreakpoint.small, "1024px"], [MediaBreakpoint.xSmall, 0]]);
|
|
2360
|
-
var mediaEventTarget = new EventTarget$1();
|
|
2361
|
-
var breakpointMatchesMap = {};
|
|
2362
|
-
var MEDIA = {};
|
|
2363
|
-
function handleMatchesChange(data, breakpoint) {
|
|
2364
|
-
var changed = false;
|
|
2365
|
-
breakpointMatchesMap[breakpoint] = data.matches;
|
|
2366
|
-
for (var [_breakpoint] of mediaBreakpointMinWidthMap) {
|
|
2367
|
-
if (breakpointMatchesMap[_breakpoint] && MEDIA.breakpoint !== _breakpoint) {
|
|
2368
|
-
MEDIA.breakpoint = _breakpoint;
|
|
2369
|
-
changed = true;
|
|
2370
|
-
break;
|
|
2371
|
-
}
|
|
2237
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2238
|
+
try {
|
|
2239
|
+
var info = gen[key](arg);
|
|
2240
|
+
var value = info.value;
|
|
2241
|
+
} catch (error) {
|
|
2242
|
+
reject(error);
|
|
2243
|
+
return;
|
|
2372
2244
|
}
|
|
2373
|
-
if (
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2245
|
+
if (info.done) {
|
|
2246
|
+
resolve(value);
|
|
2247
|
+
} else {
|
|
2248
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2377
2249
|
}
|
|
2378
2250
|
}
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2251
|
+
function _asyncToGenerator$2(fn) {
|
|
2252
|
+
return function () {
|
|
2253
|
+
var self = this,
|
|
2254
|
+
args = arguments;
|
|
2255
|
+
return new Promise(function (resolve, reject) {
|
|
2256
|
+
var gen = fn.apply(self, args);
|
|
2257
|
+
function _next(value) {
|
|
2258
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2259
|
+
}
|
|
2260
|
+
function _throw(err) {
|
|
2261
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2262
|
+
}
|
|
2263
|
+
_next(undefined);
|
|
2264
|
+
});
|
|
2265
|
+
};
|
|
2266
|
+
}
|
|
2267
|
+
function _defineProperty(obj, key, value) {
|
|
2268
|
+
if (key in obj) {
|
|
2269
|
+
Object.defineProperty(obj, key, {
|
|
2270
|
+
value: value,
|
|
2271
|
+
enumerable: true,
|
|
2272
|
+
configurable: true,
|
|
2273
|
+
writable: true
|
|
2385
2274
|
});
|
|
2386
2275
|
} else {
|
|
2387
|
-
|
|
2388
|
-
|
|
2276
|
+
obj[key] = value;
|
|
2277
|
+
}
|
|
2278
|
+
return obj;
|
|
2279
|
+
}
|
|
2280
|
+
function ownKeys(object, enumerableOnly) {
|
|
2281
|
+
var keys = Object.keys(object);
|
|
2282
|
+
if (Object.getOwnPropertySymbols) {
|
|
2283
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
2284
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
2285
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2389
2286
|
});
|
|
2287
|
+
keys.push.apply(keys, symbols);
|
|
2390
2288
|
}
|
|
2391
|
-
|
|
2392
|
-
var getMedia = () => MEDIA;
|
|
2393
|
-
|
|
2394
|
-
var FormContextMap = new Map();
|
|
2395
|
-
class CustomFormContext {
|
|
2396
|
-
constructor(renderId) {
|
|
2397
|
-
_defineProperty$1(this, "formState", void 0);
|
|
2398
|
-
_defineProperty$1(this, "id", uniqueId("form-ctx-"));
|
|
2399
|
-
FormContextMap.set(this.id, this);
|
|
2400
|
-
this.formState = new StoryboardContextWrapper(undefined, this.id, renderId);
|
|
2401
|
-
}
|
|
2289
|
+
return keys;
|
|
2402
2290
|
}
|
|
2403
|
-
function
|
|
2404
|
-
|
|
2291
|
+
function _objectSpread2(target) {
|
|
2292
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2293
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2294
|
+
if (i % 2) {
|
|
2295
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
2296
|
+
_defineProperty(target, key, source[key]);
|
|
2297
|
+
});
|
|
2298
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
2299
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
2300
|
+
} else {
|
|
2301
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
2302
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
return target;
|
|
2405
2307
|
}
|
|
2406
2308
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2309
|
+
/**
|
|
2310
|
+
* @description 获取实例详情
|
|
2311
|
+
* @endpoint GET /object/:objectId/instance/:instanceId
|
|
2312
|
+
*/
|
|
2313
|
+
var InstanceApi_getDetail = /*#__PURE__*/function () {
|
|
2314
|
+
var _ref = _asyncToGenerator$2(function* (objectId, instanceId, params, options) {
|
|
2315
|
+
return (/**! @contract easyops.api.cmdb.instance.GetDetail */
|
|
2316
|
+
(yield http.get("api/gateway/cmdb.instance.GetDetail/object/".concat(objectId, "/instance/").concat(instanceId), _objectSpread2(_objectSpread2({}, options), {}, {
|
|
2317
|
+
params
|
|
2318
|
+
}))).data
|
|
2319
|
+
);
|
|
2320
|
+
});
|
|
2321
|
+
return function InstanceApi_getDetail(_x, _x2, _x3, _x4) {
|
|
2322
|
+
return _ref.apply(this, arguments);
|
|
2323
|
+
};
|
|
2324
|
+
}();
|
|
2325
|
+
|
|
2326
|
+
/**
|
|
2327
|
+
* @description 搜索实例
|
|
2328
|
+
* @endpoint POST /object/:objectId/instance/_search
|
|
2329
|
+
*/
|
|
2330
|
+
var InstanceApi_postSearch = /*#__PURE__*/function () {
|
|
2331
|
+
var _ref = _asyncToGenerator$2(function* (objectId, data, options) {
|
|
2332
|
+
return (/**! @contract easyops.api.cmdb.instance.PostSearch */
|
|
2333
|
+
(yield http.post("api/gateway/cmdb.instance.PostSearch/object/".concat(objectId, "/instance/_search"), data, options)).data
|
|
2334
|
+
);
|
|
2335
|
+
});
|
|
2336
|
+
return function InstanceApi_postSearch(_x, _x2, _x3) {
|
|
2337
|
+
return _ref.apply(this, arguments);
|
|
2338
|
+
};
|
|
2339
|
+
}();
|
|
2340
|
+
|
|
2341
|
+
var _excluded$8 = ["children"],
|
|
2342
|
+
_excluded2$2 = ["children"],
|
|
2343
|
+
_excluded3 = ["items", "app"];
|
|
2344
|
+
var symbolAppId = Symbol("appId");
|
|
2345
|
+
var symbolMenuI18nNamespace = Symbol("menuI18nNamespace");
|
|
2346
|
+
var symbolOverrideApp = Symbol("overrideApp");
|
|
2347
|
+
var symbolShouldCache = Symbol("shouldCache");
|
|
2348
|
+
// Caching menu requests to avoid flicker.
|
|
2349
|
+
var menuCache = new Map();
|
|
2350
|
+
var menuTitleCache = new Map();
|
|
2351
|
+
var processMenuCache = new Map();
|
|
2352
|
+
function constructMenu(_x, _x2, _x3) {
|
|
2353
|
+
return _constructMenu.apply(this, arguments);
|
|
2411
2354
|
}
|
|
2412
|
-
function
|
|
2413
|
-
|
|
2355
|
+
function _constructMenu() {
|
|
2356
|
+
_constructMenu = _asyncToGenerator$3(function* (menuBar, context, kernel) {
|
|
2357
|
+
var hasSubMenu = !!menuBar.subMenuId;
|
|
2358
|
+
yield Promise.all([_asyncToGenerator$3(function* () {
|
|
2359
|
+
if (menuBar.menuId) {
|
|
2360
|
+
var _menuBar$menu;
|
|
2361
|
+
var defaultCollapsed = (_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed;
|
|
2362
|
+
var menu = yield processMenu(menuBar.menuId, context, kernel, hasSubMenu);
|
|
2363
|
+
if (!isNil(defaultCollapsed)) {
|
|
2364
|
+
menu.defaultCollapsed = defaultCollapsed;
|
|
2365
|
+
}
|
|
2366
|
+
menuBar.menu = menu;
|
|
2367
|
+
}
|
|
2368
|
+
})(), _asyncToGenerator$3(function* () {
|
|
2369
|
+
if (hasSubMenu) {
|
|
2370
|
+
menuBar.subMenu = yield processMenu(menuBar.subMenuId, context, kernel);
|
|
2371
|
+
} else {
|
|
2372
|
+
menuBar.subMenu = null;
|
|
2373
|
+
}
|
|
2374
|
+
})()]);
|
|
2375
|
+
});
|
|
2376
|
+
return _constructMenu.apply(this, arguments);
|
|
2414
2377
|
}
|
|
2415
|
-
function
|
|
2416
|
-
|
|
2378
|
+
function preConstructMenus(_x4, _x5, _x6) {
|
|
2379
|
+
return _preConstructMenus.apply(this, arguments);
|
|
2417
2380
|
}
|
|
2418
|
-
function
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2381
|
+
function _preConstructMenus() {
|
|
2382
|
+
_preConstructMenus = _asyncToGenerator$3(function* (menus, context, kernel) {
|
|
2383
|
+
var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel, undefined, true)));
|
|
2384
|
+
data.forEach((item, index) => processMenuCache.set(menus[index], item));
|
|
2385
|
+
});
|
|
2386
|
+
return _preConstructMenus.apply(this, arguments);
|
|
2423
2387
|
}
|
|
2424
|
-
var
|
|
2425
|
-
function
|
|
2426
|
-
return
|
|
2388
|
+
var getMenu = menuId => processMenuCache.get(menuId);
|
|
2389
|
+
function fetchMenuById(_x7, _x8, _x9) {
|
|
2390
|
+
return _fetchMenuById.apply(this, arguments);
|
|
2427
2391
|
}
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
var runtimeContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2433
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2434
|
-
if (options.isReEvaluation && !(typeof raw === "string" && isEvaluable(raw))) {
|
|
2435
|
-
devtoolsHookEmit("re-evaluation", {
|
|
2436
|
-
id: options.evaluationId,
|
|
2437
|
-
detail: {
|
|
2438
|
-
raw,
|
|
2439
|
-
context: {}
|
|
2440
|
-
},
|
|
2441
|
-
error: "Invalid evaluation code"
|
|
2442
|
-
});
|
|
2443
|
-
return;
|
|
2444
|
-
}
|
|
2445
|
-
if (typeof raw !== "string") {
|
|
2446
|
-
// If the `raw` is not a string, it must be a pre-evaluated object.
|
|
2447
|
-
// Then fulfil the context, and restore the original `raw`.
|
|
2448
|
-
runtimeContext = _objectSpread(_objectSpread({}, raw[symbolForContext]), runtimeContext);
|
|
2449
|
-
raw = raw[symbolForRaw];
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
// A `SyntaxError` maybe thrown.
|
|
2453
|
-
var precooked;
|
|
2454
|
-
try {
|
|
2455
|
-
precooked = preevaluate(raw);
|
|
2456
|
-
} catch (error) {
|
|
2457
|
-
var message = "".concat(error.message, ", in \"").concat(raw, "\"");
|
|
2458
|
-
if (options.isReEvaluation) {
|
|
2459
|
-
devtoolsHookEmit("re-evaluation", {
|
|
2460
|
-
id: options.evaluationId,
|
|
2461
|
-
detail: {
|
|
2462
|
-
raw,
|
|
2463
|
-
context: {}
|
|
2464
|
-
},
|
|
2465
|
-
error: message
|
|
2466
|
-
});
|
|
2467
|
-
return;
|
|
2468
|
-
} else {
|
|
2469
|
-
var errorConstructor = getCookErrorConstructor(error);
|
|
2470
|
-
throw new errorConstructor(message);
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
var globalVariables = {};
|
|
2474
|
-
var attemptToVisitGlobals = precooked.attemptToVisitGlobals;
|
|
2475
|
-
var attemptToVisitEvent = attemptToVisitGlobals.has("EVENT");
|
|
2476
|
-
var attemptToVisitData = attemptToVisitGlobals.has("DATA");
|
|
2477
|
-
var attemptToVisitTpl = attemptToVisitGlobals.has("TPL");
|
|
2478
|
-
var attemptToVisitState = attemptToVisitGlobals.has("STATE");
|
|
2479
|
-
var attemptToVisitFormState = attemptToVisitGlobals.has("FORM_STATE");
|
|
2480
|
-
var attemptToVisitTplOrState = attemptToVisitTpl || attemptToVisitState;
|
|
2481
|
-
|
|
2482
|
-
// Ignore evaluating if `event` is missing in context.
|
|
2483
|
-
// Since it should be evaluated during events handling.
|
|
2484
|
-
var missingEvent = options.lazy === true;
|
|
2485
|
-
if (attemptToVisitEvent) {
|
|
2486
|
-
if (hasOwnProperty(runtimeContext, "event")) {
|
|
2487
|
-
globalVariables.EVENT = runtimeContext.event;
|
|
2488
|
-
} else {
|
|
2489
|
-
// Let's see if pre-evaluation is required (store the `data` in context).
|
|
2490
|
-
missingEvent = true;
|
|
2491
|
-
}
|
|
2492
|
-
}
|
|
2493
|
-
var missingTplOrState = attemptToVisitTplOrState && !hasOwnProperty(runtimeContext, "tplContextId");
|
|
2494
|
-
var missingData = attemptToVisitData && !hasOwnProperty(runtimeContext, "data");
|
|
2495
|
-
var rawWithContext = Object.keys(runtimeContext).length > 0 ? {
|
|
2496
|
-
[symbolForRaw]: raw,
|
|
2497
|
-
[symbolForContext]: runtimeContext
|
|
2498
|
-
} : raw;
|
|
2499
|
-
|
|
2500
|
-
// Since `EVENT`, `DATA`, `TPL` and `STATE` are provided in different context,
|
|
2501
|
-
// whenever missing one of them, memorize the current context for later consuming.
|
|
2502
|
-
if (missingEvent || missingData || missingTplOrState) {
|
|
2503
|
-
return rawWithContext;
|
|
2504
|
-
}
|
|
2505
|
-
if (attemptToVisitData) {
|
|
2506
|
-
globalVariables.DATA = runtimeContext.data;
|
|
2507
|
-
}
|
|
2508
|
-
if (attemptToVisitTplOrState && runtimeContext.tplContextId) {
|
|
2509
|
-
var tplContext = getCustomTemplateContext(runtimeContext.tplContextId);
|
|
2510
|
-
if (attemptToVisitTpl) {
|
|
2511
|
-
globalVariables.TPL = tplContext.getVariables();
|
|
2392
|
+
function _fetchMenuById() {
|
|
2393
|
+
_fetchMenuById = _asyncToGenerator$3(function* (menuId, kernel, isPreFetch) {
|
|
2394
|
+
if (menuCache.has(menuId)) {
|
|
2395
|
+
return menuCache.get(menuId);
|
|
2512
2396
|
}
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2397
|
+
var menuList = window.STANDALONE_MICRO_APPS ? yield kernel.getStandaloneMenus(menuId, isPreFetch) : kernel.getFeatureFlags()["three-level-menu-layout"] ? (yield InstalledMicroAppApi_getMenusInfo(menuId, {
|
|
2398
|
+
menuObjectId: "EASYOPS_STORYBOARD_MENU"
|
|
2399
|
+
})).menus : (yield InstanceApi_postSearch("EASYOPS_STORYBOARD_MENU", {
|
|
2400
|
+
page: 1,
|
|
2401
|
+
page_size: 200,
|
|
2402
|
+
fields: {
|
|
2403
|
+
menuId: true,
|
|
2404
|
+
title: true,
|
|
2405
|
+
icon: true,
|
|
2406
|
+
link: true,
|
|
2407
|
+
titleDataSource: true,
|
|
2408
|
+
defaultCollapsed: true,
|
|
2409
|
+
defaultCollapsedBreakpoint: true,
|
|
2410
|
+
type: true,
|
|
2411
|
+
injectMenuGroupId: true,
|
|
2412
|
+
dynamicItems: true,
|
|
2413
|
+
itemsResolve: true,
|
|
2414
|
+
items: true,
|
|
2415
|
+
i18n: true,
|
|
2416
|
+
"items.children": true,
|
|
2417
|
+
"app.appId": true
|
|
2418
|
+
},
|
|
2419
|
+
query: {
|
|
2420
|
+
menuId: {
|
|
2421
|
+
$eq: menuId
|
|
2517
2422
|
},
|
|
2518
|
-
|
|
2519
|
-
|
|
2423
|
+
app: {
|
|
2424
|
+
$size: {
|
|
2425
|
+
$gt: 0
|
|
2426
|
+
}
|
|
2520
2427
|
}
|
|
2521
|
-
}
|
|
2428
|
+
}
|
|
2429
|
+
})).list;
|
|
2430
|
+
var menuData = yield mergeMenu(menuList, kernel);
|
|
2431
|
+
if (!menuData) {
|
|
2432
|
+
throw new Error("Menu not found: ".concat(menuId));
|
|
2522
2433
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2434
|
+
reorderMenu(menuData);
|
|
2435
|
+
menuData[symbolShouldCache] && menuCache.set(menuId, menuData);
|
|
2436
|
+
return menuData;
|
|
2437
|
+
});
|
|
2438
|
+
return _fetchMenuById.apply(this, arguments);
|
|
2439
|
+
}
|
|
2440
|
+
function mergeMenu(_x10, _x11) {
|
|
2441
|
+
return _mergeMenu.apply(this, arguments);
|
|
2442
|
+
}
|
|
2443
|
+
function _mergeMenu() {
|
|
2444
|
+
_mergeMenu = _asyncToGenerator$3(function* (menuList, kernel) {
|
|
2445
|
+
var mainMenu = menuList.find(menu => menu.type !== "inject");
|
|
2446
|
+
if (!mainMenu) {
|
|
2447
|
+
return undefined;
|
|
2448
|
+
}
|
|
2449
|
+
var validMenuList = [];
|
|
2450
|
+
var injectWithMenus = new Map();
|
|
2451
|
+
var menuWithI18n = new WeakMap();
|
|
2452
|
+
for (var menu of menuList) {
|
|
2453
|
+
if (menu.i18n) {
|
|
2454
|
+
(function () {
|
|
2455
|
+
var menuI18nNamespace = getI18nNamespace("menu", "".concat(menu.menuId, "~").concat(menu.app[0].appId, "+").concat(menu.instanceId));
|
|
2456
|
+
// Support any language in `meta.i18n`.
|
|
2457
|
+
Object.entries(menu.i18n).forEach(_ref6 => {
|
|
2458
|
+
var [lang, resources] = _ref6;
|
|
2459
|
+
i18next.addResourceBundle(lang, menuI18nNamespace, resources);
|
|
2460
|
+
});
|
|
2461
|
+
menuWithI18n.set(menu, menuI18nNamespace);
|
|
2462
|
+
})();
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
var shouldCacheList = yield Promise.all(menuList.map(menu => loadDynamicMenuItems(menu, kernel, menuWithI18n)));
|
|
2466
|
+
for (var _menu of menuList) {
|
|
2467
|
+
var _menu$items;
|
|
2468
|
+
if (((_menu$items = _menu.items) === null || _menu$items === void 0 ? void 0 : _menu$items.length) > 0) {
|
|
2469
|
+
if (_menu.type === "inject" && _menu.injectMenuGroupId) {
|
|
2470
|
+
var injectingMenus = injectWithMenus.get(_menu.injectMenuGroupId);
|
|
2471
|
+
if (!injectingMenus) {
|
|
2472
|
+
injectingMenus = [];
|
|
2473
|
+
injectWithMenus.set(_menu.injectMenuGroupId, injectingMenus);
|
|
2474
|
+
}
|
|
2475
|
+
injectingMenus.push(_menu);
|
|
2476
|
+
} else {
|
|
2477
|
+
validMenuList.push(_menu);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
return _objectSpread(_objectSpread({}, mainMenu), {}, {
|
|
2482
|
+
items: validMenuList.flatMap(menu => processGroupInject(menu.items, menu, injectWithMenus, menuWithI18n)),
|
|
2483
|
+
[symbolShouldCache]: shouldCacheList.every(Boolean),
|
|
2484
|
+
[symbolMenuI18nNamespace]: menuWithI18n.get(mainMenu),
|
|
2485
|
+
[symbolOverrideApp]: mainMenu.overrideApp
|
|
2486
|
+
});
|
|
2487
|
+
});
|
|
2488
|
+
return _mergeMenu.apply(this, arguments);
|
|
2489
|
+
}
|
|
2490
|
+
function processGroupInject(items, menu, injectWithMenus, menuWithI18n) {
|
|
2491
|
+
return items === null || items === void 0 ? void 0 : items.map(item => {
|
|
2492
|
+
var _processGroupInject;
|
|
2493
|
+
var foundInjectingMenus = item.groupId && injectWithMenus.get(item.groupId);
|
|
2494
|
+
if (foundInjectingMenus) {
|
|
2495
|
+
// Each menu to be injected with should be injected only once.
|
|
2496
|
+
injectWithMenus.delete(item.groupId);
|
|
2497
|
+
}
|
|
2498
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
2499
|
+
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)) : []),
|
|
2500
|
+
[symbolAppId]: menu.app[0].appId,
|
|
2501
|
+
[symbolMenuI18nNamespace]: menuWithI18n.get(menu),
|
|
2502
|
+
[symbolOverrideApp]: menu.overrideApp
|
|
2503
|
+
});
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
function loadDynamicMenuItems(_x12, _x13, _x14) {
|
|
2507
|
+
return _loadDynamicMenuItems.apply(this, arguments);
|
|
2508
|
+
}
|
|
2509
|
+
function _loadDynamicMenuItems() {
|
|
2510
|
+
_loadDynamicMenuItems = _asyncToGenerator$3(function* (menu, kernel, menuWithI18n) {
|
|
2511
|
+
if (menu.dynamicItems && menu.itemsResolve) {
|
|
2512
|
+
var _menu$itemsResolve;
|
|
2513
|
+
var itemsConf = {};
|
|
2514
|
+
var overrideAppId = menu.app[0].appId;
|
|
2515
|
+
var context = _internalApiGetCurrentContext();
|
|
2516
|
+
var newContext = context;
|
|
2517
|
+
if (overrideAppId !== context.app.id && attemptToVisit(menu.itemsResolve, ["APP", "I18N"])) {
|
|
2518
|
+
if (window.STANDALONE_MICRO_APPS) {
|
|
2519
|
+
if (menu.overrideApp) {
|
|
2520
|
+
menu.overrideApp.config = deepFreeze(merge({}, menu.overrideApp.defaultConfig, menu.overrideApp.userConfig));
|
|
2521
|
+
}
|
|
2522
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
2523
|
+
overrideApp: menu.overrideApp,
|
|
2524
|
+
appendI18nNamespace: menuWithI18n.get(menu)
|
|
2525
|
+
});
|
|
2526
|
+
} else {
|
|
2527
|
+
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
2528
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
2529
|
+
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
2530
|
+
appendI18nNamespace: menuWithI18n.get(menu)
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
var usedActions = scanPermissionActionsInAny(menu.itemsResolve);
|
|
2535
|
+
yield validatePermissions(usedActions);
|
|
2536
|
+
yield _internalApiGetResolver().resolveOne("reference", _objectSpread({
|
|
2537
|
+
transform: "items",
|
|
2538
|
+
transformMapArray: false
|
|
2539
|
+
}, menu.itemsResolve), itemsConf, null, newContext);
|
|
2540
|
+
menu.items = itemsConf.items;
|
|
2541
|
+
if ((_menu$itemsResolve = menu.itemsResolve) !== null && _menu$itemsResolve !== void 0 && _menu$itemsResolve.args) {
|
|
2542
|
+
var _menu$itemsResolve2;
|
|
2543
|
+
return !attemptToVisit((_menu$itemsResolve2 = menu.itemsResolve) === null || _menu$itemsResolve2 === void 0 ? void 0 : _menu$itemsResolve2.args, ["QUERY", "PATH"]);
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
return true;
|
|
2547
|
+
});
|
|
2548
|
+
return _loadDynamicMenuItems.apply(this, arguments);
|
|
2549
|
+
}
|
|
2550
|
+
function walkMenuItems(menuItems) {
|
|
2551
|
+
return menuItems === null || menuItems === void 0 ? void 0 : menuItems.filter(
|
|
2552
|
+
// `if` is already evaluated.
|
|
2553
|
+
looseCheckIfOfComputed).map(item => {
|
|
2554
|
+
var children = walkMenuItems(item.children || item.items);
|
|
2555
|
+
return item.type === "group" ? {
|
|
2556
|
+
type: "group",
|
|
2557
|
+
childLayout: item.childLayout,
|
|
2558
|
+
title: item.text || item.title,
|
|
2559
|
+
items: children,
|
|
2560
|
+
groupId: item.groupId,
|
|
2561
|
+
groupFrom: item.groupFrom
|
|
2562
|
+
} : children !== null && children !== void 0 && children.length ? {
|
|
2563
|
+
type: "subMenu",
|
|
2564
|
+
childLayout: item.childLayout,
|
|
2565
|
+
title: item.text || item.title,
|
|
2566
|
+
icon: item.icon,
|
|
2567
|
+
items: children,
|
|
2568
|
+
defaultExpanded: item.defaultExpanded
|
|
2569
|
+
} : item;
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
function processMenu(_x15, _x16, _x17, _x18, _x19) {
|
|
2573
|
+
return _processMenu.apply(this, arguments);
|
|
2574
|
+
}
|
|
2575
|
+
function _processMenu() {
|
|
2576
|
+
_processMenu = _asyncToGenerator$3(function* (menuId, context, kernel, hasSubMenu, isPreFetch) {
|
|
2577
|
+
var _yield$fetchMenuById = yield fetchMenuById(menuId, kernel, isPreFetch),
|
|
2578
|
+
{
|
|
2579
|
+
items,
|
|
2580
|
+
app
|
|
2581
|
+
} = _yield$fetchMenuById,
|
|
2582
|
+
restMenuData = _objectWithoutProperties(_yield$fetchMenuById, _excluded3);
|
|
2583
|
+
var usedActions = scanPermissionActionsInAny([items, restMenuData]);
|
|
2584
|
+
yield validatePermissions(usedActions);
|
|
2585
|
+
var appsRequireI18nFulfilled = new Set();
|
|
2586
|
+
var rootAppId = app[0].appId;
|
|
2587
|
+
if (rootAppId !== context.app.id && !restMenuData[symbolMenuI18nNamespace]) {
|
|
2588
|
+
appsRequireI18nFulfilled.add(rootAppId);
|
|
2589
|
+
}
|
|
2590
|
+
collectAppsRequireI18nFulfilled(items, context.app.id, appsRequireI18nFulfilled);
|
|
2591
|
+
yield kernel.fulfilStoryboardI18n([...appsRequireI18nFulfilled]);
|
|
2592
|
+
var menuData = _objectSpread(_objectSpread({}, yield computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
2593
|
+
items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
2594
|
+
});
|
|
2595
|
+
return {
|
|
2596
|
+
title: yield processMenuTitle(menuData),
|
|
2597
|
+
icon: menuData.icon,
|
|
2598
|
+
link: menuData.link,
|
|
2599
|
+
menuItems: walkMenuItems(menuData.items),
|
|
2600
|
+
defaultCollapsed: menuData.defaultCollapsed || hasSubMenu,
|
|
2601
|
+
defaultCollapsedBreakpoint: menuData.defaultCollapsedBreakpoint
|
|
2602
|
+
};
|
|
2603
|
+
});
|
|
2604
|
+
return _processMenu.apply(this, arguments);
|
|
2605
|
+
}
|
|
2606
|
+
function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
|
|
2607
|
+
function collect(items) {
|
|
2608
|
+
for (var _ref of items) {
|
|
2609
|
+
var {
|
|
2610
|
+
children
|
|
2611
|
+
} = _ref,
|
|
2612
|
+
rest = _objectWithoutProperties(_ref, _excluded$8);
|
|
2613
|
+
var overrideAppId = rest[symbolAppId];
|
|
2614
|
+
if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
|
|
2615
|
+
appIds.add(overrideAppId);
|
|
2616
|
+
}
|
|
2617
|
+
children && collect(children);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
collect(items);
|
|
2621
|
+
}
|
|
2622
|
+
function computeMenuItemsWithOverrideApp(items, context, kernel) {
|
|
2623
|
+
return Promise.all(items.map( /*#__PURE__*/function () {
|
|
2624
|
+
var _ref3 = _asyncToGenerator$3(function* (_ref2) {
|
|
2625
|
+
var {
|
|
2626
|
+
children
|
|
2627
|
+
} = _ref2,
|
|
2628
|
+
rest = _objectWithoutProperties(_ref2, _excluded2$2);
|
|
2629
|
+
return _objectSpread(_objectSpread({}, yield computeRealValueWithOverrideApp(rest, rest[symbolAppId], context, kernel)), {}, {
|
|
2630
|
+
children: children && (yield computeMenuItemsWithOverrideApp(children, context, kernel))
|
|
2631
|
+
});
|
|
2632
|
+
});
|
|
2633
|
+
return function (_x20) {
|
|
2634
|
+
return _ref3.apply(this, arguments);
|
|
2635
|
+
};
|
|
2636
|
+
}()));
|
|
2637
|
+
}
|
|
2638
|
+
function processMenuTitle(_x21) {
|
|
2639
|
+
return _processMenuTitle.apply(this, arguments);
|
|
2640
|
+
}
|
|
2641
|
+
function _processMenuTitle() {
|
|
2642
|
+
_processMenuTitle = _asyncToGenerator$3(function* (menuData) {
|
|
2643
|
+
if (menuData.title || isEmpty(menuData.titleDataSource)) {
|
|
2644
|
+
return menuData.title;
|
|
2645
|
+
}
|
|
2646
|
+
var cacheKey = JSON.stringify(menuData.titleDataSource);
|
|
2647
|
+
if (menuTitleCache.has(cacheKey)) {
|
|
2648
|
+
return menuTitleCache.get(cacheKey);
|
|
2649
|
+
}
|
|
2650
|
+
var {
|
|
2651
|
+
objectId,
|
|
2652
|
+
instanceId,
|
|
2653
|
+
attributeId
|
|
2654
|
+
} = menuData.titleDataSource;
|
|
2655
|
+
var attr = attributeId !== null && attributeId !== void 0 ? attributeId : "name";
|
|
2656
|
+
var instanceData = yield InstanceApi_getDetail(objectId, instanceId, {
|
|
2657
|
+
fields: attr
|
|
2658
|
+
});
|
|
2659
|
+
var title;
|
|
2660
|
+
if (attributeId === "#showKey" && Array.isArray(instanceData[attr])) {
|
|
2661
|
+
var [primary, ...rest] = instanceData[attr];
|
|
2662
|
+
title = rest.length > 0 ? "".concat(primary, "(").concat(rest.join(","), ")") : String(primary);
|
|
2663
|
+
} else {
|
|
2664
|
+
title = String(instanceData[attr]);
|
|
2665
|
+
}
|
|
2666
|
+
menuTitleCache.set(cacheKey, title);
|
|
2667
|
+
return title;
|
|
2668
|
+
});
|
|
2669
|
+
return _processMenuTitle.apply(this, arguments);
|
|
2670
|
+
}
|
|
2671
|
+
function clearMenuTitleCache() {
|
|
2672
|
+
menuTitleCache.clear();
|
|
2673
|
+
}
|
|
2674
|
+
function clearMenuCache() {
|
|
2675
|
+
menuCache.clear();
|
|
2676
|
+
}
|
|
2677
|
+
function reorderMenu(menuData) {
|
|
2678
|
+
menuData.items = reorderMenuItems(menuData.items);
|
|
2679
|
+
}
|
|
2680
|
+
function reorderMenuItems(list) {
|
|
2681
|
+
return sortMenuItems(list).map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
2682
|
+
children: reorderMenuItems(item.children)
|
|
2683
|
+
}));
|
|
2684
|
+
}
|
|
2685
|
+
function sortMenuItems(list) {
|
|
2686
|
+
return sortBy(list, item => {
|
|
2687
|
+
var _item$sort;
|
|
2688
|
+
return (_item$sort = item.sort) !== null && _item$sort !== void 0 ? _item$sort : -Infinity;
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
/**
|
|
2693
|
+
* If the menu contains evaluations which use `APP` or `I18N`,
|
|
2694
|
+
* we have to override app in context when computing real values.
|
|
2695
|
+
*/
|
|
2696
|
+
function attemptToVisit(data, globals) {
|
|
2697
|
+
var memo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakSet();
|
|
2698
|
+
if (typeof data === "string") {
|
|
2699
|
+
if (isEvaluable(data)) {
|
|
2700
|
+
if (globals.some(key => data.includes(key))) {
|
|
2701
|
+
var {
|
|
2702
|
+
attemptToVisitGlobals
|
|
2703
|
+
} = preevaluate(data);
|
|
2704
|
+
return globals.some(key => attemptToVisitGlobals.has(key));
|
|
2705
|
+
}
|
|
2706
|
+
} else if (globals.includes("APP")) {
|
|
2707
|
+
return /\${\s*APP\s*\./.test(data);
|
|
2708
|
+
}
|
|
2709
|
+
} else if (isObject(data)) {
|
|
2710
|
+
// Avoid call stack overflow.
|
|
2711
|
+
// istanbul ignore next
|
|
2712
|
+
if (memo.has(data)) {
|
|
2713
|
+
return false;
|
|
2714
|
+
}
|
|
2715
|
+
memo.add(data);
|
|
2716
|
+
return (Array.isArray(data) ? data : Object.values(data)).some(item => attemptToVisit(item, globals, memo));
|
|
2717
|
+
}
|
|
2718
|
+
return false;
|
|
2719
|
+
}
|
|
2720
|
+
function computeRealValueWithOverrideApp(_x22, _x23, _x24, _x25) {
|
|
2721
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
2722
|
+
}
|
|
2723
|
+
function _computeRealValueWithOverrideApp() {
|
|
2724
|
+
_computeRealValueWithOverrideApp = _asyncToGenerator$3(function* (data, overrideAppId, context, kernel) {
|
|
2725
|
+
if ("titleDataSource" in data && isObject(data.titleDataSource) && Object.entries(data.titleDataSource).every(_ref7 => {
|
|
2726
|
+
var [key, value] = _ref7;
|
|
2727
|
+
return value === null || value === "";
|
|
2728
|
+
})) {
|
|
2729
|
+
delete data.titleDataSource;
|
|
2730
|
+
}
|
|
2731
|
+
if ("if" in data && data.if === null) {
|
|
2732
|
+
delete data.if;
|
|
2733
|
+
}
|
|
2734
|
+
if ("to" in data && data.to && !isEvaluable(data.to)) {
|
|
2735
|
+
var yaml = pipes.yaml(data.to);
|
|
2736
|
+
if (isObject(yaml) && ["pathname", "search", "hash"].some(key => hasOwnProperty(yaml, key))) {
|
|
2737
|
+
data.to = yaml;
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
var newContext = context;
|
|
2741
|
+
if (overrideAppId !== context.app.id && attemptToVisit(data, ["APP", "I18N", "IMG"])) {
|
|
2742
|
+
if (window.STANDALONE_MICRO_APPS) {
|
|
2743
|
+
if (data[symbolOverrideApp]) {
|
|
2744
|
+
data[symbolOverrideApp].config = deepFreeze(merge({}, data[symbolOverrideApp].defaultConfig, data[symbolOverrideApp].userConfig));
|
|
2745
|
+
}
|
|
2746
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
2747
|
+
overrideApp: data[symbolOverrideApp],
|
|
2748
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
2749
|
+
});
|
|
2750
|
+
} else {
|
|
2751
|
+
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
2752
|
+
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
2753
|
+
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
2754
|
+
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
2755
|
+
});
|
|
2532
2756
|
}
|
|
2757
|
+
}
|
|
2758
|
+
var processors = scanProcessorsInAny(data);
|
|
2759
|
+
yield kernel.loadDynamicBricks([], processors);
|
|
2760
|
+
yield kernel.router.waitForUsedContext(data);
|
|
2761
|
+
return computeRealValue(data, newContext, true, {
|
|
2762
|
+
ignoreSymbols: true
|
|
2763
|
+
});
|
|
2764
|
+
});
|
|
2765
|
+
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
var MediaBreakpoint;
|
|
2769
|
+
(function (MediaBreakpoint) {
|
|
2770
|
+
MediaBreakpoint["xLarge"] = "xLarge";
|
|
2771
|
+
MediaBreakpoint["large"] = "large";
|
|
2772
|
+
MediaBreakpoint["medium"] = "medium";
|
|
2773
|
+
MediaBreakpoint["small"] = "small";
|
|
2774
|
+
MediaBreakpoint["xSmall"] = "xSmall";
|
|
2775
|
+
})(MediaBreakpoint || (MediaBreakpoint = {}));
|
|
2776
|
+
var mediaBreakpointMinWidthMap = new Map([[MediaBreakpoint.xLarge, "1920px"], [MediaBreakpoint.large, "1600px"], [MediaBreakpoint.medium, "1280px"], [MediaBreakpoint.small, "1024px"], [MediaBreakpoint.xSmall, 0]]);
|
|
2777
|
+
var mediaEventTarget = new EventTarget$1();
|
|
2778
|
+
var breakpointMatchesMap = {};
|
|
2779
|
+
var MEDIA = {};
|
|
2780
|
+
function handleMatchesChange(data, breakpoint) {
|
|
2781
|
+
var changed = false;
|
|
2782
|
+
breakpointMatchesMap[breakpoint] = data.matches;
|
|
2783
|
+
for (var [_breakpoint] of mediaBreakpointMinWidthMap) {
|
|
2784
|
+
if (breakpointMatchesMap[_breakpoint] && MEDIA.breakpoint !== _breakpoint) {
|
|
2785
|
+
MEDIA.breakpoint = _breakpoint;
|
|
2786
|
+
changed = true;
|
|
2787
|
+
break;
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
if (changed) {
|
|
2791
|
+
mediaEventTarget.dispatchEvent(new CustomEvent("change", {
|
|
2792
|
+
detail: MEDIA
|
|
2793
|
+
}));
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
mediaBreakpointMinWidthMap.forEach((minWidth, breakpoint) => {
|
|
2797
|
+
var mediaQueryList = window.matchMedia("(min-width: ".concat(minWidth, ")"));
|
|
2798
|
+
handleMatchesChange(mediaQueryList, breakpoint);
|
|
2799
|
+
if (mediaQueryList.addEventListener) {
|
|
2800
|
+
mediaQueryList.addEventListener("change", event => {
|
|
2801
|
+
handleMatchesChange(event, breakpoint);
|
|
2802
|
+
});
|
|
2803
|
+
} else {
|
|
2804
|
+
mediaQueryList.addListener(event => {
|
|
2805
|
+
handleMatchesChange(event, breakpoint);
|
|
2533
2806
|
});
|
|
2534
2807
|
}
|
|
2535
|
-
|
|
2536
|
-
|
|
2808
|
+
});
|
|
2809
|
+
var getMedia = () => MEDIA;
|
|
2537
2810
|
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2811
|
+
var FormContextMap = new Map();
|
|
2812
|
+
class CustomFormContext {
|
|
2813
|
+
constructor(renderId) {
|
|
2814
|
+
_defineProperty$1(this, "formState", void 0);
|
|
2815
|
+
_defineProperty$1(this, "id", uniqueId("form-ctx-"));
|
|
2816
|
+
FormContextMap.set(this.id, this);
|
|
2817
|
+
this.formState = new StoryboardContextWrapper(undefined, this.id, renderId);
|
|
2543
2818
|
}
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
};
|
|
2564
|
-
case "ANCHOR":
|
|
2565
|
-
return hash ? hash.substr(1) : null;
|
|
2566
|
-
case "APP":
|
|
2567
|
-
return _objectSpread(_objectSpread({}, cloneDeep(app)), {}, {
|
|
2568
|
-
getMenu
|
|
2569
|
-
});
|
|
2570
|
-
case "CTX":
|
|
2571
|
-
return getDynamicReadOnlyProxy({
|
|
2572
|
-
get(target, key) {
|
|
2573
|
-
var _item$brick$element;
|
|
2574
|
-
var item = storyboardContext.get(key);
|
|
2575
|
-
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;
|
|
2576
|
-
},
|
|
2577
|
-
ownKeys() {
|
|
2578
|
-
return Array.from(storyboardContext.keys());
|
|
2579
|
-
}
|
|
2580
|
-
});
|
|
2581
|
-
case "FLAGS":
|
|
2582
|
-
return getReadOnlyProxy(flags);
|
|
2583
|
-
case "HASH":
|
|
2584
|
-
return hash;
|
|
2585
|
-
case "PATH_NAME":
|
|
2586
|
-
return pathname;
|
|
2587
|
-
case "INSTALLED_APPS":
|
|
2588
|
-
return {
|
|
2589
|
-
has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
|
|
2590
|
-
};
|
|
2591
|
-
case "LOCAL_STORAGE":
|
|
2592
|
-
return {
|
|
2593
|
-
getItem: getItemFactory("local")
|
|
2594
|
-
};
|
|
2595
|
-
case "MISC":
|
|
2596
|
-
return getRuntime().getMiscSettings();
|
|
2597
|
-
case "PARAMS":
|
|
2598
|
-
return new URLSearchParams(query);
|
|
2599
|
-
case "PATH":
|
|
2600
|
-
return getReadOnlyProxy(match.params);
|
|
2601
|
-
case "PROCESSORS":
|
|
2602
|
-
return getDynamicReadOnlyProxy({
|
|
2603
|
-
get(target, key) {
|
|
2604
|
-
var pkg = customProcessorRegistry.get(key);
|
|
2605
|
-
if (!pkg) {
|
|
2606
|
-
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'?"));
|
|
2607
|
-
}
|
|
2608
|
-
return getDynamicReadOnlyProxy({
|
|
2609
|
-
get(t, k) {
|
|
2610
|
-
return pkg.get(k);
|
|
2611
|
-
},
|
|
2612
|
-
ownKeys() {
|
|
2613
|
-
return Array.from(pkg.keys());
|
|
2614
|
-
}
|
|
2615
|
-
});
|
|
2616
|
-
},
|
|
2617
|
-
ownKeys() {
|
|
2618
|
-
return Array.from(customProcessorRegistry.keys());
|
|
2619
|
-
}
|
|
2620
|
-
});
|
|
2621
|
-
case "QUERY":
|
|
2622
|
-
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
|
|
2623
|
-
case "QUERY_ARRAY":
|
|
2624
|
-
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
|
|
2625
|
-
case "SEGUE":
|
|
2626
|
-
return {
|
|
2627
|
-
getUrl: getUrlBySegueFactory(app, segues)
|
|
2628
|
-
};
|
|
2629
|
-
case "SESSION_STORAGE":
|
|
2630
|
-
return {
|
|
2631
|
-
getItem: getItemFactory("session")
|
|
2632
|
-
};
|
|
2633
|
-
case "SYS":
|
|
2634
|
-
return getReadOnlyProxy(sys);
|
|
2635
|
-
case "MEDIA":
|
|
2636
|
-
return getReadOnlyProxy(getMedia());
|
|
2637
|
-
case "__WIDGET_FN__":
|
|
2638
|
-
return widgetFunctions;
|
|
2639
|
-
case "__WIDGET_IMG__":
|
|
2640
|
-
return widgetImagesFactory;
|
|
2641
|
-
case "__WIDGET_I18N__":
|
|
2642
|
-
return widgetI18nFactory;
|
|
2643
|
-
}
|
|
2819
|
+
}
|
|
2820
|
+
function getCustomFormContext(formContextId) {
|
|
2821
|
+
return FormContextMap.get(formContextId);
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
var symbolForRaw = Symbol.for("pre.evaluated.raw");
|
|
2825
|
+
var symbolForContext = Symbol.for("pre.evaluated.context");
|
|
2826
|
+
function isPreEvaluated(raw) {
|
|
2827
|
+
return !!(raw !== null && raw !== void 0 && raw[symbolForRaw]);
|
|
2828
|
+
}
|
|
2829
|
+
function getPreEvaluatedRaw(pre) {
|
|
2830
|
+
return pre[symbolForRaw];
|
|
2831
|
+
}
|
|
2832
|
+
function addDataToPreEvaluated(pre, data) {
|
|
2833
|
+
pre[symbolForContext].data = data;
|
|
2834
|
+
}
|
|
2835
|
+
function shouldDismissRecursiveMarkingInjected(raw) {
|
|
2836
|
+
if (typeof raw === "string") {
|
|
2837
|
+
return shouldAllowRecursiveEvaluations(raw);
|
|
2644
2838
|
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2839
|
+
return shouldAllowRecursiveEvaluations(raw[symbolForRaw]);
|
|
2840
|
+
}
|
|
2841
|
+
var possibleErrorConstructs = new WeakSet([SyntaxError, TypeError, ReferenceError]);
|
|
2842
|
+
function getCookErrorConstructor(error) {
|
|
2843
|
+
return possibleErrorConstructs.has(error.constructor) ? error.constructor : TypeError;
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
// `raw` should always be asserted to `isEvaluable` or `isPreEvaluated`.
|
|
2847
|
+
function evaluate(raw) {
|
|
2848
|
+
var _runtimeContext$overr;
|
|
2849
|
+
var runtimeContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2850
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2851
|
+
if (options.isReEvaluation && !(typeof raw === "string" && isEvaluable(raw))) {
|
|
2852
|
+
devtoolsHookEmit("re-evaluation", {
|
|
2853
|
+
id: options.evaluationId,
|
|
2854
|
+
detail: {
|
|
2855
|
+
raw,
|
|
2856
|
+
context: {}
|
|
2857
|
+
},
|
|
2858
|
+
error: "Invalid evaluation code"
|
|
2859
|
+
});
|
|
2860
|
+
return;
|
|
2861
|
+
}
|
|
2862
|
+
if (typeof raw !== "string") {
|
|
2863
|
+
// If the `raw` is not a string, it must be a pre-evaluated object.
|
|
2864
|
+
// Then fulfil the context, and restore the original `raw`.
|
|
2865
|
+
runtimeContext = _objectSpread(_objectSpread({}, raw[symbolForContext]), runtimeContext);
|
|
2866
|
+
raw = raw[symbolForRaw];
|
|
2650
2867
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
appendI18nNamespace: runtimeContext.appendI18nNamespace
|
|
2655
|
-
}));
|
|
2868
|
+
|
|
2869
|
+
// A `SyntaxError` maybe thrown.
|
|
2870
|
+
var precooked;
|
|
2656
2871
|
try {
|
|
2657
|
-
|
|
2658
|
-
globalVariables: supply(precooked.attemptToVisitGlobals, globalVariables)
|
|
2659
|
-
});
|
|
2660
|
-
var detail = {
|
|
2661
|
-
raw,
|
|
2662
|
-
context: globalVariables,
|
|
2663
|
-
result
|
|
2664
|
-
};
|
|
2665
|
-
if (options.isReEvaluation) {
|
|
2666
|
-
devtoolsHookEmit("re-evaluation", {
|
|
2667
|
-
id: options.evaluationId,
|
|
2668
|
-
detail
|
|
2669
|
-
});
|
|
2670
|
-
} else {
|
|
2671
|
-
devtoolsHookEmit("evaluation", detail);
|
|
2672
|
-
}
|
|
2673
|
-
return result;
|
|
2872
|
+
precooked = preevaluate(raw);
|
|
2674
2873
|
} catch (error) {
|
|
2675
|
-
var
|
|
2874
|
+
var message = "".concat(error.message, ", in \"").concat(raw, "\"");
|
|
2676
2875
|
if (options.isReEvaluation) {
|
|
2677
2876
|
devtoolsHookEmit("re-evaluation", {
|
|
2678
2877
|
id: options.evaluationId,
|
|
2679
2878
|
detail: {
|
|
2680
2879
|
raw,
|
|
2681
|
-
context:
|
|
2880
|
+
context: {}
|
|
2682
2881
|
},
|
|
2683
|
-
error:
|
|
2882
|
+
error: message
|
|
2684
2883
|
});
|
|
2884
|
+
return;
|
|
2685
2885
|
} else {
|
|
2686
|
-
var
|
|
2687
|
-
throw new
|
|
2886
|
+
var errorConstructor = getCookErrorConstructor(error);
|
|
2887
|
+
throw new errorConstructor(message);
|
|
2688
2888
|
}
|
|
2689
2889
|
}
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
function isMergeableProperty(propRef) {
|
|
2699
|
-
return !!propRef.mergeProperty;
|
|
2700
|
-
}
|
|
2701
|
-
function isRefProperty(propRef) {
|
|
2702
|
-
return !!propRef.ref;
|
|
2703
|
-
}
|
|
2704
|
-
function isVariableProperty(propRef) {
|
|
2705
|
-
return !!propRef.asVariable;
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
var customTemplateRegistry = new Map();
|
|
2709
|
-
var appRegistered = new Set();
|
|
2710
|
-
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
2711
|
-
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
2712
|
-
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
2890
|
+
var globalVariables = {};
|
|
2891
|
+
var attemptToVisitGlobals = precooked.attemptToVisitGlobals;
|
|
2892
|
+
var attemptToVisitEvent = attemptToVisitGlobals.has("EVENT");
|
|
2893
|
+
var attemptToVisitData = attemptToVisitGlobals.has("DATA");
|
|
2894
|
+
var attemptToVisitTpl = attemptToVisitGlobals.has("TPL");
|
|
2895
|
+
var attemptToVisitState = attemptToVisitGlobals.has("STATE");
|
|
2896
|
+
var attemptToVisitFormState = attemptToVisitGlobals.has("FORM_STATE");
|
|
2897
|
+
var attemptToVisitTplOrState = attemptToVisitTpl || attemptToVisitState;
|
|
2713
2898
|
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
}
|
|
2724
|
-
// istanbul ignore next: should never reach
|
|
2725
|
-
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
2726
|
-
}
|
|
2727
|
-
function propertyMergeAllOfArray(_ref, object) {
|
|
2728
|
-
var _, _proxy$mergeArgs;
|
|
2729
|
-
var {
|
|
2730
|
-
baseValue,
|
|
2731
|
-
context,
|
|
2732
|
-
proxies
|
|
2733
|
-
} = _ref;
|
|
2734
|
-
// Use an approach like template-literal's quasis:
|
|
2735
|
-
// `quasi0${0}quais1${1}quasi2...`
|
|
2736
|
-
// Every quasi can be merged with multiple items.
|
|
2737
|
-
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
2738
|
-
$$lazyForUseBrick: true
|
|
2739
|
-
}) : [];
|
|
2740
|
-
var quasis = [];
|
|
2741
|
-
var size = computedBaseValue.length + 1;
|
|
2742
|
-
for (var i = 0; i < size; i += 1) {
|
|
2743
|
-
quasis.push([]);
|
|
2744
|
-
}
|
|
2745
|
-
for (var proxy of proxies) {
|
|
2746
|
-
var position = void 0;
|
|
2747
|
-
switch (proxy.mergeMethod) {
|
|
2748
|
-
case "append":
|
|
2749
|
-
position = computedBaseValue.length;
|
|
2750
|
-
break;
|
|
2751
|
-
case "prepend":
|
|
2752
|
-
position = 0;
|
|
2753
|
-
break;
|
|
2754
|
-
case "insertAt":
|
|
2755
|
-
// Defaults to `-1`.
|
|
2756
|
-
position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
|
|
2757
|
-
if (position < 0) {
|
|
2758
|
-
// It's counted from the end if position is negative.
|
|
2759
|
-
position += quasis.length;
|
|
2760
|
-
}
|
|
2761
|
-
position = clamp(position, 0, computedBaseValue.length);
|
|
2762
|
-
break;
|
|
2763
|
-
// istanbul ignore next: should never reach
|
|
2764
|
-
default:
|
|
2765
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2766
|
-
}
|
|
2767
|
-
var patchValue = object[proxy.$$reversedRef];
|
|
2768
|
-
if (!Array.isArray(patchValue)) {
|
|
2769
|
-
patchValue = [];
|
|
2899
|
+
// Ignore evaluating if `event` is missing in context.
|
|
2900
|
+
// Since it should be evaluated during events handling.
|
|
2901
|
+
var missingEvent = options.lazy === true;
|
|
2902
|
+
if (attemptToVisitEvent) {
|
|
2903
|
+
if (hasOwnProperty(runtimeContext, "event")) {
|
|
2904
|
+
globalVariables.EVENT = runtimeContext.event;
|
|
2905
|
+
} else {
|
|
2906
|
+
// Let's see if pre-evaluation is required (store the `data` in context).
|
|
2907
|
+
missingEvent = true;
|
|
2770
2908
|
}
|
|
2771
|
-
quasis[position].push(...patchValue);
|
|
2772
2909
|
}
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
context
|
|
2780
|
-
} = _ref2;
|
|
2781
|
-
var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
2782
|
-
return proxies.reduce((acc, proxy) => {
|
|
2783
|
-
switch (proxy.mergeMethod) {
|
|
2784
|
-
case "extend":
|
|
2785
|
-
return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
|
|
2786
|
-
// istanbul ignore next: should never reach
|
|
2787
|
-
default:
|
|
2788
|
-
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
2789
|
-
}
|
|
2790
|
-
}, computedBaseValue);
|
|
2791
|
-
}
|
|
2792
|
-
|
|
2793
|
-
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
2794
|
-
var computedPropsFromProxy = {};
|
|
2795
|
-
var refForProxy;
|
|
2796
|
-
var {
|
|
2797
|
-
reversedProxies,
|
|
2798
|
-
templateProperties,
|
|
2799
|
-
externalSlots,
|
|
2800
|
-
templateContextId,
|
|
2801
|
-
proxyBrick
|
|
2802
|
-
} = proxyContext;
|
|
2803
|
-
if (ref && reversedProxies) {
|
|
2804
|
-
refForProxy = {};
|
|
2805
|
-
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
2806
|
-
|
|
2807
|
-
// Reversed proxies are used for expand storyboard before rendering page.
|
|
2808
|
-
if (reversedProxies.properties.has(ref)) {
|
|
2809
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
2810
|
-
// `propValue` is computed.
|
|
2811
|
-
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
2812
|
-
if (isTransformableProperty(propRef)) {
|
|
2813
|
-
return Object.entries(preprocessTransformProperties({
|
|
2814
|
-
[propRef.$$reversedRef]: propValue
|
|
2815
|
-
}, propRef.refTransform));
|
|
2816
|
-
}
|
|
2817
|
-
if (isBasicProperty(propRef)) {
|
|
2818
|
-
return [[propRef.refProperty, propValue]];
|
|
2819
|
-
}
|
|
2820
|
-
// Ignore Variable properties.
|
|
2821
|
-
// And mergeable properties are processed later.
|
|
2822
|
-
return [];
|
|
2823
|
-
}).filter(propRef => propRef[1] !== undefined)));
|
|
2824
|
-
|
|
2825
|
-
// Brick properties can be merged multiple times.
|
|
2826
|
-
if (reversedProxies.mergeBases.has(ref)) {
|
|
2827
|
-
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
2828
|
-
var [mergeProperty, mergeBase] = _ref;
|
|
2829
|
-
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
2830
|
-
}).filter(item => item[1] !== undefined)));
|
|
2831
|
-
}
|
|
2832
|
-
}
|
|
2910
|
+
var missingTplOrState = attemptToVisitTplOrState && !hasOwnProperty(runtimeContext, "tplContextId");
|
|
2911
|
+
var missingData = attemptToVisitData && !hasOwnProperty(runtimeContext, "data");
|
|
2912
|
+
var rawWithContext = Object.keys(runtimeContext).length > 0 ? {
|
|
2913
|
+
[symbolForRaw]: raw,
|
|
2914
|
+
[symbolForContext]: runtimeContext
|
|
2915
|
+
} : raw;
|
|
2833
2916
|
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
if (reversedProxies.slots.has(ref)) {
|
|
2839
|
-
for (var item of reversedProxies.slots.get(ref)) {
|
|
2840
|
-
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
2841
|
-
if (!quasisMap.has(item.refSlot)) {
|
|
2842
|
-
var quasis = [];
|
|
2843
|
-
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
2844
|
-
var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
2845
|
-
for (var i = 0; i < size; i += 1) {
|
|
2846
|
-
quasis.push([]);
|
|
2847
|
-
}
|
|
2848
|
-
quasisMap.set(item.refSlot, quasis);
|
|
2849
|
-
}
|
|
2850
|
-
var expandableSlot = quasisMap.get(item.refSlot);
|
|
2851
|
-
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
2852
|
-
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$$ : []));
|
|
2853
|
-
}
|
|
2854
|
-
}
|
|
2855
|
-
var _loop = function (slotName, _quasis) {
|
|
2856
|
-
if (!hasOwnProperty(slots, slotName)) {
|
|
2857
|
-
slots[slotName] = {
|
|
2858
|
-
type: "bricks",
|
|
2859
|
-
bricks: []
|
|
2860
|
-
};
|
|
2861
|
-
}
|
|
2862
|
-
var slotConf = slots[slotName];
|
|
2863
|
-
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
2864
|
-
if (slotConf.bricks.length === 0) {
|
|
2865
|
-
delete slots[slotName];
|
|
2866
|
-
}
|
|
2867
|
-
};
|
|
2868
|
-
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
2869
|
-
_loop(slotName, _quasis);
|
|
2870
|
-
}
|
|
2917
|
+
// Since `EVENT`, `DATA`, `TPL` and `STATE` are provided in different context,
|
|
2918
|
+
// whenever missing one of them, memorize the current context for later consuming.
|
|
2919
|
+
if (missingEvent || missingData || missingTplOrState) {
|
|
2920
|
+
return rawWithContext;
|
|
2871
2921
|
}
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
var _excluded$8 = ["properties", "slots"];
|
|
2880
|
-
function setupUseBrickInTemplate(props, proxyContext) {
|
|
2881
|
-
function walk(props) {
|
|
2882
|
-
if (Array.isArray(props)) {
|
|
2883
|
-
return props.map(walk);
|
|
2922
|
+
if (attemptToVisitData) {
|
|
2923
|
+
globalVariables.DATA = runtimeContext.data;
|
|
2924
|
+
}
|
|
2925
|
+
if (attemptToVisitTplOrState && runtimeContext.tplContextId) {
|
|
2926
|
+
var tplContext = getCustomTemplateContext(runtimeContext.tplContextId);
|
|
2927
|
+
if (attemptToVisitTpl) {
|
|
2928
|
+
globalVariables.TPL = tplContext.getVariables();
|
|
2884
2929
|
}
|
|
2885
|
-
if (
|
|
2886
|
-
|
|
2930
|
+
if (attemptToVisitState) {
|
|
2931
|
+
globalVariables.STATE = getDynamicReadOnlyProxy({
|
|
2932
|
+
get(target, key) {
|
|
2933
|
+
return tplContext.state.getValue(key);
|
|
2934
|
+
},
|
|
2935
|
+
ownKeys() {
|
|
2936
|
+
return Array.from(tplContext.state.get().keys());
|
|
2937
|
+
}
|
|
2938
|
+
});
|
|
2887
2939
|
}
|
|
2888
|
-
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
2889
|
-
var [key, value] = _ref;
|
|
2890
|
-
return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
2891
|
-
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
2892
2940
|
}
|
|
2893
|
-
|
|
2894
|
-
var
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
type: "bricks",
|
|
2904
|
-
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
2905
|
-
}];
|
|
2906
|
-
}));
|
|
2907
|
-
return _objectSpread(_objectSpread({}, restConf), {}, {
|
|
2908
|
-
properties: walk(properties),
|
|
2909
|
-
slots
|
|
2910
|
-
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
2941
|
+
if (attemptToVisitFormState && runtimeContext.formContextId) {
|
|
2942
|
+
var formContext = getCustomFormContext(runtimeContext.formContextId);
|
|
2943
|
+
globalVariables.FORM_STATE = getDynamicReadOnlyProxy({
|
|
2944
|
+
get(target, key) {
|
|
2945
|
+
return formContext.formState.getValue(key);
|
|
2946
|
+
},
|
|
2947
|
+
ownKeys() {
|
|
2948
|
+
return Array.from(formContext.formState.get().keys());
|
|
2949
|
+
}
|
|
2950
|
+
});
|
|
2911
2951
|
}
|
|
2912
|
-
|
|
2913
|
-
}
|
|
2914
|
-
function isPlainObject(object) {
|
|
2915
|
-
return Object.prototype.toString.call(object) === "[object Object]";
|
|
2916
|
-
}
|
|
2952
|
+
var internalContext = _internalApiGetCurrentContext();
|
|
2953
|
+
var mergedContext = {};
|
|
2917
2954
|
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2955
|
+
// Use runtime context over internal context.
|
|
2956
|
+
// Internal context such as `match`, maybe change after `history.push`.
|
|
2957
|
+
// So we prefer memoized runtime context.
|
|
2958
|
+
for (var key of ["query", "match", "hash", "pathname", "app", "segues"]) {
|
|
2959
|
+
mergedContext[key] = (hasOwnProperty(runtimeContext, key) ? runtimeContext : internalContext)[key];
|
|
2960
|
+
}
|
|
2961
|
+
var {
|
|
2962
|
+
app: currentApp,
|
|
2963
|
+
query,
|
|
2964
|
+
match,
|
|
2965
|
+
hash,
|
|
2966
|
+
pathname,
|
|
2967
|
+
segues
|
|
2968
|
+
} = mergedContext;
|
|
2969
|
+
var {
|
|
2970
|
+
sys,
|
|
2971
|
+
flags,
|
|
2972
|
+
storyboardContext
|
|
2973
|
+
} = internalContext;
|
|
2974
|
+
var app = (_runtimeContext$overr = runtimeContext.overrideApp) !== null && _runtimeContext$overr !== void 0 ? _runtimeContext$overr : currentApp;
|
|
2975
|
+
function getIndividualGlobal(variableName) {
|
|
2976
|
+
switch (variableName) {
|
|
2977
|
+
case "ALIAS":
|
|
2978
|
+
return {
|
|
2979
|
+
getUrl: getUrlByAliasFactory(app)
|
|
2980
|
+
};
|
|
2981
|
+
case "ANCHOR":
|
|
2982
|
+
return hash ? hash.substr(1) : null;
|
|
2983
|
+
case "APP":
|
|
2984
|
+
return _objectSpread(_objectSpread({}, cloneDeep(app)), {}, {
|
|
2985
|
+
getMenu
|
|
2986
|
+
});
|
|
2987
|
+
case "CTX":
|
|
2988
|
+
return getDynamicReadOnlyProxy({
|
|
2989
|
+
get(target, key) {
|
|
2990
|
+
var _item$brick$element;
|
|
2991
|
+
var item = storyboardContext.get(key);
|
|
2992
|
+
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;
|
|
2993
|
+
},
|
|
2994
|
+
ownKeys() {
|
|
2995
|
+
return Array.from(storyboardContext.keys());
|
|
2933
2996
|
}
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2997
|
+
});
|
|
2998
|
+
case "FLAGS":
|
|
2999
|
+
return getReadOnlyProxy(flags);
|
|
3000
|
+
case "HASH":
|
|
3001
|
+
return hash;
|
|
3002
|
+
case "PATH_NAME":
|
|
3003
|
+
return pathname;
|
|
3004
|
+
case "INSTALLED_APPS":
|
|
3005
|
+
return {
|
|
3006
|
+
has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
|
|
3007
|
+
};
|
|
3008
|
+
case "LOCAL_STORAGE":
|
|
3009
|
+
return {
|
|
3010
|
+
getItem: getItemFactory("local")
|
|
3011
|
+
};
|
|
3012
|
+
case "MISC":
|
|
3013
|
+
return getRuntime().getMiscSettings();
|
|
3014
|
+
case "PARAMS":
|
|
3015
|
+
return new URLSearchParams(query);
|
|
3016
|
+
case "PATH":
|
|
3017
|
+
return getReadOnlyProxy(match.params);
|
|
3018
|
+
case "PROCESSORS":
|
|
3019
|
+
return getDynamicReadOnlyProxy({
|
|
3020
|
+
get(target, key) {
|
|
3021
|
+
var pkg = customProcessorRegistry.get(key);
|
|
3022
|
+
if (!pkg) {
|
|
3023
|
+
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'?"));
|
|
3024
|
+
}
|
|
3025
|
+
return getDynamicReadOnlyProxy({
|
|
3026
|
+
get(t, k) {
|
|
3027
|
+
return pkg.get(k);
|
|
3028
|
+
},
|
|
3029
|
+
ownKeys() {
|
|
3030
|
+
return Array.from(pkg.keys());
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
},
|
|
3034
|
+
ownKeys() {
|
|
3035
|
+
return Array.from(customProcessorRegistry.keys());
|
|
2939
3036
|
}
|
|
2940
|
-
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
3037
|
+
});
|
|
3038
|
+
case "QUERY":
|
|
3039
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
|
|
3040
|
+
case "QUERY_ARRAY":
|
|
3041
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
|
|
3042
|
+
case "SEGUE":
|
|
3043
|
+
return {
|
|
3044
|
+
getUrl: getUrlBySegueFactory(app, segues)
|
|
3045
|
+
};
|
|
3046
|
+
case "SESSION_STORAGE":
|
|
3047
|
+
return {
|
|
3048
|
+
getItem: getItemFactory("session")
|
|
3049
|
+
};
|
|
3050
|
+
case "SYS":
|
|
3051
|
+
return getReadOnlyProxy(sys);
|
|
3052
|
+
case "MEDIA":
|
|
3053
|
+
return getReadOnlyProxy(getMedia());
|
|
3054
|
+
case "__WIDGET_FN__":
|
|
3055
|
+
return widgetFunctions;
|
|
3056
|
+
case "__WIDGET_IMG__":
|
|
3057
|
+
return widgetImagesFactory;
|
|
3058
|
+
case "__WIDGET_I18N__":
|
|
3059
|
+
return widgetI18nFactory;
|
|
2952
3060
|
}
|
|
2953
|
-
return result;
|
|
2954
3061
|
}
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
return value.map(v => computeRealValue(v, context, injectDeep, nextOptions));
|
|
3062
|
+
for (var variableName of attemptToVisitGlobals) {
|
|
3063
|
+
var variable = getIndividualGlobal(variableName);
|
|
3064
|
+
if (variable !== undefined) {
|
|
3065
|
+
globalVariables[variableName] = variable;
|
|
3066
|
+
}
|
|
2961
3067
|
}
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
};
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
realProps = setupUseBrickInTemplate(realProps, {
|
|
2971
|
-
templateContextId: context.tplContextId
|
|
3068
|
+
Object.assign(globalVariables, getGeneralGlobals(precooked.attemptToVisitGlobals, {
|
|
3069
|
+
storyboardFunctions,
|
|
3070
|
+
app,
|
|
3071
|
+
appendI18nNamespace: runtimeContext.appendI18nNamespace
|
|
3072
|
+
}));
|
|
3073
|
+
try {
|
|
3074
|
+
var result = cook(precooked.expression, precooked.source, {
|
|
3075
|
+
globalVariables: supply(precooked.attemptToVisitGlobals, globalVariables)
|
|
2972
3076
|
});
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
brick[propName][k] = v;
|
|
2986
|
-
}
|
|
2987
|
-
} else if (propName === "innerHTML") {
|
|
2988
|
-
// `innerHTML` is dangerous, use `textContent` instead.
|
|
2989
|
-
// eslint-disable-next-line no-console
|
|
2990
|
-
console.error("Please use `textContent` instead of `innerHTML`.");
|
|
2991
|
-
brick.textContent = propValue;
|
|
2992
|
-
} else {
|
|
2993
|
-
if (extractProps) {
|
|
2994
|
-
set(brick, propName, propValue);
|
|
2995
|
-
} else {
|
|
2996
|
-
brick[propName] = propValue;
|
|
2997
|
-
}
|
|
3077
|
+
var detail = {
|
|
3078
|
+
raw,
|
|
3079
|
+
context: globalVariables,
|
|
3080
|
+
result
|
|
3081
|
+
};
|
|
3082
|
+
if (options.isReEvaluation) {
|
|
3083
|
+
devtoolsHookEmit("re-evaluation", {
|
|
3084
|
+
id: options.evaluationId,
|
|
3085
|
+
detail
|
|
3086
|
+
});
|
|
3087
|
+
} else {
|
|
3088
|
+
devtoolsHookEmit("evaluation", detail);
|
|
2998
3089
|
}
|
|
2999
|
-
|
|
3000
|
-
}
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3090
|
+
return result;
|
|
3091
|
+
} catch (error) {
|
|
3092
|
+
var _message = "".concat(error.message, ", in \"").concat(raw, "\"");
|
|
3093
|
+
if (options.isReEvaluation) {
|
|
3094
|
+
devtoolsHookEmit("re-evaluation", {
|
|
3095
|
+
id: options.evaluationId,
|
|
3096
|
+
detail: {
|
|
3097
|
+
raw,
|
|
3098
|
+
context: globalVariables
|
|
3099
|
+
},
|
|
3100
|
+
error: _message
|
|
3009
3101
|
});
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
result[propName] = realValue;
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
if (Array.isArray(trackingContextList)) {
|
|
3017
|
-
var {
|
|
3018
|
-
contextNames,
|
|
3019
|
-
stateNames,
|
|
3020
|
-
formStateNames
|
|
3021
|
-
} = getTracks(propValue);
|
|
3022
|
-
if (contextNames || stateNames || formStateNames) {
|
|
3023
|
-
trackingContextList.push({
|
|
3024
|
-
contextNames,
|
|
3025
|
-
stateNames,
|
|
3026
|
-
formStateNames,
|
|
3027
|
-
propName,
|
|
3028
|
-
propValue
|
|
3029
|
-
});
|
|
3030
|
-
}
|
|
3031
|
-
}
|
|
3102
|
+
} else {
|
|
3103
|
+
var _errorConstructor = getCookErrorConstructor(error);
|
|
3104
|
+
throw new _errorConstructor(_message);
|
|
3032
3105
|
}
|
|
3033
3106
|
}
|
|
3034
|
-
return result;
|
|
3035
|
-
}
|
|
3036
|
-
function getNextInternalOptions(internalOptions, isArray, key) {
|
|
3037
|
-
return internalOptions !== null && internalOptions !== void 0 && internalOptions.$$lazyForUseBrick ? _objectSpread(_objectSpread({}, internalOptions), {}, {
|
|
3038
|
-
$$stateOfUseBrick: getNextStateOfUseBrick(internalOptions.$$stateOfUseBrick, isArray, key)
|
|
3039
|
-
}) : internalOptions;
|
|
3040
3107
|
}
|
|
3041
3108
|
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
_excluded3 = ["items", "app"];
|
|
3045
|
-
var symbolAppId = Symbol("appId");
|
|
3046
|
-
var symbolMenuI18nNamespace = Symbol("menuI18nNamespace");
|
|
3047
|
-
var symbolOverrideApp = Symbol("overrideApp");
|
|
3048
|
-
var symbolShouldCache = Symbol("shouldCache");
|
|
3049
|
-
// Caching menu requests to avoid flicker.
|
|
3050
|
-
var menuCache = new Map();
|
|
3051
|
-
var menuTitleCache = new Map();
|
|
3052
|
-
var processMenuCache = new Map();
|
|
3053
|
-
function constructMenu(_x, _x2, _x3) {
|
|
3054
|
-
return _constructMenu.apply(this, arguments);
|
|
3109
|
+
function isBasicProperty(propRef) {
|
|
3110
|
+
return !!propRef.refProperty;
|
|
3055
3111
|
}
|
|
3056
|
-
function
|
|
3057
|
-
|
|
3058
|
-
var hasSubMenu = !!menuBar.subMenuId;
|
|
3059
|
-
yield Promise.all([_asyncToGenerator$3(function* () {
|
|
3060
|
-
if (menuBar.menuId) {
|
|
3061
|
-
var _menuBar$menu;
|
|
3062
|
-
var defaultCollapsed = (_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed;
|
|
3063
|
-
var menu = yield processMenu(menuBar.menuId, context, kernel, hasSubMenu);
|
|
3064
|
-
if (!isNil(defaultCollapsed)) {
|
|
3065
|
-
menu.defaultCollapsed = defaultCollapsed;
|
|
3066
|
-
}
|
|
3067
|
-
menuBar.menu = menu;
|
|
3068
|
-
}
|
|
3069
|
-
})(), _asyncToGenerator$3(function* () {
|
|
3070
|
-
if (hasSubMenu) {
|
|
3071
|
-
menuBar.subMenu = yield processMenu(menuBar.subMenuId, context, kernel);
|
|
3072
|
-
} else {
|
|
3073
|
-
menuBar.subMenu = null;
|
|
3074
|
-
}
|
|
3075
|
-
})()]);
|
|
3076
|
-
});
|
|
3077
|
-
return _constructMenu.apply(this, arguments);
|
|
3112
|
+
function isTransformableProperty(propRef) {
|
|
3113
|
+
return !!propRef.refTransform;
|
|
3078
3114
|
}
|
|
3079
|
-
function
|
|
3080
|
-
return
|
|
3115
|
+
function isMergeableProperty(propRef) {
|
|
3116
|
+
return !!propRef.mergeProperty;
|
|
3081
3117
|
}
|
|
3082
|
-
function
|
|
3083
|
-
|
|
3084
|
-
var data = yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel, undefined, true)));
|
|
3085
|
-
data.forEach((item, index) => processMenuCache.set(menus[index], item));
|
|
3086
|
-
});
|
|
3087
|
-
return _preConstructMenus.apply(this, arguments);
|
|
3118
|
+
function isRefProperty(propRef) {
|
|
3119
|
+
return !!propRef.ref;
|
|
3088
3120
|
}
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
return _fetchMenuById.apply(this, arguments);
|
|
3121
|
+
function isVariableProperty(propRef) {
|
|
3122
|
+
return !!propRef.asVariable;
|
|
3092
3123
|
}
|
|
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
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3124
|
+
|
|
3125
|
+
var customTemplateRegistry = new Map();
|
|
3126
|
+
var appRegistered = new Set();
|
|
3127
|
+
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
3128
|
+
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
3129
|
+
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
3130
|
+
|
|
3131
|
+
function propertyMerge(conf, value, object) {
|
|
3132
|
+
return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
|
|
3133
|
+
}
|
|
3134
|
+
function propertyMergeAll(mergeBase, object) {
|
|
3135
|
+
if (mergeBase.mergeType === "array") {
|
|
3136
|
+
return propertyMergeAllOfArray(mergeBase, object);
|
|
3137
|
+
}
|
|
3138
|
+
if (mergeBase.mergeType === "object") {
|
|
3139
|
+
return propertyMergeAllOfObject(mergeBase, object);
|
|
3140
|
+
}
|
|
3141
|
+
// istanbul ignore next: should never reach
|
|
3142
|
+
throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
|
|
3143
|
+
}
|
|
3144
|
+
function propertyMergeAllOfArray(_ref, object) {
|
|
3145
|
+
var _, _proxy$mergeArgs;
|
|
3146
|
+
var {
|
|
3147
|
+
baseValue,
|
|
3148
|
+
context,
|
|
3149
|
+
proxies
|
|
3150
|
+
} = _ref;
|
|
3151
|
+
// Use an approach like template-literal's quasis:
|
|
3152
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
3153
|
+
// Every quasi can be merged with multiple items.
|
|
3154
|
+
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
3155
|
+
$$lazyForUseBrick: true
|
|
3156
|
+
}) : [];
|
|
3157
|
+
var quasis = [];
|
|
3158
|
+
var size = computedBaseValue.length + 1;
|
|
3159
|
+
for (var i = 0; i < size; i += 1) {
|
|
3160
|
+
quasis.push([]);
|
|
3161
|
+
}
|
|
3162
|
+
for (var proxy of proxies) {
|
|
3163
|
+
var position = void 0;
|
|
3164
|
+
switch (proxy.mergeMethod) {
|
|
3165
|
+
case "append":
|
|
3166
|
+
position = computedBaseValue.length;
|
|
3167
|
+
break;
|
|
3168
|
+
case "prepend":
|
|
3169
|
+
position = 0;
|
|
3170
|
+
break;
|
|
3171
|
+
case "insertAt":
|
|
3172
|
+
// Defaults to `-1`.
|
|
3173
|
+
position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
|
|
3174
|
+
if (position < 0) {
|
|
3175
|
+
// It's counted from the end if position is negative.
|
|
3176
|
+
position += quasis.length;
|
|
3128
3177
|
}
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3178
|
+
position = clamp(position, 0, computedBaseValue.length);
|
|
3179
|
+
break;
|
|
3180
|
+
// istanbul ignore next: should never reach
|
|
3181
|
+
default:
|
|
3182
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
3134
3183
|
}
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
}
|
|
3141
|
-
|
|
3142
|
-
return _mergeMenu.apply(this, arguments);
|
|
3184
|
+
var patchValue = object[proxy.$$reversedRef];
|
|
3185
|
+
if (!Array.isArray(patchValue)) {
|
|
3186
|
+
patchValue = [];
|
|
3187
|
+
}
|
|
3188
|
+
quasis[position].push(...patchValue);
|
|
3189
|
+
}
|
|
3190
|
+
return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
|
|
3143
3191
|
}
|
|
3144
|
-
function
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3192
|
+
function propertyMergeAllOfObject(_ref2, object) {
|
|
3193
|
+
var {
|
|
3194
|
+
baseValue,
|
|
3195
|
+
proxies,
|
|
3196
|
+
context
|
|
3197
|
+
} = _ref2;
|
|
3198
|
+
var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
|
|
3199
|
+
return proxies.reduce((acc, proxy) => {
|
|
3200
|
+
switch (proxy.mergeMethod) {
|
|
3201
|
+
case "extend":
|
|
3202
|
+
return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
|
|
3203
|
+
// istanbul ignore next: should never reach
|
|
3204
|
+
default:
|
|
3205
|
+
throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
|
|
3149
3206
|
}
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3207
|
+
}, computedBaseValue);
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
function setupTemplateProxy(proxyContext, ref, slots) {
|
|
3211
|
+
var computedPropsFromProxy = {};
|
|
3212
|
+
var refForProxy;
|
|
3213
|
+
var {
|
|
3214
|
+
reversedProxies,
|
|
3215
|
+
templateProperties,
|
|
3216
|
+
externalSlots,
|
|
3217
|
+
templateContextId,
|
|
3218
|
+
proxyBrick
|
|
3219
|
+
} = proxyContext;
|
|
3220
|
+
if (ref && reversedProxies) {
|
|
3221
|
+
refForProxy = {};
|
|
3222
|
+
proxyBrick.proxyRefs.set(ref, refForProxy);
|
|
3223
|
+
|
|
3224
|
+
// Reversed proxies are used for expand storyboard before rendering page.
|
|
3225
|
+
if (reversedProxies.properties.has(ref)) {
|
|
3226
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
|
|
3227
|
+
// `propValue` is computed.
|
|
3228
|
+
var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
|
|
3229
|
+
if (isTransformableProperty(propRef)) {
|
|
3230
|
+
return Object.entries(preprocessTransformProperties({
|
|
3231
|
+
[propRef.$$reversedRef]: propValue
|
|
3232
|
+
}, propRef.refTransform));
|
|
3233
|
+
}
|
|
3234
|
+
if (isBasicProperty(propRef)) {
|
|
3235
|
+
return [[propRef.refProperty, propValue]];
|
|
3236
|
+
}
|
|
3237
|
+
// Ignore Variable properties.
|
|
3238
|
+
// And mergeable properties are processed later.
|
|
3239
|
+
return [];
|
|
3240
|
+
}).filter(propRef => propRef[1] !== undefined)));
|
|
3241
|
+
|
|
3242
|
+
// Brick properties can be merged multiple times.
|
|
3243
|
+
if (reversedProxies.mergeBases.has(ref)) {
|
|
3244
|
+
Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
|
|
3245
|
+
var [mergeProperty, mergeBase] = _ref;
|
|
3246
|
+
return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
|
|
3247
|
+
}).filter(item => item[1] !== undefined)));
|
|
3164
3248
|
}
|
|
3165
3249
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3250
|
+
|
|
3251
|
+
// Use an approach like template-literal's quasis:
|
|
3252
|
+
// `quasi0${0}quais1${1}quasi2...`
|
|
3253
|
+
// Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
|
|
3254
|
+
var quasisMap = new Map();
|
|
3255
|
+
if (reversedProxies.slots.has(ref)) {
|
|
3256
|
+
for (var item of reversedProxies.slots.get(ref)) {
|
|
3257
|
+
var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
|
|
3258
|
+
if (!quasisMap.has(item.refSlot)) {
|
|
3259
|
+
var quasis = [];
|
|
3260
|
+
// The size of quasis should be the existed slotted bricks' size plus one.
|
|
3261
|
+
var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
|
|
3262
|
+
for (var i = 0; i < size; i += 1) {
|
|
3263
|
+
quasis.push([]);
|
|
3175
3264
|
}
|
|
3176
|
-
|
|
3177
|
-
} else {
|
|
3178
|
-
validMenuList.push(_menu);
|
|
3265
|
+
quasisMap.set(item.refSlot, quasis);
|
|
3179
3266
|
}
|
|
3267
|
+
var expandableSlot = quasisMap.get(item.refSlot);
|
|
3268
|
+
var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
|
|
3269
|
+
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$$ : []));
|
|
3180
3270
|
}
|
|
3181
3271
|
}
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
});
|
|
3189
|
-
return _mergeMenu.apply(this, arguments);
|
|
3190
|
-
}
|
|
3191
|
-
function processGroupInject(items, menu, injectWithMenus, menuWithI18n) {
|
|
3192
|
-
return items === null || items === void 0 ? void 0 : items.map(item => {
|
|
3193
|
-
var _processGroupInject;
|
|
3194
|
-
var foundInjectingMenus = item.groupId && injectWithMenus.get(item.groupId);
|
|
3195
|
-
if (foundInjectingMenus) {
|
|
3196
|
-
// Each menu to be injected with should be injected only once.
|
|
3197
|
-
injectWithMenus.delete(item.groupId);
|
|
3198
|
-
}
|
|
3199
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3200
|
-
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)) : []),
|
|
3201
|
-
[symbolAppId]: menu.app[0].appId,
|
|
3202
|
-
[symbolMenuI18nNamespace]: menuWithI18n.get(menu),
|
|
3203
|
-
[symbolOverrideApp]: menu.overrideApp
|
|
3204
|
-
});
|
|
3205
|
-
});
|
|
3206
|
-
}
|
|
3207
|
-
function loadDynamicMenuItems(_x12, _x13, _x14) {
|
|
3208
|
-
return _loadDynamicMenuItems.apply(this, arguments);
|
|
3209
|
-
}
|
|
3210
|
-
function _loadDynamicMenuItems() {
|
|
3211
|
-
_loadDynamicMenuItems = _asyncToGenerator$3(function* (menu, kernel, menuWithI18n) {
|
|
3212
|
-
if (menu.dynamicItems && menu.itemsResolve) {
|
|
3213
|
-
var _menu$itemsResolve;
|
|
3214
|
-
var itemsConf = {};
|
|
3215
|
-
var overrideAppId = menu.app[0].appId;
|
|
3216
|
-
var context = _internalApiGetCurrentContext();
|
|
3217
|
-
var newContext = context;
|
|
3218
|
-
if (overrideAppId !== context.app.id && attemptToVisit(menu.itemsResolve, ["APP", "I18N"])) {
|
|
3219
|
-
if (window.STANDALONE_MICRO_APPS) {
|
|
3220
|
-
if (menu.overrideApp) {
|
|
3221
|
-
menu.overrideApp.config = deepFreeze(merge({}, menu.overrideApp.defaultConfig, menu.overrideApp.userConfig));
|
|
3222
|
-
}
|
|
3223
|
-
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3224
|
-
overrideApp: menu.overrideApp,
|
|
3225
|
-
appendI18nNamespace: menuWithI18n.get(menu)
|
|
3226
|
-
});
|
|
3227
|
-
} else {
|
|
3228
|
-
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
3229
|
-
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3230
|
-
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
3231
|
-
appendI18nNamespace: menuWithI18n.get(menu)
|
|
3232
|
-
});
|
|
3233
|
-
}
|
|
3272
|
+
var _loop = function (slotName, _quasis) {
|
|
3273
|
+
if (!hasOwnProperty(slots, slotName)) {
|
|
3274
|
+
slots[slotName] = {
|
|
3275
|
+
type: "bricks",
|
|
3276
|
+
bricks: []
|
|
3277
|
+
};
|
|
3234
3278
|
}
|
|
3235
|
-
var
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
transformMapArray: false
|
|
3240
|
-
}, menu.itemsResolve), itemsConf, null, newContext);
|
|
3241
|
-
menu.items = itemsConf.items;
|
|
3242
|
-
if ((_menu$itemsResolve = menu.itemsResolve) !== null && _menu$itemsResolve !== void 0 && _menu$itemsResolve.args) {
|
|
3243
|
-
var _menu$itemsResolve2;
|
|
3244
|
-
return !attemptToVisit((_menu$itemsResolve2 = menu.itemsResolve) === null || _menu$itemsResolve2 === void 0 ? void 0 : _menu$itemsResolve2.args, ["QUERY", "PATH"]);
|
|
3279
|
+
var slotConf = slots[slotName];
|
|
3280
|
+
slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
|
|
3281
|
+
if (slotConf.bricks.length === 0) {
|
|
3282
|
+
delete slots[slotName];
|
|
3245
3283
|
}
|
|
3284
|
+
};
|
|
3285
|
+
for (var [slotName, _quasis] of quasisMap.entries()) {
|
|
3286
|
+
_loop(slotName, _quasis);
|
|
3246
3287
|
}
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
// `if` is already evaluated.
|
|
3254
|
-
looseCheckIfOfComputed).map(item => {
|
|
3255
|
-
var children = walkMenuItems(item.children || item.items);
|
|
3256
|
-
return item.type === "group" ? {
|
|
3257
|
-
type: "group",
|
|
3258
|
-
childLayout: item.childLayout,
|
|
3259
|
-
title: item.text || item.title,
|
|
3260
|
-
items: children,
|
|
3261
|
-
groupId: item.groupId,
|
|
3262
|
-
groupFrom: item.groupFrom
|
|
3263
|
-
} : children !== null && children !== void 0 && children.length ? {
|
|
3264
|
-
type: "subMenu",
|
|
3265
|
-
childLayout: item.childLayout,
|
|
3266
|
-
title: item.text || item.title,
|
|
3267
|
-
icon: item.icon,
|
|
3268
|
-
items: children,
|
|
3269
|
-
defaultExpanded: item.defaultExpanded
|
|
3270
|
-
} : item;
|
|
3271
|
-
});
|
|
3272
|
-
}
|
|
3273
|
-
function processMenu(_x15, _x16, _x17, _x18, _x19) {
|
|
3274
|
-
return _processMenu.apply(this, arguments);
|
|
3288
|
+
}
|
|
3289
|
+
return {
|
|
3290
|
+
[symbolForComputedPropsFromProxy]: computedPropsFromProxy,
|
|
3291
|
+
[symbolForRefForProxy]: refForProxy,
|
|
3292
|
+
[symbolForTplContextId]: templateContextId
|
|
3293
|
+
};
|
|
3275
3294
|
}
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
} = _yield$fetchMenuById,
|
|
3283
|
-
restMenuData = _objectWithoutProperties(_yield$fetchMenuById, _excluded3);
|
|
3284
|
-
var usedActions = scanPermissionActionsInAny([items, restMenuData]);
|
|
3285
|
-
yield validatePermissions(usedActions);
|
|
3286
|
-
var appsRequireI18nFulfilled = new Set();
|
|
3287
|
-
var rootAppId = app[0].appId;
|
|
3288
|
-
if (rootAppId !== context.app.id && !restMenuData[symbolMenuI18nNamespace]) {
|
|
3289
|
-
appsRequireI18nFulfilled.add(rootAppId);
|
|
3295
|
+
|
|
3296
|
+
var _excluded$7 = ["properties", "slots"];
|
|
3297
|
+
function setupUseBrickInTemplate(props, proxyContext) {
|
|
3298
|
+
function walk(props) {
|
|
3299
|
+
if (Array.isArray(props)) {
|
|
3300
|
+
return props.map(walk);
|
|
3290
3301
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
var menuData = _objectSpread(_objectSpread({}, yield computeRealValueWithOverrideApp(restMenuData, rootAppId, context, kernel)), {}, {
|
|
3294
|
-
items: yield computeMenuItemsWithOverrideApp(items, context, kernel)
|
|
3295
|
-
});
|
|
3296
|
-
return {
|
|
3297
|
-
title: yield processMenuTitle(menuData),
|
|
3298
|
-
icon: menuData.icon,
|
|
3299
|
-
link: menuData.link,
|
|
3300
|
-
menuItems: walkMenuItems(menuData.items),
|
|
3301
|
-
defaultCollapsed: menuData.defaultCollapsed || hasSubMenu,
|
|
3302
|
-
defaultCollapsedBreakpoint: menuData.defaultCollapsedBreakpoint
|
|
3303
|
-
};
|
|
3304
|
-
});
|
|
3305
|
-
return _processMenu.apply(this, arguments);
|
|
3306
|
-
}
|
|
3307
|
-
function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
|
|
3308
|
-
function collect(items) {
|
|
3309
|
-
for (var _ref of items) {
|
|
3310
|
-
var {
|
|
3311
|
-
children
|
|
3312
|
-
} = _ref,
|
|
3313
|
-
rest = _objectWithoutProperties(_ref, _excluded$7);
|
|
3314
|
-
var overrideAppId = rest[symbolAppId];
|
|
3315
|
-
if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
|
|
3316
|
-
appIds.add(overrideAppId);
|
|
3317
|
-
}
|
|
3318
|
-
children && collect(children);
|
|
3302
|
+
if (!isObject(props) || !isPlainObject(props)) {
|
|
3303
|
+
return props;
|
|
3319
3304
|
}
|
|
3305
|
+
return Object.fromEntries(Object.entries(props).map(_ref => {
|
|
3306
|
+
var [key, value] = _ref;
|
|
3307
|
+
return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
|
|
3308
|
+
}).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
|
|
3320
3309
|
}
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
return
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3310
|
+
function setup(item) {
|
|
3311
|
+
var {
|
|
3312
|
+
properties,
|
|
3313
|
+
slots: originalSlots
|
|
3314
|
+
} = item,
|
|
3315
|
+
restConf = _objectWithoutProperties(item, _excluded$7);
|
|
3316
|
+
var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
|
|
3317
|
+
var _slotConf$bricks;
|
|
3318
|
+
var [slotName, slotConf] = _ref2;
|
|
3319
|
+
return [slotName, {
|
|
3320
|
+
type: "bricks",
|
|
3321
|
+
bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
|
|
3322
|
+
}];
|
|
3323
|
+
}));
|
|
3324
|
+
return _objectSpread(_objectSpread({}, restConf), {}, {
|
|
3325
|
+
properties: walk(properties),
|
|
3326
|
+
slots
|
|
3327
|
+
}, setupTemplateProxy(proxyContext, restConf.ref, slots));
|
|
3328
|
+
}
|
|
3329
|
+
return walk(props);
|
|
3338
3330
|
}
|
|
3339
|
-
function
|
|
3340
|
-
return
|
|
3331
|
+
function isPlainObject(object) {
|
|
3332
|
+
return Object.prototype.toString.call(object) === "[object Object]";
|
|
3341
3333
|
}
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3334
|
+
|
|
3335
|
+
var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
3336
|
+
var preEvaluated = isPreEvaluated(value);
|
|
3337
|
+
if (preEvaluated || typeof value === "string") {
|
|
3338
|
+
// For `useBrick`, some fields such as `properties`/`transform`/`events`/`if`,
|
|
3339
|
+
// are kept and to be evaluated later.
|
|
3340
|
+
var lazy = (internalOptions === null || internalOptions === void 0 ? void 0 : internalOptions.$$lazyForUseBrick) && isLazyContentInUseBrick(internalOptions.$$stateOfUseBrick);
|
|
3341
|
+
var result;
|
|
3342
|
+
var dismissRecursiveMarkingInjected = lazy;
|
|
3343
|
+
if (preEvaluated || isEvaluable(value)) {
|
|
3344
|
+
var runtimeContext = {};
|
|
3345
|
+
if (context) {
|
|
3346
|
+
var keys = ["event", "tplContextId", "overrideApp", "appendI18nNamespace", "formContextId", "query", "match", "app", "segues"];
|
|
3347
|
+
for (var key of keys) {
|
|
3348
|
+
if (context[key]) {
|
|
3349
|
+
runtimeContext[key] = context[key];
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
var simpleKeys = ["hash", "pathname"];
|
|
3353
|
+
for (var _key of simpleKeys) {
|
|
3354
|
+
if (hasOwnProperty(context, _key)) {
|
|
3355
|
+
runtimeContext[_key] = context[_key];
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
// The current runtime context is memoized even if the evaluation maybe lazy.
|
|
3360
|
+
result = evaluate(value, runtimeContext, {
|
|
3361
|
+
lazy
|
|
3362
|
+
});
|
|
3363
|
+
dismissRecursiveMarkingInjected = shouldDismissRecursiveMarkingInjected(value);
|
|
3364
|
+
} else {
|
|
3365
|
+
result = lazy ? value : inject(value, context);
|
|
3346
3366
|
}
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
return menuTitleCache.get(cacheKey);
|
|
3367
|
+
if (!dismissRecursiveMarkingInjected) {
|
|
3368
|
+
recursiveMarkAsInjected(result);
|
|
3350
3369
|
}
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
var
|
|
3358
|
-
|
|
3370
|
+
return result;
|
|
3371
|
+
}
|
|
3372
|
+
if (!(injectDeep && isObject(value)) || haveBeenInjected(value)) {
|
|
3373
|
+
return value;
|
|
3374
|
+
}
|
|
3375
|
+
if (Array.isArray(value)) {
|
|
3376
|
+
var nextOptions = getNextInternalOptions(internalOptions, true);
|
|
3377
|
+
return value.map(v => computeRealValue(v, context, injectDeep, nextOptions));
|
|
3378
|
+
}
|
|
3379
|
+
return Object.fromEntries(Object.entries(value).map(_ref => {
|
|
3380
|
+
var [k, v] = _ref;
|
|
3381
|
+
return [computeRealValue(k, context, false), computeRealValue(v, context, injectDeep, getNextInternalOptions(internalOptions, false, k))];
|
|
3382
|
+
}).concat(internalOptions !== null && internalOptions !== void 0 && internalOptions.ignoreSymbols ? [] : Object.getOwnPropertySymbols(value).map(k => [k, value[k]])));
|
|
3383
|
+
};
|
|
3384
|
+
function setProperties(bricks, properties, context, injectDeep) {
|
|
3385
|
+
var realProps = computeRealProperties(properties, context, injectDeep);
|
|
3386
|
+
if (context.tplContextId) {
|
|
3387
|
+
realProps = setupUseBrickInTemplate(realProps, {
|
|
3388
|
+
templateContextId: context.tplContextId
|
|
3359
3389
|
});
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
}
|
|
3367
|
-
menuTitleCache.set(cacheKey, title);
|
|
3368
|
-
return title;
|
|
3369
|
-
});
|
|
3370
|
-
return _processMenuTitle.apply(this, arguments);
|
|
3371
|
-
}
|
|
3372
|
-
function clearMenuTitleCache() {
|
|
3373
|
-
menuTitleCache.clear();
|
|
3374
|
-
}
|
|
3375
|
-
function clearMenuCache() {
|
|
3376
|
-
menuCache.clear();
|
|
3377
|
-
}
|
|
3378
|
-
function reorderMenu(menuData) {
|
|
3379
|
-
menuData.items = reorderMenuItems(menuData.items);
|
|
3380
|
-
}
|
|
3381
|
-
function reorderMenuItems(list) {
|
|
3382
|
-
return sortMenuItems(list).map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
3383
|
-
children: reorderMenuItems(item.children)
|
|
3384
|
-
}));
|
|
3385
|
-
}
|
|
3386
|
-
function sortMenuItems(list) {
|
|
3387
|
-
return sortBy(list, item => {
|
|
3388
|
-
var _item$sort;
|
|
3389
|
-
return (_item$sort = item.sort) !== null && _item$sort !== void 0 ? _item$sort : -Infinity;
|
|
3390
|
+
}
|
|
3391
|
+
if (!Array.isArray(bricks)) {
|
|
3392
|
+
bricks = [bricks];
|
|
3393
|
+
}
|
|
3394
|
+
bricks.forEach(brick => {
|
|
3395
|
+
setRealProperties(brick, realProps);
|
|
3390
3396
|
});
|
|
3391
3397
|
}
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3398
|
+
function setRealProperties(brick, realProps, extractProps) {
|
|
3399
|
+
for (var [propName, propValue] of Object.entries(realProps)) {
|
|
3400
|
+
if (propName === "style" || propName === "dataset") {
|
|
3401
|
+
for (var [k, v] of Object.entries(propValue)) {
|
|
3402
|
+
brick[propName][k] = v;
|
|
3403
|
+
}
|
|
3404
|
+
} else if (propName === "innerHTML") {
|
|
3405
|
+
// `innerHTML` is dangerous, use `textContent` instead.
|
|
3406
|
+
// eslint-disable-next-line no-console
|
|
3407
|
+
console.error("Please use `textContent` instead of `innerHTML`.");
|
|
3408
|
+
brick.textContent = propValue;
|
|
3409
|
+
} else {
|
|
3410
|
+
if (extractProps) {
|
|
3411
|
+
set(brick, propName, propValue);
|
|
3412
|
+
} else {
|
|
3413
|
+
brick[propName] = propValue;
|
|
3406
3414
|
}
|
|
3407
|
-
} else if (globals.includes("APP")) {
|
|
3408
|
-
return /\${\s*APP\s*\./.test(data);
|
|
3409
|
-
}
|
|
3410
|
-
} else if (isObject(data)) {
|
|
3411
|
-
// Avoid call stack overflow.
|
|
3412
|
-
// istanbul ignore next
|
|
3413
|
-
if (memo.has(data)) {
|
|
3414
|
-
return false;
|
|
3415
3415
|
}
|
|
3416
|
-
memo.add(data);
|
|
3417
|
-
return (Array.isArray(data) ? data : Object.values(data)).some(item => attemptToVisit(item, globals, memo));
|
|
3418
3416
|
}
|
|
3419
|
-
return false;
|
|
3420
3417
|
}
|
|
3421
|
-
function
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
if ("to" in data && data.to && !isEvaluable(data.to)) {
|
|
3436
|
-
var yaml = pipes.yaml(data.to);
|
|
3437
|
-
if (isObject(yaml) && ["pathname", "search", "hash"].some(key => hasOwnProperty(yaml, key))) {
|
|
3438
|
-
data.to = yaml;
|
|
3418
|
+
function computeRealProperties(properties, context, injectDeep, trackingContextList) {
|
|
3419
|
+
var result = {};
|
|
3420
|
+
if (isObject(properties)) {
|
|
3421
|
+
for (var [propName, propValue] of Object.entries(properties)) {
|
|
3422
|
+
// Related: https://github.com/facebook/react/issues/11347
|
|
3423
|
+
var realValue = computeRealValue(propValue, context, injectDeep, {
|
|
3424
|
+
$$lazyForUseBrick: true,
|
|
3425
|
+
$$stateOfUseBrick: propName === "useBrick" ? StateOfUseBrick.USE_BRICK : StateOfUseBrick.INITIAL
|
|
3426
|
+
});
|
|
3427
|
+
if (realValue !== undefined) {
|
|
3428
|
+
// For `style` and `dataset`, only object is acceptable.
|
|
3429
|
+
if (propName !== "style" && propName !== "dataset" || isObject(realValue)) {
|
|
3430
|
+
result[propName] = realValue;
|
|
3431
|
+
}
|
|
3439
3432
|
}
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3433
|
+
if (Array.isArray(trackingContextList)) {
|
|
3434
|
+
var {
|
|
3435
|
+
contextNames,
|
|
3436
|
+
stateNames,
|
|
3437
|
+
formStateNames
|
|
3438
|
+
} = getTracks(propValue);
|
|
3439
|
+
if (contextNames || stateNames || formStateNames) {
|
|
3440
|
+
trackingContextList.push({
|
|
3441
|
+
contextNames,
|
|
3442
|
+
stateNames,
|
|
3443
|
+
formStateNames,
|
|
3444
|
+
propName,
|
|
3445
|
+
propValue
|
|
3446
|
+
});
|
|
3446
3447
|
}
|
|
3447
|
-
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3448
|
-
overrideApp: data[symbolOverrideApp],
|
|
3449
|
-
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3450
|
-
});
|
|
3451
|
-
} else {
|
|
3452
|
-
var storyboard = kernel.bootstrapData.storyboards.find(story => story.app.id === overrideAppId);
|
|
3453
|
-
newContext = _objectSpread(_objectSpread({}, context), {}, {
|
|
3454
|
-
overrideApp: storyboard === null || storyboard === void 0 ? void 0 : storyboard.app,
|
|
3455
|
-
appendI18nNamespace: data[symbolMenuI18nNamespace]
|
|
3456
|
-
});
|
|
3457
3448
|
}
|
|
3458
3449
|
}
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
});
|
|
3466
|
-
|
|
3450
|
+
}
|
|
3451
|
+
return result;
|
|
3452
|
+
}
|
|
3453
|
+
function getNextInternalOptions(internalOptions, isArray, key) {
|
|
3454
|
+
return internalOptions !== null && internalOptions !== void 0 && internalOptions.$$lazyForUseBrick ? _objectSpread(_objectSpread({}, internalOptions), {}, {
|
|
3455
|
+
$$stateOfUseBrick: getNextStateOfUseBrick(internalOptions.$$stateOfUseBrick, isArray, key)
|
|
3456
|
+
}) : internalOptions;
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
var brickTemplateRegistry = new Map();
|
|
3460
|
+
function registerBrickTemplate(name, factory) {
|
|
3461
|
+
if (brickTemplateRegistry.has(name)) {
|
|
3462
|
+
// eslint-disable-next-line no-console
|
|
3463
|
+
console.error("Brick template of \"".concat(name, "\" already registered."));
|
|
3464
|
+
return;
|
|
3465
|
+
}
|
|
3466
|
+
brickTemplateRegistry.set(name, factory);
|
|
3467
3467
|
}
|
|
3468
3468
|
|
|
3469
3469
|
var lazyBrickRegistry = new Map();
|
|
@@ -3655,10 +3655,39 @@ function _dev_only_getAllContextValues(_ref2) {
|
|
|
3655
3655
|
}
|
|
3656
3656
|
|
|
3657
3657
|
/* istanbul ignore next */
|
|
3658
|
+
function _dev_only_debugDataValue(_x, _x2) {
|
|
3659
|
+
return _dev_only_debugDataValue2.apply(this, arguments);
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3662
|
+
/* istanbul ignore next */
|
|
3663
|
+
function _dev_only_debugDataValue2() {
|
|
3664
|
+
_dev_only_debugDataValue2 = _asyncToGenerator$3(function* (debugData, _ref3) {
|
|
3665
|
+
var {
|
|
3666
|
+
tplContextId
|
|
3667
|
+
} = _ref3;
|
|
3668
|
+
var runtimeContext = _objectSpread(_objectSpread({}, _internalApiGetCurrentContext()), {}, {
|
|
3669
|
+
tplContextId
|
|
3670
|
+
});
|
|
3671
|
+
if (debugData.value) {
|
|
3672
|
+
return computeRealValue(debugData.value, runtimeContext, true);
|
|
3673
|
+
}
|
|
3674
|
+
var hasTransform = debugData.resolve.transform;
|
|
3675
|
+
var result = {};
|
|
3676
|
+
yield _internalApiGetResolver().resolveOne("reference", hasTransform ? debugData.resolve : _objectSpread(_objectSpread({}, debugData.resolve), {}, {
|
|
3677
|
+
transform: "value"
|
|
3678
|
+
}), result, null, runtimeContext, {
|
|
3679
|
+
cache: "reload"
|
|
3680
|
+
});
|
|
3681
|
+
|
|
3682
|
+
// 跟 v3 的数据结构保持一致,有 transform 时返回完整定义,无 transform 时直接返回数据
|
|
3683
|
+
return hasTransform ? result : result.value;
|
|
3684
|
+
});
|
|
3685
|
+
return _dev_only_debugDataValue2.apply(this, arguments);
|
|
3686
|
+
}
|
|
3658
3687
|
function _dev_only_updateFormPreviewSettings(appId, formId, settings) {
|
|
3659
3688
|
kernel._dev_only_updateFormPreviewSettings(appId, formId, settings);
|
|
3660
3689
|
}
|
|
3661
|
-
function _dev_only_render(
|
|
3690
|
+
function _dev_only_render(_x3, _x4) {
|
|
3662
3691
|
return _dev_only_render2.apply(this, arguments);
|
|
3663
3692
|
}
|
|
3664
3693
|
function _dev_only_render2() {
|
|
@@ -14447,6 +14476,7 @@ var developHelper = {
|
|
|
14447
14476
|
getAddedContracts: _dev_only_getAddedContracts,
|
|
14448
14477
|
getContextValue: _dev_only_getContextValue,
|
|
14449
14478
|
getAllContextValues: _dev_only_getAllContextValues,
|
|
14479
|
+
debugDataValue: _dev_only_debugDataValue,
|
|
14450
14480
|
render: _dev_only_render,
|
|
14451
14481
|
setRealTimeDataInspectRoot,
|
|
14452
14482
|
addRealTimeDataInspectHook
|