@surdeddd/bottom-sheet 0.20.0 → 0.20.1

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/vue.cjs CHANGED
@@ -4996,7 +4996,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4996
4996
  /* KEYED_FRAGMENT */
4997
4997
  ))], 8, ["to", "disabled"]);
4998
4998
  }
4999
- var BottomSheet_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/BottomSheet/BottomSheet/src/vue/BottomSheet.vue"]]);
4999
+ var BottomSheet_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/Users/maksimkravcov/Projects/Personal/BottomSheet/src/vue/BottomSheet.vue"]]);
5000
5000
 
5001
5001
  exports.BottomSheet = BottomSheet_default;
5002
5002
  exports.useBottomSheet = useBottomSheet;
package/dist/vue.js CHANGED
@@ -4994,7 +4994,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4994
4994
  /* KEYED_FRAGMENT */
4995
4995
  ))], 8, ["to", "disabled"]);
4996
4996
  }
4997
- var BottomSheet_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/BottomSheet/BottomSheet/src/vue/BottomSheet.vue"]]);
4997
+ var BottomSheet_default = /* @__PURE__ */ export_helper_default(_sfc_main, [["render", _sfc_render], ["__file", "/Users/maksimkravcov/Projects/Personal/BottomSheet/src/vue/BottomSheet.vue"]]);
4998
4998
 
4999
4999
  export { BottomSheet_default as BottomSheet, useBottomSheet };
5000
5000
  //# sourceMappingURL=vue.js.map
package/dist/webgl.cjs CHANGED
@@ -1,12 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  // src/webgl/gl-context.ts
4
+ var supportsHighpFragment = (gl) => {
5
+ try {
6
+ const fmt = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
7
+ return !!fmt && fmt.precision > 0;
8
+ } catch {
9
+ return false;
10
+ }
11
+ };
4
12
  var hasWebGL = () => {
5
13
  if (typeof document === "undefined") return false;
6
- if (typeof WebGLRenderingContext === "undefined") return false;
14
+ if (typeof WebGLRenderingContext === "undefined" && typeof WebGL2RenderingContext === "undefined") {
15
+ return false;
16
+ }
7
17
  try {
8
18
  const probe = document.createElement("canvas");
9
- const gl = probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
19
+ const gl = probe.getContext("webgl2", { alpha: true }) ?? probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
10
20
  if (!gl) return false;
11
21
  const lose = gl.getExtension(
12
22
  "WEBGL_lose_context"
@@ -25,18 +35,26 @@ var createGLHandle = (onLost) => {
25
35
  canvas.style.left = "0";
26
36
  canvas.style.top = "0";
27
37
  canvas.style.pointerEvents = "none";
38
+ const attrs = {
39
+ alpha: true,
40
+ premultipliedAlpha: true,
41
+ antialias: true,
42
+ depth: false,
43
+ stencil: false,
44
+ preserveDrawingBuffer: false
45
+ };
28
46
  let gl = null;
29
- try {
30
- gl = canvas.getContext("webgl", {
31
- alpha: true,
32
- premultipliedAlpha: true,
33
- antialias: true,
34
- depth: false,
35
- stencil: false,
36
- preserveDrawingBuffer: false
37
- });
38
- } catch {
39
- gl = null;
47
+ let isWebGL2 = false;
48
+ for (const id of ["webgl2", "webgl", "experimental-webgl"]) {
49
+ try {
50
+ const ctx = canvas.getContext(id, attrs);
51
+ if (ctx) {
52
+ gl = ctx;
53
+ isWebGL2 = id === "webgl2";
54
+ break;
55
+ }
56
+ } catch {
57
+ }
40
58
  }
41
59
  if (!gl) return null;
42
60
  const handleLost = (e) => {
@@ -47,6 +65,8 @@ var createGLHandle = (onLost) => {
47
65
  return {
48
66
  canvas,
49
67
  gl,
68
+ isWebGL2,
69
+ highp: isWebGL2 || supportsHighpFragment(gl),
50
70
  destroy: () => {
51
71
  canvas.removeEventListener("webglcontextlost", handleLost);
52
72
  const lose = gl?.getExtension("WEBGL_lose_context");
@@ -77,8 +97,8 @@ void main() {
77
97
  gl_Position = vec4(a_pos, 0.0, 1.0);
78
98
  }
79
99
  `;
80
- var FRAGMENT_SRC = `
81
- precision mediump float;
100
+ var FRAGMENT_SRC = (precision) => `
101
+ precision ${precision} float;
82
102
 
83
103
  uniform vec2 u_resolution;
84
104
  uniform vec4 u_rect;
@@ -155,9 +175,16 @@ var compile = (gl, type, src) => {
155
175
  }
156
176
  return shader;
157
177
  };
158
- var createSurfaceProgram = (gl) => {
178
+ var createSurfaceProgram = (gl, highp = true) => {
159
179
  const vs = compile(gl, gl.VERTEX_SHADER, VERTEX_SRC);
160
- const fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC);
180
+ let fs = compile(
181
+ gl,
182
+ gl.FRAGMENT_SHADER,
183
+ FRAGMENT_SRC(highp ? "highp" : "mediump")
184
+ );
185
+ if (!fs && highp) {
186
+ fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC("mediump"));
187
+ }
161
188
  if (!vs || !fs) return null;
162
189
  const program = gl.createProgram();
163
190
  if (!program) return null;
@@ -538,7 +565,7 @@ var webglRenderer = (options = {}) => ({
538
565
  bail("no-webgl");
539
566
  return;
540
567
  }
541
- program = createSurfaceProgram(handle.gl);
568
+ program = createSurfaceProgram(handle.gl, handle.highp);
542
569
  if (!program) {
543
570
  handle.destroy();
544
571
  handle = null;
@@ -598,10 +625,13 @@ var webglRenderer = (options = {}) => ({
598
625
  paint();
599
626
  const held = ctx.isDragging();
600
627
  bend *= held ? BEND_DECAY_HELD : BEND_DECAY_FREE;
601
- const settled = !held && !ctx.isAnimating() && Math.abs(bend) < BEND_REST;
602
- if (settled) {
628
+ const flat = Math.abs(bend) < BEND_REST;
629
+ if (!held && flat && capture) {
603
630
  bend = 0;
604
631
  releaseCapture();
632
+ }
633
+ if (!held && flat && !ctx.isAnimating()) {
634
+ bend = 0;
605
635
  paint();
606
636
  running = false;
607
637
  frameId = null;
package/dist/webgl.js CHANGED
@@ -1,10 +1,20 @@
1
1
  // src/webgl/gl-context.ts
2
+ var supportsHighpFragment = (gl) => {
3
+ try {
4
+ const fmt = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
5
+ return !!fmt && fmt.precision > 0;
6
+ } catch {
7
+ return false;
8
+ }
9
+ };
2
10
  var hasWebGL = () => {
3
11
  if (typeof document === "undefined") return false;
4
- if (typeof WebGLRenderingContext === "undefined") return false;
12
+ if (typeof WebGLRenderingContext === "undefined" && typeof WebGL2RenderingContext === "undefined") {
13
+ return false;
14
+ }
5
15
  try {
6
16
  const probe = document.createElement("canvas");
7
- const gl = probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
17
+ const gl = probe.getContext("webgl2", { alpha: true }) ?? probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
8
18
  if (!gl) return false;
9
19
  const lose = gl.getExtension(
10
20
  "WEBGL_lose_context"
@@ -23,18 +33,26 @@ var createGLHandle = (onLost) => {
23
33
  canvas.style.left = "0";
24
34
  canvas.style.top = "0";
25
35
  canvas.style.pointerEvents = "none";
36
+ const attrs = {
37
+ alpha: true,
38
+ premultipliedAlpha: true,
39
+ antialias: true,
40
+ depth: false,
41
+ stencil: false,
42
+ preserveDrawingBuffer: false
43
+ };
26
44
  let gl = null;
27
- try {
28
- gl = canvas.getContext("webgl", {
29
- alpha: true,
30
- premultipliedAlpha: true,
31
- antialias: true,
32
- depth: false,
33
- stencil: false,
34
- preserveDrawingBuffer: false
35
- });
36
- } catch {
37
- gl = null;
45
+ let isWebGL2 = false;
46
+ for (const id of ["webgl2", "webgl", "experimental-webgl"]) {
47
+ try {
48
+ const ctx = canvas.getContext(id, attrs);
49
+ if (ctx) {
50
+ gl = ctx;
51
+ isWebGL2 = id === "webgl2";
52
+ break;
53
+ }
54
+ } catch {
55
+ }
38
56
  }
39
57
  if (!gl) return null;
40
58
  const handleLost = (e) => {
@@ -45,6 +63,8 @@ var createGLHandle = (onLost) => {
45
63
  return {
46
64
  canvas,
47
65
  gl,
66
+ isWebGL2,
67
+ highp: isWebGL2 || supportsHighpFragment(gl),
48
68
  destroy: () => {
49
69
  canvas.removeEventListener("webglcontextlost", handleLost);
50
70
  const lose = gl?.getExtension("WEBGL_lose_context");
@@ -75,8 +95,8 @@ void main() {
75
95
  gl_Position = vec4(a_pos, 0.0, 1.0);
76
96
  }
77
97
  `;
78
- var FRAGMENT_SRC = `
79
- precision mediump float;
98
+ var FRAGMENT_SRC = (precision) => `
99
+ precision ${precision} float;
80
100
 
81
101
  uniform vec2 u_resolution;
82
102
  uniform vec4 u_rect;
@@ -153,9 +173,16 @@ var compile = (gl, type, src) => {
153
173
  }
154
174
  return shader;
155
175
  };
156
- var createSurfaceProgram = (gl) => {
176
+ var createSurfaceProgram = (gl, highp = true) => {
157
177
  const vs = compile(gl, gl.VERTEX_SHADER, VERTEX_SRC);
158
- const fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC);
178
+ let fs = compile(
179
+ gl,
180
+ gl.FRAGMENT_SHADER,
181
+ FRAGMENT_SRC(highp ? "highp" : "mediump")
182
+ );
183
+ if (!fs && highp) {
184
+ fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC("mediump"));
185
+ }
159
186
  if (!vs || !fs) return null;
160
187
  const program = gl.createProgram();
161
188
  if (!program) return null;
@@ -536,7 +563,7 @@ var webglRenderer = (options = {}) => ({
536
563
  bail("no-webgl");
537
564
  return;
538
565
  }
539
- program = createSurfaceProgram(handle.gl);
566
+ program = createSurfaceProgram(handle.gl, handle.highp);
540
567
  if (!program) {
541
568
  handle.destroy();
542
569
  handle = null;
@@ -596,10 +623,13 @@ var webglRenderer = (options = {}) => ({
596
623
  paint();
597
624
  const held = ctx.isDragging();
598
625
  bend *= held ? BEND_DECAY_HELD : BEND_DECAY_FREE;
599
- const settled = !held && !ctx.isAnimating() && Math.abs(bend) < BEND_REST;
600
- if (settled) {
626
+ const flat = Math.abs(bend) < BEND_REST;
627
+ if (!held && flat && capture) {
601
628
  bend = 0;
602
629
  releaseCapture();
630
+ }
631
+ if (!held && flat && !ctx.isAnimating()) {
632
+ bend = 0;
603
633
  paint();
604
634
  running = false;
605
635
  frameId = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surdeddd/bottom-sheet",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "Universal, headless bottom sheet — framework-agnostic core with React, Vue 3, Svelte, Solid, Qwik, Preact, Lit and Custom Element adapters. Pointer Events, snap points, momentum, a11y, SSR-safe.",
5
5
  "type": "module",
6
6
  "license": "MIT",