Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Hristov <[email protected]>
  • Loading branch information
NikolaRHristov committed Jul 8, 2024
1 parent 0065c69 commit 13131d2
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 59 deletions.
80 changes: 66 additions & 14 deletions Source/Context/Action.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import type { JSX } from "solid-js";
self.MonacoEnvironment = {
createTrustedTypesPolicy: () => undefined,
getWorker: async (_WorkerID, Label) => {
switch (Label) {
case "css":
return new (
await import(
// @ts-expect-error
"monaco-editor/esm/vs/language/css/css.worker.js?worker"
)
).default();

import { _Function } from "@Context/Action/Context";
import "@Script/Monaco";
import Light from "@Script/Monaco/Theme/Active4D.json";
import Dark from "@Script/Monaco/Theme/Amoled.json";
case "html":
return new (
await import(
// @ts-expect-error
"monaco-editor/esm/vs/language/html/html.worker.js?worker"
)
).default();

import { editor as Monaco } from "monaco-editor";
case "typescript":
return new (
await import(
// @ts-expect-error
"monaco-editor/esm/vs/language/typescript/ts.worker.js?worker"
)
).default();

Monaco.defineTheme("Light", Light as Monaco.IStandaloneThemeData);
Monaco.defineTheme("Dark", Dark as Monaco.IStandaloneThemeData);

window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", ({ matches }) =>
Monaco.setTheme(matches ? "Dark" : "Light"),
);
default:
return new (
await import(
// @ts-expect-error
"monaco-editor/esm/vs/editor/editor.worker.js?worker"
)
).default();
}
},
};

export default ({ children }: { children?: JSX.Element }) => (
<_Function.Provider value={_Function.defaultValue}>
Expand All @@ -30,3 +51,34 @@ export default ({ children }: { children?: JSX.Element }) => (
{children}
</_Function.Provider>
);

// TODO: IMPORT AND SET ASYNC
export const { editor: Monaco, languages } = await import("monaco-editor");

languages.typescript.typescriptDefaults.setEagerModelSync(true);

Monaco.defineTheme(
"Light",
(await import("@Script/Monaco/Theme/Active4D.json"))
.default as editor.IStandaloneThemeData,
);
Monaco.defineTheme(
"Dark",
(await import("@Script/Monaco/Theme/Amoled.json"))
.default as editor.IStandaloneThemeData,
);
// TODO: END IMPORT AND SET ASYNC

// TODO: WATCH THIS ASYNC
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", ({ matches }) =>
Monaco.setTheme(matches ? "Dark" : "Light"),
);
// TODO: END WATCH THIS ASYNC

export const { _Function } = await import("@Context/Action/Context");

import type { editor } from "monaco-editor";

import type { JSX } from "solid-js";
2 changes: 1 addition & 1 deletion Source/Element/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export default () => ({});
}
};

// @TODO: If a user logs out then logs in again, the keys are persisted in local storage, however the Access Token is no longer valid, they will either roll keys or renew. If they renew no problem. If they roll keys, their HTML gets reset.
// TODO: If a user logs out then logs in again, the keys are persisted in local storage, however the Access Token is no longer valid, they will either roll keys or renew. If they renew no problem. If they roll keys, their HTML gets reset.
export const Update: SubmitHandler<Type> = ({ Content, Field }, Event) => {
if (Event) {
Event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion Source/Interface/Persist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default interface Interface {
* The `Persist` function takes an item and a store, and saves the item to the store
* using Local Storage, while also returning the store and the item as a signal.
*
* // @TODO: Properly document
* TODO: Properly document
* @param A signal representing the item to be persisted.
*
*/
Expand Down
42 changes: 0 additions & 42 deletions Source/Script/Monaco.ts

This file was deleted.

2 changes: 1 addition & 1 deletion Target/Interface/Persist.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default interface Interface {
* The `Persist` function takes an item and a store, and saves the item to the store
* using Local Storage, while also returning the store and the item as a signal.
*
* // @TODO: Properly document
* TODO: Properly document
* @param A signal representing the item to be persisted.
*
*/
Expand Down

0 comments on commit 13131d2

Please sign in to comment.