Skip to content

Commit

Permalink
🔥 chore: remove frontend
Browse files Browse the repository at this point in the history
Signed-off-by: SimonShiki <sinangentoo@gmail.com>
  • Loading branch information
SimonShiki committed Oct 9, 2023
1 parent 3c84377 commit 69f61d4
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 439 deletions.
6 changes: 1 addition & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript",
["@babel/preset-react", {"runtime": "automatic"}]
],
"plugins": [
"styled-jsx/babel"
"@babel/preset-typescript"
]
}
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"indent": ["error", 4],
"dot-notation": "error",
"block-scoped-var": "error",
"capitalized-comments": "warn",
"eqeqeq": "error",
"multiline-comment-style": ["error", "starred-block"],
"no-confusing-arrow": ["error"],
"no-else-return": "error",
"no-lonely-if": "error",
Expand Down
10 changes: 1 addition & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,29 @@
"author": "SimonShiki",
"private": true,
"scripts": {
"frontend": "webpack serve",
"build": "NODE_ENV=production webpack --color --bail",
"lint": "eslint ./src/ --ext .js,.ts",
"lint": "eslint ./src/ --ext .js,.ts,tsx,jsx",
"typecheck": "tsc --watch --noEmit"
},
"devDependencies": {
"@babel/core": "^7.22.17",
"@babel/preset-env": "^7.22.15",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.22.15",
"@turbowarp/types": "^0.0.11",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"babel-loader": "^9.1.3",
"babel-preset-solid": "^1.7.7",
"codingclip-worker-loader": "^3.0.9",
"eslint": "^8.49.0",
"html-webpack-plugin": "^5.5.3",
"mini-svg-data-uri": "^1.4.4",
"styled-jsx": "^5.1.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-userscript": "^3.2.2"
},
"dependencies": {
"format-message": "^6.2.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.2.2"
}
}
5 changes: 0 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { trap, inject } from './injector/inject';
import { applyFrontend } from './ui';
import { log } from './util/log';

// @ts-expect-error defined in webpack define plugin
Expand All @@ -10,7 +9,3 @@ if (typeof window.chibi.vm !== 'undefined') {
} else {
log(`Cannot find vm in this page, stop injecting.`);
}

window.onload = () => {
applyFrontend();
};
6 changes: 3 additions & 3 deletions src/injector/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function inject (vm: ChibiCompatibleVM) {
const result = await originalRefreshBlocksFunc.apply(vm.extensionManager, [...args]);
await window.chibi.loader.refreshBlocks();
return result;
}
};

const originalToJSONFunc = vm.toJSON;
vm.toJSON = function (optTargetId: string, ...args: unknown[]) {
Expand Down Expand Up @@ -117,7 +117,7 @@ export function inject (vm: ChibiCompatibleVM) {
// @ts-expect-error lazy to extend VM interface
vm.emit('LOCALE_CHANGED', locale);
return result;
}
};

// Hack for ClipCC 3.2- versions
if (typeof vm.ccExtensionManager === 'object') {
Expand All @@ -135,6 +135,6 @@ export function inject (vm: ChibiCompatibleVM) {
}
// @ts-expect-error internal hack
return originalGetOrderFunc.apply(vm.ccExtensionManager, [extensions, ...args]);
}
};
}
}
16 changes: 10 additions & 6 deletions src/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ class ChibiLoader {
}
}

// Load as builtin extension.
// @ts-expect-error
/*
* Load as builtin extension.
* @ts-expect-error
*/
const extensionObject = new ext(this.vm.runtime);
const extensionInfo = extensionObject.getInfo() as ExtensionMetadata;
this._registerExtensionInfo(extensionObject, extensionInfo, extensionInfo.id);
Expand All @@ -131,7 +133,7 @@ class ChibiLoader {
/**
* Reload a scratch-standard extension.
* @param {string} extensionId - Extension's ID
*/
*/
async reload (extensionId: string) {
const targetExt = this.loadedScratchExtension.get(extensionId);
if (!targetExt) {
Expand Down Expand Up @@ -178,7 +180,7 @@ class ChibiLoader {
* This method is only a replacement of refreshBlocks in
* original extension manager to reload locales. It should
* be replaced when there's a better solution.
*/
*/
reloadAll () {
const allPromises: Promise<ExtensionMetadata | void>[] = [];
for (const [extId] of this.loadedScratchExtension.entries()) {
Expand Down Expand Up @@ -296,8 +298,10 @@ class ChibiLoader {
*/
if (typeof menuInfo.items === 'string') {
const menuItemFunctionName = menuInfo.items;
// Bind the function here so we can pass a simple item generation function to Scratch Blocks later
// @ts-expect-error
/*
* Bind the function here so we can pass a simple item generation function to Scratch Blocks later
* @ts-expect-error
*/
menuInfo.items = this._getExtensionMenuItems.bind(this, extensionObject, menuItemFunctionName, serviceName);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/loader/make-ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function createTranslate (vm?: VM) {

const translate = (message: Message, args?: object) => {
if (message && typeof message === 'object') {
// already in the expected format
// Already in the expected format
} else if (typeof message === 'string') {
message = {
default: message
Expand Down Expand Up @@ -74,7 +74,7 @@ function createTranslate (vm?: VM) {
}

return translate;
};
}

export function makeCtx (vm?: VM) {
const ctx: Ctx = {
Expand Down
37 changes: 0 additions & 37 deletions src/ui/button.tsx

This file was deleted.

44 changes: 0 additions & 44 deletions src/ui/index.tsx

This file was deleted.

103 changes: 0 additions & 103 deletions src/ui/modal.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions src/ui/playground.tsx

This file was deleted.

Loading

0 comments on commit 69f61d4

Please sign in to comment.