@brett_lamy/ui 4.0.0 → 5.1.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 (249) hide show
  1. package/README.md +1 -1
  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/calendar.d.ts +26 -0
  11. package/dist/components/calendar.d.ts.map +1 -0
  12. package/dist/components/calendar.js +97 -0
  13. package/dist/components/canvas.d.ts +91 -0
  14. package/dist/components/canvas.d.ts.map +1 -0
  15. package/dist/components/canvas.js +296 -0
  16. package/dist/components/color-field.d.ts +22 -0
  17. package/dist/components/color-field.d.ts.map +1 -0
  18. package/dist/components/color-field.js +60 -0
  19. package/dist/components/color-picker.d.ts +49 -0
  20. package/dist/components/color-picker.d.ts.map +1 -0
  21. package/dist/components/color-picker.js +121 -0
  22. package/dist/components/composer/composer-cards.d.ts +55 -0
  23. package/dist/components/composer/composer-cards.d.ts.map +1 -0
  24. package/dist/components/composer/composer-cards.js +351 -0
  25. package/dist/components/composer/composer.d.ts +9 -1
  26. package/dist/components/composer/composer.d.ts.map +1 -1
  27. package/dist/components/composer/composer.js +179 -154
  28. package/dist/components/context-menu.d.ts +25 -0
  29. package/dist/components/context-menu.d.ts.map +1 -0
  30. package/dist/components/context-menu.js +127 -0
  31. package/dist/components/credenza.d.ts.map +1 -1
  32. package/dist/components/credenza.js +52 -92
  33. package/dist/components/cron-editor.d.ts +47 -0
  34. package/dist/components/cron-editor.d.ts.map +1 -0
  35. package/dist/components/cron-editor.js +297 -0
  36. package/dist/components/date-field.d.ts +19 -0
  37. package/dist/components/date-field.d.ts.map +1 -0
  38. package/dist/components/date-field.js +79 -0
  39. package/dist/components/date-picker.d.ts +38 -0
  40. package/dist/components/date-picker.d.ts.map +1 -0
  41. package/dist/components/date-picker.js +110 -0
  42. package/dist/components/dropdown-menu.d.ts +3 -1
  43. package/dist/components/dropdown-menu.d.ts.map +1 -1
  44. package/dist/components/dropdown-menu.js +5 -5
  45. package/dist/components/edge-drawer.d.ts.map +1 -1
  46. package/dist/components/edge-drawer.js +1 -0
  47. package/dist/components/file-upload.d.ts +121 -0
  48. package/dist/components/file-upload.d.ts.map +1 -0
  49. package/dist/components/file-upload.js +405 -0
  50. package/dist/components/filter-input.d.ts +22 -0
  51. package/dist/components/filter-input.d.ts.map +1 -0
  52. package/dist/components/filter-input.js +126 -0
  53. package/dist/components/filter.d.ts +154 -0
  54. package/dist/components/filter.d.ts.map +1 -0
  55. package/dist/components/filter.js +815 -0
  56. package/dist/components/floating-chat.d.ts.map +1 -1
  57. package/dist/components/floating-chat.js +71 -88
  58. package/dist/components/floating-sheet.d.ts.map +1 -1
  59. package/dist/components/floating-sheet.js +93 -104
  60. package/dist/components/markdown-editor.d.ts +2 -0
  61. package/dist/components/markdown-editor.d.ts.map +1 -1
  62. package/dist/components/markdown-editor.js +46 -45
  63. package/dist/components/markdown-view.d.ts +6 -1
  64. package/dist/components/markdown-view.d.ts.map +1 -1
  65. package/dist/components/markdown-view.js +13 -11
  66. package/dist/components/navigation-stack.d.ts +3 -5
  67. package/dist/components/navigation-stack.d.ts.map +1 -1
  68. package/dist/components/navigation-stack.js +212 -382
  69. package/dist/components/passkey-enroll-dialog.d.ts +36 -0
  70. package/dist/components/passkey-enroll-dialog.d.ts.map +1 -0
  71. package/dist/components/passkey-enroll-dialog.js +234 -0
  72. package/dist/components/result-table.d.ts +38 -0
  73. package/dist/components/result-table.d.ts.map +1 -0
  74. package/dist/components/result-table.js +161 -0
  75. package/dist/components/schema-tree.d.ts +19 -0
  76. package/dist/components/schema-tree.d.ts.map +1 -0
  77. package/dist/components/schema-tree.js +172 -0
  78. package/dist/components/side-drawer.d.ts.map +1 -1
  79. package/dist/components/side-drawer.js +117 -143
  80. package/dist/components/slider.d.ts.map +1 -1
  81. package/dist/components/slider.js +4 -1
  82. package/dist/components/spinner-shapes.d.ts +299 -0
  83. package/dist/components/spinner-shapes.d.ts.map +1 -0
  84. package/dist/components/spinner-shapes.js +876 -0
  85. package/dist/components/spinner.d.ts +133 -3
  86. package/dist/components/spinner.d.ts.map +1 -1
  87. package/dist/components/spinner.js +445 -29
  88. package/dist/components/sql-console.d.ts +28 -0
  89. package/dist/components/sql-console.d.ts.map +1 -0
  90. package/dist/components/sql-console.js +348 -0
  91. package/dist/components/sql-editor.d.ts +47 -0
  92. package/dist/components/sql-editor.d.ts.map +1 -0
  93. package/dist/components/sql-editor.js +170 -0
  94. package/dist/components/tab-view.d.ts +2 -2
  95. package/dist/components/tab-view.d.ts.map +1 -1
  96. package/dist/components/tab-view.js +63 -49
  97. package/dist/components/tailscale-login-button.d.ts +53 -0
  98. package/dist/components/tailscale-login-button.d.ts.map +1 -0
  99. package/dist/components/tailscale-login-button.js +197 -0
  100. package/dist/components/time-input.d.ts +46 -0
  101. package/dist/components/time-input.d.ts.map +1 -0
  102. package/dist/components/time-input.js +258 -0
  103. package/dist/components/toast.d.ts +5 -2
  104. package/dist/components/toast.d.ts.map +1 -1
  105. package/dist/components/toast.js +249 -125
  106. package/dist/components/vault-gate.d.ts +60 -0
  107. package/dist/components/vault-gate.d.ts.map +1 -0
  108. package/dist/components/vault-gate.js +382 -0
  109. package/dist/index.css +1 -1
  110. package/dist/index.d.ts +90 -3
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +134 -83
  113. package/dist/lib/back-history.d.ts +5 -0
  114. package/dist/lib/back-history.d.ts.map +1 -0
  115. package/dist/lib/back-history.js +44 -0
  116. package/dist/lib/canvas-math.d.ts +82 -0
  117. package/dist/lib/canvas-math.d.ts.map +1 -0
  118. package/dist/lib/canvas-math.js +226 -0
  119. package/dist/lib/controllable-state.d.ts +4 -0
  120. package/dist/lib/controllable-state.d.ts.map +1 -0
  121. package/dist/lib/controllable-state.js +11 -0
  122. package/dist/lib/cron.d.ts +55 -0
  123. package/dist/lib/cron.d.ts.map +1 -0
  124. package/dist/lib/cron.js +269 -0
  125. package/dist/lib/edge-swipe.d.ts +36 -0
  126. package/dist/lib/edge-swipe.d.ts.map +1 -0
  127. package/dist/lib/edge-swipe.js +73 -0
  128. package/dist/lib/file-upload.d.ts +187 -0
  129. package/dist/lib/file-upload.d.ts.map +1 -0
  130. package/dist/lib/file-upload.js +349 -0
  131. package/dist/lib/filter-query.d.ts +90 -0
  132. package/dist/lib/filter-query.d.ts.map +1 -0
  133. package/dist/lib/filter-query.js +459 -0
  134. package/dist/lib/filter.d.ts +120 -0
  135. package/dist/lib/filter.d.ts.map +1 -0
  136. package/dist/lib/filter.js +399 -0
  137. package/dist/lib/format-bytes.d.ts +3 -0
  138. package/dist/lib/format-bytes.d.ts.map +1 -0
  139. package/dist/lib/format-bytes.js +16 -0
  140. package/dist/lib/gpu-cron.d.ts +51 -0
  141. package/dist/lib/gpu-cron.d.ts.map +1 -0
  142. package/dist/lib/gpu-cron.js +81 -0
  143. package/dist/lib/gpu-query/featurize.d.ts +19 -0
  144. package/dist/lib/gpu-query/featurize.d.ts.map +1 -0
  145. package/dist/lib/gpu-query/featurize.js +88 -0
  146. package/dist/lib/gpu-query/index.d.ts +73 -0
  147. package/dist/lib/gpu-query/index.d.ts.map +1 -0
  148. package/dist/lib/gpu-query/index.js +117 -0
  149. package/dist/lib/gpu-query/kernel.wgsl.d.ts +30 -0
  150. package/dist/lib/gpu-query/kernel.wgsl.d.ts.map +1 -0
  151. package/dist/lib/gpu-query/model.d.ts +8 -0
  152. package/dist/lib/gpu-query/model.d.ts.map +1 -0
  153. package/dist/lib/gpu-query/model.js +91 -0
  154. package/dist/lib/gpu-query/schema.d.ts +40 -0
  155. package/dist/lib/gpu-query/schema.d.ts.map +1 -0
  156. package/dist/lib/gpu-query/schema.js +0 -0
  157. package/dist/lib/gpu-query/webgpu.d.ts +12 -0
  158. package/dist/lib/gpu-query/webgpu.d.ts.map +1 -0
  159. package/dist/lib/gpu-query/weights.d.ts +17 -0
  160. package/dist/lib/gpu-query/weights.d.ts.map +1 -0
  161. package/dist/lib/gpu-query/weights.js +40 -0
  162. package/dist/lib/gpu-query/weights.json.d.ts +3 -0
  163. package/dist/lib/gpu-query/weights2.js +25 -0
  164. package/dist/lib/gpu-time.d.ts +77 -0
  165. package/dist/lib/gpu-time.d.ts.map +1 -0
  166. package/dist/lib/gpu-time.js +260 -0
  167. package/dist/lib/morph-path.d.ts +22 -0
  168. package/dist/lib/morph-path.d.ts.map +1 -0
  169. package/dist/lib/morph-path.js +42 -0
  170. package/dist/lib/passkey.d.ts +120 -0
  171. package/dist/lib/passkey.d.ts.map +1 -0
  172. package/dist/lib/passkey.js +186 -0
  173. package/dist/lib/persistent-state.d.ts +9 -0
  174. package/dist/lib/persistent-state.d.ts.map +1 -0
  175. package/dist/lib/persistent-state.js +37 -0
  176. package/dist/lib/pglite-core.d.ts +219 -0
  177. package/dist/lib/pglite-core.d.ts.map +1 -0
  178. package/dist/lib/pglite-core.js +273 -0
  179. package/dist/lib/pglite-files.d.ts +7 -0
  180. package/dist/lib/pglite-files.d.ts.map +1 -0
  181. package/dist/lib/pglite-files.js +17 -0
  182. package/dist/lib/pglite-schema.d.ts +58 -0
  183. package/dist/lib/pglite-schema.d.ts.map +1 -0
  184. package/dist/lib/pglite-schema.js +105 -0
  185. package/dist/lib/pglite-storage.d.ts +33 -0
  186. package/dist/lib/pglite-storage.d.ts.map +1 -0
  187. package/dist/lib/pglite-storage.js +55 -0
  188. package/dist/lib/pglite-transfer.d.ts +53 -0
  189. package/dist/lib/pglite-transfer.d.ts.map +1 -0
  190. package/dist/lib/pglite-transfer.js +126 -0
  191. package/dist/lib/pglite.d.ts +106 -0
  192. package/dist/lib/pglite.d.ts.map +1 -0
  193. package/dist/lib/pglite.js +298 -0
  194. package/dist/lib/pull-to-refresh.d.ts +24 -0
  195. package/dist/lib/pull-to-refresh.d.ts.map +1 -0
  196. package/dist/lib/pull-to-refresh.js +74 -0
  197. package/dist/lib/scroll-hidden.d.ts +6 -0
  198. package/dist/lib/scroll-hidden.d.ts.map +1 -0
  199. package/dist/lib/scroll-hidden.js +21 -0
  200. package/dist/lib/sql-format.d.ts +62 -0
  201. package/dist/lib/sql-format.d.ts.map +1 -0
  202. package/dist/lib/sql-format.js +175 -0
  203. package/dist/lib/sql-lex.d.ts +25 -0
  204. package/dist/lib/sql-lex.d.ts.map +1 -0
  205. package/dist/lib/sql-lex.js +135 -0
  206. package/dist/lib/tab-lock.d.ts +28 -0
  207. package/dist/lib/tab-lock.d.ts.map +1 -0
  208. package/dist/lib/tab-lock.js +80 -0
  209. package/dist/lib/tailscale-connect.d.ts +56 -0
  210. package/dist/lib/tailscale-connect.d.ts.map +1 -0
  211. package/dist/lib/tailscale-connect.js +99 -0
  212. package/dist/lib/tailscale-fake.d.ts +33 -0
  213. package/dist/lib/tailscale-fake.d.ts.map +1 -0
  214. package/dist/lib/tailscale-fake.js +80 -0
  215. package/dist/lib/tailscale-policy.d.ts +71 -0
  216. package/dist/lib/tailscale-policy.d.ts.map +1 -0
  217. package/dist/lib/tailscale-policy.js +244 -0
  218. package/dist/lib/tailscale-react.d.ts +20 -0
  219. package/dist/lib/tailscale-react.d.ts.map +1 -0
  220. package/dist/lib/tailscale-react.js +37 -0
  221. package/dist/lib/tailscale-router/bridge.d.ts +60 -0
  222. package/dist/lib/tailscale-router/bridge.d.ts.map +1 -0
  223. package/dist/lib/tailscale-router/bridge.js +198 -0
  224. package/dist/lib/tailscale-router/react.d.ts +19 -0
  225. package/dist/lib/tailscale-router/react.d.ts.map +1 -0
  226. package/dist/lib/tailscale-router/react.js +52 -0
  227. package/dist/lib/tailscale.d.ts +204 -0
  228. package/dist/lib/tailscale.d.ts.map +1 -0
  229. package/dist/lib/tailscale.js +443 -0
  230. package/dist/lib/title-flight.d.ts +34 -0
  231. package/dist/lib/title-flight.d.ts.map +1 -0
  232. package/dist/lib/title-flight.js +123 -0
  233. package/dist/lib/vault-react.d.ts +49 -0
  234. package/dist/lib/vault-react.d.ts.map +1 -0
  235. package/dist/lib/vault-react.js +196 -0
  236. package/dist/lib/vault-storage.d.ts +30 -0
  237. package/dist/lib/vault-storage.d.ts.map +1 -0
  238. package/dist/lib/vault-storage.js +105 -0
  239. package/dist/lib/vault.d.ts +200 -0
  240. package/dist/lib/vault.d.ts.map +1 -0
  241. package/dist/lib/vault.js +641 -0
  242. package/dist/tailscale-sw.js +332 -0
  243. package/package.json +35 -4
  244. package/dist/components/icon-button.d.ts +0 -19
  245. package/dist/components/icon-button.d.ts.map +0 -1
  246. package/dist/components/icon-button.js +0 -31
  247. package/dist/components/measure-h.d.ts +0 -7
  248. package/dist/components/measure-h.d.ts.map +0 -1
  249. package/dist/components/measure-h.js +0 -20
@@ -0,0 +1,62 @@
1
+ /** Type OIDs worth special treatment (the stable ones from pg_type.dat). */
2
+ export declare const PG_TYPE: {
3
+ readonly bool: 16;
4
+ readonly bytea: 17;
5
+ readonly char: 18;
6
+ readonly int8: 20;
7
+ readonly int2: 21;
8
+ readonly int4: 23;
9
+ readonly text: 25;
10
+ readonly oid: 26;
11
+ readonly json: 114;
12
+ readonly xml: 142;
13
+ readonly float4: 700;
14
+ readonly float8: 701;
15
+ readonly money: 790;
16
+ readonly bpchar: 1042;
17
+ readonly varchar: 1043;
18
+ readonly date: 1082;
19
+ readonly time: 1083;
20
+ readonly timestamp: 1114;
21
+ readonly timestamptz: 1184;
22
+ readonly interval: 1186;
23
+ readonly numeric: 1700;
24
+ readonly uuid: 2950;
25
+ readonly jsonb: 3802;
26
+ };
27
+ /** A short name for a type OID (`int4`, `timestamptz`, `jsonb[]`), or `oid:<n>` for one we don't know. */
28
+ export declare function pgTypeName(oid: number | undefined): string;
29
+ export type CellKind = 'null' | 'boolean' | 'number' | 'text' | 'date' | 'json' | 'bytea';
30
+ export interface FormattedCell {
31
+ kind: CellKind;
32
+ /** Compact text for a table cell (single line, not truncated). */
33
+ text: string;
34
+ /** The whole value, for an expanded view or a copy — pretty-printed for JSON. */
35
+ full: string;
36
+ /** Numbers right-align. */
37
+ align: 'start' | 'end';
38
+ }
39
+ export declare function bytesToHex(bytes: Uint8Array): string;
40
+ /** JSON.stringify that survives bigint, bytea and Dates (neither of which JSON can carry). */
41
+ export declare function safeStringify(value: unknown, space?: number): string;
42
+ /** Formats one value of a result column. `oid` (the field's dataTypeID) refines dates and JSON-in-text columns. */
43
+ export declare function formatCell(value: unknown, oid?: number): FormattedCell;
44
+ export interface TabularResult {
45
+ fields: readonly {
46
+ name: string;
47
+ dataTypeID?: number;
48
+ }[];
49
+ rows: readonly Record<string, unknown>[];
50
+ }
51
+ /** RFC 4180 CSV: a header row, CRLF line ends, fields quoted when they hold a delimiter, quote, newline or edge space. */
52
+ export declare function toCsv(result: TabularResult, { delimiter, header }?: {
53
+ delimiter?: string;
54
+ header?: boolean;
55
+ }): string;
56
+ /** The rows as a pretty-printed JSON array of objects (bigint as strings, dates ISO, bytea hex). */
57
+ export declare function toJson(result: TabularResult): string;
58
+ /** `1,234 rows`, `1 row`. */
59
+ export declare function pluralRows(n: number): string;
60
+ /** `12 ms`, `1.4 s`. */
61
+ export declare function formatDuration(ms: number): string;
62
+ //# sourceMappingURL=sql-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-format.d.ts","sourceRoot":"","sources":["../../src/lib/sql-format.ts"],"names":[],"mappings":"AAOA,4EAA4E;AAC5E,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;CAwBV,CAAC;AAYX,0GAA0G;AAC1G,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG1D;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1F,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC;CACxB;AAiBD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD;AAED,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAUpE;AAED,mHAAmH;AACnH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,aAAa,CAuBtE;AAWD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,IAAI,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CAC1C;AAED,0HAA0H;AAC1H,wBAAgB,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,SAAe,EAAE,MAAa,EAAE,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAMtI;AAED,oGAAoG;AACpG,wBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAUpD;AAED,6BAA6B;AAC7B,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAwB;AACxB,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAIjD"}
@@ -0,0 +1,175 @@
1
+ //#region src/lib/sql-format.ts
2
+ var e = {
3
+ bool: 16,
4
+ bytea: 17,
5
+ char: 18,
6
+ int8: 20,
7
+ int2: 21,
8
+ int4: 23,
9
+ text: 25,
10
+ oid: 26,
11
+ json: 114,
12
+ xml: 142,
13
+ float4: 700,
14
+ float8: 701,
15
+ money: 790,
16
+ bpchar: 1042,
17
+ varchar: 1043,
18
+ date: 1082,
19
+ time: 1083,
20
+ timestamp: 1114,
21
+ timestamptz: 1184,
22
+ interval: 1186,
23
+ numeric: 1700,
24
+ uuid: 2950,
25
+ jsonb: 3802
26
+ }, t = {
27
+ 16: "bool",
28
+ 17: "bytea",
29
+ 18: "char",
30
+ 19: "name",
31
+ 20: "int8",
32
+ 21: "int2",
33
+ 23: "int4",
34
+ 25: "text",
35
+ 26: "oid",
36
+ 114: "json",
37
+ 142: "xml",
38
+ 700: "float4",
39
+ 701: "float8",
40
+ 790: "money",
41
+ 829: "macaddr",
42
+ 869: "inet",
43
+ 650: "cidr",
44
+ 1042: "bpchar",
45
+ 1043: "varchar",
46
+ 1082: "date",
47
+ 1083: "time",
48
+ 1114: "timestamp",
49
+ 1184: "timestamptz",
50
+ 1186: "interval",
51
+ 1266: "timetz",
52
+ 1560: "bit",
53
+ 1562: "varbit",
54
+ 1700: "numeric",
55
+ 2950: "uuid",
56
+ 3614: "tsvector",
57
+ 3615: "tsquery",
58
+ 3802: "jsonb",
59
+ 1e3: "bool[]",
60
+ 1001: "bytea[]",
61
+ 1005: "int2[]",
62
+ 1007: "int4[]",
63
+ 1009: "text[]",
64
+ 1016: "int8[]",
65
+ 1021: "float4[]",
66
+ 1022: "float8[]",
67
+ 1015: "varchar[]",
68
+ 1115: "timestamp[]",
69
+ 1185: "timestamptz[]",
70
+ 1231: "numeric[]",
71
+ 2951: "uuid[]",
72
+ 199: "json[]",
73
+ 3807: "jsonb[]"
74
+ };
75
+ function n(e) {
76
+ return e === void 0 ? "unknown" : t[e] ?? `oid:${e}`;
77
+ }
78
+ var r = (e, t = 2) => String(e).padStart(t, "0");
79
+ function i(e) {
80
+ let t = `${r(e.getFullYear(), 4)}-${r(e.getMonth() + 1)}-${r(e.getDate())} ${r(e.getHours())}:${r(e.getMinutes())}:${r(e.getSeconds())}`;
81
+ return e.getMilliseconds() ? `${t}.${r(e.getMilliseconds(), 3)}` : t;
82
+ }
83
+ function a(t, n) {
84
+ return Number.isNaN(t.getTime()) ? "Invalid Date" : n === e.date ? t.toISOString().slice(0, 10) : n === e.timestamp ? i(t) : t.toISOString();
85
+ }
86
+ function o(e) {
87
+ let t = "\\x";
88
+ for (let n of e) t += n.toString(16).padStart(2, "0");
89
+ return t;
90
+ }
91
+ function s(e, t) {
92
+ return JSON.stringify(e, (e, t) => typeof t == "bigint" ? t.toString() : t instanceof Uint8Array ? o(t) : t, t) ?? "null";
93
+ }
94
+ function c(t, n) {
95
+ if (t == null) return {
96
+ kind: "null",
97
+ text: "NULL",
98
+ full: "NULL",
99
+ align: "start"
100
+ };
101
+ if (typeof t == "boolean") return {
102
+ kind: "boolean",
103
+ text: String(t),
104
+ full: String(t),
105
+ align: "start"
106
+ };
107
+ if (typeof t == "number" || typeof t == "bigint") {
108
+ let e = String(t);
109
+ return {
110
+ kind: "number",
111
+ text: e,
112
+ full: e,
113
+ align: "end"
114
+ };
115
+ }
116
+ if (t instanceof Date) {
117
+ let e = a(t, n);
118
+ return {
119
+ kind: "date",
120
+ text: e,
121
+ full: e,
122
+ align: "start"
123
+ };
124
+ }
125
+ if (t instanceof Uint8Array) {
126
+ let e = o(t);
127
+ return {
128
+ kind: "bytea",
129
+ text: e.length > 34 ? `${e.slice(0, 34)}…` : e,
130
+ full: e,
131
+ align: "start"
132
+ };
133
+ }
134
+ if (typeof t == "object") return {
135
+ kind: "json",
136
+ text: s(t),
137
+ full: s(t, 2),
138
+ align: "start"
139
+ };
140
+ let r = String(t);
141
+ return n === e.numeric ? {
142
+ kind: "number",
143
+ text: r,
144
+ full: r,
145
+ align: "end"
146
+ } : {
147
+ kind: "text",
148
+ text: r.replace(/\r?\n/g, "↵"),
149
+ full: r,
150
+ align: "start"
151
+ };
152
+ }
153
+ function l(e, t) {
154
+ return e == null ? "" : e instanceof Date ? a(e, t) : e instanceof Uint8Array ? o(e) : typeof e == "object" ? s(e) : String(e);
155
+ }
156
+ function u(e, { delimiter: t = ",", header: n = !0 } = {}) {
157
+ let r = (e) => e === "" || !(e.includes(t) || /["\r\n]/.test(e) || e !== e.trim()) ? e : `"${e.replace(/"/g, "\"\"")}"`, i = [];
158
+ n && i.push(e.fields.map((e) => r(e.name)).join(t));
159
+ for (let n of e.rows) i.push(e.fields.map((e) => r(l(n[e.name], e.dataTypeID))).join(t));
160
+ return i.join("\r\n");
161
+ }
162
+ function d(e) {
163
+ return s(e.rows.map((t) => Object.fromEntries(e.fields.map((e) => {
164
+ let n = t[e.name];
165
+ return [e.name, n instanceof Date ? a(n, e.dataTypeID) : n];
166
+ }))), 2);
167
+ }
168
+ function f(e) {
169
+ return `${e.toLocaleString("en-US")} ${e === 1 ? "row" : "rows"}`;
170
+ }
171
+ function p(e) {
172
+ return e < 1 ? "<1 ms" : e < 1e3 ? `${Math.round(e)} ms` : `${(e / 1e3).toFixed(+(e < 1e4))} s`;
173
+ }
174
+ //#endregion
175
+ export { e as PG_TYPE, o as bytesToHex, c as formatCell, p as formatDuration, n as pgTypeName, f as pluralRows, s as safeStringify, u as toCsv, d as toJson };
@@ -0,0 +1,25 @@
1
+ export type SqlSpanType = 'comment' | 'string' | 'number' | 'keyword' | 'type' | 'function' | 'constant' | 'operator';
2
+ export interface SqlSpan {
3
+ type: SqlSpanType;
4
+ /** Half-open UTF-16 offsets into the source. */
5
+ start: number;
6
+ end: number;
7
+ }
8
+ /** Highlight spans for `src` (plain text — identifiers, whitespace, punctuation — has no span). Sorted, non-overlapping. */
9
+ export declare function sqlSpans(src: string): SqlSpan[];
10
+ export interface SqlStatement {
11
+ /** The statement's text, trimmed, without its terminating `;`. */
12
+ text: string;
13
+ /** Offsets of `text` in the source (half-open). */
14
+ start: number;
15
+ end: number;
16
+ }
17
+ /** Splits a script at top-level semicolons (not inside strings, comments, dollar-quoted bodies or parentheses).
18
+ Statements that hold only comments or whitespace are dropped — PostgreSQL returns no result for them either. */
19
+ export declare function splitStatements(src: string): SqlStatement[];
20
+ /** Line and column (both 1-based) of a 1-based character `position`, as PostgreSQL reports error positions. */
21
+ export declare function positionToLineColumn(src: string, position: number): {
22
+ line: number;
23
+ column: number;
24
+ };
25
+ //# sourceMappingURL=sql-lex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-lex.d.ts","sourceRoot":"","sources":["../../src/lib/sql-lex.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAwHD,4HAA4H;AAC5H,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CA8B/C;AAED,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;mHACmH;AACnH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,EAAE,CAqC3D;AAED,+GAA+G;AAC/G,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAWpG"}
@@ -0,0 +1,135 @@
1
+ //#region src/lib/sql-lex.ts
2
+ var e = new Set("add all alter analyze and any as asc begin between by case cast check collate column commit constraint create cross cycle default delete desc distinct do drop else end except exists explain extension false fetch filter first for foreign from full function grant group having if ilike in index inner insert intersect into is join key lateral left like limit materialized natural not nothing null nulls offset on only or order outer over partition policy primary references replace returning returns revoke right rollback row rows schema select sequence set show similar start table temp temporary then to transaction trigger truncate union unique unlogged update using vacuum values view when where window with within without language plpgsql declare loop while return raise perform exception conflict generated always identity stored virtual unbounded preceding following current range groups".split(" ")), t = new Set("bigint bigserial bit boolean bool bytea char character cidr date daterange decimal double float float4 float8 inet int int2 int4 int8 integer interval json jsonb macaddr numeric oid real regclass serial serial4 serial8 smallint smallserial text time timestamp timestamptz timetz tsquery tsvector uuid varbit varchar xml".split(" ")), n = /* @__PURE__ */ new Set([
3
+ "true",
4
+ "false",
5
+ "null",
6
+ "unknown"
7
+ ]), r = /* @__PURE__ */ new Set([
8
+ "left",
9
+ "right",
10
+ "replace",
11
+ "truncate",
12
+ "first",
13
+ "row",
14
+ "filter",
15
+ "set",
16
+ "show"
17
+ ]), i = (e) => /[A-Za-z_\u0080-￿]/.test(e), a = (e) => /[A-Za-z0-9_$\u0080-￿]/.test(e), o = (e) => e >= "0" && e <= "9", s = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", c = "+-*/<>=~!@#%^&|`?:";
18
+ function l(e, t) {
19
+ let n = 0, r = t;
20
+ for (; r < e.length;) if (e[r] === "/" && e[r + 1] === "*") n++, r += 2;
21
+ else if (e[r] === "*" && e[r + 1] === "/") {
22
+ if (n--, r += 2, n === 0) return r;
23
+ } else r++;
24
+ return e.length;
25
+ }
26
+ function u(e, t, n, r) {
27
+ let i = t + 1;
28
+ for (; i < e.length;) {
29
+ let t = e[i];
30
+ if (r && t === "\\") i += 2;
31
+ else if (t === n) {
32
+ if (e[i + 1] === n) i += 2;
33
+ else return i + 1;
34
+ } else i++;
35
+ }
36
+ return e.length;
37
+ }
38
+ function d(e, t) {
39
+ let n = /^\$([A-Za-z_\u0080-￿][A-Za-z0-9_\u0080-￿]*)?\$/.exec(e.slice(t, t + 64));
40
+ if (!n) return -1;
41
+ let r = e.indexOf(n[0], t + n[0].length);
42
+ return r === -1 ? e.length : r + n[0].length;
43
+ }
44
+ function* f(e) {
45
+ let t = 0;
46
+ for (; t < e.length;) {
47
+ let n = e[t], r = t, f;
48
+ if (s(n)) {
49
+ for (; t < e.length && s(e[t]);) t++;
50
+ f = "space";
51
+ } else if (n === "-" && e[t + 1] === "-") t = e.indexOf("\n", t), t === -1 && (t = e.length), f = "comment";
52
+ else if (n === "/" && e[t + 1] === "*") t = l(e, t), f = "comment";
53
+ else if (n === "'") {
54
+ let n = e[t - 1], r = (n === "e" || n === "E") && !a(e[t - 2] ?? " ");
55
+ t = u(e, t, "'", r), f = "string";
56
+ } else if (n === "\"") t = u(e, t, "\"", !1), f = "ident";
57
+ else if (n === "$" && d(e, t) !== -1) t = d(e, t), f = "string";
58
+ else if (o(n) || n === "." && o(e[t + 1] ?? "")) {
59
+ let n = /^(?:0[xX][0-9a-fA-F_]+|\d[\d_]*(?:\.\d*)?(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/.exec(e.slice(t, t + 80));
60
+ t += n ? n[0].length : 1, f = "number";
61
+ } else if (i(n)) {
62
+ for (; t < e.length && a(e[t]);) t++;
63
+ f = "word";
64
+ } else if (c.includes(n)) {
65
+ for (; t < e.length && c.includes(e[t]) && !(e[t] === "-" && e[t + 1] === "-" && t > r) && !(e[t] === "/" && e[t + 1] === "*" && t > r);) t++;
66
+ f = "op";
67
+ } else t++, f = "punct";
68
+ yield {
69
+ kind: f,
70
+ start: r,
71
+ end: t
72
+ };
73
+ }
74
+ }
75
+ function p(i) {
76
+ let a = [], o = [...f(i)], s = (e) => {
77
+ for (let t = e + 1; t < o.length; t++) if (o[t].kind !== "space" && o[t].kind !== "comment") return o[t];
78
+ };
79
+ return o.forEach((o, c) => {
80
+ let l;
81
+ if (o.kind === "comment") l = "comment";
82
+ else if (o.kind === "string") l = "string";
83
+ else if (o.kind === "number") l = "number";
84
+ else if (o.kind === "op") l = "operator";
85
+ else if (o.kind === "word") {
86
+ let a = i.slice(o.start, o.end).toLowerCase(), u = s(c), d = u?.kind === "punct" && i[u.start] === "(";
87
+ /^[ebx]$/.test(a) && i[o.end] === "'" ? l = "string" : n.has(a) ? l = "constant" : t.has(a) && !d ? l = "type" : e.has(a) && !(d && r.has(a)) ? l = "keyword" : d && (l = "function");
88
+ }
89
+ if (!l) return;
90
+ let u = a[a.length - 1];
91
+ u && u.type === l && u.end === o.start && l !== "comment" ? u.end = o.end : a.push({
92
+ type: l,
93
+ start: o.start,
94
+ end: o.end
95
+ });
96
+ }), a;
97
+ }
98
+ function m(e) {
99
+ let t = [], n = 0, r = 0, i = !1, a = (n) => {
100
+ if (i) {
101
+ let i = r, a = n;
102
+ for (; i < a && s(e[i]);) i++;
103
+ for (; a > i && s(e[a - 1]);) a--;
104
+ a > i && t.push({
105
+ text: e.slice(i, a),
106
+ start: i,
107
+ end: a
108
+ });
109
+ }
110
+ i = !1;
111
+ };
112
+ for (let t of f(e)) if (t.kind !== "space" && t.kind !== "comment") {
113
+ if (i || (r = t.start), t.kind === "punct") {
114
+ let o = e[t.start];
115
+ if (o === "(") n++;
116
+ else if (o === ")") n = Math.max(0, n - 1);
117
+ else if (o === ";" && n === 0) {
118
+ i = !0, a(t.start), r = t.end;
119
+ continue;
120
+ }
121
+ }
122
+ i = !0;
123
+ }
124
+ return a(e.length), t;
125
+ }
126
+ function h(e, t) {
127
+ let n = Math.max(0, Math.min(e.length, t - 1)), r = 1, i = 0;
128
+ for (let t = 0; t < n; t++) e[t] === "\n" && (r++, i = t + 1);
129
+ return {
130
+ line: r,
131
+ column: n - i + 1
132
+ };
133
+ }
134
+ //#endregion
135
+ export { h as positionToLineColumn, m as splitStatements, p as sqlSpans };
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+ export type TabLockStatus = 'pending' | 'held' | 'blocked' | 'unsupported';
3
+ export interface TabLock {
4
+ status: TabLockStatus;
5
+ /** This tab holds the lock — or the browser cannot lock, in which case it may proceed (`status` is `unsupported`). */
6
+ held: boolean;
7
+ /** Ask the tab that holds the lock to give it up (it becomes `blocked` and may ask for it back). No-op unless blocked. */
8
+ takeover: () => void;
9
+ }
10
+ /** Takes an exclusive lock called `name` for as long as the component is mounted. Several components with the same name in one tab share it. */
11
+ export declare function useTabLock(name: string, { enabled }?: {
12
+ enabled?: boolean;
13
+ }): TabLock;
14
+ export interface SingleTabGateProps {
15
+ /** The lock name — the database name is a good choice (`idb://notes`). */
16
+ name: string;
17
+ /** Rendered only in the tab that holds the lock. */
18
+ children: ReactNode;
19
+ /** While the lock is being checked. */
20
+ pending?: ReactNode;
21
+ /** In a tab that does not hold the lock; receives `takeover` ("use it here"). */
22
+ blocked?: ReactNode | ((api: {
23
+ takeover: () => void;
24
+ }) => ReactNode);
25
+ }
26
+ /** Renders its children in one tab at a time. Other tabs show `blocked` until the holder closes or steps aside. */
27
+ export declare function SingleTabGate({ name, children, pending, blocked }: SingleTabGateProps): ReactNode;
28
+ //# sourceMappingURL=tab-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tab-lock.d.ts","sourceRoot":"","sources":["../../src/lib/tab-lock.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAa/F,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,CAAC;AAwG3E,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,sHAAsH;IACtH,IAAI,EAAE,OAAO,CAAC;IACd,0HAA0H;IAC1H,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gJAAgJ;AAChJ,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAc,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CA0BhG;AAED,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,EAAE,SAAS,CAAC;IACpB,uCAAuC;IACvC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,iFAAiF;IACjF,OAAO,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,SAAS,CAAC,CAAC;CACtE;AAED,mHAAmH;AACnH,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAc,EAAE,OAAc,EAAE,EAAE,kBAAkB,aAKnG"}
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import { useCallback as e, useEffect as t, useState as n, useSyncExternalStore as r } from "react";
3
+ //#region src/lib/tab-lock.tsx
4
+ var i = /* @__PURE__ */ new Map(), a = (e) => `bl-tab-lock:${e}`;
5
+ function o(e, t) {
6
+ e.status !== t && (e.status = t, e.listeners.forEach((e) => e()));
7
+ }
8
+ function s(e, { ifAvailable: t }) {
9
+ let n = navigator.locks, r = ++e.generation, i = new AbortController();
10
+ e.abort = i;
11
+ let c = (t) => {
12
+ if (r === e.generation) {
13
+ if (!t) {
14
+ o(e, "blocked"), s(e, { ifAvailable: !1 });
15
+ return;
16
+ }
17
+ return e.abort = null, o(e, "held"), new Promise((t) => {
18
+ e.release = () => {
19
+ e.release = null, t();
20
+ };
21
+ });
22
+ }
23
+ };
24
+ (t ? n.request(a(e.name), { ifAvailable: !0 }, c) : n.request(a(e.name), { signal: i.signal }, c)).catch(() => void 0);
25
+ }
26
+ function c(e) {
27
+ if (typeof navigator > "u" || !navigator.locks) {
28
+ o(e, "unsupported");
29
+ return;
30
+ }
31
+ typeof BroadcastChannel < "u" && (e.channel = new BroadcastChannel(a(e.name)), e.channel.onmessage = (t) => {
32
+ t.data === "takeover" && e.status === "held" && l(e);
33
+ }), s(e, { ifAvailable: !0 });
34
+ }
35
+ function l(e) {
36
+ e.release?.(), o(e, "blocked"), s(e, { ifAvailable: !1 });
37
+ }
38
+ function u(e) {
39
+ let t = i.get(e);
40
+ return t || (t = {
41
+ name: e,
42
+ status: "pending",
43
+ refs: 0,
44
+ listeners: /* @__PURE__ */ new Set(),
45
+ release: null,
46
+ abort: null,
47
+ channel: null,
48
+ closeTimer: null,
49
+ generation: 0
50
+ }, i.set(e, t), c(t)), t.closeTimer && (clearTimeout(t.closeTimer), t.closeTimer = null), t.refs++, t;
51
+ }
52
+ function d(e) {
53
+ --e.refs > 0 || (e.closeTimer = setTimeout(() => {
54
+ e.refs > 0 || (i.delete(e.name), e.generation++, e.abort?.abort(), e.release?.(), e.channel?.close());
55
+ }, 0));
56
+ }
57
+ function f(i, { enabled: a = !0 } = {}) {
58
+ let [o, s] = n(null);
59
+ t(() => {
60
+ if (!a) return;
61
+ let e = u(i);
62
+ return s(e), () => {
63
+ d(e), s(null);
64
+ };
65
+ }, [i, a]);
66
+ let c = r((e) => (o?.listeners.add(e), () => o?.listeners.delete(e)), () => o ? o.status : "pending", () => "pending"), l = e(() => {
67
+ o && o.status === "blocked" && o.channel?.postMessage("takeover");
68
+ }, [o]), f = a ? c : "unsupported";
69
+ return {
70
+ status: f,
71
+ held: f === "held" || f === "unsupported",
72
+ takeover: l
73
+ };
74
+ }
75
+ function p({ name: e, children: t, pending: n = null, blocked: r = null }) {
76
+ let i = f(e);
77
+ return i.status === "pending" ? n : i.held ? t : typeof r == "function" ? r({ takeover: i.takeover }) : r;
78
+ }
79
+ //#endregion
80
+ export { p as SingleTabGate, f as useTabLock };
@@ -0,0 +1,56 @@
1
+ import { TailscaleClient, TailscaleClientState } from './tailscale';
2
+ /** The slice of the package's IPN this uses (structural, so this file's types do not depend on it). */
3
+ export interface TailscaleIpn {
4
+ run(callbacks: {
5
+ notifyState: (state: TailscaleClientState) => void;
6
+ notifyNetMap: (netMap: string) => void;
7
+ notifyBrowseToURL: (url: string) => void;
8
+ notifyPanicRecover: (error: string) => void;
9
+ }): void;
10
+ login(): void;
11
+ logout(): void;
12
+ fetch(request: string | {
13
+ url: string;
14
+ method?: string;
15
+ headers?: Record<string, string>;
16
+ bodyBase64?: string;
17
+ redirect?: RequestRedirect;
18
+ }): Promise<{
19
+ url?: string;
20
+ status: number;
21
+ statusText?: string;
22
+ headers?: Record<string, string>;
23
+ bodyBase64?: string;
24
+ text?: () => Promise<string>;
25
+ }>;
26
+ }
27
+ export interface TailscaleConnectModule {
28
+ createIPN(config: {
29
+ authKey: string;
30
+ controlURL?: string;
31
+ hostname?: string;
32
+ stateStorage?: {
33
+ getState(id: string): string;
34
+ setState(id: string, value: string): void;
35
+ };
36
+ wasmURL?: string;
37
+ panicHandler: (error: string) => void;
38
+ /** DNS settings; almostnode passes each in camelCase and PascalCase because the Go side reads the latter. */
39
+ [setting: string]: unknown;
40
+ }): Promise<TailscaleIpn>;
41
+ }
42
+ export interface TailscaleConnectOptions {
43
+ /** Where `main.wasm` is served (for Vite: `import wasmURL from '@agent-wasm/tailscale-connect/main.wasm?url'`). */
44
+ wasmURL: string;
45
+ /** Loads the package. Default `import('@agent-wasm/tailscale-connect')`. */
46
+ load?: () => Promise<TailscaleConnectModule>;
47
+ /** Use the tailnet's DNS (MagicDNS at 100.100.100.100) so names like `nas.tail1234.ts.net` resolve inside the client. Default true.
48
+ * almostnode found name-based fetches failing in the WebAssembly runtime without it; this sends the settings it sends. */
49
+ acceptDns?: boolean;
50
+ }
51
+ /** The client keeps its prefs as hex-encoded JSON under `profile-…` keys, and a login can write `CorpDNS: false` back;
52
+ * almostnode rewrites it to true on the way in (its worker's stateStorage.setState), and so does this. */
53
+ export declare function keepCorpDns(id: string, value: string): string;
54
+ /** A `TailscaleClient` over `@agent-wasm/tailscale-connect`. Nothing loads until `start()`. */
55
+ export declare function createTailscaleConnectClient(options: TailscaleConnectOptions): TailscaleClient;
56
+ //# sourceMappingURL=tailscale-connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailscale-connect.d.ts","sourceRoot":"","sources":["../../src/lib/tailscale-connect.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAwD,MAAM,iBAAiB,CAAC;AAEnI,uGAAuG;AACvG,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,SAAS,EAAE;QACb,WAAW,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;QACnD,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;QACvC,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QACzC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;KAC7C,GAAG,IAAI,CAAC;IACT,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,eAAe,CAAA;KAAE,GAAG,OAAO,CAAC;QACpJ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;KAC9B,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC;QAC3F,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QACtC,6GAA6G;QAC7G,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;KAC5B,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,uBAAuB;IACtC,mHAAmH;IACnH,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7C;+HAC2H;IAC3H,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;2GAC2G;AAC3G,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7D;AAsBD,+FAA+F;AAC/F,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,uBAAuB,GAAG,eAAe,CAkE9F"}
@@ -0,0 +1,99 @@
1
+ //#region src/lib/tailscale-connect.ts
2
+ function e(e, t) {
3
+ if (!e.startsWith("profile-") || !t || t.length % 2) return t;
4
+ try {
5
+ let e = new Uint8Array(t.length / 2);
6
+ for (let n = 0; n < e.length; n++) e[n] = parseInt(t.slice(n * 2, n * 2 + 2), 16);
7
+ let n = JSON.parse(new TextDecoder().decode(e));
8
+ if (!n || typeof n != "object" || n.CorpDNS !== !1) return t;
9
+ let r = new TextEncoder().encode(JSON.stringify({
10
+ ...n,
11
+ CorpDNS: !0
12
+ }, null, " "));
13
+ return Array.from(r, (e) => e.toString(16).padStart(2, "0")).join("");
14
+ } catch {
15
+ return t;
16
+ }
17
+ }
18
+ function t(e) {
19
+ return {
20
+ acceptDns: e,
21
+ corpDns: e,
22
+ corpDNS: e,
23
+ CorpDNS: e,
24
+ dns: e,
25
+ dnsIP: e ? "100.100.100.100" : null,
26
+ bootstrapDns: e ? ["100.100.100.100", "fd7a:115c:a1e0::53"] : []
27
+ };
28
+ }
29
+ function n(e) {
30
+ let t = "";
31
+ for (let n = 0; n < e.length; n += 32768) t += String.fromCharCode(...e.subarray(n, n + 32768));
32
+ return btoa(t);
33
+ }
34
+ function r(e) {
35
+ let t = atob(e);
36
+ return Uint8Array.from(t, (e) => e.charCodeAt(0));
37
+ }
38
+ function i(i) {
39
+ let a = null, o = !1;
40
+ return {
41
+ async start(n) {
42
+ if (!i.wasmURL) throw Error("createTailscaleConnectClient needs `wasmURL` (where main.wasm is served).");
43
+ let r = await (i.load ?? (() => import("@agent-wasm/tailscale-connect")))(), s = new Map(Object.entries(n.state ?? {})), c = await r.createIPN({
44
+ authKey: n.authKey ?? "",
45
+ controlURL: n.controlUrl,
46
+ hostname: n.hostname,
47
+ wasmURL: i.wasmURL,
48
+ stateStorage: {
49
+ getState: (e) => s.get(e) ?? "",
50
+ setState: (t, r) => {
51
+ s.set(t, i.acceptDns === !1 ? r : e(t, r)), n.onState(Object.fromEntries(s));
52
+ }
53
+ },
54
+ panicHandler: (e) => n.onEvent({ error: e }),
55
+ ...t(i.acceptDns !== !1)
56
+ });
57
+ o || (a = c, c.run({
58
+ notifyState: (e) => n.onEvent({ state: e }),
59
+ notifyNetMap: (e) => {
60
+ try {
61
+ n.onEvent({ netMap: JSON.parse(e) });
62
+ } catch {
63
+ n.onEvent({ netMap: null });
64
+ }
65
+ },
66
+ notifyBrowseToURL: (e) => n.onEvent({ loginUrl: e }),
67
+ notifyPanicRecover: (e) => n.onEvent({ error: e })
68
+ }));
69
+ },
70
+ login() {
71
+ a?.login();
72
+ },
73
+ logout() {
74
+ a?.logout();
75
+ },
76
+ async fetch(e) {
77
+ if (!a) throw Error("The Tailscale client is not running.");
78
+ let t = (e.method ?? "GET").toUpperCase(), i = t === "GET" && !e.body && !e.headers?.length && (e.redirect ?? "follow") === "follow", o = await a.fetch(i ? e.url : {
79
+ url: e.url,
80
+ method: t,
81
+ headers: Object.fromEntries(e.headers ?? []),
82
+ bodyBase64: e.body ? n(e.body) : void 0,
83
+ redirect: e.redirect
84
+ }), s = o.bodyBase64 === void 0 ? o.text ? new TextEncoder().encode(await o.text()) : null : r(o.bodyBase64);
85
+ return {
86
+ url: o.url ?? e.url,
87
+ status: o.status,
88
+ statusText: o.statusText ?? "",
89
+ headers: Object.entries(o.headers ?? {}),
90
+ body: s
91
+ };
92
+ },
93
+ dispose() {
94
+ o = !0, a = null;
95
+ }
96
+ };
97
+ }
98
+ //#endregion
99
+ export { i as createTailscaleConnectClient, e as keepCorpDns };