@shware/http 1.0.2 → 1.0.3

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.
@@ -20,47 +20,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/google-one-tap/index.ts
21
21
  var google_one_tap_exports = {};
22
22
  __export(google_one_tap_exports, {
23
- useGoogleOneTap: () => useGoogleOneTap
23
+ prompt: () => prompt
24
24
  });
25
25
  module.exports = __toCommonJS(google_one_tap_exports);
26
- var import_react = require("react");
27
- function useGoogleOneTap({ clientId, callback }) {
28
- const [loaded, setLoaded] = (0, import_react.useState)(false);
29
- const ref = (0, import_react.useRef)(callback);
30
- ref.current = callback;
31
- (0, import_react.useEffect)(() => {
32
- const scriptId = "google-one-tap";
33
- const script = document.createElement("script");
34
- script.id = scriptId;
35
- script.async = true;
36
- script.defer = true;
37
- script.src = "https://accounts.google.com/gsi/client";
38
- script.onload = () => {
39
- window.google.accounts.id.initialize({
40
- ux_mode: "popup",
41
- context: "signin",
42
- auto_select: false,
43
- client_id: clientId,
44
- use_fedcm_for_prompt: true,
45
- cancel_on_tap_outside: false,
46
- callback: ref.current
47
- });
48
- setLoaded(true);
49
- };
50
- document.head.appendChild(script);
51
- return () => {
52
- setLoaded(false);
53
- script.remove();
54
- };
55
- }, [clientId]);
56
- return {
57
- loaded,
58
- prompt: () => window.google?.accounts?.id?.prompt(),
59
- cancel: () => window.google?.accounts?.id?.cancel()
26
+ function prompt({ clientId, callback }) {
27
+ const scriptId = "google-one-tap";
28
+ const script = document.createElement("script");
29
+ script.id = scriptId;
30
+ script.async = true;
31
+ script.defer = true;
32
+ script.src = "https://accounts.google.com/gsi/client";
33
+ script.onload = () => {
34
+ window.google.accounts.id.initialize({
35
+ ux_mode: "popup",
36
+ context: "signin",
37
+ auto_select: false,
38
+ client_id: clientId,
39
+ use_fedcm_for_prompt: true,
40
+ cancel_on_tap_outside: false,
41
+ callback
42
+ });
43
+ window.google?.accounts?.id?.prompt();
60
44
  };
45
+ document.head.appendChild(script);
61
46
  }
62
47
  // Annotate the CommonJS export names for ESM import in node:
63
48
  0 && (module.exports = {
64
- useGoogleOneTap
49
+ prompt
65
50
  });
66
51
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport type { GoogleAccounts, CredentialResponse } from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n clientId: string;\n callback: (response: CredentialResponse) => void | Promise<void>;\n};\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport function useGoogleOneTap({ clientId, callback }: Props) {\n const [loaded, setLoaded] = useState(false);\n const ref = useRef(callback);\n ref.current = callback;\n\n useEffect(() => {\n const scriptId = 'google-one-tap';\n const script = document.createElement('script');\n script.id = scriptId;\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select: false,\n client_id: clientId,\n use_fedcm_for_prompt: true,\n cancel_on_tap_outside: false,\n callback: ref.current,\n });\n setLoaded(true);\n };\n\n document.head.appendChild(script);\n\n return () => {\n setLoaded(false);\n script.remove();\n };\n }, [clientId]);\n\n return {\n loaded,\n prompt: () => window.google?.accounts?.id?.prompt(),\n cancel: () => window.google?.accounts?.id?.cancel(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAiBrC,SAAS,gBAAgB,EAAE,UAAU,SAAS,GAAU;AAC7D,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,KAAK;AAC1C,QAAM,UAAM,qBAAO,QAAQ;AAC3B,MAAI,UAAU;AAEd,8BAAU,MAAM;AACd,UAAM,WAAW;AACjB,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,KAAK;AACZ,WAAO,QAAQ;AACf,WAAO,QAAQ;AACf,WAAO,MAAM;AACb,WAAO,SAAS,MAAM;AACpB,aAAO,OAAO,SAAS,GAAG,WAAW;AAAA,QACnC,SAAS;AAAA,QACT,SAAS;AAAA,QACT,aAAa;AAAA,QACb,WAAW;AAAA,QACX,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,UAAU,IAAI;AAAA,MAChB,CAAC;AACD,gBAAU,IAAI;AAAA,IAChB;AAEA,aAAS,KAAK,YAAY,MAAM;AAEhC,WAAO,MAAM;AACX,gBAAU,KAAK;AACf,aAAO,OAAO;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,MAAM,OAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,IAClD,QAAQ,MAAM,OAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,EACpD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type { GoogleAccounts, CredentialResponse } from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n clientId: string;\n callback: (response: CredentialResponse) => void | Promise<void>;\n};\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport function prompt({ clientId, callback }: Props) {\n const scriptId = 'google-one-tap';\n const script = document.createElement('script');\n script.id = scriptId;\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select: false,\n client_id: clientId,\n use_fedcm_for_prompt: true,\n cancel_on_tap_outside: false,\n callback,\n });\n window.google?.accounts?.id?.prompt();\n };\n\n document.head.appendChild(script);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,OAAO,EAAE,UAAU,SAAS,GAAU;AACpD,QAAM,WAAW;AACjB,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,SAAO,MAAM;AACb,SAAO,SAAS,MAAM;AACpB,WAAO,OAAO,SAAS,GAAG,WAAW;AAAA,MACnC,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB;AAAA,IACF,CAAC;AACD,WAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,EACtC;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
@@ -12,10 +12,6 @@ type Props = {
12
12
  callback: (response: CredentialResponse) => void | Promise<void>;
13
13
  };
14
14
  /** debug: chrome://settings/content/federatedIdentityApi */
15
- declare function useGoogleOneTap({ clientId, callback }: Props): {
16
- loaded: boolean;
17
- prompt: () => void;
18
- cancel: () => void;
19
- };
15
+ declare function prompt({ clientId, callback }: Props): void;
20
16
 
21
- export { type Props, useGoogleOneTap };
17
+ export { type Props, prompt };
@@ -12,10 +12,6 @@ type Props = {
12
12
  callback: (response: CredentialResponse) => void | Promise<void>;
13
13
  };
14
14
  /** debug: chrome://settings/content/federatedIdentityApi */
15
- declare function useGoogleOneTap({ clientId, callback }: Props): {
16
- loaded: boolean;
17
- prompt: () => void;
18
- cancel: () => void;
19
- };
15
+ declare function prompt({ clientId, callback }: Props): void;
20
16
 
21
- export { type Props, useGoogleOneTap };
17
+ export { type Props, prompt };
@@ -1,41 +1,26 @@
1
1
  // src/google-one-tap/index.ts
2
- import { useEffect, useRef, useState } from "react";
3
- function useGoogleOneTap({ clientId, callback }) {
4
- const [loaded, setLoaded] = useState(false);
5
- const ref = useRef(callback);
6
- ref.current = callback;
7
- useEffect(() => {
8
- const scriptId = "google-one-tap";
9
- const script = document.createElement("script");
10
- script.id = scriptId;
11
- script.async = true;
12
- script.defer = true;
13
- script.src = "https://accounts.google.com/gsi/client";
14
- script.onload = () => {
15
- window.google.accounts.id.initialize({
16
- ux_mode: "popup",
17
- context: "signin",
18
- auto_select: false,
19
- client_id: clientId,
20
- use_fedcm_for_prompt: true,
21
- cancel_on_tap_outside: false,
22
- callback: ref.current
23
- });
24
- setLoaded(true);
25
- };
26
- document.head.appendChild(script);
27
- return () => {
28
- setLoaded(false);
29
- script.remove();
30
- };
31
- }, [clientId]);
32
- return {
33
- loaded,
34
- prompt: () => window.google?.accounts?.id?.prompt(),
35
- cancel: () => window.google?.accounts?.id?.cancel()
2
+ function prompt({ clientId, callback }) {
3
+ const scriptId = "google-one-tap";
4
+ const script = document.createElement("script");
5
+ script.id = scriptId;
6
+ script.async = true;
7
+ script.defer = true;
8
+ script.src = "https://accounts.google.com/gsi/client";
9
+ script.onload = () => {
10
+ window.google.accounts.id.initialize({
11
+ ux_mode: "popup",
12
+ context: "signin",
13
+ auto_select: false,
14
+ client_id: clientId,
15
+ use_fedcm_for_prompt: true,
16
+ cancel_on_tap_outside: false,
17
+ callback
18
+ });
19
+ window.google?.accounts?.id?.prompt();
36
20
  };
21
+ document.head.appendChild(script);
37
22
  }
38
23
  export {
39
- useGoogleOneTap
24
+ prompt
40
25
  };
41
26
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport type { GoogleAccounts, CredentialResponse } from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n clientId: string;\n callback: (response: CredentialResponse) => void | Promise<void>;\n};\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport function useGoogleOneTap({ clientId, callback }: Props) {\n const [loaded, setLoaded] = useState(false);\n const ref = useRef(callback);\n ref.current = callback;\n\n useEffect(() => {\n const scriptId = 'google-one-tap';\n const script = document.createElement('script');\n script.id = scriptId;\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select: false,\n client_id: clientId,\n use_fedcm_for_prompt: true,\n cancel_on_tap_outside: false,\n callback: ref.current,\n });\n setLoaded(true);\n };\n\n document.head.appendChild(script);\n\n return () => {\n setLoaded(false);\n script.remove();\n };\n }, [clientId]);\n\n return {\n loaded,\n prompt: () => window.google?.accounts?.id?.prompt(),\n cancel: () => window.google?.accounts?.id?.cancel(),\n };\n}\n"],"mappings":";AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAiBrC,SAAS,gBAAgB,EAAE,UAAU,SAAS,GAAU;AAC7D,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAC1C,QAAM,MAAM,OAAO,QAAQ;AAC3B,MAAI,UAAU;AAEd,YAAU,MAAM;AACd,UAAM,WAAW;AACjB,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,KAAK;AACZ,WAAO,QAAQ;AACf,WAAO,QAAQ;AACf,WAAO,MAAM;AACb,WAAO,SAAS,MAAM;AACpB,aAAO,OAAO,SAAS,GAAG,WAAW;AAAA,QACnC,SAAS;AAAA,QACT,SAAS;AAAA,QACT,aAAa;AAAA,QACb,WAAW;AAAA,QACX,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,UAAU,IAAI;AAAA,MAChB,CAAC;AACD,gBAAU,IAAI;AAAA,IAChB;AAEA,aAAS,KAAK,YAAY,MAAM;AAEhC,WAAO,MAAM;AACX,gBAAU,KAAK;AACf,aAAO,OAAO;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,MAAM,OAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,IAClD,QAAQ,MAAM,OAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,EACpD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/google-one-tap/index.ts"],"sourcesContent":["import type { GoogleAccounts, CredentialResponse } from './types';\n\ndeclare global {\n interface Window {\n google: {\n accounts: GoogleAccounts;\n };\n }\n}\n\nexport type Props = {\n clientId: string;\n callback: (response: CredentialResponse) => void | Promise<void>;\n};\n\n/** debug: chrome://settings/content/federatedIdentityApi */\nexport function prompt({ clientId, callback }: Props) {\n const scriptId = 'google-one-tap';\n const script = document.createElement('script');\n script.id = scriptId;\n script.async = true;\n script.defer = true;\n script.src = 'https://accounts.google.com/gsi/client';\n script.onload = () => {\n window.google.accounts.id.initialize({\n ux_mode: 'popup',\n context: 'signin',\n auto_select: false,\n client_id: clientId,\n use_fedcm_for_prompt: true,\n cancel_on_tap_outside: false,\n callback,\n });\n window.google?.accounts?.id?.prompt();\n };\n\n document.head.appendChild(script);\n}\n"],"mappings":";AAgBO,SAAS,OAAO,EAAE,UAAU,SAAS,GAAU;AACpD,QAAM,WAAW;AACjB,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,SAAO,MAAM;AACb,SAAO,SAAS,MAAM;AACpB,WAAO,OAAO,SAAS,GAAG,WAAW;AAAA,MACnC,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB;AAAA,IACF,CAAC;AACD,WAAO,QAAQ,UAAU,IAAI,OAAO;AAAA,EACtC;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/http",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {