@next-core/brick-kit 2.70.2 → 2.72.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,49 @@
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.72.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.71.0...@next-core/brick-kit@2.72.0) (2021-09-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * expose StoryboardFunctionRegistryFactory ([c7079e8](https://github.com/easyops-cn/next-core/commit/c7079e838a37350264ca3bf210527e1b09a542f7))
12
+
13
+
14
+
15
+
16
+
17
+ # [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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * refine inject marking ([01675a8](https://github.com/easyops-cn/next-core/commit/01675a8b26fb0ab0e97de89a83c4618ccb4e7127))
23
+
24
+
25
+ ### Features
26
+
27
+ * **LocationContext:** handlePageLoad dispatch page.load event on window for e2e testing usage ([d9bb07b](https://github.com/easyops-cn/next-core/commit/d9bb07b0395fbf769d485768bbb64e035b72c743))
28
+
29
+
30
+
31
+
32
+
33
+ ## [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)
34
+
35
+ **Note:** Version bump only for package @next-core/brick-kit
36
+
37
+
38
+
39
+
40
+
41
+ ## [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)
42
+
43
+ **Note:** Version bump only for package @next-core/brick-kit
44
+
45
+
46
+
47
+
48
+
6
49
  ## [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)
7
50
 
8
51
  **Note:** Version bump only for package @next-core/brick-kit
@@ -778,9 +778,13 @@
778
778
 
779
779
  if (Array.isArray(value)) {
780
780
  value.forEach(recursiveMarkAsInjected);
781
- } else if (value.constructor === Object) {
781
+ } else {
782
782
  // Only mark pure objects.
783
- 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
+ }
784
788
  }
785
789
  }
786
790
  }
@@ -2317,58 +2321,77 @@
2317
2321
  }
2318
2322
  }
2319
2323
 
2320
- var registeredFunctions = new Map();
2321
- // Use `Proxy` with a frozen target, to make a readonly function registry.
2322
- var storyboardFunctions = new Proxy(Object.freeze({}), {
2323
- get(target, key) {
2324
- return getStoryboardFunction(key);
2324
+ /** @internal */
2325
+
2326
+ /** @internal */
2327
+ function StoryboardFunctionRegistryFactory() {
2328
+ var registeredFunctions = new Map(); // Use `Proxy` with a frozen target, to make a readonly function registry.
2329
+
2330
+ var storyboardFunctions = new Proxy(Object.freeze({}), {
2331
+ get(target, key) {
2332
+ return getStoryboardFunction(key);
2333
+ }
2334
+
2335
+ });
2336
+
2337
+ function registerStoryboardFunctions(functions) {
2338
+ registeredFunctions.clear();
2339
+
2340
+ if (Array.isArray(functions)) {
2341
+ for (var fn of functions) {
2342
+ registeredFunctions.set(fn.name, {
2343
+ source: fn.source,
2344
+ typescript: fn.typescript
2345
+ });
2346
+ }
2347
+ }
2325
2348
  }
2326
2349
 
2327
- });
2328
- function registerStoryboardFunctions(storyboard) {
2329
- var _storyboard$meta;
2350
+ function getStoryboardFunction(name) {
2351
+ var fn = registeredFunctions.get(name);
2330
2352
 
2331
- registeredFunctions.clear();
2353
+ if (!fn) {
2354
+ return undefined;
2355
+ }
2332
2356
 
2333
- if (Array.isArray((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions)) {
2334
- for (var fn of storyboard.meta.functions) {
2335
- registeredFunctions.set(fn.name, {
2336
- source: fn.source,
2357
+ if (!fn.processed) {
2358
+ var precooked = brickUtils.precookFunction(fn.source, {
2337
2359
  typescript: fn.typescript
2338
2360
  });
2361
+ fn.cooked = brickUtils.cook(precooked.function, fn.source, {
2362
+ rules: {
2363
+ noVar: true
2364
+ },
2365
+ globalVariables: supply(precooked.attemptToVisitGlobals, {
2366
+ // Functions can call other functions.
2367
+ FN: storyboardFunctions
2368
+ })
2369
+ });
2370
+ fn.processed = true;
2339
2371
  }
2340
- }
2341
- }
2342
- function getStoryboardFunctions() {
2343
- return storyboardFunctions;
2344
- }
2345
2372
 
2346
- function getStoryboardFunction(name) {
2347
- var fn = registeredFunctions.get(name);
2348
-
2349
- if (!fn) {
2350
- throw new ReferenceError("Function not found: ".concat(name));
2373
+ return fn.cooked;
2351
2374
  }
2352
2375
 
2353
- if (!fn.processed) {
2354
- var precooked = brickUtils.precookFunction(fn.source, {
2355
- typescript: fn.typescript
2376
+ function updateStoryboardFunction(name, data) {
2377
+ registeredFunctions.set(name, {
2378
+ source: data.source,
2379
+ typescript: data.typescript
2356
2380
  });
2357
- fn.cooked = brickUtils.cook(precooked.function, fn.source, {
2358
- rules: {
2359
- noVar: true
2360
- },
2361
- globalVariables: supply(precooked.attemptToVisitGlobals, {
2362
- // Functions can call other functions.
2363
- FN: storyboardFunctions
2364
- })
2365
- });
2366
- fn.processed = true;
2367
2381
  }
2368
2382
 
2369
- return fn.cooked;
2383
+ return {
2384
+ storyboardFunctions,
2385
+ registerStoryboardFunctions,
2386
+ updateStoryboardFunction
2387
+ };
2370
2388
  }
2371
2389
 
2390
+ var {
2391
+ storyboardFunctions,
2392
+ registerStoryboardFunctions
2393
+ } = StoryboardFunctionRegistryFactory();
2394
+
2372
2395
  var symbolForRaw = Symbol.for("pre.evaluated.raw");
2373
2396
  var symbolForContext = Symbol.for("pre.evaluated.context");
2374
2397
  function isPreEvaluated(raw) {
@@ -2584,7 +2607,7 @@
2584
2607
  }
2585
2608
 
2586
2609
  if (attemptToVisitGlobals.has("FN")) {
2587
- globalVariables.FN = getStoryboardFunctions();
2610
+ globalVariables.FN = storyboardFunctions;
2588
2611
  }
2589
2612
 
2590
2613
  try {
@@ -7889,7 +7912,10 @@
7889
7912
  }
7890
7913
 
7891
7914
  handlePageLoad() {
7892
- this.dispatchLifeCycleEvent(new CustomEvent("page.load"), this.pageLoadHandlers);
7915
+ var event = new CustomEvent("page.load");
7916
+ this.dispatchLifeCycleEvent(event, this.pageLoadHandlers); // Currently only for e2e testing
7917
+
7918
+ window.dispatchEvent(event);
7893
7919
  }
7894
7920
 
7895
7921
  handleBeforePageLeave(detail) {
@@ -8579,6 +8605,8 @@
8579
8605
  var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
8580
8606
 
8581
8607
  if (storyboard) {
8608
+ var _storyboard$meta;
8609
+
8582
8610
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
8583
8611
 
8584
8612
  brickUtils.restoreDynamicTemplates(storyboard); // 预加载权限信息
@@ -8594,7 +8622,7 @@
8594
8622
 
8595
8623
  _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
8596
8624
 
8597
- registerStoryboardFunctions(storyboard);
8625
+ registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions);
8598
8626
  }
8599
8627
 
8600
8628
  var {
@@ -10663,6 +10691,7 @@
10663
10691
  exports.ForwardRefSingleBrickAsComponent = ForwardRefSingleBrickAsComponent;
10664
10692
  exports.ModalElement = ModalElement;
10665
10693
  exports.SingleBrickAsComponent = SingleBrickAsComponent;
10694
+ exports.StoryboardFunctionRegistryFactory = StoryboardFunctionRegistryFactory;
10666
10695
  exports.UpdatingElement = UpdatingElement;
10667
10696
  exports.authenticate = authenticate;
10668
10697
  exports.checkIf = checkIf;