@getauthui/core 0.1.14 → 0.1.15

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 CHANGED
@@ -15,7 +15,7 @@
15
15
  visibility: hidden;
16
16
  }
17
17
  </style>
18
- <script type="module" src="https://unpkg.com/@getauthui/core@0.1.14"></script>
18
+ <script type="module" src="https://unpkg.com/@getauthui/core@0.1.15"></script>
19
19
 
20
20
  <authui-config
21
21
  endpoint="https://cloud.appwrite.io/v1"
@@ -65,7 +65,7 @@ CDN:
65
65
  visibility: hidden;
66
66
  }
67
67
  </style>
68
- <script type="module" src="https://unpkg.com/@getauthui/core@0.1.14"></script>
68
+ <script type="module" src="https://unpkg.com/@getauthui/core@0.1.15"></script>
69
69
  ```
70
70
 
71
71
  The `<style>` keeps `<authui-show>` and the buttons hidden until the module defines them. See [`<authui-show>`](https://getauthui.appwrite.network/docs/components/show).
@@ -73,7 +73,7 @@ The `<style>` keeps `<authui-show>` and the buttons hidden until the module defi
73
73
  The default CDN URL is an ESM module: it defines the elements but does **not** set `window.AuthUI`. For `AuthUI.init` / `AuthUI.on` from a classic script, use the IIFE build:
74
74
 
75
75
  ```html
76
- <script src="https://unpkg.com/@getauthui/core@0.1.14/dist/authui.cdn.js"></script>
76
+ <script src="https://unpkg.com/@getauthui/core@0.1.15/dist/authui.cdn.js"></script>
77
77
  ```
78
78
 
79
79
  npm:
@@ -19,8 +19,12 @@ export declare function useAuthUI(): {
19
19
  *
20
20
  * Configuration runs during render (not in an effect) so the first paint already
21
21
  * sees `configured: true` and a non-null `getClient()` when `endpoint` and
22
- * `project` are present. Changing any config field reconfigures the store.
23
- * `configure()` is idempotent, so React Strict Mode double-invoke is safe.
22
+ * `project` are present. Incomplete config (empty endpoint or project) mirrors
23
+ * `<authui-config>`: it does not mark configured, and surfaces `configError`.
24
+ * Changing any config field reconfigures the store. Passing a new object with
25
+ * the same values is fine; the fingerprint sorts keys so insertion order does
26
+ * not matter. `configure()` is idempotent, so React Strict Mode double-invoke
27
+ * is safe.
24
28
  */
25
29
  export declare function AuthUIProvider({ config, children, }: {
26
30
  config: AuthUIConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzF,OAAO,gCAAgC,CAAC;AACxC,OAAO,8BAA8B,CAAC;AACtC,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AACzC,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,qCAAqC,CAAC;AAE7C,iEAAiE;AACjE,wBAAgB,SAAS;;;;;;;;;;;EAUxB;AAOD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,GAAG,YAAY,CAQf;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE;IACjC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,YAAY,CAef;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;IAC3E,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAA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cAAc,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,GAAG,YAAY,CA6Bf;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,GAAG,YAAY,GAAG,IAAI,CAItB"}
package/dist/react.js CHANGED
@@ -1,73 +1,90 @@
1
- import { createElement as c, useState as o, useEffect as i, useRef as h, Fragment as a } from "react";
2
- import { a as s, z as f, c as m, o as d } from "./authui-user-button-CV2B_0j5.js";
1
+ import { createElement as i, useState as r, useEffect as c, useRef as h, Fragment as f } from "react";
2
+ import { a as o, z as m, c as d, o as S } from "./authui-user-button-CV2B_0j5.js";
3
3
  function v() {
4
- const [e, n] = o(() => s.getState());
5
- return i(() => s.on("change", n), []), {
4
+ const [e, n] = r(() => o.getState());
5
+ return c(() => o.on("change", n), []), {
6
6
  ...e,
7
- open: d,
8
- close: m,
9
- signOut: () => s.signOut(),
10
- store: s
7
+ open: S,
8
+ close: d,
9
+ signOut: () => o.signOut(),
10
+ store: o
11
11
  };
12
12
  }
13
- function S(e) {
14
- return JSON.stringify(e);
13
+ function l(e) {
14
+ if (e === null || typeof e != "object") return e;
15
+ if (Array.isArray(e)) return e.map(l);
16
+ const n = e, t = {};
17
+ for (const u of Object.keys(n).sort())
18
+ t[u] = l(n[u]);
19
+ return t;
15
20
  }
16
- function A({
21
+ function I(e) {
22
+ return JSON.stringify(l(e));
23
+ }
24
+ function O({
17
25
  config: e,
18
26
  children: n
19
27
  }) {
20
- const t = S(e), u = h(null);
21
- return u.current !== t && (u.current = t, s.configure(e)), c(a, null, n);
28
+ const t = I(e), u = h(null);
29
+ if (u.current !== t) {
30
+ u.current = t;
31
+ const a = e.endpoint?.trim() ?? "", s = e.project?.trim() ?? "";
32
+ !a || !s ? o.notifyConfigIncomplete() : o.configure(e);
33
+ }
34
+ return i(f, null, n);
22
35
  }
23
36
  function E(e) {
24
- const [n, t] = o(null);
25
- return i(() => {
37
+ const [n, t] = r(null);
38
+ return c(() => {
26
39
  !n || e.closeOnSuccess === void 0 || (n.closeOnSuccess = e.closeOnSuccess);
27
- }, [n, e.closeOnSuccess]), c("authui-modal", {
40
+ }, [n, e.closeOnSuccess]), c(() => {
41
+ !n || typeof e.open != "boolean" || (n.open = e.open);
42
+ }, [n, e.open]), i("authui-modal", {
28
43
  ref: t,
29
44
  view: e.view,
30
- open: e.open || void 0,
45
+ // Preserve boolean false; `props.open || undefined` would drop it and leave
46
+ // the dialog open. Controlled writes also go through the effect above.
47
+ open: e.open === void 0 ? void 0 : e.open,
31
48
  // Lit boolean attrs treat presence as true; write the string "false" so HTML
32
49
  // and React can turn the default off. Also set the JS property above.
33
50
  "close-on-success": e.closeOnSuccess === !1 ? "false" : e.closeOnSuccess === !0 ? "" : void 0
34
51
  });
35
52
  }
36
- function O(e) {
37
- return c(
53
+ function b(e) {
54
+ return i(
38
55
  "authui-button",
39
56
  { view: e.view, variant: e.variant, size: e.size },
40
57
  e.children
41
58
  );
42
59
  }
43
- function U(e) {
44
- return c(g, e);
60
+ function y(e) {
61
+ return i(w, e);
45
62
  }
46
- function g(e) {
47
- const [n, t] = o(null);
48
- return i(() => {
63
+ function w(e) {
64
+ const [n, t] = r(null);
65
+ return c(() => {
49
66
  if (!n || !e.onSuccess) return;
50
67
  const u = () => e.onSuccess?.();
51
68
  return n.addEventListener("authui-success", u), () => n.removeEventListener("authui-success", u);
52
- }, [n, e.onSuccess]), c("authui-sign-in", { ref: t, view: e.view });
69
+ }, [n, e.onSuccess]), i("authui-sign-in", { ref: t, view: e.view });
53
70
  }
54
- function M(e) {
55
- return c("authui-account", { tab: e.tab });
71
+ function U(e) {
72
+ return i("authui-account", { tab: e.tab });
56
73
  }
57
- function T(e) {
58
- const [n, t] = o(null);
59
- return i(() => {
74
+ function M(e) {
75
+ const [n, t] = r(null);
76
+ return c(() => {
60
77
  !n || e.showTeams === void 0 || (n.showTeams = e.showTeams);
61
- }, [n, e.showTeams]), i(() => {
78
+ }, [n, e.showTeams]), c(() => {
62
79
  n && (n.menuItems = e.menuItems ?? []);
63
- }, [n, e.menuItems]), i(() => {
80
+ }, [n, e.menuItems]), c(() => {
64
81
  if (!n || !e.onMenuAction) return;
65
- const u = (l) => {
66
- const r = l.detail?.actionId;
67
- r && e.onMenuAction?.(r);
82
+ const u = (a) => {
83
+ const s = a.detail?.actionId;
84
+ s && e.onMenuAction?.(s);
68
85
  };
69
86
  return n.addEventListener("authui-menu-action", u), () => n.removeEventListener("authui-menu-action", u);
70
- }, [n, e.onMenuAction]), c(
87
+ }, [n, e.onMenuAction]), i(
71
88
  "authui-user-button",
72
89
  {
73
90
  ref: t,
@@ -78,17 +95,17 @@ function T(e) {
78
95
  e.children
79
96
  );
80
97
  }
81
- function b(e) {
98
+ function j(e) {
82
99
  const { status: n } = v();
83
- return f(n, e.when, e.unless) ? c(a, null, e.children) : null;
100
+ return m(n, e.when, e.unless) ? i(f, null, e.children) : null;
84
101
  }
85
102
  export {
86
- M as AuthUIAccount,
87
- O as AuthUIButton,
103
+ U as AuthUIAccount,
104
+ b as AuthUIButton,
88
105
  E as AuthUIModal,
89
- A as AuthUIProvider,
90
- U as AuthUISignIn,
91
- T as AuthUIUserButton,
92
- b as Show,
106
+ O as AuthUIProvider,
107
+ y as AuthUISignIn,
108
+ M as AuthUIUserButton,
109
+ j as Show,
93
110
  v as useAuthUI
94
111
  };
package/dist/types.d.ts CHANGED
@@ -121,7 +121,7 @@ export interface AuthUIState {
121
121
  configured: boolean;
122
122
  /**
123
123
  * Developer-facing configuration problem (wrong project, origin, endpoint, or
124
- * incomplete <authui-config>). When set, sign-in shows this instead of a form.
124
+ * incomplete config). When set, sign-in shows this instead of a form.
125
125
  */
126
126
  configError: string | null;
127
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getauthui/core",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Drop-in authentication UI for Appwrite. One script tag, every sign-in method, MFA, sessions and account management as web components.",
5
5
  "type": "module",
6
6
  "main": "./dist/authui.js",