@adonisjs/repl 3.1.11 → 4.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 (59) hide show
  1. package/LICENSE.md +9 -9
  2. package/README.md +21 -201
  3. package/build/commands/adonis_repl.d.ts +9 -0
  4. package/build/commands/adonis_repl.d.ts.map +1 -0
  5. package/build/commands/adonis_repl.js +17 -0
  6. package/build/commands/commands.json +1 -0
  7. package/build/commands/main.js +36 -0
  8. package/build/index.d.ts +3 -0
  9. package/build/index.d.ts.map +1 -0
  10. package/build/index.js +2 -0
  11. package/build/providers/repl_provider.d.ts +8 -0
  12. package/build/providers/repl_provider.d.ts.map +1 -0
  13. package/build/providers/repl_provider.js +40 -0
  14. package/build/src/adonis_bindings.d.ts +4 -0
  15. package/build/src/adonis_bindings.d.ts.map +1 -0
  16. package/build/src/adonis_bindings.js +26 -0
  17. package/build/src/colorizer.d.ts +5 -0
  18. package/build/src/colorizer.d.ts.map +1 -0
  19. package/build/src/colorizer.js +39 -0
  20. package/build/src/repl.d.ts +17 -0
  21. package/build/src/repl.d.ts.map +1 -0
  22. package/build/src/repl.js +214 -0
  23. package/build/src/types/extended.d.ts +7 -0
  24. package/build/src/types/extended.d.ts.map +1 -0
  25. package/build/src/types/extended.js +1 -0
  26. package/build/src/types/main.d.ts +11 -0
  27. package/build/src/types/main.d.ts.map +1 -0
  28. package/build/src/types/main.js +1 -0
  29. package/build/src/utils.d.ts +2 -0
  30. package/build/src/utils.d.ts.map +1 -0
  31. package/build/src/utils.js +11 -0
  32. package/commands/adonis_repl.ts +38 -0
  33. package/{build/adonis-typings/repl.js → index.ts} +5 -1
  34. package/package.json +107 -129
  35. package/providers/repl_provider.ts +61 -0
  36. package/src/adonis_bindings.ts +63 -0
  37. package/src/colorizer.ts +62 -0
  38. package/src/repl.ts +423 -0
  39. package/{build/adonis-typings/container.js → src/types/extended.ts} +9 -1
  40. package/src/types/main.ts +33 -0
  41. package/src/utils.ts +14 -0
  42. package/build/adonis-typings/container.d.ts +0 -6
  43. package/build/adonis-typings/index.d.ts +0 -2
  44. package/build/adonis-typings/index.js +0 -10
  45. package/build/adonis-typings/repl.d.ts +0 -46
  46. package/build/commands/AdonisRepl.d.ts +0 -11
  47. package/build/commands/AdonisRepl.js +0 -33
  48. package/build/commands/index.d.ts +0 -2
  49. package/build/commands/index.js +0 -11
  50. package/build/providers/ReplProvider.d.ts +0 -7
  51. package/build/providers/ReplProvider.js +0 -26
  52. package/build/src/Compiler/index.d.ts +0 -29
  53. package/build/src/Compiler/index.js +0 -68
  54. package/build/src/ImportsParser/index.d.ts +0 -51
  55. package/build/src/ImportsParser/index.js +0 -137
  56. package/build/src/Repl/index.d.ts +0 -91
  57. package/build/src/Repl/index.js +0 -358
  58. package/build/standalone.d.ts +0 -3
  59. package/build/standalone.js +0 -17
package/LICENSE.md CHANGED
@@ -1,9 +1,9 @@
1
- # The MIT License
2
-
3
- Copyright 2022 Harminder Virk, contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # The MIT License
2
+
3
+ Copyright 2022 Harminder Virk, contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,216 +1,36 @@
1
- <div align="center">
2
- <h1> AdonisJS REPL </h1>
3
- <p>A slick <strong>framework agnostic REPL for Node.js</strong> with first class support for <br /> <code>top level await</code>, <code>typescript compilation</code>, <code>accurate stack traces</code> and a lot more.</p>
4
- </div>
1
+ # @adonisjs/repl
5
2
 
6
3
  <br />
7
4
 
8
- <div align="center">
5
+ [![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] [![snyk-image]][snyk-url]
9
6
 
10
- [![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] [![synk-image]][synk-url]
7
+ ## Introduction
8
+ REPL for AdonisJS applications. Syntax highlighting, bracket matching, ESM and TypeScript support out of the box.
11
9
 
12
- </div>
10
+ ## Official Documentation
11
+ The documentation is available on the [AdonisJS website](https://docs.adonisjs.com/guides/repl)
13
12
 
14
- <div align="center">
15
- <h3>
16
- <a href="#installation">
17
- Usage
18
- </a>
19
- <span> | </span>
20
- <a href="CONTRIBUTING.md">
21
- Contributing
22
- </a>
23
- <span> | </span>
24
- <a href="https://preview.adonisjs.com">
25
- Checkout AdonisJS
26
- </a>
27
- </h3>
28
- </div>
13
+ ## Contributing
14
+ One of the primary goals of AdonisJS is to have a vibrant community of users and contributors who believes in the principles of the framework.
29
15
 
30
- <div align="center">
31
- <sub>Built with ❤︎ by <a href="https://github.com/thetutlage">Harminder Virk</a>
32
- </div>
16
+ We encourage you to read the [contribution guide](https://github.com/adonisjs/.github/blob/main/docs/CONTRIBUTING.md) before contributing to the framework.
33
17
 
34
- <br />
35
-
36
- ![](./assets/imports_and_await.png)
37
-
38
- <hr />
39
-
40
- AdonisJS REPL is a standalone and framework agnostic package to create custom Node.js REPL with first class support for:
41
-
42
- <p>
43
- 👉 <strong>Execute typescript code with in-memory compilation.</strong> <br />
44
- 👉 <strong> Support for top level await keyword. </strong><br />
45
- 👉 <strong> Ability to define custom method with a help description. </strong><br />
46
- </p>
47
-
48
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
49
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
50
- ## Table of contents
51
-
52
- - [Table of contents](#table-of-contents)
53
- - [Installation](#installation)
54
- - [Usage](#usage)
55
- - [Typescript support](#typescript-support)
56
- - [History file](#history-file)
57
- - [Accurate Stack Trace](#accurate-stack-trace)
58
- - [The `.ls` command](#the-ls-command)
59
- - [Adding custom properties](#adding-custom-properties)
60
- - [Global methods](#global-methods)
61
-
62
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
63
-
64
- ## Installation
65
-
66
- Install the package from the npm registry as follows:
67
-
68
- ```sh
69
- npm i @adonisjs/repl
70
-
71
- # Yarn
72
- yarn add @adonisjs/repl
73
- ```
74
-
75
- ## Usage
76
-
77
- Import the `Repl` class from the standalone module.
78
-
79
- ```ts
80
- import { Repl } from '@adonisjs/repl/build/standalone'
81
- const repl = new Repl()
82
-
83
- repl.start()
84
- ```
85
-
86
- ### Typescript support
87
-
88
- You will have to make use of [@adonisjs/require-ts](https://npm.im/@adonisjs/require-ts) in order for the REPL to compile and run the typescript code. For example:
89
-
90
- ```ts
91
- import { loadCompiler } from '@adonisjs/require-ts'
92
- import { Repl } from '@adonisjs/repl/build/standalone'
93
-
94
- const compilerOptions = {
95
- target: 'es2019',
96
- module: 'commonjs',
97
- allowSyntheticDefaultImports: true,
98
- esModuleInterop: true,
99
- }
100
-
101
- const repl = new Repl(loadCompiler(compilerOptions))
102
- ```
103
-
104
- If you are using `@adonisjs/require-ts` as a require hook, then there is no need to instantiate another instance of the compiler as you can reference the compiler instance from the global object.
105
-
106
- ```ts
107
- const compiler = global[Symbol.for('REQUIRE_TS_COMPILER')]
108
- const repl = new Repl(compiler)
109
- ```
110
-
111
- And now run the file containing the above code as follows:
112
-
113
- ```ts
114
- node -r @adonisjs/require-ts/build/register repl.ts
115
- ```
116
-
117
- ![](./assets/typescript.png)
118
-
119
- ### History file
120
-
121
- AdonisJS REPL allows you store the commands history inside a file so that the subsequent sessions can reference the commands executed in an earlier session.
18
+ ## Code of Conduct
19
+ In order to ensure that the AdonisJS community is welcoming to all, please review and abide by the [Code of Conduct](https://github.com/adonisjs/.github/blob/main/docs/CODE_OF_CONDUCT.md).
122
20
 
123
- You need to just pass the path to the history file and rest is taken care for you.
21
+ ## License
22
+ AdonisJS Repl is open-sourced software licensed under the [MIT license](LICENSE.md).
124
23
 
125
- ```ts
126
- import { join } from 'path'
127
- import { homedir } from 'os'
128
- import { Repl } from '@adonisjs/repl/build/standalone'
129
-
130
- const repl = new Repl(compiler, join(homedir(), '.adonis_repl_history'))
131
-
132
- repl.start()
133
- ```
134
-
135
- ![](./assets/history.gif)
136
-
137
- ## Accurate Stack Trace
138
-
139
- The stack trace for the Typescript files points back to the correct file, line and the column number.
140
-
141
- ![](./assets/stack-trace.png)
142
-
143
- ## The `.ls` command
144
-
145
- The `.ls` command prints the REPL session context. The output is divided to two sections.
146
-
147
- ![](./assets/ls-command.png)
148
-
149
- - **Global Methods** are the methods in the repl context object, but has some description associated with them.
150
- - **Context properties**: are the properties/methods in the context object. Only the first level of properties are printed on the console (to avoid noisy output).
151
-
152
- ## Adding custom properties
153
-
154
- If you are aware about the [Node.js repl context](https://nodejs.org/dist/latest-v14.x/docs/api/repl.html#repl_global_and_local_scope), then you would know that you can add properties to the context as follows:
155
-
156
- ```ts
157
- // NODE.JS EXAMPLE
158
- const { start } = require('repl')
159
-
160
- const server = start({})
161
- server.context.foo = 'bar'
162
- ```
163
-
164
- Similarly, you can add properties to the AdonisJS repl `context` by referencing the underlying `server` property.
165
-
166
- ```ts
167
- import { Repl } from '@adonisjs/repl/build/standalone'
168
-
169
- const repl = new Repl().start()
170
- repl.server.context.foo = 'bar'
171
- ```
172
-
173
- ### Global methods
174
-
175
- In addition to adding properties to the `context` directly. You can also define custom methods with a description and its usage text. For example:
176
-
177
- ```ts
178
- import { Repl } from '@adonisjs/repl/build/standalone'
179
- const repl = new Repl()
180
-
181
- repl.addMethod(
182
- 'getUsers',
183
- () => {
184
- return [
185
- { id: 1, name: 'virk' },
186
- { id: 2, name: 'romain' },
187
- ]
188
- },
189
- {
190
- description: 'Returns a list of users',
191
- }
192
- )
193
-
194
- repl.start()
195
- ```
196
-
197
- There is no technical advantage for using `addMethod` over adding properties to the `context` directly. It's just that `addMethod` properties are given special treatment during the [.ls command](#ls-command).
198
-
199
- Checkout the following example
200
-
201
- ![](./assets/context-behavior.png)
202
-
203
- [gh-workflow-image]: https://img.shields.io/github/workflow/status/adonisjs/repl/test?style=for-the-badge
24
+ [gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/repl/test.yml?style=for-the-badge
204
25
  [gh-workflow-url]: https://github.com/adonisjs/repl/actions/workflows/test.yml "Github action"
205
26
 
206
- [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
207
- [typescript-url]: "typescript"
27
+ [npm-image]: https://img.shields.io/npm/v/@adonisjs/repl/latest.svg?style=for-the-badge&logo=npm
28
+ [npm-url]: https://www.npmjs.com/package/@adonisjs/repl/v/latest "npm"
208
29
 
209
- [npm-image]: https://img.shields.io/npm/v/@adonisjs/repl.svg?style=for-the-badge&logo=npm
210
- [npm-url]: https://npmjs.org/package/@adonisjs/repl 'npm'
30
+ [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
211
31
 
212
- [license-image]: https://img.shields.io/npm/l/@adonisjs/repl?color=blueviolet&style=for-the-badge
213
- [license-url]: LICENSE.md 'license'
32
+ [license-url]: LICENSE.md
33
+ [license-image]: https://img.shields.io/github/license/adonisjs/repl?style=for-the-badge
214
34
 
215
- [synk-image]: https://img.shields.io/snyk/vulnerabilities/github/adonisjs/repl?label=Synk%20Vulnerabilities&style=for-the-badge
216
- [synk-url]: https://snyk.io/test/github/adonisjs/repl?targetFile=package.json "synk"
35
+ [snyk-image]: https://img.shields.io/snyk/vulnerabilities/github/adonisjs/repl?label=Snyk%20Vulnerabilities&style=for-the-badge
36
+ [snyk-url]: https://snyk.io/test/github/adonisjs/repl?targetFile=package.json "snyk"
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ import { CommandOptions } from '@adonisjs/core/types/ace';
3
+ export default class ReplCommand extends BaseCommand {
4
+ static commandName: string;
5
+ static description: string;
6
+ static options: CommandOptions;
7
+ run(): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=adonis_repl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adonis_repl.d.ts","sourceRoot":"","sources":["../../commands/adonis_repl.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,MAAM,CAAC,WAAW,SAAS;IAC3B,MAAM,CAAC,WAAW,SAA6B;IAE/C,MAAM,CAAC,OAAO,EAAE,cAAc,CAG7B;IAEK,GAAG;CAgBV"}
@@ -0,0 +1,17 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ export default class ReplCommand extends BaseCommand {
3
+ static commandName = 'repl';
4
+ static description = 'Start a new REPL session';
5
+ static options = {
6
+ startApp: true,
7
+ staysAlive: true,
8
+ };
9
+ async run() {
10
+ this.app.container.resolving('router', (router) => router.commit());
11
+ const repl = await this.app.container.make('repl');
12
+ repl.start();
13
+ repl.server.on('exit', async () => {
14
+ await this.app.terminate();
15
+ });
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ {"commands":[{"commandName":"repl","description":"Start a new REPL session","help":"","namespace":null,"aliases":[],"flags":[],"args":[],"options":{"startApp":true,"staysAlive":true},"filePath":"adonis_repl.js"}],"version":1}
@@ -0,0 +1,36 @@
1
+ import { readFile } from 'node:fs/promises'
2
+
3
+ /**
4
+ * In-memory cache of commands after they have been loaded
5
+ */
6
+ let commandsMetaData
7
+
8
+ /**
9
+ * Reads the commands from the "./commands.json" file. Since, the commands.json
10
+ * file is generated automatically, we do not have to validate its contents
11
+ */
12
+ export async function getMetaData() {
13
+ if (commandsMetaData) {
14
+ return commandsMetaData
15
+ }
16
+
17
+ const commandsIndex = await readFile(new URL('./commands.json', import.meta.url), 'utf-8')
18
+ commandsMetaData = JSON.parse(commandsIndex).commands
19
+
20
+ return commandsMetaData
21
+ }
22
+
23
+ /**
24
+ * Imports the command by lookingup its path from the commands
25
+ * metadata
26
+ */
27
+ export async function getCommand(metaData) {
28
+ const commands = await getMetaData()
29
+ const command = commands.find(({ commandName }) => metaData.commandName === commandName)
30
+ if (!command) {
31
+ return null
32
+ }
33
+
34
+ const { default: commandConstructor } = await import(new URL(command.filePath, import.meta.url).href)
35
+ return commandConstructor
36
+ }
@@ -0,0 +1,3 @@
1
+ import './src/types/extended.js';
2
+ export { Repl } from './src/repl.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AASA,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import './src/types/extended.js';
2
+ export { Repl } from './src/repl.js';
@@ -0,0 +1,8 @@
1
+ import { ApplicationService } from '@adonisjs/core/types';
2
+ export default class ReplProvider {
3
+ #private;
4
+ protected app: ApplicationService;
5
+ constructor(app: ApplicationService);
6
+ register(): void;
7
+ }
8
+ //# sourceMappingURL=repl_provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repl_provider.d.ts","sourceRoot":"","sources":["../../providers/repl_provider.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAKzD,MAAM,CAAC,OAAO,OAAO,YAAY;;IACnB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAwB7C,QAAQ;CAmBT"}
@@ -0,0 +1,40 @@
1
+ import { join } from 'node:path';
2
+ import { homedir } from 'node:os';
3
+ import { isModuleInstalled } from '../src/utils.js';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { defineReplBindings } from '../src/adonis_bindings.js';
6
+ export default class ReplProvider {
7
+ app;
8
+ constructor(app) {
9
+ this.app = app;
10
+ }
11
+ async #createCompiler() {
12
+ const { create } = await import('ts-node');
13
+ const tsConfigPath = new URL('./tsconfig.json', this.app.appRoot);
14
+ const tsNode = create({
15
+ project: fileURLToPath(tsConfigPath),
16
+ compilerOptions: { module: 'ESNext' },
17
+ });
18
+ return {
19
+ supportsTypescript: true,
20
+ compile(code, fileName) {
21
+ return tsNode.compile(code, fileName);
22
+ },
23
+ };
24
+ }
25
+ register() {
26
+ this.app.container.singleton('repl', async () => {
27
+ const { Repl } = await import('../src/repl.js');
28
+ let compiler;
29
+ if (isModuleInstalled('ts-node')) {
30
+ compiler = await this.#createCompiler();
31
+ }
32
+ const repl = new Repl({
33
+ compiler,
34
+ historyFilePath: join(homedir(), '.adonis_repl_history'),
35
+ });
36
+ defineReplBindings(this.app, repl);
37
+ return repl;
38
+ });
39
+ }
40
+ }
@@ -0,0 +1,4 @@
1
+ import { ApplicationService } from '@adonisjs/core/types';
2
+ import { Repl } from './repl.js';
3
+ export declare function defineReplBindings(application: ApplicationService, replService: Repl): void;
4
+ //# sourceMappingURL=adonis_bindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adonis_bindings.d.ts","sourceRoot":"","sources":["../../src/adonis_bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAShC,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,IAAI,QAoDpF"}
@@ -0,0 +1,26 @@
1
+ function setupReplState(repl, key, value) {
2
+ repl.server.context[key] = value;
3
+ repl.notify(`Loaded ${key} module. You can access it using the "${repl.colors.underline(key)}" variable`);
4
+ }
5
+ export function defineReplBindings(application, replService) {
6
+ replService.addMethod('loadEncryption', async (repl) => {
7
+ setupReplState(repl, 'encryption', await application.container.make('encryption'));
8
+ }, {
9
+ description: 'Load encryption provider and save reference to the "encryption" variable',
10
+ });
11
+ replService.addMethod('loadHash', async (repl) => {
12
+ setupReplState(repl, 'hash', await application.container.make('hash'));
13
+ }, {
14
+ description: 'Load hash provider and save reference to the "hash" variable',
15
+ });
16
+ replService.addMethod('loadRouter', async (repl) => {
17
+ setupReplState(repl, 'router', await application.container.make('router'));
18
+ }, {
19
+ description: 'Load router and save reference to the "router" variable',
20
+ });
21
+ replService.addMethod('loadConfig', async (repl) => {
22
+ setupReplState(repl, 'config', await application.container.make('config'));
23
+ }, {
24
+ description: 'Load config and save reference to the "config" variable',
25
+ });
26
+ }
@@ -0,0 +1,5 @@
1
+ export declare function colorizer(): {
2
+ (s: string): string;
3
+ colorizeMatchingBracket(s: string): string;
4
+ };
5
+ //# sourceMappingURL=colorizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorizer.d.ts","sourceRoot":"","sources":["../../src/colorizer.ts"],"names":[],"mappings":"AAqDA,wBAAgB,SAAS;QAID,MAAM;+BACY,MAAM;EAG/C"}
@@ -0,0 +1,39 @@
1
+ import { emphasize } from 'emphasize';
2
+ import useColors from '@poppinss/colors';
3
+ const sheet = (colors) => ({
4
+ 'comment': (s) => colors.gray(s),
5
+ 'quote': (s) => colors.gray(s),
6
+ 'keyword': (s) => colors.cyan(s),
7
+ 'addition': (s) => colors.cyan(s),
8
+ 'number': (s) => colors.yellow(s),
9
+ 'string': (s) => colors.green(s),
10
+ 'meta meta-string': (s) => colors.cyan(s),
11
+ 'literal': (s) => colors.yellow(s),
12
+ 'doctag': (s) => colors.cyan(s),
13
+ 'regexp': (s) => colors.red(s),
14
+ 'attribute': (s) => colors.yellow(s),
15
+ 'attr': (s) => colors.yellow(s),
16
+ 'variable': (s) => colors.yellow(s),
17
+ 'template-variable': (s) => colors.yellow(s),
18
+ 'class title': (s) => colors.yellow(s),
19
+ 'function title': (s) => colors.yellow(s),
20
+ 'type': (s) => colors.yellow(s),
21
+ 'symbol': (s) => colors.green(s),
22
+ 'bullet': (s) => colors.magenta(s),
23
+ 'subst': (s) => colors.magenta(s),
24
+ 'meta': (s) => colors.magenta(s),
25
+ 'meta keyword': (s) => colors.magenta(s),
26
+ 'link': (s) => colors.magenta(s),
27
+ 'built_in': (s) => colors.cyan(s),
28
+ 'deletion': (s) => colors.red(s),
29
+ 'emphasis': (s) => colors.italic(s),
30
+ 'strong': (s) => colors.bold(s),
31
+ 'formula': (s) => colors.inverse(s),
32
+ });
33
+ export function colorizer() {
34
+ const colors = useColors.ansi();
35
+ const colorSheet = sheet(colors);
36
+ const highlight = (s) => emphasize.highlight('ts', s, colorSheet).value;
37
+ highlight.colorizeMatchingBracket = (s) => colors.bgBlue(s);
38
+ return highlight;
39
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { REPLServer } from 'node:repl';
3
+ import { Handler, ContextOptions, Compiler } from './types/main.js';
4
+ export declare class Repl {
5
+ #private;
6
+ colors: import("@poppinss/colors/types").Colors;
7
+ server?: REPLServer;
8
+ constructor(options?: {
9
+ compiler?: Compiler;
10
+ historyFilePath?: string;
11
+ });
12
+ notify(message: string): void;
13
+ start(): this;
14
+ ready(callback: (repl: Repl) => void): this;
15
+ addMethod(name: string, handler: Handler, options?: ContextOptions): this;
16
+ }
17
+ //# sourceMappingURL=repl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/repl.ts"],"names":[],"mappings":";AAUA,OAAO,EAAE,UAAU,EAAe,MAAM,WAAW,CAAA;AAKnD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AA4DnE,qBAAa,IAAI;;IAcf,MAAM,0CAAmB;IAMzB,MAAM,CAAC,EAAE,UAAU,CAAA;gBAyBP,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE;IAyNvE,MAAM,CAAC,OAAO,EAAE,MAAM;IAUtB,KAAK;IAkDL,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI;IAQ3C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI;CAiB1E"}