vuepress-plugin-md-power 1.0.0-rc.127 → 1.0.0-rc.128

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.
Files changed (2) hide show
  1. package/lib/node/index.js +34 -32
  2. package/package.json +1 -1
package/lib/node/index.js CHANGED
@@ -1942,7 +1942,7 @@ var markdownContainerRender = {
1942
1942
 
1943
1943
  // src/node/demo/normal.ts
1944
1944
  import fs5 from "node:fs";
1945
- import path4 from "node:path";
1945
+ import path5 from "node:path";
1946
1946
 
1947
1947
  // src/node/demo/supports/compiler.ts
1948
1948
  import { isPackageExists } from "local-pkg";
@@ -2022,8 +2022,8 @@ function importer(func) {
2022
2022
 
2023
2023
  // src/node/demo/supports/insertScript.ts
2024
2024
  var SCRIPT_RE = /<script.*?>/;
2025
- function insertSetupScript({ export: name, path: path8 }, env) {
2026
- const imports = `import ${name ? `${name} from ` : ""}'${path8}';`;
2025
+ function insertSetupScript({ export: name, path: path9 }, env) {
2026
+ const imports = `import ${name ? `${name} from ` : ""}'${path9}';`;
2027
2027
  const scriptSetup = env.sfcBlocks.scriptSetup ??= {
2028
2028
  type: "script",
2029
2029
  content: "<script setup>\n</script>",
@@ -2039,6 +2039,7 @@ ${imports}`);
2039
2039
 
2040
2040
  // src/node/demo/watcher.ts
2041
2041
  import fs4 from "node:fs";
2042
+ import path4 from "node:path";
2042
2043
  import { watch } from "chokidar";
2043
2044
  var renderDone = null;
2044
2045
  var renderCount = 0;
@@ -2074,46 +2075,47 @@ function demoWatcher(app, watchers) {
2074
2075
  if (!watcher) {
2075
2076
  watcher = watch([], { ignoreInitial: true });
2076
2077
  }
2077
- Object.keys(tasks).forEach((path8) => {
2078
- watcher.add(path8);
2078
+ Object.keys(tasks).forEach((path9) => {
2079
+ watcher.add(path9);
2079
2080
  });
2080
2081
  const code = readFileSync(app.dir.temp(target));
2081
2082
  if (code) {
2082
2083
  const paths = JSON.parse(code || "{}");
2083
- Object.entries(paths).forEach(([path8, output]) => {
2084
- watcher.add(path8);
2085
- tasks[path8] = output;
2084
+ Object.entries(paths).forEach(([path9, output]) => {
2085
+ watcher.add(path9);
2086
+ tasks[path9] = output;
2086
2087
  });
2087
2088
  }
2088
2089
  updateWatchFiles(app);
2089
- watcher.on("change", (path8) => {
2090
- if (tasks[path8]) {
2091
- const code2 = readFileSync(path8);
2090
+ watcher.on("change", (path9) => {
2091
+ if (tasks[path9]) {
2092
+ const code2 = readFileSync(path9);
2092
2093
  if (code2 === false)
2093
2094
  return;
2094
2095
  const source = parseEmbedCode(code2);
2095
- compileCode(source, tasks[path8]);
2096
+ compileCode(source, tasks[path9]);
2096
2097
  }
2097
2098
  });
2098
- watcher.on("unlink", (path8) => {
2099
- delete tasks[path8];
2100
- watcher.unwatch(path8);
2099
+ watcher.on("unlink", (path9) => {
2100
+ delete tasks[path9];
2101
+ watcher.unwatch(path9);
2101
2102
  });
2102
2103
  watchers.push(() => {
2103
2104
  watcher.close();
2104
2105
  watcher = null;
2105
2106
  });
2106
2107
  }
2107
- function addTask(app, path8, output) {
2108
- if (tasks[path8])
2108
+ function addTask(app, path9, output) {
2109
+ if (tasks[path9])
2109
2110
  return;
2110
- tasks[path8] = output;
2111
+ tasks[path9] = output;
2111
2112
  if (watcher) {
2112
- watcher.add(path8);
2113
+ watcher.add(path9);
2113
2114
  }
2114
2115
  updateWatchFiles(app);
2115
2116
  }
2116
2117
  async function updateWatchFiles(app) {
2118
+ await fs4.promises.mkdir(app.dir.temp(path4.dirname(target)), { recursive: true });
2117
2119
  await fs4.promises.writeFile(app.dir.temp(target), JSON.stringify(tasks));
2118
2120
  }
2119
2121
 
@@ -2205,7 +2207,7 @@ function normalEmbed(app, md, env, { url, title, desc, codeSetting = "", expande
2205
2207
  }
2206
2208
  const source = parseEmbedCode(code);
2207
2209
  const prefix = (env.filePathRelative || "").replace(/\.md$/, "").replace(/\//g, "-");
2208
- const basename = path4.basename(filepath2).replace(/-|\./g, "_");
2210
+ const basename = path5.basename(filepath2).replace(/-|\./g, "_");
2209
2211
  const name = `Demo${basename[0].toUpperCase()}${basename.slice(1)}`;
2210
2212
  const demo = { type: "normal", export: name, path: filepath2 };
2211
2213
  const output = app.dir.temp(target2, `${prefix}-${name}.js`);
@@ -2225,7 +2227,7 @@ var normalContainerRender = {
2225
2227
  const { url, title, desc, expanded = false } = meta;
2226
2228
  const name = `DemoContainer${url}`;
2227
2229
  const prefix = (env.filePathRelative || "").replace(/\.md$/, "").replace(/\//g, "-");
2228
- const output = app.dir.temp(path4.join(target2, `${prefix}-${name}.js`));
2230
+ const output = app.dir.temp(path5.join(target2, `${prefix}-${name}.js`));
2229
2231
  env.demoFiles ??= [];
2230
2232
  if (!env.demoFiles.some((d) => d.path === output)) {
2231
2233
  const demo = { type: "normal", export: name, gitignore: true, path: output };
@@ -2303,7 +2305,7 @@ function normalizeAlias(info) {
2303
2305
  }
2304
2306
 
2305
2307
  // src/node/demo/vue.ts
2306
- import path5 from "node:path";
2308
+ import path6 from "node:path";
2307
2309
  function vueEmbed(app, md, env, { url, title, desc, codeSetting = "", expanded = false }) {
2308
2310
  const filepath2 = findFile(app, env, url);
2309
2311
  const code = readFileSync(filepath2);
@@ -2311,8 +2313,8 @@ function vueEmbed(app, md, env, { url, title, desc, codeSetting = "", expanded =
2311
2313
  console.warn("[vuepress-plugin-md-power] Cannot read vue file:", filepath2);
2312
2314
  return "";
2313
2315
  }
2314
- const basename = path5.basename(filepath2).replace(/-|\./g, "_");
2315
- const ext = path5.extname(filepath2).slice(1);
2316
+ const basename = path6.basename(filepath2).replace(/-|\./g, "_");
2317
+ const ext = path6.extname(filepath2).slice(1);
2316
2318
  const name = `Demo${basename[0].toUpperCase()}${basename.slice(1)}`;
2317
2319
  const demo = { type: "vue", export: name, path: filepath2 };
2318
2320
  env.demoFiles ??= [];
@@ -2336,7 +2338,7 @@ var vueContainerRender = {
2336
2338
  const componentName2 = `DemoContainer${url}`;
2337
2339
  const prefix = (env.filePathRelative || "").replace(/\.md$/, "").replace(/\//g, "-");
2338
2340
  env.demoFiles ??= [];
2339
- const output = app.dir.temp(path5.join(target3, `${prefix}-${componentName2}`));
2341
+ const output = app.dir.temp(path6.join(target3, `${prefix}-${componentName2}`));
2340
2342
  if (codeMap.vue || codeMap.js || codeMap.ts) {
2341
2343
  let scriptOutput = output;
2342
2344
  let content = "";
@@ -2393,7 +2395,7 @@ var STYLE_RE2 = /<style.*?>/;
2393
2395
  function transformImports(code, filepath2) {
2394
2396
  return code.replace(IMPORT_RE, (matched, url) => {
2395
2397
  if (url.startsWith("./") || url.startsWith("../")) {
2396
- return matched.replace(url, `${path5.resolve(path5.dirname(filepath2), url)}`);
2398
+ return matched.replace(url, `${path6.resolve(path6.dirname(filepath2), url)}`);
2397
2399
  }
2398
2400
  return matched;
2399
2401
  });
@@ -2491,10 +2493,10 @@ function extendsPageWithDemo(page) {
2491
2493
  const markdownEnv = page.markdownEnv;
2492
2494
  const demoFiles = markdownEnv.demoFiles ?? [];
2493
2495
  page.deps.push(
2494
- ...demoFiles.filter(({ type: type2 }) => type2 === "markdown").map(({ path: path8 }) => path8)
2496
+ ...demoFiles.filter(({ type: type2 }) => type2 === "markdown").map(({ path: path9 }) => path9)
2495
2497
  );
2496
2498
  (page.frontmatter.gitInclude ??= []).push(
2497
- ...demoFiles.filter(({ gitignore }) => !gitignore).map(({ path: path8 }) => path8)
2499
+ ...demoFiles.filter(({ gitignore }) => !gitignore).map(({ path: path9 }) => path9)
2498
2500
  );
2499
2501
  }
2500
2502
 
@@ -2761,7 +2763,7 @@ var replitPlugin = (md) => {
2761
2763
  };
2762
2764
 
2763
2765
  // src/node/embed/pdf.ts
2764
- import { path as path6 } from "vuepress/utils";
2766
+ import { path as path7 } from "vuepress/utils";
2765
2767
  var pdfPlugin = (md) => {
2766
2768
  createEmbedRuleBlock(md, {
2767
2769
  type: "pdf",
@@ -2777,7 +2779,7 @@ var pdfPlugin = (md) => {
2777
2779
  width: attrs2.width ? parseRect(attrs2.width) : "100%",
2778
2780
  height: attrs2.height ? parseRect(attrs2.height) : "",
2779
2781
  ratio: attrs2.ratio ? parseRect(attrs2.ratio) : "",
2780
- title: path6.basename(src || "")
2782
+ title: path7.basename(src || "")
2781
2783
  };
2782
2784
  },
2783
2785
  content({ title, src, page, noToolbar, width, height, ratio, zoom }) {
@@ -3149,11 +3151,11 @@ function inlineSyntaxPlugin(md, options) {
3149
3151
 
3150
3152
  // src/node/prepareConfigFile.ts
3151
3153
  import { ensureEndingSlash } from "@vuepress/helper";
3152
- import { getDirname, path as path7 } from "vuepress/utils";
3154
+ import { getDirname, path as path8 } from "vuepress/utils";
3153
3155
  var { url: filepath } = import.meta;
3154
3156
  var __dirname = getDirname(filepath);
3155
3157
  var CLIENT_FOLDER = ensureEndingSlash(
3156
- path7.resolve(__dirname, "../client")
3158
+ path8.resolve(__dirname, "../client")
3157
3159
  );
3158
3160
  async function prepareConfigFile(app, options) {
3159
3161
  const imports = /* @__PURE__ */ new Set();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuepress-plugin-md-power",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.127",
4
+ "version": "1.0.0-rc.128",
5
5
  "description": "The Plugin for VuePress 2 - markdown power",
6
6
  "author": "pengzhanbo <volodymyr@foxmail.com>",
7
7
  "license": "MIT",