@runcontext/site 0.4.2 → 0.4.4

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.
Files changed (41) hide show
  1. package/astro/astro.config.mjs +13 -0
  2. package/astro/node_modules/.astro/data-store.json +1 -0
  3. package/astro/node_modules/.vite/deps/_metadata.json +31 -0
  4. package/astro/node_modules/.vite/deps/astro___aria-query.js +6776 -0
  5. package/astro/node_modules/.vite/deps/astro___aria-query.js.map +7 -0
  6. package/astro/node_modules/.vite/deps/astro___axobject-query.js +3754 -0
  7. package/astro/node_modules/.vite/deps/astro___axobject-query.js.map +7 -0
  8. package/astro/node_modules/.vite/deps/astro___cssesc.js +99 -0
  9. package/astro/node_modules/.vite/deps/astro___cssesc.js.map +7 -0
  10. package/astro/node_modules/.vite/deps/chunk-BUSYA2B4.js +8 -0
  11. package/astro/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +7 -0
  12. package/astro/node_modules/.vite/deps/package.json +3 -0
  13. package/astro/src/components/Sidebar.astro +71 -0
  14. package/astro/src/components/TierBadge.astro +9 -0
  15. package/astro/src/components/Topbar.astro +42 -0
  16. package/astro/src/data/manifest.json +10839 -0
  17. package/astro/src/data/site-config.json +1 -0
  18. package/astro/src/layouts/Base.astro +461 -0
  19. package/astro/src/pages/glossary.astro +37 -0
  20. package/astro/src/pages/index.astro +98 -0
  21. package/astro/src/pages/models/[name]/rules.astro +87 -0
  22. package/astro/src/pages/models/[name]/schema.astro +82 -0
  23. package/astro/src/pages/models/[name].astro +181 -0
  24. package/astro/src/pages/owners/[id].astro +65 -0
  25. package/astro/src/pages/search.astro +108 -0
  26. package/astro/tsconfig.json +3 -0
  27. package/dist/build-index-MSTAYUC3.cjs +7 -0
  28. package/dist/build-index-MSTAYUC3.cjs.map +1 -0
  29. package/dist/build-index-UCDMZJZP.mjs +7 -0
  30. package/dist/build-index-UCDMZJZP.mjs.map +1 -0
  31. package/dist/chunk-BBC5HGNQ.cjs +65 -0
  32. package/dist/chunk-BBC5HGNQ.cjs.map +1 -0
  33. package/dist/chunk-WM73L4RO.mjs +65 -0
  34. package/dist/chunk-WM73L4RO.mjs.map +1 -0
  35. package/dist/index.cjs +84 -69
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +20 -8
  38. package/dist/index.d.ts +20 -8
  39. package/dist/index.mjs +81 -66
  40. package/dist/index.mjs.map +1 -1
  41. package/package.json +6 -4
package/dist/index.mjs CHANGED
@@ -1,7 +1,12 @@
1
+ import {
2
+ buildSearchIndex
3
+ } from "./chunk-WM73L4RO.mjs";
4
+
1
5
  // src/generator.ts
2
6
  import ejs from "ejs";
3
7
  import * as fs from "fs";
4
8
  import * as path from "path";
9
+ import { fileURLToPath } from "url";
5
10
 
6
11
  // src/templates/shared.ts
7
12
  var HEAD = `<!DOCTYPE html>
@@ -709,6 +714,8 @@ var HEAD = `<!DOCTYPE html>
709
714
  @keyframes toast-in { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
710
715
  .studio-add-btn { background: none; border: 1px dashed #c9a55a60; color: #c9a55a; border-radius: 8px; padding: 12px; width: 100%; cursor: pointer; font-size: 14px; transition: all 0.2s; }
711
716
  .studio-add-btn:hover { border-color: #c9a55a; background: #c9a55a10; }
717
+ .rename-btn { background: none; border: 1px solid var(--accent-border, #c9a55a40); color: var(--accent, #c9a55a); border-radius: 5px; padding: 0.2rem 0.6rem; font-size: 0.72rem; cursor: pointer; opacity: 0.7; transition: opacity 0.2s, background 0.2s; font-family: var(--sans, sans-serif); }
718
+ .rename-btn:hover { opacity: 1; background: var(--accent-dim, #c9a55a12); }
712
719
  </style>
713
720
  <% } %>
714
721
  </head>`;
@@ -725,7 +732,7 @@ var TOPBAR = `<div class="topbar">
725
732
  </div>
726
733
  <div class="topbar-right">
727
734
  <a href="<%= basePath %>/search.html" class="topbar-link">Search</a>
728
- <a href="https://contextkit.dev" class="topbar-docs" target="_blank" rel="noopener">Docs &nearr;</a>
735
+ <a href="https://github.com/erickittelson/ContextKit#readme" class="topbar-docs" target="_blank" rel="noopener">Docs &nearr;</a>
729
736
  </div>
730
737
  </div>`;
731
738
  var SIDEBAR = `<div class="overlay" id="sidebar-overlay" onclick="toggleSidebar()"></div>
@@ -759,7 +766,7 @@ var SIDEBAR = `<div class="overlay" id="sidebar-overlay" onclick="toggleSidebar(
759
766
  var FOOTER = `<footer class="site-footer">
760
767
  Generated by <a href="https://github.com/erickittelson/ContextKit">ContextKit</a>
761
768
  &nbsp;&middot;&nbsp;
762
- <a href="https://contextkit.dev" target="_blank" rel="noopener">Documentation</a>
769
+ <a href="https://github.com/erickittelson/ContextKit#readme" target="_blank" rel="noopener">Documentation</a>
763
770
  </footer>`;
764
771
  var TIER_BADGE = `<% function tierBadge(tier) {
765
772
  var cls = { none: '', bronze: 'tag-bronze', silver: 'tag-silver', gold: 'tag-gold' };
@@ -883,7 +890,11 @@ async function previewAndSave() {
883
890
  body: JSON.stringify({ file: fileEdits[0].file, path: fileEdits[0].path, value: fileEdits[0].value }),
884
891
  });
885
892
  const data = await res.json();
886
- previews.push({ file, edits: fileEdits, ...data });
893
+ if (data.error) {
894
+ previews.push({ file, edits: fileEdits, error: data.error });
895
+ } else {
896
+ previews.push({ file, edits: fileEdits, ...data });
897
+ }
887
898
  } catch (err) {
888
899
  previews.push({ file, edits: fileEdits, error: err.message });
889
900
  }
@@ -1024,6 +1035,27 @@ function makeDropdown(el) {
1024
1035
  });
1025
1036
  }
1026
1037
 
1038
+ async function renameModel(currentName) {
1039
+ var newName = prompt('Rename model "' + currentName + '" to:', currentName);
1040
+ if (!newName || newName.trim() === currentName) return;
1041
+ try {
1042
+ var res = await fetch('/api/rename-model', {
1043
+ method: 'POST',
1044
+ headers: { 'Content-Type': 'application/json' },
1045
+ body: JSON.stringify({ oldName: currentName, newName: newName.trim() }),
1046
+ });
1047
+ var data = await res.json();
1048
+ if (data.ok) {
1049
+ showToast('Renamed to "' + data.newName + '" \u2014 ' + data.renamed.length + ' file(s) updated');
1050
+ setTimeout(function() { window.location.href = '/models/' + data.newName + '.html'; }, 800);
1051
+ } else {
1052
+ showToast('Rename failed');
1053
+ }
1054
+ } catch (err) {
1055
+ showToast('Rename failed: ' + err.message);
1056
+ }
1057
+ }
1058
+
1027
1059
  document.addEventListener('DOMContentLoaded', function() {
1028
1060
  document.querySelectorAll('.editable').forEach(makeEditable);
1029
1061
  document.querySelectorAll('.dropdown-editable').forEach(makeDropdown);
@@ -1165,8 +1197,11 @@ ${TIER_BADGE}
1165
1197
 
1166
1198
  <div class="page-header">
1167
1199
  <div style="display:flex;align-items:center;gap:0.6rem;">
1168
- <h1><%= model.name %></h1>
1200
+ <h1 id="model-name"><%= model.name %></h1>
1169
1201
  <% if (tier) { %><%- tierBadge(tier.tier) %><% } %>
1202
+ <% if (typeof studioMode !== 'undefined' && studioMode) { %>
1203
+ <button class="rename-btn" onclick="renameModel('<%= model.name %>')" title="Rename this model">&#9998; Rename</button>
1204
+ <% } %>
1170
1205
  </div>
1171
1206
  <% if (typeof studioMode !== 'undefined' && studioMode) { %>
1172
1207
  <p class="subtitle"><span class="editable" data-file="context/models/<%= model.name %>.osi.yaml" data-path="semantic_model.0.description" data-label="Model description"><%= model.description || 'Add description...' %></span></p>
@@ -2275,72 +2310,11 @@ ${SCRIPTS}
2275
2310
  </body>
2276
2311
  </html>`;
2277
2312
 
2278
- // src/search/build-index.ts
2279
- import MiniSearch from "minisearch";
2280
- var MINISEARCH_OPTIONS = {
2281
- fields: ["title", "description", "type"],
2282
- storeFields: ["title", "description", "type", "url"],
2283
- idField: "id"
2284
- };
2285
- function buildSearchIndex(manifest, basePath) {
2286
- const docs = [];
2287
- let idCounter = 0;
2288
- for (const [name, model] of Object.entries(manifest.models)) {
2289
- docs.push({
2290
- id: String(idCounter++),
2291
- type: "model",
2292
- title: name,
2293
- description: model.description ?? "",
2294
- url: `${basePath}/models/${name}.html`
2295
- });
2296
- if (model.datasets) {
2297
- for (const ds of model.datasets) {
2298
- docs.push({
2299
- id: String(idCounter++),
2300
- type: "dataset",
2301
- title: `${name} / ${ds.name}`,
2302
- description: ds.description ?? "",
2303
- url: `${basePath}/models/${name}/schema.html`
2304
- });
2305
- }
2306
- }
2307
- }
2308
- for (const [termId, term] of Object.entries(manifest.terms)) {
2309
- docs.push({
2310
- id: String(idCounter++),
2311
- type: "term",
2312
- title: termId,
2313
- description: term.definition,
2314
- url: `${basePath}/glossary.html#term-${termId}`
2315
- });
2316
- }
2317
- for (const [oid, owner] of Object.entries(manifest.owners)) {
2318
- docs.push({
2319
- id: String(idCounter++),
2320
- type: "owner",
2321
- title: owner.display_name,
2322
- description: owner.description ?? "",
2323
- url: `${basePath}/owners/${oid}.html`
2324
- });
2325
- }
2326
- const miniSearch = new MiniSearch(MINISEARCH_OPTIONS);
2327
- miniSearch.addAll(docs);
2328
- const documentsMap = {};
2329
- for (const doc of docs) {
2330
- documentsMap[doc.id] = doc;
2331
- }
2332
- return {
2333
- index: JSON.parse(JSON.stringify(miniSearch)),
2334
- options: MINISEARCH_OPTIONS,
2335
- documents: documentsMap
2336
- };
2337
- }
2338
-
2339
2313
  // src/generator.ts
2340
2314
  function generateSite(manifest, config, options) {
2341
2315
  const files = /* @__PURE__ */ new Map();
2342
2316
  const siteTitle = config?.title ?? "ContextKit";
2343
- const basePath = (config?.base_path ?? "").replace(/\/+$/, "") || ".";
2317
+ const basePath = (config?.base_path ?? "").replace(/\/+$/, "");
2344
2318
  const studioMode = options?.studioMode ?? false;
2345
2319
  const commonData = {
2346
2320
  siteTitle,
@@ -2449,10 +2423,51 @@ async function buildSite(manifest, config, outputDir) {
2449
2423
  fs.writeFileSync(fullPath, content, "utf-8");
2450
2424
  }
2451
2425
  }
2426
+ function getAstroProjectDir() {
2427
+ const thisFile = fileURLToPath(import.meta.url);
2428
+ const thisDir = path.dirname(thisFile);
2429
+ const astroDir = path.resolve(thisDir, "..", "astro");
2430
+ if (fs.existsSync(astroDir)) return astroDir;
2431
+ const pkgRoot = path.resolve(thisDir, "..", "..");
2432
+ return path.join(pkgRoot, "astro");
2433
+ }
2434
+ async function buildAstroSite(manifest, config, outputDir) {
2435
+ const astroDir = getAstroProjectDir();
2436
+ const dataDir = path.join(astroDir, "src", "data");
2437
+ fs.mkdirSync(dataDir, { recursive: true });
2438
+ fs.writeFileSync(
2439
+ path.join(dataDir, "manifest.json"),
2440
+ JSON.stringify(manifest, null, 2),
2441
+ "utf-8"
2442
+ );
2443
+ fs.writeFileSync(
2444
+ path.join(dataDir, "site-config.json"),
2445
+ JSON.stringify({
2446
+ title: config.site?.title ?? "ContextKit",
2447
+ studioMode: false
2448
+ }),
2449
+ "utf-8"
2450
+ );
2451
+ const { buildSearchIndex: buildSearchIndex2 } = await import("./build-index-UCDMZJZP.mjs");
2452
+ const searchIndex = buildSearchIndex2(manifest, "");
2453
+ fs.writeFileSync(
2454
+ path.join(astroDir, "public", "search-index.json"),
2455
+ JSON.stringify(searchIndex, null, 2),
2456
+ "utf-8"
2457
+ );
2458
+ const { execFileSync } = await import("child_process");
2459
+ const npx = process.platform === "win32" ? "npx.cmd" : "npx";
2460
+ execFileSync(npx, ["astro", "build", "--outDir", path.resolve(outputDir)], {
2461
+ cwd: astroDir,
2462
+ stdio: "inherit"
2463
+ });
2464
+ }
2452
2465
  export {
2466
+ buildAstroSite,
2453
2467
  buildSearchIndex,
2454
2468
  buildSite,
2455
2469
  generateSite,
2470
+ getAstroProjectDir,
2456
2471
  glossaryTemplate,
2457
2472
  indexTemplate,
2458
2473
  modelTemplate,