@netless/app-slide 0.0.50 → 0.0.51

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/main.es.js CHANGED
@@ -17,6 +17,99 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ function clamp$1(value, min, max) {
21
+ return Math.min(Math.max(value, min), max);
22
+ }
23
+ function isObj(obj) {
24
+ return typeof obj === "object" && obj !== null;
25
+ }
26
+ function deepClone(obj) {
27
+ return JSON.parse(JSON.stringify(obj));
28
+ }
29
+ class Logger {
30
+ constructor(enable) {
31
+ this.enable = enable;
32
+ this.apps = {};
33
+ this.level = "debug";
34
+ this._onMessage = (ev) => {
35
+ if (isObj(ev.data)) {
36
+ if (typeof ev.data.slide === "boolean") {
37
+ this.enable = ev.data.slide;
38
+ } else if (ev.data.slide === "__instance") {
39
+ console.log(this);
40
+ }
41
+ }
42
+ };
43
+ window.addEventListener("message", this._onMessage);
44
+ }
45
+ log(...args) {
46
+ if (this.enable) {
47
+ console.log(...args);
48
+ }
49
+ }
50
+ verbose(...args) {
51
+ if (this.enable && this.level === "verbose") {
52
+ console.log(...args);
53
+ }
54
+ }
55
+ dispose(appId) {
56
+ this.enable = false;
57
+ delete this.apps[appId];
58
+ window.removeEventListener("message", this._onMessage);
59
+ }
60
+ }
61
+ const logger = new Logger(false);
62
+ const log = logger.log.bind(logger);
63
+ const verbose = logger.verbose.bind(logger);
64
+ let useFreezer = false;
65
+ const FreezerLength = 2;
66
+ const apps = {
67
+ map: new Map(),
68
+ queue: [],
69
+ validateQueue() {
70
+ log("[Slide] freezer: validate", this.queue);
71
+ while (this.queue.length > FreezerLength) {
72
+ const appId = this.queue.pop();
73
+ const slide = this.map.get(appId);
74
+ if (slide) {
75
+ log("[Slide] freezer: validate-freeze", appId, this.queue);
76
+ slide.freeze();
77
+ }
78
+ }
79
+ },
80
+ set(appId, slide) {
81
+ log("[Slide] freezer: add", appId, this.queue);
82
+ this.map.set(appId, slide);
83
+ if (!this.queue.includes(appId)) {
84
+ this.queue.unshift(appId);
85
+ }
86
+ this.validateQueue();
87
+ },
88
+ delete(appId) {
89
+ log("[Slide] freezer: delete", appId, this.queue);
90
+ this.map.delete(appId);
91
+ this.queue = this.queue.filter((id) => id !== appId);
92
+ },
93
+ focus(appId) {
94
+ const slide = this.map.get(appId);
95
+ const index = this.queue.indexOf(appId);
96
+ if (index > -1) {
97
+ this.queue.splice(index, 1);
98
+ }
99
+ this.queue.unshift(appId);
100
+ this.validateQueue();
101
+ log("[Slide] freezer: focus", appId, this.queue);
102
+ if (slide) {
103
+ slide.unfreeze();
104
+ }
105
+ }
106
+ };
107
+ const addHooks = (emitter) => {
108
+ useFreezer = true;
109
+ emitter.on("focus", ({ appId }) => {
110
+ apps.focus(appId);
111
+ });
112
+ };
20
113
  const e = "!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", s = e.length, t = Array(20), r = () => {
21
114
  for (let r2 = 0; r2 < 20; r2++)
22
115
  t[r2] = e.charAt(Math.random() * s);
@@ -33864,6 +33957,25 @@ void main(void){
33864
33957
  }, isAndroid() {
33865
33958
  let t3 = false;
33866
33959
  return window.__nativeTags && window.__nativeTags.platform && /^android/i.test(window.__nativeTags.platform) && (t3 = true), zR.name && /android/i.test(zR.name) && (t3 = true), t3;
33960
+ }, isSupportTransaction() {
33961
+ var t3, e3;
33962
+ const n2 = (e3 = (t3 = window.__nativeTags) === null || t3 === void 0 ? void 0 : t3.platform) !== null && e3 !== void 0 ? e3 : "";
33963
+ if (n2) {
33964
+ const t4 = n2.split(" ");
33965
+ if (t4[1]) {
33966
+ if (/^iPad/.test(t4[1])) {
33967
+ const e4 = t4[1].match(/^iPad(\d+)/);
33968
+ return !!(e4 && e4[1] && parseInt(e4[1], 10) >= 6);
33969
+ }
33970
+ if (/^iPhone/.test(t4[1])) {
33971
+ const e4 = t4[1].match(/^iPhone(\d+)/);
33972
+ return !!(e4 && e4[1] && parseInt(e4[1], 10) >= 9);
33973
+ }
33974
+ return true;
33975
+ }
33976
+ return true;
33977
+ }
33978
+ return true;
33867
33979
  } };
33868
33980
  var VR = function(t3, e3, n2, i2) {
33869
33981
  return new (n2 || (n2 = Promise))(function(r3, o3) {
@@ -34032,7 +34144,7 @@ void main(void){
34032
34144
  }
34033
34145
  s3.push(() => VR(this, void 0, void 0, function* () {
34034
34146
  var e4, r4;
34035
- if (!(yield (e4 = this.snapshotCache) === null || e4 === void 0 ? void 0 : e4.getItem(t3.toString()))) {
34147
+ if (!(yield (e4 = this.snapshotCache) === null || e4 === void 0 ? void 0 : e4.getItem(t3.toString())) && KR.platform.isSupportTransaction()) {
34036
34148
  n2.createTiming(), n2.container.visible = true, n2.collectMainSeqStartValue(), n2.setMainSeqStep(0, "start");
34037
34149
  const e5 = Hy.create({ width: n2.json.width, height: n2.json.height, resolution: 1 });
34038
34150
  KR.textureCacheSize += e5.width * e5.height, i2.renderer.render(n2.container, { renderTexture: e5 });
@@ -34109,7 +34221,7 @@ void main(void){
34109
34221
  const JR = { randomBar: "RandomLines", circle: "Shape", ripple: "Ripples", wipe: "Erase", dissolve: "Dissolve", morph: "Smooth", fade: "FadeInOut", push: "Push", split: "Separation", reveal: "Display", pull: "Uncover", cover: "Cover", flash: "Flash", checker: "Checkerboard", blinds: "WindowShades", curtains: "Curtain", fallOver: "Fall", drape: "Suspension", wheel: "Clock", comb: "Combing", warp: "Scale", peelOff: "PeelOff", flip: "Flip" }, $R = { mainSeqStepChange: "mainSeqStepChange", mainSeqStateChange: "mainSeqStateChange", interactiveSeqStateChange: "interactiveSeqStateChange", interactiveSeqAction: "interactiveSeqAction", mainSeqStepStart: "mainSeqStepStart", mainSeqStepEnd: "mainSeqStepEnd", slideChange: "slideChange", renderStart: "renderStart", renderEnd: "renderEnd", hyperlinkTrigger: "hyperlinkTrigger", animateStart: "animateStart", animateEnd: "animateEnd", mediaSeek: "mediaSeek", mediaPlay: "mediaPlay", mediaPause: "mediaPause", requestNextSlide: "requestNextSlide", requestPrevSlide: "requestPrevSlide", requestGotoSlide: "requestGotoSlide" };
34110
34222
  class KR extends a.a {
34111
34223
  constructor(t3, e3 = {}) {
34112
- super(), this.loader = new $E(true), this.transactionPlayer = new og(), this.transactionSprite = new Ow(), this.isForward = true, this.drawCall = 0, this.scale = 1, this.prevSlideBase64 = null, this.fps = new qE(), this.designWidth = 0, this.designHeight = 0, this.currentIndex = 0, this.slideCount = 0, this.runtime = { drawCall: 0, fps: 0 }, this.mode = t3;
34224
+ super(), this.loader = new $E(true), this.transactionPlayer = null, this.transactionSprite = new Ow(), this.isForward = true, this.drawCall = 0, this.scale = 1, this.prevSlideBase64 = null, this.fps = new qE(), this.designWidth = 0, this.designHeight = 0, this.currentIndex = 0, this.slideCount = 0, this.runtime = { drawCall: 0, fps: 0 }, this.mode = t3;
34113
34225
  let n2 = Math.max(window.devicePixelRatio, 2);
34114
34226
  jR.isDesktop() || (n2 = 1), this.config = { minFPS: Object(l.isUndefined)(e3.minFPS) ? 30 : e3.minFPS, maxFPS: Object(l.isUndefined)(e3.maxFPS) ? 40 : e3.maxFPS, resolution: Object(l.isUndefined)(e3.resolution) ? n2 : e3.resolution, autoFPS: !Object(l.isUndefined)(e3.autoFPS) && e3.autoFPS, autoResolution: !Object(l.isUndefined)(e3.autoResolution) && e3.autoResolution, transactionBgColor: Object(l.isUndefined)(e3.transactionBgColor) ? 0 : e3.transactionBgColor }, this.app = new Lb({ antialias: true, autoDensity: false, backgroundColor: 16777215 }), this.updateConfig(this.config), this.app.view.style.zIndex = "1", this.app.stage.sortableChildren = true;
34115
34227
  const i2 = this.app.renderer, { drawElements: r3 } = i2.gl;
@@ -34137,7 +34249,7 @@ void main(void){
34137
34249
  }
34138
34250
  }), this.app.ticker.add(() => {
34139
34251
  this.runtime.drawCall = this.drawCall, this.runtime.fps = Math.floor(this.app.ticker.minFPS), this.drawCall = 0;
34140
- }, null, ey.LOW), this.clock = new sM(this.app.ticker), this.objPoolGroup = iM(), this.stagePool = new YR(this.loader, this.mode, this.app.renderer, this.app.ticker, this.app.view, this.clock, this.objPoolGroup);
34252
+ }, null, ey.LOW), this.clock = new sM(this.app.ticker), this.objPoolGroup = iM(), this.stagePool = new YR(this.loader, this.mode, this.app.renderer, this.app.ticker, this.app.view, this.clock, this.objPoolGroup), jR.isSupportTransaction() && (this.transactionPlayer = new og());
34141
34253
  }
34142
34254
  get view() {
34143
34255
  return this.app.renderer ? this.app.view : null;
@@ -34300,7 +34412,7 @@ void main(void){
34300
34412
  createSnapshotForNextSlide() {
34301
34413
  var t3;
34302
34414
  const e3 = this.nextSlideIndex, n2 = this.stagePool.getStageJson(e3);
34303
- n2 && n2.transition && n2.transition.type && this.currentStage && (this.prevSlideBase64 = this.getBase64(this.currentStage), this.currentStage.timing && !this.currentStage.timing.mainSeqHasNextStep() && ((t3 = this.snapshotCache) === null || t3 === void 0 || t3.setItem(this.currentStage.json.index + "-end", this.prevSlideBase64)));
34415
+ n2 && n2.transition && n2.transition.type && this.currentStage && this.transactionPlayer && (this.prevSlideBase64 = this.getBase64(this.currentStage), this.currentStage.timing && !this.currentStage.timing.mainSeqHasNextStep() && ((t3 = this.snapshotCache) === null || t3 === void 0 || t3.setItem(this.currentStage.json.index + "-end", this.prevSlideBase64)));
34304
34416
  }
34305
34417
  destroy() {
34306
34418
  var t3;
@@ -35843,7 +35955,7 @@ void main(void){
35843
35955
  }
35844
35956
  var aC = { syncDispatch: "syncDispatch", syncReceive: "syncReceive", renderStart: "renderStart", renderEnd: "renderEnd", renderError: "renderError", slideChange: "slideChange", mainSeqStepStart: "mainSeqStepStart", mainSeqStepEnd: "mainSeqStepEnd", animateStart: "animateStart", animateEnd: "animateEnd", stateChange: "stateChange" }, lC = { taskId: "", url: "", currentSlideIndex: -1, mainSeqStep: -1, mainSeqState: null, mediaState: Object.create(null), interactiveSeqState: Object.create(null) }, uC = "";
35845
35957
  try {
35846
- uC = "0.1.53";
35958
+ uC = "0.1.54";
35847
35959
  } catch (t3) {
35848
35960
  uC = "dev";
35849
35961
  }
@@ -36108,7 +36220,8 @@ void main(void){
36108
36220
  (n2 !== this.player.currentIndex || this.renderingTaskManager.hasStartTask()) && (n2 > this.slideCount && this.slideCount > 0 || this.poseRenderSlide(n2, e4));
36109
36221
  }
36110
36222
  }, e3.prototype.needCreateNewPlayer = function() {
36111
- return (KR.platform.isIOS() || KR.platform.isAndroid()) && (this.iosResetCache.length > 20 || 4 * KR.textureCacheSize / 1048576 > 800);
36223
+ var t4 = KR.platform.isSupportTransaction(), e4 = t4 ? 15 : 7, n2 = t4 ? 600 : 300;
36224
+ return (KR.platform.isIOS() || KR.platform.isAndroid()) && (this.iosResetCache.length > e4 || 4 * KR.textureCacheSize / 1048576 > n2);
36112
36225
  }, e3.prototype.poseRenderSlide = function(t4, e4) {
36113
36226
  this.isLoading = true, this.mode === "interactive" ? this.emitSyncDispatch({ slideIndex: this.__slideState.currentSlideIndex, type: "renderSlide", index: t4, isForward: e4 }) : this.mode === "sync" ? (this.doRenderSlide(t4, e4), this.emitSyncDispatch({ slideIndex: this.__slideState.currentSlideIndex, type: "renderSlide", index: t4, isForward: e4 })) : this.doRenderSlide(t4, e4);
36114
36227
  }, e3.prototype.doRenderSlide = function(t4, e4) {
@@ -36225,15 +36338,6 @@ void main(void){
36225
36338
  }, e3;
36226
36339
  }(a.a);
36227
36340
  }]);
36228
- function clamp$1(value, min, max) {
36229
- return Math.min(Math.max(value, min), max);
36230
- }
36231
- function isObj(obj) {
36232
- return typeof obj === "object" && obj !== null;
36233
- }
36234
- function deepClone(obj) {
36235
- return JSON.parse(JSON.stringify(obj));
36236
- }
36237
36341
  var colorString = { exports: {} };
36238
36342
  var colorName = {
36239
36343
  "aliceblue": [240, 248, 255],
@@ -36591,41 +36695,6 @@ function hexDouble(num) {
36591
36695
  return str.length < 2 ? "0" + str : str;
36592
36696
  }
36593
36697
  var ColorString = colorString.exports;
36594
- class Logger {
36595
- constructor(enable) {
36596
- this.enable = enable;
36597
- this.apps = {};
36598
- this.level = "debug";
36599
- this._onMessage = (ev) => {
36600
- if (isObj(ev.data)) {
36601
- if (typeof ev.data.slide === "boolean") {
36602
- this.enable = ev.data.slide;
36603
- } else if (ev.data.slide === "__instance") {
36604
- console.log(this);
36605
- }
36606
- }
36607
- };
36608
- window.addEventListener("message", this._onMessage);
36609
- }
36610
- log(...args) {
36611
- if (this.enable) {
36612
- console.log(...args);
36613
- }
36614
- }
36615
- verbose(...args) {
36616
- if (this.enable && this.level === "verbose") {
36617
- console.log(...args);
36618
- }
36619
- }
36620
- dispose(appId) {
36621
- this.enable = false;
36622
- delete this.apps[appId];
36623
- window.removeEventListener("message", this._onMessage);
36624
- }
36625
- }
36626
- const logger = new Logger(false);
36627
- const log = logger.log.bind(logger);
36628
- const verbose = logger.verbose.bind(logger);
36629
36698
  function guessBgColor(el) {
36630
36699
  try {
36631
36700
  const bg = window.getComputedStyle(el).backgroundColor;
@@ -38030,53 +38099,6 @@ class SlideDocsViewer {
38030
38099
  return `${this.namespace}-${className}`;
38031
38100
  }
38032
38101
  }
38033
- const FreezerLength = 2;
38034
- const apps = {
38035
- map: new Map(),
38036
- queue: [],
38037
- validateQueue() {
38038
- log("[Slide] freezer: validate", this.queue);
38039
- while (this.queue.length > FreezerLength) {
38040
- const appId = this.queue.pop();
38041
- const slide = this.map.get(appId);
38042
- if (slide) {
38043
- log("[Slide] freezer: validate-freeze", appId, this.queue);
38044
- slide.freeze();
38045
- }
38046
- }
38047
- },
38048
- set(appId, slide) {
38049
- log("[Slide] freezer: add", appId, this.queue);
38050
- this.map.set(appId, slide);
38051
- if (!this.queue.includes(appId)) {
38052
- this.queue.unshift(appId);
38053
- }
38054
- this.validateQueue();
38055
- },
38056
- delete(appId) {
38057
- log("[Slide] freezer: delete", appId, this.queue);
38058
- this.map.delete(appId);
38059
- this.queue = this.queue.filter((id) => id !== appId);
38060
- },
38061
- focus(appId) {
38062
- const slide = this.map.get(appId);
38063
- const index = this.queue.indexOf(appId);
38064
- if (index > -1) {
38065
- this.queue.splice(index, 1);
38066
- }
38067
- this.queue.unshift(appId);
38068
- this.validateQueue();
38069
- log("[Slide] freezer: focus", appId, this.queue);
38070
- if (slide) {
38071
- slide.unfreeze();
38072
- }
38073
- }
38074
- };
38075
- const addHooks = (emitter) => {
38076
- emitter.on("focus", ({ appId }) => {
38077
- apps.focus(appId);
38078
- });
38079
- };
38080
38102
  var styles = ".netless-app-slide-content{position:relative;height:100%;overflow:hidden}.netless-app-slide-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-slide-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-slide-preview-active .netless-app-slide-preview-mask{display:block}.netless-app-slide-preview-active .netless-app-slide-preview{transform:translate(0)}.netless-app-slide-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-slide-preview-page:hover,.netless-app-slide-preview-page.netless-app-slide-preview-page-active{border-color:#444e601a}.netless-app-slide-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-slide-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-slide-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-slide-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-slide-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-slide-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-slide-footer-btn:hover{background:transparent!important}}.netless-app-slide-footer-btn>svg{width:100%;height:100%}.netless-app-slide-footer-btn>svg:nth-of-type(2){display:none}.netless-app-slide-footer-btn.netless-app-slide-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-slide-footer-btn.netless-app-slide-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-slide-footer-btn~.netless-app-slide-footer-btn{margin-left:15px}.netless-app-slide-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-slide-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-slide-page-number-input{border:none;outline:none;width:1.5em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-slide-page-number-input:hover,.netless-app-slide-page-number-input:focus,.netless-app-slide-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-slide-readonly.netless-app-slide-footer{display:none}.telebox-color-scheme-dark .netless-app-slide-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-slide-page-number-input:active,.telebox-color-scheme-dark .netless-app-slide-page-number-input:focus,.telebox-color-scheme-dark .netless-app-slide-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-slide-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-slide-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-slide-preview{background:rgba(50,50,50,.9)}.netless-app-slide-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-slide-slide{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.netless-app-slide-slide canvas{transform:scale(var(--netless-app-slide-scale, 1))}\n";
38081
38103
  function previewSlide({
38082
38104
  container,
@@ -38229,7 +38251,7 @@ class SlidePreviewer {
38229
38251
  return `${this.namespace}-${className}`;
38230
38252
  }
38231
38253
  }
38232
- const version = "0.0.50";
38254
+ const version = "0.0.51";
38233
38255
  const SlideApp = {
38234
38256
  kind: "Slide",
38235
38257
  setup(context) {
@@ -38273,7 +38295,8 @@ const SlideApp = {
38273
38295
  }, options), {
38274
38296
  onPageChanged
38275
38297
  }));
38276
- apps.set(context.appId, slideController);
38298
+ if (useFreezer)
38299
+ apps.set(context.appId, slideController);
38277
38300
  ((_a = logger.apps)[_b = context.appId] || (_a[_b] = {})).controller = slideController;
38278
38301
  slideController.readyPromise.then(options.onReady);
38279
38302
  return slideController;
@@ -38307,7 +38330,8 @@ const SlideApp = {
38307
38330
  }
38308
38331
  context.emitter.on("destroy", () => {
38309
38332
  log("[Slide]: destroy");
38310
- apps.delete(context.appId);
38333
+ if (useFreezer)
38334
+ apps.delete(context.appId);
38311
38335
  sideEffect.flushAll();
38312
38336
  if (docsViewer) {
38313
38337
  docsViewer.destroy();