gulp-mu-gulp-api 0.3.3 → 0.3.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +13 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gulp-mu-gulp-api",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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
- return typeof process.send === 'function' && process.env.MICROGULP === '1';
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
- // structured log output (table / tree)
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 (IsMicroGulp()) {
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 (IsMicroGulp()) {
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 (IsMicroGulp()) {
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