@opentui/core 0.1.94 → 0.1.96
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/3d.js +1 -1
- package/{index-t7fkn9sh.js → index-ahc2zd0v.js} +28 -8
- package/index-ahc2zd0v.js.map +10 -0
- package/{index-t2rqapaa.js → index-dg6qsc3m.js} +5142 -6436
- package/{index-t2rqapaa.js.map → index-dg6qsc3m.js.map} +4 -7
- package/{index-wv534m5j.js → index-vy1rm1x3.js} +2246 -810
- package/{index-wv534m5j.js.map → index-vy1rm1x3.js.map} +9 -6
- package/index.js +11 -5
- package/index.js.map +1 -1
- package/package.json +7 -7
- package/renderables/EditBufferRenderable.d.ts +76 -1
- package/renderables/Textarea.d.ts +0 -51
- package/renderables/index.d.ts +1 -0
- package/renderer.d.ts +3 -0
- package/runtime-plugin-support.js +3 -3
- package/runtime-plugin.d.ts +5 -0
- package/runtime-plugin.js +3 -3
- package/testing.js +1 -1
- package/types.d.ts +3 -0
- package/index-t7fkn9sh.js.map +0 -10
package/index.js
CHANGED
|
@@ -15,8 +15,6 @@ import {
|
|
|
15
15
|
DEUTERANOPIA_SIM_MATRIX,
|
|
16
16
|
DiffRenderable,
|
|
17
17
|
DistortionEffect,
|
|
18
|
-
EditBuffer,
|
|
19
|
-
EditorView,
|
|
20
18
|
FlamesEffect,
|
|
21
19
|
FrameBuffer,
|
|
22
20
|
FrameBufferRenderable,
|
|
@@ -81,7 +79,7 @@ import {
|
|
|
81
79
|
registerCorePlugin,
|
|
82
80
|
resolveCoreSlot,
|
|
83
81
|
vstyles
|
|
84
|
-
} from "./index-
|
|
82
|
+
} from "./index-dg6qsc3m.js";
|
|
85
83
|
import {
|
|
86
84
|
ASCIIFontSelectionHelper,
|
|
87
85
|
ATTRIBUTE_BASE_BITS,
|
|
@@ -94,6 +92,10 @@ import {
|
|
|
94
92
|
ConsolePosition,
|
|
95
93
|
DataPathsManager,
|
|
96
94
|
DebugOverlayCorner,
|
|
95
|
+
EditBuffer,
|
|
96
|
+
EditBufferRenderable,
|
|
97
|
+
EditBufferRenderableEvents,
|
|
98
|
+
EditorView,
|
|
97
99
|
ExtmarksController,
|
|
98
100
|
InternalKeyHandler,
|
|
99
101
|
KeyEvent,
|
|
@@ -184,6 +186,7 @@ import {
|
|
|
184
186
|
hsvToRgb,
|
|
185
187
|
infoStringToFiletype,
|
|
186
188
|
instantiate,
|
|
189
|
+
isEditBufferRenderable,
|
|
187
190
|
isRenderable,
|
|
188
191
|
isStyledText,
|
|
189
192
|
isVNode,
|
|
@@ -233,7 +236,7 @@ import {
|
|
|
233
236
|
white,
|
|
234
237
|
wrapWithDelegates,
|
|
235
238
|
yellow
|
|
236
|
-
} from "./index-
|
|
239
|
+
} from "./index-vy1rm1x3.js";
|
|
237
240
|
export {
|
|
238
241
|
yellow,
|
|
239
242
|
wrapWithDelegates,
|
|
@@ -288,6 +291,7 @@ export {
|
|
|
288
291
|
isTextNodeRenderable,
|
|
289
292
|
isStyledText,
|
|
290
293
|
isRenderable,
|
|
294
|
+
isEditBufferRenderable,
|
|
291
295
|
instantiate,
|
|
292
296
|
infoStringToFiletype,
|
|
293
297
|
hsvToRgb,
|
|
@@ -439,6 +443,8 @@ export {
|
|
|
439
443
|
FlamesEffect,
|
|
440
444
|
ExtmarksController,
|
|
441
445
|
EditorView,
|
|
446
|
+
EditBufferRenderableEvents,
|
|
447
|
+
EditBufferRenderable,
|
|
442
448
|
EditBuffer,
|
|
443
449
|
DistortionEffect,
|
|
444
450
|
DiffRenderable,
|
|
@@ -468,5 +474,5 @@ export {
|
|
|
468
474
|
ACHROMATOPSIA_MATRIX
|
|
469
475
|
};
|
|
470
476
|
|
|
471
|
-
//# debugId=
|
|
477
|
+
//# debugId=FD2591B7A1AB109264756E2164756E21
|
|
472
478
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.96",
|
|
8
8
|
"description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"bun-webgpu": "0.1.5",
|
|
68
68
|
"planck": "^1.4.2",
|
|
69
69
|
"three": "0.177.0",
|
|
70
|
-
"@opentui/core-darwin-x64": "0.1.
|
|
71
|
-
"@opentui/core-darwin-arm64": "0.1.
|
|
72
|
-
"@opentui/core-linux-x64": "0.1.
|
|
73
|
-
"@opentui/core-linux-arm64": "0.1.
|
|
74
|
-
"@opentui/core-win32-x64": "0.1.
|
|
75
|
-
"@opentui/core-win32-arm64": "0.1.
|
|
70
|
+
"@opentui/core-darwin-x64": "0.1.96",
|
|
71
|
+
"@opentui/core-darwin-arm64": "0.1.96",
|
|
72
|
+
"@opentui/core-linux-x64": "0.1.96",
|
|
73
|
+
"@opentui/core-linux-arm64": "0.1.96",
|
|
74
|
+
"@opentui/core-win32-x64": "0.1.96",
|
|
75
|
+
"@opentui/core-win32-arm64": "0.1.96"
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -6,6 +6,17 @@ import { RGBA } from "../lib/RGBA.js";
|
|
|
6
6
|
import type { RenderContext, Highlight, CursorStyleOptions, LineInfoProvider, LineInfo } from "../types.js";
|
|
7
7
|
import type { OptimizedBuffer } from "../buffer.js";
|
|
8
8
|
import type { SyntaxStyle } from "../syntax-style.js";
|
|
9
|
+
declare const BrandedEditBufferRenderable: unique symbol;
|
|
10
|
+
export type EditorCapture = "escape" | "navigate" | "submit" | "tab";
|
|
11
|
+
export interface EditorTraits {
|
|
12
|
+
capture?: readonly EditorCapture[];
|
|
13
|
+
suspend?: boolean;
|
|
14
|
+
status?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare enum EditBufferRenderableEvents {
|
|
17
|
+
TRAITS_CHANGED = "traits-changed"
|
|
18
|
+
}
|
|
19
|
+
export declare function isEditBufferRenderable(obj: unknown): obj is EditBufferRenderable;
|
|
9
20
|
export interface CursorChangeEvent {
|
|
10
21
|
line: number;
|
|
11
22
|
visualColumn: number;
|
|
@@ -32,8 +43,10 @@ export interface EditBufferOptions extends RenderableOptions<EditBufferRenderabl
|
|
|
32
43
|
onContentChange?: (event: ContentChangeEvent) => void;
|
|
33
44
|
}
|
|
34
45
|
export declare abstract class EditBufferRenderable extends Renderable implements LineInfoProvider {
|
|
46
|
+
[BrandedEditBufferRenderable]: boolean;
|
|
35
47
|
protected _focusable: boolean;
|
|
36
48
|
selectable: boolean;
|
|
49
|
+
private _traits;
|
|
37
50
|
protected _textColor: RGBA;
|
|
38
51
|
protected _backgroundColor: RGBA;
|
|
39
52
|
protected _defaultAttributes: number;
|
|
@@ -85,9 +98,12 @@ export declare abstract class EditBufferRenderable extends Renderable implements
|
|
|
85
98
|
get visualCursor(): VisualCursor;
|
|
86
99
|
get cursorOffset(): number;
|
|
87
100
|
set cursorOffset(offset: number);
|
|
101
|
+
get cursorCharacterOffset(): number | undefined;
|
|
88
102
|
get textColor(): RGBA;
|
|
89
103
|
set textColor(value: RGBA | string | undefined);
|
|
90
104
|
get selectionBg(): RGBA | undefined;
|
|
105
|
+
get traits(): EditorTraits;
|
|
106
|
+
set traits(value: EditorTraits);
|
|
91
107
|
set selectionBg(value: RGBA | string | undefined);
|
|
92
108
|
get selectionFg(): RGBA | undefined;
|
|
93
109
|
set selectionFg(value: RGBA | string | undefined);
|
|
@@ -123,6 +139,65 @@ export declare abstract class EditBufferRenderable extends Renderable implements
|
|
|
123
139
|
start: number;
|
|
124
140
|
end: number;
|
|
125
141
|
} | null;
|
|
142
|
+
private refreshSelectionStyle;
|
|
143
|
+
private deleteSelectedText;
|
|
144
|
+
setSelection(start: number, end: number): void;
|
|
145
|
+
setSelectionInclusive(start: number, end: number): void;
|
|
146
|
+
clearSelection(): boolean;
|
|
147
|
+
deleteSelection(): boolean;
|
|
148
|
+
setCursor(row: number, col: number): void;
|
|
149
|
+
insertChar(char: string): void;
|
|
150
|
+
insertText(text: string): void;
|
|
151
|
+
deleteChar(): boolean;
|
|
152
|
+
deleteCharBackward(): boolean;
|
|
153
|
+
newLine(): boolean;
|
|
154
|
+
deleteLine(): boolean;
|
|
155
|
+
moveCursorLeft(options?: {
|
|
156
|
+
select?: boolean;
|
|
157
|
+
}): boolean;
|
|
158
|
+
moveCursorRight(options?: {
|
|
159
|
+
select?: boolean;
|
|
160
|
+
}): boolean;
|
|
161
|
+
moveCursorUp(options?: {
|
|
162
|
+
select?: boolean;
|
|
163
|
+
}): boolean;
|
|
164
|
+
moveCursorDown(options?: {
|
|
165
|
+
select?: boolean;
|
|
166
|
+
}): boolean;
|
|
167
|
+
gotoLine(line: number): void;
|
|
168
|
+
gotoLineStart(): void;
|
|
169
|
+
gotoLineTextEnd(): void;
|
|
170
|
+
gotoLineHome(options?: {
|
|
171
|
+
select?: boolean;
|
|
172
|
+
}): boolean;
|
|
173
|
+
gotoLineEnd(options?: {
|
|
174
|
+
select?: boolean;
|
|
175
|
+
}): boolean;
|
|
176
|
+
gotoVisualLineHome(options?: {
|
|
177
|
+
select?: boolean;
|
|
178
|
+
}): boolean;
|
|
179
|
+
gotoVisualLineEnd(options?: {
|
|
180
|
+
select?: boolean;
|
|
181
|
+
}): boolean;
|
|
182
|
+
gotoBufferHome(options?: {
|
|
183
|
+
select?: boolean;
|
|
184
|
+
}): boolean;
|
|
185
|
+
gotoBufferEnd(options?: {
|
|
186
|
+
select?: boolean;
|
|
187
|
+
}): boolean;
|
|
188
|
+
selectAll(): boolean;
|
|
189
|
+
deleteToLineEnd(): boolean;
|
|
190
|
+
deleteToLineStart(): boolean;
|
|
191
|
+
undo(): boolean;
|
|
192
|
+
redo(): boolean;
|
|
193
|
+
moveWordForward(options?: {
|
|
194
|
+
select?: boolean;
|
|
195
|
+
}): boolean;
|
|
196
|
+
moveWordBackward(options?: {
|
|
197
|
+
select?: boolean;
|
|
198
|
+
}): boolean;
|
|
199
|
+
deleteWordForward(): boolean;
|
|
200
|
+
deleteWordBackward(): boolean;
|
|
126
201
|
private setupMeasureFunc;
|
|
127
202
|
render(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
128
203
|
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
@@ -155,8 +230,8 @@ export declare abstract class EditBufferRenderable extends Renderable implements
|
|
|
155
230
|
replaceText(text: string): void;
|
|
156
231
|
clear(): void;
|
|
157
232
|
deleteRange(startLine: number, startCol: number, endLine: number, endCol: number): void;
|
|
158
|
-
insertText(text: string): void;
|
|
159
233
|
getTextRange(startOffset: number, endOffset: number): string;
|
|
160
234
|
getTextRangeByCoords(startRow: number, startCol: number, endRow: number, endCol: number): string;
|
|
161
235
|
protected updateSelectionForMovement(shiftPressed: boolean, isBeforeMovement: boolean): void;
|
|
162
236
|
}
|
|
237
|
+
export {};
|
|
@@ -41,57 +41,6 @@ export declare class TextareaRenderable extends EditBufferRenderable {
|
|
|
41
41
|
handlePaste(event: PasteEvent): void;
|
|
42
42
|
handleKeyPress(key: KeyEvent): boolean;
|
|
43
43
|
private updateColors;
|
|
44
|
-
insertChar(char: string): void;
|
|
45
|
-
insertText(text: string): void;
|
|
46
|
-
deleteChar(): boolean;
|
|
47
|
-
deleteCharBackward(): boolean;
|
|
48
|
-
private deleteSelectedText;
|
|
49
|
-
newLine(): boolean;
|
|
50
|
-
deleteLine(): boolean;
|
|
51
|
-
moveCursorLeft(options?: {
|
|
52
|
-
select?: boolean;
|
|
53
|
-
}): boolean;
|
|
54
|
-
moveCursorRight(options?: {
|
|
55
|
-
select?: boolean;
|
|
56
|
-
}): boolean;
|
|
57
|
-
moveCursorUp(options?: {
|
|
58
|
-
select?: boolean;
|
|
59
|
-
}): boolean;
|
|
60
|
-
moveCursorDown(options?: {
|
|
61
|
-
select?: boolean;
|
|
62
|
-
}): boolean;
|
|
63
|
-
gotoLine(line: number): void;
|
|
64
|
-
gotoLineHome(options?: {
|
|
65
|
-
select?: boolean;
|
|
66
|
-
}): boolean;
|
|
67
|
-
gotoLineEnd(options?: {
|
|
68
|
-
select?: boolean;
|
|
69
|
-
}): boolean;
|
|
70
|
-
gotoVisualLineHome(options?: {
|
|
71
|
-
select?: boolean;
|
|
72
|
-
}): boolean;
|
|
73
|
-
gotoVisualLineEnd(options?: {
|
|
74
|
-
select?: boolean;
|
|
75
|
-
}): boolean;
|
|
76
|
-
gotoBufferHome(options?: {
|
|
77
|
-
select?: boolean;
|
|
78
|
-
}): boolean;
|
|
79
|
-
gotoBufferEnd(options?: {
|
|
80
|
-
select?: boolean;
|
|
81
|
-
}): boolean;
|
|
82
|
-
selectAll(): boolean;
|
|
83
|
-
deleteToLineEnd(): boolean;
|
|
84
|
-
deleteToLineStart(): boolean;
|
|
85
|
-
undo(): boolean;
|
|
86
|
-
redo(): boolean;
|
|
87
|
-
moveWordForward(options?: {
|
|
88
|
-
select?: boolean;
|
|
89
|
-
}): boolean;
|
|
90
|
-
moveWordBackward(options?: {
|
|
91
|
-
select?: boolean;
|
|
92
|
-
}): boolean;
|
|
93
|
-
deleteWordForward(): boolean;
|
|
94
|
-
deleteWordBackward(): boolean;
|
|
95
44
|
focus(): void;
|
|
96
45
|
blur(): void;
|
|
97
46
|
get placeholder(): StyledText | string | null;
|
package/renderables/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./composition/constructs.js";
|
|
|
5
5
|
export * from "./composition/VRenderable.js";
|
|
6
6
|
export * from "./composition/vnode.js";
|
|
7
7
|
export * from "./Diff.js";
|
|
8
|
+
export * from "./EditBufferRenderable.js";
|
|
8
9
|
export * from "./FrameBuffer.js";
|
|
9
10
|
export * from "./Input.js";
|
|
10
11
|
export * from "./LineNumberRenderable.js";
|
package/renderer.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Selection } from "./lib/selection.js";
|
|
|
10
10
|
import { type ClipboardTarget } from "./lib/clipboard.js";
|
|
11
11
|
import { EventEmitter } from "events";
|
|
12
12
|
import { KeyHandler, InternalKeyHandler } from "./lib/KeyHandler.js";
|
|
13
|
+
import { type EditBufferRenderable } from "./renderables/EditBufferRenderable.js";
|
|
13
14
|
import { type TerminalColors, type GetPaletteOptions } from "./lib/terminal-palette.js";
|
|
14
15
|
import { type Clock } from "./lib/clock.js";
|
|
15
16
|
export interface CliRendererConfig {
|
|
@@ -111,6 +112,7 @@ export declare enum CliRenderEvents {
|
|
|
111
112
|
RESIZE = "resize",
|
|
112
113
|
FOCUS = "focus",
|
|
113
114
|
BLUR = "blur",
|
|
115
|
+
FOCUSED_EDITOR = "focused_editor",
|
|
114
116
|
THEME_MODE = "theme_mode",
|
|
115
117
|
CAPABILITIES = "capabilities",
|
|
116
118
|
SELECTION = "selection",
|
|
@@ -244,6 +246,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
|
|
|
244
246
|
unregisterLifecyclePass(renderable: Renderable): void;
|
|
245
247
|
getLifecyclePasses(): Set<Renderable>;
|
|
246
248
|
get currentFocusedRenderable(): Renderable | null;
|
|
249
|
+
get currentFocusedEditor(): EditBufferRenderable | null;
|
|
247
250
|
private normalizeClockTime;
|
|
248
251
|
private getElapsedMs;
|
|
249
252
|
focusRenderable(renderable: Renderable): void;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createRuntimePlugin,
|
|
4
4
|
runtimeModuleIdForSpecifier
|
|
5
|
-
} from "./index-
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
5
|
+
} from "./index-ahc2zd0v.js";
|
|
6
|
+
import"./index-dg6qsc3m.js";
|
|
7
|
+
import"./index-vy1rm1x3.js";
|
|
8
8
|
|
|
9
9
|
// src/runtime-plugin-support.ts
|
|
10
10
|
var {plugin: registerBunPlugin } = globalThis.Bun;
|
package/runtime-plugin.d.ts
CHANGED
|
@@ -2,9 +2,14 @@ import { type BunPlugin } from "bun";
|
|
|
2
2
|
export type RuntimeModuleExports = Record<string, unknown>;
|
|
3
3
|
export type RuntimeModuleLoader = () => RuntimeModuleExports | Promise<RuntimeModuleExports>;
|
|
4
4
|
export type RuntimeModuleEntry = RuntimeModuleExports | RuntimeModuleLoader;
|
|
5
|
+
export interface RuntimePluginRewriteOptions {
|
|
6
|
+
nodeModulesRuntimeSpecifiers?: boolean;
|
|
7
|
+
nodeModulesBareSpecifiers?: boolean;
|
|
8
|
+
}
|
|
5
9
|
export interface CreateRuntimePluginOptions {
|
|
6
10
|
core?: RuntimeModuleEntry;
|
|
7
11
|
additional?: Record<string, RuntimeModuleEntry>;
|
|
12
|
+
rewrite?: RuntimePluginRewriteOptions;
|
|
8
13
|
}
|
|
9
14
|
export declare const isCoreRuntimeModuleSpecifier: (specifier: string) => boolean;
|
|
10
15
|
export declare const runtimeModuleIdForSpecifier: (specifier: string) => string;
|
package/runtime-plugin.js
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
createRuntimePlugin,
|
|
4
4
|
isCoreRuntimeModuleSpecifier,
|
|
5
5
|
runtimeModuleIdForSpecifier
|
|
6
|
-
} from "./index-
|
|
7
|
-
import"./index-
|
|
8
|
-
import"./index-
|
|
6
|
+
} from "./index-ahc2zd0v.js";
|
|
7
|
+
import"./index-dg6qsc3m.js";
|
|
8
|
+
import"./index-vy1rm1x3.js";
|
|
9
9
|
export {
|
|
10
10
|
runtimeModuleIdForSpecifier,
|
|
11
11
|
isCoreRuntimeModuleSpecifier,
|
package/testing.js
CHANGED
package/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { EventEmitter } from "events";
|
|
|
3
3
|
import type { Selection } from "./lib/selection.js";
|
|
4
4
|
import type { Renderable } from "./Renderable.js";
|
|
5
5
|
import type { InternalKeyHandler, KeyHandler } from "./lib/KeyHandler.js";
|
|
6
|
+
import type { EditBufferRenderable } from "./renderables/EditBufferRenderable.js";
|
|
6
7
|
export declare const TextAttributes: {
|
|
7
8
|
NONE: number;
|
|
8
9
|
BOLD: number;
|
|
@@ -51,6 +52,7 @@ export interface RendererEvents {
|
|
|
51
52
|
arrayBuffers: number;
|
|
52
53
|
}) => void;
|
|
53
54
|
selection: (selection: Selection) => void;
|
|
55
|
+
focused_editor: (current: EditBufferRenderable | null, previous: EditBufferRenderable | null) => void;
|
|
54
56
|
"debugOverlay:toggle": (enabled: boolean) => void;
|
|
55
57
|
theme_mode: (mode: ThemeMode) => void;
|
|
56
58
|
}
|
|
@@ -74,6 +76,7 @@ export interface RenderContext extends EventEmitter {
|
|
|
74
76
|
getSelection: () => Selection | null;
|
|
75
77
|
requestSelectionUpdate: () => void;
|
|
76
78
|
currentFocusedRenderable: Renderable | null;
|
|
79
|
+
currentFocusedEditor: EditBufferRenderable | null;
|
|
77
80
|
focusRenderable: (renderable: Renderable) => void;
|
|
78
81
|
registerLifecyclePass: (renderable: Renderable) => void;
|
|
79
82
|
unregisterLifecyclePass: (renderable: Renderable) => void;
|
package/index-t7fkn9sh.js.map
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/runtime-plugin.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { type BunPlugin } from \"bun\"\nimport * as coreRuntime from \"./index.js\"\n\nexport type RuntimeModuleExports = Record<string, unknown>\nexport type RuntimeModuleLoader = () => RuntimeModuleExports | Promise<RuntimeModuleExports>\nexport type RuntimeModuleEntry = RuntimeModuleExports | RuntimeModuleLoader\n\nexport interface CreateRuntimePluginOptions {\n core?: RuntimeModuleEntry\n additional?: Record<string, RuntimeModuleEntry>\n}\n\nconst CORE_RUNTIME_SPECIFIER = \"@opentui/core\"\nconst CORE_TESTING_RUNTIME_SPECIFIER = \"@opentui/core/testing\"\nconst RUNTIME_MODULE_PREFIX = \"opentui:runtime-module:\"\nconst MAX_RUNTIME_RESOLVE_PARENTS = 64\n\nconst DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS = [CORE_RUNTIME_SPECIFIER, CORE_TESTING_RUNTIME_SPECIFIER] as const\n\nconst DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET = new Set<string>(DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS)\n\nexport const isCoreRuntimeModuleSpecifier = (specifier: string): boolean => {\n return DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET.has(specifier)\n}\n\nconst loadCoreTestingRuntimeModule = async (): Promise<RuntimeModuleExports> => {\n return (await import(\"./testing.js\")) as RuntimeModuleExports\n}\n\nconst escapeRegExp = (value: string): string => {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n}\n\nconst exactSpecifierFilter = (specifier: string): RegExp => {\n return new RegExp(`^${escapeRegExp(specifier)}$`)\n}\n\nexport const runtimeModuleIdForSpecifier = (specifier: string): string => {\n return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`\n}\n\nconst resolveRuntimeModuleExports = async (moduleEntry: RuntimeModuleEntry): Promise<RuntimeModuleExports> => {\n if (typeof moduleEntry === \"function\") {\n return await moduleEntry()\n }\n\n return moduleEntry\n}\n\nconst sourcePath = (path: string): string => {\n const searchIndex = path.indexOf(\"?\")\n const hashIndex = path.indexOf(\"#\")\n const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0]\n return end === undefined ? path : path.slice(0, end)\n}\n\nconst runtimeLoaderForPath = (path: string): \"js\" | \"ts\" | \"jsx\" | \"tsx\" | null => {\n const cleanPath = sourcePath(path)\n\n if (cleanPath.endsWith(\".tsx\")) {\n return \"tsx\"\n }\n\n if (cleanPath.endsWith(\".jsx\")) {\n return \"jsx\"\n }\n\n if (cleanPath.endsWith(\".ts\") || cleanPath.endsWith(\".mts\") || cleanPath.endsWith(\".cts\")) {\n return \"ts\"\n }\n\n if (cleanPath.endsWith(\".js\") || cleanPath.endsWith(\".mjs\") || cleanPath.endsWith(\".cjs\")) {\n return \"js\"\n }\n\n return null\n}\n\nconst runtimeSourceFilter = /^(?!.*(?:\\/|\\\\)node_modules(?:\\/|\\\\)).*\\.(?:[cm]?js|[cm]?ts|jsx|tsx)(?:[?#].*)?$/\n\nconst resolveImportSpecifierPatterns = [\n /(from\\s+[\"'])([^\"']+)([\"'])/g,\n /(import\\s+[\"'])([^\"']+)([\"'])/g,\n /(import\\s*\\(\\s*[\"'])([^\"']+)([\"']\\s*\\))/g,\n /(require\\s*\\(\\s*[\"'])([^\"']+)([\"']\\s*\\))/g,\n] as const\n\nconst isBareSpecifier = (specifier: string): boolean => {\n if (specifier.startsWith(\".\") || specifier.startsWith(\"/\") || specifier.startsWith(\"\\\\\")) {\n return false\n }\n\n if (\n specifier.startsWith(\"node:\") ||\n specifier.startsWith(\"bun:\") ||\n specifier.startsWith(\"http:\") ||\n specifier.startsWith(\"https:\") ||\n specifier.startsWith(\"file:\") ||\n specifier.startsWith(\"data:\")\n ) {\n return false\n }\n\n if (specifier.startsWith(RUNTIME_MODULE_PREFIX)) {\n return false\n }\n\n return true\n}\n\nconst registerResolveParent = (resolveParentsByRecency: string[], resolveParent: string): void => {\n const existingIndex = resolveParentsByRecency.indexOf(resolveParent)\n if (existingIndex >= 0) {\n resolveParentsByRecency.splice(existingIndex, 1)\n }\n\n resolveParentsByRecency.push(resolveParent)\n\n if (resolveParentsByRecency.length > MAX_RUNTIME_RESOLVE_PARENTS) {\n resolveParentsByRecency.shift()\n }\n}\n\nconst rewriteImportSpecifiers = (code: string, resolveReplacement: (specifier: string) => string | null): string => {\n let transformedCode = code\n\n for (const pattern of resolveImportSpecifierPatterns) {\n transformedCode = transformedCode.replace(pattern, (fullMatch, prefix, specifier, suffix) => {\n const replacement = resolveReplacement(specifier)\n if (!replacement || replacement === specifier) {\n return fullMatch\n }\n\n return `${prefix}${replacement}${suffix}`\n })\n }\n\n return transformedCode\n}\n\nconst resolveFromParent = (specifier: string, parent: string): string | null => {\n try {\n const resolvedSpecifier = import.meta.resolve(specifier, parent)\n if (\n resolvedSpecifier === specifier ||\n resolvedSpecifier.startsWith(\"node:\") ||\n resolvedSpecifier.startsWith(\"bun:\")\n ) {\n return null\n }\n\n return resolvedSpecifier\n } catch {\n return null\n }\n}\n\nconst rewriteImportsFromResolveParents = (code: string, resolveParentsByRecency: string[]): string => {\n if (resolveParentsByRecency.length === 0) {\n return code\n }\n\n const resolveFromParents = (specifier: string): string | null => {\n if (!isBareSpecifier(specifier)) {\n return null\n }\n\n for (let index = resolveParentsByRecency.length - 1; index >= 0; index -= 1) {\n const resolveParent = resolveParentsByRecency[index]\n const resolvedSpecifier = resolveFromParent(specifier, resolveParent)\n if (resolvedSpecifier) {\n return resolvedSpecifier\n }\n }\n\n return null\n }\n\n return rewriteImportSpecifiers(code, resolveFromParents)\n}\n\nconst rewriteRuntimeSpecifiers = (code: string, runtimeModuleIdsBySpecifier: Map<string, string>): string => {\n return rewriteImportSpecifiers(code, (specifier) => {\n const runtimeModuleId = runtimeModuleIdsBySpecifier.get(specifier)\n return runtimeModuleId ?? null\n })\n}\n\nexport function createRuntimePlugin(input: CreateRuntimePluginOptions = {}): BunPlugin {\n const runtimeModules = new Map<string, RuntimeModuleEntry>()\n runtimeModules.set(CORE_RUNTIME_SPECIFIER, input.core ?? (coreRuntime as RuntimeModuleExports))\n runtimeModules.set(CORE_TESTING_RUNTIME_SPECIFIER, loadCoreTestingRuntimeModule)\n\n for (const [specifier, moduleEntry] of Object.entries(input.additional ?? {})) {\n runtimeModules.set(specifier, moduleEntry)\n }\n\n const runtimeModuleIdsBySpecifier = new Map<string, string>()\n for (const specifier of runtimeModules.keys()) {\n runtimeModuleIdsBySpecifier.set(specifier, runtimeModuleIdForSpecifier(specifier))\n }\n\n return {\n name: \"bun-plugin-opentui-runtime-modules\",\n setup: (build) => {\n const resolveParentsByRecency: string[] = []\n\n for (const [specifier, moduleEntry] of runtimeModules.entries()) {\n const moduleId = runtimeModuleIdsBySpecifier.get(specifier)\n\n if (!moduleId) {\n continue\n }\n\n build.module(moduleId, async () => ({\n exports: await resolveRuntimeModuleExports(moduleEntry),\n loader: \"object\",\n }))\n\n build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }))\n }\n\n build.onLoad({ filter: runtimeSourceFilter }, async (args) => {\n const path = sourcePath(args.path)\n const loader = runtimeLoaderForPath(args.path)\n if (!loader) {\n throw new Error(`Unable to determine runtime loader for path: ${args.path}`)\n }\n\n const file = Bun.file(path)\n const contents = await file.text()\n const runtimeRewrittenContents = rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier)\n\n if (runtimeRewrittenContents !== contents) {\n registerResolveParent(resolveParentsByRecency, path)\n }\n\n const transformedContents = rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency)\n\n return {\n contents: transformedContents,\n loader,\n }\n })\n },\n }\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;;AAYA,IAAM,yBAAyB;AAC/B,IAAM,iCAAiC;AACvC,IAAM,wBAAwB;AAC9B,IAAM,8BAA8B;AAEpC,IAAM,yCAAyC,CAAC,wBAAwB,8BAA8B;AAEtG,IAAM,4CAA4C,IAAI,IAAY,sCAAsC;AAEjG,IAAM,+BAA+B,CAAC,cAA+B;AAAA,EAC1E,OAAO,0CAA0C,IAAI,SAAS;AAAA;AAGhE,IAAM,+BAA+B,YAA2C;AAAA,EAC9E,OAAQ,MAAa;AAAA;AAGvB,IAAM,eAAe,CAAC,UAA0B;AAAA,EAC9C,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AAAA;AAGpD,IAAM,uBAAuB,CAAC,cAA8B;AAAA,EAC1D,OAAO,IAAI,OAAO,IAAI,aAAa,SAAS,IAAI;AAAA;AAG3C,IAAM,8BAA8B,CAAC,cAA8B;AAAA,EACxE,OAAO,GAAG,wBAAwB,mBAAmB,SAAS;AAAA;AAGhE,IAAM,8BAA8B,OAAO,gBAAmE;AAAA,EAC5G,IAAI,OAAO,gBAAgB,YAAY;AAAA,IACrC,OAAO,MAAM,YAAY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