@sudajs/cli 0.8.2 → 0.9.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/dist/index.d.ts +72 -2
- package/dist/index.js +238 -242
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/templates/theme/AGENTS.md +2 -1
- package/templates/theme/README.md +11 -2
- package/templates/theme/src/manifest.ts +2 -2
- package/templates/theme/src/sections.tsx +1 -1
- package/templates/theme/src/templates.ts +1 -1
- /package/templates/theme/{src/assets → assets/brand}/suda-logo.svg +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ interface ValidatedTheme {
|
|
|
13
13
|
clientEntryPath: string | null;
|
|
14
14
|
stylesheetPath: string | null;
|
|
15
15
|
}
|
|
16
|
+
interface ThemeRootOptions {
|
|
17
|
+
themeRoot?: string | undefined;
|
|
18
|
+
}
|
|
16
19
|
interface CliAuthContext {
|
|
17
20
|
baseUrl: string;
|
|
18
21
|
token: string;
|
|
@@ -92,13 +95,17 @@ declare function buildTheme(root: string): Promise<ValidatedTheme>;
|
|
|
92
95
|
declare function finalizeTheme(root: string): Promise<ValidatedTheme>;
|
|
93
96
|
declare function findAnchorTagByHref(html: string, href: string): string | null;
|
|
94
97
|
declare const __testUtils: {
|
|
98
|
+
createThemeProjectRequire: typeof createThemeProjectRequire;
|
|
95
99
|
createRemotePageDraft: typeof createRemotePageDraft;
|
|
96
100
|
findAnchorTagByHref: typeof findAnchorTagByHref;
|
|
97
101
|
loadThemeScopedRenderer: typeof loadThemeScopedRenderer;
|
|
102
|
+
normalizePlaywrightModule: typeof normalizePlaywrightModule;
|
|
103
|
+
normalizeSharpModule: typeof normalizeSharpModule;
|
|
98
104
|
initThemeWithKey: typeof initThemeWithKey;
|
|
99
105
|
performActivateTheme: typeof performActivateTheme;
|
|
100
106
|
performConfirmedPageOperation: typeof performConfirmedPageOperation;
|
|
101
107
|
renderDevStarterPageHtml: typeof renderDevStarterPageHtml;
|
|
108
|
+
resolveScreenshotOptions: typeof resolveScreenshotOptions;
|
|
102
109
|
slugifyThemeName: typeof slugifyThemeName;
|
|
103
110
|
validateThemeKey: typeof validateThemeKey;
|
|
104
111
|
validateThemeName: typeof validateThemeName;
|
|
@@ -109,8 +116,8 @@ declare function watchTheme(root: string, port: number): Promise<void>;
|
|
|
109
116
|
/**
|
|
110
117
|
* Theme-project-scoped renderer bundle. We deliberately resolve `react`,
|
|
111
118
|
* `react-dom/server` and `@sudajs/theme-engine/server` through the theme
|
|
112
|
-
* project's own `require` graph instead of the CLI's, because the theme
|
|
113
|
-
* `dist/index.js` was already loaded against that copy of React. Importing
|
|
119
|
+
* project's own `require` graph instead of the CLI's, because the theme's
|
|
120
|
+
* local `dist/index.js` was already loaded against that copy of React. Importing
|
|
114
121
|
* a different React instance from the CLI side would yield two React
|
|
115
122
|
* dispatchers; client components inside the theme would call hooks against
|
|
116
123
|
* the CLI's React (whose dispatcher is `null` outside a render), producing
|
|
@@ -125,6 +132,69 @@ interface ThemeRenderer {
|
|
|
125
132
|
}
|
|
126
133
|
declare function loadThemeScopedRenderer(themeRoot: string): Promise<ThemeRenderer>;
|
|
127
134
|
declare function renderDevStarterPageHtml(theme: ValidatedTheme, page: ThemeStarterPage, renderer: ThemeRenderer): string;
|
|
135
|
+
interface ScreenshotOptions extends ThemeRootOptions {
|
|
136
|
+
device?: string[] | string;
|
|
137
|
+
output?: string;
|
|
138
|
+
width?: string;
|
|
139
|
+
height?: string;
|
|
140
|
+
port?: string;
|
|
141
|
+
fullPage?: boolean;
|
|
142
|
+
}
|
|
143
|
+
interface ResolvedScreenshotOptions {
|
|
144
|
+
targets: ScreenshotTarget[];
|
|
145
|
+
port: number;
|
|
146
|
+
fullPage: boolean;
|
|
147
|
+
}
|
|
148
|
+
declare const SCREENSHOT_DEVICES: readonly ["desktop", "tablet", "mobile"];
|
|
149
|
+
type ScreenshotDevice = (typeof SCREENSHOT_DEVICES)[number];
|
|
150
|
+
interface ScreenshotTarget {
|
|
151
|
+
device: ScreenshotDevice;
|
|
152
|
+
outputPath: string;
|
|
153
|
+
viewport: {
|
|
154
|
+
width: number;
|
|
155
|
+
height: number;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
declare function resolveScreenshotOptions(root: string, options: ScreenshotOptions): ResolvedScreenshotOptions;
|
|
159
|
+
interface PlaywrightModule {
|
|
160
|
+
chromium: {
|
|
161
|
+
launch: (options?: {
|
|
162
|
+
headless?: boolean;
|
|
163
|
+
}) => Promise<{
|
|
164
|
+
newContext: (options: {
|
|
165
|
+
viewport: {
|
|
166
|
+
width: number;
|
|
167
|
+
height: number;
|
|
168
|
+
};
|
|
169
|
+
deviceScaleFactor?: number;
|
|
170
|
+
}) => Promise<{
|
|
171
|
+
newPage: () => Promise<{
|
|
172
|
+
goto: (url: string, options?: {
|
|
173
|
+
waitUntil?: string;
|
|
174
|
+
}) => Promise<unknown>;
|
|
175
|
+
screenshot: (options: {
|
|
176
|
+
path: string;
|
|
177
|
+
fullPage?: boolean;
|
|
178
|
+
}) => Promise<unknown>;
|
|
179
|
+
close: () => Promise<void>;
|
|
180
|
+
}>;
|
|
181
|
+
close: () => Promise<void>;
|
|
182
|
+
}>;
|
|
183
|
+
close: () => Promise<void>;
|
|
184
|
+
}>;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
type SharpOptimizer = (input: string) => {
|
|
188
|
+
png: (options?: {
|
|
189
|
+
compressionLevel?: number;
|
|
190
|
+
palette?: boolean;
|
|
191
|
+
}) => {
|
|
192
|
+
toBuffer: () => Promise<Buffer>;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
declare function createThemeProjectRequire(themeRoot: string): NodeJS.Require;
|
|
196
|
+
declare function normalizePlaywrightModule(moduleValue: unknown): PlaywrightModule | null;
|
|
197
|
+
declare function normalizeSharpModule(moduleValue: unknown): SharpOptimizer | null;
|
|
128
198
|
/**
|
|
129
199
|
* 解析人机交互的 `key@version` 格式。允许仅 `key`,也允许带 version。
|
|
130
200
|
* 注意:theme key 现行约束不含 `@`,所以从右侧第一个 `@` 之后视为 version。
|