@player-ui/player 0.12.0-next.9 → 0.12.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,12 +6,12 @@
6
6
  "types"
7
7
  ],
8
8
  "name": "@player-ui/player",
9
- "version": "0.12.0-next.9",
9
+ "version": "0.12.0",
10
10
  "main": "dist/cjs/index.cjs",
11
11
  "dependencies": {
12
- "@player-ui/partial-match-registry": "0.12.0-next.9",
13
- "@player-ui/make-flow": "0.12.0-next.9",
14
- "@player-ui/types": "0.12.0-next.9",
12
+ "@player-ui/partial-match-registry": "0.12.0",
13
+ "@player-ui/make-flow": "0.12.0",
14
+ "@player-ui/types": "0.12.0",
15
15
  "@types/dlv": "^1.1.4",
16
16
  "dequal": "^2.0.2",
17
17
  "dlv": "^1.1.3",
@@ -595,3 +595,54 @@ describe("failure cases", () => {
595
595
  await expect(response).rejects.toThrowError("Custom Error");
596
596
  });
597
597
  });
598
+
599
+ test("it applies default-view-plugins first", () => {
600
+ let taps: Array<{ [key: string]: any; name: string }> = [];
601
+ class TestPlugin {
602
+ name = "test-plugin";
603
+
604
+ apply(player: Player) {
605
+ player.hooks.view.tap(this.name, (view) => {
606
+ view.hooks.resolver.tap(this.name, () => {
607
+ return;
608
+ });
609
+ // @ts-expect-error private property
610
+ taps = view.hooks.resolver!.taps;
611
+ });
612
+ }
613
+ }
614
+ const player = new Player({ plugins: [new TestPlugin()] });
615
+
616
+ player.start(makeFlow({ type: "text", id: "text", value: "View" }));
617
+
618
+ const tapsByName = taps.map((tap) => tap!.name);
619
+ expect(tapsByName.pop()).toBe("test-plugin");
620
+ });
621
+
622
+ test("allows custom plugin to move before default", () => {
623
+ let taps: Array<{ [key: string]: any; name: string }> = [];
624
+ class TestPlugin {
625
+ name = "test-plugin";
626
+
627
+ apply(player: Player) {
628
+ player.hooks.view.tap(this.name, (view) => {
629
+ view.hooks.resolver.tap(
630
+ { name: this.name, before: "applicability" },
631
+ () => {
632
+ return;
633
+ },
634
+ );
635
+ // @ts-expect-error private property
636
+ taps = view.hooks.resolver!.taps;
637
+ });
638
+ }
639
+ }
640
+ const player = new Player({ plugins: [new TestPlugin()] });
641
+
642
+ player.start(makeFlow({ type: "text", id: "text", value: "View" }));
643
+
644
+ const tapsByName = taps.map((tap) => tap!.name);
645
+ expect(tapsByName.indexOf("test-plugin")).toBeLessThan(
646
+ tapsByName.indexOf("applicability"),
647
+ );
648
+ });
package/src/player.ts CHANGED
@@ -420,9 +420,12 @@ export class Player {
420
420
  },
421
421
  constants: this.constantsController,
422
422
  });
423
- viewController.hooks.view.tap("player", (view) => {
424
- validationController.onView(view);
425
- this.hooks.view.call(view);
423
+
424
+ this.hooks.viewController.tap("player", (vc) => {
425
+ vc.hooks.view.tap("player", (view) => {
426
+ validationController.onView(view);
427
+ this.hooks.view.call(view);
428
+ });
426
429
  });
427
430
  this.hooks.viewController.call(viewController);
428
431