
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@dataset-viewer/sdk
Advanced tools
Dataset Viewer Plugin SDK - Types, utilities, and tools for plugin development
Dataset Viewer Plugin SDK - 为插件开发者提供类型定义、工具函数和开发辅助工具。
npm install @dataset-viewer/sdk
# 或
pnpm add @dataset-viewer/sdk
# 或
yarn add @dataset-viewer/sdk
import { createPlugin, PluginLogger } from '@dataset-viewer/sdk';
import type { PluginViewerProps } from '@dataset-viewer/sdk';
// 创建插件组件
const TextViewer: React.FC<PluginViewerProps> = ({ file, fileAccessor }) => {
const [content, setContent] = useState<string>('');
const logger = new PluginLogger('text-viewer');
useEffect(() => {
const loadContent = async () => {
try {
logger.time('load-content');
const text = await fileAccessor.getTextContent();
setContent(text);
logger.timeEnd('load-content');
} catch (error) {
logger.error('Failed to load content:', error);
}
};
loadContent();
}, [file.path]);
return (
<div className="p-4">
<pre className="whitespace-pre-wrap">{content}</pre>
</div>
);
};
// 创建插件包
const plugin = createPlugin({
metadata: {
id: 'text-viewer',
name: 'Text Viewer',
version: '1.0.0',
description: 'Simple text file viewer',
author: 'Your Name',
supportedExtensions: ['.txt', '.md', '.log'],
mimeTypes: {
'.txt': 'text/plain',
'.md': 'text/markdown',
'.log': 'text/plain',
},
category: 'viewer',
minAppVersion: '1.0.0',
},
component: TextViewer,
initialize: async () => {
console.log('Text viewer plugin initialized');
},
cleanup: async () => {
console.log('Text viewer plugin cleaned up');
},
});
export default plugin;
插件包的完整定义,包含元数据、组件和生命周期函数。
插件元数据,描述插件的基本信息:
id: 插件唯一标识符name: 插件显示名称version: 插件版本supportedExtensions: 支持的文件扩展名category: 插件分类 ('viewer' | 'editor' | 'converter' | 'analyzer')插件组件接收的属性:
file: 文件信息 (name, size, path)content: 预加载的文件内容(可选)fileAccessor: 文件访问器isLargeFile: 是否为大文件onError: 错误处理回调创建标准的插件包,自动验证和标准化配置。
const plugin = createPlugin({
metadata: { /* ... */ },
component: YourComponent,
initialize: async () => { /* ... */ },
cleanup: async () => { /* ... */ },
});
验证插件元数据的完整性和正确性。
const { valid, errors } = validatePluginMetadata(metadata);
if (!valid) {
console.error('Validation errors:', errors);
}
检查文件是否被插件支持。
if (isFileSupported('document.pdf', ['.pdf', '.doc'])) {
// 处理文件
}
提供统一的日志输出格式,支持开发模式下的调试。
const logger = new PluginLogger('my-plugin');
logger.info('Plugin loaded');
logger.error('Error occurred:', error);
logger.time('operation');
// ... do something
logger.timeEnd('operation');
统一的文件内容读取函数,自动处理不同的内容来源。
const content = await readFileContent(props, 'utf-8');
检测文件类型和分类。
const { extension, mimeType, category } = detectFileType('document.pdf');
// { extension: '.pdf', mimeType: 'application/pdf', category: 'document' }
import { handlePluginError, PluginLogger } from '@dataset-viewer/sdk';
const logger = new PluginLogger('my-plugin');
try {
// 插件逻辑
} catch (error) {
handlePluginError(error, onError, logger);
}
import { measurePerformance, PluginLogger } from '@dataset-viewer/sdk';
const logger = new PluginLogger('my-plugin');
const result = await measurePerformance(
async () => {
// 耗时操作
return await loadLargeFile();
},
'Load large file',
logger
);
import { createLoadingManager } from '@dataset-viewer/sdk';
const loadingManager = createLoadingManager(onLoadingChange);
loadingManager.setLoading(true);
// 执行操作
loadingManager.setLoading(false);
MIT
FAQs
Dataset Viewer Plugin SDK - Types, utilities, and tools for plugin development
We found that @dataset-viewer/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.