@c4a/context-cli 0.7.60 → 0.7.61

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
@@ -87128,14 +87128,57 @@ function createDiagramViewer(load) {
87128
87128
  actorBkg: color3("surface", dark ? "#202735" : "#f5f8ff"),
87129
87129
  actorTextColor: color3("text", dark ? "#e2e4ed" : "#161e2e"),
87130
87130
  signalColor: color3("muted-text", dark ? "#9faec5" : "#66758d"),
87131
- signalTextColor: color3("text", dark ? "#e2e4ed" : "#161e2e")
87131
+ signalTextColor: color3("text", dark ? "#e2e4ed" : "#161e2e"),
87132
+ titleColor: color3("muted-text", dark ? "#9faec5" : "#66758d")
87132
87133
  },
87133
- flowchart: { useMaxWidth: false, nodeSpacing: 36, rankSpacing: 58, padding: 16, curve: "linear", wrappingWidth: 220, htmlLabels: false },
87134
+ themeCSS: ".edgeLabel rect{opacity:1}.edgeLabel text{font-size:13px}",
87135
+ flowchart: { useMaxWidth: false, nodeSpacing: 36, rankSpacing: 58, padding: 16, curve: "linear", wrappingWidth: 220, htmlLabels: false, subGraphTitleMargin: { top: 10, bottom: 6 } },
87134
87136
  sequence: { useMaxWidth: false, diagramMarginX: 24, diagramMarginY: 20, actorMargin: 48, messageMargin: 38, wrap: true },
87135
87137
  state: { useMaxWidth: false },
87136
87138
  er: { useMaxWidth: false }
87137
87139
  };
87138
87140
  }
87141
+ function centerEdgeLabels(svg) {
87142
+ if (svg.dataset.labelsCentered || !svg.getClientRects().length)
87143
+ return;
87144
+ svg.dataset.labelsCentered = "true";
87145
+ for (const label2 of svg.querySelectorAll(".edgeLabel > .label[data-id]")) {
87146
+ const box = label2.querySelector("rect.background");
87147
+ const text7 = label2.querySelector("text");
87148
+ const path2 = svg.querySelector(`path[data-id="${CSS.escape(label2.getAttribute("data-id"))}"]`);
87149
+ const toLabel = label2.getCTM();
87150
+ const toPath = path2?.getCTM();
87151
+ const glyphs = text7?.getBBox();
87152
+ if (!box || !path2 || !toLabel || !toPath || !glyphs?.width)
87153
+ continue;
87154
+ box.setAttribute("x", String(glyphs.x - 4));
87155
+ box.setAttribute("y", String(glyphs.y - 1));
87156
+ box.setAttribute("width", String(glyphs.width + 8));
87157
+ box.setAttribute("height", String(glyphs.height + 2));
87158
+ const center = new DOMPoint(box.x.baseVal.value + box.width.baseVal.value / 2, box.y.baseVal.value + box.height.baseVal.value / 2);
87159
+ const local = center.matrixTransform(toLabel).matrixTransform(toPath.inverse());
87160
+ const length = path2.getTotalLength();
87161
+ let best = 0;
87162
+ let distance = Infinity;
87163
+ const probe = (at2) => {
87164
+ const point3 = path2.getPointAtLength(at2);
87165
+ const d = (point3.x - local.x) ** 2 + (point3.y - local.y) ** 2;
87166
+ if (d < distance) {
87167
+ distance = d;
87168
+ best = at2;
87169
+ }
87170
+ };
87171
+ for (let step = 0;step <= 64; step++)
87172
+ probe(length * step / 64);
87173
+ for (let span = length / 64;span > 0.25; span /= 2) {
87174
+ const at2 = best;
87175
+ probe(Math.max(0, at2 - span));
87176
+ probe(Math.min(length, at2 + span));
87177
+ }
87178
+ const target = path2.getPointAtLength(best).matrixTransform(toPath).matrixTransform(toLabel.inverse());
87179
+ label2.setAttribute("transform", `${label2.getAttribute("transform") ?? ""} translate(${target.x - center.x} ${target.y - center.y})`);
87180
+ }
87181
+ }
87139
87182
  function prune() {
87140
87183
  for (const [node3, state] of states)
87141
87184
  if (!node3.isConnected) {
@@ -87214,6 +87257,7 @@ function createDiagramViewer(load) {
87214
87257
  const svg = canvas.querySelector("svg");
87215
87258
  if (!svg || !state.width)
87216
87259
  return;
87260
+ centerEdgeLabels(svg);
87217
87261
  if (state.fit)
87218
87262
  state.scale = Math.min(1, Math.max(0.1, (viewport.clientWidth - 32) / state.width));
87219
87263
  svg.style.width = `${state.width * state.scale}px`;
@@ -87373,6 +87417,7 @@ function createDiagramViewer(load) {
87373
87417
  const element = canvas.querySelector("svg");
87374
87418
  if (!element)
87375
87419
  throw new Error("Missing SVG");
87420
+ centerEdgeLabels(element);
87376
87421
  state.width = element.viewBox.baseVal.width || element.getBoundingClientRect().width || 640;
87377
87422
  element.setAttribute("role", "img");
87378
87423
  if (!element.hasAttribute("aria-label") && !element.hasAttribute("aria-labelledby"))
@@ -87437,10 +87482,10 @@ var init_diagramStyles = __esm(() => {
87437
87482
  .context-diagram-percent{font-size:11px;color:var(--diagram-muted);min-width:34px;text-align:center}
87438
87483
  .context-diagram-viewport{overflow:auto;max-height:620px;min-height:60px;overscroll-behavior:contain;cursor:grab}
87439
87484
  .context-diagram-viewport:active{cursor:grabbing}.context-diagram-canvas{padding:16px;width:max-content;min-width:100%;box-sizing:border-box}
87440
- .context-diagram-canvas svg{display:block;margin:auto;height:auto;max-width:none}.context-diagram-status{padding:12px 16px;font-size:13px;color:var(--diagram-muted)}
87485
+ .context-diagram-canvas svg{display:block;margin:auto;height:auto;max-width:none}.context-diagram-canvas foreignObject p{margin:0;line-height:inherit}.context-diagram-status{padding:12px 16px;font-size:13px;color:var(--diagram-muted)}
87441
87486
  .context-diagram-expanded{position:fixed!important;inset:16px!important;z-index:10000!important;margin:0!important;display:flex;flex-direction:column;box-shadow:0 0 0 100vmax #10182788}
87442
87487
  .context-diagram-expanded .context-diagram-viewport{flex:1;max-height:none}.context-diagram-expanded .context-diagram-tools{flex-shrink:0}
87443
- .vp-doc div.language-mermaid.context-rendered{background:transparent;border:0}
87488
+ .vp-doc div.language-mermaid.context-rendered,div.language-mermaid.context-rendered{background:transparent;border:0;border-radius:0;padding:0;box-shadow:none}
87444
87489
  .context-rendered>pre,.context-rendered>.copy,.context-rendered>.lang{display:none!important}.context-diagram-shell [hidden]{display:none!important}
87445
87490
  .context-diagram-left,.context-diagram-right{display:flex;align-items:center;flex-wrap:wrap;gap:6px}.context-diagram-right{margin-left:auto}
87446
87491
  .context-diagram-tools{opacity:0;pointer-events:none;transition:opacity .15s}.context-diagram-shell:hover .context-diagram-tools,.context-diagram-shell:focus-within .context-diagram-tools{opacity:1;pointer-events:auto}
@@ -87809,6 +87854,12 @@ export default {
87809
87854
  extensions.knowledge === undefined ? siteMap() : extensions.knowledge && custom('knowledge'),
87810
87855
  extensions.resources === undefined ? resources() : extensions.resources && custom('resources')],
87811
87856
  'home-features-after': () => extensions.footer === undefined ? poweredBy() : extensions.footer && custom('footer'),
87857
+ 'not-found': () => h('div', { class: 'context-not-found' }, [
87858
+ h('p', { class: 'context-not-found-code' }, '404'),
87859
+ h('h1', both('页面不存在', 'Page not found')),
87860
+ h('p', both('链接可能已失效,或页面已被移动。', 'The link may be broken, or the page has moved.')),
87861
+ h('a', { class: 'context-not-found-home', href: data.site.value.base }, both('返回首页', 'Back to home')),
87862
+ ]),
87812
87863
  'doc-after': () => history.value ? h('section', { class: 'context-history-cards' },
87813
87864
  history.value.length ? history.value.map((entry, index) =>
87814
87865
  h('details', { class: 'context-history-card', open: index < 3, key: entry.version }, [
@@ -87859,7 +87910,7 @@ export default {
87859
87910
  },
87860
87911
  };
87861
87912
  // History belongs between the page heading and footer metadata.
87862
- return () => h(DefaultTheme.Layout, { class: inHome.value ? 'context-home' :
87913
+ return () => h(DefaultTheme.Layout, { class: inHome.value ? 'context-home' : data.page.value.isNotFound ? 'context-missing' :
87863
87914
  inLlms.value || inHistory.value ? 'context-empty-sidebar' : undefined }, { ...slots, 'doc-after': undefined,
87864
87915
  'doc-footer-before': () => [slots['doc-after'](), slots['doc-footer-before']()] });
87865
87916
  }
@@ -88066,13 +88117,20 @@ ${readerContentStyles(".vp-doc")}
88066
88117
  .context-home-powered { width: var(--context-content); margin: 24px auto 0; padding: 22px 0 30px; border-top: 1px solid var(--vp-c-divider);
88067
88118
  color: var(--vp-c-text-2); font-size: 11px; text-align: right; }
88068
88119
  .context-home-powered a { color: inherit; }
88120
+ /* 404: centred in the space below the top bar, in the reader language */
88121
+ .context-not-found { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - var(--vp-nav-height)); padding: 48px 24px 96px; text-align: center; }
88122
+ .context-not-found-code { margin: 0; font: 600 72px/1 var(--vp-font-family-mono); letter-spacing: -.04em; color: var(--vp-c-text-1); }
88123
+ .context-not-found h1 { margin: 20px 0 0; font-size: 20px; font-weight: 600; line-height: 1.4; color: var(--vp-c-text-1); }
88124
+ .context-not-found h1 + p { max-width: 28rem; margin: 8px 0 0; font-size: 14px; line-height: 1.7; color: var(--vp-c-text-2); }
88125
+ .context-not-found-home { margin-top: 28px; padding: 0 18px; border: 1px solid var(--vp-c-divider); border-radius: 999px; font-size: 14px; font-weight: 500; line-height: 38px; color: var(--vp-c-text-1) !important; text-decoration: none !important; transition: border-color .2s; }
88126
+ .context-not-found-home:hover { border-color: var(--vp-c-text-3); }
88069
88127
  @keyframes context-home-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
88070
88128
  @media (min-width: 960px) {
88071
88129
  /* The sidebar background reaches the screen edge; its first-level labels line up with the top-bar title. */
88072
88130
  .VPSidebar { top: var(--vp-nav-height) !important; left: 0 !important; width: calc(var(--vp-sidebar-width) + var(--context-edge) - 26px) !important;
88073
88131
  padding: 12px 0 48px calc(var(--context-edge) - 26px) !important; }
88074
88132
  .VPSidebar .curtain { display: none; }
88075
- .VPContent.has-sidebar, .Layout:not(.context-home) .VPContent:not(.is-home) { padding-left: calc(var(--vp-sidebar-width) + var(--context-edge) - 26px) !important;
88133
+ .VPContent.has-sidebar, .Layout:not(.context-home):not(.context-missing) .VPContent:not(.is-home) { padding-left: calc(var(--vp-sidebar-width) + var(--context-edge) - 26px) !important;
88076
88134
  padding-right: calc(var(--context-edge) - var(--context-gutter)) !important; }
88077
88135
  .context-home .VPContent { padding-left: 0 !important; padding-right: 0 !important; }
88078
88136
  .VPDoc { padding: 44px 36px 80px !important; }
@@ -89867,6 +89925,22 @@ ${tail}`));
89867
89925
  });
89868
89926
  });
89869
89927
  }
89928
+ function siteHomeHero(options, input) {
89929
+ const chinese = input.tag.toLowerCase().startsWith("zh");
89930
+ const locale = input.tag === input.primary ? undefined : options.locales?.[input.tag];
89931
+ const own5 = locale?.home;
89932
+ const featured = (own5?.resources ?? options.home?.resources ?? []).filter((resource) => resource.featured && resource.href);
89933
+ return {
89934
+ name: own5?.title ?? locale?.title ?? options.home?.title ?? options.title ?? input.packageName,
89935
+ text: own5?.slogan ?? options.home?.slogan ?? (chinese ? "从知识地图开始探索" : "Explore from the knowledge map"),
89936
+ tagline: own5?.description ?? locale?.description ?? options.home?.description ?? options.description ?? "",
89937
+ actions: own5?.actions ?? options.home?.actions ?? [
89938
+ { theme: "brand", text: chinese ? "浏览知识" : "Browse knowledge", link: input.firstSection },
89939
+ ...featured.map((resource) => ({ theme: "alt", text: resource.title, link: resource.href })),
89940
+ { theme: "alt", text: "LLM Docs", link: "/llms/index.html" }
89941
+ ]
89942
+ };
89943
+ }
89870
89944
  async function writePackageSite(input) {
89871
89945
  if (input.pkg.kind !== "package.kb" || !input.pkg.site)
89872
89946
  return;
@@ -90022,7 +90096,8 @@ ${localized.body}`);
90022
90096
  }
90023
90097
  };
90024
90098
  await writeFile23(join75(configRoot, "config.mjs"), `const contextLocaleMarker = ${JSON.stringify(readers.translated ? marker : null)};
90025
- ` + `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} } };
90099
+ ` + `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} },
90100
+ ` + ` transformHtml: html => html.replace(/<script id="check-dark-mode">[\\s\\S]*?<\\/script>/u, "") };
90026
90101
  `);
90027
90102
  const menu = (lines, entries2, level, tag) => entries2.forEach((entry) => {
90028
90103
  const title = mdLabel(localizer.entryTitle(tag, entry));
@@ -90040,24 +90115,8 @@ ${localized.body}`);
90040
90115
  }));
90041
90116
  }
90042
90117
  const firstSection = sections[0]?.href ?? "/llms/index.html";
90043
- const heroFor = (tag) => {
90044
- const chinese = tag.toLowerCase().startsWith("zh");
90045
- const locale = tag === readers.primary ? undefined : options.locales?.[tag];
90046
- const home = locale ? locale.home : options.home;
90047
- const featured = (home?.resources ?? options.home?.resources ?? []).filter((resource) => resource.featured && resource.href);
90048
- return {
90049
- name: (locale ? locale.home?.title ?? locale.title : options.home?.title) ?? options.title ?? pkg.name,
90050
- text: home?.slogan ?? (chinese ? "从知识地图开始探索" : "Explore from the knowledge map"),
90051
- tagline: (locale ? locale.home?.description ?? locale.description : options.home?.description ?? options.description) ?? "",
90052
- actions: home?.actions ?? [
90053
- { theme: "brand", text: chinese ? "浏览知识" : "Browse knowledge", link: firstSection },
90054
- ...featured.map((resource) => ({ theme: "alt", text: resource.title, link: resource.href })),
90055
- { theme: "alt", text: "LLM Docs", link: "/llms/index.html" }
90056
- ]
90057
- };
90058
- };
90059
90118
  const heroTags = readers.translated ? readers.tags : [readers.primary];
90060
- const heroes = new Map(heroTags.map((tag) => [tag, heroFor(tag)]));
90119
+ const heroes = new Map(heroTags.map((tag) => [tag, siteHomeHero(options, { tag, primary: readers.primary, packageName: pkg.name, firstSection })]));
90061
90120
  const hero = {
90062
90121
  name: localizedHtml(heroTags, (tag) => heroes.get(tag).name),
90063
90122
  text: localizedHtml(heroTags, (tag) => heroes.get(tag).text),
@@ -90176,7 +90235,7 @@ var init_packageSite2 = __esm(() => {
90176
90235
  init_packageSiteExtensions();
90177
90236
  init_packageDistributionMetadata();
90178
90237
  init_packageSiteLocales();
90179
- PACKAGE_SITE_VERSION = `vitepress-site-v48-reader-locales:${createHash22("sha256").update(JSON.stringify([siteThemeVariables.toString(), siteMarkdownConfig, siteThemeCss, siteThemeScript, siteThemeLabels("zh"), siteThemeLabels("en")])).digest("hex")}`;
90238
+ PACKAGE_SITE_VERSION = `vitepress-site-v49-appearance-home-fallback:${createHash22("sha256").update(JSON.stringify([siteThemeVariables.toString(), siteMarkdownConfig, siteThemeCss, siteThemeScript, siteThemeLabels("zh"), siteThemeLabels("en")])).digest("hex")}`;
90180
90239
  require2 = createRequire6(import.meta.url);
90181
90240
  });
90182
90241