Modular router && remove $$
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 9s
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 9s
This commit is contained in:
447
dist/sigpro.js
vendored
447
dist/sigpro.js
vendored
@@ -1,4 +1,42 @@
|
||||
(() => {
|
||||
var __create = Object.create;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
function __accessProp(key) {
|
||||
return this[key];
|
||||
}
|
||||
var __toESMCache_node;
|
||||
var __toESMCache_esm;
|
||||
var __toESM = (mod, isNodeMode, target) => {
|
||||
var canCache = mod != null && typeof mod === "object";
|
||||
if (canCache) {
|
||||
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
||||
var cached = cache.get(mod);
|
||||
if (cached)
|
||||
return cached;
|
||||
}
|
||||
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
||||
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
||||
for (let key of __getOwnPropNames(mod))
|
||||
if (!__hasOwnProp.call(to, key))
|
||||
__defProp(to, key, {
|
||||
get: __accessProp.bind(mod, key),
|
||||
enumerable: true
|
||||
});
|
||||
if (canCache)
|
||||
cache.set(mod, to);
|
||||
return to;
|
||||
};
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined")
|
||||
return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
|
||||
// src/sigpro.js
|
||||
var isFunc = (f) => typeof f === "function";
|
||||
var isObj = (o) => o && typeof o === "object";
|
||||
@@ -10,8 +48,6 @@
|
||||
var isFlushing = false;
|
||||
var batchDepth = 0;
|
||||
var effectQueue = new Set;
|
||||
var proxyCache = new WeakMap;
|
||||
var ITER = Symbol("iter");
|
||||
var MOUNTED_NODES = new WeakMap;
|
||||
var SVG_NS = "http://www.w3.org/2000/svg";
|
||||
var XLINK_NS = "http://www.w3.org/1999/xlink";
|
||||
@@ -172,52 +208,6 @@
|
||||
return val;
|
||||
};
|
||||
};
|
||||
var $$ = (target) => {
|
||||
if (!isObj(target))
|
||||
return target;
|
||||
const cached = proxyCache.get(target);
|
||||
if (cached)
|
||||
return cached;
|
||||
const subs = new Map;
|
||||
const getSubs = (key) => {
|
||||
let set = subs.get(key);
|
||||
if (!set)
|
||||
subs.set(key, set = new Set);
|
||||
return set;
|
||||
};
|
||||
const proxy = new Proxy(target, {
|
||||
get(target2, key, receiver) {
|
||||
if (typeof key !== "symbol")
|
||||
trackUpdate(getSubs(key));
|
||||
return $$(Reflect.get(target2, key, receiver));
|
||||
},
|
||||
set(target2, key, value, receiver) {
|
||||
const hadKey = Reflect.has(target2, key);
|
||||
const oldValue = Reflect.get(target2, key, receiver);
|
||||
const result = Reflect.set(target2, key, value, receiver);
|
||||
if (result && !Object.is(oldValue, value)) {
|
||||
trackUpdate(getSubs(key), true);
|
||||
if (!hadKey)
|
||||
trackUpdate(getSubs(ITER), true);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
deleteProperty(target2, key) {
|
||||
const result = Reflect.deleteProperty(target2, key);
|
||||
if (result) {
|
||||
trackUpdate(getSubs(key), true);
|
||||
trackUpdate(getSubs(ITER), true);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
ownKeys(target2) {
|
||||
trackUpdate(getSubs(ITER));
|
||||
return Reflect.ownKeys(target2);
|
||||
}
|
||||
});
|
||||
proxyCache.set(target, proxy);
|
||||
return proxy;
|
||||
};
|
||||
var watch = (sources, cb) => {
|
||||
if (cb === undefined) {
|
||||
const effect2 = createEffect(sources);
|
||||
@@ -467,6 +457,348 @@
|
||||
});
|
||||
return root;
|
||||
};
|
||||
var Fragment = (props) => props.children;
|
||||
var mount = (comp, target) => {
|
||||
const t = typeof target === "string" ? doc.querySelector(target) : target;
|
||||
if (!t)
|
||||
return;
|
||||
if (MOUNTED_NODES.has(t))
|
||||
MOUNTED_NODES.get(t).destroy();
|
||||
const inst = render(isFunc(comp) ? comp : () => comp);
|
||||
t.replaceChildren(inst.container);
|
||||
MOUNTED_NODES.set(t, inst);
|
||||
return inst;
|
||||
};
|
||||
if (typeof window !== "undefined") {
|
||||
"a abbr article aside audio b blockquote br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark meter nav object ol optgroup option output p picture pre progress section select slot small source span strong sub summary sup svg table tbody td template textarea tfoot th thead time tr u ul video".split(" ").forEach((tag) => {
|
||||
window[tag] = (props, children) => h(tag, props, children);
|
||||
});
|
||||
}
|
||||
|
||||
// src/router.js
|
||||
var import_node_fs = (() => ({}));
|
||||
|
||||
// node:path
|
||||
function assertPath(path) {
|
||||
if (typeof path !== "string")
|
||||
throw TypeError("Path must be a string. Received " + JSON.stringify(path));
|
||||
}
|
||||
function normalizeStringPosix(path, allowAboveRoot) {
|
||||
var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
|
||||
for (var i = 0;i <= path.length; ++i) {
|
||||
if (i < path.length)
|
||||
code = path.charCodeAt(i);
|
||||
else if (code === 47)
|
||||
break;
|
||||
else
|
||||
code = 47;
|
||||
if (code === 47) {
|
||||
if (lastSlash === i - 1 || dots === 1)
|
||||
;
|
||||
else if (lastSlash !== i - 1 && dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
||||
if (res.length > 2) {
|
||||
var lastSlashIndex = res.lastIndexOf("/");
|
||||
if (lastSlashIndex !== res.length - 1) {
|
||||
if (lastSlashIndex === -1)
|
||||
res = "", lastSegmentLength = 0;
|
||||
else
|
||||
res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
||||
lastSlash = i, dots = 0;
|
||||
continue;
|
||||
}
|
||||
} else if (res.length === 2 || res.length === 1) {
|
||||
res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (allowAboveRoot) {
|
||||
if (res.length > 0)
|
||||
res += "/..";
|
||||
else
|
||||
res = "..";
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
if (res.length > 0)
|
||||
res += "/" + path.slice(lastSlash + 1, i);
|
||||
else
|
||||
res = path.slice(lastSlash + 1, i);
|
||||
lastSegmentLength = i - lastSlash - 1;
|
||||
}
|
||||
lastSlash = i, dots = 0;
|
||||
} else if (code === 46 && dots !== -1)
|
||||
++dots;
|
||||
else
|
||||
dots = -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function _format(sep, pathObject) {
|
||||
var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
||||
if (!dir)
|
||||
return base;
|
||||
if (dir === pathObject.root)
|
||||
return dir + base;
|
||||
return dir + sep + base;
|
||||
}
|
||||
function resolve() {
|
||||
var resolvedPath = "", resolvedAbsolute = false, cwd;
|
||||
for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
|
||||
var path;
|
||||
if (i >= 0)
|
||||
path = arguments[i];
|
||||
else {
|
||||
if (cwd === undefined)
|
||||
cwd = process.cwd();
|
||||
path = cwd;
|
||||
}
|
||||
if (assertPath(path), path.length === 0)
|
||||
continue;
|
||||
resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
|
||||
}
|
||||
if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
|
||||
if (resolvedPath.length > 0)
|
||||
return "/" + resolvedPath;
|
||||
else
|
||||
return "/";
|
||||
else if (resolvedPath.length > 0)
|
||||
return resolvedPath;
|
||||
else
|
||||
return ".";
|
||||
}
|
||||
function normalize(path) {
|
||||
if (assertPath(path), path.length === 0)
|
||||
return ".";
|
||||
var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
||||
if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
|
||||
path = ".";
|
||||
if (path.length > 0 && trailingSeparator)
|
||||
path += "/";
|
||||
if (isAbsolute)
|
||||
return "/" + path;
|
||||
return path;
|
||||
}
|
||||
function isAbsolute(path) {
|
||||
return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
|
||||
}
|
||||
function join() {
|
||||
if (arguments.length === 0)
|
||||
return ".";
|
||||
var joined;
|
||||
for (var i = 0;i < arguments.length; ++i) {
|
||||
var arg = arguments[i];
|
||||
if (assertPath(arg), arg.length > 0)
|
||||
if (joined === undefined)
|
||||
joined = arg;
|
||||
else
|
||||
joined += "/" + arg;
|
||||
}
|
||||
if (joined === undefined)
|
||||
return ".";
|
||||
return normalize(joined);
|
||||
}
|
||||
function relative(from, to) {
|
||||
if (assertPath(from), assertPath(to), from === to)
|
||||
return "";
|
||||
if (from = resolve(from), to = resolve(to), from === to)
|
||||
return "";
|
||||
var fromStart = 1;
|
||||
for (;fromStart < from.length; ++fromStart)
|
||||
if (from.charCodeAt(fromStart) !== 47)
|
||||
break;
|
||||
var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
|
||||
for (;toStart < to.length; ++toStart)
|
||||
if (to.charCodeAt(toStart) !== 47)
|
||||
break;
|
||||
var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
|
||||
for (;i <= length; ++i) {
|
||||
if (i === length) {
|
||||
if (toLen > length) {
|
||||
if (to.charCodeAt(toStart + i) === 47)
|
||||
return to.slice(toStart + i + 1);
|
||||
else if (i === 0)
|
||||
return to.slice(toStart + i);
|
||||
} else if (fromLen > length) {
|
||||
if (from.charCodeAt(fromStart + i) === 47)
|
||||
lastCommonSep = i;
|
||||
else if (i === 0)
|
||||
lastCommonSep = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
|
||||
if (fromCode !== toCode)
|
||||
break;
|
||||
else if (fromCode === 47)
|
||||
lastCommonSep = i;
|
||||
}
|
||||
var out = "";
|
||||
for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
|
||||
if (i === fromEnd || from.charCodeAt(i) === 47)
|
||||
if (out.length === 0)
|
||||
out += "..";
|
||||
else
|
||||
out += "/..";
|
||||
if (out.length > 0)
|
||||
return out + to.slice(toStart + lastCommonSep);
|
||||
else {
|
||||
if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
|
||||
++toStart;
|
||||
return to.slice(toStart);
|
||||
}
|
||||
}
|
||||
function _makeLong(path) {
|
||||
return path;
|
||||
}
|
||||
function dirname(path) {
|
||||
if (assertPath(path), path.length === 0)
|
||||
return ".";
|
||||
var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
|
||||
for (var i = path.length - 1;i >= 1; --i)
|
||||
if (code = path.charCodeAt(i), code === 47) {
|
||||
if (!matchedSlash) {
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
matchedSlash = false;
|
||||
if (end === -1)
|
||||
return hasRoot ? "/" : ".";
|
||||
if (hasRoot && end === 1)
|
||||
return "//";
|
||||
return path.slice(0, end);
|
||||
}
|
||||
function basename(path, ext) {
|
||||
if (ext !== undefined && typeof ext !== "string")
|
||||
throw TypeError('"ext" argument must be a string');
|
||||
assertPath(path);
|
||||
var start = 0, end = -1, matchedSlash = true, i;
|
||||
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
||||
if (ext.length === path.length && ext === path)
|
||||
return "";
|
||||
var extIdx = ext.length - 1, firstNonSlashEnd = -1;
|
||||
for (i = path.length - 1;i >= 0; --i) {
|
||||
var code = path.charCodeAt(i);
|
||||
if (code === 47) {
|
||||
if (!matchedSlash) {
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (firstNonSlashEnd === -1)
|
||||
matchedSlash = false, firstNonSlashEnd = i + 1;
|
||||
if (extIdx >= 0)
|
||||
if (code === ext.charCodeAt(extIdx)) {
|
||||
if (--extIdx === -1)
|
||||
end = i;
|
||||
} else
|
||||
extIdx = -1, end = firstNonSlashEnd;
|
||||
}
|
||||
}
|
||||
if (start === end)
|
||||
end = firstNonSlashEnd;
|
||||
else if (end === -1)
|
||||
end = path.length;
|
||||
return path.slice(start, end);
|
||||
} else {
|
||||
for (i = path.length - 1;i >= 0; --i)
|
||||
if (path.charCodeAt(i) === 47) {
|
||||
if (!matchedSlash) {
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
} else if (end === -1)
|
||||
matchedSlash = false, end = i + 1;
|
||||
if (end === -1)
|
||||
return "";
|
||||
return path.slice(start, end);
|
||||
}
|
||||
}
|
||||
function extname(path) {
|
||||
assertPath(path);
|
||||
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
|
||||
for (var i = path.length - 1;i >= 0; --i) {
|
||||
var code = path.charCodeAt(i);
|
||||
if (code === 47) {
|
||||
if (!matchedSlash) {
|
||||
startPart = i + 1;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (end === -1)
|
||||
matchedSlash = false, end = i + 1;
|
||||
if (code === 46) {
|
||||
if (startDot === -1)
|
||||
startDot = i;
|
||||
else if (preDotState !== 1)
|
||||
preDotState = 1;
|
||||
} else if (startDot !== -1)
|
||||
preDotState = -1;
|
||||
}
|
||||
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
|
||||
return "";
|
||||
return path.slice(startDot, end);
|
||||
}
|
||||
function format(pathObject) {
|
||||
if (pathObject === null || typeof pathObject !== "object")
|
||||
throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
||||
return _format("/", pathObject);
|
||||
}
|
||||
function parse(path) {
|
||||
assertPath(path);
|
||||
var ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
||||
if (path.length === 0)
|
||||
return ret;
|
||||
var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
|
||||
if (isAbsolute2)
|
||||
ret.root = "/", start = 1;
|
||||
else
|
||||
start = 0;
|
||||
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
|
||||
for (;i >= start; --i) {
|
||||
if (code = path.charCodeAt(i), code === 47) {
|
||||
if (!matchedSlash) {
|
||||
startPart = i + 1;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (end === -1)
|
||||
matchedSlash = false, end = i + 1;
|
||||
if (code === 46) {
|
||||
if (startDot === -1)
|
||||
startDot = i;
|
||||
else if (preDotState !== 1)
|
||||
preDotState = 1;
|
||||
} else if (startDot !== -1)
|
||||
preDotState = -1;
|
||||
}
|
||||
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
||||
if (end !== -1)
|
||||
if (startPart === 0 && isAbsolute2)
|
||||
ret.base = ret.name = path.slice(1, end);
|
||||
else
|
||||
ret.base = ret.name = path.slice(startPart, end);
|
||||
} else {
|
||||
if (startPart === 0 && isAbsolute2)
|
||||
ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
|
||||
else
|
||||
ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
|
||||
ret.ext = path.slice(startDot, end);
|
||||
}
|
||||
if (startPart > 0)
|
||||
ret.dir = path.slice(0, startPart - 1);
|
||||
else if (isAbsolute2)
|
||||
ret.dir = "/";
|
||||
return ret;
|
||||
}
|
||||
var sep = "/";
|
||||
var delimiter = ":";
|
||||
var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
|
||||
|
||||
// src/router.js
|
||||
var router = (routes) => {
|
||||
const getHash = () => window.location.hash.slice(1) || "/";
|
||||
const path = $(getHash());
|
||||
@@ -500,26 +832,9 @@
|
||||
router.to = (p) => window.location.hash = p.replace(/^#?\/?/, "#/");
|
||||
router.back = () => window.history.back();
|
||||
router.path = () => window.location.hash.replace(/^#/, "") || "/";
|
||||
var Fragment = (props) => props.children;
|
||||
var mount = (comp, target) => {
|
||||
const t = typeof target === "string" ? doc.querySelector(target) : target;
|
||||
if (!t)
|
||||
return;
|
||||
if (MOUNTED_NODES.has(t))
|
||||
MOUNTED_NODES.get(t).destroy();
|
||||
const inst = render(isFunc(comp) ? comp : () => comp);
|
||||
t.replaceChildren(inst.container);
|
||||
MOUNTED_NODES.set(t, inst);
|
||||
return inst;
|
||||
};
|
||||
if (typeof window !== "undefined") {
|
||||
"a abbr article aside audio b blockquote br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark meter nav object ol optgroup option output p picture pre progress section select slot small source span strong sub summary sup svg table tbody td template textarea tfoot th thead time tr u ul video".split(" ").forEach((tag) => {
|
||||
window[tag] = (props, children) => h(tag, props, children);
|
||||
});
|
||||
}
|
||||
|
||||
// src/build_umd.js
|
||||
if (typeof window !== "undefined") {
|
||||
Object.assign(window, { $, $$, watch, h, Fragment, when, each, router, mount, batch, onUnmount, isArr, isFunc, isObj });
|
||||
Object.assign(window, { $, watch, h, Fragment, when, each, router, mount, batch, onUnmount, isArr, isFunc, isObj });
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user