Skip to content

Commit

Permalink
🔧 chore: add commitlint & update README
Browse files Browse the repository at this point in the history
Signed-off-by: SimonShiki <[email protected]>
  • Loading branch information
SimonShiki committed Nov 21, 2024
1 parent 3870d1c commit f1e0ddb
Show file tree
Hide file tree
Showing 6 changed files with 5,914 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit $1
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ Eureka is a userscript which can load 3rd-party extensions in any Scratch-based

*Here's the refactored version of Eureka, Many platform still left untested. You can choose the legacy (version <= 8.1) Eureka or open an issue for the compatibility problem you faced in those untested platforms!*

| Platform | Load extension manually | Conversion of sideloaded blocks | Load extension from eureka-ify projects | Extended Scratch context | No mixin conflicts |
|---------------------------------|-------------------------|---------------------------------|-----------------------------------------|--------------------------|--------------------|
| Scratch | | | | | |
| Scratch(Spork) | | | | | |
| Codingclip | | | | | |
| Cocrea | | | | | |
| Aerfaying (阿儿法营) | | | | | |
| Co-Create World (共创世界) | | | | | |
| Xiaomawang (小码王) | | | | | |
| CodeLab | | | | | |
| 40code | | | | | |
| TurboWarp | | | | | |
| Xueersi (学而思) | | | | | |
| Creaticode | | | | | |
| Adacraft | | | || |
| PenguinMod | | | | | |
| ElectraMod | | | | | |
| XPLab | | | | | |
| Platform | Load extension manually | Convert sideloaded blocks | Load extension from eureka-ify projects | Extended Scratch context | No mixin conflicts |
|---------------------------------|-------------------------|---------------------------|-----------------------------------------|--------------------------|--------------------|
| Scratch ||||||
| Scratch(Spork) ||||||
| Codingclip || | |||
| Cocrea || | |||
| Aerfaying (阿儿法营) ||||||
| Co-Create World (共创世界) || | |||
| Xiaomawang (小码王) ||||||
| CodeLab ||||||
| 40code ||||||
| TurboWarp ||||||
| Xueersi (学而思) ||||||
| Creaticode ||||||
| Adacraft ||||||
| PenguinMod ||||||
| ElectraMod ||||||
| XPLab ||||||

# 🧵 Why my extensions don't works?

Expand Down
11 changes: 11 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
extends: ['gitmoji'],
rules: {
'signed-off-by': [2, 'always', 'Signed-off-by:'],
'type-enum': [2, 'always', [
'build', 'ci', 'docs', 'feat', 'fix', 'perf',
'refactor', 'revert', 'style', 'test', 'wip',
'merge', 'chore'
]]
}
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@commitlint/cli": "^19.6.0",
"@gera2ld/plaid": "~2.7.0",
"@gera2ld/plaid-rollup": "~2.7.0",
"@rollup/plugin-image": "^3.0.3",
"@unocss/postcss": "^0.64.0",
"@violentmonkey/types": "^0.2.0",
"babel-preset-solid": "^1.8.16",
"commitlint-config-gitmoji": "^2.3.1",
"cross-env": "^7.0.3",
"del-cli": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
Expand Down
9 changes: 9 additions & 0 deletions src/main/patches/applier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export function applyPatchesForBlocks (blocks?: DucktypedScratchBlocks) {
);
}

// Make the newly copied block use default drag strategy, then remove the original one.
// It's a dirty hack, may we need a better solution?
if (settings.mixins['blocks.Blocks.argument_reporter_boolean.init']) {
MixinApplicator.applyTo(
blocks.Blocks.argument_reporter_boolean,
Expand Down Expand Up @@ -224,6 +226,7 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
const sideloadIds = Object.keys(extensionInfo);

if ('targets' in obj) {
// It's a full project
for (const target of obj.targets) {
for (const blockId in target.blocks) {
const block = target.blocks[blockId];
Expand Down Expand Up @@ -254,6 +257,7 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
}
}
} else {
// It's a single sprite
for (const blockId in obj.blocks) {
const block = obj.blocks[blockId];
if (!block.opcode) continue;
Expand Down Expand Up @@ -339,6 +343,7 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
}
}

// Remove eureka's stuffs, make project data clean
if (typeof projectJSON.sideloadExtensionURLs === 'object') {
delete projectJSON.sideloadExtensionURLs;
}
Expand All @@ -361,6 +366,7 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
);
}

// Turbowarp's specific patch, to bypass security manager's check
if (settings.mixins['vm._loadExtensions'] && typeof vm._loadExtensions === 'function') {
MixinApplicator.applyTo(
vm,
Expand Down Expand Up @@ -420,6 +426,7 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
);
}

// Add Turbowarp compiler support
const ScriptTreeGenerator = vm.exports?.ScriptTreeGenerator ?? getUnsupportedAPI(vm)?.ScriptTreeGenerator;
if (ScriptTreeGenerator && settings.mixins['vm.exports.ScriptTreeGenerator.prototype.descendInput']) {
MixinApplicator.applyTo(
Expand All @@ -446,6 +453,7 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
);
}

// ClipCC specific patches, to make sideloaded extension a ClipCC extension
if (typeof vm.ccExtensionManager === 'object' && settings.mixins['vm.ccExtensionManager.getExtensionLoadOrder']) {
MixinApplicator.applyTo(
vm.ccExtensionManager,
Expand All @@ -471,6 +479,7 @@ export function applyPatchesForVM (vm: DucktypedVM, ctx: EurekaContext) {
);
}

// Turbowarp extension's polyfill
if (settings.mixins['vm.runtime._convertForScratchBlocks']) {
MixinApplicator.applyTo(
vm.runtime,
Expand Down
Loading

0 comments on commit f1e0ddb

Please sign in to comment.