@danielx/civet 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -1,18 +1,37 @@
1
1
  declare module "@danielx/civet" {
2
- export type CivetAST = unknown;
2
+ export type CivetAST = unknown
3
3
  export type CompileOptions = {
4
4
  filename?: string
5
5
  js?: boolean
6
+ sourceMap?: boolean
6
7
  }
7
8
 
8
- export function compile(source: string, options?: CompileOptions): string
9
+ export type SourceMapping = [number] | [number, number, number, number]
10
+
11
+ export interface SourceMap {
12
+ updateSourceMap?(outputStr: string, inputPos: number): void
13
+ json(srcFileName: string, outFileName: string): unknown
14
+ data: {
15
+ lines: SourceMapping[][]
16
+ }
17
+ }
18
+
19
+ export function compile<T extends CompileOptions>(source: string, options?: T): T extends { sourceMap: true } ? {
20
+ code: string,
21
+ sourceMap: SourceMap,
22
+ } : string
9
23
  export function parse(source: string): CivetAST
10
24
  export function generate(ast: CivetAST, options?: CompileOptions): string
11
25
 
12
26
  const Civet: {
13
- compile: typeof compile;
14
- parse: typeof parse;
15
- generate: typeof generate;
27
+ compile: typeof compile
28
+ parse: typeof parse
29
+ generate: typeof generate
30
+ util: {
31
+ locationTable(input: string): number[]
32
+ lookupLineColumn(table: number[], pos: number): [number, number]
33
+ SourceMap(input: string): SourceMap
34
+ }
16
35
  }
17
36
 
18
37
  export default Civet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/types.d.ts",
@@ -13,6 +13,9 @@
13
13
  "register.js",
14
14
  "register.mjs"
15
15
  ],
16
+ "engines": {
17
+ "node": "^18.6.0 || ^16.17.0"
18
+ },
16
19
  "scripts": {
17
20
  "prepublishOnly": "yarn build && yarn test",
18
21
  "build": "bash ./build/build.sh",