@slidev/parser 0.27.20 → 0.28.3

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,7 +1,11 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
5
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -17,11 +21,74 @@ var __spreadValues = (a, b) => {
17
21
  return a;
18
22
  };
19
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
26
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
27
+ }) : x)(function(x) {
28
+ if (typeof require !== "undefined")
29
+ return require.apply(this, arguments);
30
+ throw new Error('Dynamic require of "' + x + '" is not supported');
31
+ });
32
+ var __esm = (fn, res) => function __init() {
33
+ return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
34
+ };
35
+ var __commonJS = (cb, mod) => function __require2() {
36
+ return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
37
+ };
38
+ var __reExport = (target, module, desc) => {
39
+ if (module && typeof module === "object" || typeof module === "function") {
40
+ for (let key of __getOwnPropNames(module))
41
+ if (!__hasOwnProp.call(target, key) && key !== "default")
42
+ __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
43
+ }
44
+ return target;
45
+ };
46
+ var __toModule = (module) => {
47
+ return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
48
+ };
49
+ var __accessCheck = (obj, member, msg) => {
50
+ if (!member.has(obj))
51
+ throw TypeError("Cannot " + msg);
52
+ };
53
+ var __privateGet = (obj, member, getter) => {
54
+ __accessCheck(obj, member, "read from private field");
55
+ return getter ? getter.call(obj) : member.get(obj);
56
+ };
57
+ var __privateAdd = (obj, member, value) => {
58
+ if (member.has(obj))
59
+ throw TypeError("Cannot add the same private member more than once");
60
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
61
+ };
62
+ var __privateSet = (obj, member, value, setter) => {
63
+ __accessCheck(obj, member, "write to private field");
64
+ setter ? setter.call(obj, value) : member.set(obj, value);
65
+ return value;
66
+ };
67
+ var __privateWrapper = (obj, member, setter, getter) => {
68
+ return {
69
+ set _(value) {
70
+ __privateSet(obj, member, value, setter);
71
+ },
72
+ get _() {
73
+ return __privateGet(obj, member, getter);
74
+ }
75
+ };
76
+ };
77
+
78
+ // ../../node_modules/.pnpm/tsup@5.11.13_typescript@4.5.5/node_modules/tsup/assets/esm_shims.js
79
+ import { fileURLToPath } from "url";
80
+ import path from "path";
81
+ var init_esm_shims = __esm({
82
+ "../../node_modules/.pnpm/tsup@5.11.13_typescript@4.5.5/node_modules/tsup/assets/esm_shims.js"() {
83
+ }
84
+ });
20
85
 
21
86
  // src/core.ts
87
+ init_esm_shims();
22
88
  import YAML from "js-yaml";
23
89
 
24
- // ../../node_modules/.pnpm/@antfu+utils@0.3.0/node_modules/@antfu/utils/dist/index.mjs
90
+ // ../../node_modules/.pnpm/@antfu+utils@0.5.0/node_modules/@antfu/utils/dist/index.mjs
91
+ init_esm_shims();
25
92
  function toArray(array) {
26
93
  array = array || [];
27
94
  if (Array.isArray(array))
@@ -48,6 +115,7 @@ function range(...args) {
48
115
  }
49
116
  return arr;
50
117
  }
118
+ var toString = (v) => Object.prototype.toString.call(v);
51
119
  function notNullish(v) {
52
120
  return v != null;
53
121
  }
@@ -55,12 +123,71 @@ function isTruthy(v) {
55
123
  return Boolean(v);
56
124
  }
57
125
  var isNumber = (val) => typeof val === "number";
58
- var isObject = (val) => toString.call(val) === "[object Object]";
126
+ var isObject = (val) => toString(val) === "[object Object]";
59
127
  function objectMap(obj, fn) {
60
128
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => fn(k, v)).filter(notNullish));
61
129
  }
130
+ var Node = class {
131
+ value;
132
+ next;
133
+ constructor(value) {
134
+ this.value = value;
135
+ }
136
+ };
137
+ var _head, _tail, _size;
138
+ var Queue = class {
139
+ constructor() {
140
+ __privateAdd(this, _head, void 0);
141
+ __privateAdd(this, _tail, void 0);
142
+ __privateAdd(this, _size, void 0);
143
+ this.clear();
144
+ }
145
+ enqueue(value) {
146
+ const node = new Node(value);
147
+ if (__privateGet(this, _head)) {
148
+ __privateGet(this, _tail).next = node;
149
+ __privateSet(this, _tail, node);
150
+ } else {
151
+ __privateSet(this, _head, node);
152
+ __privateSet(this, _tail, node);
153
+ }
154
+ __privateWrapper(this, _size)._++;
155
+ }
156
+ dequeue() {
157
+ const current = __privateGet(this, _head);
158
+ if (!current) {
159
+ return;
160
+ }
161
+ __privateSet(this, _head, __privateGet(this, _head).next);
162
+ __privateWrapper(this, _size)._--;
163
+ return current.value;
164
+ }
165
+ clear() {
166
+ __privateSet(this, _head, void 0);
167
+ __privateSet(this, _tail, void 0);
168
+ __privateSet(this, _size, 0);
169
+ }
170
+ get size() {
171
+ return __privateGet(this, _size);
172
+ }
173
+ *[Symbol.iterator]() {
174
+ let current = __privateGet(this, _head);
175
+ while (current) {
176
+ yield current.value;
177
+ current = current.next;
178
+ }
179
+ }
180
+ };
181
+ _head = new WeakMap();
182
+ _tail = new WeakMap();
183
+ _size = new WeakMap();
184
+ var VOID = Symbol("p-void");
185
+
186
+ // src/config.ts
187
+ init_esm_shims();
62
188
 
63
189
  // src/utils.ts
190
+ init_esm_shims();
64
191
  function parseRangeString(total, rangeStr) {
65
192
  if (!rangeStr || rangeStr === "all" || rangeStr === "*")
66
193
  return range(1, total + 1);
@@ -287,10 +414,20 @@ function parseSlide(raw) {
287
414
  content = content.slice(0, last.index).trim();
288
415
  }
289
416
  }
290
- const title = frontmatter.title || frontmatter.name || ((_b = (_a = content.match(/^#+ (.*)$/m)) == null ? void 0 : _a[1]) == null ? void 0 : _b.trim());
417
+ let title;
418
+ let level;
419
+ if (frontmatter.title || frontmatter.name) {
420
+ title = frontmatter.title || frontmatter.name;
421
+ level = frontmatter.level || 1;
422
+ } else {
423
+ const match = content.match(/^(#+) (.*)$/m);
424
+ title = (_a = match == null ? void 0 : match[2]) == null ? void 0 : _a.trim();
425
+ level = (_b = match == null ? void 0 : match[1]) == null ? void 0 : _b.length;
426
+ }
291
427
  return {
292
428
  raw,
293
429
  title,
430
+ level,
294
431
  content,
295
432
  frontmatter,
296
433
  note
@@ -313,14 +450,14 @@ function parse(markdown, filepath, themeMeta) {
313
450
  start = end + 1;
314
451
  }
315
452
  for (let i = 0; i < lines.length; i++) {
316
- const line = lines[i].trimRight();
453
+ const line = lines[i].trimEnd();
317
454
  if (line.match(/^---+/)) {
318
455
  slice(i);
319
456
  const next = lines[i + 1];
320
457
  if (line.match(/^---([^-].*)?$/) && !(next == null ? void 0 : next.match(/^\s*$/))) {
321
458
  start = i;
322
459
  for (i += 1; i < lines.length; i++) {
323
- if (lines[i].trimRight().match(/^---$/))
460
+ if (lines[i].trimEnd().match(/^---$/))
324
461
  break;
325
462
  }
326
463
  }
@@ -365,6 +502,10 @@ function scanMonacoModules(md) {
365
502
 
366
503
  export {
367
504
  __spreadValues,
505
+ __require,
506
+ __commonJS,
507
+ __toModule,
508
+ init_esm_shims,
368
509
  parseRangeString,
369
510
  parseAspectRatio,
370
511
  resolveConfig,
@@ -1,7 +1,11 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
5
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -17,11 +21,72 @@ var __spreadValues = (a, b) => {
17
21
  return a;
18
22
  };
19
23
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
26
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
27
+ }) : x)(function(x) {
28
+ if (typeof require !== "undefined")
29
+ return require.apply(this, arguments);
30
+ throw new Error('Dynamic require of "' + x + '" is not supported');
31
+ });
32
+ var __esm = (fn, res) => function __init() {
33
+ return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
34
+ };
35
+ var __commonJS = (cb, mod) => function __require2() {
36
+ return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
37
+ };
38
+ var __reExport = (target, module, desc) => {
39
+ if (module && typeof module === "object" || typeof module === "function") {
40
+ for (let key of __getOwnPropNames(module))
41
+ if (!__hasOwnProp.call(target, key) && key !== "default")
42
+ __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
43
+ }
44
+ return target;
45
+ };
46
+ var __toModule = (module) => {
47
+ return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
48
+ };
49
+ var __accessCheck = (obj, member, msg) => {
50
+ if (!member.has(obj))
51
+ throw TypeError("Cannot " + msg);
52
+ };
53
+ var __privateGet = (obj, member, getter) => {
54
+ __accessCheck(obj, member, "read from private field");
55
+ return getter ? getter.call(obj) : member.get(obj);
56
+ };
57
+ var __privateAdd = (obj, member, value) => {
58
+ if (member.has(obj))
59
+ throw TypeError("Cannot add the same private member more than once");
60
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
61
+ };
62
+ var __privateSet = (obj, member, value, setter) => {
63
+ __accessCheck(obj, member, "write to private field");
64
+ setter ? setter.call(obj, value) : member.set(obj, value);
65
+ return value;
66
+ };
67
+ var __privateWrapper = (obj, member, setter, getter) => {
68
+ return {
69
+ set _(value) {
70
+ __privateSet(obj, member, value, setter);
71
+ },
72
+ get _() {
73
+ return __privateGet(obj, member, getter);
74
+ }
75
+ };
76
+ };
77
+
78
+ // ../../node_modules/.pnpm/tsup@5.11.13_typescript@4.5.5/node_modules/tsup/assets/cjs_shims.js
79
+ var init_cjs_shims = __esm({
80
+ "../../node_modules/.pnpm/tsup@5.11.13_typescript@4.5.5/node_modules/tsup/assets/cjs_shims.js"() {
81
+ }
82
+ });
20
83
 
21
84
  // src/core.ts
85
+ init_cjs_shims();
22
86
  var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);
23
87
 
24
- // ../../node_modules/.pnpm/@antfu+utils@0.3.0/node_modules/@antfu/utils/dist/index.mjs
88
+ // ../../node_modules/.pnpm/@antfu+utils@0.5.0/node_modules/@antfu/utils/dist/index.mjs
89
+ init_cjs_shims();
25
90
  function toArray(array) {
26
91
  array = array || [];
27
92
  if (Array.isArray(array))
@@ -48,6 +113,7 @@ function range(...args) {
48
113
  }
49
114
  return arr;
50
115
  }
116
+ var toString = (v) => Object.prototype.toString.call(v);
51
117
  function notNullish(v) {
52
118
  return v != null;
53
119
  }
@@ -55,12 +121,71 @@ function isTruthy(v) {
55
121
  return Boolean(v);
56
122
  }
57
123
  var isNumber = (val) => typeof val === "number";
58
- var isObject = (val) => toString.call(val) === "[object Object]";
124
+ var isObject = (val) => toString(val) === "[object Object]";
59
125
  function objectMap(obj, fn) {
60
126
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => fn(k, v)).filter(notNullish));
61
127
  }
128
+ var Node = class {
129
+
130
+
131
+ constructor(value) {
132
+ this.value = value;
133
+ }
134
+ };
135
+ var _head, _tail, _size;
136
+ var Queue = class {
137
+ constructor() {
138
+ __privateAdd(this, _head, void 0);
139
+ __privateAdd(this, _tail, void 0);
140
+ __privateAdd(this, _size, void 0);
141
+ this.clear();
142
+ }
143
+ enqueue(value) {
144
+ const node = new Node(value);
145
+ if (__privateGet(this, _head)) {
146
+ __privateGet(this, _tail).next = node;
147
+ __privateSet(this, _tail, node);
148
+ } else {
149
+ __privateSet(this, _head, node);
150
+ __privateSet(this, _tail, node);
151
+ }
152
+ __privateWrapper(this, _size)._++;
153
+ }
154
+ dequeue() {
155
+ const current = __privateGet(this, _head);
156
+ if (!current) {
157
+ return;
158
+ }
159
+ __privateSet(this, _head, __privateGet(this, _head).next);
160
+ __privateWrapper(this, _size)._--;
161
+ return current.value;
162
+ }
163
+ clear() {
164
+ __privateSet(this, _head, void 0);
165
+ __privateSet(this, _tail, void 0);
166
+ __privateSet(this, _size, 0);
167
+ }
168
+ get size() {
169
+ return __privateGet(this, _size);
170
+ }
171
+ *[Symbol.iterator]() {
172
+ let current = __privateGet(this, _head);
173
+ while (current) {
174
+ yield current.value;
175
+ current = current.next;
176
+ }
177
+ }
178
+ };
179
+ _head = new WeakMap();
180
+ _tail = new WeakMap();
181
+ _size = new WeakMap();
182
+ var VOID = Symbol("p-void");
183
+
184
+ // src/config.ts
185
+ init_cjs_shims();
62
186
 
63
187
  // src/utils.ts
188
+ init_cjs_shims();
64
189
  function parseRangeString(total, rangeStr) {
65
190
  if (!rangeStr || rangeStr === "all" || rangeStr === "*")
66
191
  return range(1, total + 1);
@@ -287,10 +412,20 @@ function parseSlide(raw) {
287
412
  content = content.slice(0, last.index).trim();
288
413
  }
289
414
  }
290
- const title = frontmatter.title || frontmatter.name || ((_b = (_a = content.match(/^#+ (.*)$/m)) == null ? void 0 : _a[1]) == null ? void 0 : _b.trim());
415
+ let title;
416
+ let level;
417
+ if (frontmatter.title || frontmatter.name) {
418
+ title = frontmatter.title || frontmatter.name;
419
+ level = frontmatter.level || 1;
420
+ } else {
421
+ const match = content.match(/^(#+) (.*)$/m);
422
+ title = (_a = match == null ? void 0 : match[2]) == null ? void 0 : _a.trim();
423
+ level = (_b = match == null ? void 0 : match[1]) == null ? void 0 : _b.length;
424
+ }
291
425
  return {
292
426
  raw,
293
427
  title,
428
+ level,
294
429
  content,
295
430
  frontmatter,
296
431
  note
@@ -313,14 +448,14 @@ function parse(markdown, filepath, themeMeta) {
313
448
  start = end + 1;
314
449
  }
315
450
  for (let i = 0; i < lines.length; i++) {
316
- const line = lines[i].trimRight();
451
+ const line = lines[i].trimEnd();
317
452
  if (line.match(/^---+/)) {
318
453
  slice(i);
319
454
  const next = lines[i + 1];
320
455
  if (line.match(/^---([^-].*)?$/) && !(next == null ? void 0 : next.match(/^\s*$/))) {
321
456
  start = i;
322
457
  for (i += 1; i < lines.length; i++) {
323
- if (lines[i].trimRight().match(/^---$/))
458
+ if (lines[i].trimEnd().match(/^---$/))
324
459
  break;
325
460
  }
326
461
  }
@@ -379,4 +514,8 @@ function scanMonacoModules(md) {
379
514
 
380
515
 
381
516
 
382
- exports.__spreadValues = __spreadValues; exports.parseRangeString = parseRangeString; exports.parseAspectRatio = parseAspectRatio; exports.resolveConfig = resolveConfig; exports.resolveFonts = resolveFonts; exports.stringify = stringify; exports.filterDisabled = filterDisabled; exports.stringifySlide = stringifySlide; exports.prettifySlide = prettifySlide; exports.prettify = prettify; exports.detectFeatures = detectFeatures; exports.parseSlide = parseSlide; exports.parse = parse; exports.mergeFeatureFlags = mergeFeatureFlags; exports.scanMonacoModules = scanMonacoModules;
517
+
518
+
519
+
520
+
521
+ exports.__spreadValues = __spreadValues; exports.__require = __require; exports.__commonJS = __commonJS; exports.__toModule = __toModule; exports.init_cjs_shims = init_cjs_shims; exports.parseRangeString = parseRangeString; exports.parseAspectRatio = parseAspectRatio; exports.resolveConfig = resolveConfig; exports.resolveFonts = resolveFonts; exports.stringify = stringify; exports.filterDisabled = filterDisabled; exports.stringifySlide = stringifySlide; exports.prettifySlide = prettifySlide; exports.prettify = prettify; exports.detectFeatures = detectFeatures; exports.parseSlide = parseSlide; exports.parse = parse; exports.mergeFeatureFlags = mergeFeatureFlags; exports.scanMonacoModules = scanMonacoModules;
package/dist/core.js CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
 
15
15
 
16
- var _chunkVFP6MEJGjs = require('./chunk-VFP6MEJG.js');
16
+ var _chunkYSTQPPYUjs = require('./chunk-YSTQPPYU.js');
17
17
 
18
18
 
19
19
 
@@ -29,4 +29,4 @@ var _chunkVFP6MEJGjs = require('./chunk-VFP6MEJG.js');
29
29
 
30
30
 
31
31
 
32
- exports.detectFeatures = _chunkVFP6MEJGjs.detectFeatures; exports.filterDisabled = _chunkVFP6MEJGjs.filterDisabled; exports.mergeFeatureFlags = _chunkVFP6MEJGjs.mergeFeatureFlags; exports.parse = _chunkVFP6MEJGjs.parse; exports.parseAspectRatio = _chunkVFP6MEJGjs.parseAspectRatio; exports.parseRangeString = _chunkVFP6MEJGjs.parseRangeString; exports.parseSlide = _chunkVFP6MEJGjs.parseSlide; exports.prettify = _chunkVFP6MEJGjs.prettify; exports.prettifySlide = _chunkVFP6MEJGjs.prettifySlide; exports.resolveConfig = _chunkVFP6MEJGjs.resolveConfig; exports.resolveFonts = _chunkVFP6MEJGjs.resolveFonts; exports.scanMonacoModules = _chunkVFP6MEJGjs.scanMonacoModules; exports.stringify = _chunkVFP6MEJGjs.stringify; exports.stringifySlide = _chunkVFP6MEJGjs.stringifySlide;
32
+ exports.detectFeatures = _chunkYSTQPPYUjs.detectFeatures; exports.filterDisabled = _chunkYSTQPPYUjs.filterDisabled; exports.mergeFeatureFlags = _chunkYSTQPPYUjs.mergeFeatureFlags; exports.parse = _chunkYSTQPPYUjs.parse; exports.parseAspectRatio = _chunkYSTQPPYUjs.parseAspectRatio; exports.parseRangeString = _chunkYSTQPPYUjs.parseRangeString; exports.parseSlide = _chunkYSTQPPYUjs.parseSlide; exports.prettify = _chunkYSTQPPYUjs.prettify; exports.prettifySlide = _chunkYSTQPPYUjs.prettifySlide; exports.resolveConfig = _chunkYSTQPPYUjs.resolveConfig; exports.resolveFonts = _chunkYSTQPPYUjs.resolveFonts; exports.scanMonacoModules = _chunkYSTQPPYUjs.scanMonacoModules; exports.stringify = _chunkYSTQPPYUjs.stringify; exports.stringifySlide = _chunkYSTQPPYUjs.stringifySlide;
package/dist/core.mjs CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  scanMonacoModules,
14
14
  stringify,
15
15
  stringifySlide
16
- } from "./chunk-4LEQMYU6.mjs";
16
+ } from "./chunk-YMAA333D.mjs";
17
17
  export {
18
18
  detectFeatures,
19
19
  filterDisabled,