@makano/rew 1.1.81 → 1.2.0

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.
Files changed (72) hide show
  1. package/lib/coffeescript/browser.js +144 -139
  2. package/lib/coffeescript/cake.js +132 -133
  3. package/lib/coffeescript/coffeescript.js +437 -381
  4. package/lib/coffeescript/command.js +806 -724
  5. package/lib/coffeescript/grammar.js +1908 -2474
  6. package/lib/coffeescript/helpers.js +509 -473
  7. package/lib/coffeescript/index.js +228 -215
  8. package/lib/coffeescript/lexer.js +2282 -1909
  9. package/lib/coffeescript/nodes.js +9782 -9202
  10. package/lib/coffeescript/optparse.js +255 -227
  11. package/lib/coffeescript/parser.js +20305 -1265
  12. package/lib/coffeescript/register.js +107 -87
  13. package/lib/coffeescript/repl.js +307 -284
  14. package/lib/coffeescript/rewriter.js +1389 -1079
  15. package/lib/coffeescript/scope.js +176 -172
  16. package/lib/coffeescript/sourcemap.js +242 -227
  17. package/lib/rew/cli/cli.js +296 -239
  18. package/lib/rew/cli/log.js +27 -27
  19. package/lib/rew/cli/run.js +8 -8
  20. package/lib/rew/cli/utils.js +353 -199
  21. package/lib/rew/const/config_path.js +2 -2
  22. package/lib/rew/const/default.js +38 -53
  23. package/lib/rew/const/files.js +11 -14
  24. package/lib/rew/const/opt.js +6 -6
  25. package/lib/rew/css/theme.css +1 -1
  26. package/lib/rew/functions/core.js +55 -55
  27. package/lib/rew/functions/curl.js +23 -0
  28. package/lib/rew/functions/emitter.js +52 -55
  29. package/lib/rew/functions/exec.js +25 -25
  30. package/lib/rew/functions/export.js +17 -17
  31. package/lib/rew/functions/fs.js +57 -59
  32. package/lib/rew/functions/future.js +29 -21
  33. package/lib/rew/functions/id.js +8 -9
  34. package/lib/rew/functions/import.js +106 -122
  35. package/lib/rew/functions/map.js +10 -10
  36. package/lib/rew/functions/match.js +35 -42
  37. package/lib/rew/functions/path.js +8 -8
  38. package/lib/rew/functions/require.js +32 -36
  39. package/lib/rew/functions/sleep.js +2 -2
  40. package/lib/rew/functions/stdout.js +18 -18
  41. package/lib/rew/functions/types.js +82 -106
  42. package/lib/rew/html/ui.html +12 -12
  43. package/lib/rew/html/ui.js +196 -201
  44. package/lib/rew/main.js +14 -14
  45. package/lib/rew/misc/bin.js +37 -0
  46. package/lib/rew/misc/findAppInfo.js +13 -13
  47. package/lib/rew/misc/findAppPath.js +15 -15
  48. package/lib/rew/misc/req.js +7 -0
  49. package/lib/rew/misc/seededid.js +8 -8
  50. package/lib/rew/models/enum.js +12 -12
  51. package/lib/rew/models/struct.js +30 -32
  52. package/lib/rew/modules/compiler.js +237 -209
  53. package/lib/rew/modules/fs.js +10 -10
  54. package/lib/rew/modules/runtime.js +17 -21
  55. package/lib/rew/modules/yaml.js +27 -30
  56. package/lib/rew/pkgs/conf.js +82 -92
  57. package/lib/rew/pkgs/data.js +10 -10
  58. package/lib/rew/pkgs/date.js +27 -27
  59. package/lib/rew/pkgs/env.js +5 -5
  60. package/lib/rew/pkgs/modules/data/bintree.js +51 -51
  61. package/lib/rew/pkgs/modules/data/doublylinked.js +84 -84
  62. package/lib/rew/pkgs/modules/data/linkedList.js +72 -72
  63. package/lib/rew/pkgs/modules/data/queue.js +18 -18
  64. package/lib/rew/pkgs/modules/data/stack.js +18 -18
  65. package/lib/rew/pkgs/modules/threads/worker.js +36 -36
  66. package/lib/rew/pkgs/modules/ui/classes.js +181 -184
  67. package/lib/rew/pkgs/pkgs.js +9 -9
  68. package/lib/rew/pkgs/rune.js +373 -410
  69. package/lib/rew/pkgs/threads.js +62 -66
  70. package/lib/rew/pkgs/ui.js +148 -160
  71. package/lib/rew/qrew/compile.js +12 -0
  72. package/package.json +4 -3
@@ -1,60 +1,45 @@
1
- const { cenum } = require("../models/enum");
2
- const { struct } = require("../models/struct");
3
- const emitter = require("../functions/emitter");
4
- const future = require("../functions/future");
5
- const sleep = require("../functions/sleep");
6
- const { match } = require("../functions/match");
7
- const { map } = require("../functions/map");
8
- const {
9
- typex,
10
- typeis,
11
- typedef,
12
- typei,
13
- int,
14
- float,
15
- num,
16
- str,
17
- bool,
18
- } = require("../functions/types");
19
- const {
20
- isEmpty,
21
- clone,
22
- deepClone,
23
- merge,
24
- uniqueId,
25
- compose,
26
- curry,
27
- } = require("../functions/core");
28
- const { print, input } = require("../functions/stdout");
1
+ const { cenum } = require('../models/enum');
2
+ const { struct } = require('../models/struct');
3
+ const emitter = require('../functions/emitter');
4
+ const future = require('../functions/future');
5
+ const sleep = require('../functions/sleep');
6
+ const { match } = require('../functions/match');
7
+ const { map } = require('../functions/map');
8
+ const { typex, typeis, typedef, typei, int, float, num, str, bool } = require('../functions/types');
9
+ const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry } = require('../functions/core');
10
+ const { print, input } = require('../functions/stdout');
11
+ const { curl } = require('../functions/curl');
29
12
 
30
13
  module.exports = {
31
- cenum,
32
- struct,
33
- future,
34
- emitter,
35
- sleep,
36
- match,
37
- map,
14
+ cenum,
15
+ struct,
16
+ future,
17
+ emitter,
18
+ sleep,
19
+ match,
20
+ map,
38
21
 
39
- typex,
40
- typei,
41
- typeis,
42
- typedef,
22
+ typex,
23
+ typei,
24
+ typeis,
25
+ typedef,
43
26
 
44
- int,
45
- float,
46
- num,
47
- str,
48
- bool,
27
+ int,
28
+ float,
29
+ num,
30
+ str,
31
+ bool,
49
32
 
50
- isEmpty,
51
- clone,
52
- deepClone,
53
- merge,
54
- uniqueId,
55
- compose,
56
- curry,
33
+ isEmpty,
34
+ clone,
35
+ deepClone,
36
+ merge,
37
+ uniqueId,
38
+ compose,
39
+ curry,
57
40
 
58
- print,
59
- input,
41
+ curl,
42
+
43
+ print,
44
+ input,
60
45
  };
@@ -1,18 +1,15 @@
1
- const fs = require("fs");
2
- const path = require("path");
1
+ const fs = require('fs');
2
+ const path = require('path');
3
3
 
4
- const HOME_PATH = path.resolve(process.env.HOME, ".config/rew/default");
5
- const THEME_PATH = (module.exports.THEME_PATH = path.resolve(
6
- HOME_PATH,
7
- "theme.css",
8
- ));
4
+ const HOME_PATH = path.resolve(process.env.HOME, '.config/rew/default');
5
+ const THEME_PATH = (module.exports.THEME_PATH = path.resolve(HOME_PATH, 'theme.css'));
9
6
 
10
7
  module.exports.FILES = [
11
- {
12
- path: HOME_PATH,
13
- },
14
- {
15
- path: THEME_PATH,
16
- content: fs.readFileSync(path.resolve(__dirname, "../css/theme.css")),
17
- },
8
+ {
9
+ path: HOME_PATH,
10
+ },
11
+ {
12
+ path: THEME_PATH,
13
+ content: fs.readFileSync(path.resolve(__dirname, '../css/theme.css')),
14
+ },
18
15
  ];
@@ -1,10 +1,10 @@
1
1
  const execOptions = {
2
- sharedContext: true,
3
- resolveExtensions: [{ ext: ".js", options: { type: "js" } }, ".coffee"],
4
- nativeRequire: false,
5
- cwdAlias: "$",
6
- jsxPragma: "createElement",
7
- jsx: false,
2
+ sharedContext: true,
3
+ resolveExtensions: [{ ext: '.js', options: { type: 'js' } }, { ext: '.qrew', options: { qrew: true } }, '.coffee'],
4
+ nativeRequire: false,
5
+ cwdAlias: '$',
6
+ jsxPragma: 'createElement',
7
+ jsx: false,
8
8
  };
9
9
 
10
10
  module.exports.execOptions = execOptions;
@@ -1,3 +1,3 @@
1
1
  body {
2
- background-color: #1c2541;
2
+ background-color: #1c2541;
3
3
  }
@@ -1,84 +1,84 @@
1
1
  function isEmpty(value) {
2
- if (Array.isArray(value) || typeof value === "string") {
3
- return value.length === 0;
4
- } else if (typeof value === "object") {
5
- return Object.keys(value).length === 0;
6
- } else {
7
- return true;
8
- }
2
+ if (Array.isArray(value) || typeof value === 'string') {
3
+ return value.length === 0;
4
+ } else if (typeof value === 'object') {
5
+ return Object.keys(value).length === 0;
6
+ } else {
7
+ return true;
8
+ }
9
9
  }
10
10
 
11
11
  function clone(value) {
12
- if (Array.isArray(value)) {
13
- return value.slice();
14
- } else if (typeof value === "object") {
15
- return Object.assign({}, value);
16
- } else {
17
- return value;
18
- }
12
+ if (Array.isArray(value)) {
13
+ return value.slice();
14
+ } else if (typeof value === 'object') {
15
+ return Object.assign({}, value);
16
+ } else {
17
+ return value;
18
+ }
19
19
  }
20
20
 
21
21
  function deepClone(value) {
22
- if (Array.isArray(value)) {
23
- return value.map((item) => deepClone(item));
24
- } else if (typeof value === "object") {
25
- const obj = {};
26
- for (const key in value) {
27
- if (value.hasOwnProperty(key)) {
28
- obj[key] = deepClone(value[key]);
29
- }
30
- }
31
- return obj;
32
- } else {
33
- return value;
34
- }
22
+ if (Array.isArray(value)) {
23
+ return value.map((item) => deepClone(item));
24
+ } else if (typeof value === 'object') {
25
+ const obj = {};
26
+ for (const key in value) {
27
+ if (value.hasOwnProperty(key)) {
28
+ obj[key] = deepClone(value[key]);
29
+ }
30
+ }
31
+ return obj;
32
+ } else {
33
+ return value;
34
+ }
35
35
  }
36
36
 
37
37
  function merge(obj1, obj2) {
38
- return Object.assign({}, obj1, obj2);
38
+ return Object.assign({}, obj1, obj2);
39
39
  }
40
40
 
41
41
  const uniqueId = (() => {
42
- let id = 0;
43
- return () => {
44
- id += 1;
45
- return `id-${id}`;
46
- };
42
+ let id = 0;
43
+ return () => {
44
+ id += 1;
45
+ return `id-${id}`;
46
+ };
47
47
  })();
48
48
 
49
49
  function filter(arr, fn) {
50
- return arr.filter(fn);
50
+ return arr.filter(fn);
51
51
  }
52
52
 
53
53
  function reduce(arr, fn, initial) {
54
- return arr.reduce(fn, initial);
54
+ return arr.reduce(fn, initial);
55
55
  }
56
56
 
57
57
  function compose(...fns) {
58
- return (initialValue) => {
59
- return fns.reduceRight((acc, fn) => fn(acc), initialValue);
60
- };
58
+ return (initialValue) => {
59
+ return fns.reduceRight((acc, fn) => fn(acc), initialValue);
60
+ };
61
61
  }
62
62
 
63
63
  function curry(fn) {
64
- const curried = (...args) => {
65
- if (args.length >= fn.length) {
66
- return fn.apply(null, args);
67
- } else {
68
- return (...moreArgs) => curried.apply(null, args.concat(moreArgs));
69
- }
70
- };
71
- return curried;
64
+ const curried = (...args) => {
65
+ if (args.length >= fn.length) {
66
+ return fn.apply(null, args);
67
+ } else {
68
+ return (...moreArgs) => curried.apply(null, args.concat(moreArgs));
69
+ }
70
+ };
71
+ return curried;
72
72
  }
73
73
 
74
74
  module.exports = {
75
- isEmpty,
76
- clone,
77
- deepClone,
78
- merge,
79
- uniqueId,
80
- filter,
81
- reduce,
82
- compose,
83
- curry,
75
+ isEmpty,
76
+ clone,
77
+ deepClone,
78
+ merge,
79
+ uniqueId,
80
+ filter,
81
+ reduce,
82
+ compose,
83
+ curry,
84
84
  };
@@ -0,0 +1,23 @@
1
+ const future = require("./future");
2
+ const fs = require('fs');
3
+
4
+ module.exports.curl = function curl(options, url){
5
+ if(typeof options == 'string'){
6
+ let newurl = options;
7
+ options = typeof url == "object" ? url : {};
8
+ url = newurl;
9
+ }
10
+ if(options.url && !url){
11
+ url = options.url
12
+ }
13
+ const method = options.x || "GET";
14
+ const f = future.promise(fetch(url, {
15
+ ...options,
16
+ method
17
+ }).then(async r => {
18
+ if(options.o) fs.writeFileSync(options.o, Buffer.from(await r.clone().arrayBuffer()));
19
+ return r;
20
+ }).then(r => options.json ? r.clone().json() : r));
21
+ if(options.a) return f.wait();
22
+ else return f;
23
+ }
@@ -1,57 +1,54 @@
1
1
  module.exports = function emitter() {
2
- const events = [];
3
- const on = (event, callback, props = {}) => {
4
- const addEvent = (event) => events.push({ ...props, event, callback });
5
- if (Array.isArray(event)) {
6
- event.forEach(addEvent);
7
- } else {
8
- addEvent(event);
9
- }
10
- return listener;
11
- };
12
- const off = (event, callback, removable = null) => {
13
- const rm = (event) => {
14
- if (removable) {
15
- removable(event);
16
- }
17
- events.splice(events.indexOf(event), 1);
18
- };
19
- const rmEvent = (event) => {
20
- if (callback) {
21
- const _events = events.filter(({ callback: c }) => c == callback);
22
- _events.forEach((e) => {
23
- if (Array.isArray(event)) {
24
- if (event.includes(e.event)) rm(e);
25
- } else {
26
- if (e.event == event) rm(e);
27
- }
28
- });
29
- } else {
30
- const _events = events.filter(({ event: e }) => e == event);
31
- _events.forEach((e) => {
32
- rm(e);
33
- });
34
- }
35
- };
36
- if (Array.isArray(event)) {
37
- event.forEach(rmEvent);
38
- } else {
39
- rmEvent(event);
40
- }
41
- return listener;
42
- };
43
- const emit = (event, ...data) => {
44
- const emitEvent = (event) =>
45
- events
46
- .filter(({ event: e }) => e == event)
47
- .forEach(({ callback }) => callback(...data));
48
- if (Array.isArray(event)) {
49
- event.forEach(emitEvent);
50
- } else {
51
- emitEvent(event);
52
- }
53
- return listener;
54
- };
55
- const listener = { on, off, emit };
56
- return listener;
2
+ const events = [];
3
+ const on = (event, callback, props = {}) => {
4
+ const addEvent = (event) => events.push({ ...props, event, callback });
5
+ if (Array.isArray(event)) {
6
+ event.forEach(addEvent);
7
+ } else {
8
+ addEvent(event);
9
+ }
10
+ return listener;
11
+ };
12
+ const off = (event, callback, removable = null) => {
13
+ const rm = (event) => {
14
+ if (removable) {
15
+ removable(event);
16
+ }
17
+ events.splice(events.indexOf(event), 1);
18
+ };
19
+ const rmEvent = (event) => {
20
+ if (callback) {
21
+ const _events = events.filter(({ callback: c }) => c == callback);
22
+ _events.forEach((e) => {
23
+ if (Array.isArray(event)) {
24
+ if (event.includes(e.event)) rm(e);
25
+ } else {
26
+ if (e.event == event) rm(e);
27
+ }
28
+ });
29
+ } else {
30
+ const _events = events.filter(({ event: e }) => e == event);
31
+ _events.forEach((e) => {
32
+ rm(e);
33
+ });
34
+ }
35
+ };
36
+ if (Array.isArray(event)) {
37
+ event.forEach(rmEvent);
38
+ } else {
39
+ rmEvent(event);
40
+ }
41
+ return listener;
42
+ };
43
+ const emit = (event, ...data) => {
44
+ const emitEvent = (event) => events.filter(({ event: e }) => e == event).forEach(({ callback }) => callback(...data));
45
+ if (Array.isArray(event)) {
46
+ event.forEach(emitEvent);
47
+ } else {
48
+ emitEvent(event);
49
+ }
50
+ return listener;
51
+ };
52
+ const listener = { on, off, emit };
53
+ return listener;
57
54
  };
@@ -1,31 +1,31 @@
1
- const shell = require("child_process");
1
+ const shell = require('child_process');
2
2
 
3
3
  module.exports = (currentFile) => {
4
- function exec(command, options) {
5
- return shell.execSync(command, {
6
- stdio: options?.output == false ? null : "inherit",
7
- });
8
- }
4
+ function exec(command, options) {
5
+ return shell.execSync(command, {
6
+ stdio: options?.output == false ? null : 'inherit',
7
+ });
8
+ }
9
9
 
10
- exec.background = function execAsync(command, options, callback) {
11
- if (typeof options == "function" && !callback) {
12
- callback = options;
13
- options = {};
14
- }
15
- if (!options) options = {};
16
- if (!callback) callback = () => {};
17
- return shell.exec(
18
- command,
19
- {
20
- ...options,
21
- },
22
- callback,
23
- );
24
- };
10
+ exec.background = function execAsync(command, options, callback) {
11
+ if (typeof options == 'function' && !callback) {
12
+ callback = options;
13
+ options = {};
14
+ }
15
+ if (!options) options = {};
16
+ if (!callback) callback = () => {};
17
+ return shell.exec(
18
+ command,
19
+ {
20
+ ...options,
21
+ },
22
+ callback,
23
+ );
24
+ };
25
25
 
26
- function spawn(command, options) {
27
- return shell.spawn(command, options);
28
- }
26
+ function spawn(command, options) {
27
+ return shell.spawn(command, options);
28
+ }
29
29
 
30
- return { exec, spawn };
30
+ return { exec, spawn };
31
31
  };
@@ -1,25 +1,25 @@
1
1
  function exportsThe(item, name, context) {
2
- if (name) {
3
- if (!context.module.exports) context.module.exports = {};
4
- context.module.exports[name] = item;
5
- } else {
6
- if (context.module.exports) context.module.exports.default = item;
7
- else context.module.exports = item;
8
- }
2
+ if (name) {
3
+ if (!context.module.exports) context.module.exports = {};
4
+ context.module.exports[name] = item;
5
+ } else {
6
+ if (context.module.exports) context.module.exports.default = item;
7
+ else context.module.exports = item;
8
+ }
9
9
  }
10
10
 
11
11
  module.exports.pubFunction = function (context) {
12
- return function (name, item) {
13
- if (name && !item) {
14
- item = name;
15
- name = null;
16
- }
17
- exportsThe(item, name, context);
18
- };
12
+ return function (name, item) {
13
+ if (name && !item) {
14
+ item = name;
15
+ name = null;
16
+ }
17
+ exportsThe(item, name, context);
18
+ };
19
19
  };
20
20
 
21
21
  module.exports.exportsFunction = function (context) {
22
- return function (item, name) {
23
- exportsThe(item, name, context);
24
- };
22
+ return function (item, name) {
23
+ exportsThe(item, name, context);
24
+ };
25
25
  };
@@ -1,62 +1,60 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const { execOptions } = require("../const/opt");
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { execOptions } = require('../const/opt');
4
4
 
5
5
  module.exports = (currentFile) => {
6
- function gp(filepath) {
7
- return path.resolve(
8
- filepath.startsWith(execOptions.cwdAlias)
9
- ? process.cwd()
10
- : path.dirname(currentFile),
11
- filepath.replaceAll(execOptions.cwdAlias + "/", ""),
12
- );
13
- }
14
-
15
- function read(filepath, options = { encoding: "utf-8" }) {
16
- return fs.readFileSync(gp(filepath), options);
17
- }
18
-
19
- function realpath(filepath, options = { encoding: "utf-8" }) {
20
- return gp(filepath);
21
- }
22
-
23
- function write(filepath, content, options) {
24
- return fs.writeFileSync(gp(filepath), content, options);
25
- }
26
-
27
- function exists(filepath, options) {
28
- return fs.existsSync(gp(filepath));
29
- }
30
-
31
- function fstat(filepath, options) {
32
- return fs.statSync(gp(filepath), options);
33
- }
34
-
35
- function rm(filepath, options) {
36
- return fs.unlinkSync(filepath);
37
- }
38
-
39
- function chmod(filepath, mode, options) {
40
- return fs.chmodSync(gp(filepath), mode);
41
- }
42
-
43
- function mkdir(filepath, options) {
44
- return fs.mkdirSync(gp(filepath), options);
45
- }
46
-
47
- function ls(filepath, options) {
48
- return fs.readdirSync(gp(filepath), options);
49
- }
50
-
51
- return {
52
- ls,
53
- mkdir,
54
- chmod,
55
- rm,
56
- fstat,
57
- exists,
58
- write,
59
- read,
60
- realpath,
61
- };
6
+ function gp(filepath) {
7
+ return path.resolve(
8
+ filepath.startsWith(execOptions.cwdAlias) ? process.cwd() : path.dirname(currentFile),
9
+ filepath.replaceAll(execOptions.cwdAlias + '/', ''),
10
+ );
11
+ }
12
+
13
+ function read(filepath, options = { encoding: 'utf-8' }) {
14
+ return fs.readFileSync(gp(filepath), options);
15
+ }
16
+
17
+ function realpath(filepath, options = { encoding: 'utf-8' }) {
18
+ return gp(filepath);
19
+ }
20
+
21
+ function write(filepath, content, options) {
22
+ return fs.writeFileSync(gp(filepath), content, options);
23
+ }
24
+
25
+ function exists(filepath, options) {
26
+ return fs.existsSync(gp(filepath));
27
+ }
28
+
29
+ function fstat(filepath, options) {
30
+ return fs.statSync(gp(filepath), options);
31
+ }
32
+
33
+ function rm(filepath, options) {
34
+ return fs.unlinkSync(filepath);
35
+ }
36
+
37
+ function chmod(filepath, mode, options) {
38
+ return fs.chmodSync(gp(filepath), mode);
39
+ }
40
+
41
+ function mkdir(filepath, options) {
42
+ return fs.mkdirSync(gp(filepath), options);
43
+ }
44
+
45
+ function ls(filepath, options) {
46
+ return fs.readdirSync(gp(filepath), options);
47
+ }
48
+
49
+ return {
50
+ ls,
51
+ mkdir,
52
+ chmod,
53
+ rm,
54
+ fstat,
55
+ exists,
56
+ write,
57
+ read,
58
+ realpath,
59
+ };
62
60
  };