@weapp-vite/web 1.4.20 → 1.5.0

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.
Files changed (95) hide show
  1. package/README.md +1 -1
  2. package/dist/compiler/wxml/attributes.mjs +5 -3
  3. package/dist/compiler/wxml/attributes.mjs.map +1 -1
  4. package/dist/compiler/wxml/compile.mjs +6 -1
  5. package/dist/compiler/wxml/compile.mjs.map +1 -1
  6. package/dist/compiler/wxml/types.d.mts +1 -2
  7. package/dist/css/wxss.d.mts +3 -4
  8. package/dist/index.d.mts +5 -3
  9. package/dist/index.mjs +4 -3
  10. package/dist/plugin/assets.d.mts +1 -2
  11. package/dist/plugin/constants.mjs +2 -1
  12. package/dist/plugin/constants.mjs.map +1 -1
  13. package/dist/plugin/index.d.mts +2 -2
  14. package/dist/plugin/index.mjs +7 -2
  15. package/dist/plugin/index.mjs.map +1 -1
  16. package/dist/plugin/register.mjs +20 -5
  17. package/dist/plugin/register.mjs.map +1 -1
  18. package/dist/plugin/types.d.mts +5 -6
  19. package/dist/runtime/button/index.d.mts +3 -4
  20. package/dist/runtime/component/constants.mjs +9 -1
  21. package/dist/runtime/component/constants.mjs.map +1 -1
  22. package/dist/runtime/component/element.mjs +24 -4
  23. package/dist/runtime/component/element.mjs.map +1 -1
  24. package/dist/runtime/component/events.mjs +6 -4
  25. package/dist/runtime/component/events.mjs.map +1 -1
  26. package/dist/runtime/component/index.d.mts +2 -2
  27. package/dist/runtime/component/types.d.mts +13 -14
  28. package/dist/runtime/eventBinding.d.mts +16 -0
  29. package/dist/runtime/eventBinding.mjs +51 -0
  30. package/dist/runtime/eventBinding.mjs.map +1 -0
  31. package/dist/runtime/execution.d.mts +3 -4
  32. package/dist/runtime/host/index.d.mts +9 -9
  33. package/dist/runtime/host/types.d.mts +4 -5
  34. package/dist/runtime/hostGlobals.d.mts +1 -2
  35. package/dist/runtime/index.d.mts +5 -3
  36. package/dist/runtime/index.mjs +4 -3
  37. package/dist/runtime/index.mjs.map +1 -1
  38. package/dist/runtime/inputHandlerResult.mjs +22 -0
  39. package/dist/runtime/inputHandlerResult.mjs.map +1 -0
  40. package/dist/runtime/legacyTemplate/dom.mjs +27 -9
  41. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  42. package/dist/runtime/legacyTemplate/index.d.mts +2 -3
  43. package/dist/runtime/legacyTemplate/types.d.mts +2 -3
  44. package/dist/runtime/nativeComponents/form.d.mts +1 -2
  45. package/dist/runtime/nativeComponents/image.d.mts +1 -2
  46. package/dist/runtime/nativeComponents/index.d.mts +2 -2
  47. package/dist/runtime/nativeComponents/input.d.mts +1 -2
  48. package/dist/runtime/nativeComponents/input.mjs +3 -1
  49. package/dist/runtime/nativeComponents/input.mjs.map +1 -1
  50. package/dist/runtime/nativeComponents/scrollView.d.mts +1 -2
  51. package/dist/runtime/nativeComponents/scrollView.mjs +21 -12
  52. package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -1
  53. package/dist/runtime/nativeComponents/switch.d.mts +1 -2
  54. package/dist/runtime/nativeComponents/textarea.d.mts +1 -2
  55. package/dist/runtime/nativeComponents/video/helpers.d.mts +3 -4
  56. package/dist/runtime/navigationBar/index.d.mts +2 -2
  57. package/dist/runtime/pageLayout.d.mts +2 -3
  58. package/dist/runtime/polyfill/async.d.mts +1 -2
  59. package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +27 -28
  60. package/dist/runtime/polyfill/index.d.mts +17 -16
  61. package/dist/runtime/polyfill/index.mjs +6 -2
  62. package/dist/runtime/polyfill/index.mjs.map +1 -1
  63. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +53 -7
  64. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -1
  65. package/dist/runtime/polyfill/routeRuntime/history.d.mts +8 -9
  66. package/dist/runtime/polyfill/routeRuntime/options.d.mts +14 -10
  67. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
  68. package/dist/runtime/polyfill/routeRuntime.d.mts +17 -13
  69. package/dist/runtime/polyfill/routeRuntime.mjs +13 -1
  70. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  71. package/dist/runtime/polyfill/runtimeDataApi.d.mts +28 -29
  72. package/dist/runtime/polyfill/types/base.d.mts +2 -3
  73. package/dist/runtime/polyfill/types/common.d.mts +26 -27
  74. package/dist/runtime/polyfill/types/locationRuntime.d.mts +34 -35
  75. package/dist/runtime/polyfill/types/mediaAuth.d.mts +34 -35
  76. package/dist/runtime/polyfill/types/platformRuntime.d.mts +25 -26
  77. package/dist/runtime/polyfill/types/systemAuth.d.mts +22 -23
  78. package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +5 -6
  79. package/dist/runtime/polyfill/uiMediaApi.d.mts +42 -43
  80. package/dist/runtime/polyfill.d.mts +3 -2
  81. package/dist/runtime/renderContext.d.mts +2 -3
  82. package/dist/runtime/renderContext.mjs +2 -1
  83. package/dist/runtime/renderContext.mjs.map +1 -1
  84. package/dist/runtime/rpx.d.mts +2 -3
  85. package/dist/runtime/seo/index.d.mts +11 -11
  86. package/dist/runtime/style.d.mts +2 -3
  87. package/dist/runtime/template.d.mts +3 -3
  88. package/dist/runtime/viewport/index.d.mts +4 -4
  89. package/dist/runtime/viewport/types.d.mts +2 -3
  90. package/dist/runtime/warning.d.mts +3 -4
  91. package/dist/runtime/wevu.d.mts +7 -4
  92. package/dist/runtime/wevu.mjs +13 -2
  93. package/dist/runtime/wevu.mjs.map +1 -1
  94. package/dist/shared/tabBar.d.mts +2 -3
  95. package/package.json +20 -12
@@ -6,18 +6,18 @@ import { OpenDocumentOptions, ShowActionSheetOptions, ShowModalOptions } from ".
6
6
  import { SetTabBarBadgeOptions, SetTabBarItemOptions, SetTabBarStyleOptions, TabBarIndexOptions, TabBarOptions } from "./types/tabBarRuntime.mjs";
7
7
  import { MiniProgramBaseResultLike } from "./async.mjs";
8
8
  //#region src/runtime/polyfill/uiMediaApi.d.ts
9
- declare function showToast(options?: ShowToastOptions): Promise<any>;
10
- declare function showLoading(options?: ShowLoadingOptions): Promise<any>;
11
- declare function hideLoading(options?: MiniProgramAsyncOptions<MiniProgramBaseResult>): Promise<any>;
12
- declare function showShareMenu(options?: ShareMenuOptions): Promise<any>;
13
- declare function updateShareMenu(options?: ShareMenuOptions): Promise<any>;
14
- declare function openCustomerServiceChat(options?: OpenCustomerServiceChatOptions): Promise<{
9
+ export declare function showToast(options?: ShowToastOptions): Promise<any>;
10
+ export declare function showLoading(options?: ShowLoadingOptions): Promise<any>;
11
+ export declare function hideLoading(options?: MiniProgramAsyncOptions<MiniProgramBaseResult>): Promise<any>;
12
+ export declare function showShareMenu(options?: ShareMenuOptions): Promise<any>;
13
+ export declare function updateShareMenu(options?: ShareMenuOptions): Promise<any>;
14
+ export declare function openCustomerServiceChat(options?: OpenCustomerServiceChatOptions): Promise<{
15
15
  errMsg: string;
16
16
  }>;
17
- declare function makePhoneCall(options?: MakePhoneCallOptions): Promise<{
17
+ export declare function makePhoneCall(options?: MakePhoneCallOptions): Promise<{
18
18
  errMsg: string;
19
19
  }>;
20
- declare function chooseAddress(options?: ChooseAddressOptions): Promise<{
20
+ export declare function chooseAddress(options?: ChooseAddressOptions): Promise<{
21
21
  userName: string;
22
22
  postalCode: string;
23
23
  provinceName: string;
@@ -28,18 +28,18 @@ declare function chooseAddress(options?: ChooseAddressOptions): Promise<{
28
28
  telNumber: string;
29
29
  errMsg: string;
30
30
  }>;
31
- declare function chooseLocation(options?: ChooseLocationOptions): Promise<{
31
+ export declare function chooseLocation(options?: ChooseLocationOptions): Promise<{
32
32
  name: string;
33
33
  address: string;
34
34
  latitude: number;
35
35
  longitude: number;
36
36
  errMsg: string;
37
37
  }>;
38
- declare function openLocation(options?: OpenLocationOptions): Promise<{
38
+ export declare function openLocation(options?: OpenLocationOptions): Promise<{
39
39
  errMsg: string;
40
40
  }>;
41
- declare function getImageInfo(options?: GetImageInfoOptions): Promise<MiniProgramBaseResultLike>;
42
- declare function getVideoInfo(options?: GetVideoInfoOptions): Promise<{
41
+ export declare function getImageInfo(options?: GetImageInfoOptions): Promise<MiniProgramBaseResultLike>;
42
+ export declare function getVideoInfo(options?: GetVideoInfoOptions): Promise<{
43
43
  errMsg: string;
44
44
  orientation: string;
45
45
  type: string;
@@ -50,19 +50,19 @@ declare function getVideoInfo(options?: GetVideoInfoOptions): Promise<{
50
50
  bitrate: number;
51
51
  fps: number;
52
52
  }>;
53
- declare function showTabBar(options?: TabBarOptions): Promise<any>;
54
- declare function hideTabBar(options?: TabBarOptions): Promise<any>;
55
- declare function setTabBarItem(options: SetTabBarItemOptions): Promise<any>;
56
- declare function setTabBarStyle(options: SetTabBarStyleOptions): Promise<any>;
57
- declare function setTabBarBadge(options: SetTabBarBadgeOptions): Promise<any>;
58
- declare function removeTabBarBadge(options: TabBarIndexOptions): Promise<any>;
59
- declare function showTabBarRedDot(options: TabBarIndexOptions): Promise<any>;
60
- declare function hideTabBarRedDot(options: TabBarIndexOptions): Promise<any>;
61
- declare function requestPayment(options?: RequestPaymentOptions): Promise<any>;
62
- declare function requestSubscribeMessage(options?: RequestSubscribeMessageOptions): Promise<RequestSubscribeMessageSuccessResult>;
63
- declare function showModal(options?: ShowModalOptions): Promise<any>;
64
- declare function showActionSheet(options?: ShowActionSheetOptions): Promise<any>;
65
- declare function chooseImage(options?: ChooseImageOptions): Promise<{
53
+ export declare function showTabBar(options?: TabBarOptions): Promise<any>;
54
+ export declare function hideTabBar(options?: TabBarOptions): Promise<any>;
55
+ export declare function setTabBarItem(options: SetTabBarItemOptions): Promise<any>;
56
+ export declare function setTabBarStyle(options: SetTabBarStyleOptions): Promise<any>;
57
+ export declare function setTabBarBadge(options: SetTabBarBadgeOptions): Promise<any>;
58
+ export declare function removeTabBarBadge(options: TabBarIndexOptions): Promise<any>;
59
+ export declare function showTabBarRedDot(options: TabBarIndexOptions): Promise<any>;
60
+ export declare function hideTabBarRedDot(options: TabBarIndexOptions): Promise<any>;
61
+ export declare function requestPayment(options?: RequestPaymentOptions): Promise<any>;
62
+ export declare function requestSubscribeMessage(options?: RequestSubscribeMessageOptions): Promise<RequestSubscribeMessageSuccessResult>;
63
+ export declare function showModal(options?: ShowModalOptions): Promise<any>;
64
+ export declare function showActionSheet(options?: ShowActionSheetOptions): Promise<any>;
65
+ export declare function chooseImage(options?: ChooseImageOptions): Promise<{
66
66
  errMsg: string;
67
67
  tempFilePaths: string[];
68
68
  tempFiles: {
@@ -72,7 +72,7 @@ declare function chooseImage(options?: ChooseImageOptions): Promise<{
72
72
  name: string;
73
73
  }[];
74
74
  }>;
75
- declare function chooseMedia(options?: ChooseMediaOptions): Promise<{
75
+ export declare function chooseMedia(options?: ChooseMediaOptions): Promise<{
76
76
  errMsg: string;
77
77
  type: "image" | "video";
78
78
  tempFiles: {
@@ -84,11 +84,11 @@ declare function chooseMedia(options?: ChooseMediaOptions): Promise<{
84
84
  duration: number;
85
85
  }[];
86
86
  }>;
87
- declare function compressImage(options?: CompressImageOptions): Promise<{
87
+ export declare function compressImage(options?: CompressImageOptions): Promise<{
88
88
  errMsg: string;
89
89
  tempFilePath: string;
90
90
  }>;
91
- declare function compressVideo(options?: CompressVideoOptions): Promise<{
91
+ export declare function compressVideo(options?: CompressVideoOptions): Promise<{
92
92
  tempFilePath: any;
93
93
  size: number;
94
94
  duration: number;
@@ -98,7 +98,7 @@ declare function compressVideo(options?: CompressVideoOptions): Promise<{
98
98
  fps: number;
99
99
  errMsg: string;
100
100
  }>;
101
- declare function chooseVideo(options?: ChooseVideoOptions): Promise<{
101
+ export declare function chooseVideo(options?: ChooseVideoOptions): Promise<{
102
102
  tempFilePath: string;
103
103
  duration: number;
104
104
  size: number;
@@ -106,7 +106,7 @@ declare function chooseVideo(options?: ChooseVideoOptions): Promise<{
106
106
  width: number;
107
107
  errMsg: string;
108
108
  }>;
109
- declare function chooseMessageFile(options?: ChooseMessageFileOptions): Promise<{
109
+ export declare function chooseMessageFile(options?: ChooseMessageFileOptions): Promise<{
110
110
  errMsg: string;
111
111
  tempFiles: {
112
112
  path: string;
@@ -116,7 +116,7 @@ declare function chooseMessageFile(options?: ChooseMessageFileOptions): Promise<
116
116
  time: number;
117
117
  }[];
118
118
  }>;
119
- declare function chooseFile(options?: ChooseFileOptions): Promise<{
119
+ export declare function chooseFile(options?: ChooseFileOptions): Promise<{
120
120
  errMsg: string;
121
121
  tempFiles: {
122
122
  path: string;
@@ -126,33 +126,33 @@ declare function chooseFile(options?: ChooseFileOptions): Promise<{
126
126
  time: number;
127
127
  }[];
128
128
  }>;
129
- declare function previewImage(options?: PreviewImageOptions): Promise<{
129
+ export declare function previewImage(options?: PreviewImageOptions): Promise<{
130
130
  errMsg: string;
131
131
  }>;
132
- declare function previewMedia(options?: PreviewMediaOptions): Promise<{
132
+ export declare function previewMedia(options?: PreviewMediaOptions): Promise<{
133
133
  errMsg: string;
134
134
  }>;
135
- declare function openVideoEditor(options?: OpenVideoEditorOptions): Promise<{
135
+ export declare function openVideoEditor(options?: OpenVideoEditorOptions): Promise<{
136
136
  errMsg: string;
137
137
  tempFilePath: any;
138
138
  }>;
139
- declare function saveImageToPhotosAlbum(options?: SaveImageToPhotosAlbumOptions): Promise<{
139
+ export declare function saveImageToPhotosAlbum(options?: SaveImageToPhotosAlbumOptions): Promise<{
140
140
  errMsg: string;
141
141
  }>;
142
- declare function saveVideoToPhotosAlbum(options?: SaveVideoToPhotosAlbumOptions): Promise<{
142
+ export declare function saveVideoToPhotosAlbum(options?: SaveVideoToPhotosAlbumOptions): Promise<{
143
143
  errMsg: string;
144
144
  }>;
145
- declare function saveFile(options?: SaveFileOptions): Promise<{
145
+ export declare function saveFile(options?: SaveFileOptions): Promise<{
146
146
  errMsg: string;
147
147
  savedFilePath: string;
148
148
  }>;
149
- declare function saveFileToDisk(options?: SaveFileToDiskOptions): Promise<{
149
+ export declare function saveFileToDisk(options?: SaveFileToDiskOptions): Promise<{
150
150
  errMsg: string;
151
151
  }>;
152
- declare function openDocument(options?: OpenDocumentOptions): Promise<{
152
+ export declare function openDocument(options?: OpenDocumentOptions): Promise<{
153
153
  errMsg: string;
154
154
  }>;
155
- declare function scanCode(options?: ScanCodeOptions): Promise<{
155
+ export declare function scanCode(options?: ScanCodeOptions): Promise<{
156
156
  errMsg: string;
157
157
  result: string;
158
158
  scanType: string;
@@ -160,13 +160,12 @@ declare function scanCode(options?: ScanCodeOptions): Promise<{
160
160
  path: string;
161
161
  rawData: string;
162
162
  }>;
163
- declare function setClipboardData(options?: SetClipboardDataOptions): Promise<{
163
+ export declare function setClipboardData(options?: SetClipboardDataOptions): Promise<{
164
164
  errMsg: string;
165
165
  }>;
166
- declare function getClipboardData(options?: GetClipboardDataOptions): Promise<{
166
+ export declare function getClipboardData(options?: GetClipboardDataOptions): Promise<{
167
167
  errMsg: string;
168
168
  data: string;
169
169
  }>;
170
170
  //#endregion
171
- export { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu };
172
171
  //# sourceMappingURL=uiMediaApi.d.mts.map
@@ -1,6 +1,7 @@
1
+ import { AppHideCallback, AppHideOptions, AppLaunchOptions, AppShowCallback } from "./polyfill/routeRuntime/options.mjs";
1
2
  import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./polyfill/deviceAuthSystemApi.mjs";
2
- import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
3
+ import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
3
4
  import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./polyfill/runtimeDataApi.mjs";
4
5
  import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
5
6
  import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
6
- export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRewardedVideoAd, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setClipboardData, setNavigationBarColor, setNavigationBarTitle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
7
+ export { type AppHideCallback, type AppHideOptions, type AppLaunchOptions, type AppShowCallback, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, createCanvasContext, createInterstitialAd, createRewardedVideoAd, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppShow, offNetworkStatusChange, offWindowResize, onAppHide, onAppShow, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, request, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setClipboardData, setNavigationBarColor, setNavigationBarTitle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, updateShareMenu, uploadFile, vibrateShort };
@@ -2,7 +2,7 @@ import { TemplateScope } from "./template.mjs";
2
2
  import { ComponentPublicInstance } from "./component/types.mjs";
3
3
  import "./component/index.mjs";
4
4
  //#region src/runtime/renderContext.d.ts
5
- interface RenderContext {
5
+ export interface RenderContext {
6
6
  instance: ComponentPublicInstance;
7
7
  eval: (expression: string, scope: TemplateScope, wxs?: Record<string, any>) => any;
8
8
  createScope: (parent: TemplateScope, locals?: Record<string, any>) => TemplateScope;
@@ -16,7 +16,6 @@ interface RenderContext {
16
16
  }) => (event: Event) => void;
17
17
  createWxsModule: (code: string, id: string, requireMap?: Record<string, any>) => Record<string, any>;
18
18
  }
19
- declare function createRenderContext(instance: ComponentPublicInstance, methods: Record<string, (event: any) => any>): RenderContext;
19
+ export declare function createRenderContext(instance: ComponentPublicInstance, methods: Record<string, (event: any) => any>): RenderContext;
20
20
  //#endregion
21
- export { RenderContext, createRenderContext };
22
21
  //# sourceMappingURL=renderContext.d.mts.map
@@ -1,5 +1,6 @@
1
1
  import { emitRuntimeWarning } from "./warning.mjs";
2
2
  import { getRuntimeExecutionMode, warnRuntimeExecutionOnce } from "./execution.mjs";
3
+ import { invokeMiniProgramEventHandler } from "./inputHandlerResult.mjs";
3
4
 
4
5
  //#region src/runtime/renderContext.ts
5
6
  const expressionCache = /* @__PURE__ */ new Map();
@@ -80,7 +81,7 @@ function createEventHandler(instance, methods, eventName, handlerRef, flags) {
80
81
  currentTarget: { dataset },
81
82
  originalEvent: nativeEvent
82
83
  };
83
- handler.call(instance, syntheticEvent);
84
+ invokeMiniProgramEventHandler(handler, instance, syntheticEvent, nativeEvent);
84
85
  };
85
86
  }
86
87
  function createWxsModule(code, id, requireMap) {
@@ -1 +1 @@
1
- {"version":3,"file":"renderContext.mjs","names":[],"sources":["../../src/runtime/renderContext.ts"],"sourcesContent":["import type { ComponentPublicInstance } from './component'\nimport type { TemplateScope } from './template'\nimport { getRuntimeExecutionMode, warnRuntimeExecutionOnce } from './execution'\nimport { emitRuntimeWarning } from './warning'\n\nexport interface RenderContext {\n instance: ComponentPublicInstance\n eval: (expression: string, scope: TemplateScope, wxs?: Record<string, any>) => any\n createScope: (parent: TemplateScope, locals?: Record<string, any>) => TemplateScope\n mergeScope: (parent: TemplateScope, data?: any) => TemplateScope\n normalizeList: (value: any) => any[]\n key: (rawKey: string, item: any, index: number, scope: TemplateScope, wxs?: Record<string, any>) => any\n renderTemplate: (templates: Record<string, any>, name: any, scope: TemplateScope, ctx: RenderContext) => any\n event: (eventName: string, handlerName: any, scope: TemplateScope, wxs?: Record<string, any>, flags?: { catch?: boolean, capture?: boolean }) => (event: Event) => void\n createWxsModule: (code: string, id: string, requireMap?: Record<string, any>) => Record<string, any>\n}\n\nconst expressionCache = new Map<string, (scope: TemplateScope) => any>()\nconst MUSTACHE_PREFIX_RE = /^\\{\\{\\s*/\nconst MUSTACHE_SUFFIX_RE = /\\s*\\}\\}$/\nconst SIMPLE_KEY_PATH_RE = /[.[()]/\n\nfunction createScope(initial?: TemplateScope): TemplateScope {\n return Object.assign(Object.create(null), initial ?? {})\n}\n\nfunction createChildScope(parent: TemplateScope, locals?: Record<string, any>): TemplateScope {\n return Object.assign(Object.create(parent), locals ?? {})\n}\n\nfunction evaluateExpression(expression: string, scope: TemplateScope): any {\n if (!expression) {\n return undefined\n }\n const trimmed = expression.trim()\n if (!trimmed) {\n return undefined\n }\n let evaluator = expressionCache.get(trimmed)\n if (!evaluator) {\n try {\n // eslint-disable-next-line no-new-func -- dynamic expressions are required for template evaluation\n evaluator = new Function('scope', `with(scope){ return (${trimmed}); }`) as (scope: TemplateScope) => any\n }\n catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n const mode = getRuntimeExecutionMode()\n if (mode === 'safe') {\n warnRuntimeExecutionOnce(\n `safe-expression-parse:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式解析错误 \"${trimmed}\": ${reason}`,\n )\n evaluator = () => undefined\n }\n else {\n throw new SyntaxError(`[@weapp-vite/web] 无法解析表达式 \"${trimmed}\": ${reason}`)\n }\n }\n expressionCache.set(trimmed, evaluator)\n }\n try {\n return evaluator?.(scope)\n }\n catch (error) {\n const mode = getRuntimeExecutionMode()\n if (mode === 'strict') {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(`[@weapp-vite/web] strict 模式下表达式执行失败 \"${trimmed}\": ${reason}`)\n }\n if (mode === 'safe') {\n const reason = error instanceof Error ? error.message : String(error)\n warnRuntimeExecutionOnce(\n `safe-expression-runtime:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式执行错误 \"${trimmed}\": ${reason}`,\n )\n }\n return undefined\n }\n}\n\nfunction normalizeList(value: any): any[] {\n if (Array.isArray(value)) {\n return value\n }\n if (value == null) {\n return []\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n const length = Math.max(0, Math.floor(value))\n return Array.from({ length }, (_, index) => index)\n }\n if (typeof value === 'object') {\n return Object.values(value)\n }\n return []\n}\n\nfunction normalizeKey(rawKey: string, item: any, index: number, scope: TemplateScope): any {\n const key = rawKey?.trim()\n if (!key) {\n if (item != null && (typeof item === 'string' || typeof item === 'number' || typeof item === 'boolean')) {\n return item\n }\n return index\n }\n if (key === '*this') {\n return item\n }\n if (key.includes('{{') && key.includes('}}')) {\n const expr = key.replace(MUSTACHE_PREFIX_RE, '').replace(MUSTACHE_SUFFIX_RE, '')\n return evaluateExpression(expr, scope)\n }\n if (!SIMPLE_KEY_PATH_RE.test(key) && item && typeof item === 'object' && key in item) {\n return (item as Record<string, any>)[key]\n }\n return evaluateExpression(key, scope)\n}\n\nfunction createEventHandler(\n instance: ComponentPublicInstance,\n methods: Record<string, (event: any) => any>,\n eventName: string,\n handlerRef: string | ((event: any) => any),\n flags?: { catch?: boolean },\n) {\n const handler = typeof handlerRef === 'function'\n ? handlerRef\n : methods[handlerRef] ?? (instance as Record<string, any>)[handlerRef]\n if (typeof handler !== 'function') {\n return () => {}\n }\n return (nativeEvent: Event) => {\n if (flags?.catch) {\n nativeEvent.stopPropagation()\n }\n const target = nativeEvent.target as HTMLElement | null\n const currentTarget = nativeEvent.currentTarget as HTMLElement | null\n const dataset = currentTarget?.dataset ?? {}\n const syntheticEvent = {\n type: eventName,\n timeStamp: nativeEvent.timeStamp,\n detail: (nativeEvent as CustomEvent).detail ?? (nativeEvent as InputEvent).data ?? undefined,\n target: {\n dataset: target?.dataset ?? dataset,\n },\n currentTarget: {\n dataset,\n },\n originalEvent: nativeEvent,\n }\n handler.call(instance, syntheticEvent)\n }\n}\n\nfunction createWxsModule(code: string, id: string, requireMap?: Record<string, any>) {\n const module = { exports: {} as Record<string, any> }\n const exports = module.exports\n const getRegExp = (pattern: string, flags?: string) => new RegExp(pattern, flags)\n const getDate = (value?: string | number | Date) => (value == null ? new Date() : new Date(value))\n const require = (request: string) => requireMap?.[request]\n try {\n // eslint-disable-next-line no-new-func -- run in isolated module scope\n const runner = new Function('module', 'exports', 'require', 'getRegExp', 'getDate', code)\n runner(module, exports, require, getRegExp, getDate)\n }\n catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n const mode = getRuntimeExecutionMode()\n if (mode === 'safe') {\n warnRuntimeExecutionOnce(\n `safe-wxs-runtime:${id}`,\n `[@weapp-vite/web] safe 模式下忽略 WXS 执行错误: ${id} ${reason}`,\n )\n return {}\n }\n throw new Error(`[@weapp-vite/web] WXS 执行失败: ${id} ${reason}`)\n }\n return module.exports\n}\n\nexport function createRenderContext(\n instance: ComponentPublicInstance,\n methods: Record<string, (event: any) => any>,\n): RenderContext {\n const warnMissingTemplate = (name: string) => {\n emitRuntimeWarning(`[@weapp-vite/web] 未找到模板: ${name}`, {\n key: `template-missing:${name}`,\n context: 'runtime:template',\n })\n }\n\n return {\n instance,\n eval: (expression, scope, wxs) => {\n const baseScope = scope ?? createScope()\n const renderScope = wxs ? createChildScope(baseScope, wxs) : baseScope\n return evaluateExpression(expression, renderScope)\n },\n createScope: (parent, locals) => createChildScope(parent, locals),\n mergeScope: (parent, data) => {\n const baseScope = parent ?? createScope()\n if (!data || typeof data !== 'object') {\n return baseScope\n }\n return createChildScope(baseScope, data as Record<string, any>)\n },\n normalizeList,\n key: (rawKey, item, index, scope, wxs) => {\n const baseScope = scope ?? createScope()\n const renderScope = wxs ? createChildScope(baseScope, wxs) : baseScope\n return normalizeKey(rawKey, item, index, renderScope)\n },\n renderTemplate: (templates, name, scope, ctx) => {\n const resolvedName = typeof name === 'string' ? name : String(name)\n const template = templates?.[resolvedName]\n if (typeof template !== 'function') {\n warnMissingTemplate(resolvedName)\n return ''\n }\n return template(scope, ctx)\n },\n event: (eventName, handlerName, _scope, _wxs, flags) => {\n if (typeof handlerName === 'function') {\n return createEventHandler(instance, methods, eventName, handlerName, flags)\n }\n const resolvedHandler = String(handlerName ?? '')\n return createEventHandler(instance, methods, eventName, resolvedHandler, flags)\n },\n createWxsModule,\n }\n}\n\nexport { createChildScope, createScope, evaluateExpression }\n"],"mappings":";;;;AAiBA,MAAM,kCAAkB,IAAI,IAA2C;AACvE,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAE3B,SAAS,YAAY,SAAwC;CAC3D,OAAO,OAAO,OAAO,OAAO,OAAO,IAAI,GAAG,WAAW,CAAC,CAAC;AACzD;AAEA,SAAS,iBAAiB,QAAuB,QAA6C;CAC5F,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM,GAAG,UAAU,CAAC,CAAC;AAC1D;AAEA,SAAS,mBAAmB,YAAoB,OAA2B;CACzE,IAAI,CAAC,YACH;CAEF,MAAM,UAAU,WAAW,KAAK;CAChC,IAAI,CAAC,SACH;CAEF,IAAI,YAAY,gBAAgB,IAAI,OAAO;CAC3C,IAAI,CAAC,WAAW;EACd,IAAI;GAEF,YAAY,IAAI,SAAS,SAAS,wBAAwB,QAAQ,KAAK;EACzE,SACO,OAAO;GACZ,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAEpE,IADa,wBACN,MAAM,QAAQ;IACnB,yBACE,yBAAyB,WACzB,wCAAwC,QAAQ,KAAK,QACvD;IACA,kBAAkB;GACpB,OAEE,M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;AAChB;AAEA,SAAgB,oBACd,UACA,SACe;CACf,MAAM,uBAAuB,SAAiB;EAC5C,mBAAmB,4BAA4B,QAAQ;GACrD,KAAK,oBAAoB;GACzB,SAAS;EACX,CAAC;CACH;CAEA,OAAO;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;GAChC,MAAM,YAAY,SAAS,YAAY;GAEvC,OAAO,mBAAmB,YADN,MAAM,iBAAiB,WAAW,GAAG,IAAI,SACZ;EACnD;EACA,cAAc,QAAQ,WAAW,iBAAiB,QAAQ,MAAM;EAChE,aAAa,QAAQ,SAAS;GAC5B,MAAM,YAAY,UAAU,YAAY;GACxC,IAAI,CAAC,QAAQ,OAAO,SAAS,UAC3B,OAAO;GAET,OAAO,iBAAiB,WAAW,IAA2B;EAChE;EACA;EACA,MAAM,QAAQ,MAAM,OAAO,OAAO,QAAQ;GACxC,MAAM,YAAY,SAAS,YAAY;GAEvC,OAAO,aAAa,QAAQ,MAAM,OADd,MAAM,iBAAiB,WAAW,GAAG,IAAI,SACT;EACtD;EACA,iBAAiB,WAAW,MAAM,OAAO,QAAQ;GAC/C,MAAM,eAAe,OAAO,SAAS,WAAW,OAAO,OAAO,IAAI;GAClE,MAAM,WAAW,YAAY;GAC7B,IAAI,OAAO,aAAa,YAAY;IAClC,oBAAoB,YAAY;IAChC,OAAO;GACT;GACA,OAAO,SAAS,OAAO,GAAG;EAC5B;EACA,QAAQ,WAAW,aAAa,QAAQ,MAAM,UAAU;GACtD,IAAI,OAAO,gBAAgB,YACzB,OAAO,mBAAmB,UAAU,SAAS,WAAW,aAAa,KAAK;GAG5E,OAAO,mBAAmB,UAAU,SAAS,WADrB,OAAO,eAAe,EACwB,GAAG,KAAK;EAChF;EACA;CACF;AACF"}
1
+ {"version":3,"file":"renderContext.mjs","names":[],"sources":["../../src/runtime/renderContext.ts"],"sourcesContent":["import type { ComponentPublicInstance } from './component'\nimport type { TemplateScope } from './template'\nimport { getRuntimeExecutionMode, warnRuntimeExecutionOnce } from './execution'\nimport { invokeMiniProgramEventHandler } from './inputHandlerResult'\nimport { emitRuntimeWarning } from './warning'\n\nexport interface RenderContext {\n instance: ComponentPublicInstance\n eval: (expression: string, scope: TemplateScope, wxs?: Record<string, any>) => any\n createScope: (parent: TemplateScope, locals?: Record<string, any>) => TemplateScope\n mergeScope: (parent: TemplateScope, data?: any) => TemplateScope\n normalizeList: (value: any) => any[]\n key: (rawKey: string, item: any, index: number, scope: TemplateScope, wxs?: Record<string, any>) => any\n renderTemplate: (templates: Record<string, any>, name: any, scope: TemplateScope, ctx: RenderContext) => any\n event: (eventName: string, handlerName: any, scope: TemplateScope, wxs?: Record<string, any>, flags?: { catch?: boolean, capture?: boolean }) => (event: Event) => void\n createWxsModule: (code: string, id: string, requireMap?: Record<string, any>) => Record<string, any>\n}\n\nconst expressionCache = new Map<string, (scope: TemplateScope) => any>()\nconst MUSTACHE_PREFIX_RE = /^\\{\\{\\s*/\nconst MUSTACHE_SUFFIX_RE = /\\s*\\}\\}$/\nconst SIMPLE_KEY_PATH_RE = /[.[()]/\n\nfunction createScope(initial?: TemplateScope): TemplateScope {\n return Object.assign(Object.create(null), initial ?? {})\n}\n\nfunction createChildScope(parent: TemplateScope, locals?: Record<string, any>): TemplateScope {\n return Object.assign(Object.create(parent), locals ?? {})\n}\n\nfunction evaluateExpression(expression: string, scope: TemplateScope): any {\n if (!expression) {\n return undefined\n }\n const trimmed = expression.trim()\n if (!trimmed) {\n return undefined\n }\n let evaluator = expressionCache.get(trimmed)\n if (!evaluator) {\n try {\n // eslint-disable-next-line no-new-func -- dynamic expressions are required for template evaluation\n evaluator = new Function('scope', `with(scope){ return (${trimmed}); }`) as (scope: TemplateScope) => any\n }\n catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n const mode = getRuntimeExecutionMode()\n if (mode === 'safe') {\n warnRuntimeExecutionOnce(\n `safe-expression-parse:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式解析错误 \"${trimmed}\": ${reason}`,\n )\n evaluator = () => undefined\n }\n else {\n throw new SyntaxError(`[@weapp-vite/web] 无法解析表达式 \"${trimmed}\": ${reason}`)\n }\n }\n expressionCache.set(trimmed, evaluator)\n }\n try {\n return evaluator?.(scope)\n }\n catch (error) {\n const mode = getRuntimeExecutionMode()\n if (mode === 'strict') {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(`[@weapp-vite/web] strict 模式下表达式执行失败 \"${trimmed}\": ${reason}`)\n }\n if (mode === 'safe') {\n const reason = error instanceof Error ? error.message : String(error)\n warnRuntimeExecutionOnce(\n `safe-expression-runtime:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式执行错误 \"${trimmed}\": ${reason}`,\n )\n }\n return undefined\n }\n}\n\nfunction normalizeList(value: any): any[] {\n if (Array.isArray(value)) {\n return value\n }\n if (value == null) {\n return []\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n const length = Math.max(0, Math.floor(value))\n return Array.from({ length }, (_, index) => index)\n }\n if (typeof value === 'object') {\n return Object.values(value)\n }\n return []\n}\n\nfunction normalizeKey(rawKey: string, item: any, index: number, scope: TemplateScope): any {\n const key = rawKey?.trim()\n if (!key) {\n if (item != null && (typeof item === 'string' || typeof item === 'number' || typeof item === 'boolean')) {\n return item\n }\n return index\n }\n if (key === '*this') {\n return item\n }\n if (key.includes('{{') && key.includes('}}')) {\n const expr = key.replace(MUSTACHE_PREFIX_RE, '').replace(MUSTACHE_SUFFIX_RE, '')\n return evaluateExpression(expr, scope)\n }\n if (!SIMPLE_KEY_PATH_RE.test(key) && item && typeof item === 'object' && key in item) {\n return (item as Record<string, any>)[key]\n }\n return evaluateExpression(key, scope)\n}\n\nfunction createEventHandler(\n instance: ComponentPublicInstance,\n methods: Record<string, (event: any) => any>,\n eventName: string,\n handlerRef: string | ((event: any) => any),\n flags?: { catch?: boolean },\n) {\n const handler = typeof handlerRef === 'function'\n ? handlerRef\n : methods[handlerRef] ?? (instance as Record<string, any>)[handlerRef]\n if (typeof handler !== 'function') {\n return () => {}\n }\n return (nativeEvent: Event) => {\n if (flags?.catch) {\n nativeEvent.stopPropagation()\n }\n const target = nativeEvent.target as HTMLElement | null\n const currentTarget = nativeEvent.currentTarget as HTMLElement | null\n const dataset = currentTarget?.dataset ?? {}\n const syntheticEvent = {\n type: eventName,\n timeStamp: nativeEvent.timeStamp,\n detail: (nativeEvent as CustomEvent).detail ?? (nativeEvent as InputEvent).data ?? undefined,\n target: {\n dataset: target?.dataset ?? dataset,\n },\n currentTarget: {\n dataset,\n },\n originalEvent: nativeEvent,\n }\n invokeMiniProgramEventHandler(handler, instance, syntheticEvent, nativeEvent)\n }\n}\n\nfunction createWxsModule(code: string, id: string, requireMap?: Record<string, any>) {\n const module = { exports: {} as Record<string, any> }\n const exports = module.exports\n const getRegExp = (pattern: string, flags?: string) => new RegExp(pattern, flags)\n const getDate = (value?: string | number | Date) => (value == null ? new Date() : new Date(value))\n const require = (request: string) => requireMap?.[request]\n try {\n // eslint-disable-next-line no-new-func -- run in isolated module scope\n const runner = new Function('module', 'exports', 'require', 'getRegExp', 'getDate', code)\n runner(module, exports, require, getRegExp, getDate)\n }\n catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n const mode = getRuntimeExecutionMode()\n if (mode === 'safe') {\n warnRuntimeExecutionOnce(\n `safe-wxs-runtime:${id}`,\n `[@weapp-vite/web] safe 模式下忽略 WXS 执行错误: ${id} ${reason}`,\n )\n return {}\n }\n throw new Error(`[@weapp-vite/web] WXS 执行失败: ${id} ${reason}`)\n }\n return module.exports\n}\n\nexport function createRenderContext(\n instance: ComponentPublicInstance,\n methods: Record<string, (event: any) => any>,\n): RenderContext {\n const warnMissingTemplate = (name: string) => {\n emitRuntimeWarning(`[@weapp-vite/web] 未找到模板: ${name}`, {\n key: `template-missing:${name}`,\n context: 'runtime:template',\n })\n }\n\n return {\n instance,\n eval: (expression, scope, wxs) => {\n const baseScope = scope ?? createScope()\n const renderScope = wxs ? createChildScope(baseScope, wxs) : baseScope\n return evaluateExpression(expression, renderScope)\n },\n createScope: (parent, locals) => createChildScope(parent, locals),\n mergeScope: (parent, data) => {\n const baseScope = parent ?? createScope()\n if (!data || typeof data !== 'object') {\n return baseScope\n }\n return createChildScope(baseScope, data as Record<string, any>)\n },\n normalizeList,\n key: (rawKey, item, index, scope, wxs) => {\n const baseScope = scope ?? createScope()\n const renderScope = wxs ? createChildScope(baseScope, wxs) : baseScope\n return normalizeKey(rawKey, item, index, renderScope)\n },\n renderTemplate: (templates, name, scope, ctx) => {\n const resolvedName = typeof name === 'string' ? name : String(name)\n const template = templates?.[resolvedName]\n if (typeof template !== 'function') {\n warnMissingTemplate(resolvedName)\n return ''\n }\n return template(scope, ctx)\n },\n event: (eventName, handlerName, _scope, _wxs, flags) => {\n if (typeof handlerName === 'function') {\n return createEventHandler(instance, methods, eventName, handlerName, flags)\n }\n const resolvedHandler = String(handlerName ?? '')\n return createEventHandler(instance, methods, eventName, resolvedHandler, flags)\n },\n createWxsModule,\n }\n}\n\nexport { createChildScope, createScope, evaluateExpression }\n"],"mappings":";;;;;AAkBA,MAAM,kCAAkB,IAAI,IAA2C;AACvE,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAE3B,SAAS,YAAY,SAAwC;CAC3D,OAAO,OAAO,OAAO,OAAO,OAAO,IAAI,GAAG,WAAW,CAAC,CAAC;AACzD;AAEA,SAAS,iBAAiB,QAAuB,QAA6C;CAC5F,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM,GAAG,UAAU,CAAC,CAAC;AAC1D;AAEA,SAAS,mBAAmB,YAAoB,OAA2B;CACzE,IAAI,CAAC,YACH;CAEF,MAAM,UAAU,WAAW,KAAK;CAChC,IAAI,CAAC,SACH;CAEF,IAAI,YAAY,gBAAgB,IAAI,OAAO;CAC3C,IAAI,CAAC,WAAW;EACd,IAAI;GAEF,YAAY,IAAI,SAAS,SAAS,wBAAwB,QAAQ,KAAK;EACzE,SACO,OAAO;GACZ,MAAM,SAAS,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ACF"}
@@ -1,9 +1,8 @@
1
1
  //#region src/runtime/rpx.d.ts
2
- interface RpxConfig {
2
+ export interface RpxConfig {
3
3
  designWidth?: number;
4
4
  varName?: string;
5
5
  }
6
- declare function setupRpx(config?: RpxConfig): void;
6
+ export declare function setupRpx(config?: RpxConfig): void;
7
7
  //#endregion
8
- export { RpxConfig, setupRpx };
9
8
  //# sourceMappingURL=rpx.d.mts.map
@@ -1,31 +1,31 @@
1
1
  //#region src/runtime/seo/index.d.ts
2
- type WebResourceHintRelation = 'preconnect' | 'dns-prefetch' | 'prefetch' | 'preload';
3
- interface WebResourceHint {
2
+ export type WebResourceHintRelation = 'preconnect' | 'dns-prefetch' | 'prefetch' | 'preload';
3
+ export interface WebResourceHint {
4
4
  href: string;
5
5
  rel: WebResourceHintRelation;
6
6
  as?: string;
7
7
  type?: string;
8
8
  crossOrigin?: 'anonymous' | 'use-credentials';
9
9
  }
10
- interface WebResourceHintsConfig {
10
+ export interface WebResourceHintsConfig {
11
11
  links?: WebResourceHint[];
12
12
  }
13
- interface WebSeoConfig {
13
+ export interface WebSeoConfig {
14
14
  enabled?: boolean;
15
15
  defaultTitle?: string;
16
16
  titleTemplate?: string;
17
17
  description?: string;
18
18
  canonical?: boolean;
19
19
  }
20
- interface WebPageHead {
20
+ export interface WebPageHead {
21
21
  route?: string;
22
22
  title?: string;
23
23
  }
24
- declare function configureWebSeo(next?: WebSeoConfig): void;
25
- declare function syncWebDocumentHead(head: WebPageHead): void;
26
- declare function updateWebDocumentTitle(title: string): void;
27
- declare function setupWebResourceHints(config?: WebResourceHintsConfig): void;
28
- declare function resetWebDocumentHead(): void;
24
+ export declare function configureWebSeo(next?: WebSeoConfig): void;
25
+ export declare function syncWebDocumentHead(head: WebPageHead): void;
26
+ export declare function updateWebDocumentTitle(title: string): void;
27
+ export declare function setupWebResourceHints(config?: WebResourceHintsConfig): void;
28
+ export declare function resetWebDocumentHead(): void;
29
29
  //#endregion
30
- export { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, type WebSeoConfig as WebRuntimeSeoConfig, WebSeoConfig, configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle };
30
+ export type { WebSeoConfig as WebRuntimeSeoConfig };
31
31
  //# sourceMappingURL=index.d.mts.map
@@ -1,6 +1,5 @@
1
1
  //#region src/runtime/style.d.ts
2
- declare function removeStyle(id: string): void;
3
- declare function injectStyle(css: string, id?: string): () => void;
2
+ export declare function removeStyle(id: string): void;
3
+ export declare function injectStyle(css: string, id?: string): () => void;
4
4
  //#endregion
5
- export { injectStyle, removeStyle };
6
5
  //# sourceMappingURL=style.d.mts.map
@@ -2,8 +2,8 @@ import { RenderContext } from "./renderContext.mjs";
2
2
  import { createTemplate, renderTemplate } from "./legacyTemplate/index.mjs";
3
3
  import { TemplateResult } from "lit";
4
4
  //#region src/runtime/template.d.ts
5
- type TemplateScope = Record<string, any>;
6
- type TemplateRenderer = (scope: TemplateScope, ctx: RenderContext) => TemplateResult | string | unknown;
5
+ export type TemplateScope = Record<string, any>;
6
+ export type TemplateRenderer = (scope: TemplateScope, ctx: RenderContext) => TemplateResult | string | unknown;
7
7
  //#endregion
8
- export { TemplateRenderer, TemplateScope, createTemplate, renderTemplate };
8
+ export { createTemplate, renderTemplate };
9
9
  //# sourceMappingURL=template.d.mts.map
@@ -1,12 +1,12 @@
1
1
  import { ResolvedWebViewportConfig, WebViewportConfig } from "./types.mjs";
2
2
  //#region src/runtime/viewport/index.d.ts
3
- declare function resolveWebViewportConfig(config?: WebViewportConfig): ResolvedWebViewportConfig;
4
- declare function setupWebViewport(config?: WebViewportConfig): {
3
+ export declare function resolveWebViewportConfig(config?: WebViewportConfig): ResolvedWebViewportConfig;
4
+ export declare function setupWebViewport(config?: WebViewportConfig): {
5
5
  mode: "mini-program" | "responsive";
6
6
  maxWidth: number;
7
7
  desktopBreakpoint: number;
8
8
  };
9
- declare function getWebViewportWidth(): number;
9
+ export declare function getWebViewportWidth(): number;
10
10
  //#endregion
11
- export { type ResolvedWebViewportConfig, type WebViewportConfig, getWebViewportWidth, resolveWebViewportConfig, setupWebViewport };
11
+ export type { ResolvedWebViewportConfig, WebViewportConfig };
12
12
  //# sourceMappingURL=index.d.mts.map
@@ -1,14 +1,13 @@
1
1
  //#region src/runtime/viewport/types.d.ts
2
- interface WebViewportConfig {
2
+ export interface WebViewportConfig {
3
3
  mode?: 'mini-program' | 'responsive';
4
4
  maxWidth?: number;
5
5
  desktopBreakpoint?: number;
6
6
  }
7
- interface ResolvedWebViewportConfig {
7
+ export interface ResolvedWebViewportConfig {
8
8
  mode: 'mini-program' | 'responsive';
9
9
  maxWidth: number;
10
10
  desktopBreakpoint: number;
11
11
  }
12
12
  //#endregion
13
- export { ResolvedWebViewportConfig, WebViewportConfig };
14
13
  //# sourceMappingURL=types.d.mts.map
@@ -1,10 +1,9 @@
1
1
  //#region src/runtime/warning.d.ts
2
- type RuntimeWarningLevel = 'off' | 'warn' | 'error';
3
- interface RuntimeWarningOptions {
2
+ export type RuntimeWarningLevel = 'off' | 'warn' | 'error';
3
+ export interface RuntimeWarningOptions {
4
4
  level?: RuntimeWarningLevel;
5
5
  dedupe?: boolean;
6
6
  }
7
- declare function setRuntimeWarningOptions(options?: RuntimeWarningOptions): void;
7
+ export declare function setRuntimeWarningOptions(options?: RuntimeWarningOptions): void;
8
8
  //#endregion
9
- export { RuntimeWarningLevel, RuntimeWarningOptions, setRuntimeWarningOptions };
10
9
  //# sourceMappingURL=warning.d.mts.map
@@ -6,15 +6,18 @@ interface WevuRegisterMeta extends RegisterMeta {
6
6
  /**
7
7
  * 将 Wevu App 注册过程接入 Web 页面栈。
8
8
  */
9
- declare function registerWebWevuApp(options: Record<string, any>, meta: WevuRegisterMeta): void;
9
+ export declare function registerWebWevuApp(options: Record<string, any>, meta: WevuRegisterMeta): void;
10
10
  /**
11
11
  * 将 Wevu 页面或组件注册过程接入 Web 自定义元素。
12
12
  */
13
- declare function registerWebWevuComponent(options: Record<string, any>, meta: WevuRegisterMeta): void;
13
+ export declare function registerWebWevuComponent(options: Record<string, any>, meta: WevuRegisterMeta): void;
14
+ /**
15
+ * 保留公开 Wevu 工厂行为,并使用当前模块元数据完成 Web 注册。
16
+ */
17
+ export declare function registerWebWevuComponentFactory<TArgs extends unknown[], TResult>(factory: (...args: TArgs) => TResult, meta: WevuRegisterMeta, ...args: TArgs): TResult;
14
18
  /**
15
19
  * 在原生模块同步求值期间安装带页面元数据的宿主注册函数。
16
20
  */
17
- declare function installWebModuleRegistration(meta: WevuRegisterMeta, target?: Record<string, any>): () => void;
21
+ export declare function installWebModuleRegistration(meta: WevuRegisterMeta, target?: Record<string, any>): () => void;
18
22
  //#endregion
19
- export { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent };
20
23
  //# sourceMappingURL=wevu.d.mts.map
@@ -41,7 +41,18 @@ function registerWebWevuApp(options, meta) {
41
41
  function registerWebWevuComponent(options, meta) {
42
42
  withRuntimeConstructor("Component", (definition) => {
43
43
  return meta.kind === "page" ? registerPage(definition, meta) : registerComponent(definition, meta);
44
- }, () => createWevuComponent(options));
44
+ }, () => createWevuComponent({
45
+ ...options,
46
+ allowNullPropInput: false
47
+ }));
48
+ }
49
+ /**
50
+ * 保留公开 Wevu 工厂行为,并使用当前模块元数据完成 Web 注册。
51
+ */
52
+ function registerWebWevuComponentFactory(factory, meta, ...args) {
53
+ return withRuntimeConstructor("Component", (definition) => {
54
+ return meta.kind === "page" ? registerPage(definition, meta) : registerComponent(definition, meta);
55
+ }, () => factory(...args));
45
56
  }
46
57
  /**
47
58
  * 在原生模块同步求值期间安装带页面元数据的宿主注册函数。
@@ -69,5 +80,5 @@ function installWebModuleRegistration(meta, target = globalThis) {
69
80
  }
70
81
 
71
82
  //#endregion
72
- export { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent };
83
+ export { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory };
73
84
  //# sourceMappingURL=wevu.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"wevu.mjs","names":[],"sources":["../../src/runtime/wevu.ts"],"sourcesContent":["import type { RegisterMeta } from './polyfill/routeRuntime/options'\nimport { createApp, createWevuComponent, takePendingRuntimeAppRegistration } from 'wevu/internal-runtime'\nimport { registerApp, registerComponent, registerPage } from './polyfill/routeRuntime'\n\ninterface WevuRegisterMeta extends RegisterMeta {\n kind: 'app' | 'page' | 'component'\n}\n\ntype RuntimeConstructorName = 'App' | 'Page' | 'Component'\n\nfunction createRuntimeConstructor(meta: WevuRegisterMeta, name: RuntimeConstructorName) {\n return (definition: Record<string, any>) => {\n if (name === 'App') {\n registerApp(definition, meta)\n }\n else if (name === 'Page' || meta.kind === 'page') {\n registerPage(definition, meta)\n }\n else {\n registerComponent(definition, meta)\n }\n return definition\n }\n}\n\nfunction withRuntimeConstructor<T>(\n name: 'App' | 'Component',\n constructor: (options: Record<string, any>) => unknown,\n run: () => T,\n) {\n const target = globalThis as Record<string, any>\n const hadOwn = Object.prototype.hasOwnProperty.call(target, name)\n const previous = target[name]\n target[name] = constructor\n try {\n return run()\n }\n finally {\n if (hadOwn) {\n target[name] = previous\n }\n else {\n delete target[name]\n }\n }\n}\n\n/**\n * 将 Wevu App 注册过程接入 Web 页面栈。\n */\nexport function registerWebWevuApp(options: Record<string, any>, meta: WevuRegisterMeta): void {\n const pendingRegistration = takePendingRuntimeAppRegistration()\n withRuntimeConstructor('App', definition => registerApp(definition, meta), () => {\n if (pendingRegistration) {\n pendingRegistration.register()\n return pendingRegistration.app\n }\n return createApp(options)\n })\n}\n\n/**\n * 将 Wevu 页面或组件注册过程接入 Web 自定义元素。\n */\nexport function registerWebWevuComponent(options: Record<string, any>, meta: WevuRegisterMeta): void {\n withRuntimeConstructor('Component', (definition) => {\n return meta.kind === 'page'\n ? registerPage(definition, meta)\n : registerComponent(definition, meta)\n }, () => createWevuComponent(options))\n}\n\n/**\n * 在原生模块同步求值期间安装带页面元数据的宿主注册函数。\n */\nexport function installWebModuleRegistration(\n meta: WevuRegisterMeta,\n target: Record<string, any> = globalThis,\n): () => void {\n const names: RuntimeConstructorName[] = meta.kind === 'app'\n ? ['App']\n : meta.kind === 'page'\n ? ['Page', 'Component']\n : ['Component']\n const previous = names.map(name => ({\n hadOwn: Object.prototype.hasOwnProperty.call(target, name),\n name,\n value: target[name],\n }))\n const installed = new Map<RuntimeConstructorName, (definition: Record<string, any>) => Record<string, any>>()\n\n for (const name of names) {\n const constructor = createRuntimeConstructor(meta, name)\n installed.set(name, constructor)\n target[name] = constructor\n }\n\n return () => {\n for (const entry of previous) {\n if (target[entry.name] !== installed.get(entry.name)) {\n continue\n }\n if (entry.hadOwn) {\n target[entry.name] = entry.value\n }\n else {\n delete target[entry.name]\n }\n }\n }\n}\n"],"mappings":";;;;AAUA,SAAS,yBAAyB,MAAwB,MAA8B;CACtF,QAAQ,eAAoC;EAC1C,IAAI,SAAS,OACX,YAAY,YAAY,IAAI;OAEzB,IAAI,SAAS,UAAU,KAAK,SAAS,QACxC,aAAa,YAAY,IAAI;OAG7B,kBAAkB,YAAY,IAAI;EAEpC,OAAO;CACT;AACF;AAEA,SAAS,uBACP,MACA,aACA,KACA;CACA,MAAM,SAAS;CACf,MAAM,SAAS,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;CAChE,MAAM,WAAW,OAAO;CACxB,OAAO,QAAQ;CACf,IAAI;EACF,OAAO,IAAI;CACb,UACQ;EACN,IAAI,QACF,OAAO,QAAQ;OAGf,OAAO,OAAO;CAElB;AACF;;;;AAKA,SAAgB,mBAAmB,SAA8B,MAA8B;CAC7F,MAAM,sBAAsB,kCAAkC;CAC9D,uBAAuB,QAAO,eAAc,YAAY,YAAY,IAAI,SAAS;EAC/E,IAAI,qBAAqB;GACvB,oBAAoB,SAAS;GAC7B,OAAO,oBAAoB;EAC7B;EACA,OAAO,UAAU,OAAO;CAC1B,CAAC;AACH;;;;AAKA,SAAgB,yBAAyB,SAA8B,MAA8B;CACnG,uBAAuB,cAAc,eAAe;EAClD,OAAO,KAAK,SAAS,SACjB,aAAa,YAAY,IAAI,IAC7B,kBAAkB,YAAY,IAAI;CACxC,SAAS,oBAAoB,OAAO,CAAC;AACvC;;;;AAKA,SAAgB,6BACd,MACA,SAA8B,YAClB;CACZ,MAAM,QAAkC,KAAK,SAAS,QAClD,CAAC,KAAK,IACN,KAAK,SAAS,SACZ,CAAC,QAAQ,WAAW,IACpB,CAAC,WAAW;CAClB,MAAM,WAAW,MAAM,KAAI,UAAS;EAClC,QAAQ,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;EACzD;EACA,OAAO,OAAO;CAChB,EAAE;CACF,MAAM,4BAAY,IAAI,IAAsF;CAE5G,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,cAAc,yBAAyB,MAAM,IAAI;EACvD,UAAU,IAAI,MAAM,WAAW;EAC/B,OAAO,QAAQ;CACjB;CAEA,aAAa;EACX,KAAK,MAAM,SAAS,UAAU;GAC5B,IAAI,OAAO,MAAM,UAAU,UAAU,IAAI,MAAM,IAAI,GACjD;GAEF,IAAI,MAAM,QACR,OAAO,MAAM,QAAQ,MAAM;QAG3B,OAAO,OAAO,MAAM;EAExB;CACF;AACF"}
1
+ {"version":3,"file":"wevu.mjs","names":[],"sources":["../../src/runtime/wevu.ts"],"sourcesContent":["import type { RegisterMeta } from './polyfill/routeRuntime/options'\nimport { createApp, createWevuComponent, takePendingRuntimeAppRegistration } from 'wevu/internal-runtime'\nimport { registerApp, registerComponent, registerPage } from './polyfill/routeRuntime'\n\ninterface WevuRegisterMeta extends RegisterMeta {\n kind: 'app' | 'page' | 'component'\n}\n\ntype RuntimeConstructorName = 'App' | 'Page' | 'Component'\n\nfunction createRuntimeConstructor(meta: WevuRegisterMeta, name: RuntimeConstructorName) {\n return (definition: Record<string, any>) => {\n if (name === 'App') {\n registerApp(definition, meta)\n }\n else if (name === 'Page' || meta.kind === 'page') {\n registerPage(definition, meta)\n }\n else {\n registerComponent(definition, meta)\n }\n return definition\n }\n}\n\nfunction withRuntimeConstructor<T>(\n name: 'App' | 'Component',\n constructor: (options: Record<string, any>) => unknown,\n run: () => T,\n) {\n const target = globalThis as Record<string, any>\n const hadOwn = Object.prototype.hasOwnProperty.call(target, name)\n const previous = target[name]\n target[name] = constructor\n try {\n return run()\n }\n finally {\n if (hadOwn) {\n target[name] = previous\n }\n else {\n delete target[name]\n }\n }\n}\n\n/**\n * 将 Wevu App 注册过程接入 Web 页面栈。\n */\nexport function registerWebWevuApp(options: Record<string, any>, meta: WevuRegisterMeta): void {\n const pendingRegistration = takePendingRuntimeAppRegistration()\n withRuntimeConstructor('App', definition => registerApp(definition, meta), () => {\n if (pendingRegistration) {\n pendingRegistration.register()\n return pendingRegistration.app\n }\n return createApp(options)\n })\n}\n\n/**\n * 将 Wevu 页面或组件注册过程接入 Web 自定义元素。\n */\nexport function registerWebWevuComponent(options: Record<string, any>, meta: WevuRegisterMeta): void {\n // Web 依赖 prop 构造器解码 DOM 属性,不使用小程序宿主的 nullable transport 降级。\n withRuntimeConstructor('Component', (definition) => {\n return meta.kind === 'page'\n ? registerPage(definition, meta)\n : registerComponent(definition, meta)\n }, () => createWevuComponent({ ...options, allowNullPropInput: false }))\n}\n\n/**\n * 保留公开 Wevu 工厂行为,并使用当前模块元数据完成 Web 注册。\n */\nexport function registerWebWevuComponentFactory<TArgs extends unknown[], TResult>(\n factory: (...args: TArgs) => TResult,\n meta: WevuRegisterMeta,\n ...args: TArgs\n): TResult {\n return withRuntimeConstructor('Component', (definition) => {\n return meta.kind === 'page'\n ? registerPage(definition, meta)\n : registerComponent(definition, meta)\n }, () => factory(...args))\n}\n\n/**\n * 在原生模块同步求值期间安装带页面元数据的宿主注册函数。\n */\nexport function installWebModuleRegistration(\n meta: WevuRegisterMeta,\n target: Record<string, any> = globalThis,\n): () => void {\n const names: RuntimeConstructorName[] = meta.kind === 'app'\n ? ['App']\n : meta.kind === 'page'\n ? ['Page', 'Component']\n : ['Component']\n const previous = names.map(name => ({\n hadOwn: Object.prototype.hasOwnProperty.call(target, name),\n name,\n value: target[name],\n }))\n const installed = new Map<RuntimeConstructorName, (definition: Record<string, any>) => Record<string, any>>()\n\n for (const name of names) {\n const constructor = createRuntimeConstructor(meta, name)\n installed.set(name, constructor)\n target[name] = constructor\n }\n\n return () => {\n for (const entry of previous) {\n if (target[entry.name] !== installed.get(entry.name)) {\n continue\n }\n if (entry.hadOwn) {\n target[entry.name] = entry.value\n }\n else {\n delete target[entry.name]\n }\n }\n }\n}\n"],"mappings":";;;;AAUA,SAAS,yBAAyB,MAAwB,MAA8B;CACtF,QAAQ,eAAoC;EAC1C,IAAI,SAAS,OACX,YAAY,YAAY,IAAI;OAEzB,IAAI,SAAS,UAAU,KAAK,SAAS,QACxC,aAAa,YAAY,IAAI;OAG7B,kBAAkB,YAAY,IAAI;EAEpC,OAAO;CACT;AACF;AAEA,SAAS,uBACP,MACA,aACA,KACA;CACA,MAAM,SAAS;CACf,MAAM,SAAS,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;CAChE,MAAM,WAAW,OAAO;CACxB,OAAO,QAAQ;CACf,IAAI;EACF,OAAO,IAAI;CACb,UACQ;EACN,IAAI,QACF,OAAO,QAAQ;OAGf,OAAO,OAAO;CAElB;AACF;;;;AAKA,SAAgB,mBAAmB,SAA8B,MAA8B;CAC7F,MAAM,sBAAsB,kCAAkC;CAC9D,uBAAuB,QAAO,eAAc,YAAY,YAAY,IAAI,SAAS;EAC/E,IAAI,qBAAqB;GACvB,oBAAoB,SAAS;GAC7B,OAAO,oBAAoB;EAC7B;EACA,OAAO,UAAU,OAAO;CAC1B,CAAC;AACH;;;;AAKA,SAAgB,yBAAyB,SAA8B,MAA8B;CAEnG,uBAAuB,cAAc,eAAe;EAClD,OAAO,KAAK,SAAS,SACjB,aAAa,YAAY,IAAI,IAC7B,kBAAkB,YAAY,IAAI;CACxC,SAAS,oBAAoB;EAAE,GAAG;EAAS,oBAAoB;CAAM,CAAC,CAAC;AACzE;;;;AAKA,SAAgB,gCACd,SACA,MACA,GAAG,MACM;CACT,OAAO,uBAAuB,cAAc,eAAe;EACzD,OAAO,KAAK,SAAS,SACjB,aAAa,YAAY,IAAI,IAC7B,kBAAkB,YAAY,IAAI;CACxC,SAAS,QAAQ,GAAG,IAAI,CAAC;AAC3B;;;;AAKA,SAAgB,6BACd,MACA,SAA8B,YAClB;CACZ,MAAM,QAAkC,KAAK,SAAS,QAClD,CAAC,KAAK,IACN,KAAK,SAAS,SACZ,CAAC,QAAQ,WAAW,IACpB,CAAC,WAAW;CAClB,MAAM,WAAW,MAAM,KAAI,UAAS;EAClC,QAAQ,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;EACzD;EACA,OAAO,OAAO;CAChB,EAAE;CACF,MAAM,4BAAY,IAAI,IAAsF;CAE5G,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,cAAc,yBAAyB,MAAM,IAAI;EACvD,UAAU,IAAI,MAAM,WAAW;EAC/B,OAAO,QAAQ;CACjB;CAEA,aAAa;EACX,KAAK,MAAM,SAAS,UAAU;GAC5B,IAAI,OAAO,MAAM,UAAU,UAAU,IAAI,MAAM,IAAI,GACjD;GAEF,IAAI,MAAM,QACR,OAAO,MAAM,QAAQ,MAAM;QAG3B,OAAO,OAAO,MAAM;EAExB;CACF;AACF"}
@@ -1,11 +1,11 @@
1
1
  //#region src/shared/tabBar.d.ts
2
- interface WebTabBarItem {
2
+ export interface WebTabBarItem {
3
3
  pagePath: string;
4
4
  text: string;
5
5
  iconPath?: string;
6
6
  selectedIconPath?: string;
7
7
  }
8
- interface WebTabBarConfig {
8
+ export interface WebTabBarConfig {
9
9
  color: string;
10
10
  selectedColor: string;
11
11
  backgroundColor: string;
@@ -15,5 +15,4 @@ interface WebTabBarConfig {
15
15
  list: WebTabBarItem[];
16
16
  }
17
17
  //#endregion
18
- export { WebTabBarConfig, WebTabBarItem };
19
18
  //# sourceMappingURL=tabBar.d.mts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-vite/web",
3
3
  "type": "module",
4
- "version": "1.4.20",
4
+ "version": "1.5.0",
5
5
  "description": "Experimental web runtime for weapp-vite templates",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -22,36 +22,43 @@
22
22
  "sideEffects": false,
23
23
  "exports": {
24
24
  ".": {
25
- "types": "./dist/index.d.ts",
25
+ "types": "./dist/index.d.mts",
26
26
  "import": "./dist/index.mjs"
27
27
  },
28
28
  "./plugin": {
29
- "types": "./dist/plugin.d.ts",
29
+ "types": "./dist/plugin.d.mts",
30
30
  "import": "./dist/plugin.mjs"
31
31
  },
32
32
  "./runtime": {
33
- "types": "./dist/runtime/index.d.ts",
33
+ "types": "./dist/runtime/index.d.mts",
34
34
  "import": "./dist/runtime/index.mjs"
35
35
  },
36
36
  "./runtime/polyfill": {
37
- "types": "./dist/runtime/index.d.ts",
37
+ "types": "./dist/runtime/index.d.mts",
38
38
  "import": "./dist/runtime/index.mjs"
39
39
  }
40
40
  },
41
41
  "main": "./dist/index.mjs",
42
42
  "module": "./dist/index.mjs",
43
- "types": "./dist/index.d.ts",
43
+ "types": "./dist/index.d.mts",
44
44
  "files": [
45
45
  "dist"
46
46
  ],
47
47
  "engines": {
48
48
  "node": "^20.19.0 || >=22.12.0"
49
49
  },
50
+ "tsd": {
51
+ "compilerOptions": {
52
+ "module": "NodeNext",
53
+ "moduleResolution": "NodeNext",
54
+ "paths": {}
55
+ }
56
+ },
50
57
  "dependencies": {
51
58
  "@babel/parser": "^8.0.4",
52
59
  "@babel/traverse": "^8.0.4",
53
60
  "@babel/types": "^8.0.4",
54
- "@weapp-core/constants": "0.2.1",
61
+ "@weapp-core/constants": "0.2.2",
55
62
  "@weapp-core/shared": "3.2.1",
56
63
  "domhandler": "^6.0.1",
57
64
  "esbuild": "^0.28.2",
@@ -59,14 +66,14 @@
59
66
  "lit": "^3.3.3",
60
67
  "magic-string": "^1.2.3",
61
68
  "pathe": "^2.0.3",
62
- "postcss": "^8.5.26",
63
- "postcss-selector-parser": "^7.1.5",
64
- "rolldown": "1.2.7",
69
+ "postcss": "^8.5.28",
70
+ "postcss-selector-parser": "^7.1.6",
71
+ "rolldown": "1.2.8",
65
72
  "rolldown-require": "2.0.28",
66
- "wevu": "7.0.3"
73
+ "wevu": "7.1.0"
67
74
  },
68
75
  "devDependencies": {
69
- "happy-dom": "^20.13.1"
76
+ "happy-dom": "^20.14.0"
70
77
  },
71
78
  "scripts": {
72
79
  "dev": "tsdown -w --sourcemap",
@@ -75,6 +82,7 @@
75
82
  "test": "vitest run",
76
83
  "test:coverage": "cross-env WEAPP_VITE_WEB_COVERAGE_STRICT=1 vitest run --coverage",
77
84
  "test:dev": "vitest",
85
+ "test:types": "pnpm build && tsd",
78
86
  "typecheck": "tsc --noEmit"
79
87
  }
80
88
  }