Skip to content

Support plugin-tee in the web host #12

@topheman

Description

@topheman

The pluginlab@0.5.0 release introduces the plugin-tee plugin that allows the user to tee the output of the REPL to a file - it's the first plugin that does WRITE operations.

The plugin works well in the REPL cli, but it is not yet supported in the web host.

This issue tracks the work to add support for the plugin-tee plugin in the web host.

Changes to add plugin-tee to the web host

packages/web-host/src/utils/github.ts

   cat: "https://github.com/topheman/webassembly-component-model-experiments/tree/master/crates/plugin-cat",
   echoc:
     "https://github.com/topheman/webassembly-component-model-experiments/blob/master/c_modules/plugin-echo/component.c",
+  tee: "https://github.com/topheman/webassembly-component-model-experiments/tree/master/crates/plugin-tee",
 } as const;

packages/web-host/src/wasm/engine.ts

     import("./generated/plugin_greet/transpiled/plugin_greet.js"),
     import("./generated/plugin_ls/transpiled/plugin_ls.js"),
     import("./generated/plugin_cat/transpiled/plugin_cat.js"),
+    import("./generated/plugin_tee/transpiled/plugin_tee.js"),
     import("./generated/plugin-echo-c/transpiled/plugin-echo-c.js"),
   ]).then((plugins) =>
     plugins.map((plugin) => {

Reproduce :

Working case

The tee command works when writing to a new file.

> echo Some Content
Some Content
> tee some-new-file
Some Content
> cat some-new-file
Some Content

Bug

It's possible to tee over a file that was created with tee on the current session, however, it doesn't reset all the bytes:

> echo Some Content
Some Content
> tee some-new-file
Some Content
> cat some-new-file
Some Content
> echo foo
foo
> tee some-new-file
foo
> cat some-new-file
fooe Content

It works correctly when ran on the cli.

Error case

  • tee some-existing-file:
    • first run: Error: RangeError: offset is out of bounds
    • then: Error: RuntimeError: unreachable
  • tee -a some-existing-file:
    • first run: Error: TypeError: Resource error: Not a valid "OutputStream" resource.
    • Error: RuntimeError: unreachable

Todo

  1. Fix: tee over a file created with tee on the current session
  2. Fix: tee over a file that already exists
  3. Fix: tee -a

Errors

Image Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions