@slidev/parser 0.49.29 → 0.50.0-beta.2

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,9 @@
1
1
  // src/core.ts
2
- import YAML from "yaml";
3
2
  import { ensurePrefix } from "@antfu/utils";
3
+ import YAML from "yaml";
4
+
5
+ // src/config.ts
6
+ import { toArray, uniq as uniq2 } from "@antfu/utils";
4
7
 
5
8
  // src/utils.ts
6
9
  import { isNumber, range, uniq } from "@antfu/utils";
@@ -36,7 +39,6 @@ function parseAspectRatio(str) {
36
39
  }
37
40
 
38
41
  // src/config.ts
39
- import { toArray, uniq as uniq2 } from "@antfu/utils";
40
42
  function getDefaultConfig() {
41
43
  return {
42
44
  theme: "default",
@@ -74,6 +76,7 @@ function getDefaultConfig() {
74
76
  transition: null,
75
77
  editor: true,
76
78
  contextMenu: null,
79
+ overviewSnapshots: false,
77
80
  wakeLock: true,
78
81
  remote: false,
79
82
  mdc: false
@@ -106,6 +109,8 @@ function resolveConfig(headmatter, themeMeta = {}, filepath, verify = false) {
106
109
  console.warn(`[slidev] "shikiji" is merged back to "shiki", you can safely change it "highlighter: shiki"`);
107
110
  config.highlighter = "shiki";
108
111
  }
112
+ if (config.highlighter === "prism")
113
+ throw new Error(`[slidev] "prism" support has been dropped. Please use "highlighter: shiki" instead`);
109
114
  if (config.colorSchema !== "dark" && config.colorSchema !== "light")
110
115
  config.colorSchema = "auto";
111
116
  if (themeColorSchema && config.colorSchema === "auto")
@@ -116,7 +121,7 @@ function resolveConfig(headmatter, themeMeta = {}, filepath, verify = false) {
116
121
  return config;
117
122
  }
118
123
  function verifyConfig(config, themeMeta = {}, warn = (v) => console.warn(`[slidev] ${v}`)) {
119
- const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
124
+ const themeHightlighter = themeMeta.highlighter === "shiki" ? themeMeta.highlighter : void 0;
120
125
  const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
121
126
  if (themeColorSchema && config.colorSchema !== themeColorSchema)
122
127
  warn(`Color schema "${config.colorSchema}" does not supported by the theme`);
@@ -282,6 +287,7 @@ function parseSlide(raw, options = {}) {
282
287
  let note;
283
288
  const frontmatter = matterResult.data || {};
284
289
  let content = matterResult.content.trim();
290
+ const revision = hash(raw.trim());
285
291
  const comments = Array.from(content.matchAll(/<!--([\s\S]*?)-->/g));
286
292
  if (comments.length) {
287
293
  const last = comments[comments.length - 1];
@@ -305,6 +311,7 @@ function parseSlide(raw, options = {}) {
305
311
  raw,
306
312
  title,
307
313
  level,
314
+ revision,
308
315
  content,
309
316
  frontmatter,
310
317
  frontmatterStyle: matterResult.type,
@@ -460,6 +467,14 @@ function scanMonacoReferencedMods(md) {
460
467
  deps: Array.from(deps)
461
468
  };
462
469
  }
470
+ function hash(str) {
471
+ let hash2 = 0;
472
+ for (let i = 0; i < str.length; i++) {
473
+ hash2 = (hash2 << 5) - hash2 + str.charCodeAt(i);
474
+ hash2 |= 0;
475
+ }
476
+ return hash2.toString(36).slice(0, 12);
477
+ }
463
478
 
464
479
  export {
465
480
  parseRangeString,
package/dist/core.d.mts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { SlidevConfig, SlidevThemeMeta, FontOptions, ResolvedFontOptions, SlidevMarkdown, SourceSlideInfo, SlidevDetectedFeatures, SlidevPreparserExtension } from '@slidev/types';
2
2
 
3
+ declare function getDefaultConfig(): SlidevConfig;
4
+ declare function resolveConfig(headmatter: any, themeMeta?: SlidevThemeMeta, filepath?: string, verify?: boolean): SlidevConfig;
5
+ declare function verifyConfig(config: SlidevConfig, themeMeta?: SlidevThemeMeta, warn?: (v: string) => void): void;
6
+ declare function resolveFonts(fonts?: FontOptions): ResolvedFontOptions;
7
+
3
8
  /**
4
9
  * 1,3-5,8 => [1, 3, 4, 5, 8]
5
10
  */
@@ -9,11 +14,6 @@ declare function parseRangeString(total: number, rangeStr?: string): number[];
9
14
  */
10
15
  declare function parseAspectRatio(str: string | number): number;
11
16
 
12
- declare function getDefaultConfig(): SlidevConfig;
13
- declare function resolveConfig(headmatter: any, themeMeta?: SlidevThemeMeta, filepath?: string, verify?: boolean): SlidevConfig;
14
- declare function verifyConfig(config: SlidevConfig, themeMeta?: SlidevThemeMeta, warn?: (v: string) => void): void;
15
- declare function resolveFonts(fonts?: FontOptions): ResolvedFontOptions;
16
-
17
17
  interface SlidevParserOptions {
18
18
  noParseYAML?: boolean;
19
19
  preserveCR?: boolean;
package/dist/core.mjs CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  stringify,
14
14
  stringifySlide,
15
15
  verifyConfig
16
- } from "./chunk-3LX2JHFR.mjs";
16
+ } from "./chunk-R2T34HUD.mjs";
17
17
  export {
18
18
  detectFeatures,
19
19
  getDefaultConfig,
package/dist/fs.mjs CHANGED
@@ -13,13 +13,13 @@ import {
13
13
  stringify,
14
14
  stringifySlide,
15
15
  verifyConfig
16
- } from "./chunk-3LX2JHFR.mjs";
16
+ } from "./chunk-R2T34HUD.mjs";
17
17
 
18
18
  // src/fs.ts
19
19
  import fs from "node:fs";
20
20
  import { dirname, resolve } from "node:path";
21
- import YAML from "yaml";
22
21
  import { slash } from "@antfu/utils";
22
+ import YAML from "yaml";
23
23
  var preparserExtensionLoader = null;
24
24
  function injectPreparserExtensionLoader(fn) {
25
25
  preparserExtensionLoader = fn;
@@ -94,6 +94,7 @@ async function load(userRoot, filepath, loadedSource = {}, mode) {
94
94
  slides.push({
95
95
  frontmatter: { ...slide.frontmatter, ...frontmatterOverride },
96
96
  content: slide.content,
97
+ revision: slide.revision,
97
98
  frontmatterRaw: slide.frontmatterRaw,
98
99
  note: slide.note,
99
100
  title: slide.title,
package/dist/index.mjs CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  stringify,
14
14
  stringifySlide,
15
15
  verifyConfig
16
- } from "./chunk-3LX2JHFR.mjs";
16
+ } from "./chunk-R2T34HUD.mjs";
17
17
  export {
18
18
  detectFeatures,
19
19
  getDefaultConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/parser",
3
- "version": "0.49.29",
3
+ "version": "0.50.0-beta.2",
4
4
  "description": "Markdown parser for Slidev",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -37,8 +37,8 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@antfu/utils": "^0.7.10",
40
- "yaml": "^2.5.0",
41
- "@slidev/types": "0.49.29"
40
+ "yaml": "^2.5.1",
41
+ "@slidev/types": "0.50.0-beta.2"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts",