@player-ui/external-action-plugin 0.15.3--canary.836.34713 → 0.15.3-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.
|
@@ -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,
|
|
@@ -167,7 +167,7 @@ var ExternalActionPlugin = function() {
|
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
169
|
var __copyProps = function(to, from, except, desc) {
|
|
170
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
170
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
171
171
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
172
172
|
try {
|
|
173
173
|
var _loop = function() {
|
|
@@ -222,9 +222,8 @@ var ExternalActionPlugin = function() {
|
|
|
222
222
|
var _this = this;
|
|
223
223
|
player.hooks.flowController.tap(this.name, function(flowController) {
|
|
224
224
|
flowController.hooks.flow.tap(_this.name, function(flow) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var _ref = _async_to_generator(function(flowInstance) {
|
|
225
|
+
flow.hooks.afterTransition.tap(_this.name, function(flowInstance) {
|
|
226
|
+
return _async_to_generator(function() {
|
|
228
227
|
var state, currentState, transitionValue, _latestState_controllers_flow_current_currentState, _latestState_controllers_flow_current, latestState, error;
|
|
229
228
|
return _ts_generator(this, function(_state) {
|
|
230
229
|
switch(_state.label){
|
|
@@ -245,7 +244,7 @@ var ExternalActionPlugin = function() {
|
|
|
245
244
|
]);
|
|
246
245
|
return [
|
|
247
246
|
4,
|
|
248
|
-
|
|
247
|
+
this.handler(state.value, currentState.controllers)
|
|
249
248
|
];
|
|
250
249
|
case 2:
|
|
251
250
|
transitionValue = _state.sent();
|
|
@@ -277,11 +276,8 @@ var ExternalActionPlugin = function() {
|
|
|
277
276
|
];
|
|
278
277
|
}
|
|
279
278
|
});
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
return _ref.apply(this, arguments);
|
|
283
|
-
};
|
|
284
|
-
}());
|
|
279
|
+
}).call(_this);
|
|
280
|
+
});
|
|
285
281
|
});
|
|
286
282
|
});
|
|
287
283
|
}
|
|
@@ -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/2508/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","isExternal","state","state_type","isInProgress","status","__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","afterTransition","flowInstance","currentState","transitionValue","latestState","error","getState","controllers","current","transition","logger","warn","Error","fail"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,uBAAuB,AAAC;QCanBC,aAAT,SAASA,WACPC,KAAA;QAEA,OAAOA,MAAMC,UAAA,KAAe;IAC9B;QAESC,eAAT,SAASA,aAAaF,KAAA;QACpB,OAAOA,MAAMG,MAAA,KAAW;IAC1B;IDpBE,IAAIC,YAAYC,OAAOC,cAAc;IACrC,IAAIC,mBAAmBF,OAAOG,wBAAwB;IACtD,IAAIC,oBAAoBJ,OAAOK,mBAAmB;IAClD,IAAIC,eAAeN,OAAOO,SAAS,CAACC,cAAc;IAClD,IAAIC,WAAW,SAACC,QAAQ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AA,CAAI,MAAKnB,IAAA,EAAM,SAAOsB;;wCACzCvC,OACAwC,cASIC,iBAWFC,oDAAAA,uCALIA,aAeDC;;;;gDA/BL3C,QAAQuC,aAAaC,YAAA;gDACrBA,eAAeP,OAAOW,QAAA;qDAG1B5C,CAAAA,SACAA,MAAM6B,KAAA,IACN9B,WAAWC,MAAM6B,KAAK,KACtB3B,aAAasC,aAAY,GAHzBxC;;;;;;;;;;;;gDAM0B;;oDAAM,IAAA,CAAK+B,OAAA,CACjC/B,MAAM6B,KAAA,EACNW,aAAaK,WAAA;;;gDAFTJ,kBAAkB;gDAKxB,IAAIA,oBAAoB,KAAA,GAAW;;oDAC3BC,cAAcT,OAAOW,QAAA;oDAG3B,IACE1C,aAAawC,gBACbA,EAAAA,wCAAAA,YAAYG,WAAA,CAAYR,IAAA,CAAKS,OAAA,cAA7BJ,6DAAAA,qDAAAA,sCAAsCF,YAAA,cAAtCE,yEAAAA,mDAAoDzB,IAAA,MAClDjB,MAAMiB,IAAA,EACR;wDACAyB,YAAYG,WAAA,CAAYR,IAAA,CAAKU,UAAA,CAAWN;oDAC1C,OAAO;wDACLR,OAAOe,MAAA,CAAOC,IAAA,CACZ,iCAA8FjD,OAA7DyC,iBAAe,+CAAwD,OAAVzC,MAAMiB,IAAI,EAAA;oDAE5G;gDACF;;;;;;gDACO0B;gDACP,IAAIA,AAAA,YAAAA,OAAiBO,QAAO;oDAC1BV,aAAaW,IAAA,CAAKR;gDACpB;;;;;;;;;;;gCAGN;;wBACF;oBACF;gBACF;;;;;IDVA,OAAOhB,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 function isExternal(state) {\n return state.state_type === \"EXTERNAL\";\n }\n function isInProgress(state) {\n return state.status === \"in-progress\";\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.afterTransition.tap(this.name, async (flowInstance) => {\n const state = flowInstance.currentState;\n const currentState = player.getState();\n if (state && state.value && isExternal(state.value) && isInProgress(currentState)) {\n try {\n const transitionValue = await this.handler(\n state.value,\n currentState.controllers\n );\n if (transitionValue !== void 0) {\n const latestState = player.getState();\n if (isInProgress(latestState) && latestState.controllers.flow.current?.currentState?.name === state.name) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${state.name}]`\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\n }\n });\n });\n });\n }\n };\n return __toCommonJS(src_exports);\n})();\n","import type {\n Player,\n PlayerPlugin,\n InProgressState,\n PlayerFlowState,\n NavigationFlowState,\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\nfunction isExternal(\n state: NavigationFlowState,\n): state is NavigationFlowExternalState {\n return state.state_type === \"EXTERNAL\";\n}\n\nfunction isInProgress(state: PlayerFlowState): state is InProgressState {\n return state.status === \"in-progress\";\n}\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): void {\n player.hooks.flowController.tap(this.name, (flowController) => {\n flowController.hooks.flow.tap(this.name, (flow) => {\n flow.hooks.afterTransition.tap(this.name, async (flowInstance) => {\n const state = flowInstance.currentState;\n const currentState = player.getState();\n\n if (\n state &&\n state.value &&\n isExternal(state.value) &&\n isInProgress(currentState)\n ) {\n try {\n const transitionValue = await this.handler(\n state.value,\n currentState.controllers,\n );\n\n if (transitionValue !== undefined) {\n const latestState = player.getState();\n\n // Ensure the Player is still in the same state after waiting for transitionValue\n if (\n isInProgress(latestState) &&\n latestState.controllers.flow.current?.currentState?.name ===\n state.name\n ) {\n latestState.controllers.flow.transition(transitionValue);\n } else {\n player.logger.warn(\n `External state resolved with [${transitionValue}], but Player already navigated away from [${state.name}]`,\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n currentState.fail(error);\n }\n }\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.15.3
|
|
9
|
+
"version": "0.15.3-next.0",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@player-ui/player": "0.15.3
|
|
12
|
+
"@player-ui/player": "0.15.3-next.0"
|
|
13
13
|
},
|
|
14
14
|
"module": "dist/index.legacy-esm.js",
|
|
15
15
|
"types": "types/index.d.ts",
|