@innovatorved/code-lab 0.1.1 → 0.1.2

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.
@@ -18108,6 +18108,39 @@ declare module 'bun:sqlite' {
18108
18108
  const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
18109
18109
  const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
18110
18110
 
18111
+ // The workbench owns live terminal rendering. Only defer when an attached PTY
18112
+ // engine is itself rendering into the DOM (it is created with a null container in
18113
+ // production, so this remains the sole renderer there).
18114
+ const ptyOwnsDom = Boolean(this.ptyEngine && this.ptyEngine.container);
18115
+ const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
18116
+
18117
+ // Write a single logical line into the live terminal DOM immediately, so output
18118
+ // streams in as it is produced instead of appearing only when the command ends and
18119
+ // the whole drawer is re-rendered. Reuses the current partial-line element when it
18120
+ // is still attached (carriage-return overwrites / keep-alive updates).
18121
+ const patchLineInDom = (text) => {
18122
+ if (!canPatchDom) return;
18123
+ const html = ansiToHtml ? ansiToHtml(text) : escapeHtml(text);
18124
+ if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
18125
+ this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18126
+ this._activeStreamEl.innerHTML = html;
18127
+ } else {
18128
+ const newEl = document.createElement('div');
18129
+ newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18130
+ newEl.innerHTML = html;
18131
+ termLogEl.appendChild(newEl);
18132
+ this._activeStreamEl = newEl;
18133
+ }
18134
+ };
18135
+
18136
+ // A newline completes the current line: commit it to the log + DOM, then begin a fresh line.
18137
+ const commitActiveLine = () => {
18138
+ this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
18139
+ patchLineInDom(this._activeStreamLine);
18140
+ this._activeStreamLine = '';
18141
+ this._activeStreamEl = null;
18142
+ };
18143
+
18111
18144
  let i = 0;
18112
18145
  while (i < rawText.length) {
18113
18146
  if (rawText.startsWith('\x1b[2K', i)) {
@@ -18142,20 +18175,22 @@ declare module 'bun:sqlite' {
18142
18175
  const ch = rawText[i];
18143
18176
  if (ch === '\r') {
18144
18177
  if (i + 1 < rawText.length && rawText[i + 1] === '\n') {
18145
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
18146
- this._activeStreamLine = '';
18147
- this._activeStreamEl = null;
18178
+ commitActiveLine();
18148
18179
  i += 2;
18149
18180
  continue;
18150
18181
  } else {
18182
+ // Bare carriage return: flush the current text into the active line, then
18183
+ // keep overwriting that same DOM node (no extra line is appended).
18184
+ const rendered = this._activeStreamLine;
18185
+ if (rendered || this._activeStreamEl) {
18186
+ patchLineInDom(rendered);
18187
+ }
18151
18188
  this._activeStreamLine = '';
18152
18189
  i++;
18153
18190
  continue;
18154
18191
  }
18155
18192
  } else if (ch === '\n') {
18156
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
18157
- this._activeStreamLine = '';
18158
- this._activeStreamEl = null;
18193
+ commitActiveLine();
18159
18194
  i++;
18160
18195
  continue;
18161
18196
  } else {
@@ -18164,20 +18199,9 @@ declare module 'bun:sqlite' {
18164
18199
  }
18165
18200
  }
18166
18201
 
18167
- if (termLogEl && typeof document !== 'undefined') {
18168
- if (this._activeStreamLine) {
18169
- const formattedHtml = ansiToHtml ? ansiToHtml(this._activeStreamLine) : escapeHtml(this._activeStreamLine);
18170
- if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
18171
- this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18172
- this._activeStreamEl.innerHTML = formattedHtml;
18173
- } else {
18174
- const newEl = document.createElement('div');
18175
- newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18176
- newEl.innerHTML = formattedHtml;
18177
- termLogEl.appendChild(newEl);
18178
- this._activeStreamEl = newEl;
18179
- }
18180
- }
18202
+ // Render the still-open partial line so incremental progress stays visible.
18203
+ if (this._activeStreamLine) {
18204
+ patchLineInDom(this._activeStreamLine);
18181
18205
  }
18182
18206
 
18183
18207
  if (termSurface) {
package/dist/code-lab.js CHANGED
@@ -18115,6 +18115,39 @@ declare module 'bun:sqlite' {
18115
18115
  const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
18116
18116
  const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
18117
18117
 
18118
+ // The workbench owns live terminal rendering. Only defer when an attached PTY
18119
+ // engine is itself rendering into the DOM (it is created with a null container in
18120
+ // production, so this remains the sole renderer there).
18121
+ const ptyOwnsDom = Boolean(this.ptyEngine && this.ptyEngine.container);
18122
+ const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
18123
+
18124
+ // Write a single logical line into the live terminal DOM immediately, so output
18125
+ // streams in as it is produced instead of appearing only when the command ends and
18126
+ // the whole drawer is re-rendered. Reuses the current partial-line element when it
18127
+ // is still attached (carriage-return overwrites / keep-alive updates).
18128
+ const patchLineInDom = (text) => {
18129
+ if (!canPatchDom) return;
18130
+ const html = ansiToHtml ? ansiToHtml(text) : escapeHtml(text);
18131
+ if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
18132
+ this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18133
+ this._activeStreamEl.innerHTML = html;
18134
+ } else {
18135
+ const newEl = document.createElement('div');
18136
+ newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18137
+ newEl.innerHTML = html;
18138
+ termLogEl.appendChild(newEl);
18139
+ this._activeStreamEl = newEl;
18140
+ }
18141
+ };
18142
+
18143
+ // A newline completes the current line: commit it to the log + DOM, then begin a fresh line.
18144
+ const commitActiveLine = () => {
18145
+ this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
18146
+ patchLineInDom(this._activeStreamLine);
18147
+ this._activeStreamLine = '';
18148
+ this._activeStreamEl = null;
18149
+ };
18150
+
18118
18151
  let i = 0;
18119
18152
  while (i < rawText.length) {
18120
18153
  if (rawText.startsWith('\x1b[2K', i)) {
@@ -18149,20 +18182,22 @@ declare module 'bun:sqlite' {
18149
18182
  const ch = rawText[i];
18150
18183
  if (ch === '\r') {
18151
18184
  if (i + 1 < rawText.length && rawText[i + 1] === '\n') {
18152
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
18153
- this._activeStreamLine = '';
18154
- this._activeStreamEl = null;
18185
+ commitActiveLine();
18155
18186
  i += 2;
18156
18187
  continue;
18157
18188
  } else {
18189
+ // Bare carriage return: flush the current text into the active line, then
18190
+ // keep overwriting that same DOM node (no extra line is appended).
18191
+ const rendered = this._activeStreamLine;
18192
+ if (rendered || this._activeStreamEl) {
18193
+ patchLineInDom(rendered);
18194
+ }
18158
18195
  this._activeStreamLine = '';
18159
18196
  i++;
18160
18197
  continue;
18161
18198
  }
18162
18199
  } else if (ch === '\n') {
18163
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
18164
- this._activeStreamLine = '';
18165
- this._activeStreamEl = null;
18200
+ commitActiveLine();
18166
18201
  i++;
18167
18202
  continue;
18168
18203
  } else {
@@ -18171,20 +18206,9 @@ declare module 'bun:sqlite' {
18171
18206
  }
18172
18207
  }
18173
18208
 
18174
- if (termLogEl && typeof document !== 'undefined') {
18175
- if (this._activeStreamLine) {
18176
- const formattedHtml = ansiToHtml ? ansiToHtml(this._activeStreamLine) : escapeHtml(this._activeStreamLine);
18177
- if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
18178
- this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18179
- this._activeStreamEl.innerHTML = formattedHtml;
18180
- } else {
18181
- const newEl = document.createElement('div');
18182
- newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
18183
- newEl.innerHTML = formattedHtml;
18184
- termLogEl.appendChild(newEl);
18185
- this._activeStreamEl = newEl;
18186
- }
18187
- }
18209
+ // Render the still-open partial line so incremental progress stays visible.
18210
+ if (this._activeStreamLine) {
18211
+ patchLineInDom(this._activeStreamLine);
18188
18212
  }
18189
18213
 
18190
18214
  if (termSurface) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovatorved/code-lab",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Standalone browser-native IDE Workbench, POSIX Shell & Coreutils, PTY Terminal, and Web Worker Node.js/Bun Virtual Runtime.",
5
5
  "main": "./dist/code-lab.js",
6
6
  "module": "./dist/code-lab.esm.js",
package/src/workbench.js CHANGED
@@ -3153,6 +3153,39 @@ declare module 'bun:sqlite' {
3153
3153
  const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
3154
3154
  const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
3155
3155
 
3156
+ // The workbench owns live terminal rendering. Only defer when an attached PTY
3157
+ // engine is itself rendering into the DOM (it is created with a null container in
3158
+ // production, so this remains the sole renderer there).
3159
+ const ptyOwnsDom = Boolean(this.ptyEngine && this.ptyEngine.container);
3160
+ const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
3161
+
3162
+ // Write a single logical line into the live terminal DOM immediately, so output
3163
+ // streams in as it is produced instead of appearing only when the command ends and
3164
+ // the whole drawer is re-rendered. Reuses the current partial-line element when it
3165
+ // is still attached (carriage-return overwrites / keep-alive updates).
3166
+ const patchLineInDom = (text) => {
3167
+ if (!canPatchDom) return;
3168
+ const html = ansiToHtml ? ansiToHtml(text) : escapeHtml(text);
3169
+ if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
3170
+ this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3171
+ this._activeStreamEl.innerHTML = html;
3172
+ } else {
3173
+ const newEl = document.createElement('div');
3174
+ newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3175
+ newEl.innerHTML = html;
3176
+ termLogEl.appendChild(newEl);
3177
+ this._activeStreamEl = newEl;
3178
+ }
3179
+ };
3180
+
3181
+ // A newline completes the current line: commit it to the log + DOM, then begin a fresh line.
3182
+ const commitActiveLine = () => {
3183
+ this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3184
+ patchLineInDom(this._activeStreamLine);
3185
+ this._activeStreamLine = '';
3186
+ this._activeStreamEl = null;
3187
+ };
3188
+
3156
3189
  let i = 0;
3157
3190
  while (i < rawText.length) {
3158
3191
  if (rawText.startsWith('\x1b[2K', i)) {
@@ -3187,20 +3220,22 @@ declare module 'bun:sqlite' {
3187
3220
  const ch = rawText[i];
3188
3221
  if (ch === '\r') {
3189
3222
  if (i + 1 < rawText.length && rawText[i + 1] === '\n') {
3190
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3191
- this._activeStreamLine = '';
3192
- this._activeStreamEl = null;
3223
+ commitActiveLine();
3193
3224
  i += 2;
3194
3225
  continue;
3195
3226
  } else {
3227
+ // Bare carriage return: flush the current text into the active line, then
3228
+ // keep overwriting that same DOM node (no extra line is appended).
3229
+ const rendered = this._activeStreamLine;
3230
+ if (rendered || this._activeStreamEl) {
3231
+ patchLineInDom(rendered);
3232
+ }
3196
3233
  this._activeStreamLine = '';
3197
3234
  i++;
3198
3235
  continue;
3199
3236
  }
3200
3237
  } else if (ch === '\n') {
3201
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3202
- this._activeStreamLine = '';
3203
- this._activeStreamEl = null;
3238
+ commitActiveLine();
3204
3239
  i++;
3205
3240
  continue;
3206
3241
  } else {
@@ -3209,20 +3244,9 @@ declare module 'bun:sqlite' {
3209
3244
  }
3210
3245
  }
3211
3246
 
3212
- if (termLogEl && typeof document !== 'undefined') {
3213
- if (this._activeStreamLine) {
3214
- const formattedHtml = ansiToHtml ? ansiToHtml(this._activeStreamLine) : escapeHtml(this._activeStreamLine);
3215
- if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
3216
- this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3217
- this._activeStreamEl.innerHTML = formattedHtml;
3218
- } else {
3219
- const newEl = document.createElement('div');
3220
- newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3221
- newEl.innerHTML = formattedHtml;
3222
- termLogEl.appendChild(newEl);
3223
- this._activeStreamEl = newEl;
3224
- }
3225
- }
3247
+ // Render the still-open partial line so incremental progress stays visible.
3248
+ if (this._activeStreamLine) {
3249
+ patchLineInDom(this._activeStreamLine);
3226
3250
  }
3227
3251
 
3228
3252
  if (termSurface) {
package/src/workbench.ts CHANGED
@@ -3154,6 +3154,39 @@ declare module 'bun:sqlite' {
3154
3154
  const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
3155
3155
  const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
3156
3156
 
3157
+ // The workbench owns live terminal rendering. Only defer when an attached PTY
3158
+ // engine is itself rendering into the DOM (it is created with a null container in
3159
+ // production, so this remains the sole renderer there).
3160
+ const ptyOwnsDom = Boolean(this.ptyEngine && this.ptyEngine.container);
3161
+ const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
3162
+
3163
+ // Write a single logical line into the live terminal DOM immediately, so output
3164
+ // streams in as it is produced instead of appearing only when the command ends and
3165
+ // the whole drawer is re-rendered. Reuses the current partial-line element when it
3166
+ // is still attached (carriage-return overwrites / keep-alive updates).
3167
+ const patchLineInDom = (text) => {
3168
+ if (!canPatchDom) return;
3169
+ const html = ansiToHtml ? ansiToHtml(text) : escapeHtml(text);
3170
+ if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
3171
+ this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3172
+ this._activeStreamEl.innerHTML = html;
3173
+ } else {
3174
+ const newEl = document.createElement('div');
3175
+ newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3176
+ newEl.innerHTML = html;
3177
+ termLogEl.appendChild(newEl);
3178
+ this._activeStreamEl = newEl;
3179
+ }
3180
+ };
3181
+
3182
+ // A newline completes the current line: commit it to the log + DOM, then begin a fresh line.
3183
+ const commitActiveLine = () => {
3184
+ this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3185
+ patchLineInDom(this._activeStreamLine);
3186
+ this._activeStreamLine = '';
3187
+ this._activeStreamEl = null;
3188
+ };
3189
+
3157
3190
  let i = 0;
3158
3191
  while (i < rawText.length) {
3159
3192
  if (rawText.startsWith('\x1b[2K', i)) {
@@ -3188,20 +3221,22 @@ declare module 'bun:sqlite' {
3188
3221
  const ch = rawText[i];
3189
3222
  if (ch === '\r') {
3190
3223
  if (i + 1 < rawText.length && rawText[i + 1] === '\n') {
3191
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3192
- this._activeStreamLine = '';
3193
- this._activeStreamEl = null;
3224
+ commitActiveLine();
3194
3225
  i += 2;
3195
3226
  continue;
3196
3227
  } else {
3228
+ // Bare carriage return: flush the current text into the active line, then
3229
+ // keep overwriting that same DOM node (no extra line is appended).
3230
+ const rendered = this._activeStreamLine;
3231
+ if (rendered || this._activeStreamEl) {
3232
+ patchLineInDom(rendered);
3233
+ }
3197
3234
  this._activeStreamLine = '';
3198
3235
  i++;
3199
3236
  continue;
3200
3237
  }
3201
3238
  } else if (ch === '\n') {
3202
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3203
- this._activeStreamLine = '';
3204
- this._activeStreamEl = null;
3239
+ commitActiveLine();
3205
3240
  i++;
3206
3241
  continue;
3207
3242
  } else {
@@ -3210,20 +3245,9 @@ declare module 'bun:sqlite' {
3210
3245
  }
3211
3246
  }
3212
3247
 
3213
- if (termLogEl && typeof document !== 'undefined') {
3214
- if (this._activeStreamLine) {
3215
- const formattedHtml = ansiToHtml ? ansiToHtml(this._activeStreamLine) : escapeHtml(this._activeStreamLine);
3216
- if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
3217
- this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3218
- this._activeStreamEl.innerHTML = formattedHtml;
3219
- } else {
3220
- const newEl = document.createElement('div');
3221
- newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3222
- newEl.innerHTML = formattedHtml;
3223
- termLogEl.appendChild(newEl);
3224
- this._activeStreamEl = newEl;
3225
- }
3226
- }
3248
+ // Render the still-open partial line so incremental progress stays visible.
3249
+ if (this._activeStreamLine) {
3250
+ patchLineInDom(this._activeStreamLine);
3227
3251
  }
3228
3252
 
3229
3253
  if (termSurface) {