@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,36 +1,33 @@
1
- const yaml = require("js-yaml");
2
- const path = require("path");
3
- const { getFile } = require("./fs");
1
+ const yaml = require('js-yaml');
2
+ const path = require('path');
3
+ const { getFile } = require('./fs');
4
4
 
5
5
  function yamlFile(file) {
6
- const schema = new yaml.Schema([
7
- new yaml.Type("!import", {
8
- kind: "scalar",
9
- construct: (p) => importYaml(path.resolve(path.dirname(file.path), p)),
10
- }),
11
- new yaml.Type("!int", {
12
- kind: "scalar",
13
- construct: (data) => parseInt(data),
14
- }),
15
- new yaml.Type("!float", {
16
- kind: "scalar",
17
- construct: (data) => parseFloat(data),
18
- }),
19
- new yaml.Type("!bool", {
20
- kind: "scalar",
21
- construct: (data) => (data == "true" ? true : false),
22
- }),
23
- ]);
6
+ const schema = new yaml.Schema([
7
+ new yaml.Type('!import', {
8
+ kind: 'scalar',
9
+ construct: (p) => importYaml(path.resolve(path.dirname(file.path), p)),
10
+ }),
11
+ new yaml.Type('!int', {
12
+ kind: 'scalar',
13
+ construct: (data) => parseInt(data),
14
+ }),
15
+ new yaml.Type('!float', {
16
+ kind: 'scalar',
17
+ construct: (data) => parseFloat(data),
18
+ }),
19
+ new yaml.Type('!bool', {
20
+ kind: 'scalar',
21
+ construct: (data) => (data == 'true' ? true : false),
22
+ }),
23
+ ]);
24
24
 
25
- return yaml.load(file.content, { schema });
25
+ return yaml.load(file.content, { schema });
26
26
  }
27
27
 
28
- const importYaml = (module.exports.importYaml = function importYaml(
29
- filepath,
30
- file,
31
- ) {
32
- if (!file) {
33
- file = getFile(filepath);
34
- }
35
- return yamlFile(file);
28
+ const importYaml = (module.exports.importYaml = function importYaml(filepath, file) {
29
+ if (!file) {
30
+ file = getFile(filepath);
31
+ }
32
+ return yamlFile(file);
36
33
  });
@@ -1,109 +1,99 @@
1
- const fs = require("fs");
2
- const jsYaml = require("js-yaml");
3
- const path = require("path");
4
- const { CONFIG_PATH } = require("../const/config_path");
5
- const { seededID } = require("../misc/seededid");
1
+ const fs = require('fs');
2
+ const jsYaml = require('js-yaml');
3
+ const path = require('path');
4
+ const { CONFIG_PATH } = require('../const/config_path');
5
+ const { seededID } = require('../misc/seededid');
6
6
 
7
7
  const createPackageRoot = (packageName) => {
8
- const rootPath = path.join(CONFIG_PATH, packageName);
9
- fs.mkdirSync(rootPath, { recursive: true });
10
- return rootPath;
8
+ const rootPath = path.join(CONFIG_PATH, packageName);
9
+ fs.mkdirSync(rootPath, { recursive: true });
10
+ return rootPath;
11
11
  };
12
12
 
13
13
  module.exports = (context) => ({
14
- CONFIG_PATH,
15
- _onImport() {
16
- if (context.app) {
17
- return this.create(context.app.config.package);
18
- } else {
19
- return this.create(
20
- seededID(
21
- path.basename(context.module.filepath).replace(/[-_/\.]/g, ""),
22
- ),
23
- );
24
- }
25
- },
26
- create: (packageName) => {
27
- const rootPath = createPackageRoot(packageName);
14
+ CONFIG_PATH,
15
+ _onImport() {
16
+ if (context.app) {
17
+ return this.create(context.app.config.package);
18
+ } else {
19
+ return this.create(seededID(path.basename(context.module.filepath).replace(/[-_/\.]/g, '')));
20
+ }
21
+ },
22
+ create: (packageName) => {
23
+ const rootPath = createPackageRoot(packageName);
28
24
 
29
- const conf = {};
25
+ const conf = {};
30
26
 
31
- const dumpYaml = (val) => {
32
- if (JSON.stringify(val) == "{}") return "";
33
- else return jsYaml.dump(val);
34
- };
27
+ const dumpYaml = (val) => {
28
+ if (JSON.stringify(val) == '{}') return '';
29
+ else return jsYaml.dump(val);
30
+ };
35
31
 
36
- const setData = (optionCenter, key, value) => {
37
- conf[optionCenter.name][key] = value;
38
- fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
39
- return true;
40
- };
32
+ const setData = (optionCenter, key, value) => {
33
+ conf[optionCenter.name][key] = value;
34
+ fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
35
+ return true;
36
+ };
41
37
 
42
- const removeData = (optionCenter, key) => {
43
- delete conf[optionCenter.name][key];
44
- fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
45
- return true;
46
- };
38
+ const removeData = (optionCenter, key) => {
39
+ delete conf[optionCenter.name][key];
40
+ fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
41
+ return true;
42
+ };
47
43
 
48
- const getData = (optionCenter, key) => {
49
- return conf[optionCenter.name][key];
50
- };
44
+ const getData = (optionCenter, key) => {
45
+ return conf[optionCenter.name][key];
46
+ };
51
47
 
52
- const staticFile = (name, defaultValue = "") => {
53
- const fileRoot = path.join(rootPath, name);
54
- const exists = fs.existsSync(fileRoot);
55
- return {
56
- create(value) {
57
- if (!fs.existsSync(path.dirname(fileRoot)))
58
- fs.mkdirSync(path.dirname(fileRoot), { recursive: true });
59
- fs.writeFileSync(fileRoot, value || defaultValue);
60
- },
61
- fileRoot,
62
- exists,
63
- };
64
- };
48
+ const staticFile = (name, defaultValue = '') => {
49
+ const fileRoot = path.join(rootPath, name);
50
+ const exists = fs.existsSync(fileRoot);
51
+ return {
52
+ create(value) {
53
+ if (!fs.existsSync(path.dirname(fileRoot))) fs.mkdirSync(path.dirname(fileRoot), { recursive: true });
54
+ fs.writeFileSync(fileRoot, value || defaultValue);
55
+ },
56
+ fileRoot,
57
+ exists,
58
+ };
59
+ };
65
60
 
66
- const createOptionCenter = (name, defaults = {}) => {
67
- const optionRoot = path.join(rootPath, name + ".yaml");
68
- if (!fs.existsSync(path.dirname(optionRoot)))
69
- fs.mkdirSync(path.dirname(optionRoot), { recursive: true });
70
- if (!fs.existsSync(optionRoot)) {
71
- conf[name] = defaults;
72
- fs.writeFileSync(optionRoot, dumpYaml(defaults));
73
- } else {
74
- conf[name] = jsYaml.load(
75
- fs.readFileSync(optionRoot, { encoding: "utf-8" }),
76
- );
77
- }
61
+ const createOptionCenter = (name, defaults = {}) => {
62
+ const optionRoot = path.join(rootPath, name + '.yaml');
63
+ if (!fs.existsSync(path.dirname(optionRoot))) fs.mkdirSync(path.dirname(optionRoot), { recursive: true });
64
+ if (!fs.existsSync(optionRoot)) {
65
+ conf[name] = defaults;
66
+ fs.writeFileSync(optionRoot, dumpYaml(defaults));
67
+ } else {
68
+ conf[name] = jsYaml.load(fs.readFileSync(optionRoot, { encoding: 'utf-8' }));
69
+ }
78
70
 
79
- const optionCenter = {
80
- root: optionRoot,
81
- name,
82
- package: packageName,
83
- };
71
+ const optionCenter = {
72
+ root: optionRoot,
73
+ name,
74
+ package: packageName,
75
+ };
84
76
 
85
- return {
86
- get: (key) => getData(optionCenter, key),
87
- set: (key, value) => setData(optionCenter, key, value),
88
- remove: (key) => removeData(optionCenter, key),
89
- reset: () =>
90
- fs.writeFileSync(optionCenter.root, dumpYaml(defaults)) &&
91
- (conf[name] = defaults),
92
- getAll: (str = false) => (str ? dumpYaml(conf[name]) : conf[name]),
93
- ...optionCenter,
94
- };
95
- };
77
+ return {
78
+ get: (key, defaultValue) => getData(optionCenter, key) || defaultValue,
79
+ set: (key, value) => setData(optionCenter, key, value),
80
+ remove: (key) => removeData(optionCenter, key),
81
+ reset: () => fs.writeFileSync(optionCenter.root, dumpYaml(defaults)) && (conf[name] = defaults),
82
+ getAll: (str = false) => (str ? dumpYaml(conf[name]) : conf[name]),
83
+ ...optionCenter,
84
+ };
85
+ };
96
86
 
97
- const defaultCenter = createOptionCenter("_default", { default: true });
87
+ const defaultCenter = createOptionCenter('_default', { default: true });
98
88
 
99
- return {
100
- optionCenter: createOptionCenter,
101
- staticFile: staticFile,
102
- set: (key, value) => defaultCenter.set(key, value),
103
- get: (key) => defaultCenter.get(key),
104
- remove: (key) => defaultCenter.remove(key),
105
- root: rootPath,
106
- package: packageName,
107
- };
108
- },
89
+ return {
90
+ optionCenter: createOptionCenter,
91
+ staticFile: staticFile,
92
+ set: (key, value) => defaultCenter.set(key, value),
93
+ get: (key, defaultValue) => defaultCenter.get(key, defaultValue),
94
+ remove: (key) => defaultCenter.remove(key),
95
+ root: rootPath,
96
+ package: packageName,
97
+ };
98
+ },
109
99
  });
@@ -1,13 +1,13 @@
1
- const { BinaryTree } = require("./modules/data/bintree");
2
- const { DoublyLinkedList } = require("./modules/data/doublylinked");
3
- const { LinkedList } = require("./modules/data/linkedList");
4
- const { Queue } = require("./modules/data/queue");
5
- const { Stack } = require("./modules/data/stack");
1
+ const { BinaryTree } = require('./modules/data/bintree');
2
+ const { DoublyLinkedList } = require('./modules/data/doublylinked');
3
+ const { LinkedList } = require('./modules/data/linkedList');
4
+ const { Queue } = require('./modules/data/queue');
5
+ const { Stack } = require('./modules/data/stack');
6
6
 
7
7
  module.exports = (context) => ({
8
- Stack,
9
- Queue,
10
- BinaryTree,
11
- DoublyLinkedList,
12
- LinkedList,
8
+ Stack,
9
+ Queue,
10
+ BinaryTree,
11
+ DoublyLinkedList,
12
+ LinkedList,
13
13
  });
@@ -8,10 +8,10 @@
8
8
  * @return {string} - The formatted date string.
9
9
  */
10
10
  function formatDate(date) {
11
- const year = date.getFullYear();
12
- const month = String(date.getMonth() + 1).padStart(2, "0");
13
- const day = String(date.getDate()).padStart(2, "0");
14
- return `${year}-${month}-${day}`;
11
+ const year = date.getFullYear();
12
+ const month = String(date.getMonth() + 1).padStart(2, '0');
13
+ const day = String(date.getDate()).padStart(2, '0');
14
+ return `${year}-${month}-${day}`;
15
15
  }
16
16
 
17
17
  /**
@@ -20,10 +20,10 @@ function formatDate(date) {
20
20
  * @return {string} - The formatted time string.
21
21
  */
22
22
  function formatTime(date) {
23
- const hours = String(date.getHours()).padStart(2, "0");
24
- const minutes = String(date.getMinutes()).padStart(2, "0");
25
- const seconds = String(date.getSeconds()).padStart(2, "0");
26
- return `${hours}:${minutes}:${seconds}`;
23
+ const hours = String(date.getHours()).padStart(2, '0');
24
+ const minutes = String(date.getMinutes()).padStart(2, '0');
25
+ const seconds = String(date.getSeconds()).padStart(2, '0');
26
+ return `${hours}:${minutes}:${seconds}`;
27
27
  }
28
28
 
29
29
  // Parsing Functions
@@ -34,8 +34,8 @@ function formatTime(date) {
34
34
  * @return {Date} - The parsed date object.
35
35
  */
36
36
  function parseDate(dateString) {
37
- const [year, month, day] = dateString.split("-").map(Number);
38
- return new Date(year, month - 1, day);
37
+ const [year, month, day] = dateString.split('-').map(Number);
38
+ return new Date(year, month - 1, day);
39
39
  }
40
40
 
41
41
  /**
@@ -44,10 +44,10 @@ function parseDate(dateString) {
44
44
  * @return {Date} - The parsed date object.
45
45
  */
46
46
  function parseTime(timeString) {
47
- const [hours, minutes, seconds] = timeString.split(":").map(Number);
48
- const date = new Date();
49
- date.setHours(hours, minutes, seconds, 0);
50
- return date;
47
+ const [hours, minutes, seconds] = timeString.split(':').map(Number);
48
+ const date = new Date();
49
+ date.setHours(hours, minutes, seconds, 0);
50
+ return date;
51
51
  }
52
52
 
53
53
  // Arithmetic Functions
@@ -59,9 +59,9 @@ function parseTime(timeString) {
59
59
  * @return {Date} - The new date object.
60
60
  */
61
61
  function addDays(date, days) {
62
- const result = new Date(date);
63
- result.setDate(result.getDate() + days);
64
- return result;
62
+ const result = new Date(date);
63
+ result.setDate(result.getDate() + days);
64
+ return result;
65
65
  }
66
66
 
67
67
  /**
@@ -71,7 +71,7 @@ function addDays(date, days) {
71
71
  * @return {Date} - The new date object.
72
72
  */
73
73
  function subtractDays(date, days) {
74
- return addDays(date, -days);
74
+ return addDays(date, -days);
75
75
  }
76
76
 
77
77
  /**
@@ -81,17 +81,17 @@ function subtractDays(date, days) {
81
81
  * @return {number} - The difference in days.
82
82
  */
83
83
  function differenceInDays(date1, date2) {
84
- const diffTime = date2 - date1;
85
- return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
84
+ const diffTime = date2 - date1;
85
+ return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
86
86
  }
87
87
 
88
88
  // Exporting the functions as a CommonJS module
89
89
  module.exports = () => ({
90
- formatDate,
91
- formatTime,
92
- parseDate,
93
- parseTime,
94
- addDays,
95
- subtractDays,
96
- differenceInDays,
90
+ formatDate,
91
+ formatTime,
92
+ parseDate,
93
+ parseTime,
94
+ addDays,
95
+ subtractDays,
96
+ differenceInDays,
97
97
  });
@@ -1,7 +1,7 @@
1
1
  module.exports = (context) => ({
2
- has: (key) => key in process.env,
3
- get: (key) => process.env[key],
4
- set: (key, value) => (process.env[key] = value),
5
- rm: (key) => delete process.env[key],
6
- is: (key, value) => process.env[key] == value,
2
+ has: (key) => key in process.env,
3
+ get: (key) => process.env[key],
4
+ set: (key, value) => (process.env[key] = value),
5
+ rm: (key) => delete process.env[key],
6
+ is: (key, value) => process.env[key] == value,
7
7
  });
@@ -1,64 +1,64 @@
1
1
  class TreeNode {
2
- constructor(value) {
3
- this.value = value;
4
- this.left = null;
5
- this.right = null;
6
- }
2
+ constructor(value) {
3
+ this.value = value;
4
+ this.left = null;
5
+ this.right = null;
6
+ }
7
7
  }
8
8
 
9
9
  class BinaryTree {
10
- constructor() {
11
- this.root = null;
12
- }
10
+ constructor() {
11
+ this.root = null;
12
+ }
13
13
 
14
- insert(value) {
15
- const newNode = new TreeNode(value);
16
- if (!this.root) {
17
- this.root = newNode;
18
- return;
19
- }
14
+ insert(value) {
15
+ const newNode = new TreeNode(value);
16
+ if (!this.root) {
17
+ this.root = newNode;
18
+ return;
19
+ }
20
20
 
21
- const insertNode = (node) => {
22
- if (value < node.value) {
23
- if (!node.left) {
24
- node.left = newNode;
25
- } else {
26
- insertNode(node.left);
27
- }
28
- } else {
29
- if (!node.right) {
30
- node.right = newNode;
31
- } else {
32
- insertNode(node.right);
33
- }
34
- }
35
- };
21
+ const insertNode = (node) => {
22
+ if (value < node.value) {
23
+ if (!node.left) {
24
+ node.left = newNode;
25
+ } else {
26
+ insertNode(node.left);
27
+ }
28
+ } else {
29
+ if (!node.right) {
30
+ node.right = newNode;
31
+ } else {
32
+ insertNode(node.right);
33
+ }
34
+ }
35
+ };
36
36
 
37
- insertNode(this.root);
38
- }
37
+ insertNode(this.root);
38
+ }
39
39
 
40
- find(value) {
41
- const findNode = (node) => {
42
- if (!node) return null;
43
- if (node.value === value) return node;
44
- if (value < node.value) return findNode(node.left);
45
- return findNode(node.right);
46
- };
40
+ find(value) {
41
+ const findNode = (node) => {
42
+ if (!node) return null;
43
+ if (node.value === value) return node;
44
+ if (value < node.value) return findNode(node.left);
45
+ return findNode(node.right);
46
+ };
47
47
 
48
- return findNode(this.root);
49
- }
48
+ return findNode(this.root);
49
+ }
50
50
 
51
- toArray() {
52
- const elements = [];
53
- const traverse = (node) => {
54
- if (!node) return;
55
- traverse(node.left);
56
- elements.push(node.value);
57
- traverse(node.right);
58
- };
59
- traverse(this.root);
60
- return elements;
61
- }
51
+ toArray() {
52
+ const elements = [];
53
+ const traverse = (node) => {
54
+ if (!node) return;
55
+ traverse(node.left);
56
+ elements.push(node.value);
57
+ traverse(node.right);
58
+ };
59
+ traverse(this.root);
60
+ return elements;
61
+ }
62
62
  }
63
63
 
64
64
  BinaryTree.Node = TreeNode;