@zenbu-labs/pixel 0.0.0 → 0.0.13
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/bin.d.ts +2 -0
- package/dist/bin.js +161 -0
- package/dist/bootstrap.d.ts +1 -0
- package/dist/bootstrap.js +75 -0
- package/dist/context-menu.d.ts +20 -0
- package/dist/context-menu.js +57 -0
- package/dist/debug.d.ts +1 -0
- package/dist/debug.js +9 -0
- package/dist/devtools-layout.d.ts +21 -0
- package/dist/devtools-layout.js +45 -0
- package/dist/devtools.d.ts +33 -0
- package/dist/devtools.js +125 -0
- package/dist/electron/index.d.ts +3 -0
- package/dist/electron/index.js +4 -0
- package/dist/host/guest.d.ts +5 -0
- package/dist/host/guest.js +178 -0
- package/dist/host/server.d.ts +91 -0
- package/dist/host/server.js +296 -0
- package/dist/host/shell.d.ts +35 -0
- package/dist/host/shell.js +113 -0
- package/dist/host/strip.d.ts +6 -0
- package/dist/host/strip.js +63 -0
- package/dist/icons.d.ts +30 -0
- package/dist/icons.js +58 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +39 -0
- package/dist/instances.d.ts +30 -0
- package/dist/instances.js +177 -0
- package/dist/layout.d.ts +5 -0
- package/dist/layout.js +34 -0
- package/dist/popup.d.ts +21 -0
- package/dist/popup.js +47 -0
- package/dist/preload/index.d.ts +15 -0
- package/dist/preload/index.js +3 -0
- package/dist/react/colors.d.ts +3 -0
- package/dist/react/colors.js +25 -0
- package/dist/react/components.d.ts +21 -0
- package/dist/react/components.js +45 -0
- package/dist/react/devtools/app.d.ts +3 -0
- package/dist/react/devtools/app.js +89 -0
- package/dist/react/devtools/console-capture.d.ts +1 -0
- package/dist/react/devtools/console-capture.js +41 -0
- package/dist/react/devtools/controller.d.ts +45 -0
- package/dist/react/devtools/controller.js +252 -0
- package/dist/react/devtools/elements.d.ts +4 -0
- package/dist/react/devtools/elements.js +152 -0
- package/dist/react/devtools/export-profile.d.ts +2 -0
- package/dist/react/devtools/export-profile.js +225 -0
- package/dist/react/devtools/fiber-hook.d.ts +1 -0
- package/dist/react/devtools/fiber-hook.js +89 -0
- package/dist/react/devtools/log-panel.d.ts +4 -0
- package/dist/react/devtools/log-panel.js +113 -0
- package/dist/react/devtools/profiler.d.ts +11 -0
- package/dist/react/devtools/profiler.js +374 -0
- package/dist/react/devtools/store.d.ts +27 -0
- package/dist/react/devtools/store.js +61 -0
- package/dist/react/devtools/stores.d.ts +92 -0
- package/dist/react/devtools/stores.js +41 -0
- package/dist/react/devtools/theme.d.ts +35 -0
- package/dist/react/devtools/theme.js +77 -0
- package/dist/react/devtools/ui.d.ts +24 -0
- package/dist/react/devtools/ui.js +59 -0
- package/dist/react/index.d.ts +110 -0
- package/dist/react/index.js +538 -0
- package/dist/react/markdown.d.ts +25 -0
- package/dist/react/markdown.js +270 -0
- package/dist/react/native.d.ts +116 -0
- package/dist/react/native.js +56 -0
- package/dist/react/reconciler-config.d.ts +241 -0
- package/dist/react/reconciler-config.js +412 -0
- package/dist/react/styles.d.ts +88 -0
- package/dist/react/styles.js +85 -0
- package/dist/react/surface.d.ts +55 -0
- package/dist/react/surface.js +74 -0
- package/dist/registry.d.ts +53 -0
- package/dist/registry.js +193 -0
- package/dist/root.d.ts +19 -0
- package/dist/root.js +342 -0
- package/dist/sandbox.d.ts +4 -0
- package/dist/sandbox.js +84 -0
- package/dist/scale.d.ts +7 -0
- package/dist/scale.js +31 -0
- package/dist/ssh/index.d.ts +58 -0
- package/dist/ssh/index.js +445 -0
- package/dist/terminal/applescript.d.ts +2 -0
- package/dist/terminal/applescript.js +20 -0
- package/dist/terminal/detect.d.ts +10 -0
- package/dist/terminal/detect.js +34 -0
- package/dist/terminal/graphics.d.ts +9 -0
- package/dist/terminal/graphics.js +142 -0
- package/dist/terminal/index.d.ts +12 -0
- package/dist/terminal/index.js +23 -0
- package/dist/terminal/run.d.ts +2 -0
- package/dist/terminal/run.js +15 -0
- package/dist/terminal/shared.d.ts +20 -0
- package/dist/terminal/shared.js +88 -0
- package/dist/terminal/terminal.d.ts +66 -0
- package/dist/terminal/terminal.js +6 -0
- package/dist/terminal/terminals/cmux.d.ts +2 -0
- package/dist/terminal/terminals/cmux.js +98 -0
- package/dist/terminal/terminals/ghostty-script.d.ts +1 -0
- package/dist/terminal/terminals/ghostty-script.js +179 -0
- package/dist/terminal/terminals/ghostty.d.ts +2 -0
- package/dist/terminal/terminals/ghostty.js +336 -0
- package/dist/terminal/terminals/herdr.d.ts +2 -0
- package/dist/terminal/terminals/herdr.js +141 -0
- package/dist/terminal/terminals/index.d.ts +5 -0
- package/dist/terminal/terminals/index.js +26 -0
- package/dist/terminal/terminals/kitty.d.ts +2 -0
- package/dist/terminal/terminals/kitty.js +209 -0
- package/dist/terminal/terminals/supacode.d.ts +2 -0
- package/dist/terminal/terminals/supacode.js +79 -0
- package/dist/terminal/terminals/tmux.d.ts +2 -0
- package/dist/terminal/terminals/tmux.js +132 -0
- package/dist/terminal/terminals/tty7.d.ts +2 -0
- package/dist/terminal/terminals/tty7.js +58 -0
- package/dist/terminal/terminals/vscode.d.ts +2 -0
- package/dist/terminal/terminals/vscode.js +13 -0
- package/dist/terminal/terminals/wezterm.d.ts +2 -0
- package/dist/terminal/terminals/wezterm.js +59 -0
- package/dist/theme.d.ts +22 -0
- package/dist/theme.js +40 -0
- package/dist/web/browser-session.d.ts +13 -0
- package/dist/web/browser-session.js +186 -0
- package/dist/web/cursor.d.ts +1 -0
- package/dist/web/cursor.js +24 -0
- package/dist/web/devtools.d.ts +39 -0
- package/dist/web/devtools.js +300 -0
- package/dist/web/favicon.d.ts +7 -0
- package/dist/web/favicon.js +73 -0
- package/dist/web/frame-rate.d.ts +1 -0
- package/dist/web/frame-rate.js +12 -0
- package/dist/web/host.d.ts +123 -0
- package/dist/web/host.js +573 -0
- package/dist/web/input.d.ts +49 -0
- package/dist/web/input.js +468 -0
- package/dist/web/offscreen.d.ts +2 -0
- package/dist/web/offscreen.js +23 -0
- package/dist/web/paint.d.ts +11 -0
- package/dist/web/paint.js +128 -0
- package/dist/web/popup.d.ts +40 -0
- package/dist/web/popup.js +144 -0
- package/dist/web/session.d.ts +20 -0
- package/dist/web/session.js +110 -0
- package/dist/web/types.d.ts +38 -0
- package/dist/web/types.js +39 -0
- package/dist/web/zoom.d.ts +5 -0
- package/dist/web/zoom.js +36 -0
- package/dist/webview.d.ts +55 -0
- package/dist/webview.js +481 -0
- package/package.json +69 -3
- package/scripts/apparmor.sh +71 -0
- package/scripts/postinstall.mjs +150 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.reconciler = exports.Bridge = exports.DEVTOOLS_VIEW = exports.APP_VIEW = void 0;
|
|
7
|
+
exports.getBridge = getBridge;
|
|
8
|
+
exports.devtoolsBridge = devtoolsBridge;
|
|
9
|
+
exports.setDevtoolsBridge = setDevtoolsBridge;
|
|
10
|
+
const react_reconciler_1 = __importDefault(require("react-reconciler"));
|
|
11
|
+
const constants_1 = require("react-reconciler/constants");
|
|
12
|
+
const native_1 = require("./native");
|
|
13
|
+
const styles_1 = require("./styles");
|
|
14
|
+
const surface_1 = require("./surface");
|
|
15
|
+
exports.APP_VIEW = 0;
|
|
16
|
+
exports.DEVTOOLS_VIEW = 1;
|
|
17
|
+
class Bridge {
|
|
18
|
+
engine;
|
|
19
|
+
propsById = [new Map(), new Map()];
|
|
20
|
+
containers = [null, null];
|
|
21
|
+
onFlush = null;
|
|
22
|
+
onTreeMutation = null;
|
|
23
|
+
afterCommit = null;
|
|
24
|
+
queues = [[], []];
|
|
25
|
+
nextId = 1;
|
|
26
|
+
seq = 0;
|
|
27
|
+
constructor(tty, wrapper, sessionEnv, host) {
|
|
28
|
+
this.engine = (0, native_1.createNativeEngine)(tty, wrapper, sessionEnv, host);
|
|
29
|
+
if (!defaultBridge)
|
|
30
|
+
defaultBridge = this;
|
|
31
|
+
}
|
|
32
|
+
allocId() {
|
|
33
|
+
return this.nextId++;
|
|
34
|
+
}
|
|
35
|
+
push(view, op) {
|
|
36
|
+
this.queues[view].push(op);
|
|
37
|
+
}
|
|
38
|
+
flush() {
|
|
39
|
+
for (let view = 0; view < this.queues.length; view++) {
|
|
40
|
+
const ops = this.queues[view];
|
|
41
|
+
if (ops.length === 0)
|
|
42
|
+
continue;
|
|
43
|
+
this.queues[view] = [];
|
|
44
|
+
const seq = ++this.seq;
|
|
45
|
+
const payload = JSON.stringify({ view, seq, ops });
|
|
46
|
+
const start = performance.timeOrigin + performance.now();
|
|
47
|
+
this.engine.applyOps(payload);
|
|
48
|
+
if (this.onFlush) {
|
|
49
|
+
const dur = performance.timeOrigin + performance.now() - start;
|
|
50
|
+
this.onFlush({ seq, view, ops: ops.length, start, dur });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Bridge = Bridge;
|
|
56
|
+
let defaultBridge = null;
|
|
57
|
+
function getBridge(wrapper) {
|
|
58
|
+
if (!defaultBridge)
|
|
59
|
+
defaultBridge = new Bridge(undefined, wrapper);
|
|
60
|
+
return defaultBridge;
|
|
61
|
+
}
|
|
62
|
+
let devtoolsBridgeRef = null;
|
|
63
|
+
function devtoolsBridge() {
|
|
64
|
+
return devtoolsBridgeRef ?? getBridge();
|
|
65
|
+
}
|
|
66
|
+
function setDevtoolsBridge(bridge) {
|
|
67
|
+
devtoolsBridgeRef = bridge;
|
|
68
|
+
}
|
|
69
|
+
function textOf(children) {
|
|
70
|
+
if (children == null || typeof children === "boolean")
|
|
71
|
+
return "";
|
|
72
|
+
if (typeof children === "string" || typeof children === "number") {
|
|
73
|
+
return String(children);
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(children))
|
|
76
|
+
return children.map(textOf).join("");
|
|
77
|
+
throw new Error("<Text> children must be strings or numbers");
|
|
78
|
+
}
|
|
79
|
+
function serializeProps(type, props, hidden, prevProps) {
|
|
80
|
+
const base = {
|
|
81
|
+
style: (0, styles_1.serializeStyle)(props.style ?? {}),
|
|
82
|
+
key: props.id,
|
|
83
|
+
clickable: !!props.onClick,
|
|
84
|
+
hidden: hidden || !!props.hidden,
|
|
85
|
+
contentHeight: props.contentHeight,
|
|
86
|
+
scrollEvents: !!props.onScroll,
|
|
87
|
+
wheelEvents: !!props.onWheel,
|
|
88
|
+
pointerEvents: !!props.onPointer,
|
|
89
|
+
hoverEvents: !!(props.onMouseEnter || props.onMouseLeave),
|
|
90
|
+
outsideClickEvents: !!props.onClickOutside,
|
|
91
|
+
dragEvents: !!props.onDrag,
|
|
92
|
+
selectionEvents: !!props.onSelection,
|
|
93
|
+
moveEvents: !!props.onMouseMove,
|
|
94
|
+
slot: props.slot,
|
|
95
|
+
mark: props.mark,
|
|
96
|
+
surface: props.surface ? (0, surface_1.surfaceId)(props.surface) : undefined,
|
|
97
|
+
};
|
|
98
|
+
if ((type === "text" || type === "input") && props.spans?.length) {
|
|
99
|
+
base.spans = props.spans.map((s) => ({
|
|
100
|
+
start: s.start,
|
|
101
|
+
end: s.end,
|
|
102
|
+
color: (0, styles_1.parseColor)(s.color),
|
|
103
|
+
background: s.background && (0, styles_1.parseColor)(s.background),
|
|
104
|
+
bold: s.bold,
|
|
105
|
+
italic: s.italic,
|
|
106
|
+
underline: s.underline,
|
|
107
|
+
strikethrough: s.strikethrough,
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
if (type === "shape-path" && props.stroke) {
|
|
111
|
+
base.shape = {
|
|
112
|
+
d: props.d ?? "",
|
|
113
|
+
viewBox: props.viewBox,
|
|
114
|
+
stroke: {
|
|
115
|
+
width: props.stroke.width,
|
|
116
|
+
color: (0, styles_1.parseColor)(props.stroke.color),
|
|
117
|
+
cap: props.stroke.cap,
|
|
118
|
+
join: props.stroke.join,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (type === "text") {
|
|
123
|
+
base.text = textOf(props.children);
|
|
124
|
+
}
|
|
125
|
+
else if (type === "marked-text") {
|
|
126
|
+
base.text = props.text ?? "";
|
|
127
|
+
base.marks = props.marks;
|
|
128
|
+
}
|
|
129
|
+
else if (type === "image") {
|
|
130
|
+
base.image = {
|
|
131
|
+
src: props.src ?? "",
|
|
132
|
+
confirmedEqualTo: props.advanced?.confirmedEqualTo,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
else if (type === "input") {
|
|
136
|
+
const valueChanged = !prevProps || props.value !== prevProps.value;
|
|
137
|
+
base.input = {
|
|
138
|
+
initial: props.defaultValue ?? props.value ?? "",
|
|
139
|
+
value: valueChanged ? props.value : undefined,
|
|
140
|
+
marks: props.defaultMarks,
|
|
141
|
+
caretColor: (0, styles_1.parseColor)(props.caretColor),
|
|
142
|
+
selectionColor: (0, styles_1.parseColor)(props.selectionColor),
|
|
143
|
+
autoFocus: !!props.autoFocus,
|
|
144
|
+
submit: !!props.onSubmit,
|
|
145
|
+
gutter: props.gutter && {
|
|
146
|
+
color: (0, styles_1.parseColor)(props.gutter.color),
|
|
147
|
+
activeColor: (0, styles_1.parseColor)(props.gutter.activeColor),
|
|
148
|
+
},
|
|
149
|
+
activeLine: (0, styles_1.parseColor)(props.activeLine),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return base;
|
|
153
|
+
}
|
|
154
|
+
function mutated(b, view) {
|
|
155
|
+
b.onTreeMutation?.(view);
|
|
156
|
+
}
|
|
157
|
+
function pushPropsIfChanged(instance, serialized) {
|
|
158
|
+
const json = JSON.stringify(serialized);
|
|
159
|
+
if (json === instance.lastSent)
|
|
160
|
+
return false;
|
|
161
|
+
instance.lastSent = json;
|
|
162
|
+
instance.bridge.push(instance.view, {
|
|
163
|
+
op: "update",
|
|
164
|
+
id: instance.id,
|
|
165
|
+
props: serialized,
|
|
166
|
+
});
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
function materialize(b, instance) {
|
|
170
|
+
if (instance.mounted)
|
|
171
|
+
return;
|
|
172
|
+
instance.mounted = true;
|
|
173
|
+
const serialized = serializeProps(instance.type, instance.props, instance.hidden);
|
|
174
|
+
instance.lastSent = JSON.stringify(serialized);
|
|
175
|
+
b.push(instance.view, {
|
|
176
|
+
op: "create",
|
|
177
|
+
id: instance.id,
|
|
178
|
+
props: serialized,
|
|
179
|
+
});
|
|
180
|
+
for (const child of instance.children) {
|
|
181
|
+
materialize(b, child);
|
|
182
|
+
b.push(instance.view, {
|
|
183
|
+
op: "insertBefore",
|
|
184
|
+
parent: instance.id,
|
|
185
|
+
child: child.id,
|
|
186
|
+
before: null,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function detachFromParent(child) {
|
|
191
|
+
const parent = child.parent;
|
|
192
|
+
if (!parent)
|
|
193
|
+
return;
|
|
194
|
+
const index = parent.children.indexOf(child);
|
|
195
|
+
if (index !== -1)
|
|
196
|
+
parent.children.splice(index, 1);
|
|
197
|
+
child.parent = null;
|
|
198
|
+
}
|
|
199
|
+
function insert(parent, parentId, child, before) {
|
|
200
|
+
const b = child.bridge;
|
|
201
|
+
materialize(b, child);
|
|
202
|
+
detachFromParent(child);
|
|
203
|
+
const siblings = parent.children;
|
|
204
|
+
const at = before ? siblings.indexOf(before) : -1;
|
|
205
|
+
if (at === -1)
|
|
206
|
+
siblings.push(child);
|
|
207
|
+
else
|
|
208
|
+
siblings.splice(at, 0, child);
|
|
209
|
+
child.parent = parent;
|
|
210
|
+
b.push(child.view, {
|
|
211
|
+
op: "insertBefore",
|
|
212
|
+
parent: parentId,
|
|
213
|
+
child: child.id,
|
|
214
|
+
before: before?.id ?? null,
|
|
215
|
+
});
|
|
216
|
+
mutated(b, child.view);
|
|
217
|
+
}
|
|
218
|
+
function remove(child) {
|
|
219
|
+
detachFromParent(child);
|
|
220
|
+
child.bridge.push(child.view, { op: "remove", id: child.id });
|
|
221
|
+
mutated(child.bridge, child.view);
|
|
222
|
+
}
|
|
223
|
+
const CONTAINER_NODE_ID = 0;
|
|
224
|
+
const hostConfig = {
|
|
225
|
+
supportsMutation: true,
|
|
226
|
+
supportsPersistence: false,
|
|
227
|
+
supportsHydration: false,
|
|
228
|
+
isPrimaryRenderer: true,
|
|
229
|
+
noTimeout: -1,
|
|
230
|
+
createInstance(type, props, rootContainer) {
|
|
231
|
+
const b = rootContainer.bridge;
|
|
232
|
+
const instance = {
|
|
233
|
+
id: b.allocId(),
|
|
234
|
+
bridge: b,
|
|
235
|
+
view: rootContainer.view,
|
|
236
|
+
type,
|
|
237
|
+
props,
|
|
238
|
+
parent: null,
|
|
239
|
+
children: [],
|
|
240
|
+
mounted: false,
|
|
241
|
+
hidden: false,
|
|
242
|
+
lastSent: null,
|
|
243
|
+
};
|
|
244
|
+
b.propsById[instance.view].set(instance.id, props);
|
|
245
|
+
return instance;
|
|
246
|
+
},
|
|
247
|
+
createTextInstance() {
|
|
248
|
+
throw new Error("Raw text must be wrapped in <Text>");
|
|
249
|
+
},
|
|
250
|
+
shouldSetTextContent(type) {
|
|
251
|
+
return type === "text";
|
|
252
|
+
},
|
|
253
|
+
appendInitialChild(parent, child) {
|
|
254
|
+
parent.children.push(child);
|
|
255
|
+
child.parent = parent;
|
|
256
|
+
},
|
|
257
|
+
finalizeInitialChildren() {
|
|
258
|
+
return false;
|
|
259
|
+
},
|
|
260
|
+
prepareUpdate(_instance, _type, _oldProps, newProps) {
|
|
261
|
+
return newProps;
|
|
262
|
+
},
|
|
263
|
+
commitUpdate(instance, newProps, _type, oldProps) {
|
|
264
|
+
const b = instance.bridge;
|
|
265
|
+
const prevProps = instance.props;
|
|
266
|
+
instance.props = newProps;
|
|
267
|
+
b.propsById[instance.view].set(instance.id, newProps);
|
|
268
|
+
const serialized = serializeProps(instance.type, newProps, instance.hidden, oldProps ?? prevProps);
|
|
269
|
+
if (pushPropsIfChanged(instance, serialized)) {
|
|
270
|
+
mutated(instance.bridge, instance.view);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
appendChild(parent, child) {
|
|
274
|
+
insert(parent, parent.id, child, null);
|
|
275
|
+
},
|
|
276
|
+
appendChildToContainer(container, child) {
|
|
277
|
+
insert(container, CONTAINER_NODE_ID, child, null);
|
|
278
|
+
},
|
|
279
|
+
insertBefore(parent, child, before) {
|
|
280
|
+
insert(parent, parent.id, child, before);
|
|
281
|
+
},
|
|
282
|
+
insertInContainerBefore(container, child, before) {
|
|
283
|
+
insert(container, CONTAINER_NODE_ID, child, before);
|
|
284
|
+
},
|
|
285
|
+
removeChild(_parent, child) {
|
|
286
|
+
remove(child);
|
|
287
|
+
},
|
|
288
|
+
removeChildFromContainer(_container, child) {
|
|
289
|
+
remove(child);
|
|
290
|
+
},
|
|
291
|
+
clearContainer(container) {
|
|
292
|
+
container.children = [];
|
|
293
|
+
container.bridge.push(container.view, { op: "clear", id: CONTAINER_NODE_ID });
|
|
294
|
+
mutated(container.bridge, container.view);
|
|
295
|
+
},
|
|
296
|
+
detachDeletedInstance(instance) {
|
|
297
|
+
const b = instance.bridge;
|
|
298
|
+
b.propsById[instance.view].delete(instance.id);
|
|
299
|
+
b.push(instance.view, { op: "forget", id: instance.id });
|
|
300
|
+
},
|
|
301
|
+
hideInstance(instance) {
|
|
302
|
+
instance.hidden = true;
|
|
303
|
+
const serialized = serializeProps(instance.type, instance.props, true, instance.props);
|
|
304
|
+
if (pushPropsIfChanged(instance, serialized)) {
|
|
305
|
+
mutated(instance.bridge, instance.view);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
unhideInstance(instance, props) {
|
|
309
|
+
const prevProps = instance.props;
|
|
310
|
+
instance.hidden = false;
|
|
311
|
+
instance.props = props;
|
|
312
|
+
const serialized = serializeProps(instance.type, props, false, prevProps);
|
|
313
|
+
if (pushPropsIfChanged(instance, serialized)) {
|
|
314
|
+
mutated(instance.bridge, instance.view);
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
hideTextInstance() { },
|
|
318
|
+
unhideTextInstance() { },
|
|
319
|
+
commitTextUpdate() { },
|
|
320
|
+
resetTextContent() { },
|
|
321
|
+
commitMount() { },
|
|
322
|
+
getRootHostContext() {
|
|
323
|
+
return null;
|
|
324
|
+
},
|
|
325
|
+
getChildHostContext(parentContext) {
|
|
326
|
+
return parentContext;
|
|
327
|
+
},
|
|
328
|
+
getPublicInstance(instance) {
|
|
329
|
+
const type = instance.type;
|
|
330
|
+
return {
|
|
331
|
+
id: instance.id,
|
|
332
|
+
focus: () => {
|
|
333
|
+
if (type !== "input")
|
|
334
|
+
return;
|
|
335
|
+
const b = instance.bridge;
|
|
336
|
+
b.push(instance.view, { op: "focus", id: instance.id });
|
|
337
|
+
b.flush();
|
|
338
|
+
},
|
|
339
|
+
blur: () => {
|
|
340
|
+
if (type !== "input")
|
|
341
|
+
return;
|
|
342
|
+
const b = instance.bridge;
|
|
343
|
+
b.push(instance.view, { op: "focus", id: null });
|
|
344
|
+
b.flush();
|
|
345
|
+
},
|
|
346
|
+
scrollTo: (offset, smooth = false) => {
|
|
347
|
+
const b = instance.bridge;
|
|
348
|
+
b.push(instance.view, { op: "scrollTo", id: instance.id, offset, smooth });
|
|
349
|
+
b.flush();
|
|
350
|
+
},
|
|
351
|
+
scrollIntoView: (smooth = false) => {
|
|
352
|
+
const b = instance.bridge;
|
|
353
|
+
b.push(instance.view, { op: "scrollIntoView", id: instance.id, smooth });
|
|
354
|
+
b.flush();
|
|
355
|
+
},
|
|
356
|
+
splice: (start, end, text) => {
|
|
357
|
+
if (type !== "input")
|
|
358
|
+
return;
|
|
359
|
+
const b = instance.bridge;
|
|
360
|
+
b.push(instance.view, { op: "inputSplice", id: instance.id, start, end, text });
|
|
361
|
+
b.flush();
|
|
362
|
+
},
|
|
363
|
+
selectAll: () => {
|
|
364
|
+
if (type !== "input")
|
|
365
|
+
return;
|
|
366
|
+
const b = instance.bridge;
|
|
367
|
+
b.push(instance.view, { op: "inputSelectAll", id: instance.id });
|
|
368
|
+
b.flush();
|
|
369
|
+
},
|
|
370
|
+
addMark: (mark, offset) => {
|
|
371
|
+
if (type !== "input")
|
|
372
|
+
return;
|
|
373
|
+
const b = instance.bridge;
|
|
374
|
+
b.push(instance.view, { op: "insertMark", id: instance.id, mark, offset });
|
|
375
|
+
b.flush();
|
|
376
|
+
},
|
|
377
|
+
removeMark: (mark) => {
|
|
378
|
+
if (type !== "input")
|
|
379
|
+
return;
|
|
380
|
+
const b = instance.bridge;
|
|
381
|
+
b.push(instance.view, { op: "removeMark", id: instance.id, mark });
|
|
382
|
+
b.flush();
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
},
|
|
386
|
+
prepareForCommit() {
|
|
387
|
+
return null;
|
|
388
|
+
},
|
|
389
|
+
resetAfterCommit(container) {
|
|
390
|
+
container.bridge.flush();
|
|
391
|
+
container.bridge.afterCommit?.(container.view);
|
|
392
|
+
},
|
|
393
|
+
preparePortalMount() { },
|
|
394
|
+
scheduleTimeout: setTimeout,
|
|
395
|
+
cancelTimeout: clearTimeout,
|
|
396
|
+
supportsMicrotasks: true,
|
|
397
|
+
scheduleMicrotask: queueMicrotask,
|
|
398
|
+
getCurrentEventPriority() {
|
|
399
|
+
return constants_1.DefaultEventPriority;
|
|
400
|
+
},
|
|
401
|
+
getInstanceFromNode() {
|
|
402
|
+
return null;
|
|
403
|
+
},
|
|
404
|
+
getInstanceFromScope() {
|
|
405
|
+
return null;
|
|
406
|
+
},
|
|
407
|
+
prepareScopeUpdate() { },
|
|
408
|
+
beforeActiveInstanceBlur() { },
|
|
409
|
+
afterActiveInstanceBlur() { },
|
|
410
|
+
};
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
412
|
+
exports.reconciler = (0, react_reconciler_1.default)(hostConfig);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Rgba } from "./native";
|
|
2
|
+
export type Color = Rgba | [number, number, number] | string;
|
|
3
|
+
export interface Edges {
|
|
4
|
+
left?: number;
|
|
5
|
+
right?: number;
|
|
6
|
+
top?: number;
|
|
7
|
+
bottom?: number;
|
|
8
|
+
}
|
|
9
|
+
export type InsetValue = number | `${number}%`;
|
|
10
|
+
export interface InsetEdges {
|
|
11
|
+
left?: InsetValue;
|
|
12
|
+
right?: InsetValue;
|
|
13
|
+
top?: InsetValue;
|
|
14
|
+
bottom?: InsetValue;
|
|
15
|
+
}
|
|
16
|
+
export interface ScrollbarStyle {
|
|
17
|
+
width?: number;
|
|
18
|
+
hoverWidth?: number;
|
|
19
|
+
margin?: number;
|
|
20
|
+
minThumb?: number;
|
|
21
|
+
thumbColor?: Color;
|
|
22
|
+
thumbHoverColor?: Color;
|
|
23
|
+
trackColor?: Color;
|
|
24
|
+
}
|
|
25
|
+
export type BorderSide = [width: number, color: Color];
|
|
26
|
+
export interface GradientStop {
|
|
27
|
+
at: number;
|
|
28
|
+
color: Color;
|
|
29
|
+
}
|
|
30
|
+
export interface LinearGradient {
|
|
31
|
+
from: [number, number];
|
|
32
|
+
to: [number, number];
|
|
33
|
+
stops: GradientStop[];
|
|
34
|
+
}
|
|
35
|
+
export type Border = {
|
|
36
|
+
width: number;
|
|
37
|
+
color: Color;
|
|
38
|
+
} | {
|
|
39
|
+
top?: BorderSide;
|
|
40
|
+
right?: BorderSide;
|
|
41
|
+
bottom?: BorderSide;
|
|
42
|
+
left?: BorderSide;
|
|
43
|
+
};
|
|
44
|
+
export interface Style {
|
|
45
|
+
flexDirection?: "row" | "column";
|
|
46
|
+
flexGrow?: number;
|
|
47
|
+
flexShrink?: number;
|
|
48
|
+
flexBasis?: number | `${number}%` | "auto";
|
|
49
|
+
width?: number | `${number}%` | "auto";
|
|
50
|
+
height?: number | `${number}%` | "auto";
|
|
51
|
+
minWidth?: number | `${number}%` | "auto";
|
|
52
|
+
maxWidth?: number | `${number}%` | "auto";
|
|
53
|
+
maxHeight?: number | `${number}%` | "auto";
|
|
54
|
+
padding?: number | Edges;
|
|
55
|
+
margin?: number | Edges;
|
|
56
|
+
gap?: number;
|
|
57
|
+
position?: "flow" | "absolute";
|
|
58
|
+
inset?: InsetEdges;
|
|
59
|
+
overflow?: "visible" | "hidden" | "scroll";
|
|
60
|
+
justifyContent?: "start" | "center" | "end" | "space-between";
|
|
61
|
+
alignItems?: "start" | "center" | "end" | "stretch";
|
|
62
|
+
background?: Color | LinearGradient;
|
|
63
|
+
cornerRadius?: number | {
|
|
64
|
+
topLeft?: number;
|
|
65
|
+
topRight?: number;
|
|
66
|
+
bottomRight?: number;
|
|
67
|
+
bottomLeft?: number;
|
|
68
|
+
};
|
|
69
|
+
border?: Border;
|
|
70
|
+
color?: Color;
|
|
71
|
+
fontSize?: number;
|
|
72
|
+
font?: number;
|
|
73
|
+
hoverBackground?: Color;
|
|
74
|
+
hoverColor?: Color;
|
|
75
|
+
scrollbar?: ScrollbarStyle;
|
|
76
|
+
wrap?: boolean;
|
|
77
|
+
ellipsis?: boolean;
|
|
78
|
+
selectable?: boolean;
|
|
79
|
+
selectionColor?: Color;
|
|
80
|
+
/**
|
|
81
|
+
* bespoke property so that we can get selection that feels more like a terminal
|
|
82
|
+
*
|
|
83
|
+
* makes the highlight extend to the entire available space of the selection container instead of just the text
|
|
84
|
+
*/
|
|
85
|
+
selectionMode?: "text" | "unified";
|
|
86
|
+
}
|
|
87
|
+
export declare function parseColor(color: Color | undefined): Rgba | undefined;
|
|
88
|
+
export declare function serializeStyle(style: Style): Record<string, unknown>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseColor = parseColor;
|
|
4
|
+
exports.serializeStyle = serializeStyle;
|
|
5
|
+
function parseColor(color) {
|
|
6
|
+
if (color == null)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (Array.isArray(color)) {
|
|
9
|
+
const [r, g, b, a] = color;
|
|
10
|
+
return [r, g, b, a ?? 255];
|
|
11
|
+
}
|
|
12
|
+
let hex = color.startsWith("#") ? color.slice(1) : color;
|
|
13
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
14
|
+
hex = [...hex].map((c) => c + c).join("");
|
|
15
|
+
}
|
|
16
|
+
if (!/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(hex)) {
|
|
17
|
+
throw new Error(`unsupported color: ${color}`);
|
|
18
|
+
}
|
|
19
|
+
const int = (i) => parseInt(hex.slice(i, i + 2), 16);
|
|
20
|
+
return [int(0), int(2), int(4), hex.length === 8 ? int(6) : 255];
|
|
21
|
+
}
|
|
22
|
+
function serializePaint(paint) {
|
|
23
|
+
if (Array.isArray(paint) || typeof paint === "string")
|
|
24
|
+
return parseColor(paint);
|
|
25
|
+
return {
|
|
26
|
+
from: paint.from,
|
|
27
|
+
to: paint.to,
|
|
28
|
+
stops: paint.stops.map((stop) => ({ at: stop.at, color: parseColor(stop.color) })),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function serializeBorder(border) {
|
|
32
|
+
if ("width" in border) {
|
|
33
|
+
return { width: border.width, color: parseColor(border.color) };
|
|
34
|
+
}
|
|
35
|
+
const side = (s) => s && [s[0], parseColor(s[1])];
|
|
36
|
+
return {
|
|
37
|
+
top: side(border.top),
|
|
38
|
+
right: side(border.right),
|
|
39
|
+
bottom: side(border.bottom),
|
|
40
|
+
left: side(border.left),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function serializeStyle(style) {
|
|
44
|
+
return {
|
|
45
|
+
flexDirection: style.flexDirection,
|
|
46
|
+
flexGrow: style.flexGrow,
|
|
47
|
+
flexShrink: style.flexShrink,
|
|
48
|
+
flexBasis: style.flexBasis,
|
|
49
|
+
width: style.width,
|
|
50
|
+
height: style.height,
|
|
51
|
+
minWidth: style.minWidth,
|
|
52
|
+
maxWidth: style.maxWidth,
|
|
53
|
+
maxHeight: style.maxHeight,
|
|
54
|
+
padding: style.padding,
|
|
55
|
+
margin: style.margin,
|
|
56
|
+
gap: style.gap,
|
|
57
|
+
position: style.position,
|
|
58
|
+
inset: style.inset,
|
|
59
|
+
overflow: style.overflow,
|
|
60
|
+
justifyContent: style.justifyContent,
|
|
61
|
+
alignItems: style.alignItems,
|
|
62
|
+
background: style.background === undefined ? undefined : serializePaint(style.background),
|
|
63
|
+
cornerRadius: style.cornerRadius,
|
|
64
|
+
border: style.border && serializeBorder(style.border),
|
|
65
|
+
color: parseColor(style.color),
|
|
66
|
+
fontSize: style.fontSize,
|
|
67
|
+
font: style.font,
|
|
68
|
+
hoverBackground: parseColor(style.hoverBackground),
|
|
69
|
+
hoverColor: parseColor(style.hoverColor),
|
|
70
|
+
wrap: style.wrap,
|
|
71
|
+
ellipsis: style.ellipsis,
|
|
72
|
+
selectable: style.selectable,
|
|
73
|
+
selectionColor: parseColor(style.selectionColor),
|
|
74
|
+
selectionMode: style.selectionMode,
|
|
75
|
+
scrollbar: style.scrollbar && {
|
|
76
|
+
width: style.scrollbar.width,
|
|
77
|
+
hoverWidth: style.scrollbar.hoverWidth,
|
|
78
|
+
margin: style.scrollbar.margin,
|
|
79
|
+
minThumb: style.scrollbar.minThumb,
|
|
80
|
+
thumbColor: parseColor(style.scrollbar.thumbColor),
|
|
81
|
+
thumbHoverColor: parseColor(style.scrollbar.thumbHoverColor),
|
|
82
|
+
trackColor: parseColor(style.scrollbar.trackColor),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DamageRect, NativeEngine, SurfaceShm } from "./native";
|
|
2
|
+
type Damaged = {
|
|
3
|
+
damage?: DamageRect;
|
|
4
|
+
};
|
|
5
|
+
export type SurfaceTexture = {
|
|
6
|
+
ioSurface: Buffer;
|
|
7
|
+
} | {
|
|
8
|
+
shm: SurfaceShm;
|
|
9
|
+
};
|
|
10
|
+
export type SurfaceFrame = ({
|
|
11
|
+
bgra: Buffer;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
} & Damaged) | (SurfaceTexture & Damaged & Released);
|
|
15
|
+
interface Released {
|
|
16
|
+
released?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare class Surface {
|
|
19
|
+
private readonly id;
|
|
20
|
+
private readonly engine;
|
|
21
|
+
private closed;
|
|
22
|
+
constructor(engine: NativeEngine, id: number);
|
|
23
|
+
present(frame: SurfaceFrame): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
startCapture(dir: string): SurfaceCapture;
|
|
26
|
+
close(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface CaptureStats {
|
|
29
|
+
frames: number;
|
|
30
|
+
drops: number;
|
|
31
|
+
durationMs: number;
|
|
32
|
+
}
|
|
33
|
+
export interface CaptureFrameMeta {
|
|
34
|
+
tMs: number;
|
|
35
|
+
key: boolean;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
dropsBefore: number;
|
|
39
|
+
}
|
|
40
|
+
export interface CaptureIndex {
|
|
41
|
+
frames: CaptureFrameMeta[];
|
|
42
|
+
drops: number;
|
|
43
|
+
durationMs: number;
|
|
44
|
+
}
|
|
45
|
+
export declare class SurfaceCapture {
|
|
46
|
+
private readonly engine;
|
|
47
|
+
readonly id: number;
|
|
48
|
+
constructor(engine: NativeEngine, id: number);
|
|
49
|
+
stop(): CaptureStats;
|
|
50
|
+
index(): CaptureIndex;
|
|
51
|
+
frame(index: number): Buffer;
|
|
52
|
+
release(): void;
|
|
53
|
+
}
|
|
54
|
+
export declare function surfaceId(surface: Surface): number;
|
|
55
|
+
export {};
|