scribbletune 5.2.0 → 5.5.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 (42) hide show
  1. package/README.md +276 -22
  2. package/dist/browser.cjs +1183 -0
  3. package/dist/browser.cjs.map +1 -0
  4. package/dist/browser.js +1135 -1
  5. package/dist/browser.js.map +1 -1
  6. package/dist/cli.cjs +813 -0
  7. package/dist/{index.mjs → index.cjs} +225 -169
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.cts +323 -0
  10. package/dist/index.d.ts +303 -350
  11. package/dist/index.js +524 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/scribbletune.global.js +1944 -0
  14. package/dist/scribbletune.global.js.map +1 -0
  15. package/package.json +32 -40
  16. package/dist/lib/arp.d.ts +0 -10
  17. package/dist/lib/browser-clip.d.ts +0 -14
  18. package/dist/lib/browser-index.d.ts +0 -7
  19. package/dist/lib/channel.d.ts +0 -61
  20. package/dist/lib/clip.d.ts +0 -2
  21. package/dist/lib/index.d.ts +0 -7
  22. package/dist/lib/midi.d.ts +0 -11
  23. package/dist/lib/progression.d.ts +0 -25
  24. package/dist/lib/session.d.ts +0 -14
  25. package/dist/lib/types/arp-params.d.ts +0 -6
  26. package/dist/lib/types/channel-params.d.ts +0 -92
  27. package/dist/lib/types/channel-pattern.d.ts +0 -24
  28. package/dist/lib/types/clip-params.d.ts +0 -104
  29. package/dist/lib/types/event-fn.d.ts +0 -7
  30. package/dist/lib/types/index.d.ts +0 -14
  31. package/dist/lib/types/note-object.d.ts +0 -6
  32. package/dist/lib/types/nvp.d.ts +0 -4
  33. package/dist/lib/types/play-params.d.ts +0 -15
  34. package/dist/lib/types/player-observer-fn.d.ts +0 -6
  35. package/dist/lib/types/progression-scale.d.ts +0 -2
  36. package/dist/lib/types/seq-fn.d.ts +0 -2
  37. package/dist/lib/types/sizzle-style.d.ts +0 -2
  38. package/dist/lib/types/synth-params.d.ts +0 -20
  39. package/dist/lib/types/tpd.d.ts +0 -15
  40. package/dist/lib/utils.d.ts +0 -56
  41. package/dist/scribbletune.js +0 -2
  42. package/dist/scribbletune.js.map +0 -1
@@ -0,0 +1,1183 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/browser-index.ts
31
+ var browser_index_exports = {};
32
+ __export(browser_index_exports, {
33
+ Session: () => Session,
34
+ arp: () => arp,
35
+ chord: () => import_harmonics4.chord,
36
+ chords: () => import_harmonics4.chords,
37
+ clip: () => clip,
38
+ getChordDegrees: () => getChordDegrees,
39
+ getChordsByProgression: () => getChordsByProgression,
40
+ midi: () => midi,
41
+ mode: () => import_harmonics4.scale,
42
+ modes: () => import_harmonics4.scales,
43
+ progression: () => progression,
44
+ scale: () => import_harmonics4.scale,
45
+ scales: () => import_harmonics4.scales
46
+ });
47
+ module.exports = __toCommonJS(browser_index_exports);
48
+ var import_harmonics4 = require("harmonics");
49
+
50
+ // src/arp.ts
51
+ var import_harmonics2 = require("harmonics");
52
+
53
+ // src/utils.ts
54
+ var import_harmonics = require("harmonics");
55
+ var isNote = (str) => /^[a-gA-G](?:#|b)?\d$/.test(str);
56
+ var expandStr = (str) => {
57
+ str = JSON.stringify(str.split(""));
58
+ str = str.replace(/,"\[",/g, ", [");
59
+ str = str.replace(/"\[",/g, "[");
60
+ str = str.replace(/,"\]"/g, "]");
61
+ return JSON.parse(str);
62
+ };
63
+ var shuffle = (arr, fullShuffle = true) => {
64
+ const lastIndex = arr.length - 1;
65
+ arr.forEach((el, idx) => {
66
+ if (idx >= lastIndex) {
67
+ return;
68
+ }
69
+ const rnd = fullShuffle ? (
70
+ // Pick random number from idx+1 to lastIndex (Modified algorithm, (N-1)! combinations)
71
+ // Math.random -> [0, 1) -> [0, lastIndex-idx ) --floor-> [0, lastIndex-idx-1]
72
+ // rnd = [0, lastIndex-idx-1] + 1 + idx = [1 + idx, lastIndex]
73
+ // (Original algorithm would pick rnd = [idx, lastIndex], thus any element could arrive back into its slot)
74
+ Math.floor(Math.random() * (lastIndex - idx)) + 1 + idx
75
+ ) : (
76
+ // Pick random number from idx to lastIndex (Unmodified Richard Durstenfeld, N! combinations)
77
+ Math.floor(Math.random() * (lastIndex + 1 - idx)) + idx
78
+ );
79
+ arr[idx] = arr[rnd];
80
+ arr[rnd] = el;
81
+ });
82
+ return arr;
83
+ };
84
+ var pickOne = (arr) => arr[Math.floor(Math.random() * arr.length)];
85
+ var dice = () => !!Math.round(Math.random());
86
+ var errorHasMessage = (x) => {
87
+ return typeof x === "object" && x !== null && "message" in x && typeof x.message === "string";
88
+ };
89
+ var convertChordToNotes = (el) => {
90
+ let c1;
91
+ let c2;
92
+ let e1;
93
+ let e2;
94
+ try {
95
+ c1 = (0, import_harmonics.inlineChord)(el);
96
+ } catch (e) {
97
+ e1 = e;
98
+ }
99
+ try {
100
+ c2 = (0, import_harmonics.chord)(el.replace(/_/g, " "));
101
+ } catch (e) {
102
+ e2 = e;
103
+ }
104
+ if (!e1 && !e2) {
105
+ if (c1.toString() !== c2.toString()) {
106
+ throw new Error(`Chord ${el} cannot decode, guessing ${c1} or ${c2}`);
107
+ }
108
+ return c1;
109
+ }
110
+ if (!e1) {
111
+ return c1;
112
+ }
113
+ if (!e2) {
114
+ return c2;
115
+ }
116
+ return (0, import_harmonics.chord)(el);
117
+ };
118
+ var convertChordsToNotes = (el) => {
119
+ if (typeof el === "string" && isNote(el)) {
120
+ return [el];
121
+ }
122
+ if (Array.isArray(el)) {
123
+ el.forEach((n) => {
124
+ if (Array.isArray(n)) {
125
+ n.forEach((n1) => {
126
+ if (typeof n1 !== "string" || !isNote(n1)) {
127
+ throw new TypeError("array of arrays must comprise valid notes");
128
+ }
129
+ });
130
+ } else if (typeof n !== "string" || !isNote(n)) {
131
+ throw new TypeError("array must comprise valid notes");
132
+ }
133
+ });
134
+ return el;
135
+ }
136
+ if (!Array.isArray(el)) {
137
+ const c = convertChordToNotes(el);
138
+ if (c?.length) {
139
+ return c;
140
+ }
141
+ }
142
+ throw new Error(`Chord ${el} not found`);
143
+ };
144
+ var randomInt = (num = 1) => Math.round(Math.random() * num);
145
+
146
+ // src/arp.ts
147
+ var DEFAULT_OCTAVE = 4;
148
+ var fillArr = (arr, len) => {
149
+ const bumpOctave = (el) => {
150
+ if (!el) {
151
+ throw new Error("Empty element");
152
+ }
153
+ const note = el.replace(/\d/, "");
154
+ const oct = el.replace(/\D/g, "") || DEFAULT_OCTAVE;
155
+ if (!note) {
156
+ throw new Error("Incorrect note");
157
+ }
158
+ return note + (+oct + 1);
159
+ };
160
+ const arr1 = arr.map(bumpOctave);
161
+ const arr2 = arr1.map(bumpOctave);
162
+ const finalArr = [...arr, ...arr1, ...arr2];
163
+ return finalArr.slice(0, len);
164
+ };
165
+ var arp = (chordsOrParams) => {
166
+ let finalArr = [];
167
+ const params = {
168
+ count: 4,
169
+ order: "0123",
170
+ chords: ""
171
+ };
172
+ if (typeof chordsOrParams === "string") {
173
+ params.chords = chordsOrParams;
174
+ } else {
175
+ if (chordsOrParams.order?.match(/\D/g)) {
176
+ throw new TypeError("Invalid value for order");
177
+ }
178
+ if (chordsOrParams.count > 8 || chordsOrParams.count < 2) {
179
+ throw new TypeError("Invalid value for count");
180
+ }
181
+ if (chordsOrParams.count && !chordsOrParams.order) {
182
+ params.order = Array.from(Array(chordsOrParams.count).keys()).join("");
183
+ }
184
+ Object.assign(params, chordsOrParams);
185
+ }
186
+ if (typeof params.chords === "string") {
187
+ const chordsArr = params.chords.split(" ");
188
+ chordsArr.forEach((c, i) => {
189
+ try {
190
+ const filledArr = fillArr((0, import_harmonics2.inlineChord)(c), params.count);
191
+ const reorderedArr = params.order.split("").map((idx) => filledArr[Number(idx)]);
192
+ finalArr = [...finalArr, ...reorderedArr];
193
+ } catch (_e) {
194
+ throw new Error(
195
+ `Cannot decode chord ${i + 1} "${c}" in given "${params.chords}"`
196
+ );
197
+ }
198
+ });
199
+ } else if (Array.isArray(params.chords)) {
200
+ params.chords.forEach((c, i) => {
201
+ try {
202
+ const filledArr = fillArr(c, params.count);
203
+ const reorderedArr = params.order.split("").map((idx) => filledArr[Number(idx)]);
204
+ finalArr = [...finalArr, ...reorderedArr];
205
+ } catch (e) {
206
+ throw new Error(
207
+ `${errorHasMessage(e) ? e.message : e} in chord ${i + 1} "${c}"`
208
+ );
209
+ }
210
+ });
211
+ } else {
212
+ throw new TypeError("Invalid value for chords");
213
+ }
214
+ return finalArr;
215
+ };
216
+
217
+ // src/channel/instrument-factory.ts
218
+ function checkToneObjLoaded(toneObject, resolve) {
219
+ const skipRecursion = toneObject instanceof Tone.Sampler;
220
+ if ("loaded" in toneObject) {
221
+ if (toneObject.loaded) {
222
+ resolve();
223
+ return;
224
+ }
225
+ if (skipRecursion) {
226
+ return;
227
+ }
228
+ let handled = false;
229
+ ["buffer", "_buffer", "_buffers"].forEach((key) => {
230
+ if (key in toneObject) {
231
+ checkToneObjLoaded(toneObject[key], resolve);
232
+ handled = true;
233
+ }
234
+ });
235
+ if (handled) {
236
+ return;
237
+ }
238
+ }
239
+ const hasOnload = toneObject instanceof Tone.ToneAudioBuffer || toneObject instanceof Tone.ToneBufferSource || // Falback for "future" objects
240
+ "loaded" in toneObject && "onload" in toneObject;
241
+ if (!hasOnload) {
242
+ resolve();
243
+ } else {
244
+ const oldOnLoad = toneObject.onload;
245
+ toneObject.onload = () => {
246
+ if (oldOnLoad && typeof oldOnLoad === "function") {
247
+ toneObject.onload = oldOnLoad;
248
+ oldOnLoad();
249
+ }
250
+ resolve();
251
+ };
252
+ }
253
+ }
254
+ function recreateToneObjectInContext(toneObject, context) {
255
+ context = context || Tone.getContext();
256
+ return new Promise((resolve, _reject) => {
257
+ if (toneObject instanceof Tone.PolySynth) {
258
+ const newObj = new Tone[toneObject._dummyVoice.name]({
259
+ ...toneObject.get(),
260
+ context
261
+ });
262
+ checkToneObjLoaded(newObj, () => resolve(newObj));
263
+ } else if (toneObject instanceof Tone.Player) {
264
+ const newObj = new Tone.Player({
265
+ url: toneObject._buffer,
266
+ context,
267
+ onload: () => checkToneObjLoaded(newObj, () => resolve(newObj))
268
+ });
269
+ } else if (toneObject instanceof Tone.Sampler) {
270
+ const { attack, curve, release, volume } = toneObject.get();
271
+ const paramsFromSampler = {
272
+ attack,
273
+ curve,
274
+ release,
275
+ volume
276
+ };
277
+ const paramsFromBuffers = {
278
+ baseUrl: toneObject._buffers.baseUrl,
279
+ urls: Object.fromEntries(toneObject._buffers._buffers.entries())
280
+ };
281
+ const newObj = new Tone.Sampler({
282
+ ...paramsFromSampler,
283
+ ...paramsFromBuffers,
284
+ context,
285
+ onload: () => checkToneObjLoaded(
286
+ newObj,
287
+ () => resolve(newObj)
288
+ )
289
+ });
290
+ } else {
291
+ const newObj = new Tone[toneObject.name]({
292
+ ...toneObject.get(),
293
+ context,
294
+ onload: () => checkToneObjLoaded(newObj, () => resolve(newObj))
295
+ });
296
+ checkToneObjLoaded(newObj, () => resolve(newObj));
297
+ }
298
+ });
299
+ }
300
+ function createInstrument(context, params, channelMeta) {
301
+ let instrument;
302
+ let external;
303
+ context = context || Tone.getContext();
304
+ const loadPromise = new Promise((resolve, reject) => {
305
+ if (params.synth) {
306
+ if (params.instrument) {
307
+ throw new Error(
308
+ "Either synth or instrument can be provided, but not both."
309
+ );
310
+ }
311
+ if (params.synth.synth) {
312
+ const synthName = params.synth.synth;
313
+ const preset = params.synth.preset || {};
314
+ instrument = new Tone[synthName]({
315
+ ...preset,
316
+ context,
317
+ // Use onload for cases when synthName calls out Tone.Sample/Player/Sampler.
318
+ // It could be a universal way to load Tone.js instruments.
319
+ onload: () => checkToneObjLoaded(instrument, resolve)
320
+ // This onload is ignored in all synths. Therefore we call checkToneObjLoaded() again below.
321
+ // It is safe to call resolve() multiple times for Promise<void>
322
+ });
323
+ checkToneObjLoaded(instrument, resolve);
324
+ } else {
325
+ instrument = params.synth;
326
+ console.warn(
327
+ 'The "synth" parameter with instrument will be deprecated in the future. Please use the "instrument" parameter instead.'
328
+ );
329
+ checkToneObjLoaded(instrument, resolve);
330
+ }
331
+ } else if (typeof params.instrument === "string") {
332
+ instrument = new Tone[params.instrument]({ context });
333
+ checkToneObjLoaded(instrument, resolve);
334
+ } else if (params.instrument) {
335
+ instrument = params.instrument;
336
+ checkToneObjLoaded(instrument, resolve);
337
+ } else if (params.sample || params.buffer) {
338
+ instrument = new Tone.Player({
339
+ url: params.sample || params.buffer,
340
+ context,
341
+ onload: () => checkToneObjLoaded(instrument, resolve)
342
+ });
343
+ } else if (params.samples) {
344
+ instrument = new Tone.Sampler({
345
+ urls: params.samples,
346
+ context,
347
+ onload: () => checkToneObjLoaded(instrument, resolve)
348
+ });
349
+ } else if (params.sampler) {
350
+ instrument = params.sampler;
351
+ checkToneObjLoaded(instrument, resolve);
352
+ } else if (params.player) {
353
+ instrument = params.player;
354
+ checkToneObjLoaded(instrument, resolve);
355
+ } else if (params.external) {
356
+ external = { ...params.external };
357
+ instrument = {
358
+ context,
359
+ volume: { value: 0 }
360
+ };
361
+ if (params.external.init) {
362
+ return params.external.init(context.rawContext).then(() => {
363
+ resolve();
364
+ }).catch((e) => {
365
+ reject(
366
+ new Error(
367
+ `${errorHasMessage(e) ? e.message : e} loading external output module of channel idx ${channelMeta.idx}, ${channelMeta.name ?? "(no name)"}`
368
+ )
369
+ );
370
+ });
371
+ } else {
372
+ resolve();
373
+ }
374
+ } else {
375
+ throw new Error(
376
+ "One of required synth|instrument|sample|sampler|samples|buffer|player|external is not provided!"
377
+ );
378
+ }
379
+ if (!instrument) {
380
+ throw new Error("Failed instantiating instrument from given params.");
381
+ }
382
+ });
383
+ const initPromise = loadPromise.then(() => {
384
+ if (!external && instrument?.context !== context) {
385
+ return recreateToneObjectInContext(instrument, context).then((newObj) => {
386
+ instrument = newObj;
387
+ });
388
+ }
389
+ }).then(() => {
390
+ if (params.volume) {
391
+ instrument.volume.value = params.volume;
392
+ external?.setVolume?.(params.volume);
393
+ }
394
+ return instrument;
395
+ });
396
+ return { instrument, external, initPromise };
397
+ }
398
+
399
+ // src/channel/sequence-builder.ts
400
+ function buildSequenceCallback(params, host, playerCb, eventCb) {
401
+ if (host.external) {
402
+ const ext = host.external;
403
+ return (time, el) => {
404
+ if (el === "x" || el === "R") {
405
+ const counter = host.clipNoteCount;
406
+ if (host.hasLoaded) {
407
+ const note = getNote(el, params, counter)[0];
408
+ const duration = getDuration(params, counter);
409
+ const durSeconds = Tone.Time(duration).toSeconds();
410
+ playerCb({ note, duration, time, counter });
411
+ try {
412
+ ext.triggerAttackRelease?.(note, durSeconds, time);
413
+ } catch (e) {
414
+ eventCb("error", { e });
415
+ }
416
+ }
417
+ host.clipNoteCount++;
418
+ }
419
+ };
420
+ }
421
+ if (host.instrument instanceof Tone.Player) {
422
+ return (time, el) => {
423
+ if (el === "x" || el === "R") {
424
+ const counter = host.clipNoteCount;
425
+ if (host.hasLoaded) {
426
+ playerCb({ note: "", duration: "", time, counter });
427
+ try {
428
+ host.instrument.start(time);
429
+ } catch (e) {
430
+ eventCb("error", { e });
431
+ }
432
+ }
433
+ host.clipNoteCount++;
434
+ }
435
+ };
436
+ }
437
+ if (host.instrument instanceof Tone.PolySynth || host.instrument instanceof Tone.Sampler) {
438
+ return (time, el) => {
439
+ if (el === "x" || el === "R") {
440
+ const counter = host.clipNoteCount;
441
+ if (host.hasLoaded) {
442
+ const note = getNote(el, params, counter);
443
+ const duration = getDuration(params, counter);
444
+ playerCb({ note, duration, time, counter });
445
+ try {
446
+ host.instrument.triggerAttackRelease(note, duration, time);
447
+ } catch (e) {
448
+ eventCb("error", { e });
449
+ }
450
+ }
451
+ host.clipNoteCount++;
452
+ }
453
+ };
454
+ }
455
+ if (host.instrument instanceof Tone.NoiseSynth) {
456
+ return (time, el) => {
457
+ if (el === "x" || el === "R") {
458
+ const counter = host.clipNoteCount;
459
+ if (host.hasLoaded) {
460
+ const duration = getDuration(params, counter);
461
+ playerCb({ note: "", duration, time, counter });
462
+ try {
463
+ host.instrument.triggerAttackRelease(
464
+ duration,
465
+ time
466
+ );
467
+ } catch (e) {
468
+ eventCb("error", { e });
469
+ }
470
+ }
471
+ host.clipNoteCount++;
472
+ }
473
+ };
474
+ }
475
+ return (time, el) => {
476
+ if (el === "x" || el === "R") {
477
+ const counter = host.clipNoteCount;
478
+ if (host.hasLoaded) {
479
+ const note = getNote(el, params, counter)[0];
480
+ const duration = getDuration(params, counter);
481
+ playerCb({ note, duration, time, counter });
482
+ try {
483
+ host.instrument.triggerAttackRelease(note, duration, time);
484
+ } catch (e) {
485
+ eventCb("error", { e });
486
+ }
487
+ }
488
+ host.clipNoteCount++;
489
+ }
490
+ };
491
+ }
492
+
493
+ // src/clip-utils.ts
494
+ var defaultParams = {
495
+ notes: ["C4"],
496
+ pattern: "x",
497
+ shuffle: false,
498
+ sizzle: false,
499
+ sizzleReps: 1,
500
+ arpegiate: false,
501
+ subdiv: "4n",
502
+ amp: 100,
503
+ accentLow: 70,
504
+ randomNotes: null,
505
+ offlineRendering: false
506
+ };
507
+ var validatePattern = (pattern) => {
508
+ if (/[^x\-_[\]R]/.test(pattern)) {
509
+ throw new TypeError(
510
+ `pattern can only comprise x - _ [ ] R, found ${pattern}`
511
+ );
512
+ }
513
+ };
514
+ var preprocessClipParams = (params, extraDefaults) => {
515
+ params = { ...defaultParams, ...extraDefaults, ...params || {} };
516
+ if (typeof params.notes === "string") {
517
+ params.notes = params.notes.replace(/\s{2,}/g, " ").split(" ");
518
+ }
519
+ params.notes = params.notes ? params.notes.map(convertChordsToNotes) : [];
520
+ validatePattern(params.pattern);
521
+ if (params.shuffle) {
522
+ params.notes = shuffle(params.notes);
523
+ }
524
+ if (params.randomNotes && typeof params.randomNotes === "string") {
525
+ params.randomNotes = params.randomNotes.replace(/\s{2,}/g, " ").split(/\s/);
526
+ }
527
+ if (params.randomNotes) {
528
+ params.randomNotes = params.randomNotes.map(
529
+ convertChordsToNotes
530
+ );
531
+ }
532
+ return params;
533
+ };
534
+
535
+ // src/browser-clip.ts
536
+ var defaultSubdiv = "4n";
537
+ var defaultDur = "8n";
538
+ var getNote = (el, params, counter) => {
539
+ if (el === "R" && params.randomNotes && params.randomNotes.length > 0) {
540
+ return params.randomNotes[randomInt(params.randomNotes.length - 1)];
541
+ }
542
+ if (params.notes) {
543
+ return params.notes[counter % (params.notes.length || 1)];
544
+ }
545
+ return "";
546
+ };
547
+ var getDuration = (params, counter) => {
548
+ return params.durations ? params.durations[counter % params.durations.length] : params.dur || params.subdiv || defaultDur;
549
+ };
550
+ var recursivelyApplyPatternToDurations = (patternArr, length, durations = []) => {
551
+ patternArr.forEach((char) => {
552
+ if (typeof char === "string") {
553
+ if (char === "x" || char === "R") {
554
+ durations.push(length);
555
+ }
556
+ if (char === "_" && durations.length) {
557
+ durations[durations.length - 1] += length;
558
+ }
559
+ }
560
+ if (Array.isArray(char)) {
561
+ recursivelyApplyPatternToDurations(char, length / char.length, durations);
562
+ }
563
+ });
564
+ return durations;
565
+ };
566
+ var generateSequence = (params, channel, context) => {
567
+ context = context || Tone.getContext();
568
+ if (!params.pattern) {
569
+ throw new Error("No pattern provided!");
570
+ }
571
+ if (!params.durations && !params.dur) {
572
+ params.durations = recursivelyApplyPatternToDurations(
573
+ expandStr(params.pattern),
574
+ Tone.Ticks(params.subdiv || defaultSubdiv).toSeconds()
575
+ );
576
+ }
577
+ let callback;
578
+ if (channel) {
579
+ callback = channel.getSeqFn(params);
580
+ } else if (params.sample) {
581
+ const player = new Tone.Player({ url: params.sample, context });
582
+ player.toDestination();
583
+ player.sync();
584
+ const host = {
585
+ instrument: player,
586
+ hasLoaded: false,
587
+ clipNoteCount: 0
588
+ };
589
+ checkToneObjLoaded(player, () => {
590
+ host.hasLoaded = true;
591
+ });
592
+ const noop = () => {
593
+ };
594
+ callback = buildSequenceCallback(params, host, noop, noop);
595
+ } else {
596
+ throw new Error(
597
+ "Either a Channel or a sample URL must be provided to create a clip."
598
+ );
599
+ }
600
+ return new Tone.Sequence({
601
+ callback,
602
+ events: expandStr(params.pattern),
603
+ subdivision: params.subdiv || defaultSubdiv,
604
+ context
605
+ });
606
+ };
607
+ var totalPatternDuration = (pattern, subdivOrLength) => {
608
+ return typeof subdivOrLength === "number" ? subdivOrLength * expandStr(pattern).length : Tone.Ticks(subdivOrLength).toSeconds() * expandStr(pattern).length;
609
+ };
610
+ var leastCommonMultiple = (n1, n2) => {
611
+ const [smallest, largest] = n1 < n2 ? [n1, n2] : [n2, n1];
612
+ let i = largest;
613
+ while (i % smallest !== 0) {
614
+ i += largest;
615
+ }
616
+ return i;
617
+ };
618
+ var renderingDuration = (pattern, subdivOrLength, notes, randomNotes) => {
619
+ const patternRegularNotesCount = pattern.split("").filter((c) => {
620
+ return c === "x";
621
+ }).length;
622
+ const patternRandomNotesCount = pattern.split("").filter((c) => {
623
+ return c === "R";
624
+ }).length;
625
+ const patternNotesCount = randomNotes?.length ? patternRegularNotesCount : patternRegularNotesCount + patternRandomNotesCount;
626
+ const notesCount = notes.length || 1;
627
+ return totalPatternDuration(pattern, subdivOrLength) / patternNotesCount * leastCommonMultiple(notesCount, patternNotesCount);
628
+ };
629
+ var ongoingRenderingCounter = 0;
630
+ var originalContext;
631
+ var offlineRenderClip = (params, duration) => {
632
+ if (!originalContext) {
633
+ originalContext = Tone.getContext();
634
+ }
635
+ ongoingRenderingCounter++;
636
+ const player = new Tone.Player({ context: originalContext, loop: true });
637
+ Tone.Offline(async (context) => {
638
+ const sequence = generateSequence(params, context);
639
+ await Tone.loaded();
640
+ sequence.start();
641
+ context.transport.start();
642
+ }, duration).then((buffer) => {
643
+ player.buffer = buffer;
644
+ ongoingRenderingCounter--;
645
+ if (ongoingRenderingCounter === 0) {
646
+ Tone.setContext(originalContext);
647
+ params.offlineRenderingCallback?.();
648
+ }
649
+ });
650
+ player.toDestination();
651
+ player.sync();
652
+ return player;
653
+ };
654
+ var clip = (params, channel) => {
655
+ params = preprocessClipParams(params, { align: "1m", alignOffset: "0" });
656
+ if (params.offlineRendering) {
657
+ return offlineRenderClip(
658
+ params,
659
+ renderingDuration(
660
+ params.pattern,
661
+ params.subdiv || defaultSubdiv,
662
+ params.notes || [],
663
+ params.randomNotes
664
+ )
665
+ );
666
+ }
667
+ return generateSequence(params, channel, originalContext);
668
+ };
669
+
670
+ // src/midi.ts
671
+ var import_node_fs = __toESM(require("fs"), 1);
672
+ var import_midi = require("@scribbletune/midi");
673
+ var midi = (notes, fileName = "music.mid", bpm) => {
674
+ const file = createFileFromNotes(notes, bpm);
675
+ const bytes = file.toBytes();
676
+ if (fileName === null) {
677
+ return bytes;
678
+ }
679
+ if (!fileName.endsWith(".mid")) {
680
+ fileName = `${fileName}.mid`;
681
+ }
682
+ if (typeof window !== "undefined" && window.URL && typeof window.URL.createObjectURL === "function") {
683
+ return createDownloadLink(bytes, fileName);
684
+ }
685
+ import_node_fs.default.writeFileSync(fileName, bytes, "binary");
686
+ console.log(`MIDI file generated: ${fileName}.`);
687
+ };
688
+ var createDownloadLink = (b, fileName) => {
689
+ const bytes = new Uint8Array(b.length);
690
+ for (let i = 0; i < b.length; i++) {
691
+ const ascii = b.charCodeAt(i);
692
+ bytes[i] = ascii;
693
+ }
694
+ const blob = new Blob([bytes], { type: "audio/midi" });
695
+ const link = document.createElement("a");
696
+ link.href = typeof window !== "undefined" && typeof window.URL !== "undefined" && typeof window.URL.createObjectURL !== "undefined" && window.URL.createObjectURL(blob) || "";
697
+ link.download = fileName;
698
+ link.innerText = "Download MIDI file";
699
+ return link;
700
+ };
701
+ var createFileFromNotes = (notes, bpm) => {
702
+ const file = new import_midi.File();
703
+ const track = new import_midi.Track();
704
+ if (typeof bpm === "number") {
705
+ track.setTempo(bpm);
706
+ }
707
+ file.addTrack(track);
708
+ for (const noteObj of notes) {
709
+ const level = noteObj.level || 127;
710
+ if (noteObj.note) {
711
+ if (typeof noteObj.note === "string") {
712
+ track.noteOn(0, noteObj.note, noteObj.length, level);
713
+ track.noteOff(0, noteObj.note, noteObj.length, level);
714
+ } else {
715
+ track.addChord(0, noteObj.note, noteObj.length, level);
716
+ }
717
+ } else {
718
+ track.noteOff(0, "", noteObj.length);
719
+ }
720
+ }
721
+ return file;
722
+ };
723
+
724
+ // src/progression.ts
725
+ var import_harmonics3 = require("harmonics");
726
+ var getChordDegrees = (mode) => {
727
+ const theRomans = {
728
+ ionian: ["I", "ii", "iii", "IV", "V", "vi", "vii\xB0"],
729
+ dorian: ["i", "ii", "III", "IV", "v", "vi\xB0", "VII"],
730
+ phrygian: ["i", "II", "III", "iv", "v\xB0", "VI", "vii"],
731
+ lydian: ["I", "II", "iii", "iv\xB0", "V", "vi", "vii"],
732
+ mixolydian: ["I", "ii", "iii\xB0", "IV", "v", "vi", "VII"],
733
+ aeolian: ["i", "ii\xB0", "III", "iv", "v", "VI", "VII"],
734
+ locrian: ["i\xB0", "II", "iii", "iv", "V", "VI", "vii"],
735
+ "melodic minor": ["i", "ii", "III+", "IV", "V", "vi\xB0", "vii\xB0"],
736
+ "harmonic minor": ["i", "ii\xB0", "III+", "iv", "V", "VI", "vii\xB0"]
737
+ };
738
+ theRomans.major = theRomans.ionian;
739
+ theRomans.minor = theRomans.aeolian;
740
+ return theRomans[mode] || [];
741
+ };
742
+ var idxByDegree = {
743
+ i: 0,
744
+ ii: 1,
745
+ iii: 2,
746
+ iv: 3,
747
+ v: 4,
748
+ vi: 5,
749
+ vii: 6
750
+ };
751
+ var getChordName = (roman) => {
752
+ const str = roman.replace(/\W/g, "");
753
+ let prefix = "M";
754
+ if (str.toLowerCase() === str) {
755
+ prefix = "m";
756
+ }
757
+ if (roman.indexOf("\xB0") > -1) {
758
+ return `${prefix}7b5`;
759
+ }
760
+ if (roman.indexOf("+") > -1) {
761
+ return `${prefix}#5`;
762
+ }
763
+ if (roman.indexOf("7") > -1) {
764
+ return prefix === "M" ? "maj7" : "m7";
765
+ }
766
+ return prefix;
767
+ };
768
+ var getChordsByProgression = (noteOctaveScale, chordDegress) => {
769
+ const noteOctaveScaleArr = noteOctaveScale.split(" ");
770
+ if (!noteOctaveScaleArr[0].match(/\d/)) {
771
+ noteOctaveScaleArr[0] += "4";
772
+ noteOctaveScale = noteOctaveScaleArr.join(" ");
773
+ }
774
+ const mode = (0, import_harmonics3.scale)(noteOctaveScale);
775
+ const chordDegreesArr = chordDegress.replace(/\s*,+\s*/g, " ").split(" ");
776
+ const chordFamily = chordDegreesArr.map((roman) => {
777
+ const chordName = getChordName(roman);
778
+ const scaleId = idxByDegree[roman.replace(/\W|\d/g, "").toLowerCase()];
779
+ const note = mode[scaleId];
780
+ const oct = note.replace(/\D+/, "");
781
+ return `${note.replace(/\d/, "") + chordName}_${oct}`;
782
+ });
783
+ return chordFamily.toString().replace(/,/g, " ");
784
+ };
785
+ var getProgFactory = ({ T, P, D }) => {
786
+ return (count = 4) => {
787
+ const chords2 = [];
788
+ chords2.push(pickOne(T));
789
+ let i = 1;
790
+ if (i < count - 1) {
791
+ chords2.push(pickOne(P));
792
+ i++;
793
+ }
794
+ if (i < count - 1 && dice()) {
795
+ chords2.push(pickOne(P));
796
+ i++;
797
+ }
798
+ if (i < count - 1) {
799
+ chords2.push(pickOne(D));
800
+ i++;
801
+ }
802
+ if (i < count - 1) {
803
+ chords2.push(pickOne(P));
804
+ i++;
805
+ }
806
+ if (i < count - 1) {
807
+ chords2.push(pickOne(D));
808
+ i++;
809
+ }
810
+ if (i < count - 1 && dice()) {
811
+ chords2.push(pickOne(P));
812
+ i++;
813
+ }
814
+ while (i < count) {
815
+ chords2.push(pickOne(D));
816
+ i++;
817
+ }
818
+ return chords2;
819
+ };
820
+ };
821
+ var M = getProgFactory({ T: ["I", "vi"], P: ["ii", "IV"], D: ["V"] });
822
+ var m = getProgFactory({ T: ["i", "VI"], P: ["ii", "iv"], D: ["V"] });
823
+ var progression = (scaleType, count = 4) => {
824
+ if (scaleType === "major" || scaleType === "M") {
825
+ return M(count);
826
+ }
827
+ if (scaleType === "minor" || scaleType === "m") {
828
+ return m(count);
829
+ }
830
+ return [];
831
+ };
832
+
833
+ // src/channel/effects-chain.ts
834
+ function initEffects(instrument, context, params) {
835
+ context = context || Tone.getContext();
836
+ const createEffect = (effect) => {
837
+ return new Promise((resolve, _reject) => {
838
+ if (typeof effect === "string") {
839
+ resolve(
840
+ new Tone[effect]({
841
+ context
842
+ })
843
+ );
844
+ } else if (effect.context !== context) {
845
+ return recreateToneObjectInContext(
846
+ effect,
847
+ context
848
+ );
849
+ } else {
850
+ resolve(effect);
851
+ }
852
+ }).then((effectOut) => {
853
+ return effectOut.toDestination();
854
+ });
855
+ };
856
+ const startEffect = (eff) => {
857
+ return typeof eff.start === "function" ? eff.start() : eff;
858
+ };
859
+ const toArray = (someVal) => {
860
+ if (!someVal) {
861
+ return [];
862
+ }
863
+ if (Array.isArray(someVal)) {
864
+ return someVal;
865
+ }
866
+ return [someVal];
867
+ };
868
+ const effectsIn = toArray(params.effects);
869
+ if (params.external) {
870
+ if (effectsIn.length !== 0) {
871
+ throw new Error("Effects cannot be used with external output");
872
+ }
873
+ return Promise.resolve();
874
+ }
875
+ return Promise.all(effectsIn.map(createEffect)).then((results) => results.map(startEffect)).then((effects) => {
876
+ instrument.chain(...effects).toDestination();
877
+ });
878
+ }
879
+
880
+ // src/channel.ts
881
+ var getNextPos = (clip2) => {
882
+ const transportPosTicks = Tone.Transport.ticks;
883
+ if (transportPosTicks < Tone.Ticks("4n").toTicks()) {
884
+ return 0;
885
+ }
886
+ const align = clip2?.align || "1m";
887
+ const alignOffset = clip2?.alignOffset || "0";
888
+ const alignTicks = Tone.Ticks(align).toTicks();
889
+ const alignOffsetTicks = Tone.Ticks(alignOffset).toTicks();
890
+ const nextPosTicks = Tone.Ticks(
891
+ Math.floor(transportPosTicks / alignTicks + 1) * alignTicks + alignOffsetTicks
892
+ );
893
+ return nextPosTicks;
894
+ };
895
+ var Channel = class {
896
+ constructor(params) {
897
+ this.idx = params.idx || 0;
898
+ this.name = params.name || `ch ${params.idx}`;
899
+ this.activePatternIdx = -1;
900
+ this.channelClips = [];
901
+ this.clipNoteCount = 0;
902
+ const { clips, samples, sample, synth, ...params1 } = params;
903
+ const { external, sampler, buffer, ...params2 } = params1;
904
+ const { player, instrument, volume, ...params3 } = params2;
905
+ const { eventCb, playerCb, effects, ...params4 } = params3;
906
+ const { context = Tone.getContext(), ...originalParamsFiltered } = params4;
907
+ this.eventCbFn = eventCb;
908
+ this.playerCbFn = playerCb;
909
+ this.hasLoaded = false;
910
+ this.hasFailed = false;
911
+ const result = createInstrument(context, params, {
912
+ idx: this.idx,
913
+ name: this.name
914
+ });
915
+ this.instrument = result.instrument;
916
+ this.external = result.external;
917
+ this.initializerTask = result.initPromise.then((finalInstrument) => {
918
+ this.instrument = finalInstrument;
919
+ return initEffects(this.instrument, context, params);
920
+ });
921
+ let clipsFailed = false;
922
+ try {
923
+ (params.clips ?? []).forEach((c, i) => {
924
+ try {
925
+ this.addClip({
926
+ ...c,
927
+ ...originalParamsFiltered
928
+ });
929
+ } catch (e) {
930
+ throw new Error(
931
+ `${errorHasMessage(e) ? e.message : e} in clip ${i + 1}`
932
+ );
933
+ }
934
+ }, this);
935
+ } catch (e) {
936
+ clipsFailed = e;
937
+ }
938
+ this.initializerTask.then(() => {
939
+ if (clipsFailed) {
940
+ throw clipsFailed;
941
+ }
942
+ this.hasLoaded = true;
943
+ this.eventCb("loaded", {});
944
+ }).catch((e) => {
945
+ this.hasFailed = e;
946
+ this.eventCb("error", { e });
947
+ });
948
+ }
949
+ /** Set the global transport tempo in BPM. */
950
+ static setTransportTempo(valueBpm) {
951
+ Tone.Transport.bpm.value = valueBpm;
952
+ }
953
+ /** Resume the audio context and start the global transport. */
954
+ static startTransport() {
955
+ Tone.start();
956
+ Tone.Transport.start();
957
+ }
958
+ /**
959
+ * Stop the global transport.
960
+ * @param deleteEvents - If true (default), cancels all scheduled transport events.
961
+ */
962
+ static stopTransport(deleteEvents = true) {
963
+ Tone.Transport.stop();
964
+ if (deleteEvents) {
965
+ Tone.Transport.cancel();
966
+ }
967
+ }
968
+ /** Set the volume (in dB) of this channel's instrument and external output. */
969
+ setVolume(volume) {
970
+ if (this.instrument) {
971
+ this.instrument.volume.value = volume;
972
+ }
973
+ if (this.external) {
974
+ this.external.setVolume?.(volume);
975
+ }
976
+ }
977
+ /**
978
+ * Start the clip at the given index, stopping any other active clip first.
979
+ * @param idx - Clip index in this channel
980
+ * @param position - Transport time to start at; defaults to the next aligned position
981
+ */
982
+ startClip(idx, position) {
983
+ const clip2 = this.channelClips[idx];
984
+ position = position || (position === 0 ? 0 : getNextPos(clip2));
985
+ if (this.activePatternIdx > -1 && this.activePatternIdx !== idx) {
986
+ this.stopClip(this.activePatternIdx, position);
987
+ }
988
+ if (clip2 && clip2.state !== "started") {
989
+ this.counterResetTask = Tone.Transport.scheduleOnce(
990
+ () => {
991
+ this.clipNoteCount = 0;
992
+ },
993
+ position
994
+ );
995
+ this.activePatternIdx = idx;
996
+ clip2?.start(position);
997
+ }
998
+ }
999
+ /**
1000
+ * Stop the clip at the given index.
1001
+ * @param idx - Clip index in this channel
1002
+ * @param position - Transport time to stop at; defaults to the next aligned position
1003
+ */
1004
+ stopClip(idx, position) {
1005
+ const clip2 = this.channelClips[idx];
1006
+ position = position || (position === 0 ? 0 : getNextPos(clip2));
1007
+ clip2?.stop(position);
1008
+ if (idx === this.activePatternIdx) {
1009
+ this.activePatternIdx = -1;
1010
+ }
1011
+ }
1012
+ /**
1013
+ * Add a clip to this channel. If the clip has a pattern, a Tone.Sequence is
1014
+ * created; otherwise an empty (null) slot is reserved.
1015
+ * @param clipParams - Clip configuration
1016
+ * @param idx - Slot index; defaults to the next available position
1017
+ */
1018
+ addClip(clipParams, idx) {
1019
+ idx = idx || this.channelClips.length;
1020
+ if (clipParams.pattern) {
1021
+ this.channelClips[idx] = clip(
1022
+ {
1023
+ ...clipParams
1024
+ },
1025
+ this
1026
+ );
1027
+ const seq = this.channelClips[idx];
1028
+ if (seq && clipParams.align) seq.align = clipParams.align;
1029
+ if (seq && clipParams.alignOffset)
1030
+ seq.alignOffset = clipParams.alignOffset;
1031
+ } else {
1032
+ this.channelClips[idx] = null;
1033
+ }
1034
+ }
1035
+ /**
1036
+ * @param {Object} ClipParams clip parameters
1037
+ * @return {Function} function that can be used as the callback in Tone.Sequence https://tonejs.github.io/docs/Sequence
1038
+ */
1039
+ getSeqFn(params) {
1040
+ return buildSequenceCallback(
1041
+ params,
1042
+ this,
1043
+ (p) => this.playerCb(p),
1044
+ (e, p) => this.eventCb(e, p)
1045
+ );
1046
+ }
1047
+ /** Invoke the user-provided event callback, if set. */
1048
+ eventCb(event, params) {
1049
+ if (typeof this.eventCbFn === "function") {
1050
+ params.channel = this;
1051
+ this.eventCbFn(event, params);
1052
+ }
1053
+ }
1054
+ /** Invoke the user-provided player observer callback, if set. */
1055
+ playerCb(params) {
1056
+ if (typeof this.playerCbFn === "function") {
1057
+ params.channel = this;
1058
+ this.playerCbFn(params);
1059
+ }
1060
+ }
1061
+ /** All clips (sequences) belonging to this channel. */
1062
+ get clips() {
1063
+ return this.channelClips;
1064
+ }
1065
+ /** Index of the currently playing clip, or -1 if none. */
1066
+ get activeClipIdx() {
1067
+ return this.activePatternIdx;
1068
+ }
1069
+ };
1070
+
1071
+ // src/session.ts
1072
+ var Session = class {
1073
+ /** Create a session, optionally pre-populated with channels. */
1074
+ constructor(arr) {
1075
+ arr = arr || [];
1076
+ this.sessionChannels = arr.map((ch, i) => {
1077
+ ch.idx = ch.idx || i;
1078
+ ch.idx = this.uniqueIdx(this.sessionChannels, ch.idx);
1079
+ return new Channel(ch);
1080
+ });
1081
+ }
1082
+ /** Return a unique channel index, generating a new one if `idx` is taken or missing. */
1083
+ uniqueIdx(channels, idx) {
1084
+ if (!channels) {
1085
+ return idx || 0;
1086
+ }
1087
+ const idxs = channels.reduce((acc, c) => {
1088
+ return !acc.find((i) => i === c.idx) && acc.concat(c.idx) || acc;
1089
+ }, []);
1090
+ if (!idx || idxs.find((i) => i === idx)) {
1091
+ let newIdx = channels.length;
1092
+ while (idxs.find((i) => i === newIdx)) {
1093
+ newIdx = newIdx + 1;
1094
+ }
1095
+ return newIdx;
1096
+ }
1097
+ return idx;
1098
+ }
1099
+ /** Create a new channel with a unique index and add it to the session. */
1100
+ createChannel(ch) {
1101
+ ch.idx = this.uniqueIdx(this.sessionChannels, ch.idx);
1102
+ const newChannel = new Channel(ch);
1103
+ this.sessionChannels.push(newChannel);
1104
+ return newChannel;
1105
+ }
1106
+ /** All channels in this session. */
1107
+ get channels() {
1108
+ return this.sessionChannels;
1109
+ }
1110
+ /** Set the global transport tempo in BPM. */
1111
+ setTransportTempo(valueBpm) {
1112
+ Channel.setTransportTempo(valueBpm);
1113
+ }
1114
+ /** Resume the audio context and start the global transport. */
1115
+ startTransport() {
1116
+ Channel.startTransport();
1117
+ }
1118
+ /**
1119
+ * Stop the global transport.
1120
+ * @param deleteEvents - If true (default), cancels all scheduled transport events.
1121
+ */
1122
+ stopTransport(deleteEvents = true) {
1123
+ Channel.stopTransport(deleteEvents);
1124
+ }
1125
+ /** Start the clip at the given index across all channels simultaneously. */
1126
+ startRow(idx) {
1127
+ this.sessionChannels.forEach((ch) => {
1128
+ ch.startClip(idx);
1129
+ });
1130
+ }
1131
+ /**
1132
+ * Schedule clip playback across channels using a song-structure pattern.
1133
+ * Each channel pattern is a string where each character is a clip index
1134
+ * (or `-` for silence, `_` to sustain the previous clip).
1135
+ */
1136
+ play(params) {
1137
+ const channelPatterns = params.channelPatterns;
1138
+ const clipDuration = params.clipDuration || "4:0:0";
1139
+ const clipDurationInSeconds = Tone.Time(clipDuration).toSeconds();
1140
+ const stopClips = (clips, time) => {
1141
+ clips.forEach((c) => {
1142
+ c.stop(time);
1143
+ });
1144
+ };
1145
+ const startClips = (channelIdx, clipIdx, time) => {
1146
+ if (clipIdx === "-") return [];
1147
+ const clips = this.channels.filter((c) => c.idx === channelIdx).map((c) => c.clips[Number(clipIdx)]).filter((c) => c != null);
1148
+ for (const c of clips) c.start(time);
1149
+ return clips;
1150
+ };
1151
+ channelPatterns.forEach(({ channelIdx, pattern }) => {
1152
+ let clips = [];
1153
+ let time = 0;
1154
+ let prevClipIdx = "-";
1155
+ pattern.split("").forEach((clipIdx) => {
1156
+ if (clipIdx !== prevClipIdx && clipIdx !== "_") {
1157
+ stopClips(clips, time);
1158
+ clips = startClips(channelIdx, clipIdx, time);
1159
+ }
1160
+ prevClipIdx = clipIdx;
1161
+ time += clipDurationInSeconds;
1162
+ });
1163
+ stopClips(clips, time);
1164
+ });
1165
+ }
1166
+ };
1167
+ // Annotate the CommonJS export names for ESM import in node:
1168
+ 0 && (module.exports = {
1169
+ Session,
1170
+ arp,
1171
+ chord,
1172
+ chords,
1173
+ clip,
1174
+ getChordDegrees,
1175
+ getChordsByProgression,
1176
+ midi,
1177
+ mode,
1178
+ modes,
1179
+ progression,
1180
+ scale,
1181
+ scales
1182
+ });
1183
+ //# sourceMappingURL=browser.cjs.map