This file contains hidden or 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 { Vec2 } from "../math/Vec2"; | |
import { Result, err, ok } from "./Result"; | |
export type PropertiesSchema<A> = PropertiesSchemaInvMap<unknown,A> | PropertiesSchema2<A>; | |
type PropertiesSchemaInvMap<A,B> = { | |
type: "InvMap", | |
propertiesSchema: PropertiesSchema<A>, | |
fn1: (a: A) => B, | |
fn2: (b: B) => A, |
This file contains hidden or 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
use std::cell::{Cell, RefCell}; | |
use std::rc::{Rc, Weak}; | |
use std::ops::{Deref, DerefMut}; | |
pub struct FgrCtx { | |
observer: Rc<Node>, | |
dirty_nodes: Vec<Rc<Node>>, | |
transaction_depth: usize, | |
} |
This file contains hidden or 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
#[derive(Debug, PartialEq, Eq)] | |
pub enum ChunkNextResult { | |
Empty, | |
Char(char), | |
Eof, | |
} | |
pub struct Chunk<'a> { | |
next: Box<dyn FnMut()->ChunkNextResult+'a>, | |
unnext_stack: Vec<char>, |
This file contains hidden or 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 class Plugin { | |
private src: String; | |
private callbacks: any; | |
private iframe?: HTMLIFrameElement; | |
private messageHandler: (e: MessageEvent) => void; | |
private recvMsgHandler: (msg: string) => void; | |
private nextCallId: number = 0; | |
private resolveMap: any; | |
onLoad: () => void = () => {}; |
This file contains hidden or 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
use std::cell::RefCell; | |
use std::collections::HashSet; | |
use std::hash::{Hash, Hasher}; | |
use std::rc::Rc; | |
thread_local! { | |
static STRING_FACTORY: RefCell<StringFactory> = RefCell::new(StringFactory::new()); | |
} | |
struct MyRc<A>(Rc<A>); |
This file contains hidden or 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 { batch, Component, createEffect, createMemo, onCleanup, onMount } from 'solid-js'; | |
import { createStore } from 'solid-js/store'; | |
const Window: Component<{ | |
title?: string, | |
width?: number, | |
height?: number, | |
initX?: number, | |
initY?: number, | |
}> = (props) => { |
This file contains hidden or 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 function cellArrayKeyed2<K,A,B>(keyEq: (a:K,b:K)=>boolean, keyExtractor: (a:A)=>K, transform: (a:A) => B, cas: sodium.Cell<A[]>): sodium.Cell<B[]> { | |
return sodium.Operational | |
.updates(cas) | |
.accumLazy( | |
cas.sampleLazy().map(as => as.map(a => T2.of(keyExtractor(a), transform(a)))), | |
(nextAs: A[], lastResult: T2<K,B>[]) => { | |
let nextResult: T2<K,B>[] = []; | |
for (let i = 0; i < nextAs.length; ++i) { | |
let a = nextAs[i]; | |
let key = keyExtractor(a); |
This file contains hidden or 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 class Cell<A> { | |
. | |
. | |
. | |
static switchC<A>(cca : Cell<Cell<A>>) : Cell<A> { | |
return Transaction.run(() => { | |
const za = cca.sampleLazy().map((ba : Cell<A>) => ba.sample()), | |
out = new StreamWithSend<A>(); | |
let outValue: A = null; |
This file contains hidden or 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
class MergeState<A> { | |
constructor() {} | |
left : A = null; | |
left_present : boolean = false; | |
right : A = null; | |
right_present : boolean = false; | |
} | |
export class Stream<A> { | |
. |
This file contains hidden or 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 class Cell<A> { | |
. | |
. | |
. | |
/** | |
* Apply a value inside a cell to a function inside a cell. This is the | |
* primitive for all function lifting. | |
*/ | |
static apply<A,B>(cf : Cell<(a : A) => B>, ca : Cell<A>, sources? : Source[]) : Cell<B> { | |
return Transaction.run(() => { |