@player-ui/partial-match-fingerprint-plugin 0.8.0--canary.307.9621 → 0.8.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.
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ function _class_call_check(instance, Constructor) {
3
+ if (!(instance instanceof Constructor)) {
4
+ throw new TypeError("Cannot call a class as a function");
5
+ }
6
+ }
7
+ function _defineProperties(target, props) {
8
+ for(var i = 0; i < props.length; i++){
9
+ var descriptor = props[i];
10
+ descriptor.enumerable = descriptor.enumerable || false;
11
+ descriptor.configurable = true;
12
+ if ("value" in descriptor) descriptor.writable = true;
13
+ Object.defineProperty(target, descriptor.key, descriptor);
14
+ }
15
+ }
16
+ function _create_class(Constructor, protoProps, staticProps) {
17
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
18
+ if (staticProps) _defineProperties(Constructor, staticProps);
19
+ return Constructor;
20
+ }
21
+ var PartialMatchFingerprintPlugin = function() {
22
+ var __defProp = Object.defineProperty;
23
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
24
+ var __getOwnPropNames = Object.getOwnPropertyNames;
25
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
26
+ var __export = function(target, all) {
27
+ for(var name in all)__defProp(target, name, {
28
+ get: all[name],
29
+ enumerable: true
30
+ });
31
+ };
32
+ var __copyProps = function(to, from, except, desc) {
33
+ if (from && typeof from === "object" || typeof from === "function") {
34
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
35
+ try {
36
+ var _loop = function() {
37
+ var key = _step.value;
38
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
39
+ get: function() {
40
+ return from[key];
41
+ },
42
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
43
+ });
44
+ };
45
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
46
+ } catch (err) {
47
+ _didIteratorError = true;
48
+ _iteratorError = err;
49
+ } finally{
50
+ try {
51
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
52
+ _iterator.return();
53
+ }
54
+ } finally{
55
+ if (_didIteratorError) {
56
+ throw _iteratorError;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return to;
62
+ };
63
+ var __toCommonJS = function(mod) {
64
+ return __copyProps(__defProp({}, "__esModule", {
65
+ value: true
66
+ }), mod);
67
+ };
68
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/src/index.ts
69
+ var src_exports = {};
70
+ __export(src_exports, {
71
+ PartialMatchFingerprintPlugin: function() {
72
+ return PartialMatchFingerprintPlugin;
73
+ }
74
+ });
75
+ var PartialMatchFingerprintPlugin = /*#__PURE__*/ function() {
76
+ function PartialMatchFingerprintPlugin(registry) {
77
+ _class_call_check(this, PartialMatchFingerprintPlugin);
78
+ this.name = "partial-match-fingerprint";
79
+ this.registry = registry;
80
+ this.mapping = /* @__PURE__ */ new Map();
81
+ }
82
+ _create_class(PartialMatchFingerprintPlugin, [
83
+ {
84
+ key: "apply",
85
+ value: function apply(player) {
86
+ var _this = this;
87
+ player.hooks.viewController.tap(this.name, function(viewController) {
88
+ viewController.hooks.view.tap(_this.name, function(view) {
89
+ view.hooks.resolver.tap(_this.name, function(resolver) {
90
+ resolver.hooks.afterResolve.tap(_this.name, function(resolved, node) {
91
+ if (resolved && node && node.type === "asset" || node.type === "view") {
92
+ _this.mapping.set(resolved.id, _this.registry.get(resolved));
93
+ }
94
+ });
95
+ });
96
+ });
97
+ });
98
+ }
99
+ },
100
+ {
101
+ key: "register",
102
+ value: function register(match, value) {
103
+ this.registry.set(match, value);
104
+ }
105
+ },
106
+ {
107
+ key: "get",
108
+ value: function get(assetId) {
109
+ return this.mapping.get(assetId);
110
+ }
111
+ }
112
+ ]);
113
+ return PartialMatchFingerprintPlugin;
114
+ }();
115
+ return __toCommonJS(src_exports);
116
+ }();
117
+ //# sourceMappingURL=index.global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAQO,MAAM,gCAAN,MAA4D;AAAA,IAKjE,YAAY,UAAyB;AAJrC,kBAAO;AAKL,WAAK,WAAW;AAChB,WAAK,UAAU,oBAAI,IAAiB;AAAA,IACtC;AAAA,IAEA,MAAM,QAAgB;AACpB,aAAO,MAAM,eAAe,IAAI,KAAK,MAAM,CAAC,mBAAmB;AAC7D,uBAAe,MAAM,KAAK,IAAI,KAAK,MAAM,CAAC,SAAS;AACjD,eAAK,MAAM,SAAS,IAAI,KAAK,MAAM,CAAC,aAAa;AAC/C,qBAAS,MAAM,aAAa,IAAI,KAAK,MAAM,CAAC,UAAU,SAAS;AAC7D,kBACG,YAAY,QAAQ,KAAK,SAAS,WACnC,KAAK,SAAS,QACd;AACA,qBAAK,QAAQ;AAAA,kBACV,SAAmB;AAAA,kBACpB,KAAK,SAAS,IAAI,QAAiB;AAAA,gBACrC;AAAA,cACF;AAAA,YACF,CAAC;AAAA,UACH,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,IAEA,SAAS,OAAY,OAAY;AAC/B,WAAK,SAAS,IAAI,OAAO,KAAK;AAAA,IAChC;AAAA,IAEA,IAAI,SAAiB;AACnB,aAAO,KAAK,QAAQ,IAAI,OAAO;AAAA,IACjC;AAAA,EACF","sourcesContent":["import type { Player, PlayerPlugin, Asset } from \"@player-ui/player\";\nimport type { Registry } from \"@player-ui/partial-match-registry\";\n\n/**\n * A player plugin to manage partial-match-mappings by asset id\n * Automatically keeps track of all resolved asset id's and the value they match to in\n * the partial match registry\n */\nexport class PartialMatchFingerprintPlugin implements PlayerPlugin {\n name = \"partial-match-fingerprint\";\n private registry: Registry<any>;\n private mapping: Map<string, any>;\n\n constructor(registry: Registry<any>) {\n this.registry = registry;\n this.mapping = new Map<string, any>();\n }\n\n apply(player: Player) {\n player.hooks.viewController.tap(this.name, (viewController) => {\n viewController.hooks.view.tap(this.name, (view) => {\n view.hooks.resolver.tap(this.name, (resolver) => {\n resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {\n if (\n (resolved && node && node.type === \"asset\") ||\n node.type === \"view\"\n ) {\n this.mapping.set(\n (resolved as Asset).id,\n this.registry.get(resolved as Asset),\n );\n }\n });\n });\n });\n });\n }\n\n register(match: any, value: any) {\n this.registry.set(match, value);\n }\n\n get(assetId: string) {\n return this.mapping.get(assetId);\n }\n}\n"]}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ PartialMatchFingerprintPlugin: () => PartialMatchFingerprintPlugin
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+ var PartialMatchFingerprintPlugin = class {
27
+ constructor(registry) {
28
+ this.name = "partial-match-fingerprint";
29
+ this.registry = registry;
30
+ this.mapping = /* @__PURE__ */ new Map();
31
+ }
32
+ apply(player) {
33
+ player.hooks.viewController.tap(this.name, (viewController) => {
34
+ viewController.hooks.view.tap(this.name, (view) => {
35
+ view.hooks.resolver.tap(this.name, (resolver) => {
36
+ resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {
37
+ if (resolved && node && node.type === "asset" || node.type === "view") {
38
+ this.mapping.set(
39
+ resolved.id,
40
+ this.registry.get(resolved)
41
+ );
42
+ }
43
+ });
44
+ });
45
+ });
46
+ });
47
+ }
48
+ register(match, value) {
49
+ this.registry.set(match, value);
50
+ }
51
+ get(assetId) {
52
+ return this.mapping.get(assetId);
53
+ }
54
+ };
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ PartialMatchFingerprintPlugin
58
+ });
59
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/src/index.ts"],"sourcesContent":["import type { Player, PlayerPlugin, Asset } from \"@player-ui/player\";\nimport type { Registry } from \"@player-ui/partial-match-registry\";\n\n/**\n * A player plugin to manage partial-match-mappings by asset id\n * Automatically keeps track of all resolved asset id's and the value they match to in\n * the partial match registry\n */\nexport class PartialMatchFingerprintPlugin implements PlayerPlugin {\n name = \"partial-match-fingerprint\";\n private registry: Registry<any>;\n private mapping: Map<string, any>;\n\n constructor(registry: Registry<any>) {\n this.registry = registry;\n this.mapping = new Map<string, any>();\n }\n\n apply(player: Player) {\n player.hooks.viewController.tap(this.name, (viewController) => {\n viewController.hooks.view.tap(this.name, (view) => {\n view.hooks.resolver.tap(this.name, (resolver) => {\n resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {\n if (\n (resolved && node && node.type === \"asset\") ||\n node.type === \"view\"\n ) {\n this.mapping.set(\n (resolved as Asset).id,\n this.registry.get(resolved as Asset),\n );\n }\n });\n });\n });\n });\n }\n\n register(match: any, value: any) {\n this.registry.set(match, value);\n }\n\n get(assetId: string) {\n return this.mapping.get(assetId);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,IAAM,gCAAN,MAA4D;AAAA,EAKjE,YAAY,UAAyB;AAJrC,gBAAO;AAKL,SAAK,WAAW;AAChB,SAAK,UAAU,oBAAI,IAAiB;AAAA,EACtC;AAAA,EAEA,MAAM,QAAgB;AACpB,WAAO,MAAM,eAAe,IAAI,KAAK,MAAM,CAAC,mBAAmB;AAC7D,qBAAe,MAAM,KAAK,IAAI,KAAK,MAAM,CAAC,SAAS;AACjD,aAAK,MAAM,SAAS,IAAI,KAAK,MAAM,CAAC,aAAa;AAC/C,mBAAS,MAAM,aAAa,IAAI,KAAK,MAAM,CAAC,UAAU,SAAS;AAC7D,gBACG,YAAY,QAAQ,KAAK,SAAS,WACnC,KAAK,SAAS,QACd;AACA,mBAAK,QAAQ;AAAA,gBACV,SAAmB;AAAA,gBACpB,KAAK,SAAS,IAAI,QAAiB;AAAA,cACrC;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,SAAS,OAAY,OAAY;AAC/B,SAAK,SAAS,IAAI,OAAO,KAAK;AAAA,EAChC;AAAA,EAEA,IAAI,SAAiB;AACnB,WAAO,KAAK,QAAQ,IAAI,OAAO;AAAA,EACjC;AACF;","names":[]}
@@ -1,12 +1,9 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- class PartialMatchFingerprintPlugin {
1
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/src/index.ts
2
+ var PartialMatchFingerprintPlugin = class {
6
3
  constructor(registry) {
7
4
  this.name = "partial-match-fingerprint";
8
5
  this.registry = registry;
9
- this.mapping = new Map();
6
+ this.mapping = /* @__PURE__ */ new Map();
10
7
  }
11
8
  apply(player) {
12
9
  player.hooks.viewController.tap(this.name, (viewController) => {
@@ -14,7 +11,10 @@ class PartialMatchFingerprintPlugin {
14
11
  view.hooks.resolver.tap(this.name, (resolver) => {
15
12
  resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {
16
13
  if (resolved && node && node.type === "asset" || node.type === "view") {
17
- this.mapping.set(resolved.id, this.registry.get(resolved));
14
+ this.mapping.set(
15
+ resolved.id,
16
+ this.registry.get(resolved)
17
+ );
18
18
  }
19
19
  });
20
20
  });
@@ -27,7 +27,8 @@ class PartialMatchFingerprintPlugin {
27
27
  get(assetId) {
28
28
  return this.mapping.get(assetId);
29
29
  }
30
- }
31
-
32
- exports.PartialMatchFingerprintPlugin = PartialMatchFingerprintPlugin;
33
- //# sourceMappingURL=index.cjs.js.map
30
+ };
31
+ export {
32
+ PartialMatchFingerprintPlugin
33
+ };
34
+ //# sourceMappingURL=index.mjs.map
@@ -1,8 +1,9 @@
1
- class PartialMatchFingerprintPlugin {
1
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/src/index.ts
2
+ var PartialMatchFingerprintPlugin = class {
2
3
  constructor(registry) {
3
4
  this.name = "partial-match-fingerprint";
4
5
  this.registry = registry;
5
- this.mapping = new Map();
6
+ this.mapping = /* @__PURE__ */ new Map();
6
7
  }
7
8
  apply(player) {
8
9
  player.hooks.viewController.tap(this.name, (viewController) => {
@@ -10,7 +11,10 @@ class PartialMatchFingerprintPlugin {
10
11
  view.hooks.resolver.tap(this.name, (resolver) => {
11
12
  resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {
12
13
  if (resolved && node && node.type === "asset" || node.type === "view") {
13
- this.mapping.set(resolved.id, this.registry.get(resolved));
14
+ this.mapping.set(
15
+ resolved.id,
16
+ this.registry.get(resolved)
17
+ );
14
18
  }
15
19
  });
16
20
  });
@@ -23,7 +27,8 @@ class PartialMatchFingerprintPlugin {
23
27
  get(assetId) {
24
28
  return this.mapping.get(assetId);
25
29
  }
26
- }
27
-
28
- export { PartialMatchFingerprintPlugin };
29
- //# sourceMappingURL=index.esm.js.map
30
+ };
31
+ export {
32
+ PartialMatchFingerprintPlugin
33
+ };
34
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/src/index.ts"],"sourcesContent":["import type { Player, PlayerPlugin, Asset } from \"@player-ui/player\";\nimport type { Registry } from \"@player-ui/partial-match-registry\";\n\n/**\n * A player plugin to manage partial-match-mappings by asset id\n * Automatically keeps track of all resolved asset id's and the value they match to in\n * the partial match registry\n */\nexport class PartialMatchFingerprintPlugin implements PlayerPlugin {\n name = \"partial-match-fingerprint\";\n private registry: Registry<any>;\n private mapping: Map<string, any>;\n\n constructor(registry: Registry<any>) {\n this.registry = registry;\n this.mapping = new Map<string, any>();\n }\n\n apply(player: Player) {\n player.hooks.viewController.tap(this.name, (viewController) => {\n viewController.hooks.view.tap(this.name, (view) => {\n view.hooks.resolver.tap(this.name, (resolver) => {\n resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {\n if (\n (resolved && node && node.type === \"asset\") ||\n node.type === \"view\"\n ) {\n this.mapping.set(\n (resolved as Asset).id,\n this.registry.get(resolved as Asset),\n );\n }\n });\n });\n });\n });\n }\n\n register(match: any, value: any) {\n this.registry.set(match, value);\n }\n\n get(assetId: string) {\n return this.mapping.get(assetId);\n }\n}\n"],"mappings":";AAQO,IAAM,gCAAN,MAA4D;AAAA,EAKjE,YAAY,UAAyB;AAJrC,gBAAO;AAKL,SAAK,WAAW;AAChB,SAAK,UAAU,oBAAI,IAAiB;AAAA,EACtC;AAAA,EAEA,MAAM,QAAgB;AACpB,WAAO,MAAM,eAAe,IAAI,KAAK,MAAM,CAAC,mBAAmB;AAC7D,qBAAe,MAAM,KAAK,IAAI,KAAK,MAAM,CAAC,SAAS;AACjD,aAAK,MAAM,SAAS,IAAI,KAAK,MAAM,CAAC,aAAa;AAC/C,mBAAS,MAAM,aAAa,IAAI,KAAK,MAAM,CAAC,UAAU,SAAS;AAC7D,gBACG,YAAY,QAAQ,KAAK,SAAS,WACnC,KAAK,SAAS,QACd;AACA,mBAAK,QAAQ;AAAA,gBACV,SAAmB;AAAA,gBACpB,KAAK,SAAS,IAAI,QAAiB;AAAA,cACrC;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,SAAS,OAAY,OAAY;AAC/B,SAAK,SAAS,IAAI,OAAO,KAAK;AAAA,EAChC;AAAA,EAEA,IAAI,SAAiB;AACnB,WAAO,KAAK,QAAQ,IAAI,OAAO;AAAA,EACjC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,67 +1,34 @@
1
1
  {
2
2
  "name": "@player-ui/partial-match-fingerprint-plugin",
3
- "version": "0.8.0--canary.307.9621",
4
- "private": false,
5
- "publishConfig": {
6
- "registry": "https://registry.npmjs.org"
7
- },
8
- "peerDependencies": {
9
- "@player-ui/player": "0.8.0--canary.307.9621"
10
- },
3
+ "version": "0.8.0-next.0",
4
+ "main": "dist/cjs/index.cjs",
11
5
  "dependencies": {
6
+ "@player-ui/partial-match-registry": "0.8.0-next.0",
12
7
  "tapable-ts": "^0.2.3",
13
- "@babel/runtime": "7.15.4"
8
+ "tslib": "^2.6.2"
14
9
  },
15
- "main": "dist/index.cjs.js",
16
- "module": "dist/index.esm.js",
17
- "typings": "dist/index.d.ts",
18
- "sideEffects": false,
19
- "license": "MIT",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/player-ui/player-ui"
10
+ "devDependencies": {
11
+ "@player-ui/make-flow": "workspace:*"
23
12
  },
24
- "bugs": {
25
- "url": "https://github.com/player-ui/player-ui/issues"
13
+ "peerDependencies": {
14
+ "@player-ui/player": "0.8.0-next.0"
26
15
  },
27
- "homepage": "https://player-ui.github.io",
28
- "contributors": [
29
- {
30
- "name": "Adam Dierkens",
31
- "url": "https://github.com/adierkens"
32
- },
33
- {
34
- "name": "Spencer Hamm",
35
- "url": "https://github.com/spentacular"
36
- },
37
- {
38
- "name": "Harris Borawski",
39
- "url": "https://github.com/hborawski"
40
- },
41
- {
42
- "name": "Jeremiah Zucker",
43
- "url": "https://github.com/sugarmanz"
44
- },
45
- {
46
- "name": "Ketan Reddy",
47
- "url": "https://github.com/KetanReddy"
48
- },
49
- {
50
- "name": "Brocollie08",
51
- "url": "https://github.com/brocollie08"
52
- },
53
- {
54
- "name": "Kelly Harrop",
55
- "url": "https://github.com/kharrop"
56
- },
57
- {
58
- "name": "Alejandro Fimbres",
59
- "url": "https://github.com/lexfm"
60
- },
61
- {
62
- "name": "Rafael Campos",
63
- "url": "https://github.com/rafbcampos"
16
+ "module": "dist/index.legacy-esm.js",
17
+ "types": "types/index.d.ts",
18
+ "bundle": "dist/PartialMatchFingerprintPlugin.native.js",
19
+ "sideEffects": false,
20
+ "exports": {
21
+ "./package.json": "./package.json",
22
+ "./dist/index.css": "./dist/index.css",
23
+ ".": {
24
+ "types": "./types/index.d.ts",
25
+ "import": "./dist/index.mjs",
26
+ "default": "./dist/cjs/index.cjs"
64
27
  }
65
- ],
66
- "bundle": "./dist/partial-match-fingerprint-plugin.prod.js"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "src",
32
+ "types"
33
+ ]
67
34
  }
@@ -0,0 +1,42 @@
1
+ import { test, expect } from "vitest";
2
+ import { Player } from "@player-ui/player";
3
+ import { Registry } from "@player-ui/partial-match-registry";
4
+ import { makeFlow } from "@player-ui/make-flow";
5
+ import { PartialMatchFingerprintPlugin } from ".";
6
+
7
+ const action = makeFlow({
8
+ id: "action",
9
+ type: "action",
10
+ value: "Next",
11
+ metaData: {
12
+ role: "someRole",
13
+ },
14
+ });
15
+
16
+ test("Should match just on type", () => {
17
+ const plugin = new PartialMatchFingerprintPlugin(new Registry());
18
+ plugin.register({ type: "action" }, 0);
19
+ const player = new Player({ plugins: [plugin] });
20
+ player.start(action as any);
21
+
22
+ expect(plugin.get("action")).toBe(0);
23
+ });
24
+
25
+ test("Should match just on type and metaData", () => {
26
+ const plugin = new PartialMatchFingerprintPlugin(new Registry());
27
+ plugin.register({ type: "action" }, 0);
28
+ plugin.register({ type: "action", metaData: { role: "someRole" } }, 1);
29
+ const player = new Player({ plugins: [plugin] });
30
+ player.start(action as any);
31
+
32
+ expect(plugin.get("action")).toBe(1);
33
+ });
34
+
35
+ test("Should return undefined if assetId has no match", () => {
36
+ const plugin = new PartialMatchFingerprintPlugin(new Registry());
37
+ plugin.register({ type: "action" }, 0);
38
+ const player = new Player({ plugins: [plugin] });
39
+ player.start(action as any);
40
+
41
+ expect(plugin.get("label")).toBeUndefined();
42
+ });
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type { Player, PlayerPlugin } from '@player-ui/player';
2
- import type { Registry } from '@player-ui/partial-match-registry';
3
- import type { Asset } from '@player-ui/types';
1
+ import type { Player, PlayerPlugin, Asset } from "@player-ui/player";
2
+ import type { Registry } from "@player-ui/partial-match-registry";
4
3
 
5
4
  /**
6
5
  * A player plugin to manage partial-match-mappings by asset id
@@ -8,7 +7,7 @@ import type { Asset } from '@player-ui/types';
8
7
  * the partial match registry
9
8
  */
10
9
  export class PartialMatchFingerprintPlugin implements PlayerPlugin {
11
- name = 'partial-match-fingerprint';
10
+ name = "partial-match-fingerprint";
12
11
  private registry: Registry<any>;
13
12
  private mapping: Map<string, any>;
14
13
 
@@ -23,12 +22,12 @@ export class PartialMatchFingerprintPlugin implements PlayerPlugin {
23
22
  view.hooks.resolver.tap(this.name, (resolver) => {
24
23
  resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {
25
24
  if (
26
- (resolved && node && node.type === 'asset') ||
27
- node.type === 'view'
25
+ (resolved && node && node.type === "asset") ||
26
+ node.type === "view"
28
27
  ) {
29
28
  this.mapping.set(
30
29
  (resolved as Asset).id,
31
- this.registry.get(resolved as Asset)
30
+ this.registry.get(resolved as Asset),
32
31
  );
33
32
  }
34
33
  });
@@ -1,12 +1,11 @@
1
- import { PlayerPlugin, Player } from '@player-ui/player';
2
- import { Registry } from '@player-ui/partial-match-registry';
3
-
1
+ import type { Player, PlayerPlugin } from "@player-ui/player";
2
+ import type { Registry } from "@player-ui/partial-match-registry";
4
3
  /**
5
4
  * A player plugin to manage partial-match-mappings by asset id
6
5
  * Automatically keeps track of all resolved asset id's and the value they match to in
7
6
  * the partial match registry
8
7
  */
9
- declare class PartialMatchFingerprintPlugin implements PlayerPlugin {
8
+ export declare class PartialMatchFingerprintPlugin implements PlayerPlugin {
10
9
  name: string;
11
10
  private registry;
12
11
  private mapping;
@@ -15,5 +14,4 @@ declare class PartialMatchFingerprintPlugin implements PlayerPlugin {
15
14
  register(match: any, value: any): void;
16
15
  get(assetId: string): any;
17
16
  }
18
-
19
- export { PartialMatchFingerprintPlugin };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -1,143 +0,0 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
4
- else if(typeof define === 'function' && define.amd)
5
- define([], factory);
6
- else if(typeof exports === 'object')
7
- exports["PartialMatchFingerprintPlugin"] = factory();
8
- else
9
- root["PartialMatchFingerprintPlugin"] = factory();
10
- })(this, function() {
11
- return /******/ (function(modules) { // webpackBootstrap
12
- /******/ // The module cache
13
- /******/ var installedModules = {};
14
- /******/
15
- /******/ // The require function
16
- /******/ function __webpack_require__(moduleId) {
17
- /******/
18
- /******/ // Check if module is in cache
19
- /******/ if(installedModules[moduleId]) {
20
- /******/ return installedModules[moduleId].exports;
21
- /******/ }
22
- /******/ // Create a new module (and put it into the cache)
23
- /******/ var module = installedModules[moduleId] = {
24
- /******/ i: moduleId,
25
- /******/ l: false,
26
- /******/ exports: {}
27
- /******/ };
28
- /******/
29
- /******/ // Execute the module function
30
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
- /******/
32
- /******/ // Flag the module as loaded
33
- /******/ module.l = true;
34
- /******/
35
- /******/ // Return the exports of the module
36
- /******/ return module.exports;
37
- /******/ }
38
- /******/
39
- /******/
40
- /******/ // expose the modules object (__webpack_modules__)
41
- /******/ __webpack_require__.m = modules;
42
- /******/
43
- /******/ // expose the module cache
44
- /******/ __webpack_require__.c = installedModules;
45
- /******/
46
- /******/ // define getter function for harmony exports
47
- /******/ __webpack_require__.d = function(exports, name, getter) {
48
- /******/ if(!__webpack_require__.o(exports, name)) {
49
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
- /******/ }
51
- /******/ };
52
- /******/
53
- /******/ // define __esModule on exports
54
- /******/ __webpack_require__.r = function(exports) {
55
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
- /******/ }
58
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
- /******/ };
60
- /******/
61
- /******/ // create a fake namespace object
62
- /******/ // mode & 1: value is a module id, require it
63
- /******/ // mode & 2: merge all properties of value into the ns
64
- /******/ // mode & 4: return value when already ns object
65
- /******/ // mode & 8|1: behave like require
66
- /******/ __webpack_require__.t = function(value, mode) {
67
- /******/ if(mode & 1) value = __webpack_require__(value);
68
- /******/ if(mode & 8) return value;
69
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
- /******/ var ns = Object.create(null);
71
- /******/ __webpack_require__.r(ns);
72
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
- /******/ return ns;
75
- /******/ };
76
- /******/
77
- /******/ // getDefaultExport function for compatibility with non-harmony modules
78
- /******/ __webpack_require__.n = function(module) {
79
- /******/ var getter = module && module.__esModule ?
80
- /******/ function getDefault() { return module['default']; } :
81
- /******/ function getModuleExports() { return module; };
82
- /******/ __webpack_require__.d(getter, 'a', getter);
83
- /******/ return getter;
84
- /******/ };
85
- /******/
86
- /******/ // Object.prototype.hasOwnProperty.call
87
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
- /******/
89
- /******/ // __webpack_public_path__
90
- /******/ __webpack_require__.p = "";
91
- /******/
92
- /******/
93
- /******/ // Load entry module and return exports
94
- /******/ return __webpack_require__(__webpack_require__.s = "./bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/dist/index.esm.js");
95
- /******/ })
96
- /************************************************************************/
97
- /******/ ({
98
-
99
- /***/ "./bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/dist/index.esm.js":
100
- /*!*********************************************************************************************!*\
101
- !*** ./bazel-out/k8-fastbuild/bin/plugins/partial-match-fingerprint/core/dist/index.esm.js ***!
102
- \*********************************************************************************************/
103
- /*! exports provided: PartialMatchFingerprintPlugin */
104
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
105
-
106
- "use strict";
107
- __webpack_require__.r(__webpack_exports__);
108
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PartialMatchFingerprintPlugin", function() { return PartialMatchFingerprintPlugin; });
109
- class PartialMatchFingerprintPlugin {
110
- constructor(registry) {
111
- this.name = "partial-match-fingerprint";
112
- this.registry = registry;
113
- this.mapping = new Map();
114
- }
115
- apply(player) {
116
- player.hooks.viewController.tap(this.name, (viewController) => {
117
- viewController.hooks.view.tap(this.name, (view) => {
118
- view.hooks.resolver.tap(this.name, (resolver) => {
119
- resolver.hooks.afterResolve.tap(this.name, (resolved, node) => {
120
- if (resolved && node && node.type === "asset" || node.type === "view") {
121
- this.mapping.set(resolved.id, this.registry.get(resolved));
122
- }
123
- });
124
- });
125
- });
126
- });
127
- }
128
- register(match, value) {
129
- this.registry.set(match, value);
130
- }
131
- get(assetId) {
132
- return this.mapping.get(assetId);
133
- }
134
- }
135
-
136
-
137
- //# sourceMappingURL=index.esm.js.map
138
-
139
-
140
- /***/ })
141
-
142
- /******/ });
143
- });
@@ -1 +0,0 @@
1
- !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports.PartialMatchFingerprintPlugin=t():e.PartialMatchFingerprintPlugin=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t),r.d(t,"PartialMatchFingerprintPlugin",(function(){return n}));class n{constructor(e){this.name="partial-match-fingerprint",this.registry=e,this.mapping=new Map}apply(e){e.hooks.viewController.tap(this.name,(e=>{e.hooks.view.tap(this.name,(e=>{e.hooks.resolver.tap(this.name,(e=>{e.hooks.afterResolve.tap(this.name,((e,t)=>{(e&&t&&"asset"===t.type||"view"===t.type)&&this.mapping.set(e.id,this.registry.get(e))}))}))}))}))}register(e,t){this.registry.set(e,t)}get(e){return this.mapping.get(e)}}}])}));