@webmusic/kernel 0.2.0 → 0.4.0
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/LICENSE +202 -21
- package/NOTICE +2 -0
- package/README.md +103 -64
- package/dist/audio-context.cjs.map +1 -1
- package/dist/build-receipt.json +3 -3
- package/dist/chunk-27LH6QLZ.cjs +277 -0
- package/dist/chunk-27LH6QLZ.cjs.map +1 -0
- package/dist/chunk-3INDOVUC.cjs.map +1 -1
- package/dist/chunk-3RR2VIKA.js +393 -0
- package/dist/chunk-3RR2VIKA.js.map +1 -0
- package/dist/chunk-3YTKIKKX.cjs +378 -0
- package/dist/chunk-3YTKIKKX.cjs.map +1 -0
- package/dist/chunk-4RG4WQKC.js +360 -0
- package/dist/chunk-4RG4WQKC.js.map +1 -0
- package/dist/chunk-5AHVQXTF.cjs +620 -0
- package/dist/chunk-5AHVQXTF.cjs.map +1 -0
- package/dist/chunk-624KWJWZ.js +170 -0
- package/dist/chunk-624KWJWZ.js.map +1 -0
- package/dist/chunk-6HGFEKD3.cjs +851 -0
- package/dist/chunk-6HGFEKD3.cjs.map +1 -0
- package/dist/chunk-7ZTZZ5PN.cjs.map +1 -1
- package/dist/chunk-ALWV4P7D.js +726 -0
- package/dist/chunk-ALWV4P7D.js.map +1 -0
- package/dist/chunk-BADJJ6DV.cjs +143 -0
- package/dist/chunk-BADJJ6DV.cjs.map +1 -0
- package/dist/chunk-C3LMS36L.cjs +393 -0
- package/dist/chunk-C3LMS36L.cjs.map +1 -0
- package/dist/chunk-C3YWUZW3.cjs.map +1 -1
- package/dist/chunk-CR6OUWBJ.cjs +726 -0
- package/dist/chunk-CR6OUWBJ.cjs.map +1 -0
- package/dist/chunk-CYWDZLWC.js +2141 -0
- package/dist/chunk-CYWDZLWC.js.map +1 -0
- package/dist/chunk-DDOGX2D5.js +378 -0
- package/dist/chunk-DDOGX2D5.js.map +1 -0
- package/dist/chunk-DVN6E5U3.js +620 -0
- package/dist/chunk-DVN6E5U3.js.map +1 -0
- package/dist/chunk-EURMRU2S.js +208 -0
- package/dist/chunk-EURMRU2S.js.map +1 -0
- package/dist/chunk-EXDCK2VL.cjs +20 -0
- package/dist/chunk-EXDCK2VL.cjs.map +1 -0
- package/dist/chunk-G5EIUP52.js +114 -0
- package/dist/chunk-G5EIUP52.js.map +1 -0
- package/dist/chunk-GB4DGKLZ.js +143 -0
- package/dist/chunk-GB4DGKLZ.js.map +1 -0
- package/dist/chunk-GPOEAYOW.js +2147 -0
- package/dist/chunk-GPOEAYOW.js.map +1 -0
- package/dist/chunk-I4YMA5VM.cjs +120 -0
- package/dist/chunk-I4YMA5VM.cjs.map +1 -0
- package/dist/chunk-IVWHMDCB.cjs +4383 -0
- package/dist/chunk-IVWHMDCB.cjs.map +1 -0
- package/dist/chunk-JFCBJMA7.cjs +2147 -0
- package/dist/chunk-JFCBJMA7.cjs.map +1 -0
- package/dist/chunk-JLVSAZ3K.cjs +813 -0
- package/dist/chunk-JLVSAZ3K.cjs.map +1 -0
- package/dist/chunk-K7FYH6UG.cjs +208 -0
- package/dist/chunk-K7FYH6UG.cjs.map +1 -0
- package/dist/chunk-L4MYCETM.cjs +970 -0
- package/dist/chunk-L4MYCETM.cjs.map +1 -0
- package/dist/chunk-MNCMYNYL.js +970 -0
- package/dist/chunk-MNCMYNYL.js.map +1 -0
- package/dist/chunk-NT2BZ3QM.js +120 -0
- package/dist/chunk-NT2BZ3QM.js.map +1 -0
- package/dist/chunk-O7SA5GLC.js +277 -0
- package/dist/chunk-O7SA5GLC.js.map +1 -0
- package/dist/chunk-OCKAHITL.cjs +548 -0
- package/dist/chunk-OCKAHITL.cjs.map +1 -0
- package/dist/chunk-OTXYWCLA.js +206 -0
- package/dist/chunk-OTXYWCLA.js.map +1 -0
- package/dist/chunk-P6ZA63J7.js +548 -0
- package/dist/chunk-P6ZA63J7.js.map +1 -0
- package/dist/chunk-QLF3BOST.js +20 -0
- package/dist/chunk-QLF3BOST.js.map +1 -0
- package/dist/chunk-RCWFRZDR.js +4383 -0
- package/dist/chunk-RCWFRZDR.js.map +1 -0
- package/dist/chunk-RZBLPM3L.cjs +206 -0
- package/dist/chunk-RZBLPM3L.cjs.map +1 -0
- package/dist/chunk-TA3TNJZU.cjs +360 -0
- package/dist/chunk-TA3TNJZU.cjs.map +1 -0
- package/dist/chunk-TZSRPTQL.cjs +2141 -0
- package/dist/chunk-TZSRPTQL.cjs.map +1 -0
- package/dist/chunk-UMTPJ76S.cjs.map +1 -1
- package/dist/chunk-UY77FXDW.js +813 -0
- package/dist/chunk-UY77FXDW.js.map +1 -0
- package/dist/chunk-VFU3S7OC.js +851 -0
- package/dist/chunk-VFU3S7OC.js.map +1 -0
- package/dist/chunk-VY6WWZSW.cjs.map +1 -1
- package/dist/chunk-WN5DZOVT.cjs +170 -0
- package/dist/chunk-WN5DZOVT.cjs.map +1 -0
- package/dist/chunk-WOPW6WLR.cjs.map +1 -1
- package/dist/chunk-XBSIYUHM.cjs +114 -0
- package/dist/chunk-XBSIYUHM.cjs.map +1 -0
- package/dist/chunk-ZMU72HJS.cjs.map +1 -1
- package/dist/context-DSa0ymyN.d.cts +664 -0
- package/dist/context-DaxfAg3b.d.ts +664 -0
- package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
- package/dist/effect-chain-Do75T7uK.d.cts +91 -0
- package/dist/effect.cjs +16 -1
- package/dist/effect.cjs.map +1 -1
- package/dist/effect.d.cts +56 -14
- package/dist/effect.d.ts +56 -14
- package/dist/effect.js +16 -1
- package/dist/elements.cjs +37 -2
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.d.cts +197 -8
- package/dist/elements.d.ts +197 -8
- package/dist/elements.js +36 -1
- package/dist/events.cjs.map +1 -1
- package/dist/index.cjs +555 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +566 -19
- package/dist/message.cjs +104 -0
- package/dist/message.cjs.map +1 -0
- package/dist/message.d.cts +738 -0
- package/dist/message.d.ts +738 -0
- package/dist/message.js +104 -0
- package/dist/meter.cjs.map +1 -1
- package/dist/module-control-C25BMtH7.d.ts +61 -0
- package/dist/module-control-yH6nTJM9.d.cts +61 -0
- package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
- package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
- package/dist/module.cjs +263 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.d.cts +1112 -0
- package/dist/module.d.ts +1112 -0
- package/dist/module.js +263 -0
- package/dist/parameter-DwQzFmBR.d.cts +172 -0
- package/dist/parameter-DwQzFmBR.d.ts +172 -0
- package/dist/player.cjs.map +1 -1
- package/dist/processor-worklet.cjs +18 -0
- package/dist/processor-worklet.cjs.map +1 -0
- package/dist/processor-worklet.d.cts +166 -0
- package/dist/processor-worklet.d.ts +166 -0
- package/dist/processor-worklet.js +18 -0
- package/dist/processor-worklet.js.map +1 -0
- package/dist/processor.cjs +51 -0
- package/dist/processor.cjs.map +1 -0
- package/dist/processor.d.cts +397 -0
- package/dist/processor.d.ts +397 -0
- package/dist/processor.js +51 -0
- package/dist/processor.js.map +1 -0
- package/dist/project-types-BU4awMnL.d.ts +323 -0
- package/dist/project-types-DufCV8Ma.d.cts +323 -0
- package/dist/ring-C-i9N90a.d.cts +139 -0
- package/dist/ring-DkcMt2Eg.d.ts +139 -0
- package/dist/sequence.cjs +68 -0
- package/dist/sequence.cjs.map +1 -0
- package/dist/sequence.d.cts +303 -0
- package/dist/sequence.d.ts +303 -0
- package/dist/sequence.js +68 -0
- package/dist/sequence.js.map +1 -0
- package/dist/session.cjs +16 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +407 -0
- package/dist/session.d.ts +407 -0
- package/dist/session.js +16 -0
- package/dist/session.js.map +1 -0
- package/dist/tick.cjs.map +1 -1
- package/dist/transport.cjs +50 -2
- package/dist/transport.cjs.map +1 -1
- package/dist/transport.d.cts +145 -1
- package/dist/transport.d.ts +145 -1
- package/dist/transport.js +51 -3
- package/dist/worker.cjs.map +1 -1
- package/package.json +61 -10
- package/dist/chunk-53YD73OY.js +0 -162
- package/dist/chunk-53YD73OY.js.map +0 -1
- package/dist/chunk-54JYWB5X.cjs +0 -1051
- package/dist/chunk-54JYWB5X.cjs.map +0 -1
- package/dist/chunk-BR63OD53.cjs +0 -1
- package/dist/chunk-BR63OD53.cjs.map +0 -1
- package/dist/chunk-ON64FRCF.js +0 -1051
- package/dist/chunk-ON64FRCF.js.map +0 -1
- package/dist/chunk-SM5YPDDI.cjs +0 -162
- package/dist/chunk-SM5YPDDI.cjs.map +0 -1
- package/dist/chunk-TEM2I2NN.js +0 -1
- package/dist/chunk-VVZX7DQ6.cjs +0 -254
- package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
- package/dist/chunk-WNFGDB7B.js +0 -254
- package/dist/chunk-WNFGDB7B.js.map +0 -1
- package/dist/sync.cjs +0 -12
- package/dist/sync.cjs.map +0 -1
- package/dist/sync.d.cts +0 -307
- package/dist/sync.d.ts +0 -307
- package/dist/sync.js +0 -12
- /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
- /package/dist/{sync.js.map → module.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/chunk-CR6OUWBJ.cjs","../src/module/message.ts","../src/module/musical-time.ts","../src/module/graph-module.ts","../src/module/module-plugin.ts"],"names":["_disposed"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACMA,IAAM,YAAA,EAAc,CAAC,KAAA,EAAA,GAA4C,MAAA,CAAO,MAAA,C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A;AACR,IAAA;AAAM,MAAA;AAAc,QAAA;AAAW,MAAA;AAAwC,MAAA;AACzD,IAAA;AAAQ,MAAA;AAAQ,IAAA;AAC5C,EAAA;AAEwC,EAAA;AAClC,IAAA;AAAO,MAAA;AAAmB,IAAA;AAAiB,MAAA;AAAG,IAAA;AACpD,EAAA;AAAA;AAG0B,EAAA;AACG,IAAA;AAC7B,EAAA;AACF;AAlJW;AACA;AACA;AACA;AACA;AACT;AACA;AACA;AA8IiF;AH8btC;AACA;AI9mBR;AAyB6B;AACtC,EAAA;AACtB,EAAA;AAE4B,EAAA;AACzB,EAAA;AACM,IAAA;AACX,IAAA;AACkC,IAAA;AACG,IAAA;AACvC,EAAA;AACF;AAMyE;AACjD,EAAA;AACoB,IAAA;AAC1C,EAAA;AACF;AAaE;AAEqB,EAAA;AACf,IAAA;AACK,IAAA;AACqD,IAAA;AAC3C,MAAA;AACb,MAAA;AACA,MAAA;AACmC,QAAA;AACF,QAAA;AACrB,MAAA;AACO,QAAA;AACa,QAAA;AACtB,UAAA;AACZ,QAAA;AACM,QAAA;AACR,MAAA;AACuB,MAAA;AAChB,MAAA;AACL,QAAA;AAC4B,QAAA;AACiB,QAAA;AACX,QAAA;AACP,QAAA;AACA,QAAA;AACC,QAAA;AAAmG;AAE/F,QAAA;AACA,QAAA;AACF,QAAA;AAChC,MAAA;AACF,IAAA;AACD,EAAA;AACH;AJqkB6C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/chunk-CR6OUWBJ.cjs","sourcesContent":[null,"import {createConnectionLease, type ConnectionLease} from './lease';\nimport {PortListeners, type PortMultiplicity, type PortReadiness} from './port';\nimport type {ParamHandle} from './parameter';\n\n// ============================================================================\n// The `message` port family (DEC-075): discrete values between modules, as in\n// Max. A message is a selector and typed atoms with an optional logical time.\n// Delivery is synchronous and depth first, inputs in connection order.\n// ============================================================================\n\nexport type JsonValue = null | boolean | number | string | readonly JsonValue[] | {readonly [key: string]: JsonValue};\n\n/** One element of a message. Ints and floats stay distinct, as in Max. */\nexport type Atom =\n | {readonly type: 'int'; readonly value: number}\n | {readonly type: 'float'; readonly value: number}\n | {readonly type: 'symbol'; readonly value: string}\n | {readonly type: 'dict'; readonly value: {readonly [key: string]: JsonValue}}\n | {readonly type: 'array'; readonly value: readonly JsonValue[]};\n\nexport interface Message {\n /** `bang`, `int`, `float`, `symbol`, `list`, or the leading word of any other message. */\n readonly selector: string;\n readonly atoms: readonly Atom[];\n /** Logical time in AudioContext seconds; absent for an untimed (immediate) event. */\n readonly time?: number;\n}\n\nconst freezeAtoms = (atoms: readonly Atom[]): readonly Atom[] => Object.freeze(atoms.map(atom => Object.freeze({...atom})));\n\nexport function intAtom(value: number): Atom {\n if (!Number.isFinite(value)) throw new RangeError('An int atom requires a finite number.');\n return Object.freeze({type: 'int', value: Math.trunc(value)});\n}\nexport function floatAtom(value: number): Atom {\n if (!Number.isFinite(value)) throw new RangeError('A float atom requires a finite number.');\n return Object.freeze({type: 'float', value});\n}\nexport function symbolAtom(value: string): Atom {\n if (typeof value !== 'string') throw new TypeError('A symbol atom requires a string.');\n return Object.freeze({type: 'symbol', value});\n}\n\n/** A message with an explicit selector. */\nexport function message(selector: string, atoms: readonly Atom[] = [], time?: number): Message {\n if (typeof selector !== 'string' || !selector) throw new TypeError('A message requires a selector.');\n if (time !== undefined && !Number.isFinite(time)) throw new RangeError('Message time must be finite.');\n return Object.freeze({selector, atoms: freezeAtoms(atoms), ...(time === undefined ? {} : {time})});\n}\n\nexport const bang = (time?: number): Message => message('bang', [], time);\nexport const intMessage = (value: number, time?: number): Message => message('int', [intAtom(value)], time);\nexport const floatMessage = (value: number, time?: number): Message => message('float', [floatAtom(value)], time);\nexport const symbolMessage = (value: string, time?: number): Message => message('symbol', [symbolAtom(value)], time);\n\n/** A copy of `value` at `time` (or untimed when `time` is undefined). */\nexport function withTime(value: Message, time: number | undefined): Message {\n if (value.time === time) return value;\n return message(value.selector, value.atoms, time);\n}\n\n/**\n * The atoms a message carries, as a list would: a number, symbol or list\n * message gives its atoms; any other message gives its selector as a leading\n * symbol, then its atoms; a bang gives none.\n */\nexport function atomsOf(value: Message): readonly Atom[] {\n switch (value.selector) {\n case 'bang': return [];\n case 'int': case 'float': case 'symbol': case 'list': return value.atoms;\n default: return [symbolAtom(value.selector), ...value.atoms];\n }\n}\n\n/**\n * The message a list of atoms makes, as Max forms it: nothing is a bang, one\n * number is an int or float, a leading number makes a list, and a leading\n * symbol becomes the selector — alone, it is a message with no atoms.\n */\nexport function messageFromAtoms(atoms: readonly Atom[], time?: number): Message {\n if (!atoms.length) return bang(time);\n const [first, ...rest] = atoms;\n if (atoms.length === 1) {\n if (first.type === 'int') return message('int', atoms, time);\n if (first.type === 'float') return message('float', atoms, time);\n // A lone word is its own selector, as in Max: `stop` is the message stop, not `symbol stop`.\n if (first.type === 'symbol') return first.value === 'bang' ? bang(time) : message(first.value, [], time);\n return message('list', atoms, time);\n }\n if (first.type === 'symbol') return message(first.value, rest, time);\n return message('list', atoms, time);\n}\n\n/** The first number a message carries, or undefined. */\nexport function numberOf(value: Message): number | undefined {\n const atom = atomsOf(value).find(item => item.type === 'int' || item.type === 'float');\n return atom ? atom.value as number : undefined;\n}\n\n/** True for an int or float atom. */\nexport const isNumberAtom = (atom: Atom | undefined): atom is Extract<Atom, {type: 'int' | 'float'}> =>\n atom?.type === 'int' || atom?.type === 'float';\n\n/** Parse one word of message-box text into an atom. */\nexport function parseAtom(word: string): Atom {\n if (/^[-+]?\\d+$/.test(word)) return intAtom(Number(word));\n if (/^[-+]?(\\d+\\.\\d*|\\.\\d+|\\d+\\.?\\d*[eE][-+]?\\d+)$/.test(word)) return floatAtom(Number(word));\n return symbolAtom(word);\n}\n\n/**\n * Parse message-box text: space-separated atoms; a double-quoted word keeps its\n * spaces. `parseMessage('set 3 4.5')` is a `set` message with an int and a float.\n */\nexport function parseMessage(text: string, time?: number): Message {\n const words: string[] = [];\n const pattern = /\"((?:[^\"\\\\]|\\\\.)*)\"|(\\S+)/g;\n const quoted = new Set<number>();\n for (const match of text.matchAll(pattern)) {\n if (match[1] !== undefined) { quoted.add(words.length); words.push(match[1].replace(/\\\\(.)/g, '$1')); }\n else words.push(match[2]!);\n }\n const atoms = words.map((word, index) => quoted.has(index) ? symbolAtom(word) : parseAtom(word));\n // One quoted word stays a symbol: `\"two words\"` is data, not a command.\n if (atoms.length === 1 && quoted.has(0)) return message('symbol', atoms, time);\n return messageFromAtoms(atoms, time);\n}\n\nconst formatAtom = (atom: Atom): string => {\n switch (atom.type) {\n case 'int': return String(atom.value);\n case 'float': return Number.isInteger(atom.value) ? `${atom.value}.` : String(atom.value);\n case 'symbol': return /\\s|^$/.test(atom.value) || /^[-+]?[\\d.]/.test(atom.value) ? JSON.stringify(atom.value) : atom.value;\n default: return JSON.stringify(atom.value);\n }\n};\n\n/** Message-box text for a message; `parseMessage(formatMessage(m))` gives an equal message for int, float and symbol atoms. */\nexport function formatMessage(value: Message): string {\n return atomsOf(value).map(formatAtom).join(' ') || 'bang';\n}\n\n/** Raised when nested message deliveries exceed {@link MAX_MESSAGE_DEPTH}. */\nexport class MessageStackOverflowError extends Error {\n constructor() {\n super(`Message delivery nested deeper than ${MAX_MESSAGE_DEPTH}; a patch is probably feeding back into itself.`);\n this.name = 'MessageStackOverflowError';\n }\n}\n\n/** Nesting limit for synchronous deliveries, shared by every message port. */\nexport const MAX_MESSAGE_DEPTH = 512;\nlet depth = 0;\n\nexport interface MessageOutputPortOptions {\n id?: string;\n /** Receives a listener's failure and stack overflows; delivery continues to the next input. */\n onListenerError?: (error: unknown) => void;\n}\n\n/** Producer side of the message family. */\nexport class MessageOutputPort {\n readonly id: string;\n readonly family = 'message' as const;\n readonly direction = 'output' as const;\n readonly multiplicity = 'sum' as const;\n readonly schemaVersion = 1 as const;\n readonly #listeners: PortListeners<Message>;\n readonly #onError?: (error: unknown) => void;\n #disposed = false;\n\n constructor(options: MessageOutputPortOptions = {}) {\n this.id = options.id ?? 'outlet';\n this.#onError = options.onListenerError;\n this.#listeners = new PortListeners(options.onListenerError);\n Object.freeze(this);\n }\n\n get disposed(): boolean { return this.#disposed; }\n get readiness(): PortReadiness { return this.#disposed ? 'detached' : 'ready'; }\n\n /** Deliver to every connected input in connection order, each depth first. A disposed port drops the message. */\n send(value: Message): void {\n if (this.#disposed) return;\n if (depth >= MAX_MESSAGE_DEPTH) {\n try { this.#onError?.(new MessageStackOverflowError()); } catch { /* Diagnostics never re-enter delivery. */ }\n return;\n }\n depth++;\n try { this.#listeners.emit(value); } finally { depth--; }\n }\n\n subscribe(listener: (value: Message) => void): () => void {\n if (this.#disposed) throw new Error('MessageOutputPort is disposed');\n return this.#listeners.add(listener);\n }\n\n dispose(): void {\n if (this.#disposed) return;\n this.#disposed = true;\n this.#listeners.clear();\n }\n}\n\nexport interface MessageInputPortOptions {\n id?: string;\n multiplicity?: PortMultiplicity;\n}\n\n/** Consumer side of the message family. */\nexport class MessageInputPort {\n readonly id: string;\n readonly family = 'message' as const;\n readonly direction = 'input' as const;\n readonly multiplicity: PortMultiplicity;\n readonly schemaVersion = 1 as const;\n readonly #handler: (value: Message) => void;\n readonly #connections = new Map<MessageOutputPort, ConnectionLease>();\n #disposed = false;\n\n constructor(handler: (value: Message) => void, options: MessageInputPortOptions = {}) {\n if (typeof handler !== 'function') throw new TypeError('Message input needs a handler.');\n const multiplicity = options.multiplicity ?? 'sum';\n if (multiplicity !== 'single' && multiplicity !== 'sum') throw new TypeError(`Unknown port multiplicity: ${String(multiplicity)}`);\n this.#handler = handler;\n this.id = options.id ?? 'inlet';\n this.multiplicity = multiplicity;\n Object.freeze(this);\n }\n\n get disposed(): boolean { return this.#disposed; }\n get readiness(): PortReadiness { return this.#disposed ? 'detached' : 'ready'; }\n get connectionCount(): number { return this.#connections.size; }\n\n /** Deliver a message directly, as an untimed or programmatic event. */\n receive(value: Message): void {\n if (this.#disposed) return;\n this.#handler(value);\n }\n\n /** Connect one output. Releasing the lease stops delivery from that output. */\n connect(source: MessageOutputPort): ConnectionLease {\n if (this.#disposed) throw new Error('MessageInputPort is disposed');\n if (!(source instanceof MessageOutputPort) || source.disposed) throw new TypeError('A message input connects to a live message output.');\n if (this.#connections.has(source)) throw new Error('That message output is already connected to this input.');\n if (this.multiplicity === 'single' && this.#connections.size) throw new Error('This message input accepts one connection.');\n const unsubscribe = source.subscribe(value => this.receive(value));\n const lease = createConnectionLease(() => {\n unsubscribe();\n this.#connections.delete(source);\n });\n this.#connections.set(source, lease);\n return lease;\n }\n\n dispose(): void {\n if (this.#disposed) return;\n this.#disposed = true;\n for (const lease of [...this.#connections.values()]) lease.release();\n this.#connections.clear();\n }\n}\n\n// ----------------------------------------------------------------------------\n// Clocks: timed events are delivered ahead of their time and carry it.\n// ----------------------------------------------------------------------------\n\n/** Schedules timed message events on an AudioContext-seconds axis. */\nexport interface MessageClock {\n /** Current time on the clock's axis. */\n now(): number;\n /** Call `callback(time)` once, no later than `time` and at most the clock's lookahead early. Returns a cancel function. */\n schedule(time: number, callback: (time: number) => void): () => void;\n}\n\ninterface ScheduledEvent { time: number; order: number; callback: (time: number) => void; cancelled: boolean }\n\n/** How deep the message being delivered now is: 0 outside delivery, 1 for a first send. */\nexport function currentMessageDepth(): number { return depth; }\n\n/** Shared queue logic for clocks: events run in time order, then scheduling order. */\nabstract class QueueClock implements MessageClock {\n readonly #events: ScheduledEvent[] = [];\n #order = 0;\n #running = false;\n protected readonly onError?: (error: unknown) => void;\n\n constructor(onError?: (error: unknown) => void) { this.onError = onError; }\n\n abstract now(): number;\n\n schedule(time: number, callback: (time: number) => void): () => void {\n if (!Number.isFinite(time)) throw new RangeError('A clock event requires a finite time.');\n if (typeof callback !== 'function') throw new TypeError('A clock event requires a callback.');\n const event: ScheduledEvent = {time, order: this.#order++, callback, cancelled: false};\n let index = this.#events.length;\n while (index > 0 && (this.#events[index - 1]!.time > time)) index--;\n // New events keep time order while held; resume shifts them with the rest.\n this.#events.splice(index, 0, event);\n this.wake();\n return () => { event.cancelled = true; };\n }\n\n #heldAt: number | undefined;\n\n /** True while the clock holds its events (a debugger's break). */\n get held(): boolean { return this.#heldAt !== undefined; }\n\n /**\n * Stop delivering scheduled events; they stay queued. The event running now\n * finishes its depth-first delivery first. Untimed messages still flow.\n */\n hold(): void { if (this.#heldAt === undefined) this.#heldAt = this.now(); }\n\n /**\n * Deliver again. Held events move later by the time spent holding, so a\n * metro resumes its rhythm instead of catching up in a burst.\n */\n resume(): void {\n const heldAt = this.#heldAt;\n if (heldAt === undefined) return;\n this.#heldAt = undefined;\n const shift = Math.max(0, this.now() - heldAt);\n for (const event of this.#events) event.time += shift;\n this.wake();\n }\n\n /** While held, deliver the next queued event now; false when none is queued. */\n step(): boolean {\n if (this.#heldAt === undefined || this.#running) return false;\n let event: ScheduledEvent | undefined;\n while ((event = this.#events.shift()) && event.cancelled);\n if (!event) return false;\n this.#running = true;\n try { event.callback(this.now()); } catch (error) { try { this.onError?.(error); } catch { /* Keep the clock running. */ } }\n finally { this.#running = false; }\n // Time passes while stepping; events made since keep their places relative to now.\n this.#heldAt = this.now();\n return true;\n }\n\n /** Run every event due by `horizon`, including events they schedule within it. */\n protected flush(horizon: number): void {\n if (this.#running || this.#heldAt !== undefined) return;\n this.#running = true;\n try {\n // A break during delivery holds the rest of the queue.\n while (this.#heldAt === undefined && this.#events.length && this.#events[0]!.time <= horizon) {\n const event = this.#events.shift()!;\n if (event.cancelled) continue;\n try { event.callback(event.time); } catch (error) { try { this.onError?.(error); } catch { /* Keep the clock running. */ } }\n }\n } finally { this.#running = false; }\n }\n\n protected get pending(): number { return this.#events.filter(event => !event.cancelled).length; }\n protected wake(): void {}\n}\n\n/** A clock advanced by hand, for tests and offline rendering. */\nexport class ManualMessageClock extends QueueClock {\n #now: number;\n constructor(start = 0, onError?: (error: unknown) => void) { super(onError); this.#now = start; }\n now(): number { return this.#now; }\n /** Move to `time`, running every event due by then in order. */\n advance(time: number): void {\n if (!Number.isFinite(time) || time < this.#now) throw new RangeError('A manual clock only moves forward.');\n this.#now = time;\n this.flush(time);\n }\n get pendingEvents(): number { return this.pending; }\n}\n\nexport interface AudioMessageClockOptions {\n /** How early events are delivered, in seconds. Defaults to 0.05. */\n readonly lookahead?: number;\n /** Polling period in milliseconds. Defaults to 15. */\n readonly interval?: number;\n readonly onError?: (error: unknown) => void;\n}\n\n/** A clock on an AudioContext's `currentTime`, polled on the main thread while events are pending. */\nexport class AudioMessageClock extends QueueClock {\n readonly context: BaseAudioContext;\n readonly lookahead: number;\n readonly #interval: number;\n #timer?: ReturnType<typeof setInterval>;\n #disposed = false;\n\n constructor(context: BaseAudioContext, options: AudioMessageClockOptions = {}) {\n super(options.onError);\n this.context = context;\n this.lookahead = options.lookahead ?? 0.05;\n this.#interval = options.interval ?? 15;\n if (!(this.lookahead >= 0) || !(this.#interval > 0)) throw new RangeError('Clock lookahead and interval must be positive.');\n }\n\n now(): number { return this.context.currentTime; }\n\n protected override wake(): void {\n if (this.#disposed || this.#timer !== undefined) return;\n this.#timer = setInterval(() => this.#tick(), this.#interval);\n queueMicrotask(() => this.#tick());\n }\n\n #tick(): void {\n if (this.#disposed) return;\n this.flush(this.now() + this.lookahead);\n if (!this.pending && this.#timer !== undefined) { clearInterval(this.#timer); this.#timer = undefined; }\n }\n\n dispose(): void {\n this.#disposed = true;\n if (this.#timer !== undefined) clearInterval(this.#timer);\n this.#timer = undefined;\n }\n}\n\nconst sharedClocks = new WeakMap<BaseAudioContext, AudioMessageClock>();\n\n/** The one shared message clock of an AudioContext. */\nexport function messageClockFor(context: BaseAudioContext): AudioMessageClock {\n let clock = sharedClocks.get(context);\n if (!clock) { clock = new AudioMessageClock(context); sharedClocks.set(context, clock); }\n return clock;\n}\n\n/**\n * Set a parameter's base value from each message's first number, clamped to\n * its legal range, at the message's time: an untimed message applies at once,\n * a timed one on a main-thread timer when it falls due. Releasing the lease\n * stops delivery and drops pending timed values.\n */\nexport function connectMessageToParameter(source: MessageOutputPort, handle: ParamHandle, context: BaseAudioContext): ConnectionLease {\n const timers = new Set<ReturnType<typeof setTimeout>>();\n const {min, max} = handle.descriptor.range;\n const apply = (value: number) => {\n if (handle.snapshot.disposed) return;\n handle.setBaseValue(Math.min(max, Math.max(min, value)));\n };\n const unsubscribe = source.subscribe(value => {\n const number = numberOf(value);\n if (number === undefined) return;\n const wait = value.time === undefined ? 0 : value.time - context.currentTime;\n if (wait <= 0.002) { apply(number); return; }\n const timer = setTimeout(() => { timers.delete(timer); apply(number); }, wait * 1000);\n timers.add(timer);\n });\n return createConnectionLease(() => {\n unsubscribe();\n for (const timer of timers) clearTimeout(timer);\n timers.clear();\n });\n}\n","import {createCapabilityKey, type CapabilityKey} from './capability';\nimport type {ModuleSession} from '../session';\nimport {barsBeatsTicksAt, type BarsBeatsTicks, type MusicalTempo} from '../transport';\n\n/**\n * The Session's musical time, lent to every module of a project (DEC-077):\n * its tempo and meter, the position in bars, beats and ticks, and the audio\n * time of a Session position, for timers that follow the transport.\n */\nexport interface MusicalTimeSource {\n /** Current tempo and meter. */\n tempo(): MusicalTempo;\n /** Whether the Session is playing. */\n playing(): boolean;\n /** Session position in seconds now. */\n position(): number;\n /** Bars, beats and ticks now. */\n barsBeatsTicks(): BarsBeatsTicks;\n /** AudioContext time at a Session position, while playing; undefined while paused. */\n timeAt(position: number): number | undefined;\n /** Notified after a tempo change and after play, pause, seek or a loop jump. */\n subscribe(listener: () => void): () => void;\n}\n\nexport const MUSICAL_TIME: CapabilityKey<MusicalTimeSource> = createCapabilityKey<MusicalTimeSource>('webmusic.musical-time');\n\n/** A musical-time source over a Session; `notify()` reports a tempo change. */\nexport function createMusicalTimeSource(session: ModuleSession, tempo: () => MusicalTempo): MusicalTimeSource & {notify(): void} {\n const listeners = new Set<() => void>();\n const notify = () => { for (const listener of [...listeners]) { try { listener(); } catch { /* Observers cannot stop a tempo change. */ } } };\n let release: (() => void) | undefined;\n const source = {\n tempo,\n playing: () => !session.snapshot.paused,\n position: () => session.position,\n barsBeatsTicks: () => barsBeatsTicksAt(session.position, tempo()),\n timeAt: (position: number) => {\n if (session.snapshot.paused) return undefined;\n const time = session.clock.timeAt(position);\n return Number.isFinite(time) ? time : undefined;\n },\n subscribe(listener: () => void) {\n listeners.add(listener);\n release ??= session.subscribe(notify);\n return () => {\n listeners.delete(listener);\n if (!listeners.size) { release?.(); release = undefined; }\n };\n },\n notify,\n };\n return source;\n}\n","// GraphModule: the Headless base of the modules a graph places (DEC-097). A\n// subclass names its ports, holds its own state and is used from code through\n// its members; a graph reaches the same instance through `ports()`, and a\n// project saves it as its type and `exportOptions()`.\n//\n// Ownership: a module owns its ports, the clock events it scheduled and\n// whatever its subclass creates, and releases them in `dispose()`, which is\n// repeatable. The context, its audio clock and its Session are borrowed and\n// never closed.\n\nimport type {ModuleCapabilities} from './capability';\nimport type {ModuleContext} from './context';\nimport {\n MessageInputPort, MessageOutputPort, messageClockFor,\n type Message, type MessageClock,\n} from './message';\nimport {MUSICAL_TIME, type MusicalTimeSource} from './musical-time';\nimport type {ControlSignal} from './param-audio';\nimport type {ProjectJsonObject, ProjectPortDescriptor, ProjectSignalKind} from './project-types';\nimport {assertModuleId, type ModuleHandle, type ModulePort} from './registry';\n\nexport interface GraphModuleOptions {\n /** The module's ID. Defaults to the short name of its type, such as `metro`. */\n readonly id?: string;\n /** Borrowed. Lends the audio clock, the Session's musical time and the registry of the modules beside this one. */\n readonly context?: ModuleContext;\n /** Borrowed clock for timed output. Defaults to the shared clock of the context's AudioContext. */\n readonly clock?: MessageClock;\n /** Borrowed musical time. Defaults to the one the context lends, when it has a Session. */\n readonly musicalTime?: MusicalTimeSource;\n /** Receives a failure inside a handler. Without it the failure is rethrown in a microtask. */\n readonly onError?: (error: unknown) => void;\n}\n\n/** A value saved for a module: its options and the state it exports, by name. */\nexport type ModuleOptionsJson = ProjectJsonObject;\n\nexport abstract class GraphModule implements ModuleHandle {\n readonly id: string;\n /** The module type this instance is saved as, such as `webmusic.metro`. */\n readonly type: string;\n readonly #options: GraphModuleOptions;\n readonly #ports: ModulePort[] = [];\n readonly #descriptors: ProjectPortDescriptor[] = [];\n readonly #scheduled = new Set<() => void>();\n readonly #watchers = new Set<() => void>();\n #clock?: MessageClock;\n #active = false;\n #disposed = false;\n\n protected constructor(type: string, options: GraphModuleOptions = {}) {\n const id = options.id ?? type.slice(type.lastIndexOf('.') + 1);\n assertModuleId(id);\n this.id = id;\n this.type = type;\n this.#options = options;\n }\n\n /** True once `activate()` ran: timers run and load-time output has been sent. */\n get active(): boolean { return this.#active; }\n get disposed(): boolean { return this.#disposed; }\n /** Capabilities this module lends, when it has any. */\n get capabilities(): ModuleCapabilities | undefined { return undefined; }\n /** A control output for modulation, when the module has one. */\n get control(): ControlSignal | undefined { return undefined; }\n\n /** Every port, inputs first, in the order the module declares them. */\n ports(): readonly ModulePort[] { return this.#ports; }\n /** Each port's ID, label, kind and direction, in the same order. */\n describePorts(): readonly ProjectPortDescriptor[] { return this.#descriptors; }\n\n /**\n * Start the module: timers begin and load-time output is sent. Call it once\n * the ports are connected; a project runtime calls it when its graph\n * commits. Repeated calls do nothing.\n */\n activate(): void {\n if (this.#disposed || this.#active) return;\n this.#active = true;\n this.guard(() => this.onActivate());\n }\n\n /** Be told after each change of the module's displayed state. Returns the cleanup. */\n watch(listener: () => void): () => void {\n this.#watchers.add(listener);\n return () => { this.#watchers.delete(listener); };\n }\n\n /**\n * The options a project saves: those the module was made with and the state\n * it keeps, so that `new Type(module.exportOptions())` restores it. A value\n * an input merely stored for the next output is not saved.\n */\n abstract exportOptions(): ModuleOptionsJson;\n\n dispose(): void {\n if (this.#disposed) return;\n this.#disposed = true;\n for (const cancel of [...this.#scheduled]) cancel();\n this.#scheduled.clear();\n this.guard(() => this.onDispose());\n for (const port of this.#ports) (port as {dispose?(): void}).dispose?.();\n this.#watchers.clear();\n }\n\n // --- for subclasses --------------------------------------------------------\n\n /** Runs once, in `activate()`. */\n protected onActivate(): void {}\n /** Runs once, in `dispose()`, before the ports are released. */\n protected onDispose(): void {}\n\n /** The context this module borrows, when it was given one. */\n protected get context(): ModuleContext | undefined { return this.#options.context; }\n /** The Session's musical time, when the module was lent one. */\n protected get musicalTime(): MusicalTimeSource | undefined {\n return this.#options.musicalTime ?? this.#options.context?.capabilities.get(MUSICAL_TIME);\n }\n\n /** The context's AudioContext, created on first use. */\n protected audio(): BaseAudioContext {\n const context = this.#options.context;\n if (!context) throw new Error(`${this.type} needs a module context for its audio.`);\n return context.audio.prepare();\n }\n\n /** The module's clock. Everything scheduled through it is cancelled on dispose. */\n protected get clock(): MessageClock {\n if (this.#clock) return this.#clock;\n const shared = (): MessageClock => {\n if (this.#options.clock) return this.#options.clock;\n if (!this.#options.context) throw new Error(`${this.type} needs a clock or a module context.`);\n return messageClockFor(this.#options.context.audio.prepare());\n };\n let resolved: MessageClock | undefined;\n const clock = () => resolved ??= shared();\n return this.#clock = {\n now: () => clock().now(),\n schedule: (time, callback) => {\n if (this.#disposed) return () => {};\n const entry = {cancel: () => {}};\n const stop = () => { entry.cancel(); this.#scheduled.delete(stop); };\n entry.cancel = clock().schedule(time, at => { this.#scheduled.delete(stop); if (!this.#disposed) this.guard(() => callback(at)); });\n this.#scheduled.add(stop);\n return stop;\n },\n };\n }\n\n /** The time of a message, or now for an untimed one. */\n protected timeOf(value: Message): number { return value.time ?? this.clock.now(); }\n\n /** Declare a message input. Its handler runs guarded and never after dispose. */\n protected input(id: string, label: string, handler: (value: Message) => void): MessageInputPort {\n const port = new MessageInputPort(value => { if (!this.#disposed) this.guard(() => handler(value)); }, {id});\n this.addPort(port, {id, label, kind: 'message', direction: 'input'});\n return port;\n }\n\n /** Declare a message output. */\n protected output(id: string, label: string): MessageOutputPort {\n const port = new MessageOutputPort({id, onListenerError: error => this.fail(error)});\n this.addPort(port, {id, label, kind: 'message', direction: 'output'});\n return port;\n }\n\n /** Declare a port of another family that the subclass made, or one with no port object. */\n protected addPort(port: ModulePort | undefined, descriptor: {id: string; label: string; kind: ProjectSignalKind; direction: 'input' | 'output'}): void {\n if (port) this.#ports.push(port);\n this.#descriptors.push(Object.freeze({...descriptor}));\n }\n\n /** Report a failure without stopping the graph. */\n protected fail(error: unknown): void {\n const report = this.#options.onError;\n if (report) { try { report(error); } catch { /* Reporting never stops a module. */ } }\n else queueMicrotask(() => { throw error; });\n }\n\n protected guard(work: () => void): void {\n try { work(); } catch (error) { this.fail(error); }\n }\n\n /** Tell watchers that the displayed state changed. */\n protected changed(): void {\n for (const listener of [...this.#watchers]) this.guard(listener);\n }\n}\n\n/** Ports `in0`, `in1`… or `out0`, `out1`… for a module whose port count follows its options. */\nexport const numberedPort = (direction: 'in' | 'out', index: number): string => `${direction}${index}`;\n","// Restore registrations (DEC-097): how a saved module record becomes a\n// Headless instance. A registration owns nothing the module does not: it\n// reads the record's options by name, constructs the class and hands the\n// runtime the instance's own ports, export and disposal.\n\nimport type {ConnectionLease} from './lease';\nimport type {ModuleContext} from './context';\nimport type {MessageClock} from './message';\nimport {messageClockFor} from './message';\nimport {ProjectModuleUnavailableError} from './project-types';\nimport type {ProjectFactoryRequest, ProjectJsonObject, ProjectModuleInstance, ProjectPluginFactory} from './project-types';\nimport type {ModuleHandle} from './registry';\nimport type {GraphModule, GraphModuleOptions} from './graph-module';\n\n/** Version of the module types the packages register. */\nexport const MODULE_PLUGIN_VERSION = '1.0.0';\n\n/** Shared services for the modules of one plugin set. */\nexport interface ModuleEnvironment {\n /** The clock for timed output. Defaults to the shared clock of the module context's AudioContext. */\n readonly clock?: (context: BaseAudioContext) => MessageClock;\n /** Where the `print` function and scripts write. Defaults to `console.log`. */\n readonly print?: (name: string, text: string, moduleId: string) => void;\n /** A source of uniform numbers in [0, 1) for modules without a seed. Defaults to `Math.random`. */\n readonly random?: () => number;\n /** Receives failures inside module behavior and message delivery. */\n readonly onError?: (error: unknown, moduleId: string) => void;\n /** Creates the Worker a script module runs in, from its source text. Defaults to a Worker from a Blob URL (DEC-078). */\n readonly createScriptWorker?: (source: string) => import('../message/script').ScriptWorkerLike;\n}\n\n/** What a module may add to its project instance beyond ports and options. */\nexport interface ModuleProjectHooks {\n getInput?(port: string): AudioNode | undefined;\n childContext?(context: ModuleContext): ModuleContext;\n sourceOutput?(port: string): ModuleHandle | undefined;\n connectSource?(port: string, module: ModuleHandle): ConnectionLease | undefined;\n}\n\n/** The base options a registration gives the class it constructs. */\nexport function moduleBaseOptions(request: ProjectFactoryRequest, environment: ModuleEnvironment = {}): GraphModuleOptions {\n const {record, context} = request;\n let shared: MessageClock | undefined;\n // The audio context is made on first use, so a graph that is only opened makes none.\n const clock = () => shared ??= (environment.clock ?? messageClockFor)(context.audio.prepare());\n return {\n id: record.id,\n context,\n clock: {now: () => clock().now(), schedule: (time, callback) => clock().schedule(time, callback)},\n ...(environment.onError ? {onError: (error: unknown) => environment.onError!(error, record.id)} : {}),\n };\n}\n\n/**\n * Refuse a record saved in the earlier form (DEC-097): object argument text\n * is Studio's, and a module's options are saved by name.\n */\nexport function assertStructuredOptions(config: ProjectJsonObject): void {\n if ('args' in config) {\n throw new ProjectModuleUnavailableError('This module was saved with object argument text (\"args\"). The packages read a module\\'s options by name; open the file in the editor that wrote it to migrate it.');\n }\n}\n\n/** A module's own options from a saved config and the registration's base options. */\nexport type RestoredOptions<Options> = Options & GraphModuleOptions;\n\n/**\n * The project plugin of one module type. `create` constructs the class from\n * the record's options; a `TypeError`, `RangeError` or `SyntaxError` it throws\n * leaves the module unresolved with that reason, keeping its record and cords.\n */\nexport function modulePlugin<Options extends object>(\n type: string,\n create: (options: RestoredOptions<Options>, request: ProjectFactoryRequest) => GraphModule & ModuleProjectHooks,\n environment: ModuleEnvironment = {},\n): ProjectPluginFactory {\n return Object.freeze({\n id: type,\n version: MODULE_PLUGIN_VERSION,\n create(request: ProjectFactoryRequest): ProjectModuleInstance {\n const {record} = request;\n let module: GraphModule & ModuleProjectHooks;\n try {\n assertStructuredOptions(record.config);\n module = create({...record.config, ...moduleBaseOptions(request, environment)} as RestoredOptions<Options>, request);\n } catch (error) {\n if (error instanceof ProjectModuleUnavailableError) throw error;\n if (error instanceof TypeError || error instanceof RangeError || error instanceof SyntaxError) {\n throw new ProjectModuleUnavailableError(error.message, {cause: error});\n }\n throw error;\n }\n const control = module.control;\n return {\n module,\n ports: module.describePorts(),\n ...(control ? {getControl: (name: string) => name === 'output' ? control : undefined} : {}),\n ...(module.getInput ? {getInput: (port: string) => module.getInput!(port)} : {}),\n ...(module.childContext ? {childContext: (context: ModuleContext) => module.childContext!(context)} : {}),\n ...(module.sourceOutput ? {sourceOutput: (port: string) => module.sourceOutput!(port)} : {}),\n ...(module.connectSource ? {connectSource: (port: string, upstream: ModuleHandle) => module.connectSource!(port, upstream)} : {}),\n // Keys a host keeps beside the options, such as a control's own style, survive an export.\n exportConfig: () => ({...record.config, ...module.exportOptions()}),\n activate: () => module.activate(),\n dispose: () => module.dispose(),\n };\n },\n });\n}\n"]}
|