@netless/slide 0.8.5-beta → 0.8.5

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/lib/global.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function preloadResource(taskId: string, prefix: string, resourceOnly: boolean): Promise<void>;
1
+ export declare function preloadResource(taskId: string, prefix: string, onProgress: (p: number) => void): Promise<void>;
package/lib/global.js CHANGED
@@ -35,16 +35,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  /**
38
- * 预加载静态资源, 调用后会一次性加载除媒体文件以外的远程资源
39
- * 需要设置 useLocalCache 参数 为 true, 才能
38
+ * 预加载静态资源, 调用后会一次性加载除媒体文件以外的远程资源,并生成必要的纹理缓存
39
+ * 创建 Slide 对象时需要设置 useLocalCache 参数 为 true
40
40
  * @param taskId 任务 id
41
41
  * @param prefix 任务进度 api 返回的资源前缀
42
42
  * @param resourceOnly boolean 类型
43
- * true 表示只加载远程资源(过程较快)
44
- * false 表示同时预加载远程资源和生成本地纹理缓存(过程较慢)
43
+ * @param onProgress 加载进度回调函数
45
44
  */
46
45
  import { Slide } from "./Slide";
47
- export function preloadResource(taskId, prefix, resourceOnly) {
46
+ export function preloadResource(taskId, prefix, onProgress) {
48
47
  return __awaiter(this, void 0, void 0, function () {
49
48
  var div, slide, slideCount, i;
50
49
  return __generator(this, function (_a) {
@@ -59,13 +58,13 @@ export function preloadResource(taskId, prefix, resourceOnly) {
59
58
  resolution: 1
60
59
  },
61
60
  mode: "local",
62
- interactive: false
61
+ interactive: false,
62
+ useLocalCache: true,
63
63
  });
64
64
  slide.setResource(taskId, prefix);
65
65
  return [4 /*yield*/, slide.getSlideCountAsync()];
66
66
  case 1:
67
67
  slideCount = _a.sent();
68
- if (!!resourceOnly) return [3 /*break*/, 6];
69
68
  i = 1;
70
69
  _a.label = 2;
71
70
  case 2:
@@ -75,15 +74,17 @@ export function preloadResource(taskId, prefix, resourceOnly) {
75
74
  case 3:
76
75
  // @ts-ignore
77
76
  _a.sent();
77
+ onProgress(Math.round((i / slideCount) * 100) / 100);
78
78
  _a.label = 4;
79
79
  case 4:
80
80
  i++;
81
81
  return [3 /*break*/, 2];
82
- case 5: return [3 /*break*/, 6];
83
- case 6:
82
+ case 5:
84
83
  slide.destroy();
85
84
  return [2 /*return*/];
86
85
  }
87
86
  });
88
87
  });
89
88
  }
89
+ // @ts-ignore
90
+ window.__preloadResource = preloadResource;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/slide",
3
- "version": "0.8.5-beta",
3
+ "version": "0.8.5",
4
4
  "description": "> TODO: description",
5
5
  "author": "huaguzheng <huaguzheng2007@126.com>",
6
6
  "homepage": "https://github.com/netless-io/netless-slide-demo",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "9807f4aae9ac4de2af8c09e764179152e9ed1be6"
39
+ "gitHead": "2cc0336f54c3ec7310603d693b485f601b8f4aab"
40
40
  }