@makano/rew 1.2.56 → 1.2.57

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.
@@ -17,6 +17,7 @@ const { print, input } = require('../functions/stdout');
17
17
  const colors = require('colors');
18
18
  const { req } = require('../misc/req');
19
19
  const { gen_key } = require('../misc/bin');
20
+ const { REW_FILE_TYPE } = require('../const/ext');
20
21
 
21
22
  if (!existsSync(CONFIG_PATH) || !existsSync(CONFIG_PATH + '/repos.yaml')) {
22
23
  mkdirSync(CONFIG_PATH, { recursive: true });
@@ -127,7 +128,7 @@ yargs(hideBin(process.argv))
127
128
  type: 'string',
128
129
  })
129
130
  .option('dev', {
130
- describe: 'If your entry file is a .qrew, then just use the .coffee instead',
131
+ describe: `If your entry file is a .qrew, then just use the ${REW_FILE_TYPE.EXTENSION} instead`,
131
132
  type: 'boolean',
132
133
  })
133
134
  .option('entry', {
@@ -354,7 +355,7 @@ yargs(hideBin(process.argv))
354
355
  })
355
356
  .option('remove', {
356
357
  alias: 'r',
357
- describe: 'Remove all coffee',
358
+ describe: 'Remove all '+REW_FILE_TYPE.EXTENSION,
358
359
  type: 'boolean',
359
360
  });
360
361
  },
@@ -18,6 +18,7 @@ const { seededID } = require('../misc/seededid');
18
18
  const loading = require('loading-cli');
19
19
  const sleep = require('../functions/sleep');
20
20
  const { gen_key } = require('../misc/bin');
21
+ const { REW_FILE_TYPE } = require('../const/ext');
21
22
 
22
23
  const binpath = path.join(conf({}).create('').root, '.bin');
23
24
  const logspath = path.join(conf({}).create('').root, '.logs');
@@ -49,7 +50,7 @@ module.exports = {
49
50
  runFileWithArgv(filePath, options = {}, cargv) {
50
51
  const argv = cargv || process.argv;
51
52
  argv.shift();
52
- if (argv[0].endsWith('rew')) {
53
+ if (argv[0].endsWith(REW_FILE_TYPE.EXTENSION)) {
53
54
  if (argv[1] == 'run') {
54
55
  argv.splice(0, 3);
55
56
  } else if(argv[1] == '-w' || argv[1] == '--watch'){
@@ -118,8 +119,8 @@ module.exports = {
118
119
  const create = () => {
119
120
  fs.mkdirSync(projectPath, { recursive: true });
120
121
  const confPath = path.join(projectPath, 'app.yaml');
121
- const entryFile = path.join(projectPath, 'main.coffee');
122
- fs.writeFileSync(confPath, jsYaml.dump({ manifest: { package: project.package, private: false }, exec: { entry: 'main.coffee' }, assets: { icon: 'assets/icon.png', folder: './assets' }, install: { requirements: [] } }));
122
+ const entryFile = path.join(projectPath, 'main'+(project.civet ? REW_FILE_TYPE.EXTENSION : '.coffee'));
123
+ fs.writeFileSync(confPath, jsYaml.dump({ manifest: { package: project.package, private: false }, exec: { entry: 'main'+(project.civet ? REW_FILE_TYPE.EXTENSION : '.coffee') }, assets: { icon: 'assets/icon.png', folder: './assets' }, install: { requirements: [] } }));
123
124
  fs.writeFileSync(entryFile, `print("Hello World!")`);
124
125
  fs.mkdirSync(path.join(projectPath, 'assets'), { recursive: true });
125
126
  if (project.git) {
@@ -127,10 +128,14 @@ module.exports = {
127
128
  execSync('cd ' + projectPath + ' && git init . && git branch -m main', { stdio: 'ignore' });
128
129
  }
129
130
  if(project.intellisense){
130
- fs.copyFileSync(path.join(__dirname, '../../../jsconfig.json'), path.join(projectPath, 'jsconfig.json'));
131
+ fs.copyFileSync(path.join(__dirname, '../../../tsconfig.json'), path.join(projectPath, 'tsconfig.json'));
131
132
  fs.copyFileSync(path.join(__dirname, '../../../runtime.d.ts'), path.join(projectPath, 'runtime.d.ts'));
132
133
  }
133
134
  execSync('cd ' + projectPath + ' && npm init -y', { stdio: 'ignore' });
135
+ if(project.civet){
136
+ log('Installing NPM Packages');
137
+ execSync('cd '+projectPath+' && npm i @types/node --no-save', { stdio: 'ignore' });
138
+ }
134
139
  // log('Installing '+npm_package_name);
135
140
  // exec('cd '+projectPath+' && npm i '+npm_package_name, (err) => {
136
141
  // if(err){
@@ -149,9 +154,12 @@ module.exports = {
149
154
  project.package = pkg.trim();
150
155
  rl.question(logget(' Use intellisense declarations ? (y/N): '.magenta.bold), (inteli) => {
151
156
  project.intellisense = inteli.toLowerCase() == 'y' || inteli.toLowerCase() == 'yes';
152
- rl.question(logget('󰊢 Use git ? (y/N): '.yellow.bold), (use_git) => {
153
- project.git = use_git.toLowerCase() == 'y' || use_git.toLowerCase() == 'yes';
154
- create();
157
+ rl.question(logget(' Use Civet Types ? (y/N): '.blue.bold), (civet) => {
158
+ project.civet = civet.toLowerCase() == 'y' || civet.toLowerCase() == 'yes';
159
+ rl.question(logget('󰊢 Use git ? (y/N): '.yellow.bold), (use_git) => {
160
+ project.git = use_git.toLowerCase() == 'y' || use_git.toLowerCase() == 'yes';
161
+ create();
162
+ });
155
163
  });
156
164
  });
157
165
  } else {
@@ -173,8 +181,8 @@ module.exports = {
173
181
  c.exec.entry = c.exec[options.entry] || c.exec.entry;
174
182
  }
175
183
  if (c.exec.entry) {
176
- if (byPath && options.dev) c.exec.entry = c.entry.endsWith('.qrew') ? c.exec.entry.replace(/\.qrew$/, '.coffee') : c.exec.entry;
177
184
  let r = path.resolve(root, c.exec.entry);
185
+ if (byPath && options.dev) r = r.endsWith('.qrew') ? r.replace(/\.qrew$/, (a, b) => fs.existsSync(r.replace(a, '.coffee')) ? '.coffee' : REW_FILE_TYPE.EXTENSION) : r;
178
186
  if (options.build) {
179
187
  this.build({
180
188
  file: r,
@@ -357,9 +365,9 @@ module.exports = {
357
365
  if (fs.existsSync(importedFilePath)) {
358
366
  importsArray.push(importStatement);
359
367
  processFile(importedFilePath, importsArray);
360
- } else if (fs.existsSync(importedFilePath + '.coffee')) {
368
+ } else if (fs.existsSync(importedFilePath + REW_FILE_TYPE.EXTENSION)) {
361
369
  importsArray.push(importStatement);
362
- processFile(importedFilePath + '.coffee', importsArray);
370
+ processFile(importedFilePath + REW_FILE_TYPE.EXTENSION, importsArray);
363
371
  } else if (fs.existsSync(importedFilePath + '.js')) {
364
372
  importsArray.push(importStatement);
365
373
  processFile(importedFilePath + '.js', importsArray);
@@ -0,0 +1,5 @@
1
+
2
+ module.exports.REW_FILE_TYPE = {
3
+ EXTENSION: '.civet',
4
+ TYPE: 'civet'
5
+ }
@@ -1,10 +1,12 @@
1
+ const { REW_FILE_TYPE } = require("./ext");
2
+
1
3
  const execOptions = {
2
4
  sharedContext: true,
3
- resolveExtensions: ['.coffee', { ext: '.js', options: { type: 'js' } }, { ext: '.qrew', options: { qrew: true } }],
5
+ resolveExtensions: [REW_FILE_TYPE.EXTENSION, ".coffee", { ext: '.js', options: { type: 'js' } }, { ext: '.qrew', options: { qrew: true } }],
4
6
  nativeRequire: false,
5
7
  useImport: false,
6
8
  cwdAlias: '$',
7
- jsxPragma: 'createElement',
9
+ jsxPragma: '__using__.JSX.createElement',
8
10
  jsx: false
9
11
  };
10
12
 
@@ -0,0 +1,12 @@
1
+
2
+
3
+
4
+ module.exports.USING_DEFAULT = {
5
+ JSX: {
6
+ param: (param) => ({ createElement: param }),
7
+ use: (options) => options.jsx = true
8
+ },
9
+ TYPES: {
10
+ use: (options) => options.typescript = true
11
+ }
12
+ }
@@ -31,7 +31,11 @@ module.exports = (currentFile) => {
31
31
  }
32
32
 
33
33
  function rm(filepath, options) {
34
- return fs.unlinkSync(filepath);
34
+ return fs.rmSync(gp(filepath), { recursive: true,...options });
35
+ }
36
+
37
+ function unlink(filepath, options) {
38
+ return fs.unlinkSync(gp(filepath));
35
39
  }
36
40
 
37
41
  function chmod(filepath, mode, options) {
@@ -51,6 +55,7 @@ module.exports = (currentFile) => {
51
55
  mkdir,
52
56
  chmod,
53
57
  rm,
58
+ unlink,
54
59
  fstat,
55
60
  exists,
56
61
  write,
@@ -6,6 +6,7 @@ const { existsSync, readFileSync } = require('fs');
6
6
  const conf = require('../pkgs/conf');
7
7
  const jsYaml = require('js-yaml');
8
8
  const { execOptions } = require('../const/opt');
9
+ const { REW_FILE_TYPE } = require('../const/ext');
9
10
 
10
11
  const cachedFiles = [];
11
12
  module.exports.cleanCache = () => {
@@ -34,7 +35,7 @@ const lookUpInOtherApps = (fullPath) => {
34
35
  module.exports.imp = function (runPath, context) {
35
36
  return function (filename, options = {}) {
36
37
  if (!options) options = {};
37
- let type = options.type || 'coffee';
38
+ let type = options.type || filename.endsWith('.coffee') ? 'coffee' : REW_FILE_TYPE.TYPE;
38
39
  let exports,
39
40
  ispkg = findPackage(filename);
40
41
 
@@ -92,7 +93,7 @@ module.exports.imp = function (runPath, context) {
92
93
  const pkg = getPackage(filename)(context, options);
93
94
  exports = pkg._onImport ? pkg._onImport() : pkg;
94
95
  } else if (foundCache) {
95
- } else if (type == 'coffee') {
96
+ } else if (type == REW_FILE_TYPE.TYPE || type == "coffee") {
96
97
  exports = exec({});
97
98
  } else if (type == 'js') {
98
99
  exports = exec({ compile: false });
@@ -111,7 +112,7 @@ module.exports.imp = function (runPath, context) {
111
112
  }
112
113
  }
113
114
 
114
- if (options.save && (type == 'js' || type == 'coffee')) {
115
+ if (options.save && (type == 'js' || type == REW_FILE_TYPE.TYPE || type == "coffee")) {
115
116
  if (typeof options.save == 'string') context[options.save] = exports[i];
116
117
  else
117
118
  for (let i in exports) {
@@ -135,7 +136,6 @@ module.exports.imp = function (runPath, context) {
135
136
  //** Mock imports section
136
137
  /**/ if(!exports) exports = options.mock;
137
138
  /**/ if(options.mock === null) return null;
138
- /**/ if(!exports) throw new Error('Import '+filename+' does not export anything. Use the "mock" option to mock a value.');
139
139
  //**
140
140
 
141
141
  return exports;
@@ -8,7 +8,7 @@ const cahcedRequires = {};
8
8
  const doImp = (path) => wait(async () => await import(resolvedPath));
9
9
 
10
10
  module.exports.customRequire = function customRequire(modulePath, filePath) {
11
- const pathname = modulePath;
11
+ let pathname = modulePath;
12
12
  if (modulePath.startsWith('./') || modulePath.startsWith('../') || path.isAbsolute(modulePath)) {
13
13
  pathname = path.resolve(modulePath);
14
14
  }
package/lib/rew/main.js CHANGED
@@ -1,17 +1,5 @@
1
- const { compileFile } = require('./modules/compiler');
2
- const { exec, runPath } = require('./modules/runtime');
3
- const fs = require('fs');
4
- const { imp } = require('./functions/import');
5
- const { FILES } = require('./const/files');
1
+ const { runPath } = require('./modules/runtime');
6
2
 
7
3
  module.exports.run = function (filepath, options = {}, custom_context = {}) {
8
- FILES.forEach((file) => {
9
- if (fs.existsSync(file.path)) return;
10
- if (file.content) {
11
- fs.writeFileSync(file.path, file.content);
12
- } else {
13
- fs.mkdirSync(file.path, { recursive: true });
14
- }
15
- });
16
4
  return runPath(filepath, options, custom_context);
17
5
  };
@@ -1,4 +1,4 @@
1
- const { compile } = require('../../coffeescript/coffeescript');
1
+ const { compile: compileCivet } = require('../../civet/main');
2
2
  const { execOptions } = require('../const/opt');
3
3
  const { findAppInfo } = require('../misc/findAppInfo');
4
4
  const { from_qrew } = require('../qrew/compile');
@@ -7,6 +7,9 @@ const babel = require('@babel/core');
7
7
  const path = require('path');
8
8
  const babelReact = require('@babel/preset-react');
9
9
  const { readFileSync } = require('fs');
10
+ const { wait } = require('../functions/wait');
11
+ const { REW_FILE_TYPE } = require('../const/ext');
12
+ const { USING_DEFAULT } = require('../const/usage');
10
13
 
11
14
  function tokenizeCoffeeScript(code) {
12
15
  const tokens = [];
@@ -115,6 +118,9 @@ function compileRewStuff(content, options) {
115
118
  const token = tokens[i];
116
119
  let { token: nextToken, n } = gnextToken(i, 1, tokens) || {};
117
120
 
121
+ if(token.type == "COMMENT" && i < 2 && token.value.startsWith('#!')){
122
+ continue;
123
+ }
118
124
 
119
125
  if (token.type === 'IDENTIFIER' && token.value === 'opt.set') {
120
126
  const { token: nextNextToken } = gnextToken(i, 2, tokens) || {};
@@ -150,18 +156,19 @@ function compileRewStuff(content, options) {
150
156
  }
151
157
 
152
158
 
153
- if (token.type === 'IDENTIFIER' && token.value === 'let' && !options.keepImports) {
154
- result += '`'
155
- hooks.push({
156
- index: fnextToken(i, tokens, 'OTHER', ';').ti,
157
- value: `\``,
158
- });
159
- }
160
-
161
159
  if (token.type === 'IDENTIFIER' && token.value === 'export' && !options.keepImports) {
162
160
  token.value = 'pub';
163
161
  }
164
162
 
163
+ if (token.type === 'IDENTIFIER' && token.value === 'using' && !options.disableUse) {
164
+ const next = nextToken.value;
165
+ if(next in USING_DEFAULT) {
166
+ const { use } = USING_DEFAULT[next];
167
+ use?.(options);
168
+ nextToken.value = `"${nextToken.value}"`
169
+ }
170
+ }
171
+
165
172
  if (token.type === 'IDENTIFIER' && token.value === 'import' && !options.keepImports) {
166
173
  // console.log(nextToken.type);
167
174
  let ind = i + n + 2;
@@ -177,9 +184,12 @@ function compileRewStuff(content, options) {
177
184
  const exportsTokens = tokens.slice(ind, closingBraceToken.ti);
178
185
  const exports = exportsTokens
179
186
  .filter((t) => t.type === 'IDENTIFIER')
180
- .map((t) => t.value)
187
+ .map((t, i, arr) => t.value == 'as' ? [arr[i-1].value +': '+arr[i+1].value] : t.value)
188
+ .flat(1)
189
+ .filter((t, i, arr) => !arr[i+1]?.match(':') && !arr[i-1]?.match(':'))
181
190
  .join(', ');
182
- result += `{ ${exports} } = inc ${nameToken.value}`;
191
+
192
+ result += `{ ${exports} } ${options.type == 'coffee' ? '=' : ':='} inc ${nameToken.value}`;
183
193
  i = nameToken.ti;
184
194
  }
185
195
  } else if (nextToken.value === '*') {
@@ -188,7 +198,7 @@ function compileRewStuff(content, options) {
188
198
  if (asToken) {
189
199
  const nextToken = fnextToken(asToken.ti + 1, tokens, 'IDENTIFIER');
190
200
  defaultName = nextToken.value;
191
- result += `${defaultName} = inc ${nameToken.value}`;
201
+ result += `${defaultName} ${options.type == 'coffee' ? '=' : ':='} inc ${nameToken.value}`;
192
202
  i = ind + 6;
193
203
  }
194
204
  } else if (nextToken) {
@@ -201,13 +211,15 @@ function compileRewStuff(content, options) {
201
211
  const exportsTokens = tokens.slice(ind, closingBraceToken.ti);
202
212
  const exports = exportsTokens
203
213
  .filter((t) => t.type === 'IDENTIFIER')
204
- .map((t) => t.value)
214
+ .map((t, i, arr) => t.value == 'as' ? [arr[i-1].value +': '+arr[i+1].value] : t.value)
215
+ .flat(1)
216
+ .filter((t, i, arr) => !arr[i+1]?.match(':') && !arr[i-1]?.match(':'))
205
217
  .join(', ');
206
- result += `{ default: ${defaultName}, ${exports} } = inc ${nameToken?.value || ''}`;
218
+ result += `{ default: ${defaultName}, ${exports} } ${options.type == 'coffee' ? '=' : ':='} inc ${nameToken?.value || ''}`;
207
219
  i = closingBraceToken.ti + 4;
208
220
  }
209
221
  } else {
210
- result += `{ default: ${defaultName} } = inc ${nameToken?.value || ''}`;
222
+ result += `{ default: ${defaultName} } ${options.type == 'coffee' ? '=' : ':='} inc ${nameToken?.value || ''}`;
211
223
  i = ind + 2;
212
224
  }
213
225
  }
@@ -259,21 +271,56 @@ function compileRewStuff(content, options) {
259
271
  return result;
260
272
  }
261
273
 
262
- const cpl = (module.exports.compile = function (file, options = {}) {
263
- let c = options.type == 'js' || options.compile == false ? file.content : compile(compileRewStuff(file.content, options), {
274
+ const compileCivetStuff = (file, options) => {
275
+ const compileOptions = {
264
276
  ...options,
265
- filename: file.path,
266
- bare: options.bare ?? false,
277
+ bare: true,
278
+ filename: file.content,
267
279
  inlineMap: false,
268
- });2
280
+ js: true
281
+ };
282
+
283
+ const prepared = compileRewStuff(file.content, options);
284
+
285
+ const compiled = options.async ? compileCivet(prepared, compileOptions) : wait(compileCivet, prepared, compileOptions);
286
+
287
+ return {
288
+ compiled,
289
+ options
290
+ };
291
+ }
292
+
293
+ const cpl = (module.exports.compile = function (file, options = {}) {
294
+ let compiledCode;
295
+ const result = compileCivetStuff(file, {
296
+ ...options,
297
+ parseOptions: {
298
+ coffeeCompat: options.type == "coffee",
299
+ }
300
+ });
301
+
302
+ options = result.options;
303
+ compiledCode = result.compiled;
304
+
305
+ const babelify = (code, options) => babel.transformSync(code, {
306
+ presets: [[babelReact, { pragma: options.jsxPragma || execOptions.jsxPragma }]],
307
+ plugins: [],
308
+ }).code;
309
+
310
+ if(compiledCode instanceof Promise){
311
+ return compiledCode.then((compiledCode) => {
312
+ if (execOptions.jsx || options.jsx) {
313
+ compiledCode = babelify(compiledCode, options);
314
+ }
315
+ return compiledCode;
316
+ });
317
+ }
318
+
269
319
  // console.log(c);
270
320
  if (execOptions.jsx || options.jsx) {
271
- c = babel.transformSync(c, {
272
- presets: [[babelReact, { pragma: options.jsxPragma || execOptions.jsxPragma }]],
273
- plugins: [],
274
- }).code;
321
+ compiledCode = babelify(compiledCode, options);
275
322
  }
276
- return c;
323
+ return compiledCode;
277
324
  });
278
325
 
279
326
  module.exports.compileFile = function (filepath, options = {}) {
@@ -7,6 +7,7 @@ const fsLib = require("../functions/fs");
7
7
  const pathLib = require("../functions/path");
8
8
  const execLib = require("../functions/exec");
9
9
  const { findAppInfo } = require("../misc/findAppInfo");
10
+ const { USING_DEFAULT } = require("../const/usage");
10
11
 
11
12
  let mainFile = "";
12
13
  const isMainFile = (filepath) => filepath == mainFile;
@@ -30,6 +31,7 @@ module.exports.prepareContext = function (
30
31
  },
31
32
  app: findAppInfo(filepath),
32
33
  ...fsLib(filepath),
34
+ __using__: {}
33
35
  };
34
36
  if (options.useContext) {
35
37
  context = {
@@ -91,6 +93,16 @@ module.exports.prepareContext = function (
91
93
  context.pub = pubFunction(context);
92
94
  context.exports = exportsFunction(context);
93
95
 
96
+ context.using = (name, ...params) => {
97
+ if(USING_DEFAULT[name]){
98
+ if(USING_DEFAULT[name].param) {
99
+ context.__using__[name] = USING_DEFAULT[name].param(...params);
100
+ }
101
+ } else {
102
+ context.__using__[name] = params.length ? params.length > 1 ? [...params] : params : true;
103
+ }
104
+ };
105
+
94
106
  if (
95
107
  context.module.main ||
96
108
  (options.fromMain == true && options.as == "main")
@@ -17,6 +17,7 @@ const exec = (module.exports.exec = function (code, context, original = '') {
17
17
 
18
18
  module.exports.runPath = function runPath(filepath, options = {}, custom_context = {}) {
19
19
  if(filepath.endsWith('.js')) options.type = 'js';
20
+ if(filepath.endsWith('.coffee')) options.type = 'coffee';
20
21
  let { compiled_code, file } = compileFile(options.code ? { content: options.code, path: filepath } : filepath, options);
21
22
  const context = options.import?.takeThisContext ? custom_context : prepareContext(custom_context, options, file.path, runPath);
22
23
  // context.module.compiled = compiled_code;
@@ -5,6 +5,10 @@ const path = require('path');
5
5
  const { run } = require('../main');
6
6
  const { runPath } = require('../modules/runtime');
7
7
  const { cleanCache } = require('../functions/import');
8
+ const { REW_FILE_TYPE } = require('../const/ext');
9
+
10
+ const lookUpFiles = ['route', 'page', 'page.s'];
11
+
8
12
  module.exports = (context) => {
9
13
 
10
14
  // http.createServer((req, res) => {
@@ -105,7 +109,7 @@ module.exports = (context) => {
105
109
  }
106
110
  }
107
111
 
108
- function findLayoutFiles(filePath, root, isClientSide = true, resolveExtensions = ['.coffee', '.js', '.jsx']) {
112
+ function findLayoutFiles(filePath, root, isClientSide = true, resolveExtensions = [REW_FILE_TYPE.EXTENSION, '.coffee', '.js', '.jsx']) {
109
113
  const layouts = [];
110
114
  const rootDir = root;
111
115
  let currentDir = path.dirname(filePath);
@@ -162,13 +166,11 @@ module.exports = (context) => {
162
166
  onError = () => error(404, 'Path not found'),
163
167
  root = '',
164
168
  basePath = '',
165
- resolveExtensions = ['.coffee', '.js', '.jsx'],
169
+ resolveExtensions = [REW_FILE_TYPE.EXTENSION, '.coffee', '.js', '.jsx'],
166
170
  bundlerOptions = {},
167
171
  bundlerEntry = defaultBundlerEntry,
168
172
  ssrBundlerEntry = defaultSsrBundlerEntry,
169
173
  }) {
170
-
171
- const lookUpFiles = ['route', 'page', 'page.s'];
172
174
 
173
175
  const params = {};
174
176
 
@@ -176,6 +178,7 @@ module.exports = (context) => {
176
178
  const routeParts = pathname.split('/').filter(Boolean);
177
179
  let routePath = root;
178
180
 
181
+
179
182
  Object.keys(params).forEach(key => delete params[key]);
180
183
 
181
184
  for (const part of routeParts) {
@@ -3,6 +3,7 @@ const emitter = require("../functions/emitter");
3
3
  const { compile } = require("../modules/compiler");
4
4
  const { wait } = require("../functions/wait");
5
5
  const { generateRandomID } = require("../functions/id");
6
+ const { REW_FILE_TYPE } = require("../const/ext");
6
7
 
7
8
 
8
9
  const selfClosingElements = new Set([
@@ -476,11 +477,11 @@ module.exports = (context, importOptions) => {
476
477
  }
477
478
  return null;
478
479
  },
479
- transform(code, id) {
480
- if (id.endsWith('.coffee')) {
481
- const result = compile({ content: code, path: filepath }, { jsx: true, keepImports: true });
480
+ async transform(code, id) {
481
+ if (id.endsWith(REW_FILE_TYPE.EXTENSION) || id.endsWith('.coffee')) {
482
+ const result = compile({ content: code, path: filepath }, { jsx: true, async: true, keepImports: true });
482
483
  return {
483
- code: result,
484
+ code: await result,
484
485
  map: null,
485
486
  };
486
487
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.56",
3
+ "version": "1.2.57",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {
package/runtime.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  interface ImportOptions {
2
4
  /**
3
5
  * Determines how to import the given module
@@ -61,7 +63,7 @@ interface ModuleConf extends ModuleConfOptionCenter {
61
63
  name: string,
62
64
  defaults?: any
63
65
  ) => {
64
- write: (value: any, ifExists?: boolean) => this;
66
+ write: (value: any, ifExists?: boolean) => any;
65
67
  read: (to?: string | object) => string | object | Buffer;
66
68
  fileRoot: string;
67
69
  exists: boolean;
@@ -109,8 +111,8 @@ interface ModuleRuneDB {
109
111
  interface ModuleRune {
110
112
  db(dbname: string, data?: object, encryptionKey?: string): ModuleRuneDB;
111
113
  genKey(secret: string): string;
112
- push(...values: any[]): PushChange;
113
- pop(...values: any[]): PopChange;
114
+ push(...values: any[]): any;
115
+ pop(...values: any[]): any;
114
116
  }
115
117
 
116
118
  interface ModuleThreads {
@@ -120,7 +122,7 @@ interface ModuleThreads {
120
122
  on: (event: string, callback: (data) => void) => void;
121
123
  off: (event: string, callback: (data) => void) => void;
122
124
  emit: (event: string, data: any) => void;
123
- get: () => Promise;
125
+ get: () => Promise<any>;
124
126
  stop: () => void;
125
127
  };
126
128
  };
@@ -156,7 +158,8 @@ type StatusErrorObject = {
156
158
  error?: string;
157
159
  [key: string]: any;
158
160
  };
159
- class StatusError extends Error {
161
+
162
+ export class StatusError extends Error {
160
163
  status: number;
161
164
  [key: string]: any;
162
165
  constructor(status?: number, body?: StatusErrorObject | string);
@@ -262,12 +265,9 @@ interface ErrorLike extends Error {
262
265
  type ErrorBody = string | object;
263
266
  interface ErrorFormatter {
264
267
  (statusCode?: number, body?: ErrorBody): Response;
265
- (error: ErrorLike): Response;
266
- }
267
- {
268
268
  }
269
269
 
270
- const IttyRouter: <
270
+ export const IttyRouter: <
271
271
  RequestType extends IRequest = IRequest,
272
272
  Args extends any[] = any[],
273
273
  ResponseType = any
@@ -277,7 +277,7 @@ const IttyRouter: <
277
277
  ...other
278
278
  }?: IttyRouterOptions) => IttyRouterType<RequestType, Args, ResponseType>;
279
279
 
280
- const Router: <
280
+ export const Router: <
281
281
  RequestType = IRequest,
282
282
  Args extends any[] = any[],
283
283
  ResponseType = any
@@ -888,6 +888,7 @@ declare const presolve: (...paths: string[]) => string;
888
888
 
889
889
  declare function exports(value: any): any;
890
890
 
891
+
891
892
  declare function pub(value: any): any;
892
893
  declare function pub(name: string, value: any): any;
893
894
 
@@ -898,5 +899,9 @@ declare const opt: {
898
899
  pop: (key: string) => any;
899
900
  };
900
901
 
902
+ declare const JSX: any;
903
+ declare const TYPES: any;
904
+ declare function using(fn: any, ...args: any[]): any;
905
+
901
906
  declare function wait(fn: CallableFunction, ...args: any[]): any;
902
907
  declare function clear(): void;
package/jsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "checkJs": true,
4
- "lib": ["ESNext"],
5
- "module": "Node16"
6
- },
7
- "include": [
8
- "./runtime.d.ts"
9
- ],
10
- "typeAcquisition": {
11
- "include": ["./runtime.d.ts"]
12
- }
13
- }