beam.com 0.1.0-rc.1

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 (102) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +97 -0
  3. package/README.md +369 -0
  4. package/js/beam.com.mjs +33 -0
  5. package/js/download.mjs +78 -0
  6. package/js/node.mjs +75 -0
  7. package/package.json +36 -0
  8. package/runtime/app-com.js +203 -0
  9. package/runtime/beam.mjs +2 -0
  10. package/runtime/beam.wasm +0 -0
  11. package/runtime/browser/beam-wasm.js +2 -0
  12. package/runtime/browser/net.js +7 -0
  13. package/runtime/browser/none.js +4 -0
  14. package/runtime/browser.js +161 -0
  15. package/runtime/cloudflare/durable.js +361 -0
  16. package/runtime/cloudflare/index.js +76 -0
  17. package/runtime/cloudflare/release.js +42 -0
  18. package/runtime/cloudflare/snapshot.js +3 -0
  19. package/runtime/cloudflare/worker.js +1891 -0
  20. package/runtime/deno/app.js +8 -0
  21. package/runtime/deno/beam-wasm.js +3 -0
  22. package/runtime/deno/none.js +3 -0
  23. package/runtime/deno/release-bin.js +46 -0
  24. package/runtime/deno/snapshot-bin.js +11 -0
  25. package/runtime/deno/worker.js +1891 -0
  26. package/runtime/deno.js +346 -0
  27. package/runtime/deno.json +5 -0
  28. package/runtime/durable-global.js +40 -0
  29. package/runtime/durable.js +361 -0
  30. package/runtime/global.js +26 -0
  31. package/runtime/licenses/LICENSE +202 -0
  32. package/runtime/licenses/NOTICE +97 -0
  33. package/runtime/licenses/bcrypt_elixir.txt +87 -0
  34. package/runtime/licenses/cosmopolitan.txt +16 -0
  35. package/runtime/licenses/elixir/Apache-2.0.txt +73 -0
  36. package/runtime/licenses/elixir/LicenseRef-elixir-trademark-policy.txt +98 -0
  37. package/runtime/licenses/elixir/LicenseRef-scancode-unicode.txt +58 -0
  38. package/runtime/licenses/emscripten.txt +102 -0
  39. package/runtime/licenses/exqlite.txt +21 -0
  40. package/runtime/licenses/llvm.txt +311 -0
  41. package/runtime/licenses/musl.txt +193 -0
  42. package/runtime/licenses/otp/BSD-2-Clause.txt +22 -0
  43. package/runtime/licenses/otp/BSD-3-Clause.txt +25 -0
  44. package/runtime/licenses/otp/LicenseRef-IETF-MIB.txt +9 -0
  45. package/runtime/licenses/otp/LicenseRef-RSA-PKCS3.txt +23 -0
  46. package/runtime/licenses/otp/LicenseRef-RSA-PKCS5v2-0.txt +17 -0
  47. package/runtime/licenses/otp/LicenseRef-scancode-ietf-trust.txt +296 -0
  48. package/runtime/licenses/otp/LicenseRef-scancode-ietf.txt +23 -0
  49. package/runtime/licenses/otp/LicenseRef-scancode-w3c-docs-19990405.txt +26 -0
  50. package/runtime/licenses/otp/LicenseRef-scancode-wxwindows-free-doc-3.txt +57 -0
  51. package/runtime/licenses/otp/MIT.txt +17 -0
  52. package/runtime/licenses/otp/SGI-B-2.0.txt +25 -0
  53. package/runtime/licenses/otp/W3C-19980720.txt +55 -0
  54. package/runtime/licenses/picosat.txt +19 -0
  55. package/runtime/licenses/wamr.txt +219 -0
  56. package/runtime/nifs.js +2 -0
  57. package/runtime/package.json +1 -0
  58. package/runtime/page/404.html +49 -0
  59. package/runtime/page/app-com.js +203 -0
  60. package/runtime/page/beam.mjs +2 -0
  61. package/runtime/page/browser/beam-wasm.js +2 -0
  62. package/runtime/page/browser/net.js +7 -0
  63. package/runtime/page/browser/none.js +4 -0
  64. package/runtime/page/browser.js +161 -0
  65. package/runtime/page/index.html +50 -0
  66. package/runtime/page/licenses/LICENSE +202 -0
  67. package/runtime/page/licenses/NOTICE +97 -0
  68. package/runtime/page/licenses/bcrypt_elixir.txt +87 -0
  69. package/runtime/page/licenses/cosmopolitan.txt +16 -0
  70. package/runtime/page/licenses/elixir/Apache-2.0.txt +73 -0
  71. package/runtime/page/licenses/elixir/LicenseRef-elixir-trademark-policy.txt +98 -0
  72. package/runtime/page/licenses/elixir/LicenseRef-scancode-unicode.txt +58 -0
  73. package/runtime/page/licenses/emscripten.txt +102 -0
  74. package/runtime/page/licenses/exqlite.txt +21 -0
  75. package/runtime/page/licenses/llvm.txt +311 -0
  76. package/runtime/page/licenses/musl.txt +193 -0
  77. package/runtime/page/licenses/otp/BSD-2-Clause.txt +22 -0
  78. package/runtime/page/licenses/otp/BSD-3-Clause.txt +25 -0
  79. package/runtime/page/licenses/otp/LicenseRef-IETF-MIB.txt +9 -0
  80. package/runtime/page/licenses/otp/LicenseRef-RSA-PKCS3.txt +23 -0
  81. package/runtime/page/licenses/otp/LicenseRef-RSA-PKCS5v2-0.txt +17 -0
  82. package/runtime/page/licenses/otp/LicenseRef-scancode-ietf-trust.txt +296 -0
  83. package/runtime/page/licenses/otp/LicenseRef-scancode-ietf.txt +23 -0
  84. package/runtime/page/licenses/otp/LicenseRef-scancode-w3c-docs-19990405.txt +26 -0
  85. package/runtime/page/licenses/otp/LicenseRef-scancode-wxwindows-free-doc-3.txt +57 -0
  86. package/runtime/page/licenses/otp/MIT.txt +17 -0
  87. package/runtime/page/licenses/otp/SGI-B-2.0.txt +25 -0
  88. package/runtime/page/licenses/otp/W3C-19980720.txt +55 -0
  89. package/runtime/page/licenses/picosat.txt +19 -0
  90. package/runtime/page/licenses/wamr.txt +219 -0
  91. package/runtime/page/main.js +176 -0
  92. package/runtime/page/runtime-id.js +3 -0
  93. package/runtime/page/scope.js +17 -0
  94. package/runtime/page/sw.js +111 -0
  95. package/runtime/page/vm.js +148 -0
  96. package/runtime/page/worker.js +1891 -0
  97. package/runtime/page/ws-shim.js +143 -0
  98. package/runtime/release/app.js +17 -0
  99. package/runtime/release.json +1 -0
  100. package/runtime/runtime-id.js +3 -0
  101. package/runtime/tcp-proxy.mjs +30 -0
  102. package/runtime/worker.js +1891 -0
@@ -0,0 +1,8 @@
1
+ // The bytes of the app.com of the project, when the entry gives them with
2
+ // serve(app) of deno.js, in place of a path (the first argument of
3
+ // deno.js, or BEAM_APP). release-bin.js reads them at the first request.
4
+ export let app = null;
5
+
6
+ export function use(bytes) {
7
+ app = bytes;
8
+ }
@@ -0,0 +1,3 @@
1
+ // The runtime as a WebAssembly.Module, as the import of a .wasm file gives
2
+ // it in Workers.
3
+ export default await WebAssembly.compile(await Deno.readFile(new URL('../beam.wasm', import.meta.url)));
@@ -0,0 +1,3 @@
1
+ // The module import of nifs.js in worker.js: none in Deno, which compiles
2
+ // the NIF libraries in WebAssembly at run time.
3
+ export default null;
@@ -0,0 +1,46 @@
1
+ // release.bin as an ArrayBuffer, as the import of a Data module gives it in
2
+ // Workers: next to worker.js (one Worker), else in release/ (the Worker with
3
+ // the release). With a native app.com (the bytes of serve(app) of deno.js,
4
+ // else the path in the first argument of deno.js, else BEAM_APP): the
5
+ // files of the release of that file (its edge part, appFiles of
6
+ // app-com.js), for this runtime only.
7
+ import { app as given } from './app.js';
8
+
9
+ async function release() {
10
+ if (given) {
11
+ const [{ appFiles, bytesReader }, { default: runtime }] =
12
+ await Promise.all([import('../app-com.js'), import('../runtime-id.js')]);
13
+ const { read, size } = bytesReader(given);
14
+ return appFiles(read, size, { runtime });
15
+ }
16
+ const app = Deno.args[0] ?? Deno.env.get('BEAM_APP');
17
+ if (app) {
18
+ const { appFiles } = await import('../app-com.js');
19
+ const { default: runtime } = await import('../runtime-id.js');
20
+ const f = await Deno.open(app);
21
+ try {
22
+ const read = async (at, n) => {
23
+ const b = new Uint8Array(n);
24
+ await f.seek(at, Deno.SeekMode.Start);
25
+ for (let o = 0; o < n;) {
26
+ const r = await f.read(b.subarray(o));
27
+ if (r === null) break;
28
+ o += r;
29
+ }
30
+ return b;
31
+ };
32
+ return await appFiles(read, (await f.stat()).size, { runtime });
33
+ } finally {
34
+ f.close();
35
+ }
36
+ }
37
+ let b;
38
+ try {
39
+ b = await Deno.readFile(new URL('../release.bin', import.meta.url));
40
+ } catch {
41
+ b = await Deno.readFile(new URL('../release/release.bin', import.meta.url));
42
+ }
43
+ return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);
44
+ }
45
+
46
+ export default await release();
@@ -0,0 +1,11 @@
1
+ // snapshot.bin of the build (optional), next to release.bin: an
2
+ // ArrayBuffer, else null.
3
+ let bytes = null;
4
+ for (const path of ['../snapshot.bin', '../release/snapshot.bin']) {
5
+ try {
6
+ const b = await Deno.readFile(new URL(path, import.meta.url));
7
+ bytes = b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);
8
+ break;
9
+ } catch {}
10
+ }
11
+ export default bytes;