forked from Vendicated/Vencord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bundle dependencies with extensions for webstore rule compliance (Ven…
- Loading branch information
1 parent
efb88a4
commit 41f5d71
Showing
46 changed files
with
1,634 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Vencord, a Discord client mod | ||
* Copyright (c) 2023 Vendicated and contributors | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
import "./patch-worker"; | ||
|
||
import * as monaco from "monaco-editor/esm/vs/editor/editor.main.js"; | ||
|
||
declare global { | ||
const baseUrl: string; | ||
const getCurrentCss: () => Promise<string>; | ||
const setCss: (css: string) => void; | ||
const getTheme: () => string; | ||
} | ||
|
||
const BASE = "/dist/monaco/vs"; | ||
|
||
self.MonacoEnvironment = { | ||
getWorkerUrl(_moduleId: unknown, label: string) { | ||
const path = label === "css" ? "/language/css/css.worker.js" : "/editor/editor.worker.js"; | ||
return new URL(BASE + path, baseUrl).toString(); | ||
} | ||
}; | ||
|
||
getCurrentCss().then(css => { | ||
const editor = monaco.editor.create( | ||
document.getElementById("container")!, | ||
{ | ||
value: css, | ||
language: "css", | ||
theme: getTheme(), | ||
} | ||
); | ||
editor.onDidChangeModelContent(() => | ||
setCss(editor.getValue()) | ||
); | ||
window.addEventListener("resize", () => { | ||
// make monaco re-layout | ||
editor.layout(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Vencord QuickCSS Editor</title> | ||
<style> | ||
html, | ||
body, | ||
#container { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
overflow: hidden; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="container"></div> | ||
|
||
<script> | ||
const script = document.createElement("script"); | ||
script.src = new URL("/dist/monaco/index.js", baseUrl); | ||
|
||
const style = document.createElement("link"); | ||
style.type = "text/css"; | ||
style.rel = "stylesheet"; | ||
style.href = new URL("/dist/monaco/index.css", baseUrl); | ||
|
||
document.body.append(style, script); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
Copyright 2013 Rob Wu <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
// Target: Chrome 20+ | ||
|
||
// W3-compliant Worker proxy. | ||
// This module replaces the global Worker object. | ||
// When invoked, the default Worker object is called. | ||
// If this call fails with SECURITY_ERR, the script is fetched | ||
// using async XHR, and transparently proxies all calls and | ||
// setters/getters to the new Worker object. | ||
// Note: This script does not magically circumvent the Same origin policy. | ||
|
||
(function () { | ||
'use strict'; | ||
var Worker_ = window.Worker; | ||
var URL = window.URL || window.webkitURL; | ||
// Create dummy worker for the following purposes: | ||
// 1. Don't override the global Worker object if the fallback isn't | ||
// going to work (future API changes?) | ||
// 2. Use it to trigger early validation of postMessage calls | ||
// Note: Blob constructor is supported since Chrome 20, but since | ||
// some of the used Chrome APIs are only supported as of Chrome 20, | ||
// I don't bother adding a BlobBuilder fallback. | ||
var dummyWorker = new Worker_( | ||
URL.createObjectURL(new Blob([], { type: 'text/javascript' }))); | ||
window.Worker = function Worker(scriptURL) { | ||
if (arguments.length === 0) { | ||
throw new TypeError('Not enough arguments'); | ||
} | ||
try { | ||
return new Worker_(scriptURL); | ||
} catch (e) { | ||
if (e.code === 18/*DOMException.SECURITY_ERR*/) { | ||
return new WorkerXHR(scriptURL); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
}; | ||
// Bind events and replay queued messages | ||
function bindWorker(worker, workerURL) { | ||
if (worker._terminated) { | ||
return; | ||
} | ||
worker.Worker = new Worker_(workerURL); | ||
worker.Worker.onerror = worker._onerror; | ||
worker.Worker.onmessage = worker._onmessage; | ||
var o; | ||
while ((o = worker._replayQueue.shift())) { | ||
worker.Worker[o.method].apply(worker.Worker, o.arguments); | ||
} | ||
while ((o = worker._messageQueue.shift())) { | ||
worker.Worker.postMessage.apply(worker.Worker, o); | ||
} | ||
} | ||
function WorkerXHR(scriptURL) { | ||
var worker = this; | ||
var x = new XMLHttpRequest(); | ||
x.responseType = 'blob'; | ||
x.onload = function () { | ||
// http://stackoverflow.com/a/10372280/938089 | ||
var workerURL = URL.createObjectURL(x.response); | ||
bindWorker(worker, workerURL); | ||
}; | ||
x.open('GET', scriptURL); | ||
x.send(); | ||
worker._replayQueue = []; | ||
worker._messageQueue = []; | ||
} | ||
WorkerXHR.prototype = { | ||
constructor: Worker_, | ||
terminate: function () { | ||
if (!this._terminated) { | ||
this._terminated = true; | ||
if (this.Worker) | ||
this.Worker.terminate(); | ||
} | ||
}, | ||
postMessage: function (message, transfer) { | ||
if (!(this instanceof WorkerXHR)) | ||
throw new TypeError('Illegal invocation'); | ||
if (this.Worker) { | ||
this.Worker.postMessage.apply(this.Worker, arguments); | ||
} else { | ||
// Trigger validation: | ||
dummyWorker.postMessage(message); | ||
// Alright, push the valid message to the queue. | ||
this._messageQueue.push(arguments); | ||
} | ||
} | ||
}; | ||
// Implement the EventTarget interface | ||
[ | ||
'addEventListener', | ||
'removeEventListener', | ||
'dispatchEvent' | ||
].forEach(function (method) { | ||
WorkerXHR.prototype[method] = function () { | ||
if (!(this instanceof WorkerXHR)) { | ||
throw new TypeError('Illegal invocation'); | ||
} | ||
if (this.Worker) { | ||
this.Worker[method].apply(this.Worker, arguments); | ||
} else { | ||
this._replayQueue.push({ method: method, arguments: arguments }); | ||
} | ||
}; | ||
}); | ||
Object.defineProperties(WorkerXHR.prototype, { | ||
onmessage: { | ||
get: function () { return this._onmessage || null; }, | ||
set: function (func) { | ||
this._onmessage = typeof func === 'function' ? func : null; | ||
} | ||
}, | ||
onerror: { | ||
get: function () { return this._onerror || null; }, | ||
set: function (func) { | ||
this._onerror = typeof func === 'function' ? func : null; | ||
} | ||
} | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 翠 / green | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,10 +36,13 @@ | |
"@vap/shiki": "0.10.5", | ||
"eslint-plugin-simple-header": "^1.0.2", | ||
"fflate": "^0.7.4", | ||
"gifenc": "github:mattdesl/gifenc#64842fca317b112a8590f8fef2bf3825da8f6fe3", | ||
"monaco-editor": "^0.43.0", | ||
"nanoid": "^4.0.2", | ||
"virtual-merge": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/chrome": "^0.0.246", | ||
"@types/diff": "^5.0.3", | ||
"@types/lodash": "^4.14.194", | ||
"@types/node": "^18.16.3", | ||
|
@@ -64,7 +67,8 @@ | |
"stylelint-config-standard": "^33.0.0", | ||
"tsx": "^3.12.7", | ||
"type-fest": "^3.9.0", | ||
"typescript": "^5.0.4" | ||
"typescript": "^5.0.4", | ||
"zip-local": "^0.3.5" | ||
}, | ||
"packageManager": "[email protected]", | ||
"pnpm": { | ||
|
Oops, something went wrong.