keycloakify 10.1.0-rc.0 → 10.1.0

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 (205) hide show
  1. package/PUBLIC_URL.js +2 -2
  2. package/PUBLIC_URL.js.map +1 -1
  3. package/account/KcContext/kcContextMocks.js +3 -3
  4. package/account/KcContext/kcContextMocks.js.map +1 -1
  5. package/bin/193.index.js +198 -62
  6. package/bin/{365.index.js → 20.index.js} +302 -263
  7. package/bin/31.index.js +15 -23
  8. package/bin/{430.index.js → 33.index.js} +579 -4
  9. package/bin/{678.index.js → 36.index.js} +2 -577
  10. package/bin/{440.index.js → 499.index.js} +259 -181
  11. package/bin/526.index.js +3 -784
  12. package/bin/599.index.js +4 -1
  13. package/bin/780.index.js +1 -1
  14. package/bin/{525.index.js → 903.index.js} +4840 -97
  15. package/bin/932.index.js +115 -886
  16. package/bin/main.js +4 -4
  17. package/bin/shared/buildContext.d.ts +0 -2
  18. package/bin/shared/buildContext.js.map +1 -1
  19. package/bin/shared/constants.d.ts +5 -6
  20. package/bin/shared/constants.js +5 -6
  21. package/bin/shared/constants.js.map +1 -1
  22. package/bin/shared/copyKeycloakResourcesToPublic.d.ts +2 -4
  23. package/bin/shared/copyKeycloakResourcesToPublic.js.map +1 -1
  24. package/login/KcContext/KcContext.d.ts +9 -18
  25. package/login/KcContext/KcContext.js.map +1 -1
  26. package/login/KcContext/kcContextMocks.js +6 -10
  27. package/login/KcContext/kcContextMocks.js.map +1 -1
  28. package/login/Template.js +4 -59
  29. package/login/Template.js.map +1 -1
  30. package/login/Template.useStylesAndScripts.d.ts +17 -0
  31. package/login/Template.useStylesAndScripts.js +69 -0
  32. package/login/Template.useStylesAndScripts.js.map +1 -0
  33. package/login/pages/Login.js +1 -1
  34. package/login/pages/Login.js.map +1 -1
  35. package/login/pages/LoginIdpLinkConfirmOverride.js +0 -1
  36. package/login/pages/LoginIdpLinkConfirmOverride.js.map +1 -1
  37. package/login/pages/LoginPasskeysConditionalAuthenticate.js +6 -49
  38. package/login/pages/LoginPasskeysConditionalAuthenticate.js.map +1 -1
  39. package/login/pages/LoginPasskeysConditionalAuthenticate.useScript.d.ts +20 -0
  40. package/login/pages/LoginPasskeysConditionalAuthenticate.useScript.js +49 -0
  41. package/login/pages/LoginPasskeysConditionalAuthenticate.useScript.js.map +1 -0
  42. package/login/pages/LoginRecoveryAuthnCodeConfig.js +4 -126
  43. package/login/pages/LoginRecoveryAuthnCodeConfig.js.map +1 -1
  44. package/login/pages/LoginRecoveryAuthnCodeConfig.useScript.d.ts +9 -0
  45. package/login/pages/LoginRecoveryAuthnCodeConfig.useScript.js +133 -0
  46. package/login/pages/LoginRecoveryAuthnCodeConfig.useScript.js.map +1 -0
  47. package/login/pages/LoginUsername.js +1 -1
  48. package/login/pages/LoginUsername.js.map +1 -1
  49. package/login/pages/Register.js +6 -3
  50. package/login/pages/Register.js.map +1 -1
  51. package/login/pages/WebauthnAuthenticate.js +13 -116
  52. package/login/pages/WebauthnAuthenticate.js.map +1 -1
  53. package/login/pages/WebauthnAuthenticate.useScript.d.ts +21 -0
  54. package/login/pages/WebauthnAuthenticate.useScript.js +41 -0
  55. package/login/pages/WebauthnAuthenticate.useScript.js.map +1 -0
  56. package/login/pages/WebauthnRegister.js +8 -178
  57. package/login/pages/WebauthnRegister.js.map +1 -1
  58. package/login/pages/WebauthnRegister.useScript.d.ts +27 -0
  59. package/login/pages/WebauthnRegister.useScript.js +49 -0
  60. package/login/pages/WebauthnRegister.useScript.js.map +1 -0
  61. package/package.json +125 -15
  62. package/res/account-v1/account.ftl +70 -0
  63. package/res/account-v1/applications.ftl +76 -0
  64. package/res/account-v1/federatedIdentity.ftl +42 -0
  65. package/res/account-v1/log.ftl +35 -0
  66. package/res/account-v1/messages/messages_ar.properties +406 -0
  67. package/res/account-v1/messages/messages_ca.properties +147 -0
  68. package/res/account-v1/messages/messages_cs.properties +171 -0
  69. package/res/account-v1/messages/messages_da.properties +339 -0
  70. package/res/account-v1/messages/messages_de.properties +353 -0
  71. package/res/account-v1/messages/messages_en.properties +404 -0
  72. package/res/account-v1/messages/messages_es.properties +147 -0
  73. package/res/account-v1/messages/messages_fi.properties +400 -0
  74. package/res/account-v1/messages/messages_fr.properties +180 -0
  75. package/res/account-v1/messages/messages_hu.properties +334 -0
  76. package/res/account-v1/messages/messages_it.properties +336 -0
  77. package/res/account-v1/messages/messages_ja.properties +335 -0
  78. package/res/account-v1/messages/messages_lt.properties +154 -0
  79. package/res/account-v1/messages/messages_lv.properties +197 -0
  80. package/res/account-v1/messages/messages_nl.properties +371 -0
  81. package/res/account-v1/messages/messages_no.properties +152 -0
  82. package/res/account-v1/messages/messages_pl.properties +248 -0
  83. package/res/account-v1/messages/messages_pt_BR.properties +349 -0
  84. package/res/account-v1/messages/messages_ru.properties +235 -0
  85. package/res/account-v1/messages/messages_sk.properties +196 -0
  86. package/res/account-v1/messages/messages_sv.properties +150 -0
  87. package/res/account-v1/messages/messages_tr.properties +315 -0
  88. package/res/account-v1/messages/messages_zh_CN.properties +153 -0
  89. package/res/account-v1/password.ftl +59 -0
  90. package/res/account-v1/resource-detail.ftl +277 -0
  91. package/res/account-v1/resources/css/account.css +277 -0
  92. package/res/account-v1/resources/img/icon-sidebar-active.png +0 -0
  93. package/res/account-v1/resources/img/keycloak-logo.png +0 -0
  94. package/res/account-v1/resources/img/logo.png +0 -0
  95. package/res/account-v1/resources/resources-common/img/favicon.ico +0 -0
  96. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css +5 -0
  97. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/css/patternfly.min.css +8 -0
  98. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
  99. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
  100. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
  101. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
  102. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
  103. package/res/account-v1/resources/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
  104. package/res/account-v1/resources.ftl +403 -0
  105. package/res/account-v1/sessions.ftl +44 -0
  106. package/res/account-v1/template.ftl +88 -0
  107. package/res/account-v1/theme.properties +14 -0
  108. package/res/account-v1/totp.ftl +141 -0
  109. package/res/public/.keycloakify/account/css/account.css +277 -0
  110. package/res/public/.keycloakify/account/img/icon-sidebar-active.png +0 -0
  111. package/res/public/.keycloakify/account/img/keycloak-logo.png +0 -0
  112. package/res/public/.keycloakify/account/img/logo.png +0 -0
  113. package/res/public/.keycloakify/account/resources-common/img/favicon.ico +0 -0
  114. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css +5 -0
  115. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/css/patternfly.min.css +8 -0
  116. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
  117. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
  118. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
  119. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
  120. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
  121. package/res/public/.keycloakify/account/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
  122. package/res/public/.keycloakify/login/css/login.css +629 -0
  123. package/res/public/.keycloakify/login/img/feedback-error-arrow-down.png +0 -0
  124. package/res/public/.keycloakify/login/img/feedback-error-sign.png +0 -0
  125. package/res/public/.keycloakify/login/img/feedback-success-arrow-down.png +0 -0
  126. package/res/public/.keycloakify/login/img/feedback-success-sign.png +0 -0
  127. package/res/public/.keycloakify/login/img/feedback-warning-arrow-down.png +0 -0
  128. package/res/public/.keycloakify/login/img/feedback-warning-sign.png +0 -0
  129. package/res/public/.keycloakify/login/img/keycloak-bg.png +0 -0
  130. package/res/public/.keycloakify/login/img/keycloak-logo-text.png +0 -0
  131. package/res/public/.keycloakify/login/img/keycloak-logo.png +0 -0
  132. package/res/public/.keycloakify/login/js/authChecker.js +49 -0
  133. package/res/public/.keycloakify/login/js/common.js +48 -0
  134. package/res/public/.keycloakify/login/js/kcMultivalued.js +106 -0
  135. package/res/public/.keycloakify/login/js/kcNumberFormat.js +21 -0
  136. package/res/public/.keycloakify/login/js/kcNumberUnFormat.js +19 -0
  137. package/res/public/.keycloakify/login/js/menu-button-links.js +315 -0
  138. package/{src/bin/shared/downloadKeycloakDefaultTheme/extra-assets → res/public/.keycloakify/login/js}/passkeysConditionalAuth.js +1 -1
  139. package/res/public/.keycloakify/login/js/passwordVisibility.js +15 -0
  140. package/res/public/.keycloakify/login/js/userProfile.js +71 -0
  141. package/res/public/.keycloakify/login/js/webauthnRegister.js +140 -0
  142. package/res/public/.keycloakify/login/resources-common/img/favicon.ico +0 -0
  143. package/res/public/.keycloakify/login/resources-common/lib/pficon/pficon.css +22 -0
  144. package/res/public/.keycloakify/login/resources-common/lib/pficon/pficon.woff2 +0 -0
  145. package/res/public/.keycloakify/login/resources-common/node_modules/@patternfly/patternfly/patternfly.min.css +2 -0
  146. package/res/public/.keycloakify/login/resources-common/node_modules/jquery/dist/jquery.min.js +2 -0
  147. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/css/patternfly-additions.min.css +5 -0
  148. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/css/patternfly.min.css +8 -0
  149. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.ttf +0 -0
  150. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff +0 -0
  151. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
  152. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
  153. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
  154. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
  155. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
  156. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
  157. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/fonts/fontawesome-webfont.woff2 +0 -0
  158. package/res/public/.keycloakify/login/resources-common/node_modules/patternfly/dist/img/bg-login.jpg +0 -0
  159. package/res/public/.keycloakify/login/resources-common/node_modules/rfc4648/lib/rfc4648.js +178 -0
  160. package/src/PUBLIC_URL.ts +5 -3
  161. package/src/account/KcContext/kcContextMocks.ts +3 -3
  162. package/src/bin/copy-keycloak-resources-to-public.ts +1 -1
  163. package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +4 -1
  164. package/src/bin/initialize-email-theme.ts +28 -8
  165. package/src/bin/keycloakify/buildJars/buildJar.ts +3 -7
  166. package/src/bin/keycloakify/generateFtl/generateFtl.ts +3 -7
  167. package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +65 -90
  168. package/src/bin/keycloakify/keycloakify.ts +38 -21
  169. package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +2 -2
  170. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +3 -3
  171. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +3 -3
  172. package/src/bin/shared/buildContext.ts +1 -8
  173. package/src/bin/shared/constants.ts +5 -7
  174. package/src/bin/shared/copyKeycloakResourcesToPublic.ts +30 -40
  175. package/src/bin/start-keycloak/start-keycloak.ts +3 -7
  176. package/src/login/KcContext/KcContext.ts +9 -18
  177. package/src/login/KcContext/kcContextMocks.ts +5 -13
  178. package/src/login/Template.tsx +4 -67
  179. package/src/login/Template.useStylesAndScripts.ts +94 -0
  180. package/src/login/pages/Login.tsx +1 -1
  181. package/src/login/pages/LoginIdpLinkConfirmOverride.tsx +0 -1
  182. package/src/login/pages/LoginPasskeysConditionalAuthenticate.tsx +6 -81
  183. package/src/login/pages/LoginPasskeysConditionalAuthenticate.useScript.tsx +72 -0
  184. package/src/login/pages/LoginRecoveryAuthnCodeConfig.tsx +4 -126
  185. package/src/login/pages/LoginRecoveryAuthnCodeConfig.useScript.tsx +142 -0
  186. package/src/login/pages/LoginUsername.tsx +1 -1
  187. package/src/login/pages/Register.tsx +35 -13
  188. package/src/login/pages/WebauthnAuthenticate.tsx +20 -133
  189. package/src/login/pages/WebauthnAuthenticate.useScript.tsx +64 -0
  190. package/src/login/pages/WebauthnRegister.tsx +8 -195
  191. package/src/login/pages/WebauthnRegister.useScript.tsx +93 -0
  192. package/src/tools/useInsertScriptTags.ts +14 -4
  193. package/src/vite-plugin/vite-plugin.ts +11 -15
  194. package/tools/useInsertScriptTags.d.ts +2 -2
  195. package/tools/useInsertScriptTags.js +8 -2
  196. package/tools/useInsertScriptTags.js.map +1 -1
  197. package/vite-plugin/index.js +3357 -47132
  198. package/bin/697.index.js +0 -4749
  199. package/bin/shared/downloadKeycloakStaticResources.d.ts +0 -9
  200. package/bin/shared/downloadKeycloakStaticResources.js.map +0 -1
  201. package/src/bin/keycloakify/generateResources/bringInAccountV1.ts +0 -89
  202. package/src/bin/shared/downloadKeycloakDefaultTheme/downloadKeycloakDefaultTheme.ts +0 -337
  203. package/src/bin/shared/downloadKeycloakDefaultTheme/index.ts +0 -1
  204. package/src/bin/shared/downloadKeycloakStaticResources.ts +0 -53
  205. /package/{src/bin/shared/downloadKeycloakDefaultTheme/extra-assets → res/public/.keycloakify/login/js}/webauthnAuthenticate.js +0 -0
@@ -1,146 +1,7 @@
1
- exports.id = 678;
2
- exports.ids = [678];
1
+ exports.id = 36;
2
+ exports.ids = [36];
3
3
  exports.modules = {
4
4
 
5
- /***/ 18512:
6
- /***/ ((module) => {
7
-
8
- "use strict";
9
-
10
- const x = module.exports;
11
- const ESC = '\u001B[';
12
- const OSC = '\u001B]';
13
- const BEL = '\u0007';
14
- const SEP = ';';
15
- const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
16
-
17
- x.cursorTo = (x, y) => {
18
- if (typeof x !== 'number') {
19
- throw new TypeError('The `x` argument is required');
20
- }
21
-
22
- if (typeof y !== 'number') {
23
- return ESC + (x + 1) + 'G';
24
- }
25
-
26
- return ESC + (y + 1) + ';' + (x + 1) + 'H';
27
- };
28
-
29
- x.cursorMove = (x, y) => {
30
- if (typeof x !== 'number') {
31
- throw new TypeError('The `x` argument is required');
32
- }
33
-
34
- let ret = '';
35
-
36
- if (x < 0) {
37
- ret += ESC + (-x) + 'D';
38
- } else if (x > 0) {
39
- ret += ESC + x + 'C';
40
- }
41
-
42
- if (y < 0) {
43
- ret += ESC + (-y) + 'A';
44
- } else if (y > 0) {
45
- ret += ESC + y + 'B';
46
- }
47
-
48
- return ret;
49
- };
50
-
51
- x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
52
- x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
53
- x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
54
- x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
55
-
56
- x.cursorLeft = ESC + 'G';
57
- x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
58
- x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
59
- x.cursorGetPosition = ESC + '6n';
60
- x.cursorNextLine = ESC + 'E';
61
- x.cursorPrevLine = ESC + 'F';
62
- x.cursorHide = ESC + '?25l';
63
- x.cursorShow = ESC + '?25h';
64
-
65
- x.eraseLines = count => {
66
- let clear = '';
67
-
68
- for (let i = 0; i < count; i++) {
69
- clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
70
- }
71
-
72
- if (count) {
73
- clear += x.cursorLeft;
74
- }
75
-
76
- return clear;
77
- };
78
-
79
- x.eraseEndLine = ESC + 'K';
80
- x.eraseStartLine = ESC + '1K';
81
- x.eraseLine = ESC + '2K';
82
- x.eraseDown = ESC + 'J';
83
- x.eraseUp = ESC + '1J';
84
- x.eraseScreen = ESC + '2J';
85
- x.scrollUp = ESC + 'S';
86
- x.scrollDown = ESC + 'T';
87
-
88
- x.clearScreen = '\u001Bc';
89
-
90
- x.clearTerminal = process.platform === 'win32' ?
91
- `${x.eraseScreen}${ESC}0f` :
92
- // 1. Erases the screen (Only done in case `2` is not supported)
93
- // 2. Erases the whole screen including scrollback buffer
94
- // 3. Moves cursor to the top-left position
95
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
96
- `${x.eraseScreen}${ESC}3J${ESC}H`;
97
-
98
- x.beep = BEL;
99
-
100
- x.link = (text, url) => {
101
- return [
102
- OSC,
103
- '8',
104
- SEP,
105
- SEP,
106
- url,
107
- BEL,
108
- text,
109
- OSC,
110
- '8',
111
- SEP,
112
- SEP,
113
- BEL
114
- ].join('');
115
- };
116
-
117
- x.image = (buf, opts) => {
118
- opts = opts || {};
119
-
120
- let ret = OSC + '1337;File=inline=1';
121
-
122
- if (opts.width) {
123
- ret += `;width=${opts.width}`;
124
- }
125
-
126
- if (opts.height) {
127
- ret += `;height=${opts.height}`;
128
- }
129
-
130
- if (opts.preserveAspectRatio === false) {
131
- ret += ';preserveAspectRatio=0';
132
- }
133
-
134
- return ret + ':' + buf.toString('base64') + BEL;
135
- };
136
-
137
- x.iTerm = {};
138
-
139
- x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
140
-
141
-
142
- /***/ }),
143
-
144
5
  /***/ 35575:
145
6
  /***/ ((module, exports, __webpack_require__) => {
146
7
 
@@ -3437,442 +3298,6 @@ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
3437
3298
  module.exports = NodeFsHandler;
3438
3299
 
3439
3300
 
3440
- /***/ }),
3441
-
3442
- /***/ 39340:
3443
- /***/ ((__unused_webpack_module, exports) => {
3444
-
3445
- "use strict";
3446
-
3447
-
3448
- Object.defineProperty(exports, "__esModule", ({
3449
- value: true
3450
- }));
3451
- exports.withPromise = exports.withCallback = void 0;
3452
-
3453
- /**
3454
- * Open the input with a normal callback function
3455
- *
3456
- * @param {Input} input - input object
3457
- * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
3458
- * @param {function} callback - callback function
3459
- */
3460
- const withCallback = (input, valueMapper, callback) => {
3461
- input.open();
3462
- input.onSelect((id, value) => callback(valueMapper(id, value)));
3463
- };
3464
- /**
3465
- * Open the input with a promise
3466
- *
3467
- * @param {Input} input - input object
3468
- * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
3469
- */
3470
-
3471
-
3472
- exports.withCallback = withCallback;
3473
-
3474
- const withPromise = (input, valueMapper) => {
3475
- return new Promise((resolve, reject) => {
3476
- input.open();
3477
- input.onSelect((id, value) => {
3478
- if (id === null) {
3479
- reject();
3480
- } else {
3481
- resolve(valueMapper(id, value));
3482
- }
3483
- });
3484
- });
3485
- };
3486
-
3487
- exports.withPromise = withPromise;
3488
-
3489
- /***/ }),
3490
-
3491
- /***/ 99398:
3492
- /***/ ((module, exports, __webpack_require__) => {
3493
-
3494
- "use strict";
3495
-
3496
-
3497
- Object.defineProperty(exports, "__esModule", ({
3498
- value: true
3499
- }));
3500
- exports["default"] = void 0;
3501
-
3502
- var _input = _interopRequireDefault(__webpack_require__(25730));
3503
-
3504
- var _renderer = _interopRequireDefault(__webpack_require__(16059));
3505
-
3506
- var _callbackMappers = __webpack_require__(39340);
3507
-
3508
- var _valueMappers = __webpack_require__(26730);
3509
-
3510
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3511
-
3512
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
3513
-
3514
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3515
-
3516
- /**
3517
- * Default options
3518
- */
3519
- const defaultOptions = {
3520
- outputStream: process.stdout,
3521
- inputStream: process.stdin,
3522
- values: [],
3523
- defaultValue: 0,
3524
- selected: '(x)',
3525
- unselected: '( )',
3526
- indentation: 0,
3527
- cleanup: true,
3528
- valueRenderer: value => value
3529
- };
3530
- /**
3531
- * Create an instance of cli-select with the given options
3532
- *
3533
- * @param {object} options - options for cli-select
3534
- * @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
3535
- */
3536
-
3537
- const creator = (options, callback) => {
3538
- // merge options with default options
3539
- options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
3540
-
3541
- const renderer = new _renderer.default(options, options.outputStream);
3542
- const input = new _input.default(options.inputStream);
3543
- input.setDefaultValue(options.defaultValue);
3544
- input.attachRenderer(renderer); // handle array and object values
3545
-
3546
- let valueMapper;
3547
-
3548
- if (Array.isArray(options.values)) {
3549
- valueMapper = (0, _valueMappers.withArrayValues)(options);
3550
- } else {
3551
- valueMapper = (0, _valueMappers.withObjectValues)(options);
3552
- } // map values
3553
-
3554
-
3555
- options.values = valueMapper.input;
3556
- input.setValues(options.values); // handle different callback methods
3557
-
3558
- if (typeof callback === 'function') {
3559
- return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
3560
- } else {
3561
- return (0, _callbackMappers.withPromise)(input, valueMapper.output);
3562
- }
3563
- };
3564
-
3565
- exports = module.exports = creator;
3566
- Object.defineProperty(exports, "__esModule", ({
3567
- value: true
3568
- }));
3569
- var _default = creator;
3570
- exports["default"] = _default;
3571
-
3572
- /***/ }),
3573
-
3574
- /***/ 25730:
3575
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3576
-
3577
- "use strict";
3578
-
3579
-
3580
- Object.defineProperty(exports, "__esModule", ({
3581
- value: true
3582
- }));
3583
- exports["default"] = void 0;
3584
-
3585
- var _readline = _interopRequireDefault(__webpack_require__(14521));
3586
-
3587
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3588
-
3589
- /**
3590
- * Handle cli input
3591
- */
3592
- class Input {
3593
- /**
3594
- * Input constructor
3595
- *
3596
- * @param {any} stream - stream to catch (optional)
3597
- */
3598
- constructor(stream = process.stdin) {
3599
- // set default values
3600
- this.stream = stream;
3601
- this.values = [];
3602
- this.selectedValue = 0;
3603
-
3604
- this.onSelectListener = () => {};
3605
-
3606
- this.onKeyPress = this.onKeyPress.bind(this);
3607
- }
3608
- /**
3609
- * Set the available values
3610
- *
3611
- * @param {array} values - all available values
3612
- */
3613
-
3614
-
3615
- setValues(values) {
3616
- this.values = values;
3617
-
3618
- if (this.renderer) {
3619
- this.renderer.setValues(values);
3620
- }
3621
- }
3622
- /**
3623
- * Set the default value
3624
- *
3625
- * @param {number} defaultValue - default value id
3626
- */
3627
-
3628
-
3629
- setDefaultValue(defaultValue) {
3630
- this.selectedValue = defaultValue;
3631
- }
3632
- /**
3633
- * Attach a renderer to the input catcher
3634
- *
3635
- * @param {Renderer} renderer - renderer to use for rendering responses
3636
- */
3637
-
3638
-
3639
- attachRenderer(renderer) {
3640
- this.renderer = renderer;
3641
- this.renderer.setValues(this.values);
3642
- }
3643
- /**
3644
- * Register an on select listener
3645
- *
3646
- * @param {function} listener - listener function which receives two parameters: valueId and value
3647
- */
3648
-
3649
-
3650
- onSelect(listener) {
3651
- this.onSelectListener = listener;
3652
- }
3653
- /**
3654
- * Open the stream and listen for input
3655
- */
3656
-
3657
-
3658
- open() {
3659
- // register keypress event
3660
- _readline.default.emitKeypressEvents(this.stream); // handle keypress
3661
-
3662
-
3663
- this.stream.on('keypress', this.onKeyPress); // initially render the response
3664
-
3665
- if (this.renderer) {
3666
- this.renderer.render(this.selectedValue);
3667
- } // hide pressed keys and start listening on input
3668
-
3669
-
3670
- this.stream.setRawMode(true);
3671
- this.stream.resume();
3672
- }
3673
- /**
3674
- * Close the stream
3675
- *
3676
- * @param {boolean} cancelled - true if no value was selected (optional)
3677
- */
3678
-
3679
-
3680
- close(cancelled = false) {
3681
- // reset stream properties
3682
- this.stream.setRawMode(false);
3683
- this.stream.pause(); // cleanup the output
3684
-
3685
- if (this.renderer) {
3686
- this.renderer.cleanup();
3687
- } // call the on select listener
3688
-
3689
-
3690
- if (cancelled) {
3691
- this.onSelectListener(null);
3692
- } else {
3693
- this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
3694
- }
3695
-
3696
- this.stream.removeListener('keypress', this.onKeyPress);
3697
- }
3698
- /**
3699
- * Render the response
3700
- */
3701
-
3702
-
3703
- render() {
3704
- if (!this.renderer) {
3705
- return;
3706
- }
3707
-
3708
- this.renderer.render(this.selectedValue);
3709
- }
3710
- /**
3711
- * Handle key press event
3712
- *
3713
- * @param {string} string - input string
3714
- * @param {object} key - object containing information about the pressed key
3715
- */
3716
-
3717
-
3718
- onKeyPress(string, key) {
3719
- if (key) {
3720
- if (key.name === 'up' && this.selectedValue > 0) {
3721
- this.selectedValue--;
3722
- this.render();
3723
- } else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
3724
- this.selectedValue++;
3725
- this.render();
3726
- } else if (key.name === 'return') {
3727
- this.close();
3728
- } else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
3729
- this.close(true);
3730
- }
3731
- }
3732
- }
3733
-
3734
- }
3735
-
3736
- exports["default"] = Input;
3737
-
3738
- /***/ }),
3739
-
3740
- /***/ 16059:
3741
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3742
-
3743
- "use strict";
3744
-
3745
-
3746
- Object.defineProperty(exports, "__esModule", ({
3747
- value: true
3748
- }));
3749
- exports["default"] = void 0;
3750
-
3751
- var _readline = _interopRequireDefault(__webpack_require__(14521));
3752
-
3753
- var _ansiEscapes = __webpack_require__(18512);
3754
-
3755
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3756
-
3757
- /**
3758
- * Response renderer
3759
- */
3760
- class Renderer {
3761
- /**
3762
- * Renderer constructor
3763
- *
3764
- * @param {object} options - renderer options
3765
- * @param {any} stream - stream to write to (optional)
3766
- */
3767
- constructor(options, stream = process.stdout) {
3768
- this.options = options;
3769
- this.stream = stream;
3770
- this.values = [];
3771
- this.initialRender = true;
3772
- }
3773
- /**
3774
- * Set the available values
3775
- *
3776
- * @param {array} values - all available values
3777
- */
3778
-
3779
-
3780
- setValues(values) {
3781
- this.values = values;
3782
- }
3783
- /**
3784
- * Render the values
3785
- *
3786
- * @param {number} selectedValue - selected value (optional)
3787
- */
3788
-
3789
-
3790
- render(selectedValue = 0) {
3791
- if (this.initialRender) {
3792
- // hide the cursor initially
3793
- this.initialRender = false;
3794
- this.stream.write(_ansiEscapes.cursorHide);
3795
- } else {
3796
- // remove previous lines and values
3797
- this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
3798
- } // output the current values
3799
-
3800
-
3801
- this.values.forEach((value, index) => {
3802
- const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
3803
- const indentation = ' '.repeat(this.options.indentation);
3804
- const renderedValue = this.options.valueRenderer(value, selectedValue === index);
3805
- const end = index !== this.values.length - 1 ? '\n' : '';
3806
- this.stream.write(indentation + symbol + ' ' + renderedValue + end);
3807
- });
3808
- }
3809
- /**
3810
- * Cleanup the console at the end
3811
- */
3812
-
3813
-
3814
- cleanup() {
3815
- this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
3816
- this.stream.write(_ansiEscapes.cursorShow);
3817
- }
3818
-
3819
- }
3820
-
3821
- exports["default"] = Renderer;
3822
-
3823
- /***/ }),
3824
-
3825
- /***/ 26730:
3826
- /***/ ((__unused_webpack_module, exports) => {
3827
-
3828
- "use strict";
3829
-
3830
-
3831
- Object.defineProperty(exports, "__esModule", ({
3832
- value: true
3833
- }));
3834
- exports.withObjectValues = exports.withArrayValues = void 0;
3835
-
3836
- /**
3837
- * Map incoming and outgoing values if the initial values are an array
3838
- *
3839
- * @param {object} options - cli-select options
3840
- */
3841
- const withArrayValues = options => {
3842
- return {
3843
- input: options.values,
3844
- output: (id, value) => {
3845
- return {
3846
- id,
3847
- value
3848
- };
3849
- }
3850
- };
3851
- };
3852
- /**
3853
- * Map incoming and outgoing values if the initial values are an object
3854
- *
3855
- * @param {object} options - cli-select options
3856
- */
3857
-
3858
-
3859
- exports.withArrayValues = withArrayValues;
3860
-
3861
- const withObjectValues = options => {
3862
- const originalValues = options.values;
3863
- return {
3864
- input: Object.values(originalValues),
3865
- output: (id, value) => {
3866
- return {
3867
- id: Object.keys(originalValues)[id],
3868
- value
3869
- };
3870
- }
3871
- };
3872
- };
3873
-
3874
- exports.withObjectValues = withObjectValues;
3875
-
3876
3301
  /***/ }),
3877
3302
 
3878
3303
  /***/ 6330: