@nubjs/nub-darwin-x64 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/bin/nub +0 -0
  2. package/bin/nubx +0 -0
  3. package/package.json +2 -3
  4. package/runtime/addons/nub-native.node +0 -0
  5. package/runtime/cache-evict.mjs +0 -69
  6. package/runtime/compile-cache-restore.mjs +0 -21
  7. package/runtime/floor-builtin.mjs +0 -57
  8. package/runtime/navigator-locks.mjs +0 -242
  9. package/runtime/navigator-shim.mjs +0 -144
  10. package/runtime/node_modules/@js-temporal/polyfill/CHANGELOG.md +0 -453
  11. package/runtime/node_modules/@js-temporal/polyfill/LICENSE +0 -13
  12. package/runtime/node_modules/@js-temporal/polyfill/README.md +0 -90
  13. package/runtime/node_modules/@js-temporal/polyfill/dist/index.cjs +0 -2
  14. package/runtime/node_modules/@js-temporal/polyfill/dist/index.cjs.map +0 -1
  15. package/runtime/node_modules/@js-temporal/polyfill/dist/index.esm.js +0 -2
  16. package/runtime/node_modules/@js-temporal/polyfill/dist/index.esm.js.map +0 -1
  17. package/runtime/node_modules/@js-temporal/polyfill/dist/index.umd.js +0 -2
  18. package/runtime/node_modules/@js-temporal/polyfill/dist/index.umd.js.map +0 -1
  19. package/runtime/node_modules/@js-temporal/polyfill/index.d.cts +0 -1215
  20. package/runtime/node_modules/@js-temporal/polyfill/index.d.ts +0 -1215
  21. package/runtime/node_modules/@js-temporal/polyfill/lib/assert.ts +0 -8
  22. package/runtime/node_modules/@js-temporal/polyfill/lib/bigintmath.ts +0 -39
  23. package/runtime/node_modules/@js-temporal/polyfill/lib/calendar.ts +0 -2424
  24. package/runtime/node_modules/@js-temporal/polyfill/lib/debug.ts +0 -7
  25. package/runtime/node_modules/@js-temporal/polyfill/lib/duration.ts +0 -438
  26. package/runtime/node_modules/@js-temporal/polyfill/lib/durationformat.d.ts +0 -93
  27. package/runtime/node_modules/@js-temporal/polyfill/lib/ecmascript.ts +0 -4973
  28. package/runtime/node_modules/@js-temporal/polyfill/lib/index.ts +0 -34
  29. package/runtime/node_modules/@js-temporal/polyfill/lib/init.ts +0 -43
  30. package/runtime/node_modules/@js-temporal/polyfill/lib/instant.ts +0 -138
  31. package/runtime/node_modules/@js-temporal/polyfill/lib/internaltypes.d.ts +0 -242
  32. package/runtime/node_modules/@js-temporal/polyfill/lib/intl.ts +0 -758
  33. package/runtime/node_modules/@js-temporal/polyfill/lib/intrinsicclass.ts +0 -162
  34. package/runtime/node_modules/@js-temporal/polyfill/lib/legacydate.ts +0 -17
  35. package/runtime/node_modules/@js-temporal/polyfill/lib/math.ts +0 -96
  36. package/runtime/node_modules/@js-temporal/polyfill/lib/now.ts +0 -48
  37. package/runtime/node_modules/@js-temporal/polyfill/lib/plaindate.ts +0 -212
  38. package/runtime/node_modules/@js-temporal/polyfill/lib/plaindatetime.ts +0 -274
  39. package/runtime/node_modules/@js-temporal/polyfill/lib/plainmonthday.ts +0 -110
  40. package/runtime/node_modules/@js-temporal/polyfill/lib/plaintime.ts +0 -154
  41. package/runtime/node_modules/@js-temporal/polyfill/lib/plainyearmonth.ts +0 -157
  42. package/runtime/node_modules/@js-temporal/polyfill/lib/regex.ts +0 -59
  43. package/runtime/node_modules/@js-temporal/polyfill/lib/slots.ts +0 -341
  44. package/runtime/node_modules/@js-temporal/polyfill/lib/temporal.ts +0 -10
  45. package/runtime/node_modules/@js-temporal/polyfill/lib/timeduration.ts +0 -149
  46. package/runtime/node_modules/@js-temporal/polyfill/lib/zoneddatetime.ts +0 -492
  47. package/runtime/node_modules/@js-temporal/polyfill/package.json +0 -143
  48. package/runtime/node_modules/@oxc-project/runtime/CHANGELOG.md +0 -88
  49. package/runtime/node_modules/@oxc-project/runtime/LICENSE +0 -22
  50. package/runtime/node_modules/@oxc-project/runtime/README.md +0 -5
  51. package/runtime/node_modules/@oxc-project/runtime/package.json +0 -1066
  52. package/runtime/node_modules/@oxc-project/runtime/src/helpers/AwaitValue.js +0 -4
  53. package/runtime/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js +0 -4
  54. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecoratedDescriptor.js +0 -9
  55. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs.js +0 -236
  56. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2203.js +0 -184
  57. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2203R.js +0 -191
  58. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2301.js +0 -222
  59. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2305.js +0 -133
  60. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2311.js +0 -124
  61. package/runtime/node_modules/@oxc-project/runtime/src/helpers/arrayLikeToArray.js +0 -6
  62. package/runtime/node_modules/@oxc-project/runtime/src/helpers/arrayWithHoles.js +0 -4
  63. package/runtime/node_modules/@oxc-project/runtime/src/helpers/arrayWithoutHoles.js +0 -5
  64. package/runtime/node_modules/@oxc-project/runtime/src/helpers/assertClassBrand.js +0 -5
  65. package/runtime/node_modules/@oxc-project/runtime/src/helpers/assertThisInitialized.js +0 -5
  66. package/runtime/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js +0 -24
  67. package/runtime/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js +0 -45
  68. package/runtime/node_modules/@oxc-project/runtime/src/helpers/asyncToGenerator.js +0 -26
  69. package/runtime/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js +0 -5
  70. package/runtime/node_modules/@oxc-project/runtime/src/helpers/callSuper.js +0 -7
  71. package/runtime/node_modules/@oxc-project/runtime/src/helpers/checkInRHS.js +0 -6
  72. package/runtime/node_modules/@oxc-project/runtime/src/helpers/checkPrivateRedeclaration.js +0 -4
  73. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classApplyDescriptorDestructureSet.js +0 -10
  74. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classApplyDescriptorGet.js +0 -4
  75. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classApplyDescriptorSet.js +0 -7
  76. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classCallCheck.js +0 -4
  77. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classCheckPrivateStaticAccess.js +0 -5
  78. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classCheckPrivateStaticFieldDescriptor.js +0 -4
  79. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classExtractFieldDescriptor.js +0 -5
  80. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classNameTDZError.js +0 -4
  81. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldDestructureSet.js +0 -7
  82. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldGet.js +0 -7
  83. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldGet2.js +0 -5
  84. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldInitSpec.js +0 -5
  85. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldLooseBase.js +0 -5
  86. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldLooseKey.js +0 -5
  87. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldSet.js +0 -7
  88. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldSet2.js +0 -5
  89. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateGetter.js +0 -5
  90. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodGet.js +0 -5
  91. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodInitSpec.js +0 -5
  92. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodSet.js +0 -4
  93. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateSetter.js +0 -5
  94. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateFieldDestructureSet.js +0 -7
  95. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateFieldSpecGet.js +0 -7
  96. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateFieldSpecSet.js +0 -7
  97. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateMethodGet.js +0 -5
  98. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateMethodSet.js +0 -4
  99. package/runtime/node_modules/@oxc-project/runtime/src/helpers/construct.js +0 -10
  100. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createClass.js +0 -13
  101. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createForOfIteratorHelper.js +0 -50
  102. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createForOfIteratorHelperLoose.js +0 -19
  103. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createSuper.js +0 -16
  104. package/runtime/node_modules/@oxc-project/runtime/src/helpers/decorate.js +0 -23
  105. package/runtime/node_modules/@oxc-project/runtime/src/helpers/decorateMetadata.js +0 -9
  106. package/runtime/node_modules/@oxc-project/runtime/src/helpers/decorateParam.js +0 -11
  107. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defaults.js +0 -9
  108. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defineAccessor.js +0 -8
  109. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defineEnumerableProperties.js +0 -12
  110. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js +0 -10
  111. package/runtime/node_modules/@oxc-project/runtime/src/helpers/dispose.js +0 -28
  112. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/AwaitValue.js +0 -4
  113. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/OverloadYield.js +0 -4
  114. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecoratedDescriptor.js +0 -9
  115. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs.js +0 -236
  116. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2203.js +0 -184
  117. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2203R.js +0 -191
  118. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2301.js +0 -222
  119. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2305.js +0 -133
  120. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2311.js +0 -124
  121. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/arrayLikeToArray.js +0 -6
  122. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/arrayWithHoles.js +0 -4
  123. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/arrayWithoutHoles.js +0 -5
  124. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/assertClassBrand.js +0 -5
  125. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/assertThisInitialized.js +0 -5
  126. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/asyncGeneratorDelegate.js +0 -24
  127. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/asyncIterator.js +0 -45
  128. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/asyncToGenerator.js +0 -26
  129. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/awaitAsyncGenerator.js +0 -5
  130. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/callSuper.js +0 -7
  131. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/checkInRHS.js +0 -6
  132. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/checkPrivateRedeclaration.js +0 -4
  133. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classApplyDescriptorDestructureSet.js +0 -10
  134. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classApplyDescriptorGet.js +0 -4
  135. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classApplyDescriptorSet.js +0 -7
  136. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classCallCheck.js +0 -4
  137. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classCheckPrivateStaticAccess.js +0 -5
  138. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +0 -4
  139. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classExtractFieldDescriptor.js +0 -5
  140. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classNameTDZError.js +0 -4
  141. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldDestructureSet.js +0 -7
  142. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldGet.js +0 -7
  143. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldGet2.js +0 -5
  144. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldInitSpec.js +0 -5
  145. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldLooseBase.js +0 -5
  146. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldLooseKey.js +0 -5
  147. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldSet.js +0 -7
  148. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldSet2.js +0 -5
  149. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateGetter.js +0 -5
  150. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateMethodGet.js +0 -5
  151. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateMethodInitSpec.js +0 -5
  152. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateMethodSet.js +0 -4
  153. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateSetter.js +0 -5
  154. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateFieldDestructureSet.js +0 -7
  155. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateFieldSpecGet.js +0 -7
  156. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateFieldSpecSet.js +0 -7
  157. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateMethodGet.js +0 -5
  158. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateMethodSet.js +0 -4
  159. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/construct.js +0 -10
  160. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createClass.js +0 -13
  161. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createForOfIteratorHelper.js +0 -50
  162. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createForOfIteratorHelperLoose.js +0 -19
  163. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createSuper.js +0 -16
  164. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/decorate.js +0 -21
  165. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/decorateMetadata.js +0 -7
  166. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/decorateParam.js +0 -9
  167. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defaults.js +0 -9
  168. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defineAccessor.js +0 -8
  169. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defineEnumerableProperties.js +0 -12
  170. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defineProperty.js +0 -10
  171. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/dispose.js +0 -28
  172. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/extends.js +0 -10
  173. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/get.js +0 -11
  174. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/getPrototypeOf.js +0 -6
  175. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/identity.js +0 -4
  176. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/importDeferProxy.js +0 -27
  177. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/inherits.js +0 -14
  178. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/inheritsLoose.js +0 -5
  179. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/initializerDefineProperty.js +0 -9
  180. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/initializerWarningHelper.js +0 -4
  181. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/instanceof.js +0 -4
  182. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/interopRequireDefault.js +0 -6
  183. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/interopRequireWildcard.js +0 -27
  184. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/isNativeFunction.js +0 -8
  185. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/isNativeReflectConstruct.js +0 -9
  186. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/iterableToArray.js +0 -4
  187. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/iterableToArrayLimit.js +0 -28
  188. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/jsx.js +0 -22
  189. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/maybeArrayLike.js +0 -9
  190. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/newArrowCheck.js +0 -4
  191. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/nonIterableRest.js +0 -4
  192. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/nonIterableSpread.js +0 -4
  193. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/nullishReceiverError.js +0 -4
  194. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectDestructuringEmpty.js +0 -4
  195. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectSpread.js +0 -14
  196. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectSpread2.js +0 -23
  197. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectWithoutProperties.js +0 -13
  198. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectWithoutPropertiesLoose.js +0 -10
  199. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/package.json +0 -3
  200. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/possibleConstructorReturn.js +0 -8
  201. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/readOnlyError.js +0 -4
  202. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/regeneratorRuntime.js +0 -304
  203. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/set.js +0 -22
  204. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/setFunctionName.js +0 -12
  205. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/setPrototypeOf.js +0 -6
  206. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/skipFirstGeneratorNext.js +0 -7
  207. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/slicedToArray.js +0 -8
  208. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/superPropBase.js +0 -6
  209. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/superPropGet.js +0 -9
  210. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/superPropSet.js +0 -6
  211. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/taggedTemplateLiteral.js +0 -8
  212. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/taggedTemplateLiteralLoose.js +0 -4
  213. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/tdz.js +0 -4
  214. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/temporalRef.js +0 -6
  215. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/temporalUndefined.js +0 -2
  216. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toArray.js +0 -8
  217. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toConsumableArray.js +0 -8
  218. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toPrimitive.js +0 -12
  219. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toPropertyKey.js +0 -7
  220. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toSetter.js +0 -10
  221. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/typeof.js +0 -10
  222. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/unsupportedIterableToArray.js +0 -9
  223. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/using.js +0 -12
  224. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/usingCtx.js +0 -59
  225. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/wrapAsyncGenerator.js +0 -69
  226. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/wrapNativeSuper.js +0 -27
  227. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/wrapRegExp.js +0 -51
  228. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/writeOnlyError.js +0 -4
  229. package/runtime/node_modules/@oxc-project/runtime/src/helpers/extends.js +0 -10
  230. package/runtime/node_modules/@oxc-project/runtime/src/helpers/get.js +0 -11
  231. package/runtime/node_modules/@oxc-project/runtime/src/helpers/getPrototypeOf.js +0 -6
  232. package/runtime/node_modules/@oxc-project/runtime/src/helpers/identity.js +0 -4
  233. package/runtime/node_modules/@oxc-project/runtime/src/helpers/importDeferProxy.js +0 -27
  234. package/runtime/node_modules/@oxc-project/runtime/src/helpers/inherits.js +0 -14
  235. package/runtime/node_modules/@oxc-project/runtime/src/helpers/inheritsLoose.js +0 -5
  236. package/runtime/node_modules/@oxc-project/runtime/src/helpers/initializerDefineProperty.js +0 -9
  237. package/runtime/node_modules/@oxc-project/runtime/src/helpers/initializerWarningHelper.js +0 -4
  238. package/runtime/node_modules/@oxc-project/runtime/src/helpers/instanceof.js +0 -4
  239. package/runtime/node_modules/@oxc-project/runtime/src/helpers/interopRequireDefault.js +0 -6
  240. package/runtime/node_modules/@oxc-project/runtime/src/helpers/interopRequireWildcard.js +0 -27
  241. package/runtime/node_modules/@oxc-project/runtime/src/helpers/isNativeFunction.js +0 -8
  242. package/runtime/node_modules/@oxc-project/runtime/src/helpers/isNativeReflectConstruct.js +0 -9
  243. package/runtime/node_modules/@oxc-project/runtime/src/helpers/iterableToArray.js +0 -4
  244. package/runtime/node_modules/@oxc-project/runtime/src/helpers/iterableToArrayLimit.js +0 -28
  245. package/runtime/node_modules/@oxc-project/runtime/src/helpers/jsx.js +0 -22
  246. package/runtime/node_modules/@oxc-project/runtime/src/helpers/maybeArrayLike.js +0 -9
  247. package/runtime/node_modules/@oxc-project/runtime/src/helpers/newArrowCheck.js +0 -4
  248. package/runtime/node_modules/@oxc-project/runtime/src/helpers/nonIterableRest.js +0 -4
  249. package/runtime/node_modules/@oxc-project/runtime/src/helpers/nonIterableSpread.js +0 -4
  250. package/runtime/node_modules/@oxc-project/runtime/src/helpers/nullishReceiverError.js +0 -4
  251. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectDestructuringEmpty.js +0 -4
  252. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectSpread.js +0 -14
  253. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js +0 -23
  254. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js +0 -13
  255. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js +0 -10
  256. package/runtime/node_modules/@oxc-project/runtime/src/helpers/possibleConstructorReturn.js +0 -8
  257. package/runtime/node_modules/@oxc-project/runtime/src/helpers/readOnlyError.js +0 -4
  258. package/runtime/node_modules/@oxc-project/runtime/src/helpers/regeneratorRuntime.js +0 -304
  259. package/runtime/node_modules/@oxc-project/runtime/src/helpers/set.js +0 -22
  260. package/runtime/node_modules/@oxc-project/runtime/src/helpers/setFunctionName.js +0 -12
  261. package/runtime/node_modules/@oxc-project/runtime/src/helpers/setPrototypeOf.js +0 -6
  262. package/runtime/node_modules/@oxc-project/runtime/src/helpers/skipFirstGeneratorNext.js +0 -7
  263. package/runtime/node_modules/@oxc-project/runtime/src/helpers/slicedToArray.js +0 -8
  264. package/runtime/node_modules/@oxc-project/runtime/src/helpers/superPropBase.js +0 -6
  265. package/runtime/node_modules/@oxc-project/runtime/src/helpers/superPropGet.js +0 -9
  266. package/runtime/node_modules/@oxc-project/runtime/src/helpers/superPropSet.js +0 -6
  267. package/runtime/node_modules/@oxc-project/runtime/src/helpers/taggedTemplateLiteral.js +0 -8
  268. package/runtime/node_modules/@oxc-project/runtime/src/helpers/taggedTemplateLiteralLoose.js +0 -4
  269. package/runtime/node_modules/@oxc-project/runtime/src/helpers/tdz.js +0 -4
  270. package/runtime/node_modules/@oxc-project/runtime/src/helpers/temporalRef.js +0 -6
  271. package/runtime/node_modules/@oxc-project/runtime/src/helpers/temporalUndefined.js +0 -2
  272. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toArray.js +0 -8
  273. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toConsumableArray.js +0 -8
  274. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js +0 -12
  275. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js +0 -7
  276. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toSetter.js +0 -10
  277. package/runtime/node_modules/@oxc-project/runtime/src/helpers/typeof.js +0 -10
  278. package/runtime/node_modules/@oxc-project/runtime/src/helpers/unsupportedIterableToArray.js +0 -9
  279. package/runtime/node_modules/@oxc-project/runtime/src/helpers/using.js +0 -12
  280. package/runtime/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js +0 -59
  281. package/runtime/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js +0 -69
  282. package/runtime/node_modules/@oxc-project/runtime/src/helpers/wrapNativeSuper.js +0 -27
  283. package/runtime/node_modules/@oxc-project/runtime/src/helpers/wrapRegExp.js +0 -51
  284. package/runtime/node_modules/@oxc-project/runtime/src/helpers/writeOnlyError.js +0 -4
  285. package/runtime/node_modules/@petamoriken/float16/LICENSE +0 -21
  286. package/runtime/node_modules/@petamoriken/float16/README.md +0 -413
  287. package/runtime/node_modules/@petamoriken/float16/browser/float16.js +0 -1340
  288. package/runtime/node_modules/@petamoriken/float16/browser/float16.mjs +0 -1325
  289. package/runtime/node_modules/@petamoriken/float16/index.d.ts +0 -546
  290. package/runtime/node_modules/@petamoriken/float16/index.v5.6.d.ts +0 -546
  291. package/runtime/node_modules/@petamoriken/float16/index.v5.7.d.ts +0 -555
  292. package/runtime/node_modules/@petamoriken/float16/inspect/node.cjs +0 -25
  293. package/runtime/node_modules/@petamoriken/float16/inspect/node.mjs +0 -23
  294. package/runtime/node_modules/@petamoriken/float16/lib/DataView.cjs +0 -16
  295. package/runtime/node_modules/@petamoriken/float16/lib/Float16Array.cjs +0 -690
  296. package/runtime/node_modules/@petamoriken/float16/lib/_util/arrayIterator.cjs +0 -52
  297. package/runtime/node_modules/@petamoriken/float16/lib/_util/brand.cjs +0 -27
  298. package/runtime/node_modules/@petamoriken/float16/lib/_util/converter.cjs +0 -111
  299. package/runtime/node_modules/@petamoriken/float16/lib/_util/is.cjs +0 -78
  300. package/runtime/node_modules/@petamoriken/float16/lib/_util/messages.cjs +0 -18
  301. package/runtime/node_modules/@petamoriken/float16/lib/_util/primordials.cjs +0 -150
  302. package/runtime/node_modules/@petamoriken/float16/lib/_util/spec.cjs +0 -84
  303. package/runtime/node_modules/@petamoriken/float16/lib/f16round.cjs +0 -10
  304. package/runtime/node_modules/@petamoriken/float16/lib/index.cjs +0 -16
  305. package/runtime/node_modules/@petamoriken/float16/lib/isTypedArray.cjs +0 -11
  306. package/runtime/node_modules/@petamoriken/float16/package.json +0 -115
  307. package/runtime/node_modules/@petamoriken/float16/src/DataView.mjs +0 -35
  308. package/runtime/node_modules/@petamoriken/float16/src/Float16Array.mjs +0 -1194
  309. package/runtime/node_modules/@petamoriken/float16/src/_util/arrayIterator.mjs +0 -86
  310. package/runtime/node_modules/@petamoriken/float16/src/_util/brand.mjs +0 -31
  311. package/runtime/node_modules/@petamoriken/float16/src/_util/converter.mjs +0 -173
  312. package/runtime/node_modules/@petamoriken/float16/src/_util/is.mjs +0 -151
  313. package/runtime/node_modules/@petamoriken/float16/src/_util/messages.mjs +0 -22
  314. package/runtime/node_modules/@petamoriken/float16/src/_util/primordials.mjs +0 -254
  315. package/runtime/node_modules/@petamoriken/float16/src/_util/spec.mjs +0 -137
  316. package/runtime/node_modules/@petamoriken/float16/src/f16round.mjs +0 -10
  317. package/runtime/node_modules/@petamoriken/float16/src/index.mjs +0 -7
  318. package/runtime/node_modules/@petamoriken/float16/src/isTypedArray.mjs +0 -10
  319. package/runtime/node_modules/jsbi/LICENSE +0 -176
  320. package/runtime/node_modules/jsbi/README.md +0 -173
  321. package/runtime/node_modules/jsbi/dist/jsbi-cjs.js +0 -2
  322. package/runtime/node_modules/jsbi/dist/jsbi-cjs.js.map +0 -1
  323. package/runtime/node_modules/jsbi/dist/jsbi-umd.js +0 -2
  324. package/runtime/node_modules/jsbi/dist/jsbi-umd.js.map +0 -1
  325. package/runtime/node_modules/jsbi/dist/jsbi.mjs +0 -2
  326. package/runtime/node_modules/jsbi/dist/jsbi.mjs.map +0 -1
  327. package/runtime/node_modules/jsbi/jsbi.d.ts +0 -43
  328. package/runtime/node_modules/jsbi/package.json +0 -35
  329. package/runtime/node_modules/urlpattern-polyfill/LICENSE +0 -19
  330. package/runtime/node_modules/urlpattern-polyfill/README.md +0 -242
  331. package/runtime/node_modules/urlpattern-polyfill/dist/index.d.ts +0 -9
  332. package/runtime/node_modules/urlpattern-polyfill/dist/types.d.ts +0 -49
  333. package/runtime/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +0 -1
  334. package/runtime/node_modules/urlpattern-polyfill/dist/urlpattern.js +0 -1
  335. package/runtime/node_modules/urlpattern-polyfill/index.cjs +0 -7
  336. package/runtime/node_modules/urlpattern-polyfill/index.js +0 -7
  337. package/runtime/node_modules/urlpattern-polyfill/package.json +0 -149
  338. package/runtime/pnp-bin-run.cjs +0 -91
  339. package/runtime/pnp-util.cjs +0 -62
  340. package/runtime/polyfills.cjs +0 -278
  341. package/runtime/preload-async-hooks.mjs +0 -110
  342. package/runtime/preload-common.cjs +0 -1096
  343. package/runtime/preload.cjs +0 -313
  344. package/runtime/preload.mjs +0 -149
  345. package/runtime/transform-core.mjs +0 -756
  346. package/runtime/version.mjs +0 -12
  347. package/runtime/worker-blob-url.cjs +0 -116
  348. package/runtime/worker-polyfill.mjs +0 -541
@@ -1,756 +0,0 @@
1
- // Nub transform core — the single source of truth shared by both hook tiers.
2
- //
3
- // runtime/preload.mjs (fast path, Node 22.15+, sync `module.registerHooks`) and
4
- // the compat-tier loader worker (Node 18.19–22.14, async `module.register` →
5
- // runtime/preload-async-hooks.mjs) both import every resolution + transpile
6
- // primitive from here. The tier files own only the parts that genuinely differ:
7
- // hook registration (sync vs async signatures), polyfill preloading, the
8
- // Temporal lazy global, watch-mode IPC, and the compat-tier CJS `require()`
9
- // shim. EVERYTHING about how a file is resolved and transpiled — extension
10
- // probing, the `.js`→`.ts` swap, tsconfig `paths`, module-format detection,
11
- // transform options (including `target: 'es2022'` `using`-lowering), the
12
- // Stage-3 decorator guard, the on-disk cache, data-format imports, package
13
- // clobbering — lives here, so the two tiers can never drift. (They used to:
14
- // separate copies diverged on probe order, `target` lowering, the decorator
15
- // guard, module-format detection, the Temporal clobber's named exports, and the
16
- // reserved-export filter — every one a real compat bug. This module is the fix.)
17
- //
18
- // Side effects are confined to: loading the N-API addon (data parsers + the
19
- // in-process TS/JSX transpiler), and reading/writing the transpile cache. There is
20
- // no top-level hook registration here — importing this module never augments the
21
- // realm; the tier files do that.
22
-
23
- // EVERY node: builtin this module needs is pulled in via CJS `require()` / `process
24
- // .getBuiltinModule` (below), NOT via static ESM `import`. This is load-bearing for
25
- // loader compatibility (R11): nub loads transform-core through `require(esm)`, and
26
- // Node's `require(esm)` instantiates the module by walking its STATIC IMPORT graph
27
- // through whatever ESM loader hooks are registered — including the USER's
28
- // `--loader`/`register()` chain. Static `import get-tsconfig`/`./version.mjs`/`node:*`
29
- // here therefore once leaked nub's entire internal graph (transform-core,
30
- // version.mjs, get-tsconfig, their transitive node_modules deps, and the node:
31
- // builtins) THROUGH the user's resolve/load hooks, which observed and corrupted it
32
- // (a user load hook returning `source: 1` for version.mjs, a strict loader throwing
33
- // on a bare specifier — see test-esm-loader-chaining, -example-loader,
34
- // -preserve-symlinks-not-found, test-shadow-realm-custom-loaders). Verified: a CJS
35
- // `require()` of a builtin does NOT route through the ESM loader chain, so loading
36
- // off it bypasses the user chain entirely. As of this migration the point is
37
- // stronger: transform-core `require()`s ZERO npm packages — the transpiler, TS/JSX
38
- // detection, tsconfig discovery/parse, the additive TS-resolver, AND the transpile
39
- // cache are ALL native calls into nub's own N-API addon (loaded by absolute `.node`
40
- // path, off the loader chain), and the version.mjs text read is gone (the cache
41
- // version is baked into the addon). So the worst historical leaks — oxc-transform's
42
- // and then get-tsconfig's graphs pulled through the user chain — are gone by
43
- // construction; only node: builtins remain, fetched off the chain. `process
44
- // .getBuiltinModule` fetches node: builtins synchronously off the loader chain;
45
- // `createRequire(import.meta.url)` resolves the (now CommonJS-only) vendored
46
- // polyfills + the `@oxc-project/runtime` helpers from nub's distribution.
47
- // This file keeps its `export`s (it stays an ES module) but has ZERO static
48
- // imports — INCLUDING zero static `import` of any `node:` builtin — so `require(esm)`
49
- // of transform-core finds no dependency graph to route through the user loader.
50
- // This is load-bearing, not cosmetic: transform-core previously carried a static
51
- // `import { createRequire } from "node:module"`. That import sat in transform-core's
52
- // static graph, so when nub's fast-tier preload.cjs does `require("./transform-core
53
- // .mjs")` (a `require(esm)`), Node instantiated transform-core by walking its static
54
- // import graph THROUGH the user's pre-registered `--experimental-loader` /
55
- // `module.register` chain — and a user resolve hook that rejects or rewrites
56
- // `node:module` (e.g. the example-loader that throws on any non-`./`/`../`/URL
57
- // specifier) then exploded nub's own load, while resolve-count loaders saw a phantom
58
- // `node:module` hit. (Observed against es-module/test-esm-example-loader,
59
- // -loader-chaining, -initialization, -preserve-symlinks-not-found, and
60
- // parallel/test-shadow-realm-custom-loaders.) The earlier comment here claimed the
61
- // `node:module` import was "never routed through a user loader hook" — that was
62
- // FALSE for the fast-tier `require(esm)` path, and is the bug this rewrite fixes.
63
- //
64
- // `process.getBuiltinModule` (Node 22.3 / backported to 20.16 / 18.20.4) fetches a
65
- // node: builtin synchronously OFF the loader chain, with no static import — so on
66
- // the fast tier (22.15+, the only tier that loads transform-core via `require(esm)`,
67
- // and where getBuiltinModule ALWAYS exists) there is nothing in the graph for a user
68
- // loader to observe. On the narrow FLOOR below 22.3/20.16/18.20.4 (18.19.x,
69
- // 20.11–20.15, 22.0–22.2) it's `undefined`; there, transform-core is loaded ONLY via
70
- // static ESM `import` from the compat-tier entries (preload.mjs main thread /
71
- // preload-async-hooks.mjs loader worker), both OFF any user loader chain — so the
72
- // floor's `node:module` access cannot leak.
73
- //
74
- // BRAND BOUNDARY — the floor's `createRequire` is THREADED IN THROUGH MODULE SCOPE,
75
- // not parked on `globalThis`. floor-builtin.mjs holds the lone static `import {
76
- // createRequire } from "node:module"` and pushes the value in here via the
77
- // `setBootstrapCreateRequire` setter below; nothing is ever written to the user's
78
- // global object (a `globalThis.__nub*` sentinel is the same brand leak as a NUB_*
79
- // env var — enumerable in user code AND worker realms — so it is forbidden). The
80
- // floor's `node:module` import lives only in floor-builtin.mjs, which the fast tier
81
- // never loads, so it never enters the fast-tier `require(esm)` graph.
82
- //
83
- // On the floor the threaded value isn't available at this module's top-level eval:
84
- // the compat entry imports floor-builtin AHEAD of transform-core, but ES modules
85
- // evaluate the importEE before the importer's body, so floor-builtin's setter call
86
- // (made during ITS evaluation) lands AFTER transform-core's body has run. So on the
87
- // floor every builtin is acquired LAZILY, on first hook use — by which point the
88
- // setter has run. On the fast tier getBuiltinModule is present, so the builtins are
89
- // acquired eagerly here at module eval (no setter, no floor path involved).
90
- let _bootstrapCreateRequire = null;
91
- // Called by floor-builtin.mjs (imported first by the compat entries) to hand in the
92
- // floor's `createRequire` without any globalThis surface. NEVER called on the fast
93
- // tier (getBuiltinModule covers it). The compat entries import floor-builtin ahead of
94
- // transform-core, so by the time this fires transform-core's body has already
95
- // evaluated (importEE before importer) — which is exactly why this setter also runs
96
- // __ensureBuiltins() right now: it lands DURING floor-builtin's evaluation, before the
97
- // entry's body and long before any hook fires, so every builtin binding is ready
98
- // without ever consulting globalThis.
99
- export function setBootstrapCreateRequire(fn) {
100
- _bootstrapCreateRequire = fn;
101
- __ensureBuiltins();
102
- }
103
-
104
- // node: builtins (lazy on the floor, eager on the fast tier — see above). On the
105
- // floor `_bootstrapCreateRequire` is read at FETCH time (inside the thunk), never at
106
- // definition time, so floor-builtin's setter has run before the first fetch fires.
107
- function __getBuiltin(id) {
108
- if (typeof process.getBuiltinModule === "function") return process.getBuiltinModule(id);
109
- return _bootstrapCreateRequire(import.meta.url)(id);
110
- }
111
-
112
- // Builtin bindings + the native addon, populated by __ensureBuiltins(). They stay
113
- // `let` (not `const`) because on the floor they are filled on first hook use rather
114
- // than at module eval — see the lazy-vs-eager note above.
115
- let createRequire, __require, module, readFileSync, writeFileSync, mkdirSync, statSync;
116
- let fileURLToPath, pathToFileURL, join, dirname;
117
- // Nub's N-API addon — the in-process TS/JSX transpiler (`transform`,
118
- // `transformCached`, `detectModuleInfo`), the tsconfig reader + additive
119
- // TS-resolver (`loadTsconfig`, `resolveTs`), AND the data-format parsers
120
- // (`parseYaml`/`parseToml`/`parseJson5`/`parseJsonc`), all native. Loaded once
121
- // per module instance (= once per thread: the main thread and the loader worker
122
- // each import this module separately). It is a `.node` binary resolved by absolute
123
- // path off this file's dir, so it never touches the ESM loader chain — the
124
- // historical require(esm)-of-an-ESM-npm-package leak (oxc-transform, and before
125
- // this migration get-tsconfig) is gone: transpilation, tsconfig discovery, the
126
- // additive resolution, and the transpile cache are synchronous native calls, no JS
127
- // package, no static-import graph to route. nub now loads ZERO npm packages
128
- // internally, so the user ESM loader chain can never observe a nub dependency.
129
- let nubNative = null;
130
-
131
- // Idempotent. Acquires the node: builtins + the native addon. Runs eagerly at module
132
- // eval on the fast tier (getBuiltinModule present); on the floor it is invoked at the
133
- // top of every exported entry point, where the threaded createRequire is ready.
134
- let __builtinsReady = false;
135
- function __ensureBuiltins() {
136
- if (__builtinsReady) return;
137
- __builtinsReady = true;
138
- ({ createRequire } = __getBuiltin("node:module"));
139
- __require = createRequire(import.meta.url);
140
- module = __getBuiltin("node:module");
141
- ({ readFileSync, writeFileSync, mkdirSync, statSync } = __getBuiltin("node:fs"));
142
- ({ fileURLToPath, pathToFileURL } = __getBuiltin("node:url"));
143
- ({ join, dirname } = __getBuiltin("node:path"));
144
- for (const rel of ["./addons/nub-native.node", "../runtime/addons/nub-native.node"]) {
145
- try { nubNative = __require(fileURLToPath(new URL(rel, import.meta.url))); break; } catch {}
146
- }
147
- }
148
- // Fast tier: getBuiltinModule is present, so acquire everything now (preserves the
149
- // original eager-at-eval behavior). The floor defers to first-use — see above.
150
- if (typeof process.getBuiltinModule === "function") __ensureBuiltins();
151
-
152
- // NOTE: the transpile-cache version component is no longer read here. nub's
153
- // version is baked into the native addon at compile time (`env!("CARGO_PKG_VERSION")`
154
- // in nub-native's cache.rs), which `make version` keeps in lockstep with
155
- // runtime/version.mjs and Cargo.toml — so the cache key's version component lives
156
- // natively now, and this file no longer needs to read version.mjs.
157
-
158
- // ── Constants ───────────────────────────────────────────────────────
159
- // TS/JSX exts ALWAYS transform (type-stripping is required), so they live in
160
- // TRANSPILE_EXTS — the set every dispatch site checks to route a file to
161
- // loadTranspile. Plain JS (.js/.mjs/.cjs) is DELIBERATELY NOT here: a plain-JS file
162
- // is transpiled ONLY when it carries transformable syntax (`using`/`await using`,
163
- // `v`-flag RegExp, decorators), and a no-op plain-JS file must take Node's OWN load
164
- // path BYTE-FOR-BYTE — putting it in TRANSPILE_EXTS would route every `.js`/`.cjs`
165
- // through nub's hook and change native CJS/ESM behavior (the `commonjs-sync` relabel,
166
- // require.cache, the require-of-ESM-syntax-.cjs error). So plain JS is handled by a
167
- // SEPARATE narrow path (`maybeTranspilePlainJs`) that fires only for transformable
168
- // files and is a no-op (returns null) otherwise — see PLAIN_JS_EXTS below.
169
- export const TRANSPILE_EXTS = new Set([".ts", ".tsx", ".mts", ".cts", ".jsx"]);
170
- // Project-source plain JS. Routed to the transpiler ONLY when transformable (the
171
- // `maybeTranspilePlainJs` gate); a no-op plain-JS file falls through to Node's
172
- // native loader untouched, byte-identical. node_modules is excluded at the gate.
173
- export const PLAIN_JS_EXTS = new Set([".js", ".mjs", ".cjs"]);
174
- export const DATA_EXTS = { ".jsonc": "jsonc", ".json5": "json5", ".toml": "toml", ".yaml": "yaml", ".yml": "yaml", ".txt": "txt" };
175
- export const TS_PARENT_EXTS = new Set([".ts", ".tsx", ".mts", ".cts"]);
176
-
177
- // Packages resolved from Nub's distribution, not the user's.
178
- export const VENDORED_PACKAGES = new Set(["@oxc-project/runtime"]);
179
-
180
- // Built-in modules provided by Nub (resolved to files in this distribution).
181
- // connect() sockets deferred per design decision — "sockets" specifier not clobbered.
182
- export const BUILTIN_MODULES = new Map();
183
-
184
- // Package clobbering: specifiers that resolve to a synthetic module re-exporting
185
- // the native global instead of the userland package.
186
- export const CLOBBER_MAP = new Map([
187
- // Reading globalThis.Temporal triggers the lazy getter the tier file installs,
188
- // which loads the polyfill by resolved path — that load is what installs
189
- // Date.prototype.toTemporalInstant, so Temporal MUST be read first.
190
- // @js-temporal/polyfill exports { Temporal, Intl, toTemporalInstant }; mirror
191
- // all three so `import { Temporal, Intl, toTemporalInstant } from ...` binds.
192
- ["@js-temporal/polyfill", () => `const T = globalThis.Temporal; export default T; export const Temporal = T; export const Intl = globalThis.Intl; export const toTemporalInstant = Date.prototype.toTemporalInstant;`],
193
- ["urlpattern-polyfill", () => `export const URLPattern = globalThis.URLPattern;`],
194
- ["abort-controller", () => `export const AbortController = globalThis.AbortController; export const AbortSignal = globalThis.AbortSignal; export default globalThis.AbortController;`],
195
- ]);
196
-
197
- // ── Watch-mode hooks (injected by the main-thread tier) ─────────────
198
- // `nub watch` needs config files (tsconfig.json, package.json) and `.env*` —
199
- // which are not in any import graph — surfaced to Node's FilesWatcher. The main
200
- // thread (preload.mjs) injects reporters; the loader worker injects nothing
201
- // (watch IPC is main-thread only), so these default to no-ops.
202
- let _reportDep = null;
203
- let _reportEnvDir = null;
204
- export function setWatchHooks({ reportDep, reportEnvDir } = {}) {
205
- if (reportDep) _reportDep = reportDep;
206
- if (reportEnvDir) _reportEnvDir = reportEnvDir;
207
- }
208
-
209
- // ── tsconfig + package-type caches ──────────────────────────────────
210
- // tsconfig discovery / parse / `extends` resolution + the `paths` matcher all
211
- // happen natively (nub-native `loadTsconfig`, the get-tsconfig@4.14.0 port). This
212
- // JS wrapper exists only to (a) memoize per importer-dir — native ALSO memoizes,
213
- // but a JS-side Map skips the napi boundary on a hit and lets watch-mode report
214
- // the dep exactly once per dir — and (b) surface the resolved tsconfig path to the
215
- // watch FilesWatcher. The returned shape exposes the transform-relevant
216
- // `compilerOptions` slice and the `tsconfigHash` cache-key component; the `paths`
217
- // matcher lives entirely in native (`resolveTs` runs it), so there is no JS matcher.
218
- const tsconfigCache = new Map();
219
- export function getTsconfigForDir(dir) {
220
- if (tsconfigCache.has(dir)) return tsconfigCache.get(dir);
221
- // { path: string|null, compilerOptions: object|null, tsconfigHash: string }
222
- const result = nubNative
223
- ? nubNative.loadTsconfig(dir)
224
- : { path: null, compilerOptions: null, tsconfigHash: "" };
225
- tsconfigCache.set(dir, result);
226
- if (result.path) _reportDep?.(result.path);
227
- return result;
228
- }
229
-
230
- // The NEAREST package.json's `type` decides the format of ambiguous extensions
231
- // (.ts/.tsx/.jsx, like Node's .js). The nearest one wins even when its `type`
232
- // is absent — Node does not skip a typeless package.json to find a typed
233
- // ancestor — so we stop at the first package.json found. Returns "module",
234
- // "commonjs", or undefined.
235
- const packageTypeCache = new Map();
236
- export function getPackageType(dir) {
237
- if (packageTypeCache.has(dir)) return packageTypeCache.get(dir);
238
- let type;
239
- let current = dir;
240
- for (;;) {
241
- const pkgPath = join(current, "package.json");
242
- if (fileExists(pkgPath)) {
243
- try { type = JSON.parse(readFileSync(pkgPath, "utf8")).type; } catch {}
244
- // Watch this package.json (a `type`/script edit should restart) and the
245
- // `.env*` files alongside it (the package root is where they live).
246
- _reportDep?.(pkgPath);
247
- _reportEnvDir?.(current);
248
- break;
249
- }
250
- const parent = dirname(current);
251
- if (parent === current) break;
252
- current = parent;
253
- }
254
- packageTypeCache.set(dir, type);
255
- return type;
256
- }
257
-
258
- // ── Filesystem helpers ──────────────────────────────────────────────
259
- export function extname(url) {
260
- const path = url.includes("?") ? url.slice(0, url.indexOf("?")) : url;
261
- const dot = path.lastIndexOf(".");
262
- return dot === -1 ? "" : path.slice(dot);
263
- }
264
-
265
- export function isNodeModules(url) {
266
- return url.includes("/node_modules/") || url.includes("\\node_modules\\");
267
- }
268
-
269
- export function fileExists(filePath) {
270
- const s = statSync(filePath, { throwIfNoEntry: false });
271
- return s !== undefined && s.isFile();
272
- }
273
-
274
- function safeRequireResolve(specifier) {
275
- try { return __require.resolve(specifier); } catch { return null; }
276
- }
277
-
278
- export function barePkg(specifier) {
279
- return specifier.startsWith("@")
280
- ? specifier.split("/").slice(0, 2).join("/")
281
- : specifier.split("/")[0];
282
- }
283
-
284
- // ── Resolution ──────────────────────────────────────────────────────
285
- // The ADDITIVE TS resolution — tsconfig `paths` aliases, `.ts/.tsx/.mts/.cts/.jsx`
286
- // extension probing, the `.js`→`.ts` (and `.jsx→.tsx`, `.mjs→.mts`, `.cjs→.cts`)
287
- // emit-convention swap, directory-index probing, and reading a directory's
288
- // `package.json#main` — all happens natively now (nub-native `resolveTs`). It
289
- // returns an absolute path for the additive cases nub owns, or `null` for
290
- // EVERYTHING Node owns (node_modules, `exports`/`imports`, conditions, scoped/bare
291
- // specifiers), which the resolve hooks below turn into a fall-through to Node. That
292
- // `null` is the byte-for-byte compat boundary; reimplementing Node's resolution in
293
- // nub is forbidden. The `node:`/`data:`/builtin guards, the nub-internal-graph
294
- // bypass, vendored packages, and the clobber map all stay in JS and run BEFORE the
295
- // native resolver (see resolveSpec / resolveCjsPath).
296
- function resolveTs(specifier, parentPath) {
297
- if (!nubNative) return null;
298
- try {
299
- return nubNative.resolveTs(specifier, parentPath || "");
300
- } catch {
301
- return null;
302
- }
303
- }
304
-
305
- // nub's own runtime directory (this file's dir, as a file: URL prefix). Any
306
- // resolution whose IMPORTER lives here is one of nub's internal requires — the
307
- // preload loading transform-core, the Temporal lazy getter resolving
308
- // @js-temporal/polyfill — and must NEVER be routed through nub's own
309
- // clobber/vendored/tsconfig logic: those are user-code conveniences, and applying
310
- // them to nub's internals both breaks them (e.g. the Temporal clobber re-exports
311
- // globalThis.Temporal, which IS the getter → a require of the polyfill from the
312
- // getter would recurse into the clobber) and amplifies the user loader chain by
313
- // re-walking nub's internal graph through user hooks (R11). Short-circuit to native
314
- // resolution for these.
315
- const RUNTIME_DIR_URL = new URL(".", import.meta.url).href;
316
-
317
- // Is this importer part of nub's own internal module graph? Such imports must
318
- // bypass the user ESM loader chain entirely (R11). nub now loads ZERO npm packages
319
- // internally — tsconfig, the additive resolver, the transpile cache, the
320
- // transpiler, and module detection are ALL native nub-native calls, and the only
321
- // remaining JS deps (@oxc-project/runtime helpers, the polyfills) are CommonJS,
322
- // whose `require()` graph already bypasses the ESM loader chain by construction. So
323
- // the only nub-internal ESM importer left is nub's own runtime directory (this
324
- // file, the preload tiers, the Temporal lazy getter resolving @js-temporal/
325
- // polyfill). The historical "nub-dependency package roots" walk — which existed
326
- // solely to catch an ESM hop into get-tsconfig (and before that oxc-transform) — is
327
- // gone with those packages.
328
- function isNubInternalParent(parentURL) {
329
- if (!parentURL) return false;
330
- return String(parentURL).startsWith(RUNTIME_DIR_URL);
331
- }
332
-
333
- // Resolve a specifier the way both hook tiers do. Returns `{ url, shortCircuit }`
334
- // to short-circuit Node's resolver, or `null` to fall through to `nextResolve`.
335
- // `parentURL` is the importer (a file: URL string), or "" for the entry.
336
- export function resolveSpec(specifier, parentURL) {
337
- // nub's own internal graph (importer inside nub's runtime dir OR a nub
338
- // dependency package): resolve natively and SHORT-CIRCUIT so nextResolve (the
339
- // user's loader chain) never observes nub's internals. This MUST run before the
340
- // node:/data:/builtin early-returns below, because those `return null` =
341
- // DELEGATE to the user loader — and a nub-internal `import "node:module"` (e.g.
342
- // from a nub-dependency ESM entry) delegated to a strict user loader is exactly
343
- // the R11 leak. See isNubInternalParent.
344
- if (isNubInternalParent(parentURL)) {
345
- if (specifier.startsWith("node:") || module.isBuiltin(specifier)) {
346
- const url = specifier.startsWith("node:") ? specifier : `node:${specifier}`;
347
- return { url, shortCircuit: true };
348
- }
349
- if (specifier.startsWith("data:")) return { url: specifier, shortCircuit: true };
350
- // A relative/bare import from inside nub's graph: resolve it natively from the
351
- // parent's own require() resolver (NOT nub's tsconfig/clobber/probe logic) and
352
- // short-circuit. Bare specifiers resolve from the parent package's location.
353
- try {
354
- const parentReq = createRequire(parentURL);
355
- const resolved = parentReq.resolve(specifier);
356
- return { url: pathToFileURL(resolved).href, shortCircuit: true };
357
- } catch {
358
- // Couldn't resolve from the parent (e.g. a non-file: parent): still short-
359
- // circuit by handing the specifier back as-is, so the user chain is bypassed.
360
- return null;
361
- }
362
- }
363
-
364
- // node: and data: protocols, and bare Node built-ins, are never ours.
365
- if (specifier.startsWith("node:") || specifier.startsWith("data:")) return null;
366
- if (module.isBuiltin(specifier)) return null;
367
-
368
- // 1. Built-in modules provided by Nub.
369
- if (BUILTIN_MODULES.has(specifier)) {
370
- return { url: BUILTIN_MODULES.get(specifier), shortCircuit: true };
371
- }
372
-
373
- // 2. Vendored packages (e.g. @oxc-project/runtime).
374
- const bare = barePkg(specifier);
375
- if (VENDORED_PACKAGES.has(bare)) {
376
- const resolved = safeRequireResolve(specifier);
377
- if (resolved) return { url: pathToFileURL(resolved).href, shortCircuit: true };
378
- }
379
-
380
- // 3. Package clobbering.
381
- if (CLOBBER_MAP.has(bare) && !isNodeModules(parentURL || "")) {
382
- return { url: `data:text/javascript,${encodeURIComponent(CLOBBER_MAP.get(bare)())}`, shortCircuit: true };
383
- }
384
-
385
- const parent = String(parentURL || "");
386
-
387
- // 4. The ADDITIVE TS resolution (tsconfig `paths`, extension probing, `.js`→`.ts`
388
- // swap, directory index/`main`) — native. `resolveTs` is handed the parent's
389
- // absolute FS path (or "" for a non-file: parent / the entry, where it falls back
390
- // to cwd, matching the old `process.cwd()` parentDir). A non-null result is an
391
- // additive hit nub owns; null falls through to Node's resolver (the compat
392
- // boundary — node_modules, `exports`, bare/scoped specifiers stay Node's).
393
- const parentPath = parent.startsWith("file:") ? fileURLToPath(parent) : "";
394
- const resolved = resolveTs(specifier, parentPath);
395
- if (resolved) return { url: pathToFileURL(resolved).href, shortCircuit: true };
396
-
397
- return null;
398
- }
399
-
400
- // CommonJS `require()` resolution for the compat-tier Module._resolveFilename
401
- // patch. Returns an absolute file path for a require specifier nub should
402
- // redirect (tsconfig `paths`, extensionless `.ts`, `.js`→`.ts` swap), or null to
403
- // defer to Node's resolver. Mirrors resolveSpec steps 4–5 but returns a path (not
404
- // a URL) and never handles clobber/vendored/builtin — those are import-only, and
405
- // a clobber's data: URL can't be a require target. `parentPath` is the requiring
406
- // file's absolute path (from the CJS parent Module), or null for the entry.
407
- export function resolveCjsPath(request, parentPath) {
408
- if (request.startsWith("node:") || request.startsWith("data:") ||
409
- module.isBuiltin(request)) {
410
- return null;
411
- }
412
- // The SAME native additive resolver as resolveSpec, returning an absolute path
413
- // (not a URL). Vendored/clobber/builtin are import-only and never reach here. A
414
- // null result (node_modules / `exports` / a plain bare package) falls through to
415
- // Node's CJS resolver — the compat boundary.
416
- return resolveTs(request, parentPath || "");
417
- }
418
-
419
- // Would `require()`-ing this resolved TS file need Node's require(esm)? An
420
- // ESM-syntax `.ts`/`.mts` (or a `.ts` in a `type: module` package) transpiles to
421
- // ESM, which `require()` can only load via require(esm). On the compat tier that
422
- // path is the loader-worker's CJS translator, which on Node below the #60380 fix
423
- // crashes cryptically (`cjsCache.get(job.url)` is undefined) instead of erroring.
424
- // The compat CJS shim calls this so it can surface a clean ERR_REQUIRE_ESM
425
- // instead. (`.cts` is always CommonJS → false; non-transpiled extensions → false.)
426
- export function requireTargetIsEsm(filePath, ext) {
427
- if (ext === ".cts") return false;
428
- if (ext === ".mts") return true;
429
- if (!TRANSPILE_EXTS.has(ext)) return false;
430
- let source;
431
- try { source = readFileSync(filePath, "utf8"); } catch { return false; }
432
- const pkgType = getPackageType(dirname(filePath));
433
- return moduleFormatFor(ext, pkgType, filePath, source) === "module";
434
- }
435
-
436
- // ── Module-format detection ─────────────────────────────────────────
437
- // Both signals nub needs to read off a file's syntax — the absent-`type` module
438
- // format and the Stage-3-decorator guard — come from ONE native call into nub's
439
- // N-API addon (`detectModuleInfo`, the oxc parser compiled in-process). There is
440
- // no JS parser package anymore: `oxc-parser` (ESM-only, which used to need
441
- // `require(esm)` on the fast tier and a dynamic-`import()` `ensureParser()` dance
442
- // on the 18.19 compat tier) is gone, and with it the whole "is require(esm)
443
- // available here?" fork. The native call is synchronous and works identically on
444
- // every supported Node, so there is nothing to preload and no async warm-up — the
445
- // former `ensureParser()` export is removed (its compat-tier callers just stop
446
- // calling it). Used only for ambiguous extensions / the decorator guard; explicit
447
- // `type` and `.mts`/`.cts` short-circuit before the parser runs.
448
- function detectModuleInfo(filePath, source, lang) {
449
- // Addon missing (should never happen in a real install): default to ESM for
450
- // format (the common case) and "no decorators" for the guard — the same fallback
451
- // the old oxc-parser-unavailable branches used.
452
- if (!nubNative) return { hasValueEsmSyntax: true, hasDecorators: false, transformableSyntax: false };
453
- try {
454
- return nubNative.detectModuleInfo(filePath, source, lang);
455
- } catch {
456
- // Unparseable → CJS for format + no decorators (the transpile/V8 surfaces the
457
- // real error), matching the old per-call catch blocks. `transformableSyntax:
458
- // false` is the SAFE plain-JS default — the verbatim path hands the raw bytes
459
- // back, so V8 surfaces the real syntax error exactly where Node would.
460
- return { hasValueEsmSyntax: false, hasDecorators: false, transformableSyntax: false };
461
- }
462
- }
463
-
464
- // Map a transpiled file's extension + nearest package.json "type" to the module
465
- // format Node's loader should use. `.mts`/`.cts` are explicit; an explicit
466
- // `type` is authoritative; otherwise (ambiguous) we detect from source syntax —
467
- // full Node parity (`--experimental-detect-module`), so a CJS-syntax `.ts` with
468
- // no `type` runs as CJS on nub exactly as on Node. See wiki/runtime/module-format.md.
469
- // `.mjs`→module / `.cjs`→commonjs are explicit (mirroring `.mts`/`.cts`), so the
470
- // plain-JS gate gets the right format without a needless detect.
471
- export function moduleFormatFor(ext, pkgType, filePath, source) {
472
- return moduleFormatWithInfo(ext, pkgType, filePath, source).format;
473
- }
474
-
475
- // Same format decision as moduleFormatFor, but ALSO returns the `ModuleInfo`
476
- // (`detectModuleInfo`) result when a parse was needed — `{ format, info }`, with
477
- // `info` null on the no-parse short-circuits (`.mts`/`.mjs`/`.cts`/`.cjs`, explicit
478
- // `type`). loadTranspile uses this so its ONE parse serves BOTH readers — the
479
- // format decision (`hasValueEsmSyntax`) and the Stage-3 decorator guard
480
- // (`hasDecorators`) — instead of `moduleFormatFor` + `hasDecoratorSyntax` each
481
- // parsing the same source. On a short-circuit (`info` null) no parse happened, so
482
- // the decorator guard runs its own single parse: still ≤1 detect per file.
483
- function moduleFormatWithInfo(ext, pkgType, filePath, source) {
484
- if (ext === ".mts" || ext === ".mjs") return { format: "module", info: null };
485
- if (ext === ".cts" || ext === ".cjs") return { format: "commonjs", info: null };
486
- if (pkgType === "module") return { format: "module", info: null };
487
- if (pkgType === "commonjs") return { format: "commonjs", info: null };
488
- const lang = ext === ".tsx" ? "tsx" : ext === ".jsx" ? "jsx" : "ts";
489
- const info = detectModuleInfo(filePath, source, lang);
490
- return { format: info.hasValueEsmSyntax ? "module" : "commonjs", info };
491
- }
492
-
493
- // The Stage-3-decorator rejection diagnostic. oxc does not lower TC39 Stage 3
494
- // decorators yet (oxc-project/oxc#9170) — it passes the `@decorator` syntax
495
- // through verbatim with errors:[], so without this check V8 throws a bare
496
- // `SyntaxError: Invalid or unexpected token`. See wiki/runtime/stage3-decorators.md.
497
- function stage3DecoratorError(filePath) {
498
- return new Error(
499
- `Nub: Stage 3 decorators are not supported by the transpiler yet.\n` +
500
- `This is an upstream limitation in oxc (oxc-project/oxc#9170).\n` +
501
- ` in ${filePath}\n\n` +
502
- `Workarounds:\n` +
503
- ` 1. Set "experimentalDecorators": true in tsconfig.json to use legacy decorators\n` +
504
- ` (the shape NestJS / TypeORM / class-validator are written against).\n` +
505
- ` 2. Wait for Stage 3 decorator support in oxc; tracked upstream at\n` +
506
- ` https://github.com/oxc-project/oxc/issues/9170.\n\n` +
507
- `See: https://www.typescriptlang.org/tsconfig/#experimentalDecorators`,
508
- );
509
- }
510
-
511
- // Does the source contain TC39 decorator syntax (`@expr` on a class or class
512
- // member)? Used ONLY when legacy decorators are off, to surface a clear
513
- // diagnostic instead of oxc's verbatim passthrough → V8 SyntaxError. The cheap
514
- // `source.includes("@")` pre-filter in the caller keeps decorator-free files off
515
- // the native parser. The walk now happens in Rust (detectModuleInfo's AST visit).
516
- function hasDecoratorSyntax(filePath, source, lang) {
517
- return detectModuleInfo(filePath, source, lang).hasDecorators;
518
- }
519
-
520
- // ── Transpile cache ─────────────────────────────────────────────────
521
- // The transpile cache — `cacheGet` + transform-on-miss + post-processing
522
- // (CJS empty-export strip, inline sourceMap, `//# sourceURL=`) + `cacheSet` — is
523
- // ONE native call now (nub-native `transformCached`): the cache key (NUB_VERSION
524
- // is the sole version component — a new release ships any emit change + a rebuilt
525
- // addon), the 16-hex integrity prefix, the `c`/`m` format byte, and the atomic
526
- // `*.tmp`-then-rename write all live in Rust, byte-identical to the old JS cache so
527
- // warm caches survive. This JS file keeps only (a) the cache enable/disable signal
528
- // and (b) the cache directory it passes IN, so the policy stays in JS and native
529
- // just does the I/O against the dir nub hands it.
530
- //
531
- // Disable the transpile cache when (a) the permission model is active (writing a
532
- // cache file may not be granted), or (b) the user set `NODE_COMPILE_CACHE=0` —
533
- // Node's compile-cache disable signal, which nub honors as "no caching in this
534
- // pipeline" (one knob for both V8's compile cache and nub's transpile cache; no
535
- // nub-specific env var). Per wiki/runtime/transpile-cache.md (the maintainer 2026-05-18).
536
- const CACHE_DISABLED =
537
- process.permission?.has !== undefined || process.env.NODE_COMPILE_CACHE === "0";
538
- // Resolved lazily (memoized) rather than at module eval, because on the floor the
539
- // node:path builtins it needs aren't bound until __ensureBuiltins() runs on first
540
- // hook use. `null` = disabled / no writable dir; `undefined` cacheDirResolved means
541
- // "not yet computed".
542
- let cacheDir = null;
543
- let cacheDirResolved = false;
544
- function getCacheDir() {
545
- if (cacheDirResolved) return cacheDir;
546
- cacheDirResolved = true;
547
- if (CACHE_DISABLED) return cacheDir;
548
- __ensureBuiltins();
549
- const base = process.env.XDG_CACHE_HOME || (process.env.HOME ? join(process.env.HOME, ".cache") : null);
550
- if (base) {
551
- cacheDir = join(base, "nub", "transpile");
552
- try { mkdirSync(cacheDir, { recursive: true }); } catch { cacheDir = null; }
553
- }
554
- return cacheDir;
555
- }
556
-
557
- // ── Bounded-cache maintenance ───────────────────────────────────────
558
- const CACHE_MAX_BYTES = 512 * 1024 * 1024; // 512 MiB — bounds runaway growth, not normal use
559
- const SWEEP_INTERVAL_MS = 24 * 60 * 60 * 1000; // ≤ one sweep per day
560
- export function maybeSweepCache() {
561
- __ensureBuiltins();
562
- const dir = getCacheDir();
563
- if (!dir) return;
564
- // Workers inherit this preload (via execArgv); only the main thread sweeps.
565
- try {
566
- if (!__require("node:worker_threads").isMainThread) return;
567
- } catch {
568
- return;
569
- }
570
- const sentinel = join(dir, ".sweep");
571
- const s = statSync(sentinel, { throwIfNoEntry: false });
572
- if (s && Date.now() - s.mtimeMs < SWEEP_INTERVAL_MS) return;
573
- try {
574
- writeFileSync(sentinel, "");
575
- } catch {
576
- return;
577
- }
578
- import("./cache-evict.mjs")
579
- .then((m) => m.sweepCache(dir, CACHE_MAX_BYTES))
580
- .catch(() => {});
581
- }
582
-
583
- // ── Transpile ───────────────────────────────────────────────────────
584
- // Transpile a TS/JSX file to JS, returning `{ format, source, shortCircuit }` in
585
- // the shape both hook tiers hand back to Node. Format is detected (not derived
586
- // from extension alone), so a CommonJS-syntax `.ts` is reported `commonjs` — the
587
- // fix that makes `require()` of a TS file work on the compat tier, where Node's
588
- // CJS translator loads it via this hook and keys on the returned format.
589
- export function loadTranspile(url, ext) {
590
- __ensureBuiltins();
591
- const filePath = fileURLToPath(url);
592
- const source = readFileSync(filePath, "utf8");
593
- const dir = dirname(filePath);
594
- // The transform-relevant compilerOptions slice + the byte-for-byte cache-key
595
- // component (`tsconfigHash`) both come from the native tsconfig reader.
596
- const { compilerOptions: co, tsconfigHash } = getTsconfigForDir(dir);
597
-
598
- // The nearest package.json `type` decides the format of an ambiguous extension
599
- // (.ts/.tsx/.jsx); .mts/.cts are explicit so its lookup is skipped. The chosen
600
- // format is folded into the cache key (and the entry's leading byte) by native.
601
- const pkgType = ext === ".mts" || ext === ".cts" ? undefined : getPackageType(dir);
602
- // ONE detectModuleInfo parse for both the format decision and the decorator
603
- // guard below: `moduleInfo` is the parsed ModuleInfo when the format needed a
604
- // parse (ambiguous ext, no explicit `type`), else null (a no-parse short-circuit).
605
- const { format, info: moduleInfo } = moduleFormatWithInfo(ext, pkgType, filePath, source);
606
-
607
- const lang = ext === ".tsx" ? "tsx" : ext === ".jsx" ? "jsx" : "ts";
608
-
609
- const opts = {
610
- lang,
611
- sourceType: format === "commonjs" ? "commonjs" : "module",
612
- sourcemap: true,
613
- // Lower syntax newer than the 22.15 floor. Critically this downlevels
614
- // `using`/`await using` (Explicit Resource Management) — unparseable on Node
615
- // 22's V8 — into the vendored `@oxc-project/runtime/helpers/usingCtx` shape,
616
- // which resolves via VENDORED_PACKAGES. Without a target, oxc leaves `using`
617
- // verbatim and Node 22 throws a SyntaxError. es2022 is the highest target
618
- // that still lowers `using` while leaving everything Node 22 already supports
619
- // (top-level await, class fields, private methods) untouched.
620
- target: "es2022",
621
- typescript: {},
622
- // Decorators default to OFF (Stage-3 mode), matching tsc: legacy semantics
623
- // and metadata are opt-in via tsconfig. See wiki/runtime/non-erasable-syntax.md.
624
- decorator: co?.experimentalDecorators === true
625
- ? { legacy: true, emitDecoratorMetadata: co?.emitDecoratorMetadata === true }
626
- : undefined,
627
- };
628
- if (ext === ".tsx" || ext === ".jsx") {
629
- opts.jsx = {
630
- runtime: co?.jsx === "react" ? "classic" : "automatic",
631
- importSource: co?.jsxImportSource || "react",
632
- };
633
- if (co?.jsxFactory) opts.jsx.pragma = co.jsxFactory;
634
- if (co?.jsxFragmentFactory) opts.jsx.pragmaFrag = co.jsxFragmentFactory;
635
- }
636
-
637
- // Stage-3 decorators: oxc returns errors:[] and emits the `@decorator` syntax
638
- // verbatim, so the result-error check below never fires and V8 throws a bare
639
- // SyntaxError. When legacy mode is off and decorator syntax is present, reject
640
- // with the documented Option-A diagnostic instead. (Cheap `source.includes("@")`
641
- // pre-filter keeps decorator-free files off the native parser; runs BEFORE the
642
- // cache so the diagnostic surfaces even on what would be a warm hit.) Reuse the
643
- // `hasDecorators` flag from the format parse above when it ran (`moduleInfo`
644
- // non-null), so the ambiguous-ext + `@` path detects ONCE; on a no-parse
645
- // short-circuit (`.mts`/`.cts`/explicit `type`) it does its own single parse.
646
- if (co?.experimentalDecorators !== true && source.includes("@") &&
647
- (moduleInfo ? moduleInfo.hasDecorators : hasDecoratorSyntax(filePath, source, lang))) {
648
- throw stage3DecoratorError(filePath);
649
- }
650
-
651
- // cacheGet + transform-on-miss + post-process (CJS empty-export strip, inline
652
- // sourceMap, sourceURL append) + cacheSet — ALL native, byte-identical on-disk.
653
- // The cache key folds in ext + tsconfigHash + pkgType (same source, different
654
- // type → different format → distinct entry). `cacheDir: null/undefined` is the
655
- // JS enable/disable signal: native then skips all cache I/O and just transforms.
656
- const formatByte = format === "commonjs" ? "c" : "m";
657
- const result = nubNative.transformCached(
658
- filePath, source, opts, ext, tsconfigHash || "", pkgType || "", formatByte, getCacheDir() ?? undefined,
659
- );
660
- if (result.errors.length > 0) {
661
- const details = result.errors.map((e) => e.codeframe || e.message).join("\n\n");
662
- throw new Error(`Transpile error in ${filePath}:\n${details}`);
663
- }
664
- return { format: result.format, source: result.code, shortCircuit: true };
665
- }
666
-
667
- // Project-source plain JS (`.js`/`.mjs`/`.cjs`) gate. Returns a transpiled load
668
- // result ONLY when the file carries syntax oxc lowers at nub's es2022 target
669
- // (`using`/`await using`, a `v`-flag RegExp, or decorators); otherwise returns
670
- // `null`, meaning "this file needs no transform — handle it with Node's OWN loader,
671
- // exactly as a non-listed extension." This is why `.js`/`.mjs`/`.cjs` are NOT in
672
- // TRANSPILE_EXTS: a no-op plain-JS file must take Node's native load path
673
- // byte-for-byte (preserving the `commonjs-sync` relabel, require.cache, the
674
- // require-of-ESM-syntax-`.cjs` error — all of which intercepting the file would
675
- // break), and oxc would reformat it (quotes/semicolons/whitespace + a sourcemap
676
- // footer) if we ran it through anyway. The verdict rides ONE parse (the same one
677
- // `detectModuleInfo` does for format detection). node_modules is gated at the call
678
- // sites (the byte-parity boundary). JSX-in-`.js` is out of scope (lang is "ts",
679
- // which does not parse JSX); use `.jsx`.
680
- export function maybeTranspilePlainJs(url, ext) {
681
- __ensureBuiltins();
682
- const filePath = fileURLToPath(url);
683
- let source;
684
- try {
685
- source = readFileSync(filePath, "utf8");
686
- } catch {
687
- // Unreadable here → let Node's loader surface its own error.
688
- return null;
689
- }
690
- // lang "ts" parses all JS (a TS superset) but NOT JSX — JSX-in-.js is out of scope.
691
- const info = detectModuleInfo(filePath, source, "ts");
692
- if (!info.transformableSyntax && !info.hasDecorators) {
693
- return null; // no-op: Node's native loader handles it, byte-identical.
694
- }
695
- // Transformable: run the SAME pipeline as TS/JSX (target es2022 lowering, tsconfig,
696
- // source maps, the Stage-3 decorator guard, format detection, cache). loadTranspile
697
- // re-reads + re-parses, but only for the rare file that actually needs lowering.
698
- return loadTranspile(url, ext);
699
- }
700
-
701
- // ── Data-format imports ─────────────────────────────────────────────
702
- function lazyRequire(pkg) {
703
- try { return __require(pkg); } catch {
704
- throw new Error(`Nub: importing this file requires the "${pkg}" package.\nInstall it: npm install ${pkg}`);
705
- }
706
- }
707
-
708
- function stripJsonComments(text) {
709
- let result = "", i = 0, inString = false, escape = false;
710
- while (i < text.length) {
711
- const ch = text[i];
712
- if (escape) { result += ch; escape = false; i++; continue; }
713
- if (inString) { if (ch === "\\") escape = true; if (ch === '"') inString = false; result += ch; i++; continue; }
714
- if (ch === '"') { inString = true; result += ch; i++; continue; }
715
- if (ch === "/" && text[i + 1] === "/") { while (i < text.length && text[i] !== "\n") i++; continue; }
716
- if (ch === "/" && text[i + 1] === "*") { i += 2; while (i < text.length && !(text[i] === "*" && text[i + 1] === "/")) i++; i += 2; continue; }
717
- result += ch; i++;
718
- }
719
- return result;
720
- }
721
-
722
- export function loadData(url, ext) {
723
- const filePath = fileURLToPath(url);
724
- const raw = readFileSync(filePath, "utf8");
725
- const kind = DATA_EXTS[ext];
726
-
727
- if (kind === "txt") {
728
- return { format: "module", source: `export default ${JSON.stringify(raw)};\n`, shortCircuit: true };
729
- }
730
-
731
- let parsed;
732
- if (nubNative) {
733
- if (kind === "yaml") parsed = nubNative.parseYaml(raw);
734
- else if (kind === "toml") parsed = nubNative.parseToml(raw);
735
- else if (kind === "json5") parsed = nubNative.parseJson5(raw);
736
- else if (kind === "jsonc") parsed = nubNative.parseJsonc(raw);
737
- } else {
738
- if (kind === "yaml") parsed = lazyRequire("yaml").parse(raw);
739
- else if (kind === "toml") parsed = lazyRequire("@iarna/toml").parse(raw);
740
- else if (kind === "json5") parsed = lazyRequire("json5").parse(raw);
741
- else if (kind === "jsonc") parsed = JSON.parse(stripJsonComments(raw));
742
- }
743
-
744
- if (parsed == null) {
745
- return { format: "module", source: "export default undefined;\n", shortCircuit: true };
746
- }
747
-
748
- // Default export only. Data modules deliberately do NOT emit per-key named
749
- // exports: named imports of data are categorically un-typeable in TypeScript
750
- // (a `declare module "*.yaml"` wildcard has no per-key export index signature),
751
- // and default-only matches Node's own JSON modules. Consumers destructure the
752
- // default — `import cfg from "./c.yaml"; const { host } = cfg;` — which the
753
- // `@nubjs/types` `Record<string, unknown>` default type makes sound.
754
- const code = `export default ${JSON.stringify(parsed)};\n`;
755
- return { format: "module", source: code, shortCircuit: true };
756
- }