Skip to content

Commit 92a6a92

Browse files
committed
🔥 Remove deprecated interation wrappers
1 parent f7b6804 commit 92a6a92

File tree

2 files changed

+4
-103
lines changed

2 files changed

+4
-103
lines changed

‎packages/globals/src/globals.ts‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ type Interaction<T = any> = Operation<T> & {
1515

1616
interface Globals {
1717
readonly document: Document;
18-
/**
19-
* @deprecated Use `wrapInteraction` instead
20-
*/
21-
readonly wrapAction: <T>(description: string, perform: () => Promise<T>, type: InteractionType) => Operation<T>;
22-
readonly wrapInteraction: InteractionWrapper;
23-
readonly interactionWrappers: Set<InteractionWrapper>;
2418
readonly interactorTimeout: number;
2519
readonly reset: () => void;
2620
readonly keyboardLayout: KeyboardLayout;
@@ -52,16 +46,6 @@ declare global {
5246
}
5347

5448
if (!globalThis.__interactors) {
55-
let wrapInteraction = <T>(perform: () => Promise<T>, interaction: Interaction<T>): Operation<T> => {
56-
return (scope) => {
57-
let current = perform;
58-
for (let wrapper of getGlobals().interactionWrappers) {
59-
let operation = wrapper(current, interaction);
60-
current = () => scope.run(operation);
61-
}
62-
return current;
63-
};
64-
};
6549
Object.defineProperty(globalThis, "__interactors", {
6650
value: Object.defineProperties(
6751
{},
@@ -76,17 +60,6 @@ if (!globalThis.__interactors) {
7660
enumerable: true,
7761
configurable: true,
7862
},
79-
wrapAction: {
80-
value: wrapInteraction,
81-
enumerable: true,
82-
},
83-
wrapInteraction: {
84-
value: wrapInteraction,
85-
enumerable: true,
86-
},
87-
interactionWrappers: {
88-
value: new Set(),
89-
},
9063
interactorTimeout: {
9164
value: 1900,
9265
enumerable: true,
@@ -124,24 +97,6 @@ export function setInteractorTimeout(ms: number): void {
12497
});
12598
}
12699

127-
/**
128-
* @deprecated Use `addInteractionWrapper` instead
129-
*/
130-
export function addActionWrapper<T>(
131-
wrapper: (description: string, perform: () => Promise<T>, type: InteractionType) => Operation<T>
132-
): () => boolean {
133-
return addInteractionWrapper(
134-
(perform: () => Promise<T>, interaction: Interaction<T>): Operation<T> =>
135-
wrapper(interaction.description, perform, interaction.type)
136-
);
137-
}
138-
139-
export function addInteractionWrapper<T>(wrapper: InteractionWrapper<T>): () => boolean {
140-
getGlobals().interactionWrappers.add(wrapper);
141-
142-
return () => getGlobals().interactionWrappers.delete(wrapper);
143-
}
144-
145100
export function setKeyboardLayout(layout: KeyboardLayout): void {
146101
Object.defineProperty(getGlobals(), "keyboardLayout", {
147102
value: layout,
Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { beforeEach, describe, it } from '@std/testing/bdd';
1+
import { beforeEach, describe, it } from "@std/testing/bdd";
22
import { expect } from "@std/expect";
33
import { JSDOM } from "jsdom";
4-
import { Symbol } from "@effection/core";
54

6-
import { globals, setDocumentResolver, addInteractionWrapper, setInteractorTimeout } from "../mod.ts";
5+
import { globals, setDocumentResolver, setInteractorTimeout } from "../mod.ts";
76

87
function makeDocument(body = ""): Document {
9-
return new JSDOM(`<!doctype html><html><body>${body}</body></html>`).window.document;
8+
return new JSDOM(`<!doctype html><html><body>${body}</body></html>`).window
9+
.document;
1010
}
1111

1212
describe("@interactors/globals", () => {
@@ -34,58 +34,4 @@ describe("@interactors/globals", () => {
3434
expect(globals.interactorTimeout).toEqual(3000);
3535
});
3636
});
37-
38-
describe("wrapInteraction", () => {
39-
it("returns the same interaction without any change", () => {
40-
let action = async () => {};
41-
expect(
42-
(globals.wrapInteraction(
43-
action,
44-
{
45-
type: "action",
46-
interactor: "Interactor",
47-
description: "plain action",
48-
action,
49-
code: () => "",
50-
halt: () => Promise.resolve(),
51-
options: {
52-
interactor: "Interactor",
53-
name: "plain",
54-
type: "action",
55-
code: () => "",
56-
args: [],
57-
},
58-
[Symbol.operation]: Promise.resolve(),
59-
}
60-
) as () => unknown)()
61-
).toBe(action);
62-
});
63-
64-
it("applies defined interaction wrapper", () => {
65-
let action = async () => await Promise.resolve("foo");
66-
let removeWrapper = addInteractionWrapper(() => async () => await Promise.resolve("bar"));
67-
globals.wrapInteraction(
68-
action,
69-
{
70-
type: "action",
71-
interactor: "Interactor",
72-
description: "foo action",
73-
action,
74-
code: () => "",
75-
halt: () => Promise.resolve(),
76-
options: {
77-
interactor: "Interactor",
78-
name: "foo",
79-
type: "action",
80-
code: () => "",
81-
args: [],
82-
},
83-
[Symbol.operation]: Promise.resolve(),
84-
},
85-
);
86-
87-
removeWrapper();
88-
expect(globals.interactionWrappers.has(action)).toEqual(false);
89-
});
90-
});
9137
});

0 commit comments

Comments
 (0)