@player-ui/asset-transform-plugin 0.0.1-next.8 → 0.1.1-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
@@ -42,6 +42,49 @@ function compose(...args) {
42
42
  };
43
43
  }
44
44
 
45
+ var __defProp = Object.defineProperty;
46
+ var __defProps = Object.defineProperties;
47
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
48
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
49
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
50
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
51
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
52
+ var __spreadValues = (a, b) => {
53
+ for (var prop in b || (b = {}))
54
+ if (__hasOwnProp.call(b, prop))
55
+ __defNormalProp(a, prop, b[prop]);
56
+ if (__getOwnPropSymbols)
57
+ for (var prop of __getOwnPropSymbols(b)) {
58
+ if (__propIsEnum.call(b, prop))
59
+ __defNormalProp(a, prop, b[prop]);
60
+ }
61
+ return a;
62
+ };
63
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
64
+ const propertiesToSkipTransform = (parameters) => {
65
+ return (asset) => {
66
+ var _a, _b, _c, _d;
67
+ const skipArray = (_c = (_b = (_a = asset.plugins) == null ? void 0 : _a.stringResolver) == null ? void 0 : _b.propertiesToSkip) != null ? _c : [];
68
+ const parameterArray = parameters.filter((element) => {
69
+ return element !== "";
70
+ });
71
+ if (parameterArray.length === 0) {
72
+ return asset;
73
+ }
74
+ if (skipArray.length > 0 && skipArray.every((arr) => parameterArray.includes(arr)) && parameterArray.every((arr) => skipArray.includes(arr))) {
75
+ return asset;
76
+ }
77
+ const addParams = new Set([...skipArray, ...parameterArray]);
78
+ return __spreadProps(__spreadValues({}, asset), {
79
+ plugins: __spreadProps(__spreadValues({}, asset.plugins), {
80
+ stringResolver: __spreadProps(__spreadValues({}, (_d = asset == null ? void 0 : asset.plugins) == null ? void 0 : _d.stringResolver), {
81
+ propertiesToSkip: [...addParams]
82
+ })
83
+ })
84
+ });
85
+ };
86
+ };
87
+
45
88
  function maybeCompose(maybeFn) {
46
89
  if (typeof maybeFn === "object") {
47
90
  return maybeFn;
@@ -76,4 +119,5 @@ class AssetTransformPlugin {
76
119
  exports.AssetTransformPlugin = AssetTransformPlugin;
77
120
  exports.compose = compose;
78
121
  exports.composeBefore = composeBefore;
122
+ exports.propertiesToSkipTransform = propertiesToSkipTransform;
79
123
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts CHANGED
@@ -15,6 +15,13 @@ declare function composeBefore(...args: BeforeTransformFunction<any>[]): Transfo
15
15
  */
16
16
  declare function compose(...args: Array<TransformFunction<any> | TransformFunctions>): TransformFunctions;
17
17
 
18
+ /**
19
+ * Passes a property to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist
20
+ *
21
+ * @param asset - Asset to apply the transform to
22
+ */
23
+ declare const propertiesToSkipTransform: (parameters: string[]) => BeforeTransformFunction;
24
+
18
25
  declare type TransformType = TransformFunction<any> | TransformFunctions;
19
26
  declare type TransformRegistryEntries = Array<[any, TransformType]>;
20
27
  declare type AssetTransformInit = Registry<TransformType> | TransformRegistryEntries;
@@ -29,4 +36,4 @@ declare class AssetTransformPlugin implements PlayerPlugin {
29
36
  apply(player: Player): void;
30
37
  }
31
38
 
32
- export { AssetTransformInit, AssetTransformPlugin, TransformRegistryEntries, TransformType, compose, composeBefore };
39
+ export { AssetTransformInit, AssetTransformPlugin, TransformRegistryEntries, TransformType, compose, composeBefore, propertiesToSkipTransform };
package/dist/index.esm.js CHANGED
@@ -38,6 +38,49 @@ function compose(...args) {
38
38
  };
39
39
  }
40
40
 
41
+ var __defProp = Object.defineProperty;
42
+ var __defProps = Object.defineProperties;
43
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
44
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
45
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
46
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
47
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
48
+ var __spreadValues = (a, b) => {
49
+ for (var prop in b || (b = {}))
50
+ if (__hasOwnProp.call(b, prop))
51
+ __defNormalProp(a, prop, b[prop]);
52
+ if (__getOwnPropSymbols)
53
+ for (var prop of __getOwnPropSymbols(b)) {
54
+ if (__propIsEnum.call(b, prop))
55
+ __defNormalProp(a, prop, b[prop]);
56
+ }
57
+ return a;
58
+ };
59
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
60
+ const propertiesToSkipTransform = (parameters) => {
61
+ return (asset) => {
62
+ var _a, _b, _c, _d;
63
+ const skipArray = (_c = (_b = (_a = asset.plugins) == null ? void 0 : _a.stringResolver) == null ? void 0 : _b.propertiesToSkip) != null ? _c : [];
64
+ const parameterArray = parameters.filter((element) => {
65
+ return element !== "";
66
+ });
67
+ if (parameterArray.length === 0) {
68
+ return asset;
69
+ }
70
+ if (skipArray.length > 0 && skipArray.every((arr) => parameterArray.includes(arr)) && parameterArray.every((arr) => skipArray.includes(arr))) {
71
+ return asset;
72
+ }
73
+ const addParams = new Set([...skipArray, ...parameterArray]);
74
+ return __spreadProps(__spreadValues({}, asset), {
75
+ plugins: __spreadProps(__spreadValues({}, asset.plugins), {
76
+ stringResolver: __spreadProps(__spreadValues({}, (_d = asset == null ? void 0 : asset.plugins) == null ? void 0 : _d.stringResolver), {
77
+ propertiesToSkip: [...addParams]
78
+ })
79
+ })
80
+ });
81
+ };
82
+ };
83
+
41
84
  function maybeCompose(maybeFn) {
42
85
  if (typeof maybeFn === "object") {
43
86
  return maybeFn;
@@ -69,5 +112,5 @@ class AssetTransformPlugin {
69
112
  }
70
113
  }
71
114
 
72
- export { AssetTransformPlugin, compose, composeBefore };
115
+ export { AssetTransformPlugin, compose, composeBefore, propertiesToSkipTransform };
73
116
  //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,20 +1,60 @@
1
1
  {
2
2
  "name": "@player-ui/asset-transform-plugin",
3
- "version": "0.0.1-next.8",
3
+ "version": "0.1.1-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.0.1-next.8",
10
- "@player-ui/types": "0.0.1-next.8",
11
- "@player-ui/view": "0.0.1-next.8"
9
+ "@player-ui/player": "0.1.1-next.0",
10
+ "@player-ui/types": "0.1.1-next.0",
11
+ "@player-ui/view": "0.1.1-next.0"
12
12
  },
13
13
  "dependencies": {
14
- "@player-ui/partial-match-registry": "0.0.1-next.8",
14
+ "@player-ui/partial-match-registry": "0.1.1-next.0",
15
15
  "@babel/runtime": "7.15.4"
16
16
  },
17
17
  "main": "dist/index.cjs.js",
18
18
  "module": "dist/index.esm.js",
19
- "typings": "dist/index.d.ts"
19
+ "typings": "dist/index.d.ts",
20
+ "sideEffects": false,
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/player-ui/player-ui"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/player-ui/player-ui/issues"
28
+ },
29
+ "homepage": "https://player-ui.github.io",
30
+ "contributors": [
31
+ {
32
+ "name": "Adam Dierkens",
33
+ "url": "https://github.com/adierkens"
34
+ },
35
+ {
36
+ "name": "Spencer Hamm",
37
+ "url": "https://github.com/spentacular"
38
+ },
39
+ {
40
+ "name": "Harris Borawski",
41
+ "url": "https://github.com/hborawski"
42
+ },
43
+ {
44
+ "name": "Jeremiah Zucker",
45
+ "url": "https://github.com/sugarmanz"
46
+ },
47
+ {
48
+ "name": "Ketan Reddy",
49
+ "url": "https://github.com/KetanReddy"
50
+ },
51
+ {
52
+ "name": "Brocollie08",
53
+ "url": "https://github.com/brocollie08"
54
+ },
55
+ {
56
+ "name": "Kelly Harrop",
57
+ "url": "https://github.com/kharrop"
58
+ }
59
+ ]
20
60
  }
package/src/index.ts CHANGED
@@ -9,6 +9,8 @@ import { Registry } from '@player-ui/partial-match-registry';
9
9
  import { compose } from './utils';
10
10
 
11
11
  export * from './utils';
12
+ export * from './propertiesToSkip';
13
+
12
14
  export type TransformType = TransformFunction<any> | TransformFunctions;
13
15
  export type TransformRegistryEntries = Array<[any, TransformType]>;
14
16
  export type AssetTransformInit =
@@ -0,0 +1,44 @@
1
+ import type { BeforeTransformFunction } from '@player-ui/player';
2
+
3
+ /**
4
+ * Passes a property to the plugins.stringResolver.propertiesToSkip array or creates it if it doesn't exist
5
+ *
6
+ * @param asset - Asset to apply the transform to
7
+ */
8
+ export const propertiesToSkipTransform = (
9
+ parameters: string[]
10
+ ): BeforeTransformFunction => {
11
+ return (asset) => {
12
+ const skipArray = asset.plugins?.stringResolver?.propertiesToSkip ?? [];
13
+
14
+ /** makes sure there are no empty strings in the array */
15
+ const parameterArray = parameters.filter((element) => {
16
+ return element !== '';
17
+ });
18
+
19
+ if (parameterArray.length === 0) {
20
+ return asset;
21
+ }
22
+
23
+ if (
24
+ skipArray.length > 0 &&
25
+ skipArray.every((arr) => parameterArray.includes(arr)) &&
26
+ parameterArray.every((arr) => skipArray.includes(arr))
27
+ ) {
28
+ return asset;
29
+ }
30
+
31
+ const addParams: Set<string> = new Set([...skipArray, ...parameterArray]);
32
+
33
+ return {
34
+ ...asset,
35
+ plugins: {
36
+ ...asset.plugins,
37
+ stringResolver: {
38
+ ...asset?.plugins?.stringResolver,
39
+ propertiesToSkip: [...addParams],
40
+ },
41
+ },
42
+ };
43
+ };
44
+ };