@tensorpass/aiconnect 0.1.1 → 0.1.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.
|
@@ -16,7 +16,13 @@ function closeLine() {
|
|
|
16
16
|
const language = (globalThis.navigator?.language ?? 'en').slice(0, 2);
|
|
17
17
|
return CLOSE_LINES[language] ?? CLOSE_LINES.en;
|
|
18
18
|
}
|
|
19
|
+
// A return page that loads its script in <head> without `defer` runs it before the body exists, so the line
|
|
20
|
+
// waits for the body.
|
|
19
21
|
function showCloseLine() {
|
|
22
|
+
if (!document.body) {
|
|
23
|
+
document.addEventListener('DOMContentLoaded', showCloseLine, { once: true });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
20
26
|
const line = document.createElement('p');
|
|
21
27
|
line.textContent = closeLine();
|
|
22
28
|
line.style.cssText = 'margin:40px auto;max-width:28em;padding:0 16px;font:16px/1.5 system-ui,sans-serif;'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finishSignIn.js","sourceRoot":"","sources":["../../src/webAccounts/finishSignIn.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,4GAA4G;AAC5G,0GAA0G;AAC1G,sGAAsG;AACtG,4DAA4D;AAE5D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEvG,iGAAiG;AACjG,MAAM,WAAW,GAA2B;IAC1C,EAAE,EAAE,+CAA+C;IACnD,EAAE,EAAE,uDAAuD;IAC3D,EAAE,EAAE,mCAAmC;IACvC,EAAE,EAAE,0CAA0C;IAC9C,EAAE,EAAE,eAAe;CACpB,CAAC;AAIF,SAAS,SAAS;IAChB,MAAM,QAAQ,GAAG,CAAC,UAAU,CAAC,SAAS,EAAE,QAAQ,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtE,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,WAAW,GAAG,SAAS,EAAE,CAAC;IAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,oFAAoF;UACrG,mBAAmB,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,uGAAuG;AACvG,iEAAiE;AACjE,MAAM,UAAU,YAAY;IAC1B,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,IAAI,MAAM,EAAE,CAAC;QACX,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,aAAa,EAAE,CAAC;QAClB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzE,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// The site's return page of a web sign in, the address a site passes as `signInCallback`. It does one\n// thing on load: in the popup, it hands the provider's answer to the page that opened it and closes; in the\n// tab of a sign in the browser kept out of a popup, it sends the tab back to the page the sign in started\n// from, whose client finishes it. A popup the browser does not let close shows one line saying so. It\n// imports nothing else of the SDK, so the page stays small.\n\nimport { answerIn, redirectedSignIn, returnToOpener, windowMark, withAnswer } from './signInWindow.ts';\n\n// The line a popup shows when the browser keeps it open, in the languages of the connect window.\nconst CLOSE_LINES: Record<string, string> = {\n en: 'You are signed in. You can close this window.',\n fr: 'Vous êtes connecté. Vous pouvez fermer cette fenêtre.',\n he: 'התחברתם. אפשר לסגור את החלון הזה.',\n ar: 'تم تسجيل دخولك. يمكنك إغلاق هذه النافذة.',\n zh: '你已登录。可以关闭此窗口。',\n};\n\nexport type SignInReturn = 'window' | 'redirect' | 'none';\n\nfunction closeLine(): string {\n const language = (globalThis.navigator?.language ?? 'en').slice(0, 2);\n return CLOSE_LINES[language] ?? CLOSE_LINES.en;\n}\n\nfunction showCloseLine(): void {\n const line = document.createElement('p');\n line.textContent = closeLine();\n line.style.cssText = 'margin:40px auto;max-width:28em;padding:0 16px;font:16px/1.5 system-ui,sans-serif;'\n + 'text-align:center';\n document.body.replaceChildren(line);\n}\n\n// Runs on the return page's load and answers what the page was: a popup's return, a tab's return, or a\n// visit with no sign in waiting, which leaves the page as it is.\nexport function finishSignIn(): SignInReturn {\n const mark = windowMark();\n const answer = mark ? answerIn(location.href, mark) : null;\n if (answer) {\n returnToOpener(answer);\n if (!window.closed) {\n showCloseLine();\n }\n return 'window';\n }\n const pending = redirectedSignIn();\n const returned = pending ? answerIn(location.href, pending.state) : null;\n if (!pending || !returned) {\n return 'none';\n }\n location.replace(withAnswer(pending.returnTo, returned));\n return 'redirect';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"finishSignIn.js","sourceRoot":"","sources":["../../src/webAccounts/finishSignIn.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,4GAA4G;AAC5G,0GAA0G;AAC1G,sGAAsG;AACtG,4DAA4D;AAE5D,OAAO,EAAE,QAAQ,E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cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,aAAa,EAAE,CAAC;QAClB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzE,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// The site's return page of a web sign in, the address a site passes as `signInCallback`. It does one\n// thing on load: in the popup, it hands the provider's answer to the page that opened it and closes; in the\n// tab of a sign in the browser kept out of a popup, it sends the tab back to the page the sign in started\n// from, whose client finishes it. A popup the browser does not let close shows one line saying so. It\n// imports nothing else of the SDK, so the page stays small.\n\nimport { answerIn, redirectedSignIn, returnToOpener, windowMark, withAnswer } from './signInWindow.ts';\n\n// The line a popup shows when the browser keeps it open, in the languages of the connect window.\nconst CLOSE_LINES: Record<string, string> = {\n en: 'You are signed in. You can close this window.',\n fr: 'Vous êtes connecté. Vous pouvez fermer cette fenêtre.',\n he: 'התחברתם. אפשר לסגור את החלון הזה.',\n ar: 'تم تسجيل دخولك. يمكنك إغلاق هذه النافذة.',\n zh: '你已登录。可以关闭此窗口。',\n};\n\nexport type SignInReturn = 'window' | 'redirect' | 'none';\n\nfunction closeLine(): string {\n const language = (globalThis.navigator?.language ?? 'en').slice(0, 2);\n return CLOSE_LINES[language] ?? CLOSE_LINES.en;\n}\n\n// A return page that loads its script in <head> without `defer` runs it before the body exists, so the line\n// waits for the body.\nfunction showCloseLine(): void {\n if (!document.body) {\n document.addEventListener('DOMContentLoaded', showCloseLine, { once: true });\n return;\n }\n const line = document.createElement('p');\n line.textContent = closeLine();\n line.style.cssText = 'margin:40px auto;max-width:28em;padding:0 16px;font:16px/1.5 system-ui,sans-serif;'\n + 'text-align:center';\n document.body.replaceChildren(line);\n}\n\n// Runs on the return page's load and answers what the page was: a popup's return, a tab's return, or a\n// visit with no sign in waiting, which leaves the page as it is.\nexport function finishSignIn(): SignInReturn {\n const mark = windowMark();\n const answer = mark ? answerIn(location.href, mark) : null;\n if (answer) {\n returnToOpener(answer);\n if (!window.closed) {\n showCloseLine();\n }\n return 'window';\n }\n const pending = redirectedSignIn();\n const returned = pending ? answerIn(location.href, pending.state) : null;\n if (!pending || !returned) {\n return 'none';\n }\n location.replace(withAnswer(pending.returnTo, returned));\n return 'redirect';\n}\n"]}
|