@vuepress/plugin-replace-assets 2.0.0-rc.122 → 2.0.0-rc.124

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,6 +1,7 @@
1
- import { Plugin } from 'vuepress/core';
2
- import { VitePlugin, WebpackPluginInstance } from 'unplugin';
1
+ import { VitePlugin, WebpackPluginInstance } from "unplugin";
2
+ import { Plugin } from "vuepress/core";
3
3
 
4
+ //#region src/node/types.d.ts
4
5
  /**
5
6
  * Assets Replacement Target Path
6
7
  * - `string`: Directly concatenated before the original path
@@ -17,102 +18,102 @@ type Replacement = string | ((url: string) => string);
17
18
  * 资源替换规则
18
19
  */
19
20
  interface ReplacementRule {
20
- /**
21
- * Assets Matching
22
- *
23
- * - `RegExp`: Match using regular expression
24
- * - `string`: Match using string
25
- * - Strings starting with `^` or ending with `$` are automatically converted to regular expressions
26
- * - For ordinary strings, checks if they appear at the start or end
27
- *
28
- * 资源匹配
29
- *
30
- * - `RegExp`: 匹配正则
31
- * - `string`: 匹配字符串
32
- * - 以 `^` 开头或以 `$` 结尾的字符串,会自动转换为正则
33
- * - 普通字符串检查是否以其作为开头或结尾
34
- *
35
- * @example
36
- * ```
37
- * '^/foo/'
38
- * '.jpg$'
39
- * /\.jpg$/
40
- * ```
41
- */
42
- find: RegExp | string;
43
- /**
44
- * Assets Replacement Target Path
45
- * - `string`: Directly concatenated before the original path
46
- * - `(url) => string`: Custom replacement method, returns the new path
47
- *
48
- * 资源替换目标路径
49
- * - `string`: 直接拼接在原始路径前面
50
- * - `(url) => string`: 自定义替换方法,返回新路径
51
- *
52
- * @example
53
- * ```
54
- * 'https://example.com'
55
- * (url) => `https://example.com${url}`
56
- * ```
57
- */
58
- replacement: Replacement;
21
+ /**
22
+ * Assets Matching
23
+ *
24
+ * - `RegExp`: Match using regular expression
25
+ * - `string`: Match using string
26
+ * - Strings starting with `^` or ending with `$` are automatically converted to regular expressions
27
+ * - For ordinary strings, checks if they appear at the start or end
28
+ *
29
+ * 资源匹配
30
+ *
31
+ * - `RegExp`: 匹配正则
32
+ * - `string`: 匹配字符串
33
+ * - 以 `^` 开头或以 `$` 结尾的字符串,会自动转换为正则
34
+ * - 普通字符串检查是否以其作为开头或结尾
35
+ *
36
+ * @example
37
+ * ```
38
+ * '^/foo/'
39
+ * '.jpg$'
40
+ * /\.jpg$/
41
+ * ```
42
+ */
43
+ find: RegExp | string;
44
+ /**
45
+ * Assets Replacement Target Path
46
+ * - `string`: Directly concatenated before the original path
47
+ * - `(url) => string`: Custom replacement method, returns the new path
48
+ *
49
+ * 资源替换目标路径
50
+ * - `string`: 直接拼接在原始路径前面
51
+ * - `(url) => string`: 自定义替换方法,返回新路径
52
+ *
53
+ * @example
54
+ * ```
55
+ * 'https://example.com'
56
+ * (url) => `https://example.com${url}`
57
+ * ```
58
+ */
59
+ replacement: Replacement;
59
60
  }
60
61
  interface ReplaceAssetsOptions {
61
- /**
62
- * Custom Assets Replacement Rules
63
- *
64
- * 自定义资源替换规则
65
- *
66
- * @example
67
- * ```ts
68
- * {
69
- * rules: [{
70
- * find: /^\/images\/.*\.(jpe?g|png|gif|svg)$/,
71
- * replacement: 'https://cdn.example.com/images/',
72
- * }]
73
- * }
74
- * ```
75
- */
76
- rules?: ReplacementRule | ReplacementRule[];
77
- /**
78
- * Built-in image matching rules, designed to match and find common image paths starting with `^/images/`
79
- *
80
- * 内置的图片匹配规则,匹配查找 `^/images/` 开头的常见的图片路径
81
- *
82
- * @example
83
- * ```
84
- * {
85
- * image: 'https://example.com'
86
- * }
87
- * ```
88
- */
89
- image?: Replacement;
90
- /**
91
- * Built-in media matching rules, designed to match and locate common media paths such as videos and audio that start with `^/medias/`.
92
- *
93
- * 内置的媒体匹配规则,匹配查找 `^/medias/` 开头的常见的视频、音频等媒体路径
94
- *
95
- * @example
96
- * ```
97
- * {
98
- * media: 'https://example.com'
99
- * }
100
- * ```
101
- */
102
- media?: Replacement;
103
- /**
104
- * Equivalent to setting both {@link ReplaceAssetsOptions.image image} and {@link ReplaceAssetsOptions.media media} simultaneously.
105
- *
106
- * 相当于同时设置 {@link ReplaceAssetsOptions.image image} 和 {@link ReplaceAssetsOptions.media media}
107
- *
108
- * @example
109
- * ```
110
- * {
111
- * all: 'https://example.com'
112
- * }
113
- * ```
114
- */
115
- all?: Replacement;
62
+ /**
63
+ * Custom Assets Replacement Rules
64
+ *
65
+ * 自定义资源替换规则
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * {
70
+ * rules: [{
71
+ * find: /^\/images\/.*\.(jpe?g|png|gif|svg)$/,
72
+ * replacement: 'https://cdn.example.com/images/',
73
+ * }]
74
+ * }
75
+ * ```
76
+ */
77
+ rules?: ReplacementRule | ReplacementRule[];
78
+ /**
79
+ * Built-in image matching rules, designed to match and find common image paths starting with `^/images/`
80
+ *
81
+ * 内置的图片匹配规则,匹配查找 `^/images/` 开头的常见的图片路径
82
+ *
83
+ * @example
84
+ * ```
85
+ * {
86
+ * image: 'https://example.com'
87
+ * }
88
+ * ```
89
+ */
90
+ image?: Replacement;
91
+ /**
92
+ * Built-in media matching rules, designed to match and locate common media paths such as videos and audio that start with `^/medias/`.
93
+ *
94
+ * 内置的媒体匹配规则,匹配查找 `^/medias/` 开头的常见的视频、音频等媒体路径
95
+ *
96
+ * @example
97
+ * ```
98
+ * {
99
+ * media: 'https://example.com'
100
+ * }
101
+ * ```
102
+ */
103
+ media?: Replacement;
104
+ /**
105
+ * Equivalent to setting both {@link ReplaceAssetsOptions.image image} and {@link ReplaceAssetsOptions.media media} simultaneously.
106
+ *
107
+ * 相当于同时设置 {@link ReplaceAssetsOptions.image image} 和 {@link ReplaceAssetsOptions.media media}
108
+ *
109
+ * @example
110
+ * ```
111
+ * {
112
+ * all: 'https://example.com'
113
+ * }
114
+ * ```
115
+ */
116
+ all?: Replacement;
116
117
  }
117
118
  /**
118
119
  * Assets Replacement Plugin Options
@@ -120,7 +121,8 @@ interface ReplaceAssetsOptions {
120
121
  * 资源替换插件配置项
121
122
  */
122
123
  type ReplaceAssetsPluginOptions = ReplaceAssetsOptions | Replacement | ReplacementRule | ReplacementRule[];
123
-
124
+ //#endregion
125
+ //#region src/node/replaceAssetsPlugin.d.ts
124
126
  /**
125
127
  * Plugin for replacing assets path
126
128
  *
@@ -136,20 +138,33 @@ type ReplaceAssetsPluginOptions = ReplaceAssetsOptions | Replacement | Replaceme
136
138
  * ```
137
139
  */
138
140
  declare const replaceAssetsPlugin: (options?: ReplaceAssetsPluginOptions) => Plugin;
139
-
141
+ //#endregion
142
+ //#region src/node/normalizeRules.d.ts
140
143
  declare const createFindPattern: (dir: string, extensions: string[]) => RegExp;
141
144
  /**
142
145
  * Normalize replacement rules
146
+ *
147
+ * @param options - The plugin options to normalize
148
+ * @returns Normalized replacement rules
143
149
  */
144
150
  declare const normalizeRules: (options?: ReplaceAssetsPluginOptions) => ReplacementRule[];
145
-
151
+ //#endregion
152
+ //#region src/node/transformAssets.d.ts
146
153
  /**
147
154
  * Check if url matches find
155
+ *
156
+ * @param find - The find pattern, can be a string or a RegExp / 查找模式,可以是字符串或正则表达式
157
+ * @param url - The URL to check / 要检查的 URL
158
+ * @returns True if the URL matches the find pattern, false otherwise / 如果 URL 匹配查找模式则返回 true,否则返回 false
148
159
  */
149
160
  declare const isMatchUrl: (find: RegExp | string, url: string) => boolean;
150
161
  /**
151
162
  * Replace asset with rules
152
163
  *
164
+ * @param rules - Replacement rules / 替换规则
165
+ * @param url - The original asset URL / 原始资源 URL
166
+ * @returns The replaced asset URL if matched, otherwise return undefined / 如果匹配则返回替换后的资源 URL,否则返回 undefined
167
+ *
153
168
  * @example
154
169
  * ```ts
155
170
  * replacementAssetWithRules([{ find: '/foo/', replacement: 'https://example.com' }], '/foo/a.jpg')
@@ -158,9 +173,10 @@ declare const isMatchUrl: (find: RegExp | string, url: string) => boolean;
158
173
  */
159
174
  declare const replacementAssetWithRules: (rules: ReplacementRule[], url: string) => string | void;
160
175
  declare const transformAssets: (code: string, pattern: RegExp, rules: ReplacementRule[]) => string;
161
-
176
+ //#endregion
177
+ //#region src/node/unplugin.d.ts
162
178
  declare const createVitePluginReplaceAssets: () => (options: ReplacementRule[]) => VitePlugin | VitePlugin[];
163
179
  declare const createWebpackPluginReplaceAssets: () => (options: ReplacementRule[]) => WebpackPluginInstance;
164
-
165
- export { createFindPattern, createVitePluginReplaceAssets, createWebpackPluginReplaceAssets, isMatchUrl, normalizeRules, replaceAssetsPlugin, replacementAssetWithRules, transformAssets };
166
- export type { ReplaceAssetsOptions, ReplaceAssetsPluginOptions, Replacement, ReplacementRule };
180
+ //#endregion
181
+ export { ReplaceAssetsOptions, ReplaceAssetsPluginOptions, Replacement, ReplacementRule, createFindPattern, createVitePluginReplaceAssets, createWebpackPluginReplaceAssets, isMatchUrl, normalizeRules, replaceAssetsPlugin, replacementAssetWithRules, transformAssets };
182
+ //# sourceMappingURL=index.d.ts.map
package/lib/node/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{isFunction as w,isArray as g,removeEndingSlash as x,removeLeadingSlash as j,getBundlerName as P,addViteConfig as b,configWebpack as R}from"@vuepress/helper";import{createVitePlugin as S,createWebpackPlugin as I}from"unplugin";import M from"magic-string";const O="@vuepress/plugin-replace-assets",_=["apng","bmp","png","jpe?g","jfif","pjpeg","pjp","gif","svg","ico","webp","avif","cur","jxl"],k=["mp4","webm","ogg","mp3","wav","flac","aac","opus","mov","m4a","vtt","pdf"],o=(t,e)=>new RegExp(`^/${t}/.*\\.(?:${e.join("|")})(\\?.*)?$`),m=t=>{const e=[];return t?((typeof t=="string"||w(t))&&(t={all:t}),g(t)?(e.push(...t),e):"find"in t?(t.find&&t.replacement&&e.push(t),e):(t.rules&&e.push(...g(t.rules)?t.rules:[t.rules]),(t.image||t.all)&&e.push({find:o("images",_),replacement:t.image||t.all}),(t.media||t.all)&&e.push({find:o("medias",k),replacement:t.media||t.all}),e)):[]},y=t=>{const e=`(${t}.*?)`;return new RegExp([`(?:"${e}")`,`(?:'${e}')`,`(?:\\(${e}\\))`,`(?:\\('${e}'\\))`,`(?:\\("${e}"\\))`,`(?:\\\\"${e}\\\\")`].join("|"),"gu")},f=(t,e)=>t?e?`${x(e)}/${j(t)}`:t:"",d=(t,e)=>typeof t=="string"?t.startsWith("^")||t.endsWith("$")?new RegExp(t).test(e):e.endsWith(t)||e.startsWith(t):t.test(e),p=new Map,h=(t,e)=>{if(p.has(e))return p.get(e);for(const{find:s,replacement:r}of t)if(s&&d(s,e)){const n=typeof r=="function"?f(r(e)):f(e,r);/* istanbul ignore if -- @preserve */if(n)return p.set(e,n),n}},$=(t,e,s)=>{const r=new M(t);let n,a=!1;for(;n=e.exec(t);){const i=n[6]||n[5]||n[4]||n[3]||n[2]||n[1],[l,v]=n[0].startsWith("(")?['("','")']:n[0].startsWith('\\"')?['\\"','\\"']:['"','"'],c=n.index,A=c+n[0].length,u=h(s,i);u&&(a=!0,r.update(c,A,`${l}${u}${v}`))}return a?r.toString():t},W=t=>{const e=y("/[^/]");return{name:"vuepress:replace-assets",enforce:"pre",transform:{filter:{id:{exclude:[/\.json(?:$|\?)/,/\.html?$/]}},handler(s){return $(s,e,t)}}}},E=()=>S(W),N=()=>I(W),U=t=>{const e={name:O},s=m(t);return s.length===0?e:{...e,extendsBundlerOptions(r,n){const a=P(n);if(a==="vite"){const i=E();b(r,n,{plugins:[i(s)]})}a==="webpack"&&R(r,n,i=>{i.plugins??=[];const l=N();i.plugins.push(l(s))})}}};export{o as createFindPattern,E as createVitePluginReplaceAssets,N as createWebpackPluginReplaceAssets,d as isMatchUrl,m as normalizeRules,U as replaceAssetsPlugin,h as replacementAssetWithRules,$ as transformAssets};
2
- //# sourceMappingURL=index.js.map
1
+ import{addViteConfig as e,configWebpack as t,getBundlerName as n,isArray as r,isFunction as i,removeEndingSlash as a,removeLeadingSlash as o}from"@vuepress/helper";import{createVitePlugin as s,createWebpackPlugin as c}from"unplugin";import l from"magic-string";const u=[`apng`,`bmp`,`png`,`jpe?g`,`jfif`,`pjpeg`,`pjp`,`gif`,`svg`,`ico`,`webp`,`avif`,`cur`,`jxl`],d=[`mp4`,`webm`,`ogg`,`mp3`,`wav`,`flac`,`aac`,`opus`,`mov`,`m4a`,`vtt`,`pdf`],f=(e,t)=>RegExp(`^/${e}/.*\\.(?:${t.join(`|`)})(\\?.*)?$`),p=e=>{let t=[];return e?((typeof e==`string`||i(e))&&(e={all:e}),r(e)?(t.push(...e),t):`find`in e?(e.find&&e.replacement&&t.push(e),t):(e.rules&&t.push(...r(e.rules)?e.rules:[e.rules]),(e.image||e.all)&&t.push({find:f(`images`,u),replacement:e.image||e.all}),(e.media||e.all)&&t.push({find:f(`medias`,d),replacement:e.media||e.all}),t)):[]},m=e=>{let t=`(${e}.*?)`;return new RegExp([`(?:"${t}")`,`(?:'${t}')`,`(?:\\(${t}\\))`,`(?:\\('${t}'\\))`,`(?:\\("${t}"\\))`,`(?:\\\\"${t}\\\\")`].join(`|`),`gu`)},h=(e,t)=>e?t?`${a(t)}/${o(e)}`:e:``,g=(e,t)=>typeof e==`string`?e.startsWith(`^`)||e.endsWith(`$`)?new RegExp(e).test(t):t.endsWith(e)||t.startsWith(e):e.test(t),_=new Map,v=(e,t)=>{if(_.has(t))return _.get(t);for(let{find:n,replacement:r}of e)if(n&&g(n,t)){let e=typeof r==`function`?h(r(t)):h(t,r);if(e)return _.set(t,e),e}},y=String.raw`\"`,b=(e,t,n)=>{let r=new l(e),i,a=!1;for(;i=t.exec(e);){let e=i[6]||i[5]||i[4]||i[3]||i[2]||i[1],[t,o]=i[0].startsWith(`(`)?[`("`,`")`]:i[0].startsWith(y)?[y,y]:[`"`,`"`],s=i.index,c=s+i[0].length,l=v(n,e);l&&(a=!0,r.update(s,c,`${t}${l}${o}`))}return a?r.toString():e},x=e=>{let t=m(`/[^/]`);return{name:`vuepress:replace-assets`,enforce:`pre`,transform:{filter:{id:{exclude:[/\.json(?:$|\?)/,/\.html?$/]}},handler(n){return b(n,t,e)}}}},S=()=>s(x),C=()=>c(x),w=r=>{let i={name:`@vuepress/plugin-replace-assets`},a=p(r);return a.length===0?i:{...i,extendsBundlerOptions(r,i){let o=n(i);o===`vite`&&e(r,i,{plugins:[S()(a)]}),o===`webpack`&&t(r,i,e=>{e.plugins??=[];let t=C();e.plugins.push(t(a))})}}};export{f as createFindPattern,S as createVitePluginReplaceAssets,C as createWebpackPluginReplaceAssets,g as isMatchUrl,p as normalizeRules,w as replaceAssetsPlugin,v as replacementAssetWithRules,b as transformAssets};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/node/constants.ts","../../src/node/normalizeRules.ts","../../src/node/utils.ts","../../src/node/transformAssets.ts","../../src/node/unplugin.ts","../../src/node/replaceAssetsPlugin.ts"],"sourcesContent":["export const PLUGIN_NAME = '@vuepress/plugin-replace-assets'\n\n/**\n * images extensions\n */\nexport const KNOWN_IMAGE_EXTENSIONS: string[] = [\n 'apng',\n 'bmp',\n 'png',\n 'jpe?g',\n 'jfif',\n 'pjpeg',\n 'pjp',\n 'gif',\n 'svg',\n 'ico',\n 'webp',\n 'avif',\n 'cur',\n 'jxl',\n]\n\n/**\n * media extensions\n */\nexport const KNOWN_MEDIA_EXTENSIONS: string[] = [\n 'mp4',\n 'webm',\n 'ogg',\n 'mp3',\n 'wav',\n 'flac',\n 'aac',\n 'opus',\n 'mov',\n 'm4a',\n 'vtt',\n\n 'pdf',\n]\n","import { isArray, isFunction } from '@vuepress/helper'\nimport { KNOWN_IMAGE_EXTENSIONS, KNOWN_MEDIA_EXTENSIONS } from './constants.js'\nimport type { ReplaceAssetsPluginOptions, ReplacementRule } from './types.js'\n\nexport const createFindPattern = (\n dir: string,\n extensions: string[],\n): RegExp => {\n return new RegExp(`^/${dir}/.*\\\\.(?:${extensions.join('|')})(\\\\?.*)?$`)\n}\n\n/**\n * Normalize replacement rules\n */\nexport const normalizeRules = (\n options?: ReplaceAssetsPluginOptions,\n): ReplacementRule[] => {\n const normalized: ReplacementRule[] = []\n\n if (!options) return []\n\n if (typeof options === 'string' || isFunction(options)) {\n // eslint-disable-next-line no-param-reassign\n options = {\n all: options,\n }\n }\n\n if (isArray(options)) {\n normalized.push(...options)\n return normalized\n }\n\n if ('find' in options) {\n if (options.find && options.replacement) normalized.push(options)\n return normalized\n }\n\n if (options.rules) {\n normalized.push(\n ...(isArray(options.rules) ? options.rules : [options.rules]),\n )\n }\n\n if (options.image || options.all) {\n normalized.push({\n find: createFindPattern('images', KNOWN_IMAGE_EXTENSIONS),\n replacement: options.image || options.all!,\n })\n }\n\n if (options.media || options.all) {\n normalized.push({\n find: createFindPattern('medias', KNOWN_MEDIA_EXTENSIONS),\n replacement: options.media || options.all!,\n })\n }\n\n return normalized\n}\n","import { removeEndingSlash, removeLeadingSlash } from '@vuepress/helper'\n\nexport const createAssetPattern = (prefix: string): RegExp => {\n const s = `(${prefix}.*?)`\n return new RegExp(\n [\n `(?:\"${s}\")`, // \"prefix\"\n `(?:'${s}')`, // 'prefix'\n `(?:\\\\(${s}\\\\))`, // (prefix)\n `(?:\\\\('${s}'\\\\))`, // ('prefix')\n `(?:\\\\(\"${s}\"\\\\))`, // (\"prefix\")\n `(?:\\\\\\\\\"${s}\\\\\\\\\")`, // \\\"prefix\\\"\n ].join('|'),\n 'gu',\n )\n}\n\n/**\n * Normalize url\n *\n * @example\n * ```ts\n * normalizeUrl('/bar', '/foo/') // -> /foo/bar\n * ```\n */\nexport const normalizeUrl = (url: string, base?: string): string => {\n if (!url) return ''\n\n if (base) {\n return `${removeEndingSlash(base)}/${removeLeadingSlash(url)}`\n }\n\n return url\n}\n","import MagicString from 'magic-string'\nimport type { ReplacementRule } from './types.js'\nimport { normalizeUrl } from './utils.js'\n\n/**\n * Check if url matches find\n */\nexport const isMatchUrl = (find: RegExp | string, url: string): boolean => {\n if (typeof find === 'string') {\n // like regexp string, start with `^` or end with `$`\n if (find.startsWith('^') || find.endsWith('$')) {\n return new RegExp(find).test(url)\n }\n\n return url.endsWith(find) || url.startsWith(find)\n }\n\n return find.test(url)\n}\n\nconst cache = new Map<string, string>()\n\n/**\n * Replace asset with rules\n *\n * @example\n * ```ts\n * replacementAssetWithRules([{ find: '/foo/', replacement: 'https://example.com' }], '/foo/a.jpg')\n * // -> 'https://example.com/foo/a.jpg'\n * ```\n */\nexport const replacementAssetWithRules = (\n rules: ReplacementRule[],\n url: string,\n): string | void => {\n if (cache.has(url)) return cache.get(url)\n\n for (const { find, replacement } of rules) {\n if (find && isMatchUrl(find, url)) {\n const replaced =\n typeof replacement === 'function'\n ? normalizeUrl(replacement(url))\n : normalizeUrl(url, replacement)\n\n /* istanbul ignore if -- @preserve */\n if (replaced) {\n cache.set(url, replaced)\n return replaced\n }\n }\n }\n return undefined\n}\n\nexport const transformAssets = (\n code: string,\n pattern: RegExp,\n rules: ReplacementRule[],\n): string => {\n const s = new MagicString(code)\n let matched: RegExpExecArray | null\n let hasMatched = false\n // eslint-disable-next-line no-cond-assign\n while ((matched = pattern.exec(code))) {\n const assetUrl =\n matched[6] ||\n matched[5] ||\n matched[4] ||\n matched[3] ||\n matched[2] ||\n matched[1]\n const [left, right] = matched[0].startsWith('(')\n ? ['(\"', '\")']\n : matched[0].startsWith('\\\\\"')\n ? ['\\\\\"', '\\\\\"']\n : ['\"', '\"']\n\n const start = matched.index\n const end = start + matched[0].length\n const resolved = replacementAssetWithRules(rules, assetUrl)\n if (resolved) {\n hasMatched = true\n s.update(start, end, `${left}${resolved}${right}`)\n }\n }\n\n if (!hasMatched) return code\n\n return s.toString()\n}\n","import type {\n UnpluginFactory,\n VitePlugin,\n WebpackPluginInstance,\n} from 'unplugin'\nimport { createVitePlugin, createWebpackPlugin } from 'unplugin'\nimport { transformAssets } from './transformAssets.js'\nimport type { ReplacementRule } from './types.js'\nimport { createAssetPattern } from './utils.js'\n\nconst replaceAssetsFactory: UnpluginFactory<ReplacementRule[]> = (rules) => {\n const pattern = createAssetPattern('/[^/]')\n return {\n name: 'vuepress:replace-assets',\n enforce: 'pre',\n transform: {\n filter: { id: { exclude: [/\\.json(?:$|\\?)/, /\\.html?$/] } },\n handler(code) {\n return transformAssets(code, pattern, rules)\n },\n },\n }\n}\n\nexport const createVitePluginReplaceAssets: () => (\n options: ReplacementRule[],\n) => VitePlugin | VitePlugin[] = () => createVitePlugin(replaceAssetsFactory)\n\nexport const createWebpackPluginReplaceAssets: () => (\n options: ReplacementRule[],\n) => WebpackPluginInstance = () => createWebpackPlugin(replaceAssetsFactory)\n","import { addViteConfig, configWebpack, getBundlerName } from '@vuepress/helper'\nimport type { Plugin } from 'vuepress/core'\nimport { PLUGIN_NAME } from './constants.js'\nimport { normalizeRules } from './normalizeRules.js'\nimport type { ReplaceAssetsPluginOptions } from './types.js'\nimport {\n createVitePluginReplaceAssets,\n createWebpackPluginReplaceAssets,\n} from './unplugin.js'\n\n/**\n * Plugin for replacing assets path\n *\n * 资源路径替换插件\n *\n * @example\n * ```\n * export default defineUserConfig({\n * plugins: [\n * replaceAssetsPlugin('https://cnd.example.com')\n * ]\n * })\n * ```\n */\nexport const replaceAssetsPlugin = (\n options?: ReplaceAssetsPluginOptions,\n): Plugin => {\n const EMPTY_PLUGIN = { name: PLUGIN_NAME }\n\n const rules = normalizeRules(options)\n\n if (rules.length === 0) return EMPTY_PLUGIN\n\n return {\n ...EMPTY_PLUGIN,\n\n extendsBundlerOptions(bundlerOptions, app) {\n const bundle = getBundlerName(app)\n\n if (bundle === 'vite') {\n const replaceAssets = createVitePluginReplaceAssets()\n addViteConfig(bundlerOptions, app, {\n plugins: [replaceAssets(rules)],\n })\n }\n\n if (bundle === 'webpack') {\n configWebpack(bundlerOptions, app, (config) => {\n config.plugins ??= []\n const replaceAssets = createWebpackPluginReplaceAssets()\n config.plugins.push(replaceAssets(rules))\n })\n }\n },\n }\n}\n"],"names":["PLUGIN_NAME","KNOWN_IMAGE_EXTENSIONS","KNOWN_MEDIA_EXTENSIONS","createFindPattern","dir","extensions","normalizeRules","options","normalized","isFunction","isArray","createAssetPattern","prefix","s","normalizeUrl","url","base","removeEndingSlash","removeLeadingSlash","isMatchUrl","find","cache","replacementAssetWithRules","rules","replacement","replaced","transformAssets","code","pattern","MagicString","matched","hasMatched","assetUrl","left","right","start","end","resolved","replaceAssetsFactory","createVitePluginReplaceAssets","createVitePlugin","createWebpackPluginReplaceAssets","createWebpackPlugin","replaceAssetsPlugin","EMPTY_PLUGIN","bundlerOptions","app","bundle","getBundlerName","replaceAssets","addViteConfig","configWebpack","config"],"mappings":"qQAAO,MAAMA,EAAc,kCAKdC,EAAmC,CAC9C,OACA,MACA,MACA,QACA,OACA,QACA,MACA,MACA,MACA,MACA,OACA,OACA,MACA,KACF,EAKaC,EAAmC,CAC9C,MACA,OACA,MACA,MACA,MACA,OACA,MACA,OACA,MACA,MACA,MAEA,KACF,ECnCaC,EAAoB,CAC/BC,EACAC,IAEO,IAAI,OAAO,KAAKD,CAAG,YAAYC,EAAW,KAAK,GAAG,CAAC,YAAY,EAM3DC,EACXC,GACsB,CACtB,MAAMC,EAAgC,CAAA,EAEtC,OAAKD,IAED,OAAOA,GAAY,UAAYE,EAAWF,CAAO,KAEnDA,EAAU,CACR,IAAKA,CACP,GAGEG,EAAQH,CAAO,GACjBC,EAAW,KAAK,GAAGD,CAAO,EACnBC,GAGL,SAAUD,GACRA,EAAQ,MAAQA,EAAQ,aAAaC,EAAW,KAAKD,CAAO,EACzDC,IAGLD,EAAQ,OACVC,EAAW,KACT,GAAIE,EAAQH,EAAQ,KAAK,EAAIA,EAAQ,MAAQ,CAACA,EAAQ,KAAK,CAC7D,GAGEA,EAAQ,OAASA,EAAQ,MAC3BC,EAAW,KAAK,CACd,KAAML,EAAkB,SAAUF,CAAsB,EACxD,YAAaM,EAAQ,OAASA,EAAQ,GACxC,CAAC,GAGCA,EAAQ,OAASA,EAAQ,MAC3BC,EAAW,KAAK,CACd,KAAML,EAAkB,SAAUD,CAAsB,EACxD,YAAaK,EAAQ,OAASA,EAAQ,GACxC,CAAC,EAGIC,IAvCc,CAAA,CAw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QAAQ,KAAKH,EAAc1B,CAAK,CAAC,CAC1C,CAAC,CAEL,CACF,CACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/node/constants.ts","../../src/node/normalizeRules.ts","../../src/node/utils.ts","../../src/node/transformAssets.ts","../../src/node/unplugin.ts","../../src/node/replaceAssetsPlugin.ts"],"sourcesContent":["export const PLUGIN_NAME = '@vuepress/plugin-replace-assets'\n\n/**\n * images extensions\n */\nexport const KNOWN_IMAGE_EXTENSIONS: string[] = [\n 'apng',\n 'bmp',\n 'png',\n 'jpe?g',\n 'jfif',\n 'pjpeg',\n 'pjp',\n 'gif',\n 'svg',\n 'ico',\n 'webp',\n 'avif',\n 'cur',\n 'jxl',\n]\n\n/**\n * media extensions\n */\nexport const KNOWN_MEDIA_EXTENSIONS: string[] = [\n 'mp4',\n 'webm',\n 'ogg',\n 'mp3',\n 'wav',\n 'flac',\n 'aac',\n 'opus',\n 'mov',\n 'm4a',\n 'vtt',\n\n 'pdf',\n]\n","import { isArray, isFunction } from '@vuepress/helper'\nimport { KNOWN_IMAGE_EXTENSIONS, KNOWN_MEDIA_EXTENSIONS } from './constants.js'\nimport type { ReplaceAssetsPluginOptions, ReplacementRule } from './types.js'\n\nexport const createFindPattern = (dir: string, extensions: string[]): RegExp =>\n new RegExp(`^/${dir}/.*\\\\.(?:${extensions.join('|')})(\\\\?.*)?$`)\n\n/**\n * Normalize replacement rules\n *\n * @param options - The plugin options to normalize\n * @returns Normalized replacement rules\n */\nexport const normalizeRules = (\n options?: ReplaceAssetsPluginOptions,\n): ReplacementRule[] => {\n const normalized: ReplacementRule[] = []\n\n if (!options) return []\n\n if (typeof options === 'string' || isFunction(options)) {\n // eslint-disable-next-line no-param-reassign\n options = {\n all: options,\n }\n }\n\n if (isArray(options)) {\n normalized.push(...options)\n return normalized\n }\n\n if ('find' in options) {\n if (options.find && options.replacement) normalized.push(options)\n return normalized\n }\n\n if (options.rules) {\n normalized.push(\n ...(isArray(options.rules) ? options.rules : [options.rules]),\n )\n }\n\n if (options.image || options.all) {\n normalized.push({\n find: createFindPattern('images', KNOWN_IMAGE_EXTENSIONS),\n replacement: options.image || options.all!,\n })\n }\n\n if (options.media || options.all) {\n normalized.push({\n find: createFindPattern('medias', KNOWN_MEDIA_EXTENSIONS),\n replacement: options.media || options.all!,\n })\n }\n\n return normalized\n}\n","import { removeEndingSlash, removeLeadingSlash } from '@vuepress/helper'\n\nexport const createAssetPattern = (prefix: string): RegExp => {\n // oxlint-disable-next-line id-length\n const s = `(${prefix}.*?)`\n return new RegExp(\n [\n `(?:\"${s}\")`, // \"prefix\"\n `(?:'${s}')`, // 'prefix'\n `(?:\\\\(${s}\\\\))`, // (prefix)\n `(?:\\\\('${s}'\\\\))`, // ('prefix')\n `(?:\\\\(\"${s}\"\\\\))`, // (\"prefix\")\n `(?:\\\\\\\\\"${s}\\\\\\\\\")`, // \\\"prefix\\\"\n ].join('|'),\n 'gu',\n )\n}\n\n/**\n * Normalize url\n *\n * @param url - The url to normalize\n * @param base - The base url to prepend to the url\n * @returns Normalized url\n *\n * @example\n * ```ts\n * normalizeUrl('/bar', '/foo/') // -> /foo/bar\n * ```\n */\nexport const normalizeUrl = (url: string, base?: string): string => {\n if (!url) return ''\n\n if (base) return `${removeEndingSlash(base)}/${removeLeadingSlash(url)}`\n\n return url\n}\n","import MagicString from 'magic-string'\nimport type { ReplacementRule } from './types.js'\nimport { normalizeUrl } from './utils.js'\n\n/**\n * Check if url matches find\n *\n * @param find - The find pattern, can be a string or a RegExp / 查找模式,可以是字符串或正则表达式\n * @param url - The URL to check / 要检查的 URL\n * @returns True if the URL matches the find pattern, false otherwise / 如果 URL 匹配查找模式则返回 true,否则返回 false\n */\nexport const isMatchUrl = (find: RegExp | string, url: string): boolean => {\n if (typeof find === 'string') {\n // like regexp string, start with `^` or end with `$`\n if (find.startsWith('^') || find.endsWith('$'))\n return new RegExp(find).test(url)\n\n return url.endsWith(find) || url.startsWith(find)\n }\n\n return find.test(url)\n}\n\nconst cache = new Map<string, string>()\n\n/**\n * Replace asset with rules\n *\n * @param rules - Replacement rules / 替换规则\n * @param url - The original asset URL / 原始资源 URL\n * @returns The replaced asset URL if matched, otherwise return undefined / 如果匹配则返回替换后的资源 URL,否则返回 undefined\n *\n * @example\n * ```ts\n * replacementAssetWithRules([{ find: '/foo/', replacement: 'https://example.com' }], '/foo/a.jpg')\n * // -> 'https://example.com/foo/a.jpg'\n * ```\n */\nexport const replacementAssetWithRules = (\n rules: ReplacementRule[],\n url: string,\n): string | void => {\n if (cache.has(url)) return cache.get(url)\n\n for (const { find, replacement } of rules) {\n if (find && isMatchUrl(find, url)) {\n const replaced =\n typeof replacement === 'function'\n ? normalizeUrl(replacement(url))\n : normalizeUrl(url, replacement)\n\n /* istanbul ignore if -- @preserve */\n if (replaced) {\n cache.set(url, replaced)\n return replaced\n }\n }\n }\n}\n\nconst ESCAPED_DOUBLE_QUOTE = String.raw`\\\"`\n\nexport const transformAssets = (\n code: string,\n pattern: RegExp,\n rules: ReplacementRule[],\n): string => {\n const str = new MagicString(code)\n let matched: RegExpExecArray | null\n let hasMatched = false\n\n while ((matched = pattern.exec(code))) {\n const assetUrl =\n matched[6] ||\n matched[5] ||\n matched[4] ||\n matched[3] ||\n matched[2] ||\n matched[1]\n const [left, right] = matched[0].startsWith('(')\n ? ['(\"', '\")']\n : matched[0].startsWith(ESCAPED_DOUBLE_QUOTE)\n ? [ESCAPED_DOUBLE_QUOTE, ESCAPED_DOUBLE_QUOTE]\n : ['\"', '\"']\n\n const start = matched.index\n const end = start + matched[0].length\n const resolved = replacementAssetWithRules(rules, assetUrl)\n if (resolved) {\n hasMatched = true\n str.update(start, end, `${left}${resolved}${right}`)\n }\n }\n\n if (!hasMatched) return code\n\n return str.toString()\n}\n","import type {\n UnpluginFactory,\n VitePlugin,\n WebpackPluginInstance,\n} from 'unplugin'\nimport { createVitePlugin, createWebpackPlugin } from 'unplugin'\nimport { transformAssets } from './transformAssets.js'\nimport type { ReplacementRule } from './types.js'\nimport { createAssetPattern } from './utils.js'\n\nconst replaceAssetsFactory: UnpluginFactory<ReplacementRule[]> = (rules) => {\n const pattern = createAssetPattern('/[^/]')\n return {\n name: 'vuepress:replace-assets',\n enforce: 'pre',\n transform: {\n filter: { id: { exclude: [/\\.json(?:$|\\?)/, /\\.html?$/] } },\n handler(code) {\n return transformAssets(code, pattern, rules)\n },\n },\n }\n}\n\nexport const createVitePluginReplaceAssets: () => (\n options: ReplacementRule[],\n) => VitePlugin | VitePlugin[] = () => createVitePlugin(replaceAssetsFactory)\n\nexport const createWebpackPluginReplaceAssets: () => (\n options: ReplacementRule[],\n) => WebpackPluginInstance = () => createWebpackPlugin(replaceAssetsFactory)\n","import { addViteConfig, configWebpack, getBundlerName } from '@vuepress/helper'\nimport type { Plugin } from 'vuepress/core'\nimport { PLUGIN_NAME } from './constants.js'\nimport { normalizeRules } from './normalizeRules.js'\nimport type { ReplaceAssetsPluginOptions } from './types.js'\nimport {\n createVitePluginReplaceAssets,\n createWebpackPluginReplaceAssets,\n} from './unplugin.js'\n\n/**\n * Plugin for replacing assets path\n *\n * 资源路径替换插件\n *\n * @example\n * ```\n * export default defineUserConfig({\n * plugins: [\n * replaceAssetsPlugin('https://cnd.example.com')\n * ]\n * })\n * ```\n */\nexport const replaceAssetsPlugin = (\n options?: ReplaceAssetsPluginOptions,\n): Plugin => {\n const EMPTY_PLUGIN = { name: PLUGIN_NAME }\n\n const rules = normalizeRules(options)\n\n if (rules.length === 0) return EMPTY_PLUGIN\n\n return {\n ...EMPTY_PLUGIN,\n\n extendsBundlerOptions(bundlerOptions, app) {\n const bundle = getBundlerName(app)\n\n if (bundle === 'vite') {\n const replaceAssets = createVitePluginReplaceAssets()\n addViteConfig(bundlerOptions, app, {\n plugins: [replaceAssets(rules)],\n })\n }\n\n if (bundle === 'webpack') {\n configWebpack(bundlerOptions, app, (config) => {\n config.plugins ??= []\n const replaceAssets = createWebpackPluginReplaceAssets()\n config.plugins.push(replaceAssets(rules))\n })\n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iBAAkB,WAAW,CAAE,CAAE,CAC3D,QAAQ,EAAM,CACZ,OAAO,EAAgB,EAAM,EAAS,EAAM,EAE/C,CACF,EAGU,MAE0B,EAAiB,EAAqB,CAEhE,MAEsB,EAAoB,EAAqB,CCN/D,EACX,GACW,CACX,IAAM,EAAe,CAAE,KAAM,kCAAa,CAEpC,EAAQ,EAAe,EAAQ,CAIrC,OAFI,EAAM,SAAW,EAAU,EAExB,CACL,GAAG,EAEH,sBAAsB,EAAgB,EAAK,CACzC,IAAM,EAAS,EAAe,EAAI,CAE9B,IAAW,QAEb,EAAc,EAAgB,EAAK,CACjC,QAAS,CAFW,GAA+B,CAE3B,EAAM,CAAC,CAChC,CAAC,CAGA,IAAW,WACb,EAAc,EAAgB,EAAM,GAAW,CAC7C,EAAO,UAAY,EAAE,CACrB,IAAM,EAAgB,GAAkC,CACxD,EAAO,QAAQ,KAAK,EAAc,EAAM,CAAC,EACzC,EAGP"}
package/package.json CHANGED
@@ -1,22 +1,17 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-replace-assets",
3
- "version": "2.0.0-rc.122",
3
+ "version": "2.0.0-rc.124",
4
4
  "description": "VuePress plugin - replace assets",
5
5
  "keywords": [
6
- "vuepress-plugin",
7
- "vuepress",
8
6
  "plugin",
9
- "replace assets"
7
+ "replace assets",
8
+ "vuepress",
9
+ "vuepress-plugin"
10
10
  ],
11
11
  "homepage": "https://ecosystem.vuejs.press/plugins/tools/replace-assets.html",
12
12
  "bugs": {
13
13
  "url": "https://github.com/vuepress/ecosystem/issues"
14
14
  },
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/vuepress/ecosystem.git",
18
- "directory": "plugins/tools/plugin-replace-assets"
19
- },
20
15
  "license": "MIT",
21
16
  "author": "pengzhanbo",
22
17
  "maintainers": [
@@ -25,26 +20,36 @@
25
20
  "email": "volodymyr@foxmail.com"
26
21
  }
27
22
  ],
28
- "type": "module",
29
- "exports": {
30
- ".": "./lib/node/index.js",
31
- "./package.json": "./package.json"
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/vuepress/ecosystem.git",
26
+ "directory": "plugins/tools/plugin-replace-assets"
32
27
  },
33
- "main": "./lib/node/index.js",
34
- "types": "./lib/node/index.d.ts",
35
28
  "files": [
36
29
  "lib"
37
30
  ],
31
+ "type": "module",
32
+ "sideEffects": false,
33
+ "exports": {
34
+ ".": {
35
+ "types": "./lib/node/index.d.ts",
36
+ "default": "./lib/node/index.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
38
43
  "dependencies": {
39
- "@vuepress/helper": "2.0.0-rc.122",
44
+ "@vuepress/helper": "2.0.0-rc.124",
40
45
  "magic-string": "^0.30.21",
41
46
  "unplugin": "^3.0.0"
42
47
  },
48
+ "devDependencies": {
49
+ "webpack": "^5.105.3"
50
+ },
43
51
  "peerDependencies": {
44
52
  "vuepress": "2.0.0-rc.26"
45
53
  },
46
- "publishConfig": {
47
- "access": "public"
48
- },
49
- "gitHead": "5dfd2d24f8335f718182701995420907b0a00905"
54
+ "gitHead": "f17e7479b1ef3c06814b6107df9188ba351702da"
50
55
  }