@tbox.cn/app-build 0.0.0-stage → 1.0.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) tbox
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # @tbox.cn/app-build
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ tbox-app 1.0 构建期叶子包。负责:
4
+
5
+ - 扫描 `apps/client`、`apps/server` 与 `modules/<id>/`;
6
+ - 生成 `apps/client/.tbox-gen/{manifest.json,registry.*,entries,documents}`;
7
+ - 提供 Vite 插件;
8
+ - `checkApp` 结构检查。
9
+
10
+ 不依赖 `@tbox.cn/app-toolkit`。
11
+
12
+ ## API
13
+
14
+ ```ts
15
+ import { generateApp, checkApp, tboxAppPlugin, tboxModuleSourcesPlugin } from '@tbox.cn/app-build';
16
+ ```
17
+
18
+ Tailwind 模块源码发现与产物兼容门禁走独立子路径(Node ESM 可直接 import,供模板脚本与证据包使用):
19
+
20
+ ```ts
21
+ import { collectModuleSourceDirs, renderModuleSources } from '@tbox.cn/app-build/tailwind-sources';
22
+ import { checkCss, checkDist, formatBaseline, parseBaseline } from '@tbox.cn/app-build/compat';
23
+ ```
24
+
25
+ `compat` 是矩阵基线(`{ safari, chrome }`)+ AND 判定 + 兜底后能力(先剥 `@supports` 再判);
26
+ 缺产物即失败(fail-closed)。
27
+
28
+ ```ts
29
+ await generateApp({ root: process.cwd(), watch: true });
30
+ ```
31
+
32
+ 生成物是 disposable IR;不要手改。manifest 只含 `schemaVersion` 与 `pages`。
package/compat.d.mts ADDED
@@ -0,0 +1,60 @@
1
+ export interface CompatEngines {
2
+ safari?: number;
3
+ chrome?: number;
4
+ [engine: string]: number | undefined;
5
+ }
6
+
7
+ export interface CompatFinding {
8
+ /** checkDist 会补 `assets/<file>`。 */
9
+ file?: string;
10
+ feature: string;
11
+ message: string;
12
+ fix: string;
13
+ sample: string;
14
+ requires: Record<string, number>;
15
+ }
16
+
17
+ export interface CompatCheckResult {
18
+ ok: boolean;
19
+ engines: Record<string, number>;
20
+ errors: string[];
21
+ findings: CompatFinding[];
22
+ }
23
+
24
+ export interface CompatDistResult extends CompatCheckResult {
25
+ files: string[];
26
+ totalBytes: number;
27
+ }
28
+
29
+ export interface CompatFeature {
30
+ id: string;
31
+ pattern: RegExp;
32
+ requires: CompatEngines;
33
+ message: string;
34
+ fix: string;
35
+ }
36
+
37
+ /** 模板缺省基线:Safari 16.4(Tailwind v4 下限)与 Chromium 105(支付宝 MYWeb 内核)。 */
38
+ export const DEFAULT_BASELINE: Readonly<{ safari: number; chrome: number }>;
39
+
40
+ export const FEATURES: ReadonlyArray<CompatFeature>;
41
+
42
+ export function parseBaseline(input: unknown): {
43
+ engines: Record<string, number>;
44
+ raw: unknown;
45
+ errors: string[];
46
+ };
47
+
48
+ /** 剥掉全部 `@supports (...) { ... }` 条件块(含嵌套)。 */
49
+ export function stripConditionalBlocks(css: string): string;
50
+
51
+ export function checkCss(css: string, options?: { baseline?: unknown }): CompatCheckResult;
52
+
53
+ export function formatBaseline(baseline: unknown): string;
54
+
55
+ /** 读 `apps/client/dist/assets/*.css` 并判定;缺产物即失败(fail-closed)。 */
56
+ export function checkDist(options: {
57
+ appDir: string;
58
+ baseline?: unknown;
59
+ assetsDir?: string;
60
+ }): CompatDistResult;
package/compat.mjs ADDED
@@ -0,0 +1,259 @@
1
+ /**
2
+ * compat — Tailwind 产物兼容门禁内核(多引擎矩阵 + 兜底后能力判定)。
3
+ *
4
+ * 与 `tailwind-sources` 同型:手写 ESM + .d.mts,随包发布,模板与根级守卫共用一份实现。
5
+ *
6
+ * 判定模型(两条,缺一不可):
7
+ * 1. **矩阵基线**:基线是 `{ safari, chrome }` 而不是单引擎字符串。只在单引擎上通过不算通过——
8
+ * 产品同时跑 iOS 与安卓 webview,任一声明引擎不满足即为越线。
9
+ * 2. **兜底后能力**:先剥掉 `@supports` 条件块,再检查无条件生效的声明。条件块内是渐进增强,
10
+ * 不构成硬要求(Tailwind/Lightning 会给 `color-mix`、`dvh`、`@property` 生成这种块)。
11
+ *
12
+ * 构建期不做 CSS 降级:Tailwind v4/Lightning 不读 Vite 的 `cssTarget`(实测产物仍含
13
+ * `padding-inline` / `translate:` / `@property`),所以基线**只由产物门禁执行**;
14
+ * 输出等价性由门禁 + 真机冒烟保证,不靠构建目标换算。
15
+ *
16
+ * 刻意不作为硬失败的特性:
17
+ * - `@property`:旧引擎忽略该 at-rule,自定义属性仍生效,只失去类型与初始值;产物自带兜底块。
18
+ * - 媒体查询范围语法:压缩产物已被重写为 `min-width`,源码层检查无意义。
19
+ * - flex `gap`:无法从文本可靠判定(同为 gap 的 grid 支持面不同),交给真机冒烟。
20
+ */
21
+
22
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
23
+ import path from 'node:path';
24
+
25
+ /** 模板缺省基线:Tailwind v4 官方下限(Safari 16.4)与支付宝 MYWeb 内核(Chromium 105)的并集。 */
26
+ export const DEFAULT_BASELINE = Object.freeze({ safari: 16.4, chrome: 105 });
27
+
28
+ /** 特性表:requires 为该引擎的最低版本;缺键 = 该引擎无要求。 */
29
+ export const FEATURES = Object.freeze([
30
+ {
31
+ id: 'cascade-layers',
32
+ pattern: /@layer\b/,
33
+ requires: { safari: 15.4, chrome: 99 },
34
+ message: '级联层不被支持:整层规则被丢弃',
35
+ fix: '用 @csstools/postcss-cascade-layers 展平产物,或提高基线',
36
+ },
37
+ {
38
+ id: 'independent-transform',
39
+ pattern: /(?:^|[;{])\s*(?:translate|scale|rotate)\s*:/m,
40
+ requires: { safari: 14.1, chrome: 104 },
41
+ message: '独立变换属性(translate/scale/rotate)不生效',
42
+ fix: '改用 transform 简写,或提高基线',
43
+ },
44
+ {
45
+ id: 'logical-properties',
46
+ pattern: /(?:padding|margin|inset)-(?:inline|block)/,
47
+ requires: { safari: 14.1, chrome: 87 },
48
+ message: '逻辑属性不被支持:间距/定位丢失',
49
+ fix: '改用物理属性,或提高基线',
50
+ },
51
+ {
52
+ id: 'where-selector',
53
+ pattern: /:where\(/,
54
+ requires: { safari: 14, chrome: 88 },
55
+ message: ':where() 不被支持:整条规则被丢弃',
56
+ fix: '改用类选择器,或提高基线',
57
+ },
58
+ {
59
+ id: 'color-mix',
60
+ pattern: /color-mix\(/,
61
+ requires: { safari: 16.2, chrome: 111 },
62
+ message: 'color-mix() 无效:颜色声明在计算值阶段失效',
63
+ fix: '给该声明补无条件的静态回退色(@supports 块内的用法不计)',
64
+ },
65
+ {
66
+ id: 'oklch',
67
+ pattern: /\boklch\(/,
68
+ requires: { safari: 15.4, chrome: 111 },
69
+ message: 'oklch() 无效:颜色不生效',
70
+ fix: '清空默认调色板或改用 rgb/rgba',
71
+ },
72
+ {
73
+ id: 'dvh-unit',
74
+ pattern: /[0-9.]+(?:dvh|svh|lvh)\b/,
75
+ requires: { safari: 15.4, chrome: 108 },
76
+ message: '动态视口单位(dvh/svh/lvh)不被支持:尺寸声明失效',
77
+ fix: '写 vh 回退 + supports-[height:100dvh]: 渐进增强',
78
+ },
79
+ {
80
+ id: 'container-query',
81
+ pattern: /@container\b/,
82
+ requires: { safari: 16, chrome: 105 },
83
+ message: '容器查询不被支持:容器内的响应式规则整块失效',
84
+ fix: '改用视口断点,或提高基线',
85
+ },
86
+ {
87
+ id: 'aspect-ratio',
88
+ pattern: /(?:^|[;{])\s*aspect-ratio\s*:/m,
89
+ requires: { safari: 15, chrome: 88 },
90
+ message: 'aspect-ratio 不被支持:比例盒高度丢失',
91
+ fix: '改用 padding-top 比例盒,或提高基线',
92
+ },
93
+ ]);
94
+
95
+ const ENGINE_KEYS = Object.freeze(['safari', 'chrome']);
96
+
97
+ /**
98
+ * 解析基线。接受矩阵对象或 `"safari 16.4, chrome 105"` 字符串(兼容历史单引擎写法)。
99
+ * @param {unknown} input
100
+ * @returns {{ engines: Record<string, number>, raw: unknown, errors: string[] }}
101
+ */
102
+ export function parseBaseline(input) {
103
+ /** @type {Record<string, number>} */
104
+ const engines = {};
105
+ const errors = [];
106
+ if (input === undefined || input === null) {
107
+ return { engines, raw: input, errors: ['缺少基线(package.json 的 tbox.compat.baseline)'] };
108
+ }
109
+ if (typeof input === 'object') {
110
+ for (const [key, value] of Object.entries(input)) {
111
+ const name = String(key).toLowerCase();
112
+ if (!ENGINE_KEYS.includes(name)) {
113
+ errors.push(`未知引擎 ${key}(只支持 ${ENGINE_KEYS.join(' / ')})`);
114
+ continue;
115
+ }
116
+ const version = Number(value);
117
+ if (!Number.isFinite(version) || version <= 0) {
118
+ errors.push(`${key} 的版本不是正数:${String(value)}`);
119
+ continue;
120
+ }
121
+ engines[name] = version;
122
+ }
123
+ } else if (typeof input === 'string') {
124
+ for (const part of input.split(/[,,;;]/)) {
125
+ const match = /^\s*(safari|chrome)\s+([\d.]+)\s*$/i.exec(part);
126
+ if (!match) {
127
+ if (part.trim()) errors.push(`无法解析基线片段:${part.trim()}`);
128
+ continue;
129
+ }
130
+ engines[match[1].toLowerCase()] = Number(match[2]);
131
+ }
132
+ } else {
133
+ return { engines, raw: input, errors: [`基线类型不支持:${typeof input}`] };
134
+ }
135
+ for (const engine of ENGINE_KEYS) {
136
+ if (engines[engine] === undefined) errors.push(`基线缺少 ${engine}(矩阵基线必须同时声明 safari 与 chrome)`);
137
+ }
138
+ return { engines, raw: input, errors };
139
+ }
140
+
141
+ /**
142
+ * 剥掉所有 `@supports (...) { ... }` 条件块(含嵌套)。条件块内是渐进增强,不构成硬要求。
143
+ * @param {string} css
144
+ * @returns {string}
145
+ */
146
+ export function stripConditionalBlocks(css) {
147
+ let out = css;
148
+ for (;;) {
149
+ const match = /@supports[^{]*\{/.exec(out);
150
+ if (!match) return out;
151
+ const start = match.index;
152
+ let depth = 1;
153
+ let index = start + match[0].length;
154
+ while (index < out.length && depth > 0) {
155
+ const char = out[index];
156
+ if (char === '{') depth += 1;
157
+ else if (char === '}') depth -= 1;
158
+ index += 1;
159
+ }
160
+ out = out.slice(0, start) + out.slice(index);
161
+ }
162
+ }
163
+
164
+ /**
165
+ * 单引擎是否满足特性要求(缺 requires 键视为满足)。
166
+ * @param {number} version
167
+ * @param {number | undefined} required
168
+ */
169
+ function engineSatisfies(version, required) {
170
+ if (required === undefined) return true;
171
+ return version >= required;
172
+ }
173
+
174
+ /**
175
+ * 判定一份 CSS 文本是否在基线内。
176
+ * @param {string} css
177
+ * @param {{ baseline?: unknown }} [options]
178
+ * @returns {{
179
+ * ok: boolean,
180
+ * engines: Record<string, number>,
181
+ * errors: string[],
182
+ * findings: Array<{ feature: string, message: string, fix: string, sample: string, requires: Record<string, number> }>,
183
+ * }}
184
+ */
185
+ export function checkCss(css, options = {}) {
186
+ const parsed = parseBaseline(options.baseline ?? DEFAULT_BASELINE);
187
+ const errors = [...parsed.errors];
188
+ if (errors.length > 0) {
189
+ return { ok: false, engines: parsed.engines, errors, findings: [] };
190
+ }
191
+ const unconditional = stripConditionalBlocks(css);
192
+ const findings = [];
193
+ for (const feature of FEATURES) {
194
+ const supported = Object.entries(parsed.engines).every(([engine, version]) =>
195
+ engineSatisfies(version, feature.requires[engine]),
196
+ );
197
+ if (supported) continue;
198
+ const match = feature.pattern.exec(unconditional);
199
+ if (!match) continue;
200
+ findings.push({
201
+ feature: feature.id,
202
+ message: feature.message,
203
+ fix: feature.fix,
204
+ sample: match[0].slice(0, 60),
205
+ requires: feature.requires,
206
+ });
207
+ }
208
+ return { ok: findings.length === 0, engines: parsed.engines, errors, findings };
209
+ }
210
+
211
+ /**
212
+ * 人类可读的基线文本。
213
+ * @param {unknown} baseline
214
+ */
215
+ export function formatBaseline(baseline) {
216
+ const { engines, errors } = parseBaseline(baseline);
217
+ if (errors.length > 0) return String(baseline ?? '(缺失)');
218
+ return ENGINE_KEYS.filter((engine) => engines[engine] !== undefined)
219
+ .map((engine) => `${engine} ${engines[engine]}`)
220
+ .join(', ');
221
+ }
222
+
223
+ /**
224
+ * 读取构建产物的 CSS 并判定。缺产物 = 失败(fail-closed)——没有证据不得放行。
225
+ * @param {{ appDir: string, baseline?: unknown, assetsDir?: string }} options
226
+ * @returns {{ ok: boolean, files: string[], engines: Record<string, number>, errors: string[], findings: Array<Record<string, unknown>>, totalBytes: number }}
227
+ */
228
+ export function checkDist(options) {
229
+ const { appDir, baseline } = options;
230
+ const assetsDir = options.assetsDir ?? path.join(appDir, 'apps/client/dist/assets');
231
+ const files = existsSync(assetsDir)
232
+ ? readdirSync(assetsDir)
233
+ .filter((name) => name.endsWith('.css'))
234
+ .sort()
235
+ : [];
236
+ if (files.length === 0) {
237
+ return {
238
+ ok: false,
239
+ files,
240
+ engines: {},
241
+ errors: [`没有构建产物(${assetsDir}/*.css);先构建再跑兼容门禁(缺证据不放行)`],
242
+ findings: [],
243
+ totalBytes: 0,
244
+ };
245
+ }
246
+ const parsed = parseBaseline(baseline);
247
+ if (parsed.errors.length > 0) {
248
+ return { ok: false, files, engines: parsed.engines, errors: parsed.errors, findings: [], totalBytes: 0 };
249
+ }
250
+ const findings = [];
251
+ let totalBytes = 0;
252
+ for (const name of files) {
253
+ const css = readFileSync(path.join(assetsDir, name), 'utf8');
254
+ totalBytes += Buffer.byteLength(css);
255
+ const result = checkCss(css, { baseline });
256
+ for (const finding of result.findings) findings.push({ file: `assets/${name}`, ...finding });
257
+ }
258
+ return { ok: findings.length === 0, files, engines: parsed.engines, errors: [], findings, totalBytes };
259
+ }
@@ -0,0 +1,227 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ declare class AppBuildError extends Error {
4
+ readonly code: string;
5
+ readonly file?: string;
6
+ readonly fix?: string;
7
+ constructor(code: string, message: string, options?: {
8
+ file?: string;
9
+ fix?: string;
10
+ });
11
+ }
12
+
13
+ type AppKind = 'agent' | 'web';
14
+ interface AppMeta {
15
+ schemaVersion: 1;
16
+ appKind: AppKind;
17
+ templateVersion?: string;
18
+ npmModules?: unknown[];
19
+ [key: string]: unknown;
20
+ }
21
+ interface PageEntry {
22
+ path: string;
23
+ entry: string;
24
+ document: string;
25
+ title: string;
26
+ }
27
+ interface AppManifest {
28
+ schemaVersion: 1;
29
+ pages: PageEntry[];
30
+ }
31
+ interface PageMeta {
32
+ title: string;
33
+ meta?: Record<string, unknown>;
34
+ }
35
+ interface PageModule {
36
+ id: string;
37
+ route: string;
38
+ file: string;
39
+ relativeFile: string;
40
+ meta: PageMeta;
41
+ }
42
+ interface FunctionModule {
43
+ id: string;
44
+ file: string;
45
+ relativeFile: string;
46
+ }
47
+ interface ToolModule {
48
+ id: string;
49
+ file: string;
50
+ relativeFile: string;
51
+ }
52
+ interface SkillModule {
53
+ id: string;
54
+ file: string;
55
+ relativeFile: string;
56
+ }
57
+ interface ActionModule {
58
+ id: string;
59
+ file: string;
60
+ relativeFile: string;
61
+ }
62
+ interface CardModule {
63
+ cardType: string;
64
+ serverFile: string;
65
+ /** 视图卡没有客户端文件:客户端 stub 由 generate 派生 */
66
+ clientFile: string | null;
67
+ clientRelativeFile: string | null;
68
+ /** true = 服务端 meta 声明了 view(免成对文件) */
69
+ view: boolean;
70
+ serverRelativeFile: string;
71
+ }
72
+ interface ModuleDescriptor {
73
+ schemaVersion: 1;
74
+ id: string;
75
+ version: string;
76
+ declare: {
77
+ tools?: string[];
78
+ cards?: Array<string | {
79
+ cardType: string;
80
+ [key: string]: unknown;
81
+ }>;
82
+ skills?: string[];
83
+ providers?: {
84
+ slots?: Array<string | Record<string, unknown>>;
85
+ [key: string]: unknown;
86
+ };
87
+ owns?: Array<string | Record<string, unknown>>;
88
+ consumes?: Array<string | Record<string, unknown>>;
89
+ resources?: unknown[];
90
+ };
91
+ dependencies?: {
92
+ modules?: Array<string | {
93
+ id: string;
94
+ required?: boolean;
95
+ }>;
96
+ packages?: string[];
97
+ };
98
+ env?: string[];
99
+ }
100
+ interface LoadedModule {
101
+ id: string;
102
+ dir: string;
103
+ relativeDir: string;
104
+ descriptor: ModuleDescriptor;
105
+ packageName?: string;
106
+ vendored: boolean;
107
+ appKinds: AppKind[];
108
+ hasServer: boolean;
109
+ hasClient: boolean;
110
+ }
111
+ interface ScanResult {
112
+ root: string;
113
+ appDir: string;
114
+ appKind: AppKind;
115
+ pages: PageModule[];
116
+ functions: FunctionModule[];
117
+ tools: ToolModule[];
118
+ skills: SkillModule[];
119
+ cards: CardModule[];
120
+ actions: ActionModule[];
121
+ modules: LoadedModule[];
122
+ }
123
+ interface GeneratedApp {
124
+ root: string;
125
+ appDir: string;
126
+ genDir: string;
127
+ appKind: AppKind;
128
+ manifest: AppManifest;
129
+ scan: ScanResult;
130
+ files: string[];
131
+ }
132
+ interface CheckIssue {
133
+ code: string;
134
+ severity: 'error' | 'warning';
135
+ file?: string;
136
+ message: string;
137
+ fix?: string;
138
+ }
139
+ interface CheckResult {
140
+ ok: boolean;
141
+ issues: CheckIssue[];
142
+ }
143
+
144
+ declare function readAppMeta(root: string): Promise<AppMeta>;
145
+
146
+ declare function scanApp(root: string): Promise<ScanResult>;
147
+
148
+ declare function parsePageMeta(file: string): Promise<PageMeta>;
149
+ declare function scanPages(root: string): Promise<PageModule[]>;
150
+
151
+ declare const FUNCTION_ID_RE: RegExp;
152
+ declare function scanFunctions(root: string): Promise<FunctionModule[]>;
153
+
154
+ interface PrimitiveSet {
155
+ tools: ToolModule[];
156
+ skills: SkillModule[];
157
+ cards: CardModule[];
158
+ actions: ActionModule[];
159
+ }
160
+ declare function scanAppPrimitives(root: string): Promise<PrimitiveSet>;
161
+ declare function scanModulePrimitives(moduleDir: string): Promise<PrimitiveSet>;
162
+
163
+ declare function scanModules(root: string): Promise<LoadedModule[]>;
164
+
165
+ interface GenerateOptions {
166
+ root: string;
167
+ watch?: boolean;
168
+ onManifest?: (manifest: AppManifest) => void;
169
+ onError?: (error: Error) => void;
170
+ }
171
+ interface GenerateResult {
172
+ manifest: AppManifest;
173
+ appKind: AppKind;
174
+ files: string[];
175
+ scan: ScanResult;
176
+ close: () => Promise<void>;
177
+ }
178
+ declare function buildManifest(scan: ScanResult, entryFor?: (pageId: string) => string): AppManifest;
179
+ declare function generateApp(options: GenerateOptions): Promise<GenerateResult>;
180
+ declare function listGeneratedFiles(root: string): Promise<string[]>;
181
+
182
+ declare function checkApp(options: {
183
+ root: string;
184
+ }): Promise<CheckResult>;
185
+
186
+ interface CardSampleEntry {
187
+ label?: string;
188
+ note?: string;
189
+ data: unknown;
190
+ }
191
+ interface CardSampleSet {
192
+ cardType?: string;
193
+ samples: CardSampleEntry[];
194
+ /** 样例缺失或不可静态求值时的说明 */
195
+ issues: string[];
196
+ }
197
+ declare function readCardSamples(file: string): CardSampleSet;
198
+
199
+ interface TboxAppPluginOptions {
200
+ root?: string;
201
+ getManifest?: () => AppManifest;
202
+ }
203
+ declare function tboxAppPlugin(options?: TboxAppPluginOptions): Plugin;
204
+
205
+ interface TboxModuleSourcesOptions {
206
+ /** 应用根(含 apps/client 与 modules/) */
207
+ appRoot: string;
208
+ }
209
+ /**
210
+ * 在 Tailwind 入口编译前追加模块源码 @source。
211
+ * 必须排在 @tailwindcss/vite 之前(enforce: 'pre' + plugins 数组顺序)。
212
+ */
213
+ declare function tboxModuleSourcesPlugin(options: TboxModuleSourcesOptions): Plugin;
214
+
215
+ /** 把一段 CSS 包进 `@layer vendor`;已包过则原样返回。纯函数,单测面。 */
216
+ declare function wrapVendorCss(css: string): string;
217
+ interface TboxVendorLayerOptions {
218
+ /** 覆盖匹配规则(默认 Yet Another Lightbox 与 antd-mobile)。 */
219
+ match?: RegExp[];
220
+ }
221
+ /**
222
+ * Vite 插件:把第三方无层 CSS 包进 `@layer vendor`。
223
+ * 只处理 `.css` 模块,`enforce: 'pre'` 保证在其它 CSS 插件之前改写。
224
+ */
225
+ declare function tboxVendorLayerPlugin(options?: TboxVendorLayerOptions): Plugin;
226
+
227
+ export { type ActionModule, AppBuildError, type AppKind, type AppManifest, type AppMeta, type CardModule, type CardSampleEntry, type CardSampleSet, type CheckIssue, type CheckResult, FUNCTION_ID_RE, type FunctionModule, type GenerateOptions, type GenerateResult, type GeneratedApp, type LoadedModule, type ModuleDescriptor, type PageEntry, type PageMeta, type PageModule, type ScanResult, type SkillModule, type TboxAppPluginOptions, type TboxModuleSourcesOptions, type TboxVendorLayerOptions, type ToolModule, buildManifest, checkApp, generateApp, listGeneratedFiles, parsePageMeta, readAppMeta, readCardSamples, scanApp, scanAppPrimitives, scanFunctions, scanModulePrimitives, scanModules, scanPages, tboxAppPlugin, tboxModuleSourcesPlugin, tboxVendorLayerPlugin, wrapVendorCss };