qarpeo 0.1.5 → 0.1.7

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/dist/module.mjs CHANGED
@@ -19,7 +19,7 @@ import 'drizzle-orm/node-sqlite';
19
19
  import 'node:process';
20
20
  import 'node:readline/promises';
21
21
 
22
- const version = "0.1.5";
22
+ const version = "0.1.7";
23
23
 
24
24
  function ensureDevEnv(rootDir) {
25
25
  const envPath = join(rootDir, ".env");
@@ -261,7 +261,7 @@ async function discoverSources(contentDir) {
261
261
  return results;
262
262
  }
263
263
  async function resolveAllCmsSources(options) {
264
- const { contentDir, rootDir, cacheDir, configSources = [] } = options;
264
+ const { contentDir, rootDir, cacheDir, configSources = [], cacheOnly = false } = options;
265
265
  const discovered = await discoverSources(contentDir);
266
266
  const resolvedList = [];
267
267
  for (const item of discovered) {
@@ -282,17 +282,19 @@ async function resolveAllCmsSources(options) {
282
282
  if (cached.length > 0) {
283
283
  resolvedDir = targetDir;
284
284
  } else {
285
- rmSync(targetDir, { recursive: true, force: true });
285
+ if (!cacheOnly) rmSync(targetDir, { recursive: true, force: true });
286
286
  }
287
287
  }
288
- if (!resolvedDir) {
288
+ if (!resolvedDir && !cacheOnly) {
289
289
  await downloadTemplate(src.from, { dir: targetDir, auth: _auth });
290
290
  resolvedDir = targetDir;
291
291
  }
292
292
  } catch (err) {
293
- console.warn(
294
- `[qarpeo:cms] Failed to download remote source "${src.from}": ${err?.message ?? String(err)}`
295
- );
293
+ if (!cacheOnly) {
294
+ console.warn(
295
+ `[qarpeo:cms] Failed to download remote source "${src.from}": ${err?.message ?? String(err)}`
296
+ );
297
+ }
296
298
  if (existsSync(targetDir)) resolvedDir = targetDir;
297
299
  }
298
300
  } else {
@@ -330,17 +332,19 @@ async function resolveAllCmsSources(options) {
330
332
  if (cached.length > 0) {
331
333
  resolvedDir = targetDir;
332
334
  } else {
333
- rmSync(targetDir, { recursive: true, force: true });
335
+ if (!cacheOnly) rmSync(targetDir, { recursive: true, force: true });
334
336
  }
335
337
  }
336
- if (!resolvedDir) {
338
+ if (!resolvedDir && !cacheOnly) {
337
339
  await downloadTemplate(src.from, { dir: targetDir, auth: _auth2 });
338
340
  resolvedDir = targetDir;
339
341
  }
340
342
  } catch (err) {
341
- console.warn(
342
- `[qarpeo:cms] Failed to download remote source "${src.from}": ${err?.message ?? String(err)}`
343
- );
343
+ if (!cacheOnly) {
344
+ console.warn(
345
+ `[qarpeo:cms] Failed to download remote source "${src.from}": ${err?.message ?? String(err)}`
346
+ );
347
+ }
344
348
  if (existsSync(targetDir)) resolvedDir = targetDir;
345
349
  }
346
350
  } else {
@@ -427,9 +431,19 @@ async function readNavJson(dir) {
427
431
  return {};
428
432
  }
429
433
  async function scanContentEntries(options) {
430
- const { contentDir, collectionsConfig = {}, sources = [], exclude } = options;
434
+ const { contentDir, collectionsConfig = {}, sources = [], exclude, shiki } = options;
431
435
  const entries = [];
432
436
  const now = Date.now();
437
+ let shikiPluginInstance = null;
438
+ if (shiki !== false) {
439
+ try {
440
+ const shikiMod = await import('comark/plugins/shiki');
441
+ const shikiPlugin = shikiMod.default || shikiMod;
442
+ const shikiOptions = typeof shiki === "object" ? shiki : {};
443
+ shikiPluginInstance = shikiPlugin(shikiOptions);
444
+ } catch {
445
+ }
446
+ }
433
447
  async function syncSource(source) {
434
448
  if (!source?.resolvedDir || !existsSync(source.resolvedDir)) return;
435
449
  let orderCounter = 0;
@@ -515,7 +529,8 @@ async function scanContentEntries(options) {
515
529
  let ast = { nodes: [], frontmatter: {}, meta: {} };
516
530
  let contentHtml = "";
517
531
  try {
518
- ast = await parseMarkdown(body);
532
+ const plugins = shikiPluginInstance ? [shikiPluginInstance] : [];
533
+ ast = await parseMarkdown(body, { plugins });
519
534
  contentHtml = (await render(ast, { format: "text/html" })).trim();
520
535
  } catch {
521
536
  contentHtml = body;
@@ -3306,7 +3321,8 @@ export default queueHandler;
3306
3321
  contentDir: resolvedContentDir,
3307
3322
  rootDir: nuxt.options.rootDir,
3308
3323
  cacheDir,
3309
- configSources: cmsConfig.sources
3324
+ configSources: cmsConfig.sources,
3325
+ cacheOnly: true
3310
3326
  });
3311
3327
  } catch (err) {
3312
3328
  console.warn("[qarpeo:cms] Error resolving CMS sources:", err);
@@ -3370,16 +3386,36 @@ export default queueHandler;
3370
3386
  ])
3371
3387
  )
3372
3388
  };
3389
+ nuxt.hook("build:before", async () => {
3390
+ try {
3391
+ const freshSources = await resolveAllCmsSources({
3392
+ contentDir: resolvedContentDir,
3393
+ rootDir: nuxt.options.rootDir,
3394
+ cacheDir,
3395
+ configSources: cmsConfig.sources
3396
+ });
3397
+ resolvedSources.length = 0;
3398
+ resolvedSources.push(...freshSources);
3399
+ if (nuxt.options.runtimeConfig.qarpeo?.cms) {
3400
+ ;
3401
+ nuxt.options.runtimeConfig.qarpeo.cms.sources = freshSources;
3402
+ }
3403
+ } catch (err) {
3404
+ console.warn("[qarpeo:cms] Error resolving CMS sources in build:before:", err);
3405
+ }
3406
+ });
3373
3407
  const cmsManifestTemplate = addTemplate({
3374
3408
  filename: "qarpeo/cms-manifest.mjs",
3375
3409
  write: true,
3376
3410
  async getContents() {
3377
3411
  try {
3412
+ const shikiOpt = cmsConfig.shiki !== void 0 ? cmsConfig.shiki : cmsConfig.plugins?.shiki;
3378
3413
  const entries = await scanContentEntries({
3379
3414
  contentDir: resolvedContentDir,
3380
3415
  collectionsConfig: cmsConfig.collections,
3381
3416
  sources: resolvedSources,
3382
- exclude: cmsConfig.exclude
3417
+ exclude: cmsConfig.exclude,
3418
+ shiki: shikiOpt !== false ? typeof shikiOpt === "object" ? shikiOpt : true : false
3383
3419
  });
3384
3420
  const payload = JSON.stringify({
3385
3421
  entries,
@@ -3407,11 +3443,13 @@ export const manifestCollections = ${JSON.stringify(cmsConfig.collections || {})
3407
3443
  const prerenderPatterns = Object.entries(routeRules).filter(([_, rule]) => rule?.prerender === true).map(([pattern]) => pattern);
3408
3444
  if (prerenderPatterns.length > 0) {
3409
3445
  try {
3446
+ const shikiOpt = cmsConfig.shiki !== void 0 ? cmsConfig.shiki : cmsConfig.plugins?.shiki;
3410
3447
  const entries = await scanContentEntries({
3411
3448
  contentDir: resolvedContentDir,
3412
3449
  collectionsConfig: cmsConfig.collections,
3413
3450
  sources: resolvedSources,
3414
- exclude: cmsConfig.exclude
3451
+ exclude: cmsConfig.exclude,
3452
+ shiki: shikiOpt !== false ? typeof shikiOpt === "object" ? shikiOpt : true : false
3415
3453
  });
3416
3454
  const matchingRoutes = entries.map((e) => e.path).filter((p) => Boolean(p) && matchPathPatterns(p, prerenderPatterns));
3417
3455
  if (matchingRoutes.length > 0) {
@@ -12,12 +12,14 @@ const props = withDefaults(
12
12
  size?: "xs" | "sm" | "md"
13
13
  color?: "primary" | "neutral" | "secondary"
14
14
  class?: string
15
+ repo?: string
15
16
  }>(),
16
17
  {
17
18
  variant: "dropdown",
18
19
  size: "xs",
19
20
  color: "primary",
20
21
  class: "",
22
+ repo: "qarpeo/qarpeo",
21
23
  },
22
24
  )
23
25
 
@@ -29,6 +31,15 @@ const currentLabel = computed(() => {
29
31
  return currentVersion.value === "latest" ? "latest" : currentVersion.value
30
32
  })
31
33
 
34
+ const releaseNotesUrl = computed(() => {
35
+ const raw = currentVersion.value === "latest" ? currentLabel.value : currentVersion.value
36
+ const clean = (raw || "").replace(/^v/, "").trim()
37
+ if (clean && /^\d+\.\d+/.test(clean)) {
38
+ return `https://github.com/${props.repo}/releases/tag/v${clean}`
39
+ }
40
+ return `https://github.com/${props.repo}/releases`
41
+ })
42
+
32
43
  const dropdownItems = computed(() => [
33
44
  (versions.value || []).map((v) => ({
34
45
  label: v.label,
@@ -113,14 +124,17 @@ const selectItems = computed(() =>
113
124
  </UDropdownMenu>
114
125
  </template>
115
126
 
116
- <!-- Single version or loading fallback: static Nuxt UI UBadge -->
117
- <UBadge
127
+ <!-- Single version or loading fallback: interactive Nuxt UI UButton linking to release notes -->
128
+ <UButton
118
129
  v-else
119
- :color="color"
130
+ :label="currentLabel"
131
+ :aria-label="`Open ${currentLabel} release notes on GitHub`"
120
132
  variant="subtle"
121
133
  :size="size"
122
- class="font-mono"
134
+ :color="color"
135
+ :to="releaseNotesUrl"
136
+ target="_blank"
137
+ class="font-semibold text-xs cursor-pointer hover:bg-primary/10 active:bg-primary/10 transition-colors"
123
138
  :class="props.class"
124
- :label="currentLabel"
125
139
  />
126
140
  </template>
@@ -3118,27 +3118,55 @@ export async function getCMSNavigationTree(event, collectionId, options) {
3118
3118
  section.title = sectionMeta.title;
3119
3119
  if (sectionMeta.icon) section.icon = sectionMeta.icon;
3120
3120
  }
3121
- const isSubFeature = segments.length >= 4 && !meta._isIndex && segments[0] === "docs" && segments[1] === "features";
3121
+ const isFeatureSection = segments[0] === "docs" && segments[1] === "features";
3122
+ const subFeatureKey = isFeatureSection && segments.length >= 3 ? segments[2] : null;
3123
+ const isSubFeature = Boolean(
3124
+ subFeatureKey && (segments.length >= 4 || segments.length === 3 && meta._isIndex && meta._nav?.title && meta._nav.title !== "Features")
3125
+ );
3126
+ const itemOrder = meta._isIndex ? 0 : typeof meta.navigation?.order === "number" ? meta.navigation.order : typeof meta.order === "number" ? meta.order : r.order ? isSubFeature ? r.order % 100 : r.order % 1e3 : 500;
3122
3127
  let targetParent = section;
3123
- if (isSubFeature) {
3124
- const subFeaturePath = `/${segments[0]}/${segments[1]}/${segments[2]}`;
3125
- let subFeatureNode = section.children?.find((c) => c.path === subFeaturePath);
3128
+ if (isSubFeature && subFeatureKey) {
3129
+ const subFeaturePath = `/${segments[0]}/${segments[1]}/${subFeatureKey}`;
3130
+ let subFeatureNode = section.children?.find(
3131
+ (c) => c._subFeatureKey === subFeatureKey || c.path === subFeaturePath
3132
+ );
3126
3133
  if (!subFeatureNode) {
3127
- const subFeatureTitle = segments[2].charAt(0).toUpperCase() + segments[2].slice(1).replace(/-/g, " ");
3134
+ const subFeatureTitle = meta._nav?.title || subFeatureKey.charAt(0).toUpperCase() + subFeatureKey.slice(1).replace(/-/g, " ");
3135
+ const subFeatureOrder = typeof meta._nav?.order === "number" ? meta._nav.order : meta._sectionOrder ?? 500;
3128
3136
  const newNode = {
3129
3137
  title: subFeatureTitle,
3130
3138
  path: subFeaturePath,
3139
+ icon: meta._nav?.icon || "i-lucide-layers",
3131
3140
  children: []
3132
3141
  };
3133
- newNode._groupOrder = 500;
3142
+ newNode._subFeatureKey = subFeatureKey;
3143
+ newNode._groupOrder = subFeatureOrder;
3134
3144
  section.children = section.children || [];
3135
3145
  section.children.push(newNode);
3136
3146
  subFeatureNode = newNode;
3147
+ } else {
3148
+ if (meta._nav?.title && subFeatureNode.title !== meta._nav.title) {
3149
+ subFeatureNode.title = meta._nav.title;
3150
+ }
3151
+ if (meta._nav?.icon) {
3152
+ subFeatureNode.icon = meta._nav.icon;
3153
+ }
3154
+ if (typeof meta._nav?.order === "number") {
3155
+ ;
3156
+ subFeatureNode._groupOrder = meta._nav.order;
3157
+ }
3137
3158
  }
3138
3159
  if (!subFeatureNode.children) {
3139
3160
  subFeatureNode.children = [];
3140
3161
  }
3141
3162
  targetParent = subFeatureNode;
3163
+ targetParent.children.push({
3164
+ title: itemTitle,
3165
+ path: entryPath,
3166
+ icon: meta.navigation?.icon || meta._nav?.icon,
3167
+ _groupOrder: itemOrder
3168
+ });
3169
+ continue;
3142
3170
  }
3143
3171
  if (meta._group) {
3144
3172
  const groupKey = meta._group.key;
@@ -3160,7 +3188,8 @@ export async function getCMSNavigationTree(event, collectionId, options) {
3160
3188
  gi.children.push({
3161
3189
  title: itemTitle,
3162
3190
  path: entryPath,
3163
- icon: meta.navigation?.icon || meta._nav?.icon
3191
+ icon: meta.navigation?.icon || meta._nav?.icon,
3192
+ _groupOrder: itemOrder
3164
3193
  });
3165
3194
  continue;
3166
3195
  }
@@ -3178,7 +3207,8 @@ export async function getCMSNavigationTree(event, collectionId, options) {
3178
3207
  targetParent.children.push({
3179
3208
  title: itemTitle,
3180
3209
  path: entryPath,
3181
- icon: meta.navigation?.icon || meta._nav?.icon
3210
+ icon: meta.navigation?.icon || meta._nav?.icon,
3211
+ _groupOrder: itemOrder
3182
3212
  });
3183
3213
  } else {
3184
3214
  const subGroupKey = segments.slice(0, segments.length - 1).join("/");
@@ -3202,7 +3232,8 @@ export async function getCMSNavigationTree(event, collectionId, options) {
3202
3232
  subGroup.children.push({
3203
3233
  title: itemTitle,
3204
3234
  path: entryPath,
3205
- icon: meta.navigation?.icon || meta._nav?.icon
3235
+ icon: meta.navigation?.icon || meta._nav?.icon,
3236
+ _groupOrder: itemOrder
3206
3237
  });
3207
3238
  }
3208
3239
  }
@@ -3211,7 +3242,8 @@ export async function getCMSNavigationTree(event, collectionId, options) {
3211
3242
  targetParent.children.unshift({
3212
3243
  title: itemTitle,
3213
3244
  path: entryPath,
3214
- icon: meta.navigation?.icon || meta._nav?.icon
3245
+ icon: meta.navigation?.icon || meta._nav?.icon,
3246
+ _groupOrder: itemOrder
3215
3247
  });
3216
3248
  }
3217
3249
  }
@@ -3235,6 +3267,7 @@ export async function getCMSNavigationTree(event, collectionId, options) {
3235
3267
  delete c._groupKey;
3236
3268
  delete c._groupOrder;
3237
3269
  delete c._subGroupKey;
3270
+ delete c._subFeatureKey;
3238
3271
  cleanAndSortNode(c);
3239
3272
  }
3240
3273
  }
@@ -25,6 +25,7 @@ export interface ScanContentOptions {
25
25
  collectionsConfig?: Record<string, CMSCollectionConfig>;
26
26
  sources?: any[];
27
27
  exclude?: string | string[];
28
+ shiki?: boolean | any;
28
29
  }
29
30
  export declare function extractTOC(md: string): any[];
30
31
  export declare function parseFrontmatter(raw: string): {
@@ -52,11 +52,16 @@ export declare function discoverSources(contentDir: string): Promise<Array<{
52
52
  /**
53
53
  * Resolves all discovered and config-declared sources into absolute disk paths and normalized
54
54
  * prefixes. Downloads remote sources via giget tarball into the cache directory.
55
+ *
56
+ * @param options.cacheOnly When true, skips remote downloads and only uses already-cached dirs.
57
+ * Use this in Nuxt module `setup()` to avoid blocking startup — then call again (without
58
+ * cacheOnly) in a `build:before` hook to fetch any missing remote sources.
55
59
  */
56
60
  export declare function resolveAllCmsSources(options: {
57
61
  contentDir: string;
58
62
  rootDir: string;
59
63
  cacheDir: string;
60
64
  configSources?: CMSSourceConfig[];
65
+ cacheOnly?: boolean;
61
66
  }): Promise<CMSResolvedSource[]>;
62
67
  export { matchesSourceFilters, matchesGlobFilter } from "../runtime/server/utils/cms-filter";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qarpeo",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Zero-config Cloudflare Edge Platform for Nuxt",
5
5
  "keywords": [
6
6
  "analytics-engine",
@@ -56,7 +56,7 @@
56
56
  "@comark/nuxt": "^0.8.1",
57
57
  "@comark/vue": "^0.8.1",
58
58
  "@nuxt/devtools-kit": "^4.1.0",
59
- "@nuxt/kit": "npm:@nuxt/kit-nightly@^5.0.0-2611051431-8a89118",
59
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@^5.0.0-2611052317-a04317f",
60
60
  "@simplewebauthn/browser": "14.0.0",
61
61
  "@simplewebauthn/server": "14.0.3",
62
62
  "citty": "^0.2.2",
@@ -81,7 +81,7 @@
81
81
  "@typescript/typescript6": "^6.0.2",
82
82
  "h3": "^2.0.8",
83
83
  "nitro": "3.0.261103-rc",
84
- "nuxt": "npm:nuxt-nightly@^5.0.0-2611051431-8a89118",
84
+ "nuxt": "npm:nuxt-nightly@^5.0.0-2611052317-a04317f",
85
85
  "typescript": "^7.0.2",
86
86
  "unbuild": "^3.6.1",
87
87
  "vite-plus": "1.5.0",