@emeryld/rrroutes-export 1.0.1 → 1.0.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.
package/README.md CHANGED
@@ -7,3 +7,4 @@ Export helpers and CLI for RRRoutes finalized leaves.
7
7
  - Schema utilities: `serializeLeafContract`, `flattenLeafSchemas`, `introspectSchema`
8
8
 
9
9
  Depends on `@emeryld/rrroutes-contract` for contract types and schema parsing.
10
+ This package is configured to install `@emeryld/rrroutes-contract` from npm (not from the local workspace) to ensure release-version parity.
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.1",
4
+ "version": "1.0.4",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs",
@@ -23,7 +23,7 @@
23
23
  "bin/rrroutes-export-finalized-leaves.mjs"
24
24
  ],
25
25
  "dependencies": {
26
- "@emeryld/rrroutes-contract": "^2.7.13",
26
+ "@emeryld/rrroutes-contract": "^2.8.0",
27
27
  "typescript": "^5.9.3",
28
28
  "zod": "^4.3.6"
29
29
  },
@@ -924,15 +924,35 @@
924
924
  return node
925
925
  }
926
926
 
927
- function setHighlighted(node, text, engine) {
928
- node.innerHTML = engine.highlight(text ?? '')
927
+ function normalizeFieldIds(fieldIds) {
928
+ if (!fieldIds) return []
929
+ return Array.isArray(fieldIds) ? fieldIds : [fieldIds]
929
930
  }
930
931
 
931
- function kv(key, value, engine) {
932
+ function shouldHighlightField(fieldIds, selectedIds) {
933
+ const ids = normalizeFieldIds(fieldIds)
934
+ if (ids.length === 0) return false
935
+ if (!Array.isArray(selectedIds)) return false
936
+ return ids.some((id) => selectedIds.includes(id))
937
+ }
938
+
939
+ function highlightWithFieldScope(text, engine, selectedIds, fieldIds) {
940
+ const source = text ?? ''
941
+ if (!engine.active || !shouldHighlightField(fieldIds, selectedIds)) {
942
+ return escapeHtml(source)
943
+ }
944
+ return engine.highlight(source)
945
+ }
946
+
947
+ function setHighlighted(node, text, engine, selectedIds, fieldIds) {
948
+ node.innerHTML = highlightWithFieldScope(text, engine, selectedIds, fieldIds)
949
+ }
950
+
951
+ function kv(key, value, engine, selectedIds, fieldIds) {
932
952
  const box = el('div', 'kv')
933
953
  box.appendChild(el('div', 'k', key))
934
954
  const valueNode = el('div', 'v mono')
935
- setHighlighted(valueNode, value === undefined ? '—' : String(value), engine)
955
+ setHighlighted(valueNode, value === undefined ? '—' : String(value), engine, selectedIds, fieldIds)
936
956
  box.appendChild(valueNode)
937
957
  return box
938
958
  }
@@ -982,12 +1002,12 @@
982
1002
  return `vscode://file/${encodeURI(vscodePath)}:${line}:${column}`
983
1003
  }
984
1004
 
985
- function createSourceRow(label, source, engine) {
1005
+ function createSourceRow(label, source, engine, selectedIds, fieldIds) {
986
1006
  const box = el('div', 'kv')
987
1007
  const labelNode = el('div', 'v mono')
988
1008
 
989
1009
  if (!source || !source.file) {
990
- setHighlighted(labelNode, label, engine)
1010
+ setHighlighted(labelNode, label, engine, selectedIds, fieldIds)
991
1011
  box.appendChild(labelNode)
992
1012
  return box
993
1013
  }
@@ -997,7 +1017,7 @@
997
1017
  link.href = href
998
1018
  link.target = '_blank'
999
1019
  link.rel = 'noopener noreferrer'
1000
- link.innerHTML = engine.highlight(label)
1020
+ link.innerHTML = highlightWithFieldScope(label, engine, selectedIds, fieldIds)
1001
1021
  labelNode.appendChild(link)
1002
1022
  box.appendChild(labelNode)
1003
1023
  return box
@@ -1083,14 +1103,14 @@
1083
1103
  return root
1084
1104
  }
1085
1105
 
1086
- function renderTreeNode(node, engine, isRoot) {
1106
+ function renderTreeNode(node, engine, selectedIds, sectionName, isRoot) {
1087
1107
  const childKeys = Object.keys(node.children)
1088
1108
  const hasChildren = childKeys.length > 0
1089
1109
  const hasInfo = Boolean(node.info)
1090
1110
  const appendNameCell = (row) => {
1091
1111
  const nameWrap = el('span', 'mono tree-name')
1092
1112
  const nameNode = el('span')
1093
- setHighlighted(nameNode, node.name, engine)
1113
+ setHighlighted(nameNode, node.name, engine, selectedIds, sectionName)
1094
1114
  nameWrap.appendChild(nameNode)
1095
1115
 
1096
1116
  if (node.info && !node.info.optional) {
@@ -1107,7 +1127,10 @@
1107
1127
 
1108
1128
  const appendTypeCell = (row, info) => {
1109
1129
  const type = el('span', 'tree-pill')
1110
- setHighlighted(type, info?.type || info?.kind || '—', engine)
1130
+ setHighlighted(type, info?.type || info?.kind || '—', engine, selectedIds, [
1131
+ sectionName,
1132
+ 'types',
1133
+ ])
1111
1134
  row.appendChild(type)
1112
1135
  }
1113
1136
 
@@ -1126,7 +1149,11 @@
1126
1149
  const container = el('div', 'schema-tree')
1127
1150
  childKeys
1128
1151
  .sort((a, b) => a.localeCompare(b))
1129
- .forEach((key) => container.appendChild(renderTreeNode(node.children[key], engine, false)))
1152
+ .forEach((key) =>
1153
+ container.appendChild(
1154
+ renderTreeNode(node.children[key], engine, selectedIds, sectionName, false),
1155
+ ),
1156
+ )
1130
1157
  details.appendChild(container)
1131
1158
  return details
1132
1159
  }
@@ -1163,7 +1190,7 @@
1163
1190
  hasAnySchemaEntries = true
1164
1191
  const block = el('div', 'schema-block')
1165
1192
  const header = el('div', 'schema-header mono')
1166
- setHighlighted(header, sectionName, engine)
1193
+ setHighlighted(header, sectionName, engine, selectedIds, sectionName)
1167
1194
  block.appendChild(header)
1168
1195
 
1169
1196
  const schemaSource = getSchemaSource(source, sectionName)
@@ -1176,12 +1203,14 @@
1176
1203
  ),
1177
1204
  schemaSource.sourceValue,
1178
1205
  engine,
1206
+ selectedIds,
1207
+ 'sourceSchemas',
1179
1208
  ),
1180
1209
  )
1181
1210
  }
1182
1211
 
1183
1212
  const tree = buildSchemaTree(entries, sectionName)
1184
- block.appendChild(renderTreeNode(tree, engine, true))
1213
+ block.appendChild(renderTreeNode(tree, engine, selectedIds, sectionName, true))
1185
1214
 
1186
1215
  section.appendChild(block)
1187
1216
  })
@@ -1192,7 +1221,13 @@
1192
1221
  function renderLeaf(leaf, engine, selectedIds) {
1193
1222
  const details = el('details', 'leaf')
1194
1223
  const summary = el('summary')
1195
- setHighlighted(summary, `${String(leaf.method || '').toUpperCase()} ${leaf.path || ''}`, engine)
1224
+ setHighlighted(
1225
+ summary,
1226
+ `${String(leaf.method || '').toUpperCase()} ${leaf.path || ''}`,
1227
+ engine,
1228
+ selectedIds,
1229
+ ['method', 'path'],
1230
+ )
1196
1231
  details.appendChild(summary)
1197
1232
 
1198
1233
  const content = el('div', 'leaf-content')
@@ -1202,32 +1237,38 @@
1202
1237
  const overview = el('div', 'section')
1203
1238
  overview.appendChild(el('h3', '', 'Overview'))
1204
1239
  const topGrid = el('div', 'grid-3')
1205
- topGrid.appendChild(kv('group', cfg.docsGroup, engine))
1240
+ topGrid.appendChild(kv('group', cfg.docsGroup, engine, selectedIds, 'docsGroup'))
1206
1241
  topGrid.appendChild(
1207
- kv('tags', cfg.tags && cfg.tags.length > 0 ? cfg.tags.join(', ') : undefined, engine),
1242
+ kv(
1243
+ 'tags',
1244
+ cfg.tags && cfg.tags.length > 0 ? cfg.tags.join(', ') : undefined,
1245
+ engine,
1246
+ selectedIds,
1247
+ 'tags',
1248
+ ),
1208
1249
  )
1209
- topGrid.appendChild(kv('stability', cfg.stability, engine))
1250
+ topGrid.appendChild(kv('stability', cfg.stability, engine, selectedIds, 'stability'))
1210
1251
  overview.appendChild(topGrid)
1211
- overview.appendChild(kv('summary', cfg.summary, engine))
1212
- overview.appendChild(kv('description', cfg.description, engine))
1252
+ overview.appendChild(kv('summary', cfg.summary, engine, selectedIds, 'summary'))
1253
+ overview.appendChild(kv('description', cfg.description, engine, selectedIds, 'description'))
1213
1254
 
1214
1255
  const iconRow = el('div', 'icon-row')
1215
1256
  if (cfg.feed) {
1216
1257
  const feed = el('span', 'icon-badge feed')
1217
1258
  feed.title = 'Feed endpoint'
1218
- setHighlighted(feed, 'Feed', engine)
1259
+ feed.textContent = 'Feed'
1219
1260
  iconRow.appendChild(feed)
1220
1261
  }
1221
1262
  if (cfg.deprecated) {
1222
1263
  const deprecated = el('span', 'icon-badge warn')
1223
1264
  deprecated.title = 'Deprecated'
1224
- setHighlighted(deprecated, 'D', engine)
1265
+ deprecated.textContent = 'D'
1225
1266
  iconRow.appendChild(deprecated)
1226
1267
  }
1227
1268
  if (cfg.docsHidden) {
1228
1269
  const hidden = el('span', 'icon-badge warn')
1229
1270
  hidden.title = 'Hidden'
1230
- setHighlighted(hidden, 'H', engine)
1271
+ hidden.textContent = 'H'
1231
1272
  iconRow.appendChild(hidden)
1232
1273
  }
1233
1274
  if (iconRow.childNodes.length > 0) {
@@ -1241,7 +1282,7 @@
1241
1282
  const chips = el('div', 'chips')
1242
1283
  cfg.bodyFiles.forEach((file) => {
1243
1284
  const chip = el('span', 'chip ok')
1244
- setHighlighted(chip, `${file.name} (max ${file.maxCount})`, engine)
1285
+ chip.textContent = `${file.name} (max ${file.maxCount})`
1245
1286
  chips.appendChild(chip)
1246
1287
  })
1247
1288
  files.appendChild(chips)
@@ -1251,7 +1292,9 @@
1251
1292
  const sourceByLeaf = state.payload?.sourceByLeaf || {}
1252
1293
  const source = sourceByLeaf[leaf.key]
1253
1294
  if (source?.definition) {
1254
- overview.appendChild(createSourceRow('definition', source.definition, engine))
1295
+ overview.appendChild(
1296
+ createSourceRow('definition', source.definition, engine, selectedIds, 'sourceDefinition'),
1297
+ )
1255
1298
  }
1256
1299
 
1257
1300
  const separatedSchemas = renderSeparatedSchemas(flatSchema, engine, selectedIds, source)