@next-core/brick-kit 2.70.1 → 2.71.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/CHANGELOG.md CHANGED
@@ -3,6 +3,46 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.71.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.70.4...@next-core/brick-kit@2.71.0) (2021-09-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * refine inject marking ([01675a8](https://github.com/easyops-cn/next-core/commit/01675a8b26fb0ab0e97de89a83c4618ccb4e7127))
12
+
13
+
14
+ ### Features
15
+
16
+ * **LocationContext:** handlePageLoad dispatch page.load event on window for e2e testing usage ([d9bb07b](https://github.com/easyops-cn/next-core/commit/d9bb07b0395fbf769d485768bbb64e035b72c743))
17
+
18
+
19
+
20
+
21
+
22
+ ## [2.70.4](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.70.3...@next-core/brick-kit@2.70.4) (2021-09-23)
23
+
24
+ **Note:** Version bump only for package @next-core/brick-kit
25
+
26
+
27
+
28
+
29
+
30
+ ## [2.70.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.70.2...@next-core/brick-kit@2.70.3) (2021-09-22)
31
+
32
+ **Note:** Version bump only for package @next-core/brick-kit
33
+
34
+
35
+
36
+
37
+
38
+ ## [2.70.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.70.1...@next-core/brick-kit@2.70.2) (2021-09-22)
39
+
40
+ **Note:** Version bump only for package @next-core/brick-kit
41
+
42
+
43
+
44
+
45
+
6
46
  ## [2.70.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.70.0...@next-core/brick-kit@2.70.1) (2021-09-16)
7
47
 
8
48
  **Note:** Version bump only for package @next-core/brick-kit
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('history'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/asyncToGenerator'), require('antd'), require('@next-core/brick-utils'), require('react'), require('@next-core/brick-http'), require('@ant-design/icons'), require('i18next'), require('lodash'), require('js-yaml'), require('@next-core/easyops-analytics'), require('path'), require('react-i18next'), require('@babel/runtime/helpers/esm/extends'), require('@next-core/illustrations'), require('@babel/runtime/helpers/decorate')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'history', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/defineProperty', '@babel/runtime/helpers/asyncToGenerator', 'antd', '@next-core/brick-utils', 'react', '@next-core/brick-http', '@ant-design/icons', 'i18next', 'lodash', 'js-yaml', '@next-core/easyops-analytics', 'path', 'react-i18next', '@babel/runtime/helpers/esm/extends', '@next-core/illustrations', '@babel/runtime/helpers/decorate'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._defineProperty$2, global._asyncToGenerator$4, global.antd, global.brickUtils, global.React, global.brickHttp, global.icons, global.i18next, global.lodash, global.yaml, global.easyopsAnalytics, global.require$$0, global.reactI18next, global._extends$2, global.illustrations, global._decorate));
5
- }(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _defineProperty$2, _asyncToGenerator$4, antd, brickUtils, React, brickHttp, icons, i18next, lodash, yaml, easyopsAnalytics, require$$0, reactI18next, _extends$2, illustrations, _decorate) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('history'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/asyncToGenerator'), require('antd'), require('@next-core/brick-utils'), require('react'), require('@next-core/brick-http'), require('@ant-design/icons'), require('i18next'), require('lodash'), require('moment'), require('@next-core/pipes'), require('js-yaml'), require('@next-core/easyops-analytics'), require('path'), require('react-i18next'), require('@babel/runtime/helpers/esm/extends'), require('@next-core/illustrations'), require('@babel/runtime/helpers/decorate')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'history', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/defineProperty', '@babel/runtime/helpers/asyncToGenerator', 'antd', '@next-core/brick-utils', 'react', '@next-core/brick-http', '@ant-design/icons', 'i18next', 'lodash', 'moment', '@next-core/pipes', 'js-yaml', '@next-core/easyops-analytics', 'path', 'react-i18next', '@babel/runtime/helpers/esm/extends', '@next-core/illustrations', '@babel/runtime/helpers/decorate'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._defineProperty$2, global._asyncToGenerator$4, global.antd, global.brickUtils, global.React, global.brickHttp, global.icons, global.i18next, global.lodash, global.moment, global.pipes, global.yaml, global.easyopsAnalytics, global.require$$0, global.reactI18next, global._extends$2, global.illustrations, global._decorate));
5
+ }(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _defineProperty$2, _asyncToGenerator$4, antd, brickUtils, React, brickHttp, icons, i18next, lodash, moment, pipes, yaml, easyopsAnalytics, require$$0, reactI18next, _extends$2, illustrations, _decorate) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -33,6 +33,8 @@
33
33
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
34
34
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
35
35
  var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
36
+ var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash);
37
+ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
36
38
  var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
37
39
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
38
40
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends$2);
@@ -421,6 +423,120 @@
421
423
  return /*#__PURE__*/React__default['default'].createElement("div", null, i18next__default['default'].t("".concat(NS_BRICK_KIT, ":").concat(K.LOGIN_TIMEOUT_MESSAGE)));
422
424
  }
423
425
 
426
+ function supply(attemptToVisitGlobals, providedGlobalVariables) {
427
+ var globalVariables = _objectSpread__default['default']({}, providedGlobalVariables); // Allow limited browser builtin values.
428
+
429
+
430
+ globalVariables["undefined"] = undefined;
431
+
432
+ for (var variableName of attemptToVisitGlobals) {
433
+ if (!Object.prototype.hasOwnProperty.call(globalVariables, variableName)) {
434
+ var variable = supplyIndividual(variableName);
435
+
436
+ if (variable !== undefined) {
437
+ globalVariables[variableName] = variable;
438
+ }
439
+ }
440
+ }
441
+
442
+ return globalVariables;
443
+ }
444
+ var shouldOmitInLodash = new Set([// Omit all mutable methods from lodash.
445
+ // But allow sequence methods like `_.chain`.
446
+ "fill", "pull", "pullAll", "pullAllBy", "pullAllWith", "pullAt", "remove", "reverse", "assign", "assignIn", "assignInWith", "assignWith", "defaults", "defaultsDeep", "merge", "mergeWith", "set", "setWith", "unset", "update", "updateWith",
447
+ /**
448
+ * Ignore `Function` methods from lodash, too.
449
+ * There are chances to invoke `Object.assign`, etc.
450
+ *
451
+ * E.g.:
452
+ *
453
+ * ```
454
+ * _.wrap(_.method('constructor.assign',{b:2},{b:3}),(func,...a) => func(...a))({})
455
+ * ```
456
+ */
457
+ "after", "ary", "before", "bind", "bindKey", "curry", "curryRight", "debounce", "defer", "delay", "flip", "memoize", "negate", "once", "overArgs", "partial", "partialRight", "rearg", "rest", "spread", "throttle", "unary", "wrap"]); // Omit all mutable methods from moment.
458
+
459
+ var shouldOmitInMoment = new Set(["lang", "langData", "locale", "localeData", "defineLocale", "updateLocale", "updateOffset"]);
460
+ var allowedGlobalObjects = new Set(["Array", "Boolean", "Date", "Infinity", "JSON", "Math", "NaN", "Number", "String", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "isFinite", "isNaN", "parseFloat", "parseInt", "Map", "Set", "URLSearchParams", "WeakMap", "WeakSet", "atob", "btoa"]);
461
+
462
+ function supplyIndividual(variableName) {
463
+ switch (variableName) {
464
+ case "Object":
465
+ // Do not allow mutable methods like `Object.assign`.
466
+ return delegateMethods(Object, ["entries", "fromEntries", "keys", "values"]);
467
+
468
+ case "_":
469
+ return Object.fromEntries(Object.entries(lodash__default['default']).filter(entry => !shouldOmitInLodash.has(entry[0])));
470
+
471
+ case "moment":
472
+ return Object.assign((...args) => moment__default['default'](...args), Object.fromEntries(Object.entries(moment__default['default']).filter(entry => !shouldOmitInMoment.has(entry[0]))));
473
+
474
+ case "PIPES":
475
+ return pipes.pipes;
476
+
477
+ case "location":
478
+ return {
479
+ href: location.href,
480
+ origin: location.origin
481
+ };
482
+
483
+ case "TAG_URL":
484
+ return tagUrlFactory(true);
485
+
486
+ case "SAFE_TAG_URL":
487
+ return tagUrlFactory();
488
+
489
+ default:
490
+ if (allowedGlobalObjects.has(variableName)) {
491
+ return window[variableName];
492
+ }
493
+
494
+ }
495
+ }
496
+
497
+ function delegateMethods(target, methods) {
498
+ return Object.fromEntries(methods.map(method => [method, (...args) => target[method].apply(target, args)]));
499
+ }
500
+ /**
501
+ * Pass `ignoreSlashes` as `true` to encode all tagged expressions
502
+ * as URL components, except for `/` which maybe used in `APP.homepage`.
503
+ *
504
+ * Otherwise encode all tagged expressions as URL components.
505
+ * This will encode `/` as `%2F`. So do not use it directly
506
+ * with `APP.homepage` as in template expressions.
507
+ *
508
+ * @example
509
+ *
510
+ * ```js
511
+ * TAG_URL`${APP.homepage}/list?q=${q}&redirect=${redirect}`
512
+ * ```
513
+ *
514
+ * ```js
515
+ * SAFE_TAG_URL`file/${path}?q=${q}`
516
+ * // `path` will be fully transformed by `encodeURIComponent`.
517
+ * ```
518
+ *
519
+ * ```js
520
+ * // Wrap `APP.homepage` outside of `SAFE_TAG_URL`.
521
+ * `${APP.homepage}/${SAFE_TAG_URL`file/${path}?q=${q}`}`
522
+ * ```
523
+ */
524
+
525
+
526
+ function tagUrlFactory(ignoreSlashes) {
527
+ return function (strings, ...partials) {
528
+ var result = [];
529
+ strings.forEach((str, index) => {
530
+ result.push(str);
531
+
532
+ if (index < partials.length) {
533
+ result.push(ignoreSlashes ? String(partials[index]).replace(/[^/]+/g, p => encodeURIComponent(p)) : encodeURIComponent(String(partials[index])));
534
+ }
535
+ });
536
+ return result.join("");
537
+ };
538
+ }
539
+
424
540
  var brickTemplateRegistry = new Map();
425
541
  function registerBrickTemplate(name, factory) {
426
542
  if (brickTemplateRegistry.has(name)) {
@@ -662,9 +778,13 @@
662
778
 
663
779
  if (Array.isArray(value)) {
664
780
  value.forEach(recursiveMarkAsInjected);
665
- } else if (value.constructor === Object) {
781
+ } else {
666
782
  // Only mark pure objects.
667
- Object.values(value).forEach(recursiveMarkAsInjected);
783
+ var proto = Object.getPrototypeOf(value);
784
+
785
+ if (!proto || proto.constructor === Object) {
786
+ Object.values(value).forEach(recursiveMarkAsInjected);
787
+ }
668
788
  }
669
789
  }
670
790
  }
@@ -2242,7 +2362,7 @@
2242
2362
  rules: {
2243
2363
  noVar: true
2244
2364
  },
2245
- globalVariables: brickUtils.supply(precooked.attemptToVisitGlobals, {
2365
+ globalVariables: supply(precooked.attemptToVisitGlobals, {
2246
2366
  // Functions can call other functions.
2247
2367
  FN: storyboardFunctions
2248
2368
  })
@@ -2473,7 +2593,7 @@
2473
2593
 
2474
2594
  try {
2475
2595
  var result = brickUtils.cook(precooked.expression, precooked.source, {
2476
- globalVariables: brickUtils.supply(precooked.attemptToVisitGlobals, globalVariables)
2596
+ globalVariables: supply(precooked.attemptToVisitGlobals, globalVariables)
2477
2597
  });
2478
2598
  var detail = {
2479
2599
  raw,
@@ -7773,7 +7893,10 @@
7773
7893
  }
7774
7894
 
7775
7895
  handlePageLoad() {
7776
- this.dispatchLifeCycleEvent(new CustomEvent("page.load"), this.pageLoadHandlers);
7896
+ var event = new CustomEvent("page.load");
7897
+ this.dispatchLifeCycleEvent(event, this.pageLoadHandlers); // Currently only for e2e testing
7898
+
7899
+ window.dispatchEvent(event);
7777
7900
  }
7778
7901
 
7779
7902
  handleBeforePageLeave(detail) {