coffee-react 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +43 -0
- data/coffee-react-transform.js +1823 -0
- data/lib/coffee-react.rb +1 -0
- data/lib/coffee_react.rb +47 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a56bfc931fad78325348778c948db307a425b89a
|
4
|
+
data.tar.gz: 0209ec616f77796af686cad720f51240ad5d025c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a7e4948f7b1ce92676bedffd8f4635a6b71158e6953f23f862978a8d515d2aad0919aa8e4e7cd9e561c86b4d1cd2db35ef2d1093f2931b5611c52a5b9ca1957
|
7
|
+
data.tar.gz: 3f14694dd5baf5d2f808bba0d19859c9fff988ea2840fa09067d8c2b3a8e6752779ce8ba5f2df9c1ef7ce8d5dbba137b5b26dcdff49f7e2ae0f82020094f4045
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010 Joshua Peek
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
Ruby CoffeeScript
|
2
|
+
=================
|
3
|
+
|
4
|
+
Ruby CoffeeScript is a bridge to the official CoffeeScript compiler.
|
5
|
+
|
6
|
+
CoffeeScript.compile File.read("script.coffee")
|
7
|
+
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
|
12
|
+
gem install coffee-script
|
13
|
+
|
14
|
+
*Note: This compiler library has replaced the original CoffeeScript
|
15
|
+
compiler that was written in Ruby.*
|
16
|
+
|
17
|
+
|
18
|
+
Dependencies
|
19
|
+
------------
|
20
|
+
|
21
|
+
This library depends on the `coffee-script-source` gem which is
|
22
|
+
updated any time a new version of CoffeeScript is released. (The
|
23
|
+
`coffee-script-source` gem's version number is synced with each
|
24
|
+
official CoffeeScript release.) This way you can build against
|
25
|
+
different versions of CoffeeScript by requiring the correct version of
|
26
|
+
the `coffee-script-source` gem.
|
27
|
+
|
28
|
+
In addition, you can use this library with unreleased versions of
|
29
|
+
CoffeeScript by setting the `COFFEESCRIPT_SOURCE_PATH` environment
|
30
|
+
variable:
|
31
|
+
|
32
|
+
export COFFEESCRIPT_SOURCE_PATH=/path/to/coffee-script/extras/coffee-script.js
|
33
|
+
|
34
|
+
### JSON
|
35
|
+
|
36
|
+
The `json` library is also required but is not explicitly stated as a
|
37
|
+
gem dependency. If you're on Ruby 1.8 you'll need to install the
|
38
|
+
`json` or `json_pure` gem. On Ruby 1.9, `json` is included in the
|
39
|
+
standard library.
|
40
|
+
|
41
|
+
### ExecJS
|
42
|
+
|
43
|
+
The [ExecJS](https://github.com/sstephenson/execjs) library is used to automatically choose the best JavaScript engine for your platform. Check out its [README](https://github.com/sstephenson/execjs/blob/master/README.md) for a complete list of supported engines.
|
@@ -0,0 +1,1823 @@
|
|
1
|
+
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"GqH0vP":[function(require,module,exports){
|
2
|
+
module.exports = require('./lib/transformer').transform;
|
3
|
+
|
4
|
+
},{"./lib/transformer":10}],"coffee-react-transform":[function(require,module,exports){
|
5
|
+
module.exports=require('GqH0vP');
|
6
|
+
},{}],3:[function(require,module,exports){
|
7
|
+
(function (process){
|
8
|
+
// Generated by CoffeeScript 1.7.1
|
9
|
+
var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref;
|
10
|
+
|
11
|
+
exports.starts = function(string, literal, start) {
|
12
|
+
return literal === string.substr(start, literal.length);
|
13
|
+
};
|
14
|
+
|
15
|
+
exports.ends = function(string, literal, back) {
|
16
|
+
var len;
|
17
|
+
len = literal.length;
|
18
|
+
return literal === string.substr(string.length - len - (back || 0), len);
|
19
|
+
};
|
20
|
+
|
21
|
+
exports.repeat = repeat = function(str, n) {
|
22
|
+
var res;
|
23
|
+
res = '';
|
24
|
+
while (n > 0) {
|
25
|
+
if (n & 1) {
|
26
|
+
res += str;
|
27
|
+
}
|
28
|
+
n >>>= 1;
|
29
|
+
str += str;
|
30
|
+
}
|
31
|
+
return res;
|
32
|
+
};
|
33
|
+
|
34
|
+
exports.compact = function(array) {
|
35
|
+
var item, _i, _len, _results;
|
36
|
+
_results = [];
|
37
|
+
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
38
|
+
item = array[_i];
|
39
|
+
if (item) {
|
40
|
+
_results.push(item);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
return _results;
|
44
|
+
};
|
45
|
+
|
46
|
+
exports.count = function(string, substr) {
|
47
|
+
var num, pos;
|
48
|
+
num = pos = 0;
|
49
|
+
if (!substr.length) {
|
50
|
+
return 1 / 0;
|
51
|
+
}
|
52
|
+
while (pos = 1 + string.indexOf(substr, pos)) {
|
53
|
+
num++;
|
54
|
+
}
|
55
|
+
return num;
|
56
|
+
};
|
57
|
+
|
58
|
+
exports.merge = function(options, overrides) {
|
59
|
+
return extend(extend({}, options), overrides);
|
60
|
+
};
|
61
|
+
|
62
|
+
extend = exports.extend = function(object, properties) {
|
63
|
+
var key, val;
|
64
|
+
for (key in properties) {
|
65
|
+
val = properties[key];
|
66
|
+
object[key] = val;
|
67
|
+
}
|
68
|
+
return object;
|
69
|
+
};
|
70
|
+
|
71
|
+
exports.flatten = flatten = function(array) {
|
72
|
+
var element, flattened, _i, _len;
|
73
|
+
flattened = [];
|
74
|
+
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
75
|
+
element = array[_i];
|
76
|
+
if (element instanceof Array) {
|
77
|
+
flattened = flattened.concat(flatten(element));
|
78
|
+
} else {
|
79
|
+
flattened.push(element);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return flattened;
|
83
|
+
};
|
84
|
+
|
85
|
+
exports.del = function(obj, key) {
|
86
|
+
var val;
|
87
|
+
val = obj[key];
|
88
|
+
delete obj[key];
|
89
|
+
return val;
|
90
|
+
};
|
91
|
+
|
92
|
+
exports.last = last = function(array, back) {
|
93
|
+
return array[array.length - (back || 0) - 1];
|
94
|
+
};
|
95
|
+
|
96
|
+
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
|
97
|
+
var e, _i, _len;
|
98
|
+
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
99
|
+
e = this[_i];
|
100
|
+
if (fn(e)) {
|
101
|
+
return true;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
return false;
|
105
|
+
};
|
106
|
+
|
107
|
+
exports.invertLiterate = function(code) {
|
108
|
+
var line, lines, maybe_code;
|
109
|
+
maybe_code = true;
|
110
|
+
lines = (function() {
|
111
|
+
var _i, _len, _ref1, _results;
|
112
|
+
_ref1 = code.split('\n');
|
113
|
+
_results = [];
|
114
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
115
|
+
line = _ref1[_i];
|
116
|
+
if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) {
|
117
|
+
_results.push(line);
|
118
|
+
} else if (maybe_code = /^\s*$/.test(line)) {
|
119
|
+
_results.push(line);
|
120
|
+
} else {
|
121
|
+
_results.push('# ' + line);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
return _results;
|
125
|
+
})();
|
126
|
+
return lines.join('\n');
|
127
|
+
};
|
128
|
+
|
129
|
+
buildLocationData = function(first, last) {
|
130
|
+
if (!last) {
|
131
|
+
return first;
|
132
|
+
} else {
|
133
|
+
return {
|
134
|
+
first_line: first.first_line,
|
135
|
+
first_column: first.first_column,
|
136
|
+
last_line: last.last_line,
|
137
|
+
last_column: last.last_column
|
138
|
+
};
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
exports.addLocationDataFn = function(first, last) {
|
143
|
+
return function(obj) {
|
144
|
+
if (((typeof obj) === 'object') && (!!obj['updateLocationDataIfMissing'])) {
|
145
|
+
obj.updateLocationDataIfMissing(buildLocationData(first, last));
|
146
|
+
}
|
147
|
+
return obj;
|
148
|
+
};
|
149
|
+
};
|
150
|
+
|
151
|
+
exports.locationDataToString = function(obj) {
|
152
|
+
var locationData;
|
153
|
+
if (("2" in obj) && ("first_line" in obj[2])) {
|
154
|
+
locationData = obj[2];
|
155
|
+
} else if ("first_line" in obj) {
|
156
|
+
locationData = obj;
|
157
|
+
}
|
158
|
+
if (locationData) {
|
159
|
+
return ("" + (locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ("" + (locationData.last_line + 1) + ":" + (locationData.last_column + 1));
|
160
|
+
} else {
|
161
|
+
return "No location data";
|
162
|
+
}
|
163
|
+
};
|
164
|
+
|
165
|
+
exports.baseFileName = function(file, stripExt, useWinPathSep) {
|
166
|
+
var parts, pathSep;
|
167
|
+
if (stripExt == null) {
|
168
|
+
stripExt = false;
|
169
|
+
}
|
170
|
+
if (useWinPathSep == null) {
|
171
|
+
useWinPathSep = false;
|
172
|
+
}
|
173
|
+
pathSep = useWinPathSep ? /\\|\// : /\//;
|
174
|
+
parts = file.split(pathSep);
|
175
|
+
file = parts[parts.length - 1];
|
176
|
+
if (!(stripExt && file.indexOf('.') >= 0)) {
|
177
|
+
return file;
|
178
|
+
}
|
179
|
+
parts = file.split('.');
|
180
|
+
parts.pop();
|
181
|
+
if (parts[parts.length - 1] === 'coffee' && parts.length > 1) {
|
182
|
+
parts.pop();
|
183
|
+
}
|
184
|
+
return parts.join('.');
|
185
|
+
};
|
186
|
+
|
187
|
+
exports.isCoffee = function(file) {
|
188
|
+
return /\.((lit)?coffee|coffee\.md)$/.test(file);
|
189
|
+
};
|
190
|
+
|
191
|
+
exports.isLiterate = function(file) {
|
192
|
+
return /\.(litcoffee|coffee\.md)$/.test(file);
|
193
|
+
};
|
194
|
+
|
195
|
+
exports.throwSyntaxError = function(message, location) {
|
196
|
+
var error;
|
197
|
+
error = new SyntaxError(message);
|
198
|
+
error.location = location;
|
199
|
+
error.toString = syntaxErrorToString;
|
200
|
+
error.stack = error.toString();
|
201
|
+
throw error;
|
202
|
+
};
|
203
|
+
|
204
|
+
exports.updateSyntaxError = function(error, code, filename) {
|
205
|
+
if (error.toString === syntaxErrorToString) {
|
206
|
+
error.code || (error.code = code);
|
207
|
+
error.filename || (error.filename = filename);
|
208
|
+
error.stack = error.toString();
|
209
|
+
}
|
210
|
+
return error;
|
211
|
+
};
|
212
|
+
|
213
|
+
syntaxErrorToString = function() {
|
214
|
+
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, start, _ref1, _ref2;
|
215
|
+
if (!(this.code && this.location)) {
|
216
|
+
return Error.prototype.toString.call(this);
|
217
|
+
}
|
218
|
+
_ref1 = this.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column;
|
219
|
+
if (last_line == null) {
|
220
|
+
last_line = first_line;
|
221
|
+
}
|
222
|
+
if (last_column == null) {
|
223
|
+
last_column = first_column;
|
224
|
+
}
|
225
|
+
filename = this.filename || '[stdin]';
|
226
|
+
codeLine = this.code.split('\n')[first_line];
|
227
|
+
start = first_column;
|
228
|
+
end = first_line === last_line ? last_column + 1 : codeLine.length;
|
229
|
+
marker = repeat(' ', start) + repeat('^', end - start);
|
230
|
+
if (typeof process !== "undefined" && process !== null) {
|
231
|
+
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
|
232
|
+
}
|
233
|
+
if ((_ref2 = this.colorful) != null ? _ref2 : colorsEnabled) {
|
234
|
+
colorize = function(str) {
|
235
|
+
return "\x1B[1;31m" + str + "\x1B[0m";
|
236
|
+
};
|
237
|
+
codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end);
|
238
|
+
marker = colorize(marker);
|
239
|
+
}
|
240
|
+
return "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker;
|
241
|
+
};
|
242
|
+
|
243
|
+
exports.nameWhitespaceCharacter = function(string) {
|
244
|
+
switch (string) {
|
245
|
+
case ' ':
|
246
|
+
return 'space';
|
247
|
+
case '\n':
|
248
|
+
return 'newline';
|
249
|
+
case '\r':
|
250
|
+
return 'carriage return';
|
251
|
+
case '\t':
|
252
|
+
return 'tab';
|
253
|
+
default:
|
254
|
+
return string;
|
255
|
+
}
|
256
|
+
};
|
257
|
+
|
258
|
+
}).call(this,require("/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
|
259
|
+
},{"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":12}],4:[function(require,module,exports){
|
260
|
+
// from react-tools/vendor/fbtransform/transforms/xjs.js
|
261
|
+
|
262
|
+
module.exports = {
|
263
|
+
a: true,
|
264
|
+
abbr: true,
|
265
|
+
address: true,
|
266
|
+
applet: true,
|
267
|
+
area: true,
|
268
|
+
article: true,
|
269
|
+
aside: true,
|
270
|
+
audio: true,
|
271
|
+
b: true,
|
272
|
+
base: true,
|
273
|
+
bdi: true,
|
274
|
+
bdo: true,
|
275
|
+
big: true,
|
276
|
+
blockquote: true,
|
277
|
+
body: true,
|
278
|
+
br: true,
|
279
|
+
button: true,
|
280
|
+
canvas: true,
|
281
|
+
caption: true,
|
282
|
+
circle: true,
|
283
|
+
cite: true,
|
284
|
+
code: true,
|
285
|
+
col: true,
|
286
|
+
colgroup: true,
|
287
|
+
command: true,
|
288
|
+
data: true,
|
289
|
+
datalist: true,
|
290
|
+
dd: true,
|
291
|
+
defs: true,
|
292
|
+
del: true,
|
293
|
+
details: true,
|
294
|
+
dfn: true,
|
295
|
+
dialog: true,
|
296
|
+
div: true,
|
297
|
+
dl: true,
|
298
|
+
dt: true,
|
299
|
+
ellipse: true,
|
300
|
+
em: true,
|
301
|
+
embed: true,
|
302
|
+
fieldset: true,
|
303
|
+
figcaption: true,
|
304
|
+
figure: true,
|
305
|
+
footer: true,
|
306
|
+
form: true,
|
307
|
+
g: true,
|
308
|
+
h1: true,
|
309
|
+
h2: true,
|
310
|
+
h3: true,
|
311
|
+
h4: true,
|
312
|
+
h5: true,
|
313
|
+
h6: true,
|
314
|
+
head: true,
|
315
|
+
header: true,
|
316
|
+
hgroup: true,
|
317
|
+
hr: true,
|
318
|
+
html: true,
|
319
|
+
i: true,
|
320
|
+
iframe: true,
|
321
|
+
img: true,
|
322
|
+
input: true,
|
323
|
+
ins: true,
|
324
|
+
kbd: true,
|
325
|
+
keygen: true,
|
326
|
+
label: true,
|
327
|
+
legend: true,
|
328
|
+
li: true,
|
329
|
+
line: true,
|
330
|
+
linearGradient: true,
|
331
|
+
link: true,
|
332
|
+
main: true,
|
333
|
+
map: true,
|
334
|
+
mark: true,
|
335
|
+
marquee: true,
|
336
|
+
menu: true,
|
337
|
+
menuitem: true,
|
338
|
+
meta: true,
|
339
|
+
meter: true,
|
340
|
+
nav: true,
|
341
|
+
noscript: true,
|
342
|
+
object: true,
|
343
|
+
ol: true,
|
344
|
+
optgroup: true,
|
345
|
+
option: true,
|
346
|
+
output: true,
|
347
|
+
p: true,
|
348
|
+
param: true,
|
349
|
+
path: true,
|
350
|
+
polygon: true,
|
351
|
+
polyline: true,
|
352
|
+
pre: true,
|
353
|
+
progress: true,
|
354
|
+
q: true,
|
355
|
+
radialGradient: true,
|
356
|
+
rect: true,
|
357
|
+
rp: true,
|
358
|
+
rt: true,
|
359
|
+
ruby: true,
|
360
|
+
s: true,
|
361
|
+
samp: true,
|
362
|
+
script: true,
|
363
|
+
section: true,
|
364
|
+
select: true,
|
365
|
+
small: true,
|
366
|
+
source: true,
|
367
|
+
span: true,
|
368
|
+
stop: true,
|
369
|
+
strong: true,
|
370
|
+
style: true,
|
371
|
+
sub: true,
|
372
|
+
summary: true,
|
373
|
+
sup: true,
|
374
|
+
svg: true,
|
375
|
+
table: true,
|
376
|
+
tbody: true,
|
377
|
+
td: true,
|
378
|
+
text: true,
|
379
|
+
textarea: true,
|
380
|
+
tfoot: true,
|
381
|
+
th: true,
|
382
|
+
thead: true,
|
383
|
+
time: true,
|
384
|
+
title: true,
|
385
|
+
tr: true,
|
386
|
+
track: true,
|
387
|
+
u: true,
|
388
|
+
ul: true,
|
389
|
+
'var': true,
|
390
|
+
video: true,
|
391
|
+
wbr: true
|
392
|
+
};
|
393
|
+
},{}],5:[function(require,module,exports){
|
394
|
+
/** Function count the occurrences of substring in a string;
|
395
|
+
* @param {String} string Required. The string;
|
396
|
+
* @param {String} subString Required. The string to search for;
|
397
|
+
* @param {Boolean} allowOverlapping Optional. Default: false;
|
398
|
+
*/
|
399
|
+
function occurrences(string, subString, allowOverlapping){
|
400
|
+
|
401
|
+
string+=""; subString+="";
|
402
|
+
if(subString.length<=0) return string.length+1;
|
403
|
+
|
404
|
+
var n=0, pos=0;
|
405
|
+
var step=(allowOverlapping)?(1):(subString.length);
|
406
|
+
|
407
|
+
while(true){
|
408
|
+
pos=string.indexOf(subString,pos);
|
409
|
+
if(pos>=0){ n++; pos+=step; } else break;
|
410
|
+
}
|
411
|
+
return(n);
|
412
|
+
}
|
413
|
+
|
414
|
+
},{}],6:[function(require,module,exports){
|
415
|
+
// Generated by CoffeeScript 1.7.1
|
416
|
+
var $, BOM, CLOSING_TAG, COMMENT, HEREDOC, HEREGEX, JSTOKEN, OPENING_TAG, PRAGMA, Parser, REGEX, SIMPLESTR, TAG_ATTRIBUTES, TRAILING_SPACES, WHITESPACE, compact, count, inspect, last, locationDataToString, parseTreeBranchNode, parseTreeLeafNode, repeat, starts, throwSyntaxError, util, _ref;
|
417
|
+
|
418
|
+
util = require('util');
|
419
|
+
|
420
|
+
_ref = require('./helpers'), count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last, repeat = _ref.repeat, locationDataToString = _ref.locationDataToString, throwSyntaxError = _ref.throwSyntaxError;
|
421
|
+
|
422
|
+
$ = require('./symbols');
|
423
|
+
|
424
|
+
inspect = function(value) {
|
425
|
+
return util.inspect(value, {
|
426
|
+
showHidden: true,
|
427
|
+
depth: null
|
428
|
+
});
|
429
|
+
};
|
430
|
+
|
431
|
+
parseTreeLeafNode = function(type, value) {
|
432
|
+
if (value == null) {
|
433
|
+
value = null;
|
434
|
+
}
|
435
|
+
return {
|
436
|
+
type: type,
|
437
|
+
value: value
|
438
|
+
};
|
439
|
+
};
|
440
|
+
|
441
|
+
parseTreeBranchNode = function(type, value, children) {
|
442
|
+
if (value == null) {
|
443
|
+
value = null;
|
444
|
+
}
|
445
|
+
if (children == null) {
|
446
|
+
children = [];
|
447
|
+
}
|
448
|
+
return {
|
449
|
+
type: type,
|
450
|
+
value: value,
|
451
|
+
children: children
|
452
|
+
};
|
453
|
+
};
|
454
|
+
|
455
|
+
module.exports = Parser = (function() {
|
456
|
+
function Parser() {}
|
457
|
+
|
458
|
+
Parser.prototype.parse = function(code, opts) {
|
459
|
+
var consumed, i, message, _ref1;
|
460
|
+
this.opts = opts != null ? opts : {};
|
461
|
+
this.parseTree = parseTreeBranchNode(this.opts.root || $.ROOT);
|
462
|
+
this.activeStates = [this.parseTree];
|
463
|
+
this.chunkLine = 0;
|
464
|
+
this.chunkColumn = 0;
|
465
|
+
this.cjsxPragmaChecked = false;
|
466
|
+
code = this.clean(code);
|
467
|
+
i = 0;
|
468
|
+
while ((this.chunk = code.slice(i))) {
|
469
|
+
if (this.activeStates.length === 0) {
|
470
|
+
break;
|
471
|
+
}
|
472
|
+
consumed = (this.currentState() !== $.CJSX_EL && this.currentState() !== $.CJSX_ATTRIBUTES ? this.csComment() || this.csHeredoc() || this.csString() || this.csRegex() || this.jsEscaped() : void 0) || this.cjsxStart() || this.cjsxAttribute() || this.cjsxEscape() || this.cjsxUnescape() || this.cjsxEnd() || this.cjsxText() || this.coffeescriptCode();
|
473
|
+
_ref1 = this.getLineAndColumnFromChunk(consumed), this.chunkLine = _ref1[0], this.chunkColumn = _ref1[1];
|
474
|
+
i += consumed;
|
475
|
+
}
|
476
|
+
if ((this.activeBranchNode() != null) && this.activeBranchNode() !== this.parseTree) {
|
477
|
+
message = "Unexpected end of input: unclosed " + (this.currentState());
|
478
|
+
throwSyntaxError(message, {
|
479
|
+
first_line: this.chunkLine,
|
480
|
+
first_column: this.chunkColumn
|
481
|
+
});
|
482
|
+
}
|
483
|
+
this.remainder = code.slice(i);
|
484
|
+
if (!this.opts.recursive) {
|
485
|
+
if (this.remainder.length) {
|
486
|
+
throwSyntaxError("Unexpected return from root state", {
|
487
|
+
first_line: this.chunkLine,
|
488
|
+
first_column: this.chunkColumn
|
489
|
+
});
|
490
|
+
}
|
491
|
+
}
|
492
|
+
return this.parseTree;
|
493
|
+
};
|
494
|
+
|
495
|
+
Parser.prototype.csComment = function() {
|
496
|
+
var comment, here, match, pragmaMatch, prefix;
|
497
|
+
if (!(match = this.chunk.match(COMMENT))) {
|
498
|
+
return 0;
|
499
|
+
}
|
500
|
+
comment = match[0], here = match[1];
|
501
|
+
if (!this.cjsxPragmaChecked) {
|
502
|
+
this.cjsxPragmaChecked = true;
|
503
|
+
if (pragmaMatch = comment.match(PRAGMA)) {
|
504
|
+
if (pragmaMatch && pragmaMatch[1] && pragmaMatch[1].length) {
|
505
|
+
prefix = pragmaMatch[1];
|
506
|
+
} else {
|
507
|
+
prefix = 'React.DOM';
|
508
|
+
}
|
509
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CJSX_PRAGMA, prefix));
|
510
|
+
return comment.length;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CS_COMMENT, comment));
|
514
|
+
return comment.length;
|
515
|
+
};
|
516
|
+
|
517
|
+
Parser.prototype.csHeredoc = function() {
|
518
|
+
var heredoc, match;
|
519
|
+
if (!(match = HEREDOC.exec(this.chunk))) {
|
520
|
+
return 0;
|
521
|
+
}
|
522
|
+
heredoc = match[0];
|
523
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CS_HEREDOC, heredoc));
|
524
|
+
return heredoc.length;
|
525
|
+
};
|
526
|
+
|
527
|
+
Parser.prototype.csString = function() {
|
528
|
+
var quote, string;
|
529
|
+
switch (quote = this.chunk.charAt(0)) {
|
530
|
+
case "'":
|
531
|
+
string = SIMPLESTR.exec(this.chunk)[0];
|
532
|
+
break;
|
533
|
+
case '"':
|
534
|
+
string = this.balancedString(this.chunk, '"');
|
535
|
+
}
|
536
|
+
if (!string) {
|
537
|
+
return 0;
|
538
|
+
}
|
539
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CS_STRING, string));
|
540
|
+
return string.length;
|
541
|
+
};
|
542
|
+
|
543
|
+
Parser.prototype.csRegex = function() {
|
544
|
+
var flags, length, match, regex, _ref1;
|
545
|
+
if (this.chunk.charAt(0) !== '/') {
|
546
|
+
return 0;
|
547
|
+
}
|
548
|
+
if (length = this.csHeregex()) {
|
549
|
+
return length;
|
550
|
+
}
|
551
|
+
if (!(match = REGEX.exec(this.chunk))) {
|
552
|
+
return 0;
|
553
|
+
}
|
554
|
+
_ref1 = match, match = _ref1[0], regex = _ref1[1], flags = _ref1[2];
|
555
|
+
if (regex.indexOf("\n") > -1) {
|
556
|
+
return 0;
|
557
|
+
}
|
558
|
+
if (regex === '//') {
|
559
|
+
return 0;
|
560
|
+
}
|
561
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CS_REGEX, match));
|
562
|
+
return match.length;
|
563
|
+
};
|
564
|
+
|
565
|
+
Parser.prototype.csHeregex = function() {
|
566
|
+
var body, flags, heregex, match;
|
567
|
+
if (!(match = HEREGEX.exec(this.chunk))) {
|
568
|
+
return 0;
|
569
|
+
}
|
570
|
+
heregex = match[0], body = match[1], flags = match[2];
|
571
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CS_HEREGEX, heregex));
|
572
|
+
return heregex.length;
|
573
|
+
};
|
574
|
+
|
575
|
+
Parser.prototype.jsEscaped = function() {
|
576
|
+
var match, script;
|
577
|
+
if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) {
|
578
|
+
return 0;
|
579
|
+
}
|
580
|
+
script = match[0];
|
581
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.JS_ESC, script));
|
582
|
+
return script.length;
|
583
|
+
};
|
584
|
+
|
585
|
+
Parser.prototype.cjsxStart = function() {
|
586
|
+
var attributesText, input, match, selfClosing, tagName;
|
587
|
+
if (!(match = OPENING_TAG.exec(this.chunk))) {
|
588
|
+
return 0;
|
589
|
+
}
|
590
|
+
input = match[0], tagName = match[1], attributesText = match[2], selfClosing = match[3];
|
591
|
+
if (!(selfClosing || this.chunk.indexOf("</" + tagName + ">", input.length) > -1)) {
|
592
|
+
return 0;
|
593
|
+
}
|
594
|
+
this.pushActiveBranchNode(parseTreeBranchNode($.CJSX_EL, tagName));
|
595
|
+
this.pushActiveBranchNode(parseTreeBranchNode($.CJSX_ATTRIBUTES));
|
596
|
+
return 1 + tagName.length;
|
597
|
+
};
|
598
|
+
|
599
|
+
Parser.prototype.cjsxAttribute = function() {
|
600
|
+
var attrName, bareVal, cjsxEscVal, doubleQuotedVal, input, match, singleQuotedVal, whitespace;
|
601
|
+
if (this.currentState() !== $.CJSX_ATTRIBUTES) {
|
602
|
+
return 0;
|
603
|
+
}
|
604
|
+
if (this.chunk.charAt(0) === '/') {
|
605
|
+
if (this.chunk.charAt(1) === '>') {
|
606
|
+
this.popActiveBranchNode();
|
607
|
+
this.popActiveBranchNode();
|
608
|
+
return 2;
|
609
|
+
} else {
|
610
|
+
throwSyntaxError("/ without immediately following > in CJSX tag " + (this.peekActiveState(2).value), {
|
611
|
+
first_line: this.chunkLine,
|
612
|
+
first_column: this.chunkColumn
|
613
|
+
});
|
614
|
+
}
|
615
|
+
}
|
616
|
+
if (this.chunk.charAt(0) === '>') {
|
617
|
+
this.popActiveBranchNode();
|
618
|
+
return 1;
|
619
|
+
}
|
620
|
+
if (!(match = TAG_ATTRIBUTES.exec(this.chunk))) {
|
621
|
+
return 0;
|
622
|
+
}
|
623
|
+
input = match[0], attrName = match[1], doubleQuotedVal = match[2], singleQuotedVal = match[3], cjsxEscVal = match[4], bareVal = match[5], whitespace = match[6];
|
624
|
+
if (attrName) {
|
625
|
+
if (doubleQuotedVal) {
|
626
|
+
this.addLeafNodeToActiveBranch(parseTreeBranchNode($.CJSX_ATTR_PAIR, null, [parseTreeLeafNode($.CJSX_ATTR_KEY, "\"" + attrName + "\""), parseTreeLeafNode($.CJSX_ATTR_VAL, "\"" + doubleQuotedVal + "\"")]));
|
627
|
+
return input.length;
|
628
|
+
} else if (singleQuotedVal) {
|
629
|
+
this.addLeafNodeToActiveBranch(parseTreeBranchNode($.CJSX_ATTR_PAIR, null, [parseTreeLeafNode($.CJSX_ATTR_KEY, "\"" + attrName + "\""), parseTreeLeafNode($.CJSX_ATTR_VAL, "'" + singleQuotedVal + "'")]));
|
630
|
+
return input.length;
|
631
|
+
} else if (cjsxEscVal) {
|
632
|
+
this.pushActiveBranchNode(parseTreeBranchNode($.CJSX_ATTR_PAIR));
|
633
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CJSX_ATTR_KEY, "\"" + attrName + "\""));
|
634
|
+
return input.indexOf('{');
|
635
|
+
} else if (bareVal) {
|
636
|
+
this.addLeafNodeToActiveBranch(parseTreeBranchNode($.CJSX_ATTR_PAIR, null, [parseTreeLeafNode($.CJSX_ATTR_KEY, "\"" + attrName + "\""), parseTreeLeafNode($.CJSX_ATTR_VAL, bareVal)]));
|
637
|
+
return input.length;
|
638
|
+
} else {
|
639
|
+
this.addLeafNodeToActiveBranch(parseTreeBranchNode($.CJSX_ATTR_PAIR, null, [parseTreeLeafNode($.CJSX_ATTR_KEY, "\"" + attrName + "\""), parseTreeLeafNode($.CJSX_ATTR_VAL, 'true')]));
|
640
|
+
return input.length;
|
641
|
+
}
|
642
|
+
} else if (whitespace) {
|
643
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CJSX_WHITESPACE, whitespace));
|
644
|
+
return input.length;
|
645
|
+
} else {
|
646
|
+
return throwSyntaxError("Invalid attribute " + input + " in CJSX tag " + (this.peekActiveState(2).value), {
|
647
|
+
first_line: this.chunkLine,
|
648
|
+
first_column: this.chunkColumn
|
649
|
+
});
|
650
|
+
}
|
651
|
+
};
|
652
|
+
|
653
|
+
Parser.prototype.cjsxEscape = function() {
|
654
|
+
if (!(this.chunk.charAt(0) === '{' && this.currentState() === $.CJSX_EL || this.currentState() === $.CJSX_ATTR_PAIR)) {
|
655
|
+
return 0;
|
656
|
+
}
|
657
|
+
this.pushActiveBranchNode(parseTreeBranchNode($.CJSX_ESC));
|
658
|
+
this.activeBranchNode().stack = 1;
|
659
|
+
return 1;
|
660
|
+
};
|
661
|
+
|
662
|
+
Parser.prototype.cjsxUnescape = function() {
|
663
|
+
if (!(this.currentState() === $.CJSX_ESC && this.chunk.charAt(0) === '}')) {
|
664
|
+
return 0;
|
665
|
+
}
|
666
|
+
if (this.activeBranchNode().stack === 0) {
|
667
|
+
this.popActiveBranchNode();
|
668
|
+
if (this.currentState() === $.CJSX_ATTR_PAIR) {
|
669
|
+
this.popActiveBranchNode();
|
670
|
+
}
|
671
|
+
return 1;
|
672
|
+
} else {
|
673
|
+
return 0;
|
674
|
+
}
|
675
|
+
};
|
676
|
+
|
677
|
+
Parser.prototype.cjsxEnd = function() {
|
678
|
+
var input, match, tagName;
|
679
|
+
if (this.currentState() !== $.CJSX_EL) {
|
680
|
+
return 0;
|
681
|
+
}
|
682
|
+
if (!(match = CLOSING_TAG.exec(this.chunk))) {
|
683
|
+
return 0;
|
684
|
+
}
|
685
|
+
input = match[0], tagName = match[1];
|
686
|
+
if (tagName !== this.activeBranchNode().value) {
|
687
|
+
throwSyntaxError("opening CJSX tag " + (this.activeBranchNode().value) + " doesn't match closing CJSX tag " + tagName, {
|
688
|
+
first_line: this.chunkLine,
|
689
|
+
first_column: this.chunkColumn
|
690
|
+
});
|
691
|
+
}
|
692
|
+
this.popActiveBranchNode();
|
693
|
+
return input.length;
|
694
|
+
};
|
695
|
+
|
696
|
+
Parser.prototype.cjsxText = function() {
|
697
|
+
if (this.currentState() !== $.CJSX_EL) {
|
698
|
+
return 0;
|
699
|
+
}
|
700
|
+
if (this.newestNode().type !== $.CJSX_TEXT) {
|
701
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CJSX_TEXT, ''));
|
702
|
+
}
|
703
|
+
this.newestNode().value += this.chunk.charAt(0);
|
704
|
+
return 1;
|
705
|
+
};
|
706
|
+
|
707
|
+
Parser.prototype.coffeescriptCode = function() {
|
708
|
+
if (this.currentState() === $.CJSX_ESC) {
|
709
|
+
if (this.chunk.charAt(0) === '{') {
|
710
|
+
this.activeBranchNode().stack++;
|
711
|
+
} else if (this.chunk.charAt(0) === '}') {
|
712
|
+
this.activeBranchNode().stack--;
|
713
|
+
if (this.activeBranchNode().stack === 0) {
|
714
|
+
return 0;
|
715
|
+
}
|
716
|
+
}
|
717
|
+
}
|
718
|
+
if (this.newestNode().type !== $.CS) {
|
719
|
+
this.addLeafNodeToActiveBranch(parseTreeLeafNode($.CS, ''));
|
720
|
+
}
|
721
|
+
this.newestNode().value += this.chunk.charAt(0);
|
722
|
+
return 1;
|
723
|
+
};
|
724
|
+
|
725
|
+
Parser.prototype.activeBranchNode = function() {
|
726
|
+
return last(this.activeStates);
|
727
|
+
};
|
728
|
+
|
729
|
+
Parser.prototype.peekActiveState = function(depth) {
|
730
|
+
if (depth == null) {
|
731
|
+
depth = 1;
|
732
|
+
}
|
733
|
+
return this.activeStates.slice(-depth)[0];
|
734
|
+
};
|
735
|
+
|
736
|
+
Parser.prototype.currentState = function() {
|
737
|
+
return this.activeBranchNode().type;
|
738
|
+
};
|
739
|
+
|
740
|
+
Parser.prototype.newestNode = function() {
|
741
|
+
return last(this.activeBranchNode().children) || this.activeBranchNode();
|
742
|
+
};
|
743
|
+
|
744
|
+
Parser.prototype.pushActiveBranchNode = function(node) {
|
745
|
+
this.activeBranchNode().children.push(node);
|
746
|
+
return this.activeStates.push(node);
|
747
|
+
};
|
748
|
+
|
749
|
+
Parser.prototype.popActiveBranchNode = function() {
|
750
|
+
return this.activeStates.pop();
|
751
|
+
};
|
752
|
+
|
753
|
+
Parser.prototype.addLeafNodeToActiveBranch = function(node) {
|
754
|
+
return this.activeBranchNode().children.push(node);
|
755
|
+
};
|
756
|
+
|
757
|
+
Parser.prototype.clean = function(code) {
|
758
|
+
if (code.charCodeAt(0) === BOM) {
|
759
|
+
code = code.slice(1);
|
760
|
+
}
|
761
|
+
return code;
|
762
|
+
};
|
763
|
+
|
764
|
+
Parser.prototype.getLineAndColumnFromChunk = function(offset) {
|
765
|
+
var column, lineCount, lines, string;
|
766
|
+
if (offset === 0) {
|
767
|
+
return [this.chunkLine, this.chunkColumn];
|
768
|
+
}
|
769
|
+
if (offset >= this.chunk.length) {
|
770
|
+
string = this.chunk;
|
771
|
+
} else {
|
772
|
+
string = this.chunk.slice(0, +(offset - 1) + 1 || 9e9);
|
773
|
+
}
|
774
|
+
lineCount = count(string, '\n');
|
775
|
+
column = this.chunkColumn;
|
776
|
+
if (lineCount > 0) {
|
777
|
+
lines = string.split('\n');
|
778
|
+
column = last(lines).length;
|
779
|
+
} else {
|
780
|
+
column += string.length;
|
781
|
+
}
|
782
|
+
return [this.chunkLine + lineCount, column];
|
783
|
+
};
|
784
|
+
|
785
|
+
Parser.prototype.balancedString = function(str, end) {
|
786
|
+
var continueCount, i, letter, match, prev, stack, _i, _ref1;
|
787
|
+
continueCount = 0;
|
788
|
+
stack = [end];
|
789
|
+
for (i = _i = 1, _ref1 = str.length; 1 <= _ref1 ? _i < _ref1 : _i > _ref1; i = 1 <= _ref1 ? ++_i : --_i) {
|
790
|
+
if (continueCount) {
|
791
|
+
--continueCount;
|
792
|
+
continue;
|
793
|
+
}
|
794
|
+
switch (letter = str.charAt(i)) {
|
795
|
+
case '\\':
|
796
|
+
++continueCount;
|
797
|
+
continue;
|
798
|
+
case end:
|
799
|
+
stack.pop();
|
800
|
+
if (!stack.length) {
|
801
|
+
return str.slice(0, +i + 1 || 9e9);
|
802
|
+
}
|
803
|
+
end = stack[stack.length - 1];
|
804
|
+
continue;
|
805
|
+
}
|
806
|
+
if (end === '}' && (letter === '"' || letter === "'")) {
|
807
|
+
stack.push(end = letter);
|
808
|
+
} else if (end === '}' && letter === '/' && (match = HEREGEX.exec(str.slice(i)) || REGEX.exec(str.slice(i)))) {
|
809
|
+
continueCount += match[0].length - 1;
|
810
|
+
} else if (end === '}' && letter === '{') {
|
811
|
+
stack.push(end = '}');
|
812
|
+
} else if (end === '"' && prev === '#' && letter === '{') {
|
813
|
+
stack.push(end = '}');
|
814
|
+
}
|
815
|
+
prev = letter;
|
816
|
+
}
|
817
|
+
return this.error("missing " + (stack.pop()) + ", starting");
|
818
|
+
};
|
819
|
+
|
820
|
+
return Parser;
|
821
|
+
|
822
|
+
})();
|
823
|
+
|
824
|
+
OPENING_TAG = /^<([-A-Za-z0-9_]+)((?:\s+[\w-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:{[\s\S]*?})|[^>\s]+))?)*?\s*)(\/?)>/;
|
825
|
+
|
826
|
+
CLOSING_TAG = /^<\/([-A-Za-z0-9_]+)[^>]*>/;
|
827
|
+
|
828
|
+
TAG_ATTRIBUTES = /(?:([-A-Za-z0-9_]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:{((?:\\.|[\s\S])*)})|([^>\s]+)))?)|([\s\n]+)/;
|
829
|
+
|
830
|
+
PRAGMA = /^\s*#\s*@cjsx\s+(\S*)/i;
|
831
|
+
|
832
|
+
BOM = 65279;
|
833
|
+
|
834
|
+
WHITESPACE = /^[^\n\S]+/;
|
835
|
+
|
836
|
+
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/;
|
837
|
+
|
838
|
+
TRAILING_SPACES = /\s+$/;
|
839
|
+
|
840
|
+
HEREDOC = /^("""|''')((?:\\[\s\S]|[^\\])*?)(?:\n[^\n\S]*)?\1/;
|
841
|
+
|
842
|
+
SIMPLESTR = /^'[^\\']*(?:\\[\s\S][^\\']*)*'/;
|
843
|
+
|
844
|
+
JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/;
|
845
|
+
|
846
|
+
REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/;
|
847
|
+
|
848
|
+
HEREGEX = /^\/{3}((?:\\?[\s\S])+?)\/{3}([imgy]{0,4})(?!\w)/;
|
849
|
+
|
850
|
+
},{"./helpers":3,"./symbols":9,"util":14}],7:[function(require,module,exports){
|
851
|
+
// Generated by CoffeeScript 1.7.1
|
852
|
+
var $, HTML_ELEMENTS, SPACES_ONLY, TEXT_LEADING_WHITESPACE, TEXT_TRAILING_WHITESPACE, WHITESPACE_ONLY, containsNewlines, genericBranchSerialiser, genericLeafSerialiser, inspect, last, occurrences, serialise, serialiseNode, serialisers, stringEscape;
|
853
|
+
|
854
|
+
last = require('./helpers').last;
|
855
|
+
|
856
|
+
inspect = require('util').inspect;
|
857
|
+
|
858
|
+
$ = require('./symbols');
|
859
|
+
|
860
|
+
HTML_ELEMENTS = require('./htmlelements');
|
861
|
+
|
862
|
+
stringEscape = require('./stringescape');
|
863
|
+
|
864
|
+
occurrences = require('./occurrences');
|
865
|
+
|
866
|
+
module.exports = serialise = function(parseTree) {
|
867
|
+
var env;
|
868
|
+
env = {
|
869
|
+
serialiseNode: serialiseNode
|
870
|
+
};
|
871
|
+
if (parseTree.children && parseTree.children.length && parseTree.children[0].type === $.CJSX_PRAGMA) {
|
872
|
+
env.domObject = parseTree.children[0].value;
|
873
|
+
} else {
|
874
|
+
env.domObject = 'React.DOM';
|
875
|
+
}
|
876
|
+
return env.serialiseNode(parseTree);
|
877
|
+
};
|
878
|
+
|
879
|
+
serialiseNode = function(node) {
|
880
|
+
var serialised;
|
881
|
+
if (serialisers[node.type] == null) {
|
882
|
+
throw new Error("unknown parseTree node type " + node.type);
|
883
|
+
}
|
884
|
+
serialised = serialisers[node.type](node, this);
|
885
|
+
if (!(typeof serialised === 'string' || serialised === null)) {
|
886
|
+
throw new Error("serialiser " + node.type + " didn\'t return a string for node " + (inspect(node)) + ", instead returned " + serialised);
|
887
|
+
}
|
888
|
+
return serialised;
|
889
|
+
};
|
890
|
+
|
891
|
+
genericBranchSerialiser = function(node, env) {
|
892
|
+
return node.children.map(function(child) {
|
893
|
+
return env.serialiseNode(child);
|
894
|
+
}).join('');
|
895
|
+
};
|
896
|
+
|
897
|
+
genericLeafSerialiser = function(node, env) {
|
898
|
+
return node.value;
|
899
|
+
};
|
900
|
+
|
901
|
+
serialise.serialisers = serialisers = {
|
902
|
+
ROOT: genericBranchSerialiser,
|
903
|
+
CJSX_PRAGMA: function() {
|
904
|
+
return null;
|
905
|
+
},
|
906
|
+
CJSX_EL: function(node, env) {
|
907
|
+
var accumulatedWhitespace, child, prefix, serialisedChild, serialisedChildren, _i, _len, _ref;
|
908
|
+
serialisedChildren = [];
|
909
|
+
accumulatedWhitespace = '';
|
910
|
+
_ref = node.children;
|
911
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
912
|
+
child = _ref[_i];
|
913
|
+
serialisedChild = env.serialiseNode(child);
|
914
|
+
if (child != null) {
|
915
|
+
if (WHITESPACE_ONLY.test(serialisedChild)) {
|
916
|
+
accumulatedWhitespace += serialisedChild;
|
917
|
+
} else {
|
918
|
+
serialisedChildren.push(accumulatedWhitespace + serialisedChild);
|
919
|
+
accumulatedWhitespace = '';
|
920
|
+
}
|
921
|
+
}
|
922
|
+
}
|
923
|
+
if (serialisedChildren.length) {
|
924
|
+
serialisedChildren[serialisedChildren.length - 1] += accumulatedWhitespace;
|
925
|
+
accumulatedWhitespace = '';
|
926
|
+
}
|
927
|
+
prefix = HTML_ELEMENTS[node.value] != null ? env.domObject + '.' : '';
|
928
|
+
return prefix + node.value + '(' + serialisedChildren.join(', ') + ')';
|
929
|
+
},
|
930
|
+
CJSX_ESC: function(node, env) {
|
931
|
+
var childrenSerialised;
|
932
|
+
childrenSerialised = node.children.map(function(child) {
|
933
|
+
return env.serialiseNode(child);
|
934
|
+
}).join('');
|
935
|
+
return '(' + childrenSerialised + ')';
|
936
|
+
},
|
937
|
+
CJSX_ATTRIBUTES: function(node, env) {
|
938
|
+
var child, childIndex, indexOfLastSemanticChild, isBeforeLastSemanticChild, semanticChildren, serialisedChild, serialisedChildren, whitespaceChildren, _ref;
|
939
|
+
_ref = node.children.reduce(function(partitionedChildren, child) {
|
940
|
+
if (child.type === $.CJSX_WHITESPACE) {
|
941
|
+
partitionedChildren[0].push(child);
|
942
|
+
} else {
|
943
|
+
partitionedChildren[1].push(child);
|
944
|
+
}
|
945
|
+
return partitionedChildren;
|
946
|
+
}, [[], []]), whitespaceChildren = _ref[0], semanticChildren = _ref[1];
|
947
|
+
indexOfLastSemanticChild = node.children.lastIndexOf(last(semanticChildren));
|
948
|
+
isBeforeLastSemanticChild = function(childIndex) {
|
949
|
+
return childIndex < indexOfLastSemanticChild;
|
950
|
+
};
|
951
|
+
if (semanticChildren.length) {
|
952
|
+
serialisedChildren = (function() {
|
953
|
+
var _i, _len, _ref1, _results;
|
954
|
+
_ref1 = node.children;
|
955
|
+
_results = [];
|
956
|
+
for (childIndex = _i = 0, _len = _ref1.length; _i < _len; childIndex = ++_i) {
|
957
|
+
child = _ref1[childIndex];
|
958
|
+
serialisedChild = env.serialiseNode(child);
|
959
|
+
if (child.type === $.CJSX_WHITESPACE) {
|
960
|
+
if (containsNewlines(serialisedChild)) {
|
961
|
+
if (isBeforeLastSemanticChild(childIndex)) {
|
962
|
+
_results.push(serialisedChild.replace('\n', ' \\\n'));
|
963
|
+
} else {
|
964
|
+
_results.push(serialisedChild);
|
965
|
+
}
|
966
|
+
} else {
|
967
|
+
_results.push(null);
|
968
|
+
}
|
969
|
+
} else if (isBeforeLastSemanticChild(childIndex)) {
|
970
|
+
_results.push(serialisedChild + ', ');
|
971
|
+
} else {
|
972
|
+
_results.push(serialisedChild);
|
973
|
+
}
|
974
|
+
}
|
975
|
+
return _results;
|
976
|
+
})();
|
977
|
+
return '{' + serialisedChildren.join('') + '}';
|
978
|
+
} else {
|
979
|
+
return 'null';
|
980
|
+
}
|
981
|
+
},
|
982
|
+
CJSX_ATTR_PAIR: function(node, env) {
|
983
|
+
return node.children.map(function(child) {
|
984
|
+
return env.serialiseNode(child);
|
985
|
+
}).join(': ');
|
986
|
+
},
|
987
|
+
CS: genericLeafSerialiser,
|
988
|
+
CS_COMMENT: genericLeafSerialiser,
|
989
|
+
CS_HEREDOC: genericLeafSerialiser,
|
990
|
+
CS_STRING: genericLeafSerialiser,
|
991
|
+
CS_REGEX: genericLeafSerialiser,
|
992
|
+
CS_HEREGEX: genericLeafSerialiser,
|
993
|
+
JS_ESC: genericLeafSerialiser,
|
994
|
+
CJSX_WHITESPACE: genericLeafSerialiser,
|
995
|
+
CJSX_TEXT: function(node) {
|
996
|
+
var leftSpace, leftTrim, rightSpace, rightTrim, text, trimmedText;
|
997
|
+
text = node.value;
|
998
|
+
if (containsNewlines(text)) {
|
999
|
+
if (WHITESPACE_ONLY.test(text)) {
|
1000
|
+
return text;
|
1001
|
+
} else {
|
1002
|
+
leftSpace = text.match(TEXT_LEADING_WHITESPACE);
|
1003
|
+
rightSpace = text.match(TEXT_TRAILING_WHITESPACE);
|
1004
|
+
if (leftSpace) {
|
1005
|
+
leftTrim = text.indexOf('\n');
|
1006
|
+
} else {
|
1007
|
+
leftTrim = 0;
|
1008
|
+
}
|
1009
|
+
if (rightSpace) {
|
1010
|
+
rightTrim = text.lastIndexOf('\n') + 1;
|
1011
|
+
} else {
|
1012
|
+
rightTrim = text.length;
|
1013
|
+
}
|
1014
|
+
trimmedText = text.substring(leftTrim, rightTrim);
|
1015
|
+
return '"""' + trimmedText + '"""';
|
1016
|
+
}
|
1017
|
+
} else {
|
1018
|
+
if (text === '') {
|
1019
|
+
return null;
|
1020
|
+
} else {
|
1021
|
+
return '"' + text + '"';
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
},
|
1025
|
+
CJSX_ATTR_KEY: genericLeafSerialiser,
|
1026
|
+
CJSX_ATTR_VAL: genericLeafSerialiser
|
1027
|
+
};
|
1028
|
+
|
1029
|
+
containsNewlines = function(text) {
|
1030
|
+
return text.indexOf('\n') > -1;
|
1031
|
+
};
|
1032
|
+
|
1033
|
+
SPACES_ONLY = /^\s+$/;
|
1034
|
+
|
1035
|
+
WHITESPACE_ONLY = /^[\n\s]+$/;
|
1036
|
+
|
1037
|
+
TEXT_LEADING_WHITESPACE = /^\s*?\n\s*/;
|
1038
|
+
|
1039
|
+
TEXT_TRAILING_WHITESPACE = /\s*?\n\s*?$/;
|
1040
|
+
|
1041
|
+
},{"./helpers":3,"./htmlelements":4,"./occurrences":5,"./stringescape":8,"./symbols":9,"util":14}],8:[function(require,module,exports){
|
1042
|
+
|
1043
|
+
var hex=new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
|
1044
|
+
|
1045
|
+
module.exports = function stringEncode(preescape)
|
1046
|
+
{
|
1047
|
+
var escaped="";
|
1048
|
+
|
1049
|
+
var i=0;
|
1050
|
+
for(i=0;i<preescape.length;i++)
|
1051
|
+
{
|
1052
|
+
escaped=escaped+encodeCharx(preescape.charAt(i));
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
return escaped;
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
function encodeCharx(original)
|
1059
|
+
{
|
1060
|
+
var found=true;
|
1061
|
+
var thecharchar=original.charAt(0);
|
1062
|
+
var thechar=original.charCodeAt(0);
|
1063
|
+
switch(thecharchar) {
|
1064
|
+
case '\n': return "\\n"; break; //newline
|
1065
|
+
case '\r': return "\\r"; break; //Carriage return
|
1066
|
+
case '\'': return "\\'"; break;
|
1067
|
+
case '"': return "\\\""; break;
|
1068
|
+
case '\&': return "\\&"; break;
|
1069
|
+
case '\\': return "\\\\"; break;
|
1070
|
+
case '\t': return "\\t"; break;
|
1071
|
+
case '\b': return "\\b"; break;
|
1072
|
+
case '\f': return "\\f"; break;
|
1073
|
+
case '/': return "\\x2F"; break;
|
1074
|
+
case '<': return "\\x3C"; break;
|
1075
|
+
case '>': return "\\x3E"; break;
|
1076
|
+
default:
|
1077
|
+
found=false;
|
1078
|
+
break;
|
1079
|
+
}
|
1080
|
+
if(!found)
|
1081
|
+
{
|
1082
|
+
if(thechar>127) {
|
1083
|
+
var c=thechar;
|
1084
|
+
var a4=c%16;
|
1085
|
+
c=Math.floor(c/16);
|
1086
|
+
var a3=c%16;
|
1087
|
+
c=Math.floor(c/16);
|
1088
|
+
var a2=c%16;
|
1089
|
+
c=Math.floor(c/16);
|
1090
|
+
var a1=c%16;
|
1091
|
+
// alert(a1);
|
1092
|
+
return "\\u"+hex[a1]+hex[a2]+hex[a3]+hex[a4]+"";
|
1093
|
+
}
|
1094
|
+
else
|
1095
|
+
{
|
1096
|
+
return original;
|
1097
|
+
}
|
1098
|
+
}
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
},{}],9:[function(require,module,exports){
|
1102
|
+
// Generated by CoffeeScript 1.7.1
|
1103
|
+
module.exports = {
|
1104
|
+
ROOT: 'ROOT',
|
1105
|
+
CJSX_EL: 'CJSX_EL',
|
1106
|
+
CJSX_ESC: 'CJSX_ESC',
|
1107
|
+
CJSX_ATTRIBUTES: 'CJSX_ATTRIBUTES',
|
1108
|
+
CJSX_ATTR_PAIR: 'CJSX_ATTR_PAIR',
|
1109
|
+
CS: 'CS',
|
1110
|
+
CS_COMMENT: 'CS_COMMENT',
|
1111
|
+
CS_HEREDOC: 'CS_HEREDOC',
|
1112
|
+
CS_STRING: 'CS_STRING',
|
1113
|
+
CS_REGEX: 'CS_REGEX',
|
1114
|
+
CS_HEREGEX: 'CS_HEREGEX',
|
1115
|
+
JS_ESC: 'JS_ESC',
|
1116
|
+
CJSX_WHITESPACE: 'CJSX_WHITESPACE',
|
1117
|
+
CJSX_TEXT: 'CJSX_TEXT',
|
1118
|
+
CJSX_ATTR_KEY: 'CJSX_ATTR_KEY',
|
1119
|
+
CJSX_ATTR_VAL: 'CJSX_ATTR_VAL',
|
1120
|
+
CJSX_START: 'CJSX_START',
|
1121
|
+
CJSX_END: 'CJSX_END',
|
1122
|
+
CJSX_ESC_START: 'CJSX_ESC_START',
|
1123
|
+
CJSX_ESC_END: 'CJSX_ESC_END',
|
1124
|
+
CJSX_PRAGMA: 'CJSX_PRAGMA'
|
1125
|
+
};
|
1126
|
+
|
1127
|
+
},{}],10:[function(require,module,exports){
|
1128
|
+
// Generated by CoffeeScript 1.7.1
|
1129
|
+
var Parser, serialise;
|
1130
|
+
|
1131
|
+
Parser = require('./parser');
|
1132
|
+
|
1133
|
+
serialise = require('./serialiser');
|
1134
|
+
|
1135
|
+
module.exports.transform = function(code, opts) {
|
1136
|
+
return serialise(new Parser().parse(code, opts));
|
1137
|
+
};
|
1138
|
+
|
1139
|
+
},{"./parser":6,"./serialiser":7}],11:[function(require,module,exports){
|
1140
|
+
if (typeof Object.create === 'function') {
|
1141
|
+
// implementation from standard node.js 'util' module
|
1142
|
+
module.exports = function inherits(ctor, superCtor) {
|
1143
|
+
ctor.super_ = superCtor
|
1144
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
1145
|
+
constructor: {
|
1146
|
+
value: ctor,
|
1147
|
+
enumerable: false,
|
1148
|
+
writable: true,
|
1149
|
+
configurable: true
|
1150
|
+
}
|
1151
|
+
});
|
1152
|
+
};
|
1153
|
+
} else {
|
1154
|
+
// old school shim for old browsers
|
1155
|
+
module.exports = function inherits(ctor, superCtor) {
|
1156
|
+
ctor.super_ = superCtor
|
1157
|
+
var TempCtor = function () {}
|
1158
|
+
TempCtor.prototype = superCtor.prototype
|
1159
|
+
ctor.prototype = new TempCtor()
|
1160
|
+
ctor.prototype.constructor = ctor
|
1161
|
+
}
|
1162
|
+
}
|
1163
|
+
|
1164
|
+
},{}],12:[function(require,module,exports){
|
1165
|
+
// shim for using process in browser
|
1166
|
+
|
1167
|
+
var process = module.exports = {};
|
1168
|
+
|
1169
|
+
process.nextTick = (function () {
|
1170
|
+
var canSetImmediate = typeof window !== 'undefined'
|
1171
|
+
&& window.setImmediate;
|
1172
|
+
var canPost = typeof window !== 'undefined'
|
1173
|
+
&& window.postMessage && window.addEventListener
|
1174
|
+
;
|
1175
|
+
|
1176
|
+
if (canSetImmediate) {
|
1177
|
+
return function (f) { return window.setImmediate(f) };
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
if (canPost) {
|
1181
|
+
var queue = [];
|
1182
|
+
window.addEventListener('message', function (ev) {
|
1183
|
+
var source = ev.source;
|
1184
|
+
if ((source === window || source === null) && ev.data === 'process-tick') {
|
1185
|
+
ev.stopPropagation();
|
1186
|
+
if (queue.length > 0) {
|
1187
|
+
var fn = queue.shift();
|
1188
|
+
fn();
|
1189
|
+
}
|
1190
|
+
}
|
1191
|
+
}, true);
|
1192
|
+
|
1193
|
+
return function nextTick(fn) {
|
1194
|
+
queue.push(fn);
|
1195
|
+
window.postMessage('process-tick', '*');
|
1196
|
+
};
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
return function nextTick(fn) {
|
1200
|
+
setTimeout(fn, 0);
|
1201
|
+
};
|
1202
|
+
})();
|
1203
|
+
|
1204
|
+
process.title = 'browser';
|
1205
|
+
process.browser = true;
|
1206
|
+
process.env = {};
|
1207
|
+
process.argv = [];
|
1208
|
+
|
1209
|
+
function noop() {}
|
1210
|
+
|
1211
|
+
process.on = noop;
|
1212
|
+
process.once = noop;
|
1213
|
+
process.off = noop;
|
1214
|
+
process.emit = noop;
|
1215
|
+
|
1216
|
+
process.binding = function (name) {
|
1217
|
+
throw new Error('process.binding is not supported');
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
// TODO(shtylman)
|
1221
|
+
process.cwd = function () { return '/' };
|
1222
|
+
process.chdir = function (dir) {
|
1223
|
+
throw new Error('process.chdir is not supported');
|
1224
|
+
};
|
1225
|
+
|
1226
|
+
},{}],13:[function(require,module,exports){
|
1227
|
+
module.exports = function isBuffer(arg) {
|
1228
|
+
return arg && typeof arg === 'object'
|
1229
|
+
&& typeof arg.copy === 'function'
|
1230
|
+
&& typeof arg.fill === 'function'
|
1231
|
+
&& typeof arg.readUInt8 === 'function';
|
1232
|
+
}
|
1233
|
+
},{}],14:[function(require,module,exports){
|
1234
|
+
(function (process,global){
|
1235
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
1236
|
+
//
|
1237
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
1238
|
+
// copy of this software and associated documentation files (the
|
1239
|
+
// "Software"), to deal in the Software without restriction, including
|
1240
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
1241
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
1242
|
+
// persons to whom the Software is furnished to do so, subject to the
|
1243
|
+
// following conditions:
|
1244
|
+
//
|
1245
|
+
// The above copyright notice and this permission notice shall be included
|
1246
|
+
// in all copies or substantial portions of the Software.
|
1247
|
+
//
|
1248
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
1249
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
1250
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
1251
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
1252
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
1253
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
1254
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1255
|
+
|
1256
|
+
var formatRegExp = /%[sdj%]/g;
|
1257
|
+
exports.format = function(f) {
|
1258
|
+
if (!isString(f)) {
|
1259
|
+
var objects = [];
|
1260
|
+
for (var i = 0; i < arguments.length; i++) {
|
1261
|
+
objects.push(inspect(arguments[i]));
|
1262
|
+
}
|
1263
|
+
return objects.join(' ');
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
var i = 1;
|
1267
|
+
var args = arguments;
|
1268
|
+
var len = args.length;
|
1269
|
+
var str = String(f).replace(formatRegExp, function(x) {
|
1270
|
+
if (x === '%%') return '%';
|
1271
|
+
if (i >= len) return x;
|
1272
|
+
switch (x) {
|
1273
|
+
case '%s': return String(args[i++]);
|
1274
|
+
case '%d': return Number(args[i++]);
|
1275
|
+
case '%j':
|
1276
|
+
try {
|
1277
|
+
return JSON.stringify(args[i++]);
|
1278
|
+
} catch (_) {
|
1279
|
+
return '[Circular]';
|
1280
|
+
}
|
1281
|
+
default:
|
1282
|
+
return x;
|
1283
|
+
}
|
1284
|
+
});
|
1285
|
+
for (var x = args[i]; i < len; x = args[++i]) {
|
1286
|
+
if (isNull(x) || !isObject(x)) {
|
1287
|
+
str += ' ' + x;
|
1288
|
+
} else {
|
1289
|
+
str += ' ' + inspect(x);
|
1290
|
+
}
|
1291
|
+
}
|
1292
|
+
return str;
|
1293
|
+
};
|
1294
|
+
|
1295
|
+
|
1296
|
+
// Mark that a method should not be used.
|
1297
|
+
// Returns a modified function which warns once by default.
|
1298
|
+
// If --no-deprecation is set, then it is a no-op.
|
1299
|
+
exports.deprecate = function(fn, msg) {
|
1300
|
+
// Allow for deprecating things in the process of starting up.
|
1301
|
+
if (isUndefined(global.process)) {
|
1302
|
+
return function() {
|
1303
|
+
return exports.deprecate(fn, msg).apply(this, arguments);
|
1304
|
+
};
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
if (process.noDeprecation === true) {
|
1308
|
+
return fn;
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
var warned = false;
|
1312
|
+
function deprecated() {
|
1313
|
+
if (!warned) {
|
1314
|
+
if (process.throwDeprecation) {
|
1315
|
+
throw new Error(msg);
|
1316
|
+
} else if (process.traceDeprecation) {
|
1317
|
+
console.trace(msg);
|
1318
|
+
} else {
|
1319
|
+
console.error(msg);
|
1320
|
+
}
|
1321
|
+
warned = true;
|
1322
|
+
}
|
1323
|
+
return fn.apply(this, arguments);
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
return deprecated;
|
1327
|
+
};
|
1328
|
+
|
1329
|
+
|
1330
|
+
var debugs = {};
|
1331
|
+
var debugEnviron;
|
1332
|
+
exports.debuglog = function(set) {
|
1333
|
+
if (isUndefined(debugEnviron))
|
1334
|
+
debugEnviron = process.env.NODE_DEBUG || '';
|
1335
|
+
set = set.toUpperCase();
|
1336
|
+
if (!debugs[set]) {
|
1337
|
+
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
1338
|
+
var pid = process.pid;
|
1339
|
+
debugs[set] = function() {
|
1340
|
+
var msg = exports.format.apply(exports, arguments);
|
1341
|
+
console.error('%s %d: %s', set, pid, msg);
|
1342
|
+
};
|
1343
|
+
} else {
|
1344
|
+
debugs[set] = function() {};
|
1345
|
+
}
|
1346
|
+
}
|
1347
|
+
return debugs[set];
|
1348
|
+
};
|
1349
|
+
|
1350
|
+
|
1351
|
+
/**
|
1352
|
+
* Echos the value of a value. Trys to print the value out
|
1353
|
+
* in the best way possible given the different types.
|
1354
|
+
*
|
1355
|
+
* @param {Object} obj The object to print out.
|
1356
|
+
* @param {Object} opts Optional options object that alters the output.
|
1357
|
+
*/
|
1358
|
+
/* legacy: obj, showHidden, depth, colors*/
|
1359
|
+
function inspect(obj, opts) {
|
1360
|
+
// default options
|
1361
|
+
var ctx = {
|
1362
|
+
seen: [],
|
1363
|
+
stylize: stylizeNoColor
|
1364
|
+
};
|
1365
|
+
// legacy...
|
1366
|
+
if (arguments.length >= 3) ctx.depth = arguments[2];
|
1367
|
+
if (arguments.length >= 4) ctx.colors = arguments[3];
|
1368
|
+
if (isBoolean(opts)) {
|
1369
|
+
// legacy...
|
1370
|
+
ctx.showHidden = opts;
|
1371
|
+
} else if (opts) {
|
1372
|
+
// got an "options" object
|
1373
|
+
exports._extend(ctx, opts);
|
1374
|
+
}
|
1375
|
+
// set default options
|
1376
|
+
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
1377
|
+
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
1378
|
+
if (isUndefined(ctx.colors)) ctx.colors = false;
|
1379
|
+
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
1380
|
+
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
1381
|
+
return formatValue(ctx, obj, ctx.depth);
|
1382
|
+
}
|
1383
|
+
exports.inspect = inspect;
|
1384
|
+
|
1385
|
+
|
1386
|
+
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
1387
|
+
inspect.colors = {
|
1388
|
+
'bold' : [1, 22],
|
1389
|
+
'italic' : [3, 23],
|
1390
|
+
'underline' : [4, 24],
|
1391
|
+
'inverse' : [7, 27],
|
1392
|
+
'white' : [37, 39],
|
1393
|
+
'grey' : [90, 39],
|
1394
|
+
'black' : [30, 39],
|
1395
|
+
'blue' : [34, 39],
|
1396
|
+
'cyan' : [36, 39],
|
1397
|
+
'green' : [32, 39],
|
1398
|
+
'magenta' : [35, 39],
|
1399
|
+
'red' : [31, 39],
|
1400
|
+
'yellow' : [33, 39]
|
1401
|
+
};
|
1402
|
+
|
1403
|
+
// Don't use 'blue' not visible on cmd.exe
|
1404
|
+
inspect.styles = {
|
1405
|
+
'special': 'cyan',
|
1406
|
+
'number': 'yellow',
|
1407
|
+
'boolean': 'yellow',
|
1408
|
+
'undefined': 'grey',
|
1409
|
+
'null': 'bold',
|
1410
|
+
'string': 'green',
|
1411
|
+
'date': 'magenta',
|
1412
|
+
// "name": intentionally not styling
|
1413
|
+
'regexp': 'red'
|
1414
|
+
};
|
1415
|
+
|
1416
|
+
|
1417
|
+
function stylizeWithColor(str, styleType) {
|
1418
|
+
var style = inspect.styles[styleType];
|
1419
|
+
|
1420
|
+
if (style) {
|
1421
|
+
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
1422
|
+
'\u001b[' + inspect.colors[style][1] + 'm';
|
1423
|
+
} else {
|
1424
|
+
return str;
|
1425
|
+
}
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
|
1429
|
+
function stylizeNoColor(str, styleType) {
|
1430
|
+
return str;
|
1431
|
+
}
|
1432
|
+
|
1433
|
+
|
1434
|
+
function arrayToHash(array) {
|
1435
|
+
var hash = {};
|
1436
|
+
|
1437
|
+
array.forEach(function(val, idx) {
|
1438
|
+
hash[val] = true;
|
1439
|
+
});
|
1440
|
+
|
1441
|
+
return hash;
|
1442
|
+
}
|
1443
|
+
|
1444
|
+
|
1445
|
+
function formatValue(ctx, value, recurseTimes) {
|
1446
|
+
// Provide a hook for user-specified inspect functions.
|
1447
|
+
// Check that value is an object with an inspect function on it
|
1448
|
+
if (ctx.customInspect &&
|
1449
|
+
value &&
|
1450
|
+
isFunction(value.inspect) &&
|
1451
|
+
// Filter out the util module, it's inspect function is special
|
1452
|
+
value.inspect !== exports.inspect &&
|
1453
|
+
// Also filter out any prototype objects using the circular check.
|
1454
|
+
!(value.constructor && value.constructor.prototype === value)) {
|
1455
|
+
var ret = value.inspect(recurseTimes, ctx);
|
1456
|
+
if (!isString(ret)) {
|
1457
|
+
ret = formatValue(ctx, ret, recurseTimes);
|
1458
|
+
}
|
1459
|
+
return ret;
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
// Primitive types cannot have properties
|
1463
|
+
var primitive = formatPrimitive(ctx, value);
|
1464
|
+
if (primitive) {
|
1465
|
+
return primitive;
|
1466
|
+
}
|
1467
|
+
|
1468
|
+
// Look up the keys of the object.
|
1469
|
+
var keys = Object.keys(value);
|
1470
|
+
var visibleKeys = arrayToHash(keys);
|
1471
|
+
|
1472
|
+
if (ctx.showHidden) {
|
1473
|
+
keys = Object.getOwnPropertyNames(value);
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
// IE doesn't make error fields non-enumerable
|
1477
|
+
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
|
1478
|
+
if (isError(value)
|
1479
|
+
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
1480
|
+
return formatError(value);
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
// Some type of object without properties can be shortcutted.
|
1484
|
+
if (keys.length === 0) {
|
1485
|
+
if (isFunction(value)) {
|
1486
|
+
var name = value.name ? ': ' + value.name : '';
|
1487
|
+
return ctx.stylize('[Function' + name + ']', 'special');
|
1488
|
+
}
|
1489
|
+
if (isRegExp(value)) {
|
1490
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
1491
|
+
}
|
1492
|
+
if (isDate(value)) {
|
1493
|
+
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
1494
|
+
}
|
1495
|
+
if (isError(value)) {
|
1496
|
+
return formatError(value);
|
1497
|
+
}
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
var base = '', array = false, braces = ['{', '}'];
|
1501
|
+
|
1502
|
+
// Make Array say that they are Array
|
1503
|
+
if (isArray(value)) {
|
1504
|
+
array = true;
|
1505
|
+
braces = ['[', ']'];
|
1506
|
+
}
|
1507
|
+
|
1508
|
+
// Make functions say that they are functions
|
1509
|
+
if (isFunction(value)) {
|
1510
|
+
var n = value.name ? ': ' + value.name : '';
|
1511
|
+
base = ' [Function' + n + ']';
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
// Make RegExps say that they are RegExps
|
1515
|
+
if (isRegExp(value)) {
|
1516
|
+
base = ' ' + RegExp.prototype.toString.call(value);
|
1517
|
+
}
|
1518
|
+
|
1519
|
+
// Make dates with properties first say the date
|
1520
|
+
if (isDate(value)) {
|
1521
|
+
base = ' ' + Date.prototype.toUTCString.call(value);
|
1522
|
+
}
|
1523
|
+
|
1524
|
+
// Make error with message first say the error
|
1525
|
+
if (isError(value)) {
|
1526
|
+
base = ' ' + formatError(value);
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
if (keys.length === 0 && (!array || value.length == 0)) {
|
1530
|
+
return braces[0] + base + braces[1];
|
1531
|
+
}
|
1532
|
+
|
1533
|
+
if (recurseTimes < 0) {
|
1534
|
+
if (isRegExp(value)) {
|
1535
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
1536
|
+
} else {
|
1537
|
+
return ctx.stylize('[Object]', 'special');
|
1538
|
+
}
|
1539
|
+
}
|
1540
|
+
|
1541
|
+
ctx.seen.push(value);
|
1542
|
+
|
1543
|
+
var output;
|
1544
|
+
if (array) {
|
1545
|
+
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
1546
|
+
} else {
|
1547
|
+
output = keys.map(function(key) {
|
1548
|
+
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
1549
|
+
});
|
1550
|
+
}
|
1551
|
+
|
1552
|
+
ctx.seen.pop();
|
1553
|
+
|
1554
|
+
return reduceToSingleString(output, base, braces);
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
|
1558
|
+
function formatPrimitive(ctx, value) {
|
1559
|
+
if (isUndefined(value))
|
1560
|
+
return ctx.stylize('undefined', 'undefined');
|
1561
|
+
if (isString(value)) {
|
1562
|
+
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
1563
|
+
.replace(/'/g, "\\'")
|
1564
|
+
.replace(/\\"/g, '"') + '\'';
|
1565
|
+
return ctx.stylize(simple, 'string');
|
1566
|
+
}
|
1567
|
+
if (isNumber(value))
|
1568
|
+
return ctx.stylize('' + value, 'number');
|
1569
|
+
if (isBoolean(value))
|
1570
|
+
return ctx.stylize('' + value, 'boolean');
|
1571
|
+
// For some reason typeof null is "object", so special case here.
|
1572
|
+
if (isNull(value))
|
1573
|
+
return ctx.stylize('null', 'null');
|
1574
|
+
}
|
1575
|
+
|
1576
|
+
|
1577
|
+
function formatError(value) {
|
1578
|
+
return '[' + Error.prototype.toString.call(value) + ']';
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
|
1582
|
+
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
1583
|
+
var output = [];
|
1584
|
+
for (var i = 0, l = value.length; i < l; ++i) {
|
1585
|
+
if (hasOwnProperty(value, String(i))) {
|
1586
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
1587
|
+
String(i), true));
|
1588
|
+
} else {
|
1589
|
+
output.push('');
|
1590
|
+
}
|
1591
|
+
}
|
1592
|
+
keys.forEach(function(key) {
|
1593
|
+
if (!key.match(/^\d+$/)) {
|
1594
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
1595
|
+
key, true));
|
1596
|
+
}
|
1597
|
+
});
|
1598
|
+
return output;
|
1599
|
+
}
|
1600
|
+
|
1601
|
+
|
1602
|
+
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
1603
|
+
var name, str, desc;
|
1604
|
+
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
1605
|
+
if (desc.get) {
|
1606
|
+
if (desc.set) {
|
1607
|
+
str = ctx.stylize('[Getter/Setter]', 'special');
|
1608
|
+
} else {
|
1609
|
+
str = ctx.stylize('[Getter]', 'special');
|
1610
|
+
}
|
1611
|
+
} else {
|
1612
|
+
if (desc.set) {
|
1613
|
+
str = ctx.stylize('[Setter]', 'special');
|
1614
|
+
}
|
1615
|
+
}
|
1616
|
+
if (!hasOwnProperty(visibleKeys, key)) {
|
1617
|
+
name = '[' + key + ']';
|
1618
|
+
}
|
1619
|
+
if (!str) {
|
1620
|
+
if (ctx.seen.indexOf(desc.value) < 0) {
|
1621
|
+
if (isNull(recurseTimes)) {
|
1622
|
+
str = formatValue(ctx, desc.value, null);
|
1623
|
+
} else {
|
1624
|
+
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
1625
|
+
}
|
1626
|
+
if (str.indexOf('\n') > -1) {
|
1627
|
+
if (array) {
|
1628
|
+
str = str.split('\n').map(function(line) {
|
1629
|
+
return ' ' + line;
|
1630
|
+
}).join('\n').substr(2);
|
1631
|
+
} else {
|
1632
|
+
str = '\n' + str.split('\n').map(function(line) {
|
1633
|
+
return ' ' + line;
|
1634
|
+
}).join('\n');
|
1635
|
+
}
|
1636
|
+
}
|
1637
|
+
} else {
|
1638
|
+
str = ctx.stylize('[Circular]', 'special');
|
1639
|
+
}
|
1640
|
+
}
|
1641
|
+
if (isUndefined(name)) {
|
1642
|
+
if (array && key.match(/^\d+$/)) {
|
1643
|
+
return str;
|
1644
|
+
}
|
1645
|
+
name = JSON.stringify('' + key);
|
1646
|
+
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
1647
|
+
name = name.substr(1, name.length - 2);
|
1648
|
+
name = ctx.stylize(name, 'name');
|
1649
|
+
} else {
|
1650
|
+
name = name.replace(/'/g, "\\'")
|
1651
|
+
.replace(/\\"/g, '"')
|
1652
|
+
.replace(/(^"|"$)/g, "'");
|
1653
|
+
name = ctx.stylize(name, 'string');
|
1654
|
+
}
|
1655
|
+
}
|
1656
|
+
|
1657
|
+
return name + ': ' + str;
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
|
1661
|
+
function reduceToSingleString(output, base, braces) {
|
1662
|
+
var numLinesEst = 0;
|
1663
|
+
var length = output.reduce(function(prev, cur) {
|
1664
|
+
numLinesEst++;
|
1665
|
+
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
1666
|
+
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
1667
|
+
}, 0);
|
1668
|
+
|
1669
|
+
if (length > 60) {
|
1670
|
+
return braces[0] +
|
1671
|
+
(base === '' ? '' : base + '\n ') +
|
1672
|
+
' ' +
|
1673
|
+
output.join(',\n ') +
|
1674
|
+
' ' +
|
1675
|
+
braces[1];
|
1676
|
+
}
|
1677
|
+
|
1678
|
+
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
1679
|
+
}
|
1680
|
+
|
1681
|
+
|
1682
|
+
// NOTE: These type checking functions intentionally don't use `instanceof`
|
1683
|
+
// because it is fragile and can be easily faked with `Object.create()`.
|
1684
|
+
function isArray(ar) {
|
1685
|
+
return Array.isArray(ar);
|
1686
|
+
}
|
1687
|
+
exports.isArray = isArray;
|
1688
|
+
|
1689
|
+
function isBoolean(arg) {
|
1690
|
+
return typeof arg === 'boolean';
|
1691
|
+
}
|
1692
|
+
exports.isBoolean = isBoolean;
|
1693
|
+
|
1694
|
+
function isNull(arg) {
|
1695
|
+
return arg === null;
|
1696
|
+
}
|
1697
|
+
exports.isNull = isNull;
|
1698
|
+
|
1699
|
+
function isNullOrUndefined(arg) {
|
1700
|
+
return arg == null;
|
1701
|
+
}
|
1702
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
1703
|
+
|
1704
|
+
function isNumber(arg) {
|
1705
|
+
return typeof arg === 'number';
|
1706
|
+
}
|
1707
|
+
exports.isNumber = isNumber;
|
1708
|
+
|
1709
|
+
function isString(arg) {
|
1710
|
+
return typeof arg === 'string';
|
1711
|
+
}
|
1712
|
+
exports.isString = isString;
|
1713
|
+
|
1714
|
+
function isSymbol(arg) {
|
1715
|
+
return typeof arg === 'symbol';
|
1716
|
+
}
|
1717
|
+
exports.isSymbol = isSymbol;
|
1718
|
+
|
1719
|
+
function isUndefined(arg) {
|
1720
|
+
return arg === void 0;
|
1721
|
+
}
|
1722
|
+
exports.isUndefined = isUndefined;
|
1723
|
+
|
1724
|
+
function isRegExp(re) {
|
1725
|
+
return isObject(re) && objectToString(re) === '[object RegExp]';
|
1726
|
+
}
|
1727
|
+
exports.isRegExp = isRegExp;
|
1728
|
+
|
1729
|
+
function isObject(arg) {
|
1730
|
+
return typeof arg === 'object' && arg !== null;
|
1731
|
+
}
|
1732
|
+
exports.isObject = isObject;
|
1733
|
+
|
1734
|
+
function isDate(d) {
|
1735
|
+
return isObject(d) && objectToString(d) === '[object Date]';
|
1736
|
+
}
|
1737
|
+
exports.isDate = isDate;
|
1738
|
+
|
1739
|
+
function isError(e) {
|
1740
|
+
return isObject(e) &&
|
1741
|
+
(objectToString(e) === '[object Error]' || e instanceof Error);
|
1742
|
+
}
|
1743
|
+
exports.isError = isError;
|
1744
|
+
|
1745
|
+
function isFunction(arg) {
|
1746
|
+
return typeof arg === 'function';
|
1747
|
+
}
|
1748
|
+
exports.isFunction = isFunction;
|
1749
|
+
|
1750
|
+
function isPrimitive(arg) {
|
1751
|
+
return arg === null ||
|
1752
|
+
typeof arg === 'boolean' ||
|
1753
|
+
typeof arg === 'number' ||
|
1754
|
+
typeof arg === 'string' ||
|
1755
|
+
typeof arg === 'symbol' || // ES6 symbol
|
1756
|
+
typeof arg === 'undefined';
|
1757
|
+
}
|
1758
|
+
exports.isPrimitive = isPrimitive;
|
1759
|
+
|
1760
|
+
exports.isBuffer = require('./support/isBuffer');
|
1761
|
+
|
1762
|
+
function objectToString(o) {
|
1763
|
+
return Object.prototype.toString.call(o);
|
1764
|
+
}
|
1765
|
+
|
1766
|
+
|
1767
|
+
function pad(n) {
|
1768
|
+
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
1769
|
+
}
|
1770
|
+
|
1771
|
+
|
1772
|
+
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
1773
|
+
'Oct', 'Nov', 'Dec'];
|
1774
|
+
|
1775
|
+
// 26 Feb 16:19:34
|
1776
|
+
function timestamp() {
|
1777
|
+
var d = new Date();
|
1778
|
+
var time = [pad(d.getHours()),
|
1779
|
+
pad(d.getMinutes()),
|
1780
|
+
pad(d.getSeconds())].join(':');
|
1781
|
+
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
1782
|
+
}
|
1783
|
+
|
1784
|
+
|
1785
|
+
// log is just a thin wrapper to console.log that prepends a timestamp
|
1786
|
+
exports.log = function() {
|
1787
|
+
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
1788
|
+
};
|
1789
|
+
|
1790
|
+
|
1791
|
+
/**
|
1792
|
+
* Inherit the prototype methods from one constructor into another.
|
1793
|
+
*
|
1794
|
+
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
1795
|
+
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
1796
|
+
* during bootstrapping this function needs to be rewritten using some native
|
1797
|
+
* functions as prototype setup using normal JavaScript does not work as
|
1798
|
+
* expected during bootstrapping (see mirror.js in r114903).
|
1799
|
+
*
|
1800
|
+
* @param {function} ctor Constructor function which needs to inherit the
|
1801
|
+
* prototype.
|
1802
|
+
* @param {function} superCtor Constructor function to inherit prototype from.
|
1803
|
+
*/
|
1804
|
+
exports.inherits = require('inherits');
|
1805
|
+
|
1806
|
+
exports._extend = function(origin, add) {
|
1807
|
+
// Don't do anything if add isn't an object
|
1808
|
+
if (!add || !isObject(add)) return origin;
|
1809
|
+
|
1810
|
+
var keys = Object.keys(add);
|
1811
|
+
var i = keys.length;
|
1812
|
+
while (i--) {
|
1813
|
+
origin[keys[i]] = add[keys[i]];
|
1814
|
+
}
|
1815
|
+
return origin;
|
1816
|
+
};
|
1817
|
+
|
1818
|
+
function hasOwnProperty(obj, prop) {
|
1819
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
1820
|
+
}
|
1821
|
+
|
1822
|
+
}).call(this,require("/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
1823
|
+
},{"./support/isBuffer":13,"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":12,"inherits":11}]},{},[]);coffeeReactTransform = require('coffee-react-transform');
|