@danielx/civet 0.4.10 → 0.4.12

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/browser.js CHANGED
@@ -3205,8 +3205,8 @@ var Civet = (() => {
3205
3205
  return VariableDeclarationList$0(state);
3206
3206
  }
3207
3207
  }
3208
- var VariableDeclaration$0 = $S(BindingPattern, Initializer);
3209
- var VariableDeclaration$1 = $S(BindingIdentifier, $E(Initializer));
3208
+ var VariableDeclaration$0 = $S(BindingPattern, $E(TypeSuffix), Initializer);
3209
+ var VariableDeclaration$1 = $S(BindingIdentifier, $E(TypeSuffix), $E(Initializer));
3210
3210
  function VariableDeclaration(state) {
3211
3211
  if (state.tokenize) {
3212
3212
  return $TOKEN("VariableDeclaration", state, VariableDeclaration$0(state) || VariableDeclaration$1(state));
@@ -3676,9 +3676,7 @@ var Civet = (() => {
3676
3676
  }
3677
3677
  }
3678
3678
  var StatementDelimiter$0 = $S($Q(TrailingComment), Semicolon, $Q(TrailingComment));
3679
- var StatementDelimiter$1 = $TS($S($EXPECT($L1, fail, 'StatementDelimiter ""'), $Y(EOS)), function($skip, $loc, $0, $1, $2) {
3680
- return { $loc, token: ";" };
3681
- });
3679
+ var StatementDelimiter$1 = $Y(EOS);
3682
3680
  function StatementDelimiter(state) {
3683
3681
  if (state.tokenize) {
3684
3682
  return $TOKEN("StatementDelimiter", state, StatementDelimiter$0(state) || StatementDelimiter$1(state));
@@ -5180,7 +5178,7 @@ var Civet = (() => {
5180
5178
  }
5181
5179
  }
5182
5180
  var InsertBreak$0 = $TV($EXPECT($L1, fail, 'InsertBreak ""'), function($skip, $loc, $0, $1) {
5183
- return { $loc, token: "break;" };
5181
+ return { $loc, token: ";break;" };
5184
5182
  });
5185
5183
  function InsertBreak(state) {
5186
5184
  if (state.verbose)
@@ -1,8 +1,8 @@
1
- const { readFile } = require('fs/promises');
2
- const path = require('path');
1
+ const { readFile } = require('fs/promises')
2
+ const path = require('path')
3
3
 
4
4
  // NOTE: this references the built version of the module, not the source
5
- const { compile } = require("../dist/main.js");
5
+ const { compile } = require("../dist/main.js")
6
6
 
7
7
  module.exports = {
8
8
  name: 'civet',
@@ -11,19 +11,19 @@ module.exports = {
11
11
  filter: /\.civet$/
12
12
  }, async function(args) {
13
13
  try {
14
- const source = await readFile(args.path, 'utf8');
15
- const filename = path.relative(process.cwd(), args.path);
14
+ const source = await readFile(args.path, 'utf8')
15
+ const filename = path.relative(process.cwd(), args.path)
16
16
  return {
17
17
  contents: compile(source, { filename, js: true }),
18
- };
18
+ }
19
19
  }
20
20
  catch (e) {
21
21
  return {
22
22
  errors: [{
23
23
  text: e.message
24
24
  }],
25
- };
26
- };
27
- });
25
+ }
26
+ }
27
+ })
28
28
  },
29
- };
29
+ }
package/dist/esm.mjs CHANGED
@@ -9,82 +9,82 @@ node --loader ts-node/esm --loader @danielx/civet/esm
9
9
  ```
10
10
  */
11
11
 
12
- import { readFileSync } from "fs";
13
- import { createRequire } from "module";
14
- import { pathToFileURL, fileURLToPath } from "url";
12
+ import { readFileSync } from "fs"
13
+ import { createRequire } from "module"
14
+ import { pathToFileURL, fileURLToPath } from "url"
15
15
 
16
- import sourceMapSupport from "@cspotcode/source-map-support";
16
+ import sourceMapSupport from "@cspotcode/source-map-support"
17
17
 
18
18
  // NOTE: this references the built version of the module, not the source
19
- import Civet from "../dist/main.js";
20
- const { compile, util } = Civet;
21
- const { SourceMap } = util;
19
+ import Civet from "../dist/main.js"
20
+ const { compile, util } = Civet
21
+ const { SourceMap } = util
22
22
 
23
- const baseURL = pathToFileURL(process.cwd() + '/').href;
24
- const extensionsRegex = /\.civet$/;
23
+ const baseURL = pathToFileURL(process.cwd() + '/').href
24
+ const extensionsRegex = /\.civet$/
25
25
 
26
- let registered = false;
27
- const outputCache = new Map;
26
+ let registered = false
27
+ const outputCache = new Map
28
28
 
29
- const directorySeparator = '/';
30
- const backslashRegExp = /\\/g;
29
+ const directorySeparator = '/'
30
+ const backslashRegExp = /\\/g
31
31
  /**
32
32
  * Replace backslashes with forward slashes.
33
33
  */
34
34
  function normalizeSlashes(value) {
35
35
  return value.replace(backslashRegExp, directorySeparator);
36
- };
36
+ }
37
37
 
38
38
  const ensureRegister = function() {
39
- if( registered) {return};
39
+ if( registered) {return}
40
40
 
41
41
  const installation = {
42
42
  environment: 'node',
43
43
  retrieveFile(pathOrUrl) {
44
- let path = pathOrUrl;
44
+ let path = pathOrUrl
45
45
  // If it's a file URL, convert to local path
46
46
  // I could not find a way to handle non-URLs except to swallow an error
47
47
  if (path.startsWith('file://')) {
48
48
  try {
49
- path = fileURLToPath(path);
50
- } catch(e) {};
51
- };
52
- path = normalizeSlashes(path);
49
+ path = fileURLToPath(path)
50
+ } catch(e) {}
51
+ }
52
+ path = normalizeSlashes(path)
53
53
 
54
- return outputCache.get(path);
54
+ return outputCache.get(path)
55
55
  },
56
- };
56
+ }
57
57
 
58
- sourceMapSupport.install(installation);
58
+ sourceMapSupport.install(installation)
59
59
 
60
- registered = true;
61
- };
60
+ registered = true
61
+ }
62
62
 
63
63
  export function resolve(specifier, context, next) {
64
- const { parentURL = baseURL } = context;
64
+ const { parentURL = baseURL } = context
65
65
 
66
66
  if (extensionsRegex.test(specifier)) {
67
67
  return {
68
68
  shortCircuit: true,
69
69
  format: "civet",
70
70
  url: new URL(specifier, parentURL).href,
71
- };
72
- };
71
+ }
72
+ }
73
73
 
74
74
  // Let Node.js handle all other specifiers.
75
- return next(specifier, context);
76
- };
75
+ return next(specifier, context)
76
+ }
77
77
 
78
78
  export async function load(url, context, next) {
79
79
  if (context.format === "civet") {
80
- const path = fileURLToPath(url);
81
- const source = readFileSync(path, "utf8");
80
+ const path = fileURLToPath(url)
81
+ const source = readFileSync(path, "utf8")
82
82
  const {code: tsSource, sourceMap} = compile(source, {
83
83
  filename: path,
84
84
  sourceMap: true,
85
- });
85
+ })
86
86
 
87
- const transpiledPath = url + ".ts";
87
+ const transpiledPath = url + ".ts"
88
88
 
89
89
  // NOTE: Assuming ts-node hook follows load hook
90
90
  const result = await next(transpiledPath, {
@@ -93,34 +93,34 @@ export async function load(url, context, next) {
93
93
  format: "module",
94
94
  // NOTE: Setting the source in the context makes it available when ts-node uses defaultLoad
95
95
  source: tsSource,
96
- });
96
+ })
97
97
 
98
98
  // NOTE: we must install our source map support after ts-node does to take priority
99
- ensureRegister();
99
+ ensureRegister()
100
100
 
101
101
  // parse source map from downstream (ts-node) result
102
102
  // compose with civet source map
103
- result.source = SourceMap.remap(result.source, sourceMap, url, "");
103
+ result.source = SourceMap.remap(result.source, sourceMap, url, "")
104
104
  // NOTE: This path needs to match what ts-node uses so we can override the source map
105
- outputCache.set(normalizeSlashes(path), result.source);
105
+ outputCache.set(normalizeSlashes(path), result.source)
106
106
 
107
- return result;
108
- };
107
+ return result
108
+ }
109
109
 
110
110
  // Other URLs continue unchanged.
111
- return next(url, context);
112
- };
111
+ return next(url, context)
112
+ }
113
113
 
114
114
  // commonjs hook
115
- const require = createRequire(import.meta.url);
115
+ const require = createRequire(import.meta.url)
116
116
  require.extensions[".civet"] = function(m, filename) {
117
- const source = readFileSync(filename, "utf8");
117
+ const source = readFileSync(filename, "utf8")
118
118
  const code = compile(source, {
119
119
  filename,
120
120
  inlineMap: true,
121
121
  js: true
122
- });
122
+ })
123
123
 
124
124
  //@ts-ignore TODO: Figure out how to load types from inculde folders in Civet LSP
125
- return m._compile(code, filename);
126
- };
125
+ return m._compile(code, filename)
126
+ }
package/dist/main.js CHANGED
@@ -3204,8 +3204,8 @@ var require_parser = __commonJS({
3204
3204
  return VariableDeclarationList$0(state);
3205
3205
  }
3206
3206
  }
3207
- var VariableDeclaration$0 = $S(BindingPattern, Initializer);
3208
- var VariableDeclaration$1 = $S(BindingIdentifier, $E(Initializer));
3207
+ var VariableDeclaration$0 = $S(BindingPattern, $E(TypeSuffix), Initializer);
3208
+ var VariableDeclaration$1 = $S(BindingIdentifier, $E(TypeSuffix), $E(Initializer));
3209
3209
  function VariableDeclaration(state) {
3210
3210
  if (state.tokenize) {
3211
3211
  return $TOKEN("VariableDeclaration", state, VariableDeclaration$0(state) || VariableDeclaration$1(state));
@@ -3675,9 +3675,7 @@ var require_parser = __commonJS({
3675
3675
  }
3676
3676
  }
3677
3677
  var StatementDelimiter$0 = $S($Q(TrailingComment), Semicolon, $Q(TrailingComment));
3678
- var StatementDelimiter$1 = $TS($S($EXPECT($L1, fail, 'StatementDelimiter ""'), $Y(EOS)), function($skip, $loc, $0, $1, $2) {
3679
- return { $loc, token: ";" };
3680
- });
3678
+ var StatementDelimiter$1 = $Y(EOS);
3681
3679
  function StatementDelimiter(state) {
3682
3680
  if (state.tokenize) {
3683
3681
  return $TOKEN("StatementDelimiter", state, StatementDelimiter$0(state) || StatementDelimiter$1(state));
@@ -5179,7 +5177,7 @@ var require_parser = __commonJS({
5179
5177
  }
5180
5178
  }
5181
5179
  var InsertBreak$0 = $TV($EXPECT($L1, fail, 'InsertBreak ""'), function($skip, $loc, $0, $1) {
5182
- return { $loc, token: "break;" };
5180
+ return { $loc, token: ";break;" };
5183
5181
  });
5184
5182
  function InsertBreak(state) {
5185
5183
  if (state.verbose)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "exports": {