@websolutespa/bom-next 3.0.0 → 3.0.2
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.
- package/CHANGELOG.md +1 -1
- package/dist/_virtual/_rolldown/runtime.js +24 -0
- package/dist/client/client.d.ts +9 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +18 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/extra.d.ts +17 -0
- package/dist/client/extra.d.ts.map +1 -0
- package/dist/client/extra.js +13 -0
- package/dist/client/extra.js.map +1 -0
- package/dist/client/label.d.ts +15 -0
- package/dist/client/label.d.ts.map +1 -0
- package/dist/client/label.js +20 -0
- package/dist/client/label.js.map +1 -0
- package/dist/client/layout.d.ts +18 -0
- package/dist/client/layout.d.ts.map +1 -0
- package/dist/client/layout.js +13 -0
- package/dist/client/layout.js.map +1 -0
- package/dist/client/local.collection.d.ts +32 -0
- package/dist/client/local.collection.d.ts.map +1 -0
- package/dist/client/local.collection.js +49 -0
- package/dist/client/local.collection.js.map +1 -0
- package/dist/client/metadata.d.ts +43 -0
- package/dist/client/metadata.d.ts.map +1 -0
- package/dist/client/metadata.js +146 -0
- package/dist/client/metadata.js.map +1 -0
- package/dist/client/page.d.ts +404 -0
- package/dist/client/page.d.ts.map +1 -0
- package/dist/client/page.js +13 -0
- package/dist/client/page.js.map +1 -0
- package/dist/client/useApi.d.ts +21 -0
- package/dist/client/useApi.d.ts.map +1 -0
- package/dist/client/useApi.js +65 -0
- package/dist/client/useApi.js.map +1 -0
- package/dist/client/useCollectionApi.d.ts +21 -0
- package/dist/client/useCollectionApi.d.ts.map +1 -0
- package/dist/client/useCollectionApi.js +65 -0
- package/dist/client/useCollectionApi.js.map +1 -0
- package/dist/client/useExtra.d.ts +9 -0
- package/dist/client/useExtra.d.ts.map +1 -0
- package/dist/client/useExtra.js +13 -0
- package/dist/client/useExtra.js.map +1 -0
- package/dist/client/useHttp.d.ts +15 -0
- package/dist/client/useHttp.d.ts.map +1 -0
- package/dist/client/useHttp.js +70 -0
- package/dist/client/useHttp.js.map +1 -0
- package/dist/client/useLabel.d.ts +9 -0
- package/dist/client/useLabel.d.ts.map +1 -0
- package/dist/client/useLabel.js +13 -0
- package/dist/client/useLabel.js.map +1 -0
- package/dist/client/useLayout.d.ts +9 -0
- package/dist/client/useLayout.d.ts.map +1 -0
- package/dist/client/useLayout.js +13 -0
- package/dist/client/useLayout.js.map +1 -0
- package/dist/client/useLink.d.ts +7 -0
- package/dist/client/useLink.d.ts.map +1 -0
- package/dist/client/useLink.js +15 -0
- package/dist/client/useLink.js.map +1 -0
- package/dist/client/useMetaData.d.ts +9 -0
- package/dist/client/useMetaData.d.ts.map +1 -0
- package/dist/client/useMetaData.js +13 -0
- package/dist/client/useMetaData.js.map +1 -0
- package/dist/client/usePage.d.ts +394 -0
- package/dist/client/usePage.d.ts.map +1 -0
- package/dist/client/usePage.js +13 -0
- package/dist/client/usePage.js.map +1 -0
- package/dist/client/useUser.d.ts +9 -0
- package/dist/client/useUser.d.ts.map +1 -0
- package/dist/client/useUser.js +13 -0
- package/dist/client/useUser.js.map +1 -0
- package/dist/client/user.d.ts +20 -0
- package/dist/client/user.d.ts.map +1 -0
- package/dist/client/user.js +33 -0
- package/dist/client/user.js.map +1 -0
- package/dist/exports/client.d.ts +20 -0
- package/dist/exports/client.js +19 -5734
- package/dist/exports/instrumentation.d.ts +2 -0
- package/dist/exports/instrumentation.js +1 -24
- package/dist/exports/proxy.d.ts +5 -0
- package/dist/exports/proxy.js +4 -253
- package/dist/exports/server.d.ts +19 -0
- package/dist/exports/server.js +18 -1973
- package/dist/index.d.ts +18 -0
- package/dist/index.js +10 -200
- package/dist/instrumentation/client.d.ts +8 -0
- package/dist/instrumentation/client.d.ts.map +1 -0
- package/dist/instrumentation/client.js +15 -0
- package/dist/instrumentation/client.js.map +1 -0
- package/dist/instrumentation/sentry/capture.requestError.js +10 -0
- package/dist/instrumentation/sentry/capture.requestError.js.map +1 -0
- package/dist/instrumentation/sentry/capture.routerTransitionStart.js +7 -0
- package/dist/instrumentation/sentry/capture.routerTransitionStart.js.map +1 -0
- package/dist/{exports/instrumentation-DBO6QH4d.d.ts → instrumentation/server.d.ts} +2 -2
- package/dist/instrumentation/server.d.ts.map +1 -0
- package/dist/instrumentation/server.js +19 -0
- package/dist/instrumentation/server.js.map +1 -0
- package/dist/{types-BatUTdbZ.d.ts → instrumentation/types.d.ts} +2 -2
- package/dist/instrumentation/types.d.ts.map +1 -0
- package/dist/lib/breadcrumb.d.ts +15 -0
- package/dist/lib/breadcrumb.d.ts.map +1 -0
- package/dist/lib/breadcrumb.js +20 -0
- package/dist/lib/breadcrumb.js.map +1 -0
- package/dist/lib/const.d.ts +9 -0
- package/dist/lib/const.d.ts.map +1 -0
- package/dist/lib/const.js +9 -0
- package/dist/lib/const.js.map +1 -0
- package/dist/lib/http.d.ts +36 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/{http-_2M-UFRx.js → lib/http.js} +2 -2
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/label.d.ts +16 -0
- package/dist/lib/label.d.ts.map +1 -0
- package/dist/lib/label.js +33 -0
- package/dist/lib/label.js.map +1 -0
- package/dist/lib/layout.defaults.d.ts +9 -0
- package/dist/lib/layout.defaults.d.ts.map +1 -0
- package/dist/lib/layout.defaults.js +161 -0
- package/dist/lib/layout.defaults.js.map +1 -0
- package/dist/lib/link.d.ts +9 -0
- package/dist/lib/link.d.ts.map +1 -0
- package/dist/lib/link.js +16 -0
- package/dist/lib/link.js.map +1 -0
- package/dist/lib/meta-data.d.ts +56 -0
- package/dist/lib/meta-data.d.ts.map +1 -0
- package/dist/lib/open-graph.d.ts +143 -0
- package/dist/lib/open-graph.d.ts.map +1 -0
- package/dist/lib/pagination.d.ts +27 -0
- package/dist/lib/pagination.d.ts.map +1 -0
- package/dist/lib/pagination.js +39 -0
- package/dist/lib/pagination.js.map +1 -0
- package/dist/lib/route.d.ts +17 -0
- package/dist/lib/route.d.ts.map +1 -0
- package/dist/{route-DzFwERQP.js → lib/route.js} +2 -2
- package/dist/lib/route.js.map +1 -0
- package/dist/lib/store.d.ts +27 -0
- package/dist/lib/store.d.ts.map +1 -0
- package/dist/{store-CJzqrHsl.js → lib/store.js} +2 -25
- package/dist/lib/store.js.map +1 -0
- package/dist/lib/structured-data.d.ts +9 -0
- package/dist/lib/structured-data.d.ts.map +1 -0
- package/dist/lib/twitter-card.d.ts +43 -0
- package/dist/lib/twitter-card.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +13 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +35 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/mock.d.ts +127 -0
- package/dist/mock.d.ts.map +1 -0
- package/dist/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +75 -0
- package/dist/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js.map +1 -0
- package/dist/node_modules/deepmerge/dist/cjs.js +86 -0
- package/dist/node_modules/deepmerge/dist/cjs.js.map +1 -0
- package/dist/node_modules/dom-serializer/lib/esm/foreignNames.js +105 -0
- package/dist/node_modules/dom-serializer/lib/esm/foreignNames.js.map +1 -0
- package/dist/node_modules/dom-serializer/lib/esm/index.js +146 -0
- package/dist/node_modules/dom-serializer/lib/esm/index.js.map +1 -0
- package/dist/node_modules/domelementtype/lib/esm/index.js +53 -0
- package/dist/node_modules/domelementtype/lib/esm/index.js.map +1 -0
- package/dist/node_modules/domhandler/lib/esm/index.js +130 -0
- package/dist/node_modules/domhandler/lib/esm/index.js.map +1 -0
- package/dist/node_modules/domhandler/lib/esm/node.js +307 -0
- package/dist/node_modules/domhandler/lib/esm/node.js.map +1 -0
- package/dist/node_modules/entities/lib/esm/decode.js +363 -0
- package/dist/node_modules/entities/lib/esm/decode.js.map +1 -0
- package/dist/node_modules/entities/lib/esm/decode_codepoint.js +59 -0
- package/dist/node_modules/entities/lib/esm/decode_codepoint.js.map +1 -0
- package/dist/node_modules/entities/lib/esm/escape.js +85 -0
- package/dist/node_modules/entities/lib/esm/escape.js.map +1 -0
- package/dist/node_modules/entities/lib/esm/generated/decode-data-html.js +6 -0
- package/dist/node_modules/entities/lib/esm/generated/decode-data-html.js.map +1 -0
- package/dist/node_modules/entities/lib/esm/generated/decode-data-xml.js +6 -0
- package/dist/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +1 -0
- package/dist/node_modules/html-to-text/lib/html-to-text.js +1816 -0
- package/dist/node_modules/html-to-text/lib/html-to-text.js.map +1 -0
- package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Parser.js +435 -0
- package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Parser.js.map +1 -0
- package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Tokenizer.js +736 -0
- package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Tokenizer.js.map +1 -0
- package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/index.js +19 -0
- package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/index.js.map +1 -0
- package/dist/node_modules/leac/lib/leac.js +101 -0
- package/dist/node_modules/leac/lib/leac.js.map +1 -0
- package/dist/node_modules/parseley/lib/parseley.js +310 -0
- package/dist/node_modules/parseley/lib/parseley.js.map +1 -0
- package/dist/node_modules/peberminta/lib/core.js +149 -0
- package/dist/node_modules/peberminta/lib/core.js.map +1 -0
- package/dist/node_modules/selderee/lib/selderee.js +319 -0
- package/dist/node_modules/selderee/lib/selderee.js.map +1 -0
- package/dist/proxy/protected-route.d.ts +9 -0
- package/dist/proxy/protected-route.d.ts.map +1 -0
- package/dist/proxy/protected-route.js +40 -0
- package/dist/proxy/protected-route.js.map +1 -0
- package/dist/proxy/proxy.d.ts +31 -0
- package/dist/proxy/proxy.d.ts.map +1 -0
- package/dist/proxy/proxy.js +49 -0
- package/dist/proxy/proxy.js.map +1 -0
- package/dist/proxy/route-auto-detection.d.ts +12 -0
- package/dist/proxy/route-auto-detection.d.ts.map +1 -0
- package/dist/proxy/route-auto-detection.js +82 -0
- package/dist/proxy/route-auto-detection.js.map +1 -0
- package/dist/proxy/route-proxy.d.ts +36 -0
- package/dist/proxy/route-proxy.d.ts.map +1 -0
- package/dist/proxy/route-proxy.js +103 -0
- package/dist/proxy/route-proxy.js.map +1 -0
- package/dist/server/context.d.ts +30 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +106 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/handlers/auth.handler.d.ts +10 -0
- package/dist/server/handlers/auth.handler.d.ts.map +1 -0
- package/dist/server/handlers/auth.handler.js +29 -0
- package/dist/server/handlers/auth.handler.js.map +1 -0
- package/dist/server/handlers/captions.handler.d.ts +10 -0
- package/dist/server/handlers/captions.handler.d.ts.map +1 -0
- package/dist/server/handlers/captions.handler.js +33 -0
- package/dist/server/handlers/captions.handler.js.map +1 -0
- package/dist/server/handlers/collection.handler.d.ts +36 -0
- package/dist/server/handlers/collection.handler.d.ts.map +1 -0
- package/dist/server/handlers/collection.handler.js +166 -0
- package/dist/server/handlers/collection.handler.js.map +1 -0
- package/dist/server/handlers/error-response.js +24 -0
- package/dist/server/handlers/error-response.js.map +1 -0
- package/dist/server/handlers/index.handler.d.ts +9 -0
- package/dist/server/handlers/index.handler.d.ts.map +1 -0
- package/dist/server/handlers/index.handler.js +145 -0
- package/dist/server/handlers/index.handler.js.map +1 -0
- package/dist/server/handlers/preview.handler.d.ts +9 -0
- package/dist/server/handlers/preview.handler.d.ts.map +1 -0
- package/dist/server/handlers/preview.handler.js +15 -0
- package/dist/server/handlers/preview.handler.js.map +1 -0
- package/dist/server/handlers/registry.handler.d.ts +16 -0
- package/dist/server/handlers/registry.handler.d.ts.map +1 -0
- package/dist/server/handlers/registry.handler.js +260 -0
- package/dist/server/handlers/registry.handler.js.map +1 -0
- package/dist/server/handlers/route.handler.d.ts +20 -0
- package/dist/server/handlers/route.handler.d.ts.map +1 -0
- package/dist/server/handlers/route.handler.js +122 -0
- package/dist/server/handlers/route.handler.js.map +1 -0
- package/dist/server/handlers/sitemap.handler.d.ts +30 -0
- package/dist/server/handlers/sitemap.handler.d.ts.map +1 -0
- package/dist/server/handlers/sitemap.handler.js +338 -0
- package/dist/server/handlers/sitemap.handler.js.map +1 -0
- package/dist/server/handlers/static-params.handler.d.ts +24 -0
- package/dist/server/handlers/static-params.handler.d.ts.map +1 -0
- package/dist/server/handlers/static-params.handler.js +56 -0
- package/dist/server/handlers/static-params.handler.js.map +1 -0
- package/dist/server/handlers/vars.handler.d.ts +10 -0
- package/dist/server/handlers/vars.handler.d.ts.map +1 -0
- package/dist/server/handlers/vars.handler.js +159 -0
- package/dist/server/handlers/vars.handler.js.map +1 -0
- package/dist/server/layout.js +88 -0
- package/dist/server/layout.js.map +1 -0
- package/dist/server/lazy.d.ts +11 -0
- package/dist/server/lazy.d.ts.map +1 -0
- package/dist/server/lazy.js +33 -0
- package/dist/server/lazy.js.map +1 -0
- package/dist/server/local-api.d.ts +9 -0
- package/dist/server/local-api.d.ts.map +1 -0
- package/dist/server/local-api.js +60 -0
- package/dist/server/local-api.js.map +1 -0
- package/dist/server/metadata.d.ts +21 -0
- package/dist/server/metadata.d.ts.map +1 -0
- package/dist/server/metadata.js +20 -0
- package/dist/server/metadata.js.map +1 -0
- package/dist/server/mixer-payload.d.ts +63 -0
- package/dist/server/mixer-payload.d.ts.map +1 -0
- package/dist/server/mixer.d.ts +214 -0
- package/dist/server/mixer.d.ts.map +1 -0
- package/dist/server/mixer.js +355 -0
- package/dist/server/mixer.js.map +1 -0
- package/dist/server/page.d.ts +22 -0
- package/dist/server/page.d.ts.map +1 -0
- package/dist/server/page.js +57 -0
- package/dist/server/page.js.map +1 -0
- package/dist/server/utils.d.ts +12 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/dist/{utils-YwteTbk7.js → server/utils.js} +3 -3
- package/dist/server/utils.js.map +1 -0
- package/dist/server/utmz.d.ts +9 -0
- package/dist/server/utmz.d.ts.map +1 -0
- package/dist/server/utmz.js +14 -0
- package/dist/server/utmz.js.map +1 -0
- package/dist/types.d.ts +136 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/dist/exports/client-xcFJNcG7.d.ts +0 -979
- package/dist/exports/client-xcFJNcG7.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/exports/instrumentation-DBO6QH4d.d.ts.map +0 -1
- package/dist/exports/instrumentation.js.map +0 -1
- package/dist/exports/proxy-Cv7QFVci.d.ts +0 -71
- package/dist/exports/proxy-Cv7QFVci.d.ts.map +0 -1
- package/dist/exports/proxy.js.map +0 -1
- package/dist/exports/server-BHObJHJ6.d.ts +0 -402
- package/dist/exports/server-BHObJHJ6.d.ts.map +0 -1
- package/dist/exports/server.js.map +0 -1
- package/dist/http-_2M-UFRx.js.map +0 -1
- package/dist/index-CdYcvudT.d.ts +0 -4
- package/dist/index-CtfAJ0y7.d.ts +0 -499
- package/dist/index-CtfAJ0y7.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/route-DzFwERQP.js.map +0 -1
- package/dist/store-CJzqrHsl.js.map +0 -1
- package/dist/types-BatUTdbZ.d.ts.map +0 -1
- package/dist/types-D29_snYY.d.ts +0 -191
- package/dist/types-D29_snYY.d.ts.map +0 -1
- package/dist/utils-Ca7xh5mm.js +0 -78
- package/dist/utils-Ca7xh5mm.js.map +0 -1
- package/dist/utils-YwteTbk7.js.map +0 -1
- /package/dist/{config.client-B8As5DY0.js → instrumentation/sentry/config.client.js} +0 -0
- /package/dist/{config.edge-B8As5DY0.js → instrumentation/sentry/config.edge.js} +0 -0
- /package/dist/{config.server-B8As5DY0.js → instrumentation/sentry/config.server.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":["isTagRaw"],"sources":["../../../../../../../node_modules/domhandler/lib/esm/node.js"],"sourcesContent":["import { ElementType, isTag as isTagRaw } from \"domelementtype\";\n/**\n * This object will be used as the prototype for Nodes when creating a\n * DOM-Level-1-compliant structure.\n */\nexport class Node {\n constructor() {\n /** Parent of the node */\n this.parent = null;\n /** Previous sibling */\n this.prev = null;\n /** Next sibling */\n this.next = null;\n /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */\n this.startIndex = null;\n /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */\n this.endIndex = null;\n }\n // Read-write aliases for properties\n /**\n * Same as {@link parent}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get parentNode() {\n return this.parent;\n }\n set parentNode(parent) {\n this.parent = parent;\n }\n /**\n * Same as {@link prev}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get previousSibling() {\n return this.prev;\n }\n set previousSibling(prev) {\n this.prev = prev;\n }\n /**\n * Same as {@link next}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get nextSibling() {\n return this.next;\n }\n set nextSibling(next) {\n this.next = next;\n }\n /**\n * Clone this node, and optionally its children.\n *\n * @param recursive Clone child nodes as well.\n * @returns A clone of the node.\n */\n cloneNode(recursive = false) {\n return cloneNode(this, recursive);\n }\n}\n/**\n * A node that contains some data.\n */\nexport class DataNode extends Node {\n /**\n * @param data The content of the data node\n */\n constructor(data) {\n super();\n this.data = data;\n }\n /**\n * Same as {@link data}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get nodeValue() {\n return this.data;\n }\n set nodeValue(data) {\n this.data = data;\n }\n}\n/**\n * Text within the document.\n */\nexport class Text extends DataNode {\n constructor() {\n super(...arguments);\n this.type = ElementType.Text;\n }\n get nodeType() {\n return 3;\n }\n}\n/**\n * Comments within the document.\n */\nexport class Comment extends DataNode {\n constructor() {\n super(...arguments);\n this.type = ElementType.Comment;\n }\n get nodeType() {\n return 8;\n }\n}\n/**\n * Processing instructions, including doc types.\n */\nexport class ProcessingInstruction extends DataNode {\n constructor(name, data) {\n super(data);\n this.name = name;\n this.type = ElementType.Directive;\n }\n get nodeType() {\n return 1;\n }\n}\n/**\n * A `Node` that can have children.\n */\nexport class NodeWithChildren extends Node {\n /**\n * @param children Children of the node. Only certain node types can have children.\n */\n constructor(children) {\n super();\n this.children = children;\n }\n // Aliases\n /** First child of the node. */\n get firstChild() {\n var _a;\n return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;\n }\n /** Last child of the node. */\n get lastChild() {\n return this.children.length > 0\n ? this.children[this.children.length - 1]\n : null;\n }\n /**\n * Same as {@link children}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get childNodes() {\n return this.children;\n }\n set childNodes(children) {\n this.children = children;\n }\n}\nexport class CDATA extends NodeWithChildren {\n constructor() {\n super(...arguments);\n this.type = ElementType.CDATA;\n }\n get nodeType() {\n return 4;\n }\n}\n/**\n * The root node of the document.\n */\nexport class Document extends NodeWithChildren {\n constructor() {\n super(...arguments);\n this.type = ElementType.Root;\n }\n get nodeType() {\n return 9;\n }\n}\n/**\n * An element within the DOM.\n */\nexport class Element extends NodeWithChildren {\n /**\n * @param name Name of the tag, eg. `div`, `span`.\n * @param attribs Object mapping attribute names to attribute values.\n * @param children Children of the node.\n */\n constructor(name, attribs, children = [], type = name === \"script\"\n ? ElementType.Script\n : name === \"style\"\n ? ElementType.Style\n : ElementType.Tag) {\n super(children);\n this.name = name;\n this.attribs = attribs;\n this.type = type;\n }\n get nodeType() {\n return 1;\n }\n // DOM Level 1 aliases\n /**\n * Same as {@link name}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get tagName() {\n return this.name;\n }\n set tagName(name) {\n this.name = name;\n }\n get attributes() {\n return Object.keys(this.attribs).map((name) => {\n var _a, _b;\n return ({\n name,\n value: this.attribs[name],\n namespace: (_a = this[\"x-attribsNamespace\"]) === null || _a === void 0 ? void 0 : _a[name],\n prefix: (_b = this[\"x-attribsPrefix\"]) === null || _b === void 0 ? void 0 : _b[name],\n });\n });\n }\n}\n/**\n * @param node Node to check.\n * @returns `true` if the node is a `Element`, `false` otherwise.\n */\nexport function isTag(node) {\n return isTagRaw(node);\n}\n/**\n * @param node Node to check.\n * @returns `true` if the node has the type `CDATA`, `false` otherwise.\n */\nexport function isCDATA(node) {\n return node.type === ElementType.CDATA;\n}\n/**\n * @param node Node to check.\n * @returns `true` if the node has the type `Text`, `false` otherwise.\n */\nexport function isText(node) {\n return node.type === ElementType.Text;\n}\n/**\n * @param node Node to check.\n * @returns `true` if the node has the type `Comment`, `false` otherwise.\n */\nexport function isComment(node) {\n return node.type === ElementType.Comment;\n}\n/**\n * @param node Node to check.\n * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.\n */\nexport function isDirective(node) {\n return node.type === ElementType.Directive;\n}\n/**\n * @param node Node to check.\n * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.\n */\nexport function isDocument(node) {\n return node.type === ElementType.Root;\n}\n/**\n * @param node Node to check.\n * @returns `true` if the node has children, `false` otherwise.\n */\nexport function hasChildren(node) {\n return Object.prototype.hasOwnProperty.call(node, \"children\");\n}\n/**\n * Clone a node, and optionally its children.\n *\n * @param recursive Clone child nodes as well.\n * @returns A clone of the node.\n */\nexport function cloneNode(node, recursive = false) {\n let result;\n if (isText(node)) {\n result = new Text(node.data);\n }\n else if (isComment(node)) {\n result = new Comment(node.data);\n }\n else if (isTag(node)) {\n const children = recursive ? cloneChildren(node.children) : [];\n const clone = new Element(node.name, { ...node.attribs }, children);\n children.forEach((child) => (child.parent = clone));\n if (node.namespace != null) {\n clone.namespace = node.namespace;\n }\n if (node[\"x-attribsNamespace\"]) {\n clone[\"x-attribsNamespace\"] = { ...node[\"x-attribsNamespace\"] };\n }\n if (node[\"x-attribsPrefix\"]) {\n clone[\"x-attribsPrefix\"] = { ...node[\"x-attribsPrefix\"] };\n }\n result = clone;\n }\n else if (isCDATA(node)) {\n const children = recursive ? cloneChildren(node.children) : [];\n const clone = new CDATA(children);\n children.forEach((child) => (child.parent = clone));\n result = clone;\n }\n else if (isDocument(node)) {\n const children = recursive ? cloneChildren(node.children) : [];\n const clone = new Document(children);\n children.forEach((child) => (child.parent = clone));\n if (node[\"x-mode\"]) {\n clone[\"x-mode\"] = node[\"x-mode\"];\n }\n result = clone;\n }\n else if (isDirective(node)) {\n const instruction = new ProcessingInstruction(node.name, node.data);\n if (node[\"x-name\"] != null) {\n instruction[\"x-name\"] = node[\"x-name\"];\n instruction[\"x-publicId\"] = node[\"x-publicId\"];\n instruction[\"x-systemId\"] = node[\"x-systemId\"];\n }\n result = instruction;\n }\n else {\n throw new Error(`Not implemented yet: ${node.type}`);\n }\n result.startIndex = node.startIndex;\n result.endIndex = node.endIndex;\n if (node.sourceCodeLocation != null) {\n result.sourceCodeLocation = node.sourceCodeLocation;\n }\n return result;\n}\nfunction cloneChildren(childs) {\n const children = childs.map((child) => cloneNode(child, true));\n for (let i = 1; i < children.length; i++) {\n children[i].prev = children[i - 1];\n children[i - 1].next = children[i];\n }\n return children;\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;AAKA,IAAa,OAAb,MAAkB;CACd,cAAc;;EAEV,KAAK,SAAS;;EAEd,KAAK,OAAO;;EAEZ,KAAK,OAAO;;EAEZ,KAAK,aAAa;;EAElB,KAAK,WAAW;CACpB;;;;;CAMA,IAAI,aAAa;EACb,OAAO,KAAK;CAChB;CACA,IAAI,WAAW,QAAQ;EACnB,KAAK,SAAS;CAClB;;;;;CAKA,IAAI,kBAAkB;EAClB,OAAO,KAAK;CAChB;CACA,IAAI,gBAAgB,MAAM;EACtB,KAAK,OAAO;CAChB;;;;;CAKA,IAAI,cAAc;EACd,OAAO,KAAK;CAChB;CACA,IAAI,YAAY,MAAM;EAClB,KAAK,OAAO;CAChB;;;;;;;CAOA,UAAU,YAAY,OAAO;EACzB,OAAO,UAAU,MAAM,SAAS;CACpC;AACJ;;;;AAIA,IAAa,WAAb,cAA8B,KAAK;;;;CAI/B,YAAY,MAAM;EACd,MAAM;EACN,KAAK,OAAO;CACh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AC3B,MAAM,WAAW,OAAO,KAAK,UAAU,UAAU,OAAO,IAAI,CAAC;CAC7D,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACtC,SAAS,EAAE,CAAC,OAAO,SAAS,IAAI;EAChC,SAAS,IAAI,EAAE,CAAC,OAAO,SAAS;CACpC;CACA,OAAO;AACX"}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import decode_data_html_default from "./generated/decode-data-html.js";
|
|
2
|
+
import decode_data_xml_default from "./generated/decode-data-xml.js";
|
|
3
|
+
import { fromCodePoint, replaceCodePoint } from "./decode_codepoint.js";
|
|
4
|
+
//#region ../../node_modules/entities/lib/esm/decode.js
|
|
5
|
+
var CharCodes;
|
|
6
|
+
(function(CharCodes) {
|
|
7
|
+
CharCodes[CharCodes["NUM"] = 35] = "NUM";
|
|
8
|
+
CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
|
|
9
|
+
CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
|
|
10
|
+
CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
|
|
11
|
+
CharCodes[CharCodes["NINE"] = 57] = "NINE";
|
|
12
|
+
CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
|
|
13
|
+
CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
|
|
14
|
+
CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
|
|
15
|
+
CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
|
|
16
|
+
CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
|
|
17
|
+
CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
|
|
18
|
+
CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
|
|
19
|
+
})(CharCodes || (CharCodes = {}));
|
|
20
|
+
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
21
|
+
const TO_LOWER_BIT = 32;
|
|
22
|
+
var BinTrieFlags;
|
|
23
|
+
(function(BinTrieFlags) {
|
|
24
|
+
BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|
25
|
+
BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
|
|
26
|
+
BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|
27
|
+
})(BinTrieFlags || (BinTrieFlags = {}));
|
|
28
|
+
function isNumber(code) {
|
|
29
|
+
return code >= CharCodes.ZERO && code <= CharCodes.NINE;
|
|
30
|
+
}
|
|
31
|
+
function isHexadecimalCharacter(code) {
|
|
32
|
+
return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F;
|
|
33
|
+
}
|
|
34
|
+
function isAsciiAlphaNumeric(code) {
|
|
35
|
+
return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checks if the given character is a valid end character for an entity in an attribute.
|
|
39
|
+
*
|
|
40
|
+
* Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
|
|
41
|
+
* See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
|
|
42
|
+
*/
|
|
43
|
+
function isEntityInAttributeInvalidEnd(code) {
|
|
44
|
+
return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
|
|
45
|
+
}
|
|
46
|
+
var EntityDecoderState;
|
|
47
|
+
(function(EntityDecoderState) {
|
|
48
|
+
EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
|
|
49
|
+
EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
|
|
50
|
+
EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
|
|
51
|
+
EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
|
|
52
|
+
EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
|
|
53
|
+
})(EntityDecoderState || (EntityDecoderState = {}));
|
|
54
|
+
var DecodingMode;
|
|
55
|
+
(function(DecodingMode) {
|
|
56
|
+
/** Entities in text nodes that can end with any character. */
|
|
57
|
+
DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
|
|
58
|
+
/** Only allow entities terminated with a semicolon. */
|
|
59
|
+
DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
|
|
60
|
+
/** Entities in attributes have limitations on ending characters. */
|
|
61
|
+
DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
|
|
62
|
+
})(DecodingMode || (DecodingMode = {}));
|
|
63
|
+
/**
|
|
64
|
+
* Token decoder with support of writing partial entities.
|
|
65
|
+
*/
|
|
66
|
+
var EntityDecoder = class {
|
|
67
|
+
constructor(decodeTree, emitCodePoint, errors) {
|
|
68
|
+
this.decodeTree = decodeTree;
|
|
69
|
+
this.emitCodePoint = emitCodePoint;
|
|
70
|
+
this.errors = errors;
|
|
71
|
+
/** The current state of the decoder. */
|
|
72
|
+
this.state = EntityDecoderState.EntityStart;
|
|
73
|
+
/** Characters that were consumed while parsing an entity. */
|
|
74
|
+
this.consumed = 1;
|
|
75
|
+
/**
|
|
76
|
+
* The result of the entity.
|
|
77
|
+
*
|
|
78
|
+
* Either the result index of a numeric entity, or the codepoint of a
|
|
79
|
+
* numeric entity.
|
|
80
|
+
*/
|
|
81
|
+
this.result = 0;
|
|
82
|
+
/** The current index in the decode tree. */
|
|
83
|
+
this.treeIndex = 0;
|
|
84
|
+
/** The number of characters that were consumed in excess. */
|
|
85
|
+
this.excess = 1;
|
|
86
|
+
/** The mode in which the decoder is operating. */
|
|
87
|
+
this.decodeMode = DecodingMode.Strict;
|
|
88
|
+
}
|
|
89
|
+
/** Resets the instance to make it reusable. */
|
|
90
|
+
startEntity(decodeMode) {
|
|
91
|
+
this.decodeMode = decodeMode;
|
|
92
|
+
this.state = EntityDecoderState.EntityStart;
|
|
93
|
+
this.result = 0;
|
|
94
|
+
this.treeIndex = 0;
|
|
95
|
+
this.excess = 1;
|
|
96
|
+
this.consumed = 1;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
100
|
+
* If the entity is incomplete, the decoder will return -1.
|
|
101
|
+
*
|
|
102
|
+
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
|
103
|
+
* entity is incomplete, and resume when the next string is written.
|
|
104
|
+
*
|
|
105
|
+
* @param string The string containing the entity (or a continuation of the entity).
|
|
106
|
+
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
107
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
108
|
+
*/
|
|
109
|
+
write(str, offset) {
|
|
110
|
+
switch (this.state) {
|
|
111
|
+
case EntityDecoderState.EntityStart:
|
|
112
|
+
if (str.charCodeAt(offset) === CharCodes.NUM) {
|
|
113
|
+
this.state = EntityDecoderState.NumericStart;
|
|
114
|
+
this.consumed += 1;
|
|
115
|
+
return this.stateNumericStart(str, offset + 1);
|
|
116
|
+
}
|
|
117
|
+
this.state = EntityDecoderState.NamedEntity;
|
|
118
|
+
return this.stateNamedEntity(str, offset);
|
|
119
|
+
case EntityDecoderState.NumericStart: return this.stateNumericStart(str, offset);
|
|
120
|
+
case EntityDecoderState.NumericDecimal: return this.stateNumericDecimal(str, offset);
|
|
121
|
+
case EntityDecoderState.NumericHex: return this.stateNumericHex(str, offset);
|
|
122
|
+
case EntityDecoderState.NamedEntity: return this.stateNamedEntity(str, offset);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Switches between the numeric decimal and hexadecimal states.
|
|
127
|
+
*
|
|
128
|
+
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
129
|
+
*
|
|
130
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
131
|
+
* @param offset The current offset.
|
|
132
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
133
|
+
*/
|
|
134
|
+
stateNumericStart(str, offset) {
|
|
135
|
+
if (offset >= str.length) return -1;
|
|
136
|
+
if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
|
|
137
|
+
this.state = EntityDecoderState.NumericHex;
|
|
138
|
+
this.consumed += 1;
|
|
139
|
+
return this.stateNumericHex(str, offset + 1);
|
|
140
|
+
}
|
|
141
|
+
this.state = EntityDecoderState.NumericDecimal;
|
|
142
|
+
return this.stateNumericDecimal(str, offset);
|
|
143
|
+
}
|
|
144
|
+
addToNumericResult(str, start, end, base) {
|
|
145
|
+
if (start !== end) {
|
|
146
|
+
const digitCount = end - start;
|
|
147
|
+
this.result = this.result * Math.pow(base, digitCount) + parseInt(str.substr(start, digitCount), base);
|
|
148
|
+
this.consumed += digitCount;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Parses a hexadecimal numeric entity.
|
|
153
|
+
*
|
|
154
|
+
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
|
155
|
+
*
|
|
156
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
157
|
+
* @param offset The current offset.
|
|
158
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
159
|
+
*/
|
|
160
|
+
stateNumericHex(str, offset) {
|
|
161
|
+
const startIdx = offset;
|
|
162
|
+
while (offset < str.length) {
|
|
163
|
+
const char = str.charCodeAt(offset);
|
|
164
|
+
if (isNumber(char) || isHexadecimalCharacter(char)) offset += 1;
|
|
165
|
+
else {
|
|
166
|
+
this.addToNumericResult(str, startIdx, offset, 16);
|
|
167
|
+
return this.emitNumericEntity(char, 3);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
this.addToNumericResult(str, startIdx, offset, 16);
|
|
171
|
+
return -1;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parses a decimal numeric entity.
|
|
175
|
+
*
|
|
176
|
+
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
|
177
|
+
*
|
|
178
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
179
|
+
* @param offset The current offset.
|
|
180
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
181
|
+
*/
|
|
182
|
+
stateNumericDecimal(str, offset) {
|
|
183
|
+
const startIdx = offset;
|
|
184
|
+
while (offset < str.length) {
|
|
185
|
+
const char = str.charCodeAt(offset);
|
|
186
|
+
if (isNumber(char)) offset += 1;
|
|
187
|
+
else {
|
|
188
|
+
this.addToNumericResult(str, startIdx, offset, 10);
|
|
189
|
+
return this.emitNumericEntity(char, 2);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this.addToNumericResult(str, startIdx, offset, 10);
|
|
193
|
+
return -1;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Validate and emit a numeric entity.
|
|
197
|
+
*
|
|
198
|
+
* Implements the logic from the `Hexademical character reference start
|
|
199
|
+
* state` and `Numeric character reference end state` in the HTML spec.
|
|
200
|
+
*
|
|
201
|
+
* @param lastCp The last code point of the entity. Used to see if the
|
|
202
|
+
* entity was terminated with a semicolon.
|
|
203
|
+
* @param expectedLength The minimum number of characters that should be
|
|
204
|
+
* consumed. Used to validate that at least one digit
|
|
205
|
+
* was consumed.
|
|
206
|
+
* @returns The number of characters that were consumed.
|
|
207
|
+
*/
|
|
208
|
+
emitNumericEntity(lastCp, expectedLength) {
|
|
209
|
+
var _a;
|
|
210
|
+
if (this.consumed <= expectedLength) {
|
|
211
|
+
(_a = this.errors) === null || _a === void 0 || _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
212
|
+
return 0;
|
|
213
|
+
}
|
|
214
|
+
if (lastCp === CharCodes.SEMI) this.consumed += 1;
|
|
215
|
+
else if (this.decodeMode === DecodingMode.Strict) return 0;
|
|
216
|
+
this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
|
|
217
|
+
if (this.errors) {
|
|
218
|
+
if (lastCp !== CharCodes.SEMI) this.errors.missingSemicolonAfterCharacterReference();
|
|
219
|
+
this.errors.validateNumericCharacterReference(this.result);
|
|
220
|
+
}
|
|
221
|
+
return this.consumed;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Parses a named entity.
|
|
225
|
+
*
|
|
226
|
+
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
227
|
+
*
|
|
228
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
229
|
+
* @param offset The current offset.
|
|
230
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
231
|
+
*/
|
|
232
|
+
stateNamedEntity(str, offset) {
|
|
233
|
+
const { decodeTree } = this;
|
|
234
|
+
let current = decodeTree[this.treeIndex];
|
|
235
|
+
let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
236
|
+
for (; offset < str.length; offset++, this.excess++) {
|
|
237
|
+
const char = str.charCodeAt(offset);
|
|
238
|
+
this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
|
|
239
|
+
if (this.treeIndex < 0) return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
|
|
240
|
+
current = decodeTree[this.treeIndex];
|
|
241
|
+
valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
242
|
+
if (valueLength !== 0) {
|
|
243
|
+
if (char === CharCodes.SEMI) return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
|
|
244
|
+
if (this.decodeMode !== DecodingMode.Strict) {
|
|
245
|
+
this.result = this.treeIndex;
|
|
246
|
+
this.consumed += this.excess;
|
|
247
|
+
this.excess = 0;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return -1;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Emit a named entity that was not terminated with a semicolon.
|
|
255
|
+
*
|
|
256
|
+
* @returns The number of characters consumed.
|
|
257
|
+
*/
|
|
258
|
+
emitNotTerminatedNamedEntity() {
|
|
259
|
+
var _a;
|
|
260
|
+
const { result, decodeTree } = this;
|
|
261
|
+
const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
262
|
+
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|
263
|
+
(_a = this.errors) === null || _a === void 0 || _a.missingSemicolonAfterCharacterReference();
|
|
264
|
+
return this.consumed;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Emit a named entity.
|
|
268
|
+
*
|
|
269
|
+
* @param result The index of the entity in the decode tree.
|
|
270
|
+
* @param valueLength The number of bytes in the entity.
|
|
271
|
+
* @param consumed The number of characters consumed.
|
|
272
|
+
*
|
|
273
|
+
* @returns The number of characters consumed.
|
|
274
|
+
*/
|
|
275
|
+
emitNamedEntityData(result, valueLength, consumed) {
|
|
276
|
+
const { decodeTree } = this;
|
|
277
|
+
this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH : decodeTree[result + 1], consumed);
|
|
278
|
+
if (valueLength === 3) this.emitCodePoint(decodeTree[result + 2], consumed);
|
|
279
|
+
return consumed;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Signal to the parser that the end of the input was reached.
|
|
283
|
+
*
|
|
284
|
+
* Remaining data will be emitted and relevant errors will be produced.
|
|
285
|
+
*
|
|
286
|
+
* @returns The number of characters consumed.
|
|
287
|
+
*/
|
|
288
|
+
end() {
|
|
289
|
+
var _a;
|
|
290
|
+
switch (this.state) {
|
|
291
|
+
case EntityDecoderState.NamedEntity: return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
|
|
292
|
+
case EntityDecoderState.NumericDecimal: return this.emitNumericEntity(0, 2);
|
|
293
|
+
case EntityDecoderState.NumericHex: return this.emitNumericEntity(0, 3);
|
|
294
|
+
case EntityDecoderState.NumericStart:
|
|
295
|
+
(_a = this.errors) === null || _a === void 0 || _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
296
|
+
return 0;
|
|
297
|
+
case EntityDecoderState.EntityStart: return 0;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Creates a function that decodes entities in a string.
|
|
303
|
+
*
|
|
304
|
+
* @param decodeTree The decode tree.
|
|
305
|
+
* @returns A function that decodes entities in a string.
|
|
306
|
+
*/
|
|
307
|
+
function getDecoder(decodeTree) {
|
|
308
|
+
let ret = "";
|
|
309
|
+
const decoder = new EntityDecoder(decodeTree, (str) => ret += fromCodePoint(str));
|
|
310
|
+
return function decodeWithTrie(str, decodeMode) {
|
|
311
|
+
let lastIndex = 0;
|
|
312
|
+
let offset = 0;
|
|
313
|
+
while ((offset = str.indexOf("&", offset)) >= 0) {
|
|
314
|
+
ret += str.slice(lastIndex, offset);
|
|
315
|
+
decoder.startEntity(decodeMode);
|
|
316
|
+
const len = decoder.write(str, offset + 1);
|
|
317
|
+
if (len < 0) {
|
|
318
|
+
lastIndex = offset + decoder.end();
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
lastIndex = offset + len;
|
|
322
|
+
offset = len === 0 ? lastIndex + 1 : lastIndex;
|
|
323
|
+
}
|
|
324
|
+
const result = ret + str.slice(lastIndex);
|
|
325
|
+
ret = "";
|
|
326
|
+
return result;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Determines the branch of the current node that is taken given the current
|
|
331
|
+
* character. This function is used to traverse the trie.
|
|
332
|
+
*
|
|
333
|
+
* @param decodeTree The trie.
|
|
334
|
+
* @param current The current node.
|
|
335
|
+
* @param nodeIdx The index right after the current node and its value.
|
|
336
|
+
* @param char The current character.
|
|
337
|
+
* @returns The index of the next node, or -1 if no branch is taken.
|
|
338
|
+
*/
|
|
339
|
+
function determineBranch(decodeTree, current, nodeIdx, char) {
|
|
340
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
341
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
342
|
+
if (branchCount === 0) return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
|
|
343
|
+
if (jumpOffset) {
|
|
344
|
+
const value = char - jumpOffset;
|
|
345
|
+
return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIdx + value] - 1;
|
|
346
|
+
}
|
|
347
|
+
let lo = nodeIdx;
|
|
348
|
+
let hi = lo + branchCount - 1;
|
|
349
|
+
while (lo <= hi) {
|
|
350
|
+
const mid = lo + hi >>> 1;
|
|
351
|
+
const midVal = decodeTree[mid];
|
|
352
|
+
if (midVal < char) lo = mid + 1;
|
|
353
|
+
else if (midVal > char) hi = mid - 1;
|
|
354
|
+
else return decodeTree[mid + branchCount];
|
|
355
|
+
}
|
|
356
|
+
return -1;
|
|
357
|
+
}
|
|
358
|
+
getDecoder(decode_data_html_default);
|
|
359
|
+
getDecoder(decode_data_xml_default);
|
|
360
|
+
//#endregion
|
|
361
|
+
export { BinTrieFlags, DecodingMode, EntityDecoder, determineBranch, fromCodePoint, decode_data_html_default as htmlDecodeTree, replaceCodePoint, decode_data_xml_default as xmlDecodeTree };
|
|
362
|
+
|
|
363
|
+
//# sourceMappingURL=decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.js","names":["htmlDecodeTree","xmlDecodeTree"],"sources":["../../../../../../../node_modules/entities/lib/esm/decode.js"],"sourcesContent":["import htmlDecodeTree from \"./generated/decode-data-html.js\";\nimport xmlDecodeTree from \"./generated/decode-data-xml.js\";\nimport decodeCodePoint, { replaceCodePoint, fromCodePoint, } from \"./decode_codepoint.js\";\n// Re-export for use by eg. htmlparser2\nexport { htmlDecodeTree, xmlDecodeTree, decodeCodePoint };\nexport { replaceCodePoint, fromCodePoint } from \"./decode_codepoint.js\";\nvar CharCodes;\n(function (CharCodes) {\n CharCodes[CharCodes[\"NUM\"] = 35] = \"NUM\";\n CharCodes[CharCodes[\"SEMI\"] = 59] = \"SEMI\";\n CharCodes[CharCodes[\"EQUALS\"] = 61] = \"EQUALS\";\n CharCodes[CharCodes[\"ZERO\"] = 48] = \"ZERO\";\n CharCodes[CharCodes[\"NINE\"] = 57] = \"NINE\";\n CharCodes[CharCodes[\"LOWER_A\"] = 97] = \"LOWER_A\";\n CharCodes[CharCodes[\"LOWER_F\"] = 102] = \"LOWER_F\";\n CharCodes[CharCodes[\"LOWER_X\"] = 120] = \"LOWER_X\";\n CharCodes[CharCodes[\"LOWER_Z\"] = 122] = \"LOWER_Z\";\n CharCodes[CharCodes[\"UPPER_A\"] = 65] = \"UPPER_A\";\n CharCodes[CharCodes[\"UPPER_F\"] = 70] = \"UPPER_F\";\n CharCodes[CharCodes[\"UPPER_Z\"] = 90] = \"UPPER_Z\";\n})(CharCodes || (CharCodes = {}));\n/** Bit that needs to be set to convert an upper case ASCII character to lower case */\nconst TO_LOWER_BIT = 0b100000;\nexport var BinTrieFlags;\n(function (BinTrieFlags) {\n BinTrieFlags[BinTrieFlags[\"VALUE_LENGTH\"] = 49152] = \"VALUE_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"BRANCH_LENGTH\"] = 16256] = \"BRANCH_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"JUMP_TABLE\"] = 127] = \"JUMP_TABLE\";\n})(BinTrieFlags || (BinTrieFlags = {}));\nfunction isNumber(code) {\n return code >= CharCodes.ZERO && code <= CharCodes.NINE;\n}\nfunction isHexadecimalCharacter(code) {\n return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||\n (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));\n}\nfunction isAsciiAlphaNumeric(code) {\n return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||\n (code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||\n isNumber(code));\n}\n/**\n * Checks if the given character is a valid end character for an entity in an attribute.\n *\n * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.\n * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state\n */\nfunction isEntityInAttributeInvalidEnd(code) {\n return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);\n}\nvar EntityDecoderState;\n(function (EntityDecoderState) {\n EntityDecoderState[EntityDecoderState[\"EntityStart\"] = 0] = \"EntityStart\";\n EntityDecoderState[EntityDecoderState[\"NumericStart\"] = 1] = \"NumericStart\";\n EntityDecoderState[EntityDecoderState[\"NumericDecimal\"] = 2] = \"NumericDecimal\";\n EntityDecoderState[EntityDecoderState[\"NumericHex\"] = 3] = \"NumericHex\";\n EntityDecoderState[EntityDecoderState[\"NamedEntity\"] = 4] = \"NamedEntity\";\n})(EntityDecoderState || (EntityDecoderState = {}));\nexport var DecodingMode;\n(function (DecodingMode) {\n /** Entities in text nodes that can end with any character. */\n DecodingMode[DecodingMode[\"Legacy\"] = 0] = \"Legacy\";\n /** Only allow entities terminated with a semicolon. */\n DecodingMode[DecodingMode[\"Strict\"] = 1] = \"Strict\";\n /** Entities in attributes have limitations on ending characters. */\n DecodingMode[DecodingMode[\"Attribute\"] = 2] = \"Attribute\";\n})(DecodingMode || (DecodingMode = {}));\n/**\n * Token decoder with support of writing partial entities.\n */\nexport class EntityDecoder {\n constructor(\n /** The tree used to decode entities. */\n decodeTree, \n /**\n * The function that is called when a codepoint is decoded.\n *\n * For multi-byte named entities, this will be called multiple times,\n * with the second codepoint, and the same `consumed` value.\n *\n * @param codepoint The decoded codepoint.\n * @param consumed The number of bytes consumed by the decoder.\n */\n emitCodePoint, \n /** An object that is used to produce errors. */\n errors) {\n this.decodeTree = decodeTree;\n this.emitCodePoint = emitCodePoint;\n this.errors = errors;\n /** The current state of the decoder. */\n this.state = EntityDecoderState.EntityStart;\n /** Characters that were consumed while parsing an entity. */\n this.consumed = 1;\n /**\n * The result of the entity.\n *\n * Either the result index of a numeric entity, or the codepoint of a\n * numeric entity.\n */\n this.result = 0;\n /** The current index in the decode tree. */\n this.treeIndex = 0;\n /** The number of characters that were consumed in excess. */\n this.excess = 1;\n /** The mode in which the decoder is operating. */\n this.decodeMode = DecodingMode.Strict;\n }\n /** Resets the instance to make it reusable. */\n startEntity(decodeMode) {\n this.decodeMode = decodeMode;\n this.state = EntityDecoderState.EntityStart;\n this.result = 0;\n this.treeIndex = 0;\n this.excess = 1;\n this.consumed = 1;\n }\n /**\n * Write an entity to the decoder. This can be called multiple times with partial entities.\n * If the entity is incomplete, the decoder will return -1.\n *\n * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the\n * entity is incomplete, and resume when the next string is written.\n *\n * @param string The string containing the entity (or a continuation of the entity).\n * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n write(str, offset) {\n switch (this.state) {\n case EntityDecoderState.EntityStart: {\n if (str.charCodeAt(offset) === CharCodes.NUM) {\n this.state = EntityDecoderState.NumericStart;\n this.consumed += 1;\n return this.stateNumericStart(str, offset + 1);\n }\n this.state = EntityDecoderState.NamedEntity;\n return this.stateNamedEntity(str, offset);\n }\n case EntityDecoderState.NumericStart: {\n return this.stateNumericStart(str, offset);\n }\n case EntityDecoderState.NumericDecimal: {\n return this.stateNumericDecimal(str, offset);\n }\n case EntityDecoderState.NumericHex: {\n return this.stateNumericHex(str, offset);\n }\n case EntityDecoderState.NamedEntity: {\n return this.stateNamedEntity(str, offset);\n }\n }\n }\n /**\n * Switches between the numeric decimal and hexadecimal states.\n *\n * Equivalent to the `Numeric character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericStart(str, offset) {\n if (offset >= str.length) {\n return -1;\n }\n if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {\n this.state = EntityDecoderState.NumericHex;\n this.consumed += 1;\n return this.stateNumericHex(str, offset + 1);\n }\n this.state = EntityDecoderState.NumericDecimal;\n return this.stateNumericDecimal(str, offset);\n }\n addToNumericResult(str, start, end, base) {\n if (start !== end) {\n const digitCount = end - start;\n this.result =\n this.result * Math.pow(base, digitCount) +\n parseInt(str.substr(start, digitCount), base);\n this.consumed += digitCount;\n }\n }\n /**\n * Parses a hexadecimal numeric entity.\n *\n * Equivalent to the `Hexademical character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericHex(str, offset) {\n const startIdx = offset;\n while (offset < str.length) {\n const char = str.charCodeAt(offset);\n if (isNumber(char) || isHexadecimalCharacter(char)) {\n offset += 1;\n }\n else {\n this.addToNumericResult(str, startIdx, offset, 16);\n return this.emitNumericEntity(char, 3);\n }\n }\n this.addToNumericResult(str, startIdx, offset, 16);\n return -1;\n }\n /**\n * Parses a decimal numeric entity.\n *\n * Equivalent to the `Decimal character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericDecimal(str, offset) {\n const startIdx = offset;\n while (offset < str.length) {\n const char = str.charCodeAt(offset);\n if (isNumber(char)) {\n offset += 1;\n }\n else {\n this.addToNumericResult(str, startIdx, offset, 10);\n return this.emitNumericEntity(char, 2);\n }\n }\n this.addToNumericResult(str, startIdx, offset, 10);\n return -1;\n }\n /**\n * Validate and emit a numeric entity.\n *\n * Implements the logic from the `Hexademical character reference start\n * state` and `Numeric character reference end state` in the HTML spec.\n *\n * @param lastCp The last code point of the entity. Used to see if the\n * entity was terminated with a semicolon.\n * @param expectedLength The minimum number of characters that should be\n * consumed. Used to validate that at least one digit\n * was consumed.\n * @returns The number of characters that were consumed.\n */\n emitNumericEntity(lastCp, expectedLength) {\n var _a;\n // Ensure we consumed at least one digit.\n if (this.consumed <= expectedLength) {\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n // Figure out if this is a legit end of the entity\n if (lastCp === CharCodes.SEMI) {\n this.consumed += 1;\n }\n else if (this.decodeMode === DecodingMode.Strict) {\n return 0;\n }\n this.emitCodePoint(replaceCodePoint(this.result), this.consumed);\n if (this.errors) {\n if (lastCp !== CharCodes.SEMI) {\n this.errors.missingSemicolonAfterCharacterReference();\n }\n this.errors.validateNumericCharacterReference(this.result);\n }\n return this.consumed;\n }\n /**\n * Parses a named entity.\n *\n * Equivalent to the `Named character reference state` in the HTML spec.\n *\n * @param str The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNamedEntity(str, offset) {\n const { decodeTree } = this;\n let current = decodeTree[this.treeIndex];\n // The mask is the number of bytes of the value, including the current byte.\n let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;\n for (; offset < str.length; offset++, this.excess++) {\n const char = str.charCodeAt(offset);\n this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);\n if (this.treeIndex < 0) {\n return this.result === 0 ||\n // If we are parsing an attribute\n (this.decodeMode === DecodingMode.Attribute &&\n // We shouldn't have consumed any characters after the entity,\n (valueLength === 0 ||\n // And there should be no invalid characters.\n isEntityInAttributeInvalidEnd(char)))\n ? 0\n : this.emitNotTerminatedNamedEntity();\n }\n current = decodeTree[this.treeIndex];\n valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;\n // If the branch is a value, store it and continue\n if (valueLength !== 0) {\n // If the entity is terminated by a semicolon, we are done.\n if (char === CharCodes.SEMI) {\n return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);\n }\n // If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.\n if (this.decodeMode !== DecodingMode.Strict) {\n this.result = this.treeIndex;\n this.consumed += this.excess;\n this.excess = 0;\n }\n }\n }\n return -1;\n }\n /**\n * Emit a named entity that was not terminated with a semicolon.\n *\n * @returns The number of characters consumed.\n */\n emitNotTerminatedNamedEntity() {\n var _a;\n const { result, decodeTree } = this;\n const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;\n this.emitNamedEntityData(result, valueLength, this.consumed);\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();\n return this.consumed;\n }\n /**\n * Emit a named entity.\n *\n * @param result The index of the entity in the decode tree.\n * @param valueLength The number of bytes in the entity.\n * @param consumed The number of characters consumed.\n *\n * @returns The number of characters consumed.\n */\n emitNamedEntityData(result, valueLength, consumed) {\n const { decodeTree } = this;\n this.emitCodePoint(valueLength === 1\n ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH\n : decodeTree[result + 1], consumed);\n if (valueLength === 3) {\n // For multi-byte values, we need to emit the second byte.\n this.emitCodePoint(decodeTree[result + 2], consumed);\n }\n return consumed;\n }\n /**\n * Signal to the parser that the end of the input was reached.\n *\n * Remaining data will be emitted and relevant errors will be produced.\n *\n * @returns The number of characters consumed.\n */\n end() {\n var _a;\n switch (this.state) {\n case EntityDecoderState.NamedEntity: {\n // Emit a named entity if we have one.\n return this.result !== 0 &&\n (this.decodeMode !== DecodingMode.Attribute ||\n this.result === this.treeIndex)\n ? this.emitNotTerminatedNamedEntity()\n : 0;\n }\n // Otherwise, emit a numeric entity if we have one.\n case EntityDecoderState.NumericDecimal: {\n return this.emitNumericEntity(0, 2);\n }\n case EntityDecoderState.NumericHex: {\n return this.emitNumericEntity(0, 3);\n }\n case EntityDecoderState.NumericStart: {\n (_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n case EntityDecoderState.EntityStart: {\n // Return 0 if we have no entity.\n return 0;\n }\n }\n }\n}\n/**\n * Creates a function that decodes entities in a string.\n *\n * @param decodeTree The decode tree.\n * @returns A function that decodes entities in a string.\n */\nfunction getDecoder(decodeTree) {\n let ret = \"\";\n const decoder = new EntityDecoder(decodeTree, (str) => (ret += fromCodePoint(str)));\n return function decodeWithTrie(str, decodeMode) {\n let lastIndex = 0;\n let offset = 0;\n while ((offset = str.indexOf(\"&\", offset)) >= 0) {\n ret += str.slice(lastIndex, offset);\n decoder.startEntity(decodeMode);\n const len = decoder.write(str, \n // Skip the \"&\"\n offset + 1);\n if (len < 0) {\n lastIndex = offset + decoder.end();\n break;\n }\n lastIndex = offset + len;\n // If `len` is 0, skip the current `&` and continue.\n offset = len === 0 ? lastIndex + 1 : lastIndex;\n }\n const result = ret + str.slice(lastIndex);\n // Make sure we don't keep a reference to the final string.\n ret = \"\";\n return result;\n };\n}\n/**\n * Determines the branch of the current node that is taken given the current\n * character. This function is used to traverse the trie.\n *\n * @param decodeTree The trie.\n * @param current The current node.\n * @param nodeIdx The index right after the current node and its value.\n * @param char The current character.\n * @returns The index of the next node, or -1 if no branch is taken.\n */\nexport function determineBranch(decodeTree, current, nodeIdx, char) {\n const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;\n const jumpOffset = current & BinTrieFlags.JUMP_TABLE;\n // Case 1: Single branch encoded in jump offset\n if (branchCount === 0) {\n return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;\n }\n // Case 2: Multiple branches encoded in jump table\n if (jumpOffset) {\n const value = char - jumpOffset;\n return value < 0 || value >= branchCount\n ? -1\n : decodeTree[nodeIdx + value] - 1;\n }\n // Case 3: Multiple branches encoded in dictionary\n // Binary search for the character.\n let lo = nodeIdx;\n let hi = lo + branchCount - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >>> 1;\n const midVal = decodeTree[mid];\n if (midVal < char) {\n lo = mid + 1;\n }\n else if (midVal > char) {\n hi = mid - 1;\n }\n else {\n return decodeTree[mid + branchCount];\n }\n }\n return -1;\n}\nconst htmlDecoder = getDecoder(htmlDecodeTree);\nconst xmlDecoder = getDecoder(xmlDecodeTree);\n/**\n * Decodes an HTML string.\n *\n * @param str The string to decode.\n * @param mode The decoding mode.\n * @returns The decoded string.\n */\nexport function decodeHTML(str, mode = DecodingMode.Legacy) {\n return htmlDecoder(str, mode);\n}\n/**\n * Decodes an HTML string in an attribute.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLAttribute(str) {\n return htmlDecoder(str, DecodingMode.Attribute);\n}\n/**\n * Decodes an HTML string, requiring all entities to be terminated by a semicolon.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLStrict(str) {\n return htmlDecoder(str, DecodingMode.Strict);\n}\n/**\n * Decodes an XML string, requiring all entities to be terminated by a semicolon.\n *\n * @param str The string to decode.\n * @returns The decoded string.\n */\nexport function decodeXML(str) {\n return xmlDecoder(str, DecodingMode.Strict);\n}\n//# sourceMappingURL=decode.js.map"],"x_google_ignoreList":[0],"mappings":";;;;AAMA,IAAI;CACH,SAAU,WAAW;CAClB,UAAU,UAAU,SAAS,MAAM;CACnC,UAAU,UAAU,UAAU,MAAM;CACpC,UAAU,UAAU,YAAY,MAAM;CACtC,UAAU,UAAU,UAAU,MAAM;CACpC,UAAU,UAAU,UAAU,MAAM;CACpC,UAAU,UAAU,aAAa,MAAM;CACvC,UAAU,UAAU,aAAa,OAAO;CACxC,UAAU,UAAU,aAAa,OAAO;CACxC,UAAU,UAAU,aAAa,OAAO;CACxC,UAAU,UAAU,aAAa,MAAM;CACvC,UAAU,UAAU,aAAa,MAAM;CACvC,UAAU,UAAU,aAAa,MAAM;AAC3C,EAAA,CAAG,cAAc,YAAY,CAAC,EAAE;;AAEhC,MAAM,eAAe;AACrB,IAAW;CACV,SAAU,cAAc;CACrB,aAAa,aAAa,kBAAkB,SAAS;CACrD,aAAa,aAAa,mBAAmB,SAAS;CACtD,aAAa,aAAa,g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AM,IAAI;EACb,MAAM,MAAO,KAAK,OAAQ;EAC1B,MAAM,SAAS,WAAW;EAC1B,IAAI,SAAS,MACT,KAAK,MAAM;OAEV,IAAI,SAAS,MACd,KAAK,MAAM;OAGX,OAAO,WAAW,MAAM;CAEhC;CACA,OAAO;AACX;AACoB,WAAWA,wBAAc;AAC1B,WAAWC,uBAAa"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region ../../node_modules/entities/lib/esm/decode_codepoint.js
|
|
2
|
+
var _a;
|
|
3
|
+
const decodeMap = /* @__PURE__ */ new Map([
|
|
4
|
+
[0, 65533],
|
|
5
|
+
[128, 8364],
|
|
6
|
+
[130, 8218],
|
|
7
|
+
[131, 402],
|
|
8
|
+
[132, 8222],
|
|
9
|
+
[133, 8230],
|
|
10
|
+
[134, 8224],
|
|
11
|
+
[135, 8225],
|
|
12
|
+
[136, 710],
|
|
13
|
+
[137, 8240],
|
|
14
|
+
[138, 352],
|
|
15
|
+
[139, 8249],
|
|
16
|
+
[140, 338],
|
|
17
|
+
[142, 381],
|
|
18
|
+
[145, 8216],
|
|
19
|
+
[146, 8217],
|
|
20
|
+
[147, 8220],
|
|
21
|
+
[148, 8221],
|
|
22
|
+
[149, 8226],
|
|
23
|
+
[150, 8211],
|
|
24
|
+
[151, 8212],
|
|
25
|
+
[152, 732],
|
|
26
|
+
[153, 8482],
|
|
27
|
+
[154, 353],
|
|
28
|
+
[155, 8250],
|
|
29
|
+
[156, 339],
|
|
30
|
+
[158, 382],
|
|
31
|
+
[159, 376]
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
|
|
35
|
+
*/
|
|
36
|
+
const fromCodePoint = (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function(codePoint) {
|
|
37
|
+
let output = "";
|
|
38
|
+
if (codePoint > 65535) {
|
|
39
|
+
codePoint -= 65536;
|
|
40
|
+
output += String.fromCharCode(codePoint >>> 10 & 1023 | 55296);
|
|
41
|
+
codePoint = 56320 | codePoint & 1023;
|
|
42
|
+
}
|
|
43
|
+
output += String.fromCharCode(codePoint);
|
|
44
|
+
return output;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Replace the given code point with a replacement character if it is a
|
|
48
|
+
* surrogate or is outside the valid range. Otherwise return the code
|
|
49
|
+
* point unchanged.
|
|
50
|
+
*/
|
|
51
|
+
function replaceCodePoint(codePoint) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) return 65533;
|
|
54
|
+
return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { fromCodePoint, replaceCodePoint };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=decode_codepoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode_codepoint.js","names":[],"sources":["../../../../../../../node_modules/entities/lib/esm/decode_codepoint.js"],"sourcesContent":["// Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134\nvar _a;\nconst decodeMap = new Map([\n [0, 65533],\n // C1 Unicode control character reference replacements\n [128, 8364],\n [130, 8218],\n [131, 402],\n [132, 8222],\n [133, 8230],\n [134, 8224],\n [135, 8225],\n [136, 710],\n [137, 8240],\n [138, 352],\n [139, 8249],\n [140, 338],\n [142, 381],\n [145, 8216],\n [146, 8217],\n [147, 8220],\n [148, 8221],\n [149, 8226],\n [150, 8211],\n [151, 8212],\n [152, 732],\n [153, 8482],\n [154, 353],\n [155, 8250],\n [156, 339],\n [158, 382],\n [159, 376],\n]);\n/**\n * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.\n */\nexport const fromCodePoint = \n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins\n(_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function (codePoint) {\n let output = \"\";\n if (codePoint > 0xffff) {\n codePoint -= 0x10000;\n output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);\n codePoint = 0xdc00 | (codePoint & 0x3ff);\n }\n output += String.fromCharCode(codePoint);\n return output;\n};\n/**\n * Replace the given code point with a replacement character if it is a\n * surrogate or is outside the valid range. Otherwise return the code\n * point unchanged.\n */\nexport function replaceCodePoint(codePoint) {\n var _a;\n if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {\n return 0xfffd;\n }\n return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;\n}\n/**\n * Replace the code point if relevant, then convert it to a string.\n *\n * @deprecated Use `fromCodePoint(replaceCodePoint(codePoint))` instead.\n * @param codePoint The code point to decode.\n * @returns The decoded code point.\n */\nexport default function decodeCodePoint(codePoint) {\n return fromCodePoint(replaceCodePoint(codePoint));\n}\n//# sourceMappingURL=decode_codepoint.js.map"],"x_google_ignoreList":[0],"mappings":";AACA,IAAI;AACJ,MAAM,4BAAY,IAAI,IAAI;CACtB,CAAC,GAAG,KAAK;CAET,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,IAAI;CACV,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,GAAG;CACT,CAAC,KAAK,GAAG;AACb,CAAC;;;;AAID,MAAa,iBAEZ,KAAK,OAAO,mBAAmB,QAAQ,OAAO,KAAK,IAAI,KAAK,SAAU,WAAW;CAC9E,IAAI,SAAS;CACb,IAAI,YAAY,OAAQ;EACpB,aAAa;EACb,UAAU,OAAO,aAAe,cAAc,KAAM,OAAS,KAAM;EACnE,YAAY,QAAU,YAAY;CACtC;CACA,UAAU,OAAO,aAAa,SAAS;CACvC,OAAO;AACX;;;;;;AAMA,SAAgB,iBAAiB,WAAW;CACxC,IAAI;CACJ,IAAK,aAAa,SAAU,aAAa,SAAW,YAAY,SAC5D,OAAO;CAEX,QAAQ,KAAK,UAAU,IAAI,SAAS,OAAO,QAAQ,OAAO,KAAK,IAAI,KAAK;AAC5E"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//#region ../../node_modules/entities/lib/esm/escape.js
|
|
2
|
+
const xmlReplacer = /["&'<>$\x80-\uFFFF]/g;
|
|
3
|
+
const xmlCodeMap = /* @__PURE__ */ new Map([
|
|
4
|
+
[34, """],
|
|
5
|
+
[38, "&"],
|
|
6
|
+
[39, "'"],
|
|
7
|
+
[60, "<"],
|
|
8
|
+
[62, ">"]
|
|
9
|
+
]);
|
|
10
|
+
const getCodePoint = String.prototype.codePointAt != null ? (str, index) => str.codePointAt(index) : (c, index) => (c.charCodeAt(index) & 64512) === 55296 ? (c.charCodeAt(index) - 55296) * 1024 + c.charCodeAt(index + 1) - 56320 + 65536 : c.charCodeAt(index);
|
|
11
|
+
/**
|
|
12
|
+
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
|
13
|
+
* documents using XML entities.
|
|
14
|
+
*
|
|
15
|
+
* If a character has no equivalent entity, a
|
|
16
|
+
* numeric hexadecimal reference (eg. `ü`) will be used.
|
|
17
|
+
*/
|
|
18
|
+
function encodeXML(str) {
|
|
19
|
+
let ret = "";
|
|
20
|
+
let lastIdx = 0;
|
|
21
|
+
let match;
|
|
22
|
+
while ((match = xmlReplacer.exec(str)) !== null) {
|
|
23
|
+
const i = match.index;
|
|
24
|
+
const char = str.charCodeAt(i);
|
|
25
|
+
const next = xmlCodeMap.get(char);
|
|
26
|
+
if (next !== void 0) {
|
|
27
|
+
ret += str.substring(lastIdx, i) + next;
|
|
28
|
+
lastIdx = i + 1;
|
|
29
|
+
} else {
|
|
30
|
+
ret += `${str.substring(lastIdx, i)}&#x${getCodePoint(str, i).toString(16)};`;
|
|
31
|
+
lastIdx = xmlReplacer.lastIndex += Number((char & 64512) === 55296);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return ret + str.substr(lastIdx);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a function that escapes all characters matched by the given regular
|
|
38
|
+
* expression using the given map of characters to escape to their entities.
|
|
39
|
+
*
|
|
40
|
+
* @param regex Regular expression to match characters to escape.
|
|
41
|
+
* @param map Map of characters to escape to their entities.
|
|
42
|
+
*
|
|
43
|
+
* @returns Function that escapes all characters matched by the given regular
|
|
44
|
+
* expression using the given map of characters to escape to their entities.
|
|
45
|
+
*/
|
|
46
|
+
function getEscaper(regex, map) {
|
|
47
|
+
return function escape(data) {
|
|
48
|
+
let match;
|
|
49
|
+
let lastIdx = 0;
|
|
50
|
+
let result = "";
|
|
51
|
+
while (match = regex.exec(data)) {
|
|
52
|
+
if (lastIdx !== match.index) result += data.substring(lastIdx, match.index);
|
|
53
|
+
result += map.get(match[0].charCodeAt(0));
|
|
54
|
+
lastIdx = match.index + 1;
|
|
55
|
+
}
|
|
56
|
+
return result + data.substring(lastIdx);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Encodes all characters that have to be escaped in HTML attributes,
|
|
61
|
+
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
62
|
+
*
|
|
63
|
+
* @param data String to escape.
|
|
64
|
+
*/
|
|
65
|
+
const escapeAttribute = getEscaper(/["&\u00A0]/g, /* @__PURE__ */ new Map([
|
|
66
|
+
[34, """],
|
|
67
|
+
[38, "&"],
|
|
68
|
+
[160, " "]
|
|
69
|
+
]));
|
|
70
|
+
/**
|
|
71
|
+
* Encodes all characters that have to be escaped in HTML text,
|
|
72
|
+
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
73
|
+
*
|
|
74
|
+
* @param data String to escape.
|
|
75
|
+
*/
|
|
76
|
+
const escapeText = getEscaper(/[&<>\u00A0]/g, /* @__PURE__ */ new Map([
|
|
77
|
+
[38, "&"],
|
|
78
|
+
[60, "<"],
|
|
79
|
+
[62, ">"],
|
|
80
|
+
[160, " "]
|
|
81
|
+
]));
|
|
82
|
+
//#endregion
|
|
83
|
+
export { encodeXML, escapeAttribute, escapeText, getCodePoint, xmlReplacer };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=escape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape.js","names":[],"sources":["../../../../../../../node_modules/entities/lib/esm/escape.js"],"sourcesContent":["export const xmlReplacer = /[\"&'<>$\\x80-\\uFFFF]/g;\nconst xmlCodeMap = new Map([\n [34, \""\"],\n [38, \"&\"],\n [39, \"'\"],\n [60, \"<\"],\n [62, \">\"],\n]);\n// For compatibility with node < 4, we wrap `codePointAt`\nexport const getCodePoint = \n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nString.prototype.codePointAt != null\n ? (str, index) => str.codePointAt(index)\n : // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\n (c, index) => (c.charCodeAt(index) & 0xfc00) === 0xd800\n ? (c.charCodeAt(index) - 0xd800) * 0x400 +\n c.charCodeAt(index + 1) -\n 0xdc00 +\n 0x10000\n : c.charCodeAt(index);\n/**\n * Encodes all non-ASCII characters, as well as characters not valid in XML\n * documents using XML entities.\n *\n * If a character has no equivalent entity, a\n * numeric hexadecimal reference (eg. `ü`) will be used.\n */\nexport function encodeXML(str) {\n let ret = \"\";\n let lastIdx = 0;\n let match;\n while ((match = xmlReplacer.exec(str)) !== null) {\n const i = match.index;\n const char = str.charCodeAt(i);\n const next = xmlCodeMap.get(char);\n if (next !== undefined) {\n ret += str.substring(lastIdx, i) + next;\n lastIdx = i + 1;\n }\n else {\n ret += `${str.substring(lastIdx, i)}&#x${getCodePoint(str, i).toString(16)};`;\n // Increase by 1 if we have a surrogate pair\n lastIdx = xmlReplacer.lastIndex += Number((char & 0xfc00) === 0xd800);\n }\n }\n return ret + str.substr(lastIdx);\n}\n/**\n * Encodes all non-ASCII characters, as well as characters not valid in XML\n * documents using numeric hexadecimal reference (eg. `ü`).\n *\n * Have a look at `escapeUTF8` if you want a more concise output at the expense\n * of reduced transportability.\n *\n * @param data String to escape.\n */\nexport const escape = encodeXML;\n/**\n * Creates a function that escapes all characters matched by the given regular\n * expression using the given map of characters to escape to their entities.\n *\n * @param regex Regular expression to match characters to escape.\n * @param map Map of characters to escape to their entities.\n *\n * @returns Function that escapes all characters matched by the given regular\n * expression using the given map of characters to escape to their entities.\n */\nfunction getEscaper(regex, map) {\n return function escape(data) {\n let match;\n let lastIdx = 0;\n let result = \"\";\n while ((match = regex.exec(data))) {\n if (lastIdx !== match.index) {\n result += data.substring(lastIdx, match.index);\n }\n // We know that this character will be in the map.\n result += map.get(match[0].charCodeAt(0));\n // Every match will be of length 1\n lastIdx = match.index + 1;\n }\n return result + data.substring(lastIdx);\n };\n}\n/**\n * Encodes all characters not valid in XML documents using XML entities.\n *\n * Note that the output will be character-set dependent.\n *\n * @param data String to escape.\n */\nexport const escapeUTF8 = getEscaper(/[&<>'\"]/g, xmlCodeMap);\n/**\n * Encodes all characters that have to be escaped in HTML attributes,\n * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.\n *\n * @param data String to escape.\n */\nexport const escapeAttribute = getEscaper(/[\"&\\u00A0]/g, new Map([\n [34, \""\"],\n [38, \"&\"],\n [160, \" \"],\n]));\n/**\n * Encodes all characters that have to be escaped in HTML text,\n * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.\n *\n * @param data String to escape.\n */\nexport const escapeText = getEscaper(/[&<>\\u00A0]/g, new Map([\n [38, \"&\"],\n [60, \"<\"],\n [62, \">\"],\n [160, \" \"],\n]));\n//# sourceMappingURL=escape.js.map"],"x_google_ignoreList":[0],"mappings":";AAAA,MAAa,cAAc;AAC3B,MAAM,6BAAa,IAAI,IAAI;CACvB,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,OAAO;CACZ,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,MAAM;CACX,CAAC,IAAI,MAAM;AACf,CAAC;AAED,MAAa,eAEb,OAAO,UAAU,eAAe,QACzB,KAAK,UAAU,IAAI,YAAY,KAAK,KAElC,GAAG,WAAW,EAAE,WAAW,KAAK,IAAI,WAAY,SAC1C,EAAE,WAAW,KAAK,IAAI,SAAU,OAC/B,EAAE,WAAW,QAAQ,CAAC,IACtB,QACA,QACF,EAAE,WAAW,KAAK;;;;;;;;AAQhC,SAAgB,UAAU,KAAK;CAC3B,IAAI,MAAM;CACV,IAAI,UAAU;CACd,IAAI;CACJ,QAAQ,QAAQ,YAAY,KAAK,GAAG,OAAO,MAAM;EAC7C,MAAM,IAAI,MAAM;EAChB,MAAM,OAAO,IAAI,WAAW,CAAC;EAC7B,MAAM,OAAO,WAAW,IAAI,IAAI;EAChC,IAAI,SAAS,KAAA,GAAW;GACpB,OAAO,IAAI,UAAU,SAAS,CAAC,IAAI;GACnC,UAAU,IAAI;EAClB,OACK;GACD,OAAO,GAAG,IAAI,UAAU,SAAS,CAAC,EAAE,KAAK,aAAa,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE;GAE3E,UAAU,YAAY,aAAa,QAAQ,OAAO,WAAY,KAAM;EACxE;CACJ;CACA,OAAO,MAAM,IAAI,OAAO,OAAO;AACnC;;;;;;;;;;;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