mega-framework 0.1.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 (322) hide show
  1. package/.env +127 -0
  2. package/.env.example +186 -0
  3. package/.prettierrc.json +8 -0
  4. package/CHANGELOG.md +259 -0
  5. package/LICENSE +21 -0
  6. package/README.md +153 -0
  7. package/bin/mega-ws-hub.js +15 -0
  8. package/bin/mega.js +38 -0
  9. package/docker-compose.yml +201 -0
  10. package/eslint.config.js +57 -0
  11. package/infra/otel-collector-config.yaml +43 -0
  12. package/jsconfig.json +18 -0
  13. package/package.json +121 -0
  14. package/sample/crud/.env +18 -0
  15. package/sample/crud/.env.example +50 -0
  16. package/sample/crud/README.md +85 -0
  17. package/sample/crud/apps/main/app.config.js +114 -0
  18. package/sample/crud/apps/main/channels/chat-bus.js +115 -0
  19. package/sample/crud/apps/main/channels/chat-channel.js +145 -0
  20. package/sample/crud/apps/main/controllers/auth-controller.js +144 -0
  21. package/sample/crud/apps/main/controllers/cron-controller.js +34 -0
  22. package/sample/crud/apps/main/controllers/guide-controller.js +37 -0
  23. package/sample/crud/apps/main/controllers/jobs-controller.js +43 -0
  24. package/sample/crud/apps/main/controllers/logs-controller.js +35 -0
  25. package/sample/crud/apps/main/controllers/metrics-controller.js +22 -0
  26. package/sample/crud/apps/main/controllers/note-controller.js +116 -0
  27. package/sample/crud/apps/main/controllers/perf-controller.js +38 -0
  28. package/sample/crud/apps/main/controllers/redis-controller.js +36 -0
  29. package/sample/crud/apps/main/controllers/tracing-controller.js +43 -0
  30. package/sample/crud/apps/main/controllers/upload-controller.js +98 -0
  31. package/sample/crud/apps/main/controllers/user-controller.js +34 -0
  32. package/sample/crud/apps/main/controllers/web-controller.js +137 -0
  33. package/sample/crud/apps/main/controllers/worker-controller.js +57 -0
  34. package/sample/crud/apps/main/controllers/ws-controller.js +29 -0
  35. package/sample/crud/apps/main/jobs/email-job.js +72 -0
  36. package/sample/crud/apps/main/locales/client/en.json +3 -0
  37. package/sample/crud/apps/main/locales/client/ko.json +3 -0
  38. package/sample/crud/apps/main/locales/server/en.json +316 -0
  39. package/sample/crud/apps/main/locales/server/ko.json +316 -0
  40. package/sample/crud/apps/main/middleware/web-auth.js +40 -0
  41. package/sample/crud/apps/main/middleware/ws-auth.js +48 -0
  42. package/sample/crud/apps/main/migrations/20260606000001-create-users.js +27 -0
  43. package/sample/crud/apps/main/migrations/20260606000002-add-auth-to-users.js +30 -0
  44. package/sample/crud/apps/main/models/note.js +71 -0
  45. package/sample/crud/apps/main/models/user.js +86 -0
  46. package/sample/crud/apps/main/public/css/app.css +101 -0
  47. package/sample/crud/apps/main/public/css/guide.css +137 -0
  48. package/sample/crud/apps/main/public/js/app.js +54 -0
  49. package/sample/crud/apps/main/public/js/perf.js +129 -0
  50. package/sample/crud/apps/main/public/js/theme-init.js +12 -0
  51. package/sample/crud/apps/main/public/js/upload-demo.js +63 -0
  52. package/sample/crud/apps/main/public/js/worker-demo.js +92 -0
  53. package/sample/crud/apps/main/public/js/ws-chat.js +161 -0
  54. package/sample/crud/apps/main/public/vendor/bootstrap/bootstrap.bundle.min.js +7 -0
  55. package/sample/crud/apps/main/public/vendor/bootstrap/bootstrap.min.css +6 -0
  56. package/sample/crud/apps/main/public/vendor/highlight/github-dark.css +109 -0
  57. package/sample/crud/apps/main/public/vendor/highlight/github.css +118 -0
  58. package/sample/crud/apps/main/public/vendor/mega-client-wasm/README.md +19 -0
  59. package/sample/crud/apps/main/public/vendor/mega-client-wasm/mega_client_wasm.d.ts +196 -0
  60. package/sample/crud/apps/main/public/vendor/mega-client-wasm/mega_client_wasm.js +1187 -0
  61. package/sample/crud/apps/main/public/vendor/mega-client-wasm/mega_client_wasm_bg.wasm +0 -0
  62. package/sample/crud/apps/main/routes/auth.js +15 -0
  63. package/sample/crud/apps/main/routes/cron.js +14 -0
  64. package/sample/crud/apps/main/routes/guide.js +25 -0
  65. package/sample/crud/apps/main/routes/jobs.js +14 -0
  66. package/sample/crud/apps/main/routes/logs.js +28 -0
  67. package/sample/crud/apps/main/routes/metrics.js +13 -0
  68. package/sample/crud/apps/main/routes/notes.js +19 -0
  69. package/sample/crud/apps/main/routes/perf.js +47 -0
  70. package/sample/crud/apps/main/routes/redis.js +14 -0
  71. package/sample/crud/apps/main/routes/tracing.js +14 -0
  72. package/sample/crud/apps/main/routes/upload.js +16 -0
  73. package/sample/crud/apps/main/routes/users.js +54 -0
  74. package/sample/crud/apps/main/routes/web.js +23 -0
  75. package/sample/crud/apps/main/routes/worker.js +15 -0
  76. package/sample/crud/apps/main/routes/ws.js +30 -0
  77. package/sample/crud/apps/main/schedules/cron-counter-schedule.js +30 -0
  78. package/sample/crud/apps/main/services/auth-service.js +74 -0
  79. package/sample/crud/apps/main/services/cron-demo-service.js +66 -0
  80. package/sample/crud/apps/main/services/guide-service.js +145 -0
  81. package/sample/crud/apps/main/services/jobs-demo-service.js +83 -0
  82. package/sample/crud/apps/main/services/logs-demo-service.js +59 -0
  83. package/sample/crud/apps/main/services/metrics-demo-service.js +144 -0
  84. package/sample/crud/apps/main/services/note-service.js +75 -0
  85. package/sample/crud/apps/main/services/perf-service.js +302 -0
  86. package/sample/crud/apps/main/services/redis-demo-service.js +75 -0
  87. package/sample/crud/apps/main/services/tracing-demo-service.js +69 -0
  88. package/sample/crud/apps/main/services/upload-demo-service.js +48 -0
  89. package/sample/crud/apps/main/services/user-service.js +65 -0
  90. package/sample/crud/apps/main/views/auth/login.ejs +57 -0
  91. package/sample/crud/apps/main/views/auth/register.ejs +71 -0
  92. package/sample/crud/apps/main/views/cron/index.ejs +92 -0
  93. package/sample/crud/apps/main/views/guide/index.ejs +24 -0
  94. package/sample/crud/apps/main/views/guide/page.ejs +64 -0
  95. package/sample/crud/apps/main/views/home.ejs +82 -0
  96. package/sample/crud/apps/main/views/jobs/index.ejs +113 -0
  97. package/sample/crud/apps/main/views/layouts/main.ejs +112 -0
  98. package/sample/crud/apps/main/views/logs/index.ejs +80 -0
  99. package/sample/crud/apps/main/views/metrics/index.ejs +123 -0
  100. package/sample/crud/apps/main/views/notes/edit.ejs +45 -0
  101. package/sample/crud/apps/main/views/notes/list.ejs +74 -0
  102. package/sample/crud/apps/main/views/notes/new.ejs +45 -0
  103. package/sample/crud/apps/main/views/perf/index.ejs +90 -0
  104. package/sample/crud/apps/main/views/redis/index.ejs +65 -0
  105. package/sample/crud/apps/main/views/tracing/index.ejs +106 -0
  106. package/sample/crud/apps/main/views/upload/index.ejs +79 -0
  107. package/sample/crud/apps/main/views/users/edit.ejs +48 -0
  108. package/sample/crud/apps/main/views/users/list.ejs +81 -0
  109. package/sample/crud/apps/main/views/users/new.ejs +48 -0
  110. package/sample/crud/apps/main/views/worker/index.ejs +70 -0
  111. package/sample/crud/apps/main/views/ws/index.ejs +62 -0
  112. package/sample/crud/apps/main/workers/hash-worker.js +17 -0
  113. package/sample/crud/apps/main/workers/hash.task.js +22 -0
  114. package/sample/crud/ecosystem.config.cjs +9 -0
  115. package/sample/crud/mega.config.js +105 -0
  116. package/sample/crud/package-lock.json +5665 -0
  117. package/sample/crud/package.json +28 -0
  118. package/sample/crud/test/apps/main/auth-flow.integration.test.js +177 -0
  119. package/sample/crud/test/apps/main/auth-service.test.js +93 -0
  120. package/sample/crud/test/apps/main/chat-bus.test.js +101 -0
  121. package/sample/crud/test/apps/main/chat-channel.test.js +144 -0
  122. package/sample/crud/test/apps/main/cron-demo-service.test.js +93 -0
  123. package/sample/crud/test/apps/main/demo-flow.integration.test.js +386 -0
  124. package/sample/crud/test/apps/main/email-job.test.js +76 -0
  125. package/sample/crud/test/apps/main/guide-service.test.js +68 -0
  126. package/sample/crud/test/apps/main/hash-task.test.js +30 -0
  127. package/sample/crud/test/apps/main/jobs-demo-service.test.js +88 -0
  128. package/sample/crud/test/apps/main/logs-demo-service.test.js +85 -0
  129. package/sample/crud/test/apps/main/metrics-demo-service.test.js +90 -0
  130. package/sample/crud/test/apps/main/note-service.test.js +68 -0
  131. package/sample/crud/test/apps/main/perf-service.test.js +121 -0
  132. package/sample/crud/test/apps/main/perf.integration.test.js +202 -0
  133. package/sample/crud/test/apps/main/redis-demo-service.test.js +98 -0
  134. package/sample/crud/test/apps/main/tracing-demo-service.test.js +90 -0
  135. package/sample/crud/test/apps/main/upload-demo-service.test.js +61 -0
  136. package/sample/crud/test/apps/main/user-service.test.js +65 -0
  137. package/sample/crud/test/apps/main/ws-chat.integration.test.js +232 -0
  138. package/sample/crud/vitest.config.js +8 -0
  139. package/sample/crud/yarn.lock +2142 -0
  140. package/sample/simple/.env.example +15 -0
  141. package/sample/simple/README.md +52 -0
  142. package/sample/simple/apps/main/app.config.js +35 -0
  143. package/sample/simple/apps/main/controllers/pages-controller.js +22 -0
  144. package/sample/simple/apps/main/locales/client/en.json +3 -0
  145. package/sample/simple/apps/main/locales/client/ko.json +3 -0
  146. package/sample/simple/apps/main/locales/server/en.json +23 -0
  147. package/sample/simple/apps/main/locales/server/ko.json +23 -0
  148. package/sample/simple/apps/main/public/css/app.css +101 -0
  149. package/sample/simple/apps/main/public/hello.txt +1 -0
  150. package/sample/simple/apps/main/public/js/app.js +54 -0
  151. package/sample/simple/apps/main/public/js/theme-init.js +12 -0
  152. package/sample/simple/apps/main/public/vendor/bootstrap/bootstrap.bundle.min.js +7 -0
  153. package/sample/simple/apps/main/public/vendor/bootstrap/bootstrap.min.css +6 -0
  154. package/sample/simple/apps/main/routes/index.js +9 -0
  155. package/sample/simple/apps/main/routes/pages.js +12 -0
  156. package/sample/simple/apps/main/views/index.ejs +56 -0
  157. package/sample/simple/apps/main/views/layouts/main.ejs +74 -0
  158. package/sample/simple/ecosystem.config.cjs +10 -0
  159. package/sample/simple/mega.config.js +27 -0
  160. package/sample/simple/package-lock.json +1851 -0
  161. package/sample/simple/package.json +25 -0
  162. package/sample/simple/test/apps/main/index.test.js +13 -0
  163. package/sample/simple/vitest.config.js +8 -0
  164. package/src/adapters/adapter-manager.js +305 -0
  165. package/src/adapters/adapter-options.js +208 -0
  166. package/src/adapters/file-adapter.js +350 -0
  167. package/src/adapters/file-session-adapter.js +363 -0
  168. package/src/adapters/index.js +38 -0
  169. package/src/adapters/maria-adapter.js +425 -0
  170. package/src/adapters/mega-adapter.js +511 -0
  171. package/src/adapters/mega-bus-adapter.js +81 -0
  172. package/src/adapters/mega-cache-adapter.js +94 -0
  173. package/src/adapters/mega-db-adapter.js +72 -0
  174. package/src/adapters/mega-lock-adapter.js +118 -0
  175. package/src/adapters/mega-log-sink-adapter.js +46 -0
  176. package/src/adapters/mega-session-adapter.js +72 -0
  177. package/src/adapters/mongo-adapter.js +396 -0
  178. package/src/adapters/nats-adapter.js +370 -0
  179. package/src/adapters/postgres-adapter.js +341 -0
  180. package/src/adapters/redis-adapter.js +331 -0
  181. package/src/adapters/redis-session-adapter.js +261 -0
  182. package/src/adapters/redlock-adapter.js +385 -0
  183. package/src/adapters/registry.js +157 -0
  184. package/src/adapters/sqlite-adapter.js +309 -0
  185. package/src/auth/index.js +103 -0
  186. package/src/cli/commands/console-cmd.js +56 -0
  187. package/src/cli/commands/new.js +101 -0
  188. package/src/cli/commands/routes.js +107 -0
  189. package/src/cli/commands/scaffold.js +120 -0
  190. package/src/cli/commands/test-cmd.js +45 -0
  191. package/src/cli/generators/index.js +368 -0
  192. package/src/cli/index.js +472 -0
  193. package/src/cli/template-engine.js +72 -0
  194. package/src/cli/ws-hub.js +582 -0
  195. package/src/core/ajv-mapper.js +80 -0
  196. package/src/core/boot.js +323 -0
  197. package/src/core/cluster-metrics.js +278 -0
  198. package/src/core/config-loader.js +115 -0
  199. package/src/core/config-validator.js +322 -0
  200. package/src/core/ctx-builder.js +253 -0
  201. package/src/core/envelope.js +88 -0
  202. package/src/core/error-mapper.js +116 -0
  203. package/src/core/formbody.js +69 -0
  204. package/src/core/hub-link.js +552 -0
  205. package/src/core/i18n.js +525 -0
  206. package/src/core/index.js +63 -0
  207. package/src/core/mega-app.js +1138 -0
  208. package/src/core/mega-cluster.js +232 -0
  209. package/src/core/mega-server.js +176 -0
  210. package/src/core/mega-service.js +41 -0
  211. package/src/core/migration-runner.js +196 -0
  212. package/src/core/multipart.js +282 -0
  213. package/src/core/openapi.js +114 -0
  214. package/src/core/router.js +388 -0
  215. package/src/core/routes-loader.js +57 -0
  216. package/src/core/scope-registry.js +53 -0
  217. package/src/core/security.js +275 -0
  218. package/src/core/services-loader.js +98 -0
  219. package/src/core/session-cleanup-schedule.js +57 -0
  220. package/src/core/session-store.js +55 -0
  221. package/src/core/session.js +414 -0
  222. package/src/core/static-assets.js +126 -0
  223. package/src/core/template.js +294 -0
  224. package/src/core/workers-manager.js +193 -0
  225. package/src/core/ws-compression.js +112 -0
  226. package/src/core/ws-controller.js +109 -0
  227. package/src/core/ws-message.js +176 -0
  228. package/src/core/ws-upgrade.js +445 -0
  229. package/src/errors/config-error.js +16 -0
  230. package/src/errors/http-errors.js +130 -0
  231. package/src/errors/index.js +19 -0
  232. package/src/errors/mega-error.js +34 -0
  233. package/src/eslint-plugin/index.js +15 -0
  234. package/src/eslint-plugin/no-direct-model-import.js +113 -0
  235. package/src/index.js +131 -0
  236. package/src/lib/asp/config.js +83 -0
  237. package/src/lib/asp/crypto.js +145 -0
  238. package/src/lib/asp/errors.js +49 -0
  239. package/src/lib/asp/nonce-cache.js +94 -0
  240. package/src/lib/asp/plugin.js +263 -0
  241. package/src/lib/asp/ws-terminator.js +101 -0
  242. package/src/lib/env-mapper.js +222 -0
  243. package/src/lib/hub-protocol.js +322 -0
  244. package/src/lib/index.js +42 -0
  245. package/src/lib/logger/telegram-core.js +150 -0
  246. package/src/lib/logger/telegram-transport.js +126 -0
  247. package/src/lib/mega-brute-force.js +225 -0
  248. package/src/lib/mega-circuit-breaker.js +412 -0
  249. package/src/lib/mega-cron.js +169 -0
  250. package/src/lib/mega-hash.js +179 -0
  251. package/src/lib/mega-health.js +91 -0
  252. package/src/lib/mega-job-queue.js +600 -0
  253. package/src/lib/mega-job-worker.js +295 -0
  254. package/src/lib/mega-job.js +140 -0
  255. package/src/lib/mega-logger.js +128 -0
  256. package/src/lib/mega-metrics.js +661 -0
  257. package/src/lib/mega-plugin.js +650 -0
  258. package/src/lib/mega-retry.js +95 -0
  259. package/src/lib/mega-schedule.js +507 -0
  260. package/src/lib/mega-shutdown.js +176 -0
  261. package/src/lib/mega-tracing.js +715 -0
  262. package/src/lib/mega-worker.js +653 -0
  263. package/src/lib/worker-runner/process-entry.js +30 -0
  264. package/src/lib/worker-runner/task-dispatch.js +72 -0
  265. package/src/lib/worker-runner/thread-entry.js +26 -0
  266. package/src/models/index.js +7 -0
  267. package/src/models/mega-model.js +151 -0
  268. package/src/test/index.js +288 -0
  269. package/templates/adapter/code.tpl +40 -0
  270. package/templates/adapter/test.tpl +13 -0
  271. package/templates/app/app.config.tpl +10 -0
  272. package/templates/app/route.tpl +10 -0
  273. package/templates/app/test.tpl +13 -0
  274. package/templates/channel/code.tpl +38 -0
  275. package/templates/channel/test.tpl +19 -0
  276. package/templates/controller/code.tpl +16 -0
  277. package/templates/controller/route.tpl +9 -0
  278. package/templates/controller/test.tpl +14 -0
  279. package/templates/job/code.tpl +23 -0
  280. package/templates/job/test.tpl +17 -0
  281. package/templates/locale/code.tpl +3 -0
  282. package/templates/locale/test.tpl +13 -0
  283. package/templates/middleware/code.tpl +13 -0
  284. package/templates/middleware/test.tpl +11 -0
  285. package/templates/migration/code.tpl +20 -0
  286. package/templates/migration/test.tpl +14 -0
  287. package/templates/model/code.tpl +21 -0
  288. package/templates/model/test.tpl +29 -0
  289. package/templates/project/app.config.tpl +8 -0
  290. package/templates/project/app.config.views.tpl +37 -0
  291. package/templates/project/ecosystem.config.tpl +10 -0
  292. package/templates/project/env.tpl +12 -0
  293. package/templates/project/gitignore.tpl +8 -0
  294. package/templates/project/locales/client/en.json.tpl +3 -0
  295. package/templates/project/locales/client/ko.json.tpl +3 -0
  296. package/templates/project/locales/server/en.json.tpl +17 -0
  297. package/templates/project/locales/server/ko.json.tpl +17 -0
  298. package/templates/project/mega.config.tpl +11 -0
  299. package/templates/project/package.tpl +25 -0
  300. package/templates/project/public/css/app.css +101 -0
  301. package/templates/project/public/js/app.js +54 -0
  302. package/templates/project/public/js/theme-init.js +12 -0
  303. package/templates/project/public/vendor/bootstrap/bootstrap.bundle.min.js +7 -0
  304. package/templates/project/public/vendor/bootstrap/bootstrap.min.css +6 -0
  305. package/templates/project/readme.tpl +48 -0
  306. package/templates/project/route.test.tpl +13 -0
  307. package/templates/project/route.test.views.tpl +15 -0
  308. package/templates/project/route.tpl +10 -0
  309. package/templates/project/route.views.tpl +10 -0
  310. package/templates/project/views/index.ejs.tpl +58 -0
  311. package/templates/project/views/layout.ejs.tpl +73 -0
  312. package/templates/project/vitest.config.tpl +8 -0
  313. package/templates/route/code.tpl +11 -0
  314. package/templates/route/test.tpl +26 -0
  315. package/templates/schedule/code.tpl +19 -0
  316. package/templates/schedule/test.tpl +17 -0
  317. package/templates/service/code.tpl +18 -0
  318. package/templates/service/test.tpl +17 -0
  319. package/templates/worker/code.tpl +14 -0
  320. package/templates/worker/task.tpl +13 -0
  321. package/templates/worker/test.tpl +18 -0
  322. package/vitest.config.js +33 -0
@@ -0,0 +1,1187 @@
1
+ /* @ts-self-types="./mega_client_wasm.d.ts" */
2
+
3
+ /**
4
+ * ASP HTTP REST 클라이언트. 브라우저 `window.fetch` 위에 ASP 암/복호화 파이프라인.
5
+ */
6
+ export class MegaClient {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ MegaClientFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_megaclient_free(ptr, 0);
16
+ }
17
+ /**
18
+ * DELETE.
19
+ * @param {string} path
20
+ * @param {any} opts
21
+ * @returns {Promise<any>}
22
+ */
23
+ delete(path, opts) {
24
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
25
+ const len0 = WASM_VECTOR_LEN;
26
+ const ret = wasm.megaclient_delete(this.__wbg_ptr, ptr0, len0, addHeapObject(opts));
27
+ return takeObject(ret);
28
+ }
29
+ /**
30
+ * GET. `opts.encrypt` 로 호출별 오버라이드 (디폴트 = 클라이언트 설정).
31
+ * @param {string} path
32
+ * @param {any} opts
33
+ * @returns {Promise<any>}
34
+ */
35
+ get(path, opts) {
36
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
37
+ const len0 = WASM_VECTOR_LEN;
38
+ const ret = wasm.megaclient_get(this.__wbg_ptr, ptr0, len0, addHeapObject(opts));
39
+ return takeObject(ret);
40
+ }
41
+ /**
42
+ * ASP 시그널 헤더 이름 반환.
43
+ * @returns {string}
44
+ */
45
+ getHeaderSignal() {
46
+ let deferred1_0;
47
+ let deferred1_1;
48
+ try {
49
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
50
+ wasm.megaclient_getHeaderSignal(retptr, this.__wbg_ptr);
51
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
52
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
53
+ deferred1_0 = r0;
54
+ deferred1_1 = r1;
55
+ return getStringFromWasm0(r0, r1);
56
+ } finally {
57
+ wasm.__wbindgen_add_to_stack_pointer(16);
58
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
59
+ }
60
+ }
61
+ /**
62
+ * 클라이언트 생성.
63
+ *
64
+ * `opts = { encrypt?: boolean, headerSignal?: string }`.
65
+ * `encrypt` 디폴트 `true` (ADR-086), `headerSignal` 디폴트 `"X-Mega-Encrypted"`.
66
+ * @param {string} master_secret
67
+ * @param {any} opts
68
+ */
69
+ constructor(master_secret, opts) {
70
+ try {
71
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
72
+ const ptr0 = passStringToWasm0(master_secret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
73
+ const len0 = WASM_VECTOR_LEN;
74
+ wasm.megaclient_new(retptr, ptr0, len0, addHeapObject(opts));
75
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
76
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
77
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
78
+ if (r2) {
79
+ throw takeObject(r1);
80
+ }
81
+ this.__wbg_ptr = r0;
82
+ MegaClientFinalization.register(this, this.__wbg_ptr, this);
83
+ return this;
84
+ } finally {
85
+ wasm.__wbindgen_add_to_stack_pointer(16);
86
+ }
87
+ }
88
+ /**
89
+ * PATCH.
90
+ * @param {string} path
91
+ * @param {any} body
92
+ * @param {any} opts
93
+ * @returns {Promise<any>}
94
+ */
95
+ patch(path, body, opts) {
96
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
97
+ const len0 = WASM_VECTOR_LEN;
98
+ const ret = wasm.megaclient_patch(this.__wbg_ptr, ptr0, len0, addHeapObject(body), addHeapObject(opts));
99
+ return takeObject(ret);
100
+ }
101
+ /**
102
+ * POST. body 는 JS 객체 (JSON 직렬화됨).
103
+ * @param {string} path
104
+ * @param {any} body
105
+ * @param {any} opts
106
+ * @returns {Promise<any>}
107
+ */
108
+ post(path, body, opts) {
109
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
110
+ const len0 = WASM_VECTOR_LEN;
111
+ const ret = wasm.megaclient_post(this.__wbg_ptr, ptr0, len0, addHeapObject(body), addHeapObject(opts));
112
+ return takeObject(ret);
113
+ }
114
+ /**
115
+ * PUT.
116
+ * @param {string} path
117
+ * @param {any} body
118
+ * @param {any} opts
119
+ * @returns {Promise<any>}
120
+ */
121
+ put(path, body, opts) {
122
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ const ret = wasm.megaclient_put(this.__wbg_ptr, ptr0, len0, addHeapObject(body), addHeapObject(opts));
125
+ return takeObject(ret);
126
+ }
127
+ /**
128
+ * FormData 파일 업로드.
129
+ *
130
+ * FormData body 는 바이너리이므로 암호화하지 않고 `X-Timestamp` 만 부착 (ASP 게이트 통과).
131
+ * 응답은 서버가 ASP 암호화하므로 시그널 헤더 확인 후 복호화.
132
+ * @param {string} path
133
+ * @param {FormData} form_data
134
+ * @returns {Promise<any>}
135
+ */
136
+ upload(path, form_data) {
137
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
138
+ const len0 = WASM_VECTOR_LEN;
139
+ const ret = wasm.megaclient_upload(this.__wbg_ptr, ptr0, len0, addHeapObject(form_data));
140
+ return takeObject(ret);
141
+ }
142
+ }
143
+ if (Symbol.dispose) MegaClient.prototype[Symbol.dispose] = MegaClient.prototype.free;
144
+
145
+ /**
146
+ * 📡 MegaSocket — ASP WebSocket 클라이언트.
147
+ */
148
+ export class MegaSocket {
149
+ __destroy_into_raw() {
150
+ const ptr = this.__wbg_ptr;
151
+ this.__wbg_ptr = 0;
152
+ MegaSocketFinalization.unregister(this);
153
+ return ptr;
154
+ }
155
+ free() {
156
+ const ptr = this.__destroy_into_raw();
157
+ wasm.__wbg_megasocket_free(ptr, 0);
158
+ }
159
+ /**
160
+ * 서버 연결. 본 연결·재연결 모두 [`open_socket`] 단일 경로 (ADR-085 d).
161
+ */
162
+ connect() {
163
+ try {
164
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
165
+ wasm.megasocket_connect(retptr, this.__wbg_ptr);
166
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
167
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
168
+ if (r1) {
169
+ throw takeObject(r0);
170
+ }
171
+ } finally {
172
+ wasm.__wbindgen_add_to_stack_pointer(16);
173
+ }
174
+ }
175
+ /**
176
+ * 명시적 연결 종료 (재연결 안 함).
177
+ */
178
+ disconnect() {
179
+ wasm.megasocket_disconnect(this.__wbg_ptr);
180
+ }
181
+ /**
182
+ * 연결 상태 확인.
183
+ * @returns {boolean}
184
+ */
185
+ isConnected() {
186
+ const ret = wasm.megasocket_isConnected(this.__wbg_ptr);
187
+ return ret !== 0;
188
+ }
189
+ /**
190
+ * 생성자.
191
+ *
192
+ * `opts = { encrypt?: boolean, protocol?: "event" | "envelope" }`.
193
+ * - `encrypt` 디폴트 `true` (ADR-086).
194
+ * - `protocol` 디폴트 `"event"` — 송수신 wire 가 `{type,data}`(하위호환). `"envelope"` 면 프레임워크
195
+ * WS 서버 정본 envelope `{v,id,type,ts,payload}`(ADR-015)로 송수신해 `/ws/*` 라우트와 정합한다(ADR-160).
196
+ *
197
+ * `domain` / `ws_path` 는 URL 에서, `ua` 는 브라우저에서 추출.
198
+ * @param {string} url
199
+ * @param {string} master_secret
200
+ * @param {any} opts
201
+ */
202
+ constructor(url, master_secret, opts) {
203
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
204
+ const len0 = WASM_VECTOR_LEN;
205
+ const ptr1 = passStringToWasm0(master_secret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
206
+ const len1 = WASM_VECTOR_LEN;
207
+ const ret = wasm.megasocket_new(ptr0, len0, ptr1, len1, addHeapObject(opts));
208
+ this.__wbg_ptr = ret;
209
+ MegaSocketFinalization.register(this, this.__wbg_ptr, this);
210
+ return this;
211
+ }
212
+ /**
213
+ * 이벤트 핸들러 등록.
214
+ * @param {string} event_type
215
+ * @param {Function} callback
216
+ */
217
+ on(event_type, callback) {
218
+ const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
219
+ const len0 = WASM_VECTOR_LEN;
220
+ wasm.megasocket_on(this.__wbg_ptr, ptr0, len0, addHeapObject(callback));
221
+ }
222
+ /**
223
+ * 이벤트 기반 메시지 전송.
224
+ *
225
+ * `opts = { plain?: boolean }`. `encrypt && !plain` 이면 `E:` 프레임, 그 외 `P:` 평문.
226
+ * wire 형식은 생성자 `protocol` 모드를 따른다(`event`={type,data} / `envelope`={v,id,type,ts,payload}, ADR-160).
227
+ * @param {string} event_type
228
+ * @param {any} data
229
+ * @param {any} opts
230
+ */
231
+ send(event_type, data, opts) {
232
+ try {
233
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
234
+ const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ wasm.megasocket_send(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(data), addHeapObject(opts));
237
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
238
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
239
+ if (r1) {
240
+ throw takeObject(r0);
241
+ }
242
+ } finally {
243
+ wasm.__wbindgen_add_to_stack_pointer(16);
244
+ }
245
+ }
246
+ /**
247
+ * 자동 재연결 on/off (다음 connect 부터 반영).
248
+ * @param {boolean} enabled
249
+ */
250
+ setAutoReconnect(enabled) {
251
+ wasm.megasocket_setAutoReconnect(this.__wbg_ptr, enabled);
252
+ }
253
+ /**
254
+ * 최대 재연결 시도 횟수 설정.
255
+ * @param {number} count
256
+ */
257
+ setMaxReconnectAttempts(count) {
258
+ wasm.megasocket_setMaxReconnectAttempts(this.__wbg_ptr, count);
259
+ }
260
+ /**
261
+ * Ping 주기(ms) 설정.
262
+ * @param {number} ms
263
+ */
264
+ setPingInterval(ms) {
265
+ wasm.megasocket_setPingInterval(this.__wbg_ptr, ms);
266
+ }
267
+ }
268
+ if (Symbol.dispose) MegaSocket.prototype[Symbol.dispose] = MegaSocket.prototype.free;
269
+
270
+ /**
271
+ * 브라우저 WASM 유틸리티 (정적 메서드 모음).
272
+ */
273
+ export class MegaUtil {
274
+ __destroy_into_raw() {
275
+ const ptr = this.__wbg_ptr;
276
+ this.__wbg_ptr = 0;
277
+ MegaUtilFinalization.unregister(this);
278
+ return ptr;
279
+ }
280
+ free() {
281
+ const ptr = this.__destroy_into_raw();
282
+ wasm.__wbg_megautil_free(ptr, 0);
283
+ }
284
+ /**
285
+ * 임계값 초과 필터.
286
+ * @param {Int32Array} list
287
+ * @param {number} threshold
288
+ * @returns {Int32Array}
289
+ */
290
+ static filterGt(list, threshold) {
291
+ try {
292
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
293
+ const ptr0 = passArray32ToWasm0(list, wasm.__wbindgen_export);
294
+ const len0 = WASM_VECTOR_LEN;
295
+ wasm.megautil_filterGt(retptr, ptr0, len0, threshold);
296
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
297
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
298
+ var v2 = getArrayI32FromWasm0(r0, r1).slice();
299
+ wasm.__wbindgen_export5(r0, r1 * 4, 4);
300
+ return v2;
301
+ } finally {
302
+ wasm.__wbindgen_add_to_stack_pointer(16);
303
+ }
304
+ }
305
+ /**
306
+ * SHA-256 해시 (hex 64자).
307
+ * @param {string} input
308
+ * @returns {string}
309
+ */
310
+ static sha256(input) {
311
+ let deferred2_0;
312
+ let deferred2_1;
313
+ try {
314
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
315
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
316
+ const len0 = WASM_VECTOR_LEN;
317
+ wasm.megautil_sha256(retptr, ptr0, len0);
318
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
319
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
320
+ deferred2_0 = r0;
321
+ deferred2_1 = r1;
322
+ return getStringFromWasm0(r0, r1);
323
+ } finally {
324
+ wasm.__wbindgen_add_to_stack_pointer(16);
325
+ wasm.__wbindgen_export5(deferred2_0, deferred2_1, 1);
326
+ }
327
+ }
328
+ /**
329
+ * Fisher-Yates 셔플 — JS `sort(() => 0.5 - Math.random())` 대비 균등 분포 + 고속.
330
+ * @param {Int32Array} list
331
+ * @returns {Int32Array}
332
+ */
333
+ static shuffleI32(list) {
334
+ try {
335
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
336
+ const ptr0 = passArray32ToWasm0(list, wasm.__wbindgen_export);
337
+ const len0 = WASM_VECTOR_LEN;
338
+ wasm.megautil_shuffleI32(retptr, ptr0, len0);
339
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
340
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
341
+ var v2 = getArrayI32FromWasm0(r0, r1).slice();
342
+ wasm.__wbindgen_export5(r0, r1 * 4, 4);
343
+ return v2;
344
+ } finally {
345
+ wasm.__wbindgen_add_to_stack_pointer(16);
346
+ }
347
+ }
348
+ /**
349
+ * 고속 정렬 (unstable — 동일 값 순서 미보장, 대신 빠름).
350
+ * @param {Int32Array} list
351
+ * @returns {Int32Array}
352
+ */
353
+ static sortI32(list) {
354
+ try {
355
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
356
+ const ptr0 = passArray32ToWasm0(list, wasm.__wbindgen_export);
357
+ const len0 = WASM_VECTOR_LEN;
358
+ wasm.megautil_sortI32(retptr, ptr0, len0);
359
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
360
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
361
+ var v2 = getArrayI32FromWasm0(r0, r1).slice();
362
+ wasm.__wbindgen_export5(r0, r1 * 4, 4);
363
+ return v2;
364
+ } finally {
365
+ wasm.__wbindgen_add_to_stack_pointer(16);
366
+ }
367
+ }
368
+ /**
369
+ * UUID v4 생성 (getrandom 기반 — 신규 crate 의존 없음).
370
+ * @returns {string}
371
+ */
372
+ static uuid() {
373
+ let deferred1_0;
374
+ let deferred1_1;
375
+ try {
376
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
377
+ wasm.megautil_uuid(retptr);
378
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
379
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
380
+ deferred1_0 = r0;
381
+ deferred1_1 = r1;
382
+ return getStringFromWasm0(r0, r1);
383
+ } finally {
384
+ wasm.__wbindgen_add_to_stack_pointer(16);
385
+ wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
386
+ }
387
+ }
388
+ }
389
+ if (Symbol.dispose) MegaUtil.prototype[Symbol.dispose] = MegaUtil.prototype.free;
390
+ function __wbg_get_imports() {
391
+ const import0 = {
392
+ __proto__: null,
393
+ __wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
394
+ const v = getObject(arg0);
395
+ const ret = typeof(v) === 'boolean' ? v : undefined;
396
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
397
+ },
398
+ __wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
399
+ const ret = debugString(getObject(arg1));
400
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
401
+ const len1 = WASM_VECTOR_LEN;
402
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
403
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
404
+ },
405
+ __wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
406
+ const ret = typeof(getObject(arg0)) === 'function';
407
+ return ret;
408
+ },
409
+ __wbg___wbindgen_is_null_87c3bfe968c6a5ad: function(arg0) {
410
+ const ret = getObject(arg0) === null;
411
+ return ret;
412
+ },
413
+ __wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
414
+ const val = getObject(arg0);
415
+ const ret = typeof(val) === 'object' && val !== null;
416
+ return ret;
417
+ },
418
+ __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
419
+ const ret = typeof(getObject(arg0)) === 'string';
420
+ return ret;
421
+ },
422
+ __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
423
+ const ret = getObject(arg0) === undefined;
424
+ return ret;
425
+ },
426
+ __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
427
+ const obj = getObject(arg1);
428
+ const ret = typeof(obj) === 'string' ? obj : undefined;
429
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
430
+ var len1 = WASM_VECTOR_LEN;
431
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
432
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
433
+ },
434
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
435
+ throw new Error(getStringFromWasm0(arg0, arg1));
436
+ },
437
+ __wbg__wbg_cb_unref_61db23ac97f16c31: function(arg0) {
438
+ getObject(arg0)._wbg_cb_unref();
439
+ },
440
+ __wbg_apply_292b6d94e4f92b15: function() { return handleError(function (arg0, arg1, arg2) {
441
+ const ret = getObject(arg0).apply(getObject(arg1), getObject(arg2));
442
+ return addHeapObject(ret);
443
+ }, arguments); },
444
+ __wbg_call_9c758de292015997: function() { return handleError(function (arg0, arg1, arg2) {
445
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
446
+ return addHeapObject(ret);
447
+ }, arguments); },
448
+ __wbg_clearInterval_dd698b7aa355fbe4: function(arg0, arg1) {
449
+ getObject(arg0).clearInterval(arg1);
450
+ },
451
+ __wbg_clearTimeout_4f7dad1647aa1690: function(arg0, arg1) {
452
+ getObject(arg0).clearTimeout(arg1);
453
+ },
454
+ __wbg_close_b3889a2dd025cb33: function() { return handleError(function (arg0, arg1) {
455
+ getObject(arg0).close(arg1);
456
+ }, arguments); },
457
+ __wbg_code_27a1f220ebdc7c36: function(arg0) {
458
+ const ret = getObject(arg0).code;
459
+ return ret;
460
+ },
461
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
462
+ const ret = getObject(arg0).crypto;
463
+ return addHeapObject(ret);
464
+ },
465
+ __wbg_data_bd354b70c783c66e: function(arg0) {
466
+ const ret = getObject(arg0).data;
467
+ return addHeapObject(ret);
468
+ },
469
+ __wbg_debug_78b457f1effb3792: function(arg0) {
470
+ console.debug(getObject(arg0));
471
+ },
472
+ __wbg_error_78ff5b3a29b770e0: function(arg0) {
473
+ console.error(getObject(arg0));
474
+ },
475
+ __wbg_fetch_ce1af4d1b59a60be: function(arg0, arg1) {
476
+ const ret = getObject(arg0).fetch(getObject(arg1));
477
+ return addHeapObject(ret);
478
+ },
479
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
480
+ getObject(arg0).getRandomValues(getObject(arg1));
481
+ }, arguments); },
482
+ __wbg_get_0d06c4d815368a19: function() { return handleError(function (arg0, arg1, arg2, arg3) {
483
+ const ret = getObject(arg1).get(getStringFromWasm0(arg2, arg3));
484
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
485
+ var len1 = WASM_VECTOR_LEN;
486
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
487
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
488
+ }, arguments); },
489
+ __wbg_get_de6a0f7d4d18a304: function() { return handleError(function (arg0, arg1) {
490
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
491
+ return addHeapObject(ret);
492
+ }, arguments); },
493
+ __wbg_headers_0feb63d2d374b44a: function(arg0) {
494
+ const ret = getObject(arg0).headers;
495
+ return addHeapObject(ret);
496
+ },
497
+ __wbg_hostname_311e2a4c6de4f6fc: function() { return handleError(function (arg0, arg1) {
498
+ const ret = getObject(arg1).hostname;
499
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
500
+ const len1 = WASM_VECTOR_LEN;
501
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
502
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
503
+ }, arguments); },
504
+ __wbg_instanceof_Response_cb984bd66d7bd408: function(arg0) {
505
+ let result;
506
+ try {
507
+ result = getObject(arg0) instanceof Response;
508
+ } catch (_) {
509
+ result = false;
510
+ }
511
+ const ret = result;
512
+ return ret;
513
+ },
514
+ __wbg_instanceof_Window_e093be59ee9a8e14: function(arg0) {
515
+ let result;
516
+ try {
517
+ result = getObject(arg0) instanceof Window;
518
+ } catch (_) {
519
+ result = false;
520
+ }
521
+ const ret = result;
522
+ return ret;
523
+ },
524
+ __wbg_length_4a591ecaa01354d9: function(arg0) {
525
+ const ret = getObject(arg0).length;
526
+ return ret;
527
+ },
528
+ __wbg_location_efdf1fea18b5552a: function(arg0) {
529
+ const ret = getObject(arg0).location;
530
+ return addHeapObject(ret);
531
+ },
532
+ __wbg_log_cf2e968649f3384e: function(arg0) {
533
+ console.log(getObject(arg0));
534
+ },
535
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
536
+ const ret = getObject(arg0).msCrypto;
537
+ return addHeapObject(ret);
538
+ },
539
+ __wbg_navigator_3833ecdbc19d2757: function(arg0) {
540
+ const ret = getObject(arg0).navigator;
541
+ return addHeapObject(ret);
542
+ },
543
+ __wbg_new_ce1ab61c1c2b300d: function() {
544
+ const ret = new Object();
545
+ return addHeapObject(ret);
546
+ },
547
+ __wbg_new_d7e476b433a26bea: function() { return handleError(function (arg0, arg1) {
548
+ const ret = new WebSocket(getStringFromWasm0(arg0, arg1));
549
+ return addHeapObject(ret);
550
+ }, arguments); },
551
+ __wbg_new_d90091b82fdf5b91: function() {
552
+ const ret = new Array();
553
+ return addHeapObject(ret);
554
+ },
555
+ __wbg_new_e436d06bc8e77460: function() { return handleError(function () {
556
+ const ret = new Headers();
557
+ return addHeapObject(ret);
558
+ }, arguments); },
559
+ __wbg_new_typed_bf31d18f92484486: function(arg0, arg1) {
560
+ try {
561
+ var state0 = {a: arg0, b: arg1};
562
+ var cb0 = (arg0, arg1) => {
563
+ const a = state0.a;
564
+ state0.a = 0;
565
+ try {
566
+ return __wasm_bindgen_func_elem_769(a, state0.b, arg0, arg1);
567
+ } finally {
568
+ state0.a = a;
569
+ }
570
+ };
571
+ const ret = new Promise(cb0);
572
+ return addHeapObject(ret);
573
+ } finally {
574
+ state0.a = 0;
575
+ }
576
+ },
577
+ __wbg_new_with_length_36a4998e27b014c5: function(arg0) {
578
+ const ret = new Uint8Array(arg0 >>> 0);
579
+ return addHeapObject(ret);
580
+ },
581
+ __wbg_new_with_str_and_init_bcd02b79a793d27f: function() { return handleError(function (arg0, arg1, arg2) {
582
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
583
+ return addHeapObject(ret);
584
+ }, arguments); },
585
+ __wbg_node_84ea875411254db1: function(arg0) {
586
+ const ret = getObject(arg0).node;
587
+ return addHeapObject(ret);
588
+ },
589
+ __wbg_now_190933fa139cc119: function() {
590
+ const ret = Date.now();
591
+ return ret;
592
+ },
593
+ __wbg_parse_03863847d06c4e89: function() { return handleError(function (arg0, arg1) {
594
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
595
+ return addHeapObject(ret);
596
+ }, arguments); },
597
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
598
+ const ret = getObject(arg0).process;
599
+ return addHeapObject(ret);
600
+ },
601
+ __wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
602
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
603
+ },
604
+ __wbg_push_a6822215aa43e71c: function(arg0, arg1) {
605
+ const ret = getObject(arg0).push(getObject(arg1));
606
+ return ret;
607
+ },
608
+ __wbg_queueMicrotask_35c611f4a14830b2: function(arg0) {
609
+ queueMicrotask(getObject(arg0));
610
+ },
611
+ __wbg_queueMicrotask_404ed0a58e0b63cc: function(arg0) {
612
+ const ret = getObject(arg0).queueMicrotask;
613
+ return addHeapObject(ret);
614
+ },
615
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
616
+ getObject(arg0).randomFillSync(takeObject(arg1));
617
+ }, arguments); },
618
+ __wbg_readyState_490503c1fa8f8dd6: function(arg0) {
619
+ const ret = getObject(arg0).readyState;
620
+ return ret;
621
+ },
622
+ __wbg_reason_4624d424a130e5b2: function(arg0, arg1) {
623
+ const ret = getObject(arg1).reason;
624
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
625
+ const len1 = WASM_VECTOR_LEN;
626
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
627
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
628
+ },
629
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
630
+ const ret = module.require;
631
+ return addHeapObject(ret);
632
+ }, arguments); },
633
+ __wbg_resolve_25a7e548d5881dca: function(arg0) {
634
+ const ret = Promise.resolve(getObject(arg0));
635
+ return addHeapObject(ret);
636
+ },
637
+ __wbg_send_35647f35f8bdac5d: function() { return handleError(function (arg0, arg1, arg2) {
638
+ getObject(arg0).send(getStringFromWasm0(arg1, arg2));
639
+ }, arguments); },
640
+ __wbg_setInterval_ae27514ca815a798: function() { return handleError(function (arg0, arg1, arg2) {
641
+ const ret = getObject(arg0).setInterval(getObject(arg1), arg2);
642
+ return ret;
643
+ }, arguments); },
644
+ __wbg_setTimeout_b5f25e402b6e8ff9: function() { return handleError(function (arg0, arg1, arg2) {
645
+ const ret = getObject(arg0).setTimeout(getObject(arg1), arg2);
646
+ return ret;
647
+ }, arguments); },
648
+ __wbg_set_25ef40a9aeff260d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
649
+ getObject(arg0).set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
650
+ }, arguments); },
651
+ __wbg_set_6e30c9374c26414c: function() { return handleError(function (arg0, arg1, arg2) {
652
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
653
+ return ret;
654
+ }, arguments); },
655
+ __wbg_set_binaryType_41994c453b95bdd2: function(arg0, arg1) {
656
+ getObject(arg0).binaryType = __wbindgen_enum_BinaryType[arg1];
657
+ },
658
+ __wbg_set_body_36614c7e61546809: function(arg0, arg1) {
659
+ getObject(arg0).body = getObject(arg1);
660
+ },
661
+ __wbg_set_credentials_fa9c491a27c4bdf0: function(arg0, arg1) {
662
+ getObject(arg0).credentials = __wbindgen_enum_RequestCredentials[arg1];
663
+ },
664
+ __wbg_set_headers_7c1e39ece7826bec: function(arg0, arg1) {
665
+ getObject(arg0).headers = getObject(arg1);
666
+ },
667
+ __wbg_set_method_7a6811dec7a4feff: function(arg0, arg1, arg2) {
668
+ getObject(arg0).method = getStringFromWasm0(arg1, arg2);
669
+ },
670
+ __wbg_set_mode_c90e3667002857d4: function(arg0, arg1) {
671
+ getObject(arg0).mode = __wbindgen_enum_RequestMode[arg1];
672
+ },
673
+ __wbg_set_onclose_13787fb31ae8aefd: function(arg0, arg1) {
674
+ getObject(arg0).onclose = getObject(arg1);
675
+ },
676
+ __wbg_set_onerror_5a45265839edf1b1: function(arg0, arg1) {
677
+ getObject(arg0).onerror = getObject(arg1);
678
+ },
679
+ __wbg_set_onmessage_9c6b4cb14e244b7f: function(arg0, arg1) {
680
+ getObject(arg0).onmessage = getObject(arg1);
681
+ },
682
+ __wbg_set_onopen_db452f4233e99d7d: function(arg0, arg1) {
683
+ getObject(arg0).onopen = getObject(arg1);
684
+ },
685
+ __wbg_static_accessor_GLOBAL_9d53f2689e622ca1: function() {
686
+ const ret = typeof global === 'undefined' ? null : global;
687
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
688
+ },
689
+ __wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a: function() {
690
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
691
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
692
+ },
693
+ __wbg_static_accessor_SELF_4c59f6c7ea29a144: function() {
694
+ const ret = typeof self === 'undefined' ? null : self;
695
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
696
+ },
697
+ __wbg_static_accessor_WINDOW_e70ae9f2eb052253: function() {
698
+ const ret = typeof window === 'undefined' ? null : window;
699
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
700
+ },
701
+ __wbg_stringify_8286df6dcc591521: function() { return handleError(function (arg0) {
702
+ const ret = JSON.stringify(getObject(arg0));
703
+ return addHeapObject(ret);
704
+ }, arguments); },
705
+ __wbg_subarray_4aa221f6a4f5ab22: function(arg0, arg1, arg2) {
706
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
707
+ return addHeapObject(ret);
708
+ },
709
+ __wbg_text_a17febec76d36501: function() { return handleError(function (arg0) {
710
+ const ret = getObject(arg0).text();
711
+ return addHeapObject(ret);
712
+ }, arguments); },
713
+ __wbg_then_18f476d590e58992: function(arg0, arg1, arg2) {
714
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
715
+ return addHeapObject(ret);
716
+ },
717
+ __wbg_then_ac7b025999b52837: function(arg0, arg1) {
718
+ const ret = getObject(arg0).then(getObject(arg1));
719
+ return addHeapObject(ret);
720
+ },
721
+ __wbg_userAgent_8def8135d886414b: function() { return handleError(function (arg0, arg1) {
722
+ const ret = getObject(arg1).userAgent;
723
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
724
+ const len1 = WASM_VECTOR_LEN;
725
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
726
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
727
+ }, arguments); },
728
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
729
+ const ret = getObject(arg0).versions;
730
+ return addHeapObject(ret);
731
+ },
732
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
733
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 102, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
734
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_761);
735
+ return addHeapObject(ret);
736
+ },
737
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
738
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 1, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
739
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_144);
740
+ return addHeapObject(ret);
741
+ },
742
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
743
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 1, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
744
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_144_2);
745
+ return addHeapObject(ret);
746
+ },
747
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
748
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 1, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
749
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_144_3);
750
+ return addHeapObject(ret);
751
+ },
752
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
753
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 2, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
754
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_143);
755
+ return addHeapObject(ret);
756
+ },
757
+ __wbindgen_cast_0000000000000006: function(arg0) {
758
+ // Cast intrinsic for `F64 -> Externref`.
759
+ const ret = arg0;
760
+ return addHeapObject(ret);
761
+ },
762
+ __wbindgen_cast_0000000000000007: function(arg0, arg1) {
763
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
764
+ const ret = getArrayU8FromWasm0(arg0, arg1);
765
+ return addHeapObject(ret);
766
+ },
767
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
768
+ // Cast intrinsic for `Ref(String) -> Externref`.
769
+ const ret = getStringFromWasm0(arg0, arg1);
770
+ return addHeapObject(ret);
771
+ },
772
+ __wbindgen_object_clone_ref: function(arg0) {
773
+ const ret = getObject(arg0);
774
+ return addHeapObject(ret);
775
+ },
776
+ __wbindgen_object_drop_ref: function(arg0) {
777
+ takeObject(arg0);
778
+ },
779
+ };
780
+ return {
781
+ __proto__: null,
782
+ "./mega_client_wasm_bg.js": import0,
783
+ };
784
+ }
785
+
786
+ function __wasm_bindgen_func_elem_143(arg0, arg1) {
787
+ wasm.__wasm_bindgen_func_elem_143(arg0, arg1);
788
+ }
789
+
790
+ function __wasm_bindgen_func_elem_144(arg0, arg1, arg2) {
791
+ wasm.__wasm_bindgen_func_elem_144(arg0, arg1, addHeapObject(arg2));
792
+ }
793
+
794
+ function __wasm_bindgen_func_elem_144_2(arg0, arg1, arg2) {
795
+ wasm.__wasm_bindgen_func_elem_144_2(arg0, arg1, addHeapObject(arg2));
796
+ }
797
+
798
+ function __wasm_bindgen_func_elem_144_3(arg0, arg1, arg2) {
799
+ wasm.__wasm_bindgen_func_elem_144_3(arg0, arg1, addHeapObject(arg2));
800
+ }
801
+
802
+ function __wasm_bindgen_func_elem_761(arg0, arg1, arg2) {
803
+ try {
804
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
805
+ wasm.__wasm_bindgen_func_elem_761(retptr, arg0, arg1, addHeapObject(arg2));
806
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
807
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
808
+ if (r1) {
809
+ throw takeObject(r0);
810
+ }
811
+ } finally {
812
+ wasm.__wbindgen_add_to_stack_pointer(16);
813
+ }
814
+ }
815
+
816
+ function __wasm_bindgen_func_elem_769(arg0, arg1, arg2, arg3) {
817
+ wasm.__wasm_bindgen_func_elem_769(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
818
+ }
819
+
820
+
821
+ const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
822
+
823
+
824
+ const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
825
+
826
+
827
+ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
828
+ const MegaClientFinalization = (typeof FinalizationRegistry === 'undefined')
829
+ ? { register: () => {}, unregister: () => {} }
830
+ : new FinalizationRegistry(ptr => wasm.__wbg_megaclient_free(ptr, 1));
831
+ const MegaSocketFinalization = (typeof FinalizationRegistry === 'undefined')
832
+ ? { register: () => {}, unregister: () => {} }
833
+ : new FinalizationRegistry(ptr => wasm.__wbg_megasocket_free(ptr, 1));
834
+ const MegaUtilFinalization = (typeof FinalizationRegistry === 'undefined')
835
+ ? { register: () => {}, unregister: () => {} }
836
+ : new FinalizationRegistry(ptr => wasm.__wbg_megautil_free(ptr, 1));
837
+
838
+ function addHeapObject(obj) {
839
+ if (heap_next === heap.length) heap.push(heap.length + 1);
840
+ const idx = heap_next;
841
+ heap_next = heap[idx];
842
+
843
+ heap[idx] = obj;
844
+ return idx;
845
+ }
846
+
847
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
848
+ ? { register: () => {}, unregister: () => {} }
849
+ : new FinalizationRegistry(state => wasm.__wbindgen_export4(state.a, state.b));
850
+
851
+ function debugString(val) {
852
+ // primitive types
853
+ const type = typeof val;
854
+ if (type == 'number' || type == 'boolean' || val == null) {
855
+ return `${val}`;
856
+ }
857
+ if (type == 'string') {
858
+ return `"${val}"`;
859
+ }
860
+ if (type == 'symbol') {
861
+ const description = val.description;
862
+ if (description == null) {
863
+ return 'Symbol';
864
+ } else {
865
+ return `Symbol(${description})`;
866
+ }
867
+ }
868
+ if (type == 'function') {
869
+ const name = val.name;
870
+ if (typeof name == 'string' && name.length > 0) {
871
+ return `Function(${name})`;
872
+ } else {
873
+ return 'Function';
874
+ }
875
+ }
876
+ // objects
877
+ if (Array.isArray(val)) {
878
+ const length = val.length;
879
+ let debug = '[';
880
+ if (length > 0) {
881
+ debug += debugString(val[0]);
882
+ }
883
+ for(let i = 1; i < length; i++) {
884
+ debug += ', ' + debugString(val[i]);
885
+ }
886
+ debug += ']';
887
+ return debug;
888
+ }
889
+ // Test for built-in
890
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
891
+ let className;
892
+ if (builtInMatches && builtInMatches.length > 1) {
893
+ className = builtInMatches[1];
894
+ } else {
895
+ // Failed to match the standard '[object ClassName]'
896
+ return toString.call(val);
897
+ }
898
+ if (className == 'Object') {
899
+ // we're a user defined class or Object
900
+ // JSON.stringify avoids problems with cycles, and is generally much
901
+ // easier than looping through ownProperties of `val`.
902
+ try {
903
+ return 'Object(' + JSON.stringify(val) + ')';
904
+ } catch (_) {
905
+ return 'Object';
906
+ }
907
+ }
908
+ // errors
909
+ if (val instanceof Error) {
910
+ return `${val.name}: ${val.message}\n${val.stack}`;
911
+ }
912
+ // TODO we could test for more things here, like `Set`s and `Map`s.
913
+ return className;
914
+ }
915
+
916
+ function dropObject(idx) {
917
+ if (idx < 1028) return;
918
+ heap[idx] = heap_next;
919
+ heap_next = idx;
920
+ }
921
+
922
+ function getArrayI32FromWasm0(ptr, len) {
923
+ ptr = ptr >>> 0;
924
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
925
+ }
926
+
927
+ function getArrayU8FromWasm0(ptr, len) {
928
+ ptr = ptr >>> 0;
929
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
930
+ }
931
+
932
+ let cachedDataViewMemory0 = null;
933
+ function getDataViewMemory0() {
934
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
935
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
936
+ }
937
+ return cachedDataViewMemory0;
938
+ }
939
+
940
+ let cachedInt32ArrayMemory0 = null;
941
+ function getInt32ArrayMemory0() {
942
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
943
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
944
+ }
945
+ return cachedInt32ArrayMemory0;
946
+ }
947
+
948
+ function getStringFromWasm0(ptr, len) {
949
+ return decodeText(ptr >>> 0, len);
950
+ }
951
+
952
+ let cachedUint32ArrayMemory0 = null;
953
+ function getUint32ArrayMemory0() {
954
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
955
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
956
+ }
957
+ return cachedUint32ArrayMemory0;
958
+ }
959
+
960
+ let cachedUint8ArrayMemory0 = null;
961
+ function getUint8ArrayMemory0() {
962
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
963
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
964
+ }
965
+ return cachedUint8ArrayMemory0;
966
+ }
967
+
968
+ function getObject(idx) { return heap[idx]; }
969
+
970
+ function handleError(f, args) {
971
+ try {
972
+ return f.apply(this, args);
973
+ } catch (e) {
974
+ wasm.__wbindgen_export3(addHeapObject(e));
975
+ }
976
+ }
977
+
978
+ let heap = new Array(1024).fill(undefined);
979
+ heap.push(undefined, null, true, false);
980
+
981
+ let heap_next = heap.length;
982
+
983
+ function isLikeNone(x) {
984
+ return x === undefined || x === null;
985
+ }
986
+
987
+ function makeMutClosure(arg0, arg1, f) {
988
+ const state = { a: arg0, b: arg1, cnt: 1 };
989
+ const real = (...args) => {
990
+
991
+ // First up with a closure we increment the internal reference
992
+ // count. This ensures that the Rust closure environment won't
993
+ // be deallocated while we're invoking it.
994
+ state.cnt++;
995
+ const a = state.a;
996
+ state.a = 0;
997
+ try {
998
+ return f(a, state.b, ...args);
999
+ } finally {
1000
+ state.a = a;
1001
+ real._wbg_cb_unref();
1002
+ }
1003
+ };
1004
+ real._wbg_cb_unref = () => {
1005
+ if (--state.cnt === 0) {
1006
+ wasm.__wbindgen_export4(state.a, state.b);
1007
+ state.a = 0;
1008
+ CLOSURE_DTORS.unregister(state);
1009
+ }
1010
+ };
1011
+ CLOSURE_DTORS.register(real, state, state);
1012
+ return real;
1013
+ }
1014
+
1015
+ function passArray32ToWasm0(arg, malloc) {
1016
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
1017
+ getUint32ArrayMemory0().set(arg, ptr / 4);
1018
+ WASM_VECTOR_LEN = arg.length;
1019
+ return ptr;
1020
+ }
1021
+
1022
+ function passStringToWasm0(arg, malloc, realloc) {
1023
+ if (realloc === undefined) {
1024
+ const buf = cachedTextEncoder.encode(arg);
1025
+ const ptr = malloc(buf.length, 1) >>> 0;
1026
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1027
+ WASM_VECTOR_LEN = buf.length;
1028
+ return ptr;
1029
+ }
1030
+
1031
+ let len = arg.length;
1032
+ let ptr = malloc(len, 1) >>> 0;
1033
+
1034
+ const mem = getUint8ArrayMemory0();
1035
+
1036
+ let offset = 0;
1037
+
1038
+ for (; offset < len; offset++) {
1039
+ const code = arg.charCodeAt(offset);
1040
+ if (code > 0x7F) break;
1041
+ mem[ptr + offset] = code;
1042
+ }
1043
+ if (offset !== len) {
1044
+ if (offset !== 0) {
1045
+ arg = arg.slice(offset);
1046
+ }
1047
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1048
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1049
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1050
+
1051
+ offset += ret.written;
1052
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1053
+ }
1054
+
1055
+ WASM_VECTOR_LEN = offset;
1056
+ return ptr;
1057
+ }
1058
+
1059
+ function takeObject(idx) {
1060
+ const ret = getObject(idx);
1061
+ dropObject(idx);
1062
+ return ret;
1063
+ }
1064
+
1065
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1066
+ cachedTextDecoder.decode();
1067
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1068
+ let numBytesDecoded = 0;
1069
+ function decodeText(ptr, len) {
1070
+ numBytesDecoded += len;
1071
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1072
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1073
+ cachedTextDecoder.decode();
1074
+ numBytesDecoded = len;
1075
+ }
1076
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1077
+ }
1078
+
1079
+ const cachedTextEncoder = new TextEncoder();
1080
+
1081
+ if (!('encodeInto' in cachedTextEncoder)) {
1082
+ cachedTextEncoder.encodeInto = function (arg, view) {
1083
+ const buf = cachedTextEncoder.encode(arg);
1084
+ view.set(buf);
1085
+ return {
1086
+ read: arg.length,
1087
+ written: buf.length
1088
+ };
1089
+ };
1090
+ }
1091
+
1092
+ let WASM_VECTOR_LEN = 0;
1093
+
1094
+ let wasmModule, wasmInstance, wasm;
1095
+ function __wbg_finalize_init(instance, module) {
1096
+ wasmInstance = instance;
1097
+ wasm = instance.exports;
1098
+ wasmModule = module;
1099
+ cachedDataViewMemory0 = null;
1100
+ cachedInt32ArrayMemory0 = null;
1101
+ cachedUint32ArrayMemory0 = null;
1102
+ cachedUint8ArrayMemory0 = null;
1103
+ return wasm;
1104
+ }
1105
+
1106
+ async function __wbg_load(module, imports) {
1107
+ if (typeof Response === 'function' && module instanceof Response) {
1108
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1109
+ try {
1110
+ return await WebAssembly.instantiateStreaming(module, imports);
1111
+ } catch (e) {
1112
+ const validResponse = module.ok && expectedResponseType(module.type);
1113
+
1114
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1115
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1116
+
1117
+ } else { throw e; }
1118
+ }
1119
+ }
1120
+
1121
+ const bytes = await module.arrayBuffer();
1122
+ return await WebAssembly.instantiate(bytes, imports);
1123
+ } else {
1124
+ const instance = await WebAssembly.instantiate(module, imports);
1125
+
1126
+ if (instance instanceof WebAssembly.Instance) {
1127
+ return { instance, module };
1128
+ } else {
1129
+ return instance;
1130
+ }
1131
+ }
1132
+
1133
+ function expectedResponseType(type) {
1134
+ switch (type) {
1135
+ case 'basic': case 'cors': case 'default': return true;
1136
+ }
1137
+ return false;
1138
+ }
1139
+ }
1140
+
1141
+ function initSync(module) {
1142
+ if (wasm !== undefined) return wasm;
1143
+
1144
+
1145
+ if (module !== undefined) {
1146
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1147
+ ({module} = module)
1148
+ } else {
1149
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1150
+ }
1151
+ }
1152
+
1153
+ const imports = __wbg_get_imports();
1154
+ if (!(module instanceof WebAssembly.Module)) {
1155
+ module = new WebAssembly.Module(module);
1156
+ }
1157
+ const instance = new WebAssembly.Instance(module, imports);
1158
+ return __wbg_finalize_init(instance, module);
1159
+ }
1160
+
1161
+ async function __wbg_init(module_or_path) {
1162
+ if (wasm !== undefined) return wasm;
1163
+
1164
+
1165
+ if (module_or_path !== undefined) {
1166
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1167
+ ({module_or_path} = module_or_path)
1168
+ } else {
1169
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1170
+ }
1171
+ }
1172
+
1173
+ if (module_or_path === undefined) {
1174
+ module_or_path = new URL('mega_client_wasm_bg.wasm', import.meta.url);
1175
+ }
1176
+ const imports = __wbg_get_imports();
1177
+
1178
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1179
+ module_or_path = fetch(module_or_path);
1180
+ }
1181
+
1182
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1183
+
1184
+ return __wbg_finalize_init(instance, module);
1185
+ }
1186
+
1187
+ export { initSync, __wbg_init as default };