html-to-gutenberg 4.2.9 → 4.2.10
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/.env.example +20 -3
- package/.github/workflows/sync-npm.yml +154 -0
- package/fetch-page-assets.test.ts +448 -0
- package/index.d.ts +173 -0
- package/index.js +570 -224
- package/index.test.ts +633 -4
- package/index.ts +168 -63
- package/package.json +25 -24
- package/r2.js +163 -0
- package/readme.md +122 -88
- package/scripts/patch-fetch-page-assets.mjs +13 -0
- package/scripts/sync-from-npm.mjs +115 -0
- package/tsconfig.json +17 -2
- package/vendor/fetch-page-assets/LICENSE.MD +21 -0
- package/vendor/fetch-page-assets/README.md +117 -0
- package/vendor/fetch-page-assets/index.js +362 -0
- package/vendor/fetch-page-assets/package.json +48 -0
- package/.env +0 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export type GeneratedFiles = Record<string, string>;
|
|
2
|
+
|
|
3
|
+
export type JobOutputFile = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
size: number;
|
|
8
|
+
path: string;
|
|
9
|
+
url: string;
|
|
10
|
+
kind: 'source' | 'asset' | 'bundle';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type JobBundle = {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
size: number;
|
|
18
|
+
path: string;
|
|
19
|
+
url: string;
|
|
20
|
+
zipUrl: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type JobManifest = {
|
|
24
|
+
jobId: string;
|
|
25
|
+
status: 'completed';
|
|
26
|
+
output: {
|
|
27
|
+
files: JobOutputFile[];
|
|
28
|
+
bundle: JobBundle;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type BlockOptions = {
|
|
33
|
+
title?: string;
|
|
34
|
+
slug?: string;
|
|
35
|
+
baseUrl?: string | null;
|
|
36
|
+
namespace?: string;
|
|
37
|
+
category?: string;
|
|
38
|
+
registerCategoryIfMissing?: boolean;
|
|
39
|
+
outputPath?: string;
|
|
40
|
+
writeFiles?: boolean;
|
|
41
|
+
generatePreviewImage?: boolean;
|
|
42
|
+
jsFiles?: string[];
|
|
43
|
+
cssFiles?: string[];
|
|
44
|
+
outputMode?: 'job' | 'legacy';
|
|
45
|
+
uploadToR2?: boolean;
|
|
46
|
+
jobId?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
prefix?: string;
|
|
49
|
+
source?: string | null;
|
|
50
|
+
basePath?: string;
|
|
51
|
+
shouldSaveFiles?: boolean;
|
|
52
|
+
generateIconPreview?: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type NormalizedBlockOptions = {
|
|
56
|
+
title: string;
|
|
57
|
+
name: string;
|
|
58
|
+
slug: string;
|
|
59
|
+
namespace: string;
|
|
60
|
+
prefix: string;
|
|
61
|
+
baseUrl: string | null;
|
|
62
|
+
source: string | null;
|
|
63
|
+
category: string;
|
|
64
|
+
registerCategoryIfMissing: boolean;
|
|
65
|
+
outputPath: string;
|
|
66
|
+
basePath: string;
|
|
67
|
+
writeFiles: boolean;
|
|
68
|
+
shouldSaveFiles: boolean;
|
|
69
|
+
generatePreviewImage: boolean;
|
|
70
|
+
generateIconPreview: boolean;
|
|
71
|
+
jsFiles: string[];
|
|
72
|
+
cssFiles: string[];
|
|
73
|
+
outputMode: 'job' | 'legacy';
|
|
74
|
+
uploadToR2: boolean;
|
|
75
|
+
jobId?: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export declare const createProfiler: (enabled: boolean) => {
|
|
79
|
+
start(label: string): void;
|
|
80
|
+
end(label: string): void;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export declare const findSelfClosingJsxEnd: (
|
|
84
|
+
content: string,
|
|
85
|
+
startIndex: number
|
|
86
|
+
) => number;
|
|
87
|
+
|
|
88
|
+
export declare const replaceSelfClosingJsxComponent: (
|
|
89
|
+
content: string,
|
|
90
|
+
componentName: string,
|
|
91
|
+
replacer: (componentSource: string) => string
|
|
92
|
+
) => string;
|
|
93
|
+
|
|
94
|
+
export declare const getMediaUploadSaveTemplate: (
|
|
95
|
+
image?: {
|
|
96
|
+
randomUrlVariable: string;
|
|
97
|
+
randomAltVariable: string;
|
|
98
|
+
imgClass?: string;
|
|
99
|
+
}
|
|
100
|
+
) => string;
|
|
101
|
+
|
|
102
|
+
export declare const replaceMediaUploadComponents: (
|
|
103
|
+
content: string,
|
|
104
|
+
imageRegistry: Array<{
|
|
105
|
+
randomUrlVariable: string;
|
|
106
|
+
randomAltVariable: string;
|
|
107
|
+
imgClass?: string;
|
|
108
|
+
}>
|
|
109
|
+
) => string;
|
|
110
|
+
|
|
111
|
+
export declare const replaceRichTextComponents: (content: string) => string;
|
|
112
|
+
|
|
113
|
+
export declare const buildAssetExtractionOptions: (
|
|
114
|
+
basePath: string,
|
|
115
|
+
options?: {
|
|
116
|
+
uploadToR2?: boolean;
|
|
117
|
+
returnDetails?: boolean;
|
|
118
|
+
jobId?: string;
|
|
119
|
+
r2Prefix?: string;
|
|
120
|
+
}
|
|
121
|
+
) => {
|
|
122
|
+
basePath: string;
|
|
123
|
+
saveFile: false;
|
|
124
|
+
verbose: false;
|
|
125
|
+
maxRetryAttempts: 1;
|
|
126
|
+
retryDelay: 0;
|
|
127
|
+
concurrency: 8;
|
|
128
|
+
uploadToR2: boolean;
|
|
129
|
+
returnDetails: boolean;
|
|
130
|
+
jobId?: string;
|
|
131
|
+
r2Prefix?: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export declare const slugifyBlockValue: (value?: string) => string;
|
|
135
|
+
export declare const formatCategoryLabel: (category?: string) => string;
|
|
136
|
+
export declare const normalizeBlockOptions: (
|
|
137
|
+
options?: BlockOptions
|
|
138
|
+
) => NormalizedBlockOptions;
|
|
139
|
+
|
|
140
|
+
export declare const replaceRelativeUrls: (
|
|
141
|
+
html: string,
|
|
142
|
+
replacer: (url: string) => string
|
|
143
|
+
) => string;
|
|
144
|
+
|
|
145
|
+
export declare const replaceRelativeUrlsInCss: (
|
|
146
|
+
css: string,
|
|
147
|
+
replacer: (url: string) => string
|
|
148
|
+
) => string;
|
|
149
|
+
|
|
150
|
+
export declare const replaceRelativeUrlsInHtml: (
|
|
151
|
+
html: string,
|
|
152
|
+
baseUrl: string
|
|
153
|
+
) => string;
|
|
154
|
+
|
|
155
|
+
export declare const replaceRelativeUrlsInCssWithBase: (
|
|
156
|
+
css: string,
|
|
157
|
+
cssFileUrl: string
|
|
158
|
+
) => string;
|
|
159
|
+
|
|
160
|
+
export declare const unwrapBody: (code: string) => string;
|
|
161
|
+
|
|
162
|
+
export declare const transformBlockFile: (
|
|
163
|
+
blockCode: string
|
|
164
|
+
) => { code?: string } | string;
|
|
165
|
+
|
|
166
|
+
export declare const getSnapApiUrl: () => string;
|
|
167
|
+
|
|
168
|
+
declare const block: (
|
|
169
|
+
htmlContent: string,
|
|
170
|
+
options?: BlockOptions
|
|
171
|
+
) => Promise<GeneratedFiles | JobManifest>;
|
|
172
|
+
|
|
173
|
+
export default block;
|