New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@servlyadmin/runtime-core

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@servlyadmin/runtime-core - npm Package Compare versions

Comparing version
0.1.9
to
0.1.10
+182
dist/chunk-CIUQK4GA.js
// src/registry.ts
function createRegistry() {
const components = /* @__PURE__ */ new Map();
return {
get(id, version) {
if (version) {
const key = `${id}@${version}`;
if (components.has(key)) {
return components.get(key);
}
}
for (const [key, component] of components) {
if (key.startsWith(`${id}@`)) {
return component;
}
}
return components.get(id);
},
has(id, version) {
if (version) {
return components.has(`${id}@${version}`);
}
for (const key of components.keys()) {
if (key.startsWith(`${id}@`) || key === id) {
return true;
}
}
return false;
},
set(id, version, component) {
components.set(`${id}@${version}`, component);
}
};
}
function buildRegistryFromBundle(data) {
const registry = createRegistry();
registry.set(data.id, data.version, {
layout: data.layout,
propsInterface: data.propsInterface
});
if (data.bundle) {
for (const [key, component] of Object.entries(data.bundle)) {
const [id, version] = key.split("@");
if (id && version) {
registry.set(id, version, component);
}
}
}
return registry;
}
function extractDependencies(elements) {
const dependencies = [];
for (const element of elements) {
const config = element.configuration;
if (!config) continue;
if (config.componentViewRef) {
dependencies.push({
id: config.componentViewRef,
version: config.componentViewVersion,
type: "viewRef",
elementId: element.i
});
}
if (config.blueprint) {
dependencies.push({
id: config.blueprint,
version: config.blueprintVersion,
type: "blueprint",
elementId: element.i
});
}
}
return dependencies;
}
function extractDependenciesFromCode(code) {
const dependencies = [];
const pattern = /renderDynamicList\s*\(\s*\{[^}]*blueprint\s*:\s*["']([^"']+)["']/g;
let match;
while ((match = pattern.exec(code)) !== null) {
dependencies.push({
id: match[1],
type: "blueprint"
});
}
return dependencies;
}
async function collectAllDependencies(rootId, rootVersion, fetchComponent, maxDepth = 10) {
const manifest = {};
const visited = /* @__PURE__ */ new Set();
async function collect(id, version, via, depth) {
if (depth > maxDepth) {
console.warn(`Max dependency depth (${maxDepth}) reached for ${id}`);
return;
}
const key = `${id}@${version || "latest"}`;
if (visited.has(key)) {
return;
}
visited.add(key);
try {
const component = await fetchComponent(id, version);
if (!component) {
console.warn(`Dependency not found: ${id}@${version || "latest"}`);
return;
}
manifest[id] = {
version: version || "latest",
resolved: component.version,
type: via ? "viewRef" : "viewRef",
// Will be set by caller
via
};
const nestedDeps = extractDependencies(component.layout);
for (const dep of nestedDeps) {
await collect(dep.id, dep.version, id, depth + 1);
}
} catch (error) {
console.error(`Failed to fetch dependency ${id}:`, error);
}
}
const rootComponent = await fetchComponent(rootId, rootVersion);
if (rootComponent) {
const rootDeps = extractDependencies(rootComponent.layout);
for (const dep of rootDeps) {
manifest[dep.id] = {
version: dep.version || "latest",
resolved: "",
// Will be filled when fetched
type: dep.type
};
await collect(dep.id, dep.version, void 0, 1);
}
}
return manifest;
}
function detectCircularDependencies(manifest) {
const graph = /* @__PURE__ */ new Map();
for (const [id, entry] of Object.entries(manifest)) {
if (entry.via) {
const deps = graph.get(entry.via) || [];
deps.push(id);
graph.set(entry.via, deps);
}
}
const visited = /* @__PURE__ */ new Set();
const stack = /* @__PURE__ */ new Set();
const path = [];
function dfs(node) {
if (stack.has(node)) {
const cycleStart = path.indexOf(node);
return [...path.slice(cycleStart), node];
}
if (visited.has(node)) {
return null;
}
visited.add(node);
stack.add(node);
path.push(node);
const neighbors = graph.get(node) || [];
for (const neighbor of neighbors) {
const cycle = dfs(neighbor);
if (cycle) return cycle;
}
stack.delete(node);
path.pop();
return null;
}
for (const node of graph.keys()) {
const cycle = dfs(node);
if (cycle) return cycle;
}
return null;
}
export {
createRegistry,
buildRegistryFromBundle,
extractDependencies,
extractDependenciesFromCode,
collectAllDependencies,
detectCircularDependencies
};
// src/tailwind.ts
var DEFAULT_TAILWIND_CDN = "https://cdn.tailwindcss.com";
var tailwindInjected = false;
var tailwindScript = null;
function injectTailwind(config = {}) {
return new Promise((resolve, reject) => {
if (tailwindInjected && tailwindScript) {
resolve();
return;
}
if (typeof document === "undefined") {
resolve();
return;
}
if (window.tailwind) {
tailwindInjected = true;
config.onReady?.();
resolve();
return;
}
const {
cdnUrl = DEFAULT_TAILWIND_CDN,
config: tailwindConfig,
plugins = [],
usePlayCdn = false,
onReady,
onError
} = config;
const script = document.createElement("script");
script.src = usePlayCdn ? `${cdnUrl}?plugins=forms,typography,aspect-ratio` : cdnUrl;
script.async = true;
script.onload = () => {
tailwindInjected = true;
tailwindScript = script;
if (tailwindConfig && window.tailwind) {
window.tailwind.config = tailwindConfig;
}
onReady?.();
resolve();
};
script.onerror = (event) => {
const error = new Error(`Failed to load Tailwind CSS from ${cdnUrl}`);
onError?.(error);
reject(error);
};
document.head.appendChild(script);
});
}
function removeTailwind() {
if (tailwindScript && tailwindScript.parentNode) {
tailwindScript.parentNode.removeChild(tailwindScript);
tailwindScript = null;
tailwindInjected = false;
delete window.tailwind;
}
}
function isTailwindLoaded() {
return tailwindInjected || !!window.tailwind;
}
function getTailwind() {
return window.tailwind;
}
function updateTailwindConfig(config) {
if (window.tailwind) {
window.tailwind.config = {
...window.tailwind.config,
...config
};
}
}
function addCustomStyles(css, id) {
if (typeof document === "undefined") {
throw new Error("addCustomStyles can only be used in browser environment");
}
const styleId = id || `servly-custom-styles-${Date.now()}`;
let existingStyle = document.getElementById(styleId);
if (existingStyle) {
existingStyle.textContent = css;
return existingStyle;
}
const style = document.createElement("style");
style.id = styleId;
style.textContent = css;
document.head.appendChild(style);
return style;
}
function removeCustomStyles(id) {
if (typeof document === "undefined") return;
const style = document.getElementById(id);
if (style && style.parentNode) {
style.parentNode.removeChild(style);
}
}
var DEFAULT_SERVLY_TAILWIND_CONFIG = {
theme: {
extend: {
// Add any Servly-specific theme extensions here
}
},
// Safelist common dynamic classes
safelist: [
// Spacing
{ pattern: /^(p|m|gap)-/ },
// Sizing
{ pattern: /^(w|h|min-w|min-h|max-w|max-h)-/ },
// Flexbox
{ pattern: /^(flex|justify|items|self)-/ },
// Grid
{ pattern: /^(grid|col|row)-/ },
// Colors
{ pattern: /^(bg|text|border|ring)-/ },
// Typography
{ pattern: /^(font|text|leading|tracking)-/ },
// Borders
{ pattern: /^(rounded|border)-/ },
// Effects
{ pattern: /^(shadow|opacity|blur)-/ },
// Transforms
{ pattern: /^(scale|rotate|translate|skew)-/ },
// Transitions
{ pattern: /^(transition|duration|ease|delay)-/ }
]
};
async function initServlyTailwind(customConfig) {
const config = customConfig ? { ...DEFAULT_SERVLY_TAILWIND_CONFIG, ...customConfig } : DEFAULT_SERVLY_TAILWIND_CONFIG;
await injectTailwind({
config,
usePlayCdn: true
});
}
var tailwind_default = {
injectTailwind,
removeTailwind,
isTailwindLoaded,
getTailwind,
updateTailwindConfig,
addCustomStyles,
removeCustomStyles,
initServlyTailwind,
DEFAULT_SERVLY_TAILWIND_CONFIG
};
export {
injectTailwind,
removeTailwind,
isTailwindLoaded,
getTailwind,
updateTailwindConfig,
addCustomStyles,
removeCustomStyles,
DEFAULT_SERVLY_TAILWIND_CONFIG,
initServlyTailwind,
tailwind_default
};
var __getOwnPropNames = Object.getOwnPropertyNames;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
export {
__require,
__commonJS
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import {
require_react
} from "./chunk-OHWFJHAT.js";
import "./chunk-MCKGQKYU.js";
export default require_react();
import {
buildRegistryFromBundle,
collectAllDependencies,
createRegistry,
detectCircularDependencies,
extractDependencies,
extractDependenciesFromCode
} from "./chunk-CIUQK4GA.js";
import "./chunk-MCKGQKYU.js";
export {
buildRegistryFromBundle,
collectAllDependencies,
createRegistry,
detectCircularDependencies,
extractDependencies,
extractDependenciesFromCode
};

Sorry, the diff of this file is too big to display

import {
DEFAULT_SERVLY_TAILWIND_CONFIG,
addCustomStyles,
getTailwind,
initServlyTailwind,
injectTailwind,
isTailwindLoaded,
removeCustomStyles,
removeTailwind,
tailwind_default,
updateTailwindConfig
} from "./chunk-IWFVKY5N.js";
import "./chunk-MCKGQKYU.js";
export {
DEFAULT_SERVLY_TAILWIND_CONFIG,
addCustomStyles,
tailwind_default as default,
getTailwind,
initServlyTailwind,
injectTailwind,
isTailwindLoaded,
removeCustomStyles,
removeTailwind,
updateTailwindConfig
};
+2
-1
{
"name": "@servlyadmin/runtime-core",
"version": "0.1.9",
"version": "0.1.10",
"description": "Framework-agnostic core renderer for Servly components",

@@ -19,2 +19,3 @@ "type": "module",

"scripts": {
"build:pkg": "tsup src/index.ts --format esm,cjs --clean",
"build": "tsup src/index.ts --format esm,cjs --dts --clean",

@@ -21,0 +22,0 @@ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",

// packages/runtime-core/src/registry.ts
function createRegistry() {
const components = /* @__PURE__ */ new Map();
return {
get(id, version) {
if (version) {
const key = `${id}@${version}`;
if (components.has(key)) {
return components.get(key);
}
}
for (const [key, component] of components) {
if (key.startsWith(`${id}@`)) {
return component;
}
}
return components.get(id);
},
has(id, version) {
if (version) {
return components.has(`${id}@${version}`);
}
for (const key of components.keys()) {
if (key.startsWith(`${id}@`) || key === id) {
return true;
}
}
return false;
},
set(id, version, component) {
components.set(`${id}@${version}`, component);
}
};
}
function buildRegistryFromBundle(data) {
const registry = createRegistry();
registry.set(data.id, data.version, {
layout: data.layout,
propsInterface: data.propsInterface
});
if (data.bundle) {
for (const [key, component] of Object.entries(data.bundle)) {
const [id, version] = key.split("@");
if (id && version) {
registry.set(id, version, component);
}
}
}
return registry;
}
function extractDependencies(elements) {
const dependencies = [];
for (const element of elements) {
const config = element.configuration;
if (!config) continue;
if (config.componentViewRef) {
dependencies.push({
id: config.componentViewRef,
version: config.componentViewVersion,
type: "viewRef",
elementId: element.i
});
}
if (config.blueprint) {
dependencies.push({
id: config.blueprint,
version: config.blueprintVersion,
type: "blueprint",
elementId: element.i
});
}
}
return dependencies;
}
function extractDependenciesFromCode(code) {
const dependencies = [];
const pattern = /renderDynamicList\s*\(\s*\{[^}]*blueprint\s*:\s*["']([^"']+)["']/g;
let match;
while ((match = pattern.exec(code)) !== null) {
dependencies.push({
id: match[1],
type: "blueprint"
});
}
return dependencies;
}
async function collectAllDependencies(rootId, rootVersion, fetchComponent, maxDepth = 10) {
const manifest = {};
const visited = /* @__PURE__ */ new Set();
async function collect(id, version, via, depth) {
if (depth > maxDepth) {
console.warn(`Max dependency depth (${maxDepth}) reached for ${id}`);
return;
}
const key = `${id}@${version || "latest"}`;
if (visited.has(key)) {
return;
}
visited.add(key);
try {
const component = await fetchComponent(id, version);
if (!component) {
console.warn(`Dependency not found: ${id}@${version || "latest"}`);
return;
}
manifest[id] = {
version: version || "latest",
resolved: component.version,
type: via ? "viewRef" : "viewRef",
// Will be set by caller
via
};
const nestedDeps = extractDependencies(component.layout);
for (const dep of nestedDeps) {
await collect(dep.id, dep.version, id, depth + 1);
}
} catch (error) {
console.error(`Failed to fetch dependency ${id}:`, error);
}
}
const rootComponent = await fetchComponent(rootId, rootVersion);
if (rootComponent) {
const rootDeps = extractDependencies(rootComponent.layout);
for (const dep of rootDeps) {
manifest[dep.id] = {
version: dep.version || "latest",
resolved: "",
// Will be filled when fetched
type: dep.type
};
await collect(dep.id, dep.version, void 0, 1);
}
}
return manifest;
}
function detectCircularDependencies(manifest) {
const graph = /* @__PURE__ */ new Map();
for (const [id, entry] of Object.entries(manifest)) {
if (entry.via) {
const deps = graph.get(entry.via) || [];
deps.push(id);
graph.set(entry.via, deps);
}
}
const visited = /* @__PURE__ */ new Set();
const stack = /* @__PURE__ */ new Set();
const path = [];
function dfs(node) {
if (stack.has(node)) {
const cycleStart = path.indexOf(node);
return [...path.slice(cycleStart), node];
}
if (visited.has(node)) {
return null;
}
visited.add(node);
stack.add(node);
path.push(node);
const neighbors = graph.get(node) || [];
for (const neighbor of neighbors) {
const cycle = dfs(neighbor);
if (cycle) return cycle;
}
stack.delete(node);
path.pop();
return null;
}
for (const node of graph.keys()) {
const cycle = dfs(node);
if (cycle) return cycle;
}
return null;
}
export {
createRegistry,
buildRegistryFromBundle,
extractDependencies,
extractDependenciesFromCode,
collectAllDependencies,
detectCircularDependencies
};
// packages/runtime-core/src/tailwind.ts
var DEFAULT_TAILWIND_CDN = "https://cdn.tailwindcss.com";
var tailwindInjected = false;
var tailwindScript = null;
function injectTailwind(config = {}) {
return new Promise((resolve, reject) => {
if (tailwindInjected && tailwindScript) {
resolve();
return;
}
if (typeof document === "undefined") {
resolve();
return;
}
if (window.tailwind) {
tailwindInjected = true;
config.onReady?.();
resolve();
return;
}
const {
cdnUrl = DEFAULT_TAILWIND_CDN,
config: tailwindConfig,
plugins = [],
usePlayCdn = false,
onReady,
onError
} = config;
const script = document.createElement("script");
script.src = usePlayCdn ? `${cdnUrl}?plugins=forms,typography,aspect-ratio` : cdnUrl;
script.async = true;
script.onload = () => {
tailwindInjected = true;
tailwindScript = script;
if (tailwindConfig && window.tailwind) {
window.tailwind.config = tailwindConfig;
}
onReady?.();
resolve();
};
script.onerror = (event) => {
const error = new Error(`Failed to load Tailwind CSS from ${cdnUrl}`);
onError?.(error);
reject(error);
};
document.head.appendChild(script);
});
}
function removeTailwind() {
if (tailwindScript && tailwindScript.parentNode) {
tailwindScript.parentNode.removeChild(tailwindScript);
tailwindScript = null;
tailwindInjected = false;
delete window.tailwind;
}
}
function isTailwindLoaded() {
return tailwindInjected || !!window.tailwind;
}
function getTailwind() {
return window.tailwind;
}
function updateTailwindConfig(config) {
if (window.tailwind) {
window.tailwind.config = {
...window.tailwind.config,
...config
};
}
}
function addCustomStyles(css, id) {
if (typeof document === "undefined") {
throw new Error("addCustomStyles can only be used in browser environment");
}
const styleId = id || `servly-custom-styles-${Date.now()}`;
let existingStyle = document.getElementById(styleId);
if (existingStyle) {
existingStyle.textContent = css;
return existingStyle;
}
const style = document.createElement("style");
style.id = styleId;
style.textContent = css;
document.head.appendChild(style);
return style;
}
function removeCustomStyles(id) {
if (typeof document === "undefined") return;
const style = document.getElementById(id);
if (style && style.parentNode) {
style.parentNode.removeChild(style);
}
}
var DEFAULT_SERVLY_TAILWIND_CONFIG = {
theme: {
extend: {
// Add any Servly-specific theme extensions here
}
},
// Safelist common dynamic classes
safelist: [
// Spacing
{ pattern: /^(p|m|gap)-/ },
// Sizing
{ pattern: /^(w|h|min-w|min-h|max-w|max-h)-/ },
// Flexbox
{ pattern: /^(flex|justify|items|self)-/ },
// Grid
{ pattern: /^(grid|col|row)-/ },
// Colors
{ pattern: /^(bg|text|border|ring)-/ },
// Typography
{ pattern: /^(font|text|leading|tracking)-/ },
// Borders
{ pattern: /^(rounded|border)-/ },
// Effects
{ pattern: /^(shadow|opacity|blur)-/ },
// Transforms
{ pattern: /^(scale|rotate|translate|skew)-/ },
// Transitions
{ pattern: /^(transition|duration|ease|delay)-/ }
]
};
async function initServlyTailwind(customConfig) {
const config = customConfig ? { ...DEFAULT_SERVLY_TAILWIND_CONFIG, ...customConfig } : DEFAULT_SERVLY_TAILWIND_CONFIG;
await injectTailwind({
config,
usePlayCdn: true
});
}
var tailwind_default = {
injectTailwind,
removeTailwind,
isTailwindLoaded,
getTailwind,
updateTailwindConfig,
addCustomStyles,
removeCustomStyles,
initServlyTailwind,
DEFAULT_SERVLY_TAILWIND_CONFIG
};
export {
injectTailwind,
removeTailwind,
isTailwindLoaded,
getTailwind,
updateTailwindConfig,
addCustomStyles,
removeCustomStyles,
DEFAULT_SERVLY_TAILWIND_CONFIG,
initServlyTailwind,
tailwind_default
};

Sorry, the diff of this file is too big to display

import {
buildRegistryFromBundle,
collectAllDependencies,
createRegistry,
detectCircularDependencies,
extractDependencies,
extractDependenciesFromCode
} from "./chunk-EQFZFPI7.mjs";
export {
buildRegistryFromBundle,
collectAllDependencies,
createRegistry,
detectCircularDependencies,
extractDependencies,
extractDependenciesFromCode
};
import {
DEFAULT_SERVLY_TAILWIND_CONFIG,
addCustomStyles,
getTailwind,
initServlyTailwind,
injectTailwind,
isTailwindLoaded,
removeCustomStyles,
removeTailwind,
tailwind_default,
updateTailwindConfig
} from "./chunk-RKUT63EF.mjs";
export {
DEFAULT_SERVLY_TAILWIND_CONFIG,
addCustomStyles,
tailwind_default as default,
getTailwind,
initServlyTailwind,
injectTailwind,
isTailwindLoaded,
removeCustomStyles,
removeTailwind,
updateTailwindConfig
};

Sorry, the diff of this file is too big to display