Socket
Socket
Sign inDemoInstall

@vuepress/utils

Package Overview
Dependencies
Maintainers
6
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vuepress/utils - npm Package Compare versions

Comparing version 2.0.0-beta.50-pre.1 to 2.0.0-rc.0

101

dist/index.d.ts

@@ -1,2 +0,1 @@

export { default as chalk } from 'chalk';
export { default as debug } from 'debug';

@@ -6,6 +5,30 @@ export { default as fs } from 'fs-extra';

export { default as hash } from 'hash-sum';
import { Ora } from 'ora';
export { default as ora } from 'ora';
export { default as colors } from 'picocolors';
export { default as path } from 'upath';
import { HeadConfig, HeadAttrsConfig } from '@vuepress/shared';
/**
* Format millisecond
*/
declare const formatMs: (ms: number) => string;
declare const info: (...args: any[]) => void;
declare const tip: (...args: any[]) => void;
declare const success: (...args: any[]) => void;
declare const warn: (...args: any[]) => void;
declare const error: (...args: any[]) => void;
declare const createError: (message?: string | undefined) => Error;
declare const logger: {
info: (...args: any[]) => void;
tip: (...args: any[]) => void;
success: (...args: any[]) => void;
warn: (...args: any[]) => void;
error: (...args: any[]) => void;
createError: (message?: string | undefined) => Error;
};
declare const withSpinner: (msg: string) => <T>(target: (spinner?: Ora) => Promise<T>) => Promise<T>;
declare const getDirname: (importMetaUrl: string) => string;

@@ -30,16 +53,3 @@

declare const info: (...args: any[]) => void;
declare const tip: (...args: any[]) => void;
declare const success: (...args: any[]) => void;
declare const warn: (...args: any[]) => void;
declare const error: (...args: any[]) => void;
declare const createError: (message?: string | undefined) => Error;
declare const logger: {
info: (...args: any[]) => void;
tip: (...args: any[]) => void;
success: (...args: any[]) => void;
warn: (...args: any[]) => void;
error: (...args: any[]) => void;
createError: (message?: string | undefined) => Error;
};
declare const sanitizeFileName: (name: string) => string;

@@ -56,4 +66,61 @@ /**

declare const withSpinner: (msg: string) => <T>(target: () => Promise<T>) => Promise<T>;
/**
* HTML outlets of the template renderer
*/
declare const TEMPLATE_RENDERER_OUTLETS: {
CONTENT: string;
HEAD: string;
LANG: string;
PREFETCH: string;
PRELOAD: string;
SCRIPTS: string;
STYLES: string;
VERSION: string;
};
/**
* Context type of the template renderer
*/
interface TemplateRendererContext {
/**
* The rendered page content. Typically to be put inside `<div id="app"></div>`
*/
content: string;
/**
* The rendered page head. Typically to be put inside `<head></head>`
*/
head: string;
/**
* The language of the page. Typically to be put inside `<html lang="{{ lang }}">`
*/
lang: string;
/**
* The rendered prefetch links. Typically to be put inside `<head></head>`
*/
prefetch: string;
/**
* The rendered preload links. Typically to be put inside `<head></head>`
*/
preload: string;
/**
* The rendered scripts. Typically to be put before `</body>`
*/
scripts: string;
/**
* The rendered styles. Typically to be put inside `<head></head>`
*/
styles: string;
/**
* The version of VuePress
*/
version: string;
}
/**
* Type of the template renderer function
*/
type TemplateRenderer = (template: string, context: TemplateRendererContext) => string | Promise<string>;
/**
* The default template renderer implementation
*/
declare const templateRenderer: TemplateRenderer;
export { createError, error, getDirname, importFile, importFileDefault, info, isChildPath, logger, renderHead, renderHeadAttrs, success, tip, warn, withSpinner };
export { TEMPLATE_RENDERER_OUTLETS, TemplateRenderer, TemplateRendererContext, createError, error, formatMs, getDirname, importFile, importFileDefault, info, isChildPath, logger, renderHead, renderHeadAttrs, sanitizeFileName, success, templateRenderer, tip, warn, withSpinner };

129

dist/index.js
// src/index.ts
import chalk2 from "chalk";
import debug from "debug";

@@ -8,42 +7,28 @@ import fs from "fs-extra";

import ora2 from "ora";
import colors2 from "picocolors";
import path3 from "upath";
// src/getDirname.ts
import { fileURLToPath } from "url";
import path from "upath";
var getDirname = (importMetaUrl) => path.dirname(fileURLToPath(importMetaUrl));
// src/importFile.ts
import { pathToFileURL } from "url";
var importFile = (filePath) => import(pathToFileURL(filePath).toString());
var importFileDefault = (filePath) => importFile(filePath).then((m) => m.default);
// src/isChildPath.ts
import path2 from "upath";
var isChildPath = (child, parent) => {
const childPath = path2.normalize(child);
const parentPath = path2.normalize(parent);
if (!path2.win32.isAbsolute(childPath) || !path2.win32.isAbsolute(parentPath)) {
return false;
}
const relativePath = path2.relative(parentPath, childPath);
return relativePath === "" || !relativePath.startsWith("..");
// src/console/formatMs.ts
var formatMs = (ms) => {
if (ms < 1e3)
return `${ms}ms`;
return `${(ms / 1e3).toFixed(2)}s`;
};
// src/logger.ts
import chalk from "chalk";
// src/console/logger.ts
import colors from "picocolors";
var info = (...args) => {
console.log(chalk.cyan("info"), ...args);
console.log(colors.cyan("info"), ...args);
};
var tip = (...args) => {
console.log(chalk.blue("tip"), ...args);
console.log(colors.blue("tip"), ...args);
};
var success = (...args) => {
console.log(chalk.green("success"), ...args);
console.log(colors.green("success"), ...args);
};
var warn = (...args) => {
console.warn(chalk.yellow("warning"), ...args);
console.warn(colors.yellow("warning"), ...args);
};
var error = (...args) => {
console.error(chalk.red("error"), ...args);
console.error(colors.red("error"), ...args);
};

@@ -63,3 +48,53 @@ var createError = (message) => {

// src/renderHeadAttrs.ts
// src/console/withSpinner.ts
import process from "process";
import ora from "ora";
var withSpinner = (msg) => async (target) => {
if (process.env.DEBUG) {
return target();
}
const start = Date.now();
const spinner = ora();
try {
spinner.start(msg);
const result = await target(spinner);
spinner.succeed(`${msg} - done in ${formatMs(Date.now() - start)}`);
return result;
} catch (e) {
spinner.fail(`${msg} - failed in ${formatMs(Date.now() - start)}`);
throw e;
}
};
// src/module/getDirname.ts
import { fileURLToPath } from "url";
import path from "upath";
var getDirname = (importMetaUrl) => path.dirname(fileURLToPath(importMetaUrl));
// src/module/importFile.ts
import { pathToFileURL } from "url";
var importFile = (filePath) => import(pathToFileURL(filePath).toString());
var importFileDefault = (filePath) => importFile(filePath).then((m) => m.default);
// src/module/isChildPath.ts
import path2 from "upath";
var isChildPath = (child, parent) => {
const childPath = path2.normalize(child);
const parentPath = path2.normalize(parent);
if (!path2.win32.isAbsolute(childPath) || !path2.win32.isAbsolute(parentPath)) {
return false;
}
const relativePath = path2.relative(parentPath, childPath);
return relativePath === "" || !relativePath.startsWith("..");
};
// src/module/sanitizeFileName.ts
var INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g;
var DRIVE_LETTER_REGEX = /^[a-z]:/i;
var sanitizeFileName = (name) => {
const driveLetter = DRIVE_LETTER_REGEX.exec(name)?.[0] || "";
return driveLetter + name.substring(driveLetter.length).replace(INVALID_CHAR_REGEX, "_").replace(/^_+/, "");
};
// src/ssr/renderHeadAttrs.ts
var renderHeadAttrs = (attrs) => Object.entries(attrs).filter((item) => item[1] !== false).map(

@@ -69,3 +104,3 @@ ([key, value]) => value === true ? ` ${key}` : ` ${key}="${attrs[key]}"`

// src/renderHead.ts
// src/ssr/renderHead.ts
var renderHead = ([

@@ -83,25 +118,21 @@ tag,

// src/withSpinner.ts
import process from "process";
import ora from "ora";
var withSpinner = (msg) => async (target) => {
if (process.env.DEBUG) {
return target();
}
const spinner = ora();
try {
spinner.start(msg);
const result = await target();
spinner.succeed(`${msg} - done`);
return result;
} catch (e) {
spinner.fail(`${msg} - failed`);
throw e;
}
// src/ssr/templateRenderer.ts
var TEMPLATE_RENDERER_OUTLETS = {
CONTENT: "<!--vuepress-ssr-content-->",
HEAD: "<!--vuepress-ssr-head-->",
LANG: "{{ lang }}",
PREFETCH: "<!--vuepress-ssr-prefetch-->",
PRELOAD: "<!--vuepress-ssr-preload-->",
SCRIPTS: "<!--vuepress-ssr-scripts-->",
STYLES: "<!--vuepress-ssr-styles-->",
VERSION: "{{ version }}"
};
var templateRenderer = (template, { content, head, lang, prefetch, preload, scripts, styles, version }) => template.replace(TEMPLATE_RENDERER_OUTLETS.CONTENT, () => content).replace(TEMPLATE_RENDERER_OUTLETS.HEAD, head).replace(TEMPLATE_RENDERER_OUTLETS.LANG, lang).replace(TEMPLATE_RENDERER_OUTLETS.PREFETCH, prefetch).replace(TEMPLATE_RENDERER_OUTLETS.PRELOAD, preload).replace(TEMPLATE_RENDERER_OUTLETS.SCRIPTS, scripts).replace(TEMPLATE_RENDERER_OUTLETS.STYLES, styles).replace(TEMPLATE_RENDERER_OUTLETS.VERSION, version);
export {
chalk2 as chalk,
TEMPLATE_RENDERER_OUTLETS,
colors2 as colors,
createError,
debug,
error,
formatMs,
fs,

@@ -120,3 +151,5 @@ getDirname,

renderHeadAttrs,
sanitizeFileName,
success,
templateRenderer,
tip,

@@ -123,0 +156,0 @@ warn,

{
"name": "@vuepress/utils",
"version": "2.0.0-beta.50-pre.1",
"version": "2.0.0-rc.0",
"description": "Utils package of VuePress",

@@ -30,13 +30,13 @@ "keywords": [

"dependencies": {
"@types/debug": "^4.1.7",
"@types/fs-extra": "^9.0.13",
"@types/hash-sum": "^1.0.0",
"@vuepress/shared": "2.0.0-beta.50-pre.1",
"chalk": "^5.0.1",
"@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4",
"@types/hash-sum": "^1.0.2",
"debug": "^4.3.4",
"fs-extra": "^10.1.0",
"globby": "^13.1.2",
"fs-extra": "^11.1.1",
"globby": "^14.0.0",
"hash-sum": "^2.0.0",
"ora": "^6.1.2",
"upath": "^2.0.1"
"ora": "^7.0.1",
"picocolors": "^1.0.0",
"upath": "^2.0.1",
"@vuepress/shared": "2.0.0-rc.0"
},

@@ -57,3 +57,3 @@ "publishConfig": {

"sourcemap": false,
"target": "es2020",
"target": "es2022",
"tsconfig": "../tsconfig.dts.json"

@@ -60,0 +60,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc