@brett_lamy/ui 4.0.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.
- package/README.md +1 -1
- package/dist/components/animated-height.d.ts +3 -1
- package/dist/components/animated-height.d.ts.map +1 -1
- package/dist/components/animated-height.js +11 -11
- package/dist/components/artifact-chat-container.d.ts.map +1 -1
- package/dist/components/artifact-chat-container.js +81 -82
- package/dist/components/button.d.ts +4 -3
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/button.js +22 -9
- package/dist/components/canvas.d.ts +91 -0
- package/dist/components/canvas.d.ts.map +1 -0
- package/dist/components/canvas.js +296 -0
- package/dist/components/composer/composer-cards.d.ts +55 -0
- package/dist/components/composer/composer-cards.d.ts.map +1 -0
- package/dist/components/composer/composer-cards.js +351 -0
- package/dist/components/composer/composer.d.ts +9 -1
- package/dist/components/composer/composer.d.ts.map +1 -1
- package/dist/components/composer/composer.js +179 -154
- package/dist/components/context-menu.d.ts +25 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu.js +127 -0
- package/dist/components/credenza.d.ts.map +1 -1
- package/dist/components/credenza.js +52 -92
- package/dist/components/cron-editor.d.ts +47 -0
- package/dist/components/cron-editor.d.ts.map +1 -0
- package/dist/components/cron-editor.js +297 -0
- package/dist/components/dropdown-menu.d.ts +3 -1
- package/dist/components/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu.js +5 -5
- package/dist/components/edge-drawer.d.ts.map +1 -1
- package/dist/components/edge-drawer.js +1 -0
- package/dist/components/file-upload.d.ts +121 -0
- package/dist/components/file-upload.d.ts.map +1 -0
- package/dist/components/file-upload.js +405 -0
- package/dist/components/filter-input.d.ts +22 -0
- package/dist/components/filter-input.d.ts.map +1 -0
- package/dist/components/filter-input.js +126 -0
- package/dist/components/filter.d.ts +154 -0
- package/dist/components/filter.d.ts.map +1 -0
- package/dist/components/filter.js +815 -0
- package/dist/components/floating-chat.d.ts.map +1 -1
- package/dist/components/floating-chat.js +71 -88
- package/dist/components/floating-sheet.d.ts.map +1 -1
- package/dist/components/floating-sheet.js +93 -104
- package/dist/components/markdown-editor.d.ts +2 -0
- package/dist/components/markdown-editor.d.ts.map +1 -1
- package/dist/components/markdown-editor.js +46 -45
- package/dist/components/markdown-view.d.ts +6 -1
- package/dist/components/markdown-view.d.ts.map +1 -1
- package/dist/components/markdown-view.js +13 -11
- package/dist/components/navigation-stack.d.ts +3 -5
- package/dist/components/navigation-stack.d.ts.map +1 -1
- package/dist/components/navigation-stack.js +212 -382
- package/dist/components/passkey-enroll-dialog.d.ts +36 -0
- package/dist/components/passkey-enroll-dialog.d.ts.map +1 -0
- package/dist/components/passkey-enroll-dialog.js +234 -0
- package/dist/components/result-table.d.ts +38 -0
- package/dist/components/result-table.d.ts.map +1 -0
- package/dist/components/result-table.js +161 -0
- package/dist/components/schema-tree.d.ts +19 -0
- package/dist/components/schema-tree.d.ts.map +1 -0
- package/dist/components/schema-tree.js +172 -0
- package/dist/components/side-drawer.d.ts.map +1 -1
- package/dist/components/side-drawer.js +117 -143
- package/dist/components/slider.d.ts.map +1 -1
- package/dist/components/slider.js +4 -1
- package/dist/components/spinner-shapes.d.ts +263 -0
- package/dist/components/spinner-shapes.d.ts.map +1 -0
- package/dist/components/spinner-shapes.js +771 -0
- package/dist/components/spinner.d.ts +133 -3
- package/dist/components/spinner.d.ts.map +1 -1
- package/dist/components/spinner.js +445 -29
- package/dist/components/sql-console.d.ts +28 -0
- package/dist/components/sql-console.d.ts.map +1 -0
- package/dist/components/sql-console.js +348 -0
- package/dist/components/sql-editor.d.ts +47 -0
- package/dist/components/sql-editor.d.ts.map +1 -0
- package/dist/components/sql-editor.js +170 -0
- package/dist/components/tab-view.d.ts +2 -2
- package/dist/components/tab-view.d.ts.map +1 -1
- package/dist/components/tab-view.js +63 -49
- package/dist/components/tailscale-login-button.d.ts +53 -0
- package/dist/components/tailscale-login-button.d.ts.map +1 -0
- package/dist/components/tailscale-login-button.js +197 -0
- package/dist/components/time-input.d.ts +46 -0
- package/dist/components/time-input.d.ts.map +1 -0
- package/dist/components/time-input.js +258 -0
- package/dist/components/toast.d.ts +5 -2
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/toast.js +249 -125
- package/dist/components/vault-gate.d.ts +60 -0
- package/dist/components/vault-gate.d.ts.map +1 -0
- package/dist/components/vault-gate.js +382 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +85 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +129 -83
- package/dist/lib/back-history.d.ts +5 -0
- package/dist/lib/back-history.d.ts.map +1 -0
- package/dist/lib/back-history.js +44 -0
- package/dist/lib/canvas-math.d.ts +82 -0
- package/dist/lib/canvas-math.d.ts.map +1 -0
- package/dist/lib/canvas-math.js +226 -0
- package/dist/lib/controllable-state.d.ts +4 -0
- package/dist/lib/controllable-state.d.ts.map +1 -0
- package/dist/lib/controllable-state.js +11 -0
- package/dist/lib/cron.d.ts +55 -0
- package/dist/lib/cron.d.ts.map +1 -0
- package/dist/lib/cron.js +269 -0
- package/dist/lib/edge-swipe.d.ts +36 -0
- package/dist/lib/edge-swipe.d.ts.map +1 -0
- package/dist/lib/edge-swipe.js +73 -0
- package/dist/lib/file-upload.d.ts +187 -0
- package/dist/lib/file-upload.d.ts.map +1 -0
- package/dist/lib/file-upload.js +349 -0
- package/dist/lib/filter-query.d.ts +90 -0
- package/dist/lib/filter-query.d.ts.map +1 -0
- package/dist/lib/filter-query.js +459 -0
- package/dist/lib/filter.d.ts +120 -0
- package/dist/lib/filter.d.ts.map +1 -0
- package/dist/lib/filter.js +399 -0
- package/dist/lib/format-bytes.d.ts +3 -0
- package/dist/lib/format-bytes.d.ts.map +1 -0
- package/dist/lib/format-bytes.js +16 -0
- package/dist/lib/gpu-cron.d.ts +51 -0
- package/dist/lib/gpu-cron.d.ts.map +1 -0
- package/dist/lib/gpu-cron.js +81 -0
- package/dist/lib/gpu-query/featurize.d.ts +19 -0
- package/dist/lib/gpu-query/featurize.d.ts.map +1 -0
- package/dist/lib/gpu-query/featurize.js +88 -0
- package/dist/lib/gpu-query/index.d.ts +73 -0
- package/dist/lib/gpu-query/index.d.ts.map +1 -0
- package/dist/lib/gpu-query/index.js +117 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts +30 -0
- package/dist/lib/gpu-query/kernel.wgsl.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.d.ts +8 -0
- package/dist/lib/gpu-query/model.d.ts.map +1 -0
- package/dist/lib/gpu-query/model.js +91 -0
- package/dist/lib/gpu-query/schema.d.ts +40 -0
- package/dist/lib/gpu-query/schema.d.ts.map +1 -0
- package/dist/lib/gpu-query/schema.js +0 -0
- package/dist/lib/gpu-query/webgpu.d.ts +12 -0
- package/dist/lib/gpu-query/webgpu.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.d.ts +17 -0
- package/dist/lib/gpu-query/weights.d.ts.map +1 -0
- package/dist/lib/gpu-query/weights.js +40 -0
- package/dist/lib/gpu-query/weights.json.d.ts +3 -0
- package/dist/lib/gpu-query/weights2.js +25 -0
- package/dist/lib/gpu-time.d.ts +77 -0
- package/dist/lib/gpu-time.d.ts.map +1 -0
- package/dist/lib/gpu-time.js +260 -0
- package/dist/lib/morph-path.d.ts +22 -0
- package/dist/lib/morph-path.d.ts.map +1 -0
- package/dist/lib/morph-path.js +42 -0
- package/dist/lib/passkey.d.ts +120 -0
- package/dist/lib/passkey.d.ts.map +1 -0
- package/dist/lib/passkey.js +186 -0
- package/dist/lib/persistent-state.d.ts +9 -0
- package/dist/lib/persistent-state.d.ts.map +1 -0
- package/dist/lib/persistent-state.js +37 -0
- package/dist/lib/pglite-core.d.ts +219 -0
- package/dist/lib/pglite-core.d.ts.map +1 -0
- package/dist/lib/pglite-core.js +273 -0
- package/dist/lib/pglite-files.d.ts +7 -0
- package/dist/lib/pglite-files.d.ts.map +1 -0
- package/dist/lib/pglite-files.js +17 -0
- package/dist/lib/pglite-schema.d.ts +58 -0
- package/dist/lib/pglite-schema.d.ts.map +1 -0
- package/dist/lib/pglite-schema.js +105 -0
- package/dist/lib/pglite-storage.d.ts +33 -0
- package/dist/lib/pglite-storage.d.ts.map +1 -0
- package/dist/lib/pglite-storage.js +55 -0
- package/dist/lib/pglite-transfer.d.ts +53 -0
- package/dist/lib/pglite-transfer.d.ts.map +1 -0
- package/dist/lib/pglite-transfer.js +126 -0
- package/dist/lib/pglite.d.ts +106 -0
- package/dist/lib/pglite.d.ts.map +1 -0
- package/dist/lib/pglite.js +298 -0
- package/dist/lib/pull-to-refresh.d.ts +24 -0
- package/dist/lib/pull-to-refresh.d.ts.map +1 -0
- package/dist/lib/pull-to-refresh.js +74 -0
- package/dist/lib/scroll-hidden.d.ts +6 -0
- package/dist/lib/scroll-hidden.d.ts.map +1 -0
- package/dist/lib/scroll-hidden.js +21 -0
- package/dist/lib/sql-format.d.ts +62 -0
- package/dist/lib/sql-format.d.ts.map +1 -0
- package/dist/lib/sql-format.js +175 -0
- package/dist/lib/sql-lex.d.ts +25 -0
- package/dist/lib/sql-lex.d.ts.map +1 -0
- package/dist/lib/sql-lex.js +135 -0
- package/dist/lib/tab-lock.d.ts +28 -0
- package/dist/lib/tab-lock.d.ts.map +1 -0
- package/dist/lib/tab-lock.js +80 -0
- package/dist/lib/tailscale-connect.d.ts +56 -0
- package/dist/lib/tailscale-connect.d.ts.map +1 -0
- package/dist/lib/tailscale-connect.js +99 -0
- package/dist/lib/tailscale-fake.d.ts +33 -0
- package/dist/lib/tailscale-fake.d.ts.map +1 -0
- package/dist/lib/tailscale-fake.js +80 -0
- package/dist/lib/tailscale-policy.d.ts +71 -0
- package/dist/lib/tailscale-policy.d.ts.map +1 -0
- package/dist/lib/tailscale-policy.js +244 -0
- package/dist/lib/tailscale-react.d.ts +20 -0
- package/dist/lib/tailscale-react.d.ts.map +1 -0
- package/dist/lib/tailscale-react.js +37 -0
- package/dist/lib/tailscale-router/bridge.d.ts +60 -0
- package/dist/lib/tailscale-router/bridge.d.ts.map +1 -0
- package/dist/lib/tailscale-router/bridge.js +198 -0
- package/dist/lib/tailscale-router/react.d.ts +19 -0
- package/dist/lib/tailscale-router/react.d.ts.map +1 -0
- package/dist/lib/tailscale-router/react.js +52 -0
- package/dist/lib/tailscale.d.ts +204 -0
- package/dist/lib/tailscale.d.ts.map +1 -0
- package/dist/lib/tailscale.js +443 -0
- package/dist/lib/title-flight.d.ts +34 -0
- package/dist/lib/title-flight.d.ts.map +1 -0
- package/dist/lib/title-flight.js +123 -0
- package/dist/lib/vault-react.d.ts +49 -0
- package/dist/lib/vault-react.d.ts.map +1 -0
- package/dist/lib/vault-react.js +196 -0
- package/dist/lib/vault-storage.d.ts +30 -0
- package/dist/lib/vault-storage.d.ts.map +1 -0
- package/dist/lib/vault-storage.js +105 -0
- package/dist/lib/vault.d.ts +200 -0
- package/dist/lib/vault.d.ts.map +1 -0
- package/dist/lib/vault.js +641 -0
- package/dist/tailscale-sw.js +332 -0
- package/package.json +35 -5
- package/dist/components/icon-button.d.ts +0 -19
- package/dist/components/icon-button.d.ts.map +0 -1
- package/dist/components/icon-button.js +0 -31
- package/dist/components/measure-h.d.ts +0 -7
- package/dist/components/measure-h.d.ts.map +0 -1
- package/dist/components/measure-h.js +0 -20
|
@@ -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
|
+
"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
|
-
"
|
|
49
|
-
"
|
|
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
|
|
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 };
|