@busiverse/ui 0.2.20 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/billing.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  getServicePricingSummaries,
17
17
  getServicePricingSummary,
18
18
  labelCadence
19
- } from "./chunk-YLQKXFA7.js";
19
+ } from "./chunk-OMH22UAV.js";
20
20
  import {
21
21
  busiverseSupportedRegions,
22
22
  getSupportedRegion
@@ -2264,7 +2264,7 @@ var busiverseServicePricingCatalog = [
2264
2264
  },
2265
2265
  {
2266
2266
  "service": "communication",
2267
- "operationCode": "COMM_EMAIL_SEND",
2267
+ "operationCode": "COMMUNICATION_EMAIL_SENT",
2268
2268
  "displayName": "Email send",
2269
2269
  "category": "DELIVERY",
2270
2270
  "unit": "message",
@@ -2293,7 +2293,7 @@ var busiverseServicePricingCatalog = [
2293
2293
  },
2294
2294
  {
2295
2295
  "service": "communication",
2296
- "operationCode": "COMM_SMS_SEGMENT_SENT",
2296
+ "operationCode": "COMMUNICATION_SMS_SENT",
2297
2297
  "displayName": "SMS segment sent",
2298
2298
  "category": "DELIVERY",
2299
2299
  "unit": "segment",
@@ -2322,7 +2322,7 @@ var busiverseServicePricingCatalog = [
2322
2322
  },
2323
2323
  {
2324
2324
  "service": "communication",
2325
- "operationCode": "COMM_PUSH_NOTIFICATION_SENT",
2325
+ "operationCode": "COMMUNICATION_PUSH_SENT",
2326
2326
  "displayName": "Push notification sent",
2327
2327
  "category": "DELIVERY",
2328
2328
  "unit": "recipient",
@@ -2351,7 +2351,7 @@ var busiverseServicePricingCatalog = [
2351
2351
  },
2352
2352
  {
2353
2353
  "service": "communication",
2354
- "operationCode": "COMM_IN_APP_NOTIFICATION_SENT",
2354
+ "operationCode": "COMMUNICATION_INAPP_NOTIFICATION_CREATED",
2355
2355
  "displayName": "In-app notification sent",
2356
2356
  "category": "DELIVERY",
2357
2357
  "unit": "recipient",
@@ -2380,7 +2380,7 @@ var busiverseServicePricingCatalog = [
2380
2380
  },
2381
2381
  {
2382
2382
  "service": "communication",
2383
- "operationCode": "COMM_WHATSAPP_MESSAGE_SENT",
2383
+ "operationCode": "COMMUNICATION_WHATSAPP_SENT",
2384
2384
  "displayName": "WhatsApp message sent",
2385
2385
  "category": "DELIVERY",
2386
2386
  "unit": "message",
@@ -2409,7 +2409,7 @@ var busiverseServicePricingCatalog = [
2409
2409
  },
2410
2410
  {
2411
2411
  "service": "communication",
2412
- "operationCode": "COMM_BROADCAST_RECIPIENT",
2412
+ "operationCode": "COMMUNICATION_BROADCAST_RECIPIENT",
2413
2413
  "displayName": "Broadcast recipient",
2414
2414
  "category": "DELIVERY",
2415
2415
  "unit": "recipient",
@@ -2438,7 +2438,7 @@ var busiverseServicePricingCatalog = [
2438
2438
  },
2439
2439
  {
2440
2440
  "service": "communication",
2441
- "operationCode": "COMM_CAMPAIGN_STEP_EXECUTED",
2441
+ "operationCode": "COMMUNICATION_CAMPAIGN_AUTOMATION_STEP",
2442
2442
  "displayName": "Campaign step execution",
2443
2443
  "category": "PLATFORM",
2444
2444
  "unit": "step",
@@ -2467,7 +2467,7 @@ var busiverseServicePricingCatalog = [
2467
2467
  },
2468
2468
  {
2469
2469
  "service": "communication",
2470
- "operationCode": "COMM_WEBHOOK_DELIVERY_ATTEMPT",
2470
+ "operationCode": "COMMUNICATION_WEBHOOK_DELIVERY_ATTEMPT",
2471
2471
  "displayName": "Webhook delivery attempt",
2472
2472
  "category": "DELIVERY",
2473
2473
  "unit": "attempt",
@@ -2496,7 +2496,7 @@ var busiverseServicePricingCatalog = [
2496
2496
  },
2497
2497
  {
2498
2498
  "service": "communication",
2499
- "operationCode": "COMM_DOMAIN_VERIFICATION",
2499
+ "operationCode": "COMMUNICATION_DOMAIN_VERIFICATION",
2500
2500
  "displayName": "Sender domain verification",
2501
2501
  "category": "GOVERNANCE",
2502
2502
  "unit": "domain",
@@ -2583,7 +2583,7 @@ var busiverseServicePricingCatalog = [
2583
2583
  },
2584
2584
  {
2585
2585
  "service": "communication",
2586
- "operationCode": "COMM_INBOUND_MESSAGE_PROCESSED",
2586
+ "operationCode": "COMMUNICATION_INBOUND_MESSAGE_RECEIVED",
2587
2587
  "displayName": "Inbound message processing",
2588
2588
  "category": "USAGE",
2589
2589
  "unit": "message",
@@ -7368,7 +7368,7 @@ var busiverseServicePricingCatalog = [
7368
7368
  },
7369
7369
  {
7370
7370
  "service": "wallet",
7371
- "operationCode": "WALLET_TRANSFER_SUBMITTED",
7371
+ "operationCode": "WALLET_TRANSFER_EXECUTED",
7372
7372
  "displayName": "Wallet transfer submission",
7373
7373
  "category": "FINANCIAL",
7374
7374
  "unit": "transfer",
@@ -0,0 +1,30 @@
1
+ import { Component, type ErrorInfo, type ReactNode } from "react";
2
+ export interface PageErrorBoundaryProps {
3
+ children: ReactNode;
4
+ /** Where a person is pointed when a fault keeps coming back. */
5
+ supportEmail?: string;
6
+ /** Where "start over" lands once what this browser kept has been cleared. */
7
+ startOverPath?: string;
8
+ }
9
+ interface PageErrorBoundaryState {
10
+ error: Error | null;
11
+ }
12
+ /**
13
+ * What a console shows when a page fails while drawing, instead of an empty screen.
14
+ *
15
+ * A render fault unmounts everything beneath the nearest boundary, and with none the person is left
16
+ * with the page background and no idea what happened. This says the page stopped, shows the fault's
17
+ * name and message for support (code, never data), and offers a reload or a fresh start. Starting
18
+ * over clears this tab's session storage, which is where the sign-in is kept, so a fault that
19
+ * follows the page through a reload cannot hold anyone in a loop.
20
+ */
21
+ export declare class PageErrorBoundary extends Component<PageErrorBoundaryProps, PageErrorBoundaryState> {
22
+ state: PageErrorBoundaryState;
23
+ static getDerivedStateFromError(error: Error): PageErrorBoundaryState;
24
+ componentDidCatch(error: Error, info: ErrorInfo): void;
25
+ private reload;
26
+ private startOver;
27
+ render(): ReactNode;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/feedback/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,SAAQ,SAAS,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACvF,KAAK,EAAE,sBAAsB,CAAmB;WAEzC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,sBAAsB;IAIrE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAI7D,OAAO,CAAC,MAAM,CAEZ;IAEF,OAAO,CAAC,SAAS,CAOf;IAEK,MAAM,IAAI,SAAS;CAsC3B"}
@@ -1,2 +1,3 @@
1
1
  export * from "./States";
2
+ export * from "./ErrorBoundary";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/feedback/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/feedback/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,10 @@
1
+ import {
2
+ BusiverseGithubIcon,
3
+ BusiverseLinkedInIcon,
4
+ BusiverseMailIcon,
5
+ BusiverseSocialIcon,
6
+ BusiverseXIcon
7
+ } from "./chunk-2TTXWTIT.js";
1
8
  import {
2
9
  busiverseColors,
3
10
  busiverseContainers,
@@ -41,7 +48,7 @@ import {
41
48
  getServicePricingSummaries,
42
49
  getServicePricingSummary,
43
50
  labelCadence
44
- } from "./chunk-YLQKXFA7.js";
51
+ } from "./chunk-OMH22UAV.js";
45
52
  import {
46
53
  BusiverseBrandHead,
47
54
  applyBusiverseBrandHead
@@ -72,13 +79,6 @@ import {
72
79
  import {
73
80
  BusiverseLogo
74
81
  } from "./chunk-RO6ZPS75.js";
75
- import {
76
- BusiverseGithubIcon,
77
- BusiverseLinkedInIcon,
78
- BusiverseMailIcon,
79
- BusiverseSocialIcon,
80
- BusiverseXIcon
81
- } from "./chunk-2TTXWTIT.js";
82
82
  import {
83
83
  cn
84
84
  } from "./chunk-PYZVP4NI.js";
@@ -284,6 +284,63 @@ function ForbiddenState({ description = "You do not have permission to access th
284
284
  return /* @__PURE__ */ jsx12(ErrorState, { title: "Access denied", description, action: /* @__PURE__ */ jsx12(Button, { variant: "secondary", children: "Go back" }) });
285
285
  }
286
286
 
287
+ // src/components/feedback/ErrorBoundary.tsx
288
+ import { Component } from "react";
289
+ import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
290
+ var PageErrorBoundary = class extends Component {
291
+ state = { error: null };
292
+ static getDerivedStateFromError(error) {
293
+ return { error };
294
+ }
295
+ componentDidCatch(error, info) {
296
+ console.error("A page stopped working:", error, info.componentStack);
297
+ }
298
+ reload = () => {
299
+ window.location.reload();
300
+ };
301
+ startOver = () => {
302
+ try {
303
+ sessionStorage.clear();
304
+ } catch {
305
+ }
306
+ window.location.assign(this.props.startOverPath ?? "/");
307
+ };
308
+ render() {
309
+ const { error } = this.state;
310
+ if (!error) return this.props.children;
311
+ const supportEmail = this.props.supportEmail ?? "support@busiversehq.com";
312
+ return /* @__PURE__ */ jsx13("div", { role: "alert", className: "flex min-h-screen items-center justify-center bg-background px-4", children: /* @__PURE__ */ jsxs6("div", { className: "busiverse-card max-w-md text-center", children: [
313
+ /* @__PURE__ */ jsx13("h1", { className: "font-heading text-2xl font-bold text-foreground", children: "This page stopped working" }),
314
+ /* @__PURE__ */ jsxs6("p", { className: "mt-3 leading-relaxed text-muted-foreground", children: [
315
+ "Nothing you were doing has been lost. Reloading usually clears it; if it keeps happening, tell us at",
316
+ " ",
317
+ /* @__PURE__ */ jsx13("a", { href: `mailto:${supportEmail}`, className: "text-primary underline-offset-4 hover:underline", children: supportEmail }),
318
+ "."
319
+ ] }),
320
+ /* @__PURE__ */ jsxs6("details", { className: "mt-6 rounded-xl border border-destructive/30 bg-destructive/10 p-4 text-left", children: [
321
+ /* @__PURE__ */ jsx13("summary", { className: "cursor-pointer text-sm font-medium text-foreground", children: "Technical details" }),
322
+ /* @__PURE__ */ jsxs6("p", { className: "mt-2 break-words font-mono text-xs text-muted-foreground", children: [
323
+ error.name,
324
+ ": ",
325
+ error.message
326
+ ] })
327
+ ] }),
328
+ /* @__PURE__ */ jsxs6("div", { className: "mt-8 flex flex-col items-center gap-3", children: [
329
+ /* @__PURE__ */ jsx13(
330
+ "button",
331
+ {
332
+ type: "button",
333
+ onClick: this.reload,
334
+ className: "rounded-xl bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground",
335
+ children: "Reload the page"
336
+ }
337
+ ),
338
+ /* @__PURE__ */ jsx13("button", { type: "button", onClick: this.startOver, className: "text-sm text-primary underline-offset-4 hover:underline", children: "Start over and sign in again" })
339
+ ] })
340
+ ] }) });
341
+ }
342
+ };
343
+
287
344
  // src/api/assertGatewayBaseUrl.ts
288
345
  var GATEWAY_PUBLIC_HOST = "api.busiversehq.com";
289
346
  var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
@@ -359,10 +416,10 @@ function createGatewayClient(options) {
359
416
 
360
417
  // src/auth/AuthSessionProvider.tsx
361
418
  import * as React4 from "react";
362
- import { jsx as jsx13 } from "react/jsx-runtime";
419
+ import { jsx as jsx14 } from "react/jsx-runtime";
363
420
  var AuthContext = React4.createContext(null);
364
421
  function AuthSessionProvider({ children, session }) {
365
- return /* @__PURE__ */ jsx13(AuthContext.Provider, { value: session, children });
422
+ return /* @__PURE__ */ jsx14(AuthContext.Provider, { value: session, children });
366
423
  }
367
424
  function useBusiverseAuth() {
368
425
  const value = React4.useContext(AuthContext);
@@ -371,34 +428,34 @@ function useBusiverseAuth() {
371
428
  }
372
429
 
373
430
  // src/auth/RequireAuth.tsx
374
- import { Fragment, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
431
+ import { Fragment, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
375
432
  function RequireAuth({ children }) {
376
433
  const auth = useBusiverseAuth();
377
- if (auth.isLoading) return /* @__PURE__ */ jsx14("div", { className: "busiverse-loading-state", children: "Checking session\u2026" });
434
+ if (auth.isLoading) return /* @__PURE__ */ jsx15("div", { className: "busiverse-loading-state", children: "Checking session\u2026" });
378
435
  if (!auth.isAuthenticated) {
379
- return /* @__PURE__ */ jsxs6("div", { className: "busiverse-auth-required", children: [
380
- /* @__PURE__ */ jsx14("h1", { children: "Sign in required" }),
381
- /* @__PURE__ */ jsx14("p", { children: "Use your BUSIVERSE account to continue." }),
382
- /* @__PURE__ */ jsx14(Button, { onClick: () => void auth.signIn(), children: "Sign in" })
436
+ return /* @__PURE__ */ jsxs7("div", { className: "busiverse-auth-required", children: [
437
+ /* @__PURE__ */ jsx15("h1", { children: "Sign in required" }),
438
+ /* @__PURE__ */ jsx15("p", { children: "Use your BUSIVERSE account to continue." }),
439
+ /* @__PURE__ */ jsx15(Button, { onClick: () => void auth.signIn(), children: "Sign in" })
383
440
  ] });
384
441
  }
385
- return /* @__PURE__ */ jsx14(Fragment, { children });
442
+ return /* @__PURE__ */ jsx15(Fragment, { children });
386
443
  }
387
444
 
388
445
  // src/auth/SignUpLink.tsx
389
- import { jsx as jsx15 } from "react/jsx-runtime";
446
+ import { jsx as jsx16 } from "react/jsx-runtime";
390
447
  function SignUpLink({ signupUrl = "https://user.busiversehq.com/signup", children = "Create your Busiverse account", ...props }) {
391
- return /* @__PURE__ */ jsx15("a", { href: signupUrl, ...props, children });
448
+ return /* @__PURE__ */ jsx16("a", { href: signupUrl, ...props, children });
392
449
  }
393
450
 
394
451
  // src/auth/UserMenu.tsx
395
- import { jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
452
+ import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
396
453
  function UserMenu() {
397
454
  const auth = useBusiverseAuth();
398
- if (!auth.isAuthenticated || !auth.user) return /* @__PURE__ */ jsx16(Button, { size: "sm", onClick: () => void auth.signIn(), children: "Sign in" });
399
- return /* @__PURE__ */ jsxs7("div", { className: "busiverse-user-menu", children: [
400
- /* @__PURE__ */ jsx16("span", { children: auth.user.name ?? auth.user.email ?? "User" }),
401
- /* @__PURE__ */ jsx16(Button, { size: "sm", variant: "ghost", onClick: () => void auth.signOut(), children: "Sign out" })
455
+ if (!auth.isAuthenticated || !auth.user) return /* @__PURE__ */ jsx17(Button, { size: "sm", onClick: () => void auth.signIn(), children: "Sign in" });
456
+ return /* @__PURE__ */ jsxs8("div", { className: "busiverse-user-menu", children: [
457
+ /* @__PURE__ */ jsx17("span", { children: auth.user.name ?? auth.user.email ?? "User" }),
458
+ /* @__PURE__ */ jsx17(Button, { size: "sm", variant: "ghost", onClick: () => void auth.signOut(), children: "Sign out" })
402
459
  ] });
403
460
  }
404
461
  export {
@@ -438,6 +495,7 @@ export {
438
495
  MarketingPricingCard,
439
496
  MarketingSectionHeader,
440
497
  NorthSouthViolationError,
498
+ PageErrorBoundary,
441
499
  PageHeader,
442
500
  RegionSelector,
443
501
  RequireAuth,
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Where the signed-in person is, recorded with location so every entity they make can be placed.
3
+ *
4
+ * The browser is asked first, through its own permission prompt. Given, the reading is sent as the
5
+ * browser took it. Refused, unavailable or slow, location is asked to place the person by the network
6
+ * address the request came from instead, so every signed-in session has a position: precise where the
7
+ * person allowed it, approximate where they did not.
8
+ */
9
+ /** A reading the browser took. */
10
+ export interface PositionReading {
11
+ latitude: number;
12
+ longitude: number;
13
+ /** How far from the point the person may be, in metres, as the browser states it. */
14
+ accuracyMeters: number | null;
15
+ /** When the browser took the reading, as an ISO-8601 instant. */
16
+ capturedAt: string;
17
+ }
18
+ /** How the position reaches location; each frontend sends it with its own signed-in client. */
19
+ export interface PositionSender {
20
+ /** Sends a reading to `POST /location/api/v1/positions/mine`. */
21
+ record(reading: PositionReading): Promise<unknown>;
22
+ /** Asks `POST /location/api/v1/positions/mine/approximate` to place the person by their address. */
23
+ recordApproximate(): Promise<unknown>;
24
+ }
25
+ /** A console's own signed-in request: it attaches the person's token, as the console's other calls do. */
26
+ export type SignedInSend = (url: string, init: {
27
+ method: "POST";
28
+ headers: Record<string, string>;
29
+ body?: string;
30
+ }) => Promise<unknown>;
31
+ /**
32
+ * The sender every console uses: location's own-position endpoints behind the gateway, reached with
33
+ * the console's signed-in request. Every request at the edge reads `/<service>/api/v1/<resource>`,
34
+ * so location's paths follow from the gateway alone.
35
+ */
36
+ export declare function positionSender(gatewayUrl: string, send: SignedInSend): PositionSender;
37
+ /** What was recorded: the browser's reading, or the network's approximation. */
38
+ export type PositionOutcome = "browser" | "approximate";
39
+ export interface CaptureOptions {
40
+ /** The browser's geolocation; absent where the browser offers none. */
41
+ geolocation?: Geolocation | null;
42
+ /** How long to wait for the browser before falling back, in milliseconds. */
43
+ timeoutMs?: number;
44
+ }
45
+ /**
46
+ * Records the person's position once: the browser's reading when it gives one, the network's
47
+ * approximation when it does not. A failure to send either is the caller's to see.
48
+ */
49
+ export declare function capturePosition(sender: PositionSender, options?: CaptureOptions): Promise<PositionOutcome>;
50
+ //# sourceMappingURL=capturePosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capturePosition.d.ts","sourceRoot":"","sources":["../../src/position/capturePosition.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,kCAAkC;AAClC,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,oGAAoG;IACpG,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC;AAED,0GAA0G;AAC1G,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvI;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,cAAc,CAOrF;AAED,gFAAgF;AAChF,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,aAAa,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmBD;;;GAGG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,eAAe,CAAC,CAWpH"}
@@ -0,0 +1,13 @@
1
+ import { type CaptureOptions, type PositionSender } from "./capturePosition";
2
+ /** Session storage key: this tab has already recorded the signed-in person's position. */
3
+ export declare const POSITION_CAPTURED_KEY = "busiverse.position.captured";
4
+ /**
5
+ * Records the signed-in person's position once per tab, as soon as they are signed in.
6
+ *
7
+ * Mount it once, at the root of a console, with the console's own signed-in client. A send that
8
+ * fails is reported to `onError` and tried again on the next sign-in or page load.
9
+ */
10
+ export declare function usePositionCapture(signedIn: boolean, sender: PositionSender, options?: CaptureOptions & {
11
+ onError?: (cause: unknown) => void;
12
+ }): void;
13
+ //# sourceMappingURL=usePositionCapture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePositionCapture.d.ts","sourceRoot":"","sources":["../../src/position/usePositionCapture.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE9F,0FAA0F;AAC1F,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AAkBnE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,cAAc,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAAO,GACpE,IAAI,CAWN"}
@@ -0,0 +1,4 @@
1
+ export { capturePosition, positionSender } from "./position/capturePosition";
2
+ export type { CaptureOptions, PositionOutcome, PositionReading, PositionSender, SignedInSend } from "./position/capturePosition";
3
+ export { POSITION_CAPTURED_KEY, usePositionCapture } from "./position/usePositionCapture";
4
+ //# sourceMappingURL=position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../src/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC7E,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACjI,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,69 @@
1
+ // src/position/capturePosition.ts
2
+ function positionSender(gatewayUrl, send) {
3
+ const base = `${gatewayUrl.replace(/\/+$/, "")}/location/api/v1/positions/mine`;
4
+ const headers = { "Content-Type": "application/json" };
5
+ return {
6
+ record: (reading) => send(base, { method: "POST", headers, body: JSON.stringify(reading) }),
7
+ recordApproximate: () => send(`${base}/approximate`, { method: "POST", headers })
8
+ };
9
+ }
10
+ var MAXIMUM_AGE_MS = 5 * 60 * 1e3;
11
+ var readBrowser = (geolocation, timeoutMs) => new Promise((resolve) => {
12
+ geolocation.getCurrentPosition(
13
+ (position) => resolve({
14
+ latitude: position.coords.latitude,
15
+ longitude: position.coords.longitude,
16
+ accuracyMeters: Number.isFinite(position.coords.accuracy) ? position.coords.accuracy : null,
17
+ capturedAt: new Date(position.timestamp).toISOString()
18
+ }),
19
+ () => resolve(null),
20
+ { enableHighAccuracy: false, timeout: timeoutMs, maximumAge: MAXIMUM_AGE_MS }
21
+ );
22
+ });
23
+ async function capturePosition(sender, options = {}) {
24
+ const geolocation = options.geolocation === void 0 ? typeof navigator !== "undefined" ? navigator.geolocation ?? null : null : options.geolocation;
25
+ const reading = geolocation ? await readBrowser(geolocation, options.timeoutMs ?? 1e4) : null;
26
+ if (reading) {
27
+ await sender.record(reading);
28
+ return "browser";
29
+ }
30
+ await sender.recordApproximate();
31
+ return "approximate";
32
+ }
33
+
34
+ // src/position/usePositionCapture.ts
35
+ import { useEffect } from "react";
36
+ var POSITION_CAPTURED_KEY = "busiverse.position.captured";
37
+ var alreadyCaptured = () => {
38
+ try {
39
+ return typeof sessionStorage !== "undefined" && sessionStorage.getItem(POSITION_CAPTURED_KEY) === "1";
40
+ } catch {
41
+ return false;
42
+ }
43
+ };
44
+ var markCaptured = () => {
45
+ try {
46
+ sessionStorage.setItem(POSITION_CAPTURED_KEY, "1");
47
+ } catch {
48
+ }
49
+ };
50
+ function usePositionCapture(signedIn, sender, options = {}) {
51
+ useEffect(() => {
52
+ if (!signedIn || alreadyCaptured()) return;
53
+ let cancelled = false;
54
+ capturePosition(sender, options).then(() => {
55
+ if (!cancelled) markCaptured();
56
+ }).catch((cause) => {
57
+ if (!cancelled) options.onError?.(cause);
58
+ });
59
+ return () => {
60
+ cancelled = true;
61
+ };
62
+ }, [signedIn]);
63
+ }
64
+ export {
65
+ POSITION_CAPTURED_KEY,
66
+ capturePosition,
67
+ positionSender,
68
+ usePositionCapture
69
+ };
package/dist/styles.css CHANGED
@@ -4,8 +4,8 @@
4
4
  * itself, and substituting theme-scoped tokens into the kit would invert every one of its
5
5
  * surfaces. What guards this file is busiverse-ui/tests/brand-compliance.test.mjs, which holds
6
6
  * every value here to the brand document and measures the contrast of each pair -- a stronger
7
- * check than the literal scan. The absence of a theme-independent slate is recorded in
8
- * DECISIONS-PENDING.md. */
7
+ * check than the literal scan. The theme-independent slates are --color-absolute-slate-950 and
8
+ * --color-absolute-slate-900, below. */
9
9
  /* Font loading is intentionally app-owned. Self-host or load Space Grotesk, Inter, and JetBrains Mono in each frontend. */
10
10
  :root,
11
11
  .light {
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * A hex literal in that position renders the same but stops tracking the brand the moment the token
15
15
  * moves, and nothing fails when it diverges — a colour is never an error.
16
- * `ops/check-brand-tokens.sh` reports literals that a token already covers.
16
+ * `harness/ops/check-brand-tokens.sh` reports literals that a token already covers.
17
17
  *
18
18
  * <h2>Why it reads the live value rather than returning a constant</h2>
19
19
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@busiverse/ui",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "author": "Joel Julius Okoromi <okmarq@gmail.com> (https://busiversehq.com)",
5
5
  "description": "BUSIVERSE shared React UI, design tokens, pricing, i18n, auth helpers, and product shell. Network-neutral core; Gateway transport is app-injected.",
6
6
  "type": "module",
@@ -66,11 +66,16 @@
66
66
  "types": "./dist/sandbox.d.ts",
67
67
  "import": "./dist/sandbox.js",
68
68
  "default": "./dist/sandbox.js"
69
+ },
70
+ "./position": {
71
+ "types": "./dist/position.d.ts",
72
+ "import": "./dist/position.js",
73
+ "default": "./dist/position.js"
69
74
  }
70
75
  },
71
76
  "scripts": {
72
77
  "clean": "node scripts/clean.mjs",
73
- "build": "npm run clean && tsup src/index.ts src/tailwind-public.ts src/brand.ts src/i18n-public.ts src/billing.ts src/social.ts src/marketing.ts src/assets-public.ts src/theme-public.ts src/sandbox.ts --format esm --target es2022 && tsc -p tsconfig.build.json && node scripts/copy-static.mjs",
78
+ "build": "npm run clean && tsup src/index.ts src/tailwind-public.ts src/brand.ts src/i18n-public.ts src/billing.ts src/social.ts src/marketing.ts src/assets-public.ts src/theme-public.ts src/sandbox.ts src/position.ts --format esm --target es2022 && tsc -p tsconfig.build.json && node scripts/copy-static.mjs",
74
79
  "typecheck": "tsc --noEmit",
75
80
  "lint": "eslint .",
76
81
  "test": "node --test tests/*.test.mjs",