@player-ui/a2ui 1.1.0--canary.866.38489
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/cjs/index.cjs +49 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +26 -0
- package/dist/index.mjs +26 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -0
- package/src/__tests__/index.test.tsx +51 -0
- package/src/index.tsx +42 -0
- package/types/index.d.ts +23 -0
|
@@ -0,0 +1,49 @@
|
|
|
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/packages/a2ui/react/src/index.tsx
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
A2UIPlugin: () => import_a2ui_plugin_react2.A2UIPlugin,
|
|
24
|
+
A2UIReactPlayer: () => A2UIReactPlayer,
|
|
25
|
+
ReactPlayer: () => import_react2.ReactPlayer
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
var import_react = require("@player-ui/react");
|
|
29
|
+
var import_a2ui_plugin_react = require("@player-ui/a2ui-plugin-react");
|
|
30
|
+
var import_react2 = require("@player-ui/react");
|
|
31
|
+
var import_a2ui_plugin_react2 = require("@player-ui/a2ui-plugin-react");
|
|
32
|
+
var A2UIReactPlayer = class extends import_react.ReactPlayer {
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
super({
|
|
35
|
+
...options,
|
|
36
|
+
plugins: [
|
|
37
|
+
new import_a2ui_plugin_react.A2UIPlugin(),
|
|
38
|
+
...options.plugins ?? []
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
A2UIPlugin,
|
|
46
|
+
A2UIReactPlayer,
|
|
47
|
+
ReactPlayer
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/packages/a2ui/react/src/index.tsx"],"sourcesContent":["import {\n ReactPlayer,\n type ReactPlayerOptions,\n type ReactPlayerPlugin,\n} from \"@player-ui/react\";\nimport { A2UIPlugin } from \"@player-ui/a2ui-plugin-react\";\n\nexport type A2UIReactPlayerOptions = ReactPlayerOptions;\n\n/**\n * A `ReactPlayer` preconfigured with the A2UI plugin: content-format adapter,\n * asset transforms, expression handlers, and React asset registrations.\n *\n * Extra plugins from `options.plugins` are appended after the A2UI plugin so\n * consumer-supplied taps run later and win on conflict.\n *\n * @example\n * import { A2UIReactPlayer } from \"@player-ui/a2ui\";\n *\n * const player = new A2UIReactPlayer();\n * await player.start(snapshot, { format: \"a2ui\", version: \"0.9\" });\n */\nexport class A2UIReactPlayer extends ReactPlayer {\n constructor(options: A2UIReactPlayerOptions = {}) {\n super({\n ...options,\n plugins: [\n new A2UIPlugin() as unknown as ReactPlayerPlugin,\n ...(options.plugins ?? []),\n ],\n });\n }\n}\n\nexport {\n ReactPlayer,\n type ReactPlayerOptions,\n type ReactPlayerPlugin,\n} from \"@player-ui/react\";\nexport { A2UIPlugin } from \"@player-ui/a2ui-plugin-react\";\nexport type { StartOptions, ContentMeta } from \"@player-ui/player\";\nexport type { A2UISnapshot, A2UIComponent } from \"@player-ui/a2ui-plugin\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AACP,+BAA2B;AA6B3B,IAAAA,gBAIO;AACP,IAAAC,4BAA2B;AAjBpB,IAAM,kBAAN,cAA8B,yBAAY;AAAA,EAC/C,YAAY,UAAkC,CAAC,GAAG;AAChD,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,SAAS;AAAA,QACP,IAAI,oCAAW;AAAA,QACf,GAAI,QAAQ,WAAW,CAAC;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":["import_react","import_a2ui_plugin_react"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/packages/a2ui/react/src/index.tsx
|
|
2
|
+
import {
|
|
3
|
+
ReactPlayer
|
|
4
|
+
} from "@player-ui/react";
|
|
5
|
+
import { A2UIPlugin } from "@player-ui/a2ui-plugin-react";
|
|
6
|
+
import {
|
|
7
|
+
ReactPlayer as ReactPlayer2
|
|
8
|
+
} from "@player-ui/react";
|
|
9
|
+
import { A2UIPlugin as A2UIPlugin2 } from "@player-ui/a2ui-plugin-react";
|
|
10
|
+
var A2UIReactPlayer = class extends ReactPlayer {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
super({
|
|
13
|
+
...options,
|
|
14
|
+
plugins: [
|
|
15
|
+
new A2UIPlugin(),
|
|
16
|
+
...options.plugins ?? []
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
A2UIPlugin2 as A2UIPlugin,
|
|
23
|
+
A2UIReactPlayer,
|
|
24
|
+
ReactPlayer2 as ReactPlayer
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/packages/a2ui/react/src/index.tsx
|
|
2
|
+
import {
|
|
3
|
+
ReactPlayer
|
|
4
|
+
} from "@player-ui/react";
|
|
5
|
+
import { A2UIPlugin } from "@player-ui/a2ui-plugin-react";
|
|
6
|
+
import {
|
|
7
|
+
ReactPlayer as ReactPlayer2
|
|
8
|
+
} from "@player-ui/react";
|
|
9
|
+
import { A2UIPlugin as A2UIPlugin2 } from "@player-ui/a2ui-plugin-react";
|
|
10
|
+
var A2UIReactPlayer = class extends ReactPlayer {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
super({
|
|
13
|
+
...options,
|
|
14
|
+
plugins: [
|
|
15
|
+
new A2UIPlugin(),
|
|
16
|
+
...options.plugins ?? []
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
A2UIPlugin2 as A2UIPlugin,
|
|
23
|
+
A2UIReactPlayer,
|
|
24
|
+
ReactPlayer2 as ReactPlayer
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/packages/a2ui/react/src/index.tsx"],"sourcesContent":["import {\n ReactPlayer,\n type ReactPlayerOptions,\n type ReactPlayerPlugin,\n} from \"@player-ui/react\";\nimport { A2UIPlugin } from \"@player-ui/a2ui-plugin-react\";\n\nexport type A2UIReactPlayerOptions = ReactPlayerOptions;\n\n/**\n * A `ReactPlayer` preconfigured with the A2UI plugin: content-format adapter,\n * asset transforms, expression handlers, and React asset registrations.\n *\n * Extra plugins from `options.plugins` are appended after the A2UI plugin so\n * consumer-supplied taps run later and win on conflict.\n *\n * @example\n * import { A2UIReactPlayer } from \"@player-ui/a2ui\";\n *\n * const player = new A2UIReactPlayer();\n * await player.start(snapshot, { format: \"a2ui\", version: \"0.9\" });\n */\nexport class A2UIReactPlayer extends ReactPlayer {\n constructor(options: A2UIReactPlayerOptions = {}) {\n super({\n ...options,\n plugins: [\n new A2UIPlugin() as unknown as ReactPlayerPlugin,\n ...(options.plugins ?? []),\n ],\n });\n }\n}\n\nexport {\n ReactPlayer,\n type ReactPlayerOptions,\n type ReactPlayerPlugin,\n} from \"@player-ui/react\";\nexport { A2UIPlugin } from \"@player-ui/a2ui-plugin-react\";\nexport type { StartOptions, ContentMeta } from \"@player-ui/player\";\nexport type { A2UISnapshot, A2UIComponent } from \"@player-ui/a2ui-plugin\";\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,kBAAkB;AA6B3B;AAAA,EACE,eAAAA;AAAA,OAGK;AACP,SAAS,cAAAC,mBAAkB;AAjBpB,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,UAAkC,CAAC,GAAG;AAChD,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,SAAS;AAAA,QACP,IAAI,WAAW;AAAA,QACf,GAAI,QAAQ,WAAW,CAAC;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":["ReactPlayer","A2UIPlugin"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sideEffects": false,
|
|
3
|
+
"files": [
|
|
4
|
+
"dist",
|
|
5
|
+
"src",
|
|
6
|
+
"types"
|
|
7
|
+
],
|
|
8
|
+
"name": "@player-ui/a2ui",
|
|
9
|
+
"version": "1.1.0--canary.866.38489",
|
|
10
|
+
"main": "dist/cjs/index.cjs",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@player-ui/a2ui-plugin": "1.1.0--canary.866.38489",
|
|
13
|
+
"@player-ui/a2ui-plugin-react": "1.1.0--canary.866.38489",
|
|
14
|
+
"tslib": "^2.6.2"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@player-ui/player": "1.1.0--canary.866.38489",
|
|
18
|
+
"@player-ui/react": "1.1.0--canary.866.38489",
|
|
19
|
+
"react": "^18.2.0",
|
|
20
|
+
"@types/react": "^18.2.39"
|
|
21
|
+
},
|
|
22
|
+
"module": "dist/index.legacy-esm.js",
|
|
23
|
+
"types": "types/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
|
+
"./dist/index.css": "./dist/index.css",
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./types/index.d.ts",
|
|
29
|
+
"import": "./dist/index.mjs",
|
|
30
|
+
"default": "./dist/cjs/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, test, vitest } from "vitest";
|
|
2
|
+
import type { PlayerPlugin, Player } from "@player-ui/player";
|
|
3
|
+
import { A2UIReactPlayer, type A2UISnapshot } from "..";
|
|
4
|
+
|
|
5
|
+
describe("A2UIReactPlayer", () => {
|
|
6
|
+
test("auto-registers the A2UI plugin (content adapter)", async () => {
|
|
7
|
+
const player = new A2UIReactPlayer();
|
|
8
|
+
|
|
9
|
+
const snapshot: A2UISnapshot = {
|
|
10
|
+
surfaceId: "greet",
|
|
11
|
+
data: { message: "Hello" },
|
|
12
|
+
components: [
|
|
13
|
+
{ id: "root", component: "Text", text: { path: "/message" } },
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// If the A2UI content plugin were missing, transformContent would pass
|
|
18
|
+
// the snapshot through unchanged and setupFlow would fail trying to read
|
|
19
|
+
// `navigation` off it.
|
|
20
|
+
player.start(snapshot, { format: "a2ui" });
|
|
21
|
+
|
|
22
|
+
// Pull the underlying core player and confirm a view was set up.
|
|
23
|
+
const state = (player.player as Player).getState() as {
|
|
24
|
+
controllers?: { view?: { currentView?: { lastUpdate?: unknown } } };
|
|
25
|
+
};
|
|
26
|
+
await vitest.waitFor(() =>
|
|
27
|
+
expect(state.controllers?.view?.currentView?.lastUpdate).toBeDefined(),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const view = state.controllers!.view!.currentView!.lastUpdate as {
|
|
31
|
+
id: string;
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
expect(view.id).toBe("greet");
|
|
35
|
+
expect(view.type).toBe("Text");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("accepts and composes additional plugins", () => {
|
|
39
|
+
let extraApplied = false;
|
|
40
|
+
const extra: PlayerPlugin = {
|
|
41
|
+
name: "extra",
|
|
42
|
+
apply: () => {
|
|
43
|
+
extraApplied = true;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
new A2UIReactPlayer({ plugins: [extra] });
|
|
48
|
+
|
|
49
|
+
expect(extraApplied).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
});
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReactPlayer,
|
|
3
|
+
type ReactPlayerOptions,
|
|
4
|
+
type ReactPlayerPlugin,
|
|
5
|
+
} from "@player-ui/react";
|
|
6
|
+
import { A2UIPlugin } from "@player-ui/a2ui-plugin-react";
|
|
7
|
+
|
|
8
|
+
export type A2UIReactPlayerOptions = ReactPlayerOptions;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A `ReactPlayer` preconfigured with the A2UI plugin: content-format adapter,
|
|
12
|
+
* asset transforms, expression handlers, and React asset registrations.
|
|
13
|
+
*
|
|
14
|
+
* Extra plugins from `options.plugins` are appended after the A2UI plugin so
|
|
15
|
+
* consumer-supplied taps run later and win on conflict.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { A2UIReactPlayer } from "@player-ui/a2ui";
|
|
19
|
+
*
|
|
20
|
+
* const player = new A2UIReactPlayer();
|
|
21
|
+
* await player.start(snapshot, { format: "a2ui", version: "0.9" });
|
|
22
|
+
*/
|
|
23
|
+
export class A2UIReactPlayer extends ReactPlayer {
|
|
24
|
+
constructor(options: A2UIReactPlayerOptions = {}) {
|
|
25
|
+
super({
|
|
26
|
+
...options,
|
|
27
|
+
plugins: [
|
|
28
|
+
new A2UIPlugin() as unknown as ReactPlayerPlugin,
|
|
29
|
+
...(options.plugins ?? []),
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
ReactPlayer,
|
|
37
|
+
type ReactPlayerOptions,
|
|
38
|
+
type ReactPlayerPlugin,
|
|
39
|
+
} from "@player-ui/react";
|
|
40
|
+
export { A2UIPlugin } from "@player-ui/a2ui-plugin-react";
|
|
41
|
+
export type { StartOptions, ContentMeta } from "@player-ui/player";
|
|
42
|
+
export type { A2UISnapshot, A2UIComponent } from "@player-ui/a2ui-plugin";
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactPlayer, type ReactPlayerOptions } from "@player-ui/react";
|
|
2
|
+
export type A2UIReactPlayerOptions = ReactPlayerOptions;
|
|
3
|
+
/**
|
|
4
|
+
* A `ReactPlayer` preconfigured with the A2UI plugin: content-format adapter,
|
|
5
|
+
* asset transforms, expression handlers, and React asset registrations.
|
|
6
|
+
*
|
|
7
|
+
* Extra plugins from `options.plugins` are appended after the A2UI plugin so
|
|
8
|
+
* consumer-supplied taps run later and win on conflict.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { A2UIReactPlayer } from "@player-ui/a2ui";
|
|
12
|
+
*
|
|
13
|
+
* const player = new A2UIReactPlayer();
|
|
14
|
+
* await player.start(snapshot, { format: "a2ui", version: "0.9" });
|
|
15
|
+
*/
|
|
16
|
+
export declare class A2UIReactPlayer extends ReactPlayer {
|
|
17
|
+
constructor(options?: A2UIReactPlayerOptions);
|
|
18
|
+
}
|
|
19
|
+
export { ReactPlayer, type ReactPlayerOptions, type ReactPlayerPlugin, } from "@player-ui/react";
|
|
20
|
+
export { A2UIPlugin } from "@player-ui/a2ui-plugin-react";
|
|
21
|
+
export type { StartOptions, ContentMeta } from "@player-ui/player";
|
|
22
|
+
export type { A2UISnapshot, A2UIComponent } from "@player-ui/a2ui-plugin";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|