@lichao0223/lobehub-cli 0.0.79 → 0.0.80
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/acceptance-report.html +23 -23
- package/dist/index.js +102 -66
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -31875,6 +31875,70 @@ _Mime_extensionToType = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtension = /
|
|
|
31875
31875
|
//#region node_modules/.pnpm/mime@4.1.2/node_modules/mime/dist/src/index.js
|
|
31876
31876
|
var src_default = new Mime(types$1, types$2)._freeze();
|
|
31877
31877
|
|
|
31878
|
+
//#endregion
|
|
31879
|
+
//#region ../../packages/utils/src/detectUtf16.ts
|
|
31880
|
+
var HEURISTIC_SAMPLE_BYTES, HEURISTIC_THRESHOLD, detectUtf16NoBom;
|
|
31881
|
+
var init_detectUtf16 = __esmMin((() => {
|
|
31882
|
+
HEURISTIC_SAMPLE_BYTES = 512;
|
|
31883
|
+
HEURISTIC_THRESHOLD = .3;
|
|
31884
|
+
detectUtf16NoBom = (buffer) => {
|
|
31885
|
+
const sample = buffer.subarray(0, Math.min(HEURISTIC_SAMPLE_BYTES, buffer.length));
|
|
31886
|
+
if (sample.length < 4 || sample.length % 2 !== 0) return null;
|
|
31887
|
+
let leAsciiPairs = 0;
|
|
31888
|
+
let beAsciiPairs = 0;
|
|
31889
|
+
const totalPairs = sample.length / 2;
|
|
31890
|
+
for (let i = 0; i < sample.length; i += 2) {
|
|
31891
|
+
const lo = sample[i];
|
|
31892
|
+
const hi = sample[i + 1];
|
|
31893
|
+
if (hi === 0 && lo !== 0) leAsciiPairs++;
|
|
31894
|
+
else if (lo === 0 && hi !== 0) beAsciiPairs++;
|
|
31895
|
+
}
|
|
31896
|
+
if (leAsciiPairs > beAsciiPairs && leAsciiPairs / totalPairs >= HEURISTIC_THRESHOLD) return "utf-16le";
|
|
31897
|
+
if (beAsciiPairs > leAsciiPairs && beAsciiPairs / totalPairs >= HEURISTIC_THRESHOLD) return "utf-16be";
|
|
31898
|
+
return null;
|
|
31899
|
+
};
|
|
31900
|
+
}));
|
|
31901
|
+
|
|
31902
|
+
//#endregion
|
|
31903
|
+
//#region ../../packages/utils/src/isBinaryContent.ts
|
|
31904
|
+
var NON_PRINTABLE_THRESHOLD, hasUtf8Bom, hasUtf16Bom, sniffBinaryBuffer, REPLACEMENT_CHAR, checkPrintableRatio;
|
|
31905
|
+
var init_isBinaryContent = __esmMin((() => {
|
|
31906
|
+
init_detectUtf16();
|
|
31907
|
+
NON_PRINTABLE_THRESHOLD = .3;
|
|
31908
|
+
hasUtf8Bom = (buf) => buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191;
|
|
31909
|
+
hasUtf16Bom = (buf) => buf.length >= 2 && (buf[0] === 255 && buf[1] === 254 || buf[0] === 254 && buf[1] === 255);
|
|
31910
|
+
sniffBinaryBuffer = (buffer) => {
|
|
31911
|
+
if (buffer.length === 0) return { isBinary: false };
|
|
31912
|
+
if (hasUtf8Bom(buffer) || hasUtf16Bom(buffer)) return { isBinary: false };
|
|
31913
|
+
const utf16Variant = detectUtf16NoBom(buffer);
|
|
31914
|
+
if (utf16Variant) return checkPrintableRatio(new TextDecoder(utf16Variant, { fatal: false }).decode(buffer), buffer.length);
|
|
31915
|
+
if (buffer.includes(0)) return {
|
|
31916
|
+
isBinary: true,
|
|
31917
|
+
reason: "contains null byte"
|
|
31918
|
+
};
|
|
31919
|
+
return checkPrintableRatio(new TextDecoder("utf-8", { fatal: false }).decode(buffer), buffer.length);
|
|
31920
|
+
};
|
|
31921
|
+
REPLACEMENT_CHAR = "�";
|
|
31922
|
+
checkPrintableRatio = (text, sampledBytes) => {
|
|
31923
|
+
if (text.length === 0) return { isBinary: false };
|
|
31924
|
+
let suspect = 0;
|
|
31925
|
+
for (const ch of text) {
|
|
31926
|
+
if (ch === REPLACEMENT_CHAR) {
|
|
31927
|
+
suspect++;
|
|
31928
|
+
continue;
|
|
31929
|
+
}
|
|
31930
|
+
const code = ch.codePointAt(0);
|
|
31931
|
+
if (code < 32 && code !== 9 && code !== 10 && code !== 13) suspect++;
|
|
31932
|
+
}
|
|
31933
|
+
const ratio = suspect / text.length;
|
|
31934
|
+
if (ratio > NON_PRINTABLE_THRESHOLD) return {
|
|
31935
|
+
isBinary: true,
|
|
31936
|
+
reason: `${(ratio * 100).toFixed(1)}% non-printable chars in first ${sampledBytes} bytes`
|
|
31937
|
+
};
|
|
31938
|
+
return { isBinary: false };
|
|
31939
|
+
};
|
|
31940
|
+
}));
|
|
31941
|
+
|
|
31878
31942
|
//#endregion
|
|
31879
31943
|
//#region node_modules/.pnpm/strtok3@10.8.0/node_modules/strtok3/lib/stream/Errors.js
|
|
31880
31944
|
var defaultMessages, EndOfStreamError, AbortError$1;
|
|
@@ -37234,6 +37298,7 @@ var init_file_type = __esmMin((() => {
|
|
|
37234
37298
|
|
|
37235
37299
|
//#endregion
|
|
37236
37300
|
//#region ../../packages/utils/src/mimeType.ts
|
|
37301
|
+
init_isBinaryContent();
|
|
37237
37302
|
const CUSTOM_MIME_TYPES = {
|
|
37238
37303
|
".clj": "text/x-clojure",
|
|
37239
37304
|
".ex": "text/x-elixir",
|
|
@@ -37259,7 +37324,8 @@ const TEXT_FALLBACK_MIME = "text/plain; charset=utf-8";
|
|
|
37259
37324
|
const BINARY_FALLBACK_MIME = "application/octet-stream";
|
|
37260
37325
|
const TEXT_MIME_PATTERN = /^(?:text\/|application\/(?:ecmascript|graphql|javascript|json|toml|xhtml\+xml|xml|yaml))/;
|
|
37261
37326
|
const SVG_MIME = "image/svg+xml";
|
|
37262
|
-
const
|
|
37327
|
+
const DEFAULT_CHARSET = "utf-8";
|
|
37328
|
+
const withCharset = (mimeType, charset = DEFAULT_CHARSET) => TEXT_MIME_PATTERN.test(mimeType) && !mimeType.includes("charset=") ? `${mimeType}; charset=${charset}` : mimeType;
|
|
37263
37329
|
const getExtension = (filePath) => {
|
|
37264
37330
|
const fileName = filePath.replace(/^.*[/\\]/s, "");
|
|
37265
37331
|
const dotIndex = fileName.lastIndexOf(".");
|
|
@@ -37274,6 +37340,32 @@ const looksBinary = (buffer) => {
|
|
|
37274
37340
|
return false;
|
|
37275
37341
|
};
|
|
37276
37342
|
/**
|
|
37343
|
+
* Detect UTF-16 text marked by a byte order mark.
|
|
37344
|
+
*
|
|
37345
|
+
* The UTF-16LE BOM (0xFF 0xFE) is also a valid MPEG audio frame sync, so
|
|
37346
|
+
* file-type reports Windows PowerShell 5.1 output (`Tee-Object`, `Out-File`)
|
|
37347
|
+
* as audio/mpeg. The BOM alone is not proof: a real MPEG-1 Layer I frame can
|
|
37348
|
+
* start with the same bytes. Decode the bytes after the BOM strictly and
|
|
37349
|
+
* require them to read as text: compressed audio contains unpaired surrogates,
|
|
37350
|
+
* and a lenient decode would turn them into "printable" characters. `stream`
|
|
37351
|
+
* keeps a surrogate pair split by the sample boundary from failing the decode.
|
|
37352
|
+
*/
|
|
37353
|
+
const detectUtf16BomText = (buffer) => {
|
|
37354
|
+
if (buffer.byteLength < 2) return null;
|
|
37355
|
+
let charset;
|
|
37356
|
+
if (buffer[0] === 255 && buffer[1] === 254) charset = "utf-16le";
|
|
37357
|
+
else if (buffer[0] === 254 && buffer[1] === 255) charset = "utf-16be";
|
|
37358
|
+
else return null;
|
|
37359
|
+
const sample = buffer.subarray(2, Math.min(buffer.byteLength, SNIFF_BYTES$1));
|
|
37360
|
+
let text;
|
|
37361
|
+
try {
|
|
37362
|
+
text = new TextDecoder(charset, { fatal: true }).decode(sample, { stream: true });
|
|
37363
|
+
} catch {
|
|
37364
|
+
return null;
|
|
37365
|
+
}
|
|
37366
|
+
return sniffBinaryBuffer(new TextEncoder().encode(text)).isBinary ? null : charset;
|
|
37367
|
+
};
|
|
37368
|
+
/**
|
|
37277
37369
|
* Sync extension-only lookup. Falls back to `application/octet-stream` for
|
|
37278
37370
|
* unknown extensions. Use this when a file buffer isn't available (URL input,
|
|
37279
37371
|
* TRPC payload, filename-only records).
|
|
@@ -37289,6 +37381,9 @@ const getMimeType = (filePath) => {
|
|
|
37289
37381
|
* Trust magic bytes first, then fall back to the extension, and let a text
|
|
37290
37382
|
* sniff overrule mime-db when the two disagree.
|
|
37291
37383
|
*
|
|
37384
|
+
* 0. UTF-16 BOM text → text mime with the matching charset, before the
|
|
37385
|
+
* magic-byte check (the UTF-16LE BOM looks like an MPEG audio frame).
|
|
37386
|
+
* Keeps a text extension mime, otherwise falls back to text/plain.
|
|
37292
37387
|
* 1. `fileTypeFromBuffer()` — magic-byte detection. Authoritative when it
|
|
37293
37388
|
* matches: real MPEG-TS media wins here regardless of extension. The one
|
|
37294
37389
|
* exception is a generic `application/xml` match, which yields to the
|
|
@@ -37303,9 +37398,14 @@ const getMimeType = (filePath) => {
|
|
|
37303
37398
|
* 3. No extension mapping → sniff-based fallback.
|
|
37304
37399
|
*/
|
|
37305
37400
|
const resolveMimeType = async (filePath, buffer) => {
|
|
37401
|
+
const fromExtension = lookupExtensionMime(filePath);
|
|
37402
|
+
const utf16Charset = detectUtf16BomText(buffer);
|
|
37403
|
+
if (utf16Charset) {
|
|
37404
|
+
if (fromExtension === SVG_MIME) return SVG_MIME;
|
|
37405
|
+
return fromExtension && TEXT_MIME_PATTERN.test(fromExtension) ? withCharset(fromExtension, utf16Charset) : `text/plain; charset=${utf16Charset}`;
|
|
37406
|
+
}
|
|
37306
37407
|
const { fileTypeFromBuffer } = await Promise.resolve().then(() => (init_file_type(), file_type_exports));
|
|
37307
37408
|
const detected = await fileTypeFromBuffer(buffer);
|
|
37308
|
-
const fromExtension = lookupExtensionMime(filePath);
|
|
37309
37409
|
if (detected?.mime) {
|
|
37310
37410
|
if (detected.mime === "application/xml" && fromExtension === SVG_MIME) return SVG_MIME;
|
|
37311
37411
|
return detected.mime;
|
|
@@ -89706,70 +89806,6 @@ var init_fileParseBudget = __esmMin((() => {
|
|
|
89706
89806
|
isFileParseBudgetError = (error) => error instanceof FileParseBudgetError || error instanceof Error && error.name === "FileParseBudgetError";
|
|
89707
89807
|
}));
|
|
89708
89808
|
|
|
89709
|
-
//#endregion
|
|
89710
|
-
//#region ../../packages/utils/src/detectUtf16.ts
|
|
89711
|
-
var HEURISTIC_SAMPLE_BYTES, HEURISTIC_THRESHOLD, detectUtf16NoBom;
|
|
89712
|
-
var init_detectUtf16 = __esmMin((() => {
|
|
89713
|
-
HEURISTIC_SAMPLE_BYTES = 512;
|
|
89714
|
-
HEURISTIC_THRESHOLD = .3;
|
|
89715
|
-
detectUtf16NoBom = (buffer) => {
|
|
89716
|
-
const sample = buffer.subarray(0, Math.min(HEURISTIC_SAMPLE_BYTES, buffer.length));
|
|
89717
|
-
if (sample.length < 4 || sample.length % 2 !== 0) return null;
|
|
89718
|
-
let leAsciiPairs = 0;
|
|
89719
|
-
let beAsciiPairs = 0;
|
|
89720
|
-
const totalPairs = sample.length / 2;
|
|
89721
|
-
for (let i = 0; i < sample.length; i += 2) {
|
|
89722
|
-
const lo = sample[i];
|
|
89723
|
-
const hi = sample[i + 1];
|
|
89724
|
-
if (hi === 0 && lo !== 0) leAsciiPairs++;
|
|
89725
|
-
else if (lo === 0 && hi !== 0) beAsciiPairs++;
|
|
89726
|
-
}
|
|
89727
|
-
if (leAsciiPairs > beAsciiPairs && leAsciiPairs / totalPairs >= HEURISTIC_THRESHOLD) return "utf-16le";
|
|
89728
|
-
if (beAsciiPairs > leAsciiPairs && beAsciiPairs / totalPairs >= HEURISTIC_THRESHOLD) return "utf-16be";
|
|
89729
|
-
return null;
|
|
89730
|
-
};
|
|
89731
|
-
}));
|
|
89732
|
-
|
|
89733
|
-
//#endregion
|
|
89734
|
-
//#region ../../packages/utils/src/isBinaryContent.ts
|
|
89735
|
-
var NON_PRINTABLE_THRESHOLD, hasUtf8Bom, hasUtf16Bom, sniffBinaryBuffer, REPLACEMENT_CHAR, checkPrintableRatio;
|
|
89736
|
-
var init_isBinaryContent = __esmMin((() => {
|
|
89737
|
-
init_detectUtf16();
|
|
89738
|
-
NON_PRINTABLE_THRESHOLD = .3;
|
|
89739
|
-
hasUtf8Bom = (buf) => buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191;
|
|
89740
|
-
hasUtf16Bom = (buf) => buf.length >= 2 && (buf[0] === 255 && buf[1] === 254 || buf[0] === 254 && buf[1] === 255);
|
|
89741
|
-
sniffBinaryBuffer = (buffer) => {
|
|
89742
|
-
if (buffer.length === 0) return { isBinary: false };
|
|
89743
|
-
if (hasUtf8Bom(buffer) || hasUtf16Bom(buffer)) return { isBinary: false };
|
|
89744
|
-
const utf16Variant = detectUtf16NoBom(buffer);
|
|
89745
|
-
if (utf16Variant) return checkPrintableRatio(new TextDecoder(utf16Variant, { fatal: false }).decode(buffer), buffer.length);
|
|
89746
|
-
if (buffer.includes(0)) return {
|
|
89747
|
-
isBinary: true,
|
|
89748
|
-
reason: "contains null byte"
|
|
89749
|
-
};
|
|
89750
|
-
return checkPrintableRatio(new TextDecoder("utf-8", { fatal: false }).decode(buffer), buffer.length);
|
|
89751
|
-
};
|
|
89752
|
-
REPLACEMENT_CHAR = "�";
|
|
89753
|
-
checkPrintableRatio = (text, sampledBytes) => {
|
|
89754
|
-
if (text.length === 0) return { isBinary: false };
|
|
89755
|
-
let suspect = 0;
|
|
89756
|
-
for (const ch of text) {
|
|
89757
|
-
if (ch === REPLACEMENT_CHAR) {
|
|
89758
|
-
suspect++;
|
|
89759
|
-
continue;
|
|
89760
|
-
}
|
|
89761
|
-
const code = ch.codePointAt(0);
|
|
89762
|
-
if (code < 32 && code !== 9 && code !== 10 && code !== 13) suspect++;
|
|
89763
|
-
}
|
|
89764
|
-
const ratio = suspect / text.length;
|
|
89765
|
-
if (ratio > NON_PRINTABLE_THRESHOLD) return {
|
|
89766
|
-
isBinary: true,
|
|
89767
|
-
reason: `${(ratio * 100).toFixed(1)}% non-printable chars in first ${sampledBytes} bytes`
|
|
89768
|
-
};
|
|
89769
|
-
return { isBinary: false };
|
|
89770
|
-
};
|
|
89771
|
-
}));
|
|
89772
|
-
|
|
89773
89809
|
//#endregion
|
|
89774
89810
|
//#region ../../packages/file-loaders/src/loaders/ipynb/index.ts
|
|
89775
89811
|
var ipynb_exports = /* @__PURE__ */ __exportAll$2({
|
package/man/man1/lh.1
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
|
|
2
2
|
.\" Manual command details come from the Commander command tree.
|
|
3
|
-
.TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.
|
|
3
|
+
.TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.80" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lichao0223/lobehub-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/lichao0223/lobehub",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"access": "public",
|
|
84
84
|
"registry": "https://registry.npmjs.org"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "8bccb477727f96c43528f3649ead68d747c3d99b"
|
|
87
87
|
}
|