@danielx/civet 0.2.13 → 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/README.md +4 -3
- package/dist/browser.js +866 -369
- package/dist/browser.js.map +3 -3
- package/dist/civet +10 -8
- package/dist/cli.js.map +4 -4
- package/dist/main.js +866 -369
- package/dist/types.d.ts +25 -5
- package/esbuild-plugin.js +16 -15
- package/package.json +4 -1
- package/register.mjs +7 -6
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
declare module "@danielx/civet" {
|
|
2
|
-
export type CivetAST = unknown
|
|
2
|
+
export type CivetAST = unknown
|
|
3
3
|
export type CompileOptions = {
|
|
4
|
+
filename?: string
|
|
4
5
|
js?: boolean
|
|
6
|
+
sourceMap?: boolean
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
export
|
|
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
|
|
8
23
|
export function parse(source: string): CivetAST
|
|
9
24
|
export function generate(ast: CivetAST, options?: CompileOptions): string
|
|
10
25
|
|
|
11
26
|
const Civet: {
|
|
12
|
-
compile: typeof compile
|
|
13
|
-
parse: typeof parse
|
|
14
|
-
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
|
+
}
|
|
15
35
|
}
|
|
16
36
|
|
|
17
37
|
export default Civet;
|
package/esbuild-plugin.js
CHANGED
|
@@ -6,21 +6,22 @@ module.exports = {
|
|
|
6
6
|
name: 'civet',
|
|
7
7
|
setup(build) {
|
|
8
8
|
build.onLoad({
|
|
9
|
-
filter: /\.civet
|
|
10
|
-
},
|
|
9
|
+
filter: /\.civet/,
|
|
10
|
+
}, function(args) {
|
|
11
11
|
return readFile(args.path, 'utf8')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}
|
|
12
|
+
.then(function(source) {
|
|
13
|
+
const filename = path.relative(process.cwd(), args.path);
|
|
14
|
+
return {
|
|
15
|
+
contents: compile(source, { filename, js: true }),
|
|
16
|
+
};
|
|
17
|
+
})
|
|
18
|
+
.catch(function(e) {
|
|
19
|
+
return {
|
|
20
|
+
errors: [{
|
|
21
|
+
text: e.message,
|
|
22
|
+
}],
|
|
23
|
+
};
|
|
24
|
+
});
|
|
24
25
|
});
|
|
25
|
-
}
|
|
26
|
+
},
|
|
26
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
|
-
"version": "0.2.
|
|
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",
|
package/register.mjs
CHANGED
|
@@ -7,23 +7,24 @@ const baseURL = pathToFileURL(process.cwd() + '/').href;
|
|
|
7
7
|
|
|
8
8
|
const extensionsRegex = /\.civet$/;
|
|
9
9
|
|
|
10
|
-
export async function resolve(specifier, context,
|
|
10
|
+
export async function resolve(specifier, context, next) {
|
|
11
11
|
const { parentURL = baseURL } = context;
|
|
12
12
|
|
|
13
13
|
if (extensionsRegex.test(specifier)) {
|
|
14
14
|
return {
|
|
15
|
-
|
|
15
|
+
shortCircuit: true,
|
|
16
|
+
format: "module",
|
|
16
17
|
url: new URL(specifier, parentURL).href,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// Let Node.js handle all other specifiers.
|
|
21
|
-
return
|
|
22
|
+
return next(specifier, context);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export async function load(url, context,
|
|
25
|
+
export async function load(url, context, next) {
|
|
25
26
|
if (extensionsRegex.test(url)) {
|
|
26
|
-
const { source: rawSource } = await
|
|
27
|
+
const { source: rawSource } = await next(url, { format: "module" });
|
|
27
28
|
|
|
28
29
|
return {
|
|
29
30
|
format: "module",
|
|
@@ -32,7 +33,7 @@ export async function load(url, context, defaultLoad) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
// Let Node.js handle all other URLs.
|
|
35
|
-
return
|
|
36
|
+
return next(url, context);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
// Also transform CommonJS files.
|