flavor-code 1.3.21 → 1.3.23
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/{app-Q4M7GLFX.js → app-NTEUPJKJ.js} +148 -31
- package/dist/cli-main.js +1 -1
- package/package.json +1 -1
|
@@ -1523,43 +1523,160 @@ function isBridgeMethod(value, method) {
|
|
|
1523
1523
|
&& typeof value[method] === "function";
|
|
1524
1524
|
}
|
|
1525
1525
|
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1526
|
+
function safeDataForType(pasteboard, type) {
|
|
1527
|
+
try {
|
|
1528
|
+
return isBridgeMethod(pasteboard, "dataForType")
|
|
1529
|
+
? pasteboard.dataForType(type)
|
|
1530
|
+
: null;
|
|
1531
|
+
} catch (error) {
|
|
1532
|
+
return null;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
function pngDataFromTiff(tiff) {
|
|
1537
|
+
if (!isBridgeMethod(tiff, "base64EncodedStringWithOptions")) {
|
|
1538
|
+
return null;
|
|
1539
|
+
}
|
|
1540
|
+
try {
|
|
1541
|
+
const representation = $.NSBitmapImageRep.imageRepWithData(tiff);
|
|
1542
|
+
if (!isBridgeMethod(representation, "representationUsingTypeProperties")) {
|
|
1543
|
+
return null;
|
|
1544
|
+
}
|
|
1545
|
+
const converted = representation.representationUsingTypeProperties(
|
|
1546
|
+
$.NSBitmapImageFileTypePNG,
|
|
1547
|
+
$({})
|
|
1548
|
+
);
|
|
1549
|
+
return isBridgeMethod(converted, "base64EncodedStringWithOptions")
|
|
1550
|
+
? converted
|
|
1551
|
+
: null;
|
|
1552
|
+
} catch (error) {
|
|
1553
|
+
return null;
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
function base64FromData(data) {
|
|
1558
|
+
if (!isBridgeMethod(data, "base64EncodedStringWithOptions")) {
|
|
1559
|
+
return null;
|
|
1560
|
+
}
|
|
1561
|
+
try {
|
|
1562
|
+
const encoded = data.base64EncodedStringWithOptions(0);
|
|
1563
|
+
if (!encoded) {
|
|
1564
|
+
return null;
|
|
1565
|
+
}
|
|
1566
|
+
const unwrapped = ObjC.unwrap(encoded);
|
|
1567
|
+
return typeof unwrapped === "string" && unwrapped.length > 0
|
|
1568
|
+
? unwrapped
|
|
1569
|
+
: null;
|
|
1570
|
+
} catch (error) {
|
|
1571
|
+
return null;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
function firstReadableObject(pasteboard, objectClass) {
|
|
1576
|
+
try {
|
|
1577
|
+
if (!isBridgeMethod(pasteboard, "readObjectsForClassesOptions")) {
|
|
1578
|
+
return null;
|
|
1579
|
+
}
|
|
1580
|
+
const classes = $.NSArray.arrayWithObject(objectClass);
|
|
1581
|
+
const objects = pasteboard.readObjectsForClassesOptions(classes, $({}));
|
|
1582
|
+
return objects === null || objects === undefined ? null : objects.firstObject;
|
|
1583
|
+
} catch (error) {
|
|
1584
|
+
return null;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
function imageFromWholePasteboard(pasteboard) {
|
|
1589
|
+
try {
|
|
1590
|
+
const image = $.NSImage.alloc.initWithPasteboard(pasteboard);
|
|
1591
|
+
return image === null || image === undefined ? null : image;
|
|
1592
|
+
} catch (error) {
|
|
1593
|
+
return null;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
function imageFromFileUrl(pasteboard) {
|
|
1598
|
+
try {
|
|
1599
|
+
const url = firstReadableObject(pasteboard, $.NSURL);
|
|
1600
|
+
if (url === null || url === undefined || !url.isFileURL) {
|
|
1601
|
+
return null;
|
|
1550
1602
|
}
|
|
1603
|
+
const image = $.NSImage.alloc.initWithContentsOfURL(url);
|
|
1604
|
+
return image === null || image === undefined ? null : image;
|
|
1605
|
+
} catch (error) {
|
|
1606
|
+
return null;
|
|
1551
1607
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
function base64FromImage(image) {
|
|
1611
|
+
try {
|
|
1612
|
+
return image === null || image === undefined
|
|
1613
|
+
? null
|
|
1614
|
+
: base64FromData(pngDataFromTiff(image.TIFFRepresentation));
|
|
1615
|
+
} catch (error) {
|
|
1616
|
+
return null;
|
|
1554
1617
|
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
function pasteboardTypeNames(pasteboard) {
|
|
1621
|
+
try {
|
|
1622
|
+
const types = pasteboard.types;
|
|
1623
|
+
if (!isBridgeMethod(types, "objectAtIndex")) {
|
|
1624
|
+
return [];
|
|
1625
|
+
}
|
|
1626
|
+
const count = Number(types.count);
|
|
1627
|
+
const names = [];
|
|
1628
|
+
for (let index = 0; index < count; index += 1) {
|
|
1629
|
+
const name = ObjC.unwrap(types.objectAtIndex(index));
|
|
1630
|
+
if (typeof name === "string") {
|
|
1631
|
+
names.push(name);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
return names;
|
|
1635
|
+
} catch (error) {
|
|
1636
|
+
return [];
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
const pasteboard = $.NSPasteboard.generalPasteboard;
|
|
1641
|
+
let encoded = base64FromData(safeDataForType(pasteboard, $("public.png")));
|
|
1642
|
+
|
|
1643
|
+
if (!encoded) {
|
|
1644
|
+
encoded = base64FromData(
|
|
1645
|
+
pngDataFromTiff(safeDataForType(pasteboard, $("public.tiff")))
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
// Ask AppKit for objects conforming to NSPasteboardReading. This covers image
|
|
1650
|
+
// formats and lazy providers that do not expose direct PNG/TIFF NSData.
|
|
1651
|
+
if (!encoded) {
|
|
1652
|
+
encoded = base64FromImage(firstReadableObject(pasteboard, $.NSImage));
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
if (!encoded) {
|
|
1656
|
+
encoded = base64FromImage(imageFromWholePasteboard(pasteboard));
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
// Finder copies files as file URLs instead of image bytes. Load the first
|
|
1660
|
+
// local file through NSImage, which also rejects non-image files.
|
|
1661
|
+
if (!encoded) {
|
|
1662
|
+
encoded = base64FromImage(imageFromFileUrl(pasteboard));
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
if (!encoded) {
|
|
1666
|
+
const types = pasteboardTypeNames(pasteboard);
|
|
1667
|
+
const advertisedImage = types.some(function (type) {
|
|
1668
|
+
return /image|png|tiff|jpeg|jpg|heic|gif|webp|bmp|pdf|file-url|filenames/i.test(type);
|
|
1669
|
+
});
|
|
1670
|
+
if (advertisedImage) {
|
|
1671
|
+
throw new Error(
|
|
1672
|
+
"Clipboard advertises image or file data but AppKit could not decode it. Types: "
|
|
1673
|
+
+ types.join(", ")
|
|
1674
|
+
);
|
|
1558
1675
|
}
|
|
1559
|
-
console.log(ObjC.unwrap(encoded));
|
|
1560
|
-
} catch (error) {
|
|
1561
1676
|
$.exit(3);
|
|
1562
1677
|
}
|
|
1678
|
+
|
|
1679
|
+
console.log(encoded);
|
|
1563
1680
|
`.trim();
|
|
1564
1681
|
function shouldReadClipboardImage(input, key, isPasted) {
|
|
1565
1682
|
return (key.ctrl || key.meta === true) && input.toLowerCase() === "v" || isPasted && input.length === 0;
|
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-NTEUPJKJ.js")
|
|
886
886
|
]);
|
|
887
887
|
const instance = await render(createElement(
|
|
888
888
|
AlternateScreen,
|