gulp-mu-gulp-api 0.3.3 → 0.3.5
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/README.md +52 -10
- package/package.json +1 -1
- package/src/index.mjs +57 -16
package/README.md
CHANGED
|
@@ -32,6 +32,11 @@ The module is deliberately **dependency-free** and knows nothing about µGulp™
|
|
|
32
32
|
npm install gulp-mu-gulp-api
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
### 0.3.5
|
|
36
|
+
|
|
37
|
+
- **Added** `PlaySound(sample, { loop? })` and `StopSound(sample)` — play named samples from the dashboard µAU sound atlas; `loop: true` repeats until `StopSound`.
|
|
38
|
+
- **Changed** npm README: clearer i18x section (`Log`/`Warn` vs `.i18xTrans()` / `.i18xRegister()`).
|
|
39
|
+
|
|
35
40
|
### 0.3.3
|
|
36
41
|
|
|
37
42
|
- **Changed** npm README: centered µGulp logo and µGulp ready badge (absolute raw URLs from the µGulp repo).
|
|
@@ -50,7 +55,7 @@ npm install gulp-mu-gulp-api
|
|
|
50
55
|
## Usage
|
|
51
56
|
|
|
52
57
|
```javascript
|
|
53
|
-
import { ReportProgress, CreateProgress, PlaySignal, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm, IsMicroGulp, IsµGulp, InstallStringExtensions } from 'gulp-mu-gulp-api';
|
|
58
|
+
import { ReportProgress, CreateProgress, PlaySignal, PlaySound, StopSound, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm, IsMicroGulp, IsµGulp, InstallStringExtensions } from 'gulp-mu-gulp-api';
|
|
54
59
|
|
|
55
60
|
// Enables "phrase<context=\"…\"/>".i18xRegister()/.i18xTrans() on strings.
|
|
56
61
|
InstallStringExtensions();
|
|
@@ -77,7 +82,10 @@ export async function BUILD_THEME() {
|
|
|
77
82
|
progress.Done();
|
|
78
83
|
|
|
79
84
|
// sound + speech (rendered by the dashboard, configured in its settings)
|
|
80
|
-
PlaySignal('success');
|
|
85
|
+
PlaySignal('success'); // preset: success | error | attention
|
|
86
|
+
PlaySound('success'); // named atlas sample
|
|
87
|
+
PlaySound('engine', { loop: true }); // loop until StopSound('engine')
|
|
88
|
+
StopSound('engine');
|
|
81
89
|
Speak('Theme build finished.');
|
|
82
90
|
}
|
|
83
91
|
BUILD_THEME.µDisplayName = 'Build Theme<context="µDisplayName"/>'.i18xRegister();
|
|
@@ -106,12 +114,16 @@ let values = await RequestForm({
|
|
|
106
114
|
| :--- | :--- |
|
|
107
115
|
| `IsMicroGulp()` / `IsµGulp()` | `true` when the task runs under µGulp™ with an attached dashboard |
|
|
108
116
|
| `InstallStringExtensions()` | Installs µLib-compatible `String.prototype.i18xTrans()`/`i18xRegister()` (auto-run on import) |
|
|
109
|
-
| `Log(text, values?)` / `Warn` / `LogError` | Localized `console.*` via i18x (`<context="task log"/>` etc.) |
|
|
110
|
-
| `Translate(text, values?)` |
|
|
117
|
+
| `Log(text, values?)` / `Warn` / `LogError` | Localized `console.*` via i18x (`<context="task log"/>` etc.) — preferred for task log output |
|
|
118
|
+
| `Translate(text, values?)` | Low-level: returns the translated string without logging (rarely needed directly) |
|
|
119
|
+
| `"phrase".i18xTrans(values?)` | Prototype sugar for `Translate` — same result, ergonomic in expressions |
|
|
120
|
+
| `"phrase".i18xRegister()` | Registers metadata text (returns the source phrase unchanged as the i18x key) |
|
|
111
121
|
| `GetLid()` / `SetLid(lid?)` | Active language id; `SetLid` clears to automatic when omitted |
|
|
112
122
|
| `ReportProgress(value, label?)` | Report progress `0..1` to the task progress bar |
|
|
113
123
|
| `CreateProgress(label?)` | Reporter object with `Update(value, stepLabel?)` and `Done()` |
|
|
114
|
-
| `PlaySignal(signal?)` |
|
|
124
|
+
| `PlaySignal(signal?)` | Preset acoustic signal: `'success'` \| `'error'` \| `'attention'` (default) |
|
|
125
|
+
| `PlaySound(sample, options?)` | Named sample from the dashboard sound atlas; `options.loop` repeats until `StopSound` |
|
|
126
|
+
| `StopSound(sample)` | Stops a looping sample started with `PlaySound(sample, { loop: true })` |
|
|
115
127
|
| `Speak(text, options?)` | Speech output in the dashboard; `options`: `{ rate?, pitch?, volume? }` per-call overrides |
|
|
116
128
|
| `RequestForm(form)` | Request a complete form; resolves with `{ fieldId: value, … }` |
|
|
117
129
|
| `RequestTextInput(options)` | Single text field (with `validate` rules) |
|
|
@@ -172,6 +184,7 @@ A field descriptor is `{ id, type, label, default?, options?, validate?, min?, m
|
|
|
172
184
|
| :--- | :--- | :--- |
|
|
173
185
|
| `ReportProgress` | updating progress line | log line every 10% step |
|
|
174
186
|
| `PlaySignal` | terminal bell (`attention`/`error`) | silent |
|
|
187
|
+
| `PlaySound` / `StopSound` | `[sound] <name>` log line | silent |
|
|
175
188
|
| `Speak` | `[speech]` log line | `[speech]` log line |
|
|
176
189
|
| text/password/number/range input | readline prompt (Enter = default) | default value |
|
|
177
190
|
| font/select/radio input | numbered list + readline | default value |
|
|
@@ -183,6 +196,22 @@ Sound and speech playback (mute, volume, speech rate/pitch) is configured centra
|
|
|
183
196
|
|
|
184
197
|
MIT — © 2026 Meinolf Amekudzi
|
|
185
198
|
|
|
199
|
+
### Publishing (maintainers)
|
|
200
|
+
|
|
201
|
+
From the µGulp repo root (requires `npm login` and 2FA OTP when enabled):
|
|
202
|
+
|
|
203
|
+
```powershell
|
|
204
|
+
# PowerShell
|
|
205
|
+
$env:NPM_OTP="123456"
|
|
206
|
+
npm run publish:api
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
NPM_OTP=123456 npm run publish:api
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Bump `gulp-mu-gulp-api/package.json` before publishing. The task runs the module tests first.
|
|
214
|
+
|
|
186
215
|
---
|
|
187
216
|
|
|
188
217
|
# Deutsch
|
|
@@ -199,6 +228,11 @@ Das Modul ist bewusst **abhängigkeitsfrei** und kennt keine µGulp™-Interna:
|
|
|
199
228
|
npm install gulp-mu-gulp-api
|
|
200
229
|
```
|
|
201
230
|
|
|
231
|
+
### 0.3.5
|
|
232
|
+
|
|
233
|
+
- **Neu** `PlaySound(sample, { loop? })` und `StopSound(sample)` — benannte Samples aus dem Dashboard-µAU-Sound-Atlas; `loop: true` wiederholt bis `StopSound`.
|
|
234
|
+
- **Geändert** npm-README: klarere i18x-Sektion (`Log`/`Warn` vs. `.i18xTrans()` / `.i18xRegister()`).
|
|
235
|
+
|
|
202
236
|
### 0.3.3
|
|
203
237
|
|
|
204
238
|
- **Geändert** npm-README: zentriertes µGulp-Logo und µGulp-ready-Badge (absolute raw-URLs aus dem µGulp-Repo).
|
|
@@ -217,7 +251,7 @@ npm install gulp-mu-gulp-api
|
|
|
217
251
|
## Verwendung
|
|
218
252
|
|
|
219
253
|
```javascript
|
|
220
|
-
import { ReportProgress, CreateProgress, PlaySignal, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm, IsMicroGulp, IsµGulp, InstallStringExtensions } from 'gulp-mu-gulp-api';
|
|
254
|
+
import { ReportProgress, CreateProgress, PlaySignal, PlaySound, StopSound, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm, IsMicroGulp, IsµGulp, InstallStringExtensions } from 'gulp-mu-gulp-api';
|
|
221
255
|
|
|
222
256
|
// Enables "phrase<context=\"…\"/>".i18xRegister()/.i18xTrans() on strings.
|
|
223
257
|
InstallStringExtensions();
|
|
@@ -244,7 +278,10 @@ export async function BUILD_THEME() {
|
|
|
244
278
|
progress.Done();
|
|
245
279
|
|
|
246
280
|
// sound + speech (rendered by the dashboard, configured in its settings)
|
|
247
|
-
PlaySignal('success');
|
|
281
|
+
PlaySignal('success'); // preset: success | error | attention
|
|
282
|
+
PlaySound('success'); // named atlas sample
|
|
283
|
+
PlaySound('engine', { loop: true }); // loop until StopSound('engine')
|
|
284
|
+
StopSound('engine');
|
|
248
285
|
Speak('Theme build finished.');
|
|
249
286
|
}
|
|
250
287
|
BUILD_THEME.µDisplayName = 'Build Theme<context="µDisplayName"/>'.i18xRegister();
|
|
@@ -273,12 +310,16 @@ let values = await RequestForm({
|
|
|
273
310
|
| :--- | :--- |
|
|
274
311
|
| `IsMicroGulp()` / `IsµGulp()` | `true`, wenn der Task unter µGulp™ mit angebundenem Dashboard läuft |
|
|
275
312
|
| `InstallStringExtensions()` | Installiert µLib-kompatible `String.prototype.i18xTrans()`/`i18xRegister()` (läuft beim Import automatisch) |
|
|
276
|
-
| `Log(text, values?)` / `Warn` / `LogError` | Lokalisierte `console.*`-Ausgabe über i18x
|
|
277
|
-
| `Translate(text, values?)` |
|
|
313
|
+
| `Log(text, values?)` / `Warn` / `LogError` | Lokalisierte `console.*`-Ausgabe über i18x — bevorzugt für Task-Logs |
|
|
314
|
+
| `Translate(text, values?)` | Low-Level: übersetzter String ohne Log (selten direkt nötig) |
|
|
315
|
+
| `"phrase".i18xTrans(values?)` | Prototype-Kurzform für `Translate` |
|
|
316
|
+
| `"phrase".i18xRegister()` | Metadaten-Text registrieren (gibt die Quellphrase unverändert zurück) |
|
|
278
317
|
| `GetLid()` / `SetLid(lid?)` | Aktive Sprach-ID; `SetLid` ohne Argument = automatische Auflösung |
|
|
279
318
|
| `ReportProgress(value, label?)` | Fortschritt `0..1` an die Task-Progressbar melden |
|
|
280
319
|
| `CreateProgress(label?)` | Reporter-Objekt mit `Update(value, stepLabel?)` und `Done()` |
|
|
281
|
-
| `PlaySignal(signal?)` |
|
|
320
|
+
| `PlaySignal(signal?)` | Vorgabe-Signal: `'success'` \| `'error'` \| `'attention'` (Default) |
|
|
321
|
+
| `PlaySound(sample, options?)` | Benanntes Sample aus dem Sound-Atlas; `options.loop` wiederholt bis `StopSound` |
|
|
322
|
+
| `StopSound(sample)` | Stoppt eine Schleife von `PlaySound(sample, { loop: true })` |
|
|
282
323
|
| `Speak(text, options?)` | Sprachausgabe im Dashboard; `options`: `{ rate?, pitch?, volume? }` je Aufruf |
|
|
283
324
|
| `RequestForm(form)` | Komplettes Formular anfordern; löst mit `{ fieldId: value, … }` auf |
|
|
284
325
|
| `RequestTextInput(options)` | Einzelnes Textfeld (mit `validate`-Regeln) |
|
|
@@ -339,6 +380,7 @@ Ein Feld-Deskriptor ist `{ id, type, label, default?, options?, validate?, min?,
|
|
|
339
380
|
| :--- | :--- | :--- |
|
|
340
381
|
| `ReportProgress` | aktualisierende Fortschrittszeile | Log-Zeile je 10-%-Schritt |
|
|
341
382
|
| `PlaySignal` | Terminal-Glocke (`attention`/`error`) | stumm |
|
|
383
|
+
| `PlaySound` / `StopSound` | `[sound]`-Log-Zeile | stumm |
|
|
342
384
|
| `Speak` | `[speech]`-Log-Zeile | `[speech]`-Log-Zeile |
|
|
343
385
|
| Text-/Passwort-/Zahlen-/Range-Eingabe | readline-Prompt (Enter = Default) | Default-Wert |
|
|
344
386
|
| Font-/Select-/Radio-Eingabe | nummerierte Liste + readline | Default-Wert |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gulp-mu-gulp-api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Public task API for the µGulp orchestrator: progress reporting, sound signals, speech output, localized console output (i18x) and interactive UI inputs (text, password, number, textarea, color, font, select, radio, multi-select checkbox, range slider, date/time, file) from within gulp tasks — with graceful CLI fallbacks when running without µGulp.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.mjs",
|
package/src/index.mjs
CHANGED
|
@@ -43,7 +43,10 @@ const pendingUiRequests = new Map();
|
|
|
43
43
|
* attached dashboard (progress and inputs are rendered in the webview)
|
|
44
44
|
*/
|
|
45
45
|
export function IsMicroGulp() {
|
|
46
|
-
|
|
46
|
+
// The worker pool sets MICROGULP=1 for every forked task process. Relying
|
|
47
|
+
// only on process.send was too strict — some hosts still stream stdout
|
|
48
|
+
// correctly while structured IPC must be attempted separately.
|
|
49
|
+
return process.env.MICROGULP === '1';
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
/** Brand-aligned alias for {@link IsMicroGulp}. */
|
|
@@ -108,9 +111,12 @@ export function CreateProgress(_label) {
|
|
|
108
111
|
};
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
function _SendStructuredLog(_format, _payload) {
|
|
115
|
+
if (!IsMicroGulp()) return false;
|
|
116
|
+
if (typeof process.send !== 'function') return false;
|
|
117
|
+
process.send({ type: 'structured-log', format: _format, payload: _payload });
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
114
120
|
|
|
115
121
|
/**
|
|
116
122
|
* Sends a table to the dashboard log pane. The payload is JSON:
|
|
@@ -121,10 +127,7 @@ export function CreateProgress(_label) {
|
|
|
121
127
|
*/
|
|
122
128
|
export function LogTable(_spec) {
|
|
123
129
|
let payload = _NormalizeTableSpec(_spec);
|
|
124
|
-
if (
|
|
125
|
-
process.send({ type: 'structured-log', format: 'table', payload });
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
130
|
+
if (_SendStructuredLog('table', payload)) return;
|
|
128
131
|
console.log(_AsciiTable(payload));
|
|
129
132
|
}
|
|
130
133
|
|
|
@@ -137,10 +140,7 @@ export function LogTable(_spec) {
|
|
|
137
140
|
*/
|
|
138
141
|
export function LogTree(_spec) {
|
|
139
142
|
let payload = _NormalizeTreeSpec(_spec);
|
|
140
|
-
if (
|
|
141
|
-
process.send({ type: 'structured-log', format: 'tree', payload });
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
143
|
+
if (_SendStructuredLog('tree', payload)) return;
|
|
144
144
|
for (let line of _AsciiTreeLines(payload)) console.log(line);
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -153,10 +153,7 @@ export function LogTree(_spec) {
|
|
|
153
153
|
*/
|
|
154
154
|
export function LogGallery(_spec) {
|
|
155
155
|
let payload = _NormalizeGallerySpec(_spec);
|
|
156
|
-
if (
|
|
157
|
-
process.send({ type: 'structured-log', format: 'gallery', payload });
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
156
|
+
if (_SendStructuredLog('gallery', payload)) return;
|
|
160
157
|
console.log(_AsciiGallery(payload));
|
|
161
158
|
}
|
|
162
159
|
|
|
@@ -231,6 +228,48 @@ export function PlaySignal(_signal = 'attention') {
|
|
|
231
228
|
}
|
|
232
229
|
}
|
|
233
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Plays a named sample from the dashboard sound atlas (µAU). Sample names match
|
|
233
|
+
* the files bundled with µGulp (`success`, `error`, `attention`, or custom
|
|
234
|
+
* atlas entries in the consumer skin). When `loop` is true the sample repeats
|
|
235
|
+
* until `StopSound(sample)` is called.
|
|
236
|
+
*
|
|
237
|
+
* CLI fallback: logs `[sound] <name>` on a TTY, silent otherwise.
|
|
238
|
+
*
|
|
239
|
+
* @param {string} _sample atlas sample name (e.g. `'success'`)
|
|
240
|
+
* @param {object} [_options]
|
|
241
|
+
* @param {boolean} [_options.loop] repeat until stopped (default `false`)
|
|
242
|
+
*/
|
|
243
|
+
export function PlaySound(_sample, _options = {}) {
|
|
244
|
+
let sample = String(_sample ?? '').trim();
|
|
245
|
+
if (!sample) return;
|
|
246
|
+
if (IsMicroGulp()) {
|
|
247
|
+
process.send({ type: 'sound', sample, loop: !!_options.loop });
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (process.stdout.isTTY) {
|
|
251
|
+
console.log(`[sound] ${sample}${_options.loop ? ' (loop)' : ''}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Stops a looping sample started with `PlaySound(name, { loop: true })`.
|
|
257
|
+
* No-op for one-shot samples and outside µGulp (CLI logs `[sound-stop]` on TTY).
|
|
258
|
+
*
|
|
259
|
+
* @param {string} _sample atlas sample name passed to `PlaySound`
|
|
260
|
+
*/
|
|
261
|
+
export function StopSound(_sample) {
|
|
262
|
+
let sample = String(_sample ?? '').trim();
|
|
263
|
+
if (!sample) return;
|
|
264
|
+
if (IsMicroGulp()) {
|
|
265
|
+
process.send({ type: 'sound-stop', sample });
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (process.stdout.isTTY) {
|
|
269
|
+
console.log(`[sound-stop] ${sample}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
234
273
|
/**
|
|
235
274
|
* Speaks a text through the µGulp dashboard speech output (Web Speech API,
|
|
236
275
|
* respects the dashboard speech settings: enabled/volume/rate/pitch).
|
|
@@ -520,6 +559,8 @@ export default {
|
|
|
520
559
|
ReportProgress,
|
|
521
560
|
CreateProgress,
|
|
522
561
|
PlaySignal,
|
|
562
|
+
PlaySound,
|
|
563
|
+
StopSound,
|
|
523
564
|
Speak,
|
|
524
565
|
RequestForm,
|
|
525
566
|
RequestTextInput,
|