@skrillex1224/chrome-article-publish-extension 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.
@@ -0,0 +1,140 @@
1
+ import { P as PlatformMeta, R as RuntimeInterface, A as AuthResult, a as Article, b as PublishEventHandler, S as SyncResult, c as PublishStatusRef, d as PublishStatusResult } from './interface-BlLeWXzS.js';
2
+
3
+ /**
4
+ * 输出格式类型
5
+ */
6
+ type OutputFormat = 'html' | 'markdown';
7
+ /**
8
+ * 预处理配置
9
+ * 每个平台在 adapter 中定义自己需要的预处理选项
10
+ * Content Script 根据这些配置在发送到 Service Worker 前进行预处理
11
+ */
12
+ interface PreprocessConfig {
13
+ /** 输出格式: html 或 markdown */
14
+ outputFormat: OutputFormat;
15
+ /** 移除链接标签,保留文字 */
16
+ removeLinks?: boolean;
17
+ /** 保留的链接域名 */
18
+ keepLinkDomains?: string[];
19
+ /** 移除 iframe */
20
+ removeIframes?: boolean;
21
+ /** 移除 HTML 注释 */
22
+ removeComments?: boolean;
23
+ /** 移除微信特殊标签 (mpprofile, qqmusic 等) */
24
+ removeSpecialTags?: boolean;
25
+ /** 移除特殊标签时同时移除其父元素(知乎等需要) */
26
+ removeSpecialTagsWithParent?: boolean;
27
+ /** 移除 SVG 占位图片 */
28
+ removeSvgImages?: boolean;
29
+ /** 处理代码块 */
30
+ processCodeBlocks?: boolean;
31
+ /** 处理懒加载图片 (data-src → src) */
32
+ processLazyImages?: boolean;
33
+ /** 移除空元素 (空 p, div, section 等) */
34
+ removeEmptyElements?: boolean;
35
+ /** 移除没有有效 src 的 img 标签(src 为空或缺失) */
36
+ removeEmptyImages?: boolean;
37
+ /** 移除 data-* 属性 */
38
+ removeDataAttributes?: boolean;
39
+ /** 移除 srcset 属性 */
40
+ removeSrcset?: boolean;
41
+ /** 移除 sizes 属性 */
42
+ removeSizes?: boolean;
43
+ /** 将 section 转换为 div */
44
+ convertSectionToDiv?: boolean;
45
+ /** 将 section 转换为 p */
46
+ convertSectionToP?: boolean;
47
+ /** 移除段落尾部的 br 标签 */
48
+ removeTrailingBr?: boolean;
49
+ /** 解包单一子元素容器 */
50
+ unwrapSingleChildContainers?: boolean;
51
+ /** 解包只含单个子 span 的 span(减少过深嵌套) */
52
+ unwrapSingleChildSpans?: boolean;
53
+ /** 解包嵌套的 figure 标签 */
54
+ unwrapNestedFigures?: boolean;
55
+ /** 展平嵌套的 b/strong 标签(移除内层,保留内容) */
56
+ flattenNestedBold?: boolean;
57
+ /** 压缩 HTML(移除标签间空白) */
58
+ compactHtml?: boolean;
59
+ /** 将表格转换为文本(用 | 分隔列,适用于不支持表格的平台) */
60
+ convertTablesToText?: boolean;
61
+ /** 保留 <style> 标签(CLI 同步自定义 HTML 时使用) */
62
+ keepStyles?: boolean;
63
+ /** 移除空行(只含 br 或空白的段落) */
64
+ removeEmptyLines?: boolean;
65
+ /** 移除空 div(只含 br 或空白,但保留含图片的) */
66
+ removeEmptyDivs?: boolean;
67
+ /** 移除嵌套的空容器 */
68
+ removeNestedEmptyContainers?: boolean;
69
+ }
70
+ /**
71
+ * 默认预处理配置
72
+ */
73
+ declare const DEFAULT_PREPROCESS_CONFIG: PreprocessConfig;
74
+ /**
75
+ * 图片上传进度回调
76
+ */
77
+ type ImageProgressCallback = (current: number, total: number) => void;
78
+ /**
79
+ * 发布选项
80
+ */
81
+ interface PublishOptions {
82
+ /** 图片上传进度回调 */
83
+ onImageProgress?: ImageProgressCallback;
84
+ /** 发布过程事件:扫码、验证码、进度 */
85
+ onEvent?: PublishEventHandler;
86
+ }
87
+ /**
88
+ * 平台适配器接口
89
+ */
90
+ interface PlatformAdapter {
91
+ /** 平台元信息 */
92
+ readonly meta: PlatformMeta;
93
+ /** 预处理配置 (Content Script 根据此配置预处理内容) */
94
+ readonly preprocessConfig?: Partial<PreprocessConfig>;
95
+ /** 初始化适配器 */
96
+ init(runtime: RuntimeInterface): Promise<void>;
97
+ /** 检查认证状态 */
98
+ checkAuth(): Promise<AuthResult>;
99
+ /** 发布文章 */
100
+ publish(article: Article, options?: PublishOptions): Promise<SyncResult>;
101
+ /** 查询文章状态 */
102
+ getStatus?(statusRef: PublishStatusRef): Promise<PublishStatusResult>;
103
+ /** 上传图片 (如果支持) */
104
+ uploadImage?(file: Blob, filename?: string): Promise<string>;
105
+ /** 获取分类列表 (如果支持) */
106
+ getCategories?(): Promise<Category[]>;
107
+ /** 获取草稿列表 (如果支持) */
108
+ getDrafts?(): Promise<Draft[]>;
109
+ /** 更新文章 (如果支持) */
110
+ update?(postId: string, article: Article): Promise<SyncResult>;
111
+ /** 删除文章 (如果支持) */
112
+ delete?(postId: string): Promise<void>;
113
+ }
114
+ /**
115
+ * 分类
116
+ */
117
+ interface Category {
118
+ id: string;
119
+ name: string;
120
+ parentId?: string;
121
+ }
122
+ /**
123
+ * 草稿
124
+ */
125
+ interface Draft {
126
+ id: string;
127
+ title: string;
128
+ updatedAt: number;
129
+ }
130
+ /**
131
+ * 适配器注册项
132
+ */
133
+ interface AdapterRegistryEntry {
134
+ meta: PlatformMeta;
135
+ factory: (runtime: RuntimeInterface) => PlatformAdapter;
136
+ /** 预处理配置 (Content Script 根据此配置预处理内容) */
137
+ preprocessConfig?: Partial<PreprocessConfig>;
138
+ }
139
+
140
+ export { type AdapterRegistryEntry as A, type Category as C, DEFAULT_PREPROCESS_CONFIG as D, type ImageProgressCallback as I, type OutputFormat as O, type PlatformAdapter as P, type PublishOptions as a, type PreprocessConfig as b, type Draft as c };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@skrillex1224/chrome-article-publish-extension",
3
+ "version": "1.0.0",
4
+ "description": "Chrome-extension runtime article publishing adapters for Chinese content platforms.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "pnpm build:npm",
20
+ "build:npm": "tsup && node scripts/copy-runtime-assets.mjs",
21
+ "build:extension": "BUILD_TARGET=extension tsup && node scripts/copy-runtime-assets.mjs && node scripts/copy-extension-assets.mjs",
22
+ "check:baijiahao-cover": "pnpm build:npm && node scripts/check-baijiahao-cover-payload.mjs",
23
+ "check:bilibili-opus": "pnpm build:npm && node scripts/check-bilibili-opus-content.mjs && pnpm build:extension",
24
+ "check:csdn-status": "pnpm build:npm && node scripts/check-csdn-status.mjs",
25
+ "check:csdn-image": "pnpm build:npm && node scripts/check-csdn-image-payload.mjs",
26
+ "check:cnblogs-status": "pnpm build:npm && node scripts/check-cnblogs-status.mjs",
27
+ "check:douyin-status": "pnpm build:npm && node scripts/check-douyin-status.mjs",
28
+ "check:juejin-status": "pnpm build:npm && node scripts/check-juejin-status.mjs",
29
+ "check:netease-content": "pnpm build:npm && node scripts/check-netease-content-normalization.mjs",
30
+ "check:public-api": "pnpm build:npm && node scripts/check-public-api.mjs",
31
+ "e2e:check-auth": "node scripts/e2e-check-auth.mjs",
32
+ "zip:extension": "pnpm build:extension && rm -f chrome-article-publish-extension-1.0.0.zip && cd dist && zip -qr ../chrome-article-publish-extension-1.0.0.zip .",
33
+ "prepack": "pnpm build:npm",
34
+ "prepublishOnly": "pnpm build:npm",
35
+ "typecheck": "tsc --noEmit"
36
+ },
37
+ "dependencies": {
38
+ "html2canvas": "^1.4.1",
39
+ "js-md5": "^0.8.3",
40
+ "jszip": "^3.10.1",
41
+ "markdown-draft-js": "^2.4.0",
42
+ "marked": "^17.0.1",
43
+ "remarkable": "^2.0.1",
44
+ "turndown": "^7.2.2"
45
+ },
46
+ "devDependencies": {
47
+ "@types/chrome": "^0.0.254",
48
+ "@types/remarkable": "^2.0.8",
49
+ "@types/turndown": "^5.0.6",
50
+ "tsup": "^8.0.1",
51
+ "@types/js-md5": "^0.8.0",
52
+ "typescript": "^5.0.0"
53
+ }
54
+ }