@slidev/cli 0.48.0-beta.4 → 0.48.0-beta.5

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.
@@ -2,7 +2,7 @@ import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml,
4
4
  mergeViteConfigs
5
- } from "./chunk-JNK5R5DL.mjs";
5
+ } from "./chunk-U44GKKNH.mjs";
6
6
  import "./chunk-O6TYYGU6.mjs";
7
7
  import {
8
8
  findPkgRoot
@@ -4,7 +4,7 @@ import {
4
4
  mergeViteConfigs,
5
5
  require_semver,
6
6
  version
7
- } from "./chunk-JNK5R5DL.mjs";
7
+ } from "./chunk-U44GKKNH.mjs";
8
8
  import {
9
9
  createResolver,
10
10
  getRoots,
@@ -2496,7 +2496,7 @@ var require_semver2 = __commonJS({
2496
2496
  });
2497
2497
 
2498
2498
  // package.json
2499
- var version = "0.48.0-beta.4";
2499
+ var version = "0.48.0-beta.5";
2500
2500
 
2501
2501
  // node/common.ts
2502
2502
  import { existsSync, promises as fs } from "node:fs";
@@ -2728,23 +2728,13 @@ import * as parser from "@slidev/parser/fs";
2728
2728
  import equal from "fast-deep-equal";
2729
2729
  var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
2730
2730
  var regexIdQuery = /(\d+?)\.(md|json|frontmatter)$/;
2731
- var vueContextImports = [
2732
- `import { inject as _vueInject, provide as _vueProvide, toRef as _vueToRef } from "vue"`,
2733
- `import {
2734
- injectionSlidevContext as _injectionSlidevContext,
2735
- injectionClicksContext as _injectionClicksContext,
2736
- injectionCurrentPage as _injectionCurrentPage,
2737
- injectionRenderContext as _injectionRenderContext,
2738
- injectionFrontmatter as _injectionFrontmatter,
2739
- filterFrontmatter as _filterFrontmatter,
2740
- } from "@slidev/client/constants.ts"`.replace(/\n\s+/g, "\n"),
2741
- "const $slidev = _vueInject(_injectionSlidevContext)",
2742
- 'const $nav = _vueToRef($slidev, "nav")',
2743
- "const $clicksContext = _vueInject(_injectionClicksContext)?.value",
2744
- 'const $clicks = _vueToRef($clicksContext, "current")',
2745
- "const $page = _vueInject(_injectionCurrentPage)",
2746
- "const $renderContext = _vueInject(_injectionRenderContext)"
2747
- ];
2731
+ var templateInjectionMarker = "/* @slidev-injection */";
2732
+ var templateImportContextUtils = `import {
2733
+ useSlideContext,
2734
+ provideFrontmatter as _provideFrontmatter,
2735
+ frontmatterToProps as _frontmatterToProps,
2736
+ } from "@slidev/client/context.ts"`.replace(/\n\s*/g, " ");
2737
+ var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = useSlideContext()`;
2748
2738
  function getBodyJson(req) {
2749
2739
  return new Promise((resolve3, reject) => {
2750
2740
  let body = "";
@@ -3087,21 +3077,12 @@ Unknown layout "${bold(layoutName)}".${yellow(" Available layouts are:")}`) + Ob
3087
3077
  }
3088
3078
  delete frontmatter.title;
3089
3079
  const imports = [
3090
- ...vueContextImports,
3091
3080
  `import InjectedLayout from "${toAtFS(layouts[layoutName])}"`,
3092
3081
  `import frontmatter from "${toAtFS(`${slidePrefix + (pageNo + 1)}.frontmatter`)}"`,
3093
- "const $frontmatter = frontmatter",
3094
- "_vueProvide(_injectionFrontmatter, frontmatter)",
3095
- // update frontmatter in router
3096
- ";(() => {",
3097
- " const route = $slidev.nav.rawRoutes.find(i => i.path === String($page.value))",
3098
- " if (route?.meta?.slide?.frontmatter) {",
3099
- " Object.keys(route.meta.slide.frontmatter).forEach(key => {",
3100
- " if (!(key in $frontmatter)) delete route.meta.slide.frontmatter[key]",
3101
- " })",
3102
- " Object.assign(route.meta.slide.frontmatter, frontmatter)",
3103
- " }",
3104
- "})();"
3082
+ templateImportContextUtils,
3083
+ "_provideFrontmatter(frontmatter)",
3084
+ templateInitContext,
3085
+ templateInjectionMarker
3105
3086
  ];
3106
3087
  code = code.replace(/(<script setup.*>)/g, `$1
3107
3088
  ${imports.join("\n")}
@@ -3112,18 +3093,19 @@ ${imports.join("\n")}
3112
3093
  if (body.startsWith("<div>") && body.endsWith("</div>"))
3113
3094
  body = body.slice(5, -6);
3114
3095
  code = `${code.slice(0, injectA)}
3115
- <InjectedLayout v-bind="_filterFrontmatter(frontmatter,${pageNo})">
3096
+ <InjectedLayout v-bind="_frontmatterToProps(frontmatter,${pageNo})">
3116
3097
  ${body}
3117
3098
  </InjectedLayout>
3118
3099
  ${code.slice(injectB)}`;
3119
3100
  return code;
3120
3101
  }
3121
3102
  function transformVue(code) {
3122
- if (code.includes("injectionSlidevContext") || code.includes("injectionClicksContext") || code.includes("const $slidev"))
3103
+ if (code.includes(templateInjectionMarker) || code.includes("useSlideContext()"))
3123
3104
  return code;
3124
3105
  const imports = [
3125
- ...vueContextImports,
3126
- "const $frontmatter = _vueInject(_injectionFrontmatter)"
3106
+ templateImportContextUtils,
3107
+ templateInitContext,
3108
+ templateInjectionMarker
3127
3109
  ];
3128
3110
  const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
3129
3111
  if (matchScript && matchScript[2]) {
package/dist/cli.mjs CHANGED
@@ -5,10 +5,10 @@ import {
5
5
  resolveAddons,
6
6
  resolveOptions,
7
7
  resolveTheme
8
- } from "./chunk-YFMRSFTO.mjs";
8
+ } from "./chunk-CV7O37IO.mjs";
9
9
  import {
10
10
  version
11
- } from "./chunk-JNK5R5DL.mjs";
11
+ } from "./chunk-U44GKKNH.mjs";
12
12
  import {
13
13
  loadSetups
14
14
  } from "./chunk-O6TYYGU6.mjs";
@@ -271,7 +271,7 @@ cli.command(
271
271
  }).strict().help(),
272
272
  async (args) => {
273
273
  const { entry, theme, watch, base, download, out, inspect } = args;
274
- const { build } = await import("./build-LWZZ63IN.mjs");
274
+ const { build } = await import("./build-C6G7F24X.mjs");
275
275
  for (const entryFile of entry) {
276
276
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
277
277
  if (download && !options.data.config.download)
package/dist/index.mjs CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createServer,
3
3
  parser,
4
4
  resolveOptions
5
- } from "./chunk-YFMRSFTO.mjs";
5
+ } from "./chunk-CV7O37IO.mjs";
6
6
  import {
7
7
  ViteSlidevPlugin
8
- } from "./chunk-JNK5R5DL.mjs";
8
+ } from "./chunk-U44GKKNH.mjs";
9
9
  import "./chunk-O6TYYGU6.mjs";
10
10
  import "./chunk-7HOZGSL4.mjs";
11
11
  import "./chunk-BXO7ZPPU.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.48.0-beta.4",
3
+ "version": "0.48.0-beta.5",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -104,9 +104,9 @@
104
104
  "vitefu": "^0.2.5",
105
105
  "vue": "^3.4.19",
106
106
  "yargs": "^17.7.2",
107
- "@slidev/client": "0.48.0-beta.4",
108
- "@slidev/parser": "0.48.0-beta.4",
109
- "@slidev/types": "0.48.0-beta.4"
107
+ "@slidev/client": "0.48.0-beta.5",
108
+ "@slidev/parser": "0.48.0-beta.5",
109
+ "@slidev/types": "0.48.0-beta.5"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@hedgedoc/markdown-it-plugins": "^2.1.4",