flavor-code 1.3.21 → 1.3.22
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.
|
@@ -1523,40 +1523,71 @@ function isBridgeMethod(value, method) {
|
|
|
1523
1523
|
&& typeof value[method] === "function";
|
|
1524
1524
|
}
|
|
1525
1525
|
|
|
1526
|
+
function pngDataFromTiff(tiff) {
|
|
1527
|
+
if (!isBridgeMethod(tiff, "base64EncodedStringWithOptions")) {
|
|
1528
|
+
return null;
|
|
1529
|
+
}
|
|
1530
|
+
try {
|
|
1531
|
+
const representation = $.NSBitmapImageRep.imageRepWithData(tiff);
|
|
1532
|
+
if (!isBridgeMethod(representation, "representationUsingTypeProperties")) {
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
const converted = representation.representationUsingTypeProperties(
|
|
1536
|
+
$.NSBitmapImageFileTypePNG,
|
|
1537
|
+
$({})
|
|
1538
|
+
);
|
|
1539
|
+
return isBridgeMethod(converted, "base64EncodedStringWithOptions")
|
|
1540
|
+
? converted
|
|
1541
|
+
: null;
|
|
1542
|
+
} catch (error) {
|
|
1543
|
+
return null;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
function base64FromData(data) {
|
|
1548
|
+
if (!isBridgeMethod(data, "base64EncodedStringWithOptions")) {
|
|
1549
|
+
return null;
|
|
1550
|
+
}
|
|
1551
|
+
try {
|
|
1552
|
+
const encoded = data.base64EncodedStringWithOptions(0);
|
|
1553
|
+
if (!encoded) {
|
|
1554
|
+
return null;
|
|
1555
|
+
}
|
|
1556
|
+
const unwrapped = ObjC.unwrap(encoded);
|
|
1557
|
+
return typeof unwrapped === "string" && unwrapped.length > 0
|
|
1558
|
+
? unwrapped
|
|
1559
|
+
: null;
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
return null;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1526
1565
|
try {
|
|
1527
1566
|
const pasteboard = $.NSPasteboard.generalPasteboard;
|
|
1528
|
-
let
|
|
1567
|
+
let encoded = null;
|
|
1529
1568
|
if (isBridgeMethod(pasteboard, "dataForType")) {
|
|
1530
|
-
|
|
1531
|
-
if (
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
// NSData.length is exposed by JXA as a property value, not a
|
|
1536
|
-
// callable bridge method. Probe a real NSData method so a valid
|
|
1537
|
-
// TIFF-only pasteboard item is not mistaken for ObjC nil.
|
|
1538
|
-
if (isBridgeMethod(tiff, "base64EncodedStringWithOptions")) {
|
|
1539
|
-
const representation = $.NSBitmapImageRep.imageRepWithData(tiff);
|
|
1540
|
-
if (isBridgeMethod(representation, "representationUsingTypeProperties")) {
|
|
1541
|
-
const converted = representation.representationUsingTypeProperties(
|
|
1542
|
-
$.NSBitmapImageFileTypePNG,
|
|
1543
|
-
$({})
|
|
1544
|
-
);
|
|
1545
|
-
if (isBridgeMethod(converted, "base64EncodedStringWithOptions")) {
|
|
1546
|
-
data = converted;
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1569
|
+
encoded = base64FromData(pasteboard.dataForType($.NSPasteboardTypePNG));
|
|
1570
|
+
if (!encoded) {
|
|
1571
|
+
encoded = base64FromData(
|
|
1572
|
+
pngDataFromTiff(pasteboard.dataForType($.NSPasteboardTypeTIFF))
|
|
1573
|
+
);
|
|
1550
1574
|
}
|
|
1551
1575
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1576
|
+
|
|
1577
|
+
// Some macOS applications do not advertise a direct public.png or
|
|
1578
|
+
// public.tiff payload. NSImage can ask AppKit to read any image type the
|
|
1579
|
+
// pasteboard promises (for example PDF, HEIC, or a lazily supplied image),
|
|
1580
|
+
// after which TIFFRepresentation gives us a stable raster conversion path.
|
|
1581
|
+
if (!encoded) {
|
|
1582
|
+
const image = $.NSImage.alloc.initWithPasteboard(pasteboard);
|
|
1583
|
+
if (image !== null && image !== undefined) {
|
|
1584
|
+
encoded = base64FromData(pngDataFromTiff(image.TIFFRepresentation));
|
|
1585
|
+
}
|
|
1554
1586
|
}
|
|
1555
|
-
const encoded = data.base64EncodedStringWithOptions(0);
|
|
1556
1587
|
if (!encoded) {
|
|
1557
1588
|
$.exit(3);
|
|
1558
1589
|
}
|
|
1559
|
-
console.log(
|
|
1590
|
+
console.log(encoded);
|
|
1560
1591
|
} catch (error) {
|
|
1561
1592
|
$.exit(3);
|
|
1562
1593
|
}
|
package/dist/cli-main.js
CHANGED
|
@@ -882,7 +882,7 @@ async function runInteractiveCli(props) {
|
|
|
882
882
|
const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
|
|
883
883
|
import("./claude-ink-6CEG2XZZ.js"),
|
|
884
884
|
import("react"),
|
|
885
|
-
import("./app-
|
|
885
|
+
import("./app-MWGRT3BJ.js")
|
|
886
886
|
]);
|
|
887
887
|
const instance = await render(createElement(
|
|
888
888
|
AlternateScreen,
|