@makano/rew 1.0.1

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 (58) hide show
  1. package/bin/rew +9 -0
  2. package/bin/ui +0 -0
  3. package/bin/webkit_app +0 -0
  4. package/lib/coffeescript/browser.js +151 -0
  5. package/lib/coffeescript/cake.js +135 -0
  6. package/lib/coffeescript/coffeescript.js +409 -0
  7. package/lib/coffeescript/command.js +750 -0
  8. package/lib/coffeescript/grammar.js +2496 -0
  9. package/lib/coffeescript/helpers.js +477 -0
  10. package/lib/coffeescript/index.js +217 -0
  11. package/lib/coffeescript/lexer.js +1943 -0
  12. package/lib/coffeescript/nodes.js +9204 -0
  13. package/lib/coffeescript/optparse.js +230 -0
  14. package/lib/coffeescript/parser.js +1344 -0
  15. package/lib/coffeescript/register.js +100 -0
  16. package/lib/coffeescript/repl.js +305 -0
  17. package/lib/coffeescript/rewriter.js +1138 -0
  18. package/lib/coffeescript/scope.js +187 -0
  19. package/lib/coffeescript/sourcemap.js +229 -0
  20. package/lib/rew/cli/cli.js +117 -0
  21. package/lib/rew/cli/log.js +40 -0
  22. package/lib/rew/cli/run.js +20 -0
  23. package/lib/rew/cli/utils.js +122 -0
  24. package/lib/rew/const/default.js +35 -0
  25. package/lib/rew/const/files.js +15 -0
  26. package/lib/rew/css/theme.css +3 -0
  27. package/lib/rew/functions/core.js +85 -0
  28. package/lib/rew/functions/emitter.js +57 -0
  29. package/lib/rew/functions/export.js +9 -0
  30. package/lib/rew/functions/future.js +22 -0
  31. package/lib/rew/functions/id.js +13 -0
  32. package/lib/rew/functions/import.js +57 -0
  33. package/lib/rew/functions/map.js +17 -0
  34. package/lib/rew/functions/match.js +34 -0
  35. package/lib/rew/functions/sleep.js +5 -0
  36. package/lib/rew/functions/types.js +96 -0
  37. package/lib/rew/html/ui.html +223 -0
  38. package/lib/rew/main.js +17 -0
  39. package/lib/rew/models/enum.js +14 -0
  40. package/lib/rew/models/struct.js +41 -0
  41. package/lib/rew/modules/compiler.js +17 -0
  42. package/lib/rew/modules/context.js +50 -0
  43. package/lib/rew/modules/fs.js +19 -0
  44. package/lib/rew/modules/runtime.js +24 -0
  45. package/lib/rew/modules/utils.js +0 -0
  46. package/lib/rew/modules/yaml.js +36 -0
  47. package/lib/rew/pkgs/conf.js +92 -0
  48. package/lib/rew/pkgs/data.js +8 -0
  49. package/lib/rew/pkgs/date.js +98 -0
  50. package/lib/rew/pkgs/modules/data/bintree.js +66 -0
  51. package/lib/rew/pkgs/modules/data/doublylinked.js +100 -0
  52. package/lib/rew/pkgs/modules/data/linkedList.js +88 -0
  53. package/lib/rew/pkgs/modules/data/queue.js +28 -0
  54. package/lib/rew/pkgs/modules/data/stack.js +27 -0
  55. package/lib/rew/pkgs/modules/ui/classes.js +171 -0
  56. package/lib/rew/pkgs/pkgs.js +13 -0
  57. package/lib/rew/pkgs/ui.js +108 -0
  58. package/package.json +41 -0
@@ -0,0 +1,230 @@
1
+ // Generated by CoffeeScript 2.7.0
2
+ (function() {
3
+ var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat,
4
+ splice = [].splice;
5
+
6
+ ({repeat} = require('./helpers'));
7
+
8
+ // A simple **OptionParser** class to parse option flags from the command-line.
9
+ // Use it like so:
10
+
11
+ // parser = new OptionParser switches, helpBanner
12
+ // options = parser.parse process.argv
13
+
14
+ // The first non-option is considered to be the start of the file (and file
15
+ // option) list, and all subsequent arguments are left unparsed.
16
+
17
+ // The `coffee` command uses an instance of **OptionParser** to parse its
18
+ // command-line arguments in `src/command.coffee`.
19
+ exports.OptionParser = OptionParser = class OptionParser {
20
+ // Initialize with a list of valid options, in the form:
21
+
22
+ // [short-flag, long-flag, description]
23
+
24
+ // Along with an optional banner for the usage help.
25
+ constructor(ruleDeclarations, banner) {
26
+ this.banner = banner;
27
+ this.rules = buildRules(ruleDeclarations);
28
+ }
29
+
30
+ // Parse the list of arguments, populating an `options` object with all of the
31
+ // specified options, and return it. Options after the first non-option
32
+ // argument are treated as arguments. `options.arguments` will be an array
33
+ // containing the remaining arguments. This is a simpler API than many option
34
+ // parsers that allow you to attach callback actions for every flag. Instead,
35
+ // you're responsible for interpreting the options object.
36
+ parse(args) {
37
+ var argument, hasArgument, i, isList, len, name, options, positional, rules;
38
+ // The CoffeeScript option parser is a little odd; options after the first
39
+ // non-option argument are treated as non-option arguments themselves.
40
+ // Optional arguments are normalized by expanding merged flags into multiple
41
+ // flags. This allows you to have `-wl` be the same as `--watch --lint`.
42
+ // Note that executable scripts with a shebang (`#!`) line should use the
43
+ // line `#!/usr/bin/env coffee`, or `#!/absolute/path/to/coffee`, without a
44
+ // `--` argument after, because that will fail on Linux (see #3946).
45
+ ({rules, positional} = normalizeArguments(args, this.rules.flagDict));
46
+ options = {};
47
+ // The `argument` field is added to the rule instance non-destructively by
48
+ // `normalizeArguments`.
49
+ for (i = 0, len = rules.length; i < len; i++) {
50
+ ({hasArgument, argument, isList, name} = rules[i]);
51
+ if (hasArgument) {
52
+ if (isList) {
53
+ if (options[name] == null) {
54
+ options[name] = [];
55
+ }
56
+ options[name].push(argument);
57
+ } else {
58
+ options[name] = argument;
59
+ }
60
+ } else {
61
+ options[name] = true;
62
+ }
63
+ }
64
+ if (positional[0] === '--') {
65
+ options.doubleDashed = true;
66
+ positional = positional.slice(1);
67
+ }
68
+ options.arguments = positional;
69
+ return options;
70
+ }
71
+
72
+ // Return the help text for this **OptionParser**, listing and describing all
73
+ // of the valid options, for `--help` and such.
74
+ help() {
75
+ var i, len, letPart, lines, ref, rule, spaces;
76
+ lines = [];
77
+ if (this.banner) {
78
+ lines.unshift(`${this.banner}\n`);
79
+ }
80
+ ref = this.rules.ruleList;
81
+ for (i = 0, len = ref.length; i < len; i++) {
82
+ rule = ref[i];
83
+ spaces = 15 - rule.longFlag.length;
84
+ spaces = spaces > 0 ? repeat(' ', spaces) : '';
85
+ letPart = rule.shortFlag ? rule.shortFlag + ', ' : ' ';
86
+ lines.push(' ' + letPart + rule.longFlag + spaces + rule.description);
87
+ }
88
+ return `\n${lines.join('\n')}\n`;
89
+ }
90
+
91
+ };
92
+
93
+ // Helpers
94
+ // -------
95
+
96
+ // Regex matchers for option flags on the command line and their rules.
97
+ LONG_FLAG = /^(--\w[\w\-]*)/;
98
+
99
+ SHORT_FLAG = /^(-\w)$/;
100
+
101
+ MULTI_FLAG = /^-(\w{2,})/;
102
+
103
+ // Matches the long flag part of a rule for an option with an argument. Not
104
+ // applied to anything in process.argv.
105
+ OPTIONAL = /\[(\w+(\*?))\]/;
106
+
107
+ // Build and return the list of option rules. If the optional *short-flag* is
108
+ // unspecified, leave it out by padding with `null`.
109
+ buildRules = function(ruleDeclarations) {
110
+ var flag, flagDict, i, j, len, len1, ref, rule, ruleList, tuple;
111
+ ruleList = (function() {
112
+ var i, len, results;
113
+ results = [];
114
+ for (i = 0, len = ruleDeclarations.length; i < len; i++) {
115
+ tuple = ruleDeclarations[i];
116
+ if (tuple.length < 3) {
117
+ tuple.unshift(null);
118
+ }
119
+ results.push(buildRule(...tuple));
120
+ }
121
+ return results;
122
+ })();
123
+ flagDict = {};
124
+ for (i = 0, len = ruleList.length; i < len; i++) {
125
+ rule = ruleList[i];
126
+ ref = [rule.shortFlag, rule.longFlag];
127
+ // `shortFlag` is null if not provided in the rule.
128
+ for (j = 0, len1 = ref.length; j < len1; j++) {
129
+ flag = ref[j];
130
+ if (!(flag != null)) {
131
+ continue;
132
+ }
133
+ if (flagDict[flag] != null) {
134
+ throw new Error(`flag ${flag} for switch ${rule.name} was already declared for switch ${flagDict[flag].name}`);
135
+ }
136
+ flagDict[flag] = rule;
137
+ }
138
+ }
139
+ return {ruleList, flagDict};
140
+ };
141
+
142
+ // Build a rule from a `-o` short flag, a `--output [DIR]` long flag, and the
143
+ // description of what the option does.
144
+ buildRule = function(shortFlag, longFlag, description) {
145
+ var match;
146
+ match = longFlag.match(OPTIONAL);
147
+ shortFlag = shortFlag != null ? shortFlag.match(SHORT_FLAG)[1] : void 0;
148
+ longFlag = longFlag.match(LONG_FLAG)[1];
149
+ return {
150
+ name: longFlag.replace(/^--/, ''),
151
+ shortFlag: shortFlag,
152
+ longFlag: longFlag,
153
+ description: description,
154
+ hasArgument: !!(match && match[1]),
155
+ isList: !!(match && match[2])
156
+ };
157
+ };
158
+
159
+ normalizeArguments = function(args, flagDict) {
160
+ var arg, argIndex, flag, i, innerOpts, j, lastOpt, len, len1, multiFlags, multiOpts, needsArgOpt, positional, ref, rule, rules, singleRule, withArg;
161
+ rules = [];
162
+ positional = [];
163
+ needsArgOpt = null;
164
+ for (argIndex = i = 0, len = args.length; i < len; argIndex = ++i) {
165
+ arg = args[argIndex];
166
+ // If the previous argument given to the script was an option that uses the
167
+ // next command-line argument as its argument, create copy of the option’s
168
+ // rule with an `argument` field.
169
+ if (needsArgOpt != null) {
170
+ withArg = Object.assign({}, needsArgOpt.rule, {
171
+ argument: arg
172
+ });
173
+ rules.push(withArg);
174
+ needsArgOpt = null;
175
+ continue;
176
+ }
177
+ multiFlags = (ref = arg.match(MULTI_FLAG)) != null ? ref[1].split('').map(function(flagName) {
178
+ return `-${flagName}`;
179
+ }) : void 0;
180
+ if (multiFlags != null) {
181
+ multiOpts = multiFlags.map(function(flag) {
182
+ var rule;
183
+ rule = flagDict[flag];
184
+ if (rule == null) {
185
+ throw new Error(`unrecognized option ${flag} in multi-flag ${arg}`);
186
+ }
187
+ return {rule, flag};
188
+ });
189
+ // Only the last flag in a multi-flag may have an argument.
190
+ [...innerOpts] = multiOpts, [lastOpt] = splice.call(innerOpts, -1);
191
+ for (j = 0, len1 = innerOpts.length; j < len1; j++) {
192
+ ({rule, flag} = innerOpts[j]);
193
+ if (rule.hasArgument) {
194
+ throw new Error(`cannot use option ${flag} in multi-flag ${arg} except as the last option, because it needs an argument`);
195
+ }
196
+ rules.push(rule);
197
+ }
198
+ if (lastOpt.rule.hasArgument) {
199
+ needsArgOpt = lastOpt;
200
+ } else {
201
+ rules.push(lastOpt.rule);
202
+ }
203
+ } else if ([LONG_FLAG, SHORT_FLAG].some(function(pat) {
204
+ return arg.match(pat) != null;
205
+ })) {
206
+ singleRule = flagDict[arg];
207
+ if (singleRule == null) {
208
+ throw new Error(`unrecognized option ${arg}`);
209
+ }
210
+ if (singleRule.hasArgument) {
211
+ needsArgOpt = {
212
+ rule: singleRule,
213
+ flag: arg
214
+ };
215
+ } else {
216
+ rules.push(singleRule);
217
+ }
218
+ } else {
219
+ // This is a positional argument.
220
+ positional = args.slice(argIndex);
221
+ break;
222
+ }
223
+ }
224
+ if (needsArgOpt != null) {
225
+ throw new Error(`value required for ${needsArgOpt.flag}, but it was the last argument provided`);
226
+ }
227
+ return {rules, positional};
228
+ };
229
+
230
+ }).call(this);