@weapp-vite/volar 2.0.5 → 2.0.6

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 CHANGED
@@ -1,386 +1,323 @@
1
- "use strict";
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name2 in all)
10
- __defProp(target, name2, { get: all[name2], enumerable: true });
11
- };
12
8
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- default: () => index_default
34
- });
35
- module.exports = __toCommonJS(index_exports);
36
- var import_node_module = require("module");
37
- var import_node_path = __toESM(require("path"));
38
- var import_node_process = __toESM(require("process"));
39
-
40
- // package.json
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let node_module = require("node:module");
24
+ let node_path = require("node:path");
25
+ node_path = __toESM(node_path);
26
+ let node_process = require("node:process");
27
+ node_process = __toESM(node_process);
28
+ let _weapp_core_schematics = require("@weapp-core/schematics");
29
+ //#region package.json
41
30
  var name = "@weapp-vite/volar";
42
-
43
- // src/schema.ts
44
- var import_schematics = require("@weapp-core/schematics");
31
+ //#endregion
32
+ //#region src/schema.ts
33
+ /**
34
+ * 为小程序配置生成 JSON Schema
35
+ * 为支持 JSON Schema 的编辑器提供验证和自动补全
36
+ *
37
+ * 注意:JSON Schema 定义由 @weapp-core/schematics 统一维护
38
+ * 使用 Zod 定义并自动生成,确保单一数据源
39
+ */
40
+ /**
41
+ * 根据文件类型获取对应的 JSON Schema
42
+ * Schema 定义来自 @weapp-core/schematics,使用 Zod 维护单一数据源
43
+ */
45
44
  function getSchemaForType(type) {
46
- const definition = import_schematics.JSON_SCHEMA_DEFINITIONS.find((d) => d.typeName === type);
47
- if (!definition) {
48
- return null;
49
- }
50
- return definition.schema;
45
+ const definition = _weapp_core_schematics.JSON_SCHEMA_DEFINITIONS.find((d) => d.typeName === type);
46
+ if (!definition) return null;
47
+ return definition.schema;
51
48
  }
52
-
53
- // src/index.ts
54
- var BLOCK_TYPE = "json";
55
- var JS_LANG = "js";
56
- var JSONC_LANG = "jsonc";
57
- var JSON_LANG = "json";
58
- var JSON5_LANG = "json5";
59
- var PLUGIN_VERSION = 2.2;
60
- var TS_LANG = "ts";
61
- var BACKSLASH_RE = /\\/g;
62
- var NON_SPACE_RE = /\S/;
63
- var WXS_MODULE_RE = /<wxs[\s\S]*?module\s*=\s*(?:"([^"]+)"|'([^']+)')[\s\S]*?\/?>/gi;
64
- var FULL_CAPABILITIES = {
65
- verification: true,
66
- completion: true,
67
- semantic: true,
68
- navigation: true,
69
- structure: true,
70
- format: true
49
+ //#endregion
50
+ //#region src/index.ts
51
+ const BLOCK_TYPE = "json";
52
+ const JS_LANG = "js";
53
+ const JSONC_LANG = "jsonc";
54
+ const JSON_LANG = "json";
55
+ const JSON5_LANG = "json5";
56
+ const PLUGIN_VERSION = 2.2;
57
+ const TS_LANG = "ts";
58
+ const BACKSLASH_RE = /\\/g;
59
+ const NON_SPACE_RE = /\S/;
60
+ const WXS_MODULE_RE = /<wxs[\s\S]*?module\s*=\s*(?:"([^"]+)"|'([^']+)')[\s\S]*?\/?>/gi;
61
+ const FULL_CAPABILITIES = {
62
+ verification: true,
63
+ completion: true,
64
+ semantic: true,
65
+ navigation: true,
66
+ structure: true,
67
+ format: true
71
68
  };
72
- var VOID_CAPABILITIES = {
73
- verification: false,
74
- completion: false,
75
- semantic: false,
76
- navigation: false,
77
- structure: false,
78
- format: false
69
+ const VOID_CAPABILITIES = {
70
+ verification: false,
71
+ completion: false,
72
+ semantic: false,
73
+ navigation: false,
74
+ structure: false,
75
+ format: false
79
76
  };
80
- var require2 = (0, import_node_module.createRequire)(
81
- typeof module !== "undefined" && module.filename ? module.filename : import_node_path.default.join(import_node_process.default.cwd(), "weapp-vite-volar.cjs")
82
- );
83
- var hasSchematicsTypes = false;
77
+ const require$1 = (0, node_module.createRequire)(typeof module !== "undefined" && module.filename ? module.filename : node_path.default.join(node_process.default.cwd(), "weapp-vite-volar.cjs"));
78
+ let hasSchematicsTypes = false;
84
79
  try {
85
- require2.resolve("@weapp-core/schematics");
86
- hasSchematicsTypes = true;
80
+ require$1.resolve("@weapp-core/schematics");
81
+ hasSchematicsTypes = true;
87
82
  } catch {
88
- hasSchematicsTypes = false;
83
+ hasSchematicsTypes = false;
89
84
  }
90
85
  function parseVueSfc(content, filename = "component.vue") {
91
- try {
92
- const compilerSfc = require2("@vue/compiler-sfc");
93
- return compilerSfc.parse(content, { filename });
94
- } catch {
95
- return void 0;
96
- }
86
+ try {
87
+ return require$1("@vue/compiler-sfc").parse(content, { filename });
88
+ } catch {
89
+ return;
90
+ }
97
91
  }
98
92
  function collectWxsModuleNames(templateContent) {
99
- if (!templateContent) {
100
- return [];
101
- }
102
- const names = /* @__PURE__ */ new Set();
103
- for (const match of templateContent.matchAll(WXS_MODULE_RE)) {
104
- const name2 = match[1] ?? match[2];
105
- if (name2) {
106
- names.add(name2);
107
- }
108
- }
109
- return [...names];
93
+ if (!templateContent) return [];
94
+ const names = /* @__PURE__ */ new Set();
95
+ for (const match of templateContent.matchAll(WXS_MODULE_RE)) {
96
+ const name = match[1] ?? match[2];
97
+ if (name) names.add(name);
98
+ }
99
+ return [...names];
110
100
  }
111
101
  function createWxsModuleDeclarations(moduleNames) {
112
- if (!moduleNames.length) {
113
- return "";
114
- }
115
- return moduleNames.map((name2) => `const ${name2} = {} as Record<string, (...args: any[]) => any>`).join("\n");
102
+ if (!moduleNames.length) return "";
103
+ return moduleNames.map((name) => `const ${name} = {} as Record<string, (...args: any[]) => any>`).join("\n");
116
104
  }
117
105
  function appendWxsDeclarations(code, moduleNames) {
118
- const declarations = createWxsModuleDeclarations(moduleNames);
119
- if (!declarations) {
120
- return code;
121
- }
122
- return code ? `${code}
123
-
124
- ${declarations}
125
- ` : `${declarations}
126
- `;
106
+ const declarations = createWxsModuleDeclarations(moduleNames);
107
+ if (!declarations) return code;
108
+ return code ? `${code}\n\n${declarations}\n` : `${declarations}\n`;
127
109
  }
128
110
  function createSyntheticScriptSetup(moduleNames) {
129
- const content = createWxsModuleDeclarations(moduleNames);
130
- if (!content) {
131
- return void 0;
132
- }
133
- return {
134
- type: "script",
135
- content,
136
- loc: {
137
- source: `<script setup lang="ts">
138
- ${content}
139
- </script>`,
140
- start: { column: 1, line: 1, offset: 0 },
141
- end: { column: 1, line: 1, offset: 0 }
142
- },
143
- attrs: {
144
- setup: true,
145
- lang: "ts"
146
- },
147
- lang: "ts",
148
- setup: true,
149
- name: "scriptSetup"
150
- };
111
+ const content = createWxsModuleDeclarations(moduleNames);
112
+ if (!content) return;
113
+ return {
114
+ type: "script",
115
+ content,
116
+ loc: {
117
+ source: `<script setup lang="ts">\n${content}\n<\/script>`,
118
+ start: {
119
+ column: 1,
120
+ line: 1,
121
+ offset: 0
122
+ },
123
+ end: {
124
+ column: 1,
125
+ line: 1,
126
+ offset: 0
127
+ }
128
+ },
129
+ attrs: {
130
+ setup: true,
131
+ lang: "ts"
132
+ },
133
+ lang: "ts",
134
+ setup: true,
135
+ name: "scriptSetup"
136
+ };
151
137
  }
152
138
  function normalizeFilename(filename) {
153
- if (!filename) {
154
- return "";
155
- }
156
- return filename.replace(BACKSLASH_RE, "/");
139
+ if (!filename) return "";
140
+ return filename.replace(BACKSLASH_RE, "/");
157
141
  }
158
142
  function inferConfigType(filename) {
159
- const normalized = normalizeFilename(filename);
160
- if (normalized.endsWith("/app.vue")) {
161
- return "App";
162
- }
163
- if (normalized.includes("/plugin/")) {
164
- return "Plugin";
165
- }
166
- if (normalized.includes("/components/")) {
167
- return "Component";
168
- }
169
- if (normalized.includes("/theme/")) {
170
- return "Theme";
171
- }
172
- if (normalized.includes("/sitemap")) {
173
- return "Sitemap";
174
- }
175
- return "Page";
143
+ const normalized = normalizeFilename(filename);
144
+ if (normalized.endsWith("/app.vue")) return "App";
145
+ if (normalized.includes("/plugin/")) return "Plugin";
146
+ if (normalized.includes("/components/")) return "Component";
147
+ if (normalized.includes("/theme/")) return "Theme";
148
+ if (normalized.includes("/sitemap")) return "Sitemap";
149
+ return "Page";
176
150
  }
177
151
  function normalizeLang(lang) {
178
- if (!lang) {
179
- return JSON_LANG;
180
- }
181
- const lower = lang.toLowerCase();
182
- if (lower === "txt") {
183
- return JSON_LANG;
184
- }
185
- return lower;
152
+ if (!lang) return JSON_LANG;
153
+ const lower = lang.toLowerCase();
154
+ if (lower === "txt") return JSON_LANG;
155
+ return lower;
186
156
  }
187
157
  function findExportDefaultExpression(code, tsModule, lang) {
188
- const scriptKind = lang === TS_LANG ? tsModule.ScriptKind.TS : tsModule.ScriptKind.JS;
189
- const sourceFile = tsModule.createSourceFile(
190
- `config.${lang}`,
191
- code,
192
- tsModule.ScriptTarget.Latest,
193
- true,
194
- scriptKind
195
- );
196
- for (const statement of sourceFile.statements) {
197
- if (tsModule.isExportAssignment(statement)) {
198
- const expressionStart = statement.expression.getStart(sourceFile);
199
- const expressionEnd = statement.expression.getEnd();
200
- const leading = code.slice(0, statement.getStart(sourceFile));
201
- const expression = code.slice(expressionStart, expressionEnd);
202
- const trailing = code.slice(statement.getEnd());
203
- return {
204
- expression,
205
- expressionStart,
206
- expressionEnd,
207
- leading,
208
- trailing
209
- };
210
- }
211
- }
212
- return null;
158
+ const scriptKind = lang === TS_LANG ? tsModule.ScriptKind.TS : tsModule.ScriptKind.JS;
159
+ const sourceFile = tsModule.createSourceFile(`config.${lang}`, code, tsModule.ScriptTarget.Latest, true, scriptKind);
160
+ for (const statement of sourceFile.statements) if (tsModule.isExportAssignment(statement)) {
161
+ const expressionStart = statement.expression.getStart(sourceFile);
162
+ const expressionEnd = statement.expression.getEnd();
163
+ const leading = code.slice(0, statement.getStart(sourceFile));
164
+ return {
165
+ expression: code.slice(expressionStart, expressionEnd),
166
+ expressionStart,
167
+ expressionEnd,
168
+ leading,
169
+ trailing: code.slice(statement.getEnd())
170
+ };
171
+ }
172
+ return null;
213
173
  }
214
174
  function injectSchemaIntoJsonObject(content, schemaId) {
215
- const trimmed = content.trim();
216
- if (!trimmed.startsWith("{")) {
217
- return content;
218
- }
219
- const leftBraceIndex = content.indexOf("{");
220
- if (leftBraceIndex < 0) {
221
- return content;
222
- }
223
- const afterLeft = content.slice(leftBraceIndex + 1);
224
- const firstNonSpace = afterLeft.match(NON_SPACE_RE);
225
- const nextCharIndex = firstNonSpace ? leftBraceIndex + 1 + firstNonSpace.index : -1;
226
- const isEmptyObject = nextCharIndex >= 0 && content[nextCharIndex] === "}";
227
- const schemaLine = ` "$schema": "${schemaId}"`;
228
- const injected = isEmptyObject ? `{
229
- ${schemaLine}
230
- }` : `{
231
- ${schemaLine},${content.slice(leftBraceIndex + 1)}`;
232
- if (trimmed === content) {
233
- return injected;
234
- }
235
- const leading = content.slice(0, content.indexOf(trimmed));
236
- const trailing = content.slice(content.indexOf(trimmed) + trimmed.length);
237
- return `${leading}${injected}${trailing}`;
175
+ const trimmed = content.trim();
176
+ if (!trimmed.startsWith("{")) return content;
177
+ const leftBraceIndex = content.indexOf("{");
178
+ if (leftBraceIndex < 0) return content;
179
+ const firstNonSpace = content.slice(leftBraceIndex + 1).match(NON_SPACE_RE);
180
+ const nextCharIndex = firstNonSpace ? leftBraceIndex + 1 + firstNonSpace.index : -1;
181
+ const isEmptyObject = nextCharIndex >= 0 && content[nextCharIndex] === "}";
182
+ const schemaLine = ` "$schema": "${schemaId}"`;
183
+ const injected = isEmptyObject ? `{\n${schemaLine}\n}` : `{\n${schemaLine},${content.slice(leftBraceIndex + 1)}`;
184
+ if (trimmed === content) return injected;
185
+ return `${content.slice(0, content.indexOf(trimmed))}${injected}${content.slice(content.indexOf(trimmed) + trimmed.length)}`;
238
186
  }
239
- var plugin = (ctx) => {
240
- let tsModule = ctx?.modules?.typescript;
241
- if (!tsModule) {
242
- try {
243
- tsModule = require2("typescript");
244
- } catch {
245
- tsModule = void 0;
246
- }
247
- }
248
- return {
249
- name,
250
- version: PLUGIN_VERSION,
251
- order: -1,
252
- parseSFC2(fileName, languageId, content) {
253
- if (languageId !== "vue") {
254
- return;
255
- }
256
- const parsed = parseVueSfc(content, fileName);
257
- if (!parsed) {
258
- return;
259
- }
260
- const descriptor = parsed.descriptor;
261
- const wxsModuleNames = collectWxsModuleNames(descriptor.template?.content);
262
- if (!wxsModuleNames.length) {
263
- return parsed;
264
- }
265
- if (descriptor.scriptSetup) {
266
- descriptor.scriptSetup.content = appendWxsDeclarations(descriptor.scriptSetup.content, wxsModuleNames);
267
- } else {
268
- descriptor.scriptSetup = createSyntheticScriptSetup(wxsModuleNames);
269
- }
270
- return parsed;
271
- },
272
- getEmbeddedCodes(_, sfc) {
273
- const names = [];
274
- for (let i = 0; i < sfc.customBlocks.length; i++) {
275
- const block = sfc.customBlocks[i];
276
- if (block.type === BLOCK_TYPE) {
277
- const normalizedLang = normalizeLang(block.lang);
278
- const isJsLike = normalizedLang === JS_LANG || normalizedLang === TS_LANG;
279
- if (isJsLike) {
280
- names.push({ id: `${BLOCK_TYPE}_${i}`, lang: TS_LANG });
281
- continue;
282
- }
283
- const embeddedLang = normalizedLang === JSON_LANG || normalizedLang === JSONC_LANG || normalizedLang === JSON5_LANG ? JSONC_LANG : JSON_LANG;
284
- names.push({ id: `${BLOCK_TYPE}_${i}`, lang: embeddedLang });
285
- }
286
- }
287
- return names;
288
- },
289
- resolveEmbeddedCode(fileName, sfc, embeddedCode) {
290
- const match = embeddedCode.id.match(new RegExp(`^${BLOCK_TYPE}_(\\d+)$`));
291
- if (!match) {
292
- return;
293
- }
294
- const index = Number.parseInt(match[1]);
295
- const block = sfc.customBlocks[index];
296
- if (!block) {
297
- return;
298
- }
299
- const normalizedLang = normalizeLang(block.lang);
300
- const configType = inferConfigType(fileName);
301
- if (!hasSchematicsTypes) {
302
- embeddedCode.content.push([
303
- block.content,
304
- block.name,
305
- 0,
306
- FULL_CAPABILITIES
307
- ]);
308
- return;
309
- }
310
- const userWantsJs = normalizedLang === JS_LANG || normalizedLang === TS_LANG;
311
- if (userWantsJs) {
312
- const parsed = tsModule && findExportDefaultExpression(block.content, tsModule, normalizedLang);
313
- if (parsed && hasSchematicsTypes) {
314
- const typeImport = `import type { ${configType} as __WeappConfig } from '@weapp-core/schematics'
315
- `;
316
- const helper = "const __weapp_defineConfig = <T extends __WeappConfig>(config: T) => config\n\n";
317
- embeddedCode.content.push([
318
- `${typeImport}${helper}`,
319
- void 0,
320
- 0,
321
- VOID_CAPABILITIES
322
- ]);
323
- if (parsed.leading) {
324
- embeddedCode.content.push([
325
- parsed.leading,
326
- block.name,
327
- 0,
328
- FULL_CAPABILITIES
329
- ]);
330
- }
331
- embeddedCode.content.push([
332
- "export default __weapp_defineConfig(",
333
- void 0,
334
- parsed.expressionStart,
335
- VOID_CAPABILITIES
336
- ]);
337
- embeddedCode.content.push([
338
- parsed.expression,
339
- block.name,
340
- parsed.expressionStart,
341
- FULL_CAPABILITIES
342
- ]);
343
- embeddedCode.content.push([
344
- ")",
345
- void 0,
346
- parsed.expressionEnd,
347
- VOID_CAPABILITIES
348
- ]);
349
- if (parsed.trailing) {
350
- embeddedCode.content.push([
351
- parsed.trailing,
352
- block.name,
353
- parsed.expressionEnd,
354
- FULL_CAPABILITIES
355
- ]);
356
- }
357
- return;
358
- }
359
- embeddedCode.content.push([
360
- block.content,
361
- block.name,
362
- 0,
363
- FULL_CAPABILITIES
364
- ]);
365
- return;
366
- }
367
- const schema = getSchemaForType(configType);
368
- if (schema && schema.$id && !block.content.includes("$schema")) {
369
- embeddedCode.content.push([
370
- injectSchemaIntoJsonObject(block.content, schema.$id),
371
- block.name,
372
- 0,
373
- FULL_CAPABILITIES
374
- ]);
375
- return;
376
- }
377
- embeddedCode.content.push([
378
- block.content,
379
- block.name,
380
- 0,
381
- FULL_CAPABILITIES
382
- ]);
383
- }
384
- };
187
+ /**
188
+ * Volar 语言插件:为 weapp 配置块提供类型与 schema 提示。
189
+ */
190
+ const plugin = (ctx) => {
191
+ let tsModule = ctx?.modules?.typescript;
192
+ if (!tsModule) try {
193
+ tsModule = require$1("typescript");
194
+ } catch {
195
+ tsModule = void 0;
196
+ }
197
+ return {
198
+ name,
199
+ version: PLUGIN_VERSION,
200
+ order: -1,
201
+ parseSFC2(fileName, languageId, content) {
202
+ if (languageId !== "vue") return;
203
+ const parsed = parseVueSfc(content, fileName);
204
+ if (!parsed) return;
205
+ const descriptor = parsed.descriptor;
206
+ const wxsModuleNames = collectWxsModuleNames(descriptor.template?.content);
207
+ if (!wxsModuleNames.length) return parsed;
208
+ if (descriptor.scriptSetup) descriptor.scriptSetup.content = appendWxsDeclarations(descriptor.scriptSetup.content, wxsModuleNames);
209
+ else descriptor.scriptSetup = createSyntheticScriptSetup(wxsModuleNames);
210
+ return parsed;
211
+ },
212
+ getEmbeddedCodes(_, sfc) {
213
+ const names = [];
214
+ for (let i = 0; i < sfc.customBlocks.length; i++) {
215
+ const block = sfc.customBlocks[i];
216
+ if (block.type === BLOCK_TYPE) {
217
+ const normalizedLang = normalizeLang(block.lang);
218
+ if (normalizedLang === JS_LANG || normalizedLang === TS_LANG) {
219
+ names.push({
220
+ id: `${BLOCK_TYPE}_${i}`,
221
+ lang: TS_LANG
222
+ });
223
+ continue;
224
+ }
225
+ const embeddedLang = normalizedLang === JSON_LANG || normalizedLang === JSONC_LANG || normalizedLang === JSON5_LANG ? JSONC_LANG : JSON_LANG;
226
+ names.push({
227
+ id: `${BLOCK_TYPE}_${i}`,
228
+ lang: embeddedLang
229
+ });
230
+ }
231
+ }
232
+ return names;
233
+ },
234
+ resolveEmbeddedCode(fileName, sfc, embeddedCode) {
235
+ const match = embeddedCode.id.match(new RegExp(`^${BLOCK_TYPE}_(\\d+)$`));
236
+ if (!match) return;
237
+ const index = Number.parseInt(match[1]);
238
+ const block = sfc.customBlocks[index];
239
+ if (!block) return;
240
+ const normalizedLang = normalizeLang(block.lang);
241
+ const configType = inferConfigType(fileName);
242
+ if (!hasSchematicsTypes) {
243
+ embeddedCode.content.push([
244
+ block.content,
245
+ block.name,
246
+ 0,
247
+ FULL_CAPABILITIES
248
+ ]);
249
+ return;
250
+ }
251
+ if (normalizedLang === JS_LANG || normalizedLang === TS_LANG) {
252
+ const parsed = tsModule && findExportDefaultExpression(block.content, tsModule, normalizedLang);
253
+ if (parsed && hasSchematicsTypes) {
254
+ const typeImport = `import type { ${configType} as __WeappConfig } from '@weapp-core/schematics'\n`;
255
+ embeddedCode.content.push([
256
+ `${typeImport}const __weapp_defineConfig = <T extends __WeappConfig>(config: T) => config
257
+
258
+ `,
259
+ void 0,
260
+ 0,
261
+ VOID_CAPABILITIES
262
+ ]);
263
+ if (parsed.leading) embeddedCode.content.push([
264
+ parsed.leading,
265
+ block.name,
266
+ 0,
267
+ FULL_CAPABILITIES
268
+ ]);
269
+ embeddedCode.content.push([
270
+ "export default __weapp_defineConfig(",
271
+ void 0,
272
+ parsed.expressionStart,
273
+ VOID_CAPABILITIES
274
+ ]);
275
+ embeddedCode.content.push([
276
+ parsed.expression,
277
+ block.name,
278
+ parsed.expressionStart,
279
+ FULL_CAPABILITIES
280
+ ]);
281
+ embeddedCode.content.push([
282
+ ")",
283
+ void 0,
284
+ parsed.expressionEnd,
285
+ VOID_CAPABILITIES
286
+ ]);
287
+ if (parsed.trailing) embeddedCode.content.push([
288
+ parsed.trailing,
289
+ block.name,
290
+ parsed.expressionEnd,
291
+ FULL_CAPABILITIES
292
+ ]);
293
+ return;
294
+ }
295
+ embeddedCode.content.push([
296
+ block.content,
297
+ block.name,
298
+ 0,
299
+ FULL_CAPABILITIES
300
+ ]);
301
+ return;
302
+ }
303
+ const schema = getSchemaForType(configType);
304
+ if (schema && schema.$id && !block.content.includes("$schema")) {
305
+ embeddedCode.content.push([
306
+ injectSchemaIntoJsonObject(block.content, schema.$id),
307
+ block.name,
308
+ 0,
309
+ FULL_CAPABILITIES
310
+ ]);
311
+ return;
312
+ }
313
+ embeddedCode.content.push([
314
+ block.content,
315
+ block.name,
316
+ 0,
317
+ FULL_CAPABILITIES
318
+ ]);
319
+ }
320
+ };
385
321
  };
386
- var index_default = plugin;
322
+ //#endregion
323
+ module.exports = plugin;