@netless/slide 0.1.13 → 0.1.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/slide",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "> TODO: description",
5
5
  "author": "huaguzheng <huaguzheng2007@126.com>",
6
6
  "homepage": "https://github.com/huaguzheng/netless-ppt-plugin/tree/main/packages/slide#readme",
@@ -20,13 +20,16 @@
20
20
  },
21
21
  "scripts": {
22
22
  "dev": "tsc",
23
- "build": "webpack --config webpack.config.js"
23
+ "build": "webpack --config webpack.config.js",
24
+ "watch": "webpack --config webpack.config.js --watch"
24
25
  },
25
26
  "bugs": {
26
27
  "url": "https://github.com/huaguzheng/netless-ppt-plugin/issues"
27
28
  },
28
29
  "dependencies": {
29
30
  "@juggle/resize-observer": "^3.3.1",
31
+ "@netless/ppt-player": "^0.1.14",
32
+ "@netless/ppt-transaction": "^0.1.14",
30
33
  "@types/dat.gui": "^0.7.7",
31
34
  "dat.gui": "^0.7.7",
32
35
  "eventemitter3": "^4.0.7",
@@ -38,5 +41,5 @@
38
41
  "publishConfig": {
39
42
  "access": "public"
40
43
  },
41
- "gitHead": "aae378ad12376283da7d3a8c81380ae2f4b40ea1"
44
+ "gitHead": "daba36b8dad1318419b4a51cb27a30802b57ccd4"
42
45
  }
@@ -1,100 +0,0 @@
1
- import { GUI } from "dat.gui";
2
- import md5 from "blueimp-md5";
3
- var PlayerController = /** @class */ (function () {
4
- function PlayerController(props) {
5
- this.runTime = {
6
- fps: 0,
7
- resolution: "",
8
- };
9
- this.target = props.target;
10
- this.data = props.params;
11
- this.player = props.player;
12
- this.gui = this.createControllerGUI();
13
- this.createStats();
14
- this.addEventListener();
15
- }
16
- PlayerController.prototype.createStats = function () {
17
- var _this = this;
18
- setInterval(function () {
19
- _this.controller.runTimeFps.setValue(_this.player.runtime.fps);
20
- _this.controller.runTimeResolution.setValue(_this.player.view.width + "*" + _this.player.view.height);
21
- }, 500);
22
- };
23
- PlayerController.prototype.createControllerGUI = function () {
24
- var _a, _b, _c, _d, _e, _f;
25
- var gui = new GUI({
26
- autoPlace: true,
27
- closed: true,
28
- });
29
- gui.domElement.style.opacity = ".6";
30
- gui.domElement.style.transformOrigin = "100% 0";
31
- gui.domElement.style.transform = "scale(1.4)";
32
- this.target.appendChild(gui.domElement);
33
- gui.domElement.style.position = "absolute";
34
- gui.domElement.style.right = "0";
35
- gui.domElement.style.top = "0";
36
- gui.domElement.style.zIndex = "2";
37
- this.controller = {
38
- runTimeFps: gui.add({ "FPS": 0 }, "FPS", 0),
39
- runTimeResolution: gui.add({ "分辨率": "" }, "分辨率", ""),
40
- autoFps: gui.add({ "自动fps": (_a = this.data.autoFPS) !== null && _a !== void 0 ? _a : true }, "自动fps", true),
41
- autoResolution: gui.add({ "自动分辨率": (_b = this.data.autoResolution) !== null && _b !== void 0 ? _b : false }, "自动分辨率", true),
42
- moreCalculation: gui.add({ "额外计算": 0 }, "额外计算", 0, 100),
43
- minFPS: gui.add({ "最低fps": (_c = this.data.minFPS) !== null && _c !== void 0 ? _c : 40 }, "最低fps", 0, 60),
44
- maxFPS: gui.add({ "最高fps": (_d = this.data.maxFPS) !== null && _d !== void 0 ? _d : 50 }, "最高fps", 0, 60),
45
- resolution: gui.add({ "目标分辨倍率": (_e = this.data.resolution) !== null && _e !== void 0 ? _e : window.devicePixelRatio }, "目标分辨倍率", 0.5, 4),
46
- minResolution: gui.add({ "最小分辨倍率": (_f = this.data.minResolution) !== null && _f !== void 0 ? _f : 1 }, "最小分辨倍率", 0.5, 4),
47
- };
48
- this.controller.runTimeFps.disabled = true;
49
- this.controller.runTimeResolution.disabled = true;
50
- return gui;
51
- };
52
- PlayerController.prototype.addEventListener = function () {
53
- var _this = this;
54
- this.controller.autoFps.onChange(function (value) {
55
- _this.data.autoFPS = value;
56
- _this.player.updateConfig(_this.data);
57
- });
58
- this.controller.maxFPS.onChange(function (value) {
59
- _this.data.maxFPS = value;
60
- _this.player.updateConfig(_this.data);
61
- });
62
- this.controller.minFPS.onChange(function (value) {
63
- _this.data.minFPS = value;
64
- _this.player.updateConfig(_this.data);
65
- });
66
- this.controller.autoResolution.onChange(function (value) {
67
- _this.data.autoResolution = value;
68
- _this.player.updateConfig(_this.data);
69
- });
70
- this.controller.minResolution.onChange(function (value) {
71
- _this.data.minResolution = value;
72
- _this.player.updateConfig(_this.data);
73
- });
74
- this.controller.resolution.onChange(function (value) {
75
- _this.data.resolution = value;
76
- _this.player.updateConfig(_this.data);
77
- });
78
- var md5Value;
79
- this.controller.moreCalculation.onChange(function (value) {
80
- var calc = function () {
81
- var str = "";
82
- while (str.length < value) {
83
- str += Math.random().toString(32).substr(2);
84
- }
85
- md5(str);
86
- };
87
- if (md5Value) {
88
- // @ts-ignore
89
- _this.player.app.ticker.remove(md5Value);
90
- }
91
- if (value > 0) {
92
- md5Value = calc;
93
- // @ts-ignore
94
- _this.player.app.ticker.add(md5Value);
95
- }
96
- });
97
- };
98
- return PlayerController;
99
- }());
100
- export { PlayerController };
@@ -1,136 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import EventEmitter from "eventemitter3";
38
- var Task = /** @class */ (function () {
39
- function Task(index, slideIndex, fn, eventHub, id) {
40
- this.state = "idle";
41
- this.index = -1;
42
- this.slideIndex = -1;
43
- this.fn = fn;
44
- this.index = index;
45
- this.slideIndex = slideIndex;
46
- this.eventHub = eventHub;
47
- this.id = id;
48
- }
49
- Task.prototype.apply = function () {
50
- return __awaiter(this, void 0, void 0, function () {
51
- var e_1;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- this.eventHub.emit("task-start", this);
56
- _a.label = 1;
57
- case 1:
58
- _a.trys.push([1, 3, , 4]);
59
- this.state = "start";
60
- return [4 /*yield*/, this.fn()];
61
- case 2:
62
- _a.sent();
63
- this.state = "end";
64
- this.eventHub.emit("task-end", this);
65
- return [3 /*break*/, 4];
66
- case 3:
67
- e_1 = _a.sent();
68
- this.eventHub.emit("task-error", {
69
- task: this,
70
- error: e_1,
71
- });
72
- return [3 /*break*/, 4];
73
- case 4: return [2 /*return*/];
74
- }
75
- });
76
- });
77
- };
78
- return Task;
79
- }());
80
- export { Task };
81
- var RenderingTaskManager = /** @class */ (function () {
82
- function RenderingTaskManager() {
83
- var _this = this;
84
- this.eventHub = new EventEmitter();
85
- this.tasks = [];
86
- this.index = 0;
87
- this.eventHub.on("task-end", function (task) {
88
- var _a;
89
- var selfIndex = _this.tasks.findIndex(function (t) { return t.index === task.index; });
90
- var nextIndex = selfIndex + 1;
91
- if (nextIndex >= 0) {
92
- (_a = _this.tasks[nextIndex]) === null || _a === void 0 ? void 0 : _a.apply();
93
- }
94
- if (selfIndex >= 0) {
95
- _this.tasks.splice(selfIndex, 1);
96
- _this.replaceIdleTask();
97
- }
98
- _this.eventHub.emit("task-end-" + task.id);
99
- });
100
- this.eventHub.on("task-error", function (_a) {
101
- var task = _a.task;
102
- var selfIndex = _this.tasks.findIndex(function (t) { return t.index === task.index; });
103
- if (selfIndex >= 0) {
104
- _this.tasks.splice(selfIndex, 1);
105
- _this.replaceIdleTask();
106
- }
107
- });
108
- }
109
- RenderingTaskManager.prototype.replaceIdleTask = function () {
110
- var _this = this;
111
- var _a;
112
- var ids = new Set();
113
- for (var i = 0, len = this.tasks.length; i < len; i++) {
114
- if (this.tasks[i].state === "idle" && ((_a = this.tasks[i + 1]) === null || _a === void 0 ? void 0 : _a.state) === "idle") {
115
- ids.add(i);
116
- }
117
- }
118
- Array.from(ids).forEach(function (id) {
119
- _this.tasks.splice(id, 1);
120
- });
121
- };
122
- RenderingTaskManager.prototype.addTask = function (fn, slideIndex, id) {
123
- var task = new Task(this.index++, slideIndex, fn, this.eventHub, id);
124
- this.tasks.push(task);
125
- this.tasks.sort(function (a, b) { return a.index - b.index; });
126
- this.replaceIdleTask();
127
- if (this.tasks.length === 1) {
128
- task.apply();
129
- }
130
- };
131
- RenderingTaskManager.prototype.hasStartTask = function () {
132
- return this.tasks.some(function (t) { return t.state === "start"; });
133
- };
134
- return RenderingTaskManager;
135
- }());
136
- export { RenderingTaskManager };
package/lib/waitUntil.js DELETED
@@ -1,56 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- export var delay = function (value) { return new Promise(function (resolve) { return setTimeout(resolve, value); }); };
38
- export function waitUntil(fn, timeout) {
39
- return __awaiter(this, void 0, void 0, function () {
40
- var start;
41
- return __generator(this, function (_a) {
42
- switch (_a.label) {
43
- case 0:
44
- start = Date.now();
45
- _a.label = 1;
46
- case 1:
47
- if (!(!fn() && Date.now() - start < timeout)) return [3 /*break*/, 3];
48
- return [4 /*yield*/, delay(50)];
49
- case 2:
50
- _a.sent();
51
- return [3 /*break*/, 1];
52
- case 3: return [2 /*return*/];
53
- }
54
- });
55
- });
56
- }