@stacksjs/stx 0.2.507 → 0.2.508
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import"./chunk-g495xx4v.js";import"./chunk-c57j92td.js";import"./chunk-xd4zvm4x.js";import"./chunk-g1r4v0mc.js";import"./chunk-ba88n1j7.js";import{U}from"./chunk-96kr2xrt.js";import"./chunk-9p3rtfbv.js";import"./chunk-5tbqdz94.js";import"./chunk-zz5b1g50.js";import"./chunk-v74acg2k.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import"./chunk-8xpyzcq2.js";import"./chunk-1verz406.js";import"./chunk-n34kagea.js";import"./chunk-67actssw.js";import"./chunk-jcmgj8kk.js";import"./chunk-2j04bc8c.js";import"./chunk-fwvqbx49.js";import"./chunk-xx2pk2ay.js";import"./chunk-cprcfp0j.js";import"./chunk-5zm23zrb.js";import"./chunk-4hz4g5ym.js";import"./chunk-h6q8jafh.js";import"./chunk-7p6y0b47.js";import"./chunk-01rz8h7x.js";import"./chunk-2wr0sk42.js";import"./chunk-46wre9ep.js";import"./chunk-qt31at4s.js";import"./chunk-ph1xz7k5.js";import"./chunk-38xtsdk9.js";import"./chunk-1c407nky.js";import"./chunk-3s9s1mdt.js";import"./chunk-s9mq9x2k.js";import"./chunk-2hc5mbw8.js";import{mt,ht}from"./chunk-s87qrma5.js";import"./chunk-0vnr7mz7.js";import"./chunk-9z8mxp15.js";import"./chunk-g7wgpys2.js";import"./chunk-068ank60.js";import"./chunk-rvwtyrj4.js";import"./chunk-5tkzfw4s.js";import"./chunk-ej46bkaw.js";import"./chunk-5dh041x0.js";import"./chunk-h37bbgg8.js";import{Ks,Xs,Gs,Js,hr,Ys,Zs,Qs,yr,br,Cn,En,$n}from"./chunk-w9mxt96c.js";import"./chunk-7sjmpfwy.js";import"./chunk-er7y8hk9.js";import{yi}from"./chunk-68tzytfz.js";import{d}from"./chunk-yn2d8x8m.js";import{spawn as R}from"child_process";import S from"fs";import M from"os";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.
|
|
3
|
+
import"./chunk-g495xx4v.js";import"./chunk-c57j92td.js";import"./chunk-xd4zvm4x.js";import"./chunk-g1r4v0mc.js";import"./chunk-ba88n1j7.js";import{U}from"./chunk-96kr2xrt.js";import"./chunk-9p3rtfbv.js";import"./chunk-5tbqdz94.js";import"./chunk-zz5b1g50.js";import"./chunk-v74acg2k.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import"./chunk-8xpyzcq2.js";import"./chunk-1verz406.js";import"./chunk-n34kagea.js";import"./chunk-67actssw.js";import"./chunk-jcmgj8kk.js";import"./chunk-2j04bc8c.js";import"./chunk-fwvqbx49.js";import"./chunk-xx2pk2ay.js";import"./chunk-cprcfp0j.js";import"./chunk-5zm23zrb.js";import"./chunk-4hz4g5ym.js";import"./chunk-h6q8jafh.js";import"./chunk-7p6y0b47.js";import"./chunk-01rz8h7x.js";import"./chunk-2wr0sk42.js";import"./chunk-46wre9ep.js";import"./chunk-qt31at4s.js";import"./chunk-ph1xz7k5.js";import"./chunk-38xtsdk9.js";import"./chunk-1c407nky.js";import"./chunk-3s9s1mdt.js";import"./chunk-s9mq9x2k.js";import"./chunk-2hc5mbw8.js";import{mt,ht}from"./chunk-s87qrma5.js";import"./chunk-0vnr7mz7.js";import"./chunk-9z8mxp15.js";import"./chunk-g7wgpys2.js";import"./chunk-068ank60.js";import"./chunk-rvwtyrj4.js";import"./chunk-5tkzfw4s.js";import"./chunk-ej46bkaw.js";import"./chunk-5dh041x0.js";import"./chunk-h37bbgg8.js";import{Ks,Xs,Gs,Js,hr,Ys,Zs,Qs,yr,br,Cn,En,$n}from"./chunk-w9mxt96c.js";import"./chunk-7sjmpfwy.js";import"./chunk-er7y8hk9.js";import{yi}from"./chunk-68tzytfz.js";import{d}from"./chunk-yn2d8x8m.js";import{spawn as R}from"child_process";import S from"fs";import M from"os";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.508";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new V("stx");function B(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(p<1024||p>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),i=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:i}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(p){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function z(h){let p=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(p))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(p<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(p>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),H=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,p=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(p)}function L(h){if(!h)return;let p;try{p=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof p!=="object"||p===null||Array.isArray(p))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(p))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return p}async function G(h,p){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let r=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(r.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...r),p.verbose)console.log(`Found ${r.length} file(s) matching pattern: ${c}`)}catch(r){return console.error(`Error expanding glob pattern ${c}:`,r),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),p.filter)x.push("--pattern",p.filter);if(p.timeout)x.push("--timeout",p.timeout.toString());if(p.reporter&&p.reporter!=="default")if(p.reporter==="junit"){let c=f.join(M.tmpdir(),`stx-test-report-${Date.now()}.xml`);x.push("--reporter",p.reporter),x.push("--reporter-outfile",c)}else console.warn(`Warning: Reporter '${p.reporter}' is not supported. Using default reporter.`);if(p.coverage)x.push("--coverage");if(p.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:p.ui?"true":"false",STX_TEST_VERBOSE:p.verbose?"true":"false"},o="bun";if(p.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let i=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(r)=>{let u=((performance.now()-i)/1000).toFixed(2);if(r===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
|
|
4
4
|
Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var J=n.argv.length>=3&&(H(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(J){let h=n.argv[2],p={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=B(n.argv[++x]);if(!e.isValid)F(e);p.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")p.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!p.markdown)p.markdown={};if(!p.markdown.syntaxHighlighting)p.markdown.syntaxHighlighting={};p.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")p.cache=!1;else if(t==="--native")p.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),r=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of r)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await En(t,p))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Cn(h,p).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let i=0;i<=e.length;i++)o[i]=[i];for(let i=0;i<=t.length;i++)o[0][i]=i;for(let i=1;i<=e.length;i++)for(let s=1;s<=t.length;s++)if(e.charAt(i-1)===t.charAt(s-1))o[i][s]=o[i-1][s-1];else o[i][s]=Math.min(o[i-1][s-1]+1,o[i][s-1]+1,o[i-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await Js(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:i}=await import("./chunk-ktvr45qg.js");if(t==="list"){console.log(`
|
|
5
5
|
\uD83D\uDCDA Fetching available icon collections...
|
|
6
6
|
`);let s=await o(),c=Object.entries(s).sort((r,l)=>l[1].total-r[1].total);console.log(`Available collections:
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How loud the music is at `now` under a fade, for a set `level`: the level
|
|
3
|
+
* until the fade starts, falling in a straight line to nothing at its end.
|
|
4
|
+
*/
|
|
5
|
+
export declare function fadedLevel(level: number, now: number, fade: AmbientFade | null): number;
|
|
1
6
|
/** A fresh ambient sound engine; nothing plays until `start` is called from a user gesture. */
|
|
2
7
|
export declare function useAmbientSound(): AmbientSound;
|
|
8
|
+
/** A fade to silence on the audio clock: level held until `start`, zero at `end` (context seconds). */
|
|
9
|
+
export declare interface AmbientFade { start: number, end: number }
|
|
3
10
|
/**
|
|
4
11
|
* useAmbientSound - music for breathing, meditation and focus, synthesised
|
|
5
12
|
* on the device as it plays
|
|
@@ -14,7 +21,14 @@ export declare function useAmbientSound(): AmbientSound;
|
|
|
14
21
|
* house ~118 bpm: soft kick, off-beat hats and bass, pads
|
|
15
22
|
* electronic ~100 bpm: plucked arpeggios through a delay, light drums
|
|
16
23
|
* drone low drones and dark noise, for sleep
|
|
24
|
+
* rain steady rain on leaves and a roof, with the odd nearer drop
|
|
25
|
+
* ocean long, slow swells on a far shore, no melody
|
|
26
|
+
* brown even brown noise, the plainest bed to fall asleep to
|
|
17
27
|
*
|
|
28
|
+
* Every bed plays until stopped, so a sleep session can run for an hour.
|
|
29
|
+
* `fadeOut(seconds, after)` is a sleep timer: the fade is scheduled on the
|
|
30
|
+
* audio clock, so it happens with the screen locked and the page asleep, and
|
|
31
|
+
* it pauses with `suspend()`.
|
|
18
32
|
* Breath tones (rising on the in-breath, falling on the out) and a chime play
|
|
19
33
|
* on their own bus, so they stay audible at any music level.
|
|
20
34
|
*
|
|
@@ -30,12 +44,16 @@ export declare function useAmbientSound(): AmbientSound;
|
|
|
30
44
|
* await sound.stop()
|
|
31
45
|
* ```
|
|
32
46
|
*/
|
|
33
|
-
export type AmbientGenre = 'ambient' | 'nature' | 'house' | 'electronic' | 'drone';
|
|
47
|
+
export type AmbientGenre = 'ambient' | 'nature' | 'house' | 'electronic' | 'drone' | 'rain' | 'ocean' | 'brown';
|
|
34
48
|
export declare class AmbientSound {
|
|
35
49
|
get playing(): boolean;
|
|
36
50
|
start(genre: AmbientGenre | 'none', volume?: unknown): Promise<void>;
|
|
37
51
|
prepare(): Promise<boolean>;
|
|
38
52
|
volume(value: number): void;
|
|
53
|
+
fadeOut(seconds: number, after?: number): void;
|
|
54
|
+
cancelFade(): void;
|
|
55
|
+
get fadeSchedule(): AmbientFade | null;
|
|
56
|
+
get faded(): boolean;
|
|
39
57
|
suspend(): Promise<void>;
|
|
40
58
|
resume(): Promise<void>;
|
|
41
59
|
breathTone(kind: 'in' | 'out' | 'hold', seconds: number): void;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export function fadedLevel(level, now, fade) {
|
|
2
|
+
if (!fade || now <= fade.start)
|
|
3
|
+
return level;
|
|
4
|
+
if (now >= fade.end)
|
|
5
|
+
return 0;
|
|
6
|
+
return level * (fade.end - now) / (fade.end - fade.start);
|
|
7
|
+
}
|
|
1
8
|
const CHORDS = [
|
|
2
9
|
[50, 57, 62, 66, 69],
|
|
3
10
|
[47, 54, 59, 62, 66],
|
|
@@ -17,9 +24,11 @@ export class AmbientSound {
|
|
|
17
24
|
voices = new Set;
|
|
18
25
|
noise = null;
|
|
19
26
|
white = null;
|
|
27
|
+
hiss = null;
|
|
20
28
|
genre = null;
|
|
21
29
|
level = 0.5;
|
|
22
30
|
generation = 0;
|
|
31
|
+
fade = null;
|
|
23
32
|
get playing() {
|
|
24
33
|
return !!this.context && !!this.genre;
|
|
25
34
|
}
|
|
@@ -35,15 +44,20 @@ export class AmbientSound {
|
|
|
35
44
|
return;
|
|
36
45
|
}
|
|
37
46
|
this.genre = genre;
|
|
38
|
-
|
|
39
|
-
this.music.gain.
|
|
40
|
-
this.music.gain.
|
|
47
|
+
const now = context.currentTime;
|
|
48
|
+
this.music.gain.cancelScheduledValues(now);
|
|
49
|
+
this.music.gain.setValueAtTime(0, now);
|
|
50
|
+
this.music.gain.linearRampToValueAtTime(fadedLevel(this.level, now + 1.5, this.fade), now + 1.5);
|
|
51
|
+
this.continueFade(now + 1.5);
|
|
41
52
|
({
|
|
42
53
|
ambient: (c) => this.ambient(c),
|
|
43
54
|
nature: (c) => this.nature(c),
|
|
44
55
|
house: (c) => this.house(c),
|
|
45
56
|
electronic: (c) => this.electronic(c),
|
|
46
|
-
drone: (c) => this.drone(c)
|
|
57
|
+
drone: (c) => this.drone(c),
|
|
58
|
+
rain: (c) => this.rain(c),
|
|
59
|
+
ocean: (c) => this.ocean(c),
|
|
60
|
+
brown: (c) => this.brown(c)
|
|
47
61
|
})[genre](context);
|
|
48
62
|
}
|
|
49
63
|
async prepare() {
|
|
@@ -51,9 +65,36 @@ export class AmbientSound {
|
|
|
51
65
|
}
|
|
52
66
|
volume(value) {
|
|
53
67
|
this.level = clamp(value);
|
|
54
|
-
if (this.context
|
|
68
|
+
if (!this.context || !this.music || !this.genre)
|
|
69
|
+
return;
|
|
70
|
+
if (this.fade)
|
|
71
|
+
this.scheduleFade(this.context, this.context.currentTime);
|
|
72
|
+
else
|
|
55
73
|
this.music.gain.setTargetAtTime(this.level, this.context.currentTime, 0.2);
|
|
56
74
|
}
|
|
75
|
+
fadeOut(seconds, after = 0) {
|
|
76
|
+
const context = this.context;
|
|
77
|
+
if (!context)
|
|
78
|
+
return;
|
|
79
|
+
const now = context.currentTime, start = now + Math.max(0, Number.isFinite(after) ? after : 0);
|
|
80
|
+
this.fade = { start, end: start + Math.max(0.05, Number.isFinite(seconds) ? seconds : 0) };
|
|
81
|
+
if (this.music && this.genre)
|
|
82
|
+
this.scheduleFade(context, now);
|
|
83
|
+
}
|
|
84
|
+
cancelFade() {
|
|
85
|
+
this.fade = null;
|
|
86
|
+
const context = this.context;
|
|
87
|
+
if (!context || !this.music || !this.genre)
|
|
88
|
+
return;
|
|
89
|
+
this.music.gain.cancelScheduledValues(context.currentTime);
|
|
90
|
+
this.music.gain.setTargetAtTime(this.level, context.currentTime, 0.3);
|
|
91
|
+
}
|
|
92
|
+
get fadeSchedule() {
|
|
93
|
+
return this.fade ? { ...this.fade } : null;
|
|
94
|
+
}
|
|
95
|
+
get faded() {
|
|
96
|
+
return !!this.fade && !!this.context && this.context.currentTime >= this.fade.end;
|
|
97
|
+
}
|
|
57
98
|
async suspend() {
|
|
58
99
|
if (this.context?.state === "running")
|
|
59
100
|
await this.context.suspend().catch(() => {});
|
|
@@ -111,6 +152,7 @@ export class AmbientSound {
|
|
|
111
152
|
const context = this.context;
|
|
112
153
|
this.context = null;
|
|
113
154
|
this.genre = null;
|
|
155
|
+
this.fade = null;
|
|
114
156
|
for (const timer of this.timers)
|
|
115
157
|
clearInterval(timer);
|
|
116
158
|
this.timers = [];
|
|
@@ -118,6 +160,7 @@ export class AmbientSound {
|
|
|
118
160
|
this.music = null;
|
|
119
161
|
this.tones = null;
|
|
120
162
|
this.reverb = null;
|
|
163
|
+
this.hiss = null;
|
|
121
164
|
if (context && context.state !== "closed")
|
|
122
165
|
await context.close().catch(() => {});
|
|
123
166
|
}
|
|
@@ -155,6 +198,22 @@ export class AmbientSound {
|
|
|
155
198
|
this.white = this.whiteBuffer(context, 1);
|
|
156
199
|
return context;
|
|
157
200
|
}
|
|
201
|
+
scheduleFade(context, from) {
|
|
202
|
+
const gain = this.music?.gain;
|
|
203
|
+
if (!this.fade || !gain)
|
|
204
|
+
return;
|
|
205
|
+
gain.cancelScheduledValues(from);
|
|
206
|
+
gain.setValueAtTime(fadedLevel(this.level, from, this.fade), from);
|
|
207
|
+
this.continueFade(from);
|
|
208
|
+
}
|
|
209
|
+
continueFade(from) {
|
|
210
|
+
const fade = this.fade, gain = this.music?.gain;
|
|
211
|
+
if (!fade || !gain)
|
|
212
|
+
return;
|
|
213
|
+
if (from < fade.start)
|
|
214
|
+
gain.setValueAtTime(this.level, fade.start);
|
|
215
|
+
gain.linearRampToValueAtTime(0, Math.max(fade.end, from + 0.05));
|
|
216
|
+
}
|
|
158
217
|
stopMusic(at) {
|
|
159
218
|
for (const timer of this.timers)
|
|
160
219
|
clearInterval(timer);
|
|
@@ -372,6 +431,65 @@ export class AmbientSound {
|
|
|
372
431
|
}
|
|
373
432
|
});
|
|
374
433
|
}
|
|
434
|
+
rain(context) {
|
|
435
|
+
this.whiteBed(context, "bandpass", 2400, 0.07, 0.5, 23, 0.25);
|
|
436
|
+
this.whiteBed(context, "lowpass", 900, 0.08, 0.4, 31, 0.3);
|
|
437
|
+
this.noiseBed(context, "lowpass", 220, 0.12, 19, 0.35);
|
|
438
|
+
this.every(400, () => {
|
|
439
|
+
if (!this.context || Math.random() > 0.45)
|
|
440
|
+
return;
|
|
441
|
+
const at = context.currentTime + Math.random() * 0.4, source = context.createBufferSource();
|
|
442
|
+
source.buffer = this.white;
|
|
443
|
+
const filter = context.createBiquadFilter();
|
|
444
|
+
filter.type = "bandpass";
|
|
445
|
+
filter.frequency.value = 1800 + Math.random() * 2600;
|
|
446
|
+
filter.Q.value = 4;
|
|
447
|
+
const gain = context.createGain(), level = 0.01 + Math.random() * 0.025;
|
|
448
|
+
gain.gain.setValueAtTime(0, at);
|
|
449
|
+
gain.gain.linearRampToValueAtTime(level, at + 0.004);
|
|
450
|
+
gain.gain.exponentialRampToValueAtTime(0.0001, at + 0.06);
|
|
451
|
+
source.connect(filter).connect(gain).connect(this.music);
|
|
452
|
+
source.start(at, Math.random() * 0.8, 0.08);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
ocean(context) {
|
|
456
|
+
this.noiseBed(context, "lowpass", 420, 0.2, 11, 0.9);
|
|
457
|
+
this.noiseBed(context, "lowpass", 1100, 0.06, 13, 0.95);
|
|
458
|
+
this.whiteBed(context, "highpass", 3200, 0.012, 0.6, 11, 0.95);
|
|
459
|
+
}
|
|
460
|
+
brown(context) {
|
|
461
|
+
this.noiseBed(context, "lowpass", 500, 0.24, 40, 0.06);
|
|
462
|
+
}
|
|
463
|
+
whiteBed(context, type, frequency, level, q, swellSeconds, depth) {
|
|
464
|
+
this.hiss ||= this.whiteBuffer(context, 6);
|
|
465
|
+
const source = context.createBufferSource();
|
|
466
|
+
source.buffer = this.hiss;
|
|
467
|
+
source.loop = !0;
|
|
468
|
+
const filter = context.createBiquadFilter();
|
|
469
|
+
filter.type = type;
|
|
470
|
+
filter.frequency.value = frequency;
|
|
471
|
+
filter.Q.value = q;
|
|
472
|
+
const gain = context.createGain();
|
|
473
|
+
gain.gain.value = level;
|
|
474
|
+
const lfo = context.createOscillator();
|
|
475
|
+
lfo.frequency.value = 1 / swellSeconds;
|
|
476
|
+
const lfoGain = context.createGain();
|
|
477
|
+
lfoGain.gain.value = level * depth;
|
|
478
|
+
lfo.connect(lfoGain).connect(gain.gain);
|
|
479
|
+
source.connect(filter).connect(gain).connect(this.music);
|
|
480
|
+
const start = context.currentTime;
|
|
481
|
+
source.start(start, Math.random() * 5);
|
|
482
|
+
lfo.start(start);
|
|
483
|
+
this.voices.add({
|
|
484
|
+
stop: (at) => {
|
|
485
|
+
gain.gain.setTargetAtTime(0, context.currentTime, 0.4);
|
|
486
|
+
try {
|
|
487
|
+
source.stop(at);
|
|
488
|
+
lfo.stop(at);
|
|
489
|
+
} catch {}
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
}
|
|
375
493
|
house(context) {
|
|
376
494
|
const bpm = 118, bar = 60 / bpm * 4;
|
|
377
495
|
let lastChord = -1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.508",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -122,12 +122,12 @@
|
|
|
122
122
|
"dependencies": {
|
|
123
123
|
"@stacksjs/ts-css": "^0.3.11",
|
|
124
124
|
"@stacksjs/clapp": "^0.2.16",
|
|
125
|
-
"@stacksjs/desktop": "0.2.
|
|
126
|
-
"@stacksjs/sanitizer": "0.2.
|
|
125
|
+
"@stacksjs/desktop": "0.2.508",
|
|
126
|
+
"@stacksjs/sanitizer": "0.2.508",
|
|
127
127
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
128
|
-
"bun-plugin-stx": "0.2.
|
|
128
|
+
"bun-plugin-stx": "0.2.508",
|
|
129
129
|
"bunfig": "^0.15.19",
|
|
130
|
-
"stx-router": "0.2.
|
|
130
|
+
"stx-router": "0.2.508",
|
|
131
131
|
"ts-broadcasting": "^0.0.11",
|
|
132
132
|
"ts-images": "^0.2.22",
|
|
133
133
|
"ts-syntax-highlighter": "^0.2.1"
|