@player-ui/async-node-plugin 0.11.1-next.0 → 0.11.2-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/package.json
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/async-node-plugin",
|
|
9
|
-
"version": "0.11.
|
|
9
|
+
"version": "0.11.2-next.0",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@player-ui/player": "0.11.
|
|
12
|
+
"@player-ui/player": "0.11.2-next.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@player-ui/reference-assets-plugin": "workspace:*"
|
|
15
|
+
"@player-ui/reference-assets-plugin": "workspace:*",
|
|
16
|
+
"@player-ui/check-path-plugin": "workspace:*"
|
|
16
17
|
},
|
|
17
18
|
"module": "dist/index.legacy-esm.js",
|
|
18
19
|
"types": "types/index.d.ts",
|
|
@@ -4,6 +4,7 @@ import { Player, Parser } from "@player-ui/player";
|
|
|
4
4
|
import { waitFor } from "@testing-library/react";
|
|
5
5
|
import { AsyncNodePlugin, AsyncNodePluginPlugin } from "../index";
|
|
6
6
|
import { ReferenceAssetsPlugin } from "@player-ui/reference-assets-plugin";
|
|
7
|
+
import { CheckPathPlugin } from "@player-ui/check-path-plugin";
|
|
7
8
|
|
|
8
9
|
describe("view", () => {
|
|
9
10
|
const basicFRFWithActions = {
|
|
@@ -54,6 +55,9 @@ describe("view", () => {
|
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
],
|
|
58
|
+
data: {
|
|
59
|
+
foo: true,
|
|
60
|
+
},
|
|
57
61
|
navigation: {
|
|
58
62
|
BEGIN: "FLOW_1",
|
|
59
63
|
FLOW_1: {
|
|
@@ -1029,6 +1033,213 @@ describe("view", () => {
|
|
|
1029
1033
|
expect(view?.values[2].asset.type).toBe("text");
|
|
1030
1034
|
expect(view?.values[2].asset.value).toBe("chained async content");
|
|
1031
1035
|
});
|
|
1036
|
+
|
|
1037
|
+
test("chat-message asset - resolve chained chat-message with CheckPathPlugin", async () => {
|
|
1038
|
+
const plugin = new AsyncNodePlugin({
|
|
1039
|
+
plugins: [new AsyncNodePluginPlugin()],
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
let deferredResolve: ((value: any) => void) | undefined;
|
|
1043
|
+
|
|
1044
|
+
plugin.hooks.onAsyncNode.tap("test", async (node) => {
|
|
1045
|
+
return new Promise((resolve) => {
|
|
1046
|
+
deferredResolve = resolve;
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
let updateNumber = 0;
|
|
1051
|
+
|
|
1052
|
+
const checkPathPlugin = new CheckPathPlugin();
|
|
1053
|
+
|
|
1054
|
+
const plugins = [plugin, new ReferenceAssetsPlugin(), checkPathPlugin];
|
|
1055
|
+
|
|
1056
|
+
const player = new Player({
|
|
1057
|
+
plugins: plugins,
|
|
1058
|
+
});
|
|
1059
|
+
|
|
1060
|
+
player.hooks.viewController.tap("async-node-test", (vc) => {
|
|
1061
|
+
vc.hooks.view.tap("async-node-test", (view) => {
|
|
1062
|
+
view.hooks.onUpdate.tap("async-node-test", (update) => {
|
|
1063
|
+
updateNumber++;
|
|
1064
|
+
});
|
|
1065
|
+
});
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
player.start(chatMessageContent as any);
|
|
1069
|
+
|
|
1070
|
+
let view = (player.getState() as InProgressState).controllers.view
|
|
1071
|
+
.currentView?.lastUpdate;
|
|
1072
|
+
|
|
1073
|
+
expect(view).toBeDefined();
|
|
1074
|
+
expect(view?.values[0].asset.type).toBe("text");
|
|
1075
|
+
expect(view?.values[0].asset.value).toBe("chat message");
|
|
1076
|
+
expect(updateNumber).toBe(1);
|
|
1077
|
+
|
|
1078
|
+
await waitFor(() => {
|
|
1079
|
+
expect(deferredResolve).toBeDefined();
|
|
1080
|
+
});
|
|
1081
|
+
|
|
1082
|
+
if (deferredResolve) {
|
|
1083
|
+
deferredResolve({
|
|
1084
|
+
asset: {
|
|
1085
|
+
id: "chat-1",
|
|
1086
|
+
type: "chat-message",
|
|
1087
|
+
value: {
|
|
1088
|
+
asset: {
|
|
1089
|
+
id: "text-1",
|
|
1090
|
+
type: "text",
|
|
1091
|
+
value: "async content",
|
|
1092
|
+
},
|
|
1093
|
+
},
|
|
1094
|
+
},
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
await waitFor(() => {
|
|
1099
|
+
expect(updateNumber).toBe(2);
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
view = (player.getState() as InProgressState).controllers.view.currentView
|
|
1103
|
+
?.lastUpdate;
|
|
1104
|
+
|
|
1105
|
+
expect(view?.values[1].asset.type).toBe("text");
|
|
1106
|
+
expect(view?.values[1].asset.value).toBe("async content");
|
|
1107
|
+
|
|
1108
|
+
expect(checkPathPlugin.getParent("text-1")).toStrictEqual({
|
|
1109
|
+
id: "collection-async-1",
|
|
1110
|
+
type: "collection",
|
|
1111
|
+
values: [
|
|
1112
|
+
{
|
|
1113
|
+
asset: {
|
|
1114
|
+
id: "2",
|
|
1115
|
+
type: "text",
|
|
1116
|
+
value: "chat message",
|
|
1117
|
+
},
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
asset: {
|
|
1121
|
+
id: "text-1",
|
|
1122
|
+
type: "text",
|
|
1123
|
+
value: "async content",
|
|
1124
|
+
},
|
|
1125
|
+
},
|
|
1126
|
+
],
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
if (deferredResolve) {
|
|
1130
|
+
deferredResolve({
|
|
1131
|
+
asset: {
|
|
1132
|
+
id: "chat-2",
|
|
1133
|
+
type: "chat-message",
|
|
1134
|
+
value: {
|
|
1135
|
+
asset: {
|
|
1136
|
+
id: "text-2",
|
|
1137
|
+
type: "text",
|
|
1138
|
+
value: "async content2",
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
await waitFor(() => {
|
|
1146
|
+
expect(updateNumber).toBe(3);
|
|
1147
|
+
});
|
|
1148
|
+
|
|
1149
|
+
view = (player.getState() as InProgressState).controllers.view.currentView
|
|
1150
|
+
?.lastUpdate;
|
|
1151
|
+
|
|
1152
|
+
expect(view?.values[2].asset.type).toBe("text");
|
|
1153
|
+
expect(view?.values[2].asset.value).toBe("async content2");
|
|
1154
|
+
expect(checkPathPlugin.getParent("text-2")).toStrictEqual({
|
|
1155
|
+
id: "collection-async-1",
|
|
1156
|
+
type: "collection",
|
|
1157
|
+
values: [
|
|
1158
|
+
{
|
|
1159
|
+
asset: {
|
|
1160
|
+
id: "2",
|
|
1161
|
+
type: "text",
|
|
1162
|
+
value: "chat message",
|
|
1163
|
+
},
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
asset: {
|
|
1167
|
+
id: "text-1",
|
|
1168
|
+
type: "text",
|
|
1169
|
+
value: "async content",
|
|
1170
|
+
},
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
asset: {
|
|
1174
|
+
id: "text-2",
|
|
1175
|
+
type: "text",
|
|
1176
|
+
value: "async content2",
|
|
1177
|
+
},
|
|
1178
|
+
},
|
|
1179
|
+
],
|
|
1180
|
+
});
|
|
1181
|
+
|
|
1182
|
+
if (deferredResolve) {
|
|
1183
|
+
deferredResolve({
|
|
1184
|
+
asset: {
|
|
1185
|
+
id: "chat-3",
|
|
1186
|
+
type: "chat-message",
|
|
1187
|
+
value: {
|
|
1188
|
+
asset: {
|
|
1189
|
+
id: "text-3",
|
|
1190
|
+
type: "text",
|
|
1191
|
+
value: "async content3",
|
|
1192
|
+
},
|
|
1193
|
+
},
|
|
1194
|
+
},
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
await waitFor(() => {
|
|
1199
|
+
expect(updateNumber).toBe(4);
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
view = (player.getState() as InProgressState).controllers.view.currentView
|
|
1203
|
+
?.lastUpdate;
|
|
1204
|
+
|
|
1205
|
+
expect(view?.values[3].asset.type).toBe("text");
|
|
1206
|
+
expect(view?.values[3].asset.value).toBe("async content3");
|
|
1207
|
+
|
|
1208
|
+
expect(checkPathPlugin.getParent("text-3")).toStrictEqual({
|
|
1209
|
+
id: "collection-async-1",
|
|
1210
|
+
type: "collection",
|
|
1211
|
+
values: [
|
|
1212
|
+
{
|
|
1213
|
+
asset: {
|
|
1214
|
+
id: "2",
|
|
1215
|
+
type: "text",
|
|
1216
|
+
value: "chat message",
|
|
1217
|
+
},
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
asset: {
|
|
1221
|
+
id: "text-1",
|
|
1222
|
+
type: "text",
|
|
1223
|
+
value: "async content",
|
|
1224
|
+
},
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
asset: {
|
|
1228
|
+
id: "text-2",
|
|
1229
|
+
type: "text",
|
|
1230
|
+
value: "async content2",
|
|
1231
|
+
},
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
asset: {
|
|
1235
|
+
id: "text-3",
|
|
1236
|
+
type: "text",
|
|
1237
|
+
value: "async content3",
|
|
1238
|
+
},
|
|
1239
|
+
},
|
|
1240
|
+
],
|
|
1241
|
+
});
|
|
1242
|
+
});
|
|
1032
1243
|
});
|
|
1033
1244
|
|
|
1034
1245
|
describe("parser", () => {
|