magic-string
Advanced tools
@@ -1042,2 +1042,3 @@ 'use strict'; | ||
| let chunk = this.lastSearchedChunk; | ||
| let previousChunk = chunk; | ||
| const searchForward = index > chunk.end; | ||
@@ -1049,2 +1050,7 @@ | ||
| chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start]; | ||
| // Prevent infinite loop (e.g. via empty chunks, where start === end) | ||
| if (chunk === previousChunk) return; | ||
| previousChunk = chunk; | ||
| } | ||
@@ -1051,0 +1057,0 @@ } |
@@ -1040,2 +1040,3 @@ import { encode } from '@jridgewell/sourcemap-codec'; | ||
| let chunk = this.lastSearchedChunk; | ||
| let previousChunk = chunk; | ||
| const searchForward = index > chunk.end; | ||
@@ -1047,2 +1048,7 @@ | ||
| chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start]; | ||
| // Prevent infinite loop (e.g. via empty chunks, where start === end) | ||
| if (chunk === previousChunk) return; | ||
| previousChunk = chunk; | ||
| } | ||
@@ -1049,0 +1055,0 @@ } |
+79
-82
@@ -200,93 +200,84 @@ (function (global, factory) { | ||
| const comma = ','.charCodeAt(0); | ||
| const semicolon = ';'.charCodeAt(0); | ||
| const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
| const intToChar = new Uint8Array(64); // 64 possible chars. | ||
| const charToInt = new Uint8Array(128); // z is 122 in ASCII | ||
| // src/vlq.ts | ||
| var comma = ",".charCodeAt(0); | ||
| var semicolon = ";".charCodeAt(0); | ||
| var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
| var intToChar = new Uint8Array(64); | ||
| var charToInt = new Uint8Array(128); | ||
| for (let i = 0; i < chars.length; i++) { | ||
| const c = chars.charCodeAt(i); | ||
| intToChar[i] = c; | ||
| charToInt[c] = i; | ||
| const c = chars.charCodeAt(i); | ||
| intToChar[i] = c; | ||
| charToInt[c] = i; | ||
| } | ||
| function encodeInteger(builder, num, relative) { | ||
| let delta = num - relative; | ||
| delta = delta < 0 ? (-delta << 1) | 1 : delta << 1; | ||
| do { | ||
| let clamped = delta & 0b011111; | ||
| delta >>>= 5; | ||
| if (delta > 0) | ||
| clamped |= 0b100000; | ||
| builder.write(intToChar[clamped]); | ||
| } while (delta > 0); | ||
| return num; | ||
| let delta = num - relative; | ||
| delta = delta < 0 ? -delta << 1 | 1 : delta << 1; | ||
| do { | ||
| let clamped = delta & 31; | ||
| delta >>>= 5; | ||
| if (delta > 0) clamped |= 32; | ||
| builder.write(intToChar[clamped]); | ||
| } while (delta > 0); | ||
| return num; | ||
| } | ||
| const bufLength = 1024 * 16; | ||
| // Provide a fallback for older environments. | ||
| const td = typeof TextDecoder !== 'undefined' | ||
| ? /* #__PURE__ */ new TextDecoder() | ||
| : typeof Buffer !== 'undefined' | ||
| ? { | ||
| decode(buf) { | ||
| const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); | ||
| return out.toString(); | ||
| }, | ||
| } | ||
| : { | ||
| decode(buf) { | ||
| let out = ''; | ||
| for (let i = 0; i < buf.length; i++) { | ||
| out += String.fromCharCode(buf[i]); | ||
| } | ||
| return out; | ||
| }, | ||
| }; | ||
| class StringWriter { | ||
| constructor() { | ||
| this.pos = 0; | ||
| this.out = ''; | ||
| this.buffer = new Uint8Array(bufLength); | ||
| // src/strings.ts | ||
| var bufLength = 1024 * 16; | ||
| var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { | ||
| decode(buf) { | ||
| const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); | ||
| return out.toString(); | ||
| } | ||
| } : { | ||
| decode(buf) { | ||
| let out = ""; | ||
| for (let i = 0; i < buf.length; i++) { | ||
| out += String.fromCharCode(buf[i]); | ||
| } | ||
| write(v) { | ||
| const { buffer } = this; | ||
| buffer[this.pos++] = v; | ||
| if (this.pos === bufLength) { | ||
| this.out += td.decode(buffer); | ||
| this.pos = 0; | ||
| } | ||
| return out; | ||
| } | ||
| }; | ||
| var StringWriter = class { | ||
| constructor() { | ||
| this.pos = 0; | ||
| this.out = ""; | ||
| this.buffer = new Uint8Array(bufLength); | ||
| } | ||
| write(v) { | ||
| const { buffer } = this; | ||
| buffer[this.pos++] = v; | ||
| if (this.pos === bufLength) { | ||
| this.out += td.decode(buffer); | ||
| this.pos = 0; | ||
| } | ||
| flush() { | ||
| const { buffer, out, pos } = this; | ||
| return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; | ||
| } | ||
| } | ||
| } | ||
| flush() { | ||
| const { buffer, out, pos } = this; | ||
| return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; | ||
| } | ||
| }; | ||
| function encode(decoded) { | ||
| const writer = new StringWriter(); | ||
| let sourcesIndex = 0; | ||
| let sourceLine = 0; | ||
| let sourceColumn = 0; | ||
| let namesIndex = 0; | ||
| for (let i = 0; i < decoded.length; i++) { | ||
| const line = decoded[i]; | ||
| if (i > 0) | ||
| writer.write(semicolon); | ||
| if (line.length === 0) | ||
| continue; | ||
| let genColumn = 0; | ||
| for (let j = 0; j < line.length; j++) { | ||
| const segment = line[j]; | ||
| if (j > 0) | ||
| writer.write(comma); | ||
| genColumn = encodeInteger(writer, segment[0], genColumn); | ||
| if (segment.length === 1) | ||
| continue; | ||
| sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); | ||
| sourceLine = encodeInteger(writer, segment[2], sourceLine); | ||
| sourceColumn = encodeInteger(writer, segment[3], sourceColumn); | ||
| if (segment.length === 4) | ||
| continue; | ||
| namesIndex = encodeInteger(writer, segment[4], namesIndex); | ||
| } | ||
| const writer = new StringWriter(); | ||
| let sourcesIndex = 0; | ||
| let sourceLine = 0; | ||
| let sourceColumn = 0; | ||
| let namesIndex = 0; | ||
| for (let i = 0; i < decoded.length; i++) { | ||
| const line = decoded[i]; | ||
| if (i > 0) writer.write(semicolon); | ||
| if (line.length === 0) continue; | ||
| let genColumn = 0; | ||
| for (let j = 0; j < line.length; j++) { | ||
| const segment = line[j]; | ||
| if (j > 0) writer.write(comma); | ||
| genColumn = encodeInteger(writer, segment[0], genColumn); | ||
| if (segment.length === 1) continue; | ||
| sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); | ||
| sourceLine = encodeInteger(writer, segment[2], sourceLine); | ||
| sourceColumn = encodeInteger(writer, segment[3], sourceColumn); | ||
| if (segment.length === 4) continue; | ||
| namesIndex = encodeInteger(writer, segment[4], namesIndex); | ||
| } | ||
| return writer.flush(); | ||
| } | ||
| return writer.flush(); | ||
| } | ||
@@ -1138,2 +1129,3 @@ | ||
| let chunk = this.lastSearchedChunk; | ||
| let previousChunk = chunk; | ||
| const searchForward = index > chunk.end; | ||
@@ -1145,2 +1137,7 @@ | ||
| chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start]; | ||
| // Prevent infinite loop (e.g. via empty chunks, where start === end) | ||
| if (chunk === previousChunk) return; | ||
| previousChunk = chunk; | ||
| } | ||
@@ -1147,0 +1144,0 @@ } |
+69
-62
| { | ||
| "name": "magic-string", | ||
| "version": "0.30.17", | ||
| "description": "Modify strings, generate sourcemaps", | ||
| "keywords": [ | ||
| "string", | ||
| "string manipulation", | ||
| "sourcemap", | ||
| "templating", | ||
| "transpilation" | ||
| ], | ||
| "repository": "https://github.com/rich-harris/magic-string", | ||
| "license": "MIT", | ||
| "author": "Rich Harris", | ||
| "main": "./dist/magic-string.cjs.js", | ||
| "module": "./dist/magic-string.es.mjs", | ||
| "sideEffects": false, | ||
| "jsnext:main": "./dist/magic-string.es.mjs", | ||
| "types": "./dist/magic-string.cjs.d.ts", | ||
| "exports": { | ||
| "./package.json": "./package.json", | ||
| ".": { | ||
| "import": "./dist/magic-string.es.mjs", | ||
| "require": "./dist/magic-string.cjs.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist/*", | ||
| "index.d.ts", | ||
| "README.md" | ||
| ], | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.16.0", | ||
| "@rollup/plugin-node-resolve": "^15.3.0", | ||
| "@rollup/plugin-replace": "^5.0.7", | ||
| "benchmark": "^2.1.4", | ||
| "bumpp": "^9.9.1", | ||
| "conventional-changelog-cli": "^3.0.0", | ||
| "eslint": "^9.16.0", | ||
| "prettier": "^3.4.2", | ||
| "publint": "^0.2.12", | ||
| "rollup": "^3.29.5", | ||
| "source-map-js": "^1.2.1", | ||
| "source-map-support": "^0.5.21", | ||
| "vitest": "^2.1.8" | ||
| }, | ||
| "dependencies": { | ||
| "@jridgewell/sourcemap-codec": "^1.5.0" | ||
| }, | ||
| "scripts": { | ||
| "build": "rollup -c", | ||
| "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", | ||
| "format": "prettier --single-quote --print-width 100 --use-tabs --write .", | ||
| "lint": "eslint src test && publint", | ||
| "lint:fix": "eslint src test --fix", | ||
| "release": "bumpp -x \"npm run changelog\" --all --commit --tag --push && npm publish", | ||
| "pretest": "npm run build", | ||
| "test": "vitest run", | ||
| "test:dev": "vitest", | ||
| "bench": "npm run build && node benchmark/index.mjs", | ||
| "watch": "rollup -cw" | ||
| } | ||
| } | ||
| "name": "magic-string", | ||
| "version": "0.30.18", | ||
| "type": "commonjs", | ||
| "packageManager": "pnpm@10.15.0", | ||
| "description": "Modify strings, generate sourcemaps", | ||
| "keywords": [ | ||
| "string", | ||
| "string manipulation", | ||
| "sourcemap", | ||
| "templating", | ||
| "transpilation" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/rich-harris/magic-string.git" | ||
| }, | ||
| "license": "MIT", | ||
| "author": "Rich Harris", | ||
| "main": "./dist/magic-string.cjs.js", | ||
| "module": "./dist/magic-string.es.mjs", | ||
| "sideEffects": false, | ||
| "jsnext:main": "./dist/magic-string.es.mjs", | ||
| "types": "./dist/magic-string.cjs.d.ts", | ||
| "exports": { | ||
| "./package.json": "./package.json", | ||
| ".": { | ||
| "import": "./dist/magic-string.es.mjs", | ||
| "require": "./dist/magic-string.cjs.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist/*", | ||
| "index.d.ts", | ||
| "README.md" | ||
| ], | ||
| "scripts": { | ||
| "build": "rollup -c", | ||
| "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", | ||
| "format": "prettier --single-quote --print-width 100 --use-tabs --write .", | ||
| "lint": "eslint src test && publint", | ||
| "lint:fix": "eslint src test --fix", | ||
| "prepare": "npm run build", | ||
| "prepublishOnly": "npm run lint && rm -rf dist && npm test", | ||
| "release": "bumpp -x \"npm run changelog\" --all --commit --tag --push && npm publish", | ||
| "pretest": "npm run build", | ||
| "test": "vitest run", | ||
| "test:dev": "vitest", | ||
| "bench": "npm run build && node benchmark/index.mjs", | ||
| "watch": "rollup -cw" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.33.0", | ||
| "@rollup/plugin-node-resolve": "^16.0.1", | ||
| "@rollup/plugin-replace": "^6.0.2", | ||
| "benchmark": "^2.1.4", | ||
| "bumpp": "^10.2.3", | ||
| "conventional-changelog-cli": "^5.0.0", | ||
| "eslint": "^9.33.0", | ||
| "prettier": "^3.6.2", | ||
| "publint": "^0.3.12", | ||
| "rollup": "^4.47.1", | ||
| "source-map-js": "^1.2.1", | ||
| "source-map-support": "^0.5.21", | ||
| "vitest": "^3.2.4" | ||
| }, | ||
| "dependencies": { | ||
| "@jridgewell/sourcemap-codec": "^1.5.5" | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
4126
0.07%1
-50%456313
-2.39%