@mariozechner/pi-coding-agent 0.45.7 → 0.47.0
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/CHANGELOG.md +59 -0
- package/README.md +24 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +11 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +81 -14
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +6 -5
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +17 -0
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +52 -23
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.css +0 -33
- package/dist/core/export-html/template.js +171 -18
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +57 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +41 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +24 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +1 -5
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +4 -12
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +4 -27
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -37
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +19 -14
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +30 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +82 -10
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +16 -13
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts +1 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +7 -0
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +13 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +70 -9
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +4 -3
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +2 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +4 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +4 -1
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -2
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +5 -5
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +15 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +6 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +4 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts +21 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +146 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +7 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +35 -8
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +14 -8
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +7 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +143 -4
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -5
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +63 -126
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +12 -14
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize.d.ts +2 -2
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +102 -122
- package/dist/utils/image-resize.js.map +1 -1
- package/docs/extensions.md +51 -0
- package/docs/rpc.md +15 -15
- package/docs/tui.md +26 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/modal-editor.ts +1 -1
- package/examples/extensions/overlay-test.ts +8 -3
- package/examples/extensions/plan-mode/README.md +1 -1
- package/examples/extensions/plan-mode/index.ts +2 -2
- package/examples/extensions/question.ts +1 -1
- package/examples/extensions/questionnaire.ts +1 -1
- package/examples/extensions/rainbow-editor.ts +1 -8
- package/examples/extensions/subagent/agents.ts +3 -32
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +6 -5
- package/dist/utils/vips.d.ts +0 -11
- package/dist/utils/vips.d.ts.map +0 -1
- package/dist/utils/vips.js +0 -35
- package/dist/utils/vips.js.map +0 -1
|
@@ -119,7 +119,7 @@ export default function questionnaire(pi: ExtensionAPI) {
|
|
|
119
119
|
noMatch: (t) => theme.fg("warning", t),
|
|
120
120
|
},
|
|
121
121
|
};
|
|
122
|
-
const editor = new Editor(editorTheme);
|
|
122
|
+
const editor = new Editor(tui, editorTheme);
|
|
123
123
|
|
|
124
124
|
// Helpers
|
|
125
125
|
function refresh() {
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* Usage: pi --extension ./examples/extensions/rainbow-editor.ts
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { CustomEditor, type ExtensionAPI
|
|
8
|
-
import type { EditorTheme, TUI } from "@mariozechner/pi-tui";
|
|
7
|
+
import { CustomEditor, type ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
8
|
|
|
10
9
|
// Base colors (coral → yellow → green → teal → blue → purple → pink)
|
|
11
10
|
const COLORS: [number, number, number][] = [
|
|
@@ -44,14 +43,8 @@ function colorize(text: string, shinePos: number): string {
|
|
|
44
43
|
|
|
45
44
|
class RainbowEditor extends CustomEditor {
|
|
46
45
|
private animationTimer?: ReturnType<typeof setInterval>;
|
|
47
|
-
private tui: TUI;
|
|
48
46
|
private frame = 0;
|
|
49
47
|
|
|
50
|
-
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
|
|
51
|
-
super(theme, keybindings);
|
|
52
|
-
this.tui = tui;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
48
|
private hasUltrathink(): boolean {
|
|
56
49
|
return /ultrathink/i.test(this.getText());
|
|
57
50
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as os from "node:os";
|
|
7
7
|
import * as path from "node:path";
|
|
8
|
+
import { parseFrontmatter } from "@mariozechner/pi-coding-agent";
|
|
8
9
|
|
|
9
10
|
export type AgentScope = "user" | "project" | "both";
|
|
10
11
|
|
|
@@ -23,36 +24,6 @@ export interface AgentDiscoveryResult {
|
|
|
23
24
|
projectAgentsDir: string | null;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
function parseFrontmatter(content: string): { frontmatter: Record<string, string>; body: string } {
|
|
27
|
-
const frontmatter: Record<string, string> = {};
|
|
28
|
-
const normalized = content.replace(/\r\n/g, "\n");
|
|
29
|
-
|
|
30
|
-
if (!normalized.startsWith("---")) {
|
|
31
|
-
return { frontmatter, body: normalized };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const endIndex = normalized.indexOf("\n---", 3);
|
|
35
|
-
if (endIndex === -1) {
|
|
36
|
-
return { frontmatter, body: normalized };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const frontmatterBlock = normalized.slice(4, endIndex);
|
|
40
|
-
const body = normalized.slice(endIndex + 4).trim();
|
|
41
|
-
|
|
42
|
-
for (const line of frontmatterBlock.split("\n")) {
|
|
43
|
-
const match = line.match(/^([\w-]+):\s*(.*)$/);
|
|
44
|
-
if (match) {
|
|
45
|
-
let value = match[2].trim();
|
|
46
|
-
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
47
|
-
value = value.slice(1, -1);
|
|
48
|
-
}
|
|
49
|
-
frontmatter[match[1]] = value;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return { frontmatter, body };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
27
|
function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
|
|
57
28
|
const agents: AgentConfig[] = [];
|
|
58
29
|
|
|
@@ -79,7 +50,7 @@ function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig
|
|
|
79
50
|
continue;
|
|
80
51
|
}
|
|
81
52
|
|
|
82
|
-
const { frontmatter, body } = parseFrontmatter(content);
|
|
53
|
+
const { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);
|
|
83
54
|
|
|
84
55
|
if (!frontmatter.name || !frontmatter.description) {
|
|
85
56
|
continue;
|
|
@@ -87,7 +58,7 @@ function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig
|
|
|
87
58
|
|
|
88
59
|
const tools = frontmatter.tools
|
|
89
60
|
?.split(",")
|
|
90
|
-
.map((t) => t.trim())
|
|
61
|
+
.map((t: string) => t.trim())
|
|
91
62
|
.filter(Boolean);
|
|
92
63
|
|
|
93
64
|
agents.push({
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.11.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mariozechner/pi-coding-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -40,9 +40,10 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@mariozechner/clipboard": "^0.3.0",
|
|
42
42
|
"@mariozechner/jiti": "^2.6.2",
|
|
43
|
-
"@mariozechner/pi-agent-core": "^0.
|
|
44
|
-
"@mariozechner/pi-ai": "^0.
|
|
45
|
-
"@mariozechner/pi-tui": "^0.
|
|
43
|
+
"@mariozechner/pi-agent-core": "^0.47.0",
|
|
44
|
+
"@mariozechner/pi-ai": "^0.47.0",
|
|
45
|
+
"@mariozechner/pi-tui": "^0.47.0",
|
|
46
|
+
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
46
47
|
"chalk": "^5.5.0",
|
|
47
48
|
"cli-highlight": "^2.1.11",
|
|
48
49
|
"diff": "^8.0.2",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"marked": "^15.0.12",
|
|
52
53
|
"minimatch": "^10.1.1",
|
|
53
54
|
"proper-lockfile": "^4.1.2",
|
|
54
|
-
"
|
|
55
|
+
"yaml": "^2.8.2"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@types/diff": "^7.0.2",
|
package/dist/utils/vips.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Singleton wrapper for wasm-vips initialization.
|
|
3
|
-
* wasm-vips requires async initialization, so we cache the instance.
|
|
4
|
-
*/
|
|
5
|
-
import type Vips from "wasm-vips";
|
|
6
|
-
/**
|
|
7
|
-
* Get the initialized wasm-vips instance.
|
|
8
|
-
* Returns null if wasm-vips is not available or fails to initialize.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getVips(): Promise<Awaited<ReturnType<typeof Vips>> | null>;
|
|
11
|
-
//# sourceMappingURL=vips.d.ts.map
|
package/dist/utils/vips.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vips.d.ts","sourceRoot":"","sources":["../../src/utils/vips.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAKlC;;;GAGG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAyBhF","sourcesContent":["/**\n * Singleton wrapper for wasm-vips initialization.\n * wasm-vips requires async initialization, so we cache the instance.\n */\n\nimport type Vips from \"wasm-vips\";\n\nlet vipsInstance: Awaited<ReturnType<typeof Vips>> | null = null;\nlet vipsInitPromise: Promise<Awaited<ReturnType<typeof Vips>> | null> | null = null;\n\n/**\n * Get the initialized wasm-vips instance.\n * Returns null if wasm-vips is not available or fails to initialize.\n */\nexport async function getVips(): Promise<Awaited<ReturnType<typeof Vips>> | null> {\n\tif (vipsInstance) {\n\t\treturn vipsInstance;\n\t}\n\n\tif (vipsInitPromise) {\n\t\treturn vipsInitPromise;\n\t}\n\n\tvipsInitPromise = (async () => {\n\t\ttry {\n\t\t\tconst VipsInit = (await import(\"wasm-vips\")).default;\n\t\t\tvipsInstance = await VipsInit();\n\t\t\treturn vipsInstance;\n\t\t} catch {\n\t\t\t// wasm-vips not available\n\t\t\treturn null;\n\t\t}\n\t})();\n\n\tconst result = await vipsInitPromise;\n\tif (!result) {\n\t\tvipsInitPromise = null; // Allow retry on failure\n\t}\n\treturn result;\n}\n"]}
|
package/dist/utils/vips.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Singleton wrapper for wasm-vips initialization.
|
|
3
|
-
* wasm-vips requires async initialization, so we cache the instance.
|
|
4
|
-
*/
|
|
5
|
-
let vipsInstance = null;
|
|
6
|
-
let vipsInitPromise = null;
|
|
7
|
-
/**
|
|
8
|
-
* Get the initialized wasm-vips instance.
|
|
9
|
-
* Returns null if wasm-vips is not available or fails to initialize.
|
|
10
|
-
*/
|
|
11
|
-
export async function getVips() {
|
|
12
|
-
if (vipsInstance) {
|
|
13
|
-
return vipsInstance;
|
|
14
|
-
}
|
|
15
|
-
if (vipsInitPromise) {
|
|
16
|
-
return vipsInitPromise;
|
|
17
|
-
}
|
|
18
|
-
vipsInitPromise = (async () => {
|
|
19
|
-
try {
|
|
20
|
-
const VipsInit = (await import("wasm-vips")).default;
|
|
21
|
-
vipsInstance = await VipsInit();
|
|
22
|
-
return vipsInstance;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// wasm-vips not available
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
})();
|
|
29
|
-
const result = await vipsInitPromise;
|
|
30
|
-
if (!result) {
|
|
31
|
-
vipsInitPromise = null; // Allow retry on failure
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=vips.js.map
|
package/dist/utils/vips.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vips.js","sourceRoot":"","sources":["../../src/utils/vips.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,IAAI,YAAY,GAA4C,IAAI,CAAC;AACjE,IAAI,eAAe,GAA4D,IAAI,CAAC;AAEpF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,GAAqD;IACjF,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACrB,OAAO,eAAe,CAAC;IACxB,CAAC;IAED,eAAe,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC;YACrD,YAAY,GAAG,MAAM,QAAQ,EAAE,CAAC;YAChC,OAAO,YAAY,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACR,0BAA0B;YAC1B,OAAO,IAAI,CAAC;QACb,CAAC;IAAA,CACD,CAAC,EAAE,CAAC;IAEL,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;IACrC,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,eAAe,GAAG,IAAI,CAAC,CAAC,yBAAyB;IAClD,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * Singleton wrapper for wasm-vips initialization.\n * wasm-vips requires async initialization, so we cache the instance.\n */\n\nimport type Vips from \"wasm-vips\";\n\nlet vipsInstance: Awaited<ReturnType<typeof Vips>> | null = null;\nlet vipsInitPromise: Promise<Awaited<ReturnType<typeof Vips>> | null> | null = null;\n\n/**\n * Get the initialized wasm-vips instance.\n * Returns null if wasm-vips is not available or fails to initialize.\n */\nexport async function getVips(): Promise<Awaited<ReturnType<typeof Vips>> | null> {\n\tif (vipsInstance) {\n\t\treturn vipsInstance;\n\t}\n\n\tif (vipsInitPromise) {\n\t\treturn vipsInitPromise;\n\t}\n\n\tvipsInitPromise = (async () => {\n\t\ttry {\n\t\t\tconst VipsInit = (await import(\"wasm-vips\")).default;\n\t\t\tvipsInstance = await VipsInit();\n\t\t\treturn vipsInstance;\n\t\t} catch {\n\t\t\t// wasm-vips not available\n\t\t\treturn null;\n\t\t}\n\t})();\n\n\tconst result = await vipsInitPromise;\n\tif (!result) {\n\t\tvipsInitPromise = null; // Allow retry on failure\n\t}\n\treturn result;\n}\n"]}
|