silvery 0.17.0 → 0.17.2
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/UPNG-AVSMjiFE.mjs +5076 -0
- package/dist/UPNG-AVSMjiFE.mjs.map +1 -0
- package/dist/__vite-browser-external-2447137e-D3GdsvS_.mjs +6 -0
- package/dist/__vite-browser-external-2447137e-D3GdsvS_.mjs.map +1 -0
- package/dist/animation-C_PTO0uH.mjs +304 -0
- package/dist/animation-C_PTO0uH.mjs.map +1 -0
- package/dist/ansi-CXLE_pt1.mjs +71 -0
- package/dist/ansi-CXLE_pt1.mjs.map +1 -0
- package/dist/ansi-zmNzgkPB.d.mts +49 -0
- package/dist/ansi-zmNzgkPB.d.mts.map +1 -0
- package/dist/apng-DCWY913R.mjs +3 -0
- package/dist/apng-ENBAJk-H.mjs +70 -0
- package/dist/apng-ENBAJk-H.mjs.map +1 -0
- package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
- package/dist/backend-CkIkIHR-.mjs +13396 -0
- package/dist/backend-CkIkIHR-.mjs.map +1 -0
- package/dist/backends-CkvbG3js.mjs +1181 -0
- package/dist/backends-CkvbG3js.mjs.map +1 -0
- package/dist/backends-CyJqNLeK.mjs +3 -0
- package/dist/chunk-BSw8zbkd.mjs +37 -0
- package/dist/cli-B-k7Bm56.mjs +4 -0
- package/dist/context-QreF3UHr.mjs +64 -0
- package/dist/context-QreF3UHr.mjs.map +1 -0
- package/dist/derive-D7bFJdfU.d.mts +28 -0
- package/dist/derive-D7bFJdfU.d.mts.map +1 -0
- package/dist/devtools-CscuKaDK.mjs +89 -0
- package/dist/devtools-CscuKaDK.mjs.map +1 -0
- package/dist/devtools-D4oGc6LY.mjs +2 -0
- package/dist/eta-DLiVPaSD.mjs +110 -0
- package/dist/eta-DLiVPaSD.mjs.map +1 -0
- package/dist/flexily-zero-adapter-DmG4Ge8t.mjs +3376 -0
- package/dist/flexily-zero-adapter-DmG4Ge8t.mjs.map +1 -0
- package/dist/flexily-zero-adapter-GHwEW11s.mjs +2 -0
- package/dist/gif-BaJNREpP.mjs +3 -0
- package/dist/gif-Bp6fIyN3.mjs +73 -0
- package/dist/gif-Bp6fIyN3.mjs.map +1 -0
- package/dist/gifenc-GiVCZ9-3.mjs +730 -0
- package/dist/gifenc-GiVCZ9-3.mjs.map +1 -0
- package/dist/image-Dx7gYjkq.mjs +346 -0
- package/dist/image-Dx7gYjkq.mjs.map +1 -0
- package/dist/index-CBcSpGSM.d.mts +3416 -0
- package/dist/index-CBcSpGSM.d.mts.map +1 -0
- package/dist/index-DCVL3jHo.d.mts +634 -0
- package/dist/index-DCVL3jHo.d.mts.map +1 -0
- package/dist/index-p-wBs_wH.d.mts +175 -0
- package/dist/index-p-wBs_wH.d.mts.map +1 -0
- package/dist/index.d.mts +7296 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +9399 -0
- package/dist/index.mjs.map +1 -0
- package/dist/key-mapping-BsUHe_nk.mjs +3 -0
- package/dist/key-mapping-DsyfLEdC.mjs +132 -0
- package/dist/key-mapping-DsyfLEdC.mjs.map +1 -0
- package/dist/layout-engine-B3dsnVLU.mjs +50 -0
- package/dist/layout-engine-B3dsnVLU.mjs.map +1 -0
- package/dist/layout-engine-D_lSR4i9.mjs +2 -0
- package/dist/multi-progress-C0-rkn86.d.mts +180 -0
- package/dist/multi-progress-C0-rkn86.d.mts.map +1 -0
- package/dist/multi-progress-CQVB9lES.mjs +219 -0
- package/dist/multi-progress-CQVB9lES.mjs.map +1 -0
- package/dist/node-Dedx-6xF.mjs +1085 -0
- package/dist/node-Dedx-6xF.mjs.map +1 -0
- package/dist/pipeline-DDOPrjuY.mjs +4387 -0
- package/dist/pipeline-DDOPrjuY.mjs.map +1 -0
- package/dist/progress-bar-COPSBlT9.mjs +155 -0
- package/dist/progress-bar-COPSBlT9.mjs.map +1 -0
- package/dist/reconciler-2lp5VXK7.mjs +16506 -0
- package/dist/reconciler-2lp5VXK7.mjs.map +1 -0
- package/dist/render-string-BXvxTg5P.mjs +201 -0
- package/dist/render-string-BXvxTg5P.mjs.map +1 -0
- package/dist/render-string-hvfpVtoP.mjs +2 -0
- package/dist/resvg-js-V6oMi8CY.mjs +203 -0
- package/dist/resvg-js-V6oMi8CY.mjs.map +1 -0
- package/dist/runtime-BjDHNTxJ.mjs +8723 -0
- package/dist/runtime-BjDHNTxJ.mjs.map +1 -0
- package/dist/runtime.d.mts +2 -0
- package/dist/runtime.mjs +3 -0
- package/dist/spinner-Cgej6Vnb.d.mts +127 -0
- package/dist/spinner-Cgej6Vnb.d.mts.map +1 -0
- package/dist/spinner-DSByknyx.mjs +298 -0
- package/dist/spinner-DSByknyx.mjs.map +1 -0
- package/dist/src-9B5k0JmY.mjs +1629 -0
- package/dist/src-9B5k0JmY.mjs.map +1 -0
- package/dist/src-C9f3hiVG.mjs +3620 -0
- package/dist/src-C9f3hiVG.mjs.map +1 -0
- package/dist/src-fJVbhdn-.mjs +816 -0
- package/dist/src-fJVbhdn-.mjs.map +1 -0
- package/dist/theme.d.mts +115 -0
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.mjs +8 -0
- package/dist/theme.mjs.map +1 -0
- package/dist/types-Bhj5QkIQ.mjs +13 -0
- package/dist/types-Bhj5QkIQ.mjs.map +1 -0
- package/dist/types-CDgkE-Rw.d.mts +241 -0
- package/dist/types-CDgkE-Rw.d.mts.map +1 -0
- package/dist/ui/animation.d.mts +2 -0
- package/dist/ui/animation.mjs +2 -0
- package/dist/ui/ansi.d.mts +2 -0
- package/dist/ui/ansi.mjs +2 -0
- package/dist/ui/cli.d.mts +5 -0
- package/dist/ui/cli.mjs +7 -0
- package/dist/ui/display.d.mts +35 -0
- package/dist/ui/display.d.mts.map +1 -0
- package/dist/ui/display.mjs +123 -0
- package/dist/ui/display.mjs.map +1 -0
- package/dist/ui/image.d.mts +2 -0
- package/dist/ui/image.mjs +2 -0
- package/dist/ui/input.d.mts +184 -0
- package/dist/ui/input.d.mts.map +1 -0
- package/dist/ui/input.mjs +285 -0
- package/dist/ui/input.mjs.map +1 -0
- package/dist/ui/progress.d.mts +249 -0
- package/dist/ui/progress.d.mts.map +1 -0
- package/dist/ui/progress.mjs +858 -0
- package/dist/ui/progress.mjs.map +1 -0
- package/dist/ui/react.d.mts +280 -0
- package/dist/ui/react.d.mts.map +1 -0
- package/dist/ui/react.mjs +413 -0
- package/dist/ui/react.mjs.map +1 -0
- package/dist/ui/utils.d.mts +86 -0
- package/dist/ui/utils.d.mts.map +1 -0
- package/dist/ui/utils.mjs +2 -0
- package/dist/ui/wrappers.d.mts +3 -0
- package/dist/ui/wrappers.mjs +2 -0
- package/dist/ui.d.mts +6 -0
- package/dist/ui.mjs +7 -0
- package/dist/useLatest-BMIYXd6e.d.mts +154 -0
- package/dist/useLatest-BMIYXd6e.d.mts.map +1 -0
- package/dist/useLayout-BG2cGl15.mjs +139 -0
- package/dist/useLayout-BG2cGl15.mjs.map +1 -0
- package/dist/with-text-input-CmHf_9d6.d.mts +284 -0
- package/dist/with-text-input-CmHf_9d6.d.mts.map +1 -0
- package/dist/wrapper-Dqh0zi2W.mjs +3527 -0
- package/dist/wrapper-Dqh0zi2W.mjs.map +1 -0
- package/dist/wrappers-hhL8EQ_n.mjs +810 -0
- package/dist/wrappers-hhL8EQ_n.mjs.map +1 -0
- package/dist/yoga-adapter-BJ9SOhTY.mjs +245 -0
- package/dist/yoga-adapter-BJ9SOhTY.mjs.map +1 -0
- package/dist/yoga-adapter-Daq6-dw1.mjs +2 -0
- package/package.json +48 -75
- package/CHANGELOG.md +0 -319
- package/dist/chalk.js +0 -4
- package/dist/index.js +0 -270
- package/dist/ink.js +0 -142
- package/dist/runtime.js +0 -135
- package/dist/theme.js +0 -7
- package/dist/ui/animation.js +0 -3
- package/dist/ui/ansi.js +0 -3
- package/dist/ui/cli.js +0 -9
- package/dist/ui/display.js +0 -4
- package/dist/ui/image.js +0 -4
- package/dist/ui/input.js +0 -3
- package/dist/ui/progress.js +0 -9
- package/dist/ui/react.js +0 -4
- package/dist/ui/utils.js +0 -3
- package/dist/ui/wrappers.js +0 -15
- package/dist/ui.js +0 -18
- package/src/index.ts +0 -73
- package/src/runtime.ts +0 -4
- package/src/theme.ts +0 -4
- package/src/ui/animation.ts +0 -2
- package/src/ui/ansi.ts +0 -2
- package/src/ui/cli.ts +0 -3
- package/src/ui/display.ts +0 -2
- package/src/ui/image.ts +0 -2
- package/src/ui/input.ts +0 -2
- package/src/ui/progress.ts +0 -2
- package/src/ui/react.ts +0 -2
- package/src/ui/utils.ts +0 -2
- package/src/ui/wrappers.ts +0 -2
- package/src/ui.ts +0 -4
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { c as TermContext, o as StderrContext, s as StdoutContext } from "./context-QreF3UHr.mjs";
|
|
2
|
+
import { At as bufferToStyledText, Lt as init_buffer, S as createTerm, a as hostConfig, jt as bufferToText, r as getContainerRoot, t as createContainer } from "./reconciler-2lp5VXK7.mjs";
|
|
3
|
+
import { i as isLayoutEngineInitialized } from "./layout-engine-B3dsnVLU.mjs";
|
|
4
|
+
import { t as executeRender } from "./pipeline-DDOPrjuY.mjs";
|
|
5
|
+
import React, { act } from "react";
|
|
6
|
+
import Reconciler from "react-reconciler";
|
|
7
|
+
//#region packages/ag-react/src/reconciler/string-reconciler.ts
|
|
8
|
+
/**
|
|
9
|
+
* Separate React reconciler instance for renderStringSync.
|
|
10
|
+
*
|
|
11
|
+
* renderStringSync may be called from within React effects (e.g., useScrollback
|
|
12
|
+
* freezing items to scrollback). If it uses the same reconciler singleton as the
|
|
13
|
+
* main render tree, this causes re-entrancy: the nested reconciliation interferes
|
|
14
|
+
* with the outer one, producing empty output.
|
|
15
|
+
*
|
|
16
|
+
* By using a dedicated reconciler instance, renderStringSync operates on an
|
|
17
|
+
* independent fiber tree with no shared reconciler state.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Dedicated reconciler for string rendering.
|
|
21
|
+
*
|
|
22
|
+
* Uses the same host config functions but overrides isPrimaryRenderer to false,
|
|
23
|
+
* since this is a secondary renderer used only for one-shot string rendering.
|
|
24
|
+
* This avoids conflicts with the main reconciler's hook ownership.
|
|
25
|
+
*/
|
|
26
|
+
const stringReconciler = Reconciler({
|
|
27
|
+
...hostConfig,
|
|
28
|
+
isPrimaryRenderer: false
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region packages/ag-react/src/render-string.tsx
|
|
32
|
+
/**
|
|
33
|
+
* renderString - Static one-shot rendering to string
|
|
34
|
+
*
|
|
35
|
+
* Renders a React element to a string without needing a terminal.
|
|
36
|
+
* Use for:
|
|
37
|
+
* - CI output (no cursor control needed)
|
|
38
|
+
* - Piped output
|
|
39
|
+
* - One-shot reports/summaries
|
|
40
|
+
* - Testing component output
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* import { renderString, Box, Text } from '@silvery/ag-react'
|
|
45
|
+
*
|
|
46
|
+
* // Basic usage
|
|
47
|
+
* const output = renderString(<Summary stats={stats} />)
|
|
48
|
+
* console.log(output)
|
|
49
|
+
*
|
|
50
|
+
* // Custom width
|
|
51
|
+
* const wide = renderString(<Report />, { width: 120 })
|
|
52
|
+
*
|
|
53
|
+
* // Plain text (no ANSI)
|
|
54
|
+
* const plain = renderString(<Report />, { plain: true })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
init_buffer();
|
|
58
|
+
let engineInitialized = false;
|
|
59
|
+
async function ensureLayoutEngine() {
|
|
60
|
+
if (engineInitialized || isLayoutEngineInitialized()) return;
|
|
61
|
+
const { ensureDefaultLayoutEngine } = await import("./layout-engine-D_lSR4i9.mjs");
|
|
62
|
+
await ensureDefaultLayoutEngine();
|
|
63
|
+
engineInitialized = true;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Render a React element to a string (async version).
|
|
67
|
+
*
|
|
68
|
+
* Automatically initializes the layout engine if needed.
|
|
69
|
+
* Use this when you're not sure if the layout engine is ready.
|
|
70
|
+
*
|
|
71
|
+
* @param element - React element to render
|
|
72
|
+
* @param options - Render options (width, height, plain)
|
|
73
|
+
* @returns Rendered string (with or without ANSI codes)
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* const output = await renderString(<Summary stats={stats} />)
|
|
78
|
+
* console.log(output)
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
async function renderString(element, options = {}) {
|
|
82
|
+
await ensureLayoutEngine();
|
|
83
|
+
return renderStringSync(element, options);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Render a React element to a string (sync version).
|
|
87
|
+
*
|
|
88
|
+
* Requires the layout engine to be already initialized.
|
|
89
|
+
* Throws if the layout engine is not ready.
|
|
90
|
+
*
|
|
91
|
+
* @param element - React element to render
|
|
92
|
+
* @param options - Render options (width, height, plain)
|
|
93
|
+
* @returns Rendered string (with or without ANSI codes)
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* // After layout engine is initialized
|
|
98
|
+
* const output = renderStringSync(<Summary stats={stats} />)
|
|
99
|
+
* console.log(output)
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function renderStringSync(element, options = {}) {
|
|
103
|
+
if (!isLayoutEngineInitialized()) throw new Error("Layout engine not initialized. Use renderString() (async) or initialize with setLayoutEngine().");
|
|
104
|
+
const { width = 80, height = 24, plain = false, pipelineConfig, trimTrailingWhitespace = true, trimEmptyLines = true, onContentHeight, alwaysStyled = false } = options;
|
|
105
|
+
let hadReactCommit = false;
|
|
106
|
+
const container = createContainer(() => {
|
|
107
|
+
hadReactCommit = true;
|
|
108
|
+
});
|
|
109
|
+
let uncaughtError = null;
|
|
110
|
+
const onUncaughtError = (error) => {
|
|
111
|
+
uncaughtError = error;
|
|
112
|
+
};
|
|
113
|
+
const fiberRoot = stringReconciler.createContainer(container, 1, null, false, null, "", onUncaughtError, () => {}, () => {}, null);
|
|
114
|
+
const mockStdout = {
|
|
115
|
+
columns: width,
|
|
116
|
+
rows: height,
|
|
117
|
+
write: () => true,
|
|
118
|
+
isTTY: false,
|
|
119
|
+
on: () => mockStdout,
|
|
120
|
+
off: () => mockStdout,
|
|
121
|
+
once: () => mockStdout,
|
|
122
|
+
removeListener: () => mockStdout,
|
|
123
|
+
addListener: () => mockStdout
|
|
124
|
+
};
|
|
125
|
+
const mockTerm = createTerm({ color: plain ? null : "truecolor" });
|
|
126
|
+
const wrapped = React.createElement(TermContext.Provider, { value: mockTerm }, React.createElement(StdoutContext.Provider, { value: {
|
|
127
|
+
stdout: mockStdout,
|
|
128
|
+
write: () => {}
|
|
129
|
+
} }, React.createElement(StderrContext.Provider, { value: {
|
|
130
|
+
stderr: process.stderr,
|
|
131
|
+
write: (data) => {
|
|
132
|
+
process.stderr.write(data);
|
|
133
|
+
}
|
|
134
|
+
} }, element)));
|
|
135
|
+
withActEnvironment(() => {
|
|
136
|
+
act(() => {
|
|
137
|
+
stringReconciler.updateContainerSync(wrapped, fiberRoot, null, null);
|
|
138
|
+
stringReconciler.flushSyncWork();
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
if (uncaughtError) throw uncaughtError instanceof Error ? uncaughtError : new Error(String(uncaughtError));
|
|
142
|
+
let buffer;
|
|
143
|
+
let rootNode;
|
|
144
|
+
const MAX_ITERATIONS = 5;
|
|
145
|
+
for (let i = 0; i < MAX_ITERATIONS; i++) {
|
|
146
|
+
hadReactCommit = false;
|
|
147
|
+
withActEnvironment(() => {
|
|
148
|
+
act(() => {
|
|
149
|
+
const root = getContainerRoot(container);
|
|
150
|
+
rootNode = root;
|
|
151
|
+
buffer = executeRender(root, width, height, null, void 0, pipelineConfig).buffer;
|
|
152
|
+
});
|
|
153
|
+
if (!hadReactCommit) act(() => {
|
|
154
|
+
stringReconciler.flushSyncWork();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
if (!hadReactCommit) break;
|
|
158
|
+
}
|
|
159
|
+
if (onContentHeight && rootNode) {
|
|
160
|
+
let maxBottom = 0;
|
|
161
|
+
let hasChildren = false;
|
|
162
|
+
for (const child of rootNode.children) if (child.boxRect) {
|
|
163
|
+
hasChildren = true;
|
|
164
|
+
const props = child.props;
|
|
165
|
+
const mb = props.marginBottom ?? props.marginY ?? props.margin ?? 0;
|
|
166
|
+
const childBottom = child.boxRect.y + child.boxRect.height + mb;
|
|
167
|
+
if (childBottom > maxBottom) maxBottom = childBottom;
|
|
168
|
+
}
|
|
169
|
+
onContentHeight(hasChildren ? maxBottom : 0);
|
|
170
|
+
}
|
|
171
|
+
withActEnvironment(() => {
|
|
172
|
+
act(() => {
|
|
173
|
+
stringReconciler.updateContainerSync(null, fiberRoot, null, null);
|
|
174
|
+
stringReconciler.flushSyncWork();
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
return plain && !alwaysStyled ? bufferToText(buffer, {
|
|
178
|
+
trimTrailingWhitespace,
|
|
179
|
+
trimEmptyLines
|
|
180
|
+
}) : bufferToStyledText(buffer, {
|
|
181
|
+
trimTrailingWhitespace,
|
|
182
|
+
trimEmptyLines
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Run a function with IS_REACT_ACT_ENVIRONMENT temporarily set to true.
|
|
187
|
+
* This ensures act() captures forceUpdate/setState from layout notifications.
|
|
188
|
+
*/
|
|
189
|
+
function withActEnvironment(fn) {
|
|
190
|
+
const prev = globalThis.IS_REACT_ACT_ENVIRONMENT;
|
|
191
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
192
|
+
try {
|
|
193
|
+
fn();
|
|
194
|
+
} finally {
|
|
195
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = prev;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { renderStringSync as n, renderString as t };
|
|
200
|
+
|
|
201
|
+
//# sourceMappingURL=render-string-BXvxTg5P.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-string-BXvxTg5P.mjs","names":[],"sources":["../packages/ag-react/src/reconciler/string-reconciler.ts","../packages/ag-react/src/render-string.tsx"],"sourcesContent":["/**\n * Separate React reconciler instance for renderStringSync.\n *\n * renderStringSync may be called from within React effects (e.g., useScrollback\n * freezing items to scrollback). If it uses the same reconciler singleton as the\n * main render tree, this causes re-entrancy: the nested reconciliation interferes\n * with the outer one, producing empty output.\n *\n * By using a dedicated reconciler instance, renderStringSync operates on an\n * independent fiber tree with no shared reconciler state.\n */\n\n// @ts-expect-error - react-reconciler has no type declarations\nimport Reconciler from \"react-reconciler\"\nimport { hostConfig } from \"./host-config\"\n\n/**\n * Dedicated reconciler for string rendering.\n *\n * Uses the same host config functions but overrides isPrimaryRenderer to false,\n * since this is a secondary renderer used only for one-shot string rendering.\n * This avoids conflicts with the main reconciler's hook ownership.\n */\nexport const stringReconciler = Reconciler({\n ...hostConfig,\n isPrimaryRenderer: false,\n})\n","/**\n * renderString - Static one-shot rendering to string\n *\n * Renders a React element to a string without needing a terminal.\n * Use for:\n * - CI output (no cursor control needed)\n * - Piped output\n * - One-shot reports/summaries\n * - Testing component output\n *\n * @example\n * ```tsx\n * import { renderString, Box, Text } from '@silvery/ag-react'\n *\n * // Basic usage\n * const output = renderString(<Summary stats={stats} />)\n * console.log(output)\n *\n * // Custom width\n * const wide = renderString(<Report />, { width: 120 })\n *\n * // Plain text (no ANSI)\n * const plain = renderString(<Report />, { plain: true })\n * ```\n */\n\nimport React, { type ReactElement, act } from \"react\"\n\nimport { createTerm } from \"@silvery/ag-term/ansi\"\n\nimport { bufferToStyledText, bufferToText, type TerminalBuffer } from \"@silvery/ag-term/buffer\"\nimport { StdoutContext, StderrContext, TermContext } from \"./context\"\nimport { isLayoutEngineInitialized } from \"@silvery/ag-term/layout-engine\"\nimport { executeRender, type PipelineConfig } from \"@silvery/ag-term/pipeline\"\nimport { createContainer, getContainerRoot } from \"./reconciler\"\nimport { stringReconciler } from \"./reconciler/string-reconciler\"\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Options for renderString().\n */\nexport interface RenderStringOptions {\n /**\n * Width in columns for layout calculations.\n * Default: 80\n */\n width?: number\n\n /**\n * Height in rows for layout calculations.\n * Default: 24\n */\n height?: number\n\n /**\n * Strip ANSI codes for plain text output.\n * Default: false (includes ANSI styling)\n */\n plain?: boolean\n\n /**\n * Pipeline configuration (scoped width measurer + output phase).\n * When provided, the render pipeline uses these for width measurement\n * and output generation instead of the global defaults.\n */\n pipelineConfig?: PipelineConfig\n\n /**\n * Trim trailing whitespace from each line.\n * Default: true (trims trailing spaces)\n *\n * Set to false when rendering to stdout where trailing spaces are\n * semantically significant (e.g., ink compat static renders).\n */\n trimTrailingWhitespace?: boolean\n\n /**\n * Trim trailing empty lines from the output.\n * Default: true (removes trailing empty lines)\n *\n * Set to false when padding/margin at the bottom should be preserved\n * (e.g., ink compat renders where `\\n\\n` padding is significant).\n */\n trimEmptyLines?: boolean\n\n /**\n * Callback to receive the computed content height (root node layout height).\n * Useful for callers that need to know the actual content bounds\n * (e.g., Ink compat layer needs to trim buffer padding but preserve\n * content-area empty lines).\n */\n onContentHeight?: (height: number) => void\n\n /**\n * Always use styled output (bufferToStyledText) even when plain=true.\n * Default: false\n *\n * When true, the output includes ANSI codes from embedded sequences in text\n * content (SGR, OSC hyperlinks) even though the mock term has no color\n * support (plain=true). This is needed for Ink compatibility: Ink passes\n * embedded ANSI sequences through regardless of chalk's color level, but\n * silvery's plain mode would strip them via bufferToText.\n *\n * The `plain` flag still controls whether the mock term has color support,\n * which determines whether Text component style props (color, bold, etc.)\n * produce style attributes in the buffer.\n */\n alwaysStyled?: boolean\n}\n\n// ============================================================================\n// Module State\n// ============================================================================\n\n// Track if we've initialized to avoid redundant imports\nlet engineInitialized = false\n\nasync function ensureLayoutEngine(): Promise<void> {\n if (engineInitialized || isLayoutEngineInitialized()) {\n return\n }\n // Use centralized default engine initialization\n const { ensureDefaultLayoutEngine } = await import(\"@silvery/ag-term/layout-engine\")\n await ensureDefaultLayoutEngine()\n engineInitialized = true\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Render a React element to a string (async version).\n *\n * Automatically initializes the layout engine if needed.\n * Use this when you're not sure if the layout engine is ready.\n *\n * @param element - React element to render\n * @param options - Render options (width, height, plain)\n * @returns Rendered string (with or without ANSI codes)\n *\n * @example\n * ```tsx\n * const output = await renderString(<Summary stats={stats} />)\n * console.log(output)\n * ```\n */\nexport async function renderString(element: ReactElement, options: RenderStringOptions = {}): Promise<string> {\n await ensureLayoutEngine()\n return renderStringSync(element, options)\n}\n\n/**\n * Render a React element to a string (sync version).\n *\n * Requires the layout engine to be already initialized.\n * Throws if the layout engine is not ready.\n *\n * @param element - React element to render\n * @param options - Render options (width, height, plain)\n * @returns Rendered string (with or without ANSI codes)\n *\n * @example\n * ```tsx\n * // After layout engine is initialized\n * const output = renderStringSync(<Summary stats={stats} />)\n * console.log(output)\n * ```\n */\nexport function renderStringSync(element: ReactElement, options: RenderStringOptions = {}): string {\n if (!isLayoutEngineInitialized()) {\n throw new Error(\"Layout engine not initialized. Use renderString() (async) or initialize with setLayoutEngine().\")\n }\n\n const {\n width = 80,\n height = 24,\n plain = false,\n pipelineConfig,\n trimTrailingWhitespace = true,\n trimEmptyLines = true,\n onContentHeight,\n alwaysStyled = false,\n } = options\n\n // Track whether React committed new work (from layout notifications etc.)\n let hadReactCommit = false\n const container = createContainer(() => {\n hadReactCommit = true\n })\n\n // Capture uncaught errors from the reconciler so they propagate to the caller\n let uncaughtError: unknown = null\n const onUncaughtError = (error: unknown) => {\n uncaughtError = error\n }\n\n // Create fiber root using the dedicated string reconciler (not the main one)\n const fiberRoot = stringReconciler.createContainer(\n container,\n 1, // ConcurrentRoot\n null, // hydrationCallbacks\n false, // isStrictMode\n null, // concurrentUpdatesByDefaultOverride\n \"\", // identifierPrefix\n onUncaughtError, // onUncaughtError\n () => {}, // onCaughtError\n () => {}, // onRecoverableError\n null, // onDefaultTransitionIndicator\n )\n\n // Create minimal mock stdout for components that use useStdout\n const mockStdout = {\n columns: width,\n rows: height,\n write: () => true,\n isTTY: false,\n on: () => mockStdout,\n off: () => mockStdout,\n once: () => mockStdout,\n removeListener: () => mockStdout,\n addListener: () => mockStdout,\n } as unknown as NodeJS.WriteStream\n\n // Create mock term for components that use useTerm()\n const mockTerm = createTerm({ color: plain ? null : \"truecolor\" })\n\n // Wrap with minimal contexts (no input handling needed)\n const wrapped = React.createElement(\n TermContext.Provider,\n { value: mockTerm },\n React.createElement(\n StdoutContext.Provider,\n {\n value: {\n stdout: mockStdout,\n write: () => {},\n },\n },\n React.createElement(\n StderrContext.Provider,\n {\n value: {\n stderr: process.stderr,\n write: (data: string) => {\n process.stderr.write(data)\n },\n },\n },\n element,\n ),\n ),\n )\n\n // Mount the React tree inside act() so layout feedback works\n withActEnvironment(() => {\n act(() => {\n stringReconciler.updateContainerSync(wrapped, fiberRoot, null, null)\n stringReconciler.flushSyncWork()\n })\n })\n\n // Propagate any uncaught render errors (e.g., text outside <Text> in strict mode)\n if (uncaughtError) {\n throw uncaughtError instanceof Error ? uncaughtError : new Error(String(uncaughtError))\n }\n\n // Layout stabilization loop: run the pipeline, flush React work from\n // layout notifications (useBoxRect forceUpdate etc.), repeat until stable.\n // This matches the test renderer's multi-pass approach.\n let buffer!: TerminalBuffer\n let rootNode: ReturnType<typeof getContainerRoot> | undefined\n const MAX_ITERATIONS = 5\n for (let i = 0; i < MAX_ITERATIONS; i++) {\n hadReactCommit = false\n withActEnvironment(() => {\n act(() => {\n const root = getContainerRoot(container)\n rootNode = root\n const result = executeRender(root, width, height, null, undefined, pipelineConfig)\n buffer = result.buffer\n })\n if (!hadReactCommit) {\n act(() => {\n stringReconciler.flushSyncWork()\n })\n }\n })\n if (!hadReactCommit) break\n }\n\n // Report content height if callback provided.\n // Compute from children's outer bottom edges (including margins) rather than\n // root.boxRect.height which equals the buffer height (root stretches to fill).\n if (onContentHeight && rootNode) {\n let maxBottom = 0\n let hasChildren = false\n for (const child of rootNode.children) {\n if (child.boxRect) {\n hasChildren = true\n const props = child.props as Record<string, unknown>\n const mb = (props.marginBottom as number) ?? (props.marginY as number) ?? (props.margin as number) ?? 0\n const childBottom = child.boxRect.y + child.boxRect.height + mb\n if (childBottom > maxBottom) maxBottom = childBottom\n }\n }\n onContentHeight(hasChildren ? maxBottom : 0)\n }\n\n // Unmount (cleanup)\n withActEnvironment(() => {\n act(() => {\n stringReconciler.updateContainerSync(null, fiberRoot, null, null)\n stringReconciler.flushSyncWork()\n })\n })\n\n return plain && !alwaysStyled\n ? bufferToText(buffer, { trimTrailingWhitespace, trimEmptyLines })\n : bufferToStyledText(buffer, { trimTrailingWhitespace, trimEmptyLines })\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Run a function with IS_REACT_ACT_ENVIRONMENT temporarily set to true.\n * This ensures act() captures forceUpdate/setState from layout notifications.\n */\nfunction withActEnvironment(fn: () => void): void {\n const prev = (globalThis as any).IS_REACT_ACT_ENVIRONMENT\n ;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true\n try {\n fn()\n } finally {\n ;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = prev\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,mBAAmB,WAAW;CACzC,GAAG;CACH,mBAAmB;CACpB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;aCI6F;AAwF/F,IAAI,oBAAoB;AAExB,eAAe,qBAAoC;AACjD,KAAI,qBAAqB,2BAA2B,CAClD;CAGF,MAAM,EAAE,8BAA8B,MAAM,OAAO;AACnD,OAAM,2BAA2B;AACjC,qBAAoB;;;;;;;;;;;;;;;;;;AAuBtB,eAAsB,aAAa,SAAuB,UAA+B,EAAE,EAAmB;AAC5G,OAAM,oBAAoB;AAC1B,QAAO,iBAAiB,SAAS,QAAQ;;;;;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AAU;IACR,MAAM,OAAO,iBAAiB,UAAU;AACxC,eAAW;AAEX,aADe,cAAc,MAAM,OAAO,QAAQ,MAAM,KAAA,GAAW,eAAe,CAClE;KAChB;AACF,OAAI,CAAC,eACH,WAAU;AACR,qBAAiB,eAAe;KAChC;IAEJ;AACF,MAAI,CAAC,eAAgB;;AAMvB,KAAI,mBAAmB,UAAU;EAC/B,IAAI,YAAY;EAChB,IAAI,cAAc;AAClB,OAAK,MAAM,SAAS,SAAS,SAC3B,KAAI,MAAM,SAAS;AACjB,iBAAc;GACd,MAAM,QAAQ,MAAM;GACpB,MAAM,KAAM,MAAM,gBAA4B,MAAM,WAAuB,MAAM,UAAqB;GACtG,MAAM,cAAc,MAAM,QAAQ,IAAI,MAAM,QAAQ,SAAS;AAC7D,OAAI,cAAc,UAAW,aAAY;;AAG7C,kBAAgB,cAAc,YAAY,EAAE;;AAI9C,0BAAyB;AACvB,YAAU;AACR,oBAAiB,oBAAoB,MAAM,WAAW,MAAM,KAAK;AACjE,oBAAiB,eAAe;IAChC;GACF;AAEF,QAAO,SAAS,CAAC,eACb,aAAa,QAAQ;EAAE;EAAwB;EAAgB,CAAC,GAChE,mBAAmB,QAAQ;EAAE;EAAwB;EAAgB,CAAC;;;;;;AAW5E,SAAS,mBAAmB,IAAsB;CAChD,MAAM,OAAQ,WAAmB;AAC/B,YAAmB,2BAA2B;AAChD,KAAI;AACF,MAAI;WACI;AACN,aAAmB,2BAA2B"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { i as __require, t as __commonJSMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
//#region ../../node_modules/.bun/@resvg+resvg-js@2.6.2/node_modules/@resvg/resvg-js/js-binding.js
|
|
3
|
+
var require_js_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
const { existsSync, readFileSync } = __require("fs"), { join } = __require("path"), { platform, arch } = process;
|
|
5
|
+
let nativeBinding = null, localFileExisted = !1, loadError = null;
|
|
6
|
+
function isMusl() {
|
|
7
|
+
if (!process.report || typeof process.report.getReport != "function") try {
|
|
8
|
+
return readFileSync(__require("child_process").execSync("which ldd").toString().trim(), "utf8").includes("musl");
|
|
9
|
+
} catch {
|
|
10
|
+
return !0;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const { glibcVersionRuntime: e } = process.report.getReport().header;
|
|
14
|
+
return !e;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
switch (platform) {
|
|
18
|
+
case "android":
|
|
19
|
+
switch (arch) {
|
|
20
|
+
case "arm64":
|
|
21
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.android-arm64.node"));
|
|
22
|
+
try {
|
|
23
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.android-arm64.node") : nativeBinding = __require("@resvg/resvg-js-android-arm64");
|
|
24
|
+
} catch (e) {
|
|
25
|
+
loadError = e;
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "arm":
|
|
29
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.android-arm-eabi.node"));
|
|
30
|
+
try {
|
|
31
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.android-arm-eabi.node") : nativeBinding = __require("@resvg/resvg-js-android-arm-eabi");
|
|
32
|
+
} catch (e) {
|
|
33
|
+
loadError = e;
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
default: throw new Error(`Unsupported architecture on Android ${arch}`);
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case "win32":
|
|
40
|
+
switch (arch) {
|
|
41
|
+
case "x64":
|
|
42
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.win32-x64-msvc.node"));
|
|
43
|
+
try {
|
|
44
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.win32-x64-msvc.node") : nativeBinding = __require("@resvg/resvg-js-win32-x64-msvc");
|
|
45
|
+
} catch (e) {
|
|
46
|
+
loadError = e;
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case "ia32":
|
|
50
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.win32-ia32-msvc.node"));
|
|
51
|
+
try {
|
|
52
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.win32-ia32-msvc.node") : nativeBinding = __require("@resvg/resvg-js-win32-ia32-msvc");
|
|
53
|
+
} catch (e) {
|
|
54
|
+
loadError = e;
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case "arm64":
|
|
58
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.win32-arm64-msvc.node"));
|
|
59
|
+
try {
|
|
60
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.win32-arm64-msvc.node") : nativeBinding = __require("@resvg/resvg-js-win32-arm64-msvc");
|
|
61
|
+
} catch (e) {
|
|
62
|
+
loadError = e;
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
default: throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case "darwin":
|
|
69
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.darwin-universal.node"));
|
|
70
|
+
try {
|
|
71
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.darwin-universal.node") : nativeBinding = __require("@resvg/resvg-js-darwin-universal");
|
|
72
|
+
break;
|
|
73
|
+
} catch {}
|
|
74
|
+
switch (arch) {
|
|
75
|
+
case "x64":
|
|
76
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.darwin-x64.node"));
|
|
77
|
+
try {
|
|
78
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.darwin-x64.node") : nativeBinding = __require("@resvg/resvg-js-darwin-x64");
|
|
79
|
+
} catch (e) {
|
|
80
|
+
loadError = e;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "arm64":
|
|
84
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.darwin-arm64.node"));
|
|
85
|
+
try {
|
|
86
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.darwin-arm64.node") : nativeBinding = __require("./assets/resvgjs.darwin-arm64-BtufyGW1.node");
|
|
87
|
+
} catch (e) {
|
|
88
|
+
loadError = e;
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
default: throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case "freebsd":
|
|
95
|
+
if (arch !== "x64") throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
|
|
96
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.freebsd-x64.node"));
|
|
97
|
+
try {
|
|
98
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.freebsd-x64.node") : nativeBinding = __require("@resvg/resvg-js-freebsd-x64");
|
|
99
|
+
} catch (e) {
|
|
100
|
+
loadError = e;
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case "linux":
|
|
104
|
+
switch (arch) {
|
|
105
|
+
case "x64":
|
|
106
|
+
if (isMusl()) {
|
|
107
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-x64-musl.node"));
|
|
108
|
+
try {
|
|
109
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-x64-musl.node") : nativeBinding = __require("@resvg/resvg-js-linux-x64-musl");
|
|
110
|
+
} catch (e) {
|
|
111
|
+
loadError = e;
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-x64-gnu.node"));
|
|
115
|
+
try {
|
|
116
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-x64-gnu.node") : nativeBinding = __require("@resvg/resvg-js-linux-x64-gnu");
|
|
117
|
+
} catch (e) {
|
|
118
|
+
loadError = e;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
case "arm64":
|
|
123
|
+
if (isMusl()) {
|
|
124
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-arm64-musl.node"));
|
|
125
|
+
try {
|
|
126
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-arm64-musl.node") : nativeBinding = __require("@resvg/resvg-js-linux-arm64-musl");
|
|
127
|
+
} catch (e) {
|
|
128
|
+
loadError = e;
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-arm64-gnu.node"));
|
|
132
|
+
try {
|
|
133
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-arm64-gnu.node") : nativeBinding = __require("@resvg/resvg-js-linux-arm64-gnu");
|
|
134
|
+
} catch (e) {
|
|
135
|
+
loadError = e;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
case "arm":
|
|
140
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-arm-gnueabihf.node"));
|
|
141
|
+
try {
|
|
142
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-arm-gnueabihf.node") : nativeBinding = __require("@resvg/resvg-js-linux-arm-gnueabihf");
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e;
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case "riscv64":
|
|
148
|
+
if (isMusl()) {
|
|
149
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-riscv64-musl.node"));
|
|
150
|
+
try {
|
|
151
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-riscv64-musl.node") : nativeBinding = __require("@resvg/resvg-js-linux-riscv64-musl");
|
|
152
|
+
} catch (e) {
|
|
153
|
+
loadError = e;
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-riscv64-gnu.node"));
|
|
157
|
+
try {
|
|
158
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-riscv64-gnu.node") : nativeBinding = __require("@resvg/resvg-js-linux-riscv64-gnu");
|
|
159
|
+
} catch (e) {
|
|
160
|
+
loadError = e;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case "s390x":
|
|
165
|
+
localFileExisted = existsSync(join(__dirname, "resvgjs.linux-s390x-gnu.node"));
|
|
166
|
+
try {
|
|
167
|
+
localFileExisted ? nativeBinding = __require("./resvgjs.linux-s390x-gnu.node") : nativeBinding = __require("@resvg/resvg-js-linux-s390x-gnu");
|
|
168
|
+
} catch (e) {
|
|
169
|
+
loadError = e;
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
default: throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
default: throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
176
|
+
}
|
|
177
|
+
if (!nativeBinding) throw loadError || /* @__PURE__ */ new Error("Failed to load native binding");
|
|
178
|
+
const { BBox, Resvg, RenderedImage, renderAsync } = nativeBinding;
|
|
179
|
+
module.exports.BBox = BBox, module.exports.Resvg = Resvg, module.exports.RenderedImage = RenderedImage, module.exports.renderAsync = renderAsync;
|
|
180
|
+
}));
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region ../../node_modules/.bun/@resvg+resvg-js@2.6.2/node_modules/@resvg/resvg-js/index.js
|
|
183
|
+
var require_resvg_js = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
184
|
+
const { render: _render, renderAsync: _renderAsync, Resvg: _Resvg } = require_js_binding();
|
|
185
|
+
module.exports.render = function render(svg, options) {
|
|
186
|
+
if (options) return _render(svg, JSON.stringify(options));
|
|
187
|
+
return _render(svg);
|
|
188
|
+
};
|
|
189
|
+
module.exports.renderAsync = function renderAsync(svg, options, signal) {
|
|
190
|
+
if (options) return _renderAsync(svg, JSON.stringify(options), signal);
|
|
191
|
+
return _renderAsync(svg, null, signal);
|
|
192
|
+
};
|
|
193
|
+
module.exports.Resvg = class Resvg extends _Resvg {
|
|
194
|
+
constructor(svg, options) {
|
|
195
|
+
super(svg, JSON.stringify(options));
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}));
|
|
199
|
+
//#endregion
|
|
200
|
+
export default require_resvg_js();
|
|
201
|
+
export {};
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=resvg-js-V6oMi8CY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resvg-js-V6oMi8CY.mjs","names":[],"sources":["../../../node_modules/.bun/@resvg+resvg-js@2.6.2/node_modules/@resvg/resvg-js/js-binding.js","../../../node_modules/.bun/@resvg+resvg-js@2.6.2/node_modules/@resvg/resvg-js/index.js"],"sourcesContent":["\"use strict\";const{existsSync,readFileSync}=require(\"fs\"),{join}=require(\"path\"),{platform,arch}=process;let nativeBinding=null,localFileExisted=!1,loadError=null;function isMusl(){if(!process.report||typeof process.report.getReport!=\"function\")try{const e=require(\"child_process\").execSync(\"which ldd\").toString().trim();return readFileSync(e,\"utf8\").includes(\"musl\")}catch{return!0}else{const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}}switch(platform){case\"android\":switch(arch){case\"arm64\":localFileExisted=existsSync(join(__dirname,\"resvgjs.android-arm64.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.android-arm64.node\"):nativeBinding=require(\"@resvg/resvg-js-android-arm64\")}catch(e){loadError=e}break;case\"arm\":localFileExisted=existsSync(join(__dirname,\"resvgjs.android-arm-eabi.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.android-arm-eabi.node\"):nativeBinding=require(\"@resvg/resvg-js-android-arm-eabi\")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Android ${arch}`)}break;case\"win32\":switch(arch){case\"x64\":localFileExisted=existsSync(join(__dirname,\"resvgjs.win32-x64-msvc.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.win32-x64-msvc.node\"):nativeBinding=require(\"@resvg/resvg-js-win32-x64-msvc\")}catch(e){loadError=e}break;case\"ia32\":localFileExisted=existsSync(join(__dirname,\"resvgjs.win32-ia32-msvc.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.win32-ia32-msvc.node\"):nativeBinding=require(\"@resvg/resvg-js-win32-ia32-msvc\")}catch(e){loadError=e}break;case\"arm64\":localFileExisted=existsSync(join(__dirname,\"resvgjs.win32-arm64-msvc.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.win32-arm64-msvc.node\"):nativeBinding=require(\"@resvg/resvg-js-win32-arm64-msvc\")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Windows: ${arch}`)}break;case\"darwin\":localFileExisted=existsSync(join(__dirname,\"resvgjs.darwin-universal.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.darwin-universal.node\"):nativeBinding=require(\"@resvg/resvg-js-darwin-universal\");break}catch{}switch(arch){case\"x64\":localFileExisted=existsSync(join(__dirname,\"resvgjs.darwin-x64.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.darwin-x64.node\"):nativeBinding=require(\"@resvg/resvg-js-darwin-x64\")}catch(e){loadError=e}break;case\"arm64\":localFileExisted=existsSync(join(__dirname,\"resvgjs.darwin-arm64.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.darwin-arm64.node\"):nativeBinding=require(\"@resvg/resvg-js-darwin-arm64\")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on macOS: ${arch}`)}break;case\"freebsd\":if(arch!==\"x64\")throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);localFileExisted=existsSync(join(__dirname,\"resvgjs.freebsd-x64.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.freebsd-x64.node\"):nativeBinding=require(\"@resvg/resvg-js-freebsd-x64\")}catch(e){loadError=e}break;case\"linux\":switch(arch){case\"x64\":if(isMusl()){localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-x64-musl.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-x64-musl.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-x64-musl\")}catch(e){loadError=e}}else{localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-x64-gnu.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-x64-gnu.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-x64-gnu\")}catch(e){loadError=e}}break;case\"arm64\":if(isMusl()){localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-arm64-musl.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-arm64-musl.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-arm64-musl\")}catch(e){loadError=e}}else{localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-arm64-gnu.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-arm64-gnu.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-arm64-gnu\")}catch(e){loadError=e}}break;case\"arm\":localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-arm-gnueabihf.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-arm-gnueabihf.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-arm-gnueabihf\")}catch(e){loadError=e}break;case\"riscv64\":if(isMusl()){localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-riscv64-musl.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-riscv64-musl.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-riscv64-musl\")}catch(e){loadError=e}}else{localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-riscv64-gnu.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-riscv64-gnu.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-riscv64-gnu\")}catch(e){loadError=e}}break;case\"s390x\":localFileExisted=existsSync(join(__dirname,\"resvgjs.linux-s390x-gnu.node\"));try{localFileExisted?nativeBinding=require(\"./resvgjs.linux-s390x-gnu.node\"):nativeBinding=require(\"@resvg/resvg-js-linux-s390x-gnu\")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Linux: ${arch}`)}break;default:throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)}if(!nativeBinding)throw loadError||new Error(\"Failed to load native binding\");const{BBox,Resvg,RenderedImage,renderAsync}=nativeBinding;module.exports.BBox=BBox,module.exports.Resvg=Resvg,module.exports.RenderedImage=RenderedImage,module.exports.renderAsync=renderAsync;\n","const { render: _render, renderAsync: _renderAsync, Resvg: _Resvg } = require('./js-binding.js')\n\nmodule.exports.render = function render(svg, options) {\n if (options) {\n return _render(svg, JSON.stringify(options))\n }\n return _render(svg)\n}\n\nmodule.exports.renderAsync = function renderAsync(svg, options, signal) {\n if (options) {\n return _renderAsync(svg, JSON.stringify(options), signal)\n }\n return _renderAsync(svg, null, signal)\n}\n\nmodule.exports.Resvg = class Resvg extends _Resvg {\n constructor(svg, options) {\n super(svg, JSON.stringify(options))\n }\n}\n\n// module.exports.Resvg = _Resvg\n"],"x_google_ignoreList":[0,1],"mappings":";;;CAAa,MAAK,EAAC,YAAW,iBAAA,UAAsB,KAAK,EAAC,EAAC,SAAA,UAAc,OAAO,EAAC,EAAC,UAAS,SAAM;CAAQ,IAAI,gBAAc,MAAK,mBAAiB,CAAC,GAAE,YAAU;CAAK,SAAS,SAAQ;AAAC,MAAG,CAAC,QAAQ,UAAQ,OAAO,QAAQ,OAAO,aAAW,WAAW,KAAG;AAA0E,UAAO,aAAA,UAAhE,gBAAgB,CAAC,SAAS,YAAY,CAAC,UAAU,CAAC,MAAM,EAAuB,OAAO,CAAC,SAAS,OAAO;UAAM;AAAC,UAAM,CAAC;;OAAM;GAAC,MAAK,EAAC,qBAAoB,MAAG,QAAQ,OAAO,WAAW,CAAC;AAAO,UAAM,CAAC;;;AAAG,SAAO,UAAP;EAAiB,KAAI;AAAU,WAAO,MAAP;IAAa,KAAI;AAAQ,wBAAiB,WAAW,KAAK,WAAU,6BAA6B,CAAC;AAAC,SAAG;AAAC,yBAAiB,gBAAA,UAAsB,+BAA+B,GAAC,gBAAA,UAAsB,gCAAgC;cAAO,GAAE;AAAC,kBAAU;;AAAE;IAAM,KA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