Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+9
@@ -14,5 +14,14 @@ describe("Lazy Monaco editor boundary", () => {
|
||||
const clientSource = readRepoFile("apps/web/app/components/editors/MonacoEditor.client.tsx");
|
||||
|
||||
expect(clientSource).toContain('from "@monaco-editor/react"');
|
||||
expect(clientSource).toContain('from "monaco-editor/esm/vs/editor/editor.api.js"');
|
||||
expect(clientSource).not.toContain('from "monaco-editor"');
|
||||
expect(clientSource).toContain("loader.config({ monaco })");
|
||||
expect(clientSource).toContain("globalThis.MonacoEnvironment");
|
||||
expect(clientSource.match(/monaco-editor\/.+\?worker/g)).toHaveLength(5);
|
||||
expect(clientSource).toContain("globalThis.location.origin");
|
||||
expect(clientSource).toContain("new Worker(sameOriginUrl");
|
||||
expect(clientSource).not.toMatch(/https?:\/\//);
|
||||
expect(clientSource).not.toContain("cdn.jsdelivr.net");
|
||||
});
|
||||
});
|
||||
+50
-1
@@ -1,8 +1,57 @@
|
||||
import { Editor, useMonaco } from "@monaco-editor/react";
|
||||
import { Editor, loader, useMonaco } from "@monaco-editor/react";
|
||||
import clsx from "clsx";
|
||||
import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
|
||||
import "monaco-editor/esm/vs/editor/editor.all.js";
|
||||
import "monaco-editor/esm/vs/language/css/monaco.contribution.js";
|
||||
import "monaco-editor/esm/vs/language/html/monaco.contribution.js";
|
||||
import "monaco-editor/esm/vs/language/json/monaco.contribution.js";
|
||||
import "monaco-editor/esm/vs/language/typescript/monaco.contribution.js";
|
||||
import "monaco-editor/esm/vs/basic-languages/css/css.contribution.js";
|
||||
import "monaco-editor/esm/vs/basic-languages/html/html.contribution.js";
|
||||
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
|
||||
import "monaco-editor/esm/vs/basic-languages/markdown/markdown.contribution.js";
|
||||
import "monaco-editor/esm/vs/basic-languages/sql/sql.contribution.js";
|
||||
import "monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution.js";
|
||||
import "monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js";
|
||||
import CssWorkerUrl from "monaco-editor/esm/vs/language/css/css.worker?worker&url";
|
||||
import EditorWorkerUrl from "monaco-editor/esm/vs/editor/editor.worker?worker&url";
|
||||
import HtmlWorkerUrl from "monaco-editor/esm/vs/language/html/html.worker?worker&url";
|
||||
import JsonWorkerUrl from "monaco-editor/esm/vs/language/json/json.worker?worker&url";
|
||||
import TypeScriptWorkerUrl from "monaco-editor/esm/vs/language/typescript/ts.worker?worker&url";
|
||||
import { Fragment, useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const MONACO_WORKER_URLS: Readonly<Record<string, string>> = {
|
||||
css: CssWorkerUrl,
|
||||
handlebars: HtmlWorkerUrl,
|
||||
html: HtmlWorkerUrl,
|
||||
javascript: TypeScriptWorkerUrl,
|
||||
json: JsonWorkerUrl,
|
||||
less: CssWorkerUrl,
|
||||
razor: HtmlWorkerUrl,
|
||||
scss: CssWorkerUrl,
|
||||
typescript: TypeScriptWorkerUrl,
|
||||
};
|
||||
|
||||
export function createMonacoWorker(label: string): Worker {
|
||||
const emittedUrl = MONACO_WORKER_URLS[label] ?? EditorWorkerUrl;
|
||||
const resolvedUrl = new URL(emittedUrl, globalThis.location.href);
|
||||
// Worker constructors require same-origin URLs. Keep worker entry points on
|
||||
// the application origin even when the regular Vite asset base points at a
|
||||
// first-party CDN; the immutable assets remain available at the origin.
|
||||
const sameOriginUrl = new URL(`${resolvedUrl.pathname}${resolvedUrl.search}${resolvedUrl.hash}`, globalThis.location.origin);
|
||||
return new Worker(sameOriginUrl, { name: `monaco-${label || "editor"}` });
|
||||
}
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
globalThis.MonacoEnvironment = {
|
||||
getWorker: (_moduleId: string, label: string) => createMonacoWorker(label),
|
||||
};
|
||||
// Passing the locally installed ESM runtime prevents @monaco-editor/react's
|
||||
// default AMD loader from downloading executable code from jsDelivr.
|
||||
loader.config({ monaco });
|
||||
}
|
||||
|
||||
export type MonacoAutoCompletion = {
|
||||
label: string;
|
||||
kind: any;
|
||||
|
||||
Reference in new issue
Block a user