rails-pixrem 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.fs.yml +1 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/lib/rails-pixrem.rb +17 -0
- data/lib/rails-pixrem/processor.rb +32 -0
- data/lib/rails-pixrem/railtie.rb +17 -0
- data/lib/rails-pixrem/sprockets.rb +45 -0
- data/lib/rails-pixrem/version.rb +3 -0
- data/rails-pixrem.gemspec +27 -0
- data/spec/dummy/Rakefile +2 -0
- data/spec/dummy/app/assets/stylesheets/rails.css.scss +3 -0
- data/spec/dummy/app/assets/stylesheets/test.css +3 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/css_controller.rb +5 -0
- data/spec/dummy/config.ru +2 -0
- data/spec/dummy/config/application.rb +14 -0
- data/spec/dummy/config/boot.rb +2 -0
- data/spec/dummy/config/environment.rb +2 -0
- data/spec/dummy/config/environments/test.rb +11 -0
- data/spec/dummy/config/initializers/compress.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/pixrem.yml +1 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/rails-pixrem/processor_spec.rb +18 -0
- data/spec/rails-pixrem/rails_spec.rb +16 -0
- data/spec/rails-pixrem/sprockets_spec.rb +31 -0
- data/spec/spec_helper.rb +14 -0
- data/vendor/pixrem.js +4595 -0
- metadata +164 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require_relative 'dummy/config/environment'
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/its'
|
6
|
+
|
7
|
+
require_relative '../lib/rails-pixrem'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
config.order = 'random'
|
14
|
+
end
|
data/vendor/pixrem.js
ADDED
@@ -0,0 +1,4595 @@
|
|
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})({"L9tR7m":[function(require,module,exports){
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// Add pixel fallbacks for rem units to a string of CSS
|
5
|
+
// - css `String`: the contents of a CSS file.
|
6
|
+
// - rootvalue `String | Null`: The root element font size. Default = 16px.
|
7
|
+
// - options `Object`
|
8
|
+
// - replace `Boolean`: Replace rems with pixels instead of providing
|
9
|
+
// fallbacks. Default = false.
|
10
|
+
// }
|
11
|
+
module.exports = function pixrem(css, rootvalue, options) {
|
12
|
+
var postcss = require('postcss');
|
13
|
+
var remgex = /(\d*\.?\d+)rem/ig;
|
14
|
+
var rootvalue = typeof rootvalue !== 'undefined' ? rootvalue : 16;
|
15
|
+
var options = typeof options !== 'undefined' ? options : {
|
16
|
+
replace: false
|
17
|
+
};
|
18
|
+
var postprocessor = postcss(function (css) {
|
19
|
+
|
20
|
+
css.eachDecl(function (decl, i) {
|
21
|
+
var rule = decl.parent;
|
22
|
+
var value = decl.value;
|
23
|
+
|
24
|
+
if (value.indexOf('rem') != -1) {
|
25
|
+
|
26
|
+
value = value.replace(remgex, function ($1) {
|
27
|
+
// Round decimal pixels down to match webkit and opera behavior:
|
28
|
+
// http://tylertate.com/blog/2012/01/05/subpixel-rounding.html
|
29
|
+
return Math.floor(parseFloat($1) * toPx(rootvalue)) + 'px';
|
30
|
+
});
|
31
|
+
|
32
|
+
if (options.replace) {
|
33
|
+
decl.value = value;
|
34
|
+
} else {
|
35
|
+
rule.insertBefore(i, decl.clone({ value: value }));
|
36
|
+
}
|
37
|
+
}
|
38
|
+
});
|
39
|
+
});
|
40
|
+
|
41
|
+
// Return a unitless pixel value from any root font-size value.
|
42
|
+
function toPx(value) {
|
43
|
+
var parts = /^(\d+\.?\d*)([a-zA-Z%]*)$/.exec(value);
|
44
|
+
var number = parts[1];
|
45
|
+
var unit = parts[2];
|
46
|
+
|
47
|
+
if (unit === 'px' || unit === '') {
|
48
|
+
return parseFloat(number);
|
49
|
+
}
|
50
|
+
else if (unit === 'em' || unit === 'rem') {
|
51
|
+
return parseFloat(number) * 16;
|
52
|
+
}
|
53
|
+
else if (unit === '%') {
|
54
|
+
return (parseFloat(number) / 100) * 16;
|
55
|
+
}
|
56
|
+
|
57
|
+
// TODO: Should we throw an error here?
|
58
|
+
return false;
|
59
|
+
}
|
60
|
+
|
61
|
+
return postprocessor.process(css).css;
|
62
|
+
};
|
63
|
+
|
64
|
+
},{"postcss":12}],"pixrem":[function(require,module,exports){
|
65
|
+
module.exports=require('L9tR7m');
|
66
|
+
},{}],3:[function(require,module,exports){
|
67
|
+
(function() {
|
68
|
+
var AtRule, Container, name, _fn, _i, _len, _ref,
|
69
|
+
__hasProp = {}.hasOwnProperty,
|
70
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
71
|
+
|
72
|
+
Container = require('./container');
|
73
|
+
|
74
|
+
AtRule = (function(_super) {
|
75
|
+
__extends(AtRule, _super);
|
76
|
+
|
77
|
+
function AtRule() {
|
78
|
+
this.type = 'atrule';
|
79
|
+
AtRule.__super__.constructor.apply(this, arguments);
|
80
|
+
}
|
81
|
+
|
82
|
+
AtRule.prototype.styleType = function() {
|
83
|
+
return this.type + ((this.rules != null) || (this.decls != null) ? '-body' : '-bodiless');
|
84
|
+
};
|
85
|
+
|
86
|
+
AtRule.prototype.defaultStyle = function(type) {
|
87
|
+
if (type === 'atrule-body') {
|
88
|
+
return {
|
89
|
+
between: ' ',
|
90
|
+
after: this.defaultAfter()
|
91
|
+
};
|
92
|
+
} else {
|
93
|
+
return {
|
94
|
+
between: ''
|
95
|
+
};
|
96
|
+
}
|
97
|
+
};
|
98
|
+
|
99
|
+
AtRule.prototype.addMixin = function(type) {
|
100
|
+
var container, detector, mixin, name, value, _ref;
|
101
|
+
mixin = type === 'rules' ? Container.WithRules : Container.WithDecls;
|
102
|
+
if (!mixin) {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
_ref = mixin.prototype;
|
106
|
+
for (name in _ref) {
|
107
|
+
value = _ref[name];
|
108
|
+
if (name === 'constructor') {
|
109
|
+
continue;
|
110
|
+
}
|
111
|
+
container = Container.prototype[name] === value;
|
112
|
+
detector = name === 'append' || name === 'prepend';
|
113
|
+
if (container && !detector) {
|
114
|
+
continue;
|
115
|
+
}
|
116
|
+
this[name] = value;
|
117
|
+
}
|
118
|
+
return mixin.apply(this);
|
119
|
+
};
|
120
|
+
|
121
|
+
AtRule.raw('params');
|
122
|
+
|
123
|
+
AtRule.prototype.stringify = function(builder, last) {
|
124
|
+
var name, params, semicolon, style;
|
125
|
+
style = this.style();
|
126
|
+
name = '@' + this.name;
|
127
|
+
params = this._params ? this._params.toString() : '';
|
128
|
+
name += this.afterName != null ? this.afterName : params ? ' ' : '';
|
129
|
+
if ((this.rules != null) || (this.decls != null)) {
|
130
|
+
return this.stringifyBlock(builder, name + params + style.between + '{');
|
131
|
+
} else {
|
132
|
+
if (this.before) {
|
133
|
+
builder(this.before);
|
134
|
+
}
|
135
|
+
semicolon = !last || this.semicolon ? ';' : '';
|
136
|
+
return builder(name + params + style.between + semicolon, this);
|
137
|
+
}
|
138
|
+
};
|
139
|
+
|
140
|
+
return AtRule;
|
141
|
+
|
142
|
+
})(Container);
|
143
|
+
|
144
|
+
_ref = ['append', 'prepend'];
|
145
|
+
_fn = function(name) {
|
146
|
+
return AtRule.prototype[name] = function(child) {
|
147
|
+
var mixin;
|
148
|
+
mixin = child.type === 'decl' ? 'decls' : 'rules';
|
149
|
+
this.addMixin(mixin);
|
150
|
+
return this[name](child);
|
151
|
+
};
|
152
|
+
};
|
153
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
154
|
+
name = _ref[_i];
|
155
|
+
_fn(name);
|
156
|
+
}
|
157
|
+
|
158
|
+
module.exports = AtRule;
|
159
|
+
|
160
|
+
}).call(this);
|
161
|
+
|
162
|
+
},{"./container":5}],4:[function(require,module,exports){
|
163
|
+
(function() {
|
164
|
+
var Comment, Node,
|
165
|
+
__hasProp = {}.hasOwnProperty,
|
166
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
167
|
+
|
168
|
+
Node = require('./node');
|
169
|
+
|
170
|
+
Comment = (function(_super) {
|
171
|
+
__extends(Comment, _super);
|
172
|
+
|
173
|
+
function Comment() {
|
174
|
+
this.type = 'comment';
|
175
|
+
Comment.__super__.constructor.apply(this, arguments);
|
176
|
+
}
|
177
|
+
|
178
|
+
Comment.prototype.defaultStyle = function() {
|
179
|
+
return {
|
180
|
+
left: ' ',
|
181
|
+
right: ' '
|
182
|
+
};
|
183
|
+
};
|
184
|
+
|
185
|
+
Comment.prototype.stringify = function(builder) {
|
186
|
+
var style;
|
187
|
+
if (this.before) {
|
188
|
+
builder(this.before);
|
189
|
+
}
|
190
|
+
style = this.style();
|
191
|
+
return builder("/*" + (style.left + this.text + style.right) + "*/", this);
|
192
|
+
};
|
193
|
+
|
194
|
+
return Comment;
|
195
|
+
|
196
|
+
})(Node);
|
197
|
+
|
198
|
+
module.exports = Comment;
|
199
|
+
|
200
|
+
}).call(this);
|
201
|
+
|
202
|
+
},{"./node":10}],5:[function(require,module,exports){
|
203
|
+
(function() {
|
204
|
+
var Container, Declaration, Node,
|
205
|
+
__hasProp = {}.hasOwnProperty,
|
206
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
207
|
+
|
208
|
+
Node = require('./node');
|
209
|
+
|
210
|
+
Declaration = require('./declaration');
|
211
|
+
|
212
|
+
Container = (function(_super) {
|
213
|
+
__extends(Container, _super);
|
214
|
+
|
215
|
+
function Container() {
|
216
|
+
return Container.__super__.constructor.apply(this, arguments);
|
217
|
+
}
|
218
|
+
|
219
|
+
Container.prototype.stringifyContent = function(builder) {
|
220
|
+
var last;
|
221
|
+
if (!this.rules && !this.decls) {
|
222
|
+
return;
|
223
|
+
}
|
224
|
+
if (this.rules) {
|
225
|
+
last = this.rules.length - 1;
|
226
|
+
return this.rules.map(function(rule, i) {
|
227
|
+
return rule.stringify(builder, last === i);
|
228
|
+
});
|
229
|
+
} else if (this.decls) {
|
230
|
+
last = this.decls.length - 1;
|
231
|
+
return this.decls.map((function(_this) {
|
232
|
+
return function(decl, i) {
|
233
|
+
return decl.stringify(builder, last !== i || _this.semicolon);
|
234
|
+
};
|
235
|
+
})(this));
|
236
|
+
}
|
237
|
+
};
|
238
|
+
|
239
|
+
Container.prototype.defaultAfter = function() {
|
240
|
+
var _ref;
|
241
|
+
if (this.list.length === 0) {
|
242
|
+
return '';
|
243
|
+
} else if (((_ref = this.list[0].before) != null ? _ref.indexOf("\n") : void 0) === -1) {
|
244
|
+
return this.list[0].before;
|
245
|
+
} else {
|
246
|
+
return "\n";
|
247
|
+
}
|
248
|
+
};
|
249
|
+
|
250
|
+
Container.prototype.stringifyBlock = function(builder, start) {
|
251
|
+
var style;
|
252
|
+
style = this.style();
|
253
|
+
if (this.before) {
|
254
|
+
builder(this.before);
|
255
|
+
}
|
256
|
+
builder(start, this, 'start');
|
257
|
+
this.stringifyContent(builder);
|
258
|
+
if (style.after) {
|
259
|
+
builder(style.after);
|
260
|
+
}
|
261
|
+
return builder('}', this, 'end');
|
262
|
+
};
|
263
|
+
|
264
|
+
Container.prototype.push = function(child) {
|
265
|
+
child.parent = this;
|
266
|
+
this.list.push(child);
|
267
|
+
return this;
|
268
|
+
};
|
269
|
+
|
270
|
+
Container.prototype.each = function(callback) {
|
271
|
+
var id, index, list, result;
|
272
|
+
this.lastEach || (this.lastEach = 0);
|
273
|
+
this.indexes || (this.indexes = {});
|
274
|
+
this.lastEach += 1;
|
275
|
+
id = this.lastEach;
|
276
|
+
this.indexes[id] = 0;
|
277
|
+
list = this.list;
|
278
|
+
if (!list) {
|
279
|
+
return;
|
280
|
+
}
|
281
|
+
while (this.indexes[id] < list.length) {
|
282
|
+
index = this.indexes[id];
|
283
|
+
result = callback(list[index], index);
|
284
|
+
if (result === false) {
|
285
|
+
break;
|
286
|
+
}
|
287
|
+
this.indexes[id] += 1;
|
288
|
+
}
|
289
|
+
delete this.indexes[id];
|
290
|
+
if (result === false) {
|
291
|
+
return false;
|
292
|
+
}
|
293
|
+
};
|
294
|
+
|
295
|
+
Container.prototype.eachInside = function(callback) {
|
296
|
+
return this.each((function(_this) {
|
297
|
+
return function(child, i) {
|
298
|
+
var result;
|
299
|
+
result = callback(child, i);
|
300
|
+
if (result !== false && child.eachInside) {
|
301
|
+
result = child.eachInside(callback);
|
302
|
+
}
|
303
|
+
if (result === false) {
|
304
|
+
return result;
|
305
|
+
}
|
306
|
+
};
|
307
|
+
})(this));
|
308
|
+
};
|
309
|
+
|
310
|
+
Container.prototype.eachDecl = function(callback) {};
|
311
|
+
|
312
|
+
Container.prototype.eachComment = function(callback) {
|
313
|
+
return this.eachInside((function(_this) {
|
314
|
+
return function(child, i) {
|
315
|
+
var result;
|
316
|
+
result = child.type === 'comment' ? callback(child, i) : void 0;
|
317
|
+
if (result === false) {
|
318
|
+
return result;
|
319
|
+
}
|
320
|
+
};
|
321
|
+
})(this));
|
322
|
+
};
|
323
|
+
|
324
|
+
Container.prototype.append = function(child) {
|
325
|
+
child = this.normalize(child, this.list[this.list.length - 1]);
|
326
|
+
this.list.push(child);
|
327
|
+
return this;
|
328
|
+
};
|
329
|
+
|
330
|
+
Container.prototype.prepend = function(child) {
|
331
|
+
var id, index, _ref;
|
332
|
+
child = this.normalize(child, this.list[0], 'prepend');
|
333
|
+
this.list.unshift(child);
|
334
|
+
_ref = this.indexes;
|
335
|
+
for (id in _ref) {
|
336
|
+
index = _ref[id];
|
337
|
+
this.indexes[id] = index + 1;
|
338
|
+
}
|
339
|
+
return this;
|
340
|
+
};
|
341
|
+
|
342
|
+
Container.prototype.insertBefore = function(exist, add) {
|
343
|
+
var id, index, _ref;
|
344
|
+
exist = this.index(exist);
|
345
|
+
add = this.normalize(add, this.list[exist], exist === 0 ? 'prepend' : void 0);
|
346
|
+
this.list.splice(exist, 0, add);
|
347
|
+
_ref = this.indexes;
|
348
|
+
for (id in _ref) {
|
349
|
+
index = _ref[id];
|
350
|
+
if (index >= exist) {
|
351
|
+
this.indexes[id] = index + 1;
|
352
|
+
}
|
353
|
+
}
|
354
|
+
return this;
|
355
|
+
};
|
356
|
+
|
357
|
+
Container.prototype.insertAfter = function(exist, add) {
|
358
|
+
var id, index, _ref;
|
359
|
+
exist = this.index(exist);
|
360
|
+
add = this.normalize(add, this.list[exist]);
|
361
|
+
this.list.splice(exist + 1, 0, add);
|
362
|
+
_ref = this.indexes;
|
363
|
+
for (id in _ref) {
|
364
|
+
index = _ref[id];
|
365
|
+
if (index > exist) {
|
366
|
+
this.indexes[id] = index + 1;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
return this;
|
370
|
+
};
|
371
|
+
|
372
|
+
Container.prototype.remove = function(child) {
|
373
|
+
var id, index, _ref;
|
374
|
+
child = this.index(child);
|
375
|
+
this.list.splice(child, 1);
|
376
|
+
_ref = this.indexes;
|
377
|
+
for (id in _ref) {
|
378
|
+
index = _ref[id];
|
379
|
+
if (index >= child) {
|
380
|
+
this.indexes[id] = index - 1;
|
381
|
+
}
|
382
|
+
}
|
383
|
+
return this;
|
384
|
+
};
|
385
|
+
|
386
|
+
Container.prototype.every = function(condition) {
|
387
|
+
return this.list.every(condition);
|
388
|
+
};
|
389
|
+
|
390
|
+
Container.prototype.some = function(condition) {
|
391
|
+
return this.list.some(condition);
|
392
|
+
};
|
393
|
+
|
394
|
+
Container.prototype.index = function(child) {
|
395
|
+
if (typeof child === 'number') {
|
396
|
+
return child;
|
397
|
+
} else {
|
398
|
+
return this.list.indexOf(child);
|
399
|
+
}
|
400
|
+
};
|
401
|
+
|
402
|
+
Container.prop('first', {
|
403
|
+
get: function() {
|
404
|
+
return this.list[0];
|
405
|
+
}
|
406
|
+
});
|
407
|
+
|
408
|
+
Container.prop('last', {
|
409
|
+
get: function() {
|
410
|
+
return this.list[this.list.length - 1];
|
411
|
+
}
|
412
|
+
});
|
413
|
+
|
414
|
+
Container.prop('list', {
|
415
|
+
get: function() {
|
416
|
+
return this.rules || this.decls;
|
417
|
+
}
|
418
|
+
});
|
419
|
+
|
420
|
+
Container.prototype.normalize = function(child, sample) {
|
421
|
+
child.parent = this;
|
422
|
+
if ((child.before == null) && sample) {
|
423
|
+
child.before = sample.before;
|
424
|
+
}
|
425
|
+
return child;
|
426
|
+
};
|
427
|
+
|
428
|
+
return Container;
|
429
|
+
|
430
|
+
})(Node);
|
431
|
+
|
432
|
+
Container.WithRules = (function(_super) {
|
433
|
+
__extends(WithRules, _super);
|
434
|
+
|
435
|
+
function WithRules() {
|
436
|
+
this.rules = [];
|
437
|
+
WithRules.__super__.constructor.apply(this, arguments);
|
438
|
+
}
|
439
|
+
|
440
|
+
WithRules.prototype.eachDecl = function(callback) {
|
441
|
+
return this.each(function(child) {
|
442
|
+
var result;
|
443
|
+
if (!child.eachDecl) {
|
444
|
+
return;
|
445
|
+
}
|
446
|
+
result = child.eachDecl(callback);
|
447
|
+
if (result === false) {
|
448
|
+
return result;
|
449
|
+
}
|
450
|
+
});
|
451
|
+
};
|
452
|
+
|
453
|
+
WithRules.prototype.eachRule = function(callback) {
|
454
|
+
return this.each((function(_this) {
|
455
|
+
return function(child, i) {
|
456
|
+
var result;
|
457
|
+
result = child.type === 'rule' ? callback(child, i) : child.eachRule ? child.eachRule(callback) : void 0;
|
458
|
+
if (result === false) {
|
459
|
+
return result;
|
460
|
+
}
|
461
|
+
};
|
462
|
+
})(this));
|
463
|
+
};
|
464
|
+
|
465
|
+
WithRules.prototype.eachAtRule = function(callback) {
|
466
|
+
return this.eachInside((function(_this) {
|
467
|
+
return function(child, i) {
|
468
|
+
var result;
|
469
|
+
result = child.type === 'atrule' ? callback(child, i) : void 0;
|
470
|
+
if (result === false) {
|
471
|
+
return result;
|
472
|
+
}
|
473
|
+
};
|
474
|
+
})(this));
|
475
|
+
};
|
476
|
+
|
477
|
+
return WithRules;
|
478
|
+
|
479
|
+
})(Container);
|
480
|
+
|
481
|
+
Container.WithDecls = (function(_super) {
|
482
|
+
__extends(WithDecls, _super);
|
483
|
+
|
484
|
+
function WithDecls() {
|
485
|
+
this.decls = [];
|
486
|
+
WithDecls.__super__.constructor.apply(this, arguments);
|
487
|
+
}
|
488
|
+
|
489
|
+
WithDecls.prototype.normalize = function(child, sample) {
|
490
|
+
if (!child.type) {
|
491
|
+
child = new Declaration(child);
|
492
|
+
}
|
493
|
+
return WithDecls.__super__.normalize.call(this, child, sample);
|
494
|
+
};
|
495
|
+
|
496
|
+
WithDecls.prototype.eachDecl = function(callback) {
|
497
|
+
return this.each((function(_this) {
|
498
|
+
return function(node, i) {
|
499
|
+
var result;
|
500
|
+
if (node.type !== 'decl') {
|
501
|
+
return;
|
502
|
+
}
|
503
|
+
result = callback(node, i);
|
504
|
+
if (result === false) {
|
505
|
+
return result;
|
506
|
+
}
|
507
|
+
};
|
508
|
+
})(this));
|
509
|
+
};
|
510
|
+
|
511
|
+
return WithDecls;
|
512
|
+
|
513
|
+
})(Container);
|
514
|
+
|
515
|
+
module.exports = Container;
|
516
|
+
|
517
|
+
}).call(this);
|
518
|
+
|
519
|
+
},{"./declaration":6,"./node":10}],6:[function(require,module,exports){
|
520
|
+
(function() {
|
521
|
+
var Declaration, Node, vendor,
|
522
|
+
__hasProp = {}.hasOwnProperty,
|
523
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
524
|
+
|
525
|
+
Node = require('./node');
|
526
|
+
|
527
|
+
vendor = require('./vendor');
|
528
|
+
|
529
|
+
Declaration = (function(_super) {
|
530
|
+
__extends(Declaration, _super);
|
531
|
+
|
532
|
+
function Declaration() {
|
533
|
+
this.type = 'decl';
|
534
|
+
Declaration.__super__.constructor.apply(this, arguments);
|
535
|
+
}
|
536
|
+
|
537
|
+
Declaration.prototype.defaultStyle = function() {
|
538
|
+
return {
|
539
|
+
before: "\n ",
|
540
|
+
between: ': '
|
541
|
+
};
|
542
|
+
};
|
543
|
+
|
544
|
+
Declaration.raw('value');
|
545
|
+
|
546
|
+
Declaration.prop('important', {
|
547
|
+
get: function() {
|
548
|
+
return !!this._important;
|
549
|
+
},
|
550
|
+
set: function(value) {
|
551
|
+
if (typeof value === 'string' && value !== '') {
|
552
|
+
return this._important = value;
|
553
|
+
} else if (value) {
|
554
|
+
return this._important = ' !important';
|
555
|
+
} else {
|
556
|
+
return this._important = false;
|
557
|
+
}
|
558
|
+
}
|
559
|
+
});
|
560
|
+
|
561
|
+
Declaration.prototype.stringify = function(builder, semicolon) {
|
562
|
+
var string, style;
|
563
|
+
style = this.style();
|
564
|
+
if (style.before) {
|
565
|
+
builder(style.before);
|
566
|
+
}
|
567
|
+
string = this.prop + style.between + this._value.toString();
|
568
|
+
string += this._important || '';
|
569
|
+
if (semicolon) {
|
570
|
+
string += ';';
|
571
|
+
}
|
572
|
+
return builder(string, this);
|
573
|
+
};
|
574
|
+
|
575
|
+
Declaration.prototype.clone = function(obj) {
|
576
|
+
var cloned;
|
577
|
+
cloned = Declaration.__super__.clone.apply(this, arguments);
|
578
|
+
delete cloned.before;
|
579
|
+
return cloned;
|
580
|
+
};
|
581
|
+
|
582
|
+
return Declaration;
|
583
|
+
|
584
|
+
})(Node);
|
585
|
+
|
586
|
+
module.exports = Declaration;
|
587
|
+
|
588
|
+
}).call(this);
|
589
|
+
|
590
|
+
},{"./node":10,"./vendor":18}],7:[function(require,module,exports){
|
591
|
+
(function() {
|
592
|
+
var lazy;
|
593
|
+
|
594
|
+
lazy = function(klass, name, callback) {
|
595
|
+
var cache;
|
596
|
+
cache = name + 'Cache';
|
597
|
+
return klass.prototype[name] = function() {
|
598
|
+
if (this[cache] != null) {
|
599
|
+
return this[cache];
|
600
|
+
} else {
|
601
|
+
return this[cache] = callback.apply(this, arguments);
|
602
|
+
}
|
603
|
+
};
|
604
|
+
};
|
605
|
+
|
606
|
+
module.exports = lazy;
|
607
|
+
|
608
|
+
}).call(this);
|
609
|
+
|
610
|
+
},{}],8:[function(require,module,exports){
|
611
|
+
(function() {
|
612
|
+
var list;
|
613
|
+
|
614
|
+
list = {
|
615
|
+
split: function(string, separators, last) {
|
616
|
+
var array, current, escape, func, letter, quote, separator, split, _i, _j, _len, _len1;
|
617
|
+
array = [];
|
618
|
+
current = '';
|
619
|
+
split = false;
|
620
|
+
func = 0;
|
621
|
+
quote = false;
|
622
|
+
escape = false;
|
623
|
+
for (_i = 0, _len = string.length; _i < _len; _i++) {
|
624
|
+
letter = string[_i];
|
625
|
+
if (quote) {
|
626
|
+
if (escape) {
|
627
|
+
escape = false;
|
628
|
+
} else if (letter === '\\') {
|
629
|
+
escape = true;
|
630
|
+
} else if (letter === quote) {
|
631
|
+
quote = false;
|
632
|
+
}
|
633
|
+
} else if (letter === '"' || letter === "'") {
|
634
|
+
quote = letter;
|
635
|
+
} else if (letter === '(') {
|
636
|
+
func += 1;
|
637
|
+
} else if (letter === ')') {
|
638
|
+
if (func > 0) {
|
639
|
+
func -= 1;
|
640
|
+
}
|
641
|
+
} else if (func === 0) {
|
642
|
+
for (_j = 0, _len1 = separators.length; _j < _len1; _j++) {
|
643
|
+
separator = separators[_j];
|
644
|
+
if (letter === separator) {
|
645
|
+
split = true;
|
646
|
+
}
|
647
|
+
}
|
648
|
+
}
|
649
|
+
if (split) {
|
650
|
+
if (current !== '') {
|
651
|
+
array.push(current.trim());
|
652
|
+
}
|
653
|
+
current = '';
|
654
|
+
split = false;
|
655
|
+
} else {
|
656
|
+
current += letter;
|
657
|
+
}
|
658
|
+
}
|
659
|
+
if (last || current !== '') {
|
660
|
+
array.push(current.trim());
|
661
|
+
}
|
662
|
+
return array;
|
663
|
+
},
|
664
|
+
space: function(string) {
|
665
|
+
return this.split(string, [' ', "\n", "\t"]);
|
666
|
+
},
|
667
|
+
comma: function(string) {
|
668
|
+
return this.split(string, [','], true);
|
669
|
+
}
|
670
|
+
};
|
671
|
+
|
672
|
+
module.exports = list;
|
673
|
+
|
674
|
+
}).call(this);
|
675
|
+
|
676
|
+
},{}],9:[function(require,module,exports){
|
677
|
+
(function() {
|
678
|
+
var MapGenerator, Result, base64js, fs, lazy, mozilla, path;
|
679
|
+
|
680
|
+
base64js = require('base64-js');
|
681
|
+
|
682
|
+
mozilla = require('source-map');
|
683
|
+
|
684
|
+
Result = require('./result');
|
685
|
+
|
686
|
+
lazy = require('./lazy');
|
687
|
+
|
688
|
+
path = require('path');
|
689
|
+
|
690
|
+
fs = require('fs');
|
691
|
+
|
692
|
+
MapGenerator = (function() {
|
693
|
+
function MapGenerator(root, opts) {
|
694
|
+
this.root = root;
|
695
|
+
this.opts = opts;
|
696
|
+
}
|
697
|
+
|
698
|
+
MapGenerator.prototype.startWith = function(string, start) {
|
699
|
+
return string.slice(0, +(start.length - 1) + 1 || 9e9) === start;
|
700
|
+
};
|
701
|
+
|
702
|
+
MapGenerator.prototype.isMap = function() {
|
703
|
+
if (typeof this.opts.map === 'boolean') {
|
704
|
+
return this.opts.map;
|
705
|
+
}
|
706
|
+
return !!this.opts.inlineMap || !!this.prevMap();
|
707
|
+
};
|
708
|
+
|
709
|
+
lazy(MapGenerator, 'isInline', function() {
|
710
|
+
if (this.opts.inlineMap != null) {
|
711
|
+
return this.opts.inlineMap;
|
712
|
+
}
|
713
|
+
return this.isPrevInline();
|
714
|
+
});
|
715
|
+
|
716
|
+
lazy(MapGenerator, 'isPrevInline', function() {
|
717
|
+
var text;
|
718
|
+
if (!this.prevAnnotation()) {
|
719
|
+
return false;
|
720
|
+
}
|
721
|
+
text = this.prevAnnotation().text;
|
722
|
+
return this.startWith(text, '# sourceMappingURL=data:');
|
723
|
+
});
|
724
|
+
|
725
|
+
lazy(MapGenerator, 'prevMap', function() {
|
726
|
+
var file, map;
|
727
|
+
if (this.opts.map && typeof this.opts.map !== 'boolean') {
|
728
|
+
return this.opts.map;
|
729
|
+
}
|
730
|
+
if (this.isPrevInline()) {
|
731
|
+
return this.encodeInline(this.prevAnnotation().text);
|
732
|
+
} else if (this.opts.from) {
|
733
|
+
map = this.opts.from + '.map';
|
734
|
+
if (this.prevAnnotation()) {
|
735
|
+
file = this.prevAnnotation().text.replace('# sourceMappingURL=', '');
|
736
|
+
map = path.join(path.dirname(this.opts.from), file);
|
737
|
+
}
|
738
|
+
if (typeof fs.existsSync === "function" ? fs.existsSync(map) : void 0) {
|
739
|
+
return fs.readFileSync(map).toString();
|
740
|
+
} else {
|
741
|
+
return false;
|
742
|
+
}
|
743
|
+
}
|
744
|
+
});
|
745
|
+
|
746
|
+
lazy(MapGenerator, 'prevAnnotation', function() {
|
747
|
+
var last;
|
748
|
+
last = this.root.last;
|
749
|
+
if (!last) {
|
750
|
+
return null;
|
751
|
+
}
|
752
|
+
if (last.type === 'comment' && this.startWith(last.text, '# sourceMappingURL=')) {
|
753
|
+
return last;
|
754
|
+
} else {
|
755
|
+
return null;
|
756
|
+
}
|
757
|
+
});
|
758
|
+
|
759
|
+
MapGenerator.prototype.encodeInline = function(text) {
|
760
|
+
var base64, byte, bytes, uri;
|
761
|
+
uri = '# sourceMappingURL=data:application/json,';
|
762
|
+
base64 = '# sourceMappingURL=data:application/json;base64,';
|
763
|
+
if (this.startWith(text, uri)) {
|
764
|
+
return decodeURIComponent(text.slice(uri.length));
|
765
|
+
} else if (this.startWith(text, base64)) {
|
766
|
+
text = text.slice(base64.length);
|
767
|
+
bytes = base64js.toByteArray(text);
|
768
|
+
return ((function() {
|
769
|
+
var _i, _len, _results;
|
770
|
+
_results = [];
|
771
|
+
for (_i = 0, _len = bytes.length; _i < _len; _i++) {
|
772
|
+
byte = bytes[_i];
|
773
|
+
_results.push(String.fromCharCode(byte));
|
774
|
+
}
|
775
|
+
return _results;
|
776
|
+
})()).join('');
|
777
|
+
} else {
|
778
|
+
throw new Error('Unknown source map encoding');
|
779
|
+
}
|
780
|
+
};
|
781
|
+
|
782
|
+
MapGenerator.prototype.clearAnnotation = function() {
|
783
|
+
var _ref;
|
784
|
+
return (_ref = this.prevAnnotation()) != null ? _ref.removeSelf() : void 0;
|
785
|
+
};
|
786
|
+
|
787
|
+
MapGenerator.prototype.applyPrevMap = function() {
|
788
|
+
var from, prev;
|
789
|
+
if (this.prevMap()) {
|
790
|
+
prev = this.prevMap();
|
791
|
+
prev = typeof prev === 'string' ? JSON.parse(prev) : prev instanceof mozilla.SourceMapConsumer ? mozilla.SourceMapGenerator.fromSourceMap(prev).toJSON() : typeof prev === 'object' && prev.toJSON ? prev.toJSON() : prev;
|
792
|
+
prev = new mozilla.SourceMapConsumer(prev);
|
793
|
+
from = this.relative(this.opts.from);
|
794
|
+
return this.map.applySourceMap(prev, from, path.dirname(from));
|
795
|
+
}
|
796
|
+
};
|
797
|
+
|
798
|
+
MapGenerator.prototype.addAnnotation = function() {
|
799
|
+
var bytes, char, content;
|
800
|
+
if (this.opts.mapAnnotation === false) {
|
801
|
+
return;
|
802
|
+
}
|
803
|
+
if (this.prevMap() && !this.prevAnnotation()) {
|
804
|
+
return;
|
805
|
+
}
|
806
|
+
content = this.isInline() ? (bytes = (function() {
|
807
|
+
var _i, _len, _ref, _results;
|
808
|
+
_ref = this.map.toString();
|
809
|
+
_results = [];
|
810
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
811
|
+
char = _ref[_i];
|
812
|
+
_results.push(char.charCodeAt(0));
|
813
|
+
}
|
814
|
+
return _results;
|
815
|
+
}).call(this), "data:application/json;base64," + base64js.fromByteArray(bytes)) : this.outputFile() + '.map';
|
816
|
+
return this.css += "\n/*# sourceMappingURL=" + content + " */";
|
817
|
+
};
|
818
|
+
|
819
|
+
MapGenerator.prototype.outputFile = function() {
|
820
|
+
if (this.opts.to) {
|
821
|
+
return path.basename(this.opts.to);
|
822
|
+
} else {
|
823
|
+
return 'to.css';
|
824
|
+
}
|
825
|
+
};
|
826
|
+
|
827
|
+
MapGenerator.prototype.generateMap = function() {
|
828
|
+
this.stringify();
|
829
|
+
this.applyPrevMap();
|
830
|
+
this.addAnnotation();
|
831
|
+
if (this.isInline()) {
|
832
|
+
return new Result(this.css);
|
833
|
+
} else {
|
834
|
+
return new Result(this.css, this.map.toString());
|
835
|
+
}
|
836
|
+
};
|
837
|
+
|
838
|
+
MapGenerator.prototype.relative = function(file) {
|
839
|
+
var from;
|
840
|
+
from = this.opts.to ? path.dirname(this.opts.to) : '.';
|
841
|
+
file = path.relative(from, file);
|
842
|
+
if (path.sep === '\\') {
|
843
|
+
file = file.replace('\\', '/');
|
844
|
+
}
|
845
|
+
return file;
|
846
|
+
};
|
847
|
+
|
848
|
+
MapGenerator.prototype.sourcePath = function(node) {
|
849
|
+
return this.relative(node.source.file || 'from.css');
|
850
|
+
};
|
851
|
+
|
852
|
+
MapGenerator.prototype.stringify = function() {
|
853
|
+
var builder, column, line;
|
854
|
+
this.css = '';
|
855
|
+
this.map = new mozilla.SourceMapGenerator({
|
856
|
+
file: this.outputFile()
|
857
|
+
});
|
858
|
+
line = 1;
|
859
|
+
column = 1;
|
860
|
+
builder = (function(_this) {
|
861
|
+
return function(str, node, type) {
|
862
|
+
var last, lines, _ref, _ref1;
|
863
|
+
_this.css += str;
|
864
|
+
if ((node != null ? (_ref = node.source) != null ? _ref.start : void 0 : void 0) && type !== 'end') {
|
865
|
+
_this.map.addMapping({
|
866
|
+
source: _this.sourcePath(node),
|
867
|
+
original: {
|
868
|
+
line: node.source.start.line,
|
869
|
+
column: node.source.start.column - 1
|
870
|
+
},
|
871
|
+
generated: {
|
872
|
+
line: line,
|
873
|
+
column: column - 1
|
874
|
+
}
|
875
|
+
});
|
876
|
+
}
|
877
|
+
lines = str.match(/\n/g);
|
878
|
+
if (lines) {
|
879
|
+
line += lines.length;
|
880
|
+
last = str.lastIndexOf("\n");
|
881
|
+
column = str.length - last;
|
882
|
+
} else {
|
883
|
+
column = column + str.length;
|
884
|
+
}
|
885
|
+
if ((node != null ? (_ref1 = node.source) != null ? _ref1.end : void 0 : void 0) && type !== 'start') {
|
886
|
+
return _this.map.addMapping({
|
887
|
+
source: _this.sourcePath(node),
|
888
|
+
original: {
|
889
|
+
line: node.source.end.line,
|
890
|
+
column: node.source.end.column
|
891
|
+
},
|
892
|
+
generated: {
|
893
|
+
line: line,
|
894
|
+
column: column
|
895
|
+
}
|
896
|
+
});
|
897
|
+
}
|
898
|
+
};
|
899
|
+
})(this);
|
900
|
+
return this.root.stringify(builder);
|
901
|
+
};
|
902
|
+
|
903
|
+
MapGenerator.prototype.getResult = function() {
|
904
|
+
this.clearAnnotation();
|
905
|
+
if (this.isMap()) {
|
906
|
+
return this.generateMap();
|
907
|
+
} else {
|
908
|
+
return new Result(this.root.toString());
|
909
|
+
}
|
910
|
+
};
|
911
|
+
|
912
|
+
return MapGenerator;
|
913
|
+
|
914
|
+
})();
|
915
|
+
|
916
|
+
module.exports = MapGenerator;
|
917
|
+
|
918
|
+
}).call(this);
|
919
|
+
|
920
|
+
},{"./lazy":7,"./result":14,"base64-js":19,"fs":30,"path":32,"source-map":20}],10:[function(require,module,exports){
|
921
|
+
(function() {
|
922
|
+
var Node, Raw, clone, keys,
|
923
|
+
__hasProp = {}.hasOwnProperty;
|
924
|
+
|
925
|
+
Raw = require('./raw');
|
926
|
+
|
927
|
+
clone = function(obj, parent) {
|
928
|
+
var cloned, name, value;
|
929
|
+
if (typeof obj !== 'object') {
|
930
|
+
return obj;
|
931
|
+
}
|
932
|
+
cloned = new obj.constructor();
|
933
|
+
for (name in obj) {
|
934
|
+
if (!__hasProp.call(obj, name)) continue;
|
935
|
+
value = obj[name];
|
936
|
+
if (name === 'parent' && typeof value === 'object') {
|
937
|
+
if (parent) {
|
938
|
+
cloned[name] = parent;
|
939
|
+
}
|
940
|
+
} else if (value instanceof Array) {
|
941
|
+
cloned[name] = value.map(function(i) {
|
942
|
+
return clone(i, cloned);
|
943
|
+
});
|
944
|
+
} else {
|
945
|
+
cloned[name] = clone(value, cloned);
|
946
|
+
}
|
947
|
+
}
|
948
|
+
return cloned;
|
949
|
+
};
|
950
|
+
|
951
|
+
keys = function(obj, keys) {
|
952
|
+
var all, key;
|
953
|
+
all = {};
|
954
|
+
for (key in keys) {
|
955
|
+
if (obj[key] != null) {
|
956
|
+
all[key] = obj[key];
|
957
|
+
} else {
|
958
|
+
return false;
|
959
|
+
}
|
960
|
+
}
|
961
|
+
return all;
|
962
|
+
};
|
963
|
+
|
964
|
+
Node = (function() {
|
965
|
+
function Node(defaults) {
|
966
|
+
var name, value;
|
967
|
+
if (defaults == null) {
|
968
|
+
defaults = {};
|
969
|
+
}
|
970
|
+
for (name in defaults) {
|
971
|
+
value = defaults[name];
|
972
|
+
this[name] = value;
|
973
|
+
}
|
974
|
+
}
|
975
|
+
|
976
|
+
Node.prop = function(name, params) {
|
977
|
+
return Object.defineProperty(this.prototype, name, params);
|
978
|
+
};
|
979
|
+
|
980
|
+
Node.raw = function(name) {
|
981
|
+
var hidden;
|
982
|
+
hidden = '_' + name;
|
983
|
+
return this.prop(name, {
|
984
|
+
get: function() {
|
985
|
+
var prop;
|
986
|
+
prop = this[hidden];
|
987
|
+
if (prop instanceof Raw) {
|
988
|
+
return prop.value;
|
989
|
+
} else {
|
990
|
+
return prop;
|
991
|
+
}
|
992
|
+
},
|
993
|
+
set: function(value) {
|
994
|
+
if (value instanceof Raw) {
|
995
|
+
return this[hidden] = value;
|
996
|
+
} else {
|
997
|
+
return this[hidden] = value;
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
});
|
1001
|
+
};
|
1002
|
+
|
1003
|
+
Node.prototype.removeSelf = function() {
|
1004
|
+
if (!this.parent) {
|
1005
|
+
return;
|
1006
|
+
}
|
1007
|
+
this.parent.remove(this);
|
1008
|
+
return this;
|
1009
|
+
};
|
1010
|
+
|
1011
|
+
Node.prototype.toString = function() {
|
1012
|
+
var builder, result;
|
1013
|
+
result = '';
|
1014
|
+
builder = function(str) {
|
1015
|
+
return result += str;
|
1016
|
+
};
|
1017
|
+
this.stringify(builder);
|
1018
|
+
return result;
|
1019
|
+
};
|
1020
|
+
|
1021
|
+
Node.prototype.clone = function(overrides) {
|
1022
|
+
var cloned, name, value;
|
1023
|
+
if (overrides == null) {
|
1024
|
+
overrides = {};
|
1025
|
+
}
|
1026
|
+
cloned = clone(this);
|
1027
|
+
for (name in overrides) {
|
1028
|
+
value = overrides[name];
|
1029
|
+
cloned[name] = value;
|
1030
|
+
}
|
1031
|
+
return cloned;
|
1032
|
+
};
|
1033
|
+
|
1034
|
+
Node.prototype.toJSON = function() {
|
1035
|
+
var fixed, name, value;
|
1036
|
+
fixed = {};
|
1037
|
+
for (name in this) {
|
1038
|
+
if (!__hasProp.call(this, name)) continue;
|
1039
|
+
value = this[name];
|
1040
|
+
if (name === 'parent') {
|
1041
|
+
continue;
|
1042
|
+
}
|
1043
|
+
fixed[name] = value instanceof Array ? value.map(function(i) {
|
1044
|
+
if (typeof i === 'object' && i.toJSON) {
|
1045
|
+
return i.toJSON();
|
1046
|
+
} else {
|
1047
|
+
return i;
|
1048
|
+
}
|
1049
|
+
}) : typeof value === 'object' && value.toJSON ? value.toJSON() : value;
|
1050
|
+
}
|
1051
|
+
return fixed;
|
1052
|
+
};
|
1053
|
+
|
1054
|
+
Node.prototype.defaultStyle = function() {
|
1055
|
+
return {};
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
Node.prototype.styleType = function() {
|
1059
|
+
return this.type;
|
1060
|
+
};
|
1061
|
+
|
1062
|
+
Node.prototype.style = function() {
|
1063
|
+
var all, defaults, key, merge, root, style, type;
|
1064
|
+
type = this.styleType();
|
1065
|
+
defaults = this.defaultStyle(type);
|
1066
|
+
all = keys(this, defaults);
|
1067
|
+
if (all) {
|
1068
|
+
return all;
|
1069
|
+
}
|
1070
|
+
style = defaults;
|
1071
|
+
if (this.parent) {
|
1072
|
+
root = this;
|
1073
|
+
while (root.parent) {
|
1074
|
+
root = root.parent;
|
1075
|
+
}
|
1076
|
+
root.styleCache || (root.styleCache = {});
|
1077
|
+
if (root.styleCache[type]) {
|
1078
|
+
style = root.styleCache[type];
|
1079
|
+
} else {
|
1080
|
+
root.eachInside(function(another) {
|
1081
|
+
if (another.styleType() !== type) {
|
1082
|
+
return;
|
1083
|
+
}
|
1084
|
+
if (this === another) {
|
1085
|
+
return;
|
1086
|
+
}
|
1087
|
+
all = keys(another, style);
|
1088
|
+
if (all) {
|
1089
|
+
style = all;
|
1090
|
+
return false;
|
1091
|
+
}
|
1092
|
+
});
|
1093
|
+
root.styleCache[type] = style;
|
1094
|
+
}
|
1095
|
+
}
|
1096
|
+
merge = {};
|
1097
|
+
for (key in style) {
|
1098
|
+
merge[key] = this[key] != null ? this[key] : style[key];
|
1099
|
+
}
|
1100
|
+
return merge;
|
1101
|
+
};
|
1102
|
+
|
1103
|
+
return Node;
|
1104
|
+
|
1105
|
+
})();
|
1106
|
+
|
1107
|
+
module.exports = Node;
|
1108
|
+
|
1109
|
+
}).call(this);
|
1110
|
+
|
1111
|
+
},{"./raw":13}],11:[function(require,module,exports){
|
1112
|
+
(function() {
|
1113
|
+
var AtRule, Comment, Declaration, Parser, Raw, Root, Rule, SyntexError;
|
1114
|
+
|
1115
|
+
SyntexError = require('./syntax-error');
|
1116
|
+
|
1117
|
+
Declaration = require('./declaration');
|
1118
|
+
|
1119
|
+
Comment = require('./comment');
|
1120
|
+
|
1121
|
+
AtRule = require('./at-rule');
|
1122
|
+
|
1123
|
+
Root = require('./root');
|
1124
|
+
|
1125
|
+
Rule = require('./rule');
|
1126
|
+
|
1127
|
+
Raw = require('./raw');
|
1128
|
+
|
1129
|
+
Parser = (function() {
|
1130
|
+
function Parser(source, opts) {
|
1131
|
+
this.opts = opts;
|
1132
|
+
this.source = source.toString();
|
1133
|
+
this.root = new Root();
|
1134
|
+
this.current = this.root;
|
1135
|
+
this.parents = [this.current];
|
1136
|
+
this.type = 'rules';
|
1137
|
+
this.types = [this.type];
|
1138
|
+
this.pos = -1;
|
1139
|
+
this.line = 1;
|
1140
|
+
this.lines = [];
|
1141
|
+
this.column = 0;
|
1142
|
+
this.buffer = '';
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
Parser.prototype.loop = function() {
|
1146
|
+
while (this.pos < this.source.length - 1) {
|
1147
|
+
this.move();
|
1148
|
+
this.nextLetter();
|
1149
|
+
}
|
1150
|
+
return this.endFile();
|
1151
|
+
};
|
1152
|
+
|
1153
|
+
Parser.prototype.nextLetter = function() {
|
1154
|
+
this.inString() || this.inComment() || this.isComment() || this.isString() || this.isWrong() || this.inAtrule() || this.isAtrule() || this.isBlockEnd() || this.inSelector() || this.isSelector() || this.inProperty() || this.isProperty() || this.inValue();
|
1155
|
+
return this.unknown();
|
1156
|
+
};
|
1157
|
+
|
1158
|
+
Parser.prototype.inString = function() {
|
1159
|
+
if (this.quote) {
|
1160
|
+
if (this.escape) {
|
1161
|
+
this.escape = false;
|
1162
|
+
} else if (this.letter === '\\') {
|
1163
|
+
this.escape = true;
|
1164
|
+
} else if (this.letter === this.quote) {
|
1165
|
+
this.quote = void 0;
|
1166
|
+
}
|
1167
|
+
this.trimmed += this.letter;
|
1168
|
+
return true;
|
1169
|
+
}
|
1170
|
+
};
|
1171
|
+
|
1172
|
+
Parser.prototype.isString = function() {
|
1173
|
+
if (this.letter === '"' || this.letter === "'") {
|
1174
|
+
this.quote = this.letter;
|
1175
|
+
this.quotePos = {
|
1176
|
+
line: this.line,
|
1177
|
+
column: this.column
|
1178
|
+
};
|
1179
|
+
this.trimmed += this.letter;
|
1180
|
+
return true;
|
1181
|
+
}
|
1182
|
+
};
|
1183
|
+
|
1184
|
+
Parser.prototype.inComment = function() {
|
1185
|
+
var left, right, text, _ref, _ref1;
|
1186
|
+
if (this.inside('comment')) {
|
1187
|
+
if (this.next('*/')) {
|
1188
|
+
_ref = this.startSpaces(this.prevBuffer()), text = _ref[0], left = _ref[1];
|
1189
|
+
_ref1 = this.endSpaces(text), text = _ref1[0], right = _ref1[1];
|
1190
|
+
this.current.text = text;
|
1191
|
+
this.current.left = left;
|
1192
|
+
this.current.right = right;
|
1193
|
+
this.move();
|
1194
|
+
this.pop();
|
1195
|
+
}
|
1196
|
+
return true;
|
1197
|
+
} else if (this.inside('value-comment')) {
|
1198
|
+
if (this.next('*/')) {
|
1199
|
+
this.popType();
|
1200
|
+
this.move();
|
1201
|
+
}
|
1202
|
+
return true;
|
1203
|
+
}
|
1204
|
+
};
|
1205
|
+
|
1206
|
+
Parser.prototype.isComment = function() {
|
1207
|
+
if (this.next('/*')) {
|
1208
|
+
if (this.inside('rules') || this.inside('decls')) {
|
1209
|
+
this.init(new Comment());
|
1210
|
+
this.addType('comment');
|
1211
|
+
this.move();
|
1212
|
+
return this.buffer = '';
|
1213
|
+
} else {
|
1214
|
+
this.commentPos = {
|
1215
|
+
line: this.line,
|
1216
|
+
column: this.column
|
1217
|
+
};
|
1218
|
+
this.addType('value-comment');
|
1219
|
+
this.move();
|
1220
|
+
return true;
|
1221
|
+
}
|
1222
|
+
}
|
1223
|
+
};
|
1224
|
+
|
1225
|
+
Parser.prototype.isWrong = function() {
|
1226
|
+
if (this.letter === '{' && (this.inside('decls') || this.inside('value'))) {
|
1227
|
+
this.error("Unexpected {");
|
1228
|
+
}
|
1229
|
+
if (this.inside('prop') && (this.letter === '}' || this.letter === ';')) {
|
1230
|
+
return this.error('Missing property value');
|
1231
|
+
}
|
1232
|
+
};
|
1233
|
+
|
1234
|
+
Parser.prototype.isAtrule = function() {
|
1235
|
+
if (this.letter === '@' && this.inside('rules')) {
|
1236
|
+
this.init(new AtRule());
|
1237
|
+
this.current.name = '';
|
1238
|
+
this.addType('atrule-name');
|
1239
|
+
return true;
|
1240
|
+
}
|
1241
|
+
};
|
1242
|
+
|
1243
|
+
Parser.prototype.inAtrule = function(close) {
|
1244
|
+
var left, raw, right, _ref, _ref1;
|
1245
|
+
if (this.inside('atrule-name')) {
|
1246
|
+
if (this.space()) {
|
1247
|
+
this.checkAtruleName();
|
1248
|
+
this.buffer = this.buffer.slice(this.current.name.length);
|
1249
|
+
this.trimmed = '';
|
1250
|
+
this.setType('atrule-param');
|
1251
|
+
} else if (this.letter === ';' || this.letter === '{' || close) {
|
1252
|
+
this.current.between = '';
|
1253
|
+
this.checkAtruleName();
|
1254
|
+
this.endAtruleParams();
|
1255
|
+
} else {
|
1256
|
+
this.current.name += this.letter;
|
1257
|
+
}
|
1258
|
+
return true;
|
1259
|
+
} else if (this.inside('atrule-param')) {
|
1260
|
+
if (this.letter === ';' || this.letter === '{' || close) {
|
1261
|
+
_ref = this.startSpaces(this.prevBuffer()), raw = _ref[0], left = _ref[1];
|
1262
|
+
_ref1 = this.endSpaces(raw), raw = _ref1[0], right = _ref1[1];
|
1263
|
+
this.current.params = this.raw(this.trimmed.trim(), raw);
|
1264
|
+
if (this.current.params) {
|
1265
|
+
this.current.afterName = left;
|
1266
|
+
this.current.between = right;
|
1267
|
+
} else {
|
1268
|
+
this.current.afterName = '';
|
1269
|
+
this.current.between = left + right;
|
1270
|
+
}
|
1271
|
+
this.endAtruleParams();
|
1272
|
+
} else {
|
1273
|
+
this.trimmed += this.letter;
|
1274
|
+
}
|
1275
|
+
return true;
|
1276
|
+
}
|
1277
|
+
};
|
1278
|
+
|
1279
|
+
Parser.prototype.inSelector = function() {
|
1280
|
+
var raw, spaces, _ref;
|
1281
|
+
if (this.inside('selector')) {
|
1282
|
+
if (this.letter === '{') {
|
1283
|
+
_ref = this.endSpaces(this.prevBuffer()), raw = _ref[0], spaces = _ref[1];
|
1284
|
+
this.current.selector = this.raw(this.trimmed.trim(), raw);
|
1285
|
+
this.current.between = spaces;
|
1286
|
+
this.semicolon = false;
|
1287
|
+
this.buffer = '';
|
1288
|
+
this.setType('decls');
|
1289
|
+
} else {
|
1290
|
+
this.trimmed += this.letter;
|
1291
|
+
}
|
1292
|
+
return true;
|
1293
|
+
}
|
1294
|
+
};
|
1295
|
+
|
1296
|
+
Parser.prototype.isSelector = function() {
|
1297
|
+
if (!this.space() && this.inside('rules')) {
|
1298
|
+
this.init(new Rule());
|
1299
|
+
if (this.letter === '{') {
|
1300
|
+
this.addType('decls');
|
1301
|
+
this.current.selector = '';
|
1302
|
+
this.current.between = '';
|
1303
|
+
this.semicolon = false;
|
1304
|
+
this.buffer = '';
|
1305
|
+
} else {
|
1306
|
+
this.addType('selector');
|
1307
|
+
this.buffer = this.letter;
|
1308
|
+
this.trimmed = this.letter;
|
1309
|
+
}
|
1310
|
+
return true;
|
1311
|
+
}
|
1312
|
+
};
|
1313
|
+
|
1314
|
+
Parser.prototype.isBlockEnd = function() {
|
1315
|
+
if (this.letter === '}') {
|
1316
|
+
if (this.parents.length === 1) {
|
1317
|
+
this.error('Unexpected }');
|
1318
|
+
} else {
|
1319
|
+
if (this.inside('value')) {
|
1320
|
+
this.fixEnd(function() {
|
1321
|
+
return this.inValue('close');
|
1322
|
+
});
|
1323
|
+
} else {
|
1324
|
+
if (this.semicolon) {
|
1325
|
+
this.current.semicolon = true;
|
1326
|
+
}
|
1327
|
+
this.current.after = this.prevBuffer();
|
1328
|
+
}
|
1329
|
+
this.pop();
|
1330
|
+
}
|
1331
|
+
return true;
|
1332
|
+
}
|
1333
|
+
};
|
1334
|
+
|
1335
|
+
Parser.prototype.inProperty = function() {
|
1336
|
+
if (this.inside('prop')) {
|
1337
|
+
if (this.letter === ':') {
|
1338
|
+
if (this.buffer[0] === '*' || this.buffer[0] === '_') {
|
1339
|
+
this.current.before += this.buffer[0];
|
1340
|
+
this.trimmed = this.trimmed.slice(1);
|
1341
|
+
this.buffer = this.buffer.slice(1);
|
1342
|
+
}
|
1343
|
+
this.current.prop = this.trimmed.trim();
|
1344
|
+
this.current.between = this.prevBuffer().slice(this.current.prop.length);
|
1345
|
+
this.buffer = '';
|
1346
|
+
this.setType('value');
|
1347
|
+
this.trimmed = '';
|
1348
|
+
} else if (this.letter === '{') {
|
1349
|
+
this.error('Unexpected { in decls');
|
1350
|
+
} else {
|
1351
|
+
this.trimmed += this.letter;
|
1352
|
+
}
|
1353
|
+
return true;
|
1354
|
+
}
|
1355
|
+
};
|
1356
|
+
|
1357
|
+
Parser.prototype.isProperty = function() {
|
1358
|
+
if (this.inside('decls') && !this.space() && this.letter !== ';') {
|
1359
|
+
this.init(new Declaration());
|
1360
|
+
this.addType('prop');
|
1361
|
+
this.buffer = this.letter;
|
1362
|
+
this.trimmed = this.letter;
|
1363
|
+
this.semicolon = false;
|
1364
|
+
return true;
|
1365
|
+
}
|
1366
|
+
};
|
1367
|
+
|
1368
|
+
Parser.prototype.inValue = function(close) {
|
1369
|
+
var end, match, raw, spaces, trim, _ref;
|
1370
|
+
if (this.inside('value')) {
|
1371
|
+
if (this.letter === '(') {
|
1372
|
+
this.inBrackets = true;
|
1373
|
+
} else if (this.inBrackets && this.letter === ')') {
|
1374
|
+
this.inBrackets = false;
|
1375
|
+
}
|
1376
|
+
if ((this.letter === ';' && !this.inBrackets) || close) {
|
1377
|
+
if (this.letter === ';') {
|
1378
|
+
this.semicolon = true;
|
1379
|
+
}
|
1380
|
+
_ref = this.startSpaces(this.prevBuffer()), raw = _ref[0], spaces = _ref[1];
|
1381
|
+
trim = this.trimmed.trim();
|
1382
|
+
if (match = raw.match(/\s+!important\s*$/)) {
|
1383
|
+
this.current._important = match[0];
|
1384
|
+
end = -match[0].length - 1;
|
1385
|
+
raw = raw.slice(0, +end + 1 || 9e9);
|
1386
|
+
trim = trim.replace(/\s+!important$/, '');
|
1387
|
+
}
|
1388
|
+
this.current.value = this.raw(trim, raw);
|
1389
|
+
this.current.between += ':' + spaces;
|
1390
|
+
this.pop();
|
1391
|
+
} else {
|
1392
|
+
this.trimmed += this.letter;
|
1393
|
+
}
|
1394
|
+
return true;
|
1395
|
+
}
|
1396
|
+
};
|
1397
|
+
|
1398
|
+
Parser.prototype.unknown = function() {
|
1399
|
+
if (!this.space) {
|
1400
|
+
return this.error("Unexpected symbol " + this.letter);
|
1401
|
+
}
|
1402
|
+
};
|
1403
|
+
|
1404
|
+
Parser.prototype.endFile = function() {
|
1405
|
+
if (this.inside('atrule-param') || this.inside('atrule-name')) {
|
1406
|
+
this.fixEnd(function() {
|
1407
|
+
return this.inAtrule('close');
|
1408
|
+
});
|
1409
|
+
}
|
1410
|
+
if (this.inside('comment')) {
|
1411
|
+
return this.error('Unclosed comment', this.current.source.start);
|
1412
|
+
} else if (this.parents.length > 1) {
|
1413
|
+
return this.error('Unclosed block', this.current.source.start);
|
1414
|
+
} else if (this.inside('value-comment')) {
|
1415
|
+
return this.error('Unclosed comment', this.commentPos);
|
1416
|
+
} else if (this.quote) {
|
1417
|
+
return this.error('Unclosed quote', this.quotePos);
|
1418
|
+
} else {
|
1419
|
+
return this.root.after = this.buffer;
|
1420
|
+
}
|
1421
|
+
};
|
1422
|
+
|
1423
|
+
Parser.prototype.error = function(message, position) {
|
1424
|
+
if (position == null) {
|
1425
|
+
position = {
|
1426
|
+
line: this.line,
|
1427
|
+
column: this.column
|
1428
|
+
};
|
1429
|
+
}
|
1430
|
+
throw new SyntexError(message, this.source, position, this.opts.from);
|
1431
|
+
};
|
1432
|
+
|
1433
|
+
Parser.prototype.move = function() {
|
1434
|
+
this.pos += 1;
|
1435
|
+
this.column += 1;
|
1436
|
+
this.letter = this.source[this.pos];
|
1437
|
+
this.buffer += this.letter;
|
1438
|
+
if (this.letter === "\n") {
|
1439
|
+
this.lines[this.line] = this.column - 1;
|
1440
|
+
this.line += 1;
|
1441
|
+
return this.column = 0;
|
1442
|
+
}
|
1443
|
+
};
|
1444
|
+
|
1445
|
+
Parser.prototype.prevBuffer = function() {
|
1446
|
+
return this.buffer.slice(0, -1);
|
1447
|
+
};
|
1448
|
+
|
1449
|
+
Parser.prototype.inside = function(type) {
|
1450
|
+
return this.type === type;
|
1451
|
+
};
|
1452
|
+
|
1453
|
+
Parser.prototype.next = function(string) {
|
1454
|
+
return this.source.slice(this.pos, +(this.pos + string.length - 1) + 1 || 9e9) === string;
|
1455
|
+
};
|
1456
|
+
|
1457
|
+
Parser.prototype.space = function() {
|
1458
|
+
return this.letter.match(/\s/);
|
1459
|
+
};
|
1460
|
+
|
1461
|
+
Parser.prototype.init = function(node) {
|
1462
|
+
this.current.push(node);
|
1463
|
+
this.parents.push(node);
|
1464
|
+
this.current = node;
|
1465
|
+
this.current.source = {
|
1466
|
+
start: {
|
1467
|
+
line: this.line,
|
1468
|
+
column: this.column
|
1469
|
+
}
|
1470
|
+
};
|
1471
|
+
if (this.opts.from) {
|
1472
|
+
this.current.source.file = this.opts.from;
|
1473
|
+
}
|
1474
|
+
this.current.before = this.buffer.slice(0, -1);
|
1475
|
+
return this.buffer = '';
|
1476
|
+
};
|
1477
|
+
|
1478
|
+
Parser.prototype.raw = function(value, raw) {
|
1479
|
+
if (value !== raw) {
|
1480
|
+
return new Raw(value, raw);
|
1481
|
+
} else {
|
1482
|
+
return value;
|
1483
|
+
}
|
1484
|
+
};
|
1485
|
+
|
1486
|
+
Parser.prototype.fixEnd = function(callback) {
|
1487
|
+
var after, all, el, last, lines, start;
|
1488
|
+
if (this.letter === '}') {
|
1489
|
+
start = this.buffer.search(/\s*\}$/);
|
1490
|
+
after = this.buffer.slice(start, -1);
|
1491
|
+
} else {
|
1492
|
+
start = this.buffer.search(/\s*$/);
|
1493
|
+
after = this.buffer.slice(start);
|
1494
|
+
}
|
1495
|
+
this.buffer = this.buffer.slice(0, +start + 1 || 9e9);
|
1496
|
+
el = this.current;
|
1497
|
+
callback.apply(this);
|
1498
|
+
lines = after.match(/\n/g);
|
1499
|
+
if (lines) {
|
1500
|
+
el.source.end.line -= lines.length;
|
1501
|
+
all = this.lines[el.source.end.line];
|
1502
|
+
last = after.indexOf("\n");
|
1503
|
+
if (last === -1) {
|
1504
|
+
last = after.length;
|
1505
|
+
}
|
1506
|
+
el.source.end.column = all - last;
|
1507
|
+
} else {
|
1508
|
+
el.source.end.column -= after.length;
|
1509
|
+
}
|
1510
|
+
this.current.after = after;
|
1511
|
+
return this.buffer = after;
|
1512
|
+
};
|
1513
|
+
|
1514
|
+
Parser.prototype.pop = function() {
|
1515
|
+
this.current.source.end = {
|
1516
|
+
line: this.line,
|
1517
|
+
column: this.column
|
1518
|
+
};
|
1519
|
+
this.popType();
|
1520
|
+
this.parents.pop();
|
1521
|
+
this.current = this.parents[this.parents.length - 1];
|
1522
|
+
return this.buffer = '';
|
1523
|
+
};
|
1524
|
+
|
1525
|
+
Parser.prototype.addType = function(type) {
|
1526
|
+
this.types.push(type);
|
1527
|
+
return this.type = type;
|
1528
|
+
};
|
1529
|
+
|
1530
|
+
Parser.prototype.setType = function(type) {
|
1531
|
+
this.types[this.types.length - 1] = type;
|
1532
|
+
return this.type = type;
|
1533
|
+
};
|
1534
|
+
|
1535
|
+
Parser.prototype.popType = function() {
|
1536
|
+
this.types.pop();
|
1537
|
+
return this.type = this.types[this.types.length - 1];
|
1538
|
+
};
|
1539
|
+
|
1540
|
+
Parser.prototype.atruleType = function() {
|
1541
|
+
var name;
|
1542
|
+
name = this.current.name.toLowerCase();
|
1543
|
+
if (name === 'page' || name === 'font-face' || name.slice(-8) === 'viewport') {
|
1544
|
+
return 'decls';
|
1545
|
+
} else {
|
1546
|
+
return 'rules';
|
1547
|
+
}
|
1548
|
+
};
|
1549
|
+
|
1550
|
+
Parser.prototype.endAtruleParams = function() {
|
1551
|
+
var type;
|
1552
|
+
if (this.letter === '{') {
|
1553
|
+
type = this.atruleType();
|
1554
|
+
this.current.addMixin(type);
|
1555
|
+
this.setType(type);
|
1556
|
+
return this.buffer = '';
|
1557
|
+
} else {
|
1558
|
+
if (this.letter === ';') {
|
1559
|
+
this.current.semicolon = true;
|
1560
|
+
}
|
1561
|
+
return this.pop();
|
1562
|
+
}
|
1563
|
+
};
|
1564
|
+
|
1565
|
+
Parser.prototype.checkAtruleName = function() {
|
1566
|
+
if (this.current.name === '') {
|
1567
|
+
return this.error('At-rule without name');
|
1568
|
+
}
|
1569
|
+
};
|
1570
|
+
|
1571
|
+
Parser.prototype.startSpaces = function(string) {
|
1572
|
+
var match, pos;
|
1573
|
+
match = string.match(/^\s*/);
|
1574
|
+
if (match) {
|
1575
|
+
pos = match[0].length;
|
1576
|
+
return [string.slice(pos), match[0]];
|
1577
|
+
} else {
|
1578
|
+
return [string, ''];
|
1579
|
+
}
|
1580
|
+
};
|
1581
|
+
|
1582
|
+
Parser.prototype.endSpaces = function(string) {
|
1583
|
+
var match, pos;
|
1584
|
+
match = string.match(/\s*$/);
|
1585
|
+
if (match) {
|
1586
|
+
pos = match[0].length + 1;
|
1587
|
+
return [string.slice(0, +(-pos) + 1 || 9e9), match[0]];
|
1588
|
+
} else {
|
1589
|
+
return [string, ''];
|
1590
|
+
}
|
1591
|
+
};
|
1592
|
+
|
1593
|
+
return Parser;
|
1594
|
+
|
1595
|
+
})();
|
1596
|
+
|
1597
|
+
module.exports = function(source, opts) {
|
1598
|
+
var parser;
|
1599
|
+
if (opts == null) {
|
1600
|
+
opts = {};
|
1601
|
+
}
|
1602
|
+
parser = new Parser(source, opts);
|
1603
|
+
parser.loop();
|
1604
|
+
return parser.root;
|
1605
|
+
};
|
1606
|
+
|
1607
|
+
}).call(this);
|
1608
|
+
|
1609
|
+
},{"./at-rule":3,"./comment":4,"./declaration":6,"./raw":13,"./root":15,"./rule":16,"./syntax-error":17}],12:[function(require,module,exports){
|
1610
|
+
(function() {
|
1611
|
+
var AtRule, Comment, Declaration, PostCSS, Root, Rule, postcss,
|
1612
|
+
__slice = [].slice;
|
1613
|
+
|
1614
|
+
Declaration = require('./declaration');
|
1615
|
+
|
1616
|
+
Comment = require('./comment');
|
1617
|
+
|
1618
|
+
AtRule = require('./at-rule');
|
1619
|
+
|
1620
|
+
Rule = require('./rule');
|
1621
|
+
|
1622
|
+
Root = require('./root');
|
1623
|
+
|
1624
|
+
PostCSS = (function() {
|
1625
|
+
function PostCSS(processors) {
|
1626
|
+
this.processors = processors != null ? processors : [];
|
1627
|
+
}
|
1628
|
+
|
1629
|
+
PostCSS.prototype.use = function(processor) {
|
1630
|
+
this.processors.push(processor);
|
1631
|
+
return this;
|
1632
|
+
};
|
1633
|
+
|
1634
|
+
PostCSS.prototype.process = function(css, opts) {
|
1635
|
+
var parsed, processor, returned, _i, _len, _ref;
|
1636
|
+
if (opts == null) {
|
1637
|
+
opts = {};
|
1638
|
+
}
|
1639
|
+
parsed = postcss.parse(css, opts);
|
1640
|
+
_ref = this.processors;
|
1641
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1642
|
+
processor = _ref[_i];
|
1643
|
+
returned = processor(parsed);
|
1644
|
+
if (returned instanceof Root) {
|
1645
|
+
parsed = returned;
|
1646
|
+
}
|
1647
|
+
}
|
1648
|
+
return parsed.toResult(opts);
|
1649
|
+
};
|
1650
|
+
|
1651
|
+
return PostCSS;
|
1652
|
+
|
1653
|
+
})();
|
1654
|
+
|
1655
|
+
postcss = function() {
|
1656
|
+
var processors;
|
1657
|
+
processors = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1658
|
+
return new PostCSS(processors);
|
1659
|
+
};
|
1660
|
+
|
1661
|
+
postcss.parse = require('./parse');
|
1662
|
+
|
1663
|
+
postcss.comment = function(defaults) {
|
1664
|
+
return new Comment(defaults);
|
1665
|
+
};
|
1666
|
+
|
1667
|
+
postcss.atRule = function(defaults) {
|
1668
|
+
return new AtRule(defaults);
|
1669
|
+
};
|
1670
|
+
|
1671
|
+
postcss.decl = function(defaults) {
|
1672
|
+
return new Declaration(defaults);
|
1673
|
+
};
|
1674
|
+
|
1675
|
+
postcss.rule = function(defaults) {
|
1676
|
+
return new Rule(defaults);
|
1677
|
+
};
|
1678
|
+
|
1679
|
+
postcss.root = function(defaults) {
|
1680
|
+
return new Root(defaults);
|
1681
|
+
};
|
1682
|
+
|
1683
|
+
module.exports = postcss;
|
1684
|
+
|
1685
|
+
}).call(this);
|
1686
|
+
|
1687
|
+
},{"./at-rule":3,"./comment":4,"./declaration":6,"./parse":11,"./root":15,"./rule":16}],13:[function(require,module,exports){
|
1688
|
+
(function() {
|
1689
|
+
var Raw;
|
1690
|
+
|
1691
|
+
Raw = (function() {
|
1692
|
+
Raw.load = function(value, raw) {
|
1693
|
+
if ((raw != null) && value !== raw) {
|
1694
|
+
return new Raw(value, raw);
|
1695
|
+
} else {
|
1696
|
+
return value;
|
1697
|
+
}
|
1698
|
+
};
|
1699
|
+
|
1700
|
+
function Raw(value, raw) {
|
1701
|
+
this.value = value;
|
1702
|
+
this.raw = raw;
|
1703
|
+
}
|
1704
|
+
|
1705
|
+
Raw.prototype.toString = function() {
|
1706
|
+
if (this.changed) {
|
1707
|
+
return this.value || '';
|
1708
|
+
} else {
|
1709
|
+
return this.raw || this.value || '';
|
1710
|
+
}
|
1711
|
+
};
|
1712
|
+
|
1713
|
+
return Raw;
|
1714
|
+
|
1715
|
+
})();
|
1716
|
+
|
1717
|
+
module.exports = Raw;
|
1718
|
+
|
1719
|
+
}).call(this);
|
1720
|
+
|
1721
|
+
},{}],14:[function(require,module,exports){
|
1722
|
+
(function() {
|
1723
|
+
var Result;
|
1724
|
+
|
1725
|
+
Result = (function() {
|
1726
|
+
function Result(css, map) {
|
1727
|
+
this.css = css;
|
1728
|
+
if (map) {
|
1729
|
+
this.map = map;
|
1730
|
+
}
|
1731
|
+
}
|
1732
|
+
|
1733
|
+
Result.prototype.toString = function() {
|
1734
|
+
return this.css;
|
1735
|
+
};
|
1736
|
+
|
1737
|
+
return Result;
|
1738
|
+
|
1739
|
+
})();
|
1740
|
+
|
1741
|
+
module.exports = Result;
|
1742
|
+
|
1743
|
+
}).call(this);
|
1744
|
+
|
1745
|
+
},{}],15:[function(require,module,exports){
|
1746
|
+
(function() {
|
1747
|
+
var AtRule, Comment, Container, Declaration, MapGenerator, Root, Rule,
|
1748
|
+
__hasProp = {}.hasOwnProperty,
|
1749
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1750
|
+
|
1751
|
+
MapGenerator = require('./map-generator');
|
1752
|
+
|
1753
|
+
Declaration = require('./declaration');
|
1754
|
+
|
1755
|
+
Container = require('./container');
|
1756
|
+
|
1757
|
+
Comment = require('./comment');
|
1758
|
+
|
1759
|
+
AtRule = require('./at-rule');
|
1760
|
+
|
1761
|
+
Rule = require('./rule');
|
1762
|
+
|
1763
|
+
Root = (function(_super) {
|
1764
|
+
__extends(Root, _super);
|
1765
|
+
|
1766
|
+
function Root() {
|
1767
|
+
this.type = 'root';
|
1768
|
+
this.rules = [];
|
1769
|
+
Root.__super__.constructor.apply(this, arguments);
|
1770
|
+
}
|
1771
|
+
|
1772
|
+
Root.prototype.normalize = function(child, sample, type) {
|
1773
|
+
child = Root.__super__.normalize.apply(this, arguments);
|
1774
|
+
if (type === 'prepend') {
|
1775
|
+
sample.before = this.rules.length > 1 ? this.rules[1].before : this.after;
|
1776
|
+
}
|
1777
|
+
return child;
|
1778
|
+
};
|
1779
|
+
|
1780
|
+
Root.prototype.stringify = function(builder) {
|
1781
|
+
this.stringifyContent(builder);
|
1782
|
+
if (this.after) {
|
1783
|
+
return builder(this.after);
|
1784
|
+
}
|
1785
|
+
};
|
1786
|
+
|
1787
|
+
Root.prototype.toResult = function(opts) {
|
1788
|
+
var map;
|
1789
|
+
if (opts == null) {
|
1790
|
+
opts = {};
|
1791
|
+
}
|
1792
|
+
map = new MapGenerator(this, opts);
|
1793
|
+
return map.getResult();
|
1794
|
+
};
|
1795
|
+
|
1796
|
+
return Root;
|
1797
|
+
|
1798
|
+
})(Container.WithRules);
|
1799
|
+
|
1800
|
+
module.exports = Root;
|
1801
|
+
|
1802
|
+
}).call(this);
|
1803
|
+
|
1804
|
+
},{"./at-rule":3,"./comment":4,"./container":5,"./declaration":6,"./map-generator":9,"./rule":16}],16:[function(require,module,exports){
|
1805
|
+
(function() {
|
1806
|
+
var Container, Declaration, Rule, list,
|
1807
|
+
__hasProp = {}.hasOwnProperty,
|
1808
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1809
|
+
|
1810
|
+
Container = require('./container');
|
1811
|
+
|
1812
|
+
Declaration = require('./declaration');
|
1813
|
+
|
1814
|
+
list = require('./list');
|
1815
|
+
|
1816
|
+
Rule = (function(_super) {
|
1817
|
+
__extends(Rule, _super);
|
1818
|
+
|
1819
|
+
function Rule() {
|
1820
|
+
this.type = 'rule';
|
1821
|
+
Rule.__super__.constructor.apply(this, arguments);
|
1822
|
+
}
|
1823
|
+
|
1824
|
+
Rule.prototype.styleType = function() {
|
1825
|
+
return this.type + (this.decls.length ? '-body' : '-empty');
|
1826
|
+
};
|
1827
|
+
|
1828
|
+
Rule.prototype.defaultStyle = function(type) {
|
1829
|
+
if (type === 'rule-body') {
|
1830
|
+
return {
|
1831
|
+
between: ' ',
|
1832
|
+
after: this.defaultAfter()
|
1833
|
+
};
|
1834
|
+
} else {
|
1835
|
+
return {
|
1836
|
+
between: ' ',
|
1837
|
+
after: ''
|
1838
|
+
};
|
1839
|
+
}
|
1840
|
+
};
|
1841
|
+
|
1842
|
+
Rule.raw('selector');
|
1843
|
+
|
1844
|
+
Rule.prop('selectors', {
|
1845
|
+
get: function() {
|
1846
|
+
return list.comma(this.selector);
|
1847
|
+
},
|
1848
|
+
set: function(values) {
|
1849
|
+
return this.selector = values.join(', ');
|
1850
|
+
}
|
1851
|
+
});
|
1852
|
+
|
1853
|
+
Rule.prototype.stringify = function(builder) {
|
1854
|
+
return this.stringifyBlock(builder, this._selector + this.style().between + '{');
|
1855
|
+
};
|
1856
|
+
|
1857
|
+
return Rule;
|
1858
|
+
|
1859
|
+
})(Container.WithDecls);
|
1860
|
+
|
1861
|
+
module.exports = Rule;
|
1862
|
+
|
1863
|
+
}).call(this);
|
1864
|
+
|
1865
|
+
},{"./container":5,"./declaration":6,"./list":8}],17:[function(require,module,exports){
|
1866
|
+
(function() {
|
1867
|
+
var SyntaxError,
|
1868
|
+
__hasProp = {}.hasOwnProperty,
|
1869
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1870
|
+
|
1871
|
+
SyntaxError = (function(_super) {
|
1872
|
+
__extends(SyntaxError, _super);
|
1873
|
+
|
1874
|
+
function SyntaxError(text, source, pos, file) {
|
1875
|
+
this.source = source;
|
1876
|
+
this.file = file;
|
1877
|
+
this.line = pos.line;
|
1878
|
+
this.column = pos.column;
|
1879
|
+
this.message = "Can't parse CSS: " + text;
|
1880
|
+
this.message += " at line " + pos.line + ":" + pos.column;
|
1881
|
+
if (this.file) {
|
1882
|
+
this.message += " in " + this.file;
|
1883
|
+
}
|
1884
|
+
}
|
1885
|
+
|
1886
|
+
return SyntaxError;
|
1887
|
+
|
1888
|
+
})(Error);
|
1889
|
+
|
1890
|
+
module.exports = SyntaxError;
|
1891
|
+
|
1892
|
+
}).call(this);
|
1893
|
+
|
1894
|
+
},{}],18:[function(require,module,exports){
|
1895
|
+
(function() {
|
1896
|
+
var vendor;
|
1897
|
+
|
1898
|
+
vendor = {
|
1899
|
+
prefix: function(prop) {
|
1900
|
+
var separator;
|
1901
|
+
if (prop[0] === '-') {
|
1902
|
+
separator = prop.indexOf('-', 1) + 1;
|
1903
|
+
return prop.slice(0, separator);
|
1904
|
+
} else {
|
1905
|
+
return '';
|
1906
|
+
}
|
1907
|
+
},
|
1908
|
+
unprefixed: function(prop) {
|
1909
|
+
var separator;
|
1910
|
+
if (prop[0] === '-') {
|
1911
|
+
separator = prop.indexOf('-', 1) + 1;
|
1912
|
+
return prop.slice(separator);
|
1913
|
+
} else {
|
1914
|
+
return prop;
|
1915
|
+
}
|
1916
|
+
}
|
1917
|
+
};
|
1918
|
+
|
1919
|
+
module.exports = vendor;
|
1920
|
+
|
1921
|
+
}).call(this);
|
1922
|
+
|
1923
|
+
},{}],19:[function(require,module,exports){
|
1924
|
+
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
1925
|
+
|
1926
|
+
;(function (exports) {
|
1927
|
+
'use strict';
|
1928
|
+
|
1929
|
+
var Arr = (typeof Uint8Array !== 'undefined')
|
1930
|
+
? Uint8Array
|
1931
|
+
: Array
|
1932
|
+
|
1933
|
+
var ZERO = '0'.charCodeAt(0)
|
1934
|
+
var PLUS = '+'.charCodeAt(0)
|
1935
|
+
var SLASH = '/'.charCodeAt(0)
|
1936
|
+
var NUMBER = '0'.charCodeAt(0)
|
1937
|
+
var LOWER = 'a'.charCodeAt(0)
|
1938
|
+
var UPPER = 'A'.charCodeAt(0)
|
1939
|
+
|
1940
|
+
function decode (elt) {
|
1941
|
+
var code = elt.charCodeAt(0)
|
1942
|
+
if (code === PLUS)
|
1943
|
+
return 62 // '+'
|
1944
|
+
if (code === SLASH)
|
1945
|
+
return 63 // '/'
|
1946
|
+
if (code < NUMBER)
|
1947
|
+
return -1 //no match
|
1948
|
+
if (code < NUMBER + 10)
|
1949
|
+
return code - NUMBER + 26 + 26
|
1950
|
+
if (code < UPPER + 26)
|
1951
|
+
return code - UPPER
|
1952
|
+
if (code < LOWER + 26)
|
1953
|
+
return code - LOWER + 26
|
1954
|
+
}
|
1955
|
+
|
1956
|
+
function b64ToByteArray (b64) {
|
1957
|
+
var i, j, l, tmp, placeHolders, arr
|
1958
|
+
|
1959
|
+
if (b64.length % 4 > 0) {
|
1960
|
+
throw new Error('Invalid string. Length must be a multiple of 4')
|
1961
|
+
}
|
1962
|
+
|
1963
|
+
// the number of equal signs (place holders)
|
1964
|
+
// if there are two placeholders, than the two characters before it
|
1965
|
+
// represent one byte
|
1966
|
+
// if there is only one, then the three characters before it represent 2 bytes
|
1967
|
+
// this is just a cheap hack to not do indexOf twice
|
1968
|
+
var len = b64.length
|
1969
|
+
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
1970
|
+
|
1971
|
+
// base64 is 4/3 + up to two characters of the original data
|
1972
|
+
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
1973
|
+
|
1974
|
+
// if there are placeholders, only get up to the last complete 4 chars
|
1975
|
+
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
1976
|
+
|
1977
|
+
var L = 0
|
1978
|
+
|
1979
|
+
function push (v) {
|
1980
|
+
arr[L++] = v
|
1981
|
+
}
|
1982
|
+
|
1983
|
+
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
1984
|
+
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
1985
|
+
push((tmp & 0xFF0000) >> 16)
|
1986
|
+
push((tmp & 0xFF00) >> 8)
|
1987
|
+
push(tmp & 0xFF)
|
1988
|
+
}
|
1989
|
+
|
1990
|
+
if (placeHolders === 2) {
|
1991
|
+
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
1992
|
+
push(tmp & 0xFF)
|
1993
|
+
} else if (placeHolders === 1) {
|
1994
|
+
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
1995
|
+
push((tmp >> 8) & 0xFF)
|
1996
|
+
push(tmp & 0xFF)
|
1997
|
+
}
|
1998
|
+
|
1999
|
+
return arr
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
function uint8ToBase64 (uint8) {
|
2003
|
+
var i,
|
2004
|
+
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
2005
|
+
output = "",
|
2006
|
+
temp, length
|
2007
|
+
|
2008
|
+
function encode (num) {
|
2009
|
+
return lookup.charAt(num)
|
2010
|
+
}
|
2011
|
+
|
2012
|
+
function tripletToBase64 (num) {
|
2013
|
+
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
2014
|
+
}
|
2015
|
+
|
2016
|
+
// go through the array every three bytes, we'll deal with trailing stuff later
|
2017
|
+
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
2018
|
+
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
2019
|
+
output += tripletToBase64(temp)
|
2020
|
+
}
|
2021
|
+
|
2022
|
+
// pad the end with zeros, but make sure to not forget the extra bytes
|
2023
|
+
switch (extraBytes) {
|
2024
|
+
case 1:
|
2025
|
+
temp = uint8[uint8.length - 1]
|
2026
|
+
output += encode(temp >> 2)
|
2027
|
+
output += encode((temp << 4) & 0x3F)
|
2028
|
+
output += '=='
|
2029
|
+
break
|
2030
|
+
case 2:
|
2031
|
+
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
2032
|
+
output += encode(temp >> 10)
|
2033
|
+
output += encode((temp >> 4) & 0x3F)
|
2034
|
+
output += encode((temp << 2) & 0x3F)
|
2035
|
+
output += '='
|
2036
|
+
break
|
2037
|
+
}
|
2038
|
+
|
2039
|
+
return output
|
2040
|
+
}
|
2041
|
+
|
2042
|
+
module.exports.toByteArray = b64ToByteArray
|
2043
|
+
module.exports.fromByteArray = uint8ToBase64
|
2044
|
+
}())
|
2045
|
+
|
2046
|
+
},{}],20:[function(require,module,exports){
|
2047
|
+
/*
|
2048
|
+
* Copyright 2009-2011 Mozilla Foundation and contributors
|
2049
|
+
* Licensed under the New BSD license. See LICENSE.txt or:
|
2050
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
2051
|
+
*/
|
2052
|
+
exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
|
2053
|
+
exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
|
2054
|
+
exports.SourceNode = require('./source-map/source-node').SourceNode;
|
2055
|
+
|
2056
|
+
},{"./source-map/source-map-consumer":25,"./source-map/source-map-generator":26,"./source-map/source-node":27}],21:[function(require,module,exports){
|
2057
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2058
|
+
/*
|
2059
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
2060
|
+
* Licensed under the New BSD license. See LICENSE or:
|
2061
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
2062
|
+
*/
|
2063
|
+
if (typeof define !== 'function') {
|
2064
|
+
var define = require('amdefine')(module, require);
|
2065
|
+
}
|
2066
|
+
define(function (require, exports, module) {
|
2067
|
+
|
2068
|
+
var util = require('./util');
|
2069
|
+
|
2070
|
+
/**
|
2071
|
+
* A data structure which is a combination of an array and a set. Adding a new
|
2072
|
+
* member is O(1), testing for membership is O(1), and finding the index of an
|
2073
|
+
* element is O(1). Removing elements from the set is not supported. Only
|
2074
|
+
* strings are supported for membership.
|
2075
|
+
*/
|
2076
|
+
function ArraySet() {
|
2077
|
+
this._array = [];
|
2078
|
+
this._set = {};
|
2079
|
+
}
|
2080
|
+
|
2081
|
+
/**
|
2082
|
+
* Static method for creating ArraySet instances from an existing array.
|
2083
|
+
*/
|
2084
|
+
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
2085
|
+
var set = new ArraySet();
|
2086
|
+
for (var i = 0, len = aArray.length; i < len; i++) {
|
2087
|
+
set.add(aArray[i], aAllowDuplicates);
|
2088
|
+
}
|
2089
|
+
return set;
|
2090
|
+
};
|
2091
|
+
|
2092
|
+
/**
|
2093
|
+
* Add the given string to this set.
|
2094
|
+
*
|
2095
|
+
* @param String aStr
|
2096
|
+
*/
|
2097
|
+
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
2098
|
+
var isDuplicate = this.has(aStr);
|
2099
|
+
var idx = this._array.length;
|
2100
|
+
if (!isDuplicate || aAllowDuplicates) {
|
2101
|
+
this._array.push(aStr);
|
2102
|
+
}
|
2103
|
+
if (!isDuplicate) {
|
2104
|
+
this._set[util.toSetString(aStr)] = idx;
|
2105
|
+
}
|
2106
|
+
};
|
2107
|
+
|
2108
|
+
/**
|
2109
|
+
* Is the given string a member of this set?
|
2110
|
+
*
|
2111
|
+
* @param String aStr
|
2112
|
+
*/
|
2113
|
+
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
2114
|
+
return Object.prototype.hasOwnProperty.call(this._set,
|
2115
|
+
util.toSetString(aStr));
|
2116
|
+
};
|
2117
|
+
|
2118
|
+
/**
|
2119
|
+
* What is the index of the given string in the array?
|
2120
|
+
*
|
2121
|
+
* @param String aStr
|
2122
|
+
*/
|
2123
|
+
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
2124
|
+
if (this.has(aStr)) {
|
2125
|
+
return this._set[util.toSetString(aStr)];
|
2126
|
+
}
|
2127
|
+
throw new Error('"' + aStr + '" is not in the set.');
|
2128
|
+
};
|
2129
|
+
|
2130
|
+
/**
|
2131
|
+
* What is the element at the given index?
|
2132
|
+
*
|
2133
|
+
* @param Number aIdx
|
2134
|
+
*/
|
2135
|
+
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
2136
|
+
if (aIdx >= 0 && aIdx < this._array.length) {
|
2137
|
+
return this._array[aIdx];
|
2138
|
+
}
|
2139
|
+
throw new Error('No element indexed by ' + aIdx);
|
2140
|
+
};
|
2141
|
+
|
2142
|
+
/**
|
2143
|
+
* Returns the array representation of this set (which has the proper indices
|
2144
|
+
* indicated by indexOf). Note that this is a copy of the internal array used
|
2145
|
+
* for storing the members so that no one can mess with internal state.
|
2146
|
+
*/
|
2147
|
+
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
2148
|
+
return this._array.slice();
|
2149
|
+
};
|
2150
|
+
|
2151
|
+
exports.ArraySet = ArraySet;
|
2152
|
+
|
2153
|
+
});
|
2154
|
+
|
2155
|
+
},{"./util":28,"amdefine":29}],22:[function(require,module,exports){
|
2156
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2157
|
+
/*
|
2158
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
2159
|
+
* Licensed under the New BSD license. See LICENSE or:
|
2160
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
2161
|
+
*
|
2162
|
+
* Based on the Base 64 VLQ implementation in Closure Compiler:
|
2163
|
+
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
|
2164
|
+
*
|
2165
|
+
* Copyright 2011 The Closure Compiler Authors. All rights reserved.
|
2166
|
+
* Redistribution and use in source and binary forms, with or without
|
2167
|
+
* modification, are permitted provided that the following conditions are
|
2168
|
+
* met:
|
2169
|
+
*
|
2170
|
+
* * Redistributions of source code must retain the above copyright
|
2171
|
+
* notice, this list of conditions and the following disclaimer.
|
2172
|
+
* * Redistributions in binary form must reproduce the above
|
2173
|
+
* copyright notice, this list of conditions and the following
|
2174
|
+
* disclaimer in the documentation and/or other materials provided
|
2175
|
+
* with the distribution.
|
2176
|
+
* * Neither the name of Google Inc. nor the names of its
|
2177
|
+
* contributors may be used to endorse or promote products derived
|
2178
|
+
* from this software without specific prior written permission.
|
2179
|
+
*
|
2180
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
2181
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2182
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2183
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2184
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2185
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2186
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2187
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
2188
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
2189
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2190
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2191
|
+
*/
|
2192
|
+
if (typeof define !== 'function') {
|
2193
|
+
var define = require('amdefine')(module, require);
|
2194
|
+
}
|
2195
|
+
define(function (require, exports, module) {
|
2196
|
+
|
2197
|
+
var base64 = require('./base64');
|
2198
|
+
|
2199
|
+
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
|
2200
|
+
// length quantities we use in the source map spec, the first bit is the sign,
|
2201
|
+
// the next four bits are the actual value, and the 6th bit is the
|
2202
|
+
// continuation bit. The continuation bit tells us whether there are more
|
2203
|
+
// digits in this value following this digit.
|
2204
|
+
//
|
2205
|
+
// Continuation
|
2206
|
+
// | Sign
|
2207
|
+
// | |
|
2208
|
+
// V V
|
2209
|
+
// 101011
|
2210
|
+
|
2211
|
+
var VLQ_BASE_SHIFT = 5;
|
2212
|
+
|
2213
|
+
// binary: 100000
|
2214
|
+
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
2215
|
+
|
2216
|
+
// binary: 011111
|
2217
|
+
var VLQ_BASE_MASK = VLQ_BASE - 1;
|
2218
|
+
|
2219
|
+
// binary: 100000
|
2220
|
+
var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
2221
|
+
|
2222
|
+
/**
|
2223
|
+
* Converts from a two-complement value to a value where the sign bit is
|
2224
|
+
* is placed in the least significant bit. For example, as decimals:
|
2225
|
+
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
2226
|
+
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
2227
|
+
*/
|
2228
|
+
function toVLQSigned(aValue) {
|
2229
|
+
return aValue < 0
|
2230
|
+
? ((-aValue) << 1) + 1
|
2231
|
+
: (aValue << 1) + 0;
|
2232
|
+
}
|
2233
|
+
|
2234
|
+
/**
|
2235
|
+
* Converts to a two-complement value from a value where the sign bit is
|
2236
|
+
* is placed in the least significant bit. For example, as decimals:
|
2237
|
+
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
2238
|
+
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
2239
|
+
*/
|
2240
|
+
function fromVLQSigned(aValue) {
|
2241
|
+
var isNegative = (aValue & 1) === 1;
|
2242
|
+
var shifted = aValue >> 1;
|
2243
|
+
return isNegative
|
2244
|
+
? -shifted
|
2245
|
+
: shifted;
|
2246
|
+
}
|
2247
|
+
|
2248
|
+
/**
|
2249
|
+
* Returns the base 64 VLQ encoded value.
|
2250
|
+
*/
|
2251
|
+
exports.encode = function base64VLQ_encode(aValue) {
|
2252
|
+
var encoded = "";
|
2253
|
+
var digit;
|
2254
|
+
|
2255
|
+
var vlq = toVLQSigned(aValue);
|
2256
|
+
|
2257
|
+
do {
|
2258
|
+
digit = vlq & VLQ_BASE_MASK;
|
2259
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
2260
|
+
if (vlq > 0) {
|
2261
|
+
// There are still more digits in this value, so we must make sure the
|
2262
|
+
// continuation bit is marked.
|
2263
|
+
digit |= VLQ_CONTINUATION_BIT;
|
2264
|
+
}
|
2265
|
+
encoded += base64.encode(digit);
|
2266
|
+
} while (vlq > 0);
|
2267
|
+
|
2268
|
+
return encoded;
|
2269
|
+
};
|
2270
|
+
|
2271
|
+
/**
|
2272
|
+
* Decodes the next base 64 VLQ value from the given string and returns the
|
2273
|
+
* value and the rest of the string.
|
2274
|
+
*/
|
2275
|
+
exports.decode = function base64VLQ_decode(aStr) {
|
2276
|
+
var i = 0;
|
2277
|
+
var strLen = aStr.length;
|
2278
|
+
var result = 0;
|
2279
|
+
var shift = 0;
|
2280
|
+
var continuation, digit;
|
2281
|
+
|
2282
|
+
do {
|
2283
|
+
if (i >= strLen) {
|
2284
|
+
throw new Error("Expected more digits in base 64 VLQ value.");
|
2285
|
+
}
|
2286
|
+
digit = base64.decode(aStr.charAt(i++));
|
2287
|
+
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
2288
|
+
digit &= VLQ_BASE_MASK;
|
2289
|
+
result = result + (digit << shift);
|
2290
|
+
shift += VLQ_BASE_SHIFT;
|
2291
|
+
} while (continuation);
|
2292
|
+
|
2293
|
+
return {
|
2294
|
+
value: fromVLQSigned(result),
|
2295
|
+
rest: aStr.slice(i)
|
2296
|
+
};
|
2297
|
+
};
|
2298
|
+
|
2299
|
+
});
|
2300
|
+
|
2301
|
+
},{"./base64":23,"amdefine":29}],23:[function(require,module,exports){
|
2302
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2303
|
+
/*
|
2304
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
2305
|
+
* Licensed under the New BSD license. See LICENSE or:
|
2306
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
2307
|
+
*/
|
2308
|
+
if (typeof define !== 'function') {
|
2309
|
+
var define = require('amdefine')(module, require);
|
2310
|
+
}
|
2311
|
+
define(function (require, exports, module) {
|
2312
|
+
|
2313
|
+
var charToIntMap = {};
|
2314
|
+
var intToCharMap = {};
|
2315
|
+
|
2316
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
2317
|
+
.split('')
|
2318
|
+
.forEach(function (ch, index) {
|
2319
|
+
charToIntMap[ch] = index;
|
2320
|
+
intToCharMap[index] = ch;
|
2321
|
+
});
|
2322
|
+
|
2323
|
+
/**
|
2324
|
+
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
2325
|
+
*/
|
2326
|
+
exports.encode = function base64_encode(aNumber) {
|
2327
|
+
if (aNumber in intToCharMap) {
|
2328
|
+
return intToCharMap[aNumber];
|
2329
|
+
}
|
2330
|
+
throw new TypeError("Must be between 0 and 63: " + aNumber);
|
2331
|
+
};
|
2332
|
+
|
2333
|
+
/**
|
2334
|
+
* Decode a single base 64 digit to an integer.
|
2335
|
+
*/
|
2336
|
+
exports.decode = function base64_decode(aChar) {
|
2337
|
+
if (aChar in charToIntMap) {
|
2338
|
+
return charToIntMap[aChar];
|
2339
|
+
}
|
2340
|
+
throw new TypeError("Not a valid base 64 digit: " + aChar);
|
2341
|
+
};
|
2342
|
+
|
2343
|
+
});
|
2344
|
+
|
2345
|
+
},{"amdefine":29}],24:[function(require,module,exports){
|
2346
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2347
|
+
/*
|
2348
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
2349
|
+
* Licensed under the New BSD license. See LICENSE or:
|
2350
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
2351
|
+
*/
|
2352
|
+
if (typeof define !== 'function') {
|
2353
|
+
var define = require('amdefine')(module, require);
|
2354
|
+
}
|
2355
|
+
define(function (require, exports, module) {
|
2356
|
+
|
2357
|
+
/**
|
2358
|
+
* Recursive implementation of binary search.
|
2359
|
+
*
|
2360
|
+
* @param aLow Indices here and lower do not contain the needle.
|
2361
|
+
* @param aHigh Indices here and higher do not contain the needle.
|
2362
|
+
* @param aNeedle The element being searched for.
|
2363
|
+
* @param aHaystack The non-empty array being searched.
|
2364
|
+
* @param aCompare Function which takes two elements and returns -1, 0, or 1.
|
2365
|
+
*/
|
2366
|
+
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
|
2367
|
+
// This function terminates when one of the following is true:
|
2368
|
+
//
|
2369
|
+
// 1. We find the exact element we are looking for.
|
2370
|
+
//
|
2371
|
+
// 2. We did not find the exact element, but we can return the next
|
2372
|
+
// closest element that is less than that element.
|
2373
|
+
//
|
2374
|
+
// 3. We did not find the exact element, and there is no next-closest
|
2375
|
+
// element which is less than the one we are searching for, so we
|
2376
|
+
// return null.
|
2377
|
+
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
|
2378
|
+
var cmp = aCompare(aNeedle, aHaystack[mid], true);
|
2379
|
+
if (cmp === 0) {
|
2380
|
+
// Found the element we are looking for.
|
2381
|
+
return aHaystack[mid];
|
2382
|
+
}
|
2383
|
+
else if (cmp > 0) {
|
2384
|
+
// aHaystack[mid] is greater than our needle.
|
2385
|
+
if (aHigh - mid > 1) {
|
2386
|
+
// The element is in the upper half.
|
2387
|
+
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
|
2388
|
+
}
|
2389
|
+
// We did not find an exact match, return the next closest one
|
2390
|
+
// (termination case 2).
|
2391
|
+
return aHaystack[mid];
|
2392
|
+
}
|
2393
|
+
else {
|
2394
|
+
// aHaystack[mid] is less than our needle.
|
2395
|
+
if (mid - aLow > 1) {
|
2396
|
+
// The element is in the lower half.
|
2397
|
+
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
|
2398
|
+
}
|
2399
|
+
// The exact needle element was not found in this haystack. Determine if
|
2400
|
+
// we are in termination case (2) or (3) and return the appropriate thing.
|
2401
|
+
return aLow < 0
|
2402
|
+
? null
|
2403
|
+
: aHaystack[aLow];
|
2404
|
+
}
|
2405
|
+
}
|
2406
|
+
|
2407
|
+
/**
|
2408
|
+
* This is an implementation of binary search which will always try and return
|
2409
|
+
* the next lowest value checked if there is no exact hit. This is because
|
2410
|
+
* mappings between original and generated line/col pairs are single points,
|
2411
|
+
* and there is an implicit region between each of them, so a miss just means
|
2412
|
+
* that you aren't on the very start of a region.
|
2413
|
+
*
|
2414
|
+
* @param aNeedle The element you are looking for.
|
2415
|
+
* @param aHaystack The array that is being searched.
|
2416
|
+
* @param aCompare A function which takes the needle and an element in the
|
2417
|
+
* array and returns -1, 0, or 1 depending on whether the needle is less
|
2418
|
+
* than, equal to, or greater than the element, respectively.
|
2419
|
+
*/
|
2420
|
+
exports.search = function search(aNeedle, aHaystack, aCompare) {
|
2421
|
+
return aHaystack.length > 0
|
2422
|
+
? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
|
2423
|
+
: null;
|
2424
|
+
};
|
2425
|
+
|
2426
|
+
});
|
2427
|
+
|
2428
|
+
},{"amdefine":29}],25:[function(require,module,exports){
|
2429
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2430
|
+
/*
|
2431
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
2432
|
+
* Licensed under the New BSD license. See LICENSE or:
|
2433
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
2434
|
+
*/
|
2435
|
+
if (typeof define !== 'function') {
|
2436
|
+
var define = require('amdefine')(module, require);
|
2437
|
+
}
|
2438
|
+
define(function (require, exports, module) {
|
2439
|
+
|
2440
|
+
var util = require('./util');
|
2441
|
+
var binarySearch = require('./binary-search');
|
2442
|
+
var ArraySet = require('./array-set').ArraySet;
|
2443
|
+
var base64VLQ = require('./base64-vlq');
|
2444
|
+
|
2445
|
+
/**
|
2446
|
+
* A SourceMapConsumer instance represents a parsed source map which we can
|
2447
|
+
* query for information about the original file positions by giving it a file
|
2448
|
+
* position in the generated source.
|
2449
|
+
*
|
2450
|
+
* The only parameter is the raw source map (either as a JSON string, or
|
2451
|
+
* already parsed to an object). According to the spec, source maps have the
|
2452
|
+
* following attributes:
|
2453
|
+
*
|
2454
|
+
* - version: Which version of the source map spec this map is following.
|
2455
|
+
* - sources: An array of URLs to the original source files.
|
2456
|
+
* - names: An array of identifiers which can be referrenced by individual mappings.
|
2457
|
+
* - sourceRoot: Optional. The URL root from which all sources are relative.
|
2458
|
+
* - sourcesContent: Optional. An array of contents of the original source files.
|
2459
|
+
* - mappings: A string of base64 VLQs which contain the actual mappings.
|
2460
|
+
* - file: Optional. The generated file this source map is associated with.
|
2461
|
+
*
|
2462
|
+
* Here is an example source map, taken from the source map spec[0]:
|
2463
|
+
*
|
2464
|
+
* {
|
2465
|
+
* version : 3,
|
2466
|
+
* file: "out.js",
|
2467
|
+
* sourceRoot : "",
|
2468
|
+
* sources: ["foo.js", "bar.js"],
|
2469
|
+
* names: ["src", "maps", "are", "fun"],
|
2470
|
+
* mappings: "AA,AB;;ABCDE;"
|
2471
|
+
* }
|
2472
|
+
*
|
2473
|
+
* [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
|
2474
|
+
*/
|
2475
|
+
function SourceMapConsumer(aSourceMap) {
|
2476
|
+
var sourceMap = aSourceMap;
|
2477
|
+
if (typeof aSourceMap === 'string') {
|
2478
|
+
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
|
2479
|
+
}
|
2480
|
+
|
2481
|
+
var version = util.getArg(sourceMap, 'version');
|
2482
|
+
var sources = util.getArg(sourceMap, 'sources');
|
2483
|
+
// Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
|
2484
|
+
// requires the array) to play nice here.
|
2485
|
+
var names = util.getArg(sourceMap, 'names', []);
|
2486
|
+
var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
|
2487
|
+
var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
|
2488
|
+
var mappings = util.getArg(sourceMap, 'mappings');
|
2489
|
+
var file = util.getArg(sourceMap, 'file', null);
|
2490
|
+
|
2491
|
+
// Once again, Sass deviates from the spec and supplies the version as a
|
2492
|
+
// string rather than a number, so we use loose equality checking here.
|
2493
|
+
if (version != this._version) {
|
2494
|
+
throw new Error('Unsupported version: ' + version);
|
2495
|
+
}
|
2496
|
+
|
2497
|
+
// Pass `true` below to allow duplicate names and sources. While source maps
|
2498
|
+
// are intended to be compressed and deduplicated, the TypeScript compiler
|
2499
|
+
// sometimes generates source maps with duplicates in them. See Github issue
|
2500
|
+
// #72 and bugzil.la/889492.
|
2501
|
+
this._names = ArraySet.fromArray(names, true);
|
2502
|
+
this._sources = ArraySet.fromArray(sources, true);
|
2503
|
+
|
2504
|
+
this.sourceRoot = sourceRoot;
|
2505
|
+
this.sourcesContent = sourcesContent;
|
2506
|
+
this._mappings = mappings;
|
2507
|
+
this.file = file;
|
2508
|
+
}
|
2509
|
+
|
2510
|
+
/**
|
2511
|
+
* Create a SourceMapConsumer from a SourceMapGenerator.
|
2512
|
+
*
|
2513
|
+
* @param SourceMapGenerator aSourceMap
|
2514
|
+
* The source map that will be consumed.
|
2515
|
+
* @returns SourceMapConsumer
|
2516
|
+
*/
|
2517
|
+
SourceMapConsumer.fromSourceMap =
|
2518
|
+
function SourceMapConsumer_fromSourceMap(aSourceMap) {
|
2519
|
+
var smc = Object.create(SourceMapConsumer.prototype);
|
2520
|
+
|
2521
|
+
smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
|
2522
|
+
smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
|
2523
|
+
smc.sourceRoot = aSourceMap._sourceRoot;
|
2524
|
+
smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
|
2525
|
+
smc.sourceRoot);
|
2526
|
+
smc.file = aSourceMap._file;
|
2527
|
+
|
2528
|
+
smc.__generatedMappings = aSourceMap._mappings.slice()
|
2529
|
+
.sort(util.compareByGeneratedPositions);
|
2530
|
+
smc.__originalMappings = aSourceMap._mappings.slice()
|
2531
|
+
.sort(util.compareByOriginalPositions);
|
2532
|
+
|
2533
|
+
return smc;
|
2534
|
+
};
|
2535
|
+
|
2536
|
+
/**
|
2537
|
+
* The version of the source mapping spec that we are consuming.
|
2538
|
+
*/
|
2539
|
+
SourceMapConsumer.prototype._version = 3;
|
2540
|
+
|
2541
|
+
/**
|
2542
|
+
* The list of original sources.
|
2543
|
+
*/
|
2544
|
+
Object.defineProperty(SourceMapConsumer.prototype, 'sources', {
|
2545
|
+
get: function () {
|
2546
|
+
return this._sources.toArray().map(function (s) {
|
2547
|
+
return this.sourceRoot ? util.join(this.sourceRoot, s) : s;
|
2548
|
+
}, this);
|
2549
|
+
}
|
2550
|
+
});
|
2551
|
+
|
2552
|
+
// `__generatedMappings` and `__originalMappings` are arrays that hold the
|
2553
|
+
// parsed mapping coordinates from the source map's "mappings" attribute. They
|
2554
|
+
// are lazily instantiated, accessed via the `_generatedMappings` and
|
2555
|
+
// `_originalMappings` getters respectively, and we only parse the mappings
|
2556
|
+
// and create these arrays once queried for a source location. We jump through
|
2557
|
+
// these hoops because there can be many thousands of mappings, and parsing
|
2558
|
+
// them is expensive, so we only want to do it if we must.
|
2559
|
+
//
|
2560
|
+
// Each object in the arrays is of the form:
|
2561
|
+
//
|
2562
|
+
// {
|
2563
|
+
// generatedLine: The line number in the generated code,
|
2564
|
+
// generatedColumn: The column number in the generated code,
|
2565
|
+
// source: The path to the original source file that generated this
|
2566
|
+
// chunk of code,
|
2567
|
+
// originalLine: The line number in the original source that
|
2568
|
+
// corresponds to this chunk of generated code,
|
2569
|
+
// originalColumn: The column number in the original source that
|
2570
|
+
// corresponds to this chunk of generated code,
|
2571
|
+
// name: The name of the original symbol which generated this chunk of
|
2572
|
+
// code.
|
2573
|
+
// }
|
2574
|
+
//
|
2575
|
+
// All properties except for `generatedLine` and `generatedColumn` can be
|
2576
|
+
// `null`.
|
2577
|
+
//
|
2578
|
+
// `_generatedMappings` is ordered by the generated positions.
|
2579
|
+
//
|
2580
|
+
// `_originalMappings` is ordered by the original positions.
|
2581
|
+
|
2582
|
+
SourceMapConsumer.prototype.__generatedMappings = null;
|
2583
|
+
Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
|
2584
|
+
get: function () {
|
2585
|
+
if (!this.__generatedMappings) {
|
2586
|
+
this.__generatedMappings = [];
|
2587
|
+
this.__originalMappings = [];
|
2588
|
+
this._parseMappings(this._mappings, this.sourceRoot);
|
2589
|
+
}
|
2590
|
+
|
2591
|
+
return this.__generatedMappings;
|
2592
|
+
}
|
2593
|
+
});
|
2594
|
+
|
2595
|
+
SourceMapConsumer.prototype.__originalMappings = null;
|
2596
|
+
Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
|
2597
|
+
get: function () {
|
2598
|
+
if (!this.__originalMappings) {
|
2599
|
+
this.__generatedMappings = [];
|
2600
|
+
this.__originalMappings = [];
|
2601
|
+
this._parseMappings(this._mappings, this.sourceRoot);
|
2602
|
+
}
|
2603
|
+
|
2604
|
+
return this.__originalMappings;
|
2605
|
+
}
|
2606
|
+
});
|
2607
|
+
|
2608
|
+
/**
|
2609
|
+
* Parse the mappings in a string in to a data structure which we can easily
|
2610
|
+
* query (the ordered arrays in the `this.__generatedMappings` and
|
2611
|
+
* `this.__originalMappings` properties).
|
2612
|
+
*/
|
2613
|
+
SourceMapConsumer.prototype._parseMappings =
|
2614
|
+
function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
|
2615
|
+
var generatedLine = 1;
|
2616
|
+
var previousGeneratedColumn = 0;
|
2617
|
+
var previousOriginalLine = 0;
|
2618
|
+
var previousOriginalColumn = 0;
|
2619
|
+
var previousSource = 0;
|
2620
|
+
var previousName = 0;
|
2621
|
+
var mappingSeparator = /^[,;]/;
|
2622
|
+
var str = aStr;
|
2623
|
+
var mapping;
|
2624
|
+
var temp;
|
2625
|
+
|
2626
|
+
while (str.length > 0) {
|
2627
|
+
if (str.charAt(0) === ';') {
|
2628
|
+
generatedLine++;
|
2629
|
+
str = str.slice(1);
|
2630
|
+
previousGeneratedColumn = 0;
|
2631
|
+
}
|
2632
|
+
else if (str.charAt(0) === ',') {
|
2633
|
+
str = str.slice(1);
|
2634
|
+
}
|
2635
|
+
else {
|
2636
|
+
mapping = {};
|
2637
|
+
mapping.generatedLine = generatedLine;
|
2638
|
+
|
2639
|
+
// Generated column.
|
2640
|
+
temp = base64VLQ.decode(str);
|
2641
|
+
mapping.generatedColumn = previousGeneratedColumn + temp.value;
|
2642
|
+
previousGeneratedColumn = mapping.generatedColumn;
|
2643
|
+
str = temp.rest;
|
2644
|
+
|
2645
|
+
if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
|
2646
|
+
// Original source.
|
2647
|
+
temp = base64VLQ.decode(str);
|
2648
|
+
mapping.source = this._sources.at(previousSource + temp.value);
|
2649
|
+
previousSource += temp.value;
|
2650
|
+
str = temp.rest;
|
2651
|
+
if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
|
2652
|
+
throw new Error('Found a source, but no line and column');
|
2653
|
+
}
|
2654
|
+
|
2655
|
+
// Original line.
|
2656
|
+
temp = base64VLQ.decode(str);
|
2657
|
+
mapping.originalLine = previousOriginalLine + temp.value;
|
2658
|
+
previousOriginalLine = mapping.originalLine;
|
2659
|
+
// Lines are stored 0-based
|
2660
|
+
mapping.originalLine += 1;
|
2661
|
+
str = temp.rest;
|
2662
|
+
if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
|
2663
|
+
throw new Error('Found a source and line, but no column');
|
2664
|
+
}
|
2665
|
+
|
2666
|
+
// Original column.
|
2667
|
+
temp = base64VLQ.decode(str);
|
2668
|
+
mapping.originalColumn = previousOriginalColumn + temp.value;
|
2669
|
+
previousOriginalColumn = mapping.originalColumn;
|
2670
|
+
str = temp.rest;
|
2671
|
+
|
2672
|
+
if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
|
2673
|
+
// Original name.
|
2674
|
+
temp = base64VLQ.decode(str);
|
2675
|
+
mapping.name = this._names.at(previousName + temp.value);
|
2676
|
+
previousName += temp.value;
|
2677
|
+
str = temp.rest;
|
2678
|
+
}
|
2679
|
+
}
|
2680
|
+
|
2681
|
+
this.__generatedMappings.push(mapping);
|
2682
|
+
if (typeof mapping.originalLine === 'number') {
|
2683
|
+
this.__originalMappings.push(mapping);
|
2684
|
+
}
|
2685
|
+
}
|
2686
|
+
}
|
2687
|
+
|
2688
|
+
this.__generatedMappings.sort(util.compareByGeneratedPositions);
|
2689
|
+
this.__originalMappings.sort(util.compareByOriginalPositions);
|
2690
|
+
};
|
2691
|
+
|
2692
|
+
/**
|
2693
|
+
* Find the mapping that best matches the hypothetical "needle" mapping that
|
2694
|
+
* we are searching for in the given "haystack" of mappings.
|
2695
|
+
*/
|
2696
|
+
SourceMapConsumer.prototype._findMapping =
|
2697
|
+
function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
|
2698
|
+
aColumnName, aComparator) {
|
2699
|
+
// To return the position we are searching for, we must first find the
|
2700
|
+
// mapping for the given position and then return the opposite position it
|
2701
|
+
// points to. Because the mappings are sorted, we can use binary search to
|
2702
|
+
// find the best mapping.
|
2703
|
+
|
2704
|
+
if (aNeedle[aLineName] <= 0) {
|
2705
|
+
throw new TypeError('Line must be greater than or equal to 1, got '
|
2706
|
+
+ aNeedle[aLineName]);
|
2707
|
+
}
|
2708
|
+
if (aNeedle[aColumnName] < 0) {
|
2709
|
+
throw new TypeError('Column must be greater than or equal to 0, got '
|
2710
|
+
+ aNeedle[aColumnName]);
|
2711
|
+
}
|
2712
|
+
|
2713
|
+
return binarySearch.search(aNeedle, aMappings, aComparator);
|
2714
|
+
};
|
2715
|
+
|
2716
|
+
/**
|
2717
|
+
* Returns the original source, line, and column information for the generated
|
2718
|
+
* source's line and column positions provided. The only argument is an object
|
2719
|
+
* with the following properties:
|
2720
|
+
*
|
2721
|
+
* - line: The line number in the generated source.
|
2722
|
+
* - column: The column number in the generated source.
|
2723
|
+
*
|
2724
|
+
* and an object is returned with the following properties:
|
2725
|
+
*
|
2726
|
+
* - source: The original source file, or null.
|
2727
|
+
* - line: The line number in the original source, or null.
|
2728
|
+
* - column: The column number in the original source, or null.
|
2729
|
+
* - name: The original identifier, or null.
|
2730
|
+
*/
|
2731
|
+
SourceMapConsumer.prototype.originalPositionFor =
|
2732
|
+
function SourceMapConsumer_originalPositionFor(aArgs) {
|
2733
|
+
var needle = {
|
2734
|
+
generatedLine: util.getArg(aArgs, 'line'),
|
2735
|
+
generatedColumn: util.getArg(aArgs, 'column')
|
2736
|
+
};
|
2737
|
+
|
2738
|
+
var mapping = this._findMapping(needle,
|
2739
|
+
this._generatedMappings,
|
2740
|
+
"generatedLine",
|
2741
|
+
"generatedColumn",
|
2742
|
+
util.compareByGeneratedPositions);
|
2743
|
+
|
2744
|
+
if (mapping && mapping.generatedLine === needle.generatedLine) {
|
2745
|
+
var source = util.getArg(mapping, 'source', null);
|
2746
|
+
if (source && this.sourceRoot) {
|
2747
|
+
source = util.join(this.sourceRoot, source);
|
2748
|
+
}
|
2749
|
+
return {
|
2750
|
+
source: source,
|
2751
|
+
line: util.getArg(mapping, 'originalLine', null),
|
2752
|
+
column: util.getArg(mapping, 'originalColumn', null),
|
2753
|
+
name: util.getArg(mapping, 'name', null)
|
2754
|
+
};
|
2755
|
+
}
|
2756
|
+
|
2757
|
+
return {
|
2758
|
+
source: null,
|
2759
|
+
line: null,
|
2760
|
+
column: null,
|
2761
|
+
name: null
|
2762
|
+
};
|
2763
|
+
};
|
2764
|
+
|
2765
|
+
/**
|
2766
|
+
* Returns the original source content. The only argument is the url of the
|
2767
|
+
* original source file. Returns null if no original source content is
|
2768
|
+
* availible.
|
2769
|
+
*/
|
2770
|
+
SourceMapConsumer.prototype.sourceContentFor =
|
2771
|
+
function SourceMapConsumer_sourceContentFor(aSource) {
|
2772
|
+
if (!this.sourcesContent) {
|
2773
|
+
return null;
|
2774
|
+
}
|
2775
|
+
|
2776
|
+
if (this.sourceRoot) {
|
2777
|
+
aSource = util.relative(this.sourceRoot, aSource);
|
2778
|
+
}
|
2779
|
+
|
2780
|
+
if (this._sources.has(aSource)) {
|
2781
|
+
return this.sourcesContent[this._sources.indexOf(aSource)];
|
2782
|
+
}
|
2783
|
+
|
2784
|
+
var url;
|
2785
|
+
if (this.sourceRoot
|
2786
|
+
&& (url = util.urlParse(this.sourceRoot))) {
|
2787
|
+
// XXX: file:// URIs and absolute paths lead to unexpected behavior for
|
2788
|
+
// many users. We can help them out when they expect file:// URIs to
|
2789
|
+
// behave like it would if they were running a local HTTP server. See
|
2790
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
|
2791
|
+
var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
|
2792
|
+
if (url.scheme == "file"
|
2793
|
+
&& this._sources.has(fileUriAbsPath)) {
|
2794
|
+
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
|
2795
|
+
}
|
2796
|
+
|
2797
|
+
if ((!url.path || url.path == "/")
|
2798
|
+
&& this._sources.has("/" + aSource)) {
|
2799
|
+
return this.sourcesContent[this._sources.indexOf("/" + aSource)];
|
2800
|
+
}
|
2801
|
+
}
|
2802
|
+
|
2803
|
+
throw new Error('"' + aSource + '" is not in the SourceMap.');
|
2804
|
+
};
|
2805
|
+
|
2806
|
+
/**
|
2807
|
+
* Returns the generated line and column information for the original source,
|
2808
|
+
* line, and column positions provided. The only argument is an object with
|
2809
|
+
* the following properties:
|
2810
|
+
*
|
2811
|
+
* - source: The filename of the original source.
|
2812
|
+
* - line: The line number in the original source.
|
2813
|
+
* - column: The column number in the original source.
|
2814
|
+
*
|
2815
|
+
* and an object is returned with the following properties:
|
2816
|
+
*
|
2817
|
+
* - line: The line number in the generated source, or null.
|
2818
|
+
* - column: The column number in the generated source, or null.
|
2819
|
+
*/
|
2820
|
+
SourceMapConsumer.prototype.generatedPositionFor =
|
2821
|
+
function SourceMapConsumer_generatedPositionFor(aArgs) {
|
2822
|
+
var needle = {
|
2823
|
+
source: util.getArg(aArgs, 'source'),
|
2824
|
+
originalLine: util.getArg(aArgs, 'line'),
|
2825
|
+
originalColumn: util.getArg(aArgs, 'column')
|
2826
|
+
};
|
2827
|
+
|
2828
|
+
if (this.sourceRoot) {
|
2829
|
+
needle.source = util.relative(this.sourceRoot, needle.source);
|
2830
|
+
}
|
2831
|
+
|
2832
|
+
var mapping = this._findMapping(needle,
|
2833
|
+
this._originalMappings,
|
2834
|
+
"originalLine",
|
2835
|
+
"originalColumn",
|
2836
|
+
util.compareByOriginalPositions);
|
2837
|
+
|
2838
|
+
if (mapping) {
|
2839
|
+
return {
|
2840
|
+
line: util.getArg(mapping, 'generatedLine', null),
|
2841
|
+
column: util.getArg(mapping, 'generatedColumn', null)
|
2842
|
+
};
|
2843
|
+
}
|
2844
|
+
|
2845
|
+
return {
|
2846
|
+
line: null,
|
2847
|
+
column: null
|
2848
|
+
};
|
2849
|
+
};
|
2850
|
+
|
2851
|
+
SourceMapConsumer.GENERATED_ORDER = 1;
|
2852
|
+
SourceMapConsumer.ORIGINAL_ORDER = 2;
|
2853
|
+
|
2854
|
+
/**
|
2855
|
+
* Iterate over each mapping between an original source/line/column and a
|
2856
|
+
* generated line/column in this source map.
|
2857
|
+
*
|
2858
|
+
* @param Function aCallback
|
2859
|
+
* The function that is called with each mapping.
|
2860
|
+
* @param Object aContext
|
2861
|
+
* Optional. If specified, this object will be the value of `this` every
|
2862
|
+
* time that `aCallback` is called.
|
2863
|
+
* @param aOrder
|
2864
|
+
* Either `SourceMapConsumer.GENERATED_ORDER` or
|
2865
|
+
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
|
2866
|
+
* iterate over the mappings sorted by the generated file's line/column
|
2867
|
+
* order or the original's source/line/column order, respectively. Defaults to
|
2868
|
+
* `SourceMapConsumer.GENERATED_ORDER`.
|
2869
|
+
*/
|
2870
|
+
SourceMapConsumer.prototype.eachMapping =
|
2871
|
+
function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
|
2872
|
+
var context = aContext || null;
|
2873
|
+
var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
|
2874
|
+
|
2875
|
+
var mappings;
|
2876
|
+
switch (order) {
|
2877
|
+
case SourceMapConsumer.GENERATED_ORDER:
|
2878
|
+
mappings = this._generatedMappings;
|
2879
|
+
break;
|
2880
|
+
case SourceMapConsumer.ORIGINAL_ORDER:
|
2881
|
+
mappings = this._originalMappings;
|
2882
|
+
break;
|
2883
|
+
default:
|
2884
|
+
throw new Error("Unknown order of iteration.");
|
2885
|
+
}
|
2886
|
+
|
2887
|
+
var sourceRoot = this.sourceRoot;
|
2888
|
+
mappings.map(function (mapping) {
|
2889
|
+
var source = mapping.source;
|
2890
|
+
if (source && sourceRoot) {
|
2891
|
+
source = util.join(sourceRoot, source);
|
2892
|
+
}
|
2893
|
+
return {
|
2894
|
+
source: source,
|
2895
|
+
generatedLine: mapping.generatedLine,
|
2896
|
+
generatedColumn: mapping.generatedColumn,
|
2897
|
+
originalLine: mapping.originalLine,
|
2898
|
+
originalColumn: mapping.originalColumn,
|
2899
|
+
name: mapping.name
|
2900
|
+
};
|
2901
|
+
}).forEach(aCallback, context);
|
2902
|
+
};
|
2903
|
+
|
2904
|
+
exports.SourceMapConsumer = SourceMapConsumer;
|
2905
|
+
|
2906
|
+
});
|
2907
|
+
|
2908
|
+
},{"./array-set":21,"./base64-vlq":22,"./binary-search":24,"./util":28,"amdefine":29}],26:[function(require,module,exports){
|
2909
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2910
|
+
/*
|
2911
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
2912
|
+
* Licensed under the New BSD license. See LICENSE or:
|
2913
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
2914
|
+
*/
|
2915
|
+
if (typeof define !== 'function') {
|
2916
|
+
var define = require('amdefine')(module, require);
|
2917
|
+
}
|
2918
|
+
define(function (require, exports, module) {
|
2919
|
+
|
2920
|
+
var base64VLQ = require('./base64-vlq');
|
2921
|
+
var util = require('./util');
|
2922
|
+
var ArraySet = require('./array-set').ArraySet;
|
2923
|
+
|
2924
|
+
/**
|
2925
|
+
* An instance of the SourceMapGenerator represents a source map which is
|
2926
|
+
* being built incrementally. You may pass an object with the following
|
2927
|
+
* properties:
|
2928
|
+
*
|
2929
|
+
* - file: The filename of the generated source.
|
2930
|
+
* - sourceRoot: A root for all relative URLs in this source map.
|
2931
|
+
*/
|
2932
|
+
function SourceMapGenerator(aArgs) {
|
2933
|
+
if (!aArgs) {
|
2934
|
+
aArgs = {};
|
2935
|
+
}
|
2936
|
+
this._file = util.getArg(aArgs, 'file', null);
|
2937
|
+
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
2938
|
+
this._sources = new ArraySet();
|
2939
|
+
this._names = new ArraySet();
|
2940
|
+
this._mappings = [];
|
2941
|
+
this._sourcesContents = null;
|
2942
|
+
}
|
2943
|
+
|
2944
|
+
SourceMapGenerator.prototype._version = 3;
|
2945
|
+
|
2946
|
+
/**
|
2947
|
+
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
2948
|
+
*
|
2949
|
+
* @param aSourceMapConsumer The SourceMap.
|
2950
|
+
*/
|
2951
|
+
SourceMapGenerator.fromSourceMap =
|
2952
|
+
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
2953
|
+
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
2954
|
+
var generator = new SourceMapGenerator({
|
2955
|
+
file: aSourceMapConsumer.file,
|
2956
|
+
sourceRoot: sourceRoot
|
2957
|
+
});
|
2958
|
+
aSourceMapConsumer.eachMapping(function (mapping) {
|
2959
|
+
var newMapping = {
|
2960
|
+
generated: {
|
2961
|
+
line: mapping.generatedLine,
|
2962
|
+
column: mapping.generatedColumn
|
2963
|
+
}
|
2964
|
+
};
|
2965
|
+
|
2966
|
+
if (mapping.source) {
|
2967
|
+
newMapping.source = mapping.source;
|
2968
|
+
if (sourceRoot) {
|
2969
|
+
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
2970
|
+
}
|
2971
|
+
|
2972
|
+
newMapping.original = {
|
2973
|
+
line: mapping.originalLine,
|
2974
|
+
column: mapping.originalColumn
|
2975
|
+
};
|
2976
|
+
|
2977
|
+
if (mapping.name) {
|
2978
|
+
newMapping.name = mapping.name;
|
2979
|
+
}
|
2980
|
+
}
|
2981
|
+
|
2982
|
+
generator.addMapping(newMapping);
|
2983
|
+
});
|
2984
|
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
2985
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
2986
|
+
if (content) {
|
2987
|
+
generator.setSourceContent(sourceFile, content);
|
2988
|
+
}
|
2989
|
+
});
|
2990
|
+
return generator;
|
2991
|
+
};
|
2992
|
+
|
2993
|
+
/**
|
2994
|
+
* Add a single mapping from original source line and column to the generated
|
2995
|
+
* source's line and column for this source map being created. The mapping
|
2996
|
+
* object should have the following properties:
|
2997
|
+
*
|
2998
|
+
* - generated: An object with the generated line and column positions.
|
2999
|
+
* - original: An object with the original line and column positions.
|
3000
|
+
* - source: The original source file (relative to the sourceRoot).
|
3001
|
+
* - name: An optional original token name for this mapping.
|
3002
|
+
*/
|
3003
|
+
SourceMapGenerator.prototype.addMapping =
|
3004
|
+
function SourceMapGenerator_addMapping(aArgs) {
|
3005
|
+
var generated = util.getArg(aArgs, 'generated');
|
3006
|
+
var original = util.getArg(aArgs, 'original', null);
|
3007
|
+
var source = util.getArg(aArgs, 'source', null);
|
3008
|
+
var name = util.getArg(aArgs, 'name', null);
|
3009
|
+
|
3010
|
+
this._validateMapping(generated, original, source, name);
|
3011
|
+
|
3012
|
+
if (source && !this._sources.has(source)) {
|
3013
|
+
this._sources.add(source);
|
3014
|
+
}
|
3015
|
+
|
3016
|
+
if (name && !this._names.has(name)) {
|
3017
|
+
this._names.add(name);
|
3018
|
+
}
|
3019
|
+
|
3020
|
+
this._mappings.push({
|
3021
|
+
generatedLine: generated.line,
|
3022
|
+
generatedColumn: generated.column,
|
3023
|
+
originalLine: original != null && original.line,
|
3024
|
+
originalColumn: original != null && original.column,
|
3025
|
+
source: source,
|
3026
|
+
name: name
|
3027
|
+
});
|
3028
|
+
};
|
3029
|
+
|
3030
|
+
/**
|
3031
|
+
* Set the source content for a source file.
|
3032
|
+
*/
|
3033
|
+
SourceMapGenerator.prototype.setSourceContent =
|
3034
|
+
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
3035
|
+
var source = aSourceFile;
|
3036
|
+
if (this._sourceRoot) {
|
3037
|
+
source = util.relative(this._sourceRoot, source);
|
3038
|
+
}
|
3039
|
+
|
3040
|
+
if (aSourceContent !== null) {
|
3041
|
+
// Add the source content to the _sourcesContents map.
|
3042
|
+
// Create a new _sourcesContents map if the property is null.
|
3043
|
+
if (!this._sourcesContents) {
|
3044
|
+
this._sourcesContents = {};
|
3045
|
+
}
|
3046
|
+
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
3047
|
+
} else {
|
3048
|
+
// Remove the source file from the _sourcesContents map.
|
3049
|
+
// If the _sourcesContents map is empty, set the property to null.
|
3050
|
+
delete this._sourcesContents[util.toSetString(source)];
|
3051
|
+
if (Object.keys(this._sourcesContents).length === 0) {
|
3052
|
+
this._sourcesContents = null;
|
3053
|
+
}
|
3054
|
+
}
|
3055
|
+
};
|
3056
|
+
|
3057
|
+
/**
|
3058
|
+
* Applies the mappings of a sub-source-map for a specific source file to the
|
3059
|
+
* source map being generated. Each mapping to the supplied source file is
|
3060
|
+
* rewritten using the supplied source map. Note: The resolution for the
|
3061
|
+
* resulting mappings is the minimium of this map and the supplied map.
|
3062
|
+
*
|
3063
|
+
* @param aSourceMapConsumer The source map to be applied.
|
3064
|
+
* @param aSourceFile Optional. The filename of the source file.
|
3065
|
+
* If omitted, SourceMapConsumer's file property will be used.
|
3066
|
+
* @param aSourceMapPath Optional. The dirname of the path to the source map
|
3067
|
+
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
3068
|
+
* This parameter is needed when the two source maps aren't in the same
|
3069
|
+
* directory, and the source map to be applied contains relative source
|
3070
|
+
* paths. If so, those relative source paths need to be rewritten
|
3071
|
+
* relative to the SourceMapGenerator.
|
3072
|
+
*/
|
3073
|
+
SourceMapGenerator.prototype.applySourceMap =
|
3074
|
+
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
3075
|
+
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
3076
|
+
if (!aSourceFile) {
|
3077
|
+
if (!aSourceMapConsumer.file) {
|
3078
|
+
throw new Error(
|
3079
|
+
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
|
3080
|
+
'or the source map\'s "file" property. Both were omitted.'
|
3081
|
+
);
|
3082
|
+
}
|
3083
|
+
aSourceFile = aSourceMapConsumer.file;
|
3084
|
+
}
|
3085
|
+
var sourceRoot = this._sourceRoot;
|
3086
|
+
// Make "aSourceFile" relative if an absolute Url is passed.
|
3087
|
+
if (sourceRoot) {
|
3088
|
+
aSourceFile = util.relative(sourceRoot, aSourceFile);
|
3089
|
+
}
|
3090
|
+
// Applying the SourceMap can add and remove items from the sources and
|
3091
|
+
// the names array.
|
3092
|
+
var newSources = new ArraySet();
|
3093
|
+
var newNames = new ArraySet();
|
3094
|
+
|
3095
|
+
// Find mappings for the "aSourceFile"
|
3096
|
+
this._mappings.forEach(function (mapping) {
|
3097
|
+
if (mapping.source === aSourceFile && mapping.originalLine) {
|
3098
|
+
// Check if it can be mapped by the source map, then update the mapping.
|
3099
|
+
var original = aSourceMapConsumer.originalPositionFor({
|
3100
|
+
line: mapping.originalLine,
|
3101
|
+
column: mapping.originalColumn
|
3102
|
+
});
|
3103
|
+
if (original.source !== null) {
|
3104
|
+
// Copy mapping
|
3105
|
+
mapping.source = original.source;
|
3106
|
+
if (aSourceMapPath) {
|
3107
|
+
mapping.source = util.join(aSourceMapPath, mapping.source)
|
3108
|
+
}
|
3109
|
+
if (sourceRoot) {
|
3110
|
+
mapping.source = util.relative(sourceRoot, mapping.source);
|
3111
|
+
}
|
3112
|
+
mapping.originalLine = original.line;
|
3113
|
+
mapping.originalColumn = original.column;
|
3114
|
+
if (original.name !== null && mapping.name !== null) {
|
3115
|
+
// Only use the identifier name if it's an identifier
|
3116
|
+
// in both SourceMaps
|
3117
|
+
mapping.name = original.name;
|
3118
|
+
}
|
3119
|
+
}
|
3120
|
+
}
|
3121
|
+
|
3122
|
+
var source = mapping.source;
|
3123
|
+
if (source && !newSources.has(source)) {
|
3124
|
+
newSources.add(source);
|
3125
|
+
}
|
3126
|
+
|
3127
|
+
var name = mapping.name;
|
3128
|
+
if (name && !newNames.has(name)) {
|
3129
|
+
newNames.add(name);
|
3130
|
+
}
|
3131
|
+
|
3132
|
+
}, this);
|
3133
|
+
this._sources = newSources;
|
3134
|
+
this._names = newNames;
|
3135
|
+
|
3136
|
+
// Copy sourcesContents of applied map.
|
3137
|
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
3138
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
3139
|
+
if (content) {
|
3140
|
+
if (sourceRoot) {
|
3141
|
+
sourceFile = util.relative(sourceRoot, sourceFile);
|
3142
|
+
}
|
3143
|
+
this.setSourceContent(sourceFile, content);
|
3144
|
+
}
|
3145
|
+
}, this);
|
3146
|
+
};
|
3147
|
+
|
3148
|
+
/**
|
3149
|
+
* A mapping can have one of the three levels of data:
|
3150
|
+
*
|
3151
|
+
* 1. Just the generated position.
|
3152
|
+
* 2. The Generated position, original position, and original source.
|
3153
|
+
* 3. Generated and original position, original source, as well as a name
|
3154
|
+
* token.
|
3155
|
+
*
|
3156
|
+
* To maintain consistency, we validate that any new mapping being added falls
|
3157
|
+
* in to one of these categories.
|
3158
|
+
*/
|
3159
|
+
SourceMapGenerator.prototype._validateMapping =
|
3160
|
+
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
3161
|
+
aName) {
|
3162
|
+
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
3163
|
+
&& aGenerated.line > 0 && aGenerated.column >= 0
|
3164
|
+
&& !aOriginal && !aSource && !aName) {
|
3165
|
+
// Case 1.
|
3166
|
+
return;
|
3167
|
+
}
|
3168
|
+
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
3169
|
+
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
3170
|
+
&& aGenerated.line > 0 && aGenerated.column >= 0
|
3171
|
+
&& aOriginal.line > 0 && aOriginal.column >= 0
|
3172
|
+
&& aSource) {
|
3173
|
+
// Cases 2 and 3.
|
3174
|
+
return;
|
3175
|
+
}
|
3176
|
+
else {
|
3177
|
+
throw new Error('Invalid mapping: ' + JSON.stringify({
|
3178
|
+
generated: aGenerated,
|
3179
|
+
source: aSource,
|
3180
|
+
original: aOriginal,
|
3181
|
+
name: aName
|
3182
|
+
}));
|
3183
|
+
}
|
3184
|
+
};
|
3185
|
+
|
3186
|
+
/**
|
3187
|
+
* Serialize the accumulated mappings in to the stream of base 64 VLQs
|
3188
|
+
* specified by the source map format.
|
3189
|
+
*/
|
3190
|
+
SourceMapGenerator.prototype._serializeMappings =
|
3191
|
+
function SourceMapGenerator_serializeMappings() {
|
3192
|
+
var previousGeneratedColumn = 0;
|
3193
|
+
var previousGeneratedLine = 1;
|
3194
|
+
var previousOriginalColumn = 0;
|
3195
|
+
var previousOriginalLine = 0;
|
3196
|
+
var previousName = 0;
|
3197
|
+
var previousSource = 0;
|
3198
|
+
var result = '';
|
3199
|
+
var mapping;
|
3200
|
+
|
3201
|
+
// The mappings must be guaranteed to be in sorted order before we start
|
3202
|
+
// serializing them or else the generated line numbers (which are defined
|
3203
|
+
// via the ';' separators) will be all messed up. Note: it might be more
|
3204
|
+
// performant to maintain the sorting as we insert them, rather than as we
|
3205
|
+
// serialize them, but the big O is the same either way.
|
3206
|
+
this._mappings.sort(util.compareByGeneratedPositions);
|
3207
|
+
|
3208
|
+
for (var i = 0, len = this._mappings.length; i < len; i++) {
|
3209
|
+
mapping = this._mappings[i];
|
3210
|
+
|
3211
|
+
if (mapping.generatedLine !== previousGeneratedLine) {
|
3212
|
+
previousGeneratedColumn = 0;
|
3213
|
+
while (mapping.generatedLine !== previousGeneratedLine) {
|
3214
|
+
result += ';';
|
3215
|
+
previousGeneratedLine++;
|
3216
|
+
}
|
3217
|
+
}
|
3218
|
+
else {
|
3219
|
+
if (i > 0) {
|
3220
|
+
if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) {
|
3221
|
+
continue;
|
3222
|
+
}
|
3223
|
+
result += ',';
|
3224
|
+
}
|
3225
|
+
}
|
3226
|
+
|
3227
|
+
result += base64VLQ.encode(mapping.generatedColumn
|
3228
|
+
- previousGeneratedColumn);
|
3229
|
+
previousGeneratedColumn = mapping.generatedColumn;
|
3230
|
+
|
3231
|
+
if (mapping.source) {
|
3232
|
+
result += base64VLQ.encode(this._sources.indexOf(mapping.source)
|
3233
|
+
- previousSource);
|
3234
|
+
previousSource = this._sources.indexOf(mapping.source);
|
3235
|
+
|
3236
|
+
// lines are stored 0-based in SourceMap spec version 3
|
3237
|
+
result += base64VLQ.encode(mapping.originalLine - 1
|
3238
|
+
- previousOriginalLine);
|
3239
|
+
previousOriginalLine = mapping.originalLine - 1;
|
3240
|
+
|
3241
|
+
result += base64VLQ.encode(mapping.originalColumn
|
3242
|
+
- previousOriginalColumn);
|
3243
|
+
previousOriginalColumn = mapping.originalColumn;
|
3244
|
+
|
3245
|
+
if (mapping.name) {
|
3246
|
+
result += base64VLQ.encode(this._names.indexOf(mapping.name)
|
3247
|
+
- previousName);
|
3248
|
+
previousName = this._names.indexOf(mapping.name);
|
3249
|
+
}
|
3250
|
+
}
|
3251
|
+
}
|
3252
|
+
|
3253
|
+
return result;
|
3254
|
+
};
|
3255
|
+
|
3256
|
+
SourceMapGenerator.prototype._generateSourcesContent =
|
3257
|
+
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
3258
|
+
return aSources.map(function (source) {
|
3259
|
+
if (!this._sourcesContents) {
|
3260
|
+
return null;
|
3261
|
+
}
|
3262
|
+
if (aSourceRoot) {
|
3263
|
+
source = util.relative(aSourceRoot, source);
|
3264
|
+
}
|
3265
|
+
var key = util.toSetString(source);
|
3266
|
+
return Object.prototype.hasOwnProperty.call(this._sourcesContents,
|
3267
|
+
key)
|
3268
|
+
? this._sourcesContents[key]
|
3269
|
+
: null;
|
3270
|
+
}, this);
|
3271
|
+
};
|
3272
|
+
|
3273
|
+
/**
|
3274
|
+
* Externalize the source map.
|
3275
|
+
*/
|
3276
|
+
SourceMapGenerator.prototype.toJSON =
|
3277
|
+
function SourceMapGenerator_toJSON() {
|
3278
|
+
var map = {
|
3279
|
+
version: this._version,
|
3280
|
+
file: this._file,
|
3281
|
+
sources: this._sources.toArray(),
|
3282
|
+
names: this._names.toArray(),
|
3283
|
+
mappings: this._serializeMappings()
|
3284
|
+
};
|
3285
|
+
if (this._sourceRoot) {
|
3286
|
+
map.sourceRoot = this._sourceRoot;
|
3287
|
+
}
|
3288
|
+
if (this._sourcesContents) {
|
3289
|
+
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
3290
|
+
}
|
3291
|
+
|
3292
|
+
return map;
|
3293
|
+
};
|
3294
|
+
|
3295
|
+
/**
|
3296
|
+
* Render the source map being generated to a string.
|
3297
|
+
*/
|
3298
|
+
SourceMapGenerator.prototype.toString =
|
3299
|
+
function SourceMapGenerator_toString() {
|
3300
|
+
return JSON.stringify(this);
|
3301
|
+
};
|
3302
|
+
|
3303
|
+
exports.SourceMapGenerator = SourceMapGenerator;
|
3304
|
+
|
3305
|
+
});
|
3306
|
+
|
3307
|
+
},{"./array-set":21,"./base64-vlq":22,"./util":28,"amdefine":29}],27:[function(require,module,exports){
|
3308
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
3309
|
+
/*
|
3310
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
3311
|
+
* Licensed under the New BSD license. See LICENSE or:
|
3312
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
3313
|
+
*/
|
3314
|
+
if (typeof define !== 'function') {
|
3315
|
+
var define = require('amdefine')(module, require);
|
3316
|
+
}
|
3317
|
+
define(function (require, exports, module) {
|
3318
|
+
|
3319
|
+
var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
|
3320
|
+
var util = require('./util');
|
3321
|
+
|
3322
|
+
/**
|
3323
|
+
* SourceNodes provide a way to abstract over interpolating/concatenating
|
3324
|
+
* snippets of generated JavaScript source code while maintaining the line and
|
3325
|
+
* column information associated with the original source code.
|
3326
|
+
*
|
3327
|
+
* @param aLine The original line number.
|
3328
|
+
* @param aColumn The original column number.
|
3329
|
+
* @param aSource The original source's filename.
|
3330
|
+
* @param aChunks Optional. An array of strings which are snippets of
|
3331
|
+
* generated JS, or other SourceNodes.
|
3332
|
+
* @param aName The original identifier.
|
3333
|
+
*/
|
3334
|
+
function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
3335
|
+
this.children = [];
|
3336
|
+
this.sourceContents = {};
|
3337
|
+
this.line = aLine === undefined ? null : aLine;
|
3338
|
+
this.column = aColumn === undefined ? null : aColumn;
|
3339
|
+
this.source = aSource === undefined ? null : aSource;
|
3340
|
+
this.name = aName === undefined ? null : aName;
|
3341
|
+
if (aChunks != null) this.add(aChunks);
|
3342
|
+
}
|
3343
|
+
|
3344
|
+
/**
|
3345
|
+
* Creates a SourceNode from generated code and a SourceMapConsumer.
|
3346
|
+
*
|
3347
|
+
* @param aGeneratedCode The generated code
|
3348
|
+
* @param aSourceMapConsumer The SourceMap for the generated code
|
3349
|
+
*/
|
3350
|
+
SourceNode.fromStringWithSourceMap =
|
3351
|
+
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer) {
|
3352
|
+
// The SourceNode we want to fill with the generated code
|
3353
|
+
// and the SourceMap
|
3354
|
+
var node = new SourceNode();
|
3355
|
+
|
3356
|
+
// The generated code
|
3357
|
+
// Processed fragments are removed from this array.
|
3358
|
+
var remainingLines = aGeneratedCode.split('\n');
|
3359
|
+
|
3360
|
+
// We need to remember the position of "remainingLines"
|
3361
|
+
var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
3362
|
+
|
3363
|
+
// The generate SourceNodes we need a code range.
|
3364
|
+
// To extract it current and last mapping is used.
|
3365
|
+
// Here we store the last mapping.
|
3366
|
+
var lastMapping = null;
|
3367
|
+
|
3368
|
+
aSourceMapConsumer.eachMapping(function (mapping) {
|
3369
|
+
if (lastMapping !== null) {
|
3370
|
+
// We add the code from "lastMapping" to "mapping":
|
3371
|
+
// First check if there is a new line in between.
|
3372
|
+
if (lastGeneratedLine < mapping.generatedLine) {
|
3373
|
+
var code = "";
|
3374
|
+
// Associate first line with "lastMapping"
|
3375
|
+
addMappingWithCode(lastMapping, remainingLines.shift() + "\n");
|
3376
|
+
lastGeneratedLine++;
|
3377
|
+
lastGeneratedColumn = 0;
|
3378
|
+
// The remaining code is added without mapping
|
3379
|
+
} else {
|
3380
|
+
// There is no new line in between.
|
3381
|
+
// Associate the code between "lastGeneratedColumn" and
|
3382
|
+
// "mapping.generatedColumn" with "lastMapping"
|
3383
|
+
var nextLine = remainingLines[0];
|
3384
|
+
var code = nextLine.substr(0, mapping.generatedColumn -
|
3385
|
+
lastGeneratedColumn);
|
3386
|
+
remainingLines[0] = nextLine.substr(mapping.generatedColumn -
|
3387
|
+
lastGeneratedColumn);
|
3388
|
+
lastGeneratedColumn = mapping.generatedColumn;
|
3389
|
+
addMappingWithCode(lastMapping, code);
|
3390
|
+
// No more remaining code, continue
|
3391
|
+
lastMapping = mapping;
|
3392
|
+
return;
|
3393
|
+
}
|
3394
|
+
}
|
3395
|
+
// We add the generated code until the first mapping
|
3396
|
+
// to the SourceNode without any mapping.
|
3397
|
+
// Each line is added as separate string.
|
3398
|
+
while (lastGeneratedLine < mapping.generatedLine) {
|
3399
|
+
node.add(remainingLines.shift() + "\n");
|
3400
|
+
lastGeneratedLine++;
|
3401
|
+
}
|
3402
|
+
if (lastGeneratedColumn < mapping.generatedColumn) {
|
3403
|
+
var nextLine = remainingLines[0];
|
3404
|
+
node.add(nextLine.substr(0, mapping.generatedColumn));
|
3405
|
+
remainingLines[0] = nextLine.substr(mapping.generatedColumn);
|
3406
|
+
lastGeneratedColumn = mapping.generatedColumn;
|
3407
|
+
}
|
3408
|
+
lastMapping = mapping;
|
3409
|
+
}, this);
|
3410
|
+
// We have processed all mappings.
|
3411
|
+
if (remainingLines.length > 0) {
|
3412
|
+
if (lastMapping) {
|
3413
|
+
// Associate the remaining code in the current line with "lastMapping"
|
3414
|
+
var lastLine = remainingLines.shift();
|
3415
|
+
if (remainingLines.length > 0) lastLine += "\n";
|
3416
|
+
addMappingWithCode(lastMapping, lastLine);
|
3417
|
+
}
|
3418
|
+
// and add the remaining lines without any mapping
|
3419
|
+
node.add(remainingLines.join("\n"));
|
3420
|
+
}
|
3421
|
+
|
3422
|
+
// Copy sourcesContent into SourceNode
|
3423
|
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
3424
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
3425
|
+
if (content) {
|
3426
|
+
node.setSourceContent(sourceFile, content);
|
3427
|
+
}
|
3428
|
+
});
|
3429
|
+
|
3430
|
+
return node;
|
3431
|
+
|
3432
|
+
function addMappingWithCode(mapping, code) {
|
3433
|
+
if (mapping === null || mapping.source === undefined) {
|
3434
|
+
node.add(code);
|
3435
|
+
} else {
|
3436
|
+
node.add(new SourceNode(mapping.originalLine,
|
3437
|
+
mapping.originalColumn,
|
3438
|
+
mapping.source,
|
3439
|
+
code,
|
3440
|
+
mapping.name));
|
3441
|
+
}
|
3442
|
+
}
|
3443
|
+
};
|
3444
|
+
|
3445
|
+
/**
|
3446
|
+
* Add a chunk of generated JS to this source node.
|
3447
|
+
*
|
3448
|
+
* @param aChunk A string snippet of generated JS code, another instance of
|
3449
|
+
* SourceNode, or an array where each member is one of those things.
|
3450
|
+
*/
|
3451
|
+
SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
3452
|
+
if (Array.isArray(aChunk)) {
|
3453
|
+
aChunk.forEach(function (chunk) {
|
3454
|
+
this.add(chunk);
|
3455
|
+
}, this);
|
3456
|
+
}
|
3457
|
+
else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
|
3458
|
+
if (aChunk) {
|
3459
|
+
this.children.push(aChunk);
|
3460
|
+
}
|
3461
|
+
}
|
3462
|
+
else {
|
3463
|
+
throw new TypeError(
|
3464
|
+
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
3465
|
+
);
|
3466
|
+
}
|
3467
|
+
return this;
|
3468
|
+
};
|
3469
|
+
|
3470
|
+
/**
|
3471
|
+
* Add a chunk of generated JS to the beginning of this source node.
|
3472
|
+
*
|
3473
|
+
* @param aChunk A string snippet of generated JS code, another instance of
|
3474
|
+
* SourceNode, or an array where each member is one of those things.
|
3475
|
+
*/
|
3476
|
+
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
3477
|
+
if (Array.isArray(aChunk)) {
|
3478
|
+
for (var i = aChunk.length-1; i >= 0; i--) {
|
3479
|
+
this.prepend(aChunk[i]);
|
3480
|
+
}
|
3481
|
+
}
|
3482
|
+
else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
|
3483
|
+
this.children.unshift(aChunk);
|
3484
|
+
}
|
3485
|
+
else {
|
3486
|
+
throw new TypeError(
|
3487
|
+
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
3488
|
+
);
|
3489
|
+
}
|
3490
|
+
return this;
|
3491
|
+
};
|
3492
|
+
|
3493
|
+
/**
|
3494
|
+
* Walk over the tree of JS snippets in this node and its children. The
|
3495
|
+
* walking function is called once for each snippet of JS and is passed that
|
3496
|
+
* snippet and the its original associated source's line/column location.
|
3497
|
+
*
|
3498
|
+
* @param aFn The traversal function.
|
3499
|
+
*/
|
3500
|
+
SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
3501
|
+
var chunk;
|
3502
|
+
for (var i = 0, len = this.children.length; i < len; i++) {
|
3503
|
+
chunk = this.children[i];
|
3504
|
+
if (chunk instanceof SourceNode) {
|
3505
|
+
chunk.walk(aFn);
|
3506
|
+
}
|
3507
|
+
else {
|
3508
|
+
if (chunk !== '') {
|
3509
|
+
aFn(chunk, { source: this.source,
|
3510
|
+
line: this.line,
|
3511
|
+
column: this.column,
|
3512
|
+
name: this.name });
|
3513
|
+
}
|
3514
|
+
}
|
3515
|
+
}
|
3516
|
+
};
|
3517
|
+
|
3518
|
+
/**
|
3519
|
+
* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
|
3520
|
+
* each of `this.children`.
|
3521
|
+
*
|
3522
|
+
* @param aSep The separator.
|
3523
|
+
*/
|
3524
|
+
SourceNode.prototype.join = function SourceNode_join(aSep) {
|
3525
|
+
var newChildren;
|
3526
|
+
var i;
|
3527
|
+
var len = this.children.length;
|
3528
|
+
if (len > 0) {
|
3529
|
+
newChildren = [];
|
3530
|
+
for (i = 0; i < len-1; i++) {
|
3531
|
+
newChildren.push(this.children[i]);
|
3532
|
+
newChildren.push(aSep);
|
3533
|
+
}
|
3534
|
+
newChildren.push(this.children[i]);
|
3535
|
+
this.children = newChildren;
|
3536
|
+
}
|
3537
|
+
return this;
|
3538
|
+
};
|
3539
|
+
|
3540
|
+
/**
|
3541
|
+
* Call String.prototype.replace on the very right-most source snippet. Useful
|
3542
|
+
* for trimming whitespace from the end of a source node, etc.
|
3543
|
+
*
|
3544
|
+
* @param aPattern The pattern to replace.
|
3545
|
+
* @param aReplacement The thing to replace the pattern with.
|
3546
|
+
*/
|
3547
|
+
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
3548
|
+
var lastChild = this.children[this.children.length - 1];
|
3549
|
+
if (lastChild instanceof SourceNode) {
|
3550
|
+
lastChild.replaceRight(aPattern, aReplacement);
|
3551
|
+
}
|
3552
|
+
else if (typeof lastChild === 'string') {
|
3553
|
+
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
3554
|
+
}
|
3555
|
+
else {
|
3556
|
+
this.children.push(''.replace(aPattern, aReplacement));
|
3557
|
+
}
|
3558
|
+
return this;
|
3559
|
+
};
|
3560
|
+
|
3561
|
+
/**
|
3562
|
+
* Set the source content for a source file. This will be added to the SourceMapGenerator
|
3563
|
+
* in the sourcesContent field.
|
3564
|
+
*
|
3565
|
+
* @param aSourceFile The filename of the source file
|
3566
|
+
* @param aSourceContent The content of the source file
|
3567
|
+
*/
|
3568
|
+
SourceNode.prototype.setSourceContent =
|
3569
|
+
function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
3570
|
+
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
3571
|
+
};
|
3572
|
+
|
3573
|
+
/**
|
3574
|
+
* Walk over the tree of SourceNodes. The walking function is called for each
|
3575
|
+
* source file content and is passed the filename and source content.
|
3576
|
+
*
|
3577
|
+
* @param aFn The traversal function.
|
3578
|
+
*/
|
3579
|
+
SourceNode.prototype.walkSourceContents =
|
3580
|
+
function SourceNode_walkSourceContents(aFn) {
|
3581
|
+
for (var i = 0, len = this.children.length; i < len; i++) {
|
3582
|
+
if (this.children[i] instanceof SourceNode) {
|
3583
|
+
this.children[i].walkSourceContents(aFn);
|
3584
|
+
}
|
3585
|
+
}
|
3586
|
+
|
3587
|
+
var sources = Object.keys(this.sourceContents);
|
3588
|
+
for (var i = 0, len = sources.length; i < len; i++) {
|
3589
|
+
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
3590
|
+
}
|
3591
|
+
};
|
3592
|
+
|
3593
|
+
/**
|
3594
|
+
* Return the string representation of this source node. Walks over the tree
|
3595
|
+
* and concatenates all the various snippets together to one string.
|
3596
|
+
*/
|
3597
|
+
SourceNode.prototype.toString = function SourceNode_toString() {
|
3598
|
+
var str = "";
|
3599
|
+
this.walk(function (chunk) {
|
3600
|
+
str += chunk;
|
3601
|
+
});
|
3602
|
+
return str;
|
3603
|
+
};
|
3604
|
+
|
3605
|
+
/**
|
3606
|
+
* Returns the string representation of this source node along with a source
|
3607
|
+
* map.
|
3608
|
+
*/
|
3609
|
+
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
3610
|
+
var generated = {
|
3611
|
+
code: "",
|
3612
|
+
line: 1,
|
3613
|
+
column: 0
|
3614
|
+
};
|
3615
|
+
var map = new SourceMapGenerator(aArgs);
|
3616
|
+
var sourceMappingActive = false;
|
3617
|
+
var lastOriginalSource = null;
|
3618
|
+
var lastOriginalLine = null;
|
3619
|
+
var lastOriginalColumn = null;
|
3620
|
+
var lastOriginalName = null;
|
3621
|
+
this.walk(function (chunk, original) {
|
3622
|
+
generated.code += chunk;
|
3623
|
+
if (original.source !== null
|
3624
|
+
&& original.line !== null
|
3625
|
+
&& original.column !== null) {
|
3626
|
+
if(lastOriginalSource !== original.source
|
3627
|
+
|| lastOriginalLine !== original.line
|
3628
|
+
|| lastOriginalColumn !== original.column
|
3629
|
+
|| lastOriginalName !== original.name) {
|
3630
|
+
map.addMapping({
|
3631
|
+
source: original.source,
|
3632
|
+
original: {
|
3633
|
+
line: original.line,
|
3634
|
+
column: original.column
|
3635
|
+
},
|
3636
|
+
generated: {
|
3637
|
+
line: generated.line,
|
3638
|
+
column: generated.column
|
3639
|
+
},
|
3640
|
+
name: original.name
|
3641
|
+
});
|
3642
|
+
}
|
3643
|
+
lastOriginalSource = original.source;
|
3644
|
+
lastOriginalLine = original.line;
|
3645
|
+
lastOriginalColumn = original.column;
|
3646
|
+
lastOriginalName = original.name;
|
3647
|
+
sourceMappingActive = true;
|
3648
|
+
} else if (sourceMappingActive) {
|
3649
|
+
map.addMapping({
|
3650
|
+
generated: {
|
3651
|
+
line: generated.line,
|
3652
|
+
column: generated.column
|
3653
|
+
}
|
3654
|
+
});
|
3655
|
+
lastOriginalSource = null;
|
3656
|
+
sourceMappingActive = false;
|
3657
|
+
}
|
3658
|
+
chunk.split('').forEach(function (ch, idx, array) {
|
3659
|
+
if (ch === '\n') {
|
3660
|
+
generated.line++;
|
3661
|
+
generated.column = 0;
|
3662
|
+
// Mappings end at eol
|
3663
|
+
if (idx + 1 === array.length) {
|
3664
|
+
lastOriginalSource = null;
|
3665
|
+
sourceMappingActive = false;
|
3666
|
+
} else if (sourceMappingActive) {
|
3667
|
+
map.addMapping({
|
3668
|
+
source: original.source,
|
3669
|
+
original: {
|
3670
|
+
line: original.line,
|
3671
|
+
column: original.column
|
3672
|
+
},
|
3673
|
+
generated: {
|
3674
|
+
line: generated.line,
|
3675
|
+
column: generated.column
|
3676
|
+
},
|
3677
|
+
name: original.name
|
3678
|
+
});
|
3679
|
+
}
|
3680
|
+
} else {
|
3681
|
+
generated.column++;
|
3682
|
+
}
|
3683
|
+
});
|
3684
|
+
});
|
3685
|
+
this.walkSourceContents(function (sourceFile, sourceContent) {
|
3686
|
+
map.setSourceContent(sourceFile, sourceContent);
|
3687
|
+
});
|
3688
|
+
|
3689
|
+
return { code: generated.code, map: map };
|
3690
|
+
};
|
3691
|
+
|
3692
|
+
exports.SourceNode = SourceNode;
|
3693
|
+
|
3694
|
+
});
|
3695
|
+
|
3696
|
+
},{"./source-map-generator":26,"./util":28,"amdefine":29}],28:[function(require,module,exports){
|
3697
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
3698
|
+
/*
|
3699
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
3700
|
+
* Licensed under the New BSD license. See LICENSE or:
|
3701
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
3702
|
+
*/
|
3703
|
+
if (typeof define !== 'function') {
|
3704
|
+
var define = require('amdefine')(module, require);
|
3705
|
+
}
|
3706
|
+
define(function (require, exports, module) {
|
3707
|
+
|
3708
|
+
/**
|
3709
|
+
* This is a helper function for getting values from parameter/options
|
3710
|
+
* objects.
|
3711
|
+
*
|
3712
|
+
* @param args The object we are extracting values from
|
3713
|
+
* @param name The name of the property we are getting.
|
3714
|
+
* @param defaultValue An optional value to return if the property is missing
|
3715
|
+
* from the object. If this is not specified and the property is missing, an
|
3716
|
+
* error will be thrown.
|
3717
|
+
*/
|
3718
|
+
function getArg(aArgs, aName, aDefaultValue) {
|
3719
|
+
if (aName in aArgs) {
|
3720
|
+
return aArgs[aName];
|
3721
|
+
} else if (arguments.length === 3) {
|
3722
|
+
return aDefaultValue;
|
3723
|
+
} else {
|
3724
|
+
throw new Error('"' + aName + '" is a required argument.');
|
3725
|
+
}
|
3726
|
+
}
|
3727
|
+
exports.getArg = getArg;
|
3728
|
+
|
3729
|
+
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
|
3730
|
+
var dataUrlRegexp = /^data:.+\,.+$/;
|
3731
|
+
|
3732
|
+
function urlParse(aUrl) {
|
3733
|
+
var match = aUrl.match(urlRegexp);
|
3734
|
+
if (!match) {
|
3735
|
+
return null;
|
3736
|
+
}
|
3737
|
+
return {
|
3738
|
+
scheme: match[1],
|
3739
|
+
auth: match[2],
|
3740
|
+
host: match[3],
|
3741
|
+
port: match[4],
|
3742
|
+
path: match[5]
|
3743
|
+
};
|
3744
|
+
}
|
3745
|
+
exports.urlParse = urlParse;
|
3746
|
+
|
3747
|
+
function urlGenerate(aParsedUrl) {
|
3748
|
+
var url = '';
|
3749
|
+
if (aParsedUrl.scheme) {
|
3750
|
+
url += aParsedUrl.scheme + ':';
|
3751
|
+
}
|
3752
|
+
url += '//';
|
3753
|
+
if (aParsedUrl.auth) {
|
3754
|
+
url += aParsedUrl.auth + '@';
|
3755
|
+
}
|
3756
|
+
if (aParsedUrl.host) {
|
3757
|
+
url += aParsedUrl.host;
|
3758
|
+
}
|
3759
|
+
if (aParsedUrl.port) {
|
3760
|
+
url += ":" + aParsedUrl.port
|
3761
|
+
}
|
3762
|
+
if (aParsedUrl.path) {
|
3763
|
+
url += aParsedUrl.path;
|
3764
|
+
}
|
3765
|
+
return url;
|
3766
|
+
}
|
3767
|
+
exports.urlGenerate = urlGenerate;
|
3768
|
+
|
3769
|
+
/**
|
3770
|
+
* Normalizes a path, or the path portion of a URL:
|
3771
|
+
*
|
3772
|
+
* - Replaces consequtive slashes with one slash.
|
3773
|
+
* - Removes unnecessary '.' parts.
|
3774
|
+
* - Removes unnecessary '<dir>/..' parts.
|
3775
|
+
*
|
3776
|
+
* Based on code in the Node.js 'path' core module.
|
3777
|
+
*
|
3778
|
+
* @param aPath The path or url to normalize.
|
3779
|
+
*/
|
3780
|
+
function normalize(aPath) {
|
3781
|
+
var path = aPath;
|
3782
|
+
var url = urlParse(aPath);
|
3783
|
+
if (url) {
|
3784
|
+
if (!url.path) {
|
3785
|
+
return aPath;
|
3786
|
+
}
|
3787
|
+
path = url.path;
|
3788
|
+
}
|
3789
|
+
var isAbsolute = (path.charAt(0) === '/');
|
3790
|
+
|
3791
|
+
var parts = path.split(/\/+/);
|
3792
|
+
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
3793
|
+
part = parts[i];
|
3794
|
+
if (part === '.') {
|
3795
|
+
parts.splice(i, 1);
|
3796
|
+
} else if (part === '..') {
|
3797
|
+
up++;
|
3798
|
+
} else if (up > 0) {
|
3799
|
+
if (part === '') {
|
3800
|
+
// The first part is blank if the path is absolute. Trying to go
|
3801
|
+
// above the root is a no-op. Therefore we can remove all '..' parts
|
3802
|
+
// directly after the root.
|
3803
|
+
parts.splice(i + 1, up);
|
3804
|
+
up = 0;
|
3805
|
+
} else {
|
3806
|
+
parts.splice(i, 2);
|
3807
|
+
up--;
|
3808
|
+
}
|
3809
|
+
}
|
3810
|
+
}
|
3811
|
+
path = parts.join('/');
|
3812
|
+
|
3813
|
+
if (path === '') {
|
3814
|
+
path = isAbsolute ? '/' : '.';
|
3815
|
+
}
|
3816
|
+
|
3817
|
+
if (url) {
|
3818
|
+
url.path = path;
|
3819
|
+
return urlGenerate(url);
|
3820
|
+
}
|
3821
|
+
return path;
|
3822
|
+
}
|
3823
|
+
exports.normalize = normalize;
|
3824
|
+
|
3825
|
+
/**
|
3826
|
+
* Joins two paths/URLs.
|
3827
|
+
*
|
3828
|
+
* @param aRoot The root path or URL.
|
3829
|
+
* @param aPath The path or URL to be joined with the root.
|
3830
|
+
*
|
3831
|
+
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
|
3832
|
+
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended
|
3833
|
+
* first.
|
3834
|
+
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion
|
3835
|
+
* is updated with the result and aRoot is returned. Otherwise the result
|
3836
|
+
* is returned.
|
3837
|
+
* - If aPath is absolute, the result is aPath.
|
3838
|
+
* - Otherwise the two paths are joined with a slash.
|
3839
|
+
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
3840
|
+
*/
|
3841
|
+
function join(aRoot, aPath) {
|
3842
|
+
var aPathUrl = urlParse(aPath);
|
3843
|
+
var aRootUrl = urlParse(aRoot);
|
3844
|
+
if (aRootUrl) {
|
3845
|
+
aRoot = aRootUrl.path || '/';
|
3846
|
+
}
|
3847
|
+
|
3848
|
+
// `join(foo, '//www.example.org')`
|
3849
|
+
if (aPathUrl && !aPathUrl.scheme) {
|
3850
|
+
if (aRootUrl) {
|
3851
|
+
aPathUrl.scheme = aRootUrl.scheme;
|
3852
|
+
}
|
3853
|
+
return urlGenerate(aPathUrl);
|
3854
|
+
}
|
3855
|
+
|
3856
|
+
if (aPathUrl || aPath.match(dataUrlRegexp)) {
|
3857
|
+
return aPath;
|
3858
|
+
}
|
3859
|
+
|
3860
|
+
// `join('http://', 'www.example.com')`
|
3861
|
+
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
|
3862
|
+
aRootUrl.host = aPath;
|
3863
|
+
return urlGenerate(aRootUrl);
|
3864
|
+
}
|
3865
|
+
|
3866
|
+
var joined = aPath.charAt(0) === '/'
|
3867
|
+
? aPath
|
3868
|
+
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
|
3869
|
+
|
3870
|
+
if (aRootUrl) {
|
3871
|
+
aRootUrl.path = joined;
|
3872
|
+
return urlGenerate(aRootUrl);
|
3873
|
+
}
|
3874
|
+
return joined;
|
3875
|
+
}
|
3876
|
+
exports.join = join;
|
3877
|
+
|
3878
|
+
/**
|
3879
|
+
* Because behavior goes wacky when you set `__proto__` on objects, we
|
3880
|
+
* have to prefix all the strings in our set with an arbitrary character.
|
3881
|
+
*
|
3882
|
+
* See https://github.com/mozilla/source-map/pull/31 and
|
3883
|
+
* https://github.com/mozilla/source-map/issues/30
|
3884
|
+
*
|
3885
|
+
* @param String aStr
|
3886
|
+
*/
|
3887
|
+
function toSetString(aStr) {
|
3888
|
+
return '$' + aStr;
|
3889
|
+
}
|
3890
|
+
exports.toSetString = toSetString;
|
3891
|
+
|
3892
|
+
function fromSetString(aStr) {
|
3893
|
+
return aStr.substr(1);
|
3894
|
+
}
|
3895
|
+
exports.fromSetString = fromSetString;
|
3896
|
+
|
3897
|
+
function relative(aRoot, aPath) {
|
3898
|
+
aRoot = aRoot.replace(/\/$/, '');
|
3899
|
+
|
3900
|
+
var url = urlParse(aRoot);
|
3901
|
+
if (aPath.charAt(0) == "/" && url && url.path == "/") {
|
3902
|
+
return aPath.slice(1);
|
3903
|
+
}
|
3904
|
+
|
3905
|
+
return aPath.indexOf(aRoot + '/') === 0
|
3906
|
+
? aPath.substr(aRoot.length + 1)
|
3907
|
+
: aPath;
|
3908
|
+
}
|
3909
|
+
exports.relative = relative;
|
3910
|
+
|
3911
|
+
function strcmp(aStr1, aStr2) {
|
3912
|
+
var s1 = aStr1 || "";
|
3913
|
+
var s2 = aStr2 || "";
|
3914
|
+
return (s1 > s2) - (s1 < s2);
|
3915
|
+
}
|
3916
|
+
|
3917
|
+
/**
|
3918
|
+
* Comparator between two mappings where the original positions are compared.
|
3919
|
+
*
|
3920
|
+
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
3921
|
+
* mappings with the same original source/line/column, but different generated
|
3922
|
+
* line and column the same. Useful when searching for a mapping with a
|
3923
|
+
* stubbed out mapping.
|
3924
|
+
*/
|
3925
|
+
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
3926
|
+
var cmp;
|
3927
|
+
|
3928
|
+
cmp = strcmp(mappingA.source, mappingB.source);
|
3929
|
+
if (cmp) {
|
3930
|
+
return cmp;
|
3931
|
+
}
|
3932
|
+
|
3933
|
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
3934
|
+
if (cmp) {
|
3935
|
+
return cmp;
|
3936
|
+
}
|
3937
|
+
|
3938
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
3939
|
+
if (cmp || onlyCompareOriginal) {
|
3940
|
+
return cmp;
|
3941
|
+
}
|
3942
|
+
|
3943
|
+
cmp = strcmp(mappingA.name, mappingB.name);
|
3944
|
+
if (cmp) {
|
3945
|
+
return cmp;
|
3946
|
+
}
|
3947
|
+
|
3948
|
+
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
3949
|
+
if (cmp) {
|
3950
|
+
return cmp;
|
3951
|
+
}
|
3952
|
+
|
3953
|
+
return mappingA.generatedColumn - mappingB.generatedColumn;
|
3954
|
+
};
|
3955
|
+
exports.compareByOriginalPositions = compareByOriginalPositions;
|
3956
|
+
|
3957
|
+
/**
|
3958
|
+
* Comparator between two mappings where the generated positions are
|
3959
|
+
* compared.
|
3960
|
+
*
|
3961
|
+
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
3962
|
+
* mappings with the same generated line and column, but different
|
3963
|
+
* source/name/original line and column the same. Useful when searching for a
|
3964
|
+
* mapping with a stubbed out mapping.
|
3965
|
+
*/
|
3966
|
+
function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
|
3967
|
+
var cmp;
|
3968
|
+
|
3969
|
+
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
3970
|
+
if (cmp) {
|
3971
|
+
return cmp;
|
3972
|
+
}
|
3973
|
+
|
3974
|
+
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
3975
|
+
if (cmp || onlyCompareGenerated) {
|
3976
|
+
return cmp;
|
3977
|
+
}
|
3978
|
+
|
3979
|
+
cmp = strcmp(mappingA.source, mappingB.source);
|
3980
|
+
if (cmp) {
|
3981
|
+
return cmp;
|
3982
|
+
}
|
3983
|
+
|
3984
|
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
3985
|
+
if (cmp) {
|
3986
|
+
return cmp;
|
3987
|
+
}
|
3988
|
+
|
3989
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
3990
|
+
if (cmp) {
|
3991
|
+
return cmp;
|
3992
|
+
}
|
3993
|
+
|
3994
|
+
return strcmp(mappingA.name, mappingB.name);
|
3995
|
+
};
|
3996
|
+
exports.compareByGeneratedPositions = compareByGeneratedPositions;
|
3997
|
+
|
3998
|
+
});
|
3999
|
+
|
4000
|
+
},{"amdefine":29}],29:[function(require,module,exports){
|
4001
|
+
(function (process,__filename){
|
4002
|
+
/** vim: et:ts=4:sw=4:sts=4
|
4003
|
+
* @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
|
4004
|
+
* Available via the MIT or new BSD license.
|
4005
|
+
* see: http://github.com/jrburke/amdefine for details
|
4006
|
+
*/
|
4007
|
+
|
4008
|
+
/*jslint node: true */
|
4009
|
+
/*global module, process */
|
4010
|
+
'use strict';
|
4011
|
+
|
4012
|
+
/**
|
4013
|
+
* Creates a define for node.
|
4014
|
+
* @param {Object} module the "module" object that is defined by Node for the
|
4015
|
+
* current module.
|
4016
|
+
* @param {Function} [requireFn]. Node's require function for the current module.
|
4017
|
+
* It only needs to be passed in Node versions before 0.5, when module.require
|
4018
|
+
* did not exist.
|
4019
|
+
* @returns {Function} a define function that is usable for the current node
|
4020
|
+
* module.
|
4021
|
+
*/
|
4022
|
+
function amdefine(module, requireFn) {
|
4023
|
+
'use strict';
|
4024
|
+
var defineCache = {},
|
4025
|
+
loaderCache = {},
|
4026
|
+
alreadyCalled = false,
|
4027
|
+
path = require('path'),
|
4028
|
+
makeRequire, stringRequire;
|
4029
|
+
|
4030
|
+
/**
|
4031
|
+
* Trims the . and .. from an array of path segments.
|
4032
|
+
* It will keep a leading path segment if a .. will become
|
4033
|
+
* the first path segment, to help with module name lookups,
|
4034
|
+
* which act like paths, but can be remapped. But the end result,
|
4035
|
+
* all paths that use this function should look normalized.
|
4036
|
+
* NOTE: this method MODIFIES the input array.
|
4037
|
+
* @param {Array} ary the array of path segments.
|
4038
|
+
*/
|
4039
|
+
function trimDots(ary) {
|
4040
|
+
var i, part;
|
4041
|
+
for (i = 0; ary[i]; i+= 1) {
|
4042
|
+
part = ary[i];
|
4043
|
+
if (part === '.') {
|
4044
|
+
ary.splice(i, 1);
|
4045
|
+
i -= 1;
|
4046
|
+
} else if (part === '..') {
|
4047
|
+
if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
|
4048
|
+
//End of the line. Keep at least one non-dot
|
4049
|
+
//path segment at the front so it can be mapped
|
4050
|
+
//correctly to disk. Otherwise, there is likely
|
4051
|
+
//no path mapping for a path starting with '..'.
|
4052
|
+
//This can still fail, but catches the most reasonable
|
4053
|
+
//uses of ..
|
4054
|
+
break;
|
4055
|
+
} else if (i > 0) {
|
4056
|
+
ary.splice(i - 1, 2);
|
4057
|
+
i -= 2;
|
4058
|
+
}
|
4059
|
+
}
|
4060
|
+
}
|
4061
|
+
}
|
4062
|
+
|
4063
|
+
function normalize(name, baseName) {
|
4064
|
+
var baseParts;
|
4065
|
+
|
4066
|
+
//Adjust any relative paths.
|
4067
|
+
if (name && name.charAt(0) === '.') {
|
4068
|
+
//If have a base name, try to normalize against it,
|
4069
|
+
//otherwise, assume it is a top-level require that will
|
4070
|
+
//be relative to baseUrl in the end.
|
4071
|
+
if (baseName) {
|
4072
|
+
baseParts = baseName.split('/');
|
4073
|
+
baseParts = baseParts.slice(0, baseParts.length - 1);
|
4074
|
+
baseParts = baseParts.concat(name.split('/'));
|
4075
|
+
trimDots(baseParts);
|
4076
|
+
name = baseParts.join('/');
|
4077
|
+
}
|
4078
|
+
}
|
4079
|
+
|
4080
|
+
return name;
|
4081
|
+
}
|
4082
|
+
|
4083
|
+
/**
|
4084
|
+
* Create the normalize() function passed to a loader plugin's
|
4085
|
+
* normalize method.
|
4086
|
+
*/
|
4087
|
+
function makeNormalize(relName) {
|
4088
|
+
return function (name) {
|
4089
|
+
return normalize(name, relName);
|
4090
|
+
};
|
4091
|
+
}
|
4092
|
+
|
4093
|
+
function makeLoad(id) {
|
4094
|
+
function load(value) {
|
4095
|
+
loaderCache[id] = value;
|
4096
|
+
}
|
4097
|
+
|
4098
|
+
load.fromText = function (id, text) {
|
4099
|
+
//This one is difficult because the text can/probably uses
|
4100
|
+
//define, and any relative paths and requires should be relative
|
4101
|
+
//to that id was it would be found on disk. But this would require
|
4102
|
+
//bootstrapping a module/require fairly deeply from node core.
|
4103
|
+
//Not sure how best to go about that yet.
|
4104
|
+
throw new Error('amdefine does not implement load.fromText');
|
4105
|
+
};
|
4106
|
+
|
4107
|
+
return load;
|
4108
|
+
}
|
4109
|
+
|
4110
|
+
makeRequire = function (systemRequire, exports, module, relId) {
|
4111
|
+
function amdRequire(deps, callback) {
|
4112
|
+
if (typeof deps === 'string') {
|
4113
|
+
//Synchronous, single module require('')
|
4114
|
+
return stringRequire(systemRequire, exports, module, deps, relId);
|
4115
|
+
} else {
|
4116
|
+
//Array of dependencies with a callback.
|
4117
|
+
|
4118
|
+
//Convert the dependencies to modules.
|
4119
|
+
deps = deps.map(function (depName) {
|
4120
|
+
return stringRequire(systemRequire, exports, module, depName, relId);
|
4121
|
+
});
|
4122
|
+
|
4123
|
+
//Wait for next tick to call back the require call.
|
4124
|
+
process.nextTick(function () {
|
4125
|
+
callback.apply(null, deps);
|
4126
|
+
});
|
4127
|
+
}
|
4128
|
+
}
|
4129
|
+
|
4130
|
+
amdRequire.toUrl = function (filePath) {
|
4131
|
+
if (filePath.indexOf('.') === 0) {
|
4132
|
+
return normalize(filePath, path.dirname(module.filename));
|
4133
|
+
} else {
|
4134
|
+
return filePath;
|
4135
|
+
}
|
4136
|
+
};
|
4137
|
+
|
4138
|
+
return amdRequire;
|
4139
|
+
};
|
4140
|
+
|
4141
|
+
//Favor explicit value, passed in if the module wants to support Node 0.4.
|
4142
|
+
requireFn = requireFn || function req() {
|
4143
|
+
return module.require.apply(module, arguments);
|
4144
|
+
};
|
4145
|
+
|
4146
|
+
function runFactory(id, deps, factory) {
|
4147
|
+
var r, e, m, result;
|
4148
|
+
|
4149
|
+
if (id) {
|
4150
|
+
e = loaderCache[id] = {};
|
4151
|
+
m = {
|
4152
|
+
id: id,
|
4153
|
+
uri: __filename,
|
4154
|
+
exports: e
|
4155
|
+
};
|
4156
|
+
r = makeRequire(requireFn, e, m, id);
|
4157
|
+
} else {
|
4158
|
+
//Only support one define call per file
|
4159
|
+
if (alreadyCalled) {
|
4160
|
+
throw new Error('amdefine with no module ID cannot be called more than once per file.');
|
4161
|
+
}
|
4162
|
+
alreadyCalled = true;
|
4163
|
+
|
4164
|
+
//Use the real variables from node
|
4165
|
+
//Use module.exports for exports, since
|
4166
|
+
//the exports in here is amdefine exports.
|
4167
|
+
e = module.exports;
|
4168
|
+
m = module;
|
4169
|
+
r = makeRequire(requireFn, e, m, module.id);
|
4170
|
+
}
|
4171
|
+
|
4172
|
+
//If there are dependencies, they are strings, so need
|
4173
|
+
//to convert them to dependency values.
|
4174
|
+
if (deps) {
|
4175
|
+
deps = deps.map(function (depName) {
|
4176
|
+
return r(depName);
|
4177
|
+
});
|
4178
|
+
}
|
4179
|
+
|
4180
|
+
//Call the factory with the right dependencies.
|
4181
|
+
if (typeof factory === 'function') {
|
4182
|
+
result = factory.apply(m.exports, deps);
|
4183
|
+
} else {
|
4184
|
+
result = factory;
|
4185
|
+
}
|
4186
|
+
|
4187
|
+
if (result !== undefined) {
|
4188
|
+
m.exports = result;
|
4189
|
+
if (id) {
|
4190
|
+
loaderCache[id] = m.exports;
|
4191
|
+
}
|
4192
|
+
}
|
4193
|
+
}
|
4194
|
+
|
4195
|
+
stringRequire = function (systemRequire, exports, module, id, relId) {
|
4196
|
+
//Split the ID by a ! so that
|
4197
|
+
var index = id.indexOf('!'),
|
4198
|
+
originalId = id,
|
4199
|
+
prefix, plugin;
|
4200
|
+
|
4201
|
+
if (index === -1) {
|
4202
|
+
id = normalize(id, relId);
|
4203
|
+
|
4204
|
+
//Straight module lookup. If it is one of the special dependencies,
|
4205
|
+
//deal with it, otherwise, delegate to node.
|
4206
|
+
if (id === 'require') {
|
4207
|
+
return makeRequire(systemRequire, exports, module, relId);
|
4208
|
+
} else if (id === 'exports') {
|
4209
|
+
return exports;
|
4210
|
+
} else if (id === 'module') {
|
4211
|
+
return module;
|
4212
|
+
} else if (loaderCache.hasOwnProperty(id)) {
|
4213
|
+
return loaderCache[id];
|
4214
|
+
} else if (defineCache[id]) {
|
4215
|
+
runFactory.apply(null, defineCache[id]);
|
4216
|
+
return loaderCache[id];
|
4217
|
+
} else {
|
4218
|
+
if(systemRequire) {
|
4219
|
+
return systemRequire(originalId);
|
4220
|
+
} else {
|
4221
|
+
throw new Error('No module with ID: ' + id);
|
4222
|
+
}
|
4223
|
+
}
|
4224
|
+
} else {
|
4225
|
+
//There is a plugin in play.
|
4226
|
+
prefix = id.substring(0, index);
|
4227
|
+
id = id.substring(index + 1, id.length);
|
4228
|
+
|
4229
|
+
plugin = stringRequire(systemRequire, exports, module, prefix, relId);
|
4230
|
+
|
4231
|
+
if (plugin.normalize) {
|
4232
|
+
id = plugin.normalize(id, makeNormalize(relId));
|
4233
|
+
} else {
|
4234
|
+
//Normalize the ID normally.
|
4235
|
+
id = normalize(id, relId);
|
4236
|
+
}
|
4237
|
+
|
4238
|
+
if (loaderCache[id]) {
|
4239
|
+
return loaderCache[id];
|
4240
|
+
} else {
|
4241
|
+
plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
|
4242
|
+
|
4243
|
+
return loaderCache[id];
|
4244
|
+
}
|
4245
|
+
}
|
4246
|
+
};
|
4247
|
+
|
4248
|
+
//Create a define function specific to the module asking for amdefine.
|
4249
|
+
function define(id, deps, factory) {
|
4250
|
+
if (Array.isArray(id)) {
|
4251
|
+
factory = deps;
|
4252
|
+
deps = id;
|
4253
|
+
id = undefined;
|
4254
|
+
} else if (typeof id !== 'string') {
|
4255
|
+
factory = id;
|
4256
|
+
id = deps = undefined;
|
4257
|
+
}
|
4258
|
+
|
4259
|
+
if (deps && !Array.isArray(deps)) {
|
4260
|
+
factory = deps;
|
4261
|
+
deps = undefined;
|
4262
|
+
}
|
4263
|
+
|
4264
|
+
if (!deps) {
|
4265
|
+
deps = ['require', 'exports', 'module'];
|
4266
|
+
}
|
4267
|
+
|
4268
|
+
//Set up properties for this module. If an ID, then use
|
4269
|
+
//internal cache. If no ID, then use the external variables
|
4270
|
+
//for this node module.
|
4271
|
+
if (id) {
|
4272
|
+
//Put the module in deep freeze until there is a
|
4273
|
+
//require call for it.
|
4274
|
+
defineCache[id] = [id, deps, factory];
|
4275
|
+
} else {
|
4276
|
+
runFactory(id, deps, factory);
|
4277
|
+
}
|
4278
|
+
}
|
4279
|
+
|
4280
|
+
//define.require, which has access to all the values in the
|
4281
|
+
//cache. Useful for AMD modules that all have IDs in the file,
|
4282
|
+
//but need to finally export a value to node based on one of those
|
4283
|
+
//IDs.
|
4284
|
+
define.require = function (id) {
|
4285
|
+
if (loaderCache[id]) {
|
4286
|
+
return loaderCache[id];
|
4287
|
+
}
|
4288
|
+
|
4289
|
+
if (defineCache[id]) {
|
4290
|
+
runFactory.apply(null, defineCache[id]);
|
4291
|
+
return loaderCache[id];
|
4292
|
+
}
|
4293
|
+
};
|
4294
|
+
|
4295
|
+
define.amd = {};
|
4296
|
+
|
4297
|
+
return define;
|
4298
|
+
}
|
4299
|
+
|
4300
|
+
module.exports = amdefine;
|
4301
|
+
|
4302
|
+
}).call(this,require("/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"/../node_modules/postcss/node_modules/source-map/node_modules/amdefine/amdefine.js")
|
4303
|
+
},{"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":31,"path":32}],30:[function(require,module,exports){
|
4304
|
+
|
4305
|
+
},{}],31:[function(require,module,exports){
|
4306
|
+
// shim for using process in browser
|
4307
|
+
|
4308
|
+
var process = module.exports = {};
|
4309
|
+
|
4310
|
+
process.nextTick = (function () {
|
4311
|
+
var canSetImmediate = typeof window !== 'undefined'
|
4312
|
+
&& window.setImmediate;
|
4313
|
+
var canPost = typeof window !== 'undefined'
|
4314
|
+
&& window.postMessage && window.addEventListener
|
4315
|
+
;
|
4316
|
+
|
4317
|
+
if (canSetImmediate) {
|
4318
|
+
return function (f) { return window.setImmediate(f) };
|
4319
|
+
}
|
4320
|
+
|
4321
|
+
if (canPost) {
|
4322
|
+
var queue = [];
|
4323
|
+
window.addEventListener('message', function (ev) {
|
4324
|
+
var source = ev.source;
|
4325
|
+
if ((source === window || source === null) && ev.data === 'process-tick') {
|
4326
|
+
ev.stopPropagation();
|
4327
|
+
if (queue.length > 0) {
|
4328
|
+
var fn = queue.shift();
|
4329
|
+
fn();
|
4330
|
+
}
|
4331
|
+
}
|
4332
|
+
}, true);
|
4333
|
+
|
4334
|
+
return function nextTick(fn) {
|
4335
|
+
queue.push(fn);
|
4336
|
+
window.postMessage('process-tick', '*');
|
4337
|
+
};
|
4338
|
+
}
|
4339
|
+
|
4340
|
+
return function nextTick(fn) {
|
4341
|
+
setTimeout(fn, 0);
|
4342
|
+
};
|
4343
|
+
})();
|
4344
|
+
|
4345
|
+
process.title = 'browser';
|
4346
|
+
process.browser = true;
|
4347
|
+
process.env = {};
|
4348
|
+
process.argv = [];
|
4349
|
+
|
4350
|
+
function noop() {}
|
4351
|
+
|
4352
|
+
process.on = noop;
|
4353
|
+
process.once = noop;
|
4354
|
+
process.off = noop;
|
4355
|
+
process.emit = noop;
|
4356
|
+
|
4357
|
+
process.binding = function (name) {
|
4358
|
+
throw new Error('process.binding is not supported');
|
4359
|
+
}
|
4360
|
+
|
4361
|
+
// TODO(shtylman)
|
4362
|
+
process.cwd = function () { return '/' };
|
4363
|
+
process.chdir = function (dir) {
|
4364
|
+
throw new Error('process.chdir is not supported');
|
4365
|
+
};
|
4366
|
+
|
4367
|
+
},{}],32:[function(require,module,exports){
|
4368
|
+
(function (process){
|
4369
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
4370
|
+
//
|
4371
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
4372
|
+
// copy of this software and associated documentation files (the
|
4373
|
+
// "Software"), to deal in the Software without restriction, including
|
4374
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
4375
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
4376
|
+
// persons to whom the Software is furnished to do so, subject to the
|
4377
|
+
// following conditions:
|
4378
|
+
//
|
4379
|
+
// The above copyright notice and this permission notice shall be included
|
4380
|
+
// in all copies or substantial portions of the Software.
|
4381
|
+
//
|
4382
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
4383
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
4384
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
4385
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
4386
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
4387
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
4388
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
4389
|
+
|
4390
|
+
// resolves . and .. elements in a path array with directory names there
|
4391
|
+
// must be no slashes, empty elements, or device names (c:\) in the array
|
4392
|
+
// (so also no leading and trailing slashes - it does not distinguish
|
4393
|
+
// relative and absolute paths)
|
4394
|
+
function normalizeArray(parts, allowAboveRoot) {
|
4395
|
+
// if the path tries to go above the root, `up` ends up > 0
|
4396
|
+
var up = 0;
|
4397
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
4398
|
+
var last = parts[i];
|
4399
|
+
if (last === '.') {
|
4400
|
+
parts.splice(i, 1);
|
4401
|
+
} else if (last === '..') {
|
4402
|
+
parts.splice(i, 1);
|
4403
|
+
up++;
|
4404
|
+
} else if (up) {
|
4405
|
+
parts.splice(i, 1);
|
4406
|
+
up--;
|
4407
|
+
}
|
4408
|
+
}
|
4409
|
+
|
4410
|
+
// if the path is allowed to go above the root, restore leading ..s
|
4411
|
+
if (allowAboveRoot) {
|
4412
|
+
for (; up--; up) {
|
4413
|
+
parts.unshift('..');
|
4414
|
+
}
|
4415
|
+
}
|
4416
|
+
|
4417
|
+
return parts;
|
4418
|
+
}
|
4419
|
+
|
4420
|
+
// Split a filename into [root, dir, basename, ext], unix version
|
4421
|
+
// 'root' is just a slash, or nothing.
|
4422
|
+
var splitPathRe =
|
4423
|
+
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
4424
|
+
var splitPath = function(filename) {
|
4425
|
+
return splitPathRe.exec(filename).slice(1);
|
4426
|
+
};
|
4427
|
+
|
4428
|
+
// path.resolve([from ...], to)
|
4429
|
+
// posix version
|
4430
|
+
exports.resolve = function() {
|
4431
|
+
var resolvedPath = '',
|
4432
|
+
resolvedAbsolute = false;
|
4433
|
+
|
4434
|
+
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
4435
|
+
var path = (i >= 0) ? arguments[i] : process.cwd();
|
4436
|
+
|
4437
|
+
// Skip empty and invalid entries
|
4438
|
+
if (typeof path !== 'string') {
|
4439
|
+
throw new TypeError('Arguments to path.resolve must be strings');
|
4440
|
+
} else if (!path) {
|
4441
|
+
continue;
|
4442
|
+
}
|
4443
|
+
|
4444
|
+
resolvedPath = path + '/' + resolvedPath;
|
4445
|
+
resolvedAbsolute = path.charAt(0) === '/';
|
4446
|
+
}
|
4447
|
+
|
4448
|
+
// At this point the path should be resolved to a full absolute path, but
|
4449
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
4450
|
+
|
4451
|
+
// Normalize the path
|
4452
|
+
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
4453
|
+
return !!p;
|
4454
|
+
}), !resolvedAbsolute).join('/');
|
4455
|
+
|
4456
|
+
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
4457
|
+
};
|
4458
|
+
|
4459
|
+
// path.normalize(path)
|
4460
|
+
// posix version
|
4461
|
+
exports.normalize = function(path) {
|
4462
|
+
var isAbsolute = exports.isAbsolute(path),
|
4463
|
+
trailingSlash = substr(path, -1) === '/';
|
4464
|
+
|
4465
|
+
// Normalize the path
|
4466
|
+
path = normalizeArray(filter(path.split('/'), function(p) {
|
4467
|
+
return !!p;
|
4468
|
+
}), !isAbsolute).join('/');
|
4469
|
+
|
4470
|
+
if (!path && !isAbsolute) {
|
4471
|
+
path = '.';
|
4472
|
+
}
|
4473
|
+
if (path && trailingSlash) {
|
4474
|
+
path += '/';
|
4475
|
+
}
|
4476
|
+
|
4477
|
+
return (isAbsolute ? '/' : '') + path;
|
4478
|
+
};
|
4479
|
+
|
4480
|
+
// posix version
|
4481
|
+
exports.isAbsolute = function(path) {
|
4482
|
+
return path.charAt(0) === '/';
|
4483
|
+
};
|
4484
|
+
|
4485
|
+
// posix version
|
4486
|
+
exports.join = function() {
|
4487
|
+
var paths = Array.prototype.slice.call(arguments, 0);
|
4488
|
+
return exports.normalize(filter(paths, function(p, index) {
|
4489
|
+
if (typeof p !== 'string') {
|
4490
|
+
throw new TypeError('Arguments to path.join must be strings');
|
4491
|
+
}
|
4492
|
+
return p;
|
4493
|
+
}).join('/'));
|
4494
|
+
};
|
4495
|
+
|
4496
|
+
|
4497
|
+
// path.relative(from, to)
|
4498
|
+
// posix version
|
4499
|
+
exports.relative = function(from, to) {
|
4500
|
+
from = exports.resolve(from).substr(1);
|
4501
|
+
to = exports.resolve(to).substr(1);
|
4502
|
+
|
4503
|
+
function trim(arr) {
|
4504
|
+
var start = 0;
|
4505
|
+
for (; start < arr.length; start++) {
|
4506
|
+
if (arr[start] !== '') break;
|
4507
|
+
}
|
4508
|
+
|
4509
|
+
var end = arr.length - 1;
|
4510
|
+
for (; end >= 0; end--) {
|
4511
|
+
if (arr[end] !== '') break;
|
4512
|
+
}
|
4513
|
+
|
4514
|
+
if (start > end) return [];
|
4515
|
+
return arr.slice(start, end - start + 1);
|
4516
|
+
}
|
4517
|
+
|
4518
|
+
var fromParts = trim(from.split('/'));
|
4519
|
+
var toParts = trim(to.split('/'));
|
4520
|
+
|
4521
|
+
var length = Math.min(fromParts.length, toParts.length);
|
4522
|
+
var samePartsLength = length;
|
4523
|
+
for (var i = 0; i < length; i++) {
|
4524
|
+
if (fromParts[i] !== toParts[i]) {
|
4525
|
+
samePartsLength = i;
|
4526
|
+
break;
|
4527
|
+
}
|
4528
|
+
}
|
4529
|
+
|
4530
|
+
var outputParts = [];
|
4531
|
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
4532
|
+
outputParts.push('..');
|
4533
|
+
}
|
4534
|
+
|
4535
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
4536
|
+
|
4537
|
+
return outputParts.join('/');
|
4538
|
+
};
|
4539
|
+
|
4540
|
+
exports.sep = '/';
|
4541
|
+
exports.delimiter = ':';
|
4542
|
+
|
4543
|
+
exports.dirname = function(path) {
|
4544
|
+
var result = splitPath(path),
|
4545
|
+
root = result[0],
|
4546
|
+
dir = result[1];
|
4547
|
+
|
4548
|
+
if (!root && !dir) {
|
4549
|
+
// No dirname whatsoever
|
4550
|
+
return '.';
|
4551
|
+
}
|
4552
|
+
|
4553
|
+
if (dir) {
|
4554
|
+
// It has a dirname, strip trailing slash
|
4555
|
+
dir = dir.substr(0, dir.length - 1);
|
4556
|
+
}
|
4557
|
+
|
4558
|
+
return root + dir;
|
4559
|
+
};
|
4560
|
+
|
4561
|
+
|
4562
|
+
exports.basename = function(path, ext) {
|
4563
|
+
var f = splitPath(path)[2];
|
4564
|
+
// TODO: make this comparison case-insensitive on windows?
|
4565
|
+
if (ext && f.substr(-1 * ext.length) === ext) {
|
4566
|
+
f = f.substr(0, f.length - ext.length);
|
4567
|
+
}
|
4568
|
+
return f;
|
4569
|
+
};
|
4570
|
+
|
4571
|
+
|
4572
|
+
exports.extname = function(path) {
|
4573
|
+
return splitPath(path)[3];
|
4574
|
+
};
|
4575
|
+
|
4576
|
+
function filter (xs, f) {
|
4577
|
+
if (xs.filter) return xs.filter(f);
|
4578
|
+
var res = [];
|
4579
|
+
for (var i = 0; i < xs.length; i++) {
|
4580
|
+
if (f(xs[i], i, xs)) res.push(xs[i]);
|
4581
|
+
}
|
4582
|
+
return res;
|
4583
|
+
}
|
4584
|
+
|
4585
|
+
// String.prototype.substr - negative index don't work in IE8
|
4586
|
+
var substr = 'ab'.substr(-1) === 'b'
|
4587
|
+
? function (str, start, len) { return str.substr(start, len) }
|
4588
|
+
: function (str, start, len) {
|
4589
|
+
if (start < 0) start = str.length + start;
|
4590
|
+
return str.substr(start, len);
|
4591
|
+
}
|
4592
|
+
;
|
4593
|
+
|
4594
|
+
}).call(this,require("/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
|
4595
|
+
},{"/usr/local/lib/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":31}]},{},[])
|