@emeryld/rrroutes-export 1.0.23 → 1.0.25

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@emeryld/rrroutes-export",
3
3
  "description": "Finalized leaves export helpers and CLI for RRRoutes",
4
- "version": "1.0.23",
4
+ "version": "1.0.25",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs",
@@ -381,7 +381,12 @@
381
381
  .changelog-commit-separator {
382
382
  margin-top: 12px;
383
383
  padding-top: 10px;
384
+ padding-bottom: 6px;
384
385
  border-top: 1px solid var(--muted);
386
+ position: sticky;
387
+ top: 0;
388
+ z-index: 5;
389
+ background: var(--bg);
385
390
  }
386
391
 
387
392
  .changelog-commit-separator:first-child {
@@ -418,6 +423,24 @@
418
423
  .changelog-schema-type {
419
424
  color: var(--schema-accent);
420
425
  }
426
+ .changelog-schema-details {
427
+ margin-top: 6px;
428
+ }
429
+ .changelog-schema-details > summary {
430
+ color: var(--schema-accent);
431
+ font-size: 12px;
432
+ }
433
+ .changelog-schema-details-body {
434
+ margin-top: 6px;
435
+ display: grid;
436
+ gap: 4px;
437
+ }
438
+ .changelog-schema-line > summary {
439
+ font-size: 12px;
440
+ }
441
+ .changelog-schema-line .meta {
442
+ margin-top: 4px;
443
+ }
421
444
 
422
445
  .event-title-row {
423
446
  display: inline-flex;
@@ -1844,6 +1867,23 @@
1844
1867
  return basePath
1845
1868
  }
1846
1869
 
1870
+ function stripSectionPrefix(path, section) {
1871
+ if (typeof path !== 'string' || typeof section !== 'string') return ''
1872
+ if (!path) return ''
1873
+ if (path === section) return ''
1874
+ if (path.startsWith(`${section}.`)) return path.slice(section.length + 1)
1875
+ if (path.startsWith(`${section}[]`)) return path.slice(section.length)
1876
+ return path
1877
+ }
1878
+
1879
+ function sourceSchemaLocation(section, path) {
1880
+ if (typeof section !== 'string' || !section) return String(path || '')
1881
+ const normalizedPath = stripSectionPrefix(path, section)
1882
+ if (!normalizedPath) return section
1883
+ if (normalizedPath.startsWith('[]')) return `${section}${normalizedPath}`
1884
+ return `${section}.${normalizedPath}`
1885
+ }
1886
+
1847
1887
  function parseSignatureEntry(signature) {
1848
1888
  if (typeof signature !== 'string') return null
1849
1889
  const typeMatch = signature.match(/(?:^|,\s*)type=([^,]+)/)
@@ -1947,7 +1987,7 @@
1947
1987
  function formatSchemaDiffLine(delta) {
1948
1988
  if (!delta || typeof delta !== 'object') return null
1949
1989
  if ('section' in delta) {
1950
- const location = `${delta.section}.${delta.path}`
1990
+ const location = sourceSchemaLocation(delta.section, delta.path)
1951
1991
  if (delta.op === 'added') {
1952
1992
  const afterType = formatSourceTypeLabel(delta.after)
1953
1993
  if (afterType) return buildSchemaDiffLine(delta.op, afterType, location)
@@ -2024,7 +2064,7 @@
2024
2064
  '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><path d="M2 4h12"/><path d="M2 8h12"/><path d="M2 12h12"/><circle cx="6" cy="4" r="1.6" fill="currentColor" stroke="none"/><circle cx="10.5" cy="8" r="1.6" fill="currentColor" stroke="none"/><circle cx="4.5" cy="12" r="1.6" fill="currentColor" stroke="none"/></svg>',
2025
2065
  }
2026
2066
 
2027
- function eventVisualByType(type) {
2067
+ function eventVisualByType(type, eventKind) {
2028
2068
  switch (type) {
2029
2069
  case 'route_added':
2030
2070
  return {
@@ -2040,7 +2080,8 @@
2040
2080
  }
2041
2081
  case 'schema_changed':
2042
2082
  return {
2043
- actionText: 'modified schema',
2083
+ actionText:
2084
+ eventKind === 'route' ? 'modified route' : 'modified schema',
2044
2085
  actionClass: 'event-action-modified',
2045
2086
  icon: 'schema',
2046
2087
  }
@@ -2099,13 +2140,61 @@
2099
2140
 
2100
2141
  function renderEventTitle(item) {
2101
2142
  const row = el('div', 'event-title-row mono')
2102
- const visual = eventVisualByType(item?.event?.type)
2143
+ const visual = eventVisualByType(item?.event?.type, item?.eventKind)
2103
2144
  row.appendChild(el('span', visual.actionClass, visual.actionText))
2104
2145
  row.appendChild(renderEventIcon(visual.icon))
2105
2146
  row.appendChild(el('span', 'event-name', `[${resolveEventName(item)}]`))
2106
2147
  return row
2107
2148
  }
2108
2149
 
2150
+ function schemaDiffRawDetail(delta) {
2151
+ if (!delta || typeof delta !== 'object') return ''
2152
+ if ('path' in delta) {
2153
+ const location = formatPathLabel(delta.path) || String(delta.path || '')
2154
+ if (delta.op === 'added') {
2155
+ return `added ${location}: ${formatRouteSchemaEntry(delta.after)}`
2156
+ }
2157
+ if (delta.op === 'removed') {
2158
+ return `removed ${location}: ${formatRouteSchemaEntry(delta.before)}`
2159
+ }
2160
+ return `changed ${location}: ${formatRouteSchemaEntry(delta.before)} -> ${formatRouteSchemaEntry(delta.after)}`
2161
+ }
2162
+ if ('section' in delta) {
2163
+ const location = sourceSchemaLocation(delta.section, delta.path)
2164
+ if (delta.op === 'added') {
2165
+ return `added ${location}: ${JSON.stringify(delta.after || [])}`
2166
+ }
2167
+ if (delta.op === 'removed') {
2168
+ return `removed ${location}: ${JSON.stringify(delta.before || [])}`
2169
+ }
2170
+ return `changed ${location}: ${JSON.stringify(delta.before || [])} -> ${JSON.stringify(delta.after || [])}`
2171
+ }
2172
+ return JSON.stringify(delta)
2173
+ }
2174
+
2175
+ function renderSchemaDiffNested(schemaDiff) {
2176
+ if (!Array.isArray(schemaDiff) || schemaDiff.length === 0) return null
2177
+ const wrapper = el('details', 'changelog-schema-details')
2178
+ wrapper.appendChild(
2179
+ el('summary', 'mono', `schema changes (${schemaDiff.length})`),
2180
+ )
2181
+ const body = el('div', 'changelog-schema-details-body')
2182
+ schemaDiff.forEach((delta) => {
2183
+ const lineNode = formatSchemaDiffLine(delta)
2184
+ if (!lineNode) return
2185
+ const lineDetails = el('details', 'changelog-schema-line')
2186
+ const lineSummary = el('summary')
2187
+ lineSummary.appendChild(lineNode)
2188
+ lineDetails.appendChild(lineSummary)
2189
+ lineDetails.appendChild(
2190
+ el('div', 'meta mono', schemaDiffRawDetail(delta)),
2191
+ )
2192
+ body.appendChild(lineDetails)
2193
+ })
2194
+ wrapper.appendChild(body)
2195
+ return wrapper
2196
+ }
2197
+
2109
2198
  function renderEventCard(event, commitBySha, options = {}) {
2110
2199
  const card = el('div', 'leaf-content')
2111
2200
  const commit = commitBySha.get(event.commitSha)
@@ -2123,16 +2212,8 @@
2123
2212
  card.appendChild(renderEventTitle(options.item))
2124
2213
  }
2125
2214
  if (Array.isArray(event.schemaDiff) && event.schemaDiff.length > 0) {
2126
- card.appendChild(
2127
- el('div', 'meta', `schema changes: ${event.schemaDiff.length}`),
2128
- )
2129
- const schemaChanges = el('div')
2130
- event.schemaDiff.forEach((delta) => {
2131
- const lineNode = formatSchemaDiffLine(delta)
2132
- if (!lineNode) return
2133
- schemaChanges.appendChild(lineNode)
2134
- })
2135
- card.appendChild(schemaChanges)
2215
+ const schemaDetails = renderSchemaDiffNested(event.schemaDiff)
2216
+ if (schemaDetails) card.appendChild(schemaDetails)
2136
2217
  }
2137
2218
  if (Array.isArray(event.cfgDiff) && event.cfgDiff.length > 0) {
2138
2219
  card.appendChild(
@@ -2190,8 +2271,14 @@
2190
2271
  const box = el('div', 'changelog-commit-separator')
2191
2272
  const commit = commitBySha.get(commitSha)
2192
2273
  const commitDateTime = formatCommitDateTime(commit?.authorDate)
2193
- const label = `commit ${String(commitSha || '').slice(0, 12)}`
2194
- const meta = [commitDateTime, commit?.authorName || null, commit?.subject || null]
2274
+ const subjectFirstLine = String(commit?.subject || '')
2275
+ .split('\n')
2276
+ .map((line) => line.trim())
2277
+ .find(Boolean)
2278
+ const labelParts = [`commit ${String(commitSha || '').slice(0, 12)}`]
2279
+ if (subjectFirstLine) labelParts.push(subjectFirstLine)
2280
+ const label = labelParts.join(' ')
2281
+ const meta = [commitDateTime, commit?.authorName || null]
2195
2282
  .filter(Boolean)
2196
2283
  .join(' - ')
2197
2284
  box.appendChild(el('div', 'changelog-commit-label mono', label))
@@ -2223,11 +2310,8 @@
2223
2310
  row.appendChild(renderEventTitle(item))
2224
2311
 
2225
2312
  if (Array.isArray(event.schemaDiff) && event.schemaDiff.length > 0) {
2226
- event.schemaDiff.forEach((delta) => {
2227
- const lineNode = formatSchemaDiffLine(delta)
2228
- if (!lineNode) return
2229
- row.appendChild(lineNode)
2230
- })
2313
+ const schemaDetails = renderSchemaDiffNested(event.schemaDiff)
2314
+ if (schemaDetails) row.appendChild(schemaDetails)
2231
2315
  }
2232
2316
  if (Array.isArray(event.cfgDiff) && event.cfgDiff.length > 0) {
2233
2317
  event.cfgDiff.forEach((diff) => {
@@ -2318,7 +2402,7 @@
2318
2402
  return { op, location, before, after }
2319
2403
  }
2320
2404
  if ('section' in delta) {
2321
- const location = `${delta.section}.${delta.path}`
2405
+ const location = sourceSchemaLocation(delta.section, delta.path)
2322
2406
  const before = Array.isArray(delta.before)
2323
2407
  ? delta.before.map((item) => normalizeSignatureToken(item)).filter(Boolean)
2324
2408
  : []