@kubb/ast 5.23.1 → 5.23.3

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 (163) hide show
  1. package/dist/{constants-Ckeonm-D.js → constants-BTTus9ee.js} +1 -1
  2. package/dist/{constants-Ckeonm-D.js.map → constants-BTTus9ee.js.map} +1 -1
  3. package/dist/{constants-CquR083U.cjs → constants-DztHlVmY.cjs} +1 -1
  4. package/dist/{constants-CquR083U.cjs.map → constants-DztHlVmY.cjs.map} +1 -1
  5. package/dist/factory.cjs +3 -3
  6. package/dist/factory.d.cts +3 -3
  7. package/dist/factory.d.ts +3 -3
  8. package/dist/factory.js +3 -3
  9. package/dist/{file-Dd50jPkH.cjs → file-BAICym_L.cjs} +19 -10
  10. package/dist/file-BAICym_L.cjs.map +1 -0
  11. package/dist/{file-CnuL8oUj.js → file-DUFttt26.js} +21 -11
  12. package/dist/file-DUFttt26.js.map +1 -0
  13. package/dist/{file-CvlMAp_d.js → file-Dj9lsbJu.js} +19 -10
  14. package/dist/file-Dj9lsbJu.js.map +1 -0
  15. package/dist/{file-BVqSiSvV.d.cts → file-DkFGn_Os.d.ts} +29 -7
  16. package/dist/{file-Cg0T6cgz.cjs → file-Dz1HPMld.cjs} +21 -11
  17. package/dist/file-Dz1HPMld.cjs.map +1 -0
  18. package/dist/{file-xJnBQPGq.d.ts → file-KunZhFIV.d.cts} +29 -7
  19. package/dist/file.cjs +1 -1
  20. package/dist/file.d.cts +1 -1
  21. package/dist/file.d.ts +1 -1
  22. package/dist/file.js +1 -1
  23. package/dist/{graph-BcwFCvei.js → graph-BUEOBomo.js} +5 -5
  24. package/dist/{graph-BcwFCvei.js.map → graph-BUEOBomo.js.map} +1 -1
  25. package/dist/{graph-DcIY6tQb.cjs → graph-CFJ4wzFR.cjs} +5 -5
  26. package/dist/{graph-DcIY6tQb.cjs.map → graph-CFJ4wzFR.cjs.map} +1 -1
  27. package/dist/graph.cjs +1 -1
  28. package/dist/graph.d.cts +1 -1
  29. package/dist/graph.d.ts +1 -1
  30. package/dist/graph.js +1 -1
  31. package/dist/{guards-COVJE6TU.cjs → guards-4drgx10i.cjs} +1 -1
  32. package/dist/{guards-COVJE6TU.cjs.map → guards-4drgx10i.cjs.map} +1 -1
  33. package/dist/{guards-D-h9R_sV.d.ts → guards-C6w6KQSY.d.ts} +1 -1
  34. package/dist/{guards-B8qDgSaT.d.cts → guards-COBkDtgu.d.cts} +1 -1
  35. package/dist/{guards-DlJkKsT1.js → guards-DKw4uwc5.js} +1 -1
  36. package/dist/{guards-DlJkKsT1.js.map → guards-DKw4uwc5.js.map} +1 -1
  37. package/dist/{http-DwboM6pK.js → http-CAWf6TAJ.js} +2 -2
  38. package/dist/http-CAWf6TAJ.js.map +1 -0
  39. package/dist/{http-Bm5lhVK4.cjs → http-Dv8py6wh.cjs} +2 -2
  40. package/dist/http-Dv8py6wh.cjs.map +1 -0
  41. package/dist/http.cjs +2 -2
  42. package/dist/http.d.cts +2 -2
  43. package/dist/http.d.ts +2 -2
  44. package/dist/http.js +2 -2
  45. package/dist/{index-DNiIem0x.d.ts → index-9l1xMEl_.d.ts} +4 -4
  46. package/dist/{index-Dp50LM3a.d.ts → index-B5w-X5V6.d.ts} +1 -1
  47. package/dist/{index-BwnMIoLl.d.ts → index-Be5d4Zcl.d.ts} +2 -2
  48. package/dist/index-CI6Tu2c7.d.ts +5 -0
  49. package/dist/{index-CAGuKv6t.d.ts → index-CPXo4cA8.d.cts} +8 -3
  50. package/dist/{index-eGkM4FE9.d.ts → index-CX7yfAGI.d.ts} +1 -1
  51. package/dist/{index-CFH4ZC7q.d.ts → index-CnY3KmAg.d.ts} +1 -1
  52. package/dist/{index-CIqwy4EE.d.cts → index-CwFC71XK.d.ts} +8 -3
  53. package/dist/{index-DYDha-3I.d.cts → index-D-BjRrJo.d.cts} +1 -1
  54. package/dist/{index-DU_jYpBt.d.cts → index-DZe5evGM.d.cts} +1 -1
  55. package/dist/{index-D3M2spDR.d.ts → index-DjThtAn4.d.ts} +3 -3
  56. package/dist/{index-cpjUxIik.d.ts → index-DkThxxxq.d.cts} +3 -3
  57. package/dist/{index-BngGJux5.d.cts → index-Dr81DOsC.d.cts} +3 -3
  58. package/dist/index-DuDvNFQ8.d.cts +5 -0
  59. package/dist/{index-C-vhkzwR.d.cts → index-dgiKWRpD.d.cts} +4 -4
  60. package/dist/{index-Bb1kqq8H.d.cts → index-gDZYBeJw.d.cts} +1 -1
  61. package/dist/{index-Csf8xsCc.d.cts → index-jWtEIa7j.d.ts} +3 -3
  62. package/dist/{index-DSVef1pp.d.cts → index-ss1YqjpW.d.cts} +2 -2
  63. package/dist/index.cjs +30 -24
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +27 -27
  66. package/dist/index.d.ts +27 -27
  67. package/dist/index.js +30 -24
  68. package/dist/index.js.map +1 -1
  69. package/dist/{json-DURdtz9A.cjs → json-CCWMgzJZ.cjs} +2 -2
  70. package/dist/{json-DURdtz9A.cjs.map → json-CCWMgzJZ.cjs.map} +1 -1
  71. package/dist/{json-DH7_lcWm.js → json-DyDtIZTj.js} +2 -2
  72. package/dist/{json-DH7_lcWm.js.map → json-DyDtIZTj.js.map} +1 -1
  73. package/dist/json.cjs +1 -1
  74. package/dist/json.d.cts +1 -1
  75. package/dist/json.d.ts +1 -1
  76. package/dist/json.js +1 -1
  77. package/dist/{macro-D0KfNtff.js → macro-9WouvtZe.js} +3 -3
  78. package/dist/macro-9WouvtZe.js.map +1 -0
  79. package/dist/{macro-DrTBT7fh.cjs → macro-BEwfGNu1.cjs} +3 -3
  80. package/dist/macro-BEwfGNu1.cjs.map +1 -0
  81. package/dist/macro.cjs +1 -1
  82. package/dist/macro.d.cts +1 -1
  83. package/dist/macro.d.ts +1 -1
  84. package/dist/macro.js +1 -1
  85. package/dist/{mediaType-D8uIO8sG.cjs → mediaType-BbIfudh0.cjs} +1 -1
  86. package/dist/{mediaType-D8uIO8sG.cjs.map → mediaType-BbIfudh0.cjs.map} +1 -1
  87. package/dist/{mediaType-CRjggmoG.js → mediaType-DXQCNYdM.js} +1 -1
  88. package/dist/{mediaType-CRjggmoG.js.map → mediaType-DXQCNYdM.js.map} +1 -1
  89. package/dist/mediaType.cjs +1 -1
  90. package/dist/mediaType.d.cts +1 -1
  91. package/dist/mediaType.d.ts +1 -1
  92. package/dist/mediaType.js +1 -1
  93. package/dist/{node-Djh-mZB2.js → node-DtuO3zr8.js} +4 -4
  94. package/dist/{node-Djh-mZB2.js.map → node-DtuO3zr8.js.map} +1 -1
  95. package/dist/{node-DjcETnc8.cjs → node-vTrAIz3e.cjs} +4 -4
  96. package/dist/{node-DjcETnc8.cjs.map → node-vTrAIz3e.cjs.map} +1 -1
  97. package/dist/node.cjs +4 -4
  98. package/dist/node.d.cts +3 -3
  99. package/dist/node.d.ts +3 -3
  100. package/dist/node.js +4 -4
  101. package/dist/{nodeText-DVVDZQjF.js → nodeText-BSYvDZOH.js} +2 -2
  102. package/dist/{nodeText-DVVDZQjF.js.map → nodeText-BSYvDZOH.js.map} +1 -1
  103. package/dist/{nodeText-DRb_rVd1.cjs → nodeText-CZ7wgxu9.cjs} +2 -2
  104. package/dist/{nodeText-DRb_rVd1.cjs.map → nodeText-CZ7wgxu9.cjs.map} +1 -1
  105. package/dist/{nodes-BB60Bq2H.cjs → nodes-BT2Ocq0x.cjs} +5 -5
  106. package/dist/{nodes-BB60Bq2H.cjs.map → nodes-BT2Ocq0x.cjs.map} +1 -1
  107. package/dist/{nodes-CWMa9xhW.js → nodes-CwYIFVt5.js} +5 -5
  108. package/dist/{nodes-CWMa9xhW.js.map → nodes-CwYIFVt5.js.map} +1 -1
  109. package/dist/{operation-X7chCdL2.d.cts → operation-BUhPuZMY.d.cts} +1 -1
  110. package/dist/{operation-BgRyVS7z.d.ts → operation-jxEr2No4.d.ts} +1 -1
  111. package/dist/{optionality-D-zqzVMH.cjs → optionality-C-qULYxo.cjs} +1 -1
  112. package/dist/{optionality-D-zqzVMH.cjs.map → optionality-C-qULYxo.cjs.map} +1 -1
  113. package/dist/{optionality-DISn8ytP.js → optionality-FkRredTC.js} +1 -1
  114. package/dist/{optionality-DISn8ytP.js.map → optionality-FkRredTC.js.map} +1 -1
  115. package/dist/{promise-RpnEev9D.js → promise-B3YkZ4C8.js} +1 -1
  116. package/dist/{promise-RpnEev9D.js.map → promise-B3YkZ4C8.js.map} +1 -1
  117. package/dist/{promise-BOdlgT0N.cjs → promise-DScaykew.cjs} +1 -1
  118. package/dist/{promise-BOdlgT0N.cjs.map → promise-DScaykew.cjs.map} +1 -1
  119. package/dist/{ref-P0ZLT1Bg.cjs → ref-Bh5Xo8T7.cjs} +4 -4
  120. package/dist/{ref-P0ZLT1Bg.cjs.map → ref-Bh5Xo8T7.cjs.map} +1 -1
  121. package/dist/{ref-Bu7PoHar.js → ref-DPqeS8K1.js} +4 -4
  122. package/dist/{ref-Bu7PoHar.js.map → ref-DPqeS8K1.js.map} +1 -1
  123. package/dist/ref.cjs +2 -2
  124. package/dist/ref.d.cts +1 -1
  125. package/dist/ref.d.ts +1 -1
  126. package/dist/ref.js +2 -2
  127. package/dist/{refs-YCV3CznS.js → refs-Bgf8_9Ui.js} +2 -2
  128. package/dist/{refs-YCV3CznS.js.map → refs-Bgf8_9Ui.js.map} +1 -1
  129. package/dist/{refs-CYHpRlQo.cjs → refs-rmr2LFV1.cjs} +2 -2
  130. package/dist/{refs-CYHpRlQo.cjs.map → refs-rmr2LFV1.cjs.map} +1 -1
  131. package/dist/{schema-DloctnMm.js → schema-4UcdIPQ2.js} +7 -7
  132. package/dist/{schema-DloctnMm.js.map → schema-4UcdIPQ2.js.map} +1 -1
  133. package/dist/{schema-BIErWqgc.cjs → schema-DuCY4lCG.cjs} +7 -7
  134. package/dist/{schema-BIErWqgc.cjs.map → schema-DuCY4lCG.cjs.map} +1 -1
  135. package/dist/{schema-hxMlgCrV.cjs → schema-gSjYgaCl.cjs} +2 -2
  136. package/dist/{schema-hxMlgCrV.cjs.map → schema-gSjYgaCl.cjs.map} +1 -1
  137. package/dist/{schema-2ZAQk7qE.js → schema-tH14gE6i.js} +2 -2
  138. package/dist/{schema-2ZAQk7qE.js.map → schema-tH14gE6i.js.map} +1 -1
  139. package/dist/schema.cjs +5 -5
  140. package/dist/schema.d.cts +4 -4
  141. package/dist/schema.d.ts +4 -4
  142. package/dist/schema.js +5 -5
  143. package/dist/{visitor-DTrzvA3R.cjs → visitor-Bh1CBAOz.cjs} +4 -5
  144. package/dist/{visitor-DTrzvA3R.cjs.map → visitor-Bh1CBAOz.cjs.map} +1 -1
  145. package/dist/{visitor-BZozlXBF.d.ts → visitor-CFbuH7BY.d.ts} +6 -3
  146. package/dist/{visitor-Bw_opzjF.d.cts → visitor-DxhkIQyP.d.cts} +6 -3
  147. package/dist/{visitor-NoQSUQTu.js → visitor-XA0W3OVv.js} +4 -5
  148. package/dist/{visitor-NoQSUQTu.js.map → visitor-XA0W3OVv.js.map} +1 -1
  149. package/package.json +1 -1
  150. package/dist/file-Cg0T6cgz.cjs.map +0 -1
  151. package/dist/file-CnuL8oUj.js.map +0 -1
  152. package/dist/file-CvlMAp_d.js.map +0 -1
  153. package/dist/file-Dd50jPkH.cjs.map +0 -1
  154. package/dist/http-Bm5lhVK4.cjs.map +0 -1
  155. package/dist/http-DwboM6pK.js.map +0 -1
  156. package/dist/index-BWd95onW.d.cts +0 -5
  157. package/dist/index-DaHsMJ_S.d.ts +0 -5
  158. package/dist/macro-D0KfNtff.js.map +0 -1
  159. package/dist/macro-DrTBT7fh.cjs.map +0 -1
  160. /package/dist/{base-IpYuh3ZP.d.cts → base-LhsPvVY1.d.ts} +0 -0
  161. /package/dist/{base-IpYuh3ZP.d.ts → base-UFBZi-FO.d.cts} +0 -0
  162. /package/dist/{index-Cc2K3OzU.d.cts → index-C-nsgwuD.d.ts} +0 -0
  163. /package/dist/{index-Cc2K3OzU.d.ts → index-DR9ahJ-x.d.cts} +0 -0
@@ -138,4 +138,4 @@ const schemaTypes = {
138
138
  };
139
139
  export { schemaTypes as n, nodeKinds as t };
140
140
 
141
- //# sourceMappingURL=constants-Ckeonm-D.js.map
141
+ //# sourceMappingURL=constants-BTTus9ee.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-Ckeonm-D.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { SchemaType } from './nodes/schema.ts'\n\n/**\n * Node kind discriminators used by every AST node (for example `node.kind === nodeKinds.text`).\n */\nexport const nodeKinds = {\n input: 'Input',\n operation: 'Operation',\n schema: 'Schema',\n property: 'Property',\n parameter: 'Parameter',\n response: 'Response',\n requestBody: 'RequestBody',\n content: 'Content',\n type: 'Type',\n file: 'File',\n import: 'Import',\n export: 'Export',\n source: 'Source',\n const: 'Const',\n function: 'Function',\n arrowFunction: 'ArrowFunction',\n text: 'Text',\n break: 'Break',\n jsx: 'Jsx',\n} as const\n\n/**\n * Schema type discriminators used by all AST schema nodes.\n *\n * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).\n */\nexport const schemaTypes = {\n /**\n * Text value.\n */\n string: 'string',\n /**\n * Floating-point number (`float`, `double`).\n */\n number: 'number',\n /**\n * Whole number (`int32`). Use `bigint` for `int64`.\n */\n integer: 'integer',\n /**\n * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.\n */\n bigint: 'bigint',\n /**\n * Boolean value.\n */\n boolean: 'boolean',\n /**\n * Explicit null value.\n */\n null: 'null',\n /**\n * Any value (no type restriction).\n */\n any: 'any',\n /**\n * Unknown value (must be narrowed before usage).\n */\n unknown: 'unknown',\n /**\n * No return value (`void`).\n */\n void: 'void',\n /**\n * Object with named properties.\n */\n object: 'object',\n /**\n * Sequential list of items.\n */\n array: 'array',\n /**\n * Fixed-length list with position-specific items.\n */\n tuple: 'tuple',\n /**\n * \"One of\" multiple schema members.\n */\n union: 'union',\n /**\n * \"All of\" multiple schema members.\n */\n intersection: 'intersection',\n /** \"Not\" a single schema member. */\n not: 'not',\n /**\n * Enum schema.\n */\n enum: 'enum',\n /**\n * Reference to another schema.\n */\n ref: 'ref',\n /**\n * Calendar date (for example `2026-03-24`).\n */\n date: 'date',\n /**\n * Date-time value (for example `2026-03-24T09:00:00Z`).\n */\n datetime: 'datetime',\n /**\n * Time-only value (for example `09:00:00`).\n */\n time: 'time',\n /**\n * UUID value.\n */\n uuid: 'uuid',\n /**\n * Email address value.\n */\n email: 'email',\n /**\n * URL value.\n */\n url: 'url',\n /**\n * IPv4 address value.\n */\n ipv4: 'ipv4',\n /**\n * IPv6 address value.\n */\n ipv6: 'ipv6',\n /**\n * Binary/blob value.\n */\n blob: 'blob',\n /**\n * Impossible value (`never`).\n */\n never: 'never',\n} as const satisfies Record<SchemaType, SchemaType>\n"],"mappings":";;;;AAKA,MAAa,YAAY;CACvB,OAAO;CACP,WAAW;CACX,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;CACV,aAAa;CACb,SAAS;CACT,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,UAAU;CACV,eAAe;CACf,MAAM;CACN,OAAO;CACP,KAAK;AACP;;;;;;AAOA,MAAa,cAAc;;;;CAIzB,QAAQ;;;;CAIR,QAAQ;;;;CAIR,SAAS;;;;CAIT,QAAQ;;;;CAIR,SAAS;;;;CAIT,MAAM;;;;CAIN,KAAK;;;;CAIL,SAAS;;;;CAIT,MAAM;;;;CAIN,QAAQ;;;;CAIR,OAAO;;;;CAIP,OAAO;;;;CAIP,OAAO;;;;CAIP,cAAc;;CAEd,KAAK;;;;CAIL,MAAM;;;;CAIN,KAAK;;;;CAIL,MAAM;;;;CAIN,UAAU;;;;CAIV,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;;;;CAIP,KAAK;;;;CAIL,MAAM;;;;CAIN,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;AACT"}
1
+ {"version":3,"file":"constants-BTTus9ee.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { SchemaType } from './nodes/schema.ts'\n\n/**\n * Node kind discriminators used by every AST node (for example `node.kind === nodeKinds.text`).\n */\nexport const nodeKinds = {\n input: 'Input',\n operation: 'Operation',\n schema: 'Schema',\n property: 'Property',\n parameter: 'Parameter',\n response: 'Response',\n requestBody: 'RequestBody',\n content: 'Content',\n type: 'Type',\n file: 'File',\n import: 'Import',\n export: 'Export',\n source: 'Source',\n const: 'Const',\n function: 'Function',\n arrowFunction: 'ArrowFunction',\n text: 'Text',\n break: 'Break',\n jsx: 'Jsx',\n} as const\n\n/**\n * Schema type discriminators used by all AST schema nodes.\n *\n * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).\n */\nexport const schemaTypes = {\n /**\n * Text value.\n */\n string: 'string',\n /**\n * Floating-point number (`float`, `double`).\n */\n number: 'number',\n /**\n * Whole number (`int32`). Use `bigint` for `int64`.\n */\n integer: 'integer',\n /**\n * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.\n */\n bigint: 'bigint',\n /**\n * Boolean value.\n */\n boolean: 'boolean',\n /**\n * Explicit null value.\n */\n null: 'null',\n /**\n * Any value (no type restriction).\n */\n any: 'any',\n /**\n * Unknown value (must be narrowed before usage).\n */\n unknown: 'unknown',\n /**\n * No return value (`void`).\n */\n void: 'void',\n /**\n * Object with named properties.\n */\n object: 'object',\n /**\n * Sequential list of items.\n */\n array: 'array',\n /**\n * Fixed-length list with position-specific items.\n */\n tuple: 'tuple',\n /**\n * \"One of\" multiple schema members.\n */\n union: 'union',\n /**\n * \"All of\" multiple schema members.\n */\n intersection: 'intersection',\n /** \"Not\" a single schema member. */\n not: 'not',\n /**\n * Enum schema.\n */\n enum: 'enum',\n /**\n * Reference to another schema.\n */\n ref: 'ref',\n /**\n * Calendar date (for example `2026-03-24`).\n */\n date: 'date',\n /**\n * Date-time value (for example `2026-03-24T09:00:00Z`).\n */\n datetime: 'datetime',\n /**\n * Time-only value (for example `09:00:00`).\n */\n time: 'time',\n /**\n * UUID value.\n */\n uuid: 'uuid',\n /**\n * Email address value.\n */\n email: 'email',\n /**\n * URL value.\n */\n url: 'url',\n /**\n * IPv4 address value.\n */\n ipv4: 'ipv4',\n /**\n * IPv6 address value.\n */\n ipv6: 'ipv6',\n /**\n * Binary/blob value.\n */\n blob: 'blob',\n /**\n * Impossible value (`never`).\n */\n never: 'never',\n} as const satisfies Record<SchemaType, SchemaType>\n"],"mappings":";;;;AAKA,MAAa,YAAY;CACvB,OAAO;CACP,WAAW;CACX,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;CACV,aAAa;CACb,SAAS;CACT,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,UAAU;CACV,eAAe;CACf,MAAM;CACN,OAAO;CACP,KAAK;AACP;;;;;;AAOA,MAAa,cAAc;;;;CAIzB,QAAQ;;;;CAIR,QAAQ;;;;CAIR,SAAS;;;;CAIT,QAAQ;;;;CAIR,SAAS;;;;CAIT,MAAM;;;;CAIN,KAAK;;;;CAIL,SAAS;;;;CAIT,MAAM;;;;CAIN,QAAQ;;;;CAIR,OAAO;;;;CAIP,OAAO;;;;CAIP,OAAO;;;;CAIP,cAAc;;CAEd,KAAK;;;;CAIL,MAAM;;;;CAIN,KAAK;;;;CAIL,MAAM;;;;CAIN,UAAU;;;;CAIV,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;;;;CAIP,KAAK;;;;CAIL,MAAM;;;;CAIN,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;AACT"}
@@ -149,4 +149,4 @@ Object.defineProperty(exports, "schemaTypes", {
149
149
  }
150
150
  });
151
151
 
152
- //# sourceMappingURL=constants-CquR083U.cjs.map
152
+ //# sourceMappingURL=constants-DztHlVmY.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-CquR083U.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { SchemaType } from './nodes/schema.ts'\n\n/**\n * Node kind discriminators used by every AST node (for example `node.kind === nodeKinds.text`).\n */\nexport const nodeKinds = {\n input: 'Input',\n operation: 'Operation',\n schema: 'Schema',\n property: 'Property',\n parameter: 'Parameter',\n response: 'Response',\n requestBody: 'RequestBody',\n content: 'Content',\n type: 'Type',\n file: 'File',\n import: 'Import',\n export: 'Export',\n source: 'Source',\n const: 'Const',\n function: 'Function',\n arrowFunction: 'ArrowFunction',\n text: 'Text',\n break: 'Break',\n jsx: 'Jsx',\n} as const\n\n/**\n * Schema type discriminators used by all AST schema nodes.\n *\n * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).\n */\nexport const schemaTypes = {\n /**\n * Text value.\n */\n string: 'string',\n /**\n * Floating-point number (`float`, `double`).\n */\n number: 'number',\n /**\n * Whole number (`int32`). Use `bigint` for `int64`.\n */\n integer: 'integer',\n /**\n * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.\n */\n bigint: 'bigint',\n /**\n * Boolean value.\n */\n boolean: 'boolean',\n /**\n * Explicit null value.\n */\n null: 'null',\n /**\n * Any value (no type restriction).\n */\n any: 'any',\n /**\n * Unknown value (must be narrowed before usage).\n */\n unknown: 'unknown',\n /**\n * No return value (`void`).\n */\n void: 'void',\n /**\n * Object with named properties.\n */\n object: 'object',\n /**\n * Sequential list of items.\n */\n array: 'array',\n /**\n * Fixed-length list with position-specific items.\n */\n tuple: 'tuple',\n /**\n * \"One of\" multiple schema members.\n */\n union: 'union',\n /**\n * \"All of\" multiple schema members.\n */\n intersection: 'intersection',\n /** \"Not\" a single schema member. */\n not: 'not',\n /**\n * Enum schema.\n */\n enum: 'enum',\n /**\n * Reference to another schema.\n */\n ref: 'ref',\n /**\n * Calendar date (for example `2026-03-24`).\n */\n date: 'date',\n /**\n * Date-time value (for example `2026-03-24T09:00:00Z`).\n */\n datetime: 'datetime',\n /**\n * Time-only value (for example `09:00:00`).\n */\n time: 'time',\n /**\n * UUID value.\n */\n uuid: 'uuid',\n /**\n * Email address value.\n */\n email: 'email',\n /**\n * URL value.\n */\n url: 'url',\n /**\n * IPv4 address value.\n */\n ipv4: 'ipv4',\n /**\n * IPv6 address value.\n */\n ipv6: 'ipv6',\n /**\n * Binary/blob value.\n */\n blob: 'blob',\n /**\n * Impossible value (`never`).\n */\n never: 'never',\n} as const satisfies Record<SchemaType, SchemaType>\n"],"mappings":";;;;AAKA,MAAa,YAAY;CACvB,OAAO;CACP,WAAW;CACX,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;CACV,aAAa;CACb,SAAS;CACT,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,UAAU;CACV,eAAe;CACf,MAAM;CACN,OAAO;CACP,KAAK;AACP;;;;;;AAOA,MAAa,cAAc;;;;CAIzB,QAAQ;;;;CAIR,QAAQ;;;;CAIR,SAAS;;;;CAIT,QAAQ;;;;CAIR,SAAS;;;;CAIT,MAAM;;;;CAIN,KAAK;;;;CAIL,SAAS;;;;CAIT,MAAM;;;;CAIN,QAAQ;;;;CAIR,OAAO;;;;CAIP,OAAO;;;;CAIP,OAAO;;;;CAIP,cAAc;;CAEd,KAAK;;;;CAIL,MAAM;;;;CAIN,KAAK;;;;CAIL,MAAM;;;;CAIN,UAAU;;;;CAIV,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;;;;CAIP,KAAK;;;;CAIL,MAAM;;;;CAIN,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;AACT"}
1
+ {"version":3,"file":"constants-DztHlVmY.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { SchemaType } from './nodes/schema.ts'\n\n/**\n * Node kind discriminators used by every AST node (for example `node.kind === nodeKinds.text`).\n */\nexport const nodeKinds = {\n input: 'Input',\n operation: 'Operation',\n schema: 'Schema',\n property: 'Property',\n parameter: 'Parameter',\n response: 'Response',\n requestBody: 'RequestBody',\n content: 'Content',\n type: 'Type',\n file: 'File',\n import: 'Import',\n export: 'Export',\n source: 'Source',\n const: 'Const',\n function: 'Function',\n arrowFunction: 'ArrowFunction',\n text: 'Text',\n break: 'Break',\n jsx: 'Jsx',\n} as const\n\n/**\n * Schema type discriminators used by all AST schema nodes.\n *\n * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).\n */\nexport const schemaTypes = {\n /**\n * Text value.\n */\n string: 'string',\n /**\n * Floating-point number (`float`, `double`).\n */\n number: 'number',\n /**\n * Whole number (`int32`). Use `bigint` for `int64`.\n */\n integer: 'integer',\n /**\n * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.\n */\n bigint: 'bigint',\n /**\n * Boolean value.\n */\n boolean: 'boolean',\n /**\n * Explicit null value.\n */\n null: 'null',\n /**\n * Any value (no type restriction).\n */\n any: 'any',\n /**\n * Unknown value (must be narrowed before usage).\n */\n unknown: 'unknown',\n /**\n * No return value (`void`).\n */\n void: 'void',\n /**\n * Object with named properties.\n */\n object: 'object',\n /**\n * Sequential list of items.\n */\n array: 'array',\n /**\n * Fixed-length list with position-specific items.\n */\n tuple: 'tuple',\n /**\n * \"One of\" multiple schema members.\n */\n union: 'union',\n /**\n * \"All of\" multiple schema members.\n */\n intersection: 'intersection',\n /** \"Not\" a single schema member. */\n not: 'not',\n /**\n * Enum schema.\n */\n enum: 'enum',\n /**\n * Reference to another schema.\n */\n ref: 'ref',\n /**\n * Calendar date (for example `2026-03-24`).\n */\n date: 'date',\n /**\n * Date-time value (for example `2026-03-24T09:00:00Z`).\n */\n datetime: 'datetime',\n /**\n * Time-only value (for example `09:00:00`).\n */\n time: 'time',\n /**\n * UUID value.\n */\n uuid: 'uuid',\n /**\n * Email address value.\n */\n email: 'email',\n /**\n * URL value.\n */\n url: 'url',\n /**\n * IPv4 address value.\n */\n ipv4: 'ipv4',\n /**\n * IPv6 address value.\n */\n ipv6: 'ipv6',\n /**\n * Binary/blob value.\n */\n blob: 'blob',\n /**\n * Impossible value (`never`).\n */\n never: 'never',\n} as const satisfies Record<SchemaType, SchemaType>\n"],"mappings":";;;;AAKA,MAAa,YAAY;CACvB,OAAO;CACP,WAAW;CACX,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;CACV,aAAa;CACb,SAAS;CACT,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,UAAU;CACV,eAAe;CACf,MAAM;CACN,OAAO;CACP,KAAK;AACP;;;;;;AAOA,MAAa,cAAc;;;;CAIzB,QAAQ;;;;CAIR,QAAQ;;;;CAIR,SAAS;;;;CAIT,QAAQ;;;;CAIR,SAAS;;;;CAIT,MAAM;;;;CAIN,KAAK;;;;CAIL,SAAS;;;;CAIT,MAAM;;;;CAIN,QAAQ;;;;CAIR,OAAO;;;;CAIP,OAAO;;;;CAIP,OAAO;;;;CAIP,cAAc;;CAEd,KAAK;;;;CAIL,MAAM;;;;CAIN,KAAK;;;;CAIL,MAAM;;;;CAIN,UAAU;;;;CAIV,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;;;;CAIP,KAAK;;;;CAIL,MAAM;;;;CAIN,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;AACT"}
package/dist/factory.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_schema = require("./schema-hxMlgCrV.cjs");
3
- const require_file = require("./file-Cg0T6cgz.cjs");
4
- const require_nodes = require("./nodes-BB60Bq2H.cjs");
2
+ const require_schema = require("./schema-gSjYgaCl.cjs");
3
+ const require_file = require("./file-Dz1HPMld.cjs");
4
+ const require_nodes = require("./nodes-BT2Ocq0x.cjs");
5
5
  exports.createArrowFunction = require_nodes.createArrowFunction;
6
6
  exports.createBreak = require_nodes.createBreak;
7
7
  exports.createConst = require_nodes.createConst;
@@ -1,4 +1,4 @@
1
- import { C as createJsx, S as createFunction, T as createType, a as UserFileNode, b as createBreak, c as createImport, l as createSource, o as createExport, s as createFile, w as createText, x as createConst, y as createArrowFunction } from "./file-BVqSiSvV.cjs";
2
- import { Y as createSchema, Z as createProperty, a as createOperation, d as createRequestBody, h as createParameter, k as createInput, l as createResponse, y as createContent } from "./operation-X7chCdL2.cjs";
3
- import { t as Node } from "./index-DSVef1pp.cjs";
1
+ import { C as createJsx, S as createFunction, T as createType, a as UserFileNode, b as createBreak, c as createImport, l as createSource, o as createExport, s as createFile, w as createText, x as createConst, y as createArrowFunction } from "./file-KunZhFIV.cjs";
2
+ import { Y as createSchema, Z as createProperty, a as createOperation, d as createRequestBody, h as createParameter, k as createInput, l as createResponse, y as createContent } from "./operation-BUhPuZMY.cjs";
3
+ import { t as Node } from "./index-ss1YqjpW.cjs";
4
4
  export { Node, type UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
package/dist/factory.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as createJsx, S as createFunction, T as createType, a as UserFileNode, b as createBreak, c as createImport, l as createSource, o as createExport, s as createFile, w as createText, x as createConst, y as createArrowFunction } from "./file-xJnBQPGq.js";
2
- import { Y as createSchema, Z as createProperty, a as createOperation, d as createRequestBody, h as createParameter, k as createInput, l as createResponse, y as createContent } from "./operation-BgRyVS7z.js";
3
- import { t as Node } from "./index-BwnMIoLl.js";
1
+ import { C as createJsx, S as createFunction, T as createType, a as UserFileNode, b as createBreak, c as createImport, l as createSource, o as createExport, s as createFile, w as createText, x as createConst, y as createArrowFunction } from "./file-DkFGn_Os.js";
2
+ import { Y as createSchema, Z as createProperty, a as createOperation, d as createRequestBody, h as createParameter, k as createInput, l as createResponse, y as createContent } from "./operation-jxEr2No4.js";
3
+ import { t as Node } from "./index-Be5d4Zcl.js";
4
4
  export { Node, type UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
package/dist/factory.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createSchema } from "./schema-2ZAQk7qE.js";
2
- import { i as createSource, n as createFile, r as createImport, t as createExport } from "./file-CnuL8oUj.js";
3
- import { a as createOperation, c as createContent, d as createConst, f as createFunction, h as createType, i as createParameter, l as createArrowFunction, m as createText, n as createResponse, o as createRequestBody, p as createJsx, r as createProperty, s as createInput, u as createBreak } from "./nodes-CWMa9xhW.js";
1
+ import { t as createSchema } from "./schema-tH14gE6i.js";
2
+ import { i as createSource, n as createFile, r as createImport, t as createExport } from "./file-DUFttt26.js";
3
+ import { a as createOperation, c as createContent, d as createConst, f as createFunction, h as createType, i as createParameter, l as createArrowFunction, m as createText, n as createResponse, o as createRequestBody, p as createJsx, r as createProperty, s as createInput, u as createBreak } from "./nodes-CwYIFVt5.js";
4
4
  export { createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
@@ -1,14 +1,14 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_constants = require("./constants-CquR083U.cjs");
3
- const require_file = require("./file-Cg0T6cgz.cjs");
4
- const require_nodeText = require("./nodeText-DRb_rVd1.cjs");
2
+ const require_constants = require("./constants-DztHlVmY.cjs");
3
+ const require_file = require("./file-Dz1HPMld.cjs");
4
+ const require_nodeText = require("./nodeText-CZ7wgxu9.cjs");
5
5
  // src/utils/inline.ts
6
6
  /**
7
- * Replaces every name a file imports from a virtual file (one whose sources are all inline, so it is never written) with that name's
8
- * `inline.expression`, until no inline names are left. The definitions' own imports move to the importing file.
7
+ * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's
8
+ * declaration, until no inline names are left. The definitions' own imports move to the importing file.
9
9
  */
10
10
  function inlineFiles(files, { language }) {
11
- const virtualFiles = new Map(files.filter((file) => file.sources.length > 0 && file.sources.every((source) => source.inline)).map((file) => [file.path, file]));
11
+ const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]));
12
12
  const result = {
13
13
  files: [],
14
14
  virtualPaths: [...virtualFiles.keys()],
@@ -27,8 +27,8 @@ function inlineFiles(files, { language }) {
27
27
  return definition ?? void 0;
28
28
  }
29
29
  const file = virtualFiles.get(path);
30
- const inline = file.sources.find((source) => source.name === name)?.inline;
31
- if (!inline) {
30
+ const expression = bodyOf(file.sources.find((source) => source.name === name));
31
+ if (expression === void 0) {
32
32
  result.problems.push({
33
33
  path: from,
34
34
  message: `"${name}" is imported from "${path}", which never writes it and has no inline definition for it.`
@@ -37,7 +37,7 @@ function inlineFiles(files, { language }) {
37
37
  }
38
38
  definitions.set(key, null);
39
39
  const imports = [];
40
- const { text, used } = replaceNames(inline.expression, file, lang, imports);
40
+ const { text, used } = replaceNames(expression, file, lang, imports);
41
41
  imports.push(...file.imports.flatMap((imp) => virtualFiles.has(imp.path) ? [] : pickNames(imp, used)));
42
42
  const definition = {
43
43
  expression: text,
@@ -102,6 +102,15 @@ function inlineFiles(files, { language }) {
102
102
  }
103
103
  return result;
104
104
  }
105
+ function isInlineFile(file) {
106
+ return !!file.inline || file.sources.length > 0 && file.sources.every((source) => source.inline);
107
+ }
108
+ function bodyOf(source) {
109
+ if (source?.inline) return source.inline.expression;
110
+ const node = source?.nodes?.length === 1 ? source.nodes[0] : void 0;
111
+ if (node?.kind !== require_constants.nodeKinds.const && node?.kind !== require_constants.nodeKinds.type) return void 0;
112
+ return require_nodeText.getNodeText(node.nodes) || void 0;
113
+ }
105
114
  function pickNames(imp, used) {
106
115
  if (!Array.isArray(imp.name)) return used.has(imp.name) ? [imp] : [];
107
116
  const name = imp.name.filter((item) => used.has(require_file.importLocalName(item)));
@@ -139,4 +148,4 @@ Object.defineProperty(exports, "inlineFiles", {
139
148
  }
140
149
  });
141
150
 
142
- //# sourceMappingURL=file-Dd50jPkH.cjs.map
151
+ //# sourceMappingURL=file-BAICym_L.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-BAICym_L.cjs","names":["importLocalName","createFile","nodeKinds","getNodeText","CODE_NODE_TEXT_FIELDS"],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { importLocalName } from './combineFileMembers.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\ntype InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\ntype InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, imports)\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n imports.push(...definition.imports)\n return lang.wrap(definition.expression)\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && [imp.name].flat().find((item) => importLocalName(item) === local)\n if (item) return { path: imp.path, name: typeof item === 'string' ? item : item.propertyName }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n if (!Array.isArray(imp.name)) return used.has(imp.name) ? [imp] : []\n const name = imp.name.filter((item) => used.has(importLocalName(item)))\n return name.length > 0 ? [{ ...imp, name }] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { inlineFiles as inline } from '../utils/inline.ts'\n"],"mappings":";;;;;;;;;AAiDA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAA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AAA,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
@@ -1,9 +1,9 @@
1
1
  import "./rolldown-runtime-BYyVTPww.js";
2
- import { t as nodeKinds } from "./constants-Ckeonm-D.js";
3
- import { t as memo } from "./promise-RpnEev9D.js";
4
- import { n as getNodeText } from "./nodeText-DVVDZQjF.js";
5
- import path from "node:path";
6
2
  import { hash } from "node:crypto";
3
+ import path from "node:path";
4
+ import { t as nodeKinds } from "./constants-BTTus9ee.js";
5
+ import { t as memo } from "./promise-B3YkZ4C8.js";
6
+ import { n as getNodeText } from "./nodeText-BSYvDZOH.js";
7
7
  // src/utils/combineFileMembers.ts
8
8
  /**
9
9
  * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and
@@ -24,13 +24,23 @@ function importLocalName(item) {
24
24
  return typeof item === "string" ? item : item.name ?? item.propertyName;
25
25
  }
26
26
  /**
27
+ * Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every
28
+ * merge, and the path math dominated that sort on large specs. Two levels keep the existing strings
29
+ * as keys, so lookups reuse their hashes instead of hashing a new joined key each time.
30
+ */
31
+ const specifierCache = memo.create({ max: 1e4 });
32
+ /**
27
33
  * Returns the specifier a member is written with: POSIX and relative to the importing file when it
28
34
  * has a `root`, like `getRelativePath` in parser-ts. Sorting on it keeps the order the same on every OS.
29
35
  */
30
36
  function specifier(node) {
31
- if (!node.root) return node.path;
32
- const relative = path.relative(path.dirname(node.root), node.path).replaceAll("\\", "/");
33
- return relative.startsWith("../") ? relative : `./${relative}`;
37
+ const { root, path: target } = node;
38
+ if (!root) return target;
39
+ const byPath = memo(specifierCache, root, () => /* @__PURE__ */ new Map());
40
+ return memo(byPath, target, () => {
41
+ const relative = path.relative(path.dirname(root), target).replaceAll("\\", "/");
42
+ return relative.startsWith("../") ? relative : `./${relative}`;
43
+ });
34
44
  }
35
45
  /**
36
46
  * Computes a multi-level sort key for exports and imports:
@@ -81,14 +91,14 @@ function mergeByPath(result) {
81
91
  };
82
92
  }
83
93
  /**
84
- * Deduplicates `SourceNode` objects by `name + isExportable + isTypeOnly`, keeping the first of each
94
+ * Deduplicates `SourceNode` objects by `name + export + isTypeOnly`, keeping the first of each
85
95
  * key. An unnamed source only drops when the same node appears twice, so markdown can repeat a
86
96
  * paragraph or a table. Returns the deduplicated array in original order.
87
97
  */
88
98
  function combineSources(sources) {
89
99
  const seen = /* @__PURE__ */ new Set();
90
100
  return sources.filter((source) => {
91
- const key = source.name != null ? `${source.name}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}` : source;
101
+ const key = source.name != null ? `${source.name}:${source.export ?? source.isExportable ?? false}:${source.isTypeOnly ?? false}` : source;
92
102
  if (seen.has(key)) return false;
93
103
  seen.add(key);
94
104
  return true;
@@ -198,7 +208,7 @@ const createExport = nodeFactory(nodeKinds.export);
198
208
  *
199
209
  * @example
200
210
  * ```ts
201
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
211
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
202
212
  * ```
203
213
  */
204
214
  const createSource = nodeFactory(nodeKinds.source);
@@ -280,4 +290,4 @@ function createFile(input) {
280
290
  }
281
291
  export { nodeFactory as a, createSource as i, createFile as n, importLocalName as o, createImport as r, createExport as t };
282
292
 
283
- //# sourceMappingURL=file-CnuL8oUj.js.map
293
+ //# sourceMappingURL=file-DUFttt26.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-DUFttt26.js","names":[],"sources":["../src/utils/combineFileMembers.ts","../src/nodes/base.ts","../src/nodes/file.ts"],"sourcesContent":["/**\n * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and\n * export entries of one file, while `combineSources` deduplicates source entries in original order.\n * `combineImports` also drops imports nothing references. This works on a file's members, not on\n * schema content.\n */\nimport path from 'node:path'\nimport { memo } from '@internals/utils'\nimport type { ExportNode, ImportNode, SourceNode } from '../nodes/file.ts'\n\nconst IDENTIFIER_RUN = /[\\w$]+/g\n\n/**\n * How many imports a file needs before indexing the source beats scanning it once per name.\n */\nconst INDEX_ABOVE_IMPORTS = 128\n\ntype ImportNameItem = string | { propertyName: string; name?: string }\n\ntype FileMember = { name?: string | Array<unknown> | null; isTypeOnly?: boolean | null; path: string; root?: string | null }\n\n/**\n * Returns the local binding an import name item introduces: the alias when there is one, else the\n * imported name.\n */\nexport function importLocalName(item: ImportNameItem): string {\n return typeof item === 'string' ? item : (item.name ?? item.propertyName)\n}\n\n/**\n * Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every\n * merge, and the path math dominated that sort on large specs. Two levels keep the existing strings\n * as keys, so lookups reuse their hashes instead of hashing a new joined key each time.\n */\nconst specifierCache = memo.create<string, Map<string, string>>({ max: 10_000 })\n\n/**\n * Returns the specifier a member is written with: POSIX and relative to the importing file when it\n * has a `root`, like `getRelativePath` in parser-ts. Sorting on it keeps the order the same on every OS.\n */\nfunction specifier(node: FileMember): string {\n const { root, path: target } = node\n if (!root) return target\n const byPath = memo(specifierCache, root, () => new Map<string, string>())\n return memo(byPath, target, () => {\n const relative = path.relative(path.dirname(root), target).replaceAll('\\\\', '/')\n return relative.startsWith('../') ? relative : `./${relative}`\n })\n}\n\n/**\n * Computes a multi-level sort key for exports and imports:\n * non-array names first (wildcards/namespace aliases). Type-only before value. Alphabetical specifier. Unnamed before named.\n */\nfunction sortKey(node: FileMember): string {\n const isArray = Array.isArray(node.name) ? '1' : '0'\n const typeOnly = node.isTypeOnly ? '0' : '1'\n const hasName = node.name != null ? '1' : '0'\n const name = Array.isArray(node.name) ? node.name.toSorted().join('\\0') : (node.name ?? '')\n return `${isArray}:${typeOnly}:${specifier(node)}:${hasName}:${name}`\n}\n\n/**\n * Sorts members by {@link sortKey}. Keys are computed once per node, not per comparison.\n */\nfunction sortMembers<TNode extends FileMember>(nodes: Array<TNode>): Array<TNode> {\n return nodes\n .map((node) => ({ node, key: sortKey(node) }))\n .sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n .map(({ node }) => node)\n}\n\n/**\n * Returns a collector for array-named members. A member whose path and `isTypeOnly` were already\n * seen folds its names into that entry, otherwise it joins `result` as a new entry.\n */\nfunction mergeByPath<TNode extends FileMember>(result: Array<TNode>): (member: { node: TNode; names: Array<unknown> }) => void {\n // Append new names instead of rebuilding the list, which went quadratic on a shared path.\n const byPath = new Map<string, { names: Array<unknown>; seen: Set<unknown> }>()\n\n return ({ node, names }) => {\n const key = `${node.path}:${node.isTypeOnly ?? false}`\n const existing = byPath.get(key)\n\n if (existing) {\n for (const name of names) {\n if (existing.seen.has(name)) continue\n existing.seen.add(name)\n existing.names.push(name)\n }\n return\n }\n\n const item = { ...node, name: [...names] }\n result.push(item)\n byPath.set(key, { names: item.name, seen: new Set(names) })\n }\n}\n\n/**\n * Deduplicates `SourceNode` objects by `name + export + isTypeOnly`, keeping the first of each\n * key. An unnamed source only drops when the same node appears twice, so markdown can repeat a\n * paragraph or a table. Returns the deduplicated array in original order.\n */\nexport function combineSources(sources: Array<SourceNode>): Array<SourceNode> {\n const seen = new Set<SourceNode | string>()\n return sources.filter((source) => {\n const key = source.name != null ? `${source.name}:${source.export ?? source.isExportable ?? false}:${source.isTypeOnly ?? false}` : source\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\n/**\n * Deduplicates and merges `ExportNode` objects by path and type.\n *\n * Named exports with the same path and `isTypeOnly` flag have their names merged into a single export.\n * Non-array exports are deduplicated by exact identity. Returns a sorted, deduplicated array.\n */\nexport function combineExports(exports: Array<ExportNode>): Array<ExportNode> {\n const result: Array<ExportNode> = []\n const merge = mergeByPath(result)\n // Deduplicates non-array exports by their exact identity\n const seen = new Set<string>()\n\n for (const curr of sortMembers(exports)) {\n const { name, path, isTypeOnly, asAlias } = curr\n\n if (Array.isArray(name)) {\n if (name.length) merge({ node: curr, names: [...new Set(name)] })\n continue\n }\n\n const key = `${path}:${name ?? ''}:${isTypeOnly ?? false}:${asAlias ?? ''}`\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n\n return result\n}\n\n/**\n * Deduplicates and merges `ImportNode` objects, filtering out unused imports.\n *\n * Retains imports that are referenced in `source` or re-exported. Imports with the same path and\n * `isTypeOnly` flag have their names merged. Returns a sorted, deduplicated, filtered array.\n */\nexport function combineImports(imports: Array<ImportNode>, exports: Array<ExportNode>, source?: string): Array<ImportNode> {\n // Build a lookup of all exported names to retain imports that are re-exported\n const exportedNames = new Set(exports.flatMap((e) => (Array.isArray(e.name) ? e.name : e.name ? [e.name] : [])))\n // `createFile` re-runs on every merge into a file, so scanning the source once per import name\n // costs a heavily merged file that scan again for every fragment it already holds. Indexing pays\n // for itself there, and costs more than it saves on the small files the default output produces.\n const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? new Set(source.match(IDENTIFIER_RUN)) : null\n\n // A name in the index is used. One that is not still might be, inside a longer identifier, so the\n // substring test stays behind it.\n const isUsed = (importName: string): boolean => !source || identifiers?.has(importName) || source.includes(importName) || exportedNames.has(importName)\n\n // Memoize object import names so the same logical (propertyName, name) pair always\n // reuses the same object reference. Set-based deduplication then works correctly.\n const importNameMemo = memo.create<string, ImportNameItem>()\n const canonicalizeName = (n: ImportNameItem): ImportNameItem => {\n if (typeof n === 'string') return n\n const key = `${n.propertyName}:${n.name ?? ''}`\n return memo(importNameMemo, key, () => n)\n }\n\n // Paths that keep at least one used named import. A default import from such a path is retained\n // even when its binding can't be found in `source` e.g. a generated `client` default import\n // alongside `import type { Client } from <same path>`, where merged grouped output omits the body.\n const pathsWithUsedNamedImport = new Set<string>()\n for (const node of imports) {\n if (Array.isArray(node.name) && node.name.some((item) => isUsed(importLocalName(item)))) {\n pathsWithUsedNamedImport.add(node.path)\n }\n }\n\n const result: Array<ImportNode> = []\n const merge = mergeByPath(result)\n // Deduplicates non-array imports by their exact identity\n const seen = new Set<string>()\n\n for (const curr of sortMembers(imports)) {\n if (curr.path === curr.root) continue\n\n const { name, path, isTypeOnly } = curr\n\n if (Array.isArray(name)) {\n const names = [...new Set(name.map(canonicalizeName))].filter((item) => isUsed(importLocalName(item)))\n if (names.length) merge({ node: curr, names })\n continue\n }\n\n if (!isUsed(name) && !pathsWithUsedNamedImport.has(path)) continue\n\n const key = `${path}:${name}:${isTypeOnly ?? false}`\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n\n return result\n}\n","import type { ValueOf } from '@internals/utils'\nimport type { nodeKinds } from '../constants.ts'\n\n/**\n * `kind` values used by AST nodes.\n *\n * @example\n * ```ts\n * const kind: NodeKind = 'Schema'\n * ```\n */\nexport type NodeKind = ValueOf<typeof nodeKinds>\n\n/**\n * Base shape shared by all AST nodes.\n *\n * @example\n * ```ts\n * const base: BaseNode = { kind: 'Input' }\n * ```\n */\nexport type BaseNode = {\n /**\n * Node discriminator.\n */\n kind: NodeKind\n /**\n * Where the node comes from in the input, in the form the adapter's `locate` reads. Document\n * adapters such as OpenAPI and AsyncAPI use an RFC 6901 JSON pointer, for example\n * `#/components/schemas/Pet`. Plugins can copy it to the code nodes they emit.\n */\n pointer?: string\n}\n\n/** `Omit` applied to each member of a union, so the union survives. */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** Builds a `createX` factory for a node whose only computed field is `kind`. */\nexport function nodeFactory<T extends BaseNode>(kind: T['kind']): (input: Omit<T, 'kind'>) => T {\n return (input) => {\n const node = { ...input, kind }\n return node as T\n }\n}\n","import { hash } from 'node:crypto'\nimport path from 'node:path'\nimport { nodeKinds } from '../constants.ts'\nimport { combineExports, combineImports, combineSources, importLocalName } from '../utils/combineFileMembers.ts'\nimport { getNodeText } from '../utils/nodeText.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { CodeNode } from './code.ts'\n\n/**\n * Supported file extensions.\n */\ntype Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\ntype ImportName = string | Array<string | { propertyName: string; name?: string }>\n\n/**\n * Represents a language-agnostic import/dependency declaration.\n *\n * @example Named import (TypeScript: `import { useState } from 'react'`)\n * ```ts\n * createImport({ name: ['useState'], path: 'react' })\n * ```\n *\n * @example Default import (TypeScript: `import React from 'react'`)\n * ```ts\n * createImport({ name: 'React', path: 'react' })\n * ```\n *\n * @example Type-only import (TypeScript: `import type { FC } from 'react'`)\n * ```ts\n * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })\n * ```\n *\n * @example Namespace import (TypeScript: `import * as React from 'react'`)\n * ```ts\n * createImport({ name: 'React', path: 'react', isNameSpace: true })\n * ```\n */\nexport type ImportNode = BaseNode & {\n kind: 'Import'\n /**\n * Import name(s) to be used.\n *\n * @example Named imports\n * `['useState']`\n *\n * @example Default import\n * `'React'`\n */\n name: ImportName\n /**\n * Path for the import.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only import prefix.\n * - `true` generates `import type { Type } from './path'`\n * - `false` generates `import { Type } from './path'`\n */\n isTypeOnly?: boolean | null\n /**\n * Import the entire module as a namespace.\n * - `true` generates `import * as Name from './path'`\n * - `false` generates a standard import\n */\n isNameSpace?: boolean | null\n /**\n * When set, the import path is resolved relative to this root.\n */\n root?: string | null\n}\n\n/**\n * Represents a language-agnostic export/public API declaration.\n *\n * @example Named export (TypeScript: `export { Pets } from './Pets'`)\n * ```ts\n * createExport({ name: ['Pets'], path: './Pets' })\n * ```\n *\n * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)\n * ```ts\n * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })\n * ```\n *\n * @example Wildcard export (TypeScript: `export * from './utils'`)\n * ```ts\n * createExport({ path: './utils' })\n * ```\n *\n * @example Namespace alias (TypeScript: `export * as utils from './utils'`)\n * ```ts\n * createExport({ name: 'utils', path: './utils', asAlias: true })\n * ```\n */\nexport type ExportNode = BaseNode & {\n kind: 'Export'\n /**\n * Export name(s) to be used. When omitted, generates a wildcard export.\n *\n * @example Named exports\n * `['useState']`\n *\n * @example Single export\n * `'React'`\n */\n name?: string | Array<string> | null\n /**\n * Path for the export.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only export prefix.\n * - `true` generates `export type { Type } from './path'`\n * - `false` generates `export { Type } from './path'`\n */\n isTypeOnly?: boolean | null\n /**\n * Export as an aliased namespace.\n * - `true` generates `export * as aliasName from './path'`\n * - `false` generates a standard export\n */\n asAlias?: boolean | null\n}\n\n/**\n * Represents a fragment of source code within a file.\n *\n * @example Named exportable source\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n *\n * @example Inline unnamed code block\n * ```ts\n * createSource({ nodes: [createText('const x = 1')] })\n * ```\n */\nexport type SourceNode = BaseNode & {\n kind: 'Source'\n /**\n * Optional name identifying this source (used for deduplication and barrel generation).\n */\n name?: string | null\n /**\n * Mark this source as a type-only export.\n */\n isTypeOnly?: boolean | null\n /**\n * Mark this source as an exported declaration, which barrels list. The source text carries its own `export` keyword.\n */\n export?: boolean | null\n /**\n * Mark this exported source as the module's default export. Barrels skip it, since they can't re-export it by name.\n */\n default?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isExportable?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isIndexable?: boolean | null\n /**\n * Marks the source as a definition that importing files absorb instead of import. `expression` is\n * the declaration's right-hand side, such as `{ body: Pet }`.\n *\n * @deprecated Set `inline` on the file. Removed in Kubb v6.\n */\n inline?: { expression: string } | null\n /**\n * Child nodes that make up this source fragment, in DOM order.\n * Use a {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * Represents a fully resolved file in the AST.\n *\n * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input\n * and deduplicates `imports`, `exports`, and `sources`.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of the path\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n */\nexport type FileNode<TMeta extends object = object> = BaseNode & {\n kind: 'File'\n /**\n * Unique identifier derived from a SHA256 hash of the file path. `createFile`\n * computes it, so callers do not need to provide it.\n */\n id: string\n /**\n * File name without extension, derived from `baseName`.\n *\n * @see https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n /**\n * File base name, including extension, shaped like `${name}${extname}`.\n *\n * @see https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: `${string}.${string}`\n /**\n * Full qualified path to the file.\n */\n path: string\n /**\n * File extension extracted from `baseName`.\n */\n extname: Extname\n /**\n * Deduplicated list of source code fragments.\n */\n sources: Array<SourceNode>\n /**\n * Deduplicated list of import declarations.\n */\n imports: Array<ImportNode>\n /**\n * Deduplicated list of export declarations.\n */\n exports: Array<ExportNode>\n /**\n * Optional metadata attached to this file, read by plugins during barrel generation.\n */\n meta?: TMeta\n /**\n * Optional banner prepended to the generated file content.\n * Accepts `null` so `resolver.default.banner()` results can be passed directly.\n */\n banner?: string | null\n /**\n * Optional footer appended to the generated file content.\n * Accepts `null` so `resolver.default.footer()` results can be passed directly.\n */\n footer?: string | null\n /**\n * Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has one.\n *\n * Use to emit a real source file shipped inside a package (a template) into the generated\n * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for\n * output; `sources` may still carry `name`/`export` so barrel generation\n * treats the file the same as a rendered one.\n */\n copy?: string | null\n /**\n * Marks a file that is never written. Each file that imports from it gets the body of each imported declaration, such as `{ body: Pet }`, in place of its name.\n */\n inline?: boolean | null\n}\n\n/**\n * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.\n *\n * @example Named import\n * ```ts\n * createImport({ name: ['useState'], path: 'react' })\n * // import { useState } from 'react'\n * ```\n */\nexport const createImport = nodeFactory<ImportNode>(nodeKinds.import)\n\n/**\n * Creates an `ExportNode` representing a language-agnostic export/public API declaration.\n *\n * @example Named export\n * ```ts\n * createExport({ name: ['Pet'], path: './Pet' })\n * // export { Pet } from './Pet'\n * ```\n */\nexport const createExport = nodeFactory<ExportNode>(nodeKinds.export)\n\n/**\n * Creates a `SourceNode` representing a fragment of source code within a file.\n *\n * @example\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n */\nexport const createSource = nodeFactory<SourceNode>(nodeKinds.source)\n\n/**\n * Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed\n * and `imports`/`exports`/`sources` are deduplicated.\n */\nexport type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> &\n Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>\n\n/**\n * Creates a fully resolved `FileNode` from a file input descriptor.\n *\n * Computes:\n * - `id` SHA256 hash of the file path\n * - `name` `baseName` without extension\n * - `extname` extension extracted from `baseName`\n *\n * Deduplicates:\n * - `sources` via `combineSources`\n * - `exports` via `combineExports`\n * - `imports` via `combineImports` (also filters unused imports)\n *\n * @throws {Error} when `baseName` has no extension.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of 'src/models/petStore.ts'\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n *\n * @example Copy a real file into the output\n * ```ts\n * const file = createFile({\n * baseName: 'client.ts',\n * path: 'src/gen/client.ts',\n * copy: '/abs/path/to/templates/client.ts',\n * })\n * ```\n */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const extname = path.extname(input.baseName) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n // Skip building the source text and local-name set when there are no imports to resolve against them.\n const resolvedImports: Array<ImportNode> = (() => {\n if (!input.imports?.length) return []\n\n const sourceParts: Array<string> = []\n const localNames = new Set<string>()\n // Only the sources the file keeps count: an import used just by a dropped duplicate is unused.\n for (const item of resolvedSources) {\n const extracted = item.nodes && getNodeText(item.nodes)\n if (extracted) sourceParts.push(extracted)\n if (item.name) localNames.add(item.name)\n }\n const source = sourceParts.join('\\n') || undefined\n const combinedImports = combineImports(input.imports, resolvedExports, source)\n // Consolidating output (`mode: 'file'`) can put a symbol's definition and an import of it in the\n // same file: by path when the import still targets this file, by name when consolidation moved it.\n return combinedImports.flatMap((imp) => {\n if (imp.path === input.path) return []\n if (!Array.isArray(imp.name)) {\n return typeof imp.name === 'string' && localNames.has(imp.name) ? [] : [imp]\n }\n const kept = imp.name.filter((item) => !localNames.has(importLocalName(item)))\n\n if (!kept.length) return []\n return [kept.length === imp.name.length ? imp : { ...imp, name: kept }]\n })\n })()\n\n return {\n ...input,\n kind: nodeKinds.file,\n id: hash('sha256', input.path, 'hex'),\n name: path.basename(input.baseName, extname),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,\n sources: resolvedSources,\n meta: (input.meta ?? {}) as TMeta,\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,MAAM,iBAAiB;;;;A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,YAAY,KAAK,IAAI,KAAK,KAAA;EAIzC,OAHwB,eAAe,MAAM,SAAS,iBAAiB,MAGlD,CAAC,CAAC,SAAS,QAAQ;GACtC,IAAI,IAAI,SAAS,MAAM,MAAM,OAAO,CAAC;GACrC,IAAI,CAAC,MAAM,QAAQ,IAAI,IAAI,GACzB,OAAO,OAAO,IAAI,SAAS,YAAY,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG;GAE7E,MAAM,OAAO,IAAI,KAAK,QAAQ,SAAS,CAAC,WAAW,IAAI,gBAAgB,IAAI,CAAC,CAAC;GAE7E,IAAI,CAAC,KAAK,QAAQ,OAAO,CAAC;GAC1B,OAAO,CAAC,KAAK,WAAW,IAAI,KAAK,SAAS,MAAM;IAAE,GAAG;IAAK,MAAM;GAAK,CAAC;EACxE,CAAC;CACH,EAAA,CAAG;CAEH,OAAO;EACL,GAAG;EACH,MAAM,UAAU;EAChB,IAAI,KAAK,UAAU,MAAM,MAAM,KAAK;EACpC,MAAM,KAAK,SAAS,MAAM,UAAU,OAAO;EAC3C;EACA,SAAS;EACT,SAAS;EACT,SAAS;EACT,MAAO,MAAM,QAAQ,CAAC;CACxB;AACF"}
@@ -1,14 +1,14 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
2
- import { t as nodeKinds } from "./constants-Ckeonm-D.js";
3
- import { n as createFile, o as importLocalName } from "./file-CnuL8oUj.js";
4
- import { t as CODE_NODE_TEXT_FIELDS } from "./nodeText-DVVDZQjF.js";
2
+ import { t as nodeKinds } from "./constants-BTTus9ee.js";
3
+ import { n as createFile, o as importLocalName } from "./file-DUFttt26.js";
4
+ import { n as getNodeText, t as CODE_NODE_TEXT_FIELDS } from "./nodeText-BSYvDZOH.js";
5
5
  // src/utils/inline.ts
6
6
  /**
7
- * Replaces every name a file imports from a virtual file (one whose sources are all inline, so it is never written) with that name's
8
- * `inline.expression`, until no inline names are left. The definitions' own imports move to the importing file.
7
+ * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's
8
+ * declaration, until no inline names are left. The definitions' own imports move to the importing file.
9
9
  */
10
10
  function inlineFiles(files, { language }) {
11
- const virtualFiles = new Map(files.filter((file) => file.sources.length > 0 && file.sources.every((source) => source.inline)).map((file) => [file.path, file]));
11
+ const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]));
12
12
  const result = {
13
13
  files: [],
14
14
  virtualPaths: [...virtualFiles.keys()],
@@ -27,8 +27,8 @@ function inlineFiles(files, { language }) {
27
27
  return definition ?? void 0;
28
28
  }
29
29
  const file = virtualFiles.get(path);
30
- const inline = file.sources.find((source) => source.name === name)?.inline;
31
- if (!inline) {
30
+ const expression = bodyOf(file.sources.find((source) => source.name === name));
31
+ if (expression === void 0) {
32
32
  result.problems.push({
33
33
  path: from,
34
34
  message: `"${name}" is imported from "${path}", which never writes it and has no inline definition for it.`
@@ -37,7 +37,7 @@ function inlineFiles(files, { language }) {
37
37
  }
38
38
  definitions.set(key, null);
39
39
  const imports = [];
40
- const { text, used } = replaceNames(inline.expression, file, lang, imports);
40
+ const { text, used } = replaceNames(expression, file, lang, imports);
41
41
  imports.push(...file.imports.flatMap((imp) => virtualFiles.has(imp.path) ? [] : pickNames(imp, used)));
42
42
  const definition = {
43
43
  expression: text,
@@ -102,6 +102,15 @@ function inlineFiles(files, { language }) {
102
102
  }
103
103
  return result;
104
104
  }
105
+ function isInlineFile(file) {
106
+ return !!file.inline || file.sources.length > 0 && file.sources.every((source) => source.inline);
107
+ }
108
+ function bodyOf(source) {
109
+ if (source?.inline) return source.inline.expression;
110
+ const node = source?.nodes?.length === 1 ? source.nodes[0] : void 0;
111
+ if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return void 0;
112
+ return getNodeText(node.nodes) || void 0;
113
+ }
105
114
  function pickNames(imp, used) {
106
115
  if (!Array.isArray(imp.name)) return used.has(imp.name) ? [imp] : [];
107
116
  const name = imp.name.filter((item) => used.has(importLocalName(item)));
@@ -128,4 +137,4 @@ function rewriteNodes(nodes, rewrite) {
128
137
  var file_exports = /* @__PURE__ */ __exportAll({ inline: () => inlineFiles });
129
138
  export { inlineFiles as n, file_exports as t };
130
139
 
131
- //# sourceMappingURL=file-CvlMAp_d.js.map
140
+ //# sourceMappingURL=file-Dj9lsbJu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-Dj9lsbJu.js","names":[],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { importLocalName } from './combineFileMembers.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\ntype InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\ntype InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, imports)\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n imports.push(...definition.imports)\n return lang.wrap(definition.expression)\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && [imp.name].flat().find((item) => importLocalName(item) === local)\n if (item) return { path: imp.path, name: typeof item === 'string' ? item : item.propertyName }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n if (!Array.isArray(imp.name)) return used.has(imp.name) ? [imp] : []\n const name = imp.name.filter((item) => used.has(importLocalName(item)))\n return name.length > 0 ? [{ ...imp, name }] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { inlineFiles as inline } from '../utils/inline.ts'\n"],"mappings":";;;;;;;;;AAiDA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;CACxF,MAAM,SAA4B;EAAE,OAAO,CAAC;EAAG,cAAc,CAAC,GAAG,aAAa,KAAK,CAAC;EAAG,UAAU,CAAC;CAAE;CACpG,IAAI,aAAa,SAAS,GAAG,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAA+B;CAEvD,SAAS,OAAO,MAAc,MAAc,MAAc,MAA8C;EACtG,MAAM,MAAM,GAAG,KAAK,IAAI;EACxB,IAAI,YAAY,IAAI,GAAG,GAAG;GACxB,MAAM,aAAa,YAAY,IAAI,GAAG;GACtC,IAAI,eAAe,MAAM,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,UAAU,KAAK;GAAkC,CAAC;GAChI,OAAO,cAAc,KAAA;EACvB;EAEA,MAAM,OAAO,aAAa,IAAI,IAAI;EAClC,MAAM,aAAa,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,CAAC;EAC7E,IAAI,eAAe,KAAA,GAAW;GAC5B,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,sBAAsB,KAAK;GAA+D,CAAC;GAChJ;EACF;EAEA,YAAY,IAAI,KAAK,IAAI;EACzB,MAAM,UAA6B,CAAC;EACpC,MAAM,EAAE,MAAM,SAAS,aAAa,YAAY,MAAM,MAAM,OAAO;EACnE,QAAQ,KAAK,GAAG,KAAK,QAAQ,SAAS,QAAS,aAAa,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,UAAU,KAAK,IAAI,CAAE,CAAC;EA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AmB;EAEpC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;EACjD,IAAI,KAAK,SAAS,UAAU,OAAO,OAAO;EAE1C,MAAM,OAAO,EAAE,GAAG,KAAK;EACvB,KAAK,MAAM,SAAS,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { t as BaseNode } from "./base-IpYuh3ZP.cjs";
1
+ import { t as BaseNode } from "./base-LhsPvVY1.js";
2
2
  /**
3
3
  * JSDoc documentation metadata attached to code declarations.
4
4
  */
@@ -78,6 +78,14 @@ type TypeNode = BaseNode & {
78
78
  * Whether the declaration should be exported.
79
79
  */
80
80
  export?: boolean | null;
81
+ /**
82
+ * How the declaration is written.
83
+ * - `'type'` declares `type Name = …`
84
+ * - `'interface'` declares `interface Name { … }`, so the body must be an object type
85
+ *
86
+ * @default 'type'
87
+ */
88
+ syntax?: 'type' | 'interface' | null;
81
89
  /**
82
90
  * JSDoc documentation metadata.
83
91
  */
@@ -426,7 +434,7 @@ type ExportNode = BaseNode & {
426
434
  *
427
435
  * @example Named exportable source
428
436
  * ```ts
429
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
437
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
430
438
  * ```
431
439
  *
432
440
  * @example Inline unnamed code block
@@ -445,16 +453,26 @@ type SourceNode = BaseNode & {
445
453
  */
446
454
  isTypeOnly?: boolean | null;
447
455
  /**
448
- * Mark this source as an exported declaration. The source text carries its own `export` keyword.
456
+ * Mark this source as an exported declaration, which barrels list. The source text carries its own `export` keyword.
457
+ */
458
+ export?: boolean | null;
459
+ /**
460
+ * Mark this exported source as the module's default export. Barrels skip it, since they can't re-export it by name.
461
+ */
462
+ default?: boolean | null;
463
+ /**
464
+ * @deprecated Use `export`. Removed in Kubb v6.
449
465
  */
450
466
  isExportable?: boolean | null;
451
467
  /**
452
- * Include this source in barrel/index file generation.
468
+ * @deprecated Use `export`. Removed in Kubb v6.
453
469
  */
454
470
  isIndexable?: boolean | null;
455
471
  /**
456
472
  * Marks the source as a definition that importing files absorb instead of import. `expression` is
457
473
  * the declaration's right-hand side, such as `{ body: Pet }`.
474
+ *
475
+ * @deprecated Set `inline` on the file. Removed in Kubb v6.
458
476
  */
459
477
  inline?: {
460
478
  expression: string;
@@ -476,7 +494,7 @@ type SourceNode = BaseNode & {
476
494
  * const file = createFile({
477
495
  * baseName: 'petStore.ts',
478
496
  * path: 'src/models/petStore.ts',
479
- * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
497
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })],
480
498
  * imports: [createImport({ name: ['z'], path: 'zod' })],
481
499
  * exports: [createExport({ name: ['Pet'], path: './petStore' })],
482
500
  * })
@@ -543,10 +561,14 @@ type FileNode<TMeta extends object = object> = BaseNode & {
543
561
  *
544
562
  * Use to emit a real source file shipped inside a package (a template) into the generated
545
563
  * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for
546
- * output; `sources` may still carry `name`/`isExportable`/`isIndexable` so barrel generation
564
+ * output; `sources` may still carry `name`/`export` so barrel generation
547
565
  * treats the file the same as a rendered one.
548
566
  */
549
567
  copy?: string | null;
568
+ /**
569
+ * Marks a file that is never written. Each file that imports from it gets the body of each imported declaration, such as `{ body: Pet }`, in place of its name.
570
+ */
571
+ inline?: boolean | null;
550
572
  };
551
573
  /**
552
574
  * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
@@ -573,7 +595,7 @@ declare const createExport: (input: Omit<ExportNode, "kind">) => ExportNode;
573
595
  *
574
596
  * @example
575
597
  * ```ts
576
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
598
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
577
599
  * ```
578
600
  */
579
601
  declare const createSource: (input: Omit<SourceNode, "kind">) => SourceNode;
@@ -1,10 +1,10 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_constants = require("./constants-CquR083U.cjs");
3
- const require_promise = require("./promise-BOdlgT0N.cjs");
4
- const require_nodeText = require("./nodeText-DRb_rVd1.cjs");
2
+ let node_crypto = require("node:crypto");
5
3
  let node_path = require("node:path");
4
+ const require_constants = require("./constants-DztHlVmY.cjs");
5
+ const require_promise = require("./promise-DScaykew.cjs");
6
+ const require_nodeText = require("./nodeText-CZ7wgxu9.cjs");
6
7
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
7
- let node_crypto = require("node:crypto");
8
8
  // src/utils/combineFileMembers.ts
9
9
  /**
10
10
  * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and
@@ -25,13 +25,23 @@ function importLocalName(item) {
25
25
  return typeof item === "string" ? item : item.name ?? item.propertyName;
26
26
  }
27
27
  /**
28
+ * Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every
29
+ * merge, and the path math dominated that sort on large specs. Two levels keep the existing strings
30
+ * as keys, so lookups reuse their hashes instead of hashing a new joined key each time.
31
+ */
32
+ const specifierCache = require_promise.memo.create({ max: 1e4 });
33
+ /**
28
34
  * Returns the specifier a member is written with: POSIX and relative to the importing file when it
29
35
  * has a `root`, like `getRelativePath` in parser-ts. Sorting on it keeps the order the same on every OS.
30
36
  */
31
37
  function specifier(node) {
32
- if (!node.root) return node.path;
33
- const relative = node_path.default.relative(node_path.default.dirname(node.root), node.path).replaceAll("\\", "/");
34
- return relative.startsWith("../") ? relative : `./${relative}`;
38
+ const { root, path: target } = node;
39
+ if (!root) return target;
40
+ const byPath = require_promise.memo(specifierCache, root, () => /* @__PURE__ */ new Map());
41
+ return require_promise.memo(byPath, target, () => {
42
+ const relative = node_path.default.relative(node_path.default.dirname(root), target).replaceAll("\\", "/");
43
+ return relative.startsWith("../") ? relative : `./${relative}`;
44
+ });
35
45
  }
36
46
  /**
37
47
  * Computes a multi-level sort key for exports and imports:
@@ -82,14 +92,14 @@ function mergeByPath(result) {
82
92
  };
83
93
  }
84
94
  /**
85
- * Deduplicates `SourceNode` objects by `name + isExportable + isTypeOnly`, keeping the first of each
95
+ * Deduplicates `SourceNode` objects by `name + export + isTypeOnly`, keeping the first of each
86
96
  * key. An unnamed source only drops when the same node appears twice, so markdown can repeat a
87
97
  * paragraph or a table. Returns the deduplicated array in original order.
88
98
  */
89
99
  function combineSources(sources) {
90
100
  const seen = /* @__PURE__ */ new Set();
91
101
  return sources.filter((source) => {
92
- const key = source.name != null ? `${source.name}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}` : source;
102
+ const key = source.name != null ? `${source.name}:${source.export ?? source.isExportable ?? false}:${source.isTypeOnly ?? false}` : source;
93
103
  if (seen.has(key)) return false;
94
104
  seen.add(key);
95
105
  return true;
@@ -199,7 +209,7 @@ const createExport = nodeFactory(require_constants.nodeKinds.export);
199
209
  *
200
210
  * @example
201
211
  * ```ts
202
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
212
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
203
213
  * ```
204
214
  */
205
215
  const createSource = nodeFactory(require_constants.nodeKinds.source);
@@ -316,4 +326,4 @@ Object.defineProperty(exports, "nodeFactory", {
316
326
  }
317
327
  });
318
328
 
319
- //# sourceMappingURL=file-Cg0T6cgz.cjs.map
329
+ //# sourceMappingURL=file-Dz1HPMld.cjs.map