-
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathjavascript.js
More file actions
56 lines (47 loc) · 1.15 KB
/
javascript.js
File metadata and controls
56 lines (47 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable no-restricted-globals */
import { getLanguage } from "../common.js";
import { checkFile, getCodeObjectIds, diagnose, Interrupt } from "./util.js";
const languageId = "javascript";
export default async function javascript({
file,
lspc,
blueprint_object_ids,
demo_dir,
application,
builder,
template,
window,
}) {
print(` ${file.get_path()}`);
const text = await diagnose({ file, lspc, languageId });
await checkFile({
lspc,
file,
lang: getLanguage(languageId),
uri: file.get_uri(),
});
const js_object_ids = getCodeObjectIds(text);
for (const object_id of js_object_ids) {
if (!blueprint_object_ids.includes(object_id)) {
print(` ❌ Reference to inexistant object id "${object_id}"`);
throw new Interrupt();
}
}
globalThis.workbench = {
window,
application,
builder,
template,
resolve(path) {
return demo_dir.resolve_relative_path(path).get_uri();
},
preview() {},
};
await import(`file://${file.get_path()}`);
print(" ✅ runs");
await lspc._notify("textDocument/didClose", {
textDocument: {
uri: file.get_uri(),
},
});
}