@hanzo/rooms 0.1.56 → 0.1.57

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/host.js CHANGED
@@ -25,7 +25,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
25
25
  import { createContext, useContext } from 'react';
26
26
  import { useIam, useOrganizations } from '@hanzo/iam/react';
27
27
  import { useAppearance } from '@hanzo/appearance';
28
- import { where } from './where.js';
28
+ import { iam } from './lib/api.js';
29
29
  const Plain = ({ prefetch: _prefetch, ...rest }) => _jsx("a", { ...rest });
30
30
  const Context = createContext({
31
31
  router: {
@@ -59,7 +59,7 @@ export function useLook() {
59
59
  // passing through a room on the way to sign in sends nothing to the issuer.
60
60
  return useAppearance({
61
61
  org: org.id,
62
- account: accessToken ? { base: (where().iam ?? 'https://hanzo.id').replace(/\/+$/, ''), token: accessToken } : undefined,
62
+ account: accessToken ? { base: iam(), token: accessToken } : undefined,
63
63
  });
64
64
  }
65
65
  /**
package/dist/lib/host.js CHANGED
@@ -207,9 +207,11 @@ const DEVNET = '-dev.hanzo.ai';
207
207
  * either: it is hanzo.ai/dev's old address and redirects there.
208
208
  */
209
209
  export function devnet(hostname) {
210
- if (!hostname.endsWith(DEVNET))
210
+ // A fully qualified name (app-dev.hanzo.ai.) is the same host.
211
+ const host = hostname.endsWith('.') ? hostname.slice(0, -1) : hostname;
212
+ if (!host.endsWith(DEVNET))
211
213
  return false;
212
- const label = hostname.slice(0, -'.hanzo.ai'.length);
214
+ const label = host.slice(0, -'.hanzo.ai'.length);
213
215
  return label.length > '-dev'.length && !label.includes('.');
214
216
  }
215
217
  /**
package/dist/lib/pay.d.ts CHANGED
@@ -17,6 +17,14 @@
17
17
  * hanzo.bot, and the checkout lives on hanzo.ai.
18
18
  */
19
19
  export declare const BILLING_URL = "https://hanzo.ai/pay";
20
+ /**
21
+ * The devnet's checkout: the same /pay mount on the devnet's site host, which
22
+ * charges Square's sandbox through the devnet's cloud. A page on a devnet host
23
+ * sends a buyer here and never to production's checkout.
24
+ */
25
+ export declare const BILLING_DEV = "https://app-dev.hanzo.ai/pay";
26
+ /** The checkout for the page in front of us: the devnet's on a devnet host, hanzo.ai's everywhere else. */
27
+ export declare function billing(): string;
20
28
  /**
21
29
  * The checkout address, opened on a plan when one is named, and returning to
22
30
  * `back` once the buyer has paid. Without `back` a paid buyer lands on the pay
package/dist/lib/pay.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Kept apart from `plans.ts`, which reads the bundled plan catalogue: a page
5
5
  * that only links the pay page or prints a price carries none of it.
6
6
  */
7
+ import { devnet } from "./host.js";
7
8
  import { org } from "./session.js";
8
9
  /**
9
10
  * Where money changes hands: the checkout, mounted at hanzo.ai/pay so a buyer
@@ -18,6 +19,16 @@ import { org } from "./session.js";
18
19
  * hanzo.bot, and the checkout lives on hanzo.ai.
19
20
  */
20
21
  export const BILLING_URL = "https://hanzo.ai/pay";
22
+ /**
23
+ * The devnet's checkout: the same /pay mount on the devnet's site host, which
24
+ * charges Square's sandbox through the devnet's cloud. A page on a devnet host
25
+ * sends a buyer here and never to production's checkout.
26
+ */
27
+ export const BILLING_DEV = "https://app-dev.hanzo.ai/pay";
28
+ /** The checkout for the page in front of us: the devnet's on a devnet host, hanzo.ai's everywhere else. */
29
+ export function billing() {
30
+ return typeof window !== "undefined" && devnet(window.location.hostname) ? BILLING_DEV : BILLING_URL;
31
+ }
21
32
  /**
22
33
  * The checkout address, opened on a plan when one is named, and returning to
23
34
  * `back` once the buyer has paid. Without `back` a paid buyer lands on the pay
@@ -50,9 +61,10 @@ export function payUrl(path, query) {
50
61
  if (v)
51
62
  q.set(k, v);
52
63
  const s = q.toString();
64
+ const at = billing();
53
65
  if (path === "/" && !s)
54
- return BILLING_URL;
55
- return `${BILLING_URL}${path}${s ? `?${s}` : ""}`;
66
+ return at;
67
+ return `${at}${path}${s ? `?${s}` : ""}`;
56
68
  }
57
69
  export const dollars = (n) => `$${n.toFixed(2)}`;
58
70
  /** Money as a sentence says it: whole dollars bare, anything else to the cent — $20, $16.67. */
package/dist/lib/plans.js CHANGED
@@ -32,7 +32,7 @@
32
32
  import { useEffect, useMemo, useState } from "react";
33
33
  import { where } from "../where.js";
34
34
  import { api } from "./api.js";
35
- import { BILLING_URL, checkoutUrl, dollars, money, payUrl } from "./pay.js";
35
+ import { billing, checkoutUrl, dollars, money, payUrl } from "./pay.js";
36
36
  /**
37
37
  * The checkout a plan's CTA opens.
38
38
  *
@@ -52,7 +52,7 @@ export function planCheckoutUrl(plan, back) {
52
52
  export function term(href, interval) {
53
53
  if (interval === "month")
54
54
  return href;
55
- const url = new URL(href, BILLING_URL);
55
+ const url = new URL(href, billing());
56
56
  url.searchParams.set("interval", "year");
57
57
  return url.toString();
58
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/rooms",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "description": "The workspace rooms — Home, Chat, Inbox, Contacts, Meet, Cal, Drive, Board, Work, Bots — and the frame that holds them, once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",