@interfere/vite 12.1.0 → 12.1.1

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.
@@ -1 +1 @@
1
- import{createHash,randomUUID}from"node:crypto";import{isAbsolute,join,relative,resolve}from"node:path";import{readFile,readdir,writeFile}from"node:fs/promises";import{injectDebugIdIntoJs,injectDebugIdIntoJs as injectDebugIdIntoJs$1,readDebugIdFromJs}from"@interfere/types/data/source-maps";import{mapWithConcurrency}from"@interfere/helpers/map-with-concurrency";const LEADING_DOT_SLASH_RE=/^(?:\.\/)+/u,SOURCEMAPPING_RE=/\/\/[#@]\s*sourceMappingURL=(?<sourceMap>\S+)\s*$/u,RUNTIME_DEBUG_ID_RE=/_debugIds\[[^\]]+\]\s*=\s*["'`](?<id>[a-fA-F0-9-]{36})["'`]/gu,SCRIPT_SUFFIXES=[`.js`,`.mjs`,`.cjs`];function normalizeDistDir(distDir){return distDir.replaceAll(`\\`,`/`).replace(LEADING_DOT_SLASH_RE,``)}function resolveDistDir(projectDir,distDir){return isAbsolute(distDir)?distDir:resolve(projectDir,distDir)}async function walkDistTrees(absDistDir,suffixes,subtrees){return(await Promise.all(subtrees.map(async subtree=>{let root=subtree===`.`?absDistDir:join(absDistDir,subtree),entries=await readdir(root,{recursive:!0}).catch(()=>[]),out=[];for(let entry of entries)suffixes.some(suffix=>entry.endsWith(suffix))&&out.push(join(root,entry));return out}))).flat()}function toPublicPath(rel,rewrites){let normalized=rel.replaceAll(`\\`,`/`);for(let{from,to}of rewrites){let prefix=from.endsWith(`/`)?from:`${from}/`;if(normalized.startsWith(prefix))return`${to}${normalized.slice(prefix.length)}`}return normalized}function injectDebugIdIntoMap(content,debugId){let json=JSON.parse(content);if(typeof json!=`object`||!json||Array.isArray(json))throw TypeError(`Source map must be a JSON object`);return Reflect.set(json,`debugId`,debugId),JSON.stringify(json)}async function discoverByPairing(opts){let absDistDir=resolveDistDir(opts.projectDir,normalizeDistDir(opts.distDir)),jsPaths=await walkDistTrees(absDistDir,SCRIPT_SUFFIXES,opts.subtrees),discovered=await mapWithConcurrency(jsPaths,16,async jsAbs=>{let content=await readFile(jsAbs,`utf8`),match=SOURCEMAPPING_RE.exec(content);if(!match?.groups?.sourceMap||match.groups.sourceMap.startsWith(`data:`))return null;let mapAbs=`${jsAbs.slice(0,jsAbs.lastIndexOf(`/`)+1)}${decodeURIComponent(match.groups.sourceMap)}`,jsPublic=toPublicPath(relative(absDistDir,jsAbs),opts.publicPathRewrites);return[toPublicPath(relative(absDistDir,mapAbs),opts.publicPathRewrites),{existingDebugId:readDebugIdFromJs(content)??[...content.matchAll(RUNTIME_DEBUG_ID_RE)].at(-1)?.groups?.id,jsAbs,jsContent:content,jsPublic,mapAbs}]}),pairs=new Map;for(let[mapPublic,pair]of discovered.filter(entry=>entry!==null)){let chunkAbsolutes=pairs.get(mapPublic)?.chunkAbsolutes??[];pairs.set(mapPublic,{...pair,chunkAbsolutes:[...chunkAbsolutes,pair.jsAbs]})}let loaded=(await mapWithConcurrency([...pairs],16,async([mapPublic,pair])=>{let mapContent=await readFile(pair.mapAbs,`utf8`).catch(()=>null);if(mapContent===null)return null;let debugId=pair.existingDebugId??randomUUID(),mapJson=JSON.parse(mapContent),finalMap=typeof mapJson==`object`&&mapJson&&`debugId`in mapJson&&mapJson.debugId===debugId?mapContent:injectDebugIdIntoMap(mapContent,debugId);return pair.existingDebugId||await writeFile(pair.jsAbs,injectDebugIdIntoJs$1(pair.jsContent,debugId),`utf8`),finalMap!==mapContent&&await writeFile(pair.mapAbs,finalMap,`utf8`),{absolute:pair.mapAbs,chunkAbsolutes:pair.chunkAbsolutes,chunkUrl:pair.jsPublic,content:finalMap,debugId,hash:createHash(`sha256`).update(finalMap).digest(`hex`),path:mapPublic}})).filter(file=>file!==null);return{files:loaded,missingSourceMapCount:pairs.size-loaded.length,sourceFileCount:pairs.size}}export{discoverByPairing,injectDebugIdIntoJs};
1
+ import{createHash,randomUUID}from"node:crypto";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{readFile,readdir,realpath,writeFile}from"node:fs/promises";import{injectDebugIdIntoJs,injectDebugIdIntoJs as injectDebugIdIntoJs$1,readDebugIdFromJs}from"@interfere/types/data/source-maps";import{mapWithConcurrency}from"@interfere/helpers/map-with-concurrency";const LEADING_DOT_SLASH_RE=/^(?:\.\/)+/u,SOURCEMAPPING_RE=/\/\/[#@]\s*sourceMappingURL=(?<sourceMap>\S+)\s*$/u,RUNTIME_DEBUG_ID_RE=/_debugIds\[[^\]]+\]\s*=\s*["'`](?<id>[a-fA-F0-9-]{36})["'`]/gu,SCRIPT_SUFFIXES=[`.js`,`.mjs`,`.cjs`];function normalizeDistDir(distDir){return distDir.replaceAll(`\\`,`/`).replace(LEADING_DOT_SLASH_RE,``)}function resolveDistDir(projectDir,distDir){return isAbsolute(distDir)?distDir:resolve(projectDir,distDir)}function isInsideDir(root,candidate){let rel=relative(root,candidate);return rel!==``&&!isAbsolute(rel)&&rel.split(sep)[0]!==`..`}async function resolveContainedMap(absDistDir,realDistDir,jsAbs,sourceMappingUrl){let mapAbs=resolve(dirname(jsAbs),decodeURIComponent(sourceMappingUrl));if(!isInsideDir(absDistDir,mapAbs))return null;let mapReal=await realpath(mapAbs).catch(()=>null);return mapReal===null||isInsideDir(realDistDir,mapReal)?mapAbs:null}async function walkDistTrees(absDistDir,suffixes,subtrees){return(await Promise.all(subtrees.map(async subtree=>{let root=subtree===`.`?absDistDir:join(absDistDir,subtree),entries=await readdir(root,{recursive:!0}).catch(()=>[]),out=[];for(let entry of entries)suffixes.some(suffix=>entry.endsWith(suffix))&&out.push(join(root,entry));return out}))).flat()}function toPublicPath(rel,rewrites){let normalized=rel.replaceAll(`\\`,`/`);for(let{from,to}of rewrites){let prefix=from.endsWith(`/`)?from:`${from}/`;if(normalized.startsWith(prefix))return`${to}${normalized.slice(prefix.length)}`}return normalized}function injectDebugIdIntoMap(content,debugId){let json=JSON.parse(content);if(typeof json!=`object`||!json||Array.isArray(json))throw TypeError(`Source map must be a JSON object`);return Reflect.set(json,`debugId`,debugId),JSON.stringify(json)}async function discoverByPairing(opts){let absDistDir=resolveDistDir(opts.projectDir,normalizeDistDir(opts.distDir)),realDistDir=await realpath(absDistDir).catch(()=>absDistDir),jsPaths=await walkDistTrees(absDistDir,SCRIPT_SUFFIXES,opts.subtrees),discovered=await mapWithConcurrency(jsPaths,16,async jsAbs=>{let content=await readFile(jsAbs,`utf8`),match=SOURCEMAPPING_RE.exec(content);if(!match?.groups?.sourceMap||match.groups.sourceMap.startsWith(`data:`))return null;let mapAbs=await resolveContainedMap(absDistDir,realDistDir,jsAbs,match.groups.sourceMap);if(mapAbs===null)return null;let jsPublic=toPublicPath(relative(absDistDir,jsAbs),opts.publicPathRewrites);return[toPublicPath(relative(absDistDir,mapAbs),opts.publicPathRewrites),{existingDebugId:readDebugIdFromJs(content)??[...content.matchAll(RUNTIME_DEBUG_ID_RE)].at(-1)?.groups?.id,jsAbs,jsContent:content,jsPublic,mapAbs}]}),pairs=new Map;for(let[mapPublic,pair]of discovered.filter(entry=>entry!==null)){let chunkAbsolutes=pairs.get(mapPublic)?.chunkAbsolutes??[];pairs.set(mapPublic,{...pair,chunkAbsolutes:[...chunkAbsolutes,pair.jsAbs]})}let loaded=(await mapWithConcurrency([...pairs],16,async([mapPublic,pair])=>{let mapContent=await readFile(pair.mapAbs,`utf8`).catch(()=>null);if(mapContent===null)return null;let debugId=pair.existingDebugId??randomUUID(),mapJson=JSON.parse(mapContent),finalMap=typeof mapJson==`object`&&mapJson&&`debugId`in mapJson&&mapJson.debugId===debugId?mapContent:injectDebugIdIntoMap(mapContent,debugId);return pair.existingDebugId||await writeFile(pair.jsAbs,injectDebugIdIntoJs$1(pair.jsContent,debugId),`utf8`),finalMap!==mapContent&&await writeFile(pair.mapAbs,finalMap,`utf8`),{absolute:pair.mapAbs,chunkAbsolutes:pair.chunkAbsolutes,chunkUrl:pair.jsPublic,content:finalMap,debugId,hash:createHash(`sha256`).update(finalMap).digest(`hex`),path:mapPublic}})).filter(file=>file!==null);return{files:loaded,missingSourceMapCount:pairs.size-loaded.length,sourceFileCount:pairs.size}}export{discoverByPairing,injectDebugIdIntoJs};
package/dist/package.mjs CHANGED
@@ -1 +1 @@
1
- var name=`@interfere/vite`,version=`12.1.0`;export{name,version};
1
+ var name=`@interfere/vite`,version=`12.1.1`;export{name,version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interfere/vite",
3
- "version": "12.1.0",
3
+ "version": "12.1.1",
4
4
  "description": "Vite build plugin and client + server initialization for Interfere.",
5
5
  "keywords": [
6
6
  "error-tracking",
@@ -64,9 +64,9 @@
64
64
  "dependencies": {
65
65
  "@interfere/build": "^0.3.1",
66
66
  "@interfere/constants": "^9.2.0",
67
- "@interfere/helpers": "^9.2.0",
67
+ "@interfere/helpers": "^9.2.1",
68
68
  "@interfere/javascript": "^0.2.1",
69
- "@interfere/react": "^12.1.0",
69
+ "@interfere/react": "^12.1.1",
70
70
  "@interfere/types": "^10.3.0",
71
71
  "@opentelemetry/api": "^1.9.1",
72
72
  "@opentelemetry/api-logs": "^0.222.0",
@@ -86,7 +86,7 @@
86
86
  "zod": "^4.5.4"
87
87
  },
88
88
  "devDependencies": {
89
- "@interfere/test-utils": "^10.0.0",
89
+ "@interfere/test-utils": "^10.0.1",
90
90
  "@interfere/typescript-config": "^9.0.2",
91
91
  "@interfere/vitest-config": "0.0.0",
92
92
  "@jridgewell/trace-mapping": "^0.3.31",