@open-wxa/wxa-runner-core 0.11.0 → 0.12.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.
@@ -40,6 +40,8 @@ interface AppInfo {
40
40
  };
41
41
  /** 没有时不转发 */
42
42
  forwardConsole?: ForwardConsole;
43
+ /** web-view 的网页在新窗口打开,见 api/webView.ts 的 WebViewWindows */
44
+ webViewWindow?: boolean;
43
45
  }
44
46
 
45
47
  /**
@@ -40,6 +40,8 @@ interface AppInfo {
40
40
  };
41
41
  /** 没有时不转发 */
42
42
  forwardConsole?: ForwardConsole;
43
+ /** web-view 的网页在新窗口打开,见 api/webView.ts 的 WebViewWindows */
44
+ webViewWindow?: boolean;
43
45
  }
44
46
 
45
47
  /**
package/dist/setup.d.mts CHANGED
@@ -1 +1 @@
1
- export { K as KnownMocks, 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, k as SetupEnv, U as UserInfo, l as defineSetup } from './setup-DhDDVlit.mjs';
1
+ export { K as KnownMocks, 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, k as SetupEnv, U as UserInfo, l as defineSetup } from './setup-D0ubZt2C.mjs';
package/dist/setup.d.ts CHANGED
@@ -1 +1 @@
1
- export { K as KnownMocks, 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, k as SetupEnv, U as UserInfo, l as defineSetup } from './setup-DhDDVlit.js';
1
+ export { K as KnownMocks, 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, k as SetupEnv, U as UserInfo, l as defineSetup } from './setup-D0ubZt2C.js';
@@ -1,5 +1,5 @@
1
- import { W as WxaTestApi } from './testApi-BbK_1vhj.mjs';
2
- import './setup-DhDDVlit.mjs';
1
+ import { a as WxaTestApi } from './testApi-x2Yph6M2.mjs';
2
+ import './setup-D0ubZt2C.mjs';
3
3
 
4
4
  /**
5
5
  * window.__wxa_test_api__ 的全局类型声明,供测试代码按需引用:
@@ -17,5 +17,15 @@ declare global {
17
17
  * 这里调用 mock、route,App.onLaunch 里就能生效。抛错时模拟器显示错误,小程序不启动
18
18
  */
19
19
  __wxa_before_launch__?: (api: WxaTestApi) => unknown;
20
+ /**
21
+ * 由测试工具在页面脚本执行前设为 true,这次打开的小程序里 web-view 的网页在新窗口打开,
22
+ * 同开发服务器的 webViewWindow 选项(--webview-window)
23
+ */
24
+ __wxa_webview_window__?: boolean;
25
+ /**
26
+ * 由测试工具在页面脚本执行前定义。新窗口模式下宿主每新开一个网页窗口(type 为 'open',带上地址)、关掉一个窗口('close')时调用,
27
+ * name 同 webViews() 的 windowName。网页设置了 Cross-Origin-Opener-Policy 时窗口名会被清空、宿主也关不掉窗口,测试工具靠它对上窗口
28
+ */
29
+ __wxa_webview_window_event__?: (type: 'open' | 'close', name: string, src?: string) => Promise<void> | void;
20
30
  }
21
31
  }
@@ -1,5 +1,5 @@
1
- import { W as WxaTestApi } from './testApi-DbTnccYV.js';
2
- import './setup-DhDDVlit.js';
1
+ import { a as WxaTestApi } from './testApi-Df0ltBI6.js';
2
+ import './setup-D0ubZt2C.js';
3
3
 
4
4
  /**
5
5
  * window.__wxa_test_api__ 的全局类型声明,供测试代码按需引用:
@@ -17,5 +17,15 @@ declare global {
17
17
  * 这里调用 mock、route,App.onLaunch 里就能生效。抛错时模拟器显示错误,小程序不启动
18
18
  */
19
19
  __wxa_before_launch__?: (api: WxaTestApi) => unknown;
20
+ /**
21
+ * 由测试工具在页面脚本执行前设为 true,这次打开的小程序里 web-view 的网页在新窗口打开,
22
+ * 同开发服务器的 webViewWindow 选项(--webview-window)
23
+ */
24
+ __wxa_webview_window__?: boolean;
25
+ /**
26
+ * 由测试工具在页面脚本执行前定义。新窗口模式下宿主每新开一个网页窗口(type 为 'open',带上地址)、关掉一个窗口('close')时调用,
27
+ * name 同 webViews() 的 windowName。网页设置了 Cross-Origin-Opener-Policy 时窗口名会被清空、宿主也关不掉窗口,测试工具靠它对上窗口
28
+ */
29
+ __wxa_webview_window_event__?: (type: 'open' | 'close', name: string, src?: string) => Promise<void> | void;
20
30
  }
21
31
  }
@@ -1,4 +1,4 @@
1
- import { d as MockRequest, j as FrameKind, a as ApiHandler, b as ApiResult, R as RouteHandler } from './setup-DhDDVlit.mjs';
1
+ import { d as MockRequest, j as FrameKind, a as ApiHandler, b as ApiResult, R as RouteHandler } from './setup-D0ubZt2C.js';
2
2
 
3
3
  /**
4
4
  * 网络 API:wx.request / downloadFile / uploadFile / connectSocket
@@ -16,6 +16,28 @@ interface RecordedRequest extends MockRequest {
16
16
  routedBy: string | null;
17
17
  }
18
18
 
19
+ /**
20
+ * web-view 组件背后的原生网页视图
21
+ *
22
+ * 渲染层的 web-view 组件调 insertHTMLWebView 占位,updateHTMLWebView 设置地址和位置,
23
+ * 销毁时 removeHTMLWebView;加载进度通过渲染层的 onWebviewStartLoad / onWebviewFinishLoad
24
+ * 告诉组件,组件据此触发 bindload。
25
+ *
26
+ * 默认把网页放在所在页面渲染层里的 iframe 中,跟着页面显示、隐藏和关闭。这有两个限制:
27
+ * - 设置了 X-Frame-Options 或 CSP frame-ancestors 的网站不允许被嵌入,这类网页显示不出来
28
+ * - 网页和宿主域名不同时,浏览器按跨站嵌入处理:SameSite 为 Lax、Strict 或没写的 Cookie 存不下、也不发送,
29
+ * 网页的登录态因此失效。微信里 web-view 是独立的原生网页视图,没有这个问题
30
+ *
31
+ * 新窗口模式(--webview-window)把网页放到新窗口里打开,网页是顶层页面,绕开这两个限制,见 WebViewWindows
32
+ */
33
+
34
+ /** web-view 当前显示的网页,供测试 API 查询 */
35
+ interface WebViewInfo {
36
+ src: string;
37
+ /** 新窗口模式下网页所在窗口的 name;iframe 模式为 null */
38
+ windowName: string | null;
39
+ }
40
+
19
41
  interface FrameError {
20
42
  kind: FrameKind;
21
43
  webviewId: number;
@@ -44,6 +66,11 @@ interface WxaTestApi {
44
66
  currentPage(): PageSnapshot | null;
45
67
  /** 整个页面栈,栈底在前 */
46
68
  pageStack(): PageSnapshot[];
69
+ /**
70
+ * 当前页里设置过 src 的 web-view,按创建顺序;小程序启动前为空数组。
71
+ * 新窗口模式下 windowName 是网页所在窗口的 name,可以用它找到这个窗口;iframe 模式下为 null
72
+ */
73
+ webViews(): WebViewInfo[];
47
74
  /**
48
75
  * 等到指定页面成为当前页,已经是当前页时立即返回
49
76
  * @param path 页面路径,如 pages/index/index,开头的 / 可有可无
@@ -128,4 +155,4 @@ interface WxaTestApi {
128
155
  errors(): FrameError[];
129
156
  }
130
157
 
131
- export type { FrameError as F, PageSnapshot as P, RecordedRequest as R, WxaTestApi as W };
158
+ export type { FrameError as F, PageSnapshot as P, RecordedRequest as R, WebViewInfo as W, WxaTestApi as a };
@@ -1,4 +1,4 @@
1
- import { d as MockRequest, j as FrameKind, a as ApiHandler, b as ApiResult, R as RouteHandler } from './setup-DhDDVlit.js';
1
+ import { d as MockRequest, j as FrameKind, a as ApiHandler, b as ApiResult, R as RouteHandler } from './setup-D0ubZt2C.mjs';
2
2
 
3
3
  /**
4
4
  * 网络 API:wx.request / downloadFile / uploadFile / connectSocket
@@ -16,6 +16,28 @@ interface RecordedRequest extends MockRequest {
16
16
  routedBy: string | null;
17
17
  }
18
18
 
19
+ /**
20
+ * web-view 组件背后的原生网页视图
21
+ *
22
+ * 渲染层的 web-view 组件调 insertHTMLWebView 占位,updateHTMLWebView 设置地址和位置,
23
+ * 销毁时 removeHTMLWebView;加载进度通过渲染层的 onWebviewStartLoad / onWebviewFinishLoad
24
+ * 告诉组件,组件据此触发 bindload。
25
+ *
26
+ * 默认把网页放在所在页面渲染层里的 iframe 中,跟着页面显示、隐藏和关闭。这有两个限制:
27
+ * - 设置了 X-Frame-Options 或 CSP frame-ancestors 的网站不允许被嵌入,这类网页显示不出来
28
+ * - 网页和宿主域名不同时,浏览器按跨站嵌入处理:SameSite 为 Lax、Strict 或没写的 Cookie 存不下、也不发送,
29
+ * 网页的登录态因此失效。微信里 web-view 是独立的原生网页视图,没有这个问题
30
+ *
31
+ * 新窗口模式(--webview-window)把网页放到新窗口里打开,网页是顶层页面,绕开这两个限制,见 WebViewWindows
32
+ */
33
+
34
+ /** web-view 当前显示的网页,供测试 API 查询 */
35
+ interface WebViewInfo {
36
+ src: string;
37
+ /** 新窗口模式下网页所在窗口的 name;iframe 模式为 null */
38
+ windowName: string | null;
39
+ }
40
+
19
41
  interface FrameError {
20
42
  kind: FrameKind;
21
43
  webviewId: number;
@@ -44,6 +66,11 @@ interface WxaTestApi {
44
66
  currentPage(): PageSnapshot | null;
45
67
  /** 整个页面栈,栈底在前 */
46
68
  pageStack(): PageSnapshot[];
69
+ /**
70
+ * 当前页里设置过 src 的 web-view,按创建顺序;小程序启动前为空数组。
71
+ * 新窗口模式下 windowName 是网页所在窗口的 name,可以用它找到这个窗口;iframe 模式下为 null
72
+ */
73
+ webViews(): WebViewInfo[];
47
74
  /**
48
75
  * 等到指定页面成为当前页,已经是当前页时立即返回
49
76
  * @param path 页面路径,如 pages/index/index,开头的 / 可有可无
@@ -128,4 +155,4 @@ interface WxaTestApi {
128
155
  errors(): FrameError[];
129
156
  }
130
157
 
131
- export type { FrameError as F, PageSnapshot as P, RecordedRequest as R, WxaTestApi as W };
158
+ export type { FrameError as F, PageSnapshot as P, RecordedRequest as R, WebViewInfo as W, WxaTestApi as a };
package/dist/web.d.mts CHANGED
@@ -33,6 +33,8 @@ interface AppInfo {
33
33
  };
34
34
  /** 没有时不转发 */
35
35
  forwardConsole?: ForwardConsole;
36
+ /** web-view 的网页在新窗口打开,见 api/webView.ts 的 WebViewWindows */
37
+ webViewWindow?: boolean;
36
38
  }
37
39
 
38
40
  /**
package/dist/web.d.ts CHANGED
@@ -33,6 +33,8 @@ interface AppInfo {
33
33
  };
34
34
  /** 没有时不转发 */
35
35
  forwardConsole?: ForwardConsole;
36
+ /** web-view 的网页在新窗口打开,见 api/webView.ts 的 WebViewWindows */
37
+ webViewWindow?: boolean;
36
38
  }
37
39
 
38
40
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wxa/wxa-runner-core",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Dev server and browser runtime that run WeChat mini-programs on the official base library",
5
5
  "license": "MIT",
6
6
  "author": "open-wxa",
@@ -59,8 +59,8 @@
59
59
  "less": "^4.9.1",
60
60
  "sass": "~1.99.0",
61
61
  "ws": "^8.14.2",
62
- "@open-wxa/wxa-runner-extractor": "0.11.0",
63
- "@open-wxa/wxa-runner-compiler": "0.11.0"
62
+ "@open-wxa/wxa-runner-extractor": "0.12.0",
63
+ "@open-wxa/wxa-runner-compiler": "0.12.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/express": "^4.17.21",