@occluze/umber 0.3.0 → 0.4.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.
Files changed (87) hide show
  1. package/README.md +93 -47
  2. package/THIRD-PARTY-NOTICES.md +33 -0
  3. package/dist/chunks/badge.js +2 -2
  4. package/dist/chunks/basis.js +2 -2
  5. package/dist/chunks/batches.js +2 -0
  6. package/dist/chunks/capture.js +2 -2
  7. package/dist/chunks/covers.js +2 -2
  8. package/dist/chunks/curves.js +2 -2
  9. package/dist/chunks/flip.js +2 -2
  10. package/dist/chunks/fx.js +2 -2
  11. package/dist/chunks/gl.js +2 -2
  12. package/dist/chunks/glsl.js +2 -2
  13. package/dist/chunks/glyphs.js +2 -0
  14. package/dist/chunks/inspect.js +2 -2
  15. package/dist/chunks/instances.js +2 -2
  16. package/dist/chunks/layers.js +2 -2
  17. package/dist/chunks/licence.js +2 -2
  18. package/dist/chunks/morph.js +2 -2
  19. package/dist/chunks/pace.js +2 -0
  20. package/dist/chunks/patch.js +2 -2
  21. package/dist/chunks/prepared.js +2 -2
  22. package/dist/chunks/profiler.js +2 -2
  23. package/dist/chunks/recheck.js +2 -0
  24. package/dist/chunks/resize.js +2 -0
  25. package/dist/chunks/restore.js +2 -2
  26. package/dist/chunks/shapes.js +2 -2
  27. package/dist/chunks/sim.js +2 -2
  28. package/dist/chunks/text.js +2 -2
  29. package/dist/chunks/video.js +2 -2
  30. package/dist/chunks/vocabulary.js +2 -2
  31. package/dist/chunks/warm.js +2 -2
  32. package/dist/modules/debug.js +2 -2
  33. package/dist/modules/debug.mjs +2 -2
  34. package/dist/modules/handoff.js +2 -2
  35. package/dist/modules/handoff.mjs +2 -2
  36. package/dist/modules/input.js +2 -2
  37. package/dist/modules/input.mjs +2 -2
  38. package/dist/modules/scrollfx.js +2 -2
  39. package/dist/modules/scrollfx.mjs +2 -2
  40. package/dist/modules/scrub.js +2 -2
  41. package/dist/modules/scrub.mjs +2 -2
  42. package/dist/modules/three.js +2 -2
  43. package/dist/modules/three.mjs +2 -2
  44. package/dist/node/assets.mjs +4 -2
  45. package/dist/node/astro.mjs +26 -18
  46. package/dist/node/cli.mjs +63 -10
  47. package/dist/node/shared-NFSQ5J4B.mjs +2116 -0
  48. package/dist/node/{shared-4FIU6DYP.mjs → shared-OUFNIXQ7.mjs} +106 -17
  49. package/dist/node/vite.mjs +7 -3
  50. package/dist/prepared.mjs +2 -0
  51. package/dist/umber.css +1 -1
  52. package/dist/umber.js +2 -2
  53. package/dist/umber.mjs +2 -2
  54. package/docs/AI-quick.md +43 -87
  55. package/docs/AI.md +1977 -1829
  56. package/docs/npm.md +13 -16
  57. package/package.json +32 -48
  58. package/types/assets.d.ts +109 -4
  59. package/types/astro.d.ts +20 -23
  60. package/types/debug.d.ts +1 -1
  61. package/types/esm.d.ts +2 -6
  62. package/types/input.d.ts +3 -3
  63. package/types/loop.d.ts +21 -9
  64. package/types/module.d.ts +0 -2
  65. package/types/scrollfx.d.ts +5 -41
  66. package/types/scrub.d.ts +2 -2
  67. package/types/three.d.ts +26 -1
  68. package/types/umber.d.ts +152 -155
  69. package/types/vite.d.ts +3 -3
  70. package/dist/chunks/views.js +0 -2
  71. package/dist/frameworks/astro.mjs +0 -2
  72. package/dist/frameworks/react.mjs +0 -2
  73. package/dist/frameworks/svelte.mjs +0 -2
  74. package/dist/frameworks/vue.mjs +0 -2
  75. package/dist/modules/router-swap.js +0 -2
  76. package/dist/modules/router.js +0 -2
  77. package/dist/modules/router.mjs +0 -2
  78. package/dist/modules/scroll-more.js +0 -2
  79. package/dist/modules/scroll-touch.js +0 -2
  80. package/dist/modules/scroll.js +0 -2
  81. package/dist/modules/scroll.mjs +0 -2
  82. package/dist/node/shared-3Q24RNIF.mjs +0 -602
  83. package/types/react.d.ts +0 -15
  84. package/types/router.d.ts +0 -223
  85. package/types/scroll.d.ts +0 -190
  86. package/types/svelte.d.ts +0 -16
  87. package/types/vue.d.ts +0 -14
package/README.md CHANGED
@@ -3,47 +3,101 @@
3
3
  <img src=".github/header-light.svg" alt="Umber" width="400">
4
4
  </picture>
5
5
 
6
- **A DOM-to-WebGL engine whose core works next to the libraries a site already uses and controls none of them. Its own scroll and router add-ons are there for a site that wants them.**
6
+ **Tag a DOM element and Umber draws it with WebGL, exactly on top of where it is in the page. One canvas for the whole site, the page stays a normal page, and Umber works beside the scroller, the router and the animation code the site already has.**
7
7
 
8
- [![version](https://img.shields.io/badge/version-0.3.0-D1D1D1?labelColor=000000)](CHANGELOG.md)
9
- [![size](https://img.shields.io/badge/umber.js%20%2B%20gl.js-56%20KB%20brotli-D1D1D1?labelColor=000000)](docs/architecture.md#size)
8
+ [![version](https://img.shields.io/badge/version-0.4.1-D1D1D1?labelColor=000000)](CHANGELOG.md)
9
+ [![size](https://img.shields.io/badge/umber.js%20%2B%20gl.js-55%20KB%20brotli-D1D1D1?labelColor=000000)](docs/architecture.md#size)
10
10
  [![WebGL2](https://img.shields.io/badge/GPU-WebGL2-D1D1D1?labelColor=000000)](docs/architecture.md#why-native-webgl2-instead-of-threejs)
11
11
  [![licence](https://img.shields.io/badge/licence-proprietary-D1D1D1?labelColor=000000)](docs/hosting.md)
12
12
 
13
- ## Install
13
+ ## What it is
14
14
 
15
- Script tag, for Webflow (Site settings → Custom code) or any page without a build step:
15
+ - **The link.** `data-umber="image"` on an element, and Umber draws that element on its one canvas, in step with the page while it scrolls, resizes and changes. Images, video, text, shader surfaces and three.js scenes share that canvas, so any of them can take an effect.
16
+ - **The page stays the page.** The real `<img>`, `<video>` and text stay in the DOM for search engines, screen readers and layout, and the page scrolls natively. Where WebGL can't run, the plain page shows.
17
+ - **Beside what the site uses.** Umber has no scroller and no router of its own, and no code for any library by name. Set yours up as their own docs say; Umber reads where the page is and sees a new page arrive in the DOM.
18
+ - **The build tool.** One plugin does the heavy work when the site is built: pictures as GPU-ready files, text painted from the font's outlines, Umber's own files served from your site and named in each page's `<head>`.
19
+ - **An engine, not an effects library.** Umber ships no effects. An effect is a few lines of GLSL in named slots that you write with `umber.effect()`; the [examples](examples/) show how.
16
20
 
17
- <!-- snippet:readme -->
21
+ ## A first drawn element
22
+
23
+ ### With a script tag
24
+
25
+ A whole page. Save it next to a `photo.jpg`, open it from a local server, and the picture fades in as WebGL:
26
+
27
+ <!-- snippet:first -->
18
28
  ```html
19
- <!-- In <head> -->
20
- <link rel="stylesheet" href="https://umber.occluze.com/umber@0.3.0/umber.css">
21
-
22
- <!-- Before </body>: data-umber-key is your public key (occluze.com/dashboard?view=umber); data-umber-modules names the add-ons to load (scroll, router, handoff, scrub, input, debug) -->
23
- <script src="https://umber.occluze.com/umber@0.3.0/umber.js" data-umber-key="YOUR_KEY" data-umber-modules="scroll router"></script>
24
- <script>
25
- const umber = Umber.createUmber();
26
- </script>
29
+ <!doctype html>
30
+ <html lang="en">
31
+ <head>
32
+ <meta charset="utf-8">
33
+ <meta name="viewport" content="width=device-width, initial-scale=1">
34
+ <title>A first element</title>
35
+ <link rel="stylesheet" href="https://umber.occluze.com/umber@0.4.1/umber.css">
36
+ </head>
37
+ <body>
38
+ <!-- A normal image, tagged. It stays in the page; Umber draws it on its canvas and fades it in. -->
39
+ <div data-umber="image" data-umber-effect="fade" style="max-width: 600px">
40
+ <img src="photo.jpg" alt="Describe the photo" width="1200" height="800" style="width: 100%; height: auto">
41
+ </div>
42
+
43
+ <!-- localhost needs no key; a live site adds data-umber-key="YOUR_KEY" to this tag (docs/hosting.md) -->
44
+ <script src="https://umber.occluze.com/umber@0.4.1/umber.js"></script>
45
+ <script>
46
+ const umber = Umber.createUmber();
47
+ // An effect is yours to write: a name, and a few lines of GLSL in named slots.
48
+ umber.effect("fade", { play: "uShow", uniforms: { uShow: 0 }, fragment: { alpha: "alpha *= uShow;" } });
49
+ </script>
50
+ </body>
51
+ </html>
27
52
  ```
28
53
  <!-- /snippet -->
29
54
 
30
- Runs in Chrome and Edge 92+, Firefox 101+ and Safari 16.4+, with WebGL2 ([browsers, and a Content Security Policy](docs/hosting.md#browsers)).
55
+ Webflow takes the same three parts: the stylesheet in **Site settings > Custom code > Head code**, the two scripts in **Footer code**, and `data-umber` = `image`, `data-umber-effect` = `fade` as Custom attributes on the image.
56
+
57
+ ### With a bundler and the build tool
58
+
59
+ ```bash
60
+ npm install --save-exact @occluze/umber
61
+ ```
62
+
63
+ Add the build tool to the config, one line:
64
+
65
+ ```js
66
+ // vite.config.js
67
+ import umberAssets from "@occluze/umber/vite";
68
+ export default { plugins: [umberAssets()] };
69
+ ```
31
70
 
32
- npm, for Astro, Vite or another bundler (TypeScript types included):
71
+ ```js
72
+ // astro.config.mjs
73
+ import { defineConfig } from "astro/config";
74
+ import umberAstro from "@occluze/umber/astro";
75
+ export default defineConfig({ integrations: [umberAstro()] });
76
+ ```
77
+
78
+ Start the engine once, in code that runs in the browser, and tag an element as above:
33
79
 
34
80
  <!-- snippet:npm -->
35
81
  ```js
36
- // npm install @occluze/umber@0.3.0 (docs/npm.md)
82
+ // npm install --save-exact @occluze/umber@0.4.1
37
83
  import { createUmber } from "@occluze/umber";
38
84
  import "@occluze/umber/umber.css";
39
- import { Scroll } from "@occluze/umber/scroll"; // smooth scrolling, on Umber's clock
40
- import { Router } from "@occluze/umber/router"; // page transitions without a reload
41
85
 
42
- const umber = createUmber({ key: "YOUR_KEY", modules: [Scroll, Router] }); // client code only; on the server it does nothing
86
+ const umber = createUmber({ key: "YOUR_KEY" }); // browser code only; on a server it does nothing
87
+ // An effect is yours to write: a name, and a few lines of GLSL in named slots.
88
+ umber.effect("fade", { play: "uShow", uniforms: { uShow: 0 }, fragment: { alpha: "alpha *= uShow;" } });
43
89
  ```
44
90
  <!-- /snippet -->
45
91
 
46
- ## Quick start
92
+ ```html
93
+ <div data-umber="image" data-umber-effect="fade"><img src="/photo.jpg" alt="Describe the photo"></div>
94
+ ```
95
+
96
+ Any other build runs the tool on its output folder: `npx umber assets dist`.
97
+
98
+ Umber runs in Chrome and Edge 92+, Firefox 101+ and Safari 16.4+, with WebGL2 ([browsers, and a Content Security Policy](docs/hosting.md#browsers)). Your own computer needs no key. A live site adds its account's public key (`data-umber-key="YOUR_KEY"` on the tag, or `createUmber({ key })`), from [occluze.com/dashboard?view=umber](https://occluze.com/dashboard?view=umber); until the site is on the account it runs with a small Occluze badge ([hosting and the licence](docs/hosting.md)).
99
+
100
+ ## What an element says
47
101
 
48
102
  An element says **what it is, how it behaves, and what it's set to**: `data-umber` holds what it is (one kind) and how it behaves (any number of behaviours), and each setting is an attribute of its own, `data-umber-<setting>`. These are all the words:
49
103
 
@@ -53,42 +107,34 @@ An element says **what it is, how it behaves, and what it's set to**: `data-umbe
53
107
  | `shader`, `layer` | kind | A surface drawn by `umber.shader()` or `umber.layer()` (named by `data-umber-shader` / `data-umber-layer`). | |
54
108
  | `model` | kind | A glTF model (`data-umber-src="x.glb"`) fitted to the box. | `three` |
55
109
  | `group` | kind | Draws the planes inside it as one, through its own effect. | |
56
- | `container`, `wrapper` | kind | The part of each page the router swaps, and the element around it. | `router` |
57
110
  | `scroller` | kind | The element that scrolls instead of the window. | |
58
111
  | `above` | behaviour | Keeps it above the canvas. | |
59
112
  | `pin`, `horizontal`, `inview` | behaviour | Sticks while its parent scrolls past; slides its track sideways; a class while on screen. | `scrollfx` |
60
- | `skip` | behaviour | The router leaves that link (or script) alone. | `router` |
61
- | `nested` | behaviour | It scrolls smoothly by itself. | `scroll` |
62
113
 
63
- Tag an element; Umber draws it on the GPU with an effect you write with `umber.effect()`:
114
+ "Needs" names an add-on: `data-umber-modules="scrollfx"` on the `umber.js` tag, or an import with npm ([npm](docs/npm.md)).
64
115
 
65
- ```html
66
- <!-- The site's own "dissolve" effect (examples/effects/dissolve.js is one). Still real HTML for Google. -->
67
- <div data-umber="image" data-umber-effect="dissolve">
68
- <img src="photo.jpg" alt="Describe the photo" />
69
- </div>
70
- ```
116
+ ## Guides
71
117
 
72
- Put your account's public key from [occluze.com/dashboard?view=umber](https://occluze.com/dashboard?view=umber) in the install code and publish. While your account is on Approve automatically (the first 30 minutes after buying, or 30 minutes whenever you switch it on in the dashboard) it joins your domains and runs on the next refresh; on Block all, nothing new gets in. Umber is sold per account: 25 domains, 25 more at a time, every update. Your own computer and network need no key ([hosting](docs/hosting.md)).
118
+ Start here:
73
119
 
74
- ## Pictures ready at build time
120
+ - [Getting started](docs/getting-started.md): the first element step by step, then the next things to mark.
121
+ - [Setups](docs/setups.md): starters to copy for Webflow, plain HTML, Astro and Vite.
122
+ - [Examples](examples/): one view-source HTML page per technique, each writing the effects it shows.
75
123
 
76
- Umber's asset tool makes the pictures Umber draws GPU-ready when you build the site: compressed textures (BC1 or BC7, ASTC, ETC2) with all their mip levels, and an AVIF. The browser fetches the one file its GPU draws, only up to the size it shows it at, and uploads it as it is: nothing to decode, about a third of the GPU memory, and fewer bytes than before: by default each `<img>` shows a small placeholder while GL loads, so a visitor whose GPU draws the picture downloads that and the GPU file, never the full image too, and the full AVIF appears wherever GL won't draw it (`domImages: "avif"` turns the placeholder off). Your `<img src>` stays your original file ([how](docs/ai/assets.md)). The same plugins put Umber's chunks in the built site, so it loads no Umber code from another origin and passes a strict `script-src 'self'` ([CSP](docs/hosting.md#content-security-policy)).
124
+ One page per subject:
77
125
 
78
- ```js
79
- import umberAstro from "@occluze/umber/astro"; // Astro: integrations: [umberAstro()]
80
- import umberAssets from "@occluze/umber/vite"; // Vite: plugins: [umberAssets()]
81
- // Anything else, after the build: npx umber assets dist
82
- ```
126
+ - [Bring your own scroller](docs/ai/scrollers.md): what a smooth scroller needs to do to fit, and the optional one clock for the page.
127
+ - [Bring your own router](docs/ai/routers.md): page changes without a reload, and the optional calls that time them.
128
+ - [The build tool](docs/ai/assets.md): what it prepares, the Vite and Astro entry points, the command line.
129
+ - [Text](docs/ai/text.md): text painted from the font's outlines, one quad per letter, what falls back to the DOM.
130
+ - [Effects and shaders](docs/ai/effects.md): the vertex and fragment slots, every input and helper.
131
+ - [Performance](docs/ai/performance.md): what costs, how to pause what can't be seen, what the warnings on localhost mean.
132
+ - [Hosting and the licence](docs/hosting.md): versions, what a visitor sees with and without a licence, Content Security Policy.
133
+
134
+ The whole reference:
83
135
 
84
- ## Docs
85
- - [Getting started](docs/getting-started.md): what Umber is, and a Webflow or HTML site in four steps, with or without the site's own router and smooth scrolling
86
- - [AI-quick.md](docs/AI-quick.md) and [AI.md](docs/AI.md): the short guide for a simple site, and the full reference; paste either into any AI assistant
87
- - [Setups](docs/setups.md): copy-paste starters for Webflow, plain HTML with Barba + Lenis, Astro / Vite
88
- - [Examples](examples/): one view-source HTML page per technique, each writing the effects it shows
89
- - [npm](docs/npm.md), [hosting and versions](docs/hosting.md), [architecture](docs/architecture.md)
90
- - [Development](docs/development.md): the commands, the checks and what each file in the root is for
91
- - [Changelog](CHANGELOG.md)
136
+ - [AI.md](docs/AI.md) is every page above and the rest of the API in one file, written to paste into an AI assistant; [AI-quick.md](docs/AI-quick.md) is the short one for a simple site.
137
+ - [npm](docs/npm.md), [architecture](docs/architecture.md), [development](docs/development.md) (the commands and checks of this repository), [changelog](CHANGELOG.md).
92
138
 
93
139
  ## Licence
94
140
 
@@ -0,0 +1,33 @@
1
+ # Third-party notices
2
+
3
+ Umber includes code from the works below. Each is used under its own licence, which is given here in full.
4
+
5
+ ## dom-gpu-text
6
+
7
+ The exact-area glyph coverage in `dist/chunks/curves.js` (source: `src/gl/curves/glsl.ts`) is
8
+ ported from the reference implementation of dom-gpu-text.
9
+
10
+ MIT License
11
+
12
+ Copyright (c) 2026 Jesper Landberg
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+
32
+ The band index and the two-ray coverage that Umber's curve text and that work both use follow Eric Lengyel's
33
+ Slug algorithm (Journal of Computer Graphics Techniques, 2017).
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- var C="M697.239 167.222C704.712 155.597 712.185 153.937 722.979 162.24C728.791 167.222 734.604 173.034 740.416 178.016C747.889 186.319 756.192 193.792 764.495 201.265C767.816 203.756 771.138 206.247 775.289 207.907C791.896 217.871 816.805 204.586 819.296 185.489C819.296 184.658 819.296 182.998 819.296 181.337C818.466 173.864 812.654 169.713 805.181 171.373C802.69 172.204 799.369 173.034 796.878 175.525C790.235 180.507 785.253 178.846 779.441 173.864C763.665 160.579 748.719 146.464 739.586 128.197C737.925 124.045 735.434 120.724 733.773 117.402C726.3 105.778 717.997 104.117 705.542 111.59C699.73 115.742 695.578 120.724 690.597 124.875C683.124 132.348 679.802 133.178 670.669 128.197C661.535 124.045 652.402 118.233 644.929 112.42C640.777 109.099 636.626 105.778 634.965 99.9656C632.474 92.4927 635.795 88.3411 644.099 88.3411C647.42 88.3411 650.741 89.1714 654.062 90.0018C661.535 91.6624 668.178 93.3231 675.651 95.814C693.088 99.9656 709.694 98.305 726.3 89.1714C734.604 84.1895 742.907 79.2076 751.21 73.3953C758.683 67.5831 766.156 61.7708 773.629 56.7889C781.932 50.9767 791.065 45.9947 801.029 43.5038C810.993 40.1825 820.957 39.3522 829.26 46.825C831.751 49.316 835.903 50.9767 839.224 48.4857C842.545 45.1644 842.545 41.8431 840.885 37.6915C840.054 36.8612 840.054 36.0309 839.224 34.3702C830.091 19.4244 817.636 8.63026 801.029 1.98769C792.726 -0.503277 784.423 -0.503277 776.12 1.15737C764.495 3.64833 753.701 8.63026 744.568 16.9335C734.604 26.067 725.47 35.2005 715.506 44.3341C702.221 56.7889 688.106 60.9405 670.669 55.9586C666.517 54.2979 662.366 53.4676 659.044 52.6373C635.795 45.1644 612.546 45.9947 589.297 53.4676C580.164 55.9586 571.03 57.6192 561.066 57.6192C541.969 58.4495 522.041 60.1102 502.944 62.6012C492.15 64.2618 482.186 66.7528 471.392 66.7528C430.706 65.0921 392.511 57.6192 355.147 41.8431C348.504 39.3522 341.862 37.6915 336.049 32.7096C332.728 30.2186 328.576 29.3883 324.425 28.558C313.631 26.8973 302.836 25.2367 292.873 21.0851C289.551 20.2548 287.06 19.4244 287.06 15.2728C286.23 5.30897 281.248 3.64833 273.775 9.46058C267.963 13.6122 262.981 17.7638 257.169 21.0851C253.847 23.576 249.696 25.2367 245.544 25.2367C237.241 24.4064 235.58 22.7457 236.411 14.4425C237.241 2.81801 230.598 -1.3336 219.804 3.64833C213.992 6.1393 209.01 9.46058 204.028 13.6122C188.252 24.4064 171.646 31.8793 153.379 33.5399C145.075 34.3702 137.603 32.7096 129.299 32.7096C120.166 32.7096 113.523 36.0309 111.032 44.3341C106.05 60.1102 95.2561 69.2437 81.1406 76.7166C76.1587 79.2076 71.1768 80.8682 67.0252 83.3592C57.0613 89.1714 55.4007 96.6443 62.0433 104.948C63.7039 106.608 65.3645 108.269 67.0252 109.929C73.6678 116.572 78.6497 117.402 86.1226 112.42C90.2742 109.929 94.4258 106.608 98.5774 103.287C108.541 94.1534 120.166 89.1714 133.451 92.4927C148.397 95.814 160.021 90.0018 170.815 80.8682C174.137 78.3773 177.458 75.8863 180.779 73.3953C189.913 66.7528 199.877 65.9224 210.671 68.4134C224.786 71.7347 238.071 77.5469 251.357 84.1895C258.829 88.3411 262.981 94.9837 265.472 103.287C267.133 109.099 267.133 114.911 266.302 120.724C264.642 136.5 253.847 145.633 238.071 146.464C229.768 146.464 221.465 143.142 213.162 139.821C205.689 135.669 199.046 131.518 191.573 128.197C174.967 119.893 160.021 121.554 145.075 133.178C130.13 145.633 113.523 154.767 95.2561 162.24C83.6316 167.222 72.0071 173.034 61.2129 180.507C52.9097 185.489 47.0975 192.131 43.7762 200.435C41.2852 207.907 39.6246 214.55 42.9459 221.193C44.6065 227.835 50.4188 230.326 56.231 227.835C60.3826 227.005 63.7039 224.514 67.0252 222.853C94.4258 202.926 125.148 187.98 154.209 169.713C155.87 168.052 158.361 167.222 160.852 166.391C174.967 158.918 189.082 158.918 203.198 166.391C211.501 169.713 218.974 174.695 227.277 178.846C238.071 184.658 249.696 190.471 262.151 193.792C275.436 196.283 287.891 195.453 297.855 185.489C299.515 183.828 301.176 182.998 302.836 182.167C320.273 171.373 338.54 165.561 358.468 173.864C363.45 175.525 368.432 178.016 373.414 179.676C391.681 187.149 410.778 190.471 429.876 189.64C456.446 187.98 478.034 176.355 497.962 160.579C505.435 154.767 512.077 148.124 519.55 142.312C525.363 136.5 532.836 133.178 541.139 130.688C555.254 127.366 567.709 131.518 580.164 138.991C595.11 148.124 608.395 159.749 620.85 172.204C626.662 178.016 633.304 184.658 639.947 189.64C661.535 207.077 678.142 203.756 691.427 178.846C693.088 174.695 694.748 170.543 697.239 167.222ZM194.064 171.373C170.815 179.676 148.397 191.301 126.808 204.586C108.541 216.211 90.2742 226.174 71.1768 236.138C62.8736 240.29 55.4007 241.12 46.2671 236.969C37.9639 233.647 28.8304 231.156 18.8665 231.156C17.2059 231.156 15.5453 231.156 14.7149 231.156C0.599465 232.817 -3.55214 241.12 3.09043 252.745C4.75107 256.896 8.07236 260.218 10.5633 263.539C20.5272 273.503 31.3214 275.163 43.7762 269.351C48.7581 266.86 54.5704 263.539 59.5523 261.048C105.22 235.308 152.548 214.55 201.537 197.944C204.859 197.113 208.18 195.453 211.501 193.792C218.144 189.64 219.804 182.998 214.822 177.186C209.84 170.543 202.368 168.052 194.064 171.373ZM831.751 229.496C828.43 228.665 825.109 227.835 820.957 227.835C815.975 227.005 810.993 227.005 806.011 227.835C796.878 227.835 788.575 226.174 781.102 222.853C766.156 216.211 754.531 207.077 742.907 196.283C737.095 191.301 732.113 185.489 726.3 180.507C717.997 173.864 712.185 173.034 703.051 178.016C698.069 181.337 693.918 185.489 688.936 188.81C682.293 193.792 684.784 200.435 690.597 202.095C710.524 208.738 727.131 220.362 743.737 231.987C751.21 236.969 757.022 242.781 763.665 246.933C773.629 254.405 784.423 257.727 797.708 257.727C807.672 257.727 819.296 254.405 830.091 250.254C831.751 250.254 833.412 249.424 834.242 248.593C837.563 246.102 840.885 242.781 840.054 237.799C839.224 233.647 835.903 230.326 831.751 229.496Z",e="http://www.w3.org/2000/svg";function t(){let t=()=>{if(document.querySelector("[data-occluze-badge]"))return;let t=document.createElement("a");t.href="https://occluze.com",t.target="_blank",t.rel="noopener",t.setAttribute("data-occluze-badge",""),Object.assign(t.style,{position:"fixed",right:"12px",bottom:"12px",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"7px",padding:"5px 10px",borderRadius:"6px",background:"#e73e2e",color:"#000",font:"500 12px/1.4 system-ui, sans-serif",textDecoration:"none"});let n=document.createElementNS(e,"svg");n.setAttribute("viewBox","0 0 842 273"),n.setAttribute("width","40"),n.setAttribute("height","13"),n.setAttribute("fill","#000"),n.setAttribute("aria-hidden","true");let a=document.createElementNS(e,"path");a.setAttribute("d",C),n.append(a),t.append(n,"Occluze"),document.body.append(t)};document.readyState==="loading"?addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{t as showBadge};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e=[60,16],t=.9,r=4,n=5e3;function i(){if(document.fullscreenElement)return!0;try{return!!document.querySelector("dialog:modal")}catch{return!1}}function o(e,t){try{return e.matches(t)}catch{return!1}}var a=e=>o(e,":popover-open"),l=()=>document.body??document.documentElement;function s(r){let n=r.getBoundingClientRect();if(n.width<e[0]||n.height<e[1])return!0;let i=1;for(let e=r;e;e=a(r)?null:e.parentElement)i*=Number(getComputedStyle(e).opacity||1);if(i<t)return!0;let o=n.top+n.height/2;return[.15,.5,.85].some(e=>!r.contains(document.elementFromPoint(n.left+n.width*e,o)))}function d(e){let t=!1,r=typeof IntersectionObserver>"u"?null:new IntersectionObserver(e=>{let r=e[e.length-1];t=!!r&&r.isIntersecting&&r.isVisible===!1},{threshold:1,trackVisibility:!0,delay:100});return r?.observe(e),{covered:()=>t,stop:()=>r?.disconnect()}}function c(e,t){let r=0,n=!1;for(let i of e)r+=i.removedNodes.length,i.removedNodes.length===1&&i.removedNodes[0]===t&&(n=!0);return n&&r===1}function u(){let e=0,t=0;return()=>{let i=Date.now();return i-t>n&&(e=0,t=i),++e>r}}var C="Umber: the Occluze badge was removed or hidden on this page, so Umber has stopped and the page shows without GL. The free version of Umber shows the badge; a site on a licence runs without it: https://occluze.com/dashboard?view=umber";function h(e,t,r){let n=0,o=0,a=u(),h=d(e),f=new MutationObserver(b),m=setInterval(T,3e3);return p(),g;function p(){l().append(e),t.dress(),f.disconnect(),f.observe(e,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),f.observe(l(),{childList:!0}),f.observe(document.documentElement,{childList:!0}),f.takeRecords()}function g(){f.disconnect(),h.stop(),clearInterval(m)}function E(){g(),console.warn(C),r()}function v(e){(!e||a())&&n++,n>2?E():p()}function x(){return e.isConnected&&e.parentNode===l()}function b(r){x()?t.intact()||v(!1):v(!c(r,e))}function T(){if(document.visibilityState==="visible"){if(!x()||!t.intact()){v(!1);return}if(!i()){if(!h.covered()&&!s(e)){o=Math.max(0,o-1);return}o+=2,o>=8?E():p()}}}}var f=[10,5],m=7,p=[40,13],g=12,E=1.4,v=`#version 300 es\nuniform vec4 uBox;\nout vec2 vUv;\nvoid main() {\n vec2 corner = vec2(gl_VertexID & 1, gl_VertexID >> 1);\n vUv = vec2(corner.x, 1.0 - corner.y);\n gl_Position = vec4(mix(uBox.xy, uBox.zw, corner), 0.0, 1.0);\n}`,x=`#version 300 es\nprecision mediump float;\nuniform sampler2D uMark;\nin vec2 vUv;\nout vec4 color;\nvoid main() {\n color = vec4(texture(uMark, vUv).rgb, 1.0);\n}`;function b(e){let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return null;let n=`500 ${g*2}px system-ui, sans-serif`;r.font=n;let i=f[0]*2+p[0]+m+Math.ceil(r.measureText(e.word).width/2),o=Math.ceil(f[1]*2+g*E);return t.width=i*2,t.height=o*2,r.fillStyle="#e73e2e",r.fillRect(0,0,t.width,t.height),r.fillStyle="#000",r.font=n,r.textBaseline="middle",r.fillText(e.word,(f[0]+p[0]+m)*2,o/2*2),r.translate(f[0]*2,(o-p[1])/2*2),r.scale(p[0]*2/e.box[0],p[1]*2/e.box[1]),r.fill(new Path2D(e.path)),{canvas:t,width:i,height:o}}function T(e,t,r){let n=e.createShader(t);return n?(e.shaderSource(n,r),e.compileShader(n),n):null}function _(e,t){let r=b(t),n=e.createProgram(),i=T(e,e.VERTEX_SHADER,v),o=T(e,e.FRAGMENT_SHADER,x),a=e.createTexture(),l=e.createVertexArray();if(!r||!i||!o||(e.attachShader(n,i),e.attachShader(n,o),e.linkProgram(n),!e.getProgramParameter(n,e.LINK_STATUS)))return null;let s=e.getParameter(e.TEXTURE_BINDING_2D),d=e.getParameter(e.UNPACK_FLIP_Y_WEBGL),c=e.getParameter(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL);return e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r.canvas),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,d),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,c),{gl:e,program:n,texture:a,quad:l,box:e.getUniformLocation(n,"uBox"),sampler:e.getUniformLocation(n,"uMark"),width:r.width,height:r.height}}var w=[2929,2960,2884,3089,3042],P=w.map(()=>!1);function R(e,t,r){let{gl:n}=e,i=n.getParameter(n.CURRENT_PROGRAM),o=n.getParameter(n.ACTIVE_TEXTURE)-n.TEXTURE0,a=n.getParameter(n.TEXTURE_BINDING_2D),l=n.getParameter(n.FRAMEBUFFER_BINDING);l&&n.bindFramebuffer(n.FRAMEBUFFER,null);for(let e=0;e<w.length;e++){let t=w[e];t!==void 0&&(P[e]=n.isEnabled(t),P[e]&&n.disable(t))}n.viewport(0,0,n.drawingBufferWidth,n.drawingBufferHeight),n.useProgram(e.program),n.bindTexture(n.TEXTURE_2D,e.texture),n.uniform1i(e.sampler,o),n.uniform4f(e.box,1-2*(12+e.width)/t,-1+24/r,1-24/t,-1+2*(12+e.height)/r),n.bindVertexArray(e.quad),n.drawArrays(n.TRIANGLE_STRIP,0,4),n.bindVertexArray(null),n.bindTexture(n.TEXTURE_2D,a),n.useProgram(i);for(let e=0;e<w.length;e++){let t=w[e];t!==void 0&&P[e]&&n.enable(t)}l&&n.bindFramebuffer(n.FRAMEBUFFER,l)}function A(e,t){let r=null,n=null,i=null,o=0,a=[0,0],l=[0,0],s=!0,d=()=>{s=!0};addEventListener("resize",d);let c=e.on("frame",()=>{let d=e.context,c=e.canvas,u=e.info.renders;if(!(!d||!c||u===void 0)){if(d!==i){i=d,o=u,e.wake(1);return}if(u!==o&&(o=u,!(d.isContextLost()||d===n))){if(r&&(r.gl!==d||!d.isProgram(r.program))&&(r=null),r??=_(d,t),!r){n=d;return}(s||l[0]!==d.drawingBufferWidth||l[1]!==d.drawingBufferHeight)&&(s=!1,l=[d.drawingBufferWidth,d.drawingBufferHeight],a=[c.clientWidth,c.clientHeight]),a[0]&&a[1]&&R(r,a[0],a[1])}}},{always:!1,phase:"render",order:1e6});return e.wake(1),()=>{c(),removeEventListener("resize",d)}}var U="M697.239 167.222C704.712 155.597 712.185 153.937 722.979 162.24C728.791 167.222 734.604 173.034 740.416 178.016C747.889 186.319 756.192 193.792 764.495 201.265C767.816 203.756 771.138 206.247 775.289 207.907C791.896 217.871 816.805 204.586 819.296 185.489C819.296 184.658 819.296 182.998 819.296 181.337C818.466 173.864 812.654 169.713 805.181 171.373C802.69 172.204 799.369 173.034 796.878 175.525C790.235 180.507 785.253 178.846 779.441 173.864C763.665 160.579 748.719 146.464 739.586 128.197C737.925 124.045 735.434 120.724 733.773 117.402C726.3 105.778 717.997 104.117 705.542 111.59C699.73 115.742 695.578 120.724 690.597 124.875C683.124 132.348 679.802 133.178 670.669 128.197C661.535 124.045 652.402 118.233 644.929 112.42C640.777 109.099 636.626 105.778 634.965 99.9656C632.474 92.4927 635.795 88.3411 644.099 88.3411C647.42 88.3411 650.741 89.1714 654.062 90.0018C661.535 91.6624 668.178 93.3231 675.651 95.814C693.088 99.9656 709.694 98.305 726.3 89.1714C734.604 84.1895 742.907 79.2076 751.21 73.3953C758.683 67.5831 766.156 61.7708 773.629 56.7889C781.932 50.9767 791.065 45.9947 801.029 43.5038C810.993 40.1825 820.957 39.3522 829.26 46.825C831.751 49.316 835.903 50.9767 839.224 48.4857C842.545 45.1644 842.545 41.8431 840.885 37.6915C840.054 36.8612 840.054 36.0309 839.224 34.3702C830.091 19.4244 817.636 8.63026 801.029 1.98769C792.726 -0.503277 784.423 -0.503277 776.12 1.15737C764.495 3.64833 753.701 8.63026 744.568 16.9335C734.604 26.067 725.47 35.2005 715.506 44.3341C702.221 56.7889 688.106 60.9405 670.669 55.9586C666.517 54.2979 662.366 53.4676 659.044 52.6373C635.795 45.1644 612.546 45.9947 589.297 53.4676C580.164 55.9586 571.03 57.6192 561.066 57.6192C541.969 58.4495 522.041 60.1102 502.944 62.6012C492.15 64.2618 482.186 66.7528 471.392 66.7528C430.706 65.0921 392.511 57.6192 355.147 41.8431C348.504 39.3522 341.862 37.6915 336.049 32.7096C332.728 30.2186 328.576 29.3883 324.425 28.558C313.631 26.8973 302.836 25.2367 292.873 21.0851C289.551 20.2548 287.06 19.4244 287.06 15.2728C286.23 5.30897 281.248 3.64833 273.775 9.46058C267.963 13.6122 262.981 17.7638 257.169 21.0851C253.847 23.576 249.696 25.2367 245.544 25.2367C237.241 24.4064 235.58 22.7457 236.411 14.4425C237.241 2.81801 230.598 -1.3336 219.804 3.64833C213.992 6.1393 209.01 9.46058 204.028 13.6122C188.252 24.4064 171.646 31.8793 153.379 33.5399C145.075 34.3702 137.603 32.7096 129.299 32.7096C120.166 32.7096 113.523 36.0309 111.032 44.3341C106.05 60.1102 95.2561 69.2437 81.1406 76.7166C76.1587 79.2076 71.1768 80.8682 67.0252 83.3592C57.0613 89.1714 55.4007 96.6443 62.0433 104.948C63.7039 106.608 65.3645 108.269 67.0252 109.929C73.6678 116.572 78.6497 117.402 86.1226 112.42C90.2742 109.929 94.4258 106.608 98.5774 103.287C108.541 94.1534 120.166 89.1714 133.451 92.4927C148.397 95.814 160.021 90.0018 170.815 80.8682C174.137 78.3773 177.458 75.8863 180.779 73.3953C189.913 66.7528 199.877 65.9224 210.671 68.4134C224.786 71.7347 238.071 77.5469 251.357 84.1895C258.829 88.3411 262.981 94.9837 265.472 103.287C267.133 109.099 267.133 114.911 266.302 120.724C264.642 136.5 253.847 145.633 238.071 146.464C229.768 146.464 221.465 143.142 213.162 139.821C205.689 135.669 199.046 131.518 191.573 128.197C174.967 119.893 160.021 121.554 145.075 133.178C130.13 145.633 113.523 154.767 95.2561 162.24C83.6316 167.222 72.0071 173.034 61.2129 180.507C52.9097 185.489 47.0975 192.131 43.7762 200.435C41.2852 207.907 39.6246 214.55 42.9459 221.193C44.6065 227.835 50.4188 230.326 56.231 227.835C60.3826 227.005 63.7039 224.514 67.0252 222.853C94.4258 202.926 125.148 187.98 154.209 169.713C155.87 168.052 158.361 167.222 160.852 166.391C174.967 158.918 189.082 158.918 203.198 166.391C211.501 169.713 218.974 174.695 227.277 178.846C238.071 184.658 249.696 190.471 262.151 193.792C275.436 196.283 287.891 195.453 297.855 185.489C299.515 183.828 301.176 182.998 302.836 182.167C320.273 171.373 338.54 165.561 358.468 173.864C363.45 175.525 368.432 178.016 373.414 179.676C391.681 187.149 410.778 190.471 429.876 189.64C456.446 187.98 478.034 176.355 497.962 160.579C505.435 154.767 512.077 148.124 519.55 142.312C525.363 136.5 532.836 133.178 541.139 130.688C555.254 127.366 567.709 131.518 580.164 138.991C595.11 148.124 608.395 159.749 620.85 172.204C626.662 178.016 633.304 184.658 639.947 189.64C661.535 207.077 678.142 203.756 691.427 178.846C693.088 174.695 694.748 170.543 697.239 167.222ZM194.064 171.373C170.815 179.676 148.397 191.301 126.808 204.586C108.541 216.211 90.2742 226.174 71.1768 236.138C62.8736 240.29 55.4007 241.12 46.2671 236.969C37.9639 233.647 28.8304 231.156 18.8665 231.156C17.2059 231.156 15.5453 231.156 14.7149 231.156C0.599465 232.817 -3.55214 241.12 3.09043 252.745C4.75107 256.896 8.07236 260.218 10.5633 263.539C20.5272 273.503 31.3214 275.163 43.7762 269.351C48.7581 266.86 54.5704 263.539 59.5523 261.048C105.22 235.308 152.548 214.55 201.537 197.944C204.859 197.113 208.18 195.453 211.501 193.792C218.144 189.64 219.804 182.998 214.822 177.186C209.84 170.543 202.368 168.052 194.064 171.373ZM831.751 229.496C828.43 228.665 825.109 227.835 820.957 227.835C815.975 227.005 810.993 227.005 806.011 227.835C796.878 227.835 788.575 226.174 781.102 222.853C766.156 216.211 754.531 207.077 742.907 196.283C737.095 191.301 732.113 185.489 726.3 180.507C717.997 173.864 712.185 173.034 703.051 178.016C698.069 181.337 693.918 185.489 688.936 188.81C682.293 193.792 684.784 200.435 690.597 202.095C710.524 208.738 727.131 220.362 743.737 231.987C751.21 236.969 757.022 242.781 763.665 246.933C773.629 254.405 784.423 257.727 797.708 257.727C807.672 257.727 819.296 254.405 830.091 250.254C831.751 250.254 833.412 249.424 834.242 248.593C837.563 246.102 840.885 242.781 840.054 237.799C839.224 233.647 835.903 230.326 831.751 229.496Z",L=[842,273];var y="https://occluze.com/umber",N="Occluze",I="Made with Umber by Occluze",B="http://www.w3.org/2000/svg",D=e=>e.replace(/;/g,"!important;"),M=D("all:initial;position:fixed;right:12px;bottom:12px;z-index:2147483647;display:flex;align-items:center;gap:7px;padding:5px 10px;border-radius:6px;background:#e73e2e;color:#000;font:500 12px/1.4 system-ui,sans-serif;text-decoration:none;white-space:nowrap;cursor:pointer;"),S=D("outline:2px solid #000;outline-offset:2px;"),G=D("all:initial;display:block;flex:none;width:40px;height:13px;fill:#000;"),F=D("display:inline;visibility:visible;opacity:1;fill:#000;"),X=e=>"showPopover"in e;function k(){let e=document.createElementNS(B,"svg");e.setAttribute("viewBox",`0 0 ${L[0]} ${L[1]}`),e.setAttribute("aria-hidden","true");let t=document.createElementNS(B,"path");return t.setAttribute("d",U),e.append(t),{mark:e,path:t}}function W(){let e=document.createElement("a"),{mark:t,path:r}=k(),n=e=>{let t=document.createElement("a");return t.style.cssText=e,t.style.cssText},i={plain:n(M),ring:n(M+S),mark:n(G),path:n(F)},a=()=>{e.setAttribute("href",y),e.target="_blank",e.rel="noopener",e.setAttribute("aria-label",I),e.setAttribute("data-occluze-badge","");for(let t of["hidden","inert","aria-hidden","tabindex"])e.removeAttribute(t);(e.firstChild!==t||e.childNodes.length!==2||e.textContent!==N)&&e.replaceChildren(t,N),(t.firstChild!==r||t.childNodes.length!==1)&&t.replaceChildren(r);let n=document.activeElement===e&&o(e,":focus-visible");if(e.style.cssText=n?M+S:M,t.style.cssText=G,r.style.cssText=F,X(e)&&e.isConnected){e.setAttribute("popover","manual");try{o(e,":popover-open")&&e.hidePopover(),e.showPopover()}catch{}}},l=()=>e.getAttribute("href")===y&&!/nofollow|sponsored|ugc/.test(e.rel)&&e.getAttribute("aria-label")===I&&!["hidden","inert","aria-hidden","tabindex"].some(t=>e.hasAttribute(t))&&e.textContent===N&&e.firstChild===t&&e.childNodes.length===2&&t.firstChild===r&&t.childNodes.length===1&&(e.style.cssText===i.plain||e.style.cssText===i.ring)&&t.style.cssText===i.mark&&r.style.cssText===i.path&&(!X(e)||!e.isConnected||o(e,":popover-open")),s=()=>{a()};return e.addEventListener("focus",s),e.addEventListener("blur",s),{badge:e,dress:a,intact:l}}var z;function O(e){if(z){e&&!z.hosted&&(z.hosted=!0,H(e));return}z={hosted:!!e},H(e)}function H(e){let{badge:t,dress:r,intact:n}=W(),i=()=>{h(t,{dress:r,intact:n},()=>e?.gone()),e&&A(e.engine,{path:U,box:L,word:N})};document.body?i():addEventListener("DOMContentLoaded",i,{once:!0})}export{O as showBadge};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- function e(e,t,r){let[n]=r.levels,a=e.createTexture();if(!n||!a)return;e.bindTexture(e.TEXTURE_2D,a),e.pixelStorei(e.UNPACK_ALIGNMENT,1);let i=0;r.levels.forEach((t,n)=>{r.format?e.compressedTexImage2D(e.TEXTURE_2D,n,r.format,t.width,t.height,0,t.data):e.texImage2D(e.TEXTURE_2D,n,e.RGBA,t.width,t.height,0,e.RGBA,e.UNSIGNED_BYTE,t.data),i+=t.data.byteLength}),e.pixelStorei(e.UNPACK_ALIGNMENT,4);let o=r.levels.length>1;o||r.format?e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAX_LEVEL,r.levels.length-1):(e.generateMipmap(e.TEXTURE_2D),i*=4/3);let s=o||!r.format;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,s?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),t.adopt(a,{width:n.width,height:n.height,bytes:i,mipmaps:s})}var t=[["WEBGL_compressed_texture_astc",10,37808,10,37808],["EXT_texture_compression_bptc",6,36492,6,36492],["WEBGL_compressed_texture_etc",1,37496,1,37496],["WEBGL_compressed_texture_s3tc",2,33776,3,33779]],r=13,n=`\nlet ready;\nonmessage = async (event) => {\n const message = event.data;\n if (message.wasm) {\n ready = new Promise((resolve, reject) => {\n const module = { wasmBinary: message.wasm, printErr() {}, onRuntimeInitialized: () => resolve(module), onAbort: reject };\n Promise.resolve(BASIS(module)).catch(reject);\n }).then((module) => { module.initializeBasis(); return module; });\n ready.then(() => postMessage({}), (error) => postMessage({ failed: String(error && error.message || error) }));\n return;\n }\n const { id, buffer, formats, box } = message;\n let file;\n try {\n const module = await ready;\n file = new module.KTX2File(new Uint8Array(buffer));\n if (!file.isValid() || !file.startTranscoding()) throw new Error("not a KTX2 file this transcoder reads");\n const width = file.getWidth();\n const height = file.getHeight();\n const count = file.getLevels();\n const alpha = file.getHasAlpha();\n const blocks = width % 4 === 0 && height % 4 === 0;\n const pick = blocks ? formats.find((f) => f) : null;\n const basis = pick ? (alpha ? pick[2] : pick[0]) : ${r};\n const format = pick ? (alpha ? pick[3] : pick[1]) : 0;\n let from = 0;\n for (let level = 1; box[0] && level < count; level++) {\n const next = file.getImageLevelInfo(level, 0, 0);\n if (next.origWidth < box[0] || next.origHeight < box[1]) break;\n if (!pick || (next.origWidth % 4 === 0 && next.origHeight % 4 === 0)) from = level;\n }\n const levels = [];\n for (let level = from; level < count; level++) {\n const info = file.getImageLevelInfo(level, 0, 0);\n const data = new Uint8Array(file.getImageTranscodedSizeInBytes(level, 0, 0, basis));\n if (!file.transcodeImage(data, level, 0, 0, basis, 0, -1, -1)) throw new Error("transcode failed");\n levels.push({ width: info.origWidth, height: info.origHeight, data });\n }\n postMessage({ id, image: { width, height, format, levels } }, levels.map((l) => l.data.buffer));\n } catch (error) {\n postMessage({ id, error: String(error && error.message || error) });\n } finally {\n if (file) { file.close(); file.delete(); }\n }\n};\n`,a=15e3,i=e=>new Promise((t,r)=>setTimeout(r,a,new Error(`KTX2 transcoder: ${e}`))),o=null,s=0,l=new Map;function c(){return o??=d()}async function f(e){let t=await fetch(new URL(`./${e}`,import.meta.url).href);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t}async function d(){let e;try{e=await Promise.all([f("basis_transcoder.js").then(e=>e.text()),f("basis_transcoder.wasm").then(e=>e.arrayBuffer())])}catch(e){throw o=null,e}let t=URL.createObjectURL(new Blob([e[0],n],{type:"text/javascript"})),r;try{r=new Worker(t)}finally{URL.revokeObjectURL(t)}let a=!1,s,c=new Promise((e,t)=>{s=t,r.onmessage=({data:t})=>{if(t.failed)d(new Error(`KTX2 transcoder: ${t.failed}`));else if(t.id===void 0)a=!0,e(r);else{let e=l.get(t.id);l.delete(t.id),t.image?e?.resolve(t.image):e?.reject(new Error(t.error))}}}),d=e=>{r.terminate(),a&&(o=null),s(e);for(let t of l.values())t.reject(e);l.clear()};return r.onerror=r.onmessageerror=e=>{e.preventDefault(),d(new Error(e.message||"KTX2 transcoder: worker failed"))},r.postMessage({wasm:e[1]},[e[1]]),Promise.race([c,i("no start")]).catch(e=>{throw d(e),e})}function m(e){return t.map(([t,...r])=>e.getExtension(t)?r:null)}async function h(e,t,r){let n=await fetch(t,{mode:"cors",credentials:"omit"});if(!n.ok)throw new Error(`HTTP ${n.status}`);let a=await n.arrayBuffer(),o=r(),f=await c(),d=s++,h=await Promise.race([new Promise((t,r)=>{l.set(d,{resolve:t,reject:r}),f.postMessage({id:d,buffer:a,formats:m(e).filter(Boolean),box:[o[0]??0,o[1]??0]},[a])}),i("no answer")]).finally(()=>l.delete(d)),[g]=h.levels;return!g||g.width===h.width&&g.height===h.height?{image:h,box:[0,0,h.width,h.height]}:{image:h,box:[g.width,g.height,h.width,h.height]}}export{h as loadKtx2,e as upload};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ function e(e,r,n){let[a]=n.levels,i=e.createTexture();if(!a||!i)return;e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_ALIGNMENT,1);let o=0;n.levels.forEach((t,r)=>{n.format?e.compressedTexImage2D(e.TEXTURE_2D,r,n.format,t.width,t.height,0,t.data):e.texImage2D(e.TEXTURE_2D,r,e.RGBA,t.width,t.height,0,e.RGBA,e.UNSIGNED_BYTE,t.data),o+=t.data.byteLength}),e.pixelStorei(e.UNPACK_ALIGNMENT,4);let s=n.levels.length>1;s||n.format?e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAX_LEVEL,n.levels.length-1):(e.generateMipmap(e.TEXTURE_2D),o*=4/3);let l=s||!n.format;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),r.adopt(i,{width:a.width,height:a.height,bytes:o,mipmaps:l});for(let e of n.levels)t(e.data.buffer)}function t(e){e.byteLength&&e.transfer?.(0)}var r=[["WEBGL_compressed_texture_astc",10,37808,10,37808],["EXT_texture_compression_bptc",6,36492,6,36492],["WEBGL_compressed_texture_etc",1,37496,1,37496],["WEBGL_compressed_texture_s3tc",2,33776,3,33779]],n=13,a=`\nlet ready;\nonmessage = async (event) => {\n const message = event.data;\n if (message.wasm) {\n ready = new Promise((resolve, reject) => {\n const module = { wasmBinary: message.wasm, printErr() {}, onRuntimeInitialized: () => resolve(module), onAbort: reject };\n Promise.resolve(BASIS(module)).catch(reject);\n }).then((module) => { module.initializeBasis(); return module; });\n ready.then(() => postMessage({}), (error) => postMessage({ failed: String(error && error.message || error) }));\n return;\n }\n const { id, buffer, formats, box } = message;\n let file;\n try {\n const module = await ready;\n file = new module.KTX2File(new Uint8Array(buffer));\n if (!file.isValid() || !file.startTranscoding()) throw new Error("not a KTX2 file this transcoder reads");\n const width = file.getWidth();\n const height = file.getHeight();\n const count = file.getLevels();\n const alpha = file.getHasAlpha();\n const blocks = width % 4 === 0 && height % 4 === 0;\n const pick = blocks ? formats.find((f) => f) : null;\n const basis = pick ? (alpha ? pick[2] : pick[0]) : ${n};\n const format = pick ? (alpha ? pick[3] : pick[1]) : 0;\n let from = 0;\n for (let level = 1; box[0] && level < count; level++) {\n const next = file.getImageLevelInfo(level, 0, 0);\n if (next.origWidth < box[0] || next.origHeight < box[1]) break;\n if (!pick || (next.origWidth % 4 === 0 && next.origHeight % 4 === 0)) from = level;\n }\n const levels = [];\n for (let level = from; level < count; level++) {\n const info = file.getImageLevelInfo(level, 0, 0);\n const data = new Uint8Array(file.getImageTranscodedSizeInBytes(level, 0, 0, basis));\n if (!file.transcodeImage(data, level, 0, 0, basis, 0, -1, -1)) throw new Error("transcode failed");\n levels.push({ width: info.origWidth, height: info.origHeight, data });\n }\n postMessage({ id, image: { width, height, format, levels } }, levels.map((l) => l.data.buffer));\n } catch (error) {\n postMessage({ id, error: String(error && error.message || error) });\n } finally {\n if (file) { file.close(); file.delete(); }\n }\n};\n`,i=15e3,o=e=>new Promise((t,r)=>setTimeout(r,i,new Error(`KTX2 transcoder: ${e}`))),s=null,l=0,f=new Map;function c(){return s??=m()}async function d(e){let t=await fetch(new URL(`./${e}`,import.meta.url).href);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t}async function m(){let e;try{e=await Promise.all([d("basis_transcoder.js").then(e=>e.text()),d("basis_transcoder.wasm").then(e=>e.arrayBuffer())])}catch(e){throw s=null,e}let t=URL.createObjectURL(new Blob([e[0],a],{type:"text/javascript"})),r;try{r=new Worker(t)}finally{URL.revokeObjectURL(t)}let n=!1,i,l=new Promise((e,t)=>{i=t,r.onmessage=({data:t})=>{if(t.failed)c(new Error(`KTX2 transcoder: ${t.failed}`));else if(t.id===void 0)n=!0,e(r);else{let e=f.get(t.id);f.delete(t.id),t.image?e?.resolve(t.image):e?.reject(new Error(t.error))}}}),c=e=>{r.terminate(),n&&(s=null),i(e);for(let t of f.values())t.reject(e);f.clear()};return r.onerror=r.onmessageerror=e=>{e.preventDefault(),c(new Error(e.message||"KTX2 transcoder: worker failed"))},r.postMessage({wasm:e[1]},[e[1]]),Promise.race([l,o("no start")]).catch(e=>{throw c(e),e})}function h(e){return r.map(([t,...r])=>e.getExtension(t)?r:null)}async function g(e,t,r){let n=await fetch(t,{mode:"cors",credentials:"omit"});if(!n.ok)throw new Error(`HTTP ${n.status}`);let a=await n.arrayBuffer(),i=r(),s=await c(),d=l++,m=await Promise.race([new Promise((t,r)=>{f.set(d,{resolve:t,reject:r}),s.postMessage({id:d,buffer:a,formats:h(e).filter(Boolean),box:[i[0]??0,i[1]??0]},[a])}),o("no answer")]).finally(()=>f.delete(d)),[g]=m.levels;return!g||g.width===m.width&&g.height===m.height?{image:m,box:[0,0,m.width,m.height]}:{image:m,box:[g.width,g.height,m.width,m.height]}}export{g as loadKtx2,e as upload};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e=[["aUmberRect",1],["aUmberA",2],["aUmberB",3],["aUmberRadius",4],["aUmberC",5],["aUmberD",6],["aUmberM",7],["aUmberXf",10],["aUmberClipBox",13],["aUmberClipRadius",14]],r={uRect:"aUmberRect",uSize:"aUmberA.xy",uMouse:"aUmberA.zw",uBleed:"vec4(aUmberB.x)",uProgress:"aUmberB.y",uPlaneMatrix:"aUmberM"},t={uRect:"vUmberRect",uSize:"vUmberA.xy",uMouse:"vUmberA.zw",uProgress:"vUmberB.y",uAlpha:"vUmberB.z",uRadiusKy:"vUmberB.w",uRadius:"vUmberRadius",uFit:"vUmberC.x",uFitPosition:"vUmberC.yz",uImageSize:"vUmberD.xy"},i=["Rect","A","B","Radius","C","D","ClipBox","ClipRadius"],s=/\b(gl_InstanceID|vUmber\w*|aUmber\w*|uUmberImages|umberImage)\b/;function n(e,r){return e.replace(new RegExp(`^uniform\\s+\\w+\\s+(${r.join("|")});.*$`,"gm"),"")}var u=/^uniform\s+\w+\s+(uUmberClips|uUmberClipXf\[2\]|uUmberClipBox\[2\]|uUmberClipRadius\[2\]);.*$/gm,l=`int uUmberClips;\nmat3 uUmberClipXf[2];\nvec4 uUmberClipBox[2];\nvec4 uUmberClipRadius[2];`,a=` uUmberClips = int(vUmberD.z + 0.5);\n uUmberClipXf[0] = vUmberXf;\n uUmberClipBox[0] = vUmberClipBox;\n uUmberClipRadius[0] = vUmberClipRadius;`,f=/void\s+main\s*\(\s*\)\s*\{/g,b=/vec4\s+c\s*=\s*texture\(\s*uImage\s*,\s*f\s*\)\s*;/,m=/vec2\s+fitUv\s*\(\s*vec2\s+uv\s*\)\s*\{/,o=/precision\s+highp\s+float\s*;(?:\s*precision\s+highp\s+\w+\s*;)*/;function c(e,r){let t=[...e.matchAll(f)].at(-1);if(!t)return null;let i=t.index+t[0].length;return e.slice(0,i)+`\n`+r+e.slice(i)}function h(e,r){let t=o.exec(e);if(!t)return null;let i=t.index+t[0].length;return e.slice(0,i)+`\n`+r+e.slice(i)}var p=e=>Object.entries(e).map(([e,r])=>`#define ${e} ${r}`).join(`\n`);function U(e,f){if((f.match(/\buImage\b/g)??[]).length!==2||s.test(e+f)||!b.test(f)||!m.test(f))return null;let o=[...i,"Xf"].map(e=>` vUmber${e} = aUmber${e};`).join(`\n`),U=c(e,o),d=c(f,a);if(!U||!d)return null;let v=h(n(U,Object.keys(r)),[...i.map(e=>`in vec4 aUmber${e};`),"in mat3 aUmberM;","in mat3 aUmberXf;",...i.map(e=>`flat out vec4 vUmber${e};`),"flat out mat3 vUmberXf;",p(r)].join(`\n`)),g=`vec4 umberImage(vec2 f) {\n vec2 dx = dFdx(f);\n vec2 dy = dFdy(f);\n int i = int(vUmberC.w + 0.5);\n vec4 c = vec4(0.0);\n${Array.from({length:8},(e,r)=>` ${r?"else ":""}if (i == ${r}) c = textureGrad(uUmberImages[${r}], f, dx, dy);`).join(`\n`)}\n return c;\n}\n\n`,A=n(d,[...Object.keys(t),"uImage"]).replace(u,"").replace(b,"vec4 c = umberImage(f);").replace(m,e=>g+e),R=h(A,[...i.map(e=>`flat in vec4 vUmber${e};`),"flat in mat3 vUmberXf;",l,"uniform sampler2D uUmberImages[8];",p(t)].join(`\n`));return v&&R?{vertex:v,fragment:R}:null}function d(e,r){if(e===r)return!0;if(!ArrayBuffer.isView(e)&&!Array.isArray(e)||!ArrayBuffer.isView(r)&&!Array.isArray(r))return!1;let t=e,i=r;if(t.length!==i.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==i[e])return!1;return!0}function v(e,r){for(let t in e.uniforms)if(!d(e.uniforms[t]?.value,r.uniforms[t]?.value))return!1;return!0}function g(e){return e.kind==="image"&&!e.backdrop&&!e.modules.frames&&!e.instancing&&!e._z&&!e.shader&&e.bleed.every(r=>r===e.bleed[0])&&e.level!==2&&(!e.clips?.count||e.clips.count===1&&(e.clips.polyInfo[0]??-1)<0)}var A=Array.from({length:8},(e,r)=>r),R=[-1,0];function x(e,r){let t=e.clips?.lb?e.clips.scissorPx:null,i=r.clips?.lb?r.clips.scissorPx:null;return!t||!i?t===i:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}var y=e=>!!e&&"buffers"in e,B=class{constructor(e,r){this.gl=e;this.renderer=r;this.run=[];this.data=new Float32Array(3200);this.buffer=null;this.Ri=new Map;this.pictures=[]}take(e){let r=e.grid;if(!g(e)||!y(r))return!1;let t=this.run,i=t[0];i&&(i.program!==e.program||i.grid!==r||t.length>=64||!x(i,e)||!v(i,e))&&this.flush();let s=this.renderer.picture(e),n=this.unit(s);return n<0&&(this.flush(),n=this.unit(s)),this.write(t.length,e,s,n),t.push(e),!0}flush(){let r=this.run,[t]=r;if(!t)return;let i=this.renderer,s=r.length>1?i.host.gpu.programs.batch(t,{batchSource:U,BATCH_ATTRIBUTES:e}):null,n=i.wa;if(s)this.Tk(s,t);else for(let e of r)i.drawPlane(e);i.wa=n,this.drop()}drop(){this.run.length=0,this.pictures.length=0}Tk(e,r){let t=this.renderer,i=r.grid;if(y(i)){t.wa=r,t.scissor(r.clips?.lb?r.clips.scissorPx:null),t.use(e),e.set("uUmberClipPolyInfo",R);for(let e=0;e<8;e++)t.yb(this.pictures[e]??t.blank,e);e.set("uUmberImages",A),t.wj(e,r,8),this.draw(i,this.run.length),t.draws++}}unit(e){let r=this.pictures.indexOf(e);return r>=0?r:this.pictures.length>=8?-1:this.pictures.push(e)-1}write(e,r,t,i){let s=this.data,n=e*50,u=r.level&&!r.xfReason?r._x:r.rect;s.set(u,n),n+=4,s[n++]=r.size[0],s[n++]=r.size[1],s[n++]=r.mouse[0],s[n++]=r.mouse[1],s[n++]=r.bleed[0]??0,s[n++]=r.progress,s[n++]=r.opacity,s[n++]=r._w,s.set(r.radius,n),n+=4,s[n++]=r.fit,s[n++]=r._M[0],s[n++]=r._M[1],s[n++]=i,s[n++]=(t.box?.[2]??0)||t.width,s[n++]=(t.box?.[3]??0)||t.height;let l=r.clips,a=l?.count??0;s[n++]=a,s[n++]=0,s.set(r._s,n),n+=9;for(let e=0;e<17;e++)s[n+e]=0;if(l&&a){for(let e=0;e<9;e++)s[n+e]=l.xf[e]??0;for(let e=0;e<4;e++)s[n+9+e]=l.box[e]??0,s[n+13+e]=l.radius[e]??0}}draw(e,r){let t=this.gl;this.buffer??=t.createBuffer(),t.bindVertexArray(this.vao(e)),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.data.subarray(0,r*50),t.STREAM_DRAW),t.drawElementsInstanced(t.TRIANGLES,e.count,t.UNSIGNED_SHORT,0,r)}vao(e){let r=this.Ri.get(e);if(r!==void 0)return r;let t=this.gl;r=t.createVertexArray(),this.Ri.set(e,r),t.bindVertexArray(r);let[i,s]=e.buffers;t.bindBuffer(t.ARRAY_BUFFER,i??null),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,s??null),this.buffer??=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.buffer);let n=200,u=(e,r,i)=>{t.enableVertexAttribArray(e),t.vertexAttribPointer(e,r,t.FLOAT,!1,n,i),t.vertexAttribDivisor(e,1)};for(let e=0;e<6;e++)u(e+1,4,e*16);for(let e=0;e<6;e++)u(e+7,3,96+e*12);return u(13,4,168),u(14,4,184),t.bindVertexArray(null),r}lost(){this.drop(),this.Ri.clear(),this.buffer=null}dispose(){for(let e of this.Ri.values())this.gl.deleteVertexArray(e);this.gl.deleteBuffer(this.buffer),this.lost()}};export{B as Batches};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- var e=()=>new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(0)});var t=e=>new Promise(t=>{typeof AbortSignal.timeout=="function"?AbortSignal.timeout(e).onabort=()=>{t()}:setTimeout(t,e)});var s=(e,t)=>e[t]??NaN;var a=250,i=20;function r(e,t){return new h(e,t)}var h=class{constructor(e,t){this.stage=e;this.api=t;this.poll=a;this.Ud=i;this.ic=!1;this.settle=null;this.held=[];this.was="";this.stuck=new WeakMap;this.seen=0;this.cut=1/0;this.said=!1;let r=e.gpu.gl,h=r.getParameter(r.MAX_VIEWPORT_DIMS);this.side=Math.min(r.getParameter(r.MAX_RENDERBUFFER_SIZE),s(h,0),s(h,1)),e.gpu.tier.maxTexture=r.getParameter(r.MAX_TEXTURE_SIZE);let n=e.gpu.renderer.adaptive;n.index=0,n.scale=1,e.env.stats.scale=1;let l=()=>{this.ic||this.news()};e.scheduler.onRequest.add(l);let u=e.env.host.ticker;e.env.cleanups.push(()=>e.scheduler.onRequest.delete(l),u.add(()=>this.ic=!0,{phase:"measure",order:-1/0}),u.add(()=>{this.frame()},{phase:"render",order:1/0}),()=>this.settle?.()),e.canvasHost.Ib(),e.scheduler.wake(2)}dpr(e,t){let s=devicePixelRatio||1,a=Math.min(s,this.side/Math.max(e,1),this.side/Math.max(t,1),this.cut);return a<s&&!this.said&&(this.said=!0,this.stage.env.lib.say("captureDpr",[s,a,Math.round(Math.max(e,t)*a)])),a}pending(e){if(e.destroyed||e.domReason||e.viewTransition||e._j||e.morphHidden||e.status==="error"||e.textureState==="error"||!(e.visible||e.zone.screen&&e.opacity>.001))return!1;let t=e.texture;return e.status==="loading"&&!e.raster?.empty||!!(t?.ready&&t.refs>0&&!t.box.length)}frame(){this.ic=!1;let s=this.stage;if(s.scheduler.inactive)return;let a=s.gpu.gl,i=s.gpu.canvas,r=Math.min(a.drawingBufferWidth/i.width,a.drawingBufferHeight/i.height);if(r<1&&(this.cut=s.canvasHost.dpr*r,s.canvasHost.Ib(),s.scheduler.markDirty()),s.canvasHost.dpr!==this.seen){this.seen=s.canvasHost.dpr;for(let e of s.planes.all)s.gpu.media.sharpen(e)}if(this.settle)return;let h=[];for(let e of s.planes.all)this.pending(e)?(this.stuck.get(e)??0)<this.Ud&&h.push(e):this.stuck.delete(e);h.length&&(this.held=h,this.was=this.state(),this.api.wait(new Promise(a=>{let i=this.settle=e=>{if(this.settle===i){if(this.settle=null,e)for(let e of h){let t=(this.stuck.get(e)??0)+1;this.stuck.set(e,t),t===this.Ud&&s.env.lib.say("captureWait",[e.el,t*this.poll/1e3])}a()}};h.every(e=>e.state.status==="loading"&&e.state.drawnFrame!==null)&&e().then(()=>{i()}),t(this.poll).then(()=>{i(!0)})})))}state(){return this.held.map(e=>`${e.status} ${e.textureState} ${e.texture?.ready} ${e.texture?.box.length} ${!!e.program} ${e.videoFrame} ${e.shapeWait} ${e.modules.frames?.pending}`).join()}news(){let t=this.settle;t&&this.state()!==this.was&&e().then(()=>{t()})}};export{h as Capture,a as POLL_MS,i as STUCK_AFTER,r as capture};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e=()=>new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(0)});var t=e=>new Promise(t=>{typeof AbortSignal.timeout=="function"?AbortSignal.timeout(e).onabort=()=>{t()}:setTimeout(t,e)});var s=()=>{};var a=(e,t)=>e[t]??NaN;var i=250,r=20;function h(e,t){return new n(e,t)}var n=class{constructor(e,t){this.stage=e;this.api=t;this.poll=i;this.ua=r;this.Bi=!1;this.settle=null;this.held=[];this.was="";this.stuck=new WeakMap;this.seen=0;this.cut=1/0;this.said=!1;let h=e.gpu.gl,n=h.getParameter(h.MAX_VIEWPORT_DIMS);this.side=Math.min(h.getParameter(h.MAX_RENDERBUFFER_SIZE),a(n,0),a(n,1)),e.gpu.tier.maxTexture=h.getParameter(h.MAX_TEXTURE_SIZE);let l=e.gpu.renderer.adaptive;l.index=0,l.scale=1,e.env.stats.scale=1;let u=()=>{this.Bi||this.news()};e.scheduler.onRequest.add(u);let o=e.env.host.ticker;e.env.cleanups.push(()=>e.scheduler.onRequest.delete(u),o.add(s,{always:!0},!0),o.add(()=>this.Bi=!0,{phase:"measure",order:-1/0}),o.add(()=>{this.frame()},{phase:"render",order:1/0}),()=>this.settle?.()),e.canvasHost.Ae(),e.scheduler.wake(2)}dpr(e,t){let s=devicePixelRatio||1,a=Math.min(s,this.side/Math.max(e,1),this.side/Math.max(t,1),this.cut);return a<s&&!this.said&&(this.said=!0,this.stage.env.lib.say("captureDpr",[s,a,Math.round(Math.max(e,t)*a)])),a}pending(e){if(e.destroyed||e.domReason||e.viewTransition||e._t||e.morphHidden||e.status==="error"||e.textureState==="error"||!(e.visible||e.zone.screen&&e.opacity>.001))return!1;let t=e.texture;return e.status==="loading"&&!e.raster?.empty||!!(t?.ready&&t.refs>0&&!t.box.length)}frame(){this.Bi=!1;let s=this.stage;if(s.scheduler.inactive)return;let a=s.gpu.gl,i=s.gpu.canvas,r=Math.min(a.drawingBufferWidth/i.width,a.drawingBufferHeight/i.height);if(r<1&&(this.cut=s.canvasHost.dpr*r,s.canvasHost.Ae(),s.scheduler.markDirty()),s.canvasHost.dpr!==this.seen){this.seen=s.canvasHost.dpr;for(let e of s.planes.all)s.gpu.media.sharpen(e)}if(this.settle)return;let h=[];for(let e of s.planes.all)this.pending(e)?(this.stuck.get(e)??0)<this.ua&&h.push(e):this.stuck.delete(e);h.length&&(this.held=h,this.was=this.state(),this.api.wait(new Promise(a=>{let i=this.settle=e=>{if(this.settle===i){if(this.settle=null,e)for(let e of h){let t=(this.stuck.get(e)??0)+1;this.stuck.set(e,t),t===this.ua&&s.env.lib.say("captureWait",[e.el,t*this.poll/1e3])}a()}};h.every(e=>e.state.status==="loading"&&e.state.drawnFrame!==null)&&e().then(()=>{i()}),t(this.poll).then(()=>{i(!0)})})))}state(){return this.held.map(e=>`${e.status} ${e.textureState} ${e.texture?.ready} ${e.texture?.box.length} ${!!e.program} ${e.videoFrame} ${e.shapeWait} ${e.modules.frames?.pending}`).join()}news(){let t=this.settle;t&&this.state()!==this.was&&e().then(()=>{t()})}};export{n as Capture,i as POLL_MS,r as STUCK_AFTER,h as capture};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- var t=t=>t!==null&&t!==document.body&&t!==document.documentElement;function e(t){let e=t.tagName.toLowerCase();return t.id?`${e}#${t.id}`:t.classList[0]?`${e}.${t.classList[0]}`:e}var n=(t,e)=>(t.position!=="static"||e<0)&&(+t.zIndex||0)>=e,o=t=>t.backgroundColor.startsWith("rgb(");function r(r,l,u){let a=+getComputedStyle(l).zIndex||0;for(let i=r.parentElement;t(i);i=i.parentElement){let t=getComputedStyle(i);if(n(t,a)&&o(t))return u("coverBackground",[e(r),e(i),t.zIndex,a],i),!0}return i(r,l,a,u)}function i(t,n,r,i){let u=t.getBoundingClientRect(),a=(Math.max(u.left,0)+Math.min(u.right,innerWidth))/2,m=(Math.max(u.top,0)+Math.min(u.bottom,innerHeight))/2;if(!("elementsFromPoint"in document)||a<0||m<0||a>innerWidth||m>innerHeight)return!1;let d=document.elementsFromPoint(a,m);if(d.some(e=>t.contains(e)))return!1;for(let u of d){if(u.contains(t)||n.contains(u))break;if(!o(getComputedStyle(u)))continue;let a=l(u,r);if(a)return i("coverBox",[e(t),e(a),getComputedStyle(a).zIndex],a),!0}return!1}function l(e,o){for(let r=e;t(r);r=r.parentElement)if(n(getComputedStyle(r),o))return r;return null}export{r as landed};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ function t(t){if(!t||typeof t.tagName!="string")return"<?>";let e=t.tagName.toLowerCase();if(t.id)return`<${e}#${t.id}>`;let n=typeof t.className=="string"?t.className.trim().split(/\s+/)[0]:"";return n?`<${e}.${n}>`:`<${e}>`}var e=t=>!!t.backgroundImage&&t.backgroundImage!=="none"||!/^(transparent|rgba\(.*,\s*0\))$/.test(t.backgroundColor||"transparent"),n=["transform","translate","rotate","scale","perspective","filter","backdropFilter","clipPath","maskImage","webkitMaskImage"],a=t=>t.position!=="static"&&t.zIndex!=="auto"||/fixed|sticky/.test(t.position)||parseFloat(t.opacity)<1||n.some(e=>(t[e]||"none")!=="none")||t.isolation==="isolate"||(t.mixBlendMode||"normal")!=="normal"||/\b(layout|paint|strict|content)\b/.test(t.contain)||/^(size|inline-size)$/.test(t.containerType)||/\b(transform|translate|rotate|scale|perspective|filter|opacity|clip-path|mask|isolation|mix-blend-mode|contain)\b/.test(t.willChange),i=t=>t!==null&&t!==document.body&&t!==document.documentElement;function o(n,o){let r=parseInt(getComputedStyle(o).zIndex,10);if(!(r>0))return null;let s=null,l="auto",d=[];for(let t=n;i(t);t=t.parentElement){let i=getComputedStyle(t);e(i)&&!(t===n&&n.matches("[data-umber~=shader]"))&&d.push(t),a(i)&&(s=t,l=i.position!=="static"?i.zIndex:"auto")}if(!s||l==="auto"||+l<r)return null;let c=d.filter(t=>s.contains(t)),u=c.find(t=>t!==n)??c[0];return u?u===n?`its own background covers Umber's canvas (z-index ${r}): ${t(s)} around it (z-index ${l}) is above the canvas, so that background paints over what GL draws of it. Remove its background (GL draws the element itself), or drop that z-index.`:`${u===s?`${t(s)} (z-index ${l}, with a background) covers Umber's canvas (z-index ${r})`:`${t(s)} (z-index ${l}) is above Umber's canvas (z-index ${r}), and the background of ${t(u)} inside it covers Umber's canvas`}: GL inside it is hidden. Drop that z-index (and give it data-umber-occlude if it must still cover the GL elements before it) or move the background behind the content.`:null}function r(e,n,a){if(!e.has(n)||e.get(n)){let i=o(n.el,a.canvasHost.el),r=n.kind==="layer",s=i&&`${t(n.el)}: ${i}${r?"":" Until then its DOM shows."}`;e.set(n,s),s&&r&&a.fallbacks.Ja(n,s)}return n.kind==="layer"?null:e.get(n)??null}function s(t){let e=new WeakMap,n=t.fallbacks,a=n.decide.bind(n);n.decide=n=>{t.chunks.shapes||(n._I=n.stale&&!t.transitions.ongoing?r(e,n,t):e.get(n)??null),a(n)},t.factory.invalidate()}function l(t){let e=t.tagName.toLowerCase();return t.id?`${e}#${t.id}`:t.classList[0]?`${e}.${t.classList[0]}`:e}var d=(t,e)=>(t.position!=="static"||e<0)&&(+t.zIndex||0)>=e,c=t=>t.backgroundColor.startsWith("rgb(");function u(t,e,n){let a=+getComputedStyle(e).zIndex||0;for(let e=t.parentElement;i(e);e=e.parentElement){let i=getComputedStyle(e);if(d(i,a)&&c(i))return n("coverBackground",[l(t),l(e),i.zIndex,a],e),!0}return m(t,e,a,n)}function m(t,e,n,a){let i=t.getBoundingClientRect(),o=(Math.max(i.left,0)+Math.min(i.right,innerWidth))/2,r=(Math.max(i.top,0)+Math.min(i.bottom,innerHeight))/2;if(!("elementsFromPoint"in document)||o<0||r<0||o>innerWidth||r>innerHeight)return!1;let s=document.elementsFromPoint(o,r);if(s.some(e=>t.contains(e)))return!1;for(let i of s){if(i.contains(t)||e.contains(i))break;if(!c(getComputedStyle(i)))continue;let o=f(i,n);if(o)return a("coverBox",[l(t),l(o),getComputedStyle(o).zIndex],o),!0}return!1}function f(t,e){for(let n=t;i(n);n=n.parentElement)if(d(getComputedStyle(n),e))return n;return null}export{u as landed,s as plain};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- function e(e,t){let n=new DataView(e);if(String.fromCharCode(...new Uint8Array(e,0,4))!=="UMBG"||n.getUint16(4,!0)!==1)throw new Error("not a glyphs file this version reads");let r=n.getUint32(12,!0),i=n.getUint32(16,!0),a=n.getUint32(20,!0),u=n.getUint32(24,!0),s=28,h=new Map;for(let e=0;e<i;e++,s+=8)h.set(n.getUint32(s,!0),n.getUint32(s+4,!0));let o=new Int16Array(r*4),l=new Uint32Array(r*4);for(let e=0;e<r;e++,s+=20){for(let t=0;t<4;t++)o[e*4+t]=n.getInt16(s+2*t,!0);l.set([n.getUint32(s+12,!0),n.getUint32(s+16,!0),n.getUint8(s+10),n.getUint8(s+11)],e*4)}let c=new Int16Array(e.slice(s,s+a*8));s+=a*8;let p=new Uint16Array(e.slice(s,s+u*2));return{unitsPerEm:n.getUint16(6,!0),cmap:h,base:t,bounds:o,where:l,curves:c,bands:p}}var t=1024;function n(e){let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),{texture:t}}function r(e,n,r){let i=Math.max(1,e.length/n),a=Math.min(t,i),u=Math.ceil(i/a),s=r(a*u*n);return s.set(e),{out:s,width:a,height:u}}var i=class{constructor(e){this.gl=e;this.fonts=[];this.cc=0;this.curves=n(e),this.bands=n(e),this.glyphs=n(e)}get bytes(){let e=0;for(let t of this.fonts)e+=t.curves.byteLength+t.bands.byteLength+t.where.length*8;return e}add(t){let n=e(t,this.cc);return this.cc+=n.where.length/4,this.fonts.push(n),this.upload(),n}upload(){let e=this.gl,t=0,n=0,i=new Float32Array(Math.max(1,this.cc)*8),a=new Int16Array(this.fonts.reduce((e,t)=>e+t.curves.length,0)),u=new Uint16Array(this.fonts.reduce((e,t)=>e+t.bands.length,0));for(let e of this.fonts){a.set(e.curves,t*4),u.set(e.bands,n);for(let r=0;r<e.where.length/4;r++){let a=(e.base+r)*8,u=e.where;i.set([(u[r*4]??0)+t,(u[r*4+1]??0)+n,u[r*4+2]??0,u[r*4+3]??0],a),i.set(Array.from(e.bounds.subarray(r*4,r*4+4)),a+4)}t+=e.curves.length/4,n+=e.bands.length}e.pixelStorei(e.UNPACK_ALIGNMENT,1);let s=r(a,4,e=>new Int16Array(e));e.bindTexture(e.TEXTURE_2D,this.curves.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA16I,s.width,s.height,0,e.RGBA_INTEGER,e.SHORT,s.out);let h=r(u,1,e=>new Uint16Array(e));e.bindTexture(e.TEXTURE_2D,this.bands.texture),e.texImage2D(e.TEXTURE_2D,0,e.R16UI,h.width,h.height,0,e.RED_INTEGER,e.UNSIGNED_SHORT,h.out);let o=r(i,4,e=>new Float32Array(e));e.bindTexture(e.TEXTURE_2D,this.glyphs.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,o.width,o.height,0,e.RGBA,e.FLOAT,o.out),e.pixelStorei(e.UNPACK_ALIGNMENT,4)}restore(){let e=this.gl;for(let t of[this.curves,this.bands,this.glyphs])t.texture=n(e).texture;this.upload()}};function a(e,t){let n=e.cmap.get(t);if(n===void 0||!e.where[n*4+2])return null;let r=e.bounds;return{index:e.base+n,bounds:[r[n*4]??0,r[n*4+1]??0,r[n*4+2]??0,r[n*4+3]??0],unitsPerEm:e.unitsPerEm}}var u=new RegExp("f[filt]|\\p{Extended_Pictographic}|\\p{Regional_Indicator}","u");function s(e,t,n){if(u.test(n))return null;let r=[],i=0;for(let u of n){let s=u.codePointAt(0)??0,h=a(t,s);if(h)r.push([i?e.measureText(n.slice(0,i)).width:0,h]);else if(/\S/.test(u)&&!t.cmap.has(s))return null;i+=u.length}return r}var h={text:"",font:"",letterSpacing:"",wordSpacing:"",kerning:"",caps:"",rtl:!1,color:"",scale:1};function o({fill:e,rgba:t,scale:n},r,i,a){let u=r.unitsPerEm/(a*n),s=(e.x+i)*n,o=e.y*n,[l,c,p,x]=r.bounds,b=Math.floor(s+l/u)-1,g=Math.floor(o-x/u)-1,d=Math.ceil(s+p/u)+1,f=Math.ceil(o-c/u)+1,m=d-b,y=f-g;return{entry:{key:"",page:0,x:s-b,y:o-g,w:m,h:y,ox:0,oy:0,ink:[0,0,m,y],refs:1,paint:h,curve:[r.index,u]},x:b,y:g,tint:[t[0],t[1],t[2],t[3]*e.alpha]}}function l(e,{font:t,px:n},r,i){return s(e,t,i.text)?.map(([e,t])=>o(r,t,i.advance+e,n))??null}var c=`uniform highp isampler2D uUmberCurves;\nuniform highp usampler2D uUmberBands;\nuniform highp sampler2D uUmberGlyphs;\nvec4 umberCurveTexel(highp int i){\nhighp int w=textureSize(uUmberCurves,0).x;\nreturn vec4(texelFetch(uUmberCurves,ivec2(i%w,i/w),0))*0.25;\n}\nhighp int umberBandWord(highp int i){\nhighp int w=textureSize(uUmberBands,0).x;\nreturn int(texelFetch(uUmberBands,ivec2(i%w,i/w),0).r);\n}\nvec4 umberCurveRow(highp int i){\nhighp int w=textureSize(uUmberGlyphs,0).x;\nreturn texelFetch(uUmberGlyphs,ivec2(i%w,i/w),0);\n}\nhighp uint umberRoots(float a,float b,float c){\nhighp uint code=(a>0.0?2u:0u)+(b>0.0?4u:0u)+(c>0.0?8u:0u);\nreturn(0x2E74u>>code)&3u;\n}\nfloat umberRay(vec2 p,float ppu,highp int curves,highp int bands,highp int band,bool down){\nhighp int count=umberBandWord(bands+2*band);\nhighp int list=bands+umberBandWord(bands+2*band+1);\nfloat sum=0.0;\nfor(highp int k=0;k<count;k++){\nhighp int c=curves+umberBandWord(list+k);\nvec4 t=umberCurveTexel(c);\nvec2 q1=t.xy-p;\nvec2 q2=t.zw-p;\nvec2 q3=umberCurveTexel(c+1).xy-p;\nif(down){q1=q1.yx;q2=q2.yx;q3=q3.yx;}\nif(max(max(q1.x,q2.x),q3.x)*ppu< -0.5)break;\nhighp uint roots=umberRoots(q1.y,q2.y,q3.y);\nif(roots==0u)continue;\nfloat a=q1.y-2.0*q2.y+q3.y;\nfloat b=q1.y-q2.y;\nfloat d=sqrt(max(b*b-a*q1.y,0.0));\nfloat t1=abs(a)<1e-4?q1.y/(2.0*b):(b-d)/a;\nfloat t2=abs(a)<1e-4?t1:(b+d)/a;\nfloat ax=q1.x-2.0*q2.x+q3.x;\nfloat bx=q1.x-q2.x;\nif((roots&1u)!=0u)sum+=clamp(((ax*t1-2.0*bx)*t1+q1.x)*ppu+0.5,0.0,1.0);\nif(roots>1u)sum-=clamp(((ax*t2-2.0*bx)*t2+q1.x)*ppu+0.5,0.0,1.0);\n}\nreturn sum;\n}\nfloat umberCurveGlyph(vec2 l,vec4 a,vec2 pxPer){\nfloat perPx= -a.z;\nhighp int g=int(a.w+0.5);\nvec4 where=umberCurveRow(2*g);\nvec4 box=umberCurveRow(2*g+1);\nvec2 p=vec2(l.x-a.x,a.y-l.y)*perPx;\nvec2 ppu=pxPer/perPx;\nhighp int across=int(where.z+0.5);\nhighp int down=int(where.w+0.5);\nvec2 size=max(box.zw-box.xy,vec2(1.0));\nhighp int h=clamp(int(floor((p.y-box.y)/size.y*float(across))),0,across-1);\nhighp int v=clamp(int(floor((p.x-box.x)/size.x*float(down))),0,down-1);\nhighp int curves=int(where.x+0.5);\nhighp int bands=int(where.y+0.5);\nfloat x=umberRay(p,ppu.x,curves,bands,h,false);\nfloat y=umberRay(p,ppu.y,curves,bands,across+v,true);\nreturn clamp(0.5*(abs(x)+abs(y)),0.0,1.0);\n}`;export{c as CURVE_GLSL,i as CurveTables,l as curveWord};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e=`\nfloat umberAreaF(float u){\nreturn u<0.0?0.0:u<1.0?0.5*u*u:u-0.5;\n}\nfloat umberAreaSeg(vec2 a,vec2 b,float y0,float y1){\nfloat dy=b.y-a.y;\nif(abs(dy)<1e-7)return 0.0;\nfloat t0=(y0-a.y)/dy;\nfloat t1=(y1-a.y)/dy;\nfloat lo=clamp(min(t0,t1),0.0,1.0);\nfloat hi=clamp(max(t0,t1),0.0,1.0);\nif(hi<=lo)return 0.0;\nvec2 from=mix(a,b,lo);\nvec2 to=mix(a,b,hi);\nfloat d=to.y-from.y;\nfloat u0=from.x+0.5;\nfloat u1=to.x+0.5;\nif(abs(u1-u0)<1e-5)return clamp(u0,0.0,1.0)*d;\nreturn(umberAreaF(u1)-umberAreaF(u0))/(u1-u0)*d;\n}\nfloat umberArea(vec2 p,vec2 px,highp int curves,highp int bands,highp int band,float y0,float y1){\nhighp int count=umberBandWord(bands+2*band);\nhighp int list=bands+umberBandWord(bands+2*band+1);\nfloat cov=0.0;\nfor(highp int k=0;k<count;k++){\nhighp int c=curves+umberBandWord(list+k);\nvec4 t=umberCurveTexel(c);\nvec2 p0=t.xy-p;\nvec2 p1=t.zw-p;\nvec2 p2=umberCurveTexel(c+1).xy-p;\nif(max(p0.x,max(p1.x,p2.x))*px.x< -0.5)break;\np0*=px;\np1*=px;\np2*=px;\nif(max(p0.y,max(p1.y,p2.y))<y0||min(p0.y,min(p1.y,p2.y))>y1)continue;\nvec2 dd=p0-2.0*p1+p2;\nhighp int n=int(clamp(ceil(sqrt(length(dd)*0.5)),1.0,32.0));\nvec2 prev=p0;\nfor(highp int j=1;j<=n;j++){\nfloat s=float(j)/float(n);\nvec2 q=mix(mix(p0,p1,s),mix(p1,p2,s),s);\ncov+=umberAreaSeg(prev,q,y0,y1);\nprev=q;\n}\n}\nreturn cov;\n}\n`,t=`\nfloat fy=(p.y-box.y)/size.y*float(across);\nfloat hb=0.5/ppu.y/size.y*float(across);\nhighp int lo=clamp(int(floor(fy-hb)),0,across-1);\nhighp int hi=clamp(int(floor(fy+hb)),0,across-1);\nfloat acc=0.0;\nfor(highp int b=lo;b<=hi;b++){\nfloat e0=b==0?-0.5:(float(b)-fy)/float(across)*size.y*ppu.y;\nfloat e1=b==across-1?0.5:(float(b+1)-fy)/float(across)*size.y*ppu.y;\nacc+=umberArea(p,ppu,curves,bands,b,max(e0,-0.5),min(e1,0.5));\n}\nreturn clamp(abs(acc),0.0,1.0);\n`,n=`\nuniform highp isampler2D uUmberCurves;\nuniform highp usampler2D uUmberBands;\nuniform highp sampler2D uUmberGlyphs;\nvec4 umberCurveTexel(highp int i){\nreturn vec4(texelFetch(uUmberCurves,ivec2(i&1023,i>>10),0))*0.25;\n}\nhighp int umberBandWord(highp int i){\nreturn int(texelFetch(uUmberBands,ivec2(i&1023,i>>10),0).r);\n}\nvec4 umberCurveRow(highp int i){\nreturn texelFetch(uUmberGlyphs,ivec2(i&1023,i>>10),0);\n}\n`+e+`\nfloat umberCurveGlyph(vec2 l,vec4 a,vec2 pxPer){\nfloat perPx= -a.z;\nhighp int g=int(a.w+0.5);\nvec4 where=umberCurveRow(2*g);\nvec4 box=umberCurveRow(2*g+1);\nvec2 p=vec2(l.x-a.x,a.y-l.y)*perPx;\nvec2 ppu=pxPer/perPx;\nhighp int across=int(where.z+0.5);\nvec2 size=max(box.zw-box.xy,vec2(1.0));\nhighp int curves=int(where.x+0.5);\nhighp int bands=int(where.y+0.5);\n`+t+"}";function r(e,t){let n=new DataView(e);if(String.fromCharCode(...new Uint8Array(e,0,4))!=="UMBG"||n.getUint16(4,!0)!==2)throw new Error("not a glyphs file this version reads");let r=n.getUint32(12,!0),i=n.getUint32(16,!0),a=n.getUint32(20,!0),l=n.getUint32(24,!0),o=new Uint32Array(e.slice(e.byteLength-n.getUint32(28,!0)*4)),s=32,u=new Map;for(let e=0;e<i;e++,s+=8)u.set(n.getUint32(s,!0),n.getUint32(s+4,!0));let h=new Int16Array(r*4),p=new Uint32Array(r*4);for(let e=0;e<r;e++,s+=20){for(let t=0;t<4;t++)h[e*4+t]=n.getInt16(s+2*t,!0);p.set([n.getUint32(s+12,!0),n.getUint32(s+16,!0),n.getUint8(s+10),n.getUint8(s+11)],e*4)}let c=new Int16Array(e.slice(s,s+a*8));s+=a*8;let f=new Uint16Array(e.slice(s,s+l*2));return{unitsPerEm:n.getUint16(6,!0),cmap:u,base:t,bounds:h,where:p,curves:c,bands:f,ligatures:o}}function i(e){let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),{texture:t}}function a(e,t,n){let r=Math.max(1,e.length/t),i=Math.min(1024,r),a=Math.ceil(r/i),l=n(i*a*t);return l.set(e),{out:l,width:i,height:a}}var l=class{constructor(e){this.gl=e;this.fonts=[];this.yf=0;this.curves=i(e),this.bands=i(e),this.glyphs=i(e)}get bytes(){let e=0;for(let t of this.fonts)e+=t.curves.byteLength+t.bands.byteLength+t.where.length*8;return e}add(e){let t=r(e,this.yf);return this.yf+=t.where.length/4,this.fonts.push(t),this.upload(),t}upload(){let e=this.gl,t=0,n=0,r=new Float32Array(Math.max(1,this.yf)*8),i=new Int16Array(this.fonts.reduce((e,t)=>e+t.curves.length,0)),l=new Uint16Array(this.fonts.reduce((e,t)=>e+t.bands.length,0));for(let e of this.fonts){i.set(e.curves,t*4),l.set(e.bands,n);let a=[t,n];for(let t=0;t<e.where.length/4;t++){let n=(e.base+t)*8;r.set(e.where.subarray(t*4,t*4+4).map((e,t)=>e+(a[t]??0)),n),r.set(e.bounds.subarray(t*4,t*4+4),n+4)}t+=e.curves.length/4,n+=e.bands.length}e.pixelStorei(e.UNPACK_ALIGNMENT,1);let o=a(i,4,e=>new Int16Array(e));e.bindTexture(e.TEXTURE_2D,this.curves.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA16I,o.width,o.height,0,e.RGBA_INTEGER,e.SHORT,o.out);let s=a(l,1,e=>new Uint16Array(e));e.bindTexture(e.TEXTURE_2D,this.bands.texture),e.texImage2D(e.TEXTURE_2D,0,e.R16UI,s.width,s.height,0,e.RED_INTEGER,e.UNSIGNED_SHORT,s.out);let u=a(r,4,e=>new Float32Array(e));e.bindTexture(e.TEXTURE_2D,this.glyphs.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,u.width,u.height,0,e.RGBA,e.FLOAT,u.out),e.pixelStorei(e.UNPACK_ALIGNMENT,4)}restore(){let e=this.gl;for(let t of[this.curves,this.bands,this.glyphs])t.texture=i(e).texture;this.upload()}};function o(e,t){return e.where[t*4+2]?{index:e.base+t,bounds:e.bounds.subarray(t*4,t*4+4),unitsPerEm:e.unitsPerEm}:null}var s=2147483648;function u(e,t,n,r){let i=e.ligatures;if(!e.joins){e.joins=new Map;for(let t=0;t+2<i.length;t+=2+((i[t+1]??0)&~s)){let n=i[t+2]??0;e.joins.set(n,[...e.joins.get(n)??[],t])}}for(let a of e.joins.get(t[n]??-1)??[]){let e=(i[a+1]??0)&~s;if(!(r&((i[a+1]??0)<s?2:1)))continue;let l=n+e<=t.length;for(let r=1;l&&r<e;r++)l=i[a+2+r]===t[n+r];if(l)return[i[a]??0,e]}return null}var h=new RegExp("\\p{Extended_Pictographic}|\\p{Regional_Indicator}","u");function p(e,t,n,r){if(h.test(n))return null;let i=Array.from(n),a=[];for(let e of i){let n=t.cmap.get(e.codePointAt(0)??0);if(n===void 0)return null;a.push(n)}let l=[],s=t=>e.measureText(t).width,p=0;for(let e=0;e<i.length;){let[h=a[e]??0,c=1]=u(t,a,e,r)??[],f=i.slice(e,e+c).join(""),g=o(t,h);g&&l.push([p?s(n.slice(0,p+f.length))-s(f):0,g]),p+=f.length,e+=c}return l}var c={text:"",font:"",letterSpacing:"",wordSpacing:"",kerning:"",caps:"",rtl:!1,color:"",scale:1};function f({fill:e,rgba:t,scale:n},r,i,a){let l=r.unitsPerEm/(a*n),o=(e.x+i)*n,s=e.y*n,[u=0,h=0,p=0,f=0]=r.bounds,g=Math.floor(o+u/l)-1,b=Math.floor(s-f/l)-1,y=Math.ceil(o+p/l)+1,x=Math.ceil(s-h/l)+1,m=y-g,d=x-b;return{entry:{key:"",page:0,x:o-g,y:s-b,w:m,h:d,ox:0,oy:0,ink:[0,0,m,d],refs:1,paint:c,curve:[r.index,l]},x:g,y:b,tint:[t[0],t[1],t[2],t[3]*e.alpha]}}function g({font:e,px:t},n){let r=[];for(let{fill:t}of n){let n=e.cmap.get(t.text.codePointAt(0)??0);if(n===void 0)return null;r.push(n)}let i=[];for(let a=0;a<n.length;){let l=n[a];if(!l)break;let[s=r[a]??0,h=1]=u(e,r,a,l.fill.joins)??[],p=o(e,s);p&&i.push(f(l,p,0,t)),a+=h}return i}function b(e,{font:t,px:n},r,i){return p(e,t,i.text,r.fill.joins)?.map(([e,t])=>f(r,t,i.advance+e,n))??null}export{n as CURVE_GLSL,l as CurveTables,g as curveLetters,b as curveWord};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- function e(e){return typeof e=="number"?new Float32Array(e):new Float32Array(e)}var t=(e,t)=>e[t]??NaN;var r={duration:.8,ease:"umber",stagger:0},a={duration:.8,ease:"umber"},s=class{constructor(e){this.stage=e;this.ends=new WeakMap}swap(e,t,r){let s=e._o("uPrev"),n=e._o("uPrevSize"),i=e._o("uSwap");if(!s||!n||!i){r();return}s.value=t,n.value=new Float32Array([t.width,t.height]),i.value=0;let l=this.stage.env.lib.config(e.el,"data-umber-swap",a);this.stage.env.tweens.to(i,{value:1,duration:l.duration||0,ease:l.ease,onComplete:r})}fly(a,s,n={}){let i=this.stage,l={...r,...n},u=i.env.kit.ease(l.ease),o=i.env.reducedMotion?0:Math.max(0,l.duration||0)*1e3,d=i.env.reducedMotion?0:Math.max(0,l.stagger||0)*1e3,h=i.env.now;return Promise.all(a.map((r,a)=>new Promise(n=>{let l=s[a];if(!l){r.fly=null,n();return}this.ends.get(r)?.();let f=e(4),y=e(4);f.set(r.radius),y.set(r.radius);let m=r._b,g=m,c=()=>{for(let e=0;e<4;e++){let a=t(r.radius,e);a!==y[e]&&(f[e]=a)}r._b!==g&&(m=r._b)},v=()=>{if(this.ends.get(r)!==v){n();return}this.ends.delete(r),r.fly===b&&(r.fly=null),c(),r.radius.set(f),r._b=m,w(),i.scheduler.markDirty(),n()},w=r.on("destroy",v);this.ends.set(r,v);let b=(e,s,n)=>{let w=o?Math.min(1,Math.max(0,(i.env.now-h-a*d)/o)):1,b=1-u(w);c(),e[0]+=(l[0]-s-e[0])*b,e[1]+=(l[1]-n-e[1])*b,e[2]+=(l[2]-e[2])*b,e[3]+=(l[3]-e[3])*b;for(let e=0;e<4;e++){let a=t(f,e),s=a+(t(l,4+e)-a)*b;y[e]=s,r.radius[e]=s}g=m+(l[8]-m)*b,r._b=g,w<1?i.scheduler.markDirty():v()};r.fly=b,i.scheduler.markDirty()}))).then(()=>{})}lift(e){let t=this.stage,r=e.rect,a=new Float32Array(r);this.ends.get(e)?.();let s={};return["x","y","width","height"].forEach((e,r)=>Object.defineProperty(s,e,{enumerable:!0,get:()=>a[r],set:e=>{a[r]=e||0,t.scheduler.markDirty()}})),e.fly=e=>{e.set(a)},t.scheduler.markDirty(),s}land(e,t){return e.fly?this.fly([e],[this.stage.transitions.where(e)],t):Promise.resolve()}};function n(e){return new s(e)}export{s as Flip,n as flip};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ function e(e){return typeof e=="number"?new Float32Array(e):new Float32Array(e)}var t=(e,t)=>e[t]??NaN;var r={duration:.8,ease:"umber",stagger:0},a={duration:.8,ease:"umber"},s=class{constructor(e){this.stage=e;this.ends=new WeakMap}swap(e,t,r){let s=e._r("uPrev"),n=e._r("uPrevSize"),i=e._r("uSwap");if(!s||!n||!i){r();return}s.value=t,n.value=new Float32Array([t.width,t.height]),i.value=0;let l=this.stage.env.lib.config(e.el,"data-umber-swap",a);this.stage.env.tweens.to(i,{value:1,duration:l.duration||0,ease:l.ease,onComplete:r})}fly(a,s,n={}){let i=this.stage,l={...r,...n},u=i.env.kit.ease(l.ease),o=i.env.reducedMotion?0:Math.max(0,l.duration||0)*1e3,d=i.env.reducedMotion?0:Math.max(0,l.stagger||0)*1e3,h=i.env.now;return Promise.all(a.map((r,a)=>new Promise(n=>{let l=s[a];if(!l){r.fly=null,n();return}this.ends.get(r)?.();let f=e(4),w=e(4);f.set(r.radius),w.set(r.radius);let y=r._w,m=y,g=()=>{for(let e=0;e<4;e++){let a=t(r.radius,e);a!==w[e]&&(f[e]=a)}r._w!==m&&(y=r._w)},c=()=>{if(this.ends.get(r)!==c){n();return}this.ends.delete(r),r.fly===p&&(r.fly=null),g(),r.radius.set(f),r._w=y,v(),i.scheduler.markDirty(),n()},v=r.on("destroy",c);this.ends.set(r,c);let p=(e,s,n)=>{let v=o?Math.min(1,Math.max(0,(i.env.now-h-a*d)/o)):1,p=1-u(v);g(),e[0]+=(l[0]-s-e[0])*p,e[1]+=(l[1]-n-e[1])*p,e[2]+=(l[2]-e[2])*p,e[3]+=(l[3]-e[3])*p;for(let e=0;e<4;e++){let a=t(f,e),s=a+(t(l,4+e)-a)*p;w[e]=s,r.radius[e]=s}m=y+(l[8]-y)*p,r._w=m,v<1?i.scheduler.markDirty():c()};r.fly=p,i.scheduler.markDirty()}))).then(()=>{})}lift(e){let t=this.stage,r=e.rect,a=new Float32Array(r);this.ends.get(e)?.();let s={};return["x","y","width","height"].forEach((e,r)=>Object.defineProperty(s,e,{enumerable:!0,get:()=>a[r],set:e=>{a[r]=e||0,t.scheduler.markDirty()}})),e.fly=e=>{e.set(a)},t.scheduler.markDirty(),s}land(e,t){return e.fly?this.fly([e],[this.stage.transitions.where(e)],t):Promise.resolve()}};function n(e){return new s(e)}export{s as Flip,n as flip};