🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@rg-dev/stdlib

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rg-dev/stdlib - npm Package Compare versions

Comparing version
1.0.65
to
1.0.66
+36
-3
lib/vite-helpers.cjs

@@ -24,3 +24,4 @@ "use strict";

VERSION: () => VERSION,
createViteMiddleware: () => createViteMiddleware
createViteMiddleware: () => createViteMiddleware,
viteEntryscriptCatchPlugin: () => viteEntryscriptCatchPlugin
});

@@ -38,4 +39,35 @@ module.exports = __toCommonJS(vite_helpers_exports);

// src/vite-helpers.ts
function viteEntryscriptCatchPlugin() {
return {
name: "keep-inline-script",
transformIndexHtml: {
enforce: "post",
transform(html) {
return html.replace(
/<script type="module" crossorigin src="([^"]+)"><\/script>/,
(_, src) => `
<script type="module">
async function init() {
try {
await import('${src}')
} catch (err) {
console.error('Failed to load app:', err)
document.getElementById('app').innerHTML = \`
<div style="font-family:sans-serif;text-align:center;margin-top:4rem">
<h1>Failed to load</h1>
<p>\${err?.message ?? 'Unknown error'}</p>
<a href="/">Retry</a>
</div>
\`
}
}
init()
</script>`
);
}
}
};
}
async function createViteMiddleware(rootPath, opts = Object()) {
var _a;
var _a, _b;
(_a = opts.hmr) != null ? _a : opts.hmr = true;

@@ -65,3 +97,4 @@ if (!isNonEmptyString(rootPath)) {

}
}
},
...(_b = opts.plugins) != null ? _b : []
]

@@ -68,0 +101,0 @@ }

import { Handler } from 'express';
export { VERSION } from './index.cjs';
declare function viteEntryscriptCatchPlugin(): {
name: string;
transformIndexHtml: {
enforce: string;
transform(html: string): string;
};
};
declare function createViteMiddleware(rootPath: string, opts?: {
editHtmlFn?: (html: string) => string;
hmr?: boolean;
plugins?: any[];
}): Promise<Handler>;
export { createViteMiddleware };
export { createViteMiddleware, viteEntryscriptCatchPlugin };
import { Handler } from 'express';
export { VERSION } from './index.js';
declare function viteEntryscriptCatchPlugin(): {
name: string;
transformIndexHtml: {
enforce: string;
transform(html: string): string;
};
};
declare function createViteMiddleware(rootPath: string, opts?: {
editHtmlFn?: (html: string) => string;
hmr?: boolean;
plugins?: any[];
}): Promise<Handler>;
export { createViteMiddleware };
export { createViteMiddleware, viteEntryscriptCatchPlugin };

@@ -10,4 +10,35 @@ // src/index.ts

// src/vite-helpers.ts
function viteEntryscriptCatchPlugin() {
return {
name: "keep-inline-script",
transformIndexHtml: {
enforce: "post",
transform(html) {
return html.replace(
/<script type="module" crossorigin src="([^"]+)"><\/script>/,
(_, src) => `
<script type="module">
async function init() {
try {
await import('${src}')
} catch (err) {
console.error('Failed to load app:', err)
document.getElementById('app').innerHTML = \`
<div style="font-family:sans-serif;text-align:center;margin-top:4rem">
<h1>Failed to load</h1>
<p>\${err?.message ?? 'Unknown error'}</p>
<a href="/">Retry</a>
</div>
\`
}
}
init()
</script>`
);
}
}
};
}
async function createViteMiddleware(rootPath, opts = Object()) {
var _a;
var _a, _b;
(_a = opts.hmr) != null ? _a : opts.hmr = true;

@@ -37,3 +68,4 @@ if (!isNonEmptyString(rootPath)) {

}
}
},
...(_b = opts.plugins) != null ? _b : []
]

@@ -46,3 +78,4 @@ }

VERSION,
createViteMiddleware
createViteMiddleware,
viteEntryscriptCatchPlugin
};
+1
-1
{
"name": "@rg-dev/stdlib",
"version": "1.0.65",
"version": "1.0.66",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {