@player-ui/external-action-plugin 0.13.0 → 0.14.0-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.
|
@@ -54,8 +54,12 @@ function _instanceof(left, right) {
|
|
|
54
54
|
return left instanceof right;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
function _type_of(obj) {
|
|
58
|
+
"@swc/helpers - typeof";
|
|
59
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
60
|
+
}
|
|
57
61
|
function _ts_generator(thisArg, body) {
|
|
58
|
-
var f, y, t,
|
|
62
|
+
var f, y, t, _ = {
|
|
59
63
|
label: 0,
|
|
60
64
|
sent: function() {
|
|
61
65
|
if (t[0] & 1) throw t[1];
|
|
@@ -63,12 +67,8 @@ function _ts_generator(thisArg, body) {
|
|
|
63
67
|
},
|
|
64
68
|
trys: [],
|
|
65
69
|
ops: []
|
|
66
|
-
};
|
|
67
|
-
return g = {
|
|
68
|
-
next: verb(0),
|
|
69
|
-
"throw": verb(1),
|
|
70
|
-
"return": verb(2)
|
|
71
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
70
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
71
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
72
72
|
return this;
|
|
73
73
|
}), g;
|
|
74
74
|
function verb(n) {
|
|
@@ -81,7 +81,7 @@ function _ts_generator(thisArg, body) {
|
|
|
81
81
|
}
|
|
82
82
|
function step(op) {
|
|
83
83
|
if (f) throw new TypeError("Generator is already executing.");
|
|
84
|
-
while(_)try {
|
|
84
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
85
85
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
86
86
|
if (y = 0, t) op = [
|
|
87
87
|
op[0] & 2,
|
|
@@ -161,7 +161,7 @@ var ExternalActionPlugin = function() {
|
|
|
161
161
|
});
|
|
162
162
|
};
|
|
163
163
|
var __copyProps = function(to, from, except, desc) {
|
|
164
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
164
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
165
165
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
166
166
|
try {
|
|
167
167
|
var _loop = function() {
|
|
@@ -219,63 +219,64 @@ var ExternalActionPlugin = function() {
|
|
|
219
219
|
flow.hooks.transition.tap(_this.name, function(fromState, toState) {
|
|
220
220
|
var state = toState.value;
|
|
221
221
|
if (state.state_type === "EXTERNAL") {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
222
|
+
setTimeout(function() {
|
|
223
|
+
return _async_to_generator(function() {
|
|
224
|
+
var shouldTransition, currentState, transitionValue, latestState, error;
|
|
225
|
+
return _ts_generator(this, function(_state) {
|
|
226
|
+
switch(_state.label){
|
|
227
|
+
case 0:
|
|
228
|
+
shouldTransition = function(currentState2) {
|
|
229
|
+
var _currentState2_controllers_flow_current_currentState, _currentState2_controllers_flow_current;
|
|
230
|
+
return currentState2.status === "in-progress" && ((_currentState2_controllers_flow_current = currentState2.controllers.flow.current) === null || _currentState2_controllers_flow_current === void 0 ? void 0 : (_currentState2_controllers_flow_current_currentState = _currentState2_controllers_flow_current.currentState) === null || _currentState2_controllers_flow_current_currentState === void 0 ? void 0 : _currentState2_controllers_flow_current_currentState.value) === state;
|
|
231
|
+
};
|
|
232
|
+
currentState = player.getState();
|
|
233
|
+
if (!shouldTransition(currentState)) return [
|
|
234
|
+
3,
|
|
235
|
+
4
|
|
236
|
+
];
|
|
237
|
+
_state.label = 1;
|
|
238
|
+
case 1:
|
|
239
|
+
_state.trys.push([
|
|
240
|
+
1,
|
|
241
|
+
3,
|
|
242
|
+
,
|
|
243
|
+
4
|
|
244
|
+
]);
|
|
245
|
+
return [
|
|
246
|
+
4,
|
|
247
|
+
this.handler(state, currentState.controllers)
|
|
248
|
+
];
|
|
249
|
+
case 2:
|
|
250
|
+
transitionValue = _state.sent();
|
|
251
|
+
if (transitionValue !== void 0) {
|
|
252
|
+
latestState = player.getState();
|
|
253
|
+
if (shouldTransition(latestState)) {
|
|
254
|
+
latestState.controllers.flow.transition(transitionValue);
|
|
255
|
+
} else {
|
|
256
|
+
player.logger.warn("External state resolved with [".concat(transitionValue, "], but Player already navigated away from [").concat(toState.name, "]"));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return [
|
|
260
|
+
3,
|
|
261
|
+
4
|
|
262
|
+
];
|
|
263
|
+
case 3:
|
|
264
|
+
error = _state.sent();
|
|
265
|
+
if (_instanceof(error, Error)) {
|
|
266
|
+
currentState.fail(error);
|
|
257
267
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
4
|
|
271
|
-
];
|
|
272
|
-
case 4:
|
|
273
|
-
return [
|
|
274
|
-
2
|
|
275
|
-
];
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}), 0);
|
|
268
|
+
return [
|
|
269
|
+
3,
|
|
270
|
+
4
|
|
271
|
+
];
|
|
272
|
+
case 4:
|
|
273
|
+
return [
|
|
274
|
+
2
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}).call(_this);
|
|
279
|
+
}, 0);
|
|
279
280
|
}
|
|
280
281
|
});
|
|
281
282
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/
|
|
1
|
+
{"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2607/execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-action/core/dist/index.global.js","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-action/core/src/index.ts"],"names":["ExternalActionPlugin","__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","src_exports","handler","apply","player","hooks","flowController","tap","flow","transition","fromState","toState","state","state_type","setTimeout","shouldTransition","currentState","transitionValue","latestState","error","status","controllers","current","getState","logger","warn","Error","fail"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,uBAAuB,AAAC;IAC1B,IAAIC,YAAYC,OAAOC,cAAc;IACrC,IAAIC,mBAAmBF,OAAOG,wBAAwB;IACtD,IAAIC,oBAAoBJ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CAAKD,GAAA,CAAI,MAAKnB,IAAA,EAAM,SAACoB;4BACxCA,KAAKH,KAAA,CAAMI,UAAA,CAAWF,GAAA,CAAI,MAAKnB,IAAA,EAAM,SAACsB,WAAWC;gCAC/C,IAAQX,AAAOY,QAAUD,QAAjBX;gCACR,IAAIY,MAAMC,UAAA,KAAe,YAAY;oCACnCC,WAAW;;gDAEHC,kBAOAC,cAGIC,iBAOEC,aASDC;;;;wDA1BLJ,mBAAmB,SACvBC;gEAGAA,sDAAAA;mEADAA,cAAaI,MAAA,KAAW,iBACxBJ,EAAAA,0CAAAA,cAAaK,WAAA,CAAYb,IAAA,CAAKc,OAAA,cAA9BN,+DAAAA,uDAAAA,wCAAuCA,YAAA,cAAvCA,2EAAAA,qDAAqDhB,KAAA,MACnDY;;wDAEEI,eAAeZ,OAAOmB,QAAA;6DACxBR,iBAAiBC,eAAjBD;;;;;;;;;;;;wDAEwB;;4DAAM,IAAA,CAAKb,OAAA,CACjCU,OACAI,aAAaK,WAAA;;;wDAFTJ,kBAAkB;wDAKxB,IAAIA,oBAAoB,KAAA,GAAW;4DAE3BC,cAAcd,OAAOmB,QAAA;4DAC3B,IAAIR,iBAAiBG,cAAc;gEACjCA,YAAYG,WAAA,CAAYb,IAAA,CAAKC,UAAA,CAAWQ;4DAC1C,OAAO;gEACLb,OAAOoB,MAAA,CAAOC,IAAA,CACZ,iCAA8Fd,OAA7DM,iBAAe,+CAA0D,OAAZN,QAAQvB,IAAI,EAAA;4DAE9G;wDACF;;;;;;wDACO+B;wDACP,IAAIA,AAAA,YAAAA,OAAiBO,QAAO;4DAC1BV,aAAaW,IAAA,CAAKR;wDACpB;;;;;;;;;;;wCAGN;uCAAG;gCACL;4BACF;wBACF;oBACF;gBACF;;;;;IDDA,OAAOrB,aAAaG;AACtB","sourcesContent":["\"use strict\";\nvar ExternalActionPlugin = (() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-action/core/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n ExternalActionPlugin: () => ExternalActionPlugin\n });\n var ExternalActionPlugin = class {\n constructor(handler) {\n this.name = \"ExternalActionPlugin\";\n this.handler = handler;\n }\n apply(player) {\n player.hooks.flowController.tap(this.name, (flowController) => {\n flowController.hooks.flow.tap(this.name, (flow) => {\n flow.hooks.transition.tap(this.name, (fromState, toState) => {\n const { value: state } = toState;\n if (state.state_type === \"EXTERNAL\") {\n setTimeout(async () => {\n const shouldTransition = (currentState2) => currentState2.status === \"in-progress\" && currentState2.controllers.flow.current?.currentState?.value === state;\n const currentState = player.getState();\n if (shouldTransition(currentState)) {\n try {\n const transitionValue = await this.handler(\n state,\n currentState.controllers\n );\n if (transitionValue !== void 0) {\n const latestState = player.getState();\n if (shouldTransition(latestState)) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\n }\n }, 0);\n }\n });\n });\n });\n }\n };\n return __toCommonJS(src_exports);\n})();\n","import type {\n Player,\n PlayerPlugin,\n InProgressState,\n PlayerFlowState,\n NavigationFlowExternalState,\n} from \"@player-ui/player\";\n\nexport type ExternalStateHandler = (\n state: NavigationFlowExternalState,\n options: InProgressState[\"controllers\"],\n) => string | undefined | Promise<string | undefined>;\n\n/**\n * A plugin to handle external actions states\n */\nexport class ExternalActionPlugin implements PlayerPlugin {\n name = \"ExternalActionPlugin\";\n private handler: ExternalStateHandler;\n\n constructor(handler: ExternalStateHandler) {\n this.handler = handler;\n }\n\n apply(player: Player) {\n player.hooks.flowController.tap(this.name, (flowController) => {\n flowController.hooks.flow.tap(this.name, (flow) => {\n flow.hooks.transition.tap(this.name, (fromState, toState) => {\n const { value: state } = toState;\n if (state.state_type === \"EXTERNAL\") {\n setTimeout(async () => {\n /** Helper for ensuring state is still current relative to external state this is handling */\n const shouldTransition = (\n currentState: PlayerFlowState,\n ): currentState is InProgressState =>\n currentState.status === \"in-progress\" &&\n currentState.controllers.flow.current?.currentState?.value ===\n state;\n\n const currentState = player.getState();\n if (shouldTransition(currentState)) {\n try {\n const transitionValue = await this.handler(\n state,\n currentState.controllers,\n );\n\n if (transitionValue !== undefined) {\n // Ensure the Player is still in the same state after waiting for transitionValue\n const latestState = player.getState();\n if (shouldTransition(latestState)) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${toState.name}]`,\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\n }\n }, 0);\n }\n });\n });\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/external-action-plugin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.14.0-next.1",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@player-ui/player": "0.
|
|
12
|
+
"@player-ui/player": "0.14.0-next.1"
|
|
13
13
|
},
|
|
14
14
|
"module": "dist/index.legacy-esm.js",
|
|
15
15
|
"types": "types/index.d.ts",
|