From 020a1692117c67baeb5ebe8c6ace8152da34e4ed Mon Sep 17 00:00:00 2001 From: Luca Peruzzo Date: Thu, 16 May 2024 14:23:10 +0200 Subject: [PATCH 1/2] update pull request to 6.0.0 --- package-lock.json | 12 ------------ package.json | 5 +---- src/web.ts | 15 +++++++++++++-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index a77171d..78d064d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,10 +8,6 @@ "name": "@capacitor-community/apple-sign-in", "version": "6.0.0", "license": "MIT", - "dependencies": { - "@types/scriptjs": "0.0.2", - "scriptjs": "^2.5.9" - }, "devDependencies": { "@capacitor/android": "^6.0.0", "@capacitor/cli": "^6.0.0", @@ -634,10 +630,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/scriptjs": { - "version": "0.0.2", - "license": "MIT" - }, "node_modules/@types/slice-ansi": { "version": "4.0.0", "dev": true, @@ -4939,10 +4931,6 @@ "node": ">=v12.22.7" } }, - "node_modules/scriptjs": { - "version": "2.5.9", - "license": "MIT" - }, "node_modules/semver": { "version": "7.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", diff --git a/package.json b/package.json index 2ebb5d7..ff6a0fa 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,7 @@ "prettier": "@ionic/prettier-config", "swiftlint": "@ionic/swiftlint-config", "license": "MIT", - "dependencies": { - "@types/scriptjs": "0.0.2", - "scriptjs": "^2.5.9" - }, + "dependencies": {}, "devDependencies": { "@capacitor/android": "^6.0.0", "@capacitor/cli": "^6.0.0", diff --git a/src/web.ts b/src/web.ts index 5e19477..a3c1b82 100755 --- a/src/web.ts +++ b/src/web.ts @@ -1,5 +1,4 @@ import { WebPlugin } from '@capacitor/core'; -import * as $script from 'scriptjs'; import type { SignInWithAppleOptions, @@ -75,7 +74,19 @@ export class SignInWithAppleWeb return new Promise(resolve => { if (!this.isAppleScriptLoaded) { if (typeof window !== undefined) { - $script.get(this.appleScriptUrl, () => resolve(true)); + if (!document.getElementById('capacitor-community__apple-sign-in__script')) { + const script = document.createElement('script'); + script.id = 'capacitor-community__apple-sign-in__script'; + script.async = true; + script.src = this.appleScriptUrl; + script.onload = script.onerror = () => { + script.onload = null; + resolve(true); + }; + document.head.insertBefore(script, document.head.lastChild); + } else { + resolve(true); + } } else { resolve(false); } From e4ac4d8c23af8ebaa2af0f47921c5f77cd63a306 Mon Sep 17 00:00:00 2001 From: Luca Peruzzo Date: Thu, 16 May 2024 14:33:18 +0200 Subject: [PATCH 2/2] lint --- src/web.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/web.ts b/src/web.ts index a3c1b82..4c5ac39 100755 --- a/src/web.ts +++ b/src/web.ts @@ -74,14 +74,18 @@ export class SignInWithAppleWeb return new Promise(resolve => { if (!this.isAppleScriptLoaded) { if (typeof window !== undefined) { - if (!document.getElementById('capacitor-community__apple-sign-in__script')) { + if ( + !document.getElementById( + 'capacitor-community__apple-sign-in__script', + ) + ) { const script = document.createElement('script'); script.id = 'capacitor-community__apple-sign-in__script'; script.async = true; script.src = this.appleScriptUrl; script.onload = script.onerror = () => { - script.onload = null; - resolve(true); + script.onload = null; + resolve(true); }; document.head.insertBefore(script, document.head.lastChild); } else {