@expressive/mvc 1.0.0-beta.23 → 1.0.0-beta.27

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/assign.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, UPDATE } from './controller';\nimport { create, define, defineLazy, 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 handle = {} as BunchOf<Callback | true>;\n public dependant = new Set<Listener>();\n public parent: Controller;\n public notify?: RequestCallback;\n\n constructor(\n parent: Controller | Stateful,\n public onUpdate: Controller.Listen){\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 defineLazy(this.proxy, UPDATE, this.debug);\n\n for(const key in parent.state)\n this.spy(key);\n }\n\n public debug = () => {\n const update: string[] = [];\n\n this.notify = keys => {\n update.splice(0, update.length,\n ...keys.filter(k => k in this.handle) \n )\n }\n\n return update;\n }\n\n public listen = (key: string, from: Controller) => {\n const handler = this.handle[key];\n\n if(!handler)\n return;\n\n if(typeof handler == \"function\")\n handler();\n\n const notify = this.onUpdate(key, from);\n\n if(notify)\n from.waiting.add(notify);\n\n if(this.notify)\n from.waiting.add(this.notify);\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, callback?: Callback){\n this.handle[key] = callback || true;\n }\n\n public commit(){\n const onDone =\n this.parent.addListener(this.listen);\n\n this.active = true;\n\n this.dependant.forEach(x => x.commit());\n\n return this.release = () => {\n this.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 INIT = new WeakSet<Function>();\nconst INFO = new WeakMap<Function, GetterInfo>();\nconst USED = new WeakMap<Controller, Map<string, GetterInfo>>();\nconst KEYS = new WeakMap<Controller, RequestCallback[]>();\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 let register = USED.get(parent)!;\n\n if(!register){\n register = new Map<string, GetterInfo>();\n USED.set(parent, register);\n }\n\n register.set(key, info);\n\n const current = getter\n ? () => getter.call(subject, state[key], key)\n : () => state[key];\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 defer(_key: string, from: Controller){\n let pending = KEYS.get(from);\n\n if(!pending)\n KEYS.set(from, pending = []);\n\n if(info.parent !== from)\n update();\n else {\n const after = pending.findIndex(peer => (\n info.priority > INFO.get(peer)!.priority\n ));\n\n pending.splice(after + 1, 0, update);\n }\n }\n\n function create(early?: boolean){\n sub = new Subscriber(source(), defer);\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.handle){\n const peer = register.get(key);\n \n if(peer && peer.priority >= info.priority)\n info.priority = peer.priority + 1;\n }\n }\n\n return current();\n }\n\n setAlias(update, `try ${key}`);\n setAlias(create, `new ${key}`);\n setAlias(setter, `run ${key}`);\n\n INIT.add(create);\n INFO.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\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(INIT.has(getter!))\n (getter as Initial)(true);\n }\n}\n\nexport function flush(on: Controller){\n const handled = on.frame;\n const pending = KEYS.get(on);\n\n if(!pending)\n return;\n\n while(pending.length){\n const why = [ ...handled ];\n const compute = pending.shift()!;\n const { key } = INFO.get(compute)!;\n\n if(!handled.has(key))\n compute(why);\n }\n\n KEYS.delete(on);\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 UPDATE = Symbol(\"update\");\nexport const LOCAL = Symbol(\"local\");\nexport const STATE = Symbol(\"state\");\n\nexport interface Stateful {\n [CONTROL]: Controller;\n [UPDATE]?: readonly string[];\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\n\nexport type Instruction<T> = (this: Controller, key: string, thisArg: Controller) =>\n void | Getter<T> | PropertyDescriptor;\n\nexport namespace Controller {\n export type Listen = (key: string, source: Controller) =>\n RequestCallback | void;\n}\n\nexport class Controller {\n public state = {} as BunchOf<any>;\n public frame = new Set<string>();\n public waiting = new Set<RequestCallback>();\n\n protected followers = new Set<Controller.Listen>();\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(listener: Controller.Listen){\n this.followers.add(listener);\n return () => {\n this.followers.delete(listener)\n }\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.followers){\n const notify = subscription(key, this);\n\n if(notify)\n this.waiting.add(notify);\n }\n }\n\n public emit(){\n Computed.flush(this);\n\n const keys = Object.freeze([ ...this.frame ]);\n const handle = new Set(this.waiting);\n\n this.waiting.clear();\n this.frame.clear();\n\n defineProperty(this.subject, UPDATE, {\n configurable: true,\n value: keys\n })\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 | string[] | Set<string> | Query){\n\n if(typeof using == \"string\")\n return [ using ];\n\n if(typeof using == \"object\"){\n using = Array.from(using);\n \n if(using.length === 0)\n using = undefined;\n else\n return using;\n }\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 source: ChildInstruction<T>,\n name?: string){\n\n return apply(\n function child(this: Controller, key: string){\n const context = new WeakMap<Subscriber, any>();\n const current = source.call(this, key);\n \n function subscribe(sub: Subscriber){\n let child: Subscriber | undefined;\n \n function start(){\n const instance = current();\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 context.set(sub, child.proxy);\n }\n }\n\n function restart(){\n if(child){\n child.release();\n sub.dependant.delete(child);\n context.set(sub, undefined);\n child = undefined;\n }\n \n start();\n }\n \n start();\n sub.follow(key, restart);\n }\n \n return (local: Subscriber | undefined) => {\n if(!local)\n return current();\n \n if(!context.has(local))\n subscribe(local);\n \n return context.get(local);\n }\n },\n name || source.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 (key: string) => {\n if(key == Lifecycle.WILL_UNMOUNT)\n return () => {\n instance.destroy();\n release();\n }\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, UPDATE } 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 static WHY = UPDATE;\n\n static [CONTROL]: Controller;\n static [UPDATE]: readonly string[];\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.waiting.add(() => {\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 | string[] | Set<string> | Query,\n handler: Function,\n squash?: boolean,\n once?: boolean){\n\n const control = manage(this);\n const request = keys(control, subset);\n\n const callback: RequestCallback = squash\n ? handler.bind(this)\n : frame => frame\n .filter(k => request.includes(k))\n .forEach(k => handler.call(this, control.state[k], k))\n\n const trigger: RequestCallback = once\n ? frame => { remove(); callback(frame) }\n : callback;\n\n Computed.ensure(control, request);\n\n const remove = control.addListener(key => {\n if(request.includes(key))\n return trigger;\n });\n\n return remove;\n }\n\n once(\n select: string | string[] | Set<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?: Set<string> | 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?: Set<string> | 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<readonly string[]>;\n update(key: string | Select, tag?: any): PromiseLike<readonly 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<readonly string[] | false>> {\n then(callback){\n if(callback)\n if(control.pending)\n control.waiting.add(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.add(() => {\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 IsReadOnly: (owner, key) =>\n `${owner}.${key} is set to read-only, but tried to reassign assign.`,\n\n MustBeDefined: (owner, key) =>\n `${owner}.${key} must have initial value, as a read-only property.`\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) => boolean) | boolean){\n\n return child(\n function use(key){\n const { subject } = this;\n\n // `true` => readonly\n // `false` => writable, may be undefined\n // `undefined` => writable (default)\n let mode = argument;\n let current: Model | undefined;\n \n const onUpdate = (\n next: Model | {} | undefined,\n initial?: boolean) => {\n\n if(mode === true && !initial)\n throw Oops.IsReadOnly(subject, key);\n\n if(next){\n current = next instanceof Model\n ? next : bootstrap(next);\n\n Parent.set(current, subject);\n manage(current);\n }\n else if(mode === undefined)\n throw Oops.UndefinedNotAllowed(key);\n else\n current = undefined;\n \n if(typeof argument == \"function\")\n return argument(current);\n }\n \n if(input){\n current =\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(current)\n mode = onUpdate(current, true) || mode;\n else if(mode == true)\n throw Oops.MustBeDefined(subject, key);\n }\n else\n mode = false;\n \n this.manage(key, current, onUpdate);\n \n return () => current;\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 { apply } from './controller';\nimport { createValueEffect, define, defineLazy, defineProperty } from './util';\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}","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, 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 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(forKey => {\n if(forKey == key)\n return () => {\n if(via.state[key] !== 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.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;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AI,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAErC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE3B,OAAO,QAAyB,CAAC;KAClC;IAED,OAAO,MAAM,CACF,OAA+B;QAExC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC/C,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;KAC1B;IAED,OAAO,EAAE;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACxB;IAED,OAAO,IAAI,CAA2B,MAAgB;QACpD,MAAM,QAAQ,GAAI,IAAY,CAAC,OAAwB,CAAC;QAExD,IAAG,CAAC,QAAQ,IAAI,MAAM;YACpB,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC;KACjB;IAED,OAAO,KAAK;QACV,IAAG,IAAI,CAAC,OAAO;YACb,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;KAC1B;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAkB,CAAC,CAAC;KACxC;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@expressive/mvc",
3
- "version": "1.0.0-beta.23",
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",
@@ -26,14 +26,16 @@
26
26
  "build": "rollup --config",
27
27
  "watch": "jest --watchAll",
28
28
  "test": "jest --collectCoverage",
29
- "prebuild": "rm -rf lib/"
29
+ "prebuild": "rm -rf lib/",
30
+ "preversion": "npm run test && npm run build",
31
+ "publish:beta": "npm version prerelease --preid=beta",
32
+ "postversion": "npm publish"
30
33
  },
31
34
  "peerDependencies": {
32
35
  "react": ">=17.0.2"
33
36
  },
34
37
  "devDependencies": {
35
- "@rollup/plugin-commonjs": "^19.0.0",
36
- "@rollup/plugin-typescript": "^8.2.1",
38
+ "@rollup/plugin-commonjs": "^21.0.1",
37
39
  "@testing-library/react-hooks": "^7.0.0",
38
40
  "@types/jest": "^26.0.23",
39
41
  "@types/node": "^15.12.4",
@@ -41,19 +43,11 @@
41
43
  "jest": "^27.0.4",
42
44
  "react": ">=17.0.2",
43
45
  "react-test-renderer": "^17.0.2",
44
- "rollup": "^2.52.2",
45
- "rollup-plugin-typescript2": "^0.30.0",
46
- "semantic-release": "^18.0.1",
46
+ "rollup": "^2.61.1",
47
+ "rollup-plugin-typescript2": "^0.31.1",
47
48
  "ts-jest": "^27.0.3",
48
49
  "tslib": "^2.3.0",
49
50
  "typescript": "typescript@>=3.8 <5.0"
50
51
  },
51
- "release": {
52
- "branches": [
53
- {
54
- "name": "beta",
55
- "prerelease": true
56
- }
57
- ]
58
- }
52
+ "version": "1.0.0-beta.27"
59
53
  }
@@ -8,47 +8,64 @@ import { Async, Class, InstanceOf, InterceptCallback } from './types';
8
8
  export function apply <T = any> (instruction: Model.Instruction<T>, name?: string): T;
9
9
 
10
10
  /**
11
- * Creates a new child-instance of specified controller.
12
- *
13
- * @param Peer - Type of Model to create and apply to host property.
14
- * @param callback - Fired after controller is created and ready for use.
11
+ * Create a placeholder for specified Model type.
15
12
  */
16
- export function use <T extends Class> (Peer: T, callback: (i?: InstanceOf<T>) => void): InstanceOf<T> | undefined;
13
+ export function use <T extends Model> (): T | undefined;
17
14
 
18
15
  /**
19
- * Creates a new child-instance of specified controller.
20
- *
21
- * @param Peer - Type of Model to create and apply to host property.
22
- * @param required - Property should be non-nullable, will throw if value is set to undefined.
16
+ * Create a new child instance of model.
23
17
  */
24
- export function use <T extends Class> (Peer: T, required: false): InstanceOf<T> | undefined;
25
- export function use <T extends Class> (Peer: T, required?: true): InstanceOf<T>;
18
+ export function use <T extends Class> (Type: T): InstanceOf<T>;
26
19
 
27
20
  /**
28
- * Creates a new child-instance of specified controller.
29
- *
30
- * @param factory - Generate model for use.
31
- * @param callback - Fired after controller is created and ready for use.
21
+ * Create a new child-instance of specified controller, in readonly mode.
22
+ * Will prevent assignment of new value.
23
+ *
24
+ * **Note:** This is only enforced at runtime. Use
25
+ * [`readonly`](https://www.typescriptlang.org/docs/handbook/2/classes.html#readonly), if writing in typescript.
26
+ */
27
+ export function use <T extends Class> (Type: T, readonly: true): InstanceOf<T>;
28
+ export function use <T extends Model> (from: () => T, readonly: true): T;
29
+
30
+ /**
31
+ * Create a new child-instance of specified controller, in optional mode.
32
+ * Will allow assignment of undefined, and likewise should be checked before usage.
33
+ */
34
+ export function use <T extends Class> (Type: T, required: false): InstanceOf<T> | undefined;
35
+ export function use <T extends Model> (from: () => T | undefined, required: false): T | undefined;
36
+
37
+ /**
38
+ * Create a new child-instance of specified controller.
39
+ *
40
+ * By default, property is non-nullable. If callback returns `true` the first time, will be in readonly mode.
41
+ * If callback returns false, property may also be set to undefined, as needed.
42
+ */
43
+ export function use <T extends Class> (Type: T, callback: (i: InstanceOf<T>) => true): InstanceOf<T>;
44
+ export function use <T extends Class> (Type: T, callback: (i: InstanceOf<T>) => false): InstanceOf<T> | undefined;
45
+ export function use <T extends Class> (Type: T, callback: (i: InstanceOf<T>) => void): InstanceOf<T>;
46
+
47
+ /**
48
+ * Create a new child-instance from factory function.
32
49
  */
33
- export function use <T extends Model | undefined> (factory: () => T, callback?: (i: T) => void): T;
50
+ export function use <T extends Model> (from: () => T): T;
51
+ export function use <T extends Model> (from: () => T, callback: (i: T) => true): T;
52
+ export function use <T extends Model> (from: () => T | undefined, callback: (i: T) => false): T | undefined;
53
+ export function use <T extends Model> (from: () => T, callback: (i: T) => void): T;
34
54
 
35
55
  /**
36
- * Create a child-instance relationship with provided model.
56
+ * Createa child-instance relationship with provided model.
37
57
  *
38
58
  * Note: If `peer` is not already initialized before parent is
39
59
  * (created with `new` as opposed to create method), that model will
40
- * attach this via `parent()` instruction. It will not howerver, if
60
+ * attach this via `parent()` instruction. It will not, if
41
61
  * already active.
42
- *
43
- * @param factory - Instance of model to attach.
44
- * @param callback - Fired after controller is attached.
45
62
  */
46
- export function use <T extends Model> (peer: T, callback?: (i: T) => void): T;
47
-
48
- /**
49
- * Create a placeholder for specified Model type.
50
- */
51
- export function use <T extends Model> (): T | undefined;
63
+ export function use <T extends Model> (peer: T): T;
64
+ export function use <T extends Model> (peer: T, readonly: true): T;
65
+ export function use <T extends Model> (peer: T, required: false): T | undefined;
66
+ export function use <T extends Model> (peer: T, callback: (i: T) => true): T;
67
+ export function use <T extends Model> (peer: T, callback: (i: T) => false): T | undefined;
68
+ export function use <T extends Model> (peer: T, callback: (i: T) => void): T;
52
69
 
53
70
  /**
54
71
  * Generate a child controller from specified object. Object's values are be trackable, as would be for a full-model.
@@ -113,8 +130,10 @@ export function tap <T extends Class> (Type: T, required?: boolean): InstanceOf<
113
130
  * @param initialValue - Beginning value of host property.
114
131
  * @param onUpdate - Effect-callback fired upon set of host property.
115
132
  */
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;
133
+ export function on <T> (initialValue: undefined, onUpdate: InterceptCallback<T>): T | undefined;
134
+ export function on <T> (initialValue: T, onUpdate: InterceptCallback<T>): T;
135
+ export function on <T, S> (initialValue: undefined, onUpdate: InterceptCallback<T, S>): T | undefined;
136
+ export function on <T, S> (initialValue: T, onUpdate: InterceptCallback<T, S>): T;
118
137
 
119
138
  /** Object with references to all managed values of `T`. */
120
139
  export type Refs <T extends Model> = { [P in Model.Fields<T>]: Model.Ref<T[P]> };
@@ -138,6 +157,7 @@ export function ref <T extends Model> (target: T): Refs<T>;
138
157
  * @param callback - Optional callback to synchronously fire when reference is first set or does update.
139
158
  */
140
159
  export function ref <T = HTMLElement> (callback?: InterceptCallback<T>): Model.Ref<T>;
160
+ export function ref <T, S> (callback?: InterceptCallback<T, S>): Model.Ref<T>;
141
161
 
142
162
  /**
143
163
  * Sets an exotic method with managed ready-state. Property accepts an async function.
@@ -149,14 +169,16 @@ export function ref <T = HTMLElement> (callback?: InterceptCallback<T>): Model.R
149
169
  *
150
170
  * @param action - Action to fire when resulting property is invoked.
151
171
  */
152
- export function act <T extends Async> (action: T): T & { active: boolean };
172
+ export function act (action: Async): typeof action & { active: boolean };
173
+ export function act <S> (action: Async<S>): typeof action & { active: boolean };
153
174
 
154
175
  /**
155
176
  * Implement a computed value; output is returned by function from provided factory.
156
177
  *
157
178
  * @param compute - Factory function to generate a getter to subscribe dependancies.
158
179
  */
159
- export function from <R> (compute: (property: string) => (this: any, state: any) => R): R;
180
+ export function from <R> (compute: (property: string) => <T>(this: T, state: T) => R): R;
181
+ export function from <R, T> (compute: (property: string) => (this: T, state: T) => R): R;
160
182
 
161
183
  /**
162
184
  * Implement a computed value; output will be generated by provided function.
@@ -176,7 +198,7 @@ export function from <T extends Class, R> (source: T, compute: (this: InstanceOf
176
198
  * @param compute - Compute function. Bound to a subscriber-proxy of source, returns output value.
177
199
  * Will update automatically as input values change.
178
200
  */
179
- export function from <T, R> (source: T, compute: (this: T, on: T) => R): R;
201
+ export function from <R, T> (source: T, compute: (this: T, on: T) => R): R;
180
202
 
181
203
  /**
182
204
  * Memoized value. Computes and stores a value returned by provided factory.
@@ -185,7 +207,8 @@ export function from <T, R> (source: T, compute: (this: T, on: T) => R): R;
185
207
  * @param compute - Factory for memoized value.
186
208
  * @param lazy - Wait until accessed to introduce value.
187
209
  */
188
- export function memo <T> (compute: () => T, lazy?: boolean): T;
210
+ export function memo <R> (compute: () => R, lazy?: boolean): R;
211
+ export function memo <R, T> (compute: (this: T) => R, lazy?: boolean): R;
189
212
 
190
213
  /**
191
214
  * Flag property as not to be tracked. Useful if changes often with no real-time impact.
@@ -198,7 +221,7 @@ export function lazy <T> (value?: T): T;
198
221
  * Pending value. Will suspend unless value is defined,
199
222
  * suspense resolves when a value is aquired.
200
223
  */
201
- export function pending <T = boolean> (): Exclude<T, undefined>;
224
+ export function pending <T = boolean> (): T;
202
225
 
203
226
  /**
204
227
  * Suspend during the execution of given function to obtain value.
@@ -206,7 +229,9 @@ export function pending <T = boolean> (): Exclude<T, undefined>;
206
229
  * @param waitFor - Async function to suspend for.
207
230
  */
208
231
  export function pending (waitFor: () => Promise<void>): undefined;
209
- export function pending <T> (waitFor: () => Promise<T>): T;
232
+ export function pending <T> (waitFor: (this: T) => Promise<void>): undefined;
233
+ export function pending <R> (waitFor: () => Promise<R>): R;
234
+ export function pending <R, T> (waitFor: (this: T) => Promise<R>): R;
210
235
 
211
236
  /**
212
237
  * Suspend for a computed value, returned by syncronous function.
@@ -225,4 +250,4 @@ export function pending <T> (waitFor: () => Promise<T>): T;
225
250
  * @param compute - Compute function returns output value. Bound to a subscriber of source.
226
251
  * Will re-run automatically as input values change.
227
252
  */
228
- export function pending <T, R> (source: T, compute: (this: T, on: T) => R): Exclude<R, undefined>;
253
+ export function pending <R, T> (source: T, compute: (this: T, on: T) => R): R;
package/types/model.d.ts CHANGED
@@ -113,9 +113,15 @@ export namespace Model {
113
113
 
114
114
  type HandleValue = (value: any) => boolean | void;
115
115
 
116
+ export namespace Controller {
117
+ export type Listen = (key: string, source: Controller) =>
118
+ RequestCallback | undefined;
119
+ }
120
+
116
121
  export class Controller {
117
122
  state: BunchOf<any>;
118
123
  subject: {};
124
+ waiting: Set<RequestCallback>;
119
125
 
120
126
  /** Add property to managed state. */
121
127
  manage(key: string, initial: any, effect?: HandleValue): void;
@@ -124,11 +130,9 @@ export namespace Model {
124
130
 
125
131
  setter(key: string, effect?: HandleValue): (value: any) => boolean | void;
126
132
 
127
- addListener(batch: BunchOf<RequestCallback>): Callback;
133
+ addListener(listener: Controller.Listen): Callback;
128
134
 
129
135
  update(key: string, value?: any): void;
130
-
131
- include(cb: RequestCallback): void;
132
136
  }
133
137
 
134
138
  export class Subscriber {
@@ -136,13 +140,13 @@ export namespace Model {
136
140
  source: any;
137
141
  parent: Controller;
138
142
  active: boolean;
139
- follows: BunchOf<Callback>;
143
+ listen: Controller.Listen;
140
144
  dependant: Set<{
141
145
  commit(): void;
142
146
  release(): void;
143
147
  }>;
144
148
 
145
- follow(key: string, cb?: Callback | undefined): void;
149
+ follow(key: string, cb?: RequestCallback | undefined): void;
146
150
  commit(): Callback;
147
151
  release(): Callback;
148
152
  onUpdate(): void;
@@ -150,6 +154,7 @@ export namespace Model {
150
154
  }
151
155
 
152
156
  declare const CONTROL: unique symbol;
157
+ declare const UPDATE: unique symbol;
153
158
  declare const LOCAL: unique symbol;
154
159
  declare const STATE: unique symbol;
155
160
 
@@ -164,6 +169,14 @@ export abstract class Model {
164
169
  /** Current subscriber (if present) while used in a live context (e.g. hook or effect). */
165
170
  [LOCAL]?: Model.Subscriber;
166
171
 
172
+ /**
173
+ * Last update causing a refresh to subscribers.
174
+ *
175
+ * If accessed directly, will contain all keys from last push.
176
+ * If within a subscribed function, will contain only keys which explicitly caused a refresh.
177
+ **/
178
+ [UPDATE]?: readonly string[];
179
+
167
180
  /**
168
181
  * Circular reference to `this` controller.
169
182
  *
@@ -229,19 +242,19 @@ export abstract class Model {
229
242
  export <P extends Model.Fields<this>> (select: P[]): Model.State<this, P>;
230
243
  export <S extends Model.SelectFields<this>> (select: S): Model.State<this, Selector.From<S>>;
231
244
 
232
- update(): PromiseLike<string[] | false>;
233
- update(strict: true): Promise<string[]>;
245
+ update(): PromiseLike<readonly string[] | false>;
246
+ update(strict: true): Promise<readonly string[]>;
234
247
  update(strict: false): Promise<false>;
235
- update(strict: boolean): Promise<string[] | false>;
248
+ update(strict: boolean): Promise<readonly string[] | false>;
236
249
 
237
- update(keys: Model.Fields<this>): Thenable<string[]>;
238
- update(keys: Model.SelectFieldKey<this>): Thenable<string[]>;
250
+ update(keys: Model.Fields<this>): Thenable<readonly string[]>;
251
+ update(keys: Model.SelectFieldKey<this>): Thenable<readonly string[]>;
239
252
 
240
- update(keys: Model.Fields<this>, callMethod: boolean): PromiseLike<string[]>;
241
- update(keys: Model.SelectFields<this>, callMethod: boolean): PromiseLike<string[]>;
253
+ update(keys: Model.Fields<this>, callMethod: boolean): PromiseLike<readonly string[]>;
254
+ update(keys: Model.SelectFields<this>, callMethod: boolean): PromiseLike<readonly string[]>;
242
255
 
243
- update<T>(keys: Model.Fields<this>, argument: T): PromiseLike<string[]>;
244
- update<T>(keys: Model.SelectFields<this>, argument: T): PromiseLike<string[]>;
256
+ update<T>(keys: Model.Fields<this>, argument: T): PromiseLike<readonly string[]>;
257
+ update<T>(keys: Model.SelectFields<this>, argument: T): PromiseLike<readonly string[]>;
245
258
 
246
259
  /*
247
260
  Issue with self-reference, using fallback.
@@ -284,32 +297,40 @@ export abstract class Model {
284
297
 
285
298
  // Keyed
286
299
  on <S extends Model.SelectEvents<this>> (via: S, cb: Selector.Callback<S, this>, squash?: false, once?: boolean): Callback;
300
+ on <P = Model.EventsCompat<this>> (keys: [], listener: UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
287
301
  on <P extends Model.EventsCompat<this>> (key: P | P[], listener: UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
288
302
  // Squash
289
303
  on <S extends Model.SelectEvents<this>> (via: S, cb: (keys: Selector.From<S>[]) => void, squash: true, once?: boolean): Callback;
304
+ on <P = Model.EventsCompat<this>> (keys: [], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
290
305
  on <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
291
306
  // Unknown
292
307
  on <S extends Model.SelectEvents<this>> (via: S, cb: unknown, squash: boolean, once?: boolean): Callback;
308
+ on (keys: [], listener: unknown, squash: boolean, once?: boolean): Callback;
293
309
  on <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean, once?: boolean): Callback;
294
310
 
295
311
  // Keyed
296
312
  once <S extends Model.SelectEvents<this>> (via: S, cb: Selector.Callback<S, this>, squash?: false): Callback;
313
+ once <P = Model.EventsCompat<this>> (keys: [], listener: UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
297
314
  once <P extends Model.EventsCompat<this>> (key: P | P[], listener: UpdateCallback<this, P>, squash?: false): Callback;
298
315
  // Squash
299
316
  once <S extends Model.SelectEvents<this>> (via: S, cb: (keys: Selector.From<S>[]) => void, squash: true): Callback;
317
+ once <P = Model.EventsCompat<this>> (keys: [], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
300
318
  once <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true): Callback;
301
319
  // Promise
302
320
  once <S extends Model.SelectEvents<this>> (via: S): Promise<Selector.From<S>[]>;
321
+ once <P = Model.EventsCompat<this>> (keys: [], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
303
322
  once <P extends Model.EventsCompat<this>> (key: P | P[]): Promise<P[]>;
304
323
  // Unknown
305
324
  once <S extends Model.SelectEvents<this>> (via: S, cb: unknown, squash: boolean): Callback;
325
+ once (keys: [], listener: unknown, squash: boolean, once?: boolean): Callback;
306
326
  once <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean): Callback;
307
327
 
308
328
  effect(callback: (this: this, state: this) => void, select?: Model.SelectFields<this>): Callback;
329
+ effect(callback: (this: this, state: this) => void, select?: []): Callback;
309
330
  effect(callback: (this: this, state: this) => void, select?: (keyof this)[]): Callback;
310
331
 
311
332
  /**
312
- * **React Hook** - Attach to instance of this controller within ambient component.
333
+ * **React Hook** - Attach to instance of this controller within a component.
313
334
  *
314
335
  * This method will fire lifecycle events on given controller.
315
336
  *
@@ -318,14 +339,23 @@ export abstract class Model {
318
339
  tag(id?: any): this;
319
340
 
320
341
  /**
321
- * **React Hook** - Attach to instance of this controller within ambient component.
342
+ * **React Hook** - Subscribe to instance of controller within a component.
322
343
  *
323
- * This method will fire lifecycle events on given controller.
344
+ * This method will fire lifecycle events on given controller (as element)..
324
345
  *
325
346
  * @param idFactory - Will be invoked with fetched instance. Use this to register a tag as-needed.
326
347
  */
327
348
  tag(idFactory: (idFactory: this) => any): this;
328
349
 
350
+ /**
351
+ * **React Hook** - Subscribe to instance of controller within a component.
352
+ *
353
+ * This method will fire lifecycle events on given controller (as component).
354
+ *
355
+ * @param callback - Run once before subscription begins.
356
+ */
357
+ use(callback?: (instance: this) => void): this;
358
+
329
359
  /** Use symbol to access controller of a model. */
330
360
  static CONTROL: typeof CONTROL;
331
361
 
@@ -335,6 +365,9 @@ export abstract class Model {
335
365
  /** Use symbol to access current subscriber of a model in a live context (e.g. hook or effect). */
336
366
  static LOCAL: typeof LOCAL;
337
367
 
368
+ /** Use symbol to access keys affected by last update. */
369
+ static WHY: typeof UPDATE;
370
+
338
371
  /**
339
372
  * Creates a new instance of this controller.
340
373
  *
@@ -350,20 +383,18 @@ export abstract class Model {
350
383
  * Differs from `use()` in lacking subscription and lifecycle events.
351
384
  * Much more efficient if you don't need hook-based features.
352
385
  *
353
- * @param args - Arguments passed to constructor of `this`
354
386
  * @param callback - Run after creation of instance.
355
387
  */
356
- static new <T extends Class> (this: T, args?: ConstructorParameters<T>, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
388
+ static new <T extends Class> (this: T, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
357
389
 
358
390
  /**
359
391
  * **React Hook** - Create and attach an instance of this controller a react component.
360
392
  *
361
393
  * Note: Model will be destroyed when ambient component unmounts!
362
394
  *
363
- * @param args - Arguments passed to constructor of `this`
364
395
  * @param callback - Run after creation of instance.
365
396
  */
366
- static use <T extends Class> (this: T, args?: ConstructorParameters<T>, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
397
+ static use <T extends Class> (this: T, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
367
398
 
368
399
  /**
369
400
  * **React Hook** - Similar to `use`, will instanciate a controller bound to ambient component.