From ec64fcbfd797f5c410a9be665b8a022682479c9f Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Mon, 4 Mar 2024 16:19:17 +0100 Subject: [PATCH] Import Alpine through module instead of script tag (#27496) Signed-off-by: Jon Koops --- .../login/resources/script/cdn.min.js | 5 ----- .../theme/keycloak.v2/login/template.ftl | 12 ++++++++++++ .../theme/keycloak.v2/login/theme.properties | 1 - .../keycloak/common/resources/package.json | 1 + .../keycloak/common/resources/pnpm-lock.yaml | 19 +++++++++++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) delete mode 100644 themes/src/main/resources/theme/keycloak.v2/login/resources/script/cdn.min.js diff --git a/themes/src/main/resources/theme/keycloak.v2/login/resources/script/cdn.min.js b/themes/src/main/resources/theme/keycloak.v2/login/resources/script/cdn.min.js deleted file mode 100644 index af7df64380..0000000000 --- a/themes/src/main/resources/theme/keycloak.v2/login/resources/script/cdn.min.js +++ /dev/null @@ -1,5 +0,0 @@ -(()=>{var tt=!1,rt=!1,V=[],nt=-1;function Vt(e){Sn(e)}function Sn(e){V.includes(e)||V.push(e),An()}function Ee(e){let t=V.indexOf(e);t!==-1&&t>nt&&V.splice(t,1)}function An(){!rt&&!tt&&(tt=!0,queueMicrotask(On))}function On(){tt=!1,rt=!0;for(let e=0;ee.effect(t,{scheduler:r=>{it?Vt(r):r()}}),ot=e.raw}function st(e){k=e}function Wt(e){let t=()=>{};return[n=>{let i=k(n);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(o=>o())}),e._x_effects.add(i),t=()=>{i!==void 0&&(e._x_effects.delete(i),$(i))},i},()=>{t()}]}function q(e,t,r={}){e.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:!0}))}function O(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>O(i,t));return}let r=!1;if(t(e,()=>r=!0),r)return;let n=e.firstElementChild;for(;n;)O(n,t,!1),n=n.nextElementSibling}function v(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}var Gt=!1;function Jt(){Gt&&v("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),Gt=!0,document.body||v("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's ` <#if properties.scripts?has_content> <#list properties.scripts?split(' ') as script> @@ -216,6 +223,11 @@ + diff --git a/themes/src/main/resources/theme/keycloak.v2/login/theme.properties b/themes/src/main/resources/theme/keycloak.v2/login/theme.properties index d2bfb61472..072b527463 100644 --- a/themes/src/main/resources/theme/keycloak.v2/login/theme.properties +++ b/themes/src/main/resources/theme/keycloak.v2/login/theme.properties @@ -3,7 +3,6 @@ import=common/keycloak styles=css/styles.css stylesCommon=node_modules/@patternfly-v5/patternfly/patternfly.min.css node_modules/@patternfly-v5/patternfly/patternfly-addons.css -scripts=script/cdn.min.js kcFormGroupClass=pf-v5-c-form__group kcLabelClass=pf-v5-c-form__label diff --git a/themes/src/main/resources/theme/keycloak/common/resources/package.json b/themes/src/main/resources/theme/keycloak/common/resources/package.json index 506276380d..ed56fc69cb 100644 --- a/themes/src/main/resources/theme/keycloak/common/resources/package.json +++ b/themes/src/main/resources/theme/keycloak/common/resources/package.json @@ -9,6 +9,7 @@ "@patternfly-v5/patternfly": "npm:@patternfly/patternfly@^5.1.0", "@patternfly/patternfly": "^4.224.5", "@patternfly/react-core": "^4.278.1", + "alpinejs": "^3.13.5", "jquery": "^3.7.1", "patternfly": "^3.59.5", "react": "^18.2.0", diff --git a/themes/src/main/resources/theme/keycloak/common/resources/pnpm-lock.yaml b/themes/src/main/resources/theme/keycloak/common/resources/pnpm-lock.yaml index 9b0705b517..cf9f969c50 100644 --- a/themes/src/main/resources/theme/keycloak/common/resources/pnpm-lock.yaml +++ b/themes/src/main/resources/theme/keycloak/common/resources/pnpm-lock.yaml @@ -14,6 +14,9 @@ dependencies: '@patternfly/react-core': specifier: ^4.278.1 version: 4.278.1(react-dom@18.2.0)(react@18.2.0) + alpinejs: + specifier: ^3.13.5 + version: 3.13.5 jquery: specifier: ^3.7.1 version: 3.7.1 @@ -573,12 +576,28 @@ packages: resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} dev: true + /@vue/reactivity@3.1.5: + resolution: {integrity: sha512-1tdfLmNjWG6t/CsPldh+foumYFo3cpyCHgBYQ34ylaMsJ+SNHQ1kApMIa8jN+i593zQuaw3AdWH0nJTARzCFhg==} + dependencies: + '@vue/shared': 3.1.5 + dev: false + + /@vue/shared@3.1.5: + resolution: {integrity: sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA==} + dev: false + /acorn@8.11.2: resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==} engines: {node: '>=0.4.0'} hasBin: true dev: true + /alpinejs@3.13.5: + resolution: {integrity: sha512-1d2XeNGN+Zn7j4mUAKXtAgdc4/rLeadyTMWeJGXF5DzwawPBxwTiBhFFm6w/Ei8eJxUZeyNWWSD9zknfdz1kEw==} + dependencies: + '@vue/reactivity': 3.1.5 + dev: false + /attr-accept@1.1.3: resolution: {integrity: sha512-iT40nudw8zmCweivz6j58g+RT33I4KbaIvRUhjNmDwO2WmsQUxFEZZYZ5w3vXe5x5MX9D7mfvA/XaLOZYFR9EQ==} engines: {node: '>=4'}