bailinghub 0.9.3 → 0.10.0

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 (1264) hide show
  1. package/.dockerignore +1 -0
  2. package/.gitignore +1 -0
  3. package/.npmignore +1 -0
  4. package/Dockerfile +1 -0
  5. package/README.en.md +6 -6
  6. package/README.md +6 -6
  7. package/SECURITY.md +3 -3
  8. package/THIRD_PARTY_NOTICES.md +8 -8
  9. package/docker-compose.images.yml +2 -2
  10. package/docs/AGENT_CLIENT_QUICKSTART.en.md +1 -3
  11. package/docs/AGENT_CLIENT_QUICKSTART.md +1 -1
  12. package/docs/AGENT_CLIENT_RUNTIME_API.en.md +87 -2
  13. package/docs/AGENT_CLIENT_RUNTIME_API.md +36 -2
  14. package/docs/AGENT_KNOWLEDGE_API.en.md +77 -0
  15. package/docs/AGENT_KNOWLEDGE_API.md +86 -0
  16. package/docs/AGENT_TASK_CONTROL.md +4 -4
  17. package/docs/AGENT_TASK_CONTROL_FOUNDATION.md +1 -1
  18. package/docs/ARCHITECTURE.md +4 -0
  19. package/docs/CHANGELOG.en.md +24 -1
  20. package/docs/CHANGELOG.md +24 -1
  21. package/docs/COMPATIBILITY.en.md +27 -1
  22. package/docs/CONTRACT.en.md +1 -1
  23. package/docs/CONTRACT.md +1 -1
  24. package/docs/DOCX_DEPENDENCY.en.md +26 -0
  25. package/docs/DOCX_DEPENDENCY.md +26 -0
  26. package/docs/IMPLEMENTATION_STATUS.en.md +23 -15
  27. package/docs/IMPLEMENTATION_STATUS.md +23 -15
  28. package/docs/INDEPENDENT_VALIDATION.en.md +6 -4
  29. package/docs/INDEPENDENT_VALIDATION.md +6 -4
  30. package/docs/INTEGRATION_WALKTHROUGH.md +65 -0
  31. package/docs/MODEL_BILLING.en.md +2 -0
  32. package/docs/MODEL_BILLING.md +6 -2
  33. package/docs/MODEL_CONTINUATION.en.md +54 -0
  34. package/docs/MODEL_CONTINUATION.md +54 -0
  35. package/docs/MODEL_OUTPUT_BUDGET.en.md +69 -0
  36. package/docs/MODEL_OUTPUT_BUDGET.md +69 -0
  37. package/docs/NOTIFICATION_DURABILITY.en.md +47 -0
  38. package/docs/NOTIFICATION_DURABILITY.md +47 -0
  39. package/docs/OPERATIONS.en.md +22 -6
  40. package/docs/OPERATIONS.md +22 -6
  41. package/docs/QUICKSTART.md +1 -1
  42. package/docs/README.en.md +9 -0
  43. package/docs/README.md +9 -0
  44. package/docs/RELEASE_NOTES_NEXT.en.md +3 -3
  45. package/docs/RELEASE_NOTES_NEXT.md +3 -3
  46. package/docs/RELEASE_NOTES_v0.10.0.en.md +58 -0
  47. package/docs/RELEASE_NOTES_v0.10.0.md +58 -0
  48. package/docs/RELEASE_NOTES_v0.9.4.en.md +42 -0
  49. package/docs/RELEASE_NOTES_v0.9.4.md +42 -0
  50. package/docs/UPGRADE_PLAN.en.md +118 -0
  51. package/docs/UPGRADE_PLAN.md +124 -0
  52. package/docs/UPGRADE_v0.10.0.en.md +47 -0
  53. package/docs/UPGRADE_v0.10.0.md +47 -0
  54. package/docs/UPGRADE_v0.9.4.en.md +57 -0
  55. package/docs/UPGRADE_v0.9.4.md +57 -0
  56. package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +38 -22
  57. package/node_modules/@xmldom/xmldom/CHANGELOG.md +533 -0
  58. package/node_modules/@xmldom/xmldom/LICENSE +8 -0
  59. package/node_modules/@xmldom/xmldom/SECURITY.md +50 -0
  60. package/node_modules/@xmldom/xmldom/index.d.ts +96 -0
  61. package/node_modules/@xmldom/xmldom/lib/.eslintrc.yml +2 -0
  62. package/node_modules/@xmldom/xmldom/lib/conventions.js +214 -0
  63. package/node_modules/@xmldom/xmldom/lib/dom-parser.js +322 -0
  64. package/node_modules/@xmldom/xmldom/lib/dom.js +2266 -0
  65. package/node_modules/@xmldom/xmldom/lib/entities.js +2166 -0
  66. package/node_modules/@xmldom/xmldom/lib/index.js +4 -0
  67. package/node_modules/@xmldom/xmldom/lib/sax.js +683 -0
  68. package/node_modules/@xmldom/xmldom/package.json +75 -0
  69. package/node_modules/@xmldom/xmldom/readme.md +356 -0
  70. package/node_modules/base64-js/LICENSE +21 -0
  71. package/node_modules/base64-js/README.md +34 -0
  72. package/node_modules/base64-js/base64js.min.js +1 -0
  73. package/node_modules/base64-js/index.d.ts +3 -0
  74. package/node_modules/base64-js/index.js +150 -0
  75. package/node_modules/base64-js/package.json +47 -0
  76. package/node_modules/bluebird/LICENSE +21 -0
  77. package/node_modules/bluebird/README.md +51 -0
  78. package/node_modules/bluebird/changelog.md +1 -0
  79. package/node_modules/bluebird/js/browser/bluebird.core.js +3739 -0
  80. package/node_modules/bluebird/js/browser/bluebird.core.min.js +31 -0
  81. package/node_modules/bluebird/js/browser/bluebird.js +5581 -0
  82. package/node_modules/bluebird/js/browser/bluebird.min.js +31 -0
  83. package/node_modules/bluebird/js/release/any.js +21 -0
  84. package/node_modules/bluebird/js/release/assert.js +55 -0
  85. package/node_modules/bluebird/js/release/async.js +161 -0
  86. package/node_modules/bluebird/js/release/bind.js +67 -0
  87. package/node_modules/bluebird/js/release/bluebird.js +11 -0
  88. package/node_modules/bluebird/js/release/call_get.js +123 -0
  89. package/node_modules/bluebird/js/release/cancel.js +129 -0
  90. package/node_modules/bluebird/js/release/catch_filter.js +42 -0
  91. package/node_modules/bluebird/js/release/context.js +69 -0
  92. package/node_modules/bluebird/js/release/debuggability.js +916 -0
  93. package/node_modules/bluebird/js/release/direct_resolve.js +46 -0
  94. package/node_modules/bluebird/js/release/each.js +30 -0
  95. package/node_modules/bluebird/js/release/errors.js +116 -0
  96. package/node_modules/bluebird/js/release/es5.js +80 -0
  97. package/node_modules/bluebird/js/release/filter.js +12 -0
  98. package/node_modules/bluebird/js/release/finally.js +111 -0
  99. package/node_modules/bluebird/js/release/generators.js +223 -0
  100. package/node_modules/bluebird/js/release/join.js +168 -0
  101. package/node_modules/bluebird/js/release/map.js +168 -0
  102. package/node_modules/bluebird/js/release/method.js +55 -0
  103. package/node_modules/bluebird/js/release/nodeback.js +51 -0
  104. package/node_modules/bluebird/js/release/nodeify.js +58 -0
  105. package/node_modules/bluebird/js/release/promise.js +773 -0
  106. package/node_modules/bluebird/js/release/promise_array.js +184 -0
  107. package/node_modules/bluebird/js/release/promisify.js +314 -0
  108. package/node_modules/bluebird/js/release/props.js +118 -0
  109. package/node_modules/bluebird/js/release/queue.js +73 -0
  110. package/node_modules/bluebird/js/release/race.js +49 -0
  111. package/node_modules/bluebird/js/release/reduce.js +172 -0
  112. package/node_modules/bluebird/js/release/schedule.js +61 -0
  113. package/node_modules/bluebird/js/release/settle.js +43 -0
  114. package/node_modules/bluebird/js/release/some.js +148 -0
  115. package/node_modules/bluebird/js/release/synchronous_inspection.js +103 -0
  116. package/node_modules/bluebird/js/release/thenables.js +86 -0
  117. package/node_modules/bluebird/js/release/timers.js +93 -0
  118. package/node_modules/bluebird/js/release/using.js +226 -0
  119. package/node_modules/bluebird/js/release/util.js +379 -0
  120. package/node_modules/bluebird/package.json +76 -0
  121. package/node_modules/core-util-is/LICENSE +19 -0
  122. package/node_modules/core-util-is/README.md +3 -0
  123. package/node_modules/core-util-is/lib/util.js +107 -0
  124. package/node_modules/core-util-is/package.json +38 -0
  125. package/node_modules/dingbat-to-unicode/README.md +79 -0
  126. package/node_modules/dingbat-to-unicode/dist/dingbats.d.ts +8 -0
  127. package/node_modules/dingbat-to-unicode/dist/dingbats.js +1066 -0
  128. package/node_modules/dingbat-to-unicode/dist/index.d.ts +7 -0
  129. package/node_modules/dingbat-to-unicode/dist/index.js +44 -0
  130. package/node_modules/dingbat-to-unicode/package.json +39 -0
  131. package/node_modules/duck/LICENSE +22 -0
  132. package/node_modules/duck/README.md +184 -0
  133. package/node_modules/duck/index.js +267 -0
  134. package/node_modules/duck/makefile +4 -0
  135. package/node_modules/duck/package.json +23 -0
  136. package/node_modules/duck/test/duck.test.js +160 -0
  137. package/node_modules/immediate/LICENSE.txt +20 -0
  138. package/node_modules/immediate/README.md +93 -0
  139. package/node_modules/immediate/dist/immediate.js +75 -0
  140. package/node_modules/immediate/dist/immediate.min.js +1 -0
  141. package/node_modules/immediate/lib/browser.js +69 -0
  142. package/node_modules/immediate/lib/index.js +73 -0
  143. package/node_modules/immediate/package.json +42 -0
  144. package/node_modules/inherits/LICENSE +16 -0
  145. package/node_modules/inherits/README.md +42 -0
  146. package/node_modules/inherits/inherits.js +9 -0
  147. package/node_modules/inherits/inherits_browser.js +27 -0
  148. package/node_modules/inherits/package.json +29 -0
  149. package/node_modules/isarray/.npmignore +1 -0
  150. package/node_modules/isarray/.travis.yml +4 -0
  151. package/node_modules/isarray/Makefile +6 -0
  152. package/node_modules/isarray/README.md +60 -0
  153. package/node_modules/isarray/component.json +19 -0
  154. package/node_modules/isarray/index.js +5 -0
  155. package/node_modules/isarray/package.json +45 -0
  156. package/node_modules/isarray/test.js +20 -0
  157. package/node_modules/jszip/.codeclimate.yml +16 -0
  158. package/node_modules/jszip/.editorconfig +8 -0
  159. package/node_modules/jszip/.eslintrc.js +43 -0
  160. package/node_modules/jszip/.github/workflows/pr.yaml +58 -0
  161. package/node_modules/jszip/.jekyll-metadata +0 -0
  162. package/node_modules/jszip/.travis.yml +17 -0
  163. package/node_modules/jszip/CHANGES.md +204 -0
  164. package/node_modules/jszip/LICENSE.markdown +651 -0
  165. package/node_modules/jszip/README.markdown +33 -0
  166. package/node_modules/jszip/deps.js +37 -0
  167. package/node_modules/jszip/dist/jszip.js +11577 -0
  168. package/node_modules/jszip/dist/jszip.min.js +13 -0
  169. package/node_modules/jszip/graph.svg +601 -0
  170. package/node_modules/jszip/index.d.ts +330 -0
  171. package/node_modules/jszip/lib/base64.js +106 -0
  172. package/node_modules/jszip/lib/compressedObject.js +74 -0
  173. package/node_modules/jszip/lib/compressions.js +14 -0
  174. package/node_modules/jszip/lib/crc32.js +77 -0
  175. package/node_modules/jszip/lib/defaults.js +11 -0
  176. package/node_modules/jszip/lib/external.js +18 -0
  177. package/node_modules/jszip/lib/flate.js +85 -0
  178. package/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
  179. package/node_modules/jszip/lib/generate/index.js +57 -0
  180. package/node_modules/jszip/lib/index.js +55 -0
  181. package/node_modules/jszip/lib/license_header.js +11 -0
  182. package/node_modules/jszip/lib/load.js +88 -0
  183. package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
  184. package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
  185. package/node_modules/jszip/lib/nodejsUtils.js +57 -0
  186. package/node_modules/jszip/lib/object.js +384 -0
  187. package/node_modules/jszip/lib/readable-stream-browser.js +10 -0
  188. package/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
  189. package/node_modules/jszip/lib/reader/DataReader.js +116 -0
  190. package/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
  191. package/node_modules/jszip/lib/reader/StringReader.js +38 -0
  192. package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
  193. package/node_modules/jszip/lib/reader/readerFor.js +28 -0
  194. package/node_modules/jszip/lib/signature.js +7 -0
  195. package/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
  196. package/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
  197. package/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
  198. package/node_modules/jszip/lib/stream/DataWorker.js +116 -0
  199. package/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
  200. package/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
  201. package/node_modules/jszip/lib/support.js +38 -0
  202. package/node_modules/jszip/lib/utf8.js +275 -0
  203. package/node_modules/jszip/lib/utils.js +501 -0
  204. package/node_modules/jszip/lib/zipEntries.js +261 -0
  205. package/node_modules/jszip/lib/zipEntry.js +293 -0
  206. package/node_modules/jszip/lib/zipObject.js +133 -0
  207. package/node_modules/jszip/package.json +67 -0
  208. package/node_modules/jszip/sponsors.md +21 -0
  209. package/node_modules/jszip/tsconfig.json +101 -0
  210. package/node_modules/jszip/vendor/FileSaver.js +247 -0
  211. package/node_modules/lie/README.md +62 -0
  212. package/node_modules/lie/dist/lie.js +350 -0
  213. package/node_modules/lie/dist/lie.min.js +1 -0
  214. package/node_modules/lie/dist/lie.polyfill.js +358 -0
  215. package/node_modules/lie/dist/lie.polyfill.min.js +1 -0
  216. package/node_modules/lie/lib/browser.js +273 -0
  217. package/node_modules/lie/lib/index.js +298 -0
  218. package/node_modules/lie/license.md +7 -0
  219. package/node_modules/lie/lie.d.ts +244 -0
  220. package/node_modules/lie/package.json +69 -0
  221. package/node_modules/lie/polyfill.js +4 -0
  222. package/node_modules/lop/LICENSE +22 -0
  223. package/node_modules/lop/README.md +248 -0
  224. package/node_modules/lop/index.js +18 -0
  225. package/node_modules/lop/lib/StringSource.js +53 -0
  226. package/node_modules/lop/lib/Token.js +7 -0
  227. package/node_modules/lop/lib/TokenIterator.js +28 -0
  228. package/node_modules/lop/lib/bottom-up.js +128 -0
  229. package/node_modules/lop/lib/errors.js +22 -0
  230. package/node_modules/lop/lib/lazy-iterators.js +81 -0
  231. package/node_modules/lop/lib/parser.js +11 -0
  232. package/node_modules/lop/lib/parsing-results.js +103 -0
  233. package/node_modules/lop/lib/regex-tokeniser.js +70 -0
  234. package/node_modules/lop/lib/rules.js +313 -0
  235. package/node_modules/lop/lib/testing.js +69 -0
  236. package/node_modules/lop/makefile +4 -0
  237. package/node_modules/lop/package.json +24 -0
  238. package/node_modules/lop/test/StringSource.test.js +21 -0
  239. package/node_modules/lop/test/TokenIterator.test.js +17 -0
  240. package/node_modules/lop/test/Tokeniser.js +50 -0
  241. package/node_modules/lop/test/Tokeniser.test.js +38 -0
  242. package/node_modules/lop/test/bottom-up.test.js +187 -0
  243. package/node_modules/lop/test/errors.test.js +36 -0
  244. package/node_modules/lop/test/lazy-iterators.test.js +53 -0
  245. package/node_modules/lop/test/lop.test.js +27 -0
  246. package/node_modules/lop/test/regex-tokeniser.test.js +114 -0
  247. package/node_modules/lop/test/results.test.js +8 -0
  248. package/node_modules/lop/test/rules.test.js +617 -0
  249. package/node_modules/mammoth/LICENSE +22 -0
  250. package/node_modules/mammoth/SOURCE.json +57 -0
  251. package/node_modules/mammoth/browser/docx/files.js +14 -0
  252. package/node_modules/mammoth/browser/unzip.js +12 -0
  253. package/node_modules/mammoth/lib/document-to-html.js +469 -0
  254. package/node_modules/mammoth/lib/documents.js +254 -0
  255. package/node_modules/mammoth/lib/docx/body-reader.js +798 -0
  256. package/node_modules/mammoth/lib/docx/comments-reader.js +31 -0
  257. package/node_modules/mammoth/lib/docx/content-types-reader.js +58 -0
  258. package/node_modules/mammoth/lib/docx/document-xml-reader.js +30 -0
  259. package/node_modules/mammoth/lib/docx/docx-reader.js +226 -0
  260. package/node_modules/mammoth/lib/docx/files.js +80 -0
  261. package/node_modules/mammoth/lib/docx/notes-reader.js +28 -0
  262. package/node_modules/mammoth/lib/docx/numbering-xml.js +111 -0
  263. package/node_modules/mammoth/lib/docx/office-xml-reader.js +73 -0
  264. package/node_modules/mammoth/lib/docx/relationships-reader.js +43 -0
  265. package/node_modules/mammoth/lib/docx/style-map.js +75 -0
  266. package/node_modules/mammoth/lib/docx/styles-reader.js +90 -0
  267. package/node_modules/mammoth/lib/docx/uris.js +21 -0
  268. package/node_modules/mammoth/lib/html/ast.js +51 -0
  269. package/node_modules/mammoth/lib/html/index.js +41 -0
  270. package/node_modules/mammoth/lib/html/simplify.js +88 -0
  271. package/node_modules/mammoth/lib/images.js +31 -0
  272. package/node_modules/mammoth/lib/index.d.ts +86 -0
  273. package/node_modules/mammoth/lib/index.js +111 -0
  274. package/node_modules/mammoth/lib/options-reader.js +107 -0
  275. package/node_modules/mammoth/lib/promises.js +42 -0
  276. package/node_modules/mammoth/lib/raw-text.js +14 -0
  277. package/node_modules/mammoth/lib/results.js +72 -0
  278. package/node_modules/mammoth/lib/style-reader.js +365 -0
  279. package/node_modules/mammoth/lib/styles/document-matchers.js +100 -0
  280. package/node_modules/mammoth/lib/styles/html-paths.js +75 -0
  281. package/node_modules/mammoth/lib/styles/parser/tokeniser.js +30 -0
  282. package/node_modules/mammoth/lib/transforms.js +62 -0
  283. package/node_modules/mammoth/lib/underline.js +11 -0
  284. package/node_modules/mammoth/lib/unzip.js +20 -0
  285. package/node_modules/mammoth/lib/writers/html-writer.js +159 -0
  286. package/node_modules/mammoth/lib/writers/index.js +14 -0
  287. package/node_modules/mammoth/lib/writers/markdown-writer.js +163 -0
  288. package/node_modules/mammoth/lib/xml/index.js +8 -0
  289. package/node_modules/mammoth/lib/xml/nodes.js +70 -0
  290. package/node_modules/mammoth/lib/xml/reader.js +69 -0
  291. package/node_modules/mammoth/lib/xml/writer.js +61 -0
  292. package/node_modules/mammoth/lib/xml/xmldom.js +23 -0
  293. package/node_modules/mammoth/lib/zipfile.js +72 -0
  294. package/node_modules/mammoth/package.json +39 -0
  295. package/node_modules/mammoth/upstream-package.json +64 -0
  296. package/node_modules/option/.npmignore +1 -0
  297. package/node_modules/option/LICENSE +22 -0
  298. package/node_modules/option/README.md +101 -0
  299. package/node_modules/option/index.js +88 -0
  300. package/node_modules/option/package.json +23 -0
  301. package/node_modules/option/test/options.test.js +174 -0
  302. package/node_modules/pako/CHANGELOG.md +164 -0
  303. package/node_modules/pako/LICENSE +21 -0
  304. package/node_modules/pako/README.md +191 -0
  305. package/node_modules/pako/dist/pako.js +6818 -0
  306. package/node_modules/pako/dist/pako.min.js +1 -0
  307. package/node_modules/pako/dist/pako_deflate.js +3997 -0
  308. package/node_modules/pako/dist/pako_deflate.min.js +1 -0
  309. package/node_modules/pako/dist/pako_inflate.js +3300 -0
  310. package/node_modules/pako/dist/pako_inflate.min.js +1 -0
  311. package/node_modules/pako/index.js +14 -0
  312. package/node_modules/pako/lib/deflate.js +400 -0
  313. package/node_modules/pako/lib/inflate.js +423 -0
  314. package/node_modules/pako/lib/utils/common.js +105 -0
  315. package/node_modules/pako/lib/utils/strings.js +187 -0
  316. package/node_modules/pako/lib/zlib/README +59 -0
  317. package/node_modules/pako/lib/zlib/adler32.js +51 -0
  318. package/node_modules/pako/lib/zlib/constants.js +68 -0
  319. package/node_modules/pako/lib/zlib/crc32.js +59 -0
  320. package/node_modules/pako/lib/zlib/deflate.js +1874 -0
  321. package/node_modules/pako/lib/zlib/gzheader.js +58 -0
  322. package/node_modules/pako/lib/zlib/inffast.js +345 -0
  323. package/node_modules/pako/lib/zlib/inflate.js +1556 -0
  324. package/node_modules/pako/lib/zlib/inftrees.js +343 -0
  325. package/node_modules/pako/lib/zlib/messages.js +32 -0
  326. package/node_modules/pako/lib/zlib/trees.js +1222 -0
  327. package/node_modules/pako/lib/zlib/zstream.js +47 -0
  328. package/node_modules/pako/package.json +44 -0
  329. package/node_modules/path-is-absolute/index.js +20 -0
  330. package/node_modules/path-is-absolute/license +21 -0
  331. package/node_modules/path-is-absolute/package.json +43 -0
  332. package/node_modules/path-is-absolute/readme.md +59 -0
  333. package/node_modules/process-nextick-args/index.js +45 -0
  334. package/node_modules/process-nextick-args/license.md +19 -0
  335. package/node_modules/process-nextick-args/package.json +25 -0
  336. package/node_modules/process-nextick-args/readme.md +18 -0
  337. package/node_modules/readable-stream/.travis.yml +34 -0
  338. package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  339. package/node_modules/readable-stream/GOVERNANCE.md +136 -0
  340. package/node_modules/readable-stream/LICENSE +47 -0
  341. package/node_modules/readable-stream/README.md +58 -0
  342. package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
  343. package/node_modules/readable-stream/duplex-browser.js +1 -0
  344. package/node_modules/readable-stream/duplex.js +1 -0
  345. package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
  346. package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
  347. package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
  348. package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
  349. package/node_modules/readable-stream/lib/_stream_writable.js +685 -0
  350. package/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
  351. package/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
  352. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  353. package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  354. package/node_modules/readable-stream/package.json +52 -0
  355. package/node_modules/readable-stream/passthrough.js +1 -0
  356. package/node_modules/readable-stream/readable-browser.js +7 -0
  357. package/node_modules/readable-stream/readable.js +19 -0
  358. package/node_modules/readable-stream/transform.js +1 -0
  359. package/node_modules/readable-stream/writable-browser.js +1 -0
  360. package/node_modules/readable-stream/writable.js +8 -0
  361. package/node_modules/safe-buffer/LICENSE +21 -0
  362. package/node_modules/safe-buffer/README.md +584 -0
  363. package/node_modules/safe-buffer/index.d.ts +187 -0
  364. package/node_modules/safe-buffer/index.js +62 -0
  365. package/node_modules/safe-buffer/package.json +37 -0
  366. package/node_modules/setimmediate/LICENSE.txt +20 -0
  367. package/node_modules/setimmediate/package.json +30 -0
  368. package/node_modules/setimmediate/setImmediate.js +186 -0
  369. package/node_modules/string_decoder/.travis.yml +50 -0
  370. package/node_modules/string_decoder/LICENSE +48 -0
  371. package/node_modules/string_decoder/README.md +47 -0
  372. package/node_modules/string_decoder/lib/string_decoder.js +296 -0
  373. package/node_modules/string_decoder/package.json +31 -0
  374. package/node_modules/underscore/LICENSE +22 -0
  375. package/node_modules/underscore/README.md +34 -0
  376. package/node_modules/underscore/amd/_baseCreate.js +21 -0
  377. package/node_modules/underscore/amd/_baseIteratee.js +15 -0
  378. package/node_modules/underscore/amd/_cb.js +12 -0
  379. package/node_modules/underscore/amd/_chainResult.js +10 -0
  380. package/node_modules/underscore/amd/_collectNonEnumProps.js +42 -0
  381. package/node_modules/underscore/amd/_createAssigner.js +24 -0
  382. package/node_modules/underscore/amd/_createEscaper.js +21 -0
  383. package/node_modules/underscore/amd/_createIndexFinder.js +30 -0
  384. package/node_modules/underscore/amd/_createPredicateIndexFinder.js +18 -0
  385. package/node_modules/underscore/amd/_createReduce.js +30 -0
  386. package/node_modules/underscore/amd/_createSizePropertyCheck.js +13 -0
  387. package/node_modules/underscore/amd/_deepGet.js +15 -0
  388. package/node_modules/underscore/amd/_escapeMap.js +15 -0
  389. package/node_modules/underscore/amd/_executeBound.js +16 -0
  390. package/node_modules/underscore/amd/_flatten.js +32 -0
  391. package/node_modules/underscore/amd/_getByteLength.js +8 -0
  392. package/node_modules/underscore/amd/_getLength.js +8 -0
  393. package/node_modules/underscore/amd/_group.js +18 -0
  394. package/node_modules/underscore/amd/_has.js +10 -0
  395. package/node_modules/underscore/amd/_hasObjectTag.js +7 -0
  396. package/node_modules/underscore/amd/_isArrayLike.js +11 -0
  397. package/node_modules/underscore/amd/_isBufferLike.js +9 -0
  398. package/node_modules/underscore/amd/_keyInObj.js +11 -0
  399. package/node_modules/underscore/amd/_methodFingerprint.js +44 -0
  400. package/node_modules/underscore/amd/_optimizeCb.js +27 -0
  401. package/node_modules/underscore/amd/_setup.js +70 -0
  402. package/node_modules/underscore/amd/_shallowProperty.js +12 -0
  403. package/node_modules/underscore/amd/_stringTagBug.js +19 -0
  404. package/node_modules/underscore/amd/_tagTester.js +13 -0
  405. package/node_modules/underscore/amd/_toBufferView.js +15 -0
  406. package/node_modules/underscore/amd/_toPath.js +11 -0
  407. package/node_modules/underscore/amd/_unescapeMap.js +8 -0
  408. package/node_modules/underscore/amd/after.js +14 -0
  409. package/node_modules/underscore/amd/allKeys.js +15 -0
  410. package/node_modules/underscore/amd/before.js +18 -0
  411. package/node_modules/underscore/amd/bind.js +15 -0
  412. package/node_modules/underscore/amd/bindAll.js +19 -0
  413. package/node_modules/underscore/amd/chain.js +12 -0
  414. package/node_modules/underscore/amd/chunk.js +17 -0
  415. package/node_modules/underscore/amd/clone.js +11 -0
  416. package/node_modules/underscore/amd/compact.js +10 -0
  417. package/node_modules/underscore/amd/compose.js +18 -0
  418. package/node_modules/underscore/amd/constant.js +12 -0
  419. package/node_modules/underscore/amd/contains.js +12 -0
  420. package/node_modules/underscore/amd/countBy.js +12 -0
  421. package/node_modules/underscore/amd/create.js +14 -0
  422. package/node_modules/underscore/amd/debounce.js +43 -0
  423. package/node_modules/underscore/amd/defaults.js +8 -0
  424. package/node_modules/underscore/amd/defer.js +9 -0
  425. package/node_modules/underscore/amd/delay.js +13 -0
  426. package/node_modules/underscore/amd/difference.js +14 -0
  427. package/node_modules/underscore/amd/each.js +25 -0
  428. package/node_modules/underscore/amd/escape.js +8 -0
  429. package/node_modules/underscore/amd/every.js +17 -0
  430. package/node_modules/underscore/amd/extend.js +8 -0
  431. package/node_modules/underscore/amd/extendOwn.js +10 -0
  432. package/node_modules/underscore/amd/filter.js +15 -0
  433. package/node_modules/underscore/amd/find.js +12 -0
  434. package/node_modules/underscore/amd/findIndex.js +8 -0
  435. package/node_modules/underscore/amd/findKey.js +15 -0
  436. package/node_modules/underscore/amd/findLastIndex.js +8 -0
  437. package/node_modules/underscore/amd/findWhere.js +11 -0
  438. package/node_modules/underscore/amd/first.js +13 -0
  439. package/node_modules/underscore/amd/flatten.js +11 -0
  440. package/node_modules/underscore/amd/functions.js +14 -0
  441. package/node_modules/underscore/amd/get.js +14 -0
  442. package/node_modules/underscore/amd/groupBy.js +11 -0
  443. package/node_modules/underscore/amd/has.js +19 -0
  444. package/node_modules/underscore/amd/identity.js +10 -0
  445. package/node_modules/underscore/amd/index-default.js +12 -0
  446. package/node_modules/underscore/amd/index.js +154 -0
  447. package/node_modules/underscore/amd/indexBy.js +11 -0
  448. package/node_modules/underscore/amd/indexOf.js +11 -0
  449. package/node_modules/underscore/amd/initial.js +12 -0
  450. package/node_modules/underscore/amd/intersection.js +22 -0
  451. package/node_modules/underscore/amd/invert.js +15 -0
  452. package/node_modules/underscore/amd/invoke.js +28 -0
  453. package/node_modules/underscore/amd/isArguments.js +19 -0
  454. package/node_modules/underscore/amd/isArray.js +9 -0
  455. package/node_modules/underscore/amd/isArrayBuffer.js +7 -0
  456. package/node_modules/underscore/amd/isBoolean.js +10 -0
  457. package/node_modules/underscore/amd/isDataView.js +17 -0
  458. package/node_modules/underscore/amd/isDate.js +7 -0
  459. package/node_modules/underscore/amd/isElement.js +10 -0
  460. package/node_modules/underscore/amd/isEmpty.js +18 -0
  461. package/node_modules/underscore/amd/isEqual.js +133 -0
  462. package/node_modules/underscore/amd/isError.js +7 -0
  463. package/node_modules/underscore/amd/isFinite.js +10 -0
  464. package/node_modules/underscore/amd/isFunction.js +18 -0
  465. package/node_modules/underscore/amd/isMap.js +7 -0
  466. package/node_modules/underscore/amd/isMatch.js +17 -0
  467. package/node_modules/underscore/amd/isNaN.js +10 -0
  468. package/node_modules/underscore/amd/isNull.js +10 -0
  469. package/node_modules/underscore/amd/isNumber.js +7 -0
  470. package/node_modules/underscore/amd/isObject.js +11 -0
  471. package/node_modules/underscore/amd/isRegExp.js +7 -0
  472. package/node_modules/underscore/amd/isSet.js +7 -0
  473. package/node_modules/underscore/amd/isString.js +7 -0
  474. package/node_modules/underscore/amd/isSymbol.js +7 -0
  475. package/node_modules/underscore/amd/isTypedArray.js +16 -0
  476. package/node_modules/underscore/amd/isUndefined.js +10 -0
  477. package/node_modules/underscore/amd/isWeakMap.js +7 -0
  478. package/node_modules/underscore/amd/isWeakSet.js +7 -0
  479. package/node_modules/underscore/amd/iteratee.js +13 -0
  480. package/node_modules/underscore/amd/keys.js +17 -0
  481. package/node_modules/underscore/amd/last.js +13 -0
  482. package/node_modules/underscore/amd/lastIndexOf.js +9 -0
  483. package/node_modules/underscore/amd/map.js +18 -0
  484. package/node_modules/underscore/amd/mapObject.js +19 -0
  485. package/node_modules/underscore/amd/matcher.js +14 -0
  486. package/node_modules/underscore/amd/max.js +30 -0
  487. package/node_modules/underscore/amd/memoize.js +17 -0
  488. package/node_modules/underscore/amd/min.js +30 -0
  489. package/node_modules/underscore/amd/mixin.js +18 -0
  490. package/node_modules/underscore/amd/negate.js +12 -0
  491. package/node_modules/underscore/amd/noop.js +8 -0
  492. package/node_modules/underscore/amd/now.js +10 -0
  493. package/node_modules/underscore/amd/object.js +20 -0
  494. package/node_modules/underscore/amd/omit.js +20 -0
  495. package/node_modules/underscore/amd/once.js +9 -0
  496. package/node_modules/underscore/amd/pairs.js +17 -0
  497. package/node_modules/underscore/amd/partial.js +25 -0
  498. package/node_modules/underscore/amd/partition.js +11 -0
  499. package/node_modules/underscore/amd/pick.js +25 -0
  500. package/node_modules/underscore/amd/pipe.js +13 -0
  501. package/node_modules/underscore/amd/pluck.js +10 -0
  502. package/node_modules/underscore/amd/property.js +14 -0
  503. package/node_modules/underscore/amd/propertyOf.js +13 -0
  504. package/node_modules/underscore/amd/random.js +14 -0
  505. package/node_modules/underscore/amd/range.js +27 -0
  506. package/node_modules/underscore/amd/reduce.js +9 -0
  507. package/node_modules/underscore/amd/reduceRight.js +8 -0
  508. package/node_modules/underscore/amd/reject.js +10 -0
  509. package/node_modules/underscore/amd/rest.js +12 -0
  510. package/node_modules/underscore/amd/restArguments.js +33 -0
  511. package/node_modules/underscore/amd/result.js +25 -0
  512. package/node_modules/underscore/amd/sample.js +27 -0
  513. package/node_modules/underscore/amd/shuffle.js +10 -0
  514. package/node_modules/underscore/amd/size.js +11 -0
  515. package/node_modules/underscore/amd/some.js +17 -0
  516. package/node_modules/underscore/amd/sortBy.js +26 -0
  517. package/node_modules/underscore/amd/sortedIndex.js +18 -0
  518. package/node_modules/underscore/amd/tap.js +13 -0
  519. package/node_modules/underscore/amd/template.js +103 -0
  520. package/node_modules/underscore/amd/templateSettings.js +13 -0
  521. package/node_modules/underscore/amd/throttle.js +51 -0
  522. package/node_modules/underscore/amd/times.js +13 -0
  523. package/node_modules/underscore/amd/toArray.js +18 -0
  524. package/node_modules/underscore/amd/toPath.js +12 -0
  525. package/node_modules/underscore/amd/underscore-array-methods.js +30 -0
  526. package/node_modules/underscore/amd/underscore.js +29 -0
  527. package/node_modules/underscore/amd/unescape.js +8 -0
  528. package/node_modules/underscore/amd/union.js +11 -0
  529. package/node_modules/underscore/amd/uniq.js +37 -0
  530. package/node_modules/underscore/amd/uniqueId.js +13 -0
  531. package/node_modules/underscore/amd/unzip.js +17 -0
  532. package/node_modules/underscore/amd/values.js +16 -0
  533. package/node_modules/underscore/amd/where.js +11 -0
  534. package/node_modules/underscore/amd/without.js +10 -0
  535. package/node_modules/underscore/amd/wrap.js +12 -0
  536. package/node_modules/underscore/amd/zip.js +9 -0
  537. package/node_modules/underscore/cjs/_baseCreate.js +20 -0
  538. package/node_modules/underscore/cjs/_baseIteratee.js +19 -0
  539. package/node_modules/underscore/cjs/_cb.js +12 -0
  540. package/node_modules/underscore/cjs/_chainResult.js +8 -0
  541. package/node_modules/underscore/cjs/_collectNonEnumProps.js +42 -0
  542. package/node_modules/underscore/cjs/_createAssigner.js +20 -0
  543. package/node_modules/underscore/cjs/_createEscaper.js +19 -0
  544. package/node_modules/underscore/cjs/_createIndexFinder.js +30 -0
  545. package/node_modules/underscore/cjs/_createPredicateIndexFinder.js +17 -0
  546. package/node_modules/underscore/cjs/_createReduce.js +30 -0
  547. package/node_modules/underscore/cjs/_createSizePropertyCheck.js +11 -0
  548. package/node_modules/underscore/cjs/_deepGet.js +11 -0
  549. package/node_modules/underscore/cjs/_escapeMap.js +11 -0
  550. package/node_modules/underscore/cjs/_executeBound.js +15 -0
  551. package/node_modules/underscore/cjs/_flatten.js +33 -0
  552. package/node_modules/underscore/cjs/_getByteLength.js +6 -0
  553. package/node_modules/underscore/cjs/_getLength.js +6 -0
  554. package/node_modules/underscore/cjs/_group.js +17 -0
  555. package/node_modules/underscore/cjs/_has.js +8 -0
  556. package/node_modules/underscore/cjs/_hasObjectTag.js +5 -0
  557. package/node_modules/underscore/cjs/_isArrayLike.js +10 -0
  558. package/node_modules/underscore/cjs/_isBufferLike.js +8 -0
  559. package/node_modules/underscore/cjs/_keyInObj.js +7 -0
  560. package/node_modules/underscore/cjs/_methodFingerprint.js +44 -0
  561. package/node_modules/underscore/cjs/_optimizeCb.js +23 -0
  562. package/node_modules/underscore/cjs/_setup.js +66 -0
  563. package/node_modules/underscore/cjs/_shallowProperty.js +8 -0
  564. package/node_modules/underscore/cjs/_stringTagBug.js +18 -0
  565. package/node_modules/underscore/cjs/_tagTester.js +11 -0
  566. package/node_modules/underscore/cjs/_toBufferView.js +13 -0
  567. package/node_modules/underscore/cjs/_toPath.js +10 -0
  568. package/node_modules/underscore/cjs/_unescapeMap.js +7 -0
  569. package/node_modules/underscore/cjs/after.js +10 -0
  570. package/node_modules/underscore/cjs/allKeys.js +15 -0
  571. package/node_modules/underscore/cjs/before.js +14 -0
  572. package/node_modules/underscore/cjs/bind.js +15 -0
  573. package/node_modules/underscore/cjs/bindAll.js +19 -0
  574. package/node_modules/underscore/cjs/chain.js +10 -0
  575. package/node_modules/underscore/cjs/chunk.js +15 -0
  576. package/node_modules/underscore/cjs/clone.js +11 -0
  577. package/node_modules/underscore/cjs/compact.js +8 -0
  578. package/node_modules/underscore/cjs/compose.js +14 -0
  579. package/node_modules/underscore/cjs/constant.js +8 -0
  580. package/node_modules/underscore/cjs/contains.js +12 -0
  581. package/node_modules/underscore/cjs/countBy.js +11 -0
  582. package/node_modules/underscore/cjs/create.js +13 -0
  583. package/node_modules/underscore/cjs/debounce.js +42 -0
  584. package/node_modules/underscore/cjs/defaults.js +7 -0
  585. package/node_modules/underscore/cjs/defer.js +9 -0
  586. package/node_modules/underscore/cjs/delay.js +11 -0
  587. package/node_modules/underscore/cjs/difference.js +15 -0
  588. package/node_modules/underscore/cjs/each.js +25 -0
  589. package/node_modules/underscore/cjs/escape.js +7 -0
  590. package/node_modules/underscore/cjs/every.js +17 -0
  591. package/node_modules/underscore/cjs/extend.js +7 -0
  592. package/node_modules/underscore/cjs/extendOwn.js +9 -0
  593. package/node_modules/underscore/cjs/filter.js +14 -0
  594. package/node_modules/underscore/cjs/find.js +12 -0
  595. package/node_modules/underscore/cjs/findIndex.js +6 -0
  596. package/node_modules/underscore/cjs/findKey.js +14 -0
  597. package/node_modules/underscore/cjs/findLastIndex.js +6 -0
  598. package/node_modules/underscore/cjs/findWhere.js +10 -0
  599. package/node_modules/underscore/cjs/first.js +11 -0
  600. package/node_modules/underscore/cjs/flatten.js +9 -0
  601. package/node_modules/underscore/cjs/functions.js +12 -0
  602. package/node_modules/underscore/cjs/get.js +14 -0
  603. package/node_modules/underscore/cjs/groupBy.js +10 -0
  604. package/node_modules/underscore/cjs/has.js +18 -0
  605. package/node_modules/underscore/cjs/identity.js +6 -0
  606. package/node_modules/underscore/cjs/index-default.js +11 -0
  607. package/node_modules/underscore/cjs/index.js +278 -0
  608. package/node_modules/underscore/cjs/indexBy.js +9 -0
  609. package/node_modules/underscore/cjs/indexOf.js +11 -0
  610. package/node_modules/underscore/cjs/initial.js +10 -0
  611. package/node_modules/underscore/cjs/intersection.js +21 -0
  612. package/node_modules/underscore/cjs/invert.js +13 -0
  613. package/node_modules/underscore/cjs/invoke.js +30 -0
  614. package/node_modules/underscore/cjs/isArguments.js +18 -0
  615. package/node_modules/underscore/cjs/isArray.js +8 -0
  616. package/node_modules/underscore/cjs/isArrayBuffer.js +5 -0
  617. package/node_modules/underscore/cjs/isBoolean.js +8 -0
  618. package/node_modules/underscore/cjs/isDataView.js +18 -0
  619. package/node_modules/underscore/cjs/isDate.js +5 -0
  620. package/node_modules/underscore/cjs/isElement.js +6 -0
  621. package/node_modules/underscore/cjs/isEmpty.js +20 -0
  622. package/node_modules/underscore/cjs/isEqual.js +140 -0
  623. package/node_modules/underscore/cjs/isError.js +5 -0
  624. package/node_modules/underscore/cjs/isFinite.js +9 -0
  625. package/node_modules/underscore/cjs/isFunction.js +17 -0
  626. package/node_modules/underscore/cjs/isMap.js +7 -0
  627. package/node_modules/underscore/cjs/isMatch.js +15 -0
  628. package/node_modules/underscore/cjs/isNaN.js +9 -0
  629. package/node_modules/underscore/cjs/isNull.js +6 -0
  630. package/node_modules/underscore/cjs/isNumber.js +5 -0
  631. package/node_modules/underscore/cjs/isObject.js +7 -0
  632. package/node_modules/underscore/cjs/isRegExp.js +5 -0
  633. package/node_modules/underscore/cjs/isSet.js +7 -0
  634. package/node_modules/underscore/cjs/isString.js +5 -0
  635. package/node_modules/underscore/cjs/isSymbol.js +5 -0
  636. package/node_modules/underscore/cjs/isTypedArray.js +17 -0
  637. package/node_modules/underscore/cjs/isUndefined.js +6 -0
  638. package/node_modules/underscore/cjs/isWeakMap.js +7 -0
  639. package/node_modules/underscore/cjs/isWeakSet.js +5 -0
  640. package/node_modules/underscore/cjs/iteratee.js +12 -0
  641. package/node_modules/underscore/cjs/keys.js +18 -0
  642. package/node_modules/underscore/cjs/last.js +11 -0
  643. package/node_modules/underscore/cjs/lastIndexOf.js +8 -0
  644. package/node_modules/underscore/cjs/map.js +18 -0
  645. package/node_modules/underscore/cjs/mapObject.js +18 -0
  646. package/node_modules/underscore/cjs/matcher.js +13 -0
  647. package/node_modules/underscore/cjs/max.js +31 -0
  648. package/node_modules/underscore/cjs/memoize.js +15 -0
  649. package/node_modules/underscore/cjs/min.js +31 -0
  650. package/node_modules/underscore/cjs/mixin.js +20 -0
  651. package/node_modules/underscore/cjs/negate.js +8 -0
  652. package/node_modules/underscore/cjs/noop.js +4 -0
  653. package/node_modules/underscore/cjs/now.js +6 -0
  654. package/node_modules/underscore/cjs/object.js +18 -0
  655. package/node_modules/underscore/cjs/omit.js +24 -0
  656. package/node_modules/underscore/cjs/once.js +8 -0
  657. package/node_modules/underscore/cjs/pairs.js +15 -0
  658. package/node_modules/underscore/cjs/partial.js +25 -0
  659. package/node_modules/underscore/cjs/partition.js +9 -0
  660. package/node_modules/underscore/cjs/pick.js +28 -0
  661. package/node_modules/underscore/cjs/pipe.js +12 -0
  662. package/node_modules/underscore/cjs/pluck.js +9 -0
  663. package/node_modules/underscore/cjs/property.js +13 -0
  664. package/node_modules/underscore/cjs/propertyOf.js +12 -0
  665. package/node_modules/underscore/cjs/random.js +10 -0
  666. package/node_modules/underscore/cjs/range.js +23 -0
  667. package/node_modules/underscore/cjs/reduce.js +7 -0
  668. package/node_modules/underscore/cjs/reduceRight.js +6 -0
  669. package/node_modules/underscore/cjs/reject.js +10 -0
  670. package/node_modules/underscore/cjs/rest.js +10 -0
  671. package/node_modules/underscore/cjs/restArguments.js +29 -0
  672. package/node_modules/underscore/cjs/result.js +24 -0
  673. package/node_modules/underscore/cjs/sample.js +29 -0
  674. package/node_modules/underscore/cjs/shuffle.js +8 -0
  675. package/node_modules/underscore/cjs/size.js +10 -0
  676. package/node_modules/underscore/cjs/some.js +17 -0
  677. package/node_modules/underscore/cjs/sortBy.js +26 -0
  678. package/node_modules/underscore/cjs/sortedIndex.js +17 -0
  679. package/node_modules/underscore/cjs/tap.js +9 -0
  680. package/node_modules/underscore/cjs/template.js +103 -0
  681. package/node_modules/underscore/cjs/templateSettings.js +11 -0
  682. package/node_modules/underscore/cjs/throttle.js +49 -0
  683. package/node_modules/underscore/cjs/times.js +11 -0
  684. package/node_modules/underscore/cjs/toArray.js +22 -0
  685. package/node_modules/underscore/cjs/toPath.js +11 -0
  686. package/node_modules/underscore/cjs/underscore-array-methods.js +31 -0
  687. package/node_modules/underscore/cjs/underscore.js +27 -0
  688. package/node_modules/underscore/cjs/unescape.js +7 -0
  689. package/node_modules/underscore/cjs/union.js +11 -0
  690. package/node_modules/underscore/cjs/uniq.js +38 -0
  691. package/node_modules/underscore/cjs/uniqueId.js +9 -0
  692. package/node_modules/underscore/cjs/unzip.js +17 -0
  693. package/node_modules/underscore/cjs/values.js +14 -0
  694. package/node_modules/underscore/cjs/where.js +10 -0
  695. package/node_modules/underscore/cjs/without.js +9 -0
  696. package/node_modules/underscore/cjs/wrap.js +10 -0
  697. package/node_modules/underscore/cjs/zip.js +8 -0
  698. package/node_modules/underscore/modules/.eslintrc +21 -0
  699. package/node_modules/underscore/modules/_baseCreate.js +18 -0
  700. package/node_modules/underscore/modules/_baseIteratee.js +17 -0
  701. package/node_modules/underscore/modules/_cb.js +10 -0
  702. package/node_modules/underscore/modules/_chainResult.js +6 -0
  703. package/node_modules/underscore/modules/_collectNonEnumProps.js +40 -0
  704. package/node_modules/underscore/modules/_createAssigner.js +18 -0
  705. package/node_modules/underscore/modules/_createEscaper.js +17 -0
  706. package/node_modules/underscore/modules/_createIndexFinder.js +28 -0
  707. package/node_modules/underscore/modules/_createPredicateIndexFinder.js +15 -0
  708. package/node_modules/underscore/modules/_createReduce.js +28 -0
  709. package/node_modules/underscore/modules/_createSizePropertyCheck.js +9 -0
  710. package/node_modules/underscore/modules/_deepGet.js +9 -0
  711. package/node_modules/underscore/modules/_escapeMap.js +9 -0
  712. package/node_modules/underscore/modules/_executeBound.js +13 -0
  713. package/node_modules/underscore/modules/_flatten.js +33 -0
  714. package/node_modules/underscore/modules/_getByteLength.js +4 -0
  715. package/node_modules/underscore/modules/_getLength.js +4 -0
  716. package/node_modules/underscore/modules/_group.js +15 -0
  717. package/node_modules/underscore/modules/_has.js +6 -0
  718. package/node_modules/underscore/modules/_hasObjectTag.js +3 -0
  719. package/node_modules/underscore/modules/_isArrayLike.js +8 -0
  720. package/node_modules/underscore/modules/_isBufferLike.js +6 -0
  721. package/node_modules/underscore/modules/_keyInObj.js +5 -0
  722. package/node_modules/underscore/modules/_methodFingerprint.js +37 -0
  723. package/node_modules/underscore/modules/_optimizeCb.js +21 -0
  724. package/node_modules/underscore/modules/_setup.js +43 -0
  725. package/node_modules/underscore/modules/_shallowProperty.js +6 -0
  726. package/node_modules/underscore/modules/_stringTagBug.js +13 -0
  727. package/node_modules/underscore/modules/_tagTester.js +9 -0
  728. package/node_modules/underscore/modules/_toBufferView.js +11 -0
  729. package/node_modules/underscore/modules/_toPath.js +8 -0
  730. package/node_modules/underscore/modules/_unescapeMap.js +5 -0
  731. package/node_modules/underscore/modules/after.js +8 -0
  732. package/node_modules/underscore/modules/allKeys.js +13 -0
  733. package/node_modules/underscore/modules/before.js +12 -0
  734. package/node_modules/underscore/modules/bind.js +13 -0
  735. package/node_modules/underscore/modules/bindAll.js +17 -0
  736. package/node_modules/underscore/modules/chain.js +8 -0
  737. package/node_modules/underscore/modules/chunk.js +13 -0
  738. package/node_modules/underscore/modules/clone.js +9 -0
  739. package/node_modules/underscore/modules/compact.js +6 -0
  740. package/node_modules/underscore/modules/compose.js +12 -0
  741. package/node_modules/underscore/modules/constant.js +6 -0
  742. package/node_modules/underscore/modules/contains.js +10 -0
  743. package/node_modules/underscore/modules/countBy.js +9 -0
  744. package/node_modules/underscore/modules/create.js +11 -0
  745. package/node_modules/underscore/modules/debounce.js +40 -0
  746. package/node_modules/underscore/modules/defaults.js +5 -0
  747. package/node_modules/underscore/modules/defer.js +7 -0
  748. package/node_modules/underscore/modules/delay.js +9 -0
  749. package/node_modules/underscore/modules/difference.js +13 -0
  750. package/node_modules/underscore/modules/each.js +23 -0
  751. package/node_modules/underscore/modules/escape.js +5 -0
  752. package/node_modules/underscore/modules/every.js +15 -0
  753. package/node_modules/underscore/modules/extend.js +5 -0
  754. package/node_modules/underscore/modules/extendOwn.js +7 -0
  755. package/node_modules/underscore/modules/filter.js +12 -0
  756. package/node_modules/underscore/modules/find.js +10 -0
  757. package/node_modules/underscore/modules/findIndex.js +4 -0
  758. package/node_modules/underscore/modules/findKey.js +12 -0
  759. package/node_modules/underscore/modules/findLastIndex.js +4 -0
  760. package/node_modules/underscore/modules/findWhere.js +8 -0
  761. package/node_modules/underscore/modules/first.js +9 -0
  762. package/node_modules/underscore/modules/flatten.js +7 -0
  763. package/node_modules/underscore/modules/functions.js +10 -0
  764. package/node_modules/underscore/modules/get.js +12 -0
  765. package/node_modules/underscore/modules/groupBy.js +8 -0
  766. package/node_modules/underscore/modules/has.js +16 -0
  767. package/node_modules/underscore/modules/identity.js +4 -0
  768. package/node_modules/underscore/modules/index-all.js +18 -0
  769. package/node_modules/underscore/modules/index-default.js +27 -0
  770. package/node_modules/underscore/modules/index.js +200 -0
  771. package/node_modules/underscore/modules/indexBy.js +7 -0
  772. package/node_modules/underscore/modules/indexOf.js +9 -0
  773. package/node_modules/underscore/modules/initial.js +8 -0
  774. package/node_modules/underscore/modules/intersection.js +19 -0
  775. package/node_modules/underscore/modules/invert.js +11 -0
  776. package/node_modules/underscore/modules/invoke.js +28 -0
  777. package/node_modules/underscore/modules/isArguments.js +16 -0
  778. package/node_modules/underscore/modules/isArray.js +6 -0
  779. package/node_modules/underscore/modules/isArrayBuffer.js +3 -0
  780. package/node_modules/underscore/modules/isBoolean.js +6 -0
  781. package/node_modules/underscore/modules/isDataView.js +16 -0
  782. package/node_modules/underscore/modules/isDate.js +3 -0
  783. package/node_modules/underscore/modules/isElement.js +4 -0
  784. package/node_modules/underscore/modules/isEmpty.js +18 -0
  785. package/node_modules/underscore/modules/isEqual.js +153 -0
  786. package/node_modules/underscore/modules/isError.js +3 -0
  787. package/node_modules/underscore/modules/isFinite.js +7 -0
  788. package/node_modules/underscore/modules/isFunction.js +15 -0
  789. package/node_modules/underscore/modules/isMap.js +5 -0
  790. package/node_modules/underscore/modules/isMatch.js +13 -0
  791. package/node_modules/underscore/modules/isNaN.js +7 -0
  792. package/node_modules/underscore/modules/isNull.js +4 -0
  793. package/node_modules/underscore/modules/isNumber.js +3 -0
  794. package/node_modules/underscore/modules/isObject.js +5 -0
  795. package/node_modules/underscore/modules/isRegExp.js +3 -0
  796. package/node_modules/underscore/modules/isSet.js +5 -0
  797. package/node_modules/underscore/modules/isString.js +3 -0
  798. package/node_modules/underscore/modules/isSymbol.js +3 -0
  799. package/node_modules/underscore/modules/isTypedArray.js +15 -0
  800. package/node_modules/underscore/modules/isUndefined.js +4 -0
  801. package/node_modules/underscore/modules/isWeakMap.js +5 -0
  802. package/node_modules/underscore/modules/isWeakSet.js +3 -0
  803. package/node_modules/underscore/modules/iteratee.js +10 -0
  804. package/node_modules/underscore/modules/keys.js +16 -0
  805. package/node_modules/underscore/modules/last.js +9 -0
  806. package/node_modules/underscore/modules/lastIndexOf.js +6 -0
  807. package/node_modules/underscore/modules/map.js +16 -0
  808. package/node_modules/underscore/modules/mapObject.js +16 -0
  809. package/node_modules/underscore/modules/matcher.js +11 -0
  810. package/node_modules/underscore/modules/max.js +29 -0
  811. package/node_modules/underscore/modules/memoize.js +13 -0
  812. package/node_modules/underscore/modules/min.js +29 -0
  813. package/node_modules/underscore/modules/mixin.js +18 -0
  814. package/node_modules/underscore/modules/negate.js +6 -0
  815. package/node_modules/underscore/modules/noop.js +2 -0
  816. package/node_modules/underscore/modules/now.js +4 -0
  817. package/node_modules/underscore/modules/object.js +16 -0
  818. package/node_modules/underscore/modules/omit.js +22 -0
  819. package/node_modules/underscore/modules/once.js +6 -0
  820. package/node_modules/underscore/modules/package.json +1 -0
  821. package/node_modules/underscore/modules/pairs.js +13 -0
  822. package/node_modules/underscore/modules/partial.js +24 -0
  823. package/node_modules/underscore/modules/partition.js +7 -0
  824. package/node_modules/underscore/modules/pick.js +26 -0
  825. package/node_modules/underscore/modules/pluck.js +7 -0
  826. package/node_modules/underscore/modules/property.js +11 -0
  827. package/node_modules/underscore/modules/propertyOf.js +10 -0
  828. package/node_modules/underscore/modules/random.js +8 -0
  829. package/node_modules/underscore/modules/range.js +21 -0
  830. package/node_modules/underscore/modules/reduce.js +5 -0
  831. package/node_modules/underscore/modules/reduceRight.js +4 -0
  832. package/node_modules/underscore/modules/reject.js +8 -0
  833. package/node_modules/underscore/modules/rest.js +8 -0
  834. package/node_modules/underscore/modules/restArguments.js +27 -0
  835. package/node_modules/underscore/modules/result.js +22 -0
  836. package/node_modules/underscore/modules/sample.js +27 -0
  837. package/node_modules/underscore/modules/shuffle.js +6 -0
  838. package/node_modules/underscore/modules/size.js +8 -0
  839. package/node_modules/underscore/modules/some.js +15 -0
  840. package/node_modules/underscore/modules/sortBy.js +24 -0
  841. package/node_modules/underscore/modules/sortedIndex.js +15 -0
  842. package/node_modules/underscore/modules/tap.js +7 -0
  843. package/node_modules/underscore/modules/template.js +101 -0
  844. package/node_modules/underscore/modules/templateSettings.js +9 -0
  845. package/node_modules/underscore/modules/throttle.js +47 -0
  846. package/node_modules/underscore/modules/times.js +9 -0
  847. package/node_modules/underscore/modules/toArray.js +20 -0
  848. package/node_modules/underscore/modules/toPath.js +9 -0
  849. package/node_modules/underscore/modules/underscore-array-methods.js +31 -0
  850. package/node_modules/underscore/modules/underscore.js +25 -0
  851. package/node_modules/underscore/modules/unescape.js +5 -0
  852. package/node_modules/underscore/modules/union.js +9 -0
  853. package/node_modules/underscore/modules/uniq.js +36 -0
  854. package/node_modules/underscore/modules/uniqueId.js +7 -0
  855. package/node_modules/underscore/modules/unzip.js +15 -0
  856. package/node_modules/underscore/modules/values.js +12 -0
  857. package/node_modules/underscore/modules/where.js +8 -0
  858. package/node_modules/underscore/modules/without.js +7 -0
  859. package/node_modules/underscore/modules/wrap.js +8 -0
  860. package/node_modules/underscore/modules/zip.js +6 -0
  861. package/node_modules/underscore/package.json +124 -0
  862. package/node_modules/underscore/underscore-esm-min.js +5 -0
  863. package/node_modules/underscore/underscore-esm-min.js.map +1 -0
  864. package/node_modules/underscore/underscore-esm.js +2056 -0
  865. package/node_modules/underscore/underscore-esm.js.map +1 -0
  866. package/node_modules/underscore/underscore-min.js +6 -0
  867. package/node_modules/underscore/underscore-min.js.map +1 -0
  868. package/node_modules/underscore/underscore-node-f.cjs +2180 -0
  869. package/node_modules/underscore/underscore-node-f.cjs.map +1 -0
  870. package/node_modules/underscore/underscore-node.cjs +11 -0
  871. package/node_modules/underscore/underscore-node.cjs.map +1 -0
  872. package/node_modules/underscore/underscore-node.mjs +7 -0
  873. package/node_modules/underscore/underscore-node.mjs.map +1 -0
  874. package/node_modules/underscore/underscore-umd-min.js +6 -0
  875. package/node_modules/underscore/underscore-umd-min.js.map +1 -0
  876. package/node_modules/underscore/underscore-umd.js +2064 -0
  877. package/node_modules/underscore/underscore-umd.js.map +1 -0
  878. package/node_modules/underscore/underscore.js +2064 -0
  879. package/node_modules/util-deprecate/History.md +16 -0
  880. package/node_modules/util-deprecate/LICENSE +24 -0
  881. package/node_modules/util-deprecate/README.md +53 -0
  882. package/node_modules/util-deprecate/browser.js +67 -0
  883. package/node_modules/util-deprecate/node.js +6 -0
  884. package/node_modules/util-deprecate/package.json +27 -0
  885. package/node_modules/xmlbuilder/CHANGELOG.md +438 -0
  886. package/node_modules/xmlbuilder/LICENSE +21 -0
  887. package/node_modules/xmlbuilder/README.md +86 -0
  888. package/node_modules/xmlbuilder/appveyor.yml +20 -0
  889. package/node_modules/xmlbuilder/lib/Utility.js +83 -0
  890. package/node_modules/xmlbuilder/lib/XMLAttribute.js +41 -0
  891. package/node_modules/xmlbuilder/lib/XMLCData.js +32 -0
  892. package/node_modules/xmlbuilder/lib/XMLComment.js +32 -0
  893. package/node_modules/xmlbuilder/lib/XMLDTDAttList.js +50 -0
  894. package/node_modules/xmlbuilder/lib/XMLDTDElement.js +35 -0
  895. package/node_modules/xmlbuilder/lib/XMLDTDEntity.js +56 -0
  896. package/node_modules/xmlbuilder/lib/XMLDTDNotation.js +37 -0
  897. package/node_modules/xmlbuilder/lib/XMLDeclaration.js +40 -0
  898. package/node_modules/xmlbuilder/lib/XMLDocType.js +108 -0
  899. package/node_modules/xmlbuilder/lib/XMLDocument.js +49 -0
  900. package/node_modules/xmlbuilder/lib/XMLDocumentCB.js +414 -0
  901. package/node_modules/xmlbuilder/lib/XMLDummy.js +29 -0
  902. package/node_modules/xmlbuilder/lib/XMLElement.js +111 -0
  903. package/node_modules/xmlbuilder/lib/XMLNode.js +467 -0
  904. package/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js +35 -0
  905. package/node_modules/xmlbuilder/lib/XMLRaw.js +32 -0
  906. package/node_modules/xmlbuilder/lib/XMLStreamWriter.js +287 -0
  907. package/node_modules/xmlbuilder/lib/XMLStringWriter.js +341 -0
  908. package/node_modules/xmlbuilder/lib/XMLStringifier.js +163 -0
  909. package/node_modules/xmlbuilder/lib/XMLText.js +32 -0
  910. package/node_modules/xmlbuilder/lib/XMLWriterBase.js +90 -0
  911. package/node_modules/xmlbuilder/lib/index.js +53 -0
  912. package/node_modules/xmlbuilder/package.json +37 -0
  913. package/package.json +18 -7
  914. package/schemas/tool-definition.schema.json +13 -0
  915. package/scripts/check-doc-links.mjs +6 -0
  916. package/scripts/check-image-tags.sh +1 -1
  917. package/scripts/check-package-artifact.mjs +19 -0
  918. package/scripts/check-release-consistency.test.mjs +2 -2
  919. package/scripts/dependency-audit.mjs +49 -96
  920. package/scripts/dependency-audit.test.mjs +70 -106
  921. package/scripts/doctor-upgrade-plan.test.ts +205 -0
  922. package/scripts/doctor-upgrade-plan.ts +276 -0
  923. package/scripts/doctor.ts +4 -1
  924. package/scripts/docx-browser-test.mjs +56 -0
  925. package/scripts/docx-compatibility.test.mjs +39 -0
  926. package/scripts/docx-fixtures.mjs +19 -0
  927. package/scripts/e2e-console-approval-details.mjs +134 -0
  928. package/scripts/e2e-console-config-races.mjs +180 -0
  929. package/scripts/e2e-console-kb-audit.mjs +170 -0
  930. package/scripts/e2e-console-operations-audit.mjs +152 -0
  931. package/scripts/e2e-console-runtime-audit.mjs +179 -0
  932. package/scripts/e2e-console-settings-audit.mjs +125 -0
  933. package/scripts/e2e-console-troubleshooting-extra.mjs +267 -0
  934. package/scripts/e2e-console.mjs +476 -7
  935. package/scripts/export-oss.mjs +3 -0
  936. package/scripts/generate-third-party-notices.mjs +6 -2
  937. package/scripts/install.sh +1 -1
  938. package/scripts/notification-console-test.mjs +172 -0
  939. package/scripts/oss-boundary-check.mjs +3 -1
  940. package/scripts/publish-images.sh +1 -1
  941. package/scripts/release-audit.mjs +9 -1
  942. package/scripts/vendor-mammoth.mjs +130 -0
  943. package/scripts/verify-github-repo.mjs +8 -0
  944. package/scripts/verify-oss-export.mjs +3 -0
  945. package/sql/068_notification_outbox.sql +28 -0
  946. package/sql/README.en.md +8 -0
  947. package/sql/README.md +8 -0
  948. package/src/app/agent-client-runtime.test.ts +115 -2
  949. package/src/app/agent-client-runtime.ts +40 -11
  950. package/src/app/agent-knowledge.test.ts +171 -0
  951. package/src/app/agent-knowledge.ts +233 -0
  952. package/src/app/agent-tool-catalog-revision.test.ts +31 -0
  953. package/src/app/agent-tool-invocations.test.ts +7 -2
  954. package/src/app/agent-tool-invocations.ts +67 -7
  955. package/src/app/approval-continuations.mysql.test.ts +1 -1
  956. package/src/app/approval-continuations.test.ts +49 -1
  957. package/src/app/delivery-dlq-replay.mysql.test.ts +2 -2
  958. package/src/app/delivery.ts +115 -1
  959. package/src/app/engine.ts +5 -4
  960. package/src/app/http.test.ts +16 -1
  961. package/src/app/http.ts +3 -3
  962. package/src/app/kernel-boot-recovery.mysql.test.ts +132 -0
  963. package/src/app/kernel-boot-recovery.test.ts +157 -0
  964. package/src/app/kernel-usage-lifecycle.mysql.test.ts +1 -1
  965. package/src/app/kernel.ts +20 -8
  966. package/src/app/notification-outbox.test.ts +321 -0
  967. package/src/app/notification-outbox.ts +123 -0
  968. package/src/app/operational-metrics.test.ts +15 -0
  969. package/src/app/operational-metrics.ts +9 -0
  970. package/src/app/outbound.ts +28 -0
  971. package/src/app/readiness.mysql.test.ts +120 -0
  972. package/src/app/readiness.test.ts +111 -26
  973. package/src/app/readiness.ts +26 -22
  974. package/src/app/runtime-evidence-maintenance.test.ts +34 -1
  975. package/src/app/runtime-lifecycle-default.ts +7 -0
  976. package/src/app/runtime-lifecycle.ts +42 -3
  977. package/src/app/tool-approvals.test.ts +83 -0
  978. package/src/app/tool-approvals.ts +89 -34
  979. package/src/app/tool-proxy-payload.test.ts +81 -0
  980. package/src/app/tool-proxy.ts +24 -2
  981. package/src/core/config/console-diagnostic-location.test.ts +36 -0
  982. package/src/core/config/console-form-guard.test.ts +69 -0
  983. package/src/core/config/console-task-location.test.ts +64 -0
  984. package/src/core/contracts/delivery-replay.ts +1 -0
  985. package/src/core/contracts/notification-outbox.ts +54 -0
  986. package/src/core/contracts/openapi-tools.ts +16 -5
  987. package/src/core/contracts/schema-readiness.ts +11 -0
  988. package/src/core/contracts/tool-definition.ts +26 -0
  989. package/src/core/contracts/tool-guidance.test.ts +77 -0
  990. package/src/core/contracts/tool-guidance.ts +31 -0
  991. package/src/core/contracts/tool-input-limits.ts +15 -0
  992. package/src/core/contracts/tools-idempotency.test.ts +90 -0
  993. package/src/core/contracts/tools.ts +52 -9
  994. package/src/core/observability/openmetrics.test.ts +18 -0
  995. package/src/core/observability/openmetrics.ts +17 -0
  996. package/src/core/runtime/agent-execution-memory.test.ts +64 -0
  997. package/src/core/runtime/agent-execution-memory.ts +63 -0
  998. package/src/core/runtime/finish-runtime.test.ts +20 -0
  999. package/src/core/runtime/finish-runtime.ts +13 -5
  1000. package/src/core/runtime/inhub-runtime.ts +10 -2
  1001. package/src/core/runtime/notification-outbox-work.ts +15 -0
  1002. package/src/core/state/notification-outbox.ts +66 -0
  1003. package/src/core/state/state-contracts.ts +7 -0
  1004. package/src/infrastructure/config/config-approval-ledger.ts +23 -1
  1005. package/src/infrastructure/config/config-delivery-dlq-ledger.ts +26 -13
  1006. package/src/infrastructure/config/config-observability-ledger.ts +2 -0
  1007. package/src/infrastructure/config/configstore.ts +8 -4
  1008. package/src/infrastructure/schema/schema-readiness.ts +29 -0
  1009. package/src/infrastructure/state/notification-outbox-jsonl.ts +80 -0
  1010. package/src/infrastructure/state/notification-outbox-mysql.ts +100 -0
  1011. package/src/infrastructure/state/notification-outbox-storage.test.ts +325 -0
  1012. package/src/infrastructure/state/state-jsonl.ts +64 -13
  1013. package/src/infrastructure/state/state-mysql.ts +39 -5
  1014. package/src/modules/usage/contracts.ts +7 -0
  1015. package/src/modules/usage/http.ts +2 -0
  1016. package/src/modules/usage/model-continuation.test.ts +109 -0
  1017. package/src/modules/usage/model-gateway.ts +5 -1
  1018. package/src/modules/usage/output-budget.mysql.test.ts +84 -0
  1019. package/src/modules/usage/output-budget.test.ts +167 -0
  1020. package/src/modules/usage/output-budget.ts +73 -0
  1021. package/src/modules/usage/provider-stream.test.ts +22 -0
  1022. package/src/modules/usage/provider.ts +2 -3
  1023. package/src/modules/usage/repository.ts +6 -0
  1024. package/src/modules/usage/test-harness.ts +4 -2
  1025. package/src/routes/admin-approval-view.test.ts +109 -0
  1026. package/src/routes/admin-approval-view.ts +36 -0
  1027. package/src/routes/admin-notifications.test.ts +75 -0
  1028. package/src/routes/admin-notifications.ts +77 -0
  1029. package/src/routes/admin-readiness.test.ts +52 -0
  1030. package/src/routes/admin-runtime-ux.test.ts +51 -0
  1031. package/src/routes/admin-runtime-ux.ts +25 -0
  1032. package/src/routes/admin-runtime.test.ts +25 -0
  1033. package/src/routes/admin-runtime.ts +51 -8
  1034. package/src/routes/admin.ts +10 -0
  1035. package/src/routes/agent-api.test.ts +80 -1
  1036. package/src/routes/agent-api.ts +63 -4
  1037. package/src/routes/agent-tool-detail.test.ts +140 -0
  1038. package/src/routes/public-default.ts +1 -1
  1039. package/src/services/kb-agent.test.ts +84 -0
  1040. package/src/services/kb.ts +73 -0
  1041. package/src/test-support/notification-outbox-journal-crash-child.ts +20 -0
  1042. package/vendor/bailinghub-mammoth-library-1.12.0-bailinghub.1.tgz +0 -0
  1043. package/vendor/mammoth-library/LICENSE +22 -0
  1044. package/vendor/mammoth-library/SOURCE.json +57 -0
  1045. package/vendor/mammoth-library/browser/docx/files.js +14 -0
  1046. package/vendor/mammoth-library/browser/unzip.js +12 -0
  1047. package/vendor/mammoth-library/lib/document-to-html.js +469 -0
  1048. package/vendor/mammoth-library/lib/documents.js +254 -0
  1049. package/vendor/mammoth-library/lib/docx/body-reader.js +798 -0
  1050. package/vendor/mammoth-library/lib/docx/comments-reader.js +31 -0
  1051. package/vendor/mammoth-library/lib/docx/content-types-reader.js +58 -0
  1052. package/vendor/mammoth-library/lib/docx/document-xml-reader.js +30 -0
  1053. package/vendor/mammoth-library/lib/docx/docx-reader.js +226 -0
  1054. package/vendor/mammoth-library/lib/docx/files.js +80 -0
  1055. package/vendor/mammoth-library/lib/docx/notes-reader.js +28 -0
  1056. package/vendor/mammoth-library/lib/docx/numbering-xml.js +111 -0
  1057. package/vendor/mammoth-library/lib/docx/office-xml-reader.js +73 -0
  1058. package/vendor/mammoth-library/lib/docx/relationships-reader.js +43 -0
  1059. package/vendor/mammoth-library/lib/docx/style-map.js +75 -0
  1060. package/vendor/mammoth-library/lib/docx/styles-reader.js +90 -0
  1061. package/vendor/mammoth-library/lib/docx/uris.js +21 -0
  1062. package/vendor/mammoth-library/lib/html/ast.js +51 -0
  1063. package/vendor/mammoth-library/lib/html/index.js +41 -0
  1064. package/vendor/mammoth-library/lib/html/simplify.js +88 -0
  1065. package/vendor/mammoth-library/lib/images.js +31 -0
  1066. package/vendor/mammoth-library/lib/index.d.ts +86 -0
  1067. package/vendor/mammoth-library/lib/index.js +111 -0
  1068. package/vendor/mammoth-library/lib/options-reader.js +107 -0
  1069. package/vendor/mammoth-library/lib/promises.js +42 -0
  1070. package/vendor/mammoth-library/lib/raw-text.js +14 -0
  1071. package/vendor/mammoth-library/lib/results.js +72 -0
  1072. package/vendor/mammoth-library/lib/style-reader.js +365 -0
  1073. package/vendor/mammoth-library/lib/styles/document-matchers.js +100 -0
  1074. package/vendor/mammoth-library/lib/styles/html-paths.js +75 -0
  1075. package/vendor/mammoth-library/lib/styles/parser/tokeniser.js +30 -0
  1076. package/vendor/mammoth-library/lib/transforms.js +62 -0
  1077. package/vendor/mammoth-library/lib/underline.js +11 -0
  1078. package/vendor/mammoth-library/lib/unzip.js +20 -0
  1079. package/vendor/mammoth-library/lib/writers/html-writer.js +159 -0
  1080. package/vendor/mammoth-library/lib/writers/index.js +14 -0
  1081. package/vendor/mammoth-library/lib/writers/markdown-writer.js +163 -0
  1082. package/vendor/mammoth-library/lib/xml/index.js +8 -0
  1083. package/vendor/mammoth-library/lib/xml/nodes.js +70 -0
  1084. package/vendor/mammoth-library/lib/xml/reader.js +69 -0
  1085. package/vendor/mammoth-library/lib/xml/writer.js +61 -0
  1086. package/vendor/mammoth-library/lib/xml/xmldom.js +23 -0
  1087. package/vendor/mammoth-library/lib/zipfile.js +72 -0
  1088. package/vendor/mammoth-library/package.json +39 -0
  1089. package/vendor/mammoth-library/upstream-package.json +64 -0
  1090. package/vendor/mammoth-library-distribution.json +4 -0
  1091. package/web/console/assets/Accounts-CjIBO3sU.css +1 -0
  1092. package/web/console/assets/Accounts-Dhyw-7wF.js +3 -0
  1093. package/web/console/assets/AgentClients-BA0M26-I.css +1 -0
  1094. package/web/console/assets/AgentClients-DWxb8-ko.js +1 -0
  1095. package/web/console/assets/AgentTasks-DOyxANnx.css +1 -0
  1096. package/web/console/assets/AgentTasks-DUHD4dzr.js +2 -0
  1097. package/web/console/assets/Approvals-Brl-2uJq.css +1 -0
  1098. package/web/console/assets/Approvals-CQx1YWxW.js +1 -0
  1099. package/web/console/assets/Audit--QcdVlMh.js +1 -0
  1100. package/web/console/assets/Audit-DAdmOnIs.css +1 -0
  1101. package/web/console/assets/{BrandLockup-BgASiRSE.js → BrandLockup-DQcaW4Nt.js} +1 -1
  1102. package/web/console/assets/Channels-DJJU3ksE.css +1 -0
  1103. package/web/console/assets/Channels-cGS5WfQ-.js +105 -0
  1104. package/web/console/assets/ChatEntries-BYpji27B.css +1 -0
  1105. package/web/console/assets/ChatEntries-nh23Iz5O.js +7 -0
  1106. package/web/console/assets/Clients-CX5EeYio.js +3 -0
  1107. package/web/console/assets/Clients-CbZAou8E.css +1 -0
  1108. package/web/console/assets/Cost-C6oQvz9P.css +1 -0
  1109. package/web/console/assets/Cost-DOZfdNS9.js +1 -0
  1110. package/web/console/assets/Credentials--aHs57yV.css +1 -0
  1111. package/web/console/assets/Credentials-sy6W9Sac.js +1 -0
  1112. package/web/console/assets/Diagnostics-CKs27Dnv.css +1 -0
  1113. package/web/console/assets/Diagnostics-CyoM1XrZ.js +1 -0
  1114. package/web/console/assets/Executors-2Upi6bOS.css +1 -0
  1115. package/web/console/assets/Executors-BQqqiFwt.js +1 -0
  1116. package/web/console/assets/HelpTip-DLlhaGQp.js +1 -0
  1117. package/web/console/assets/HelpTip-bbDEyuqV.css +1 -0
  1118. package/web/console/assets/Kb-5R3ce4UU.js +5 -0
  1119. package/web/console/assets/Kb-BM_PYi11.css +1 -0
  1120. package/web/console/assets/{Login-DA6BASZd.js → Login-YKeUwdgo.js} +1 -1
  1121. package/web/console/assets/Projects-DHwHrPT9.css +1 -0
  1122. package/web/console/assets/Projects-Grgb6fOv.js +1 -0
  1123. package/web/console/assets/Routes-DR_Yf02e.css +1 -0
  1124. package/web/console/assets/Routes-DYgrXlRJ.js +138 -0
  1125. package/web/console/assets/Runs-CwTddJJj.js +3 -0
  1126. package/web/console/assets/Runs-D4FOvNfu.css +1 -0
  1127. package/web/console/assets/Setup-Ca0b1d1-.css +1 -0
  1128. package/web/console/assets/Setup-D_xUPNDq.js +1 -0
  1129. package/web/console/assets/Shell-BTg8Vw_L.css +1 -0
  1130. package/web/console/assets/Shell-Dfam2Uoj.js +1 -0
  1131. package/web/console/assets/StorageBuckets-7QLBpV4a.css +1 -0
  1132. package/web/console/assets/StorageBuckets-CP6e50wI.js +1 -0
  1133. package/web/console/assets/SystemSettings-BRYKyJNa.js +1 -0
  1134. package/web/console/assets/SystemSettings-HsXGx0aH.css +1 -0
  1135. package/web/console/assets/SystemStatus-B-VfRsQd.css +1 -0
  1136. package/web/console/assets/SystemStatus-CbPsDsGt.js +1 -0
  1137. package/web/console/assets/Targets-1j4-g6rC.css +1 -0
  1138. package/web/console/assets/Targets-C2LkR2AF.js +1 -0
  1139. package/web/console/assets/Tools-C9HPJqJb.css +1 -0
  1140. package/web/console/assets/Tools-C9JNJUS0.js +2 -0
  1141. package/web/console/assets/Usage-D1Mv6vGY.js +1 -0
  1142. package/web/console/assets/Usage-DMOzUsqh.css +1 -0
  1143. package/web/console/assets/UsageAccess-77LmGCm6.js +1 -0
  1144. package/web/console/assets/UsageAccess-C6ZGxEgJ.css +1 -0
  1145. package/web/console/assets/{UsageHelp-BBKIvbQ5.js → UsageHelp-BmuiE1Ew.js} +1 -1
  1146. package/web/console/assets/client-route-draft-DxZRxKPT.js +1 -0
  1147. package/web/console/assets/console-location-Csv-xsnl.js +1 -0
  1148. package/web/console/assets/form-guard-8GrFpry0.js +1 -0
  1149. package/web/console/assets/{index-65JiiUr4.js → index-B_5UfiTw.js} +1 -1
  1150. package/web/console/assets/index-MjZJEFIN.js +2 -0
  1151. package/web/console/assets/{request-BpaimqEb.js → request-rqm6MT0s.js} +1 -1
  1152. package/web/console/assets/runtime-feedback-gPfZVNvY.js +1 -0
  1153. package/web/console/assets/{schema-D0Z4kFCZ.js → schema-o3mK4mid.js} +1 -1
  1154. package/web/console/assets/task-page-location-DWiGtAln.js +1 -0
  1155. package/web/console/assets/use-list-location-FvLFt0Tq.css +1 -0
  1156. package/web/console/assets/use-list-location-cIPy2cKM.js +1 -0
  1157. package/web/console/assets/use-unsaved-form-DScKD0h9.js +1 -0
  1158. package/web/console/assets/{util-DZYfJ5Zo.js → util-B40VqOwl.js} +1 -1
  1159. package/web/console/assets/{vendor-element-8cVcdt5T.js → vendor-element-BT8tHCFk.js} +1 -1
  1160. package/web/console/assets/{vendor-mammoth-CnDA23N0.js → vendor-mammoth-CVIXVxTN.js} +1 -1
  1161. package/web/console/assets/{vendor-vue-Co7x2FW6.js → vendor-vue-DhbG0vd4.js} +7 -7
  1162. package/web/console/index.html +3 -3
  1163. package/web-admin/package-lock.json +9 -27
  1164. package/web-admin/package.json +2 -2
  1165. package/web-admin/src/client-route-draft.ts +25 -0
  1166. package/web-admin/src/components/AgentSetupPanel.vue +54 -41
  1167. package/web-admin/src/components/HelpTip.vue +4 -1
  1168. package/web-admin/src/components/ListLocationBar.vue +22 -0
  1169. package/web-admin/src/components/NotificationOutboxPanel.vue +134 -0
  1170. package/web-admin/src/console-entry.test.ts +26 -0
  1171. package/web-admin/src/console-entry.ts +20 -0
  1172. package/web-admin/src/console-location.ts +35 -0
  1173. package/web-admin/src/form-guard.ts +35 -0
  1174. package/web-admin/src/layout/Shell.vue +18 -65
  1175. package/web-admin/src/onboarding-state.test.ts +174 -0
  1176. package/web-admin/src/onboarding-state.ts +122 -0
  1177. package/web-admin/src/pages/Accounts.vue +44 -24
  1178. package/web-admin/src/pages/AgentClients.vue +47 -29
  1179. package/web-admin/src/pages/AgentTasks.vue +57 -12
  1180. package/web-admin/src/pages/Approvals.vue +105 -25
  1181. package/web-admin/src/pages/Audit.vue +15 -6
  1182. package/web-admin/src/pages/Channels.vue +136 -43
  1183. package/web-admin/src/pages/ChatEntries.vue +96 -41
  1184. package/web-admin/src/pages/Clients.vue +87 -26
  1185. package/web-admin/src/pages/Cost.vue +15 -4
  1186. package/web-admin/src/pages/Credentials.vue +63 -32
  1187. package/web-admin/src/pages/Diagnostics.vue +103 -54
  1188. package/web-admin/src/pages/Executors.vue +103 -40
  1189. package/web-admin/src/pages/Kb.vue +278 -128
  1190. package/web-admin/src/pages/Projects.vue +44 -16
  1191. package/web-admin/src/pages/Routes.vue +168 -247
  1192. package/web-admin/src/pages/Runs.vue +169 -91
  1193. package/web-admin/src/pages/Setup.vue +182 -291
  1194. package/web-admin/src/pages/StorageBuckets.vue +61 -25
  1195. package/web-admin/src/pages/SystemSettings.vue +76 -51
  1196. package/web-admin/src/pages/SystemStatus.vue +54 -30
  1197. package/web-admin/src/pages/Targets.vue +45 -17
  1198. package/web-admin/src/pages/Tools.vue +133 -68
  1199. package/web-admin/src/pages/Usage.vue +64 -25
  1200. package/web-admin/src/pages/UsageAccess.vue +11 -8
  1201. package/web-admin/src/route-call-snippets.test.ts +82 -0
  1202. package/web-admin/src/route-call-snippets.ts +178 -0
  1203. package/web-admin/src/router.ts +11 -29
  1204. package/web-admin/src/runtime-feedback.ts +43 -0
  1205. package/web-admin/src/task-page-location.ts +66 -0
  1206. package/web-admin/src/usage-output-budget.test.ts +26 -0
  1207. package/web-admin/src/usage-output-budget.ts +46 -0
  1208. package/web-admin/src/use-list-location.ts +24 -0
  1209. package/web-admin/src/use-unsaved-form.ts +38 -0
  1210. package/web-admin/tests/model-output-budget.browser.mjs +69 -0
  1211. package/security/dependency-audit-exceptions.json +0 -192
  1212. package/web/console/assets/Accounts-Bervi5JU.css +0 -1
  1213. package/web/console/assets/Accounts-DKhw_QLr.js +0 -3
  1214. package/web/console/assets/AgentClients-CM4_5HaA.js +0 -1
  1215. package/web/console/assets/AgentClients-i52AI6YV.css +0 -1
  1216. package/web/console/assets/AgentTasks-BsG850Il.css +0 -1
  1217. package/web/console/assets/AgentTasks-CkQgZTU5.js +0 -2
  1218. package/web/console/assets/Approvals-B9O9TkbO.js +0 -1
  1219. package/web/console/assets/Approvals-DlTSHl_7.css +0 -1
  1220. package/web/console/assets/Audit-2vDC1SPu.js +0 -1
  1221. package/web/console/assets/Audit-CSu6_3oD.css +0 -1
  1222. package/web/console/assets/Channels-A-GvkNBt.js +0 -105
  1223. package/web/console/assets/Channels-CCn0L1jg.css +0 -1
  1224. package/web/console/assets/ChatEntries-BLxymI67.js +0 -7
  1225. package/web/console/assets/ChatEntries-DsYtcXN6.css +0 -1
  1226. package/web/console/assets/Clients-CSHIsaWU.css +0 -1
  1227. package/web/console/assets/Clients-DeNlmvS6.js +0 -3
  1228. package/web/console/assets/Cost-CBq_L4Kz.js +0 -1
  1229. package/web/console/assets/Cost-CjT39DSZ.css +0 -1
  1230. package/web/console/assets/Credentials-DmtbctNj.js +0 -1
  1231. package/web/console/assets/Credentials-ioLP0qYN.css +0 -1
  1232. package/web/console/assets/Diagnostics-BbcRDiA-.js +0 -1
  1233. package/web/console/assets/Diagnostics-Ya05PTDp.css +0 -1
  1234. package/web/console/assets/Executors-CjhEM54c.css +0 -1
  1235. package/web/console/assets/Executors-gGgmQrDt.js +0 -1
  1236. package/web/console/assets/HelpTip-CA6Bm7Nx.css +0 -1
  1237. package/web/console/assets/HelpTip-Dtdt2tKR.js +0 -1
  1238. package/web/console/assets/Kb-CzIzd9xr.css +0 -1
  1239. package/web/console/assets/Kb-lgY6OXUz.js +0 -5
  1240. package/web/console/assets/Projects-Bm8AjsNx.css +0 -1
  1241. package/web/console/assets/Projects-DEbmB_sT.js +0 -1
  1242. package/web/console/assets/Routes-CyXV4Pba.css +0 -1
  1243. package/web/console/assets/Routes-qS6LLoyS.js +0 -124
  1244. package/web/console/assets/Runs-CvGTV8I-.css +0 -1
  1245. package/web/console/assets/Runs-DG-VLRSc.js +0 -3
  1246. package/web/console/assets/Setup-D7nxgn-9.css +0 -1
  1247. package/web/console/assets/Setup-DEpVF5uw.js +0 -1
  1248. package/web/console/assets/Shell-DgoPgK1E.js +0 -1
  1249. package/web/console/assets/Shell-ykb-tUfo.css +0 -1
  1250. package/web/console/assets/StorageBuckets-CVgpZRWY.css +0 -1
  1251. package/web/console/assets/StorageBuckets-DJtNN769.js +0 -1
  1252. package/web/console/assets/SystemSettings-0DEUgeTR.js +0 -1
  1253. package/web/console/assets/SystemSettings-BjiHyrXO.css +0 -1
  1254. package/web/console/assets/SystemStatus-CR1phiPE.js +0 -1
  1255. package/web/console/assets/SystemStatus-I11I67rw.css +0 -1
  1256. package/web/console/assets/Targets-D65l-IMB.js +0 -1
  1257. package/web/console/assets/Targets-DTb5tn6z.css +0 -1
  1258. package/web/console/assets/Tools-DU8ei6sd.css +0 -1
  1259. package/web/console/assets/Tools-DqtrINrN.js +0 -2
  1260. package/web/console/assets/Usage-B5njXNjx.js +0 -1
  1261. package/web/console/assets/Usage-CAeDGjrb.css +0 -1
  1262. package/web/console/assets/UsageAccess-CGGaWTuj.css +0 -1
  1263. package/web/console/assets/UsageAccess-ChnB4pjb.js +0 -1
  1264. package/web/console/assets/index-sLKrJd_p.js +0 -2
@@ -0,0 +1,2266 @@
1
+ var conventions = require("./conventions");
2
+
3
+ var find = conventions.find;
4
+ var NAMESPACE = conventions.NAMESPACE;
5
+ var tagNamePattern = conventions.tagNamePattern;
6
+
7
+ /**
8
+ * A prerequisite for `[].filter`, to drop elements that are empty
9
+ * @param {string} input
10
+ * @returns {boolean}
11
+ */
12
+ function notEmptyString (input) {
13
+ return input !== ''
14
+ }
15
+ /**
16
+ * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
17
+ * @see https://infra.spec.whatwg.org/#ascii-whitespace
18
+ *
19
+ * @param {string} input
20
+ * @returns {string[]} (can be empty)
21
+ */
22
+ function splitOnASCIIWhitespace(input) {
23
+ // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
24
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
25
+ }
26
+
27
+ /**
28
+ * Adds element as a key to current if it is not already present.
29
+ *
30
+ * @param {Record<string, boolean | undefined>} current
31
+ * @param {string} element
32
+ * @returns {Record<string, boolean | undefined>}
33
+ */
34
+ function orderedSetReducer (current, element) {
35
+ if (!current.hasOwnProperty(element)) {
36
+ current[element] = true;
37
+ }
38
+ return current;
39
+ }
40
+
41
+ /**
42
+ * @see https://infra.spec.whatwg.org/#ordered-set
43
+ * @param {string} input
44
+ * @returns {string[]}
45
+ */
46
+ function toOrderedSet(input) {
47
+ if (!input) return [];
48
+ var list = splitOnASCIIWhitespace(input);
49
+ return Object.keys(list.reduce(orderedSetReducer, {}))
50
+ }
51
+
52
+ /**
53
+ * Uses `list.indexOf` to implement something like `Array.prototype.includes`,
54
+ * which we can not rely on being available.
55
+ *
56
+ * @param {any[]} list
57
+ * @returns {function(any): boolean}
58
+ */
59
+ function arrayIncludes (list) {
60
+ return function(element) {
61
+ return list && list.indexOf(element) !== -1;
62
+ }
63
+ }
64
+
65
+ function copy(src,dest){
66
+ for(var p in src){
67
+ if (Object.prototype.hasOwnProperty.call(src, p)) {
68
+ dest[p] = src[p];
69
+ }
70
+ }
71
+ }
72
+
73
+ /**
74
+ ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
75
+ ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
76
+ */
77
+ function _extends(Class,Super){
78
+ var pt = Class.prototype;
79
+ if(!(pt instanceof Super)){
80
+ function t(){};
81
+ t.prototype = Super.prototype;
82
+ t = new t();
83
+ copy(pt,t);
84
+ Class.prototype = pt = t;
85
+ }
86
+ if(pt.constructor != Class){
87
+ if(typeof Class != 'function'){
88
+ console.error("unknown Class:"+Class)
89
+ }
90
+ pt.constructor = Class
91
+ }
92
+ }
93
+
94
+ // Node Types
95
+ var NodeType = {}
96
+ var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
97
+ var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
98
+ var TEXT_NODE = NodeType.TEXT_NODE = 3;
99
+ var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
100
+ var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
101
+ var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
102
+ var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
103
+ var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
104
+ var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
105
+ var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
106
+ var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
107
+ var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
108
+
109
+ // ExceptionCode
110
+ var ExceptionCode = {}
111
+ var ExceptionMessage = {};
112
+ var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
113
+ var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
114
+ var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
115
+ var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
116
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
117
+ var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
118
+ var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
119
+ var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
120
+ var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
121
+ var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
122
+ //level2
123
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
124
+ var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
125
+ var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
126
+ var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
127
+ var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
128
+
129
+ /**
130
+ * DOM Level 2
131
+ * Object DOMException
132
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
133
+ * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
134
+ */
135
+ function DOMException(code, message) {
136
+ if(message instanceof Error){
137
+ var error = message;
138
+ }else{
139
+ error = this;
140
+ Error.call(this, ExceptionMessage[code]);
141
+ this.message = ExceptionMessage[code];
142
+ if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
143
+ }
144
+ error.code = code;
145
+ if(message) this.message = this.message + ": " + message;
146
+ return error;
147
+ };
148
+ DOMException.prototype = Error.prototype;
149
+ copy(ExceptionCode,DOMException)
150
+
151
+ /**
152
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
153
+ * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
154
+ * The items in the NodeList are accessible via an integral index, starting from 0.
155
+ */
156
+ function NodeList() {
157
+ };
158
+ NodeList.prototype = {
159
+ /**
160
+ * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
161
+ * @standard level1
162
+ */
163
+ length:0,
164
+ /**
165
+ * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
166
+ * @standard level1
167
+ * @param index unsigned long
168
+ * Index into the collection.
169
+ * @return Node
170
+ * The node at the indexth position in the NodeList, or null if that is not a valid index.
171
+ */
172
+ item: function(index) {
173
+ return index >= 0 && index < this.length ? this[index] : null;
174
+ },
175
+ toString:function(isHTML,nodeFilter,options){
176
+ var requireWellFormed = !!options && !!options.requireWellFormed;
177
+ for(var buf = [], i = 0;i<this.length;i++){
178
+ serializeToString(this[i],buf,isHTML,nodeFilter,null,requireWellFormed);
179
+ }
180
+ return buf.join('');
181
+ },
182
+ /**
183
+ * @private
184
+ * @param {function (Node):boolean} predicate
185
+ * @returns {Node[]}
186
+ */
187
+ filter: function (predicate) {
188
+ return Array.prototype.filter.call(this, predicate);
189
+ },
190
+ /**
191
+ * @private
192
+ * @param {Node} item
193
+ * @returns {number}
194
+ */
195
+ indexOf: function (item) {
196
+ return Array.prototype.indexOf.call(this, item);
197
+ },
198
+ };
199
+
200
+ function LiveNodeList(node,refresh){
201
+ this._node = node;
202
+ this._refresh = refresh
203
+ _updateLiveList(this);
204
+ }
205
+ function _updateLiveList(list){
206
+ var inc = list._node._inc || list._node.ownerDocument._inc;
207
+ if (list._inc !== inc) {
208
+ var ls = list._refresh(list._node);
209
+ __set__(list,'length',ls.length);
210
+ if (!list.$$length || ls.length < list.$$length) {
211
+ for (var i = ls.length; i in list; i++) {
212
+ if (Object.prototype.hasOwnProperty.call(list, i)) {
213
+ delete list[i];
214
+ }
215
+ }
216
+ }
217
+ copy(ls,list);
218
+ list._inc = inc;
219
+ }
220
+ }
221
+ LiveNodeList.prototype.item = function(i){
222
+ _updateLiveList(this);
223
+ return this[i] || null;
224
+ }
225
+
226
+ _extends(LiveNodeList,NodeList);
227
+
228
+ /**
229
+ * Objects implementing the NamedNodeMap interface are used
230
+ * to represent collections of nodes that can be accessed by name.
231
+ * Note that NamedNodeMap does not inherit from NodeList;
232
+ * NamedNodeMaps are not maintained in any particular order.
233
+ * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,
234
+ * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
235
+ * and does not imply that the DOM specifies an order to these Nodes.
236
+ * NamedNodeMap objects in the DOM are live.
237
+ * used for attributes or DocumentType entities
238
+ */
239
+ function NamedNodeMap() {
240
+ // nodeName -> Attr membership index; lets the parse-time de-duplication in
241
+ // setNamedItem resolve an existing attribute in O(1) instead of scanning the
242
+ // list, so building an element with M attributes costs O(M) rather than O(M^2).
243
+ // The numbered entries and length remain the sole authority for attribute order.
244
+ // Object.create(null) so an attribute named __proto__ or constructor is an
245
+ // ordinary key.
246
+ this._nameIndex = Object.create(null);
247
+ };
248
+
249
+ function _findNodeIndex(list,node){
250
+ var i = list.length;
251
+ while(i--){
252
+ if(list[i] === node){return i}
253
+ }
254
+ }
255
+
256
+ function _nnmIndexAdd(list, attr) {
257
+ list._nameIndex[attr.nodeName] = attr;
258
+ }
259
+ function _nnmIndexRemove(list, attr) {
260
+ // Only drop the entry if it still points at this attribute; a replacement with
261
+ // a different nodeName may already have re-keyed it.
262
+ if (list._nameIndex[attr.nodeName] === attr) {
263
+ delete list._nameIndex[attr.nodeName];
264
+ }
265
+ }
266
+
267
+ function _addNamedNode(el,list,newAttr,oldAttr){
268
+ if(oldAttr){
269
+ list[_findNodeIndex(list,oldAttr)] = newAttr;
270
+ // oldAttr leaves the list; drop its index entry (its nodeName may differ
271
+ // from newAttr's when the replacement came via setNamedItemNS).
272
+ _nnmIndexRemove(list, oldAttr);
273
+ }else{
274
+ list[list.length++] = newAttr;
275
+ }
276
+ _nnmIndexAdd(list, newAttr);
277
+ if(el){
278
+ newAttr.ownerElement = el;
279
+ var doc = el.ownerDocument;
280
+ if(doc){
281
+ oldAttr && _onRemoveAttribute(doc,el,oldAttr);
282
+ _onAddAttribute(doc,el,newAttr);
283
+ }
284
+ }
285
+ }
286
+ function _removeNamedNode(el,list,attr){
287
+ //console.log('remove attr:'+attr)
288
+ var i = _findNodeIndex(list,attr);
289
+ if(i>=0){
290
+ var lastIndex = list.length-1
291
+ while(i<lastIndex){
292
+ list[i] = list[++i]
293
+ }
294
+ list.length = lastIndex;
295
+ _nnmIndexRemove(list, attr);
296
+ if(el){
297
+ var doc = el.ownerDocument;
298
+ if(doc){
299
+ _onRemoveAttribute(doc,el,attr);
300
+ attr.ownerElement = null;
301
+ }
302
+ }
303
+ }else{
304
+ throw new DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
305
+ }
306
+ }
307
+ NamedNodeMap.prototype = {
308
+ length:0,
309
+ item:NodeList.prototype.item,
310
+ getNamedItem: function(key) {
311
+ // if(key.indexOf(':')>0 || key == 'xmlns'){
312
+ // return null;
313
+ // }
314
+ //console.log()
315
+ var i = this.length;
316
+ while(i--){
317
+ var attr = this[i];
318
+ //console.log(attr.nodeName,key)
319
+ if(attr.nodeName == key){
320
+ return attr;
321
+ }
322
+ }
323
+ },
324
+ setNamedItem: function(attr) {
325
+ var el = attr.ownerElement;
326
+ if(el && el!=this._ownerElement){
327
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
328
+ }
329
+ // Resolve any existing attribute with the same nodeName through the O(1)
330
+ // membership index rather than an O(M) scan — this is the parse-dedup hot
331
+ // path (setAttributeNode per attribute during parse). Absent -> undefined,
332
+ // matching getNamedItem's contract.
333
+ var oldAttr = this._nameIndex[attr.nodeName];
334
+ _addNamedNode(this._ownerElement,this,attr,oldAttr);
335
+ return oldAttr;
336
+ },
337
+ /* returns Node */
338
+ setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
339
+ var el = attr.ownerElement, oldAttr;
340
+ if(el && el!=this._ownerElement){
341
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
342
+ }
343
+ oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
344
+ _addNamedNode(this._ownerElement,this,attr,oldAttr);
345
+ return oldAttr;
346
+ },
347
+
348
+ /* returns Node */
349
+ removeNamedItem: function(key) {
350
+ var attr = this.getNamedItem(key);
351
+ _removeNamedNode(this._ownerElement,this,attr);
352
+ return attr;
353
+
354
+
355
+ },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
356
+
357
+ //for level2
358
+ removeNamedItemNS:function(namespaceURI,localName){
359
+ var attr = this.getNamedItemNS(namespaceURI,localName);
360
+ _removeNamedNode(this._ownerElement,this,attr);
361
+ return attr;
362
+ },
363
+ getNamedItemNS: function(namespaceURI, localName) {
364
+ var i = this.length;
365
+ while(i--){
366
+ var node = this[i];
367
+ if(node.localName == localName && node.namespaceURI == namespaceURI){
368
+ return node;
369
+ }
370
+ }
371
+ return null;
372
+ }
373
+ };
374
+
375
+ /**
376
+ * The DOMImplementation interface represents an object providing methods
377
+ * which are not dependent on any particular document.
378
+ * Such an object is returned by the `Document.implementation` property.
379
+ *
380
+ * __The individual methods describe the differences compared to the specs.__
381
+ *
382
+ * @constructor
383
+ *
384
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
385
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)
386
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
387
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
388
+ * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
389
+ */
390
+ function DOMImplementation() {
391
+ }
392
+
393
+ DOMImplementation.prototype = {
394
+ /**
395
+ * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
396
+ * The different implementations fairly diverged in what kind of features were reported.
397
+ * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
398
+ *
399
+ * @deprecated It is deprecated and modern browsers return true in all cases.
400
+ *
401
+ * @param {string} feature
402
+ * @param {string} [version]
403
+ * @returns {boolean} always true
404
+ *
405
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
406
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
407
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
408
+ */
409
+ hasFeature: function(feature, version) {
410
+ return true;
411
+ },
412
+ /**
413
+ * Creates an XML Document object of the specified type with its document element.
414
+ *
415
+ * __It behaves slightly different from the description in the living standard__:
416
+ * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
417
+ * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
418
+ * - this implementation is not validating names or qualified names
419
+ * (when parsing XML strings, the SAX parser takes care of that)
420
+ *
421
+ * @param {string|null} namespaceURI
422
+ * @param {string} qualifiedName
423
+ * @param {DocumentType=null} doctype
424
+ * @returns {Document}
425
+ *
426
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
427
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
428
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
429
+ *
430
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
431
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
432
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
433
+ */
434
+ createDocument: function(namespaceURI, qualifiedName, doctype){
435
+ var doc = new Document();
436
+ doc.implementation = this;
437
+ doc.childNodes = new NodeList();
438
+ doc.doctype = doctype || null;
439
+ if (doctype){
440
+ doc.appendChild(doctype);
441
+ }
442
+ if (qualifiedName){
443
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
444
+ doc.appendChild(root);
445
+ }
446
+ return doc;
447
+ },
448
+ /**
449
+ * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
450
+ *
451
+ * __This implementation differs from the specification:__
452
+ * - this implementation is not validating names or qualified names
453
+ * (when parsing XML strings, the SAX parser takes care of that)
454
+ *
455
+ * Note: `internalSubset` can only be introduced via a direct property write to `node.internalSubset` after creation.
456
+ * Creation-time validation of `publicId`, `systemId` is not enforced.
457
+ * The serializer-level check covers all mutation vectors, including direct property writes.
458
+ * `internalSubset` is only serialized as `[ ... ]` when both `publicId` and `systemId` are
459
+ * absent (empty or `'.'`) — if either external identifier is present, `internalSubset` is
460
+ * silently omitted from the serialized output.
461
+ *
462
+ * @param {string} qualifiedName
463
+ * @param {string} [publicId]
464
+ * The external subset public identifier. Stored verbatim including surrounding quotes.
465
+ * When serialized with `requireWellFormed: true` (via the 4th-parameter options object),
466
+ * throws `DOMException` with code `INVALID_STATE_ERR` if the value is non-empty and does
467
+ * not match the XML `PubidLiteral` production (W3C DOM Parsing §3.2.1.3; XML 1.0 [12]).
468
+ * @param {string} [systemId]
469
+ * The external subset system identifier. Stored verbatim including surrounding quotes.
470
+ * When serialized with `requireWellFormed: true`, throws `DOMException` with code
471
+ * `INVALID_STATE_ERR` if the value is non-empty and does not match the XML `SystemLiteral`
472
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 [11]).
473
+ * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
474
+ * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
475
+ *
476
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
477
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
478
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
479
+ *
480
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
481
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
482
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
483
+ */
484
+ createDocumentType: function(qualifiedName, publicId, systemId){
485
+ var node = new DocumentType();
486
+ node.name = qualifiedName;
487
+ node.nodeName = qualifiedName;
488
+ node.publicId = publicId || '';
489
+ node.systemId = systemId || '';
490
+
491
+ return node;
492
+ }
493
+ };
494
+
495
+
496
+ /**
497
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
498
+ */
499
+
500
+ function Node() {
501
+ };
502
+
503
+ Node.prototype = {
504
+ firstChild : null,
505
+ lastChild : null,
506
+ previousSibling : null,
507
+ nextSibling : null,
508
+ attributes : null,
509
+ parentNode : null,
510
+ childNodes : null,
511
+ ownerDocument : null,
512
+ nodeValue : null,
513
+ namespaceURI : null,
514
+ prefix : null,
515
+ localName : null,
516
+ // Modified in DOM Level 2:
517
+ insertBefore:function(newChild, refChild){//raises
518
+ return _insertBefore(this,newChild,refChild);
519
+ },
520
+ replaceChild:function(newChild, oldChild){//raises
521
+ _insertBefore(this, newChild,oldChild, assertPreReplacementValidityInDocument);
522
+ if(oldChild){
523
+ this.removeChild(oldChild);
524
+ }
525
+ },
526
+ removeChild:function(oldChild){
527
+ return _removeChild(this,oldChild);
528
+ },
529
+ appendChild:function(newChild){
530
+ return this.insertBefore(newChild,null);
531
+ },
532
+ hasChildNodes:function(){
533
+ return this.firstChild != null;
534
+ },
535
+ cloneNode:function(deep){
536
+ return cloneNode(this.ownerDocument||this,this,deep);
537
+ },
538
+ // Modified in DOM Level 2:
539
+ /**
540
+ * Puts the specified node and all of its subtree into a "normalized" form. In a normalized
541
+ * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
542
+ *
543
+ * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
544
+ * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
545
+ * nodes.
546
+ *
547
+ * This method iteratively traverses all child nodes to normalize all descendant nodes within
548
+ * the subtree.
549
+ *
550
+ * @throws {DOMException}
551
+ * May throw a DOMException if operations within removeChild or appendData (which are
552
+ * potentially invoked in this method) do not meet their specific constraints.
553
+ * @see {@link Node.removeChild}
554
+ * @see {@link CharacterData.appendData}
555
+ * @see ../docs/walk-dom.md.
556
+ */
557
+ normalize: function () {
558
+ walkDOM(this, null, {
559
+ enter: function (node) {
560
+ // Merge adjacent text children of node before walkDOM schedules them.
561
+ // walkDOM reads lastChild/previousSibling after enter returns, so the
562
+ // surviving post-merge children are what it descends into.
563
+ var child = node.firstChild;
564
+ while (child) {
565
+ var next = child.nextSibling;
566
+ if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
567
+ // Merge the whole run of adjacent text nodes at once: gather the
568
+ // following text siblings' data, unlink them in a single pass, and
569
+ // re-index the child list a single time. Per-sibling `removeChild`
570
+ // (each an O(K) re-index) plus per-sibling `appendData` (each an O(K)
571
+ // string rebuild) is O(K^2) over a long run of single-character text
572
+ // nodes; this keeps it O(K). The first text node of the run survives
573
+ // and carries the concatenated data, preserving node identity and
574
+ // locator semantics.
575
+ var tail = [];
576
+ var sibling = next;
577
+ while (sibling !== null && sibling.nodeType === TEXT_NODE) {
578
+ tail.push(sibling.data);
579
+ sibling = sibling.nextSibling;
580
+ }
581
+ // `sibling` is now the first non-text node after the run, or null.
582
+ var removed = child.nextSibling;
583
+ while (removed !== sibling) {
584
+ var following = removed.nextSibling;
585
+ removed.parentNode = null;
586
+ removed.previousSibling = null;
587
+ removed.nextSibling = null;
588
+ removed = following;
589
+ }
590
+ child.nextSibling = sibling;
591
+ if (sibling !== null) {
592
+ sibling.previousSibling = child;
593
+ } else {
594
+ node.lastChild = child;
595
+ }
596
+ child.appendData(tail.join('')); // single O(K) string rebuild
597
+ _onUpdateChild(node.ownerDocument, node); // single O(K) re-index
598
+ child = sibling;
599
+ } else {
600
+ child = next;
601
+ }
602
+ }
603
+ return true; // descend into surviving children
604
+ },
605
+ });
606
+ },
607
+ // Introduced in DOM Level 2:
608
+ isSupported:function(feature, version){
609
+ return this.ownerDocument.implementation.hasFeature(feature,version);
610
+ },
611
+ // Introduced in DOM Level 2:
612
+ hasAttributes:function(){
613
+ return this.attributes.length>0;
614
+ },
615
+ /**
616
+ * Look up the prefix associated to the given namespace URI, starting from this node.
617
+ * **The default namespace declarations are ignored by this method.**
618
+ * See Namespace Prefix Lookup for details on the algorithm used by this method.
619
+ *
620
+ * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
621
+ *
622
+ * @param {string | null} namespaceURI
623
+ * @returns {string | null}
624
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
625
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
626
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
627
+ * @see https://github.com/xmldom/xmldom/issues/322
628
+ */
629
+ lookupPrefix:function(namespaceURI){
630
+ var el = this;
631
+ while(el){
632
+ var map = el._nsMap;
633
+ //console.dir(map)
634
+ if(map){
635
+ for(var n in map){
636
+ if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
637
+ return n;
638
+ }
639
+ }
640
+ }
641
+ el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
642
+ }
643
+ return null;
644
+ },
645
+ // Introduced in DOM Level 3:
646
+ lookupNamespaceURI:function(prefix){
647
+ var el = this;
648
+ while(el){
649
+ var map = el._nsMap;
650
+ //console.dir(map)
651
+ if(map){
652
+ if(Object.prototype.hasOwnProperty.call(map, prefix)){
653
+ return map[prefix] ;
654
+ }
655
+ }
656
+ el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
657
+ }
658
+ return null;
659
+ },
660
+ // Introduced in DOM Level 3:
661
+ isDefaultNamespace:function(namespaceURI){
662
+ var prefix = this.lookupPrefix(namespaceURI);
663
+ return prefix == null;
664
+ }
665
+ };
666
+
667
+
668
+ function _xmlEncoder(c){
669
+ return c == '<' && '&lt;' ||
670
+ c == '>' && '&gt;' ||
671
+ c == '&' && '&amp;' ||
672
+ c == '"' && '&quot;' ||
673
+ '&#'+c.charCodeAt()+';'
674
+ }
675
+
676
+
677
+ copy(NodeType,Node);
678
+ copy(NodeType,Node.prototype);
679
+
680
+ /**
681
+ * @param {Node} node
682
+ * Root of the subtree to visit.
683
+ * @param {function(Node): boolean} callback
684
+ * Called for each node in depth-first pre-order. Return a truthy value to stop traversal early.
685
+ * @return {boolean} `true` if traversal was aborted by the callback, `false` otherwise.
686
+ */
687
+ function _visitNode(node, callback) {
688
+ return walkDOM(node, null, { enter: function (n) { return callback(n) ? walkDOM.STOP : true; } }) === walkDOM.STOP;
689
+ }
690
+
691
+ /**
692
+ * Depth-first pre/post-order DOM tree walker.
693
+ *
694
+ * Visits every node in the subtree rooted at `node`. For each node:
695
+ *
696
+ * 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
697
+ * return value becomes the `context` passed to each child's `enter` call and to the matching
698
+ * `exit` call.
699
+ * 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
700
+ * sibling traversal continues normally.
701
+ * 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
702
+ * further `enter` or `exit` calls are made.
703
+ * 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
704
+ * safely modify the node's own child list before the walker descends. Modifying siblings of
705
+ * the current node or any other part of the tree produces unpredictable results: nodes already
706
+ * queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
707
+ * the current child list are never visited.
708
+ * 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
709
+ * been visited, passing the same `context` that `enter`
710
+ * returned for that node.
711
+ *
712
+ * This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
713
+ * deep trees.
714
+ *
715
+ * @param {Node} node
716
+ * Root of the subtree to walk.
717
+ * @param {*} context
718
+ * Initial context value passed to the root node's `enter`.
719
+ * @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
720
+ * @returns {void | walkDOM.STOP}
721
+ * @see ../docs/walk-dom.md.
722
+ */
723
+ function walkDOM(node, context, callbacks) {
724
+ // Each stack frame is {node, context, phase}:
725
+ // walkDOM.ENTER — call enter, then push children
726
+ // walkDOM.EXIT — call exit
727
+ var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
728
+ while (stack.length > 0) {
729
+ var frame = stack.pop();
730
+ if (frame.phase === walkDOM.ENTER) {
731
+ var childContext = callbacks.enter(frame.node, frame.context);
732
+ if (childContext === walkDOM.STOP) {
733
+ return walkDOM.STOP;
734
+ }
735
+ // Push exit frame before children so it fires after all children are processed (Last In First Out)
736
+ stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
737
+ if (childContext === null || childContext === undefined) {
738
+ continue; // skip children
739
+ }
740
+ // lastChild is read after enter returns, so enter may modify the child list.
741
+ var child = frame.node.lastChild;
742
+ // Traverse from lastChild backwards so that pushing onto the stack
743
+ // naturally yields firstChild on top (processed first).
744
+ while (child) {
745
+ stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
746
+ child = child.previousSibling;
747
+ }
748
+ } else {
749
+ // frame.phase === walkDOM.EXIT
750
+ if (callbacks.exit) {
751
+ callbacks.exit(frame.node, frame.context);
752
+ }
753
+ }
754
+ }
755
+ }
756
+
757
+ /**
758
+ * Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
759
+ * immediately.
760
+ *
761
+ * @type {symbol}
762
+ */
763
+ walkDOM.STOP = Symbol('walkDOM.STOP');
764
+ /**
765
+ * Phase constant for a stack frame that has not yet been visited.
766
+ * The `enter` callback is called and children are scheduled.
767
+ *
768
+ * @type {number}
769
+ */
770
+ walkDOM.ENTER = 0;
771
+ /**
772
+ * Phase constant for a stack frame whose subtree has been fully visited.
773
+ * The `exit` callback is called.
774
+ *
775
+ * @type {number}
776
+ */
777
+ walkDOM.EXIT = 1;
778
+
779
+ function Document(){
780
+ this.ownerDocument = this;
781
+ }
782
+
783
+ function _onAddAttribute(doc,el,newAttr){
784
+ doc && doc._inc++;
785
+ var ns = newAttr.namespaceURI ;
786
+ if(ns === NAMESPACE.XMLNS){
787
+ //update namespace
788
+ el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
789
+ }
790
+ }
791
+
792
+ function _onRemoveAttribute(doc,el,newAttr,remove){
793
+ doc && doc._inc++;
794
+ var ns = newAttr.namespaceURI ;
795
+ if(ns === NAMESPACE.XMLNS){
796
+ //update namespace
797
+ delete el._nsMap[newAttr.prefix?newAttr.localName:'']
798
+ }
799
+ }
800
+
801
+ /**
802
+ * Updates `el.childNodes`, updating the indexed items and it's `length`.
803
+ * Passing `newChild` means it will be appended.
804
+ * Otherwise it's assumed that an item has been removed,
805
+ * and `el.firstNode` and it's `.nextSibling` are used
806
+ * to walk the current list of child nodes.
807
+ *
808
+ * @param {Document} doc
809
+ * @param {Node} el
810
+ * @param {Node} [newChild]
811
+ * @private
812
+ */
813
+ function _onUpdateChild (doc, el, newChild) {
814
+ if(doc && doc._inc){
815
+ doc._inc++;
816
+ //update childNodes
817
+ var cs = el.childNodes;
818
+ if (newChild) {
819
+ cs[cs.length++] = newChild;
820
+ } else {
821
+ var child = el.firstChild;
822
+ var i = 0;
823
+ while (child) {
824
+ cs[i++] = child;
825
+ child = child.nextSibling;
826
+ }
827
+ cs.length = i;
828
+ delete cs[cs.length];
829
+ }
830
+ }
831
+ }
832
+
833
+ /**
834
+ * Removes the connections between `parentNode` and `child`
835
+ * and any existing `child.previousSibling` or `child.nextSibling`.
836
+ *
837
+ * @see https://github.com/xmldom/xmldom/issues/135
838
+ * @see https://github.com/xmldom/xmldom/issues/145
839
+ *
840
+ * @param {Node} parentNode
841
+ * @param {Node} child
842
+ * @returns {Node} the child that was removed.
843
+ * @private
844
+ */
845
+ function _removeChild (parentNode, child) {
846
+ var previous = child.previousSibling;
847
+ var next = child.nextSibling;
848
+ if (previous) {
849
+ previous.nextSibling = next;
850
+ } else {
851
+ parentNode.firstChild = next;
852
+ }
853
+ if (next) {
854
+ next.previousSibling = previous;
855
+ } else {
856
+ parentNode.lastChild = previous;
857
+ }
858
+ child.parentNode = null;
859
+ child.previousSibling = null;
860
+ child.nextSibling = null;
861
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
862
+ return child;
863
+ }
864
+
865
+ /**
866
+ * Returns `true` if `node` can be a parent for insertion.
867
+ * @param {Node} node
868
+ * @returns {boolean}
869
+ */
870
+ function hasValidParentNodeType(node) {
871
+ return (
872
+ node &&
873
+ (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)
874
+ );
875
+ }
876
+
877
+ /**
878
+ * Returns `true` if `node` can be inserted according to it's `nodeType`.
879
+ * @param {Node} node
880
+ * @returns {boolean}
881
+ */
882
+ function hasInsertableNodeType(node) {
883
+ return (
884
+ node &&
885
+ (isElementNode(node) ||
886
+ isTextNode(node) ||
887
+ isDocTypeNode(node) ||
888
+ node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
889
+ node.nodeType === Node.COMMENT_NODE ||
890
+ node.nodeType === Node.PROCESSING_INSTRUCTION_NODE)
891
+ );
892
+ }
893
+
894
+ /**
895
+ * Returns true if `node` is a DOCTYPE node
896
+ * @param {Node} node
897
+ * @returns {boolean}
898
+ */
899
+ function isDocTypeNode(node) {
900
+ return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
901
+ }
902
+
903
+ /**
904
+ * Returns true if the node is an element
905
+ * @param {Node} node
906
+ * @returns {boolean}
907
+ */
908
+ function isElementNode(node) {
909
+ return node && node.nodeType === Node.ELEMENT_NODE;
910
+ }
911
+ /**
912
+ * Returns true if `node` is a text node
913
+ * @param {Node} node
914
+ * @returns {boolean}
915
+ */
916
+ function isTextNode(node) {
917
+ return node && node.nodeType === Node.TEXT_NODE;
918
+ }
919
+
920
+ /**
921
+ * Check if en element node can be inserted before `child`, or at the end if child is falsy,
922
+ * according to the presence and position of a doctype node on the same level.
923
+ *
924
+ * @param {Document} doc The document node
925
+ * @param {Node} child the node that would become the nextSibling if the element would be inserted
926
+ * @returns {boolean} `true` if an element can be inserted before child
927
+ * @private
928
+ * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
929
+ */
930
+ function isElementInsertionPossible(doc, child) {
931
+ var parentChildNodes = doc.childNodes || [];
932
+ if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
933
+ return false;
934
+ }
935
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
936
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
937
+ }
938
+
939
+ /**
940
+ * Check if en element node can be inserted before `child`, or at the end if child is falsy,
941
+ * according to the presence and position of a doctype node on the same level.
942
+ *
943
+ * @param {Node} doc The document node
944
+ * @param {Node} child the node that would become the nextSibling if the element would be inserted
945
+ * @returns {boolean} `true` if an element can be inserted before child
946
+ * @private
947
+ * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
948
+ */
949
+ function isElementReplacementPossible(doc, child) {
950
+ var parentChildNodes = doc.childNodes || [];
951
+
952
+ function hasElementChildThatIsNotChild(node) {
953
+ return isElementNode(node) && node !== child;
954
+ }
955
+
956
+ if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
957
+ return false;
958
+ }
959
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
960
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
961
+ }
962
+
963
+ /**
964
+ * @private
965
+ * Steps 1-5 of the checks before inserting and before replacing a child are the same.
966
+ *
967
+ * @param {Node} parent the parent node to insert `node` into
968
+ * @param {Node} node the node to insert
969
+ * @param {Node=} child the node that should become the `nextSibling` of `node`
970
+ * @returns {Node}
971
+ * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
972
+ * @throws DOMException if `child` is provided but is not a child of `parent`.
973
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
974
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
975
+ */
976
+ function assertPreInsertionValidity1to5(parent, node, child) {
977
+ // 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
978
+ if (!hasValidParentNodeType(parent)) {
979
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);
980
+ }
981
+ // 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a "HierarchyRequestError" DOMException.
982
+ // not implemented!
983
+ // 3. If `child` is non-null and its parent is not `parent`, then throw a "NotFoundError" DOMException.
984
+ if (child && child.parentNode !== parent) {
985
+ throw new DOMException(NOT_FOUND_ERR, 'child not in parent');
986
+ }
987
+ if (
988
+ // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
989
+ !hasInsertableNodeType(node) ||
990
+ // 5. If either `node` is a Text node and `parent` is a document,
991
+ // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
992
+ // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
993
+ // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
994
+ (isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)
995
+ ) {
996
+ throw new DOMException(
997
+ HIERARCHY_REQUEST_ERR,
998
+ 'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType
999
+ );
1000
+ }
1001
+ }
1002
+
1003
+ /**
1004
+ * @private
1005
+ * Step 6 of the checks before inserting and before replacing a child are different.
1006
+ *
1007
+ * @param {Document} parent the parent node to insert `node` into
1008
+ * @param {Node} node the node to insert
1009
+ * @param {Node | undefined} child the node that should become the `nextSibling` of `node`
1010
+ * @returns {Node}
1011
+ * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
1012
+ * @throws DOMException if `child` is provided but is not a child of `parent`.
1013
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
1014
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
1015
+ */
1016
+ function assertPreInsertionValidityInDocument(parent, node, child) {
1017
+ var parentChildNodes = parent.childNodes || [];
1018
+ var nodeChildNodes = node.childNodes || [];
1019
+
1020
+ // DocumentFragment
1021
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
1022
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
1023
+ // If node has more than one element child or has a Text node child.
1024
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
1025
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
1026
+ }
1027
+ // Otherwise, if `node` has one element child and either `parent` has an element child,
1028
+ // `child` is a doctype, or `child` is non-null and a doctype is following `child`.
1029
+ if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
1030
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
1031
+ }
1032
+ }
1033
+ // Element
1034
+ if (isElementNode(node)) {
1035
+ // `parent` has an element child, `child` is a doctype,
1036
+ // or `child` is non-null and a doctype is following `child`.
1037
+ if (!isElementInsertionPossible(parent, child)) {
1038
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
1039
+ }
1040
+ }
1041
+ // DocumentType
1042
+ if (isDocTypeNode(node)) {
1043
+ // `parent` has a doctype child,
1044
+ if (find(parentChildNodes, isDocTypeNode)) {
1045
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
1046
+ }
1047
+ var parentElementChild = find(parentChildNodes, isElementNode);
1048
+ // `child` is non-null and an element is preceding `child`,
1049
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
1050
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
1051
+ }
1052
+ // or `child` is null and `parent` has an element child.
1053
+ if (!child && parentElementChild) {
1054
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+ /**
1060
+ * @private
1061
+ * Step 6 of the checks before inserting and before replacing a child are different.
1062
+ *
1063
+ * @param {Document} parent the parent node to insert `node` into
1064
+ * @param {Node} node the node to insert
1065
+ * @param {Node | undefined} child the node that should become the `nextSibling` of `node`
1066
+ * @returns {Node}
1067
+ * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
1068
+ * @throws DOMException if `child` is provided but is not a child of `parent`.
1069
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
1070
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
1071
+ */
1072
+ function assertPreReplacementValidityInDocument(parent, node, child) {
1073
+ var parentChildNodes = parent.childNodes || [];
1074
+ var nodeChildNodes = node.childNodes || [];
1075
+
1076
+ // DocumentFragment
1077
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
1078
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
1079
+ // If `node` has more than one element child or has a Text node child.
1080
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
1081
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
1082
+ }
1083
+ // Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.
1084
+ if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
1085
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
1086
+ }
1087
+ }
1088
+ // Element
1089
+ if (isElementNode(node)) {
1090
+ // `parent` has an element child that is not `child` or a doctype is following `child`.
1091
+ if (!isElementReplacementPossible(parent, child)) {
1092
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
1093
+ }
1094
+ }
1095
+ // DocumentType
1096
+ if (isDocTypeNode(node)) {
1097
+ function hasDoctypeChildThatIsNotChild(node) {
1098
+ return isDocTypeNode(node) && node !== child;
1099
+ }
1100
+
1101
+ // `parent` has a doctype child that is not `child`,
1102
+ if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {
1103
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
1104
+ }
1105
+ var parentElementChild = find(parentChildNodes, isElementNode);
1106
+ // or an element is preceding `child`.
1107
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
1108
+ throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ /**
1114
+ * @private
1115
+ * @param {Node} parent the parent node to insert `node` into
1116
+ * @param {Node} node the node to insert
1117
+ * @param {Node=} child the node that should become the `nextSibling` of `node`
1118
+ * @returns {Node}
1119
+ * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
1120
+ * @throws DOMException if `child` is provided but is not a child of `parent`.
1121
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
1122
+ */
1123
+ function _insertBefore(parent, node, child, _inDocumentAssertion) {
1124
+ // To ensure pre-insertion validity of a node into a parent before a child, run these steps:
1125
+ assertPreInsertionValidity1to5(parent, node, child);
1126
+
1127
+ // If parent is a document, and any of the statements below, switched on the interface node implements,
1128
+ // are true, then throw a "HierarchyRequestError" DOMException.
1129
+ if (parent.nodeType === Node.DOCUMENT_NODE) {
1130
+ (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
1131
+ }
1132
+
1133
+ var cp = node.parentNode;
1134
+ if(cp){
1135
+ cp.removeChild(node);//remove and update
1136
+ }
1137
+ if(node.nodeType === DOCUMENT_FRAGMENT_NODE){
1138
+ var newFirst = node.firstChild;
1139
+ if (newFirst == null) {
1140
+ return node;
1141
+ }
1142
+ var newLast = node.lastChild;
1143
+ }else{
1144
+ newFirst = newLast = node;
1145
+ }
1146
+ var pre = child ? child.previousSibling : parent.lastChild;
1147
+
1148
+ newFirst.previousSibling = pre;
1149
+ newLast.nextSibling = child;
1150
+
1151
+
1152
+ if(pre){
1153
+ pre.nextSibling = newFirst;
1154
+ }else{
1155
+ parent.firstChild = newFirst;
1156
+ }
1157
+ if(child == null){
1158
+ parent.lastChild = newLast;
1159
+ }else{
1160
+ child.previousSibling = newLast;
1161
+ }
1162
+ do{
1163
+ newFirst.parentNode = parent;
1164
+ // Update ownerDocument for each node being inserted
1165
+ var targetDoc = parent.ownerDocument || parent;
1166
+ _updateOwnerDocument(newFirst, targetDoc);
1167
+ }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
1168
+ _onUpdateChild(parent.ownerDocument||parent, parent);
1169
+ //console.log(parent.lastChild.nextSibling == null)
1170
+ if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
1171
+ node.firstChild = node.lastChild = null;
1172
+ }
1173
+ return node;
1174
+ }
1175
+
1176
+ /**
1177
+ * Recursively updates the ownerDocument property for a node and all its descendants
1178
+ * @param {Node} node
1179
+ * @param {Document} newOwnerDocument
1180
+ * @private
1181
+ */
1182
+ function _updateOwnerDocument(node, newOwnerDocument) {
1183
+ if (node.ownerDocument === newOwnerDocument) {
1184
+ return;
1185
+ }
1186
+
1187
+ node.ownerDocument = newOwnerDocument;
1188
+
1189
+ // Update attributes if this is an element
1190
+ if (node.nodeType === ELEMENT_NODE && node.attributes) {
1191
+ for (var i = 0; i < node.attributes.length; i++) {
1192
+ var attr = node.attributes.item(i);
1193
+ if (attr) {
1194
+ attr.ownerDocument = newOwnerDocument;
1195
+ }
1196
+ }
1197
+ }
1198
+
1199
+ // Recursively update child nodes
1200
+ var child = node.firstChild;
1201
+ while (child) {
1202
+ _updateOwnerDocument(child, newOwnerDocument);
1203
+ child = child.nextSibling;
1204
+ }
1205
+ }
1206
+
1207
+ /**
1208
+ * Appends `newChild` to `parentNode`.
1209
+ * If `newChild` is already connected to a `parentNode` it is first removed from it.
1210
+ *
1211
+ * @see https://github.com/xmldom/xmldom/issues/135
1212
+ * @see https://github.com/xmldom/xmldom/issues/145
1213
+ * @param {Node} parentNode
1214
+ * @param {Node} newChild
1215
+ * @returns {Node}
1216
+ * @private
1217
+ */
1218
+ function _appendSingleChild (parentNode, newChild) {
1219
+ if (newChild.parentNode) {
1220
+ newChild.parentNode.removeChild(newChild);
1221
+ }
1222
+ newChild.parentNode = parentNode;
1223
+ newChild.previousSibling = parentNode.lastChild;
1224
+ newChild.nextSibling = null;
1225
+ if (newChild.previousSibling) {
1226
+ newChild.previousSibling.nextSibling = newChild;
1227
+ } else {
1228
+ parentNode.firstChild = newChild;
1229
+ }
1230
+ parentNode.lastChild = newChild;
1231
+ _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
1232
+
1233
+ // Update ownerDocument for the new child and all its descendants
1234
+ var targetDoc = parentNode.ownerDocument || parentNode;
1235
+ _updateOwnerDocument(newChild, targetDoc);
1236
+
1237
+ return newChild;
1238
+ }
1239
+
1240
+ Document.prototype = {
1241
+ //implementation : null,
1242
+ nodeName : '#document',
1243
+ nodeType : DOCUMENT_NODE,
1244
+ /**
1245
+ * The DocumentType node of the document.
1246
+ *
1247
+ * @readonly
1248
+ * @type DocumentType
1249
+ */
1250
+ doctype : null,
1251
+ documentElement : null,
1252
+ _inc : 1,
1253
+
1254
+ insertBefore : function(newChild, refChild){//raises
1255
+ if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
1256
+ var child = newChild.firstChild;
1257
+ while(child){
1258
+ var next = child.nextSibling;
1259
+ this.insertBefore(child,refChild);
1260
+ child = next;
1261
+ }
1262
+ return newChild;
1263
+ }
1264
+ _insertBefore(this, newChild, refChild);
1265
+ _updateOwnerDocument(newChild, this);
1266
+ if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
1267
+ this.documentElement = newChild;
1268
+ }
1269
+
1270
+ return newChild;
1271
+ },
1272
+ removeChild : function(oldChild){
1273
+ if(this.documentElement == oldChild){
1274
+ this.documentElement = null;
1275
+ }
1276
+ return _removeChild(this,oldChild);
1277
+ },
1278
+ replaceChild: function (newChild, oldChild) {
1279
+ //raises
1280
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
1281
+ _updateOwnerDocument(newChild, this);
1282
+ if (oldChild) {
1283
+ this.removeChild(oldChild);
1284
+ }
1285
+ if (isElementNode(newChild)) {
1286
+ this.documentElement = newChild;
1287
+ }
1288
+ },
1289
+ // Introduced in DOM Level 2:
1290
+ importNode : function(importedNode,deep){
1291
+ return importNode(this,importedNode,deep);
1292
+ },
1293
+ // Introduced in DOM Level 2:
1294
+ getElementById : function(id){
1295
+ var rtv = null;
1296
+ _visitNode(this.documentElement,function(node){
1297
+ if(node.nodeType == ELEMENT_NODE){
1298
+ if(node.getAttribute('id') == id){
1299
+ rtv = node;
1300
+ return true;
1301
+ }
1302
+ }
1303
+ })
1304
+ return rtv;
1305
+ },
1306
+
1307
+ /**
1308
+ * The `getElementsByClassName` method of `Document` interface returns an array-like object
1309
+ * of all child elements which have **all** of the given class name(s).
1310
+ *
1311
+ * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
1312
+ *
1313
+ *
1314
+ * Warning: This is a live LiveNodeList.
1315
+ * Changes in the DOM will reflect in the array as the changes occur.
1316
+ * If an element selected by this array no longer qualifies for the selector,
1317
+ * it will automatically be removed. Be aware of this for iteration purposes.
1318
+ *
1319
+ * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
1320
+ *
1321
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
1322
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
1323
+ */
1324
+ getElementsByClassName: function(classNames) {
1325
+ var classNamesSet = toOrderedSet(classNames)
1326
+ return new LiveNodeList(this, function(base) {
1327
+ var ls = [];
1328
+ if (classNamesSet.length > 0) {
1329
+ _visitNode(base.documentElement, function(node) {
1330
+ if(node !== base && node.nodeType === ELEMENT_NODE) {
1331
+ var nodeClassNames = node.getAttribute('class')
1332
+ // can be null if the attribute does not exist
1333
+ if (nodeClassNames) {
1334
+ // before splitting and iterating just compare them for the most common case
1335
+ var matches = classNames === nodeClassNames;
1336
+ if (!matches) {
1337
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames)
1338
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet))
1339
+ }
1340
+ if(matches) {
1341
+ ls.push(node);
1342
+ }
1343
+ }
1344
+ }
1345
+ });
1346
+ }
1347
+ return ls;
1348
+ });
1349
+ },
1350
+
1351
+ //document factory method:
1352
+ createElement : function(tagName){
1353
+ var node = new Element();
1354
+ node.ownerDocument = this;
1355
+ node.nodeName = tagName;
1356
+ node.tagName = tagName;
1357
+ node.localName = tagName;
1358
+ node.childNodes = new NodeList();
1359
+ var attrs = node.attributes = new NamedNodeMap();
1360
+ attrs._ownerElement = node;
1361
+ return node;
1362
+ },
1363
+ createDocumentFragment : function(){
1364
+ var node = new DocumentFragment();
1365
+ node.ownerDocument = this;
1366
+ node.childNodes = new NodeList();
1367
+ return node;
1368
+ },
1369
+ createTextNode : function(data){
1370
+ var node = new Text();
1371
+ node.ownerDocument = this;
1372
+ node.appendData(data)
1373
+ return node;
1374
+ },
1375
+ createComment : function(data){
1376
+ var node = new Comment();
1377
+ node.ownerDocument = this;
1378
+ node.appendData(data)
1379
+ return node;
1380
+ },
1381
+ /**
1382
+ * Returns a new CDATASection node whose data is `data`.
1383
+ *
1384
+ * __This implementation differs from the specification:__
1385
+ * - calling this method on an HTML document does not throw `NotSupportedError`.
1386
+ *
1387
+ * @param {string} data
1388
+ * @returns {CDATASection}
1389
+ * @throws DOMException with code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
1390
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
1391
+ * @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
1392
+ */
1393
+ createCDATASection : function(data){
1394
+ if (data.indexOf(']]>') !== -1) {
1395
+ throw new DOMException(INVALID_CHARACTER_ERR, 'data contains "]]>"');
1396
+ }
1397
+ var node = new CDATASection();
1398
+ node.ownerDocument = this;
1399
+ node.appendData(data)
1400
+ return node;
1401
+ },
1402
+ /**
1403
+ * Returns a ProcessingInstruction node whose target is target and data is data.
1404
+ *
1405
+ * __This implementation differs from the specification:__
1406
+ * - it does not do any input validation on the arguments and doesn't throw "InvalidCharacterError".
1407
+ *
1408
+ * Note: When the resulting document is serialized with `requireWellFormed: true`, the
1409
+ * serializer throws with code `INVALID_STATE_ERR` if `.target` is not a valid XML `NCName`
1410
+ * (a `Name` with no colon) or is an ASCII case-insensitive match for `"xml"`, or if `.data`
1411
+ * contains `?>` (W3C DOM Parsing §3.2.1.7). Without that option the target and data are
1412
+ * emitted verbatim.
1413
+ *
1414
+ * @param {string} target
1415
+ * @param {string} data
1416
+ * @returns {ProcessingInstruction}
1417
+ * @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
1418
+ * @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
1419
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
1420
+ */
1421
+ createProcessingInstruction : function(target,data){
1422
+ var node = new ProcessingInstruction();
1423
+ node.ownerDocument = this;
1424
+ node.tagName = node.nodeName = node.target = target;
1425
+ node.nodeValue = node.data = data;
1426
+ return node;
1427
+ },
1428
+ createAttribute : function(name){
1429
+ var node = new Attr();
1430
+ node.ownerDocument = this;
1431
+ node.name = name;
1432
+ node.nodeName = name;
1433
+ node.localName = name;
1434
+ node.specified = true;
1435
+ return node;
1436
+ },
1437
+ /**
1438
+ * Creates an EntityReference object, serialized as `&name;`.
1439
+ *
1440
+ * The `name` is validated against the XML `Name` production at creation time; an invalid name
1441
+ * throws a `DOMException` with code `INVALID_CHARACTER_ERR`. When the resulting node is
1442
+ * serialized with `requireWellFormed: true`, the serializer re-validates `nodeName` and throws
1443
+ * a `DOMException` with code `INVALID_STATE_ERR` if a later `nodeName` mutation made it invalid;
1444
+ * without that option the name is emitted verbatim.
1445
+ *
1446
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
1447
+ * constructs `EntityReference` nodes, so this method is the only producer.
1448
+ *
1449
+ * @param {string} name The name of the entity to reference.
1450
+ * @returns {EntityReference}
1451
+ * @throws {DOMException} With code `INVALID_CHARACTER_ERR` when `name` is not a valid XML `Name`.
1452
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
1453
+ */
1454
+ createEntityReference : function(name){
1455
+ if (!tagNamePattern.test(name)) {
1456
+ throw new DOMException(INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
1457
+ }
1458
+ var node = new EntityReference();
1459
+ node.ownerDocument = this;
1460
+ node.nodeName = name;
1461
+ return node;
1462
+ },
1463
+ // Introduced in DOM Level 2:
1464
+ createElementNS : function(namespaceURI,qualifiedName){
1465
+ var node = new Element();
1466
+ var pl = qualifiedName.split(':');
1467
+ var attrs = node.attributes = new NamedNodeMap();
1468
+ node.childNodes = new NodeList();
1469
+ node.ownerDocument = this;
1470
+ node.nodeName = qualifiedName;
1471
+ node.tagName = qualifiedName;
1472
+ node.namespaceURI = namespaceURI;
1473
+ if(pl.length == 2){
1474
+ node.prefix = pl[0];
1475
+ node.localName = pl[1];
1476
+ }else{
1477
+ //el.prefix = null;
1478
+ node.localName = qualifiedName;
1479
+ }
1480
+ attrs._ownerElement = node;
1481
+ return node;
1482
+ },
1483
+ // Introduced in DOM Level 2:
1484
+ createAttributeNS : function(namespaceURI,qualifiedName){
1485
+ var node = new Attr();
1486
+ var pl = qualifiedName.split(':');
1487
+ node.ownerDocument = this;
1488
+ node.nodeName = qualifiedName;
1489
+ node.name = qualifiedName;
1490
+ node.namespaceURI = namespaceURI;
1491
+ node.specified = true;
1492
+ if(pl.length == 2){
1493
+ node.prefix = pl[0];
1494
+ node.localName = pl[1];
1495
+ }else{
1496
+ //el.prefix = null;
1497
+ node.localName = qualifiedName;
1498
+ }
1499
+ return node;
1500
+ }
1501
+ };
1502
+ _extends(Document,Node);
1503
+
1504
+
1505
+ function Element() {
1506
+ this._nsMap = {};
1507
+ };
1508
+ Element.prototype = {
1509
+ nodeType : ELEMENT_NODE,
1510
+ hasAttribute : function(name){
1511
+ return this.getAttributeNode(name)!=null;
1512
+ },
1513
+ getAttribute : function(name){
1514
+ var attr = this.getAttributeNode(name);
1515
+ return attr && attr.value || '';
1516
+ },
1517
+ getAttributeNode : function(name){
1518
+ return this.attributes.getNamedItem(name);
1519
+ },
1520
+ setAttribute : function(name, value){
1521
+ var attr = this.ownerDocument.createAttribute(name);
1522
+ attr.value = attr.nodeValue = "" + value;
1523
+ this.setAttributeNode(attr)
1524
+ },
1525
+ removeAttribute : function(name){
1526
+ var attr = this.getAttributeNode(name)
1527
+ attr && this.removeAttributeNode(attr);
1528
+ },
1529
+
1530
+ //four real opeartion method
1531
+ appendChild:function(newChild){
1532
+ if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
1533
+ return this.insertBefore(newChild,null);
1534
+ }else{
1535
+ return _appendSingleChild(this,newChild);
1536
+ }
1537
+ },
1538
+ setAttributeNode : function(newAttr){
1539
+ return this.attributes.setNamedItem(newAttr);
1540
+ },
1541
+ setAttributeNodeNS : function(newAttr){
1542
+ return this.attributes.setNamedItemNS(newAttr);
1543
+ },
1544
+ removeAttributeNode : function(oldAttr){
1545
+ //console.log(this == oldAttr.ownerElement)
1546
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
1547
+ },
1548
+ //get real attribute name,and remove it by removeAttributeNode
1549
+ removeAttributeNS : function(namespaceURI, localName){
1550
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
1551
+ old && this.removeAttributeNode(old);
1552
+ },
1553
+
1554
+ hasAttributeNS : function(namespaceURI, localName){
1555
+ return this.getAttributeNodeNS(namespaceURI, localName)!=null;
1556
+ },
1557
+ getAttributeNS : function(namespaceURI, localName){
1558
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
1559
+ return attr && attr.value || '';
1560
+ },
1561
+ setAttributeNS : function(namespaceURI, qualifiedName, value){
1562
+ var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
1563
+ attr.value = attr.nodeValue = "" + value;
1564
+ this.setAttributeNode(attr)
1565
+ },
1566
+ getAttributeNodeNS : function(namespaceURI, localName){
1567
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
1568
+ },
1569
+
1570
+ getElementsByTagName : function(tagName){
1571
+ return new LiveNodeList(this,function(base){
1572
+ var ls = [];
1573
+ _visitNode(base,function(node){
1574
+ if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
1575
+ ls.push(node);
1576
+ }
1577
+ });
1578
+ return ls;
1579
+ });
1580
+ },
1581
+ getElementsByTagNameNS : function(namespaceURI, localName){
1582
+ return new LiveNodeList(this,function(base){
1583
+ var ls = [];
1584
+ _visitNode(base,function(node){
1585
+ if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
1586
+ ls.push(node);
1587
+ }
1588
+ });
1589
+ return ls;
1590
+
1591
+ });
1592
+ }
1593
+ };
1594
+ Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
1595
+ Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
1596
+
1597
+
1598
+ _extends(Element,Node);
1599
+ function Attr() {
1600
+ };
1601
+ Attr.prototype.nodeType = ATTRIBUTE_NODE;
1602
+ _extends(Attr,Node);
1603
+
1604
+
1605
+ function CharacterData() {
1606
+ };
1607
+ CharacterData.prototype = {
1608
+ data : '',
1609
+ substringData : function(offset, count) {
1610
+ return this.data.substring(offset, offset+count);
1611
+ },
1612
+ appendData: function(text) {
1613
+ text = this.data+text;
1614
+ this.nodeValue = this.data = text;
1615
+ this.length = text.length;
1616
+ },
1617
+ insertData: function(offset,text) {
1618
+ this.replaceData(offset,0,text);
1619
+
1620
+ },
1621
+ appendChild:function(newChild){
1622
+ throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
1623
+ },
1624
+ deleteData: function(offset, count) {
1625
+ this.replaceData(offset,count,"");
1626
+ },
1627
+ replaceData: function(offset, count, text) {
1628
+ var start = this.data.substring(0,offset);
1629
+ var end = this.data.substring(offset+count);
1630
+ text = start + text + end;
1631
+ this.nodeValue = this.data = text;
1632
+ this.length = text.length;
1633
+ }
1634
+ }
1635
+ _extends(CharacterData,Node);
1636
+ function Text() {
1637
+ };
1638
+ Text.prototype = {
1639
+ nodeName : "#text",
1640
+ nodeType : TEXT_NODE,
1641
+ splitText : function(offset) {
1642
+ var text = this.data;
1643
+ var newText = text.substring(offset);
1644
+ text = text.substring(0, offset);
1645
+ this.data = this.nodeValue = text;
1646
+ this.length = text.length;
1647
+ var newNode = this.ownerDocument.createTextNode(newText);
1648
+ if(this.parentNode){
1649
+ this.parentNode.insertBefore(newNode, this.nextSibling);
1650
+ }
1651
+ return newNode;
1652
+ }
1653
+ }
1654
+ _extends(Text,CharacterData);
1655
+ function Comment() {
1656
+ };
1657
+ Comment.prototype = {
1658
+ nodeName : "#comment",
1659
+ nodeType : COMMENT_NODE
1660
+ }
1661
+ _extends(Comment,CharacterData);
1662
+
1663
+ function CDATASection() {
1664
+ };
1665
+ CDATASection.prototype = {
1666
+ nodeName : "#cdata-section",
1667
+ nodeType : CDATA_SECTION_NODE
1668
+ }
1669
+ _extends(CDATASection,CharacterData);
1670
+
1671
+
1672
+ /**
1673
+ * Represents a DocumentType node (the `<!DOCTYPE ...>` declaration).
1674
+ *
1675
+ * `name`, `publicId`, `systemId`, and `internalSubset` are plain own-property assignments.
1676
+ * xmldom does not enforce the `readonly` constraint declared by the WHATWG DOM spec —
1677
+ * direct property writes succeed silently. Values are serialized verbatim when
1678
+ * `requireWellFormed` is false (the default). When the serializer is invoked with
1679
+ * `requireWellFormed: true` (via the 4th-parameter options object), it validates each
1680
+ * field — including `name`, which is checked against the XML `Name` production — and throws
1681
+ * `DOMException` with code `INVALID_STATE_ERR` on invalid values.
1682
+ *
1683
+ * @class
1684
+ * @see https://developer.mozilla.org/docs/Web/API/DocumentType MDN
1685
+ */
1686
+ function DocumentType() {
1687
+ };
1688
+ DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
1689
+ _extends(DocumentType,Node);
1690
+
1691
+ function Notation() {
1692
+ };
1693
+ Notation.prototype.nodeType = NOTATION_NODE;
1694
+ _extends(Notation,Node);
1695
+
1696
+ function Entity() {
1697
+ };
1698
+ Entity.prototype.nodeType = ENTITY_NODE;
1699
+ _extends(Entity,Node);
1700
+
1701
+ /**
1702
+ * Represents an EntityReference node, serialized as `&nodeName;`.
1703
+ *
1704
+ * `nodeName` is the referenced entity's name, stored verbatim. When serialized with
1705
+ * `requireWellFormed: true`, the serializer validates `nodeName` against the XML `Name` production
1706
+ * and throws a `DOMException` with code `INVALID_STATE_ERR` if it does not match; without that
1707
+ * option the name is emitted verbatim between `&` and `;`.
1708
+ *
1709
+ * Note: xmldom does not expand entities — the parser resolves entity references inline and never
1710
+ * constructs `EntityReference` nodes, so the only producer is `Document.createEntityReference`.
1711
+ *
1712
+ * @class
1713
+ * @see https://www.w3.org/TR/xml/#NT-Name
1714
+ */
1715
+ function EntityReference() {
1716
+ };
1717
+ EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
1718
+ _extends(EntityReference,Node);
1719
+
1720
+ function DocumentFragment() {
1721
+ };
1722
+ DocumentFragment.prototype.nodeName = "#document-fragment";
1723
+ DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
1724
+ _extends(DocumentFragment,Node);
1725
+
1726
+
1727
+ function ProcessingInstruction() {
1728
+ }
1729
+ ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
1730
+ _extends(ProcessingInstruction,Node);
1731
+ function XMLSerializer(){}
1732
+ /**
1733
+ * Returns the result of serializing `node` to XML.
1734
+ *
1735
+ * When `options.requireWellFormed` is `true`, the serializer throws for content that would
1736
+ * produce ill-formed XML.
1737
+ *
1738
+ * __This implementation differs from the specification:__
1739
+ * - CDATASection nodes whose data contains `]]>` are serialized by splitting the section
1740
+ * at each `]]>` occurrence (following W3C DOM Level 3 Core `split-cdata-sections`
1741
+ * default behaviour) unless `requireWellFormed` is `true`.
1742
+ * - when `requireWellFormed` is `true`, `DOMException` with code `INVALID_STATE_ERR`
1743
+ * is only thrown to prevent injection vectors, not for all the spec mandated checks.
1744
+ *
1745
+ * @param {Node} node
1746
+ * @param {boolean} [isHtml]
1747
+ * @param {function} [nodeFilter]
1748
+ * @param {Object} [options]
1749
+ * @param {boolean} [options.requireWellFormed=false]
1750
+ * When `true`, throws for content that would produce ill-formed XML.
1751
+ * @returns {string}
1752
+ * @throws {DOMException}
1753
+ * With code `INVALID_STATE_ERR` when `requireWellFormed` is `true` and:
1754
+ * - an Element's qualified name (including any namespace prefix) is not a valid XML QName,
1755
+ * - an attribute's qualified name (including a synthesized `xmlns:` namespace declaration) is
1756
+ * not a valid XML QName,
1757
+ * - a CDATASection node's data contains `"]]>"`,
1758
+ * - a Comment node's data contains `"-->"` (bare `"--"` does not throw on this branch),
1759
+ * - a ProcessingInstruction's target is not a valid XML `NCName` (a `Name` with no colon) or is
1760
+ * an ASCII case-insensitive match for `"xml"`, or its data contains `"?>"`,
1761
+ * - a DocumentType's `name` is not a valid XML `Name` (XML 1.0 production [5]),
1762
+ * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
1763
+ * production,
1764
+ * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
1765
+ * production,
1766
+ * - a DocumentType's `internalSubset` contains `"]>"`, or
1767
+ * - an EntityReference's `nodeName` is not a valid XML `Name` (XML 1.0 production [5]).
1768
+ * Note: xmldom does not enforce `readonly` on DocumentType fields — direct property
1769
+ * writes succeed and are covered by the serializer-level checks above.
1770
+ * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
1771
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serialization
1772
+ * @see https://github.com/w3c/DOM-Parsing/issues/84
1773
+ */
1774
+ XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter,options){
1775
+ return nodeSerializeToString.call(node,isHtml,nodeFilter,options);
1776
+ }
1777
+ Node.prototype.toString = nodeSerializeToString;
1778
+ function nodeSerializeToString(isHtml,nodeFilter,options){
1779
+ var requireWellFormed = !!options && !!options.requireWellFormed;
1780
+ var buf = [];
1781
+ var refNode = this.nodeType == 9 && this.documentElement || this;
1782
+ var prefix = refNode.prefix;
1783
+ var uri = refNode.namespaceURI;
1784
+
1785
+ if(uri && prefix == null){
1786
+ //console.log(prefix)
1787
+ var prefix = refNode.lookupPrefix(uri);
1788
+ if(prefix == null){
1789
+ //isHTML = true;
1790
+ var visibleNamespaces=[
1791
+ {namespace:uri,prefix:null}
1792
+ //{namespace:uri,prefix:''}
1793
+ ]
1794
+ }
1795
+ }
1796
+ serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces,requireWellFormed);
1797
+ //console.log('###',this.nodeType,uri,prefix,buf.join(''))
1798
+ return buf.join('');
1799
+ }
1800
+
1801
+ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
1802
+ var prefix = node.prefix || '';
1803
+ var uri = node.namespaceURI;
1804
+ // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
1805
+ // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
1806
+ // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
1807
+ // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
1808
+ // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
1809
+ // > [...] Furthermore, the attribute value [...] must not be an empty string.
1810
+ // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
1811
+ if (!uri) {
1812
+ return false;
1813
+ }
1814
+ if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
1815
+ return false;
1816
+ }
1817
+
1818
+ var i = visibleNamespaces.length
1819
+ while (i--) {
1820
+ var ns = visibleNamespaces[i];
1821
+ // get namespace prefix
1822
+ if (ns.prefix === prefix) {
1823
+ return ns.namespace !== uri;
1824
+ }
1825
+ }
1826
+ return true;
1827
+ }
1828
+ /**
1829
+ * Well-formed constraint: No < in Attribute Values
1830
+ * > The replacement text of any entity referred to directly or indirectly
1831
+ * > in an attribute value must not contain a <.
1832
+ * @see https://www.w3.org/TR/xml11/#CleanAttrVals
1833
+ * @see https://www.w3.org/TR/xml11/#NT-AttValue
1834
+ *
1835
+ * Literal whitespace other than space that appear in attribute values
1836
+ * are serialized as their entity references, so they will be preserved.
1837
+ * (In contrast to whitespace literals in the input which are normalized to spaces)
1838
+ * @see https://www.w3.org/TR/xml11/#AVNormalize
1839
+ * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
1840
+ */
1841
+ function addSerializedAttribute(buf, qualifiedName, value, requireWellFormed) {
1842
+ if (requireWellFormed && !tagNamePattern.test(qualifiedName)) {
1843
+ throw new DOMException(INVALID_STATE_ERR, 'The attribute name "' + qualifiedName + '" is not a valid XML QName');
1844
+ }
1845
+ buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"')
1846
+ }
1847
+
1848
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces, requireWellFormed) {
1849
+ if (!visibleNamespaces) {
1850
+ visibleNamespaces = [];
1851
+ }
1852
+ walkDOM(node, { ns: visibleNamespaces, isHTML: isHTML }, {
1853
+ enter: function (n, ctx) {
1854
+ var ns = ctx.ns;
1855
+ var html = ctx.isHTML;
1856
+
1857
+ if (nodeFilter) {
1858
+ n = nodeFilter(n);
1859
+ if (n) {
1860
+ if (typeof n == 'string') {
1861
+ buf.push(n);
1862
+ return null;
1863
+ }
1864
+ } else {
1865
+ return null;
1866
+ }
1867
+ }
1868
+
1869
+ switch (n.nodeType) {
1870
+ case ELEMENT_NODE:
1871
+ var attrs = n.attributes;
1872
+ var len = attrs.length;
1873
+ var nodeName = n.tagName;
1874
+
1875
+ html = NAMESPACE.isHTML(n.namespaceURI) || html;
1876
+
1877
+ var prefixedNodeName = nodeName;
1878
+ if (!html && !n.prefix && n.namespaceURI) {
1879
+ var defaultNS;
1880
+ // lookup current default ns from `xmlns` attribute
1881
+ for (var ai = 0; ai < attrs.length; ai++) {
1882
+ if (attrs.item(ai).name === 'xmlns') {
1883
+ defaultNS = attrs.item(ai).value;
1884
+ break;
1885
+ }
1886
+ }
1887
+ if (!defaultNS) {
1888
+ // lookup current default ns in visibleNamespaces
1889
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
1890
+ var nsEntry = ns[nsi];
1891
+ if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
1892
+ defaultNS = nsEntry.namespace;
1893
+ break;
1894
+ }
1895
+ }
1896
+ }
1897
+ if (defaultNS !== n.namespaceURI) {
1898
+ for (var nsi = ns.length - 1; nsi >= 0; nsi--) {
1899
+ var nsEntry = ns[nsi];
1900
+ if (nsEntry.namespace === n.namespaceURI) {
1901
+ if (nsEntry.prefix) {
1902
+ prefixedNodeName = nsEntry.prefix + ':' + nodeName;
1903
+ }
1904
+ break;
1905
+ }
1906
+ }
1907
+ }
1908
+ }
1909
+
1910
+ if (requireWellFormed && !tagNamePattern.test(prefixedNodeName)) {
1911
+ throw new DOMException(INVALID_STATE_ERR, 'The element name "' + prefixedNodeName + '" is not a valid XML QName');
1912
+ }
1913
+ buf.push('<', prefixedNodeName);
1914
+
1915
+ // Build a fresh namespace snapshot for this element's children.
1916
+ // The slice prevents sibling elements from inheriting each other's declarations.
1917
+ var childNs = ns.slice();
1918
+ for (var i = 0; i < len; i++) {
1919
+ var attr = attrs.item(i);
1920
+ if (attr.prefix == 'xmlns') {
1921
+ childNs.push({ prefix: attr.localName, namespace: attr.value });
1922
+ } else if (attr.nodeName == 'xmlns') {
1923
+ childNs.push({ prefix: '', namespace: attr.value });
1924
+ }
1925
+ }
1926
+
1927
+ for (var i = 0; i < len; i++) {
1928
+ var attr = attrs.item(i);
1929
+ if (needNamespaceDefine(attr, html, childNs)) {
1930
+ var attrPrefix = attr.prefix || '';
1931
+ var uri = attr.namespaceURI;
1932
+ addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri, requireWellFormed);
1933
+ childNs.push({ prefix: attrPrefix, namespace: uri });
1934
+ }
1935
+ // Apply nodeFilter and serialize the attribute.
1936
+ var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
1937
+ if (filteredAttr) {
1938
+ if (typeof filteredAttr === 'string') {
1939
+ buf.push(filteredAttr);
1940
+ } else {
1941
+ addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value, requireWellFormed);
1942
+ }
1943
+ }
1944
+ }
1945
+
1946
+ // add namespace for current node
1947
+ if (nodeName === prefixedNodeName && needNamespaceDefine(n, html, childNs)) {
1948
+ var nodePrefix = n.prefix || '';
1949
+ var uri = n.namespaceURI;
1950
+ addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri, requireWellFormed);
1951
+ childNs.push({ prefix: nodePrefix, namespace: uri });
1952
+ }
1953
+
1954
+ var child = n.firstChild;
1955
+ if (child || html && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
1956
+ buf.push('>');
1957
+ if (html && /^script$/i.test(nodeName)) {
1958
+ // Inline serialization for <script> children; return null to skip walkDOM descent.
1959
+ while (child) {
1960
+ if (child.data) {
1961
+ buf.push(child.data);
1962
+ } else {
1963
+ serializeToString(child, buf, html, nodeFilter, childNs.slice(), requireWellFormed);
1964
+ }
1965
+ child = child.nextSibling;
1966
+ }
1967
+ buf.push('</', nodeName, '>');
1968
+ return null;
1969
+ }
1970
+ // Return child context; walkDOM descends and exit emits the closing tag.
1971
+ return { ns: childNs, isHTML: html, tag: prefixedNodeName };
1972
+ } else {
1973
+ buf.push('/>');
1974
+ return null;
1975
+ }
1976
+
1977
+ case DOCUMENT_NODE:
1978
+ case DOCUMENT_FRAGMENT_NODE:
1979
+ // Descend into children; exit is a no-op (tag is null).
1980
+ return { ns: ns.slice(), isHTML: html, tag: null };
1981
+
1982
+ case ATTRIBUTE_NODE:
1983
+ addSerializedAttribute(buf, n.name, n.value, requireWellFormed);
1984
+ return null;
1985
+
1986
+ case TEXT_NODE:
1987
+ /**
1988
+ * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
1989
+ * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
1990
+ * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
1991
+ * `&amp;` and `&lt;` respectively.
1992
+ * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
1993
+ * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
1994
+ * when that string is not marking the end of a CDATA section.
1995
+ *
1996
+ * In the content of elements, character data is any string of characters
1997
+ * which does not contain the start-delimiter of any markup
1998
+ * and does not include the CDATA-section-close delimiter, `]]>`.
1999
+ *
2000
+ * @see https://www.w3.org/TR/xml/#NT-CharData
2001
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
2002
+ */
2003
+ buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
2004
+ return null;
2005
+
2006
+ case CDATA_SECTION_NODE:
2007
+ if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
2008
+ throw new DOMException(INVALID_STATE_ERR, 'The CDATASection data contains "]]>"');
2009
+ }
2010
+ buf.push('<![CDATA[', n.data.replace(/]]>/g, ']]]]><![CDATA[>'), ']]>');
2011
+ return null;
2012
+
2013
+ case COMMENT_NODE:
2014
+ if (requireWellFormed && n.data.indexOf('-->') !== -1) {
2015
+ throw new DOMException(INVALID_STATE_ERR, 'The comment node data contains "-->"');
2016
+ }
2017
+ buf.push('<!--', n.data, '-->');
2018
+ return null;
2019
+
2020
+ case DOCUMENT_TYPE_NODE:
2021
+ if (requireWellFormed) {
2022
+ if (!tagNamePattern.test(n.name)) {
2023
+ throw new DOMException(INVALID_STATE_ERR, 'The doctype name "' + n.name + '" is not a valid XML Name');
2024
+ }
2025
+ if (n.publicId && !/^("[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%']*"|'[\x20\r\na-zA-Z0-9\-()+,.\/:=?;!*#@$_%'"]*')$/.test(n.publicId)) {
2026
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType publicId is not a valid PubidLiteral');
2027
+ }
2028
+ if (n.systemId && !/^("[^"]*"|'[^']*')$/.test(n.systemId)) {
2029
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType systemId is not a valid SystemLiteral');
2030
+ }
2031
+ if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
2032
+ throw new DOMException(INVALID_STATE_ERR, 'DocumentType internalSubset contains "]>"');
2033
+ }
2034
+ }
2035
+ var pubid = n.publicId;
2036
+ var sysid = n.systemId;
2037
+ buf.push('<!DOCTYPE ', n.name);
2038
+ if (pubid) {
2039
+ buf.push(' PUBLIC ', pubid);
2040
+ if (sysid && sysid != '.') {
2041
+ buf.push(' ', sysid);
2042
+ }
2043
+ buf.push('>');
2044
+ } else if (sysid && sysid != '.') {
2045
+ buf.push(' SYSTEM ', sysid, '>');
2046
+ } else {
2047
+ var sub = n.internalSubset;
2048
+ if (sub) {
2049
+ buf.push(' [', sub, ']');
2050
+ }
2051
+ buf.push('>');
2052
+ }
2053
+ return null;
2054
+
2055
+ case PROCESSING_INSTRUCTION_NODE:
2056
+ if (requireWellFormed) {
2057
+ if (!tagNamePattern.test(n.target) || n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
2058
+ throw new DOMException(
2059
+ INVALID_STATE_ERR,
2060
+ 'The processing instruction target "' + n.target + '" is not a valid XML NCName or is reserved'
2061
+ );
2062
+ }
2063
+ if (n.data.indexOf('?>') !== -1) {
2064
+ throw new DOMException(INVALID_STATE_ERR, 'The ProcessingInstruction data contains "?>"');
2065
+ }
2066
+ }
2067
+ buf.push('<?', n.target, ' ', n.data, '?>');
2068
+ return null;
2069
+
2070
+ case ENTITY_REFERENCE_NODE:
2071
+ if (requireWellFormed && !tagNamePattern.test(n.nodeName)) {
2072
+ throw new DOMException(
2073
+ INVALID_STATE_ERR,
2074
+ 'The entity reference name "' + n.nodeName + '" is not a valid XML Name'
2075
+ );
2076
+ }
2077
+ buf.push('&', n.nodeName, ';');
2078
+ return null;
2079
+
2080
+ //case ENTITY_NODE:
2081
+ //case NOTATION_NODE:
2082
+ default:
2083
+ buf.push('??', n.nodeName);
2084
+ return null;
2085
+ }
2086
+ },
2087
+ exit: function (n, childCtx) {
2088
+ if (childCtx && childCtx.tag) {
2089
+ buf.push('</', childCtx.tag, '>');
2090
+ }
2091
+ },
2092
+ });
2093
+ }
2094
+ /**
2095
+ * Imports a node from a different document into `doc`, creating a new copy.
2096
+ * Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
2097
+ * stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
2098
+ * Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
2099
+ * always forced to `true`
2100
+ * because an attribute's value lives in a child text node.
2101
+ *
2102
+ * @param {Document} doc
2103
+ * The document that will own the imported node.
2104
+ * @param {Node} node
2105
+ * The node to import.
2106
+ * @param {boolean} deep
2107
+ * If `true`, descendants are imported recursively.
2108
+ * @returns {Node}
2109
+ * The newly imported node, now owned by `doc`.
2110
+ */
2111
+ function importNode(doc, node, deep) {
2112
+ var destRoot;
2113
+ walkDOM(node, null, {
2114
+ enter: function (srcNode, destParent) {
2115
+ // Shallow-clone the node and stamp it into the target document.
2116
+ var destNode = srcNode.cloneNode(false);
2117
+ destNode.ownerDocument = doc;
2118
+ destNode.parentNode = null;
2119
+ // capture as the root of the imported subtree or attach to parent.
2120
+ if (destParent === null) {
2121
+ destRoot = destNode;
2122
+ } else {
2123
+ destParent.appendChild(destNode);
2124
+ }
2125
+ // ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
2126
+ var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
2127
+ return shouldDeep ? destNode : null;
2128
+ },
2129
+ });
2130
+ return destRoot;
2131
+ }
2132
+ //
2133
+ //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
2134
+ // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
2135
+ function cloneNode(doc, node, deep) {
2136
+ var destRoot;
2137
+ walkDOM(node, null, {
2138
+ enter: function (srcNode, destParent) {
2139
+ // 1. Create a blank node of the same type and copy all scalar own properties.
2140
+ var destNode = new srcNode.constructor();
2141
+ for (var n in srcNode) {
2142
+ if (Object.prototype.hasOwnProperty.call(srcNode, n)) {
2143
+ var v = srcNode[n];
2144
+ if (typeof v != 'object') {
2145
+ if (v != destNode[n]) {
2146
+ destNode[n] = v;
2147
+ }
2148
+ }
2149
+ }
2150
+ }
2151
+ if (srcNode.childNodes) {
2152
+ destNode.childNodes = new NodeList();
2153
+ }
2154
+ destNode.ownerDocument = doc;
2155
+ // 2. Handle node-type-specific setup.
2156
+ // Attributes are not DOM children, so they are cloned inline here
2157
+ // rather than by walkDOM descent.
2158
+ // ATTRIBUTE_NODE forces deep=true so its own children are walked.
2159
+ var shouldDeep = deep;
2160
+ switch (destNode.nodeType) {
2161
+ case ELEMENT_NODE:
2162
+ var attrs = srcNode.attributes;
2163
+ var attrs2 = (destNode.attributes = new NamedNodeMap());
2164
+ var len = attrs.length;
2165
+ attrs2._ownerElement = destNode;
2166
+ for (var i = 0; i < len; i++) {
2167
+ destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
2168
+ }
2169
+ break;
2170
+ case ATTRIBUTE_NODE:
2171
+ shouldDeep = true;
2172
+ }
2173
+ // 3. Attach to parent, or capture as the root of the cloned subtree.
2174
+ if (destParent !== null) {
2175
+ destParent.appendChild(destNode);
2176
+ } else {
2177
+ destRoot = destNode;
2178
+ }
2179
+ // 4. Return destNode as the context for children (causes walkDOM to descend),
2180
+ // or null to skip children (shallow clone).
2181
+ return shouldDeep ? destNode : null;
2182
+ },
2183
+ });
2184
+ return destRoot;
2185
+ }
2186
+
2187
+ function __set__(object,key,value){
2188
+ object[key] = value
2189
+ }
2190
+ //do dynamic
2191
+ try{
2192
+ if(Object.defineProperty){
2193
+ Object.defineProperty(LiveNodeList.prototype,'length',{
2194
+ get:function(){
2195
+ _updateLiveList(this);
2196
+ return this.$$length;
2197
+ }
2198
+ });
2199
+
2200
+ /**
2201
+ * The text content of this node and its descendants.
2202
+ *
2203
+ * Setting `textContent` on an element or document fragment replaces all child nodes with a
2204
+ * single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
2205
+ *
2206
+ * @type {string | null}
2207
+ * @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
2208
+ */
2209
+ Object.defineProperty(Node.prototype, 'textContent', {
2210
+ get: function () {
2211
+ if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
2212
+ var buf = [];
2213
+ walkDOM(this, null, {
2214
+ enter: function (n) {
2215
+ if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
2216
+ return true; // enter children
2217
+ }
2218
+ if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
2219
+ return null; // excluded from text content
2220
+ }
2221
+ buf.push(n.nodeValue);
2222
+ },
2223
+ });
2224
+ return buf.join('');
2225
+ }
2226
+ return this.nodeValue;
2227
+ },
2228
+
2229
+ set: function (data) {
2230
+ switch (this.nodeType) {
2231
+ case ELEMENT_NODE:
2232
+ case DOCUMENT_FRAGMENT_NODE:
2233
+ while (this.firstChild) {
2234
+ this.removeChild(this.firstChild);
2235
+ }
2236
+ if (data || String(data)) {
2237
+ this.appendChild(this.ownerDocument.createTextNode(data));
2238
+ }
2239
+ break;
2240
+
2241
+ default:
2242
+ this.data = data;
2243
+ this.value = data;
2244
+ this.nodeValue = data;
2245
+ }
2246
+ },
2247
+ })
2248
+
2249
+ __set__ = function(object,key,value){
2250
+ //console.log(value)
2251
+ object['$$'+key] = value
2252
+ }
2253
+ }
2254
+ }catch(e){//ie8
2255
+ }
2256
+
2257
+ //if(typeof require == 'function'){
2258
+ exports.DocumentType = DocumentType;
2259
+ exports.DOMException = DOMException;
2260
+ exports.DOMImplementation = DOMImplementation;
2261
+ exports.Element = Element;
2262
+ exports.Node = Node;
2263
+ exports.NodeList = NodeList;
2264
+ exports.walkDOM = walkDOM;
2265
+ exports.XMLSerializer = XMLSerializer;
2266
+ //}