@open-wxa/wxa-runner-core 0.4.0 → 0.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.
package/dist/index.d.mts CHANGED
@@ -15,6 +15,7 @@ interface AppJson {
15
15
  entryPagePath?: string;
16
16
  window?: Record<string, any>;
17
17
  tabBar?: {
18
+ custom?: boolean;
18
19
  list: Array<{
19
20
  pagePath: string;
20
21
  text?: string;
@@ -66,7 +67,7 @@ declare class MiniProgram {
66
67
  * 规则:/ 开头为根目录绝对路径;否则先按相对路径找,再沿目录向上查找 miniprogram_npm。
67
68
  */
68
69
  resolveComponent(fromId: string, ref: string): string | null;
69
- /** 收集所有页面以及它们(递归)引用到的自定义组件 */
70
+ /** 收集页面、隐式自定义 tabBar 及它们(递归)引用到的组件 */
70
71
  collectUnits(app: AppJson): {
71
72
  pages: string[];
72
73
  components: string[];
@@ -158,7 +159,7 @@ declare class AppBuilder {
158
159
  * /__wxa__/page-styles.js 渲染层的样式(热更新时重新下发)
159
160
  * /__baselib__/* 官方基础库
160
161
  * /__wxa__/proxy?url= 网络代理
161
- * /__wxa__/tmp 临时文件:POST ?type=png 保存,返回可直接访问的地址;对该地址 HEAD 查大小、DELETE 删除
162
+ * /__wxa__/tmp 临时文件:POST ?type=png 保存,返回可直接访问的地址(GET 支持分段请求);对该地址 HEAD 查大小、DELETE 删除
162
163
  * /__wxa__/region/<kind> 地区选择器用的行政区划数据(districts / streets),取自本机开发者工具
163
164
  * /__wxa__/api/* 真实登录(--real-login):wx.login 的 code、手机号,只允许本机访问
164
165
  * /__wxa__/ws 文件变化通知:热更新(hot)或整页刷新(reload)
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ interface AppJson {
15
15
  entryPagePath?: string;
16
16
  window?: Record<string, any>;
17
17
  tabBar?: {
18
+ custom?: boolean;
18
19
  list: Array<{
19
20
  pagePath: string;
20
21
  text?: string;
@@ -66,7 +67,7 @@ declare class MiniProgram {
66
67
  * 规则:/ 开头为根目录绝对路径;否则先按相对路径找,再沿目录向上查找 miniprogram_npm。
67
68
  */
68
69
  resolveComponent(fromId: string, ref: string): string | null;
69
- /** 收集所有页面以及它们(递归)引用到的自定义组件 */
70
+ /** 收集页面、隐式自定义 tabBar 及它们(递归)引用到的组件 */
70
71
  collectUnits(app: AppJson): {
71
72
  pages: string[];
72
73
  components: string[];
@@ -158,7 +159,7 @@ declare class AppBuilder {
158
159
  * /__wxa__/page-styles.js 渲染层的样式(热更新时重新下发)
159
160
  * /__baselib__/* 官方基础库
160
161
  * /__wxa__/proxy?url= 网络代理
161
- * /__wxa__/tmp 临时文件:POST ?type=png 保存,返回可直接访问的地址;对该地址 HEAD 查大小、DELETE 删除
162
+ * /__wxa__/tmp 临时文件:POST ?type=png 保存,返回可直接访问的地址(GET 支持分段请求);对该地址 HEAD 查大小、DELETE 删除
162
163
  * /__wxa__/region/<kind> 地区选择器用的行政区划数据(districts / streets),取自本机开发者工具
163
164
  * /__wxa__/api/* 真实登录(--real-login):wx.login 的 code、手机号,只允许本机访问
164
165
  * /__wxa__/ws 文件变化通知:热更新(hot)或整页刷新(reload)
package/dist/index.js CHANGED
@@ -412,7 +412,7 @@ var MiniProgram = class {
412
412
  }
413
413
  return null;
414
414
  }
415
- /** 收集所有页面以及它们(递归)引用到的自定义组件 */
415
+ /** 收集页面、隐式自定义 tabBar 及它们(递归)引用到的组件 */
416
416
  collectUnits(app) {
417
417
  const pages = this.allPages(app);
418
418
  const components = [];
@@ -423,15 +423,15 @@ var MiniProgram = class {
423
423
  for (const generic of Object.values(json.componentGenerics || {})) {
424
424
  if (typeof generic === "object" && generic.default) refs.push(generic.default);
425
425
  }
426
- for (const ref of refs) {
427
- const component = this.resolveComponent(id, ref);
428
- if (component && !visited.has(component)) {
429
- visited.add(component);
430
- components.push(component);
431
- visit(component);
432
- }
433
- }
426
+ for (const ref of refs) enter(this.resolveComponent(id, ref));
434
427
  };
428
+ const enter = (id) => {
429
+ if (!id || visited.has(id)) return;
430
+ visited.add(id);
431
+ components.push(id);
432
+ visit(id);
433
+ };
434
+ if (app.tabBar?.custom) enter(this.resolveComponent("app", "/custom-tab-bar/index"));
435
435
  pages.forEach(visit);
436
436
  return { pages, components };
437
437
  }
@@ -565,6 +565,9 @@ function webviewHtml(build2, pagePath, webviewId, options) {
565
565
  <!-- \u771F\u673A\u7684\u6EDA\u52A8\u6761\u662F\u4E0D\u5360\u5E03\u5C40\u7684\u6D6E\u5C42\uFF1B\u684C\u9762\u6D4F\u89C8\u5668\u7684\u5E38\u89C4\u6EDA\u52A8\u6761\u548C\u81EA\u5B9A\u4E49 ::-webkit-scrollbar \u4F1A\u6324\u7A84\u9875\u9762\uFF0C\u4E00\u5F8B\u9690\u85CF\u3002
566
566
  scrollbar-width \u4F18\u5148\u4E8E ::-webkit-scrollbar\uFF0C\u9875\u9762\u6837\u5F0F\u4E0D\u4F1A\u518D\u628A\u6EDA\u52A8\u6761\u52A0\u56DE\u6765 -->
567
567
  <style>*{scrollbar-width:none}::-webkit-scrollbar{display:none}</style>
568
+ <!-- \u903B\u8F91\u5C42\u5EFA\u7684 2d\u3001webgl \u753B\u5E03\u642C\u8FDB wx-canvas \u540E\u94FA\u6EE1\u5B83\uFF08\u89C1 frame.ts \u7684 moveCanvasesIntoPages\uFF09\u3002
569
+ \u57FA\u7840\u5E93\u8FD8\u4F1A\u6309\u903B\u8F91\u5C42\u91CC\u7684\u5E03\u5C40\u6539\u5B83\u7684\u4F4D\u7F6E\u548C\u663E\u9690\uFF0C\u8FD9\u91CC\u4E00\u5F8B\u538B\u4F4F\uFF1B\u89E6\u6478\u7167\u5E38\u4EA4\u7ED9 wx-canvas \u81EA\u5DF1\u7684 canvas -->
570
+ <style>.wxa-service-canvas{position:absolute!important;left:0!important;top:0!important;width:100%!important;height:100%!important;visibility:inherit!important;pointer-events:none}</style>
568
571
  <script>var __wxConfig = ${toJs(wxConfig)};</script>
569
572
  <script src="/__wxa__/runtime/frame.js" data-kind="webview" data-webview-id="${id}"></script>
570
573
  <script src="/__baselib__/WAWebview.js"></script>
@@ -1191,7 +1194,22 @@ ${error.message}`);
1191
1194
  res.status(404).end();
1192
1195
  return;
1193
1196
  }
1194
- res.type(import_path4.default.extname(req.params.name)).send(data);
1197
+ res.type(import_path4.default.extname(req.params.name));
1198
+ res.setHeader("ETag", `"${req.params.name}"`);
1199
+ res.setHeader("Accept-Ranges", "bytes");
1200
+ const ranges = req.range(data.length);
1201
+ if (ranges === -1) {
1202
+ res.status(416).setHeader("Content-Range", `bytes */${data.length}`);
1203
+ res.end();
1204
+ return;
1205
+ }
1206
+ if (Array.isArray(ranges) && ranges.type === "bytes" && ranges.length === 1) {
1207
+ const { start, end } = ranges[0];
1208
+ res.status(206).setHeader("Content-Range", `bytes ${start}-${end}/${data.length}`);
1209
+ res.send(data.subarray(start, end + 1));
1210
+ return;
1211
+ }
1212
+ res.send(data);
1195
1213
  });
1196
1214
  app.delete("/__wxa__/tmp/:name", (req, res) => {
1197
1215
  res.status(this.tempFiles.delete(req.params.name) ? 204 : 404).end();