@gridland/web 0.2.15 → 0.2.16
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/dist/index.d.ts +2 -2
- package/dist/index.js +70 -13
- package/dist/index.js.map +2 -2
- package/dist/{next-CxYMg6AG.d.ts → next-BWTklBmN.d.ts} +22 -3
- package/dist/next.d.ts +1 -1
- package/dist/next.js +70 -13
- package/dist/next.js.map +2 -2
- package/dist/vite-plugin.js +5 -1
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BrowserRenderer, W as WidthMethod, R as RGBA, a as BrowserRenderContext, b as BrowserBuffer } from './next-
|
|
2
|
-
export { c as BorderDrawOptions, C as CanvasPainter, d as CanvasPainterOptions, S as SelectionManager, T as TUI, e as TUIProps } from './next-
|
|
1
|
+
import { B as BrowserRenderer, W as WidthMethod, R as RGBA, a as BrowserRenderContext, b as BrowserBuffer } from './next-BWTklBmN.js';
|
|
2
|
+
export { c as BorderDrawOptions, C as CanvasPainter, d as CanvasPainterOptions, S as SelectionManager, T as TUI, e as TUIProps } from './next-BWTklBmN.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import 'react/jsx-runtime';
|
package/dist/index.js
CHANGED
|
@@ -39876,6 +39876,9 @@ var BrowserRenderContext = class extends EventEmitter {
|
|
|
39876
39876
|
_onRenderRequest = null;
|
|
39877
39877
|
_lifecyclePasses = /* @__PURE__ */ new Set();
|
|
39878
39878
|
_focusedRenderable = null;
|
|
39879
|
+
cursorColor = null;
|
|
39880
|
+
cursorStyleType = "block";
|
|
39881
|
+
cursorBlinking = false;
|
|
39879
39882
|
keyInput;
|
|
39880
39883
|
_internalKeyInput;
|
|
39881
39884
|
constructor(width, height, widthMethod = "wcwidth") {
|
|
@@ -39929,9 +39932,19 @@ var BrowserRenderContext = class extends EventEmitter {
|
|
|
39929
39932
|
}
|
|
39930
39933
|
setCursorPosition(_x, _y, _visible) {
|
|
39931
39934
|
}
|
|
39932
|
-
setCursorStyle(
|
|
39935
|
+
setCursorStyle(options) {
|
|
39936
|
+
if (options.color) {
|
|
39937
|
+
this.cursorColor = options.color;
|
|
39938
|
+
}
|
|
39939
|
+
if (options.style) {
|
|
39940
|
+
this.cursorStyleType = options.style;
|
|
39941
|
+
}
|
|
39942
|
+
if (options.blinking !== void 0) {
|
|
39943
|
+
this.cursorBlinking = options.blinking;
|
|
39944
|
+
}
|
|
39933
39945
|
}
|
|
39934
|
-
setCursorColor(
|
|
39946
|
+
setCursorColor(color) {
|
|
39947
|
+
this.cursorColor = color;
|
|
39935
39948
|
}
|
|
39936
39949
|
setMousePointer(_shape) {
|
|
39937
39950
|
}
|
|
@@ -41544,6 +41557,11 @@ var BrowserBuffer = class _BrowserBuffer {
|
|
|
41544
41557
|
// Link registry for clickable links
|
|
41545
41558
|
linkRegistry = /* @__PURE__ */ new Map();
|
|
41546
41559
|
nextLinkId = 1;
|
|
41560
|
+
/** Cursor rendering config -- set by renderer before pipeline, read by drawEditorView */
|
|
41561
|
+
cursorColor = null;
|
|
41562
|
+
cursorStyleType = "block";
|
|
41563
|
+
/** Line cursor position -- set by drawEditorView during pipeline, read by renderer after */
|
|
41564
|
+
lineCursorPosition = null;
|
|
41547
41565
|
constructor(width, height, options = {}) {
|
|
41548
41566
|
this._width = width;
|
|
41549
41567
|
this._height = height;
|
|
@@ -41991,7 +42009,7 @@ var BrowserBuffer = class _BrowserBuffer {
|
|
|
41991
42009
|
};
|
|
41992
42010
|
const visibleRows = viewport.height > 0 ? viewport.height : this._height - y2;
|
|
41993
42011
|
if (text === "" && editorView._placeholderChunks && editorView._placeholderChunks.length > 0) {
|
|
41994
|
-
let curX = x2;
|
|
42012
|
+
let curX = this.cursorStyleType === "line" ? x2 + 1 : x2;
|
|
41995
42013
|
for (const chunk of editorView._placeholderChunks) {
|
|
41996
42014
|
const chunkFg = chunk.fg ?? dfg;
|
|
41997
42015
|
const chunkBg = chunk.bg ?? dbg;
|
|
@@ -42025,10 +42043,22 @@ var BrowserBuffer = class _BrowserBuffer {
|
|
|
42025
42043
|
const cursorX = x2 + cursor.visualCol;
|
|
42026
42044
|
const cursorY = y2 + cursor.visualRow;
|
|
42027
42045
|
if (cursorX >= 0 && cursorX < this._width && cursorY >= 0 && cursorY < this._height) {
|
|
42028
|
-
const
|
|
42029
|
-
|
|
42030
|
-
|
|
42031
|
-
|
|
42046
|
+
const cursorFg = this.cursorColor ?? dfg;
|
|
42047
|
+
if (this.cursorStyleType === "line") {
|
|
42048
|
+
this.lineCursorPosition = { x: cursorX, y: cursorY };
|
|
42049
|
+
} else {
|
|
42050
|
+
const idx = cursorY * this._width + cursorX;
|
|
42051
|
+
const charCode = this.char[idx];
|
|
42052
|
+
const ch = charCode === 0 || charCode === 32 ? " " : String.fromCodePoint(charCode);
|
|
42053
|
+
const offset = idx * 4;
|
|
42054
|
+
const cellBg = {
|
|
42055
|
+
r: this.bg[offset],
|
|
42056
|
+
g: this.bg[offset + 1],
|
|
42057
|
+
b: this.bg[offset + 2],
|
|
42058
|
+
a: this.bg[offset + 3] || 1
|
|
42059
|
+
};
|
|
42060
|
+
this.setCell(cursorX, cursorY, ch, cursorFg, cellBg, 32);
|
|
42061
|
+
}
|
|
42032
42062
|
}
|
|
42033
42063
|
}
|
|
42034
42064
|
}
|
|
@@ -42065,6 +42095,8 @@ var TextAttributes3 = {
|
|
|
42065
42095
|
UNDERLINE_DOTTED: 1 << 6
|
|
42066
42096
|
};
|
|
42067
42097
|
var CONTINUATION2 = 3221225472;
|
|
42098
|
+
var LINE_CURSOR_WIDTH = 8;
|
|
42099
|
+
var CURSOR_BLINK_INTERVAL_MS = 530;
|
|
42068
42100
|
var BOX_DRAWING_MAP = {
|
|
42069
42101
|
// Light lines
|
|
42070
42102
|
9472: { left: true, right: true, type: "light" },
|
|
@@ -42344,7 +42376,7 @@ var CanvasPainter = class {
|
|
|
42344
42376
|
getCellSize() {
|
|
42345
42377
|
return { width: this.cellWidth, height: this.cellHeight };
|
|
42346
42378
|
}
|
|
42347
|
-
paint(ctx, buffer, selection) {
|
|
42379
|
+
paint(ctx, buffer, selection, cursor) {
|
|
42348
42380
|
const { char, fg: fg2, bg: bg2, attributes } = buffer;
|
|
42349
42381
|
const cols = buffer.width;
|
|
42350
42382
|
const rows = buffer.height;
|
|
@@ -42541,6 +42573,13 @@ var CanvasPainter = class {
|
|
|
42541
42573
|
}
|
|
42542
42574
|
}
|
|
42543
42575
|
}
|
|
42576
|
+
if (cursor) {
|
|
42577
|
+
const visible = !cursor.blinking || Math.floor(performance.now() / CURSOR_BLINK_INTERVAL_MS) % 2 === 0;
|
|
42578
|
+
if (visible) {
|
|
42579
|
+
ctx.fillStyle = rgbaToCSS(cursor.color.r, cursor.color.g, cursor.color.b, cursor.color.a ?? 1);
|
|
42580
|
+
ctx.fillRect(cursor.x * cw, cursor.y * ch, LINE_CURSOR_WIDTH, ch);
|
|
42581
|
+
}
|
|
42582
|
+
}
|
|
42544
42583
|
if (selection?.active) {
|
|
42545
42584
|
ctx.fillStyle = "rgba(51, 153, 255, 0.3)";
|
|
42546
42585
|
for (let row = 0; row < rows; row++) {
|
|
@@ -42873,9 +42912,17 @@ var BrowserRenderer = class _BrowserRenderer {
|
|
|
42873
42912
|
const now = performance.now();
|
|
42874
42913
|
const deltaTime = now - this.lastTime;
|
|
42875
42914
|
this.lastTime = now;
|
|
42876
|
-
|
|
42877
|
-
this.needsRender
|
|
42878
|
-
|
|
42915
|
+
let didRender = false;
|
|
42916
|
+
if (this.needsRender) {
|
|
42917
|
+
this.needsRender = false;
|
|
42918
|
+
didRender = true;
|
|
42919
|
+
this.buffer.cursorColor = this.renderContext.cursorColor;
|
|
42920
|
+
this.buffer.cursorStyleType = this.renderContext.cursorStyleType;
|
|
42921
|
+
this.buffer.lineCursorPosition = null;
|
|
42922
|
+
executeRenderPipeline(this.buffer, this.renderContext, this.root, deltaTime);
|
|
42923
|
+
}
|
|
42924
|
+
const cursorOverlay = this.buildCursorOverlay();
|
|
42925
|
+
if (!didRender && !cursorOverlay?.blinking) return;
|
|
42879
42926
|
const dpr = window.devicePixelRatio || 1;
|
|
42880
42927
|
this.ctx2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
42881
42928
|
if (this.backgroundColor) {
|
|
@@ -42884,8 +42931,18 @@ var BrowserRenderer = class _BrowserRenderer {
|
|
|
42884
42931
|
} else {
|
|
42885
42932
|
this.ctx2d.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
42886
42933
|
}
|
|
42887
|
-
this.painter.paint(this.ctx2d, this.buffer, this.selection);
|
|
42934
|
+
this.painter.paint(this.ctx2d, this.buffer, this.selection, cursorOverlay);
|
|
42888
42935
|
};
|
|
42936
|
+
buildCursorOverlay() {
|
|
42937
|
+
const pos = this.buffer.lineCursorPosition;
|
|
42938
|
+
if (!pos || !this.renderContext.cursorColor) return null;
|
|
42939
|
+
return {
|
|
42940
|
+
x: pos.x,
|
|
42941
|
+
y: pos.y,
|
|
42942
|
+
color: this.renderContext.cursorColor,
|
|
42943
|
+
blinking: this.renderContext.cursorBlinking
|
|
42944
|
+
};
|
|
42945
|
+
}
|
|
42889
42946
|
resize(cols, rows) {
|
|
42890
42947
|
this.cols = cols;
|
|
42891
42948
|
this.rows = rows;
|
|
@@ -42930,7 +42987,7 @@ var BrowserRenderer = class _BrowserRenderer {
|
|
|
42930
42987
|
PageDown: "pagedown"
|
|
42931
42988
|
};
|
|
42932
42989
|
handleKeyDown(event) {
|
|
42933
|
-
if (_BrowserRenderer.PREVENT_DEFAULT_KEYS.has(event.key)) {
|
|
42990
|
+
if (_BrowserRenderer.PREVENT_DEFAULT_KEYS.has(event.key) || event.key.length === 1 && !event.metaKey && !event.ctrlKey) {
|
|
42934
42991
|
event.preventDefault();
|
|
42935
42992
|
}
|
|
42936
42993
|
if (this.selection.active && (event.key === "c" || event.key === "\xE7") && (event.metaKey || event.ctrlKey || event.altKey)) {
|