modern-monaco 0.0.0-beta.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.
@@ -0,0 +1,611 @@
1
+ // src/workspace.ts
2
+ import {
3
+ createPersistStateStorage,
4
+ createPersistTask,
5
+ decode,
6
+ encode,
7
+ filenameToURL,
8
+ openIDB,
9
+ openIDBCursor,
10
+ promiseWithResolvers,
11
+ promisifyIDBRequest,
12
+ supportLocalStorage,
13
+ toURL
14
+ } from "./util.js";
15
+ var Workspace = class {
16
+ _monaco;
17
+ _history;
18
+ _fs;
19
+ _viewState;
20
+ _entryFile;
21
+ constructor(options = {}) {
22
+ const { name = "default", browserHistory, initialFiles, entryFile } = options;
23
+ const db = new WorkspaceDatabase(
24
+ name,
25
+ {
26
+ name: "fs/meta",
27
+ keyPath: "url",
28
+ onCreate: async (store) => {
29
+ if (initialFiles) {
30
+ const promises = [];
31
+ const now = Date.now();
32
+ const reg = { type: 1, version: 1, ctime: now, mtime: now, size: 0 };
33
+ const dir = { type: 2, version: 1, ctime: now, mtime: now, size: 0 };
34
+ for (const [name2, data] of Object.entries(initialFiles)) {
35
+ const { pathname, href: url } = filenameToURL(name2);
36
+ let parent = pathname.slice(0, pathname.lastIndexOf("/"));
37
+ while (parent) {
38
+ promises.push(
39
+ promisifyIDBRequest(
40
+ store.put({ url: toURL(parent).href, ...dir })
41
+ )
42
+ );
43
+ parent = parent.slice(0, parent.lastIndexOf("/"));
44
+ }
45
+ promises.push(
46
+ promisifyIDBRequest(
47
+ store.put({ url, ...reg, size: encode(data).byteLength })
48
+ )
49
+ );
50
+ }
51
+ await Promise.all(promises);
52
+ }
53
+ }
54
+ },
55
+ {
56
+ name: "fs/blobs",
57
+ keyPath: "url",
58
+ onCreate: async (store) => {
59
+ if (initialFiles) {
60
+ const promises = [];
61
+ for (const [name2, data] of Object.entries(initialFiles)) {
62
+ promises.push(
63
+ promisifyIDBRequest(
64
+ store.put({ url: filenameToURL(name2).href, content: encode(data) })
65
+ )
66
+ );
67
+ }
68
+ await Promise.all(promises);
69
+ }
70
+ }
71
+ },
72
+ {
73
+ name: "viewState",
74
+ keyPath: "url"
75
+ }
76
+ );
77
+ this._monaco = promiseWithResolvers();
78
+ this._fs = new FS(db);
79
+ this._viewState = new WorkspaceStateStorage(db, "viewState");
80
+ this._entryFile = entryFile;
81
+ if (browserHistory) {
82
+ if (!globalThis.history) {
83
+ throw new Error("Browser history is not supported.");
84
+ }
85
+ this._history = new BrowserHistory(browserHistory === true ? "/" : browserHistory.basePath);
86
+ } else {
87
+ this._history = new LocalStorageHistory(name);
88
+ }
89
+ }
90
+ init(monaco) {
91
+ this._monaco.resolve(monaco);
92
+ }
93
+ get entryFile() {
94
+ return this._entryFile;
95
+ }
96
+ get fs() {
97
+ return this._fs;
98
+ }
99
+ get history() {
100
+ return this._history;
101
+ }
102
+ get viewState() {
103
+ return this._viewState;
104
+ }
105
+ async openTextDocument(uri, content) {
106
+ const monaco = await this._monaco.promise;
107
+ return this._openTextDocument(uri, monaco.editor.getEditors()[0]);
108
+ }
109
+ // @internal
110
+ async _openTextDocument(uri, editor, selectionOrPosition) {
111
+ const monaco = await this._monaco.promise;
112
+ const fs = this._fs;
113
+ const href = toURL(uri).href;
114
+ const content = await fs.readTextFile(href);
115
+ const viewState = await this.viewState.get(href);
116
+ const modelUri = monaco.Uri.parse(href);
117
+ const model = monaco.editor.getModel(modelUri) ?? monaco.editor.createModel(content, void 0, modelUri);
118
+ if (!Reflect.has(model, "__OB__")) {
119
+ const persist = createPersistTask(() => fs.writeFile(href, model.getValue(), { isModelContentChange: true }));
120
+ const disposable = model.onDidChangeContent(persist);
121
+ const unwatch = fs.watch(href, (kind, _, __, context) => {
122
+ if (kind === "modify" && (!context || !context.isModelContentChange)) {
123
+ fs.readTextFile(href).then((content2) => {
124
+ if (model.getValue() !== content2) {
125
+ model.setValue(content2);
126
+ model.pushStackElement();
127
+ }
128
+ });
129
+ }
130
+ });
131
+ model.onWillDispose(() => {
132
+ Reflect.deleteProperty(model, "__OB__");
133
+ disposable.dispose();
134
+ unwatch();
135
+ });
136
+ Reflect.set(model, "__OB__", true);
137
+ }
138
+ if (editor) {
139
+ editor.setModel(model);
140
+ editor.updateOptions({ readOnly: false });
141
+ if (selectionOrPosition) {
142
+ if ("startLineNumber" in selectionOrPosition) {
143
+ editor.setSelection(selectionOrPosition);
144
+ } else {
145
+ editor.setPosition(selectionOrPosition);
146
+ }
147
+ const pos = editor.getPosition();
148
+ if (pos) {
149
+ const svp = editor.getScrolledVisiblePosition(new monaco.Position(pos.lineNumber - 7, pos.column));
150
+ if (svp) {
151
+ editor.setScrollTop(svp.top);
152
+ }
153
+ }
154
+ } else if (viewState) {
155
+ editor.restoreViewState(viewState);
156
+ }
157
+ if (this._history.state.current !== href) {
158
+ this._history.push(href);
159
+ }
160
+ }
161
+ return model;
162
+ }
163
+ async showInputBox(options, token) {
164
+ const monaco = await this._monaco.promise;
165
+ return monaco.showInputBox(options, token);
166
+ }
167
+ async showQuickPick(items, options, token) {
168
+ const monaco = await this._monaco.promise;
169
+ return monaco.showQuickPick(items, options, token);
170
+ }
171
+ };
172
+ var FS = class {
173
+ constructor(_db) {
174
+ this._db = _db;
175
+ }
176
+ _watchers = /* @__PURE__ */ new Set();
177
+ async _getIdbObjectStore(storeName, readwrite = false) {
178
+ const db = await this._db.open();
179
+ return db.transaction(storeName, readwrite ? "readwrite" : "readonly").objectStore(storeName);
180
+ }
181
+ async _getIdbObjectStores(readwrite = false) {
182
+ const transaction = (await this._db.open()).transaction(["fs/meta", "fs/blobs"], readwrite ? "readwrite" : "readonly");
183
+ return [transaction.objectStore("fs/meta"), transaction.objectStore("fs/blobs")];
184
+ }
185
+ /**
186
+ * read the fs entries
187
+ * @internal
188
+ */
189
+ async entries() {
190
+ const metaStore = await this._getIdbObjectStore("fs/meta");
191
+ const entries = await promisifyIDBRequest(metaStore.getAll());
192
+ return entries.map(({ url, type }) => [url, type]);
193
+ }
194
+ async stat(name) {
195
+ const url = filenameToURL(name).href;
196
+ if (url === "file:///") {
197
+ return { type: 2, version: 1, ctime: 0, mtime: 0, size: 0 };
198
+ }
199
+ const metaStore = await this._getIdbObjectStore("fs/meta");
200
+ const stat = await promisifyIDBRequest(metaStore.get(url));
201
+ if (!stat) {
202
+ throw new ErrorNotFound(url);
203
+ }
204
+ return stat;
205
+ }
206
+ async createDirectory(name) {
207
+ const now = Date.now();
208
+ const { pathname, href: url } = filenameToURL(name);
209
+ const metaStore = await this._getIdbObjectStore("fs/meta", true);
210
+ const promises = [];
211
+ const newDirs = [];
212
+ let parent = pathname.slice(0, pathname.lastIndexOf("/"));
213
+ while (parent) {
214
+ const stat2 = { type: 2, version: 1, ctime: now, mtime: now, size: 0 };
215
+ promises.push(
216
+ promisifyIDBRequest(metaStore.add({ url: filenameToURL(parent).href, ...stat2 })).catch((error) => {
217
+ if (error.name !== "ConstraintError") {
218
+ throw error;
219
+ }
220
+ })
221
+ );
222
+ newDirs.push(parent);
223
+ parent = parent.slice(0, parent.lastIndexOf("/"));
224
+ }
225
+ const stat = { type: 2, version: 1, ctime: now, mtime: now, size: 0 };
226
+ promises.push(
227
+ promisifyIDBRequest(metaStore.add({ url, ...stat })).catch((error) => {
228
+ if (error.name !== "ConstraintError") {
229
+ throw error;
230
+ }
231
+ })
232
+ );
233
+ newDirs.push(pathname);
234
+ await Promise.all(promises);
235
+ for (const dir of newDirs) {
236
+ this._notify("create", dir, 2);
237
+ }
238
+ }
239
+ async readDirectory(name) {
240
+ const { pathname } = filenameToURL(name);
241
+ const stat = await this.stat(name);
242
+ if (stat.type !== 2) {
243
+ throw new Error(`read ${pathname}: not a directory`);
244
+ }
245
+ const metaStore = await this._getIdbObjectStore("fs/meta");
246
+ const entries = [];
247
+ const dir = "file://" + pathname + (pathname.endsWith("/") ? "" : "/");
248
+ await openIDBCursor(metaStore, IDBKeyRange.lowerBound(dir, true), (cursor) => {
249
+ const stat2 = cursor.value;
250
+ if (stat2.url.startsWith(dir)) {
251
+ const name2 = stat2.url.slice(dir.length);
252
+ if (name2 !== "" && name2.indexOf("/") === -1) {
253
+ entries.push([name2, stat2.type]);
254
+ }
255
+ return true;
256
+ }
257
+ return false;
258
+ });
259
+ return entries;
260
+ }
261
+ async readFile(name) {
262
+ const url = filenameToURL(name).href;
263
+ const blobStore = await this._getIdbObjectStore("fs/blobs");
264
+ const file = await promisifyIDBRequest(blobStore.get(url));
265
+ if (!file) {
266
+ throw new ErrorNotFound(url);
267
+ }
268
+ return file.content;
269
+ }
270
+ async readTextFile(filename) {
271
+ return this.readFile(filename).then(decode);
272
+ }
273
+ async writeFile(name, content, context) {
274
+ const { pathname, href: url } = filenameToURL(name);
275
+ const dir = pathname.slice(0, pathname.lastIndexOf("/"));
276
+ if (dir) {
277
+ try {
278
+ if ((await this.stat(dir)).type !== 2) {
279
+ throw new Error(`write ${pathname}: not a directory`);
280
+ }
281
+ } catch (error) {
282
+ if (error instanceof ErrorNotFound) {
283
+ throw new Error(`write ${pathname}: no such file or directory`);
284
+ }
285
+ throw error;
286
+ }
287
+ }
288
+ let oldStat = null;
289
+ try {
290
+ oldStat = await this.stat(url);
291
+ } catch (error) {
292
+ if (!(error instanceof ErrorNotFound)) {
293
+ throw error;
294
+ }
295
+ }
296
+ if (oldStat?.type === 2) {
297
+ throw new Error(`write ${pathname}: is a directory`);
298
+ }
299
+ content = typeof content === "string" ? encode(content) : content;
300
+ const now = Date.now();
301
+ const newStat = {
302
+ type: 1,
303
+ version: (oldStat?.version ?? 0) + 1,
304
+ ctime: oldStat?.ctime ?? now,
305
+ mtime: now,
306
+ size: content.byteLength
307
+ };
308
+ const [metaStore, blobStore] = await this._getIdbObjectStores(true);
309
+ await Promise.all([
310
+ promisifyIDBRequest(metaStore.put({ url, ...newStat })),
311
+ promisifyIDBRequest(blobStore.put({ url, content }))
312
+ ]);
313
+ this._notify(oldStat ? "modify" : "create", pathname, 1, context);
314
+ }
315
+ async delete(name, options) {
316
+ const { pathname, href: url } = filenameToURL(name);
317
+ const stat = await this.stat(url);
318
+ if (stat.type === 1) {
319
+ const [metaStore, blobStore] = await this._getIdbObjectStores(true);
320
+ await Promise.all([
321
+ promisifyIDBRequest(metaStore.delete(url)),
322
+ promisifyIDBRequest(blobStore.delete(url))
323
+ ]);
324
+ this._notify("remove", pathname, 1);
325
+ } else if (stat.type === 2) {
326
+ if (options?.recursive) {
327
+ const promises = [];
328
+ const [metaStore, blobStore] = await this._getIdbObjectStores(true);
329
+ const deleted = [];
330
+ promises.push(openIDBCursor(metaStore, IDBKeyRange.lowerBound(url), (cursor) => {
331
+ const stat2 = cursor.value;
332
+ if (stat2.url.startsWith(url)) {
333
+ if (stat2.type === 1) {
334
+ promises.push(promisifyIDBRequest(blobStore.delete(stat2.url)));
335
+ }
336
+ promises.push(promisifyIDBRequest(cursor.delete()));
337
+ deleted.push([stat2.url, stat2.type]);
338
+ return true;
339
+ }
340
+ return false;
341
+ }));
342
+ await Promise.all(promises);
343
+ for (const [url2, type] of deleted) {
344
+ this._notify("remove", new URL(url2).pathname, type);
345
+ }
346
+ } else {
347
+ const entries = await this.readDirectory(url);
348
+ if (entries.length > 0) {
349
+ throw new Error(`delete ${url}: directory not empty`);
350
+ }
351
+ const metaStore = await this._getIdbObjectStore("fs/meta", true);
352
+ await promisifyIDBRequest(metaStore.delete(url));
353
+ this._notify("remove", pathname, 2);
354
+ }
355
+ } else {
356
+ const metaStore = await this._getIdbObjectStore("fs/meta", true);
357
+ await promisifyIDBRequest(metaStore.delete(url));
358
+ this._notify("remove", pathname, stat.type);
359
+ }
360
+ }
361
+ async copy(source, target, options) {
362
+ throw new Error("Method not implemented.");
363
+ }
364
+ async rename(oldName, newName, options) {
365
+ const { href: oldUrl, pathname: oldPath } = filenameToURL(oldName);
366
+ const { href: newUrl, pathname: newPath } = filenameToURL(newName);
367
+ const oldStat = await this.stat(oldUrl);
368
+ try {
369
+ const stat = await this.stat(newUrl);
370
+ if (!options?.overwrite) {
371
+ throw new Error(`rename ${oldUrl} to ${newUrl}: file exists`);
372
+ }
373
+ await this.delete(newUrl, stat.type === 2 ? { recursive: true } : void 0);
374
+ } catch (error) {
375
+ if (!(error instanceof ErrorNotFound)) {
376
+ throw error;
377
+ }
378
+ }
379
+ const newPathDirname = newPath.slice(0, newPath.lastIndexOf("/"));
380
+ if (newPathDirname) {
381
+ try {
382
+ if ((await this.stat(newPathDirname)).type !== 2) {
383
+ throw new Error(`rename ${oldUrl} to ${newUrl}: Not a directory`);
384
+ }
385
+ } catch (error) {
386
+ if (error instanceof ErrorNotFound) {
387
+ throw new Error(`rename ${oldUrl} to ${newUrl}: No such file or directory`);
388
+ }
389
+ throw error;
390
+ }
391
+ }
392
+ const [metaStore, blobStore] = await this._getIdbObjectStores(true);
393
+ const promises = [
394
+ promisifyIDBRequest(metaStore.delete(oldUrl)),
395
+ promisifyIDBRequest(metaStore.put({ ...oldStat, url: newUrl }))
396
+ ];
397
+ const renameBlob = (oldUrl2, newUrl2) => openIDBCursor(blobStore, IDBKeyRange.only(oldUrl2), (cursor) => {
398
+ promises.push(promisifyIDBRequest(blobStore.put({ url: newUrl2, content: cursor.value.content })));
399
+ promises.push(promisifyIDBRequest(cursor.delete()));
400
+ });
401
+ const moved = [[oldPath, newPath, oldStat.type]];
402
+ if (oldStat.type === 1) {
403
+ promises.push(renameBlob(oldUrl, newUrl));
404
+ } else if (oldStat.type === 2) {
405
+ let dirUrl = oldUrl;
406
+ if (!dirUrl.endsWith("/")) {
407
+ dirUrl += "/";
408
+ }
409
+ const renamingChildren = openIDBCursor(
410
+ metaStore,
411
+ IDBKeyRange.lowerBound(dirUrl, true),
412
+ (cursor) => {
413
+ const stat = cursor.value;
414
+ if (stat.url.startsWith(dirUrl)) {
415
+ const url = newUrl + stat.url.slice(dirUrl.length - 1);
416
+ if (stat.type === 1) {
417
+ promises.push(renameBlob(stat.url, url));
418
+ }
419
+ promises.push(promisifyIDBRequest(metaStore.put({ ...stat, url })));
420
+ promises.push(promisifyIDBRequest(cursor.delete()));
421
+ moved.push([new URL(stat.url).pathname, new URL(url).pathname, stat.type]);
422
+ return true;
423
+ }
424
+ return false;
425
+ }
426
+ );
427
+ promises.push(renamingChildren);
428
+ }
429
+ await Promise.all(promises);
430
+ for (const [oldPath2, newPath2, type] of moved) {
431
+ this._notify("remove", oldPath2, type);
432
+ this._notify("create", newPath2, type);
433
+ }
434
+ }
435
+ watch(filename, handleOrOptions, handle) {
436
+ const options = typeof handleOrOptions === "function" ? void 0 : handleOrOptions;
437
+ handle = typeof handleOrOptions === "function" ? handleOrOptions : handle;
438
+ if (typeof handle !== "function") {
439
+ throw new TypeError("handle must be a function");
440
+ }
441
+ const watcher = { pathname: filenameToURL(filename).pathname, recursive: options?.recursive ?? false, handle };
442
+ this._watchers.add(watcher);
443
+ return () => {
444
+ this._watchers.delete(watcher);
445
+ };
446
+ }
447
+ async _notify(kind, pathname, type, context) {
448
+ for (const watcher of this._watchers) {
449
+ if (watcher.pathname === pathname || watcher.recursive && (watcher.pathname === "/" || pathname.startsWith(watcher.pathname + "/"))) {
450
+ watcher.handle(kind, pathname, type, context);
451
+ }
452
+ }
453
+ }
454
+ };
455
+ var ErrorNotFound = class extends Error {
456
+ constructor(name) {
457
+ super("No such file or directory: " + name);
458
+ }
459
+ };
460
+ var WorkspaceDatabase = class {
461
+ _db;
462
+ constructor(workspaceName, ...stores) {
463
+ const open = () => openIDB("monaco:workspace:" + workspaceName, 1, ...stores).then((db) => {
464
+ db.onclose = () => {
465
+ this._db = open();
466
+ };
467
+ return this._db = db;
468
+ });
469
+ this._db = open();
470
+ }
471
+ async open() {
472
+ return await this._db;
473
+ }
474
+ };
475
+ var WorkspaceStateStorage = class {
476
+ constructor(_db, _stateName) {
477
+ this._db = _db;
478
+ this._stateName = _stateName;
479
+ }
480
+ async get(uri) {
481
+ const url = toURL(uri).href;
482
+ const store = (await this._db.open()).transaction(this._stateName, "readonly").objectStore(this._stateName);
483
+ return promisifyIDBRequest(store.get(url)).then((result) => result?.state);
484
+ }
485
+ async save(uri, state) {
486
+ const url = toURL(uri).href;
487
+ const store = (await this._db.open()).transaction(this._stateName, "readwrite").objectStore(this._stateName);
488
+ await promisifyIDBRequest(store.put({ url, state }));
489
+ }
490
+ };
491
+ var LocalStorageHistory = class {
492
+ _state;
493
+ _maxHistory;
494
+ _handlers = /* @__PURE__ */ new Set();
495
+ constructor(scope, maxHistory = 100) {
496
+ const defaultState = { "current": -1, "history": [] };
497
+ this._state = supportLocalStorage() ? createPersistStateStorage(`monaco:workspace:${scope}:history`, defaultState) : defaultState;
498
+ this._maxHistory = maxHistory;
499
+ }
500
+ _onPopState() {
501
+ for (const handler of this._handlers) {
502
+ handler(this.state);
503
+ }
504
+ }
505
+ get state() {
506
+ return { current: this._state.history[this._state.current] ?? "" };
507
+ }
508
+ back() {
509
+ this._state.current--;
510
+ if (this._state.current < 0) {
511
+ this._state.current = 0;
512
+ }
513
+ this._onPopState();
514
+ }
515
+ forward() {
516
+ this._state.current++;
517
+ if (this._state.current >= this._state.history.length) {
518
+ this._state.current = this._state.history.length - 1;
519
+ }
520
+ this._onPopState();
521
+ }
522
+ push(name) {
523
+ const url = filenameToURL(name);
524
+ const history2 = this._state.history.slice(0, this._state.current + 1);
525
+ history2.push(url.href);
526
+ if (history2.length > this._maxHistory) {
527
+ history2.shift();
528
+ }
529
+ this._state.history = history2;
530
+ this._state.current = history2.length - 1;
531
+ this._onPopState();
532
+ }
533
+ replace(name) {
534
+ const url = filenameToURL(name);
535
+ const history2 = [...this._state.history];
536
+ if (this._state.current === -1) {
537
+ this._state.current = 0;
538
+ }
539
+ history2[this._state.current] = url.href;
540
+ this._state.history = history2;
541
+ this._onPopState();
542
+ }
543
+ onChange(handler) {
544
+ this._handlers.add(handler);
545
+ return () => {
546
+ this._handlers.delete(handler);
547
+ };
548
+ }
549
+ };
550
+ var BrowserHistory = class {
551
+ _basePath = "";
552
+ _current = "";
553
+ _handlers = /* @__PURE__ */ new Set();
554
+ constructor(basePath = "") {
555
+ this._basePath = "/" + basePath.split("/").filter(Boolean).join("/");
556
+ this._current = this._trimBasePath(location.pathname);
557
+ window.addEventListener("popstate", () => {
558
+ this._current = this._trimBasePath(location.pathname);
559
+ this._onPopState();
560
+ });
561
+ }
562
+ _trimBasePath(pathname) {
563
+ if (pathname != "/" && pathname.startsWith(this._basePath)) {
564
+ return new URL(pathname.slice(this._basePath.length), "file:///").href;
565
+ }
566
+ return "";
567
+ }
568
+ _joinBasePath(url) {
569
+ const basePath = this._basePath === "/" ? "" : this._basePath;
570
+ if (url.protocol === "file:") {
571
+ return basePath + url.pathname;
572
+ }
573
+ return basePath + "/" + url.href;
574
+ }
575
+ _onPopState() {
576
+ for (const handler of this._handlers) {
577
+ handler(this.state);
578
+ }
579
+ }
580
+ get state() {
581
+ return { current: this._current };
582
+ }
583
+ back() {
584
+ history.back();
585
+ }
586
+ forward() {
587
+ history.forward();
588
+ }
589
+ push(name) {
590
+ const url = filenameToURL(name);
591
+ history.pushState(null, "", this._joinBasePath(url));
592
+ this._current = url.href;
593
+ this._onPopState();
594
+ }
595
+ replace(name) {
596
+ const url = filenameToURL(name);
597
+ history.replaceState(null, "", this._joinBasePath(url));
598
+ this._current = url.href;
599
+ this._onPopState();
600
+ }
601
+ onChange(handler) {
602
+ this._handlers.add(handler);
603
+ return () => {
604
+ this._handlers.delete(handler);
605
+ };
606
+ }
607
+ };
608
+ export {
609
+ ErrorNotFound,
610
+ Workspace
611
+ };
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "modern-monaco",
3
+ "description": "A modern version of Monaco Editor",
4
+ "version": "0.0.0-beta.0",
5
+ "type": "module",
6
+ "module": "dist/index.js",
7
+ "types": "types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./types/index.d.ts"
12
+ },
13
+ "./editor-core": {
14
+ "import": "./dist/editor-core.js",
15
+ "types": "./types/monaco.d.ts"
16
+ },
17
+ "./editor-worker": {
18
+ "import": "./dist/editor-worker.js"
19
+ },
20
+ "./ssr": {
21
+ "workerd": "./dist/ssr/workerd.js",
22
+ "import": "./dist/ssr/index.js",
23
+ "types": "./types/ssr.d.ts"
24
+ },
25
+ "./lsp/*": {
26
+ "import": "./dist/lsp/*.js"
27
+ }
28
+ },
29
+ "scripts": {
30
+ "prepublishOnly": "deno run -A --no-lock scripts/build.ts",
31
+ "prepare": "deno run -A --no-lock scripts/patch.ts",
32
+ "update-language-configurations": "deno run -A --no-lock scripts/update-language-configurations.ts",
33
+ "dev": "deno run -A --no-lock scripts/dev.ts",
34
+ "fmt": "dprint fmt"
35
+ },
36
+ "files": [
37
+ "dist/",
38
+ "types/"
39
+ ],
40
+ "browser": {
41
+ "process": false,
42
+ "buffer": false
43
+ },
44
+ "sideEffects": false,
45
+ "devDependencies": {
46
+ "@esm.sh/import-map": "0.1.1",
47
+ "@shikijs/core": "3.2.1",
48
+ "@shikijs/engine-oniguruma": "3.2.1",
49
+ "monaco-editor-core": "0.52.2",
50
+ "tm-grammars": "1.23.5",
51
+ "tm-themes": "1.10.1",
52
+ "typescript": "5.8.2",
53
+ "vscode-css-languageservice": "6.3.2",
54
+ "vscode-html-languageservice": "5.3.1",
55
+ "vscode-json-languageservice": "5.4.3",
56
+ "vscode-languageserver-textdocument": "1.0.12",
57
+ "vscode-languageserver-types": "3.17.5"
58
+ },
59
+ "peerDependencies": {
60
+ "typescript": ">= 5.0.0"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/esm-dev/modern-monaco.git"
65
+ },
66
+ "license": "MIT"
67
+ }
@@ -0,0 +1,7 @@
1
+ export interface ICache {
2
+ fetch(url: string | URL): Promise<Response>;
3
+ query(key: string | URL): Promise<Response | null>;
4
+ }
5
+
6
+ export const cache: ICache;
7
+ export default cache;