@blastlauncher/web 0.0.0-stage → 3.0.0-alpha.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.
Files changed (46) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +85 -2
  3. package/assets/almostnode.mjs +735 -0
  4. package/assets/blast-sources.json +1 -0
  5. package/assets/blast-web.js +35 -0
  6. package/assets/esbuild.mjs +2695 -0
  7. package/assets/esbuild.wasm +0 -0
  8. package/dist/browser-bundle.d.ts +54 -0
  9. package/dist/browser-bundle.js +441 -0
  10. package/dist/browser-install.d.ts +66 -0
  11. package/dist/browser-install.js +326 -0
  12. package/dist/bundle-config.d.ts +10 -0
  13. package/dist/bundle-config.js +31 -0
  14. package/dist/bundles.d.ts +29 -0
  15. package/dist/bundles.js +126 -0
  16. package/dist/capabilities.d.ts +66 -0
  17. package/dist/capabilities.js +288 -0
  18. package/dist/custom-element.d.ts +6 -0
  19. package/dist/custom-element.js +36 -0
  20. package/dist/default-renderer.d.ts +27 -0
  21. package/dist/default-renderer.js +145 -0
  22. package/dist/default-styles.d.ts +2 -0
  23. package/dist/default-styles.js +28 -0
  24. package/dist/extension-files.d.ts +21 -0
  25. package/dist/extension-files.js +86 -0
  26. package/dist/handlers.d.ts +18 -0
  27. package/dist/handlers.js +22 -0
  28. package/dist/index.d.ts +14 -0
  29. package/dist/index.js +17 -0
  30. package/dist/launch.d.ts +11 -0
  31. package/dist/launch.js +29 -0
  32. package/dist/prebuilt.d.ts +24 -0
  33. package/dist/prebuilt.js +112 -0
  34. package/dist/render.d.ts +62 -0
  35. package/dist/render.js +288 -0
  36. package/dist/runtime-port.d.ts +5 -0
  37. package/dist/runtime-port.js +8 -0
  38. package/dist/sandbox.d.ts +25 -0
  39. package/dist/sandbox.js +71 -0
  40. package/dist/session.d.ts +77 -0
  41. package/dist/session.js +520 -0
  42. package/dist/source.d.ts +16 -0
  43. package/dist/source.js +42 -0
  44. package/package.json +33 -4
  45. package/sandbox/almostnode-full.mjs +19713 -0
  46. package/sandbox/index.html +1 -0
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2023 Yukai Huang
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,86 @@
1
- # Temporary Holding Version
1
+ # @blastlauncher/web
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Runs Raycast extensions in any web page. The extension runs in a sandbox on a
4
+ second origin you host, so it cannot reach your page's DOM, cookies or data.
5
+
6
+ ## Quickstart
7
+
8
+ The package is not on npm until the next prerelease. Build it from source
9
+ (`bun run release:build` in a checkout) and install its tarball with the
10
+ `client-core` and `protocol` ones it depends on:
11
+
12
+ ```sh
13
+ npm install ../blast/.cache/release/tarballs/blastlauncher-{web,client-core,protocol}-*.tgz
14
+ ```
15
+
16
+ Serve two directories from the package as static files, unchanged:
17
+
18
+ | Directory | Serve on |
19
+ | ------------------------------------------ | ------------------------------------------ |
20
+ | `node_modules/@blastlauncher/web/assets/` | your page's origin, e.g. `/blast/` |
21
+ | `node_modules/@blastlauncher/web/sandbox/` | another origin, e.g. `sandbox.example.com` |
22
+
23
+ ```html
24
+ <div id="app"></div>
25
+ <script type="module">
26
+ import { mount } from "/blast/blast-web.js";
27
+ const session = mount(document.querySelector("#app"), {
28
+ extension: "raycast/extensions/android-versions",
29
+ sandboxUrl: "https://sandbox.example.com/",
30
+ });
31
+ </script>
32
+ ```
33
+
34
+ `assets/blast-web.js` finds the other assets beside itself. With a bundler,
35
+ `import { mount } from "@blastlauncher/web"` and pass `assetsUrl: "/blast/"`.
36
+
37
+ ## Options
38
+
39
+ - `session.input({ type: "search", text: "ban" })` sends input; `session.close()` ends it.
40
+ - `root: true` shows the extension's commands as the engine root view.
41
+ - `handlers` overrides the default `storage`, `clipboard` and `openUrl`;
42
+ `handlers.capability` answers or denies any capability first.
43
+ - `render(view, input)` replaces the built-in renderer; `theme` is `"light"`,
44
+ `"dark"` or a map of `--blast-*` custom properties.
45
+ - `<blast-extension extension="…" sandbox-url="…" assets-url="…">` after
46
+ `defineBlastExtension()`.
47
+
48
+ `examples/web-embed` is a complete page and `bun run example:web-embed:e2e`
49
+ runs it headless against loopback servers.
50
+
51
+ Hooks for hosts with their own UI (`examples/browser-demo` uses all of them):
52
+
53
+ - `render(view, input, { scene, status })`: the view, an `input` that returns
54
+ the controller result (`handled` for keys), and the scene it came from.
55
+ `loading` and `error` views come before the first scene and on failure. A
56
+ custom `render` owns `element`; `close()` leaves its contents alone.
57
+ - `session.view()` is the running command's view; `session.input()` returns
58
+ the same result as `render`'s `input`.
59
+ - `onExit({ reason, view })`: the command closed its window (`quit`) or exited
60
+ with code 0 (`exit`); `view` is its last view (HUD, toast). No-view commands
61
+ report `exit` only. Without it the session returns to its root.
62
+ - `commandTitle`: navigation title until the command sets one.
63
+ - `esbuild` may be a loader (`() => Promise<esbuild>`) so the wasm loads only
64
+ when a command needs bundling.
65
+ - `bundlesUrl`: a prebuilt `bundles.json` (see `examples/browser-demo/prebuild.ts`).
66
+ A `raycast/extensions` command found there runs without fetching GitHub; its
67
+ bytes and files must match the index's digests. The index's shared runtime
68
+ loads into every sandbox first. `buildUrl` (JSON `{ "sha" }`) rejects an
69
+ index from another deploy.
70
+ - `preferenceForm(request)`: asked for missing required preferences before a
71
+ launch, and for `openExtensionPreferences`/`openCommandPreferences`
72
+ (`request.scope`). It returns the submitted values, which are saved, or
73
+ `undefined` to cancel; after `open*Preferences` the command runs again.
74
+ - `prewarm(options)` starts a sandbox (with the prebuilt runtime) while the
75
+ page is idle; the next `mount()` with the same `sandboxUrl`, `assetsUrl`,
76
+ `bundlesUrl` and `buildUrl` adopts it. Its frame has `data-blast="warm"`,
77
+ then `"session"` once adopted.
78
+
79
+ ## In this repository
80
+
81
+ Browser-only (decision 0015): the package never imports the Node engine, and
82
+ `packages/web/src` typechecks under `tsconfig.browser.json`.
83
+ `packages/web/build/assets.ts` builds `assets/` and `sandbox/` for
84
+ `release:build`, the browser demo and the examples. After `release:build`,
85
+ `bun run release:web:e2e` installs the tarball and runs the quickstart page
86
+ against two loopback origins.