dozy 1.0.76 → 1.0.77
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/chunk-PHGHC5BP.js +2 -0
- package/dist/index.d.ts +402 -2
- package/dist/index.js +24 -15
- package/dist/index.js.map +1 -1
- package/dist/zod.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-7Q6CTFBS.js +0 -2
- /package/dist/{chunk-7Q6CTFBS.js.map → chunk-PHGHC5BP.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var g=a=>{throw TypeError(a)};var n=(a,b,c)=>b in a?f(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c;var p=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var q=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),r=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0})},o=(a,b,c,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let e of k(b))!m.call(a,e)&&e!==c&&f(a,e,{get:()=>b[e],enumerable:!(d=j(b,e))||d.enumerable});return a};var s=(a,b,c)=>(c=a!=null?i(l(a)):{},o(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));var t=(a,b,c)=>n(a,typeof b!="symbol"?b+"":b,c),h=(a,b,c)=>b.has(a)||g("Cannot "+c);var u=(a,b,c)=>(h(a,b,"read from private field"),c?c.call(a):b.get(a)),v=(a,b,c)=>b.has(a)?g("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),w=(a,b,c,d)=>(h(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);export{p as a,q as b,r as c,s as d,t as e,u as f,v as g,w as h};
|
|
2
|
+
//# sourceMappingURL=chunk-PHGHC5BP.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Options } from 'browser-image-compression';
|
|
2
2
|
export * from 'browser-image-compression';
|
|
3
3
|
export { default as imageCompression } from 'browser-image-compression';
|
|
4
|
+
import { Octokit } from '@octokit/core';
|
|
4
5
|
import { Color } from 'culori';
|
|
5
6
|
import * as culori from 'culori';
|
|
6
7
|
export { culori as ColorLib };
|
|
@@ -885,6 +886,405 @@ declare class StringObfuscator {
|
|
|
885
886
|
de(obfuscated: string): string;
|
|
886
887
|
}
|
|
887
888
|
|
|
889
|
+
/**
|
|
890
|
+
* StoreRepo - GitHub 仓库内容存储类
|
|
891
|
+
*
|
|
892
|
+
* 基于 Octokit 实现的 GitHub 仓库文件操作类,支持文件的增删改查、JSON 序列化存储、
|
|
893
|
+
* 目录列表等功能。所有操作都通过 GitHub REST API v3 的 Contents API 完成。
|
|
894
|
+
*
|
|
895
|
+
* @remarks
|
|
896
|
+
* - 支持自动处理 Base64 编码/解码(GitHub API 要求文件内容使用 Base64 编码)
|
|
897
|
+
* - 内置冲突重试机制(HTTP 409 冲突时自动重试)
|
|
898
|
+
* - 提供原始模式和文本模式的切换(raw 参数)
|
|
899
|
+
* - 可通过重写 `_prind` 和 `path` 方法实现自定义处理(如加密、路径映射等)
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```typescript
|
|
903
|
+
* const repo = new StoreRepo('github-token', 'username', 'repo-name')
|
|
904
|
+
*
|
|
905
|
+
* // 存储 JSON 数据
|
|
906
|
+
* await repo.putJson('data/config.json', { key: 'value' })
|
|
907
|
+
*
|
|
908
|
+
* // 读取 JSON 数据
|
|
909
|
+
* const data = await repo.getJson('data/config.json')
|
|
910
|
+
*
|
|
911
|
+
* // 列出目录
|
|
912
|
+
* const files = await repo.list('data')
|
|
913
|
+
* ```
|
|
914
|
+
*/
|
|
915
|
+
declare class StoreRepo {
|
|
916
|
+
/**
|
|
917
|
+
* Octokit 实例,用于与 GitHub API 交互
|
|
918
|
+
* @internal
|
|
919
|
+
*/
|
|
920
|
+
ware: Octokit;
|
|
921
|
+
/**
|
|
922
|
+
* 仓库所有者(用户名或组织名)
|
|
923
|
+
*/
|
|
924
|
+
owner: string;
|
|
925
|
+
/**
|
|
926
|
+
* 仓库名称
|
|
927
|
+
*/
|
|
928
|
+
repo: string;
|
|
929
|
+
/**
|
|
930
|
+
* HTTP 请求头配置
|
|
931
|
+
* @property {'""'} ['If-None-Match'] - 设置为空字符串以禁用 ETag 缓存,确保获取最新内容
|
|
932
|
+
* @property {string} ['Cache-Control'] - 可选,用于禁用缓存(当前已注释)
|
|
933
|
+
*/
|
|
934
|
+
headers: {
|
|
935
|
+
'If-None-Match': string;
|
|
936
|
+
};
|
|
937
|
+
/**
|
|
938
|
+
* 内容预处理方法(可重写)
|
|
939
|
+
*
|
|
940
|
+
* 在内容被编码存储前或解码读取后调用,用于对内容进行自定义处理(如加密/解密、压缩/解压等)。
|
|
941
|
+
* 这是一个钩子方法,子类可以重写以实现特定的内容转换逻辑。
|
|
942
|
+
*
|
|
943
|
+
* @param content - 要处理的内容字符串
|
|
944
|
+
* @param en - 处理方向:`true` 表示编码(存储前),`false` 表示解码(读取后)
|
|
945
|
+
* @returns 处理后的内容字符串
|
|
946
|
+
*
|
|
947
|
+
* @remarks
|
|
948
|
+
* - 默认实现直接返回原内容,不做任何处理
|
|
949
|
+
* - 当 `en=true` 时,在 Base64 编码之前调用
|
|
950
|
+
* - 当 `en=false` 时,在 Base64 解码之后调用
|
|
951
|
+
*
|
|
952
|
+
* @example
|
|
953
|
+
* ```typescript
|
|
954
|
+
* class EncryptedStoreRepo extends StoreRepo {
|
|
955
|
+
* _prind(content: string, en: boolean) {
|
|
956
|
+
* return en ? encrypt(content) : decrypt(content)
|
|
957
|
+
* }
|
|
958
|
+
* }
|
|
959
|
+
* ```
|
|
960
|
+
*/
|
|
961
|
+
_prind(content: string, en: boolean): string;
|
|
962
|
+
/**
|
|
963
|
+
* 路径处理方法(可重写)
|
|
964
|
+
*
|
|
965
|
+
* 在每次操作路径之前调用,用于对路径进行自定义转换(如添加前缀、路径映射等)。
|
|
966
|
+
* 这是一个钩子方法,子类可以重写以实现特定的路径处理逻辑。
|
|
967
|
+
*
|
|
968
|
+
* @param path - 原始路径
|
|
969
|
+
* @returns 处理后的路径
|
|
970
|
+
*
|
|
971
|
+
* @remarks
|
|
972
|
+
* - 默认实现直接返回原路径,不做任何处理
|
|
973
|
+
* - 所有公开方法(get、put、del、det、list 等)都会先调用此方法处理路径
|
|
974
|
+
*
|
|
975
|
+
* @example
|
|
976
|
+
* ```typescript
|
|
977
|
+
* class PrefixedStoreRepo extends StoreRepo {
|
|
978
|
+
* path(path: string) {
|
|
979
|
+
* return `data/${path}`
|
|
980
|
+
* }
|
|
981
|
+
* }
|
|
982
|
+
* ```
|
|
983
|
+
*/
|
|
984
|
+
path(path: string): string;
|
|
985
|
+
/**
|
|
986
|
+
* 检测文件或目录是否存在
|
|
987
|
+
*
|
|
988
|
+
* @param path - 要检测的文件或目录路径(相对于仓库根目录)
|
|
989
|
+
* @returns `true` 表示存在,`false` 表示不存在(HTTP 404)
|
|
990
|
+
*
|
|
991
|
+
* @throws {Error} 当遇到非 404 错误时抛出异常(如权限不足、API 限流等)
|
|
992
|
+
*
|
|
993
|
+
* @remarks
|
|
994
|
+
* - 使用 GitHub API 的 GET contents 端点进行检测
|
|
995
|
+
* - 仅对 HTTP 404 错误返回 false,其他错误会向上抛出
|
|
996
|
+
* - 会自动应用 `path()` 方法处理路径
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* if (await repo.det('config.json')) {
|
|
1001
|
+
* console.log('文件存在')
|
|
1002
|
+
* } else {
|
|
1003
|
+
* console.log('文件不存在')
|
|
1004
|
+
* }
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
det(path: string): Promise<boolean>;
|
|
1008
|
+
/**
|
|
1009
|
+
* 获取文件或目录内容
|
|
1010
|
+
*
|
|
1011
|
+
* @param path - 文件或目录路径(相对于仓库根目录)
|
|
1012
|
+
* @param raw - 原始模式标志
|
|
1013
|
+
* - `false`(默认):自动解码 Base64 内容,返回文本字符串或二进制数据
|
|
1014
|
+
* - `true`:返回 GitHub API 响应的原始 Base64 编码内容
|
|
1015
|
+
* @returns
|
|
1016
|
+
* - 当 `raw=true`:返回 Base64 编码的字符串
|
|
1017
|
+
* - 当 `raw=false` 且内容是文本:返回解码后的 Unicode 字符串(会经过 `_prind` 处理)
|
|
1018
|
+
* - 当 `raw=false` 且内容是二进制:返回 `ArrayBuffer`
|
|
1019
|
+
* - 当 `data.content` 为空时:返回完整的 API 响应数据(可能是目录列表或文件元数据)
|
|
1020
|
+
*
|
|
1021
|
+
* @throws {Error} 当 GitHub API 请求失败时抛出异常(如文件不存在、权限不足等)
|
|
1022
|
+
*
|
|
1023
|
+
* @remarks
|
|
1024
|
+
* - 文本内容会尝试使用 `$decodeBase64ToUnicode` 解码,失败则使用 `$decodeBase64ToBinary` 解码
|
|
1025
|
+
* - 返回目录列表时,`data.content` 为空,此时返回原始响应数据
|
|
1026
|
+
* - 会自动应用 `path()` 方法处理路径
|
|
1027
|
+
* - 解码后的文本会经过 `_prind(content, false)` 处理
|
|
1028
|
+
*
|
|
1029
|
+
* @see https://docs.github.com/en/rest/repos/contents
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```typescript
|
|
1033
|
+
* // 获取文本文件
|
|
1034
|
+
* const text = await repo.get('README.md')
|
|
1035
|
+
* console.log(text) // 解码后的文本字符串
|
|
1036
|
+
*
|
|
1037
|
+
* // 获取目录列表(返回原始数据)
|
|
1038
|
+
* const dirData = await repo.get('src')
|
|
1039
|
+
* console.log(dirData) // 数组,包含目录下的文件信息
|
|
1040
|
+
*
|
|
1041
|
+
* // 获取原始 Base64 内容
|
|
1042
|
+
* const base64 = await repo.get('image.png', true)
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
get(path: string, raw?: boolean): Promise<any>;
|
|
1046
|
+
/**
|
|
1047
|
+
* 生成提交信息(commit message)
|
|
1048
|
+
*
|
|
1049
|
+
* @returns 格式化的日期时间字符串,用作 Git 提交信息
|
|
1050
|
+
*
|
|
1051
|
+
* @remarks
|
|
1052
|
+
* - 使用 `$formatDate` 格式化当前时间
|
|
1053
|
+
* - 每次调用都会生成新的时间戳
|
|
1054
|
+
* - 可以通过重写此方法自定义提交信息格式
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* ```typescript
|
|
1058
|
+
* class CustomMsgStoreRepo extends StoreRepo {
|
|
1059
|
+
* msg() {
|
|
1060
|
+
* return `Update at ${new Date().toISOString()}`
|
|
1061
|
+
* }
|
|
1062
|
+
* }
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1065
|
+
msg(): string;
|
|
1066
|
+
/**
|
|
1067
|
+
* 创建或更新文件内容
|
|
1068
|
+
*
|
|
1069
|
+
* @param path - 文件路径(相对于仓库根目录)
|
|
1070
|
+
* @param content - 要存储的内容(字符串)
|
|
1071
|
+
* @param raw - 原始模式标志
|
|
1072
|
+
* - `false`(默认):将内容视为文本,经过 `_prind` 处理后 Base64 编码再存储
|
|
1073
|
+
* - `true`:假定 content 已经是 Base64 编码,直接存储(跳过编码步骤)
|
|
1074
|
+
* @returns 无返回值
|
|
1075
|
+
*
|
|
1076
|
+
* @throws {Error} 当遇到非 409 错误时抛出异常(如权限不足、API 限流等)
|
|
1077
|
+
*
|
|
1078
|
+
* @remarks
|
|
1079
|
+
* - **冲突处理**:当遇到 HTTP 409(冲突)错误时,会自动重试一次(递归调用自身)
|
|
1080
|
+
* - **SHA 处理**:如果文件已存在,会自动获取其 SHA 值用于 API 调用(GitHub API 要求提供 SHA 以更新文件)
|
|
1081
|
+
* - **编码流程**:非 raw 模式下,内容会先经过 `_prind(content, true)` 处理,然后 Base64 编码
|
|
1082
|
+
* - **空文件检测**:使用 `det()` 方法检查文件是否存在,不存在时 sha 为 undefined(创建新文件)
|
|
1083
|
+
* - 会自动应用 `path()` 方法处理路径
|
|
1084
|
+
*
|
|
1085
|
+
* @see https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```typescript
|
|
1089
|
+
* // 存储文本文件
|
|
1090
|
+
* await repo.put('hello.txt', 'Hello, World!')
|
|
1091
|
+
*
|
|
1092
|
+
* // 存储 JSON(推荐用 putJson)
|
|
1093
|
+
* await repo.put('data.json', JSON.stringify({ a: 1 }))
|
|
1094
|
+
*
|
|
1095
|
+
* // 存储原始 Base64 内容
|
|
1096
|
+
* const base64 = btoa('binary data')
|
|
1097
|
+
* await repo.put('data.bin', base64, true)
|
|
1098
|
+
* ```
|
|
1099
|
+
*/
|
|
1100
|
+
put(path: string, content: string, raw?: boolean): Promise<void>;
|
|
1101
|
+
/**
|
|
1102
|
+
* 删除文件或目录
|
|
1103
|
+
*
|
|
1104
|
+
* @param path - 要删除的文件或目录路径(相对于仓库根目录)
|
|
1105
|
+
* @returns 无返回值
|
|
1106
|
+
*
|
|
1107
|
+
* @throws {Error} 当遇到非 409 错误时抛出异常(如权限不足、API 限流等)
|
|
1108
|
+
*
|
|
1109
|
+
* @remarks
|
|
1110
|
+
* - **幂等性**:如果文件不存在(通过 `det()` 检测),方法会直接返回,不会报错
|
|
1111
|
+
* - **冲突处理**:当遇到 HTTP 409(冲突)错误时,会自动重试一次(递归调用自身)
|
|
1112
|
+
* - **SHA 要求**:GitHub API 删除文件需要提供文件的 SHA 值,此方法会自动获取
|
|
1113
|
+
* - **目录删除**:GitHub API 不支持直接删除目录,需要递归删除目录下的所有文件
|
|
1114
|
+
* - 会自动应用 `path()` 方法处理路径
|
|
1115
|
+
*
|
|
1116
|
+
* @see https://docs.github.com/en/rest/repos/contents#delete-a-file
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
* ```typescript
|
|
1120
|
+
* // 删除文件
|
|
1121
|
+
* await repo.del('old-file.txt')
|
|
1122
|
+
*
|
|
1123
|
+
* // 删除不存在的文件(不会报错)
|
|
1124
|
+
* await repo.del('non-existent.txt')
|
|
1125
|
+
* ```
|
|
1126
|
+
*/
|
|
1127
|
+
del(path: string): Promise<void>;
|
|
1128
|
+
/**
|
|
1129
|
+
* 安全获取 JSON 数据(忽略 404 错误)
|
|
1130
|
+
*
|
|
1131
|
+
* 与 `getJson` 类似,但当文件不存在(HTTP 404)时不会抛出异常,而是返回 undefined。
|
|
1132
|
+
* 适用于不确定文件是否存在的场景。
|
|
1133
|
+
*
|
|
1134
|
+
* @param path - JSON 文件路径(相对于仓库根目录)
|
|
1135
|
+
* @returns
|
|
1136
|
+
* - 解析后的 JSON 对象(成功时)
|
|
1137
|
+
* - `undefined`(当文件不存在,即 HTTP 404 时)
|
|
1138
|
+
*
|
|
1139
|
+
* @throws {Error} 当遇到非 404 错误时抛出异常(如权限不足、JSON 解析错误等)
|
|
1140
|
+
*
|
|
1141
|
+
* @remarks
|
|
1142
|
+
* - 仅在 HTTP 状态码为 404 时静默失败,其他错误会正常抛出
|
|
1143
|
+
* - 内部调用 `getJson` 方法,因此会经过 Base64 解码和 `_prind` 处理
|
|
1144
|
+
*
|
|
1145
|
+
* @example
|
|
1146
|
+
* ```typescript
|
|
1147
|
+
* // 安全读取,文件可能不存在
|
|
1148
|
+
* const config = await repo.c_getJson('config.json')
|
|
1149
|
+
* if (config) {
|
|
1150
|
+
* console.log('配置已加载', config)
|
|
1151
|
+
* } else {
|
|
1152
|
+
* console.log('配置文件不存在,使用默认配置')
|
|
1153
|
+
* }
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
c_getJson(path: string): Promise<any>;
|
|
1157
|
+
/**
|
|
1158
|
+
* 获取并解析 JSON 数据
|
|
1159
|
+
*
|
|
1160
|
+
* 从仓库读取文件内容,并使用 `$jsonParse` 解析为 JSON 对象。
|
|
1161
|
+
*
|
|
1162
|
+
* @param path - JSON 文件路径(相对于仓库根目录)
|
|
1163
|
+
* @returns 解析后的 JSON 对象(类型由调用者指定)
|
|
1164
|
+
*
|
|
1165
|
+
* @throws {Error} 当文件不存在、读取失败或 JSON 解析失败时抛出异常
|
|
1166
|
+
*
|
|
1167
|
+
* @remarks
|
|
1168
|
+
* - 内部调用 `get()` 方法获取内容,因此会经过 Base64 解码和 `_prind` 处理
|
|
1169
|
+
* - 使用 `$jsonParse` 进行解析(可能包含自定义的 JSON 解析逻辑,如日期恢复等)
|
|
1170
|
+
* - 如果文件内容不是有效的 JSON,会抛出异常
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* interface Config {
|
|
1175
|
+
* theme: string
|
|
1176
|
+
* version: number
|
|
1177
|
+
* }
|
|
1178
|
+
*
|
|
1179
|
+
* const config = await repo.getJson<Config>('config.json')
|
|
1180
|
+
* console.log(config.theme)
|
|
1181
|
+
* ```
|
|
1182
|
+
*/
|
|
1183
|
+
getJson(path: string): Promise<any>;
|
|
1184
|
+
/**
|
|
1185
|
+
* 将对象序列化为 JSON 并存储到仓库
|
|
1186
|
+
*
|
|
1187
|
+
* 使用 `$jsonStringify` 将对象序列化为 JSON 字符串,然后调用 `put` 方法存储。
|
|
1188
|
+
* 这是存储结构化数据(对象、数组等)的便捷方法。
|
|
1189
|
+
*
|
|
1190
|
+
* @param path - 目标文件路径(相对于仓库根目录)
|
|
1191
|
+
* @param content - 要存储的对象(会被序列化为 JSON)
|
|
1192
|
+
* @returns `put` 方法的返回值
|
|
1193
|
+
*
|
|
1194
|
+
* @throws {Error} 当序列化失败或存储失败时抛出异常
|
|
1195
|
+
*
|
|
1196
|
+
* @remarks
|
|
1197
|
+
* - 使用 `$jsonStringify` 进行序列化(可能包含自定义的 JSON 序列化逻辑,如日期处理等)
|
|
1198
|
+
* - 默认以文本模式存储(非 raw),会经过 Base64 编码
|
|
1199
|
+
* - 推荐使用此方法而非手动 `JSON.stringify` + `put`,以保持序列化逻辑一致
|
|
1200
|
+
*
|
|
1201
|
+
* @example
|
|
1202
|
+
* ```typescript
|
|
1203
|
+
* // 存储对象
|
|
1204
|
+
* await repo.putJson('user.json', {
|
|
1205
|
+
* name: 'Alice',
|
|
1206
|
+
* age: 30,
|
|
1207
|
+
* tags: ['developer', 'designer']
|
|
1208
|
+
* })
|
|
1209
|
+
*
|
|
1210
|
+
* // 读取回来
|
|
1211
|
+
* const user = await repo.getJson('user.json')
|
|
1212
|
+
* ```
|
|
1213
|
+
*/
|
|
1214
|
+
putJson(path: string, content: Object): Promise<void>;
|
|
1215
|
+
/**
|
|
1216
|
+
* 列出目录下的文件和子目录
|
|
1217
|
+
*
|
|
1218
|
+
* 获取指定路径的内容列表,返回精简的文件信息数组。
|
|
1219
|
+
*
|
|
1220
|
+
* @param path - 目录路径(相对于仓库根目录)
|
|
1221
|
+
* @returns
|
|
1222
|
+
* - 成功时:包含文件信息的数组,每个元素包含 `name`、`path`、`type` 属性
|
|
1223
|
+
* - 如果路径不是目录或获取失败:返回 `undefined`
|
|
1224
|
+
*
|
|
1225
|
+
* @throws {Error} 当 GitHub API 请求失败时抛出异常
|
|
1226
|
+
*
|
|
1227
|
+
* @remarks
|
|
1228
|
+
* - 返回的 `type` 字段可能是 `'file'`、`'dir'` 或 `'symlink'`
|
|
1229
|
+
* - 返回的 `path` 是文件的完整路径(相对于仓库根目录)
|
|
1230
|
+
* - 如果路径指向文件而非目录,GitHub API 返回的不是数组,此时方法返回 undefined
|
|
1231
|
+
* - 会自动应用 `path()` 方法处理路径
|
|
1232
|
+
*
|
|
1233
|
+
* @see https://docs.github.com/en/rest/repos/contents#get-contents
|
|
1234
|
+
*
|
|
1235
|
+
* @example
|
|
1236
|
+
* ```typescript
|
|
1237
|
+
* // 列出目录内容
|
|
1238
|
+
* const files = await repo.list('src')
|
|
1239
|
+
* if (files) {
|
|
1240
|
+
* for (const file of files) {
|
|
1241
|
+
* console.log(`${file.type}: ${file.name} (${file.path})`)
|
|
1242
|
+
* }
|
|
1243
|
+
* }
|
|
1244
|
+
*
|
|
1245
|
+
* // 过滤只显示文件
|
|
1246
|
+
* const onlyFiles = files?.filter(f => f.type === 'file')
|
|
1247
|
+
* ```
|
|
1248
|
+
*/
|
|
1249
|
+
list(path: string): Promise<{
|
|
1250
|
+
name: any;
|
|
1251
|
+
path: any;
|
|
1252
|
+
type: any;
|
|
1253
|
+
}[] | undefined>;
|
|
1254
|
+
/**
|
|
1255
|
+
* 创建 StoreRepo 实例
|
|
1256
|
+
*
|
|
1257
|
+
* @param x0 - GitHub Personal Access Token(个人访问令牌)
|
|
1258
|
+
* - 需要具有对目标仓库的读写权限
|
|
1259
|
+
* - 可在 https://github.com/settings/tokens 创建
|
|
1260
|
+
* @param user - 仓库所有者(用户名或组织名)
|
|
1261
|
+
* @param repo - 仓库名称
|
|
1262
|
+
*
|
|
1263
|
+
* @remarks
|
|
1264
|
+
* - 初始化时会创建 Octokit 实例,用于后续的 API 调用
|
|
1265
|
+
* - Token 会通过 `auth` 配置传递给 Octokit
|
|
1266
|
+
* - 确保 Token 具有 `repo` 或 `contents:write` 权限
|
|
1267
|
+
*
|
|
1268
|
+
* @example
|
|
1269
|
+
* ```typescript
|
|
1270
|
+
* // 基本用法
|
|
1271
|
+
* const repo = new StoreRepo(
|
|
1272
|
+
* 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // GitHub Token
|
|
1273
|
+
* 'myusername', // 所有者
|
|
1274
|
+
* 'my-repo' // 仓库名
|
|
1275
|
+
* )
|
|
1276
|
+
*
|
|
1277
|
+
* // 组织仓库
|
|
1278
|
+
* const orgRepo = new StoreRepo(
|
|
1279
|
+
* process.env.GITHUB_TOKEN,
|
|
1280
|
+
* 'my-organization',
|
|
1281
|
+
* 'org-repo'
|
|
1282
|
+
* )
|
|
1283
|
+
* ```
|
|
1284
|
+
*/
|
|
1285
|
+
constructor(x0: string, user: string, repo: string);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
888
1288
|
declare function $escapeHTML(str: string): string;
|
|
889
1289
|
declare class RainbowGen {
|
|
890
1290
|
i: number;
|
|
@@ -977,6 +1377,6 @@ declare function toRgbString(input: string | Color | any): string | undefined;
|
|
|
977
1377
|
*/
|
|
978
1378
|
declare function toHslString(input: string | Color | any): string | undefined;
|
|
979
1379
|
|
|
980
|
-
declare const DOZY = "1.0.
|
|
1380
|
+
declare const DOZY = "1.0.77";
|
|
981
1381
|
|
|
982
|
-
export { $Headers, $Request, $Response, $URL, $URLSearchParams, $arrayFrom, $arrayIsArray, $assign, $backgroundColor, $borderColor, $capitalize, $checkValidEmailWithUnicode, $clamp, $clearInterval, $clearTimeout, $clone, $compressImage, $compressImageBase64, $compressImageDefaultOptions, $copy, $crypto, $date, $decodeBase64ToBinary, $decodeBase64ToUnicode, $deepClone, $defineProperty, $document, $encodeUnicodeToBase64, $entries, $escapeHTML, $fallbackCopy, $fetch, $fileToBase64, $formatDate, $formatPoints, $formatPointsWithChange, $formatWithCommas, $freeze, $genSSF, $getFileType, $getHue, $getTimeString, $hasKey, $if, $inRange, $inRange2, $inferMimeTypeFormPureBase64, $is, $isObject, $isPlainClass, $isValidEmailWithUnicode, $isValidOrBriefURL, $jsonParse, $jsonStringify, $keys, $lastIndex, $lindex, $loadOpt, $location, $log, $lplus, $magic, $math, $now, $numberIsFinite, $numberIsNaN, $oc, $open, $parseParams, $promise, $pureText, $purifyBase64, $randomByte, $replaceHolesWithUndefined, $rmvSlash, $rsValue, $rsetValue, $rvalue, $s, $sc, $setInterval, $setRange, $setTimeout, $stringFromCharCode, $stringFromCodePoint, $stringToRange, $strings, $toDataUrlFromBase64, $validName, $values, $window, type Any, type Atoa, type Coord, type Coord3, DOZY, type DozyConfig, type DozyConfigItem, type FileType, Gens, type Hel, type IOpt, type Items, type Null, type Nullable, RainbowGen, type ScaleComputer, type ScaleIniter, StringObfuscator, type UNumber, __GensDirectives, _res, boxShadow, dozy, enableScaler, err403, errArg, errCode, errContent, errMsg, errNotLoggedIn, errToString, getBrightness, getColorMap, isNowAroundUtcHour, isNull, isValidColor, maybeString, registerCustomColor, s, shanghaiDateFormatter, smallChance, smartParse, smartString, standardIniter, textShadow, toHexString, toHslString, toRgbString, toRgbaArray, web$enableHttpsRedirect, web$enableProdProtector, web$encodeURI, web$pathStartData, web$redirectToDomain, web$setPathTarget, xtrim };
|
|
1382
|
+
export { $Headers, $Request, $Response, $URL, $URLSearchParams, $arrayFrom, $arrayIsArray, $assign, $backgroundColor, $borderColor, $capitalize, $checkValidEmailWithUnicode, $clamp, $clearInterval, $clearTimeout, $clone, $compressImage, $compressImageBase64, $compressImageDefaultOptions, $copy, $crypto, $date, $decodeBase64ToBinary, $decodeBase64ToUnicode, $deepClone, $defineProperty, $document, $encodeUnicodeToBase64, $entries, $escapeHTML, $fallbackCopy, $fetch, $fileToBase64, $formatDate, $formatPoints, $formatPointsWithChange, $formatWithCommas, $freeze, $genSSF, $getFileType, $getHue, $getTimeString, $hasKey, $if, $inRange, $inRange2, $inferMimeTypeFormPureBase64, $is, $isObject, $isPlainClass, $isValidEmailWithUnicode, $isValidOrBriefURL, $jsonParse, $jsonStringify, $keys, $lastIndex, $lindex, $loadOpt, $location, $log, $lplus, $magic, $math, $now, $numberIsFinite, $numberIsNaN, $oc, $open, $parseParams, $promise, $pureText, $purifyBase64, $randomByte, $replaceHolesWithUndefined, $rmvSlash, $rsValue, $rsetValue, $rvalue, $s, $sc, $setInterval, $setRange, $setTimeout, $stringFromCharCode, $stringFromCodePoint, $stringToRange, $strings, $toDataUrlFromBase64, $validName, $values, $window, type Any, type Atoa, type Coord, type Coord3, DOZY, type DozyConfig, type DozyConfigItem, type FileType, Gens, type Hel, type IOpt, type Items, type Null, type Nullable, RainbowGen, type ScaleComputer, type ScaleIniter, StoreRepo, StringObfuscator, type UNumber, __GensDirectives, _res, boxShadow, dozy, enableScaler, err403, errArg, errCode, errContent, errMsg, errNotLoggedIn, errToString, getBrightness, getColorMap, isNowAroundUtcHour, isNull, isValidColor, maybeString, registerCustomColor, s, shanghaiDateFormatter, smallChance, smartParse, smartString, standardIniter, textShadow, toHexString, toHslString, toRgbString, toRgbaArray, web$enableHttpsRedirect, web$enableProdProtector, web$encodeURI, web$pathStartData, web$redirectToDomain, web$setPathTarget, xtrim };
|