@swmansion/popcorn 0.3.2 → 0.4.0-next.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.
- package/LICENSE +1 -1
- package/NOTICE +12 -0
- package/README.md +78 -2
- package/dist/beam.d.ts +10 -0
- package/dist/errors.d.ts +96 -39
- package/dist/etf.d.ts +38 -0
- package/dist/events.d.ts +82 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +1287 -2
- package/dist/plugins/beam_tools/lib/popcorn/beam_tools/beam_patcher.ex +184 -0
- package/dist/plugins/beam_tools/lib/popcorn/beam_tools/cli.ex +74 -0
- package/dist/plugins/beam_tools/lib/popcorn/beam_tools/packager.ex +540 -0
- package/dist/plugins/beam_tools/mix.exs +16 -0
- package/dist/plugins/beam_tools/patches/kernel/prim_tty.erl +13 -0
- package/dist/plugins/beam_tools/patches/stdlib/beam_lib.erl +27 -0
- package/dist/plugins/esbuild.d.ts +10 -2
- package/dist/plugins/esbuild.mjs +39 -34
- package/dist/plugins/rollup.d.ts +10 -2
- package/dist/plugins/rollup.mjs +46 -25
- package/dist/plugins/shared.d.ts +54 -4
- package/dist/plugins/shared.mjs +207 -0
- package/dist/plugins/vite.d.ts +17 -2
- package/dist/plugins/vite.mjs +201 -75
- package/dist/popcorn.d.ts +237 -110
- package/dist/runtimes/core/beam.emu.mjs +141 -0
- package/dist/runtimes/core/beam.mjs +141 -0
- package/dist/runtimes/core/beam.wasm +0 -0
- package/dist/runtimes/core/manifest.json +1 -0
- package/dist/runtimes/crypto/beam.emu.mjs +520 -0
- package/dist/runtimes/crypto/beam.mjs +520 -0
- package/dist/runtimes/crypto/beam.wasm +0 -0
- package/dist/runtimes/crypto/manifest.json +1 -0
- package/dist/tar.d.ts +4 -0
- package/dist/types.d.ts +108 -63
- package/dist/utils.d.ts +7 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.mjs +765 -0
- package/package.json +20 -28
- package/dist/AtomVM.mjs +0 -7992
- package/dist/AtomVM.wasm +0 -0
- package/dist/bridge.d.ts +0 -22
- package/dist/bridge.mjs +0 -66
- package/dist/errors.mjs +0 -55
- package/dist/iframe.d.ts +0 -1
- package/dist/iframe.mjs +0 -215
- package/dist/popcorn.mjs +0 -381
- package/dist/types.mjs +0 -25
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"vm":{"version":"29.0.6","capabilities":{"crypto":true},"preloaded":["atomics","counters","erl_init","erl_prim_loader","erl_tracer","erlang","erts_code_purger","erts_dirty_process_signal_handler","erts_internal","erts_literal_area_collector","erts_trace_cleaner","init","persistent_term","prim_buffer","prim_eval","prim_file","prim_inet","prim_net","prim_socket","prim_zip","socket_registry","wasm","zlib"]}}
|
package/dist/tar.d.ts
ADDED
package/dist/types.d.ts
CHANGED
|
@@ -1,77 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
type CreateModuleFn<Mod> = (overrides?: Partial<Mod>) => Promise<Mod>;
|
|
2
|
+
/**
|
|
3
|
+
* A message value. JavaScript sends use these BEAM conversions:
|
|
4
|
+
*
|
|
5
|
+
* - Strings become UTF-8 binaries. Booleans become `true` and `false` atoms.
|
|
6
|
+
* - Integers become integers. Other finite numbers become floats.
|
|
7
|
+
* - Arrays become lists.
|
|
8
|
+
* - Plain objects become maps with binary string keys.
|
|
9
|
+
* - `null` and `undefined` become the `nil` atom.
|
|
10
|
+
* - `atom()` and `tuple()` create atoms and tuples. PIDs retain their BEAM identity.
|
|
11
|
+
*
|
|
12
|
+
* Cycles, class instances, functions, symbols, bigints, unsafe integers, and non-finite numbers cause `bridge:unserializable`.
|
|
13
|
+
*/
|
|
14
|
+
export type AnyValue = unknown;
|
|
15
|
+
declare const pidBrand: unique symbol;
|
|
16
|
+
/**
|
|
17
|
+
* An opaque BEAM process identifier received from the VM.
|
|
18
|
+
*
|
|
19
|
+
* Valid only with the Popcorn instance and boot that produced it.
|
|
20
|
+
*/
|
|
21
|
+
export type Pid = {
|
|
22
|
+
readonly [pidBrand]: true;
|
|
10
23
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
args: AnySerializable;
|
|
15
|
-
};
|
|
16
|
-
export type CastRequest = {
|
|
17
|
-
requestId: number;
|
|
18
|
-
process: string;
|
|
19
|
-
args: AnySerializable;
|
|
20
|
-
};
|
|
21
|
-
/** Messages sent from parent window to iframe */
|
|
22
|
-
export type IframeRequest = {
|
|
23
|
-
type: "popcorn-call";
|
|
24
|
-
value: CallRequest;
|
|
24
|
+
/** Internal wire target. The public `send` accepts `string | Pid` instead. */
|
|
25
|
+
export type BeamTarget = {
|
|
26
|
+
name: string;
|
|
25
27
|
} | {
|
|
26
|
-
|
|
27
|
-
value: CastRequest;
|
|
28
|
+
pid: Uint8Array;
|
|
28
29
|
};
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
data?: AnySerializable;
|
|
30
|
+
export type BeamSendPayload = {
|
|
31
|
+
target: BeamTarget;
|
|
32
|
+
etf: Uint8Array<ArrayBuffer>;
|
|
33
33
|
};
|
|
34
|
-
export type
|
|
35
|
-
|
|
34
|
+
export type BeamBootOptions = {
|
|
35
|
+
otpAssetsRoot: string;
|
|
36
|
+
/**
|
|
37
|
+
* Emulator flags before `--`.
|
|
38
|
+
*
|
|
39
|
+
* Overrides the default scheduler flags.
|
|
40
|
+
* Use `schedulers()` to set thread counts.
|
|
41
|
+
*/
|
|
42
|
+
emulatorArgs?: string[];
|
|
43
|
+
/** Erlang arguments after the boot arguments, such as `-eval` expressions. */
|
|
44
|
+
extraArgs?: string[];
|
|
45
|
+
/** VM environment variables. */
|
|
46
|
+
env?: Record<string, string>;
|
|
47
|
+
ttySize: TtySize;
|
|
48
|
+
createModule: CreateModuleFn<EmscriptenModule>;
|
|
49
|
+
emit: (event: BeamEvent) => void;
|
|
36
50
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
export type BeamEvent = {
|
|
52
|
+
type: "otp:stdout";
|
|
53
|
+
payload: Uint8Array;
|
|
54
|
+
} | {
|
|
55
|
+
type: "otp:stderr";
|
|
56
|
+
payload: Uint8Array;
|
|
41
57
|
} | {
|
|
42
|
-
type: "
|
|
43
|
-
|
|
58
|
+
type: "otp:stdin-consumed";
|
|
59
|
+
payload: number;
|
|
44
60
|
} | {
|
|
45
|
-
type: "
|
|
46
|
-
|
|
61
|
+
type: "otp:error";
|
|
62
|
+
payload: OtpErrorPayload;
|
|
47
63
|
} | {
|
|
48
|
-
type: "
|
|
49
|
-
|
|
64
|
+
type: "otp:message";
|
|
65
|
+
payload: AnyValue;
|
|
50
66
|
} | {
|
|
51
|
-
type: "
|
|
52
|
-
|
|
67
|
+
type: "otp:run_js";
|
|
68
|
+
payload: RunJsRequest;
|
|
69
|
+
} | {
|
|
70
|
+
type: "otp:tracked-value-delete";
|
|
71
|
+
payload: number;
|
|
72
|
+
};
|
|
73
|
+
export type RunJsRequest = {
|
|
74
|
+
code: string;
|
|
75
|
+
args: AnyValue;
|
|
76
|
+
replyTo: Uint8Array;
|
|
77
|
+
return: "value" | "ref";
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* VM shutdown notification.
|
|
81
|
+
*
|
|
82
|
+
* An `exit` carries a status code, including zero for a normal exit.
|
|
83
|
+
*/
|
|
84
|
+
export type OtpErrorPayload = {
|
|
85
|
+
kind: "abort";
|
|
86
|
+
data: string;
|
|
53
87
|
} | {
|
|
54
|
-
|
|
55
|
-
|
|
88
|
+
kind: "error";
|
|
89
|
+
data: string;
|
|
56
90
|
} | {
|
|
57
|
-
|
|
58
|
-
|
|
91
|
+
kind: "exit";
|
|
92
|
+
data: number;
|
|
59
93
|
};
|
|
60
|
-
/**
|
|
61
|
-
export type
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
readonly CALL: "popcorn-call";
|
|
65
|
-
readonly CAST: "popcorn-cast";
|
|
66
|
-
readonly CALL_ACK: "popcorn-callAck";
|
|
67
|
-
readonly STDOUT: "popcorn-stdout";
|
|
68
|
-
readonly STDERR: "popcorn-stderr";
|
|
69
|
-
readonly HEARTBEAT: "popcorn-heartbeat";
|
|
70
|
-
readonly RELOAD: "popcorn-reload";
|
|
94
|
+
/** Terminal dimensions in character cells, from 1 to 65,535 per dimension. */
|
|
95
|
+
export type TtySize = {
|
|
96
|
+
columns: number;
|
|
97
|
+
rows: number;
|
|
71
98
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
99
|
+
/** Emscripten Module interface (subset exposed after instantiation). */
|
|
100
|
+
export type EmscriptenModule = {
|
|
101
|
+
ENV: Record<string, string>;
|
|
102
|
+
FS_mkdirTree: (path: string) => void;
|
|
103
|
+
FS_createDataFile: (parent: string, name: string | null, data: Uint8Array, canRead: boolean, canWrite: boolean, canOwn: boolean) => void;
|
|
104
|
+
HEAPU8: Uint8Array;
|
|
105
|
+
ccall: (ident: string, returnType: string | null, argTypes: string[], args: unknown[]) => AnyValue;
|
|
106
|
+
print: (text: string) => void;
|
|
107
|
+
printErr: (text: string) => void;
|
|
108
|
+
onExit: (code: number) => void;
|
|
109
|
+
onAbort: (text: string) => void;
|
|
110
|
+
arguments: string[];
|
|
111
|
+
preRun: ((mod: EmscriptenModule) => void)[];
|
|
112
|
+
_malloc: (size: number) => number;
|
|
113
|
+
_free: (ptr: number) => void;
|
|
114
|
+
onBeamMessage?: (text: string) => void | Promise<void>;
|
|
115
|
+
onError?: (text: string) => void | Promise<void>;
|
|
116
|
+
onStdinConsumed?: (size: number) => void;
|
|
117
|
+
onTrackedValueDelete?: (key: number) => void;
|
|
118
|
+
onTtyChunk?: (fd: number, chunk: Uint8Array) => void;
|
|
119
|
+
addRunDependency: (id: string) => void;
|
|
120
|
+
removeRunDependency: (id: string) => void;
|
|
76
121
|
};
|
|
77
|
-
export
|
|
122
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function dirname(path: string): string;
|
|
2
|
+
export declare function fetchBinary(url: string): Promise<Uint8Array | null>;
|
|
3
|
+
export declare function fetchJson<T>(url: string): Promise<T | null>;
|
|
4
|
+
export declare function base64ToBytes(b64: string): Uint8Array;
|
|
5
|
+
export declare function check(ok: boolean, msg?: string): asserts ok;
|
|
6
|
+
export declare function unreachable(): never;
|
|
7
|
+
export declare function objectWithKeys<K extends string>(value: unknown, keys: K[]): null | Record<K, unknown>;
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|