keycloakify 11.4.0-rc.0 → 11.4.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.
Files changed (94) hide show
  1. package/README.md +2 -0
  2. package/account/i18n/noJsx/getI18n.js +5 -7
  3. package/account/i18n/noJsx/getI18n.js.map +1 -1
  4. package/account/i18n/withJsx/useI18n.js +15 -4
  5. package/account/i18n/withJsx/useI18n.js.map +1 -1
  6. package/bin/20.index.js +0 -85
  7. package/bin/33.index.js +55 -212
  8. package/bin/356.index.js +106 -45
  9. package/bin/36.index.js +1 -2922
  10. package/bin/{526.index.js → 392.index.js} +107 -3
  11. package/bin/40.index.js +1 -86
  12. package/bin/453.index.js +85 -22
  13. package/bin/573.index.js +5 -86
  14. package/bin/653.index.js +752 -0
  15. package/bin/658.index.js +197 -0
  16. package/bin/735.index.js +343 -116
  17. package/bin/786.index.js +78 -14
  18. package/bin/805.index.js +15 -18
  19. package/bin/921.index.js +79 -18
  20. package/bin/97.index.js +64 -13
  21. package/bin/main.js +165 -86
  22. package/bin/shared/constants.d.ts +2 -0
  23. package/bin/shared/constants.js +3 -1
  24. package/bin/shared/constants.js.map +1 -1
  25. package/bin/start-keycloak/startViteDevServer.d.ts +8 -0
  26. package/bin/tools/crawlAsync.d.ts +1 -1
  27. package/bin/tools/isTrackedByGit.d.ts +3 -0
  28. package/bin/tools/runPrettier.d.ts +5 -5
  29. package/bin/tools/untrackFromGit.d.ts +3 -0
  30. package/lib/getKcClsx.js +1 -2
  31. package/lib/getKcClsx.js.map +1 -1
  32. package/login/KcContext/KcContext.d.ts +2 -2
  33. package/login/KcContext/kcContextMocks.d.ts +1 -1
  34. package/login/TemplateProps.d.ts +0 -1
  35. package/login/i18n/noJsx/getI18n.js +5 -7
  36. package/login/i18n/noJsx/getI18n.js.map +1 -1
  37. package/login/i18n/withJsx/useI18n.js +15 -4
  38. package/login/i18n/withJsx/useI18n.js.map +1 -1
  39. package/login/pages/LoginConfigTotp.js +1 -1
  40. package/login/pages/LoginConfigTotp.js.map +1 -1
  41. package/login/pages/LoginPasskeysConditionalAuthenticate.js +16 -18
  42. package/login/pages/LoginPasskeysConditionalAuthenticate.js.map +1 -1
  43. package/package.json +17 -7
  44. package/src/account/i18n/noJsx/getI18n.tsx +5 -7
  45. package/src/account/i18n/withJsx/useI18n.tsx +18 -4
  46. package/src/bin/eject-page.ts +28 -10
  47. package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +3 -18
  48. package/src/bin/initialize-account-theme/updateAccountThemeImplementationInConfig.ts +1 -2
  49. package/src/bin/keycloakify/generateFtl/generateFtl.ts +6 -1
  50. package/src/bin/keycloakify/generateFtl/kcContextDeclarationTemplate.ftl +39 -0
  51. package/src/bin/keycloakify/generateResources/generateResources.ts +6 -2
  52. package/src/bin/main.ts +51 -4
  53. package/src/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.ts +30 -19
  54. package/src/bin/postinstall/installUiModulesPeerDependencies.ts +3 -3
  55. package/src/bin/postinstall/managedGitignoreFile.ts +4 -3
  56. package/src/bin/postinstall/postinstall.ts +24 -2
  57. package/src/bin/postinstall/uiModuleMeta.ts +14 -9
  58. package/src/bin/shared/buildContext.ts +1 -2
  59. package/src/bin/shared/constants.ts +4 -1
  60. package/src/bin/start-keycloak/myrealm-realm-25.json +21 -34
  61. package/src/bin/start-keycloak/myrealm-realm-26.json +32 -35
  62. package/src/bin/start-keycloak/start-keycloak.ts +94 -1
  63. package/src/bin/start-keycloak/startViteDevServer.ts +66 -0
  64. package/src/bin/tools/crawlAsync.ts +6 -6
  65. package/src/bin/tools/isTrackedByGit.ts +29 -0
  66. package/src/bin/tools/listInstalledModules.ts +1 -2
  67. package/src/bin/tools/npmInstall.ts +396 -1
  68. package/src/bin/tools/runPrettier.ts +63 -14
  69. package/src/bin/tools/untrackFromGit.ts +24 -0
  70. package/src/bin/tsconfig.json +1 -1
  71. package/src/bin/update-kc-gen.ts +17 -2
  72. package/src/lib/getKcClsx.ts +1 -2
  73. package/src/login/KcContext/KcContext.ts +2 -2
  74. package/src/login/KcContext/kcContextMocks.ts +1 -1
  75. package/src/login/TemplateProps.ts +0 -1
  76. package/src/login/i18n/noJsx/getI18n.tsx +5 -7
  77. package/src/login/i18n/withJsx/useI18n.tsx +18 -4
  78. package/src/login/pages/LoginConfigTotp.tsx +18 -20
  79. package/src/login/pages/LoginPasskeysConditionalAuthenticate.tsx +51 -52
  80. package/src/tools/StatefulObservable/StatefulObservable.ts +1 -2
  81. package/src/tools/deepAssign.ts +1 -2
  82. package/src/tools/extractLastParenthesisContent.ts +43 -0
  83. package/src/vite-plugin/vite-plugin.ts +67 -0
  84. package/stories/login/pages/Info.stories.tsx +3 -39
  85. package/tools/StatefulObservable/StatefulObservable.js +1 -2
  86. package/tools/StatefulObservable/StatefulObservable.js.map +1 -1
  87. package/tools/deepAssign.js +1 -2
  88. package/tools/deepAssign.js.map +1 -1
  89. package/tools/extractLastParenthesisContent.d.ts +6 -0
  90. package/tools/extractLastParenthesisContent.js +36 -0
  91. package/tools/extractLastParenthesisContent.js.map +1 -0
  92. package/vite-plugin/index.js +326 -186
  93. package/bin/124.index.js +0 -348
  94. package/stories/login/pages/LoginDeviceVerifyUserCode.stories.tsx +0 -18
package/bin/786.index.js CHANGED
@@ -142,8 +142,8 @@ function getNodeModulesBinDirPath() {
142
142
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
143
143
 
144
144
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
145
+ /* harmony export */ "LG": () => (/* binding */ getPrettier),
145
146
  /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
146
- /* harmony export */ "cI": () => (/* binding */ getPrettierAndConfig),
147
147
  /* harmony export */ "eY": () => (/* binding */ runPrettier)
148
148
  /* harmony export */ });
149
149
  /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
@@ -151,17 +151,24 @@ function getNodeModulesBinDirPath() {
151
151
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
152
152
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
153
153
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
154
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(38469);
154
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
155
155
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
156
156
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
157
157
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
158
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
159
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
160
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
161
+ /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
158
162
 
159
163
 
160
164
 
161
165
 
162
166
 
163
167
 
164
- getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
168
+
169
+
170
+
171
+ getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
165
172
  async function getIsPrettierAvailable() {
166
173
  var _a;
167
174
  if (getIsPrettierAvailable.cache !== undefined) {
@@ -174,26 +181,53 @@ async function getIsPrettierAvailable() {
174
181
  getIsPrettierAvailable.cache = isPrettierAvailable;
175
182
  return isPrettierAvailable;
176
183
  }
177
- getPrettierAndConfig.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
178
- async function getPrettierAndConfig() {
184
+ getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
185
+ async function getPrettier() {
179
186
  (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
180
- if (getPrettierAndConfig.cache !== undefined) {
181
- return getPrettierAndConfig.cache;
187
+ if (getPrettier.cache !== undefined) {
188
+ return getPrettier.cache;
182
189
  }
183
- const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
190
+ let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
191
+ import_prettier: {
192
+ // NOTE: When module is linked we want to make sure we import the correct version
193
+ // of prettier, that is the one of the project, not the one of this repo.
194
+ // So we do a sketchy eval to bypass ncc.
195
+ // We make sure to only do that when linking, otherwise we import properly.
196
+ if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
197
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${(0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), "..", "prettier"))}")`);
198
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
199
+ break import_prettier;
200
+ }
201
+ prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
202
+ }
203
+ const configHash = await (async () => {
204
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."));
205
+ if (configFilePath === null) {
206
+ return "";
207
+ }
208
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
209
+ return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
210
+ })();
184
211
  const prettierAndConfig = {
185
212
  prettier,
186
- config: await prettier.resolveConfig((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."))
213
+ configHash
187
214
  };
188
- getPrettierAndConfig.cache = prettierAndConfig;
215
+ getPrettier.cache = prettierAndConfig;
189
216
  return prettierAndConfig;
190
217
  }
191
218
  async function runPrettier(params) {
192
219
  const { sourceCode, filePath } = params;
193
220
  let formattedSourceCode;
194
221
  try {
195
- const { prettier, config } = await getPrettierAndConfig();
196
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath }));
222
+ const { prettier } = await getPrettier();
223
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
224
+ resolveConfig: true
225
+ });
226
+ if (ignored) {
227
+ return sourceCode;
228
+ }
229
+ const config = await prettier.resolveConfig(filePath);
230
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
197
231
  }
198
232
  catch (error) {
199
233
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
@@ -229,6 +263,13 @@ __webpack_require__.r(__webpack_exports__);
229
263
 
230
264
  async function command(params) {
231
265
  const { buildContext } = params;
266
+ run_copy_assets_to_public: {
267
+ if (buildContext.bundler !== "webpack") {
268
+ break run_copy_assets_to_public;
269
+ }
270
+ const { command } = await __webpack_require__.e(/* import() */ 658).then(__webpack_require__.bind(__webpack_require__, 18040));
271
+ await command({ buildContext });
272
+ }
232
273
  const { hasBeenHandled } = (0,_shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_3__/* .maybeDelegateCommandToCustomHandler */ .q)({
233
274
  commandName: "update-kc-gen",
234
275
  buildContext
@@ -236,7 +277,7 @@ async function command(params) {
236
277
  if (hasBeenHandled) {
237
278
  return;
238
279
  }
239
- const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, "kc-gen.tsx");
280
+ const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, "kc.gen.tsx");
240
281
  const hasLoginTheme = buildContext.implementedThemeTypes.login.isImplemented;
241
282
  const hasAccountTheme = buildContext.implementedThemeTypes.account.isImplemented;
242
283
  const hasAdminTheme = buildContext.implementedThemeTypes.admin.isImplemented;
@@ -260,7 +301,12 @@ async function command(params) {
260
301
  ``,
261
302
  `export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(Object.fromEntries(buildContext.environmentVariables.map(({ name, default: defaultValue }) => [name, defaultValue])), null, 2)};`,
262
303
  ``,
263
- `type KcContext =`,
304
+ `/**`,
305
+ ` * NOTE: Do not import this type except maybe in your entrypoint. `,
306
+ ` * If you need to import the KcContext import it either from src/login/KcContext.ts or src/account/KcContext.ts.`,
307
+ ` * Depending on the theme type you are working on.`,
308
+ ` */`,
309
+ `export type KcContext =`,
264
310
  hasLoginTheme && ` | import("./login/KcContext").KcContext`,
265
311
  hasAccountTheme && ` | import("./account/KcContext").KcContext`,
266
312
  hasAdminTheme && ` | import("./admin/KcContext").KcContext`,
@@ -342,6 +388,24 @@ async function command(params) {
342
388
  }
343
389
  //# sourceMappingURL=update-kc-gen.js.map
344
390
 
391
+ /***/ }),
392
+
393
+ /***/ 76030:
394
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
395
+
396
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
397
+ /* harmony export */ "r": () => (/* binding */ symToStr)
398
+ /* harmony export */ });
399
+ /** @see <https://docs.tsafe.dev/main/symtostr> */
400
+ function symToStr(wrap) {
401
+ // @ts-expect-error: We know better
402
+ return Object.keys(wrap)[0];
403
+ }
404
+
405
+
406
+ //# sourceMappingURL=symToStr.mjs.map
407
+
408
+
345
409
  /***/ })
346
410
 
347
411
  };
package/bin/805.index.js CHANGED
@@ -3,23 +3,6 @@ exports.id = 805;
3
3
  exports.ids = [805];
4
4
  exports.modules = {
5
5
 
6
- /***/ 11800:
7
- /***/ ((__unused_webpack_module, exports) => {
8
-
9
-
10
- /* eslint-disable @typescript-eslint/no-namespace */
11
- /* eslint-disable @typescript-eslint/no-explicit-any */
12
- Object.defineProperty(exports, "__esModule", ({ value: true }));
13
- exports.typeGuard = void 0;
14
- /** https://docs.tsafe.dev/typeguard */
15
- function typeGuard(_value, isMatched) {
16
- return isMatched;
17
- }
18
- exports.typeGuard = typeGuard;
19
- //# sourceMappingURL=typeGuard.js.map
20
-
21
- /***/ }),
22
-
23
6
  /***/ 53501:
24
7
  /***/ (function(__unused_webpack_module, exports) {
25
8
 
@@ -304,7 +287,7 @@ exports.sameFactory = sameFactory;
304
287
 
305
288
  Object.defineProperty(exports, "__esModule", ({ value: true }));
306
289
  exports.DateLike = exports.ArrayLike = exports.MapLike = exports.SetLike = void 0;
307
- var typeGuard_1 = __webpack_require__(11800);
290
+ var typeGuard_1 = __webpack_require__(47393);
308
291
  var getPrototypeChain_1 = __webpack_require__(53501);
309
292
  var SetLike;
310
293
  (function (SetLike) {
@@ -668,6 +651,20 @@ exports.LightSetImpl = LightSetImpl;
668
651
  exports.Polyfill = typeof Set !== "undefined" ? Set : LightSetImpl;
669
652
  //# sourceMappingURL=Set.js.map
670
653
 
654
+ /***/ }),
655
+
656
+ /***/ 47393:
657
+ /***/ ((__unused_webpack_module, exports) => {
658
+
659
+
660
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
661
+ exports.typeGuard = typeGuard;
662
+ /** https://docs.tsafe.dev/typeguard */
663
+ function typeGuard(value, isMatched) {
664
+ return isMatched;
665
+ }
666
+ //# sourceMappingURL=typeGuard.js.map
667
+
671
668
  /***/ })
672
669
 
673
670
  };
package/bin/921.index.js CHANGED
@@ -30,8 +30,6 @@ var assert = __webpack_require__(29041);
30
30
  var lib = __webpack_require__(52300);
31
31
  // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
32
32
  var id = __webpack_require__(38469);
33
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/is.mjs
34
- var is = __webpack_require__(16453);
35
33
  ;// CONCATENATED MODULE: ./dist/bin/initialize-account-theme/updateAccountThemeImplementationInConfig.js
36
34
 
37
35
 
@@ -39,7 +37,6 @@ var is = __webpack_require__(16453);
39
37
 
40
38
 
41
39
 
42
-
43
40
  (0,assert/* assert */.h)();
44
41
  function updateAccountThemeImplementationInConfig(params) {
45
42
  const { buildContext, accountThemeType } = params;
@@ -73,7 +70,7 @@ function updateAccountThemeImplementationInConfig(params) {
73
70
  })();
74
71
  const parsedPackageJson = JSON.parse(external_fs_.readFileSync(buildContext.packageJsonFilePath).toString("utf8"));
75
72
  zParsedPackageJson.parse(parsedPackageJson);
76
- (0,assert/* assert */.h)((0,is.is)(parsedPackageJson));
73
+ (0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
77
74
  return parsedPackageJson;
78
75
  })();
79
76
  parsedPackageJson.keycloakify.accountThemeImplementation =
@@ -325,8 +322,8 @@ function getNodeModulesBinDirPath() {
325
322
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
326
323
 
327
324
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
325
+ /* harmony export */ "LG": () => (/* binding */ getPrettier),
328
326
  /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
329
- /* harmony export */ "cI": () => (/* binding */ getPrettierAndConfig),
330
327
  /* harmony export */ "eY": () => (/* binding */ runPrettier)
331
328
  /* harmony export */ });
332
329
  /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
@@ -334,17 +331,24 @@ function getNodeModulesBinDirPath() {
334
331
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
335
332
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
336
333
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
337
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(38469);
334
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
338
335
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
339
336
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
340
337
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
338
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
339
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
340
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
341
+ /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
342
+
343
+
341
344
 
342
345
 
343
346
 
344
347
 
345
348
 
346
349
 
347
- getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
350
+
351
+ getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
348
352
  async function getIsPrettierAvailable() {
349
353
  var _a;
350
354
  if (getIsPrettierAvailable.cache !== undefined) {
@@ -357,26 +361,53 @@ async function getIsPrettierAvailable() {
357
361
  getIsPrettierAvailable.cache = isPrettierAvailable;
358
362
  return isPrettierAvailable;
359
363
  }
360
- getPrettierAndConfig.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
361
- async function getPrettierAndConfig() {
364
+ getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
365
+ async function getPrettier() {
362
366
  (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
363
- if (getPrettierAndConfig.cache !== undefined) {
364
- return getPrettierAndConfig.cache;
367
+ if (getPrettier.cache !== undefined) {
368
+ return getPrettier.cache;
369
+ }
370
+ let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
371
+ import_prettier: {
372
+ // NOTE: When module is linked we want to make sure we import the correct version
373
+ // of prettier, that is the one of the project, not the one of this repo.
374
+ // So we do a sketchy eval to bypass ncc.
375
+ // We make sure to only do that when linking, otherwise we import properly.
376
+ if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
377
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${(0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), "..", "prettier"))}")`);
378
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
379
+ break import_prettier;
380
+ }
381
+ prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
365
382
  }
366
- const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
383
+ const configHash = await (async () => {
384
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."));
385
+ if (configFilePath === null) {
386
+ return "";
387
+ }
388
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
389
+ return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
390
+ })();
367
391
  const prettierAndConfig = {
368
392
  prettier,
369
- config: await prettier.resolveConfig((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."))
393
+ configHash
370
394
  };
371
- getPrettierAndConfig.cache = prettierAndConfig;
395
+ getPrettier.cache = prettierAndConfig;
372
396
  return prettierAndConfig;
373
397
  }
374
398
  async function runPrettier(params) {
375
399
  const { sourceCode, filePath } = params;
376
400
  let formattedSourceCode;
377
401
  try {
378
- const { prettier, config } = await getPrettierAndConfig();
379
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath }));
402
+ const { prettier } = await getPrettier();
403
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
404
+ resolveConfig: true
405
+ });
406
+ if (ignored) {
407
+ return sourceCode;
408
+ }
409
+ const config = await prettier.resolveConfig(filePath);
410
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
380
411
  }
381
412
  catch (error) {
382
413
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
@@ -412,6 +443,13 @@ __webpack_require__.r(__webpack_exports__);
412
443
 
413
444
  async function command(params) {
414
445
  const { buildContext } = params;
446
+ run_copy_assets_to_public: {
447
+ if (buildContext.bundler !== "webpack") {
448
+ break run_copy_assets_to_public;
449
+ }
450
+ const { command } = await __webpack_require__.e(/* import() */ 658).then(__webpack_require__.bind(__webpack_require__, 18040));
451
+ await command({ buildContext });
452
+ }
415
453
  const { hasBeenHandled } = (0,_shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_3__/* .maybeDelegateCommandToCustomHandler */ .q)({
416
454
  commandName: "update-kc-gen",
417
455
  buildContext
@@ -419,7 +457,7 @@ async function command(params) {
419
457
  if (hasBeenHandled) {
420
458
  return;
421
459
  }
422
- const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, "kc-gen.tsx");
460
+ const filePath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(buildContext.themeSrcDirPath, "kc.gen.tsx");
423
461
  const hasLoginTheme = buildContext.implementedThemeTypes.login.isImplemented;
424
462
  const hasAccountTheme = buildContext.implementedThemeTypes.account.isImplemented;
425
463
  const hasAdminTheme = buildContext.implementedThemeTypes.admin.isImplemented;
@@ -443,7 +481,12 @@ async function command(params) {
443
481
  ``,
444
482
  `export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(Object.fromEntries(buildContext.environmentVariables.map(({ name, default: defaultValue }) => [name, defaultValue])), null, 2)};`,
445
483
  ``,
446
- `type KcContext =`,
484
+ `/**`,
485
+ ` * NOTE: Do not import this type except maybe in your entrypoint. `,
486
+ ` * If you need to import the KcContext import it either from src/login/KcContext.ts or src/account/KcContext.ts.`,
487
+ ` * Depending on the theme type you are working on.`,
488
+ ` */`,
489
+ `export type KcContext =`,
447
490
  hasLoginTheme && ` | import("./login/KcContext").KcContext`,
448
491
  hasAccountTheme && ` | import("./account/KcContext").KcContext`,
449
492
  hasAdminTheme && ` | import("./admin/KcContext").KcContext`,
@@ -1094,6 +1137,24 @@ const withObjectValues = options => {
1094
1137
 
1095
1138
  exports.withObjectValues = withObjectValues;
1096
1139
 
1140
+ /***/ }),
1141
+
1142
+ /***/ 76030:
1143
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1144
+
1145
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1146
+ /* harmony export */ "r": () => (/* binding */ symToStr)
1147
+ /* harmony export */ });
1148
+ /** @see <https://docs.tsafe.dev/main/symtostr> */
1149
+ function symToStr(wrap) {
1150
+ // @ts-expect-error: We know better
1151
+ return Object.keys(wrap)[0];
1152
+ }
1153
+
1154
+
1155
+ //# sourceMappingURL=symToStr.mjs.map
1156
+
1157
+
1097
1158
  /***/ })
1098
1159
 
1099
1160
  };
package/bin/97.index.js CHANGED
@@ -263,8 +263,8 @@ function getNodeModulesBinDirPath() {
263
263
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
264
264
 
265
265
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
266
+ /* harmony export */ "LG": () => (/* binding */ getPrettier),
266
267
  /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
267
- /* harmony export */ "cI": () => (/* binding */ getPrettierAndConfig),
268
268
  /* harmony export */ "eY": () => (/* binding */ runPrettier)
269
269
  /* harmony export */ });
270
270
  /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
@@ -272,17 +272,24 @@ function getNodeModulesBinDirPath() {
272
272
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
273
273
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
274
274
  /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
275
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(38469);
275
+ /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
276
276
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
277
277
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
278
278
  /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
279
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
280
+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
281
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
282
+ /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
279
283
 
280
284
 
281
285
 
282
286
 
283
287
 
284
288
 
285
- getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
289
+
290
+
291
+
292
+ getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
286
293
  async function getIsPrettierAvailable() {
287
294
  var _a;
288
295
  if (getIsPrettierAvailable.cache !== undefined) {
@@ -295,26 +302,53 @@ async function getIsPrettierAvailable() {
295
302
  getIsPrettierAvailable.cache = isPrettierAvailable;
296
303
  return isPrettierAvailable;
297
304
  }
298
- getPrettierAndConfig.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_5__.id)(undefined);
299
- async function getPrettierAndConfig() {
305
+ getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
306
+ async function getPrettier() {
300
307
  (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
301
- if (getPrettierAndConfig.cache !== undefined) {
302
- return getPrettierAndConfig.cache;
308
+ if (getPrettier.cache !== undefined) {
309
+ return getPrettier.cache;
310
+ }
311
+ let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
312
+ import_prettier: {
313
+ // NOTE: When module is linked we want to make sure we import the correct version
314
+ // of prettier, that is the one of the project, not the one of this repo.
315
+ // So we do a sketchy eval to bypass ncc.
316
+ // We make sure to only do that when linking, otherwise we import properly.
317
+ if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
318
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${(0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), "..", "prettier"))}")`);
319
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
320
+ break import_prettier;
321
+ }
322
+ prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
303
323
  }
304
- const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
324
+ const configHash = await (async () => {
325
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."));
326
+ if (configFilePath === null) {
327
+ return "";
328
+ }
329
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
330
+ return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
331
+ })();
305
332
  const prettierAndConfig = {
306
333
  prettier,
307
- config: await prettier.resolveConfig((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."))
334
+ configHash
308
335
  };
309
- getPrettierAndConfig.cache = prettierAndConfig;
336
+ getPrettier.cache = prettierAndConfig;
310
337
  return prettierAndConfig;
311
338
  }
312
339
  async function runPrettier(params) {
313
340
  const { sourceCode, filePath } = params;
314
341
  let formattedSourceCode;
315
342
  try {
316
- const { prettier, config } = await getPrettierAndConfig();
317
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath }));
343
+ const { prettier } = await getPrettier();
344
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
345
+ resolveConfig: true
346
+ });
347
+ if (ignored) {
348
+ return sourceCode;
349
+ }
350
+ const config = await prettier.resolveConfig(filePath);
351
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
318
352
  }
319
353
  catch (error) {
320
354
  console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
@@ -903,7 +937,6 @@ exports.withObjectValues = withObjectValues;
903
937
  /* harmony export */ });
904
938
  /** @see <https://docs.tsafe.dev/capitalize> */
905
939
  function capitalize(str) {
906
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
907
940
  return (str.charAt(0).toUpperCase() + str.slice(1));
908
941
  }
909
942
 
@@ -911,6 +944,24 @@ function capitalize(str) {
911
944
  //# sourceMappingURL=capitalize.mjs.map
912
945
 
913
946
 
947
+ /***/ }),
948
+
949
+ /***/ 76030:
950
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
951
+
952
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
953
+ /* harmony export */ "r": () => (/* binding */ symToStr)
954
+ /* harmony export */ });
955
+ /** @see <https://docs.tsafe.dev/main/symtostr> */
956
+ function symToStr(wrap) {
957
+ // @ts-expect-error: We know better
958
+ return Object.keys(wrap)[0];
959
+ }
960
+
961
+
962
+ //# sourceMappingURL=symToStr.mjs.map
963
+
964
+
914
965
  /***/ })
915
966
 
916
967
  };