weapp-vite 1.9.0 → 1.9.1

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/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="vite/client" />
2
2
 
3
- type MP_PLATFORM = 'weapp'
3
+ type MP_PLATFORM = 'weapp' | 'alipay' | 'tt'
4
4
 
5
5
  interface ImportMetaEnv {
6
6
  MP_PLATFORM: MP_PLATFORM // | 'swan' | 'alipay' | 'tt' | 'qq' | 'jd' | 'h5'
@@ -1,7 +1,7 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { RollupOutput, RollupWatcher } from 'rollup';
3
- import { a as ResolvedValue } from './types-D7SAXpSN.js';
4
- import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, C as CompilerContextOptions, a as SubPackage } from './config-C0N6oM5k.js';
3
+ import { R as ResolvedValue } from './types-dS68tjL6.cjs';
4
+ import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, a as ComponentsMap, C as CompilerContextOptions, b as SubPackage } from './config-D__5C2s3.cjs';
5
5
  import { InlineConfig } from 'vite';
6
6
  import { Options } from 'tsup';
7
7
 
@@ -13,12 +13,6 @@ interface OutputExtensions {
13
13
  wxs?: string;
14
14
  }
15
15
 
16
- interface ScanComponentItem {
17
- start: number;
18
- end: number;
19
- }
20
- type ComponentsMap = Record<string, ScanComponentItem[]>;
21
-
22
16
  declare class CompilerContext {
23
17
  /**
24
18
  * loadDefaultConfig 的时候会被重新赋予
@@ -46,10 +40,36 @@ declare class CompilerContext {
46
40
  */
47
41
  defineEnv: Record<string, any>;
48
42
  wxmlComponentsMap: Map<string, ComponentsMap>;
43
+ /**
44
+ * CompilerContext 类的构造函数,用于初始化编译上下文。
45
+ * @param options - 可选的编译上下文选项,包括当前工作目录、是否为开发环境、内联配置、项目配置、模式、package.json 和平台等信息。
46
+ * 如果未提供选项,则使用默认值进行初始化。
47
+ * @property cwd - 当前工作目录。
48
+ * @property inlineConfig - 内联配置。
49
+ * @property isDev - 是否为开发环境。
50
+ * @property projectConfig - 项目配置。
51
+ * @property mode - 编译模式。
52
+ * @property packageJson - package.json 文件内容。
53
+ * @property rollupWatcherMap - Rollup 监视器映射。
54
+ * @property subPackageMeta - 子包元数据。
55
+ * @property entriesSet - 入口文件集合。
56
+ * @property entries - 入口文件数组。
57
+ * @property potentialComponentMap - 潜在组件映射。
58
+ * @property aliasEntries - 别名入口数组。
59
+ * @property platform - 平台类型。
60
+ * @property outputExtensions - 输出文件扩展名。
61
+ * @property defineEnv - 定义的环境变量。
62
+ * @property wxmlComponentsMap - WXML 组件映射。
63
+ */
49
64
  constructor(options?: CompilerContextOptions);
50
65
  /**
51
66
  * 插件真正计算出来的 define options
52
67
  */
68
+ /**
69
+ * 获取编译上下文中的环境变量定义,用于在小程序环境中暴露全局变量。
70
+ * 该函数将当前平台、用户自定义的环境变量合并,并将其转换为 import.meta.env 对象的属性。
71
+ * @returns {Record<string, any>} 包含所有环境变量的对象,键为 import.meta.env 下的属性名,值为对应的环境变量值。
72
+ */
53
73
  get defineImportMetaEnv(): Record<string, any>;
54
74
  setDefineEnv(key: string, value: any): void;
55
75
  get srcRoot(): string;
@@ -78,6 +98,16 @@ declare class CompilerContext {
78
98
  resolvedComponentName(entry: string): string | undefined;
79
99
  scanPotentialComponentEntries(filePath: string): Promise<void>;
80
100
  scanAppEntry(): Promise<AppEntry | undefined>;
101
+ /**
102
+ * 扫描并处理组件入口文件。
103
+ * @param componentEntry 组件入口文件名
104
+ * @param dirname 当前目录路径
105
+ * @param subPackageMeta 分包元信息(可选)
106
+ * @returns Promise<void>
107
+ *
108
+ * 该函数用于扫描并处理组件入口文件,包括查找 JS 入口、JSON 配置文件、模板入口等。
109
+ * 同时处理引入组件的情况,自动注入 usingComponents。
110
+ */
81
111
  scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
82
112
  setRollupWatcher(watcher: RollupWatcher, root?: string): void;
83
113
  autoImportFilter(id: string, meta?: SubPackageMetaValue): boolean;
@@ -1,7 +1,7 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { RollupOutput, RollupWatcher } from 'rollup';
3
- import { a as ResolvedValue } from './types-D7SAXpSN.cjs';
4
- import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, C as CompilerContextOptions, a as SubPackage } from './config-Cs01aZpF.cjs';
3
+ import { R as ResolvedValue } from './types-dS68tjL6.js';
4
+ import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, a as ComponentsMap, C as CompilerContextOptions, b as SubPackage } from './config-YkkDB5_Y.js';
5
5
  import { InlineConfig } from 'vite';
6
6
  import { Options } from 'tsup';
7
7
 
@@ -13,12 +13,6 @@ interface OutputExtensions {
13
13
  wxs?: string;
14
14
  }
15
15
 
16
- interface ScanComponentItem {
17
- start: number;
18
- end: number;
19
- }
20
- type ComponentsMap = Record<string, ScanComponentItem[]>;
21
-
22
16
  declare class CompilerContext {
23
17
  /**
24
18
  * loadDefaultConfig 的时候会被重新赋予
@@ -46,10 +40,36 @@ declare class CompilerContext {
46
40
  */
47
41
  defineEnv: Record<string, any>;
48
42
  wxmlComponentsMap: Map<string, ComponentsMap>;
43
+ /**
44
+ * CompilerContext 类的构造函数,用于初始化编译上下文。
45
+ * @param options - 可选的编译上下文选项,包括当前工作目录、是否为开发环境、内联配置、项目配置、模式、package.json 和平台等信息。
46
+ * 如果未提供选项,则使用默认值进行初始化。
47
+ * @property cwd - 当前工作目录。
48
+ * @property inlineConfig - 内联配置。
49
+ * @property isDev - 是否为开发环境。
50
+ * @property projectConfig - 项目配置。
51
+ * @property mode - 编译模式。
52
+ * @property packageJson - package.json 文件内容。
53
+ * @property rollupWatcherMap - Rollup 监视器映射。
54
+ * @property subPackageMeta - 子包元数据。
55
+ * @property entriesSet - 入口文件集合。
56
+ * @property entries - 入口文件数组。
57
+ * @property potentialComponentMap - 潜在组件映射。
58
+ * @property aliasEntries - 别名入口数组。
59
+ * @property platform - 平台类型。
60
+ * @property outputExtensions - 输出文件扩展名。
61
+ * @property defineEnv - 定义的环境变量。
62
+ * @property wxmlComponentsMap - WXML 组件映射。
63
+ */
49
64
  constructor(options?: CompilerContextOptions);
50
65
  /**
51
66
  * 插件真正计算出来的 define options
52
67
  */
68
+ /**
69
+ * 获取编译上下文中的环境变量定义,用于在小程序环境中暴露全局变量。
70
+ * 该函数将当前平台、用户自定义的环境变量合并,并将其转换为 import.meta.env 对象的属性。
71
+ * @returns {Record<string, any>} 包含所有环境变量的对象,键为 import.meta.env 下的属性名,值为对应的环境变量值。
72
+ */
53
73
  get defineImportMetaEnv(): Record<string, any>;
54
74
  setDefineEnv(key: string, value: any): void;
55
75
  get srcRoot(): string;
@@ -78,6 +98,16 @@ declare class CompilerContext {
78
98
  resolvedComponentName(entry: string): string | undefined;
79
99
  scanPotentialComponentEntries(filePath: string): Promise<void>;
80
100
  scanAppEntry(): Promise<AppEntry | undefined>;
101
+ /**
102
+ * 扫描并处理组件入口文件。
103
+ * @param componentEntry 组件入口文件名
104
+ * @param dirname 当前目录路径
105
+ * @param subPackageMeta 分包元信息(可选)
106
+ * @returns Promise<void>
107
+ *
108
+ * 该函数用于扫描并处理组件入口文件,包括查找 JS 入口、JSON 配置文件、模板入口等。
109
+ * 同时处理引入组件的情况,自动注入 usingComponents。
110
+ */
81
111
  scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
82
112
  setRollupWatcher(watcher: RollupWatcher, root?: string): void;
83
113
  autoImportFilter(id: string, meta?: SubPackageMetaValue): boolean;
@@ -1,5 +1,5 @@
1
- import { C as CreateResolver } from '../types-D7SAXpSN.cjs';
2
- export { O as Options, a as ResolvedValue, R as Resolver } from '../types-D7SAXpSN.cjs';
1
+ import { C as CreateResolver } from '../types-dS68tjL6.cjs';
2
+ export { O as Options, R as ResolvedValue, a as Resolver } from '../types-dS68tjL6.cjs';
3
3
 
4
4
  declare const TDesignResolver: CreateResolver;
5
5
 
@@ -1,5 +1,5 @@
1
- import { C as CreateResolver } from '../types-D7SAXpSN.js';
2
- export { O as Options, a as ResolvedValue, R as Resolver } from '../types-D7SAXpSN.js';
1
+ import { C as CreateResolver } from '../types-dS68tjL6.js';
2
+ export { O as Options, R as ResolvedValue, a as Resolver } from '../types-dS68tjL6.js';
3
3
 
4
4
  declare const TDesignResolver: CreateResolver;
5
5
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "../chunk-D64WYHZN.mjs";
3
+ } from "../chunk-JQSQ7TXP.mjs";
4
4
 
5
5
  // src/auto-import-components/resolvers/index.ts
6
6
  init_esm_shims();