From afa87af01c79a9baa539f2992d32154d2a4739bd Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 14 Feb 2026 14:46:37 -0800 Subject: task: delete vanilla js prototype\n\n- Removed vanilla/ directory and web/dist/vanilla directory\n- Updated Makefile, Dockerfile, and CI workflow to remove vanilla references\n- Cleaned up web/web.go to remove vanilla embed and routes\n- Verified build and tests pass\n\nCloses NK-2tcnmq --- vanilla/node_modules/data-urls/LICENSE.txt | 7 --- vanilla/node_modules/data-urls/README.md | 66 -------------------------- vanilla/node_modules/data-urls/lib/parser.js | 69 ---------------------------- vanilla/node_modules/data-urls/lib/utils.js | 20 -------- vanilla/node_modules/data-urls/package.json | 51 -------------------- 5 files changed, 213 deletions(-) delete mode 100644 vanilla/node_modules/data-urls/LICENSE.txt delete mode 100644 vanilla/node_modules/data-urls/README.md delete mode 100644 vanilla/node_modules/data-urls/lib/parser.js delete mode 100644 vanilla/node_modules/data-urls/lib/utils.js delete mode 100644 vanilla/node_modules/data-urls/package.json (limited to 'vanilla/node_modules/data-urls') diff --git a/vanilla/node_modules/data-urls/LICENSE.txt b/vanilla/node_modules/data-urls/LICENSE.txt deleted file mode 100644 index 4220dea..0000000 --- a/vanilla/node_modules/data-urls/LICENSE.txt +++ /dev/null @@ -1,7 +0,0 @@ -Copyright © Domenic Denicola - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vanilla/node_modules/data-urls/README.md b/vanilla/node_modules/data-urls/README.md deleted file mode 100644 index 9ff1cc1..0000000 --- a/vanilla/node_modules/data-urls/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Parse `data:` URLs - -This package helps you parse `data:` URLs [according to the WHATWG Fetch Standard](https://fetch.spec.whatwg.org/#data-urls): - -```js -const parseDataURL = require("data-urls"); - -const textExample = parseDataURL("data:,Hello%2C%20World!"); -console.log(textExample.mimeType.toString()); // "text/plain;charset=US-ASCII" -console.log(textExample.body); // Uint8Array(13) [ 72, 101, 108, 108, 111, 44, … ] - -const htmlExample = parseDataURL("data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E"); -console.log(htmlExample.mimeType.toString()); // "text/html" -console.log(htmlExample.body); // Uint8Array(22) [ 60, 104, 49, 62, 72, 101, … ] - -const pngExample = parseDataURL("data:image/png;base64,iVBORw0KGgoAAA" + - "ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4" + - "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU" + - "5ErkJggg=="); -console.log(pngExample.mimeType.toString()); // "image/png" -console.log(pngExample.body); // Uint8Array(85) [ 137, 80, 78, 71, 13, 10, … ] -``` - -## API - -This package's main module's default export is a function that accepts a string and returns a `{ mimeType, body }` object, or `null` if the result cannot be parsed as a `data:` URL. - -- The `mimeType` property is an instance of [whatwg-mimetype](https://www.npmjs.com/package/whatwg-mimetype)'s `MIMEType` class. -- The `body` property is a `Uint8Array` instance. - -As shown in the examples above, you can easily get a stringified version of the MIME type using its `toString()` method. Read on for more on getting the stringified version of the body. - -### Decoding the body - -To decode the body bytes of a parsed data URL, you'll need to use the `charset` parameter of the MIME type, if any. This contains an encoding [label](https://encoding.spec.whatwg.org/#label); there are [various possible labels](https://encoding.spec.whatwg.org/#names-and-labels) for a given encoding. You can use the [`TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) API for this: - -```js -const parseDataURL = require("data-urls"); - -const dataURL = parseDataURL(arbitraryString); - -// If there's no charset parameter, e.g. if `arbitraryString` is `"data:text/plain,H%C3%A9llo!"`, -// then let's guess UTF-8. -const encodingLabel = dataURL.mimeType.parameters.get("charset") ?? "utf-8"; -const decoder = new TextDecoder(encodingLabel); - -const bodyDecoded = decoder.decode(dataURL.body); -``` - -(Note that as of the time of this writing in 2026-01, Node.js's built-in `TextDecoder` has many correctness bugs, so we suggest using the polyfill from the [`@exodus/bytes`](https://www.npmjs.com/package/@exodus/bytes) package until they are fixed.) - -Using the parsed charset is quite important, since [the spec requires](https://fetch.spec.whatwg.org/#data-url-processor) that if no parseable MIME type is given, the default is `"US-ASCII"`, [aka windows-1252](https://encoding.spec.whatwg.org/#note-latin1-ascii)—not UTF-8, like you might asume. So for example, given an `arbitraryString` of `"data:,H%E9llo!"`, the above code snippet will correctly produce a `bodyDecoded` of `"Héllo!"` by using the windows-1252 decoder, whereas if you used a UTF-8 decoder you'd get back `"H�llo!"`. - -### Advanced functionality: parsing from a URL record - -If you are using the [`whatwg-url`](https://www.npmjs.com/package/whatwg-url) package, you may already have a "URL record" object on hand, as produced by that package's `parseURL` export. In that case, you can use this package's `fromURLRecord` export to save a bit of work: - -```js -const { parseURL } = require("whatwg-url"); -const dataURLFromURLRecord = require("data-urls").fromURLRecord; - -const urlRecord = parseURL("data:,Hello%2C%20World!"); -const dataURL = dataURLFromURLRecord(urlRecord); -``` - -In practice, we expect this functionality only to be used by consumers like [jsdom](https://www.npmjs.com/package/jsdom), which are using these packages at a very low level. diff --git a/vanilla/node_modules/data-urls/lib/parser.js b/vanilla/node_modules/data-urls/lib/parser.js deleted file mode 100644 index f3f708f..0000000 --- a/vanilla/node_modules/data-urls/lib/parser.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -const { MIMEType } = require("whatwg-mimetype"); -const { parseURL, serializeURL, percentDecodeString } = require("whatwg-url"); -const { stripLeadingAndTrailingASCIIWhitespace, isomorphicDecode, forgivingBase64Decode } = require("./utils.js"); - -module.exports = stringInput => { - const urlRecord = parseURL(stringInput); - - if (urlRecord === null) { - return null; - } - - return module.exports.fromURLRecord(urlRecord); -}; - -module.exports.fromURLRecord = urlRecord => { - if (urlRecord.scheme !== "data") { - return null; - } - - const input = serializeURL(urlRecord, true).substring("data:".length); - - let position = 0; - - let mimeType = ""; - while (position < input.length && input[position] !== ",") { - mimeType += input[position]; - ++position; - } - mimeType = stripLeadingAndTrailingASCIIWhitespace(mimeType); - - if (position === input.length) { - return null; - } - - ++position; - - const encodedBody = input.substring(position); - - let body = percentDecodeString(encodedBody); - - // Can't use /i regexp flag because it isn't restricted to ASCII. - const mimeTypeBase64MatchResult = /(.*); *[Bb][Aa][Ss][Ee]64$/u.exec(mimeType); - if (mimeTypeBase64MatchResult) { - const stringBody = isomorphicDecode(body); - body = forgivingBase64Decode(stringBody); - - if (body === null) { - return null; - } - mimeType = mimeTypeBase64MatchResult[1]; - } - - if (mimeType.startsWith(";")) { - mimeType = `text/plain${mimeType}`; - } - - let mimeTypeRecord; - try { - mimeTypeRecord = new MIMEType(mimeType); - } catch { - mimeTypeRecord = new MIMEType("text/plain;charset=US-ASCII"); - } - - return { - mimeType: mimeTypeRecord, - body - }; -}; diff --git a/vanilla/node_modules/data-urls/lib/utils.js b/vanilla/node_modules/data-urls/lib/utils.js deleted file mode 100644 index 8f5a424..0000000 --- a/vanilla/node_modules/data-urls/lib/utils.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -exports.stripLeadingAndTrailingASCIIWhitespace = string => { - return string.replace(/^[ \t\n\f\r]+/u, "").replace(/[ \t\n\f\r]+$/u, ""); -}; - -exports.isomorphicDecode = input => { - return Array.from(input, byte => String.fromCodePoint(byte)).join(""); -}; - -exports.forgivingBase64Decode = data => { - let asString; - try { - asString = atob(data); - } catch { - return null; - } - - return Uint8Array.from(asString, c => c.codePointAt(0)); -}; diff --git a/vanilla/node_modules/data-urls/package.json b/vanilla/node_modules/data-urls/package.json deleted file mode 100644 index 23ba3e5..0000000 --- a/vanilla/node_modules/data-urls/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "data-urls", - "description": "Parses data: URLs", - "keywords": [ - "data url", - "data uri", - "data:", - "http", - "fetch", - "whatwg" - ], - "version": "7.0.0", - "author": "Domenic Denicola (https://domenic.me/)", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jsdom/data-urls.git" - }, - "main": "lib/parser.js", - "files": [ - "lib/" - ], - "scripts": { - "test": "node --test", - "coverage": "c8 node --test --experimental-test-coverage", - "lint": "eslint", - "pretest": "node scripts/get-latest-platform-tests.mjs" - }, - "dependencies": { - "whatwg-mimetype": "^5.0.0", - "whatwg-url": "^16.0.0" - }, - "devDependencies": { - "@domenic/eslint-config": "^4.1.0", - "c8": "^10.1.3", - "eslint": "^9.39.2", - "globals": "^17.3.0" - }, - "engines": { - "node": "^20.19.0 || ^22.12.0 || >=24.0.0" - }, - "c8": { - "reporter": [ - "html" - ], - "exclude": [ - "scripts/", - "test/" - ] - } -} -- cgit v1.2.3