@player-ui/player 0.13.0-next.1 → 0.13.0-next.2
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/Player.native.js +34 -88
- package/dist/Player.native.js.map +1 -1
- package/dist/cjs/index.cjs +16 -25
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +18 -27
- package/dist/index.mjs +18 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/flow.test.ts +165 -1
- package/src/__tests__/player.test.ts +51 -1
- package/src/controllers/flow/controller.ts +9 -2
- package/src/controllers/flow/flow.ts +54 -16
- package/src/controllers/view/controller.ts +1 -2
- package/src/expressions/__tests__/evaluator.test.ts +10 -0
- package/src/player.ts +21 -22
- package/types/controllers/flow/controller.d.ts +4 -3
- package/types/controllers/flow/flow.d.ts +31 -18
package/dist/index.legacy-esm.js
CHANGED
|
@@ -4025,19 +4025,12 @@ var FlowInstance = class {
|
|
|
4025
4025
|
this.isTransitioning = false;
|
|
4026
4026
|
this.hooks = {
|
|
4027
4027
|
beforeStart: new SyncBailHook4(),
|
|
4028
|
-
/** A callback when the onStart node was present */
|
|
4029
4028
|
onStart: new SyncHook5(),
|
|
4030
|
-
/** A callback when the onEnd node was present */
|
|
4031
4029
|
onEnd: new SyncHook5(),
|
|
4032
|
-
/** A hook to intercept and block a transition */
|
|
4033
4030
|
skipTransition: new SyncBailHook4(),
|
|
4034
|
-
/** A chance to manipulate the flow-node used to calculate the given transition used */
|
|
4035
4031
|
beforeTransition: new SyncWaterfallHook7(),
|
|
4036
|
-
/** A chance to manipulate the flow-node calculated after a transition */
|
|
4037
4032
|
resolveTransitionNode: new SyncWaterfallHook7(),
|
|
4038
|
-
/** A callback when a transition from 1 state to another was made */
|
|
4039
4033
|
transition: new SyncHook5(),
|
|
4040
|
-
/** A callback to run actions after a transition occurs */
|
|
4041
4034
|
afterTransition: new SyncHook5()
|
|
4042
4035
|
};
|
|
4043
4036
|
this.id = id;
|
|
@@ -4919,7 +4912,7 @@ var ValidationController = class {
|
|
|
4919
4912
|
|
|
4920
4913
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/view/controller.ts
|
|
4921
4914
|
import { SyncHook as SyncHook8, SyncWaterfallHook as SyncWaterfallHook9 } from "tapable-ts";
|
|
4922
|
-
import
|
|
4915
|
+
import queueMicrotask2 from "queue-microtask";
|
|
4923
4916
|
import { Registry } from "@player-ui/partial-match-registry";
|
|
4924
4917
|
var ViewController = class {
|
|
4925
4918
|
constructor(initialViews, options) {
|
|
@@ -4989,7 +4982,7 @@ var ViewController = class {
|
|
|
4989
4982
|
}
|
|
4990
4983
|
if (!this.pendingUpdate.scheduled && !silent) {
|
|
4991
4984
|
this.pendingUpdate.scheduled = true;
|
|
4992
|
-
|
|
4985
|
+
queueMicrotask2(() => {
|
|
4993
4986
|
const updates = this.pendingUpdate?.changedBindings;
|
|
4994
4987
|
this.pendingUpdate = void 0;
|
|
4995
4988
|
this.currentView?.update(updates);
|
|
@@ -5540,43 +5533,41 @@ var _Player = class _Player {
|
|
|
5540
5533
|
validationController.reset();
|
|
5541
5534
|
}
|
|
5542
5535
|
});
|
|
5543
|
-
flow.hooks.afterTransition.tap("player", (flowInstance) => {
|
|
5544
|
-
const value = flowInstance.currentState?.value;
|
|
5545
|
-
if (value && value.state_type === "ACTION") {
|
|
5546
|
-
const { exp } = value;
|
|
5547
|
-
const result = expressionEvaluator.evaluate(exp);
|
|
5548
|
-
if (isPromiseLike(result)) {
|
|
5549
|
-
this.logger.warn(
|
|
5550
|
-
"Async expression used as return value in in non-async context, transitioning with '*' value"
|
|
5551
|
-
);
|
|
5552
|
-
}
|
|
5553
|
-
flowController?.transition(String(result));
|
|
5554
|
-
}
|
|
5555
|
-
expressionEvaluator.reset();
|
|
5556
|
-
});
|
|
5557
|
-
flow.hooks.afterTransition.tap("player", async (flowInstance) => {
|
|
5536
|
+
flow.hooks.afterTransition.tap("player-action-states", (flowInstance) => {
|
|
5558
5537
|
const value = flowInstance.currentState?.value;
|
|
5559
5538
|
if (value && value.state_type === "ASYNC_ACTION") {
|
|
5560
5539
|
const { exp } = value;
|
|
5561
5540
|
try {
|
|
5562
|
-
|
|
5541
|
+
const result = expressionEvaluator.evaluateAsync(exp);
|
|
5563
5542
|
if (isPromiseLike(result)) {
|
|
5564
5543
|
if (value.await) {
|
|
5565
|
-
|
|
5544
|
+
queueMicrotask(() => {
|
|
5545
|
+
result.then((r) => flowController?.transition(String(r))).catch(flowResultDeferred.reject);
|
|
5546
|
+
});
|
|
5566
5547
|
} else {
|
|
5567
5548
|
this.logger.warn(
|
|
5568
5549
|
"Unawaited promise used as return value in in non-async context, transitioning with '*' value"
|
|
5569
5550
|
);
|
|
5551
|
+
flowController?.transition(String(result));
|
|
5570
5552
|
}
|
|
5571
5553
|
} else {
|
|
5572
5554
|
this.logger.warn(
|
|
5573
5555
|
"Non async expression used in async action node"
|
|
5574
5556
|
);
|
|
5557
|
+
flowController?.transition(String(result));
|
|
5575
5558
|
}
|
|
5576
|
-
flowController?.transition(String(result));
|
|
5577
5559
|
} catch (e) {
|
|
5578
5560
|
flowResultDeferred.reject(e);
|
|
5579
5561
|
}
|
|
5562
|
+
} else if (value && value.state_type === "ACTION") {
|
|
5563
|
+
const { exp } = value;
|
|
5564
|
+
const result = expressionEvaluator.evaluate(exp);
|
|
5565
|
+
if (isPromiseLike(result)) {
|
|
5566
|
+
this.logger.warn(
|
|
5567
|
+
"Async expression used as return value in in non-async context, transitioning with '*' value"
|
|
5568
|
+
);
|
|
5569
|
+
}
|
|
5570
|
+
flowController?.transition(String(result));
|
|
5580
5571
|
}
|
|
5581
5572
|
expressionEvaluator.reset();
|
|
5582
5573
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -4025,19 +4025,12 @@ var FlowInstance = class {
|
|
|
4025
4025
|
this.isTransitioning = false;
|
|
4026
4026
|
this.hooks = {
|
|
4027
4027
|
beforeStart: new SyncBailHook4(),
|
|
4028
|
-
/** A callback when the onStart node was present */
|
|
4029
4028
|
onStart: new SyncHook5(),
|
|
4030
|
-
/** A callback when the onEnd node was present */
|
|
4031
4029
|
onEnd: new SyncHook5(),
|
|
4032
|
-
/** A hook to intercept and block a transition */
|
|
4033
4030
|
skipTransition: new SyncBailHook4(),
|
|
4034
|
-
/** A chance to manipulate the flow-node used to calculate the given transition used */
|
|
4035
4031
|
beforeTransition: new SyncWaterfallHook7(),
|
|
4036
|
-
/** A chance to manipulate the flow-node calculated after a transition */
|
|
4037
4032
|
resolveTransitionNode: new SyncWaterfallHook7(),
|
|
4038
|
-
/** A callback when a transition from 1 state to another was made */
|
|
4039
4033
|
transition: new SyncHook5(),
|
|
4040
|
-
/** A callback to run actions after a transition occurs */
|
|
4041
4034
|
afterTransition: new SyncHook5()
|
|
4042
4035
|
};
|
|
4043
4036
|
this.id = id;
|
|
@@ -4919,7 +4912,7 @@ var ValidationController = class {
|
|
|
4919
4912
|
|
|
4920
4913
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/view/controller.ts
|
|
4921
4914
|
import { SyncHook as SyncHook8, SyncWaterfallHook as SyncWaterfallHook9 } from "tapable-ts";
|
|
4922
|
-
import
|
|
4915
|
+
import queueMicrotask2 from "queue-microtask";
|
|
4923
4916
|
import { Registry } from "@player-ui/partial-match-registry";
|
|
4924
4917
|
var ViewController = class {
|
|
4925
4918
|
constructor(initialViews, options) {
|
|
@@ -4989,7 +4982,7 @@ var ViewController = class {
|
|
|
4989
4982
|
}
|
|
4990
4983
|
if (!this.pendingUpdate.scheduled && !silent) {
|
|
4991
4984
|
this.pendingUpdate.scheduled = true;
|
|
4992
|
-
|
|
4985
|
+
queueMicrotask2(() => {
|
|
4993
4986
|
const updates = this.pendingUpdate?.changedBindings;
|
|
4994
4987
|
this.pendingUpdate = void 0;
|
|
4995
4988
|
this.currentView?.update(updates);
|
|
@@ -5540,43 +5533,41 @@ var _Player = class _Player {
|
|
|
5540
5533
|
validationController.reset();
|
|
5541
5534
|
}
|
|
5542
5535
|
});
|
|
5543
|
-
flow.hooks.afterTransition.tap("player", (flowInstance) => {
|
|
5544
|
-
const value = flowInstance.currentState?.value;
|
|
5545
|
-
if (value && value.state_type === "ACTION") {
|
|
5546
|
-
const { exp } = value;
|
|
5547
|
-
const result = expressionEvaluator.evaluate(exp);
|
|
5548
|
-
if (isPromiseLike(result)) {
|
|
5549
|
-
this.logger.warn(
|
|
5550
|
-
"Async expression used as return value in in non-async context, transitioning with '*' value"
|
|
5551
|
-
);
|
|
5552
|
-
}
|
|
5553
|
-
flowController?.transition(String(result));
|
|
5554
|
-
}
|
|
5555
|
-
expressionEvaluator.reset();
|
|
5556
|
-
});
|
|
5557
|
-
flow.hooks.afterTransition.tap("player", async (flowInstance) => {
|
|
5536
|
+
flow.hooks.afterTransition.tap("player-action-states", (flowInstance) => {
|
|
5558
5537
|
const value = flowInstance.currentState?.value;
|
|
5559
5538
|
if (value && value.state_type === "ASYNC_ACTION") {
|
|
5560
5539
|
const { exp } = value;
|
|
5561
5540
|
try {
|
|
5562
|
-
|
|
5541
|
+
const result = expressionEvaluator.evaluateAsync(exp);
|
|
5563
5542
|
if (isPromiseLike(result)) {
|
|
5564
5543
|
if (value.await) {
|
|
5565
|
-
|
|
5544
|
+
queueMicrotask(() => {
|
|
5545
|
+
result.then((r) => flowController?.transition(String(r))).catch(flowResultDeferred.reject);
|
|
5546
|
+
});
|
|
5566
5547
|
} else {
|
|
5567
5548
|
this.logger.warn(
|
|
5568
5549
|
"Unawaited promise used as return value in in non-async context, transitioning with '*' value"
|
|
5569
5550
|
);
|
|
5551
|
+
flowController?.transition(String(result));
|
|
5570
5552
|
}
|
|
5571
5553
|
} else {
|
|
5572
5554
|
this.logger.warn(
|
|
5573
5555
|
"Non async expression used in async action node"
|
|
5574
5556
|
);
|
|
5557
|
+
flowController?.transition(String(result));
|
|
5575
5558
|
}
|
|
5576
|
-
flowController?.transition(String(result));
|
|
5577
5559
|
} catch (e) {
|
|
5578
5560
|
flowResultDeferred.reject(e);
|
|
5579
5561
|
}
|
|
5562
|
+
} else if (value && value.state_type === "ACTION") {
|
|
5563
|
+
const { exp } = value;
|
|
5564
|
+
const result = expressionEvaluator.evaluate(exp);
|
|
5565
|
+
if (isPromiseLike(result)) {
|
|
5566
|
+
this.logger.warn(
|
|
5567
|
+
"Async expression used as return value in in non-async context, transitioning with '*' value"
|
|
5568
|
+
);
|
|
5569
|
+
}
|
|
5570
|
+
flowController?.transition(String(result));
|
|
5580
5571
|
}
|
|
5581
5572
|
expressionEvaluator.reset();
|
|
5582
5573
|
});
|