Compare commits

...
2 Commits
9 changed files with 124 additions and 41 deletions
+5
View File
@@ -1,4 +1,9 @@
{
"ignorePatterns": [
"node_modules/",
"settings.*.js",
"webpack.*.js"
],
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "google"],
"parser": "@babel/eslint-parser",
+62 -24
View File
File diff suppressed because one or more lines are too long
+8 -2
View File
@@ -1,17 +1,18 @@
{
"name": "mybb-april-fools",
"version": "1.0.0",
"version": "1.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "mybb-april-fools",
"version": "1.0.0",
"version": "1.1.0",
"license": "https://forumd.ru/viewtopic.php?id=5751#rule",
"dependencies": {
"@babel/eslint-parser": "^7.24.1",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"cursor-effects": "^1.0.11",
"ignore-loader": "^0.1.2",
"jquery": "^3.6.4",
"webpack-utf8-bom": "^1.4.0"
},
@@ -7587,6 +7588,11 @@
"node": ">= 4"
}
},
"node_modules/ignore-loader": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ignore-loader/-/ignore-loader-0.1.2.tgz",
"integrity": "sha512-yOJQEKrNwoYqrWLS4DcnzM7SEQhRKis5mB+LdKKh4cPmGYlLPR0ozRzHV5jmEk2IxptqJNQA5Cc0gw8Fj12bXA=="
},
"node_modules/ignore-walk": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-4.0.1.tgz",
+1
View File
@@ -49,6 +49,7 @@
"@babel/eslint-parser": "^7.24.1",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"cursor-effects": "^1.0.11",
"ignore-loader": "^0.1.2",
"jquery": "^3.6.4",
"webpack-utf8-bom": "^1.4.0"
}
+21
View File
@@ -23,3 +23,24 @@ export function getTextNodes(
filter((_, node) => node.nodeType === Node.TEXT_NODE);
}
let debugEnabled = ((scriptElement) => {
if (!(scriptElement instanceof HTMLScriptElement)) {
return false;
}
return !/\.min\.js$/.test(scriptElement.src);
})(document.currentScript);
/**
* Отоброзить отладочное сообщение
*/
export function debug(...data: (string|number|object)[]) {
if (!debugEnabled) return;
console.log(...data);
}
/**
* Включить отладку
*/
export function enableDebug() {
debugEnabled = true;
}
+6 -3
View File
@@ -1,6 +1,7 @@
import './types/mybb.d.ts';
import './types/mybb.d';
import {Joke, JokeSettings, StoppableJoke} from './joke';
import {JokerUI} from './ui';
import {debug} from './common';
/**
* Блок обработки перво-апрельских шуток
@@ -13,6 +14,7 @@ export class JokerClass {
* Общие настройки системы
*/
core_settings = new CoreSettings();
/**
* Перечисление всех шуток
*/
@@ -235,9 +237,10 @@ export class JokerClass {
if (!forced && (!joke.settings.enabled || !this.check(joke.settings.chance))
) {
debug(joke.title, '- шутка не включена');
return;
}
debug(joke.title, '- шутка включена');
joke.start();
}
@@ -297,7 +300,7 @@ type JokeHandler = () => void;
* Объект хранения шуток
*/
interface JokeMap {
[key: string]: Joke< JokeSettings>;
[key: string]: Joke<JokeSettings>;
}
/**
+2 -4
View File
@@ -1,7 +1,5 @@
// / <reference path="html.d.ts"/>
import './types/html.d.ts';
import './types/mybb.d.ts';
import './types/html.d';
import './types/mybb.d';
import {JokerClass} from './joker';
import $ from 'jquery';
+14 -3
View File
@@ -3,8 +3,9 @@ const webpack = require("webpack");
const BomPlugin = require("webpack-utf8-bom");
const TerserPlugin = require("terser-webpack-plugin");
const { libBanner } = require("./webpack.banner");
const { libUpload } = require("./webpack.upload");
const isProduction = process.env.NODE_ENV == "production";
const isProduction = process.env.NODE_ENV === "production";
const config = {
entry: "./src/main.ts",
@@ -20,9 +21,19 @@ const config = {
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
test: /\.tsx?$/i,
loader: "ts-loader",
exclude: ["/node_modules/"],
exclude: /node_modules|\.d\.ts$/,
// exclude: ["/node_modules/|.d.ts"],
options: {
compilerOptions: {
noEmit: false,
},
},
},
{
test: /\.d\.ts$/i,
loader: 'ignore-loader'
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
+5 -5
View File
@@ -1,16 +1,16 @@
const { exec } = require("node:child_process");
const { exec } = require('node:child_process');
const libUpload = {
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", (compilation) => {
exec("./upload.sh", (err, stdout, stderr) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
exec('./upload.sh', (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
console.log("Uploaded.");
console.log('Uploaded.');
});
});
},
}
module.exports
module.exports = { libUpload };