@powerlines/plugin-unified 0.1.47 → 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +24 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +81 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +81 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +1 -0
- package/package.json +8 -8
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`@rollup/pluginutils`),t=require(`@stryke/type-checks`),n=require(`unified`);const r=(r={})=>{let i=(r?.rules??[]).map(r=>({...r,filter:(0,t.isFunction)(r.include)?r.include:(0,e.createFilter)(r.include,r.exclude),processor:Promise.resolve(r.setup((0,n.unified)()))})),a=[],o=[],s=[];for(let e of i)e.enforce===`pre`?a.push(e):e.enforce===`post`?o.push(e):s.push(e);return[{name:`unified:config`,config(){return{unified:{rules:i}}}},[a,s,o].map((e,n)=>{let r=[`pre`,void 0,`post`][n];if(e.length!==0)return{name:`unified${r?`:${r}`:``}`,enforce:r,transform:{filter:t=>e.some(e=>e.filter(t)),async handler(n,r){let i=e.find(e=>e.filter(r));if(!i)return;n=await i.transform?.pre?.(n,r)||n;let a=await(await i.processor).process(n),o=a.toString(),s=a.map;if(i.transform?.post){let e=await i.transform.post(o,r,s)||o;(0,t.isString)(e)?o=e:(o=e.code,s=e.map)}return{code:o,map:s}}}}}).filter(Boolean)].flat()};exports.default=r,exports.plugin=r;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule } from "./types/plugin.cjs";
|
|
2
|
+
import { Plugin } from "powerlines";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare module "powerlines" {
|
|
6
|
+
interface Config {
|
|
7
|
+
unified?: UnifiedPluginOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* UnifiedJs Transformations Plugin
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This plugin allows you to define transformations using the UnifiedJS ecosystem. You can specify rules that match certain files and apply Unified processors to transform their content. This is useful for processing markdown, HTML, or any other text-based files using Unified's powerful plugins and ecosystem.
|
|
15
|
+
*
|
|
16
|
+
* @see https://unified.js.org
|
|
17
|
+
*
|
|
18
|
+
* @param options - The plugin options.
|
|
19
|
+
* @returns A Powerlines plugin instance.
|
|
20
|
+
*/
|
|
21
|
+
declare const plugin: <TContext extends UnifiedPluginContext = UnifiedPluginContext>(options?: UnifiedPluginOptions) => Plugin<TContext>[];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule, plugin as default, plugin };
|
|
24
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAgCY,MAAA;IACR,OAAA,GAAU,oBAAA;EAAA;AAAA;;;;;;;;AAed;;;;cAAa,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule } from "./types/plugin.mjs";
|
|
2
|
+
import { Plugin } from "powerlines";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare module "powerlines" {
|
|
6
|
+
interface Config {
|
|
7
|
+
unified?: UnifiedPluginOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* UnifiedJs Transformations Plugin
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This plugin allows you to define transformations using the UnifiedJS ecosystem. You can specify rules that match certain files and apply Unified processors to transform their content. This is useful for processing markdown, HTML, or any other text-based files using Unified's powerful plugins and ecosystem.
|
|
15
|
+
*
|
|
16
|
+
* @see https://unified.js.org
|
|
17
|
+
*
|
|
18
|
+
* @param options - The plugin options.
|
|
19
|
+
* @returns A Powerlines plugin instance.
|
|
20
|
+
*/
|
|
21
|
+
declare const plugin: <TContext extends UnifiedPluginContext = UnifiedPluginContext>(options?: UnifiedPluginOptions) => Plugin<TContext>[];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule, plugin as default, plugin };
|
|
24
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAgCY,MAAA;IACR,OAAA,GAAU,oBAAA;EAAA;AAAA;;;;;;;;AAed;;;;cAAa,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createFilter as e}from"@rollup/pluginutils";import{isFunction as t,isString as n}from"@stryke/type-checks";import{unified as r}from"unified";const i=(i={})=>{let a=(i?.rules??[]).map(n=>({...n,filter:t(n.include)?n.include:e(n.include,n.exclude),processor:Promise.resolve(n.setup(r()))})),o=[],s=[],c=[];for(let e of a)e.enforce===`pre`?o.push(e):e.enforce===`post`?s.push(e):c.push(e);return[{name:`unified:config`,config(){return{unified:{rules:a}}}},[o,c,s].map((e,t)=>{let r=[`pre`,void 0,`post`][t];if(e.length!==0)return{name:`unified${r?`:${r}`:``}`,enforce:r,transform:{filter:t=>e.some(e=>e.filter(t)),async handler(t,r){let i=e.find(e=>e.filter(r));if(!i)return;t=await i.transform?.pre?.(t,r)||t;let a=await(await i.processor).process(t),o=a.toString(),s=a.map;if(i.transform?.post){let e=await i.transform.post(o,r,s)||o;n(e)?o=e:(o=e.code,s=e.map)}return{code:o,map:s}}}}}).filter(Boolean)].flat()};export{i as default,i as plugin};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { createFilter } from \"@rollup/pluginutils\";\nimport { isFunction, isString } from \"@stryke/type-checks\";\nimport { Plugin } from \"powerlines\";\nimport type { SourceMap } from \"rollup\";\nimport { unified } from \"unified\";\nimport {\n ResolvedUnifiedRule,\n UnifiedPluginContext,\n UnifiedPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n unified?: UnifiedPluginOptions;\n }\n}\n\n/**\n * UnifiedJs Transformations Plugin\n *\n * @remarks\n * This plugin allows you to define transformations using the UnifiedJS ecosystem. You can specify rules that match certain files and apply Unified processors to transform their content. This is useful for processing markdown, HTML, or any other text-based files using Unified's powerful plugins and ecosystem.\n *\n * @see https://unified.js.org\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends UnifiedPluginContext = UnifiedPluginContext\n>(\n options: UnifiedPluginOptions = {}\n): Plugin<TContext>[] => {\n const resolved = (options?.rules ?? []).map((rule): ResolvedUnifiedRule => {\n return {\n ...rule,\n filter: isFunction(rule.include)\n ? rule.include\n : createFilter(rule.include, rule.exclude),\n processor: Promise.resolve(rule.setup(unified()))\n };\n });\n\n const pre: ResolvedUnifiedRule[] = [];\n const post: ResolvedUnifiedRule[] = [];\n const normal: ResolvedUnifiedRule[] = [];\n\n for (const rule of resolved) {\n if (rule.enforce === \"pre\") pre.push(rule);\n else if (rule.enforce === \"post\") post.push(rule);\n else normal.push(rule);\n }\n\n return [\n {\n name: \"unified:config\",\n config() {\n return {\n unified: {\n rules: resolved\n }\n };\n }\n },\n [pre, normal, post]\n .map((rules, idx): Plugin<TContext> | undefined => {\n const enforce = ([\"pre\", undefined, \"post\"] as const)[idx];\n if (rules.length === 0) return undefined;\n\n return {\n name: `unified${enforce ? `:${enforce}` : \"\"}`,\n enforce,\n transform: {\n filter: (id: string) => rules.some(r => r.filter(id)),\n async handler(code, id) {\n const rule = rules.find(r => r.filter(id));\n if (!rule) return;\n\n code = (await rule.transform?.pre?.(code, id)) || code;\n\n const processor = await rule.processor;\n const result = await processor.process(code);\n\n let resultCode = result.toString();\n let resultMap = result.map;\n\n if (rule.transform?.post) {\n const postResult =\n (await rule.transform.post(\n resultCode,\n id,\n resultMap as SourceMap\n )) || resultCode;\n if (isString(postResult)) {\n resultCode = postResult;\n } else {\n resultCode = postResult.code;\n resultMap = postResult.map;\n }\n }\n\n return {\n code: resultCode,\n map: resultMap\n };\n }\n }\n };\n })\n .filter(Boolean)\n ].flat() as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":"oJAgDA,MAAa,GAGX,EAAgC,EAAE,GACX,CACvB,IAAM,GAAY,GAAS,OAAS,EAAE,EAAE,IAAK,IACpC,CACL,GAAG,EACH,OAAQ,EAAW,EAAK,QAAQ,CAC5B,EAAK,QACL,EAAa,EAAK,QAAS,EAAK,QAAQ,CAC5C,UAAW,QAAQ,QAAQ,EAAK,MAAM,GAAS,CAAC,CAAC,CAClD,EACD,CAEI,EAA6B,EAAE,CAC/B,EAA8B,EAAE,CAChC,EAAgC,EAAE,CAExC,IAAK,IAAM,KAAQ,EACb,EAAK,UAAY,MAAO,EAAI,KAAK,EAAK,CACjC,EAAK,UAAY,OAAQ,EAAK,KAAK,EAAK,CAC5C,EAAO,KAAK,EAAK,CAGxB,MAAO,CACL,CACE,KAAM,iBACN,QAAS,CACP,MAAO,CACL,QAAS,CACP,MAAO,EACR,CACF,EAEJ,CACD,CAAC,EAAK,EAAQ,EAAK,CAChB,KAAK,EAAO,IAAsC,CACjD,IAAM,EAAW,CAAC,MAAO,IAAA,GAAW,OAAO,CAAW,GAClD,KAAM,SAAW,EAErB,MAAO,CACL,KAAM,UAAU,EAAU,IAAI,IAAY,KAC1C,UACA,UAAW,CACT,OAAS,GAAe,EAAM,KAAK,GAAK,EAAE,OAAO,EAAG,CAAC,CACrD,MAAM,QAAQ,EAAM,EAAI,CACtB,IAAM,EAAO,EAAM,KAAK,GAAK,EAAE,OAAO,EAAG,CAAC,CAC1C,GAAI,CAAC,EAAM,OAEX,EAAQ,MAAM,EAAK,WAAW,MAAM,EAAM,EAAG,EAAK,EAGlD,IAAM,EAAS,MAAM,MADG,EAAK,WACE,QAAQ,EAAK,CAExC,EAAa,EAAO,UAAU,CAC9B,EAAY,EAAO,IAEvB,GAAI,EAAK,WAAW,KAAM,CACxB,IAAM,EACH,MAAM,EAAK,UAAU,KACpB,EACA,EACA,EACD,EAAK,EACJ,EAAS,EAAW,CACtB,EAAa,GAEb,EAAa,EAAW,KACxB,EAAY,EAAW,KAI3B,MAAO,CACL,KAAM,EACN,IAAK,EACN,EAEJ,CACF,EACD,CACD,OAAO,QAAQ,CACnB,CAAC,MAAM"}
|
|
File without changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule } from "./plugin.cjs";
|
|
2
|
+
export { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule } from "./plugin.mjs";
|
|
2
|
+
export { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
2
|
+
import { FilterPattern } from "@rollup/pluginutils";
|
|
3
|
+
import { MaybePromise } from "@stryke/types";
|
|
4
|
+
import { SourceMap } from "rollup";
|
|
5
|
+
import { Processor } from "unified";
|
|
6
|
+
|
|
7
|
+
//#region src/types/plugin.d.ts
|
|
8
|
+
interface UnifiedRule {
|
|
9
|
+
/**
|
|
10
|
+
* Include filter, accepts glob patterns, RegExp or a function.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* The following rules apply to the {@link include} and {@link exclude} options:
|
|
14
|
+
* If a function is provided, it will be called with the id of the file and should return a boolean indicating whether the rule should be applied.
|
|
15
|
+
* If a glob pattern or RegExp is provided, it will be used to create a filter function using `@rollup/pluginutils`'s `createFilter` function.
|
|
16
|
+
* If {@link include} is a function, the {@link exclude} option will be ignored.
|
|
17
|
+
* If {@link include} is not a function, the {@link exclude} option can be used to exclude files from being processed by this rule.
|
|
18
|
+
* If neither {@link include} nor {@link exclude} is provided, the rule will be applied to all files.
|
|
19
|
+
*/
|
|
20
|
+
include: FilterPattern | ((id: string) => boolean);
|
|
21
|
+
/**
|
|
22
|
+
* Exclude filter, accepts glob patterns, RegExp or a function.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* The following rules apply to the {@link include} and {@link exclude} options:
|
|
26
|
+
* If a function is provided, it will be called with the id of the file and should return a boolean indicating whether the rule should be applied.
|
|
27
|
+
* If a glob pattern or RegExp is provided, it will be used to create a filter function using `@rollup/pluginutils`'s `createFilter` function.
|
|
28
|
+
* If {@link include} is a function, the {@link exclude} option will be ignored.
|
|
29
|
+
* If {@link include} is not a function, the {@link exclude} option can be used to exclude files from being processed by this rule.
|
|
30
|
+
* If neither {@link include} nor {@link exclude} is provided, the rule will be applied to all files.
|
|
31
|
+
*
|
|
32
|
+
* @see https://rollupjs.org/guide/en/#plugincontext
|
|
33
|
+
*/
|
|
34
|
+
exclude?: FilterPattern;
|
|
35
|
+
/**
|
|
36
|
+
* Enforce the rule to be applied the in the build pipeline
|
|
37
|
+
*
|
|
38
|
+
* @see https://github.com/unjs/unplugin#hooks
|
|
39
|
+
*/
|
|
40
|
+
enforce?: "pre" | "post" | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Setup the unified processor
|
|
43
|
+
*/
|
|
44
|
+
setup: (unified: Processor) => MaybePromise<Processor<any, any, any, any, any>>;
|
|
45
|
+
/**
|
|
46
|
+
* Additional string transforms
|
|
47
|
+
*/
|
|
48
|
+
transform?: {
|
|
49
|
+
/**
|
|
50
|
+
* Preprocess the raw code before unified process
|
|
51
|
+
*/
|
|
52
|
+
pre?: (code: string, id: string) => MaybePromise<string | void>;
|
|
53
|
+
/**
|
|
54
|
+
* Postprocess the unified result.
|
|
55
|
+
* If a sourcemap is returned, the function is responsible for merging it with the unified result.
|
|
56
|
+
*/
|
|
57
|
+
post?: (code: string, id: string, map?: SourceMap) => MaybePromise<string | void | {
|
|
58
|
+
code: string;
|
|
59
|
+
map?: SourceMap | null;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
interface UnifiedPluginOptions {
|
|
64
|
+
rules?: UnifiedRule[];
|
|
65
|
+
}
|
|
66
|
+
type UnifiedPluginUserConfig = UserConfig & {
|
|
67
|
+
unified?: UnifiedPluginOptions;
|
|
68
|
+
};
|
|
69
|
+
interface ResolvedUnifiedRule extends UnifiedRule {
|
|
70
|
+
filter: (id: string) => boolean;
|
|
71
|
+
processor: Promise<Processor>;
|
|
72
|
+
}
|
|
73
|
+
type UnifiedPluginResolvedConfig = ResolvedConfig & {
|
|
74
|
+
unified: {
|
|
75
|
+
rules: ResolvedUnifiedRule[];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
type UnifiedPluginContext<TResolvedConfig extends UnifiedPluginResolvedConfig = UnifiedPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule };
|
|
81
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;UAwBiB,WAAA;;AAAjB;;;;;;;;;;EAYE,OAAA,EAAS,aAAA,KAAkB,EAAA;EAgDpB;;;;;;;;;;;;;EAjCP,OAAA,GAAU,aAAA;EAmBV;;;;;EAZA,OAAA;EAuBI;;;EAlBJ,KAAA,GACE,OAAA,EAAS,SAAA,KACN,YAAA,CAAa,SAAA;EAmBX;;;EAdP,SAAA;IAcmE;;AAIrE;IAdI,GAAA,IAAO,IAAA,UAAc,EAAA,aAAe,YAAA;IAe9B;;;AAGV;IAZI,IAAA,IACE,IAAA,UACA,EAAA,UACA,GAAA,GAAM,SAAA,KACH,YAAA;MAA+B,IAAA;MAAc,GAAA,GAAM,SAAA;IAAA;EAAA;AAAA;AAAA,UAI3C,oBAAA;EACf,KAAA,GAAQ,WAAA;AAAA;AAAA,KAGE,uBAAA,GAA0B,UAAA;EACpC,OAAA,GAAU,oBAAA;AAAA;AAAA,UAGK,mBAAA,SAA4B,WAAA;EAC3C,MAAA,GAAS,EAAA;EACT,SAAA,EAAW,OAAA,CAAQ,SAAA;AAAA;AAAA,KAGT,2BAAA,GAA8B,cAAA;EACxC,OAAA;IACE,KAAA,EAAO,mBAAA;EAAA;AAAA;AAAA,KAIC,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { FilterPattern } from "@rollup/pluginutils";
|
|
2
|
+
import { Processor } from "unified";
|
|
3
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
4
|
+
import { MaybePromise } from "@stryke/types";
|
|
5
|
+
import { SourceMap } from "rollup";
|
|
6
|
+
|
|
7
|
+
//#region src/types/plugin.d.ts
|
|
8
|
+
interface UnifiedRule {
|
|
9
|
+
/**
|
|
10
|
+
* Include filter, accepts glob patterns, RegExp or a function.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* The following rules apply to the {@link include} and {@link exclude} options:
|
|
14
|
+
* If a function is provided, it will be called with the id of the file and should return a boolean indicating whether the rule should be applied.
|
|
15
|
+
* If a glob pattern or RegExp is provided, it will be used to create a filter function using `@rollup/pluginutils`'s `createFilter` function.
|
|
16
|
+
* If {@link include} is a function, the {@link exclude} option will be ignored.
|
|
17
|
+
* If {@link include} is not a function, the {@link exclude} option can be used to exclude files from being processed by this rule.
|
|
18
|
+
* If neither {@link include} nor {@link exclude} is provided, the rule will be applied to all files.
|
|
19
|
+
*/
|
|
20
|
+
include: FilterPattern | ((id: string) => boolean);
|
|
21
|
+
/**
|
|
22
|
+
* Exclude filter, accepts glob patterns, RegExp or a function.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* The following rules apply to the {@link include} and {@link exclude} options:
|
|
26
|
+
* If a function is provided, it will be called with the id of the file and should return a boolean indicating whether the rule should be applied.
|
|
27
|
+
* If a glob pattern or RegExp is provided, it will be used to create a filter function using `@rollup/pluginutils`'s `createFilter` function.
|
|
28
|
+
* If {@link include} is a function, the {@link exclude} option will be ignored.
|
|
29
|
+
* If {@link include} is not a function, the {@link exclude} option can be used to exclude files from being processed by this rule.
|
|
30
|
+
* If neither {@link include} nor {@link exclude} is provided, the rule will be applied to all files.
|
|
31
|
+
*
|
|
32
|
+
* @see https://rollupjs.org/guide/en/#plugincontext
|
|
33
|
+
*/
|
|
34
|
+
exclude?: FilterPattern;
|
|
35
|
+
/**
|
|
36
|
+
* Enforce the rule to be applied the in the build pipeline
|
|
37
|
+
*
|
|
38
|
+
* @see https://github.com/unjs/unplugin#hooks
|
|
39
|
+
*/
|
|
40
|
+
enforce?: "pre" | "post" | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Setup the unified processor
|
|
43
|
+
*/
|
|
44
|
+
setup: (unified: Processor) => MaybePromise<Processor<any, any, any, any, any>>;
|
|
45
|
+
/**
|
|
46
|
+
* Additional string transforms
|
|
47
|
+
*/
|
|
48
|
+
transform?: {
|
|
49
|
+
/**
|
|
50
|
+
* Preprocess the raw code before unified process
|
|
51
|
+
*/
|
|
52
|
+
pre?: (code: string, id: string) => MaybePromise<string | void>;
|
|
53
|
+
/**
|
|
54
|
+
* Postprocess the unified result.
|
|
55
|
+
* If a sourcemap is returned, the function is responsible for merging it with the unified result.
|
|
56
|
+
*/
|
|
57
|
+
post?: (code: string, id: string, map?: SourceMap) => MaybePromise<string | void | {
|
|
58
|
+
code: string;
|
|
59
|
+
map?: SourceMap | null;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
interface UnifiedPluginOptions {
|
|
64
|
+
rules?: UnifiedRule[];
|
|
65
|
+
}
|
|
66
|
+
type UnifiedPluginUserConfig = UserConfig & {
|
|
67
|
+
unified?: UnifiedPluginOptions;
|
|
68
|
+
};
|
|
69
|
+
interface ResolvedUnifiedRule extends UnifiedRule {
|
|
70
|
+
filter: (id: string) => boolean;
|
|
71
|
+
processor: Promise<Processor>;
|
|
72
|
+
}
|
|
73
|
+
type UnifiedPluginResolvedConfig = ResolvedConfig & {
|
|
74
|
+
unified: {
|
|
75
|
+
rules: ResolvedUnifiedRule[];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
type UnifiedPluginContext<TResolvedConfig extends UnifiedPluginResolvedConfig = UnifiedPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ResolvedUnifiedRule, UnifiedPluginContext, UnifiedPluginOptions, UnifiedPluginResolvedConfig, UnifiedPluginUserConfig, UnifiedRule };
|
|
81
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;UAwBiB,WAAA;;AAAjB;;;;;;;;;;EAYE,OAAA,EAAS,aAAA,KAAkB,EAAA;EAgDpB;;;;;;;;;;;;;EAjCP,OAAA,GAAU,aAAA;EAmBV;;;;;EAZA,OAAA;EAuBI;;;EAlBJ,KAAA,GACE,OAAA,EAAS,SAAA,KACN,YAAA,CAAa,SAAA;EAmBX;;;EAdP,SAAA;IAcmE;;AAIrE;IAdI,GAAA,IAAO,IAAA,UAAc,EAAA,aAAe,YAAA;IAe9B;;;AAGV;IAZI,IAAA,IACE,IAAA,UACA,EAAA,UACA,GAAA,GAAM,SAAA,KACH,YAAA;MAA+B,IAAA;MAAc,GAAA,GAAM,SAAA;IAAA;EAAA;AAAA;AAAA,UAI3C,oBAAA;EACf,KAAA,GAAQ,WAAA;AAAA;AAAA,KAGE,uBAAA,GAA0B,UAAA;EACpC,OAAA,GAAU,oBAAA;AAAA;AAAA,UAGK,mBAAA,SAA4B,WAAA;EAC3C,MAAA,GAAS,EAAA;EACT,SAAA,EAAW,OAAA,CAAQ,SAAA;AAAA;AAAA,KAGT,2BAAA,GAA8B,cAAA;EACxC,OAAA;IACE,KAAA,EAAO,mBAAA;EAAA;AAAA;AAAA,KAIC,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-unified",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Powerlines plugin to use the Unified ecosystem to generate content.",
|
|
6
6
|
"keywords": ["unified", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -90,18 +90,18 @@
|
|
|
90
90
|
"typings": "dist/index.d.mts",
|
|
91
91
|
"files": ["dist/**/*"],
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"@stryke/fs": "^0.33.
|
|
94
|
-
"@stryke/path": "^0.
|
|
95
|
-
"@stryke/types": "^0.11.
|
|
96
|
-
"@stryke/type-checks": "^0.6.
|
|
93
|
+
"@stryke/fs": "^0.33.69",
|
|
94
|
+
"@stryke/path": "^0.28.1",
|
|
95
|
+
"@stryke/types": "^0.11.6",
|
|
96
|
+
"@stryke/type-checks": "^0.6.4",
|
|
97
97
|
"defu": "^6.1.7",
|
|
98
|
-
"powerlines": "^0.43.
|
|
98
|
+
"powerlines": "^0.43.30",
|
|
99
99
|
"unified": "^11.0.5",
|
|
100
100
|
"@rollup/pluginutils": "^4.2.1",
|
|
101
101
|
"rollup": "^4.60.2"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
104
|
+
"@powerlines/plugin-plugin": "^0.12.385",
|
|
105
105
|
"@types/node": "^25.6.0",
|
|
106
106
|
"@types/hast": "^3.0.4",
|
|
107
107
|
"@types/mdast": "^4.0.4",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"@types/estree": "^1.0.8"
|
|
110
110
|
},
|
|
111
111
|
"publishConfig": { "access": "public" },
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "36f3385b33024e00aafb6c4a10e7a2e3c896aad5"
|
|
113
113
|
}
|