@open-wxa/wxa-runner-core 0.7.0 → 0.8.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/dist/index.d.mts +27 -10
- package/dist/index.d.ts +27 -10
- package/dist/index.js +380 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +376 -55
- package/dist/index.mjs.map +1 -1
- package/dist/runtime/frame.js +44 -2
- package/dist/runtime/frame.js.map +1 -1
- package/dist/runtime/host.js +443 -175
- package/dist/runtime/host.js.map +1 -1
- package/dist/runtime/sw.js +56 -0
- package/dist/runtime/sw.js.map +1 -0
- package/dist/{setup-DZ5FeKay.d.mts → setup-Bac8XdhR.d.mts} +5 -1
- package/dist/{setup-DZ5FeKay.d.ts → setup-Bac8XdhR.d.ts} +5 -1
- package/dist/setup.d.mts +1 -1
- package/dist/setup.d.ts +1 -1
- package/dist/test-api.d.mts +2 -2
- package/dist/test-api.d.ts +2 -2
- package/dist/{testApi-BLozOgCt.d.ts → testApi-BOZSXSnV.d.ts} +3 -3
- package/dist/{testApi-CnZOLyWw.d.mts → testApi-DHuEW5Cl.d.mts} +3 -3
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResolvedBaseLib } from '@open-wxa/wxa-runner-extractor';
|
|
2
|
-
import { D as DeviceProfile } from './setup-
|
|
3
|
-
export { A as ApiContext, a as ApiHandler, b as ApiResult, c as AppInfo, M as MockConfig, d as MockRequest, e as MockResponse, f as MockValue, N as NetworkConfig, R as RouteHandler, S as SetupApi, g as SetupConfig, h as SetupContext, i as SetupDefinition } from './setup-
|
|
4
|
-
export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-
|
|
2
|
+
import { D as DeviceProfile, F as ForwardConsole } from './setup-Bac8XdhR.mjs';
|
|
3
|
+
export { A as ApiContext, a as ApiHandler, b as ApiResult, c as AppInfo, M as MockConfig, d as MockRequest, e as MockResponse, f as MockValue, N as NetworkConfig, R as RouteHandler, S as SetupApi, g as SetupConfig, h as SetupContext, i as SetupDefinition } from './setup-Bac8XdhR.mjs';
|
|
4
|
+
export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-DHuEW5Cl.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 小程序项目结构解析
|
|
@@ -64,7 +64,11 @@ declare class MiniProgram {
|
|
|
64
64
|
workersDir(app: AppJson): string | null;
|
|
65
65
|
/** 主包页面 + 分包页面(带 root 前缀) */
|
|
66
66
|
allPages(app: AppJson): string[];
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* 读取并预处理页面/组件 json,id 不带扩展名。
|
|
69
|
+
* 基础库运行时只把组件引用和当前路径拼在一起,不查找 miniprogram_npm、不补 /index(开发者工具编译时已解析好),
|
|
70
|
+
* 所以能解析到的引用都换成组件的绝对路径
|
|
71
|
+
*/
|
|
68
72
|
readUnitJson(id: string, app: AppJson): UnitJson;
|
|
69
73
|
/**
|
|
70
74
|
* 解析组件引用到组件路径(不带扩展名);插件组件或找不到时返回 null。
|
|
@@ -167,18 +171,22 @@ declare class AppBuilder {
|
|
|
167
171
|
* /__wxa__/service-templates.js、page-templates.js 两层的模板(热更新时重新下发)
|
|
168
172
|
* /__wxa__/page-styles.js 渲染层的样式(热更新时重新下发)
|
|
169
173
|
* /__baselib__/* 官方基础库
|
|
170
|
-
* /__wxa__/proxy?
|
|
171
|
-
* /__wxa__/
|
|
174
|
+
* /__wxa__/proxy/<协议>/<域名><路径> 网络代理,如 /__wxa__/proxy/https/api.example.com/a?b=1
|
|
175
|
+
* /__wxa__/mock/<协议>/<域名><路径> 被拦截的请求在 Network 面板里的地址,由 Service Worker(runtime/sw.js)返回响应
|
|
176
|
+
* /__wxa__/fs/<会话> 文件系统接口(FileSystemManager),每个浏览器会话一份文件,会话标识见 runtime/fileSession.ts
|
|
177
|
+
* /__wxa__/tmp/<会话> 临时文件:POST ?type=png 保存,返回可直接访问的地址(GET 支持分段请求);对该地址 HEAD 查大小、DELETE 删除
|
|
178
|
+
* /__wxa__/usr/<会话>/<路径> 用户目录(USER_DATA_PATH)下的文件,image 等组件和 uploadFile 按地址读取
|
|
172
179
|
* /__wxa__/region/<kind> 地区选择器用的行政区划数据(districts / streets),取自本机开发者工具
|
|
173
180
|
* /__wxa__/api/* --devtools-login:wx.login 的 code、手机号,服务市场、插件的请求转发,只允许本机访问
|
|
174
|
-
* /__wxa__/ws 文件变化通知:热更新(hot)或整页刷新(reload
|
|
181
|
+
* /__wxa__/ws 文件变化通知:热更新(hot)或整页刷新(reload);开启 forwardConsole 时浏览器从这里发来报错
|
|
175
182
|
* 其余路径 小程序目录下的静态资源
|
|
176
183
|
*/
|
|
177
184
|
|
|
178
185
|
interface DevServerOptions {
|
|
179
186
|
projectPath: string;
|
|
180
|
-
/**
|
|
187
|
+
/** 不传时从 3000 起找空闲的端口;指定的端口被占用时启动失败;传 0 使用随机端口 */
|
|
181
188
|
port?: number;
|
|
189
|
+
/** 监听地址,默认 localhost;0.0.0.0 或 :: 时局域网也能访问 */
|
|
182
190
|
host?: string;
|
|
183
191
|
/** 指定基础库版本,默认使用本机已安装的最新兼容版本 */
|
|
184
192
|
baseLibVersion?: string;
|
|
@@ -199,6 +207,11 @@ interface DevServerOptions {
|
|
|
199
207
|
devtoolsLogin?: boolean;
|
|
200
208
|
/** @deprecated 改名为 devtoolsLogin */
|
|
201
209
|
realLogin?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* 把浏览器里的报错打印到终端:'errors' 转发运行时错误和未实现 API 的提醒,'all' 再加上 console.warn / console.error。
|
|
212
|
+
* 默认不转发;命令行默认 'errors',检测到编程助手时 'all'
|
|
213
|
+
*/
|
|
214
|
+
forwardConsole?: ForwardConsole;
|
|
202
215
|
logger?: Pick<Console, 'log' | 'warn' | 'error'>;
|
|
203
216
|
}
|
|
204
217
|
declare const DEFAULT_DEVICE: DeviceProfile;
|
|
@@ -217,14 +230,18 @@ declare class DevServer {
|
|
|
217
230
|
private sockets;
|
|
218
231
|
private watcher;
|
|
219
232
|
private address;
|
|
233
|
+
private lanAccess;
|
|
220
234
|
/** 运行时生成的临时文件(canvas 导出、拍照等),随服务器进程存在 */
|
|
221
|
-
private readonly
|
|
235
|
+
private readonly fileSessions;
|
|
222
236
|
private readonly devtoolsLogin;
|
|
223
237
|
/** 开启 --devtools-login 时才有 */
|
|
224
238
|
private readonly ticketSource;
|
|
225
239
|
private readonly plugins;
|
|
226
240
|
constructor(options: DevServerOptions);
|
|
241
|
+
/** 本机访问的地址 */
|
|
227
242
|
get url(): string;
|
|
243
|
+
/** 局域网里其他设备访问的地址,每块网卡一个;只监听本机时为空 */
|
|
244
|
+
get networkUrls(): string[];
|
|
228
245
|
start(): Promise<string>;
|
|
229
246
|
close(): Promise<void>;
|
|
230
247
|
private createApp;
|
|
@@ -254,4 +271,4 @@ interface WxConfigInput {
|
|
|
254
271
|
}
|
|
255
272
|
declare function createWxConfig(input: WxConfigInput): Record<string, any>;
|
|
256
273
|
|
|
257
|
-
export { AppBuilder, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerOptions, DeviceProfile, MiniProgram, type UnitJson, createWxConfig };
|
|
274
|
+
export { AppBuilder, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerOptions, DeviceProfile, ForwardConsole, MiniProgram, type UnitJson, createWxConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResolvedBaseLib } from '@open-wxa/wxa-runner-extractor';
|
|
2
|
-
import { D as DeviceProfile } from './setup-
|
|
3
|
-
export { A as ApiContext, a as ApiHandler, b as ApiResult, c as AppInfo, M as MockConfig, d as MockRequest, e as MockResponse, f as MockValue, N as NetworkConfig, R as RouteHandler, S as SetupApi, g as SetupConfig, h as SetupContext, i as SetupDefinition } from './setup-
|
|
4
|
-
export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-
|
|
2
|
+
import { D as DeviceProfile, F as ForwardConsole } from './setup-Bac8XdhR.js';
|
|
3
|
+
export { A as ApiContext, a as ApiHandler, b as ApiResult, c as AppInfo, M as MockConfig, d as MockRequest, e as MockResponse, f as MockValue, N as NetworkConfig, R as RouteHandler, S as SetupApi, g as SetupConfig, h as SetupContext, i as SetupDefinition } from './setup-Bac8XdhR.js';
|
|
4
|
+
export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-BOZSXSnV.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 小程序项目结构解析
|
|
@@ -64,7 +64,11 @@ declare class MiniProgram {
|
|
|
64
64
|
workersDir(app: AppJson): string | null;
|
|
65
65
|
/** 主包页面 + 分包页面(带 root 前缀) */
|
|
66
66
|
allPages(app: AppJson): string[];
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* 读取并预处理页面/组件 json,id 不带扩展名。
|
|
69
|
+
* 基础库运行时只把组件引用和当前路径拼在一起,不查找 miniprogram_npm、不补 /index(开发者工具编译时已解析好),
|
|
70
|
+
* 所以能解析到的引用都换成组件的绝对路径
|
|
71
|
+
*/
|
|
68
72
|
readUnitJson(id: string, app: AppJson): UnitJson;
|
|
69
73
|
/**
|
|
70
74
|
* 解析组件引用到组件路径(不带扩展名);插件组件或找不到时返回 null。
|
|
@@ -167,18 +171,22 @@ declare class AppBuilder {
|
|
|
167
171
|
* /__wxa__/service-templates.js、page-templates.js 两层的模板(热更新时重新下发)
|
|
168
172
|
* /__wxa__/page-styles.js 渲染层的样式(热更新时重新下发)
|
|
169
173
|
* /__baselib__/* 官方基础库
|
|
170
|
-
* /__wxa__/proxy?
|
|
171
|
-
* /__wxa__/
|
|
174
|
+
* /__wxa__/proxy/<协议>/<域名><路径> 网络代理,如 /__wxa__/proxy/https/api.example.com/a?b=1
|
|
175
|
+
* /__wxa__/mock/<协议>/<域名><路径> 被拦截的请求在 Network 面板里的地址,由 Service Worker(runtime/sw.js)返回响应
|
|
176
|
+
* /__wxa__/fs/<会话> 文件系统接口(FileSystemManager),每个浏览器会话一份文件,会话标识见 runtime/fileSession.ts
|
|
177
|
+
* /__wxa__/tmp/<会话> 临时文件:POST ?type=png 保存,返回可直接访问的地址(GET 支持分段请求);对该地址 HEAD 查大小、DELETE 删除
|
|
178
|
+
* /__wxa__/usr/<会话>/<路径> 用户目录(USER_DATA_PATH)下的文件,image 等组件和 uploadFile 按地址读取
|
|
172
179
|
* /__wxa__/region/<kind> 地区选择器用的行政区划数据(districts / streets),取自本机开发者工具
|
|
173
180
|
* /__wxa__/api/* --devtools-login:wx.login 的 code、手机号,服务市场、插件的请求转发,只允许本机访问
|
|
174
|
-
* /__wxa__/ws 文件变化通知:热更新(hot)或整页刷新(reload
|
|
181
|
+
* /__wxa__/ws 文件变化通知:热更新(hot)或整页刷新(reload);开启 forwardConsole 时浏览器从这里发来报错
|
|
175
182
|
* 其余路径 小程序目录下的静态资源
|
|
176
183
|
*/
|
|
177
184
|
|
|
178
185
|
interface DevServerOptions {
|
|
179
186
|
projectPath: string;
|
|
180
|
-
/**
|
|
187
|
+
/** 不传时从 3000 起找空闲的端口;指定的端口被占用时启动失败;传 0 使用随机端口 */
|
|
181
188
|
port?: number;
|
|
189
|
+
/** 监听地址,默认 localhost;0.0.0.0 或 :: 时局域网也能访问 */
|
|
182
190
|
host?: string;
|
|
183
191
|
/** 指定基础库版本,默认使用本机已安装的最新兼容版本 */
|
|
184
192
|
baseLibVersion?: string;
|
|
@@ -199,6 +207,11 @@ interface DevServerOptions {
|
|
|
199
207
|
devtoolsLogin?: boolean;
|
|
200
208
|
/** @deprecated 改名为 devtoolsLogin */
|
|
201
209
|
realLogin?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* 把浏览器里的报错打印到终端:'errors' 转发运行时错误和未实现 API 的提醒,'all' 再加上 console.warn / console.error。
|
|
212
|
+
* 默认不转发;命令行默认 'errors',检测到编程助手时 'all'
|
|
213
|
+
*/
|
|
214
|
+
forwardConsole?: ForwardConsole;
|
|
202
215
|
logger?: Pick<Console, 'log' | 'warn' | 'error'>;
|
|
203
216
|
}
|
|
204
217
|
declare const DEFAULT_DEVICE: DeviceProfile;
|
|
@@ -217,14 +230,18 @@ declare class DevServer {
|
|
|
217
230
|
private sockets;
|
|
218
231
|
private watcher;
|
|
219
232
|
private address;
|
|
233
|
+
private lanAccess;
|
|
220
234
|
/** 运行时生成的临时文件(canvas 导出、拍照等),随服务器进程存在 */
|
|
221
|
-
private readonly
|
|
235
|
+
private readonly fileSessions;
|
|
222
236
|
private readonly devtoolsLogin;
|
|
223
237
|
/** 开启 --devtools-login 时才有 */
|
|
224
238
|
private readonly ticketSource;
|
|
225
239
|
private readonly plugins;
|
|
226
240
|
constructor(options: DevServerOptions);
|
|
241
|
+
/** 本机访问的地址 */
|
|
227
242
|
get url(): string;
|
|
243
|
+
/** 局域网里其他设备访问的地址,每块网卡一个;只监听本机时为空 */
|
|
244
|
+
get networkUrls(): string[];
|
|
228
245
|
start(): Promise<string>;
|
|
229
246
|
close(): Promise<void>;
|
|
230
247
|
private createApp;
|
|
@@ -254,4 +271,4 @@ interface WxConfigInput {
|
|
|
254
271
|
}
|
|
255
272
|
declare function createWxConfig(input: WxConfigInput): Record<string, any>;
|
|
256
273
|
|
|
257
|
-
export { AppBuilder, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerOptions, DeviceProfile, MiniProgram, type UnitJson, createWxConfig };
|
|
274
|
+
export { AppBuilder, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerOptions, DeviceProfile, ForwardConsole, MiniProgram, type UnitJson, createWxConfig };
|