@shware/http 1.0.1 → 1.0.2
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.
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/google-one-tap/index.
|
|
20
|
+
// src/google-one-tap/index.ts
|
|
21
21
|
var google_one_tap_exports = {};
|
|
22
22
|
__export(google_one_tap_exports, {
|
|
23
23
|
useGoogleOneTap: () => useGoogleOneTap
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/google-one-tap/index.
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/google-one-tap/index.
|
|
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":[]}
|