/
plist-build.js
5348 lines (4513 loc) · 164 KB
/
plist-build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (Buffer){(function (){
/**
* Module dependencies.
*/
var base64 = require('base64-js');
var xmlbuilder = require('xmlbuilder');
/**
* Module exports.
*/
exports.build = build;
/**
* Accepts a `Date` instance and returns an ISO date string.
*
* @param {Date} d - Date instance to serialize
* @returns {String} ISO date string representation of `d`
* @api private
*/
function ISODateString(d){
function pad(n){
return n < 10 ? '0' + n : n;
}
return d.getUTCFullYear()+'-'
+ pad(d.getUTCMonth()+1)+'-'
+ pad(d.getUTCDate())+'T'
+ pad(d.getUTCHours())+':'
+ pad(d.getUTCMinutes())+':'
+ pad(d.getUTCSeconds())+'Z';
}
/**
* Returns the internal "type" of `obj` via the
* `Object.prototype.toString()` trick.
*
* @param {Mixed} obj - any value
* @returns {String} the internal "type" name
* @api private
*/
var toString = Object.prototype.toString;
function type (obj) {
var m = toString.call(obj).match(/\[object (.*)\]/);
return m ? m[1] : m;
}
/**
* Generate an XML plist string from the input object `obj`.
*
* @param {Object} obj - the object to convert
* @param {Object} [opts] - optional options object
* @returns {String} converted plist XML string
* @api public
*/
function build (obj, opts) {
var XMLHDR = {
version: '1.0',
encoding: 'UTF-8'
};
var XMLDTD = {
pubid: '-//Apple//DTD PLIST 1.0//EN',
sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
};
var doc = xmlbuilder.create('plist');
doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
doc.att('version', '1.0');
walk_obj(obj, doc);
if (!opts) opts = {};
// default `pretty` to `true`
opts.pretty = opts.pretty !== false;
return doc.end(opts);
}
/**
* depth first, recursive traversal of a javascript object. when complete,
* next_child contains a reference to the build XML object.
*
* @api private
*/
function walk_obj(next, next_child) {
var tag_type, i, prop;
var name = type(next);
if ('Undefined' == name) {
return;
} else if (Array.isArray(next)) {
next_child = next_child.ele('array');
for (i = 0; i < next.length; i++) {
walk_obj(next[i], next_child);
}
} else if (Buffer.isBuffer(next)) {
next_child.ele('data').raw(next.toString('base64'));
} else if ('Object' == name) {
next_child = next_child.ele('dict');
for (prop in next) {
if (next.hasOwnProperty(prop)) {
next_child.ele('key').txt(prop);
walk_obj(next[prop], next_child);
}
}
} else if ('Number' == name) {
// detect if this is an integer or real
// TODO: add an ability to force one way or another via a "cast"
tag_type = (next % 1 === 0) ? 'integer' : 'real';
next_child.ele(tag_type).txt(next.toString());
} else if ('BigInt' == name) {
next_child.ele('integer').txt(next);
} else if ('Date' == name) {
next_child.ele('date').txt(ISODateString(new Date(next)));
} else if ('Boolean' == name) {
next_child.ele(next ? 'true' : 'false');
} else if ('String' == name) {
next_child.ele('string').txt(next);
} else if ('ArrayBuffer' == name) {
next_child.ele('data').raw(base64.fromByteArray(next));
} else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
// a typed array
next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
} else if ('Null' === name) {
next_child.ele('null').txt('');
}
}
}).call(this)}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
},{"../node_modules/is-buffer/index.js":3,"base64-js":2,"xmlbuilder":36}],2:[function(require,module,exports){
'use strict'
exports.byteLength = byteLength
exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for (var i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i]
revLookup[code.charCodeAt(i)] = i
}
// Support decoding URL-safe base64 strings, as Node.js does.
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
revLookup['-'.charCodeAt(0)] = 62
revLookup['_'.charCodeAt(0)] = 63
function getLens (b64) {
var len = b64.length
if (len % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
// Trim off extra bytes after placeholder bytes are found
// See: https://github.com/beatgammit/base64-js/issues/42
var validLen = b64.indexOf('=')
if (validLen === -1) validLen = len
var placeHoldersLen = validLen === len
? 0
: 4 - (validLen % 4)
return [validLen, placeHoldersLen]
}
// base64 is 4/3 + up to two characters of the original data
function byteLength (b64) {
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
}
function _byteLength (b64, validLen, placeHoldersLen) {
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
}
function toByteArray (b64) {
var tmp
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
var curByte = 0
// if there are placeholders, only get up to the last complete 4 chars
var len = placeHoldersLen > 0
? validLen - 4
: validLen
var i
for (i = 0; i < len; i += 4) {
tmp =
(revLookup[b64.charCodeAt(i)] << 18) |
(revLookup[b64.charCodeAt(i + 1)] << 12) |
(revLookup[b64.charCodeAt(i + 2)] << 6) |
revLookup[b64.charCodeAt(i + 3)]
arr[curByte++] = (tmp >> 16) & 0xFF
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
}
if (placeHoldersLen === 2) {
tmp =
(revLookup[b64.charCodeAt(i)] << 2) |
(revLookup[b64.charCodeAt(i + 1)] >> 4)
arr[curByte++] = tmp & 0xFF
}
if (placeHoldersLen === 1) {
tmp =
(revLookup[b64.charCodeAt(i)] << 10) |
(revLookup[b64.charCodeAt(i + 1)] << 4) |
(revLookup[b64.charCodeAt(i + 2)] >> 2)
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
}
return arr
}
function tripletToBase64 (num) {
return lookup[num >> 18 & 0x3F] +
lookup[num >> 12 & 0x3F] +
lookup[num >> 6 & 0x3F] +
lookup[num & 0x3F]
}
function encodeChunk (uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
tmp =
((uint8[i] << 16) & 0xFF0000) +
((uint8[i + 1] << 8) & 0xFF00) +
(uint8[i + 2] & 0xFF)
output.push(tripletToBase64(tmp))
}
return output.join('')
}
function fromByteArray (uint8) {
var tmp
var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var parts = []
var maxChunkLength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
}
// pad the end with zeros, but make sure to not forget the extra bytes
if (extraBytes === 1) {
tmp = uint8[len - 1]
parts.push(
lookup[tmp >> 2] +
lookup[(tmp << 4) & 0x3F] +
'=='
)
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
parts.push(
lookup[tmp >> 10] +
lookup[(tmp >> 4) & 0x3F] +
lookup[(tmp << 2) & 0x3F] +
'='
)
}
return parts.join('')
}
},{}],3:[function(require,module,exports){
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
// The _isBuffer check is for Safari 5-7 support, because it's missing
// Object.prototype.constructor. Remove this eventually
module.exports = function (obj) {
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
}
function isBuffer (obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
// For Node v0.10 support. Remove this eventually.
function isSlowBuffer (obj) {
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
}
},{}],4:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
module.exports = {
Disconnected: 1,
Preceding: 2,
Following: 4,
Contains: 8,
ContainedBy: 16,
ImplementationSpecific: 32
};
}).call(this);
},{}],5:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
module.exports = {
Element: 1,
Attribute: 2,
Text: 3,
CData: 4,
EntityReference: 5,
EntityDeclaration: 6,
ProcessingInstruction: 7,
Comment: 8,
Document: 9,
DocType: 10,
DocumentFragment: 11,
NotationDeclaration: 12,
// Numeric codes up to 200 are reserved to W3C for possible future use.
// Following are types internal to this library:
Declaration: 201,
Raw: 202,
AttributeDeclaration: 203,
ElementDeclaration: 204,
Dummy: 205
};
}).call(this);
},{}],6:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
// Copies all enumerable own properties from `sources` to `target`
var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
hasProp = {}.hasOwnProperty;
assign = function(target, ...sources) {
var i, key, len, source;
if (isFunction(Object.assign)) {
Object.assign.apply(null, arguments);
} else {
for (i = 0, len = sources.length; i < len; i++) {
source = sources[i];
if (source != null) {
for (key in source) {
if (!hasProp.call(source, key)) continue;
target[key] = source[key];
}
}
}
}
return target;
};
// Determines if `val` is a Function object
isFunction = function(val) {
return !!val && Object.prototype.toString.call(val) === '[object Function]';
};
// Determines if `val` is an Object
isObject = function(val) {
var ref;
return !!val && ((ref = typeof val) === 'function' || ref === 'object');
};
// Determines if `val` is an Array
isArray = function(val) {
if (isFunction(Array.isArray)) {
return Array.isArray(val);
} else {
return Object.prototype.toString.call(val) === '[object Array]';
}
};
// Determines if `val` is an empty Array or an Object with no own properties
isEmpty = function(val) {
var key;
if (isArray(val)) {
return !val.length;
} else {
for (key in val) {
if (!hasProp.call(val, key)) continue;
return false;
}
return true;
}
};
// Determines if `val` is a plain Object
isPlainObject = function(val) {
var ctor, proto;
return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
};
// Gets the primitive value of an object
getValue = function(obj) {
if (isFunction(obj.valueOf)) {
return obj.valueOf();
} else {
return obj;
}
};
module.exports.assign = assign;
module.exports.isFunction = isFunction;
module.exports.isObject = isObject;
module.exports.isArray = isArray;
module.exports.isEmpty = isEmpty;
module.exports.isPlainObject = isPlainObject;
module.exports.getValue = getValue;
}).call(this);
},{}],7:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
module.exports = {
None: 0,
OpenTag: 1,
InsideTag: 2,
CloseTag: 3
};
}).call(this);
},{}],8:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
var NodeType, XMLAttribute, XMLNode;
NodeType = require('./NodeType');
XMLNode = require('./XMLNode');
// Represents an attribute
module.exports = XMLAttribute = (function() {
class XMLAttribute {
// Initializes a new instance of `XMLAttribute`
// `parent` the parent node
// `name` attribute target
// `value` attribute value
constructor(parent, name, value) {
this.parent = parent;
if (this.parent) {
this.options = this.parent.options;
this.stringify = this.parent.stringify;
}
if (name == null) {
throw new Error("Missing attribute name. " + this.debugInfo(name));
}
this.name = this.stringify.name(name);
this.value = this.stringify.attValue(value);
this.type = NodeType.Attribute;
// DOM level 3
this.isId = false;
this.schemaTypeInfo = null;
}
// Creates and returns a deep clone of `this`
clone() {
return Object.create(this);
}
// Converts the XML fragment to string
// `options.pretty` pretty prints the result
// `options.indent` indentation for pretty print
// `options.offset` how many indentations to add to every line for pretty print
// `options.newline` newline sequence for pretty print
toString(options) {
return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
}
// Returns debug string for this node
debugInfo(name) {
name = name || this.name;
if (name == null) {
return "parent: <" + this.parent.name + ">";
} else {
return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
}
}
isEqualNode(node) {
if (node.namespaceURI !== this.namespaceURI) {
return false;
}
if (node.prefix !== this.prefix) {
return false;
}
if (node.localName !== this.localName) {
return false;
}
if (node.value !== this.value) {
return false;
}
return true;
}
};
// DOM level 1
Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
get: function() {
return this.type;
}
});
Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
get: function() {
return this.parent;
}
});
// DOM level 3
Object.defineProperty(XMLAttribute.prototype, 'textContent', {
get: function() {
return this.value;
},
set: function(value) {
return this.value = value || '';
}
});
// DOM level 4
Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
get: function() {
return '';
}
});
Object.defineProperty(XMLAttribute.prototype, 'prefix', {
get: function() {
return '';
}
});
Object.defineProperty(XMLAttribute.prototype, 'localName', {
get: function() {
return this.name;
}
});
Object.defineProperty(XMLAttribute.prototype, 'specified', {
get: function() {
return true;
}
});
return XMLAttribute;
}).call(this);
}).call(this);
},{"./NodeType":5,"./XMLNode":27}],9:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
var NodeType, XMLCData, XMLCharacterData;
NodeType = require('./NodeType');
XMLCharacterData = require('./XMLCharacterData');
// Represents a CDATA node
module.exports = XMLCData = class XMLCData extends XMLCharacterData {
// Initializes a new instance of `XMLCData`
// `text` CDATA text
constructor(parent, text) {
super(parent);
if (text == null) {
throw new Error("Missing CDATA text. " + this.debugInfo());
}
this.name = "#cdata-section";
this.type = NodeType.CData;
this.value = this.stringify.cdata(text);
}
// Creates and returns a deep clone of `this`
clone() {
return Object.create(this);
}
// Converts the XML fragment to string
// `options.pretty` pretty prints the result
// `options.indent` indentation for pretty print
// `options.offset` how many indentations to add to every line for pretty print
// `options.newline` newline sequence for pretty print
toString(options) {
return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
}
};
}).call(this);
},{"./NodeType":5,"./XMLCharacterData":10}],10:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
var XMLCharacterData, XMLNode;
XMLNode = require('./XMLNode');
// Represents a character data node
module.exports = XMLCharacterData = (function() {
class XMLCharacterData extends XMLNode {
// Initializes a new instance of `XMLCharacterData`
constructor(parent) {
super(parent);
this.value = '';
}
// Creates and returns a deep clone of `this`
clone() {
return Object.create(this);
}
// DOM level 1 functions to be implemented later
substringData(offset, count) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
appendData(arg) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
insertData(offset, arg) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
deleteData(offset, count) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
replaceData(offset, count, arg) {
throw new Error("This DOM method is not implemented." + this.debugInfo());
}
isEqualNode(node) {
if (!super.isEqualNode(node)) {
return false;
}
if (node.data !== this.data) {
return false;
}
return true;
}
};
// DOM level 1
Object.defineProperty(XMLCharacterData.prototype, 'data', {
get: function() {
return this.value;
},
set: function(value) {
return this.value = value || '';
}
});
Object.defineProperty(XMLCharacterData.prototype, 'length', {
get: function() {
return this.value.length;
}
});
// DOM level 3
Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
get: function() {
return this.value;
},
set: function(value) {
return this.value = value || '';
}
});
return XMLCharacterData;
}).call(this);
}).call(this);
},{"./XMLNode":27}],11:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
var NodeType, XMLCharacterData, XMLComment;
NodeType = require('./NodeType');
XMLCharacterData = require('./XMLCharacterData');
// Represents a comment node
module.exports = XMLComment = class XMLComment extends XMLCharacterData {
// Initializes a new instance of `XMLComment`
// `text` comment text
constructor(parent, text) {
super(parent);
if (text == null) {
throw new Error("Missing comment text. " + this.debugInfo());
}
this.name = "#comment";
this.type = NodeType.Comment;
this.value = this.stringify.comment(text);
}
// Creates and returns a deep clone of `this`
clone() {
return Object.create(this);
}
// Converts the XML fragment to string
// `options.pretty` pretty prints the result
// `options.indent` indentation for pretty print
// `options.offset` how many indentations to add to every line for pretty print
// `options.newline` newline sequence for pretty print
toString(options) {
return this.options.writer.comment(this, this.options.writer.filterOptions(options));
}
};
}).call(this);
},{"./NodeType":5,"./XMLCharacterData":10}],12:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
XMLDOMStringList = require('./XMLDOMStringList');
// Implements the DOMConfiguration interface
module.exports = XMLDOMConfiguration = (function() {
class XMLDOMConfiguration {
constructor() {
var clonedSelf;
this.defaultParams = {
"canonical-form": false,
"cdata-sections": false,
"comments": false,
"datatype-normalization": false,
"element-content-whitespace": true,
"entities": true,
"error-handler": new XMLDOMErrorHandler(),
"infoset": true,
"validate-if-schema": false,
"namespaces": true,
"namespace-declarations": true,
"normalize-characters": false,
"schema-location": '',
"schema-type": '',
"split-cdata-sections": true,
"validate": false,
"well-formed": true
};
this.params = clonedSelf = Object.create(this.defaultParams);
}
// Gets the value of a parameter.
// `name` name of the parameter
getParameter(name) {
if (this.params.hasOwnProperty(name)) {
return this.params[name];
} else {
return null;
}
}
// Checks if setting a parameter to a specific value is supported.
// `name` name of the parameter
// `value` parameter value
canSetParameter(name, value) {
return true;
}
// Sets the value of a parameter.
// `name` name of the parameter
// `value` new value or null if the user wishes to unset the parameter
setParameter(name, value) {
if (value != null) {
return this.params[name] = value;
} else {
return delete this.params[name];
}
}
};
// Returns the list of parameter names
Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
get: function() {
return new XMLDOMStringList(Object.keys(this.defaultParams));
}
});
return XMLDOMConfiguration;
}).call(this);
}).call(this);
},{"./XMLDOMErrorHandler":13,"./XMLDOMStringList":15}],13:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
// Represents the error handler for DOM operations
var XMLDOMErrorHandler;
module.exports = XMLDOMErrorHandler = class XMLDOMErrorHandler {
// Initializes a new instance of `XMLDOMErrorHandler`
constructor() {}
// Called on the error handler when an error occurs.
// `error` the error message as a string
handleError(error) {
throw new Error(error);
}
};
}).call(this);
},{}],14:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
// Implements the DOMImplementation interface
var XMLDOMImplementation;
module.exports = XMLDOMImplementation = class XMLDOMImplementation {
// Tests if the DOM implementation implements a specific feature.
// `feature` package name of the feature to test. In Level 1, the
// legal values are "HTML" and "XML" (case-insensitive).
// `version` version number of the package name to test.
// In Level 1, this is the string "1.0". If the version is
// not specified, supporting any version of the feature will
// cause the method to return true.
hasFeature(feature, version) {
return true;
}
// Creates a new document type declaration.
// `qualifiedName` qualified name of the document type to be created
// `publicId` public identifier of the external subset
// `systemId` system identifier of the external subset
createDocumentType(qualifiedName, publicId, systemId) {
throw new Error("This DOM method is not implemented.");
}
// Creates a new document.
// `namespaceURI` namespace URI of the document element to create
// `qualifiedName` the qualified name of the document to be created
// `doctype` the type of document to be created or null
createDocument(namespaceURI, qualifiedName, doctype) {
throw new Error("This DOM method is not implemented.");
}
// Creates a new HTML document.
// `title` document title
createHTMLDocument(title) {
throw new Error("This DOM method is not implemented.");
}
// Returns a specialized object which implements the specialized APIs
// of the specified feature and version.
// `feature` name of the feature requested.
// `version` version number of the feature to test
getFeature(feature, version) {
throw new Error("This DOM method is not implemented.");
}
};
}).call(this);
},{}],15:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
// Represents a list of string entries
var XMLDOMStringList;
module.exports = XMLDOMStringList = (function() {
class XMLDOMStringList {
// Initializes a new instance of `XMLDOMStringList`
// This is just a wrapper around an ordinary
// JS array.
// `arr` the array of string values
constructor(arr) {
this.arr = arr || [];
}
// Returns the indexth item in the collection.
// `index` index into the collection
item(index) {
return this.arr[index] || null;
}
// Test if a string is part of this DOMStringList.
// `str` the string to look for
contains(str) {
return this.arr.indexOf(str) !== -1;
}
};
// Returns the number of strings in the list.
Object.defineProperty(XMLDOMStringList.prototype, 'length', {
get: function() {
return this.arr.length;
}
});
return XMLDOMStringList;
}).call(this);
}).call(this);
},{}],16:[function(require,module,exports){
// Generated by CoffeeScript 2.4.1
(function() {
var NodeType, XMLDTDAttList, XMLNode;
XMLNode = require('./XMLNode');
NodeType = require('./NodeType');
// Represents an attribute list
module.exports = XMLDTDAttList = class XMLDTDAttList extends XMLNode {
// Initializes a new instance of `XMLDTDAttList`
// `parent` the parent `XMLDocType` element
// `elementName` the name of the element containing this attribute
// `attributeName` attribute name
// `attributeType` type of the attribute
// `defaultValueType` default value type (either #REQUIRED, #IMPLIED,
// #FIXED or #DEFAULT)
// `defaultValue` default value of the attribute
// (only used for #FIXED or #DEFAULT)
constructor(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {