summaryrefslogtreecommitdiff
path: root/cli/js/plugins.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-04-20 10:27:15 -0400
committerGitHub <noreply@github.com>2020-04-20 10:27:15 -0400
commit6e5f3453f806d6007b8f724837b5dd7d9eb17be9 (patch)
tree12d683562ae59856c81aca683541b0239290c41a /cli/js/plugins.ts
parent437e35ca52227337588148a6896040d3fc3f2d54 (diff)
Remove core/plugin.rs (#4824)
This simplifies the plugin interface in order to deliver op crates with a similar API
Diffstat (limited to 'cli/js/plugins.ts')
-rw-r--r--cli/js/plugins.ts64
1 files changed, 0 insertions, 64 deletions
diff --git a/cli/js/plugins.ts b/cli/js/plugins.ts
deleted file mode 100644
index 498da8e16..000000000
--- a/cli/js/plugins.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import { openPlugin as openPluginOp } from "./ops/plugins.ts";
-import { core } from "./core.ts";
-import { close } from "./ops/resources.ts";
-
-export interface AsyncHandler {
- (msg: Uint8Array): void;
-}
-
-interface PluginOp {
- dispatch(
- control: Uint8Array,
- zeroCopy?: ArrayBufferView | null
- ): Uint8Array | null;
- setAsyncHandler(handler: AsyncHandler): void;
-}
-
-class PluginOpImpl implements PluginOp {
- readonly #opId: number;
-
- constructor(opId: number) {
- this.#opId = opId;
- }
-
- dispatch(
- control: Uint8Array,
- zeroCopy?: ArrayBufferView | null
- ): Uint8Array | null {
- return core.dispatch(this.#opId, control, zeroCopy);
- }
-
- setAsyncHandler(handler: AsyncHandler): void {
- core.setAsyncHandler(this.#opId, handler);
- }
-}
-
-interface Plugin {
- ops: {
- [name: string]: PluginOp;
- };
- close(): void;
-}
-
-class PluginImpl implements Plugin {
- #ops: { [name: string]: PluginOp } = {};
-
- constructor(readonly rid: number, ops: { [name: string]: number }) {
- for (const op in ops) {
- this.#ops[op] = new PluginOpImpl(ops[op]);
- }
- }
-
- get ops(): { [name: string]: PluginOp } {
- return Object.assign({}, this.#ops);
- }
-
- close(): void {
- close(this.rid);
- }
-}
-
-export function openPlugin(filename: string): Plugin {
- const response = openPluginOp(filename);
- return new PluginImpl(response.rid, response.ops);
-}