@open-wxa/wxa-runner-core 0.10.0 → 0.11.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.
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { IncomingMessage, ServerResponse } from 'http';
1
+ import http, { IncomingMessage, ServerResponse } from 'http';
2
2
  import { ResolvedBaseLib } from '@open-wxa/wxa-runner-extractor';
3
- import { D as DeviceProfile, F as ForwardConsole } from './setup-Bac8XdhR.mjs';
4
- 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';
5
- export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-DHuEW5Cl.mjs';
3
+ import { D as DeviceProfile, F as ForwardConsole } from './setup-DhDDVlit.mjs';
4
+ 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-DhDDVlit.mjs';
5
+ import { Request, Response } from 'express';
6
+ export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-BbK_1vhj.mjs';
6
7
 
7
8
  /**
8
9
  * 样式预处理:project.config.json 的 setting.useCompilerPlugins 开启 less / sass 时,
@@ -201,6 +202,15 @@ declare class AppBuilder {
201
202
  private createServiceBootstrap;
202
203
  }
203
204
 
205
+ /**
206
+ * 小程序页面与代码的路由:逻辑层、子上下文、渲染层的 HTML,业务模块、模板、样式和插件代码
207
+ *
208
+ * 开发服务器和查看器(wxapack)的 Service Worker 共用这一份,两边生成的页面才不会走样,所以不依赖 Node。
209
+ * app-info、setup、静态资源、文件接口等和运行环境有关的路由各自实现。
210
+ */
211
+
212
+ declare const DEFAULT_DEVICE: DeviceProfile;
213
+
204
214
  /**
205
215
  * 开发服务器扩展:检查器这类开发工具把要用的扩展点打包成一个扩展,
206
216
  * 由 DevServer 的 extensions 选项或命令行的 --extension 加载。runner 只认这个约定,不认识具体的工具。
@@ -325,7 +335,7 @@ interface DevServerOptions {
325
335
  extensions?: DevServerExtension[];
326
336
  logger?: Pick<Console, 'log' | 'warn' | 'error'>;
327
337
  }
328
- declare const DEFAULT_DEVICE: DeviceProfile;
338
+
329
339
  declare class DevServer {
330
340
  private readonly options;
331
341
  readonly project: MiniProgram;
@@ -366,6 +376,7 @@ declare class DevServer {
366
376
  /** 构建结果并入这次打开小程序时决定用的插件 */
367
377
  private currentBuild;
368
378
  /** 需要构建结果的路由;构建失败时返回错误文本 */
379
+ private appSource;
369
380
  private withBuild;
370
381
  private runtimeDir;
371
382
  /** 只在监听文件变化时打开基础库的热更新开关,跑测试(watch: false)时运行环境与真机一致 */
@@ -373,6 +384,35 @@ declare class DevServer {
373
384
  private startWatching;
374
385
  private broadcast;
375
386
  }
387
+ /** 监听所有地址时,本机访问用的地址:0.0.0.0 只监听 IPv4,localhost 可能解析到 IPv6 的 ::1 */
388
+ declare const LOCAL_HOST_OF_ANY_ADDRESS: Map<string, string>;
389
+ /** 开始监听,返回实际的端口。没指定端口时从 3000 起往后找空闲的,换了端口在终端提示 */
390
+ declare function listen(server: http.Server, port: number | undefined, host: string, logger: Pick<Console, 'warn'>): Promise<number>;
391
+ /**
392
+ * 浏览器端运行时(host.js、frame.js 等)所在目录:给了 explicit 就用它,否则找本包的构建产物
393
+ * @throws 都没有 host.js 时(源码运行但还没 pnpm build)
394
+ */
395
+ declare function findRuntimeDir(explicit?: string): string;
396
+
397
+ /** 项目目录(project.config.json 所在目录)下约定名称的 setup 文件 */
398
+ declare function findSetupFile(projectPath: string): string | null;
399
+ /**
400
+ * 把 setup 文件连同它 import 的文件打成一个浏览器 ES 模块
401
+ *
402
+ * 用户的小程序项目里通常没装本包,对它的引用直接换成运行时自带的实现。
403
+ *
404
+ * @throws 语法错误、import 找不到等编译错误,消息里带相对 setup 文件目录的位置
405
+ */
406
+ declare function bundleSetup(file: string): Promise<string>;
407
+
408
+ /**
409
+ * 开发服务器和本机查看器的网络代理:把 express 的请求转成 Fetch 请求交给 proxyFetch.ts,再把响应流式写回
410
+ */
411
+
412
+ /**
413
+ * 用 app.use 挂载,保留未解码的 originalUrl:Express 通配路由会解码 %2F,甚至拒绝单独的 %。
414
+ */
415
+ declare function handleProxy(req: Request, res: Response): Promise<void>;
376
416
 
377
417
  /**
378
418
  * 生成基础库读取的 __wxConfig,字段与开发者工具保持一致
@@ -387,4 +427,4 @@ interface WxConfigInput {
387
427
  }
388
428
  declare function createWxConfig(input: WxConfigInput): Record<string, any>;
389
429
 
390
- export { AppBuilder, type AppBuilderOptions, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerExtension, type DevServerMiddleware, type DevServerOptions, DeviceProfile, type ExtensionContext, type ExtensionEntry, type ExtensionSetup, ForwardConsole, MiniProgram, type UnitJson, type WebviewScript, createWxConfig };
430
+ export { AppBuilder, type AppBuilderOptions, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerExtension, type DevServerMiddleware, type DevServerOptions, DeviceProfile, type ExtensionContext, type ExtensionEntry, type ExtensionSetup, ForwardConsole, LOCAL_HOST_OF_ANY_ADDRESS, MiniProgram, type UnitJson, type WebviewScript, bundleSetup, createWxConfig, findRuntimeDir, findSetupFile, handleProxy, listen };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { IncomingMessage, ServerResponse } from 'http';
1
+ import http, { IncomingMessage, ServerResponse } from 'http';
2
2
  import { ResolvedBaseLib } from '@open-wxa/wxa-runner-extractor';
3
- import { D as DeviceProfile, F as ForwardConsole } from './setup-Bac8XdhR.js';
4
- 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';
5
- export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-BOZSXSnV.js';
3
+ import { D as DeviceProfile, F as ForwardConsole } from './setup-DhDDVlit.js';
4
+ 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-DhDDVlit.js';
5
+ import { Request, Response } from 'express';
6
+ export { F as FrameError, P as PageSnapshot, R as RecordedRequest, W as WxaTestApi } from './testApi-DbTnccYV.js';
6
7
 
7
8
  /**
8
9
  * 样式预处理:project.config.json 的 setting.useCompilerPlugins 开启 less / sass 时,
@@ -201,6 +202,15 @@ declare class AppBuilder {
201
202
  private createServiceBootstrap;
202
203
  }
203
204
 
205
+ /**
206
+ * 小程序页面与代码的路由:逻辑层、子上下文、渲染层的 HTML,业务模块、模板、样式和插件代码
207
+ *
208
+ * 开发服务器和查看器(wxapack)的 Service Worker 共用这一份,两边生成的页面才不会走样,所以不依赖 Node。
209
+ * app-info、setup、静态资源、文件接口等和运行环境有关的路由各自实现。
210
+ */
211
+
212
+ declare const DEFAULT_DEVICE: DeviceProfile;
213
+
204
214
  /**
205
215
  * 开发服务器扩展:检查器这类开发工具把要用的扩展点打包成一个扩展,
206
216
  * 由 DevServer 的 extensions 选项或命令行的 --extension 加载。runner 只认这个约定,不认识具体的工具。
@@ -325,7 +335,7 @@ interface DevServerOptions {
325
335
  extensions?: DevServerExtension[];
326
336
  logger?: Pick<Console, 'log' | 'warn' | 'error'>;
327
337
  }
328
- declare const DEFAULT_DEVICE: DeviceProfile;
338
+
329
339
  declare class DevServer {
330
340
  private readonly options;
331
341
  readonly project: MiniProgram;
@@ -366,6 +376,7 @@ declare class DevServer {
366
376
  /** 构建结果并入这次打开小程序时决定用的插件 */
367
377
  private currentBuild;
368
378
  /** 需要构建结果的路由;构建失败时返回错误文本 */
379
+ private appSource;
369
380
  private withBuild;
370
381
  private runtimeDir;
371
382
  /** 只在监听文件变化时打开基础库的热更新开关,跑测试(watch: false)时运行环境与真机一致 */
@@ -373,6 +384,35 @@ declare class DevServer {
373
384
  private startWatching;
374
385
  private broadcast;
375
386
  }
387
+ /** 监听所有地址时,本机访问用的地址:0.0.0.0 只监听 IPv4,localhost 可能解析到 IPv6 的 ::1 */
388
+ declare const LOCAL_HOST_OF_ANY_ADDRESS: Map<string, string>;
389
+ /** 开始监听,返回实际的端口。没指定端口时从 3000 起往后找空闲的,换了端口在终端提示 */
390
+ declare function listen(server: http.Server, port: number | undefined, host: string, logger: Pick<Console, 'warn'>): Promise<number>;
391
+ /**
392
+ * 浏览器端运行时(host.js、frame.js 等)所在目录:给了 explicit 就用它,否则找本包的构建产物
393
+ * @throws 都没有 host.js 时(源码运行但还没 pnpm build)
394
+ */
395
+ declare function findRuntimeDir(explicit?: string): string;
396
+
397
+ /** 项目目录(project.config.json 所在目录)下约定名称的 setup 文件 */
398
+ declare function findSetupFile(projectPath: string): string | null;
399
+ /**
400
+ * 把 setup 文件连同它 import 的文件打成一个浏览器 ES 模块
401
+ *
402
+ * 用户的小程序项目里通常没装本包,对它的引用直接换成运行时自带的实现。
403
+ *
404
+ * @throws 语法错误、import 找不到等编译错误,消息里带相对 setup 文件目录的位置
405
+ */
406
+ declare function bundleSetup(file: string): Promise<string>;
407
+
408
+ /**
409
+ * 开发服务器和本机查看器的网络代理:把 express 的请求转成 Fetch 请求交给 proxyFetch.ts,再把响应流式写回
410
+ */
411
+
412
+ /**
413
+ * 用 app.use 挂载,保留未解码的 originalUrl:Express 通配路由会解码 %2F,甚至拒绝单独的 %。
414
+ */
415
+ declare function handleProxy(req: Request, res: Response): Promise<void>;
376
416
 
377
417
  /**
378
418
  * 生成基础库读取的 __wxConfig,字段与开发者工具保持一致
@@ -387,4 +427,4 @@ interface WxConfigInput {
387
427
  }
388
428
  declare function createWxConfig(input: WxConfigInput): Record<string, any>;
389
429
 
390
- export { AppBuilder, type AppBuilderOptions, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerExtension, type DevServerMiddleware, type DevServerOptions, DeviceProfile, type ExtensionContext, type ExtensionEntry, type ExtensionSetup, ForwardConsole, MiniProgram, type UnitJson, type WebviewScript, createWxConfig };
430
+ export { AppBuilder, type AppBuilderOptions, type AppJson, type BuildResult, DEFAULT_DEVICE, DevServer, type DevServerExtension, type DevServerMiddleware, type DevServerOptions, DeviceProfile, type ExtensionContext, type ExtensionEntry, type ExtensionSetup, ForwardConsole, LOCAL_HOST_OF_ANY_ADDRESS, MiniProgram, type UnitJson, type WebviewScript, bundleSetup, createWxConfig, findRuntimeDir, findSetupFile, handleProxy, listen };