Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(workerd): remote eval api #23

Merged
merged 8 commits into from
Apr 14, 2024
Merged

feat(workerd): remote eval api #23

merged 8 commits into from
Apr 14, 2024

Conversation

hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Apr 14, 2024

Inspired by pupetter/playwright's eval https://playwright.dev/docs/evaluating, this would be probably the simplest but somewhat general enough remote runner execution API.

export type WorkerdDevEnvironment = 
  DevEnvironment & {
    api: {
      dispatchFetch: (entry: string, request: Request) => Promise<Response>,
      // [ NEW ]
      eval: (entry: string, fn: (entryModule: unknown, ...args: Args) => T, ...args: Args) => Promise<T>,
    }
  }

If we customize (de)serialization (e.g. by devalue, turbo-stream), this API might be powerful enough for common use cases.

TODO

  • demo
    • workerd repl?
  • (de)serialization customization
    • serialization library can be even imported by runner, so it doesn't need to be bundled?
    • by specializing Request and Response cases, dispatchFetch can be replaced by a general eval API?

@hi-ogawa hi-ogawa marked this pull request as ready for review April 14, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant