@netless/app-slide 0.0.30 → 0.0.35
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/README.md +14 -1
- package/dist/DocsViewer/index.d.ts +1 -5
- package/dist/SlidePreviewer/index.d.ts +42 -0
- package/dist/index.d.ts +2 -0
- package/dist/main.cjs.js +120 -120
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +142 -14
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +114 -114
- package/dist/main.iife.js.map +1 -1
- package/package.json +4 -4
- package/src/DocsViewer/index.ts +1 -10
- package/src/SlideDocsViewer/index.ts +2 -2
- package/src/SlidePreviewer/index.ts +184 -0
- package/src/index.ts +3 -0
package/dist/main.es.js
CHANGED
|
@@ -31078,7 +31078,7 @@ void main() {
|
|
|
31078
31078
|
var t3, e3, n2;
|
|
31079
31079
|
return sl(this, void 0, void 0, function* () {
|
|
31080
31080
|
const i2 = this.ctx.fillTexture.getTexture(this.picTextureId);
|
|
31081
|
-
i2.texture && (this.picSprite.texture = i2.texture), this.picMask.texture = this.backgroundMask.texture, this.picSprite.mask = this.picMask, this.picSprite.width = this.designWidth, this.picSprite.height = this.designHeight, this.container.addChild(this.picSprite), this.container.addChild(this.picMask), ((t3 = this.media) === null || t3 === void 0 ? void 0 : t3.type) === "video" ? (this.mediaPlayer = new il({ id: this.json.id + "-video", ctx: this.ctx, video: this.media, height: this.designHeight, width: this.designWidth, sprite: this.picSprite, container: this.container, canvasElement: this.ctx.view }), ((e3 = this.mediaPlayer) === null || e3 === void 0 ? void 0 : e3.sprite) && (this.mediaPlayer.sprite.mask = this.picMask)) : ((n2 = this.media) === null || n2 === void 0 ? void 0 : n2.type) === "audio" && (this.mediaPlayer = new ol({ id: this.json.id + "-audio", ctx: this.ctx, audio: this.media, height: this.designHeight, width: this.designWidth, sprite: this.picSprite, container: this.container, canvasElement: this.ctx.view })), this.mediaPlayer && (this.picSprite.interactive = true, this.picSprite.on("mouseover", () => {
|
|
31081
|
+
i2.texture && (this.picSprite.texture = i2.texture), this.picMask.texture = this.backgroundMask.texture, this.picSprite.mask = this.picMask, this.picSprite.width = this.designWidth, this.picSprite.height = this.designHeight, this.container.addChild(this.picSprite), this.container.addChild(this.picMask), ((t3 = this.media) === null || t3 === void 0 ? void 0 : t3.type) === "video" && this.media.src ? (this.mediaPlayer = new il({ id: this.json.id + "-video", ctx: this.ctx, video: this.media, height: this.designHeight, width: this.designWidth, sprite: this.picSprite, container: this.container, canvasElement: this.ctx.view }), ((e3 = this.mediaPlayer) === null || e3 === void 0 ? void 0 : e3.sprite) && (this.mediaPlayer.sprite.mask = this.picMask)) : ((n2 = this.media) === null || n2 === void 0 ? void 0 : n2.type) === "audio" && this.media.src && (this.mediaPlayer = new ol({ id: this.json.id + "-audio", ctx: this.ctx, audio: this.media, height: this.designHeight, width: this.designWidth, sprite: this.picSprite, container: this.container, canvasElement: this.ctx.view })), this.mediaPlayer && (this.picSprite.interactive = true, this.picSprite.on("mouseover", () => {
|
|
31082
31082
|
this.mediaPlayer.showController();
|
|
31083
31083
|
}), this.picSprite.on("mouseout", () => {
|
|
31084
31084
|
this.mediaPlayer.hideController();
|
|
@@ -35471,9 +35471,9 @@ cs.get.rgb = function(string) {
|
|
|
35471
35471
|
}
|
|
35472
35472
|
var abbr = /^#([a-f0-9]{3,4})$/i;
|
|
35473
35473
|
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
|
35474
|
-
var rgba = /^rgba?\(\s*([+-]?\d+)\s
|
|
35474
|
+
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
35475
35475
|
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
35476
|
-
var keyword =
|
|
35476
|
+
var keyword = /^(\w+)$/;
|
|
35477
35477
|
var rgb = [0, 0, 0, 1];
|
|
35478
35478
|
var match;
|
|
35479
35479
|
var i;
|
|
@@ -35503,7 +35503,7 @@ cs.get.rgb = function(string) {
|
|
|
35503
35503
|
}
|
|
35504
35504
|
if (match[4]) {
|
|
35505
35505
|
if (match[5]) {
|
|
35506
|
-
rgb[3] =
|
|
35506
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
35507
35507
|
} else {
|
|
35508
35508
|
rgb[3] = parseFloat(match[4]);
|
|
35509
35509
|
}
|
|
@@ -35514,7 +35514,7 @@ cs.get.rgb = function(string) {
|
|
|
35514
35514
|
}
|
|
35515
35515
|
if (match[4]) {
|
|
35516
35516
|
if (match[5]) {
|
|
35517
|
-
rgb[3] =
|
|
35517
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
35518
35518
|
} else {
|
|
35519
35519
|
rgb[3] = parseFloat(match[4]);
|
|
35520
35520
|
}
|
|
@@ -36638,7 +36638,7 @@ if (runningOnBrowser) {
|
|
|
36638
36638
|
autoInitialize(LazyLoad, window.lazyLoadOptions);
|
|
36639
36639
|
}
|
|
36640
36640
|
class DocsViewer {
|
|
36641
|
-
constructor({ readonly,
|
|
36641
|
+
constructor({ readonly, onNewPageIndex, onPlay }) {
|
|
36642
36642
|
this._pages = [];
|
|
36643
36643
|
this.pageIndex = 0;
|
|
36644
36644
|
this.setPaused = () => {
|
|
@@ -36652,7 +36652,6 @@ class DocsViewer {
|
|
|
36652
36652
|
this.isSmallBox = false;
|
|
36653
36653
|
this.sideEffect = new o();
|
|
36654
36654
|
this.readonly = readonly;
|
|
36655
|
-
this.box = box;
|
|
36656
36655
|
this.onNewPageIndex = onNewPageIndex;
|
|
36657
36656
|
this.onPlay = onPlay;
|
|
36658
36657
|
this.render();
|
|
@@ -36666,10 +36665,6 @@ class DocsViewer {
|
|
|
36666
36665
|
get pages() {
|
|
36667
36666
|
return this._pages;
|
|
36668
36667
|
}
|
|
36669
|
-
mount() {
|
|
36670
|
-
this.box.mountContent(this.$content);
|
|
36671
|
-
this.box.mountFooter(this.$footer);
|
|
36672
|
-
}
|
|
36673
36668
|
unmount() {
|
|
36674
36669
|
this.$content.remove();
|
|
36675
36670
|
this.$footer.remove();
|
|
@@ -36962,7 +36957,6 @@ class SlideDocsViewer {
|
|
|
36962
36957
|
this.mountSlideController = mountSlideController;
|
|
36963
36958
|
this.mountWhiteboard = mountWhiteboard;
|
|
36964
36959
|
this.viewer = new DocsViewer({
|
|
36965
|
-
box,
|
|
36966
36960
|
readonly: box.readonly,
|
|
36967
36961
|
onNewPageIndex: this.onNewPageIndex,
|
|
36968
36962
|
onPlay: this.onPlay
|
|
@@ -37013,7 +37007,8 @@ class SlideDocsViewer {
|
|
|
37013
37007
|
return this.$whiteboardView;
|
|
37014
37008
|
}
|
|
37015
37009
|
mount() {
|
|
37016
|
-
this.
|
|
37010
|
+
this.box.mountContent(this.viewer.$content);
|
|
37011
|
+
this.box.mountFooter(this.viewer.$footer);
|
|
37017
37012
|
this.slideController = this.mountSlideController({
|
|
37018
37013
|
anchor: this.$slide,
|
|
37019
37014
|
onTransitionStart: this.viewer.setPlaying,
|
|
@@ -37102,6 +37097,139 @@ const addHooks = (emitter) => {
|
|
|
37102
37097
|
});
|
|
37103
37098
|
};
|
|
37104
37099
|
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}.netless-app-slide-footer-btn:hover{background:rgba(237,237,240,.9)}.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;text-align:right;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text}.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-btn{cursor:not-allowed}.netless-app-slide-readonly .netless-app-slide-footer-btn:hover{background:transparent}.netless-app-slide-readonly .netless-app-slide-page-number-input{cursor:not-allowed}.netless-app-slide-readonly .netless-app-slide-page-number-input:hover,.netless-app-slide-readonly .netless-app-slide-page-number-input:focus,.netless-app-slide-readonly .netless-app-slide-page-number-input:active{background:transparent;box-shadow:none}.netless-app-slide-readonly .netless-app-slide-page-number-input:disabled{color:inherit}.netless-app-slide-readonly.netless-app-slide-float-footer{display:none}.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";
|
|
37100
|
+
function previewSlide({
|
|
37101
|
+
container,
|
|
37102
|
+
taskId,
|
|
37103
|
+
url = DefaultUrl,
|
|
37104
|
+
debug = false
|
|
37105
|
+
}) {
|
|
37106
|
+
if (!taskId) {
|
|
37107
|
+
throw new Error("[Slide] taskId is required");
|
|
37108
|
+
}
|
|
37109
|
+
container.style.cssText += `display:flex;flex-direction:column`;
|
|
37110
|
+
const previewer = new SlidePreviewer({ target: container });
|
|
37111
|
+
previewer.debug = !!debug;
|
|
37112
|
+
previewer.mount(taskId, url);
|
|
37113
|
+
return previewer;
|
|
37114
|
+
}
|
|
37115
|
+
class SlidePreviewer {
|
|
37116
|
+
constructor(config) {
|
|
37117
|
+
this.slide = null;
|
|
37118
|
+
this.debug = false;
|
|
37119
|
+
this.ready = false;
|
|
37120
|
+
this.readyPromise = new Promise((resolve) => {
|
|
37121
|
+
this.resolveReady = () => {
|
|
37122
|
+
this.ready = true;
|
|
37123
|
+
resolve();
|
|
37124
|
+
};
|
|
37125
|
+
});
|
|
37126
|
+
this.onPageChanged = (page) => {
|
|
37127
|
+
this.viewer.setPageIndex(page - 1);
|
|
37128
|
+
};
|
|
37129
|
+
this.onTransitionStart = () => {
|
|
37130
|
+
this.viewer.setPlaying();
|
|
37131
|
+
};
|
|
37132
|
+
this.onTransitionEnd = () => {
|
|
37133
|
+
this.viewer.setPaused();
|
|
37134
|
+
};
|
|
37135
|
+
this.onError = ({ error }) => {
|
|
37136
|
+
this.viewer.setPaused();
|
|
37137
|
+
console.warn("[Slide] render error", error);
|
|
37138
|
+
};
|
|
37139
|
+
this.destroyed = false;
|
|
37140
|
+
this.refreshPages = () => {
|
|
37141
|
+
if (this.slide) {
|
|
37142
|
+
this.viewer.pages = createDocsViewerPages(this.slide);
|
|
37143
|
+
this.viewer.setPageIndex(this.getPageIndex(this.slide.slideState.currentSlideIndex));
|
|
37144
|
+
}
|
|
37145
|
+
};
|
|
37146
|
+
this.onPlay = () => {
|
|
37147
|
+
if (this.slide) {
|
|
37148
|
+
this.slide.nextStep();
|
|
37149
|
+
}
|
|
37150
|
+
};
|
|
37151
|
+
this.onNewPageIndex = (index) => {
|
|
37152
|
+
if (this.slide && this.slide.slideCount > 0) {
|
|
37153
|
+
this.slide.renderSlide(clamp$1(index + 1, 1, this.slide.slideCount));
|
|
37154
|
+
}
|
|
37155
|
+
};
|
|
37156
|
+
this.namespace = "netless-app-slide";
|
|
37157
|
+
this.target = config.target;
|
|
37158
|
+
this.bgColor = cachedGetBgColor(this.target);
|
|
37159
|
+
this.viewer = new DocsViewer({
|
|
37160
|
+
readonly: false,
|
|
37161
|
+
onNewPageIndex: this.onNewPageIndex,
|
|
37162
|
+
onPlay: this.onPlay
|
|
37163
|
+
});
|
|
37164
|
+
this.render();
|
|
37165
|
+
}
|
|
37166
|
+
render() {
|
|
37167
|
+
this.viewer.$content.appendChild(this.renderSlideContainer());
|
|
37168
|
+
}
|
|
37169
|
+
mount(taskId, url) {
|
|
37170
|
+
this.target.appendChild(this.renderStyle());
|
|
37171
|
+
this.target.appendChild(this.viewer.$content);
|
|
37172
|
+
this.target.appendChild(this.viewer.$footer);
|
|
37173
|
+
this.slide = new Slide.Slide({
|
|
37174
|
+
anchor: this.$slide,
|
|
37175
|
+
interactive: false,
|
|
37176
|
+
mode: "local",
|
|
37177
|
+
resize: true,
|
|
37178
|
+
controller: this.debug,
|
|
37179
|
+
renderOptions: {
|
|
37180
|
+
minFPS: 25,
|
|
37181
|
+
maxFPS: 30,
|
|
37182
|
+
autoFPS: true,
|
|
37183
|
+
autoResolution: true,
|
|
37184
|
+
transactionBgColor: this.bgColor
|
|
37185
|
+
}
|
|
37186
|
+
});
|
|
37187
|
+
this.registerEventListeners();
|
|
37188
|
+
this.slide.setResource(taskId, url);
|
|
37189
|
+
this.slide.renderSlide(1);
|
|
37190
|
+
}
|
|
37191
|
+
renderStyle() {
|
|
37192
|
+
const element = document.createElement("style");
|
|
37193
|
+
element.appendChild(document.createTextNode(styles));
|
|
37194
|
+
return element;
|
|
37195
|
+
}
|
|
37196
|
+
registerEventListeners() {
|
|
37197
|
+
if (!this.slide)
|
|
37198
|
+
return;
|
|
37199
|
+
const { slide } = this;
|
|
37200
|
+
slide.on(Slide.SLIDE_EVENTS.slideChange, this.onPageChanged);
|
|
37201
|
+
slide.on(Slide.SLIDE_EVENTS.renderStart, this.onTransitionStart);
|
|
37202
|
+
slide.on(Slide.SLIDE_EVENTS.renderEnd, this.onTransitionEnd);
|
|
37203
|
+
slide.on(Slide.SLIDE_EVENTS.mainSeqStepStart, this.onTransitionStart);
|
|
37204
|
+
slide.on(Slide.SLIDE_EVENTS.mainSeqStepEnd, this.onTransitionEnd);
|
|
37205
|
+
slide.on(Slide.SLIDE_EVENTS.renderError, this.onError);
|
|
37206
|
+
slide.on(Slide.SLIDE_EVENTS.renderEnd, this.resolveReady);
|
|
37207
|
+
this.readyPromise.then(this.refreshPages);
|
|
37208
|
+
}
|
|
37209
|
+
destroy() {
|
|
37210
|
+
if (this.slide && !this.destroyed) {
|
|
37211
|
+
log("[Slide] destroy slide (once)");
|
|
37212
|
+
this.slide.destroy();
|
|
37213
|
+
this.destroyed = true;
|
|
37214
|
+
}
|
|
37215
|
+
this.viewer.destroy();
|
|
37216
|
+
}
|
|
37217
|
+
getPageIndex(page) {
|
|
37218
|
+
return (page > 0 ? page : 1) - 1;
|
|
37219
|
+
}
|
|
37220
|
+
renderSlideContainer() {
|
|
37221
|
+
if (!this.$slide) {
|
|
37222
|
+
const $slide = document.createElement("div");
|
|
37223
|
+
$slide.className = this.wrapClassName("slide");
|
|
37224
|
+
$slide.dataset.appKind = "Slide";
|
|
37225
|
+
this.$slide = $slide;
|
|
37226
|
+
}
|
|
37227
|
+
return this.$slide;
|
|
37228
|
+
}
|
|
37229
|
+
wrapClassName(className) {
|
|
37230
|
+
return `${this.namespace}-${className}`;
|
|
37231
|
+
}
|
|
37232
|
+
}
|
|
37105
37233
|
const SlideApp = {
|
|
37106
37234
|
kind: "Slide",
|
|
37107
37235
|
setup(context) {
|
|
@@ -37184,5 +37312,5 @@ const SlideApp = {
|
|
|
37184
37312
|
docsViewer.mount();
|
|
37185
37313
|
}
|
|
37186
37314
|
};
|
|
37187
|
-
export { DefaultUrl, FreezerLength, addHooks, apps, SlideApp as default };
|
|
37315
|
+
export { DefaultUrl, FreezerLength, SlidePreviewer, addHooks, apps, SlideApp as default, previewSlide };
|
|
37188
37316
|
//# sourceMappingURL=main.es.js.map
|