@slidev/parser 0.49.11 → 0.49.13

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.
@@ -120,7 +120,7 @@ function verifyConfig(config, themeMeta = {}, warn = (v) => console.warn(`[slide
120
120
  warn(`Color schema "${config.colorSchema}" does not supported by the theme`);
121
121
  if (themeHightlighter && config.highlighter !== themeHightlighter)
122
122
  warn(`Syntax highlighter "${config.highlighter}" does not supported by the theme`);
123
- if (!["unocss", void 0].includes(config.css)) {
123
+ if (config.css !== "unocss") {
124
124
  warn(`Unsupported Atomic CSS engine "${config.css}", fallback to UnoCSS`);
125
125
  config.css = "unocss";
126
126
  }
package/dist/core.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  stringify,
13
13
  stringifySlide,
14
14
  verifyConfig
15
- } from "./chunk-HHQTU4EH.mjs";
15
+ } from "./chunk-ZR4UYCRF.mjs";
16
16
  export {
17
17
  detectFeatures,
18
18
  getDefaultConfig,
package/dist/fs.mjs CHANGED
@@ -12,10 +12,10 @@ import {
12
12
  stringify,
13
13
  stringifySlide,
14
14
  verifyConfig
15
- } from "./chunk-HHQTU4EH.mjs";
15
+ } from "./chunk-ZR4UYCRF.mjs";
16
16
 
17
17
  // src/fs.ts
18
- import { promises as fs } from "node:fs";
18
+ import fs from "node:fs";
19
19
  import { dirname, resolve } from "node:path";
20
20
  import YAML from "yaml";
21
21
  import { slash } from "@antfu/utils";
@@ -24,7 +24,7 @@ function injectPreparserExtensionLoader(fn) {
24
24
  preparserExtensionLoader = fn;
25
25
  }
26
26
  async function load(userRoot, filepath, content, mode) {
27
- const markdown = content ?? await fs.readFile(filepath, "utf-8");
27
+ const markdown = content ?? fs.readFileSync(filepath, "utf-8");
28
28
  let extensions;
29
29
  if (preparserExtensionLoader) {
30
30
  const lines = markdown.split(/\r?\n/g);
@@ -43,20 +43,29 @@ async function load(userRoot, filepath, content, mode) {
43
43
  async function loadMarkdown(path, range, frontmatterOverride, importers) {
44
44
  let md = markdownFiles[path];
45
45
  if (!md) {
46
- const raw = await fs.readFile(path, "utf-8");
46
+ const raw = fs.readFileSync(path, "utf-8");
47
47
  md = await parse(raw, path, extensions);
48
48
  markdownFiles[path] = md;
49
49
  }
50
50
  const directImporter = importers?.at(-1);
51
51
  for (const index of parseRangeString(md.slides.length, range)) {
52
52
  const subSlide = md.slides[index - 1];
53
- await loadSlide(subSlide, frontmatterOverride, importers);
53
+ try {
54
+ await loadSlide(md, subSlide, frontmatterOverride, importers);
55
+ } catch (e) {
56
+ md.errors ??= [];
57
+ md.errors.push({
58
+ row: subSlide.start,
59
+ message: `Error when loading slide: ${e}`
60
+ });
61
+ continue;
62
+ }
54
63
  if (directImporter)
55
64
  (directImporter.imports ??= []).push(subSlide);
56
65
  }
57
66
  return md;
58
67
  }
59
- async function loadSlide(slide, frontmatterOverride, importChain) {
68
+ async function loadSlide(md, slide, frontmatterOverride, importChain) {
60
69
  if (slide.frontmatter.disabled || slide.frontmatter.hide)
61
70
  return;
62
71
  if (slide.frontmatter.src) {
@@ -69,7 +78,15 @@ async function load(userRoot, filepath, content, mode) {
69
78
  ...frontmatterOverride
70
79
  };
71
80
  delete frontmatterOverride.src;
72
- await loadMarkdown(path, rangeRaw, frontmatterOverride, importChain ? [...importChain, slide] : [slide]);
81
+ if (!fs.existsSync(path)) {
82
+ md.errors ??= [];
83
+ md.errors.push({
84
+ row: slide.start,
85
+ message: `Imported markdown file not found: ${path}`
86
+ });
87
+ } else {
88
+ await loadMarkdown(path, rangeRaw, frontmatterOverride, importChain ? [...importChain, slide] : [slide]);
89
+ }
73
90
  } else {
74
91
  slides.push({
75
92
  index: slides.length,
@@ -98,7 +115,7 @@ async function load(userRoot, filepath, content, mode) {
98
115
  }
99
116
  async function save(markdown) {
100
117
  const fileContent = stringify(markdown);
101
- await fs.writeFile(markdown.filepath, fileContent, "utf-8");
118
+ fs.writeFileSync(markdown.filepath, fileContent, "utf-8");
102
119
  return fileContent;
103
120
  }
104
121
  export {
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  stringify,
13
13
  stringifySlide,
14
14
  verifyConfig
15
- } from "./chunk-HHQTU4EH.mjs";
15
+ } from "./chunk-ZR4UYCRF.mjs";
16
16
  export {
17
17
  detectFeatures,
18
18
  getDefaultConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/parser",
3
- "version": "0.49.11",
3
+ "version": "0.49.13",
4
4
  "description": "Markdown parser for Slidev",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -13,24 +13,21 @@
13
13
  "bugs": "https://github.com/slidevjs/slidev/issues",
14
14
  "exports": {
15
15
  ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.mjs",
18
- "require": "./dist/index.js"
16
+ "types": "./dist/index.d.mts",
17
+ "import": "./dist/index.mjs"
19
18
  },
20
19
  "./core": {
21
- "types": "./dist/core.d.ts",
22
- "import": "./dist/core.mjs",
23
- "require": "./dist/core.js"
20
+ "types": "./dist/core.d.mts",
21
+ "import": "./dist/core.mjs"
24
22
  },
25
23
  "./fs": {
26
- "types": "./fs.d.ts",
27
- "import": "./dist/fs.mjs",
28
- "require": "./dist/fs.js"
24
+ "types": "./dist/fs.d.mts",
25
+ "import": "./dist/fs.mjs"
29
26
  }
30
27
  },
31
- "main": "dist/index.js",
28
+ "main": "dist/index.mjs",
32
29
  "module": "dist/index.mjs",
33
- "types": "dist/index.d.ts",
30
+ "types": "dist/index.d.mts",
34
31
  "files": [
35
32
  "*.d.ts",
36
33
  "dist"
@@ -39,9 +36,9 @@
39
36
  "node": ">=18.0.0"
40
37
  },
41
38
  "dependencies": {
42
- "@antfu/utils": "^0.7.8",
43
- "yaml": "^2.4.2",
44
- "@slidev/types": "0.49.11"
39
+ "@antfu/utils": "^0.7.10",
40
+ "yaml": "^2.4.5",
41
+ "@slidev/types": "0.49.13"
45
42
  },
46
43
  "scripts": {
47
44
  "build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts",
package/fs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/fs.mjs'