@adonisjs/core 5.9.0 → 6.0.0-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 (256) hide show
  1. package/README.md +6 -15
  2. package/build/commands/commands.json +1 -0
  3. package/build/commands/eject.d.ts +8 -0
  4. package/build/commands/eject.js +34 -0
  5. package/build/commands/{GenerateKey.d.ts → generate_key.d.ts} +3 -4
  6. package/build/commands/generate_key.js +47 -0
  7. package/build/commands/main.js +36 -0
  8. package/build/commands/make/_base.d.ts +6 -0
  9. package/build/commands/make/_base.js +19 -0
  10. package/build/commands/make/command.d.ts +8 -0
  11. package/build/commands/make/command.js +25 -0
  12. package/build/commands/make/controller.d.ts +12 -0
  13. package/build/commands/make/controller.js +57 -0
  14. package/build/commands/make/event.d.ts +8 -0
  15. package/build/commands/make/event.js +25 -0
  16. package/build/commands/make/listener.d.ts +10 -0
  17. package/build/commands/make/listener.js +48 -0
  18. package/build/commands/make/middleware.d.ts +8 -0
  19. package/build/commands/make/middleware.js +25 -0
  20. package/build/commands/make/provider.d.ts +8 -0
  21. package/build/commands/make/provider.js +25 -0
  22. package/build/index.d.ts +140 -0
  23. package/build/index.js +21 -0
  24. package/build/legacy/validator.d.ts +1 -0
  25. package/build/legacy/validator.js +1 -0
  26. package/build/modules/ace/commands.d.ts +26 -0
  27. package/build/modules/ace/commands.js +63 -0
  28. package/build/modules/ace/create_kernel.d.ts +3 -0
  29. package/build/modules/ace/create_kernel.js +33 -0
  30. package/build/modules/ace/kernel.d.ts +7 -0
  31. package/build/modules/ace/kernel.js +14 -0
  32. package/build/modules/ace/main.d.ts +3 -0
  33. package/build/modules/ace/main.js +3 -0
  34. package/build/modules/app.d.ts +1 -0
  35. package/build/modules/app.js +1 -0
  36. package/build/modules/bodyparser/bodyparser_middleware.d.ts +2 -0
  37. package/build/modules/bodyparser/bodyparser_middleware.js +2 -0
  38. package/build/modules/bodyparser/main.d.ts +1 -0
  39. package/build/modules/bodyparser/main.js +1 -0
  40. package/build/modules/config.d.ts +1 -0
  41. package/build/modules/config.js +1 -0
  42. package/build/modules/container.d.ts +1 -0
  43. package/build/modules/container.js +1 -0
  44. package/build/modules/encryption.d.ts +1 -0
  45. package/build/modules/encryption.js +1 -0
  46. package/build/modules/env.d.ts +1 -0
  47. package/build/modules/env.js +1 -0
  48. package/build/modules/events.d.ts +1 -0
  49. package/build/modules/events.js +1 -0
  50. package/build/modules/hash/define_config.d.ts +15 -0
  51. package/build/modules/hash/define_config.js +19 -0
  52. package/build/modules/hash/drivers_collection.d.ts +9 -0
  53. package/build/modules/hash/drivers_collection.js +22 -0
  54. package/build/modules/hash/main.d.ts +2 -0
  55. package/build/modules/hash/main.js +2 -0
  56. package/build/modules/http.d.ts +1 -0
  57. package/build/modules/http.js +1 -0
  58. package/build/modules/logger.d.ts +1 -0
  59. package/build/modules/logger.js +1 -0
  60. package/build/providers/app_provider.d.ts +16 -0
  61. package/build/providers/app_provider.js +74 -0
  62. package/build/providers/hash_provider.d.ts +9 -0
  63. package/build/providers/hash_provider.js +29 -0
  64. package/build/providers/http_provider.d.ts +9 -0
  65. package/build/providers/http_provider.js +36 -0
  66. package/build/services/ace.d.ts +3 -0
  67. package/build/services/ace.js +6 -0
  68. package/build/services/app.d.ts +4 -12
  69. package/build/services/app.js +5 -12
  70. package/build/services/config.d.ts +3 -3
  71. package/build/services/config.js +6 -12
  72. package/build/services/emitter.d.ts +3 -0
  73. package/build/services/emitter.js +7 -0
  74. package/build/services/encryption.d.ts +3 -3
  75. package/build/services/encryption.js +7 -12
  76. package/build/services/hash.d.ts +3 -3
  77. package/build/services/hash.js +7 -12
  78. package/build/services/logger.d.ts +3 -0
  79. package/build/services/logger.js +7 -0
  80. package/build/services/router.d.ts +3 -0
  81. package/build/services/router.js +7 -0
  82. package/build/services/server.d.ts +3 -0
  83. package/build/services/server.js +7 -0
  84. package/build/services/test_utils.d.ts +3 -0
  85. package/build/services/test_utils.js +6 -0
  86. package/build/src/debug.d.ts +3 -0
  87. package/build/src/debug.js +2 -0
  88. package/build/src/helpers/is.d.ts +2 -0
  89. package/build/src/helpers/is.js +2 -0
  90. package/build/src/helpers/main.d.ts +2 -0
  91. package/build/src/helpers/main.js +2 -0
  92. package/build/src/helpers/string.d.ts +17 -0
  93. package/build/src/helpers/string.js +26 -0
  94. package/build/src/helpers/string_builder.d.ts +23 -0
  95. package/build/src/helpers/string_builder.js +86 -0
  96. package/build/src/helpers/types.d.ts +24 -0
  97. package/build/src/helpers/types.js +29 -0
  98. package/build/src/ignitor/ace.d.ts +8 -0
  99. package/build/src/ignitor/ace.js +31 -0
  100. package/build/src/ignitor/http.d.ts +10 -0
  101. package/build/src/ignitor/http.js +62 -0
  102. package/build/src/ignitor/main.d.ts +17 -0
  103. package/build/src/ignitor/main.js +45 -0
  104. package/build/src/ignitor/test.d.ts +8 -0
  105. package/build/src/ignitor/test.js +18 -0
  106. package/build/src/test_utils/http.d.ts +10 -0
  107. package/build/src/test_utils/http.js +42 -0
  108. package/build/src/test_utils/main.d.ts +19 -0
  109. package/build/src/test_utils/main.js +33 -0
  110. package/build/src/types.d.ts +63 -0
  111. package/build/src/types.js +1 -0
  112. package/build/stubs/index.d.ts +1 -0
  113. package/build/stubs/index.js +2 -0
  114. package/build/stubs/make/command/main.stub +19 -0
  115. package/build/stubs/make/controller/api.stub +33 -0
  116. package/build/stubs/make/controller/main.stub +9 -0
  117. package/build/stubs/make/controller/resource.stub +43 -0
  118. package/build/stubs/make/event/main.stub +15 -0
  119. package/build/stubs/make/listener/for_event.stub +13 -0
  120. package/build/stubs/make/listener/main.stub +7 -0
  121. package/build/stubs/make/middleware/main.stub +22 -0
  122. package/build/stubs/make/provider/main.stub +35 -0
  123. package/build/types/ace.d.ts +5 -0
  124. package/build/types/ace.js +1 -0
  125. package/build/types/app.d.ts +1 -0
  126. package/build/types/app.js +1 -0
  127. package/build/types/bodyparser.d.ts +1 -0
  128. package/build/types/bodyparser.js +1 -0
  129. package/build/types/container.d.ts +1 -0
  130. package/build/types/container.js +1 -0
  131. package/build/types/encryption.d.ts +1 -0
  132. package/build/types/encryption.js +1 -0
  133. package/build/types/events.d.ts +1 -0
  134. package/build/types/events.js +1 -0
  135. package/build/types/hash.d.ts +1 -0
  136. package/build/types/hash.js +1 -0
  137. package/build/types/http.d.ts +1 -0
  138. package/build/types/http.js +1 -0
  139. package/build/types/logger.d.ts +1 -0
  140. package/build/types/logger.js +1 -0
  141. package/package.json +226 -245
  142. package/build/adonis-typings/ace.d.ts +0 -5
  143. package/build/adonis-typings/ace.js +0 -8
  144. package/build/adonis-typings/assets-manager.d.ts +0 -92
  145. package/build/adonis-typings/assets-manager.js +0 -8
  146. package/build/adonis-typings/container.d.ts +0 -14
  147. package/build/adonis-typings/container.js +0 -8
  148. package/build/adonis-typings/cors.d.ts +0 -15
  149. package/build/adonis-typings/cors.js +0 -8
  150. package/build/adonis-typings/exception-handler.d.ts +0 -31
  151. package/build/adonis-typings/exception-handler.js +0 -8
  152. package/build/adonis-typings/health-check.d.ts +0 -40
  153. package/build/adonis-typings/health-check.js +0 -8
  154. package/build/adonis-typings/index.d.ts +0 -17
  155. package/build/adonis-typings/index.js +0 -25
  156. package/build/adonis-typings/static.d.ts +0 -15
  157. package/build/adonis-typings/static.js +0 -8
  158. package/build/adonis-typings/test-utils.d.ts +0 -24
  159. package/build/adonis-typings/test-utils.js +0 -8
  160. package/build/adonis-typings/tests.d.ts +0 -13
  161. package/build/adonis-typings/tests.js +0 -11
  162. package/build/commands/DumpRc.d.ts +0 -13
  163. package/build/commands/DumpRc.js +0 -33
  164. package/build/commands/GenerateKey.js +0 -25
  165. package/build/commands/ListRoutes/Renderers/Base.d.ts +0 -31
  166. package/build/commands/ListRoutes/Renderers/Base.js +0 -70
  167. package/build/commands/ListRoutes/Renderers/PrettyRenderer.d.ts +0 -51
  168. package/build/commands/ListRoutes/Renderers/PrettyRenderer.js +0 -135
  169. package/build/commands/ListRoutes/Renderers/TableRenderer.d.ts +0 -36
  170. package/build/commands/ListRoutes/Renderers/TableRenderer.js +0 -137
  171. package/build/commands/ListRoutes/index.d.ts +0 -75
  172. package/build/commands/ListRoutes/index.js +0 -166
  173. package/build/commands/index.d.ts +0 -2
  174. package/build/commands/index.js +0 -15
  175. package/build/config.d.ts +0 -2
  176. package/build/config.js +0 -15
  177. package/build/instructions.js +0 -81
  178. package/build/providers/AppProvider.d.ts +0 -68
  179. package/build/providers/AppProvider.js +0 -201
  180. package/build/services/base.d.ts +0 -3
  181. package/build/services/base.js +0 -23
  182. package/build/services/bodyparser.d.ts +0 -2
  183. package/build/services/bodyparser.js +0 -12
  184. package/build/services/drive.d.ts +0 -3
  185. package/build/services/drive.js +0 -12
  186. package/build/services/event.d.ts +0 -3
  187. package/build/services/event.js +0 -12
  188. package/build/services/healthChecks.d.ts +0 -3
  189. package/build/services/healthChecks.js +0 -12
  190. package/build/services/httpContext.d.ts +0 -3
  191. package/build/services/httpContext.js +0 -12
  192. package/build/services/route.d.ts +0 -3
  193. package/build/services/route.js +0 -12
  194. package/build/services/validator.d.ts +0 -3
  195. package/build/services/validator.js +0 -12
  196. package/build/src/AssetsManager/Drivers/Base.d.ts +0 -27
  197. package/build/src/AssetsManager/Drivers/Base.js +0 -66
  198. package/build/src/AssetsManager/Drivers/Encore.d.ts +0 -58
  199. package/build/src/AssetsManager/Drivers/Encore.js +0 -93
  200. package/build/src/AssetsManager/Drivers/Fake.d.ts +0 -38
  201. package/build/src/AssetsManager/Drivers/Fake.js +0 -61
  202. package/build/src/AssetsManager/Drivers/Vite.d.ts +0 -84
  203. package/build/src/AssetsManager/Drivers/Vite.js +0 -139
  204. package/build/src/AssetsManager/index.d.ts +0 -87
  205. package/build/src/AssetsManager/index.js +0 -184
  206. package/build/src/Bindings/Repl.d.ts +0 -8
  207. package/build/src/Bindings/Repl.js +0 -90
  208. package/build/src/Bindings/Tests.d.ts +0 -7
  209. package/build/src/Bindings/Tests.js +0 -66
  210. package/build/src/HealthCheck/Checkers/AppKey.d.ts +0 -6
  211. package/build/src/HealthCheck/Checkers/AppKey.js +0 -60
  212. package/build/src/HealthCheck/Checkers/Env.d.ts +0 -6
  213. package/build/src/HealthCheck/Checkers/Env.js +0 -42
  214. package/build/src/HealthCheck/index.d.ts +0 -48
  215. package/build/src/HealthCheck/index.js +0 -99
  216. package/build/src/Hooks/Cors/index.d.ts +0 -70
  217. package/build/src/Hooks/Cors/index.js +0 -314
  218. package/build/src/Hooks/Static/index.d.ts +0 -18
  219. package/build/src/Hooks/Static/index.js +0 -66
  220. package/build/src/HttpExceptionHandler/index.d.ts +0 -82
  221. package/build/src/HttpExceptionHandler/index.js +0 -213
  222. package/build/src/Ignitor/Ace/App/index.d.ts +0 -60
  223. package/build/src/Ignitor/Ace/App/index.js +0 -236
  224. package/build/src/Ignitor/Ace/Exceptions/index.d.ts +0 -4
  225. package/build/src/Ignitor/Ace/Exceptions/index.js +0 -19
  226. package/build/src/Ignitor/Ace/GenerateManifest/index.d.ts +0 -28
  227. package/build/src/Ignitor/Ace/GenerateManifest/index.js +0 -75
  228. package/build/src/Ignitor/Ace/index.d.ts +0 -11
  229. package/build/src/Ignitor/Ace/index.js +0 -36
  230. package/build/src/Ignitor/HttpServer/index.d.ts +0 -56
  231. package/build/src/Ignitor/HttpServer/index.js +0 -127
  232. package/build/src/Ignitor/Kernel/index.d.ts +0 -56
  233. package/build/src/Ignitor/Kernel/index.js +0 -123
  234. package/build/src/Ignitor/SignalsListener/index.d.ts +0 -23
  235. package/build/src/Ignitor/SignalsListener/index.js +0 -66
  236. package/build/src/Ignitor/index.d.ts +0 -32
  237. package/build/src/Ignitor/index.js +0 -58
  238. package/build/src/TestUtils/HttpServer/index.d.ts +0 -27
  239. package/build/src/TestUtils/HttpServer/index.js +0 -56
  240. package/build/src/TestUtils/index.d.ts +0 -24
  241. package/build/src/TestUtils/index.js +0 -43
  242. package/build/src/utils/index.d.ts +0 -18
  243. package/build/src/utils/index.js +0 -82
  244. package/build/standalone.d.ts +0 -9
  245. package/build/standalone.js +0 -52
  246. package/build/templates/config/app.txt +0 -303
  247. package/build/templates/config/bodyparser.txt +0 -211
  248. package/build/templates/config/cors.txt +0 -134
  249. package/build/templates/config/drive.txt +0 -149
  250. package/build/templates/config/hash.txt +0 -96
  251. package/build/templates/config/static.txt +0 -89
  252. package/build/templates/contracts/drive.txt +0 -13
  253. package/build/templates/contracts/env.txt +0 -24
  254. package/build/templates/contracts/events.txt +0 -31
  255. package/build/templates/contracts/hash.txt +0 -13
  256. package/build/templates/env.txt +0 -31
@@ -1,61 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.FakeDriver = void 0;
12
- /**
13
- * Fake driver stubs out the implementation of the Assets
14
- * manager with empty return data.
15
- *
16
- * The main use case is to make assets manager work during
17
- * testing without compiling the real assets
18
- */
19
- class FakeDriver {
20
- get version() {
21
- return '';
22
- }
23
- constructor(application) {
24
- this.application = application;
25
- this.name = 'fake';
26
- this.hasEntrypoints = true;
27
- this.publicPath = this.application.publicPath('assets');
28
- this.scriptAttributes = {};
29
- }
30
- /**
31
- * Returns the manifest contents as object
32
- */
33
- manifest() {
34
- return {};
35
- }
36
- /**
37
- * Returns path to a given asset file
38
- */
39
- assetPath(name) {
40
- return `__fake('${name}')`;
41
- }
42
- /**
43
- * Returns the entrypoints contents as object
44
- */
45
- entryPoints() {
46
- return {};
47
- }
48
- /**
49
- * Returns list for all the javascript files for a given entry point
50
- */
51
- entryPointJsFiles(_) {
52
- return [];
53
- }
54
- /**
55
- * Returns list for all the css files for a given entry point
56
- */
57
- entryPointCssFiles(_) {
58
- return [];
59
- }
60
- }
61
- exports.FakeDriver = FakeDriver;
@@ -1,84 +0,0 @@
1
- import { AssetsDriverContract } from '@ioc:Adonis/Core/AssetsManager';
2
- import { BaseDriver } from './Base';
3
- /**
4
- * Resolves entry points and assets path for Vite. Relies
5
- * on the "manifest.json" and "entrypoints.json" files.
6
- *
7
- **********************************************************************
8
- * The driver assumes following format for the manifest.json file
9
- **********************************************************************
10
- *
11
- * ```json
12
- * {
13
- * "assetName": {
14
- * "file": "path",
15
- * "src": "path"
16
- * },
17
- * ...
18
- * }
19
- * ```
20
- **********************************************************************
21
- * The driver assumes following format for the entrypoints.json file
22
- ***********************************************************************
23
- *
24
- * ```json
25
- * {
26
- * "url": "url"
27
- * "entrypoints": {
28
- * "entryPointName": {
29
- * "js": ["url", "url"],
30
- * "css": ["url", "url"],
31
- * }
32
- * }
33
- * }
34
- * ```
35
- *
36
- * Please read the documentation for understanding the format of the files.
37
- */
38
- export declare class ViteDriver extends BaseDriver implements AssetsDriverContract {
39
- name: string;
40
- /**
41
- * Vite driver has support for entrypoints
42
- */
43
- hasEntrypoints: boolean;
44
- /**
45
- * Attributes to apply to the script tag. Vite needs to serve
46
- * source over native ESM
47
- */
48
- scriptAttributes: Record<string, any>;
49
- /**
50
- * If we should use the manifest. We only use the manifest in production.
51
- */
52
- private shouldUseManifest;
53
- /**
54
- * Get the assets url from the entrypoints.json file
55
- */
56
- private getAssetUrl;
57
- /**
58
- * Returns path to a given asset file
59
- */
60
- assetPath(filename: string): string;
61
- /**
62
- * Returns the manifest contents as object
63
- *
64
- * Note that the manifest file is only available in production.
65
- * Vite doesn't generate any manifest file in development.
66
- */
67
- manifest(): any;
68
- /**
69
- * Returns list for all the javascript files for a given entry point
70
- */
71
- entryPointJsFiles(name: string): string[];
72
- /**
73
- * Returns list for all the css files for a given entry point
74
- */
75
- entryPointCssFiles(name: string): string[];
76
- /**
77
- * Returns the script needed for the HMR working with React
78
- */
79
- getReactHmrScript(): string;
80
- /**
81
- * Returns the script needed for the HMR working with Vite
82
- */
83
- getViteHmrScript(): string;
84
- }
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViteDriver = void 0;
4
- const path_1 = require("path");
5
- const Base_1 = require("./Base");
6
- /**
7
- * Resolves entry points and assets path for Vite. Relies
8
- * on the "manifest.json" and "entrypoints.json" files.
9
- *
10
- **********************************************************************
11
- * The driver assumes following format for the manifest.json file
12
- **********************************************************************
13
- *
14
- * ```json
15
- * {
16
- * "assetName": {
17
- * "file": "path",
18
- * "src": "path"
19
- * },
20
- * ...
21
- * }
22
- * ```
23
- **********************************************************************
24
- * The driver assumes following format for the entrypoints.json file
25
- ***********************************************************************
26
- *
27
- * ```json
28
- * {
29
- * "url": "url"
30
- * "entrypoints": {
31
- * "entryPointName": {
32
- * "js": ["url", "url"],
33
- * "css": ["url", "url"],
34
- * }
35
- * }
36
- * }
37
- * ```
38
- *
39
- * Please read the documentation for understanding the format of the files.
40
- */
41
- class ViteDriver extends Base_1.BaseDriver {
42
- constructor() {
43
- super(...arguments);
44
- this.name = 'vite';
45
- /**
46
- * Vite driver has support for entrypoints
47
- */
48
- this.hasEntrypoints = true;
49
- /**
50
- * Attributes to apply to the script tag. Vite needs to serve
51
- * source over native ESM
52
- */
53
- this.scriptAttributes = { type: 'module' };
54
- }
55
- /**
56
- * If we should use the manifest. We only use the manifest in production.
57
- */
58
- shouldUseManifest() {
59
- return this.application.inProduction;
60
- }
61
- /**
62
- * Get the assets url from the entrypoints.json file
63
- */
64
- getAssetUrl() {
65
- return this.readFileAsJSON((0, path_1.join)(this.publicPath, 'entrypoints.json')).url;
66
- }
67
- /**
68
- * Returns path to a given asset file
69
- */
70
- assetPath(filename) {
71
- if (!this.shouldUseManifest()) {
72
- return `${this.getAssetUrl()}/${filename}`;
73
- }
74
- const manifest = this.manifest();
75
- if (!manifest[filename]) {
76
- throw new Error(`Cannot find "${filename}" asset in the manifest file`);
77
- }
78
- return `${this.getAssetUrl()}/${manifest[filename].file}`;
79
- }
80
- /**
81
- * Returns the manifest contents as object
82
- *
83
- * Note that the manifest file is only available in production.
84
- * Vite doesn't generate any manifest file in development.
85
- */
86
- manifest() {
87
- if (!this.shouldUseManifest()) {
88
- throw new Error('Cannot use manifest when not in production');
89
- }
90
- return super.manifest();
91
- }
92
- /**
93
- * Returns list for all the javascript files for a given entry point
94
- */
95
- entryPointJsFiles(name) {
96
- const entrypoints = this.entryPoints();
97
- if (!entrypoints[name]) {
98
- throw new Error(`Cannot find assets for "${name}" entrypoint. Make sure to define it inside the "entryPoints" vite config`);
99
- }
100
- return entrypoints[name].js;
101
- }
102
- /**
103
- * Returns list for all the css files for a given entry point
104
- */
105
- entryPointCssFiles(name) {
106
- const entrypoints = this.entryPoints();
107
- if (!entrypoints[name]) {
108
- throw new Error(`Cannot find assets for "${name}" entrypoint. Make sure to define it inside the "entryPoints" vite config`);
109
- }
110
- return entrypoints[name].css;
111
- }
112
- /**
113
- * Returns the script needed for the HMR working with React
114
- */
115
- getReactHmrScript() {
116
- if (!this.application.inDev) {
117
- return '';
118
- }
119
- return `
120
- <script type="module">
121
- import RefreshRuntime from '${this.getAssetUrl()}/@react-refresh'
122
- RefreshRuntime.injectIntoGlobalHook(window)
123
- window.$RefreshReg$ = () => {}
124
- window.$RefreshSig$ = () => (type) => type
125
- window.__vite_plugin_react_preamble_installed__ = true
126
- </script>
127
- `;
128
- }
129
- /**
130
- * Returns the script needed for the HMR working with Vite
131
- */
132
- getViteHmrScript() {
133
- if (!this.application.inDev) {
134
- return '';
135
- }
136
- return `<script type="module" src="${this.getAssetUrl()}/@vite/client"></script>`;
137
- }
138
- }
139
- exports.ViteDriver = ViteDriver;
@@ -1,87 +0,0 @@
1
- import { ApplicationContract } from '@ioc:Adonis/Core/Application';
2
- import { ExtendCallback, AssetsManagerConfig, AssetsManagerContract } from '@ioc:Adonis/Core/AssetsManager';
3
- /**
4
- * Assets manager exposes the API to make link and HTML fragments
5
- * for static assets.
6
- *
7
- * The compilation is not done by the assets manager. It must be done
8
- * separately
9
- */
10
- export declare class AssetsManager implements AssetsManagerContract {
11
- private config;
12
- application: ApplicationContract;
13
- private drivers;
14
- /**
15
- * Attributes to apply to the script tag
16
- */
17
- get scriptAttributes(): Record<string, any>;
18
- /**
19
- * Configured driver
20
- */
21
- private driver;
22
- private booted;
23
- /**
24
- * Find if the configured driver supports entrypoints or not
25
- */
26
- get hasEntrypoints(): boolean;
27
- /**
28
- * Path to the public output directory. The property must be
29
- * mutable
30
- */
31
- get publicPath(): string;
32
- /**
33
- * Returns the current version of assets
34
- */
35
- get version(): string | undefined;
36
- /**
37
- * Returns the name of the driver currently in use
38
- */
39
- get name(): string;
40
- constructor(config: AssetsManagerConfig, application: ApplicationContract);
41
- /**
42
- * Boot the manager. Must be done lazily to allow `extend` method to takes
43
- * in effect.
44
- */
45
- private boot;
46
- /**
47
- * Ensure entrypoints are enabled, otherwise raise an exception. The
48
- * methods relying on the entrypoints file uses this method
49
- */
50
- private ensureHasEntryPoints;
51
- /**
52
- * Returns the manifest contents as an object
53
- */
54
- manifest(): any;
55
- /**
56
- * Returns path to a given asset entry
57
- */
58
- assetPath(filename: string): string;
59
- /**
60
- * Returns the entrypoints contents as an object
61
- */
62
- entryPoints(): any;
63
- /**
64
- * Returns list for all the javascript files for a given entry point.
65
- * Raises exceptions when [[hasEntrypoints]] is false
66
- */
67
- entryPointJsFiles(name: string): string[];
68
- /**
69
- * Returns list for all the css files for a given entry point.
70
- * Raises exceptions when [[hasEntrypoints]] is false
71
- */
72
- entryPointCssFiles(name: string): string[];
73
- /**
74
- * Returns an HTML fragment for script tags. Raises exceptions
75
- * when [[hasEntrypoints]] is false
76
- */
77
- entryPointScriptTags(name: string): string;
78
- /**
79
- * Returns an HTML fragment for stylesheet link tags. Raises exceptions
80
- * when [[hasEntrypoints]] is false
81
- */
82
- entryPointStyleTags(name: string): string;
83
- /**
84
- * Register a custom asset manager driver
85
- */
86
- extend(name: string, callback: ExtendCallback): this;
87
- }
@@ -1,184 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.AssetsManager = void 0;
15
- const utils_1 = require("@poppinss/utils");
16
- const stringify_attributes_1 = __importDefault(require("stringify-attributes"));
17
- const Fake_1 = require("./Drivers/Fake");
18
- const Encore_1 = require("./Drivers/Encore");
19
- const Vite_1 = require("./Drivers/Vite");
20
- /**
21
- * Assets manager exposes the API to make link and HTML fragments
22
- * for static assets.
23
- *
24
- * The compilation is not done by the assets manager. It must be done
25
- * separately
26
- */
27
- class AssetsManager {
28
- /**
29
- * Attributes to apply to the script tag
30
- */
31
- get scriptAttributes() {
32
- return this.driver.scriptAttributes;
33
- }
34
- /**
35
- * Find if the configured driver supports entrypoints or not
36
- */
37
- get hasEntrypoints() {
38
- this.boot();
39
- return this.driver.hasEntrypoints;
40
- }
41
- /**
42
- * Path to the public output directory. The property must be
43
- * mutable
44
- */
45
- get publicPath() {
46
- this.boot();
47
- return this.driver.publicPath;
48
- }
49
- /**
50
- * Returns the current version of assets
51
- */
52
- get version() {
53
- this.boot();
54
- return this.driver.version;
55
- }
56
- /**
57
- * Returns the name of the driver currently in use
58
- */
59
- get name() {
60
- this.boot();
61
- return this.driver.name;
62
- }
63
- constructor(config, application) {
64
- this.config = config;
65
- this.application = application;
66
- this.drivers = {
67
- vite: () => new Vite_1.ViteDriver(this.application),
68
- encore: () => new Encore_1.EncoreDriver(this.application),
69
- fake: () => new Fake_1.FakeDriver(this.application),
70
- };
71
- this.booted = false;
72
- }
73
- /**
74
- * Boot the manager. Must be done lazily to allow `extend` method to takes
75
- * in effect.
76
- */
77
- boot() {
78
- if (this.booted) {
79
- return false;
80
- }
81
- this.booted = true;
82
- const driver = this.config.driver || 'encore';
83
- /**
84
- * Ensure driver name is recognized
85
- */
86
- if (!this.drivers[driver]) {
87
- throw new utils_1.Exception(`Invalid asset driver "${driver}". Make sure to register the driver using the "AssetsManager.extend" method`);
88
- }
89
- /**
90
- * Configure the driver
91
- */
92
- this.driver = this.drivers[driver](this, this.config);
93
- /**
94
- * Configure the public path
95
- */
96
- if (this.config.publicPath) {
97
- this.driver.publicPath = this.config.publicPath;
98
- }
99
- }
100
- /**
101
- * Ensure entrypoints are enabled, otherwise raise an exception. The
102
- * methods relying on the entrypoints file uses this method
103
- */
104
- ensureHasEntryPoints() {
105
- if (!this.hasEntrypoints) {
106
- throw new Error(`Cannot reference entrypoints. The "${this.driver.name}" driver does not support entrypoints`);
107
- }
108
- }
109
- /**
110
- * Returns the manifest contents as an object
111
- */
112
- manifest() {
113
- this.boot();
114
- return this.driver.manifest();
115
- }
116
- /**
117
- * Returns path to a given asset entry
118
- */
119
- assetPath(filename) {
120
- this.boot();
121
- return this.driver.assetPath(filename);
122
- }
123
- /**
124
- * Returns the entrypoints contents as an object
125
- */
126
- entryPoints() {
127
- this.boot();
128
- this.ensureHasEntryPoints();
129
- return this.driver.entryPoints();
130
- }
131
- /**
132
- * Returns list for all the javascript files for a given entry point.
133
- * Raises exceptions when [[hasEntrypoints]] is false
134
- */
135
- entryPointJsFiles(name) {
136
- this.boot();
137
- this.ensureHasEntryPoints();
138
- return this.driver.entryPointJsFiles(name);
139
- }
140
- /**
141
- * Returns list for all the css files for a given entry point.
142
- * Raises exceptions when [[hasEntrypoints]] is false
143
- */
144
- entryPointCssFiles(name) {
145
- this.boot();
146
- this.ensureHasEntryPoints();
147
- return this.driver.entryPointCssFiles(name);
148
- }
149
- /**
150
- * Returns an HTML fragment for script tags. Raises exceptions
151
- * when [[hasEntrypoints]] is false
152
- */
153
- entryPointScriptTags(name) {
154
- const scripts = this.entryPointJsFiles(name);
155
- const configDefinedAttributes = this.config.script?.attributes || {};
156
- const driverDefinedAttributes = this.driver.scriptAttributes || {};
157
- const mergedAttributes = {
158
- ...configDefinedAttributes,
159
- ...driverDefinedAttributes,
160
- };
161
- return scripts
162
- .map((url) => `<script src="${url}"${(0, stringify_attributes_1.default)(mergedAttributes)}></script>`)
163
- .join('\n');
164
- }
165
- /**
166
- * Returns an HTML fragment for stylesheet link tags. Raises exceptions
167
- * when [[hasEntrypoints]] is false
168
- */
169
- entryPointStyleTags(name) {
170
- const links = this.entryPointCssFiles(name);
171
- const styleAttributes = this.config.style?.attributes || {};
172
- return links
173
- .map((url) => `<link rel="stylesheet" href="${url}"${(0, stringify_attributes_1.default)(styleAttributes)} />`)
174
- .join('\n');
175
- }
176
- /**
177
- * Register a custom asset manager driver
178
- */
179
- extend(name, callback) {
180
- this.drivers[name] = callback;
181
- return this;
182
- }
183
- }
184
- exports.AssetsManager = AssetsManager;
@@ -1,8 +0,0 @@
1
- /// <reference types="@adonisjs/repl" />
2
- import { ReplContract } from '@ioc:Adonis/Addons/Repl';
3
- import { ApplicationContract } from '@ioc:Adonis/Core/Application';
4
- /**
5
- * Define repl bindings. The method must be invoked when application environment
6
- * is set to repl.
7
- */
8
- export declare function defineReplBindings(application: ApplicationContract, Repl: ReplContract): void;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/core
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.defineReplBindings = void 0;
12
- /**
13
- * Shortcuts to load containers bindings
14
- */
15
- function setupReplState(repl, key, value) {
16
- repl.server.context[key] = value;
17
- repl.notify(`Loaded ${key} module. You can access it using the "${repl.colors.underline(key)}" variable`);
18
- }
19
- /**
20
- * Define repl bindings. The method must be invoked when application environment
21
- * is set to repl.
22
- */
23
- function defineReplBindings(application, Repl) {
24
- /**
25
- * Load the encryption module
26
- */
27
- Repl.addMethod('loadEncryption', (repl) => {
28
- setupReplState(repl, 'Encryption', application.container.resolveBinding('Adonis/Core/Encryption'));
29
- }, {
30
- description: 'Load encryption provider and save reference to the "Encryption" variable',
31
- });
32
- /**
33
- * Load the hash module
34
- */
35
- Repl.addMethod('loadHash', (repl) => {
36
- setupReplState(repl, 'Hash', application.container.resolveBinding('Adonis/Core/Hash'));
37
- }, {
38
- description: 'Load hash provider and save reference to the "Hash" variable',
39
- });
40
- /**
41
- * Load the Env module
42
- */
43
- Repl.addMethod('loadEnv', (repl) => {
44
- setupReplState(repl, 'Env', application.container.resolveBinding('Adonis/Core/Env'));
45
- }, {
46
- description: 'Load env provider and save reference to the "Env" variable',
47
- });
48
- /**
49
- * Load the HTTP router
50
- */
51
- Repl.addMethod('loadRouter', (repl) => {
52
- setupReplState(repl, 'Route', application.container.resolveBinding('Adonis/Core/Route'));
53
- }, {
54
- description: 'Load router and save reference to the "Route" variable',
55
- });
56
- /**
57
- * Load config
58
- */
59
- Repl.addMethod('loadConfig', (repl) => {
60
- setupReplState(repl, 'Config', application.container.resolveBinding('Adonis/Core/Config'));
61
- }, {
62
- description: 'Load config and save reference to the "Config" variable',
63
- });
64
- /**
65
- * Load validator
66
- */
67
- Repl.addMethod('loadValidator', (repl) => {
68
- setupReplState(repl, 'Validator', application.container.resolveBinding('Adonis/Core/Validator'));
69
- }, {
70
- description: 'Load validator and save reference to the "Validator" variable',
71
- });
72
- /**
73
- * Create context for a dummy route
74
- */
75
- Repl.addMethod('getContext', (_, route, params) => {
76
- return application.container.use('Adonis/Core/HttpContext').create(route, params || {});
77
- }, {
78
- description: 'Get HTTP context for a given route',
79
- usage: `${Repl.colors.yellow('getContext')}${Repl.colors.gray('(route, params?)')}`,
80
- });
81
- /**
82
- * Load the Helpers module
83
- */
84
- Repl.addMethod('loadHelpers', (repl) => {
85
- setupReplState(repl, 'Helpers', application.container.resolveBinding('Adonis/Core/Helpers'));
86
- }, {
87
- description: 'Load helpers provider and save reference to the "Helpers" variable',
88
- });
89
- }
90
- exports.defineReplBindings = defineReplBindings;
@@ -1,7 +0,0 @@
1
- /// <reference types="@adonisjs/http-server/build/adonis-typings" />
2
- import { ContainerBindings } from '@ioc:Adonis/Core/Application';
3
- import { CookieClientContract } from '@ioc:Adonis/Core/CookieClient';
4
- /**
5
- * Define test bindings
6
- */
7
- export declare function defineTestsBindings(ApiRequest: ContainerBindings['Japa/Preset/ApiRequest'], ApiClient: ContainerBindings['Japa/Preset/ApiClient'], CookieClient: CookieClientContract): void;