@webmusic/kernel 0.1.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.
Files changed (197) hide show
  1. package/LICENSE +202 -21
  2. package/NOTICE +2 -0
  3. package/README.md +138 -101
  4. package/dist/audio-context.cjs.map +1 -1
  5. package/dist/build-receipt.json +3 -3
  6. package/dist/chunk-27LH6QLZ.cjs +277 -0
  7. package/dist/chunk-27LH6QLZ.cjs.map +1 -0
  8. package/dist/chunk-3INDOVUC.cjs.map +1 -1
  9. package/dist/chunk-3RR2VIKA.js +393 -0
  10. package/dist/chunk-3RR2VIKA.js.map +1 -0
  11. package/dist/chunk-3YTKIKKX.cjs +378 -0
  12. package/dist/chunk-3YTKIKKX.cjs.map +1 -0
  13. package/dist/chunk-4RG4WQKC.js +360 -0
  14. package/dist/chunk-4RG4WQKC.js.map +1 -0
  15. package/dist/chunk-5AHVQXTF.cjs +620 -0
  16. package/dist/chunk-5AHVQXTF.cjs.map +1 -0
  17. package/dist/chunk-624KWJWZ.js +170 -0
  18. package/dist/chunk-624KWJWZ.js.map +1 -0
  19. package/dist/chunk-6HGFEKD3.cjs +851 -0
  20. package/dist/chunk-6HGFEKD3.cjs.map +1 -0
  21. package/dist/chunk-7ZTZZ5PN.cjs.map +1 -1
  22. package/dist/chunk-ALWV4P7D.js +726 -0
  23. package/dist/chunk-ALWV4P7D.js.map +1 -0
  24. package/dist/chunk-BADJJ6DV.cjs +143 -0
  25. package/dist/chunk-BADJJ6DV.cjs.map +1 -0
  26. package/dist/chunk-C3LMS36L.cjs +393 -0
  27. package/dist/chunk-C3LMS36L.cjs.map +1 -0
  28. package/dist/chunk-C3YWUZW3.cjs.map +1 -1
  29. package/dist/chunk-CR6OUWBJ.cjs +726 -0
  30. package/dist/chunk-CR6OUWBJ.cjs.map +1 -0
  31. package/dist/chunk-CYWDZLWC.js +2141 -0
  32. package/dist/chunk-CYWDZLWC.js.map +1 -0
  33. package/dist/chunk-DDOGX2D5.js +378 -0
  34. package/dist/chunk-DDOGX2D5.js.map +1 -0
  35. package/dist/chunk-DVN6E5U3.js +620 -0
  36. package/dist/chunk-DVN6E5U3.js.map +1 -0
  37. package/dist/chunk-EURMRU2S.js +208 -0
  38. package/dist/chunk-EURMRU2S.js.map +1 -0
  39. package/dist/chunk-EXDCK2VL.cjs +20 -0
  40. package/dist/chunk-EXDCK2VL.cjs.map +1 -0
  41. package/dist/chunk-G5EIUP52.js +114 -0
  42. package/dist/chunk-G5EIUP52.js.map +1 -0
  43. package/dist/chunk-GB4DGKLZ.js +143 -0
  44. package/dist/chunk-GB4DGKLZ.js.map +1 -0
  45. package/dist/chunk-GPOEAYOW.js +2147 -0
  46. package/dist/chunk-GPOEAYOW.js.map +1 -0
  47. package/dist/chunk-I4YMA5VM.cjs +120 -0
  48. package/dist/chunk-I4YMA5VM.cjs.map +1 -0
  49. package/dist/chunk-IVWHMDCB.cjs +4383 -0
  50. package/dist/chunk-IVWHMDCB.cjs.map +1 -0
  51. package/dist/chunk-JFCBJMA7.cjs +2147 -0
  52. package/dist/chunk-JFCBJMA7.cjs.map +1 -0
  53. package/dist/chunk-JLVSAZ3K.cjs +813 -0
  54. package/dist/chunk-JLVSAZ3K.cjs.map +1 -0
  55. package/dist/chunk-K7FYH6UG.cjs +208 -0
  56. package/dist/chunk-K7FYH6UG.cjs.map +1 -0
  57. package/dist/chunk-L4MYCETM.cjs +970 -0
  58. package/dist/chunk-L4MYCETM.cjs.map +1 -0
  59. package/dist/chunk-MNCMYNYL.js +970 -0
  60. package/dist/chunk-MNCMYNYL.js.map +1 -0
  61. package/dist/chunk-NT2BZ3QM.js +120 -0
  62. package/dist/chunk-NT2BZ3QM.js.map +1 -0
  63. package/dist/chunk-O7SA5GLC.js +277 -0
  64. package/dist/chunk-O7SA5GLC.js.map +1 -0
  65. package/dist/chunk-OCKAHITL.cjs +548 -0
  66. package/dist/chunk-OCKAHITL.cjs.map +1 -0
  67. package/dist/{chunk-HOKRTYPV.js → chunk-OPBHDUZK.js} +39 -1
  68. package/dist/chunk-OPBHDUZK.js.map +1 -0
  69. package/dist/chunk-OTXYWCLA.js +206 -0
  70. package/dist/chunk-OTXYWCLA.js.map +1 -0
  71. package/dist/chunk-P6ZA63J7.js +548 -0
  72. package/dist/chunk-P6ZA63J7.js.map +1 -0
  73. package/dist/chunk-QLF3BOST.js +20 -0
  74. package/dist/chunk-QLF3BOST.js.map +1 -0
  75. package/dist/chunk-RCWFRZDR.js +4383 -0
  76. package/dist/chunk-RCWFRZDR.js.map +1 -0
  77. package/dist/chunk-RZBLPM3L.cjs +206 -0
  78. package/dist/chunk-RZBLPM3L.cjs.map +1 -0
  79. package/dist/chunk-TA3TNJZU.cjs +360 -0
  80. package/dist/chunk-TA3TNJZU.cjs.map +1 -0
  81. package/dist/chunk-TZSRPTQL.cjs +2141 -0
  82. package/dist/chunk-TZSRPTQL.cjs.map +1 -0
  83. package/dist/chunk-UMTPJ76S.cjs.map +1 -1
  84. package/dist/chunk-UY77FXDW.js +813 -0
  85. package/dist/chunk-UY77FXDW.js.map +1 -0
  86. package/dist/chunk-VFU3S7OC.js +851 -0
  87. package/dist/chunk-VFU3S7OC.js.map +1 -0
  88. package/dist/chunk-VY6WWZSW.cjs.map +1 -1
  89. package/dist/chunk-WN5DZOVT.cjs +170 -0
  90. package/dist/chunk-WN5DZOVT.cjs.map +1 -0
  91. package/dist/{chunk-HZQX4J2J.cjs → chunk-WOPW6WLR.cjs} +40 -2
  92. package/dist/chunk-WOPW6WLR.cjs.map +1 -0
  93. package/dist/chunk-XBSIYUHM.cjs +114 -0
  94. package/dist/chunk-XBSIYUHM.cjs.map +1 -0
  95. package/dist/chunk-ZMU72HJS.cjs.map +1 -1
  96. package/dist/context-DSa0ymyN.d.cts +664 -0
  97. package/dist/context-DaxfAg3b.d.ts +664 -0
  98. package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
  99. package/dist/effect-chain-Do75T7uK.d.cts +91 -0
  100. package/dist/effect.cjs +16 -1
  101. package/dist/effect.cjs.map +1 -1
  102. package/dist/effect.d.cts +56 -14
  103. package/dist/effect.d.ts +56 -14
  104. package/dist/effect.js +16 -1
  105. package/dist/elements.cjs +37 -2
  106. package/dist/elements.cjs.map +1 -1
  107. package/dist/elements.d.cts +197 -8
  108. package/dist/elements.d.ts +197 -8
  109. package/dist/elements.js +36 -1
  110. package/dist/events.cjs.map +1 -1
  111. package/dist/index.cjs +556 -9
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +17 -5
  114. package/dist/index.d.ts +17 -5
  115. package/dist/index.js +567 -20
  116. package/dist/message.cjs +104 -0
  117. package/dist/message.cjs.map +1 -0
  118. package/dist/message.d.cts +738 -0
  119. package/dist/message.d.ts +738 -0
  120. package/dist/message.js +104 -0
  121. package/dist/meter.cjs +2 -2
  122. package/dist/meter.cjs.map +1 -1
  123. package/dist/meter.d.cts +9 -1
  124. package/dist/meter.d.ts +9 -1
  125. package/dist/meter.js +1 -1
  126. package/dist/module-control-C25BMtH7.d.ts +61 -0
  127. package/dist/module-control-yH6nTJM9.d.cts +61 -0
  128. package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
  129. package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
  130. package/dist/module.cjs +263 -0
  131. package/dist/module.cjs.map +1 -0
  132. package/dist/module.d.cts +1112 -0
  133. package/dist/module.d.ts +1112 -0
  134. package/dist/module.js +263 -0
  135. package/dist/parameter-DwQzFmBR.d.cts +172 -0
  136. package/dist/parameter-DwQzFmBR.d.ts +172 -0
  137. package/dist/player.cjs.map +1 -1
  138. package/dist/processor-worklet.cjs +18 -0
  139. package/dist/processor-worklet.cjs.map +1 -0
  140. package/dist/processor-worklet.d.cts +166 -0
  141. package/dist/processor-worklet.d.ts +166 -0
  142. package/dist/processor-worklet.js +18 -0
  143. package/dist/processor-worklet.js.map +1 -0
  144. package/dist/processor.cjs +51 -0
  145. package/dist/processor.cjs.map +1 -0
  146. package/dist/processor.d.cts +397 -0
  147. package/dist/processor.d.ts +397 -0
  148. package/dist/processor.js +51 -0
  149. package/dist/processor.js.map +1 -0
  150. package/dist/project-types-BU4awMnL.d.ts +323 -0
  151. package/dist/project-types-DufCV8Ma.d.cts +323 -0
  152. package/dist/ring-C-i9N90a.d.cts +139 -0
  153. package/dist/ring-DkcMt2Eg.d.ts +139 -0
  154. package/dist/sequence.cjs +68 -0
  155. package/dist/sequence.cjs.map +1 -0
  156. package/dist/sequence.d.cts +303 -0
  157. package/dist/sequence.d.ts +303 -0
  158. package/dist/sequence.js +68 -0
  159. package/dist/sequence.js.map +1 -0
  160. package/dist/session.cjs +16 -0
  161. package/dist/session.cjs.map +1 -0
  162. package/dist/session.d.cts +407 -0
  163. package/dist/session.d.ts +407 -0
  164. package/dist/session.js +16 -0
  165. package/dist/session.js.map +1 -0
  166. package/dist/tick.cjs.map +1 -1
  167. package/dist/transport.cjs +50 -2
  168. package/dist/transport.cjs.map +1 -1
  169. package/dist/transport.d.cts +145 -1
  170. package/dist/transport.d.ts +145 -1
  171. package/dist/transport.js +51 -3
  172. package/dist/worker.cjs.map +1 -1
  173. package/package.json +62 -11
  174. package/dist/chunk-53YD73OY.js +0 -162
  175. package/dist/chunk-53YD73OY.js.map +0 -1
  176. package/dist/chunk-BR63OD53.cjs +0 -1
  177. package/dist/chunk-BR63OD53.cjs.map +0 -1
  178. package/dist/chunk-HOKRTYPV.js.map +0 -1
  179. package/dist/chunk-HZQX4J2J.cjs.map +0 -1
  180. package/dist/chunk-JNXB74G3.cjs +0 -987
  181. package/dist/chunk-JNXB74G3.cjs.map +0 -1
  182. package/dist/chunk-SM5YPDDI.cjs +0 -162
  183. package/dist/chunk-SM5YPDDI.cjs.map +0 -1
  184. package/dist/chunk-TEM2I2NN.js +0 -1
  185. package/dist/chunk-VVZX7DQ6.cjs +0 -254
  186. package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
  187. package/dist/chunk-WNFGDB7B.js +0 -254
  188. package/dist/chunk-WNFGDB7B.js.map +0 -1
  189. package/dist/chunk-XBJBY4J5.js +0 -987
  190. package/dist/chunk-XBJBY4J5.js.map +0 -1
  191. package/dist/sync.cjs +0 -12
  192. package/dist/sync.cjs.map +0 -1
  193. package/dist/sync.d.cts +0 -304
  194. package/dist/sync.d.ts +0 -304
  195. package/dist/sync.js +0 -12
  196. /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
  197. /package/dist/{sync.js.map → module.js.map} +0 -0
@@ -0,0 +1,104 @@
1
+ import {
2
+ Button,
3
+ Choice,
4
+ ControlRamp,
5
+ ControlSource,
6
+ Counter,
7
+ Delay,
8
+ FunctionModule,
9
+ GamepadSource,
10
+ Gate,
11
+ HidSource,
12
+ Line,
13
+ LoadBang,
14
+ MESSAGE_FUNCTIONS,
15
+ Matrix,
16
+ MessageBox,
17
+ Metro,
18
+ NumberValue,
19
+ OscSink,
20
+ OscSource,
21
+ Pipe,
22
+ SCRIPT_PRELUDE,
23
+ ScriptModule,
24
+ ScriptSandbox,
25
+ Switch,
26
+ Toggle,
27
+ TransportReadout,
28
+ ValueList,
29
+ atomOf,
30
+ compileExpr,
31
+ createMessagePlugins,
32
+ expr,
33
+ fromOsc,
34
+ functionModule,
35
+ numberMessage,
36
+ pack,
37
+ print,
38
+ random,
39
+ route,
40
+ scale,
41
+ scriptAtom,
42
+ scriptMessage,
43
+ seededRandom,
44
+ select,
45
+ toOsc,
46
+ trigger,
47
+ unpack
48
+ } from "./chunk-CYWDZLWC.js";
49
+ import "./chunk-624KWJWZ.js";
50
+ import "./chunk-ALWV4P7D.js";
51
+ import "./chunk-NT2BZ3QM.js";
52
+ import "./chunk-4RG4WQKC.js";
53
+ import "./chunk-GB4DGKLZ.js";
54
+ import "./chunk-QLF3BOST.js";
55
+ import "./chunk-PXG64RU4.js";
56
+ export {
57
+ Button,
58
+ Choice,
59
+ ControlRamp,
60
+ ControlSource,
61
+ Counter,
62
+ Delay,
63
+ FunctionModule,
64
+ GamepadSource,
65
+ Gate,
66
+ HidSource,
67
+ Line,
68
+ LoadBang,
69
+ MESSAGE_FUNCTIONS,
70
+ Matrix,
71
+ MessageBox,
72
+ Metro,
73
+ NumberValue,
74
+ OscSink,
75
+ OscSource,
76
+ Pipe,
77
+ SCRIPT_PRELUDE,
78
+ ScriptModule,
79
+ ScriptSandbox,
80
+ Switch,
81
+ Toggle,
82
+ TransportReadout,
83
+ ValueList,
84
+ atomOf,
85
+ compileExpr,
86
+ createMessagePlugins,
87
+ expr,
88
+ fromOsc,
89
+ functionModule,
90
+ numberMessage,
91
+ pack,
92
+ print,
93
+ random,
94
+ route,
95
+ scale,
96
+ scriptAtom,
97
+ scriptMessage,
98
+ seededRandom,
99
+ select,
100
+ toOsc,
101
+ trigger,
102
+ unpack
103
+ };
104
+ //# sourceMappingURL=message.js.map
package/dist/meter.cjs CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkHZQX4J2Jcjs = require('./chunk-HZQX4J2J.cjs');
5
+ var _chunkWOPW6WLRcjs = require('./chunk-WOPW6WLR.cjs');
6
6
  require('./chunk-7ZTZZ5PN.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.AnalyserMeter = _chunkHZQX4J2Jcjs.AnalyserMeter; exports.aggregateSpectrumBars = _chunkHZQX4J2Jcjs.aggregateSpectrumBars; exports.createAnalyserMeter = _chunkHZQX4J2Jcjs.createAnalyserMeter;
11
+ exports.AnalyserMeter = _chunkWOPW6WLRcjs.AnalyserMeter; exports.aggregateSpectrumBars = _chunkWOPW6WLRcjs.aggregateSpectrumBars; exports.createAnalyserMeter = _chunkWOPW6WLRcjs.createAnalyserMeter;
12
12
  //# sourceMappingURL=meter.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/mamingchen/GitHub/public/WebMusic/platform/kernel/dist/meter.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,sMAAC","file":"/Users/mamingchen/GitHub/public/WebMusic/platform/kernel/dist/meter.cjs"}
1
+ {"version":3,"sources":["/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/meter.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,sMAAC","file":"/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/meter.cjs"}
package/dist/meter.d.cts CHANGED
@@ -33,6 +33,8 @@ interface AnalyserMeterOptions {
33
33
  /** Floor applied to {@link AnalyserMeter.readSpectrum}'s bar count; non-finite values use 1. */
34
34
  minimumBars?: number;
35
35
  }
36
+ /** Live configuration; omitted fields retain their current values. Sources never change. */
37
+ type AnalyserMeterConfiguration = Omit<AnalyserMeterOptions, 'context' | 'analyser'>;
36
38
  /**
37
39
  * Aggregate an FFT vector into a fixed number of normalized bars. Each bar is
38
40
  * the mean of its contiguous slice. When there are at least as many bins as
@@ -58,6 +60,12 @@ declare class AnalyserMeter {
58
60
  get output(): AudioNode | undefined;
59
61
  /** Whether this meter created and owns its tap graph. */
60
62
  get ownsGraph(): boolean;
63
+ /**
64
+ * Update tuning without replacing the graph or its public input/output ports.
65
+ * Owned analyser settings are validated together and rolled back on failure;
66
+ * borrowed analysers are never reconfigured. Omitted fields stay unchanged.
67
+ */
68
+ configure(options?: AnalyserMeterConfiguration): void;
61
69
  /** Read one time-domain frame and derive its level, peak and peak hold. */
62
70
  readLevel(): AnalyserMeterFrame;
63
71
  /** Read one frequency-domain frame, aggregated into normalized bars. */
@@ -73,4 +81,4 @@ declare class AnalyserMeter {
73
81
  /** Build an {@link AnalyserMeter} (the `createX` convention). */
74
82
  declare function createAnalyserMeter(options?: AnalyserMeterOptions): AnalyserMeter;
75
83
 
76
- export { AnalyserMeter, type AnalyserMeterFrame, type AnalyserMeterOptions, type SpectrumBarOptions, aggregateSpectrumBars, createAnalyserMeter };
84
+ export { AnalyserMeter, type AnalyserMeterConfiguration, type AnalyserMeterFrame, type AnalyserMeterOptions, type SpectrumBarOptions, aggregateSpectrumBars, createAnalyserMeter };
package/dist/meter.d.ts CHANGED
@@ -33,6 +33,8 @@ interface AnalyserMeterOptions {
33
33
  /** Floor applied to {@link AnalyserMeter.readSpectrum}'s bar count; non-finite values use 1. */
34
34
  minimumBars?: number;
35
35
  }
36
+ /** Live configuration; omitted fields retain their current values. Sources never change. */
37
+ type AnalyserMeterConfiguration = Omit<AnalyserMeterOptions, 'context' | 'analyser'>;
36
38
  /**
37
39
  * Aggregate an FFT vector into a fixed number of normalized bars. Each bar is
38
40
  * the mean of its contiguous slice. When there are at least as many bins as
@@ -58,6 +60,12 @@ declare class AnalyserMeter {
58
60
  get output(): AudioNode | undefined;
59
61
  /** Whether this meter created and owns its tap graph. */
60
62
  get ownsGraph(): boolean;
63
+ /**
64
+ * Update tuning without replacing the graph or its public input/output ports.
65
+ * Owned analyser settings are validated together and rolled back on failure;
66
+ * borrowed analysers are never reconfigured. Omitted fields stay unchanged.
67
+ */
68
+ configure(options?: AnalyserMeterConfiguration): void;
61
69
  /** Read one time-domain frame and derive its level, peak and peak hold. */
62
70
  readLevel(): AnalyserMeterFrame;
63
71
  /** Read one frequency-domain frame, aggregated into normalized bars. */
@@ -73,4 +81,4 @@ declare class AnalyserMeter {
73
81
  /** Build an {@link AnalyserMeter} (the `createX` convention). */
74
82
  declare function createAnalyserMeter(options?: AnalyserMeterOptions): AnalyserMeter;
75
83
 
76
- export { AnalyserMeter, type AnalyserMeterFrame, type AnalyserMeterOptions, type SpectrumBarOptions, aggregateSpectrumBars, createAnalyserMeter };
84
+ export { AnalyserMeter, type AnalyserMeterConfiguration, type AnalyserMeterFrame, type AnalyserMeterOptions, type SpectrumBarOptions, aggregateSpectrumBars, createAnalyserMeter };
package/dist/meter.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  AnalyserMeter,
3
3
  aggregateSpectrumBars,
4
4
  createAnalyserMeter
5
- } from "./chunk-HOKRTYPV.js";
5
+ } from "./chunk-OPBHDUZK.js";
6
6
  import "./chunk-PXG64RU4.js";
7
7
  export {
8
8
  AnalyserMeter,
@@ -0,0 +1,61 @@
1
+ import { J as JsonValue, j as Message, t as ModuleCapabilities, C as CapabilityKey, w as ModuleHandle } from './context-DaxfAg3b.js';
2
+ import { G as GraphModule } from './module-plugin-BnPmq1VP.js';
3
+
4
+ /** An OSC argument: int32 (`i`), float32 (`f`), string (`s`), blob (`b`), true/false (`T`/`F`) or nil (`N`). */
5
+ type OscArgument = {
6
+ readonly type: 'i';
7
+ readonly value: number;
8
+ } | {
9
+ readonly type: 'f';
10
+ readonly value: number;
11
+ } | {
12
+ readonly type: 's';
13
+ readonly value: string;
14
+ } | {
15
+ readonly type: 'b';
16
+ readonly value: Uint8Array;
17
+ } | {
18
+ readonly type: 'T' | 'F' | 'N';
19
+ };
20
+ interface OscMessage {
21
+ readonly address: string;
22
+ readonly args: readonly OscArgument[];
23
+ }
24
+ interface OscBundle {
25
+ readonly timetag: bigint;
26
+ readonly elements: readonly (OscMessage | OscBundle)[];
27
+ }
28
+ type OscPacket = OscMessage | OscBundle;
29
+ declare const isOscBundle: (packet: OscPacket) => packet is OscBundle;
30
+ /** Encode a message or bundle. Throws for an address that does not start with `/`. */
31
+ declare function encodeOsc(packet: OscPacket): Uint8Array;
32
+ /** Decode one packet. Throws a SyntaxError for malformed bytes. */
33
+ declare function decodeOsc(input: ArrayBuffer | Uint8Array): OscPacket;
34
+
35
+ interface ModuleControl {
36
+ /** Which control shows the module, such as `toggle`, `slider` or `matrix`. */
37
+ readonly kind: string;
38
+ /** The state to draw; its shape depends on `kind` (see the Kernel reference). */
39
+ snapshot(): JsonValue;
40
+ /** Notified after every change of the snapshot. */
41
+ subscribe(listener: () => void): () => void;
42
+ /** A user action, as an untimed message into the module's first input. */
43
+ interact(message: Message): void;
44
+ }
45
+ /** The capability key under which a module offers its control. */
46
+ declare const MODULE_CONTROL: CapabilityKey<ModuleControl>;
47
+ /** Read a module's control from any module handle that offers one. */
48
+ declare function moduleControlOf(module: ModuleHandle | undefined): ModuleControl | undefined;
49
+ /** A module that shows a control: it lends its state and takes user actions. */
50
+ declare abstract class ControlModule extends GraphModule {
51
+ #private;
52
+ /** Which control shows this module. */
53
+ abstract readonly kind: string;
54
+ /** The state a presenter draws. */
55
+ abstract snapshot(): JsonValue;
56
+ /** A message at the first input. */
57
+ protected abstract receive(value: Message): void;
58
+ get capabilities(): ModuleCapabilities;
59
+ }
60
+
61
+ export { ControlModule as C, MODULE_CONTROL as M, type OscArgument as O, type ModuleControl as a, type OscBundle as b, type OscMessage as c, type OscPacket as d, decodeOsc as e, encodeOsc as f, isOscBundle as i, moduleControlOf as m };
@@ -0,0 +1,61 @@
1
+ import { J as JsonValue, j as Message, t as ModuleCapabilities, C as CapabilityKey, w as ModuleHandle } from './context-DSa0ymyN.cjs';
2
+ import { G as GraphModule } from './module-plugin-CHb-5W0Y.cjs';
3
+
4
+ /** An OSC argument: int32 (`i`), float32 (`f`), string (`s`), blob (`b`), true/false (`T`/`F`) or nil (`N`). */
5
+ type OscArgument = {
6
+ readonly type: 'i';
7
+ readonly value: number;
8
+ } | {
9
+ readonly type: 'f';
10
+ readonly value: number;
11
+ } | {
12
+ readonly type: 's';
13
+ readonly value: string;
14
+ } | {
15
+ readonly type: 'b';
16
+ readonly value: Uint8Array;
17
+ } | {
18
+ readonly type: 'T' | 'F' | 'N';
19
+ };
20
+ interface OscMessage {
21
+ readonly address: string;
22
+ readonly args: readonly OscArgument[];
23
+ }
24
+ interface OscBundle {
25
+ readonly timetag: bigint;
26
+ readonly elements: readonly (OscMessage | OscBundle)[];
27
+ }
28
+ type OscPacket = OscMessage | OscBundle;
29
+ declare const isOscBundle: (packet: OscPacket) => packet is OscBundle;
30
+ /** Encode a message or bundle. Throws for an address that does not start with `/`. */
31
+ declare function encodeOsc(packet: OscPacket): Uint8Array;
32
+ /** Decode one packet. Throws a SyntaxError for malformed bytes. */
33
+ declare function decodeOsc(input: ArrayBuffer | Uint8Array): OscPacket;
34
+
35
+ interface ModuleControl {
36
+ /** Which control shows the module, such as `toggle`, `slider` or `matrix`. */
37
+ readonly kind: string;
38
+ /** The state to draw; its shape depends on `kind` (see the Kernel reference). */
39
+ snapshot(): JsonValue;
40
+ /** Notified after every change of the snapshot. */
41
+ subscribe(listener: () => void): () => void;
42
+ /** A user action, as an untimed message into the module's first input. */
43
+ interact(message: Message): void;
44
+ }
45
+ /** The capability key under which a module offers its control. */
46
+ declare const MODULE_CONTROL: CapabilityKey<ModuleControl>;
47
+ /** Read a module's control from any module handle that offers one. */
48
+ declare function moduleControlOf(module: ModuleHandle | undefined): ModuleControl | undefined;
49
+ /** A module that shows a control: it lends its state and takes user actions. */
50
+ declare abstract class ControlModule extends GraphModule {
51
+ #private;
52
+ /** Which control shows this module. */
53
+ abstract readonly kind: string;
54
+ /** The state a presenter draws. */
55
+ abstract snapshot(): JsonValue;
56
+ /** A message at the first input. */
57
+ protected abstract receive(value: Message): void;
58
+ get capabilities(): ModuleCapabilities;
59
+ }
60
+
61
+ export { ControlModule as C, MODULE_CONTROL as M, type OscArgument as O, type ModuleControl as a, type OscBundle as b, type OscMessage as c, type OscPacket as d, decodeOsc as e, encodeOsc as f, isOscBundle as i, moduleControlOf as m };
@@ -0,0 +1,198 @@
1
+ import { C as CapabilityKey, u as ModuleContext, k as MessageClock, w as ModuleHandle, t as ModuleCapabilities, x as ModulePort, j as Message, l as MessageInputPort, n as MessageOutputPort, A as Atom } from './context-DaxfAg3b.js';
2
+ import { a as ControlSignal, C as ConnectionLease } from './parameter-DwQzFmBR.js';
3
+ import { A as ProjectPortDescriptor, m as ProjectJsonObject, J as ProjectSignalKind, j as ProjectFactoryRequest, x as ProjectPluginFactory } from './project-types-BU4awMnL.js';
4
+ import { ModuleSession } from './session.js';
5
+ import { MusicalTempo, BarsBeatsTicks } from './transport.js';
6
+
7
+ /**
8
+ * The Session's musical time, lent to every module of a project (DEC-077):
9
+ * its tempo and meter, the position in bars, beats and ticks, and the audio
10
+ * time of a Session position, for timers that follow the transport.
11
+ */
12
+ interface MusicalTimeSource {
13
+ /** Current tempo and meter. */
14
+ tempo(): MusicalTempo;
15
+ /** Whether the Session is playing. */
16
+ playing(): boolean;
17
+ /** Session position in seconds now. */
18
+ position(): number;
19
+ /** Bars, beats and ticks now. */
20
+ barsBeatsTicks(): BarsBeatsTicks;
21
+ /** AudioContext time at a Session position, while playing; undefined while paused. */
22
+ timeAt(position: number): number | undefined;
23
+ /** Notified after a tempo change and after play, pause, seek or a loop jump. */
24
+ subscribe(listener: () => void): () => void;
25
+ }
26
+ declare const MUSICAL_TIME: CapabilityKey<MusicalTimeSource>;
27
+ /** A musical-time source over a Session; `notify()` reports a tempo change. */
28
+ declare function createMusicalTimeSource(session: ModuleSession, tempo: () => MusicalTempo): MusicalTimeSource & {
29
+ notify(): void;
30
+ };
31
+
32
+ interface GraphModuleOptions {
33
+ /** The module's ID. Defaults to the short name of its type, such as `metro`. */
34
+ readonly id?: string;
35
+ /** Borrowed. Lends the audio clock, the Session's musical time and the registry of the modules beside this one. */
36
+ readonly context?: ModuleContext;
37
+ /** Borrowed clock for timed output. Defaults to the shared clock of the context's AudioContext. */
38
+ readonly clock?: MessageClock;
39
+ /** Borrowed musical time. Defaults to the one the context lends, when it has a Session. */
40
+ readonly musicalTime?: MusicalTimeSource;
41
+ /** Receives a failure inside a handler. Without it the failure is rethrown in a microtask. */
42
+ readonly onError?: (error: unknown) => void;
43
+ }
44
+ /** A value saved for a module: its options and the state it exports, by name. */
45
+ type ModuleOptionsJson = ProjectJsonObject;
46
+ declare abstract class GraphModule implements ModuleHandle {
47
+ #private;
48
+ readonly id: string;
49
+ /** The module type this instance is saved as, such as `webmusic.metro`. */
50
+ readonly type: string;
51
+ protected constructor(type: string, options?: GraphModuleOptions);
52
+ /** True once `activate()` ran: timers run and load-time output has been sent. */
53
+ get active(): boolean;
54
+ get disposed(): boolean;
55
+ /** Capabilities this module lends, when it has any. */
56
+ get capabilities(): ModuleCapabilities | undefined;
57
+ /** A control output for modulation, when the module has one. */
58
+ get control(): ControlSignal | undefined;
59
+ /** Every port, inputs first, in the order the module declares them. */
60
+ ports(): readonly ModulePort[];
61
+ /** Each port's ID, label, kind and direction, in the same order. */
62
+ describePorts(): readonly ProjectPortDescriptor[];
63
+ /**
64
+ * Start the module: timers begin and load-time output is sent. Call it once
65
+ * the ports are connected; a project runtime calls it when its graph
66
+ * commits. Repeated calls do nothing.
67
+ */
68
+ activate(): void;
69
+ /** Be told after each change of the module's displayed state. Returns the cleanup. */
70
+ watch(listener: () => void): () => void;
71
+ /**
72
+ * The options a project saves: those the module was made with and the state
73
+ * it keeps, so that `new Type(module.exportOptions())` restores it. A value
74
+ * an input merely stored for the next output is not saved.
75
+ */
76
+ abstract exportOptions(): ModuleOptionsJson;
77
+ dispose(): void;
78
+ /** Runs once, in `activate()`. */
79
+ protected onActivate(): void;
80
+ /** Runs once, in `dispose()`, before the ports are released. */
81
+ protected onDispose(): void;
82
+ /** The context this module borrows, when it was given one. */
83
+ protected get context(): ModuleContext | undefined;
84
+ /** The Session's musical time, when the module was lent one. */
85
+ protected get musicalTime(): MusicalTimeSource | undefined;
86
+ /** The context's AudioContext, created on first use. */
87
+ protected audio(): BaseAudioContext;
88
+ /** The module's clock. Everything scheduled through it is cancelled on dispose. */
89
+ protected get clock(): MessageClock;
90
+ /** The time of a message, or now for an untimed one. */
91
+ protected timeOf(value: Message): number;
92
+ /** Declare a message input. Its handler runs guarded and never after dispose. */
93
+ protected input(id: string, label: string, handler: (value: Message) => void): MessageInputPort;
94
+ /** Declare a message output. */
95
+ protected output(id: string, label: string): MessageOutputPort;
96
+ /** Declare a port of another family that the subclass made, or one with no port object. */
97
+ protected addPort(port: ModulePort | undefined, descriptor: {
98
+ id: string;
99
+ label: string;
100
+ kind: ProjectSignalKind;
101
+ direction: 'input' | 'output';
102
+ }): void;
103
+ /** Report a failure without stopping the graph. */
104
+ protected fail(error: unknown): void;
105
+ protected guard(work: () => void): void;
106
+ /** Tell watchers that the displayed state changed. */
107
+ protected changed(): void;
108
+ }
109
+ /** Ports `in0`, `in1`… or `out0`, `out1`… for a module whose port count follows its options. */
110
+ declare const numberedPort: (direction: "in" | "out", index: number) => string;
111
+
112
+ /** The part of a Worker a sandbox uses; injectable for tests. */
113
+ interface ScriptWorkerLike {
114
+ onmessage: ((event: {
115
+ data: unknown;
116
+ }) => void) | null;
117
+ onerror: ((event: {
118
+ message?: string;
119
+ }) => void) | null;
120
+ postMessage(data: unknown): void;
121
+ terminate(): void;
122
+ }
123
+ interface ScriptSandboxOptions {
124
+ /** Host functions the script may call as `<namespace>.<name>(...args)`; each returns a value or a promise. Arguments and results are structured-cloned. */
125
+ readonly api?: Readonly<Record<string, (...args: never[]) => unknown>>;
126
+ /** The global name of `api` in the script. Defaults to `host`. */
127
+ readonly namespace?: string;
128
+ /** Receives `post(...)` output from the script. */
129
+ readonly onPost?: (text: string) => void;
130
+ /** Receives `outlet(index, ...values)` from the script. */
131
+ readonly onOutlet?: (index: number, values: readonly unknown[]) => void;
132
+ /** Receives errors thrown by the script outside a call. */
133
+ readonly onError?: (error: Error) => void;
134
+ /** Create the worker from the prelude's source text. Defaults to a module-less Worker from a Blob URL. */
135
+ readonly createWorker?: (source: string) => ScriptWorkerLike;
136
+ }
137
+ /** The source the Worker runs first. Exported for tests that run it elsewhere. */
138
+ declare const SCRIPT_PRELUDE: string;
139
+ /** One user script on its own thread. */
140
+ declare class ScriptSandbox {
141
+ #private;
142
+ constructor(options?: ScriptSandboxOptions);
143
+ get terminated(): boolean;
144
+ /** Compile `code` as a module script; rejects with its syntax or top-level error. */
145
+ load(code: string): Promise<void>;
146
+ /** Run REPL input in the script's global scope; resolves with the value and its printed form. `await` makes it async. */
147
+ evaluate(code: string): Promise<{
148
+ value: unknown;
149
+ text: string;
150
+ }>;
151
+ /** Hand a message to the loaded script's handler; fire and forget. */
152
+ deliver(inlet: number, value: Message): void;
153
+ terminate(): void;
154
+ }
155
+ /** A script value as an atom: integers stay ints, other numbers floats, strings symbols. */
156
+ declare function scriptAtom(value: unknown): Atom;
157
+ /** Values from `outlet(...)` as a message: one number or symbol, a leading word as selector, else a list. */
158
+ declare function scriptMessage(values: readonly unknown[]): Message;
159
+
160
+ /** Version of the module types the packages register. */
161
+ declare const MODULE_PLUGIN_VERSION = "1.0.0";
162
+ /** Shared services for the modules of one plugin set. */
163
+ interface ModuleEnvironment {
164
+ /** The clock for timed output. Defaults to the shared clock of the module context's AudioContext. */
165
+ readonly clock?: (context: BaseAudioContext) => MessageClock;
166
+ /** Where the `print` function and scripts write. Defaults to `console.log`. */
167
+ readonly print?: (name: string, text: string, moduleId: string) => void;
168
+ /** A source of uniform numbers in [0, 1) for modules without a seed. Defaults to `Math.random`. */
169
+ readonly random?: () => number;
170
+ /** Receives failures inside module behavior and message delivery. */
171
+ readonly onError?: (error: unknown, moduleId: string) => void;
172
+ /** Creates the Worker a script module runs in, from its source text. Defaults to a Worker from a Blob URL (DEC-078). */
173
+ readonly createScriptWorker?: (source: string) => ScriptWorkerLike;
174
+ }
175
+ /** What a module may add to its project instance beyond ports and options. */
176
+ interface ModuleProjectHooks {
177
+ getInput?(port: string): AudioNode | undefined;
178
+ childContext?(context: ModuleContext): ModuleContext;
179
+ sourceOutput?(port: string): ModuleHandle | undefined;
180
+ connectSource?(port: string, module: ModuleHandle): ConnectionLease | undefined;
181
+ }
182
+ /** The base options a registration gives the class it constructs. */
183
+ declare function moduleBaseOptions(request: ProjectFactoryRequest, environment?: ModuleEnvironment): GraphModuleOptions;
184
+ /**
185
+ * Refuse a record saved in the earlier form (DEC-097): object argument text
186
+ * is Studio's, and a module's options are saved by name.
187
+ */
188
+ declare function assertStructuredOptions(config: ProjectJsonObject): void;
189
+ /** A module's own options from a saved config and the registration's base options. */
190
+ type RestoredOptions<Options> = Options & GraphModuleOptions;
191
+ /**
192
+ * The project plugin of one module type. `create` constructs the class from
193
+ * the record's options; a `TypeError`, `RangeError` or `SyntaxError` it throws
194
+ * leaves the module unresolved with that reason, keeping its record and cords.
195
+ */
196
+ declare function modulePlugin<Options extends object>(type: string, create: (options: RestoredOptions<Options>, request: ProjectFactoryRequest) => GraphModule & ModuleProjectHooks, environment?: ModuleEnvironment): ProjectPluginFactory;
197
+
198
+ export { GraphModule as G, MODULE_PLUGIN_VERSION as M, type RestoredOptions as R, SCRIPT_PRELUDE as S, type GraphModuleOptions as a, MUSICAL_TIME as b, type ModuleEnvironment as c, type ModuleOptionsJson as d, type ModuleProjectHooks as e, type MusicalTimeSource as f, ScriptSandbox as g, type ScriptSandboxOptions as h, type ScriptWorkerLike as i, assertStructuredOptions as j, createMusicalTimeSource as k, modulePlugin as l, moduleBaseOptions as m, numberedPort as n, scriptMessage as o, scriptAtom as s };