modern-monaco 0.2.1 → 0.3.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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/tm-themes@1.10.9/node_modules/tm-themes/themes/vitesse-dark.json
1
+ // node_modules/.pnpm/tm-themes@1.10.12/node_modules/tm-themes/themes/vitesse-dark.json
2
2
  var vitesse_dark_default = {
3
3
  colors: {
4
4
  "activityBar.activeBorder": "#4d9375",
@@ -693,29 +693,7 @@ var vitesse_dark_default = {
693
693
  type: "dark"
694
694
  };
695
695
 
696
- // src/lsp/index.ts
697
- var builtinLSPProviders = {
698
- html: {
699
- // @ts-expect-error 'setup.js' is generated at build time
700
- import: () => import("./lsp/html/setup.mjs")
701
- },
702
- css: {
703
- aliases: ["less", "sass"],
704
- // @ts-expect-error 'setup.js' is generated at build time
705
- import: () => import("./lsp/css/setup.mjs")
706
- },
707
- json: {
708
- // @ts-expect-error 'setup.js' is generated at build time
709
- import: () => import("./lsp/json/setup.mjs")
710
- },
711
- typescript: {
712
- aliases: ["javascript", "jsx", "tsx"],
713
- // @ts-expect-error 'setup.js' is generated at build time
714
- import: () => import("./lsp/typescript/setup.mjs")
715
- }
716
- };
717
-
718
- // node_modules/.pnpm/tm-grammars@1.24.10/node_modules/tm-grammars/grammars/html.json
696
+ // node_modules/.pnpm/tm-grammars@1.25.3/node_modules/tm-grammars/grammars/html.json
719
697
  var html_default = {
720
698
  displayName: "HTML",
721
699
  injections: {
@@ -3344,7 +3322,7 @@ var html_default = {
3344
3322
  scopeName: "text.html.basic"
3345
3323
  };
3346
3324
 
3347
- // node_modules/.pnpm/tm-grammars@1.24.10/node_modules/tm-grammars/grammars/css.json
3325
+ // node_modules/.pnpm/tm-grammars@1.25.3/node_modules/tm-grammars/grammars/css.json
3348
3326
  var css_default = {
3349
3327
  displayName: "CSS",
3350
3328
  name: "css",
@@ -5206,7 +5184,7 @@ var css_default = {
5206
5184
  scopeName: "source.css"
5207
5185
  };
5208
5186
 
5209
- // node_modules/.pnpm/tm-grammars@1.24.10/node_modules/tm-grammars/grammars/javascript.json
5187
+ // node_modules/.pnpm/tm-grammars@1.25.3/node_modules/tm-grammars/grammars/javascript.json
5210
5188
  var javascript_default = {
5211
5189
  displayName: "JavaScript",
5212
5190
  name: "javascript",
@@ -11204,7 +11182,7 @@ var javascript_default = {
11204
11182
  scopeName: "source.js"
11205
11183
  };
11206
11184
 
11207
- // node_modules/.pnpm/tm-grammars@1.24.10/node_modules/tm-grammars/grammars/typescript.json
11185
+ // node_modules/.pnpm/tm-grammars@1.25.3/node_modules/tm-grammars/grammars/typescript.json
11208
11186
  var typescript_default = {
11209
11187
  displayName: "TypeScript",
11210
11188
  name: "typescript",
@@ -16953,7 +16931,7 @@ var typescript_default = {
16953
16931
  scopeName: "source.ts"
16954
16932
  };
16955
16933
 
16956
- // node_modules/.pnpm/tm-grammars@1.24.10/node_modules/tm-grammars/grammars/jsx.json
16934
+ // node_modules/.pnpm/tm-grammars@1.25.3/node_modules/tm-grammars/grammars/jsx.json
16957
16935
  var jsx_default = {
16958
16936
  displayName: "JSX",
16959
16937
  name: "jsx",
@@ -22951,7 +22929,7 @@ var jsx_default = {
22951
22929
  scopeName: "source.js.jsx"
22952
22930
  };
22953
22931
 
22954
- // node_modules/.pnpm/tm-grammars@1.24.10/node_modules/tm-grammars/grammars/tsx.json
22932
+ // node_modules/.pnpm/tm-grammars@1.25.3/node_modules/tm-grammars/grammars/tsx.json
22955
22933
  var tsx_default = {
22956
22934
  displayName: "TSX",
22957
22935
  name: "tsx",
@@ -28949,7 +28927,7 @@ var tsx_default = {
28949
28927
  scopeName: "source.tsx"
28950
28928
  };
28951
28929
 
28952
- // node_modules/.pnpm/tm-grammars@1.24.10/node_modules/tm-grammars/grammars/json.json
28930
+ // node_modules/.pnpm/tm-grammars@1.25.3/node_modules/tm-grammars/grammars/json.json
28953
28931
  var json_default = {
28954
28932
  displayName: "JSON",
28955
28933
  name: "json",
@@ -29343,15 +29321,15 @@ var syntaxes = [
29343
29321
  ];
29344
29322
 
29345
29323
  // src/index.ts
29346
- import { registerLSPProvider, registerSyntax, registerTheme } from "./core.mjs";
29324
+ import { registerSyntax, registerTheme } from "./core.mjs";
29347
29325
  import { errors, hydrate, init, lazy, Workspace } from "./core.mjs";
29348
- for (const [lang, provider] of Object.entries(builtinLSPProviders)) {
29349
- registerLSPProvider(lang, provider);
29350
- }
29351
29326
  for (const syntax of syntaxes) {
29352
29327
  registerSyntax(syntax);
29353
29328
  }
29354
29329
  registerTheme(vitesse_dark_default);
29330
+ Object.assign(globalThis, {
29331
+ MonacoEnvironment: { useBuiltinLSP: true }
29332
+ });
29355
29333
  export {
29356
29334
  Workspace,
29357
29335
  errors,
@@ -1181,7 +1181,7 @@ var Is;
1181
1181
  Is2.typedArray = typedArray;
1182
1182
  })(Is || (Is = {}));
1183
1183
 
1184
- // src/lsp/language-service.ts
1184
+ // src/lsp/client.ts
1185
1185
  import { cache } from "../cache.mjs";
1186
1186
  var monaco;
1187
1187
  function init(monacoNS) {
@@ -1200,6 +1200,18 @@ function createHost(workspace) {
1200
1200
  }
1201
1201
  } : /* @__PURE__ */ Object.create(null);
1202
1202
  }
1203
+ async function walkFS(fs, dir = "/") {
1204
+ const entries = [];
1205
+ for (const [name, type] of await fs.readDirectory(dir || "/")) {
1206
+ const path = (dir.endsWith("/") ? dir.slice(0, -1) : dir) + "/" + name;
1207
+ if (type === 2) {
1208
+ entries.push(...await walkFS(fs, path));
1209
+ } else {
1210
+ entries.push(path);
1211
+ }
1212
+ }
1213
+ return entries;
1214
+ }
1203
1215
  function lspRequest(req, token) {
1204
1216
  return new Promise((resolve, reject) => {
1205
1217
  if (token.isCancellationRequested) {
@@ -1222,7 +1234,7 @@ function registerBasicFeatures(languageId, worker, completionTriggerCharacters,
1222
1234
  const { editor, languages } = monaco;
1223
1235
  const onDispose = async (model) => {
1224
1236
  const workerProxy = await worker.withSyncedResources([]);
1225
- workerProxy.removeDocumentCache(model.uri.toString());
1237
+ workerProxy.releaseDocument(model.uri.toString());
1226
1238
  };
1227
1239
  editor.onDidChangeModelLanguage(({ model, oldLanguage }) => {
1228
1240
  if (oldLanguage === languageId) {
@@ -1263,12 +1275,6 @@ function registerBasicFeatures(languageId, worker, completionTriggerCharacters,
1263
1275
  worker.getProxy().then((proxy) => proxy.fsNotify(kind, path, type));
1264
1276
  }
1265
1277
  });
1266
- (async () => {
1267
- const workerProxy = await worker.getProxy();
1268
- for await (const [path, type] of workspace.fs.walk()) {
1269
- workerProxy.fsNotify("create", path, type);
1270
- }
1271
- })();
1272
1278
  }
1273
1279
  }
1274
1280
  function registerDiagnostics(languageId, worker) {
@@ -2240,5 +2246,6 @@ export {
2240
2246
  registerColorPresentation,
2241
2247
  registerDocumentLinks,
2242
2248
  registerEmbedded,
2243
- registerSignatureHelp
2249
+ registerSignatureHelp,
2250
+ walkFS
2244
2251
  };
@@ -1,5 +1,5 @@
1
1
  // src/lsp/css/setup.ts
2
- import * as ls from "../language-service.mjs";
2
+ import * as client from "../client.mjs";
3
3
  async function setup(monaco, languageId, languageSettings, formattingOptions, workspace) {
4
4
  const { tabSize, insertSpaces, insertFinalNewline, trimFinalNewlines } = formattingOptions ?? {};
5
5
  const createData = {
@@ -18,26 +18,26 @@ async function setup(monaco, languageId, languageSettings, formattingOptions, wo
18
18
  spaceAroundSelectorSeparator: false,
19
19
  braceStyle: "collapse"
20
20
  },
21
- workspace: !!workspace
21
+ fs: workspace ? await client.walkFS(workspace.fs, "/") : void 0
22
22
  };
23
23
  const worker = monaco.editor.createWebWorker({
24
24
  worker: getWorker(createData),
25
- host: ls.createHost(workspace)
25
+ host: client.createHost(workspace)
26
26
  });
27
- ls.registerBasicFeatures(languageId, worker, ["/", "-", ":", "("], workspace);
28
- ls.registerCodeAction(languageId, worker);
29
- ls.registerColorPresentation(languageId, worker);
30
- ls.registerDocumentLinks(languageId, worker);
27
+ client.registerBasicFeatures(languageId, worker, ["/", "-", ":", "("], workspace);
28
+ client.registerCodeAction(languageId, worker);
29
+ client.registerColorPresentation(languageId, worker);
30
+ client.registerDocumentLinks(languageId, worker);
31
31
  }
32
32
  function createWebWorker() {
33
33
  const workerUrl = new URL("./worker.mjs", import.meta.url);
34
34
  if (workerUrl.origin !== location.origin) {
35
35
  return new Worker(
36
36
  URL.createObjectURL(new Blob([`import "${workerUrl.href}"`], { type: "application/javascript" })),
37
- { type: "module" }
37
+ { type: "module", name: "css-worker" }
38
38
  );
39
39
  }
40
- return new Worker(new URL("./worker.mjs", import.meta.url), { type: "module" });
40
+ return new Worker(workerUrl, { type: "module", name: "css-worker" });
41
41
  }
42
42
  function getWorker(createData) {
43
43
  const worker = createWebWorker();