@player-ui/asset-testing-library 0.0.1-next.1
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 +36 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.esm.js +32 -0
- package/package.json +18 -0
- package/src/index.ts +41 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var player = require('@player-ui/player');
|
|
6
|
+
var assetTransformPlugin = require('@player-ui/asset-transform-plugin');
|
|
7
|
+
var makeFlow = require('@player-ui/make-flow');
|
|
8
|
+
|
|
9
|
+
function runTransform(type, transform, content) {
|
|
10
|
+
const player$1 = new player.Player({
|
|
11
|
+
plugins: [new assetTransformPlugin.AssetTransformPlugin([[{ type }, transform]])]
|
|
12
|
+
});
|
|
13
|
+
player$1.start(makeFlow.makeFlow(content));
|
|
14
|
+
return {
|
|
15
|
+
player: player$1,
|
|
16
|
+
get current() {
|
|
17
|
+
var _a;
|
|
18
|
+
const status = player$1.getState();
|
|
19
|
+
if (status.status === "in-progress") {
|
|
20
|
+
const view = (_a = status.controllers.view.currentView) == null ? void 0 : _a.lastUpdate;
|
|
21
|
+
if (view) {
|
|
22
|
+
return view;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
get controllers() {
|
|
27
|
+
const status = player$1.getState();
|
|
28
|
+
if (status.status === "in-progress") {
|
|
29
|
+
return status.controllers;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.runTransform = runTransform;
|
|
36
|
+
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _player_ui_player from '@player-ui/player';
|
|
2
|
+
import { Asset, TransformFunction, Flow, View, Player } from '@player-ui/player';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A testing utility for transforms
|
|
6
|
+
*/
|
|
7
|
+
declare function runTransform<BaseAssetType extends Asset, TransformedAssetType extends Asset = BaseAssetType>(type: string, transform: TransformFunction<BaseAssetType, TransformedAssetType>, content: BaseAssetType | Flow | Array<View>): {
|
|
8
|
+
player: Player;
|
|
9
|
+
readonly current: TransformedAssetType | undefined;
|
|
10
|
+
readonly controllers: _player_ui_player.ControllerState | undefined;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { runTransform };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Player } from '@player-ui/player';
|
|
2
|
+
import { AssetTransformPlugin } from '@player-ui/asset-transform-plugin';
|
|
3
|
+
import { makeFlow } from '@player-ui/make-flow';
|
|
4
|
+
|
|
5
|
+
function runTransform(type, transform, content) {
|
|
6
|
+
const player = new Player({
|
|
7
|
+
plugins: [new AssetTransformPlugin([[{ type }, transform]])]
|
|
8
|
+
});
|
|
9
|
+
player.start(makeFlow(content));
|
|
10
|
+
return {
|
|
11
|
+
player,
|
|
12
|
+
get current() {
|
|
13
|
+
var _a;
|
|
14
|
+
const status = player.getState();
|
|
15
|
+
if (status.status === "in-progress") {
|
|
16
|
+
const view = (_a = status.controllers.view.currentView) == null ? void 0 : _a.lastUpdate;
|
|
17
|
+
if (view) {
|
|
18
|
+
return view;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
get controllers() {
|
|
23
|
+
const status = player.getState();
|
|
24
|
+
if (status.status === "in-progress") {
|
|
25
|
+
return status.controllers;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { runTransform };
|
|
32
|
+
//# sourceMappingURL=index.esm.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@player-ui/asset-testing-library",
|
|
3
|
+
"version": "0.0.1-next.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"registry": "https://registry.npmjs.org"
|
|
7
|
+
},
|
|
8
|
+
"peerDependencies": {},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@player-ui/binding-grammar": "0.0.1-next.1",
|
|
11
|
+
"@player-ui/types": "0.0.1-next.1",
|
|
12
|
+
"@player-ui/partial-match-registry": "0.0.1-next.1",
|
|
13
|
+
"@babel/runtime": "7.15.4"
|
|
14
|
+
},
|
|
15
|
+
"main": "dist/index.cjs.js",
|
|
16
|
+
"module": "dist/index.esm.js",
|
|
17
|
+
"typings": "dist/index.d.ts"
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TransformFunction, Asset, Flow, View } from '@player-ui/player';
|
|
2
|
+
import { Player } from '@player-ui/player';
|
|
3
|
+
import { AssetTransformPlugin } from '@player-ui/asset-transform-plugin';
|
|
4
|
+
import { makeFlow } from '@player-ui/make-flow';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A testing utility for transforms
|
|
8
|
+
*/
|
|
9
|
+
export function runTransform<
|
|
10
|
+
BaseAssetType extends Asset,
|
|
11
|
+
TransformedAssetType extends Asset = BaseAssetType
|
|
12
|
+
>(
|
|
13
|
+
type: string,
|
|
14
|
+
transform: TransformFunction<BaseAssetType, TransformedAssetType>,
|
|
15
|
+
content: BaseAssetType | Flow | Array<View>
|
|
16
|
+
) {
|
|
17
|
+
const player = new Player({
|
|
18
|
+
plugins: [new AssetTransformPlugin([[{ type }, transform]])],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
player.start(makeFlow(content));
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
player,
|
|
25
|
+
get current() {
|
|
26
|
+
const status = player.getState();
|
|
27
|
+
if (status.status === 'in-progress') {
|
|
28
|
+
const view = status.controllers.view.currentView?.lastUpdate;
|
|
29
|
+
if (view) {
|
|
30
|
+
return view as TransformedAssetType;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
get controllers() {
|
|
35
|
+
const status = player.getState();
|
|
36
|
+
if (status.status === 'in-progress') {
|
|
37
|
+
return status.controllers;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|