@netless/app-slide 0.3.0-canary.2 → 0.3.0-canary.5

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/typings.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Slide, SLIDE_EVENTS, SyncEvent } from "@netless/slide";
1
+ import type { ISlideRenderOptions, Slide, SLIDE_EVENTS, SyncEvent } from "@netless/slide";
2
2
  import type { RegisterParams } from "@netless/window-manager";
3
3
  export declare type SlideState = Slide["slideState"];
4
4
  export declare type AddHooks = NonNullable<RegisterParams["addHooks"]>;
@@ -13,19 +13,6 @@ export interface Attributes {
13
13
  export interface MagixEvents {
14
14
  [SLIDE_EVENTS.syncDispatch]: SyncEvent;
15
15
  }
16
- export interface AppOptions {
17
- /** show debug controller */
16
+ export interface AppOptions extends ISlideRenderOptions {
18
17
  debug?: boolean;
19
- /** scale */
20
- resolution?: number;
21
- /** background color for slide animations */
22
- bgColor?: string;
23
- /** minimal fps (default: 25) */
24
- minFPS?: number;
25
- /** maximal fps (default: 30) */
26
- maxFPS?: number;
27
- /** automatically decrease fps (default: true) */
28
- autoFPS?: boolean;
29
- /** whether to re-scale automatically (default: true) */
30
- autoResolution?: boolean;
31
18
  }
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "@netless/app-slide",
3
- "version": "0.3.0-canary.2",
4
- "main": "dist/main.cjs.js",
5
- "module": "dist/main.es.js",
3
+ "version": "0.3.0-canary.5",
4
+ "main": "dist/main.js",
5
+ "module": "dist/main.mjs",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "src",
9
9
  "dist",
10
10
  "README-zh.md"
11
11
  ],
12
+ "dependencies": {
13
+ "@netless/slide": "^0.5.10"
14
+ },
12
15
  "devDependencies": {
13
- "@netless/slide": "^0.4.7",
14
16
  "@types/color-string": "^1.5.2",
15
17
  "color-string": "^1.9.1",
16
- "side-effect-manager": "^1.1.0",
17
- "value-enhancer": "^1.3.0",
18
- "vanilla-lazyload": "^17.8.2"
18
+ "side-effect-manager": "^1.1.1",
19
+ "value-enhancer": "^1.3.2",
20
+ "vanilla-lazyload": "^17.8.3"
19
21
  },
20
22
  "scripts": {
21
23
  "types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --outDir dist",
@@ -176,8 +176,8 @@ function create_sidebar() {
176
176
  }
177
177
  }
178
178
 
179
- function set_page_index(page_index_: number) {
180
- if (page_index !== page_index_) {
179
+ function set_page_index(page_index_: number, force = false) {
180
+ if (force || page_index !== page_index_) {
181
181
  page_index = page_index_;
182
182
  const $page = $preview.querySelector<HTMLElement>(
183
183
  `.${wrap_class(`preview-page-${page_index}`)}`
@@ -292,9 +292,6 @@ function create_footer() {
292
292
  const $pageNumberInput = h("input");
293
293
  set_class($pageNumberInput, "page-number-input");
294
294
  $pageNumberInput.value = String(page_index + 1);
295
- $pageNumberInput.onfocus = function on_focus_page_number_input() {
296
- $pageNumberInput.select();
297
- };
298
295
  $pageNumberInput.onchange = function on_change_page_number_input() {
299
296
  if (readonly) return;
300
297
  if ($pageNumberInput.value) {
@@ -329,8 +326,8 @@ function create_footer() {
329
326
  }
330
327
  }
331
328
 
332
- function set_page_index(page_index_: number) {
333
- if (page_index !== page_index_) {
329
+ function set_page_index(page_index_: number, force = false) {
330
+ if (force || page_index !== page_index_) {
334
331
  page_index = page_index_;
335
332
  $pageNumberInput.value = String(page_index + 1);
336
333
  }
@@ -414,6 +411,8 @@ export class SlideViewer {
414
411
  const on_new_page_index = (index: number) => {
415
412
  if (this._ready && index >= 0 && index < this._slideCount) {
416
413
  this.slide.renderSlide(index + 1);
414
+ } else {
415
+ this.setPage(this.slide.slideState.currentSlideIndex);
417
416
  }
418
417
  };
419
418
  this.sidebar.on_new_page_index(on_new_page_index);
@@ -429,6 +428,11 @@ export class SlideViewer {
429
428
 
430
429
  this.sideEffect.addDisposer(this.sidebar.destroy);
431
430
  this.sideEffect.addDisposer(() => this.slide.destroy());
431
+ this.sideEffect.addDisposer(() => {
432
+ this.$content.parentElement && this.$content.remove();
433
+ this.$footer.parentElement && this.$footer.remove();
434
+ this.$slide.parentElement && this.$slide.remove();
435
+ });
432
436
 
433
437
  let saved_is_frozen = false;
434
438
  this.sideEffect.addDisposer(
@@ -528,30 +532,23 @@ export class SlideViewer {
528
532
  }
529
533
 
530
534
  setPage(page: number) {
531
- this.sidebar.set_page_index(page - 1);
532
- this.footer.set_page_index(page - 1);
535
+ this.sidebar.set_page_index(page - 1, true);
536
+ this.footer.set_page_index(page - 1, true);
533
537
  }
534
538
 
535
539
  private _isFrozen = false;
536
- private _freezePromise: Promise<void> | null = null;
537
540
 
538
541
  freeze() {
539
542
  if (this._destroyed) return;
540
543
  this._isFrozen = true;
541
- if (!this._ready || this._freezePromise) return;
542
- this._freezePromise = this.slide.frozen().then(() => {
543
- this._freezePromise = null;
544
- if (!this._isFrozen) this.unfreeze();
545
- });
544
+ if (!this._ready) return;
545
+ this.slide.frozen();
546
546
  }
547
547
 
548
548
  unfreeze() {
549
549
  if (this._destroyed) return;
550
550
  this._isFrozen = false;
551
- if (!this._ready || this._freezePromise) return;
552
- this._freezePromise = this.slide.release().then(() => {
553
- this._freezePromise = null;
554
- if (this._isFrozen) this.freeze();
555
- });
551
+ if (!this._ready) return;
552
+ this.slide.release();
556
553
  }
557
554
  }
package/src/index.ts CHANGED
@@ -23,7 +23,6 @@ const SlideApp: NetlessApp<Attributes, MagixEvents, AppOptions, void> = {
23
23
  }
24
24
 
25
25
  const options = context.getAppOptions() || {};
26
- const debug = Boolean(options.debug);
27
26
  const logger = make_logger(context);
28
27
  logger.info("[Slide] setup @ " + __APP_VERSION__);
29
28
 
@@ -35,7 +34,6 @@ const SlideApp: NetlessApp<Attributes, MagixEvents, AppOptions, void> = {
35
34
  mode: "interactive",
36
35
  resize: true,
37
36
  enableGlobalClick: true,
38
- controller: debug,
39
37
  timestamp: make_timestamp(context),
40
38
  logger,
41
39
  renderOptions: {
@@ -44,7 +42,8 @@ const SlideApp: NetlessApp<Attributes, MagixEvents, AppOptions, void> = {
44
42
  autoFPS: options.autoFPS ?? true,
45
43
  autoResolution: options.autoResolution ?? true,
46
44
  resolution: options.resolution,
47
- transactionBgColor: options.bgColor || make_bg_color(context.box.$content),
45
+ maxResolutionLevel: options.maxResolutionLevel,
46
+ transactionBgColor: options.transactionBgColor || make_bg_color(context.box.$content),
48
47
  },
49
48
 
50
49
  taskId: context.storage.state.taskId,
@@ -92,6 +91,11 @@ export function previewSlide(options: SlideViewerOptions & { container: HTMLElem
92
91
  return viewer;
93
92
  }
94
93
 
94
+ if (import.meta.env.DEV) {
95
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
+ (window as any).previewSlide = previewSlide;
97
+ }
98
+
95
99
  function make_timestamp(context: AppContext): () => number {
96
100
  const room = context.room;
97
101
  const player = context.displayer as Player;
@@ -166,7 +170,8 @@ function connect({ context, viewer, sideEffect, logger }: ConnectParams) {
166
170
  viewer.prepare(({ width, height, slideCount }) => {
167
171
  if (context.destroyed) return;
168
172
  width && context.box.setStageRatio(height / width);
169
- whiteboard = context.createWhiteBoardView(slideCount);
173
+ whiteboard = context.createWhiteBoardView({ size: slideCount });
174
+ whiteboard.setBaseRect({ width, height });
170
175
  kick_start();
171
176
  });
172
177
 
package/src/style.scss CHANGED
@@ -1,5 +1,13 @@
1
1
  @import "./fancy-scrollbar.scss";
2
2
 
3
+ @mixin no-user-select {
4
+ -webkit-touch-callout: none;
5
+ -webkit-user-select: none;
6
+ -moz-user-select: none;
7
+ -ms-user-select: none;
8
+ user-select: none;
9
+ }
10
+
3
11
  $namespace: "netless-app-slide";
4
12
 
5
13
  .#{$namespace}-content {
@@ -11,12 +19,13 @@ $namespace: "netless-app-slide";
11
19
  .#{$namespace}-slide {
12
20
  width: 100%;
13
21
  height: 100%;
22
+ @include no-user-select;
14
23
  }
15
24
 
16
25
  .#{$namespace}-preview-mask {
17
26
  display: none;
18
27
  position: absolute;
19
- z-index: 6000;
28
+ z-index: 10200;
20
29
  top: 0;
21
30
  left: 0;
22
31
  width: 100%;
@@ -28,7 +37,7 @@ $namespace: "netless-app-slide";
28
37
  flex-direction: column;
29
38
  align-items: center;
30
39
  position: absolute;
31
- z-index: 6100;
40
+ z-index: 10300;
32
41
  top: 0;
33
42
  left: 0;
34
43
  width: 33%;
@@ -39,6 +48,7 @@ $namespace: "netless-app-slide";
39
48
  background: rgba(237, 237, 240, 0.9);
40
49
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.11);
41
50
  transition: transform 0.4s;
51
+ @include no-user-select;
42
52
  }
43
53
 
44
54
  .#{$namespace}-preview-active {
@@ -62,7 +72,7 @@ $namespace: "netless-app-slide";
62
72
  border: 7px solid transparent;
63
73
  border-radius: 4px;
64
74
  transition: border-color 0.3s;
65
- user-select: none;
75
+ @include no-user-select;
66
76
 
67
77
  &:hover,
68
78
  &.#{$namespace}-preview-page-active {
@@ -88,7 +98,7 @@ $namespace: "netless-app-slide";
88
98
  text-align: right;
89
99
  font-size: 12px;
90
100
  color: #5f5f5f;
91
- user-select: none;
101
+ @include no-user-select;
92
102
  }
93
103
 
94
104
  .#{$namespace}-footer {
@@ -98,7 +108,8 @@ $namespace: "netless-app-slide";
98
108
  align-items: center;
99
109
  padding: 0 16px;
100
110
  border-top: 1px solid #eeeef7;
101
- color: #191919;
111
+ font-family: system-ui, -apple-system, "Segoe UI", "Roboto", "Ubuntu", "Cantarell", "Noto Sans",
112
+ sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
102
113
  }
103
114
 
104
115
  .#{$namespace}-float-footer {
@@ -126,7 +137,7 @@ $namespace: "netless-app-slide";
126
137
  background: transparent;
127
138
  transition: background 0.4s;
128
139
  cursor: pointer;
129
- user-select: none;
140
+ @include no-user-select;
130
141
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
131
142
 
132
143
  &:hover {
@@ -171,11 +182,15 @@ $namespace: "netless-app-slide";
171
182
  }
172
183
 
173
184
  .#{$namespace}-page-number {
185
+ display: flex;
186
+ align-items: center;
187
+ height: 26px;
174
188
  margin-left: auto;
175
189
  font-size: 13px;
176
- user-select: none;
190
+ @include no-user-select;
177
191
  white-space: nowrap;
178
192
  word-break: keep-all;
193
+ font-variant-numeric: tabular-nums;
179
194
  }
180
195
 
181
196
  .#{$namespace}-page-number-input {
@@ -183,7 +198,7 @@ $namespace: "netless-app-slide";
183
198
  outline: none;
184
199
  width: 3em;
185
200
  margin: 0;
186
- padding: 0 2px;
201
+ padding: 0 0.5em 0 2px;
187
202
  text-align: right;
188
203
  font-size: 13px;
189
204
  line-height: 1;
@@ -191,14 +206,17 @@ $namespace: "netless-app-slide";
191
206
  font-family: inherit;
192
207
  border-radius: 2px;
193
208
  color: currentColor;
209
+ font-family: system-ui, -apple-system, "Segoe UI", "Roboto", "Ubuntu", "Cantarell", "Noto Sans",
210
+ sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
194
211
  background: transparent;
195
212
  transition: background 0.4s;
196
- user-select: text;
213
+ font-variant-numeric: tabular-nums;
197
214
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
198
215
 
199
216
  &:hover,
200
217
  &:focus,
201
218
  &:active {
219
+ user-select: text;
202
220
  background: #fff;
203
221
  box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
204
222
  }
@@ -234,17 +252,13 @@ $namespace: "netless-app-slide";
234
252
  }
235
253
 
236
254
  .telebox-color-scheme-dark {
237
- .#{$namespace}-page-number-input {
238
- color: #a6a6a8;
239
- }
240
255
  .#{$namespace}-page-number-input:active,
241
256
  .#{$namespace}-page-number-input:focus,
242
257
  .#{$namespace}-page-number-input:hover {
243
- color: #222;
258
+ color: currentColor;
259
+ background: #25282e;
244
260
  }
245
261
  .#{$namespace}-footer {
246
- color: #a6a6a8;
247
- background: #2d2d33;
248
262
  border-top: none;
249
263
  }
250
264
  .#{$namespace}-footer-btn:hover {
package/src/typings.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Slide, SLIDE_EVENTS, SyncEvent } from "@netless/slide";
1
+ import type { ISlideRenderOptions, Slide, SLIDE_EVENTS, SyncEvent } from "@netless/slide";
2
2
  import type { RegisterParams } from "@netless/window-manager";
3
3
 
4
4
  export type SlideState = Slide["slideState"];
@@ -18,19 +18,6 @@ export interface MagixEvents {
18
18
  [SLIDE_EVENTS.syncDispatch]: SyncEvent;
19
19
  }
20
20
 
21
- export interface AppOptions {
22
- /** show debug controller */
21
+ export interface AppOptions extends ISlideRenderOptions {
23
22
  debug?: boolean;
24
- /** scale */
25
- resolution?: number;
26
- /** background color for slide animations */
27
- bgColor?: string;
28
- /** minimal fps (default: 25) */
29
- minFPS?: number;
30
- /** maximal fps (default: 30) */
31
- maxFPS?: number;
32
- /** automatically decrease fps (default: true) */
33
- autoFPS?: boolean;
34
- /** whether to re-scale automatically (default: true) */
35
- autoResolution?: boolean;
36
23
  }