keycloakify 11.13.10 → 11.14.0-rc.1

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.
package/bin/511.index.js CHANGED
@@ -616,6 +616,16 @@ function generateFtlFilesCodeFactory(params) {
616
616
  const ftlObjectToJsCodeDeclaringAnObjectPlaceholder = '{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
617
617
  $("head").prepend([
618
618
  `<script>\n${ftlObjectToJsCodeDeclaringAnObjectPlaceholder}\n</script>`,
619
+ ...(() => {
620
+ const wrap = buildContext.implementedThemeTypes[themeType];
621
+ (0,assert/* assert */.h)(wrap.isImplemented);
622
+ if (!wrap.hasEarlyColorSchemeScript) {
623
+ return [];
624
+ }
625
+ return [
626
+ `<script src="\${xKeycloakify.resourcesPath}/${constants/* WELL_KNOWN_DIRECTORY_BASE_NAME.DIST */.Ju.DIST}/keycloak-theme/${themeType}/early-color-scheme.js"></script>`
627
+ ];
628
+ })(),
619
629
  `<base href="\${xKeycloakify.resourcesPath}/${constants/* WELL_KNOWN_DIRECTORY_BASE_NAME.DIST */.Ju.DIST}/" />`
620
630
  ].join("\n"));
621
631
  // Remove part of the document marked as ignored.
@@ -1208,9 +1218,6 @@ async function generateResources(params) {
1208
1218
  if (isNative) {
1209
1219
  break extensions_static_resources;
1210
1220
  }
1211
- if (isSpa) {
1212
- break extensions_static_resources;
1213
- }
1214
1221
  const dirPath = (0,external_path_.join)(buildContext.publicDirPath, constants/* KEYCLOAK_THEME */.PC, themeType);
1215
1222
  if (!external_fs_default().existsSync(dirPath)) {
1216
1223
  break extensions_static_resources;
package/bin/97.index.js CHANGED
@@ -163,7 +163,8 @@ async function getExtensionModuleMetas(params) {
163
163
  }
164
164
  const shouldExcludeLoginUi = await (async () => {
165
165
  for (const entry of installedExtensionModules) {
166
- if (entry.moduleName === LOGIN_UI_MODULE_NAME) {
166
+ if (entry.moduleName === LOGIN_UI_MODULE_NAME ||
167
+ entry.moduleName === "@keycloakify/login-ui-storybook") {
167
168
  continue;
168
169
  }
169
170
  if (await (0,fs_existsAsync/* existsAsync */.o)((0,external_path_.join)(entry.dirPath, constants/* KEYCLOAK_THEME */.PC, "login", "pages", "login"))) {
@@ -379,12 +380,22 @@ async function getExtensionModuleFileSourceCodeReadyToBeCopied(params) {
379
380
  fileRelativePath,
380
381
  commentLines: (() => {
381
382
  const path = fileRelativePath.split(path__WEBPACK_IMPORTED_MODULE_2__.sep).join("/");
383
+ const isEarlyColorSchemeScript = isPublic &&
384
+ _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .THEME_TYPES.find */ .Jh.find(themeType => (0,path__WEBPACK_IMPORTED_MODULE_2__.join)(themeType, _shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .EARLY_COLOR_SCHEME_SCRIPT_BASENAME */ .PH) ===
385
+ fileRelativePath) !== undefined;
386
+ const common = !isEarlyColorSchemeScript
387
+ ? []
388
+ : [
389
+ ``,
390
+ `${_shared_constants__WEBPACK_IMPORTED_MODULE_4__/* .EARLY_COLOR_SCHEME_SCRIPT_BASENAME */ .PH} is a special file that will be imported in the head automatically by Keycloakify.`
391
+ ];
382
392
  return isOwnershipAction
383
393
  ? [
384
394
  `This file has been claimed for ownership from ${extensionModuleName} version ${extensionModuleVersion}.`,
385
395
  `To relinquish ownership and restore this file to its original content, run the following command:`,
386
396
  ``,
387
- `$ npx keycloakify own --path "${path}" ${isPublic ? "--public " : ""}--revert`
397
+ `$ npx keycloakify own --path "${path}" ${isPublic ? "--public " : ""}--revert`,
398
+ ...common
388
399
  ]
389
400
  : [
390
401
  `WARNING: Before modifying this file, run the following command:`,
@@ -392,7 +403,8 @@ async function getExtensionModuleFileSourceCodeReadyToBeCopied(params) {
392
403
  `$ npx keycloakify own --path "${path}"${isPublic ? " --public" : ""}`,
393
404
  ``,
394
405
  `This file is provided by ${extensionModuleName} version ${extensionModuleVersion}.`,
395
- `It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`
406
+ `It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`,
407
+ ...common
396
408
  ];
397
409
  })()
398
410
  });
@@ -5,6 +5,26 @@ export type BuildContextLike = BuildContextLike_replaceImportsInJsCode & BuildCo
5
5
  urlPathname: string | undefined;
6
6
  themeVersion: string;
7
7
  kcContextExclusionsFtlCode: string | undefined;
8
+ implementedThemeTypes: {
9
+ login: {
10
+ isImplemented: true;
11
+ hasEarlyColorSchemeScript: boolean;
12
+ } | {
13
+ isImplemented: false;
14
+ };
15
+ account: {
16
+ isImplemented: false;
17
+ } | {
18
+ isImplemented: true;
19
+ hasEarlyColorSchemeScript: boolean;
20
+ };
21
+ admin: {
22
+ isImplemented: true;
23
+ hasEarlyColorSchemeScript: boolean;
24
+ } | {
25
+ isImplemented: false;
26
+ };
27
+ };
8
28
  };
9
29
  export declare function generateFtlFilesCodeFactory(params: {
10
30
  themeName: string;
package/bin/main.js CHANGED
@@ -353,8 +353,41 @@ function getBuildContext(params) {
353
353
  }
354
354
  (0,assert/* assert */.h)(false);
355
355
  })();
356
+ const relativePathsCwd = (() => {
357
+ switch (bundler) {
358
+ case "vite":
359
+ return projectDirPath;
360
+ case "webpack":
361
+ return (0,external_path_.dirname)(packageJsonFilePath);
362
+ }
363
+ })();
364
+ const publicDirPath = (() => {
365
+ if (process.env.PUBLIC_DIR_PATH !== undefined) {
366
+ return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
367
+ pathIsh: process.env.PUBLIC_DIR_PATH,
368
+ cwd: projectDirPath
369
+ });
370
+ }
371
+ webpack: {
372
+ if (bundler !== "webpack") {
373
+ break webpack;
374
+ }
375
+ (0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
376
+ if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
377
+ return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
378
+ pathIsh: parsedPackageJson.keycloakify.publicDirPath,
379
+ cwd: relativePathsCwd
380
+ });
381
+ }
382
+ return (0,external_path_.join)(projectDirPath, "public");
383
+ }
384
+ (0,assert/* assert */.h)(bundler === "vite");
385
+ (0,assert/* assert */.h)(resolvedViteConfig !== undefined);
386
+ return (0,external_path_.join)(projectDirPath, resolvedViteConfig.publicDir);
387
+ })();
356
388
  const implementedThemeTypes = (() => {
357
389
  const getIsNative = (dirPath) => external_fs_.existsSync((0,external_path_.join)(dirPath, "theme.properties"));
390
+ const getHasEarlyColorSchemeScript = (themeType) => external_fs_.existsSync((0,external_path_.join)(publicDirPath, constants/* KEYCLOAK_THEME */.PC, themeType, constants/* EARLY_COLOR_SCHEME_SCRIPT_BASENAME */.PH));
358
391
  return {
359
392
  login: (() => {
360
393
  const dirPath = (0,external_path_.join)(themeSrcDirPath, "login");
@@ -364,7 +397,10 @@ function getBuildContext(params) {
364
397
  if (getIsNative(dirPath)) {
365
398
  return { isImplemented: false, isImplemented_native: true };
366
399
  }
367
- return { isImplemented: true };
400
+ return {
401
+ isImplemented: true,
402
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("login")
403
+ };
368
404
  })(),
369
405
  email: (() => {
370
406
  const dirPath = (0,external_path_.join)(themeSrcDirPath, "email");
@@ -386,7 +422,8 @@ function getBuildContext(params) {
386
422
  }
387
423
  return {
388
424
  isImplemented: true,
389
- type: buildOptions.accountThemeImplementation
425
+ type: buildOptions.accountThemeImplementation,
426
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("account")
390
427
  };
391
428
  })(),
392
429
  admin: (() => {
@@ -397,7 +434,10 @@ function getBuildContext(params) {
397
434
  if (getIsNative(dirPath)) {
398
435
  return { isImplemented: false, isImplemented_native: true };
399
436
  }
400
- return { isImplemented: true };
437
+ return {
438
+ isImplemented: true,
439
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("admin")
440
+ };
401
441
  })()
402
442
  };
403
443
  })();
@@ -440,14 +480,6 @@ function getBuildContext(params) {
440
480
  }
441
481
  return themeNames;
442
482
  })();
443
- const relativePathsCwd = (() => {
444
- switch (bundler) {
445
- case "vite":
446
- return projectDirPath;
447
- case "webpack":
448
- return (0,external_path_.dirname)(packageJsonFilePath);
449
- }
450
- })();
451
483
  const projectBuildDirPath = (() => {
452
484
  webpack: {
453
485
  if (bundler !== "webpack") {
@@ -494,30 +526,7 @@ function getBuildContext(params) {
494
526
  ? "build_keycloak"
495
527
  : `${resolvedViteConfig.buildDir}_keycloak`);
496
528
  })(),
497
- publicDirPath: (() => {
498
- if (process.env.PUBLIC_DIR_PATH !== undefined) {
499
- return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
500
- pathIsh: process.env.PUBLIC_DIR_PATH,
501
- cwd: projectDirPath
502
- });
503
- }
504
- webpack: {
505
- if (bundler !== "webpack") {
506
- break webpack;
507
- }
508
- (0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
509
- if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
510
- return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
511
- pathIsh: parsedPackageJson.keycloakify.publicDirPath,
512
- cwd: relativePathsCwd
513
- });
514
- }
515
- return (0,external_path_.join)(projectDirPath, "public");
516
- }
517
- (0,assert/* assert */.h)(bundler === "vite");
518
- (0,assert/* assert */.h)(resolvedViteConfig !== undefined);
519
- return (0,external_path_.join)(projectDirPath, resolvedViteConfig.publicDir);
520
- })(),
529
+ publicDirPath,
521
530
  cacheDirPath: (0,external_path_.join)((() => {
522
531
  if (process.env.XDG_CACHE_HOME !== undefined) {
523
532
  return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
@@ -801,6 +810,7 @@ function getBuildContext(params) {
801
810
  /* harmony export */ "Jh": () => (/* binding */ THEME_TYPES),
802
811
  /* harmony export */ "Ju": () => (/* binding */ WELL_KNOWN_DIRECTORY_BASE_NAME),
803
812
  /* harmony export */ "PC": () => (/* binding */ KEYCLOAK_THEME),
813
+ /* harmony export */ "PH": () => (/* binding */ EARLY_COLOR_SCHEME_SCRIPT_BASENAME),
804
814
  /* harmony export */ "Sz": () => (/* binding */ KEYCLOAKIFY_SPA_DEV_SERVER_PORT),
805
815
  /* harmony export */ "TE": () => (/* binding */ VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES),
806
816
  /* harmony export */ "XV": () => (/* binding */ LOGIN_THEME_PAGE_IDS),
@@ -885,6 +895,7 @@ const KEYCLOAKIFY_SPA_DEV_SERVER_PORT = "KEYCLOAKIFY_SPA_DEV_SERVER_PORT";
885
895
  const KEYCLOAKIFY_LOGGING_VERSION = "1.0.3";
886
896
  const KEYCLOAKIFY_LOGGING_JAR_BASENAME = `keycloakify-logging-${KEYCLOAKIFY_LOGGING_VERSION}.jar`;
887
897
  const TEST_APP_URL = "https://my-theme.keycloakify.dev";
898
+ const EARLY_COLOR_SCHEME_SCRIPT_BASENAME = "early-color-scheme.js";
888
899
  //# sourceMappingURL=constants.js.map
889
900
 
890
901
  /***/ }),
@@ -26,6 +26,7 @@ export type BuildContext = {
26
26
  implementedThemeTypes: {
27
27
  login: {
28
28
  isImplemented: true;
29
+ hasEarlyColorSchemeScript: boolean;
29
30
  } | {
30
31
  isImplemented: false;
31
32
  isImplemented_native: boolean;
@@ -40,9 +41,11 @@ export type BuildContext = {
40
41
  } | {
41
42
  isImplemented: true;
42
43
  type: "Single-Page" | "Multi-Page";
44
+ hasEarlyColorSchemeScript: boolean;
43
45
  };
44
46
  admin: {
45
47
  isImplemented: true;
48
+ hasEarlyColorSchemeScript: boolean;
46
49
  } | {
47
50
  isImplemented: false;
48
51
  isImplemented_native: boolean;
@@ -26,3 +26,4 @@ export declare const KEYCLOAKIFY_SPA_DEV_SERVER_PORT = "KEYCLOAKIFY_SPA_DEV_SERV
26
26
  export declare const KEYCLOAKIFY_LOGGING_VERSION = "1.0.3";
27
27
  export declare const KEYCLOAKIFY_LOGGING_JAR_BASENAME: string;
28
28
  export declare const TEST_APP_URL = "https://my-theme.keycloakify.dev";
29
+ export declare const EARLY_COLOR_SCHEME_SCRIPT_BASENAME = "early-color-scheme.js";
@@ -70,4 +70,5 @@ export const KEYCLOAKIFY_SPA_DEV_SERVER_PORT = "KEYCLOAKIFY_SPA_DEV_SERVER_PORT"
70
70
  export const KEYCLOAKIFY_LOGGING_VERSION = "1.0.3";
71
71
  export const KEYCLOAKIFY_LOGGING_JAR_BASENAME = `keycloakify-logging-${KEYCLOAKIFY_LOGGING_VERSION}.jar`;
72
72
  export const TEST_APP_URL = "https://my-theme.keycloakify.dev";
73
+ export const EARLY_COLOR_SCHEME_SCRIPT_BASENAME = "early-color-scheme.js";
73
74
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/bin/shared/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC1C,yBAAyB,EAAE,2BAA2B;IACtD,gBAAgB,EAAE,kBAAkB;IACpC,IAAI,EAAE,MAAM;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAIlE,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC7C,qBAAqB,EAAE,mCAAmC;IAC1D,mBAAmB,EAAE,iCAAiC;IACtD,wBAAwB,EAAE,sCAAsC;CAC1D,CAAC;AAEX,MAAM,CAAC,MAAM,yCAAyC,GAClD,8CAA8C,CAAC;AAEnD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B;IAC3B,uBAAuB;IACvB,cAAc;IACd,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,wBAAwB;IACxB,WAAW;IACX,0CAA0C;IAC1C,uBAAuB;IACvB,eAAe;IACf,0BAA0B;IAC1B,2BAA2B;IAC3B,qBAAqB;IACrB,4BAA4B;IAC5B,0BAA0B;IAC1B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,CAAC;AAEnD,MAAM,CAAC,MAAM,gCAAgC,GAAG,uBAAuB,2BAA2B,MAAM,CAAC;AAEzG,MAAM,CAAC,MAAM,YAAY,GAAG,kCAAkC,CAAC;AAE/D,MAAM,CAAC,MAAM,kCAAkC,GAAG,uBAAuB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "11.13.10",
3
+ "version": "11.14.0-rc.1",
4
4
  "description": "Framework to create custom Keycloak UIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,6 +23,20 @@ export type BuildContextLike = BuildContextLike_replaceImportsInJsCode &
23
23
  urlPathname: string | undefined;
24
24
  themeVersion: string;
25
25
  kcContextExclusionsFtlCode: string | undefined;
26
+ implementedThemeTypes: {
27
+ login:
28
+ | { isImplemented: true; hasEarlyColorSchemeScript: boolean }
29
+ | { isImplemented: false };
30
+ account:
31
+ | { isImplemented: false }
32
+ | {
33
+ isImplemented: true;
34
+ hasEarlyColorSchemeScript: boolean;
35
+ };
36
+ admin:
37
+ | { isImplemented: true; hasEarlyColorSchemeScript: boolean }
38
+ | { isImplemented: false };
39
+ };
26
40
  };
27
41
 
28
42
  assert<BuildContext extends BuildContextLike ? true : false>();
@@ -134,6 +148,19 @@ export function generateFtlFilesCodeFactory(params: {
134
148
  $("head").prepend(
135
149
  [
136
150
  `<script>\n${ftlObjectToJsCodeDeclaringAnObjectPlaceholder}\n</script>`,
151
+ ...(() => {
152
+ const wrap = buildContext.implementedThemeTypes[themeType];
153
+
154
+ assert(wrap.isImplemented);
155
+
156
+ if (!wrap.hasEarlyColorSchemeScript) {
157
+ return [];
158
+ }
159
+
160
+ return [
161
+ `<script src="\${xKeycloakify.resourcesPath}/${WELL_KNOWN_DIRECTORY_BASE_NAME.DIST}/keycloak-theme/${themeType}/early-color-scheme.js"></script>`
162
+ ];
163
+ })(),
137
164
  `<base href="\${xKeycloakify.resourcesPath}/${WELL_KNOWN_DIRECTORY_BASE_NAME.DIST}/" />`
138
165
  ].join("\n")
139
166
  );
@@ -604,10 +604,6 @@ export async function generateResources(params: {
604
604
  break extensions_static_resources;
605
605
  }
606
606
 
607
- if (isSpa) {
608
- break extensions_static_resources;
609
- }
610
-
611
607
  const dirPath = pathJoin(
612
608
  buildContext.publicDirPath,
613
609
  KEYCLOAK_THEME,
@@ -12,7 +12,8 @@ import { assert, type Equals, is } from "tsafe/assert";
12
12
  import * as child_process from "child_process";
13
13
  import {
14
14
  VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES,
15
- BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME
15
+ BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME,
16
+ EARLY_COLOR_SCHEME_SCRIPT_BASENAME
16
17
  } from "./constants";
17
18
  import type { KeycloakVersionRange } from "./KeycloakVersionRange";
18
19
  import { exclude } from "tsafe";
@@ -45,14 +46,18 @@ export type BuildContext = {
45
46
  themeSrcDirPath: string;
46
47
  implementedThemeTypes: {
47
48
  login:
48
- | { isImplemented: true }
49
+ | { isImplemented: true; hasEarlyColorSchemeScript: boolean }
49
50
  | { isImplemented: false; isImplemented_native: boolean };
50
51
  email: { isImplemented: false; isImplemented_native: boolean };
51
52
  account:
52
53
  | { isImplemented: false; isImplemented_native: boolean }
53
- | { isImplemented: true; type: "Single-Page" | "Multi-Page" };
54
+ | {
55
+ isImplemented: true;
56
+ type: "Single-Page" | "Multi-Page";
57
+ hasEarlyColorSchemeScript: boolean;
58
+ };
54
59
  admin:
55
- | { isImplemented: true }
60
+ | { isImplemented: true; hasEarlyColorSchemeScript: boolean }
56
61
  | { isImplemented: false; isImplemented_native: boolean };
57
62
  };
58
63
  packageJsonFilePath: string;
@@ -428,10 +433,60 @@ export function getBuildContext(params: {
428
433
  assert<Equals<typeof bundler, never>>(false);
429
434
  })();
430
435
 
436
+ const relativePathsCwd = (() => {
437
+ switch (bundler) {
438
+ case "vite":
439
+ return projectDirPath;
440
+ case "webpack":
441
+ return pathDirname(packageJsonFilePath);
442
+ }
443
+ })();
444
+
445
+ const publicDirPath = (() => {
446
+ if (process.env.PUBLIC_DIR_PATH !== undefined) {
447
+ return getAbsoluteAndInOsFormatPath({
448
+ pathIsh: process.env.PUBLIC_DIR_PATH,
449
+ cwd: projectDirPath
450
+ });
451
+ }
452
+
453
+ webpack: {
454
+ if (bundler !== "webpack") {
455
+ break webpack;
456
+ }
457
+
458
+ assert(parsedPackageJson.keycloakify !== undefined);
459
+
460
+ if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
461
+ return getAbsoluteAndInOsFormatPath({
462
+ pathIsh: parsedPackageJson.keycloakify.publicDirPath,
463
+ cwd: relativePathsCwd
464
+ });
465
+ }
466
+
467
+ return pathJoin(projectDirPath, "public");
468
+ }
469
+
470
+ assert(bundler === "vite");
471
+ assert(resolvedViteConfig !== undefined);
472
+
473
+ return pathJoin(projectDirPath, resolvedViteConfig.publicDir);
474
+ })();
475
+
431
476
  const implementedThemeTypes: BuildContext["implementedThemeTypes"] = (() => {
432
477
  const getIsNative = (dirPath: string) =>
433
478
  fs.existsSync(pathJoin(dirPath, "theme.properties"));
434
479
 
480
+ const getHasEarlyColorSchemeScript = (themeType: ThemeType) =>
481
+ fs.existsSync(
482
+ pathJoin(
483
+ publicDirPath,
484
+ KEYCLOAK_THEME,
485
+ themeType,
486
+ EARLY_COLOR_SCHEME_SCRIPT_BASENAME
487
+ )
488
+ );
489
+
435
490
  return {
436
491
  login: (() => {
437
492
  const dirPath = pathJoin(themeSrcDirPath, "login");
@@ -444,7 +499,10 @@ export function getBuildContext(params: {
444
499
  return { isImplemented: false, isImplemented_native: true };
445
500
  }
446
501
 
447
- return { isImplemented: true };
502
+ return {
503
+ isImplemented: true,
504
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("login")
505
+ };
448
506
  })(),
449
507
  email: (() => {
450
508
  const dirPath = pathJoin(themeSrcDirPath, "email");
@@ -472,7 +530,8 @@ export function getBuildContext(params: {
472
530
 
473
531
  return {
474
532
  isImplemented: true,
475
- type: buildOptions.accountThemeImplementation
533
+ type: buildOptions.accountThemeImplementation,
534
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("account")
476
535
  };
477
536
  })(),
478
537
  admin: (() => {
@@ -486,7 +545,10 @@ export function getBuildContext(params: {
486
545
  return { isImplemented: false, isImplemented_native: true };
487
546
  }
488
547
 
489
- return { isImplemented: true };
548
+ return {
549
+ isImplemented: true,
550
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("admin")
551
+ };
490
552
  })()
491
553
  };
492
554
  })();
@@ -548,15 +610,6 @@ export function getBuildContext(params: {
548
610
  return themeNames;
549
611
  })();
550
612
 
551
- const relativePathsCwd = (() => {
552
- switch (bundler) {
553
- case "vite":
554
- return projectDirPath;
555
- case "webpack":
556
- return pathDirname(packageJsonFilePath);
557
- }
558
- })();
559
-
560
613
  const projectBuildDirPath = (() => {
561
614
  webpack: {
562
615
  if (bundler !== "webpack") {
@@ -623,36 +676,7 @@ export function getBuildContext(params: {
623
676
  : `${resolvedViteConfig.buildDir}_keycloak`
624
677
  );
625
678
  })(),
626
- publicDirPath: (() => {
627
- if (process.env.PUBLIC_DIR_PATH !== undefined) {
628
- return getAbsoluteAndInOsFormatPath({
629
- pathIsh: process.env.PUBLIC_DIR_PATH,
630
- cwd: projectDirPath
631
- });
632
- }
633
-
634
- webpack: {
635
- if (bundler !== "webpack") {
636
- break webpack;
637
- }
638
-
639
- assert(parsedPackageJson.keycloakify !== undefined);
640
-
641
- if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
642
- return getAbsoluteAndInOsFormatPath({
643
- pathIsh: parsedPackageJson.keycloakify.publicDirPath,
644
- cwd: relativePathsCwd
645
- });
646
- }
647
-
648
- return pathJoin(projectDirPath, "public");
649
- }
650
-
651
- assert(bundler === "vite");
652
- assert(resolvedViteConfig !== undefined);
653
-
654
- return pathJoin(projectDirPath, resolvedViteConfig.publicDir);
655
- })(),
679
+ publicDirPath,
656
680
  cacheDirPath: pathJoin(
657
681
  (() => {
658
682
  if (process.env.XDG_CACHE_HOME !== undefined) {
@@ -89,3 +89,5 @@ export const KEYCLOAKIFY_LOGGING_VERSION = "1.0.3";
89
89
  export const KEYCLOAKIFY_LOGGING_JAR_BASENAME = `keycloakify-logging-${KEYCLOAKIFY_LOGGING_VERSION}.jar`;
90
90
 
91
91
  export const TEST_APP_URL = "https://my-theme.keycloakify.dev";
92
+
93
+ export const EARLY_COLOR_SCHEME_SCRIPT_BASENAME = "early-color-scheme.js";
@@ -144,7 +144,10 @@ export async function getExtensionModuleMetas(params: {
144
144
 
145
145
  const shouldExcludeLoginUi = await (async () => {
146
146
  for (const entry of installedExtensionModules) {
147
- if (entry.moduleName === LOGIN_UI_MODULE_NAME) {
147
+ if (
148
+ entry.moduleName === LOGIN_UI_MODULE_NAME ||
149
+ entry.moduleName === "@keycloakify/login-ui-storybook"
150
+ ) {
148
151
  continue;
149
152
  }
150
153
 
@@ -3,7 +3,11 @@ import * as fsPr from "fs/promises";
3
3
  import { join as pathJoin, sep as pathSep } from "path";
4
4
  import { assert } from "tsafe/assert";
5
5
  import type { BuildContext } from "../shared/buildContext";
6
- import { KEYCLOAK_THEME } from "../shared/constants";
6
+ import {
7
+ KEYCLOAK_THEME,
8
+ THEME_TYPES,
9
+ EARLY_COLOR_SCHEME_SCRIPT_BASENAME
10
+ } from "../shared/constants";
7
11
 
8
12
  export type BuildContextLike = {
9
13
  themeSrcDirPath: string;
@@ -93,12 +97,28 @@ export async function getExtensionModuleFileSourceCodeReadyToBeCopied(params: {
93
97
  commentLines: (() => {
94
98
  const path = fileRelativePath.split(pathSep).join("/");
95
99
 
100
+ const isEarlyColorSchemeScript =
101
+ isPublic &&
102
+ THEME_TYPES.find(
103
+ themeType =>
104
+ pathJoin(themeType, EARLY_COLOR_SCHEME_SCRIPT_BASENAME) ===
105
+ fileRelativePath
106
+ ) !== undefined;
107
+
108
+ const common = !isEarlyColorSchemeScript
109
+ ? []
110
+ : [
111
+ ``,
112
+ `${EARLY_COLOR_SCHEME_SCRIPT_BASENAME} is a special file that will be imported in the head automatically by Keycloakify.`
113
+ ];
114
+
96
115
  return isOwnershipAction
97
116
  ? [
98
117
  `This file has been claimed for ownership from ${extensionModuleName} version ${extensionModuleVersion}.`,
99
118
  `To relinquish ownership and restore this file to its original content, run the following command:`,
100
119
  ``,
101
- `$ npx keycloakify own --path "${path}" ${isPublic ? "--public " : ""}--revert`
120
+ `$ npx keycloakify own --path "${path}" ${isPublic ? "--public " : ""}--revert`,
121
+ ...common
102
122
  ]
103
123
  : [
104
124
  `WARNING: Before modifying this file, run the following command:`,
@@ -106,7 +126,8 @@ export async function getExtensionModuleFileSourceCodeReadyToBeCopied(params: {
106
126
  `$ npx keycloakify own --path "${path}"${isPublic ? " --public" : ""}`,
107
127
  ``,
108
128
  `This file is provided by ${extensionModuleName} version ${extensionModuleVersion}.`,
109
- `It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`
129
+ `It was copied into your repository by the postinstall script: \`keycloakify sync-extensions\`.`,
130
+ ...common
110
131
  ];
111
132
  })()
112
133
  });
@@ -567,8 +567,41 @@ function getBuildContext(params) {
567
567
  }
568
568
  (0,assert/* assert */.h)(false);
569
569
  })();
570
+ const relativePathsCwd = (() => {
571
+ switch (bundler) {
572
+ case "vite":
573
+ return projectDirPath;
574
+ case "webpack":
575
+ return (0,external_path_.dirname)(packageJsonFilePath);
576
+ }
577
+ })();
578
+ const publicDirPath = (() => {
579
+ if (process.env.PUBLIC_DIR_PATH !== undefined) {
580
+ return getAbsoluteAndInOsFormatPath({
581
+ pathIsh: process.env.PUBLIC_DIR_PATH,
582
+ cwd: projectDirPath
583
+ });
584
+ }
585
+ webpack: {
586
+ if (bundler !== "webpack") {
587
+ break webpack;
588
+ }
589
+ (0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
590
+ if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
591
+ return getAbsoluteAndInOsFormatPath({
592
+ pathIsh: parsedPackageJson.keycloakify.publicDirPath,
593
+ cwd: relativePathsCwd
594
+ });
595
+ }
596
+ return (0,external_path_.join)(projectDirPath, "public");
597
+ }
598
+ (0,assert/* assert */.h)(bundler === "vite");
599
+ (0,assert/* assert */.h)(resolvedViteConfig !== undefined);
600
+ return (0,external_path_.join)(projectDirPath, resolvedViteConfig.publicDir);
601
+ })();
570
602
  const implementedThemeTypes = (() => {
571
603
  const getIsNative = (dirPath) => external_fs_.existsSync((0,external_path_.join)(dirPath, "theme.properties"));
604
+ const getHasEarlyColorSchemeScript = (themeType) => external_fs_.existsSync((0,external_path_.join)(publicDirPath, constants.KEYCLOAK_THEME, themeType, constants.EARLY_COLOR_SCHEME_SCRIPT_BASENAME));
572
605
  return {
573
606
  login: (() => {
574
607
  const dirPath = (0,external_path_.join)(themeSrcDirPath, "login");
@@ -578,7 +611,10 @@ function getBuildContext(params) {
578
611
  if (getIsNative(dirPath)) {
579
612
  return { isImplemented: false, isImplemented_native: true };
580
613
  }
581
- return { isImplemented: true };
614
+ return {
615
+ isImplemented: true,
616
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("login")
617
+ };
582
618
  })(),
583
619
  email: (() => {
584
620
  const dirPath = (0,external_path_.join)(themeSrcDirPath, "email");
@@ -600,7 +636,8 @@ function getBuildContext(params) {
600
636
  }
601
637
  return {
602
638
  isImplemented: true,
603
- type: buildOptions.accountThemeImplementation
639
+ type: buildOptions.accountThemeImplementation,
640
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("account")
604
641
  };
605
642
  })(),
606
643
  admin: (() => {
@@ -611,7 +648,10 @@ function getBuildContext(params) {
611
648
  if (getIsNative(dirPath)) {
612
649
  return { isImplemented: false, isImplemented_native: true };
613
650
  }
614
- return { isImplemented: true };
651
+ return {
652
+ isImplemented: true,
653
+ hasEarlyColorSchemeScript: getHasEarlyColorSchemeScript("admin")
654
+ };
615
655
  })()
616
656
  };
617
657
  })();
@@ -654,14 +694,6 @@ function getBuildContext(params) {
654
694
  }
655
695
  return themeNames;
656
696
  })();
657
- const relativePathsCwd = (() => {
658
- switch (bundler) {
659
- case "vite":
660
- return projectDirPath;
661
- case "webpack":
662
- return (0,external_path_.dirname)(packageJsonFilePath);
663
- }
664
- })();
665
697
  const projectBuildDirPath = (() => {
666
698
  webpack: {
667
699
  if (bundler !== "webpack") {
@@ -708,30 +740,7 @@ function getBuildContext(params) {
708
740
  ? "build_keycloak"
709
741
  : `${resolvedViteConfig.buildDir}_keycloak`);
710
742
  })(),
711
- publicDirPath: (() => {
712
- if (process.env.PUBLIC_DIR_PATH !== undefined) {
713
- return getAbsoluteAndInOsFormatPath({
714
- pathIsh: process.env.PUBLIC_DIR_PATH,
715
- cwd: projectDirPath
716
- });
717
- }
718
- webpack: {
719
- if (bundler !== "webpack") {
720
- break webpack;
721
- }
722
- (0,assert/* assert */.h)(parsedPackageJson.keycloakify !== undefined);
723
- if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
724
- return getAbsoluteAndInOsFormatPath({
725
- pathIsh: parsedPackageJson.keycloakify.publicDirPath,
726
- cwd: relativePathsCwd
727
- });
728
- }
729
- return (0,external_path_.join)(projectDirPath, "public");
730
- }
731
- (0,assert/* assert */.h)(bundler === "vite");
732
- (0,assert/* assert */.h)(resolvedViteConfig !== undefined);
733
- return (0,external_path_.join)(projectDirPath, resolvedViteConfig.publicDir);
734
- })(),
743
+ publicDirPath,
735
744
  cacheDirPath: (0,external_path_.join)((() => {
736
745
  if (process.env.XDG_CACHE_HOME !== undefined) {
737
746
  return getAbsoluteAndInOsFormatPath({
@@ -1017,6 +1026,7 @@ __nccwpck_require__.r(__webpack_exports__);
1017
1026
  /* harmony export */ "BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME": () => (/* binding */ BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME),
1018
1027
  /* harmony export */ "CONTAINER_NAME": () => (/* binding */ CONTAINER_NAME),
1019
1028
  /* harmony export */ "CUSTOM_HANDLER_ENV_NAMES": () => (/* binding */ CUSTOM_HANDLER_ENV_NAMES),
1029
+ /* harmony export */ "EARLY_COLOR_SCHEME_SCRIPT_BASENAME": () => (/* binding */ EARLY_COLOR_SCHEME_SCRIPT_BASENAME),
1020
1030
  /* harmony export */ "FALLBACK_LANGUAGE_TAG": () => (/* binding */ FALLBACK_LANGUAGE_TAG),
1021
1031
  /* harmony export */ "KEYCLOAKIFY_LOGGING_JAR_BASENAME": () => (/* binding */ KEYCLOAKIFY_LOGGING_JAR_BASENAME),
1022
1032
  /* harmony export */ "KEYCLOAKIFY_LOGGING_VERSION": () => (/* binding */ KEYCLOAKIFY_LOGGING_VERSION),
@@ -1100,6 +1110,7 @@ const KEYCLOAKIFY_SPA_DEV_SERVER_PORT = "KEYCLOAKIFY_SPA_DEV_SERVER_PORT";
1100
1110
  const KEYCLOAKIFY_LOGGING_VERSION = "1.0.3";
1101
1111
  const KEYCLOAKIFY_LOGGING_JAR_BASENAME = `keycloakify-logging-${KEYCLOAKIFY_LOGGING_VERSION}.jar`;
1102
1112
  const TEST_APP_URL = "https://my-theme.keycloakify.dev";
1113
+ const EARLY_COLOR_SCHEME_SCRIPT_BASENAME = "early-color-scheme.js";
1103
1114
  //# sourceMappingURL=constants.js.map
1104
1115
 
1105
1116
  /***/ }),