gulp-mu-gulp-api 0.2.0 → 0.2.1
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 +10 -4
- package/package.json +1 -1
- package/src/index.mjs +35 -5
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm install gulp-mu-gulp-api
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
```javascript
|
|
26
|
-
import { ReportProgress, CreateProgress, PlaySignal, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm,
|
|
26
|
+
import { ReportProgress, CreateProgress, PlaySignal, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm, IsMicroGulp, IsµGulp, µMeta } from 'gulp-mu-gulp-api';
|
|
27
27
|
|
|
28
28
|
export async function BUILD_THEME() {
|
|
29
29
|
// single inputs
|
|
@@ -50,6 +50,8 @@ export async function BUILD_THEME() {
|
|
|
50
50
|
PlaySignal('success');
|
|
51
51
|
Speak('Theme build finished.');
|
|
52
52
|
}
|
|
53
|
+
BUILD_THEME.µDisplayName = µMeta('Build Theme', 'µDisplayName');
|
|
54
|
+
BUILD_THEME.µDescription = µMeta('Compiles the Carbon/Neon dashboard skin.', 'µDescription');
|
|
53
55
|
```
|
|
54
56
|
|
|
55
57
|
Complete forms in one go:
|
|
@@ -72,7 +74,8 @@ let values = await RequestForm({
|
|
|
72
74
|
|
|
73
75
|
| Function | Purpose |
|
|
74
76
|
| :--- | :--- |
|
|
75
|
-
| `
|
|
77
|
+
| `IsMicroGulp()` / `IsµGulp()` | `true` when the task runs under µGulp™ with an attached dashboard (`IsUGulp` is a deprecated alias) |
|
|
78
|
+
| `µMeta(text, property)` | Marks a µXXX task metadata string with an i18xe context tag (`µDisplayName`, `µDescription`, `µTooltip`, `µGroup`) |
|
|
76
79
|
| `ReportProgress(value, label?)` | Report progress `0..1` to the task progress bar |
|
|
77
80
|
| `CreateProgress(label?)` | Reporter object with `Update(value, stepLabel?)` and `Done()` |
|
|
78
81
|
| `PlaySignal(signal?)` | Acoustic signal in the dashboard: `'success'` \| `'error'` \| `'attention'` (default) |
|
|
@@ -143,7 +146,7 @@ npm install gulp-mu-gulp-api
|
|
|
143
146
|
## Verwendung
|
|
144
147
|
|
|
145
148
|
```javascript
|
|
146
|
-
import { ReportProgress, CreateProgress, PlaySignal, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm,
|
|
149
|
+
import { ReportProgress, CreateProgress, PlaySignal, Speak, RequestTextInput, RequestColorInput, RequestFontInput, RequestSelectInput, RequestMultiSelectInput, RequestForm, IsMicroGulp, IsµGulp, µMeta } from 'gulp-mu-gulp-api';
|
|
147
150
|
|
|
148
151
|
export async function BUILD_THEME() {
|
|
149
152
|
// Einzeleingaben
|
|
@@ -170,6 +173,8 @@ export async function BUILD_THEME() {
|
|
|
170
173
|
PlaySignal('success');
|
|
171
174
|
Speak('Theme build finished.');
|
|
172
175
|
}
|
|
176
|
+
BUILD_THEME.µDisplayName = µMeta('Build Theme', 'µDisplayName');
|
|
177
|
+
BUILD_THEME.µDescription = µMeta('Kompiliert den Carbon/Neon-Dashboard-Skin.', 'µDescription');
|
|
173
178
|
```
|
|
174
179
|
|
|
175
180
|
Komplette Formulare in einem Rutsch:
|
|
@@ -192,7 +197,8 @@ let values = await RequestForm({
|
|
|
192
197
|
|
|
193
198
|
| Funktion | Zweck |
|
|
194
199
|
| :--- | :--- |
|
|
195
|
-
| `
|
|
200
|
+
| `IsMicroGulp()` / `IsµGulp()` | `true`, wenn der Task unter µGulp™ mit angebundenem Dashboard läuft (`IsUGulp` ist ein veralteter Alias) |
|
|
201
|
+
| `µMeta(text, property)` | Kennzeichnet einen µXXX-Metadaten-String mit einem i18xe-Kontext-Tag (`µDisplayName`, `µDescription`, `µTooltip`, `µGroup`) |
|
|
196
202
|
| `ReportProgress(value, label?)` | Fortschritt `0..1` an die Task-Progressbar melden |
|
|
197
203
|
| `CreateProgress(label?)` | Reporter-Objekt mit `Update(value, stepLabel?)` und `Done()` |
|
|
198
204
|
| `PlaySignal(signal?)` | Akustisches Signal im Dashboard: `'success'` \| `'error'` \| `'attention'` (Default) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gulp-mu-gulp-api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Public task API for the µGulp orchestrator: progress reporting, sound signals, speech output 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
|
@@ -37,10 +37,36 @@ const pendingUiRequests = new Map();
|
|
|
37
37
|
* @returns {boolean} true when the task runs inside a µGulp worker with an
|
|
38
38
|
* attached dashboard (progress and inputs are rendered in the webview)
|
|
39
39
|
*/
|
|
40
|
-
export function
|
|
40
|
+
export function IsMicroGulp() {
|
|
41
41
|
return typeof process.send === 'function' && process.env.UGULP === '1';
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/** Brand-aligned alias for {@link IsMicroGulp}. */
|
|
45
|
+
export const IsµGulp = IsMicroGulp;
|
|
46
|
+
|
|
47
|
+
/** @deprecated Use {@link IsMicroGulp} or {@link IsµGulp}. */
|
|
48
|
+
export const IsUGulp = IsMicroGulp;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Marks a µXXX task metadata string for i18x (American English source).
|
|
52
|
+
* Appends the i18xe context tag for the property (`µDisplayName`,
|
|
53
|
+
* `µDescription`, …) so the dashboard can translate it and a later
|
|
54
|
+
* i18xe-server sync can pick it up. The classic gulp CLI ignores these
|
|
55
|
+
* properties entirely.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} _text source phrase
|
|
58
|
+
* @param {'µDisplayName'|'µDescription'|'µTooltip'|'µGroup'} _contextProperty
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function µMeta(_text, _contextProperty) {
|
|
62
|
+
let text = String(_text ?? '').trim();
|
|
63
|
+
if (!text || text.includes('<context="')) return text;
|
|
64
|
+
return text + '<context="' + _contextProperty + '"/>';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** ASCII export alias for {@link µMeta}. */
|
|
68
|
+
export const MicroGulpMeta = µMeta;
|
|
69
|
+
|
|
44
70
|
// -------------------------------------------------
|
|
45
71
|
// progress
|
|
46
72
|
// -------------------------------------------------
|
|
@@ -55,7 +81,7 @@ export function IsUGulp() {
|
|
|
55
81
|
*/
|
|
56
82
|
export function ReportProgress(_value, _label) {
|
|
57
83
|
let value = Math.max(0, Math.min(1, Number(_value) || 0));
|
|
58
|
-
if (
|
|
84
|
+
if (IsMicroGulp()) {
|
|
59
85
|
process.send({ type: 'progress', value, label: _label });
|
|
60
86
|
return;
|
|
61
87
|
}
|
|
@@ -97,7 +123,7 @@ export function CreateProgress(_label) {
|
|
|
97
123
|
* @param {'success'|'error'|'attention'} [_signal]
|
|
98
124
|
*/
|
|
99
125
|
export function PlaySignal(_signal = 'attention') {
|
|
100
|
-
if (
|
|
126
|
+
if (IsMicroGulp()) {
|
|
101
127
|
process.send({ type: 'sound', signal: _signal });
|
|
102
128
|
return;
|
|
103
129
|
}
|
|
@@ -117,7 +143,7 @@ export function PlaySignal(_signal = 'attention') {
|
|
|
117
143
|
export function Speak(_text, _options) {
|
|
118
144
|
let text = String(_text ?? '').trim();
|
|
119
145
|
if (!text) return;
|
|
120
|
-
if (
|
|
146
|
+
if (IsMicroGulp()) {
|
|
121
147
|
process.send({ type: 'speech', text, options: _options ?? null });
|
|
122
148
|
return;
|
|
123
149
|
}
|
|
@@ -149,7 +175,7 @@ export function Speak(_text, _options) {
|
|
|
149
175
|
* @returns {Promise<object>} map fieldId -> value
|
|
150
176
|
*/
|
|
151
177
|
export async function RequestForm(_form) {
|
|
152
|
-
if (
|
|
178
|
+
if (IsMicroGulp()) {
|
|
153
179
|
_EnsureIpcListener();
|
|
154
180
|
let requestId = 'api-req-' + process.pid + '-' + (++uiRequestCounter);
|
|
155
181
|
return new Promise((_resolve) => {
|
|
@@ -308,7 +334,11 @@ async function _FallbackField(_field) {
|
|
|
308
334
|
}
|
|
309
335
|
|
|
310
336
|
export default {
|
|
337
|
+
IsMicroGulp,
|
|
338
|
+
IsµGulp,
|
|
311
339
|
IsUGulp,
|
|
340
|
+
µMeta,
|
|
341
|
+
MicroGulpMeta,
|
|
312
342
|
ReportProgress,
|
|
313
343
|
CreateProgress,
|
|
314
344
|
PlaySignal,
|