// npm 패키지
@antv/util
<h1 align="center">@antv/util</h1>
버전
71
메인테이너
52
라이선스
MIT
최초 publish
2018-05-23
publisher
kn9117
tarball
911,023 B
AUTO-PUBLISHED·1개 버전 인덱싱됨·최근 publish: 2025-07-01
// publisher 캠페인by kn9117
이 계정에서 catch된 패키지 4건고립된 catch가 아닙니다. 동일 publisher가 3개의 다른 패키지를 추가로 발행했고, 모두 파이프라인이 catch했습니다 — 일회성이 아닌 조직적 캠페인의 형태. 아래 링크는 각 형제 catch의 분석으로 이동합니다.
// offending code· @3.3.11· 3 files flagged
llm: benign · 0.85→ 의심 전송지 없음, 원격 실행 형태 없음 — 1 known-vendor host(s).
- @3.3.11··AUTO-PUBLISHED·publisher: kn9117heuristic 75/100static flags 2llm benign (0.85) via ollamamature-packageosv-flagged:MAL-2026-4092public-github-pushchild-process-spawn
→ 의심 전송지 없음, 원격 실행 형태 없음 — 1 known-vendor host(s).
// offending code· 3 files flaggedpatterns: 2
--- install scripts --- ### prepublishOnly npm run ci --- package/package.json (excerpt) --- { "name": "@antv/util", "version": "3.3.11", "license": "MIT", "sideEffects": false, "main": "lib/index.js", "module": "esm/index.js", "unpkg": "dist/util.min.js", "types": "lib/index.d.ts", "files": [ "src", "lib", "esm", "dist" ], "scripts": { "clean": "rimraf lib esm dist", "lint-staged": "lint-staged", "size": "limit-size", "lint": "eslint ./src ./__tests__ && prettier ./src ./__tests__ --check && lint-md docs/**/* README.md", "fix": "eslint ./src ./__tests__ --fix && prettier ./src ./__tests__ --write && lint-md docs/**/* README.md --fix", "test": "jest", "build:umd": "rimraf ./dist && rollup -c && npm run size", "build:cjs": "rimraf ./lib && tsc --module commonjs --outDir lib", "build:esm": "rimraf ./esm && tsc --module ESNext --outDir esm", "build": "run-p build:*", "ci": "run-s lint test build", "prepublishOnly": "npm run ci", "benchmarks": "node benchmarks/path-2-string.test && node benchmarks/path-2-absolute.test" }, "keywords": [ "util", "antv" ], "devDependencies": { "@antv/path-util": "^2.0.15", "@commitlint/cli": "^18.6.1", "@commitlint/config-conventional": "^18.6.3", "@lint-md/cli": "^2.0.0", "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^11.1.6", "@types/jest": "^26.0.20", "@typescript-eslint/eslint-plugin": "^4.18.0", --- package/src/color/tocssgradient.ts (excerpt) --- const regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i; const regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i; const regexColorStop = /[\d.]+:(#[^\s]+|[^)]+\))/gi; function isGradientColor(val) { return /^[r,R,L,l]{1}[\s]*\(/.test(val); } /** * 将 g 渐变转换为 css 渐变 */ export function toCSSGradient(gradientColor) { if (isGradientColor(gradientColor)) { let cssColor; let steps; if (gradientColor[0] === 'l') { // 线性渐变 const arr = regexLG.exec(gradientColor); const angle = +arr[1] + 90; // css 和 g 的渐变起始角度不同 steps = arr[2]; cssColor = `linear-gradient(${angle}deg, `; } else if (gradientColor[0] === 'r') { // 径向渐变 cssColor = 'radial-gradient('; const arr = regexRG.exec(gradientColor); steps = arr[4]; } const colorStops: string[] = steps.match(regexColorStop); colorStops.forEach((item: string, index: number) => { const itemArr = item.split(':'); cssColor += `${itemArr[1]} ${Number(itemArr[0]) * 100}%`; if (index !== colorStops.length - 1) { cssColor += ', '; } }); cssColor += ')'; return cssColor; } return gradientColor; } --- package/src/color/torgb.ts (excerpt) --- import { memoize } from '../lodash'; import { arr2rgb } from './arr2rgb'; const RGB_REG = /rgba?\(([\s.,0-9]+)\)/; /** * 创建辅助 tag 取颜色 * @returns */ function getTmp(): HTMLElement { let i = document.getElementById('antv-web-colour-picker'); if (i) { return i; } i = document.createElement('i'); i.id = 'antv-web-colour-picker'; i.title = 'Web Colour Picker'; i.style.display = 'none'; document.body.appendChild(i); return i; } /** * 将颜色转换到 rgb 的格式 * @param {color} color 颜色 * @return 将颜色转换到 '#ffffff' 的格式 */ function toRGBString(color: string): string { // 如果已经是 rgb的格式 if (color[0] === '#' && color.length === 7) { return color; } const iEl = getTmp(); iEl.style.color = color; let rst = document.defaultView.getComputedStyle(iEl, '').getPropertyValue('color'); const matches = RGB_REG.exec(rst) as string[]; const cArray: number[] = matches[1].split(/\s*,\s*/).map((s) => Number(s)); rst = arr2rgb(cArray); return rst; } /** * export with memoize. * @param color * @returns */ export const toRGB = memoize(toRGBString, (color) => color, 256); --- bundled output (OSV-MAL flagged — LLM scope expansion) --- --- lib/path/util/equalize-segments.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.equalizeSegments = equalizeSegments; var mid_point_1 = require("./mid-point"); var segment_cubic_factory_1 = require("./segment-cubic-factory"); var MAX_RECURSION_DEPTH = 50; function splitCubic(pts, t) { if (t === void 0) { t = 0.5; } var p0 = pts.slice(0, 2); var p1 = pts.slice(2, 4); var p2 = pts.slice(4, 6); var p3 = pts.slice(6, 8); var p4 = (0, mid_point_1.midPoint)(p0, p1, t); var p5 = (0, mid_point_1.midPoint)(p1, p2, t); var p6 = (0, mid_point_1.midPoint)(p2, p3, t); var p7 = (0, mid_point_1.midPoint)(p4, p5, t); var p8 = (0, mid_point_1.midPoint)(p5, p6, t); var p9 = (0, mid_point_1.midPoint)(p7, p8, t); return [ // @ts-ignore ['C'].concat(p4, p7, p9), // @ts-ignore ['C'].concat(p8, p6, p3), ]; } function getCurveArray(segments) { return segments.map(function (segment, i, pathArray) { // @ts-ignore var segmentData = i && pathArray[i - 1].slice(-2).concat(segment.slice(1)); // @ts-ignore var curveLength = i ? (0, segment_cubic_factory_1.segmentCubicFactory)(segmentData[0], segmentData[1], segmentData[2], segmentData[3], segmentData[4], segmentData[5], segmentData[6], segmentData[7], segmentData[8], { bbox: false }).length : 0; var subsegs; if (i) { // must be [segment,segment] subsegs = curveLength ? splitCubic(segmentData) : [segment, segment]; } else { subsegs = [segment]; } return { s: segment, ss: subsegs, l: curveLength, }; }); } function equalizeSegments(path1, path2, TL, depth) { if (depth === void 0) { depth = 0; } if (depth > MAX_RECURSION_DEPTH) { console.warn('Maximum recursion depth reached in equalizeSegments'); return [path1, path2]; } var c1 = getCurveArray --- lib/path/util/get-draw-direction.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDrawDirection = getDrawDirection; var get_path_area_1 = require("./get-path-area"); function getDrawDirection(pathArray) { return (0, get_path_area_1.getPathArea)(pathArray) >= 0; } //# sourceMappingURL=get-draw-direction.js.map --- lib/path/util/get-path-bbox-total-length.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPathBBoxTotalLength = getPathBBoxTotalLength; var tslib_1 = require("tslib"); var path_length_factory_1 = require("./path-length-factory"); /** * Returns the bounding box of a shape. */ function getPathBBoxTotalLength(path, options) { if (!path) { return { length: 0, x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0, cx: 0, cy: 0, cz: 0, }; } var _a = (0, path_length_factory_1.pathLengthFactory)(path, undefined, tslib_1.__assign(tslib_1.__assign({}, options), { bbox: true, length: true })), length = _a.length, _b = _a.min, xMin = _b.x, yMin = _b.y, _c = _a.max, xMax = _c.x, yMax = _c.y; var width = xMax - xMin; var height = yMax - yMin; return { length: length, width: width, height: height, x: xMin, y: yMin, x2: xMax, y2: yMax, cx: xMin + width / 2, cy: yMin + height / 2, // an estimted guess cz: Math.max(width, height) + Math.min(width, height) / 2, }; } //# sourceMappingURL=get-path-bbox-total-length.js.map --- lib/path/util/get-point-at-length.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPointAtLength = getPointAtLength; var tslib_1 = require("tslib"); var path_length_factory_1 = require("./path-length-factory"); /** * Returns [x,y] coordinates of a point at a given length of a shape. */ function getPointAtLength(pathInput, distance, options) { return (0, path_length_factory_1.pathLengthFactory)(pathInput, distance, tslib_1.__assign(tslib_1.__assign({}, options), { bbox: false, length: true })).point; } //# sourceMappingURL=get-point-at-length.js.map --- lib/path/util/get-properties-at-length.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPropertiesAtLength = getPropertiesAtLength; var parse_path_string_1 = require("../parser/parse-path-string"); var get_total_length_1 = require("./get-total-length"); /** * Returns the segment, its index and length as well as * the length to that segment at a given length in a path. */ function getPropertiesAtLength(pathInput, distance) { var pathArray = (0, parse_path_string_1.parsePathString)(pathInput); if (typeof pathArray === 'string') { throw TypeError(pathArray); } var pathTemp = pathArray.slice(); var pathLength = (0, get_total_length_1.getTotalLength)(pathTemp); var index = pathTemp.length - 1; var lengthAtSegment = 0; var length = 0; var segment = pathArray[0]; var _a = segment.slice(-2), x = _a[0], y = _a[1]; var point = { x: x, y: y }; // If the path is empty, return 0. if (index <= 0 || !distance || !Number.isFinite(distance)) { return { segment: segment, index: 0, length: length, point: point, lengthAtSegment: lengthAtSegment, }; } if (distance >= pathLength) { pathTemp = pathArray.slice(0, -1); lengthAtSegment = (0, get_total_length_1.getTotalLength)(pathTemp); length = pathLength - lengthAtSegment; return { segment: pathArray[index], index: index, length: length, lengthAtSegment: lengthAtSegment, }; } var segments = []; while (index > 0) { segment = pathTemp[index]; pathTemp = pathTemp.slice(0, -1); lengthAtSegment = (0, get_total_length_1.getTotalLength)(pathTemp); length = pathLength - lengthAtSegment; pathLength = lengthAtSegment; segments.push({ segment: segment, index: index, length: length, lengthAtSegment: lengthAtSegment --- lib/path/util/get-total-length.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTotalLength = getTotalLength; var tslib_1 = require("tslib"); var path_length_factory_1 = require("./path-length-factory"); /** * Returns the shape total length, or the equivalent to `shape.getTotalLength()`. * * The `normalizePath` version is lighter, faster, more efficient and more accurate * with paths that are not `curveArray`. */ function getTotalLength(pathInput, options) { return (0, path_length_factory_1.pathLengthFactory)(pathInput, undefined, tslib_1.__assign(tslib_1.__assign({}, options), { bbox: false, length: true })).length; } //# sourceMappingURL=get-total-length.js.map --- lib/path/util/is-point-in-stroke.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPointInStroke = isPointInStroke; var get_properties_at_point_1 = require("./get-properties-at-point"); /** * Checks if a given point is in the stroke of a path. */ function isPointInStroke(pathInput, point) { var distance = (0, get_properties_at_point_1.getPropertiesAtPoint)(pathInput, point).distance; return Math.abs(distance) < 0.001; // 0.01 might be more permissive } //# sourceMappingURL=is-point-in-stroke.js.map --- lib/path/util/path-length-factory.js (bundled) --- "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pathLengthFactory = pathLengthFactory; var normalize_path_1 = require("../process/normalize-path"); var segment_line_fac
