@netless/slide 1.4.59-alpha.4 → 1.4.59

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.
@@ -0,0 +1,175 @@
1
+ import { GUI } from "dat.gui";
2
+ var PlayerConfig = /** @class */ (function () {
3
+ function PlayerConfig(player) {
4
+ this.player = player;
5
+ }
6
+ ;
7
+ Object.defineProperty(PlayerConfig.prototype, "frameRate", {
8
+ get: function () {
9
+ return this.player.fps.value;
10
+ },
11
+ set: function (_) { },
12
+ enumerable: false,
13
+ configurable: true
14
+ });
15
+ Object.defineProperty(PlayerConfig.prototype, "drawFrames", {
16
+ get: function () {
17
+ return this.player.runtime.fps;
18
+ },
19
+ set: function (_) { },
20
+ enumerable: false,
21
+ configurable: true
22
+ });
23
+ Object.defineProperty(PlayerConfig.prototype, "drawCall", {
24
+ get: function () {
25
+ return this.player.runtime.drawCall;
26
+ },
27
+ set: function (_) { },
28
+ enumerable: false,
29
+ configurable: true
30
+ });
31
+ Object.defineProperty(PlayerConfig.prototype, "resolution", {
32
+ get: function () {
33
+ return this.player.config.resolution;
34
+ },
35
+ set: function (value) {
36
+ this.player.updateConfig({ resolution: value });
37
+ },
38
+ enumerable: false,
39
+ configurable: true
40
+ });
41
+ Object.defineProperty(PlayerConfig.prototype, "size", {
42
+ get: function () {
43
+ var _a, _b;
44
+ return ((_a = this.player.view) === null || _a === void 0 ? void 0 : _a.width) + "*" + ((_b = this.player.view) === null || _b === void 0 ? void 0 : _b.height);
45
+ },
46
+ set: function (_) { },
47
+ enumerable: false,
48
+ configurable: true
49
+ });
50
+ Object.defineProperty(PlayerConfig.prototype, "minFPS", {
51
+ get: function () {
52
+ return this.player.config.minFPS;
53
+ },
54
+ set: function (value) {
55
+ this.player.updateConfig({ minFPS: value, maxFPS: this.player.config.maxFPS });
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
60
+ Object.defineProperty(PlayerConfig.prototype, "maxFPS", {
61
+ get: function () {
62
+ return this.player.config.maxFPS;
63
+ },
64
+ set: function (value) {
65
+ this.player.updateConfig({ maxFPS: value, minFPS: this.player.config.minFPS });
66
+ },
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ Object.defineProperty(PlayerConfig.prototype, "autoResolution", {
71
+ get: function () {
72
+ return this.player.config.autoResolution;
73
+ },
74
+ set: function (value) {
75
+ this.player.updateConfig({ autoResolution: value });
76
+ },
77
+ enumerable: false,
78
+ configurable: true
79
+ });
80
+ Object.defineProperty(PlayerConfig.prototype, "autoFPS", {
81
+ get: function () {
82
+ return this.player.config.autoFPS;
83
+ },
84
+ set: function (value) {
85
+ this.player.updateConfig({ autoFPS: value });
86
+ },
87
+ enumerable: false,
88
+ configurable: true
89
+ });
90
+ Object.defineProperty(PlayerConfig.prototype, "backgroundColor", {
91
+ get: function () {
92
+ return this.player.config.transactionBgColor;
93
+ },
94
+ set: function (value) {
95
+ this.player.updateConfig({ transactionBgColor: value });
96
+ },
97
+ enumerable: false,
98
+ configurable: true
99
+ });
100
+ Object.defineProperty(PlayerConfig.prototype, "maxResolutionLevel", {
101
+ get: function () {
102
+ return this.player.config.maxResolutionLevel;
103
+ },
104
+ set: function (value) {
105
+ this.player.updateConfig({ maxResolutionLevel: value });
106
+ },
107
+ enumerable: false,
108
+ configurable: true
109
+ });
110
+ return PlayerConfig;
111
+ }());
112
+ export { PlayerConfig };
113
+ var PlayerController = /** @class */ (function () {
114
+ function PlayerController(player, anchor) {
115
+ var _a;
116
+ this.config = new PlayerConfig(player);
117
+ this.anchor = anchor;
118
+ _a = this.createControllerGUI(), this.gui = _a[0], this.controller = _a[1];
119
+ this.createStats();
120
+ }
121
+ PlayerController.prototype.createStats = function () {
122
+ var _this = this;
123
+ this.stateId = setInterval(function () {
124
+ _this.controller.frameRate.updateDisplay();
125
+ _this.controller.size.updateDisplay();
126
+ _this.controller.minFPS.updateDisplay();
127
+ _this.controller.drawFrames.updateDisplay();
128
+ _this.controller.maxFPS.updateDisplay();
129
+ _this.controller.resolution.updateDisplay();
130
+ _this.controller.autoFps.updateDisplay();
131
+ _this.controller.autoResolution.updateDisplay();
132
+ _this.controller.drawCall.updateDisplay();
133
+ }, 16);
134
+ };
135
+ PlayerController.prototype.createControllerGUI = function () {
136
+ var gui = new GUI({
137
+ autoPlace: true,
138
+ closed: true,
139
+ });
140
+ gui.domElement.style.opacity = ".6";
141
+ gui.domElement.style.transformOrigin = "100% 0";
142
+ gui.domElement.style.transform = "scale(1)";
143
+ this.anchor.appendChild(gui.domElement);
144
+ gui.domElement.style.position = "absolute";
145
+ gui.domElement.style.right = "0";
146
+ gui.domElement.style.top = "0";
147
+ gui.domElement.style.zIndex = "2";
148
+ var controller = {
149
+ frameRate: gui.add(this.config, "frameRate"),
150
+ drawFrames: gui.add(this.config, "drawFrames"),
151
+ drawCall: gui.add(this.config, "drawCall"),
152
+ size: gui.add(this.config, "size"),
153
+ minFPS: gui.add(this.config, "minFPS", 0, 60),
154
+ maxFPS: gui.add(this.config, "maxFPS", 0, 60),
155
+ resolution: gui.add(this.config, "resolution", 0.5, 8, 0.5),
156
+ autoResolution: gui.add(this.config, "autoResolution"),
157
+ autoFps: gui.add(this.config, "autoFPS"),
158
+ maxResolutionLevel: gui.add(this.config, "maxResolutionLevel", 0, 4, 1),
159
+ transactionBgColor: gui.addColor(this.config, "backgroundColor"),
160
+ };
161
+ return [gui, controller];
162
+ };
163
+ PlayerController.prototype.destroy = function () {
164
+ try {
165
+ window.clearInterval(this.stateId);
166
+ this.anchor.removeChild(this.gui.domElement);
167
+ this.gui.destroy();
168
+ }
169
+ catch (_a) {
170
+ //
171
+ }
172
+ };
173
+ return PlayerController;
174
+ }());
175
+ export { PlayerController };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Reveal a completed live render and remove its fallback image.
3
+ * Frozen and release states own visibility while their player transition is active.
4
+ */
5
+ export function updateRenderSlideVisibility(isReleasing, player, frame, cacheImage) {
6
+ if (isReleasing || !(player === null || player === void 0 ? void 0 : player.view)) {
7
+ return;
8
+ }
9
+ if (player.view.style.visibility === "hidden") {
10
+ player.view.style.visibility = "visible";
11
+ }
12
+ if (frame.style.visibility === "hidden") {
13
+ frame.style.visibility = "visible";
14
+ }
15
+ cacheImage.style.display = "none";
16
+ }
@@ -0,0 +1,230 @@
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 EventEmitter from "eventemitter3";
53
+ var RenderTaskCancelledError = /** @class */ (function (_super) {
54
+ __extends(RenderTaskCancelledError, _super);
55
+ function RenderTaskCancelledError(message) {
56
+ if (message === void 0) { message = "render task cancelled"; }
57
+ var _this = _super.call(this, message) || this;
58
+ _this.code = "RENDER_TASK_CANCELLED";
59
+ _this.name = "AbortError";
60
+ return _this;
61
+ }
62
+ return RenderTaskCancelledError;
63
+ }(Error));
64
+ export { RenderTaskCancelledError };
65
+ var Task = /** @class */ (function () {
66
+ function Task(index, slideIndex, fn, eventHub, id) {
67
+ this.state = "idle";
68
+ this.index = -1;
69
+ this.slideIndex = -1;
70
+ this.cancelled = false;
71
+ this.fn = fn;
72
+ this.index = index;
73
+ this.slideIndex = slideIndex;
74
+ this.eventHub = eventHub;
75
+ this.id = id;
76
+ }
77
+ Task.prototype.apply = function () {
78
+ return __awaiter(this, void 0, void 0, function () {
79
+ var e_1;
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
82
+ case 0:
83
+ if (this.cancelled) {
84
+ return [2 /*return*/];
85
+ }
86
+ this.eventHub.emit("task-start", this);
87
+ _a.label = 1;
88
+ case 1:
89
+ _a.trys.push([1, 3, , 4]);
90
+ this.state = "start";
91
+ return [4 /*yield*/, this.fn()];
92
+ case 2:
93
+ _a.sent();
94
+ if (this.cancelled) {
95
+ return [2 /*return*/];
96
+ }
97
+ this.state = "end";
98
+ this.eventHub.emit("task-end", this);
99
+ return [3 /*break*/, 4];
100
+ case 3:
101
+ e_1 = _a.sent();
102
+ if (this.cancelled) {
103
+ return [2 /*return*/];
104
+ }
105
+ if (e_1 instanceof RenderTaskCancelledError) {
106
+ this.cancel();
107
+ this.eventHub.emit("task-cancel", {
108
+ task: this,
109
+ error: e_1,
110
+ });
111
+ return [2 /*return*/];
112
+ }
113
+ this.eventHub.emit("task-error", {
114
+ task: this,
115
+ error: e_1,
116
+ });
117
+ return [3 /*break*/, 4];
118
+ case 4: return [2 /*return*/];
119
+ }
120
+ });
121
+ });
122
+ };
123
+ Task.prototype.cancel = function () {
124
+ this.cancelled = true;
125
+ };
126
+ return Task;
127
+ }());
128
+ export { Task };
129
+ var RenderingTaskManager = /** @class */ (function () {
130
+ function RenderingTaskManager() {
131
+ var _this = this;
132
+ this.eventHub = new EventEmitter();
133
+ this.tasks = [];
134
+ this.index = 0;
135
+ this.destroyed = false;
136
+ this.eventHub.on("task-end", function (task) {
137
+ var _a;
138
+ var selfIndex = _this.tasks.findIndex(function (t) { return t.index === task.index; });
139
+ var nextIndex = selfIndex + 1;
140
+ if (nextIndex >= 0) {
141
+ (_a = _this.tasks[nextIndex]) === null || _a === void 0 ? void 0 : _a.apply();
142
+ }
143
+ if (selfIndex >= 0) {
144
+ _this.tasks.splice(selfIndex, 1);
145
+ _this.replaceIdleTask();
146
+ }
147
+ _this.eventHub.emit("task-end-" + task.id);
148
+ });
149
+ this.eventHub.on("task-error", function (_a) {
150
+ var _b;
151
+ var task = _a.task, error = _a.error;
152
+ var selfIndex = _this.tasks.findIndex(function (t) { return t.index === task.index; });
153
+ var wasRunning = task.state === "start";
154
+ if (selfIndex >= 0) {
155
+ _this.tasks.splice(selfIndex, 1);
156
+ _this.replaceIdleTask();
157
+ if (wasRunning && !_this.destroyed) {
158
+ (_b = _this.tasks[selfIndex]) === null || _b === void 0 ? void 0 : _b.apply();
159
+ }
160
+ }
161
+ _this.eventHub.emit("task-error-" + task.id, error);
162
+ });
163
+ this.eventHub.on("task-cancel", function (_a) {
164
+ var _b;
165
+ var task = _a.task, error = _a.error;
166
+ var selfIndex = _this.tasks.findIndex(function (t) { return t.index === task.index; });
167
+ var wasRunning = task.state === "start";
168
+ if (selfIndex >= 0) {
169
+ _this.tasks.splice(selfIndex, 1);
170
+ if (wasRunning && !_this.destroyed) {
171
+ (_b = _this.tasks[selfIndex]) === null || _b === void 0 ? void 0 : _b.apply();
172
+ }
173
+ }
174
+ _this.eventHub.emit("task-cancel-" + task.id, error);
175
+ });
176
+ }
177
+ RenderingTaskManager.prototype.cancelTask = function (task) {
178
+ var error = new RenderTaskCancelledError();
179
+ task.cancel();
180
+ this.eventHub.emit("task-cancel", { task: task, error: error });
181
+ };
182
+ RenderingTaskManager.prototype.replaceIdleTask = function () {
183
+ var _this = this;
184
+ var _a;
185
+ var ids = new Set();
186
+ for (var i = 0, len = this.tasks.length; i < len; i++) {
187
+ if (this.tasks[i].state === "idle" && ((_a = this.tasks[i + 1]) === null || _a === void 0 ? void 0 : _a.state) === "idle") {
188
+ ids.add(i);
189
+ }
190
+ }
191
+ // Remove from the end so deleting one idle task does not shift the
192
+ // indexes selected for the remaining cancellations.
193
+ Array.from(ids).sort(function (a, b) { return b - a; }).forEach(function (id) {
194
+ var task = _this.tasks.splice(id, 1)[0];
195
+ if (task) {
196
+ _this.cancelTask(task);
197
+ }
198
+ });
199
+ };
200
+ RenderingTaskManager.prototype.addTask = function (fn, slideIndex, id) {
201
+ if (this.destroyed) {
202
+ return undefined;
203
+ }
204
+ var task = new Task(this.index++, slideIndex, fn, this.eventHub, id);
205
+ this.tasks.push(task);
206
+ this.tasks.sort(function (a, b) { return a.index - b.index; });
207
+ this.replaceIdleTask();
208
+ if (this.tasks.length === 1) {
209
+ task.apply();
210
+ }
211
+ return task;
212
+ };
213
+ RenderingTaskManager.prototype.hasStartTask = function () {
214
+ return this.tasks.some(function (t) { return t.state === "start"; });
215
+ };
216
+ RenderingTaskManager.prototype.destroy = function () {
217
+ var _this = this;
218
+ if (this.destroyed) {
219
+ return;
220
+ }
221
+ this.destroyed = true;
222
+ var tasks = this.tasks.splice(0);
223
+ tasks.forEach(function (task) {
224
+ _this.cancelTask(task);
225
+ });
226
+ this.eventHub.removeAllListeners();
227
+ };
228
+ return RenderingTaskManager;
229
+ }());
230
+ export { RenderingTaskManager };
package/lib/Slide.d.ts CHANGED
@@ -446,6 +446,7 @@ export declare class Slide extends Slide_base {
446
446
  static __stageCountLimit: number;
447
447
  static setStageCountLimit(limit: number): void;
448
448
  private iosResetCache;
449
+ private iosResetPending;
449
450
  private iosNewPlayer?;
450
451
  private version?;
451
452
  private __slideState;
@@ -467,10 +468,6 @@ export declare class Slide extends Slide_base {
467
468
  private anchor;
468
469
  private tracker;
469
470
  private player?;
470
- private pptMediaPermissionCallbacks;
471
- private pptMediaPermissionNotified;
472
- private pptMediaPermissionRenotifyPending;
473
- private pendingPptMediaState?;
474
471
  private playerGeneration;
475
472
  private playerGenerations;
476
473
  private playerSwapRenderTimeoutMs;
@@ -514,8 +511,7 @@ export declare class Slide extends Slide_base {
514
511
  private handleSyncQueueCompactRenderComplete;
515
512
  private handleSyncQueueCatchUpStateChange;
516
513
  private updatePlayerInteractive;
517
- private flipDebugState;
518
- private logSlideFlip;
514
+ private hideResetSnapshot;
519
515
  private observeRenderTask;
520
516
  private recoverHandler;
521
517
  private reportError;
@@ -526,14 +522,6 @@ export declare class Slide extends Slide_base {
526
522
  static handleLogDownload: () => Promise<void>;
527
523
  private urlInterrupter;
528
524
  private initPlayer;
529
- private getPptMediaState;
530
- private getPlayingMediaIds;
531
- private hasPptMediaPermissionRequest;
532
- private notifyPptMediaPermissionRequest;
533
- private handlePptMediaPermissionRequest;
534
- private handlePptMediaPermissionResolved;
535
- onPptMediaPermissionRequest(callback: () => void): () => void;
536
- playPptMedia(): void;
537
525
  private userInputHandle;
538
526
  private _handleViewClick;
539
527
  private handleViewTouchStart;