1 | module.exports =
|
2 | (function(modules) {
|
3 |
|
4 | var installedModules = {};
|
5 |
|
6 |
|
7 | function __webpack_require__(moduleId) {
|
8 |
|
9 |
|
10 | if(installedModules[moduleId]) {
|
11 | return installedModules[moduleId].exports;
|
12 | }
|
13 |
|
14 | var module = installedModules[moduleId] = {
|
15 | i: moduleId,
|
16 | l: false,
|
17 | exports: {}
|
18 | };
|
19 |
|
20 |
|
21 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
22 |
|
23 |
|
24 | module.l = true;
|
25 |
|
26 |
|
27 | return module.exports;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | __webpack_require__.m = modules;
|
33 |
|
34 |
|
35 | __webpack_require__.c = installedModules;
|
36 |
|
37 |
|
38 | __webpack_require__.i = function(value) { return value; };
|
39 |
|
40 |
|
41 | __webpack_require__.d = function(exports, name, getter) {
|
42 | if(!__webpack_require__.o(exports, name)) {
|
43 | Object.defineProperty(exports, name, {
|
44 | configurable: false,
|
45 | enumerable: true,
|
46 | get: getter
|
47 | /******/ });
|
48 | /******/ }
|
49 | /******/ };
|
50 | /******/
|
51 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
52 | /******/ __webpack_require__.n = function(module) {
|
53 | var getter = module && module.__esModule ?
|
54 | function getDefault() { return module['default']; } :
|
55 | function getModuleExports() { return module; };
|
56 | __webpack_require__.d(getter, 'a', getter);
|
57 | return getter;
|
58 | };
|
59 |
|
60 |
|
61 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
62 |
|
63 |
|
64 | __webpack_require__.p = "";
|
65 |
|
66 |
|
67 | return __webpack_require__(__webpack_require__.s = 22);
|
68 | })
|
69 |
|
70 | ([
|
71 |
|
72 | (function(module, exports) {
|
73 |
|
74 | module.exports = require("art-standard-lib");
|
75 |
|
76 | }),
|
77 |
|
78 | (function(module, exports) {
|
79 |
|
80 | module.exports = require("art-class-system");
|
81 |
|
82 | }),
|
83 |
|
84 | (function(module, exports, __webpack_require__) {
|
85 |
|
86 | module.exports = __webpack_require__(5);
|
87 |
|
88 | module.exports.addModules({
|
89 | EmptyNode: __webpack_require__(10),
|
90 | EmptyOptionalNode: __webpack_require__(26),
|
91 | Node: __webpack_require__(11),
|
92 | ScratchNode: __webpack_require__(27)
|
93 | });
|
94 |
|
95 |
|
96 | }),
|
97 |
|
98 | (function(module, exports, __webpack_require__) {
|
99 |
|
100 | var Stats,
|
101 | extend = 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; },
|
102 | hasProp = {}.hasOwnProperty;
|
103 |
|
104 | module.exports = Stats = (function(superClass) {
|
105 | extend(Stats, superClass);
|
106 |
|
107 | function Stats() {
|
108 | return Stats.__super__.constructor.apply(this, arguments);
|
109 | }
|
110 |
|
111 | Stats._stats = {};
|
112 |
|
113 | Stats.reset = function() {
|
114 | return this._stats = {};
|
115 | };
|
116 |
|
117 | Stats.add = function(statName, amount) {
|
118 | if (amount == null) {
|
119 | amount = 1;
|
120 | }
|
121 | return this._stats[statName] = (this._stats[statName] || 0) + amount;
|
122 | };
|
123 |
|
124 | Stats.get = function() {
|
125 | return this._stats;
|
126 | };
|
127 |
|
128 | return Stats;
|
129 |
|
130 | })(__webpack_require__(1).BaseClass);
|
131 |
|
132 |
|
133 | }),
|
134 |
|
135 | (function(module, exports) {
|
136 |
|
137 | module.exports = function(module) {
|
138 | if(!module.webpackPolyfill) {
|
139 | module.deprecate = function() {};
|
140 | module.paths = [];
|
141 |
|
142 | if(!module.children) module.children = [];
|
143 | Object.defineProperty(module, "loaded", {
|
144 | enumerable: true,
|
145 | get: function() {
|
146 | return module.l;
|
147 | }
|
148 | });
|
149 | Object.defineProperty(module, "id", {
|
150 | enumerable: true,
|
151 | get: function() {
|
152 | return module.i;
|
153 | }
|
154 | });
|
155 | module.webpackPolyfill = 1;
|
156 | }
|
157 | return module;
|
158 | };
|
159 |
|
160 |
|
161 | }),
|
162 |
|
163 | (function(module, exports, __webpack_require__) {
|
164 |
|
165 | var Nodes,
|
166 | extend = 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 | hasProp = {}.hasOwnProperty;
|
168 |
|
169 | module.exports = (__webpack_require__(7)).addNamespace('Nodes', Nodes = (function(superClass) {
|
170 | extend(Nodes, superClass);
|
171 |
|
172 | function Nodes() {
|
173 | return Nodes.__super__.constructor.apply(this, arguments);
|
174 | }
|
175 |
|
176 | return Nodes;
|
177 |
|
178 | })(Neptune.PackageNamespace));
|
179 |
|
180 |
|
181 | }),
|
182 |
|
183 | (function(module, exports, __webpack_require__) {
|
184 |
|
185 | (function(module) {var Repl, defineModule, formattedInspect, isClass, log, ref;
|
186 |
|
187 | ref = __webpack_require__(0), defineModule = ref.defineModule, formattedInspect = ref.formattedInspect, isClass = ref.isClass, log = ref.log;
|
188 |
|
189 | __webpack_require__(32);
|
190 |
|
191 | defineModule(module, Repl = (function() {
|
192 | function Repl() {}
|
193 |
|
194 | Repl.babelBridgeRepl = function(parser) {
|
195 | if (isClass(parser)) {
|
196 | parser = new parser;
|
197 | }
|
198 | return __webpack_require__(34).start({
|
199 | prompt: ((parser.getClassName()) + "> ").grey,
|
200 | "eval": function(command, context, filename, callback) {
|
201 | var e, parsed, result;
|
202 | try {
|
203 | parsed = parser.parse(command.trim());
|
204 | try {
|
205 | if (result = typeof parsed.evaluate === "function" ? parsed.evaluate() : void 0) {
|
206 | return callback(null, result);
|
207 | } else {
|
208 | log(formattedInspect(parsed, {
|
209 | color: true
|
210 | }));
|
211 | return callback();
|
212 | }
|
213 | } catch (error) {
|
214 | e = error;
|
215 | return callback(e);
|
216 | }
|
217 | } catch (error) {
|
218 | e = error;
|
219 | return callback(parser.getParseFailureInfo({
|
220 | color: true
|
221 | }).replace("<HERE>", "<HERE>".red));
|
222 | }
|
223 | }
|
224 | });
|
225 | };
|
226 |
|
227 | return Repl;
|
228 |
|
229 | })());
|
230 |
|
231 | }.call(exports, __webpack_require__(4)(module)))
|
232 |
|
233 | }),
|
234 |
|
235 | (function(module, exports, __webpack_require__) {
|
236 |
|
237 | var BabelBridge,
|
238 | extend = 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; },
|
239 | hasProp = {}.hasOwnProperty;
|
240 |
|
241 | module.exports = (__webpack_require__(33)).addNamespace('BabelBridge', BabelBridge = (function(superClass) {
|
242 | extend(BabelBridge, superClass);
|
243 |
|
244 | function BabelBridge() {
|
245 | return BabelBridge.__super__.constructor.apply(this, arguments);
|
246 | }
|
247 |
|
248 | BabelBridge.version = __webpack_require__(19).version;
|
249 |
|
250 | return BabelBridge;
|
251 |
|
252 | })(Neptune.PackageNamespace));
|
253 |
|
254 | __webpack_require__(9);
|
255 |
|
256 | __webpack_require__(5);
|
257 |
|
258 |
|
259 | }),
|
260 |
|
261 | (function(module, exports, __webpack_require__) {
|
262 |
|
263 | (function(module) {var BabelBridgeCompileError, ErrorWithInfo, defineModule, formattedInspect, isFunction, log, mergeInto, ref,
|
264 | extend = 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; },
|
265 | hasProp = {}.hasOwnProperty;
|
266 |
|
267 | ref = __webpack_require__(0), defineModule = ref.defineModule, log = ref.log, mergeInto = ref.mergeInto, isFunction = ref.isFunction, formattedInspect = ref.formattedInspect, ErrorWithInfo = ref.ErrorWithInfo;
|
268 |
|
269 | defineModule(module, BabelBridgeCompileError = (function(superClass) {
|
270 | extend(BabelBridgeCompileError, superClass);
|
271 |
|
272 | function BabelBridgeCompileError(message, info) {
|
273 | BabelBridgeCompileError.__super__.constructor.call(this, message, info, "BabelBridgeCompileError");
|
274 | }
|
275 |
|
276 | return BabelBridgeCompileError;
|
277 |
|
278 | })(ErrorWithInfo));
|
279 |
|
280 | }.call(exports, __webpack_require__(4)(module)))
|
281 |
|
282 | }),
|
283 |
|
284 | (function(module, exports, __webpack_require__) {
|
285 |
|
286 | var Extensions,
|
287 | extend = 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; },
|
288 | hasProp = {}.hasOwnProperty;
|
289 |
|
290 | module.exports = (__webpack_require__(7)).addNamespace('Extensions', Extensions = (function(superClass) {
|
291 | extend(Extensions, superClass);
|
292 |
|
293 | function Extensions() {
|
294 | return Extensions.__super__.constructor.apply(this, arguments);
|
295 | }
|
296 |
|
297 | return Extensions;
|
298 |
|
299 | })(Neptune.PackageNamespace));
|
300 |
|
301 |
|
302 | }),
|
303 |
|
304 | (function(module, exports, __webpack_require__) {
|
305 |
|
306 | var EmptyNode,
|
307 | extend = 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; },
|
308 | hasProp = {}.hasOwnProperty;
|
309 |
|
310 | module.exports = EmptyNode = (function(superClass) {
|
311 | extend(EmptyNode, superClass);
|
312 |
|
313 | function EmptyNode() {
|
314 | return EmptyNode.__super__.constructor.apply(this, arguments);
|
315 | }
|
316 |
|
317 | EmptyNode.getter({
|
318 | present: function() {
|
319 | return false;
|
320 | }
|
321 | });
|
322 |
|
323 | return EmptyNode;
|
324 |
|
325 | })(__webpack_require__(11));
|
326 |
|
327 |
|
328 | }),
|
329 |
|
330 | (function(module, exports, __webpack_require__) {
|
331 |
|
332 | var BaseClass, Node, Nodes, Stats, array, arrayWith, compactFlatten, inspectedObjectLiteral, isPlainArray, isPlainObject, log, merge, mergeInto, objectWithout, peek, push, ref,
|
333 | extend = 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; },
|
334 | hasProp = {}.hasOwnProperty;
|
335 |
|
336 | ref = __webpack_require__(0), arrayWith = ref.arrayWith, array = ref.array, peek = ref.peek, log = ref.log, push = ref.push, compactFlatten = ref.compactFlatten, objectWithout = ref.objectWithout, isPlainArray = ref.isPlainArray, isPlainObject = ref.isPlainObject, inspectedObjectLiteral = ref.inspectedObjectLiteral, merge = ref.merge, mergeInto = ref.mergeInto;
|
337 |
|
338 | Nodes = __webpack_require__(5);
|
339 |
|
340 | BaseClass = __webpack_require__(1).BaseClass;
|
341 |
|
342 | Stats = __webpack_require__(3);
|
343 |
|
344 | module.exports = Node = (function(superClass) {
|
345 | var emptyArray;
|
346 |
|
347 | extend(Node, superClass);
|
348 |
|
349 | function Node(parent, options) {
|
350 | var ref1;
|
351 | Node.__super__.constructor.apply(this, arguments);
|
352 | Stats.add("newNode");
|
353 | this._parent = parent;
|
354 | this._parser = parent._parser;
|
355 | this._offset = ((ref1 = options != null ? options.offset : void 0) != null ? ref1 : this._parent.getNextOffset()) | 0;
|
356 | this._matchLength = 0;
|
357 | this._ruleName = this._pluralRuleName = this._label = this._pluralLabel = this._pattern = this._nonMatches = this._ruleVariant = this._matches = this._matchPatterns = null;
|
358 | this._labelsApplied = this._nonMatch = false;
|
359 | if (options) {
|
360 | this._matchLength = (options.matchLength || 0) | 0;
|
361 | this._ruleVariant = options.ruleVariant;
|
362 | this._matches = options.matches;
|
363 | this._matchPatterns = options.matchPatterns;
|
364 | }
|
365 | }
|
366 |
|
367 | Node._createSubclassBase = function() {
|
368 | var NodeSubclass;
|
369 | return NodeSubclass = (function(superClass1) {
|
370 | extend(NodeSubclass, superClass1);
|
371 |
|
372 | function NodeSubclass() {
|
373 | return NodeSubclass.__super__.constructor.apply(this, arguments);
|
374 | }
|
375 |
|
376 | return NodeSubclass;
|
377 |
|
378 | })(this);
|
379 | };
|
380 |
|
381 | Node.createSubclass = function(options) {
|
382 | var klass;
|
383 | klass = this._createSubclassBase();
|
384 | if (options.name) {
|
385 | klass._name = klass.prototype._name = options.name;
|
386 | }
|
387 | if (options.ruleVarient) {
|
388 | klass.ruleVarient = options.ruleVarient;
|
389 | klass.rule = klass.ruleVariant.rule;
|
390 | }
|
391 | mergeInto(klass.prototype, objectWithout(options, "getter"));
|
392 | if (options.getter) {
|
393 | klass.getter(options.getter);
|
394 | }
|
395 | return klass;
|
396 | };
|
397 |
|
398 | Node.prototype.toString = function() {
|
399 | return this.text;
|
400 | };
|
401 |
|
402 | emptyArray = [];
|
403 |
|
404 | Node.setter("matches offset matchLength ruleVariant pattern matchPatterns");
|
405 |
|
406 | Node.getter("parent parser offset matchLength matchPatterns label pluralLabel ruleName pluralRuleName pattern nonMatch", {
|
407 | realNode: function() {
|
408 | return this;
|
409 | },
|
410 | name: function() {
|
411 | return this._name || this.ruleName || this["class"].getName();
|
412 | },
|
413 | present: function() {
|
414 | return this._matchLength > 0 || this._nonMatch;
|
415 | },
|
416 | matches: function() {
|
417 | return this._matches || (this._matches = []);
|
418 | },
|
419 | source: function() {
|
420 | return this._parser.source;
|
421 | },
|
422 | isRoot: function() {
|
423 | return this._parser === this._parent;
|
424 | },
|
425 | absoluteOffset: function() {
|
426 | return this._parser.offsetInRootParserSource(this._offset);
|
427 | },
|
428 | ancestors: function(into) {
|
429 | if (into == null) {
|
430 | into = [];
|
431 | }
|
432 | this.parent.getAncestors(into);
|
433 | into.push(this);
|
434 | return into;
|
435 | },
|
436 | parseInfo: function() {
|
437 | if (this.subparseInfo) {
|
438 | return "subparse:" + this.ruleName + ":" + this.offset;
|
439 | } else {
|
440 | return this.ruleName + ":" + this.offset;
|
441 | }
|
442 | },
|
443 | rulePath: function() {
|
444 | var ancestor, ancestorRuleNames;
|
445 | ancestorRuleNames = (function() {
|
446 | var j, len, ref1, results;
|
447 | ref1 = this.ancestors;
|
448 | results = [];
|
449 | for (j = 0, len = ref1.length; j < len; j++) {
|
450 | ancestor = ref1[j];
|
451 | results.push(ancestor.parseInfo);
|
452 | }
|
453 | return results;
|
454 | }).call(this);
|
455 | return ancestorRuleNames.join(" > ");
|
456 | },
|
457 | nextOffset: function() {
|
458 | return this.offset + this.matchLength;
|
459 | },
|
460 | text: function() {
|
461 | var matchLength, offset, ref1, source;
|
462 | ref1 = this.subparseInfo || this, matchLength = ref1.matchLength, offset = ref1.offset, source = ref1.source;
|
463 | if (matchLength === 0) {
|
464 | return "";
|
465 | } else {
|
466 | return source.slice(offset, offset + matchLength);
|
467 | }
|
468 | },
|
469 | ruleVariant: function() {
|
470 | var ref1;
|
471 | return this._ruleVariant || ((ref1 = this._parent) != null ? ref1.ruleVariant : void 0);
|
472 | },
|
473 | ruleName: function() {
|
474 | var ref1;
|
475 | return this.ruleNameOrNull || ((ref1 = this.parent) != null ? ref1.ruleName : void 0) || ("" + (this.pattern || 'no rule'));
|
476 | },
|
477 | ruleNameOrNull: function() {
|
478 | var ref1, ref2;
|
479 | return ((ref1 = this["class"].rule) != null ? ref1.getName() : void 0) || ((ref2 = this._ruleVariant) != null ? ref2.rule.getName() : void 0);
|
480 | },
|
481 | ruleNameOrPattern: function() {
|
482 | var ref1;
|
483 | return this.ruleNameOrNull || ("" + (((ref1 = this.pattern) != null ? ref1.pattern : void 0) || 'no rule'));
|
484 | },
|
485 | isRuleNode: function() {
|
486 | return this["class"].rule;
|
487 | },
|
488 | isPassThrough: function() {
|
489 | var ref1;
|
490 | return (ref1 = this.ruleVariant) != null ? ref1.isPassThrough : void 0;
|
491 | },
|
492 | nonPassThrough: function() {
|
493 | var ref1;
|
494 | return !((ref1 = this.ruleVariant) != null ? ref1.isPassThrough : void 0);
|
495 | }
|
496 | });
|
497 |
|
498 | Node.prototype.getNextText = function(length) {
|
499 | var nextOffset;
|
500 | nextOffset = this.nextOffset;
|
501 | return this.source.slice(nextOffset, nextOffset + length);
|
502 | };
|
503 |
|
504 | Node.prototype.formattedInspect = function() {
|
505 | return "CUSTOM";
|
506 | };
|
507 |
|
508 | Node.getter({
|
509 | parseTreePath: function() {
|
510 | var ref1;
|
511 | return compactFlatten([(ref1 = this.parent) != null ? ref1.parseTreePath : void 0, this["class"].getName()]);
|
512 | },
|
513 | presentMatches: function() {
|
514 | var j, len, m, ref1, results;
|
515 | ref1 = this.matches;
|
516 | results = [];
|
517 | for (j = 0, len = ref1.length; j < len; j++) {
|
518 | m = ref1[j];
|
519 | if (typeof m.getPresent === "function" ? m.getPresent() : void 0) {
|
520 | results.push(m);
|
521 | }
|
522 | }
|
523 | return results;
|
524 | },
|
525 | isNonMatch: function() {
|
526 | return !!this.nonMatch;
|
527 | },
|
528 | isPartialMatch: function() {
|
529 | var j, len, match, ref1;
|
530 | if (!this.nonMatch) {
|
531 | return false;
|
532 | }
|
533 | ref1 = this.presentMatches;
|
534 | for (j = 0, len = ref1.length; j < len; j++) {
|
535 | match = ref1[j];
|
536 | if (!match.nonMatch) {
|
537 | return true;
|
538 | }
|
539 | }
|
540 | return false;
|
541 | },
|
542 | isMatch: function() {
|
543 | return !this.nonMatch;
|
544 | },
|
545 | nonMatchingLeaf: function() {
|
546 | return this.nonMatch && peek(this.matches);
|
547 | },
|
548 | firstPartialMatchParent: function() {
|
549 | if (this.parent === this.parser || this.isPartialMatch) {
|
550 | return this;
|
551 | } else {
|
552 | return this.parent.firstPartialMatchParent;
|
553 | }
|
554 | },
|
555 | inspectedObjects: function(verbose) {
|
556 | var children, hasOneOrMoreMatchingChildren, label, match, matches, nonMatch, obj, parts, path, ref1, ref2, ref3, ruleName;
|
557 | match = this;
|
558 | matches = this.presentMatches;
|
559 | if (matches.length > 0) {
|
560 | path = [];
|
561 | while (matches.length === 1 && ((ref1 = matches[0].matches) != null ? ref1.length : void 0) > 0) {
|
562 | path.push("" + (match.label ? match.label + ":" : "") + match.ruleName);
|
563 | match = matches[0];
|
564 | matches = match.presentMatches;
|
565 | }
|
566 | label = match.label, ruleName = match.ruleName, nonMatch = match.nonMatch;
|
567 | path.push(ruleName);
|
568 | path = path.join('.');
|
569 | hasOneOrMoreMatchingChildren = false;
|
570 | children = (function() {
|
571 | var j, len, results;
|
572 | results = [];
|
573 | for (j = 0, len = matches.length; j < len; j++) {
|
574 | match = matches[j];
|
575 | if (!match.nonMatch) {
|
576 | hasOneOrMoreMatchingChildren = true;
|
577 | }
|
578 | results.push(match.getInspectedObjects(verbose));
|
579 | }
|
580 | return results;
|
581 | })();
|
582 | parts = compactFlatten([
|
583 | label ? {
|
584 | label: label
|
585 | } : void 0, children.length > 0 ? children : match.toString()
|
586 | ]);
|
587 | if (parts.length === 1) {
|
588 | parts = parts[0];
|
589 | }
|
590 | return (
|
591 | obj = {},
|
592 | obj["" + (nonMatch ? hasOneOrMoreMatchingChildren ? 'partialMatch-' : 'nonMatch-' : '') + path] = parts,
|
593 | obj
|
594 | );
|
595 | } else if (this.nonMatch) {
|
596 | return {
|
597 | nonMatch: {
|
598 | offset: this.offset,
|
599 | pattern: "" + ((ref2 = this.pattern) != null ? ref2.pattern : void 0)
|
600 | }
|
601 | };
|
602 | } else {
|
603 | if (verbose) {
|
604 | return {
|
605 | token: {
|
606 | offset: this.offset,
|
607 | length: this.matchLength,
|
608 | text: this.text,
|
609 | pattern: "" + ((ref3 = this.pattern) != null ? ref3.pattern : void 0),
|
610 | "class": this["class"].getName(),
|
611 | ruleName: this.ruleName
|
612 | }
|
613 | };
|
614 | } else {
|
615 | return this.text;
|
616 | }
|
617 | }
|
618 | },
|
619 | detailedInspectedObjects: function() {
|
620 | var children, match, matches, ret;
|
621 | matches = this.matches;
|
622 | if (matches.length > 0) {
|
623 | children = (function() {
|
624 | var j, len, results;
|
625 | results = [];
|
626 | for (j = 0, len = matches.length; j < len; j++) {
|
627 | match = matches[j];
|
628 | results.push(match.detailedInspectedObjects);
|
629 | }
|
630 | return results;
|
631 | })();
|
632 | ret = {};
|
633 | ret[this.name] = children.length === 1 ? children[0] : children;
|
634 | return ret;
|
635 | } else {
|
636 | return this.text;
|
637 | }
|
638 | },
|
639 | plainObjects: function() {
|
640 | var match, ref1, ret;
|
641 | ret = [
|
642 | {
|
643 | inspect: (function(_this) {
|
644 | return function() {
|
645 | return _this["class"].getName();
|
646 | };
|
647 | })(this)
|
648 | }
|
649 | ];
|
650 | if (((ref1 = this._matches) != null ? ref1.length : void 0) > 0) {
|
651 | ret = ret.concat((function() {
|
652 | var j, len, ref2, results;
|
653 | ref2 = this.matches;
|
654 | results = [];
|
655 | for (j = 0, len = ref2.length; j < len; j++) {
|
656 | match = ref2[j];
|
657 | results.push(match.getPlainObjects());
|
658 | }
|
659 | return results;
|
660 | }).call(this));
|
661 | } else {
|
662 | ret = this.text;
|
663 | }
|
664 | return ret;
|
665 | }
|
666 | });
|
667 |
|
668 | Node.prototype.find = function(searchName, out) {
|
669 | var j, len, m, ref1;
|
670 | if (out == null) {
|
671 | out = [];
|
672 | }
|
673 | ref1 = this.matches;
|
674 | for (j = 0, len = ref1.length; j < len; j++) {
|
675 | m = ref1[j];
|
676 | if (m.getName() === searchName) {
|
677 | out.push(m);
|
678 | } else {
|
679 | m.find(searchName, out);
|
680 | }
|
681 | }
|
682 | return out;
|
683 | };
|
684 |
|
685 | Node.prototype.subparse = function(subSource, options) {
|
686 | return this._parser.subparse(subSource, merge(options, {
|
687 | parentNode: this
|
688 | }));
|
689 | };
|
690 |
|
691 |
|
692 | |
693 |
|
694 |
|
695 |
|
696 |
|
697 | Node.prototype.addMatch = function(pattern, match) {
|
698 | if (!match) {
|
699 | return false;
|
700 | }
|
701 | this._matches = push(this._matches, match);
|
702 | this._matchPatterns = push(this._matchPatterns, pattern);
|
703 | this._matchLength = match.nextOffset - this.offset;
|
704 | return true;
|
705 | };
|
706 |
|
707 | Node.prototype.applyLabels = function() {
|
708 | if (!this._matches || this._labelsApplied) {
|
709 | return;
|
710 | }
|
711 | this._labelsApplied = true;
|
712 | return array(this._matches, (function(_this) {
|
713 | return function(match, i) {
|
714 | var label, pattern, pluralLabel, pluralRuleName, ruleName;
|
715 | pattern = _this._matchPatterns[i];
|
716 | match._parent = _this;
|
717 | if (pattern) {
|
718 | label = pattern.label, ruleName = pattern.ruleName;
|
719 | match._pattern = pattern;
|
720 | match._label = label;
|
721 | match._ruleName = ruleName;
|
722 | }
|
723 | if (label) {
|
724 | match._pluralLabel = pluralLabel = _this.parser.pluralize(label);
|
725 | }
|
726 | if (ruleName) {
|
727 | match._pluralRuleName = pluralRuleName = _this.parser.pluralize(ruleName);
|
728 | }
|
729 | label || (label = ruleName);
|
730 | pluralLabel || (pluralLabel = pluralRuleName);
|
731 | if (label && !(match instanceof Nodes.EmptyNode)) {
|
732 | _this._bindToLabelLists(pluralLabel, match);
|
733 | _this._bindToSingleLabels(label, match);
|
734 | }
|
735 | return match.applyLabels();
|
736 | };
|
737 | })(this));
|
738 | };
|
739 |
|
740 | Node.prototype._bindToLabelLists = function(pluralLabel, match) {
|
741 | if (this.__proto__[pluralLabel] == null) {
|
742 | return this[pluralLabel] = push(this[pluralLabel], match);
|
743 | }
|
744 | };
|
745 |
|
746 | Node.prototype._bindToSingleLabels = function(label, match) {
|
747 | if (this.__proto__[label] == null) {
|
748 | return this[label] = match;
|
749 | }
|
750 | };
|
751 |
|
752 | Node.prototype._addNonMatch = function(node) {
|
753 | return (this._nonMatches || (this._nonMatches = [])).push(node);
|
754 | };
|
755 |
|
756 | Node.prototype._addToParentAsNonMatch = function() {
|
757 | if (this._matchLength === 0) {
|
758 | this._matchLength = 1;
|
759 | }
|
760 | if (this.parent) {
|
761 | if (this.parent.matches) {
|
762 | if (!(0 <= this.parent.matches.indexOf(this))) {
|
763 | this._nonMatch = true;
|
764 | this.parent.matches.push(this);
|
765 | this.parent._presentMatches = null;
|
766 | if (this.parent._matchLength === 0) {
|
767 | this.parent._matchLength = 1;
|
768 | }
|
769 | }
|
770 | return this.parent._addToParentAsNonMatch();
|
771 | } else {
|
772 | return this;
|
773 | }
|
774 | } else {
|
775 | return this;
|
776 | }
|
777 | };
|
778 |
|
779 | return Node;
|
780 |
|
781 | })(BaseClass);
|
782 |
|
783 |
|
784 | }),
|
785 |
|
786 | (function(module, exports, __webpack_require__) {
|
787 |
|
788 | (function(module) {var BaseClass, NonMatch, defineModule, log, ref,
|
789 | extend = 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; },
|
790 | hasProp = {}.hasOwnProperty;
|
791 |
|
792 | ref = __webpack_require__(0), log = ref.log, defineModule = ref.defineModule;
|
793 |
|
794 | BaseClass = __webpack_require__(1).BaseClass;
|
795 |
|
796 | defineModule(module, NonMatch = (function(superClass) {
|
797 | extend(NonMatch, superClass);
|
798 |
|
799 | function NonMatch(_node, _patternElement) {
|
800 | this._node = _node;
|
801 | this._patternElement = _patternElement;
|
802 | }
|
803 |
|
804 | NonMatch.getter("node patternElement", {
|
805 | inspectedObjects: function() {
|
806 | return {
|
807 | NonMatch: {
|
808 | patternElement: this.toString(),
|
809 | offset: this.node.offset
|
810 | }
|
811 | };
|
812 | }
|
813 | });
|
814 |
|
815 | NonMatch.prototype.toString = function() {
|
816 | return this.patternElement.ruleVariant.toString();
|
817 | };
|
818 |
|
819 | return NonMatch;
|
820 |
|
821 | })(BaseClass));
|
822 |
|
823 | }.call(exports, __webpack_require__(4)(module)))
|
824 |
|
825 | }),
|
826 |
|
827 | (function(module, exports, __webpack_require__) {
|
828 |
|
829 | var EmptyNode, EmptyOptionalNode, Node, PatternElement, inspect, isPlainObject, isRegExp, isString, log, ref, ref1,
|
830 | extend = 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; },
|
831 | hasProp = {}.hasOwnProperty;
|
832 |
|
833 | ref = __webpack_require__(2), Node = ref.Node, EmptyNode = ref.EmptyNode, EmptyOptionalNode = ref.EmptyOptionalNode;
|
834 |
|
835 | ref1 = __webpack_require__(0), isPlainObject = ref1.isPlainObject, isString = ref1.isString, isRegExp = ref1.isRegExp, inspect = ref1.inspect, log = ref1.log;
|
836 |
|
837 | module.exports = PatternElement = (function(superClass) {
|
838 | var escapeRegExp;
|
839 |
|
840 | extend(PatternElement, superClass);
|
841 |
|
842 | PatternElement.escapeRegExp = escapeRegExp = function(str) {
|
843 | return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
844 | };
|
845 |
|
846 | PatternElement.regExpRegExp = /\/((?:[^\\\/]|\\.)+)\//;
|
847 |
|
848 | PatternElement.ruleRegExp = /([a-zA-Z0-9_]+)/;
|
849 |
|
850 | PatternElement.singleQuotedStringRegExp = /'((?:[^\\']|\\.)+)'/;
|
851 |
|
852 | PatternElement.doubleQuotedStringRegExp = /"((?:[^\\"]|\\.)+)"/;
|
853 |
|
854 | PatternElement.labelRegExp = /([a-zA-Z0-9_]+)\:/;
|
855 |
|
856 | PatternElement.patternElementRegExp = RegExp("(?:" + PatternElement.labelRegExp.source + ")?([!&])?(?:" + PatternElement.ruleRegExp.source + "|" + PatternElement.regExpRegExp.source + "|" + PatternElement.singleQuotedStringRegExp.source + "|" + PatternElement.doubleQuotedStringRegExp.source + ")([?*+])?");
|
857 |
|
858 | PatternElement.allPatternElementsRegExp = RegExp("" + PatternElement.patternElementRegExp.source, "g");
|
859 |
|
860 | function PatternElement(pattern1, arg) {
|
861 | this.pattern = pattern1;
|
862 | this.ruleVariant = (arg != null ? arg : {}).ruleVariant;
|
863 | PatternElement.__super__.constructor.apply(this, arguments);
|
864 | this.parse = null;
|
865 | this._init();
|
866 | }
|
867 |
|
868 | PatternElement.prototype.toString = function() {
|
869 | return "PatternElement(" + this.pattern + ")";
|
870 | };
|
871 |
|
872 | PatternElement.getter("isTokenPattern");
|
873 |
|
874 | PatternElement.property({
|
875 | label: null,
|
876 | optional: false,
|
877 | negative: false,
|
878 | couldMatch: false,
|
879 | zeroOrMore: false,
|
880 | oneOrMore: false,
|
881 | pattern: null,
|
882 | ruleName: null
|
883 | });
|
884 |
|
885 | PatternElement.getter({
|
886 | isBasicRulePattern: function() {
|
887 | return this.ruleName && !this.optional && !this.negative && !this.zeroOrMore && !this.oneOrMore && !this.couldMatch;
|
888 | },
|
889 | inspectedObjects: function() {
|
890 | return {
|
891 | PatternElement: this.props
|
892 | };
|
893 | },
|
894 | props: function() {
|
895 | var props;
|
896 | props = {
|
897 | pattern: this.pattern
|
898 | };
|
899 | if (this.ruleName) {
|
900 | props.ruleName = this.ruleName;
|
901 | }
|
902 | if (this.negative) {
|
903 | props.negative = true;
|
904 | }
|
905 | if (this.zeroOrMore) {
|
906 | props.zeroOrMore = true;
|
907 | }
|
908 | if (this.oneOrMore) {
|
909 | props.oneOrMore = true;
|
910 | }
|
911 | if (this.couldMatch) {
|
912 | props.couldMatch = true;
|
913 | }
|
914 | return props;
|
915 | }
|
916 | });
|
917 |
|
918 | PatternElement.prototype.parse = function(parentNode) {
|
919 | throw new Error("should be overridden");
|
920 | };
|
921 |
|
922 | PatternElement.prototype.parseInto = function(parentNode) {
|
923 | return !!parentNode.addMatch(this, this.parse(parentNode));
|
924 | };
|
925 |
|
926 | PatternElement.prototype._applyParseFlags = function() {
|
927 | var singleParser;
|
928 | singleParser = this.parse;
|
929 | if (this._optional) {
|
930 | this.parse = function(parentNode) {
|
931 | var match;
|
932 | if (match = singleParser(parentNode)) {
|
933 | return match;
|
934 | } else {
|
935 | return new EmptyOptionalNode(parentNode);
|
936 | }
|
937 | };
|
938 | }
|
939 | if (this._negative) {
|
940 | this.parse = function(parentNode) {
|
941 | return parentNode.parser._matchNegative(function() {
|
942 | var match;
|
943 | if (match = singleParser(parentNode)) {
|
944 | return null;
|
945 | } else {
|
946 | return new EmptyNode(parentNode);
|
947 | }
|
948 | });
|
949 | };
|
950 | }
|
951 | if (this.couldMatch) {
|
952 | this.parse = function(parentNode) {
|
953 | if (singleParser(parentNode)) {
|
954 | return new EmptyNode(parentNode);
|
955 | }
|
956 | };
|
957 | }
|
958 | if (this._zeroOrMore) {
|
959 | this.parseInto = (function(_this) {
|
960 | return function(parentNode) {
|
961 | var m, matchCount;
|
962 | matchCount = 0;
|
963 | while (parentNode.addMatch(_this, m = singleParser(parentNode))) {
|
964 | matchCount++;
|
965 | if (m.matchLength === 0) {
|
966 | break;
|
967 | }
|
968 | }
|
969 | return true;
|
970 | };
|
971 | })(this);
|
972 | }
|
973 | if (this._oneOrMore) {
|
974 | return this.parseInto = (function(_this) {
|
975 | return function(parentNode) {
|
976 | var m, matchCount;
|
977 | matchCount = 0;
|
978 | while (parentNode.addMatch(_this, m = singleParser(parentNode))) {
|
979 | matchCount++;
|
980 | if (m.matchLength === 0) {
|
981 | break;
|
982 | }
|
983 | }
|
984 | return matchCount > 0;
|
985 | };
|
986 | })(this);
|
987 | }
|
988 | };
|
989 |
|
990 | PatternElement.prototype._init = function() {
|
991 | var __, doubleQuotedString, pattern, prefix, ref2, regExp, res, singleQuotedString, string, suffix;
|
992 | this.parse = this.label = this.ruleName = null;
|
993 | this.negative = this.couldMatch = this.oneOrMore = this.optional = this.zeroOrMore = false;
|
994 | this._isTokenPattern = false;
|
995 | pattern = this.pattern;
|
996 | if (isPlainObject(pattern)) {
|
997 | this._initPlainObject(pattern);
|
998 | } else if (isString(pattern)) {
|
999 | ref2 = res = pattern.match(PatternElement.patternElementRegExp), __ = ref2[0], this.label = ref2[1], prefix = ref2[2], this.ruleName = ref2[3], regExp = ref2[4], singleQuotedString = ref2[5], doubleQuotedString = ref2[6], suffix = ref2[7];
|
1000 | if (prefix && suffix) {
|
1001 | throw new Error("pattern can only have one prefix: !/& or one suffix: ?/+/*");
|
1002 | }
|
1003 | switch (prefix) {
|
1004 | case "!":
|
1005 | this.negative = true;
|
1006 | break;
|
1007 | case "&":
|
1008 | this.couldMatch = true;
|
1009 | }
|
1010 | switch (suffix) {
|
1011 | case "?":
|
1012 | this.optional = true;
|
1013 | break;
|
1014 | case "+":
|
1015 | this.oneOrMore = true;
|
1016 | break;
|
1017 | case "*":
|
1018 | this.zeroOrMore = true;
|
1019 | }
|
1020 | string = singleQuotedString || doubleQuotedString;
|
1021 | if (this.ruleName) {
|
1022 | this._initRule(this.ruleName);
|
1023 | } else if (regExp) {
|
1024 | this._initRegExp(new RegExp(regExp));
|
1025 | } else if (string) {
|
1026 | this._initRegExp(new RegExp(escapeRegExp(string)));
|
1027 | } else {
|
1028 | throw new Error("invalid pattern: " + pattern);
|
1029 | }
|
1030 | } else if (isRegExp(pattern)) {
|
1031 | this._initRegExp(pattern);
|
1032 | } else {
|
1033 | throw new Error("invalid pattern type: " + (inspect(pattern)));
|
1034 | }
|
1035 | return this._applyParseFlags();
|
1036 | };
|
1037 |
|
1038 | PatternElement.prototype._initPlainObject = function(object) {
|
1039 | var parseInto;
|
1040 | this.negative = object.negative, this.oneOrMore = object.oneOrMore, this.zeroOrMore = object.zeroOrMore, this.optional = object.optional, this.parse = object.parse, parseInto = object.parseInto;
|
1041 | if (parseInto) {
|
1042 | this.parseInto = parseInto;
|
1043 | }
|
1044 | if (!(this.parse || parseInto)) {
|
1045 | throw new Error("plain-object pattern definition requires 'parse' or 'parseInto'");
|
1046 | }
|
1047 | };
|
1048 |
|
1049 | PatternElement.prototype._initRule = function(ruleName) {
|
1050 | var matchRule;
|
1051 | matchRule = null;
|
1052 | return this.parse = function(parentNode) {
|
1053 | matchRule || (matchRule = parentNode.parser.getRule(ruleName));
|
1054 | return matchRule.parse(parentNode);
|
1055 | };
|
1056 | };
|
1057 |
|
1058 |
|
1059 | |
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 | PatternElement.prototype._initRegExp = function(regExp) {
|
1070 | var flags;
|
1071 | this._isTokenPattern = true;
|
1072 | flags = "yg";
|
1073 | if (regExp.ignoreCase) {
|
1074 | flags += "i";
|
1075 | }
|
1076 | regExp = RegExp(regExp.source, flags);
|
1077 | return this.parse = function(parentNode) {
|
1078 | var nextOffset, source;
|
1079 | nextOffset = parentNode.nextOffset, source = parentNode.source;
|
1080 | regExp.lastIndex = nextOffset;
|
1081 | if (regExp.test(source)) {
|
1082 | return new Node(parentNode, {
|
1083 | offset: nextOffset,
|
1084 | matchLength: regExp.lastIndex - nextOffset
|
1085 | });
|
1086 | }
|
1087 | };
|
1088 | };
|
1089 |
|
1090 | return PatternElement;
|
1091 |
|
1092 | })(__webpack_require__(1).BaseClass);
|
1093 |
|
1094 |
|
1095 | }),
|
1096 |
|
1097 | (function(module, exports, __webpack_require__) {
|
1098 |
|
1099 | var Rule, RuleVariant, Stats, log, merge, objectName, ref, upperCamelCase,
|
1100 | extend = 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; },
|
1101 | hasProp = {}.hasOwnProperty;
|
1102 |
|
1103 | RuleVariant = __webpack_require__(15);
|
1104 |
|
1105 | Stats = __webpack_require__(3);
|
1106 |
|
1107 | ref = __webpack_require__(0), merge = ref.merge, upperCamelCase = ref.upperCamelCase, objectName = ref.objectName, log = ref.log;
|
1108 |
|
1109 | module.exports = Rule = (function(superClass) {
|
1110 | extend(Rule, superClass);
|
1111 |
|
1112 | function Rule(_name, _parserClass, _variants) {
|
1113 | this._name = _name;
|
1114 | this._parserClass = _parserClass;
|
1115 | this._variants = _variants != null ? _variants : [];
|
1116 | }
|
1117 |
|
1118 | Rule.getter("nodeClassName name variantNodeClasses", {
|
1119 | numVariants: function() {
|
1120 | return this._variants.length;
|
1121 | }
|
1122 | });
|
1123 |
|
1124 | Rule.prototype.addVariant = function(options) {
|
1125 | var v;
|
1126 | this._variants.push(v = new RuleVariant(merge(options, {
|
1127 | variantNumber: this._variants.length + 1,
|
1128 | rule: this,
|
1129 | parserClass: this._parserClass
|
1130 | })));
|
1131 | return v;
|
1132 | };
|
1133 |
|
1134 | Rule.getter({
|
1135 | inspectObjects: function() {
|
1136 | return [
|
1137 | {
|
1138 | inspect: (function(_this) {
|
1139 | return function() {
|
1140 | return "<Rule: " + _this._name + ">";
|
1141 | };
|
1142 | })(this)
|
1143 | }, this._variants
|
1144 | ];
|
1145 | }
|
1146 | });
|
1147 |
|
1148 | Rule.prototype.clone = function() {
|
1149 | return new Rule(this._name, this._parserClass, this._variants.slice());
|
1150 | };
|
1151 |
|
1152 |
|
1153 | |
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 | Rule.prototype.parse = function(parentNode) {
|
1166 | var cached, i, len, match, nextOffset, parser, ref1, v;
|
1167 | Stats.add("parseRule");
|
1168 | parser = parentNode.parser, nextOffset = parentNode.nextOffset;
|
1169 | if (cached = parser._cached(this.name, nextOffset)) {
|
1170 | if (cached === "no_match") {
|
1171 | Stats.add("cacheHitNoMatch");
|
1172 | return null;
|
1173 | } else {
|
1174 | Stats.add("cacheHit");
|
1175 | return cached;
|
1176 | }
|
1177 | }
|
1178 | ref1 = this._variants;
|
1179 | for (i = 0, len = ref1.length; i < len; i++) {
|
1180 | v = ref1[i];
|
1181 | if (match = v.parse(parentNode)) {
|
1182 | return parser._cacheMatch(this.name, match);
|
1183 | }
|
1184 | }
|
1185 | return parser._cacheNoMatch(this.name, nextOffset);
|
1186 | };
|
1187 |
|
1188 | return Rule;
|
1189 |
|
1190 | })(__webpack_require__(1).BaseClass);
|
1191 |
|
1192 |
|
1193 | }),
|
1194 |
|
1195 | (function(module, exports, __webpack_require__) {
|
1196 |
|
1197 | var BaseClass, Node, PatternElement, RuleVariant, ScratchNode, Stats, allPatternElementsRegExp, compactFlatten, inspect, isPlainObject, isString, log, merge, pad, push, ref, ref1, toInspectedObjects, upperCamelCase,
|
1198 | extend = 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; },
|
1199 | hasProp = {}.hasOwnProperty;
|
1200 |
|
1201 | PatternElement = __webpack_require__(13);
|
1202 |
|
1203 | Stats = __webpack_require__(3);
|
1204 |
|
1205 | ref = __webpack_require__(2), Node = ref.Node, ScratchNode = ref.ScratchNode;
|
1206 |
|
1207 | ref1 = __webpack_require__(0), log = ref1.log, toInspectedObjects = ref1.toInspectedObjects, isPlainObject = ref1.isPlainObject, push = ref1.push, isString = ref1.isString, compactFlatten = ref1.compactFlatten, inspect = ref1.inspect, pad = ref1.pad, upperCamelCase = ref1.upperCamelCase, merge = ref1.merge;
|
1208 |
|
1209 | allPatternElementsRegExp = PatternElement.allPatternElementsRegExp;
|
1210 |
|
1211 | BaseClass = __webpack_require__(1).BaseClass;
|
1212 |
|
1213 | module.exports = RuleVariant = (function(superClass) {
|
1214 | extend(RuleVariant, superClass);
|
1215 |
|
1216 | function RuleVariant(options1) {
|
1217 | var ref2;
|
1218 | this.options = options1;
|
1219 | this._toString = null;
|
1220 | if (!isPlainObject(this.options)) {
|
1221 | this.options = {
|
1222 | pattern: this.options
|
1223 | };
|
1224 | }
|
1225 | ref2 = this.options, this.pattern = ref2.pattern, this.rule = ref2.rule, this.parserClass = ref2.parserClass;
|
1226 | this._variantNodeClassName = this.options.variantNodeClassName;
|
1227 | this._initVariantNodeClass(this.options);
|
1228 | if (this.options.parse) {
|
1229 | this.parse = this.options.parse;
|
1230 | }
|
1231 | }
|
1232 |
|
1233 | RuleVariant.property({
|
1234 | passThroughRuleName: null
|
1235 | });
|
1236 |
|
1237 | RuleVariant.setter("variantNodeClassName");
|
1238 |
|
1239 | RuleVariant.getter({
|
1240 | isPassThrough: function() {
|
1241 | return this._passThroughRuleName;
|
1242 | },
|
1243 | name: function() {
|
1244 | return this.variantNodeClassName + "Variant";
|
1245 | },
|
1246 | numVariants: function() {
|
1247 | return this.rule.numVariants;
|
1248 | },
|
1249 | patternElements: function() {
|
1250 | return this._patternElements || (this._patternElements = this._generatePatternElements());
|
1251 | }
|
1252 | });
|
1253 |
|
1254 | RuleVariant.prototype._generatePatternElements = function() {
|
1255 | var part, parts, pes;
|
1256 | pes = (function() {
|
1257 | var i, len, results;
|
1258 | if (isString(this.pattern)) {
|
1259 | parts = this.pattern.match(allPatternElementsRegExp);
|
1260 | if (!parts) {
|
1261 | throw new Error("no pattern-parts found in: " + (inspect(this.pattern)));
|
1262 | }
|
1263 | results = [];
|
1264 | for (i = 0, len = parts.length; i < len; i++) {
|
1265 | part = parts[i];
|
1266 | results.push(new PatternElement(part, {
|
1267 | ruleVariant: this
|
1268 | }));
|
1269 | }
|
1270 | return results;
|
1271 | } else {
|
1272 | return [
|
1273 | new PatternElement(this.pattern, {
|
1274 | ruleVariant: this
|
1275 | })
|
1276 | ];
|
1277 | }
|
1278 | }).call(this);
|
1279 | pes = compactFlatten(pes);
|
1280 | if (pes.length === 1 && pes[0].isBasicRulePattern) {
|
1281 | this.passThroughRuleName = pes[0].ruleName;
|
1282 | }
|
1283 | return pes;
|
1284 | };
|
1285 |
|
1286 | RuleVariant.prototype.inspect = function() {
|
1287 | return this.toString();
|
1288 | };
|
1289 |
|
1290 | RuleVariant.prototype.toString = function() {
|
1291 | return this._toString || (this._toString = this.name + ": " + this.patternString);
|
1292 | };
|
1293 |
|
1294 | RuleVariant.getter({
|
1295 | patternString: function() {
|
1296 | return this.pattern || (this.options.parse && 'function()');
|
1297 | }
|
1298 | });
|
1299 |
|
1300 |
|
1301 | |
1302 |
|
1303 |
|
1304 |
|
1305 | RuleVariant.prototype.parse = function(parentNode) {
|
1306 | var activeRuleVariantParserOffsets, i, len, name, nextOffset, parser, patternElement, previousActiveRuleVariantParserOffset, ref2, scratchNode;
|
1307 | name = this.name;
|
1308 | parser = parentNode.parser, nextOffset = parentNode.nextOffset;
|
1309 | activeRuleVariantParserOffsets = parser.activeRuleVariantParserOffsets;
|
1310 | if (nextOffset === (previousActiveRuleVariantParserOffset = activeRuleVariantParserOffsets[name])) {
|
1311 | throw new Error("leftRecursion detected: RuleVariant: " + name + ", offset: " + nextOffset);
|
1312 | }
|
1313 | activeRuleVariantParserOffsets[name] = nextOffset;
|
1314 | try {
|
1315 | Stats.add("parseVariant");
|
1316 | scratchNode = ScratchNode.checkout(parentNode, this);
|
1317 | parser = parentNode.parser;
|
1318 | ref2 = this.patternElements;
|
1319 | for (i = 0, len = ref2.length; i < len; i++) {
|
1320 | patternElement = ref2[i];
|
1321 | if (!parser.tryPatternElement(patternElement, scratchNode, this)) {
|
1322 | scratchNode.checkin();
|
1323 | return false;
|
1324 | }
|
1325 | }
|
1326 | scratchNode.checkin();
|
1327 | return scratchNode.getRealNode();
|
1328 | } finally {
|
1329 | activeRuleVariantParserOffsets[name] = previousActiveRuleVariantParserOffset;
|
1330 | }
|
1331 | };
|
1332 |
|
1333 | RuleVariant.getter({
|
1334 | variantNodeClassName: function() {
|
1335 | var baseName, ref2;
|
1336 | if (this._variantNodeClassName) {
|
1337 | return this._variantNodeClassName;
|
1338 | }
|
1339 | baseName = upperCamelCase(this.rule.name) + "Rule" + (this.pattern ? upperCamelCase(((ref2 = ("" + this.pattern).match(/[a-zA-Z0-9_]+/g)) != null ? ref2.join('_') : void 0) || "") : this.parse ? "CustomParser" : void 0);
|
1340 | return this._variantNodeClassName = baseName;
|
1341 | }
|
1342 | });
|
1343 |
|
1344 |
|
1345 | |
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 | RuleVariant.prototype._initVariantNodeClass = function(options) {
|
1356 | var nodeBaseClass, nodeSubclassOptions, rule;
|
1357 | rule = options.rule;
|
1358 | nodeSubclassOptions = options.node || options.nodeClass || options;
|
1359 | nodeBaseClass = options["extends"] || options.baseClass || options.nodeBaseClass || Node;
|
1360 | return this.VariantNodeClass = (typeof nodeClass !== "undefined" && nodeClass !== null ? nodeClass.prototype : void 0) instanceof Node ? nodeClass : nodeBaseClass.createSubclass(merge({
|
1361 | name: this.variantNodeClassName,
|
1362 | ruleVarient: this.ruleVarient
|
1363 | }, nodeSubclassOptions));
|
1364 | };
|
1365 |
|
1366 | return RuleVariant;
|
1367 |
|
1368 | })(BaseClass);
|
1369 |
|
1370 |
|
1371 | }),
|
1372 |
|
1373 | (function(module, exports, __webpack_require__) {
|
1374 |
|
1375 | var Tools, peek;
|
1376 |
|
1377 | peek = __webpack_require__(0).peek;
|
1378 |
|
1379 | module.exports = Tools = (function() {
|
1380 | var getLineColumn;
|
1381 |
|
1382 | function Tools() {}
|
1383 |
|
1384 | Tools.getLineColumn = getLineColumn = function(string, offset) {
|
1385 | var lines;
|
1386 | if (string.length === 0 || offset === 0) {
|
1387 | return {
|
1388 | line: 1,
|
1389 | column: 1
|
1390 | };
|
1391 | }
|
1392 | lines = (string.slice(0, offset)).split("\n");
|
1393 | return {
|
1394 | line: lines.length,
|
1395 | column: peek(lines).length + 1
|
1396 | };
|
1397 | };
|
1398 |
|
1399 | Tools.getLineColumnString = function(string, offset) {
|
1400 | var column, line, ref;
|
1401 | ref = getLineColumn(string, offset), line = ref.line, column = ref.column;
|
1402 | return line + ":" + column;
|
1403 | };
|
1404 |
|
1405 | return Tools;
|
1406 |
|
1407 | })();
|
1408 |
|
1409 |
|
1410 | }),
|
1411 |
|
1412 | (function(module, exports, __webpack_require__) {
|
1413 |
|
1414 |
|
1415 | var cssKeywords = __webpack_require__(18);
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 | var reverseKeywords = {};
|
1422 | for (var key in cssKeywords) {
|
1423 | if (cssKeywords.hasOwnProperty(key)) {
|
1424 | reverseKeywords[cssKeywords[key]] = key;
|
1425 | }
|
1426 | }
|
1427 |
|
1428 | var convert = module.exports = {
|
1429 | rgb: {channels: 3, labels: 'rgb'},
|
1430 | hsl: {channels: 3, labels: 'hsl'},
|
1431 | hsv: {channels: 3, labels: 'hsv'},
|
1432 | hwb: {channels: 3, labels: 'hwb'},
|
1433 | cmyk: {channels: 4, labels: 'cmyk'},
|
1434 | xyz: {channels: 3, labels: 'xyz'},
|
1435 | lab: {channels: 3, labels: 'lab'},
|
1436 | lch: {channels: 3, labels: 'lch'},
|
1437 | hex: {channels: 1, labels: ['hex']},
|
1438 | keyword: {channels: 1, labels: ['keyword']},
|
1439 | ansi16: {channels: 1, labels: ['ansi16']},
|
1440 | ansi256: {channels: 1, labels: ['ansi256']},
|
1441 | hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
1442 | apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
1443 | gray: {channels: 1, labels: ['gray']}
|
1444 | };
|
1445 |
|
1446 |
|
1447 | for (var model in convert) {
|
1448 | if (convert.hasOwnProperty(model)) {
|
1449 | if (!('channels' in convert[model])) {
|
1450 | throw new Error('missing channels property: ' + model);
|
1451 | }
|
1452 |
|
1453 | if (!('labels' in convert[model])) {
|
1454 | throw new Error('missing channel labels property: ' + model);
|
1455 | }
|
1456 |
|
1457 | if (convert[model].labels.length !== convert[model].channels) {
|
1458 | throw new Error('channel and label counts mismatch: ' + model);
|
1459 | }
|
1460 |
|
1461 | var channels = convert[model].channels;
|
1462 | var labels = convert[model].labels;
|
1463 | delete convert[model].channels;
|
1464 | delete convert[model].labels;
|
1465 | Object.defineProperty(convert[model], 'channels', {value: channels});
|
1466 | Object.defineProperty(convert[model], 'labels', {value: labels});
|
1467 | }
|
1468 | }
|
1469 |
|
1470 | convert.rgb.hsl = function (rgb) {
|
1471 | var r = rgb[0] / 255;
|
1472 | var g = rgb[1] / 255;
|
1473 | var b = rgb[2] / 255;
|
1474 | var min = Math.min(r, g, b);
|
1475 | var max = Math.max(r, g, b);
|
1476 | var delta = max - min;
|
1477 | var h;
|
1478 | var s;
|
1479 | var l;
|
1480 |
|
1481 | if (max === min) {
|
1482 | h = 0;
|
1483 | } else if (r === max) {
|
1484 | h = (g - b) / delta;
|
1485 | } else if (g === max) {
|
1486 | h = 2 + (b - r) / delta;
|
1487 | } else if (b === max) {
|
1488 | h = 4 + (r - g) / delta;
|
1489 | }
|
1490 |
|
1491 | h = Math.min(h * 60, 360);
|
1492 |
|
1493 | if (h < 0) {
|
1494 | h += 360;
|
1495 | }
|
1496 |
|
1497 | l = (min + max) / 2;
|
1498 |
|
1499 | if (max === min) {
|
1500 | s = 0;
|
1501 | } else if (l <= 0.5) {
|
1502 | s = delta / (max + min);
|
1503 | } else {
|
1504 | s = delta / (2 - max - min);
|
1505 | }
|
1506 |
|
1507 | return [h, s * 100, l * 100];
|
1508 | };
|
1509 |
|
1510 | convert.rgb.hsv = function (rgb) {
|
1511 | var r = rgb[0];
|
1512 | var g = rgb[1];
|
1513 | var b = rgb[2];
|
1514 | var min = Math.min(r, g, b);
|
1515 | var max = Math.max(r, g, b);
|
1516 | var delta = max - min;
|
1517 | var h;
|
1518 | var s;
|
1519 | var v;
|
1520 |
|
1521 | if (max === 0) {
|
1522 | s = 0;
|
1523 | } else {
|
1524 | s = (delta / max * 1000) / 10;
|
1525 | }
|
1526 |
|
1527 | if (max === min) {
|
1528 | h = 0;
|
1529 | } else if (r === max) {
|
1530 | h = (g - b) / delta;
|
1531 | } else if (g === max) {
|
1532 | h = 2 + (b - r) / delta;
|
1533 | } else if (b === max) {
|
1534 | h = 4 + (r - g) / delta;
|
1535 | }
|
1536 |
|
1537 | h = Math.min(h * 60, 360);
|
1538 |
|
1539 | if (h < 0) {
|
1540 | h += 360;
|
1541 | }
|
1542 |
|
1543 | v = ((max / 255) * 1000) / 10;
|
1544 |
|
1545 | return [h, s, v];
|
1546 | };
|
1547 |
|
1548 | convert.rgb.hwb = function (rgb) {
|
1549 | var r = rgb[0];
|
1550 | var g = rgb[1];
|
1551 | var b = rgb[2];
|
1552 | var h = convert.rgb.hsl(rgb)[0];
|
1553 | var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
1554 |
|
1555 | b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
1556 |
|
1557 | return [h, w * 100, b * 100];
|
1558 | };
|
1559 |
|
1560 | convert.rgb.cmyk = function (rgb) {
|
1561 | var r = rgb[0] / 255;
|
1562 | var g = rgb[1] / 255;
|
1563 | var b = rgb[2] / 255;
|
1564 | var c;
|
1565 | var m;
|
1566 | var y;
|
1567 | var k;
|
1568 |
|
1569 | k = Math.min(1 - r, 1 - g, 1 - b);
|
1570 | c = (1 - r - k) / (1 - k) || 0;
|
1571 | m = (1 - g - k) / (1 - k) || 0;
|
1572 | y = (1 - b - k) / (1 - k) || 0;
|
1573 |
|
1574 | return [c * 100, m * 100, y * 100, k * 100];
|
1575 | };
|
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 | function comparativeDistance(x, y) {
|
1581 | return (
|
1582 | Math.pow(x[0] - y[0], 2) +
|
1583 | Math.pow(x[1] - y[1], 2) +
|
1584 | Math.pow(x[2] - y[2], 2)
|
1585 | );
|
1586 | }
|
1587 |
|
1588 | convert.rgb.keyword = function (rgb) {
|
1589 | var reversed = reverseKeywords[rgb];
|
1590 | if (reversed) {
|
1591 | return reversed;
|
1592 | }
|
1593 |
|
1594 | var currentClosestDistance = Infinity;
|
1595 | var currentClosestKeyword;
|
1596 |
|
1597 | for (var keyword in cssKeywords) {
|
1598 | if (cssKeywords.hasOwnProperty(keyword)) {
|
1599 | var value = cssKeywords[keyword];
|
1600 |
|
1601 |
|
1602 | var distance = comparativeDistance(rgb, value);
|
1603 |
|
1604 |
|
1605 | if (distance < currentClosestDistance) {
|
1606 | currentClosestDistance = distance;
|
1607 | currentClosestKeyword = keyword;
|
1608 | }
|
1609 | }
|
1610 | }
|
1611 |
|
1612 | return currentClosestKeyword;
|
1613 | };
|
1614 |
|
1615 | convert.keyword.rgb = function (keyword) {
|
1616 | return cssKeywords[keyword];
|
1617 | };
|
1618 |
|
1619 | convert.rgb.xyz = function (rgb) {
|
1620 | var r = rgb[0] / 255;
|
1621 | var g = rgb[1] / 255;
|
1622 | var b = rgb[2] / 255;
|
1623 |
|
1624 |
|
1625 | r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
|
1626 | g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
|
1627 | b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
|
1628 |
|
1629 | var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
1630 | var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
1631 | var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
1632 |
|
1633 | return [x * 100, y * 100, z * 100];
|
1634 | };
|
1635 |
|
1636 | convert.rgb.lab = function (rgb) {
|
1637 | var xyz = convert.rgb.xyz(rgb);
|
1638 | var x = xyz[0];
|
1639 | var y = xyz[1];
|
1640 | var z = xyz[2];
|
1641 | var l;
|
1642 | var a;
|
1643 | var b;
|
1644 |
|
1645 | x /= 95.047;
|
1646 | y /= 100;
|
1647 | z /= 108.883;
|
1648 |
|
1649 | x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
|
1650 | y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
|
1651 | z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
|
1652 |
|
1653 | l = (116 * y) - 16;
|
1654 | a = 500 * (x - y);
|
1655 | b = 200 * (y - z);
|
1656 |
|
1657 | return [l, a, b];
|
1658 | };
|
1659 |
|
1660 | convert.hsl.rgb = function (hsl) {
|
1661 | var h = hsl[0] / 360;
|
1662 | var s = hsl[1] / 100;
|
1663 | var l = hsl[2] / 100;
|
1664 | var t1;
|
1665 | var t2;
|
1666 | var t3;
|
1667 | var rgb;
|
1668 | var val;
|
1669 |
|
1670 | if (s === 0) {
|
1671 | val = l * 255;
|
1672 | return [val, val, val];
|
1673 | }
|
1674 |
|
1675 | if (l < 0.5) {
|
1676 | t2 = l * (1 + s);
|
1677 | } else {
|
1678 | t2 = l + s - l * s;
|
1679 | }
|
1680 |
|
1681 | t1 = 2 * l - t2;
|
1682 |
|
1683 | rgb = [0, 0, 0];
|
1684 | for (var i = 0; i < 3; i++) {
|
1685 | t3 = h + 1 / 3 * -(i - 1);
|
1686 | if (t3 < 0) {
|
1687 | t3++;
|
1688 | }
|
1689 | if (t3 > 1) {
|
1690 | t3--;
|
1691 | }
|
1692 |
|
1693 | if (6 * t3 < 1) {
|
1694 | val = t1 + (t2 - t1) * 6 * t3;
|
1695 | } else if (2 * t3 < 1) {
|
1696 | val = t2;
|
1697 | } else if (3 * t3 < 2) {
|
1698 | val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
1699 | } else {
|
1700 | val = t1;
|
1701 | }
|
1702 |
|
1703 | rgb[i] = val * 255;
|
1704 | }
|
1705 |
|
1706 | return rgb;
|
1707 | };
|
1708 |
|
1709 | convert.hsl.hsv = function (hsl) {
|
1710 | var h = hsl[0];
|
1711 | var s = hsl[1] / 100;
|
1712 | var l = hsl[2] / 100;
|
1713 | var smin = s;
|
1714 | var lmin = Math.max(l, 0.01);
|
1715 | var sv;
|
1716 | var v;
|
1717 |
|
1718 | l *= 2;
|
1719 | s *= (l <= 1) ? l : 2 - l;
|
1720 | smin *= lmin <= 1 ? lmin : 2 - lmin;
|
1721 | v = (l + s) / 2;
|
1722 | sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
1723 |
|
1724 | return [h, sv * 100, v * 100];
|
1725 | };
|
1726 |
|
1727 | convert.hsv.rgb = function (hsv) {
|
1728 | var h = hsv[0] / 60;
|
1729 | var s = hsv[1] / 100;
|
1730 | var v = hsv[2] / 100;
|
1731 | var hi = Math.floor(h) % 6;
|
1732 |
|
1733 | var f = h - Math.floor(h);
|
1734 | var p = 255 * v * (1 - s);
|
1735 | var q = 255 * v * (1 - (s * f));
|
1736 | var t = 255 * v * (1 - (s * (1 - f)));
|
1737 | v *= 255;
|
1738 |
|
1739 | switch (hi) {
|
1740 | case 0:
|
1741 | return [v, t, p];
|
1742 | case 1:
|
1743 | return [q, v, p];
|
1744 | case 2:
|
1745 | return [p, v, t];
|
1746 | case 3:
|
1747 | return [p, q, v];
|
1748 | case 4:
|
1749 | return [t, p, v];
|
1750 | case 5:
|
1751 | return [v, p, q];
|
1752 | }
|
1753 | };
|
1754 |
|
1755 | convert.hsv.hsl = function (hsv) {
|
1756 | var h = hsv[0];
|
1757 | var s = hsv[1] / 100;
|
1758 | var v = hsv[2] / 100;
|
1759 | var vmin = Math.max(v, 0.01);
|
1760 | var lmin;
|
1761 | var sl;
|
1762 | var l;
|
1763 |
|
1764 | l = (2 - s) * v;
|
1765 | lmin = (2 - s) * vmin;
|
1766 | sl = s * vmin;
|
1767 | sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
1768 | sl = sl || 0;
|
1769 | l /= 2;
|
1770 |
|
1771 | return [h, sl * 100, l * 100];
|
1772 | };
|
1773 |
|
1774 |
|
1775 | convert.hwb.rgb = function (hwb) {
|
1776 | var h = hwb[0] / 360;
|
1777 | var wh = hwb[1] / 100;
|
1778 | var bl = hwb[2] / 100;
|
1779 | var ratio = wh + bl;
|
1780 | var i;
|
1781 | var v;
|
1782 | var f;
|
1783 | var n;
|
1784 |
|
1785 |
|
1786 | if (ratio > 1) {
|
1787 | wh /= ratio;
|
1788 | bl /= ratio;
|
1789 | }
|
1790 |
|
1791 | i = Math.floor(6 * h);
|
1792 | v = 1 - bl;
|
1793 | f = 6 * h - i;
|
1794 |
|
1795 | if ((i & 0x01) !== 0) {
|
1796 | f = 1 - f;
|
1797 | }
|
1798 |
|
1799 | n = wh + f * (v - wh);
|
1800 |
|
1801 | var r;
|
1802 | var g;
|
1803 | var b;
|
1804 | switch (i) {
|
1805 | default:
|
1806 | case 6:
|
1807 | case 0: r = v; g = n; b = wh; break;
|
1808 | case 1: r = n; g = v; b = wh; break;
|
1809 | case 2: r = wh; g = v; b = n; break;
|
1810 | case 3: r = wh; g = n; b = v; break;
|
1811 | case 4: r = n; g = wh; b = v; break;
|
1812 | case 5: r = v; g = wh; b = n; break;
|
1813 | }
|
1814 |
|
1815 | return [r * 255, g * 255, b * 255];
|
1816 | };
|
1817 |
|
1818 | convert.cmyk.rgb = function (cmyk) {
|
1819 | var c = cmyk[0] / 100;
|
1820 | var m = cmyk[1] / 100;
|
1821 | var y = cmyk[2] / 100;
|
1822 | var k = cmyk[3] / 100;
|
1823 | var r;
|
1824 | var g;
|
1825 | var b;
|
1826 |
|
1827 | r = 1 - Math.min(1, c * (1 - k) + k);
|
1828 | g = 1 - Math.min(1, m * (1 - k) + k);
|
1829 | b = 1 - Math.min(1, y * (1 - k) + k);
|
1830 |
|
1831 | return [r * 255, g * 255, b * 255];
|
1832 | };
|
1833 |
|
1834 | convert.xyz.rgb = function (xyz) {
|
1835 | var x = xyz[0] / 100;
|
1836 | var y = xyz[1] / 100;
|
1837 | var z = xyz[2] / 100;
|
1838 | var r;
|
1839 | var g;
|
1840 | var b;
|
1841 |
|
1842 | r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
1843 | g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
1844 | b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
1845 |
|
1846 |
|
1847 | r = r > 0.0031308
|
1848 | ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
|
1849 | : r * 12.92;
|
1850 |
|
1851 | g = g > 0.0031308
|
1852 | ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
|
1853 | : g * 12.92;
|
1854 |
|
1855 | b = b > 0.0031308
|
1856 | ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
|
1857 | : b * 12.92;
|
1858 |
|
1859 | r = Math.min(Math.max(0, r), 1);
|
1860 | g = Math.min(Math.max(0, g), 1);
|
1861 | b = Math.min(Math.max(0, b), 1);
|
1862 |
|
1863 | return [r * 255, g * 255, b * 255];
|
1864 | };
|
1865 |
|
1866 | convert.xyz.lab = function (xyz) {
|
1867 | var x = xyz[0];
|
1868 | var y = xyz[1];
|
1869 | var z = xyz[2];
|
1870 | var l;
|
1871 | var a;
|
1872 | var b;
|
1873 |
|
1874 | x /= 95.047;
|
1875 | y /= 100;
|
1876 | z /= 108.883;
|
1877 |
|
1878 | x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
|
1879 | y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
|
1880 | z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
|
1881 |
|
1882 | l = (116 * y) - 16;
|
1883 | a = 500 * (x - y);
|
1884 | b = 200 * (y - z);
|
1885 |
|
1886 | return [l, a, b];
|
1887 | };
|
1888 |
|
1889 | convert.lab.xyz = function (lab) {
|
1890 | var l = lab[0];
|
1891 | var a = lab[1];
|
1892 | var b = lab[2];
|
1893 | var x;
|
1894 | var y;
|
1895 | var z;
|
1896 |
|
1897 | y = (l + 16) / 116;
|
1898 | x = a / 500 + y;
|
1899 | z = y - b / 200;
|
1900 |
|
1901 | var y2 = Math.pow(y, 3);
|
1902 | var x2 = Math.pow(x, 3);
|
1903 | var z2 = Math.pow(z, 3);
|
1904 | y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
1905 | x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
1906 | z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
1907 |
|
1908 | x *= 95.047;
|
1909 | y *= 100;
|
1910 | z *= 108.883;
|
1911 |
|
1912 | return [x, y, z];
|
1913 | };
|
1914 |
|
1915 | convert.lab.lch = function (lab) {
|
1916 | var l = lab[0];
|
1917 | var a = lab[1];
|
1918 | var b = lab[2];
|
1919 | var hr;
|
1920 | var h;
|
1921 | var c;
|
1922 |
|
1923 | hr = Math.atan2(b, a);
|
1924 | h = hr * 360 / 2 / Math.PI;
|
1925 |
|
1926 | if (h < 0) {
|
1927 | h += 360;
|
1928 | }
|
1929 |
|
1930 | c = Math.sqrt(a * a + b * b);
|
1931 |
|
1932 | return [l, c, h];
|
1933 | };
|
1934 |
|
1935 | convert.lch.lab = function (lch) {
|
1936 | var l = lch[0];
|
1937 | var c = lch[1];
|
1938 | var h = lch[2];
|
1939 | var a;
|
1940 | var b;
|
1941 | var hr;
|
1942 |
|
1943 | hr = h / 360 * 2 * Math.PI;
|
1944 | a = c * Math.cos(hr);
|
1945 | b = c * Math.sin(hr);
|
1946 |
|
1947 | return [l, a, b];
|
1948 | };
|
1949 |
|
1950 | convert.rgb.ansi16 = function (args) {
|
1951 | var r = args[0];
|
1952 | var g = args[1];
|
1953 | var b = args[2];
|
1954 | var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2];
|
1955 |
|
1956 | value = Math.round(value / 50);
|
1957 |
|
1958 | if (value === 0) {
|
1959 | return 30;
|
1960 | }
|
1961 |
|
1962 | var ansi = 30
|
1963 | + ((Math.round(b / 255) << 2)
|
1964 | | (Math.round(g / 255) << 1)
|
1965 | | Math.round(r / 255));
|
1966 |
|
1967 | if (value === 2) {
|
1968 | ansi += 60;
|
1969 | }
|
1970 |
|
1971 | return ansi;
|
1972 | };
|
1973 |
|
1974 | convert.hsv.ansi16 = function (args) {
|
1975 |
|
1976 |
|
1977 | return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
1978 | };
|
1979 |
|
1980 | convert.rgb.ansi256 = function (args) {
|
1981 | var r = args[0];
|
1982 | var g = args[1];
|
1983 | var b = args[2];
|
1984 |
|
1985 |
|
1986 |
|
1987 | if (r === g && g === b) {
|
1988 | if (r < 8) {
|
1989 | return 16;
|
1990 | }
|
1991 |
|
1992 | if (r > 248) {
|
1993 | return 231;
|
1994 | }
|
1995 |
|
1996 | return Math.round(((r - 8) / 247) * 24) + 232;
|
1997 | }
|
1998 |
|
1999 | var ansi = 16
|
2000 | + (36 * Math.round(r / 255 * 5))
|
2001 | + (6 * Math.round(g / 255 * 5))
|
2002 | + Math.round(b / 255 * 5);
|
2003 |
|
2004 | return ansi;
|
2005 | };
|
2006 |
|
2007 | convert.ansi16.rgb = function (args) {
|
2008 | var color = args % 10;
|
2009 |
|
2010 |
|
2011 | if (color === 0 || color === 7) {
|
2012 | if (args > 50) {
|
2013 | color += 3.5;
|
2014 | }
|
2015 |
|
2016 | color = color / 10.5 * 255;
|
2017 |
|
2018 | return [color, color, color];
|
2019 | }
|
2020 |
|
2021 | var mult = (~~(args > 50) + 1) * 0.5;
|
2022 | var r = ((color & 1) * mult) * 255;
|
2023 | var g = (((color >> 1) & 1) * mult) * 255;
|
2024 | var b = (((color >> 2) & 1) * mult) * 255;
|
2025 |
|
2026 | return [r, g, b];
|
2027 | };
|
2028 |
|
2029 | convert.ansi256.rgb = function (args) {
|
2030 |
|
2031 | if (args >= 232) {
|
2032 | var c = (args - 232) * 10 + 8;
|
2033 | return [c, c, c];
|
2034 | }
|
2035 |
|
2036 | args -= 16;
|
2037 |
|
2038 | var rem;
|
2039 | var r = Math.floor(args / 36) / 5 * 255;
|
2040 | var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
2041 | var b = (rem % 6) / 5 * 255;
|
2042 |
|
2043 | return [r, g, b];
|
2044 | };
|
2045 |
|
2046 | convert.rgb.hex = function (args) {
|
2047 | var integer = ((Math.round(args[0]) & 0xFF) << 16)
|
2048 | + ((Math.round(args[1]) & 0xFF) << 8)
|
2049 | + (Math.round(args[2]) & 0xFF);
|
2050 |
|
2051 | var string = integer.toString(16).toUpperCase();
|
2052 | return '000000'.substring(string.length) + string;
|
2053 | };
|
2054 |
|
2055 | convert.hex.rgb = function (args) {
|
2056 | var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
2057 | if (!match) {
|
2058 | return [0, 0, 0];
|
2059 | }
|
2060 |
|
2061 | var colorString = match[0];
|
2062 |
|
2063 | if (match[0].length === 3) {
|
2064 | colorString = colorString.split('').map(function (char) {
|
2065 | return char + char;
|
2066 | }).join('');
|
2067 | }
|
2068 |
|
2069 | var integer = parseInt(colorString, 16);
|
2070 | var r = (integer >> 16) & 0xFF;
|
2071 | var g = (integer >> 8) & 0xFF;
|
2072 | var b = integer & 0xFF;
|
2073 |
|
2074 | return [r, g, b];
|
2075 | };
|
2076 |
|
2077 | convert.rgb.hcg = function (rgb) {
|
2078 | var r = rgb[0] / 255;
|
2079 | var g = rgb[1] / 255;
|
2080 | var b = rgb[2] / 255;
|
2081 | var max = Math.max(Math.max(r, g), b);
|
2082 | var min = Math.min(Math.min(r, g), b);
|
2083 | var chroma = (max - min);
|
2084 | var grayscale;
|
2085 | var hue;
|
2086 |
|
2087 | if (chroma < 1) {
|
2088 | grayscale = min / (1 - chroma);
|
2089 | } else {
|
2090 | grayscale = 0;
|
2091 | }
|
2092 |
|
2093 | if (chroma <= 0) {
|
2094 | hue = 0;
|
2095 | } else
|
2096 | if (max === r) {
|
2097 | hue = ((g - b) / chroma) % 6;
|
2098 | } else
|
2099 | if (max === g) {
|
2100 | hue = 2 + (b - r) / chroma;
|
2101 | } else {
|
2102 | hue = 4 + (r - g) / chroma + 4;
|
2103 | }
|
2104 |
|
2105 | hue /= 6;
|
2106 | hue %= 1;
|
2107 |
|
2108 | return [hue * 360, chroma * 100, grayscale * 100];
|
2109 | };
|
2110 |
|
2111 | convert.hsl.hcg = function (hsl) {
|
2112 | var s = hsl[1] / 100;
|
2113 | var l = hsl[2] / 100;
|
2114 | var c = 1;
|
2115 | var f = 0;
|
2116 |
|
2117 | if (l < 0.5) {
|
2118 | c = 2.0 * s * l;
|
2119 | } else {
|
2120 | c = 2.0 * s * (1.0 - l);
|
2121 | }
|
2122 |
|
2123 | if (c < 1.0) {
|
2124 | f = (l - 0.5 * c) / (1.0 - c);
|
2125 | }
|
2126 |
|
2127 | return [hsl[0], c * 100, f * 100];
|
2128 | };
|
2129 |
|
2130 | convert.hsv.hcg = function (hsv) {
|
2131 | var s = hsv[1] / 100;
|
2132 | var v = hsv[2] / 100;
|
2133 |
|
2134 | var c = s * v;
|
2135 | var f = 0;
|
2136 |
|
2137 | if (c < 1.0) {
|
2138 | f = (v - c) / (1 - c);
|
2139 | }
|
2140 |
|
2141 | return [hsv[0], c * 100, f * 100];
|
2142 | };
|
2143 |
|
2144 | convert.hcg.rgb = function (hcg) {
|
2145 | var h = hcg[0] / 360;
|
2146 | var c = hcg[1] / 100;
|
2147 | var g = hcg[2] / 100;
|
2148 |
|
2149 | if (c === 0.0) {
|
2150 | return [g * 255, g * 255, g * 255];
|
2151 | }
|
2152 |
|
2153 | var pure = [0, 0, 0];
|
2154 | var hi = (h % 1) * 6;
|
2155 | var v = hi % 1;
|
2156 | var w = 1 - v;
|
2157 | var mg = 0;
|
2158 |
|
2159 | switch (Math.floor(hi)) {
|
2160 | case 0:
|
2161 | pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
2162 | case 1:
|
2163 | pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
2164 | case 2:
|
2165 | pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
2166 | case 3:
|
2167 | pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
2168 | case 4:
|
2169 | pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
2170 | default:
|
2171 | pure[0] = 1; pure[1] = 0; pure[2] = w;
|
2172 | }
|
2173 |
|
2174 | mg = (1.0 - c) * g;
|
2175 |
|
2176 | return [
|
2177 | (c * pure[0] + mg) * 255,
|
2178 | (c * pure[1] + mg) * 255,
|
2179 | (c * pure[2] + mg) * 255
|
2180 | ];
|
2181 | };
|
2182 |
|
2183 | convert.hcg.hsv = function (hcg) {
|
2184 | var c = hcg[1] / 100;
|
2185 | var g = hcg[2] / 100;
|
2186 |
|
2187 | var v = c + g * (1.0 - c);
|
2188 | var f = 0;
|
2189 |
|
2190 | if (v > 0.0) {
|
2191 | f = c / v;
|
2192 | }
|
2193 |
|
2194 | return [hcg[0], f * 100, v * 100];
|
2195 | };
|
2196 |
|
2197 | convert.hcg.hsl = function (hcg) {
|
2198 | var c = hcg[1] / 100;
|
2199 | var g = hcg[2] / 100;
|
2200 |
|
2201 | var l = g * (1.0 - c) + 0.5 * c;
|
2202 | var s = 0;
|
2203 |
|
2204 | if (l > 0.0 && l < 0.5) {
|
2205 | s = c / (2 * l);
|
2206 | } else
|
2207 | if (l >= 0.5 && l < 1.0) {
|
2208 | s = c / (2 * (1 - l));
|
2209 | }
|
2210 |
|
2211 | return [hcg[0], s * 100, l * 100];
|
2212 | };
|
2213 |
|
2214 | convert.hcg.hwb = function (hcg) {
|
2215 | var c = hcg[1] / 100;
|
2216 | var g = hcg[2] / 100;
|
2217 | var v = c + g * (1.0 - c);
|
2218 | return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
2219 | };
|
2220 |
|
2221 | convert.hwb.hcg = function (hwb) {
|
2222 | var w = hwb[1] / 100;
|
2223 | var b = hwb[2] / 100;
|
2224 | var v = 1 - b;
|
2225 | var c = v - w;
|
2226 | var g = 0;
|
2227 |
|
2228 | if (c < 1) {
|
2229 | g = (v - c) / (1 - c);
|
2230 | }
|
2231 |
|
2232 | return [hwb[0], c * 100, g * 100];
|
2233 | };
|
2234 |
|
2235 | convert.apple.rgb = function (apple) {
|
2236 | return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
2237 | };
|
2238 |
|
2239 | convert.rgb.apple = function (rgb) {
|
2240 | return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
2241 | };
|
2242 |
|
2243 | convert.gray.rgb = function (args) {
|
2244 | return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
2245 | };
|
2246 |
|
2247 | convert.gray.hsl = convert.gray.hsv = function (args) {
|
2248 | return [0, 0, args[0]];
|
2249 | };
|
2250 |
|
2251 | convert.gray.hwb = function (gray) {
|
2252 | return [0, 100, gray[0]];
|
2253 | };
|
2254 |
|
2255 | convert.gray.cmyk = function (gray) {
|
2256 | return [0, 0, 0, gray[0]];
|
2257 | };
|
2258 |
|
2259 | convert.gray.lab = function (gray) {
|
2260 | return [gray[0], 0, 0];
|
2261 | };
|
2262 |
|
2263 | convert.gray.hex = function (gray) {
|
2264 | var val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
2265 | var integer = (val << 16) + (val << 8) + val;
|
2266 |
|
2267 | var string = integer.toString(16).toUpperCase();
|
2268 | return '000000'.substring(string.length) + string;
|
2269 | };
|
2270 |
|
2271 | convert.rgb.gray = function (rgb) {
|
2272 | var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
2273 | return [val / 255 * 100];
|
2274 | };
|
2275 |
|
2276 |
|
2277 | }),
|
2278 |
|
2279 | (function(module, exports) {
|
2280 |
|
2281 | module.exports = {
|
2282 | "aliceblue": [240, 248, 255],
|
2283 | "antiquewhite": [250, 235, 215],
|
2284 | "aqua": [0, 255, 255],
|
2285 | "aquamarine": [127, 255, 212],
|
2286 | "azure": [240, 255, 255],
|
2287 | "beige": [245, 245, 220],
|
2288 | "bisque": [255, 228, 196],
|
2289 | "black": [0, 0, 0],
|
2290 | "blanchedalmond": [255, 235, 205],
|
2291 | "blue": [0, 0, 255],
|
2292 | "blueviolet": [138, 43, 226],
|
2293 | "brown": [165, 42, 42],
|
2294 | "burlywood": [222, 184, 135],
|
2295 | "cadetblue": [95, 158, 160],
|
2296 | "chartreuse": [127, 255, 0],
|
2297 | "chocolate": [210, 105, 30],
|
2298 | "coral": [255, 127, 80],
|
2299 | "cornflowerblue": [100, 149, 237],
|
2300 | "cornsilk": [255, 248, 220],
|
2301 | "crimson": [220, 20, 60],
|
2302 | "cyan": [0, 255, 255],
|
2303 | "darkblue": [0, 0, 139],
|
2304 | "darkcyan": [0, 139, 139],
|
2305 | "darkgoldenrod": [184, 134, 11],
|
2306 | "darkgray": [169, 169, 169],
|
2307 | "darkgreen": [0, 100, 0],
|
2308 | "darkgrey": [169, 169, 169],
|
2309 | "darkkhaki": [189, 183, 107],
|
2310 | "darkmagenta": [139, 0, 139],
|
2311 | "darkolivegreen": [85, 107, 47],
|
2312 | "darkorange": [255, 140, 0],
|
2313 | "darkorchid": [153, 50, 204],
|
2314 | "darkred": [139, 0, 0],
|
2315 | "darksalmon": [233, 150, 122],
|
2316 | "darkseagreen": [143, 188, 143],
|
2317 | "darkslateblue": [72, 61, 139],
|
2318 | "darkslategray": [47, 79, 79],
|
2319 | "darkslategrey": [47, 79, 79],
|
2320 | "darkturquoise": [0, 206, 209],
|
2321 | "darkviolet": [148, 0, 211],
|
2322 | "deeppink": [255, 20, 147],
|
2323 | "deepskyblue": [0, 191, 255],
|
2324 | "dimgray": [105, 105, 105],
|
2325 | "dimgrey": [105, 105, 105],
|
2326 | "dodgerblue": [30, 144, 255],
|
2327 | "firebrick": [178, 34, 34],
|
2328 | "floralwhite": [255, 250, 240],
|
2329 | "forestgreen": [34, 139, 34],
|
2330 | "fuchsia": [255, 0, 255],
|
2331 | "gainsboro": [220, 220, 220],
|
2332 | "ghostwhite": [248, 248, 255],
|
2333 | "gold": [255, 215, 0],
|
2334 | "goldenrod": [218, 165, 32],
|
2335 | "gray": [128, 128, 128],
|
2336 | "green": [0, 128, 0],
|
2337 | "greenyellow": [173, 255, 47],
|
2338 | "grey": [128, 128, 128],
|
2339 | "honeydew": [240, 255, 240],
|
2340 | "hotpink": [255, 105, 180],
|
2341 | "indianred": [205, 92, 92],
|
2342 | "indigo": [75, 0, 130],
|
2343 | "ivory": [255, 255, 240],
|
2344 | "khaki": [240, 230, 140],
|
2345 | "lavender": [230, 230, 250],
|
2346 | "lavenderblush": [255, 240, 245],
|
2347 | "lawngreen": [124, 252, 0],
|
2348 | "lemonchiffon": [255, 250, 205],
|
2349 | "lightblue": [173, 216, 230],
|
2350 | "lightcoral": [240, 128, 128],
|
2351 | "lightcyan": [224, 255, 255],
|
2352 | "lightgoldenrodyellow": [250, 250, 210],
|
2353 | "lightgray": [211, 211, 211],
|
2354 | "lightgreen": [144, 238, 144],
|
2355 | "lightgrey": [211, 211, 211],
|
2356 | "lightpink": [255, 182, 193],
|
2357 | "lightsalmon": [255, 160, 122],
|
2358 | "lightseagreen": [32, 178, 170],
|
2359 | "lightskyblue": [135, 206, 250],
|
2360 | "lightslategray": [119, 136, 153],
|
2361 | "lightslategrey": [119, 136, 153],
|
2362 | "lightsteelblue": [176, 196, 222],
|
2363 | "lightyellow": [255, 255, 224],
|
2364 | "lime": [0, 255, 0],
|
2365 | "limegreen": [50, 205, 50],
|
2366 | "linen": [250, 240, 230],
|
2367 | "magenta": [255, 0, 255],
|
2368 | "maroon": [128, 0, 0],
|
2369 | "mediumaquamarine": [102, 205, 170],
|
2370 | "mediumblue": [0, 0, 205],
|
2371 | "mediumorchid": [186, 85, 211],
|
2372 | "mediumpurple": [147, 112, 219],
|
2373 | "mediumseagreen": [60, 179, 113],
|
2374 | "mediumslateblue": [123, 104, 238],
|
2375 | "mediumspringgreen": [0, 250, 154],
|
2376 | "mediumturquoise": [72, 209, 204],
|
2377 | "mediumvioletred": [199, 21, 133],
|
2378 | "midnightblue": [25, 25, 112],
|
2379 | "mintcream": [245, 255, 250],
|
2380 | "mistyrose": [255, 228, 225],
|
2381 | "moccasin": [255, 228, 181],
|
2382 | "navajowhite": [255, 222, 173],
|
2383 | "navy": [0, 0, 128],
|
2384 | "oldlace": [253, 245, 230],
|
2385 | "olive": [128, 128, 0],
|
2386 | "olivedrab": [107, 142, 35],
|
2387 | "orange": [255, 165, 0],
|
2388 | "orangered": [255, 69, 0],
|
2389 | "orchid": [218, 112, 214],
|
2390 | "palegoldenrod": [238, 232, 170],
|
2391 | "palegreen": [152, 251, 152],
|
2392 | "paleturquoise": [175, 238, 238],
|
2393 | "palevioletred": [219, 112, 147],
|
2394 | "papayawhip": [255, 239, 213],
|
2395 | "peachpuff": [255, 218, 185],
|
2396 | "peru": [205, 133, 63],
|
2397 | "pink": [255, 192, 203],
|
2398 | "plum": [221, 160, 221],
|
2399 | "powderblue": [176, 224, 230],
|
2400 | "purple": [128, 0, 128],
|
2401 | "rebeccapurple": [102, 51, 153],
|
2402 | "red": [255, 0, 0],
|
2403 | "rosybrown": [188, 143, 143],
|
2404 | "royalblue": [65, 105, 225],
|
2405 | "saddlebrown": [139, 69, 19],
|
2406 | "salmon": [250, 128, 114],
|
2407 | "sandybrown": [244, 164, 96],
|
2408 | "seagreen": [46, 139, 87],
|
2409 | "seashell": [255, 245, 238],
|
2410 | "sienna": [160, 82, 45],
|
2411 | "silver": [192, 192, 192],
|
2412 | "skyblue": [135, 206, 235],
|
2413 | "slateblue": [106, 90, 205],
|
2414 | "slategray": [112, 128, 144],
|
2415 | "slategrey": [112, 128, 144],
|
2416 | "snow": [255, 250, 250],
|
2417 | "springgreen": [0, 255, 127],
|
2418 | "steelblue": [70, 130, 180],
|
2419 | "tan": [210, 180, 140],
|
2420 | "teal": [0, 128, 128],
|
2421 | "thistle": [216, 191, 216],
|
2422 | "tomato": [255, 99, 71],
|
2423 | "turquoise": [64, 224, 208],
|
2424 | "violet": [238, 130, 238],
|
2425 | "wheat": [245, 222, 179],
|
2426 | "white": [255, 255, 255],
|
2427 | "whitesmoke": [245, 245, 245],
|
2428 | "yellow": [255, 255, 0],
|
2429 | "yellowgreen": [154, 205, 50]
|
2430 | };
|
2431 |
|
2432 | }),
|
2433 |
|
2434 | (function(module, exports) {
|
2435 |
|
2436 | module.exports = {
|
2437 | "author": "Shane Brinkman-Davis Delamore, Imikimi LLC",
|
2438 | "dependencies": {
|
2439 | "art-build-configurator": "*",
|
2440 | "art-class-system": "*",
|
2441 | "art-config": "*",
|
2442 | "art-standard-lib": "*",
|
2443 | "art-testbench": "*",
|
2444 | "bluebird": "^3.5.0",
|
2445 | "caffeine-script": "*",
|
2446 | "caffeine-script-runtime": "*",
|
2447 | "case-sensitive-paths-webpack-plugin": "^2.1.1",
|
2448 | "chai": "^4.0.1",
|
2449 | "coffee-loader": "^0.7.3",
|
2450 | "coffee-script": "^1.12.6",
|
2451 | "colors": "^1.1.2",
|
2452 | "commander": "^2.9.0",
|
2453 | "css-loader": "^0.28.4",
|
2454 | "dateformat": "^2.0.0",
|
2455 | "detect-node": "^2.0.3",
|
2456 | "fs-extra": "^3.0.1",
|
2457 | "glob": "^7.1.2",
|
2458 | "glob-promise": "^3.1.0",
|
2459 | "json-loader": "^0.5.4",
|
2460 | "mocha": "^3.4.2",
|
2461 | "neptune-namespaces": "*",
|
2462 | "script-loader": "^0.7.0",
|
2463 | "style-loader": "^0.18.1",
|
2464 | "webpack": "^2.6.1",
|
2465 | "webpack-dev-server": "^2.4.5",
|
2466 | "webpack-merge": "^4.1.0",
|
2467 | "webpack-node-externals": "^1.6.0"
|
2468 | },
|
2469 | "description": "a 'runtime' parsing expression grammar parser",
|
2470 | "license": "ISC",
|
2471 | "name": "babel-bridge",
|
2472 | "scripts": {
|
2473 | "build": "webpack --progress",
|
2474 | "start": "webpack-dev-server --hot --inline --progress",
|
2475 | "test": "nn -s;mocha -u tdd --compilers coffee:coffee-script/register",
|
2476 | "testInBrowser": "webpack-dev-server --progress"
|
2477 | },
|
2478 | "version": "1.12.8"
|
2479 | };
|
2480 |
|
2481 | }),
|
2482 |
|
2483 | (function(module, exports, __webpack_require__) {
|
2484 |
|
2485 | module.exports = __webpack_require__(7);
|
2486 |
|
2487 | module.exports.includeInNamespace(__webpack_require__(23)).addModules({
|
2488 | BabelBridgeCompileError: __webpack_require__(8),
|
2489 | NonMatch: __webpack_require__(12),
|
2490 | Parser: __webpack_require__(28),
|
2491 | PatternElement: __webpack_require__(13),
|
2492 | Repl: __webpack_require__(6),
|
2493 | Rule: __webpack_require__(14),
|
2494 | RuleVariant: __webpack_require__(15),
|
2495 | Stats: __webpack_require__(3),
|
2496 | Tools: __webpack_require__(16)
|
2497 | });
|
2498 |
|
2499 | __webpack_require__(25);
|
2500 |
|
2501 | __webpack_require__(2);
|
2502 |
|
2503 |
|
2504 | }),
|
2505 |
|
2506 | (function(module, exports) {
|
2507 |
|
2508 | var clone = (function() {
|
2509 | 'use strict';
|
2510 |
|
2511 |
|
2512 |
|
2513 |
|
2514 |
|
2515 |
|
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 |
|
2526 |
|
2527 |
|
2528 |
|
2529 | function clone(parent, circular, depth, prototype) {
|
2530 | var filter;
|
2531 | if (typeof circular === 'object') {
|
2532 | depth = circular.depth;
|
2533 | prototype = circular.prototype;
|
2534 | filter = circular.filter;
|
2535 | circular = circular.circular
|
2536 | }
|
2537 |
|
2538 |
|
2539 | var allParents = [];
|
2540 | var allChildren = [];
|
2541 |
|
2542 | var useBuffer = typeof Buffer != 'undefined';
|
2543 |
|
2544 | if (typeof circular == 'undefined')
|
2545 | circular = true;
|
2546 |
|
2547 | if (typeof depth == 'undefined')
|
2548 | depth = Infinity;
|
2549 |
|
2550 |
|
2551 | function _clone(parent, depth) {
|
2552 |
|
2553 | if (parent === null)
|
2554 | return null;
|
2555 |
|
2556 | if (depth == 0)
|
2557 | return parent;
|
2558 |
|
2559 | var child;
|
2560 | var proto;
|
2561 | if (typeof parent != 'object') {
|
2562 | return parent;
|
2563 | }
|
2564 |
|
2565 | if (clone.__isArray(parent)) {
|
2566 | child = [];
|
2567 | } else if (clone.__isRegExp(parent)) {
|
2568 | child = new RegExp(parent.source, __getRegExpFlags(parent));
|
2569 | if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
2570 | } else if (clone.__isDate(parent)) {
|
2571 | child = new Date(parent.getTime());
|
2572 | } else if (useBuffer && Buffer.isBuffer(parent)) {
|
2573 | child = new Buffer(parent.length);
|
2574 | parent.copy(child);
|
2575 | return child;
|
2576 | } else {
|
2577 | if (typeof prototype == 'undefined') {
|
2578 | proto = Object.getPrototypeOf(parent);
|
2579 | child = Object.create(proto);
|
2580 | }
|
2581 | else {
|
2582 | child = Object.create(prototype);
|
2583 | proto = prototype;
|
2584 | }
|
2585 | }
|
2586 |
|
2587 | if (circular) {
|
2588 | var index = allParents.indexOf(parent);
|
2589 |
|
2590 | if (index != -1) {
|
2591 | return allChildren[index];
|
2592 | }
|
2593 | allParents.push(parent);
|
2594 | allChildren.push(child);
|
2595 | }
|
2596 |
|
2597 | for (var i in parent) {
|
2598 | var attrs;
|
2599 | if (proto) {
|
2600 | attrs = Object.getOwnPropertyDescriptor(proto, i);
|
2601 | }
|
2602 |
|
2603 | if (attrs && attrs.set == null) {
|
2604 | continue;
|
2605 | }
|
2606 | child[i] = _clone(parent[i], depth - 1);
|
2607 | }
|
2608 |
|
2609 | return child;
|
2610 | }
|
2611 |
|
2612 | return _clone(parent, depth);
|
2613 | }
|
2614 |
|
2615 |
|
2616 |
|
2617 |
|
2618 |
|
2619 |
|
2620 |
|
2621 |
|
2622 | clone.clonePrototype = function clonePrototype(parent) {
|
2623 | if (parent === null)
|
2624 | return null;
|
2625 |
|
2626 | var c = function () {};
|
2627 | c.prototype = parent;
|
2628 | return new c();
|
2629 | };
|
2630 |
|
2631 |
|
2632 |
|
2633 | function __objToStr(o) {
|
2634 | return Object.prototype.toString.call(o);
|
2635 | };
|
2636 | clone.__objToStr = __objToStr;
|
2637 |
|
2638 | function __isDate(o) {
|
2639 | return typeof o === 'object' && __objToStr(o) === '[object Date]';
|
2640 | };
|
2641 | clone.__isDate = __isDate;
|
2642 |
|
2643 | function __isArray(o) {
|
2644 | return typeof o === 'object' && __objToStr(o) === '[object Array]';
|
2645 | };
|
2646 | clone.__isArray = __isArray;
|
2647 |
|
2648 | function __isRegExp(o) {
|
2649 | return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
|
2650 | };
|
2651 | clone.__isRegExp = __isRegExp;
|
2652 |
|
2653 | function __getRegExpFlags(re) {
|
2654 | var flags = '';
|
2655 | if (re.global) flags += 'g';
|
2656 | if (re.ignoreCase) flags += 'i';
|
2657 | if (re.multiline) flags += 'm';
|
2658 | return flags;
|
2659 | };
|
2660 | clone.__getRegExpFlags = __getRegExpFlags;
|
2661 |
|
2662 | return clone;
|
2663 | })();
|
2664 |
|
2665 | if (typeof module === 'object' && module.exports) {
|
2666 | module.exports = clone;
|
2667 | }
|
2668 |
|
2669 |
|
2670 | }),
|
2671 |
|
2672 | (function(module, exports, __webpack_require__) {
|
2673 |
|
2674 | module.exports = __webpack_require__(20);
|
2675 |
|
2676 |
|
2677 | }),
|
2678 |
|
2679 | (function(module, exports, __webpack_require__) {
|
2680 |
|
2681 | var isClass, log, ref;
|
2682 |
|
2683 | ref = __webpack_require__(0), isClass = ref.isClass, log = ref.log;
|
2684 |
|
2685 | module.exports = [
|
2686 | __webpack_require__(6), {
|
2687 | version: (__webpack_require__(19)).version
|
2688 | }
|
2689 | ];
|
2690 |
|
2691 |
|
2692 | }),
|
2693 |
|
2694 | (function(module, exports, __webpack_require__) {
|
2695 |
|
2696 | (function(module) {var Node, array, defineModule, escapeJavascriptString, find, log, merge, ref;
|
2697 |
|
2698 | ref = __webpack_require__(0), array = ref.array, defineModule = ref.defineModule, log = ref.log, merge = ref.merge, escapeJavascriptString = ref.escapeJavascriptString, find = ref.find;
|
2699 |
|
2700 | Node = __webpack_require__(2).Node;
|
2701 |
|
2702 | defineModule(module, function() {
|
2703 | var IndentBlocks;
|
2704 | return IndentBlocks = (function() {
|
2705 | var blockLinesRegExp, blockStartRegExp, computeSubsourceToParentSourceMap, matchBlock, matchToEolAndBlock, toEolContent;
|
2706 |
|
2707 | function IndentBlocks() {}
|
2708 |
|
2709 | blockStartRegExp = /\n(?: *\n)*( +)(?=$|[^ \n])/y;
|
2710 |
|
2711 | toEolContent = /(\ *)((?:\ *[^ \n]+)+)\ */y;
|
2712 |
|
2713 | blockLinesRegExp = function(indent) {
|
2714 | return RegExp("((?:\\s*\\n)(?:" + indent + " *[^\\n ][^\\n]*))+", "y");
|
2715 | };
|
2716 |
|
2717 |
|
2718 | |
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 |
|
2727 | IndentBlocks.matchBlock = matchBlock = function(source, sourceOffset, returnRawMatch) {
|
2728 | var __, indent, length, linesRegExp, match, rawSubsource, replaceRegExp, replaceWith, subsource, subsourceToParentSourceMap;
|
2729 | if (returnRawMatch == null) {
|
2730 | returnRawMatch = false;
|
2731 | }
|
2732 | blockStartRegExp.lastIndex = sourceOffset;
|
2733 | if (match = blockStartRegExp.exec(source)) {
|
2734 | __ = match[0], indent = match[1];
|
2735 | length = indent.length;
|
2736 | linesRegExp = blockLinesRegExp(indent);
|
2737 | linesRegExp.lastIndex = sourceOffset;
|
2738 | rawSubsource = linesRegExp.exec(source)[0];
|
2739 | replaceRegExp = RegExp("(?:^\\n" + indent + ")|(\\n)(?:" + indent + ")", "g");
|
2740 | replaceWith = "$1";
|
2741 | subsourceToParentSourceMap = null;
|
2742 | subsource = returnRawMatch ? rawSubsource : rawSubsource.replace(replaceRegExp, "$1");
|
2743 | return {
|
2744 | matchLength: rawSubsource.length,
|
2745 | subsource: subsource,
|
2746 | sourceMap: returnRawMatch ? function(suboffset) {
|
2747 | return suboffset + sourceOffset;
|
2748 | } : function(suboffset) {
|
2749 | var bestMapEntry;
|
2750 | subsourceToParentSourceMap || (subsourceToParentSourceMap = computeSubsourceToParentSourceMap(sourceOffset, replaceRegExp, indent, rawSubsource));
|
2751 | bestMapEntry = find(subsourceToParentSourceMap, function(entry) {
|
2752 | if (suboffset < entry.subsourceEndOffset) {
|
2753 | return entry;
|
2754 | }
|
2755 | });
|
2756 | return suboffset + bestMapEntry.toSourceDelta;
|
2757 | }
|
2758 | };
|
2759 | }
|
2760 | };
|
2761 |
|
2762 | computeSubsourceToParentSourceMap = function(sourceBaseOffset, replaceRegExp, indent, rawSubsource) {
|
2763 | var indentLength, indentWithNewLineLength, indexes, keptLength, match, matchLength, ref1, removedLength, sourceEndOffset, sourceOffset, subsourceEndOffset, subsourceOffset, toSourceDelta;
|
2764 | indentLength = indent.length;
|
2765 | indentWithNewLineLength = indentLength + 1;
|
2766 | indexes = [];
|
2767 | sourceOffset = toSourceDelta = sourceBaseOffset;
|
2768 | subsourceOffset = subsourceEndOffset = 0;
|
2769 | while (match = replaceRegExp.exec(rawSubsource)) {
|
2770 | matchLength = match[0].length;
|
2771 | keptLength = ((ref1 = match[1]) != null ? ref1.length : void 0) || 0;
|
2772 | removedLength = matchLength - keptLength;
|
2773 | sourceEndOffset = match.index + sourceBaseOffset + matchLength;
|
2774 | subsourceEndOffset += sourceEndOffset - sourceOffset - removedLength;
|
2775 | indexes.push({
|
2776 | keptLength: keptLength,
|
2777 | removedLength: removedLength,
|
2778 | sourceOffset: sourceOffset,
|
2779 | subsourceOffset: subsourceOffset,
|
2780 | toSourceDelta: toSourceDelta,
|
2781 | sourceEndOffset: sourceEndOffset,
|
2782 | subsourceEndOffset: subsourceEndOffset
|
2783 | });
|
2784 | toSourceDelta += removedLength;
|
2785 | sourceOffset = sourceEndOffset;
|
2786 | subsourceOffset = subsourceEndOffset;
|
2787 | }
|
2788 | sourceEndOffset = sourceBaseOffset + rawSubsource.length;
|
2789 | subsourceEndOffset = sourceEndOffset - sourceOffset + sourceOffset;
|
2790 | indexes.push({
|
2791 | sourceOffset: sourceOffset,
|
2792 | subsourceOffset: subsourceOffset,
|
2793 | toSourceDelta: toSourceDelta,
|
2794 | sourceEndOffset: sourceEndOffset,
|
2795 | subsourceEndOffset: subsourceEndOffset
|
2796 | });
|
2797 | return indexes;
|
2798 | };
|
2799 |
|
2800 | IndentBlocks.matchToEolAndBlock = matchToEolAndBlock = function(source, offset) {
|
2801 | var blockMatch, eolMatch, matchLength, sourceMatched, spaces;
|
2802 | toEolContent.lastIndex = offset;
|
2803 | if (eolMatch = toEolContent.exec(source)) {
|
2804 | sourceMatched = eolMatch[0], spaces = eolMatch[1];
|
2805 | matchLength = sourceMatched.length;
|
2806 | if (blockMatch = matchBlock(source, offset + matchLength, true)) {
|
2807 | matchLength += blockMatch.matchLength;
|
2808 | }
|
2809 | return {
|
2810 | subsource: source.slice(offset + spaces.length, offset + matchLength),
|
2811 | sourceMap: function(suboffset) {
|
2812 | return offset + spaces.length + suboffset;
|
2813 | },
|
2814 | matchLength: matchLength
|
2815 | };
|
2816 | } else {
|
2817 | return matchBlock(source, offset);
|
2818 | }
|
2819 | };
|
2820 |
|
2821 | IndentBlocks.getParseFunction = function(matcher, subparseOptions) {
|
2822 | return {
|
2823 | parse: function(parentNode) {
|
2824 | var block, matchLength, offset, source, sourceMap, subsource;
|
2825 | offset = parentNode.nextOffset, source = parentNode.source;
|
2826 | if (block = matcher(source, offset)) {
|
2827 | subsource = block.subsource, matchLength = block.matchLength, sourceMap = block.sourceMap;
|
2828 | return parentNode.subparse(subsource, merge(subparseOptions, {
|
2829 | originalOffset: offset,
|
2830 | originalMatchLength: matchLength,
|
2831 | sourceMap: sourceMap
|
2832 | }));
|
2833 | }
|
2834 | }
|
2835 | };
|
2836 | };
|
2837 |
|
2838 | IndentBlocks.getPropsToSubparseBlock = function(subparseOptions) {
|
2839 | if (subparseOptions == null) {
|
2840 | subparseOptions = {};
|
2841 | }
|
2842 | return IndentBlocks.getParseFunction(IndentBlocks.matchBlock, subparseOptions);
|
2843 | };
|
2844 |
|
2845 | IndentBlocks.getPropsToSubparseToEolAndBlock = function(subparseOptions) {
|
2846 | if (subparseOptions == null) {
|
2847 | subparseOptions = {};
|
2848 | }
|
2849 | return IndentBlocks.getParseFunction(IndentBlocks.matchToEolAndBlock, subparseOptions);
|
2850 | };
|
2851 |
|
2852 | return IndentBlocks;
|
2853 |
|
2854 | })();
|
2855 | });
|
2856 |
|
2857 | }.call(exports, __webpack_require__(4)(module)))
|
2858 |
|
2859 | }),
|
2860 |
|
2861 | (function(module, exports, __webpack_require__) {
|
2862 |
|
2863 | module.exports = __webpack_require__(9);
|
2864 |
|
2865 | module.exports.addModules({
|
2866 | IndentBlocks: __webpack_require__(24)
|
2867 | });
|
2868 |
|
2869 |
|
2870 | }),
|
2871 |
|
2872 | (function(module, exports, __webpack_require__) {
|
2873 |
|
2874 | var EmptyOptionalNode,
|
2875 | extend = 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; },
|
2876 | hasProp = {}.hasOwnProperty;
|
2877 |
|
2878 | module.exports = EmptyOptionalNode = (function(superClass) {
|
2879 | extend(EmptyOptionalNode, superClass);
|
2880 |
|
2881 | function EmptyOptionalNode() {
|
2882 | return EmptyOptionalNode.__super__.constructor.apply(this, arguments);
|
2883 | }
|
2884 |
|
2885 | EmptyOptionalNode.getter({
|
2886 | present: function() {
|
2887 | return false;
|
2888 | }
|
2889 | });
|
2890 |
|
2891 | return EmptyOptionalNode;
|
2892 |
|
2893 | })(__webpack_require__(10));
|
2894 |
|
2895 |
|
2896 | }),
|
2897 |
|
2898 | (function(module, exports, __webpack_require__) {
|
2899 |
|
2900 | (function(module) {var BaseClass, ScratchNode, compactFlatten, defineModule, inspect, isPlainObject, isString, log, merge, pad, push, ref, toInspectedObjects, upperCamelCase,
|
2901 | extend = 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; },
|
2902 | hasProp = {}.hasOwnProperty;
|
2903 |
|
2904 | ref = __webpack_require__(0), log = ref.log, defineModule = ref.defineModule, toInspectedObjects = ref.toInspectedObjects, isPlainObject = ref.isPlainObject, push = ref.push, isString = ref.isString, compactFlatten = ref.compactFlatten, inspect = ref.inspect, pad = ref.pad, upperCamelCase = ref.upperCamelCase, merge = ref.merge;
|
2905 |
|
2906 | BaseClass = __webpack_require__(1).BaseClass;
|
2907 |
|
2908 | defineModule(module, ScratchNode = (function(superClass) {
|
2909 | extend(ScratchNode, superClass);
|
2910 |
|
2911 | ScratchNode._scatchNodes = [];
|
2912 |
|
2913 | ScratchNode._scatchNodesInUse = 0;
|
2914 |
|
2915 | ScratchNode.checkout = function(parentNode, ruleVariant) {
|
2916 | if (this._scatchNodesInUse >= this._scatchNodes.length) {
|
2917 | return this._scatchNodes[this._scatchNodesInUse++] = new ScratchNode(parentNode, ruleVariant);
|
2918 | } else {
|
2919 | return this._scatchNodes[this._scatchNodesInUse++].reset(parentNode, ruleVariant);
|
2920 | }
|
2921 | };
|
2922 |
|
2923 | ScratchNode.checkin = function(scratchNode) {
|
2924 | if (scratchNode !== this._scatchNodes[--this._scatchNodesInUse]) {
|
2925 | throw new Error("WTF");
|
2926 | }
|
2927 | };
|
2928 |
|
2929 | function ScratchNode(parent, ruleVariant) {
|
2930 | this.matches = [];
|
2931 | this.matchPatterns = [];
|
2932 | this.reset(parent, ruleVariant);
|
2933 | }
|
2934 |
|
2935 | ScratchNode.prototype.reset = function(parent1, ruleVariant1) {
|
2936 | this.parent = parent1;
|
2937 | this.ruleVariant = ruleVariant1;
|
2938 | this._parser = this.parent._parser;
|
2939 | this.offset = this.parent.getNextOffset() | 0;
|
2940 | this.matchesLength = this.matchPatternsLength = this.matchLength = 0;
|
2941 | this.variantNode = null;
|
2942 | return this;
|
2943 | };
|
2944 |
|
2945 | ScratchNode.getter("parser", {
|
2946 | source: function() {
|
2947 | return this._parser.source;
|
2948 | },
|
2949 | nextOffset: function() {
|
2950 | return this.offset + this.matchLength;
|
2951 | },
|
2952 | inspectedObjects: function() {
|
2953 | return {
|
2954 | offset: this.offset,
|
2955 | matchLength: this.matchLength,
|
2956 | matches: toInspectedObjects(this.matches),
|
2957 | matchPatterns: toInspectedObjects(this.matchPatterns)
|
2958 | };
|
2959 | }
|
2960 | });
|
2961 |
|
2962 | ScratchNode.prototype.getNextText = function(length) {
|
2963 | var nextOffset;
|
2964 | nextOffset = this.getNextOffset();
|
2965 | return this.source.slice(nextOffset, nextOffset + length);
|
2966 | };
|
2967 |
|
2968 | ScratchNode.getter({
|
2969 | firstPartialMatchParent: function() {
|
2970 | return this.realNode.firstPartialMatchParent;
|
2971 | },
|
2972 | realNode: function() {
|
2973 | return this.variantNode || (this.variantNode = new this.ruleVariant.VariantNodeClass(this.parent.realNode || this._parser, {
|
2974 | ruleVariant: this.ruleVariant,
|
2975 | matchLength: this.matchLength,
|
2976 | matches: this.matchesLength > 0 && this.matches.slice(0, this.matchesLength),
|
2977 | matchPatterns: this.matchPatternsLength > 0 && this.matchPatterns.slice(0, this.matchPatternsLength)
|
2978 | }));
|
2979 | }
|
2980 | });
|
2981 |
|
2982 | ScratchNode.prototype.checkin = function() {
|
2983 | return ScratchNode.checkin(this);
|
2984 | };
|
2985 |
|
2986 | ScratchNode.prototype.subparse = function(subSource, options) {
|
2987 | return this._parser.subparse(subSource, merge(options, {
|
2988 | parentNode: this
|
2989 | }));
|
2990 | };
|
2991 |
|
2992 | ScratchNode.prototype.addMatch = function(pattern, match) {
|
2993 | var ref1;
|
2994 | if (!match) {
|
2995 | return false;
|
2996 | }
|
2997 | if ((ref1 = this.variantNode) != null) {
|
2998 | ref1.addMatch(pattern, match);
|
2999 | }
|
3000 | this.matches[this.matchesLength++] = match;
|
3001 | this.matchPatterns[this.matchPatternsLength++] = pattern;
|
3002 | this.matchLength = match.nextOffset - this.offset;
|
3003 | return true;
|
3004 | };
|
3005 |
|
3006 | ScratchNode.prototype._addToParentAsNonMatch = function() {
|
3007 | return this.realNode._addToParentAsNonMatch();
|
3008 | };
|
3009 |
|
3010 | return ScratchNode;
|
3011 |
|
3012 | })(BaseClass));
|
3013 |
|
3014 | }.call(exports, __webpack_require__(4)(module)))
|
3015 |
|
3016 | }),
|
3017 |
|
3018 | (function(module, exports, __webpack_require__) {
|
3019 |
|
3020 | var BabelBridgeCompileError, Node, NonMatch, Parser, Rule, Stats, compactFlatten, formattedInspect, getLineColumn, getLineColumnString, inspect, inspectLean, isClass, isFunction, isPlainArray, isPlainObject, log, max, merge, mergeInto, objectHasKeys, objectLength, objectWithout, peek, pluralize, pushIfNotPresent, ref, ref1, uniqueValues, upperCamelCase,
|
3021 | extend = 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; },
|
3022 | hasProp = {}.hasOwnProperty,
|
3023 | slice = [].slice;
|
3024 |
|
3025 | Rule = __webpack_require__(14);
|
3026 |
|
3027 | ref = __webpack_require__(16), getLineColumn = ref.getLineColumn, getLineColumnString = ref.getLineColumnString;
|
3028 |
|
3029 | Node = __webpack_require__(2).Node;
|
3030 |
|
3031 | NonMatch = __webpack_require__(12);
|
3032 |
|
3033 | Stats = __webpack_require__(3);
|
3034 |
|
3035 | ref1 = __webpack_require__(0), isFunction = ref1.isFunction, peek = ref1.peek, log = ref1.log, isPlainObject = ref1.isPlainObject, isPlainArray = ref1.isPlainArray, merge = ref1.merge, compactFlatten = ref1.compactFlatten, objectLength = ref1.objectLength, inspect = ref1.inspect, inspectLean = ref1.inspectLean, pluralize = ref1.pluralize, isClass = ref1.isClass, isPlainArray = ref1.isPlainArray, upperCamelCase = ref1.upperCamelCase, mergeInto = ref1.mergeInto, objectWithout = ref1.objectWithout, uniqueValues = ref1.uniqueValues, formattedInspect = ref1.formattedInspect, max = ref1.max, inspect = ref1.inspect, pushIfNotPresent = ref1.pushIfNotPresent, uniqueValues = ref1.uniqueValues, objectHasKeys = ref1.objectHasKeys;
|
3036 |
|
3037 | BabelBridgeCompileError = __webpack_require__(8);
|
3038 |
|
3039 | module.exports = Parser = (function(superClass) {
|
3040 | var addToExpectingInfo, firstLines, instanceRulesFunction, lastLines, rulesFunction;
|
3041 |
|
3042 | extend(Parser, superClass);
|
3043 |
|
3044 | Parser.repl = function() {
|
3045 | return (__webpack_require__(6)).babelBridgeRepl(this);
|
3046 | };
|
3047 |
|
3048 | Parser.parse = function(_source, options) {
|
3049 | this._source = _source;
|
3050 | if (options == null) {
|
3051 | options = {};
|
3052 | }
|
3053 | return (new this).parse(this._source, options);
|
3054 | };
|
3055 |
|
3056 | Parser.classGetter({
|
3057 | rootRuleName: function() {
|
3058 | return this._rootRuleName || "root";
|
3059 | },
|
3060 | rootRule: function() {
|
3061 | return this.getRules()[this._rootRuleName];
|
3062 | }
|
3063 | });
|
3064 |
|
3065 | Parser.extendableProperty({
|
3066 | rules: {}
|
3067 | }, function(extendableRules, newRules) {
|
3068 | var newRule, ruleName;
|
3069 | for (ruleName in a) {
|
3070 | newRule = a[ruleName];
|
3071 | extendableRules[ruleName] = newRule.clone();
|
3072 | }
|
3073 | return newRule;
|
3074 | });
|
3075 |
|
3076 | Parser.addRule = function(ruleName, definitions, nodeBaseClass) {
|
3077 | var array, base, commonNodeProps, definition, i, j, last, len, pattern, patterns, ref2, results, rule;
|
3078 | if (nodeBaseClass == null) {
|
3079 | nodeBaseClass = this.getNodeBaseClass();
|
3080 | }
|
3081 | rule = (base = this.extendRules())[ruleName] || (base[ruleName] = new Rule(ruleName, this));
|
3082 | if (definitions.root) {
|
3083 | if (this._rootRuleName) {
|
3084 | throw new Error("root rule already defined! was: " + this._rootRuleName + ", wanted: " + ruleName);
|
3085 | }
|
3086 | this._rootRuleName = ruleName;
|
3087 | }
|
3088 | if (!isPlainArray(array = definitions)) {
|
3089 | definitions = [definitions];
|
3090 | }
|
3091 | if (definitions.length > 1 && isPlainObject(last = peek(definitions)) && !last.pattern) {
|
3092 | ref2 = definitions, definitions = 2 <= ref2.length ? slice.call(ref2, 0, i = ref2.length - 1) : (i = 0, []), commonNodeProps = ref2[i++];
|
3093 | } else {
|
3094 | commonNodeProps = {};
|
3095 | }
|
3096 | commonNodeProps.nodeBaseClass || (commonNodeProps.nodeBaseClass = nodeBaseClass);
|
3097 | results = [];
|
3098 | for (j = 0, len = definitions.length; j < len; j++) {
|
3099 | definition = definitions[j];
|
3100 | if (!isPlainObject(definition)) {
|
3101 | definition = {
|
3102 | pattern: definition
|
3103 | };
|
3104 | }
|
3105 | if (isPlainArray(patterns = definition.pattern)) {
|
3106 | results.push((function() {
|
3107 | var l, len1, results1;
|
3108 | results1 = [];
|
3109 | for (l = 0, len1 = patterns.length; l < len1; l++) {
|
3110 | pattern = patterns[l];
|
3111 | results1.push(rule.addVariant(merge(commonNodeProps, definition, {
|
3112 | pattern: pattern
|
3113 | })));
|
3114 | }
|
3115 | return results1;
|
3116 | })());
|
3117 | } else {
|
3118 | results.push(rule.addVariant(merge(commonNodeProps, definition)));
|
3119 | }
|
3120 | }
|
3121 | return results;
|
3122 | };
|
3123 |
|
3124 |
|
3125 | |
3126 |
|
3127 |
|
3128 |
|
3129 |
|
3130 |
|
3131 | Parser.rule = rulesFunction = function(a, b) {
|
3132 | var definition, results, ruleName, rules, sharedNodeBaseClass;
|
3133 | if (isClass(a)) {
|
3134 | sharedNodeBaseClass = a;
|
3135 | rules = b;
|
3136 | } else {
|
3137 | rules = a;
|
3138 | sharedNodeBaseClass = b;
|
3139 | }
|
3140 | if (isPlainObject(sharedNodeBaseClass)) {
|
3141 | sharedNodeBaseClass = this.getNodeBaseClass().createSubclass(sharedNodeBaseClass);
|
3142 | }
|
3143 | results = [];
|
3144 | for (ruleName in rules) {
|
3145 | definition = rules[ruleName];
|
3146 | results.push(this.addRule(ruleName, definition, sharedNodeBaseClass || this.getNodeBaseClass()));
|
3147 | }
|
3148 | return results;
|
3149 | };
|
3150 |
|
3151 | Parser.rules = rulesFunction;
|
3152 |
|
3153 | Parser.prototype.rule = instanceRulesFunction = function(a, b) {
|
3154 | return this["class"].rule(a, b);
|
3155 | };
|
3156 |
|
3157 | Parser.prototype.rules = instanceRulesFunction;
|
3158 |
|
3159 | Parser.getNodeBaseClass = function() {
|
3160 | return this._nodeBaseClass || (this._nodeBaseClass = isPlainObject(this.nodeBaseClass) ? (log({
|
3161 | create: this.getName() + "NodeBaseClass"
|
3162 | }), Node.createSubclass(merge({
|
3163 | name: this.getName() + "NodeBaseClass"
|
3164 | }, this.nodeBaseClass))) : this.nodeBaseClass || Node);
|
3165 | };
|
3166 |
|
3167 | Parser.property("subparseInfo options");
|
3168 |
|
3169 | Parser.getter("source parser", {
|
3170 | rootRuleName: function() {
|
3171 | return this["class"].getRootRuleName();
|
3172 | },
|
3173 | rootRule: function() {
|
3174 | return this["class"].getRootRule();
|
3175 | },
|
3176 | nextOffset: function() {
|
3177 | return 0;
|
3178 | },
|
3179 | rootParser: function() {
|
3180 | var ref2;
|
3181 | return ((ref2 = this.parentParser) != null ? ref2.rootParser : void 0) || this;
|
3182 | },
|
3183 | ancestors: function(into) {
|
3184 | into.push(this);
|
3185 | return into;
|
3186 | },
|
3187 | parseInfo: function() {
|
3188 | return "Parser";
|
3189 | }
|
3190 | });
|
3191 |
|
3192 | function Parser() {
|
3193 | Parser.__super__.constructor.apply(this, arguments);
|
3194 | this._options = null;
|
3195 | this._parser = this;
|
3196 | this._source = null;
|
3197 | this._resetParserTracking();
|
3198 | }
|
3199 |
|
3200 | Parser._pluralNames = {};
|
3201 |
|
3202 | Parser.pluralize = function(name) {
|
3203 | var base;
|
3204 | return (base = this._pluralNames)[name] || (base[name] = pluralize(name));
|
3205 | };
|
3206 |
|
3207 | Parser.prototype.pluralize = function(name) {
|
3208 | return this["class"].pluralize(name);
|
3209 | };
|
3210 |
|
3211 |
|
3212 | |
3213 |
|
3214 |
|
3215 |
|
3216 |
|
3217 |
|
3218 |
|
3219 |
|
3220 |
|
3221 |
|
3222 |
|
3223 |
|
3224 |
|
3225 |
|
3226 |
|
3227 |
|
3228 |
|
3229 |
|
3230 |
|
3231 |
|
3232 |
|
3233 |
|
3234 |
|
3235 | Parser.prototype.subparse = function(subsource, options) {
|
3236 | var failureIndex, k, match, matchLength, nonMatch, offset, originalMatchLength, originalOffset, parentNode, parser, ref2, rootNode, source, sourceMap, subparser;
|
3237 | if (options == null) {
|
3238 | options = {};
|
3239 | }
|
3240 | Stats.add("subparse");
|
3241 | subparser = new this["class"];
|
3242 | originalMatchLength = options.originalMatchLength, parentNode = options.parentNode, sourceMap = options.sourceMap, originalOffset = options.originalOffset;
|
3243 | options.parentParser = this;
|
3244 | if (match = subparser.parse(subsource, merge(options, {
|
3245 | isSubparse: true,
|
3246 | logParsingFailures: this._logParsingFailures
|
3247 | }))) {
|
3248 | offset = match.offset, matchLength = match.matchLength, source = match.source, parser = match.parser;
|
3249 | match.subparseInfo = {
|
3250 | offset: offset,
|
3251 | matchLength: matchLength,
|
3252 | source: source,
|
3253 | parser: parser
|
3254 | };
|
3255 | if (match.matchLength < subsource.length) {
|
3256 | if (match.text !== parentNode.getNextText(match.matchLength)) {
|
3257 | throw new Error("INTERNAL TODO: SubParse was a partial match, but a source-map is required to determine the matchLength in the original source.");
|
3258 | }
|
3259 | originalMatchLength = match.matchLength;
|
3260 | }
|
3261 | match.offset = parentNode.nextOffset;
|
3262 | match.matchLength = originalMatchLength;
|
3263 | match._parent = parentNode;
|
3264 | return match;
|
3265 | } else {
|
3266 | failureIndex = subparser.failureIndexInParentParser;
|
3267 | ref2 = subparser._nonMatches;
|
3268 | for (k in ref2) {
|
3269 | nonMatch = ref2[k];
|
3270 | rootNode = nonMatch.node;
|
3271 | while (rootNode !== parentNode && rootNode.parent instanceof Node) {
|
3272 | rootNode = rootNode.parent;
|
3273 | }
|
3274 | if (rootNode !== parentNode) {
|
3275 | rootNode._parent = parentNode;
|
3276 | }
|
3277 | if (this._logParsingFailures) {
|
3278 | this._addNonMatch(failureIndex, nonMatch);
|
3279 | } else {
|
3280 | this._failureIndex = max(this._failureIndex, failureIndex);
|
3281 | }
|
3282 | }
|
3283 | return null;
|
3284 | }
|
3285 | };
|
3286 |
|
3287 | Parser.prototype.offsetInParentParserSource = function(suboffset) {
|
3288 | var originalOffset, ref2, ref3, sourceMap;
|
3289 | ref2 = this.options, sourceMap = ref2.sourceMap, originalOffset = (ref3 = ref2.originalOffset) != null ? ref3 : 0;
|
3290 | if (sourceMap) {
|
3291 | return sourceMap(suboffset);
|
3292 | } else if (this.parentParser) {
|
3293 | return this.options.originalOffset + suboffset;
|
3294 | } else {
|
3295 | return suboffset;
|
3296 | }
|
3297 | };
|
3298 |
|
3299 | Parser.prototype.offsetInRootParserSource = function(suboffset) {
|
3300 | if (this.parentParser) {
|
3301 | return this.parentParser.offsetInRootParserSource(this.offsetInParentParserSource(suboffset));
|
3302 | } else {
|
3303 | return suboffset;
|
3304 | }
|
3305 | };
|
3306 |
|
3307 | Parser.getter({
|
3308 | failureIndexInParentParser: function() {
|
3309 | return this.offsetInParentParserSource(this._failureIndex);
|
3310 | }
|
3311 | });
|
3312 |
|
3313 | Parser.prototype.colorString = function(clr, str) {
|
3314 | if (this.options.color) {
|
3315 | return ("" + str)[clr];
|
3316 | } else {
|
3317 | return str;
|
3318 | }
|
3319 | };
|
3320 |
|
3321 |
|
3322 | |
3323 |
|
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 | Parser.prototype.parse = function(_source, options1) {
|
3329 | var allowPartialMatch, isSubparse, logParsingFailures, ref2, result, rule, startRule;
|
3330 | this._source = _source;
|
3331 | this.options = options1 != null ? options1 : {};
|
3332 | ref2 = this.options, this.parentParser = ref2.parentParser, allowPartialMatch = ref2.allowPartialMatch, rule = ref2.rule, isSubparse = ref2.isSubparse, logParsingFailures = ref2.logParsingFailures;
|
3333 | startRule = this.getRule(rule);
|
3334 | this._resetParserTracking();
|
3335 | this._logParsingFailures = logParsingFailures;
|
3336 | if ((result = startRule.parse(this)) && (result.matchLength === this._source.length || (allowPartialMatch && result.matchLength > 0))) {
|
3337 | if (!isSubparse) {
|
3338 | result.applyLabels();
|
3339 | }
|
3340 | return result;
|
3341 | } else {
|
3342 | if (!isSubparse) {
|
3343 | if (logParsingFailures) {
|
3344 | throw new BabelBridgeCompileError(result ? [this.colorString("gray", (this["class"].name + " only parsed: ") + this.colorString("black", (result.matchLength + " of " + this._source.length + " ") + this.colorString("gray", "characters"))), this.getParseFailureInfo(this.options)].join("\n") : this.getParseFailureInfo(this.options), this.parseFailureInfoObject);
|
3345 | } else {
|
3346 | return this.parse(this._source, merge(this.options, {
|
3347 | logParsingFailures: true
|
3348 | }));
|
3349 | }
|
3350 | }
|
3351 | }
|
3352 | };
|
3353 |
|
3354 | Parser.prototype.getRule = function(ruleName) {
|
3355 | var rule;
|
3356 | ruleName || (ruleName = this.rootRuleName);
|
3357 | if (!ruleName) {
|
3358 | throw new Error("No root rule defined.");
|
3359 | }
|
3360 | if (!(rule = this.rules[ruleName])) {
|
3361 | throw new Error("Could not find rule: " + ruleName);
|
3362 | }
|
3363 | return rule;
|
3364 | };
|
3365 |
|
3366 | addToExpectingInfo = function(node, into, value) {
|
3367 | var m, name1, p, pm, ref2;
|
3368 | if (node.parent) {
|
3369 | into = addToExpectingInfo(node.parent, into);
|
3370 | }
|
3371 | return into[name1 = node.parseInfo] || (into[name1] = value ? value : (p = {}, ((ref2 = (pm = node.presentMatches)) != null ? ref2.length : void 0) > 0 ? p.matches = (function() {
|
3372 | var i, len, results;
|
3373 | results = [];
|
3374 | for (i = 0, len = pm.length; i < len; i++) {
|
3375 | m = pm[i];
|
3376 | results.push(m.parseInfo);
|
3377 | }
|
3378 | return results;
|
3379 | })() : void 0, p));
|
3380 | };
|
3381 |
|
3382 | lastLines = function(string, count) {
|
3383 | var a;
|
3384 | if (count == null) {
|
3385 | count = 5;
|
3386 | }
|
3387 | a = string.split("\n");
|
3388 | return a.slice(max(0, a.length - count), a.length).join("\n");
|
3389 | };
|
3390 |
|
3391 | firstLines = function(string, count) {
|
3392 | var a;
|
3393 | if (count == null) {
|
3394 | count = 5;
|
3395 | }
|
3396 | a = string.split("\n");
|
3397 | return a.slice(0, count).join("\n");
|
3398 | };
|
3399 |
|
3400 | Parser.getter("nonMatches", {
|
3401 | failureUrl: function() {
|
3402 | return (this.options.sourceFile || '') + ":" + (getLineColumnString(this._source, this._failureIndex));
|
3403 | },
|
3404 | parseFailureInfoObject: function() {
|
3405 | return merge({
|
3406 | sourceFile: this.options.sourceFile,
|
3407 | failureIndex: this._failureIndex,
|
3408 | location: this.failureUrl
|
3409 | }, getLineColumn(this._source, this._failureIndex));
|
3410 | },
|
3411 | parseFailureInfo: function(options) {
|
3412 | var left, out, right, sourceAfter, sourceBefore, verbose;
|
3413 | if (!this._source) {
|
3414 | return;
|
3415 | }
|
3416 | verbose = options != null ? options.verbose : void 0;
|
3417 | sourceBefore = lastLines(left = this._source.slice(0, this._failureIndex));
|
3418 | sourceAfter = firstLines(right = this._source.slice(this._failureIndex));
|
3419 | out = compactFlatten([
|
3420 | "", this.colorString("gray", "Parsing error at " + (this.colorString("red", this.failureUrl))), "", this.colorString("gray", "Source:"), this.colorString("gray", "..."), "" + sourceBefore + (this.colorString("red", "<HERE>")) + (sourceAfter.replace(/[\s\n]+$/, '')), this.colorString("gray", "..."), "", this.getExpectingInfo(options), verbose ? formattedInspect({
|
3421 | "partial-parse-tree": this.partialParseTree
|
3422 | }, options) : void 0, ""
|
3423 | ]);
|
3424 | return out.join("\n");
|
3425 | },
|
3426 | partialParseTreeLeafNodes: function() {
|
3427 | if (this._partialParseTreeNodes) {
|
3428 | return this._partialParseTreeNodes;
|
3429 | }
|
3430 | this.getPartialParseTree();
|
3431 | return this._partialParseTreeNodes;
|
3432 | },
|
3433 | partialParseTree: function() {
|
3434 | var expectingInfoTree, k, n, node, patternElement, rootNode;
|
3435 | if (this._partialParseTree) {
|
3436 | return this._partialParseTree;
|
3437 | }
|
3438 | expectingInfoTree = {};
|
3439 | this._partialParseTreeNodes = (function() {
|
3440 | var ref2, ref3, results;
|
3441 | ref2 = this._nonMatches;
|
3442 | results = [];
|
3443 | for (k in ref2) {
|
3444 | ref3 = ref2[k], patternElement = ref3.patternElement, node = ref3.node;
|
3445 | addToExpectingInfo(node, expectingInfoTree, patternElement.pattern.toString());
|
3446 | n = new Node(node);
|
3447 | n.pattern = patternElement;
|
3448 | rootNode = n._addToParentAsNonMatch();
|
3449 | results.push(n);
|
3450 | }
|
3451 | return results;
|
3452 | }).call(this);
|
3453 | return this._partialParseTree = rootNode;
|
3454 | },
|
3455 | expectingInfo: function(options) {
|
3456 | var child, couldMatchRuleNames, expecting, firstPartialMatchParent, i, j, l, len, len1, len2, node, out, partialMatchingParents, pmp, ref2, ref3, ruleName, v;
|
3457 | if (!(objectLength(this._nonMatches) > 0)) {
|
3458 | return null;
|
3459 | }
|
3460 |
|
3461 | |
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 |
|
3467 |
|
3468 | partialMatchingParents = [];
|
3469 | ref2 = this.partialParseTreeLeafNodes;
|
3470 | for (i = 0, len = ref2.length; i < len; i++) {
|
3471 | node = ref2[i];
|
3472 | firstPartialMatchParent = node.firstPartialMatchParent;
|
3473 | pushIfNotPresent(partialMatchingParents, firstPartialMatchParent);
|
3474 | }
|
3475 | couldMatchRuleNames = [];
|
3476 | expecting = {};
|
3477 | for (j = 0, len1 = partialMatchingParents.length; j < len1; j++) {
|
3478 | pmp = partialMatchingParents[j];
|
3479 | ref3 = pmp.matches;
|
3480 | for (l = 0, len2 = ref3.length; l < len2; l++) {
|
3481 | child = ref3[l];
|
3482 | if (!(child.isNonMatch && child.nonMatchingLeaf)) {
|
3483 | continue;
|
3484 | }
|
3485 | if (ruleName = child.nonMatchingLeaf.ruleNameOrNull) {
|
3486 | couldMatchRuleNames.push(ruleName);
|
3487 | }
|
3488 | expecting[child.nonMatchingLeaf.ruleNameOrPattern] = {
|
3489 | "to-continue": pmp.ruleName,
|
3490 | "started-at": getLineColumnString(this._source, pmp.absoluteOffset)
|
3491 | };
|
3492 | }
|
3493 | }
|
3494 | expecting = (function() {
|
3495 | var len3, len4, o, q, ref4;
|
3496 | if (objectHasKeys(expecting)) {
|
3497 | out = {
|
3498 | expecting: expecting
|
3499 | };
|
3500 | if (couldMatchRuleNames.length > 1) {
|
3501 | out.rules = {};
|
3502 | for (o = 0, len3 = couldMatchRuleNames.length; o < len3; o++) {
|
3503 | ruleName = couldMatchRuleNames[o];
|
3504 | ref4 = this.rules[ruleName]._variants;
|
3505 | for (q = 0, len4 = ref4.length; q < len4; q++) {
|
3506 | v = ref4[q];
|
3507 | out.rules[ruleName] = v.patternString;
|
3508 | }
|
3509 | }
|
3510 | }
|
3511 | return out;
|
3512 | } else {
|
3513 | return {
|
3514 | expecting: "end of input"
|
3515 | };
|
3516 | }
|
3517 | }).call(this);
|
3518 | return formattedInspect(expecting, options);
|
3519 | }
|
3520 | });
|
3521 |
|
3522 | Parser.prototype.tryPatternElement = function(patternElement, parseIntoNode, ruleVariant) {
|
3523 | Stats.add("tryPatternElement");
|
3524 | if (patternElement.parseInto(parseIntoNode)) {
|
3525 | return true;
|
3526 | } else {
|
3527 | this._logParsingFailure(parseIntoNode, patternElement);
|
3528 | return false;
|
3529 | }
|
3530 | };
|
3531 |
|
3532 | Parser.prototype._getRuleParseCache = function(ruleName) {
|
3533 | var base;
|
3534 | return (base = this._parseCache)[ruleName] || (base[ruleName] = {});
|
3535 | };
|
3536 |
|
3537 | Parser.prototype._cached = function(ruleName, offset) {
|
3538 | return this._getRuleParseCache(ruleName)[offset];
|
3539 | };
|
3540 |
|
3541 | Parser.prototype._cacheMatch = function(ruleName, matchingNode) {
|
3542 | Stats.add("cacheMatch");
|
3543 | this._getRuleParseCache(ruleName)[matchingNode.offset] = matchingNode;
|
3544 | return matchingNode;
|
3545 | };
|
3546 |
|
3547 | Parser.prototype._cacheNoMatch = function(ruleName, offset) {
|
3548 | Stats.add("cacheNoMatch");
|
3549 | this._getRuleParseCache(ruleName)[offset] = "no_match";
|
3550 | return null;
|
3551 | };
|
3552 |
|
3553 | Parser.prototype._resetParserTracking = function() {
|
3554 | this._activeRuleVariantParserOffsets = {};
|
3555 | this._subparseInfo = null;
|
3556 | this._logParsingFailures = false;
|
3557 | this._partialParseTreeNodes = null;
|
3558 | this._partialParseTree = null;
|
3559 | this._matchingNegativeDepth = 0;
|
3560 | this._parsingDidNotMatchEntireInput = false;
|
3561 | this._failureIndex = 0;
|
3562 | this._nonMatches = {};
|
3563 | this._parseCache = {};
|
3564 | return this._parentParserRootOffset = null;
|
3565 | };
|
3566 |
|
3567 | Parser.getter("activeRuleVariantParserOffsets activeRuleVariantParserAreLeftRecursive failureIndex", {
|
3568 | isMatchingNegative: function() {
|
3569 | return this._matchingNegativeDepth > 0;
|
3570 | }
|
3571 | });
|
3572 |
|
3573 | Parser.prototype._matchNegative = function(f) {
|
3574 | var result;
|
3575 | this._matchingNegativeDepth++;
|
3576 | result = f();
|
3577 | this._matchingNegativeDepth--;
|
3578 | return result;
|
3579 | };
|
3580 |
|
3581 | Parser.prototype._logParsingFailure = function(parseIntoNode, patternElement) {
|
3582 | var offset;
|
3583 | if (!(this._matchingNegativeDepth === 0 && parseIntoNode.offset >= this._failureIndex && patternElement.isTokenPattern)) {
|
3584 | return;
|
3585 | }
|
3586 | offset = parseIntoNode.offset;
|
3587 | if (this._logParsingFailures) {
|
3588 | parseIntoNode = parseIntoNode.getRealNode();
|
3589 | return this._addNonMatch(offset, new NonMatch(parseIntoNode, patternElement));
|
3590 | } else {
|
3591 | return this._failureIndex = offset;
|
3592 | }
|
3593 | };
|
3594 |
|
3595 | Parser.prototype._addNonMatch = function(offset, nonMatch) {
|
3596 | if (offset > this._failureIndex) {
|
3597 | this._failureIndex = offset;
|
3598 | this._nonMatches = {};
|
3599 | }
|
3600 | return this._nonMatches[nonMatch] = nonMatch;
|
3601 | };
|
3602 |
|
3603 | return Parser;
|
3604 |
|
3605 | })(__webpack_require__(1).BaseClass);
|
3606 |
|
3607 |
|
3608 | }),
|
3609 |
|
3610 | (function(module, exports, __webpack_require__) {
|
3611 |
|
3612 | var conversions = __webpack_require__(17);
|
3613 | var route = __webpack_require__(30);
|
3614 |
|
3615 | var convert = {};
|
3616 |
|
3617 | var models = Object.keys(conversions);
|
3618 |
|
3619 | function wrapRaw(fn) {
|
3620 | var wrappedFn = function (args) {
|
3621 | if (args === undefined || args === null) {
|
3622 | return args;
|
3623 | }
|
3624 |
|
3625 | if (arguments.length > 1) {
|
3626 | args = Array.prototype.slice.call(arguments);
|
3627 | }
|
3628 |
|
3629 | return fn(args);
|
3630 | };
|
3631 |
|
3632 |
|
3633 | if ('conversion' in fn) {
|
3634 | wrappedFn.conversion = fn.conversion;
|
3635 | }
|
3636 |
|
3637 | return wrappedFn;
|
3638 | }
|
3639 |
|
3640 | function wrapRounded(fn) {
|
3641 | var wrappedFn = function (args) {
|
3642 | if (args === undefined || args === null) {
|
3643 | return args;
|
3644 | }
|
3645 |
|
3646 | if (arguments.length > 1) {
|
3647 | args = Array.prototype.slice.call(arguments);
|
3648 | }
|
3649 |
|
3650 | var result = fn(args);
|
3651 |
|
3652 |
|
3653 |
|
3654 |
|
3655 | if (typeof result === 'object') {
|
3656 | for (var len = result.length, i = 0; i < len; i++) {
|
3657 | result[i] = Math.round(result[i]);
|
3658 | }
|
3659 | }
|
3660 |
|
3661 | return result;
|
3662 | };
|
3663 |
|
3664 |
|
3665 | if ('conversion' in fn) {
|
3666 | wrappedFn.conversion = fn.conversion;
|
3667 | }
|
3668 |
|
3669 | return wrappedFn;
|
3670 | }
|
3671 |
|
3672 | models.forEach(function (fromModel) {
|
3673 | convert[fromModel] = {};
|
3674 |
|
3675 | Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
3676 | Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
3677 |
|
3678 | var routes = route(fromModel);
|
3679 | var routeModels = Object.keys(routes);
|
3680 |
|
3681 | routeModels.forEach(function (toModel) {
|
3682 | var fn = routes[toModel];
|
3683 |
|
3684 | convert[fromModel][toModel] = wrapRounded(fn);
|
3685 | convert[fromModel][toModel].raw = wrapRaw(fn);
|
3686 | });
|
3687 | });
|
3688 |
|
3689 | module.exports = convert;
|
3690 |
|
3691 |
|
3692 | }),
|
3693 |
|
3694 | (function(module, exports, __webpack_require__) {
|
3695 |
|
3696 | var conversions = __webpack_require__(17);
|
3697 |
|
3698 |
|
3699 |
|
3700 |
|
3701 |
|
3702 |
|
3703 |
|
3704 |
|
3705 |
|
3706 |
|
3707 |
|
3708 |
|
3709 |
|
3710 | var models = Object.keys(conversions);
|
3711 |
|
3712 | function buildGraph() {
|
3713 | var graph = {};
|
3714 |
|
3715 | for (var len = models.length, i = 0; i < len; i++) {
|
3716 | graph[models[i]] = {
|
3717 |
|
3718 |
|
3719 | distance: -1,
|
3720 | parent: null
|
3721 | };
|
3722 | }
|
3723 |
|
3724 | return graph;
|
3725 | }
|
3726 |
|
3727 |
|
3728 | function deriveBFS(fromModel) {
|
3729 | var graph = buildGraph();
|
3730 | var queue = [fromModel];
|
3731 |
|
3732 | graph[fromModel].distance = 0;
|
3733 |
|
3734 | while (queue.length) {
|
3735 | var current = queue.pop();
|
3736 | var adjacents = Object.keys(conversions[current]);
|
3737 |
|
3738 | for (var len = adjacents.length, i = 0; i < len; i++) {
|
3739 | var adjacent = adjacents[i];
|
3740 | var node = graph[adjacent];
|
3741 |
|
3742 | if (node.distance === -1) {
|
3743 | node.distance = graph[current].distance + 1;
|
3744 | node.parent = current;
|
3745 | queue.unshift(adjacent);
|
3746 | }
|
3747 | }
|
3748 | }
|
3749 |
|
3750 | return graph;
|
3751 | }
|
3752 |
|
3753 | function link(from, to) {
|
3754 | return function (args) {
|
3755 | return to(from(args));
|
3756 | };
|
3757 | }
|
3758 |
|
3759 | function wrapConversion(toModel, graph) {
|
3760 | var path = [graph[toModel].parent, toModel];
|
3761 | var fn = conversions[graph[toModel].parent][toModel];
|
3762 |
|
3763 | var cur = graph[toModel].parent;
|
3764 | while (graph[cur].parent) {
|
3765 | path.unshift(graph[cur].parent);
|
3766 | fn = link(conversions[graph[cur].parent][cur], fn);
|
3767 | cur = graph[cur].parent;
|
3768 | }
|
3769 |
|
3770 | fn.conversion = path;
|
3771 | return fn;
|
3772 | }
|
3773 |
|
3774 | module.exports = function (fromModel) {
|
3775 | var graph = deriveBFS(fromModel);
|
3776 | var conversion = {};
|
3777 |
|
3778 | var models = Object.keys(graph);
|
3779 | for (var len = models.length, i = 0; i < len; i++) {
|
3780 | var toModel = models[i];
|
3781 | var node = graph[toModel];
|
3782 |
|
3783 | if (node.parent === null) {
|
3784 |
|
3785 | continue;
|
3786 | }
|
3787 |
|
3788 | conversion[toModel] = wrapConversion(toModel, graph);
|
3789 | }
|
3790 |
|
3791 | return conversion;
|
3792 | };
|
3793 |
|
3794 |
|
3795 |
|
3796 | }),
|
3797 |
|
3798 | (function(module, exports, __webpack_require__) {
|
3799 |
|
3800 |
|
3801 | var colorNames = __webpack_require__(18);
|
3802 |
|
3803 | module.exports = {
|
3804 | getRgba: getRgba,
|
3805 | getHsla: getHsla,
|
3806 | getRgb: getRgb,
|
3807 | getHsl: getHsl,
|
3808 | getHwb: getHwb,
|
3809 | getAlpha: getAlpha,
|
3810 |
|
3811 | hexString: hexString,
|
3812 | rgbString: rgbString,
|
3813 | rgbaString: rgbaString,
|
3814 | percentString: percentString,
|
3815 | percentaString: percentaString,
|
3816 | hslString: hslString,
|
3817 | hslaString: hslaString,
|
3818 | hwbString: hwbString,
|
3819 | keyword: keyword
|
3820 | }
|
3821 |
|
3822 | function getRgba(string) {
|
3823 | if (!string) {
|
3824 | return;
|
3825 | }
|
3826 | var abbr = /^#([a-fA-F0-9]{3})$/,
|
3827 | hex = /^#([a-fA-F0-9]{6})$/,
|
3828 | rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,
|
3829 | per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,
|
3830 | keyword = /(\D+)/;
|
3831 |
|
3832 | var rgb = [0, 0, 0],
|
3833 | a = 1,
|
3834 | match = string.match(abbr);
|
3835 | if (match) {
|
3836 | match = match[1];
|
3837 | for (var i = 0; i < rgb.length; i++) {
|
3838 | rgb[i] = parseInt(match[i] + match[i], 16);
|
3839 | }
|
3840 | }
|
3841 | else if (match = string.match(hex)) {
|
3842 | match = match[1];
|
3843 | for (var i = 0; i < rgb.length; i++) {
|
3844 | rgb[i] = parseInt(match.slice(i * 2, i * 2 + 2), 16);
|
3845 | }
|
3846 | }
|
3847 | else if (match = string.match(rgba)) {
|
3848 | for (var i = 0; i < rgb.length; i++) {
|
3849 | rgb[i] = parseInt(match[i + 1]);
|
3850 | }
|
3851 | a = parseFloat(match[4]);
|
3852 | }
|
3853 | else if (match = string.match(per)) {
|
3854 | for (var i = 0; i < rgb.length; i++) {
|
3855 | rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
3856 | }
|
3857 | a = parseFloat(match[4]);
|
3858 | }
|
3859 | else if (match = string.match(keyword)) {
|
3860 | if (match[1] == "transparent") {
|
3861 | return [0, 0, 0, 0];
|
3862 | }
|
3863 | rgb = colorNames[match[1]];
|
3864 | if (!rgb) {
|
3865 | return;
|
3866 | }
|
3867 | }
|
3868 |
|
3869 | for (var i = 0; i < rgb.length; i++) {
|
3870 | rgb[i] = scale(rgb[i], 0, 255);
|
3871 | }
|
3872 | if (!a && a != 0) {
|
3873 | a = 1;
|
3874 | }
|
3875 | else {
|
3876 | a = scale(a, 0, 1);
|
3877 | }
|
3878 | rgb[3] = a;
|
3879 | return rgb;
|
3880 | }
|
3881 |
|
3882 | function getHsla(string) {
|
3883 | if (!string) {
|
3884 | return;
|
3885 | }
|
3886 | var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
|
3887 | var match = string.match(hsl);
|
3888 | if (match) {
|
3889 | var alpha = parseFloat(match[4]);
|
3890 | var h = scale(parseInt(match[1]), 0, 360),
|
3891 | s = scale(parseFloat(match[2]), 0, 100),
|
3892 | l = scale(parseFloat(match[3]), 0, 100),
|
3893 | a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
|
3894 | return [h, s, l, a];
|
3895 | }
|
3896 | }
|
3897 |
|
3898 | function getHwb(string) {
|
3899 | if (!string) {
|
3900 | return;
|
3901 | }
|
3902 | var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
|
3903 | var match = string.match(hwb);
|
3904 | if (match) {
|
3905 | var alpha = parseFloat(match[4]);
|
3906 | var h = scale(parseInt(match[1]), 0, 360),
|
3907 | w = scale(parseFloat(match[2]), 0, 100),
|
3908 | b = scale(parseFloat(match[3]), 0, 100),
|
3909 | a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
|
3910 | return [h, w, b, a];
|
3911 | }
|
3912 | }
|
3913 |
|
3914 | function getRgb(string) {
|
3915 | var rgba = getRgba(string);
|
3916 | return rgba && rgba.slice(0, 3);
|
3917 | }
|
3918 |
|
3919 | function getHsl(string) {
|
3920 | var hsla = getHsla(string);
|
3921 | return hsla && hsla.slice(0, 3);
|
3922 | }
|
3923 |
|
3924 | function getAlpha(string) {
|
3925 | var vals = getRgba(string);
|
3926 | if (vals) {
|
3927 | return vals[3];
|
3928 | }
|
3929 | else if (vals = getHsla(string)) {
|
3930 | return vals[3];
|
3931 | }
|
3932 | else if (vals = getHwb(string)) {
|
3933 | return vals[3];
|
3934 | }
|
3935 | }
|
3936 |
|
3937 |
|
3938 | function hexString(rgb) {
|
3939 | return "#" + hexDouble(rgb[0]) + hexDouble(rgb[1])
|
3940 | + hexDouble(rgb[2]);
|
3941 | }
|
3942 |
|
3943 | function rgbString(rgba, alpha) {
|
3944 | if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
|
3945 | return rgbaString(rgba, alpha);
|
3946 | }
|
3947 | return "rgb(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2] + ")";
|
3948 | }
|
3949 |
|
3950 | function rgbaString(rgba, alpha) {
|
3951 | if (alpha === undefined) {
|
3952 | alpha = (rgba[3] !== undefined ? rgba[3] : 1);
|
3953 | }
|
3954 | return "rgba(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2]
|
3955 | + ", " + alpha + ")";
|
3956 | }
|
3957 |
|
3958 | function percentString(rgba, alpha) {
|
3959 | if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
|
3960 | return percentaString(rgba, alpha);
|
3961 | }
|
3962 | var r = Math.round(rgba[0]/255 * 100),
|
3963 | g = Math.round(rgba[1]/255 * 100),
|
3964 | b = Math.round(rgba[2]/255 * 100);
|
3965 |
|
3966 | return "rgb(" + r + "%, " + g + "%, " + b + "%)";
|
3967 | }
|
3968 |
|
3969 | function percentaString(rgba, alpha) {
|
3970 | var r = Math.round(rgba[0]/255 * 100),
|
3971 | g = Math.round(rgba[1]/255 * 100),
|
3972 | b = Math.round(rgba[2]/255 * 100);
|
3973 | return "rgba(" + r + "%, " + g + "%, " + b + "%, " + (alpha || rgba[3] || 1) + ")";
|
3974 | }
|
3975 |
|
3976 | function hslString(hsla, alpha) {
|
3977 | if (alpha < 1 || (hsla[3] && hsla[3] < 1)) {
|
3978 | return hslaString(hsla, alpha);
|
3979 | }
|
3980 | return "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)";
|
3981 | }
|
3982 |
|
3983 | function hslaString(hsla, alpha) {
|
3984 | if (alpha === undefined) {
|
3985 | alpha = (hsla[3] !== undefined ? hsla[3] : 1);
|
3986 | }
|
3987 | return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, "
|
3988 | + alpha + ")";
|
3989 | }
|
3990 |
|
3991 |
|
3992 |
|
3993 | function hwbString(hwb, alpha) {
|
3994 | if (alpha === undefined) {
|
3995 | alpha = (hwb[3] !== undefined ? hwb[3] : 1);
|
3996 | }
|
3997 | return "hwb(" + hwb[0] + ", " + hwb[1] + "%, " + hwb[2] + "%"
|
3998 | + (alpha !== undefined && alpha !== 1 ? ", " + alpha : "") + ")";
|
3999 | }
|
4000 |
|
4001 | function keyword(rgb) {
|
4002 | return reverseNames[rgb.slice(0, 3)];
|
4003 | }
|
4004 |
|
4005 |
|
4006 | function scale(num, min, max) {
|
4007 | return Math.min(Math.max(min, num), max);
|
4008 | }
|
4009 |
|
4010 | function hexDouble(num) {
|
4011 | var str = num.toString(16).toUpperCase();
|
4012 | return (str.length < 2) ? "0" + str : str;
|
4013 | }
|
4014 |
|
4015 |
|
4016 |
|
4017 | var reverseNames = {};
|
4018 | for (var name in colorNames) {
|
4019 | reverseNames[colorNames[name]] = name;
|
4020 | }
|
4021 |
|
4022 |
|
4023 | }),
|
4024 |
|
4025 | (function(module, exports, __webpack_require__) {
|
4026 |
|
4027 |
|
4028 | var clone = __webpack_require__(21);
|
4029 | var convert = __webpack_require__(29);
|
4030 | var string = __webpack_require__(31);
|
4031 |
|
4032 | var Color = function (obj) {
|
4033 | if (obj instanceof Color) {
|
4034 | return obj;
|
4035 | }
|
4036 | if (!(this instanceof Color)) {
|
4037 | return new Color(obj);
|
4038 | }
|
4039 |
|
4040 | this.values = {
|
4041 | rgb: [0, 0, 0],
|
4042 | hsl: [0, 0, 0],
|
4043 | hsv: [0, 0, 0],
|
4044 | hwb: [0, 0, 0],
|
4045 | cmyk: [0, 0, 0, 0],
|
4046 | alpha: 1
|
4047 | };
|
4048 |
|
4049 |
|
4050 | var vals;
|
4051 | if (typeof obj === 'string') {
|
4052 | vals = string.getRgba(obj);
|
4053 | if (vals) {
|
4054 | this.setValues('rgb', vals);
|
4055 | } else if (vals = string.getHsla(obj)) {
|
4056 | this.setValues('hsl', vals);
|
4057 | } else if (vals = string.getHwb(obj)) {
|
4058 | this.setValues('hwb', vals);
|
4059 | } else {
|
4060 | throw new Error('Unable to parse color from string "' + obj + '"');
|
4061 | }
|
4062 | } else if (typeof obj === 'object') {
|
4063 | vals = obj;
|
4064 | if (vals.r !== undefined || vals.red !== undefined) {
|
4065 | this.setValues('rgb', vals);
|
4066 | } else if (vals.l !== undefined || vals.lightness !== undefined) {
|
4067 | this.setValues('hsl', vals);
|
4068 | } else if (vals.v !== undefined || vals.value !== undefined) {
|
4069 | this.setValues('hsv', vals);
|
4070 | } else if (vals.w !== undefined || vals.whiteness !== undefined) {
|
4071 | this.setValues('hwb', vals);
|
4072 | } else if (vals.c !== undefined || vals.cyan !== undefined) {
|
4073 | this.setValues('cmyk', vals);
|
4074 | } else {
|
4075 | throw new Error('Unable to parse color from object ' + JSON.stringify(obj));
|
4076 | }
|
4077 | }
|
4078 | };
|
4079 |
|
4080 | Color.prototype = {
|
4081 | rgb: function () {
|
4082 | return this.setSpace('rgb', arguments);
|
4083 | },
|
4084 | hsl: function () {
|
4085 | return this.setSpace('hsl', arguments);
|
4086 | },
|
4087 | hsv: function () {
|
4088 | return this.setSpace('hsv', arguments);
|
4089 | },
|
4090 | hwb: function () {
|
4091 | return this.setSpace('hwb', arguments);
|
4092 | },
|
4093 | cmyk: function () {
|
4094 | return this.setSpace('cmyk', arguments);
|
4095 | },
|
4096 |
|
4097 | rgbArray: function () {
|
4098 | return this.values.rgb;
|
4099 | },
|
4100 | hslArray: function () {
|
4101 | return this.values.hsl;
|
4102 | },
|
4103 | hsvArray: function () {
|
4104 | return this.values.hsv;
|
4105 | },
|
4106 | hwbArray: function () {
|
4107 | if (this.values.alpha !== 1) {
|
4108 | return this.values.hwb.concat([this.values.alpha]);
|
4109 | }
|
4110 | return this.values.hwb;
|
4111 | },
|
4112 | cmykArray: function () {
|
4113 | return this.values.cmyk;
|
4114 | },
|
4115 | rgbaArray: function () {
|
4116 | var rgb = this.values.rgb;
|
4117 | return rgb.concat([this.values.alpha]);
|
4118 | },
|
4119 | rgbaArrayNormalized: function () {
|
4120 | var rgb = this.values.rgb;
|
4121 | var glRgba = [];
|
4122 | for (var i = 0; i < 3; i++) {
|
4123 | glRgba[i] = rgb[i] / 255;
|
4124 | }
|
4125 | glRgba.push(this.values.alpha);
|
4126 | return glRgba;
|
4127 | },
|
4128 | hslaArray: function () {
|
4129 | var hsl = this.values.hsl;
|
4130 | return hsl.concat([this.values.alpha]);
|
4131 | },
|
4132 | alpha: function (val) {
|
4133 | if (val === undefined) {
|
4134 | return this.values.alpha;
|
4135 | }
|
4136 | this.setValues('alpha', val);
|
4137 | return this;
|
4138 | },
|
4139 |
|
4140 | red: function (val) {
|
4141 | return this.setChannel('rgb', 0, val);
|
4142 | },
|
4143 | green: function (val) {
|
4144 | return this.setChannel('rgb', 1, val);
|
4145 | },
|
4146 | blue: function (val) {
|
4147 | return this.setChannel('rgb', 2, val);
|
4148 | },
|
4149 | hue: function (val) {
|
4150 | if (val) {
|
4151 | val %= 360;
|
4152 | val = val < 0 ? 360 + val : val;
|
4153 | }
|
4154 | return this.setChannel('hsl', 0, val);
|
4155 | },
|
4156 | saturation: function (val) {
|
4157 | return this.setChannel('hsl', 1, val);
|
4158 | },
|
4159 | lightness: function (val) {
|
4160 | return this.setChannel('hsl', 2, val);
|
4161 | },
|
4162 | saturationv: function (val) {
|
4163 | return this.setChannel('hsv', 1, val);
|
4164 | },
|
4165 | whiteness: function (val) {
|
4166 | return this.setChannel('hwb', 1, val);
|
4167 | },
|
4168 | blackness: function (val) {
|
4169 | return this.setChannel('hwb', 2, val);
|
4170 | },
|
4171 | value: function (val) {
|
4172 | return this.setChannel('hsv', 2, val);
|
4173 | },
|
4174 | cyan: function (val) {
|
4175 | return this.setChannel('cmyk', 0, val);
|
4176 | },
|
4177 | magenta: function (val) {
|
4178 | return this.setChannel('cmyk', 1, val);
|
4179 | },
|
4180 | yellow: function (val) {
|
4181 | return this.setChannel('cmyk', 2, val);
|
4182 | },
|
4183 | black: function (val) {
|
4184 | return this.setChannel('cmyk', 3, val);
|
4185 | },
|
4186 |
|
4187 | hexString: function () {
|
4188 | return string.hexString(this.values.rgb);
|
4189 | },
|
4190 | rgbString: function () {
|
4191 | return string.rgbString(this.values.rgb, this.values.alpha);
|
4192 | },
|
4193 | rgbaString: function () {
|
4194 | return string.rgbaString(this.values.rgb, this.values.alpha);
|
4195 | },
|
4196 | percentString: function () {
|
4197 | return string.percentString(this.values.rgb, this.values.alpha);
|
4198 | },
|
4199 | hslString: function () {
|
4200 | return string.hslString(this.values.hsl, this.values.alpha);
|
4201 | },
|
4202 | hslaString: function () {
|
4203 | return string.hslaString(this.values.hsl, this.values.alpha);
|
4204 | },
|
4205 | hwbString: function () {
|
4206 | return string.hwbString(this.values.hwb, this.values.alpha);
|
4207 | },
|
4208 | keyword: function () {
|
4209 | return string.keyword(this.values.rgb, this.values.alpha);
|
4210 | },
|
4211 |
|
4212 | rgbNumber: function () {
|
4213 | return (this.values.rgb[0] << 16) | (this.values.rgb[1] << 8) | this.values.rgb[2];
|
4214 | },
|
4215 |
|
4216 | luminosity: function () {
|
4217 |
|
4218 | var rgb = this.values.rgb;
|
4219 | var lum = [];
|
4220 | for (var i = 0; i < rgb.length; i++) {
|
4221 | var chan = rgb[i] / 255;
|
4222 | lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
|
4223 | }
|
4224 | return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
|
4225 | },
|
4226 |
|
4227 | contrast: function (color2) {
|
4228 |
|
4229 | var lum1 = this.luminosity();
|
4230 | var lum2 = color2.luminosity();
|
4231 | if (lum1 > lum2) {
|
4232 | return (lum1 + 0.05) / (lum2 + 0.05);
|
4233 | }
|
4234 | return (lum2 + 0.05) / (lum1 + 0.05);
|
4235 | },
|
4236 |
|
4237 | level: function (color2) {
|
4238 | var contrastRatio = this.contrast(color2);
|
4239 | if (contrastRatio >= 7.1) {
|
4240 | return 'AAA';
|
4241 | }
|
4242 |
|
4243 | return (contrastRatio >= 4.5) ? 'AA' : '';
|
4244 | },
|
4245 |
|
4246 | dark: function () {
|
4247 |
|
4248 | var rgb = this.values.rgb;
|
4249 | var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
|
4250 | return yiq < 128;
|
4251 | },
|
4252 |
|
4253 | light: function () {
|
4254 | return !this.dark();
|
4255 | },
|
4256 |
|
4257 | negate: function () {
|
4258 | var rgb = [];
|
4259 | for (var i = 0; i < 3; i++) {
|
4260 | rgb[i] = 255 - this.values.rgb[i];
|
4261 | }
|
4262 | this.setValues('rgb', rgb);
|
4263 | return this;
|
4264 | },
|
4265 |
|
4266 | lighten: function (ratio) {
|
4267 | this.values.hsl[2] += this.values.hsl[2] * ratio;
|
4268 | this.setValues('hsl', this.values.hsl);
|
4269 | return this;
|
4270 | },
|
4271 |
|
4272 | darken: function (ratio) {
|
4273 | this.values.hsl[2] -= this.values.hsl[2] * ratio;
|
4274 | this.setValues('hsl', this.values.hsl);
|
4275 | return this;
|
4276 | },
|
4277 |
|
4278 | saturate: function (ratio) {
|
4279 | this.values.hsl[1] += this.values.hsl[1] * ratio;
|
4280 | this.setValues('hsl', this.values.hsl);
|
4281 | return this;
|
4282 | },
|
4283 |
|
4284 | desaturate: function (ratio) {
|
4285 | this.values.hsl[1] -= this.values.hsl[1] * ratio;
|
4286 | this.setValues('hsl', this.values.hsl);
|
4287 | return this;
|
4288 | },
|
4289 |
|
4290 | whiten: function (ratio) {
|
4291 | this.values.hwb[1] += this.values.hwb[1] * ratio;
|
4292 | this.setValues('hwb', this.values.hwb);
|
4293 | return this;
|
4294 | },
|
4295 |
|
4296 | blacken: function (ratio) {
|
4297 | this.values.hwb[2] += this.values.hwb[2] * ratio;
|
4298 | this.setValues('hwb', this.values.hwb);
|
4299 | return this;
|
4300 | },
|
4301 |
|
4302 | greyscale: function () {
|
4303 | var rgb = this.values.rgb;
|
4304 |
|
4305 | var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
|
4306 | this.setValues('rgb', [val, val, val]);
|
4307 | return this;
|
4308 | },
|
4309 |
|
4310 | clearer: function (ratio) {
|
4311 | this.setValues('alpha', this.values.alpha - (this.values.alpha * ratio));
|
4312 | return this;
|
4313 | },
|
4314 |
|
4315 | opaquer: function (ratio) {
|
4316 | this.setValues('alpha', this.values.alpha + (this.values.alpha * ratio));
|
4317 | return this;
|
4318 | },
|
4319 |
|
4320 | rotate: function (degrees) {
|
4321 | var hue = this.values.hsl[0];
|
4322 | hue = (hue + degrees) % 360;
|
4323 | hue = hue < 0 ? 360 + hue : hue;
|
4324 | this.values.hsl[0] = hue;
|
4325 | this.setValues('hsl', this.values.hsl);
|
4326 | return this;
|
4327 | },
|
4328 |
|
4329 | |
4330 |
|
4331 |
|
4332 |
|
4333 | mix: function (mixinColor, weight) {
|
4334 | var color1 = this;
|
4335 | var color2 = mixinColor;
|
4336 | var p = weight === undefined ? 0.5 : weight;
|
4337 |
|
4338 | var w = 2 * p - 1;
|
4339 | var a = color1.alpha() - color2.alpha();
|
4340 |
|
4341 | var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
|
4342 | var w2 = 1 - w1;
|
4343 |
|
4344 | return this
|
4345 | .rgb(
|
4346 | w1 * color1.red() + w2 * color2.red(),
|
4347 | w1 * color1.green() + w2 * color2.green(),
|
4348 | w1 * color1.blue() + w2 * color2.blue()
|
4349 | )
|
4350 | .alpha(color1.alpha() * p + color2.alpha() * (1 - p));
|
4351 | },
|
4352 |
|
4353 | toJSON: function () {
|
4354 | return this.rgb();
|
4355 | },
|
4356 |
|
4357 | clone: function () {
|
4358 | var col = new Color();
|
4359 | col.values = clone(this.values);
|
4360 | return col;
|
4361 | }
|
4362 | };
|
4363 |
|
4364 | Color.prototype.getValues = function (space) {
|
4365 | var vals = {};
|
4366 |
|
4367 | for (var i = 0; i < space.length; i++) {
|
4368 | vals[space.charAt(i)] = this.values[space][i];
|
4369 | }
|
4370 |
|
4371 | if (this.values.alpha !== 1) {
|
4372 | vals.a = this.values.alpha;
|
4373 | }
|
4374 |
|
4375 |
|
4376 | return vals;
|
4377 | };
|
4378 |
|
4379 | Color.prototype.setValues = function (space, vals) {
|
4380 | var spaces = {
|
4381 | rgb: ['red', 'green', 'blue'],
|
4382 | hsl: ['hue', 'saturation', 'lightness'],
|
4383 | hsv: ['hue', 'saturation', 'value'],
|
4384 | hwb: ['hue', 'whiteness', 'blackness'],
|
4385 | cmyk: ['cyan', 'magenta', 'yellow', 'black']
|
4386 | };
|
4387 |
|
4388 | var maxes = {
|
4389 | rgb: [255, 255, 255],
|
4390 | hsl: [360, 100, 100],
|
4391 | hsv: [360, 100, 100],
|
4392 | hwb: [360, 100, 100],
|
4393 | cmyk: [100, 100, 100, 100]
|
4394 | };
|
4395 |
|
4396 | var i;
|
4397 | var alpha = 1;
|
4398 | if (space === 'alpha') {
|
4399 | alpha = vals;
|
4400 | } else if (vals.length) {
|
4401 |
|
4402 | this.values[space] = vals.slice(0, space.length);
|
4403 | alpha = vals[space.length];
|
4404 | } else if (vals[space.charAt(0)] !== undefined) {
|
4405 |
|
4406 | for (i = 0; i < space.length; i++) {
|
4407 | this.values[space][i] = vals[space.charAt(i)];
|
4408 | }
|
4409 |
|
4410 | alpha = vals.a;
|
4411 | } else if (vals[spaces[space][0]] !== undefined) {
|
4412 |
|
4413 | var chans = spaces[space];
|
4414 |
|
4415 | for (i = 0; i < space.length; i++) {
|
4416 | this.values[space][i] = vals[chans[i]];
|
4417 | }
|
4418 |
|
4419 | alpha = vals.alpha;
|
4420 | }
|
4421 |
|
4422 | this.values.alpha = Math.max(0, Math.min(1, (alpha === undefined ? this.values.alpha : alpha)));
|
4423 |
|
4424 | if (space === 'alpha') {
|
4425 | return false;
|
4426 | }
|
4427 |
|
4428 | var capped;
|
4429 |
|
4430 |
|
4431 | for (i = 0; i < space.length; i++) {
|
4432 | capped = Math.max(0, Math.min(maxes[space][i], this.values[space][i]));
|
4433 | this.values[space][i] = Math.round(capped);
|
4434 | }
|
4435 |
|
4436 |
|
4437 | for (var sname in spaces) {
|
4438 | if (sname !== space) {
|
4439 | this.values[sname] = convert[space][sname](this.values[space]);
|
4440 | }
|
4441 |
|
4442 |
|
4443 | for (i = 0; i < sname.length; i++) {
|
4444 | capped = Math.max(0, Math.min(maxes[sname][i], this.values[sname][i]));
|
4445 | this.values[sname][i] = Math.round(capped);
|
4446 | }
|
4447 | }
|
4448 |
|
4449 | return true;
|
4450 | };
|
4451 |
|
4452 | Color.prototype.setSpace = function (space, args) {
|
4453 | var vals = args[0];
|
4454 |
|
4455 | if (vals === undefined) {
|
4456 |
|
4457 | return this.getValues(space);
|
4458 | }
|
4459 |
|
4460 |
|
4461 | if (typeof vals === 'number') {
|
4462 | vals = Array.prototype.slice.call(args);
|
4463 | }
|
4464 |
|
4465 | this.setValues(space, vals);
|
4466 | return this;
|
4467 | };
|
4468 |
|
4469 | Color.prototype.setChannel = function (space, index, val) {
|
4470 | if (val === undefined) {
|
4471 |
|
4472 | return this.values[space][index];
|
4473 | } else if (val === this.values[space][index]) {
|
4474 |
|
4475 | return this;
|
4476 | }
|
4477 |
|
4478 |
|
4479 | this.values[space][index] = val;
|
4480 | this.setValues(space, this.values[space]);
|
4481 |
|
4482 | return this;
|
4483 | };
|
4484 |
|
4485 | module.exports = Color;
|
4486 |
|
4487 |
|
4488 | }),
|
4489 |
|
4490 | (function(module, exports) {
|
4491 |
|
4492 | module.exports = require("neptune-namespaces");
|
4493 |
|
4494 | }),
|
4495 |
|
4496 | (function(module, exports) {
|
4497 |
|
4498 | module.exports = require("repl");
|
4499 |
|
4500 | })
|
4501 | ]); |
\ | No newline at end of file |