@c4a/context-cli 0.7.65 → 0.7.66

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.
package/cli.js CHANGED
@@ -87709,7 +87709,7 @@ import DefaultTheme from 'vitepress/theme-without-fonts';
87709
87709
  import { useData, useRoute, dataSymbol, onContentUpdated, getScrollOffset } from 'vitepress';
87710
87710
  import { onMounted, onUnmounted, nextTick, watch, computed, ref, provide, h } from 'vue';
87711
87711
  import './style.css';
87712
- import extensions from './extensions.js';
87712
+ import extensions, { preloadExtensions } from './extensions.js';
87713
87713
  export default {
87714
87714
  extends: DefaultTheme,
87715
87715
  Layout: {
@@ -87896,7 +87896,10 @@ export default {
87896
87896
  // components that read isDark are mounted again for readers starting dark.
87897
87897
  const startedDark = ref(false);
87898
87898
  const custom = name => extensions[name]({ key: startedDark.value ? 'client' : 'prerender' });
87899
- onMounted(() => { mounted.value = true; startedDark.value = data.isDark.value; });
87899
+ onMounted(() => {
87900
+ mounted.value = true;
87901
+ if (data.isDark.value) preloadExtensions().catch(() => {}).then(() => { startedDark.value = true; });
87902
+ });
87900
87903
  const updatedLabel = computed(() => {
87901
87904
  const value = data.frontmatter.value.contextUpdated || data.theme.value.contextUpdated;
87902
87905
  if (!value) return '';
@@ -88430,6 +88433,7 @@ async function writeSiteExtensions(projectRoot, temporary, extensions) {
88430
88433
  }
88431
88434
  const imports = ["import { h, defineAsyncComponent, resolveComponent } from 'vue';"];
88432
88435
  const slots = [];
88436
+ const remounted = [];
88433
88437
  for (const [name3, path2] of Object.entries(extensions?.slots ?? {})) {
88434
88438
  if (path2 === undefined)
88435
88439
  continue;
@@ -88438,11 +88442,15 @@ async function writeSiteExtensions(projectRoot, temporary, extensions) {
88438
88442
  continue;
88439
88443
  }
88440
88444
  imports.push(`const ${name3} = defineAsyncComponent(() => import(${JSON.stringify(`../../_site/${path2}`)}));`);
88445
+ if (name3 !== "floating")
88446
+ remounted.push(name3);
88441
88447
  slots.push(`${JSON.stringify(name3)}: ${name3 === "floating" ? `() => h(resolveComponent('ClientOnly'), null, { default: () => h(${name3}) })` : `props => h(${name3}, props)`}`);
88442
88448
  }
88449
+ const preload = `export const preloadExtensions = () => Promise.all([${remounted.map((name3) => `${name3}.__asyncLoader()`).join(",")}]);`;
88443
88450
  await writeFile20(join70(temporary, ".vitepress/theme/extensions.js"), imports.join(`
88444
88451
  `) + `
88445
88452
  export default {${slots.join(",")}};
88453
+ ${preload}
88446
88454
  `);
88447
88455
  for (const [key, path2] of Object.entries(extensions?.pages ?? {})) {
88448
88456
  await mkdir25(join70(temporary, "custom"), { recursive: true });