uneventful 0.0.4 → 0.0.5

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.
package/dist/mod.d.ts CHANGED
@@ -251,7 +251,7 @@ declare function backpressure(inlet?: Inlet): Backpressure;
251
251
  interface Inlet {
252
252
  /** Is the main connection open? (i.e. is the creating job not closed yet?) */
253
253
  isOpen(): boolean;
254
- /** Is the conduit currently ready to receive data? */
254
+ /** Is the connection ready to receive data? */
255
255
  isReady(): boolean;
256
256
  /**
257
257
  * Register a callback to produce more data when the inlet is resumed
@@ -1393,7 +1393,7 @@ declare function runRules(scheduleFn?: (cb: () => unknown) => unknown): void;
1393
1393
  * Error indicating a rule has attempted to write a value it indirectly
1394
1394
  * depends on, or which has already been read by another rule in the current
1395
1395
  * batch. (Also thrown when a cached function attempts to write a value at all,
1396
- * directly or inidirectly.)
1396
+ * directly or indirectly.)
1397
1397
  *
1398
1398
  * @category Errors
1399
1399
  */
@@ -1720,7 +1720,7 @@ declare function fromDomEvent<T extends Event>(target: EventTarget, type: string
1720
1720
  * Convert an iterable to a synchronous event source
1721
1721
  *
1722
1722
  * Each time the resulting source is subscribed to, it will emit an event for
1723
- * each item in the iterator, then close the conduit. Pause/resume is
1723
+ * each item in the iterator, then close the connection. Pause/resume is
1724
1724
  * supported.
1725
1725
  *
1726
1726
  * @category Stream Producers
@@ -1730,10 +1730,10 @@ declare function fromIterable<T>(iterable: Iterable<T>): Source<T>;
1730
1730
  * Convert a Promise to an event source
1731
1731
  *
1732
1732
  * Each time the resulting source is subscribed to, it will emit an event for
1733
- * the result of the promise, then close the conduit. (Unless the promise is
1734
- * rejected, in which case the conduit throws and closes each time the source is
1735
- * subscribed.) Non-native promises and non-promise values are converted using
1736
- * Promise.resolve().
1733
+ * the result of the promise, then close the connection. (Unless the promise is
1734
+ * rejected, in which case the connection throws and closes each time the source
1735
+ * is subscribed.) Non-native promises and non-promise values are converted
1736
+ * using Promise.resolve().
1737
1737
  *
1738
1738
  * @category Stream Producers
1739
1739
  */
package/dist/mod.mjs CHANGED
@@ -636,7 +636,7 @@ class _Throttle {
636
636
  isOpen() {
637
637
  return !this._job?.result();
638
638
  }
639
- /** Is the conduit currently ready to receive data? */
639
+ /** Is the connection ready to receive data? */
640
640
  isReady() {
641
641
  return this.isOpen() && this._isReady;
642
642
  }
@@ -1008,6 +1008,7 @@ class Cell {
1008
1008
  sub.pT.nT = sub.nT;
1009
1009
  if (this.subscribers === sub)
1010
1010
  this.subscribers = sub.nT;
1011
+ sub.nT = sub.pT = void 0;
1011
1012
  if (!this.subscribers) {
1012
1013
  if (this.flags & 4 /* Calc */) {
1013
1014
  for (let s = this.sources; s; s = s.nS)
@@ -1160,11 +1161,11 @@ class SignalImpl extends CallableObject {
1160
1161
  res = this();
1161
1162
  } catch (e) {
1162
1163
  stop();
1163
- reject(r, e);
1164
+ defer(reject.bind(null, r, e));
1164
1165
  }
1165
1166
  if (seen) {
1166
1167
  stop();
1167
- resolve(r, res);
1168
+ defer(resolve.bind(null, r, res));
1168
1169
  }
1169
1170
  seen = true;
1170
1171
  });
@@ -1186,11 +1187,11 @@ class SignalImpl extends CallableObject {
1186
1187
  res = this();
1187
1188
  } catch (e) {
1188
1189
  stop();
1189
- reject(r, e);
1190
+ defer(reject.bind(null, r, e));
1190
1191
  }
1191
1192
  if (res) {
1192
1193
  stop();
1193
- resolve(r, res);
1194
+ defer(resolve.bind(null, r, res));
1194
1195
  }
1195
1196
  });
1196
1197
  };
package/dist/mod.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.mjs","sources":["../src/defer.ts","../src/results.ts","../src/ambient.ts","../src/internals.ts","../src/chains.ts","../src/tracking.ts","../src/async.ts","../src/scheduling.ts","../src/streams.ts","../src/utils.ts","../src/cells.ts","../src/rules.ts","../src/signals.ts","../src/jobutils.ts","../src/sources.ts","../src/sinks.ts","../src/operators.ts"],"sourcesContent":["/**\n * Invoke a no-argument function as a microtask, using queueMicrotask or Promise.resolve().then()\n *\n * @category Scheduling\n */\nexport let defer: (cb: () => any) => void =\n typeof queueMicrotask === \"function\" ?\n queueMicrotask :\n (p => (cb: () => any) => p.then(cb))(Promise.resolve());\n\n/**\n * @internal For testing use only!\n *\n */\nexport function setDefer(fn: typeof defer) {\n defer = fn;\n}","import { Job, Request } from \"./types.ts\";\n\n/**\n * Resolve a {@link Request} with a value.\n *\n * (For a curried version, see {@link resolver}.)\n *\n * @category Requests and Results\n */\nexport function resolve<T>(request: Request<T>, val: T) { request(\"next\", val); }\n\n/**\n * Reject a {@link Request} with a reason.\n *\n * (For a curried version, see {@link rejecter}.)\n *\n * @category Requests and Results\n */\nexport function reject(request: Request<any>, reason: any) { request(\"throw\", undefined, reason); }\n\n/**\n * Create a callback that will resolve the given {@link Request} with a value.\n *\n * @category Requests and Results\n */\nexport function resolver<T>(request: Request<T>): (val: T) => void { return request.bind(null, \"next\"); }\n\n/**\n * Create a callback that will reject the given {@link Request} with a reason.\n *\n * @category Requests and Results\n */\nexport function rejecter(request: Request<any>): (err: any) => void { return request.bind(null, \"throw\", undefined); }\n\n\n/**\n * A function that does nothing and returns void.\n *\n * @category Stream Consumers\n */\nexport function noop() {}\n\n/**\n * A {@link JobResult} that indicates the job was ended via a return() value.\n *\n * @category Types and Interfaces\n */\nexport type ValueResult<T> = {op: \"next\", val: T, err: undefined};\n\n/**\n * A {@link JobResult} that indicates the job was ended via a throw() or other\n * error.\n *\n * @category Types and Interfaces\n */\nexport type ErrorResult = UnhandledError | HandledError;\n\n/**\n * An {@link ErrorResult} that hasn't yet been \"handled\" (by being passed to an\n * error-specific handler, converted to a promise, given to {@link markHandled},\n * etc.)\n *\n * @category Types and Interfaces\n */\nexport type UnhandledError = {op: \"throw\", val: undefined, err: any};\n\n/**\n * An {@link ErrorResult} that has been marked \"handled\" (by being passed to an\n * error-specific handler, converted to a promise, given to {@link markHandled},\n * etc.)\n *\n * @category Types and Interfaces\n */\nexport type HandledError = {op: \"throw\", val: null, err: any};\n\n/**\n * A {@link JobResult} that indicates the job was canceled by its creator (via\n * end() or restart()).\n *\n * @category Types and Interfaces\n */\nexport type CancelResult = {op: \"cancel\", val: undefined, err: undefined};\n\n/**\n * A result passed to a job's cleanup callbacks, or supplied by its\n * .{@link Job.result result}() method.\n *\n * You can inspect a JobResult using functions like {@link isCancel}(),\n * {@link isError}(), and {@link isValue}(). {@link getResult}() can be used to\n * unwrap the value or throw the error.\n *\n * @category Types and Interfaces\n */\nexport type JobResult<T> = ValueResult<T> | ErrorResult | CancelResult ;\n\nfunction mkResult<T>(op: \"next\", val?: T): ValueResult<T>;\nfunction mkResult(op: \"throw\", val: undefined|null, err: any): ErrorResult;\nfunction mkResult(op: \"cancel\"): CancelResult;\nfunction mkResult<T>(op: string, val?: T, err?: any): JobResult<T> {\n return {op, val, err} as JobResult<T>\n}\n\n/**\n * The {@link JobResult} used to indicate a canceled job.\n *\n * @category Requests and Results\n */\nexport const CancelResult = Object.freeze(mkResult(\"cancel\"));\n\n/**\n * Create a {@link ValueResult} from a value\n *\n * @category Requests and Results\n */\nexport function ValueResult<T>(val: T): ValueResult<T> { return mkResult(\"next\", val); }\n\n/**\n * Create an {@link ErrorResult} from an error\n *\n * @category Requests and Results\n */\nexport function ErrorResult(err: any): UnhandledError { return mkResult(\"throw\", undefined, err); }\n\n/**\n * Returns true if the given result is a {@link CancelResult}.\n *\n * @category Requests and Results\n */\nexport function isCancel(res: JobResult<any> | undefined): res is CancelResult {\n return res === CancelResult;\n}\n\n/**\n * Returns true if the given result is a {@link ValueResult}.\n *\n * @category Requests and Results\n */\nexport function isValue<T>(res: JobResult<T> | undefined): res is ValueResult<T> {\n return res ? res.op === \"next\" : false;\n}\n\n/**\n * Returns true if the given result is a {@link ErrorResult}.\n *\n * @category Requests and Results\n */\nexport function isError(res: JobResult<any> | undefined): res is ErrorResult {\n return res ? res.op === \"throw\" : false;\n}\n\n/**\n * Returns true if the given result is an {@link UnhandledError}.\n *\n * @category Requests and Results\n */\nexport function isUnhandled(res: JobResult<any> | undefined): res is UnhandledError {\n return isError(res) && res.val === undefined;\n}\n\n/**\n * Returns true if the given result is a {@link HandledError} (an\n * {@link ErrorResult} that has been touched by {@link markHandled}).\n *\n * @category Requests and Results\n */\nexport function isHandled(res: JobResult<any> | undefined): res is HandledError {\n return isError(res) && res.val === null;\n}\n\n/**\n * Return the error of an {@link ErrorResult} and mark it as handled. The\n * {@link ErrorResult} is mutated in-place to become a {@link HandledError}.\n *\n * @category Requests and Results\n */\nexport function markHandled(res: ErrorResult): any {\n res.val = null;\n return res.err;\n}\n\n/**\n * Get the return value from a {@link JobResult}, throwing an appropriate error\n * if the result isn't a {@link ValueResult}.\n *\n * @param res The job result you want to unwrap. Must not be undefined!\n *\n * @returns The value if the result is a {@link ValueResult}, or a thrown error\n * if it's an {@link ErrorResult}. A {@link CancelError} is thrown if the job\n * was canceled, or the error in the result is thrown.\n *\n * If the result is an error, it is marked as handled.\n *\n * @category Jobs\n */\nexport function getResult<T>(res: JobResult<T>): T {\n if (isValue(res)) return res.val;\n res.op; // throw if not defined\n fulfillPromise(noop, e => { throw e; }, res);\n}\n\n/**\n * Fulfill a Promise from a {@link JobResult}\n *\n * If the result is a {@link CancelResult}, the promise is rejected with a\n * {@link CancelError}. Otherwise it is resolved or rejected according to the\n * state of the result.\n *\n * @param resolve A value-taking function (first arg to `new Promise` callback)\n *\n * @param reject An error-taking function (second arg to `new Promise` callback)\n *\n * @param res The job result you want to settle the promise with. An error will\n * be thrown if it's undefined.\n *\n * If the result is an error, it is marked as handled.\n *\n * @category Requests and Results\n */\nexport function fulfillPromise<T>(resolve: (v: T) => void, reject: (e: any) => void, res: JobResult<T>) {\n if (isError(res)) reject(markHandled(res));\n else if (isCancel(res)) reject(new CancelError(\"Job canceled\"));\n else resolve(res.val);\n}\n\n/**\n * Propagate a {@link JobResult} to another job\n *\n * If the result is a {@link CancelResult}, the job will throw with a\n * {@link CancelError}. Otherwise it is resolved or rejected according to the\n * state of the result.\n *\n * @param job The job to terminate. If it's already ended, nothing changes: the\n * result is not propagated and the error (if any) is not marked as handled.\n *\n * @param res The job result you want to settle the job with. An error will be\n * thrown if it's undefined. If the result is an error, it is marked as\n * handled.\n *\n * @category Requests and Results\n */\nexport function propagateResult<T>(job: Job<T>, res: JobResult<T>) {\n if (!job.result()) fulfillPromise(job.return.bind(job), job.throw.bind(job), res);\n}\n\n/**\n * Error thrown when waiting for a result from a job that is canceled.\n *\n * If you `await`, `yield *`, `.then()`, `.catch()`, {@link getResult}() or\n * otherwise wait on the result of a job that is canceled, this is the type\n * of error you'll get.\n *\n * @category Errors\n */\nexport class CancelError extends Error {}\n","/**\n * Ambient execution context (for job, resource, and dependency tracking)\n *\n * @internal\n * @module\n */\n\nimport type { Job } from \"./types.ts\";\nimport type { Cell } from \"./cells.ts\";\n\ntype Opt<X> = X | undefined | null;\n\nexport type Context = {\n job: Opt<Job<unknown>>\n cell: Opt<Cell>\n}\n\n/** The current context */\nexport var current: Context = makeCtx();\n\n\n/** Set a new current context, returning the old one */\nexport function swapCtx(future: Context): Context {\n const now = current;\n current = future;\n return now\n}\n\nvar freelist = [] as Context[];\n\n/** Get a fresh context object (either by creation or recycling) */\nexport function makeCtx(\n job?: Context[\"job\"],\n cell?: Context[\"cell\"],\n): Context {\n if (freelist && freelist.length) {\n const s = freelist.pop()!;\n s.job = job;\n s.cell = cell;\n return s;\n }\n return {job, cell};\n}\n\n/** Put a no-longer-needed context object on the recycling heap */\nexport function freeCtx(s: Context) {\n s.job = s.cell = null;\n freelist.push(s);\n}\n\n","/**\n * Provide access to certain internals (for testing use only)\n *\n * @module\n */\n\nimport { makeCtx } from \"./ambient.ts\";\nimport { Job } from \"./types.ts\";\n\nexport const\n /** Jobs' asyncCatch handlers: in a map because few jobs will have them */\n catchers = new WeakMap<Job, (this: Job, err: any) => unknown>(),\n\n /** Default error handler for the `detached` job */\n defaultCatch = (e: any) => { Promise.reject(e); }\n;\n\n/** A null context (no job/observer) for cleanups to run in */\nexport const nullCtx = makeCtx();\n\n/** Jobs' owners (parents) - uses a map so child jobs can't directly access them */\nexport const owners = new WeakMap<Job, Job>();\n","import { DisposeFn } from \"./types.ts\";\n\n/**\n * A counted, double-ended queue with the ability to undo insertions (even out\n * of order).\n *\n * @category Chains\n */\nexport type Chain<T, U=any> = Node<T, number, U>;\n\n/**\n * Create a new Chain\n *\n * @category Chains\n */\nexport function chain<T, U=DisposeFn>(): Chain<T, U> { return link<number, U>(0, undefined, undefined); }\n\n/**\n * Recycle a chain entirely - only safe if no references to it remain anywhere!\n */\nexport function recycle(c: Chain<any>) {\n while (c.v) unlink(c, c.n);\n c.u = undefined;\n unlink(c, c);\n}\n\n/**\n * Unshift a value onto the front of the chain\n *\n * @category Chains\n */\nexport function unshift<T>(c: Chain<T>, v: T) { ++c.v; link(v, c.n, c); }\n\n/**\n * Unshift a value onto the front of the chain, returning an undo callback. The\n * callback can be invoked to remove the value from the chain at any time, even\n * after other values have been added or removed. There is no effect if the\n * callback is run more than once, or if the value has already been removed.\n *\n * @category Chains\n */\nexport function unshiftCB<T>(c: Chain<T>, v: T) { ++c.v; return unlinker(c, link(v, c.n, c)); }\n\n/**\n * Push a value onto the end of the chain\n *\n * @category Chains\n */\nexport function push<T>(c: Chain<T>, v: T) { ++c.v; link(v, c, c.p); }\n\n/**\n * Push a value onto the end of the chain, returning an undo callback. The\n * callback can be invoked to remove the value from the chain at any time, even\n * after other values have been added or removed. There is no effect if the\n * callback is run more than once, or if the value has already been removed.\n *\n * @category Chains\n */\nexport function pushCB<T>(c: Chain<T>, v: T) { ++c.v; return unlinker(c, link(v, c, c.p)); }\n\n/**\n * Return true if the chain is empty, or is null/undefined\n *\n * @category Chains\n */\nexport function isEmpty(c: Chain<any> | null | undefined) { return !c || c.v === 0; }\n\n/**\n * Return the number of items in the chain, or 0 if it's null/undefined\n *\n * @category Chains\n */\nexport function qlen(c: Chain<any> | null | undefined) { return c ? c.v : 0; }\n\n/**\n * Remove a value from the end of the chain, returning it\n *\n * @category Chains\n */\nexport function pop<T>(c: Chain<T>) { if (qlen(c)) return unlink(c, c.p); }\n\n/**\n * Remove a value from the front of the chain, returning it\n *\n * @category Chains\n */\nexport function shift<T>(c: Chain<T>) { if (qlen(c)) return unlink(c, c.n); }\n\n/** A node in a chain */\nclass Node<T, V=T, U=DisposeFn> {\n /** The next node (or the start node if this is a chain head) */\n n: Node<T> = this as Node<T, any>;\n /** The previous node (or the end node if this is a chain head) */\n p: Node<T> = this as Node<T, any>;\n /** The value held by the node (or the chain length if this is a chain head) */\n v: V = 0 as any;\n /** The most recently created undo callback for this node */\n u: U = undefined;\n}\n\n/** Recycling list for chain nodes, to reduce constructor/alloc overhead */\nvar free: Node<any,any,any>;\n\n/** Create (or reuse) a node with a given value, inserting it between two nodes in a chain */\nfunction link<T,U=DisposeFn>(v: T, n: Node<T, any, any>, p: Node<T, any, any>): Node<T,T,U> {\n let node: Node<T, T, any> = free;\n if (node) {\n free = node.n;\n node.n = n || node;\n node.p = p || node;\n } else {\n node = new Node<T, T, U>;\n if (n) node.n = n;\n if (p) node.p = p;\n }\n node.v = v;\n node.n.p = node;\n node.p.n = node;\n return node;\n}\n\n/** Unlink a node from a chain and recycle it, returning the value it held */\nfunction unlink<T>(c: Chain<any>, node: Node<T>) {\n --c.v;\n var v = node.v, u = node.u;\n node.n && (node.n.p = node.p);\n node.p && (node.p.n = node.n);\n node.u = node.v = node.p = undefined;\n node.n = free; free = node;\n if (u) u(); // drop refs to node+chain\n return v;\n}\n\n/**\n * Return an undo/remove callback that will run at most once and is a no-op if the\n * node was already removed. If called more than once on the same node while\n * it's in the same chain, it returns the same callback. ()\n */\nfunction unlinker(chain: Chain<any>, node: Node<any>) {\n let u = (node.u ||= () => {\n if (u) {\n // If the node's undo callback is this callback, then it's safe to remove;\n // otherwise, the node has already been removed and/or recycled for use in\n // a different chain (or a different value in this one!)\n if (u === node.u) unlink(chain, node);\n u = chain = node = undefined;\n }\n })\n return u;\n}\n","import { makeCtx, current, freeCtx, swapCtx } from \"./ambient.ts\";\nimport { catchers, defaultCatch, nullCtx, owners } from \"./internals.ts\";\nimport { CleanupFn, Job, Request, Yielding, Suspend, PlainFunction, StartFn, OptionalCleanup, JobIterator, RecalcSource, StartObj } from \"./types.ts\";\nimport { defer } from \"./defer.ts\";\nimport { JobResult, ErrorResult, CancelResult, isCancel, ValueResult, isError, isValue, noop, markHandled, isUnhandled, propagateResult } from \"./results.ts\";\nimport { rejecter, resolver, getResult, fulfillPromise } from \"./results.ts\";\nimport { Chain, chain, isEmpty, pop, push, pushCB, qlen, recycle, unshift } from \"./chains.ts\";\nimport { Stream, Sink, Inlet, Connection } from \"./streams.ts\";\n\n/**\n * Is the given value a function?\n *\n * @category Types and Interfaces\n */\nexport function isFunction(f: any): f is Function {\n return typeof f === \"function\";\n}\n\n/**\n * Return the currently-active Job, or throw an error if none is active.\n *\n * (You can check if a job is active first using {@link isJobActive}().)\n *\n * @category Jobs\n */\nexport function getJob<T=unknown>() {\n const {job} = current;\n if (job) return job as Job<T>;\n throw new Error(\"No job is currently active\");\n}\n\n/** RecalcSource factory for jobs (so you can wait on a job result in a signal or rule) */\nfunction recalcJob(job: Job<any>): RecalcSource { return (cb => { current.job.must(job.release(cb)); }); }\n\nfunction runChain<T>(res: JobResult<T>, cbs: Chain<CleanupFn<T>>): undefined {\n while (qlen(cbs)) try { pop(cbs)(res); } catch (e) { detached.asyncThrow(e); }\n cbs && recycle(cbs);\n return undefined;\n}\n\n// The set of jobs whose callbacks need running during an end() sweep\nvar inProcess = new Set<_Job<any>>;\n\nclass _Job<T> implements Job<T> {\n /** @internal */\n static create<T,R>(parent?: Job<R>, stop?: CleanupFn<R>): Job<T> {\n const job = new _Job<T>;\n if (parent || stop) {\n job.must((parent ||= getJob() as Job<R>).release(stop || job.end));\n owners.set(job, parent);\n }\n return job;\n }\n\n do(cleanup: CleanupFn<T>): this {\n unshift(this._chain(), cleanup);\n return this;\n }\n\n onError(cb: (err: any) => unknown): this {\n return this.do(r => { if (isError(r)) cb(markHandled(r)); });\n }\n\n onValue(cb: (val: T) => unknown): this {\n return this.do(r => { if (isValue(r)) cb(r.val); });\n }\n\n onCancel(cb: () => unknown): this {\n return this.do(r => { if (isCancel(r)) cb(); });\n }\n\n result(): JobResult<T> | undefined {\n // If we're done, we're done; otherwise make signals/rules reading this\n // recalc when we're done (handy for rendering \"loading\" states).\n return this._done || current.cell?.recalcWhen(this, recalcJob) || undefined;\n }\n\n get [Symbol.toStringTag]() { return \"Job\"; }\n\n end = () => {\n const res = (this._done ||= CancelResult), cbs = this._cbs;\n // if we have an unhandled error, fall through to queued mode for later\n // re-throw; otherwise, if there aren't any callbacks we're done here\n if (!cbs && !isUnhandled(res)) return;\n\n const ct = inProcess.size, old = swapCtx(nullCtx);;\n // Put a placeholder on the queue if it's empty\n if (!ct) inProcess.add(null);\n\n // Give priority to the release() chain so we get breadth-first flagging\n // of all child jobs as canceled immediately\n if (cbs && cbs.u) cbs.u = runChain(res, cbs.u);\n\n // Put ourselves on the queue *after* our children, so their cleanups run first\n inProcess.add(this);\n\n // if the queue wasn't empty, there's a loop above us that will run our must/do()s\n if (ct) { swapCtx(old); return; }\n\n // don't need the placeholder any more\n inProcess.delete(null);\n\n // Queue was empty, so it's up to us to run everybody's must/do()s\n for (const item of inProcess) {\n if (item._cbs) item._cbs = runChain(item._done, item._cbs);\n inProcess.delete(item);\n if (isUnhandled(item._done)) item.throw(markHandled(item._done));\n }\n swapCtx(old);\n }\n\n restart() {\n if (!this._done && inProcess.size) {\n // if a tree of jobs is ending right now, we need to start\n // a new stack so that when we return, all our children's\n // callbacks will have finished running first.\n const old = inProcess;\n inProcess = new Set;\n this.end();\n inProcess = old;\n } else {\n this._end(CancelResult);\n }\n this._done = undefined;\n promises.delete(this); // don't reuse any now-cancelled promise!\n return this;\n }\n\n _end(res: JobResult<T>) {\n if (this._done) throw new Error(\"Job already ended\");\n if (this !== detached) this._done = res;\n this.end();\n return this;\n }\n\n throw(err: any) {\n if (this._done) {\n (owners.get(this) || detached).asyncThrow(err);\n return this;\n }\n return this._end(ErrorResult(err));\n }\n\n return(val: T) { return this._end(ValueResult(val)); }\n\n then<T1=T, T2=never>(\n onfulfilled?: (value: T) => T1 | PromiseLike<T1>,\n onrejected?: (reason: any) => T2 | PromiseLike<T2>\n ): Promise<T1 | T2> {\n return nativePromise(this).then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult> {\n return nativePromise(this).catch(onrejected);\n }\n\n finally(onfinally?: () => void): Promise<T> {\n return nativePromise(this).finally(onfinally);\n }\n\n *[Symbol.iterator](): JobIterator<T> {\n if (this._done) {\n return getResult(this._done);\n } else return yield (req: Request<T>) => {\n // XXX should this be a release(), so if the waiter dies we\n // don't bother? The downside is that it'd have to be mutual and\n // the resume is a no-op anyway in that case.\n this.do(res => fulfillPromise(resolver(req), rejecter(req), res));\n }\n }\n\n start<T>(fn?: StartFn<T> | StartObj<T>): Job<T>;\n start<T, This>(ctx: This, fn: StartFn<T, This>): Job<T>;\n start<T, This>(fnOrCtx: StartFn<T> | StartObj<T>|This, fn?: StartFn<T, This>) {\n if (!fnOrCtx) return makeJob(this);\n let init: StartFn<T, This>, result: StartObj<T> | OptionalCleanup;\n if (isFunction(fn)) {\n init = fn.bind(fnOrCtx as This);\n } else if (isFunction(fnOrCtx)) {\n init = fnOrCtx as StartFn<T, This>;\n } else if (fnOrCtx instanceof _Job) {\n return fnOrCtx;\n } else {\n result = fnOrCtx as StartObj<T>;\n }\n const job = makeJob<T>(this);\n try {\n if (init) result = job.run(init as StartFn<T>, job);\n if (result != null) {\n if (result instanceof _Job) {\n if (result !== job) result.do(res => propagateResult(job, res));\n } else if (isFunction((result as Promise<T>).then)) {\n (result as Promise<T>).then(\n v => { job.result() || job.return(v); },\n e => { job.result() || job.throw(e); }\n );\n return job;\n } else if (\n isFunction((result as Yielding<T>)[Symbol.iterator]) &&\n typeof result !== \"string\"\n ) {\n job.run(runGen<T>, result as Yielding<T>, job);\n } else if (isFunction(result)) {\n job.must(result);\n } else {\n throw new TypeError(\"Invalid value/return for start()\");\n }\n }\n return job;\n } catch(e) {\n job.end();\n throw e;\n }\n }\n\n connect<T>(src: Stream<T>, sink: Sink<T>, inlet?: Inlet): Connection {\n return this.start(job => void src(sink, job, inlet));\n }\n\n protected constructor() {};\n\n run<F extends PlainFunction>(fn: F, ...args: Parameters<F>): ReturnType<F> {\n const old = swapCtx(makeCtx(this));\n try { return fn.apply(null, args); } finally { freeCtx(swapCtx(old)); }\n }\n\n bind<F extends (...args: any[]) => any>(fn: F): F {\n const job = this;\n return <F> function (this: any) {\n const old = swapCtx(makeCtx(job));\n try { return fn.apply(this, arguments as any); } finally { freeCtx(swapCtx(old)); }\n }\n }\n\n must(cleanup?: OptionalCleanup<T>) {\n if (isFunction(cleanup)) push(this._chain(), cleanup);\n return this;\n }\n\n release(cleanup: CleanupFn<T>): () => void {\n if (this === detached) return noop;\n let cbs = this._chain();\n if (!this._done || cbs.u) cbs = cbs.u ||= chain();\n return pushCB(cbs, cleanup);\n }\n\n asyncThrow(err: any) {\n try {\n (catchers.get(this) || this.throw).call(this, err);\n } catch (e) {\n // Don't allow a broken handler to stay on the job\n if (this === detached) catchers.set(this, defaultCatch); else catchers.delete(this);\n const catcher = catchers.get(this) || this.throw;\n catcher.call(this, err);\n catcher.call(this, e); // also report the broken handler\n }\n return this;\n }\n\n asyncCatch(handler: ((this: Job, err: any) => unknown) | null): this {\n if (isFunction(handler)) catchers.set(this, handler);\n else if (handler === null) catchers.delete(this);\n return this;\n }\n\n protected _done: JobResult<T> = undefined;\n\n // Chain whose .u stores a second chain for `release()` callbacks\n protected _cbs: Chain<CleanupFn<T>, Chain<CleanupFn<T>>> = undefined;\n protected _chain() {\n if (this === detached) this.end()\n if (this._done && isEmpty(this._cbs)) defer(this.end);\n return this._cbs ||= chain();\n }\n}\n\nconst promises = new WeakMap<Job<any>, Promise<any>>();\n\n/**\n * Obtain a native promise for a job\n *\n * While jobs have the same interface as native promises, there are occasionally\n * reasons to just use one directly. (Like when Uneventful uses this function\n * to implement jobs' promise methods!)\n *\n * @param job Optional: the job to get a native promise for. If none is given,\n * the active job is used.\n *\n * @returns A {@link Promise} that resolves or rejects according to whether the\n * job returns or throws. If the job is canceled, the promise is rejected with\n * a {@link CancelError}.\n *\n * @category Jobs\n */\nexport function nativePromise<T>(job = getJob<T>()): Promise<T> {\n if (!promises.has(job)) {\n promises.set(job, new Promise((res, rej) => {\n const toPromise = (fulfillPromise<T>).bind(null, res, rej);\n if (job.result()) toPromise(job.result()); else job.do(toPromise);\n }));\n }\n return promises.get(job);\n}\n\n/**\n * Return a new {@link Job}. If *either* a parent parameter or stop function\n * are given, the new job is linked to the parent.\n *\n * @param parent The parent job to which the new job should be attached.\n * Defaults to the currently-active job if none given (assuming a stop\n * parameter is provided).\n *\n * @param stop The function to call to destroy the nested job. Defaults to the\n * {@link Job.end} method of the new job if none is given (assuming a parent\n * parameter is provided).\n *\n * @returns A new job. The job is linked/nested if any arguments are given,\n * or a detached (parentless) job otherwise.\n *\n * @category Jobs\n */\nexport const makeJob: <T,R=unknown>(parent?: Job<R>, stop?: CleanupFn<R>) => Job<T> = _Job.create;\n\n/**\n * A special {@link Job} with no parents, that can be used to create standalone\n * jobs. detached.start() returns a new detached job, detached.run() can be\n * used to run code that expects to create a child job, and detached.bind() can\n * wrap a function to work without a parent job.\n *\n * (Note that in all cases, a child job of `detached` *must* be stopped\n * explicitly, or it may \"run\" forever, never running its cleanup callbacks.)\n *\n * The detached job has a few special features and limitations:\n *\n * - It can't be ended, thrown, return()ed, etc. -- you'll get an error\n *\n * - It can't have any cleanup functions added: no do, must, onError, etc., and\n * thus also can't have any native promise, abort signal, etc. used. You can\n * call its release() method, but nothing will actually be registered and the\n * returned callback is a no-op.\n *\n * - Unhandled errors from jobs without parents (and errors from *any* job's\n * cleanup functions) are sent to the detached job for handling. This means\n * whatever you set as the detached job's .{@link Job.asyncCatch asyncCatch}()\n * handler will receive them. (Its default is Promise.reject, causing an\n * unhandled promise rejection.)\n *\n * @category Jobs\n */\nexport const detached = makeJob();\n(detached as any).end = () => { throw new Error(\"Can't do that with the detached job\"); }\ndetached.asyncCatch(defaultCatch);\n\nfunction runGen<R>(g: Yielding<R>, job: Job<R>) {\n let it = g[Symbol.iterator](), running = true, ctx = makeCtx(job), ct = 0;\n let done = ctx.job.release(() => {\n job = undefined;\n ++ct; // disable any outstanding request(s)\n // XXX this should be deferred to cleanup phase, or must() instead of release\n // (release only makes sense here if you can run more than one generator in a job)\n step(\"return\", undefined);\n });\n // Start asynchronously\n defer(() => { running = false; step(\"next\", undefined); });\n\n function step(method: \"next\" | \"throw\" | \"return\", arg: any): void {\n if (!it) return;\n // Don't resume a job while it's running\n if (running) {\n return defer(step.bind(null, method, arg));\n }\n const old = swapCtx(ctx);\n try {\n running = true;\n try {\n for(;;) {\n ++ct;\n const {done, value} = it[method](arg);\n if (done) {\n job && job.return(value);\n job = undefined;\n break;\n } else if (!isFunction(value)) {\n method = \"throw\";\n arg = new TypeError(\"Jobs must yield functions (or yield* Yielding<T>s)\");\n continue;\n } else {\n let called = false, returned = false, count = ct;\n (value as Suspend<any>)((op, val, err) => {\n if (called) return; else called = true;\n method = op; arg = op === \"next\" ? val : err;\n if (returned && count === ct) step(op, arg);\n });\n returned = true;\n if (!called) return;\n }\n }\n } catch(e) {\n it = job = undefined;\n ctx.job.throw(e);\n }\n // Iteration is finished; disconnect from job\n it = undefined;\n done?.();\n done = undefined;\n } finally {\n swapCtx(old);\n running = false;\n }\n }\n}\n","import { Request, Yielding } from \"./types.ts\";\nimport { rejecter, resolve, resolver } from \"./results.ts\"\n\n/**\n * Convert a (possible) promise to something you can `yield *to()` in a job\n *\n * Much like `await valueOrPromiseLike` in an async function, using `yield\n * *to(valueOrPromiseLike)` in a {@link Job}'s generator function will return\n * the value or the result of the promise/promise-like object.\n *\n * @category Scheduling\n */\nexport function *to<T>(p: Promise<T> | PromiseLike<T> | T): Yielding<T> {\n return yield (res: Request<T>) => Promise.resolve(p).then(resolver(res), rejecter(res));\n}\n\n/**\n * Pause the job for the specified time in ms, e.g. `yield *sleep(1000)` to wait\n * one second.\n *\n * @category Scheduling\n */\nexport function *sleep(ms: number): Yielding<void> {\n try {\n var id: ReturnType<typeof setTimeout>;\n yield r => {\n id = setTimeout(() => { id = undefined; resolve(r, void 0); }, ms);\n }\n } finally {\n if (id) clearTimeout(id);\n }\n}\n","import { type Cell } from \"./cells.ts\";\nimport { defer } from \"./defer.ts\";\n\n/** Scheduler state flags */\nconst enum Is {\n Unset = 0,\n _ = 1,\n Running = _ << 0,\n Scheduled = _ << 1,\n}\n\n/**\n * A generic queue for things that need to be run at-most-once per item\n * per timeframe.\n *\n * @category Jobs and Scheduling\n */\nexport class RunQueue<K> {\n protected _flags: Is = Is.Unset;\n protected readonly q = new Set<K>();\n\n constructor(\n /**\n * A single-argument scheduling function (like requestAnimationFrame,\n * setImmediate, or queueMicrotask). The scheduler will call it from\n * time to time with a single callback. The scheduling function should\n * then arrange for that callback to be invoked *once* at some future\n * point, when it is the desired time for all pending items on this\n * queue to run.\n */\n protected readonly sched: (cb: () => unknown) => unknown,\n /**\n * A callback to loop over the queue, removing items and performing any\n * necessary operations\n */\n protected readonly reap: (queue: Set<K>) => void\n ) {}\n\n /** Is this queue currently running? */\n isRunning() { return !!(this._flags & Is.Running); }\n\n /** Is this queue currently empty? */\n isEmpty() { return !this.q.size; }\n\n add(subject: K) {\n this.q.size || this._flags & (Is.Running|Is.Scheduled) || this._sched();\n this.q.add(subject);\n }\n\n delete(subject: any) {\n this.q.delete(subject);\n }\n\n protected _sched() {\n this._flags |= Is.Scheduled;\n this.sched(this._run);\n }\n\n protected _run = () => {\n this._flags &= ~Is.Scheduled;\n this.flush();\n }\n\n /** Run all pending items */\n flush = () => {\n // already running? skip it\n if (this._flags & Is.Running) return;\n const {q: queue} = this;\n // nothing to do? skip it\n if (!queue.size) return;\n this._flags |= Is.Running;\n try {\n this.reap(queue);\n } finally {\n this._flags &= ~Is.Running;\n // schedule again if we're stopping early due to error\n !queue.size || (this._flags & Is.Scheduled) || this._sched();\n }\n }\n}\n\nexport var currentRule: Cell;\nvar currentQueue: RuleQueue;\n\nconst ruleQueues = new WeakMap<Function, RuleQueue>();\n\nexport class RuleQueue extends RunQueue<Cell> {\n constructor(sched: (cb: () => unknown) => unknown) {\n super(sched, function(this: RuleQueue, q) {\n // another queue is running? reschedule for later\n if (currentQueue) return;\n currentQueue = this;\n try {\n // run rules marked dirty by value changes\n for (currentRule of q) {\n currentRule.catchUp();\n q.delete(currentRule);\n }\n } finally {\n currentQueue = currentRule = undefined;\n }\n });\n }\n}\n\nexport function ruleQueue(scheduleFn: (cb: () => unknown) => unknown = defer) {\n ruleQueues.has(scheduleFn) || ruleQueues.set(scheduleFn, new RuleQueue(scheduleFn));\n return ruleQueues.get(scheduleFn);\n}\n\nexport const defaultQ = /* @__PURE__ */ ruleQueue(defer);\n\n/** @internal */\nexport const pulls = new RunQueue<{doPull(): void}>(defer, pulls => {\n for (const conn of pulls) { pulls.delete(conn); conn.doPull(); }\n})\n\n/** @internal For testing only */\nexport const runPulls = pulls.flush;","import { pulls } from \"./scheduling.ts\";\nimport { DisposeFn, Job } from \"./types.ts\";\nimport { getJob } from \"./tracking.ts\";\nimport { current } from \"./ambient.ts\";\n\n/**\n * A backpressure controller: returns true if downstream is ready to accept\n * data.\n *\n * @param cb (optional) - a callback to run when the downstream consumer wishes\n * to resume event production (i.e., when a sink calls\n * {@link Throttle.resume}()). The callback is automatically unregistered when\n * invoked, so the producer must re-register it after each call if it wishes to\n * keep being called.\n *\n * @category Types and Interfaces\n */\nexport type Backpressure = (cb?: () => any) => boolean\n\n\n/**\n * Create a backpressure control function for the given connection\n *\n * @category Stream Producers\n */\nexport function backpressure(inlet: Inlet = defaultInlet): Backpressure {\n const job = getJob();\n return (cb?: Flush) => {\n if (!job.result() && inlet.isOpen()) {\n if (cb) inlet.onReady(cb, job);\n return inlet.isReady();\n }\n return false;\n }\n}\n\n/**\n * Control backpressure for listening streams. This interface is the API\n * internal to the implementation of {@link backpressure}(). Unless you're\n * implementing a backpressurable stream yourself, see the {@link Throttle}\n * interface instead.\n *\n * @category Types and Interfaces\n */\nexport interface Inlet {\n /** Is the main connection open? (i.e. is the creating job not closed yet?) */\n isOpen(): boolean\n\n /** Is the conduit currently ready to receive data? */\n isReady(): boolean\n\n /**\n * Register a callback to produce more data when the inlet is resumed\n * (The callback is unregistered if the supplied job ends.)\n */\n onReady(cb: () => any, job: Job): this;\n}\n\n/**\n * Control backpressure for listening streams\n *\n * Obtain instances via {@link throttle}(), then pass them into the appropriate\n * stream-consuming API. (e.g. {@link connect}).\n *\n * @category Types and Interfaces\n */\nexport interface Throttle extends Inlet {\n /** Set inlet status to \"paused\". */\n pause(): void;\n\n /**\n * Un-pause, and iterate backpressure-able sources' onReady callbacks to\n * resume sending immediately. (i.e., synchronously!)\n */\n resume(): void;\n}\n\n/**\n * A Connection is a job that returns void when the connected stream ends\n * itself. If the stream doesn't end itself (e.g. it's an event listener), the\n * job will never return, and only end with a cancel or throw.\n *\n * @category Types and Interfaces\n */\nexport type Connection = Job<void>;\n\n/**\n * A Source is a function that can be called to arrange for data to be\n * produced and sent to a {@link Sink} function for consumption, until the\n * associated {@link Connection} is closed (either by the source or the sink,\n * e.g. if the sink doesn't want more data or the source has no more to send).\n *\n * If the source is a backpressurable stream, it can use the (optional) supplied\n * inlet (usually a {@link throttle}()) to rate-limit its output.\n *\n * A producer function *must* return the special {@link IsStream} value, so\n * TypeScript can tell what functions are usable as sources. (Otherwise any\n * void function with no arguments would appear to be usable as a source!)\n *\n * @category Types and Interfaces\n */\nexport interface Source<T> {\n /** Subscribe sink to receive values */\n (sink: Sink<T>, conn?: Connection, inlet?: Throttle | Inlet): typeof IsStream;\n}\n\n/**\n * An uneventful stream is either a {@link Source} or a {@link SignalSource}.\n * (Signals actually implement the {@link Source} interface as an overload, but\n * TypeScript gets confused about that sometimes, so we generally declare our\n * stream *inputs* as `Stream<T>` and our stream *outputs* as {@link Source}, so\n * that TypeScript knows what's what.\n *\n * @category Types and Interfaces\n */\nexport type Stream<T> = Source<T> | SignalSource<T>;\n\n/**\n * The call signatures implemented by signals. (They can be used as sources, or\n * called with no arguments to return a value.)\n *\n * This type is needed because TypeScript won't infer the overloads of\n * {@link Signal} correctly otherwise. (Specifically, it won't allow it to be\n * used as a zero-agument function.)\n *\n * @category Types and Interfaces\n*/\nexport type SignalSource<T> = Source<T> & {\n /** A signal object can be called to get its current value */\n (): T\n}\n\n/**\n * A specially-typed string used to verify that a function supports uneventful's\n * streaming protocol. Return it from a function to implement the\n * {@link Source} type.\n *\n * @category Types and Interfaces\n */\nexport const IsStream = \"uneventful/is-stream\" as const;\n\n/**\n * A `Sink` is a function that receives data from a {@link Stream}.\n *\n * @category Types and Interfaces\n */\nexport type Sink<T> = (val: T) => void;\n\n/**\n * A `Transformer` is a function that takes one stream and returns another,\n * possibly one that produces data of a different type. Most operator functions\n * return a transformer, allowing them to be combined via {@link pipe}().\n *\n * @category Types and Interfaces\n */\nexport type Transformer<T, V=T> = (input: Stream<T>) => Source<V>;\n\ntype Flush = () => any\n\n\n/**\n * Subscribe a sink to a stream, returning a nested job. (Shorthand for\n * {@link getJob}().{@link Job.connect connect}(...).)\n *\n * @param src An event source or signal\n * @param sink A callback that will receive the events\n * @param inlet Optional - a {@link throttle}() to control backpressure\n *\n * @returns A job that can be aborted to end the subscription, and which will\n * end naturally (with a void return or error) if the stream ends itself.\n *\n * @category Stream Consumers\n */\nexport function connect<T>(src: Stream<T>, sink: Sink<T>, inlet?: Throttle | Inlet): Connection {\n return getJob().connect(src, sink, inlet);\n}\n\n/**\n * Create a backpressure controller for a stream. Pass it to one or more\n * sources you're connecting to, and if they support backpressure they'll\n * respond when you call its .pause() and .resume() methods.\n *\n * @param job - Optional: a job that controls readiness. (The throttle will\n * pause indefinitely when the job ends.) Defaults to the currently-active job,\n * but unlike most such defaults, it won't throw if no job is active.\n *\n * @category Stream Consumers\n */\nexport function throttle(job: Job = current.job): Throttle {\n return new _Throttle(job);\n}\n\nclass _Throttle implements Throttle {\n /** @internal */\n protected _callbacks: Map<Flush, DisposeFn> = undefined;\n\n /** @internal */\n constructor(protected _job?: Job) {}\n\n isOpen(): boolean { return !this._job?.result(); }\n\n /** Is the conduit currently ready to receive data? */\n isReady(): boolean { return this.isOpen() && this._isReady; }\n\n _isReady = true;\n _isPulling = false;\n\n onReady(cb: Flush, job: Job) {\n if (!this.isOpen()) return this;\n const _callbacks = (this._callbacks ||= new Map);\n const unlink = job.release(() => _callbacks.delete(cb));\n if (this.isReady() && this && !_callbacks.size) {\n pulls.add(this);\n }\n _callbacks.set(cb, unlink);\n return this;\n }\n\n pause() { this._isReady = false; return this; }\n\n doPull() {\n if (this._isPulling) return;\n const {_callbacks} = this;\n if (!_callbacks?.size) return;\n this._isPulling = true;\n try {\n for(let [cb, unlink] of _callbacks) {\n if (!this.isReady()) break; // we're done\n unlink()\n _callbacks.delete(cb);\n cb() // XXX error handling?\n }\n } finally {\n this._isPulling = false;\n }\n }\n\n resume() {\n if (this.isOpen()) {\n this._isReady = true;\n this.doPull();\n }\n }\n}\n\nconst defaultInlet: Inlet = throttle();\n\n/**\n * Pipe a stream (or anything else) through a series of single-argument\n * functions/operators\n *\n * e.g. the following creates a stream that outputs 4 and then 6:\n *\n * ```ts\n * pipe(fromIterable([1,2,3,4]), skip(1), take(2), map(x => x*2))\n * ```\n *\n * The first argument to pipe() can be any value, but all other arguments must\n * be functions. The value is passed to the first function, and then the result\n * is passed to the next function in turn, until all provided functions have\n * been called with the result of the previous function. The return value is\n * the last result, or the original value if no functions were given.\n *\n * The underlying implementation of pipe() works with any number of arguments,\n * but due to TypeScript limitations we only have typing defined for a max of 9\n * functions (10 arguments total). If you need more than 9 functions, you can\n * stack some of them with {@link compose}(), e.g.:\n *\n * ```typescript\n * pipe(\n * aStream,\n * compose(op1, op2, ...),\n * compose(op10, op11, ...),\n * compose(op19, ...),\n * ...\n * )\n * ```\n *\n * @category Stream Operators\n */\nexport function pipe<A,B,C,D,E,F,G,H,I,J>(input: A, ...fns: Chain9<A,J,B,C,D,E,F,G,H,I>): J\nexport function pipe<A,B,C,D,E,F,G,H,I> (input: A, ...fns: Chain8<A,I,B,C,D,E,F,G,H>): I\nexport function pipe<A,B,C,D,E,F,G,H> (input: A, ...fns: Chain7<A,H,B,C,D,E,F,G>): H\nexport function pipe<A,B,C,D,E,F,G> (input: A, ...fns: Chain6<A,G,B,C,D,E,F>): G\nexport function pipe<A,B,C,D,E,F> (input: A, ...fns: Chain5<A,F,B,C,D,E>): F\nexport function pipe<A,B,C,D,E> (input: A, ...fns: Chain4<A,E,B,C,D>): E\nexport function pipe<A,B,C,D> (input: A, ...fns: Chain3<A,D,B,C>): D\nexport function pipe<A,B,C> (input: A, ...fns: Chain2<A,C,B>): C\nexport function pipe<A,B> (input: A, ...fns: Chain1<A,B>): B\nexport function pipe<A> (input: A): A\nexport function pipe(input: any, ...fns: Array<(v: any) => any>): any;\nexport function pipe<A,X>(): X {\n var v = arguments[0];\n for (var i=1; i<arguments.length; i++) v = arguments[i](v);\n return v;\n}\n\n/**\n * Compose a series of single-argument functions/operators in application order.\n * (This is basically a deferred version of {@link pipe}().) For example:\n *\n * ```ts\n * const func = compose(skip(1), take(2), map(x => x*2));\n * const stream_4_6 = func(fromIterable([1,2,3,4])); // stream that outputs 4, 6\n * ```\n *\n * As with `pipe()`, the declared typings only support composing up to 9\n * functions at once; if you need more you'll need to nest calls to `compose()`\n * (i.e. passing the result of a `compose()` as an argument to another\n * `compose()` call.)\n *\n * @returns A function taking the same type as the first input function,\n * returning the same type as the last input function.\n *\n * @category Stream Operators\n */\nexport function compose<A,B,C,D,E,F,G,H,I,J>(...fns: Chain9<A,J,B,C,D,E,F,G,H,I>): (a: A) => J\nexport function compose<A,B,C,D,E,F,G,H,I> (...fns: Chain8<A,I,B,C,D,E,F,G,H>): (a: A) => I\nexport function compose<A,B,C,D,E,F,G,H> (...fns: Chain7<A,H,B,C,D,E,F,G>): (a: A) => H\nexport function compose<A,B,C,D,E,F,G> (...fns: Chain6<A,G,B,C,D,E,F>): (a: A) => G\nexport function compose<A,B,C,D,E,F> (...fns: Chain5<A,F,B,C,D,E>): (a: A) => F\nexport function compose<A,B,C,D,E> (...fns: Chain4<A,E,B,C,D>): (a: A) => E\nexport function compose<A,B,C,D> (...fns: Chain3<A,D,B,C>): (a: A) => D\nexport function compose<A,B,C> (...fns: Chain2<A,C,B>): (a: A) => C\nexport function compose<A,B> (...fns: Chain1<A,B>): (a: A) => B\nexport function compose<A> (): (a: A) => A\nexport function compose(...fns: ((v:any)=>any)[]) {\n return (val:any) => (pipe as any)(val, ...fns);\n}\n\ntype Chain1<A,R> = [(v: A) => R];\ntype Chain2<A,R,B> = [...Chain1<A,B>, ...Chain1<B,R>];\ntype Chain3<A,R,B,C> = [...Chain1<A,B>, ...Chain2<B,R,C>];\ntype Chain4<A,R,B,C,D> = [...Chain1<A,B>, ...Chain3<B,R,C,D>];\ntype Chain5<A,R,B,C,D,E> = [...Chain1<A,B>, ...Chain4<B,R,C,D,E>];\ntype Chain6<A,R,B,C,D,E,F> = [...Chain1<A,B>, ...Chain5<B,R,C,D,E,F>];\ntype Chain7<A,R,B,C,D,E,F,G> = [...Chain1<A,B>, ...Chain6<B,R,C,D,E,F,G>];\ntype Chain8<A,R,B,C,D,E,F,G,H> = [...Chain1<A,B>, ...Chain7<B,R,C,D,E,F,G,H>];\ntype Chain9<A,R,B,C,D,E,F,G,H,I> = [...Chain1<A,B>, ...Chain8<B,R,C,D,E,F,G,H,I>];\n\n/**\n * Pass subscriber into a stream (or any arguments into any other function).\n *\n * This utility is mainly here for uses like:\n *\n * - `pipe(src, into(sink))`,\n * - `pipe(src, into(sink, conn))`,\n * - `pipe(src, into(restarting(sink)))`, etc.\n *\n * but can also be used for argument currying generally.\n *\n * @param args The arguments to pass to the stream (or other function)\n *\n * @returns a function that takes another function and calls it with the given args.\n *\n * @category Stream Consumers\n */\nexport function into<In extends any[], Out>(...args: In): (src: (...args: In) => Out) => Out {\n return src => src(...args);\n}\n","import { AnyFunction } from \"./types.ts\";\n\nexport function setMap<K, V>(map: { set(key: K, val: V): void; }, key: K, val: V) {\n map.set(key, val);\n return val;\n}\n\n/**\n * This class hides the implementation details of inheriting from Function in\n * the documentation. (By default, typedoc exposes all the inherited properties\n * and members, which we don't want. By inheriting from it instead of from\n * Function, we keep the documentation free of unimportant details.)\n */\n//@ts-ignore CallableObject<T> adheres to the constraint of T in its *implementation*\nexport interface CallableObject<T extends AnyFunction> extends T {\n /** @internal */ [Symbol.hasInstance](value: any): boolean;\n /** @internal */ apply(this: Function, thisArg: any, argArray?: any): any;\n /** @internal */ bind(this: Function, thisArg: any, ...argArray: any[]): any;\n /** @internal */ call(this: Function, thisArg: any, ...argArray: any[]): any;\n /** @internal */ toString(): string;\n}\n\nexport declare class CallableObject<T extends AnyFunction> extends Function {\n /** @internal */ protected constructor(fn: T);\n /** @internal */ declare length: number;\n /** @internal */ declare arguments: any;\n /** @internal */ declare caller: Function;\n /** @internal */ declare prototype: any;\n /** @internal */ declare name: string;\n}\n\nexport function CallableObject<T>(fn: T) { return Object.setPrototypeOf(fn, new.target.prototype); }\n\n// No need to have extra prototypes in the chain\nCallableObject.prototype = Function.prototype as any;","import { Context, current, makeCtx, swapCtx } from \"./ambient.ts\";\nimport { type RuleQueue, currentRule, ruleQueue, defaultQ } from \"./scheduling.ts\";\nimport { Job, OptionalCleanup, RecalcSource } from \"./types.ts\"\nimport { detached, getJob, makeJob } from \"./tracking.ts\";\nimport { Connection, Inlet, IsStream, Sink, Source, backpressure } from \"./streams.ts\";\nimport { setMap } from \"./utils.ts\";\nimport { isError, isValue, markHandled } from \"./results.ts\";\nimport { nullCtx } from \"./internals.ts\";\n\n/**\n * Error indicating a rule has attempted to write a value it indirectly\n * depends on, or which has already been read by another rule in the current\n * batch. (Also thrown when a cached function attempts to write a value at all,\n * directly or inidirectly.)\n *\n * @category Errors\n */\nexport class WriteConflict extends Error {}\n\n/**\n * Error indicating a rule has attempted to write a value it directly depends\n * on, or a cached function has called itself, directly or indirectly.\n *\n * @category Errors\n */\nexport class CircularDependency extends Error {}\n\nvar timestamp = 1;\n\n/** recalcWhen(fn): map fn -> signal */\nconst fntrackers = new WeakMap<Function, () => number>();\n\n/** recalcWhen(key, factory): map factory -> key -> signal */\nconst obtrackers = new WeakMap<Function, WeakMap<WeakKey, () => number>>();\n\nconst dirtyStack: Cell[] = [];\n\nfunction markDependentsDirty(cell: Cell) {\n // We don't set validThrough here because that's how we tell the cell's been read/depended on\n const latestSource = cell.latestSource = timestamp;\n for(; cell; cell = dirtyStack.pop()) {\n for (let sub=cell.subscribers; sub; sub = sub.nT) {\n const tgt = sub.tgt;\n if (tgt.latestSource >= latestSource) continue;\n tgt.latestSource = latestSource;\n if (tgt.flags & Is.Rule) (tgt.value.q as RuleQueue).add(tgt);\n if (tgt.subscribers) dirtyStack.push(tgt);\n }\n }\n}\n\n// The .compute for a cell whose value has been explicitly set\nfunction returnValue(this: Cell) {\n return this.value;\n}\n\n// The compute for a cell whose value is an explicit error\nfunction throwValue(this: Cell) {\n throw this.value;\n}\n\n/**\n * Cells that are known to be clean as of this timestamp, but have not been\n * marked as read yet (and whose sources might also not be marked read). This\n * lets us lazily determine if a cell's value has been depended on (i.e.\n * \"virtually read\") in this timestamp, even if it wasn't *actually* read.\n */\nconst notCaughtUp = [] as Cell[];\n\nconst enum Is {\n Rule = 1 << 0,\n Calc = 1 << 2,\n Dead = 1 << 3,\n Error = 1 << 4,\n Running = 1 << 5,\n Stream = 1 << 6,\n Mutable = 1 << 7,\n Computed = Rule | Calc,\n Variable = Computed | Mutable,\n}\n\ntype Subscription = {\n /** Source of the subscription */\n src: Cell\n nS: Subscription,\n pS: Subscription,\n\n /** Subscriber */\n tgt: Cell\n nT: Subscription,\n pT: Subscription,\n\n ts: number,\n\n /* stack for active subscriptions on sources */\n old: Subscription\n}\n\nvar freesubs: Subscription;\n\nfunction mksub(source: Cell, target: Cell) {\n let sub: Subscription = freesubs;\n if (sub) {\n freesubs = sub.old;\n sub.src = source; sub.nS = undefined; sub.pS = target.sources;\n sub.tgt = target; sub.nT = sub.pT = undefined;\n sub.ts = source.lastChanged; sub.old = source.adding;\n } else sub = {\n src: source, nS: undefined, pS: target.sources,\n tgt: target, nT: undefined, pT: undefined,\n ts: source.lastChanged, old: source.adding\n }\n // Add subscription to tail of target's sources\n if (target.sources) target.sources.nS = sub;\n target.sources = sub;\n // track that this source has had a subscription added during this calculation\n source.adding = sub;\n // Set up reciprocal subscription if needed\n if (target.subscribers || target.flags & Is.Rule) source.subscribe(sub);\n}\n\nfunction delsub(sub: Subscription) {\n sub.src.unsubscribe(sub);\n if (sub.nS) sub.nS.pS = sub.pS;\n if (sub.pS) sub.pS.nS = sub.nS;\n sub.src = sub.tgt = sub.nS = sub.pS = sub.nT = sub.pT = undefined;\n sub.old = freesubs;\n freesubs = sub;\n}\n\nconst sentinel = {} // a unique value for uniqueness checking\n\nexport class Cell {\n value: any = undefined // the value, or, for a rule, the `{q, rm}` struct\n validThrough = 0; // timestamp of most recent validation or recalculation\n lastChanged = 0; // timestamp of last value change\n latestSource = timestamp; // max lastChanged of this cell or any ancestor source\n flags = 0;\n ctx: Context = undefined;\n /** The subscription being added during the current calculation - used for uniqueness */\n adding: Subscription = undefined;\n /** Linked list of sources */\n sources: Subscription = undefined;\n /** Linked list of targets */\n subscribers: Subscription = undefined;\n\n /**\n * The computation to be performed (if {@link Is.Calc} or {@link Is.Rule})\n * or the setup/teardown for {@link Is.Stream}.\n */\n compute: (sub?: boolean) => any = returnValue;\n\n stream<T>(sink: Sink<T>, _conn?: Connection, inlet?: Inlet) {\n let lastValue = sentinel;\n Cell.mkRule(() => {\n const val = this.getValue();\n if (val !== lastValue) {\n const old = swapCtx(nullCtx);\n try { sink(lastValue = val); } finally { swapCtx(old); }\n }\n }, inlet ? ruleQueue(backpressure(inlet)) : defaultQ);\n return IsStream;\n }\n\n getValue() {\n if (arguments.length) return this.stream.apply(this, arguments as any);\n this.catchUp();\n const dep = current.cell;\n // Only create a dependency if our value can change\n if (dep && this.flags & Is.Variable) {\n if (this.flags & Is.Running) throw new CircularDependency(\"Cached function dependency cycle\");\n // See if we've already got a subscription node for the dependent\n let s = this.adding;\n if (!s || s.tgt !== dep) {\n // nope, it's new\n mksub(this, dep);\n } else {\n // Yep, see if it's a hangover from last time\n if (s.ts === -1) {\n // yep, mark it reused\n s.ts = this.lastChanged;\n if (s.nS) { // if not at end, move it\n s.nS.pS = s.pS;\n if (s.pS) s.pS.nS = s.nS;\n s.nS = undefined;\n s.pS = dep.sources;\n dep.sources.nS = s;\n dep.sources = s;\n }\n }\n // else it's already done, no need to do anything.\n }\n }\n if (this.flags & Is.Error) throw this.value;\n return this.value;\n }\n\n shouldWrite(changed: boolean) {\n const cell = current.cell || currentRule;\n if (cell) {\n // When a cell changes within a sweep (i.e. from an active rule or other\n // cell), we need to check if it's not a circular update or disallowed\n // side-effect. In such a case we bail out with an error, even if the\n // change is idempotent. (To avoid hiding value-dependent errors.)\n if (cell.flags & Is.Calc) throw new WriteConflict(\"Side-effects not allowed in cached functions\");\n if (this.adding && this.adding.tgt === cell) throw new CircularDependency(\"Can't update direct dependency\");\n if (this.validThrough === timestamp || this.hasBeenRead()) throw new WriteConflict(\"Value already used\");\n } else if (changed) {\n // We are *not* in a sweep, but *did* have a change. So we may need to advance\n // the timestamp, if we might have had readers in the current one.\n if (this.validThrough === timestamp || notCaughtUp.length) { ++timestamp; notCaughtUp.length = 0; }\n } else {\n // Not in a sweep and no change -- no need to actually write anything\n return false;\n }\n // If we changed as of the current timestamp, we're already dirty\n // Otherwise, we should flag our subscribers as such.\n (this.lastChanged === timestamp) || markDependentsDirty(this);\n // If we have sources, reset the subscription timestamp of the first one\n // to force a recalculation on our next catchUp().\n if (this.sources) this.sources.ts = 0;\n return true;\n }\n\n setValue(val: any, isErr: boolean) {\n if (this.shouldWrite(val !== this.value || isErr !== !!(this.flags & Is.Error))) {\n this.value = val;\n this.lastChanged = timestamp;\n this.flags = isErr ? this.flags | Is.Error : this.flags & ~Is.Error;\n }\n // We always reset the compute here because we might have been in the\n // Calc state. But we don't clear the Calc flag because we might need\n // any previous sources to be released or unsubscribed. (Which will\n // happen on our next recalc.)\n this.compute = isErr ? throwValue : returnValue;\n }\n\n setCalc(compute: () => any) {\n if (this.shouldWrite(compute !== this.compute)) {\n this.flags |= Is.Calc;\n this.compute = compute;\n this.ctx ||= makeCtx(null, this);\n }\n }\n\n hasBeenRead() {\n if (notCaughtUp.length) {\n for(const cell of notCaughtUp) cell.catchUp();\n notCaughtUp.length = 0;\n }\n return this.validThrough === timestamp;\n }\n\n catchUp(): void {\n const {validThrough} = this;\n if (validThrough === timestamp) return;\n this.validThrough = timestamp;\n if (!(this.flags & Is.Computed)) return;\n if (this.sources) {\n for(let sub=this.sources; sub; sub = sub.nS) {\n const s = sub.src;\n // changed since our last compute? we're definitely dirty\n if (sub.ts !== s.lastChanged) return this.doRecalc();\n // if source is clean, skip it (most should be)\n // (note: only cells w/subscribers can be trusted as to their\n // latestSource, as cacheds with no subscribers don't get\n // notified by their upstreams)\n if (s.subscribers && s.latestSource <= validThrough) continue;\n // not a simple yes or no -- \"it's complicated\" -- so recurse\n s.catchUp();\n if (s.lastChanged > validThrough) {\n return this.doRecalc();\n }\n }\n // If we got to this point, we didn't need to recalc, but that means\n // none of our sources actually *changed*, despite at least one being\n // dirty. But that means we \"virtually\" read the clean values and\n // therefore depended on them... which means if they get written to,\n // either the timestamp must change or the write must be blocked.\n //\n // So we put them on our notCaughtUp list, in order to prevent rules\n // from changing them (or their sources) in the same timestamp, and\n // so that non-rule writes will know to update the timestamp.\n for(let sub=this.sources; sub; sub = sub.nS) {\n if (sub.src.validThrough !== timestamp) notCaughtUp.push(sub.src);\n }\n } else return this.doRecalc();\n }\n\n doRecalc() {\n const oldCtx = swapCtx(this.ctx);\n for(let sub = this.sources; sub; sub = sub.nS) {\n sub.ts = -1; // mark stale for possible reuse\n // attach sub to its source, so we can look it up\n sub.old = sub.src.adding;\n sub.src.adding = sub;\n this.sources = sub;\n }\n this.flags |= Is.Running;\n try {\n if (this.flags & Is.Calc) {\n try {\n const future = this.compute();\n if (future !== this.value || !this.lastChanged || this.flags & Is.Error) {\n this.value = future;\n this.lastChanged = timestamp;\n }\n this.flags &= ~Is.Error;\n } catch(e) {\n this.flags |= Is.Error\n this.value = e;\n this.lastChanged = timestamp;\n }\n } else {\n const {job} = this.ctx;\n job.restart();\n try {\n job.must(this.compute());\n this.lastChanged = timestamp;\n } catch (e) {\n this.disposeRule();\n throw e;\n }\n }\n } finally {\n this.flags &= ~Is.Running;\n swapCtx(oldCtx);\n // reset this.src to the head of the list, dropping stale subscriptions\n let head: Subscription;\n for(let sub = this.sources; sub; ) {\n const pS = sub.pS;\n sub.src.adding = sub.old;\n sub.old = undefined;\n if (sub.ts === -1) delsub(sub); else head = sub;\n sub = pS;\n }\n this.sources = head;\n if (!head) {\n // without sources, we can never change or be invalidated, so\n // revert to settable value() or permanent constant\n this.flags &= ~Is.Calc;\n }\n if (this.flags & Is.Dead) this.disposeRule();\n }\n }\n\n disposeRule() {\n this.ctx.job.end();\n this.flags |= Is.Dead;\n (this.value.q as RuleQueue).delete(this);\n this.value.rm();\n if (current !== this.ctx) {\n for(let s=this.sources; s;) { let nS = s.nS; delsub(s); s = nS; }\n this.sources = undefined;\n }\n }\n\n subscribe(sub: Subscription) {\n if (!this.subscribers) {\n if (this.flags & Is.Calc) {\n for(let s=this.sources; s; s = s.nS) s.src.subscribe(s);\n }\n if (this.flags & Is.Stream) this.compute(true); // subscribe to source\n }\n if (this.subscribers !== sub && !sub.pT) { // avoid adding already-added subs\n sub.nT = this.subscribers;\n if (this.subscribers) this.subscribers.pT = sub;\n this.subscribers = sub;\n }\n }\n\n unsubscribe(sub: Subscription) {\n if (sub.nT) sub.nT.pT = sub.pT;\n if (sub.pT) sub.pT.nT = sub.nT;\n if (this.subscribers === sub) this.subscribers = sub.nT;\n if (!this.subscribers) {\n if (this.flags & Is.Calc) {\n for(let s=this.sources; s; s = s.nS) s.src.unsubscribe(s);\n }\n if (this.flags & Is.Stream) this.compute(false); // unsubscribe from source\n }\n }\n\n static mkValue<T>(val: T) {\n const cell = new Cell;\n cell.flags = Is.Mutable;\n cell.value = val;\n cell.lastChanged = timestamp;\n return cell;\n }\n\n static mkStream<T>(src: Source<T>, val?: T) {\n const cell = this.mkValue(val);\n cell.flags |= Is.Stream;\n cell.ctx = makeCtx();\n const write = (v: T) => { cell.setValue(v, false); cell.compute = compute; };\n let job: Job<void>;\n const compute = cell.compute = (sub: boolean) => {\n if (!sub) {\n // Last subscriber is gone, so reset to default value\n cell.value = val; cell.flags &= ~Is.Error;\n job?.end(); // unsubscribe from source\n return\n }\n if (job) return;\n job = cell.ctx.job = makeJob<void>().do(r => {\n if (isError(r)) {\n cell.setValue(markHandled(r), true);\n } else if (isValue(r)) {\n cell.setValue(val, false);\n }\n cell.compute = compute;\n cell.ctx.job = job = undefined;\n });\n const old = swapCtx(cell.ctx);\n try {\n src(write, job);\n } catch(e) {\n job.end();\n throw e;\n } finally {\n swapCtx(old);\n }\n }\n return cell;\n }\n\n recalcWhen(src: RecalcSource): void;\n recalcWhen<T extends WeakKey>(key: T, factory: (key: T) => RecalcSource): void;\n recalcWhen<T extends WeakKey>(fnOrKey: T | RecalcSource, fn?: (key: T) => RecalcSource) {\n let trackers: WeakMap<WeakKey, () => number> = fn ?\n obtrackers.get(fn) || setMap(obtrackers, fn, new WeakMap) :\n fntrackers\n ;\n let signal = trackers.get(fnOrKey);\n if (!signal) {\n const src = fn ? fn(<T>fnOrKey) : <RecalcSource> fnOrKey;\n let ct = 0;\n const c = Cell.mkStream(s => (src(() => s(++ct)), IsStream), ct);\n trackers.set(fnOrKey, signal = c.getValue.bind(c));\n }\n signal(); // Subscribe to the cell\n }\n\n static mkCached<T>(compute: () => T) {\n const cell = new Cell;\n cell.compute = compute;\n cell.ctx = makeCtx(null, cell);\n cell.flags = Is.Calc;\n return cell;\n }\n\n static mkRule(fn: (stop: () => void) => OptionalCleanup, q: RuleQueue) {\n var cell = new Cell, job = makeJob();\n const stop = cell.disposeRule.bind(cell);\n cell.value = {q, rm: getJob().release(stop)};\n cell.compute = fn.bind(null, stop);\n cell.ctx = makeCtx(job, cell);\n cell.flags = Is.Rule;\n q.add(cell);\n return stop;\n }\n}\n","import { defer } from \"./defer.ts\";\nimport { RuleQueue, currentRule, defaultQ, ruleQueue } from \"./scheduling.ts\";\nimport { AnyFunction, DisposeFn, OptionalCleanup } from \"./types.ts\";\nimport { Cell } from \"./cells.ts\";\nimport { CallableObject, setMap } from \"./utils.ts\";\n\n/**\n * A decorator function that supports both TC39 and \"legacy\" decorator protocols\n *\n * @template F the type of method this decorator can decorate. If the method\n * doesn't conform to this type, compile-time type checks will fail.\n *\n * @category Types and Interfaces\n */\nexport type GenericMethodDecorator<F extends AnyFunction> = {\n /** TC39 Method Decorator @hidden */\n (fn: F, ctx?: {kind: \"method\"}): F;\n\n /** Legacy Method Decorator @hidden */\n (proto: object, name: string|symbol, desc?: {value?: F}): void;\n}\n\n/**\n * The interface provided by {@link rule}, and other {@link rule.factory}()\n * functions.\n*\n* @category Types and Interfaces\n*/\nexport interface RuleFactory {\n /**\n * @inheritdoc rule factory tied to a specific scheduler. See {@link rule} for\n * more details.\n */\n (fn: (stop: DisposeFn) => OptionalCleanup): DisposeFn;\n\n /**\n * Stop the currently-executing rule, or throw an error if no rule is\n * currently running.\n */\n stop(): void\n\n /**\n * Observe a condition and apply an action.\n *\n * This is roughly equivalent to `rule(() => { if (condition()) return\n * action(); })`, except that the rule is *only* rerun if the `action`'s\n * dependencies change, *or* the truthiness of `condition()` changes. It\n * will *not* be re-run if only the dependencies of `condition()` have\n * changed, without affecting its truthiness.\n *\n * This behavior can be important for rules that nest other rules, have\n * cleanups, fire off tasks, etc., as it may be wasteful to constantly tear\n * them down and set them back up if the enabling condition is a calculation\n * with frequently-changing dependencies.\n */\n if(condition: () => any, action: () => OptionalCleanup): DisposeFn\n\n /**\n * Decorate a method to behave as a rule, e.g.\n *\n * ```ts\n * const animate = rule.factory(requestAnimationFrame);\n *\n * class Draggable {\n * ⁣@animate.method\n * trackPosition(handleTop: number, handleLeft: number) {\n * const {clientX, clientY} = lastMouseEvent();\n * this.element.style.top = `${clientY - handleTop}px`;\n * this.element.style.left = `${clientX - handleLeft}px`;\n * }\n * }\n *\n * // Start running the method in an animation frame for every change to\n * // lastMouseEvent, until the current job ends:\n * someDraggable.trackPosition(top, left);\n * ```\n *\n * Each time it's (explicitly) called, the decorated method will start a new\n * rule, which will repeatedly run the method body (with the original\n * arguments and `this`) whenever its dependencies change, according to the\n * schedule defined by the rule factory. (So e.g. `@rule.method` will\n * update on the microtask after a change, etc.)\n *\n * The decorated method will always return a {@link DisposeFn} to let you\n * explicitly stop the rule before the current job end. But if the original\n * method body doesn't return a dispose function of its own, TypeScript will\n * consider the method to return void, unless you explicitly declare its\n * return type to be `DisposeFn | void`.\n *\n * Also note that since rule methods can accept arbitrary parameters, they\n * do not receive a `stop` parameter, and must therefore use {@link\n * RuleFactory.stop rule.stop}() if they wish to terminate themselves.\n */\n readonly method: GenericMethodDecorator<(...args: any[]) => OptionalCleanup>\n\n /**\n * Return a rule factory for the given scheduling function, that you can\n * then use to make rules that run in a specific time frame.\n *\n * ```ts\n * // `animate` will now create rules that run during animation fames\n * const animate = rule.factory(requestAnimationFrame);\n *\n * animate(() => {\n * // ... do stuff in an animation frame when signals used here change\n * })\n * ```\n *\n * (In addition to being callable, the returned function is also a\n * {@link RuleFactory}, and thus has a `.method` decorator, `.if()` method,\n * and so on.)\n *\n * @param scheduleFn A single-argument scheduling function (such as\n * requestAnimationFrame, setImmediate, or queueMicrotask). The rule\n * scheduler will call it from time to time with a single callback. The\n * scheduling function should then arrange for that callback to be invoked\n * *once* at some future point, when it is the desired time for all pending\n * rules on that scheduler to run.\n *\n * @returns A {@link RuleFactory}, like {@link rule}. If called with the\n * same scheduling function more than once, it returns the same factory.\n *\n */\n factory(scheduleFn: (cb: () => unknown) => unknown): RuleFactory\n}\n\nclass RF extends CallableObject<(fn: (stop: DisposeFn) => OptionalCleanup) => DisposeFn> implements RuleFactory {\n\n constructor(q: RuleQueue) {\n super((fn: (stop: DisposeFn) => OptionalCleanup): DisposeFn => Cell.mkRule(fn, q))\n }\n\n stop() {\n if (currentRule) return currentRule.disposeRule();\n throw new Error(\"No rule active\");\n }\n if(condition: () => any, action: () => OptionalCleanup): DisposeFn {\n const cond = Cell.mkCached(() => !!condition());\n return this(() => cond.getValue() ? action() : undefined);\n }\n\n get method(): GenericMethodDecorator<(...args: any[]) => OptionalCleanup> {\n const self = this;\n return (\n fn: object | ((...args: any[]) => OptionalCleanup),\n _ctxOrName?: any,\n desc?: { value?: (...args: any[]) => OptionalCleanup; }\n ) => {\n if (desc) return void (desc.value = this.method(desc.value));\n return function (this: any, ...args: any[]): DisposeFn {\n return self(() => (fn as any).apply(this, args));\n };\n }\n }\n\n factory(scheduleFn: (cb: () => unknown) => unknown): RuleFactory {\n return factories.get(scheduleFn) || setMap(factories, scheduleFn, new RF(ruleQueue(scheduleFn)));\n }\n}\n\n\nconst factories = new WeakMap<Function, RuleFactory>();\n\n/**\n * Subscribe a function to run every time certain values change.\n *\n * The function is run asynchronously, first after being created, then again\n * after there are changes in any of the values or cached functions it read\n * during its previous run.\n *\n * The created subscription is tied to the currently-active job (which may be\n * another rule). So when that job is ended or restarted, the rule will be\n * terminated automatically. You can also terminate it early by calling the\n * \"stop\" function that is both passed to the rule function and returned by\n * `rule()`.\n *\n * Note: this function will throw an error if called without an active job. If\n * you need a standalone rule, use {@link detached}.run to wrap the\n * call to rule.\n *\n * @param fn The function that will be run each time its dependencies change.\n * The function will be run in a restarted job each time, with any resources\n * used by the previous run being cleaned up. The function is passed a single\n * argument: a function that can be called to terminate the rule. The function\n * should return a cleanup function or void.\n *\n * @returns A function that can be called to terminate the rule.\n *\n * @category Signals\n */\nexport const rule: ((action: (stop: DisposeFn) => OptionalCleanup) => DisposeFn) & RuleFactory = (\n RF.prototype.factory(defer)\n)\n\n/**\n * Synchronously run any pending rules tied to a specific schedule.\n *\n * (Note: \"pending\" rules are ones with at least one changed ancestor\n * dependency; this doesn't mean they will actually *do* anything, since\n * intermediate cached() function results might end up unchanged.)\n *\n * You should normally only need to call this when you need to *force*\n * side-effects to occur within a specific *synchronous* timeframe, e.g. if\n * rules need to be able to cancel a synchronous event or continue an IndexedDB\n * transaction. (Otherwise, this is really only useful for testing.)\n *\n * @param scheduleFn The scheduler used to create the rule factory you wish to\n * run pending rules for. If not given, the default {@link rule}() factory is\n * targeted.\n *\n * @category Signals\n */\nexport function runRules(scheduleFn?: (cb: () => unknown) => unknown) {\n (scheduleFn ? ruleQueue(scheduleFn) : defaultQ).flush();\n}\n","import { current, freeCtx, makeCtx, swapCtx } from \"./ambient.ts\";\nimport { PlainFunction, Yielding, RecalcSource, AnyFunction } from \"./types.ts\";\nimport { Cell } from \"./cells.ts\";\nimport { rule } from \"./rules.ts\";\nimport { reject, resolve } from \"./results.ts\";\nimport { UntilMethod } from \"./sinks.ts\";\nimport { SignalSource, Source } from \"./streams.ts\";\nimport { CallableObject } from \"./utils.ts\";\n\nexport { rule, runRules, type GenericMethodDecorator, type RuleFactory } from \"./rules.ts\"\nexport { WriteConflict, CircularDependency } from \"./cells.ts\";\n\n/**\n * An observable value, as a zero-argument callable with extra methods.\n *\n * In addition to being callable, signals also offer a `.value` getter, and\n * implement the standard JS methods `.toString()`, `.valueOf()`, and\n * `.toJSON()` in such a way that they reflect the signal's contents rather than\n * the signal itself.\n *\n * Signals also implement the {@link Source} interface, and can thus be\n * subscribed to. Subscribers receive the current value first, and then any\n * changes thereafter. They can be waited on by {@link until}(), in which case\n * the calling job resumes when the signal's value is truthy.\n *\n * You can also transform a signal to a {@link Writable} by calling its\n * .{@link Signal.withSet withSet}() method, or create a writable value using\n * {@link value}().\n *\n * @category Types and Interfaces\n */\nexport interface Signal<T> extends SignalSource<T>, UntilMethod<T> {\n /**\n * The current value\n *\n * @category Reading\n */\n readonly value: T\n\n /** Current value @hidden */\n valueOf() : T\n\n /** Current value as a string @hidden */\n toString(): string\n\n /** The current value @hidden */\n toJSON() : T\n\n /**\n * Get the signal's current value, without adding the signal as a dependency\n *\n * (This is exactly equivalent to calling {@link peek}(signal), and exists\n * here mainly for interop with other signal frameworks.)\n *\n * @category Reading */\n peek(): T;\n\n /** Get a read-only version of this signal @category Reading */\n asReadonly(): Signal<T>\n\n /** New writable signal with a custom setter @category Writing */\n withSet(set: (v: T) => unknown): Writable<T>\n\n /** @hidden */\n \"uneventful.until\"(): Yielding<T>;\n}\n\n/** @internal */\nexport class SignalImpl<T> extends CallableObject<SignalSource<T>> implements Signal<T> {\n constructor(protected _c: Cell) { super(_c.getValue.bind(_c)); }\n get value() { return this(); }\n valueOf() { return this(); }\n toString() { return \"\" + this(); }\n toJSON() { return this(); }\n peek() { return peek(this as () => T); };\n asReadonly(): Signal<T> { return this; }\n withSet(set: (v: T) => unknown): Writable<T> {\n return Object.assign(new WritableImpl<T>(this._c), {set});\n }\n\n *\"uneventful.next\"(): Yielding<T> {\n return yield (r => {\n let seen = false, res: T;\n rule(stop => {\n try { res = this(); } catch(e) { stop(); reject(r, e); }\n if (seen) { stop(); resolve(r, res); }\n seen = true;\n })\n });\n }\n\n *\"uneventful.until\"(): Yielding<T> {\n return yield (r => {\n let res: T;\n try { res = this(); } catch(e) { reject(r, e); return; }\n if (res) return resolve(r, res);\n rule(stop => {\n try { res = this(); } catch(e) { stop(); reject(r,e); }\n if (res) { stop(); resolve(r, res); }\n });\n });\n }\n}\n\n/**\n * A {@link Signal} with a {@link Writable.set | .set()} method and writable\n * {@link Writable.value | .value} property.\n *\n * @category Types and Interfaces\n */\nexport interface Writable<T> extends Signal<T> {\n /**\n * Set the current value. (Note: this is a bound method so it can be used\n * as a callback.)\n *\n * @category Writing\n */\n readonly set: (val: T) => void;\n\n get value(): T\n\n /** Set the current value */\n set value(val: T);\n}\n\n/** @internal */\nexport class WritableImpl<T> extends SignalImpl<T> implements Writable<T> {\n get value() { return this(); }\n set value(val: T) { this.set(val); }\n set = (val: T) => { this._c.setValue(val, false); }\n asReadonly(): Signal<T> {\n return new SignalImpl<T>(this._c);\n }\n}\n\n/**\n * A writable signal that can be set to either a value or an expression.\n *\n * Like a spreadsheet cell, a configurable signal can contain either a value or\n * a formula. If you .set() a value or change the .value property of the\n * signal, the formula is cleared. Conversely, if you set a formula with\n * .setf(), then the value is calculated using that formula from then on, until\n * another formula is set, or the value is changed directly again.\n *\n * @category Types and Interfaces\n */\nexport interface Configurable<T> extends Writable<T> {\n /**\n * Set a formula that will be used to calculate the signal's value. If it\n * uses the value of other signals, this signal's value will be recalculated\n * when they change.\n *\n * @category Writing\n */\n setf(expr: () => T): this;\n}\n\n/** @internal */\nexport class ConfigurableImpl<T> extends WritableImpl<T> implements Configurable<T> {\n setf(expr: () => T): this {\n this._c.setCalc(expr);\n return this;\n }\n}\n\n/**\n * Create a {@link Configurable} signal with the given inital value\n *\n * @category Signals\n */\nexport function value<T>(val?: T): Configurable<T> {\n const cell = Cell.mkValue(val);\n return new ConfigurableImpl<T>(cell);\n}\n\n/**\n * Create a cached version of a function. The returned callable is also a\n * {@link Signal}.\n *\n * Note: If the supplied function has a non-zero `.length` (i.e., it explicitly\n * takes arguments), it is assumed to be a {@link Source}, and the second\n * calling signature below will apply, even if TypeScript doesn't see it that\n * way!)\n *\n * @category Signals\n */\nexport function cached<T>(compute: () => T): Signal<T>;\n\n/**\n * If the supplied function has a non-zero `.length` (i.e., it explicitly takes\n * arguments), it is assumed to be a {@link Source}, and the second argument is\n * a default value for the created signal to use as default value until the\n * source produces a value.\n *\n * The source will be subscribed *only* while the signal is subscribed as a\n * stream, or observed (directly or indirectly) by a rule. While subscribed,\n * the signal will update itself with the most recent value produced by the\n * source, triggering rules or events as appropriate if the value changes. When\n * the signal is once again unobserved (or if the source ends without an error),\n * its value will revert to the supplied default.\n *\n * If the source ends *with* an error, however, then the cached function will\n * throw that error whenever called, until/unless it becomes unobserved again.\n * (And thus reverts to the default value once more.)\n *\n * @param source A {@link Source} providing data which will become this signal's\n * value\n * @param defaultVal The value to use when the signal is unobserved or waiting for\n * the first item from the source.\n */\nexport function cached<T>(source: Source<T>, defaultVal?: T): Signal<T>;\nexport function cached<T extends Signal<any>>(signal: T): T\nexport function cached<T>(compute: Source<T> | (() => T), initVal?: T): Signal<T> {\n if (compute instanceof SignalImpl) return compute;\n return new SignalImpl<T>(\n compute.length ? Cell.mkStream(compute as Source<T>, initVal) : Cell.mkCached(compute as () => T)\n );\n}\n\n/**\n * Call a function without creating a dependency on any signals it reads. (Like\n * {@link Signal.peek}, but for any function with any arguments.)\n *\n * You can also pass in any arguments the function takes, and the function's\n * return value is returned.\n *\n * (Note: Typed overloads are not supported: TypeScript will use the function's\n * *last* overload for argument-typing purposes. If you need to call a function\n * with a specific overload, wrap the function with {@link action}() instead, and\n * then TypeScript will be able to detect which overload you're using.)\n *\n * @returns The result of calling `fn(..args)`\n *\n * @category Signals\n */\nexport function peek<F extends PlainFunction>(fn: F, ...args: Parameters<F>): ReturnType<F> {\n if (!current.cell) return fn(...args);\n const old = swapCtx(makeCtx(current.job));\n try { return fn.apply(null, args); } finally { freeCtx(swapCtx(old)); }\n}\n\n/**\n * Arrange for the current signal or rule to recalculate on demand\n *\n * This lets you interop with systems that have a way to query a value and\n * subscribe to changes to it, but not directly produce a signal. (Such as\n * querying the DOM state and using a MutationObserver.)\n *\n * By calling this with a {@link Source} or {@link RecalcSource}, you arrange\n * for it to be subscribed, if and when the call occurs in a rule or a cached\n * function that's in use by a rule (directly or indirectly). When the source\n * emits a value, the signal machinery will invalidate the caching of the\n * function or rule, forcing a recalculation and subsequent rule reruns, if\n * applicable.\n *\n * Note: you should generally only call the 1-argument version of this function\n * with \"static\" sources - i.e. ones that won't change on every call. Otherwise,\n * you will end up creating new signals each time, subscribing and unsubscribing\n * on every call to recalcWhen().\n *\n * If the source needs to reference some object, it's best to use the 2-argument\n * version (i.e. `recalcWhen(someObj, factory)`, where `factory` is a function\n * that takes `someObj` and returns a suitable {@link RecalcSource}.)\n *\n * @remarks\n * recalcWhen is specifically designed so that using it does not pull in any\n * part of Uneventful's signals framework, in the event a program doesn't\n * already use it. This means you can use it in library code to provide signal\n * compatibility, without adding bundle bloat to code that doesn't use signals.\n *\n * @category Signals\n */\nexport function recalcWhen(src: RecalcSource): void;\n/**\n * Two-argument variant of recalcWhen\n *\n * In certain circumstances, you may wish to use recalcWhen with a source\n * related to some object. You could call recalcWhen with a closure, but that\n * would create and discard signals on every call. So this 2-argument version\n * lets you avoid that by allowing the use of an arbitrary object as a key,\n * along with a factory function to turn the key into a {@link RecalcSource}.\n *\n * @param key an object to be used as a key\n *\n * @param factory a function that will be called with the key to obtain a\n * {@link RecalcSource}. (Note that this factory function must also be a static\n * function, not a closure, or the same memory thrash issue will occur!)\n */\nexport function recalcWhen<T extends WeakKey>(key: T, factory: (key: T) => RecalcSource): void;\nexport function recalcWhen<T extends WeakKey>(fnOrKey: T | RecalcSource, fn?: (key: T) => RecalcSource) {\n current.cell?.recalcWhen<T>(fnOrKey as T, fn);\n}\n\n/**\n * Wrap a function (or decorate a method) so that signals it reads are not added\n * as dependencies to the current rule (if any). (Basically, it's shorthand for\n * wrapping the function or method body in a giant call to {@link peek}().)\n *\n * So, instead of writing an action function like this:\n *\n * ```ts\n * function outer(arg1, arg2) {\n * return peek(() => {\n * // reactive values used here will not be added to the running rule\n * })\n * }\n * ```\n * you can just write this:\n * ```ts\n * const outer = action((arg1, arg2) => {\n * // reactive values used here will not be added to the running rule\n * });\n * ```\n * or this:\n * ```ts\n * class Something {\n * ⁣⁣@action // auto-detects TC39 or legacy decorators\n * someMethod(arg1) {\n * // reactive values used here will not be added to the running rule\n * }\n * }\n * ```\n *\n * @param fn The function to wrap. It can take any arguments or return value,\n * and overloads are supported. However, any non-standard properties the\n * function may have had will *not* be present on the wrapped function, even if\n * TypeScript will act as if they are!\n *\n * @returns A wrapped version of the function that passes through its arguments\n * to the original function, while running with dependency tracking suppressed\n * (as with {@link peek}()).\n *\n * @category Signals\n */\nexport function action<F extends AnyFunction>(fn: F): F;\n\n/** @hidden TC39 Decorator protocol */\nexport function action<F extends AnyFunction>(fn: F, ctx: {kind: \"method\"}): F;\n\n/** @hidden Legacy Decorator protocol */\nexport function action<F extends AnyFunction, D extends {value?: F}>(\n clsOrProto: any, name: string|symbol, desc: D\n): D\n\nexport function action<F extends AnyFunction, D extends {value?: F}>(fn: F, _ctx?: any, desc?: D): D | F {\n if (desc) return {...desc, value: action(desc.value)};\n return <F> function (this: ThisParameterType<F>) {\n if (!current.cell) return fn.apply(this, arguments as any);\n const old = swapCtx(makeCtx(current.job));\n try { return fn.apply(this, arguments as any); } finally { freeCtx(swapCtx(old)); }\n }\n}\n","import { current, freeCtx, makeCtx, swapCtx } from \"./ambient.ts\";\nimport { getJob, makeJob } from \"./tracking.ts\";\nimport { AnyFunction, Job, OptionalCleanup, StartFn, StartObj, Yielding } from \"./types.ts\";\n\n/**\n * Add a cleanup function to the active job. Non-function values are ignored.\n * Equivalent to {@link getJob}().{@link Job.must must}() -- see\n * {@link Job.must}() for more details.\n *\n * @category Jobs\n */\nexport function must<T>(cleanup?: OptionalCleanup<T>): Job<T> {\n return (getJob() as Job<T>).must(cleanup);\n}\n\n/**\n * Start a nested job within the currently-active job. (Shorthand for\n * {@link getJob}().{@link Job.start start}(...).)\n *\n * This function can be called with zero, one, or two arguments:\n *\n * - When called with zero arguments, the new job is returned without any other\n * initialization.\n *\n * - When called with one argument that's a function (either a {@link SyncStart}\n * or {@link AsyncStart}): the function is run inside the new job and receives\n * it as an argument. It can return a {@link Yielding} iterator (such as a\n * generator or job), a promise, or void. A returned iterator or promise will\n * be treated as if the method was called with that to begin with; a returned\n * job will be awaited and its result transferred to the new job\n * asynchronously. A returned function will be added to the job via `must()`.\n *\n * - When called with one argument that's a {@link Yielding} iterator (such as a\n * generator or an existing job): it's attached to the new job and executed\n * asynchronously. (Starting in the next available microtask.)\n *\n * - When called with one argument that's a Promise, it's converted to a job\n * that will end when the promise settles. The resulting job is returned.\n *\n * - When called with two arguments -- a \"this\" object and a function -- it\n * works the same as one argument that's a function, except the function is\n * bound to the supplied \"this\" before being called.\n *\n * This last signature is needed because you can't make generator arrows in JS\n * yet: if you want to start() a generator function bound to the current\n * `this`, you'll want to use `.start(this, function*() { ...whatever })`.\n *\n * (Note, however, that TypeScript and/or VSCode may require that you give\n * such a function an explicit `this` parameter (e.g. `.start(this, function\n * *(this) {...}));`) in order to correctly infer types inside a generator\n * function.)\n *\n * In any of the above cases, if a supplied function throws an error while\n * starting, the new job will be ended, and the error synchronously re-thrown.\n *\n * @returns the created {@link Job}\n *\n * @category Jobs\n */\nexport function start<T>(init?: StartFn<T> | StartObj<T>): Job<T>;\n\n/**\n * The two-argument variant of start() allows you to pass a \"this\" object that\n * will be bound to the initialization function. (It's mostly useful for\n * generator functions, since generator arrows aren't a thing yet.)\n */\nexport function start<T, This>(thisArg: This, fn: StartFn<T, This>): Job<T>;\nexport function start<T, This>(init: StartFn<T>|StartObj<T>|This, fn?: StartFn<T, This>) {\n return getJob().start(init as This, fn);\n}\n\n/**\n * Is there a currently active job? (i.e., can you safely use {@link must}(),\n * or {@link getJob}() right now?)\n *\n * @category Jobs\n */\nexport function isJobActive() { return !!current.job; }\n\n\nconst timers = new WeakMap<Job,\n ReturnType<typeof setTimeout> | // current timeout\n undefined | // no timeout set since job was last restarted (if ever)\n null // current timeout is 0, aka explicit no-timeout\n>();\n\n/**\n * Set the cancellation timeout for a job.\n *\n * When the timeout is reached, the job is canceled (throwing\n * {@link CancelError} to any waiting promises or jobs), unless a new timeout\n * is set before then. You may set a new timeout value for a job as many times\n * as desired. A timeout value of zero disables the timeout. Timers are\n * disposed of if the job is canceled or restarted.\n *\n * @param ms Optional: Number of milliseconds after which the job will be\n * canceled. Defaults to zero if not given.\n *\n * @param job Optional: the job to apply the timeout to. If none is given, the\n * active job is used.\n *\n * @returns the job to which the timeout was added or removed.\n *\n * @category Scheduling\n */\nexport function timeout<T>(ms: number, job?: Job<T>): Job<T>;\nexport function timeout(ms = 0, job: Job = getJob()) {\n let timer = timers.get(job);\n if (timer) {\n clearTimeout(timer);\n } else if (timer === undefined && !job.result()) {\n // no timeout has been set since job was last restarted,\n // so we need to arrange to clear it\n job.must(timeout.bind(null, 0, job));\n }\n if (job.result()) {\n // allow restarted timer to set a new must()\n timers.delete(job);\n } else if (ms) {\n timers.set(job, setTimeout(() => { timers.set(job, null); job.end(); }, ms));\n } else {\n timers.set(job, null); // Zero = cancel timeout, but don't duplicate must() if called again\n }\n return job;\n}\n\nconst abortSignals = new WeakMap<Job, AbortSignal>();\n\n/**\n * Get an AbortSignal that aborts when the job ends or is restarted.\n *\n * @param job Optional: the job to get an AbortSignal for. If none is given,\n * the active job is used.\n *\n * @returns the AbortSignal\n *\n * @category Jobs\n */\nexport function abortSignal(job: Job = getJob()) {\n let signal = abortSignals.get(job);\n if (!signal) {\n const ctrl = new AbortController;\n signal = ctrl.signal;\n job.do(() => { abortSignals.set(job, null); ctrl.abort(); });\n abortSignals.set(job, signal);\n if (job.result()) ctrl.abort();\n }\n return signal;\n}\n\n/**\n * Wrap a function in a {@link Job} that restarts each time the resulting\n * function is called, thereby canceling any nested jobs and cleaning up any\n * resources used by previous calls. (This can be useful for such things as\n * canceling an in-progress search when the user types more text in a field.)\n *\n * The restarting job will be ended when the job that invoked `restarting()`\n * is finished, canceled, or restarted. Calling the wrapped function after its\n * job has ended will result in an error. You can wrap any function any number\n * of times: each call to `restarting()` creates a new, distinct \"restarting\n * job\" and function wrapper to go with it.\n *\n * @param task (Optional) The function to be wrapped. This can be any function:\n * the returned wrapper function will match its call signature exactly, including\n * overloads. (So for example you could wrap the {@link start} API via\n * `restarting(start)`, to create a function you can pass job-start functions to.\n * When called, the function would cancel any outstanding job from a previous\n * call, and start the new one in its place.)\n *\n * @returns A function of identical type to the input function. If no input\n * function was given, the returned function will just take one argument (a\n * zero-argument function optionally returning a {@link CleanupFn}).\n *\n * @category Jobs\n */\nexport function restarting<F extends AnyFunction>(task: F): F\nexport function restarting(): (task: () => OptionalCleanup<never>) => void\nexport function restarting<F extends AnyFunction>(task?: F): F {\n const outer = getJob(), inner = makeJob<never>(outer), {end} = inner;\n task ||= <F>((f: () => OptionalCleanup<never>) => { inner.must(f()); });\n inner.asyncCatch(e => outer.asyncThrow(e));\n return <F>function(this: any) {\n inner.restart().must(outer.release(end));\n const old = swapCtx(makeCtx(inner));\n try { return task.apply(this, arguments as any); }\n catch(e) { inner.restart(); throw e; }\n finally { freeCtx(swapCtx(old)); }\n };\n}\n\n/**\n * Wrap an argument-taking function so it will run in (and returns) a new Job\n * when called.\n *\n * This lets you avoid the common pattern of needing to write your functions or\n * methods like this:\n *\n * ```ts\n * function outer(arg1, arg2) {\n * return start(function*() {\n * // ...\n * })\n * }\n * ```\n * and instead write them like this:\n * ```ts\n * const outer = task(function *(arg1, arg2) {\n * // ...\n * });\n * ```\n * or this:\n * ```ts\n * class Something {\n * ⁣⁣@task // auto-detects TC39 or legacy decorators\n * *someMethod(arg1): Yielding<SomeResultType> {\n * // ...\n * }\n * }\n * ```\n *\n * Important: if the wrapped function or method has overloads, the resulting\n * function type will be based on the **last** overload, because TypeScript (at\n * least as of 5.x) is still not very good at dealing with higher order\n * generics, especially if overloads are involved.\n *\n * Also note that TypeScript doesn't allow decorators to change the calling\n * signature or return type of a method, so even though the above method will\n * return a {@link Job}, TypeScript will only see it as a {@link Yielding}.\n *\n * This is fine if all you're going to do is `yield *` it to wait for the\n * result, but if you need to use any job-specific methods on it, you'll have to\n * pass it through {@link start} to have TypeScript treat it as an actual job.\n * (Luckily, start() has a fast path to return the original job if it's passed a\n * job, so you won't actually create a new job by doing this.)\n *\n * @param fn The function to wrap. A function returning a generator or\n * promise-like object (i.e., a {@link StartObj}).\n *\n * @returns A wrapped version of the function that passes through its arguments\n * to the original function, while running it in a new job. (The wrapper also\n * returns the job.)\n *\n * @category Jobs\n */\nexport function task<T, A extends any[], C>(fn: (this: C, ...args: A) => StartObj<T>): (this: C, ...args: A) => Job<T>;\n\n/** @hidden TC39 Decorator protocol */\nexport function task<T, A extends any[], C>(\n fn: (this: C, ...args: A) => StartObj<T>, ctx: {kind: \"method\"}\n): (this: C, ...args: A) => Job<T>;\n\n/** @hidden Legacy Decorator protocol */\nexport function task<T, A extends any[], C, D extends {value?: (this:C, ...args: A) => StartObj<T>}>(\n clsOrProto: any, name: string|symbol, desc: D\n): D\n\nexport function task<T, A extends any[], C, D extends {value?: (this:C, ...args: A) => StartObj<T>}>(\n fn: (this: C, ...args: A) => StartObj<T>, _ctx?: any, desc?: D\n): D | ((this: C, ...args: A) => Job<T>) {\n if (desc) return {...desc, value: task(desc.value)};\n return function (this: C, ...args: A) {\n return start<T>(() => fn.apply(this, args));\n }\n}\n","import { defer } from \"./defer.ts\";\nimport { type Stream, IsStream, backpressure, Sink, Connection, Backpressure, throttle, Inlet, Source } from \"./streams.ts\";\nimport { getJob, detached } from \"./tracking.ts\";\nimport { must, start } from \"./jobutils.ts\";\nimport { DisposeFn } from \"./types.ts\";\nimport { isCancel, isError, isUnhandled, markHandled, noop } from \"./results.ts\";\n\n/**\n * A function that emits events, with a .source they're emitted from\n *\n * Created using {@link emitter}.\n *\n * @category Types and Interfaces\n */\nexport interface Emitter<T> {\n /** Call the emitter to emit events on its .source */\n (val: T): void;\n /** An event source that receives the events */\n source: Source<T>;\n /** Close all current subscribers' connections */\n end: () => void;\n /** Close all current subscribers' connections with an error */\n throw: (e: any) => void;\n};\n\n/**\n * Create an event source and a function to emit events on it\n *\n * (Note: you must specify the event type (e.g. `emitter<number>()`), since\n * there's nothing else to infer it from.)\n *\n * @returns A function that emits events, with a .source property they're\n * emitted on.\n *\n * @category Stream Producers\n */\nexport function emitter<T>(): Emitter<T> {\n const emit = mockSource<T>();\n emit.source = share(emit.source);\n return emit;\n}\n\n/**\n * A stream that immediately closes\n *\n * @category Stream Producers\n */\nexport function empty(): Source<never> {\n return (_, conn) => (conn?.return(), IsStream);\n}\n\n/**\n * Convert an async iterable to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item output by the iterator, then end the stream. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromAsyncIterable<T>(iterable: AsyncIterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.asyncIterator]();\n if (iter.return) must(() => iter.return());\n return ready(next), IsStream;\n function next() {\n iter.next().then(({value, done}) => {\n if (done) conn.return(); else ready(() => {\n if (sink(value), ready()) next(); else ready(next);\n })\n }, e => conn.throw(e));\n }\n }\n}\n\n/**\n * Create an event source from an element, window, or other event target\n *\n * You can manually override the expected event type using a type parameter,\n * e.g. `fromDomEvent<CustomEvent>(someTarget, \"custom-event\")`.\n *\n * @param target an HTMLElement, Window, Document, or other EventTarget.\n * @param type the name of the event to add a listener for\n * @param options a boolean capture option, or an object of event listener\n * options\n * @returns a source that can be subscribed or piped, issuing events from the\n * target of the specified type.\n *\n * @category Stream Producers\n */\nexport function fromDomEvent<T extends HTMLElement, K extends keyof HTMLElementEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<HTMLElementEventMap[K]>;\nexport function fromDomEvent<T extends Window, K extends keyof WindowEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<WindowEventMap[K]>;\nexport function fromDomEvent<T extends Document, K extends keyof DocumentEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<DocumentEventMap[K]>;\nexport function fromDomEvent<T extends Event>(\n target: EventTarget, type: string, options?: boolean | AddEventListenerOptions\n): Source<T>\nexport function fromDomEvent<T extends EventTarget, K extends string>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<Event> {\n return (sink) => {\n function push(v: Event) { sink(v); }\n target.addEventListener(type, push, options);\n must(() => target.removeEventListener(type, push, options));\n return IsStream;\n }\n}\n\n/**\n * Convert an iterable to a synchronous event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item in the iterator, then close the conduit. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromIterable<T>(iterable: Iterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.iterator]();\n if (iter.return) must(() => iter.return());\n return ready(loop), IsStream;\n function loop() {\n try {\n for(;;) {\n const {value, done} = iter.next();\n if (done) return conn.return();\n if (sink(value), !ready()) return ready(loop);\n }\n } catch (e) {\n conn.throw(e);\n }\n }\n }\n}\n\n/**\n * Convert a Promise to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * the result of the promise, then close the conduit. (Unless the promise is\n * rejected, in which case the conduit throws and closes each time the source is\n * subscribed.) Non-native promises and non-promise values are converted using\n * Promise.resolve().\n *\n * @category Stream Producers\n */\nexport function fromPromise<T>(promise: Promise<T>|PromiseLike<T>|T): Source<T> {\n return (sink, conn) => {\n const job = getJob();\n Promise.resolve(promise).then(\n v => void (job.result() || (sink(v), conn?.return())),\n e => void (job.result() || conn?.throw(e))\n )\n return IsStream;\n }\n}\n\n/**\n * Create an event source from an arbitrary subscribe/unsubscribe function\n *\n * The supplied \"subscribe\" function will be passed a 1-argument callback and\n * must return an unsubscribe function. The callback should be called with\n * events of the appropriate type, and the unsubscribe function will be called\n * when the connection is closed.\n *\n * (Note: it's okay if the act of subscribing causes an immediate callback, as\n * the subscribe function will be called in a separate microtask.)\n *\n * @category Stream Producers\n */\nexport function fromSubscribe<T>(subscribe: (cb: (val: T) => void) => DisposeFn): Source<T> {\n return (sink) => {\n const f = getJob().must(() => sink = noop);\n return defer(() => f.must(subscribe(v => { sink(v); }))), IsStream;\n }\n}\n\n/**\n * Create a source that emits a single given value\n *\n * @category Stream Producers\n */\nexport function fromValue<T>(val: T): Source<T> {\n return (sink, conn) => {\n must(() => { sink = noop; conn = undefined; })\n return defer(() => { sink(val); conn?.return(); }), IsStream;\n }\n}\n\n/**\n * Create an event source that issues a number every `ms` milliseconds (starting\n * with 0 after the first interval passes).\n *\n * @category Stream Producers\n */\nexport function interval(ms: number): Source<number> {\n return (sink) => {\n let idx = 0, id = setInterval(() => sink(idx++), ms);\n return must(() => clearInterval(id)), IsStream;\n }\n}\n\n/**\n * Create a dynamic source that is created each time it's subscribed\n *\n * @param factory A function returning a source of the desired type. It will be\n * called whenever the lazy() stream is subscribed, and its result subscribed to.\n *\n * @returns A stream of the same type as the factory function returns\n *\n * @category Stream Producers\n */\nexport function lazy<T>(factory: () => Stream<T>): Source<T> {\n return (sink, conn, inlet) => factory()(sink, conn, inlet)\n}\n\n/**\n * An {@link Emitter} with a ready() method, that only supports a single active\n * subscriber. (Useful for testing stream operators and sinks.)\n *\n * Created using {@link mockSource}().\n *\n * @category Types and Interfaces\n */\nexport interface MockSource<T> extends Emitter<T> {\n ready: Backpressure\n}\n\n/**\n * Like {@link emitter}, but with a ready() backpressure method. It also only\n * supports a single active subscriber. (Useful for testing stream operators\n * and sinks.)\n *\n * @category Stream Producers\n */\nexport function mockSource<T>(): MockSource<T> {\n let write: Sink<T>, outlet: Connection, ready: Backpressure;\n const emit: MockSource<T> = (val: T) => { if (write) write(val); };\n emit.source = (sink, conn, inlet) => {\n write = sink; outlet = conn; ready = backpressure(inlet);\n must(() => write = outlet = ready = undefined);\n return IsStream;\n };\n emit.end = () => outlet?.return();\n emit.throw = (e: any) => outlet?.throw(e);\n emit.ready = (cb?: () => any) => ready(cb);\n return emit;\n}\n\n/**\n * A stream that never emits or closes\n *\n * @category Stream Producers\n */\nexport function never(): Source<never> {\n return () => IsStream;\n}\n\n/**\n * Wrap a source to allow multiple subscribers to the same underlying stream\n *\n * The input source will be susbcribed when the output has at least one\n * subscriber, and unsubscribed when the output has no subscribers. The input\n * will be paused when any subscriber pauses, and will only be resumed when all\n * subscribers are unpaused. All subscribers are closed or thrown if the input\n * source closes or throws.\n *\n * (Generally speaking, you should place the share call as late in your\n * pipelines as possible, if you use it at all. It adds some overhead that is\n * wasted if the stream doesn't have multiple subscribers, and may be redundant\n * if an upstream source is already shared. It's mainly useful if there is a\n * lot of mapping, filtering, or other complicated processing taking place\n * upstream of the share, and you know for a fact there will be enough\n * subscribers to make it a bottleneck. You should probably also consider\n * putting some {@link slack}() either upstream or downstream of the share, if\n * the upstream supports backpressure.)\n *\n * @category Stream Operators\n */\nexport function share<T>(source: Stream<T>): Source<T> {\n let uplink: Connection;\n const\n links = new Set<[sink: Sink<T>, conn: Connection]>,\n inlets = new Map<Inlet, number>(), // refcounts of incoming inlets\n t = throttle(), // the actual onReady queue\n multi: Inlet = {\n // A multi-connection inlet that requires all downstreams to be ready\n isOpen() { return !uplink?.result(); },\n isReady() {\n if (this.isOpen()) {\n for (const [i] of inlets) if (!i.isReady()) return (t.pause(), false);\n return true;\n }\n t.pause();\n return false;\n },\n onReady(cb, job) {\n if (this.isOpen()) {\n t.onReady(cb, job);\n for (const [i] of inlets) i.isReady() || i.onReady(produce, job);\n }\n return this;\n }\n }\n ;\n function produce() { multi.isReady() && t.resume(); }\n\n return (sink, conn=start(), inlet) => {\n const self: [Sink<T>, Connection] = [sink, conn];\n links.add(self);\n if (inlet) inlets.set(inlet, 1+(inlets.get(inlet) || 0));\n conn.must(() => {\n links.delete(self);\n if (inlet) {\n inlets.set(inlet, inlets.get(inlet)-1);\n if (!inlets.get(inlet)) inlets.delete(inlet);\n }\n if (!links.size) uplink?.end();\n else if (multi.isReady() && !t.isReady()) defer(produce);\n });\n if (links.size === 1) {\n uplink = detached.connect(source, v => {\n for(const [s, c] of links) try { s(v) } catch(e) { c.throw(e); };\n }, multi).do(r => {\n uplink = undefined;\n if (isCancel(r)) return;\n if (isUnhandled(r)) markHandled(r);\n for(const [_, c] of links) isError(r) ? c.throw(r.err) : c.return();\n })\n }\n return IsStream;\n }\n}\n","import { Job, Request, Suspend, Yielding } from \"./types.ts\"\nimport { defer } from \"./defer.ts\";\nimport { Connection, Inlet, Source, Sink, Stream, connect, pipe, throttle } from \"./streams.ts\";\nimport { resolve, isError, markHandled, isValue, fulfillPromise, rejecter, resolver } from \"./results.ts\";\nimport { restarting, start } from \"./jobutils.ts\";\nimport { getJob, isFunction } from \"./tracking.ts\";\nimport { Signal, cached } from \"./signals.ts\";\n\n/**\n * The result type returned from calls to {@link Each}.next()\n *\n * @category Types and Interfaces\n */\nexport type EachResult<T> = {\n /** The value provided by the source being iterated */\n item: T;\n\n /**\n * A suspend callback that must be `yield`-ed before the next call to the\n * iterator's .next() method. (That is, you must `yield next` it exactly once\n * per loop pass. See {@link each}() for more details.)\n */\n next: Suspend<void>;\n}\n\n/**\n * The iterable returned by `yield *` {@link each}()\n *\n * @category Types and Interfaces\n */\nexport type Each<T> = IterableIterator<EachResult<T>>\n\n/**\n * Asynchronously iterate over an event source\n *\n * Usage:\n *\n * ```ts\n * for (const {item: event, next} of yield *each(mouseMove)) {\n * console.log(event.clientX, event.clientY);\n * yield next; // required exactly once per iteration, even/w continue!\n * }\n * ```\n *\n * each(eventSource) yield-returns an iterator of `{item, next}` pairs. The\n * item is the data supplied by the event source, and `next` is a\n * {@link Suspend}\\<void\\> that advances the iterator to the next item. It\n * *must* be yielded exactly once per loop iteration. If you use `continue` to\n * shortcut the loop body, you must `yield next` *before* doing so.\n *\n * The for-loop will end if the source ends, errors, or is canceled. The source\n * is paused while the loop body is running, and resumed when the `yield next`\n * happens. If events arrive anyway (e.g. because the source doesn't support\n * pausing), they will be ignored unless you pipe the source through the\n * {@link slack}() operator to provide a buffer. If the for-loop is exited\n * early for any reason (or the iterator's `.return()` is called), the source is\n * unsubscribed and the iteration ended.\n *\n * @category Stream Consumers\n */\nexport function *each<T>(src: Stream<T>): Yielding<Each<T>> {\n let yielded = false, waiter: Request<void>;\n const result: IteratorYieldResult<EachResult<T>> = {value: {item: undefined as T, next}, done: false};\n const t = throttle(), conn = getJob().connect(src, v => {\n t.pause();\n if (!waiter || conn.result()) return;\n result.value.item = v;\n resolve(waiter, waiter = void 0);\n }, t).do(r => {\n // Prevent unhandled throws from here - it'll be seen by the next `yield\n // next`, or in the next microtask if `yield next` is already running.\n if (isError(r)) markHandled(r);\n if (waiter) { defer(next.bind(null, waiter)); waiter = undefined; }\n });\n\n // Wait for first value to arrive (and get put in result) before returning the iterator\n t.pause(); yield next;\n return {\n [Symbol.iterator]() { return this; },\n next() {\n if (!yielded) throw new Error(\"Must `yield next` in loop\");\n yielded = false;\n return result;\n },\n return() { conn.end(); return {value: undefined, done: true}; },\n }\n function next(r: Request<void>) {\n if (waiter) throw new Error(\"Multiple `yield next` in loop\");\n yielded = true;\n if (conn.result()) {\n result.value = undefined;\n (result as IteratorResult<any>).done = true;\n fulfillPromise(resolver(r), rejecter(r), conn.result())\n } else {\n waiter = r;\n t.resume();\n }\n }\n}\n\n/**\n * An object that can be waited on with `yield *until()`, by calling its\n * \"uneventful.until\" method. (This mostly exists to allow Signals to optimize\n * their until() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface UntilMethod<T> {\n /** Return an async op to resume once a truthy value is available */\n \"uneventful.until\"(): Yielding<T>\n}\n\n/**\n * An object that can be waited on with `yield *next()`, by calling its\n * \"uneventful.next\" method. (This mostly exists to allow Signals to optimize\n * their next() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface NextMethod<T> {\n /** Return an async op to resume with the \"next\" (i.e. not current) value produced */\n \"uneventful.next\"(): Yielding<T>\n};\n\n/**\n * Wait for and return the next truthy value (or error) from a data source (when\n * processed with `yield *` within a {@link Job}).\n *\n * This differs from {@link next}() in that it waits for the next \"truthy\" value\n * (i.e., not null, false, zero, empty string, etc.), and when used with signals\n * or a signal-using function, it can resume *immediately* if the result is\n * already truthy. (It also supports zero-argument signal-using functions,\n * automatically wrapping them with {@link cached}(), as the common use case for\n * until() is to wait for an arbitrary condition to be satisfied.)\n *\n * @param source The source to wait on, which can be:\n * - An object with an `\"uneventful.until\"` method returning a {@link Yielding}\n * (in which case the result will be the the result of calling that method)\n * - A {@link Signal}, or a zero-argument function returning a value based on\n * signals (in which case the job resumes as soon as the result is truthy,\n * perhaps immediately)\n * - A {@link Source} (in which case the job resumes on the next truthy value\n * it produces\n *\n * (Note: if the supplied source is a function with a non-zero `.length`, it is\n * assumed to be a {@link Source}.)\n *\n * @returns a Yieldable that when processed with `yield *` in a job, will return\n * the triggered event, or signal value. An error is thrown if event stream\n * throws or closes early, or the signal throws.\n *\n * @category Signals\n * @category Scheduling\n */\nexport function until<T>(source: UntilMethod<T> | Stream<T> | (() => T)): Yielding<T> {\n return callOrWait<T>(source, \"uneventful.until\", waitTruthy, recache);\n}\nfunction recache<T>(s: () => T) { return until(cached(s)); }\nfunction waitTruthy<T>(job: Job<T>, v: T) { v && job.return(v); }\n\n/**\n * Wait for and return the next value (or error) from a data source (when\n * processed with `yield *` within a {@link Job}).\n *\n * This differs from {@link until}() in that it waits for the *next* value\n * (truthy or not!), and it never resumes immediately for signals, but instead\n * waits for the signal to *change*. (Also, it does not support zero-argument\n * functions, unless you wrap them with {@link cached}() first.)\n *\n * @param source The source to wait on, which can be:\n * - An object with an `\"uneventful.next\"` method returning a {@link Yielding}\n * (in which case the result will be the the result of calling that method)\n * - A {@link Signal} or {@link Source} (in which case the job resumes on the\n * next value it produces)\n *\n * (Note: if the supplied source is a function with a non-zero `.length`, it is\n * assumed to be a {@link Source}.)\n *\n * @returns a Yieldable that when processed with `yield *` in a job, will return\n * the triggered event, or signal value. An error is thrown if event stream\n * throws or closes early, or the signal throws.\n *\n * @category Stream Consumers\n * @category Scheduling\n */\nexport function next<T>(source: NextMethod<T> | Stream<T>): Yielding<T> {\n return callOrWait<T>(source, \"uneventful.next\", waitAny, mustBeSourceOrSignal);\n}\n\nfunction waitAny<T>(job: Job<T>, v: T) { job.return(v); }\n\nfunction callOrWait<T>(\n source: any, method: string, handler: (job: Job<T>, val: T) => void, noArgs: (f?: any) => Yielding<T>|void\n) {\n if (source && isFunction(source[method])) return source[method]() as Yielding<T>;\n if (isFunction(source)) return (\n source.length === 0 ? noArgs(source) : false\n ) || start<T>(job => {\n connect(source as Source<T>, v => handler(job, v)).do(r => {\n if(isValue(r)) job.throw(new Error(\"Stream ended\"));\n else if (isError(r)) job.throw(markHandled(r));\n });\n })\n mustBeSourceOrSignal();\n}\n\nfunction mustBeSourceOrSignal() { throw new TypeError(\"not a source or signal\"); }\n\n/**\n * Run a {@link restarting}() callback for each value produced by a source.\n *\n * With each event that occurs, any previous callback run is cleaned up before\n * the new one begins. (And the last run is cleaned up when the connection or\n * job ends.)\n *\n * This function is almost the exact opposite of {@link each}(), in that the\n * stream is never paused (unless you do so manually via a throttle or inlet),\n * and if the \"loop body\" (callback job) is still running when a new value\n * arrives, forEach() restarts the job instead of dropping the value.\n *\n * @param src An event source (i.e. a {@link Source} or {@link Signal})\n * @param sink A callback that receives values from the source\n * @param inlet An optional throttle or inlet that will be used to pause the\n * source (if it's a signal or supports backpressure)\n * @returns a {@link Connection} that can be used to detect the stream\n * end/error, or ended to close it early.\n *\n * @category Stream Consumers\n */\nexport function forEach<T>(src: Stream<T>, sink: Sink<T>, inlet?: Inlet): Connection;\n/**\n * When called without a source, return a callback suitable for use w/{@link pipe}().\n * e.g.:\n *\n * ```ts\n * pipe(someSource, ..., forEach(v => { doSomething(v); }), optionalInlet));\n * ```\n *\n */\nexport function forEach<T>(sink: Sink<T>, inlet?: Inlet): (src: Stream<T>) => Connection;\nexport function forEach<T>(\n src: Stream<T>|Sink<T>, sink?: Sink<T>|Inlet, inlet?: Inlet\n): Connection | ((src: Stream<T>) => Connection) {\n if (isFunction(sink)) return start(j => {\n (src as Stream<T>)(restarting(sink as Sink<T>), j, inlet)\n });\n inlet = sink as Inlet; sink = src as Sink<T>;\n return (src: Stream<T>) => forEach(src, sink as Sink<T>, inlet);\n}\n","import { fromIterable } from \"./sources.ts\";\nimport { Connection, IsStream, Source, Sink, Stream, Transformer, backpressure, throttle } from \"./streams.ts\";\nimport { isValue, noop } from \"./results.ts\";\nimport { start } from \"./jobutils.ts\";\n\n/**\n * Output multiple streams' contents in order (from an array/iterable of stream\n * sources)\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * Note: this function is just shorthand for {@link concatAll}({@link fromIterable}(*sources*)).\n *\n * @category Stream Operators\n */\nexport function concat<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return concatAll(fromIterable(sources))\n}\n\n/**\n * Flatten a source of sources by emitting their contents in series\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * If you want to switch to a new stream whenever a new source arrives from the\n * input stream, use {@link switchAll} instead.\n *\n * @category Stream Operators\n */\nexport function concatAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n const inputs: Stream<T>[] = [], t = throttle();\n let outer = conn.connect(sources, s => {\n inputs.push(s); startNext(); t.pause();\n }, t).do(r => {\n outer = undefined\n inputs.length || inner || !isValue(r) || conn.return();\n });\n function startNext() {\n inner ||= conn.connect(inputs.shift(), sink, inlet).do(r => {\n inner = undefined;\n inputs.length ? startNext() : (outer ? t.resume() : !isValue(r) || conn.return());\n });\n }\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then concatenate the resulting\n * substreams\n *\n * (This is just shorthand for `compose(map(mapper), concatAll)`.)\n *\n * If you want to switch to a new stream whenever a new event arrives on the\n * input stream, use {@link switchMap} instead.\n *\n * @category Stream Operators\n */\nexport function concatMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => concatAll(map(mapper)(src))\n}\n\n\n/**\n * Create a subset of a stream, based on a filter function (like Array.filter)\n *\n * The filter function receives the current index (zero-based) as well as the\n * current value. If it returns truth, the value will be passed to the output,\n * otherwise it will be skipped.\n *\n * If the filter function is typed as a Typescript type guard (i.e. as returning\n * `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function filter<T,R extends T>(filter: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => filter(v, idx++) && sink(v), conn, inlet);\n }\n}\n\n/**\n * Replace each value in a stream using a function (like Array.map)\n *\n * The mapping function receives the current index (zero-based) as well as the\n * current value.\n *\n * @category Stream Operators\n */\nexport function map<T,R>(mapper: (v: T, idx: number) => R): Transformer<T,R> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => sink(mapper(v, idx++)), conn, inlet);\n }\n}\n\n/**\n * Create an event source by merging an array or iterable of event sources.\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function merge<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return mergeAll(fromIterable(sources));\n}\n\n/**\n * Create an event source by merging sources from a stream of event sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function mergeAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const uplinks: Set<Connection> = new Set;\n let outer = conn.connect(sources, (s) => {\n const c = conn.connect(s, sink, inlet).do(r => {\n uplinks.delete(c);\n uplinks.size || outer || !isValue(r) || conn.return();\n });\n uplinks.add(c);\n }).do(r => {\n outer = undefined;\n uplinks.size || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Create an event source by merging sources created by mapping events to sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * (Note: this is just shorthand for `compose(map(mapper), mergeAll)`.)\n *\n * @category Stream Operators\n */\nexport function mergeMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => mergeAll(map(mapper)(src));\n}\n\n/**\n * Skip the first N items from a source\n *\n * (Equivalent to {@link skipWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function skip<T>(n: number): Transformer<T> {\n return skipWhile((_, i) => i<n);\n}\n\n/**\n * Skip items from a stream until another source produces a value.\n *\n * If the notifier closes without producing a value, the output will\n * be empty. If the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function skipUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n let taking = false;\n const c = conn.connect(notifier, () => { taking = true; c.end(); });\n return src(v => taking && sink(v), conn, inlet);\n }\n}\n\n/**\n * Skip items from a stream until a given condition is false, then output all\n * remaining items. The condition function is not called again once it returns\n * false.\n *\n * @category Stream Operators\n */\nexport function skipWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0, met = false;\n return src(v => (met ||= !condition(v, idx++)) && sink(v), conn, inlet);\n };\n}\n\n/**\n * Add job control and buffering to a stream\n *\n * This lets you block events from a stream that can't be paused, or allow for\n * some slack for a source that can sometimes get ahead of its sink.\n *\n * @param size The number of items to buffer when the sink is busy (i.e., the\n * sink is running or the connection is paused). If positive, the most recent N\n * items are kept (a \"sliding\" buffer), and if negative, the oldest N item are\n * kept (a \"dropping\" buffer). If zero, no items are buffered, and items are\n * dropped if received while the sink is busy.\n *\n * @param dropped Optional: a callback that will receive items when they are\n * dropped. (Useful for testing, performance instrumentation, error logging,\n * etc.)\n *\n * @category Stream Operators\n */\nexport function slack<T>(size: number, dropped: Sink<T> = noop): Transformer<T> {\n const max = Math.abs(size);\n return src => (sink, conn=start(), inlet) => {\n const buffer: T[] = [], ready = backpressure(inlet);\n let paused = false, draining = false;\n const t = throttle();\n conn.connect(src, v => {\n buffer.push(v);\n if (!draining && ready()) return drain();\n while (buffer.length > max) { dropped((size < 0) ? buffer.pop() : buffer.shift()); }\n if (buffer.length === max) { t.pause(); paused = true; }\n if (buffer.length) ready(drain);\n }, t).do(r => {\n if (isValue(r)) conn.return();\n });\n\n function drain() {\n draining = true;\n try {\n while(buffer.length) {\n sink(buffer.shift());\n if (paused && ready()) {\n paused = false; t.resume();\n }\n if (buffer.length && !ready()) {\n return ready(drain);\n }\n }\n } finally {\n draining = false;\n }\n }\n return IsStream;\n }\n}\n\n/**\n * Flatten a source of sources by emitting their contents until a new one\n * arrives.\n *\n * As each source arrives from the input stream, its values are sent to the\n * output, closing the previous one (if any). The output is closed when both\n * the input stream and the most-recently-arrived stream are finished. Errors\n * propagate to the output if any stream throws.\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatAll} or {@link mergeAll} instead.)\n *\n * @category Stream Operators\n */\nexport function switchAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n let outer = conn.connect(sources, s => {\n inner?.end();\n inner = conn.connect(s, sink, inlet).do(r => {\n inner = undefined;\n outer || !isValue(r) || conn.return();\n });\n }).do(r => {\n outer = undefined;\n inner || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then output the resulting\n * substreams until a new value arrives.\n *\n * (This is just shorthand for `compose(map(mapper),`{@link switchAll `switchAll)`}.)\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatMap} or {@link mergeMap} instead.)\n *\n * @category Stream Operators\n */\nexport function switchMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => switchAll(map(mapper)(src))\n}\n\n/**\n * Take the first N items from a source\n *\n * (Equivalent to {@link takeWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function take<T>(n: number): Transformer<T> {\n return takeWhile((_, i) => i<n);\n}\n\n/**\n * Take items from a source until another source produces a value.\n *\n * If the notifier closes without producing a value, this will output all\n * elements of the input. But if the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function takeUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n conn.connect(notifier, () => conn.return());\n return src(sink, conn, inlet);\n }\n}\n\n/**\n * Take items from a stream until a given condition is false, then close the\n * output. The condition function is not called again after it returns false.\n *\n * If the condition function is typed as a Typescript type guard (i.e. as\n * returning `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function takeWhile<T,R extends T>(condition: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function takeWhile<T>(condition: (v: T, idx: number) => boolean): Transformer<T>;\nexport function takeWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0;\n return src(v => condition(v, idx++) ? sink(v) : conn?.return(), conn, inlet);\n };\n}\n"],"names":[],"mappings":"AAAU,IAAC,KAAK,GAAG,OAAO,cAAc,KAAK,UAAU,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE;;ACAjH,SAAS,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE;AACtC,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACvB,CAAC;AACM,SAAS,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE;AACxC,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC;AACM,SAAS,QAAQ,CAAC,OAAO,EAAE;AAClC,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC;AACM,SAAS,QAAQ,CAAC,OAAO,EAAE;AAClC,EAAE,OAAO,OAAO,CAAC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AC,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC;AACM,SAAS,IAAI,CAAC,CAAC,EAAE;AACxB,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AACM,SAAS,SAAS,CAAC,QAAQ,EAAE;AACpC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,EAAE,KAAK,KAAK;AACnD,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAChD,IAAI,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAClC,GAAG,CAAC;AACJ,CAAC;AACM,SAAS,SAAS,CAAC,SAAS,EAAE;AACrC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,KAAK;AACzC,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC;AAChB,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACnF,GAAG,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"mod.mjs","sources":["../src/defer.ts","../src/results.ts","../src/ambient.ts","../src/internals.ts","../src/chains.ts","../src/tracking.ts","../src/async.ts","../src/scheduling.ts","../src/streams.ts","../src/utils.ts","../src/cells.ts","../src/rules.ts","../src/signals.ts","../src/jobutils.ts","../src/sources.ts","../src/sinks.ts","../src/operators.ts"],"sourcesContent":["/**\n * Invoke a no-argument function as a microtask, using queueMicrotask or Promise.resolve().then()\n *\n * @category Scheduling\n */\nexport let defer: (cb: () => any) => void =\n typeof queueMicrotask === \"function\" ?\n queueMicrotask :\n (p => (cb: () => any) => p.then(cb))(Promise.resolve());\n\n/**\n * @internal For testing use only!\n *\n */\nexport function setDefer(fn: typeof defer) {\n defer = fn;\n}","import { Job, Request } from \"./types.ts\";\n\n/**\n * Resolve a {@link Request} with a value.\n *\n * (For a curried version, see {@link resolver}.)\n *\n * @category Requests and Results\n */\nexport function resolve<T>(request: Request<T>, val: T) { request(\"next\", val); }\n\n/**\n * Reject a {@link Request} with a reason.\n *\n * (For a curried version, see {@link rejecter}.)\n *\n * @category Requests and Results\n */\nexport function reject(request: Request<any>, reason: any) { request(\"throw\", undefined, reason); }\n\n/**\n * Create a callback that will resolve the given {@link Request} with a value.\n *\n * @category Requests and Results\n */\nexport function resolver<T>(request: Request<T>): (val: T) => void { return request.bind(null, \"next\"); }\n\n/**\n * Create a callback that will reject the given {@link Request} with a reason.\n *\n * @category Requests and Results\n */\nexport function rejecter(request: Request<any>): (err: any) => void { return request.bind(null, \"throw\", undefined); }\n\n\n/**\n * A function that does nothing and returns void.\n *\n * @category Stream Consumers\n */\nexport function noop() {}\n\n/**\n * A {@link JobResult} that indicates the job was ended via a return() value.\n *\n * @category Types and Interfaces\n */\nexport type ValueResult<T> = {op: \"next\", val: T, err: undefined};\n\n/**\n * A {@link JobResult} that indicates the job was ended via a throw() or other\n * error.\n *\n * @category Types and Interfaces\n */\nexport type ErrorResult = UnhandledError | HandledError;\n\n/**\n * An {@link ErrorResult} that hasn't yet been \"handled\" (by being passed to an\n * error-specific handler, converted to a promise, given to {@link markHandled},\n * etc.)\n *\n * @category Types and Interfaces\n */\nexport type UnhandledError = {op: \"throw\", val: undefined, err: any};\n\n/**\n * An {@link ErrorResult} that has been marked \"handled\" (by being passed to an\n * error-specific handler, converted to a promise, given to {@link markHandled},\n * etc.)\n *\n * @category Types and Interfaces\n */\nexport type HandledError = {op: \"throw\", val: null, err: any};\n\n/**\n * A {@link JobResult} that indicates the job was canceled by its creator (via\n * end() or restart()).\n *\n * @category Types and Interfaces\n */\nexport type CancelResult = {op: \"cancel\", val: undefined, err: undefined};\n\n/**\n * A result passed to a job's cleanup callbacks, or supplied by its\n * .{@link Job.result result}() method.\n *\n * You can inspect a JobResult using functions like {@link isCancel}(),\n * {@link isError}(), and {@link isValue}(). {@link getResult}() can be used to\n * unwrap the value or throw the error.\n *\n * @category Types and Interfaces\n */\nexport type JobResult<T> = ValueResult<T> | ErrorResult | CancelResult ;\n\nfunction mkResult<T>(op: \"next\", val?: T): ValueResult<T>;\nfunction mkResult(op: \"throw\", val: undefined|null, err: any): ErrorResult;\nfunction mkResult(op: \"cancel\"): CancelResult;\nfunction mkResult<T>(op: string, val?: T, err?: any): JobResult<T> {\n return {op, val, err} as JobResult<T>\n}\n\n/**\n * The {@link JobResult} used to indicate a canceled job.\n *\n * @category Requests and Results\n */\nexport const CancelResult = Object.freeze(mkResult(\"cancel\"));\n\n/**\n * Create a {@link ValueResult} from a value\n *\n * @category Requests and Results\n */\nexport function ValueResult<T>(val: T): ValueResult<T> { return mkResult(\"next\", val); }\n\n/**\n * Create an {@link ErrorResult} from an error\n *\n * @category Requests and Results\n */\nexport function ErrorResult(err: any): UnhandledError { return mkResult(\"throw\", undefined, err); }\n\n/**\n * Returns true if the given result is a {@link CancelResult}.\n *\n * @category Requests and Results\n */\nexport function isCancel(res: JobResult<any> | undefined): res is CancelResult {\n return res === CancelResult;\n}\n\n/**\n * Returns true if the given result is a {@link ValueResult}.\n *\n * @category Requests and Results\n */\nexport function isValue<T>(res: JobResult<T> | undefined): res is ValueResult<T> {\n return res ? res.op === \"next\" : false;\n}\n\n/**\n * Returns true if the given result is a {@link ErrorResult}.\n *\n * @category Requests and Results\n */\nexport function isError(res: JobResult<any> | undefined): res is ErrorResult {\n return res ? res.op === \"throw\" : false;\n}\n\n/**\n * Returns true if the given result is an {@link UnhandledError}.\n *\n * @category Requests and Results\n */\nexport function isUnhandled(res: JobResult<any> | undefined): res is UnhandledError {\n return isError(res) && res.val === undefined;\n}\n\n/**\n * Returns true if the given result is a {@link HandledError} (an\n * {@link ErrorResult} that has been touched by {@link markHandled}).\n *\n * @category Requests and Results\n */\nexport function isHandled(res: JobResult<any> | undefined): res is HandledError {\n return isError(res) && res.val === null;\n}\n\n/**\n * Return the error of an {@link ErrorResult} and mark it as handled. The\n * {@link ErrorResult} is mutated in-place to become a {@link HandledError}.\n *\n * @category Requests and Results\n */\nexport function markHandled(res: ErrorResult): any {\n res.val = null;\n return res.err;\n}\n\n/**\n * Get the return value from a {@link JobResult}, throwing an appropriate error\n * if the result isn't a {@link ValueResult}.\n *\n * @param res The job result you want to unwrap. Must not be undefined!\n *\n * @returns The value if the result is a {@link ValueResult}, or a thrown error\n * if it's an {@link ErrorResult}. A {@link CancelError} is thrown if the job\n * was canceled, or the error in the result is thrown.\n *\n * If the result is an error, it is marked as handled.\n *\n * @category Jobs\n */\nexport function getResult<T>(res: JobResult<T>): T {\n if (isValue(res)) return res.val;\n res.op; // throw if not defined\n fulfillPromise(noop, e => { throw e; }, res);\n}\n\n/**\n * Fulfill a Promise from a {@link JobResult}\n *\n * If the result is a {@link CancelResult}, the promise is rejected with a\n * {@link CancelError}. Otherwise it is resolved or rejected according to the\n * state of the result.\n *\n * @param resolve A value-taking function (first arg to `new Promise` callback)\n *\n * @param reject An error-taking function (second arg to `new Promise` callback)\n *\n * @param res The job result you want to settle the promise with. An error will\n * be thrown if it's undefined.\n *\n * If the result is an error, it is marked as handled.\n *\n * @category Requests and Results\n */\nexport function fulfillPromise<T>(resolve: (v: T) => void, reject: (e: any) => void, res: JobResult<T>) {\n if (isError(res)) reject(markHandled(res));\n else if (isCancel(res)) reject(new CancelError(\"Job canceled\"));\n else resolve(res.val);\n}\n\n/**\n * Propagate a {@link JobResult} to another job\n *\n * If the result is a {@link CancelResult}, the job will throw with a\n * {@link CancelError}. Otherwise it is resolved or rejected according to the\n * state of the result.\n *\n * @param job The job to terminate. If it's already ended, nothing changes: the\n * result is not propagated and the error (if any) is not marked as handled.\n *\n * @param res The job result you want to settle the job with. An error will be\n * thrown if it's undefined. If the result is an error, it is marked as\n * handled.\n *\n * @category Requests and Results\n */\nexport function propagateResult<T>(job: Job<T>, res: JobResult<T>) {\n if (!job.result()) fulfillPromise(job.return.bind(job), job.throw.bind(job), res);\n}\n\n/**\n * Error thrown when waiting for a result from a job that is canceled.\n *\n * If you `await`, `yield *`, `.then()`, `.catch()`, {@link getResult}() or\n * otherwise wait on the result of a job that is canceled, this is the type\n * of error you'll get.\n *\n * @category Errors\n */\nexport class CancelError extends Error {}\n","/**\n * Ambient execution context (for job, resource, and dependency tracking)\n *\n * @internal\n * @module\n */\n\nimport type { Job } from \"./types.ts\";\nimport type { Cell } from \"./cells.ts\";\n\ntype Opt<X> = X | undefined | null;\n\nexport type Context = {\n job: Opt<Job<unknown>>\n cell: Opt<Cell>\n}\n\n/** The current context */\nexport var current: Context = makeCtx();\n\n\n/** Set a new current context, returning the old one */\nexport function swapCtx(future: Context): Context {\n const now = current;\n current = future;\n return now\n}\n\nvar freelist = [] as Context[];\n\n/** Get a fresh context object (either by creation or recycling) */\nexport function makeCtx(\n job?: Context[\"job\"],\n cell?: Context[\"cell\"],\n): Context {\n if (freelist && freelist.length) {\n const s = freelist.pop()!;\n s.job = job;\n s.cell = cell;\n return s;\n }\n return {job, cell};\n}\n\n/** Put a no-longer-needed context object on the recycling heap */\nexport function freeCtx(s: Context) {\n s.job = s.cell = null;\n freelist.push(s);\n}\n\n","/**\n * Provide access to certain internals (for testing use only)\n *\n * @module\n */\n\nimport { makeCtx } from \"./ambient.ts\";\nimport { Job } from \"./types.ts\";\n\nexport const\n /** Jobs' asyncCatch handlers: in a map because few jobs will have them */\n catchers = new WeakMap<Job, (this: Job, err: any) => unknown>(),\n\n /** Default error handler for the `detached` job */\n defaultCatch = (e: any) => { Promise.reject(e); }\n;\n\n/** A null context (no job/observer) for cleanups to run in */\nexport const nullCtx = makeCtx();\n\n/** Jobs' owners (parents) - uses a map so child jobs can't directly access them */\nexport const owners = new WeakMap<Job, Job>();\n","import { DisposeFn } from \"./types.ts\";\n\n/**\n * A counted, double-ended queue with the ability to undo insertions (even out\n * of order).\n *\n * @category Chains\n */\nexport type Chain<T, U=any> = Node<T, number, U>;\n\n/**\n * Create a new Chain\n *\n * @category Chains\n */\nexport function chain<T, U=DisposeFn>(): Chain<T, U> { return link<number, U>(0, undefined, undefined); }\n\n/**\n * Recycle a chain entirely - only safe if no references to it remain anywhere!\n */\nexport function recycle(c: Chain<any>) {\n while (c.v) unlink(c, c.n);\n c.u = undefined;\n unlink(c, c);\n}\n\n/**\n * Unshift a value onto the front of the chain\n *\n * @category Chains\n */\nexport function unshift<T>(c: Chain<T>, v: T) { ++c.v; link(v, c.n, c); }\n\n/**\n * Unshift a value onto the front of the chain, returning an undo callback. The\n * callback can be invoked to remove the value from the chain at any time, even\n * after other values have been added or removed. There is no effect if the\n * callback is run more than once, or if the value has already been removed.\n *\n * @category Chains\n */\nexport function unshiftCB<T>(c: Chain<T>, v: T) { ++c.v; return unlinker(c, link(v, c.n, c)); }\n\n/**\n * Push a value onto the end of the chain\n *\n * @category Chains\n */\nexport function push<T>(c: Chain<T>, v: T) { ++c.v; link(v, c, c.p); }\n\n/**\n * Push a value onto the end of the chain, returning an undo callback. The\n * callback can be invoked to remove the value from the chain at any time, even\n * after other values have been added or removed. There is no effect if the\n * callback is run more than once, or if the value has already been removed.\n *\n * @category Chains\n */\nexport function pushCB<T>(c: Chain<T>, v: T) { ++c.v; return unlinker(c, link(v, c, c.p)); }\n\n/**\n * Return true if the chain is empty, or is null/undefined\n *\n * @category Chains\n */\nexport function isEmpty(c: Chain<any> | null | undefined) { return !c || c.v === 0; }\n\n/**\n * Return the number of items in the chain, or 0 if it's null/undefined\n *\n * @category Chains\n */\nexport function qlen(c: Chain<any> | null | undefined) { return c ? c.v : 0; }\n\n/**\n * Remove a value from the end of the chain, returning it\n *\n * @category Chains\n */\nexport function pop<T>(c: Chain<T>) { if (qlen(c)) return unlink(c, c.p); }\n\n/**\n * Remove a value from the front of the chain, returning it\n *\n * @category Chains\n */\nexport function shift<T>(c: Chain<T>) { if (qlen(c)) return unlink(c, c.n); }\n\n/** A node in a chain */\nclass Node<T, V=T, U=DisposeFn> {\n /** The next node (or the start node if this is a chain head) */\n n: Node<T> = this as Node<T, any>;\n /** The previous node (or the end node if this is a chain head) */\n p: Node<T> = this as Node<T, any>;\n /** The value held by the node (or the chain length if this is a chain head) */\n v: V = 0 as any;\n /** The most recently created undo callback for this node */\n u: U = undefined;\n}\n\n/** Recycling list for chain nodes, to reduce constructor/alloc overhead */\nvar free: Node<any,any,any>;\n\n/** Create (or reuse) a node with a given value, inserting it between two nodes in a chain */\nfunction link<T,U=DisposeFn>(v: T, n: Node<T, any, any>, p: Node<T, any, any>): Node<T,T,U> {\n let node: Node<T, T, any> = free;\n if (node) {\n free = node.n;\n node.n = n || node;\n node.p = p || node;\n } else {\n node = new Node<T, T, U>;\n if (n) node.n = n;\n if (p) node.p = p;\n }\n node.v = v;\n node.n.p = node;\n node.p.n = node;\n return node;\n}\n\n/** Unlink a node from a chain and recycle it, returning the value it held */\nfunction unlink<T>(c: Chain<any>, node: Node<T>) {\n --c.v;\n var v = node.v, u = node.u;\n node.n && (node.n.p = node.p);\n node.p && (node.p.n = node.n);\n node.u = node.v = node.p = undefined;\n node.n = free; free = node;\n if (u) u(); // drop refs to node+chain\n return v;\n}\n\n/**\n * Return an undo/remove callback that will run at most once and is a no-op if the\n * node was already removed. If called more than once on the same node while\n * it's in the same chain, it returns the same callback. ()\n */\nfunction unlinker(chain: Chain<any>, node: Node<any>) {\n let u = (node.u ||= () => {\n if (u) {\n // If the node's undo callback is this callback, then it's safe to remove;\n // otherwise, the node has already been removed and/or recycled for use in\n // a different chain (or a different value in this one!)\n if (u === node.u) unlink(chain, node);\n u = chain = node = undefined;\n }\n })\n return u;\n}\n","import { makeCtx, current, freeCtx, swapCtx } from \"./ambient.ts\";\nimport { catchers, defaultCatch, nullCtx, owners } from \"./internals.ts\";\nimport { CleanupFn, Job, Request, Yielding, Suspend, PlainFunction, StartFn, OptionalCleanup, JobIterator, RecalcSource, StartObj } from \"./types.ts\";\nimport { defer } from \"./defer.ts\";\nimport { JobResult, ErrorResult, CancelResult, isCancel, ValueResult, isError, isValue, noop, markHandled, isUnhandled, propagateResult } from \"./results.ts\";\nimport { rejecter, resolver, getResult, fulfillPromise } from \"./results.ts\";\nimport { Chain, chain, isEmpty, pop, push, pushCB, qlen, recycle, unshift } from \"./chains.ts\";\nimport { Stream, Sink, Inlet, Connection } from \"./streams.ts\";\n\n/**\n * Is the given value a function?\n *\n * @category Types and Interfaces\n */\nexport function isFunction(f: any): f is Function {\n return typeof f === \"function\";\n}\n\n/**\n * Return the currently-active Job, or throw an error if none is active.\n *\n * (You can check if a job is active first using {@link isJobActive}().)\n *\n * @category Jobs\n */\nexport function getJob<T=unknown>() {\n const {job} = current;\n if (job) return job as Job<T>;\n throw new Error(\"No job is currently active\");\n}\n\n/** RecalcSource factory for jobs (so you can wait on a job result in a signal or rule) */\nfunction recalcJob(job: Job<any>): RecalcSource { return (cb => { current.job.must(job.release(cb)); }); }\n\nfunction runChain<T>(res: JobResult<T>, cbs: Chain<CleanupFn<T>>): undefined {\n while (qlen(cbs)) try { pop(cbs)(res); } catch (e) { detached.asyncThrow(e); }\n cbs && recycle(cbs);\n return undefined;\n}\n\n// The set of jobs whose callbacks need running during an end() sweep\nvar inProcess = new Set<_Job<any>>;\n\nclass _Job<T> implements Job<T> {\n /** @internal */\n static create<T,R>(parent?: Job<R>, stop?: CleanupFn<R>): Job<T> {\n const job = new _Job<T>;\n if (parent || stop) {\n job.must((parent ||= getJob() as Job<R>).release(stop || job.end));\n owners.set(job, parent);\n }\n return job;\n }\n\n do(cleanup: CleanupFn<T>): this {\n unshift(this._chain(), cleanup);\n return this;\n }\n\n onError(cb: (err: any) => unknown): this {\n return this.do(r => { if (isError(r)) cb(markHandled(r)); });\n }\n\n onValue(cb: (val: T) => unknown): this {\n return this.do(r => { if (isValue(r)) cb(r.val); });\n }\n\n onCancel(cb: () => unknown): this {\n return this.do(r => { if (isCancel(r)) cb(); });\n }\n\n result(): JobResult<T> | undefined {\n // If we're done, we're done; otherwise make signals/rules reading this\n // recalc when we're done (handy for rendering \"loading\" states).\n return this._done || current.cell?.recalcWhen(this, recalcJob) || undefined;\n }\n\n get [Symbol.toStringTag]() { return \"Job\"; }\n\n end = () => {\n const res = (this._done ||= CancelResult), cbs = this._cbs;\n // if we have an unhandled error, fall through to queued mode for later\n // re-throw; otherwise, if there aren't any callbacks we're done here\n if (!cbs && !isUnhandled(res)) return;\n\n const ct = inProcess.size, old = swapCtx(nullCtx);;\n // Put a placeholder on the queue if it's empty\n if (!ct) inProcess.add(null);\n\n // Give priority to the release() chain so we get breadth-first flagging\n // of all child jobs as canceled immediately\n if (cbs && cbs.u) cbs.u = runChain(res, cbs.u);\n\n // Put ourselves on the queue *after* our children, so their cleanups run first\n inProcess.add(this);\n\n // if the queue wasn't empty, there's a loop above us that will run our must/do()s\n if (ct) { swapCtx(old); return; }\n\n // don't need the placeholder any more\n inProcess.delete(null);\n\n // Queue was empty, so it's up to us to run everybody's must/do()s\n for (const item of inProcess) {\n if (item._cbs) item._cbs = runChain(item._done, item._cbs);\n inProcess.delete(item);\n if (isUnhandled(item._done)) item.throw(markHandled(item._done));\n }\n swapCtx(old);\n }\n\n restart() {\n if (!this._done && inProcess.size) {\n // if a tree of jobs is ending right now, we need to start\n // a new stack so that when we return, all our children's\n // callbacks will have finished running first.\n const old = inProcess;\n inProcess = new Set;\n this.end();\n inProcess = old;\n } else {\n this._end(CancelResult);\n }\n this._done = undefined;\n promises.delete(this); // don't reuse any now-cancelled promise!\n return this;\n }\n\n _end(res: JobResult<T>) {\n if (this._done) throw new Error(\"Job already ended\");\n if (this !== detached) this._done = res;\n this.end();\n return this;\n }\n\n throw(err: any) {\n if (this._done) {\n (owners.get(this) || detached).asyncThrow(err);\n return this;\n }\n return this._end(ErrorResult(err));\n }\n\n return(val: T) { return this._end(ValueResult(val)); }\n\n then<T1=T, T2=never>(\n onfulfilled?: (value: T) => T1 | PromiseLike<T1>,\n onrejected?: (reason: any) => T2 | PromiseLike<T2>\n ): Promise<T1 | T2> {\n return nativePromise(this).then(onfulfilled, onrejected);\n }\n\n catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult> {\n return nativePromise(this).catch(onrejected);\n }\n\n finally(onfinally?: () => void): Promise<T> {\n return nativePromise(this).finally(onfinally);\n }\n\n *[Symbol.iterator](): JobIterator<T> {\n if (this._done) {\n return getResult(this._done);\n } else return yield (req: Request<T>) => {\n // XXX should this be a release(), so if the waiter dies we\n // don't bother? The downside is that it'd have to be mutual and\n // the resume is a no-op anyway in that case.\n this.do(res => fulfillPromise(resolver(req), rejecter(req), res));\n }\n }\n\n start<T>(fn?: StartFn<T> | StartObj<T>): Job<T>;\n start<T, This>(ctx: This, fn: StartFn<T, This>): Job<T>;\n start<T, This>(fnOrCtx: StartFn<T> | StartObj<T>|This, fn?: StartFn<T, This>) {\n if (!fnOrCtx) return makeJob(this);\n let init: StartFn<T, This>, result: StartObj<T> | OptionalCleanup;\n if (isFunction(fn)) {\n init = fn.bind(fnOrCtx as This);\n } else if (isFunction(fnOrCtx)) {\n init = fnOrCtx as StartFn<T, This>;\n } else if (fnOrCtx instanceof _Job) {\n return fnOrCtx;\n } else {\n result = fnOrCtx as StartObj<T>;\n }\n const job = makeJob<T>(this);\n try {\n if (init) result = job.run(init as StartFn<T>, job);\n if (result != null) {\n if (result instanceof _Job) {\n if (result !== job) result.do(res => propagateResult(job, res));\n } else if (isFunction((result as Promise<T>).then)) {\n (result as Promise<T>).then(\n v => { job.result() || job.return(v); },\n e => { job.result() || job.throw(e); }\n );\n return job;\n } else if (\n isFunction((result as Yielding<T>)[Symbol.iterator]) &&\n typeof result !== \"string\"\n ) {\n job.run(runGen<T>, result as Yielding<T>, job);\n } else if (isFunction(result)) {\n job.must(result);\n } else {\n throw new TypeError(\"Invalid value/return for start()\");\n }\n }\n return job;\n } catch(e) {\n job.end();\n throw e;\n }\n }\n\n connect<T>(src: Stream<T>, sink: Sink<T>, inlet?: Inlet): Connection {\n return this.start(job => void src(sink, job, inlet));\n }\n\n protected constructor() {};\n\n run<F extends PlainFunction>(fn: F, ...args: Parameters<F>): ReturnType<F> {\n const old = swapCtx(makeCtx(this));\n try { return fn.apply(null, args); } finally { freeCtx(swapCtx(old)); }\n }\n\n bind<F extends (...args: any[]) => any>(fn: F): F {\n const job = this;\n return <F> function (this: any) {\n const old = swapCtx(makeCtx(job));\n try { return fn.apply(this, arguments as any); } finally { freeCtx(swapCtx(old)); }\n }\n }\n\n must(cleanup?: OptionalCleanup<T>) {\n if (isFunction(cleanup)) push(this._chain(), cleanup);\n return this;\n }\n\n release(cleanup: CleanupFn<T>): () => void {\n if (this === detached) return noop;\n let cbs = this._chain();\n if (!this._done || cbs.u) cbs = cbs.u ||= chain();\n return pushCB(cbs, cleanup);\n }\n\n asyncThrow(err: any) {\n try {\n (catchers.get(this) || this.throw).call(this, err);\n } catch (e) {\n // Don't allow a broken handler to stay on the job\n if (this === detached) catchers.set(this, defaultCatch); else catchers.delete(this);\n const catcher = catchers.get(this) || this.throw;\n catcher.call(this, err);\n catcher.call(this, e); // also report the broken handler\n }\n return this;\n }\n\n asyncCatch(handler: ((this: Job, err: any) => unknown) | null): this {\n if (isFunction(handler)) catchers.set(this, handler);\n else if (handler === null) catchers.delete(this);\n return this;\n }\n\n protected _done: JobResult<T> = undefined;\n\n // Chain whose .u stores a second chain for `release()` callbacks\n protected _cbs: Chain<CleanupFn<T>, Chain<CleanupFn<T>>> = undefined;\n protected _chain() {\n if (this === detached) this.end()\n if (this._done && isEmpty(this._cbs)) defer(this.end);\n return this._cbs ||= chain();\n }\n}\n\nconst promises = new WeakMap<Job<any>, Promise<any>>();\n\n/**\n * Obtain a native promise for a job\n *\n * While jobs have the same interface as native promises, there are occasionally\n * reasons to just use one directly. (Like when Uneventful uses this function\n * to implement jobs' promise methods!)\n *\n * @param job Optional: the job to get a native promise for. If none is given,\n * the active job is used.\n *\n * @returns A {@link Promise} that resolves or rejects according to whether the\n * job returns or throws. If the job is canceled, the promise is rejected with\n * a {@link CancelError}.\n *\n * @category Jobs\n */\nexport function nativePromise<T>(job = getJob<T>()): Promise<T> {\n if (!promises.has(job)) {\n promises.set(job, new Promise((res, rej) => {\n const toPromise = (fulfillPromise<T>).bind(null, res, rej);\n if (job.result()) toPromise(job.result()); else job.do(toPromise);\n }));\n }\n return promises.get(job);\n}\n\n/**\n * Return a new {@link Job}. If *either* a parent parameter or stop function\n * are given, the new job is linked to the parent.\n *\n * @param parent The parent job to which the new job should be attached.\n * Defaults to the currently-active job if none given (assuming a stop\n * parameter is provided).\n *\n * @param stop The function to call to destroy the nested job. Defaults to the\n * {@link Job.end} method of the new job if none is given (assuming a parent\n * parameter is provided).\n *\n * @returns A new job. The job is linked/nested if any arguments are given,\n * or a detached (parentless) job otherwise.\n *\n * @category Jobs\n */\nexport const makeJob: <T,R=unknown>(parent?: Job<R>, stop?: CleanupFn<R>) => Job<T> = _Job.create;\n\n/**\n * A special {@link Job} with no parents, that can be used to create standalone\n * jobs. detached.start() returns a new detached job, detached.run() can be\n * used to run code that expects to create a child job, and detached.bind() can\n * wrap a function to work without a parent job.\n *\n * (Note that in all cases, a child job of `detached` *must* be stopped\n * explicitly, or it may \"run\" forever, never running its cleanup callbacks.)\n *\n * The detached job has a few special features and limitations:\n *\n * - It can't be ended, thrown, return()ed, etc. -- you'll get an error\n *\n * - It can't have any cleanup functions added: no do, must, onError, etc., and\n * thus also can't have any native promise, abort signal, etc. used. You can\n * call its release() method, but nothing will actually be registered and the\n * returned callback is a no-op.\n *\n * - Unhandled errors from jobs without parents (and errors from *any* job's\n * cleanup functions) are sent to the detached job for handling. This means\n * whatever you set as the detached job's .{@link Job.asyncCatch asyncCatch}()\n * handler will receive them. (Its default is Promise.reject, causing an\n * unhandled promise rejection.)\n *\n * @category Jobs\n */\nexport const detached = makeJob();\n(detached as any).end = () => { throw new Error(\"Can't do that with the detached job\"); }\ndetached.asyncCatch(defaultCatch);\n\nfunction runGen<R>(g: Yielding<R>, job: Job<R>) {\n let it = g[Symbol.iterator](), running = true, ctx = makeCtx(job), ct = 0;\n let done = ctx.job.release(() => {\n job = undefined;\n ++ct; // disable any outstanding request(s)\n // XXX this should be deferred to cleanup phase, or must() instead of release\n // (release only makes sense here if you can run more than one generator in a job)\n step(\"return\", undefined);\n });\n // Start asynchronously\n defer(() => { running = false; step(\"next\", undefined); });\n\n function step(method: \"next\" | \"throw\" | \"return\", arg: any): void {\n if (!it) return;\n // Don't resume a job while it's running\n if (running) {\n return defer(step.bind(null, method, arg));\n }\n const old = swapCtx(ctx);\n try {\n running = true;\n try {\n for(;;) {\n ++ct;\n const {done, value} = it[method](arg);\n if (done) {\n job && job.return(value);\n job = undefined;\n break;\n } else if (!isFunction(value)) {\n method = \"throw\";\n arg = new TypeError(\"Jobs must yield functions (or yield* Yielding<T>s)\");\n continue;\n } else {\n let called = false, returned = false, count = ct;\n (value as Suspend<any>)((op, val, err) => {\n if (called) return; else called = true;\n method = op; arg = op === \"next\" ? val : err;\n if (returned && count === ct) step(op, arg);\n });\n returned = true;\n if (!called) return;\n }\n }\n } catch(e) {\n it = job = undefined;\n ctx.job.throw(e);\n }\n // Iteration is finished; disconnect from job\n it = undefined;\n done?.();\n done = undefined;\n } finally {\n swapCtx(old);\n running = false;\n }\n }\n}\n","import { Request, Yielding } from \"./types.ts\";\nimport { rejecter, resolve, resolver } from \"./results.ts\"\n\n/**\n * Convert a (possible) promise to something you can `yield *to()` in a job\n *\n * Much like `await valueOrPromiseLike` in an async function, using `yield\n * *to(valueOrPromiseLike)` in a {@link Job}'s generator function will return\n * the value or the result of the promise/promise-like object.\n *\n * @category Scheduling\n */\nexport function *to<T>(p: Promise<T> | PromiseLike<T> | T): Yielding<T> {\n return yield (res: Request<T>) => Promise.resolve(p).then(resolver(res), rejecter(res));\n}\n\n/**\n * Pause the job for the specified time in ms, e.g. `yield *sleep(1000)` to wait\n * one second.\n *\n * @category Scheduling\n */\nexport function *sleep(ms: number): Yielding<void> {\n try {\n var id: ReturnType<typeof setTimeout>;\n yield r => {\n id = setTimeout(() => { id = undefined; resolve(r, void 0); }, ms);\n }\n } finally {\n if (id) clearTimeout(id);\n }\n}\n","import { type Cell } from \"./cells.ts\";\nimport { defer } from \"./defer.ts\";\n\n/** Scheduler state flags */\nconst enum Is {\n Unset = 0,\n _ = 1,\n Running = _ << 0,\n Scheduled = _ << 1,\n}\n\n/**\n * A generic queue for things that need to be run at-most-once per item\n * per timeframe.\n *\n * @category Jobs and Scheduling\n */\nexport class RunQueue<K> {\n protected _flags: Is = Is.Unset;\n protected readonly q = new Set<K>();\n\n constructor(\n /**\n * A single-argument scheduling function (like requestAnimationFrame,\n * setImmediate, or queueMicrotask). The scheduler will call it from\n * time to time with a single callback. The scheduling function should\n * then arrange for that callback to be invoked *once* at some future\n * point, when it is the desired time for all pending items on this\n * queue to run.\n */\n protected readonly sched: (cb: () => unknown) => unknown,\n /**\n * A callback to loop over the queue, removing items and performing any\n * necessary operations\n */\n protected readonly reap: (queue: Set<K>) => void\n ) {}\n\n /** Is this queue currently running? */\n isRunning() { return !!(this._flags & Is.Running); }\n\n /** Is this queue currently empty? */\n isEmpty() { return !this.q.size; }\n\n add(subject: K) {\n this.q.size || this._flags & (Is.Running|Is.Scheduled) || this._sched();\n this.q.add(subject);\n }\n\n delete(subject: any) {\n this.q.delete(subject);\n }\n\n protected _sched() {\n this._flags |= Is.Scheduled;\n this.sched(this._run);\n }\n\n protected _run = () => {\n this._flags &= ~Is.Scheduled;\n this.flush();\n }\n\n /** Run all pending items */\n flush = () => {\n // already running? skip it\n if (this._flags & Is.Running) return;\n const {q: queue} = this;\n // nothing to do? skip it\n if (!queue.size) return;\n this._flags |= Is.Running;\n try {\n this.reap(queue);\n } finally {\n this._flags &= ~Is.Running;\n // schedule again if we're stopping early due to error\n !queue.size || (this._flags & Is.Scheduled) || this._sched();\n }\n }\n}\n\nexport var currentRule: Cell;\nvar currentQueue: RuleQueue;\n\nconst ruleQueues = new WeakMap<Function, RuleQueue>();\n\nexport class RuleQueue extends RunQueue<Cell> {\n constructor(sched: (cb: () => unknown) => unknown) {\n super(sched, function(this: RuleQueue, q) {\n // another queue is running? reschedule for later\n if (currentQueue) return;\n currentQueue = this;\n try {\n // run rules marked dirty by value changes\n for (currentRule of q) {\n currentRule.catchUp();\n q.delete(currentRule);\n }\n } finally {\n currentQueue = currentRule = undefined;\n }\n });\n }\n}\n\nexport function ruleQueue(scheduleFn: (cb: () => unknown) => unknown = defer) {\n ruleQueues.has(scheduleFn) || ruleQueues.set(scheduleFn, new RuleQueue(scheduleFn));\n return ruleQueues.get(scheduleFn);\n}\n\nexport const defaultQ = /* @__PURE__ */ ruleQueue(defer);\n\n/** @internal */\nexport const pulls = new RunQueue<{doPull(): void}>(defer, pulls => {\n for (const conn of pulls) { pulls.delete(conn); conn.doPull(); }\n})\n\n/** @internal For testing only */\nexport const runPulls = pulls.flush;","import { pulls } from \"./scheduling.ts\";\nimport { DisposeFn, Job } from \"./types.ts\";\nimport { getJob } from \"./tracking.ts\";\nimport { current } from \"./ambient.ts\";\n\n/**\n * A backpressure controller: returns true if downstream is ready to accept\n * data.\n *\n * @param cb (optional) - a callback to run when the downstream consumer wishes\n * to resume event production (i.e., when a sink calls\n * {@link Throttle.resume}()). The callback is automatically unregistered when\n * invoked, so the producer must re-register it after each call if it wishes to\n * keep being called.\n *\n * @category Types and Interfaces\n */\nexport type Backpressure = (cb?: () => any) => boolean\n\n\n/**\n * Create a backpressure control function for the given connection\n *\n * @category Stream Producers\n */\nexport function backpressure(inlet: Inlet = defaultInlet): Backpressure {\n const job = getJob();\n return (cb?: Flush) => {\n if (!job.result() && inlet.isOpen()) {\n if (cb) inlet.onReady(cb, job);\n return inlet.isReady();\n }\n return false;\n }\n}\n\n/**\n * Control backpressure for listening streams. This interface is the API\n * internal to the implementation of {@link backpressure}(). Unless you're\n * implementing a backpressurable stream yourself, see the {@link Throttle}\n * interface instead.\n *\n * @category Types and Interfaces\n */\nexport interface Inlet {\n /** Is the main connection open? (i.e. is the creating job not closed yet?) */\n isOpen(): boolean\n\n /** Is the connection ready to receive data? */\n isReady(): boolean\n\n /**\n * Register a callback to produce more data when the inlet is resumed\n * (The callback is unregistered if the supplied job ends.)\n */\n onReady(cb: () => any, job: Job): this;\n}\n\n/**\n * Control backpressure for listening streams\n *\n * Obtain instances via {@link throttle}(), then pass them into the appropriate\n * stream-consuming API. (e.g. {@link connect}).\n *\n * @category Types and Interfaces\n */\nexport interface Throttle extends Inlet {\n /** Set inlet status to \"paused\". */\n pause(): void;\n\n /**\n * Un-pause, and iterate backpressure-able sources' onReady callbacks to\n * resume sending immediately. (i.e., synchronously!)\n */\n resume(): void;\n}\n\n/**\n * A Connection is a job that returns void when the connected stream ends\n * itself. If the stream doesn't end itself (e.g. it's an event listener), the\n * job will never return, and only end with a cancel or throw.\n *\n * @category Types and Interfaces\n */\nexport type Connection = Job<void>;\n\n/**\n * A Source is a function that can be called to arrange for data to be\n * produced and sent to a {@link Sink} function for consumption, until the\n * associated {@link Connection} is closed (either by the source or the sink,\n * e.g. if the sink doesn't want more data or the source has no more to send).\n *\n * If the source is a backpressurable stream, it can use the (optional) supplied\n * inlet (usually a {@link throttle}()) to rate-limit its output.\n *\n * A producer function *must* return the special {@link IsStream} value, so\n * TypeScript can tell what functions are usable as sources. (Otherwise any\n * void function with no arguments would appear to be usable as a source!)\n *\n * @category Types and Interfaces\n */\nexport interface Source<T> {\n /** Subscribe sink to receive values */\n (sink: Sink<T>, conn?: Connection, inlet?: Throttle | Inlet): typeof IsStream;\n}\n\n/**\n * An uneventful stream is either a {@link Source} or a {@link SignalSource}.\n * (Signals actually implement the {@link Source} interface as an overload, but\n * TypeScript gets confused about that sometimes, so we generally declare our\n * stream *inputs* as `Stream<T>` and our stream *outputs* as {@link Source}, so\n * that TypeScript knows what's what.\n *\n * @category Types and Interfaces\n */\nexport type Stream<T> = Source<T> | SignalSource<T>;\n\n/**\n * The call signatures implemented by signals. (They can be used as sources, or\n * called with no arguments to return a value.)\n *\n * This type is needed because TypeScript won't infer the overloads of\n * {@link Signal} correctly otherwise. (Specifically, it won't allow it to be\n * used as a zero-agument function.)\n *\n * @category Types and Interfaces\n*/\nexport type SignalSource<T> = Source<T> & {\n /** A signal object can be called to get its current value */\n (): T\n}\n\n/**\n * A specially-typed string used to verify that a function supports uneventful's\n * streaming protocol. Return it from a function to implement the\n * {@link Source} type.\n *\n * @category Types and Interfaces\n */\nexport const IsStream = \"uneventful/is-stream\" as const;\n\n/**\n * A `Sink` is a function that receives data from a {@link Stream}.\n *\n * @category Types and Interfaces\n */\nexport type Sink<T> = (val: T) => void;\n\n/**\n * A `Transformer` is a function that takes one stream and returns another,\n * possibly one that produces data of a different type. Most operator functions\n * return a transformer, allowing them to be combined via {@link pipe}().\n *\n * @category Types and Interfaces\n */\nexport type Transformer<T, V=T> = (input: Stream<T>) => Source<V>;\n\ntype Flush = () => any\n\n\n/**\n * Subscribe a sink to a stream, returning a nested job. (Shorthand for\n * {@link getJob}().{@link Job.connect connect}(...).)\n *\n * @param src An event source or signal\n * @param sink A callback that will receive the events\n * @param inlet Optional - a {@link throttle}() to control backpressure\n *\n * @returns A job that can be aborted to end the subscription, and which will\n * end naturally (with a void return or error) if the stream ends itself.\n *\n * @category Stream Consumers\n */\nexport function connect<T>(src: Stream<T>, sink: Sink<T>, inlet?: Throttle | Inlet): Connection {\n return getJob().connect(src, sink, inlet);\n}\n\n/**\n * Create a backpressure controller for a stream. Pass it to one or more\n * sources you're connecting to, and if they support backpressure they'll\n * respond when you call its .pause() and .resume() methods.\n *\n * @param job - Optional: a job that controls readiness. (The throttle will\n * pause indefinitely when the job ends.) Defaults to the currently-active job,\n * but unlike most such defaults, it won't throw if no job is active.\n *\n * @category Stream Consumers\n */\nexport function throttle(job: Job = current.job): Throttle {\n return new _Throttle(job);\n}\n\nclass _Throttle implements Throttle {\n /** @internal */\n protected _callbacks: Map<Flush, DisposeFn> = undefined;\n\n /** @internal */\n constructor(protected _job?: Job) {}\n\n isOpen(): boolean { return !this._job?.result(); }\n\n /** Is the connection ready to receive data? */\n isReady(): boolean { return this.isOpen() && this._isReady; }\n\n _isReady = true;\n _isPulling = false;\n\n onReady(cb: Flush, job: Job) {\n if (!this.isOpen()) return this;\n const _callbacks = (this._callbacks ||= new Map);\n const unlink = job.release(() => _callbacks.delete(cb));\n if (this.isReady() && this && !_callbacks.size) {\n pulls.add(this);\n }\n _callbacks.set(cb, unlink);\n return this;\n }\n\n pause() { this._isReady = false; return this; }\n\n doPull() {\n if (this._isPulling) return;\n const {_callbacks} = this;\n if (!_callbacks?.size) return;\n this._isPulling = true;\n try {\n for(let [cb, unlink] of _callbacks) {\n if (!this.isReady()) break; // we're done\n unlink()\n _callbacks.delete(cb);\n cb() // XXX error handling?\n }\n } finally {\n this._isPulling = false;\n }\n }\n\n resume() {\n if (this.isOpen()) {\n this._isReady = true;\n this.doPull();\n }\n }\n}\n\nconst defaultInlet: Inlet = throttle();\n\n/**\n * Pipe a stream (or anything else) through a series of single-argument\n * functions/operators\n *\n * e.g. the following creates a stream that outputs 4 and then 6:\n *\n * ```ts\n * pipe(fromIterable([1,2,3,4]), skip(1), take(2), map(x => x*2))\n * ```\n *\n * The first argument to pipe() can be any value, but all other arguments must\n * be functions. The value is passed to the first function, and then the result\n * is passed to the next function in turn, until all provided functions have\n * been called with the result of the previous function. The return value is\n * the last result, or the original value if no functions were given.\n *\n * The underlying implementation of pipe() works with any number of arguments,\n * but due to TypeScript limitations we only have typing defined for a max of 9\n * functions (10 arguments total). If you need more than 9 functions, you can\n * stack some of them with {@link compose}(), e.g.:\n *\n * ```typescript\n * pipe(\n * aStream,\n * compose(op1, op2, ...),\n * compose(op10, op11, ...),\n * compose(op19, ...),\n * ...\n * )\n * ```\n *\n * @category Stream Operators\n */\nexport function pipe<A,B,C,D,E,F,G,H,I,J>(input: A, ...fns: Chain9<A,J,B,C,D,E,F,G,H,I>): J\nexport function pipe<A,B,C,D,E,F,G,H,I> (input: A, ...fns: Chain8<A,I,B,C,D,E,F,G,H>): I\nexport function pipe<A,B,C,D,E,F,G,H> (input: A, ...fns: Chain7<A,H,B,C,D,E,F,G>): H\nexport function pipe<A,B,C,D,E,F,G> (input: A, ...fns: Chain6<A,G,B,C,D,E,F>): G\nexport function pipe<A,B,C,D,E,F> (input: A, ...fns: Chain5<A,F,B,C,D,E>): F\nexport function pipe<A,B,C,D,E> (input: A, ...fns: Chain4<A,E,B,C,D>): E\nexport function pipe<A,B,C,D> (input: A, ...fns: Chain3<A,D,B,C>): D\nexport function pipe<A,B,C> (input: A, ...fns: Chain2<A,C,B>): C\nexport function pipe<A,B> (input: A, ...fns: Chain1<A,B>): B\nexport function pipe<A> (input: A): A\nexport function pipe(input: any, ...fns: Array<(v: any) => any>): any;\nexport function pipe<A,X>(): X {\n var v = arguments[0];\n for (var i=1; i<arguments.length; i++) v = arguments[i](v);\n return v;\n}\n\n/**\n * Compose a series of single-argument functions/operators in application order.\n * (This is basically a deferred version of {@link pipe}().) For example:\n *\n * ```ts\n * const func = compose(skip(1), take(2), map(x => x*2));\n * const stream_4_6 = func(fromIterable([1,2,3,4])); // stream that outputs 4, 6\n * ```\n *\n * As with `pipe()`, the declared typings only support composing up to 9\n * functions at once; if you need more you'll need to nest calls to `compose()`\n * (i.e. passing the result of a `compose()` as an argument to another\n * `compose()` call.)\n *\n * @returns A function taking the same type as the first input function,\n * returning the same type as the last input function.\n *\n * @category Stream Operators\n */\nexport function compose<A,B,C,D,E,F,G,H,I,J>(...fns: Chain9<A,J,B,C,D,E,F,G,H,I>): (a: A) => J\nexport function compose<A,B,C,D,E,F,G,H,I> (...fns: Chain8<A,I,B,C,D,E,F,G,H>): (a: A) => I\nexport function compose<A,B,C,D,E,F,G,H> (...fns: Chain7<A,H,B,C,D,E,F,G>): (a: A) => H\nexport function compose<A,B,C,D,E,F,G> (...fns: Chain6<A,G,B,C,D,E,F>): (a: A) => G\nexport function compose<A,B,C,D,E,F> (...fns: Chain5<A,F,B,C,D,E>): (a: A) => F\nexport function compose<A,B,C,D,E> (...fns: Chain4<A,E,B,C,D>): (a: A) => E\nexport function compose<A,B,C,D> (...fns: Chain3<A,D,B,C>): (a: A) => D\nexport function compose<A,B,C> (...fns: Chain2<A,C,B>): (a: A) => C\nexport function compose<A,B> (...fns: Chain1<A,B>): (a: A) => B\nexport function compose<A> (): (a: A) => A\nexport function compose(...fns: ((v:any)=>any)[]) {\n return (val:any) => (pipe as any)(val, ...fns);\n}\n\ntype Chain1<A,R> = [(v: A) => R];\ntype Chain2<A,R,B> = [...Chain1<A,B>, ...Chain1<B,R>];\ntype Chain3<A,R,B,C> = [...Chain1<A,B>, ...Chain2<B,R,C>];\ntype Chain4<A,R,B,C,D> = [...Chain1<A,B>, ...Chain3<B,R,C,D>];\ntype Chain5<A,R,B,C,D,E> = [...Chain1<A,B>, ...Chain4<B,R,C,D,E>];\ntype Chain6<A,R,B,C,D,E,F> = [...Chain1<A,B>, ...Chain5<B,R,C,D,E,F>];\ntype Chain7<A,R,B,C,D,E,F,G> = [...Chain1<A,B>, ...Chain6<B,R,C,D,E,F,G>];\ntype Chain8<A,R,B,C,D,E,F,G,H> = [...Chain1<A,B>, ...Chain7<B,R,C,D,E,F,G,H>];\ntype Chain9<A,R,B,C,D,E,F,G,H,I> = [...Chain1<A,B>, ...Chain8<B,R,C,D,E,F,G,H,I>];\n\n/**\n * Pass subscriber into a stream (or any arguments into any other function).\n *\n * This utility is mainly here for uses like:\n *\n * - `pipe(src, into(sink))`,\n * - `pipe(src, into(sink, conn))`,\n * - `pipe(src, into(restarting(sink)))`, etc.\n *\n * but can also be used for argument currying generally.\n *\n * @param args The arguments to pass to the stream (or other function)\n *\n * @returns a function that takes another function and calls it with the given args.\n *\n * @category Stream Consumers\n */\nexport function into<In extends any[], Out>(...args: In): (src: (...args: In) => Out) => Out {\n return src => src(...args);\n}\n","import { AnyFunction } from \"./types.ts\";\n\nexport function setMap<K, V>(map: { set(key: K, val: V): void; }, key: K, val: V) {\n map.set(key, val);\n return val;\n}\n\n/**\n * This class hides the implementation details of inheriting from Function in\n * the documentation. (By default, typedoc exposes all the inherited properties\n * and members, which we don't want. By inheriting from it instead of from\n * Function, we keep the documentation free of unimportant details.)\n */\n//@ts-ignore CallableObject<T> adheres to the constraint of T in its *implementation*\nexport interface CallableObject<T extends AnyFunction> extends T {\n /** @internal */ [Symbol.hasInstance](value: any): boolean;\n /** @internal */ apply(this: Function, thisArg: any, argArray?: any): any;\n /** @internal */ bind(this: Function, thisArg: any, ...argArray: any[]): any;\n /** @internal */ call(this: Function, thisArg: any, ...argArray: any[]): any;\n /** @internal */ toString(): string;\n}\n\nexport declare class CallableObject<T extends AnyFunction> extends Function {\n /** @internal */ protected constructor(fn: T);\n /** @internal */ declare length: number;\n /** @internal */ declare arguments: any;\n /** @internal */ declare caller: Function;\n /** @internal */ declare prototype: any;\n /** @internal */ declare name: string;\n}\n\nexport function CallableObject<T>(fn: T) { return Object.setPrototypeOf(fn, new.target.prototype); }\n\n// No need to have extra prototypes in the chain\nCallableObject.prototype = Function.prototype as any;","import { Context, current, makeCtx, swapCtx } from \"./ambient.ts\";\nimport { type RuleQueue, currentRule, ruleQueue, defaultQ } from \"./scheduling.ts\";\nimport { Job, OptionalCleanup, RecalcSource } from \"./types.ts\"\nimport { getJob, makeJob } from \"./tracking.ts\";\nimport { Connection, Inlet, IsStream, Sink, Source, backpressure } from \"./streams.ts\";\nimport { setMap } from \"./utils.ts\";\nimport { isError, isValue, markHandled } from \"./results.ts\";\nimport { nullCtx } from \"./internals.ts\";\n\n/**\n * Error indicating a rule has attempted to write a value it indirectly\n * depends on, or which has already been read by another rule in the current\n * batch. (Also thrown when a cached function attempts to write a value at all,\n * directly or indirectly.)\n *\n * @category Errors\n */\nexport class WriteConflict extends Error {}\n\n/**\n * Error indicating a rule has attempted to write a value it directly depends\n * on, or a cached function has called itself, directly or indirectly.\n *\n * @category Errors\n */\nexport class CircularDependency extends Error {}\n\nvar timestamp = 1;\n\n/** recalcWhen(fn): map fn -> signal */\nconst fntrackers = new WeakMap<Function, () => number>();\n\n/** recalcWhen(key, factory): map factory -> key -> signal */\nconst obtrackers = new WeakMap<Function, WeakMap<WeakKey, () => number>>();\n\nconst dirtyStack: Cell[] = [];\n\nfunction markDependentsDirty(cell: Cell) {\n // We don't set validThrough here because that's how we tell the cell's been read/depended on\n const latestSource = cell.latestSource = timestamp;\n for(; cell; cell = dirtyStack.pop()) {\n for (let sub=cell.subscribers; sub; sub = sub.nT) {\n const tgt = sub.tgt;\n if (tgt.latestSource >= latestSource) continue;\n tgt.latestSource = latestSource;\n if (tgt.flags & Is.Rule) (tgt.value.q as RuleQueue).add(tgt);\n if (tgt.subscribers) dirtyStack.push(tgt);\n }\n }\n}\n\n// The .compute for a cell whose value has been explicitly set\nfunction returnValue(this: Cell) {\n return this.value;\n}\n\n// The compute for a cell whose value is an explicit error\nfunction throwValue(this: Cell) {\n throw this.value;\n}\n\n/**\n * Cells that are known to be clean as of this timestamp, but have not been\n * marked as read yet (and whose sources might also not be marked read). This\n * lets us lazily determine if a cell's value has been depended on (i.e.\n * \"virtually read\") in this timestamp, even if it wasn't *actually* read.\n */\nconst notCaughtUp = [] as Cell[];\n\nconst enum Is {\n Rule = 1 << 0,\n Calc = 1 << 2,\n Dead = 1 << 3,\n Error = 1 << 4,\n Running = 1 << 5,\n Stream = 1 << 6,\n Mutable = 1 << 7,\n Computed = Rule | Calc,\n Variable = Computed | Mutable,\n}\n\ntype Subscription = {\n /** Source of the subscription */\n src: Cell\n nS: Subscription,\n pS: Subscription,\n\n /** Subscriber */\n tgt: Cell\n nT: Subscription,\n pT: Subscription,\n\n ts: number,\n\n /* stack for active subscriptions on sources */\n old: Subscription\n}\n\nvar freesubs: Subscription;\n\nfunction mksub(source: Cell, target: Cell) {\n let sub: Subscription = freesubs;\n if (sub) {\n freesubs = sub.old;\n sub.src = source; sub.nS = undefined; sub.pS = target.sources;\n sub.tgt = target; sub.nT = sub.pT = undefined;\n sub.ts = source.lastChanged; sub.old = source.adding;\n } else sub = {\n src: source, nS: undefined, pS: target.sources,\n tgt: target, nT: undefined, pT: undefined,\n ts: source.lastChanged, old: source.adding\n }\n // Add subscription to tail of target's sources\n if (target.sources) target.sources.nS = sub;\n target.sources = sub;\n // track that this source has had a subscription added during this calculation\n source.adding = sub;\n // Set up reciprocal subscription if needed\n if (target.subscribers || target.flags & Is.Rule) source.subscribe(sub);\n}\n\nfunction delsub(sub: Subscription) {\n sub.src.unsubscribe(sub);\n if (sub.nS) sub.nS.pS = sub.pS;\n if (sub.pS) sub.pS.nS = sub.nS;\n sub.src = sub.tgt = sub.nS = sub.pS = sub.nT = sub.pT = undefined;\n sub.old = freesubs;\n freesubs = sub;\n}\n\nconst sentinel = {} // a unique value for uniqueness checking\n\nexport class Cell {\n value: any = undefined // the value, or, for a rule, the `{q, rm}` struct\n validThrough = 0; // timestamp of most recent validation or recalculation\n lastChanged = 0; // timestamp of last value change\n latestSource = timestamp; // max lastChanged of this cell or any ancestor source\n flags = 0;\n ctx: Context = undefined;\n /** The subscription being added during the current calculation - used for uniqueness */\n adding: Subscription = undefined;\n /** Linked list of sources */\n sources: Subscription = undefined;\n /** Linked list of targets */\n subscribers: Subscription = undefined;\n\n /**\n * The computation to be performed (if {@link Is.Calc} or {@link Is.Rule})\n * or the setup/teardown for {@link Is.Stream}.\n */\n compute: (sub?: boolean) => any = returnValue;\n\n stream<T>(sink: Sink<T>, _conn?: Connection, inlet?: Inlet) {\n let lastValue = sentinel;\n Cell.mkRule(() => {\n const val = this.getValue();\n if (val !== lastValue) {\n const old = swapCtx(nullCtx);\n try { sink(lastValue = val); } finally { swapCtx(old); }\n }\n }, inlet ? ruleQueue(backpressure(inlet)) : defaultQ);\n return IsStream;\n }\n\n getValue() {\n if (arguments.length) return this.stream.apply(this, arguments as any);\n this.catchUp();\n const dep = current.cell;\n // Only create a dependency if our value can change\n if (dep && this.flags & Is.Variable) {\n if (this.flags & Is.Running) throw new CircularDependency(\"Cached function dependency cycle\");\n // See if we've already got a subscription node for the dependent\n let s = this.adding;\n if (!s || s.tgt !== dep) {\n // nope, it's new\n mksub(this, dep);\n } else {\n // Yep, see if it's a hangover from last time\n if (s.ts === -1) {\n // yep, mark it reused\n s.ts = this.lastChanged;\n if (s.nS) { // if not at end, move it\n s.nS.pS = s.pS;\n if (s.pS) s.pS.nS = s.nS;\n s.nS = undefined;\n s.pS = dep.sources;\n dep.sources.nS = s;\n dep.sources = s;\n }\n }\n // else it's already done, no need to do anything.\n }\n }\n if (this.flags & Is.Error) throw this.value;\n return this.value;\n }\n\n shouldWrite(changed: boolean) {\n const cell = current.cell || currentRule;\n if (cell) {\n // When a cell changes within a sweep (i.e. from an active rule or other\n // cell), we need to check if it's not a circular update or disallowed\n // side-effect. In such a case we bail out with an error, even if the\n // change is idempotent. (To avoid hiding value-dependent errors.)\n if (cell.flags & Is.Calc) throw new WriteConflict(\"Side-effects not allowed in cached functions\");\n if (this.adding && this.adding.tgt === cell) throw new CircularDependency(\"Can't update direct dependency\");\n if (this.validThrough === timestamp || this.hasBeenRead()) throw new WriteConflict(\"Value already used\");\n } else if (changed) {\n // We are *not* in a sweep, but *did* have a change. So we may need to advance\n // the timestamp, if we might have had readers in the current one.\n if (this.validThrough === timestamp || notCaughtUp.length) { ++timestamp; notCaughtUp.length = 0; }\n } else {\n // Not in a sweep and no change -- no need to actually write anything\n return false;\n }\n // If we changed as of the current timestamp, we're already dirty\n // Otherwise, we should flag our subscribers as such.\n (this.lastChanged === timestamp) || markDependentsDirty(this);\n // If we have sources, reset the subscription timestamp of the first one\n // to force a recalculation on our next catchUp().\n if (this.sources) this.sources.ts = 0;\n return true;\n }\n\n setValue(val: any, isErr: boolean) {\n if (this.shouldWrite(val !== this.value || isErr !== !!(this.flags & Is.Error))) {\n this.value = val;\n this.lastChanged = timestamp;\n this.flags = isErr ? this.flags | Is.Error : this.flags & ~Is.Error;\n }\n // We always reset the compute here because we might have been in the\n // Calc state. But we don't clear the Calc flag because we might need\n // any previous sources to be released or unsubscribed. (Which will\n // happen on our next recalc.)\n this.compute = isErr ? throwValue : returnValue;\n }\n\n setCalc(compute: () => any) {\n if (this.shouldWrite(compute !== this.compute)) {\n this.flags |= Is.Calc;\n this.compute = compute;\n this.ctx ||= makeCtx(null, this);\n }\n }\n\n hasBeenRead() {\n if (notCaughtUp.length) {\n for(const cell of notCaughtUp) cell.catchUp();\n notCaughtUp.length = 0;\n }\n return this.validThrough === timestamp;\n }\n\n catchUp(): void {\n const {validThrough} = this;\n if (validThrough === timestamp) return;\n this.validThrough = timestamp;\n if (!(this.flags & Is.Computed)) return;\n if (this.sources) {\n for(let sub=this.sources; sub; sub = sub.nS) {\n const s = sub.src;\n // changed since our last compute? we're definitely dirty\n if (sub.ts !== s.lastChanged) return this.doRecalc();\n // if source is clean, skip it (most should be)\n // (note: only cells w/subscribers can be trusted as to their\n // latestSource, as cacheds with no subscribers don't get\n // notified by their upstreams)\n if (s.subscribers && s.latestSource <= validThrough) continue;\n // not a simple yes or no -- \"it's complicated\" -- so recurse\n s.catchUp();\n if (s.lastChanged > validThrough) {\n return this.doRecalc();\n }\n }\n // If we got to this point, we didn't need to recalc, but that means\n // none of our sources actually *changed*, despite at least one being\n // dirty. But that means we \"virtually\" read the clean values and\n // therefore depended on them... which means if they get written to,\n // either the timestamp must change or the write must be blocked.\n //\n // So we put them on our notCaughtUp list, in order to prevent rules\n // from changing them (or their sources) in the same timestamp, and\n // so that non-rule writes will know to update the timestamp.\n for(let sub=this.sources; sub; sub = sub.nS) {\n if (sub.src.validThrough !== timestamp) notCaughtUp.push(sub.src);\n }\n } else return this.doRecalc();\n }\n\n doRecalc() {\n const oldCtx = swapCtx(this.ctx);\n for(let sub = this.sources; sub; sub = sub.nS) {\n sub.ts = -1; // mark stale for possible reuse\n // attach sub to its source, so we can look it up\n sub.old = sub.src.adding;\n sub.src.adding = sub;\n this.sources = sub;\n }\n this.flags |= Is.Running;\n try {\n if (this.flags & Is.Calc) {\n try {\n const future = this.compute();\n if (future !== this.value || !this.lastChanged || this.flags & Is.Error) {\n this.value = future;\n this.lastChanged = timestamp;\n }\n this.flags &= ~Is.Error;\n } catch(e) {\n this.flags |= Is.Error\n this.value = e;\n this.lastChanged = timestamp;\n }\n } else {\n const {job} = this.ctx;\n job.restart();\n try {\n job.must(this.compute());\n this.lastChanged = timestamp;\n } catch (e) {\n this.disposeRule();\n throw e;\n }\n }\n } finally {\n this.flags &= ~Is.Running;\n swapCtx(oldCtx);\n // reset this.src to the head of the list, dropping stale subscriptions\n let head: Subscription;\n for(let sub = this.sources; sub; ) {\n const pS = sub.pS;\n sub.src.adding = sub.old;\n sub.old = undefined;\n if (sub.ts === -1) delsub(sub); else head = sub;\n sub = pS;\n }\n this.sources = head;\n if (!head) {\n // without sources, we can never change or be invalidated, so\n // revert to settable value() or permanent constant\n this.flags &= ~Is.Calc;\n }\n if (this.flags & Is.Dead) this.disposeRule();\n }\n }\n\n disposeRule() {\n this.ctx.job.end();\n this.flags |= Is.Dead;\n (this.value.q as RuleQueue).delete(this);\n this.value.rm();\n if (current !== this.ctx) {\n for(let s=this.sources; s;) { let nS = s.nS; delsub(s); s = nS; }\n this.sources = undefined;\n }\n }\n\n subscribe(sub: Subscription) {\n if (!this.subscribers) {\n if (this.flags & Is.Calc) {\n for(let s=this.sources; s; s = s.nS) s.src.subscribe(s);\n }\n if (this.flags & Is.Stream) this.compute(true); // subscribe to source\n }\n if (this.subscribers !== sub && !sub.pT) { // avoid adding already-added subs\n sub.nT = this.subscribers;\n if (this.subscribers) this.subscribers.pT = sub;\n this.subscribers = sub;\n }\n }\n\n unsubscribe(sub: Subscription) {\n if (sub.nT) sub.nT.pT = sub.pT;\n if (sub.pT) sub.pT.nT = sub.nT;\n if (this.subscribers === sub) this.subscribers = sub.nT;\n sub.nT = sub.pT = undefined;\n if (!this.subscribers) {\n if (this.flags & Is.Calc) {\n for(let s=this.sources; s; s = s.nS) s.src.unsubscribe(s);\n }\n if (this.flags & Is.Stream) this.compute(false); // unsubscribe from source\n }\n }\n\n static mkValue<T>(val: T) {\n const cell = new Cell;\n cell.flags = Is.Mutable;\n cell.value = val;\n cell.lastChanged = timestamp;\n return cell;\n }\n\n static mkStream<T>(src: Source<T>, val?: T) {\n const cell = this.mkValue(val);\n cell.flags |= Is.Stream;\n cell.ctx = makeCtx();\n const write = (v: T) => { cell.setValue(v, false); cell.compute = compute; };\n let job: Job<void>;\n const compute = cell.compute = (sub: boolean) => {\n if (!sub) {\n // Last subscriber is gone, so reset to default value\n cell.value = val; cell.flags &= ~Is.Error;\n job?.end(); // unsubscribe from source\n return\n }\n if (job) return;\n job = cell.ctx.job = makeJob<void>().do(r => {\n if (isError(r)) {\n cell.setValue(markHandled(r), true);\n } else if (isValue(r)) {\n cell.setValue(val, false);\n }\n cell.compute = compute;\n cell.ctx.job = job = undefined;\n });\n const old = swapCtx(cell.ctx);\n try {\n src(write, job);\n } catch(e) {\n job.end();\n throw e;\n } finally {\n swapCtx(old);\n }\n }\n return cell;\n }\n\n recalcWhen(src: RecalcSource): void;\n recalcWhen<T extends WeakKey>(key: T, factory: (key: T) => RecalcSource): void;\n recalcWhen<T extends WeakKey>(fnOrKey: T | RecalcSource, fn?: (key: T) => RecalcSource) {\n let trackers: WeakMap<WeakKey, () => number> = fn ?\n obtrackers.get(fn) || setMap(obtrackers, fn, new WeakMap) :\n fntrackers\n ;\n let signal = trackers.get(fnOrKey);\n if (!signal) {\n const src = fn ? fn(<T>fnOrKey) : <RecalcSource> fnOrKey;\n let ct = 0;\n const c = Cell.mkStream(s => (src(() => s(++ct)), IsStream), ct);\n trackers.set(fnOrKey, signal = c.getValue.bind(c));\n }\n signal(); // Subscribe to the cell\n }\n\n static mkCached<T>(compute: () => T) {\n const cell = new Cell;\n cell.compute = compute;\n cell.ctx = makeCtx(null, cell);\n cell.flags = Is.Calc;\n return cell;\n }\n\n static mkRule(fn: (stop: () => void) => OptionalCleanup, q: RuleQueue) {\n var cell = new Cell, job = makeJob();\n const stop = cell.disposeRule.bind(cell);\n cell.value = {q, rm: getJob().release(stop)};\n cell.compute = fn.bind(null, stop);\n cell.ctx = makeCtx(job, cell);\n cell.flags = Is.Rule;\n q.add(cell);\n return stop;\n }\n}\n","import { defer } from \"./defer.ts\";\nimport { RuleQueue, currentRule, defaultQ, ruleQueue } from \"./scheduling.ts\";\nimport { AnyFunction, DisposeFn, OptionalCleanup } from \"./types.ts\";\nimport { Cell } from \"./cells.ts\";\nimport { CallableObject, setMap } from \"./utils.ts\";\n\n/**\n * A decorator function that supports both TC39 and \"legacy\" decorator protocols\n *\n * @template F the type of method this decorator can decorate. If the method\n * doesn't conform to this type, compile-time type checks will fail.\n *\n * @category Types and Interfaces\n */\nexport type GenericMethodDecorator<F extends AnyFunction> = {\n /** TC39 Method Decorator @hidden */\n (fn: F, ctx?: {kind: \"method\"}): F;\n\n /** Legacy Method Decorator @hidden */\n (proto: object, name: string|symbol, desc?: {value?: F}): void;\n}\n\n/**\n * The interface provided by {@link rule}, and other {@link rule.factory}()\n * functions.\n*\n* @category Types and Interfaces\n*/\nexport interface RuleFactory {\n /**\n * @inheritdoc rule factory tied to a specific scheduler. See {@link rule} for\n * more details.\n */\n (fn: (stop: DisposeFn) => OptionalCleanup): DisposeFn;\n\n /**\n * Stop the currently-executing rule, or throw an error if no rule is\n * currently running.\n */\n stop(): void\n\n /**\n * Observe a condition and apply an action.\n *\n * This is roughly equivalent to `rule(() => { if (condition()) return\n * action(); })`, except that the rule is *only* rerun if the `action`'s\n * dependencies change, *or* the truthiness of `condition()` changes. It\n * will *not* be re-run if only the dependencies of `condition()` have\n * changed, without affecting its truthiness.\n *\n * This behavior can be important for rules that nest other rules, have\n * cleanups, fire off tasks, etc., as it may be wasteful to constantly tear\n * them down and set them back up if the enabling condition is a calculation\n * with frequently-changing dependencies.\n */\n if(condition: () => any, action: () => OptionalCleanup): DisposeFn\n\n /**\n * Decorate a method to behave as a rule, e.g.\n *\n * ```ts\n * const animate = rule.factory(requestAnimationFrame);\n *\n * class Draggable {\n * ⁣@animate.method\n * trackPosition(handleTop: number, handleLeft: number) {\n * const {clientX, clientY} = lastMouseEvent();\n * this.element.style.top = `${clientY - handleTop}px`;\n * this.element.style.left = `${clientX - handleLeft}px`;\n * }\n * }\n *\n * // Start running the method in an animation frame for every change to\n * // lastMouseEvent, until the current job ends:\n * someDraggable.trackPosition(top, left);\n * ```\n *\n * Each time it's (explicitly) called, the decorated method will start a new\n * rule, which will repeatedly run the method body (with the original\n * arguments and `this`) whenever its dependencies change, according to the\n * schedule defined by the rule factory. (So e.g. `@rule.method` will\n * update on the microtask after a change, etc.)\n *\n * The decorated method will always return a {@link DisposeFn} to let you\n * explicitly stop the rule before the current job end. But if the original\n * method body doesn't return a dispose function of its own, TypeScript will\n * consider the method to return void, unless you explicitly declare its\n * return type to be `DisposeFn | void`.\n *\n * Also note that since rule methods can accept arbitrary parameters, they\n * do not receive a `stop` parameter, and must therefore use {@link\n * RuleFactory.stop rule.stop}() if they wish to terminate themselves.\n */\n readonly method: GenericMethodDecorator<(...args: any[]) => OptionalCleanup>\n\n /**\n * Return a rule factory for the given scheduling function, that you can\n * then use to make rules that run in a specific time frame.\n *\n * ```ts\n * // `animate` will now create rules that run during animation fames\n * const animate = rule.factory(requestAnimationFrame);\n *\n * animate(() => {\n * // ... do stuff in an animation frame when signals used here change\n * })\n * ```\n *\n * (In addition to being callable, the returned function is also a\n * {@link RuleFactory}, and thus has a `.method` decorator, `.if()` method,\n * and so on.)\n *\n * @param scheduleFn A single-argument scheduling function (such as\n * requestAnimationFrame, setImmediate, or queueMicrotask). The rule\n * scheduler will call it from time to time with a single callback. The\n * scheduling function should then arrange for that callback to be invoked\n * *once* at some future point, when it is the desired time for all pending\n * rules on that scheduler to run.\n *\n * @returns A {@link RuleFactory}, like {@link rule}. If called with the\n * same scheduling function more than once, it returns the same factory.\n *\n */\n factory(scheduleFn: (cb: () => unknown) => unknown): RuleFactory\n}\n\nclass RF extends CallableObject<(fn: (stop: DisposeFn) => OptionalCleanup) => DisposeFn> implements RuleFactory {\n\n constructor(q: RuleQueue) {\n super((fn: (stop: DisposeFn) => OptionalCleanup): DisposeFn => Cell.mkRule(fn, q))\n }\n\n stop() {\n if (currentRule) return currentRule.disposeRule();\n throw new Error(\"No rule active\");\n }\n if(condition: () => any, action: () => OptionalCleanup): DisposeFn {\n const cond = Cell.mkCached(() => !!condition());\n return this(() => cond.getValue() ? action() : undefined);\n }\n\n get method(): GenericMethodDecorator<(...args: any[]) => OptionalCleanup> {\n const self = this;\n return (\n fn: object | ((...args: any[]) => OptionalCleanup),\n _ctxOrName?: any,\n desc?: { value?: (...args: any[]) => OptionalCleanup; }\n ) => {\n if (desc) return void (desc.value = this.method(desc.value));\n return function (this: any, ...args: any[]): DisposeFn {\n return self(() => (fn as any).apply(this, args));\n };\n }\n }\n\n factory(scheduleFn: (cb: () => unknown) => unknown): RuleFactory {\n return factories.get(scheduleFn) || setMap(factories, scheduleFn, new RF(ruleQueue(scheduleFn)));\n }\n}\n\n\nconst factories = new WeakMap<Function, RuleFactory>();\n\n/**\n * Subscribe a function to run every time certain values change.\n *\n * The function is run asynchronously, first after being created, then again\n * after there are changes in any of the values or cached functions it read\n * during its previous run.\n *\n * The created subscription is tied to the currently-active job (which may be\n * another rule). So when that job is ended or restarted, the rule will be\n * terminated automatically. You can also terminate it early by calling the\n * \"stop\" function that is both passed to the rule function and returned by\n * `rule()`.\n *\n * Note: this function will throw an error if called without an active job. If\n * you need a standalone rule, use {@link detached}.run to wrap the\n * call to rule.\n *\n * @param fn The function that will be run each time its dependencies change.\n * The function will be run in a restarted job each time, with any resources\n * used by the previous run being cleaned up. The function is passed a single\n * argument: a function that can be called to terminate the rule. The function\n * should return a cleanup function or void.\n *\n * @returns A function that can be called to terminate the rule.\n *\n * @category Signals\n */\nexport const rule: ((action: (stop: DisposeFn) => OptionalCleanup) => DisposeFn) & RuleFactory = (\n RF.prototype.factory(defer)\n)\n\n/**\n * Synchronously run any pending rules tied to a specific schedule.\n *\n * (Note: \"pending\" rules are ones with at least one changed ancestor\n * dependency; this doesn't mean they will actually *do* anything, since\n * intermediate cached() function results might end up unchanged.)\n *\n * You should normally only need to call this when you need to *force*\n * side-effects to occur within a specific *synchronous* timeframe, e.g. if\n * rules need to be able to cancel a synchronous event or continue an IndexedDB\n * transaction. (Otherwise, this is really only useful for testing.)\n *\n * @param scheduleFn The scheduler used to create the rule factory you wish to\n * run pending rules for. If not given, the default {@link rule}() factory is\n * targeted.\n *\n * @category Signals\n */\nexport function runRules(scheduleFn?: (cb: () => unknown) => unknown) {\n (scheduleFn ? ruleQueue(scheduleFn) : defaultQ).flush();\n}\n","import { current, freeCtx, makeCtx, swapCtx } from \"./ambient.ts\";\nimport { PlainFunction, Yielding, RecalcSource, AnyFunction } from \"./types.ts\";\nimport { Cell } from \"./cells.ts\";\nimport { rule } from \"./rules.ts\";\nimport { reject, resolve } from \"./results.ts\";\nimport { UntilMethod } from \"./sinks.ts\";\nimport { SignalSource, Source } from \"./streams.ts\";\nimport { CallableObject } from \"./utils.ts\";\nimport { defer } from \"./defer.ts\";\n\nexport { rule, runRules, type GenericMethodDecorator, type RuleFactory } from \"./rules.ts\"\nexport { WriteConflict, CircularDependency } from \"./cells.ts\";\n\n/**\n * An observable value, as a zero-argument callable with extra methods.\n *\n * In addition to being callable, signals also offer a `.value` getter, and\n * implement the standard JS methods `.toString()`, `.valueOf()`, and\n * `.toJSON()` in such a way that they reflect the signal's contents rather than\n * the signal itself.\n *\n * Signals also implement the {@link Source} interface, and can thus be\n * subscribed to. Subscribers receive the current value first, and then any\n * changes thereafter. They can be waited on by {@link until}(), in which case\n * the calling job resumes when the signal's value is truthy.\n *\n * You can also transform a signal to a {@link Writable} by calling its\n * .{@link Signal.withSet withSet}() method, or create a writable value using\n * {@link value}().\n *\n * @category Types and Interfaces\n */\nexport interface Signal<T> extends SignalSource<T>, UntilMethod<T> {\n /**\n * The current value\n *\n * @category Reading\n */\n readonly value: T\n\n /** Current value @hidden */\n valueOf() : T\n\n /** Current value as a string @hidden */\n toString(): string\n\n /** The current value @hidden */\n toJSON() : T\n\n /**\n * Get the signal's current value, without adding the signal as a dependency\n *\n * (This is exactly equivalent to calling {@link peek}(signal), and exists\n * here mainly for interop with other signal frameworks.)\n *\n * @category Reading */\n peek(): T;\n\n /** Get a read-only version of this signal @category Reading */\n asReadonly(): Signal<T>\n\n /** New writable signal with a custom setter @category Writing */\n withSet(set: (v: T) => unknown): Writable<T>\n\n /** @hidden */\n \"uneventful.until\"(): Yielding<T>;\n}\n\n/** @internal */\nexport class SignalImpl<T> extends CallableObject<SignalSource<T>> implements Signal<T> {\n constructor(protected _c: Cell) { super(_c.getValue.bind(_c)); }\n get value() { return this(); }\n valueOf() { return this(); }\n toString() { return \"\" + this(); }\n toJSON() { return this(); }\n peek() { return peek(this as () => T); };\n asReadonly(): Signal<T> { return this; }\n withSet(set: (v: T) => unknown): Writable<T> {\n return Object.assign(new WritableImpl<T>(this._c), {set});\n }\n\n *\"uneventful.next\"(): Yielding<T> {\n return yield (r => {\n let seen = false, res: T;\n rule(stop => {\n try { res = this(); } catch(e) { stop(); defer(reject.bind(null, r,e)); }\n if (seen) { stop(); defer(resolve.bind(null, r, res)); }\n seen = true;\n })\n });\n }\n\n *\"uneventful.until\"(): Yielding<T> {\n return yield (r => {\n let res: T;\n try { res = this(); } catch(e) { reject(r, e); return; }\n if (res) return resolve(r, res);\n rule(stop => {\n try { res = this(); } catch(e) { stop(); defer(reject.bind(null, r,e)); }\n if (res) { stop(); defer(resolve.bind(null, r, res)); }\n });\n });\n }\n}\n\n/**\n * A {@link Signal} with a {@link Writable.set | .set()} method and writable\n * {@link Writable.value | .value} property.\n *\n * @category Types and Interfaces\n */\nexport interface Writable<T> extends Signal<T> {\n /**\n * Set the current value. (Note: this is a bound method so it can be used\n * as a callback.)\n *\n * @category Writing\n */\n readonly set: (val: T) => void;\n\n get value(): T\n\n /** Set the current value */\n set value(val: T);\n}\n\n/** @internal */\nexport class WritableImpl<T> extends SignalImpl<T> implements Writable<T> {\n get value() { return this(); }\n set value(val: T) { this.set(val); }\n set = (val: T) => { this._c.setValue(val, false); }\n asReadonly(): Signal<T> {\n return new SignalImpl<T>(this._c);\n }\n}\n\n/**\n * A writable signal that can be set to either a value or an expression.\n *\n * Like a spreadsheet cell, a configurable signal can contain either a value or\n * a formula. If you .set() a value or change the .value property of the\n * signal, the formula is cleared. Conversely, if you set a formula with\n * .setf(), then the value is calculated using that formula from then on, until\n * another formula is set, or the value is changed directly again.\n *\n * @category Types and Interfaces\n */\nexport interface Configurable<T> extends Writable<T> {\n /**\n * Set a formula that will be used to calculate the signal's value. If it\n * uses the value of other signals, this signal's value will be recalculated\n * when they change.\n *\n * @category Writing\n */\n setf(expr: () => T): this;\n}\n\n/** @internal */\nexport class ConfigurableImpl<T> extends WritableImpl<T> implements Configurable<T> {\n setf(expr: () => T): this {\n this._c.setCalc(expr);\n return this;\n }\n}\n\n/**\n * Create a {@link Configurable} signal with the given inital value\n *\n * @category Signals\n */\nexport function value<T>(val?: T): Configurable<T> {\n const cell = Cell.mkValue(val);\n return new ConfigurableImpl<T>(cell);\n}\n\n/**\n * Create a cached version of a function. The returned callable is also a\n * {@link Signal}.\n *\n * Note: If the supplied function has a non-zero `.length` (i.e., it explicitly\n * takes arguments), it is assumed to be a {@link Source}, and the second\n * calling signature below will apply, even if TypeScript doesn't see it that\n * way!)\n *\n * @category Signals\n */\nexport function cached<T>(compute: () => T): Signal<T>;\n\n/**\n * If the supplied function has a non-zero `.length` (i.e., it explicitly takes\n * arguments), it is assumed to be a {@link Source}, and the second argument is\n * a default value for the created signal to use as default value until the\n * source produces a value.\n *\n * The source will be subscribed *only* while the signal is subscribed as a\n * stream, or observed (directly or indirectly) by a rule. While subscribed,\n * the signal will update itself with the most recent value produced by the\n * source, triggering rules or events as appropriate if the value changes. When\n * the signal is once again unobserved (or if the source ends without an error),\n * its value will revert to the supplied default.\n *\n * If the source ends *with* an error, however, then the cached function will\n * throw that error whenever called, until/unless it becomes unobserved again.\n * (And thus reverts to the default value once more.)\n *\n * @param source A {@link Source} providing data which will become this signal's\n * value\n * @param defaultVal The value to use when the signal is unobserved or waiting for\n * the first item from the source.\n */\nexport function cached<T>(source: Source<T>, defaultVal?: T): Signal<T>;\nexport function cached<T extends Signal<any>>(signal: T): T\nexport function cached<T>(compute: Source<T> | (() => T), initVal?: T): Signal<T> {\n if (compute instanceof SignalImpl) return compute;\n return new SignalImpl<T>(\n compute.length ? Cell.mkStream(compute as Source<T>, initVal) : Cell.mkCached(compute as () => T)\n );\n}\n\n/**\n * Call a function without creating a dependency on any signals it reads. (Like\n * {@link Signal.peek}, but for any function with any arguments.)\n *\n * You can also pass in any arguments the function takes, and the function's\n * return value is returned.\n *\n * (Note: Typed overloads are not supported: TypeScript will use the function's\n * *last* overload for argument-typing purposes. If you need to call a function\n * with a specific overload, wrap the function with {@link action}() instead, and\n * then TypeScript will be able to detect which overload you're using.)\n *\n * @returns The result of calling `fn(..args)`\n *\n * @category Signals\n */\nexport function peek<F extends PlainFunction>(fn: F, ...args: Parameters<F>): ReturnType<F> {\n if (!current.cell) return fn(...args);\n const old = swapCtx(makeCtx(current.job));\n try { return fn.apply(null, args); } finally { freeCtx(swapCtx(old)); }\n}\n\n/**\n * Arrange for the current signal or rule to recalculate on demand\n *\n * This lets you interop with systems that have a way to query a value and\n * subscribe to changes to it, but not directly produce a signal. (Such as\n * querying the DOM state and using a MutationObserver.)\n *\n * By calling this with a {@link Source} or {@link RecalcSource}, you arrange\n * for it to be subscribed, if and when the call occurs in a rule or a cached\n * function that's in use by a rule (directly or indirectly). When the source\n * emits a value, the signal machinery will invalidate the caching of the\n * function or rule, forcing a recalculation and subsequent rule reruns, if\n * applicable.\n *\n * Note: you should generally only call the 1-argument version of this function\n * with \"static\" sources - i.e. ones that won't change on every call. Otherwise,\n * you will end up creating new signals each time, subscribing and unsubscribing\n * on every call to recalcWhen().\n *\n * If the source needs to reference some object, it's best to use the 2-argument\n * version (i.e. `recalcWhen(someObj, factory)`, where `factory` is a function\n * that takes `someObj` and returns a suitable {@link RecalcSource}.)\n *\n * @remarks\n * recalcWhen is specifically designed so that using it does not pull in any\n * part of Uneventful's signals framework, in the event a program doesn't\n * already use it. This means you can use it in library code to provide signal\n * compatibility, without adding bundle bloat to code that doesn't use signals.\n *\n * @category Signals\n */\nexport function recalcWhen(src: RecalcSource): void;\n/**\n * Two-argument variant of recalcWhen\n *\n * In certain circumstances, you may wish to use recalcWhen with a source\n * related to some object. You could call recalcWhen with a closure, but that\n * would create and discard signals on every call. So this 2-argument version\n * lets you avoid that by allowing the use of an arbitrary object as a key,\n * along with a factory function to turn the key into a {@link RecalcSource}.\n *\n * @param key an object to be used as a key\n *\n * @param factory a function that will be called with the key to obtain a\n * {@link RecalcSource}. (Note that this factory function must also be a static\n * function, not a closure, or the same memory thrash issue will occur!)\n */\nexport function recalcWhen<T extends WeakKey>(key: T, factory: (key: T) => RecalcSource): void;\nexport function recalcWhen<T extends WeakKey>(fnOrKey: T | RecalcSource, fn?: (key: T) => RecalcSource) {\n current.cell?.recalcWhen<T>(fnOrKey as T, fn);\n}\n\n/**\n * Wrap a function (or decorate a method) so that signals it reads are not added\n * as dependencies to the current rule (if any). (Basically, it's shorthand for\n * wrapping the function or method body in a giant call to {@link peek}().)\n *\n * So, instead of writing an action function like this:\n *\n * ```ts\n * function outer(arg1, arg2) {\n * return peek(() => {\n * // reactive values used here will not be added to the running rule\n * })\n * }\n * ```\n * you can just write this:\n * ```ts\n * const outer = action((arg1, arg2) => {\n * // reactive values used here will not be added to the running rule\n * });\n * ```\n * or this:\n * ```ts\n * class Something {\n * ⁣⁣@action // auto-detects TC39 or legacy decorators\n * someMethod(arg1) {\n * // reactive values used here will not be added to the running rule\n * }\n * }\n * ```\n *\n * @param fn The function to wrap. It can take any arguments or return value,\n * and overloads are supported. However, any non-standard properties the\n * function may have had will *not* be present on the wrapped function, even if\n * TypeScript will act as if they are!\n *\n * @returns A wrapped version of the function that passes through its arguments\n * to the original function, while running with dependency tracking suppressed\n * (as with {@link peek}()).\n *\n * @category Signals\n */\nexport function action<F extends AnyFunction>(fn: F): F;\n\n/** @hidden TC39 Decorator protocol */\nexport function action<F extends AnyFunction>(fn: F, ctx: {kind: \"method\"}): F;\n\n/** @hidden Legacy Decorator protocol */\nexport function action<F extends AnyFunction, D extends {value?: F}>(\n clsOrProto: any, name: string|symbol, desc: D\n): D\n\nexport function action<F extends AnyFunction, D extends {value?: F}>(fn: F, _ctx?: any, desc?: D): D | F {\n if (desc) return {...desc, value: action(desc.value)};\n return <F> function (this: ThisParameterType<F>) {\n if (!current.cell) return fn.apply(this, arguments as any);\n const old = swapCtx(makeCtx(current.job));\n try { return fn.apply(this, arguments as any); } finally { freeCtx(swapCtx(old)); }\n }\n}\n","import { current, freeCtx, makeCtx, swapCtx } from \"./ambient.ts\";\nimport { getJob, makeJob } from \"./tracking.ts\";\nimport { AnyFunction, Job, OptionalCleanup, StartFn, StartObj, Yielding } from \"./types.ts\";\n\n/**\n * Add a cleanup function to the active job. Non-function values are ignored.\n * Equivalent to {@link getJob}().{@link Job.must must}() -- see\n * {@link Job.must}() for more details.\n *\n * @category Jobs\n */\nexport function must<T>(cleanup?: OptionalCleanup<T>): Job<T> {\n return (getJob() as Job<T>).must(cleanup);\n}\n\n/**\n * Start a nested job within the currently-active job. (Shorthand for\n * {@link getJob}().{@link Job.start start}(...).)\n *\n * This function can be called with zero, one, or two arguments:\n *\n * - When called with zero arguments, the new job is returned without any other\n * initialization.\n *\n * - When called with one argument that's a function (either a {@link SyncStart}\n * or {@link AsyncStart}): the function is run inside the new job and receives\n * it as an argument. It can return a {@link Yielding} iterator (such as a\n * generator or job), a promise, or void. A returned iterator or promise will\n * be treated as if the method was called with that to begin with; a returned\n * job will be awaited and its result transferred to the new job\n * asynchronously. A returned function will be added to the job via `must()`.\n *\n * - When called with one argument that's a {@link Yielding} iterator (such as a\n * generator or an existing job): it's attached to the new job and executed\n * asynchronously. (Starting in the next available microtask.)\n *\n * - When called with one argument that's a Promise, it's converted to a job\n * that will end when the promise settles. The resulting job is returned.\n *\n * - When called with two arguments -- a \"this\" object and a function -- it\n * works the same as one argument that's a function, except the function is\n * bound to the supplied \"this\" before being called.\n *\n * This last signature is needed because you can't make generator arrows in JS\n * yet: if you want to start() a generator function bound to the current\n * `this`, you'll want to use `.start(this, function*() { ...whatever })`.\n *\n * (Note, however, that TypeScript and/or VSCode may require that you give\n * such a function an explicit `this` parameter (e.g. `.start(this, function\n * *(this) {...}));`) in order to correctly infer types inside a generator\n * function.)\n *\n * In any of the above cases, if a supplied function throws an error while\n * starting, the new job will be ended, and the error synchronously re-thrown.\n *\n * @returns the created {@link Job}\n *\n * @category Jobs\n */\nexport function start<T>(init?: StartFn<T> | StartObj<T>): Job<T>;\n\n/**\n * The two-argument variant of start() allows you to pass a \"this\" object that\n * will be bound to the initialization function. (It's mostly useful for\n * generator functions, since generator arrows aren't a thing yet.)\n */\nexport function start<T, This>(thisArg: This, fn: StartFn<T, This>): Job<T>;\nexport function start<T, This>(init: StartFn<T>|StartObj<T>|This, fn?: StartFn<T, This>) {\n return getJob().start(init as This, fn);\n}\n\n/**\n * Is there a currently active job? (i.e., can you safely use {@link must}(),\n * or {@link getJob}() right now?)\n *\n * @category Jobs\n */\nexport function isJobActive() { return !!current.job; }\n\n\nconst timers = new WeakMap<Job,\n ReturnType<typeof setTimeout> | // current timeout\n undefined | // no timeout set since job was last restarted (if ever)\n null // current timeout is 0, aka explicit no-timeout\n>();\n\n/**\n * Set the cancellation timeout for a job.\n *\n * When the timeout is reached, the job is canceled (throwing\n * {@link CancelError} to any waiting promises or jobs), unless a new timeout\n * is set before then. You may set a new timeout value for a job as many times\n * as desired. A timeout value of zero disables the timeout. Timers are\n * disposed of if the job is canceled or restarted.\n *\n * @param ms Optional: Number of milliseconds after which the job will be\n * canceled. Defaults to zero if not given.\n *\n * @param job Optional: the job to apply the timeout to. If none is given, the\n * active job is used.\n *\n * @returns the job to which the timeout was added or removed.\n *\n * @category Scheduling\n */\nexport function timeout<T>(ms: number, job?: Job<T>): Job<T>;\nexport function timeout(ms = 0, job: Job = getJob()) {\n let timer = timers.get(job);\n if (timer) {\n clearTimeout(timer);\n } else if (timer === undefined && !job.result()) {\n // no timeout has been set since job was last restarted,\n // so we need to arrange to clear it\n job.must(timeout.bind(null, 0, job));\n }\n if (job.result()) {\n // allow restarted timer to set a new must()\n timers.delete(job);\n } else if (ms) {\n timers.set(job, setTimeout(() => { timers.set(job, null); job.end(); }, ms));\n } else {\n timers.set(job, null); // Zero = cancel timeout, but don't duplicate must() if called again\n }\n return job;\n}\n\nconst abortSignals = new WeakMap<Job, AbortSignal>();\n\n/**\n * Get an AbortSignal that aborts when the job ends or is restarted.\n *\n * @param job Optional: the job to get an AbortSignal for. If none is given,\n * the active job is used.\n *\n * @returns the AbortSignal\n *\n * @category Jobs\n */\nexport function abortSignal(job: Job = getJob()) {\n let signal = abortSignals.get(job);\n if (!signal) {\n const ctrl = new AbortController;\n signal = ctrl.signal;\n job.do(() => { abortSignals.set(job, null); ctrl.abort(); });\n abortSignals.set(job, signal);\n if (job.result()) ctrl.abort();\n }\n return signal;\n}\n\n/**\n * Wrap a function in a {@link Job} that restarts each time the resulting\n * function is called, thereby canceling any nested jobs and cleaning up any\n * resources used by previous calls. (This can be useful for such things as\n * canceling an in-progress search when the user types more text in a field.)\n *\n * The restarting job will be ended when the job that invoked `restarting()`\n * is finished, canceled, or restarted. Calling the wrapped function after its\n * job has ended will result in an error. You can wrap any function any number\n * of times: each call to `restarting()` creates a new, distinct \"restarting\n * job\" and function wrapper to go with it.\n *\n * @param task (Optional) The function to be wrapped. This can be any function:\n * the returned wrapper function will match its call signature exactly, including\n * overloads. (So for example you could wrap the {@link start} API via\n * `restarting(start)`, to create a function you can pass job-start functions to.\n * When called, the function would cancel any outstanding job from a previous\n * call, and start the new one in its place.)\n *\n * @returns A function of identical type to the input function. If no input\n * function was given, the returned function will just take one argument (a\n * zero-argument function optionally returning a {@link CleanupFn}).\n *\n * @category Jobs\n */\nexport function restarting<F extends AnyFunction>(task: F): F\nexport function restarting(): (task: () => OptionalCleanup<never>) => void\nexport function restarting<F extends AnyFunction>(task?: F): F {\n const outer = getJob(), inner = makeJob<never>(outer), {end} = inner;\n task ||= <F>((f: () => OptionalCleanup<never>) => { inner.must(f()); });\n inner.asyncCatch(e => outer.asyncThrow(e));\n return <F>function(this: any) {\n inner.restart().must(outer.release(end));\n const old = swapCtx(makeCtx(inner));\n try { return task.apply(this, arguments as any); }\n catch(e) { inner.restart(); throw e; }\n finally { freeCtx(swapCtx(old)); }\n };\n}\n\n/**\n * Wrap an argument-taking function so it will run in (and returns) a new Job\n * when called.\n *\n * This lets you avoid the common pattern of needing to write your functions or\n * methods like this:\n *\n * ```ts\n * function outer(arg1, arg2) {\n * return start(function*() {\n * // ...\n * })\n * }\n * ```\n * and instead write them like this:\n * ```ts\n * const outer = task(function *(arg1, arg2) {\n * // ...\n * });\n * ```\n * or this:\n * ```ts\n * class Something {\n * ⁣⁣@task // auto-detects TC39 or legacy decorators\n * *someMethod(arg1): Yielding<SomeResultType> {\n * // ...\n * }\n * }\n * ```\n *\n * Important: if the wrapped function or method has overloads, the resulting\n * function type will be based on the **last** overload, because TypeScript (at\n * least as of 5.x) is still not very good at dealing with higher order\n * generics, especially if overloads are involved.\n *\n * Also note that TypeScript doesn't allow decorators to change the calling\n * signature or return type of a method, so even though the above method will\n * return a {@link Job}, TypeScript will only see it as a {@link Yielding}.\n *\n * This is fine if all you're going to do is `yield *` it to wait for the\n * result, but if you need to use any job-specific methods on it, you'll have to\n * pass it through {@link start} to have TypeScript treat it as an actual job.\n * (Luckily, start() has a fast path to return the original job if it's passed a\n * job, so you won't actually create a new job by doing this.)\n *\n * @param fn The function to wrap. A function returning a generator or\n * promise-like object (i.e., a {@link StartObj}).\n *\n * @returns A wrapped version of the function that passes through its arguments\n * to the original function, while running it in a new job. (The wrapper also\n * returns the job.)\n *\n * @category Jobs\n */\nexport function task<T, A extends any[], C>(fn: (this: C, ...args: A) => StartObj<T>): (this: C, ...args: A) => Job<T>;\n\n/** @hidden TC39 Decorator protocol */\nexport function task<T, A extends any[], C>(\n fn: (this: C, ...args: A) => StartObj<T>, ctx: {kind: \"method\"}\n): (this: C, ...args: A) => Job<T>;\n\n/** @hidden Legacy Decorator protocol */\nexport function task<T, A extends any[], C, D extends {value?: (this:C, ...args: A) => StartObj<T>}>(\n clsOrProto: any, name: string|symbol, desc: D\n): D\n\nexport function task<T, A extends any[], C, D extends {value?: (this:C, ...args: A) => StartObj<T>}>(\n fn: (this: C, ...args: A) => StartObj<T>, _ctx?: any, desc?: D\n): D | ((this: C, ...args: A) => Job<T>) {\n if (desc) return {...desc, value: task(desc.value)};\n return function (this: C, ...args: A) {\n return start<T>(() => fn.apply(this, args));\n }\n}\n","import { defer } from \"./defer.ts\";\nimport { type Stream, IsStream, backpressure, Sink, Connection, Backpressure, throttle, Inlet, Source } from \"./streams.ts\";\nimport { getJob, detached } from \"./tracking.ts\";\nimport { must, start } from \"./jobutils.ts\";\nimport { DisposeFn } from \"./types.ts\";\nimport { isCancel, isError, isUnhandled, markHandled, noop } from \"./results.ts\";\n\n/**\n * A function that emits events, with a .source they're emitted from\n *\n * Created using {@link emitter}.\n *\n * @category Types and Interfaces\n */\nexport interface Emitter<T> {\n /** Call the emitter to emit events on its .source */\n (val: T): void;\n /** An event source that receives the events */\n source: Source<T>;\n /** Close all current subscribers' connections */\n end: () => void;\n /** Close all current subscribers' connections with an error */\n throw: (e: any) => void;\n};\n\n/**\n * Create an event source and a function to emit events on it\n *\n * (Note: you must specify the event type (e.g. `emitter<number>()`), since\n * there's nothing else to infer it from.)\n *\n * @returns A function that emits events, with a .source property they're\n * emitted on.\n *\n * @category Stream Producers\n */\nexport function emitter<T>(): Emitter<T> {\n const emit = mockSource<T>();\n emit.source = share(emit.source);\n return emit;\n}\n\n/**\n * A stream that immediately closes\n *\n * @category Stream Producers\n */\nexport function empty(): Source<never> {\n return (_, conn) => (conn?.return(), IsStream);\n}\n\n/**\n * Convert an async iterable to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item output by the iterator, then end the stream. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromAsyncIterable<T>(iterable: AsyncIterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.asyncIterator]();\n if (iter.return) must(() => iter.return());\n return ready(next), IsStream;\n function next() {\n iter.next().then(({value, done}) => {\n if (done) conn.return(); else ready(() => {\n if (sink(value), ready()) next(); else ready(next);\n })\n }, e => conn.throw(e));\n }\n }\n}\n\n/**\n * Create an event source from an element, window, or other event target\n *\n * You can manually override the expected event type using a type parameter,\n * e.g. `fromDomEvent<CustomEvent>(someTarget, \"custom-event\")`.\n *\n * @param target an HTMLElement, Window, Document, or other EventTarget.\n * @param type the name of the event to add a listener for\n * @param options a boolean capture option, or an object of event listener\n * options\n * @returns a source that can be subscribed or piped, issuing events from the\n * target of the specified type.\n *\n * @category Stream Producers\n */\nexport function fromDomEvent<T extends HTMLElement, K extends keyof HTMLElementEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<HTMLElementEventMap[K]>;\nexport function fromDomEvent<T extends Window, K extends keyof WindowEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<WindowEventMap[K]>;\nexport function fromDomEvent<T extends Document, K extends keyof DocumentEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<DocumentEventMap[K]>;\nexport function fromDomEvent<T extends Event>(\n target: EventTarget, type: string, options?: boolean | AddEventListenerOptions\n): Source<T>\nexport function fromDomEvent<T extends EventTarget, K extends string>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<Event> {\n return (sink) => {\n function push(v: Event) { sink(v); }\n target.addEventListener(type, push, options);\n must(() => target.removeEventListener(type, push, options));\n return IsStream;\n }\n}\n\n/**\n * Convert an iterable to a synchronous event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item in the iterator, then close the connection. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromIterable<T>(iterable: Iterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.iterator]();\n if (iter.return) must(() => iter.return());\n return ready(loop), IsStream;\n function loop() {\n try {\n for(;;) {\n const {value, done} = iter.next();\n if (done) return conn.return();\n if (sink(value), !ready()) return ready(loop);\n }\n } catch (e) {\n conn.throw(e);\n }\n }\n }\n}\n\n/**\n * Convert a Promise to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * the result of the promise, then close the connection. (Unless the promise is\n * rejected, in which case the connection throws and closes each time the source\n * is subscribed.) Non-native promises and non-promise values are converted\n * using Promise.resolve().\n *\n * @category Stream Producers\n */\nexport function fromPromise<T>(promise: Promise<T>|PromiseLike<T>|T): Source<T> {\n return (sink, conn) => {\n const job = getJob();\n Promise.resolve(promise).then(\n v => void (job.result() || (sink(v), conn?.return())),\n e => void (job.result() || conn?.throw(e))\n )\n return IsStream;\n }\n}\n\n/**\n * Create an event source from an arbitrary subscribe/unsubscribe function\n *\n * The supplied \"subscribe\" function will be passed a 1-argument callback and\n * must return an unsubscribe function. The callback should be called with\n * events of the appropriate type, and the unsubscribe function will be called\n * when the connection is closed.\n *\n * (Note: it's okay if the act of subscribing causes an immediate callback, as\n * the subscribe function will be called in a separate microtask.)\n *\n * @category Stream Producers\n */\nexport function fromSubscribe<T>(subscribe: (cb: (val: T) => void) => DisposeFn): Source<T> {\n return (sink) => {\n const f = getJob().must(() => sink = noop);\n return defer(() => f.must(subscribe(v => { sink(v); }))), IsStream;\n }\n}\n\n/**\n * Create a source that emits a single given value\n *\n * @category Stream Producers\n */\nexport function fromValue<T>(val: T): Source<T> {\n return (sink, conn) => {\n must(() => { sink = noop; conn = undefined; })\n return defer(() => { sink(val); conn?.return(); }), IsStream;\n }\n}\n\n/**\n * Create an event source that issues a number every `ms` milliseconds (starting\n * with 0 after the first interval passes).\n *\n * @category Stream Producers\n */\nexport function interval(ms: number): Source<number> {\n return (sink) => {\n let idx = 0, id = setInterval(() => sink(idx++), ms);\n return must(() => clearInterval(id)), IsStream;\n }\n}\n\n/**\n * Create a dynamic source that is created each time it's subscribed\n *\n * @param factory A function returning a source of the desired type. It will be\n * called whenever the lazy() stream is subscribed, and its result subscribed to.\n *\n * @returns A stream of the same type as the factory function returns\n *\n * @category Stream Producers\n */\nexport function lazy<T>(factory: () => Stream<T>): Source<T> {\n return (sink, conn, inlet) => factory()(sink, conn, inlet)\n}\n\n/**\n * An {@link Emitter} with a ready() method, that only supports a single active\n * subscriber. (Useful for testing stream operators and sinks.)\n *\n * Created using {@link mockSource}().\n *\n * @category Types and Interfaces\n */\nexport interface MockSource<T> extends Emitter<T> {\n ready: Backpressure\n}\n\n/**\n * Like {@link emitter}, but with a ready() backpressure method. It also only\n * supports a single active subscriber. (Useful for testing stream operators\n * and sinks.)\n *\n * @category Stream Producers\n */\nexport function mockSource<T>(): MockSource<T> {\n let write: Sink<T>, outlet: Connection, ready: Backpressure;\n const emit: MockSource<T> = (val: T) => { if (write) write(val); };\n emit.source = (sink, conn, inlet) => {\n write = sink; outlet = conn; ready = backpressure(inlet);\n must(() => write = outlet = ready = undefined);\n return IsStream;\n };\n emit.end = () => outlet?.return();\n emit.throw = (e: any) => outlet?.throw(e);\n emit.ready = (cb?: () => any) => ready(cb);\n return emit;\n}\n\n/**\n * A stream that never emits or closes\n *\n * @category Stream Producers\n */\nexport function never(): Source<never> {\n return () => IsStream;\n}\n\n/**\n * Wrap a source to allow multiple subscribers to the same underlying stream\n *\n * The input source will be susbcribed when the output has at least one\n * subscriber, and unsubscribed when the output has no subscribers. The input\n * will be paused when any subscriber pauses, and will only be resumed when all\n * subscribers are unpaused. All subscribers are closed or thrown if the input\n * source closes or throws.\n *\n * (Generally speaking, you should place the share call as late in your\n * pipelines as possible, if you use it at all. It adds some overhead that is\n * wasted if the stream doesn't have multiple subscribers, and may be redundant\n * if an upstream source is already shared. It's mainly useful if there is a\n * lot of mapping, filtering, or other complicated processing taking place\n * upstream of the share, and you know for a fact there will be enough\n * subscribers to make it a bottleneck. You should probably also consider\n * putting some {@link slack}() either upstream or downstream of the share, if\n * the upstream supports backpressure.)\n *\n * @category Stream Operators\n */\nexport function share<T>(source: Stream<T>): Source<T> {\n let uplink: Connection;\n const\n links = new Set<[sink: Sink<T>, conn: Connection]>,\n inlets = new Map<Inlet, number>(), // refcounts of incoming inlets\n t = throttle(), // the actual onReady queue\n multi: Inlet = {\n // A multi-connection inlet that requires all downstreams to be ready\n isOpen() { return !uplink?.result(); },\n isReady() {\n if (this.isOpen()) {\n for (const [i] of inlets) if (!i.isReady()) return (t.pause(), false);\n return true;\n }\n t.pause();\n return false;\n },\n onReady(cb, job) {\n if (this.isOpen()) {\n t.onReady(cb, job);\n for (const [i] of inlets) i.isReady() || i.onReady(produce, job);\n }\n return this;\n }\n }\n ;\n function produce() { multi.isReady() && t.resume(); }\n\n return (sink, conn=start(), inlet) => {\n const self: [Sink<T>, Connection] = [sink, conn];\n links.add(self);\n if (inlet) inlets.set(inlet, 1+(inlets.get(inlet) || 0));\n conn.must(() => {\n links.delete(self);\n if (inlet) {\n inlets.set(inlet, inlets.get(inlet)-1);\n if (!inlets.get(inlet)) inlets.delete(inlet);\n }\n if (!links.size) uplink?.end();\n else if (multi.isReady() && !t.isReady()) defer(produce);\n });\n if (links.size === 1) {\n uplink = detached.connect(source, v => {\n for(const [s, c] of links) try { s(v) } catch(e) { c.throw(e); };\n }, multi).do(r => {\n uplink = undefined;\n if (isCancel(r)) return;\n if (isUnhandled(r)) markHandled(r);\n for(const [_, c] of links) isError(r) ? c.throw(r.err) : c.return();\n })\n }\n return IsStream;\n }\n}\n","import { Job, Request, Suspend, Yielding } from \"./types.ts\"\nimport { defer } from \"./defer.ts\";\nimport { Connection, Inlet, Source, Sink, Stream, connect, pipe, throttle } from \"./streams.ts\";\nimport { resolve, isError, markHandled, isValue, fulfillPromise, rejecter, resolver } from \"./results.ts\";\nimport { restarting, start } from \"./jobutils.ts\";\nimport { getJob, isFunction } from \"./tracking.ts\";\nimport { Signal, cached } from \"./signals.ts\";\n\n/**\n * The result type returned from calls to {@link Each}.next()\n *\n * @category Types and Interfaces\n */\nexport type EachResult<T> = {\n /** The value provided by the source being iterated */\n item: T;\n\n /**\n * A suspend callback that must be `yield`-ed before the next call to the\n * iterator's .next() method. (That is, you must `yield next` it exactly once\n * per loop pass. See {@link each}() for more details.)\n */\n next: Suspend<void>;\n}\n\n/**\n * The iterable returned by `yield *` {@link each}()\n *\n * @category Types and Interfaces\n */\nexport type Each<T> = IterableIterator<EachResult<T>>\n\n/**\n * Asynchronously iterate over an event source\n *\n * Usage:\n *\n * ```ts\n * for (const {item: event, next} of yield *each(mouseMove)) {\n * console.log(event.clientX, event.clientY);\n * yield next; // required exactly once per iteration, even/w continue!\n * }\n * ```\n *\n * each(eventSource) yield-returns an iterator of `{item, next}` pairs. The\n * item is the data supplied by the event source, and `next` is a\n * {@link Suspend}\\<void\\> that advances the iterator to the next item. It\n * *must* be yielded exactly once per loop iteration. If you use `continue` to\n * shortcut the loop body, you must `yield next` *before* doing so.\n *\n * The for-loop will end if the source ends, errors, or is canceled. The source\n * is paused while the loop body is running, and resumed when the `yield next`\n * happens. If events arrive anyway (e.g. because the source doesn't support\n * pausing), they will be ignored unless you pipe the source through the\n * {@link slack}() operator to provide a buffer. If the for-loop is exited\n * early for any reason (or the iterator's `.return()` is called), the source is\n * unsubscribed and the iteration ended.\n *\n * @category Stream Consumers\n */\nexport function *each<T>(src: Stream<T>): Yielding<Each<T>> {\n let yielded = false, waiter: Request<void>;\n const result: IteratorYieldResult<EachResult<T>> = {value: {item: undefined as T, next}, done: false};\n const t = throttle(), conn = getJob().connect(src, v => {\n t.pause();\n if (!waiter || conn.result()) return;\n result.value.item = v;\n resolve(waiter, waiter = void 0);\n }, t).do(r => {\n // Prevent unhandled throws from here - it'll be seen by the next `yield\n // next`, or in the next microtask if `yield next` is already running.\n if (isError(r)) markHandled(r);\n if (waiter) { defer(next.bind(null, waiter)); waiter = undefined; }\n });\n\n // Wait for first value to arrive (and get put in result) before returning the iterator\n t.pause(); yield next;\n return {\n [Symbol.iterator]() { return this; },\n next() {\n if (!yielded) throw new Error(\"Must `yield next` in loop\");\n yielded = false;\n return result;\n },\n return() { conn.end(); return {value: undefined, done: true}; },\n }\n function next(r: Request<void>) {\n if (waiter) throw new Error(\"Multiple `yield next` in loop\");\n yielded = true;\n if (conn.result()) {\n result.value = undefined;\n (result as IteratorResult<any>).done = true;\n fulfillPromise(resolver(r), rejecter(r), conn.result())\n } else {\n waiter = r;\n t.resume();\n }\n }\n}\n\n/**\n * An object that can be waited on with `yield *until()`, by calling its\n * \"uneventful.until\" method. (This mostly exists to allow Signals to optimize\n * their until() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface UntilMethod<T> {\n /** Return an async op to resume once a truthy value is available */\n \"uneventful.until\"(): Yielding<T>\n}\n\n/**\n * An object that can be waited on with `yield *next()`, by calling its\n * \"uneventful.next\" method. (This mostly exists to allow Signals to optimize\n * their next() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface NextMethod<T> {\n /** Return an async op to resume with the \"next\" (i.e. not current) value produced */\n \"uneventful.next\"(): Yielding<T>\n};\n\n/**\n * Wait for and return the next truthy value (or error) from a data source (when\n * processed with `yield *` within a {@link Job}).\n *\n * This differs from {@link next}() in that it waits for the next \"truthy\" value\n * (i.e., not null, false, zero, empty string, etc.), and when used with signals\n * or a signal-using function, it can resume *immediately* if the result is\n * already truthy. (It also supports zero-argument signal-using functions,\n * automatically wrapping them with {@link cached}(), as the common use case for\n * until() is to wait for an arbitrary condition to be satisfied.)\n *\n * @param source The source to wait on, which can be:\n * - An object with an `\"uneventful.until\"` method returning a {@link Yielding}\n * (in which case the result will be the the result of calling that method)\n * - A {@link Signal}, or a zero-argument function returning a value based on\n * signals (in which case the job resumes as soon as the result is truthy,\n * perhaps immediately)\n * - A {@link Source} (in which case the job resumes on the next truthy value\n * it produces\n *\n * (Note: if the supplied source is a function with a non-zero `.length`, it is\n * assumed to be a {@link Source}.)\n *\n * @returns a Yieldable that when processed with `yield *` in a job, will return\n * the triggered event, or signal value. An error is thrown if event stream\n * throws or closes early, or the signal throws.\n *\n * @category Signals\n * @category Scheduling\n */\nexport function until<T>(source: UntilMethod<T> | Stream<T> | (() => T)): Yielding<T> {\n return callOrWait<T>(source, \"uneventful.until\", waitTruthy, recache);\n}\nfunction recache<T>(s: () => T) { return until(cached(s)); }\nfunction waitTruthy<T>(job: Job<T>, v: T) { v && job.return(v); }\n\n/**\n * Wait for and return the next value (or error) from a data source (when\n * processed with `yield *` within a {@link Job}).\n *\n * This differs from {@link until}() in that it waits for the *next* value\n * (truthy or not!), and it never resumes immediately for signals, but instead\n * waits for the signal to *change*. (Also, it does not support zero-argument\n * functions, unless you wrap them with {@link cached}() first.)\n *\n * @param source The source to wait on, which can be:\n * - An object with an `\"uneventful.next\"` method returning a {@link Yielding}\n * (in which case the result will be the the result of calling that method)\n * - A {@link Signal} or {@link Source} (in which case the job resumes on the\n * next value it produces)\n *\n * (Note: if the supplied source is a function with a non-zero `.length`, it is\n * assumed to be a {@link Source}.)\n *\n * @returns a Yieldable that when processed with `yield *` in a job, will return\n * the triggered event, or signal value. An error is thrown if event stream\n * throws or closes early, or the signal throws.\n *\n * @category Stream Consumers\n * @category Scheduling\n */\nexport function next<T>(source: NextMethod<T> | Stream<T>): Yielding<T> {\n return callOrWait<T>(source, \"uneventful.next\", waitAny, mustBeSourceOrSignal);\n}\n\nfunction waitAny<T>(job: Job<T>, v: T) { job.return(v); }\n\nfunction callOrWait<T>(\n source: any, method: string, handler: (job: Job<T>, val: T) => void, noArgs: (f?: any) => Yielding<T>|void\n) {\n if (source && isFunction(source[method])) return source[method]() as Yielding<T>;\n if (isFunction(source)) return (\n source.length === 0 ? noArgs(source) : false\n ) || start<T>(job => {\n connect(source as Source<T>, v => handler(job, v)).do(r => {\n if(isValue(r)) job.throw(new Error(\"Stream ended\"));\n else if (isError(r)) job.throw(markHandled(r));\n });\n })\n mustBeSourceOrSignal();\n}\n\nfunction mustBeSourceOrSignal() { throw new TypeError(\"not a source or signal\"); }\n\n/**\n * Run a {@link restarting}() callback for each value produced by a source.\n *\n * With each event that occurs, any previous callback run is cleaned up before\n * the new one begins. (And the last run is cleaned up when the connection or\n * job ends.)\n *\n * This function is almost the exact opposite of {@link each}(), in that the\n * stream is never paused (unless you do so manually via a throttle or inlet),\n * and if the \"loop body\" (callback job) is still running when a new value\n * arrives, forEach() restarts the job instead of dropping the value.\n *\n * @param src An event source (i.e. a {@link Source} or {@link Signal})\n * @param sink A callback that receives values from the source\n * @param inlet An optional throttle or inlet that will be used to pause the\n * source (if it's a signal or supports backpressure)\n * @returns a {@link Connection} that can be used to detect the stream\n * end/error, or ended to close it early.\n *\n * @category Stream Consumers\n */\nexport function forEach<T>(src: Stream<T>, sink: Sink<T>, inlet?: Inlet): Connection;\n/**\n * When called without a source, return a callback suitable for use w/{@link pipe}().\n * e.g.:\n *\n * ```ts\n * pipe(someSource, ..., forEach(v => { doSomething(v); }), optionalInlet));\n * ```\n *\n */\nexport function forEach<T>(sink: Sink<T>, inlet?: Inlet): (src: Stream<T>) => Connection;\nexport function forEach<T>(\n src: Stream<T>|Sink<T>, sink?: Sink<T>|Inlet, inlet?: Inlet\n): Connection | ((src: Stream<T>) => Connection) {\n if (isFunction(sink)) return start(j => {\n (src as Stream<T>)(restarting(sink as Sink<T>), j, inlet)\n });\n inlet = sink as Inlet; sink = src as Sink<T>;\n return (src: Stream<T>) => forEach(src, sink as Sink<T>, inlet);\n}\n","import { fromIterable } from \"./sources.ts\";\nimport { Connection, IsStream, Source, Sink, Stream, Transformer, backpressure, throttle } from \"./streams.ts\";\nimport { isValue, noop } from \"./results.ts\";\nimport { start } from \"./jobutils.ts\";\n\n/**\n * Output multiple streams' contents in order (from an array/iterable of stream\n * sources)\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * Note: this function is just shorthand for {@link concatAll}({@link fromIterable}(*sources*)).\n *\n * @category Stream Operators\n */\nexport function concat<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return concatAll(fromIterable(sources))\n}\n\n/**\n * Flatten a source of sources by emitting their contents in series\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * If you want to switch to a new stream whenever a new source arrives from the\n * input stream, use {@link switchAll} instead.\n *\n * @category Stream Operators\n */\nexport function concatAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n const inputs: Stream<T>[] = [], t = throttle();\n let outer = conn.connect(sources, s => {\n inputs.push(s); startNext(); t.pause();\n }, t).do(r => {\n outer = undefined\n inputs.length || inner || !isValue(r) || conn.return();\n });\n function startNext() {\n inner ||= conn.connect(inputs.shift(), sink, inlet).do(r => {\n inner = undefined;\n inputs.length ? startNext() : (outer ? t.resume() : !isValue(r) || conn.return());\n });\n }\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then concatenate the resulting\n * substreams\n *\n * (This is just shorthand for `compose(map(mapper), concatAll)`.)\n *\n * If you want to switch to a new stream whenever a new event arrives on the\n * input stream, use {@link switchMap} instead.\n *\n * @category Stream Operators\n */\nexport function concatMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => concatAll(map(mapper)(src))\n}\n\n\n/**\n * Create a subset of a stream, based on a filter function (like Array.filter)\n *\n * The filter function receives the current index (zero-based) as well as the\n * current value. If it returns truth, the value will be passed to the output,\n * otherwise it will be skipped.\n *\n * If the filter function is typed as a Typescript type guard (i.e. as returning\n * `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function filter<T,R extends T>(filter: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => filter(v, idx++) && sink(v), conn, inlet);\n }\n}\n\n/**\n * Replace each value in a stream using a function (like Array.map)\n *\n * The mapping function receives the current index (zero-based) as well as the\n * current value.\n *\n * @category Stream Operators\n */\nexport function map<T,R>(mapper: (v: T, idx: number) => R): Transformer<T,R> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => sink(mapper(v, idx++)), conn, inlet);\n }\n}\n\n/**\n * Create an event source by merging an array or iterable of event sources.\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function merge<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return mergeAll(fromIterable(sources));\n}\n\n/**\n * Create an event source by merging sources from a stream of event sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function mergeAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const uplinks: Set<Connection> = new Set;\n let outer = conn.connect(sources, (s) => {\n const c = conn.connect(s, sink, inlet).do(r => {\n uplinks.delete(c);\n uplinks.size || outer || !isValue(r) || conn.return();\n });\n uplinks.add(c);\n }).do(r => {\n outer = undefined;\n uplinks.size || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Create an event source by merging sources created by mapping events to sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * (Note: this is just shorthand for `compose(map(mapper), mergeAll)`.)\n *\n * @category Stream Operators\n */\nexport function mergeMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => mergeAll(map(mapper)(src));\n}\n\n/**\n * Skip the first N items from a source\n *\n * (Equivalent to {@link skipWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function skip<T>(n: number): Transformer<T> {\n return skipWhile((_, i) => i<n);\n}\n\n/**\n * Skip items from a stream until another source produces a value.\n *\n * If the notifier closes without producing a value, the output will\n * be empty. If the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function skipUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n let taking = false;\n const c = conn.connect(notifier, () => { taking = true; c.end(); });\n return src(v => taking && sink(v), conn, inlet);\n }\n}\n\n/**\n * Skip items from a stream until a given condition is false, then output all\n * remaining items. The condition function is not called again once it returns\n * false.\n *\n * @category Stream Operators\n */\nexport function skipWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0, met = false;\n return src(v => (met ||= !condition(v, idx++)) && sink(v), conn, inlet);\n };\n}\n\n/**\n * Add job control and buffering to a stream\n *\n * This lets you block events from a stream that can't be paused, or allow for\n * some slack for a source that can sometimes get ahead of its sink.\n *\n * @param size The number of items to buffer when the sink is busy (i.e., the\n * sink is running or the connection is paused). If positive, the most recent N\n * items are kept (a \"sliding\" buffer), and if negative, the oldest N item are\n * kept (a \"dropping\" buffer). If zero, no items are buffered, and items are\n * dropped if received while the sink is busy.\n *\n * @param dropped Optional: a callback that will receive items when they are\n * dropped. (Useful for testing, performance instrumentation, error logging,\n * etc.)\n *\n * @category Stream Operators\n */\nexport function slack<T>(size: number, dropped: Sink<T> = noop): Transformer<T> {\n const max = Math.abs(size);\n return src => (sink, conn=start(), inlet) => {\n const buffer: T[] = [], ready = backpressure(inlet);\n let paused = false, draining = false;\n const t = throttle();\n conn.connect(src, v => {\n buffer.push(v);\n if (!draining && ready()) return drain();\n while (buffer.length > max) { dropped((size < 0) ? buffer.pop() : buffer.shift()); }\n if (buffer.length === max) { t.pause(); paused = true; }\n if (buffer.length) ready(drain);\n }, t).do(r => {\n if (isValue(r)) conn.return();\n });\n\n function drain() {\n draining = true;\n try {\n while(buffer.length) {\n sink(buffer.shift());\n if (paused && ready()) {\n paused = false; t.resume();\n }\n if (buffer.length && !ready()) {\n return ready(drain);\n }\n }\n } finally {\n draining = false;\n }\n }\n return IsStream;\n }\n}\n\n/**\n * Flatten a source of sources by emitting their contents until a new one\n * arrives.\n *\n * As each source arrives from the input stream, its values are sent to the\n * output, closing the previous one (if any). The output is closed when both\n * the input stream and the most-recently-arrived stream are finished. Errors\n * propagate to the output if any stream throws.\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatAll} or {@link mergeAll} instead.)\n *\n * @category Stream Operators\n */\nexport function switchAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n let outer = conn.connect(sources, s => {\n inner?.end();\n inner = conn.connect(s, sink, inlet).do(r => {\n inner = undefined;\n outer || !isValue(r) || conn.return();\n });\n }).do(r => {\n outer = undefined;\n inner || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then output the resulting\n * substreams until a new value arrives.\n *\n * (This is just shorthand for `compose(map(mapper),`{@link switchAll `switchAll)`}.)\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatMap} or {@link mergeMap} instead.)\n *\n * @category Stream Operators\n */\nexport function switchMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => switchAll(map(mapper)(src))\n}\n\n/**\n * Take the first N items from a source\n *\n * (Equivalent to {@link takeWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function take<T>(n: number): Transformer<T> {\n return takeWhile((_, i) => i<n);\n}\n\n/**\n * Take items from a source until another source produces a value.\n *\n * If the notifier closes without producing a value, this will output all\n * elements of the input. But if the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function takeUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n conn.connect(notifier, () => conn.return());\n return src(sink, conn, inlet);\n }\n}\n\n/**\n * Take items from a stream until a given condition is false, then close the\n * output. The condition function is not called again after it returns false.\n *\n * If the condition function is typed as a Typescript type guard (i.e. as\n * returning `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function takeWhile<T,R extends T>(condition: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function takeWhile<T>(condition: (v: T, idx: number) => boolean): Transformer<T>;\nexport function takeWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0;\n return src(v => condition(v, idx++) ? sink(v) : conn?.return(), conn, inlet);\n };\n}\n"],"names":[],"mappings":"AAAU,IAAC,KAAK,GAAG,OAAO,cAAc,KAAK,UAAU,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE;;ACAjH,SAAS,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE;AACtC,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACvB,CAAC;AACM,SAAS,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE;AACxC,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC;AACM,SAAS,QAAQ,CAAC,OAAO,EAAE;AAClC,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC;AACM,SAAS,QAAQ,CAAC,OAAO,EAAE;AAClC,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC,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ity: signals, streams, structured concurrency, and easy resource cleanup",
5
5
  "keywords": [
6
6
  "signals",