xbintsc 0.6.18 → 0.6.20

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 (393) hide show
  1. package/dist/src/ast/common.d.ts +2 -2
  2. package/dist/src/ast/declarations.d.ts +2 -0
  3. package/dist/src/ast/expressions.d.ts +5 -0
  4. package/dist/src/ast/kinds.d.ts +2 -0
  5. package/dist/src/ast/kinds.js +2 -0
  6. package/dist/src/ast/kinds.js.map +1 -1
  7. package/dist/src/ast/types.d.ts +2 -0
  8. package/dist/src/binder/binder.d.ts +6 -0
  9. package/dist/src/binder/binder.js +13 -0
  10. package/dist/src/binder/binder.js.map +1 -1
  11. package/dist/src/binder/references.js +9 -2
  12. package/dist/src/binder/references.js.map +1 -1
  13. package/dist/src/checker/assignability.js +11 -3
  14. package/dist/src/checker/assignability.js.map +1 -1
  15. package/dist/src/checker/calls.js +4 -0
  16. package/dist/src/checker/calls.js.map +1 -1
  17. package/dist/src/checker/flow.js +16 -12
  18. package/dist/src/checker/flow.js.map +1 -1
  19. package/dist/src/checker/globals.js +3 -1
  20. package/dist/src/checker/globals.js.map +1 -1
  21. package/dist/src/checker/type-system.js +1 -0
  22. package/dist/src/checker/type-system.js.map +1 -1
  23. package/dist/src/checker/typecheck.js +8 -1
  24. package/dist/src/checker/typecheck.js.map +1 -1
  25. package/dist/src/cli/help.d.ts +1 -1
  26. package/dist/src/cli/main.js +3 -0
  27. package/dist/src/cli/main.js.map +1 -1
  28. package/dist/src/codegen/generator/calls/access.js +3 -1
  29. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  30. package/dist/src/codegen/generator/calls/invocation.js +8 -4
  31. package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
  32. package/dist/src/codegen/generator/context.js +3 -3
  33. package/dist/src/codegen/generator/context.js.map +1 -1
  34. package/dist/src/codegen/generator/expressions/assignment.js +1 -0
  35. package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
  36. package/dist/src/codegen/generator/expressions/module-values.d.ts +21 -0
  37. package/dist/src/codegen/generator/expressions/module-values.js +84 -0
  38. package/dist/src/codegen/generator/expressions/module-values.js.map +1 -0
  39. package/dist/src/codegen/generator/expressions/primary.js +38 -6
  40. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  41. package/dist/src/codegen/generator/expressions.d.ts +2 -1
  42. package/dist/src/codegen/generator/expressions.js +2 -1
  43. package/dist/src/codegen/generator/expressions.js.map +1 -1
  44. package/dist/src/codegen/generator/module.js +16 -6
  45. package/dist/src/codegen/generator/module.js.map +1 -1
  46. package/dist/src/codegen/generator/state.js +6 -0
  47. package/dist/src/codegen/generator/state.js.map +1 -1
  48. package/dist/src/codegen/generator/statements/dispatch.js +10 -0
  49. package/dist/src/codegen/generator/statements/dispatch.js.map +1 -1
  50. package/dist/src/codegen/generator/tables.d.ts +7 -0
  51. package/dist/src/codegen/generator/tables.js +26 -0
  52. package/dist/src/codegen/generator/tables.js.map +1 -1
  53. package/dist/src/driver/bundler/commonjs.js +9 -5
  54. package/dist/src/driver/bundler/commonjs.js.map +1 -1
  55. package/dist/src/driver/bundler/deferred.d.ts +1 -1
  56. package/dist/src/driver/bundler/deferred.js +2 -2
  57. package/dist/src/driver/bundler/deferred.js.map +1 -1
  58. package/dist/src/driver/bundler/dynamic-import.d.ts +30 -0
  59. package/dist/src/driver/bundler/dynamic-import.js +123 -0
  60. package/dist/src/driver/bundler/dynamic-import.js.map +1 -0
  61. package/dist/src/driver/bundler/graph.d.ts +1 -1
  62. package/dist/src/driver/bundler/graph.js +30 -12
  63. package/dist/src/driver/bundler/graph.js.map +1 -1
  64. package/dist/src/driver/bundler/merge.d.ts +1 -1
  65. package/dist/src/driver/bundler/merge.js +37 -55
  66. package/dist/src/driver/bundler/merge.js.map +1 -1
  67. package/dist/src/driver/bundler/namespace-import.d.ts +7 -0
  68. package/dist/src/driver/bundler/namespace-import.js +46 -0
  69. package/dist/src/driver/bundler/namespace-import.js.map +1 -0
  70. package/dist/src/driver/bundler/reexport-fixup.d.ts +14 -0
  71. package/dist/src/driver/bundler/reexport-fixup.js +92 -0
  72. package/dist/src/driver/bundler/reexport-fixup.js.map +1 -0
  73. package/dist/src/driver/bundler/resolve.d.ts +6 -5
  74. package/dist/src/driver/bundler/resolve.js +52 -6
  75. package/dist/src/driver/bundler/resolve.js.map +1 -1
  76. package/dist/src/driver/bundler/symbols.d.ts +4 -0
  77. package/dist/src/driver/bundler/symbols.js +12 -0
  78. package/dist/src/driver/bundler/symbols.js.map +1 -1
  79. package/dist/src/driver/bundler/types.d.ts +1 -0
  80. package/dist/src/driver/compiler.js +1 -1
  81. package/dist/src/driver/compiler.js.map +1 -1
  82. package/dist/src/driver/config.d.ts +2 -0
  83. package/dist/src/driver/config.js +18 -0
  84. package/dist/src/driver/config.js.map +1 -1
  85. package/dist/src/driver/frontend.d.ts +3 -1
  86. package/dist/src/driver/frontend.js +5 -4
  87. package/dist/src/driver/frontend.js.map +1 -1
  88. package/dist/src/driver/options.d.ts +5 -0
  89. package/dist/src/driver/runtime-objects.d.ts +1 -1
  90. package/dist/src/driver/runtime-objects.js +2 -0
  91. package/dist/src/driver/runtime-objects.js.map +1 -1
  92. package/dist/src/driver/version.d.ts +1 -1
  93. package/dist/src/driver/version.js +1 -1
  94. package/dist/src/extensions/node/async-hooks/index.d.ts +6 -0
  95. package/dist/src/extensions/node/async-hooks/index.js +19 -0
  96. package/dist/src/extensions/node/async-hooks/index.js.map +1 -0
  97. package/dist/src/extensions/node/buffer/index.js +2 -0
  98. package/dist/src/extensions/node/buffer/index.js.map +1 -1
  99. package/dist/src/extensions/node/child_process/index.js +10 -1
  100. package/dist/src/extensions/node/child_process/index.js.map +1 -1
  101. package/dist/src/extensions/node/console/index.d.ts +6 -0
  102. package/dist/src/extensions/node/console/index.js +34 -0
  103. package/dist/src/extensions/node/console/index.js.map +1 -0
  104. package/dist/src/extensions/node/constants/index.d.ts +6 -0
  105. package/dist/src/extensions/node/constants/index.js +27 -0
  106. package/dist/src/extensions/node/constants/index.js.map +1 -0
  107. package/dist/src/extensions/node/diagnostics-channel/index.d.ts +5 -0
  108. package/dist/src/extensions/node/diagnostics-channel/index.js +16 -0
  109. package/dist/src/extensions/node/diagnostics-channel/index.js.map +1 -0
  110. package/dist/src/extensions/node/dns/index.d.ts +5 -0
  111. package/dist/src/extensions/node/dns/index.js +14 -0
  112. package/dist/src/extensions/node/dns/index.js.map +1 -0
  113. package/dist/src/extensions/node/events/index.js +1 -0
  114. package/dist/src/extensions/node/events/index.js.map +1 -1
  115. package/dist/src/extensions/node/http/index.js +5 -1
  116. package/dist/src/extensions/node/http/index.js.map +1 -1
  117. package/dist/src/extensions/node/http2/index.d.ts +5 -0
  118. package/dist/src/extensions/node/http2/index.js +16 -0
  119. package/dist/src/extensions/node/http2/index.js.map +1 -0
  120. package/dist/src/extensions/node/index.js +36 -0
  121. package/dist/src/extensions/node/index.js.map +1 -1
  122. package/dist/src/extensions/node/module/index.d.ts +5 -0
  123. package/dist/src/extensions/node/module/index.js +15 -0
  124. package/dist/src/extensions/node/module/index.js.map +1 -0
  125. package/dist/src/extensions/node/os/index.js +4 -1
  126. package/dist/src/extensions/node/os/index.js.map +1 -1
  127. package/dist/src/extensions/node/path/index.js +9 -1
  128. package/dist/src/extensions/node/path/index.js.map +1 -1
  129. package/dist/src/extensions/node/perf_hooks/index.d.ts +6 -0
  130. package/dist/src/extensions/node/perf_hooks/index.js +15 -0
  131. package/dist/src/extensions/node/perf_hooks/index.js.map +1 -0
  132. package/dist/src/extensions/node/readline-promises/index.d.ts +5 -0
  133. package/dist/src/extensions/node/readline-promises/index.js +14 -0
  134. package/dist/src/extensions/node/readline-promises/index.js.map +1 -0
  135. package/dist/src/extensions/node/sqlite/index.d.ts +6 -0
  136. package/dist/src/extensions/node/sqlite/index.js +16 -0
  137. package/dist/src/extensions/node/sqlite/index.js.map +1 -0
  138. package/dist/src/extensions/node/stream/index.js +2 -0
  139. package/dist/src/extensions/node/stream/index.js.map +1 -1
  140. package/dist/src/extensions/node/stream-web/index.d.ts +5 -0
  141. package/dist/src/extensions/node/stream-web/index.js +17 -0
  142. package/dist/src/extensions/node/stream-web/index.js.map +1 -0
  143. package/dist/src/extensions/node/string-decoder/index.d.ts +5 -0
  144. package/dist/src/extensions/node/string-decoder/index.js +14 -0
  145. package/dist/src/extensions/node/string-decoder/index.js.map +1 -0
  146. package/dist/src/extensions/node/timers/index.d.ts +6 -0
  147. package/dist/src/extensions/node/timers/index.js +20 -0
  148. package/dist/src/extensions/node/timers/index.js.map +1 -0
  149. package/dist/src/extensions/node/timers-promises/index.d.ts +5 -0
  150. package/dist/src/extensions/node/timers-promises/index.js +15 -0
  151. package/dist/src/extensions/node/timers-promises/index.js.map +1 -0
  152. package/dist/src/extensions/node/tls/index.d.ts +5 -0
  153. package/dist/src/extensions/node/tls/index.js +16 -0
  154. package/dist/src/extensions/node/tls/index.js.map +1 -0
  155. package/dist/src/extensions/node/tty/index.d.ts +5 -0
  156. package/dist/src/extensions/node/tty/index.js +14 -0
  157. package/dist/src/extensions/node/tty/index.js.map +1 -0
  158. package/dist/src/extensions/node/url/index.js +1 -0
  159. package/dist/src/extensions/node/url/index.js.map +1 -1
  160. package/dist/src/extensions/node/util/index.js +15 -1
  161. package/dist/src/extensions/node/util/index.js.map +1 -1
  162. package/dist/src/extensions/node/util-types/index.d.ts +6 -0
  163. package/dist/src/extensions/node/util-types/index.js +26 -0
  164. package/dist/src/extensions/node/util-types/index.js.map +1 -0
  165. package/dist/src/extensions/node/worker_threads/index.js +1 -0
  166. package/dist/src/extensions/node/worker_threads/index.js.map +1 -1
  167. package/dist/src/extensions/node/zlib/compression.d.ts +10 -0
  168. package/dist/src/extensions/node/zlib/compression.js +44 -0
  169. package/dist/src/extensions/node/zlib/compression.js.map +1 -0
  170. package/dist/src/extensions/node/zlib/index.d.ts +5 -2
  171. package/dist/src/extensions/node/zlib/index.js +21 -2
  172. package/dist/src/extensions/node/zlib/index.js.map +1 -1
  173. package/dist/src/lexer/scanner/punctuation.js +8 -2
  174. package/dist/src/lexer/scanner/punctuation.js.map +1 -1
  175. package/dist/src/lexer/scanner/regex.d.ts +3 -1
  176. package/dist/src/lexer/scanner/regex.js +32 -22
  177. package/dist/src/lexer/scanner/regex.js.map +1 -1
  178. package/dist/src/lexer/scanner.d.ts +2 -0
  179. package/dist/src/lexer/scanner.js +8 -0
  180. package/dist/src/lexer/scanner.js.map +1 -1
  181. package/dist/src/lexer/token.d.ts +1 -0
  182. package/dist/src/lexer/token.js +2 -0
  183. package/dist/src/lexer/token.js.map +1 -1
  184. package/dist/src/parser/declarations/classes.js +7 -0
  185. package/dist/src/parser/declarations/classes.js.map +1 -1
  186. package/dist/src/parser/declarations/functions.js +8 -2
  187. package/dist/src/parser/declarations/functions.js.map +1 -1
  188. package/dist/src/parser/expressions.d.ts +2 -2
  189. package/dist/src/parser/expressions.js +32 -17
  190. package/dist/src/parser/expressions.js.map +1 -1
  191. package/dist/src/parser/helpers.js +1 -0
  192. package/dist/src/parser/helpers.js.map +1 -1
  193. package/dist/src/parser/literals.js +27 -0
  194. package/dist/src/parser/literals.js.map +1 -1
  195. package/dist/src/parser/statements.js +3 -0
  196. package/dist/src/parser/statements.js.map +1 -1
  197. package/dist/src/parser/types.js +106 -45
  198. package/dist/src/parser/types.js.map +1 -1
  199. package/dist/tests/binder/binder.test.js +8 -1
  200. package/dist/tests/binder/binder.test.js.map +1 -1
  201. package/dist/tests/checker/checker.test.js +63 -0
  202. package/dist/tests/checker/checker.test.js.map +1 -1
  203. package/dist/tests/codegen/expressions.test.js +8 -0
  204. package/dist/tests/codegen/expressions.test.js.map +1 -1
  205. package/dist/tests/conformance/test262/manifest.js +9 -10
  206. package/dist/tests/conformance/test262/manifest.js.map +1 -1
  207. package/dist/tests/driver/bundler-resolve.test.js +22 -0
  208. package/dist/tests/driver/bundler-resolve.test.js.map +1 -1
  209. package/dist/tests/driver/config.test.js +15 -0
  210. package/dist/tests/driver/config.test.js.map +1 -1
  211. package/dist/tests/driver/deferred-reexport.test.d.ts +9 -0
  212. package/dist/tests/driver/deferred-reexport.test.js +62 -0
  213. package/dist/tests/driver/deferred-reexport.test.js.map +1 -0
  214. package/dist/tests/driver/modules.test.js +110 -11
  215. package/dist/tests/driver/modules.test.js.map +1 -1
  216. package/dist/tests/e2e/compile-basics.test.js +11 -0
  217. package/dist/tests/e2e/compile-basics.test.js.map +1 -1
  218. package/dist/tests/e2e/compile-modules.test.js +40 -0
  219. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  220. package/dist/tests/e2e/compile-node.test.js +49 -0
  221. package/dist/tests/e2e/compile-node.test.js.map +1 -1
  222. package/dist/tests/e2e/compile-objects-classes.test.js +32 -0
  223. package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
  224. package/dist/tests/e2e/node-modules.test.js +174 -0
  225. package/dist/tests/e2e/node-modules.test.js.map +1 -1
  226. package/dist/tests/e2e/npm-modules.test.js +8 -0
  227. package/dist/tests/e2e/npm-modules.test.js.map +1 -1
  228. package/dist/tests/e2e/weak-collections.test.js +12 -0
  229. package/dist/tests/e2e/weak-collections.test.js.map +1 -1
  230. package/dist/tests/lexer/scanner.test.js +17 -0
  231. package/dist/tests/lexer/scanner.test.js.map +1 -1
  232. package/dist/tests/parser/declarations.test.js +24 -0
  233. package/dist/tests/parser/declarations.test.js.map +1 -1
  234. package/dist/tests/parser/expressions.test.js +34 -7
  235. package/dist/tests/parser/expressions.test.js.map +1 -1
  236. package/dist/tests/parser/literals.test.js +15 -0
  237. package/dist/tests/parser/literals.test.js.map +1 -1
  238. package/dist/tests/parser/types.test.js +26 -0
  239. package/dist/tests/parser/types.test.js.map +1 -1
  240. package/doc/ai/language-support.md +4 -2
  241. package/doc/ai/zh-CN/language-support.md +4 -2
  242. package/doc/implemented/node/buffer.md +2 -0
  243. package/doc/implemented/node/child-process.md +29 -6
  244. package/doc/implemented/node/http.md +2 -0
  245. package/doc/implemented/node/os.md +1 -0
  246. package/doc/implemented/node/path.md +3 -0
  247. package/doc/implemented/node/stream.md +3 -0
  248. package/doc/implemented/node/util.md +1 -0
  249. package/doc/implemented/node/zlib.md +12 -1
  250. package/doc/implemented/node.md +8 -1
  251. package/doc/implemented/wasm.md +22 -0
  252. package/doc/implemented.md +1 -0
  253. package/doc/support-matrix.md +3 -3
  254. package/doc/unimplemented/node/modules.md +4 -3
  255. package/doc/unimplemented/stdlib.md +1 -0
  256. package/doc/unimplemented/wasm.md +15 -0
  257. package/doc/unimplemented.md +1 -0
  258. package/doc/zh-CN/implemented/node/child-process.md +27 -5
  259. package/doc/zh-CN/implemented/node.md +1 -1
  260. package/doc/zh-CN/implemented/wasm.md +20 -0
  261. package/doc/zh-CN/implemented.md +1 -0
  262. package/doc/zh-CN/support-matrix.md +3 -3
  263. package/doc/zh-CN/unimplemented/node/modules.md +3 -2
  264. package/doc/zh-CN/unimplemented/stdlib.md +1 -0
  265. package/doc/zh-CN/unimplemented/wasm.md +14 -0
  266. package/doc/zh-CN/unimplemented.md +1 -0
  267. package/package.json +7 -7
  268. package/runtime/ext_node/async_hooks/async_hooks.c +59 -0
  269. package/runtime/ext_node/buffer/parts/static-api.inc +39 -0
  270. package/runtime/ext_node/child_process/spawn.c +201 -0
  271. package/runtime/ext_node/child_process/spawn.h +56 -0
  272. package/runtime/ext_node/child_process/spawn_posix.c +206 -0
  273. package/runtime/ext_node/child_process/spawn_win.c +276 -0
  274. package/runtime/ext_node/console/console.c +67 -0
  275. package/runtime/ext_node/constants/constants.c +72 -0
  276. package/runtime/ext_node/diagnostics_channel/diagnostics_channel.c +61 -0
  277. package/runtime/ext_node/dns/dns.c +77 -0
  278. package/runtime/ext_node/events/events.c +7 -0
  279. package/runtime/ext_node/http/http.c +38 -0
  280. package/runtime/ext_node/http2/http2.c +26 -0
  281. package/runtime/ext_node/module/module.c +31 -0
  282. package/runtime/ext_node/os/os.c +42 -0
  283. package/runtime/ext_node/path/path.c +93 -0
  284. package/runtime/ext_node/perf_hooks/perf_hooks.c +22 -0
  285. package/runtime/ext_node/readline_promises/readline_promises.c +59 -0
  286. package/runtime/ext_node/sqlite/sqlite.c +24 -0
  287. package/runtime/ext_node/stream/stream.c +19 -1
  288. package/runtime/ext_node/stream_web/stream_web.c +22 -0
  289. package/runtime/ext_node/string_decoder/string_decoder.c +31 -0
  290. package/runtime/ext_node/timers_promises/timers_promises.c +58 -0
  291. package/runtime/ext_node/tls/tls.c +26 -0
  292. package/runtime/ext_node/tty/tty.c +18 -0
  293. package/runtime/ext_node/util/util.c +84 -0
  294. package/runtime/ext_node/worker_threads/worker_threads.c +8 -0
  295. package/runtime/ext_node/zlib/miniz/compression_bridge.c +43 -0
  296. package/runtime/ext_node/zlib/miniz/miniz.c +646 -0
  297. package/runtime/ext_node/zlib/miniz/miniz.h +615 -0
  298. package/runtime/ext_node/zlib/miniz/miniz_common.h +89 -0
  299. package/runtime/ext_node/zlib/miniz/miniz_export.h +4 -0
  300. package/runtime/ext_node/zlib/miniz/miniz_tdef.c +1653 -0
  301. package/runtime/ext_node/zlib/miniz/miniz_tdef.h +206 -0
  302. package/runtime/ext_node/zlib/miniz/miniz_tinfl.c +778 -0
  303. package/runtime/ext_node/zlib/miniz/miniz_tinfl.h +150 -0
  304. package/runtime/ext_node/zlib/miniz/miniz_zip.h +454 -0
  305. package/runtime/ext_node/zlib/zlib.c +194 -0
  306. package/runtime/xt_builtins.c +1 -0
  307. package/runtime/xt_constructors.c +5 -0
  308. package/runtime/xt_module_values.c +29 -0
  309. package/runtime/xt_weak.c +43 -0
  310. package/runtime/xt_webassembly.c +53 -0
  311. package/scripts/check-file-length.ts +10 -0
  312. package/src/ast/common.ts +2 -0
  313. package/src/ast/declarations.ts +2 -0
  314. package/src/ast/expressions.ts +6 -0
  315. package/src/ast/kinds.ts +2 -0
  316. package/src/ast/types.ts +2 -0
  317. package/src/binder/binder.ts +13 -0
  318. package/src/binder/references.ts +9 -2
  319. package/src/checker/assignability.ts +12 -2
  320. package/src/checker/calls.ts +3 -0
  321. package/src/checker/flow.ts +13 -9
  322. package/src/checker/globals.ts +3 -0
  323. package/src/checker/type-system.ts +1 -0
  324. package/src/checker/typecheck.ts +8 -1
  325. package/src/cli/main.ts +3 -0
  326. package/src/codegen/generator/calls/access.ts +4 -1
  327. package/src/codegen/generator/calls/invocation.ts +8 -4
  328. package/src/codegen/generator/context.ts +5 -3
  329. package/src/codegen/generator/expressions/assignment.ts +1 -0
  330. package/src/codegen/generator/expressions/module-values.ts +105 -0
  331. package/src/codegen/generator/expressions/primary.ts +35 -5
  332. package/src/codegen/generator/expressions.ts +3 -0
  333. package/src/codegen/generator/module.ts +16 -5
  334. package/src/codegen/generator/state.ts +6 -0
  335. package/src/codegen/generator/statements/dispatch.ts +9 -0
  336. package/src/codegen/generator/tables.ts +27 -0
  337. package/src/driver/bundler/commonjs.ts +18 -5
  338. package/src/driver/bundler/deferred.ts +2 -1
  339. package/src/driver/bundler/dynamic-import.ts +135 -0
  340. package/src/driver/bundler/graph.ts +34 -19
  341. package/src/driver/bundler/merge.ts +38 -64
  342. package/src/driver/bundler/namespace-import.ts +59 -0
  343. package/src/driver/bundler/reexport-fixup.ts +102 -0
  344. package/src/driver/bundler/resolve.ts +49 -5
  345. package/src/driver/bundler/symbols.ts +13 -0
  346. package/src/driver/bundler/types.ts +1 -0
  347. package/src/driver/compiler.ts +1 -1
  348. package/src/driver/config.ts +20 -0
  349. package/src/driver/frontend.ts +13 -8
  350. package/src/driver/options.ts +5 -0
  351. package/src/driver/runtime-objects.ts +2 -0
  352. package/src/driver/version.ts +1 -1
  353. package/src/extensions/node/async-hooks/index.ts +23 -0
  354. package/src/extensions/node/buffer/index.ts +2 -0
  355. package/src/extensions/node/child_process/index.ts +13 -1
  356. package/src/extensions/node/console/index.ts +44 -0
  357. package/src/extensions/node/constants/index.ts +34 -0
  358. package/src/extensions/node/diagnostics-channel/index.ts +20 -0
  359. package/src/extensions/node/dns/index.ts +18 -0
  360. package/src/extensions/node/events/index.ts +1 -0
  361. package/src/extensions/node/http/index.ts +5 -3
  362. package/src/extensions/node/http2/index.ts +20 -0
  363. package/src/extensions/node/index.ts +36 -0
  364. package/src/extensions/node/module/index.ts +19 -0
  365. package/src/extensions/node/os/index.ts +4 -3
  366. package/src/extensions/node/path/index.ts +9 -3
  367. package/src/extensions/node/perf_hooks/index.ts +19 -0
  368. package/src/extensions/node/readline-promises/index.ts +18 -0
  369. package/src/extensions/node/sqlite/index.ts +20 -0
  370. package/src/extensions/node/stream/index.ts +3 -0
  371. package/src/extensions/node/stream-web/index.ts +21 -0
  372. package/src/extensions/node/string-decoder/index.ts +18 -0
  373. package/src/extensions/node/timers/index.ts +27 -0
  374. package/src/extensions/node/timers-promises/index.ts +19 -0
  375. package/src/extensions/node/tls/index.ts +20 -0
  376. package/src/extensions/node/tty/index.ts +18 -0
  377. package/src/extensions/node/url/index.ts +1 -0
  378. package/src/extensions/node/util/index.ts +15 -3
  379. package/src/extensions/node/util-types/index.ts +33 -0
  380. package/src/extensions/node/worker_threads/index.ts +1 -0
  381. package/src/extensions/node/zlib/compression.ts +48 -0
  382. package/src/extensions/node/zlib/index.ts +23 -2
  383. package/src/lexer/scanner/punctuation.ts +7 -1
  384. package/src/lexer/scanner/regex.ts +31 -22
  385. package/src/lexer/scanner.ts +7 -0
  386. package/src/lexer/token.ts +2 -0
  387. package/src/parser/declarations/classes.ts +7 -0
  388. package/src/parser/declarations/functions.ts +9 -3
  389. package/src/parser/expressions.ts +29 -20
  390. package/src/parser/helpers.ts +1 -0
  391. package/src/parser/literals.ts +28 -0
  392. package/src/parser/statements.ts +3 -0
  393. package/src/parser/types.ts +106 -43
@@ -0,0 +1,150 @@
1
+ #pragma once
2
+ #include "miniz_common.h"
3
+ /* ------------------- Low-level Decompression API Definitions */
4
+
5
+ #ifndef MINIZ_NO_INFLATE_APIS
6
+
7
+ #ifdef __cplusplus
8
+ extern "C"
9
+ {
10
+ #endif /* __cplusplus */
11
+ /* Decompression flags used by tinfl_decompress(). */
12
+ /* TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. */
13
+ /* TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. */
14
+ /* TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). */
15
+ /* TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. */
16
+ enum
17
+ {
18
+ TINFL_FLAG_PARSE_ZLIB_HEADER = 1,
19
+ TINFL_FLAG_HAS_MORE_INPUT = 2,
20
+ TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4,
21
+ TINFL_FLAG_COMPUTE_ADLER32 = 8
22
+ };
23
+
24
+ /* High level decompression functions: */
25
+ /* tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). */
26
+ /* On entry: */
27
+ /* pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. */
28
+ /* On return: */
29
+ /* Function returns a pointer to the decompressed data, or NULL on failure. */
30
+ /* *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. */
31
+ /* The caller must call mz_free() on the returned block when it's no longer needed. */
32
+ MINIZ_EXPORT void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
33
+
34
+ /* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */
35
+ /* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */
36
+ #define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
37
+ MINIZ_EXPORT size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
38
+
39
+ /* tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. */
40
+ /* Returns 1 on success or 0 on failure. */
41
+ typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
42
+ MINIZ_EXPORT int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
43
+
44
+ struct tinfl_decompressor_tag;
45
+ typedef struct tinfl_decompressor_tag tinfl_decompressor;
46
+
47
+ #ifndef MINIZ_NO_MALLOC
48
+ /* Allocate the tinfl_decompressor structure in C so that */
49
+ /* non-C language bindings to tinfl_ API don't need to worry about */
50
+ /* structure size and allocation mechanism. */
51
+ MINIZ_EXPORT tinfl_decompressor *tinfl_decompressor_alloc(void);
52
+ MINIZ_EXPORT void tinfl_decompressor_free(tinfl_decompressor *pDecomp);
53
+ #endif /* MINIZ_NO_MALLOC */
54
+
55
+ /* Max size of LZ dictionary. */
56
+ #define TINFL_LZ_DICT_SIZE 32768
57
+
58
+ /* Return status. */
59
+ typedef enum
60
+ {
61
+ /* This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data */
62
+ /* is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). */
63
+ /* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */
64
+ TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4,
65
+
66
+ /* This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.) */
67
+ TINFL_STATUS_BAD_PARAM = -3,
68
+
69
+ /* This flags indicate the inflator is finished but the adler32 check of the uncompressed data didn't match. If you call it again it'll return TINFL_STATUS_DONE. */
70
+ TINFL_STATUS_ADLER32_MISMATCH = -2,
71
+
72
+ /* This flags indicate the inflator has somehow failed (bad code, corrupted input, etc.). If you call it again without resetting via tinfl_init() it it'll just keep on returning the same status failure code. */
73
+ TINFL_STATUS_FAILED = -1,
74
+
75
+ /* Any status code less than TINFL_STATUS_DONE must indicate a failure. */
76
+
77
+ /* This flag indicates the inflator has returned every byte of uncompressed data that it can, has consumed every byte that it needed, has successfully reached the end of the deflate stream, and */
78
+ /* if zlib headers and adler32 checking enabled that it has successfully checked the uncompressed data's adler32. If you call it again you'll just get TINFL_STATUS_DONE over and over again. */
79
+ TINFL_STATUS_DONE = 0,
80
+
81
+ /* This flag indicates the inflator MUST have more input data (even 1 byte) before it can make any more forward progress, or you need to clear the TINFL_FLAG_HAS_MORE_INPUT */
82
+ /* flag on the next call if you don't have any more source data. If the source data was somehow corrupted it's also possible (but unlikely) for the inflator to keep on demanding input to */
83
+ /* proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. */
84
+ TINFL_STATUS_NEEDS_MORE_INPUT = 1,
85
+
86
+ /* This flag indicates the inflator definitely has 1 or more bytes of uncompressed data available, but it cannot write this data into the output buffer. */
87
+ /* Note if the source compressed data was corrupted it's possible for the inflator to return a lot of uncompressed data to the caller. I've been assuming you know how much uncompressed data to expect */
88
+ /* (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible */
89
+ /* so I may need to add some code to address this. */
90
+ TINFL_STATUS_HAS_MORE_OUTPUT = 2
91
+ } tinfl_status;
92
+
93
+ /* Initializes the decompressor to its initial state. */
94
+ #define tinfl_init(r) \
95
+ do \
96
+ { \
97
+ (r)->m_state = 0; \
98
+ } \
99
+ MZ_MACRO_END
100
+ #define tinfl_get_adler32(r) (r)->m_check_adler32
101
+
102
+ /* Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. */
103
+ /* This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. */
104
+ MINIZ_EXPORT tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
105
+
106
+ /* Internal/private bits follow. */
107
+ enum
108
+ {
109
+ TINFL_MAX_HUFF_TABLES = 3,
110
+ TINFL_MAX_HUFF_SYMBOLS_0 = 288,
111
+ TINFL_MAX_HUFF_SYMBOLS_1 = 32,
112
+ TINFL_MAX_HUFF_SYMBOLS_2 = 19,
113
+ TINFL_FAST_LOOKUP_BITS = 10,
114
+ TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS
115
+ };
116
+
117
+ #if MINIZ_HAS_64BIT_REGISTERS
118
+ #define TINFL_USE_64BIT_BITBUF 1
119
+ #else
120
+ #define TINFL_USE_64BIT_BITBUF 0
121
+ #endif /* MINIZ_HAS_64BIT_REGISTERS */
122
+
123
+ #if TINFL_USE_64BIT_BITBUF
124
+ typedef mz_uint64 tinfl_bit_buf_t;
125
+ #define TINFL_BITBUF_SIZE (64)
126
+ #else
127
+ typedef mz_uint32 tinfl_bit_buf_t;
128
+ #define TINFL_BITBUF_SIZE (32)
129
+ #endif /* TINFL_USE_64BIT_BITBUF */
130
+
131
+ struct tinfl_decompressor_tag
132
+ {
133
+ mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES];
134
+ tinfl_bit_buf_t m_bit_buf;
135
+ size_t m_dist_from_out_buf_start;
136
+ mz_int16 m_look_up[TINFL_MAX_HUFF_TABLES][TINFL_FAST_LOOKUP_SIZE];
137
+ mz_int16 m_tree_0[TINFL_MAX_HUFF_SYMBOLS_0 * 2];
138
+ mz_int16 m_tree_1[TINFL_MAX_HUFF_SYMBOLS_1 * 2];
139
+ mz_int16 m_tree_2[TINFL_MAX_HUFF_SYMBOLS_2 * 2];
140
+ mz_uint8 m_code_size_0[TINFL_MAX_HUFF_SYMBOLS_0];
141
+ mz_uint8 m_code_size_1[TINFL_MAX_HUFF_SYMBOLS_1];
142
+ mz_uint8 m_code_size_2[TINFL_MAX_HUFF_SYMBOLS_2];
143
+ mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137];
144
+ };
145
+
146
+ #ifdef __cplusplus
147
+ }
148
+ #endif /* __cplusplus */
149
+
150
+ #endif /* MINIZ_NO_INFLATE_APIS */
@@ -0,0 +1,454 @@
1
+
2
+ #pragma once
3
+ #include "miniz_common.h"
4
+
5
+ /* ------------------- ZIP archive reading/writing */
6
+
7
+ #ifndef MINIZ_NO_ARCHIVE_APIS
8
+
9
+ #ifdef __cplusplus
10
+ extern "C"
11
+ {
12
+ #endif /* __cplusplus */
13
+
14
+ enum
15
+ {
16
+ /* Note: These enums can be reduced as needed to save memory or stack space - they are pretty conservative. */
17
+ MZ_ZIP_MAX_IO_BUF_SIZE = 64 * 1024,
18
+ MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 512,
19
+ MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 512
20
+ };
21
+
22
+ typedef struct
23
+ {
24
+ /* Central directory file index. */
25
+ mz_uint32 m_file_index;
26
+
27
+ /* Byte offset of this entry in the archive's central directory. Note we currently only support up to UINT_MAX or less bytes in the central dir. */
28
+ mz_uint64 m_central_dir_ofs;
29
+
30
+ /* These fields are copied directly from the zip's central dir. */
31
+ mz_uint16 m_version_made_by;
32
+ mz_uint16 m_version_needed;
33
+ mz_uint16 m_bit_flag;
34
+ mz_uint16 m_method;
35
+
36
+ /* CRC-32 of uncompressed data. */
37
+ mz_uint32 m_crc32;
38
+
39
+ /* File's compressed size. */
40
+ mz_uint64 m_comp_size;
41
+
42
+ /* File's uncompressed size. Note, I've seen some old archives where directory entries had 512 bytes for their uncompressed sizes, but when you try to unpack them you actually get 0 bytes. */
43
+ mz_uint64 m_uncomp_size;
44
+
45
+ /* Zip internal and external file attributes. */
46
+ mz_uint16 m_internal_attr;
47
+ mz_uint32 m_external_attr;
48
+
49
+ /* Entry's local header file offset in bytes. */
50
+ mz_uint64 m_local_header_ofs;
51
+
52
+ /* Size of comment in bytes. */
53
+ mz_uint32 m_comment_size;
54
+
55
+ /* MZ_TRUE if the entry appears to be a directory. */
56
+ mz_bool m_is_directory;
57
+
58
+ /* MZ_TRUE if the entry uses encryption/strong encryption (which miniz_zip doesn't support) */
59
+ mz_bool m_is_encrypted;
60
+
61
+ /* MZ_TRUE if the file is not encrypted, a patch file, and if it uses a compression method we support. */
62
+ mz_bool m_is_supported;
63
+
64
+ /* Filename. If string ends in '/' it's a subdirectory entry. */
65
+ /* Guaranteed to be zero terminated, may be truncated to fit. */
66
+ char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE];
67
+
68
+ /* Comment field. */
69
+ /* Guaranteed to be zero terminated, may be truncated to fit. */
70
+ char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE];
71
+
72
+ #ifdef MINIZ_NO_TIME
73
+ MZ_TIME_T m_padding;
74
+ #else
75
+ MZ_TIME_T m_time;
76
+ #endif /* MINIZ_NO_TIME */
77
+ } mz_zip_archive_file_stat;
78
+
79
+ typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n);
80
+ typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n);
81
+ typedef mz_bool (*mz_file_needs_keepalive)(void *pOpaque);
82
+
83
+ struct mz_zip_internal_state_tag;
84
+ typedef struct mz_zip_internal_state_tag mz_zip_internal_state;
85
+
86
+ typedef enum
87
+ {
88
+ MZ_ZIP_MODE_INVALID = 0,
89
+ MZ_ZIP_MODE_READING = 1,
90
+ MZ_ZIP_MODE_WRITING = 2,
91
+ MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3
92
+ } mz_zip_mode;
93
+
94
+ typedef enum
95
+ {
96
+ MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100,
97
+ MZ_ZIP_FLAG_IGNORE_PATH = 0x0200,
98
+ MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400,
99
+ MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800,
100
+ MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG = 0x1000, /* if enabled, mz_zip_reader_locate_file() will be called on each file as its validated to ensure the func finds the file in the central dir (intended for testing) */
101
+ MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY = 0x2000, /* validate the local headers, but don't decompress the entire file and check the crc32 */
102
+ MZ_ZIP_FLAG_WRITE_ZIP64 = 0x4000, /* always use the zip64 file format, instead of the original zip file format with automatic switch to zip64. Use as flags parameter with mz_zip_writer_init*_v2 */
103
+ MZ_ZIP_FLAG_WRITE_ALLOW_READING = 0x8000,
104
+ MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000,
105
+ /*After adding a compressed file, seek back
106
+ to local file header and set the correct sizes*/
107
+ MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE = 0x20000,
108
+ MZ_ZIP_FLAG_READ_ALLOW_WRITING = 0x40000
109
+ } mz_zip_flags;
110
+
111
+ typedef enum
112
+ {
113
+ MZ_ZIP_TYPE_INVALID = 0,
114
+ MZ_ZIP_TYPE_USER,
115
+ MZ_ZIP_TYPE_MEMORY,
116
+ MZ_ZIP_TYPE_HEAP,
117
+ MZ_ZIP_TYPE_FILE,
118
+ MZ_ZIP_TYPE_CFILE,
119
+ MZ_ZIP_TOTAL_TYPES
120
+ } mz_zip_type;
121
+
122
+ /* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */
123
+ typedef enum
124
+ {
125
+ MZ_ZIP_NO_ERROR = 0,
126
+ MZ_ZIP_UNDEFINED_ERROR,
127
+ MZ_ZIP_TOO_MANY_FILES,
128
+ MZ_ZIP_FILE_TOO_LARGE,
129
+ MZ_ZIP_UNSUPPORTED_METHOD,
130
+ MZ_ZIP_UNSUPPORTED_ENCRYPTION,
131
+ MZ_ZIP_UNSUPPORTED_FEATURE,
132
+ MZ_ZIP_FAILED_FINDING_CENTRAL_DIR,
133
+ MZ_ZIP_NOT_AN_ARCHIVE,
134
+ MZ_ZIP_INVALID_HEADER_OR_CORRUPTED,
135
+ MZ_ZIP_UNSUPPORTED_MULTIDISK,
136
+ MZ_ZIP_DECOMPRESSION_FAILED,
137
+ MZ_ZIP_COMPRESSION_FAILED,
138
+ MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE,
139
+ MZ_ZIP_CRC_CHECK_FAILED,
140
+ MZ_ZIP_UNSUPPORTED_CDIR_SIZE,
141
+ MZ_ZIP_ALLOC_FAILED,
142
+ MZ_ZIP_FILE_OPEN_FAILED,
143
+ MZ_ZIP_FILE_CREATE_FAILED,
144
+ MZ_ZIP_FILE_WRITE_FAILED,
145
+ MZ_ZIP_FILE_READ_FAILED,
146
+ MZ_ZIP_FILE_CLOSE_FAILED,
147
+ MZ_ZIP_FILE_SEEK_FAILED,
148
+ MZ_ZIP_FILE_STAT_FAILED,
149
+ MZ_ZIP_INVALID_PARAMETER,
150
+ MZ_ZIP_INVALID_FILENAME,
151
+ MZ_ZIP_BUF_TOO_SMALL,
152
+ MZ_ZIP_INTERNAL_ERROR,
153
+ MZ_ZIP_FILE_NOT_FOUND,
154
+ MZ_ZIP_ARCHIVE_TOO_LARGE,
155
+ MZ_ZIP_VALIDATION_FAILED,
156
+ MZ_ZIP_WRITE_CALLBACK_FAILED,
157
+ MZ_ZIP_TOTAL_ERRORS
158
+ } mz_zip_error;
159
+
160
+ typedef struct
161
+ {
162
+ mz_uint64 m_archive_size;
163
+ mz_uint64 m_central_directory_file_ofs;
164
+
165
+ /* We only support up to UINT32_MAX files in zip64 mode. */
166
+ mz_uint32 m_total_files;
167
+ mz_zip_mode m_zip_mode;
168
+ mz_zip_type m_zip_type;
169
+ mz_zip_error m_last_error;
170
+
171
+ mz_uint64 m_file_offset_alignment;
172
+
173
+ mz_alloc_func m_pAlloc;
174
+ mz_free_func m_pFree;
175
+ mz_realloc_func m_pRealloc;
176
+ void *m_pAlloc_opaque;
177
+
178
+ mz_file_read_func m_pRead;
179
+ mz_file_write_func m_pWrite;
180
+ mz_file_needs_keepalive m_pNeeds_keepalive;
181
+ void *m_pIO_opaque;
182
+
183
+ mz_zip_internal_state *m_pState;
184
+
185
+ } mz_zip_archive;
186
+
187
+ typedef struct
188
+ {
189
+ mz_zip_archive *pZip;
190
+ mz_uint flags;
191
+
192
+ int status;
193
+
194
+ mz_uint64 read_buf_size, read_buf_ofs, read_buf_avail, comp_remaining, out_buf_ofs, cur_file_ofs;
195
+ mz_zip_archive_file_stat file_stat;
196
+ void *pRead_buf;
197
+ void *pWrite_buf;
198
+
199
+ size_t out_blk_remain;
200
+
201
+ tinfl_decompressor inflator;
202
+
203
+ #ifdef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
204
+ mz_uint padding;
205
+ #else
206
+ mz_uint file_crc32;
207
+ #endif /* MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS */
208
+
209
+ } mz_zip_reader_extract_iter_state;
210
+
211
+ /* -------- ZIP reading */
212
+
213
+ /* Inits a ZIP archive reader. */
214
+ /* These functions read and validate the archive's central directory. */
215
+ MINIZ_EXPORT mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags);
216
+
217
+ MINIZ_EXPORT mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags);
218
+
219
+ #ifndef MINIZ_NO_STDIO
220
+ /* Read a archive from a disk file. */
221
+ /* file_start_ofs is the file offset where the archive actually begins, or 0. */
222
+ /* actual_archive_size is the true total size of the archive, which may be smaller than the file's actual size on disk. If zero the entire file is treated as the archive. */
223
+ MINIZ_EXPORT mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
224
+ MINIZ_EXPORT mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size);
225
+
226
+ /* Read an archive from an already opened FILE, beginning at the current file position. */
227
+ /* The archive is assumed to be archive_size bytes long. If archive_size is 0, then the entire rest of the file is assumed to contain the archive. */
228
+ /* The FILE will NOT be closed when mz_zip_reader_end() is called. */
229
+ MINIZ_EXPORT mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags);
230
+ #endif /* MINIZ_NO_STDIO */
231
+
232
+ /* Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. */
233
+ MINIZ_EXPORT mz_bool mz_zip_reader_end(mz_zip_archive *pZip);
234
+
235
+ /* -------- ZIP reading or writing */
236
+
237
+ /* Clears a mz_zip_archive struct to all zeros. */
238
+ /* Important: This must be done before passing the struct to any mz_zip functions. */
239
+ MINIZ_EXPORT void mz_zip_zero_struct(mz_zip_archive *pZip);
240
+
241
+ MINIZ_EXPORT mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip);
242
+ MINIZ_EXPORT mz_zip_type mz_zip_get_type(mz_zip_archive *pZip);
243
+
244
+ /* Returns the total number of files in the archive. */
245
+ MINIZ_EXPORT mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
246
+
247
+ MINIZ_EXPORT mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip);
248
+ MINIZ_EXPORT mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip);
249
+ MINIZ_EXPORT MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip);
250
+
251
+ /* Reads n bytes of raw archive data, starting at file offset file_ofs, to pBuf. */
252
+ MINIZ_EXPORT size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n);
253
+
254
+ /* All mz_zip funcs set the m_last_error field in the mz_zip_archive struct. These functions retrieve/manipulate this field. */
255
+ /* Note that the m_last_error functionality is not thread safe. */
256
+ MINIZ_EXPORT mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num);
257
+ MINIZ_EXPORT mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip);
258
+ MINIZ_EXPORT mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip);
259
+ MINIZ_EXPORT mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip);
260
+ MINIZ_EXPORT const char *mz_zip_get_error_string(mz_zip_error mz_err);
261
+
262
+ /* MZ_TRUE if the archive file entry is a directory entry. */
263
+ MINIZ_EXPORT mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
264
+
265
+ /* MZ_TRUE if the file is encrypted/strong encrypted. */
266
+ MINIZ_EXPORT mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
267
+
268
+ /* MZ_TRUE if the compression method is supported, and the file is not encrypted, and the file is not a compressed patch file. */
269
+ MINIZ_EXPORT mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index);
270
+
271
+ /* Retrieves the filename of an archive file entry. */
272
+ /* Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. */
273
+ MINIZ_EXPORT mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
274
+
275
+ /* Attempts to locates a file in the archive's central directory. */
276
+ /* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
277
+ /* Returns -1 if the file cannot be found. */
278
+ MINIZ_EXPORT int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
279
+ MINIZ_EXPORT mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index);
280
+
281
+ /* Returns detailed information about an archive file entry. */
282
+ MINIZ_EXPORT mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
283
+
284
+ /* MZ_TRUE if the file is in zip64 format. */
285
+ /* A file is considered zip64 if it contained a zip64 end of central directory marker, or if it contained any zip64 extended file information fields in the central directory. */
286
+ MINIZ_EXPORT mz_bool mz_zip_is_zip64(mz_zip_archive *pZip);
287
+
288
+ /* Returns the total central directory size in bytes. */
289
+ /* The current max supported size is <= MZ_UINT32_MAX. */
290
+ MINIZ_EXPORT size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip);
291
+
292
+ /* Extracts a archive file to a memory buffer using no memory allocation. */
293
+ /* There must be at least enough room on the stack to store the inflator's state (~34KB or so). */
294
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
295
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
296
+
297
+ /* Extracts a archive file to a memory buffer. */
298
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags);
299
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags);
300
+
301
+ /* Extracts a archive file to a dynamically allocated heap buffer. */
302
+ /* The memory will be allocated via the mz_zip_archive's alloc/realloc functions. */
303
+ /* Returns NULL and sets the last error on failure. */
304
+ MINIZ_EXPORT void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags);
305
+ MINIZ_EXPORT void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
306
+
307
+ /* Extracts a archive file using a callback function to output the file's data. */
308
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
309
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
310
+
311
+ /* Extract a file iteratively */
312
+ MINIZ_EXPORT mz_zip_reader_extract_iter_state *mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
313
+ MINIZ_EXPORT mz_zip_reader_extract_iter_state *mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
314
+ MINIZ_EXPORT size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state *pState, void *pvBuf, size_t buf_size);
315
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state *pState);
316
+
317
+ #ifndef MINIZ_NO_STDIO
318
+ /* Extracts a archive file to a disk file and sets its last accessed and modified times. */
319
+ /* This function only extracts files, not archive directory records. */
320
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags);
321
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags);
322
+
323
+ /* Extracts a archive file starting at the current position in the destination FILE stream. */
324
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *File, mz_uint flags);
325
+ MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags);
326
+ #endif /* MINIZ_NO_STDIO */
327
+
328
+ #if 0
329
+ /* TODO */
330
+ typedef void *mz_zip_streaming_extract_state_ptr;
331
+ mz_zip_streaming_extract_state_ptr mz_zip_streaming_extract_begin(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
332
+ mz_uint64 mz_zip_streaming_extract_get_size(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
333
+ mz_uint64 mz_zip_streaming_extract_get_cur_ofs(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
334
+ mz_bool mz_zip_streaming_extract_seek(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState, mz_uint64 new_ofs);
335
+ size_t mz_zip_streaming_extract_read(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState, void *pBuf, size_t buf_size);
336
+ mz_bool mz_zip_streaming_extract_end(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
337
+ #endif /* 0 */
338
+
339
+ /* This function compares the archive's local headers, the optional local zip64 extended information block, and the optional descriptor following the compressed data vs. the data in the central directory. */
340
+ /* It also validates that each file can be successfully uncompressed unless the MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY is specified. */
341
+ MINIZ_EXPORT mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
342
+
343
+ /* Validates an entire archive by calling mz_zip_validate_file() on each file. */
344
+ MINIZ_EXPORT mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags);
345
+
346
+ /* Misc utils/helpers, valid for ZIP reading or writing */
347
+ MINIZ_EXPORT mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr);
348
+ #ifndef MINIZ_NO_STDIO
349
+ MINIZ_EXPORT mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr);
350
+ #endif /* MINIZ_NO_STDIO */
351
+
352
+ /* Universal end function - calls either mz_zip_reader_end() or mz_zip_writer_end(). */
353
+ MINIZ_EXPORT mz_bool mz_zip_end(mz_zip_archive *pZip);
354
+
355
+ /* -------- ZIP writing */
356
+
357
+ #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
358
+
359
+ /* Inits a ZIP archive writer. */
360
+ /*Set pZip->m_pWrite (and pZip->m_pIO_opaque) before calling mz_zip_writer_init or mz_zip_writer_init_v2*/
361
+ /*The output is streamable, i.e. file_ofs in mz_file_write_func always increases only by n*/
362
+ MINIZ_EXPORT mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size);
363
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags);
364
+
365
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size);
366
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags);
367
+
368
+ #ifndef MINIZ_NO_STDIO
369
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning);
370
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags);
371
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags);
372
+ #endif /* MINIZ_NO_STDIO */
373
+
374
+ /* Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. */
375
+ /* For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. */
376
+ /* For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). */
377
+ /* Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. */
378
+ /* Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before */
379
+ /* the archive is finalized the file's central directory will be hosed. */
380
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename);
381
+ MINIZ_EXPORT mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
382
+
383
+ /* Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. */
384
+ /* To add a directory entry, call this method with an archive name ending in a forwardslash with an empty buffer. */
385
+ /* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
386
+ MINIZ_EXPORT mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags);
387
+
388
+ /* Like mz_zip_writer_add_mem(), except you can specify a file comment field, and optionally supply the function with already compressed data. */
389
+ /* uncomp_size/uncomp_crc32 are only used if the MZ_ZIP_FLAG_COMPRESSED_DATA flag is specified. */
390
+ MINIZ_EXPORT mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
391
+ mz_uint64 uncomp_size, mz_uint32 uncomp_crc32);
392
+
393
+ MINIZ_EXPORT mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
394
+ mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
395
+ const char *user_extra_data_central, mz_uint user_extra_data_central_len);
396
+
397
+ /* Adds the contents of a file to an archive. This function also records the disk file's modified time into the archive. */
398
+ /* File data is supplied via a read callback function. User mz_zip_writer_add_(c)file to add a file directly.*/
399
+ MINIZ_EXPORT mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void *callback_opaque, mz_uint64 max_size,
400
+ const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
401
+ const char *user_extra_data_central, mz_uint user_extra_data_central_len);
402
+
403
+ #ifndef MINIZ_NO_STDIO
404
+ /* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */
405
+ /* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
406
+ MINIZ_EXPORT mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
407
+
408
+ /* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */
409
+ MINIZ_EXPORT mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 max_size,
410
+ const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
411
+ const char *user_extra_data_central, mz_uint user_extra_data_central_len);
412
+ #endif /* MINIZ_NO_STDIO */
413
+
414
+ /* Adds a file to an archive by fully cloning the data from another archive. */
415
+ /* This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data (it may add or modify the zip64 local header extra data field), and the optional descriptor following the compressed data. */
416
+ MINIZ_EXPORT mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index);
417
+
418
+ /* Finalizes the archive by writing the central directory records followed by the end of central directory record. */
419
+ /* After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). */
420
+ /* An archive must be manually finalized by calling this function for it to be valid. */
421
+ MINIZ_EXPORT mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip);
422
+
423
+ /* Finalizes a heap archive, returning a pointer to the heap block and its size. */
424
+ /* The heap block will be allocated using the mz_zip_archive's alloc/realloc callbacks. */
425
+ MINIZ_EXPORT mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize);
426
+
427
+ /* Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. */
428
+ /* Note for the archive to be valid, it *must* have been finalized before ending (this function will not do it for you). */
429
+ MINIZ_EXPORT mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
430
+
431
+ /* -------- Misc. high-level helper functions: */
432
+
433
+ /* mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. */
434
+ /* Note this is NOT a fully safe operation. If it crashes or dies in some way your archive can be left in a screwed up state (without a central directory). */
435
+ /* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
436
+ /* TODO: Perhaps add an option to leave the existing central dir in place in case the add dies? We could then truncate the file (so the old central dir would be at the end) if something goes wrong. */
437
+ MINIZ_EXPORT mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
438
+ MINIZ_EXPORT mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr);
439
+
440
+ #ifndef MINIZ_NO_STDIO
441
+ /* Reads a single file from an archive into a heap block. */
442
+ /* If pComment is not NULL, only the file with the specified comment will be extracted. */
443
+ /* Returns NULL on failure. */
444
+ MINIZ_EXPORT void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags);
445
+ MINIZ_EXPORT void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr);
446
+ #endif /* MINIZ_NO_STDIO */
447
+
448
+ #endif /* MINIZ_NO_ARCHIVE_WRITING_APIS */
449
+
450
+ #ifdef __cplusplus
451
+ }
452
+ #endif /* __cplusplus */
453
+
454
+ #endif /* MINIZ_NO_ARCHIVE_APIS */