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.67 to 2.0.0-beta.68

105

dist/index.d.ts

@@ -11,16 +11,3 @@ export { default as debug } from 'debug';

declare const getDirname: (importMetaUrl: string) => string;
/**
* A helper for dynamically importing a file path
*
* We need to use `pathToFileURL` to transform file path wo compat with windows
*/
declare const importFile: <T>(filePath: string) => Promise<T>;
/**
* A wrapper of `importFile` and returns the default export
*/
declare const importFileDefault: <T>(filePath: string) => Promise<T>;
/**
* Format millisecond

@@ -30,8 +17,2 @@ */

/**
* Check if `child` is a sub path of `parent` or not. Return `true` if
* they are the same path
*/
declare const isChildPath: (child: string, parent: string) => boolean;
declare const info: (...args: any[]) => void;

@@ -52,3 +33,26 @@ declare const tip: (...args: any[]) => void;

declare const withSpinner: (msg: string) => <T>(target: (spinner?: Ora) => Promise<T>) => Promise<T>;
declare const getDirname: (importMetaUrl: string) => string;
/**
* A helper for dynamically importing a file path
*
* We need to use `pathToFileURL` to transform file path wo compat with windows
*/
declare const importFile: <T>(filePath: string) => Promise<T>;
/**
* A wrapper of `importFile` and returns the default export
*/
declare const importFileDefault: <T>(filePath: string) => Promise<T>;
/**
* Check if `child` is a sub path of `parent` or not. Return `true` if
* they are the same path
*/
declare const isChildPath: (child: string, parent: string) => boolean;
declare const sanitizeFileName: (name: string) => string;
/**
* Render head config to string

@@ -63,6 +67,61 @@ */

declare const sanitizeFileName: (name: string) => string;
/**
* 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;
declare const withSpinner: (msg: string) => <T>(target: (spinner?: Ora) => Promise<T>) => Promise<T>;
export { createError, error, formatMs, getDirname, importFile, importFileDefault, info, isChildPath, logger, renderHead, renderHeadAttrs, sanitizeFileName, 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 };

@@ -10,13 +10,3 @@ // src/index.ts

// 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/formatMs.ts
// src/console/formatMs.ts
var formatMs = (ms) => {

@@ -28,15 +18,3 @@ if (ms < 1e3)

// 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/logger.ts
// src/console/logger.ts
import colors from "picocolors";

@@ -71,29 +49,3 @@ var info = (...args) => {

// src/renderHeadAttrs.ts
var renderHeadAttrs = (attrs) => Object.entries(attrs).filter((item) => item[1] !== false).map(
([key, value]) => value === true ? ` ${key}` : ` ${key}="${attrs[key]}"`
).join("");
// src/renderHead.ts
var renderHead = ([
tag,
attrs,
innerHTML = ""
]) => {
const openTag = `<${tag}${renderHeadAttrs(attrs)}>`;
if (tag === "link" || tag === "meta" || tag === "base") {
return openTag;
}
return `${openTag}${innerHTML}</${tag}>`;
};
// src/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/withSpinner.ts
// src/console/withSpinner.ts
import process from "process";

@@ -117,3 +69,65 @@ import ora from "ora";

};
// 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(
([key, value]) => value === true ? ` ${key}` : ` ${key}="${attrs[key]}"`
).join("");
// src/ssr/renderHead.ts
var renderHead = ([
tag,
attrs,
innerHTML = ""
]) => {
const openTag = `<${tag}${renderHeadAttrs(attrs)}>`;
if (tag === "link" || tag === "meta" || tag === "base") {
return openTag;
}
return `${openTag}${innerHTML}</${tag}>`;
};
// 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 {
TEMPLATE_RENDERER_OUTLETS,
colors2 as colors,

@@ -139,2 +153,3 @@ createError,

success,
templateRenderer,
tip,

@@ -141,0 +156,0 @@ warn,

{
"name": "@vuepress/utils",
"version": "2.0.0-beta.67",
"version": "2.0.0-beta.68",
"description": "Utils package of VuePress",

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

"dependencies": {
"@types/debug": "^4.1.8",
"@types/fs-extra": "^11.0.1",
"@types/hash-sum": "^1.0.0",
"@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4",
"@types/hash-sum": "^1.0.2",
"debug": "^4.3.4",
"fs-extra": "^11.1.1",
"globby": "^13.2.2",
"globby": "^14.0.0",
"hash-sum": "^2.0.0",

@@ -41,3 +41,3 @@ "ora": "^7.0.1",

"upath": "^2.0.1",
"@vuepress/shared": "2.0.0-beta.67"
"@vuepress/shared": "2.0.0-beta.68"
},

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

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

@@ -61,0 +61,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