diff --git a/public/assets/components/breadcrumb.js b/public/assets/components/breadcrumb.js index dc8a5f69..f93a03ae 100644 --- a/public/assets/components/breadcrumb.js +++ b/public/assets/components/breadcrumb.js @@ -1,7 +1,7 @@ import { toHref } from "../lib/skeleton/router.js"; import { animate, slideYOut, slideYIn, opacityOut } from "../lib/animate.js"; import { forwardURLParams } from "../lib/path.js"; -import { safe } from "../../lib/dom.js"; +import { safe } from "../lib/dom.js"; import assert from "../lib/assert.js"; import { settingsSave } from "../lib/store.js"; import { get as getConfig } from "../model/config.js"; diff --git a/public/assets/components/sidebar.js b/public/assets/components/sidebar.js index 9fb9978c..52d3994a 100644 --- a/public/assets/components/sidebar.js +++ b/public/assets/components/sidebar.js @@ -79,13 +79,13 @@ export default async function ctrlSidebar(render, nRestart = 0) { ctrlTagPane(createRender(qs($sidebar, `[data-bind="your-tags"]`))); } -const withResize = (function () { +const withResize = (function() { let memory = null; return ($sidebar) => { const $resize = createElement(`
`); effect(rxjs.fromEvent($resize, "mousedown").pipe( rxjs.mergeMap((e0) => rxjs.fromEvent(document, "mousemove").pipe( - rxjs.takeUntil(rxjs.fromEvent(document, "mouseup")), + rxjs.takeUntil(rxjs.fromEvent(document, "mouseup")), rxjs.startWith(e0), rxjs.pairwise(), rxjs.map(([prevX, currX]) => currX.clientX - prevX.clientX), @@ -100,7 +100,7 @@ const withResize = (function () { }), )); $sidebar.appendChild($resize); - } + }; }()); async function ctrlNavigationPane(render, { $sidebar, nRestart }) { diff --git a/public/assets/helpers/loader_wasm.js b/public/assets/helpers/loader_wasm.js index 07af6fac..24607c82 100644 --- a/public/assets/helpers/loader_wasm.js +++ b/public/assets/helpers/loader_wasm.js @@ -242,10 +242,8 @@ export class Wasi { true, ); if (fd === 1 || fd === 2) { - let msg = fd === 1? "stdout: " : "stderr: "; - msg += new TextDecoder().decode(readFS(fd)); FS[fd] = { - buffer: new Uint8Array(0), + buffer: new Uint8Array(readFS(fd)), position: 0, path: FS[fd].path || "", }; @@ -300,7 +298,7 @@ export class Wasi { const start = (offset_hi >>> 0) * 0x100000000 + (offset_lo >>> 0); const ioVec = new Uint32Array(this.#instance.exports.memory.buffer, iovs, iovs_len * 2); - const mem = new Uint8Array(this.#instance.exports.memory.buffer); + const mem = new Uint8Array(this.#instance.exports.memory.buffer); let total = 0; for (let i = 0; i < iovs_len * 2; i += 2) { @@ -311,7 +309,7 @@ export class Wasi { Math.min(len, file.buffer.length - (start + total)), ); if (avail === 0) { - console.log(`len=[${len}] buffLength=[${file.buffer.length}] start=[${start}] total=[${total}]`) + console.log(`len=[${len}] buffLength=[${file.buffer.length}] start=[${start}] total=[${total}]`); break; } mem.set( @@ -469,19 +467,19 @@ export class Wasi { __syscall_fstat64(fd, buf) { log(` syscall::fstat64 fd=${fd}, buf=${buf}`); const file = FS[fd]; - if (!file) return -1; // EBADF + if (!file) return -1; // EBADF - const size = file.buffer.byteLength >>> 0; // ≤ 4 GB + const size = file.buffer.byteLength >>> 0; // ≤ 4 GB const nowSec = (Date.now() / 1000) | 0; - const H32 = new Int32Array(this.#instance.exports.memory.buffer); + const H32 = new Int32Array(this.#instance.exports.memory.buffer); /* basic fields */ - H32[ buf >> 2] = 1; /* st_dev */ - H32[(buf+4) >> 2] = 0o100644; /* st_mode */ - H32[(buf+8) >> 2] = 1; /* st_nlink */ - H32[(buf+12) >> 2] = 1000; /* st_uid */ - H32[(buf+16) >> 2] = 1000; /* st_gid */ - H32[(buf+20) >> 2] = 0; /* st_rdev */ + H32[buf >> 2] = 1; /* st_dev */ + H32[(buf+4) >> 2] = 0o100644; /* st_mode */ + H32[(buf+8) >> 2] = 1; /* st_nlink */ + H32[(buf+12) >> 2] = 1000; /* st_uid */ + H32[(buf+16) >> 2] = 1000; /* st_gid */ + H32[(buf+20) >> 2] = 0; /* st_rdev */ H32[((buf + 24) >> 2)] = size & 0xFFFFFFFF; H32[((buf + 28) >> 2)] = Math.floor(size / 4294967296); @@ -490,22 +488,21 @@ export class Wasi { H32[(buf+36) >> 2] = (size + 511) >> 9; /* st_size lives at byte 40 in Emscripten’s 32-bit stat64 */ - H32[(buf+40) >> 2] = size; /* low 32 bits (high word = 0) */ + H32[(buf+40) >> 2] = size; /* low 32 bits (high word = 0) */ H32[(buf+44) >> 2] = 0; - H32[(buf+32) >> 2] = 4096; /* st_blksize */ + H32[(buf+32) >> 2] = 4096; /* st_blksize */ H32[(buf+36) >> 2] = (size + 511) >> 9; /* st_blocks */ /* atime / mtime / ctime: seconds, nsec = 0 */ - for (let off of [48, 56, 64]) { - H32[((buf+off) >> 2)] = nowSec; + for (const off of [48, 56, 64]) { + H32[((buf+off) >> 2)] = nowSec; H32[((buf+off+4) >> 2)] = 0; } - H32[(buf+72) >> 2] = fd; /* st_ino (low) */ - H32[(buf+76) >> 2] = 0; /* st_ino (high) */ + H32[(buf+72) >> 2] = fd; /* st_ino (low) */ + H32[(buf+76) >> 2] = 0; /* st_ino (high) */ return 0; } - } diff --git a/public/assets/lib/dom.d.ts b/public/assets/lib/dom.d.ts index c0845b11..69e53a32 100644 --- a/public/assets/lib/dom.d.ts +++ b/public/assets/lib/dom.d.ts @@ -2,4 +2,4 @@ export function qs($node: HTMLElement | DocumentFragment, selector: string); export function qsa($node: HTMLElement | DocumentFragment, selector: string); -export function safe(str: string): string; +export function safe(str: string | null): string; diff --git a/public/assets/pages/filespage/thing.js b/public/assets/pages/filespage/thing.js index 140d6271..eeeafebf 100644 --- a/public/assets/pages/filespage/thing.js +++ b/public/assets/pages/filespage/thing.js @@ -1,7 +1,6 @@ import { createElement } from "../../lib/skeleton/index.js"; import { animate, opacityOut, opacityIn } from "../../lib/animate.js"; import assert from "../../lib/assert.js"; -import { safe } from "../../lib/dom.js"; import { forwardURLParams } from "../../lib/path.js"; import { get as getConfig } from "../../model/config.js"; diff --git a/public/assets/pages/viewerpage/application_editor.js b/public/assets/pages/viewerpage/application_editor.js index a45801a8..f9fda1e0 100644 --- a/public/assets/pages/viewerpage/application_editor.js +++ b/public/assets/pages/viewerpage/application_editor.js @@ -110,7 +110,7 @@ export default async function(render, { acl$, getFilename, getDownloadUrl, mime rxjs.tap((editor) => requestAnimationFrame(() => editor.refresh())), ); }), - rxjs.mergeMap(async (editor) => { + rxjs.mergeMap(async(editor) => { const loader = await loadPlugin(mime); if (loader) new (await loader(IEditor, { mime, $menubar: $dom.menubar(), getFilename, getDownloadUrl }))(editor); return editor; diff --git a/public/assets/pages/viewerpage/application_image.js b/public/assets/pages/viewerpage/application_image.js index 4701c96c..91a9b665 100644 --- a/public/assets/pages/viewerpage/application_image.js +++ b/public/assets/pages/viewerpage/application_image.js @@ -76,7 +76,7 @@ export default function(render, { getFilename, getDownloadUrl, mime, hasMenubar rxjs.tap(() => { const cancel = animate($photo, { onEnter: () => $photo.classList.remove("hidden"), - onExit: async () => (await cancel)(), + onExit: async() => (await cancel)(), time: 300, easing: "cubic-bezier(.51,.92,.24,1.15)", keyframes: [ @@ -84,7 +84,7 @@ export default function(render, { getFilename, getDownloadUrl, mime, hasMenubar { opacity: 1 }, { opacity: 1, transform: "scale(1)" }, ], - }) + }); }), rxjs.catchError((err) => { if (err.target instanceof HTMLElement && err.type === "error") { diff --git a/public/assets/pages/viewerpage/application_image/pagination.js b/public/assets/pages/viewerpage/application_image/pagination.js index 6b57598f..fd6c19bd 100644 --- a/public/assets/pages/viewerpage/application_image/pagination.js +++ b/public/assets/pages/viewerpage/application_image/pagination.js @@ -105,7 +105,7 @@ function initMobileNavigation({ $img, $navigation }) { active: false, originX: null, originT: null, - dist: null, + dist: null, }; effect(rxjs.fromEvent($img, "touchstart", { passive: true }).pipe(rxjs.debounceTime(10), rxjs.tap((event) => { @@ -122,7 +122,7 @@ function initMobileNavigation({ $img, $navigation }) { $img.style.transform = `translateX(${state.dist}px)`; }))); - effect(rxjs.fromEvent($img, "touchend").pipe(rxjs.tap(async (event) => { + effect(rxjs.fromEvent($img, "touchend").pipe(rxjs.tap(async(event) => { if (state.active === false) return; state.active = false; @@ -148,10 +148,13 @@ function initMobileNavigation({ $img, $navigation }) { } $navlink.click(); - await animate($img, { time: 200, keyframes: [ - { transform: `translateX(${state.dist}px)`, opacity: 1 }, - { transform: `translateX(${$img.clientWidth*Math.sign(state.dist)}px)`, opacity: 0 }, - ]}); + await animate($img, { + time: 200, + keyframes: [ + { transform: `translateX(${state.dist}px)`, opacity: 1 }, + { transform: `translateX(${$img.clientWidth*Math.sign(state.dist)}px)`, opacity: 0 }, + ] + }); $img.classList.add("hidden"); }))); } diff --git a/public/assets/pages/viewerpage/application_image/zoom.js b/public/assets/pages/viewerpage/application_image/zoom.js index b2aa78c5..769b6813 100644 --- a/public/assets/pages/viewerpage/application_image/zoom.js +++ b/public/assets/pages/viewerpage/application_image/zoom.js @@ -1,7 +1,7 @@ import rxjs, { effect } from "../../../lib/rx.js"; import { qs } from "../../../lib/dom.js"; -export default function ({ $img, $page }) { +export default function({ $img, $page }) { const $navigation = qs($page, `[data-bind="component_navigation"]`); effect(rxjs.merge(...builder({ $img })).pipe( @@ -12,8 +12,8 @@ export default function ({ $img, $page }) { const next = Math.min(20, Math.max(1, state.scale * (scale ?? 1))); if (next > 1) { const rect = $img.getBoundingClientRect(); - const ox = (clientX ?? rect.left + rect.width / 2) - rect.left; - const oy = (clientY ?? rect.top + rect.height / 2) - rect.top; + const ox = (clientX ?? rect.left + rect.width / 2) - rect.left; + const oy = (clientY ?? rect.top + rect.height / 2) - rect.top; const f = next / state.scale; state.x += (1 - f) * ox; state.y += (1 - f) * oy; @@ -27,7 +27,7 @@ export default function ({ $img, $page }) { }, { scale: 1, x: 0, y: 0, duration: 0 }), rxjs.tap(({ scale, x, y, duration }) => { $img.style.transition = `transform ${duration}ms ease`; - $img.style.transform = `translate(${x}px,${y}px) scale(${scale})`; + $img.style.transform = `translate(${x}px,${y}px) scale(${scale})`; if (scale === 1) $navigation.classList.remove("hidden"); }), )); @@ -47,11 +47,11 @@ function builder({ $img }) { rxjs.fromEvent($img.parentElement, "wheel").pipe( rxjs.tap((e) => e.preventDefault()), rxjs.bufferTime(100), - rxjs.filter(events => events.length > 0), + rxjs.filter((events) => events.length > 0), rxjs.map((events) => { let out = null; for (let i=0; i Math.abs(out.scale)) out = ({ scale, clientX: events[i].clientX, clientY: events[i].clientY }); } @@ -99,12 +99,12 @@ function builder({ $img }) { ), // grab and drag rxjs.fromEvent($img.parentElement, "mousedown").pipe( - rxjs.filter(e => e.target === $img && e.button === 0), + rxjs.filter((e) => e.target === $img && e.button === 0), rxjs.switchMap((down) => { let prev = { x: down.clientX, y: down.clientY, t: down.timeStamp }; const move$ = rxjs.fromEvent(window, "mousemove").pipe( rxjs.takeUntil(rxjs.fromEvent(window, "mouseup")), - rxjs.map(m => { + rxjs.map((m) => { const dx = m.clientX - prev.x; const dy = m.clientY - prev.y; const dt = m.timeStamp - prev.t || 1; @@ -138,5 +138,5 @@ function builder({ $img }) { return rxjs.merge(move$, $inertia); }), ), - ] + ]; } diff --git a/public/assets/pages/viewerpage/application_table.js b/public/assets/pages/viewerpage/application_table.js index 74c72946..37f50959 100644 --- a/public/assets/pages/viewerpage/application_table.js +++ b/public/assets/pages/viewerpage/application_table.js @@ -1,4 +1,4 @@ -import { createElement, nop } from "../../lib/skeleton/index.js"; +import { createElement } from "../../lib/skeleton/index.js"; import rxjs, { effect } from "../../lib/rx.js"; import { qs, qsa, safe } from "../../lib/dom.js"; import ajax from "../../lib/ajax.js"; @@ -19,7 +19,7 @@ class ITable { getBody() { throw new Error("NOT_IMPLEMENTED"); } } -export default async function(render, { mime, getDownloadUrl = nop, getFilename = nop, hasMenubar = true, acl$ = rxjs.EMPTY }) { +export default async function(render, { mime, getDownloadUrl, getFilename, hasMenubar = true, acl$ = rxjs.EMPTY }) { const $page = createElement(`
diff --git a/public/assets/sw.js b/public/assets/sw.js index 3fff4e81..c9af9a93 100644 --- a/public/assets/sw.js +++ b/public/assets/sw.js @@ -37,7 +37,7 @@ self.addEventListener("activate", (event) => { })()); }); -self.addEventListener("fetch", async (event) => { +self.addEventListener("fetch", async(event) => { if (!event.request.url.startsWith(location.origin + "/assets/")) return; event.respondWith((async() => { @@ -78,7 +78,7 @@ async function preload({ urls, cache, cleanup }) { cleanup.push(() => evtsrc.close()); let i = 0; - const messageHandler = async (resolve, event, decoder) => { + const messageHandler = async(resolve, event, decoder) => { const url = event.lastEventId; let mime = "application/octet-stream"; if (url.endsWith(".css")) mime = "text/css"; diff --git a/public/package.json b/public/package.json index 9056bb4e..258fa171 100644 --- a/public/package.json +++ b/public/package.json @@ -133,6 +133,9 @@ ], "accessor-pairs": [ "off" + ], + "no-new": [ + "off" ] } },