@makano/rew 1.5.4 → 1.5.5

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.
@@ -20,7 +20,7 @@ module.exports.cleanCache = () => {
20
20
  while(cachedFiles.length) cachedFiles.pop();
21
21
  };
22
22
  const lookUpInOtherApps = (fullPath) => {
23
- straceLog('===> WARN: LOOKUP SLOWS PROCESS');
23
+ straceLog('===> WARN: Lookup slows process');
24
24
  const con = conf({});
25
25
  const name = fullPath.indexOf('/') ? fullPath.split('/')[0] : fullPath;
26
26
  let dpath = fullPath.indexOf('/') ? fullPath.split('/')[1] : '';
@@ -51,10 +51,10 @@ module.exports.imp = function (runPath, context) {
51
51
  let exports,
52
52
  ispkg = findPackage(filename);
53
53
 
54
- straceLog('IMPORT for', filename, 'as', type);
54
+ straceLog('import file', '"' + filename + '"', 'as type', type);
55
55
 
56
56
  if (filename.startsWith('@') && context.app) {
57
- straceLog('===> FROM APP ROOT');
57
+ straceLog('===> from app root');
58
58
  filename = filename.replace('@', context.app.path);
59
59
  }
60
60
 
@@ -62,7 +62,7 @@ module.exports.imp = function (runPath, context) {
62
62
  if(path.extname(filepath) == '.qrew') options.qrew = true;
63
63
 
64
64
  const lookUp = () => {
65
- straceLog('===> LOOKUP()');
65
+ straceLog('===> lookUp()');
66
66
  const otherPath = lookUpInOtherApps(filename);
67
67
  if (!otherPath) throw new Error('Module "' + filename + '" not found');
68
68
  else filepath = otherPath;
@@ -80,7 +80,7 @@ module.exports.imp = function (runPath, context) {
80
80
  typeof ext == 'string' ? existsSync(filepath + ext) : existsSync(filepath + (ext.ext || '')),
81
81
  );
82
82
  if (resolve) {
83
- straceLog('===> RESOLVE()');
83
+ straceLog('===> resolve()');
84
84
  filepath += typeof resolve == 'string' ? resolve : resolve.ext;
85
85
  if (typeof resolve == 'object' && resolve.options) {
86
86
  if (resolve.options.type) type = resolve.options.type;
@@ -91,7 +91,7 @@ module.exports.imp = function (runPath, context) {
91
91
  }
92
92
 
93
93
  const exec = (coptions = {}) => {
94
- straceLog('===> EXECUTE() IMPORTFILE');
94
+ straceLog('===> execute(importFile)');
95
95
  const r = runPath(
96
96
  filepath,
97
97
  {
@@ -113,7 +113,7 @@ module.exports.imp = function (runPath, context) {
113
113
  }
114
114
 
115
115
  if (ispkg) {
116
- straceLog('===> FIND_PACKAGE()');
116
+ straceLog('===> findPackage()');
117
117
  const pkg = getPackage(filename)(context, options);
118
118
  exports = pkg._onImport ? pkg._onImport() : pkg;
119
119
  if(options.useDefaultForPackages) exports = { default: exports };
@@ -124,10 +124,10 @@ module.exports.imp = function (runPath, context) {
124
124
  } else if (type == 'js') {
125
125
  exports = exec({ compile: false });
126
126
  } else if (type == 'yaml' || type == 'json' || type == 'text') {
127
- straceLog('===> GET_RAW_FILE()');
127
+ straceLog('===> getRawFile()');
128
128
  const f = getFile(filepath);
129
129
  if (type == 'yaml') {
130
- straceLog('===> FROM_YAML()');
130
+ straceLog('===> fromYaml()');
131
131
  exports = _returns(options, importYaml(f.path, f));
132
132
  } else if (type == 'json') {
133
133
  straceLog('===>');
@@ -137,7 +137,7 @@ module.exports.imp = function (runPath, context) {
137
137
  exports = _returns(options, {});
138
138
  }
139
139
  } else {
140
- straceLog('===> FROM_TEXT');
140
+ straceLog('===> fromText()');
141
141
  exports = _returns(options, f.content);
142
142
  }
143
143
  }
@@ -6,11 +6,11 @@ const { straceLog } = require('./strace');
6
6
 
7
7
  module.exports.findAppInfo = function (filepath) {
8
8
  const appPath = findAppPath(path.dirname(filepath));
9
- straceLog('FINDAPPINFO() for', filepath);
9
+ straceLog('findAppInfo() for', filepath);
10
10
  if (appPath) {
11
11
  const config = jsYaml.load(readFileSync(path.join(appPath, 'app.yaml')));
12
- straceLog('==> FOUND CONFIG AT', appPath);
13
- straceLog('==> APP PACKAGE', config?.manifest?.package);
12
+ straceLog('==> INFO Found config at:', '"' + appPath + '"');
13
+ straceLog('==> INFO App Package:', '"' + config?.manifest?.package + '"');
14
14
  return {
15
15
  path: appPath,
16
16
  config,
@@ -3,23 +3,19 @@ const fs = require('fs'); // Import the 'path' module
3
3
  const { straceLog } = require('./strace');
4
4
 
5
5
  module.exports.findAppPath = (currentDir = __dirname) => {
6
- // Check if app.yaml exists in the current directory
7
- straceLog('FINDAPP() for', currentDir);
6
+ straceLog('findApp() for', '"' + currentDir + '"');
8
7
  const appYamlPath = path.join(currentDir, 'app.yaml');
9
8
  if (fs.existsSync(appYamlPath)) {
10
9
 
11
- straceLog('==> FOUND PATH', appYamlPath);
10
+ straceLog('==> INFO found path', `"${appYamlPath}"`);
12
11
  return currentDir;
13
12
  }
14
13
 
15
- // If not found, move up a directory level
16
14
  const parentDir = path.dirname(currentDir);
17
15
 
18
- // Check if we reached the root directory
19
16
  if (parentDir === currentDir) {
20
- return null; // Not found
17
+ return null;
21
18
  }
22
19
 
23
- // Recursively call the function on the parent directory
24
20
  return module.exports.findAppPath(parentDir);
25
21
  };
@@ -1,5 +1,5 @@
1
1
  module.exports.straceLog = function(...logs){
2
2
  if(process.straceMode){
3
- console.log(`[${new Date().getHours()}:${new Date().getMinutes()}:${new Date().getSeconds()} ${new Date().getDate()}/${new Date().getMonth()}/${new Date().getFullYear()}] [${process.pid}]`, ...logs);
3
+ console.log(`[${new Date().toLocaleTimeString()} ${new Date().getDate()}/${new Date().getMonth()}/${new Date().getFullYear()}] [${process.pid}]`, ...logs.map(i => i.replace(/^([=>]+)/, '\x1b[34m$1\x1b[39m').replace(/WARN:/g, '\x1b[30m\x1b[43m WARN \x1b[39m\x1b[49m').replace(/INFO/g, '\x1b[30m\x1b[44m INFO \x1b[39m\x1b[49m').replace(/^"(.+)"$/, '\x1b[32m$1\x1b[39m').replace(/!([A-Z-+]+)/, (_, a) => `\x1b[30m\x1b[4${a.startsWith('-') ? '5' : a.startsWith('+') ? '6' : '2'}m ${a.replace(/^[-+]/, '')} \x1b[39m\x1b[49m`)));
4
4
  }
5
5
  }
@@ -137,15 +137,15 @@ const fnextToken = (i, tokens, type, value) => {
137
137
  function declareAlias(aliases, token) {
138
138
  const regex = /^#declare(\*)?\s+(\w+)\s+"([^"]+)"\s*=\s*([\s\S]*);$/;
139
139
  const match = token.value.trim().match(regex);
140
- straceLog('DECLARECASE()');
141
- straceLog('==> EXPERIMENTAL FEATURE DETECTED');
140
+ straceLog('declareCase()');
141
+ straceLog('==> WARN: Experimental feature detected');
142
142
 
143
143
  if (match) {
144
144
  const isPublic = !!match[1];
145
145
  const type = match[2] == "key" ? 'IDENTIFIER' : match[2];
146
146
  let name = match[3];
147
147
  let value = match[4].trim();
148
- straceLog('==> DECLARE', name, 'as', value);
148
+ straceLog('==> INFO !DECLARE', name, 'as', value);
149
149
 
150
150
  let aliasValue = value.startsWith('${')
151
151
  ? new Function('token', 'tokens', 'code', 'hooks', 'index', 'setIndex', value.slice(2, -1))
@@ -210,7 +210,7 @@ function declareAlias(aliases, token) {
210
210
  aliases[type][name] = aliasValue;
211
211
 
212
212
  if(isPublic){
213
- straceLog('==>', 'DECLARATION GLOBALIZED');
213
+ straceLog('==>', 'INFO Declaration Globalized');
214
214
  execOptions._syntaxAliases[type] = execOptions._syntaxAliases[type] || {};
215
215
  execOptions._syntaxAliases[type][name] = aliasValue;
216
216
  }
@@ -234,11 +234,11 @@ const stdTypes = (isPublic) => {
234
234
  return r;
235
235
  };
236
236
  const includeFile = (includeContent, options) => {
237
- straceLog('INCLUDE()', includeContent);
237
+ straceLog('include()', includeContent);
238
238
  const dontInclude = includeContent.startsWith('*');
239
239
  if(dontInclude) {
240
240
  includeContent = includeContent.slice(1);
241
- straceLog('==> IGNORING OUTPUT', includeContent);
241
+ straceLog('==> INFO ingoring output', includeContent);
242
242
  };
243
243
  const fp = path.resolve(path.dirname(options.filename || ''), includeContent);
244
244
  let packageName = options.filename ? (existsSync(fp) ? fp : includeContent) : includeContent;
@@ -257,13 +257,13 @@ const includeFile = (includeContent, options) => {
257
257
  if(packageName == 'std'){
258
258
  r = _inc(stdTypes(dontInclude), true);
259
259
  } else if (existsSync(packageName)) {
260
- straceLog('==> INCLUDE FILE', packageName);
260
+ straceLog('==> includeFile(', '"'+packageName+'"', ')');
261
261
  r = _inc(packageName);
262
262
  } else {
263
263
  const packageName = includeContent.match('/') ? includeContent.split('/')[0] : includeContent;
264
264
  const headerFile = includeContent.match('/') ? includeContent.replace(packageName+'/', '') : 'main.h.coffee';
265
265
  const pathname = path.join(CONFIG_PATH, packageName, 'app', headerFile);
266
- straceLog('==> INCLUDE PACKAGE', packageName);
266
+ straceLog('==> includePackage(', '"'+packageName+'"');
267
267
  if(existsSync(pathname)) r = _inc(pathname);
268
268
  }
269
269
  if(dontInclude){
@@ -277,12 +277,12 @@ function useImp(token, options){
277
277
  token.value.startsWith('"#') ||
278
278
  token.value.startsWith("'#")
279
279
  )){
280
- straceLog('==> IMP Uses HEADER');
280
+ straceLog('==> INFO imp() Uses HEADER');
281
281
  const dem = token.value.slice(0, 1);
282
282
  const value = token.value.slice(1, -1);
283
283
  let packageName = value.slice(1);
284
284
  token.value = dem+packageName+dem;
285
- straceLog('IMP() with HEADER for', packageName);
285
+ straceLog('imp() with header for', `"${packageName}"`);
286
286
  return includeFile(packageName !== 'std' ? packageName : '*'+packageName, options);
287
287
  }
288
288
  return '';
@@ -344,7 +344,7 @@ function insertAt(array, index, ...values) {
344
344
  }
345
345
 
346
346
  function compileRewStuff(content, options) {
347
- straceLog('TOKENIZE() for CURRENTFILE');
347
+ straceLog('tokeinze(currentFile)');
348
348
  const tokens = tokenizeCoffeeScript(content);
349
349
  let result = '';
350
350
  let multilineDeclareBuffer = [];
@@ -412,17 +412,17 @@ function compileRewStuff(content, options) {
412
412
 
413
413
  if (token.type === 'COMMENT' && token.value.slice(1).trim().startsWith('@jsx')) {
414
414
  options.jsx = true;
415
- straceLog('JSX() ENABLE WITH COMMENTS');
415
+ straceLog('jsx().with(comments)');
416
416
  if(token.value.split('@jsx')[1].trim()){
417
417
  options.jsxPragma = token.value.split('@jsx')[1].trim();
418
- straceLog('JSX() PRAGMA WITH', options.jsxPragma);
418
+ straceLog('jsx().withPragma(', `"${options.jsxPragma}"`, ')');
419
419
  }
420
420
  }
421
421
 
422
422
  if (token.type === 'COMMENT' && token.value.slice(1).trim() === '@cls') {
423
423
  options.cls = true;
424
- straceLog('CLI_SYNTAX() ENABLE');
425
- straceLog('===> HIGHLY EXPERIMENTAL FEATURE DETECTED');
424
+ straceLog('cliSyntax::enable()');
425
+ straceLog('===> WARN: HIGHLY EXPERIMENTAL FEATURE DETECTED');
426
426
  }
427
427
 
428
428
  if (options.cls && token.type === 'OTHER' && token.value === '-' && nextToken.value == '-' && tokens[i-1]?.type == 'WHITESPACE') {
@@ -442,12 +442,12 @@ function compileRewStuff(content, options) {
442
442
 
443
443
  if (tokens[i-1]?.value !== '.' && token.type === 'IDENTIFIER' && token.value === 'export' && !options.keepImports) {
444
444
  token.value = 'pub';
445
- straceLog('EXPORT() => TRANSLATING TO pub');
445
+ straceLog('INFO !TRANSLATE converting export to pub');
446
446
  }
447
447
 
448
448
  if (tokens[i-1]?.value !== '.' && token.type === 'IDENTIFIER' && token.value === 'package' && nextToken.type == 'STRING') {
449
449
  token.value = 'appPackage';
450
- straceLog('APP_PACKAGE_CHANGE()');
450
+ straceLog('changeAppPackage()');
451
451
  }
452
452
 
453
453
  if (
@@ -465,7 +465,7 @@ function compileRewStuff(content, options) {
465
465
  }
466
466
 
467
467
  if (tokens[i-1]?.value !== '.' && token.type === 'IDENTIFIER' && token.value === 'using' && !options.disableUse) {
468
- straceLog('USING()');
468
+ straceLog('!+DIRECTIVE using()');
469
469
  const next = nextToken?.value;
470
470
  if(next in USING_DEFAULT) {
471
471
  const { use } = USING_DEFAULT[next];
@@ -475,7 +475,7 @@ function compileRewStuff(content, options) {
475
475
 
476
476
  const { token: nextNextToken } = gnextToken(i, 3, tokens) || {};
477
477
  if(nextNextToken.value == "as") nextNextToken.value = ",";
478
- } else straceLog('==> UNKNOWN');
478
+ } else straceLog('==> !-UNKNOWN');
479
479
  }
480
480
 
481
481
  if (token.type === 'IDENTIFIER' && token.value === 'as' && !options.keepImports) {
@@ -493,15 +493,15 @@ function compileRewStuff(content, options) {
493
493
 
494
494
  if (tokens[i-1]?.value !== '.' && token.type === 'IDENTIFIER' && token.value === 'import' && !options.keepImports) {
495
495
  // console.log(nextToken.type);
496
- straceLog('IMPORT()');
497
- straceLog('==> WARN: SLOWS DOWN COMPILATION');
496
+ straceLog('import()');
497
+ straceLog('==> WARN: Slows compilation');
498
498
  let ind = i + n + 2;
499
499
  let isAs = false;
500
500
  let usedDefault = false;
501
501
 
502
502
  let defaultName;
503
503
  if (nextToken.type === 'STRING') {
504
- straceLog('==> SIMPLE');
504
+ straceLog('==> !SIMPLE');
505
505
  if(useImp(nextToken, options)) updateAliases(aliases);
506
506
  result += `inc ${nextToken.value}`;
507
507
  i += n;
@@ -538,7 +538,7 @@ function compileRewStuff(content, options) {
538
538
  .filter((t, i, arr) => !arr[i+1]?.match(':') && !arr[i-1]?.match(':'))
539
539
  .join(', ');
540
540
 
541
- straceLog('==>', exports, 'from', nameToken.value);
541
+ straceLog('==> !COMPLEX', exports, 'from', nameToken.value);
542
542
 
543
543
  if(useImp(nameToken, options)) updateAliases(aliases);
544
544
  result += `{ ${exports} } ${options.type == 'coffee' ? '=' : ':='} inc ${nameToken.value}`;
@@ -550,7 +550,7 @@ function compileRewStuff(content, options) {
550
550
  const nameToken = fnextToken(asToken.ti, tokens, 'STRING');
551
551
  const nextToken = fnextToken(asToken.ti + 1, tokens, 'IDENTIFIER');
552
552
  defaultName = nextToken.value;
553
- straceLog('==>', defaultName, 'from', nameToken.value);
553
+ straceLog('==> !COMPLEX', defaultName, 'from', nameToken.value);
554
554
  if(useImp(nameToken, options)) updateAliases(aliases);
555
555
  result += `${defaultName} ${options.type == 'coffee' ? '=' : ':='} inc ${nameToken.value}`;
556
556
  i = ind + 6;
@@ -570,7 +570,7 @@ function compileRewStuff(content, options) {
570
570
  .flat(1)
571
571
  .filter((t, i, arr) => !arr[i+1]?.match(':') && !arr[i-1]?.match(':'))
572
572
  .join(', ');
573
- straceLog('==>', defaultName, 'and', exports, 'from', nameToken.value);
573
+ straceLog('==> !COMPLEX', defaultName, 'and', exports, 'from', nameToken.value);
574
574
  if(useImp(nameToken, options)) updateAliases(aliases);
575
575
  result += `{ default: ${defaultName}, ${exports} } ${options.type == 'coffee' ? '=' : ':='} inc ${nameToken?.value || ''}`;
576
576
  i = closingBraceToken.ti + 4;
@@ -589,7 +589,7 @@ function compileRewStuff(content, options) {
589
589
  if (nextLastToken?.value == 'assert') {
590
590
  result += ', ';
591
591
  const assertionToken = gnextToken(nextLastToken.ti, 2, tokens);
592
- straceLog('==> ASSERT', assertionToken);
592
+ straceLog('==> !ASSERT', assertionToken);
593
593
  if(assertionToken.token.type == 'OTHER' && assertionToken.token.value == '{'){
594
594
  hooks.push({
595
595
  index: assertionToken.token.ti,
@@ -607,7 +607,7 @@ function compileRewStuff(content, options) {
607
607
  }
608
608
 
609
609
  if (tokens[i-1]?.value !== '.' && token.type === 'IDENTIFIER' && (token.value === 'imp' || token.value === 'inc')) {
610
- straceLog('IMP() Detected');
610
+ straceLog('!+DIRECTIVE imp()');
611
611
  let { token: t1 } = gnextToken(i, 1, tokens) || {};
612
612
  let { token: t2 } = gnextToken(i, 2, tokens) || {};
613
613
  let r = '';
@@ -634,7 +634,7 @@ function compileRewStuff(content, options) {
634
634
  nextToken.value &&
635
635
  nextToken.value !== 'undefined' && !options.keepImports
636
636
  ) {
637
- straceLog('PUB() Detected');
637
+ straceLog('!+DIRECTIVE pub()');
638
638
  let next = {...nextToken}, isClass = false;
639
639
  if(next.value == 'default'){
640
640
  i += 2;
@@ -643,7 +643,7 @@ function compileRewStuff(content, options) {
643
643
  next.value = gnextToken(i, n + 1, tokens)?.token.value || "default";
644
644
  isClass = true;
645
645
  }
646
- straceLog('==> PUBLIC', next.value);
646
+ straceLog('==> !PUBLIC', next.value);
647
647
  hooks.push({
648
648
  index: i + 1,
649
649
  value: `"${next.value}", ${isClass ? `${next.value} = ` : ''}`,
@@ -653,13 +653,13 @@ function compileRewStuff(content, options) {
653
653
  const aliasType = aliases[token.type];
654
654
  // if(token.value == 'sidewest') console.log(aliases, token.value, token.type);
655
655
  if (aliasType && Object.keys(aliasType).includes(token.value)) {
656
- straceLog('ALIAS()', token.type);
656
+ straceLog('!+DIRECTIVE alias()', token.type);
657
657
  const aliasValue = aliasType[token.value];
658
658
  if (typeof aliasValue === 'function') {
659
- straceLog('==> EXECUTE ALIAS', token.value);
659
+ straceLog('==> INFO Execute alias:', token.value);
660
660
  result += aliasValue(token, tokens, result, hooks, i, (n) => i = n) || "";
661
661
  } else {
662
- straceLog('==> LITERAL ALIAS', token.value);
662
+ straceLog('==> INFO Literal alias:', token.value);
663
663
  result += aliasValue;
664
664
  }
665
665
  continue;
@@ -697,12 +697,12 @@ function compileRewStuff(content, options) {
697
697
  }
698
698
 
699
699
  const compileCivetStuff = (file, options) => {
700
- straceLog('COMPILE_CIVET() for CURRENTFILE');
700
+ straceLog('compileCivet(currentFile)');
701
701
  const preCompileOptions = {
702
702
  filename: file.path,
703
703
  ...options
704
704
  };
705
- straceLog('OPTION_PREPARE() for CURRENTFILE as', JSON.stringify(preCompileOptions));
705
+ straceLog('prepareOptions(currentFile).as(', `"${JSON.stringify(preCompileOptions)}"`, ')');
706
706
 
707
707
  if(options?.type == 'js' || file?.path?.endsWith('.js')){
708
708
  return {
@@ -724,7 +724,7 @@ const compileCivetStuff = (file, options) => {
724
724
  };
725
725
 
726
726
  let compiled = options.async ? compileCivet(prepared, compileOptions) : wait(compileCivet, prepared, compileOptions);
727
- straceLog('==> CIVET COMPILE <>');
727
+ straceLog('==> !COMPILER civetCompile(fileContent)');
728
728
 
729
729
  return {
730
730
  compiled,
@@ -745,10 +745,10 @@ const cpl = (module.exports.compile = function (file, options = {}) {
745
745
  compiledCode = result.compiled;
746
746
 
747
747
  const babelify = (code, options) => {
748
- straceLog('BABEL()');
749
- if(doJSX) straceLog('==> WITH JSX');
750
- if(doTypes) straceLog('==> WITH TYPES');
751
- if(doDecorators) straceLog('==> WITH DECORATORS');
748
+ straceLog('!COMPILER babel()');
749
+ if(doJSX) straceLog('==> INFO !-WITH JSX');
750
+ if(doTypes) straceLog('==> INFO !-WITH Types');
751
+ if(doDecorators) straceLog('==> INFO !-WITH DECORATORS');
752
752
  return babel.transformSync(code, {
753
753
  presets: [
754
754
  ...(doJSX ? [[babelReact, { throwIfNamespace: false, pragmaFrag: options.jsxPragmaFrag || execOptions.jsxPragmaFrag, pragma: options.jsxPragma || execOptions.jsxPragma }]] : [])
@@ -782,7 +782,7 @@ const cpl = (module.exports.compile = function (file, options = {}) {
782
782
  });
783
783
 
784
784
  module.exports.compileFile = function (filepath, options = {}) {
785
- straceLog('COMPILE() for CURRENTFILE');
785
+ straceLog('compile(currentFile)');
786
786
  const f = typeof filepath == "object" ? filepath : getFile(filepath);
787
787
  if(typeof filepath == "object") filepath = filepath.path;
788
788
  let qrew = false;
@@ -791,13 +791,13 @@ module.exports.compileFile = function (filepath, options = {}) {
791
791
  qrew = true
792
792
  f.content = from_qrew(readFileSync(f.path), options.package || findAppInfo(filepath)?.config.manifest.package || path.basename(filepath).split('.').slice(0, -1).join('.')).toString();
793
793
  options.type = f.content.split('\n')[0]?.match(/"initFile (.+)"/)?.[1]?.split('.').pop();
794
- straceLog('QREW_DECODE() as', options.type, 'for CURRENTFILE');
794
+ straceLog('decodeCrew(currentFile).as(', `"${options.type}"`,')');
795
795
  }
796
796
 
797
797
  let compiled_code = cpl(f, { ...options });
798
798
 
799
799
  if(options.onlyCompile && !qrew){
800
- straceLog('WRITE_AND_QUIT() for COMPILEDATA');
800
+ straceLog('writeAndQuit(compileData)');
801
801
  if(compiled_code instanceof Promise){
802
802
  compiled_code.then((r) => {
803
803
  console.log(r);
@@ -25,7 +25,7 @@ module.exports.prepareContext = function (
25
25
  filepath = "",
26
26
  runPath = () => {},
27
27
  ) {
28
- straceLog('PREPARE() NEW CONTEXT');
28
+ straceLog('!-NEW context()');
29
29
  if (mainFile == "") mainFile = filepath;
30
30
  /** @type {Record<string, any>} */
31
31
  let context = {
@@ -82,7 +82,7 @@ module.exports.prepareContext = function (
82
82
  this['@cb'] = cb;
83
83
  }
84
84
  });
85
- }, out: {...process.stdout, cols: process.stdout.columns, rows: process.stdout.rows, put: (...logs) => context.print(...logs), strace: (...logs) => straceLog('==> STRACE_OUT():', ...logs ), write: (logs) => context.printf(logs+'\n') }, in: {...process.stdin, read: (...args) => context.input(...args)}, define: (name, object) => {
85
+ }, out: {...process.stdout, cols: process.stdout.columns, rows: process.stdout.rows, put: (...logs) => context.print(...logs), strace: (...logs) => straceLog('==> !+OUT straceOut(): ', ...logs ), write: (logs) => context.printf(logs+'\n') }, in: {...process.stdin, read: (...args) => context.input(...args)}, define: (name, object) => {
86
86
  if(Array.isArray(name) && name.length == 2 && typeof name[0] == 'string'){
87
87
  object = name[1];
88
88
  name = name[0];
@@ -242,14 +242,14 @@ module.exports.prepareContext = function (
242
242
  if(context.app?.config?.exec?.['auto import']){
243
243
  const autoipath = path.join(context.app.path, context.app.config?.exec?.['auto import']);
244
244
  if(autoipath !== filepath){
245
- straceLog('==> AUTOIMPORT()', autoipath);
245
+ straceLog('==> !ACTION autoImport()', autoipath);
246
246
  const all = context.imp(path.relative(path.dirname(filepath), autoipath));
247
247
  for(let i in all) context[i] = all[i];
248
248
  }
249
249
  }
250
250
 
251
251
  if(!context.app){
252
- straceLog('==> APP NOT FOUND');
252
+ straceLog('==> WARN: App not found');
253
253
  context.appPackage = (packageName) => context.app = { config: { manifest: { package: packageName } } }
254
254
  } else {
255
255
  context.appPackage = context.mod = (packageName) => context.module.modset = packageName;
@@ -265,7 +265,7 @@ module.exports.prepareContext = function (
265
265
  context.module.main ||
266
266
  (options.fromMain == true && options.as == "main")
267
267
  ) {
268
- straceLog('==> RUNTIME() as MAIN for', filepath);
268
+ straceLog('==> !MAIN', filepath);
269
269
  context.opt = {
270
270
  set: (key, value) => (execOptions[key] = value),
271
271
  get: (key) => execOptions[key],
@@ -21,17 +21,17 @@ module.exports.runPath = function runPath(filepath, options = {}, custom_context
21
21
  if(filepath.endsWith('.coffee')) options.type = 'coffee';
22
22
  if(filepath.endsWith('.qrew')) options.type = 'qrew';
23
23
 
24
- straceLog('RUN() CURRENTFILE = ', filepath, 'as', options.type || 'UNKNOWN');
24
+ straceLog('!+DECLARE currentFile =', filepath, 'as', options.type || '!UNKNOWN');
25
25
 
26
26
  if(options.import?.async) options.async = true;
27
- if(options.async) straceLog('ASYNCMODE() for CURRENTFILE');
27
+ if(options.async) straceLog('==> !ASYNCMODE currentFile::async()');
28
28
  let { compiled_code, file } = compileFile(options.code ? { content: options.code, path: filepath } : filepath, options);
29
- straceLog('COMPILE_DONE() with COMPILEDATA');
29
+ straceLog('==> INFO Compile done with compileData');
30
30
  // context.module.compiled = compiled_code;
31
31
  // context.process.exit = (int) => process.exit(int);
32
32
 
33
33
  const doCode = () => {
34
- straceLog('RUNCODE() COMPILEDATA');
34
+ straceLog('runCode(compileData)');
35
35
  const context = options.import?.takeThisContext ? custom_context : prepareContext(custom_context, options, file.path, runPath);
36
36
 
37
37
  if(context.app){
@@ -51,6 +51,7 @@ module.exports.runPath = function runPath(filepath, options = {}, custom_context
51
51
  let execd = exec(compiled_code, context, file.content);
52
52
 
53
53
  if(context.module.main && (context.module.exports?.main || (typeof context.module.exports == "function" && context.module.exports.name == 'main'))){
54
+ straceLog('call(currentFile::mainFn)');
54
55
  const mainFn = context.module.exports.main ?? context.module.exports;
55
56
  let ctx = context;
56
57
  if(mainFn._class){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.5.4",
3
+ "version": "1.5.5",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {