@player-ui/check-path-plugin 0.1.1-next.11 → 0.1.1-next.14
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.cjs.js +12 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +12 -7
- package/package.json +3 -3
- package/src/index.ts +12 -5
package/dist/index.cjs.js
CHANGED
|
@@ -45,10 +45,7 @@ class CheckPathPlugin {
|
|
|
45
45
|
};
|
|
46
46
|
this.viewInfo = viewInfo;
|
|
47
47
|
resolver.hooks.afterResolve.tap(this.name, (value, node) => {
|
|
48
|
-
|
|
49
|
-
if ((sourceNode == null ? void 0 : sourceNode.type) === "applicability") {
|
|
50
|
-
sourceNode = sourceNode.value;
|
|
51
|
-
}
|
|
48
|
+
const sourceNode = this.getSourceAssetNode(node);
|
|
52
49
|
if (sourceNode) {
|
|
53
50
|
viewInfo.resolvedMap.set(sourceNode, {
|
|
54
51
|
resolved: node,
|
|
@@ -121,6 +118,14 @@ class CheckPathPlugin {
|
|
|
121
118
|
}
|
|
122
119
|
return void 0;
|
|
123
120
|
}
|
|
121
|
+
getSourceAssetNode(node) {
|
|
122
|
+
var _a;
|
|
123
|
+
let sourceNode = (_a = this.viewInfo) == null ? void 0 : _a.resolver.getSourceNode(node);
|
|
124
|
+
if ((sourceNode == null ? void 0 : sourceNode.type) === "applicability") {
|
|
125
|
+
sourceNode = sourceNode.value;
|
|
126
|
+
}
|
|
127
|
+
return sourceNode;
|
|
128
|
+
}
|
|
124
129
|
hasParentContext(id, query) {
|
|
125
130
|
return Boolean(this.getParent(id, query));
|
|
126
131
|
}
|
|
@@ -161,14 +166,14 @@ class CheckPathPlugin {
|
|
|
161
166
|
return this.findChildPath(assetNode, queryArray, false);
|
|
162
167
|
}
|
|
163
168
|
getAsset(id) {
|
|
164
|
-
var _a, _b, _c
|
|
169
|
+
var _a, _b, _c;
|
|
165
170
|
const assetNode = (_a = this.viewInfo) == null ? void 0 : _a.assetIdMap.get(id);
|
|
166
171
|
if (!assetNode)
|
|
167
172
|
return;
|
|
168
|
-
const sourceNode =
|
|
173
|
+
const sourceNode = this.getSourceAssetNode(assetNode);
|
|
169
174
|
if (!sourceNode)
|
|
170
175
|
return;
|
|
171
|
-
return (
|
|
176
|
+
return (_c = (_b = this.viewInfo) == null ? void 0 : _b.resolvedMap.get(sourceNode)) == null ? void 0 : _c.value;
|
|
172
177
|
}
|
|
173
178
|
getPath(id, query) {
|
|
174
179
|
var _a, _b;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ declare class CheckPathPlugin implements PlayerPlugin {
|
|
|
26
26
|
* @returns - The property name or undefined if no parent was found
|
|
27
27
|
*/
|
|
28
28
|
getParentProp(id: string): string | number | undefined;
|
|
29
|
+
/** Given a node, return itself, or the nested asset if the node is an applicability node */
|
|
30
|
+
private getSourceAssetNode;
|
|
29
31
|
/**
|
|
30
32
|
* Given the starting node, check to verify that the supplied queries are relevant to the current asset's parents.
|
|
31
33
|
*
|
package/dist/index.esm.js
CHANGED
|
@@ -37,10 +37,7 @@ class CheckPathPlugin {
|
|
|
37
37
|
};
|
|
38
38
|
this.viewInfo = viewInfo;
|
|
39
39
|
resolver.hooks.afterResolve.tap(this.name, (value, node) => {
|
|
40
|
-
|
|
41
|
-
if ((sourceNode == null ? void 0 : sourceNode.type) === "applicability") {
|
|
42
|
-
sourceNode = sourceNode.value;
|
|
43
|
-
}
|
|
40
|
+
const sourceNode = this.getSourceAssetNode(node);
|
|
44
41
|
if (sourceNode) {
|
|
45
42
|
viewInfo.resolvedMap.set(sourceNode, {
|
|
46
43
|
resolved: node,
|
|
@@ -113,6 +110,14 @@ class CheckPathPlugin {
|
|
|
113
110
|
}
|
|
114
111
|
return void 0;
|
|
115
112
|
}
|
|
113
|
+
getSourceAssetNode(node) {
|
|
114
|
+
var _a;
|
|
115
|
+
let sourceNode = (_a = this.viewInfo) == null ? void 0 : _a.resolver.getSourceNode(node);
|
|
116
|
+
if ((sourceNode == null ? void 0 : sourceNode.type) === "applicability") {
|
|
117
|
+
sourceNode = sourceNode.value;
|
|
118
|
+
}
|
|
119
|
+
return sourceNode;
|
|
120
|
+
}
|
|
116
121
|
hasParentContext(id, query) {
|
|
117
122
|
return Boolean(this.getParent(id, query));
|
|
118
123
|
}
|
|
@@ -153,14 +158,14 @@ class CheckPathPlugin {
|
|
|
153
158
|
return this.findChildPath(assetNode, queryArray, false);
|
|
154
159
|
}
|
|
155
160
|
getAsset(id) {
|
|
156
|
-
var _a, _b, _c
|
|
161
|
+
var _a, _b, _c;
|
|
157
162
|
const assetNode = (_a = this.viewInfo) == null ? void 0 : _a.assetIdMap.get(id);
|
|
158
163
|
if (!assetNode)
|
|
159
164
|
return;
|
|
160
|
-
const sourceNode =
|
|
165
|
+
const sourceNode = this.getSourceAssetNode(assetNode);
|
|
161
166
|
if (!sourceNode)
|
|
162
167
|
return;
|
|
163
|
-
return (
|
|
168
|
+
return (_c = (_b = this.viewInfo) == null ? void 0 : _b.resolvedMap.get(sourceNode)) == null ? void 0 : _c.value;
|
|
164
169
|
}
|
|
165
170
|
getPath(id, query) {
|
|
166
171
|
var _a, _b;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-ui/check-path-plugin",
|
|
3
|
-
"version": "0.1.1-next.
|
|
3
|
+
"version": "0.1.1-next.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@player-ui/player": "0.1.1-next.
|
|
9
|
+
"@player-ui/player": "0.1.1-next.14"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@player-ui/partial-match-registry": "0.1.1-next.
|
|
12
|
+
"@player-ui/partial-match-registry": "0.1.1-next.14",
|
|
13
13
|
"dlv": "^1.1.3",
|
|
14
14
|
"tapable-ts": "^0.1.0",
|
|
15
15
|
"@babel/runtime": "7.15.4"
|
package/src/index.ts
CHANGED
|
@@ -95,10 +95,7 @@ export class CheckPathPlugin implements PlayerPlugin {
|
|
|
95
95
|
this.viewInfo = viewInfo;
|
|
96
96
|
|
|
97
97
|
resolver.hooks.afterResolve.tap(this.name, (value, node) => {
|
|
98
|
-
|
|
99
|
-
if (sourceNode?.type === 'applicability') {
|
|
100
|
-
sourceNode = sourceNode.value;
|
|
101
|
-
}
|
|
98
|
+
const sourceNode = this.getSourceAssetNode(node);
|
|
102
99
|
|
|
103
100
|
if (sourceNode) {
|
|
104
101
|
viewInfo.resolvedMap.set(sourceNode, {
|
|
@@ -225,6 +222,16 @@ export class CheckPathPlugin implements PlayerPlugin {
|
|
|
225
222
|
return undefined;
|
|
226
223
|
}
|
|
227
224
|
|
|
225
|
+
/** Given a node, return itself, or the nested asset if the node is an applicability node */
|
|
226
|
+
private getSourceAssetNode(node: Node.Node) {
|
|
227
|
+
let sourceNode = this.viewInfo?.resolver.getSourceNode(node);
|
|
228
|
+
if (sourceNode?.type === 'applicability') {
|
|
229
|
+
sourceNode = sourceNode.value;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return sourceNode;
|
|
233
|
+
}
|
|
234
|
+
|
|
228
235
|
/**
|
|
229
236
|
* Given the starting node, check to verify that the supplied queries are relevant to the current asset's parents.
|
|
230
237
|
*
|
|
@@ -308,7 +315,7 @@ export class CheckPathPlugin implements PlayerPlugin {
|
|
|
308
315
|
const assetNode = this.viewInfo?.assetIdMap.get(id);
|
|
309
316
|
if (!assetNode) return;
|
|
310
317
|
|
|
311
|
-
const sourceNode = this.
|
|
318
|
+
const sourceNode = this.getSourceAssetNode(assetNode);
|
|
312
319
|
if (!sourceNode) return;
|
|
313
320
|
|
|
314
321
|
return this.viewInfo?.resolvedMap.get(sourceNode)?.value;
|