just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
#!/usr/bin/env bash | |
BLUE='\033[1;34m' | |
BRIGHT_RED='\033[1;31m' | |
DARK_GRAY='\033[0;37m' | |
RESET='\033[m' | |
INFO="${BLUE}[INFO]${RESET}" | |
function task() { | |
if [ "$3" != "" ] && [ $1 ]; then |
just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
/* eslint-disable no-unused-vars */ | |
/* eslint-disable no-else-return */ | |
// JSX constructor, similar to createElement() | |
export const h = (type, props, ...children) => { | |
return { | |
type, | |
// Props will be an object for components and DOM nodes, but a string for | |
// text nodes | |
props, |
import { options } from "preact"; | |
function getComponentName(vnode) { | |
return vnode.type.displayName || vnode.name || "Component"; | |
} | |
let prevBeforeDiff = (options._diff = options.__b); | |
options._diff = options.__b = (vnode) => { | |
if (typeof vnode.type === "function") { | |
const name = getComponentName(vnode); |
var N = 1 << 0, | |
S = 1 << 1, | |
A = 1 << 2, | |
le = 1 << 3, | |
T = 1 << 4, | |
Y = N | S, | |
P = A | le | T, | |
h = 1 << 5, | |
d = 1 << 6, | |
D = 1 << 7, |
import { signal, computed, effect } from "../esm/index.js"; | |
const a = signal(1); | |
const b = computed(() => a.value); | |
const c = computed(() => a.value); | |
const d = computed(() => b.value + c.value); | |
effect(() => console.log(d.value)); | |
a.value = 2; // Should log 4, but logs 2 |
import { options, VNode } from 'preact'; | |
import { renderToString } from 'preact-render-to-string'; | |
// List of web components that were rendered | |
let webComponents = new Set<string>(); | |
// Called when a vnode is rendered | |
let oldDiffedHook = options.diffed; | |
options.diffed = (vnode: VNode) => { | |
if (typeof vnode.type === 'string' && vnode.type.includes('-')) { | |
webComponents.add(vnode.type); |
export const foo = "it doesn't work"; |
import { options } from "preact"; | |
import { Signal } from "@preact/signals"; | |
// Add `bind:value` to JSX types | |
declare global { | |
namespace preact.createElement.JSX { | |
interface HTMLAttributes { | |
"bind:value"?: Signal<string | string[] | number | undefined>; | |
} | |
} |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script type="module"> |