@player-ui/check-path-plugin 0.3.1-next.0 → 0.4.0-next.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.cjs.js CHANGED
@@ -20,14 +20,15 @@ function createMatcher(match) {
20
20
  return partialMatchRegistry.createObjectMatcher(match);
21
21
  }
22
22
  function getParent(node, viewInfo) {
23
- var _a;
24
23
  let working = node;
25
24
  while (working.parent && working.parent.type !== player.NodeType.Asset && working.parent.type !== player.NodeType.View) {
26
25
  working = working.parent;
27
26
  }
28
27
  const { parent } = working;
29
28
  if (parent && (parent.type === player.NodeType.Asset || parent.type === player.NodeType.View)) {
30
- return (_a = viewInfo.resolver.getSourceNode(parent)) != null ? _a : parent;
29
+ const sourceNode = viewInfo.resolver.getSourceNode(parent);
30
+ const viewOrAsset = (sourceNode == null ? void 0 : sourceNode.type) === player.NodeType.Applicability ? sourceNode.value : viewInfo.resolver.getSourceNode(parent);
31
+ return viewOrAsset != null ? viewOrAsset : parent;
31
32
  }
32
33
  }
33
34
  class CheckPathPlugin {
@@ -136,17 +137,18 @@ class CheckPathPlugin {
136
137
  }
137
138
  const [first, ...rest] = query;
138
139
  const matcher = createMatcher(first);
139
- if (node.type === player.NodeType.Asset || node.type === player.NodeType.View) {
140
- const resolved = (_a = this.viewInfo) == null ? void 0 : _a.resolvedMap.get(node);
141
- const includesSelf = (_b = includeSelfMatch && resolved && matcher(resolved.value)) != null ? _b : false;
140
+ if (node.type === player.NodeType.Asset || node.type === player.NodeType.View || node.type === player.NodeType.Applicability) {
141
+ const resolved = node.type === player.NodeType.Applicability ? (_a = this.viewInfo) == null ? void 0 : _a.resolvedMap.get(node.value) : (_b = this.viewInfo) == null ? void 0 : _b.resolvedMap.get(node);
142
+ const includesSelf = (_c = includeSelfMatch && resolved && matcher(resolved.value)) != null ? _c : false;
142
143
  const childQuery = includesSelf ? rest : query;
143
144
  if (childQuery.length === 0 && includesSelf) {
144
145
  return true;
145
146
  }
146
- if (childQuery.length && (!node.children || node.children.length === 0)) {
147
+ const children = node.type === player.NodeType.Applicability ? node.value.children : node.children;
148
+ if (childQuery.length && (!children || children.length === 0)) {
147
149
  return false;
148
150
  }
149
- if ((_c = node.children) == null ? void 0 : _c.some((childNode) => this.findChildPath(childNode.value, childQuery))) {
151
+ if (children == null ? void 0 : children.some((childNode) => this.findChildPath(childNode.value, childQuery))) {
150
152
  return true;
151
153
  }
152
154
  } else if (node.type === player.NodeType.MultiNode && node.values.some((childNode) => this.findChildPath(childNode, query))) {
package/dist/index.esm.js CHANGED
@@ -12,14 +12,15 @@ function createMatcher(match) {
12
12
  return createObjectMatcher(match);
13
13
  }
14
14
  function getParent(node, viewInfo) {
15
- var _a;
16
15
  let working = node;
17
16
  while (working.parent && working.parent.type !== NodeType.Asset && working.parent.type !== NodeType.View) {
18
17
  working = working.parent;
19
18
  }
20
19
  const { parent } = working;
21
20
  if (parent && (parent.type === NodeType.Asset || parent.type === NodeType.View)) {
22
- return (_a = viewInfo.resolver.getSourceNode(parent)) != null ? _a : parent;
21
+ const sourceNode = viewInfo.resolver.getSourceNode(parent);
22
+ const viewOrAsset = (sourceNode == null ? void 0 : sourceNode.type) === NodeType.Applicability ? sourceNode.value : viewInfo.resolver.getSourceNode(parent);
23
+ return viewOrAsset != null ? viewOrAsset : parent;
23
24
  }
24
25
  }
25
26
  class CheckPathPlugin {
@@ -128,17 +129,18 @@ class CheckPathPlugin {
128
129
  }
129
130
  const [first, ...rest] = query;
130
131
  const matcher = createMatcher(first);
131
- if (node.type === NodeType.Asset || node.type === NodeType.View) {
132
- const resolved = (_a = this.viewInfo) == null ? void 0 : _a.resolvedMap.get(node);
133
- const includesSelf = (_b = includeSelfMatch && resolved && matcher(resolved.value)) != null ? _b : false;
132
+ if (node.type === NodeType.Asset || node.type === NodeType.View || node.type === NodeType.Applicability) {
133
+ const resolved = node.type === NodeType.Applicability ? (_a = this.viewInfo) == null ? void 0 : _a.resolvedMap.get(node.value) : (_b = this.viewInfo) == null ? void 0 : _b.resolvedMap.get(node);
134
+ const includesSelf = (_c = includeSelfMatch && resolved && matcher(resolved.value)) != null ? _c : false;
134
135
  const childQuery = includesSelf ? rest : query;
135
136
  if (childQuery.length === 0 && includesSelf) {
136
137
  return true;
137
138
  }
138
- if (childQuery.length && (!node.children || node.children.length === 0)) {
139
+ const children = node.type === NodeType.Applicability ? node.value.children : node.children;
140
+ if (childQuery.length && (!children || children.length === 0)) {
139
141
  return false;
140
142
  }
141
- if ((_c = node.children) == null ? void 0 : _c.some((childNode) => this.findChildPath(childNode.value, childQuery))) {
143
+ if (children == null ? void 0 : children.some((childNode) => this.findChildPath(childNode.value, childQuery))) {
142
144
  return true;
143
145
  }
144
146
  } else if (node.type === NodeType.MultiNode && node.values.some((childNode) => this.findChildPath(childNode, query))) {
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@player-ui/check-path-plugin",
3
- "version": "0.3.1-next.0",
3
+ "version": "0.4.0-next.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "@player-ui/player": "0.3.1-next.0"
9
+ "@player-ui/player": "0.4.0-next.0"
10
10
  },
11
11
  "dependencies": {
12
- "@player-ui/partial-match-registry": "0.3.1-next.0",
12
+ "@player-ui/partial-match-registry": "0.4.0-next.0",
13
13
  "dlv": "^1.1.3",
14
- "tapable-ts": "^0.1.0",
14
+ "tapable-ts": "^0.2.2",
15
15
  "@babel/runtime": "7.15.4"
16
16
  },
17
17
  "main": "dist/index.cjs.js",
package/src/index.ts CHANGED
@@ -69,8 +69,12 @@ function getParent(
69
69
  parent &&
70
70
  (parent.type === NodeType.Asset || parent.type === NodeType.View)
71
71
  ) {
72
- return (viewInfo.resolver.getSourceNode(parent) ??
73
- parent) as Node.ViewOrAsset;
72
+ const sourceNode = viewInfo.resolver.getSourceNode(parent);
73
+ const viewOrAsset =
74
+ sourceNode?.type === NodeType.Applicability
75
+ ? sourceNode.value
76
+ : viewInfo.resolver.getSourceNode(parent);
77
+ return (viewOrAsset ?? parent) as Node.ViewOrAsset;
74
78
  }
75
79
  }
76
80
 
@@ -254,8 +258,15 @@ export class CheckPathPlugin implements PlayerPlugin {
254
258
  const [first, ...rest] = query;
255
259
  const matcher = createMatcher(first);
256
260
 
257
- if (node.type === NodeType.Asset || node.type === NodeType.View) {
258
- const resolved = this.viewInfo?.resolvedMap.get(node);
261
+ if (
262
+ node.type === NodeType.Asset ||
263
+ node.type === NodeType.View ||
264
+ node.type === NodeType.Applicability
265
+ ) {
266
+ const resolved =
267
+ node.type === NodeType.Applicability
268
+ ? this.viewInfo?.resolvedMap.get(node.value)
269
+ : this.viewInfo?.resolvedMap.get(node);
259
270
  const includesSelf =
260
271
  (includeSelfMatch && resolved && matcher(resolved.value)) ?? false;
261
272
  const childQuery = includesSelf ? rest : query;
@@ -264,12 +275,16 @@ export class CheckPathPlugin implements PlayerPlugin {
264
275
  return true;
265
276
  }
266
277
 
267
- if (childQuery.length && (!node.children || node.children.length === 0)) {
278
+ const children =
279
+ node.type === NodeType.Applicability
280
+ ? (node.value as Node.ViewOrAsset).children
281
+ : node.children;
282
+ if (childQuery.length && (!children || children.length === 0)) {
268
283
  return false;
269
284
  }
270
285
 
271
286
  if (
272
- node.children?.some((childNode) =>
287
+ children?.some((childNode) =>
273
288
  this.findChildPath(childNode.value, childQuery)
274
289
  )
275
290
  ) {