This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function use<T>(promiseOrContext: Promise<T> | Context<T>): T { | |
if ('__c' in promiseOrContext) { | |
return useContext(promiseOrContext) | |
} | |
return usePromise(promiseOrContext) | |
} | |
function usePromise<T>(promise: Promise<T>): T { | |
const resolving = useRef(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> | |
<h1>hello</h1> |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> | |
<h1>hello world</h1> | |
<p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"inputs": { | |
"../src/runtime/polyfills.ts": { "bytes": 134, "imports": [] }, | |
"https://esm.sh/stable/[email protected]/denonext/preact.mjs": { | |
"bytes": 10781, | |
"imports": [], | |
"format": "esm" | |
}, | |
"https://esm.sh/[email protected]": { | |
"bytes": 104, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> | |
<label for="foo">Input mask demo</label> | |
<input id="foo" type="text" pattern="\d{6}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const foo = "it doesn't work"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder