codex-plus-patcher 0.6.0 → 0.7.1
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/README.md +3 -1
- package/package.json +5 -3
- package/src/cli.js +88 -0
- package/src/core/dev-mode.js +274 -0
- package/src/core/plugin-audit.js +1267 -0
- package/src/patches/26.623.41415-4505.js +44 -0
- package/src/patches/index.js +8 -1
- package/src/patches/lib/common-patches.js +411 -248
- package/src/patches/lib/hooks/about.js +7 -0
- package/src/patches/lib/hooks/diagnostics.js +7 -0
- package/src/patches/lib/hooks/mermaid.js +7 -0
- package/src/patches/lib/hooks/message-composer.js +7 -0
- package/src/patches/lib/hooks/native-main.js +7 -0
- package/src/patches/lib/hooks/project-selector.js +12 -0
- package/src/patches/lib/hooks/review.js +9 -0
- package/src/patches/lib/hooks/settings-commands.js +13 -0
- package/src/patches/lib/hooks/sidebar.js +7 -0
- package/src/patches/lib/hooks/thread-header.js +7 -0
- package/src/patches/lib/hooks/worker.js +7 -0
- package/src/patches/lib/project-selector-shortcut-patch.js +84 -8
- package/src/runtime/api/about.js +16 -0
- package/src/runtime/api/commands.js +85 -0
- package/src/runtime/api/composer.js +14 -0
- package/src/runtime/api/diagnostics.js +38 -0
- package/src/runtime/api/errors.js +20 -0
- package/src/runtime/api/index.js +82 -0
- package/src/runtime/api/mermaid.js +14 -0
- package/src/runtime/api/message.js +14 -0
- package/src/runtime/api/modules.js +57 -0
- package/src/runtime/api/native.js +14 -0
- package/src/runtime/api/patches.js +31 -0
- package/src/runtime/api/review.js +20 -0
- package/src/runtime/api/settings.js +76 -0
- package/src/runtime/api/sidebar.js +24 -0
- package/src/runtime/api/styles.js +28 -0
- package/src/runtime/api/threadHeader.js +41 -0
- package/src/runtime/assets.js +59 -18
- package/src/runtime/host/messageComposer.js +16 -0
- package/src/runtime/host/nativeMain.js +159 -0
- package/src/runtime/host/projectSelector.js +58 -0
- package/src/runtime/host/review.js +62 -0
- package/src/runtime/host/sidebar.js +21 -0
- package/src/runtime/host/threadHeader.js +9 -0
- package/src/runtime/{worker.js → host/worker.js} +7 -0
- package/src/runtime/plugins/mermaidFullscreen.js +19 -6
- package/src/runtime/plugins/nestedRepositories.js +72 -11
- package/src/runtime/plugins/projectColors.js +94 -7
- package/src/runtime/plugins/projectSelectorShortcut.js +67 -12
- package/src/runtime/plugins/sidebarNameBlur.js +1 -1
- package/src/runtime/runtime.js +23 -441
package/src/runtime/runtime.js
CHANGED
|
@@ -1,454 +1,36 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
const globalObject = typeof window !== "undefined" ? window : globalThis;
|
|
3
|
-
|
|
4
|
-
const startedPlugins = new Set();
|
|
5
|
-
const hostModules = new Map();
|
|
6
|
-
const waiters = [];
|
|
7
|
-
const patchDescriptors = [];
|
|
8
|
-
const commands = new Map();
|
|
9
|
-
const styleElements = new Map();
|
|
10
|
-
const settingsListeners = new Map();
|
|
11
|
-
const storagePrefix = "codex-plus:plugin:";
|
|
12
|
-
const diagnosticEvents = [];
|
|
3
|
+
if (typeof document === "undefined") return;
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return globalObject.localStorage?.getItem("codex-plus:diagnostics") === "1";
|
|
17
|
-
} catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function diagnose(event, details = {}) {
|
|
23
|
-
const entry = { event, details, time: new Date().toISOString() };
|
|
24
|
-
diagnosticEvents.push(entry);
|
|
25
|
-
if (diagnosticEvents.length > 200) diagnosticEvents.shift();
|
|
26
|
-
if (diagnosticsEnabled()) {
|
|
27
|
-
try {
|
|
28
|
-
console.info("[Codex Plus]", event, details);
|
|
29
|
-
} catch {}
|
|
30
|
-
}
|
|
31
|
-
return entry;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function safeId(id) {
|
|
35
|
-
if (typeof id !== "string" || id.trim() === "") throw new Error("Codex Plus plugin ids must be non-empty strings");
|
|
36
|
-
return id.trim();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function definePlugin(definition) {
|
|
40
|
-
const id = safeId(definition.id || definition.name);
|
|
41
|
-
return { ...definition, id };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function notifyWaiters(name, value) {
|
|
45
|
-
for (let index = waiters.length - 1; index >= 0; index -= 1) {
|
|
46
|
-
const waiter = waiters[index];
|
|
47
|
-
if (!waiter.filter(value, name)) continue;
|
|
48
|
-
waiters.splice(index, 1);
|
|
49
|
-
waiter.resolve(value);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function registerHostModule(name, value) {
|
|
54
|
-
hostModules.set(name, value);
|
|
55
|
-
notifyWaiters(name, value);
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function moduleValues() {
|
|
60
|
-
return Array.from(hostModules.values());
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function findByProps(...props) {
|
|
64
|
-
return moduleValues().find((value) => value && props.every((prop) => prop in value));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function findByCode(text) {
|
|
68
|
-
return moduleValues().find((value) => {
|
|
69
|
-
try {
|
|
70
|
-
return String(value).includes(text);
|
|
71
|
-
} catch {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function findComponentByCode(text) {
|
|
78
|
-
return moduleValues().find((value) => {
|
|
79
|
-
try {
|
|
80
|
-
return typeof value === "function" && String(value).includes(text);
|
|
81
|
-
} catch {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function waitFor(filter) {
|
|
88
|
-
for (const [name, value] of hostModules) {
|
|
89
|
-
if (filter(value, name)) return Promise.resolve(value);
|
|
90
|
-
}
|
|
91
|
-
return new Promise((resolve) => waiters.push({ filter, resolve }));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function getPluginStore(pluginId) {
|
|
95
|
-
const key = `${storagePrefix}${pluginId}`;
|
|
96
|
-
try {
|
|
97
|
-
return JSON.parse(globalObject.localStorage?.getItem(key) || "{}") || {};
|
|
98
|
-
} catch {
|
|
99
|
-
return {};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function writePluginStore(pluginId, store) {
|
|
104
|
-
const key = `${storagePrefix}${pluginId}`;
|
|
105
|
-
globalObject.localStorage?.setItem(key, JSON.stringify(store));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function emitSetting(pluginId, key, value) {
|
|
109
|
-
const listenerKey = `${pluginId}:${key}`;
|
|
110
|
-
for (const listener of settingsListeners.get(listenerKey) || []) listener(value);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function defineSettings(pluginId, definitions) {
|
|
114
|
-
const id = safeId(pluginId);
|
|
115
|
-
const store = getPluginStore(id);
|
|
116
|
-
for (const [key, definition] of Object.entries(definitions || {})) {
|
|
117
|
-
if (!(key in store) && "default" in definition) store[key] = definition.default;
|
|
118
|
-
}
|
|
119
|
-
writePluginStore(id, store);
|
|
120
|
-
return {
|
|
121
|
-
definitions,
|
|
122
|
-
get(key) {
|
|
123
|
-
return getPluginStore(id)[key];
|
|
124
|
-
},
|
|
125
|
-
set(key, value) {
|
|
126
|
-
const next = getPluginStore(id);
|
|
127
|
-
next[key] = value;
|
|
128
|
-
writePluginStore(id, next);
|
|
129
|
-
emitSetting(id, key, value);
|
|
130
|
-
},
|
|
131
|
-
use(key, listener) {
|
|
132
|
-
const listenerKey = `${id}:${key}`;
|
|
133
|
-
const listeners = settingsListeners.get(listenerKey) || new Set();
|
|
134
|
-
listeners.add(listener);
|
|
135
|
-
settingsListeners.set(listenerKey, listeners);
|
|
136
|
-
listener(getPluginStore(id)[key]);
|
|
137
|
-
return () => listeners.delete(listener);
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function registerPatch(descriptor) {
|
|
143
|
-
patchDescriptors.push(descriptor);
|
|
144
|
-
return descriptor;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function applyPatchDescriptors(source, descriptors = patchDescriptors) {
|
|
148
|
-
let output = source;
|
|
149
|
-
for (const descriptor of descriptors) {
|
|
150
|
-
const moduleMatches =
|
|
151
|
-
typeof descriptor.find === "string" ? output.includes(descriptor.find) : descriptor.find.test(output);
|
|
152
|
-
if (!moduleMatches) continue;
|
|
153
|
-
const replacements = Array.isArray(descriptor.replacement) ? descriptor.replacement : [descriptor.replacement];
|
|
154
|
-
const beforeGroup = output;
|
|
155
|
-
let appliedGroup = true;
|
|
156
|
-
for (const replacement of replacements) {
|
|
157
|
-
const before = output;
|
|
158
|
-
output = output.replace(replacement.match, replacement.replace);
|
|
159
|
-
if (before === output) appliedGroup = false;
|
|
160
|
-
}
|
|
161
|
-
if (descriptor.group && !appliedGroup) output = beforeGroup;
|
|
162
|
-
if (!descriptor.all) break;
|
|
163
|
-
}
|
|
164
|
-
return output;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function registerCommand(command) {
|
|
168
|
-
commands.set(safeId(command.id), command);
|
|
169
|
-
return command;
|
|
170
|
-
}
|
|
5
|
+
const base = new URL(".", document.currentScript?.src || globalObject.location?.href || "");
|
|
6
|
+
const loadWithDocumentWrite = document.readyState === "loading" && typeof document.write === "function";
|
|
171
7
|
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
if (!command) throw new Error(`Unknown Codex Plus command: ${id}`);
|
|
175
|
-
return command.run?.(...args);
|
|
8
|
+
function scriptUrl(file) {
|
|
9
|
+
return new URL(file, base).href;
|
|
176
10
|
}
|
|
177
11
|
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function commandMetadata() {
|
|
187
|
-
return Array.from(commands.values())
|
|
188
|
-
.filter((command) => command.palette?.enabled !== false)
|
|
189
|
-
.map((command) => {
|
|
190
|
-
const groups = commandGroups(command);
|
|
191
|
-
return {
|
|
192
|
-
id: command.id,
|
|
193
|
-
title: command.title,
|
|
194
|
-
description: command.description,
|
|
195
|
-
menuGroups: groups,
|
|
196
|
-
defaultKeybindings: commandKeybindings(command),
|
|
197
|
-
commandMenuGroupKey: groups.includes("panels") ? "panels" : groups[0],
|
|
198
|
-
commandMenu: true,
|
|
199
|
-
electron: {
|
|
200
|
-
menuTitle: command.title,
|
|
201
|
-
defaultKeybindings: commandKeybindings(command),
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function CommandMenuItemHost({ command, deps, group, close }) {
|
|
208
|
-
const jsx = deps?.jsx;
|
|
209
|
-
const MenuItem = deps?.MenuItem;
|
|
210
|
-
if (typeof jsx !== "function" || MenuItem == null) return null;
|
|
211
|
-
const render = (closeMenu) =>
|
|
212
|
-
jsx(
|
|
213
|
-
MenuItem,
|
|
214
|
-
{
|
|
215
|
-
value: command.title,
|
|
216
|
-
title: command.title,
|
|
217
|
-
description: command.description,
|
|
218
|
-
onSelect() {
|
|
219
|
-
runCommand(command.id);
|
|
220
|
-
closeMenu?.();
|
|
221
|
-
close?.();
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
command.id,
|
|
225
|
-
);
|
|
226
|
-
deps?.register?.(command.id, () => runCommand(command.id), {
|
|
227
|
-
menuItem: { id: command.id, groupKey: group, render },
|
|
228
|
-
});
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function renderCommandMenuItems({ group, deps, close } = {}) {
|
|
233
|
-
const jsx = deps?.jsx;
|
|
234
|
-
if (typeof jsx !== "function") return [];
|
|
235
|
-
return Array.from(commands.values())
|
|
236
|
-
.filter((command) => commandGroups(command).includes(group))
|
|
237
|
-
.map((command) => jsx(CommandMenuItemHost, { command, deps, group, close }, command.id));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function mergeDataAttributes(base, extra) {
|
|
241
|
-
if (extra == null) return base;
|
|
242
|
-
if (base == null) return extra;
|
|
243
|
-
return { ...base, ...extra, style: { ...base.style, ...extra.style } };
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function applyDecorators(props, decorators) {
|
|
247
|
-
let result;
|
|
248
|
-
for (const decorator of decorators) result = mergeDataAttributes(result, decorator(props));
|
|
249
|
-
return result;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function AppearanceRowHost({ row, deps, variant }) {
|
|
253
|
-
return row.render?.({ ...deps, variant, row }) ?? null;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function renderAppearanceRows({ deps, variant, section = "appearance" } = {}) {
|
|
257
|
-
const jsx = deps?.jsx;
|
|
258
|
-
if (typeof jsx !== "function") return [];
|
|
259
|
-
return CodexPlus.ui.settings.appearance.rows
|
|
260
|
-
.filter((row) => (row.section || "appearance") === section)
|
|
261
|
-
.slice()
|
|
262
|
-
.sort((left, right) => (left.order || 0) - (right.order || 0))
|
|
263
|
-
.map((row) => jsx(AppearanceRowHost, { row, deps, variant }, row.id));
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function renderReviewBody({ props, deps, defaultBody } = {}) {
|
|
267
|
-
let body = defaultBody;
|
|
268
|
-
for (const wrapper of CodexPlus.ui.review.wrappers) {
|
|
269
|
-
body = wrapper({ ...props, mainReviewContent: body }, deps);
|
|
270
|
-
}
|
|
271
|
-
return body;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function renderErrorDetails({ jsx, error, componentStack } = {}) {
|
|
275
|
-
for (const decorator of CodexPlus.ui.errors.boundaryDecorators) {
|
|
276
|
-
const detail = decorator({ jsx, error, componentStack });
|
|
277
|
-
if (detail != null) return detail;
|
|
12
|
+
function loadScripts(files) {
|
|
13
|
+
const diagnose = globalObject.CodexPlus?.diagnostics?.log;
|
|
14
|
+
if (loadWithDocumentWrite) {
|
|
15
|
+
diagnose?.("runtime.load", { mode: "document.write", count: files.length });
|
|
16
|
+
for (const file of files) document.write(`<script src="${scriptUrl(file).replace(/"/g, """)}"><\/script>`);
|
|
17
|
+
return;
|
|
278
18
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
cwd: typeof context?.cwd === "string" ? context.cwd : null,
|
|
287
|
-
rendered: rendered != null,
|
|
288
|
-
});
|
|
289
|
-
return rendered;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function renderThreadHeaderAccessories({ context, deps } = {}) {
|
|
293
|
-
const jsx = deps?.jsx;
|
|
294
|
-
if (typeof jsx !== "function") {
|
|
295
|
-
diagnose("threadHeader.render.skip", { reason: "missing-jsx" });
|
|
296
|
-
return null;
|
|
19
|
+
diagnose?.("runtime.load", { mode: "appendChild", count: files.length });
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
const script = document.createElement("script");
|
|
22
|
+
script.src = scriptUrl(file);
|
|
23
|
+
script.async = false;
|
|
24
|
+
script.defer = false;
|
|
25
|
+
document.head?.appendChild(script);
|
|
297
26
|
}
|
|
298
|
-
diagnose("threadHeader.render", {
|
|
299
|
-
accessoryCount: CodexPlus.ui.threadHeader.accessories.length,
|
|
300
|
-
cwd: typeof context?.cwd === "string" ? context.cwd : null,
|
|
301
|
-
hostId: context?.hostId ?? null,
|
|
302
|
-
header: context?.header ?? null,
|
|
303
|
-
});
|
|
304
|
-
const rendered = CodexPlus.ui.threadHeader.accessories.map((accessory, index) =>
|
|
305
|
-
jsx(ThreadHeaderAccessoryHost, { accessory, context, deps }, `thread-header-accessory:${index}`),
|
|
306
|
-
);
|
|
307
|
-
return rendered.length === 0 ? null : rendered;
|
|
308
27
|
}
|
|
309
28
|
|
|
310
|
-
|
|
311
|
-
if (typeof document === "undefined") return null;
|
|
312
|
-
const id = `codex-plus-style-${safeId(pluginId)}`;
|
|
313
|
-
let element = styleElements.get(id) || document.getElementById(id);
|
|
314
|
-
if (!element) {
|
|
315
|
-
element = document.createElement("style");
|
|
316
|
-
element.id = id;
|
|
317
|
-
document.head?.appendChild(element);
|
|
318
|
-
}
|
|
319
|
-
element.textContent = cssText;
|
|
320
|
-
styleElements.set(id, element);
|
|
321
|
-
return element;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
function setRootVars(vars) {
|
|
325
|
-
if (typeof document === "undefined") return;
|
|
326
|
-
for (const [key, value] of Object.entries(vars || {})) {
|
|
327
|
-
if (value == null) document.documentElement.style.removeProperty(key);
|
|
328
|
-
else document.documentElement.style.setProperty(key, value);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function registerPlugin(definition) {
|
|
333
|
-
const plugin = definePlugin(definition);
|
|
334
|
-
plugins.set(plugin.id, plugin);
|
|
335
|
-
if (plugin.settings) plugin.settingsStore = defineSettings(plugin.id, plugin.settings);
|
|
336
|
-
for (const descriptor of plugin.patches || []) registerPatch({ ...descriptor, plugin: plugin.id });
|
|
337
|
-
for (const command of plugin.commands || []) registerCommand({ ...command, plugin: plugin.id });
|
|
338
|
-
if (plugin.styles) registerStyle(plugin.id, plugin.styles);
|
|
339
|
-
if (plugin.required || plugin.enabledByDefault) startPlugin(plugin.id);
|
|
340
|
-
diagnose("plugin.register", { id: plugin.id, started: startedPlugins.has(plugin.id) });
|
|
341
|
-
return plugin;
|
|
342
|
-
}
|
|
29
|
+
globalObject.__CodexPlusLoadRuntimeFiles = loadScripts;
|
|
343
30
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
startedPlugins.add(id);
|
|
349
|
-
diagnose("plugin.start", { id });
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function stopPlugin(id) {
|
|
353
|
-
const plugin = plugins.get(id);
|
|
354
|
-
if (!plugin || !startedPlugins.has(id)) return;
|
|
355
|
-
plugin.stop?.(CodexPlus);
|
|
356
|
-
startedPlugins.delete(id);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function registerNativeMenuItem(item) {
|
|
360
|
-
return CodexPlus.native.request("native-menu/register-item", item).catch(() => ({ ok: false }));
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const CodexPlus = {
|
|
364
|
-
definePlugin,
|
|
365
|
-
registerPlugin,
|
|
366
|
-
startPlugin,
|
|
367
|
-
stopPlugin,
|
|
368
|
-
plugins,
|
|
369
|
-
patches: { register: registerPatch, apply: applyPatchDescriptors, all: patchDescriptors },
|
|
370
|
-
modules: { registerHostModule, findByCode, findByProps, findComponentByCode, waitFor },
|
|
371
|
-
ui: {
|
|
372
|
-
commands: { renderMenuItems: renderCommandMenuItems, commandMetadata },
|
|
373
|
-
settings: { appearance: { rows: [], addRow(row) { this.rows.push(row); return row; }, renderRows: renderAppearanceRows } },
|
|
374
|
-
review: { wrappers: [], wrapBody(wrapper) { this.wrappers.push(wrapper); return wrapper; }, renderBody: renderReviewBody },
|
|
375
|
-
sidebar: {
|
|
376
|
-
projectDecorators: [],
|
|
377
|
-
threadDecorators: [],
|
|
378
|
-
decorateProjectRow(fn) { this.projectDecorators.push(fn); return fn; },
|
|
379
|
-
decorateThreadRow(fn) { this.threadDecorators.push(fn); return fn; },
|
|
380
|
-
mergeDataAttributes,
|
|
381
|
-
projectRowProps(props) { return applyDecorators(props, this.projectDecorators); },
|
|
382
|
-
threadRowProps(props) { return applyDecorators(props, this.threadDecorators); },
|
|
383
|
-
},
|
|
384
|
-
message: { userBubbleDecorators: [], decorateUserBubble(fn) { this.userBubbleDecorators.push(fn); return fn; }, userBubbleProps(props) { return applyDecorators(props, this.userBubbleDecorators); } },
|
|
385
|
-
composer: { surfaceDecorators: [], decorateSurface(fn) { this.surfaceDecorators.push(fn); return fn; }, surfaceProps(props) { return applyDecorators(props, this.surfaceDecorators); } },
|
|
386
|
-
about: { buildInfo: [], addBuildInfo(fn) { this.buildInfo.push(fn); return fn; } },
|
|
387
|
-
errors: { boundaryDecorators: [], decorateBoundary(fn) { this.boundaryDecorators.push(fn); return fn; }, renderDetails: renderErrorDetails },
|
|
388
|
-
threadHeader: {
|
|
389
|
-
accessories: [],
|
|
390
|
-
addAccessory(fn) {
|
|
391
|
-
this.accessories.push(fn);
|
|
392
|
-
diagnose("threadHeader.addAccessory", { accessoryName: fn?.name || null, accessoryCount: this.accessories.length });
|
|
393
|
-
return fn;
|
|
394
|
-
},
|
|
395
|
-
renderAccessories: renderThreadHeaderAccessories,
|
|
396
|
-
},
|
|
397
|
-
mermaid: {
|
|
398
|
-
diagramDecorators: [],
|
|
399
|
-
decorateDiagram(fn) { this.diagramDecorators.push(fn); return fn; },
|
|
400
|
-
diagramProps(props) { return applyDecorators(props, this.diagramDecorators); },
|
|
401
|
-
},
|
|
402
|
-
},
|
|
403
|
-
commands: { register: registerCommand, run: runCommand, all: () => Array.from(commands.values()), menuItems: (group) => Array.from(commands.values()).filter((command) => commandGroups(command).includes(group)) },
|
|
404
|
-
nativeMenus: { registerItem: registerNativeMenuItem },
|
|
405
|
-
settings: { define: defineSettings },
|
|
406
|
-
native: { async request(method, params) { return globalObject.codexPlusNative?.request?.(method, params) ?? globalObject.CodexPlusHost?.nativeRequest?.(method, params); } },
|
|
407
|
-
styles: { register: registerStyle, setRootVars },
|
|
408
|
-
diagnostics: {
|
|
409
|
-
log: diagnose,
|
|
410
|
-
snapshot() { return diagnosticEvents.slice(); },
|
|
411
|
-
clear() { diagnosticEvents.splice(0, diagnosticEvents.length); },
|
|
412
|
-
enabled: diagnosticsEnabled,
|
|
413
|
-
},
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
globalObject.CodexPlus = CodexPlus;
|
|
417
|
-
globalObject.CodexPlusDiagnostics = CodexPlus.diagnostics;
|
|
418
|
-
globalObject.CodexPlusHost ||= {};
|
|
419
|
-
globalObject.CodexPlusHost.register = registerHostModule;
|
|
420
|
-
|
|
421
|
-
const pluginFiles = [
|
|
422
|
-
"plugins/aboutMetadata.js",
|
|
423
|
-
"plugins/nestedRepositories.js",
|
|
424
|
-
"plugins/diagnosticErrors.js",
|
|
425
|
-
"plugins/userBubbleColors.js",
|
|
426
|
-
"plugins/projectColors.js",
|
|
427
|
-
"plugins/projectPathHeader.js",
|
|
428
|
-
"plugins/sidebarNameBlur.js",
|
|
429
|
-
"plugins/devTools.js",
|
|
430
|
-
"vendor/fzf.umd.js",
|
|
431
|
-
"plugins/projectSelectorShortcut.js",
|
|
432
|
-
"plugins/mermaidFullscreen.js",
|
|
433
|
-
];
|
|
434
|
-
|
|
435
|
-
if (typeof document !== "undefined") {
|
|
436
|
-
const base = new URL(".", document.currentScript?.src || globalObject.location?.href || "");
|
|
437
|
-
if (document.readyState === "loading" && typeof document.write === "function") {
|
|
438
|
-
diagnose("plugins.load", { mode: "document.write", count: pluginFiles.length });
|
|
439
|
-
for (const file of pluginFiles) {
|
|
440
|
-
const src = new URL(file, base).href.replace(/"/g, """);
|
|
441
|
-
document.write(`<script src="${src}"><\/script>`);
|
|
442
|
-
}
|
|
443
|
-
} else {
|
|
444
|
-
diagnose("plugins.load", { mode: "appendChild", count: pluginFiles.length });
|
|
445
|
-
for (const file of pluginFiles) {
|
|
446
|
-
const script = document.createElement("script");
|
|
447
|
-
script.src = new URL(file, base).href;
|
|
448
|
-
script.async = false;
|
|
449
|
-
script.defer = false;
|
|
450
|
-
document.head?.appendChild(script);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
31
|
+
if (loadWithDocumentWrite) {
|
|
32
|
+
document.write(`<script src="${scriptUrl("runtime-manifest.js").replace(/"/g, """)}"><\/script>`);
|
|
33
|
+
} else {
|
|
34
|
+
loadScripts(["runtime-manifest.js"]);
|
|
453
35
|
}
|
|
454
36
|
})();
|