@expressive/mvc 1.0.0-beta.20 → 1.0.0-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/issues.ts","../src/util.ts","../src/subscriber.ts","../src/compute.ts","../src/lifecycle.ts","../src/controller.ts","../src/attach.ts","../src/hooks.ts","../src/peer.ts","../src/register.ts","../src/context.ts","../src/model.ts","../src/compose.ts","../src/instructions.ts","../src/suspense.ts","../src/singleton.ts"],"sourcesContent":["type MessageVar = {} | string | number | boolean | null;\ntype ExpectVars<T> = T extends (...args: infer T) => any ? T : never;\n\ntype Messages = {\n [named: string]: (...args: MessageVar[]) => string;\n}\n\ntype Issues<M extends Messages> = {\n readonly [P in keyof M]: (...args: ExpectVars<M[P]>) => Issue;\n}\n\nclass Issue extends Error {\n // drop first line (error factory) in stack trace.\n stack = this.stack.replace(/\\n.+/, \"\") as string;\n\n warn(){\n console.warn(this.message);\n }\n\n throw(): never {\n throw this;\n }\n}\n\nexport function issues<M extends Messages>(register: M){\n const Library = {} as any;\n \n for(const name in register)\n Library[name] = (...args: MessageVar[]) => \n new Issue(register[name].apply(null, args));\n\n return Library as Issues<M>;\n}","import { issues } from './issues';\n\nexport const Oops = issues({\n BadEffectCallback: () =>\n `Callback for effect-callback may only return a function.`\n})\n\nconst {\n assign,\n create,\n defineProperty,\n entries,\n getPrototypeOf,\n getOwnPropertyNames,\n getOwnPropertyDescriptor,\n getOwnPropertyDescriptors,\n getOwnPropertySymbols,\n keys,\n values\n} = Object;\n\nexport {\n assign,\n create,\n defineProperty,\n entries,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n getOwnPropertyDescriptors,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n keys,\n values\n}\n\nexport function define(\n target: {}, key: string | symbol, value: any){\n\n defineProperty(target, key, { value })\n}\n\nexport function defineLazy<T>(\n object: T, \n property: string | symbol, \n init: (this: T) => any){\n\n defineProperty(object, property, { \n configurable: true,\n get(){\n const value = init!.call(this);\n defineProperty(this, property, { value });\n return value;\n }\n });\n}\n\nexport function setAlias<T extends Function>(\n func: T, displayName: string){\n\n assign(func, { displayName });\n}\n\nexport function createEffect(\n callback: EffectCallback<any>){\n\n let unSet: Callback | Promise<any> | void;\n\n return function(this: any, value: any){\n if(typeof unSet == \"function\")\n unSet();\n\n unSet = callback.call(this, value);\n\n if(unSet instanceof Promise)\n unSet = undefined;\n\n if(unSet && typeof unSet !== \"function\")\n throw Oops.BadEffectCallback()\n }\n}\n\nexport function createValueEffect<T = any>(\n callback: InterceptCallback<T>){\n\n let unSet: ((next: T) => void) | undefined;\n\n return function(this: any, value: any){\n if(typeof unSet == \"function\")\n unSet(value);\n \n const out = callback.call(this, value);\n \n if(typeof out == \"boolean\")\n return out;\n \n if(!out || out instanceof Promise)\n return;\n\n if(typeof out == \"function\")\n unSet = out;\n else\n throw Oops.BadEffectCallback()\n }\n}\n\nexport function select<T extends {}>(\n source: T, select: (from: { [K in keyof T]: K }) => any){\n\n const proxy = {} as any;\n\n for(const k in source)\n proxy[k] = k;\n\n return select(proxy) as string;\n}\n\nexport function selectRecursive(\n using: Function,\n keys: Iterable<string>){\n\n const found = new Set<string>();\n const spy = {} as Recursive<any>;\n\n for(const key of new Set(keys))\n defineProperty(spy, key, {\n get(){\n found.add(key);\n return spy;\n }\n });\n\n using(spy);\n\n return Array.from(found);\n}","import { Controller, LOCAL, manage, Stateful } from './controller';\nimport { create, define, defineProperty, getOwnPropertyDescriptor, setAlias } from './util';\n\ntype Listener = {\n commit(): void;\n release(): void;\n}\n\nexport class Subscriber {\n public proxy: any;\n public source: any;\n public active = false;\n public follows = {} as BunchOf<Callback>;\n public dependant = new Set<Listener>();\n public parent: Controller;\n\n constructor(\n parent: Controller | Stateful,\n public onUpdate: Callback){\n\n if(!(parent instanceof Controller))\n parent = manage(parent);\n\n this.parent = parent;\n this.source = parent.subject;\n this.proxy = create(parent.subject);\n\n define(this.proxy, LOCAL, this);\n\n for(const key in parent.state)\n this.spy(key);\n }\n\n public spy(key: string){\n const { proxy, source } = this;\n\n const { set } =\n getOwnPropertyDescriptor(source, key)!;\n\n const intercept = () => {\n this.follow(key);\n delete proxy[key];\n return proxy[key];\n }\n\n setAlias(intercept, `tap ${key}`);\n defineProperty(proxy, key, {\n get: intercept,\n set,\n configurable: true,\n enumerable: true\n })\n }\n\n public follow(key: string, cb?: Callback){\n this.follows[key] = cb || this.onUpdate;\n }\n\n public commit(){\n const { dependant, follows, parent } = this;\n\n const onDone = parent.addListener(follows);\n this.active = true;\n\n dependant.forEach(x => x.commit());\n\n return this.release = () => {\n dependant.forEach(x => x.release());\n onDone();\n }\n }\n\n public release!: Callback;\n}","import { Controller } from './controller';\nimport { issues } from './issues';\nimport { Subscriber } from './subscriber';\nimport { defineProperty, getOwnPropertyDescriptor, setAlias } from './util';\n\nexport const Oops = issues({\n ComputeFailed: (parent, property, initial) =>\n `An exception was thrown while ${initial ? \"initializing\" : \"refreshing\"} [${parent}.${property}].`,\n\n ComputedEarly: (property) => \n `Note: Computed values don't run until accessed, except when subscribed to. '${property}' getter may have run earlier than intended.`\n})\n\ntype GetterInfo = {\n key: string;\n parent: Controller;\n priority: number;\n}\n\nconst ComputedInit = new WeakSet<Function>();\nconst ComputedInfo = new WeakMap<Function, GetterInfo>();\nconst ComputedUsed = new WeakMap<Controller, Map<string, GetterInfo>>();\nconst ComputedKeys = new WeakMap<Controller, Callback[]>();\n\nexport function prepare(\n parent: Controller,\n key: string,\n source: () => Controller,\n setter: (on?: any) => any,\n getter?: (value: any, key: string) => any){\n\n let sub: Subscriber;\n\n const { state, subject } = parent;\n const info: GetterInfo = { key, parent, priority: 1 };\n\n const current = getter\n ? () => getter.call(subject, state[key], key)\n : () => state[key];\n\n const prioritize = register(parent, key, info);\n\n function compute(initial?: boolean){\n try {\n return setter.call(sub.proxy, sub.proxy);\n }\n catch(err){\n Oops.ComputeFailed(subject, key, !!initial).warn();\n throw err;\n }\n }\n\n function update(){\n let value;\n\n try {\n value = compute(false);\n }\n catch(e){\n console.error(e);\n }\n finally {\n if(state[key] !== value){\n parent.update(key, value);\n return value;\n }\n }\n }\n\n function create(early?: boolean){\n sub = new Subscriber(source(), update);\n\n defineProperty(state, key, {\n value: undefined,\n writable: true\n })\n\n defineProperty(subject, key, {\n enumerable: true,\n configurable: true,\n get: current\n });\n\n try {\n state[key] = compute(true);\n }\n catch(e){\n if(early)\n Oops.ComputedEarly(key).warn();\n\n throw e;\n }\n finally {\n sub.commit();\n\n for(const key in sub.follows)\n prioritize(key);\n }\n\n return current();\n }\n\n setAlias(update, `try ${key}`);\n setAlias(create, `new ${key}`);\n setAlias(setter, `run ${key}`);\n\n ComputedInit.add(create);\n ComputedInfo.set(update, info);\n\n for(const on of [state, subject])\n defineProperty(on, key, {\n get: create,\n configurable: true,\n enumerable: true\n })\n}\n\nfunction register(\n on: Controller,\n key: string,\n info: GetterInfo){\n\n let register = ComputedUsed.get(on)!;\n\n if(!register)\n ComputedUsed.set(on, \n register = new Map<string, GetterInfo>()\n );\n\n register.set(key, info);\n\n return (key: string) => {\n const peer = register.get(key);\n\n if(peer && peer.priority >= info.priority)\n info.priority = peer.priority + 1;\n }\n}\n\nexport function ensure(on: Controller, keys: string[]){\n type Initial = (early?: boolean) => void;\n\n for(const key of keys){\n const desc = getOwnPropertyDescriptor(on.subject, key);\n const getter = desc && desc.get;\n \n if(ComputedInit.has(getter!))\n (getter as Initial)(true);\n }\n}\n\nexport function capture(on: Controller, request: RequestCallback){\n const compute = ComputedInfo.get(request);\n const callback = request as Callback;\n\n if(!compute)\n return;\n\n let pending = ComputedKeys.get(on);\n\n if(!pending)\n ComputedKeys.set(on, pending = []);\n\n if(compute.parent !== on)\n callback();\n else {\n const queue = pending.findIndex(peer =>\n compute.priority > ComputedInfo.get(peer)!.priority\n );\n\n pending.splice(queue + 1, 0, callback);\n }\n\n return true;\n}\n\nexport function flush(on: Controller){\n const handled = on.frame!;\n let pending = ComputedKeys.get(on);\n\n if(pending){\n while(pending.length){\n const compute = pending.shift()!;\n const { key } = ComputedInfo.get(compute)!;\n\n if(!handled.has(key))\n compute();\n }\n \n ComputedKeys.delete(on);\n }\n}","import { useLayoutEffect, useMemo } from 'react';\n\nimport { Model } from './model';\nimport { Subscriber } from './subscriber';\nimport { values } from './util';\n\nexport const Lifecycle = {\n WILL_RENDER: \"willRender\",\n WILL_UPDATE: \"willUpdate\",\n WILL_MOUNT: \"willMount\",\n WILL_UNMOUNT: \"willUnmount\",\n DID_MOUNT: \"didMount\"\n} as const;\n\nexport type Event = ValuesOf<typeof Lifecycle>;\n\nexport const lifecycleEvents = [\n \"didCreate\",\n \"willDestroy\",\n ...values(Lifecycle)\n];\n\nexport function lifecycle(prefix: string){\n const type = eventsFor(prefix);\n\n return function useLifecycle(\n sub: Subscriber, tag?: Key | KeyFactory<any>){\n\n const emit = useMemo(() => {\n const subject = sub.source as Model;\n const id = typeof tag == \"function\" ? tag(subject) : tag;\n \n return (name: Event) => {\n for(const key of [name, type(name)])\n subject.update(key, id);\n }\n }, [sub, tag]);\n\n emit(Lifecycle.WILL_RENDER);\n emit(sub.active\n ? Lifecycle.WILL_UPDATE\n : Lifecycle.WILL_MOUNT \n )\n \n useLayoutEffect(() => {\n sub.commit();\n emit(Lifecycle.DID_MOUNT);\n \n return () => {\n emit(Lifecycle.WILL_UNMOUNT);\n sub.release();\n }\n }, [sub]);\n }\n}\n\nfunction eventsFor(prefix: string){\n const map = new Map<Event, Event>();\n\n for(const name of values(Lifecycle)){\n const alias = prefix + name[0].toUpperCase() + name.slice(1);\n\n lifecycleEvents.push(alias);\n map.set(name, alias as Event);\n }\n\n return (e: Event) => map.get(e)!;\n}","import * as Computed from './compute';\nimport { lifecycleEvents } from './lifecycle';\nimport { Subscriber } from './subscriber';\nimport { defineLazy, defineProperty, getOwnPropertyDescriptor, getOwnPropertyNames, selectRecursive } from './util';\n\nexport const CONTROL = Symbol(\"control\");\nexport const LOCAL = Symbol(\"local\");\nexport const STATE = Symbol(\"state\");\n\nexport interface Stateful {\n [CONTROL]: Controller;\n [LOCAL]?: Subscriber;\n [STATE]?: any;\n\n didCreate?(): void;\n};\n\nexport function manage(src: Stateful){\n return src[CONTROL];\n}\n\nexport const Pending = new Map<symbol, Instruction<any>>();\n\nexport function apply<T = any>(\n fn: Instruction<any>, label?: string){\n\n const name = label || fn.name || \"pending\";\n const placeholder = Symbol(`${name} instruction`);\n\n function setup(this: Controller, key: string){\n let output = fn.call(this, key, this);\n\n if(typeof output == \"function\"){\n const getter = output;\n\n output = {\n ...getOwnPropertyDescriptor(this.subject, key),\n get(this: Stateful){\n return getter(this[LOCAL])\n }\n }\n }\n\n if(output)\n defineProperty(this.subject, key, output);\n }\n\n Pending.set(placeholder, setup);\n\n return placeholder as unknown as T;\n}\n\nexport type HandleValue = (this: Stateful, value: any) => boolean | void;\n\nexport type Getter<T> = (sub?: Subscriber) => T\nexport type Instruction<T> = (this: Controller, key: string, thisArg: Controller) =>\n void | Getter<T> | PropertyDescriptor;\n\nexport class Controller {\n public state = {} as BunchOf<any>;\n public frame = new Set<string>();\n\n protected handles = new Set<BunchOf<RequestCallback>>();\n protected waiting = [] as RequestCallback[];\n\n constructor(public subject: Stateful){}\n\n static setup(onto: Stateful){\n const control = new this(onto);\n\n defineLazy(onto, CONTROL, () => {\n onto[STATE] = control.state;\n control.start();\n\n if(onto.didCreate)\n onto.didCreate();\n\n return control;\n })\n\n return control;\n }\n\n public get pending(){\n return this.frame.size > 0;\n }\n\n public start(){\n const { subject } = this;\n \n for(const key in subject){\n const desc = getOwnPropertyDescriptor(subject, key);\n\n if(desc && \"value\" in desc){\n const { value } = desc;\n const instruction = Pending.get(value);\n\n if(instruction){\n Pending.delete(value);\n delete (subject as any)[key];\n instruction.call(this, key, this);\n }\n else if(typeof value !== \"function\" || /^[A-Z]/.test(key))\n this.manage(key, value);\n }\n }\n\n this.emit();\n\n return this;\n }\n\n public select(using?: Query){\n const keys = getOwnPropertyNames(this.state);\n\n return using\n ? selectRecursive(using, keys.concat(lifecycleEvents))\n : keys;\n }\n\n public manage(\n key: string,\n initial: any,\n effect?: HandleValue){\n\n const { state, subject } = this;\n\n state[key] = initial;\n defineProperty(subject, key, {\n enumerable: true,\n configurable: true,\n get: () => state[key],\n set: this.setter(key, effect)\n });\n }\n\n public setter(\n key: string,\n handler?: HandleValue){\n\n const { state, subject } = this;\n\n return (value: any) => {\n if(state[key] == value)\n return;\n\n if(handler)\n switch(handler.call(subject, value)){\n case true:\n this.update(key);\n case false:\n return;\n }\n\n this.update(key, value);\n }\n }\n\n public addListener(\n batch: BunchOf<RequestCallback>){\n\n this.handles.add(batch);\n return () => {\n this.handles.delete(batch)\n }\n }\n\n public include(to: RequestCallback){\n if(Computed.capture(this, to))\n return;\n else\n this.waiting.push(to)\n }\n\n public update(key: string, value?: any){\n if(1 in arguments)\n this.state[key] = value;\n\n if(this.frame.has(key))\n return;\n\n if(!this.frame.size)\n setTimeout(() => this.emit(), 0);\n\n this.frame.add(key);\n\n for(const subscription of this.handles)\n if(key in subscription)\n this.include(subscription[key]);\n }\n\n public emit(){\n Computed.flush(this);\n\n const keys = Array.from(this.frame);\n const handle = new Set(this.waiting.splice(0));\n\n this.frame.clear();\n\n handle.forEach(callback => {\n try { callback(keys) }\n catch(e){ }\n })\n }\n}\n\nexport function keys(\n from: Controller,\n using?: string | Iterable<string> | Query){\n\n if(typeof using == \"string\")\n return [ using ];\n\n if(typeof using == \"object\")\n return Array.from(using);\n\n return from.select(using);\n}","import { apply, Controller } from './controller';\nimport { Model } from './model';\nimport { Subscriber } from './subscriber';\n\ntype ChildInstruction<T extends Model> =\n (this: Controller, key: string) => () => T | undefined;\n\nexport function child<T extends Model>(\n from: ChildInstruction<T>, name?: string){\n\n return apply(\n function child(this: Controller, key: string){\n const proxyCache = new WeakMap<Subscriber, any>();\n const getCurrent = from.call(this, key);\n \n function subscribe(sub: Subscriber){\n let child: Subscriber | undefined;\n \n function start(){\n const instance = getCurrent();\n \n if(instance){\n child = new Subscriber(instance, sub.onUpdate);\n \n if(sub.active)\n child.commit();\n \n sub.dependant.add(child);\n proxyCache.set(sub, child.proxy);\n }\n }\n \n function refresh(){\n if(child){\n child.release();\n sub.dependant.delete(child);\n proxyCache.set(sub, undefined);\n child = undefined;\n }\n \n start();\n sub.onUpdate();\n }\n \n start();\n sub.follow(key, refresh);\n }\n \n return (local: Subscriber | undefined) => {\n if(!local)\n return getCurrent();\n \n if(!proxyCache.has(local))\n subscribe(local);\n \n return proxyCache.get(local);\n }\n },\n name || from.name\n )\n}","import { useLayoutEffect, useMemo, useState } from 'react';\n\nimport { keys, manage, Stateful } from './controller';\nimport { issues } from './issues';\nimport { Lifecycle } from './lifecycle';\nimport { Model } from './model';\nimport { Subscriber } from './subscriber';\nimport { defineProperty } from './util';\n\nexport const Oops = issues({\n HasPropertyUndefined: (control, property) =>\n `${control}.${property} is marked as required for this render.`\n})\n\nexport function use<T>(init: (trigger: Callback) => T){\n const [ state, update ] = useState((): T[] => [\n init(() => update(state.concat()))\n ]);\n\n return state[0];\n}\n\nexport function useLazy<T extends typeof Model>(\n Type: T, callback?: (instance: InstanceOf<T>) => void){\n\n const instance = useMemo(() => {\n const instance = Type.create();\n\n if(callback)\n callback(instance);\n\n return instance;\n }, []);\n\n useLayoutEffect(() => () => instance.destroy(), []);\n\n return instance;\n}\n\nexport function useWatcher(\n target: Stateful,\n focus?: string | Select,\n expected?: boolean){\n\n const hook = use(refresh => {\n const sub = new Subscriber(target, refresh);\n\n if(focus){\n const src = sub.proxy;\n const key = keys(sub.parent, focus)[0];\n\n defineProperty(sub, \"proxy\", {\n get(){\n if(src[key] === undefined && expected)\n throw Oops.HasPropertyUndefined(target, key);\n\n return src[key];\n }\n })\n }\n\n return sub;\n });\n\n useLayoutEffect(() => hook.commit(), []);\n\n return hook.proxy;\n}\n\nexport function useModel(\n Type: Class,\n callback?: (instance: Model) => void){\n\n const hook = use(refresh => {\n const instance = new Type() as Model;\n const control = manage(instance);\n const sub = new Subscriber(control, refresh);\n\n const release = control.addListener({\n [Lifecycle.WILL_UNMOUNT](){\n instance.destroy();\n release();\n }\n });\n\n if(callback)\n callback(instance);\n\n return sub;\n });\n\n return hook.proxy;\n}","import { child } from './attach';\nimport { useLookup } from './context';\nimport { Stateful } from './controller';\nimport { issues } from './issues';\nimport { Model } from './model';\nimport { Lookup } from './register';\nimport { Singleton } from './singleton';\n\nexport const Oops = issues({\n CantAttachGlobal: (parent, child) =>\n `Singleton '${parent}' attempted to attach '${child}' but it is not also a singleton.`,\n\n AmbientRequired: (requested, requester, key) =>\n `Attempted to find an instance of ${requested} in context. It is required for [${requester}.${key}], but one could not be found.`\n})\n\ntype Peer = typeof Model | typeof Singleton;\ntype ApplyPeer = (context: Lookup) => void;\ntype PeerCallback<T extends Peer> = (instance: InstanceOf<T> | undefined) => void | boolean;\n\nconst PendingContext = new WeakMap<Stateful, ApplyPeer[]>();\nconst ContextWasUsed = new WeakMap<Model, boolean>();\n\nexport function tap<T extends Peer>(\n type: T, argument?: boolean | PeerCallback<T>){\n\n return child(\n function tap(key){\n return pendingAccess(this.subject, type, key, argument);\n }\n )\n};\n\nexport function pendingAccess<T extends Peer>(\n from: Stateful,\n type: T,\n key: string,\n argument?: boolean | PeerCallback<T>){\n\n if(\"current\" in type)\n return () => type.current as InstanceOf<T>;\n\n if(\"current\" in from.constructor)\n throw Oops.CantAttachGlobal(from, type.name);\n\n let instance: InstanceOf<T> | undefined;\n\n getPending(from).push(context => {\n instance = context.get(type);\n\n if(typeof argument == \"function\"){\n if(argument(instance) === false)\n instance = undefined;\n }\n\n else if(!instance && argument)\n throw Oops.AmbientRequired(type.name, from, key);\n })\n\n return () => instance;\n}\n\nexport function usePeerContext(subject: Model){\n if(ContextWasUsed.has(subject)){\n if(ContextWasUsed.get(subject))\n useLookup();\n\n return;\n }\n\n const pending = PendingContext.get(subject);\n\n if(pending){\n const local = useLookup();\n \n for(const init of pending)\n init(local);\n\n PendingContext.delete(subject);\n }\n\n ContextWasUsed.set(subject, !!pending);\n}\n\nexport function getPending(subject: Stateful){\n let pending = PendingContext.get(subject);\n\n if(!pending)\n PendingContext.set(subject, pending = []);\n\n return pending;\n}","import { Model } from './model';\nimport { create, defineProperty, getOwnPropertyDescriptor, getOwnPropertySymbols, getPrototypeOf, values } from './util';\n\nexport type Collection =\n | Array<Model | typeof Model>\n | BunchOf<Model | typeof Model>;\n\nexport class Lookup {\n private table = new Map<typeof Model, symbol>();\n\n public get local(){\n return getOwnPropertySymbols(this).map(\n (symbol): Model => (this as any)[symbol]\n ) \n }\n\n private key(T: typeof Model){\n let key = this.table.get(T);\n\n if(!key){\n key = Symbol(T.name);\n this.table.set(T, key);\n }\n\n return key;\n }\n\n public get(T: typeof Model){\n return (this as any)[this.key(T)];\n }\n \n public push(I: Model | typeof Model | Collection){\n const next = create(this) as this;\n\n if(I instanceof Model || typeof I == \"function\")\n next.register(I);\n else\n for(const i of values(I))\n next.register(i);\n\n return next;\n }\n\n public register(I: Model | typeof Model){\n let writable = true;\n let T: typeof Model;\n\n if(I instanceof Model){\n T = I.constructor as any;\n writable = false;\n }\n else {\n T = I;\n I = I.create();\n }\n\n do {\n defineProperty(this, this.key(T), {\n value: I, writable\n });\n T = getPrototypeOf(T);\n }\n while(T !== Model);\n\n return I;\n }\n\n public pop(){\n for(const key of getOwnPropertySymbols(this)){\n const entry = getOwnPropertyDescriptor(this, key)!;\n\n if(entry.writable)\n entry.value.destroy();\n }\n }\n}","import { createContext, createElement, ReactElement, ReactNode, useContext, useLayoutEffect, useMemo } from 'react';\n\nimport { use } from './hooks';\nimport { issues } from './issues';\nimport { Model } from './model';\nimport { getPending } from './peer';\nimport { Collection, Lookup } from './register';\nimport { Subscriber } from './subscriber';\nimport { entries } from './util';\n\nexport const Oops = issues({\n NoProviderType: () =>\n `Provider 'of' prop must be Model, typeof Model or a collection of them.`,\n\n NothingInContext: (name) =>\n `Couldn't find ${name} in context; did you forget to use a Provider?`,\n\n BadConsumerProps: () =>\n `Provider expects either a render function, 'get' or 'has' props.`\n})\n\nexport const LookupContext = createContext(new Lookup());\nexport const useLookup = () => useContext(LookupContext);\n\nexport function useFromContext<T extends Class>(\n Type: T, strict?: boolean){\n\n const instance = useLookup().get(Type as any);\n\n if(!instance && strict)\n throw Oops.NothingInContext(Type.name);\n\n return instance as InstanceOf<T>;\n}\n\ninterface ConsumerProps {\n of: typeof Model;\n get?: (value: Model) => void;\n has?: (value: Model) => void;\n children?: (value: Model) => ReactElement<any, any> | null;\n}\n\nexport function Consumer(props: ConsumerProps){\n const { get, has, children, of: Control } = props;\n\n if(typeof children == \"function\")\n return children(Control.tap());\n\n const callback = has || get;\n\n if(typeof callback == \"function\")\n callback(Control.get(!!has));\n else\n throw Oops.BadConsumerProps()\n\n return null;\n}\n\nfunction useNewContext(\n from: Lookup,\n inject?: Model | typeof Model | Collection){\n\n return useMemo(() => {\n if(!inject)\n throw Oops.NoProviderType();\n \n const context = from.push(inject);\n\n for(const instance of context.local)\n for(const apply of getPending(instance))\n apply(context)\n\n return context;\n }, []);\n}\n\nfunction useAppliedProps(within: Lookup, props: {}){\n const update = useMemo(() => {\n const targets = within.local;\n\n return function integrate(props: {}){\n for(const [key, value] of entries(props))\n if(key != \"of\" && key != \"children\")\n for(const into of targets)\n if(key in into)\n (into as any)[key] = value;\n };\n }, []);\n\n update(props);\n}\n\ninterface RenderFunctionProps {\n context: Lookup;\n render: Function;\n}\n\nfunction RenderFunction(props: RenderFunctionProps): any {\n const hook = use(refresh => {\n const targets = props.context.local;\n\n if(targets.length == 1)\n return new Subscriber(targets[0], refresh);\n\n return {} as Subscriber;\n });\n\n if(hook.commit)\n useLayoutEffect(() => hook.commit(), []);\n\n return props.render(hook.proxy);\n}\n\ninterface ProvideProps {\n of?: typeof Model | Model | Collection;\n children: ReactNode | ((instance?: any) => ReactNode);\n}\n\nexport function Provider(props: ProvideProps){\n const render = props.children;\n const current = useLookup();\n const context = useNewContext(current, props.of);\n\n useAppliedProps(context, props);\n useLayoutEffect(() => () => context.pop(), []);\n\n return createElement(LookupContext.Provider, { value: context },\n typeof render == \"function\"\n ? createElement(RenderFunction, { context, render })\n : render\n );\n}","import * as Computed from './compute';\nimport { useFromContext } from './context';\nimport { CONTROL, Controller, keys, LOCAL, manage, STATE, Stateful } from './controller';\nimport { use, useLazy, useModel, useWatcher } from './hooks';\nimport { issues } from './issues';\nimport { lifecycle } from './lifecycle';\nimport { usePeerContext } from './peer';\nimport { Subscriber } from './subscriber';\nimport { createEffect, define, defineLazy, select } from './util';\n\nexport const Oops = issues({\n StrictUpdate: (expected) => \n `Strict update() did ${expected ? \"not \" : \"\"}find pending updates.`,\n\n NoChaining: () =>\n `Then called with undefined; update promise will never catch nor supports chaining.`\n})\n\nconst useElementLifecycle = lifecycle(\"element\");\nconst useComponentLifecycle = lifecycle(\"component\");\n\nexport interface Model extends Stateful {\n get: this;\n set: this;\n\n didCreate?: Callback;\n willDestroy?: Callback;\n}\n\nexport class Model {\n static CONTROL = CONTROL;\n static STATE = STATE;\n static LOCAL = LOCAL;\n\n static [CONTROL]: Controller;\n\n constructor(){\n const control = Controller.setup(this);\n\n define(this, \"get\", this);\n define(this, \"set\", this);\n\n defer(control, \"on\");\n defer(control, \"effect\");\n\n control.include(() => {\n delete (this as any).on;\n delete (this as any).effect;\n })\n }\n\n tap(path?: string | Select, expect?: boolean){\n const proxy = useWatcher(this, path, expect);\n this.update(\"willRender\", true);\n return proxy;\n }\n\n tag(id?: Key | KeyFactory<this>){\n const hook = use(refresh => {\n return new Subscriber(this, refresh);\n });\n \n useElementLifecycle(hook, id || 0);\n \n return hook.proxy;\n }\n\n use(callback?: (instance: Model) => void){\n const hook = use(refresh => {\n if(callback)\n callback(this);\n\n return new Subscriber(this, refresh);\n });\n \n useComponentLifecycle(hook);\n \n return hook.proxy;\n }\n\n on(\n subset: string | Iterable<string> | Query,\n handler: Function,\n squash?: boolean,\n once?: boolean){\n\n const control = manage(this);\n const set = keys(control, subset);\n const batch = {} as BunchOf<RequestCallback>;\n const remove = control.addListener(batch);\n\n const callback: RequestCallback = squash\n ? handler.bind(this)\n : (frame: string[]) => {\n for(const key of frame)\n if(set.includes(key))\n handler.call(this, control.state[key], key);\n }\n\n const handle = once\n ? (k: string[]) => { remove(); callback(k) }\n : callback;\n\n for(const key of set)\n batch[key] = handle;\n\n Computed.ensure(control, set);\n\n return remove;\n }\n\n once(\n select: string | Iterable<string> | Query,\n callback?: UpdateCallback<any, any>,\n squash?: boolean){\n\n if(callback)\n return this.on(select, callback, squash, true);\n else \n return new Promise<void>(resolve => {\n this.on(select, resolve, true, true);\n });\n }\n\n effect(\n callback: EffectCallback<any>,\n select?: string[] | Query){\n\n const control = manage(this);\n let target = this;\n\n const effect = createEffect(callback);\n const invoke = () => effect.call(target, target);\n\n if(select){\n invoke();\n return this.on(select, invoke, true);\n }\n else {\n const sub = new Subscriber(control, invoke);\n target = sub.proxy;\n invoke();\n return sub.commit();\n }\n }\n\n import(\n from: BunchOf<any>,\n subset?: Iterable<string> | Query){\n\n for(const key of keys(manage(this), subset))\n if(key in from)\n (this as any)[key] = from[key];\n }\n\n export(subset?: Iterable<string> | Query){\n const control = manage(this);\n const output: BunchOf<any> = {};\n\n for(const key of keys(control, subset))\n output[key] = (control.state as any)[key];\n\n return output;\n }\n\n update(strict?: boolean): Promise<string[] | false>;\n update(select?: Select): PromiseLike<string[]>;\n update(key: string | Select, callMethod: boolean): PromiseLike<string[]>;\n update(key: string | Select, tag?: any): PromiseLike<string[]>;\n update(arg?: string | boolean | Select, tag?: any){\n const control = manage(this);\n\n if(typeof arg == \"function\")\n arg = select(this, arg);\n\n if(typeof arg == \"boolean\"){\n if(!control.pending === arg)\n return Promise.reject(Oops.StrictUpdate(arg))\n }\n else if(arg){\n control.update(arg);\n\n if(1 in arguments && arg in this){\n const method = (this as any)[arg];\n\n if(typeof method == \"function\")\n if(typeof tag != \"boolean\")\n method.call(this, tag);\n else if(tag)\n method.call(this);\n }\n }\n\n return <PromiseLike<string[] | false>> {\n then(callback){\n if(callback)\n if(control.pending)\n control.include(callback);\n else\n callback(false);\n else\n throw Oops.NoChaining();\n }\n }\n }\n\n destroy(){\n this.update(\"willDestroy\", true);\n }\n\n toString(){\n return this.constructor.name;\n }\n\n static create<T extends Class>(\n this: T, ...args: any[]){\n\n const instance: InstanceOf<T> = \n new (this as any)(...args);\n\n manage(instance);\n\n return instance;\n }\n\n static new(callback?: (instance: Model) => void){\n const instance = useLazy(this, callback);\n instance.update(\"willRender\", true);\n return instance\n }\n\n static find<T extends Class>(this: T, strict: true): InstanceOf<T>;\n static find<T extends Class>(this: T, strict?: boolean): InstanceOf<T> | undefined;\n static find<T extends Class>(this: T, strict?: boolean){\n return useFromContext(this, strict);\n }\n\n static get(key?: boolean | string | Select){\n const instance: any = this.find(!!key);\n \n return (\n typeof key == \"function\" ?\n key(instance) :\n typeof key == \"string\" ?\n instance[key] :\n instance\n )\n }\n\n static tap(key?: string | Select, expect?: boolean): any {\n return this.find(true).tap(key, expect);\n }\n\n static tag(id?: Key | ((target: Model) => Key | undefined)){\n return this.find(true).tag(id);\n }\n\n static use(callback?: (instance: Model) => void){\n const instance = useModel(this, callback);\n useComponentLifecycle(instance[LOCAL]);\n usePeerContext(instance.get);\n return instance;\n }\n\n static uses(props: BunchOf<any>, only?: string[]){\n return this.use(instance => {\n instance.import(props, only);\n })\n }\n\n static using(props: BunchOf<any>, only?: string[]){\n const instance = this.use();\n instance.import(props, only);\n return instance;\n }\n\n static meta(path: string | Select): any {\n return useWatcher(this, path);\n }\n\n static isTypeof<T extends typeof Model>(\n this: T, maybe: any): maybe is T {\n\n return (\n typeof maybe == \"function\" &&\n maybe.prototype instanceof this\n )\n }\n}\n\ndefineLazy(Model, CONTROL, function(){\n return new Controller(this).start();\n})\n\nfunction defer(on: Controller, method: string){\n const { subject, waiting } = on as any;\n const real = subject[method];\n\n subject[method] = (...args: any[]) => {\n let done: any;\n waiting.push(() => {\n done = real.apply(subject, args);\n });\n return () => done();\n }\n}","import { child } from './attach';\nimport { apply, manage } from './controller';\nimport { issues } from './issues';\nimport { Model } from './model';\nimport { defineProperty, getOwnPropertyDescriptors } from './util';\n\nconst Parent = new WeakMap<{}, {}>();\n\nexport const Oops = issues({\n ParentRequired: (expects, child) => \n `New ${child} created standalone but requires parent of type ${expects}. Did you remember to create via use(${child})?`,\n\n UnexpectedParent: (expects, child, got) =>\n `New ${child} created as child of ${got}, but must be instanceof ${expects}.`,\n\n UndefinedNotAllowed: (key) =>\n `Child property ${key} may not be undefined.`,\n\n BadArgument: (type) =>\n `Instruction \\`use\\` cannot accept argument type of ${type}.`\n})\n\nfunction bootstrap<T extends {}>(object: T){\n const breakdown = getOwnPropertyDescriptors(object);\n const control = new Model();\n\n for(const key in breakdown)\n defineProperty(control, key, breakdown[key]);\n \n return control as T & Model;\n}\n\nexport function use<T extends typeof Model>(\n input?: T | (() => InstanceOf<T>),\n argument?: ((i: Model | undefined) => void) | boolean){\n\n return child(\n function use(key){\n let instance: Model | undefined;\n \n const update = (next: Model | {} | undefined) => {\n instance =\n next instanceof Model ? next :\n next && bootstrap(next);\n \n if(instance){\n Parent.set(instance, this.subject);\n manage(instance);\n }\n \n if(typeof argument == \"function\")\n argument(instance);\n else if(!instance && argument !== false)\n throw Oops.UndefinedNotAllowed(key);\n }\n \n if(input){\n instance =\n Model.isTypeof(input) ? new input() :\n input instanceof Model ? input :\n typeof input === \"function\" ? input() :\n typeof input === \"object\" ? bootstrap(input) :\n Oops.BadArgument(typeof input).throw();\n \n if(instance)\n update(instance);\n }\n else\n argument = false;\n \n this.manage(key, instance, update);\n \n return () => instance;\n }\n )\n}\n\nexport function parent<T extends typeof Model>(\n Expects: T, required?: boolean): InstanceOf<T> {\n\n return apply(\n function parent(){\n const child = this.subject;\n const expected = Expects.name;\n const value = Parent.get(this.subject);\n \n if(!value){\n if(required)\n throw Oops.ParentRequired(expected, child);\n }\n else if(!(value instanceof Expects))\n throw Oops.UnexpectedParent(expected, child, value);\n \n return { value };\n }\n );\n}","import * as Computed from './compute';\nimport { apply, Controller, manage, Stateful } from './controller';\nimport { issues } from './issues';\nimport { Model } from './model';\nimport { pendingAccess } from './peer';\nimport { createValueEffect, define, defineLazy, defineProperty, setAlias } from './util';\n\nexport const Oops = issues({\n DuplicateAction: (key) =>\n `Invoked action ${key} but one is already active.`,\n\n BadComputedSource: (model, property, got) =>\n `Bad from-instruction provided to ${model}.${property}. Expects an arrow-function or a Model as source. Got ${got}.`,\n\n PeerNotAllowed: (model, property) =>\n `Attempted to use an instruction result (probably use or tap) as computed source for ${model}.${property}. This is not possible.`\n})\n\nfunction createRef(\n this: Controller,\n key: string,\n cb?: InterceptCallback<any>){\n\n const refObjectFunction =\n this.setter(key, cb && createValueEffect(cb));\n\n defineProperty(refObjectFunction, \"current\", {\n set: refObjectFunction,\n get: () => this.state[key]\n })\n\n return refObjectFunction;\n}\n\nexport function ref<T>(arg?: InterceptCallback<T> | Model): { current: T } {\n return apply(\n function ref(key){\n let value = {};\n\n if(typeof arg == \"object\"){\n const source = manage(arg);\n \n for(const key in source.state)\n defineLazy(value, key, createRef.bind(source, key));\n }\n else \n value = createRef.call(this, key, arg);\n\n return { value };\n }\n )\n}\n\nexport function on<T>(\n initial: T, cb: InterceptCallback<T>): T {\n\n return apply(\n function on(key){\n this.manage(key, initial, cb && createValueEffect(cb));\n }\n );\n}\n\nexport function memo<T>(\n factory: () => T, defer?: boolean): T {\n\n return apply(\n function memo(key){\n const source = this.subject;\n const get = () => factory.call(source);\n\n if(defer)\n defineLazy(source, key, get);\n else\n define(source, key, get())\n }\n );\n}\n\nexport function lazy<T>(value: T): T {\n return apply(\n function lazy(key){\n const source = this.subject as any;\n\n source[key] = value;\n defineProperty(this.state, key, {\n get: () => source[key]\n });\n }\n );\n}\n\nexport function act<T extends Async>(task: T): T {\n return apply(\n function act(key){\n let pending = false;\n\n const invoke = (...args: any[]) => {\n if(pending)\n return Promise.reject(\n Oops.DuplicateAction(key)\n )\n\n pending = true;\n this.update(key);\n\n return new Promise(res => {\n res(task.apply(this.subject, args));\n }).finally(() => {\n pending = false;\n this.update(key);\n })\n };\n\n setAlias(invoke, `run ${key}`);\n defineProperty(invoke, \"active\", {\n get: () => pending\n })\n\n return {\n value: invoke,\n writable: false\n };\n }\n )\n}\n\ntype ComputeFunction<T, O = any> = (this: O, on: O) => T;\ntype ComputeFactory<T> = (key: string) => ComputeFunction<T>;\n\nexport function from<T, R = T>(\n source: ComputeFactory<T> | Stateful,\n setter?: ComputeFunction<T>,\n getter?: (this: Model, value: T, key: string) => R): R {\n\n return apply(\n function from(key){\n const { subject } = this;\n let getSource: () => Controller;\n\n // Easy mistake, using a peer, will always be unresolved.\n if(typeof source == \"symbol\")\n throw Oops.PeerNotAllowed(subject, key);\n\n // replace source controller in-case different\n if(typeof source == \"object\")\n getSource = () => manage(source);\n\n // specifically an arrow function (getter factory)\n else if(!source.prototype){\n setter = source.call(subject, key);\n getSource = () => this;\n }\n\n // is a peer Model (constructor)\n else if(Model.isTypeof(source))\n getSource = pendingAccess(subject, source, key, true);\n\n // Regular function is to ambiguous so not allowed.\n else\n throw Oops.BadComputedSource(subject, key, source);\n\n Computed.prepare(this, key, getSource, setter!, getter);\n }\n )\n}","import { apply, Controller, manage } from './controller';\nimport { from } from './instructions';\nimport { issues } from './issues';\nimport { Model } from './model';\n\nexport const Oops = issues({\n ValueNotReady: (model, key) =>\n `Value ${model}.${key} value is not yet available.`\n})\n\ntype ComputeFunction<T, O = any> = (this: O, on: O) => T;\n\nexport function pending<T = void>(\n source: (() => Promise<T>) | Model | typeof Model,\n compute?: ComputeFunction<T>){\n\n return (\n source === undefined ?\n suspendForValue() :\n typeof source == \"function\" && !source.prototype ?\n suspendForAsync(source as any) :\n suspendForComputed(source as any, compute)\n )\n}\n\n/**\n * Get value, suspend instead if undefined.\n * \n * Throws suspense promise also interpretable as an error.\n * React could handle it but other contexts probably not.\n */\nfunction pendingValue<T = any>(\n via: Controller, key: string): T {\n\n const value = via.state[key];\n\n if(value !== undefined)\n return value;\n\n const error =\n Oops.ValueNotReady(via.subject, key);\n\n const promise = new Promise<void>(resolve => {\n const release = via.addListener({\n [key](value: any){\n if(value !== undefined){\n release();\n resolve();\n }\n }\n });\n });\n\n throw Object.assign(promise, {\n toString: () => String(error),\n message: error.message,\n stack: error.stack\n });\n}\n\nfunction suspendForComputed<T>(\n source: Model | typeof Model,\n compute?: ComputeFunction<T>){\n\n function getter(\n this: Model, _value: any, key: string){\n\n return pendingValue(manage(this), key);\n }\n\n return from(source, compute, getter);\n}\n\nfunction suspendForValue<T = void>(){\n return apply<T>(\n function pending(key){\n this.state[key] = undefined;\n\n return {\n set: this.setter(key),\n get: () => pendingValue(this, key)\n }\n }\n )\n}\n\nfunction suspendForAsync<T = void>(\n source: (key: string) => Promise<T>){\n\n return apply(\n function suspense(key){\n const subject = this.subject as Model\n let waiting = true;\n let value: any;\n let error: any;\n \n return () => {\n if(error)\n throw error;\n\n if(!waiting)\n return value;\n\n const issue =\n Oops.ValueNotReady(subject, key);\n\n let suspend = source\n .call(subject, key)\n .catch(err => error = err)\n .then(out => value = out)\n .finally(() => waiting = false);\n \n throw Object.assign(suspend, {\n message: issue.message,\n stack: issue.stack\n });\n }\n }\n )\n}","import { issues } from './issues';\nimport { Model } from './model';\n\nexport const Oops = issues({\n GlobalDoesNotExist: (name) =>\n `Tried to access singleton ${name}, but none exist! Did you forget to initialize?\\nCall ${name}.create() before attempting to access, or consider using ${name}.use() instead.`,\n \n GlobalExists: (name) =>\n `Shared instance of ${name} already exists! Consider unmounting existing, or use ${name}.reset() to force-delete it.`\n})\n\nconst Active = new WeakMap<typeof Singleton, Singleton>();\n\nexport class Singleton extends Model {\n static get current(){\n return Active.get(this);\n }\n\n static create<T extends Class>(\n this: T, ...args: any[]){\n\n const Type: typeof Singleton = this as any;\n\n if(Active.has(Type))\n throw Oops.GlobalExists(this.name);\n\n let instance = super.create(...args);\n\n Active.set(Type, instance);\n\n return instance as InstanceOf<T>;\n }\n\n static update<T extends typeof Singleton>(\n this: T, updates: Partial<InstanceOf<T>>){\n\n const instance = this.current || this.create();\n instance.import(updates);\n return instance.update();\n }\n\n static is(){\n return this.find(true);\n }\n\n static find<T extends Class>(this: T, strict?: boolean){\n const instance = (this as any).current as InstanceOf<T>;\n\n if(!instance && strict)\n throw Oops.GlobalDoesNotExist(this.name);\n\n return instance;\n }\n\n static reset(){\n if(this.current)\n this.current.destroy();\n }\n\n destroy(){\n super.destroy();\n Active.delete(this.constructor as any);\n }\n}"],"names":["Oops","keys","useMemo","useLayoutEffect","Computed.capture","Computed.flush","use","useState","createContext","useContext","createElement","Computed.ensure","Computed.prepare"],"mappings":";;;;;;AAWA,MAAM,KAAM,SAAQ,KAAK;IAAzB;;;QAEE,UAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAW,CAAC;KASlD;IAPC,IAAI;QACF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC5B;IAED,KAAK;QACH,MAAM,IAAI,CAAC;KACZ;CACF;SAEe,MAAM,CAAqB,QAAW;IACpD,MAAM,OAAO,GAAG,EAAS,CAAC;IAE1B,KAAI,MAAM,IAAI,IAAI,QAAQ;QACxB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAkB,KACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEhD,OAAO,OAAoB,CAAC;AAC9B;;AC9BO,MAAMA,MAAI,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,MACjB,0DAA0D;CAC7D,CAAC,CAAA;AAEF,MAAM,EACJ,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,QACrBC,MAAI,EACJ,MAAM,EACP,GAAG,MAAM,CAAC;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;KACxC;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@expressive/mvc",
3
- "version": "1.0.0-beta.20",
4
3
  "description": "Use classes to define state in React!",
5
4
  "author": {
6
5
  "name": "Gabe Klein",
@@ -17,6 +16,7 @@
17
16
  "mvc"
18
17
  ],
19
18
  "main": "lib/index.js",
19
+ "module": "lib/index.esm.js",
20
20
  "types": "types/index.d.ts",
21
21
  "files": [
22
22
  "lib",
@@ -32,8 +32,7 @@
32
32
  "react": ">=17.0.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@rollup/plugin-commonjs": "^19.0.0",
36
- "@rollup/plugin-typescript": "^8.2.1",
35
+ "@rollup/plugin-commonjs": "^21.0.1",
37
36
  "@testing-library/react-hooks": "^7.0.0",
38
37
  "@types/jest": "^26.0.23",
39
38
  "@types/node": "^15.12.4",
@@ -41,10 +40,11 @@
41
40
  "jest": "^27.0.4",
42
41
  "react": ">=17.0.2",
43
42
  "react-test-renderer": "^17.0.2",
44
- "rollup": "^2.52.2",
45
- "rollup-plugin-typescript2": "^0.30.0",
43
+ "rollup": "^2.61.1",
44
+ "rollup-plugin-typescript2": "^0.31.1",
46
45
  "ts-jest": "^27.0.3",
47
46
  "tslib": "^2.3.0",
48
47
  "typescript": "typescript@>=3.8 <5.0"
49
- }
48
+ },
49
+ "version": "1.0.0-beta.24"
50
50
  }
@@ -1,9 +1,7 @@
1
- import { Consumer, ReactElement, ReactNode, Component, ComponentType } from "react";
1
+ import { Consumer, ReactElement, ReactNode } from "react";
2
2
  import { Model } from "./model"
3
3
  import { Class } from "./types";
4
4
 
5
- type Output = ReactElement<any, any> | null;
6
-
7
5
  export namespace Provider {
8
6
  type Item = Model | typeof Model;
9
7
  type Collection<T extends Item> = T[] | { [key: string]: T };
@@ -21,7 +19,7 @@ export namespace Provider {
21
19
  type Props<T extends Item> = MultipleProps<T> | NormalProps<T>;
22
20
  }
23
21
 
24
- export function Provider<T extends Provider.Item>(props: Provider.Props<T>): Output;
22
+ export function Provider<T extends Provider.Item>(props: Provider.Props<T>): ReactElement<typeof props>;
25
23
 
26
24
  export namespace Consumer {
27
25
  type HasProps<E extends Class> = {
@@ -50,10 +48,10 @@ export namespace Consumer {
50
48
  * Similar to `tap()`, updates to properties accessed in
51
49
  * this function will cause a refresh when they change.
52
50
  */
53
- children: (value: InstanceType<E>) => Output;
51
+ children: (value: InstanceType<E>) => ReactElement<any, any> | null;
54
52
  }
55
53
 
56
54
  type Props<T extends Class> = HasProps<T> | GetProps<T> | RenderProps<T>
57
55
  }
58
56
 
59
- export function Consumer<T extends Class>(props: Consumer.Props<T>): Output;
57
+ export function Consumer<T extends Class>(props: Consumer.Props<T>): null;
package/types/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export {
2
- State,
3
2
  Model,
4
3
  Model as default,
5
4
  Singleton
@@ -5,7 +5,7 @@ import { Async, Class, InstanceOf, InterceptCallback } from './types';
5
5
  * Run instruction as controller sets itself up.
6
6
  * This will specialize the behavior of a given property.
7
7
  **/
8
- export function set <T = any> (instruction: Model.Instruction<T>, name?: string): T;
8
+ export function apply <T = any> (instruction: Model.Instruction<T>, name?: string): T;
9
9
 
10
10
  /**
11
11
  * Creates a new child-instance of specified controller.
@@ -113,18 +113,34 @@ export function tap <T extends Class> (Type: T, required?: boolean): InstanceOf<
113
113
  * @param initialValue - Beginning value of host property.
114
114
  * @param onUpdate - Effect-callback fired upon set of host property.
115
115
  */
116
- export function on <T = any> (initialValue: undefined, onUpdate: InterceptCallback<T>): T | undefined;
117
- export function on <T = any> (initialValue: T, onUpdate: InterceptCallback<T>): T;
116
+ export function on <T> (initialValue: undefined, onUpdate: InterceptCallback<T>): T | undefined;
117
+ export function on <T> (initialValue: T, onUpdate: InterceptCallback<T>): T;
118
+ export function on <T, S> (initialValue: undefined, onUpdate: InterceptCallback<T, S>): T | undefined;
119
+ export function on <T, S> (initialValue: T, onUpdate: InterceptCallback<T, S>): T;
120
+
121
+ /** Object with references to all managed values of `T`. */
122
+ export type Refs <T extends Model> = { [P in Model.Fields<T>]: Model.Ref<T[P]> };
118
123
 
119
124
  /**
120
- * Creates a ref-compatible property for use with components.
125
+ * Creates an object with references to all managed values.
126
+ * Each property will set value in state when invoked.
127
+ *
128
+ * *Properties are simultaneously a ref-function and ref-object, use as needed.*
129
+ *
130
+ * @param target - Source model from which to reference values.
131
+ */
132
+ export function ref <T extends Model> (target: T): Refs<T>;
133
+
134
+ /**
135
+ * Creates a ref-compatible property.
121
136
  * Will persist value, and updates to this are made part of controller event-stream.
122
137
  *
123
138
  * *Output is simultaneously a ref-function and ref-object, use as needed.*
124
139
  *
125
140
  * @param callback - Optional callback to synchronously fire when reference is first set or does update.
126
141
  */
127
- export function ref <T = HTMLElement> (this: any, callback?: InterceptCallback<T>): Model.Ref<T>;
142
+ export function ref <T = HTMLElement> (callback?: InterceptCallback<T>): Model.Ref<T>;
143
+ export function ref <T, S> (callback?: InterceptCallback<T, S>): Model.Ref<T>;
128
144
 
129
145
  /**
130
146
  * Sets an exotic method with managed ready-state. Property accepts an async function.
@@ -136,34 +152,36 @@ export function ref <T = HTMLElement> (this: any, callback?: InterceptCallback<T
136
152
  *
137
153
  * @param action - Action to fire when resulting property is invoked.
138
154
  */
139
- export function act <T extends Async> (action: T): T & { active: boolean };
155
+ export function act (action: Async): typeof action & { active: boolean };
156
+ export function act <S> (action: Async<S>): typeof action & { active: boolean };
140
157
 
141
158
  /**
142
159
  * Implement a computed value; output is returned by function from provided factory.
143
160
  *
144
- * @param fn - Factory function to generate a getter to subscribe dependancies.
161
+ * @param compute - Factory function to generate a getter to subscribe dependancies.
145
162
  */
146
- export function from <R> (fn: (property: string) => (this: any, state: any) => R): R;
163
+ export function from <R> (compute: (property: string) => <T>(this: T, state: T) => R): R;
164
+ export function from <R, T> (compute: (property: string) => (this: T, state: T) => R): R;
147
165
 
148
166
  /**
149
167
  * Implement a computed value; output will be generated by provided function.
150
168
  *
151
169
  * @param source - Source Model to find and subscribe to, for input.
152
170
  *
153
- * @param fn - Compute function. Bound to a subscriber-proxy of source, returns output value.
171
+ * @param compute - Compute function. Bound to a subscriber-proxy of source, returns output value.
154
172
  * Will update automatically as input values change.
155
173
  */
156
- export function from <T extends Class, R> (source: T, fn: (this: InstanceOf<T>, on: InstanceOf<T>) => R): R;
174
+ export function from <T extends Class, R> (source: T, compute: (this: InstanceOf<T>, on: InstanceOf<T>) => R): R;
157
175
 
158
176
  /**
159
177
  * Implement a computed value; output will be generated by provided function.
160
178
  *
161
179
  * @param source - Source model from which computed value will be a subscriber.
162
180
  *
163
- * @param fn - Compute function. Bound to a subscriber-proxy of source, returns output value.
181
+ * @param compute - Compute function. Bound to a subscriber-proxy of source, returns output value.
164
182
  * Will update automatically as input values change.
165
183
  */
166
- export function from <T, R> (source: T, fn: (this: T, on: T) => R): R;
184
+ export function from <R, T> (source: T, compute: (this: T, on: T) => R): R;
167
185
 
168
186
  /**
169
187
  * Memoized value. Computes and stores a value returned by provided factory.
@@ -172,7 +190,8 @@ export function from <T, R> (source: T, fn: (this: T, on: T) => R): R;
172
190
  * @param compute - Factory for memoized value.
173
191
  * @param lazy - Wait until accessed to introduce value.
174
192
  */
175
- export function memo <T> (compute: () => T, lazy?: boolean): T;
193
+ export function memo <R> (compute: () => R, lazy?: boolean): R;
194
+ export function memo <R, T> (compute: (this: T) => R, lazy?: boolean): R;
176
195
 
177
196
  /**
178
197
  * Flag property as not to be tracked. Useful if changes often with no real-time impact.
@@ -181,22 +200,37 @@ export function memo <T> (compute: () => T, lazy?: boolean): T;
181
200
  */
182
201
  export function lazy <T> (value?: T): T;
183
202
 
203
+ /**
204
+ * Pending value. Will suspend unless value is defined,
205
+ * suspense resolves when a value is aquired.
206
+ */
207
+ export function pending <T = boolean> (): T;
208
+
184
209
  /**
185
210
  * Suspend during the execution of given function to obtain value.
186
211
  *
187
212
  * @param waitFor - Async function to suspend for.
188
213
  */
189
214
  export function pending (waitFor: () => Promise<void>): undefined;
190
- export function pending <T> (waitFor: () => Promise<T>): T;
215
+ export function pending <T> (waitFor: (this: T) => Promise<void>): undefined;
216
+ export function pending <R> (waitFor: () => Promise<R>): R;
217
+ export function pending <R, T> (waitFor: (this: T) => Promise<R>): R;
191
218
 
192
219
  /**
193
- * Suspend for a computed value; output will be generated by provided function.
194
- * Will throw a promise if value is accessed while undefined, promise will
195
- * resolve once value gains any value.
220
+ * Suspend for a computed value, returned by syncronous function.
196
221
  *
197
- * @param source - Source model from which computed value will be a subscriber.
222
+ * If accessed while computing to undefined, will throw a promise. Function is subscribed
223
+ * and will re-evaluate anytime used properties change. Once function returns any value,
224
+ * outstanding promises resolve and are not thrown on subsequent access of this property.
198
225
  *
199
- * @param fn - Compute function. Bound to a subscriber-proxy of source, returns output value.
200
- * Will update automatically as input values change.
226
+ * Similar to `from`, compute function will only run when inputs change and not upon access.
227
+ *
228
+ * This behavior is recursive. If return value _becomes_ undefined, property
229
+ * access will throw Promises again, awaiting its next value.
230
+ *
231
+ * @param source - Source object, from which computed value will be a subscriber.
232
+ *
233
+ * @param compute - Compute function returns output value. Bound to a subscriber of source.
234
+ * Will re-run automatically as input values change.
201
235
  */
202
- export function pending <T, R> (source: T, fn: (this: T, on: T) => R): Exclude<R, undefined>;
236
+ export function pending <R, T> (source: T, compute: (this: T, on: T) => R): R;
package/types/model.d.ts CHANGED
@@ -153,7 +153,8 @@ declare const CONTROL: unique symbol;
153
153
  declare const LOCAL: unique symbol;
154
154
  declare const STATE: unique symbol;
155
155
 
156
- export abstract class State {
156
+ export interface Model extends Lifecycle {}
157
+ export abstract class Model {
157
158
  /** Controller for this instance. */
158
159
  [CONTROL]: Model.Controller;
159
160
 
@@ -280,6 +281,59 @@ export abstract class State {
280
281
 
281
282
  tap <K extends Model.SelectField<this>> (key: K, expect?: boolean): ReturnType<K>;
282
283
  tap <K extends Model.SelectField<this>> (key: K, expect: true): Exclude<ReturnType<K>, undefined>;
284
+
285
+ // Keyed
286
+ on <S extends Model.SelectEvents<this>> (via: S, cb: Selector.Callback<S, this>, squash?: false, once?: boolean): Callback;
287
+ on <P extends Model.EventsCompat<this>> (key: P | P[], listener: UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
288
+ // Squash
289
+ on <S extends Model.SelectEvents<this>> (via: S, cb: (keys: Selector.From<S>[]) => void, squash: true, once?: boolean): Callback;
290
+ on <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
291
+ // Unknown
292
+ on <S extends Model.SelectEvents<this>> (via: S, cb: unknown, squash: boolean, once?: boolean): Callback;
293
+ on <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean, once?: boolean): Callback;
294
+
295
+ // Keyed
296
+ once <S extends Model.SelectEvents<this>> (via: S, cb: Selector.Callback<S, this>, squash?: false): Callback;
297
+ once <P extends Model.EventsCompat<this>> (key: P | P[], listener: UpdateCallback<this, P>, squash?: false): Callback;
298
+ // Squash
299
+ once <S extends Model.SelectEvents<this>> (via: S, cb: (keys: Selector.From<S>[]) => void, squash: true): Callback;
300
+ once <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true): Callback;
301
+ // Promise
302
+ once <S extends Model.SelectEvents<this>> (via: S): Promise<Selector.From<S>[]>;
303
+ once <P extends Model.EventsCompat<this>> (key: P | P[]): Promise<P[]>;
304
+ // Unknown
305
+ once <S extends Model.SelectEvents<this>> (via: S, cb: unknown, squash: boolean): Callback;
306
+ once <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean): Callback;
307
+
308
+ effect(callback: (this: this, state: this) => void, select?: Model.SelectFields<this>): Callback;
309
+ effect(callback: (this: this, state: this) => void, select?: (keyof this)[]): Callback;
310
+
311
+ /**
312
+ * **React Hook** - Attach to instance of this controller within a component.
313
+ *
314
+ * This method will fire lifecycle events on given controller.
315
+ *
316
+ * @param id - Argument passed to controller-lifecycle methods. Use to identify the consumer.
317
+ */
318
+ tag(id?: any): this;
319
+
320
+ /**
321
+ * **React Hook** - Subscribe to instance of controller within a component.
322
+ *
323
+ * This method will fire lifecycle events on given controller (as element)..
324
+ *
325
+ * @param idFactory - Will be invoked with fetched instance. Use this to register a tag as-needed.
326
+ */
327
+ tag(idFactory: (idFactory: this) => any): this;
328
+
329
+ /**
330
+ * **React Hook** - Subscribe to instance of controller within a component.
331
+ *
332
+ * This method will fire lifecycle events on given controller (as component).
333
+ *
334
+ * @param callback - Run once before subscription begins.
335
+ */
336
+ use(callback?: (instance: this) => void): this;
283
337
 
284
338
  /** Use symbol to access controller of a model. */
285
339
  static CONTROL: typeof CONTROL;
@@ -305,20 +359,18 @@ export abstract class State {
305
359
  * Differs from `use()` in lacking subscription and lifecycle events.
306
360
  * Much more efficient if you don't need hook-based features.
307
361
  *
308
- * @param args - Arguments passed to constructor of `this`
309
362
  * @param callback - Run after creation of instance.
310
363
  */
311
- static new <T extends Class> (this: T, args?: ConstructorParameters<T>, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
364
+ static new <T extends Class> (this: T, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
312
365
 
313
366
  /**
314
367
  * **React Hook** - Create and attach an instance of this controller a react component.
315
368
  *
316
369
  * Note: Model will be destroyed when ambient component unmounts!
317
370
  *
318
- * @param args - Arguments passed to constructor of `this`
319
371
  * @param callback - Run after creation of instance.
320
372
  */
321
- static use <T extends Class> (this: T, args?: ConstructorParameters<T>, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
373
+ static use <T extends Class> (this: T, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
322
374
 
323
375
  /**
324
376
  * **React Hook** - Similar to `use`, will instanciate a controller bound to ambient component.
@@ -387,61 +439,6 @@ export abstract class State {
387
439
  static tap <T extends Class, I extends InstanceOf<T>, K extends Model.Fields<I>> (this: T, key: K, expect: true): Exclude<I[K], undefined>;
388
440
  static tap <T extends Class, I extends InstanceOf<T>, K extends Model.SelectField<I>> (this: T, key: K, expect: true): Exclude<ReturnType<K>, undefined>;
389
441
 
390
- /**
391
- * Static equivalent of `x instanceof this`.
392
- *
393
- * Will determine if provided class is a subtype of this one.
394
- */
395
- static isTypeof <T extends Class>(this: T, subject: any): subject is T;
396
- }
397
-
398
- export interface Model extends Lifecycle {}
399
- export abstract class Model extends State {
400
- // Keyed
401
- on <S extends Model.SelectEvents<this>> (via: S, cb: Selector.Callback<S, this>, squash?: false, once?: boolean): Callback;
402
- on <P extends Model.EventsCompat<this>> (key: P | P[], listener: UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
403
- // Squash
404
- on <S extends Model.SelectEvents<this>> (via: S, cb: (keys: Selector.From<S>[]) => void, squash: true, once?: boolean): Callback;
405
- on <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
406
- // Unknown
407
- on <S extends Model.SelectEvents<this>> (via: S, cb: unknown, squash: boolean, once?: boolean): Callback;
408
- on <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean, once?: boolean): Callback;
409
-
410
- // Keyed
411
- once <S extends Model.SelectEvents<this>> (via: S, cb: Selector.Callback<S, this>, squash?: false): Callback;
412
- once <P extends Model.EventsCompat<this>> (key: P | P[], listener: UpdateCallback<this, P>, squash?: false): Callback;
413
- // Squash
414
- once <S extends Model.SelectEvents<this>> (via: S, cb: (keys: Selector.From<S>[]) => void, squash: true): Callback;
415
- once <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true): Callback;
416
- // Promise
417
- once <S extends Model.SelectEvents<this>> (via: S): Promise<Selector.From<S>[]>;
418
- once <P extends Model.EventsCompat<this>> (key: P | P[]): Promise<P[]>;
419
- // Unknown
420
- once <S extends Model.SelectEvents<this>> (via: S, cb: unknown, squash: boolean): Callback;
421
- once <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean): Callback;
422
-
423
- effect(callback: (this: this, state: this) => void, select?: Model.SelectFields<this>): Callback;
424
- effect(callback: (this: this, state: this) => void, select?: (keyof this)[]): Callback;
425
-
426
- /**
427
- * **React Hook** - Attach to instance of this controller within ambient component.
428
- *
429
- * This method will fire lifecycle events on given controller.
430
- *
431
- * @param id - Argument passed to controller-lifecycle methods. Use to identify the consumer.
432
- */
433
- tag(id?: any): this;
434
-
435
- /**
436
- * **React Hook** - Attach to instance of this controller within ambient component.
437
- *
438
- * This method will fire lifecycle events on given controller.
439
- *
440
- * @param idFactory - Will be invoked with fetched instance. Use this to register a tag as-needed.
441
- */
442
- tag(idFactory: (idFactory: this) => any): this;
443
-
444
-
445
442
  /**
446
443
  * **React Hook** - Attach to instance of this controller within ambient component.
447
444
  *
@@ -475,6 +472,13 @@ export abstract class Model extends State {
475
472
  * Documentation TBD.
476
473
  */
477
474
  static meta <T extends Class, K extends Model.SelectField<T>> (this: T, key?: K): ReturnType<K>;
475
+
476
+ /**
477
+ * Static equivalent of `x instanceof this`.
478
+ *
479
+ * Will determine if provided class is a subtype of this one.
480
+ */
481
+ static isTypeof <T extends Class>(this: T, subject: any): subject is T;
478
482
  }
479
483
 
480
484
  export class Singleton extends Model {
package/types/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type Key = string | symbol | number;
2
- export type Async = (...args: any[]) => Promise<any>;
2
+ export type Async<T = any> = (this: T, ...args: any[]) => Promise<any>;
3
3
  export type BunchOf<T> = { [key: string]: T };
4
4
 
5
5
  export type Class = new (...args: any[]) => any;
@@ -10,7 +10,7 @@ export type Callback = () => void;
10
10
  export type RequestCallback = (keys?: string[]) => void;
11
11
  export type EffectCallback<T, A = T> = (this: T, argument: A) => Callback | Promise<any> | void;
12
12
  export type UpdateCallback<T, P> = (this: T, value: IfApplicable<T, P>, changed: P) => void;
13
- export type InterceptCallback<T> = (argument: T) => ((next: T) => void) | Promise<any> | void | boolean;
13
+ export type InterceptCallback<T, S = any> = (this: S, argument: T) => ((next: T) => void) | Promise<any> | void | boolean;
14
14
 
15
15
  export type RefFunction = (e: HTMLElement | null) => void;
16
16