Commit 2a087a9c authored by Akari Labs's avatar Akari Labs

switch to webpack

parent 8e5c15bd
......@@ -87,5 +87,8 @@ typings/
# DynamoDB Local files
.dynamodb/
# nanopack build output
build/
\ No newline at end of file
# build output
dist/
# annoying thing dolphin does
.directory
\ No newline at end of file
MIT License
Copyright (c) 2019 caela and astra akari (lp0 and nocebo)
Copyright (c) 2019 caela and atsuko akari (lp0 and nocebo)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......@@ -18,4 +18,4 @@ 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.
SOFTWARE.
\ No newline at end of file
# gltchrr
an artificial text corruption system
an artificial text corruption engine
## to use
run `npm install`, followed by `npm run build`
run `npm install --save-dev`, followed by `npm run build`
this will emit the standalone html and the pleromafe userscript
this will emit the userscripts and standalone html builds to `dist/`
you can also use gltchrr as a node module in a project with `npm install git+https://git.agiri.ninja/lp0/gltchrr.git`
\ No newline at end of file
you can also use gltchrr's corruption engine as a module in a project with `npm install git+https://git.agiri.ninja/akari/gltchrr.git`
\ No newline at end of file
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
rimraf.sync(path.resolve('dist'));
\ No newline at end of file
require('./clean');
const webpack = require('webpack');
const targets = {
standalone: require('./webpack.standalone.config'),
pleroma: require('./webpack.pleroma.config'),
discord: require('./webpack.discord.config'),
rocketchat: require('./webpack.rocketchat.config')
}
var pending = [];
if (process.argv.length > 2) {
process.argv.forEach((c, i) => {
if (i < 2) return;
pending.push(c);
});
}
else pending = Object.keys(targets);
pending.forEach(config => {
if (!(config in targets)) throw new Error(`invalid target ${config}`);
webpack(targets[config], (err, stats) => {
if (err) throw err;
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n');
});
});
\ No newline at end of file
const path = require('path');
const dev = process.env.NODE_ENV === 'dev';
const root = path.resolve(__dirname, '../');
module.exports = {
mode: dev ? 'development' : 'production',
output: {
path: path.resolve(root, 'dist'),
jsonpFunction: '$pack'
},
resolve: {
alias: {
"gltchrr": path.resolve(root, 'src/gltchrr.js'),
"gltchrr.ui": path.resolve(root, 'src/ui.jsx')
}
},
module: {
rules: [
{
test: /.css$/i,
use: 'clean-css-loader'
},
{
test: /.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/env'],
plugins: [
['transform-react-jsx', {
pragma: 'inert',
pragmaFrag: 'inert.frag',
useBuiltIns: true
}]
],
comments: false
}
}
}
]
}
}
\ No newline at end of file
const merge = require('webpack-merge');
const wrap = require('./wrap');
module.exports = merge(require('./webpack.base.config'), {
entry: './src/discord/index.js',
output: {
filename: 'gltchrr_discord.userscript.js'
},
plugins: [
wrap.userscript({name: 'gltchrr for Discord', match: 'https://discordapp.com/*' })
]
});
\ No newline at end of file
const merge = require('webpack-merge');
const wrap = require('./wrap');
module.exports = merge(require('./webpack.base.config'), {
entry: './src/pleromafe/index.js',
output: {
filename: 'gltchrr_pleroma.userscript.js'
},
plugins: [
wrap.userscript({name: 'gltchrr for PleromaFE', match: 'https://example.com/*' })
]
});
\ No newline at end of file
const merge = require('webpack-merge');
const wrap = require('./wrap');
module.exports = merge(require('./webpack.base.config'), {
entry: './src/rocketchat/index.js',
output: {
filename: 'gltchrr_rocketchat.userscript.js'
},
plugins: [
wrap.userscript({name: 'gltchrr for rocket.chat', match: 'https://example.com/*' })
]
});
\ No newline at end of file
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const dev = process.env.NODE_ENV === 'dev';
module.exports = merge(require('./webpack.base.config'), {
entry: './src/standalone/index.jsx',
output: {
filename: 'standalone_bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
filename: 'gltchrr.html',
template: 'src/standalone/template.html',
inject: true,
minify: dev ? false : {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
},
inlineSource: '.(js|css)$'
}),
new HtmlWebpackInlineSourcePlugin()
]
});
\ No newline at end of file
const WrapperPlugin = require('wrapper-webpack-plugin');
const baseSettings = {
afterOptimizations: true
}
function getWrapper(match, header, footer) {
return new WrapperPlugin(Object.assign({
match, header, footer
}, baseSettings));
}
module.exports = {
userscript({ name, match }) {
return getWrapper(/\.js$/,
`// ==UserScript==
// @name ${name}
// @description g̴̐͋litcc̣̟̭̿cch
// @author lp0 and nocebo
// @match ${match}
// @grant none
// @run-at document-start
// ==/UserScript==
`);
}
};
\ No newline at end of file
module.exports = require('./modules/shared/gltchrr');
\ No newline at end of file
module.exports = {
css(data) {
const style = document.createElement('style');
style.innerHTML = data;
document.head.appendChild(style);
}
}
\ No newline at end of file
This diff is collapsed.
{
"name": "gltchrr",
"version": "0.0.0",
"description": "an artificial text corruption system",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node node_modules/nanopack/build.js"
},
"description": "an artificial text corruption engine",
"repository": {
"type": "git",
"url": "https://git.agiri.ninja/lp0/gltchrr.git"
},
"author": "lp0",
"author": "lp0 and nocebo",
"license": "MIT",
"private": true,
"main": "./src/gltchrr.js",
"scripts": {
"build": "node build",
"clean": "node build/clean.js"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.0",
"babel-loader": "^8.0.6",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"cascade": "git+https://git.agiri.ninja/akari/cascade-webpack.git",
"css-loader": "^3.0.0",
"html-webpack-inline-source-plugin": "0.0.10",
"html-webpack-plugin": "^3.2.0",
"keirawm": "git+https://git.agiri.ninja/akari/kwm.git",
"rimraf": "^2.6.3",
"tsundiscord": "git+https://git.agiri.ninja/akari/tsundiscord.git",
"webpack": "^4.35.2",
"webpack-cli": "^3.3.5",
"wrapper-webpack-plugin": "^2.1.0"
},
"dependencies": {
"nanopack": "git+https://git.agiri.ninja/lp0/nanopack.git",
"nanopack_cascade": "git+https://git.agiri.ninja/lp0/cascade-webpack.git",
"nanopack_kwm": "git+https://git.agiri.ninja/lp0/kwm.git",
"nanopack_tsundiscord": "git+https://git.agiri.ninja/lp0/tsundiscord.git"
"clean-css-loader": "git+https://git.agiri.ninja/akari/clean-css-loader.git",
"inert2": "git+https://git.agiri.ninja/akari/inert2.git",
"to-string-loader": "^1.1.5",
"webpack-merge": "^4.2.1"
}
}
{
"friendly_name": "gltchrr",
"depends": [
"nanopack_kwm"
],
"modules": {
"inject": {
"filename": "modules/inject.js"
},
"@index": {
"filename": "modules/gltchrr.js"
},
"ui": {
"filename": "modules/ui.jsx",
"type": "jsx"
}
}
}
\ No newline at end of file
const ui = new (require('gltchrr!ui'))();
const gltchrr = ui.gltchrr;
// expose the control functions through window.gltchrr
window.gltchrr = ui.gltchrr.control;
var showing = false;
module.exports = {
selfbot: {
callbacks: [gltchrr.processText],
commands: {
gltoggle: {
description: 'Toggle showing the gltchrr UI',
action: m => {
if (showing) {
ui.hide();
showing = false;
}
else {
ui.show();
showing = true;
}
m.content = '';
}
}
}
}
};
\ No newline at end of file
{
"friendly_name": "gltchrr_discord",
"depends": [
"../..",
"nanopack_tsundiscord"
],
"modules": {
"@index": {
"filename": "hook.js",
"doCallbacks": true
}
},
"main": [
"gltchrr_discord"
]
}
\ No newline at end of file
const ui = new (require('gltchrr!ui'))();
const gltchrr = ui.gltchrr;
// expose the control functions through window.gltchrr
window.gltchrr = ui.gltchrr.control;
module.exports = {
ready() {
ui.show();
},
cascade: {
postCtor: [
{
condition: info =>
info.module.exports &&
info.module.exports.default &&
info.module.exports.default.postStatus &&
info.module.exports.default.register,
callback: info => {
const _postStatus = info.module.exports.default.postStatus;
info.module.exports.default.postStatus = e => (e.status = gltchrr.processText(e.status), _postStatus(e));
}
}
]
}
};
\ No newline at end of file
{
"friendly_name": "gltchrr_pleromafe",
"depends": [
"../..",
"nanopack_cascade"
],
"modules": {
"@index": {
"filename": "hook.js",
"doCallbacks": true
}
},
"main": [
"gltchrr_pleromafe"
]
}
\ No newline at end of file
{
"friendly_name": "gltchrr_rocketchat",
"depends": [
"../.."
],
"modules": {
"@index": {
"filename": "hook.js"
}
},
"main": [
"gltchrr_rocketchat"
]
}
\ No newline at end of file
{
"friendly_name": "gltchrr_standalone",
"depends": [
"../.."
],
"modules": {
"index.css": {
"filename": "standalone.css",
"type": "css"
},
"@index": {
"filename": "standalone.jsx",
"type": "jsx"
}
},
"main": [
"gltchrr_standalone"
]
}
\ No newline at end of file
const ui = new (require('gltchrr.ui'))();
const cascade = require('cascade');
const { selfbot } = require('tsundiscord');
const gltchrr = ui.gltchrr;
// expose the control functions through window.gltchrr
window.gltchrr = ui.gltchrr.control;
var showing = false;
cascade.hookWebpack();
selfbot.installCallback(gltchrr.processText);
selfbot.installCommand('gltoggle', {
description: 'Toggle showing gltchrr UI',
action: m => {
if (showing) {
ui.hide();
showing = false;
}
else {
ui.show();
showing = true;
}
m.content = '';
}
});
console.log('hello')
\ No newline at end of file
const ui = new (require('gltchrr.ui'))();
const cascade = require('cascade');
const gltchrr = ui.gltchrr;
// expose the control functions through window.gltchrr
window.gltchrr = ui.gltchrr.control;
cascade.hookWebpack();
cascade.installPostCtor(
info =>
info.module.exports &&
info.module.exports.default &&
info.module.exports.default.postStatus &&
info.module.exports.default.register,
info => {
const _postStatus = info.module.exports.default.postStatus;
info.module.exports.default.postStatus = e => (e.status = gltchrr.processText(e.status), _postStatus(e));
}
);
window.onload = () => ui.show();
\ No newline at end of file
const ui = new (require('gltchrr!ui'))();
const ui = new (require('gltchrr.ui'))();
const gltchrr = ui.gltchrr;
......
const kwm = require('kwm');
/** @jsx inert */
const inert = require('inert2');
const kwm = require('keirawm');
const { Window } = kwm;
const ui = new (require('gltchrr!ui'))({
const ui = new (require('gltchrr.ui'))({
x: 512 + 8 * 2,
y: 8
});
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>gltchrr</title>
</head>
<body>
<noscript>
<h1>this page requires javascript, sorry!</h1>
</noscript>
</body>
</html>
\ No newline at end of file
/** @jsx inert */
const inert = require('inert2');
const _gltchrr = require('gltchrr');
const kwm = require('kwm');
const kwm = require('keirawm');
const { Window } = kwm;
function GltchrrWindow(attr) {
......
module.exports = {
finalize: true,
minify: true,
header: `// ==UserScript==
// @name gltchrr for Discord
// @namespace http://akari.vii/
// @version 1.2.5
// @description g̴̐͋litcc̣̟̭̿cch
// @author lp0 and nocebo
// @match https://discordapp.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
`,
packages: [
'./packages/discord'
],
output: 'gltchrr_discord.userscript.js'
};
\ No newline at end of file
module.exports = {
finalize: true,
minify: true,
header: `// ==UserScript==
// @name gltchrr for Pleroma
// @namespace http://akari.vii/
// @version 1.2.5
// @description g̴̐͋litcc̣̟̭̿cch
// @author lp0 and nocebo
// @match https://girldick.icu/*
// @grant none
// @run-at document-start
// ==/UserScript==
`,
packages: [
'./packages/pleromafe'
],
output: 'gltchrr_pleromafe.userscript.js'
};
\ No newline at end of file
module.exports = {
finalize: true,
minify: true,
header: `// ==UserScript==
// @name gltchrr for rocket.chat
// @namespace http://akari.vii/
// @version 1.2.5
// @description g̴̐͋litcc̣̟̭̿cch
// @author lp0 and nocebo
// @match https://meow.natalie.ee/*
// @grant none
// @run-at document-start
// ==/UserScript==
`,
packages: [
'./packages/rocketchat'
],
output: 'gltchrr_rocketchat.userscript.js'
};
\ No newline at end of file
{
"finalize": true,
"minify": true,
"header": "<!DOCTYPE HTML><html><head><meta charset=\"utf-8\"><script>",
"footer": "</script></head><body><noscript><h1>this page requires javascript, sorry!</h1></noscript></body></html>",
"packages": [
"./packages/standalone"
],
"output": "gltchrr.html"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment