more preact tweaks

This commit is contained in:
Seth Trowbridge 2024-05-14 20:34:18 -04:00
parent b2b868d62f
commit ee5881bcaa
12 changed files with 74 additions and 1158 deletions

File diff suppressed because one or more lines are too long

6
bundled/preact/hooks.js Normal file
View File

@ -0,0 +1,6 @@
/* esm.sh - esbuild bundle(preact@10.20.2/hooks) es2022 production */
import{options as B}from"./preact.js";
var c,r,H,b,v=0,x=[],p=[],o=B,g=o.__b,C=o.__r,A=o.diffed,D=o.__c,F=o.unmount,k=o.__;function l(t,_){o.__h&&o.__h(r,t,v||_),v=0;var u=r.__H||(r.__H={__:[],__h:[]});return t>=u.__.length&&u.__.push({__V:p}),u.__[t]}function I(t){return v=1,R(U,t)}function R(t,_,u){var n=l(c++,2);if(n.t=t,!n.__c&&(n.__=[u?u(_):U(void 0,_),function(a){var f=n.__N?n.__N[0]:n.__[0],s=n.t(f,a);f!==s&&(n.__N=[s,n.__[1]],n.__c.setState({}))}],n.__c=r,!r.u)){var i=function(a,f,s){if(!n.__c.__H)return!0;var m=n.__c.__H.__.filter(function(e){return!!e.__c});if(m.every(function(e){return!e.__N}))return!h||h.call(this,a,f,s);var V=!1;return m.forEach(function(e){if(e.__N){var P=e.__[0];e.__=e.__N,e.__N=void 0,P!==e.__[0]&&(V=!0)}}),!(!V&&n.__c.props===a)&&(!h||h.call(this,a,f,s))};r.u=!0;var h=r.shouldComponentUpdate,N=r.componentWillUpdate;r.componentWillUpdate=function(a,f,s){if(this.__e){var m=h;h=void 0,i(a,f,s),h=m}N&&N.call(this,a,f,s)},r.shouldComponentUpdate=i}return n.__N||n.__}function z(t,_){var u=l(c++,3);!o.__s&&y(u.__H,_)&&(u.__=t,u.i=_,r.__H.__h.push(u))}function S(t,_){var u=l(c++,4);!o.__s&&y(u.__H,_)&&(u.__=t,u.i=_,r.__h.push(u))}function L(t){return v=5,T(function(){return{current:t}},[])}function M(t,_,u){v=6,S(function(){return typeof t=="function"?(t(_()),function(){return t(null)}):t?(t.current=_(),function(){return t.current=null}):void 0},u==null?u:u.concat(t))}function T(t,_){var u=l(c++,7);return y(u.__H,_)?(u.__V=t(),u.i=_,u.__h=t,u.__V):u.__}function G(t,_){return v=8,T(function(){return t},_)}function J(t){var _=r.context[t.__c],u=l(c++,9);return u.c=t,_?(u.__==null&&(u.__=!0,_.sub(r)),_.props.value):t.__}function K(t,_){o.useDebugValue&&o.useDebugValue(_?_(t):t)}function O(t){var _=l(c++,10),u=I();return _.__=t,r.componentDidCatch||(r.componentDidCatch=function(n,i){_.__&&_.__(n,i),u[1](n)}),[u[0],function(){u[1](void 0)}]}function Q(){var t=l(c++,11);if(!t.__){for(var _=r.__v;_!==null&&!_.__m&&_.__!==null;)_=_.__;var u=_.__m||(_.__m=[0,0]);t.__="P"+u[0]+"-"+u[1]++}return t.__}function W(){for(var t;t=x.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(d),t.__H.__h.forEach(E),t.__H.__h=[]}catch(_){t.__H.__h=[],o.__e(_,t.__v)}}o.__b=function(t){r=null,g&&g(t)},o.__=function(t,_){t&&_.__k&&_.__k.__m&&(t.__m=_.__k.__m),k&&k(t,_)},o.__r=function(t){C&&C(t),c=0;var _=(r=t.__c).__H;_&&(H===r?(_.__h=[],r.__h=[],_.__.forEach(function(u){u.__N&&(u.__=u.__N),u.__V=p,u.__N=u.i=void 0})):(_.__h.forEach(d),_.__h.forEach(E),_.__h=[],c=0)),H=r},o.diffed=function(t){A&&A(t);var _=t.__c;_&&_.__H&&(_.__H.__h.length&&(x.push(_)!==1&&b===o.requestAnimationFrame||((b=o.requestAnimationFrame)||j)(W)),_.__H.__.forEach(function(u){u.i&&(u.__H=u.i),u.__V!==p&&(u.__=u.__V),u.i=void 0,u.__V=p})),H=r=null},o.__c=function(t,_){_.some(function(u){try{u.__h.forEach(d),u.__h=u.__h.filter(function(n){return!n.__||E(n)})}catch(n){_.some(function(i){i.__h&&(i.__h=[])}),_=[],o.__e(n,u.__v)}}),D&&D(t,_)},o.unmount=function(t){F&&F(t);var _,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{d(n)}catch(i){_=i}}),u.__H=void 0,_&&o.__e(_,u.__v))};var q=typeof requestAnimationFrame=="function";function j(t){var _,u=function(){clearTimeout(n),q&&cancelAnimationFrame(_),setTimeout(t)},n=setTimeout(u,100);q&&(_=requestAnimationFrame(u))}function d(t){var _=r,u=t.__c;typeof u=="function"&&(t.__c=void 0,u()),r=_}function E(t){var _=r;t.__c=t.__(),r=_}function y(t,_){return!t||t.length!==_.length||_.some(function(u,n){return u!==t[n]})}function U(t,_){return typeof _=="function"?_(t):_}
export{G as useCallback,J as useContext,K as useDebugValue,z as useEffect,O as useErrorBoundary,Q as useId,M as useImperativeHandle,S as useLayoutEffect,T as useMemo,R as useReducer,L as useRef,I as useState};
//# sourceMappingURL=hooks.js.map

View File

@ -1,7 +0,0 @@
/* esm.sh - esbuild bundle(preact@10.20.2/jsx-runtime) es2022 production */
import{options as c,Fragment as _}from"./compat.js";
import{Fragment as C}from"./compat.js";
var v=/["&<]/;function p(t){if(t.length===0||v.test(t)===!1)return t;for(var r=0,e=0,a="",o="";e<t.length;e++){switch(t.charCodeAt(e)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;default:continue}e!==r&&(a+=t.slice(r,e)),a+=o,r=e+1}return e!==r&&(a+=t.slice(r,e)),a}var y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,d=0,x=Array.isArray;function g(t,r,e,a,o,i){var s,n,f={};for(n in r)n=="ref"?s=r[n]:f[n]=r[n];var u={type:t,props:f,key:e,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--d,__i:-1,__u:0,__source:o,__self:i};if(typeof t=="function"&&(s=t.defaultProps))for(n in s)f[n]===void 0&&(f[n]=s[n]);return c.vnode&&c.vnode(u),u}function h(t){var r=g(_,{tpl:t,exprs:[].slice.call(arguments,1)});return r.key=r.__v,r}var l={},m=/[A-Z]/g;function k(t,r){if(c.attr){var e=c.attr(t,r);if(typeof e=="string")return e}if(t==="ref"||t==="key")return"";if(t==="style"&&typeof r=="object"){var a="";for(var o in r){var i=r[o];if(i!=null&&i!==""){var s=o[0]=="-"?o:l[o]||(l[o]=o.replace(m,"-$&").toLowerCase()),n=";";typeof i!="number"||s.startsWith("--")||y.test(s)||(n="px;"),a=a+s+":"+i+n}}return t+'="'+a+'"'}return r==null||r===!1||typeof r=="function"||typeof r=="object"?"":r===!0?t:t+'="'+p(r)+'"'}function b(t){if(t==null||typeof t=="boolean"||typeof t=="function")return null;if(typeof t=="object"){if(t.constructor===void 0)return t;if(x(t)){for(var r=0;r<t.length;r++)t[r]=b(t[r]);return t}}return p(""+t)}
export{C as Fragment,g as jsx,k as jsxAttr,g as jsxDEV,b as jsxEscape,h as jsxTemplate,g as jsxs};

3
bundled/preact/preact.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,5 @@
import * as TW from "./twind/core.js"; import * as TW from "./twind/core.js";
import {presetAutoprefix, presetTailwind} from "./twind/presets.js" import {presetAutoprefix, presetTailwind} from "./twind/presets.js"
import * as BUNDLE from "./preact/compat.js";
const Configure = const Configure =
{ {
theme: {}, theme: {},
@ -11,4 +7,10 @@ const Configure =
hash: false hash: false
} as TW.TwindUserConfig; } as TW.TwindUserConfig;
console.log(TW.install(Configure)); //console.log(TW.install(Configure));
import * as LOL from "react";
console.log(LOL.jsx)

1114
bundled/twind/core.d.ts vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,28 +1,26 @@
{ {
"imports": { "imports": {
"react": "https://esm.sh/preact@10.20.2/compat",
"react/jsx-runtime": "https://esm.sh/stable/preact@10.20.2/es2022/jsx-runtime.js",
"react-original": "https://esm.sh/preact@10.20.2/compat",
"@preact/signals": "https://esm.sh/@preact/signals@1.2.3?deps=preact@10.20.2",
"signals-original": "https://esm.sh/@preact/signals@1.2.3?deps=preact@10.20.2",
"@twind/": "./bundled/twind/",
"react": "https://esm.sh/preact@10.20.2/compat", ">able/": "./",
"react-original": "https://esm.sh/preact@10.20.2/compat", ">able/app.tsx": "./app.tsx"
"react-original/": "https://esm.sh/preact@10.20.2/compat/", },
"react/": "https://esm.sh/preact@10.20.2/compat/", "tasks": {
"@preact/signals": "https://esm.sh/@preact/signals@1.2.3?deps=preact@10.20.2", "check": "deno run -A --no-lock ./cli.tsx check",
"signals-original": "https://esm.sh/@preact/signals@1.2.3?deps=preact@10.20.2", "local": "deno run -A --no-lock ./cli.tsx local",
"@twind/": "http://localhost:4507/bundled/twind/", "debug": "deno run -A --no-lock ./cli.tsx debug",
"serve": "deno run -A --no-lock ./cli.tsx serve",
">able/": "./", "cloud": "deno run -A --no-lock ./cli.tsx cloud",
">able/app.tsx": "./app.tsx" "install": "deno install -A -r -f -n able ./cli.tsx"
}, },
"tasks": { "compilerOptions": {
"check": "deno run -A --no-lock ./cli.tsx check", "jsx": "react-jsx",
"local": "deno run -A --no-lock ./cli.tsx local", "jsxImportSource": "react",
"debug": "deno run -A --no-lock ./cli.tsx debug", "lib": ["deno.window", "dom", "dom.iterable", "dom.asynciterable"]
"serve": "deno run -A --no-lock ./cli.tsx serve", }
"cloud": "deno run -A --no-lock ./cli.tsx cloud", }
"install": "deno install -A -r -f -n able ./cli.tsx"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "react",
"lib": ["deno.window", "dom", "dom.iterable", "dom.asynciterable"]
}
}

View File

@ -31,7 +31,7 @@ export const HMR =
RegisteredComponents: new Map() as Map<string, ()=>void>, RegisteredComponents: new Map() as Map<string, ()=>void>,
statesNew: new Map() as Map<string, StateCapture>, statesNew: new Map() as Map<string, StateCapture>,
statesOld: new Map() as Map<string, StateCapture>, statesOld: new Map() as Map<string, StateCapture>,
wireframe: true, wireframe: false,
RegisterComponent(reactID:string, value:()=>void):void RegisterComponent(reactID:string, value:()=>void):void
{ {
this.RegisteredComponents.set(reactID, value); this.RegisteredComponents.set(reactID, value);

View File

@ -1,6 +1,6 @@
import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts"; import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts";
import * as SWCW from "https://esm.sh/@swc/wasm-web@1.3.62"; import * as SWCW from "https://esm.sh/@swc/wasm-web@1.3.62";
import SSR from "https://esm.sh/preact-render-to-string@6.4.2?external=react&alias=preact:react"; import SSR from "http://localhost:4507/bundled/preact/to-string.js";
import { HuntConfig, Root } from "./checker.tsx"; import { HuntConfig, Root } from "./checker.tsx";
import CustomServe from ">able/api.tsx"; import CustomServe from ">able/api.tsx";
@ -196,7 +196,6 @@ export default async()=>
const User = await import("./run-browser.tsx"); const User = await import("./run-browser.tsx");
markup = SSR(<User.CustomApp/>); markup = SSR(<User.CustomApp/>);
const {css, html} = User.CustomTwindExtractor(markup); const {css, html} = User.CustomTwindExtractor(markup);
console.log(css);
markup = html; markup = html;
styles = css; styles = css;
} }