Commit e1fa1952 authored by Akari Labs's avatar Akari Labs

use latest nanopack, split modules into their own repos

parent a41cb721
/*
cascade!webpack 1.1
Copyright 2019 astra akari (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 in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.
*/
var _webpack;
const moduleInfo = [];
const replacements = [];
const preCtor = [];
const postCtor = [];
function ctorSearchToFunc(cond) {
if (typeof cond === 'function') return cond;
if (typeof cond === 'string') return info => info.ctor.toString().indexOf(cond) !== -1;
if (Array.isArray(cond)) return info => cond.filter(s => info.ctor.toString().indexOf(s) !== -1).length > 0;
if (cond instanceof RegExp) return info => info.ctor.toString().match(cond);
}
function callbackSearchToFunc(cond) {
if (typeof cond === 'function') return cond;
if (typeof cond === 'string') return info => info.module.exports && ((!!info.module.exports[cond]) || (info.module.exports.default && !!info.module.exports.default[cond]));
if (Array.isArray(cond)) return info => info.module.exports && ((cond.filter(s => info.module.exports[s]).length === cond.length) || (info.module.exports.default && cond.filter(s => info.module.exports.default[s]).length === cond.length));
}
const search = {
byCtor(search) {
const searchFunc = ctorSearchToFunc(search);
return moduleInfo.filter(searchFunc);
},
byCallback(search) {
const searchFunc = callbackSearchToFunc(search);
return moduleInfo.filter(searchFunc);
},
moduleInfo: moduleInfo
};
function cascadeModule(_self, _exports, _require) {
search.require = _require;
}
function exportHook(_self, _exports, _require, _ctor) {
const modinfo = {
ctor: _ctor,
module: _self
};
moduleInfo.push(modinfo);
preCtor.filter(c => c.condition(modinfo)).forEach(c => c.callback(modinfo));
modinfo.ctor(_self, _exports, _require);
postCtor.filter(c => c.condition(modinfo)).forEach(c => c.callback(modinfo));
}
function processModule(mod, i) {
if (!mod) return mod;
var ctorstr = mod.toString();
replacements.forEach(set => {
if (typeof set === 'function') set(ctorstr);
else {
if (
typeof set.search === 'function' ? set.search(ctorstr) :
set.search instanceof RegExp ? ctorstr.match(set.search) :
ctorstr.indexOf(set.search) != -1
) {
console.debug(`patching module ${i} (${set.search})`);
if (typeof set.search === 'function' && typeof set.replace !== 'function')
throw 'function search must have function replace';
ctorstr = typeof set.replace === 'function' ?
set.replace(ctorstr) :
ctorstr.replace(set.search, set.replace);
}
}
});
return (s, e, r) => exportHook(s, e, r, eval(`(${ctorstr})`));
}
function pushHook(mod) {
if (Array.isArray(mod)) {
console.debug(`processing ${mod.length} modules (in array)`);
for (var i in mod) mod[i] = processModule(mod[i], i);
}
else if (typeof mod === 'object') {
var keys = Object.keys(mod);
console.debug(`processing ${keys.length} modules (in object)`);
keys.forEach(i => mod[i] = processModule(mod[i], i));
}
/*else if (typeof mod === 'function') {
console.debug(`processing a module (single)`);
mod = processModule(mod);
}*/
else {
console.warn(`weird type passed to push (${typeof mod}); ignoring it`);
console.debug(mod);
}
return mod;
}
function hookWebpack() {
console.debug('hooking webpackJsonp');
Object.defineProperty(window, 'webpackJsonp', {
get: () => _webpack,
set(webpack) {
_webpack = (x, mod) => webpack(x, pushHook(mod));
setTimeout(() => webpack([9e9, 0], [cascadeModule]), 10);
}
});
}
module.exports = {
search, hookWebpack,
replacements, preCtor, postCtor
};
\ No newline at end of file
const cascade = require('cascade!webpack');
const ui = new (require('gltchrr!ui'))();
const cascade = require('cascade.webpack');
const ui = new (require('gltchrr.ui'))();
const gltchrr = ui.gltchrr;
......
/*
inertDOM
a ridiculously simple jsx dom function provider
Copyright 2019 astra akari (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 in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.
*/
function reduceChild(child) {
if (Array.isArray(child)) return child.map(reduceChild);
return [child];
}
function dom(tag, attrs, ...children) {
if (children.length === 1 && Array.isArray(children[0])) children = children[0];
if (children.length !== 0)
children = children.map(reduceChild)
.reduce((p, c) => p.concat(c));
var element;
switch (typeof tag) {
case 'function':
element = tag(attrs || {}, children);
break;
case 'string':
element = document.createElement(tag);
if (attrs) Object.keys(attrs).forEach(k => {
const a = attrs[k];
switch (typeof a) {
case 'boolean':
if (a) element.setAttribute(k, '');
break;
case 'function':
// a bit of a hack, but it works
if (k.startsWith('on')) {
element[k] = a;
break;
}
default:
element.setAttribute(k, a);
break;
}
});
children.forEach(child => {
if (child instanceof HTMLElement)
return element.appendChild(child);
if (typeof child === 'string')
return element.append(child);
})
break;
}
return element;
}
module.exports = dom;
\ No newline at end of file
.kwm_transform {
position: absolute;
display: none;
}
#kwm_parent {
all: initial;
width: 0px;
height: 0px;
}
.kwm_win {
position: fixed;
z-index: 99998;
font-size: 12px;
background-color: #444;
opacity: 0.8;
color: white;
font-family: sans-serif;
}
.kwm_win_hdr {
z-index: 99999;
padding: 2px;
background-color: #8300e0;
cursor: default;
}
.kwm_win_body {
padding: 4px;
}
.kwm_win_handle {
position: absolute;
right: 0px;
bottom: 0px;
width: 0px;
height: 0px;
border-right: 8px solid white;
border-top: 8px solid transparent;
cursor: se-resize;
}
.kwm_win_body * {
margin-left: 0px;
margin-right: 0px;
}
.kwm_win_body input,
.kwm_win_body button {
display: initial !important;
border-radius: initial !important;
box-shadow: initial !important;
font-size: unset !important;
padding: initial !important;
height: initial !important;
box-shadow: initial !important;
}
.kwm_win_body input[type="checkbox"],
.kwm_win_body input[type="radio"] {
position: relative;
top: 3px;
}
/* range slider */
.kwm_win_body input[type="range"] {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 10px;
background: #777;
outline: none;
}
.kwm_win_body input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 10px;
height: 10px;
background-color: #6800b2;
}
.kwm_win_body input[type="range"]::-moz-range-thumb {
width: 10px;
height: 10px;
background-color: #6800b2;
border: none;
border-radius: 0;
}
.kwm_win_body input[type="range"]:hover::-webkit-slider-thumb {
background-color: #8300e0;
}
.kwm_win_body input[type="range"]:hover::-moz-range-thumb {
background-color: #8300e0;
}
.kwm_win_body input[type="range"]:active::-webkit-slider-thumb {
background-color: #4b0082;
}
.kwm_win_body input[type="range"]:active::-moz-range-thumb {
background-color: #4b0082;
}
/* button */
.kwm_win_body button {
border: none;
outline: none;
text-align: center;
text-decoration: none;
display: inline-block;
background-color: #6800b2;
color: white;
}
.kwm_win_body button:hover {
background-color: #8300e0;
}
.kwm_win_body button:active {
background-color: #4b0082;
}
/* textbox */
.kwm_win_body input[type="text"] {
background-color: #777;
border-style: none;
color: white;
outline: none;
width: 100%;
font-family: sans-serif;
}
\ No newline at end of file
/*
kwm (keira's window manager)
a tiny (and hopefully cute) html+js window manager
Copyright 2019 caela akari (lp0)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.
*/
const inject = require('inject');
function KParent(attr, children) {
return <div id="kwm_parent">{children}</div>
}
function KWindowHeader(attr, children) {
return <div class="kwm_win_hdr">{attr.title || 'kwm'}</div>
}
function KWindowBody(attr, children) {
return <div class="kwm_win_body">{children}</div>
}
function KWindowHandle(attr, children) {
return <div class="kwm_win_handle" />
}
function KWindow(attr, children) {
var hdr, handle;
const element = <div class="kwm_win">
{hdr = <KWindowHeader title={attr.title} />}
<KWindowBody>{children}</KWindowBody>
{handle = attr.resizable ? <KWindowHandle /> : null}
</div>
element.hdr = hdr;
element.handle = handle;
element.style.left = (attr.x || 32) + 'px';
element.style.top = (attr.y || 32) + 'px';
element.style.width = (attr.width || 256) + 'px';
element.style.height = (attr.height || 256) + 'px';
return element;
}
var container;
function makeDraggable(win, header, handle) {
var cX, cY, dX, dY;
function cleanup() {
document.onmouseup = null;
document.onmousemove = null;
}
function updateClientX(e) {
cX = e.clientX;
}
function updateClientY(e) {
cY = e.clientY;
}
function updateClient(e) {
updateClientX(e);
updateClientY(e);
}
function updateDelta(e) {
dX = cX - e.clientX;
dY = cY - e.clientY;
}
(header || win).onmousedown = e => {
e.preventDefault();
updateClient(e);
document.onmousemove = e => {
e.preventDefault();
updateDelta(e);
const newX = win.offsetLeft - dX;
const newY = win.offsetTop - dY;
if (!(newX < 0 || newX + win.offsetWidth > window.innerWidth)) {
win.style.left = (win.offsetLeft - dX) + 'px';
updateClientX(e);
}
if (!(newY < 0 || newY + win.offsetHeight > window.innerHeight)) {
win.style.top = (win.offsetTop - dY) + 'px';
updateClientY(e);
}
};
document.onmouseup = cleanup;
};
if (handle) handle.onmousedown = e => {
e.preventDefault();
updateClient(e);
document.onmousemove = e => {
e.preventDefault();
updateDelta(e);
const newW = win.offsetWidth - dX;
const newH = win.offsetHeight - dY;
if (!(newW < 64)) {
win.style.width = (win.offsetWidth - dX) + 'px';
updateClientX(e);
}
if (!(newH < 64)) {
win.style.height = (win.offsetHeight - dY) + 'px';
updateClientY(e);
}
};
document.onmouseup = cleanup;
};
}
module.exports = {
Window: KWindow,
init() {
if (!container) {
inject.css(require('kwm.css'));
document.body.appendChild(container = <KParent />);
}
},
makeDraggable,
append(win) {
container.appendChild(win);
makeDraggable(win, win.hdr, win.handle);
return win;
}
}
\ No newline at end of file
const inject = require('inject');
const ui = new (require('gltchrr!ui'))({
const ui = new (require('gltchrr.ui'))({
y: 544
});
......
......@@ -94,12 +94,20 @@
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
},
"nanopack": {
"version": "git+https://git.agiri.ninja/lp0/nanopack.git#ecda1e9fee6a6a8625aabf30003ea929b9943379",
"version": "git+https://git.agiri.ninja/lp0/nanopack.git#ab50fe4f706427cd0ed77da5818a7bee65d872b2",
"from": "git+https://git.agiri.ninja/lp0/nanopack.git",
"requires": {
"buble": "^0.19.7"
}
},
"nanopack_cascade": {
"version": "git+https://git.agiri.ninja/lp0/cascade-webpack.git#092949ed12da80e791d69caeb70025ef40693dff",
"from": "git+https://git.agiri.ninja/lp0/cascade-webpack.git"
},
"nanopack_kwm": {
"version": "git+https://git.agiri.ninja/lp0/kwm.git#707172a2aa2d4dbb585b86699c6ed0fd5f98a45d",
"from": "git+https://git.agiri.ninja/lp0/kwm.git"
},
"os-homedir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
......
......@@ -14,6 +14,8 @@
"author": "lp0",
"license": "MIT",
"dependencies": {
"nanopack": "git+https://git.agiri.ninja/lp0/nanopack.git"
"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"
}
}
module.exports = function () {
return {
header: `// ==UserScript==
module.exports = () => ({
header: `// ==UserScript==
// @name gltchrr for PleromaFE
// @namespace http://akari.vii/
// @version 1.2.0
......@@ -12,12 +11,15 @@ module.exports = function () {
// ==/UserScript==
`,
jsxmodule: 'inertdom',
directories: [
'modules/shared',
'modules/pleromafe'
],
main: ['index'],
output: 'gltchrr_pleromafe.userscript.js'
}
}
\ No newline at end of file
jsxmodule: 'inertdom',
directories: [
'modules/shared',
'modules/pleromafe'
],
modules: [
'nanopack_kwm',
'nanopack_cascade'
],
main: ['index'],
output: 'gltchrr_pleromafe.userscript.js'
});
\ No newline at end of file
module.exports = function () {
return {
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>`,
jsxmodule: 'inertdom',
directories: [
'modules/shared',
'modules/standalone'
],
main: ['index'],
output: 'gltchrr.html'
}
}
\ No newline at end of file
module.exports = () => ({
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>`,
jsxmodule: 'inertdom',
directories: [
'modules/shared',
'modules/standalone'
],
modules: [
'nanopack_kwm',
'nanopack_cascade'
],
main: ['index'],
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