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(() => { |
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
test("cell lift work", done => { | |
let lines = [ | |
"Work it harder", | |
"Make it better", | |
"Do it faster", | |
"Makes us stronger" | |
]; | |
let idx = 0; | |
let c1 = new CellSink(0); | |
let c2 = new CellSink(0); |
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 * as sodium from 'sodiumjs'; | |
import * as THREE from 'three'; | |
import { EcsComponentType } from './EcsComponentType'; | |
import { EcsReadOnlySceneContext } from './EcsReadOnlySceneContext'; | |
import { EcsSceneChanges } from './EcsSceneChanges'; | |
import { IsEcsComponentValue } from './IsEcsComponentValue'; | |
import { ArcComponent } from './components/ArcComponent'; | |
import { Axes2DComponent } from './components/Axes2DComponent'; | |
import { CircleComponent } from './components/CircleComponent'; | |
import { Line3DComponent } from './components/Line3DComponent'; |
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 cellTrace<A>(ca: sodium.Cell<A>, extractor: (a: A) => (sodium.Stream<any>|sodium.Cell<any>)[]): sodium.Cell<A> { | |
let cKeepAlive = sodium.Cell.switchC(ca.map( | |
a => | |
cellLiftArray( | |
extractor(a).map( | |
x => { | |
if (x instanceof sodium.Stream) { | |
return x.hold({} as any); | |
} else { |