Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
"dts-cli>eslint-plugin-react-hooks": "-",
"dts-cli>eslint-plugin-testing-library": "-",
"react-dev-utils>fork-ts-checker-webpack-plugin": "-",
"keyv@<5.5.3": "^5.5.3"
"keyv@<5.5.3": "^5.5.3",
"@vscode/monaco-lsp-client>monaco-editor-core": "-"
},
"patchedDependencies": {
"@vscode/monaco-lsp-client@0.1.0": "patches/@vscode__monaco-lsp-client@0.1.0.patch",
"gatsby-remark-shiki-twoslash@3.0.38": "patches/gatsby-remark-shiki-twoslash@3.0.38.patch",
"monaco-editor-core@0.56.0": "patches/monaco-editor-core@0.56.0.patch",
"coi-serviceworker@0.1.7": "patches/coi-serviceworker@0.1.7.patch",
"monaco-editor@0.56.0": "patches/monaco-editor@0.56.0.patch",
"query-string@6.14.1": "patches/query-string@6.14.1.patch",
Expand Down
1 change: 0 additions & 1 deletion packages/playground-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"jsonc-parser": "^3.3.1",
"lz-string": "^1.5.0",
"monaco-editor": "0.56.0",
"monaco-editor-core": "0.56.0",
"reflect-metadata": "^0.2.2",
"semver": "7.7.4",
"vscode-json-languageservice": "^5.7.2",
Expand Down
28 changes: 28 additions & 0 deletions packages/playground-v2/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const serve = process.argv.includes("--serve")
const playgroundBase = serve ? "/" : process.env.PLAYGROUND_BASE ?? playgroundPath

const editorWorker = fileURLToPath(import.meta.resolve("monaco-editor/editor/editor.worker"))
const monacoEditorMain = fileURLToPath(import.meta.resolve("monaco-editor/editor/editor.main.js"))
const coiServiceWorker = fileURLToPath(import.meta.resolve("coi-serviceworker/coi-serviceworker.min.js"))

const indexHtml = (await readFile(resolve(packageDirectory, "src/index.html"), "utf8")).replaceAll(
Expand All @@ -30,6 +31,26 @@ await Promise.all([
cp(coiServiceWorker, resolve(outputDirectory, "coi-serviceworker.min.js")),
])

// monaco-editor-core resolves to monaco-editor's editor entry without its
// built-in language registrations, which would compete with the tsgo LSP.
const monacoEditorCorePlugin = {
name: "monaco-editor-core",
setup(build) {
build.onResolve({ filter: /^monaco-editor-core$/ }, () => ({
path: monacoEditorMain,
namespace: "monaco-editor-core",
}))
build.onLoad({ filter: /.*/, namespace: "monaco-editor-core" }, async () => ({
contents: (await readFile(monacoEditorMain, "utf8"))
.split("\n")
.filter(line => !/\/languages\/|monaco-lsp-client|\bas (lsp|css|html|json|typescript) \}/.test(line))
.join("\n"),
loader: "js",
resolveDir: dirname(monacoEditorMain),
}))
},
}

const buildContext = await context({
absWorkingDir: packageDirectory,
bundle: true,
Expand All @@ -51,6 +72,7 @@ const buildContext = await context({
outdir: outputDirectory,
metafile: true,
platform: "browser",
plugins: [monacoEditorCorePlugin],
sourcemap: true,
target: ["es2022"],
})
Expand All @@ -69,6 +91,12 @@ if (serve) {
/node_modules\/(?:@typescript\/)?typescript(?:-wasip1-wasm)?\//.test(path)
)
if (compilerInputs.length) throw new Error(`Compiler implementation was bundled: ${compilerInputs.join(", ")}`)
const monacoBuiltinInputs = Object.keys(result.metafile.inputs).filter(path =>
/monaco-editor\/esm\/(?:vs\/languages\/features|external\/monaco-lsp-client)\//.test(path)
)
if (monacoBuiltinInputs.length) {
throw new Error(`Monaco built-in language services were bundled: ${monacoBuiltinInputs.join(", ")}`)
}
await buildContext.dispose()
await rm(websitePlayDirectory, { force: true, recursive: true })
await cp(outputDirectory, websiteStaticDirectory, { recursive: true })
Expand Down
2 changes: 1 addition & 1 deletion packages/playground-v2/src/editor-touch-scroll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as monaco from "monaco-editor-core"
import { EventType } from "monaco-editor-core/esm/vs/base/browser/touch.js"
import { EventType } from "monaco-editor/base/browser/touch.js"

export function configureEditorTouchScroll(editor: monaco.editor.IStandaloneCodeEditor, mobileLayout: MediaQueryList) {
const element = editor.getDomNode()
Expand Down
3 changes: 1 addition & 2 deletions packages/playground-v2/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ declare module "*.json" {
const value: any
export default value
}
declare module "monaco-editor/editor/contrib/links/browser/links.js"

declare module "monaco-editor-core/esm/vs/base/browser/touch.js" {
declare module "monaco-editor/base/browser/touch.js" {
export const EventType: { Change: string; Tap: string }
}

Expand Down
1 change: 0 additions & 1 deletion packages/playground-v2/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
loadLegacyCompilerVersions,
publishedNativeCompilerSelection,
} from "./compiler-versions"
import "monaco-editor/editor/contrib/links/browser/links.js"
import LZString from "lz-string"
import "reflect-metadata"
import {
Expand Down
5 changes: 4 additions & 1 deletion packages/playground-v2/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"lib": ["DOM", "ES2022"],
"strict": true,
"noEmit": true,
"skipLibCheck": true
"skipLibCheck": true,
"paths": {
"monaco-editor-core": ["./node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts"]
}
},
"include": ["src"],
"exclude": ["src/**/*.test.ts"]
Expand Down
92 changes: 0 additions & 92 deletions patches/monaco-editor-core@0.56.0.patch

This file was deleted.

85 changes: 85 additions & 0 deletions patches/monaco-editor@0.56.0.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
diff --git a/esm/vs/base/browser/domSanitize.js b/esm/vs/base/browser/domSanitize.js
index 95061a20c8ecd48ff3ca732dbb1848cd213f7965..4bbb061da3fc2115cfc1917759b1660959dd308f 100644
--- a/esm/vs/base/browser/domSanitize.js
+++ b/esm/vs/base/browser/domSanitize.js
@@ -1,6 +1,6 @@
Expand All @@ -9,3 +10,87 @@ diff --git a/esm/vs/base/browser/domSanitize.js b/esm/vs/base/browser/domSanitiz

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
diff --git a/esm/vs/base/browser/touch.js b/esm/vs/base/browser/touch.js
index 0bc8accfabad3c860ee2a705418b42254ab9a03b..15fbb29e5e441ca257e3e5aef389a8b8742d1ca3 100644
--- a/esm/vs/base/browser/touch.js
+++ b/esm/vs/base/browser/touch.js
@@ -42,9 +42,6 @@ class Gesture extends Disposable {
}, { window: mainWindow, disposables: this._store }));
}
static addTarget(element) {
- if (!Gesture.isTouchDevice()) {
- return Disposable.None;
- }
if (!Gesture.INSTANCE) {
Gesture.INSTANCE = markAsSingleton(new Gesture());
}
@@ -52,9 +49,6 @@ class Gesture extends Disposable {
return toDisposable(remove);
}
static ignoreTarget(element) {
- if (!Gesture.isTouchDevice()) {
- return Disposable.None;
- }
if (!Gesture.INSTANCE) {
Gesture.INSTANCE = markAsSingleton(new Gesture());
}
@@ -88,11 +82,12 @@ class Gesture extends Disposable {
id: touch.identifier,
initialTarget: touch.target,
initialTimeStamp: timestamp,
- initialPageX: touch.pageX,
- initialPageY: touch.pageY,
+ // Store viewport coordinates so page scrolling does not alter gestures.
+ initialPageX: touch.clientX,
+ initialPageY: touch.clientY,
rollingTimestamps: [timestamp],
- rollingPageX: [touch.pageX],
- rollingPageY: [touch.pageY]
+ rollingPageX: [touch.clientX],
+ rollingPageY: [touch.clientY]
};
const evt = this.newGestureEvent(EventType.Start, touch.target);
evt.pageX = touch.pageX;
@@ -119,16 +114,16 @@ class Gesture extends Disposable {
&& Math.abs(data.initialPageX - data.rollingPageX.at(-1)) < 30
&& Math.abs(data.initialPageY - data.rollingPageY.at(-1)) < 30) {
const evt = this.newGestureEvent(EventType.Tap, data.initialTarget);
- evt.pageX = data.rollingPageX.at(-1);
- evt.pageY = data.rollingPageY.at(-1);
+ evt.pageX = data.rollingPageX.at(-1) + targetWindow.scrollX;
+ evt.pageY = data.rollingPageY.at(-1) + targetWindow.scrollY;
this.dispatchEvent(evt);
}
else if (holdTime >= Gesture.HOLD_DELAY
&& Math.abs(data.initialPageX - data.rollingPageX.at(-1)) < 30
&& Math.abs(data.initialPageY - data.rollingPageY.at(-1)) < 30) {
const evt = this.newGestureEvent(EventType.Contextmenu, data.initialTarget);
- evt.pageX = data.rollingPageX.at(-1);
- evt.pageY = data.rollingPageY.at(-1);
+ evt.pageX = data.rollingPageX.at(-1) + targetWindow.scrollX;
+ evt.pageY = data.rollingPageY.at(-1) + targetWindow.scrollY;
this.dispatchEvent(evt);
}
else if (activeTouchCount === 1) {
@@ -244,8 +239,8 @@ class Gesture extends Disposable {
}
const data = this.activeTouches[touch.identifier];
const evt = this.newGestureEvent(EventType.Change, data.initialTarget);
- evt.translationX = touch.pageX - data.rollingPageX.at(-1);
- evt.translationY = touch.pageY - data.rollingPageY.at(-1);
+ evt.translationX = touch.clientX - data.rollingPageX.at(-1);
+ evt.translationY = touch.clientY - data.rollingPageY.at(-1);
evt.pageX = touch.pageX;
evt.pageY = touch.pageY;
this.dispatchEvent(evt);
@@ -255,8 +250,8 @@ class Gesture extends Disposable {
data.rollingPageY.shift();
data.rollingTimestamps.shift();
}
- data.rollingPageX.push(touch.pageX);
- data.rollingPageY.push(touch.pageY);
+ data.rollingPageX.push(touch.clientX);
+ data.rollingPageY.push(touch.clientY);
data.rollingTimestamps.push(timestamp);
}
if (this.dispatched) {
28 changes: 6 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading