@next-core/brick-utils 2.38.3 → 2.39.2
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 +27 -0
- package/dist/index.bundle.js +37 -24
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +36 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/types/track.d.ts +2 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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.39.2](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.39.1...@next-core/brick-utils@2.39.2) (2022-08-31)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @next-core/brick-utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.39.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.39.0...@next-core/brick-utils@2.39.1) (2022-08-26)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @next-core/brick-utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [2.39.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.38.3...@next-core/brick-utils@2.39.0) (2022-08-25)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* context can track its deps now ([4993308](https://github.com/easyops-cn/next-core/commit/49933089e1ff6ec1ec5f01eeac5609dde07c1e2e))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [2.38.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-utils@2.38.2...@next-core/brick-utils@2.38.3) (2022-08-23)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @next-core/brick-utils
|
package/dist/index.bundle.js
CHANGED
|
@@ -2774,9 +2774,7 @@
|
|
|
2774
2774
|
var name = functionExpression.id.name;
|
|
2775
2775
|
var funcEnv = new DeclarativeEnvironment(scope);
|
|
2776
2776
|
funcEnv.CreateImmutableBinding(name, false);
|
|
2777
|
-
var closure = OrdinaryFunctionCreate(functionExpression,
|
|
2778
|
-
// functionExpression.body,
|
|
2779
|
-
funcEnv, true);
|
|
2777
|
+
var closure = OrdinaryFunctionCreate(functionExpression, funcEnv, true);
|
|
2780
2778
|
funcEnv.InitializeBinding(name, closure);
|
|
2781
2779
|
return closure;
|
|
2782
2780
|
} else {
|
|
@@ -2794,9 +2792,7 @@
|
|
|
2794
2792
|
} // https://tc39.es/ecma262/#sec-ordinaryfunctioncreate
|
|
2795
2793
|
|
|
2796
2794
|
|
|
2797
|
-
function OrdinaryFunctionCreate(sourceNode,
|
|
2798
|
-
// body: BlockStatement | Expression,
|
|
2799
|
-
scope, isConstructor) {
|
|
2795
|
+
function OrdinaryFunctionCreate(sourceNode, scope, isConstructor) {
|
|
2800
2796
|
var F = function () {
|
|
2801
2797
|
// eslint-disable-next-line prefer-rest-params
|
|
2802
2798
|
return CallFunction(F, arguments);
|
|
@@ -22633,7 +22629,7 @@
|
|
|
22633
22629
|
};
|
|
22634
22630
|
|
|
22635
22631
|
if (!_contextConf2.property) {
|
|
22636
|
-
visitStoryboardExpressions([_contextConf2.if, _contextConf2.value, _contextConf2.resolve], beforeVisitContextFactory(stats, keyword), keyword);
|
|
22632
|
+
visitStoryboardExpressions([_contextConf2.if, _contextConf2.value, _contextConf2.resolve], beforeVisitContextFactory$1(stats, keyword), keyword);
|
|
22637
22633
|
}
|
|
22638
22634
|
|
|
22639
22635
|
depsMap.set(_contextConf2, stats);
|
|
@@ -22642,7 +22638,7 @@
|
|
|
22642
22638
|
return depsMap;
|
|
22643
22639
|
}
|
|
22644
22640
|
|
|
22645
|
-
function beforeVisitContextFactory(stats, keyword) {
|
|
22641
|
+
function beforeVisitContextFactory$1(stats, keyword) {
|
|
22646
22642
|
return function beforeVisitContext(node, parent) {
|
|
22647
22643
|
if (node.name === keyword) {
|
|
22648
22644
|
var memberParent = parent[parent.length - 1];
|
|
@@ -22970,6 +22966,12 @@
|
|
|
22970
22966
|
function trackState(raw) {
|
|
22971
22967
|
return track(raw, "track state", "STATE");
|
|
22972
22968
|
}
|
|
22969
|
+
function trackUsedContext(data) {
|
|
22970
|
+
return trackUsed(data, "CTX");
|
|
22971
|
+
}
|
|
22972
|
+
function trackUsedState(data) {
|
|
22973
|
+
return trackUsed(data, "STATE");
|
|
22974
|
+
}
|
|
22973
22975
|
|
|
22974
22976
|
function track(raw, trackText, variableName) {
|
|
22975
22977
|
if (raw.includes(trackText)) {
|
|
@@ -22979,22 +22981,7 @@
|
|
|
22979
22981
|
} = preevaluate(raw, {
|
|
22980
22982
|
withParent: true,
|
|
22981
22983
|
hooks: {
|
|
22982
|
-
beforeVisitGlobal(
|
|
22983
|
-
if (node.name === variableName) {
|
|
22984
|
-
var memberParent = parent[parent.length - 1];
|
|
22985
|
-
|
|
22986
|
-
if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
|
|
22987
|
-
var memberNode = memberParent.node;
|
|
22988
|
-
|
|
22989
|
-
if (!memberNode.computed && memberNode.property.type === "Identifier") {
|
|
22990
|
-
contexts.add(memberNode.property.name);
|
|
22991
|
-
} else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
|
|
22992
|
-
contexts.add(memberNode.property.value);
|
|
22993
|
-
}
|
|
22994
|
-
}
|
|
22995
|
-
}
|
|
22996
|
-
}
|
|
22997
|
-
|
|
22984
|
+
beforeVisitGlobal: beforeVisitContextFactory(contexts, variableName)
|
|
22998
22985
|
}
|
|
22999
22986
|
});
|
|
23000
22987
|
var trackCtxExp;
|
|
@@ -23012,6 +22999,30 @@
|
|
|
23012
22999
|
return false;
|
|
23013
23000
|
}
|
|
23014
23001
|
|
|
23002
|
+
function trackUsed(data, variableName) {
|
|
23003
|
+
var contexts = new Set();
|
|
23004
|
+
visitStoryboardExpressions(data, beforeVisitContextFactory(contexts, variableName), variableName);
|
|
23005
|
+
return Array.from(contexts);
|
|
23006
|
+
}
|
|
23007
|
+
|
|
23008
|
+
function beforeVisitContextFactory(contexts, variableName) {
|
|
23009
|
+
return function beforeVisitContext(node, parent) {
|
|
23010
|
+
if (node.name === variableName) {
|
|
23011
|
+
var memberParent = parent[parent.length - 1];
|
|
23012
|
+
|
|
23013
|
+
if ((memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object") {
|
|
23014
|
+
var memberNode = memberParent.node;
|
|
23015
|
+
|
|
23016
|
+
if (!memberNode.computed && memberNode.property.type === "Identifier") {
|
|
23017
|
+
contexts.add(memberNode.property.name);
|
|
23018
|
+
} else if (memberNode.computed && memberNode.property.type === "Literal" && typeof memberNode.property.value === "string") {
|
|
23019
|
+
contexts.add(memberNode.property.value);
|
|
23020
|
+
}
|
|
23021
|
+
}
|
|
23022
|
+
}
|
|
23023
|
+
};
|
|
23024
|
+
}
|
|
23025
|
+
|
|
23015
23026
|
// The debounce function receives our function as a parameter
|
|
23016
23027
|
function debounceByAnimationFrame(fn) {
|
|
23017
23028
|
// This holds the requestAnimationFrame reference, so we can cancel it if we wish
|
|
@@ -23134,6 +23145,8 @@
|
|
|
23134
23145
|
exports.tokTypes = tokTypes_1;
|
|
23135
23146
|
exports.trackContext = trackContext;
|
|
23136
23147
|
exports.trackState = trackState;
|
|
23148
|
+
exports.trackUsedContext = trackUsedContext;
|
|
23149
|
+
exports.trackUsedState = trackUsedState;
|
|
23137
23150
|
exports.transform = transform;
|
|
23138
23151
|
exports.transformAndInject = transformAndInject;
|
|
23139
23152
|
exports.visitStoryboardExpressions = visitStoryboardExpressions;
|