weapp-vite 6.0.0-alpha.2 → 6.0.0-alpha.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/README.md CHANGED
@@ -33,9 +33,9 @@
33
33
  ### Vue 项目
34
34
 
35
35
  ```typescript
36
+ import weappVite from '@weapp-vite/vite'
36
37
  // vite.config.ts
37
38
  import { defineConfig } from 'vite'
38
- import weappVite from '@weapp-vite/vite'
39
39
 
40
40
  export default defineConfig({
41
41
  plugins: [
@@ -53,23 +53,25 @@ export default defineConfig({
53
53
 
54
54
  ```vue
55
55
  <!-- App.vue -->
56
- <template>
57
- <view class="container">
58
- <text>{{ message }}</text>
59
- <button @click="handleClick">Click</button>
60
- </view>
61
- </template>
62
-
63
56
  <script setup>
64
57
  import { ref } from 'vue'
65
58
 
66
59
  const message = ref('Hello Vue in Mini-program!')
67
60
 
68
- const handleClick = () => {
61
+ function handleClick() {
69
62
  console.log('Button clicked!')
70
63
  }
71
64
  </script>
72
65
 
66
+ <template>
67
+ <view class="container">
68
+ <text>{{ message }}</text>
69
+ <button @click="handleClick">
70
+ Click
71
+ </button>
72
+ </view>
73
+ </template>
74
+
73
75
  <style scoped>
74
76
  .container {
75
77
  padding: 20rpx;
package/client.d.ts CHANGED
@@ -30,3 +30,19 @@ declare module 'process' {
30
30
  }
31
31
  }
32
32
  }
33
+
34
+ type __WEAPP_APP_JSON__ = import('@weapp-core/schematics').App
35
+ type __WEAPP_PAGE_JSON__ = import('@weapp-core/schematics').Page
36
+ type __WEAPP_COMPONENT_JSON__ = import('@weapp-core/schematics').Component
37
+
38
+ declare function defineAppJson(config: () => __WEAPP_APP_JSON__): () => __WEAPP_APP_JSON__
39
+ declare function defineAppJson(config: () => Promise<__WEAPP_APP_JSON__>): () => Promise<__WEAPP_APP_JSON__>
40
+ declare function defineAppJson(config: __WEAPP_APP_JSON__): __WEAPP_APP_JSON__
41
+
42
+ declare function definePageJson(config: () => __WEAPP_PAGE_JSON__): () => __WEAPP_PAGE_JSON__
43
+ declare function definePageJson(config: () => Promise<__WEAPP_PAGE_JSON__>): () => Promise<__WEAPP_PAGE_JSON__>
44
+ declare function definePageJson(config: __WEAPP_PAGE_JSON__): __WEAPP_PAGE_JSON__
45
+
46
+ declare function defineComponentJson(config: () => __WEAPP_COMPONENT_JSON__): () => __WEAPP_COMPONENT_JSON__
47
+ declare function defineComponentJson(config: () => Promise<__WEAPP_COMPONENT_JSON__>): () => Promise<__WEAPP_COMPONENT_JSON__>
48
+ declare function defineComponentJson(config: __WEAPP_COMPONENT_JSON__): __WEAPP_COMPONENT_JSON__
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkKBGC6ODZcjs = require('./chunk-KBGC6ODZ.cjs');
4
- require('./chunk-IEICAJDZ.cjs');
3
+ var _chunkEVZXCCHNcjs = require('./chunk-EVZXCCHN.cjs');
4
+ require('./chunk-R6Z72GR5.cjs');
5
5
  require('./chunk-E34K6TPD.cjs');
6
6
  require('./chunk-SJSLFDTA.cjs');
7
7
 
@@ -25,7 +25,7 @@ function createGetter(resolver) {
25
25
  get: resolver
26
26
  };
27
27
  }
28
- var ctx = _chunkKBGC6ODZcjs.getCompilerContext.call(void 0, );
28
+ var ctx = _chunkEVZXCCHNcjs.getCompilerContext.call(void 0, );
29
29
  var service = ctx.autoRoutesService;
30
30
  var routes = {};
31
31
  Object.defineProperties(routes, {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getCompilerContext
3
- } from "./chunk-IHHBS4DF.mjs";
4
- import "./chunk-MK4LDVBT.mjs";
3
+ } from "./chunk-ZAAP7JAU.mjs";
4
+ import "./chunk-AYB4WOZM.mjs";
5
5
  import "./chunk-YXFADQPY.mjs";
6
6
  import "./chunk-O6633IWP.mjs";
7
7
  import {
@@ -144,18 +144,21 @@ async function extractConfigFromVue(vueFilePath) {
144
144
  if (errors.length > 0) {
145
145
  return void 0;
146
146
  }
147
- const configBlocks = descriptor.customBlocks.filter((block) => block.type === "config");
148
- if (!configBlocks.length) {
147
+ const jsonBlocks = descriptor.customBlocks.filter((block) => block.type === "json");
148
+ if (!jsonBlocks.length) {
149
149
  return void 0;
150
150
  }
151
151
  const mergedConfig = {};
152
152
  const { parse: parseJson } = await import("comment-json");
153
- for (const block of configBlocks) {
153
+ for (const block of jsonBlocks) {
154
154
  try {
155
- const lang = block.lang || "json";
156
- if (lang === "json" || lang === "json5" || lang === "jsonc") {
155
+ const lang = (block.lang || "json").toLowerCase();
156
+ if (lang === "json" || lang === "jsonc" || lang === "json5" || lang === "txt") {
157
157
  const config = parseJson(block.content, void 0, true);
158
- Object.assign(mergedConfig, config);
158
+ if (config && typeof config === "object" && !Array.isArray(config)) {
159
+ Object.assign(mergedConfig, config);
160
+ }
161
+ continue;
159
162
  }
160
163
  } catch {
161
164
  }