From 8279a81dc9ea09464294b479867fe8085adfd79d Mon Sep 17 00:00:00 2001 From: metacryst Date: Sat, 28 Mar 2026 02:24:04 -0500 Subject: [PATCH] updating quill --- src/public/_/code/quill.js | 86 ++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 12 deletions(-) diff --git a/src/public/_/code/quill.js b/src/public/_/code/quill.js index c1688c3..7cca3c6 100644 --- a/src/public/_/code/quill.js +++ b/src/public/_/code/quill.js @@ -1,10 +1,13 @@ /* Sam Russell Captured Sun - 2.24.26 - Allowing state() to watch other elements - 2.21.26 - Making state() be called on initial definition, fixing fontSize so it works with clamp(), other strings - 2.20.26 - Adding state() - 2.19.26 - Adding dynamicText() + 3.27.26 - Adding quill router, removing dynamicText(), removing horizontal and verticalAlign() checks + 3.24.26 - Allowing state() to watch other elements + 3.21.26 - Making state() be called on initial definition, fixing fontSize so it works with clamp(), other strings + 3.20.26 - Adding state() + 3.19.26 - Adding dynamicText() + 3.4.26 - Making horizontalAlign() and verticalAlign() methods of checking for stacks more robust + 2.27.26 - Adding parentShadow() function 2.16.26 - Adding event objects to the onTouch callbacks 1.16.26 - Moving nav event dispatch out of pushState, adding null feature to attr() 1.5.26 - Switching verticalAlign and horizontalAlign names, adding borderVertical and Horizontal @@ -182,6 +185,62 @@ Object.defineProperty(Array.prototype, 'last', { window.quill = { rendering: [], lastState: null, + router: null, + + router: class { + routes = [] + + route(route, cb) { + this.routes.push({route: route, cb: cb}) + } + + async findMatch() { + let matched; + for (const route of this.routes) { + const [match, params] = this.matchPath(route.route, window.location.pathname) + if (match) { + await route.cb(params) + return; + } + } + if(!matched) throw new Error("Quill: couldn't match route!") + return null + } + + matchPath(pattern, pathname) { + const patternParts = pattern.split('/').filter(Boolean) + const pathParts = pathname.split('/').filter(Boolean) + + if (patternParts.length !== pathParts.length) return [false] + + const params = [] + + for (let i = 0; i < patternParts.length; i++) { + if (patternParts[i].startsWith(':')) { + params.push(pathParts[i]) + } else if (patternParts[i] !== pathParts[i]) { + return [false] + } + } + + return [true, params] + } + }, + + init: async (home, router) => { + if(router) { + quill.router = router + window.addEventListener("navigate", () => { + if(quill.router) { + router.findMatch() + } + }) + if(quill.router) { + await router.findMatch() + } + } + home() + }, render: (el) => { if(el instanceof Shadow) { @@ -315,6 +374,17 @@ HTMLElement.prototype.rerender = function() { quill.rerender(this) } +HTMLElement.prototype.parentShadow = function(selector) { + let el = this + while(el !== document.body) { + el = el.parentElement + if(el instanceof Shadow) { + return el + } + } + return null +} + /* Styling */ window.pct = "%" @@ -672,10 +742,6 @@ HTMLElement.prototype.centerY = function () { HTMLElement.prototype.verticalAlign = function (value) { const direction = getComputedStyle(this).flexDirection; - if(!direction) { - throw new Error("verticalAlign can be only be used on HStacks or VStacks!") - } - if (direction === "column" || direction === "column-reverse") { this.style.justifyContent = value; } else { @@ -686,10 +752,6 @@ HTMLElement.prototype.verticalAlign = function (value) { HTMLElement.prototype.horizontalAlign = function (value) { const direction = getComputedStyle(this).flexDirection; - if(!direction) { - throw new Error("horizontalAlign can be only be used on HStacks or VStacks!") - } - if (direction === "column" || direction === "column-reverse") { this.style.alignItems = value; } else {