nuxt-ai-ready 2.5.3 → 3.0.0

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 (286) hide show
  1. package/README.md +13 -12
  2. package/dist/chunks/agent-skills.mjs +35 -12
  3. package/dist/chunks/prerender.mjs +35 -24
  4. package/dist/cli.mjs +5 -2
  5. package/dist/module.d.mts +4 -0
  6. package/dist/module.json +2 -2
  7. package/dist/module.mjs +8 -4
  8. package/dist/runtime/app/index.d.ts +3 -0
  9. package/dist/runtime/app/index.js +2 -0
  10. package/dist/runtime/cache-control.d.ts +2 -0
  11. package/dist/runtime/cache-control.js +11 -0
  12. package/dist/runtime/llms-txt-utils.js +1 -1
  13. package/dist/runtime/server/db/context.d.ts +13 -0
  14. package/dist/runtime/server/db/drizzle/client.d.ts +6 -7
  15. package/dist/runtime/server/db/drizzle/client.js +13 -2
  16. package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -2
  17. package/dist/runtime/server/db/drizzle/providers/bun.js +2 -2
  18. package/dist/runtime/server/db/drizzle/providers/d1.d.ts +2 -2
  19. package/dist/runtime/server/db/drizzle/providers/d1.js +3 -2
  20. package/dist/runtime/server/db/drizzle/providers/libsql.d.ts +2 -2
  21. package/dist/runtime/server/db/drizzle/providers/libsql.js +2 -2
  22. package/dist/runtime/server/db/drizzle/providers/neon.d.ts +2 -2
  23. package/dist/runtime/server/db/drizzle/providers/neon.js +2 -2
  24. package/dist/runtime/server/db/drizzle/providers/node-sqlite.d.ts +2 -2
  25. package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +2 -2
  26. package/dist/runtime/server/db/drizzle/providers/postgres.d.ts +2 -2
  27. package/dist/runtime/server/db/drizzle/providers/postgres.js +2 -2
  28. package/dist/runtime/server/db/drizzle/queries.d.ts +27 -27
  29. package/dist/runtime/server/db/drizzle/queries.js +6 -5
  30. package/dist/runtime/server/db/drizzle/raw.d.ts +2 -6
  31. package/dist/runtime/server/db/index.d.ts +1 -1
  32. package/dist/runtime/server/db/index.js +1 -1
  33. package/dist/runtime/server/db/queries.d.ts +36 -36
  34. package/dist/runtime/server/db/queries.js +8 -9
  35. package/dist/runtime/server/db/seed.d.ts +2 -2
  36. package/dist/runtime/server/db/seed.js +4 -3
  37. package/dist/runtime/server/db/shared.d.ts +8 -0
  38. package/dist/runtime/server/db/shared.js +8 -2
  39. package/dist/runtime/server/index.d.ts +2 -0
  40. package/dist/runtime/server/index.js +17 -0
  41. package/dist/runtime/server/mcp/tools/get-page-markdown.js +1 -1
  42. package/dist/runtime/server/mcp/tools/list-pages.js +1 -1
  43. package/dist/runtime/server/mcp/tools/search-pages.js +1 -1
  44. package/dist/runtime/server/middleware/markdown.prerender.js +1 -1
  45. package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +2 -0
  46. package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +16 -0
  47. package/dist/runtime/server/plugins/html-capture.prerender.js +6 -4
  48. package/dist/runtime/server/plugins/link-header-nitro3.d.ts +2 -0
  49. package/dist/runtime/server/plugins/link-header-nitro3.js +20 -0
  50. package/dist/runtime/server/plugins/link-header.d.ts +6 -0
  51. package/dist/runtime/server/plugins/link-header.js +7 -11
  52. package/dist/runtime/server/plugins/markdown-negotiation.js +8 -1
  53. package/dist/runtime/server/plugins/sitemap-seeder.js +3 -3
  54. package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
  55. package/dist/runtime/server/routes/agent-skills-artifact.js +10 -10
  56. package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
  57. package/dist/runtime/server/routes/agent-skills-index.js +7 -6
  58. package/dist/runtime/server/routes/ai-catalog.d.ts +2 -1
  59. package/dist/runtime/server/routes/ai-catalog.js +7 -8
  60. package/dist/runtime/server/routes/api-catalog.d.ts +3 -1
  61. package/dist/runtime/server/routes/api-catalog.js +12 -12
  62. package/dist/runtime/server/routes/llms-full.txt.get.js +1 -1
  63. package/dist/runtime/server/routes/mcp-server-card.d.ts +1 -1
  64. package/dist/runtime/server/routes/mcp-server-card.js +7 -8
  65. package/dist/runtime/server/utils/checkStale.d.ts +2 -2
  66. package/dist/runtime/server/utils/cloudflare-prerendered.d.ts +3 -0
  67. package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -0
  68. package/dist/runtime/server/utils/cloudflare.d.ts +5 -5
  69. package/dist/runtime/server/utils/cloudflare.js +31 -7
  70. package/dist/runtime/server/utils/content-negotiation.d.ts +5 -3
  71. package/dist/runtime/server/utils/content-negotiation.js +8 -7
  72. package/dist/runtime/server/utils/context.d.ts +3 -3
  73. package/dist/runtime/server/utils/context.js +1 -1
  74. package/dist/runtime/server/utils/discovery-response.d.ts +2 -0
  75. package/dist/runtime/server/utils/link-header.d.ts +5 -3
  76. package/dist/runtime/server/utils/link-header.js +26 -2
  77. package/dist/runtime/server/utils/markdown-request.d.ts +4 -3
  78. package/dist/runtime/server/utils/markdown-request.js +15 -13
  79. package/dist/runtime/server/utils/negotiation-decision.d.ts +4 -0
  80. package/dist/runtime/server/utils/negotiation-decision.js +6 -5
  81. package/dist/runtime/server/utils/negotiation-response.js +47 -22
  82. package/dist/runtime/server/utils/prerender-html.d.ts +2 -1
  83. package/dist/runtime/server/utils/prerender-html.js +3 -1
  84. package/dist/runtime/types.d.ts +15 -7
  85. package/dist/shared/nuxt-ai-ready.B3hAuOLQ.mjs +29 -0
  86. package/dist/shared/{nuxt-ai-ready.CLSWou20.mjs → nuxt-ai-ready.C34F0LJo.mjs} +560 -219
  87. package/package.json +85 -20
  88. package/skills/nuxt-ai-ready/SKILL.md +26 -12
  89. package/skills/nuxt-ai-ready/references/runtime-indexing.md +7 -6
  90. package/dist/runtime/server/db/drizzle/providers/sqlite.d.ts +0 -8
  91. package/dist/runtime/server/db/drizzle/providers/sqlite.js +0 -15
  92. package/node_modules/@mdream/js/LICENSE.md +0 -9
  93. package/node_modules/@mdream/js/README.md +0 -792
  94. package/node_modules/@mdream/js/bin/mdream.mjs +0 -2
  95. package/node_modules/@mdream/js/dist/_chunks/const.mjs +0 -134
  96. package/node_modules/@mdream/js/dist/_chunks/index.d.mts +0 -9
  97. package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +0 -1968
  98. package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +0 -6
  99. package/node_modules/@mdream/js/dist/_chunks/parse.mjs +0 -2756
  100. package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +0 -725
  101. package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +0 -44
  102. package/node_modules/@mdream/js/dist/_chunks/stream.mjs +0 -37
  103. package/node_modules/@mdream/js/dist/_chunks/types.d.mts +0 -473
  104. package/node_modules/@mdream/js/dist/cli.d.mts +0 -1
  105. package/node_modules/@mdream/js/dist/cli.mjs +0 -32
  106. package/node_modules/@mdream/js/dist/core.d.mts +0 -15
  107. package/node_modules/@mdream/js/dist/core.mjs +0 -28
  108. package/node_modules/@mdream/js/dist/index.d.mts +0 -4
  109. package/node_modules/@mdream/js/dist/index.mjs +0 -58
  110. package/node_modules/@mdream/js/dist/llms-txt.d.mts +0 -86
  111. package/node_modules/@mdream/js/dist/llms-txt.mjs +0 -308
  112. package/node_modules/@mdream/js/dist/negotiate.d.mts +0 -35
  113. package/node_modules/@mdream/js/dist/negotiate.mjs +0 -121
  114. package/node_modules/@mdream/js/dist/parse.d.mts +0 -90
  115. package/node_modules/@mdream/js/dist/parse.mjs +0 -2
  116. package/node_modules/@mdream/js/dist/plugins.d.mts +0 -85
  117. package/node_modules/@mdream/js/dist/plugins.mjs +0 -2
  118. package/node_modules/@mdream/js/dist/preset/minimal.d.mts +0 -2
  119. package/node_modules/@mdream/js/dist/preset/minimal.mjs +0 -33
  120. package/node_modules/@mdream/js/dist/splitter.d.mts +0 -18
  121. package/node_modules/@mdream/js/dist/splitter.mjs +0 -194
  122. package/node_modules/@mdream/js/package.json +0 -103
  123. package/node_modules/cac/LICENSE +0 -21
  124. package/node_modules/cac/README.md +0 -492
  125. package/node_modules/cac/dist/index.d.ts +0 -196
  126. package/node_modules/cac/dist/index.js +0 -638
  127. package/node_modules/cac/package.json +0 -72
  128. package/node_modules/mdream/LICENSE.md +0 -9
  129. package/node_modules/mdream/README.md +0 -1091
  130. package/node_modules/mdream/bin/mdream.mjs +0 -46
  131. package/node_modules/mdream/dist/browser.d.mts +0 -105
  132. package/node_modules/mdream/dist/browser.mjs +0 -262
  133. package/node_modules/mdream/dist/edge.d.mts +0 -100
  134. package/node_modules/mdream/dist/edge.mjs +0 -250
  135. package/node_modules/mdream/dist/iife.js +0 -605
  136. package/node_modules/mdream/dist/index.d.mts +0 -89
  137. package/node_modules/mdream/dist/index.mjs +0 -184
  138. package/node_modules/mdream/dist/wasm.d.mts +0 -100
  139. package/node_modules/mdream/dist/wasm.mjs +0 -140
  140. package/node_modules/mdream/dist/worker.d.mts +0 -101
  141. package/node_modules/mdream/dist/worker.mjs +0 -217
  142. package/node_modules/mdream/napi/index.d.mts +0 -127
  143. package/node_modules/mdream/napi/index.d.ts +0 -127
  144. package/node_modules/mdream/napi/index.mjs +0 -725
  145. package/node_modules/mdream/napi/rust.android-arm-eabi.node +0 -0
  146. package/node_modules/mdream/napi/rust.android-arm64.node +0 -0
  147. package/node_modules/mdream/napi/rust.darwin-arm64.node +0 -0
  148. package/node_modules/mdream/napi/rust.darwin-x64.node +0 -0
  149. package/node_modules/mdream/napi/rust.freebsd-x64.node +0 -0
  150. package/node_modules/mdream/napi/rust.linux-arm-gnueabihf.node +0 -0
  151. package/node_modules/mdream/napi/rust.linux-arm64-gnu.node +0 -0
  152. package/node_modules/mdream/napi/rust.linux-arm64-musl.node +0 -0
  153. package/node_modules/mdream/napi/rust.linux-x64-gnu.node +0 -0
  154. package/node_modules/mdream/napi/rust.linux-x64-musl.node +0 -0
  155. package/node_modules/mdream/napi/rust.wasi.cjs +0 -2144
  156. package/node_modules/mdream/napi/rust.wasm32-wasi.wasm +0 -0
  157. package/node_modules/mdream/napi/rust.win32-arm64-msvc.node +0 -0
  158. package/node_modules/mdream/napi/rust.win32-x64-msvc.node +0 -0
  159. package/node_modules/mdream/node_modules/@emnapi/core/LICENSE +0 -21
  160. package/node_modules/mdream/node_modules/@emnapi/core/README.md +0 -1
  161. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +0 -392
  162. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +0 -392
  163. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +0 -8351
  164. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +0 -7268
  165. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +0 -5
  166. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +0 -843
  167. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +0 -4
  168. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +0 -3
  169. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +0 -5
  170. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +0 -1010
  171. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +0 -5
  172. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +0 -1446
  173. package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/LICENSE +0 -21
  174. package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/README.md +0 -203
  175. package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +0 -236
  176. package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +0 -1086
  177. package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/package.json +0 -35
  178. package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/rollup.config.js +0 -6
  179. package/node_modules/mdream/node_modules/@emnapi/core/package.json +0 -39
  180. package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +0 -60
  181. package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +0 -21
  182. package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +0 -1
  183. package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +0 -833
  184. package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +0 -2306
  185. package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +0 -1
  186. package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +0 -63
  187. package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +0 -39
  188. package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +0 -25
  189. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +0 -21
  190. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +0 -203
  191. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +0 -240
  192. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +0 -1118
  193. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +0 -35
  194. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +0 -6
  195. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +0 -1472
  196. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +0 -1470
  197. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +0 -237
  198. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +0 -17578
  199. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +0 -317
  200. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +0 -67
  201. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +0 -39
  202. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +0 -36
  203. package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +0 -21
  204. package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +0 -193
  205. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +0 -11
  206. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +0 -423
  207. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +0 -2932
  208. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +0 -2932
  209. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +0 -1
  210. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +0 -2954
  211. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +0 -1
  212. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +0 -158
  213. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +0 -13
  214. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +0 -46
  215. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +0 -97
  216. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +0 -35
  217. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +0 -103
  218. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +0 -268
  219. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +0 -3
  220. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +0 -192
  221. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +0 -316
  222. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +0 -1599
  223. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +0 -141
  224. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +0 -220
  225. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +0 -128
  226. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +0 -13
  227. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +0 -153
  228. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +0 -9
  229. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +0 -39
  230. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +0 -89
  231. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +0 -28
  232. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +0 -97
  233. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +0 -256
  234. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +0 -1
  235. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +0 -186
  236. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +0 -310
  237. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +0 -1593
  238. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +0 -135
  239. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +0 -216
  240. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +0 -113
  241. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +0 -9
  242. package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +0 -58
  243. package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +0 -15
  244. package/node_modules/mdream/node_modules/tslib/LICENSE.txt +0 -12
  245. package/node_modules/mdream/node_modules/tslib/README.md +0 -164
  246. package/node_modules/mdream/node_modules/tslib/SECURITY.md +0 -41
  247. package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +0 -38
  248. package/node_modules/mdream/node_modules/tslib/modules/index.js +0 -70
  249. package/node_modules/mdream/node_modules/tslib/modules/package.json +0 -3
  250. package/node_modules/mdream/node_modules/tslib/package.json +0 -47
  251. package/node_modules/mdream/node_modules/tslib/tslib.d.ts +0 -460
  252. package/node_modules/mdream/node_modules/tslib/tslib.es6.html +0 -1
  253. package/node_modules/mdream/node_modules/tslib/tslib.es6.js +0 -402
  254. package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +0 -401
  255. package/node_modules/mdream/node_modules/tslib/tslib.html +0 -1
  256. package/node_modules/mdream/node_modules/tslib/tslib.js +0 -484
  257. package/node_modules/mdream/package.json +0 -110
  258. package/node_modules/mdream/skills/mdream/SKILL.md +0 -124
  259. package/node_modules/mdream/skills/mdream/references/runtimes.md +0 -49
  260. package/node_modules/mdream/wasm/mdream_edge.d.ts +0 -90
  261. package/node_modules/mdream/wasm/mdream_edge.js +0 -517
  262. package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
  263. package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +0 -20
  264. package/node_modules/mdream/wasm/package.json +0 -17
  265. package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +0 -45
  266. package/node_modules/mdream/wasm-bundler/mdream_edge.js +0 -13
  267. package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +0 -413
  268. package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
  269. package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +0 -20
  270. package/node_modules/mdream/wasm-bundler/package.json +0 -19
  271. package/node_modules/pathe/LICENSE +0 -70
  272. package/node_modules/pathe/README.md +0 -73
  273. package/node_modules/pathe/dist/index.cjs +0 -39
  274. package/node_modules/pathe/dist/index.d.cts +0 -47
  275. package/node_modules/pathe/dist/index.d.mts +0 -47
  276. package/node_modules/pathe/dist/index.d.ts +0 -47
  277. package/node_modules/pathe/dist/index.mjs +0 -19
  278. package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +0 -266
  279. package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -249
  280. package/node_modules/pathe/dist/utils.cjs +0 -82
  281. package/node_modules/pathe/dist/utils.d.cts +0 -32
  282. package/node_modules/pathe/dist/utils.d.mts +0 -32
  283. package/node_modules/pathe/dist/utils.d.ts +0 -32
  284. package/node_modules/pathe/dist/utils.mjs +0 -77
  285. package/node_modules/pathe/package.json +0 -61
  286. package/node_modules/pathe/utils.d.ts +0 -1
@@ -1,843 +0,0 @@
1
- //#region src/emnapi/async-work.js
2
- function asyncWork (emnapiPluginCtx) {
3
- const { emnapiCtx, emnapiNodeBinding, emnapiAsyncWorkPoolSize } = emnapiPluginCtx;
4
- var mod = (function (exports, emnapi_shared, emscripten_runtime) {
5
-
6
- //#region src/async-work.ts
7
- /**
8
- * @__deps $emnapiCtx
9
- * @__deps $emnapiEnv
10
- * @__deps $emnapiNodeBinding
11
- * @__deps $emnapiAsyncWorkPoolSize
12
- * @__postset
13
- * ```
14
- * emnapiAWST.init();
15
- * ```
16
- */
17
- var emnapiAWST = {
18
- idGen: {},
19
- values: [undefined],
20
- queued: new Set(),
21
- pending: [],
22
- pendingHead: 0,
23
- init: function () {
24
- const idGen = {
25
- nextId: 1,
26
- list: [],
27
- listHead: 0,
28
- generate: function () {
29
- let id;
30
- if (idGen.listHead < idGen.list.length) {
31
- id = idGen.list[idGen.listHead++];
32
- if (idGen.listHead === idGen.list.length) {
33
- idGen.list.length = 0;
34
- idGen.listHead = 0;
35
- }
36
- }
37
- else {
38
- id = idGen.nextId;
39
- idGen.nextId++;
40
- }
41
- return id;
42
- },
43
- reuse: function (id) {
44
- idGen.list.push(id);
45
- }
46
- };
47
- emnapiAWST.idGen = idGen;
48
- emnapiAWST.values = [undefined];
49
- emnapiAWST.queued = new Set();
50
- emnapiAWST.pending = [];
51
- emnapiAWST.pendingHead = 0;
52
- },
53
- create: function (env, resource, resourceName, execute, complete, data) {
54
- let asyncId = 0;
55
- let triggerAsyncId = 0;
56
- if (emnapiNodeBinding) {
57
- const asyncContext = emnapiNodeBinding.node.emitAsyncInit(resource, resourceName, -1);
58
- asyncId = asyncContext.asyncId;
59
- triggerAsyncId = asyncContext.triggerAsyncId;
60
- }
61
- const id = emnapiAWST.idGen.generate();
62
- emnapiAWST.values[id] = {
63
- env,
64
- id,
65
- resource,
66
- asyncId,
67
- triggerAsyncId,
68
- status: 0,
69
- execute,
70
- complete,
71
- data
72
- };
73
- return id;
74
- },
75
- callComplete: function (work, status) {
76
- const complete = work.complete;
77
- const env = work.env;
78
- const data = work.data;
79
- const callback = () => {
80
- if (!complete)
81
- return;
82
- const envObject = emnapi_shared.emnapiEnv;
83
- const scope = emnapiCtx.openScope(envObject);
84
- try {
85
- envObject.callbackIntoModule(true, () => {
86
- (emnapiPluginCtx.wasmTable.get(complete))(env, status, data);
87
- });
88
- }
89
- finally {
90
- emnapiCtx.closeScope(envObject, scope);
91
- }
92
- };
93
- if (emnapiNodeBinding) {
94
- emnapiNodeBinding.node.makeCallback(work.resource, callback, [], {
95
- asyncId: work.asyncId,
96
- triggerAsyncId: work.triggerAsyncId
97
- });
98
- }
99
- else {
100
- callback();
101
- }
102
- },
103
- queue: function (id) {
104
- const work = emnapiAWST.values[id];
105
- if (!work)
106
- return;
107
- if (work.status === 0) {
108
- work.status = 1;
109
- if (emnapiAWST.queued.size >= (Math.abs(emnapiAsyncWorkPoolSize) || 4)) {
110
- if (emnapiAWST.pendingHead >= 1024 && emnapiAWST.pendingHead * 2 >= emnapiAWST.pending.length) {
111
- emnapiAWST.pending.splice(0, emnapiAWST.pendingHead);
112
- emnapiAWST.pendingHead = 0;
113
- }
114
- emnapiAWST.pending.push(id);
115
- return;
116
- }
117
- emnapiAWST.queued.add(id);
118
- const env = work.env;
119
- const data = work.data;
120
- const execute = work.execute;
121
- work.status = 2;
122
- emnapiCtx.features.setImmediate(() => {
123
- (emnapiPluginCtx.wasmTable.get(execute))(env, data);
124
- emnapiAWST.queued.delete(id);
125
- work.status = 3;
126
- emnapiCtx.features.setImmediate(() => {
127
- emnapiAWST.callComplete(work, 0 /* napi_status.napi_ok */);
128
- });
129
- if (emnapiAWST.pendingHead < emnapiAWST.pending.length) {
130
- const nextWorkId = emnapiAWST.pending[emnapiAWST.pendingHead++];
131
- if (emnapiAWST.pendingHead === emnapiAWST.pending.length) {
132
- emnapiAWST.pending.length = 0;
133
- emnapiAWST.pendingHead = 0;
134
- }
135
- emnapiAWST.values[nextWorkId].status = 0;
136
- emnapiAWST.queue(nextWorkId);
137
- }
138
- });
139
- }
140
- },
141
- cancel: function (id) {
142
- const index = emnapiAWST.pending.indexOf(id, emnapiAWST.pendingHead);
143
- if (index !== -1) {
144
- const work = emnapiAWST.values[id];
145
- if (work && (work.status === 1)) {
146
- work.status = 4;
147
- emnapiAWST.pending.splice(index, 1);
148
- if (emnapiAWST.pendingHead === emnapiAWST.pending.length) {
149
- emnapiAWST.pending.length = 0;
150
- emnapiAWST.pendingHead = 0;
151
- }
152
- emnapiCtx.features.setImmediate(() => {
153
- emnapiAWST.callComplete(work, 11 /* napi_status.napi_cancelled */);
154
- });
155
- return 0 /* napi_status.napi_ok */;
156
- }
157
- else {
158
- return 9 /* napi_status.napi_generic_failure */;
159
- }
160
- }
161
- return 9 /* napi_status.napi_generic_failure */;
162
- },
163
- remove: function (id) {
164
- const work = emnapiAWST.values[id];
165
- if (!work)
166
- return;
167
- if (emnapiNodeBinding) {
168
- emnapiNodeBinding.node.emitAsyncDestroy({
169
- asyncId: work.asyncId,
170
- triggerAsyncId: work.triggerAsyncId
171
- });
172
- }
173
- emnapiAWST.values[id] = undefined;
174
- emnapiAWST.idGen.reuse(id);
175
- }
176
- };
177
-
178
- //#endregion src/async-work.ts
179
-
180
- //#region src/macro.ts
181
-
182
- //#endregion src/macro.ts
183
-
184
- //#region src/core/async-work.ts
185
- const {
186
- // onCreateWorker, napiModule, singleThreadAsyncWork, _emnapi_async_work_pool_size,
187
- // PThread, ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_PTHREAD, wasmInstance, _free, wasmMemory, _malloc,
188
- _emnapi_node_emit_async_init, _emnapi_node_emit_async_destroy, _emnapi_runtime_keepalive_pop, _emnapi_runtime_keepalive_push } = emnapiPluginCtx;
189
- var emnapiAWMT = {
190
- pool: [],
191
- workerReady: null,
192
- globalAddress: 0,
193
- globalOffset: {
194
- idle_threads: 0,
195
- q: 1 * 4,
196
- next: 1 * 4,
197
- prev: 2 * 4,
198
- mutex: 3 * 4,
199
- cond: 4 * 4,
200
- exit_message: 5 * 4,
201
- end: 7 * 4
202
- },
203
- offset: {
204
- /* napi_ref */ resource: 0,
205
- /* double */ async_id: 8,
206
- /* double */ trigger_async_id: 16,
207
- /* napi_env */ env: 24,
208
- /* int32_t */ status: 1 * 4 + 24, // 0 for pending, 1 for cancelled, 2 for completed
209
- queue: 2 * 4 + 24,
210
- queue_next: 2 * 4 + 24,
211
- queue_prev: 3 * 4 + 24,
212
- /* void* */ data: 4 * 4 + 24,
213
- /* napi_async_execute_callback */ execute: 5 * 4 + 24,
214
- /* napi_async_complete_callback */ complete: 6 * 4 + 24,
215
- end: 7 * 4 + 24
216
- },
217
- /**
218
- * When another thread grows the shared WebAssembly.Memory, this agent's
219
- * cached `wasmMemory.buffer` may still have the old shorter length
220
- * (V8 refreshes it lazily). If a pointer derived from shared memory lies
221
- * beyond the cached length, `wasmMemory.grow(0)` forces the agent to
222
- * observe the current memory size and refreshes the buffer.
223
- */
224
- ensureBufferFor(end) {
225
- let buffer = emscripten_runtime.wasmMemory.buffer;
226
- if (end > buffer.byteLength) {
227
- emscripten_runtime.wasmMemory.grow(0);
228
- buffer = emscripten_runtime.wasmMemory.buffer;
229
- }
230
- return buffer;
231
- },
232
- init() {
233
- emnapiAWMT.pool = [];
234
- emnapiAWMT.workerReady = null;
235
- if (typeof emscripten_runtime.PThread !== 'undefined') {
236
- emscripten_runtime.PThread.unusedWorkers.forEach(emnapiAWMT.addListener);
237
- Object.values(emscripten_runtime.PThread.pthreads).forEach(emnapiAWMT.addListener);
238
- const __original_getNewWorker = emscripten_runtime.PThread.getNewWorker;
239
- emscripten_runtime.PThread.getNewWorker = function () {
240
- const r = __original_getNewWorker.apply(this, arguments);
241
- emnapiAWMT.addListener(r);
242
- return r;
243
- };
244
- }
245
- },
246
- addListener(worker) {
247
- if (!worker)
248
- return false;
249
- if (worker._emnapiAWMTListener)
250
- return true;
251
- const handler = function (e) {
252
- const data = emscripten_runtime.ENVIRONMENT_IS_NODE ? e : e.data;
253
- const __emnapi__ = data.__emnapi__;
254
- if (__emnapi__) {
255
- const type = __emnapi__.type;
256
- const payload = __emnapi__.payload;
257
- if (type === 'async-work-complete') {
258
- emnapiAWMT.callComplete(payload.work, 0 /* napi_status.napi_ok */);
259
- }
260
- }
261
- };
262
- const dispose = function () {
263
- if (emscripten_runtime.ENVIRONMENT_IS_NODE) {
264
- worker.off('message', handler);
265
- }
266
- else {
267
- worker.removeEventListener('message', handler, false);
268
- }
269
- delete worker._emnapiAWMTListener;
270
- };
271
- worker._emnapiAWMTListener = { handler, dispose };
272
- if (emscripten_runtime.ENVIRONMENT_IS_NODE) {
273
- worker.on('message', handler);
274
- }
275
- else {
276
- worker.addEventListener('message', handler, false);
277
- }
278
- return true;
279
- },
280
- initGlobal() {
281
- if (!emnapiAWMT.globalAddress) {
282
- emnapiAWMT.globalAddress = emscripten_runtime._malloc(emnapiAWMT.globalOffset.end);
283
- emnapiAWMT.globalAddress >>>= 0;
284
- const size = emnapiAWMT.globalOffset.end;
285
- const addr = emnapiAWMT.globalAddress;
286
- new Uint8Array(emnapiAWMT.ensureBufferFor(addr + size), addr, size).fill(0);
287
- emnapiAWMT.queueInit(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.q);
288
- emnapiAWMT.queueInit(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.exit_message);
289
- }
290
- },
291
- terminateWorkers() {
292
- emnapiAWMT.pool.forEach(w => {
293
- w._emnapiAWMTListener?.dispose();
294
- w._emnapiTSFNListener?.dispose();
295
- w.terminate();
296
- });
297
- emnapiAWMT.pool.length = 0;
298
- },
299
- initWorkers(n) {
300
- if (emscripten_runtime.ENVIRONMENT_IS_PTHREAD) {
301
- return emnapiAWMT.workerReady || (emnapiAWMT.workerReady = Promise.resolve());
302
- }
303
- if (emnapiAWMT.workerReady)
304
- return emnapiAWMT.workerReady;
305
- if (!('emnapi_async_worker_create' in emscripten_runtime.wasmInstance.exports)) {
306
- throw new TypeError('`emnapi_async_worker_create` is not exported, please try to add `--export=emnapi_async_worker_create` to linker flags');
307
- }
308
- const emnapi_async_worker_create = emscripten_runtime.wasmInstance.exports.emnapi_async_worker_create;
309
- const args = [];
310
- emnapiAWMT.initGlobal();
311
- for (let i = 0; i < n; ++i) {
312
- args.push(emnapi_async_worker_create(1, emnapiAWMT.globalAddress));
313
- }
314
- const promises = args.map(index => {
315
- if (index === 0) {
316
- return Promise.reject(new Error('Failed to create async worker'));
317
- }
318
- let worker;
319
- if (index < 0) {
320
- worker = emnapiAWMT.pool[-index - 1];
321
- if (worker)
322
- return worker.whenLoaded;
323
- }
324
- index >>>= 0;
325
- const tidOffset = 20;
326
- const view = new DataView(emnapiAWMT.ensureBufferFor(index + tidOffset + 4));
327
- const tid = view.getInt32(index + tidOffset, true);
328
- worker = emscripten_runtime.PThread.pthreads[tid];
329
- return worker.whenLoaded;
330
- });
331
- emnapiAWMT.workerReady = Promise.all(promises);
332
- return emnapiAWMT.workerReady;
333
- },
334
- getResource(work) {
335
- emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.resource + 4);
336
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
337
- return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.resource, true);
338
- },
339
- getExecute(work) {
340
- emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.execute + 4);
341
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
342
- return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.execute, true);
343
- },
344
- getComplete(work) {
345
- emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.complete + 4);
346
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
347
- return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.complete, true);
348
- },
349
- getEnv(work) {
350
- emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.env + 4);
351
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
352
- return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.env, true);
353
- },
354
- getData(work) {
355
- emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.data + 4);
356
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
357
- return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.data, true);
358
- },
359
- getMutex() {
360
- const index = emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.mutex;
361
- const mutex = {
362
- lock() {
363
- const isBrowserMain = typeof window !== 'undefined' && typeof document !== 'undefined' && !emscripten_runtime.ENVIRONMENT_IS_NODE;
364
- const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
365
- if (isBrowserMain) {
366
- while (true) {
367
- const oldValue = Atomics.compareExchange(i32a, 0, 0, 10);
368
- if (oldValue === 0) {
369
- return;
370
- }
371
- }
372
- }
373
- else {
374
- while (true) {
375
- const oldValue = Atomics.compareExchange(i32a, 0, 0, 10);
376
- if (oldValue === 0) {
377
- return;
378
- }
379
- Atomics.wait(i32a, 0, 10);
380
- }
381
- }
382
- },
383
- unlock() {
384
- const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
385
- const oldValue = Atomics.compareExchange(i32a, 0, 10, 0);
386
- if (oldValue !== 10) {
387
- throw new Error('Tried to unlock while not holding the mutex');
388
- }
389
- Atomics.notify(i32a, 0, 1);
390
- },
391
- execute(fn) {
392
- mutex.lock();
393
- try {
394
- return fn();
395
- }
396
- finally {
397
- mutex.unlock();
398
- }
399
- }
400
- };
401
- return mutex;
402
- },
403
- getCond() {
404
- const index = emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.cond;
405
- const mutex = emnapiAWMT.getMutex();
406
- const cond = {
407
- wait() {
408
- const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
409
- const value = Atomics.load(i32a, 0);
410
- mutex.unlock();
411
- Atomics.wait(i32a, 0, value);
412
- mutex.lock();
413
- },
414
- signal() {
415
- const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
416
- Atomics.add(i32a, 0, 1);
417
- Atomics.notify(i32a, 0, 1);
418
- }
419
- };
420
- return cond;
421
- },
422
- queueInit(q) {
423
- emnapiAWMT.ensureBufferFor(q + 4 + 4);
424
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
425
- GET_HEAP_DATA_VIEW().setUint32(q, q, true);
426
- GET_HEAP_DATA_VIEW().setUint32(q + 4, q, true);
427
- },
428
- queueInsertTail(h, q) {
429
- emnapiAWMT.ensureBufferFor(h + 4 + 4);
430
- emnapiAWMT.ensureBufferFor(q + 4 + 4);
431
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
432
- GET_HEAP_DATA_VIEW().setUint32(q, h, true);
433
- const tempValue = GET_HEAP_DATA_VIEW().getUint32(h + 4, true);
434
- GET_HEAP_DATA_VIEW().setUint32(q + 4, tempValue, true);
435
- const qprev = GET_HEAP_DATA_VIEW().getUint32(q + 4, true);
436
- GET_HEAP_DATA_VIEW().setUint32(qprev, q, true);
437
- GET_HEAP_DATA_VIEW().setUint32(h + 4, q, true);
438
- },
439
- queueRemove(q) {
440
- emnapiAWMT.ensureBufferFor(q + 4 + 4);
441
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
442
- const qprev = GET_HEAP_DATA_VIEW().getUint32(q + 4, true);
443
- const qnext = GET_HEAP_DATA_VIEW().getUint32(q, true);
444
- GET_HEAP_DATA_VIEW().setUint32(qprev, qnext, true);
445
- GET_HEAP_DATA_VIEW().setUint32(qnext + 4, qprev, true);
446
- },
447
- queueEmpty(q) {
448
- emnapiAWMT.ensureBufferFor(q + 4);
449
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
450
- // eslint-disable-next-line eqeqeq
451
- return q == GET_HEAP_DATA_VIEW().getUint32(q, true);
452
- },
453
- scheduleWork: function (work) {
454
- if (!emnapiAWMT.workerReady?.ready) {
455
- emnapiAWMT.initWorkers(emnapi_shared._emnapi_async_work_pool_size()).then(() => {
456
- emnapiAWMT.workerReady.ready = true;
457
- }).catch((err) => {
458
- emnapiAWMT.workerReady = null;
459
- throw err;
460
- });
461
- }
462
- _emnapi_runtime_keepalive_push();
463
- emnapiCtx.increaseWaitingRequestCounter();
464
- const statusBuffer = new Int32Array(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4), work + emnapiAWMT.offset.status, 1);
465
- Atomics.store(statusBuffer, 0, 0 /* AsyncWorkStatus.Pending */);
466
- const mutex = emnapiAWMT.getMutex();
467
- const cond = emnapiAWMT.getCond();
468
- mutex.lock();
469
- try {
470
- emnapiAWMT.queueInsertTail(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.q, work + emnapiAWMT.offset.queue);
471
- }
472
- catch (err) {
473
- _emnapi_runtime_keepalive_pop();
474
- emnapiCtx.decreaseWaitingRequestCounter();
475
- mutex.unlock();
476
- throw err;
477
- }
478
- emnapiAWMT.ensureBufferFor(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.idle_threads + 4);
479
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
480
- if (GET_HEAP_DATA_VIEW().getUint32(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.idle_threads, true) > 0) {
481
- cond.signal();
482
- }
483
- mutex.unlock();
484
- },
485
- cancelWork(work) {
486
- let cancelled = false;
487
- emnapiAWMT.getMutex().execute(() => {
488
- emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4);
489
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
490
- cancelled = !emnapiAWMT.queueEmpty(work + emnapiAWMT.offset.queue) && GET_HEAP_DATA_VIEW().getInt32(work + emnapiAWMT.offset.status, true) !== 2 /* AsyncWorkStatus.Completed */;
491
- if (cancelled) {
492
- emnapiAWMT.queueRemove(work + emnapiAWMT.offset.queue);
493
- }
494
- });
495
- if (!cancelled) {
496
- return 9 /* napi_status.napi_generic_failure */;
497
- }
498
- if (Atomics.compareExchange(new Int32Array(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4), work + emnapiAWMT.offset.status, 1), 0, 0 /* AsyncWorkStatus.Pending */, 1 /* AsyncWorkStatus.Cancelled */) !== 0 /* AsyncWorkStatus.Pending */) {
499
- return 9 /* napi_status.napi_generic_failure */;
500
- }
501
- emnapiCtx.features.setImmediate(() => {
502
- emnapiAWMT.callComplete(work, 11 /* napi_status.napi_cancelled */);
503
- });
504
- return 0 /* napi_status.napi_ok */;
505
- },
506
- callComplete: function (work, status) {
507
- _emnapi_runtime_keepalive_pop();
508
- emnapiCtx.decreaseWaitingRequestCounter();
509
- const complete = emnapiAWMT.getComplete(work);
510
- const env = emnapiAWMT.getEnv(work);
511
- const data = emnapiAWMT.getData(work);
512
- const envObject = emnapi_shared.emnapiEnv;
513
- const scope = emnapiCtx.openScope(envObject);
514
- const callback = () => {
515
- if (!complete)
516
- return;
517
- envObject.callbackIntoModule(true, () => {
518
- (emnapiPluginCtx.wasmTable.get(complete))(env, status, data);
519
- });
520
- };
521
- try {
522
- if (emnapiNodeBinding) {
523
- const resource = emnapiAWMT.getResource(work);
524
- const resource_value = emnapiCtx.getRef(resource).get();
525
- const resourceObject = emnapiCtx.jsValueFromNapiValue(resource_value);
526
- const view = new DataView(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.trigger_async_id + 8));
527
- const asyncId = view.getFloat64(work + emnapiAWMT.offset.async_id, true);
528
- const triggerAsyncId = view.getFloat64(work + emnapiAWMT.offset.trigger_async_id, true);
529
- emnapiNodeBinding.node.makeCallback(resourceObject, callback, [], {
530
- asyncId,
531
- triggerAsyncId
532
- });
533
- }
534
- else {
535
- callback();
536
- }
537
- }
538
- finally {
539
- emnapiCtx.closeScope(envObject, scope);
540
- }
541
- }
542
- };
543
- emnapiAWST.init();
544
- emnapiAWMT.init();
545
- /** @__sig ippppppp */
546
- var napi_create_async_work = emnapi_shared.singleThreadAsyncWork
547
- ? function (env, resource, resource_name, execute, complete, data, result) {
548
- if (!env)
549
- return 1 /* napi_status.napi_invalid_arg */;
550
- // @ts-expect-error
551
- const envObject = emnapi_shared.emnapiEnv;
552
- envObject.checkGCAccess();
553
- if (!execute)
554
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
555
- if (!result)
556
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
557
- let resourceObject;
558
- if (resource) {
559
- resourceObject = Object(emnapiCtx.jsValueFromNapiValue(resource));
560
- }
561
- else {
562
- resourceObject = {};
563
- }
564
- if (!resource_name)
565
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
566
- const resourceName = String(emnapiCtx.jsValueFromNapiValue(resource_name));
567
- const id = emnapiAWST.create(env, resourceObject, resourceName, execute, complete, data);
568
- result >>>= 0;
569
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
570
- GET_HEAP_DATA_VIEW().setUint32(result, id, true);
571
- return envObject.clearLastError();
572
- }
573
- : function (env, resource, resource_name, execute, complete, data, result) {
574
- if (!env)
575
- return 1 /* napi_status.napi_invalid_arg */;
576
- // @ts-expect-error
577
- const envObject = emnapi_shared.emnapiEnv;
578
- envObject.checkGCAccess();
579
- if (!execute)
580
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
581
- if (!result)
582
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
583
- let resourceObject;
584
- if (resource) {
585
- resourceObject = Object(emnapiCtx.jsValueFromNapiValue(resource));
586
- }
587
- else {
588
- resourceObject = {};
589
- }
590
- if (!resource_name)
591
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
592
- const sizeofAW = emnapiAWMT.offset.end;
593
- let aw = emscripten_runtime._malloc(sizeofAW);
594
- if (!aw)
595
- return envObject.setLastError(9 /* napi_status.napi_generic_failure */);
596
- aw >>>= 0;
597
- new Uint8Array(emnapiAWMT.ensureBufferFor(aw + sizeofAW)).subarray(aw, aw + sizeofAW).fill(0);
598
- const s = emnapiCtx.napiValueFromJsValue(resourceObject);
599
- const resourceRef = emnapiCtx.createReference(envObject, s, 1, 1 /* ReferenceOwnership.kUserland */);
600
- const resource_ = resourceRef.id;
601
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
602
- GET_HEAP_DATA_VIEW().setUint32(aw, resource_, true);
603
- _emnapi_node_emit_async_init(s, resource_name, -1, aw + emnapiAWMT.offset.async_id);
604
- GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.env, env, true);
605
- GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.execute, execute, true);
606
- GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.complete, complete, true);
607
- GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.data, data, true);
608
- emnapiAWMT.queueInit(aw + emnapiAWMT.offset.queue);
609
- result >>>= 0;
610
- GET_HEAP_DATA_VIEW().setUint32(result, aw, true);
611
- return envObject.clearLastError();
612
- };
613
- /** @__sig ipp */
614
- var napi_delete_async_work = emnapi_shared.singleThreadAsyncWork
615
- ? function (env, work) {
616
- if (!env)
617
- return 1 /* napi_status.napi_invalid_arg */;
618
- // @ts-expect-error
619
- const envObject = emnapi_shared.emnapiEnv;
620
- envObject.checkGCAccess();
621
- if (!work)
622
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
623
- work >>>= 0;
624
- emnapiAWST.remove(work);
625
- return envObject.clearLastError();
626
- }
627
- : function (env, work) {
628
- if (!env)
629
- return 1 /* napi_status.napi_invalid_arg */;
630
- // @ts-expect-error
631
- const envObject = emnapi_shared.emnapiEnv;
632
- envObject.checkGCAccess();
633
- if (!work)
634
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
635
- work >>>= 0;
636
- const resource = emnapiAWMT.getResource(work);
637
- emnapiCtx.getRef(resource).dispose();
638
- if (emnapiNodeBinding) {
639
- const view = new DataView(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.trigger_async_id + 8));
640
- const asyncId = view.getFloat64(work + emnapiAWMT.offset.async_id, true);
641
- const triggerAsyncId = view.getFloat64(work + emnapiAWMT.offset.trigger_async_id, true);
642
- _emnapi_node_emit_async_destroy(asyncId, triggerAsyncId);
643
- }
644
- emscripten_runtime._free(work);
645
- return envObject.clearLastError();
646
- };
647
- /** @__sig ipp */
648
- var napi_queue_async_work = emnapi_shared.singleThreadAsyncWork
649
- ? function (env, work) {
650
- if (!env)
651
- return 1 /* napi_status.napi_invalid_arg */;
652
- const envObject = emnapi_shared.emnapiEnv;
653
- if (!work)
654
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
655
- work >>>= 0;
656
- emnapiAWST.queue(work);
657
- return envObject.clearLastError();
658
- }
659
- : function (env, work) {
660
- if (!env)
661
- return 1 /* napi_status.napi_invalid_arg */;
662
- const envObject = emnapi_shared.emnapiEnv;
663
- if (!work)
664
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
665
- work >>>= 0;
666
- emnapiAWMT.scheduleWork(work);
667
- return envObject.clearLastError();
668
- };
669
- /** @__sig ipp */
670
- var napi_cancel_async_work = emnapi_shared.singleThreadAsyncWork
671
- ? function (env, work) {
672
- if (!env)
673
- return 1 /* napi_status.napi_invalid_arg */;
674
- const envObject = emnapi_shared.emnapiEnv;
675
- if (!work)
676
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
677
- work >>>= 0;
678
- const status = emnapiAWST.cancel(work);
679
- if (status === 0 /* napi_status.napi_ok */)
680
- return envObject.clearLastError();
681
- return envObject.setLastError(status);
682
- }
683
- : function (env, work) {
684
- if (!env)
685
- return 1 /* napi_status.napi_invalid_arg */;
686
- const envObject = emnapi_shared.emnapiEnv;
687
- if (!work)
688
- return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
689
- work >>>= 0;
690
- const status = emnapiAWMT.cancelWork(work);
691
- if (status === 0 /* napi_status.napi_ok */)
692
- return envObject.clearLastError();
693
- return envObject.setLastError(status);
694
- };
695
- /** @__sig pp */
696
- function _emnapi_async_worker(globalAddress) {
697
- globalAddress >>>= 0;
698
- emnapiAWMT.globalAddress = globalAddress;
699
- const mutex = emnapiAWMT.getMutex();
700
- const cond = emnapiAWMT.getCond();
701
- mutex.lock();
702
- const exitMessageAddr = globalAddress + emnapiAWMT.globalOffset.exit_message;
703
- const idleThreadsAddr = globalAddress + emnapiAWMT.globalOffset.idle_threads;
704
- const workerQueueAddr = globalAddress + emnapiAWMT.globalOffset.q;
705
- var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
706
- for (;;) {
707
- emnapiAWMT.ensureBufferFor(workerQueueAddr + 4);
708
- while (emnapiAWMT.queueEmpty(workerQueueAddr)) {
709
- Atomics.add(new Int32Array(emnapiAWMT.ensureBufferFor(idleThreadsAddr + 4), idleThreadsAddr, 1), 0, 1);
710
- cond.wait();
711
- Atomics.sub(new Int32Array(emnapiAWMT.ensureBufferFor(idleThreadsAddr + 4), idleThreadsAddr, 1), 0, 1);
712
- }
713
- const q = GET_HEAP_DATA_VIEW().getUint32(workerQueueAddr, true);
714
- if (q === exitMessageAddr) {
715
- cond.signal();
716
- mutex.unlock();
717
- break;
718
- }
719
- const work = q - emnapiAWMT.offset.queue;
720
- emnapiAWMT.queueRemove(q);
721
- emnapiAWMT.queueInit(q);
722
- mutex.unlock();
723
- const statusBuffer = new Int32Array(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4), work + emnapiAWMT.offset.status, 1);
724
- if (Atomics.load(statusBuffer, 0) === 1 /* AsyncWorkStatus.Cancelled */) {
725
- emscripten_runtime.abort('unreachable');
726
- }
727
- const execute = emnapiAWMT.getExecute(work);
728
- const env = emnapiAWMT.getEnv(work);
729
- const data = emnapiAWMT.getData(work);
730
- (emnapiPluginCtx.wasmTable.get(execute))(env, data);
731
- Atomics.store(statusBuffer, 0, 2 /* AsyncWorkStatus.Completed */);
732
- const postMessage = emnapi_shared.napiModule.postMessage;
733
- postMessage({
734
- __emnapi__: {
735
- type: 'async-work-complete',
736
- payload: { work }
737
- }
738
- });
739
- mutex.lock();
740
- }
741
- return 0;
742
- }
743
- /** @__sig ipp */
744
- function _emnapi_spawn_worker(f, globalAddress) {
745
- if (typeof emnapi_shared.onCreateWorker !== 'function') {
746
- throw new TypeError('`options.onCreateWorker` is not a function');
747
- }
748
- const promises = [];
749
- const args = [];
750
- if (!('emnapi_async_worker_create' in emscripten_runtime.wasmInstance.exports)) {
751
- throw new TypeError('`emnapi_async_worker_create` is not exported, please try to add `--export=emnapi_async_worker_create` to linker flags');
752
- }
753
- args.push(emscripten_runtime.wasmInstance.exports.emnapi_async_worker_create(0, 0));
754
- let ret;
755
- try {
756
- const worker = emnapi_shared.onCreateWorker({ type: 'async-work', name: 'emnapi-async-worker' });
757
- const handleError = () => {
758
- // Loading failures reject loadWasmModuleToWorker and are local to this
759
- // worker. Once loaded, every uncaught worker error is terminal; do not
760
- // depend on engine-specific RuntimeError message text.
761
- if (!worker.loaded)
762
- return;
763
- Promise.resolve().then(() => {
764
- emnapiAWMT.terminateWorkers();
765
- emscripten_runtime.PThread.terminateAllThreads();
766
- });
767
- };
768
- if (emscripten_runtime.ENVIRONMENT_IS_NODE) {
769
- worker.on('error', handleError);
770
- }
771
- else {
772
- worker.addEventListener('error', handleError, false);
773
- }
774
- const p = emscripten_runtime.PThread.loadWasmModuleToWorker(worker);
775
- emnapiAWMT.addListener(worker);
776
- if (typeof emnapiPluginCtx.emnapiTSFN !== 'undefined') {
777
- emnapiPluginCtx.emnapiTSFN.addListener(worker);
778
- }
779
- promises.push(p.then(() => {
780
- if (typeof worker.unref === 'function') {
781
- worker.unref();
782
- }
783
- }));
784
- ret = emnapiAWMT.pool.push(worker) - 1;
785
- const arg = args[0];
786
- worker.threadBlockBase = arg;
787
- worker.postMessage({
788
- __emnapi__: {
789
- type: 'async-worker-init',
790
- payload: { arg, func: [f, globalAddress] }
791
- }
792
- });
793
- }
794
- catch (err) {
795
- const arg = args[0];
796
- emscripten_runtime._free(arg);
797
- throw err;
798
- }
799
- return ret;
800
- }
801
- function initWorker(startArg, func) {
802
- if (emnapi_shared.napiModule.childThread) {
803
- if (typeof emscripten_runtime.wasmInstance.exports.emnapi_async_worker_init !== 'function') {
804
- throw new TypeError('`emnapi_async_worker_init` is not exported, please try to add `--export=emnapi_async_worker_init` to linker flags');
805
- }
806
- emscripten_runtime.wasmInstance.exports.emnapi_async_worker_init(startArg);
807
- (emnapiPluginCtx.wasmTable.get(func[0]))(func[1]);
808
- }
809
- else {
810
- throw new Error('startThread is only available in child threads');
811
- }
812
- }
813
- emnapi_shared.napiModule.initWorker = initWorker;
814
-
815
- //#endregion src/core/async-work.ts
816
-
817
- exports._emnapi_async_worker = _emnapi_async_worker;
818
- exports._emnapi_spawn_worker = _emnapi_spawn_worker;
819
- exports.napi_cancel_async_work = napi_cancel_async_work;
820
- exports.napi_create_async_work = napi_create_async_work;
821
- exports.napi_delete_async_work = napi_delete_async_work;
822
- exports.napi_queue_async_work = napi_queue_async_work;
823
-
824
- return exports;
825
-
826
- })({}, emnapiPluginCtx, emnapiPluginCtx);
827
- return {
828
- importObject: (original) => {
829
-
830
- Object.keys(mod).forEach(key => {
831
- if (key.startsWith('napi_') || key.startsWith('node_api_')) {
832
- original.napi[key] = mod[key];
833
- } else {
834
- original.env[key] = mod[key];
835
- }
836
- });
837
- }
838
- };
839
- }
840
-
841
- //#endregion src/emnapi/async-work.js
842
-
843
- export { asyncWork as default };