wasm-idle 1.3.0 → 1.4.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/README.md +183 -147
- package/dist/container/clang-runtime.js +32 -8
- package/dist/container/runtime-adapter.d.ts +2 -0
- package/dist/container/runtime-adapter.js +37 -8
- package/dist/playground/assetBridge.js +10 -8
- package/dist/playground/assets.d.ts +4 -0
- package/dist/playground/assets.js +9 -4
- package/dist/playground/c3.js +1 -1
- package/dist/playground/compiledLldb.d.ts +2 -0
- package/dist/playground/compiledLldb.js +37 -2
- package/dist/playground/d.d.ts +1 -0
- package/dist/playground/d.js +18 -8
- package/dist/playground/index.d.ts +1 -1
- package/dist/playground/index.js +7 -0
- package/dist/playground/{java-debug-HUZVAK4F.js → java-debug-64JGCLTC.js} +1 -1
- package/dist/playground/java-debug-notices.txt +26 -1
- package/dist/playground/java.js +3 -2
- package/dist/playground/javaDebugBridge.js +42 -7
- package/dist/playground/javaDebugSource.js +4 -4
- package/dist/playground/javaMain.d.ts +3 -0
- package/dist/playground/javaMain.js +2 -0
- package/dist/playground/javaRuntimeErrors.d.ts +2 -1
- package/dist/playground/javaRuntimeErrors.js +9 -2
- package/dist/playground/javaSource.d.ts +1 -1
- package/dist/playground/javaSource.js +7 -2
- package/dist/playground/lldbSession.d.ts +1 -0
- package/dist/playground/lldbSession.js +15 -2
- package/dist/playground/objectivec.js +2 -1
- package/dist/playground/options.d.ts +1 -1
- package/dist/playground/pythonCompileOptions.d.ts +7 -4
- package/dist/playground/pythonCompileOptions.js +2 -2
- package/dist/playground/scala.d.ts +34 -0
- package/dist/playground/scala.js +397 -0
- package/dist/playground/scalaAssets.d.ts +16 -0
- package/dist/playground/scalaAssets.js +51 -0
- package/dist/playground/scalaDiagnostics.d.ts +3 -0
- package/dist/playground/scalaDiagnostics.js +29 -0
- package/dist/playground/staticWorkerRuntime.d.ts +2 -0
- package/dist/playground/staticWorkerRuntime.js +85 -11
- package/dist/playground/tinygo.js +21 -8
- package/dist/playground/tinygoExecutableGraph.js +1 -1
- package/dist/playground/v.d.ts +1 -0
- package/dist/playground/v.js +17 -7
- package/dist/playground/wasmC3Version.d.ts +8 -8
- package/dist/playground/wasmC3Version.js +8 -8
- package/dist/playground/wasmDotnetVersion.d.ts +1 -1
- package/dist/playground/wasmDotnetVersion.js +1 -1
- package/dist/playground/wasmGoVersion.d.ts +1 -1
- package/dist/playground/wasmGoVersion.js +1 -1
- package/dist/playground/wasmLispVersion.d.ts +5 -0
- package/dist/playground/wasmLispVersion.js +5 -0
- package/dist/playground/wasmOcamlVersion.d.ts +4 -4
- package/dist/playground/wasmOcamlVersion.js +3 -3
- package/dist/playground/wasmTinyGoVersion.d.ts +57 -57
- package/dist/playground/wasmTinyGoVersion.js +57 -57
- package/dist/playground/wasmZigVersion.d.ts +7 -7
- package/dist/playground/wasmZigVersion.js +7 -7
- package/dist/playground/worker/java.js +18 -4
- package/dist/playground/worker/javaDebugEvaluator.js +2 -2
- package/dist/playground/worker/javaDebugRuntime.js +8 -1
- package/dist/playground/worker/javaStreaming.js +4 -2
- package/dist/playground/worker/ocaml.js +11 -10
- package/dist/playground/worker/python.js +21 -164
- package/dist/playground/worker/pythonCompile.js +5 -0
- package/dist/playground/worker/pythonDebug.d.ts +20 -0
- package/dist/playground/worker/pythonDebug.js +205 -0
- package/dist/playground/worker/scala/UPSTREAM-LICENSE.txt +201 -0
- package/dist/playground/worker/scala/UPSTREAM-NOTICE.txt +108 -0
- package/dist/playground/worker/scala/asset-bootstrap.d.ts +6 -0
- package/dist/playground/worker/scala/asset-bootstrap.js +58 -0
- package/dist/playground/worker/scala/asset-receipts.d.ts +7 -0
- package/dist/playground/worker/scala/asset-receipts.js +58 -0
- package/dist/playground/worker/scala/compiler.worker.d.ts +1 -0
- package/dist/playground/worker/scala/compiler.worker.js +204 -0
- package/dist/playground/worker/scala/execution.worker.d.ts +1 -0
- package/dist/playground/worker/scala/execution.worker.js +89 -0
- package/dist/playground/worker/scala/memory-fs.d.ts +29 -0
- package/dist/playground/worker/scala/memory-fs.js +333 -0
- package/dist/playground/worker/scala/runner.d.ts +1 -0
- package/dist/playground/worker/scala/runner.js +36 -0
- package/dist/playground/worker/zig.d.ts +2 -1
- package/dist/playground/worker/zig.js +212 -86
- package/dist/playground/worker/zigDebug.d.ts +39 -0
- package/dist/playground/worker/zigDebug.js +156 -0
- package/dist/playground/zig.d.ts +27 -4
- package/dist/playground/zig.js +266 -23
- package/dist/playground/zigDebugValues.d.ts +20 -0
- package/dist/playground/zigDebugValues.js +248 -0
- package/package.json +17 -10
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { PYTHON_DEBUG_PREVIEW } from './pythonDebugPreview';
|
|
2
|
+
/** Fixed code is reusable; every run still gets its own breakpoint and stepping state. */
|
|
3
|
+
export const PYTHON_DEBUG_TRACE = String.raw `
|
|
4
|
+
import os as __wasm_idle_debug_os
|
|
5
|
+
|
|
6
|
+
__wasm_idle_debug_breakpoint_state = __wasm_idle_debug_bridge.state
|
|
7
|
+
|
|
8
|
+
# Direct compilation uses relative paths; imported modules use absolute paths.
|
|
9
|
+
# Capture both identities before user code can change the working directory.
|
|
10
|
+
__wasm_idle_debug_source_filenames = {
|
|
11
|
+
__wasm_idle_debug_filename,
|
|
12
|
+
__wasm_idle_debug_os.path.abspath(__wasm_idle_debug_filename),
|
|
13
|
+
}
|
|
14
|
+
__wasm_idle_debug_breakpoints = set(json.loads(__wasm_idle_debug_breakpoints_json))
|
|
15
|
+
__wasm_idle_debug_breakpoint_version = -1
|
|
16
|
+
__wasm_idle_debug_pause_on_entry = __wasm_idle_debug_initial_pause
|
|
17
|
+
__wasm_idle_debug_step_mode = None
|
|
18
|
+
__wasm_idle_debug_next_depth = None
|
|
19
|
+
__wasm_idle_debug_step_out_depth = None
|
|
20
|
+
|
|
21
|
+
def __wasm_idle_debug_refresh_breakpoints():
|
|
22
|
+
global __wasm_idle_debug_breakpoints
|
|
23
|
+
global __wasm_idle_debug_breakpoint_version
|
|
24
|
+
if __wasm_idle_debug_breakpoint_state.version == __wasm_idle_debug_breakpoint_version:
|
|
25
|
+
return
|
|
26
|
+
payload = __wasm_idle_debug_bridge.readBreakpoints(__wasm_idle_debug_breakpoint_version)
|
|
27
|
+
# JavaScript null crosses Pyodide as JsNull rather than Python None.
|
|
28
|
+
if not isinstance(payload, str):
|
|
29
|
+
return
|
|
30
|
+
snapshot = json.loads(payload)
|
|
31
|
+
version = int(snapshot.get("version", -1))
|
|
32
|
+
if version == __wasm_idle_debug_breakpoint_version:
|
|
33
|
+
return
|
|
34
|
+
__wasm_idle_debug_breakpoint_version = version
|
|
35
|
+
__wasm_idle_debug_breakpoints = set(int(line) for line in snapshot.get("lines", []) if int(line) > 0)
|
|
36
|
+
|
|
37
|
+
def __wasm_idle_debug_depth(frame):
|
|
38
|
+
depth = 0
|
|
39
|
+
current = frame
|
|
40
|
+
while current is not None:
|
|
41
|
+
if current.f_code.co_filename in __wasm_idle_debug_source_filenames:
|
|
42
|
+
depth += 1
|
|
43
|
+
current = current.f_back
|
|
44
|
+
return depth
|
|
45
|
+
|
|
46
|
+
${PYTHON_DEBUG_PREVIEW}
|
|
47
|
+
|
|
48
|
+
def __wasm_idle_debug_locals(frame, start=0, count=50):
|
|
49
|
+
locals_preview = []
|
|
50
|
+
index = 0
|
|
51
|
+
for name, value in frame.f_locals.items():
|
|
52
|
+
if name == "__builtins__" or name.startswith("__wasm_idle_") or name.startswith("."):
|
|
53
|
+
continue
|
|
54
|
+
if index >= start:
|
|
55
|
+
preview = __wasm_idle_debug_preview(value)
|
|
56
|
+
if len(preview) > 200:
|
|
57
|
+
preview = preview[:197] + "..."
|
|
58
|
+
suffix = "… [" + str(index) + "]"
|
|
59
|
+
display_name = name if len(name) <= 256 else name[:256-len(suffix)] + suffix
|
|
60
|
+
locals_preview.append({"name": display_name, "value": preview})
|
|
61
|
+
if len(locals_preview) >= count:
|
|
62
|
+
break
|
|
63
|
+
index += 1
|
|
64
|
+
return locals_preview
|
|
65
|
+
|
|
66
|
+
def __wasm_idle_debug_stack(frame):
|
|
67
|
+
stack = []
|
|
68
|
+
current = frame
|
|
69
|
+
while current is not None:
|
|
70
|
+
if current.f_code.co_filename in __wasm_idle_debug_source_filenames:
|
|
71
|
+
stack.append({"functionName": current.f_code.co_name, "line": current.f_lineno})
|
|
72
|
+
current = current.f_back
|
|
73
|
+
return stack
|
|
74
|
+
|
|
75
|
+
def __wasm_idle_debug_trace(frame, event, arg):
|
|
76
|
+
global __wasm_idle_debug_pause_on_entry
|
|
77
|
+
global __wasm_idle_debug_step_mode
|
|
78
|
+
global __wasm_idle_debug_next_depth
|
|
79
|
+
global __wasm_idle_debug_step_out_depth
|
|
80
|
+
|
|
81
|
+
if frame.f_code.co_filename not in __wasm_idle_debug_source_filenames:
|
|
82
|
+
return None
|
|
83
|
+
if event != "line":
|
|
84
|
+
return __wasm_idle_debug_trace
|
|
85
|
+
|
|
86
|
+
# Poll atomically on every user line, but enter the snapshot helper only on change.
|
|
87
|
+
if __wasm_idle_debug_breakpoint_state.version != __wasm_idle_debug_breakpoint_version:
|
|
88
|
+
__wasm_idle_debug_refresh_breakpoints()
|
|
89
|
+
# Returning from a trace callback executes this event; a later event on the same
|
|
90
|
+
# line is another loop iteration, not a replay of the previous stop.
|
|
91
|
+
needs_depth = __wasm_idle_debug_step_mode in ("next", "out")
|
|
92
|
+
depth = __wasm_idle_debug_depth(frame) if needs_depth else None
|
|
93
|
+
line = frame.f_lineno
|
|
94
|
+
|
|
95
|
+
reason = None
|
|
96
|
+
if __wasm_idle_debug_pause_on_entry:
|
|
97
|
+
reason = "entry"
|
|
98
|
+
elif line in __wasm_idle_debug_breakpoints:
|
|
99
|
+
reason = "breakpoint"
|
|
100
|
+
elif __wasm_idle_debug_step_mode == "step":
|
|
101
|
+
reason = "step"
|
|
102
|
+
elif __wasm_idle_debug_step_mode == "next" and __wasm_idle_debug_next_depth is not None and depth <= __wasm_idle_debug_next_depth:
|
|
103
|
+
reason = "nextLine"
|
|
104
|
+
elif __wasm_idle_debug_step_mode == "out" and __wasm_idle_debug_step_out_depth is not None and depth <= __wasm_idle_debug_step_out_depth:
|
|
105
|
+
reason = "stepOut"
|
|
106
|
+
|
|
107
|
+
if reason is None:
|
|
108
|
+
return __wasm_idle_debug_trace
|
|
109
|
+
|
|
110
|
+
if depth is None:
|
|
111
|
+
depth = __wasm_idle_debug_depth(frame)
|
|
112
|
+
__wasm_idle_debug_pause_on_entry = False
|
|
113
|
+
__wasm_idle_debug_step_mode = None
|
|
114
|
+
__wasm_idle_debug_next_depth = None
|
|
115
|
+
__wasm_idle_debug_step_out_depth = None
|
|
116
|
+
|
|
117
|
+
sys.stdout.flush()
|
|
118
|
+
sys.stderr.flush()
|
|
119
|
+
pause_reference = __wasm_idle_debug_bridge.pause(line, reason, json.dumps(__wasm_idle_debug_locals(frame)), json.dumps(__wasm_idle_debug_stack(frame)))
|
|
120
|
+
while True:
|
|
121
|
+
command = __wasm_idle_debug_bridge.wait()
|
|
122
|
+
if command < 0:
|
|
123
|
+
raise KeyboardInterrupt()
|
|
124
|
+
if command == 6:
|
|
125
|
+
try:
|
|
126
|
+
request = json.loads(__wasm_idle_debug_bridge.readWatch())
|
|
127
|
+
start = max(0, int(request.get("start", 0)))
|
|
128
|
+
count = max(1, min(50, int(request.get("count", 50))))
|
|
129
|
+
page = __wasm_idle_debug_locals(frame, start, count) if request.get("reference") == pause_reference else []
|
|
130
|
+
__wasm_idle_debug_bridge.writeWatch(json.dumps(page))
|
|
131
|
+
except Exception:
|
|
132
|
+
__wasm_idle_debug_bridge.writeWatch("[]")
|
|
133
|
+
continue
|
|
134
|
+
if command != 5:
|
|
135
|
+
break
|
|
136
|
+
try:
|
|
137
|
+
expression = __wasm_idle_debug_bridge.readWatch()
|
|
138
|
+
result = __wasm_idle_debug_preview(eval(expression, frame.f_globals, frame.f_locals))
|
|
139
|
+
except Exception as error:
|
|
140
|
+
result = "?" if error.__class__.__name__ == "NameError" else "error"
|
|
141
|
+
__wasm_idle_debug_bridge.writeWatch(result)
|
|
142
|
+
if command == 2:
|
|
143
|
+
__wasm_idle_debug_step_mode = "step"
|
|
144
|
+
elif command == 3:
|
|
145
|
+
__wasm_idle_debug_step_mode = "next"
|
|
146
|
+
__wasm_idle_debug_next_depth = depth
|
|
147
|
+
elif command == 4:
|
|
148
|
+
__wasm_idle_debug_step_mode = "out"
|
|
149
|
+
__wasm_idle_debug_step_out_depth = max(0, depth - 1)
|
|
150
|
+
return __wasm_idle_debug_trace
|
|
151
|
+
|
|
152
|
+
`;
|
|
153
|
+
export const PYTHON_DEBUG_FACTORY = String.raw `
|
|
154
|
+
def __wasm_idle_compile_debug_helpers(trace_source, image_source):
|
|
155
|
+
import builtins
|
|
156
|
+
import json
|
|
157
|
+
import sys
|
|
158
|
+
|
|
159
|
+
compile_source, execute = builtins.compile, builtins.exec
|
|
160
|
+
trace_code = compile_source(trace_source, "<wasm-idle-debug-trace>", "exec", dont_inherit=True)
|
|
161
|
+
image_code = compile_source(image_source, "<wasm-idle-image-hook>", "exec", dont_inherit=True)
|
|
162
|
+
image_scope = globals()
|
|
163
|
+
|
|
164
|
+
def make_trace(filename, breakpoints_json, pause_on_entry, bridge):
|
|
165
|
+
# Keep the existing image-hook guard and namespace shared with ordinary runs.
|
|
166
|
+
execute(image_code, image_scope, image_scope)
|
|
167
|
+
scope = {
|
|
168
|
+
"sys": sys, "json": json,
|
|
169
|
+
"__wasm_idle_debug_filename": filename,
|
|
170
|
+
"__wasm_idle_debug_breakpoints_json": breakpoints_json,
|
|
171
|
+
"__wasm_idle_debug_initial_pause": pause_on_entry,
|
|
172
|
+
"__wasm_idle_debug_bridge": bridge,
|
|
173
|
+
}
|
|
174
|
+
execute(trace_code, scope, scope)
|
|
175
|
+
return scope["__wasm_idle_debug_trace"]
|
|
176
|
+
|
|
177
|
+
return make_trace
|
|
178
|
+
|
|
179
|
+
__wasm_idle_compile_debug_helpers
|
|
180
|
+
`;
|
|
181
|
+
/** The worker retains only fixed code; callers destroy each run's returned trace proxy. */
|
|
182
|
+
export function createPythonDebugHelpers(runtime, imageHook) {
|
|
183
|
+
const factory = runtime.runPython(PYTHON_DEBUG_FACTORY);
|
|
184
|
+
let makeTrace;
|
|
185
|
+
try {
|
|
186
|
+
makeTrace = factory(PYTHON_DEBUG_TRACE, imageHook);
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
factory.destroy();
|
|
190
|
+
}
|
|
191
|
+
let disposed = false;
|
|
192
|
+
return {
|
|
193
|
+
createTrace(filename, breakpoints, pauseOnEntry, bridge) {
|
|
194
|
+
if (disposed)
|
|
195
|
+
throw new Error('Python debug helpers are disposed');
|
|
196
|
+
return makeTrace(filename, breakpoints, pauseOnEntry, bridge);
|
|
197
|
+
},
|
|
198
|
+
dispose() {
|
|
199
|
+
if (disposed)
|
|
200
|
+
return;
|
|
201
|
+
disposed = true;
|
|
202
|
+
makeTrace.destroy();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Scala 3 (https://www.scala-lang.org)
|
|
2
|
+
Copyright 2012-2026 EPFL
|
|
3
|
+
Copyright 2012-2026 Lightbend, Inc. dba Akka
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License"):
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
See the License for the specific language governing permissions and
|
|
12
|
+
limitations under the License.
|
|
13
|
+
|
|
14
|
+
The Scala 3 compiler is also known as Dotty. The Dotty compiler
|
|
15
|
+
frontend has been developed since November 2012 by Martin Odersky. It
|
|
16
|
+
is expected and hoped for that the list of contributors to the
|
|
17
|
+
codebase will grow quickly. Dotty draws inspiration and code from the
|
|
18
|
+
original Scala 2 compiler "nsc", which is still developed at scala/scala [1].
|
|
19
|
+
|
|
20
|
+
The majority of the Dotty codebase is new code, with the exception of the
|
|
21
|
+
components mentioned below. We have for each component tried to come up with a
|
|
22
|
+
list of the original authors in the scala/scala [1] codebase. Apologies if some
|
|
23
|
+
major authors were omitted by oversight.
|
|
24
|
+
|
|
25
|
+
* dotty.tools.dotc.ast: The syntax tree handling is mostly new, but some
|
|
26
|
+
elements, such as the idea of tree copiers and the `TreeInfo` module,
|
|
27
|
+
were adopted from scala/scala [1]. The original authors of these parts
|
|
28
|
+
include Martin Odersky, Paul Phillips, Adriaan Moors, and Matthias Zenger.
|
|
29
|
+
|
|
30
|
+
* dotty.tools.dotc.classpath: The classpath handling is taken mostly as is
|
|
31
|
+
from scala/scala [1]. The original authors were Grzegorz Kossakowski,
|
|
32
|
+
Michał Pociecha, Lukas Rytz, Jason Zaugg and others.
|
|
33
|
+
|
|
34
|
+
* dotty.tools.dotc.config: The configuration components were adapted and
|
|
35
|
+
extended from scala/scala [1]. The original sources were authored by Paul
|
|
36
|
+
Phillips with contributions from Martin Odersky, Miguel Garcia and others.
|
|
37
|
+
|
|
38
|
+
* dotty.tools.dotc.core: The core data structures and operations are mostly
|
|
39
|
+
new. Some parts (e.g. those dealing with names) were adapted from
|
|
40
|
+
scala/scala [1]. These were originally authored by Martin Odersky, Adriaan
|
|
41
|
+
Moors, Jason Zaugg, Paul Phillips, Eugene Burmako and others.
|
|
42
|
+
|
|
43
|
+
* dotty.tools.dotc.core.pickling: The classfile readers were adapted from the
|
|
44
|
+
current Scala compiler. Original authors were Martin Odersky, Iulian
|
|
45
|
+
Dragos, Matthias Zenger and others.
|
|
46
|
+
|
|
47
|
+
* dotty.tools.dotc.parsing: The lexical and syntactic analysis components
|
|
48
|
+
were adapted from the current Scala compiler. They were originally authored
|
|
49
|
+
by Martin Odersky, Burak Emir, Paul Phillips, Lex Spoon, Sean McDirmid and
|
|
50
|
+
others.
|
|
51
|
+
|
|
52
|
+
* dotty.tools.dotc.profile: The per-phase profiling support is taken mostly
|
|
53
|
+
as is from scala/scala. The original author was Mike Skells.
|
|
54
|
+
|
|
55
|
+
* dotty.tools.dotc.reporting: Adapted from scala/scala [1] with some heavy
|
|
56
|
+
modifications. They were originally authored by Matthias Zenger, Martin
|
|
57
|
+
Odersky, and others.
|
|
58
|
+
|
|
59
|
+
* dotty.tools.dotc.typer: This is new code except for some minor components
|
|
60
|
+
(e.g. the ConstantFolder). It uses however many solution details that have
|
|
61
|
+
been developed over time by many people, including Jason Zaugg, Adriaan
|
|
62
|
+
Moors, Lukas Rytz, Paul Phillips, Grzegorz Kossakowski, and others.
|
|
63
|
+
|
|
64
|
+
* dotty.tools.dotc.util: The utilities package is a mix of new and adapted
|
|
65
|
+
components. The files in scala/scala [1] were originally authored by many
|
|
66
|
+
people, including Paul Phillips, Martin Odersky, Sean McDirmid, and others.
|
|
67
|
+
|
|
68
|
+
* dotty.tools.io: The I/O support library was adapted from current Scala
|
|
69
|
+
compiler. Original authors were Paul Phillips and others.
|
|
70
|
+
|
|
71
|
+
* dotty.test.DottyBytecodeTest: Is an adaptation of the bytecode testing from
|
|
72
|
+
scala/scala [1]. It has been reworked to fit the needs of dotty. Original
|
|
73
|
+
authors include: Adrian Moors, Lukas Rytz, Grzegorz Kossakowski, Paul
|
|
74
|
+
Phillips.
|
|
75
|
+
|
|
76
|
+
* dotty.tools.dotc.sbt and everything in sbt-bridge: The sbt compiler phases
|
|
77
|
+
are based on [2] which attempts to integrate the sbt phases into scalac and
|
|
78
|
+
is itself based on the compiler bridge in sbt 0.13 [3], but has been
|
|
79
|
+
heavily adapted and refactored. Original authors were Mark Harrah, Grzegorz
|
|
80
|
+
Kossakowski, Martin Duhemm, Adriaan Moors and others.
|
|
81
|
+
|
|
82
|
+
* dotty.tools.dotc.plugins: Adapted from scala/scala [1] with some
|
|
83
|
+
modifications. They were originally authored by Lex Spoon, Som Snytt,
|
|
84
|
+
Adriaan Moors, Paul Phillips and others.
|
|
85
|
+
|
|
86
|
+
* dotty.tools.scaladoc: The Scaladoc documentation utility ships some
|
|
87
|
+
third-party JavaScript and CSS libraries which are located under
|
|
88
|
+
scaladoc/resources/dotty_res/styles/, scaladoc/resources/dotty_res/scripts/, docs/css/ and
|
|
89
|
+
docs/js/. Please refer to the license header of the concerned files for
|
|
90
|
+
details.
|
|
91
|
+
|
|
92
|
+
* dotty.tools.dotc.coverage: Coverage instrumentation utilities have been
|
|
93
|
+
adapted from the scoverage plugin for scala 2 [4], which is under the
|
|
94
|
+
Apache 2.0 license.
|
|
95
|
+
|
|
96
|
+
* dooty.tools.pc: Presentation compiler implementation adapted from
|
|
97
|
+
scalameta/metals [5] mtags module, which is under the Apache 2.0 license.
|
|
98
|
+
|
|
99
|
+
* The Dotty codebase contains parts which are derived from
|
|
100
|
+
the ScalaPB protobuf library [6], which is under the Apache 2.0 license.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
[1] https://github.com/scala/scala
|
|
104
|
+
[2] https://github.com/adriaanm/scala/tree/sbt-api-consolidate/src/compiler/scala/tools/sbt
|
|
105
|
+
[3] https://github.com/sbt/sbt/tree/0.13/compile/interface/src/main/scala/xsbt
|
|
106
|
+
[4] https://github.com/scoverage/scalac-scoverage-plugin
|
|
107
|
+
[5] https://github.com/scalameta/metals
|
|
108
|
+
[6] https://github.com/scalapb/protobuf-scala-runtime
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SCALA_ASSET_RECEIPTS } from './asset-receipts.js';
|
|
2
|
+
|
|
3
|
+
/** Build the complete executable graph only from verified in-memory source bytes. */
|
|
4
|
+
/** @param {Record<string, Uint8Array>} payload */
|
|
5
|
+
export async function loadScalaCompilerAssets(payload) {
|
|
6
|
+
const names = Object.keys(payload ?? {}).sort();
|
|
7
|
+
const expected = SCALA_ASSET_RECEIPTS.map((entry) => entry.path).sort();
|
|
8
|
+
if (names.length !== expected.length || names.some((name, index) => name !== expected[index]))
|
|
9
|
+
throw new Error('Scala requires exactly the pinned compiler asset graph.');
|
|
10
|
+
for (const receipt of SCALA_ASSET_RECEIPTS) {
|
|
11
|
+
const bytes = payload[receipt.path];
|
|
12
|
+
if (!(bytes instanceof Uint8Array) || bytes.byteLength !== receipt.bytes)
|
|
13
|
+
throw new Error(`Scala asset size mismatch: ${receipt.path}`);
|
|
14
|
+
const digest = await crypto.subtle.digest('SHA-256', Uint8Array.from(bytes).buffer);
|
|
15
|
+
const hash = Array.from(new Uint8Array(digest), (value) =>
|
|
16
|
+
value.toString(16).padStart(2, '0')
|
|
17
|
+
).join('');
|
|
18
|
+
if (hash !== receipt.sha256)
|
|
19
|
+
throw new Error(`Scala asset integrity mismatch: ${receipt.path}`);
|
|
20
|
+
}
|
|
21
|
+
/** @type {string[]} */
|
|
22
|
+
const urls = [];
|
|
23
|
+
/** @param {BlobPart} bytes */
|
|
24
|
+
const url = (bytes, type = 'text/javascript') => {
|
|
25
|
+
const result = URL.createObjectURL(new Blob([bytes], { type }));
|
|
26
|
+
urls.push(result);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
/** @param {string} path */
|
|
30
|
+
const text = (path) => new TextDecoder('utf-8', { fatal: true }).decode(payload[path]);
|
|
31
|
+
/** @param {string} source @param {string} from @param {string} to */
|
|
32
|
+
const replace = (source, from, to) => {
|
|
33
|
+
if (source.split(from).length !== 2)
|
|
34
|
+
throw new Error('Scala compiler graph does not match pinned rewrite profile.');
|
|
35
|
+
return source.replace(from, to);
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
const zipGlobal = url(Uint8Array.from(payload['vendor/jszip.global.js']));
|
|
39
|
+
const wrapper = url(
|
|
40
|
+
replace(
|
|
41
|
+
text('vendor/jszip-wrapper.js'),
|
|
42
|
+
'"./jszip.global.js"',
|
|
43
|
+
JSON.stringify(zipGlobal)
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
const loader = url(Uint8Array.from(payload['compiler/__loader.js']));
|
|
47
|
+
const wasm = url(Uint8Array.from(payload['compiler/main.wasm']), 'application/wasm');
|
|
48
|
+
let source = text('compiler/main.js');
|
|
49
|
+
source = replace(source, '"../vendor/jszip-wrapper.js"', JSON.stringify(wrapper));
|
|
50
|
+
source = replace(source, '"./__loader.js"', JSON.stringify(loader));
|
|
51
|
+
source = replace(source, '"./main.wasm"', JSON.stringify(wasm));
|
|
52
|
+
const compiler = await import(/* @vite-ignore */ url(source));
|
|
53
|
+
const { default: JSZip } = await import(/* @vite-ignore */ wrapper);
|
|
54
|
+
return { compiler, JSZip };
|
|
55
|
+
} finally {
|
|
56
|
+
for (const value of urls) URL.revokeObjectURL(value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const SCALA_ASSET_REVISION: "357051c857d4ffd5d1e1bfc9a56f0cbf5943a325";
|
|
2
|
+
export const SCALA_ASSET_BASE_URL: "https://raw.githubusercontent.com/pgilliar/scala3-compiler-sjs/357051c857d4ffd5d1e1bfc9a56f0cbf5943a325/compiler/browser-ide/assets/";
|
|
3
|
+
export const SCALA_ASSET_RECEIPTS: readonly Readonly<{
|
|
4
|
+
path: string;
|
|
5
|
+
bytes: number;
|
|
6
|
+
sha256: string;
|
|
7
|
+
}>[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Generated from runtimes/wasm-scala/assets.lock.json; tests require exact receipt equality.
|
|
2
|
+
export const SCALA_ASSET_REVISION = '357051c857d4ffd5d1e1bfc9a56f0cbf5943a325';
|
|
3
|
+
export const SCALA_ASSET_BASE_URL =
|
|
4
|
+
'https://raw.githubusercontent.com/pgilliar/scala3-compiler-sjs/357051c857d4ffd5d1e1bfc9a56f0cbf5943a325/compiler/browser-ide/assets/';
|
|
5
|
+
export const SCALA_ASSET_RECEIPTS = Object.freeze(
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
path: 'classpath/rt.jar',
|
|
9
|
+
bytes: 13050896,
|
|
10
|
+
sha256: 'fc201cadc0932924d89ac0e7b64e5e992525d8fe05d87821047765cbd14d7f60'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
path: 'classpath/scala-lib.jar',
|
|
14
|
+
bytes: 9215387,
|
|
15
|
+
sha256: 'f88697ae427f04ab3303bbfaa7666f66aac781b0a1eecaaa19eaf58819b357ee'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: 'classpath/scalajs-lib.jar',
|
|
19
|
+
bytes: 1092821,
|
|
20
|
+
sha256: '784d4e6ddf8d4c39b4a2ae1402f2eb97f9da96f4996e7edc3e6cb9d050e04531'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: 'compiler/__loader.js',
|
|
24
|
+
bytes: 6252,
|
|
25
|
+
sha256: '67c35961534e93df509377d133623a102ca2bf8a1d7e9c17cb7e4efd8db09228'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
path: 'compiler/main.js',
|
|
29
|
+
bytes: 39025,
|
|
30
|
+
sha256: '46b6466ecc0e0943a266b1252991a545981a3dbbdc001aaf63ac0ff7f621633e'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
path: 'compiler/main.wasm',
|
|
34
|
+
bytes: 31659267,
|
|
35
|
+
sha256: '26b004f61743f2611acbd79e227a2ea95c34f0cdd583f8127eef4e5eb815c92a'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
path: 'manifest.json',
|
|
39
|
+
bytes: 359,
|
|
40
|
+
sha256: '9cdcc034f5b1452bb1165dfc92fbc49fa39e033a9dac3450badad56c8948552d'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: 'runtime/runtime-sjsir.zip',
|
|
44
|
+
bytes: 7116080,
|
|
45
|
+
sha256: 'd7a50f10350ba0c4629deae4d78ebea27d3a69e4b481ef92afffe79c52cbd57a'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: 'vendor/jszip-wrapper.js',
|
|
49
|
+
bytes: 171,
|
|
50
|
+
sha256: 'a807b59ac97717905c27996372982c3174f441e3b3c3fef8f67e99a70742820d'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
path: 'vendor/jszip.global.js',
|
|
54
|
+
bytes: 374191,
|
|
55
|
+
sha256: 'e2e1be5c22d3f15b0b89e676d3eede94644529996d9898a6b1587c9908a78506'
|
|
56
|
+
}
|
|
57
|
+
].map((entry) => Object.freeze(entry))
|
|
58
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|