@netless/slide 1.4.22 → 1.4.23

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.
@@ -1,664 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (_) try {
32
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- import * as localForage from "localforage";
53
- import { PPTPlayer, PLAYER_EVENTS } from "@netless/ppt-player";
54
- import { isEqual } from "lodash";
55
- import EventEmitter from "eventemitter3";
56
- import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
57
- import { RenderingTaskManager } from "./RenderingTaskManager";
58
- import { waitUntil } from "./waitUntil";
59
- import { PlayerController } from "./PlayerController";
60
- // @ts-ignore
61
- if (!window.__slide_local_logger__) {
62
- // @ts-ignore
63
- window.__slide_local_logger__ = localForage.createInstance({
64
- name: "_slide_local_log_",
65
- driver: localForage.INDEXEDDB,
66
- version: 1,
67
- });
68
- }
69
- // @ts-ignore
70
- var logger = window.__slide_local_logger__;
71
- var ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
72
- export var SLIDE_EVENTS = {
73
- /** 当前 slide 渲染开始触发 */
74
- renderStart: "renderStart",
75
- /** 当前 slide 渲染完毕触发 */
76
- renderEnd: "renderEnd",
77
- /** 当前 slide 渲染出错触发 */
78
- renderError: "renderError",
79
- /** slide 页码变化时触发 */
80
- slideChange: "slideChange",
81
- // 任意动画开始时触发
82
- animateStart: "animateStart",
83
- // 任意动画结束时触发
84
- animateEnd: "animateEnd",
85
- /** slide 状态变化触发 */
86
- stateChange: "stateChange",
87
- };
88
- var StateDriveSlide = /** @class */ (function (_super) {
89
- __extends(StateDriveSlide, _super);
90
- function StateDriveSlide(config) {
91
- var _this = _super.call(this) || this;
92
- _this.__slideState = {
93
- taskId: "",
94
- url: "",
95
- currentSlideIndex: 0,
96
- timeNodeSeqState: Object.create(null),
97
- mediaState: Object.create(null),
98
- };
99
- _this.resize = false;
100
- _this.isAnimating = false;
101
- _this.renderingTaskManager = new RenderingTaskManager();
102
- _this.isLoading = false;
103
- _this.interactive = true;
104
- _this.frameWidth = 1;
105
- _this.frameHeight = 1;
106
- _this.frame = document.createElement("div");
107
- _this.medianController = document.createElement("div");
108
- _this.frameResizeObserver = new ResizeObserver(function (entries) {
109
- return _this.frameResizeHandler(entries);
110
- });
111
- _this.timestamp = function () { return Date.now(); };
112
- _this.mode = "local";
113
- _this.log = "";
114
- _this.logId = "";
115
- _this.lastEmitedState = null;
116
- _this.persistLog = function () { return __awaiter(_this, void 0, void 0, function () {
117
- var log, pre, _a;
118
- return __generator(this, function (_b) {
119
- switch (_b.label) {
120
- case 0:
121
- if (!(logger && this.logId)) return [3 /*break*/, 5];
122
- _b.label = 1;
123
- case 1:
124
- _b.trys.push([1, 4, , 5]);
125
- log = this.log;
126
- return [4 /*yield*/, logger.getItem(this.logId)];
127
- case 2:
128
- pre = (_b.sent()) || "";
129
- return [4 /*yield*/, logger.setItem(this.logId, pre + log)];
130
- case 3:
131
- _b.sent();
132
- this.log = "";
133
- return [3 /*break*/, 5];
134
- case 4:
135
- _a = _b.sent();
136
- return [3 /*break*/, 5];
137
- case 5: return [2 /*return*/];
138
- }
139
- });
140
- }); };
141
- _this.handleSlideStateLog = function () {
142
- console.log(_this.logId);
143
- console.log(JSON.stringify(_this.slideState, null, 2));
144
- };
145
- _this.handleLogDownload = function () { return __awaiter(_this, void 0, void 0, function () {
146
- var logStr, _a, element;
147
- return __generator(this, function (_b) {
148
- switch (_b.label) {
149
- case 0:
150
- logStr = "";
151
- if (!logger) return [3 /*break*/, 2];
152
- _a = logStr;
153
- return [4 /*yield*/, logger.getItem(this.logId)];
154
- case 1:
155
- logStr = _a + ((_b.sent()) || "");
156
- _b.label = 2;
157
- case 2:
158
- logStr += this.log;
159
- element = document.createElement('a');
160
- element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(logStr));
161
- element.setAttribute('download', this.logId);
162
- element.style.display = 'none';
163
- document.body.appendChild(element);
164
- element.click();
165
- document.body.removeChild(element);
166
- return [2 /*return*/];
167
- }
168
- });
169
- }); };
170
- if (config.timestamp) {
171
- _this.timestamp = config.timestamp;
172
- }
173
- _this.anchor = config.anchor;
174
- _this.resize = config.resize || false;
175
- _this.interactive = config.interactive;
176
- _this.player = new PPTPlayer(_this.mode);
177
- _this.player.setInteractive(_this.interactive);
178
- _this.player.updateConfig(config.renderOptions || {});
179
- _this.frame.style.cssText = "width:100%;height:100%;display:flex;justify-content:center;align-items:center";
180
- _this.frame.appendChild(_this.player.view);
181
- _this.setMedianControllerAttribute();
182
- _this.frame.appendChild(_this.medianController);
183
- _this.anchor.appendChild(_this.frame);
184
- if (config === null || config === void 0 ? void 0 : config.controller) {
185
- new PlayerController({
186
- player: _this.player,
187
- params: config.renderOptions || {},
188
- target: _this.frame
189
- });
190
- }
191
- _this.frameResizeObserver.observe(_this.frame);
192
- _this.player.on(PLAYER_EVENTS.renderStart, function (index) {
193
- _this.isLoading = true;
194
- _this.emit(SLIDE_EVENTS.renderStart, index);
195
- });
196
- _this.player.on(PLAYER_EVENTS.renderEnd, function (index) {
197
- _this.isLoading = false;
198
- _this.emit(SLIDE_EVENTS.renderEnd, index);
199
- });
200
- _this.player.on(PLAYER_EVENTS.slideChange, function (nextSlideIndex) {
201
- _this.__slideState.currentSlideIndex = nextSlideIndex;
202
- _this.emit(SLIDE_EVENTS.slideChange, nextSlideIndex);
203
- });
204
- _this.player.on(PLAYER_EVENTS.seqStateChange, function (args) {
205
- _this.__slideState.timeNodeSeqState[args.id] = args;
206
- _this.emitStateChange();
207
- });
208
- _this.player.on(PLAYER_EVENTS.seqStepChange, function (args) {
209
- _this.__slideState.timeNodeSeqState[args.id] = args;
210
- _this.emitStateChange();
211
- });
212
- _this.player.on(PLAYER_EVENTS.animateStart, function () {
213
- if (_this.isAnimating !== true) {
214
- _this.isAnimating = true;
215
- _this.emit(SLIDE_EVENTS.animateStart);
216
- }
217
- });
218
- _this.player.on(PLAYER_EVENTS.animateEnd, function () {
219
- if (_this.isAnimating !== false) {
220
- _this.isAnimating = false;
221
- _this.emit(SLIDE_EVENTS.animateEnd);
222
- }
223
- });
224
- _this.player.on(PLAYER_EVENTS.mediaPlay, function (evt) {
225
- var mediaState = {
226
- type: "play",
227
- time: _this.timestamp() - evt.time * 1000,
228
- };
229
- _this.__slideState.mediaState[evt.id] = mediaState;
230
- _this.emitStateChange();
231
- });
232
- _this.player.on(PLAYER_EVENTS.mediaPause, function (evt) {
233
- var mediaState = {
234
- type: "pause",
235
- time: evt.time,
236
- };
237
- _this.__slideState.mediaState[evt.id] = mediaState;
238
- _this.emitStateChange();
239
- });
240
- _this.player.on(PLAYER_EVENTS.mediaSeek, function (evt) {
241
- var state = {
242
- type: "pause",
243
- time: 0,
244
- };
245
- if (evt.isPlaying) {
246
- state.type = "play";
247
- if (_this.__slideState.mediaState[evt.id]) {
248
- state.time = _this.__slideState.mediaState[evt.id].time - evt.time * 1000;
249
- }
250
- else {
251
- state.time = _this.timestamp() - evt.time * 1000;
252
- }
253
- _this.__slideState.mediaState[evt.id] = state;
254
- }
255
- else {
256
- state.type = "pause";
257
- state.time = evt.time;
258
- _this.__slideState.mediaState[evt.id] = state;
259
- }
260
- _this.emitStateChange();
261
- });
262
- _this.renderingTaskManager.eventHub.on("task-error", function (_a) {
263
- var error = _a.error, task = _a.task;
264
- _this.emit(SLIDE_EVENTS.renderError, { error: error, index: task.slideIndex });
265
- });
266
- window.addEventListener("__slide_log__", _this.handleLogDownload);
267
- window.addEventListener("__slide_state__", _this.handleSlideStateLog);
268
- _this.persistLogId = window.setInterval(_this.persistLog, 5000);
269
- return _this;
270
- }
271
- StateDriveSlide.prototype.setMedianControllerAttribute = function () {
272
- this.medianController.id = "median-container";
273
- this.medianController.style.position = "absolute";
274
- this.medianController.style.left = "0";
275
- this.medianController.style.top = "0";
276
- this.medianController.style.zIndex = "2";
277
- };
278
- StateDriveSlide.prototype.frameResizeHandler = function (entries) {
279
- var _a = entries[0].contentRect, width = _a.width, height = _a.height;
280
- this.frameWidth = width;
281
- this.frameHeight = height;
282
- this.resizeView();
283
- };
284
- StateDriveSlide.prototype.resizeView = function () {
285
- var _this = this;
286
- var viewWidth = this.width;
287
- var viewHeight = this.height;
288
- if (viewWidth > 0 && viewHeight > 0) {
289
- var scale_1 = this.frameWidth / viewWidth;
290
- var nextHeight = scale_1 * viewHeight;
291
- if (nextHeight > this.frameHeight) {
292
- scale_1 *= this.frameHeight / nextHeight;
293
- }
294
- if (this.resize) {
295
- // @ts-ignore
296
- var app_1 = this.player.app;
297
- app_1.ticker.addOnce(function () {
298
- var r = scale_1 * (_this.player.config.resolution || window.devicePixelRatio);
299
- app_1.renderer.resolution = r;
300
- app_1.renderer.plugins.interaction.resolution = app_1.renderer.resolution;
301
- app_1.renderer.resize(_this.width, _this.height);
302
- });
303
- }
304
- this.view.style.transform = "scale(" + scale_1 + ")";
305
- this.medianController.style.transform = "scale(" + scale_1 + ")";
306
- this.medianController.style.top = (this.frameHeight - viewHeight * scale_1) / 2 + "px";
307
- }
308
- };
309
- /**
310
- * 设置整个 slide 的状态, slide 会以传入的状态更新画面.
311
- * 供整体同步时候调用.
312
- * @param state ISlideState
313
- */
314
- StateDriveSlide.prototype.setSlideState = function (state) {
315
- return __awaiter(this, void 0, void 0, function () {
316
- var keys, i, len, key, next, current;
317
- var _this = this;
318
- return __generator(this, function (_a) {
319
- switch (_a.label) {
320
- case 0:
321
- this.log += "=== stateChange receive [" + new Date().toISOString() + "] ===\n";
322
- this.log += JSON.stringify(state, null, 2);
323
- this.log += "\n\n";
324
- if (state.taskId && state.taskId !== this.__slideState.taskId) {
325
- this.__slideState.taskId = state.taskId;
326
- this.player.setResourceData(state.taskId, this.__slideState.url);
327
- }
328
- if (state.url && state.url !== this.__slideState.url) {
329
- this.__slideState.url = state.url;
330
- this.player.setResourceData(this.__slideState.taskId, state.url);
331
- }
332
- if (!(Number.isInteger(state.currentSlideIndex) && state.currentSlideIndex !== this.__slideState.currentSlideIndex)) return [3 /*break*/, 2];
333
- this.__slideState.currentSlideIndex = state.currentSlideIndex;
334
- return [4 /*yield*/, this.doRenderSlide(state.currentSlideIndex)];
335
- case 1:
336
- _a.sent();
337
- _a.label = 2;
338
- case 2:
339
- // @ts-ignore
340
- return [4 /*yield*/, waitUntil(function () { return _this.player.currentIndex === state.currentSlideIndex && _this.player.currentStage; }, 30000)];
341
- case 3:
342
- // @ts-ignore
343
- _a.sent();
344
- if (state.timeNodeSeqState) {
345
- keys = Object.keys(state.timeNodeSeqState);
346
- for (i = 0, len = keys.length; i < len; i++) {
347
- key = keys[i];
348
- next = state.timeNodeSeqState[key];
349
- current = this.__slideState.timeNodeSeqState[key];
350
- if (current) {
351
- this.player.setTimeNodeSeqStep(key, next.step, next.state);
352
- }
353
- }
354
- }
355
- if (state.mediaState) {
356
- this.initMedia(state);
357
- this.__slideState.mediaState = state.mediaState;
358
- }
359
- return [2 /*return*/];
360
- }
361
- });
362
- });
363
- };
364
- StateDriveSlide.prototype.initMedia = function (state) {
365
- var _this = this;
366
- var _loop_1 = function (key) {
367
- var mediaState = state.mediaState[key];
368
- var oldState = this_1.__slideState.mediaState[key];
369
- if (oldState && mediaState.type === oldState.type && mediaState.time === oldState.time) {
370
- return "continue";
371
- }
372
- if (mediaState.type === "play") {
373
- this_1.player.setMediaState(key, true).then(function () {
374
- var now = _this.timestamp();
375
- _this.player.setMediaCurrentTime(key, (now - mediaState.time) / 1000);
376
- });
377
- }
378
- else {
379
- this_1.player.setMediaState(key, false).then(function () {
380
- _this.player.setMediaCurrentTime(key, mediaState.time);
381
- });
382
- }
383
- };
384
- var this_1 = this;
385
- for (var key in state.mediaState) {
386
- _loop_1(key);
387
- }
388
- };
389
- Object.defineProperty(StateDriveSlide.prototype, "slideCount", {
390
- /**
391
- * 返回 slide 总页数
392
- */
393
- get: function () {
394
- return this.player.slideCount;
395
- },
396
- enumerable: false,
397
- configurable: true
398
- });
399
- Object.defineProperty(StateDriveSlide.prototype, "slideState", {
400
- /**
401
- * 整个 slide 的状态, 将获取的值传递给另一个客户端, 并调用 setSlideState
402
- * 可以完成整体同步. 只读属性.
403
- * @readonly
404
- */
405
- get: function () {
406
- return JSON.parse(JSON.stringify(this.__slideState));
407
- },
408
- enumerable: false,
409
- configurable: true
410
- });
411
- Object.defineProperty(StateDriveSlide.prototype, "mainSeqLength", {
412
- /**
413
- * 主序列动画步数, 只读属性
414
- * @readonly
415
- */
416
- get: function () {
417
- return this.player.mainSeqLength();
418
- },
419
- enumerable: false,
420
- configurable: true
421
- });
422
- Object.defineProperty(StateDriveSlide.prototype, "mainSeqStep", {
423
- /**
424
- * 主序列动画, 当前步, 只读属性
425
- * @readonly
426
- */
427
- get: function () {
428
- return this.player.mainSeqStep();
429
- },
430
- enumerable: false,
431
- configurable: true
432
- });
433
- Object.defineProperty(StateDriveSlide.prototype, "mainSeqState", {
434
- /**
435
- * 主序列动画, 当前状态, 只读属性
436
- * "idle": 动画尚未运行
437
- * "running": 动画运行中
438
- * "end": 动画已经结束
439
- * null: 当前 Slide 没有主序列动画
440
- * @readonly
441
- */
442
- get: function () {
443
- return this.player.mainSeqState();
444
- },
445
- enumerable: false,
446
- configurable: true
447
- });
448
- Object.defineProperty(StateDriveSlide.prototype, "renderOptions", {
449
- /**
450
- * 实时渲染属性, 只读属性.
451
- * @readonly
452
- */
453
- get: function () {
454
- return this.player.config;
455
- },
456
- enumerable: false,
457
- configurable: true
458
- });
459
- Object.defineProperty(StateDriveSlide.prototype, "drawCall", {
460
- /**
461
- * drawCall 次数, 即每帧调用 gpu drawElements 次数, 只读属性.
462
- * @readonly
463
- */
464
- get: function () {
465
- return this.player.runtime.drawCall;
466
- },
467
- enumerable: false,
468
- configurable: true
469
- });
470
- Object.defineProperty(StateDriveSlide.prototype, "renderFps", {
471
- /**
472
- * 渲染 fps, 只读属性.
473
- * @readonly
474
- */
475
- get: function () {
476
- return this.player.runtime.fps;
477
- },
478
- enumerable: false,
479
- configurable: true
480
- });
481
- Object.defineProperty(StateDriveSlide.prototype, "runtimeFps", {
482
- /**
483
- * js 运行时 fps, 只读属性.
484
- * @readonly
485
- */
486
- get: function () {
487
- return this.player.fps.value;
488
- },
489
- enumerable: false,
490
- configurable: true
491
- });
492
- Object.defineProperty(StateDriveSlide.prototype, "view", {
493
- /**
494
- * 渲染 Slide 的 canvas 元素.
495
- * @readonly
496
- */
497
- get: function () {
498
- return this.player.view;
499
- },
500
- enumerable: false,
501
- configurable: true
502
- });
503
- Object.defineProperty(StateDriveSlide.prototype, "width", {
504
- /**
505
- * Slide 宽度. 此宽度为设计宽度, 由 ppt 决定. 只读属性.
506
- * @readonly
507
- */
508
- get: function () {
509
- return this.player.width;
510
- },
511
- enumerable: false,
512
- configurable: true
513
- });
514
- Object.defineProperty(StateDriveSlide.prototype, "height", {
515
- /**
516
- * Slide 高度. 此高度为设计高度, 由 ppt 决定. 只读属性.
517
- * @readonly
518
- */
519
- get: function () {
520
- return this.player.height;
521
- },
522
- enumerable: false,
523
- configurable: true
524
- });
525
- /**
526
- * 更新渲染属性
527
- * @param renderOptions
528
- */
529
- StateDriveSlide.prototype.updateRenderOption = function (renderOptions) {
530
- this.player.updateConfig(renderOptions);
531
- };
532
- /**
533
- * 设置 ppt 转换后的资源
534
- * @param taskId 转换任务 id
535
- * @param url 资源 url 前缀
536
- */
537
- StateDriveSlide.prototype.setResource = function (taskId, url) {
538
- this.player.setResourceData(taskId, url);
539
- this.__slideState.taskId = taskId;
540
- this.__slideState.url = url;
541
- this.logId = taskId + "-" + Math.random().toString(32).substr(2);
542
- this.emitStateChange();
543
- };
544
- StateDriveSlide.prototype._renderSlide = function (index) {
545
- return __awaiter(this, void 0, void 0, function () {
546
- return __generator(this, function (_a) {
547
- switch (_a.label) {
548
- case 0:
549
- this.isLoading = true;
550
- return [4 /*yield*/, this.player.renderSlide(index)];
551
- case 1:
552
- _a.sent();
553
- this.__slideState.currentSlideIndex = index;
554
- this.isLoading = false;
555
- this.resizeView();
556
- this.emitStateChange();
557
- return [2 /*return*/];
558
- }
559
- });
560
- });
561
- };
562
- /**
563
- * 渲染 index 参数对应的 ppt 页.
564
- * @param index 要显示的页码, 从 1 开始
565
- */
566
- StateDriveSlide.prototype.renderSlide = function (index) {
567
- var indexNum = Number(index);
568
- if (indexNum === this.player.currentIndex && !this.renderingTaskManager.hasStartTask()) {
569
- return;
570
- }
571
- if (indexNum > this.slideCount && this.slideCount > 0) {
572
- return;
573
- }
574
- this.doRenderSlide(indexNum);
575
- };
576
- StateDriveSlide.prototype.doRenderSlide = function (index) {
577
- var _this = this;
578
- this.player.clearForward();
579
- this.renderingTaskManager.addTask(function () { return _this._renderSlide(index); }, index);
580
- };
581
- /**
582
- * 执行下一个主序列动画
583
- */
584
- StateDriveSlide.prototype.nextStep = function () {
585
- if (this.isLoading) {
586
- return;
587
- }
588
- this.player.nextStep();
589
- };
590
- /**
591
- * 执行上一个主序列动画
592
- */
593
- StateDriveSlide.prototype.prevStep = function () {
594
- if (this.isLoading) {
595
- return;
596
- }
597
- this.player.prevStep();
598
- };
599
- StateDriveSlide.prototype.emitStateChange = function () {
600
- if (this.mode !== "local") {
601
- var nextState = this.slideState;
602
- if (!isEqual(this.lastEmitedState, nextState)) {
603
- this.lastEmitedState = nextState;
604
- this.emit(SLIDE_EVENTS.stateChange, this.slideState);
605
- this.log += "=== stateChange dispatch [" + new Date().toISOString() + "] ===\n";
606
- this.log += JSON.stringify(this.slideState, null, 2);
607
- this.log += "\n\n";
608
- }
609
- }
610
- };
611
- /**
612
- * 重置主序列动画
613
- * @param index 将要重置到的步数
614
- * @param status 将要重置到的状态, "start" 重置到动画开始, "end" 重置到动画结束
615
- */
616
- StateDriveSlide.prototype.setMainSeqStep = function (index, status) {
617
- this.player.setMainSeqStep(index, status);
618
- };
619
- /**
620
- * 设置是否可以互动
621
- * @param val boolean
622
- */
623
- StateDriveSlide.prototype.setInteractive = function (val) {
624
- this.interactive = val;
625
- this.player.setInteractive(val);
626
- };
627
- /**
628
- * 暂停播放
629
- */
630
- StateDriveSlide.prototype.pause = function () {
631
- this.player.pause();
632
- };
633
- /**
634
- * 恢复播放状态
635
- */
636
- StateDriveSlide.prototype.resume = function () {
637
- this.player.resume();
638
- };
639
- /**
640
- * 销毁方法.
641
- */
642
- StateDriveSlide.prototype.destroy = function () {
643
- this.frameResizeObserver.disconnect();
644
- this.player.removeAllListeners();
645
- this.player.destroy();
646
- this.player.removeAllListeners();
647
- window.removeEventListener("__slide_log__", this.handleLogDownload);
648
- window.removeEventListener("__slide_state__", this.handleSlideStateLog);
649
- window.clearInterval(this.persistLogId);
650
- if (logger) {
651
- logger.removeItem(this.logId).catch(function () {
652
- // ignore
653
- });
654
- }
655
- try {
656
- this.anchor.removeChild(this.player.view);
657
- }
658
- catch (e) {
659
- // ignore remove error
660
- }
661
- };
662
- return StateDriveSlide;
663
- }(EventEmitter));
664
- export { StateDriveSlide };
@@ -1,13 +0,0 @@
1
- import { SyncEvent } from "./Slide";
2
- import EventEmitter from "eventemitter3";
3
- export declare class SyncEventQueue extends EventEmitter {
4
- private queue;
5
- private slideIndex;
6
- private isLoading;
7
- constructor();
8
- private findLastRenderSlideIndex;
9
- private schedule;
10
- setSlideIndex(index: number): void;
11
- setIsLoading(val: boolean): void;
12
- addEvent(evt: SyncEvent): void;
13
- }