@zucker-framework/ext-kit 1.0.0
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/LICENSE +201 -0
- package/NOTICE +22 -0
- package/THIRD_PARTY_NOTICES +4 -0
- package/assets/offscreen.html +5 -0
- package/assets/offscreen.js +32 -0
- package/assets/package.mjs +18 -0
- package/dist/ext-kit-popup.js +525 -0
- package/dist/ext-kit.js +955 -0
- package/dist/index.d.mts +102 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +1818 -0
- package/dist/index.mjs +1781 -0
- package/package.json +52 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
type Settings = Record<string, unknown>;
|
|
2
|
+
interface CaptureContext {
|
|
3
|
+
/** batch = 后台批量新开 tab;quick = 用户当前浏览的 tab(不得改视口、需还原页面状态) */
|
|
4
|
+
mode: 'batch' | 'quick';
|
|
5
|
+
tabId: number;
|
|
6
|
+
url: string;
|
|
7
|
+
options: Settings;
|
|
8
|
+
/** chrome.debugger sendCommand(已 attach) */
|
|
9
|
+
send(method: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
10
|
+
}
|
|
11
|
+
interface CaptureOutput {
|
|
12
|
+
base64: string;
|
|
13
|
+
mime: string;
|
|
14
|
+
/** 文件扩展名,不含点:"png" | "jpg" | "pdf" … */
|
|
15
|
+
extension: string;
|
|
16
|
+
/** 非致命告警(如超高截断),展示在结果列表 */
|
|
17
|
+
warning?: string;
|
|
18
|
+
}
|
|
19
|
+
interface LicensingConfig {
|
|
20
|
+
apiBase: string;
|
|
21
|
+
purchaseUrl: string;
|
|
22
|
+
}
|
|
23
|
+
/** 措辞(capture/convert 等动词差异);不配则用 capture 系默认值 */
|
|
24
|
+
interface ExtTexts {
|
|
25
|
+
alreadyRunning: string;
|
|
26
|
+
cannotQuick: string;
|
|
27
|
+
challengeBeforeQuick: (challenge: string) => string;
|
|
28
|
+
quickFolder: string;
|
|
29
|
+
}
|
|
30
|
+
interface ExtKitConfig {
|
|
31
|
+
/** 消费项目提供的存储 key 命名空间;已发布产品应保持原值,以兼容既有安装 */
|
|
32
|
+
product: string;
|
|
33
|
+
/** 品牌名:下载文件夹前缀、设备名 */
|
|
34
|
+
brand: string;
|
|
35
|
+
/** 消费项目提供的消息类型前缀,用于构造 START 等消息类型 */
|
|
36
|
+
messagePrefix: string;
|
|
37
|
+
freeDailyLimit?: number;
|
|
38
|
+
badgeColor: string;
|
|
39
|
+
defaultSettings: Settings;
|
|
40
|
+
licensing: LicensingConfig;
|
|
41
|
+
texts?: Partial<ExtTexts>;
|
|
42
|
+
/** 仅批量模式、autoScroll 之前调用(如固定视口宽度);quick 模式不调用(不能动用户的 tab) */
|
|
43
|
+
beforeScroll?(ctx: CaptureContext): Promise<void>;
|
|
44
|
+
/** 核心业务:页面已加载、已过验证、已滚动揭示,产出要下载的数据 */
|
|
45
|
+
capture(ctx: CaptureContext): Promise<CaptureOutput>;
|
|
46
|
+
}
|
|
47
|
+
interface PopupTexts {
|
|
48
|
+
startNone: string;
|
|
49
|
+
startSome: (n: number) => string;
|
|
50
|
+
quickIng: string;
|
|
51
|
+
quickFailed: string;
|
|
52
|
+
}
|
|
53
|
+
interface PopupConfig {
|
|
54
|
+
messagePrefix: string;
|
|
55
|
+
/** 消费项目提供的 URL 队列存储 key;已发布产品应保持原值 */
|
|
56
|
+
queueKey: string;
|
|
57
|
+
/** 快速处理当前页的消息类型后缀:CAPTURE_CURRENT / CONVERT_CURRENT */
|
|
58
|
+
quickType: string;
|
|
59
|
+
/** 快速按钮的元素 id,默认 "captureCurrent",可由消费项目覆盖 */
|
|
60
|
+
quickButtonId?: string;
|
|
61
|
+
texts: PopupTexts;
|
|
62
|
+
collectSettings(): Settings;
|
|
63
|
+
collectQuickSettings(): Settings;
|
|
64
|
+
/** 快速处理成功后的状态栏文案 */
|
|
65
|
+
quickResult(result: {
|
|
66
|
+
fileName: string;
|
|
67
|
+
warning?: string;
|
|
68
|
+
}): string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare function initExtension(config: ExtKitConfig): void;
|
|
72
|
+
|
|
73
|
+
declare function initPopup(config: PopupConfig): void;
|
|
74
|
+
|
|
75
|
+
interface Entitlement {
|
|
76
|
+
plan: string;
|
|
77
|
+
expiresAt: string;
|
|
78
|
+
}
|
|
79
|
+
interface Licensing {
|
|
80
|
+
activate(code: string): Promise<unknown>;
|
|
81
|
+
getEntitlement(): Promise<Entitlement | null>;
|
|
82
|
+
isPro(): Promise<boolean>;
|
|
83
|
+
clear(): Promise<void>;
|
|
84
|
+
purchaseUrl: string;
|
|
85
|
+
}
|
|
86
|
+
declare function createLicensing(product: string, brand: string, config: LicensingConfig): Licensing;
|
|
87
|
+
|
|
88
|
+
declare function sanitize(value: string): string;
|
|
89
|
+
declare function hostOf(url: string): string;
|
|
90
|
+
declare function normalizeUrls(urls: unknown[]): string[];
|
|
91
|
+
declare function sessionStamp(): string;
|
|
92
|
+
declare function fileStamp(): string;
|
|
93
|
+
declare function todayString(): string;
|
|
94
|
+
declare function folderNameFor(urls: string[]): string;
|
|
95
|
+
declare function urlBaseName(url: string, maxLength: number, includeQuery: boolean): string;
|
|
96
|
+
declare function buildBatchFileName(folder: string, item: {
|
|
97
|
+
url: string;
|
|
98
|
+
index: number;
|
|
99
|
+
}, extension: string): string;
|
|
100
|
+
declare function buildQuickFileName(brand: string, quickFolder: string, pageUrl: string, extension: string): string;
|
|
101
|
+
|
|
102
|
+
export { type CaptureContext, type CaptureOutput, type Entitlement, type ExtKitConfig, type ExtTexts, type Licensing, type LicensingConfig, type PopupConfig, type PopupTexts, type Settings, buildBatchFileName, buildQuickFileName, createLicensing, fileStamp, folderNameFor, hostOf, initExtension, initPopup, normalizeUrls, sanitize, sessionStamp, todayString, urlBaseName };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
type Settings = Record<string, unknown>;
|
|
2
|
+
interface CaptureContext {
|
|
3
|
+
/** batch = 后台批量新开 tab;quick = 用户当前浏览的 tab(不得改视口、需还原页面状态) */
|
|
4
|
+
mode: 'batch' | 'quick';
|
|
5
|
+
tabId: number;
|
|
6
|
+
url: string;
|
|
7
|
+
options: Settings;
|
|
8
|
+
/** chrome.debugger sendCommand(已 attach) */
|
|
9
|
+
send(method: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
10
|
+
}
|
|
11
|
+
interface CaptureOutput {
|
|
12
|
+
base64: string;
|
|
13
|
+
mime: string;
|
|
14
|
+
/** 文件扩展名,不含点:"png" | "jpg" | "pdf" … */
|
|
15
|
+
extension: string;
|
|
16
|
+
/** 非致命告警(如超高截断),展示在结果列表 */
|
|
17
|
+
warning?: string;
|
|
18
|
+
}
|
|
19
|
+
interface LicensingConfig {
|
|
20
|
+
apiBase: string;
|
|
21
|
+
purchaseUrl: string;
|
|
22
|
+
}
|
|
23
|
+
/** 措辞(capture/convert 等动词差异);不配则用 capture 系默认值 */
|
|
24
|
+
interface ExtTexts {
|
|
25
|
+
alreadyRunning: string;
|
|
26
|
+
cannotQuick: string;
|
|
27
|
+
challengeBeforeQuick: (challenge: string) => string;
|
|
28
|
+
quickFolder: string;
|
|
29
|
+
}
|
|
30
|
+
interface ExtKitConfig {
|
|
31
|
+
/** 消费项目提供的存储 key 命名空间;已发布产品应保持原值,以兼容既有安装 */
|
|
32
|
+
product: string;
|
|
33
|
+
/** 品牌名:下载文件夹前缀、设备名 */
|
|
34
|
+
brand: string;
|
|
35
|
+
/** 消费项目提供的消息类型前缀,用于构造 START 等消息类型 */
|
|
36
|
+
messagePrefix: string;
|
|
37
|
+
freeDailyLimit?: number;
|
|
38
|
+
badgeColor: string;
|
|
39
|
+
defaultSettings: Settings;
|
|
40
|
+
licensing: LicensingConfig;
|
|
41
|
+
texts?: Partial<ExtTexts>;
|
|
42
|
+
/** 仅批量模式、autoScroll 之前调用(如固定视口宽度);quick 模式不调用(不能动用户的 tab) */
|
|
43
|
+
beforeScroll?(ctx: CaptureContext): Promise<void>;
|
|
44
|
+
/** 核心业务:页面已加载、已过验证、已滚动揭示,产出要下载的数据 */
|
|
45
|
+
capture(ctx: CaptureContext): Promise<CaptureOutput>;
|
|
46
|
+
}
|
|
47
|
+
interface PopupTexts {
|
|
48
|
+
startNone: string;
|
|
49
|
+
startSome: (n: number) => string;
|
|
50
|
+
quickIng: string;
|
|
51
|
+
quickFailed: string;
|
|
52
|
+
}
|
|
53
|
+
interface PopupConfig {
|
|
54
|
+
messagePrefix: string;
|
|
55
|
+
/** 消费项目提供的 URL 队列存储 key;已发布产品应保持原值 */
|
|
56
|
+
queueKey: string;
|
|
57
|
+
/** 快速处理当前页的消息类型后缀:CAPTURE_CURRENT / CONVERT_CURRENT */
|
|
58
|
+
quickType: string;
|
|
59
|
+
/** 快速按钮的元素 id,默认 "captureCurrent",可由消费项目覆盖 */
|
|
60
|
+
quickButtonId?: string;
|
|
61
|
+
texts: PopupTexts;
|
|
62
|
+
collectSettings(): Settings;
|
|
63
|
+
collectQuickSettings(): Settings;
|
|
64
|
+
/** 快速处理成功后的状态栏文案 */
|
|
65
|
+
quickResult(result: {
|
|
66
|
+
fileName: string;
|
|
67
|
+
warning?: string;
|
|
68
|
+
}): string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare function initExtension(config: ExtKitConfig): void;
|
|
72
|
+
|
|
73
|
+
declare function initPopup(config: PopupConfig): void;
|
|
74
|
+
|
|
75
|
+
interface Entitlement {
|
|
76
|
+
plan: string;
|
|
77
|
+
expiresAt: string;
|
|
78
|
+
}
|
|
79
|
+
interface Licensing {
|
|
80
|
+
activate(code: string): Promise<unknown>;
|
|
81
|
+
getEntitlement(): Promise<Entitlement | null>;
|
|
82
|
+
isPro(): Promise<boolean>;
|
|
83
|
+
clear(): Promise<void>;
|
|
84
|
+
purchaseUrl: string;
|
|
85
|
+
}
|
|
86
|
+
declare function createLicensing(product: string, brand: string, config: LicensingConfig): Licensing;
|
|
87
|
+
|
|
88
|
+
declare function sanitize(value: string): string;
|
|
89
|
+
declare function hostOf(url: string): string;
|
|
90
|
+
declare function normalizeUrls(urls: unknown[]): string[];
|
|
91
|
+
declare function sessionStamp(): string;
|
|
92
|
+
declare function fileStamp(): string;
|
|
93
|
+
declare function todayString(): string;
|
|
94
|
+
declare function folderNameFor(urls: string[]): string;
|
|
95
|
+
declare function urlBaseName(url: string, maxLength: number, includeQuery: boolean): string;
|
|
96
|
+
declare function buildBatchFileName(folder: string, item: {
|
|
97
|
+
url: string;
|
|
98
|
+
index: number;
|
|
99
|
+
}, extension: string): string;
|
|
100
|
+
declare function buildQuickFileName(brand: string, quickFolder: string, pageUrl: string, extension: string): string;
|
|
101
|
+
|
|
102
|
+
export { type CaptureContext, type CaptureOutput, type Entitlement, type ExtKitConfig, type ExtTexts, type Licensing, type LicensingConfig, type PopupConfig, type PopupTexts, type Settings, buildBatchFileName, buildQuickFileName, createLicensing, fileStamp, folderNameFor, hostOf, initExtension, initPopup, normalizeUrls, sanitize, sessionStamp, todayString, urlBaseName };
|