@weapp-core/schematics 1.0.2 → 1.0.4
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.cjs +82 -20
- package/dist/index.d.cts +44 -9
- package/dist/index.d.ts +44 -9
- package/dist/index.js +82 -20
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -38,30 +38,92 @@ function generateJs(type) {
|
|
|
38
38
|
function generateWxss() {
|
|
39
39
|
return "";
|
|
40
40
|
}
|
|
41
|
-
function generateWxml(
|
|
42
|
-
return `<view
|
|
41
|
+
function generateWxml(filepath) {
|
|
42
|
+
return `<view>hello weapp-vite!${filepath ? ` from ${filepath}` : ""}</view>`;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function JSONStringify(res) {
|
|
45
|
+
return JSON.stringify(res, void 0, 2);
|
|
46
|
+
}
|
|
47
|
+
function generateJson(type, ext = "json") {
|
|
45
48
|
if (type === "app") {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if (ext === "ts") {
|
|
50
|
+
return `import { defineAppJson } from 'weapp-vite/json'
|
|
51
|
+
|
|
52
|
+
export default defineAppJson({
|
|
53
|
+
pages: [
|
|
54
|
+
'pages/index/index',
|
|
55
|
+
],
|
|
56
|
+
usingComponents: {},
|
|
57
|
+
})
|
|
58
|
+
`;
|
|
59
|
+
} else if (ext === "js") {
|
|
60
|
+
return `import { defineAppJson } from 'weapp-vite/json'
|
|
61
|
+
|
|
62
|
+
export default defineAppJson({
|
|
63
|
+
pages: [
|
|
64
|
+
'pages/index/index',
|
|
65
|
+
],
|
|
66
|
+
usingComponents: {},
|
|
67
|
+
})
|
|
68
|
+
`;
|
|
69
|
+
} else {
|
|
70
|
+
return JSONStringify({
|
|
71
|
+
$schema: "https://vite.icebreaker.top/app.json",
|
|
72
|
+
usingComponents: {},
|
|
73
|
+
pages: [
|
|
74
|
+
"pages/index/index"
|
|
75
|
+
],
|
|
76
|
+
sitemapLocation: "sitemap.json"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
53
79
|
} else if (type === "page") {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
80
|
+
if (ext === "ts") {
|
|
81
|
+
return `import { definePageJson } from 'weapp-vite/json'
|
|
82
|
+
|
|
83
|
+
export default definePageJson({
|
|
84
|
+
usingComponents: {},
|
|
85
|
+
})
|
|
86
|
+
`;
|
|
87
|
+
} else if (ext === "js") {
|
|
88
|
+
return `import { definePageJson } from 'weapp-vite/json'
|
|
89
|
+
|
|
90
|
+
export default definePageJson({
|
|
91
|
+
usingComponents: {},
|
|
92
|
+
})
|
|
93
|
+
`;
|
|
94
|
+
} else {
|
|
95
|
+
return JSONStringify({
|
|
96
|
+
$schema: "https://vite.icebreaker.top/page.json",
|
|
97
|
+
usingComponents: {}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
58
100
|
} else {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
101
|
+
if (ext === "ts") {
|
|
102
|
+
return `import { defineComponentJson } from 'weapp-vite/json'
|
|
103
|
+
|
|
104
|
+
export default defineComponentJson({
|
|
105
|
+
component: true,
|
|
106
|
+
styleIsolation: 'apply-shared',
|
|
107
|
+
usingComponents: {},
|
|
108
|
+
})
|
|
109
|
+
`;
|
|
110
|
+
} else if (ext === "js") {
|
|
111
|
+
return `import { defineComponentJson } from 'weapp-vite/json'
|
|
112
|
+
|
|
113
|
+
export default defineComponentJson({
|
|
114
|
+
component: true,
|
|
115
|
+
styleIsolation: 'apply-shared',
|
|
116
|
+
usingComponents: {},
|
|
117
|
+
})
|
|
118
|
+
`;
|
|
119
|
+
} else {
|
|
120
|
+
return JSONStringify({
|
|
121
|
+
$schema: "https://vite.icebreaker.top/component.json",
|
|
122
|
+
component: true,
|
|
123
|
+
styleIsolation: "apply-shared",
|
|
124
|
+
usingComponents: {}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
65
127
|
}
|
|
66
128
|
}
|
|
67
129
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* 全局配置, 小程序根目录下的 app.json 文件用来对微信小程序进行全局配置。
|
|
8
8
|
*/
|
|
9
|
-
interface App {
|
|
9
|
+
interface App$1 {
|
|
10
10
|
/**
|
|
11
11
|
* 指定小程序的默认启动路径(首页),常见情景是从微信聊天列表页下拉启动、小程序列表启动等。如果不填,将默认为 pages 列表的第一项。不支持带页面路径参数。
|
|
12
12
|
*/
|
|
@@ -232,7 +232,6 @@ interface App {
|
|
|
232
232
|
[k: string]: unknown;
|
|
233
233
|
};
|
|
234
234
|
componentFramework?: string;
|
|
235
|
-
$schema?: string;
|
|
236
235
|
[k: string]: unknown;
|
|
237
236
|
}
|
|
238
237
|
/**
|
|
@@ -243,7 +242,7 @@ interface App {
|
|
|
243
242
|
/**
|
|
244
243
|
* 自定义组件配置
|
|
245
244
|
*/
|
|
246
|
-
interface Component {
|
|
245
|
+
interface Component$1 {
|
|
247
246
|
component?: boolean;
|
|
248
247
|
styleIsolation?: "isolated" | "apply-shared" | "shared";
|
|
249
248
|
componentGenerics?: {
|
|
@@ -256,7 +255,6 @@ interface Component {
|
|
|
256
255
|
[k: string]: unknown;
|
|
257
256
|
};
|
|
258
257
|
componentFramework?: string;
|
|
259
|
-
$schema?: string;
|
|
260
258
|
[k: string]: unknown;
|
|
261
259
|
}
|
|
262
260
|
/**
|
|
@@ -267,7 +265,7 @@ interface Component {
|
|
|
267
265
|
/**
|
|
268
266
|
* 页面配置, 支持对单个页面进行配置,可以在页面对应的 .json 文件来对本页面的表现进行配置
|
|
269
267
|
*/
|
|
270
|
-
interface Page {
|
|
268
|
+
interface Page$1 {
|
|
271
269
|
backgroundColorContent?: string;
|
|
272
270
|
disableScroll?: boolean;
|
|
273
271
|
styleIsolation?: "page-isolated" | "page-apply-shared" | "page-shared";
|
|
@@ -292,7 +290,6 @@ interface Page {
|
|
|
292
290
|
[k: string]: unknown;
|
|
293
291
|
};
|
|
294
292
|
componentFramework?: string;
|
|
295
|
-
$schema?: string;
|
|
296
293
|
componentPlaceholder?: {
|
|
297
294
|
[k: string]: unknown;
|
|
298
295
|
};
|
|
@@ -314,11 +311,49 @@ interface Page {
|
|
|
314
311
|
handleWebviewPreload?: "static" | "manual" | "auto";
|
|
315
312
|
[k: string]: unknown;
|
|
316
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
316
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
317
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
318
|
+
*/
|
|
319
|
+
/**
|
|
320
|
+
* https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/sitemap.html
|
|
321
|
+
*/
|
|
322
|
+
interface Sitemap$1 {
|
|
323
|
+
rules: {
|
|
324
|
+
action?: "allow" | "disallow";
|
|
325
|
+
page: string;
|
|
326
|
+
params?: string[];
|
|
327
|
+
matching?: "exact" | "inclusive" | "exclusive" | "partial";
|
|
328
|
+
priority?: number;
|
|
329
|
+
}[];
|
|
330
|
+
[k: string]: unknown;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
334
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
335
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
336
|
+
*/
|
|
337
|
+
interface Theme$1 {
|
|
338
|
+
light: {
|
|
339
|
+
[k: string]: unknown;
|
|
340
|
+
};
|
|
341
|
+
dark: {
|
|
342
|
+
[k: string]: unknown;
|
|
343
|
+
};
|
|
344
|
+
[k: string]: unknown;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
type App = App$1;
|
|
348
|
+
type Component = Component$1;
|
|
349
|
+
type Page = Page$1;
|
|
350
|
+
type Sitemap = Sitemap$1;
|
|
351
|
+
type Theme = Theme$1;
|
|
317
352
|
|
|
318
353
|
type GenerateType = 'app' | 'page' | 'component';
|
|
319
354
|
declare function generateJs(type?: GenerateType): "App({})" | "Page({})" | "Component({})";
|
|
320
355
|
declare function generateWxss(): string;
|
|
321
|
-
declare function generateWxml(
|
|
322
|
-
declare function generateJson(type?: GenerateType
|
|
356
|
+
declare function generateWxml(filepath?: string): string;
|
|
357
|
+
declare function generateJson(type?: GenerateType, ext?: 'json' | 'js' | 'ts' | (string & {})): string;
|
|
323
358
|
|
|
324
|
-
export { type App, type Component, type GenerateType, type Page, generateJs, generateJson, generateWxml, generateWxss };
|
|
359
|
+
export { type App, type Component, type GenerateType, type Page, type Sitemap, type Theme, generateJs, generateJson, generateWxml, generateWxss };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* 全局配置, 小程序根目录下的 app.json 文件用来对微信小程序进行全局配置。
|
|
8
8
|
*/
|
|
9
|
-
interface App {
|
|
9
|
+
interface App$1 {
|
|
10
10
|
/**
|
|
11
11
|
* 指定小程序的默认启动路径(首页),常见情景是从微信聊天列表页下拉启动、小程序列表启动等。如果不填,将默认为 pages 列表的第一项。不支持带页面路径参数。
|
|
12
12
|
*/
|
|
@@ -232,7 +232,6 @@ interface App {
|
|
|
232
232
|
[k: string]: unknown;
|
|
233
233
|
};
|
|
234
234
|
componentFramework?: string;
|
|
235
|
-
$schema?: string;
|
|
236
235
|
[k: string]: unknown;
|
|
237
236
|
}
|
|
238
237
|
/**
|
|
@@ -243,7 +242,7 @@ interface App {
|
|
|
243
242
|
/**
|
|
244
243
|
* 自定义组件配置
|
|
245
244
|
*/
|
|
246
|
-
interface Component {
|
|
245
|
+
interface Component$1 {
|
|
247
246
|
component?: boolean;
|
|
248
247
|
styleIsolation?: "isolated" | "apply-shared" | "shared";
|
|
249
248
|
componentGenerics?: {
|
|
@@ -256,7 +255,6 @@ interface Component {
|
|
|
256
255
|
[k: string]: unknown;
|
|
257
256
|
};
|
|
258
257
|
componentFramework?: string;
|
|
259
|
-
$schema?: string;
|
|
260
258
|
[k: string]: unknown;
|
|
261
259
|
}
|
|
262
260
|
/**
|
|
@@ -267,7 +265,7 @@ interface Component {
|
|
|
267
265
|
/**
|
|
268
266
|
* 页面配置, 支持对单个页面进行配置,可以在页面对应的 .json 文件来对本页面的表现进行配置
|
|
269
267
|
*/
|
|
270
|
-
interface Page {
|
|
268
|
+
interface Page$1 {
|
|
271
269
|
backgroundColorContent?: string;
|
|
272
270
|
disableScroll?: boolean;
|
|
273
271
|
styleIsolation?: "page-isolated" | "page-apply-shared" | "page-shared";
|
|
@@ -292,7 +290,6 @@ interface Page {
|
|
|
292
290
|
[k: string]: unknown;
|
|
293
291
|
};
|
|
294
292
|
componentFramework?: string;
|
|
295
|
-
$schema?: string;
|
|
296
293
|
componentPlaceholder?: {
|
|
297
294
|
[k: string]: unknown;
|
|
298
295
|
};
|
|
@@ -314,11 +311,49 @@ interface Page {
|
|
|
314
311
|
handleWebviewPreload?: "static" | "manual" | "auto";
|
|
315
312
|
[k: string]: unknown;
|
|
316
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
316
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
317
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
318
|
+
*/
|
|
319
|
+
/**
|
|
320
|
+
* https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/sitemap.html
|
|
321
|
+
*/
|
|
322
|
+
interface Sitemap$1 {
|
|
323
|
+
rules: {
|
|
324
|
+
action?: "allow" | "disallow";
|
|
325
|
+
page: string;
|
|
326
|
+
params?: string[];
|
|
327
|
+
matching?: "exact" | "inclusive" | "exclusive" | "partial";
|
|
328
|
+
priority?: number;
|
|
329
|
+
}[];
|
|
330
|
+
[k: string]: unknown;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
334
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
335
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
336
|
+
*/
|
|
337
|
+
interface Theme$1 {
|
|
338
|
+
light: {
|
|
339
|
+
[k: string]: unknown;
|
|
340
|
+
};
|
|
341
|
+
dark: {
|
|
342
|
+
[k: string]: unknown;
|
|
343
|
+
};
|
|
344
|
+
[k: string]: unknown;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
type App = App$1;
|
|
348
|
+
type Component = Component$1;
|
|
349
|
+
type Page = Page$1;
|
|
350
|
+
type Sitemap = Sitemap$1;
|
|
351
|
+
type Theme = Theme$1;
|
|
317
352
|
|
|
318
353
|
type GenerateType = 'app' | 'page' | 'component';
|
|
319
354
|
declare function generateJs(type?: GenerateType): "App({})" | "Page({})" | "Component({})";
|
|
320
355
|
declare function generateWxss(): string;
|
|
321
|
-
declare function generateWxml(
|
|
322
|
-
declare function generateJson(type?: GenerateType
|
|
356
|
+
declare function generateWxml(filepath?: string): string;
|
|
357
|
+
declare function generateJson(type?: GenerateType, ext?: 'json' | 'js' | 'ts' | (string & {})): string;
|
|
323
358
|
|
|
324
|
-
export { type App, type Component, type GenerateType, type Page, generateJs, generateJson, generateWxml, generateWxss };
|
|
359
|
+
export { type App, type Component, type GenerateType, type Page, type Sitemap, type Theme, generateJs, generateJson, generateWxml, generateWxss };
|
package/dist/index.js
CHANGED
|
@@ -11,30 +11,92 @@ function generateJs(type) {
|
|
|
11
11
|
function generateWxss() {
|
|
12
12
|
return "";
|
|
13
13
|
}
|
|
14
|
-
function generateWxml(
|
|
15
|
-
return `<view
|
|
14
|
+
function generateWxml(filepath) {
|
|
15
|
+
return `<view>hello weapp-vite!${filepath ? ` from ${filepath}` : ""}</view>`;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function JSONStringify(res) {
|
|
18
|
+
return JSON.stringify(res, void 0, 2);
|
|
19
|
+
}
|
|
20
|
+
function generateJson(type, ext = "json") {
|
|
18
21
|
if (type === "app") {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
if (ext === "ts") {
|
|
23
|
+
return `import { defineAppJson } from 'weapp-vite/json'
|
|
24
|
+
|
|
25
|
+
export default defineAppJson({
|
|
26
|
+
pages: [
|
|
27
|
+
'pages/index/index',
|
|
28
|
+
],
|
|
29
|
+
usingComponents: {},
|
|
30
|
+
})
|
|
31
|
+
`;
|
|
32
|
+
} else if (ext === "js") {
|
|
33
|
+
return `import { defineAppJson } from 'weapp-vite/json'
|
|
34
|
+
|
|
35
|
+
export default defineAppJson({
|
|
36
|
+
pages: [
|
|
37
|
+
'pages/index/index',
|
|
38
|
+
],
|
|
39
|
+
usingComponents: {},
|
|
40
|
+
})
|
|
41
|
+
`;
|
|
42
|
+
} else {
|
|
43
|
+
return JSONStringify({
|
|
44
|
+
$schema: "https://vite.icebreaker.top/app.json",
|
|
45
|
+
usingComponents: {},
|
|
46
|
+
pages: [
|
|
47
|
+
"pages/index/index"
|
|
48
|
+
],
|
|
49
|
+
sitemapLocation: "sitemap.json"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
26
52
|
} else if (type === "page") {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
if (ext === "ts") {
|
|
54
|
+
return `import { definePageJson } from 'weapp-vite/json'
|
|
55
|
+
|
|
56
|
+
export default definePageJson({
|
|
57
|
+
usingComponents: {},
|
|
58
|
+
})
|
|
59
|
+
`;
|
|
60
|
+
} else if (ext === "js") {
|
|
61
|
+
return `import { definePageJson } from 'weapp-vite/json'
|
|
62
|
+
|
|
63
|
+
export default definePageJson({
|
|
64
|
+
usingComponents: {},
|
|
65
|
+
})
|
|
66
|
+
`;
|
|
67
|
+
} else {
|
|
68
|
+
return JSONStringify({
|
|
69
|
+
$schema: "https://vite.icebreaker.top/page.json",
|
|
70
|
+
usingComponents: {}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
31
73
|
} else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
74
|
+
if (ext === "ts") {
|
|
75
|
+
return `import { defineComponentJson } from 'weapp-vite/json'
|
|
76
|
+
|
|
77
|
+
export default defineComponentJson({
|
|
78
|
+
component: true,
|
|
79
|
+
styleIsolation: 'apply-shared',
|
|
80
|
+
usingComponents: {},
|
|
81
|
+
})
|
|
82
|
+
`;
|
|
83
|
+
} else if (ext === "js") {
|
|
84
|
+
return `import { defineComponentJson } from 'weapp-vite/json'
|
|
85
|
+
|
|
86
|
+
export default defineComponentJson({
|
|
87
|
+
component: true,
|
|
88
|
+
styleIsolation: 'apply-shared',
|
|
89
|
+
usingComponents: {},
|
|
90
|
+
})
|
|
91
|
+
`;
|
|
92
|
+
} else {
|
|
93
|
+
return JSONStringify({
|
|
94
|
+
$schema: "https://vite.icebreaker.top/component.json",
|
|
95
|
+
component: true,
|
|
96
|
+
styleIsolation: "apply-shared",
|
|
97
|
+
usingComponents: {}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
38
100
|
}
|
|
39
101
|
}
|
|
40
102
|
export {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/schematics",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"description": "@weapp-core/schematics",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"dev": "tsup --watch --sourcemap",
|
|
31
|
-
"build": "
|
|
31
|
+
"build": "tsup",
|
|
32
32
|
"test": "vitest run",
|
|
33
33
|
"test:dev": "vitest",
|
|
34
34
|
"release": "pnpm publish",
|