View hotreload.js
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 (){ | |
const moduleDef = { | |
"./a.tsx": { | |
code: function (module, exports, require){ | |
module.exports = 1 | |
}, | |
parent: ["./b.tsx"] | |
}, | |
"./b.tsx": { |
View base.ts
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
class BaseModel { | |
private deepCloneImpl(oldObject: object, intrinsicTypes: string[], clonedMap: WeakMap<object, unknown>){ | |
if (!oldObject || typeof oldObject !== "object") return oldObject; | |
if(clonedMap.has(oldObject)){ | |
return clonedMap.get(oldObject) | |
} |
View rxjs-materialize-response.tsx
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 { Observable, SubscribableOrPromise, OperatorFunction } from "rxjs" | |
import { switchMap, tap } from "rxjs/operators" | |
export type MaterializedResponseState<T> = { loading: true, error: null, value: null | T } | { loading: false, error: Error } | { loading:false, value: T } | |
export function materializeResponse<T1, T2>(performRequest: (t1: T1) => SubscribableOrPromise<T2>): OperatorFunction<T1, MaterializedResponseState<T2>> { | |
return (observer: Observable<T1>) => { | |
let lastResponse = null as null | T2 | |
return new Observable<MaterializedResponseState<T2>>(subscriber => { | |
return observer |
View suspendable-use-observables.ts
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
type ObservedValueOfWithoutDefaultValue<T> = T extends Observable<infer U2> ? U2 : T extends Promise<infer U1> ? U1 : never | |
export type ObservedValueTupleFromArrayWithoutDefaultValue<X> = X extends readonly (Observable<unknown> | Promise<unknown> | null | undefined)[] | |
? { [K in keyof X]: ObservedValueOfWithoutDefaultValue<X[K]> } | |
: never | |
const mapValue = new WeakMap< | |
object, | |
{ |
View bubu-form-antd.tsx
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 { Form, Col, Row, Button } from "antd" | |
import { FormItemProps } from "antd/lib/form" | |
import { useObservables } from "./use-observables" | |
import * as React from "react" | |
import { AbstractControl, ValidationInfo, FormControls, FormControlList } from "./model" | |
import { CloseOutlined, PlusOutlined, MinusOutlined } from "@ant-design/icons" | |
type FormItemRenderChildren<T, Meta> = (inputProps: { value?: T; onChange?: (v: T) => void }, behavior: Meta | null, err: ValidationInfo) => React.ReactNode | |
export function FormItem<T, Meta>({ |
View parser.ts
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
const EOF = Symbol("EOF") | |
type TokenStream = { | |
token: Token | |
start: number | |
end: number | |
}[] | |
type Token = { | |
kind: "token" |
View obuservable.ts
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
type Unsubscribe = () => void | |
const NOOP: Unsubscribe = () => {} | |
interface Observer<T> { | |
(t: T): void | |
} | |
interface Observable<T> { | |
(ob: Observer<T>): Unsubscribe |
View babylonjs-builder-pattern.ts
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 { Animation, CubicEase, EasingFunction, Mesh, MeshBuilder, MultiMaterial, Scene, Vector3, ActionManager, InterpolateValueAction } from "@babylonjs/core" | |
import { RACK_HEIGHT, RACK_WIDTH, UNIT_HEIGHT } from "config/canvas-constants" | |
import { genMultiMaterialMesh } from "utils/canvas-utils" | |
export class DoorBuilder { | |
constructor(private scene: Scene, material: MultiMaterial) { | |
const doorCube = MeshBuilder.CreateBox("door", { width: RACK_WIDTH, height: RACK_HEIGHT, depth: UNIT_HEIGHT }) | |
genMultiMaterialMesh(doorCube, material) |
View typescript-di.tsx
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
//Idea is borrowed from https://github.com/gnaeus/react-ioc | |
//Differences are: | |
//1. Does not require reflect-metadata | |
//2. Has an additional "useProvider" method | |
import * as React from "react" | |
export interface Disposable { | |
dispose?(): void | |
} |
View use-observables.ts
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 { BehaviorSubject, Observable, Subscription, SubscribableOrPromise, from } from "rxjs" | |
import { skip } from "rxjs/operators" | |
import * as React from "react" | |
import { useSubscription } from "use-subscription" | |
type ObservedValueOf<T> = T extends BehaviorSubject<infer U1> ? U1 : T extends Observable<infer U2> ? U2 | null : never | |
export function useObservables<T>(ob: T | undefined | null): [ObservedValueOf<T>] | |
export function useObservables<T1, T2>(ob1: T1 | undefined | null, ob2: T2 | undefined | null): [ObservedValueOf<T1>, ObservedValueOf<T2>] | |
export function useObservables<T1, T2, T3>( |
NewerOlder