🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

vite-plugin-md

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-md - npm Package Compare versions

Comparing version

to
0.22.5

import { UserConfig, InlineConfig, Plugin } from 'vite';
import MarkdownIt from 'markdown-it';
import { BuilderApi, BuilderOptions, BuilderDependencyApi, BuilderRegistration } from '@yankeeinlondon/builder-api';
import { ConfiguredBuilder, BuilderOptions } from '@yankeeinlondon/builder-api';
import { MaybeRef } from '@vueuse/core';

@@ -12,45 +12,23 @@ import * as TE from 'fp-ts/lib/TaskEither.js';

declare enum PipelineStage {
/**
* Initialized with incoming filename, config, options,
* available events (core and provided by builders).
*/
initialize = "initialize",
/**
* All frontmatter has been extracted from default values and page values
* but no mapping has been done yet.
*
* Note: this is the event hook which the included `meta` builder connects
* to and it in turn _provides_ a `metaMapped` hook.
*/
metaExtracted = "metaExtracted",
/**
* The **MarkdownIt** parser is initialized, all builders
* connecting at this point will receive a valid `md` parser
* object so that they can participate in MD-to-HTML parsing.
*/
parser = "parser",
/**
* The **MarkdownIt** parser is initialized and all builders
* have been able to apply their customizations to it.
*/
parsed = "parsed",
/**
* The HTML has been converted to a HappyDom tree to allow
* interested parties to manipulate contents using DOM based
* queries.
*/
dom = "dom",
/**
* SFC blocks (template, script, and an array of customBlocks) are ready for
* builders to inspect/mutate/etc.
*/
sfcBlocksExtracted = "sfcBlocksExtracted",
/**
* All mutations of page are complete; builders can hook into this stage but
* will _not_ be able to mutate at this stage.
*/
closeout = "closeout"
}
type IPipelineStage = EnumValues<PipelineStage>;
/**
* **PipelineStage**
*
* The _stage_ in the transformation pipeline:
*
* - `initialize` - meant for configuration settings
* - `metaExtracted` - all frontmatter has been separated from the text content
* giving you a clear but raw markdown content and frontmatter key/value
* - `parser` - a **markdown-it** parser is initialized; providing the `md` prop
* on the payload. This is where builders who want to act as a markdown-it-plugin
* will want to engage.
* - `parsed` - The **MarkdownIt** parser is initialized and all builders
* have been able to apply their customizations to it.
* - `dom` - The HTML has been converted to a HappyDom tree to allow interested builders
* to manipulate contents using DOM based queries
* - `sfcBlocksExtracted` - SFC blocks (template, script, and an array of customBlocks)
* are ready for builders to inspect/mutate/etc.
* - `closeout` - All mutations of page are complete; builders can hook into this stage
* but will _not_ be able to mutate at this stage
*/
type PipelineStage = 'initialize' | 'metaExtracted' | 'parser' | 'parsed' | 'dom' | 'sfcBlocksExtracted' | 'closeout';
interface RulesUse {

@@ -61,4 +39,3 @@ ruleName: string;

}
type PipelineInitializer = (i?: Pipeline<PipelineStage.initialize>) => Pipeline<PipelineStage.initialize>;
type Parser<S extends IPipelineStage> = S extends 'parser' | 'parsed' | 'dom' | 'sfcBlocksExtracted' | 'closeout' ? {
type Parser<S extends PipelineStage> = S extends 'parser' | 'parsed' | 'dom' | 'sfcBlocksExtracted' | 'closeout' ? {
/** the **MarkdownIT** parser instance */

@@ -143,6 +120,3 @@ parser: MarkdownIt;

/** types available _only_ during initialization */
type Initialization<S extends IPipelineStage> = S extends 'initialize' ? {
/** allows a Builder API to express a dependency on another Builder API */
usesBuilder: <T extends BuilderApi<BuilderOptions, IPipelineStage>>(builder: T) => BuilderDependencyApi<T>;
} : {};
type Initialization<S extends PipelineStage> = S extends 'initialize' ? {} : {};
interface PipelineUtilityFunctions {

@@ -177,3 +151,3 @@ /**

}
type MetaExtracted<S extends IPipelineStage> = S extends 'initialize' ? {} : {
type MetaExtracted<S extends PipelineStage> = S extends 'initialize' ? {} : {
/** the frontmatter metadata */

@@ -192,3 +166,3 @@ frontmatter: Frontmatter;

} & PipelineUtilityFunctions;
type HtmlContent<S extends IPipelineStage> = S extends 'parsed' | 'sfcBlocksExtracted' | 'closeout' ? {
type HtmlContent<S extends PipelineStage> = S extends 'parsed' | 'sfcBlocksExtracted' | 'closeout' ? {
/**

@@ -209,3 +183,3 @@ * the HTML produced from MD content (and using parser rules passed in)

} : {};
type Blocks<S extends IPipelineStage> = S extends 'sfcBlocksExtracted' | 'closeout' ? {
type Blocks<S extends PipelineStage> = S extends 'sfcBlocksExtracted' | 'closeout' ? {
/** the SFC's template block (aka, html content) */

@@ -228,3 +202,3 @@ templateBlock: string;

} : {};
type Completed<S extends IPipelineStage> = S extends 'closeout' ? {
type Completed<S extends PipelineStage> = S extends 'closeout' ? {
/** the finalized component in string form */

@@ -235,3 +209,4 @@ component: string;

} : {};
type Pipeline<S extends IPipelineStage> = {
type Pipeline<S extends PipelineStage, B extends readonly ConfiguredBuilder<string, BuilderOptions, PipelineStage, string>[] = readonly ConfiguredBuilder<string, BuilderOptions, PipelineStage, string>[]> = {
stage: S;
/** the underlying filename of the source */

@@ -242,3 +217,3 @@ fileName: string;

/** the `vite-plugin-md` options */
options: ResolvedOptions;
options: ResolvedOptions<B>;
/** the Vite config */

@@ -287,3 +262,3 @@ viteConfig: UserConfig;

*/
type PipeEither<S extends IPipelineStage> = Either<string, Pipeline<S>>;
type PipeEither<S extends PipelineStage, B extends readonly GenericBuilder[]> = Either<string, Pipeline<S, B>>;
/**

@@ -294,7 +269,7 @@ * Carries an `TaskEither<T>` condition which is either:

*/
type PipeTask<S extends IPipelineStage> = TE.TaskEither<string, Pipeline<S>>;
type PipeTask<S extends PipelineStage, B extends readonly ConfiguredBuilder<string, {}, PipelineStage, string>[]> = TE.TaskEither<string, Pipeline<S, B>>;
/**
* A pipeline payload or either an async `PipeTask<S>` or a synchronous `PipeEither<S>`
*/
type PipelinePayload<S extends IPipelineStage> = PipeTask<S> | PipeEither<S>;
type PipelinePayload<S extends PipelineStage, B extends readonly GenericBuilder[]> = PipeTask<S, B> | PipeEither<S, B>;
/**

@@ -306,3 +281,3 @@ * A _synchronous_ transformer function which:

*/
type SyncPipelineTransformer<F extends IPipelineStage, T extends IPipelineStage> = (payload: PipeTask<F>) => PipeTask<T>;
type SyncPipelineTransformer<F extends PipelineStage, T extends PipelineStage, B extends readonly GenericBuilder[]> = (payload: PipeTask<F, B>) => PipeTask<T, B>;
/**

@@ -314,4 +289,5 @@ * An _asynchronous_ transformer function which:

*/
type AsyncPipelineTransformer<F extends IPipelineStage, T extends IPipelineStage> = (payload: PipeTask<F>) => PipeTask<T>;
type AsyncPipelineTransformer<F extends PipelineStage, T extends PipelineStage, B extends readonly GenericBuilder[]> = (payload: PipeTask<F, B>) => PipeTask<T, B>;
type GenericBuilder = ConfiguredBuilder<string, BuilderOptions, PipelineStage, string>;
/**

@@ -479,3 +455,3 @@ * The key/value definition for Route Properties.

}
interface Options {
interface Options<B extends readonly ConfiguredBuilder<string, BuilderOptions, PipelineStage, string>[]> {
style?: {

@@ -485,3 +461,3 @@ baseStyle?: 'none' | 'github';

/** allows adding in Builder's which help to expand functionality of this plugin */
builders?: readonly BuilderRegistration<BuilderOptions, IPipelineStage>[];
builders?: B;
/**

@@ -582,3 +558,3 @@ * Explicitly set the Vue version.

*/
frontmatterPreprocess?: (frontmatter: Frontmatter, options: ResolvedOptions) => ProcessedFrontmatter;
frontmatterPreprocess?: (frontmatter: Frontmatter, options: ResolvedOptions<B>) => ProcessedFrontmatter;
/**

@@ -665,3 +641,3 @@ * Expose frontmatter via expose API

}
interface ResolvedOptions extends Required<Options> {
interface ResolvedOptions<B extends readonly ConfiguredBuilder<string, BuilderOptions, PipelineStage, string>[] = []> extends Required<Options<B>> {
wrapperClasses: string;

@@ -680,3 +656,3 @@ frontmatterDefaults: FmValueCallback | Record<string, FmAllowedValue>;

}
type WithConfig<T extends ResolvedOptions> = ViteConfigPassthrough & T;
type WithConfig<T extends ResolvedOptions<any>> = ViteConfigPassthrough & T;
type ReturnValues = string | string[] | number | boolean | Object;

@@ -688,3 +664,3 @@

*/
declare function composeSfcBlocks(id: string, raw: string, opts?: Omit<Options, 'usingBuilder'>, config?: Partial<ViteConfigPassthrough>): Promise<Pipeline<PipelineStage.closeout>>;
declare function composeSfcBlocks<B extends readonly GenericBuilder[] = []>(id: string, raw: string, opts?: Options<B>, config?: Partial<ViteConfigPassthrough>): Promise<Pipeline<"closeout", B>>;

@@ -697,4 +673,4 @@ type ViteConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {

}>;
declare function VitePluginMarkdown(userOptions?: Options): Plugin;
declare function VitePluginMarkdown<O extends Options<any>>(userOptions?: O): Plugin;
export { AsyncPipelineTransformer, BaseProperty, Blocks, Completed, EnumValues, ExcerptFunction, ExcerptMeta, FmAllowedValue, FmValueCallback, Frontmatter, GraymatterOptions, HeadProps, HtmlContent, IPipelineStage, Include, Initialization, LinkProperty, MetaExtracted, MetaProperty, Options, Parser, PipeEither, PipeTask, Pipeline, PipelineInitializer, PipelinePayload, PipelineStage, PipelineUtilityFunctions, ProcessedFrontmatter, ResolvedOptions, Retain, ReturnValues, RouteConfig, RouteProperties, RulesUse, ScriptProperty, SfcBlocks, StyleProperty, SyncPipelineTransformer, ViteConfig, ViteConfigPassthrough, WithConfig, composeSfcBlocks, VitePluginMarkdown as default };
export { AsyncPipelineTransformer, BaseProperty, Blocks, Completed, EnumValues, ExcerptFunction, ExcerptMeta, FmAllowedValue, FmValueCallback, Frontmatter, GenericBuilder, GraymatterOptions, HeadProps, HtmlContent, Include, Initialization, LinkProperty, MetaExtracted, MetaProperty, Options, Parser, PipeEither, PipeTask, Pipeline, PipelinePayload, PipelineStage, PipelineUtilityFunctions, ProcessedFrontmatter, ResolvedOptions, Retain, ReturnValues, RouteConfig, RouteProperties, RulesUse, ScriptProperty, SfcBlocks, StyleProperty, SyncPipelineTransformer, ViteConfig, ViteConfigPassthrough, WithConfig, composeSfcBlocks, VitePluginMarkdown as default };
{
"name": "vite-plugin-md",
"version": "0.22.4",
"version": "0.22.5",
"description": "Markdown for Vite",

@@ -58,3 +58,3 @@ "type": "module",

"dependencies": {
"@yankeeinlondon/builder-api": "^1.2.2",
"@yankeeinlondon/builder-api": "^1.3.4",
"@yankeeinlondon/gray-matter": "^6.1.1",

@@ -66,4 +66,4 @@ "@yankeeinlondon/happy-wrapper": "^2.10.1",

"peerDependencies": {
"vite": "^4.0.0 || ^3.0.0",
"@vitejs/plugin-vue": ">=2.3.4"
"@vitejs/plugin-vue": ">=2.3.4",
"vite": "^4.0.0 || ^3.0.0"
},

@@ -83,3 +83,3 @@ "devDependencies": {

"@vue/test-utils": "^2.2.6",
"@vueuse/core": "^9.6.0",
"@vueuse/core": "^9.7.0",
"@yankeeinlondon/code-builder": "^1.2.1",

@@ -95,2 +95,3 @@ "@yankeeinlondon/link-builder": "^1.2.1",

"happy-dom": "^8.1.0",
"native-dash": "^1.25.0",
"npm-run-all": "^4.1.5",

@@ -97,0 +98,0 @@ "pathe": "^1.0.0",

Sorry, the diff of this file is not supported yet

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