@prisma-next/sql-runtime 0.3.0-dev.6 → 0.3.0-dev.64

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 (166) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +137 -26
  3. package/dist/exports-BhZqJPVb.mjs +771 -0
  4. package/dist/exports-BhZqJPVb.mjs.map +1 -0
  5. package/dist/index-D59jqEKF.d.mts +159 -0
  6. package/dist/index-D59jqEKF.d.mts.map +1 -0
  7. package/dist/index.d.mts +2 -0
  8. package/dist/index.mjs +3 -0
  9. package/dist/test/utils.d.mts +82 -0
  10. package/dist/test/utils.d.mts.map +1 -0
  11. package/dist/test/utils.mjs +212 -0
  12. package/dist/test/utils.mjs.map +1 -0
  13. package/package.json +32 -25
  14. package/src/codecs/decoding.ts +84 -3
  15. package/src/codecs/encoding.ts +15 -2
  16. package/src/codecs/json-schema-validation.ts +61 -0
  17. package/src/exports/index.ts +14 -6
  18. package/src/lower-sql-plan.ts +8 -8
  19. package/src/plugins/lints.ts +204 -0
  20. package/src/sql-context.ts +385 -98
  21. package/src/sql-family-adapter.ts +9 -5
  22. package/src/sql-marker.ts +2 -2
  23. package/src/sql-runtime.ts +131 -31
  24. package/test/async-iterable-result.test.ts +42 -34
  25. package/test/context.types.test-d.ts +68 -0
  26. package/test/execution-stack.test.ts +166 -0
  27. package/test/json-schema-validation.test.ts +653 -0
  28. package/test/lints.test.ts +330 -0
  29. package/test/parameterized-types.test.ts +539 -0
  30. package/test/sql-context.test.ts +292 -117
  31. package/test/sql-family-adapter.test.ts +7 -6
  32. package/test/sql-runtime.test.ts +218 -30
  33. package/test/utils.ts +80 -51
  34. package/dist/accelerate-EEKAFGN3-P6A6XJWJ.js +0 -137863
  35. package/dist/accelerate-EEKAFGN3-P6A6XJWJ.js.map +0 -1
  36. package/dist/amcheck-24VY6X5V.js +0 -13
  37. package/dist/amcheck-24VY6X5V.js.map +0 -1
  38. package/dist/bloom-VS74NLHT.js +0 -13
  39. package/dist/bloom-VS74NLHT.js.map +0 -1
  40. package/dist/btree_gin-WBC4EAAI.js +0 -13
  41. package/dist/btree_gin-WBC4EAAI.js.map +0 -1
  42. package/dist/btree_gist-UNC6QD3M.js +0 -13
  43. package/dist/btree_gist-UNC6QD3M.js.map +0 -1
  44. package/dist/chunk-3KTOEDFX.js +0 -49
  45. package/dist/chunk-3KTOEDFX.js.map +0 -1
  46. package/dist/chunk-47DZBRQC.js +0 -1280
  47. package/dist/chunk-47DZBRQC.js.map +0 -1
  48. package/dist/chunk-52N6AFZM.js +0 -133
  49. package/dist/chunk-52N6AFZM.js.map +0 -1
  50. package/dist/chunk-7D4SUZUM.js +0 -38
  51. package/dist/chunk-7D4SUZUM.js.map +0 -1
  52. package/dist/chunk-C6I3V3DM.js +0 -455
  53. package/dist/chunk-C6I3V3DM.js.map +0 -1
  54. package/dist/chunk-ECWIHLAT.js +0 -37
  55. package/dist/chunk-ECWIHLAT.js.map +0 -1
  56. package/dist/chunk-EI626SDC.js +0 -105
  57. package/dist/chunk-EI626SDC.js.map +0 -1
  58. package/dist/chunk-UKKOYUGL.js +0 -578
  59. package/dist/chunk-UKKOYUGL.js.map +0 -1
  60. package/dist/chunk-XPLNMXQV.js +0 -1537
  61. package/dist/chunk-XPLNMXQV.js.map +0 -1
  62. package/dist/citext-T7MXGUY7.js +0 -13
  63. package/dist/citext-T7MXGUY7.js.map +0 -1
  64. package/dist/client-5FENX6AW.js +0 -299
  65. package/dist/client-5FENX6AW.js.map +0 -1
  66. package/dist/cube-TFDQBZCI.js +0 -13
  67. package/dist/cube-TFDQBZCI.js.map +0 -1
  68. package/dist/dict_int-AEUOPGWP.js +0 -13
  69. package/dist/dict_int-AEUOPGWP.js.map +0 -1
  70. package/dist/dict_xsyn-DAAYX3FL.js +0 -13
  71. package/dist/dict_xsyn-DAAYX3FL.js.map +0 -1
  72. package/dist/dist-AQ3LWXOX.js +0 -570
  73. package/dist/dist-AQ3LWXOX.js.map +0 -1
  74. package/dist/dist-LBVX6BJW.js +0 -189
  75. package/dist/dist-LBVX6BJW.js.map +0 -1
  76. package/dist/dist-WLKUVDN2.js +0 -5127
  77. package/dist/dist-WLKUVDN2.js.map +0 -1
  78. package/dist/earthdistance-KIGTF4LE.js +0 -13
  79. package/dist/earthdistance-KIGTF4LE.js.map +0 -1
  80. package/dist/file_fdw-5N55UP6I.js +0 -13
  81. package/dist/file_fdw-5N55UP6I.js.map +0 -1
  82. package/dist/fuzzystrmatch-KN3YWBFP.js +0 -13
  83. package/dist/fuzzystrmatch-KN3YWBFP.js.map +0 -1
  84. package/dist/hstore-YX726NKN.js +0 -13
  85. package/dist/hstore-YX726NKN.js.map +0 -1
  86. package/dist/http-exception-FZY2H4OF.js +0 -8
  87. package/dist/http-exception-FZY2H4OF.js.map +0 -1
  88. package/dist/index.js +0 -30
  89. package/dist/index.js.map +0 -1
  90. package/dist/intarray-NKVXNO2D.js +0 -13
  91. package/dist/intarray-NKVXNO2D.js.map +0 -1
  92. package/dist/isn-FTEMJGEV.js +0 -13
  93. package/dist/isn-FTEMJGEV.js.map +0 -1
  94. package/dist/lo-DB7L4NGI.js +0 -13
  95. package/dist/lo-DB7L4NGI.js.map +0 -1
  96. package/dist/logger-WQ7SHNDD.js +0 -68
  97. package/dist/logger-WQ7SHNDD.js.map +0 -1
  98. package/dist/ltree-Z32TZT6W.js +0 -13
  99. package/dist/ltree-Z32TZT6W.js.map +0 -1
  100. package/dist/nodefs-NM46ACH7.js +0 -31
  101. package/dist/nodefs-NM46ACH7.js.map +0 -1
  102. package/dist/opfs-ahp-NJO33LVZ.js +0 -332
  103. package/dist/opfs-ahp-NJO33LVZ.js.map +0 -1
  104. package/dist/pageinspect-YP3IZR4X.js +0 -13
  105. package/dist/pageinspect-YP3IZR4X.js.map +0 -1
  106. package/dist/pg_buffercache-7TD5J2FB.js +0 -13
  107. package/dist/pg_buffercache-7TD5J2FB.js.map +0 -1
  108. package/dist/pg_dump-SG4KYBUB.js +0 -2492
  109. package/dist/pg_dump-SG4KYBUB.js.map +0 -1
  110. package/dist/pg_freespacemap-DZDNCPZK.js +0 -13
  111. package/dist/pg_freespacemap-DZDNCPZK.js.map +0 -1
  112. package/dist/pg_surgery-J2MUEWEP.js +0 -13
  113. package/dist/pg_surgery-J2MUEWEP.js.map +0 -1
  114. package/dist/pg_trgm-7VNQOYS6.js +0 -13
  115. package/dist/pg_trgm-7VNQOYS6.js.map +0 -1
  116. package/dist/pg_visibility-TTSIPHFL.js +0 -13
  117. package/dist/pg_visibility-TTSIPHFL.js.map +0 -1
  118. package/dist/pg_walinspect-KPFHSHRJ.js +0 -13
  119. package/dist/pg_walinspect-KPFHSHRJ.js.map +0 -1
  120. package/dist/proxy-signals-GUDAMDHV.js +0 -39
  121. package/dist/proxy-signals-GUDAMDHV.js.map +0 -1
  122. package/dist/seg-IYVDLE4O.js +0 -13
  123. package/dist/seg-IYVDLE4O.js.map +0 -1
  124. package/dist/src/codecs/decoding.d.ts +0 -4
  125. package/dist/src/codecs/decoding.d.ts.map +0 -1
  126. package/dist/src/codecs/encoding.d.ts +0 -5
  127. package/dist/src/codecs/encoding.d.ts.map +0 -1
  128. package/dist/src/codecs/validation.d.ts +0 -6
  129. package/dist/src/codecs/validation.d.ts.map +0 -1
  130. package/dist/src/exports/index.d.ts +0 -11
  131. package/dist/src/exports/index.d.ts.map +0 -1
  132. package/dist/src/index.d.ts +0 -2
  133. package/dist/src/index.d.ts.map +0 -1
  134. package/dist/src/lower-sql-plan.d.ts +0 -15
  135. package/dist/src/lower-sql-plan.d.ts.map +0 -1
  136. package/dist/src/sql-context.d.ts +0 -65
  137. package/dist/src/sql-context.d.ts.map +0 -1
  138. package/dist/src/sql-family-adapter.d.ts +0 -10
  139. package/dist/src/sql-family-adapter.d.ts.map +0 -1
  140. package/dist/src/sql-marker.d.ts +0 -22
  141. package/dist/src/sql-marker.d.ts.map +0 -1
  142. package/dist/src/sql-runtime.d.ts +0 -25
  143. package/dist/src/sql-runtime.d.ts.map +0 -1
  144. package/dist/tablefunc-EF4RCS7S.js +0 -13
  145. package/dist/tablefunc-EF4RCS7S.js.map +0 -1
  146. package/dist/tcn-3VT5BQYW.js +0 -13
  147. package/dist/tcn-3VT5BQYW.js.map +0 -1
  148. package/dist/test/utils.d.ts +0 -59
  149. package/dist/test/utils.d.ts.map +0 -1
  150. package/dist/test/utils.js +0 -24634
  151. package/dist/test/utils.js.map +0 -1
  152. package/dist/tiny-CW6F4GX6.js +0 -10
  153. package/dist/tiny-CW6F4GX6.js.map +0 -1
  154. package/dist/tsm_system_rows-ES7KNUQH.js +0 -13
  155. package/dist/tsm_system_rows-ES7KNUQH.js.map +0 -1
  156. package/dist/tsm_system_time-76WEIMBG.js +0 -13
  157. package/dist/tsm_system_time-76WEIMBG.js.map +0 -1
  158. package/dist/unaccent-7RYF3R64.js +0 -13
  159. package/dist/unaccent-7RYF3R64.js.map +0 -1
  160. package/dist/utility-Q5A254LJ-J4HTKZPT.js +0 -347
  161. package/dist/utility-Q5A254LJ-J4HTKZPT.js.map +0 -1
  162. package/dist/uuid_ossp-4ETE4FPE.js +0 -13
  163. package/dist/uuid_ossp-4ETE4FPE.js.map +0 -1
  164. package/dist/vector-74GPNV7V.js +0 -13
  165. package/dist/vector-74GPNV7V.js.map +0 -1
  166. package/src/index.ts +0 -1
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/earthdistance.js
7
- u();
8
- var t = async (n, s) => ({ bundlePath: new URL("../earthdistance.tar.gz", import.meta.url) });
9
- var r = { name: "earthdistance", setup: t };
10
- export {
11
- r as earthdistance
12
- };
13
- //# sourceMappingURL=earthdistance-KIGTF4LE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/earthdistance.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/earthdistance.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const earthdistance = {\n name: 'earthdistance',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,2BAAA,YAAsC,GAAA,EAAA;AAF9D,IAE8D,IAAA,EAAA,MAC5D,iBAIM,OAAA,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/file_fdw.js
7
- u();
8
- var t = async (n, s) => ({ bundlePath: new URL("../file_fdw.tar.gz", import.meta.url) });
9
- var a = { name: "file_fdw", setup: t };
10
- export {
11
- a as file_fdw
12
- };
13
- //# sourceMappingURL=file_fdw-5N55UP6I.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/file_fdw.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/file_fdw.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const file_fdw = {\n name: 'file_fdw',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,sBAAA,YAAiC,GAAA,EAAA;AAFzD,IAEyD,IAAA,EAAA,MACvD,YAIM,OAAA,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/fuzzystrmatch.js
7
- u();
8
- var e = async (s, n) => ({ bundlePath: new URL("../fuzzystrmatch.tar.gz", import.meta.url) });
9
- var i = { name: "fuzzystrmatch", setup: e };
10
- export {
11
- i as fuzzystrmatch
12
- };
13
- //# sourceMappingURL=fuzzystrmatch-KN3YWBFP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/fuzzystrmatch.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/fuzzystrmatch.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const fuzzystrmatch = {\n name: 'fuzzystrmatch',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,2BAAA,YAAsC,GAAA,EAAA;AAF9D,IAE8D,IAAA,EAAA,MAC5D,iBAIM,OAAA,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/hstore.js
7
- u();
8
- var t = async (s, n) => ({ bundlePath: new URL("../hstore.tar.gz", import.meta.url) });
9
- var o = { name: "hstore", setup: t };
10
- export {
11
- o as hstore
12
- };
13
- //# sourceMappingURL=hstore-YX726NKN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/hstore.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/hstore.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const hstore = {\n name: 'hstore',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,oBAAA,YAA+B,GAAA,EAAA;AAFvD,IAEuD,IAAA,EAAA,MACrD,UAIA,OAAM,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,8 +0,0 @@
1
- import {
2
- HTTPException
3
- } from "./chunk-ECWIHLAT.js";
4
- import "./chunk-7D4SUZUM.js";
5
- export {
6
- HTTPException
7
- };
8
- //# sourceMappingURL=http-exception-FZY2H4OF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.js DELETED
@@ -1,30 +0,0 @@
1
- import {
2
- budgets,
3
- createRuntime,
4
- createRuntimeContext,
5
- ensureSchemaStatement,
6
- ensureTableStatement,
7
- extractCodecIds,
8
- lints,
9
- lowerSqlPlan,
10
- readContractMarker,
11
- validateCodecRegistryCompleteness,
12
- validateContractCodecMappings,
13
- writeContractMarker
14
- } from "./chunk-C6I3V3DM.js";
15
- import "./chunk-7D4SUZUM.js";
16
- export {
17
- budgets,
18
- createRuntime,
19
- createRuntimeContext,
20
- ensureSchemaStatement,
21
- ensureTableStatement,
22
- extractCodecIds,
23
- lints,
24
- lowerSqlPlan,
25
- readContractMarker,
26
- validateCodecRegistryCompleteness,
27
- validateContractCodecMappings,
28
- writeContractMarker
29
- };
30
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/intarray.js
7
- u();
8
- var t = async (n, r) => ({ bundlePath: new URL("../intarray.tar.gz", import.meta.url) });
9
- var i = { name: "intarray", setup: t };
10
- export {
11
- i as intarray
12
- };
13
- //# sourceMappingURL=intarray-NKVXNO2D.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/intarray.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/intarray.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const intarray = {\n name: 'intarray',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,sBAAA,YAAiC,GAAA,EAAA;AAFzD,IAEyD,IAAA,EAAA,MACvD,YAIM,OAAA,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/isn.js
7
- u();
8
- var t = async (n, s) => ({ bundlePath: new URL("../isn.tar.gz", import.meta.url) });
9
- var a = { name: "isn", setup: t };
10
- export {
11
- a as isn
12
- };
13
- //# sourceMappingURL=isn-FTEMJGEV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/isn.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/isn.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const isn = {\n name: 'isn',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,iBAAA,YAA4B,GAAA,EAAA;AAFpD,IAEoD,IAAA,EAAA,MAClD,OAIA,OAAM,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/lo.js
7
- u();
8
- var t = async (n, s) => ({ bundlePath: new URL("../lo.tar.gz", import.meta.url) });
9
- var r = { name: "lo", setup: t };
10
- export {
11
- r as lo
12
- };
13
- //# sourceMappingURL=lo-DB7L4NGI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/lo.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/lo.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const lo = {\n name: 'lo',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,gBAAA,YAA2B,GAAA,EAAA;AAFnD,IAEmD,IAAA,EAAA,MACjD,MAGgB,OACV,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,68 +0,0 @@
1
- import "./chunk-7D4SUZUM.js";
2
-
3
- // ../../../node_modules/.pnpm/hono@4.11.1/node_modules/hono/dist/utils/color.js
4
- function getColorEnabled() {
5
- const { process, Deno } = globalThis;
6
- const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : process !== void 0 ? (
7
- // eslint-disable-next-line no-unsafe-optional-chaining
8
- "NO_COLOR" in process?.env
9
- ) : false;
10
- return !isNoColor;
11
- }
12
- async function getColorEnabledAsync() {
13
- const { navigator } = globalThis;
14
- const cfWorkers = "cloudflare:workers";
15
- const isNoColor = navigator !== void 0 && navigator.userAgent === "Cloudflare-Workers" ? await (async () => {
16
- try {
17
- return "NO_COLOR" in ((await import(cfWorkers)).env ?? {});
18
- } catch {
19
- return false;
20
- }
21
- })() : !getColorEnabled();
22
- return !isNoColor;
23
- }
24
-
25
- // ../../../node_modules/.pnpm/hono@4.11.1/node_modules/hono/dist/middleware/logger/index.js
26
- var humanize = (times) => {
27
- const [delimiter, separator] = [",", "."];
28
- const orderTimes = times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter));
29
- return orderTimes.join(separator);
30
- };
31
- var time = (start) => {
32
- const delta = Date.now() - start;
33
- return humanize([delta < 1e3 ? delta + "ms" : Math.round(delta / 1e3) + "s"]);
34
- };
35
- var colorStatus = async (status) => {
36
- const colorEnabled = await getColorEnabledAsync();
37
- if (colorEnabled) {
38
- switch (status / 100 | 0) {
39
- case 5:
40
- return `\x1B[31m${status}\x1B[0m`;
41
- case 4:
42
- return `\x1B[33m${status}\x1B[0m`;
43
- case 3:
44
- return `\x1B[36m${status}\x1B[0m`;
45
- case 2:
46
- return `\x1B[32m${status}\x1B[0m`;
47
- }
48
- }
49
- return `${status}`;
50
- };
51
- async function log(fn, prefix, method, path, status = 0, elapsed) {
52
- const out = prefix === "<--" ? `${prefix} ${method} ${path}` : `${prefix} ${method} ${path} ${await colorStatus(status)} ${elapsed}`;
53
- fn(out);
54
- }
55
- var logger = (fn = console.log) => {
56
- return async function logger2(c, next) {
57
- const { method, url } = c.req;
58
- const path = url.slice(url.indexOf("/", 8));
59
- await log(fn, "<--", method, path);
60
- const start = Date.now();
61
- await next();
62
- await log(fn, "-->", method, path, c.res.status, time(start));
63
- };
64
- };
65
- export {
66
- logger
67
- };
68
- //# sourceMappingURL=logger-WQ7SHNDD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/hono@4.11.1/node_modules/hono/dist/utils/color.js","../../../../node_modules/.pnpm/hono@4.11.1/node_modules/hono/dist/middleware/logger/index.js"],"sourcesContent":["// src/utils/color.ts\nfunction getColorEnabled() {\n const { process, Deno } = globalThis;\n const isNoColor = typeof Deno?.noColor === \"boolean\" ? Deno.noColor : process !== void 0 ? (\n // eslint-disable-next-line no-unsafe-optional-chaining\n \"NO_COLOR\" in process?.env\n ) : false;\n return !isNoColor;\n}\nasync function getColorEnabledAsync() {\n const { navigator } = globalThis;\n const cfWorkers = \"cloudflare:workers\";\n const isNoColor = navigator !== void 0 && navigator.userAgent === \"Cloudflare-Workers\" ? await (async () => {\n try {\n return \"NO_COLOR\" in ((await import(cfWorkers)).env ?? {});\n } catch {\n return false;\n }\n })() : !getColorEnabled();\n return !isNoColor;\n}\nexport {\n getColorEnabled,\n getColorEnabledAsync\n};\n","// src/middleware/logger/index.ts\nimport { getColorEnabledAsync } from \"../../utils/color.js\";\nvar humanize = (times) => {\n const [delimiter, separator] = [\",\", \".\"];\n const orderTimes = times.map((v) => v.replace(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/g, \"$1\" + delimiter));\n return orderTimes.join(separator);\n};\nvar time = (start) => {\n const delta = Date.now() - start;\n return humanize([delta < 1e3 ? delta + \"ms\" : Math.round(delta / 1e3) + \"s\"]);\n};\nvar colorStatus = async (status) => {\n const colorEnabled = await getColorEnabledAsync();\n if (colorEnabled) {\n switch (status / 100 | 0) {\n case 5:\n return `\\x1B[31m${status}\\x1B[0m`;\n case 4:\n return `\\x1B[33m${status}\\x1B[0m`;\n case 3:\n return `\\x1B[36m${status}\\x1B[0m`;\n case 2:\n return `\\x1B[32m${status}\\x1B[0m`;\n }\n }\n return `${status}`;\n};\nasync function log(fn, prefix, method, path, status = 0, elapsed) {\n const out = prefix === \"<--\" /* Incoming */ ? `${prefix} ${method} ${path}` : `${prefix} ${method} ${path} ${await colorStatus(status)} ${elapsed}`;\n fn(out);\n}\nvar logger = (fn = console.log) => {\n return async function logger2(c, next) {\n const { method, url } = c.req;\n const path = url.slice(url.indexOf(\"/\", 8));\n await log(fn, \"<--\" /* Incoming */, method, path);\n const start = Date.now();\n await next();\n await log(fn, \"-->\" /* Outgoing */, method, path, c.res.status, time(start));\n };\n};\nexport {\n logger\n};\n"],"mappings":";;;AACA,SAAS,kBAAkB;AACzB,QAAM,EAAE,SAAS,KAAK,IAAI;AAC1B,QAAM,YAAY,OAAO,MAAM,YAAY,YAAY,KAAK,UAAU,YAAY;AAAA;AAAA,IAEhF,cAAc,SAAS;AAAA,MACrB;AACJ,SAAO,CAAC;AACV;AACA,eAAe,uBAAuB;AACpC,QAAM,EAAE,UAAU,IAAI;AACtB,QAAM,YAAY;AAClB,QAAM,YAAY,cAAc,UAAU,UAAU,cAAc,uBAAuB,OAAO,YAAY;AAC1G,QAAI;AACF,aAAO,gBAAgB,MAAM,OAAO,YAAY,OAAO,CAAC;AAAA,IAC1D,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF,GAAG,IAAI,CAAC,gBAAgB;AACxB,SAAO,CAAC;AACV;;;AClBA,IAAI,WAAW,CAAC,UAAU;AACxB,QAAM,CAAC,WAAW,SAAS,IAAI,CAAC,KAAK,GAAG;AACxC,QAAM,aAAa,MAAM,IAAI,CAAC,MAAM,EAAE,QAAQ,4BAA4B,OAAO,SAAS,CAAC;AAC3F,SAAO,WAAW,KAAK,SAAS;AAClC;AACA,IAAI,OAAO,CAAC,UAAU;AACpB,QAAM,QAAQ,KAAK,IAAI,IAAI;AAC3B,SAAO,SAAS,CAAC,QAAQ,MAAM,QAAQ,OAAO,KAAK,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;AAC9E;AACA,IAAI,cAAc,OAAO,WAAW;AAClC,QAAM,eAAe,MAAM,qBAAqB;AAChD,MAAI,cAAc;AAChB,YAAQ,SAAS,MAAM,GAAG;AAAA,MACxB,KAAK;AACH,eAAO,WAAW,MAAM;AAAA,MAC1B,KAAK;AACH,eAAO,WAAW,MAAM;AAAA,MAC1B,KAAK;AACH,eAAO,WAAW,MAAM;AAAA,MAC1B,KAAK;AACH,eAAO,WAAW,MAAM;AAAA,IAC5B;AAAA,EACF;AACA,SAAO,GAAG,MAAM;AAClB;AACA,eAAe,IAAI,IAAI,QAAQ,QAAQ,MAAM,SAAS,GAAG,SAAS;AAChE,QAAM,MAAM,WAAW,QAAuB,GAAG,MAAM,IAAI,MAAM,IAAI,IAAI,KAAK,GAAG,MAAM,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,YAAY,MAAM,CAAC,IAAI,OAAO;AACjJ,KAAG,GAAG;AACR;AACA,IAAI,SAAS,CAAC,KAAK,QAAQ,QAAQ;AACjC,SAAO,eAAe,QAAQ,GAAG,MAAM;AACrC,UAAM,EAAE,QAAQ,IAAI,IAAI,EAAE;AAC1B,UAAM,OAAO,IAAI,MAAM,IAAI,QAAQ,KAAK,CAAC,CAAC;AAC1C,UAAM,IAAI,IAAI,OAAsB,QAAQ,IAAI;AAChD,UAAM,QAAQ,KAAK,IAAI;AACvB,UAAM,KAAK;AACX,UAAM,IAAI,IAAI,OAAsB,QAAQ,MAAM,EAAE,IAAI,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC7E;AACF;","names":[]}
@@ -1,13 +0,0 @@
1
- import {
2
- u
3
- } from "./chunk-3KTOEDFX.js";
4
- import "./chunk-7D4SUZUM.js";
5
-
6
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/contrib/ltree.js
7
- u();
8
- var t = async (n, s) => ({ bundlePath: new URL("../ltree.tar.gz", import.meta.url) });
9
- var a = { name: "ltree", setup: t };
10
- export {
11
- a as ltree
12
- };
13
- //# sourceMappingURL=ltree-Z32TZT6W.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/contrib/ltree.ts"],"sourcesContent":["import type {\n Extension,\n ExtensionSetupResult,\n PGliteInterface,\n} from '../interface'\n\nconst setup = async (_pg: PGliteInterface, _emscriptenOpts: any) => {\n return {\n bundlePath: new URL('../../release/ltree.tar.gz', import.meta.url),\n } satisfies ExtensionSetupResult\n}\n\nexport const ltree = {\n name: 'ltree',\n setup,\n} satisfies Extension\n"],"mappings":";;;;;;AAAAA,EAAAA;AAMA,IAAMC,IAAQ,OAAOC,GAAsBC,OAClC,EACL,YAAY,IAAI,IAAI,mBAAA,YAA8B,GAAA,EAAA;AAFtD,IAEsD,IAAA,EAAA,MACpD,SAIA,OAAM,EAAA;","names":["init_esm_shims","setup","_pg","_emscriptenOpts"]}
@@ -1,31 +0,0 @@
1
- import {
2
- C,
3
- ur
4
- } from "./chunk-UKKOYUGL.js";
5
- import {
6
- u
7
- } from "./chunk-3KTOEDFX.js";
8
- import "./chunk-7D4SUZUM.js";
9
-
10
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/fs/nodefs.js
11
- import * as s from "fs";
12
- import * as o from "path";
13
- u();
14
- var m = class extends ur {
15
- constructor(t) {
16
- super(t), this.rootDir = o.resolve(t), s.existsSync(o.join(this.rootDir)) || s.mkdirSync(this.rootDir);
17
- }
18
- async init(t, e) {
19
- return this.pg = t, { emscriptenOpts: { ...e, preRun: [...e.preRun || [], (r) => {
20
- let c = r.FS.filesystems.NODEFS;
21
- r.FS.mkdir(C), r.FS.mount(c, { root: this.rootDir }, C);
22
- }] } };
23
- }
24
- async closeFs() {
25
- this.pg.Module.FS.quit();
26
- }
27
- };
28
- export {
29
- m as NodeFS
30
- };
31
- //# sourceMappingURL=nodefs-NM46ACH7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/src/fs/nodefs.ts"],"sourcesContent":["import * as fs from 'fs'\nimport * as path from 'path'\nimport { EmscriptenBuiltinFilesystem, PGDATA } from './base.js'\nimport type { PostgresMod } from '../postgresMod.js'\nimport { PGlite } from '../pglite.js'\n\nexport class NodeFS extends EmscriptenBuiltinFilesystem {\n protected rootDir: string\n\n constructor(dataDir: string) {\n super(dataDir)\n this.rootDir = path.resolve(dataDir)\n if (!fs.existsSync(path.join(this.rootDir))) {\n fs.mkdirSync(this.rootDir)\n }\n }\n\n async init(pg: PGlite, opts: Partial<PostgresMod>) {\n this.pg = pg\n const options: Partial<PostgresMod> = {\n ...opts,\n preRun: [\n ...(opts.preRun || []),\n (mod: any) => {\n const nodefs = mod.FS.filesystems.NODEFS\n mod.FS.mkdir(PGDATA)\n mod.FS.mount(nodefs, { root: this.rootDir }, PGDATA)\n },\n ],\n }\n return { emscriptenOpts: options }\n }\n\n async closeFs(): Promise<void> {\n this.pg!.Module.FS.quit()\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,YAAYA,OAAQ;AACpB,YAAYC,OAAU;AADtBC,EAAAA;AAMO,IAAMC,IAAN,cAAqBC,GAA4B;EAGtD,YAAYC,GAAiB;AAC3B,UAAMA,CAAO,GACb,KAAK,UAAe,UAAQA,CAAO,GAC3B,aAAgB,OAAK,KAAK,OAAO,CAAC,KACrC,YAAU,KAAK,OAAO;EAE7B;EAEA,MAAM,KAAKC,GAAYC,GAA4B;AACjD,WAAA,KAAK,KAAKD,GAYH,EAAE,gBAX6B,EACpC,GAAGC,GACH,QAAQ,CACN,GAAIA,EAAK,UAAU,CAAC,GACnBC,OAAa;AACZ,UAAMC,IAASD,EAAI,GAAG,YAAY;AAClCA,QAAI,GAAG,MAAME,CAAM,GACnBF,EAAI,GAAG,MAAMC,GAAQ,EAAE,MAAM,KAAK,QAAQ,GAAGC,CAAM;IACrD,CACF,EACF,EACiC;EACnC;EAEA,MAAM,UAAyB;AAC7B,SAAK,GAAI,OAAO,GAAG,KAAK;EAC1B;AACF;","names":["fs","path","init_esm_shims","NodeFS","EmscriptenBuiltinFilesystem","dataDir","pg","opts","mod","nodefs","PGDATA"]}
@@ -1,332 +0,0 @@
1
- import {
2
- cr,
3
- pr
4
- } from "./chunk-UKKOYUGL.js";
5
- import {
6
- R,
7
- T,
8
- U,
9
- h,
10
- u,
11
- x
12
- } from "./chunk-3KTOEDFX.js";
13
- import "./chunk-7D4SUZUM.js";
14
-
15
- // ../../../node_modules/.pnpm/@electric-sql+pglite@0.3.14/node_modules/@electric-sql/pglite/dist/fs/opfs-ahp.js
16
- u();
17
- var $ = "state.txt";
18
- var G = "data";
19
- var T2 = { DIR: 16384, FILE: 32768 };
20
- var H;
21
- var v;
22
- var F;
23
- var M;
24
- var y;
25
- var b;
26
- var m;
27
- var x2;
28
- var P;
29
- var D;
30
- var S;
31
- var n;
32
- var C;
33
- var O;
34
- var k;
35
- var w;
36
- var f;
37
- var I;
38
- var W;
39
- var j;
40
- var L = class extends cr {
41
- constructor(e, { initialPoolSize: t = 1e3, maintainedPoolSize: o = 100, debug: i = false } = {}) {
42
- super(e, { debug: i });
43
- R(this, n);
44
- R(this, H);
45
- R(this, v);
46
- R(this, F);
47
- R(this, M);
48
- R(this, y);
49
- R(this, b, /* @__PURE__ */ new Map());
50
- R(this, m, /* @__PURE__ */ new Map());
51
- R(this, x2, 0);
52
- R(this, P, /* @__PURE__ */ new Map());
53
- R(this, D, /* @__PURE__ */ new Map());
54
- this.lastCheckpoint = 0;
55
- this.checkpointInterval = 1e3 * 60;
56
- this.poolCounter = 0;
57
- R(this, S, /* @__PURE__ */ new Set());
58
- this.initialPoolSize = t, this.maintainedPoolSize = o;
59
- }
60
- async init(e, t) {
61
- return await T(this, n, C).call(this), super.init(e, t);
62
- }
63
- async syncToFs(e = false) {
64
- await this.maybeCheckpointState(), await this.maintainPool(), e || this.flush();
65
- }
66
- async closeFs() {
67
- for (let e of h(this, m).values()) e.close();
68
- h(this, y).flush(), h(this, y).close(), this.pg.Module.FS.quit();
69
- }
70
- async maintainPool(e) {
71
- e = e || this.maintainedPoolSize;
72
- let t = e - this.state.pool.length, o = [];
73
- for (let i = 0; i < t; i++) o.push(new Promise(async (c) => {
74
- ++this.poolCounter;
75
- let a = `${(Date.now() - 1704063600).toString(16).padStart(8, "0")}-${this.poolCounter.toString(16).padStart(8, "0")}`, h2 = await h(this, F).getFileHandle(a, { create: true }), d = await h2.createSyncAccessHandle();
76
- h(this, b).set(a, h2), h(this, m).set(a, d), T(this, n, k).call(this, { opp: "createPoolFile", args: [a] }), this.state.pool.push(a), c();
77
- }));
78
- for (let i = 0; i > t; i--) o.push(new Promise(async (c) => {
79
- let a = this.state.pool.pop();
80
- T(this, n, k).call(this, { opp: "deletePoolFile", args: [a] });
81
- let h2 = h(this, b).get(a);
82
- h(this, m).get(a)?.close(), await h(this, F).removeEntry(h2.name), h(this, b).delete(a), h(this, m).delete(a), c();
83
- }));
84
- await Promise.all(o);
85
- }
86
- _createPoolFileState(e) {
87
- this.state.pool.push(e);
88
- }
89
- _deletePoolFileState(e) {
90
- let t = this.state.pool.indexOf(e);
91
- t > -1 && this.state.pool.splice(t, 1);
92
- }
93
- async maybeCheckpointState() {
94
- Date.now() - this.lastCheckpoint > this.checkpointInterval && await this.checkpointState();
95
- }
96
- async checkpointState() {
97
- let e = new TextEncoder().encode(JSON.stringify(this.state));
98
- h(this, y).truncate(0), h(this, y).write(e, { at: 0 }), h(this, y).flush(), this.lastCheckpoint = Date.now();
99
- }
100
- flush() {
101
- for (let e of h(this, S)) try {
102
- e.flush();
103
- } catch {
104
- }
105
- h(this, S).clear();
106
- }
107
- chmod(e, t) {
108
- T(this, n, O).call(this, { opp: "chmod", args: [e, t] }, () => {
109
- this._chmodState(e, t);
110
- });
111
- }
112
- _chmodState(e, t) {
113
- let o = T(this, n, f).call(this, e);
114
- o.mode = t;
115
- }
116
- close(e) {
117
- let t = T(this, n, I).call(this, e);
118
- h(this, P).delete(e), h(this, D).delete(t);
119
- }
120
- fstat(e) {
121
- let t = T(this, n, I).call(this, e);
122
- return this.lstat(t);
123
- }
124
- lstat(e) {
125
- let t = T(this, n, f).call(this, e), o = t.type === "file" ? h(this, m).get(t.backingFilename).getSize() : 0, i = 4096;
126
- return { dev: 0, ino: 0, mode: t.mode, nlink: 1, uid: 0, gid: 0, rdev: 0, size: o, blksize: i, blocks: Math.ceil(o / i), atime: t.lastModified, mtime: t.lastModified, ctime: t.lastModified };
127
- }
128
- mkdir(e, t) {
129
- T(this, n, O).call(this, { opp: "mkdir", args: [e, t] }, () => {
130
- this._mkdirState(e, t);
131
- });
132
- }
133
- _mkdirState(e, t) {
134
- let o = T(this, n, w).call(this, e), i = o.pop(), c = [], a = this.state.root;
135
- for (let d of o) {
136
- if (c.push(e), !Object.prototype.hasOwnProperty.call(a.children, d)) if (t?.recursive) this.mkdir(c.join("/"));
137
- else throw new p("ENOENT", "No such file or directory");
138
- if (a.children[d].type !== "directory") throw new p("ENOTDIR", "Not a directory");
139
- a = a.children[d];
140
- }
141
- if (Object.prototype.hasOwnProperty.call(a.children, i)) throw new p("EEXIST", "File exists");
142
- let h2 = { type: "directory", lastModified: Date.now(), mode: t?.mode || T2.DIR, children: {} };
143
- a.children[i] = h2;
144
- }
145
- open(e, t, o) {
146
- if (T(this, n, f).call(this, e).type !== "file") throw new p("EISDIR", "Is a directory");
147
- let c = T(this, n, W).call(this);
148
- return h(this, P).set(c, e), h(this, D).set(e, c), c;
149
- }
150
- readdir(e) {
151
- let t = T(this, n, f).call(this, e);
152
- if (t.type !== "directory") throw new p("ENOTDIR", "Not a directory");
153
- return Object.keys(t.children);
154
- }
155
- read(e, t, o, i, c) {
156
- let a = T(this, n, I).call(this, e), h2 = T(this, n, f).call(this, a);
157
- if (h2.type !== "file") throw new p("EISDIR", "Is a directory");
158
- return h(this, m).get(h2.backingFilename).read(new Uint8Array(t.buffer, o, i), { at: c });
159
- }
160
- rename(e, t) {
161
- T(this, n, O).call(this, { opp: "rename", args: [e, t] }, () => {
162
- this._renameState(e, t, true);
163
- });
164
- }
165
- _renameState(e, t, o = false) {
166
- let i = T(this, n, w).call(this, e), c = i.pop(), a = T(this, n, f).call(this, i.join("/"));
167
- if (!Object.prototype.hasOwnProperty.call(a.children, c)) throw new p("ENOENT", "No such file or directory");
168
- let h2 = T(this, n, w).call(this, t), d = h2.pop(), l = T(this, n, f).call(this, h2.join("/"));
169
- if (o && Object.prototype.hasOwnProperty.call(l.children, d)) {
170
- let u2 = l.children[d];
171
- h(this, m).get(u2.backingFilename).truncate(0), this.state.pool.push(u2.backingFilename);
172
- }
173
- l.children[d] = a.children[c], delete a.children[c];
174
- }
175
- rmdir(e) {
176
- T(this, n, O).call(this, { opp: "rmdir", args: [e] }, () => {
177
- this._rmdirState(e);
178
- });
179
- }
180
- _rmdirState(e) {
181
- let t = T(this, n, w).call(this, e), o = t.pop(), i = T(this, n, f).call(this, t.join("/"));
182
- if (!Object.prototype.hasOwnProperty.call(i.children, o)) throw new p("ENOENT", "No such file or directory");
183
- let c = i.children[o];
184
- if (c.type !== "directory") throw new p("ENOTDIR", "Not a directory");
185
- if (Object.keys(c.children).length > 0) throw new p("ENOTEMPTY", "Directory not empty");
186
- delete i.children[o];
187
- }
188
- truncate(e, t = 0) {
189
- let o = T(this, n, f).call(this, e);
190
- if (o.type !== "file") throw new p("EISDIR", "Is a directory");
191
- let i = h(this, m).get(o.backingFilename);
192
- if (!i) throw new p("ENOENT", "No such file or directory");
193
- i.truncate(t), h(this, S).add(i);
194
- }
195
- unlink(e) {
196
- T(this, n, O).call(this, { opp: "unlink", args: [e] }, () => {
197
- this._unlinkState(e, true);
198
- });
199
- }
200
- _unlinkState(e, t = false) {
201
- let o = T(this, n, w).call(this, e), i = o.pop(), c = T(this, n, f).call(this, o.join("/"));
202
- if (!Object.prototype.hasOwnProperty.call(c.children, i)) throw new p("ENOENT", "No such file or directory");
203
- let a = c.children[i];
204
- if (a.type !== "file") throw new p("EISDIR", "Is a directory");
205
- if (delete c.children[i], t) {
206
- let h2 = h(this, m).get(a.backingFilename);
207
- h2?.truncate(0), h(this, S).add(h2), h(this, D).has(e) && (h(this, P).delete(h(this, D).get(e)), h(this, D).delete(e));
208
- }
209
- this.state.pool.push(a.backingFilename);
210
- }
211
- utimes(e, t, o) {
212
- T(this, n, O).call(this, { opp: "utimes", args: [e, t, o] }, () => {
213
- this._utimesState(e, t, o);
214
- });
215
- }
216
- _utimesState(e, t, o) {
217
- let i = T(this, n, f).call(this, e);
218
- i.lastModified = o;
219
- }
220
- writeFile(e, t, o) {
221
- let i = T(this, n, w).call(this, e), c = i.pop(), a = T(this, n, f).call(this, i.join("/"));
222
- if (Object.prototype.hasOwnProperty.call(a.children, c)) {
223
- let l = a.children[c];
224
- l.lastModified = Date.now(), T(this, n, k).call(this, { opp: "setLastModified", args: [e, l.lastModified] });
225
- } else {
226
- if (this.state.pool.length === 0) throw new Error("No more file handles available in the pool");
227
- let l = { type: "file", lastModified: Date.now(), mode: o?.mode || T2.FILE, backingFilename: this.state.pool.pop() };
228
- a.children[c] = l, T(this, n, k).call(this, { opp: "createFileNode", args: [e, l] });
229
- }
230
- let h2 = a.children[c], d = h(this, m).get(h2.backingFilename);
231
- t.length > 0 && (d.write(typeof t == "string" ? new TextEncoder().encode(t) : new Uint8Array(t), { at: 0 }), e.startsWith("/pg_wal") && h(this, S).add(d));
232
- }
233
- _createFileNodeState(e, t) {
234
- let o = T(this, n, w).call(this, e), i = o.pop(), c = T(this, n, f).call(this, o.join("/"));
235
- c.children[i] = t;
236
- let a = this.state.pool.indexOf(t.backingFilename);
237
- return a > -1 && this.state.pool.splice(a, 1), t;
238
- }
239
- _setLastModifiedState(e, t) {
240
- let o = T(this, n, f).call(this, e);
241
- o.lastModified = t;
242
- }
243
- write(e, t, o, i, c) {
244
- let a = T(this, n, I).call(this, e), h2 = T(this, n, f).call(this, a);
245
- if (h2.type !== "file") throw new p("EISDIR", "Is a directory");
246
- let d = h(this, m).get(h2.backingFilename);
247
- if (!d) throw new p("EBADF", "Bad file descriptor");
248
- let l = d.write(new Uint8Array(t, o, i), { at: c });
249
- return a.startsWith("/pg_wal") && h(this, S).add(d), l;
250
- }
251
- };
252
- H = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), x2 = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakSet(), C = async function() {
253
- x(this, H, await navigator.storage.getDirectory()), x(this, v, await T(this, n, j).call(this, this.dataDir, { create: true })), x(this, F, await T(this, n, j).call(this, G, { from: h(this, v), create: true })), x(this, M, await h(this, v).getFileHandle($, { create: true })), x(this, y, await h(this, M).createSyncAccessHandle());
254
- let e = new ArrayBuffer(h(this, y).getSize());
255
- h(this, y).read(e, { at: 0 });
256
- let t, o = new TextDecoder().decode(e).split(`
257
- `), i = false;
258
- try {
259
- t = JSON.parse(o[0]);
260
- } catch {
261
- t = { root: { type: "directory", lastModified: Date.now(), mode: T2.DIR, children: {} }, pool: [] }, h(this, y).truncate(0), h(this, y).write(new TextEncoder().encode(JSON.stringify(t)), { at: 0 }), i = true;
262
- }
263
- this.state = t;
264
- let c = o.slice(1).filter(Boolean).map((l) => JSON.parse(l));
265
- for (let l of c) {
266
- let u2 = `_${l.opp}State`;
267
- if (typeof this[u2] == "function") try {
268
- this[u2].bind(this)(...l.args);
269
- } catch (N) {
270
- console.warn("Error applying OPFS AHP WAL entry", l, N);
271
- }
272
- }
273
- let a = [], h2 = async (l) => {
274
- if (l.type === "file") try {
275
- let u2 = await h(this, F).getFileHandle(l.backingFilename), N = await u2.createSyncAccessHandle();
276
- h(this, b).set(l.backingFilename, u2), h(this, m).set(l.backingFilename, N);
277
- } catch (u2) {
278
- console.error("Error opening file handle for node", l, u2);
279
- }
280
- else for (let u2 of Object.values(l.children)) a.push(h2(u2));
281
- };
282
- await h2(this.state.root);
283
- let d = [];
284
- for (let l of this.state.pool) d.push(new Promise(async (u2) => {
285
- h(this, b).has(l) && console.warn("File handle already exists for pool file", l);
286
- let N = await h(this, F).getFileHandle(l), U2 = await N.createSyncAccessHandle();
287
- h(this, b).set(l, N), h(this, m).set(l, U2), u2();
288
- }));
289
- await Promise.all([...a, ...d]), await this.maintainPool(i ? this.initialPoolSize : this.maintainedPoolSize);
290
- }, O = function(e, t) {
291
- let o = T(this, n, k).call(this, e);
292
- try {
293
- t();
294
- } catch (i) {
295
- throw h(this, y).truncate(o), i;
296
- }
297
- }, k = function(e) {
298
- let t = JSON.stringify(e), o = new TextEncoder().encode(`
299
- ${t}`), i = h(this, y).getSize();
300
- return h(this, y).write(o, { at: i }), h(this, S).add(h(this, y)), i;
301
- }, w = function(e) {
302
- return e.split("/").filter(Boolean);
303
- }, f = function(e, t) {
304
- let o = T(this, n, w).call(this, e), i = t || this.state.root;
305
- for (let c of o) {
306
- if (i.type !== "directory") throw new p("ENOTDIR", "Not a directory");
307
- if (!Object.prototype.hasOwnProperty.call(i.children, c)) throw new p("ENOENT", "No such file or directory");
308
- i = i.children[c];
309
- }
310
- return i;
311
- }, I = function(e) {
312
- let t = h(this, P).get(e);
313
- if (!t) throw new p("EBADF", "Bad file descriptor");
314
- return t;
315
- }, W = function() {
316
- let e = ++U(this, x2)._;
317
- for (; h(this, P).has(e); ) U(this, x2)._++;
318
- return e;
319
- }, j = async function(e, t) {
320
- let o = T(this, n, w).call(this, e), i = t?.from || h(this, H);
321
- for (let c of o) i = await i.getDirectoryHandle(c, { create: t?.create });
322
- return i;
323
- };
324
- var p = class extends Error {
325
- constructor(A, e) {
326
- super(e), typeof A == "number" ? this.code = A : typeof A == "string" && (this.code = pr[A]);
327
- }
328
- };
329
- export {
330
- L as OpfsAhpFS
331
- };
332
- //# sourceMappingURL=opfs-ahp-NJO33LVZ.js.map