@gpustack/core-ui 1.0.25 → 1.0.27

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.
@@ -0,0 +1,5 @@
1
+ (function(){let e=/\x1b\[(\d*);?(\d*)?([A-DJKHfm])/g,t=e=>e.startsWith(`(…)`)?e.slice(3):e;var n=class{onMessage;cursorRow=0;cursorCol=0;screen=[[``]];rawDataRows=0;uid=0;isProcessing=!1;taskQueue=[];page=1;progress=0;percent=0;isComplete=!1;chunked=!0;reminder=``;lines=[];isDownloading=!1;pageSize=500;resetFlag=!1;colorMap={30:`black`,31:`red`,32:`green`,33:`yellow`,34:`blue`,35:`magenta`,36:`cyan`,37:`white`};constructor(){this.reset()}reset(){this.cursorRow=0,this.cursorCol=0,this.screen=[[``]],this.rawDataRows=0,this.uid+=1,this.lines=[],this.reminder=``,this.page=1,this.resetFlag=!0}setPage(e){this.page=e??1}setPercent(e){this.percent=e??0}setProgress(e){this.progress=e??0}setIsCompelete(e){this.isComplete=e}setChunked(e){this.chunked=e??!0}setIsDownloading(e){this.isDownloading=e}setId(){return this.uid+=1,this.uid}handleText(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`\r`){if(e[t+1]===`
2
+ `)continue;this.cursorCol=0}else if(n===`
3
+ `)this.rawDataRows++,this.cursorRow++,this.cursorCol=0,this.screen[this.cursorRow]||(this.screen[this.cursorRow]=[``]);else{let e=this.screen[this.cursorRow]||(this.screen[this.cursorRow]=[``]);e[this.cursorCol]=n||``,this.cursorCol++}}}handleAnsiSequence(e,t){let n=parseInt(e[1]||`1`,10),r=parseInt(e[2]||`1`,10);switch(e[3]){case`A`:this.cursorRow=Math.max(0,this.cursorRow-n);break;case`B`:this.cursorRow+=n;break;case`C`:this.cursorCol+=n;break;case`D`:this.cursorCol=Math.max(0,this.cursorCol-n);break;case`H`:this.cursorRow=Math.max(0,n-1),this.cursorCol=Math.max(0,r-1);break;case`J`:n===2&&this.reset();break;case`m`:break}for(;this.screen.length<=this.cursorRow&&!t;)this.screen.push([``]);for(;this.screen[this.cursorRow].length<=this.cursorCol&&!t;)this.screen[this.cursorRow].push(``)}processInput(n){let r=/\x1b(\[[\d;]*)?$/.exec(n),i=``;r&&(i=n.slice(r.index),n=n.slice(0,r.index)),e.lastIndex=0;let a,o=0;for(;(a=e.exec(n))!==null;){let t=n.slice(o,a.index);this.handleText(t),o=e.lastIndex,this.handleAnsiSequence(a,o===n.length-1)}let s=n.slice(o);return this.handleText(s),{data:this.screen.map((e,n)=>t(e.join(``))),lines:this.rawDataRows,remainder:i}}getScreenText(){return this.screen.map(e=>t(e.join(``))).join(`
4
+ `)}processInputByLine(e){let t=e?.split(/\r?\n/)||[],n=t.pop()||``;return this.rawDataRows+=t.length,this.chunked||t.forEach(e=>{this.lines.push(e)}),{data:t,lines:this.rawDataRows,remainder:n}}getAllLines(){return this.lines.join(`
5
+ `)}emit(e){typeof self<`u`&&typeof self.postMessage==`function`&&self.postMessage(e),this.onMessage?.(e)}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.taskQueue.length>0;){let e=this.reminder+(this.taskQueue.shift()||``);if(this.reminder=``,e)try{let t=this.isDownloading?this.processInput(e):this.processInputByLine(e);this.reminder=t.remainder,this.chunked?(this.emit({result:t.data,lines:t.lines,append:!this.isDownloading,reset:this.resetFlag}),this.resetFlag=!1):this.isComplete||this.emit({result:``,percent:this.percent,isComplete:!1})}catch(e){console.error(`Error processing input:`,e)}await new Promise(e=>{setTimeout(e,0)})}this.isProcessing=!1,this.taskQueue.length>0?this.processQueue():this.isComplete&&!this.chunked&&(this.emit({result:this.getAllLines(),percent:this.percent,isComplete:!0}),this.reset())}}enqueueData(e){this.taskQueue.push(e),this.isProcessing||this.processQueue()}};if(typeof self<`u`&&typeof self.addEventListener==`function`){let e=new n;self.onmessage=function(t){let{inputStr:n,reset:r,page:i,isComplete:a=!1,chunked:o=!0,percent:s=0,isDownloading:c=!1}=t.data;e.setIsDownloading(c),e.setPage(i),e.setIsCompelete(a),e.setChunked(o),e.setPercent(s),r&&e.reset(),e.enqueueData(n)},self.onerror=function(e){console.error(`parse logs error===`,e)}}})();
package/dist/index.es.js CHANGED
@@ -2825,7 +2825,7 @@ function Qi() {
2825
2825
  };
2826
2826
  return F(() => (t.current?.terminate?.(), t.current = new Worker(new URL(
2827
2827
  /* @vite-ignore */
2828
- "" + new URL("assets/parse-worker-DASzfShu.js", import.meta.url).href,
2828
+ "" + new URL("assets/parse-worker-BnGEhil7.js", import.meta.url).href,
2829
2829
  "" + import.meta.url
2830
2830
  ), { type: "module" }), t.current.onmessage = (t) => {
2831
2831
  let { result: n, isComplete: a, percent: s } = t.data, c = e.current?.current?.signal?.aborted;
@@ -3552,6 +3552,7 @@ var ma = () => {
3552
3552
  white-space: pre-line;
3553
3553
  word-break: normal;
3554
3554
  overflow-wrap: break-word;
3555
+ hyphens: auto;
3555
3556
  span {
3556
3557
  color: var(--ant-color-text);
3557
3558
  display: flex;
@@ -6758,6 +6759,7 @@ var Fs = (e) => {
6758
6759
  }), /* @__PURE__ */ H("div", {
6759
6760
  className: "del-btn",
6760
6761
  children: /* @__PURE__ */ H(G, {
6762
+ onMouseDown: (e) => e.preventDefault(),
6761
6763
  onClick: r,
6762
6764
  icon: /* @__PURE__ */ H(ue, {}),
6763
6765
  size: "small",
@@ -8709,7 +8711,7 @@ var Ic = (e) => {
8709
8711
  ce();
8710
8712
  }, [C, ce]), F(() => (_.current?.terminate?.(), _.current = new Worker(new URL(
8711
8713
  /* @vite-ignore */
8712
- "" + new URL("assets/parse-worker-DASzfShu.js", import.meta.url).href,
8714
+ "" + new URL("assets/parse-worker-BnGEhil7.js", import.meta.url).href,
8713
8715
  "" + import.meta.url
8714
8716
  ), { type: "module" }), _.current.onmessage = (e) => {
8715
8717
  let { result: t, lines: n, append: r, reset: i } = e.data;
@@ -10151,52 +10153,65 @@ var Xu = Y.div`
10151
10153
  i.current = new (window.AudioContext || window.webkitAudioContext)(), a.current = i.current.createAnalyser(), a.current.fftSize = 512, o.current = new Uint8Array(a.current.frequencyBinCount);
10152
10154
  }, []), c = N(() => {
10153
10155
  i.current.createMediaElementSource(r.current).connect(a.current), a.current.connect(i.current.destination);
10154
- }, []), l = z(e);
10155
- l.current = e;
10156
- let u = z();
10157
- u.current ||= {
10156
+ }, []), l = N(() => {
10157
+ if (!i.current) try {
10158
+ s(), c();
10159
+ } catch (e) {
10160
+ if (console.error("Failed to init audio context:", e), i.current) {
10161
+ try {
10162
+ i.current.close();
10163
+ } catch (e) {
10164
+ console.error("Failed to close audio context after initialization failure:", e);
10165
+ }
10166
+ i.current = null;
10167
+ }
10168
+ }
10169
+ }, [s, c]), u = z(e);
10170
+ u.current = e;
10171
+ let d = z();
10172
+ d.current ||= {
10158
10173
  play: () => {
10159
- l.current.onAnalyse?.(o.current, a), l.current.onPlay?.();
10174
+ u.current.onAnalyse?.(o.current, a), u.current.onPlay?.();
10160
10175
  },
10161
10176
  pause: () => {
10162
- l.current.onAnalyse?.(o.current, a), l.current.onPause?.();
10177
+ u.current.onAnalyse?.(o.current, a), u.current.onPause?.();
10163
10178
  },
10164
10179
  timeupdate: () => {
10165
10180
  let e = r.current?.currentTime || 0;
10166
- l.current.onTimeUpdate?.(), l.current.onAudioProcess?.(e);
10181
+ u.current.onTimeUpdate?.(), u.current.onAudioProcess?.(e);
10167
10182
  },
10168
10183
  ended: () => {
10169
- l.current.onEnded?.();
10184
+ u.current.onEnded?.();
10170
10185
  },
10171
10186
  canplay: () => {
10172
- l.current.onCanPlay?.();
10187
+ u.current.onCanPlay?.();
10173
10188
  },
10174
10189
  loadeddata: () => {
10175
- i.current || (s(), c()), l.current.onLoadedData?.();
10190
+ l(), u.current.onLoadedData?.();
10176
10191
  },
10177
10192
  seeked: () => {
10178
- l.current.onSeeked?.();
10193
+ u.current.onSeeked?.();
10179
10194
  },
10180
10195
  seeking: () => {
10181
- l.current.onSeeking?.();
10196
+ u.current.onSeeking?.();
10182
10197
  },
10183
10198
  volumechange: () => {
10184
- l.current.onVolumeChange?.();
10199
+ u.current.onVolumeChange?.();
10185
10200
  },
10186
10201
  playing: () => {
10187
- l.current.onPlaying?.();
10202
+ u.current.onPlaying?.();
10188
10203
  },
10189
10204
  loadedmetadata: () => {
10190
10205
  let e = r.current?.duration || 0;
10191
- l.current.onLoadedMetadata?.(e), l.current.onReady?.(e);
10206
+ u.current.onLoadedMetadata?.(e), u.current.onReady?.(e);
10192
10207
  }
10193
10208
  };
10194
- let d = () => {
10195
- i.current?.state === "suspended" && i.current.resume();
10209
+ let f = () => {
10210
+ l(), i.current?.state === "suspended" && i.current.resume();
10196
10211
  };
10197
10212
  return I(t, () => ({
10198
10213
  play: () => {
10199
- r.current && (d(), r.current.currentTime >= r.current.duration && (r.current.currentTime = 0), r.current.play());
10214
+ r.current && (f(), r.current.currentTime >= r.current.duration && (r.current.currentTime = 0), r.current.play());
10200
10215
  },
10201
10216
  pause: () => {
10202
10217
  r.current?.pause();
@@ -10205,11 +10220,11 @@ var Xu = Y.div`
10205
10220
  r.current && r.current.duration && (r.current.currentTime = e * r.current.duration);
10206
10221
  },
10207
10222
  wavesurfer: { current: {
10208
- play: () => r.current ? (d(), r.current.currentTime >= r.current.duration && (r.current.currentTime = 0), r.current.play()) : Promise.resolve(),
10223
+ play: () => r.current ? (f(), r.current.currentTime >= r.current.duration && (r.current.currentTime = 0), r.current.play()) : Promise.resolve(),
10209
10224
  isPlaying: () => r.current ? !r.current?.paused : !1
10210
10225
  } }
10211
10226
  })), F(() => {
10212
- let e = r.current, t = u.current;
10227
+ let e = r.current, t = d.current;
10213
10228
  if (!(!e || !t)) return Object.entries(t).forEach(([t, n]) => {
10214
10229
  e.addEventListener(t, n);
10215
10230
  }), () => {
@@ -1 +1,39 @@
1
- export {};
1
+ export declare class AnsiParser {
2
+ onMessage?: (message: any) => void;
3
+ private cursorRow;
4
+ private cursorCol;
5
+ private screen;
6
+ private rawDataRows;
7
+ private uid;
8
+ private isProcessing;
9
+ private taskQueue;
10
+ private page;
11
+ private progress;
12
+ private percent;
13
+ private isComplete;
14
+ private chunked;
15
+ private reminder;
16
+ private lines;
17
+ isDownloading: boolean;
18
+ private pageSize;
19
+ private resetFlag;
20
+ private colorMap;
21
+ constructor();
22
+ reset(): void;
23
+ setPage(page: number | undefined): void;
24
+ setPercent(percent: number | undefined): void;
25
+ setProgress(progress: number | undefined): void;
26
+ setIsCompelete(isComplete: boolean): void;
27
+ setChunked(chunked: boolean): void;
28
+ setIsDownloading(isDownloading: boolean): void;
29
+ private setId;
30
+ private handleText;
31
+ private handleAnsiSequence;
32
+ private processInput;
33
+ private getScreenText;
34
+ private processInputByLine;
35
+ private getAllLines;
36
+ private emit;
37
+ private processQueue;
38
+ enqueueData(input: string): void;
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpustack/core-ui",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -48,6 +48,8 @@
48
48
  "prepare": "husky",
49
49
  "prepublishOnly": "pnpm build",
50
50
  "preview": "vite preview",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest",
51
53
  "typecheck": "tsc -p tsconfig.app.json --noEmit"
52
54
  },
53
55
  "lint-staged": {
@@ -139,7 +141,8 @@
139
141
  "typescript": "~6.0.2",
140
142
  "typescript-eslint": "^8.58.0",
141
143
  "vite": "^8.0.8",
142
- "vite-plugin-dts": "^4.5.4"
144
+ "vite-plugin-dts": "^4.5.4",
145
+ "vitest": "^4.1.8"
143
146
  },
144
147
  "peerDependencies": {
145
148
  "@ant-design/icons": ">=6.0.0",
@@ -1,5 +0,0 @@
1
- (function(){let e=/\x1b\[(\d*);?(\d*)?([A-DJKHfm])/g,t=e=>e.startsWith(`(…)`)?e.slice(3):e,n=new class{cursorRow=0;cursorCol=0;screen=[[``]];rawDataRows=0;uid=0;isProcessing=!1;taskQueue=[];page=1;progress=0;percent=0;isComplete=!1;chunked=!0;reminder=``;lines=[];isDownloading=!1;pageSize=500;resetFlag=!1;colorMap={30:`black`,31:`red`,32:`green`,33:`yellow`,34:`blue`,35:`magenta`,36:`cyan`,37:`white`};constructor(){this.reset()}reset(){this.cursorRow=0,this.cursorCol=0,this.screen=[[``]],this.rawDataRows=0,this.uid+=1,this.lines=[],this.reminder=``,this.page=1,this.resetFlag=!0}setPage(e){this.page=e??1}setPercent(e){this.percent=e??0}setProgress(e){this.progress=e??0}setIsCompelete(e){this.isComplete=e}setChunked(e){this.chunked=e??!0}setIsDownloading(e){this.isDownloading=e}setId(){return this.uid+=1,this.uid}handleText(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`\r`){if(e[t+1]===`
2
- `)continue;this.cursorCol=0}else if(n===`
3
- `)this.rawDataRows++,this.cursorRow++,this.cursorCol=0,this.screen[this.cursorRow]||(this.screen[this.cursorRow]=[``]);else{let e=this.screen[this.cursorRow]||(this.screen[this.cursorRow]=[``]);e[this.cursorCol]=n||``,this.cursorCol++}}}handleAnsiSequence(e,t){let n=parseInt(e[1]||`1`,10),r=parseInt(e[2]||`1`,10);switch(e[3]){case`A`:this.cursorRow=Math.max(0,this.cursorRow-n);break;case`B`:this.cursorRow+=n;break;case`C`:this.cursorCol+=n;break;case`D`:this.cursorCol=Math.max(0,this.cursorCol-n);break;case`H`:this.cursorRow=Math.max(0,n-1),this.cursorCol=Math.max(0,r-1);break;case`J`:n===2&&this.reset();break;case`m`:break}for(;this.screen.length<=this.cursorRow&&!t;)this.screen.push([``]);for(;this.screen[this.cursorRow].length<=this.cursorCol&&!t;)this.screen[this.cursorRow].push(``)}processInput(n){let r,i=0;for(;(r=e.exec(n))!==null;){let t=n.slice(i,r.index);this.handleText(t),i=e.lastIndex,this.handleAnsiSequence(r,i===n.length-1)}let a=n.slice(i);return this.handleText(a),{data:this.screen.map((e,n)=>t(e.join(``))),lines:this.rawDataRows,remainder:``}}getScreenText(){return this.screen.map(e=>t(e.join(``))).join(`
4
- `)}processInputByLine(e){let t=e?.split(/\r?\n/)||[],n=t.pop()||``;return this.rawDataRows+=t.length,this.chunked||t.forEach(e=>{this.lines.push(e)}),{data:t,lines:this.rawDataRows,remainder:n}}getAllLines(){return this.lines.join(`
5
- `)}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.taskQueue.length>0;){let e=``;if(e=this.isDownloading?this.taskQueue.shift()||``:this.reminder+this.taskQueue.shift(),e)try{let t=this.isDownloading?this.processInput(e):this.processInputByLine(e);this.isDownloading||(this.reminder=t.remainder),this.chunked?(self.postMessage({result:t.data,lines:t.lines,append:!this.isDownloading,reset:this.resetFlag}),this.resetFlag=!1):this.isComplete||self.postMessage({result:``,percent:this.percent,isComplete:!1})}catch(e){console.error(`Error processing input:`,e)}await new Promise(e=>{setTimeout(e,0)})}this.isProcessing=!1,this.taskQueue.length>0?this.processQueue():this.isComplete&&!this.chunked&&(self.postMessage({result:this.getAllLines(),percent:this.percent,isComplete:!0}),this.reset())}}enqueueData(e){this.taskQueue.push(e),this.isProcessing||this.processQueue()}};self.onmessage=function(e){let{inputStr:t,reset:r,page:i,isComplete:a=!1,chunked:o=!0,percent:s=0,isDownloading:c=!1}=e.data;n.setIsDownloading(c),n.setPage(i),n.setIsCompelete(a),n.setChunked(o),n.setPercent(s),r&&n.reset(),n.enqueueData(t)},self.onerror=function(e){console.error(`parse logs error===`,e)}})();