@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":["../src/message/expr.ts","../src/message/functions.ts","../src/message/timers.ts","../src/message/values.ts","../src/message/sources.ts","../src/message/script.ts","../src/message/script-module.ts","../src/message/plugins.ts"],"sourcesContent":["// A small expression language for the `expr` object: numbers, `$i1`…`$i9`\n// and `$f1`…`$f9` inlets, C-like operators and math functions. Parsed once\n// into a tree and evaluated per message; it never calls `eval`. Ints and\n// floats keep Max's typing: an operation on two ints is an int (division\n// truncates), anything touching a float is a float.\n\nexport interface ExprValue { readonly value: number; readonly float: boolean }\n\ntype Node =\n | {kind: 'number'; value: number; float: boolean}\n | {kind: 'inlet'; index: number; float: boolean}\n | {kind: 'unary'; operator: string; operand: Node}\n | {kind: 'binary'; operator: string; left: Node; right: Node}\n | {kind: 'conditional'; test: Node; then: Node; otherwise: Node}\n | {kind: 'call'; name: string; args: Node[]};\n\nexport interface CompiledExpr {\n /** Number of inlets the expression reads (at least 1). */\n readonly inlets: number;\n /** Evaluate with inlet values; missing inlets read 0. */\n evaluate(inputs: readonly number[], random?: () => number): ExprValue;\n}\n\nconst FUNCTIONS: Record<string, {arity: [number, number]; apply: (args: ExprValue[], random: () => number) => ExprValue}> = {\n abs: {arity: [1, 1], apply: ([a]) => ({value: Math.abs(a!.value), float: a!.float})},\n min: {arity: [2, 2], apply: ([a, b]) => ({value: Math.min(a!.value, b!.value), float: a!.float || b!.float})},\n max: {arity: [2, 2], apply: ([a, b]) => ({value: Math.max(a!.value, b!.value), float: a!.float || b!.float})},\n pow: {arity: [2, 2], apply: ([a, b]) => ({value: a!.value ** b!.value, float: true})},\n sqrt: {arity: [1, 1], apply: ([a]) => ({value: Math.sqrt(a!.value), float: true})},\n exp: {arity: [1, 1], apply: ([a]) => ({value: Math.exp(a!.value), float: true})},\n log: {arity: [1, 1], apply: ([a]) => ({value: Math.log(a!.value), float: true})},\n log10: {arity: [1, 1], apply: ([a]) => ({value: Math.log10(a!.value), float: true})},\n sin: {arity: [1, 1], apply: ([a]) => ({value: Math.sin(a!.value), float: true})},\n cos: {arity: [1, 1], apply: ([a]) => ({value: Math.cos(a!.value), float: true})},\n tan: {arity: [1, 1], apply: ([a]) => ({value: Math.tan(a!.value), float: true})},\n atan2: {arity: [2, 2], apply: ([a, b]) => ({value: Math.atan2(a!.value, b!.value), float: true})},\n floor: {arity: [1, 1], apply: ([a]) => ({value: Math.floor(a!.value), float: true})},\n ceil: {arity: [1, 1], apply: ([a]) => ({value: Math.ceil(a!.value), float: true})},\n round: {arity: [1, 1], apply: ([a]) => ({value: Math.round(a!.value), float: true})},\n int: {arity: [1, 1], apply: ([a]) => ({value: Math.trunc(a!.value), float: false})},\n float: {arity: [1, 1], apply: ([a]) => ({value: a!.value, float: true})},\n random: {arity: [2, 2], apply: ([a, b], random) => ({value: Math.floor(a!.value + random() * (b!.value - a!.value)), float: false})},\n};\n\nconst BINARY: Record<string, number> = {\n '||': 1, '&&': 2, '|': 3, '^': 4, '&': 5, '==': 6, '!=': 6,\n '<': 7, '<=': 7, '>': 7, '>=': 7, '<<': 8, '>>': 8, '+': 9, '-': 9, '*': 10, '/': 10, '%': 10, '**': 11,\n};\n\nfunction tokenize(source: string): string[] {\n const tokens: string[] = [];\n const pattern = /\\s*(\\$[if][1-9]|\\d+\\.\\d*(?:[eE][-+]?\\d+)?|\\.\\d+(?:[eE][-+]?\\d+)?|\\d+(?:[eE][-+]?\\d+)?|[A-Za-z_][A-Za-z0-9_]*|\\*\\*|<<|>>|<=|>=|==|!=|&&|\\|\\||[-+*/%()<>!~&|^,?:])/y;\n let index = 0;\n while (index < source.length) {\n if (/^\\s*$/.test(source.slice(index))) break;\n pattern.lastIndex = index;\n const match = pattern.exec(source);\n if (!match) throw new SyntaxError(`expr: cannot read \"${source.slice(index).trim()}\".`);\n tokens.push(match[1]!);\n index = pattern.lastIndex;\n }\n return tokens;\n}\n\n/** Parse an expression. Throws a SyntaxError naming the problem. */\nexport function compileExpr(source: string): CompiledExpr {\n const tokens = tokenize(source);\n if (!tokens.length) throw new SyntaxError('expr: the expression is empty.');\n let position = 0;\n let inlets = 1;\n const peek = () => tokens[position];\n const take = (expected?: string) => {\n const token = tokens[position];\n if (token === undefined || (expected !== undefined && token !== expected)) {\n throw new SyntaxError(`expr: expected ${expected ?? 'a value'}${token === undefined ? ' at the end' : ` but found \"${token}\"`}.`);\n }\n position++;\n return token;\n };\n\n const primary = (): Node => {\n const token = take();\n if (token === '(') { const inner = conditional(); take(')'); return inner; }\n if (token === '-' || token === '!' || token === '~' || token === '+') return {kind: 'unary', operator: token, operand: unary()};\n if (/^\\$[if][1-9]$/.test(token)) {\n const index = Number(token[2]) - 1;\n inlets = Math.max(inlets, index + 1);\n return {kind: 'inlet', index, float: token[1] === 'f'};\n }\n if (/^[\\d.]/.test(token)) return {kind: 'number', value: Number(token), float: /[.eE]/.test(token)};\n if (/^[A-Za-z_]/.test(token)) {\n if (token === 'pi') return {kind: 'number', value: Math.PI, float: true};\n const definition = FUNCTIONS[token];\n if (!definition) throw new SyntaxError(`expr: no function named ${token}.`);\n take('(');\n const args: Node[] = [];\n if (peek() !== ')') { args.push(conditional()); while (peek() === ',') { take(','); args.push(conditional()); } }\n take(')');\n if (args.length < definition.arity[0] || args.length > definition.arity[1]) throw new SyntaxError(`expr: ${token} takes ${definition.arity[0]} argument${definition.arity[0] === 1 ? '' : 's'}.`);\n return {kind: 'call', name: token, args};\n }\n throw new SyntaxError(`expr: unexpected \"${token}\".`);\n };\n const unary = (): Node => primary();\n const binary = (minimum: number): Node => {\n let left = unary();\n for (;;) {\n const operator = peek();\n const precedence = operator === undefined ? undefined : BINARY[operator];\n if (precedence === undefined || precedence < minimum) return left;\n take();\n // `**` is right-associative; everything else is left-associative.\n const right = binary(operator === '**' ? precedence : precedence + 1);\n left = {kind: 'binary', operator: operator!, left, right};\n }\n };\n const conditional = (): Node => {\n const test = binary(1);\n if (peek() !== '?') return test;\n take('?');\n const then = conditional();\n take(':');\n return {kind: 'conditional', test, then, otherwise: conditional()};\n };\n\n const tree = conditional();\n if (position < tokens.length) throw new SyntaxError(`expr: unexpected \"${tokens[position]}\".`);\n\n const evaluate = (node: Node, inputs: readonly number[], random: () => number): ExprValue => {\n switch (node.kind) {\n case 'number': return {value: node.value, float: node.float};\n case 'inlet': {\n const raw = inputs[node.index] ?? 0;\n return node.float ? {value: raw, float: true} : {value: Math.trunc(raw), float: false};\n }\n case 'unary': {\n const operand = evaluate(node.operand, inputs, random);\n if (node.operator === '-') return {value: -operand.value, float: operand.float};\n if (node.operator === '+') return operand;\n if (node.operator === '!') return {value: operand.value ? 0 : 1, float: false};\n return {value: ~Math.trunc(operand.value), float: false};\n }\n case 'conditional': return evaluate(node.test, inputs, random).value ? evaluate(node.then, inputs, random) : evaluate(node.otherwise, inputs, random);\n case 'call': return FUNCTIONS[node.name]!.apply(node.args.map(arg => evaluate(arg, inputs, random)), random);\n case 'binary': {\n const a = evaluate(node.left, inputs, random), b = evaluate(node.right, inputs, random);\n const float = a.float || b.float;\n const int = (value: number) => ({value: Math.trunc(value), float: false});\n switch (node.operator) {\n case '+': return {value: a.value + b.value, float};\n case '-': return {value: a.value - b.value, float};\n case '*': return {value: a.value * b.value, float};\n case '/': return float ? {value: a.value / b.value, float} : (b.value === 0 ? {value: 0, float} : int(a.value / b.value));\n case '%': return float ? {value: a.value % b.value, float} : (b.value === 0 ? {value: 0, float} : int(a.value % b.value));\n case '**': return {value: a.value ** b.value, float: float || b.value < 0};\n case '<': return {value: Number(a.value < b.value), float: false};\n case '<=': return {value: Number(a.value <= b.value), float: false};\n case '>': return {value: Number(a.value > b.value), float: false};\n case '>=': return {value: Number(a.value >= b.value), float: false};\n case '==': return {value: Number(a.value === b.value), float: false};\n case '!=': return {value: Number(a.value !== b.value), float: false};\n case '&&': return {value: Number(Boolean(a.value) && Boolean(b.value)), float: false};\n case '||': return {value: Number(Boolean(a.value) || Boolean(b.value)), float: false};\n case '&': return int(Math.trunc(a.value) & Math.trunc(b.value));\n case '|': return int(Math.trunc(a.value) | Math.trunc(b.value));\n case '^': return int(Math.trunc(a.value) ^ Math.trunc(b.value));\n case '<<': return int(Math.trunc(a.value) << Math.trunc(b.value));\n default: return int(Math.trunc(a.value) >> Math.trunc(b.value));\n }\n }\n }\n };\n\n return Object.freeze({\n inlets,\n evaluate: (inputs: readonly number[], random: () => number = Math.random) => {\n const result = evaluate(tree, inputs, random);\n return Number.isFinite(result.value) ? result : {value: 0, float: result.float};\n },\n });\n}\n","// Message functions (DEC-097): pure computations on values, each also usable\n// as a module through `functionModule`. A function is called with plain\n// values; its `module` binding says which ports it has in a graph and how\n// messages reach it. Hot inputs produce output; the others store an operand,\n// and every output carries the time of the message that caused it.\n\nimport {\n atomsOf, bang, floatAtom, formatMessage, intAtom, isNumberAtom, message, messageFromAtoms, numberOf, symbolAtom,\n type Atom, type Message, type MessageInputPort, type MessageOutputPort,\n} from '../module/message';\nimport type {ProjectJsonObject} from '../module/project-types';\nimport {compileExpr} from './expr';\nimport {GraphModule, numberedPort, type GraphModuleOptions, type ModuleOptionsJson} from '../module/graph-module';\n\n// --- values --------------------------------------------------------------------\n\n/** A number or a word, as options and function arguments carry them. */\nexport type MessageValue = number | string;\n\n/** The atom of a value: an integer is an int, another number a float, a string a symbol. */\nexport function atomOf(value: MessageValue, float = false): Atom {\n if (typeof value === 'string') return symbolAtom(value);\n return float || !Number.isInteger(value) ? floatAtom(value) : intAtom(value);\n}\n\nconst isValue = (value: unknown): value is MessageValue => typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value));\nconst sameAtom = (a: Atom | undefined, b: Atom | undefined) =>\n !!a && !!b && (isNumberAtom(a) && isNumberAtom(b) ? a.value === b.value : a.type === b.type && JSON.stringify(a.value) === JSON.stringify(b.value));\nconst textOf = (atom: Atom) => formatMessage(messageFromAtoms([atom]));\n/** A number message of the right type. */\nexport const numberMessage = (value: number, float: boolean, time?: number): Message =>\n float ? message('float', [floatAtom(value)], time) : message('int', [intAtom(Math.round(value))], time);\n\nconst record = (input: unknown): Record<string, unknown> => input && typeof input === 'object' && !Array.isArray(input) ? input as Record<string, unknown> : {};\nconst finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);\nfunction values(name: string, key: string, input: unknown, what: string): readonly MessageValue[] {\n if (!Array.isArray(input) || !input.length || !input.every(isValue)) throw new TypeError(`${name} needs ${what} in \"${key}\".`);\n return Object.freeze([...input]);\n}\n\n// --- the binding and its adapter ---------------------------------------------\n\nexport interface FunctionPortSpec { readonly id: string; readonly label: string }\n\n/** What a function's module instance may use. */\nexport interface FunctionHost {\n /** Send from output `index`. */\n send(index: number, message: Message): void;\n /** Uniform numbers in [0, 1). */\n readonly random: () => number;\n /** Write one line for the function named `name`. */\n print(name: string, text: string): void;\n}\n\n/** One function at work in a graph: it holds the operands its inputs store. */\nexport interface FunctionInstance {\n receive(index: number, message: Message): void;\n}\n\n/** How a function is placed in a graph: its module type, options and ports. */\nexport interface FunctionBinding<Options> {\n /** The module type it is saved as, such as `webmusic.scale`. */\n readonly type: string;\n /** Complete options from partial or saved ones. Throws a TypeError, RangeError or SyntaxError that names the problem. */\n options(input: unknown): Options;\n inputs(options: Options): readonly FunctionPortSpec[];\n outputs(options: Options): readonly FunctionPortSpec[];\n bind(options: Options, host: FunctionHost): FunctionInstance;\n}\n\n/** A function a graph can place. */\nexport interface MessageFunction<Options> { readonly module: FunctionBinding<Options> }\n\nexport interface FunctionModuleOptions<Options> extends GraphModuleOptions {\n /** The function's options; absent ones take their defaults. */\n readonly options?: Partial<Options>;\n /** Uniform numbers in [0, 1) for functions that draw one. Defaults to `Math.random`. */\n readonly random?: () => number;\n /** Where a printing function writes. Defaults to `console.log`. */\n readonly print?: (name: string, text: string) => void;\n}\n\n/** The one Headless adapter that gives a message function ports. */\nexport class FunctionModule<Options extends object = object> extends GraphModule {\n /** The message inputs, by port ID. */\n readonly inputs: Readonly<Record<string, MessageInputPort>>;\n /** The message outputs, by port ID. */\n readonly outputs: Readonly<Record<string, MessageOutputPort>>;\n readonly #options: Options;\n\n constructor(fn: MessageFunction<Options>, init: FunctionModuleOptions<Options> = {}) {\n super(fn.module.type, init);\n const options = this.#options = fn.module.options(init.options ?? {});\n const holder: {instance?: FunctionInstance} = {};\n this.inputs = Object.freeze(Object.fromEntries(fn.module.inputs(options).map((spec, index) =>\n [spec.id, this.input(spec.id, spec.label, value => holder.instance?.receive(index, value))])));\n const outputs = fn.module.outputs(options).map(spec => this.output(spec.id, spec.label));\n this.outputs = Object.freeze(Object.fromEntries(outputs.map(port => [port.id, port])));\n holder.instance = fn.module.bind(options, {\n send: (index, value) => { if (!this.disposed) outputs[index]?.send(value); },\n random: init.random ?? Math.random,\n print: init.print ?? ((name, text) => console.log(`${name}: ${text}`)),\n });\n }\n\n /** The options it was made with. Operands stored through an input are not saved. */\n get options(): Options { return this.#options; }\n exportOptions(): ModuleOptionsJson { return this.#options as unknown as ProjectJsonObject; }\n}\n\n/** A module with ports that calls `fn` as messages arrive. */\nexport function functionModule<Options extends object>(fn: MessageFunction<Options>, init: FunctionModuleOptions<Options> = {}): FunctionModule<Options> {\n return new FunctionModule(fn, init);\n}\n\nconst bind = <F extends (...args: never[]) => unknown, Options>(fn: F, module: FunctionBinding<Options>): F & MessageFunction<Options> =>\n Object.freeze(Object.assign(fn, {module: Object.freeze(module)}));\nconst port = (id: string, label: string): FunctionPortSpec => ({id, label});\nconst numbered = (direction: 'in' | 'out', labels: readonly string[]): FunctionPortSpec[] => labels.map((label, index) => port(numberedPort(direction, index), label));\n\n// --- scale -----------------------------------------------------------------------\n\nexport interface ScaleOptions {\n readonly inLow: number;\n readonly inHigh: number;\n readonly outLow: number;\n readonly outHigh: number;\n /** Curve of the mapping; 1 is linear. */\n readonly exponent?: number;\n /** In a graph, send floats even for an int input. */\n readonly float?: boolean;\n}\n\n/** Map `value` from the input range onto the output range. Values outside the input range extend the line. */\nexport const scale = bind(function scale(value: number, range: ScaleOptions): number {\n const span = range.inHigh - range.inLow;\n const fraction = span === 0 ? 0 : (value - range.inLow) / span;\n const exponent = range.exponent ?? 1;\n const shaped = exponent === 1 ? fraction : Math.sign(fraction) * Math.abs(fraction) ** exponent;\n return range.outLow + shaped * (range.outHigh - range.outLow);\n}, {\n type: 'webmusic.scale',\n options(input): ScaleOptions {\n const {inLow, inHigh, outLow, outHigh, exponent, float} = record(input);\n if (!finite(inLow) || !finite(inHigh) || !finite(outLow) || !finite(outHigh)) throw new TypeError('scale needs inLow, inHigh, outLow and outHigh.');\n return {inLow, inHigh, outLow, outHigh, exponent: finite(exponent) ? exponent : 1, float: float === true};\n },\n inputs: () => [port('value', 'value to scale'), port('inLow', 'input low'), port('inHigh', 'input high'), port('outLow', 'output low'), port('outHigh', 'output high')],\n outputs: () => [port('result', 'scaled value')],\n bind(options, host) {\n const range: {-readonly [Key in keyof ScaleOptions]: ScaleOptions[Key]} = {...options};\n const keys = ['inLow', 'inHigh', 'outLow', 'outHigh'] as const;\n return {\n receive(index, value) {\n const number = numberOf(value);\n if (number === undefined) return;\n if (index > 0) { range[keys[index - 1]!] = number; return; }\n host.send(0, numberMessage(scale(number, range), range.float === true || value.selector === 'float', value.time));\n },\n };\n },\n});\n\n// --- select and route --------------------------------------------------------------\n\nexport interface SelectOptions { readonly matches: readonly MessageValue[] }\n\n/** The index of the first of `matches` that equals `value`, or -1. Numbers compare by value, whatever their type. */\nexport const select = bind(function select(value: MessageValue | Atom | undefined, matches: readonly MessageValue[]): number {\n const subject = value === undefined || typeof value === 'object' ? value : atomOf(value);\n return matches.findIndex(match => sameAtom(atomOf(match), subject));\n}, {\n type: 'webmusic.select',\n options: (input): SelectOptions => ({matches: values('select', 'matches', record(input).matches, 'at least one value to match')}),\n inputs: options => numbered('in', options.matches.length === 1 ? ['value to test', 'value to match'] : ['value to test']),\n outputs: options => numbered('out', [...options.matches.map(match => `bang on ${textOf(atomOf(match))}`), 'anything else']),\n bind(options, host) {\n const matches = [...options.matches];\n return {\n receive(index, value) {\n const atoms = atomsOf(value);\n if (index === 1) { const first = atoms[0]; if (first && (first.type === 'int' || first.type === 'float' || first.type === 'symbol')) matches[0] = first.value; return; }\n const found = select(value.selector === 'bang' ? symbolAtom('bang') : atoms[0], matches);\n if (found >= 0 && atoms.length <= 1) host.send(found, bang(value.time));\n else host.send(matches.length, value);\n },\n };\n },\n});\n\nexport interface RouteOptions { readonly keys: readonly MessageValue[] }\n\n/**\n * Route a message by its first element: the index of the key it starts with\n * and the rest of the message, or -1 and the message itself.\n */\nexport const route = bind(function route(value: Message, keys: readonly MessageValue[]): {index: number; message: Message} {\n const atoms = atomsOf(value);\n const index = keys.findIndex(key => sameAtom(atomOf(key), atoms[0]));\n return index < 0 ? {index, message: value} : {index, message: messageFromAtoms(atoms.slice(1), value.time)};\n}, {\n type: 'webmusic.route',\n options: (input): RouteOptions => ({keys: values('route', 'keys', record(input).keys, 'at least one value to route')}),\n inputs: () => [port('message', 'message to route')],\n outputs: options => numbered('out', [...options.keys.map(key => `rest of ${textOf(atomOf(key))}`), 'anything else']),\n bind: (options, host) => ({\n receive(_index, value) {\n const routed = route(value, options.keys);\n host.send(routed.index < 0 ? options.keys.length : routed.index, routed.message);\n },\n }),\n});\n\n// --- trigger -----------------------------------------------------------------------\n\n/** What one trigger output sends: a conversion of the input, or a fixed value. */\nexport type TriggerOutput = 'bang' | 'int' | 'float' | 'symbol' | 'list' | 'any' | {readonly value: MessageValue; readonly float?: boolean};\nexport interface TriggerOptions { readonly outputs: readonly TriggerOutput[] }\n\nconst TRIGGER_KINDS: readonly string[] = ['bang', 'int', 'float', 'symbol', 'list', 'any'];\nfunction convert(kind: TriggerOutput, value: Message): Message {\n if (typeof kind === 'object') return messageFromAtoms([atomOf(kind.value, kind.float)], value.time);\n const atoms = atomsOf(value);\n const first = atoms[0];\n switch (kind) {\n case 'bang': return bang(value.time);\n case 'int': return message('int', [intAtom(isNumberAtom(first) ? first.value : 0)], value.time);\n case 'float': return message('float', [floatAtom(isNumberAtom(first) ? first.value : 0)], value.time);\n case 'symbol': { const named = atoms.find(atom => atom.type === 'symbol'); return message('symbol', [symbolAtom(named?.type === 'symbol' ? named.value : value.selector)], value.time); }\n case 'list': return message('list', atoms, value.time);\n default: return value;\n }\n}\n\n/** One message per output, each a conversion of `value`, in output order. A graph sends them right to left. */\nexport const trigger = bind(function trigger(value: Message, outputs: readonly TriggerOutput[]): Message[] {\n return outputs.map(kind => convert(kind, value));\n}, {\n type: 'webmusic.trigger',\n options(input): TriggerOptions {\n const given = record(input).outputs;\n if (given === undefined) return {outputs: ['bang', 'bang']};\n const valid = (item: unknown) => TRIGGER_KINDS.includes(item as string) || (!!item && typeof item === 'object' && isValue((item as {value?: unknown}).value));\n if (!Array.isArray(given) || !given.length || !given.every(valid)) throw new TypeError('trigger needs \"outputs\": bang, int, float, symbol, list, any or {value}.');\n return {outputs: Object.freeze([...given]) as readonly TriggerOutput[]};\n },\n inputs: () => [port('message', 'message to distribute')],\n outputs: options => numbered('out', options.outputs.map(kind => typeof kind === 'object' ? textOf(atomOf(kind.value, kind.float)) : kind)),\n bind: (options, host) => ({\n receive(_index, value) {\n const sent = trigger(value, options.outputs);\n // Right to left: the last output fires first.\n for (let index = sent.length - 1; index >= 0; index--) host.send(index, sent[index]!);\n },\n }),\n});\n\n// --- pack and unpack ---------------------------------------------------------------\n\nexport type SlotType = 'int' | 'float' | 'symbol';\n/** One element of a packed list: its type, and the value it holds until one arrives. */\nexport type Slot = SlotType | {readonly type: SlotType; readonly value?: MessageValue};\nexport interface SlotOptions { readonly slots: readonly Slot[] }\n\nconst SLOT_TYPES: readonly string[] = ['int', 'float', 'symbol'];\nfunction slotAtom(slot: Slot): Atom {\n const type = typeof slot === 'string' ? slot : slot.type;\n const value = typeof slot === 'string' ? undefined : slot.value;\n if (type === 'symbol') return symbolAtom(value === undefined ? '' : String(value));\n const number = typeof value === 'number' ? value : 0;\n return type === 'float' ? floatAtom(number) : intAtom(number);\n}\nfunction coerce(slot: Atom, value: Atom): Atom {\n if (slot.type === 'int') return isNumberAtom(value) ? intAtom(value.value) : slot;\n if (slot.type === 'float') return isNumberAtom(value) ? floatAtom(value.value) : slot;\n if (slot.type === 'symbol') return value.type === 'symbol' ? value : symbolAtom(textOf(value));\n return value;\n}\nfunction slotOptions(name: string, input: unknown): SlotOptions {\n const given = record(input).slots;\n if (given === undefined) return {slots: ['int', 'int']};\n const valid = (item: unknown) => SLOT_TYPES.includes(item as string) || (!!item && typeof item === 'object' && SLOT_TYPES.includes((item as {type?: string}).type as string)\n && ((item as {value?: unknown}).value === undefined || isValue((item as {value?: unknown}).value)));\n if (!Array.isArray(given) || !given.length || !given.every(valid)) throw new TypeError(`${name} needs \"slots\": int, float, symbol or {type, value}.`);\n return {slots: Object.freeze([...given]) as readonly Slot[]};\n}\nconst asAtom = (value: MessageValue | Atom): Atom => typeof value === 'object' ? value : atomOf(value);\n\n/** A list of `values`, each made the type of its slot; a slot with no value keeps its own. */\nexport const pack = bind(function pack(slots: readonly Slot[], values: readonly (MessageValue | Atom)[] = [], time?: number): Message {\n return message('list', slots.map((slot, index) => values[index] === undefined ? slotAtom(slot) : coerce(slotAtom(slot), asAtom(values[index]!))), time);\n}, {\n type: 'webmusic.pack',\n options: (input): SlotOptions => slotOptions('pack', input),\n inputs: options => numbered('in', options.slots.map((_, index) => index === 0 ? 'first element, outputs the list' : `element ${index + 1}`)),\n outputs: () => [port('list', 'list')],\n bind(options, host) {\n const held = options.slots.map(slotAtom);\n const store = (atoms: readonly Atom[]) => atoms.forEach((atom, offset) => { if (offset < held.length) held[offset] = coerce(held[offset]!, atom); });\n return {\n receive(index, value) {\n const atoms = atomsOf(value);\n if (index > 0) { if (atoms[0]) held[index] = coerce(held[index]!, atoms[0]); return; }\n if (value.selector === 'bang') { host.send(0, message('list', held, value.time)); return; }\n if (value.selector === 'set') { store(atoms.slice(1)); return; }\n store(atoms);\n host.send(0, message('list', held, value.time));\n },\n };\n },\n});\n\n/** One message per slot from a list, each made the type of its slot; undefined where the list is shorter. */\nexport const unpack = bind(function unpack(value: Message, slots: readonly Slot[]): (Message | undefined)[] {\n const atoms = atomsOf(value);\n return slots.map((slot, index) => atoms[index] === undefined ? undefined : messageFromAtoms([coerce(slotAtom(slot), atoms[index]!)], value.time));\n}, {\n type: 'webmusic.unpack',\n options: (input): SlotOptions => slotOptions('unpack', input),\n inputs: () => [port('list', 'list to split')],\n outputs: options => numbered('out', options.slots.map((_, index) => `element ${index + 1}`)),\n bind: (options, host) => ({\n receive(_index, value) {\n const sent = unpack(value, options.slots);\n for (let index = sent.length - 1; index >= 0; index--) { const part = sent[index]; if (part) host.send(index, part); }\n },\n }),\n});\n\n// --- expr --------------------------------------------------------------------------\n\nexport interface ExprOptions { readonly expression: string }\n\n/**\n * Evaluate an expression of the `compileExpr` language with `inputs` as\n * `$i1`, `$f2`…. Compile once with `compileExpr` to evaluate many times.\n */\nexport const expr = bind(function expr(expression: string, inputs: readonly number[] = [], random?: () => number): number {\n return compileExpr(expression).evaluate(inputs, random).value;\n}, {\n type: 'webmusic.expr',\n options(input): ExprOptions {\n const expression = record(input).expression;\n if (typeof expression !== 'string') throw new TypeError('expr needs an \"expression\".');\n compileExpr(expression);\n return {expression};\n },\n inputs: options => numbered('in', Array.from({length: compileExpr(options.expression).inlets}, (_, index) => index === 0 ? '$1, evaluates' : `$${index + 1}`)),\n outputs: () => [port('result', 'result')],\n bind(options, host) {\n const compiled = compileExpr(options.expression);\n const inputs = new Array<number>(compiled.inlets).fill(0);\n const evaluate = (time?: number) => {\n const result = compiled.evaluate(inputs, host.random);\n host.send(0, numberMessage(result.value, result.float, time));\n };\n return {\n receive(index, value) {\n if (index === 0 && value.selector === 'bang') { evaluate(value.time); return; }\n // A list into the first input fills the inputs in order.\n atomsOf(value).forEach((atom, offset) => { if (isNumberAtom(atom) && index + offset < inputs.length) inputs[index + offset] = atom.value; });\n if (index === 0) evaluate(value.time);\n },\n };\n },\n});\n\n// --- random ------------------------------------------------------------------------\n\n/** A repeatable generator of uniform numbers in [0, 1) from a seed (mulberry32). */\nexport function seededRandom(seed: number): () => number {\n let state = seed >>> 0;\n return () => {\n state = (state + 0x6d2b79f5) >>> 0;\n let t = state;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nexport interface RandomOptions {\n /** Results are 0 to `range` − 1. Default 2. */\n readonly range?: number;\n /** A seed makes the series repeat; without one each instance draws from its host. */\n readonly seed?: number;\n}\n\n/** A random integer from 0 to `range` − 1, drawn from `next`. */\nexport const random = bind(function random(range: number, next: () => number = Math.random): number {\n return Math.floor(next() * range);\n}, {\n type: 'webmusic.random',\n options(input): RandomOptions {\n const {range, seed} = record(input);\n return {range: Math.max(1, Math.trunc(finite(range) ? range : 2)), ...(finite(seed) ? {seed} : {})};\n },\n inputs: () => [port('trigger', 'bang for a number, seed'), port('range', 'range')],\n outputs: () => [port('value', 'random int from 0')],\n bind(options, host) {\n let range = options.range ?? 2;\n let seed = options.seed;\n let next = seed === undefined ? host.random : seededRandom(seed);\n return {\n receive(index, value) {\n const number = numberOf(value);\n if (index === 1) { if (number !== undefined && number >= 1) range = Math.trunc(number); return; }\n if (value.selector === 'seed') {\n seed = number === undefined || number === 0 ? undefined : number;\n next = seed === undefined ? host.random : seededRandom(seed);\n return;\n }\n if (value.selector === 'bang') host.send(0, message('int', [intAtom(random(range, next))], value.time));\n },\n };\n },\n});\n\n// --- print -------------------------------------------------------------------------\n\nexport interface PrintOptions { readonly name?: string }\n\n/** Write a message as text, as `name: text`, and return that line. */\nexport const print = bind(function print(value: Message, name = 'print', write: (line: string) => void = line => console.log(line)): string {\n const line = `${name}: ${formatMessage(value)}`;\n write(line);\n return line;\n}, {\n type: 'webmusic.print',\n options(input): PrintOptions {\n const name = record(input).name;\n return {name: typeof name === 'string' && name ? name : 'print'};\n },\n inputs: () => [port('value', 'anything to print')],\n outputs: () => [],\n bind: (options, host) => ({\n receive(_index, value) { host.print(options.name ?? 'print', formatMessage(value)); },\n }),\n});\n\n/** Every message function, for a host that registers or lists them. */\nexport const MESSAGE_FUNCTIONS: readonly MessageFunction<never>[] = Object.freeze([select, route, trigger, pack, unpack, expr, scale, random, print] as unknown as MessageFunction<never>[]);\n","// Timers and counters as Headless classes (DEC-097): each is constructed with\n// typed options, driven by its members or by messages at its inputs, and\n// sends timed messages from its outputs. Hot inputs produce output; the\n// others store a value. Every output carries the time of what caused it.\n\nimport {\n atomsOf, bang, intAtom, isNumberAtom, message, messageFromAtoms, numberOf,\n type Atom, type Message, type MessageInputPort, type MessageOutputPort,\n} from '../module/message';\nimport {nextGridTime, timeValueSeconds, timeValueTicks} from '../transport';\nimport {numberMessage} from './functions';\nimport {GraphModule, numberedPort, type GraphModuleOptions, type ModuleOptionsJson} from '../module/graph-module';\n\n/** An atom's plain value, for options that hold a number or a word. */\nconst plainValue = (atom: Atom | undefined): number | string | undefined =>\n atom && (atom.type === 'int' || atom.type === 'float' || atom.type === 'symbol') ? atom.value : undefined;\nconst isBang = (value: Message) => value.selector === 'bang';\nconst isNumber = (value: Message) => value.selector === 'int' || value.selector === 'float';\nconst finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);\nconst count = (name: string, value: unknown, fallback: number, most: number): number => {\n if (value === undefined) return fallback;\n if (!finite(value)) throw new TypeError(`${name} must be a number.`);\n return Math.max(1, Math.min(most, Math.trunc(value)));\n};\n\n// --- load bang -----------------------------------------------------------------\n\n/** Sends a bang when it is activated, and again for anything at its input. */\nexport class LoadBang extends GraphModule {\n static readonly type = 'webmusic.load-bang';\n readonly inputs = {trigger: this.input('trigger', 'bang', value => this.outputs.bang.send(bang(value.time)))};\n readonly outputs = {bang: this.output('bang', 'bang when the component loads')};\n constructor(options: GraphModuleOptions = {}) { super(LoadBang.type, options); }\n protected override onActivate(): void { this.outputs.bang.send(bang()); }\n exportOptions(): ModuleOptionsJson { return {}; }\n}\n\n// --- metro ---------------------------------------------------------------------\n\nexport interface MetroOptions extends GraphModuleOptions {\n /** Milliseconds, or a time value (`4n`, `8nt`, `1.0.0`) that follows the Session's transport. Default 500. */\n readonly interval?: number | string;\n /** Start ticking when activated. Default false. */\n readonly running?: boolean;\n}\n\ntype Interval = {readonly kind: 'ms'; readonly ms: number} | {readonly kind: 'musical'; readonly text: string};\n\nfunction intervalOf(value: unknown, fallback: Interval): Interval {\n if (finite(value)) return value > 0 ? {kind: 'ms', ms: value} : fallback;\n if (typeof value !== 'string') return fallback;\n if (timeValueTicks(value) !== undefined) return {kind: 'musical', text: value};\n const seconds = timeValueSeconds(value);\n return seconds > 0 ? {kind: 'ms', ms: seconds * 1000} : fallback;\n}\n\n/**\n * A metronome. A millisecond interval ticks on the clock from its start; a\n * time value ticks on the transport's grid, only while the Session plays.\n */\nexport class Metro extends GraphModule {\n static readonly type = 'webmusic.metro';\n readonly inputs = {\n control: this.input('control', 'on/off, bang, stop', value => this.#control(value)),\n interval: this.input('interval', 'interval (ms or a time value such as 4n)', value => {\n this.#interval = intervalOf(plainValue(atomsOf(value)[0]), this.#interval);\n if (this.#running) this.#begin(this.timeOf(value));\n }),\n };\n readonly outputs = {ticks: this.output('ticks', 'bang')};\n #interval: Interval;\n #running: boolean;\n #cancel?: () => void;\n #release?: () => void;\n\n constructor(options: MetroOptions = {}) {\n super(Metro.type, options);\n if (finite(options.interval) && !(options.interval > 0)) throw new RangeError('metro interval must be greater than 0.');\n this.#interval = intervalOf(options.interval, {kind: 'ms', ms: 500});\n this.#running = options.running === true;\n this.#release = this.musicalTime?.subscribe(() => { if (this.#interval.kind === 'musical' && this.#running) this.#scheduleLocked(); });\n }\n\n /** Whether the metronome is on. A transport-locked one ticks only while the Session plays. */\n get running(): boolean { return this.#running; }\n /** The interval: milliseconds, or the time value it follows. */\n get interval(): number | string { return this.#interval.kind === 'ms' ? this.#interval.ms : this.#interval.text; }\n\n /** Turn it on from `time` (now by default). Activates the module if it is not yet active. */\n start(time?: number): void {\n this.#running = true;\n if (!this.active) { this.activate(); return; }\n this.#begin(time ?? this.clock.now());\n }\n stop(): void { this.#cancel?.(); this.#cancel = undefined; this.#running = false; }\n\n exportOptions(): ModuleOptionsJson { return {interval: this.interval, running: this.#running}; }\n protected override onActivate(): void { this.#begin(this.clock.now()); }\n protected override onDispose(): void { this.stop(); this.#release?.(); }\n\n #control(value: Message): void {\n if (value.selector === 'stop' || (isNumber(value) && numberOf(value) === 0)) this.stop();\n else if (isBang(value) || isNumber(value) || value.selector === 'start') { this.#running = true; this.#begin(this.timeOf(value)); }\n }\n\n // Free-running: every interval from the start, on the clock.\n #tick = (time: number): void => {\n this.outputs.ticks.send(bang(time));\n if (this.#interval.kind === 'ms') this.#cancel = this.clock.schedule(time + this.#interval.ms / 1000, this.#tick);\n };\n\n // Musical: on the transport's grid, only while it plays.\n #scheduleLocked(from?: number): void {\n this.#cancel?.(); this.#cancel = undefined;\n const musical = this.musicalTime;\n if (this.#interval.kind !== 'musical' || !this.#running || !this.active || !musical?.playing()) return;\n const step = timeValueSeconds(this.#interval.text, musical.tempo());\n const position = from ?? nextGridTime(musical.position(), step);\n const when = musical.timeAt(position);\n if (when === undefined) return;\n this.#cancel = this.clock.schedule(Math.max(this.clock.now(), when), time => {\n this.#cancel = undefined;\n this.outputs.ticks.send(bang(time));\n this.#scheduleLocked(position + step);\n });\n }\n\n #begin(time: number): void {\n this.#cancel?.(); this.#cancel = undefined;\n if (!this.active || !this.#running) return;\n if (this.#interval.kind === 'ms') this.#tick(time); else this.#scheduleLocked();\n }\n}\n\n// --- delay and pipe --------------------------------------------------------------\n\nexport interface DelayOptions extends GraphModuleOptions {\n /** Delay in milliseconds. Default 0. */\n readonly time?: number;\n}\n\n/** Sends one bang a time after it is triggered; a new trigger replaces the pending one. */\nexport class Delay extends GraphModule {\n static readonly type = 'webmusic.delay';\n readonly inputs = {\n trigger: this.input('trigger', 'bang, stop, or delay time to start', value => {\n const number = numberOf(value);\n if (value.selector === 'stop') { this.cancel(); return; }\n if (isNumber(value) && number !== undefined && number >= 0) this.#time = number;\n if (isBang(value) || isNumber(value)) this.trigger(this.timeOf(value));\n }),\n time: this.input('time', 'delay time (ms)', value => { const number = numberOf(value); if (number !== undefined && number >= 0) this.#time = number; }),\n };\n readonly outputs = {bang: this.output('bang', 'bang after the delay')};\n #time: number;\n readonly #authored: number;\n #cancel?: () => void;\n\n constructor(options: DelayOptions = {}) {\n super(Delay.type, options);\n this.#time = this.#authored = finite(options.time) ? options.time : 0;\n }\n\n /** The delay, in milliseconds. */\n get time(): number { return this.#time; }\n set time(value: number) { if (value >= 0) this.#time = value; }\n /** Send the bang `time` milliseconds after `from` (now by default). */\n trigger(from: number = this.clock.now()): void {\n this.#cancel?.();\n this.#cancel = this.clock.schedule(from + this.#time / 1000, when => { this.#cancel = undefined; this.outputs.bang.send(bang(when)); });\n }\n /** Drop the pending bang. */\n cancel(): void { this.#cancel?.(); this.#cancel = undefined; }\n\n exportOptions(): ModuleOptionsJson { return {time: this.#authored}; }\n protected override onDispose(): void { this.#cancel?.(); }\n}\n\n/** Sends every value it receives a time later, each on its own. */\nexport class Pipe extends GraphModule {\n static readonly type = 'webmusic.pipe';\n readonly inputs = {\n value: this.input('value', 'value to delay, clear', value => {\n if (value.selector === 'clear') { this.clear(); return; }\n this.send(value);\n }),\n time: this.input('time', 'delay time (ms)', value => { const number = numberOf(value); if (number !== undefined && number >= 0) this.#time = number; }),\n };\n readonly outputs = {value: this.output('value', 'the value after the delay')};\n #time: number;\n readonly #authored: number;\n readonly #pending = new Set<() => void>();\n\n constructor(options: DelayOptions = {}) {\n super(Pipe.type, options);\n this.#time = this.#authored = finite(options.time) ? options.time : 0;\n }\n\n /** The delay, in milliseconds. */\n get time(): number { return this.#time; }\n set time(value: number) { if (value >= 0) this.#time = value; }\n /** Send `value` from the output after the delay, counted from its own time. */\n send(value: Message): void {\n const atoms = atomsOf(value);\n const cancel = this.clock.schedule(this.timeOf(value) + this.#time / 1000, when => {\n this.#pending.delete(cancel);\n this.outputs.value.send(messageFromAtoms(atoms, when));\n });\n this.#pending.add(cancel);\n }\n /** Drop every value still waiting. */\n clear(): void { for (const cancel of this.#pending) cancel(); this.#pending.clear(); }\n\n exportOptions(): ModuleOptionsJson { return {time: this.#authored}; }\n protected override onDispose(): void { this.clear(); }\n}\n\n// --- line ------------------------------------------------------------------------\n\nexport interface LineOptions extends GraphModuleOptions {\n /** Where the ramp starts. Default 0. */\n readonly value?: number;\n /** Milliseconds between the values of a ramp. Default 20. */\n readonly grain?: number;\n /** Send floats; otherwise each value is rounded to an int. Default false. */\n readonly float?: boolean;\n}\n\n/** Ramps to a target in steps: one value every `grain` milliseconds, then a bang. */\nexport class Line extends GraphModule {\n static readonly type = 'webmusic.line';\n readonly inputs = {\n target: this.input('target', 'target, or target and time (ms)', value => {\n const atoms = atomsOf(value);\n if (value.selector === 'stop') { this.stop(); return; }\n if (value.selector === 'set') { const n = numberOf(message('list', atoms.slice(1))); if (n !== undefined) { this.stop(); this.#current = n; } return; }\n const target = isNumberAtom(atoms[0]) ? atoms[0].value : undefined;\n if (target === undefined) return;\n const duration = isNumberAtom(atoms[1]) ? atoms[1].value : this.#nextTime;\n this.#nextTime = 0;\n this.ramp(target, duration, this.timeOf(value));\n }),\n time: this.input('time', 'ramp time (ms)', value => { const n = numberOf(value); if (n !== undefined && n >= 0) this.#nextTime = n; }),\n grain: this.input('grain', 'grain (ms)', value => { const n = numberOf(value); if (n !== undefined && n > 0) this.#grain = n; }),\n };\n readonly outputs = {value: this.output('value', 'ramp values'), done: this.output('done', 'bang at the end')};\n readonly #float: boolean;\n #current: number;\n #nextTime = 0;\n #grain: number;\n readonly #authoredGrain: number;\n #cancel?: () => void;\n\n constructor(options: LineOptions = {}) {\n super(Line.type, options);\n this.#float = options.float === true;\n this.#current = finite(options.value) ? options.value : 0;\n this.#grain = this.#authoredGrain = finite(options.grain) && options.grain > 0 ? options.grain : 20;\n }\n\n /** The value the ramp has reached. */\n get value(): number { return this.#current; }\n /** Ramp to `target` over `duration` milliseconds from `start` (now by default); 0 jumps. */\n ramp(target: number, duration = 0, start: number = this.clock.now()): void {\n this.stop();\n const {value, done} = this.outputs;\n if (duration <= 0) { this.#current = target; value.send(numberMessage(target, this.#float, start)); done.send(bang(start)); return; }\n const from = this.#current, steps = Math.max(1, Math.ceil(duration / this.#grain));\n let step = 0;\n const next = (time: number) => {\n step++;\n this.#current = step >= steps ? target : from + (target - from) * (step / steps);\n value.send(numberMessage(this.#current, this.#float, time));\n if (step >= steps) { this.#cancel = undefined; done.send(bang(time)); return; }\n this.#cancel = this.clock.schedule(start + (duration / 1000) * ((step + 1) / steps), next);\n };\n this.#cancel = this.clock.schedule(start + (duration / 1000) / steps, next);\n }\n /** Stop where the ramp is. */\n stop(): void { this.#cancel?.(); this.#cancel = undefined; }\n\n exportOptions(): ModuleOptionsJson { return {value: this.#current, grain: this.#authoredGrain, float: this.#float}; }\n protected override onDispose(): void { this.stop(); }\n}\n\n// --- counter -----------------------------------------------------------------------\n\nexport interface CounterOptions extends GraphModuleOptions {\n /** The first value, and where the count returns after `maximum`. Default 0. */\n readonly minimum?: number;\n /** The last value before the count wraps. Absent: it never wraps. */\n readonly maximum?: number;\n /** The value the next count sends. Defaults to `minimum`. */\n readonly next?: number;\n}\n\n/** Counts up by one for each bang and reports when it wraps. */\nexport class Counter extends GraphModule {\n static readonly type = 'webmusic.counter';\n readonly inputs = {\n trigger: this.input('trigger', 'bang to count, set, reset, min, max', value => {\n const number = numberOf(value);\n switch (value.selector) {\n case 'bang': this.count(value.time); return;\n case 'reset': this.reset(); return;\n case 'set': if (number !== undefined) this.#next = Math.trunc(number); return;\n case 'min': if (number !== undefined) this.#minimum = Math.trunc(number); return;\n case 'max': if (number !== undefined) this.#maximum = Math.trunc(number); return;\n case 'int': case 'float': if (number !== undefined) { this.#next = Math.trunc(number); this.count(value.time); } return;\n }\n }),\n next: this.input('next', 'next value', value => { const number = numberOf(value); if (number !== undefined) this.#next = Math.trunc(number); }),\n };\n readonly outputs = {count: this.output('count', 'count'), wrap: this.output('wrap', 'bang when it wraps')};\n #minimum: number;\n #maximum: number;\n readonly #authored: {minimum: number; maximum: number};\n #next: number;\n\n constructor(options: CounterOptions = {}) {\n super(Counter.type, options);\n this.#minimum = finite(options.minimum) ? options.minimum : 0;\n this.#maximum = finite(options.maximum) ? options.maximum : Infinity;\n this.#authored = {minimum: this.#minimum, maximum: this.#maximum};\n this.#next = finite(options.next) ? options.next : this.#minimum;\n }\n\n /** The value the next count sends. */\n get next(): number { return this.#next; }\n set next(value: number) { this.#next = Math.trunc(value); }\n /** Send the count and advance it; returns the value sent. */\n count(time?: number): number {\n const value = this.#next;\n this.#next = value + 1;\n let wrapped = false;\n if (this.#next > this.#maximum) { this.#next = this.#minimum; wrapped = true; }\n this.outputs.count.send(message('int', [intAtom(value)], time));\n if (wrapped) this.outputs.wrap.send(bang(time));\n return value;\n }\n /** Return to the minimum without sending. */\n reset(): void { this.#next = this.#minimum; }\n\n exportOptions(): ModuleOptionsJson {\n const {minimum, maximum} = this.#authored;\n return {minimum, ...(Number.isFinite(maximum) ? {maximum} : {}), next: this.#next};\n }\n}\n\n// --- gate and switch -----------------------------------------------------------------\n\nexport interface GateOptions extends GraphModuleOptions {\n /** How many outputs (gate) or inputs (switch) there are to choose among. */\n readonly count?: number;\n /** Which one is open, counted from 1; 0 closes all. Default 0. */\n readonly open?: number;\n}\n\n/** Passes messages to the one output that is open. */\nexport class Gate extends GraphModule {\n static readonly type = 'webmusic.gate';\n readonly inputs: {readonly open: MessageInputPort; readonly message: MessageInputPort};\n /** `out0`, `out1`…, one for each output. */\n readonly outputs: Readonly<Record<string, MessageOutputPort>>;\n readonly #count: number;\n readonly #ports: MessageOutputPort[];\n #open: number;\n\n constructor(options: GateOptions = {}) {\n super(Gate.type, options);\n this.#count = count('gate count', options.count, 1, 64);\n this.#open = this.#clamp(finite(options.open) ? options.open : 0);\n this.inputs = {\n open: this.input('open', 'outlet to open (0 closes)', value => { const n = numberOf(value); if (n !== undefined) this.open = n; }),\n message: this.input('message', 'message to pass', value => { if (this.#open > 0) this.#ports[this.#open - 1]!.send(value); }),\n };\n this.#ports = Array.from({length: this.#count}, (_, index) => this.output(numberedPort('out', index), `open ${index + 1}`));\n this.outputs = Object.freeze(Object.fromEntries(this.#ports.map(port => [port.id, port])));\n }\n\n /** The open output, counted from 1; 0 when closed. */\n get open(): number { return this.#open; }\n set open(value: number) { this.#open = this.#clamp(value); this.changed(); }\n #clamp(value: number): number { return Math.max(0, Math.min(this.#count, Math.trunc(value))); }\n exportOptions(): ModuleOptionsJson { return {count: this.#count, open: this.#open}; }\n}\n\n/** Passes the messages of the one input that is open. */\nexport class Switch extends GraphModule {\n static readonly type = 'webmusic.switch';\n /** `in0` chooses the open input; `in1`, `in2`… are the inputs. */\n readonly inputs: Readonly<Record<string, MessageInputPort>>;\n readonly outputs: {readonly message: MessageOutputPort};\n readonly #count: number;\n #open: number;\n\n constructor(options: GateOptions = {}) {\n super(Switch.type, options);\n this.#count = count('switch count', options.count, 2, 64);\n this.#open = this.#clamp(finite(options.open) ? options.open : 0);\n const ports = [\n this.input(numberedPort('in', 0), 'inlet to pass (0 closes)', value => { const n = numberOf(value); if (n !== undefined) this.open = n; }),\n ...Array.from({length: this.#count}, (_, index) =>\n this.input(numberedPort('in', index + 1), `input ${index + 1}`, value => { if (index + 1 === this.#open) this.outputs.message.send(value); })),\n ];\n this.inputs = Object.freeze(Object.fromEntries(ports.map(port => [port.id, port])));\n this.outputs = {message: this.output('message', 'the open input')};\n }\n\n /** The open input, counted from 1; 0 when closed. */\n get open(): number { return this.#open; }\n set open(value: number) { this.#open = this.#clamp(value); }\n #clamp(value: number): number { return Math.max(0, Math.min(this.#count, Math.trunc(value))); }\n exportOptions(): ModuleOptionsJson { return {count: this.#count, open: this.#open}; }\n}\n","// Values with a control (DEC-097): Headless values a program reads, writes\n// and watches, each offering `MODULE_CONTROL` so a UI Kit `/controls`\n// presenter can show it. The module holds the value; the presenter is the\n// host's. A value sent to the input is stored and sent on; `set` stores it\n// silently, and a bang sends what is held.\n\nimport {\n atomsOf, bang, floatAtom, formatMessage, intAtom, isNumberAtom, message, messageFromAtoms, numberOf, parseMessage, symbolAtom,\n type Atom, type JsonValue, type Message,\n} from '../module/message';\nimport {ControlModule} from '../module/module-control';\nimport type {ProjectJson} from '../module/project-types';\nimport {numberMessage} from './functions';\nimport type {GraphModuleOptions, ModuleOptionsJson} from '../module/graph-module';\n\nconst finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);\nconst whole = (name: string, value: unknown, fallback: number, least: number, most: number): number => {\n if (value === undefined) return fallback;\n if (!finite(value)) throw new TypeError(`${name} must be a number.`);\n return Math.max(least, Math.min(most, Math.trunc(value)));\n};\n\n// --- button and toggle -----------------------------------------------------------\n\n/** Sends a bang for anything it receives and counts its flashes. */\nexport class Button extends ControlModule {\n static readonly type = 'webmusic.button';\n readonly kind = 'button';\n readonly inputs = {trigger: this.input('trigger', 'anything flashes and outputs a bang', value => this.receive(value))};\n readonly outputs = {bang: this.output('bang', 'bang')};\n #flashes = 0;\n constructor(options: GraphModuleOptions = {}) { super(Button.type, options); }\n /** How many times it has fired. */\n get flashes(): number { return this.#flashes; }\n /** Fire: flash and send a bang at `time`. */\n press(time?: number): void { this.#flashes++; this.changed(); this.outputs.bang.send(bang(time)); }\n snapshot(): JsonValue { return {flashes: this.#flashes}; }\n exportOptions(): ModuleOptionsJson { return {}; }\n protected receive(value: Message): void { this.press(value.time); }\n}\n\nexport interface ToggleOptions extends GraphModuleOptions {\n /** Whether it starts on. Default false. */\n readonly value?: boolean;\n}\n\n/** An on/off value: a bang flips it, a number sets it. */\nexport class Toggle extends ControlModule {\n static readonly type = 'webmusic.toggle';\n readonly kind = 'toggle';\n readonly inputs = {value: this.input('value', 'bang flips, a number sets, set', value => this.receive(value))};\n readonly outputs = {value: this.output('value', '0 or 1')};\n #on: boolean;\n constructor(options: ToggleOptions = {}) { super(Toggle.type, options); this.#on = options.value === true; }\n get value(): boolean { return this.#on; }\n /** Set the value and send it; `silent` stores it without sending. */\n set(on: boolean, options: {silent?: boolean; time?: number} = {}): void {\n this.#on = on;\n this.changed();\n if (!options.silent) this.outputs.value.send(message('int', [intAtom(on ? 1 : 0)], options.time));\n }\n snapshot(): JsonValue { return {on: this.#on}; }\n exportOptions(): ModuleOptionsJson { return {value: this.#on}; }\n protected receive(value: Message): void {\n const number = numberOf(value);\n if (value.selector === 'set') { if (number !== undefined) this.set(number !== 0, {silent: true}); return; }\n if (value.selector === 'bang') this.set(!this.#on, {time: value.time});\n else if (number !== undefined) this.set(number !== 0, {time: value.time});\n }\n}\n\n// --- number ------------------------------------------------------------------------\n\nexport interface NumberValueOptions extends GraphModuleOptions {\n /** Which control shows it. Default `number`, a number box. */\n readonly control?: 'number' | 'slider' | 'dial';\n /** Lowest value. Default: none for a number box, 0 for a slider or dial. */\n readonly min?: number;\n /** Highest value. Default: none for a number box, 127 for a slider or dial. */\n readonly max?: number;\n /** Hold and send floats; otherwise values are rounded to ints. Default false. */\n readonly float?: boolean;\n /** The value it starts with. Default 0, moved into the range. */\n readonly value?: number;\n}\n\nconst NUMBER_CONTROLS: readonly string[] = ['number', 'slider', 'dial'];\n\n/** A number within a range, shown as a number box, a slider or a dial. */\nexport class NumberValue extends ControlModule {\n static readonly type = 'webmusic.number';\n readonly kind: 'number' | 'slider' | 'dial';\n readonly inputs = {value: this.input('value', 'value to set and output, set, bang', value => this.receive(value))};\n readonly outputs = {value: this.output('value', 'value')};\n readonly min: number;\n readonly max: number;\n readonly float: boolean;\n #value: number;\n\n constructor(options: NumberValueOptions = {}) {\n super(NumberValue.type, options);\n if (options.control !== undefined && !NUMBER_CONTROLS.includes(options.control)) throw new TypeError('A number is shown as number, slider or dial.');\n this.kind = options.control ?? 'number';\n const box = this.kind === 'number';\n this.min = finite(options.min) ? options.min : box ? -Infinity : 0;\n this.max = finite(options.max) ? options.max : box ? Infinity : 127;\n this.float = options.float === true;\n this.#value = this.#clamp(finite(options.value) ? options.value : Math.min(Math.max(0, Math.min(this.min, this.max)), Math.max(this.min, this.max)));\n }\n\n get value(): number { return this.#value; }\n /** Set the value, moved into the range, and send it; `silent` stores it without sending. */\n set(value: number, options: {silent?: boolean; time?: number} = {}): void {\n this.#value = this.#clamp(value);\n this.changed();\n if (!options.silent) this.outputs.value.send(numberMessage(this.#value, this.float, options.time));\n }\n snapshot(): JsonValue { return {value: this.#value, min: this.min, max: this.max, float: this.float}; }\n exportOptions(): ModuleOptionsJson {\n return {control: this.kind, ...(Number.isFinite(this.min) ? {min: this.min} : {}), ...(Number.isFinite(this.max) ? {max: this.max} : {}), float: this.float, value: this.#value};\n }\n protected receive(input: Message): void {\n const number = numberOf(input);\n if (input.selector === 'bang') { this.outputs.value.send(numberMessage(this.#value, this.float, input.time)); return; }\n if (number === undefined) return;\n this.set(number, {silent: input.selector === 'set', time: input.time});\n }\n #clamp(value: number): number {\n const bounded = Math.min(Math.max(this.min, this.max), Math.max(Math.min(this.min, this.max), value));\n return this.float ? bounded : Math.round(bounded);\n }\n}\n\n// --- choice ------------------------------------------------------------------------\n\nexport interface ChoiceOptions extends GraphModuleOptions {\n /** Which control shows it. Default `menu`. */\n readonly control?: 'menu' | 'tab';\n /** The items to choose among; at least one. */\n readonly items: readonly string[];\n /** The index chosen at the start. Default 0. */\n readonly value?: number;\n}\n\n/** One of several named items, shown as a menu or as tabs. */\nexport class Choice extends ControlModule {\n static readonly type = 'webmusic.choice';\n readonly kind: 'menu' | 'tab';\n readonly inputs = {index: this.input('index', 'index to choose and output, set, bang', value => this.receive(value))};\n readonly outputs = {index: this.output('index', 'index'), item: this.output('item', 'item')};\n readonly items: readonly string[];\n #index: number;\n\n constructor(options: ChoiceOptions) {\n super(Choice.type, options);\n if (options.control !== undefined && options.control !== 'menu' && options.control !== 'tab') throw new TypeError('A choice is shown as menu or tab.');\n this.kind = options.control ?? 'menu';\n if (!Array.isArray(options.items) || !options.items.length || !options.items.every(item => typeof item === 'string')) {\n throw new TypeError(`${this.kind} needs at least one item.`);\n }\n this.items = Object.freeze([...options.items]);\n this.#index = this.#clamp(finite(options.value) ? options.value : 0);\n }\n\n /** The chosen index. */\n get value(): number { return this.#index; }\n /** Choose an index and send it; `silent` stores it without sending. */\n set(index: number, options: {silent?: boolean; time?: number} = {}): void {\n this.#index = this.#clamp(index);\n this.changed();\n if (!options.silent) this.#send(options.time);\n }\n snapshot(): JsonValue { return {items: this.items, index: this.#index}; }\n exportOptions(): ModuleOptionsJson { return {control: this.kind, items: this.items, value: this.#index}; }\n protected receive(value: Message): void {\n const number = numberOf(value);\n if (value.selector === 'bang') { this.#send(value.time); return; }\n if (number === undefined) return;\n this.set(number, {silent: value.selector === 'set', time: value.time});\n }\n #send(time?: number): void {\n // Right to left: the item, then the index.\n this.outputs.item.send(messageFromAtoms([symbolAtom(this.items[this.#index]!)], time));\n this.outputs.index.send(message('int', [intAtom(this.#index)], time));\n }\n #clamp(value: number): number { return Math.max(0, Math.min(this.items.length - 1, Math.trunc(value))); }\n}\n\n// --- message box ---------------------------------------------------------------------\n\nexport interface MessageBoxOptions extends GraphModuleOptions {\n /** The message text; commas separate messages sent one after another, and `$1`…`$9` take the input's values. */\n readonly text?: string;\n}\n\n/** A message kept as text and sent when triggered. */\nexport class MessageBox extends ControlModule {\n static readonly type = 'webmusic.message-box';\n readonly kind = 'message';\n readonly inputs = {trigger: this.input('trigger', 'bang outputs, $1… fill from any message, set', value => this.receive(value))};\n readonly outputs = {message: this.output('message', 'the message')};\n #text: string;\n constructor(options: MessageBoxOptions = {}) {\n super(MessageBox.type, options);\n if (options.text !== undefined && typeof options.text !== 'string') throw new TypeError('A message box holds text.');\n this.#text = options.text ?? '';\n }\n get text(): string { return this.#text; }\n set text(value: string) { this.#text = value; this.changed(); }\n /** Send the text as messages, with `$1`… taken from `values`. */\n send(values: readonly Atom[] = [], time?: number): void {\n const text = (atom: Atom) => formatMessage(messageFromAtoms([atom]));\n for (const part of this.#text.split(',')) {\n const filled = part.replace(/\\$([1-9])/g, (_, digit: string) => { const atom = values[Number(digit) - 1]; return atom ? text(atom) : '0'; }).trim();\n if (filled) this.outputs.message.send(parseMessage(filled, time));\n }\n }\n snapshot(): JsonValue { return {text: this.#text}; }\n exportOptions(): ModuleOptionsJson { return {text: this.#text}; }\n protected receive(value: Message): void {\n if (value.selector === 'set') { this.text = value.atoms.map(atom => formatMessage(messageFromAtoms([atom]))).join(' '); return; }\n this.send(value.selector === 'bang' ? [] : atomsOf(value), value.time);\n }\n}\n\n// --- value list --------------------------------------------------------------------\n\nexport interface ValueListOptions extends GraphModuleOptions {\n /** How many values, 1 to 128. Default 8. */\n readonly count?: number;\n readonly min?: number;\n readonly max?: number;\n /** Hold floats. Default true. */\n readonly float?: boolean;\n /** The values it starts with; missing ones are `min`. */\n readonly values?: readonly number[];\n}\n\n/** A list of numbers within one range, shown as a row of sliders. */\nexport class ValueList extends ControlModule {\n static readonly type = 'webmusic.value-list';\n readonly kind = 'multislider';\n readonly inputs = {values: this.input('values', 'list to set and output, set, bang', value => this.receive(value))};\n readonly outputs = {values: this.output('values', 'list of values')};\n readonly min: number;\n readonly max: number;\n readonly float: boolean;\n readonly #values: number[];\n\n constructor(options: ValueListOptions = {}) {\n super(ValueList.type, options);\n const count = whole('count', options.count, 8, 1, 128);\n this.min = finite(options.min) ? options.min : 0;\n this.max = finite(options.max) ? options.max : 1;\n this.float = options.float !== false;\n const saved = options.values;\n this.#values = Array.from({length: count}, (_, index) => this.#clamp(Array.isArray(saved) && finite(saved[index]) ? saved[index] : this.min));\n }\n\n get values(): readonly number[] { return [...this.#values]; }\n /** Set values from the first on and send the list; `silent` stores them without sending. */\n set(values: readonly number[], options: {silent?: boolean; time?: number} = {}): void {\n values.forEach((value, index) => { if (finite(value) && index < this.#values.length) this.#values[index] = this.#clamp(value); });\n this.changed();\n if (!options.silent) this.#send(options.time);\n }\n snapshot(): JsonValue { return {values: [...this.#values], min: this.min, max: this.max, float: this.float}; }\n exportOptions(): ModuleOptionsJson { return {count: this.#values.length, min: this.min, max: this.max, float: this.float, values: [...this.#values]}; }\n protected receive(value: Message): void {\n const atoms = atomsOf(value);\n if (value.selector === 'bang') { this.#send(value.time); return; }\n const silent = value.selector === 'set';\n const given = silent ? atoms.slice(1) : atoms;\n if (!silent && !given.some(isNumberAtom)) return;\n // A value that is not a number leaves its place as it is.\n this.set(given.map(atom => isNumberAtom(atom) ? atom.value : NaN), {silent, time: value.time});\n }\n #send(time?: number): void {\n this.outputs.values.send(message('list', this.#values.map(value => this.float ? floatAtom(value) : intAtom(value)), time));\n }\n #clamp(value: number): number {\n const bounded = Math.min(Math.max(this.min, this.max), Math.max(Math.min(this.min, this.max), value));\n return this.float ? bounded : Math.round(bounded);\n }\n}\n\n// --- matrix ------------------------------------------------------------------------\n\nexport interface MatrixOptions extends GraphModuleOptions {\n /** 1 to 32. Default 4. */\n readonly columns?: number;\n /** 1 to 32. Default 4. */\n readonly rows?: number;\n /** The cells by row, 0 or 1 each. */\n readonly cells?: readonly number[];\n}\n\n/** A grid of on/off cells. */\nexport class Matrix extends ControlModule {\n static readonly type = 'webmusic.matrix';\n readonly kind = 'matrix';\n readonly inputs = {cell: this.input('cell', 'column row value, clear, bang', value => this.receive(value))};\n readonly outputs = {cell: this.output('cell', 'column row value')};\n readonly columns: number;\n readonly rows: number;\n readonly #cells: number[];\n\n constructor(options: MatrixOptions = {}) {\n super(Matrix.type, options);\n this.columns = whole('columns', options.columns, 4, 1, 32);\n this.rows = whole('rows', options.rows, 4, 1, 32);\n const saved = options.cells;\n this.#cells = Array.from({length: this.columns * this.rows}, (_, index) => Array.isArray(saved) && saved[index] === 1 ? 1 : 0);\n }\n\n /** The cells by row, 0 or 1 each. */\n get cells(): readonly number[] { return [...this.#cells]; }\n /** Set one cell and send it; `silent` stores it without sending. Cells outside the grid are ignored. */\n set(column: number, row: number, on: boolean, options: {silent?: boolean; time?: number} = {}): void {\n if (column < 0 || column >= this.columns || row < 0 || row >= this.rows) return;\n this.#cells[row * this.columns + column] = on ? 1 : 0;\n this.changed();\n if (!options.silent) this.#send(column, row, on ? 1 : 0, options.time);\n }\n clear(): void { this.#cells.fill(0); this.changed(); }\n snapshot(): JsonValue { return {columns: this.columns, rows: this.rows, cells: [...this.#cells]}; }\n exportOptions(): ModuleOptionsJson { return {columns: this.columns, rows: this.rows, cells: [...this.#cells] as ProjectJson}; }\n protected receive(value: Message): void {\n if (value.selector === 'clear') { this.clear(); return; }\n if (value.selector === 'bang') {\n for (let row = 0; row < this.rows; row++) for (let column = 0; column < this.columns; column++) if (this.#cells[row * this.columns + column]) this.#send(column, row, 1, value.time);\n return;\n }\n const silent = value.selector === 'set';\n const numbers = (silent ? value.atoms : atomsOf(value)).filter(isNumberAtom).map(atom => Math.trunc(atom.value));\n if (numbers.length < 3) return;\n const [column, row, on] = numbers as [number, number, number];\n this.set(column, row, on !== 0, {silent, time: value.time});\n }\n #send(column: number, row: number, value: number, time?: number): void {\n this.outputs.cell.send(message('list', [intAtom(column), intAtom(row), intAtom(value)], time));\n }\n}\n","// Sources and sinks as Headless classes (DEC-097): control signals that\n// follow messages on their sample, the Session's musical time as messages,\n// and gamepads, HID devices and OSC over a WebSocket.\n//\n// Ownership: a control source owns its ConstantSourceNode; an input source\n// owns its polling timer, device handle or socket; each releases them on\n// dispose. Browser APIs are reached only when an instance is activated or\n// opened, so importing this file needs no DOM.\n\nimport {\n atomsOf, bang, floatAtom, intAtom, isNumberAtom, message, numberOf, symbolAtom,\n type Atom, type Message,\n} from '../module/message';\nimport {decodeOsc, encodeOsc, isOscBundle, type OscArgument, type OscPacket} from '../module/osc';\nimport type {ControlSignal} from '../module/param-audio';\nimport {GraphModule, type GraphModuleOptions, type ModuleOptionsJson} from '../module/graph-module';\n\nconst finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);\n\n// --- control signals -----------------------------------------------------------------\n\n/** A ConstantSourceNode whose value follows messages on the scheduled sample. */\nfunction constantControl(audio: BaseAudioContext, initial: number) {\n const node = audio.createConstantSource();\n node.offset.value = initial;\n node.start();\n const segments: {start: number; from: number; end: number; to: number}[] = [];\n const valueAt = (time: number): number => {\n let value = initial;\n for (const segment of segments) {\n if (time >= segment.end) value = segment.to;\n else if (time >= segment.start) value = segment.from + (segment.to - segment.from) * ((time - segment.start) / Math.max(1e-9, segment.end - segment.start));\n }\n return value;\n };\n return {\n control: Object.freeze({output: node, rate: 'a-rate' as const, range: Object.freeze({min: -1, max: 1})}) as ControlSignal,\n /** Jump to `value` at `time`. */\n set(value: number, time: number) {\n node.offset.cancelScheduledValues(time);\n node.offset.setValueAtTime(value, time);\n segments.splice(0, segments.length, {start: time, from: value, end: time, to: value});\n },\n /** Ramp through `[target, ms]` pairs from `time`; returns when it ends. */\n ramp(pairs: readonly (readonly [number, number])[], time: number) {\n let start = time, from = valueAt(time);\n node.offset.cancelScheduledValues(time);\n node.offset.setValueAtTime(from, time);\n segments.splice(0, segments.length);\n for (const [target, ms] of pairs) {\n const end = start + Math.max(0, ms) / 1000;\n if (end > start) node.offset.linearRampToValueAtTime(target, end); else node.offset.setValueAtTime(target, end);\n segments.push({start, from, end, to: target});\n start = end; from = target;\n }\n return start;\n },\n when: (time?: number) => Math.max(audio.currentTime, time ?? audio.currentTime),\n current: () => valueAt(audio.currentTime),\n dispose() { try { node.stop(); } catch { /* Already stopped. */ } node.disconnect(); },\n };\n}\n\nexport interface ControlSourceOptions extends GraphModuleOptions {\n /** The value it starts at. Default 0. */\n readonly value?: number;\n}\n\n/** A control signal that jumps to each number it receives, on that message's sample. Needs a context. */\nexport class ControlSource extends GraphModule {\n static readonly type = 'webmusic.control-source';\n readonly inputs = {value: this.input('value', 'value', value => { const number = numberOf(value); if (number !== undefined) this.set(number, value.time); })};\n readonly #output: ReturnType<typeof constantControl>;\n #last: number;\n\n constructor(options: ControlSourceOptions = {}) {\n super(ControlSource.type, options);\n this.#last = finite(options.value) ? options.value : 0;\n this.#output = constantControl(this.audio(), this.#last);\n this.addPort(undefined, {id: 'output', label: 'signal', kind: 'control', direction: 'output'});\n }\n\n override get control(): ControlSignal { return this.#output.control; }\n /** The last value it was set to. */\n get value(): number { return this.#last; }\n /** Jump to `value` at `time` (now by default). */\n set(value: number, time?: number): void { this.#last = value; this.#output.set(value, this.#output.when(time)); }\n exportOptions(): ModuleOptionsJson { return {value: this.#last}; }\n protected override onDispose(): void { this.#output.dispose(); }\n}\n\n/** A control signal that ramps through targets, then sends a bang. Needs a context. */\nexport class ControlRamp extends GraphModule {\n static readonly type = 'webmusic.control-ramp';\n readonly inputs = {target: this.input('target', 'target, or target and time (ms) pairs', value => {\n const numbers = atomsOf(value).filter(isNumberAtom).map(atom => atom.value);\n if (value.selector === 'stop') { this.stop(value.time); return; }\n if (!numbers.length) return;\n if (numbers.length === 1) { this.#output.set(numbers[0]!, this.#output.when(value.time)); return; }\n const pairs: [number, number][] = [];\n for (let index = 0; index + 1 < numbers.length; index += 2) pairs.push([numbers[index]!, numbers[index + 1]!]);\n this.ramp(pairs, value.time);\n })};\n readonly outputs = {done: this.output('done', 'bang at the end')};\n readonly #output: ReturnType<typeof constantControl>;\n #cancel?: () => void;\n\n constructor(options: ControlSourceOptions = {}) {\n super(ControlRamp.type, options);\n this.#output = constantControl(this.audio(), finite(options.value) ? options.value : 0);\n this.addPort(undefined, {id: 'output', label: 'signal', kind: 'control', direction: 'output'});\n }\n\n override get control(): ControlSignal { return this.#output.control; }\n /** The value the signal has now. */\n get value(): number { return this.#output.current(); }\n /** Ramp through `[target, milliseconds]` pairs from `time` (now by default). */\n ramp(pairs: readonly (readonly [number, number])[], time?: number): void {\n const end = this.#output.ramp(pairs, this.#output.when(time));\n this.#cancel?.();\n this.#cancel = this.clock.schedule(end, when => { this.#cancel = undefined; this.outputs.done.send(bang(when)); });\n }\n /** Hold the value the signal has at `time` (now by default). */\n stop(time?: number): void { this.#output.set(this.#output.current(), this.#output.when(time)); this.#cancel?.(); }\n exportOptions(): ModuleOptionsJson { return {value: this.#output.current()}; }\n protected override onDispose(): void { this.#cancel?.(); this.#output.dispose(); }\n}\n\n// --- the Session's musical time ---------------------------------------------------------\n\n/** On a bang, the Session's position as `bar beat tick`, its tempo, its seconds and whether it plays. */\nexport class TransportReadout extends GraphModule {\n static readonly type = 'webmusic.transport-readout';\n readonly inputs = {trigger: this.input('trigger', 'bang reports the position', value => { if (value.selector === 'bang') this.report(value.time); })};\n readonly outputs = {\n position: this.output('position', 'bar beat tick'),\n tempo: this.output('tempo', 'tempo (bpm)'),\n seconds: this.output('seconds', 'position (seconds)'),\n playing: this.output('playing', 'playing (0 or 1)'),\n };\n constructor(options: GraphModuleOptions = {}) { super(TransportReadout.type, options); }\n /** Send the four readings, last output first. Without a Session it sends nothing. */\n report(time?: number): void {\n const musical = this.musicalTime;\n if (!musical) return;\n const position = musical.barsBeatsTicks();\n this.outputs.playing.send(message('int', [intAtom(musical.playing() ? 1 : 0)], time));\n this.outputs.seconds.send(message('float', [floatAtom(musical.position())], time));\n this.outputs.tempo.send(message('float', [floatAtom(musical.tempo().bpm)], time));\n this.outputs.position.send(message('list', [intAtom(position.bar), intAtom(position.beat), intAtom(position.tick)], time));\n }\n exportOptions(): ModuleOptionsJson { return {}; }\n}\n\n// --- gamepad and HID ------------------------------------------------------------------\n\nexport interface GamepadSourceOptions extends GraphModuleOptions {\n /** Which gamepad. Default 0. */\n readonly index?: number;\n}\n\n/** While active, each change of a gamepad's button or axis as `button i value` or `axis i value`. */\nexport class GamepadSource extends GraphModule {\n static readonly type = 'webmusic.gamepad';\n readonly inputs = {trigger: this.input('trigger', 'bang reports every button and axis', value => { if (value.selector === 'bang') this.report(true); })};\n readonly outputs = {events: this.output('events', 'button i value, axis i value')};\n readonly index: number;\n #previous: {buttons: number[]; axes: number[]} = {buttons: [], axes: []};\n #timer?: ReturnType<typeof setInterval>;\n\n constructor(options: GamepadSourceOptions = {}) {\n super(GamepadSource.type, options);\n this.index = finite(options.index) ? Math.trunc(options.index) : 0;\n }\n\n /** Send what changed since the last report, or every button and axis with `all`. */\n report(all = false): void {\n const pads = typeof navigator !== 'undefined' && typeof navigator.getGamepads === 'function' ? navigator.getGamepads() : [];\n const pad = pads[this.index];\n if (!pad) return;\n const current = {buttons: pad.buttons.map(button => button.value), axes: [...pad.axes]};\n const {events} = this.outputs;\n current.buttons.forEach((value, i) => { if (all || this.#previous.buttons[i] !== value) events.send(message('button', [intAtom(i), floatAtom(value)])); });\n current.axes.forEach((value, i) => { if (all || Math.abs((this.#previous.axes[i] ?? 0) - value) > 0.002) events.send(message('axis', [intAtom(i), floatAtom(value)])); });\n this.#previous = current;\n }\n exportOptions(): ModuleOptionsJson { return {index: this.index}; }\n protected override onActivate(): void { this.#timer = setInterval(() => this.guard(() => this.report(false)), 16); }\n protected override onDispose(): void { if (this.#timer) clearInterval(this.#timer); }\n}\n\ninterface HidDeviceLike {\n readonly opened: boolean;\n readonly productName: string;\n open(): Promise<void>;\n close(): Promise<void>;\n addEventListener(type: 'inputreport', listener: (event: {reportId: number; data: DataView}) => void): void;\n removeEventListener(type: 'inputreport', listener: (event: {reportId: number; data: DataView}) => void): void;\n}\n\n/** A HID device the user chooses: each input report as `report id bytes…`. */\nexport class HidSource extends GraphModule {\n static readonly type = 'webmusic.hid';\n readonly inputs = {control: this.input('control', 'open, close', value => {\n if (value.selector === 'open') void this.open().catch(error => this.fail(error));\n else if (value.selector === 'close') this.close();\n })};\n readonly outputs = {reports: this.output('reports', 'report id bytes…'), device: this.output('device', 'device name')};\n #device?: HidDeviceLike;\n constructor(options: GraphModuleOptions = {}) { super(HidSource.type, options); }\n\n /** Ask the browser for a device and listen to it. Call it from a click, as the browser requires. */\n async open(): Promise<void> {\n const api = (globalThis.navigator as unknown as {hid?: {requestDevice(options: {filters: object[]}): Promise<HidDeviceLike[]>}} | undefined)?.hid;\n if (!api) throw new Error('This browser has no WebHID.');\n const [chosen] = await api.requestDevice({filters: []});\n if (!chosen || this.disposed) return;\n this.close();\n if (!chosen.opened) await chosen.open();\n this.#device = chosen;\n chosen.addEventListener('inputreport', this.#report);\n this.outputs.device.send(message('symbol', [symbolAtom(chosen.productName || 'HID device')]));\n }\n /** Release the device. */\n close(): void {\n const device = this.#device;\n if (!device) return;\n device.removeEventListener('inputreport', this.#report);\n void device.close().catch(error => this.fail(error));\n this.#device = undefined;\n }\n exportOptions(): ModuleOptionsJson { return {}; }\n protected override onDispose(): void { this.close(); }\n #report = (event: {reportId: number; data: DataView}): void => {\n const bytes = Array.from({length: event.data.byteLength}, (_, i) => intAtom(event.data.getUint8(i)));\n this.outputs.reports.send(message('report', [intAtom(event.reportId), ...bytes]));\n };\n}\n\n// --- OSC over a WebSocket -------------------------------------------------------------\n\n/** A message from an OSC packet: the address is the selector. A bundle gives one message per element. */\nexport function fromOsc(packet: OscPacket): Message[] {\n if (isOscBundle(packet)) return packet.elements.flatMap(fromOsc);\n const atoms = packet.args.flatMap((arg): Atom[] => {\n switch (arg.type) {\n case 'i': return [intAtom(arg.value)];\n case 'f': return [floatAtom(arg.value)];\n case 's': return [symbolAtom(arg.value)];\n case 'T': return [intAtom(1)];\n case 'F': return [intAtom(0)];\n default: return [];\n }\n });\n return [message(packet.address, atoms)];\n}\n\n/** An OSC message from a message whose selector is an address. */\nexport function toOsc(value: Message): OscPacket | undefined {\n if (!value.selector.startsWith('/')) return undefined;\n const args = value.atoms.flatMap((atom): OscArgument[] => {\n if (atom.type === 'int') return [{type: 'i', value: atom.value}];\n if (atom.type === 'float') return [{type: 'f', value: atom.value}];\n if (atom.type === 'symbol') return [{type: 's', value: atom.value}];\n return [];\n });\n return {address: value.selector, args};\n}\n\nexport interface OscOptions extends GraphModuleOptions {\n /** The WebSocket address of an OSC bridge: `ws://` or `wss://`. */\n readonly url: string;\n}\n\nfunction bridgeUrl(name: string, url: unknown): string {\n if (typeof url !== 'string' || !url) throw new TypeError(`${name} needs a ws:// or wss:// bridge address.`);\n return url;\n}\n\n/** A WebSocket carrying binary OSC packets; it reconnects until closed. */\nfunction oscSocket(url: string, onPacket: ((packet: OscPacket) => void) | undefined, onStatus: (status: string) => void, fail: (error: unknown) => void) {\n if (typeof WebSocket === 'undefined') throw new Error('This environment has no WebSocket.');\n if (!/^wss?:\\/\\//.test(url)) throw new Error('An OSC bridge address starts with ws:// or wss://.');\n let socket: WebSocket | undefined;\n let closed = false;\n let retry: ReturnType<typeof setTimeout> | undefined;\n const connect = () => {\n if (closed) return;\n socket = new WebSocket(url);\n socket.binaryType = 'arraybuffer';\n socket.onopen = () => onStatus('open');\n socket.onclose = () => { onStatus('closed'); if (!closed) retry = setTimeout(connect, 2000); };\n socket.onerror = () => onStatus('error');\n socket.onmessage = event => {\n if (!onPacket || !(event.data instanceof ArrayBuffer)) return;\n try { onPacket(decodeOsc(event.data)); } catch (error) { fail(error); }\n };\n };\n connect();\n return {\n send(packet: OscPacket) { if (socket?.readyState === 1) socket.send(encodeOsc(packet)); },\n close() { closed = true; if (retry) clearTimeout(retry); socket?.close(); },\n };\n}\n\n/** While active, each OSC message arriving through a bridge, as a message named by its address. */\nexport class OscSource extends GraphModule {\n static readonly type = 'webmusic.osc-in';\n readonly outputs = {messages: this.output('messages', '/address arguments…'), status: this.output('status', 'connection: open, closed, error')};\n readonly url: string;\n #socket?: ReturnType<typeof oscSocket>;\n constructor(options: OscOptions) {\n super(OscSource.type, options);\n this.url = bridgeUrl('An OSC source', options?.url);\n }\n exportOptions(): ModuleOptionsJson { return {url: this.url}; }\n protected override onActivate(): void {\n this.#socket = oscSocket(this.url, packet => { for (const value of fromOsc(packet)) this.outputs.messages.send(value); },\n status => this.outputs.status.send(message('symbol', [symbolAtom(status)])), error => this.fail(error));\n }\n protected override onDispose(): void { this.#socket?.close(); }\n}\n\n/** While active, sends each message named by an address through a bridge as OSC. */\nexport class OscSink extends GraphModule {\n static readonly type = 'webmusic.osc-out';\n readonly inputs = {messages: this.input('messages', '/address arguments…', value => this.send(value))};\n readonly outputs = {status: this.output('status', 'connection: open, closed, error')};\n readonly url: string;\n #socket?: ReturnType<typeof oscSocket>;\n constructor(options: OscOptions) {\n super(OscSink.type, options);\n this.url = bridgeUrl('An OSC sink', options?.url);\n }\n /** Send one message; one whose selector is not an address is dropped. */\n send(value: Message): void { const packet = toOsc(value); if (packet) this.#socket?.send(packet); }\n exportOptions(): ModuleOptionsJson { return {url: this.url}; }\n protected override onActivate(): void {\n this.#socket = oscSocket(this.url, undefined, status => this.outputs.status.send(message('symbol', [symbolAtom(status)])), error => this.fail(error));\n }\n protected override onDispose(): void { this.#socket?.close(); }\n}\n","// User scripts in a Worker (DEC-078), as Max's js and its patcher\n// scripting: code runs on its own thread with no DOM and no page state, and\n// reaches the host only through messages and the functions the host offers.\n//\n// Scope of the isolation: a script cannot see or change the page, Studio or\n// the audio graph except through what it is given, and an endless loop stalls\n// only its own thread. `fetch`, `XMLHttpRequest`, `WebSocket`, `EventSource`\n// and `importScripts` are removed as a convenience, but a dynamic `import()`\n// still reaches the network: this is not a security boundary for code you do\n// not trust.\n//\n// Ownership: a sandbox owns its Worker and Blob URL and terminates both on\n// `terminate()`. Pending calls reject then.\n\nimport {floatAtom, intAtom, message, symbolAtom, type Atom, type Message} from '../module/message';\n\n/** The part of a Worker a sandbox uses; injectable for tests. */\nexport interface ScriptWorkerLike {\n onmessage: ((event: {data: unknown}) => void) | null;\n onerror: ((event: {message?: string}) => void) | null;\n postMessage(data: unknown): void;\n terminate(): void;\n}\n\nexport interface ScriptSandboxOptions {\n /** Host functions the script may call as `<namespace>.<name>(...args)`; each returns a value or a promise. Arguments and results are structured-cloned. */\n readonly api?: Readonly<Record<string, (...args: never[]) => unknown>>;\n /** The global name of `api` in the script. Defaults to `host`. */\n readonly namespace?: string;\n /** Receives `post(...)` output from the script. */\n readonly onPost?: (text: string) => void;\n /** Receives `outlet(index, ...values)` from the script. */\n readonly onOutlet?: (index: number, values: readonly unknown[]) => void;\n /** Receives errors thrown by the script outside a call. */\n readonly onError?: (error: Error) => void;\n /** Create the worker from the prelude's source text. Defaults to a module-less Worker from a Blob URL. */\n readonly createWorker?: (source: string) => ScriptWorkerLike;\n}\n\n/** The source the Worker runs first. Exported for tests that run it elsewhere. */\nexport const SCRIPT_PRELUDE = String.raw`\n'use strict';\nfor (const name of ['fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource', 'importScripts']) {\n try { Object.defineProperty(self, name, {value: undefined, configurable: false, writable: false}); } catch {}\n}\nconst pending = new Map();\nlet nextCall = 0;\nconst format = value => {\n if (typeof value === 'string') return value;\n try { const text = JSON.stringify(value); return text === undefined ? String(value) : text; } catch { return String(value); }\n};\nconst post = (...values) => postMessage({type: 'post', text: values.map(format).join(' ')});\nconst outlet = (index, ...values) => postMessage({type: 'outlet', index, values: JSON.parse(JSON.stringify(values))});\nconst hostCall = (name, args) => new Promise((resolve, reject) => {\n const id = ++nextCall;\n pending.set(id, {resolve, reject});\n postMessage({type: 'host', id, name, args});\n});\nlet program;\n// Input with await runs in an async function, as a browser console does:\n// top-level declarations become globals so later input sees them, and the\n// last statement's value is returned when it is an expression.\nconst evaluateAsync = code => {\n const body = code.replace(/(^|[;\\n{}])(\\s*)(?:var|let|const)\\s+([A-Za-z_$][\\w$]*)\\s*=/g, '$1$2globalThis.$3 =').trim().replace(/;+\\s*$/, '');\n const cut = body.lastIndexOf(';');\n const head = body.slice(0, cut + 1), tail = body.slice(cut + 1);\n const statement = /^\\s*(if|for|while|do|switch|try|return|throw|function|class|async\\s+function)\\b|^\\s*[{}]?\\s*$/.test(tail);\n if (!statement) {\n try { return (0, eval)('(async () => {\\n' + head + '\\nreturn (' + tail + '\\n);\\n})()'); }\n catch (error) { if (!(error instanceof SyntaxError)) throw error; }\n }\n return (0, eval)('(async () => {\\n' + body + '\\n})()');\n};\nself.post = post;\nself.outlet = outlet;\nconst fail = (id, error) => postMessage({type: 'result', id, error: {name: error && error.name || 'Error', message: error && error.message || String(error)}});\nself.onmessage = async ({data}) => {\n if (data.type === 'setup') {\n const space = {};\n for (const name of data.api) space[name] = (...args) => hostCall(name, args);\n self[data.namespace] = Object.freeze(space);\n return;\n }\n if (data.type === 'reply') {\n const call = pending.get(data.id);\n if (!call) return;\n pending.delete(data.id);\n if (data.error) call.reject(Object.assign(new Error(data.error.message), {name: data.error.name}));\n else call.resolve(data.value);\n return;\n }\n try {\n if (data.type === 'load') {\n program = new Function('outlet', 'post', 'let inlet = 0, messagename = \"\";\\n' + data.code +\n '\\n;return {enter(index, name) { inlet = index; messagename = name; },' +\n ' find(name) { return /^[A-Za-z_$][\\\\w$]*$/.test(name) ? eval(\"typeof \" + name + \" === \\\\\"function\\\\\" ? \" + name + \" : undefined\") : undefined; }};')(outlet, post);\n postMessage({type: 'result', id: data.id, value: null});\n } else if (data.type === 'message') {\n if (!program) return;\n const {inlet, selector, values} = data;\n const named = selector === 'int' ? 'msg_int' : selector === 'float' ? 'msg_float' : selector;\n program.enter(inlet, selector);\n const direct = program.find(named);\n if (direct) { await direct(...values); return; }\n const anything = program.find('anything');\n if (anything) await anything(selector, ...values);\n } else if (data.type === 'eval') {\n const run = /\\bawait\\b/.test(data.code) ? evaluateAsync(data.code) : (0, eval)(data.code);\n const value = await run;\n postMessage({type: 'result', id: data.id, value: value === undefined ? null : JSON.parse(JSON.stringify(value) ?? 'null'), text: value === undefined ? 'undefined' : format(value)});\n }\n } catch (error) {\n if (data.id !== undefined) fail(data.id, error);\n else postMessage({type: 'error', error: {name: error && error.name || 'Error', message: error && error.message || String(error)}});\n }\n};\n`;\n\nfunction defaultWorker(source: string): ScriptWorkerLike {\n if (typeof Worker === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined') throw new Error('Scripts need Web Workers.');\n const url = URL.createObjectURL(new Blob([source], {type: 'text/javascript'}));\n const worker = new Worker(url);\n // The worker has read its source; the URL is not needed again.\n URL.revokeObjectURL(url);\n return worker as unknown as ScriptWorkerLike;\n}\n\nconst toError = (error: {name?: string; message?: string} | undefined) => Object.assign(new Error(error?.message ?? 'Script error'), {name: error?.name ?? 'Error'});\n\n/** One user script on its own thread. */\nexport class ScriptSandbox {\n readonly #worker: ScriptWorkerLike;\n readonly #options: ScriptSandboxOptions;\n readonly #calls = new Map<number, {resolve(value: {value: unknown; text?: string}): void; reject(error: Error): void}>();\n #next = 0;\n #terminated = false;\n\n constructor(options: ScriptSandboxOptions = {}) {\n this.#options = options;\n this.#worker = (options.createWorker ?? defaultWorker)(SCRIPT_PRELUDE);\n this.#worker.onmessage = event => this.#receive(event.data as Record<string, unknown>);\n this.#worker.onerror = event => options.onError?.(new Error(event.message ?? 'Script error'));\n const api = options.api ?? {};\n this.#worker.postMessage({type: 'setup', namespace: options.namespace ?? 'host', api: Object.keys(api)});\n }\n\n get terminated(): boolean { return this.#terminated; }\n\n /** Compile `code` as a module script; rejects with its syntax or top-level error. */\n async load(code: string): Promise<void> { await this.#request({type: 'load', code}); }\n\n /** Run REPL input in the script's global scope; resolves with the value and its printed form. `await` makes it async. */\n async evaluate(code: string): Promise<{value: unknown; text: string}> {\n const result = await this.#request({type: 'eval', code});\n return {value: result.value, text: result.text ?? 'undefined'};\n }\n\n /** Hand a message to the loaded script's handler; fire and forget. */\n deliver(inlet: number, value: Message): void {\n if (this.#terminated) return;\n this.#worker.postMessage({type: 'message', inlet, selector: value.selector, values: value.atoms.map(atom => atom.value)});\n }\n\n terminate(): void {\n if (this.#terminated) return;\n this.#terminated = true;\n this.#worker.onmessage = null;\n this.#worker.onerror = null;\n this.#worker.terminate();\n for (const call of this.#calls.values()) call.reject(new Error('The script was stopped.'));\n this.#calls.clear();\n }\n\n #request(data: Record<string, unknown>): Promise<{value: unknown; text?: string}> {\n if (this.#terminated) return Promise.reject(new Error('The script was stopped.'));\n const id = ++this.#next;\n return new Promise((resolve, reject) => {\n this.#calls.set(id, {resolve, reject});\n this.#worker.postMessage({...data, id});\n });\n }\n\n #receive(data: Record<string, unknown>): void {\n if (this.#terminated || !data || typeof data !== 'object') return;\n switch (data.type) {\n case 'post': this.#options.onPost?.(String(data.text)); return;\n case 'outlet': this.#options.onOutlet?.(Number(data.index), Array.isArray(data.values) ? data.values : []); return;\n case 'error': this.#options.onError?.(toError(data.error as never)); return;\n case 'result': {\n const call = this.#calls.get(Number(data.id));\n if (!call) return;\n this.#calls.delete(Number(data.id));\n if (data.error) call.reject(toError(data.error as never));\n else call.resolve({value: data.value, text: typeof data.text === 'string' ? data.text : undefined});\n return;\n }\n case 'host': void this.#host(Number(data.id), String(data.name), Array.isArray(data.args) ? data.args : []);\n }\n }\n\n async #host(id: number, name: string, args: unknown[]): Promise<void> {\n const fn = this.#options.api?.[name];\n try {\n if (!fn) throw new Error(`No host function ${name}.`);\n const value = await fn(...(args as never[]));\n if (!this.#terminated) this.#worker.postMessage({type: 'reply', id, value: value === undefined ? null : value});\n } catch (error) {\n if (!this.#terminated) this.#worker.postMessage({type: 'reply', id, error: {name: error instanceof Error ? error.name : 'Error', message: error instanceof Error ? error.message : String(error)}});\n }\n }\n}\n\n/** A script value as an atom: integers stay ints, other numbers floats, strings symbols. */\nexport function scriptAtom(value: unknown): Atom {\n if (typeof value === 'number') return Number.isInteger(value) ? intAtom(value) : floatAtom(value);\n if (typeof value === 'string') return symbolAtom(value);\n if (typeof value === 'boolean') return intAtom(value ? 1 : 0);\n if (Array.isArray(value)) return {type: 'array', value: value as never} as Atom;\n return {type: 'dict', value: (value ?? null) as never} as Atom;\n}\n\n/** Values from `outlet(...)` as a message: one number or symbol, a leading word as selector, else a list. */\nexport function scriptMessage(values: readonly unknown[]): Message {\n if (!values.length) return message('bang');\n const atoms = values.map(scriptAtom);\n const [first, ...rest] = atoms;\n if (atoms.length === 1) return message(first!.type === 'int' ? 'int' : first!.type === 'float' ? 'float' : first!.type === 'symbol' ? 'symbol' : 'list', atoms);\n if (first!.type === 'symbol') return message((first as {value: string}).value, rest);\n return message('list', atoms);\n}\n","// A script as a module (DEC-078, DEC-097): user code in a ScriptSandbox, with\n// message inputs and outputs. A message at input i calls the function named\n// by its selector (`bang`, `msg_int`, `msg_float`, `list`, or any word), else\n// `anything(selector, …values)`, with `inlet` and `messagename` set. The\n// script sends with `outlet(index, …values)` and writes with `post(…)`.\n// Outputs arrive asynchronously and untimed.\n//\n// Ownership: the module owns its sandbox and terminates it on dispose.\n\nimport type {Message, MessageInputPort, MessageOutputPort} from '../module/message';\nimport {GraphModule, numberedPort, type GraphModuleOptions, type ModuleOptionsJson} from '../module/graph-module';\nimport {ScriptSandbox, scriptMessage, type ScriptWorkerLike} from './script';\n\nexport interface ScriptModuleOptions extends GraphModuleOptions {\n /** How many inputs, 1 to 16. Default 1. */\n readonly inputs?: number;\n /** How many outputs, 1 to 16. Default 1. */\n readonly outputs?: number;\n /** The script's source. Default: a `bang` function that sends a bang. */\n readonly code?: string;\n /** Creates the Worker from the sandbox's source text. Defaults to a Worker from a Blob URL. */\n readonly createWorker?: (source: string) => ScriptWorkerLike;\n /** Receives `post(…)` output. Defaults to `console.log`. */\n readonly print?: (text: string) => void;\n}\n\nconst DEFAULT_CODE = 'function bang() { outlet(0, \"bang\"); }';\nconst count = (value: unknown, fallback: number) => typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= 16 ? value : fallback;\n\n/** One user script on its own thread, between message ports. */\nexport class ScriptModule extends GraphModule {\n static readonly type = 'webmusic.script';\n /** `in0`, `in1`…. */\n readonly inputs: Readonly<Record<string, MessageInputPort>>;\n /** `out0`, `out1`…. */\n readonly outputs: Readonly<Record<string, MessageOutputPort>>;\n readonly code: string;\n readonly #counts: {inputs: number; outputs: number};\n #sandbox?: ScriptSandbox;\n\n constructor(options: ScriptModuleOptions = {}) {\n super(ScriptModule.type, options);\n this.code = typeof options.code === 'string' ? options.code : DEFAULT_CODE;\n this.#counts = {inputs: count(options.inputs, 1), outputs: count(options.outputs, 1)};\n const inputs = Array.from({length: this.#counts.inputs}, (_, index) =>\n this.input(numberedPort('in', index), `messages to the script, inlet ${index}`, value => this.deliver(index, value)));\n const outputs = Array.from({length: this.#counts.outputs}, (_, index) => this.output(numberedPort('out', index), `outlet ${index}`));\n this.inputs = Object.freeze(Object.fromEntries(inputs.map(port => [port.id, port])));\n this.outputs = Object.freeze(Object.fromEntries(outputs.map(port => [port.id, port])));\n try {\n this.#sandbox = new ScriptSandbox({\n createWorker: options.createWorker,\n onPost: text => { if (options.print) options.print(text); else console.log(`js: ${text}`); },\n onOutlet: (index, values) => { if (!this.disposed && Number.isInteger(index) && index >= 0 && index < outputs.length) outputs[index]!.send(scriptMessage(values)); },\n onError: error => this.fail(error),\n });\n this.#sandbox.load(this.code).catch(error => this.fail(error));\n } catch (error) { this.fail(error); }\n }\n\n /** Hand a message to the script's handler for input `index`. */\n deliver(index: number, value: Message): void { this.#sandbox?.deliver(index, value); }\n exportOptions(): ModuleOptionsJson { return {inputs: this.#counts.inputs, outputs: this.#counts.outputs, code: this.code}; }\n protected override onDispose(): void { this.#sandbox?.terminate(); }\n}\n","// The restore registrations of the message modules (DEC-097): one project\n// plugin per module type, each constructing its class or function module\n// from a record's options.\n\nimport {modulePlugin, type ModuleEnvironment} from '../module/module-plugin';\nimport type {ProjectPluginFactory} from '../module/project-types';\nimport {MESSAGE_FUNCTIONS, FunctionModule, type MessageFunction} from './functions';\nimport {ScriptModule, type ScriptModuleOptions} from './script-module';\nimport {ControlRamp, ControlSource, GamepadSource, HidSource, OscSink, OscSource, TransportReadout} from './sources';\nimport {Counter, Delay, Gate, Line, LoadBang, Metro, Pipe, Switch} from './timers';\nimport {Button, Choice, Matrix, MessageBox, NumberValue, Toggle, ValueList} from './values';\n\n/**\n * Project plugins for every message module: the functions, timers and\n * counters, values with a control, control sources, the script module and the\n * device, network and Session sources. They share one environment.\n */\nexport function createMessagePlugins(environment: ModuleEnvironment = {}): readonly ProjectPluginFactory[] {\n const classes = [LoadBang, Metro, Delay, Pipe, Line, Counter, Gate, Switch, ControlSource, ControlRamp,\n Button, Toggle, NumberValue, Choice, MessageBox, ValueList, Matrix, TransportReadout, GamepadSource, HidSource, OscSource, OscSink] as const;\n return Object.freeze([\n ...(MESSAGE_FUNCTIONS as readonly MessageFunction<object>[]).map(fn => modulePlugin<object>(fn.module.type, (options, request) => new FunctionModule(fn, {\n ...options, options,\n ...(environment.random ? {random: environment.random} : {}),\n ...(environment.print ? {print: (name: string, text: string) => environment.print!(name, text, request.record.id)} : {}),\n }), environment)),\n ...classes.map(Type => modulePlugin<object>(Type.type, options => new Type(options as never), environment)),\n modulePlugin<ScriptModuleOptions>(ScriptModule.type, (options, request) => new ScriptModule({\n ...options,\n ...(environment.createScriptWorker ? {createWorker: environment.createScriptWorker} : {}),\n ...(environment.print ? {print: (text: string) => environment.print!('js', text, request.record.id)} : {}),\n }), environment),\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,YAAsH;AAAA,EAC1H,KAAK,EAAC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,EAAC,OAAO,KAAK,IAAI,EAAG,KAAK,GAAG,OAAO,EAAG,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AoC;AACzG,QAAM,UAAU;AAAA,IAAC;AAAA,IAAU;AAAA,IAAO;AAAA,IAAO;AAAA,IAAM;AAAA,IAAM;AAAA,IAAS;AAAA,IAAM;AAAA,IAAQ;AAAA,IAAe;AAAA,IACzF;AAAA,IAAQ;AAAA,IAAQ;AAAA,IAAa;AAAA,IAAQ;AAAA,IAAY;AAAA,IAAW;AAAA,IAAQ;AAAA,IAAkB;AAAA,IAAe;AAAA,IAAW;AAAA,IAAW;AAAA,EAAO;AACpI,SAAO,OAAO,OAAO;AAAA,IACnB,GAAI,kBAAyD,IAAI,QAAM,aAAqB,GAAG,OAAO,MAAM,CAAC,SAAS,YAAY,IAAI,eAAe,IAAI;AAAA,MACvJ,GAAG;AAAA,MAAS;AAAA,MACZ,GAAI,YAAY,SAAS,EAAC,QAAQ,YAAY,OAAM,IAAI,CAAC;AAAA,MACzD,GAAI,YAAY,QAAQ,EAAC,OAAO,CAAC,MAAc,SAAiB,YAAY,MAAO,MAAM,MAAM,QAAQ,OAAO,EAAE,EAAC,IAAI,CAAC;AAAA,IACxH,CAAC,GAAG,WAAW,CAAC;AAAA,IAChB,GAAG,QAAQ,IAAI,UAAQ,aAAqB,KAAK,MAAM,aAAW,IAAI,KAAK,OAAgB,GAAG,WAAW,CAAC;AAAA,IAC1G,aAAkC,aAAa,MAAM,CAAC,SAAS,YAAY,IAAI,aAAa;AAAA,MAC1F,GAAG;AAAA,MACH,GAAI,YAAY,qBAAqB,EAAC,cAAc,YAAY,mBAAkB,IAAI,CAAC;AAAA,MACvF,GAAI,YAAY,QAAQ,EAAC,OAAO,CAAC,SAAiB,YAAY,MAAO,MAAM,MAAM,QAAQ,OAAO,EAAE,EAAC,IAAI,CAAC;AAAA,IAC1G,CAAC,GAAG,WAAW;AAAA,EACjB,CAAC;AACH;","names":["random","port","scale","select","route","_index","trigger","pack","values","unpack","expr","random","print","finite","_cancel","_time","_authored","port","_count","_open","clamp_fn","finite","clamp_fn","values","send_fn","count","row","column","finite","_output","_cancel","_socket","_options","_next","values","count","port","values"]}
|