@brett_lamy/ui 3.1.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +4 -4
  2. package/dist/components/animated-height.d.ts +3 -1
  3. package/dist/components/animated-height.d.ts.map +1 -1
  4. package/dist/components/animated-height.js +11 -11
  5. package/dist/components/artifact-chat-container.d.ts.map +1 -1
  6. package/dist/components/artifact-chat-container.js +81 -82
  7. package/dist/components/button.d.ts +4 -3
  8. package/dist/components/button.d.ts.map +1 -1
  9. package/dist/components/button.js +22 -9
  10. package/dist/components/canvas.d.ts +91 -0
  11. package/dist/components/canvas.d.ts.map +1 -0
  12. package/dist/components/canvas.js +296 -0
  13. package/dist/components/composer/composer-cards.d.ts +55 -0
  14. package/dist/components/composer/composer-cards.d.ts.map +1 -0
  15. package/dist/components/composer/composer-cards.js +351 -0
  16. package/dist/components/composer/composer.d.ts +9 -1
  17. package/dist/components/composer/composer.d.ts.map +1 -1
  18. package/dist/components/composer/composer.js +179 -154
  19. package/dist/components/context-menu.d.ts +25 -0
  20. package/dist/components/context-menu.d.ts.map +1 -0
  21. package/dist/components/context-menu.js +127 -0
  22. package/dist/components/credenza.d.ts.map +1 -1
  23. package/dist/components/credenza.js +52 -92
  24. package/dist/components/cron-editor.d.ts +47 -0
  25. package/dist/components/cron-editor.d.ts.map +1 -0
  26. package/dist/components/cron-editor.js +297 -0
  27. package/dist/components/dropdown-menu.d.ts +3 -1
  28. package/dist/components/dropdown-menu.d.ts.map +1 -1
  29. package/dist/components/dropdown-menu.js +5 -5
  30. package/dist/components/edge-drawer.d.ts.map +1 -1
  31. package/dist/components/edge-drawer.js +1 -0
  32. package/dist/components/file-upload.d.ts +121 -0
  33. package/dist/components/file-upload.d.ts.map +1 -0
  34. package/dist/components/file-upload.js +405 -0
  35. package/dist/components/filter-input.d.ts +22 -0
  36. package/dist/components/filter-input.d.ts.map +1 -0
  37. package/dist/components/filter-input.js +126 -0
  38. package/dist/components/filter.d.ts +154 -0
  39. package/dist/components/filter.d.ts.map +1 -0
  40. package/dist/components/filter.js +815 -0
  41. package/dist/components/floating-chat.d.ts.map +1 -1
  42. package/dist/components/floating-chat.js +71 -88
  43. package/dist/components/floating-sheet.d.ts +21 -5
  44. package/dist/components/floating-sheet.d.ts.map +1 -1
  45. package/dist/components/floating-sheet.js +113 -116
  46. package/dist/components/markdown-editor.d.ts +2 -0
  47. package/dist/components/markdown-editor.d.ts.map +1 -1
  48. package/dist/components/markdown-editor.js +46 -45
  49. package/dist/components/markdown-view.d.ts +6 -1
  50. package/dist/components/markdown-view.d.ts.map +1 -1
  51. package/dist/components/markdown-view.js +13 -11
  52. package/dist/components/navigation-stack.d.ts +3 -5
  53. package/dist/components/navigation-stack.d.ts.map +1 -1
  54. package/dist/components/navigation-stack.js +212 -382
  55. package/dist/components/passkey-enroll-dialog.d.ts +36 -0
  56. package/dist/components/passkey-enroll-dialog.d.ts.map +1 -0
  57. package/dist/components/passkey-enroll-dialog.js +234 -0
  58. package/dist/components/result-table.d.ts +38 -0
  59. package/dist/components/result-table.d.ts.map +1 -0
  60. package/dist/components/result-table.js +161 -0
  61. package/dist/components/schema-tree.d.ts +19 -0
  62. package/dist/components/schema-tree.d.ts.map +1 -0
  63. package/dist/components/schema-tree.js +172 -0
  64. package/dist/components/side-drawer.d.ts.map +1 -1
  65. package/dist/components/side-drawer.js +117 -143
  66. package/dist/components/slider.d.ts.map +1 -1
  67. package/dist/components/slider.js +4 -1
  68. package/dist/components/spinner-shapes.d.ts +263 -0
  69. package/dist/components/spinner-shapes.d.ts.map +1 -0
  70. package/dist/components/spinner-shapes.js +771 -0
  71. package/dist/components/spinner.d.ts +133 -3
  72. package/dist/components/spinner.d.ts.map +1 -1
  73. package/dist/components/spinner.js +445 -29
  74. package/dist/components/sql-console.d.ts +28 -0
  75. package/dist/components/sql-console.d.ts.map +1 -0
  76. package/dist/components/sql-console.js +348 -0
  77. package/dist/components/sql-editor.d.ts +47 -0
  78. package/dist/components/sql-editor.d.ts.map +1 -0
  79. package/dist/components/sql-editor.js +170 -0
  80. package/dist/components/tab-view.d.ts +2 -2
  81. package/dist/components/tab-view.d.ts.map +1 -1
  82. package/dist/components/tab-view.js +63 -49
  83. package/dist/components/tailscale-login-button.d.ts +53 -0
  84. package/dist/components/tailscale-login-button.d.ts.map +1 -0
  85. package/dist/components/tailscale-login-button.js +197 -0
  86. package/dist/components/time-input.d.ts +46 -0
  87. package/dist/components/time-input.d.ts.map +1 -0
  88. package/dist/components/time-input.js +258 -0
  89. package/dist/components/toast.d.ts +5 -2
  90. package/dist/components/toast.d.ts.map +1 -1
  91. package/dist/components/toast.js +249 -125
  92. package/dist/components/vault-gate.d.ts +60 -0
  93. package/dist/components/vault-gate.d.ts.map +1 -0
  94. package/dist/components/vault-gate.js +382 -0
  95. package/dist/index.css +1 -1
  96. package/dist/index.d.ts +86 -7
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +129 -85
  99. package/dist/lib/back-history.d.ts +5 -0
  100. package/dist/lib/back-history.d.ts.map +1 -0
  101. package/dist/lib/back-history.js +44 -0
  102. package/dist/lib/canvas-math.d.ts +82 -0
  103. package/dist/lib/canvas-math.d.ts.map +1 -0
  104. package/dist/lib/canvas-math.js +226 -0
  105. package/dist/lib/controllable-state.d.ts +4 -0
  106. package/dist/lib/controllable-state.d.ts.map +1 -0
  107. package/dist/lib/controllable-state.js +11 -0
  108. package/dist/lib/cron.d.ts +55 -0
  109. package/dist/lib/cron.d.ts.map +1 -0
  110. package/dist/lib/cron.js +269 -0
  111. package/dist/lib/edge-swipe.d.ts +36 -0
  112. package/dist/lib/edge-swipe.d.ts.map +1 -0
  113. package/dist/lib/edge-swipe.js +73 -0
  114. package/dist/lib/file-upload.d.ts +187 -0
  115. package/dist/lib/file-upload.d.ts.map +1 -0
  116. package/dist/lib/file-upload.js +349 -0
  117. package/dist/lib/filter-query.d.ts +90 -0
  118. package/dist/lib/filter-query.d.ts.map +1 -0
  119. package/dist/lib/filter-query.js +459 -0
  120. package/dist/lib/filter.d.ts +120 -0
  121. package/dist/lib/filter.d.ts.map +1 -0
  122. package/dist/lib/filter.js +399 -0
  123. package/dist/lib/format-bytes.d.ts +3 -0
  124. package/dist/lib/format-bytes.d.ts.map +1 -0
  125. package/dist/lib/format-bytes.js +16 -0
  126. package/dist/lib/gpu-cron.d.ts +51 -0
  127. package/dist/lib/gpu-cron.d.ts.map +1 -0
  128. package/dist/lib/gpu-cron.js +81 -0
  129. package/dist/lib/gpu-query/featurize.d.ts +19 -0
  130. package/dist/lib/gpu-query/featurize.d.ts.map +1 -0
  131. package/dist/lib/gpu-query/featurize.js +88 -0
  132. package/dist/lib/gpu-query/index.d.ts +73 -0
  133. package/dist/lib/gpu-query/index.d.ts.map +1 -0
  134. package/dist/lib/gpu-query/index.js +117 -0
  135. package/dist/lib/gpu-query/kernel.wgsl.d.ts +30 -0
  136. package/dist/lib/gpu-query/kernel.wgsl.d.ts.map +1 -0
  137. package/dist/lib/gpu-query/model.d.ts +8 -0
  138. package/dist/lib/gpu-query/model.d.ts.map +1 -0
  139. package/dist/lib/gpu-query/model.js +91 -0
  140. package/dist/lib/gpu-query/schema.d.ts +40 -0
  141. package/dist/lib/gpu-query/schema.d.ts.map +1 -0
  142. package/dist/lib/gpu-query/schema.js +0 -0
  143. package/dist/lib/gpu-query/webgpu.d.ts +12 -0
  144. package/dist/lib/gpu-query/webgpu.d.ts.map +1 -0
  145. package/dist/lib/gpu-query/weights.d.ts +17 -0
  146. package/dist/lib/gpu-query/weights.d.ts.map +1 -0
  147. package/dist/lib/gpu-query/weights.js +40 -0
  148. package/dist/lib/gpu-query/weights.json.d.ts +3 -0
  149. package/dist/lib/gpu-query/weights2.js +25 -0
  150. package/dist/lib/gpu-time.d.ts +77 -0
  151. package/dist/lib/gpu-time.d.ts.map +1 -0
  152. package/dist/lib/gpu-time.js +260 -0
  153. package/dist/lib/morph-path.d.ts +22 -0
  154. package/dist/lib/morph-path.d.ts.map +1 -0
  155. package/dist/lib/morph-path.js +42 -0
  156. package/dist/lib/passkey.d.ts +120 -0
  157. package/dist/lib/passkey.d.ts.map +1 -0
  158. package/dist/lib/passkey.js +186 -0
  159. package/dist/lib/persistent-state.d.ts +9 -0
  160. package/dist/lib/persistent-state.d.ts.map +1 -0
  161. package/dist/lib/persistent-state.js +37 -0
  162. package/dist/lib/pglite-core.d.ts +219 -0
  163. package/dist/lib/pglite-core.d.ts.map +1 -0
  164. package/dist/lib/pglite-core.js +273 -0
  165. package/dist/lib/pglite-files.d.ts +7 -0
  166. package/dist/lib/pglite-files.d.ts.map +1 -0
  167. package/dist/lib/pglite-files.js +17 -0
  168. package/dist/lib/pglite-schema.d.ts +58 -0
  169. package/dist/lib/pglite-schema.d.ts.map +1 -0
  170. package/dist/lib/pglite-schema.js +105 -0
  171. package/dist/lib/pglite-storage.d.ts +33 -0
  172. package/dist/lib/pglite-storage.d.ts.map +1 -0
  173. package/dist/lib/pglite-storage.js +55 -0
  174. package/dist/lib/pglite-transfer.d.ts +53 -0
  175. package/dist/lib/pglite-transfer.d.ts.map +1 -0
  176. package/dist/lib/pglite-transfer.js +126 -0
  177. package/dist/lib/pglite.d.ts +106 -0
  178. package/dist/lib/pglite.d.ts.map +1 -0
  179. package/dist/lib/pglite.js +298 -0
  180. package/dist/lib/pull-to-refresh.d.ts +24 -0
  181. package/dist/lib/pull-to-refresh.d.ts.map +1 -0
  182. package/dist/lib/pull-to-refresh.js +74 -0
  183. package/dist/lib/scroll-hidden.d.ts +6 -0
  184. package/dist/lib/scroll-hidden.d.ts.map +1 -0
  185. package/dist/lib/scroll-hidden.js +21 -0
  186. package/dist/lib/sheet-drag.d.ts +10 -2
  187. package/dist/lib/sheet-drag.d.ts.map +1 -1
  188. package/dist/lib/sheet-drag.js +72 -69
  189. package/dist/lib/sql-format.d.ts +62 -0
  190. package/dist/lib/sql-format.d.ts.map +1 -0
  191. package/dist/lib/sql-format.js +175 -0
  192. package/dist/lib/sql-lex.d.ts +25 -0
  193. package/dist/lib/sql-lex.d.ts.map +1 -0
  194. package/dist/lib/sql-lex.js +135 -0
  195. package/dist/lib/tab-lock.d.ts +28 -0
  196. package/dist/lib/tab-lock.d.ts.map +1 -0
  197. package/dist/lib/tab-lock.js +80 -0
  198. package/dist/lib/tailscale-connect.d.ts +56 -0
  199. package/dist/lib/tailscale-connect.d.ts.map +1 -0
  200. package/dist/lib/tailscale-connect.js +99 -0
  201. package/dist/lib/tailscale-fake.d.ts +33 -0
  202. package/dist/lib/tailscale-fake.d.ts.map +1 -0
  203. package/dist/lib/tailscale-fake.js +80 -0
  204. package/dist/lib/tailscale-policy.d.ts +71 -0
  205. package/dist/lib/tailscale-policy.d.ts.map +1 -0
  206. package/dist/lib/tailscale-policy.js +244 -0
  207. package/dist/lib/tailscale-react.d.ts +20 -0
  208. package/dist/lib/tailscale-react.d.ts.map +1 -0
  209. package/dist/lib/tailscale-react.js +37 -0
  210. package/dist/lib/tailscale-router/bridge.d.ts +60 -0
  211. package/dist/lib/tailscale-router/bridge.d.ts.map +1 -0
  212. package/dist/lib/tailscale-router/bridge.js +198 -0
  213. package/dist/lib/tailscale-router/react.d.ts +19 -0
  214. package/dist/lib/tailscale-router/react.d.ts.map +1 -0
  215. package/dist/lib/tailscale-router/react.js +52 -0
  216. package/dist/lib/tailscale.d.ts +204 -0
  217. package/dist/lib/tailscale.d.ts.map +1 -0
  218. package/dist/lib/tailscale.js +443 -0
  219. package/dist/lib/title-flight.d.ts +34 -0
  220. package/dist/lib/title-flight.d.ts.map +1 -0
  221. package/dist/lib/title-flight.js +123 -0
  222. package/dist/lib/vault-react.d.ts +49 -0
  223. package/dist/lib/vault-react.d.ts.map +1 -0
  224. package/dist/lib/vault-react.js +196 -0
  225. package/dist/lib/vault-storage.d.ts +30 -0
  226. package/dist/lib/vault-storage.d.ts.map +1 -0
  227. package/dist/lib/vault-storage.js +105 -0
  228. package/dist/lib/vault.d.ts +200 -0
  229. package/dist/lib/vault.d.ts.map +1 -0
  230. package/dist/lib/vault.js +641 -0
  231. package/dist/tailscale-sw.js +332 -0
  232. package/package.json +35 -5
  233. package/dist/components/icon-button.d.ts +0 -19
  234. package/dist/components/icon-button.d.ts.map +0 -1
  235. package/dist/components/icon-button.js +0 -31
  236. package/dist/components/measure-h.d.ts +0 -7
  237. package/dist/components/measure-h.d.ts.map +0 -1
  238. package/dist/components/measure-h.js +0 -20
  239. package/dist/components/snap-sheet.d.ts +0 -13
  240. package/dist/components/snap-sheet.d.ts.map +0 -1
  241. package/dist/components/snap-sheet.js +0 -100
@@ -0,0 +1,332 @@
1
+ /* BL UI — Tailscale request router (service worker). https://blamy.github.io/ui/#/tailscale-router
2
+ *
3
+ * Serve this file from your site's root (copy it to `public/`) and register it with `registerTailscaleRouter` from
4
+ * lib/tailscale-router/bridge. It intercepts the fetches of the pages it controls; the ones that match its policy are
5
+ * handed to a page that is connected to the tailnet (over a MessagePort), and the answer is streamed back. Everything
6
+ * else is left alone: the worker does not call respondWith for it, so the browser handles it as if there were no worker.
7
+ *
8
+ * The policy is read from this script's own URL (`?p=`, written by registerTailscaleRouter), never from a message: it
9
+ * is known the moment the worker wakes up, and changing it means registering a new script. It is the same matching as
10
+ * lib/tailscale-policy.ts (`matchTailscalePolicy`); the two are tested against one set of cases. Classic script, no
11
+ * imports, no build step. MIT licensed, like the rest of BL UI. */
12
+
13
+
14
+
15
+ (function () {
16
+ const VERSION = 1;
17
+ const PREFIX = 'bl-ts/';
18
+ const sw = self;
19
+
20
+ /* ── policy (mirrors lib/tailscale-policy.ts) ── */
21
+
22
+ const DEFAULT_POLICY = {
23
+ v: 1, intercept: 'tailnet', hosts: [], cidrs: [], shortNames: false, exclude: [], schemes: ['http', 'https'], methods: null,
24
+ sameOrigin: false, whenUnavailable: 'network', maxBodyBytes: 32 * 1024 * 1024, timeoutMs: 60000,
25
+ };
26
+
27
+ function parseIPv4(text) {
28
+ const parts = text.split('.');
29
+ if (parts.length !== 4) return null;
30
+ let value = 0n;
31
+ for (let i = 0; i < 4; i++) {
32
+ if (!/^\d{1,3}$/.test(parts[i])) return null;
33
+ const n = Number(parts[i]);
34
+ if (n > 255) return null;
35
+ value = (value << 8n) | BigInt(n);
36
+ }
37
+ return value;
38
+ }
39
+
40
+ function parseIPv6(input) {
41
+ let text = input;
42
+ if (!/^[0-9a-f:.]+$/i.test(text) || text.indexOf(':') < 0) return null;
43
+ if (text.lastIndexOf('.') >= 0) {
44
+ const colon = text.lastIndexOf(':');
45
+ const v4 = parseIPv4(text.slice(colon + 1));
46
+ if (v4 === null) return null;
47
+ text = text.slice(0, colon + 1) + (v4 >> 16n).toString(16) + ':' + (v4 & 0xffffn).toString(16);
48
+ }
49
+ const halves = text.split('::');
50
+ if (halves.length > 2) return null;
51
+ const groups = function (s) { return s === '' ? [] : s.split(':'); };
52
+ const head = groups(halves[0]);
53
+ const tail = halves.length === 2 ? groups(halves[1]) : [];
54
+ const missing = 8 - head.length - tail.length;
55
+ if (halves.length === 2 ? missing < 1 : missing !== 0) return null;
56
+ const all = head.concat(halves.length === 2 ? new Array(missing).fill('0') : [], tail);
57
+ let value = 0n;
58
+ for (let i = 0; i < all.length; i++) {
59
+ if (!/^[0-9a-f]{1,4}$/i.test(all[i])) return null;
60
+ value = (value << 16n) | BigInt(parseInt(all[i], 16));
61
+ }
62
+ return value;
63
+ }
64
+
65
+ function parseAddress(host) {
66
+ const bare = host.charAt(0) === '[' && host.charAt(host.length - 1) === ']' ? host.slice(1, -1) : host;
67
+ const v4 = parseIPv4(bare);
68
+ if (v4 !== null) return { family: 4, value: v4 };
69
+ const v6 = parseIPv6(bare);
70
+ return v6 !== null ? { family: 6, value: v6 } : null;
71
+ }
72
+
73
+ function parseCidr(text) {
74
+ const parts = text.split('/');
75
+ if (parts.length > 2) return null;
76
+ const a = parseAddress(parts[0]);
77
+ if (!a) return null;
78
+ const max = a.family === 4 ? 32 : 128;
79
+ const prefix = parts.length === 1 ? max : /^\d{1,3}$/.test(parts[1]) ? Number(parts[1]) : -1;
80
+ if (prefix < 0 || prefix > max) return null;
81
+ return { family: a.family, value: a.value, prefix: prefix };
82
+ }
83
+
84
+ function inCidr(a, c) {
85
+ if (a.family !== c.family) return false;
86
+ const shift = BigInt((a.family === 4 ? 32 : 128) - c.prefix);
87
+ return a.value >> shift === c.value >> shift;
88
+ }
89
+
90
+ const TAILNET_V4 = { family: 4, value: (100n << 24n) | (64n << 16n), prefix: 10 };
91
+ const TAILNET_V6 = { family: 6, value: 0xfd7a115ca1e0n << 80n, prefix: 48 };
92
+ const LOOPBACK_V4 = { family: 4, value: 127n << 24n, prefix: 8 };
93
+ const LOOPBACK_V6 = { family: 6, value: 1n, prefix: 128 };
94
+
95
+ function matchesPattern(host, pattern) {
96
+ if (pattern.slice(0, 2) === '*.') return host.endsWith(pattern.slice(1));
97
+ if (pattern.charAt(0) === '.') return host === pattern.slice(1) || host.endsWith(pattern);
98
+ return host === pattern;
99
+ }
100
+
101
+ function hostIn(host, addr, list) {
102
+ for (let i = 0; i < list.length; i++) {
103
+ const entry = list[i];
104
+ if (entry.indexOf('/') >= 0) {
105
+ const c = parseCidr(entry);
106
+ if (c && addr && inCidr(addr, c)) return true;
107
+ } else if (matchesPattern(host, entry)) return true;
108
+ }
109
+ return false;
110
+ }
111
+
112
+ function match(url, method, policy, origin) {
113
+ let u;
114
+ try { u = new URL(url, origin); } catch { return { route: false, reason: 'invalid-url' }; }
115
+ const scheme = u.protocol.slice(0, -1);
116
+ if ((scheme !== 'http' && scheme !== 'https') || policy.schemes.indexOf(scheme) < 0) return { route: false, reason: 'scheme' };
117
+ if (!policy.sameOrigin && origin !== undefined && u.origin === origin) return { route: false, reason: 'same-origin' };
118
+ const host = u.hostname.toLowerCase();
119
+ const addr = parseAddress(host);
120
+ if (host === 'localhost' || host.endsWith('.localhost') || (addr && (inCidr(addr, LOOPBACK_V4) || inCidr(addr, LOOPBACK_V6)))) return { route: false, reason: 'loopback' };
121
+ if (policy.methods && policy.methods.indexOf(method.toUpperCase()) < 0) return { route: false, reason: 'method' };
122
+ if (hostIn(host, addr, policy.exclude)) return { route: false, reason: 'excluded' };
123
+ if (policy.intercept === 'all') return { route: true, reason: 'all' };
124
+ if (host.endsWith('.ts.net')) return { route: true, reason: 'tailnet-name' };
125
+ if (addr && (inCidr(addr, TAILNET_V4) || inCidr(addr, TAILNET_V6))) return { route: true, reason: 'tailnet-address' };
126
+ if (hostIn(host, addr, policy.hosts)) return { route: true, reason: 'host' };
127
+ if (hostIn(host, addr, policy.cidrs)) return { route: true, reason: 'cidr' };
128
+ if (policy.shortNames && addr === null && host.indexOf('.') < 0 && host !== '') return { route: true, reason: 'short-name' };
129
+ return { route: false, reason: 'no-match' };
130
+ }
131
+
132
+ function readPolicy() {
133
+ try {
134
+ const p = new URL(sw.location.href).searchParams.get('p');
135
+ if (!p) return DEFAULT_POLICY;
136
+ const binary = atob(p.replace(/-/g, '+').replace(/_/g, '/'));
137
+ const bytes = Uint8Array.from(binary, function (ch) { return ch.charCodeAt(0); });
138
+ const parsed = JSON.parse(new TextDecoder().decode(bytes));
139
+ if (!parsed || parsed.v !== 1) return DEFAULT_POLICY;
140
+ const out = {};
141
+ for (const k in DEFAULT_POLICY) out[k] = parsed[k] !== undefined ? parsed[k] : DEFAULT_POLICY[k];
142
+ if (out.intercept !== 'all') out.intercept = 'tailnet';
143
+ if (out.whenUnavailable !== 'error') out.whenUnavailable = 'network';
144
+ return out;
145
+ } catch {
146
+ return DEFAULT_POLICY;
147
+ }
148
+ }
149
+
150
+ const policy = readPolicy();
151
+
152
+ /* ── owners: pages connected to the tailnet ── */
153
+
154
+ // clientId → { port, connected }
155
+ const owners = new Map();
156
+ let waiters = [];
157
+ let nextId = 1;
158
+ const pending = new Map();
159
+
160
+ function pickOwner() {
161
+ let found = null;
162
+ owners.forEach(function (o) { if (o.connected) found = o; });
163
+ return found;
164
+ }
165
+
166
+ function notifyWaiters() {
167
+ const o = pickOwner();
168
+ if (!o) return;
169
+ const list = waiters;
170
+ waiters = [];
171
+ list.forEach(function (w) { w(o); });
172
+ }
173
+
174
+ /** The page to ask: a connected one if there is one, else any attached page (it answers `unavailable` itself when it
175
+ * is not connected, so a status update still in flight cannot misroute a request). With no page attached at all (the
176
+ * worker was restarted and lost its ports), ask every window to re-attach and wait a little. */
177
+ function waitForOwner(ms) {
178
+ let o = pickOwner();
179
+ if (!o) owners.forEach(function (x) { o = x; });
180
+ if (o) return Promise.resolve(o);
181
+ return new Promise(function (resolve) {
182
+ let done = false;
183
+ const w = function (owner) { if (!done) { done = true; resolve(owner); } };
184
+ waiters.push(w);
185
+ setTimeout(function () { if (!done) { done = true; waiters = waiters.filter(function (x) { return x !== w; }); resolve(null); } }, ms);
186
+ sw.clients.matchAll({ type: 'window', includeUncontrolled: false }).then(function (list) {
187
+ list.forEach(function (c) { c.postMessage({ type: PREFIX + 'needs-attach', v: VERSION }); });
188
+ });
189
+ });
190
+ }
191
+
192
+ function onPortMessage(clientId, entry, event) {
193
+ const m = event.data || {};
194
+ if (m.type === 'status') {
195
+ entry.connected = m.connected === true;
196
+ if (entry.connected) notifyWaiters();
197
+ return;
198
+ }
199
+ const p = pending.get(m.id);
200
+ if (!p) return;
201
+ p.handle(m);
202
+ }
203
+
204
+ sw.addEventListener('install', function () { sw.skipWaiting(); });
205
+ sw.addEventListener('activate', function (event) { event.waitUntil(sw.clients.claim()); });
206
+
207
+ sw.addEventListener('message', function (event) {
208
+ const m = event.data || {};
209
+ const source = event.source;
210
+ // Only top-level windows of this origin may serve requests: not iframes, not workers.
211
+ if (!source || source.type !== 'window' || source.frameType === 'nested') return;
212
+ if (event.origin && event.origin !== sw.location.origin) return;
213
+ if (m.type === PREFIX + 'attach' && event.ports && event.ports[0]) {
214
+ const old = owners.get(source.id);
215
+ if (old) try { old.port.close(); } catch { /* ignore */ }
216
+ const entry = { port: event.ports[0], connected: m.connected === true };
217
+ owners.set(source.id, entry);
218
+ entry.port.onmessage = function (e) { onPortMessage(source.id, entry, e); };
219
+ entry.port.postMessage({ type: 'attached', v: VERSION, policy: policy });
220
+ if (entry.connected) notifyWaiters();
221
+ } else if (m.type === PREFIX + 'detach') {
222
+ const gone = owners.get(source.id);
223
+ if (gone) try { gone.port.close(); } catch { /* ignore */ }
224
+ owners.delete(source.id);
225
+ }
226
+ });
227
+
228
+ /* ── requests ── */
229
+
230
+ const NULL_BODY = { 101: 1, 103: 1, 204: 1, 205: 1, 304: 1 };
231
+
232
+ function unavailable(request, why) {
233
+ if (policy.whenUnavailable === 'error') {
234
+ return new Response('Tailscale is not connected (' + why + ').', {
235
+ status: 503, statusText: 'Tailscale unavailable', headers: { 'content-type': 'text/plain; charset=utf-8', 'x-bl-tailscale': 'unavailable' },
236
+ });
237
+ }
238
+ return fetch(request);
239
+ }
240
+
241
+ function withCors(headers, request) {
242
+ if (request.mode !== 'cors') return;
243
+ const origin = sw.location.origin;
244
+ if (new URL(request.url).origin === origin) return;
245
+ const names = [];
246
+ headers.forEach(function (_, k) { names.push(k); });
247
+ headers.set('access-control-allow-origin', origin);
248
+ headers.set('access-control-allow-credentials', 'true');
249
+ headers.set('access-control-expose-headers', names.concat('x-bl-tailscale').join(', '));
250
+ headers.append('vary', 'Origin');
251
+ }
252
+
253
+ function route(event) {
254
+ const request = event.request;
255
+ const bodyPromise = request.method === 'GET' || request.method === 'HEAD' ? Promise.resolve(null) : request.clone().arrayBuffer();
256
+ return Promise.all([bodyPromise, waitForOwner(1500)]).then(function (got) {
257
+ const body = got[0];
258
+ const owner = got[1];
259
+ if (body && body.byteLength > policy.maxBodyBytes) return unavailable(request, 'request body too large');
260
+ if (!owner) return unavailable(request, 'no connected page');
261
+ const id = nextId++;
262
+ const headers = [];
263
+ request.headers.forEach(function (v, k) { if (k !== 'cookie') headers.push([k, v]); });
264
+ return new Promise(function (resolve, reject) {
265
+ let controller = null;
266
+ let settled = false;
267
+ const timer = setTimeout(function () {
268
+ if (settled) return;
269
+ settled = true;
270
+ pending.delete(id);
271
+ owner.port.postMessage({ type: 'cancel', id: id });
272
+ resolve(new Response('The tailnet did not answer in time.', { status: 504, headers: { 'content-type': 'text/plain', 'x-bl-tailscale': 'timeout' } }));
273
+ }, policy.timeoutMs);
274
+ const cancel = function () {
275
+ if (!pending.has(id)) return;
276
+ pending.delete(id);
277
+ owner.port.postMessage({ type: 'cancel', id: id });
278
+ };
279
+ if (request.signal) request.signal.addEventListener('abort', cancel);
280
+ pending.set(id, {
281
+ handle: function (m) {
282
+ if (m.type === 'head') {
283
+ settled = true;
284
+ clearTimeout(timer);
285
+ const h = new Headers();
286
+ (m.headers || []).forEach(function (pair) { try { h.append(pair[0], pair[1]); } catch { /* forbidden */ } });
287
+ h.set('x-bl-tailscale', 'routed');
288
+ withCors(h, request);
289
+ const status = m.status >= 200 && m.status <= 599 ? m.status : 502;
290
+ const stream = NULL_BODY[status] || request.method === 'HEAD' ? null : new ReadableStream({
291
+ start: function (c) { controller = c; },
292
+ cancel: cancel,
293
+ });
294
+ if (!stream) pending.delete(id);
295
+ resolve(new Response(stream, { status: status, statusText: m.statusText || '', headers: h }));
296
+ } else if (m.type === 'chunk') {
297
+ if (controller && m.data) controller.enqueue(new Uint8Array(m.data));
298
+ } else if (m.type === 'end') {
299
+ pending.delete(id);
300
+ if (controller) controller.close();
301
+ } else if (m.type === 'error') {
302
+ pending.delete(id);
303
+ clearTimeout(timer);
304
+ if (controller) controller.error(new TypeError(m.message || 'Tailscale request failed'));
305
+ else if (!settled) { settled = true; reject(new TypeError(m.message || 'Tailscale request failed')); }
306
+ } else if (m.type === 'passthrough' || m.type === 'unavailable') {
307
+ pending.delete(id);
308
+ clearTimeout(timer);
309
+ if (!settled) { settled = true; resolve(m.type === 'passthrough' ? fetch(request) : unavailable(request, 'disconnected')); }
310
+ }
311
+ },
312
+ });
313
+ const message = {
314
+ type: 'request', id: id, url: request.url, method: request.method, headers: headers, body: body,
315
+ redirect: request.redirect, credentials: request.credentials, mode: request.mode, destination: request.destination,
316
+ };
317
+ owner.port.postMessage(message, body ? [body] : []);
318
+ });
319
+ });
320
+ }
321
+
322
+ sw.addEventListener('fetch', function (event) {
323
+ const request = event.request;
324
+ if (request.mode === 'navigate') return; // a navigation is the page itself, never the tailnet's
325
+ const m = match(request.url, request.method, policy, sw.location.origin);
326
+ if (!m.route) return; // not ours: the browser handles it as if there were no worker
327
+ event.respondWith(route(event));
328
+ });
329
+
330
+ // For the unit tests (and curious readers in devtools): the matcher and the policy this worker runs with.
331
+ sw.__blTailscaleRouter = { version: VERSION, policy: policy, match: match };
332
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brett_lamy/ui",
3
- "version": "3.1.0",
3
+ "version": "5.0.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -20,6 +20,10 @@
20
20
  "./theme.css": {
21
21
  "@org/source": "./src/theme.css",
22
22
  "default": "./dist/theme.css"
23
+ },
24
+ "./tailscale-sw.js": {
25
+ "@org/source": "./src/lib/tailscale-router/tailscale-sw.js",
26
+ "default": "./dist/tailscale-sw.js"
23
27
  }
24
28
  },
25
29
  "dependencies": {
@@ -36,8 +40,11 @@
36
40
  "@tiptap/suggestion": "3.30.5",
37
41
  "class-variance-authority": "^0.7",
38
42
  "clsx": "^2",
43
+ "cronstrue": "^3.27.0",
39
44
  "framer-motion": "^12 || ^13",
45
+ "gpu-cron": "0.1.1",
40
46
  "gpu-lexer": "0.0.3",
47
+ "gpu-time": "0.5.0",
41
48
  "perfect-freehand": "^1.2.2",
42
49
  "react-aria": "^3.51.0",
43
50
  "react-aria-components": "^1",
@@ -45,10 +52,24 @@
45
52
  "tailwind-merge": "^3"
46
53
  },
47
54
  "peerDependencies": {
48
- "react": "^18 || ^19",
49
- "react-dom": "^18 || ^19"
55
+ "@agent-wasm/tailscale-connect": "^1.39.98-t02582083d",
56
+ "@electric-sql/pglite": "^0.5.8",
57
+ "@electric-sql/pglite-tools": "^0.4.8",
58
+ "react": "^19",
59
+ "react-dom": "^19"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "@agent-wasm/tailscale-connect": {
63
+ "optional": true
64
+ },
65
+ "@electric-sql/pglite": {
66
+ "optional": true
67
+ },
68
+ "@electric-sql/pglite-tools": {
69
+ "optional": true
70
+ }
50
71
  },
51
- "description": "iOS-flavored React components on react-aria-components, Tailwind v4 and cva — containers, lists, tokens, Composer, PencilKit. Also a shadcn registry (source-copy items and app blocks).",
72
+ "description": "iOS-flavored React components on react-aria-components, Tailwind v4 and cva \u2014 containers, lists, tokens, Composer, PencilKit. Also a shadcn registry (source-copy items and app blocks).",
52
73
  "license": "MIT",
53
74
  "sideEffects": [
54
75
  "*.css"
@@ -67,5 +88,14 @@
67
88
  "react-aria",
68
89
  "shadcn",
69
90
  "components"
70
- ]
91
+ ],
92
+ "devDependencies": {
93
+ "@agent-wasm/tailscale-connect": "1.39.98-t02582083d",
94
+ "@electric-sql/pglite": "0.5.8",
95
+ "@electric-sql/pglite-tools": "0.4.8",
96
+ "@testing-library/dom": "^10.4.2",
97
+ "@testing-library/react": "^16.3.3",
98
+ "fake-indexeddb": "^6.2.5",
99
+ "happy-dom": "^20.14.5"
100
+ }
71
101
  }
@@ -1,19 +0,0 @@
1
- import { IconName } from '../lib/icon';
2
- import * as React from 'react';
3
- /** Square icon button: transparent until hovered, filled while `active`. */
4
- export declare const iconButtonVariants: (props?: ({
5
- active?: boolean | null | undefined;
6
- } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
- export interface IconButtonProps {
8
- /** An `Icon` name. */
9
- name: IconName | (string & {});
10
- label: string;
11
- onPress?: () => void;
12
- /** Glyph size in px. Default 18. */
13
- size?: number;
14
- active?: boolean;
15
- className?: string;
16
- style?: React.CSSProperties;
17
- }
18
- export declare function IconButton({ name, label, onPress, size, active, className, style }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
19
- //# sourceMappingURL=icon-button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/components/icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB;;8EAQ7B,CAAC;AAEH,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,IAAI,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AACD,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,eAAe,2CAanG"}
@@ -1,31 +0,0 @@
1
- import { cn as e, pressable as t } from "../lib/utils.js";
2
- import { Icon as n } from "../lib/icon.js";
3
- import { PlainButton as r } from "./plain-button.js";
4
- import "react";
5
- import { jsx as i } from "react/jsx-runtime";
6
- import { cva as a } from "class-variance-authority";
7
- //#region src/components/icon-button.tsx
8
- var o = a(e(t, "grid cursor-pointer place-items-center rounded-[7px] border-0 p-[5px] hover:bg-secondary!"), {
9
- variants: { active: {
10
- true: "bg-secondary text-foreground",
11
- false: "bg-transparent text-muted-foreground"
12
- } },
13
- defaultVariants: { active: !1 }
14
- });
15
- function s({ name: t, label: a, onPress: s, size: c, active: l, className: u, style: d }) {
16
- return /* @__PURE__ */ i(r, {
17
- "data-slot": "icon-button",
18
- className: e(o({ active: !!l }), u),
19
- onPress: s,
20
- "aria-label": a,
21
- title: a,
22
- style: d,
23
- children: /* @__PURE__ */ i(n, {
24
- name: t,
25
- size: c || 18,
26
- sw: 1.7
27
- })
28
- });
29
- }
30
- //#endregion
31
- export { s as IconButton, o as iconButtonVariants };
@@ -1,7 +0,0 @@
1
- import { ReactNode } from 'react';
2
- /** Internal: reports its rendered height (used by Credenza's morphing body). */
3
- export declare function MeasureH({ onH, children }: {
4
- onH: (h: number) => void;
5
- children?: ReactNode;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- //# sourceMappingURL=measure-h.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"measure-h.d.ts","sourceRoot":"","sources":["../../src/components/measure-h.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhE,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;IAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,2CAW7F"}
@@ -1,20 +0,0 @@
1
- "use client";
2
- import { useLayoutEffect as e, useRef as t } from "react";
3
- import { jsx as n } from "react/jsx-runtime";
4
- //#region src/components/measure-h.tsx
5
- function r({ onH: r, children: i }) {
6
- let a = t(null);
7
- return e(() => {
8
- let e = a.current;
9
- if (!e || (r(e.offsetHeight), typeof ResizeObserver > "u")) return;
10
- let t = new ResizeObserver(() => {
11
- a.current && r(a.current.offsetHeight);
12
- });
13
- return t.observe(e), () => t.disconnect();
14
- }, [i]), /* @__PURE__ */ n("div", {
15
- ref: a,
16
- children: i
17
- });
18
- }
19
- //#endregion
20
- export { r as MeasureH };
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
- export interface SnapSheetProps {
3
- open: boolean;
4
- onClose: () => void;
5
- snaps?: number[];
6
- children?: React.ReactNode;
7
- /** Classes for the sheet surface (the panel), merged last — e.g. `bg-background` for a surface other than `bg-card`. */
8
- className?: string;
9
- /** Styles for the sheet surface (the panel). */
10
- style?: React.CSSProperties;
11
- }
12
- export declare function SnapSheet({ open, onClose, snaps: snapsProp, children, className, style }: SnapSheetProps): import("react/jsx-runtime").JSX.Element | null;
13
- //# sourceMappingURL=snap-sheet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snap-sheet.d.ts","sourceRoot":"","sources":["../../src/components/snap-sheet.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,wHAAwH;IACxH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AACD,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,cAAc,kDA+GxG"}
@@ -1,100 +0,0 @@
1
- "use client";
2
- import { cn as e } from "../lib/utils.js";
3
- import { prefersReducedMotion as t, springs as n } from "../lib/motion.js";
4
- import { animate as r, motion as i, useMotionValue as a, useTransform as o } from "framer-motion";
5
- import * as s from "react";
6
- import { useEffect as c, useRef as l, useState as u } from "react";
7
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
- //#region src/components/snap-sheet.tsx
9
- function p({ open: p, onClose: m, snaps: h, children: g, className: _, style: v }) {
10
- let y = h || [.55, .94], b = Math.max(...y), [x, S] = u(!1), C = l(null), w = a(1e4), T = l(null), E = l({
11
- drag: !1,
12
- y0: 0,
13
- ty0: 0,
14
- samples: []
15
- }), D = () => C.current ? C.current.offsetHeight : 700, O = (e) => D() * (b - y[e]), k = o(w, (e) => {
16
- let t = D();
17
- return Math.min(1, Math.max(0, (b - e / t) / b));
18
- }), A = (e, i = 0, a) => {
19
- if (T.current?.stop(), t()) {
20
- w.set(e), a?.();
21
- return;
22
- }
23
- T.current = r(w, e, {
24
- ...n.tray,
25
- velocity: i,
26
- onComplete: a
27
- });
28
- };
29
- if (c(() => {
30
- p ? S(!0) : x && A(D() * b, 0, () => S(!1));
31
- }, [p]), s.useLayoutEffect(() => {
32
- !x || !p || (w.set(D() * b), A(O(0)));
33
- }, [x]), c(() => () => T.current?.stop(), []), !p && !x) return null;
34
- let j = (e) => {
35
- T.current?.stop(), E.current = {
36
- drag: !0,
37
- y0: e.clientY,
38
- ty0: w.get(),
39
- samples: [{
40
- t: e.timeStamp,
41
- y: e.clientY
42
- }]
43
- }, e.currentTarget.setPointerCapture(e.pointerId);
44
- }, M = (e) => {
45
- let t = E.current;
46
- if (!t.drag) return;
47
- t.samples.push({
48
- t: e.timeStamp,
49
- y: e.clientY
50
- }), t.samples.length > 6 && t.samples.shift();
51
- let n = t.ty0 + (e.clientY - t.y0), r = O(y.indexOf(b));
52
- n < r && (n = r - (r - n) ** .72), w.set(Math.max(0, n));
53
- }, N = (e) => {
54
- let t = E.current;
55
- if (!t.drag) return;
56
- t.drag = !1;
57
- let n = t.samples.filter((t) => e.timeStamp - t.t < 90)[0] ?? t.samples[0], r = n ? (e.clientY - n.y) / Math.max(1, e.timeStamp - n.t) : 0, i = w.get() + r * 200, a = D(), o = -1, s = Infinity;
58
- if (y.forEach((e, t) => {
59
- let n = Math.abs(i - a * (b - e));
60
- n < s && (s = n, o = t);
61
- }), Math.abs(i - a * b) < s || i > a * (b - Math.min(...y)) + a * .12) {
62
- A(a * b, r * 1e3), m();
63
- return;
64
- }
65
- A(O(o), r * 1e3);
66
- };
67
- return /* @__PURE__ */ f("div", {
68
- ref: C,
69
- "data-slot": "snap-sheet",
70
- className: "absolute inset-0 z-70 overflow-hidden",
71
- children: [/* @__PURE__ */ d(i.div, {
72
- "data-slot": "snap-sheet-scrim",
73
- onClick: m,
74
- className: "absolute inset-0 bg-black/45",
75
- style: { opacity: k }
76
- }), /* @__PURE__ */ f(i.div, {
77
- "data-slot": "snap-sheet-panel",
78
- className: e("absolute right-0 bottom-0 left-0 flex h-(--sheet-h) touch-none flex-col rounded-t-2xl border-x border-t border-border bg-card shadow-[0_-12px_40px_black] shadow-black/8 dark:shadow-black/50", _),
79
- style: {
80
- ...v,
81
- y: w,
82
- "--sheet-h": b * 100 + "%"
83
- },
84
- children: [/* @__PURE__ */ d("div", {
85
- "data-slot": "snap-sheet-handle",
86
- onPointerDown: j,
87
- onPointerMove: M,
88
- onPointerUp: N,
89
- onPointerCancel: N,
90
- className: "shrink-0 cursor-grab touch-none pt-2 pb-1",
91
- children: /* @__PURE__ */ d("div", { className: "mx-auto h-[5px] w-[38px] rounded-[3px] bg-handle" })
92
- }), /* @__PURE__ */ d("div", {
93
- className: "flex min-h-0 flex-1 flex-col",
94
- children: g
95
- })]
96
- })]
97
- });
98
- }
99
- //#endregion
100
- export { p as SnapSheet };