@powerlines/plugin-unified 0.1.116 → 0.1.117

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.
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAgCY,MAAA;IACR,OAAA,GAAU,oBAAoB;EAAA;AAAA;;;;;;;AAAA;AAelC;;;;cAAa,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAgCY,MAAA;IACR,OAAA,GAAU,oBAAoB;EAAA;AAAA;;;;;;;AAAA;AAelC;;;;cAAa,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
@@ -1 +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":";;;;;;;;;;;;;;;;AAgDA,MAAa,UAGX,UAAgC,EAAE,KACX;CACvB,MAAM,YAAY,SAAS,SAAS,EAAE,EAAE,KAAK,SAA8B;AACzE,SAAO;GACL,GAAG;GACH,QAAQ,WAAW,KAAK,QAAQ,GAC5B,KAAK,UACL,aAAa,KAAK,SAAS,KAAK,QAAQ;GAC5C,WAAW,QAAQ,QAAQ,KAAK,MAAM,SAAS,CAAC,CAAC;GAClD;GACD;CAEF,MAAM,MAA6B,EAAE;CACrC,MAAM,OAA8B,EAAE;CACtC,MAAM,SAAgC,EAAE;AAExC,MAAK,MAAM,QAAQ,SACjB,KAAI,KAAK,YAAY,MAAO,KAAI,KAAK,KAAK;UACjC,KAAK,YAAY,OAAQ,MAAK,KAAK,KAAK;KAC5C,QAAO,KAAK,KAAK;AAGxB,QAAO,CACL;EACE,MAAM;EACN,SAAS;AACP,UAAO,EACL,SAAS,EACP,OAAO,UACR,EACF;;EAEJ,EACD;EAAC;EAAK;EAAQ;EAAK,CAChB,KAAK,OAAO,QAAsC;EACjD,MAAM,UAAW;GAAC;GAAO;GAAW;GAAO,CAAW;AACtD,MAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,SAAO;GACL,MAAM,UAAU,UAAU,IAAI,YAAY;GAC1C;GACA,WAAW;IACT,SAAS,OAAe,MAAM,MAAK,MAAK,EAAE,OAAO,GAAG,CAAC;IACrD,MAAM,QAAQ,MAAM,IAAI;KACtB,MAAM,OAAO,MAAM,MAAK,MAAK,EAAE,OAAO,GAAG,CAAC;AAC1C,SAAI,CAAC,KAAM;AAEX,YAAQ,MAAM,KAAK,WAAW,MAAM,MAAM,GAAG,IAAK;KAGlD,MAAM,SAAS,OAAM,MADG,KAAK,WACE,QAAQ,KAAK;KAE5C,IAAI,aAAa,OAAO,UAAU;KAClC,IAAI,YAAY,OAAO;AAEvB,SAAI,KAAK,WAAW,MAAM;MACxB,MAAM,aACH,MAAM,KAAK,UAAU,KACpB,YACA,IACA,UACD,IAAK;AACR,UAAI,SAAS,WAAW,CACtB,cAAa;WACR;AACL,oBAAa,WAAW;AACxB,mBAAY,WAAW;;;AAI3B,YAAO;MACL,MAAM;MACN,KAAK;MACN;;IAEJ;GACF;GACD,CACD,OAAO,QAAQ,CACnB,CAAC,MAAM"}
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":";;;;;;;;;;;;;;;;AAgDA,MAAa,UAGX,UAAgC,CAAC,MACV;CACvB,MAAM,YAAY,SAAS,SAAS,CAAC,GAAG,KAAK,SAA8B;EACzE,OAAO;GACL,GAAG;GACH,QAAQ,WAAW,KAAK,OAAO,IAC3B,KAAK,UACL,aAAa,KAAK,SAAS,KAAK,OAAO;GAC3C,WAAW,QAAQ,QAAQ,KAAK,MAAM,QAAQ,CAAC,CAAC;EAClD;CACF,CAAC;CAED,MAAM,MAA6B,CAAC;CACpC,MAAM,OAA8B,CAAC;CACrC,MAAM,SAAgC,CAAC;CAEvC,KAAK,MAAM,QAAQ,UACjB,IAAI,KAAK,YAAY,OAAO,IAAI,KAAK,IAAI;MACpC,IAAI,KAAK,YAAY,QAAQ,KAAK,KAAK,IAAI;MAC3C,OAAO,KAAK,IAAI;CAGvB,OAAO,CACL;EACE,MAAM;EACN,SAAS;GACP,OAAO,EACL,SAAS,EACP,OAAO,SACT,EACF;EACF;CACF,GACA;EAAC;EAAK;EAAQ;CAAI,EACf,KAAK,OAAO,QAAsC;EACjD,MAAM,UAAW;GAAC;GAAO;GAAW;EAAM,EAAY;EACtD,IAAI,MAAM,WAAW,GAAG,OAAO;EAE/B,OAAO;GACL,MAAM,UAAU,UAAU,IAAI,YAAY;GAC1C;GACA,WAAW;IACT,SAAS,OAAe,MAAM,MAAK,MAAK,EAAE,OAAO,EAAE,CAAC;IACpD,MAAM,QAAQ,MAAM,IAAI;KACtB,MAAM,OAAO,MAAM,MAAK,MAAK,EAAE,OAAO,EAAE,CAAC;KACzC,IAAI,CAAC,MAAM;KAEX,OAAQ,MAAM,KAAK,WAAW,MAAM,MAAM,EAAE,KAAM;KAGlD,MAAM,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,2BAAA,IACA,aAAA,CAAc,eAAA"}
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;AAAA;AAIrE;IAdI,GAAA,IAAO,IAAA,UAAc,EAAA,aAAe,YAAA;IAe9B;;AAAW;AAGrB;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,WAAW;AAAA;AAAA,KAGT,uBAAA,GAA0B,UAAA;EACpC,OAAA,GAAU,oBAAoB;AAAA;AAAA,UAGf,mBAAA,SAA4B,WAAA;EAC3C,MAAA,GAAS,EAAA;EACT,SAAA,EAAW,OAAA,CAAQ,SAAA;AAAA;AAAA,KAGT,2BAAA,GAA8B,cAAA;EACxC,OAAA;IACE,KAAA,EAAO,mBAAmB;EAAA;AAAA;AAAA,KAIlB,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA"}
@@ -1 +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,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,WAAA;EAC3C,MAAA,GAAS,EAAA;EACT,SAAA,EAAW,OAAA,CAAQ,SAAA;AAAA;AAAA,KAGT,2BAAA,GAA8B,cAAA;EACxC,OAAA;IACE,KAAA,EAAO,mBAAmB;EAAA;AAAA;AAAA,KAIlB,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-unified",
3
- "version": "0.1.116",
3
+ "version": "0.1.117",
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"],
@@ -62,13 +62,13 @@
62
62
  "@stryke/types": "^0.12.4",
63
63
  "@stryke/type-checks": "^0.6.9",
64
64
  "defu": "^6.1.7",
65
- "powerlines": "^0.47.40",
65
+ "powerlines": "^0.47.41",
66
66
  "unified": "^11.0.5",
67
67
  "@rollup/pluginutils": "^4.2.1",
68
68
  "rollup": "^4.60.4"
69
69
  },
70
70
  "devDependencies": {
71
- "@powerlines/plugin-plugin": "^0.12.452",
71
+ "@powerlines/plugin-plugin": "^0.12.453",
72
72
  "@types/node": "^25.8.0",
73
73
  "@types/hast": "^3.0.4",
74
74
  "@types/mdast": "^4.0.4",
@@ -76,5 +76,5 @@
76
76
  "@types/estree": "^1.0.9"
77
77
  },
78
78
  "publishConfig": { "access": "public" },
79
- "gitHead": "c5c293e753d59ab690265988c77bd535680ac71b"
79
+ "gitHead": "b5c7361d0ca942652f98baf11488435c7918fd65"
80
80
  }