open-agreements 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/README.md +1 -1
  2. package/content/templates/openagreements-due-diligence-request-list/template.docx +0 -0
  3. package/content/templates/openagreements-due-diligence-request-list/template.md +1 -1
  4. package/dist/core/fill-pipeline.d.ts.map +1 -1
  5. package/dist/core/fill-pipeline.js +0 -8
  6. package/dist/core/fill-pipeline.js.map +1 -1
  7. package/dist/core/unified-pipeline.d.ts.map +1 -1
  8. package/dist/core/unified-pipeline.js +4 -6
  9. package/dist/core/unified-pipeline.js.map +1 -1
  10. package/gemini-extension.json +1 -1
  11. package/node_modules/@xmldom/xmldom/CHANGELOG.md +939 -0
  12. package/node_modules/@xmldom/xmldom/LICENSE +8 -0
  13. package/node_modules/@xmldom/xmldom/SECURITY.md +50 -0
  14. package/node_modules/@xmldom/xmldom/index.d.ts +1664 -0
  15. package/node_modules/@xmldom/xmldom/lib/.eslintrc.yml +3 -0
  16. package/node_modules/@xmldom/xmldom/lib/conventions.js +429 -0
  17. package/node_modules/@xmldom/xmldom/lib/dom-parser.js +586 -0
  18. package/node_modules/@xmldom/xmldom/lib/dom.js +3192 -0
  19. package/node_modules/@xmldom/xmldom/lib/entities.js +2171 -0
  20. package/node_modules/@xmldom/xmldom/lib/errors.js +202 -0
  21. package/node_modules/@xmldom/xmldom/lib/grammar.js +533 -0
  22. package/node_modules/@xmldom/xmldom/lib/index.js +41 -0
  23. package/node_modules/@xmldom/xmldom/lib/sax.js +929 -0
  24. package/node_modules/@xmldom/xmldom/package.json +74 -0
  25. package/node_modules/@xmldom/xmldom/readme.md +364 -0
  26. package/node_modules/core-util-is/LICENSE +19 -0
  27. package/node_modules/core-util-is/README.md +3 -0
  28. package/node_modules/core-util-is/lib/util.js +107 -0
  29. package/node_modules/core-util-is/package.json +38 -0
  30. package/node_modules/immediate/LICENSE.txt +20 -0
  31. package/node_modules/immediate/README.md +93 -0
  32. package/node_modules/immediate/dist/immediate.js +75 -0
  33. package/node_modules/immediate/dist/immediate.min.js +1 -0
  34. package/node_modules/immediate/lib/browser.js +69 -0
  35. package/node_modules/immediate/lib/index.js +73 -0
  36. package/node_modules/immediate/package.json +42 -0
  37. package/node_modules/inherits/LICENSE +16 -0
  38. package/node_modules/inherits/README.md +42 -0
  39. package/node_modules/inherits/inherits.js +9 -0
  40. package/node_modules/inherits/inherits_browser.js +27 -0
  41. package/node_modules/inherits/package.json +29 -0
  42. package/node_modules/isarray/.npmignore +1 -0
  43. package/node_modules/isarray/.travis.yml +4 -0
  44. package/node_modules/isarray/Makefile +6 -0
  45. package/node_modules/isarray/README.md +60 -0
  46. package/node_modules/isarray/component.json +19 -0
  47. package/node_modules/isarray/index.js +5 -0
  48. package/node_modules/isarray/package.json +45 -0
  49. package/node_modules/isarray/test.js +20 -0
  50. package/node_modules/jszip/.codeclimate.yml +16 -0
  51. package/node_modules/jszip/.editorconfig +8 -0
  52. package/node_modules/jszip/.eslintrc.js +43 -0
  53. package/node_modules/jszip/.github/workflows/pr.yaml +58 -0
  54. package/node_modules/jszip/.jekyll-metadata +0 -0
  55. package/node_modules/jszip/.travis.yml +17 -0
  56. package/node_modules/jszip/CHANGES.md +204 -0
  57. package/node_modules/jszip/LICENSE.markdown +651 -0
  58. package/node_modules/jszip/README.markdown +33 -0
  59. package/node_modules/jszip/deps.js +37 -0
  60. package/node_modules/jszip/dist/jszip.js +11577 -0
  61. package/node_modules/jszip/dist/jszip.min.js +13 -0
  62. package/node_modules/jszip/graph.svg +601 -0
  63. package/node_modules/jszip/index.d.ts +330 -0
  64. package/node_modules/jszip/lib/base64.js +106 -0
  65. package/node_modules/jszip/lib/compressedObject.js +74 -0
  66. package/node_modules/jszip/lib/compressions.js +14 -0
  67. package/node_modules/jszip/lib/crc32.js +77 -0
  68. package/node_modules/jszip/lib/defaults.js +11 -0
  69. package/node_modules/jszip/lib/external.js +18 -0
  70. package/node_modules/jszip/lib/flate.js +85 -0
  71. package/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
  72. package/node_modules/jszip/lib/generate/index.js +57 -0
  73. package/node_modules/jszip/lib/index.js +55 -0
  74. package/node_modules/jszip/lib/license_header.js +11 -0
  75. package/node_modules/jszip/lib/load.js +88 -0
  76. package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
  77. package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
  78. package/node_modules/jszip/lib/nodejsUtils.js +57 -0
  79. package/node_modules/jszip/lib/object.js +384 -0
  80. package/node_modules/jszip/lib/readable-stream-browser.js +10 -0
  81. package/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
  82. package/node_modules/jszip/lib/reader/DataReader.js +116 -0
  83. package/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
  84. package/node_modules/jszip/lib/reader/StringReader.js +38 -0
  85. package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
  86. package/node_modules/jszip/lib/reader/readerFor.js +28 -0
  87. package/node_modules/jszip/lib/signature.js +7 -0
  88. package/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
  89. package/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
  90. package/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
  91. package/node_modules/jszip/lib/stream/DataWorker.js +116 -0
  92. package/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
  93. package/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
  94. package/node_modules/jszip/lib/support.js +38 -0
  95. package/node_modules/jszip/lib/utf8.js +275 -0
  96. package/node_modules/jszip/lib/utils.js +501 -0
  97. package/node_modules/jszip/lib/zipEntries.js +261 -0
  98. package/node_modules/jszip/lib/zipEntry.js +293 -0
  99. package/node_modules/jszip/lib/zipObject.js +133 -0
  100. package/node_modules/jszip/package.json +67 -0
  101. package/node_modules/jszip/sponsors.md +21 -0
  102. package/node_modules/jszip/tsconfig.json +101 -0
  103. package/node_modules/jszip/vendor/FileSaver.js +247 -0
  104. package/node_modules/lie/README.md +62 -0
  105. package/node_modules/lie/dist/lie.js +350 -0
  106. package/node_modules/lie/dist/lie.min.js +1 -0
  107. package/node_modules/lie/dist/lie.polyfill.js +358 -0
  108. package/node_modules/lie/dist/lie.polyfill.min.js +1 -0
  109. package/node_modules/lie/lib/browser.js +273 -0
  110. package/node_modules/lie/lib/index.js +298 -0
  111. package/node_modules/lie/license.md +7 -0
  112. package/node_modules/lie/lie.d.ts +244 -0
  113. package/node_modules/lie/package.json +69 -0
  114. package/node_modules/lie/polyfill.js +4 -0
  115. package/node_modules/pako/LICENSE +21 -0
  116. package/node_modules/pako/README.md +191 -0
  117. package/node_modules/pako/dist/pako.js +6818 -0
  118. package/node_modules/pako/dist/pako.min.js +1 -0
  119. package/node_modules/pako/dist/pako_deflate.js +3997 -0
  120. package/node_modules/pako/dist/pako_deflate.min.js +1 -0
  121. package/node_modules/pako/dist/pako_inflate.js +3300 -0
  122. package/node_modules/pako/dist/pako_inflate.min.js +1 -0
  123. package/node_modules/pako/index.js +14 -0
  124. package/node_modules/pako/lib/deflate.js +400 -0
  125. package/node_modules/pako/lib/inflate.js +423 -0
  126. package/node_modules/pako/lib/utils/common.js +105 -0
  127. package/node_modules/pako/lib/utils/strings.js +187 -0
  128. package/node_modules/pako/lib/zlib/README +59 -0
  129. package/node_modules/pako/lib/zlib/adler32.js +51 -0
  130. package/node_modules/pako/lib/zlib/constants.js +68 -0
  131. package/node_modules/pako/lib/zlib/crc32.js +59 -0
  132. package/node_modules/pako/lib/zlib/deflate.js +1874 -0
  133. package/node_modules/pako/lib/zlib/gzheader.js +58 -0
  134. package/node_modules/pako/lib/zlib/inffast.js +345 -0
  135. package/node_modules/pako/lib/zlib/inflate.js +1556 -0
  136. package/node_modules/pako/lib/zlib/inftrees.js +343 -0
  137. package/node_modules/pako/lib/zlib/messages.js +32 -0
  138. package/node_modules/pako/lib/zlib/trees.js +1222 -0
  139. package/node_modules/pako/lib/zlib/zstream.js +47 -0
  140. package/node_modules/pako/package.json +44 -0
  141. package/node_modules/process-nextick-args/index.js +45 -0
  142. package/node_modules/process-nextick-args/license.md +19 -0
  143. package/node_modules/process-nextick-args/package.json +25 -0
  144. package/node_modules/process-nextick-args/readme.md +18 -0
  145. package/node_modules/readable-stream/.travis.yml +34 -0
  146. package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  147. package/node_modules/readable-stream/GOVERNANCE.md +136 -0
  148. package/node_modules/readable-stream/LICENSE +47 -0
  149. package/node_modules/readable-stream/README.md +58 -0
  150. package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
  151. package/node_modules/readable-stream/duplex-browser.js +1 -0
  152. package/node_modules/readable-stream/duplex.js +1 -0
  153. package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
  154. package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
  155. package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
  156. package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
  157. package/node_modules/readable-stream/lib/_stream_writable.js +685 -0
  158. package/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
  159. package/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
  160. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  161. package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  162. package/node_modules/readable-stream/package.json +52 -0
  163. package/node_modules/readable-stream/passthrough.js +1 -0
  164. package/node_modules/readable-stream/readable-browser.js +7 -0
  165. package/node_modules/readable-stream/readable.js +19 -0
  166. package/node_modules/readable-stream/transform.js +1 -0
  167. package/node_modules/readable-stream/writable-browser.js +1 -0
  168. package/node_modules/readable-stream/writable.js +8 -0
  169. package/node_modules/safe-buffer/LICENSE +21 -0
  170. package/node_modules/safe-buffer/README.md +584 -0
  171. package/node_modules/safe-buffer/index.d.ts +187 -0
  172. package/node_modules/safe-buffer/index.js +62 -0
  173. package/node_modules/safe-buffer/package.json +37 -0
  174. package/node_modules/setimmediate/LICENSE.txt +20 -0
  175. package/node_modules/setimmediate/package.json +30 -0
  176. package/node_modules/setimmediate/setImmediate.js +186 -0
  177. package/node_modules/string_decoder/.travis.yml +50 -0
  178. package/node_modules/string_decoder/LICENSE +48 -0
  179. package/node_modules/string_decoder/README.md +47 -0
  180. package/node_modules/string_decoder/lib/string_decoder.js +296 -0
  181. package/node_modules/string_decoder/package.json +31 -0
  182. package/node_modules/util-deprecate/History.md +16 -0
  183. package/node_modules/util-deprecate/LICENSE +24 -0
  184. package/node_modules/util-deprecate/README.md +53 -0
  185. package/node_modules/util-deprecate/browser.js +67 -0
  186. package/node_modules/util-deprecate/node.js +6 -0
  187. package/node_modules/util-deprecate/package.json +27 -0
  188. package/package.json +1 -1
  189. package/skills/client-email/SKILL.md +8 -6
  190. package/skills/employment-contract/SKILL.md +23 -6
  191. package/skills/non-compete-contract-explainer/content/alabama.md +251 -0
  192. package/skills/non-compete-contract-explainer/content/alaska.md +160 -0
  193. package/skills/non-compete-contract-explainer/content/american-samoa.md +187 -0
  194. package/skills/non-compete-contract-explainer/content/arizona.md +293 -0
  195. package/skills/non-compete-contract-explainer/content/arkansas.md +235 -0
  196. package/skills/non-compete-contract-explainer/content/california.md +270 -0
  197. package/skills/non-compete-contract-explainer/content/cnmi.md +168 -0
  198. package/skills/non-compete-contract-explainer/content/colorado.md +277 -0
  199. package/skills/non-compete-contract-explainer/content/connecticut.md +220 -0
  200. package/skills/non-compete-contract-explainer/content/delaware.md +222 -0
  201. package/skills/non-compete-contract-explainer/content/district-of-columbia.md +263 -0
  202. package/skills/non-compete-contract-explainer/content/florida.md +267 -0
  203. package/skills/non-compete-contract-explainer/content/georgia.md +323 -0
  204. package/skills/non-compete-contract-explainer/content/guam.md +180 -0
  205. package/skills/non-compete-contract-explainer/content/hawaii.md +236 -0
  206. package/skills/non-compete-contract-explainer/content/idaho.md +258 -0
  207. package/skills/non-compete-contract-explainer/content/illinois.md +266 -0
  208. package/skills/non-compete-contract-explainer/content/india.md +269 -0
  209. package/skills/non-compete-contract-explainer/content/indiana.md +253 -0
  210. package/skills/non-compete-contract-explainer/content/iowa.md +232 -0
  211. package/skills/non-compete-contract-explainer/content/kansas.md +227 -0
  212. package/skills/non-compete-contract-explainer/content/kentucky.md +201 -0
  213. package/skills/non-compete-contract-explainer/content/louisiana.md +272 -0
  214. package/skills/non-compete-contract-explainer/content/maine.md +178 -0
  215. package/skills/non-compete-contract-explainer/content/maryland.md +244 -0
  216. package/skills/non-compete-contract-explainer/content/massachusetts.md +272 -0
  217. package/skills/non-compete-contract-explainer/content/michigan.md +222 -0
  218. package/skills/non-compete-contract-explainer/content/minnesota.md +171 -0
  219. package/skills/non-compete-contract-explainer/content/mississippi.md +237 -0
  220. package/skills/non-compete-contract-explainer/content/missouri.md +219 -0
  221. package/skills/non-compete-contract-explainer/content/montana.md +202 -0
  222. package/skills/non-compete-contract-explainer/content/nebraska.md +206 -0
  223. package/skills/non-compete-contract-explainer/content/nevada.md +278 -0
  224. package/skills/non-compete-contract-explainer/content/new-hampshire.md +233 -0
  225. package/skills/non-compete-contract-explainer/content/new-jersey.md +277 -0
  226. package/skills/non-compete-contract-explainer/content/new-mexico.md +244 -0
  227. package/skills/non-compete-contract-explainer/content/new-york.md +226 -0
  228. package/skills/non-compete-contract-explainer/content/north-carolina.md +346 -0
  229. package/skills/non-compete-contract-explainer/content/north-dakota.md +187 -0
  230. package/skills/non-compete-contract-explainer/content/ohio.md +207 -0
  231. package/skills/non-compete-contract-explainer/content/oklahoma.md +196 -0
  232. package/skills/non-compete-contract-explainer/content/oregon.md +359 -0
  233. package/skills/non-compete-contract-explainer/content/pennsylvania.md +254 -0
  234. package/skills/non-compete-contract-explainer/content/philippines.md +211 -0
  235. package/skills/non-compete-contract-explainer/content/puerto-rico.md +163 -0
  236. package/skills/non-compete-contract-explainer/content/rhode-island.md +171 -0
  237. package/skills/non-compete-contract-explainer/content/singapore.md +229 -0
  238. package/skills/non-compete-contract-explainer/content/south-carolina.md +226 -0
  239. package/skills/non-compete-contract-explainer/content/south-dakota.md +222 -0
  240. package/skills/non-compete-contract-explainer/content/tennessee.md +251 -0
  241. package/skills/non-compete-contract-explainer/content/texas.md +297 -0
  242. package/skills/non-compete-contract-explainer/content/us-virgin-islands.md +193 -0
  243. package/skills/non-compete-contract-explainer/content/utah.md +250 -0
  244. package/skills/non-compete-contract-explainer/content/vermont.md +193 -0
  245. package/skills/non-compete-contract-explainer/content/virginia.md +213 -0
  246. package/skills/non-compete-contract-explainer/content/washington.md +296 -0
  247. package/skills/non-compete-contract-explainer/content/west-virginia.md +187 -0
  248. package/skills/non-compete-contract-explainer/content/wisconsin.md +293 -0
  249. package/skills/non-compete-contract-explainer/content/wyoming.md +55 -45
  250. package/skills/non-compete-contract-explainer/manifest.json +523 -1
@@ -0,0 +1,586 @@
1
+ 'use strict';
2
+
3
+ var conventions = require('./conventions');
4
+ var dom = require('./dom');
5
+ var errors = require('./errors');
6
+ var entities = require('./entities');
7
+ var sax = require('./sax');
8
+
9
+ var DOMImplementation = dom.DOMImplementation;
10
+
11
+ var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
12
+ var isHTMLMimeType = conventions.isHTMLMimeType;
13
+ var isValidMimeType = conventions.isValidMimeType;
14
+ var MIME_TYPE = conventions.MIME_TYPE;
15
+ var NAMESPACE = conventions.NAMESPACE;
16
+ var ParseError = errors.ParseError;
17
+
18
+ var XMLReader = sax.XMLReader;
19
+
20
+ /**
21
+ * Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
22
+ * including some Unicode "newline" characters:
23
+ *
24
+ * > XML parsed entities are often stored in computer files which,
25
+ * > for editing convenience, are organized into lines.
26
+ * > These lines are typically separated by some combination
27
+ * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
28
+ * >
29
+ * > To simplify the tasks of applications, the XML processor must behave
30
+ * > as if it normalized all line breaks in external parsed entities (including the document entity)
31
+ * > on input, before parsing, by translating the following to a single #xA character:
32
+ * >
33
+ * > 1. the two-character sequence #xD #xA,
34
+ * > 2. the two-character sequence #xD #x85,
35
+ * > 3. the single character #x85,
36
+ * > 4. the single character #x2028,
37
+ * > 5. the single character #x2029,
38
+ * > 6. any #xD character that is not immediately followed by #xA or #x85.
39
+ *
40
+ * @param {string} input
41
+ * @returns {string}
42
+ * @prettierignore
43
+ */
44
+ function normalizeLineEndings(input) {
45
+ return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028\u2029]/g, '\n');
46
+ }
47
+
48
+ /**
49
+ * @typedef Locator
50
+ * @property {number} [columnNumber]
51
+ * @property {number} [lineNumber]
52
+ */
53
+
54
+ /**
55
+ * @typedef DOMParserOptions
56
+ * @property {typeof assign} [assign]
57
+ * The method to use instead of `conventions.assign`, which is used to copy values from
58
+ * `options` before they are used for parsing.
59
+ * @property {typeof DOMHandler} [domHandler]
60
+ * For internal testing: The class for creating an instance for handling events from the SAX
61
+ * parser.
62
+ * *****Warning: By configuring a faulty implementation, the specified behavior can completely
63
+ * be broken.*****.
64
+ * @property {Function} [errorHandler]
65
+ * DEPRECATED! use `onError` instead.
66
+ * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}
67
+ * [onError]
68
+ * A function invoked for every error that occurs during parsing.
69
+ *
70
+ * If it is not provided, all errors are reported to `console.error`
71
+ * and only `fatalError`s are thrown as a `ParseError`,
72
+ * which prevents any further processing.
73
+ * If the provided method throws, a `ParserError` is thrown,
74
+ * which prevents any further processing.
75
+ *
76
+ * Be aware that many `warning`s are considered an error that prevents further processing in
77
+ * most implementations.
78
+ * @property {boolean} [locator=true]
79
+ * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`
80
+ * attribute describing their location in the XML string.
81
+ * Default is true.
82
+ * @property {(string) => string} [normalizeLineEndings]
83
+ * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
84
+ * which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
85
+ * including some Unicode "newline" characters.
86
+ * @property {Object} [xmlns]
87
+ * The XML namespaces that should be assumed when parsing.
88
+ * The default namespace can be provided by the key that is the empty string.
89
+ * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
90
+ * the default namespace that will be used,
91
+ * will be overridden according to the specification.
92
+ * @see {@link normalizeLineEndings}
93
+ */
94
+
95
+ /**
96
+ * The DOMParser interface provides the ability to parse XML or HTML source code from a string
97
+ * into a DOM `Document`.
98
+ *
99
+ * ***xmldom is different from the spec in that it allows an `options` parameter,
100
+ * to control the behavior***.
101
+ *
102
+ * @class
103
+ * @param {DOMParserOptions} [options]
104
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
105
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
106
+ */
107
+ function DOMParser(options) {
108
+ options = options || {};
109
+ if (options.locator === undefined) {
110
+ options.locator = true;
111
+ }
112
+
113
+ /**
114
+ * The method to use instead of `conventions.assign`, which is used to copy values from
115
+ * `options`
116
+ * before they are used for parsing.
117
+ *
118
+ * @type {conventions.assign}
119
+ * @private
120
+ * @see {@link conventions.assign}
121
+ * @readonly
122
+ */
123
+ this.assign = options.assign || conventions.assign;
124
+
125
+ /**
126
+ * For internal testing: The class for creating an instance for handling events from the SAX
127
+ * parser.
128
+ * *****Warning: By configuring a faulty implementation, the specified behavior can completely
129
+ * be broken*****.
130
+ *
131
+ * @type {typeof DOMHandler}
132
+ * @private
133
+ * @readonly
134
+ */
135
+ this.domHandler = options.domHandler || DOMHandler;
136
+
137
+ /**
138
+ * A function that is invoked for every error that occurs during parsing.
139
+ *
140
+ * If it is not provided, all errors are reported to `console.error`
141
+ * and only `fatalError`s are thrown as a `ParseError`,
142
+ * which prevents any further processing.
143
+ * If the provided method throws, a `ParserError` is thrown,
144
+ * which prevents any further processing.
145
+ *
146
+ * Be aware that many `warning`s are considered an error that prevents further processing in
147
+ * most implementations.
148
+ *
149
+ * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}
150
+ * @see {@link onErrorStopParsing}
151
+ * @see {@link onWarningStopParsing}
152
+ */
153
+ this.onError = options.onError || options.errorHandler;
154
+ if (options.errorHandler && typeof options.errorHandler !== 'function') {
155
+ throw new TypeError('errorHandler object is no longer supported, switch to onError!');
156
+ } else if (options.errorHandler) {
157
+ options.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);
158
+ }
159
+
160
+ /**
161
+ * used to replace line endings before parsing, defaults to `normalizeLineEndings`
162
+ *
163
+ * @type {(string) => string}
164
+ * @readonly
165
+ */
166
+ this.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;
167
+
168
+ /**
169
+ * Configures if the nodes created during parsing will have a `lineNumber` and a
170
+ * `columnNumber`
171
+ * attribute describing their location in the XML string.
172
+ * Default is true.
173
+ *
174
+ * @type {boolean}
175
+ * @readonly
176
+ */
177
+ this.locator = !!options.locator;
178
+
179
+ /**
180
+ * The default namespace can be provided by the key that is the empty string.
181
+ * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
182
+ * the default namespace that will be used,
183
+ * will be overridden according to the specification.
184
+ *
185
+ * @type {Readonly<Object>}
186
+ * @readonly
187
+ */
188
+ this.xmlns = this.assign(Object.create(null), options.xmlns);
189
+ }
190
+
191
+ /**
192
+ * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`
193
+ * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,
194
+ * otherwise an XML `Document` is created.
195
+ *
196
+ * __It behaves different from the description in the living standard__:
197
+ * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
198
+ * - Any unexpected input is reported to `onError` with either a `warning`,
199
+ * `error` or `fatalError` level.
200
+ * - Any `fatalError` throws a `ParseError` which prevents further processing.
201
+ * - Any error thrown by `onError` is converted to a `ParseError` which prevents further
202
+ * processing - If no `Document` was created during parsing it is reported as a `fatalError`.
203
+ * *****Warning: By configuring a faulty DOMHandler implementation,
204
+ * the specified behavior can completely be broken*****.
205
+ *
206
+ * @param {string} source
207
+ * The XML mime type only allows string input!
208
+ * @param {string} [mimeType='application/xml']
209
+ * the mimeType or contentType of the document to be created determines the `type` of document
210
+ * created (XML or HTML)
211
+ * @returns {Document}
212
+ * The `Document` node.
213
+ * @throws {ParseError}
214
+ * for any `fatalError` or anything that is thrown by `onError`
215
+ * @throws {TypeError}
216
+ * for any invalid `mimeType`
217
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
218
+ * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
219
+ */
220
+ DOMParser.prototype.parseFromString = function (source, mimeType) {
221
+ if (!isValidMimeType(mimeType)) {
222
+ throw new TypeError('DOMParser.parseFromString: the provided mimeType "' + mimeType + '" is not valid.');
223
+ }
224
+ var defaultNSMap = this.assign(Object.create(null), this.xmlns);
225
+ var entityMap = entities.XML_ENTITIES;
226
+ var defaultNamespace = defaultNSMap[''] || null;
227
+ if (hasDefaultHTMLNamespace(mimeType)) {
228
+ entityMap = entities.HTML_ENTITIES;
229
+ defaultNamespace = NAMESPACE.HTML;
230
+ } else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {
231
+ defaultNamespace = NAMESPACE.SVG;
232
+ }
233
+ defaultNSMap[''] = defaultNamespace;
234
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
235
+
236
+ var domBuilder = new this.domHandler({
237
+ mimeType: mimeType,
238
+ defaultNamespace: defaultNamespace,
239
+ onError: this.onError,
240
+ });
241
+ var locator = this.locator ? {} : undefined;
242
+ if (this.locator) {
243
+ domBuilder.setDocumentLocator(locator);
244
+ }
245
+
246
+ var sax = new XMLReader();
247
+ sax.errorHandler = domBuilder;
248
+ sax.domBuilder = domBuilder;
249
+ var isXml = !conventions.isHTMLMimeType(mimeType);
250
+ if (isXml && typeof source !== 'string') {
251
+ sax.errorHandler.fatalError('source is not a string');
252
+ }
253
+ sax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);
254
+ if (!domBuilder.doc.documentElement) {
255
+ sax.errorHandler.fatalError('missing root element');
256
+ }
257
+ return domBuilder.doc;
258
+ };
259
+
260
+ /**
261
+ * @typedef DOMHandlerOptions
262
+ * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]
263
+ * @property {string | null} [defaultNamespace=null]
264
+ */
265
+ /**
266
+ * The class that is used to handle events from the SAX parser to create the related DOM
267
+ * elements.
268
+ *
269
+ * Some methods are only implemented as an empty function,
270
+ * since they are (at least currently) not relevant for xmldom.
271
+ *
272
+ * @class
273
+ * @param {DOMHandlerOptions} [options]
274
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html
275
+ */
276
+ function DOMHandler(options) {
277
+ var opt = options || {};
278
+ /**
279
+ * The mime type is used to determine if the DOM handler will create an XML or HTML document.
280
+ * Only if it is set to `text/html` it will create an HTML document.
281
+ * It defaults to MIME_TYPE.XML_APPLICATION.
282
+ *
283
+ * @type {string}
284
+ * @see {@link MIME_TYPE}
285
+ * @readonly
286
+ */
287
+ this.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;
288
+
289
+ /**
290
+ * The namespace to use to create an XML document.
291
+ * For the following reasons this is required:
292
+ * - The SAX API for `startDocument` doesn't offer any way to pass a namespace,
293
+ * since at that point there is no way for the parser to know what the default namespace from
294
+ * the document will be.
295
+ * - When creating using `DOMImplementation.createDocument` it is required to pass a
296
+ * namespace,
297
+ * to determine the correct `Document.contentType`, which should match `this.mimeType`.
298
+ * - When parsing an XML document with the `application/xhtml+xml` mimeType,
299
+ * the HTML namespace needs to be the default namespace.
300
+ *
301
+ * @type {string | null}
302
+ * @private
303
+ * @readonly
304
+ */
305
+ this.defaultNamespace = opt.defaultNamespace || null;
306
+
307
+ /**
308
+ * @type {boolean}
309
+ * @private
310
+ */
311
+ this.cdata = false;
312
+
313
+ /**
314
+ * The last `Element` that was created by `startElement`.
315
+ * `endElement` sets it to the `currentElement.parentNode`.
316
+ *
317
+ * Note: The sax parser currently sets it to white space text nodes between tags.
318
+ *
319
+ * @type {Element | Node | undefined}
320
+ * @private
321
+ */
322
+ this.currentElement = undefined;
323
+
324
+ /**
325
+ * The Document that is created as part of `startDocument`,
326
+ * and returned by `DOMParser.parseFromString`.
327
+ *
328
+ * @type {Document | undefined}
329
+ * @readonly
330
+ */
331
+ this.doc = undefined;
332
+
333
+ /**
334
+ * The locator is stored as part of setDocumentLocator.
335
+ * It is controlled and mutated by the SAX parser to store the current parsing position.
336
+ * It is used by DOMHandler to set `columnNumber` and `lineNumber`
337
+ * on the DOM nodes.
338
+ *
339
+ * @type {Readonly<Locator> | undefined}
340
+ * @private
341
+ * @readonly (the
342
+ * sax parser currently sometimes set's it)
343
+ */
344
+ this.locator = undefined;
345
+ /**
346
+ * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}
347
+ * @readonly
348
+ */
349
+ this.onError = opt.onError;
350
+ }
351
+
352
+ function position(locator, node) {
353
+ node.lineNumber = locator.lineNumber;
354
+ node.columnNumber = locator.columnNumber;
355
+ }
356
+
357
+ DOMHandler.prototype = {
358
+ /**
359
+ * Either creates an XML or an HTML document and stores it under `this.doc`.
360
+ * If it is an XML document, `this.defaultNamespace` is used to create it,
361
+ * and it will not contain any `childNodes`.
362
+ * If it is an HTML document, it will be created without any `childNodes`.
363
+ *
364
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
365
+ */
366
+ startDocument: function () {
367
+ var impl = new DOMImplementation();
368
+ this.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');
369
+ },
370
+ startElement: function (namespaceURI, localName, qName, attrs) {
371
+ var doc = this.doc;
372
+ var el = doc.createElementNS(namespaceURI, qName || localName);
373
+ var len = attrs.length;
374
+ appendElement(this, el);
375
+ this.currentElement = el;
376
+
377
+ this.locator && position(this.locator, el);
378
+ for (var i = 0; i < len; i++) {
379
+ var namespaceURI = attrs.getURI(i);
380
+ var value = attrs.getValue(i);
381
+ var qName = attrs.getQName(i);
382
+ var attr = doc.createAttributeNS(namespaceURI, qName);
383
+ this.locator && position(attrs.getLocator(i), attr);
384
+ attr.value = attr.nodeValue = value;
385
+ el.setAttributeNode(attr);
386
+ }
387
+ },
388
+ endElement: function (namespaceURI, localName, qName) {
389
+ this.currentElement = this.currentElement.parentNode;
390
+ },
391
+ startPrefixMapping: function (prefix, uri) {},
392
+ endPrefixMapping: function (prefix) {},
393
+ processingInstruction: function (target, data) {
394
+ var ins = this.doc.createProcessingInstruction(target, data);
395
+ this.locator && position(this.locator, ins);
396
+ appendElement(this, ins);
397
+ },
398
+ ignorableWhitespace: function (ch, start, length) {},
399
+ characters: function (chars, start, length) {
400
+ chars = _toString.apply(this, arguments);
401
+ //console.log(chars)
402
+ if (chars) {
403
+ if (this.cdata) {
404
+ var charNode = this.doc.createCDATASection(chars);
405
+ } else {
406
+ var charNode = this.doc.createTextNode(chars);
407
+ }
408
+ if (this.currentElement) {
409
+ this.currentElement.appendChild(charNode);
410
+ } else if (/^\s*$/.test(chars)) {
411
+ this.doc.appendChild(charNode);
412
+ //process xml
413
+ }
414
+ this.locator && position(this.locator, charNode);
415
+ }
416
+ },
417
+ skippedEntity: function (name) {},
418
+ endDocument: function () {
419
+ this.doc.normalize();
420
+ },
421
+ /**
422
+ * Stores the locator to be able to set the `columnNumber` and `lineNumber`
423
+ * on the created DOM nodes.
424
+ *
425
+ * @param {Locator} locator
426
+ */
427
+ setDocumentLocator: function (locator) {
428
+ if (locator) {
429
+ locator.lineNumber = 0;
430
+ }
431
+ this.locator = locator;
432
+ },
433
+ //LexicalHandler
434
+ comment: function (chars, start, length) {
435
+ chars = _toString.apply(this, arguments);
436
+ var comm = this.doc.createComment(chars);
437
+ this.locator && position(this.locator, comm);
438
+ appendElement(this, comm);
439
+ },
440
+
441
+ startCDATA: function () {
442
+ //used in characters() methods
443
+ this.cdata = true;
444
+ },
445
+ endCDATA: function () {
446
+ this.cdata = false;
447
+ },
448
+
449
+ startDTD: function (name, publicId, systemId, internalSubset) {
450
+ var impl = this.doc.implementation;
451
+ if (impl && impl.createDocumentType) {
452
+ var dt = impl.createDocumentType(name, publicId, systemId, internalSubset);
453
+ this.locator && position(this.locator, dt);
454
+ appendElement(this, dt);
455
+ this.doc.doctype = dt;
456
+ }
457
+ },
458
+ reportError: function (level, message) {
459
+ if (typeof this.onError === 'function') {
460
+ try {
461
+ this.onError(level, message, this);
462
+ } catch (e) {
463
+ throw new ParseError('Reporting ' + level + ' "' + message + '" caused ' + e, this.locator);
464
+ }
465
+ } else {
466
+ console.error('[xmldom ' + level + ']\t' + message, _locator(this.locator));
467
+ }
468
+ },
469
+ /**
470
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
471
+ */
472
+ warning: function (message) {
473
+ this.reportError('warning', message);
474
+ },
475
+ error: function (message) {
476
+ this.reportError('error', message);
477
+ },
478
+ /**
479
+ * This function reports a fatal error and throws a ParseError.
480
+ *
481
+ * @param {string} message
482
+ * - The message to be used for reporting and throwing the error.
483
+ * @returns {never}
484
+ * This function always throws an error and never returns a value.
485
+ * @throws {ParseError}
486
+ * Always throws a ParseError with the provided message.
487
+ */
488
+ fatalError: function (message) {
489
+ this.reportError('fatalError', message);
490
+ throw new ParseError(message, this.locator);
491
+ },
492
+ };
493
+
494
+ function _locator(l) {
495
+ if (l) {
496
+ return '\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';
497
+ }
498
+ }
499
+
500
+ function _toString(chars, start, length) {
501
+ if (typeof chars == 'string') {
502
+ return chars.substr(start, length);
503
+ } else {
504
+ //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
505
+ if (chars.length >= start + length || start) {
506
+ return new java.lang.String(chars, start, length) + '';
507
+ }
508
+ return chars;
509
+ }
510
+ }
511
+
512
+ /*
513
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
514
+ * used method of org.xml.sax.ext.LexicalHandler:
515
+ * #comment(chars, start, length)
516
+ * #startCDATA()
517
+ * #endCDATA()
518
+ * #startDTD(name, publicId, systemId)
519
+ *
520
+ *
521
+ * IGNORED method of org.xml.sax.ext.LexicalHandler:
522
+ * #endDTD()
523
+ * #startEntity(name)
524
+ * #endEntity(name)
525
+ *
526
+ *
527
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
528
+ * IGNORED method of org.xml.sax.ext.DeclHandler
529
+ * #attributeDecl(eName, aName, type, mode, value)
530
+ * #elementDecl(name, model)
531
+ * #externalEntityDecl(name, publicId, systemId)
532
+ * #internalEntityDecl(name, value)
533
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
534
+ * IGNORED method of org.xml.sax.EntityResolver2
535
+ * #resolveEntity(String name,String publicId,String baseURI,String systemId)
536
+ * #resolveEntity(publicId, systemId)
537
+ * #getExternalSubset(name, baseURI)
538
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
539
+ * IGNORED method of org.xml.sax.DTDHandler
540
+ * #notationDecl(name, publicId, systemId) {};
541
+ * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
542
+ */
543
+ 'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(
544
+ /\w+/g,
545
+ function (key) {
546
+ DOMHandler.prototype[key] = function () {
547
+ return null;
548
+ };
549
+ }
550
+ );
551
+
552
+ /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
553
+ function appendElement(handler, node) {
554
+ if (!handler.currentElement) {
555
+ handler.doc.appendChild(node);
556
+ } else {
557
+ handler.currentElement.appendChild(node);
558
+ }
559
+ }
560
+
561
+ /**
562
+ * A method that prevents any further parsing when an `error`
563
+ * with level `error` is reported during parsing.
564
+ *
565
+ * @see {@link DOMParserOptions.onError}
566
+ * @see {@link onWarningStopParsing}
567
+ */
568
+ function onErrorStopParsing(level) {
569
+ if (level === 'error') throw 'onErrorStopParsing';
570
+ }
571
+
572
+ /**
573
+ * A method that prevents any further parsing when any `error` is reported during parsing.
574
+ *
575
+ * @see {@link DOMParserOptions.onError}
576
+ * @see {@link onErrorStopParsing}
577
+ */
578
+ function onWarningStopParsing() {
579
+ throw 'onWarningStopParsing';
580
+ }
581
+
582
+ exports.__DOMHandler = DOMHandler;
583
+ exports.DOMParser = DOMParser;
584
+ exports.normalizeLineEndings = normalizeLineEndings;
585
+ exports.onErrorStopParsing = onErrorStopParsing;
586
+ exports.onWarningStopParsing = onWarningStopParsing;