1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | var utils_1 = require("./utils");
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | var Options = (function () {
|
26 | function Options(options) {
|
27 | if (options === void 0) { options = {}; }
|
28 | this.aliasString = "=";
|
29 | this.attributeString = "@";
|
30 | this.cdataInvalidChars = false;
|
31 | this.cdataKeys = [];
|
32 | this.replaceInvalidChars = false;
|
33 | this.useSelfClosingTagIfEmpty = true;
|
34 | this.validation = true;
|
35 | this.valueString = "#";
|
36 | if (!utils_1.isUndefined(options.validation)) {
|
37 | this.validation = options.validation;
|
38 | }
|
39 | if (!utils_1.isUndefined(options.aliasString)) {
|
40 | this.aliasString = options.aliasString;
|
41 | }
|
42 | if (!utils_1.isUndefined(options.attributeString)) {
|
43 | this.attributeString = options.attributeString;
|
44 | }
|
45 | if (!utils_1.isUndefined(options.cdataInvalidChars)) {
|
46 | this.cdataInvalidChars = options.cdataInvalidChars;
|
47 | }
|
48 | if (!utils_1.isUndefined(options.cdataKeys)) {
|
49 | this.cdataKeys = options.cdataKeys;
|
50 | }
|
51 | this.declaration = new DeclarationOptions(options.declaration);
|
52 | this.dtd = new DtdOptions(this.validation, options.dtd);
|
53 | this.format = new FormatOptions(options.format);
|
54 | if (!utils_1.isUndefined(options.replaceInvalidChars)) {
|
55 | this.replaceInvalidChars = options.replaceInvalidChars;
|
56 | }
|
57 | this.typeHandlers = new TypeHandlers(options.typeHandlers);
|
58 | if (!utils_1.isUndefined(options.useSelfClosingTagIfEmpty)) {
|
59 | this.useSelfClosingTagIfEmpty = options.useSelfClosingTagIfEmpty;
|
60 | }
|
61 | if (!utils_1.isUndefined(options.valueString)) {
|
62 | this.valueString = options.valueString;
|
63 | }
|
64 | this.wrapHandlers = new WrapHandlers(options.wrapHandlers);
|
65 | }
|
66 | return Options;
|
67 | }());
|
68 | exports.Options = Options;
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | var DeclarationOptions = (function () {
|
76 | function DeclarationOptions(declarationOptions) {
|
77 | if (declarationOptions === void 0) { declarationOptions = {}; }
|
78 | this.include = true;
|
79 | if (!utils_1.isUndefined(declarationOptions.include)) {
|
80 | this.include = declarationOptions.include;
|
81 | }
|
82 |
|
83 | this.encoding = declarationOptions.encoding;
|
84 | this.standalone = declarationOptions.standalone;
|
85 | this.version = declarationOptions.version;
|
86 | }
|
87 | return DeclarationOptions;
|
88 | }());
|
89 | exports.DeclarationOptions = DeclarationOptions;
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | var DtdOptions = (function () {
|
97 | function DtdOptions(validation, dtdOptions) {
|
98 | if (dtdOptions === void 0) { dtdOptions = {}; }
|
99 | this.include = false;
|
100 | if (!utils_1.isUndefined(dtdOptions.include)) {
|
101 | this.include = dtdOptions.include;
|
102 | }
|
103 | if (validation && utils_1.isUndefined(dtdOptions.name) && this.include) {
|
104 | throw new Error("options.dtd.name should be defined if"
|
105 | + " options.dtd.include is true");
|
106 | }
|
107 | this.name = dtdOptions.name;
|
108 | this.sysId = dtdOptions.sysId;
|
109 | this.pubId = dtdOptions.pubId;
|
110 | }
|
111 | return DtdOptions;
|
112 | }());
|
113 | exports.DtdOptions = DtdOptions;
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | var FormatOptions = (function () {
|
121 | function FormatOptions(formatOptions) {
|
122 | if (formatOptions === void 0) { formatOptions = {}; }
|
123 | this.doubleQuotes = formatOptions.doubleQuotes;
|
124 | this.indent = formatOptions.indent;
|
125 | this.newline = formatOptions.newline;
|
126 | this.pretty = formatOptions.pretty;
|
127 | }
|
128 | return FormatOptions;
|
129 | }());
|
130 | exports.FormatOptions = FormatOptions;
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | var TypeHandlers = (function () {
|
138 | function TypeHandlers(typeHandlers) {
|
139 | if (typeHandlers === void 0) { typeHandlers = {}; }
|
140 | for (var key in typeHandlers) {
|
141 | if (Object.prototype.hasOwnProperty.call(typeHandlers, key)) {
|
142 | this[key] = typeHandlers[key];
|
143 | }
|
144 | }
|
145 | }
|
146 | return TypeHandlers;
|
147 | }());
|
148 | exports.TypeHandlers = TypeHandlers;
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | var WrapHandlers = (function () {
|
156 | function WrapHandlers(wrapHandlers) {
|
157 | if (wrapHandlers === void 0) { wrapHandlers = {}; }
|
158 | for (var key in wrapHandlers) {
|
159 | if (Object.prototype.hasOwnProperty.call(wrapHandlers, key)) {
|
160 | this[key] = wrapHandlers[key];
|
161 | }
|
162 | }
|
163 | }
|
164 | return WrapHandlers;
|
165 | }());
|
166 | exports.WrapHandlers = WrapHandlers;
|