@scarlett-player/gestures 1.8.1 → 1.9.0

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/index.cjs CHANGED
@@ -178,6 +178,7 @@ function createRecognizer(options = {}) {
178
178
  }
179
179
 
180
180
  // src/overlay.ts
181
+ var import_core = require("@scarlett-player/core");
181
182
  var STYLE_ID = "sp-gestures-styles";
182
183
  var styles = `
183
184
  .sp-gestures {
@@ -250,7 +251,7 @@ var GestureOverlay = class {
250
251
  constructor(container, options) {
251
252
  this.container = container;
252
253
  this.options = options;
253
- this.styleEl = null;
254
+ this.releaseStyles = null;
254
255
  this.hideTimer = null;
255
256
  this.pointerHandler = (event) => {
256
257
  if (event.pointerType !== "touch") return;
@@ -325,8 +326,8 @@ var GestureOverlay = class {
325
326
  this.el.removeEventListener("pointerup", this.pointerHandler);
326
327
  this.el.removeEventListener("pointercancel", this.pointerHandler);
327
328
  this.el.remove();
328
- this.styleEl?.remove();
329
- this.styleEl = null;
329
+ this.releaseStyles?.();
330
+ this.releaseStyles = null;
330
331
  }
331
332
  /** Exposed for tests and for hosts that want to inspect the surface. */
332
333
  getElement() {
@@ -341,17 +342,19 @@ var GestureOverlay = class {
341
342
  zone.appendChild(label);
342
343
  return { zone, label };
343
344
  }
345
+ /**
346
+ * Claim the shared gesture stylesheet.
347
+ *
348
+ * Reference-counted: two players on one page share the sheet, and destroying
349
+ * either used to take it away from the other.
350
+ */
344
351
  injectStyles() {
345
- if (document.getElementById(STYLE_ID)) return;
346
- this.styleEl = document.createElement("style");
347
- this.styleEl.id = STYLE_ID;
348
- this.styleEl.textContent = styles;
349
- document.head.appendChild(this.styleEl);
352
+ this.releaseStyles = (0, import_core.injectSharedStyles)(STYLE_ID, styles);
350
353
  }
351
354
  };
352
355
 
353
356
  // src/version.ts
354
- var PKG_VERSION = true ? "1.8.1" : "0.0.0-dev";
357
+ var PKG_VERSION = true ? "1.9.0" : "0.0.0-dev";
355
358
 
356
359
  // src/index.ts
357
360
  function hasCoarsePointer() {
package/dist/index.d.cts CHANGED
@@ -201,7 +201,7 @@ declare class GestureOverlay {
201
201
  private zones;
202
202
  private labels;
203
203
  private live;
204
- private styleEl;
204
+ private releaseStyles;
205
205
  private hideTimer;
206
206
  private readonly pointerHandler;
207
207
  constructor(container: HTMLElement, options: OverlayOptions);
@@ -220,6 +220,12 @@ declare class GestureOverlay {
220
220
  /** Exposed for tests and for hosts that want to inspect the surface. */
221
221
  getElement(): HTMLElement;
222
222
  private createZone;
223
+ /**
224
+ * Claim the shared gesture stylesheet.
225
+ *
226
+ * Reference-counted: two players on one page share the sheet, and destroying
227
+ * either used to take it away from the other.
228
+ */
223
229
  private injectStyles;
224
230
  }
225
231
 
package/dist/index.d.ts CHANGED
@@ -201,7 +201,7 @@ declare class GestureOverlay {
201
201
  private zones;
202
202
  private labels;
203
203
  private live;
204
- private styleEl;
204
+ private releaseStyles;
205
205
  private hideTimer;
206
206
  private readonly pointerHandler;
207
207
  constructor(container: HTMLElement, options: OverlayOptions);
@@ -220,6 +220,12 @@ declare class GestureOverlay {
220
220
  /** Exposed for tests and for hosts that want to inspect the surface. */
221
221
  getElement(): HTMLElement;
222
222
  private createZone;
223
+ /**
224
+ * Claim the shared gesture stylesheet.
225
+ *
226
+ * Reference-counted: two players on one page share the sheet, and destroying
227
+ * either used to take it away from the other.
228
+ */
223
229
  private injectStyles;
224
230
  }
225
231
 
package/dist/index.js CHANGED
@@ -147,6 +147,7 @@ function createRecognizer(options = {}) {
147
147
  }
148
148
 
149
149
  // src/overlay.ts
150
+ import { injectSharedStyles } from "@scarlett-player/core";
150
151
  var STYLE_ID = "sp-gestures-styles";
151
152
  var styles = `
152
153
  .sp-gestures {
@@ -219,7 +220,7 @@ var GestureOverlay = class {
219
220
  constructor(container, options) {
220
221
  this.container = container;
221
222
  this.options = options;
222
- this.styleEl = null;
223
+ this.releaseStyles = null;
223
224
  this.hideTimer = null;
224
225
  this.pointerHandler = (event) => {
225
226
  if (event.pointerType !== "touch") return;
@@ -294,8 +295,8 @@ var GestureOverlay = class {
294
295
  this.el.removeEventListener("pointerup", this.pointerHandler);
295
296
  this.el.removeEventListener("pointercancel", this.pointerHandler);
296
297
  this.el.remove();
297
- this.styleEl?.remove();
298
- this.styleEl = null;
298
+ this.releaseStyles?.();
299
+ this.releaseStyles = null;
299
300
  }
300
301
  /** Exposed for tests and for hosts that want to inspect the surface. */
301
302
  getElement() {
@@ -310,17 +311,19 @@ var GestureOverlay = class {
310
311
  zone.appendChild(label);
311
312
  return { zone, label };
312
313
  }
314
+ /**
315
+ * Claim the shared gesture stylesheet.
316
+ *
317
+ * Reference-counted: two players on one page share the sheet, and destroying
318
+ * either used to take it away from the other.
319
+ */
313
320
  injectStyles() {
314
- if (document.getElementById(STYLE_ID)) return;
315
- this.styleEl = document.createElement("style");
316
- this.styleEl.id = STYLE_ID;
317
- this.styleEl.textContent = styles;
318
- document.head.appendChild(this.styleEl);
321
+ this.releaseStyles = injectSharedStyles(STYLE_ID, styles);
319
322
  }
320
323
  };
321
324
 
322
325
  // src/version.ts
323
- var PKG_VERSION = true ? "1.8.1" : "0.0.0-dev";
326
+ var PKG_VERSION = true ? "1.9.0" : "0.0.0-dev";
324
327
 
325
328
  // src/index.ts
326
329
  function hasCoarsePointer() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scarlett-player/gestures",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "description": "Gestures Plugin for Scarlett Player - double-tap seek zones and tap to toggle controls",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -30,7 +30,7 @@
30
30
  "tsup": "^8.5.1",
31
31
  "typescript": "^5.3.0",
32
32
  "vitest": "^1.6.0",
33
- "@scarlett-player/core": "1.8.1"
33
+ "@scarlett-player/core": "1.9.0"
34
34
  },
35
35
  "keywords": [
36
36
  "video",