@mszr/idb-dux 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (453) hide show
  1. package/LICENSE +194 -0
  2. package/README.md +84 -0
  3. package/dist/commonjs/admin/index.d.ts +18 -0
  4. package/dist/commonjs/admin/index.d.ts.map +1 -0
  5. package/dist/commonjs/admin/index.js +31 -0
  6. package/dist/commonjs/admin/index.js.map +1 -0
  7. package/dist/commonjs/admin/init.d.ts +67 -0
  8. package/dist/commonjs/admin/init.d.ts.map +1 -0
  9. package/dist/commonjs/admin/init.js +86 -0
  10. package/dist/commonjs/admin/init.js.map +1 -0
  11. package/dist/commonjs/admin/query.d.ts +21 -0
  12. package/dist/commonjs/admin/query.d.ts.map +1 -0
  13. package/dist/commonjs/admin/query.js +46 -0
  14. package/dist/commonjs/admin/query.js.map +1 -0
  15. package/dist/commonjs/admin/types.d.ts +124 -0
  16. package/dist/commonjs/admin/types.d.ts.map +1 -0
  17. package/dist/commonjs/admin/types.js +3 -0
  18. package/dist/commonjs/admin/types.js.map +1 -0
  19. package/dist/commonjs/admin/webhooks.d.ts +11 -0
  20. package/dist/commonjs/admin/webhooks.d.ts.map +1 -0
  21. package/dist/commonjs/admin/webhooks.js +8 -0
  22. package/dist/commonjs/admin/webhooks.js.map +1 -0
  23. package/dist/commonjs/errors.d.ts +13 -0
  24. package/dist/commonjs/errors.d.ts.map +1 -0
  25. package/dist/commonjs/errors.js +19 -0
  26. package/dist/commonjs/errors.js.map +1 -0
  27. package/dist/commonjs/index.d.ts +13 -0
  28. package/dist/commonjs/index.d.ts.map +1 -0
  29. package/dist/commonjs/index.js +29 -0
  30. package/dist/commonjs/index.js.map +1 -0
  31. package/dist/commonjs/nuxt/defineAuthSyncHandler.d.ts +15 -0
  32. package/dist/commonjs/nuxt/defineAuthSyncHandler.d.ts.map +1 -0
  33. package/dist/commonjs/nuxt/defineAuthSyncHandler.js +44 -0
  34. package/dist/commonjs/nuxt/defineAuthSyncHandler.js.map +1 -0
  35. package/dist/commonjs/nuxt/defineServerKit.d.ts +5 -0
  36. package/dist/commonjs/nuxt/defineServerKit.d.ts.map +1 -0
  37. package/dist/commonjs/nuxt/defineServerKit.js +49 -0
  38. package/dist/commonjs/nuxt/defineServerKit.js.map +1 -0
  39. package/dist/commonjs/nuxt/defineWebhookHandler.d.ts +17 -0
  40. package/dist/commonjs/nuxt/defineWebhookHandler.d.ts.map +1 -0
  41. package/dist/commonjs/nuxt/defineWebhookHandler.js +24 -0
  42. package/dist/commonjs/nuxt/defineWebhookHandler.js.map +1 -0
  43. package/dist/commonjs/nuxt/index.d.ts +15 -0
  44. package/dist/commonjs/nuxt/index.d.ts.map +1 -0
  45. package/dist/commonjs/nuxt/index.js +24 -0
  46. package/dist/commonjs/nuxt/index.js.map +1 -0
  47. package/dist/commonjs/nuxt/types.d.ts +54 -0
  48. package/dist/commonjs/nuxt/types.d.ts.map +1 -0
  49. package/dist/commonjs/nuxt/types.js +3 -0
  50. package/dist/commonjs/nuxt/types.js.map +1 -0
  51. package/dist/commonjs/package.json +3 -0
  52. package/dist/commonjs/perms/ast.d.ts +98 -0
  53. package/dist/commonjs/perms/ast.d.ts.map +1 -0
  54. package/dist/commonjs/perms/ast.js +148 -0
  55. package/dist/commonjs/perms/ast.js.map +1 -0
  56. package/dist/commonjs/perms/builder.d.ts +18 -0
  57. package/dist/commonjs/perms/builder.d.ts.map +1 -0
  58. package/dist/commonjs/perms/builder.js +260 -0
  59. package/dist/commonjs/perms/builder.js.map +1 -0
  60. package/dist/commonjs/perms/context.d.ts +27 -0
  61. package/dist/commonjs/perms/context.d.ts.map +1 -0
  62. package/dist/commonjs/perms/context.js +96 -0
  63. package/dist/commonjs/perms/context.js.map +1 -0
  64. package/dist/commonjs/perms/index.d.ts +13 -0
  65. package/dist/commonjs/perms/index.d.ts.map +1 -0
  66. package/dist/commonjs/perms/index.js +6 -0
  67. package/dist/commonjs/perms/index.js.map +1 -0
  68. package/dist/commonjs/perms/types.d.ts +353 -0
  69. package/dist/commonjs/perms/types.d.ts.map +1 -0
  70. package/dist/commonjs/perms/types.js +3 -0
  71. package/dist/commonjs/perms/types.js.map +1 -0
  72. package/dist/commonjs/perms/validate.d.ts +31 -0
  73. package/dist/commonjs/perms/validate.d.ts.map +1 -0
  74. package/dist/commonjs/perms/validate.js +66 -0
  75. package/dist/commonjs/perms/validate.js.map +1 -0
  76. package/dist/commonjs/query/constants.d.ts +13 -0
  77. package/dist/commonjs/query/constants.d.ts.map +1 -0
  78. package/dist/commonjs/query/constants.js +16 -0
  79. package/dist/commonjs/query/constants.js.map +1 -0
  80. package/dist/commonjs/query/defineQuery.d.ts +33 -0
  81. package/dist/commonjs/query/defineQuery.d.ts.map +1 -0
  82. package/dist/commonjs/query/defineQuery.js +28 -0
  83. package/dist/commonjs/query/defineQuery.js.map +1 -0
  84. package/dist/commonjs/query/index.d.ts +9 -0
  85. package/dist/commonjs/query/index.d.ts.map +1 -0
  86. package/dist/commonjs/query/index.js +16 -0
  87. package/dist/commonjs/query/index.js.map +1 -0
  88. package/dist/commonjs/query/keys.d.ts +33 -0
  89. package/dist/commonjs/query/keys.d.ts.map +1 -0
  90. package/dist/commonjs/query/keys.js +3 -0
  91. package/dist/commonjs/query/keys.js.map +1 -0
  92. package/dist/commonjs/query/shapeResult.d.ts +36 -0
  93. package/dist/commonjs/query/shapeResult.d.ts.map +1 -0
  94. package/dist/commonjs/query/shapeResult.js +173 -0
  95. package/dist/commonjs/query/shapeResult.js.map +1 -0
  96. package/dist/commonjs/query/types.d.ts +187 -0
  97. package/dist/commonjs/query/types.d.ts.map +1 -0
  98. package/dist/commonjs/query/types.js +3 -0
  99. package/dist/commonjs/query/types.js.map +1 -0
  100. package/dist/commonjs/query/validation.d.ts +61 -0
  101. package/dist/commonjs/query/validation.d.ts.map +1 -0
  102. package/dist/commonjs/query/validation.js +3 -0
  103. package/dist/commonjs/query/validation.js.map +1 -0
  104. package/dist/commonjs/query/wire.d.ts +13 -0
  105. package/dist/commonjs/query/wire.d.ts.map +1 -0
  106. package/dist/commonjs/query/wire.js +77 -0
  107. package/dist/commonjs/query/wire.js.map +1 -0
  108. package/dist/commonjs/schema/defineSchema.d.ts +110 -0
  109. package/dist/commonjs/schema/defineSchema.d.ts.map +1 -0
  110. package/dist/commonjs/schema/defineSchema.js +72 -0
  111. package/dist/commonjs/schema/defineSchema.js.map +1 -0
  112. package/dist/commonjs/schema/fields.d.ts +33 -0
  113. package/dist/commonjs/schema/fields.d.ts.map +1 -0
  114. package/dist/commonjs/schema/fields.js +3 -0
  115. package/dist/commonjs/schema/fields.js.map +1 -0
  116. package/dist/commonjs/schema/index.d.ts +9 -0
  117. package/dist/commonjs/schema/index.d.ts.map +1 -0
  118. package/dist/commonjs/schema/index.js +10 -0
  119. package/dist/commonjs/schema/index.js.map +1 -0
  120. package/dist/commonjs/schema/namespace.d.ts +82 -0
  121. package/dist/commonjs/schema/namespace.d.ts.map +1 -0
  122. package/dist/commonjs/schema/namespace.js +37 -0
  123. package/dist/commonjs/schema/namespace.js.map +1 -0
  124. package/dist/commonjs/schema/register.d.ts +37 -0
  125. package/dist/commonjs/schema/register.d.ts.map +1 -0
  126. package/dist/commonjs/schema/register.js +3 -0
  127. package/dist/commonjs/schema/register.js.map +1 -0
  128. package/dist/commonjs/schema/singularize.d.ts +45 -0
  129. package/dist/commonjs/schema/singularize.d.ts.map +1 -0
  130. package/dist/commonjs/schema/singularize.js +47 -0
  131. package/dist/commonjs/schema/singularize.js.map +1 -0
  132. package/dist/commonjs/schema/types.d.ts +39 -0
  133. package/dist/commonjs/schema/types.d.ts.map +1 -0
  134. package/dist/commonjs/schema/types.js +3 -0
  135. package/dist/commonjs/schema/types.js.map +1 -0
  136. package/dist/commonjs/schema/util.d.ts +11 -0
  137. package/dist/commonjs/schema/util.d.ts.map +1 -0
  138. package/dist/commonjs/schema/util.js +3 -0
  139. package/dist/commonjs/schema/util.js.map +1 -0
  140. package/dist/commonjs/tx/index.d.ts +4 -0
  141. package/dist/commonjs/tx/index.d.ts.map +1 -0
  142. package/dist/commonjs/tx/index.js +11 -0
  143. package/dist/commonjs/tx/index.js.map +1 -0
  144. package/dist/commonjs/tx/typedTx.d.ts +15 -0
  145. package/dist/commonjs/tx/typedTx.d.ts.map +1 -0
  146. package/dist/commonjs/tx/typedTx.js +54 -0
  147. package/dist/commonjs/tx/typedTx.js.map +1 -0
  148. package/dist/commonjs/tx/types.d.ts +104 -0
  149. package/dist/commonjs/tx/types.d.ts.map +1 -0
  150. package/dist/commonjs/tx/types.js +3 -0
  151. package/dist/commonjs/tx/types.js.map +1 -0
  152. package/dist/commonjs/vue/baseline/InstantDuxDatabase.d.ts +52 -0
  153. package/dist/commonjs/vue/baseline/InstantDuxDatabase.d.ts.map +1 -0
  154. package/dist/commonjs/vue/baseline/InstantDuxDatabase.js +157 -0
  155. package/dist/commonjs/vue/baseline/InstantDuxDatabase.js.map +1 -0
  156. package/dist/commonjs/vue/baseline/InstantDuxRoom.d.ts +72 -0
  157. package/dist/commonjs/vue/baseline/InstantDuxRoom.d.ts.map +1 -0
  158. package/dist/commonjs/vue/baseline/InstantDuxRoom.js +211 -0
  159. package/dist/commonjs/vue/baseline/InstantDuxRoom.js.map +1 -0
  160. package/dist/commonjs/vue/baseline/components/Cursor.d.ts +15 -0
  161. package/dist/commonjs/vue/baseline/components/Cursor.d.ts.map +1 -0
  162. package/dist/commonjs/vue/baseline/components/Cursor.js +39 -0
  163. package/dist/commonjs/vue/baseline/components/Cursor.js.map +1 -0
  164. package/dist/commonjs/vue/baseline/components/Cursors.d.ts +65 -0
  165. package/dist/commonjs/vue/baseline/components/Cursors.d.ts.map +1 -0
  166. package/dist/commonjs/vue/baseline/components/Cursors.js +113 -0
  167. package/dist/commonjs/vue/baseline/components/Cursors.js.map +1 -0
  168. package/dist/commonjs/vue/baseline/components/auth.d.ts +37 -0
  169. package/dist/commonjs/vue/baseline/components/auth.d.ts.map +1 -0
  170. package/dist/commonjs/vue/baseline/components/auth.js +27 -0
  171. package/dist/commonjs/vue/baseline/components/auth.js.map +1 -0
  172. package/dist/commonjs/vue/baseline/index.d.ts +11 -0
  173. package/dist/commonjs/vue/baseline/index.d.ts.map +1 -0
  174. package/dist/commonjs/vue/baseline/index.js +29 -0
  175. package/dist/commonjs/vue/baseline/index.js.map +1 -0
  176. package/dist/commonjs/vue/baseline/useInfiniteQuery.d.ts +19 -0
  177. package/dist/commonjs/vue/baseline/useInfiniteQuery.d.ts.map +1 -0
  178. package/dist/commonjs/vue/baseline/useInfiniteQuery.js +65 -0
  179. package/dist/commonjs/vue/baseline/useInfiniteQuery.js.map +1 -0
  180. package/dist/commonjs/vue/baseline/utils.d.ts +9 -0
  181. package/dist/commonjs/vue/baseline/utils.d.ts.map +1 -0
  182. package/dist/commonjs/vue/baseline/utils.js +29 -0
  183. package/dist/commonjs/vue/baseline/utils.js.map +1 -0
  184. package/dist/commonjs/vue/baseline/version.d.ts +3 -0
  185. package/dist/commonjs/vue/baseline/version.d.ts.map +1 -0
  186. package/dist/commonjs/vue/baseline/version.js +6 -0
  187. package/dist/commonjs/vue/baseline/version.js.map +1 -0
  188. package/dist/commonjs/vue/index.d.ts +21 -0
  189. package/dist/commonjs/vue/index.d.ts.map +1 -0
  190. package/dist/commonjs/vue/index.js +31 -0
  191. package/dist/commonjs/vue/index.js.map +1 -0
  192. package/dist/commonjs/vue/overlay/db.d.ts +106 -0
  193. package/dist/commonjs/vue/overlay/db.d.ts.map +1 -0
  194. package/dist/commonjs/vue/overlay/db.js +105 -0
  195. package/dist/commonjs/vue/overlay/db.js.map +1 -0
  196. package/dist/commonjs/vue/overlay/defineDb.d.ts +34 -0
  197. package/dist/commonjs/vue/overlay/defineDb.d.ts.map +1 -0
  198. package/dist/commonjs/vue/overlay/defineDb.js +48 -0
  199. package/dist/commonjs/vue/overlay/defineDb.js.map +1 -0
  200. package/dist/commonjs/vue/overlay/result.d.ts +29 -0
  201. package/dist/commonjs/vue/overlay/result.d.ts.map +1 -0
  202. package/dist/commonjs/vue/overlay/result.js +75 -0
  203. package/dist/commonjs/vue/overlay/result.js.map +1 -0
  204. package/dist/commonjs/vue/overlay/rooms/index.d.ts +79 -0
  205. package/dist/commonjs/vue/overlay/rooms/index.d.ts.map +1 -0
  206. package/dist/commonjs/vue/overlay/rooms/index.js +28 -0
  207. package/dist/commonjs/vue/overlay/rooms/index.js.map +1 -0
  208. package/dist/commonjs/vue/overlay/types.d.ts +73 -0
  209. package/dist/commonjs/vue/overlay/types.d.ts.map +1 -0
  210. package/dist/commonjs/vue/overlay/types.js +3 -0
  211. package/dist/commonjs/vue/overlay/types.js.map +1 -0
  212. package/dist/commonjs/webhooks/defineWebhookHandlers.d.ts +27 -0
  213. package/dist/commonjs/webhooks/defineWebhookHandlers.d.ts.map +1 -0
  214. package/dist/commonjs/webhooks/defineWebhookHandlers.js +33 -0
  215. package/dist/commonjs/webhooks/defineWebhookHandlers.js.map +1 -0
  216. package/dist/commonjs/webhooks/index.d.ts +15 -0
  217. package/dist/commonjs/webhooks/index.d.ts.map +1 -0
  218. package/dist/commonjs/webhooks/index.js +21 -0
  219. package/dist/commonjs/webhooks/index.js.map +1 -0
  220. package/dist/commonjs/webhooks/init.d.ts +13 -0
  221. package/dist/commonjs/webhooks/init.d.ts.map +1 -0
  222. package/dist/commonjs/webhooks/init.js +39 -0
  223. package/dist/commonjs/webhooks/init.js.map +1 -0
  224. package/dist/commonjs/webhooks/types.d.ts +136 -0
  225. package/dist/commonjs/webhooks/types.d.ts.map +1 -0
  226. package/dist/commonjs/webhooks/types.js +3 -0
  227. package/dist/commonjs/webhooks/types.js.map +1 -0
  228. package/dist/esm/admin/index.d.ts +18 -0
  229. package/dist/esm/admin/index.d.ts.map +1 -0
  230. package/dist/esm/admin/index.js +21 -0
  231. package/dist/esm/admin/index.js.map +1 -0
  232. package/dist/esm/admin/init.d.ts +67 -0
  233. package/dist/esm/admin/init.d.ts.map +1 -0
  234. package/dist/esm/admin/init.js +81 -0
  235. package/dist/esm/admin/init.js.map +1 -0
  236. package/dist/esm/admin/query.d.ts +21 -0
  237. package/dist/esm/admin/query.d.ts.map +1 -0
  238. package/dist/esm/admin/query.js +42 -0
  239. package/dist/esm/admin/query.js.map +1 -0
  240. package/dist/esm/admin/types.d.ts +124 -0
  241. package/dist/esm/admin/types.d.ts.map +1 -0
  242. package/dist/esm/admin/types.js +2 -0
  243. package/dist/esm/admin/types.js.map +1 -0
  244. package/dist/esm/admin/webhooks.d.ts +11 -0
  245. package/dist/esm/admin/webhooks.d.ts.map +1 -0
  246. package/dist/esm/admin/webhooks.js +5 -0
  247. package/dist/esm/admin/webhooks.js.map +1 -0
  248. package/dist/esm/errors.d.ts +13 -0
  249. package/dist/esm/errors.d.ts.map +1 -0
  250. package/dist/esm/errors.js +16 -0
  251. package/dist/esm/errors.js.map +1 -0
  252. package/dist/esm/index.d.ts +13 -0
  253. package/dist/esm/index.d.ts.map +1 -0
  254. package/dist/esm/index.js +13 -0
  255. package/dist/esm/index.js.map +1 -0
  256. package/dist/esm/nuxt/defineAuthSyncHandler.d.ts +15 -0
  257. package/dist/esm/nuxt/defineAuthSyncHandler.d.ts.map +1 -0
  258. package/dist/esm/nuxt/defineAuthSyncHandler.js +41 -0
  259. package/dist/esm/nuxt/defineAuthSyncHandler.js.map +1 -0
  260. package/dist/esm/nuxt/defineServerKit.d.ts +5 -0
  261. package/dist/esm/nuxt/defineServerKit.d.ts.map +1 -0
  262. package/dist/esm/nuxt/defineServerKit.js +46 -0
  263. package/dist/esm/nuxt/defineServerKit.js.map +1 -0
  264. package/dist/esm/nuxt/defineWebhookHandler.d.ts +17 -0
  265. package/dist/esm/nuxt/defineWebhookHandler.d.ts.map +1 -0
  266. package/dist/esm/nuxt/defineWebhookHandler.js +21 -0
  267. package/dist/esm/nuxt/defineWebhookHandler.js.map +1 -0
  268. package/dist/esm/nuxt/index.d.ts +15 -0
  269. package/dist/esm/nuxt/index.d.ts.map +1 -0
  270. package/dist/esm/nuxt/index.js +17 -0
  271. package/dist/esm/nuxt/index.js.map +1 -0
  272. package/dist/esm/nuxt/types.d.ts +54 -0
  273. package/dist/esm/nuxt/types.d.ts.map +1 -0
  274. package/dist/esm/nuxt/types.js +2 -0
  275. package/dist/esm/nuxt/types.js.map +1 -0
  276. package/dist/esm/package.json +3 -0
  277. package/dist/esm/perms/ast.d.ts +98 -0
  278. package/dist/esm/perms/ast.d.ts.map +1 -0
  279. package/dist/esm/perms/ast.js +140 -0
  280. package/dist/esm/perms/ast.js.map +1 -0
  281. package/dist/esm/perms/builder.d.ts +18 -0
  282. package/dist/esm/perms/builder.d.ts.map +1 -0
  283. package/dist/esm/perms/builder.js +257 -0
  284. package/dist/esm/perms/builder.js.map +1 -0
  285. package/dist/esm/perms/context.d.ts +27 -0
  286. package/dist/esm/perms/context.d.ts.map +1 -0
  287. package/dist/esm/perms/context.js +93 -0
  288. package/dist/esm/perms/context.js.map +1 -0
  289. package/dist/esm/perms/index.d.ts +13 -0
  290. package/dist/esm/perms/index.d.ts.map +1 -0
  291. package/dist/esm/perms/index.js +2 -0
  292. package/dist/esm/perms/index.js.map +1 -0
  293. package/dist/esm/perms/types.d.ts +353 -0
  294. package/dist/esm/perms/types.d.ts.map +1 -0
  295. package/dist/esm/perms/types.js +2 -0
  296. package/dist/esm/perms/types.js.map +1 -0
  297. package/dist/esm/perms/validate.d.ts +31 -0
  298. package/dist/esm/perms/validate.d.ts.map +1 -0
  299. package/dist/esm/perms/validate.js +61 -0
  300. package/dist/esm/perms/validate.js.map +1 -0
  301. package/dist/esm/query/constants.d.ts +13 -0
  302. package/dist/esm/query/constants.d.ts.map +1 -0
  303. package/dist/esm/query/constants.js +13 -0
  304. package/dist/esm/query/constants.js.map +1 -0
  305. package/dist/esm/query/defineQuery.d.ts +33 -0
  306. package/dist/esm/query/defineQuery.d.ts.map +1 -0
  307. package/dist/esm/query/defineQuery.js +24 -0
  308. package/dist/esm/query/defineQuery.js.map +1 -0
  309. package/dist/esm/query/index.d.ts +9 -0
  310. package/dist/esm/query/index.d.ts.map +1 -0
  311. package/dist/esm/query/index.js +5 -0
  312. package/dist/esm/query/index.js.map +1 -0
  313. package/dist/esm/query/keys.d.ts +33 -0
  314. package/dist/esm/query/keys.d.ts.map +1 -0
  315. package/dist/esm/query/keys.js +2 -0
  316. package/dist/esm/query/keys.js.map +1 -0
  317. package/dist/esm/query/shapeResult.d.ts +36 -0
  318. package/dist/esm/query/shapeResult.d.ts.map +1 -0
  319. package/dist/esm/query/shapeResult.js +168 -0
  320. package/dist/esm/query/shapeResult.js.map +1 -0
  321. package/dist/esm/query/types.d.ts +187 -0
  322. package/dist/esm/query/types.d.ts.map +1 -0
  323. package/dist/esm/query/types.js +2 -0
  324. package/dist/esm/query/types.js.map +1 -0
  325. package/dist/esm/query/validation.d.ts +61 -0
  326. package/dist/esm/query/validation.d.ts.map +1 -0
  327. package/dist/esm/query/validation.js +2 -0
  328. package/dist/esm/query/validation.js.map +1 -0
  329. package/dist/esm/query/wire.d.ts +13 -0
  330. package/dist/esm/query/wire.d.ts.map +1 -0
  331. package/dist/esm/query/wire.js +74 -0
  332. package/dist/esm/query/wire.js.map +1 -0
  333. package/dist/esm/schema/defineSchema.d.ts +110 -0
  334. package/dist/esm/schema/defineSchema.d.ts.map +1 -0
  335. package/dist/esm/schema/defineSchema.js +69 -0
  336. package/dist/esm/schema/defineSchema.js.map +1 -0
  337. package/dist/esm/schema/fields.d.ts +33 -0
  338. package/dist/esm/schema/fields.d.ts.map +1 -0
  339. package/dist/esm/schema/fields.js +2 -0
  340. package/dist/esm/schema/fields.js.map +1 -0
  341. package/dist/esm/schema/index.d.ts +9 -0
  342. package/dist/esm/schema/index.d.ts.map +1 -0
  343. package/dist/esm/schema/index.js +4 -0
  344. package/dist/esm/schema/index.js.map +1 -0
  345. package/dist/esm/schema/namespace.d.ts +82 -0
  346. package/dist/esm/schema/namespace.d.ts.map +1 -0
  347. package/dist/esm/schema/namespace.js +34 -0
  348. package/dist/esm/schema/namespace.js.map +1 -0
  349. package/dist/esm/schema/register.d.ts +37 -0
  350. package/dist/esm/schema/register.d.ts.map +1 -0
  351. package/dist/esm/schema/register.js +2 -0
  352. package/dist/esm/schema/register.js.map +1 -0
  353. package/dist/esm/schema/singularize.d.ts +45 -0
  354. package/dist/esm/schema/singularize.d.ts.map +1 -0
  355. package/dist/esm/schema/singularize.js +44 -0
  356. package/dist/esm/schema/singularize.js.map +1 -0
  357. package/dist/esm/schema/types.d.ts +39 -0
  358. package/dist/esm/schema/types.d.ts.map +1 -0
  359. package/dist/esm/schema/types.js +2 -0
  360. package/dist/esm/schema/types.js.map +1 -0
  361. package/dist/esm/schema/util.d.ts +11 -0
  362. package/dist/esm/schema/util.d.ts.map +1 -0
  363. package/dist/esm/schema/util.js +2 -0
  364. package/dist/esm/schema/util.js.map +1 -0
  365. package/dist/esm/tx/index.d.ts +4 -0
  366. package/dist/esm/tx/index.d.ts.map +1 -0
  367. package/dist/esm/tx/index.js +5 -0
  368. package/dist/esm/tx/index.js.map +1 -0
  369. package/dist/esm/tx/typedTx.d.ts +15 -0
  370. package/dist/esm/tx/typedTx.d.ts.map +1 -0
  371. package/dist/esm/tx/typedTx.js +51 -0
  372. package/dist/esm/tx/typedTx.js.map +1 -0
  373. package/dist/esm/tx/types.d.ts +104 -0
  374. package/dist/esm/tx/types.d.ts.map +1 -0
  375. package/dist/esm/tx/types.js +2 -0
  376. package/dist/esm/tx/types.js.map +1 -0
  377. package/dist/esm/vue/baseline/InstantDuxDatabase.d.ts +52 -0
  378. package/dist/esm/vue/baseline/InstantDuxDatabase.d.ts.map +1 -0
  379. package/dist/esm/vue/baseline/InstantDuxDatabase.js +149 -0
  380. package/dist/esm/vue/baseline/InstantDuxDatabase.js.map +1 -0
  381. package/dist/esm/vue/baseline/InstantDuxRoom.d.ts +72 -0
  382. package/dist/esm/vue/baseline/InstantDuxRoom.d.ts.map +1 -0
  383. package/dist/esm/vue/baseline/InstantDuxRoom.js +202 -0
  384. package/dist/esm/vue/baseline/InstantDuxRoom.js.map +1 -0
  385. package/dist/esm/vue/baseline/components/Cursor.d.ts +15 -0
  386. package/dist/esm/vue/baseline/components/Cursor.d.ts.map +1 -0
  387. package/dist/esm/vue/baseline/components/Cursor.js +36 -0
  388. package/dist/esm/vue/baseline/components/Cursor.js.map +1 -0
  389. package/dist/esm/vue/baseline/components/Cursors.d.ts +65 -0
  390. package/dist/esm/vue/baseline/components/Cursors.d.ts.map +1 -0
  391. package/dist/esm/vue/baseline/components/Cursors.js +107 -0
  392. package/dist/esm/vue/baseline/components/Cursors.js.map +1 -0
  393. package/dist/esm/vue/baseline/components/auth.d.ts +37 -0
  394. package/dist/esm/vue/baseline/components/auth.d.ts.map +1 -0
  395. package/dist/esm/vue/baseline/components/auth.js +24 -0
  396. package/dist/esm/vue/baseline/components/auth.js.map +1 -0
  397. package/dist/esm/vue/baseline/index.d.ts +11 -0
  398. package/dist/esm/vue/baseline/index.d.ts.map +1 -0
  399. package/dist/esm/vue/baseline/index.js +10 -0
  400. package/dist/esm/vue/baseline/index.js.map +1 -0
  401. package/dist/esm/vue/baseline/useInfiniteQuery.d.ts +19 -0
  402. package/dist/esm/vue/baseline/useInfiniteQuery.d.ts.map +1 -0
  403. package/dist/esm/vue/baseline/useInfiniteQuery.js +62 -0
  404. package/dist/esm/vue/baseline/useInfiniteQuery.js.map +1 -0
  405. package/dist/esm/vue/baseline/utils.d.ts +9 -0
  406. package/dist/esm/vue/baseline/utils.d.ts.map +1 -0
  407. package/dist/esm/vue/baseline/utils.js +25 -0
  408. package/dist/esm/vue/baseline/utils.js.map +1 -0
  409. package/dist/esm/vue/baseline/version.d.ts +3 -0
  410. package/dist/esm/vue/baseline/version.d.ts.map +1 -0
  411. package/dist/esm/vue/baseline/version.js +4 -0
  412. package/dist/esm/vue/baseline/version.js.map +1 -0
  413. package/dist/esm/vue/index.d.ts +21 -0
  414. package/dist/esm/vue/index.d.ts.map +1 -0
  415. package/dist/esm/vue/index.js +18 -0
  416. package/dist/esm/vue/index.js.map +1 -0
  417. package/dist/esm/vue/overlay/db.d.ts +106 -0
  418. package/dist/esm/vue/overlay/db.d.ts.map +1 -0
  419. package/dist/esm/vue/overlay/db.js +101 -0
  420. package/dist/esm/vue/overlay/db.js.map +1 -0
  421. package/dist/esm/vue/overlay/defineDb.d.ts +34 -0
  422. package/dist/esm/vue/overlay/defineDb.d.ts.map +1 -0
  423. package/dist/esm/vue/overlay/defineDb.js +44 -0
  424. package/dist/esm/vue/overlay/defineDb.js.map +1 -0
  425. package/dist/esm/vue/overlay/result.d.ts +29 -0
  426. package/dist/esm/vue/overlay/result.d.ts.map +1 -0
  427. package/dist/esm/vue/overlay/result.js +71 -0
  428. package/dist/esm/vue/overlay/result.js.map +1 -0
  429. package/dist/esm/vue/overlay/rooms/index.d.ts +79 -0
  430. package/dist/esm/vue/overlay/rooms/index.d.ts.map +1 -0
  431. package/dist/esm/vue/overlay/rooms/index.js +25 -0
  432. package/dist/esm/vue/overlay/rooms/index.js.map +1 -0
  433. package/dist/esm/vue/overlay/types.d.ts +73 -0
  434. package/dist/esm/vue/overlay/types.d.ts.map +1 -0
  435. package/dist/esm/vue/overlay/types.js +2 -0
  436. package/dist/esm/vue/overlay/types.js.map +1 -0
  437. package/dist/esm/webhooks/defineWebhookHandlers.d.ts +27 -0
  438. package/dist/esm/webhooks/defineWebhookHandlers.d.ts.map +1 -0
  439. package/dist/esm/webhooks/defineWebhookHandlers.js +30 -0
  440. package/dist/esm/webhooks/defineWebhookHandlers.js.map +1 -0
  441. package/dist/esm/webhooks/index.d.ts +15 -0
  442. package/dist/esm/webhooks/index.d.ts.map +1 -0
  443. package/dist/esm/webhooks/index.js +14 -0
  444. package/dist/esm/webhooks/index.js.map +1 -0
  445. package/dist/esm/webhooks/init.d.ts +13 -0
  446. package/dist/esm/webhooks/init.d.ts.map +1 -0
  447. package/dist/esm/webhooks/init.js +36 -0
  448. package/dist/esm/webhooks/init.js.map +1 -0
  449. package/dist/esm/webhooks/types.d.ts +136 -0
  450. package/dist/esm/webhooks/types.d.ts.map +1 -0
  451. package/dist/esm/webhooks/types.js +2 -0
  452. package/dist/esm/webhooks/types.js.map +1 -0
  453. package/package.json +149 -0
@@ -0,0 +1,101 @@
1
+ import { InstantError } from '@instantdb/core';
2
+ /**
3
+ * The enhanced db — the only public client surface. A thin overlay over the
4
+ * vendored baseline ([dux-spec-vue.md §1]): hooks compose baseline hooks and
5
+ * reshape through the pure `shapeResult`, never forking the baseline. SSR
6
+ * resilience comes from the baseline guards; shaping and the result pattern
7
+ * are added here.
8
+ */
9
+ import { computed, toValue } from 'vue';
10
+ import { resultKeys, shapeResult, shapingSchema, toWireQuery } from '../../query/index.js';
11
+ import { typedTx } from '../../tx/index.js';
12
+ import { makeDynamicResult, makeResult } from './result.js';
13
+ import { rooms as overlayRooms } from './rooms/index.js';
14
+ export class IdbClient {
15
+ /** The schema-typed tx chain — shared machinery with `/admin` ([root §5]). */
16
+ tx = typedTx();
17
+ /** Rooms hooks — stateful ones return the result pattern ([§6]). */
18
+ rooms = overlayRooms;
19
+ #baseline;
20
+ #schema;
21
+ constructor(baseline, schema) {
22
+ this.#baseline = baseline;
23
+ this.#schema = shapingSchema(schema);
24
+ }
25
+ // ----- pass-throughs to the baseline -----
26
+ get auth() {
27
+ return this.#baseline.auth;
28
+ }
29
+ get storage() {
30
+ return this.#baseline.storage;
31
+ }
32
+ get streams() {
33
+ return this.#baseline.streams;
34
+ }
35
+ transact = (chunks) => this.#baseline.transact(chunks);
36
+ getAuth = () => this.#baseline.getAuth();
37
+ getLocalId = (name) => this.#baseline.getLocalId(name);
38
+ room = ((type, id) => this.#baseline.room(type, id));
39
+ // ----- the data plane -----
40
+ /**
41
+ * Subscribe to a query. Destructure top-level scopes directly — full
42
+ * shaping ($only/$at/$as/$m, array normalization, singularization) per the
43
+ * root spec, plus the result pattern. A factory returning `null` pauses.
44
+ */
45
+ useQuery = (query, opts) => {
46
+ const duxQuery = computed(() => toValue(query));
47
+ const base = this.#baseline.useQuery((() => {
48
+ const q = duxQuery.value;
49
+ return q ? toWireQuery(q) : null;
50
+ }), opts);
51
+ const shaped = computed(() => {
52
+ const q = duxQuery.value;
53
+ return q ? shapeResult(base.data.value, q, this.#schema) : {};
54
+ });
55
+ return makeDynamicResult({ isLoading: base.isLoading, error: base.error, pageInfo: base.pageInfo }, key => computed(() => shaped.value[key]));
56
+ };
57
+ /** Imperative one-shot with identical shaping — plain shaped data, no refs. */
58
+ queryOnce = async (query, opts) => {
59
+ const { data } = await this.#baseline.queryOnce(toWireQuery(query), opts);
60
+ return shapeResult(data, query, this.#schema);
61
+ };
62
+ /** The data plane, paginated — same shaping, plus `loadNextPage`. */
63
+ useInfiniteQuery = (query, opts) => {
64
+ const duxQuery = computed(() => toValue(query));
65
+ const base = this.#baseline.useInfiniteQuery((() => {
66
+ const q = duxQuery.value;
67
+ return q ? toWireQuery(q) : null;
68
+ }), opts);
69
+ const shaped = computed(() => {
70
+ const q = duxQuery.value;
71
+ return q ? shapeResult(base.data.value, q, this.#schema) : {};
72
+ });
73
+ return makeDynamicResult({ isLoading: base.isLoading, error: base.error, canLoadNextPage: base.canLoadNextPage }, key => computed(() => shaped.value[key]), { loadNextPage: base.loadNextPage });
74
+ };
75
+ // ----- auth, connection, identity -----
76
+ useAuth = () => {
77
+ const { isLoading, user, error } = this.#baseline.useAuth();
78
+ // dux types `user` as IdbAuthUser | undefined — fold the official null.
79
+ const userRef = computed(() => user.value ?? undefined);
80
+ return makeResult({ isLoading, user: userRef, error });
81
+ };
82
+ useUser(opts) {
83
+ const { user } = this.useAuth();
84
+ return computed(() => {
85
+ if (!user.value && opts?.requireUser) {
86
+ throw new InstantError('useUser({ requireUser: true }) must be used behind an auth gate');
87
+ }
88
+ return user.value;
89
+ });
90
+ }
91
+ useConnectionStatus = () => {
92
+ const status = this.#baseline.useConnectionStatus();
93
+ return makeResult({ status });
94
+ };
95
+ useLocalId = (name) => {
96
+ const localId = this.#baseline.useLocalId(name);
97
+ return makeResult({ localId });
98
+ };
99
+ }
100
+ void resultKeys; // exported utility; kept available for tooling
101
+ //# sourceMappingURL=db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","sourceRoot":"","sources":["../../../../src/vue/overlay/db.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC1F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAKxD,MAAM,OAAO,SAAS;IACpB,8EAA8E;IAC9D,EAAE,GAAa,OAAO,EAAK,CAAA;IAC3C,oEAAoE;IACpD,KAAK,GAAG,YAAY,CAAA;IAE3B,SAAS,CAAuB;IAChC,OAAO,CAAW;IAE3B,YAAY,QAA+B,EAAE,MAA6B;QACxE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC;IAED,4CAA4C;IAE5C,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAA;IAC/B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAA;IAC/B,CAAC;IAED,QAAQ,GAAG,CAAC,MAAiD,EAAE,EAAE,CAC/D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAa,CAAC,CAAA;IAExC,OAAO,GAAG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AC,CAAA;CACF;AAED,KAAK,UAAU,CAAA,CAAC,+CAA+C","sourcesContent":["import type { ComputedRef, MaybeRefOrGetter } from 'vue'\nimport type { IdbQueryData, IdbQueryOptions, IdbValidQuery } from '../../query/index.js'\nimport type { IdbSchema } from '../../schema/defineSchema.js'\nimport type { IdbRegisteredSchema } from '../../schema/register.js'\nimport type { IdbTx, IdbTxChunkInput } from '../../tx/index.js'\nimport type { InstantDuxDatabase } from '../baseline/index.js'\nimport type {\n IdbAuthResult,\n IdbAuthUser,\n IdbConnectionResult,\n IdbInfiniteQueryResult,\n IdbLocalIdResult,\n IdbQueryResult,\n IdbUserOptions,\n} from './types.js'\nimport { InstantError } from '@instantdb/core'\n/**\n * The enhanced db — the only public client surface. A thin overlay over the\n * vendored baseline ([dux-spec-vue.md §1]): hooks compose baseline hooks and\n * reshape through the pure `shapeResult`, never forking the baseline. SSR\n * resilience comes from the baseline guards; shaping and the result pattern\n * are added here.\n */\nimport { computed, toValue } from 'vue'\nimport { resultKeys, shapeResult, shapingSchema, toWireQuery } from '../../query/index.js'\nimport { typedTx } from '../../tx/index.js'\nimport { makeDynamicResult, makeResult } from './result.js'\nimport { rooms as overlayRooms } from './rooms/index.js'\n\n/** A query input: a query, a ref/getter of one, or a factory returning null to pause. */\ntype QueryInput<Q> = MaybeRefOrGetter<Q | null>\n\nexport class IdbClient<S extends IdbSchema = IdbRegisteredSchema> {\n /** The schema-typed tx chain — shared machinery with `/admin` ([root §5]). */\n public readonly tx: IdbTx<S> = typedTx<S>()\n /** Rooms hooks — stateful ones return the result pattern ([§6]). */\n public readonly rooms = overlayRooms\n\n readonly #baseline: InstantDuxDatabase<S>\n readonly #schema: IdbSchema\n\n constructor(baseline: InstantDuxDatabase<S>, schema: IdbSchema | undefined) {\n this.#baseline = baseline\n this.#schema = shapingSchema(schema)\n }\n\n // ----- pass-throughs to the baseline -----\n\n get auth() {\n return this.#baseline.auth\n }\n\n get storage() {\n return this.#baseline.storage\n }\n\n get streams() {\n return this.#baseline.streams\n }\n\n transact = (chunks: IdbTxChunkInput<S> | IdbTxChunkInput<S>[]) =>\n this.#baseline.transact(chunks as any)\n\n getAuth = (): Promise<IdbAuthUser | null> => this.#baseline.getAuth()\n getLocalId = (name: string): Promise<string> => this.#baseline.getLocalId(name)\n\n room = ((type?: any, id?: any) => this.#baseline.room(type, id)) as\n InstantDuxDatabase<S>['room']\n\n // ----- the data plane -----\n\n /**\n * Subscribe to a query. Destructure top-level scopes directly — full\n * shaping ($only/$at/$as/$m, array normalization, singularization) per the\n * root spec, plus the result pattern. A factory returning `null` pauses.\n */\n useQuery = <const Q extends IdbValidQuery<Q, S>>(\n query: QueryInput<Q>,\n opts?: MaybeRefOrGetter<IdbQueryOptions<S> | null | undefined>,\n ): IdbQueryResult<Q, S> => {\n const duxQuery = computed(() => toValue(query) as Record<string, any> | null)\n const base = this.#baseline.useQuery(\n (() => {\n const q = duxQuery.value\n return q ? toWireQuery(q) : null\n }) as any,\n opts as any,\n )\n const shaped = computed(() => {\n const q = duxQuery.value\n return q ? shapeResult(base.data.value, q, this.#schema) : {}\n })\n return makeDynamicResult(\n { isLoading: base.isLoading, error: base.error, pageInfo: base.pageInfo },\n key => computed(() => shaped.value[key]),\n )\n }\n\n /** Imperative one-shot with identical shaping — plain shaped data, no refs. */\n queryOnce = async <const Q extends IdbValidQuery<Q, S>>(\n query: Q,\n opts?: IdbQueryOptions<S>,\n ): Promise<IdbQueryData<Q, S>> => {\n const { data } = await this.#baseline.queryOnce(\n toWireQuery(query as Record<string, any>) as any,\n opts as any,\n )\n return shapeResult(data, query as Record<string, any>, this.#schema) as IdbQueryData<Q, S>\n }\n\n /** The data plane, paginated — same shaping, plus `loadNextPage`. */\n useInfiniteQuery = <const Q extends IdbValidQuery<Q, S>>(\n query: QueryInput<Q>,\n opts?: MaybeRefOrGetter<IdbQueryOptions<S> | undefined>,\n ): IdbInfiniteQueryResult<Q, S> => {\n const duxQuery = computed(() => toValue(query) as Record<string, any> | null)\n const base = this.#baseline.useInfiniteQuery(\n (() => {\n const q = duxQuery.value\n return q ? toWireQuery(q) : null\n }) as any,\n opts as any,\n )\n const shaped = computed(() => {\n const q = duxQuery.value\n return q ? shapeResult(base.data.value, q, this.#schema) : {}\n })\n return makeDynamicResult(\n { isLoading: base.isLoading, error: base.error, canLoadNextPage: base.canLoadNextPage },\n key => computed(() => shaped.value[key]),\n { loadNextPage: base.loadNextPage },\n )\n }\n\n // ----- auth, connection, identity -----\n\n useAuth = (): IdbAuthResult => {\n const { isLoading, user, error } = this.#baseline.useAuth()\n // dux types `user` as IdbAuthUser | undefined — fold the official null.\n const userRef = computed(() => user.value ?? undefined)\n return makeResult({ isLoading, user: userRef, error })\n }\n\n /**\n * The user-centric projection. `requireUser: true` types `user` present and\n * throws at access when there's none; the default leaves it optional.\n */\n useUser(opts: { requireUser: true }): ComputedRef<IdbAuthUser>\n useUser(opts?: IdbUserOptions): ComputedRef<IdbAuthUser | undefined>\n useUser(opts?: IdbUserOptions): ComputedRef<IdbAuthUser | undefined> {\n const { user } = this.useAuth()\n return computed(() => {\n if (!user.value && opts?.requireUser) {\n throw new InstantError(\n 'useUser({ requireUser: true }) must be used behind an auth gate',\n )\n }\n return user.value\n })\n }\n\n useConnectionStatus = (): IdbConnectionResult => {\n const status = this.#baseline.useConnectionStatus()\n return makeResult({ status })\n }\n\n useLocalId = (name: MaybeRefOrGetter<string>): IdbLocalIdResult => {\n const localId = this.#baseline.useLocalId(name)\n return makeResult({ localId })\n }\n}\n\nvoid resultKeys // exported utility; kept available for tooling\n"]}
@@ -0,0 +1,34 @@
1
+ import type { IdbSchema } from '../../schema/defineSchema.js';
2
+ import type { IdbRegisteredSchema } from '../../schema/register.js';
3
+ import type { IdbClientConfig } from './types.js';
4
+ import { IdbClient } from './db.js';
5
+ /**
6
+ * Build the db eagerly — for apps whose config is available at module load.
7
+ *
8
+ * The client is `markRaw`'d: it is a stable handle, not reactive state (its
9
+ * reactivity lives in the refs its hooks return), so it must never be wrapped
10
+ * in a reactive proxy. Storing it in a Pinia store or `reactive()` is the
11
+ * normal case, and a proxy would break the pass-through getters (`auth`,
12
+ * `storage`, `streams`) — reading a private field through a proxy throws. This
13
+ * makes the client proxy-safe with zero userland ceremony.
14
+ */
15
+ export declare function init<S extends IdbSchema = IdbRegisteredSchema>(config: IdbClientConfig<S>): IdbClient<S>;
16
+ /** `defineDb` options: the schema, a lazy `getAppId`, and the rest of config. */
17
+ export type IdbDefineDbOptions<S extends IdbSchema> = Omit<IdbClientConfig<S>, 'appId'> & {
18
+ /** Resolved on first use (framework runtime config, env indirection, …). */
19
+ getAppId: () => string;
20
+ };
21
+ /**
22
+ * Returns a factory: the first call resolves config and creates the db;
23
+ * subsequent calls return the same instance. No framework-wide singleton —
24
+ * global state stays the app's responsibility.
25
+ *
26
+ * @example
27
+ * export const useDb = defineDb({
28
+ * schema,
29
+ * getAppId: () => useRuntimeConfig().public.instantAppId,
30
+ * firstPartyPath: '/api/idb',
31
+ * })
32
+ */
33
+ export declare function defineDb<S extends IdbSchema = IdbRegisteredSchema>(options: IdbDefineDbOptions<S>): () => IdbClient<S>;
34
+ //# sourceMappingURL=defineDb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineDb.d.ts","sourceRoot":"","sources":["../../../../src/vue/overlay/defineDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAQjD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,GAAG,mBAAmB,EAC5D,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,GACzB,SAAS,CAAC,CAAC,CAAC,CAGd;AAED,iFAAiF;AACjF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG;IACxF,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,MAAM,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,GAAG,mBAAmB,EAChE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC7B,MAAM,SAAS,CAAC,CAAC,CAAC,CAQpB"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Setup — `init` (eager) and `defineDb` (memoized lazy factory). `defineDb`
3
+ * gives first-class support to the app-id-resolves-at-runtime pattern instead
4
+ * of a hand-rolled lazy-init-and-memoize dance ([dux-spec-vue.md §2]).
5
+ */
6
+ import { markRaw } from 'vue';
7
+ import { init as baselineInit } from '../baseline/index.js';
8
+ import { IdbClient } from './db.js';
9
+ /**
10
+ * Build the db eagerly — for apps whose config is available at module load.
11
+ *
12
+ * The client is `markRaw`'d: it is a stable handle, not reactive state (its
13
+ * reactivity lives in the refs its hooks return), so it must never be wrapped
14
+ * in a reactive proxy. Storing it in a Pinia store or `reactive()` is the
15
+ * normal case, and a proxy would break the pass-through getters (`auth`,
16
+ * `storage`, `streams`) — reading a private field through a proxy throws. This
17
+ * makes the client proxy-safe with zero userland ceremony.
18
+ */
19
+ export function init(config) {
20
+ const baseline = baselineInit(config);
21
+ return markRaw(new IdbClient(baseline, config.schema));
22
+ }
23
+ /**
24
+ * Returns a factory: the first call resolves config and creates the db;
25
+ * subsequent calls return the same instance. No framework-wide singleton —
26
+ * global state stays the app's responsibility.
27
+ *
28
+ * @example
29
+ * export const useDb = defineDb({
30
+ * schema,
31
+ * getAppId: () => useRuntimeConfig().public.instantAppId,
32
+ * firstPartyPath: '/api/idb',
33
+ * })
34
+ */
35
+ export function defineDb(options) {
36
+ let instance;
37
+ const { getAppId, ...config } = options;
38
+ return () => {
39
+ if (!instance)
40
+ instance = init({ ...config, appId: getAppId() });
41
+ return instance;
42
+ };
43
+ }
44
+ //# sourceMappingURL=defineDb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineDb.js","sourceRoot":"","sources":["../../../../src/vue/overlay/defineDb.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAC7B,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAClB,MAA0B;IAE1B,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAa,CAAC,CAAA;IAC5C,OAAO,OAAO,CAAC,IAAI,SAAS,CAAI,QAAe,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;AAClE,CAAC;AAQD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CACtB,OAA8B;IAE9B,IAAI,QAAkC,CAAA;IACtC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAA;IACvC,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,QAAQ;YACX,QAAQ,GAAG,IAAI,CAAI,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAwB,CAAC,CAAA;QAC5E,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IdbSchema } from '../../schema/defineSchema.js'\nimport type { IdbRegisteredSchema } from '../../schema/register.js'\nimport type { IdbClientConfig } from './types.js'\n/**\n * Setup — `init` (eager) and `defineDb` (memoized lazy factory). `defineDb`\n * gives first-class support to the app-id-resolves-at-runtime pattern instead\n * of a hand-rolled lazy-init-and-memoize dance ([dux-spec-vue.md §2]).\n */\nimport { markRaw } from 'vue'\nimport { init as baselineInit } from '../baseline/index.js'\nimport { IdbClient } from './db.js'\n\n/**\n * Build the db eagerly — for apps whose config is available at module load.\n *\n * The client is `markRaw`'d: it is a stable handle, not reactive state (its\n * reactivity lives in the refs its hooks return), so it must never be wrapped\n * in a reactive proxy. Storing it in a Pinia store or `reactive()` is the\n * normal case, and a proxy would break the pass-through getters (`auth`,\n * `storage`, `streams`) — reading a private field through a proxy throws. This\n * makes the client proxy-safe with zero userland ceremony.\n */\nexport function init<S extends IdbSchema = IdbRegisteredSchema>(\n config: IdbClientConfig<S>,\n): IdbClient<S> {\n const baseline = baselineInit(config as any)\n return markRaw(new IdbClient<S>(baseline as any, config.schema))\n}\n\n/** `defineDb` options: the schema, a lazy `getAppId`, and the rest of config. */\nexport type IdbDefineDbOptions<S extends IdbSchema> = Omit<IdbClientConfig<S>, 'appId'> & {\n /** Resolved on first use (framework runtime config, env indirection, …). */\n getAppId: () => string\n}\n\n/**\n * Returns a factory: the first call resolves config and creates the db;\n * subsequent calls return the same instance. No framework-wide singleton —\n * global state stays the app's responsibility.\n *\n * @example\n * export const useDb = defineDb({\n * schema,\n * getAppId: () => useRuntimeConfig().public.instantAppId,\n * firstPartyPath: '/api/idb',\n * })\n */\nexport function defineDb<S extends IdbSchema = IdbRegisteredSchema>(\n options: IdbDefineDbOptions<S>,\n): () => IdbClient<S> {\n let instance: IdbClient<S> | undefined\n const { getAppId, ...config } = options\n return () => {\n if (!instance)\n instance = init<S>({ ...config, appId: getAppId() } as IdbClientConfig<S>)\n return instance\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import type { Ref } from 'vue';
2
+ /** The flat ref bag a hook produces (`{ isLoading, error, todos, … }`). */
3
+ export type RefsBag = Record<string, Ref<any>>;
4
+ type Unref<R> = R extends Ref<infer V> ? V : never;
5
+ /** `.state` — getter projection over the refs, `.value`-free and read-only. */
6
+ export type StateOf<Refs> = {
7
+ readonly [K in keyof Refs]: Unref<Refs[K]>;
8
+ };
9
+ /** The full result: top-level refs (spread in), plus `.refs` and `.state`. */
10
+ export type IdbResult<Refs> = Refs & {
11
+ refs: Refs;
12
+ state: StateOf<Refs>;
13
+ };
14
+ /**
15
+ * Wrap a hook's flat ref bag into the result pattern. The refs are spread to
16
+ * the top level, exposed again under `.refs`, and projected read-only under a
17
+ * raw `.state`.
18
+ */
19
+ export declare function makeResult<Refs extends RefsBag>(refs: Refs): IdbResult<Refs>;
20
+ /**
21
+ * The result pattern for hooks whose key set is *dynamic* (query scopes
22
+ * depend on the query, which can change at runtime). `staticRefs` are always
23
+ * present (`isLoading`, `error`, …); any other accessed key is resolved
24
+ * through `scopeRef`, which the builder memoizes. Destructuring, `.refs`
25
+ * passthrough, and the raw `.state` projection all work over arbitrary keys.
26
+ */
27
+ export declare function makeDynamicResult<Static extends RefsBag>(staticRefs: Static, scopeRef: (key: string) => Ref<any>, extras?: Record<string, unknown>): any;
28
+ export {};
29
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../../src/vue/overlay/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAiB9B,2EAA2E;AAC3E,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAE9C,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAQlD,+EAA+E;AAC/E,MAAM,MAAM,OAAO,CAAC,IAAI,IAAI;IAC1B,QAAQ,EAAE,CAAC,IAAI,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAC3C,CAAA;AAED,8EAA8E;AAC9E,MAAM,MAAM,SAAS,CAAC,IAAI,IAAI,IAAI,GAAG;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAc5E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,OAAO,EACtD,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,EACnC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACnC,GAAG,CA8CL"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The refs+state primitive — one shape, every stateful hook ([conventions §3],
3
+ * [dux-spec-vue.md §3]). A result serves three reading styles over one
4
+ * reactive source:
5
+ *
6
+ * - **top-level refs** for destructuring and watch sources,
7
+ * - **`.refs`** for composable passthrough,
8
+ * - **`.state`** for `.value`-free script reads.
9
+ *
10
+ * `state` is a `markRaw` plain object with getters over the underlying refs:
11
+ * Pinia won't try to hydrate it, writing a property fails at the property
12
+ * level, and Vue effects still track because each getter reads a reactive
13
+ * source.
14
+ */
15
+ import { markRaw } from 'vue';
16
+ /**
17
+ * Wrap a hook's flat ref bag into the result pattern. The refs are spread to
18
+ * the top level, exposed again under `.refs`, and projected read-only under a
19
+ * raw `.state`.
20
+ */
21
+ export function makeResult(refs) {
22
+ const state = markRaw(Object.defineProperties({}, Object.fromEntries(Object.keys(refs).map(key => [
23
+ key,
24
+ { get: () => refs[key].value, enumerable: true },
25
+ ]))));
26
+ return { ...refs, refs, state };
27
+ }
28
+ /**
29
+ * The result pattern for hooks whose key set is *dynamic* (query scopes
30
+ * depend on the query, which can change at runtime). `staticRefs` are always
31
+ * present (`isLoading`, `error`, …); any other accessed key is resolved
32
+ * through `scopeRef`, which the builder memoizes. Destructuring, `.refs`
33
+ * passthrough, and the raw `.state` projection all work over arbitrary keys.
34
+ */
35
+ export function makeDynamicResult(staticRefs, scopeRef, extras = {}) {
36
+ const cache = new Map();
37
+ const refFor = (key) => {
38
+ if (key in staticRefs)
39
+ return staticRefs[key];
40
+ if (typeof key !== 'string')
41
+ return undefined;
42
+ let ref = cache.get(key);
43
+ if (!ref) {
44
+ ref = scopeRef(key);
45
+ cache.set(key, ref);
46
+ }
47
+ return ref;
48
+ };
49
+ const refs = new Proxy({}, {
50
+ get: (_t, key) => refFor(key),
51
+ has: () => true,
52
+ });
53
+ const state = markRaw(new Proxy({}, {
54
+ get: (_t, key) => refFor(key)?.value,
55
+ has: () => true,
56
+ set: () => false, // writing a state property fails at the property level
57
+ }));
58
+ return new Proxy({}, {
59
+ get: (_t, key) => {
60
+ if (key === 'refs')
61
+ return refs;
62
+ if (key === 'state')
63
+ return state;
64
+ if (key in extras)
65
+ return extras[key]; // passthrough methods (e.g. loadNextPage)
66
+ return refFor(key);
67
+ },
68
+ has: () => true,
69
+ });
70
+ }
71
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../../../src/vue/overlay/result.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAwB7B;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAuB,IAAU;IACzD,MAAM,KAAK,GAAG,OAAO,CACnB,MAAM,CAAC,gBAAgB,CACrB,EAAE,EACF,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,GAAG;QACH,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE;KAClD,CAAC,CACH,CACF,CACe,CAAA;IAElB,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MA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K,CAAA;YACd,IAAI,GAAG,IAAI,MAAM;gBACf,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA,CAAC,0CAA0C;YAC/D,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;QACpB,CAAC;QACD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;KAChB,CACF,CAAA;AACH,CAAC","sourcesContent":["import type { Ref } from 'vue'\n/**\n * The refs+state primitive — one shape, every stateful hook ([conventions §3],\n * [dux-spec-vue.md §3]). A result serves three reading styles over one\n * reactive source:\n *\n * - **top-level refs** for destructuring and watch sources,\n * - **`.refs`** for composable passthrough,\n * - **`.state`** for `.value`-free script reads.\n *\n * `state` is a `markRaw` plain object with getters over the underlying refs:\n * Pinia won't try to hydrate it, writing a property fails at the property\n * level, and Vue effects still track because each getter reads a reactive\n * source.\n */\nimport { markRaw } from 'vue'\n\n/** The flat ref bag a hook produces (`{ isLoading, error, todos, … }`). */\nexport type RefsBag = Record<string, Ref<any>>\n\ntype Unref<R> = R extends Ref<infer V> ? V : never\n\n// The type-level helpers don't constrain to `RefsBag`: a named ref-bag\n// interface (e.g. `AuthRefs`) has no string index signature and so wouldn't\n// satisfy `Record<string, Ref>`, even though every member is a `Ref`. They\n// map over `keyof Refs` directly instead; `makeResult` keeps the runtime\n// constraint where call sites pass object literals.\n\n/** `.state` — getter projection over the refs, `.value`-free and read-only. */\nexport type StateOf<Refs> = {\n readonly [K in keyof Refs]: Unref<Refs[K]>\n}\n\n/** The full result: top-level refs (spread in), plus `.refs` and `.state`. */\nexport type IdbResult<Refs> = Refs & {\n refs: Refs\n state: StateOf<Refs>\n}\n\n/**\n * Wrap a hook's flat ref bag into the result pattern. The refs are spread to\n * the top level, exposed again under `.refs`, and projected read-only under a\n * raw `.state`.\n */\nexport function makeResult<Refs extends RefsBag>(refs: Refs): IdbResult<Refs> {\n const state = markRaw(\n Object.defineProperties(\n {},\n Object.fromEntries(\n Object.keys(refs).map(key => [\n key,\n { get: () => refs[key]!.value, enumerable: true },\n ]),\n ),\n ),\n ) as StateOf<Refs>\n\n return { ...refs, refs, state }\n}\n\n/**\n * The result pattern for hooks whose key set is *dynamic* (query scopes\n * depend on the query, which can change at runtime). `staticRefs` are always\n * present (`isLoading`, `error`, …); any other accessed key is resolved\n * through `scopeRef`, which the builder memoizes. Destructuring, `.refs`\n * passthrough, and the raw `.state` projection all work over arbitrary keys.\n */\nexport function makeDynamicResult<Static extends RefsBag>(\n staticRefs: Static,\n scopeRef: (key: string) => Ref<any>,\n extras: Record<string, unknown> = {},\n): any {\n const cache = new Map<string, Ref<any>>()\n const refFor = (key: string): Ref<any> | undefined => {\n if (key in staticRefs)\n return staticRefs[key]\n if (typeof key !== 'string')\n return undefined\n let ref = cache.get(key)\n if (!ref) {\n ref = scopeRef(key)\n cache.set(key, ref)\n }\n return ref\n }\n\n const refs = new Proxy({} as RefsBag, {\n get: (_t, key: string) => refFor(key),\n has: () => true,\n })\n\n const state = markRaw(\n new Proxy(\n {},\n {\n get: (_t, key: string) => refFor(key)?.value,\n has: () => true,\n set: () => false, // writing a state property fails at the property level\n },\n ),\n )\n\n return new Proxy(\n {},\n {\n get: (_t, key: string) => {\n if (key === 'refs')\n return refs\n if (key === 'state')\n return state\n if (key in extras)\n return extras[key] // passthrough methods (e.g. loadNextPage)\n return refFor(key)\n },\n has: () => true,\n },\n )\n}\n"]}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The rooms overlay: the baseline room hooks keep their official names and
3
+ * semantics; the stateful ones (`usePresence`, `useTypingIndicator`) gain the
4
+ * result pattern, the rest pass through unchanged ([dux-spec-vue.md §6]).
5
+ *
6
+ * The wrappers re-declare the baseline generics rather than forwarding
7
+ * `Parameters<typeof …>`: a spread-args signature collapses the generics to
8
+ * their constraints, which erases per-room presence/topic typing (`keys` and
9
+ * `peers` resolve against `never`). Re-declaring keeps `keys`,
10
+ * `initialPresence`, and the resulting `peers`/`active` typed against the
11
+ * room's schema.
12
+ */
13
+ import type { PresenceOpts, RoomSchemaShape } from '@instantdb/core';
14
+ import type { InstantDuxRoom, TypingIndicatorOpts } from '../../baseline/index.js';
15
+ import { usePublishTopic, useSyncPresence, useTopicEffect } from '../../baseline/index.js';
16
+ declare function usePresence<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema, Keys extends keyof RoomSchema[RoomType]['presence']>(room: InstantDuxRoom<any, RoomSchema, RoomType>, opts?: PresenceOpts<RoomSchema[RoomType]['presence'], Keys>): {
17
+ peers: import("vue").ShallowRef<{
18
+ [peerId: string]: Pick<RoomSchema[RoomType]["presence"], Keys> & {
19
+ peerId: string;
20
+ };
21
+ }>;
22
+ isLoading: import("vue").ShallowRef<boolean>;
23
+ user: import("vue").ShallowRef<(Pick<RoomSchema[RoomType]["presence"], Keys> & {
24
+ peerId: string;
25
+ }) | undefined>;
26
+ error: import("vue").ShallowRef<string | undefined>;
27
+ } & {
28
+ refs: {
29
+ peers: import("vue").ShallowRef<{
30
+ [peerId: string]: Pick<RoomSchema[RoomType]["presence"], Keys> & {
31
+ peerId: string;
32
+ };
33
+ }>;
34
+ isLoading: import("vue").ShallowRef<boolean>;
35
+ user: import("vue").ShallowRef<(Pick<RoomSchema[RoomType]["presence"], Keys> & {
36
+ peerId: string;
37
+ }) | undefined>;
38
+ error: import("vue").ShallowRef<string | undefined>;
39
+ };
40
+ state: import("../result.js").StateOf<{
41
+ peers: import("vue").ShallowRef<{
42
+ [peerId: string]: Pick<RoomSchema[RoomType]["presence"], Keys> & {
43
+ peerId: string;
44
+ };
45
+ }>;
46
+ isLoading: import("vue").ShallowRef<boolean>;
47
+ user: import("vue").ShallowRef<(Pick<RoomSchema[RoomType]["presence"], Keys> & {
48
+ peerId: string;
49
+ }) | undefined>;
50
+ error: import("vue").ShallowRef<string | undefined>;
51
+ }>;
52
+ } & {
53
+ publishPresence: (data: Partial<RoomSchema[RoomType]["presence"]>) => void;
54
+ };
55
+ declare function useTypingIndicator<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema>(room: InstantDuxRoom<any, RoomSchema, RoomType>, inputName: string, opts?: TypingIndicatorOpts): {
56
+ active: import("vue").Ref<RoomSchema[RoomType]["presence"][], RoomSchema[RoomType]["presence"][]>;
57
+ } & {
58
+ refs: {
59
+ active: import("vue").Ref<RoomSchema[RoomType]["presence"][], RoomSchema[RoomType]["presence"][]>;
60
+ };
61
+ state: import("../result.js").StateOf<{
62
+ active: import("vue").Ref<RoomSchema[RoomType]["presence"][], RoomSchema[RoomType]["presence"][]>;
63
+ }>;
64
+ } & {
65
+ setActive: (active: boolean) => void;
66
+ inputProps: {
67
+ onKeydown: (e: KeyboardEvent) => void;
68
+ onBlur: () => void;
69
+ };
70
+ };
71
+ export declare const rooms: {
72
+ useTopicEffect: typeof useTopicEffect;
73
+ usePublishTopic: typeof usePublishTopic;
74
+ usePresence: typeof usePresence;
75
+ useSyncPresence: typeof useSyncPresence;
76
+ useTypingIndicator: typeof useTypingIndicator;
77
+ };
78
+ export {};
79
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/vue/overlay/rooms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAClF,OAAO,EAGL,eAAe,EACf,eAAe,EACf,cAAc,EACf,MAAM,yBAAyB,CAAA;AAGhC,iBAAS,WAAW,CAClB,UAAU,SAAS,eAAe,EAClC,QAAQ,SAAS,MAAM,UAAU,EACjC,IAAI,SAAS,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,EAEnD,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,EAC/C,IAAI,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc5D;AAED,iBAAS,kBAAkB,CACzB,UAAU,SAAS,eAAe,EAClC,QAAQ,SAAS,MAAM,UAAU,EAEjC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,EAC/C,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;EAI3B;AAED,eAAO,MAAM,KAAK;;;;;;CAMjB,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { usePresence as baselineUsePresence, useTypingIndicator as baselineUseTypingIndicator, usePublishTopic, useSyncPresence, useTopicEffect, } from '../../baseline/index.js';
2
+ import { makeResult } from '../result.js';
3
+ function usePresence(room, opts) {
4
+ const handle = baselineUsePresence(room, opts);
5
+ // user/error are optional on the presence-response shape, but the baseline
6
+ // always creates their refs; assert them present for the result bag.
7
+ return Object.assign(makeResult({
8
+ peers: handle.peers,
9
+ isLoading: handle.isLoading,
10
+ user: handle.user,
11
+ error: handle.error,
12
+ }), { publishPresence: handle.publishPresence });
13
+ }
14
+ function useTypingIndicator(room, inputName, opts) {
15
+ const { active, setActive, inputProps } = baselineUseTypingIndicator(room, inputName, opts);
16
+ return Object.assign(makeResult({ active }), { setActive, inputProps });
17
+ }
18
+ export const rooms = {
19
+ useTopicEffect,
20
+ usePublishTopic,
21
+ usePresence,
22
+ useSyncPresence,
23
+ useTypingIndicator,
24
+ };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/vue/overlay/rooms/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,kBAAkB,IAAI,0BAA0B,EAChD,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,SAAS,WAAW,CAKlB,IAA+C,EAC/C,IAA2D;IAE3D,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC9C,2EAA2E;IAC3E,qEAAqE;IACrE,OAAO,MAAM,CAAC,MAAM,CAClB,UAAU,CAAC;QACT,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,IAAI,EAAE,MAAM,CAAC,IAAK;QAClB,KAAK,EAAE,MAAM,CAAC,KAAM;KACrB,CAAC,EACF,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,CAC5C,CAAA;AACH,CAAC;AAED,SAAS,kBAAkB,CAIzB,IAA+C,EAC/C,SAAiB,EACjB,IAA0B;IAE1B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,0BAA0B,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;IAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAA;AACzE,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,cAAc;IACd,eAAe;IACf,WAAW;IACX,eAAe;IACf,kBAAkB;CACnB,CAAA","sourcesContent":["/**\n * The rooms overlay: the baseline room hooks keep their official names and\n * semantics; the stateful ones (`usePresence`, `useTypingIndicator`) gain the\n * result pattern, the rest pass through unchanged ([dux-spec-vue.md §6]).\n *\n * The wrappers re-declare the baseline generics rather than forwarding\n * `Parameters<typeof …>`: a spread-args signature collapses the generics to\n * their constraints, which erases per-room presence/topic typing (`keys` and\n * `peers` resolve against `never`). Re-declaring keeps `keys`,\n * `initialPresence`, and the resulting `peers`/`active` typed against the\n * room's schema.\n */\nimport type { PresenceOpts, RoomSchemaShape } from '@instantdb/core'\nimport type { InstantDuxRoom, TypingIndicatorOpts } from '../../baseline/index.js'\nimport {\n usePresence as baselineUsePresence,\n useTypingIndicator as baselineUseTypingIndicator,\n usePublishTopic,\n useSyncPresence,\n useTopicEffect,\n} from '../../baseline/index.js'\nimport { makeResult } from '../result.js'\n\nfunction usePresence<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n Keys extends keyof RoomSchema[RoomType]['presence'],\n>(\n room: InstantDuxRoom<any, RoomSchema, RoomType>,\n opts?: PresenceOpts<RoomSchema[RoomType]['presence'], Keys>,\n) {\n const handle = baselineUsePresence(room, opts)\n // user/error are optional on the presence-response shape, but the baseline\n // always creates their refs; assert them present for the result bag.\n return Object.assign(\n makeResult({\n peers: handle.peers,\n isLoading: handle.isLoading,\n user: handle.user!,\n error: handle.error!,\n }),\n { publishPresence: handle.publishPresence },\n )\n}\n\nfunction useTypingIndicator<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n>(\n room: InstantDuxRoom<any, RoomSchema, RoomType>,\n inputName: string,\n opts?: TypingIndicatorOpts,\n) {\n const { active, setActive, inputProps } = baselineUseTypingIndicator(room, inputName, opts)\n return Object.assign(makeResult({ active }), { setActive, inputProps })\n}\n\nexport const rooms = {\n useTopicEffect,\n usePublishTopic,\n usePresence,\n useSyncPresence,\n useTypingIndicator,\n}\n"]}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The `/vue` overlay's public types: the config rename, the result-pattern
3
+ * shapes per domain, and the auth/connection renames. Every stateful hook
4
+ * returns `Idb<Domain>Result` with `-Data`/`-State`/`-Refs` subparts
5
+ * ([conventions §3]).
6
+ */
7
+ import type { ConnectionStatus, InstantConfig, User } from '@instantdb/core';
8
+ import type { Ref } from 'vue';
9
+ import type { IdbQueryData, IdbQueryPageInfo } from '../../query/index.js';
10
+ import type { IdbSchema } from '../../schema/defineSchema.js';
11
+ import type { IdbRegisteredSchema } from '../../schema/register.js';
12
+ import type { IdbResult, StateOf } from './result.js';
13
+ /**
14
+ * `init`/`defineDb` config — everything core supports, including `devtool`
15
+ * and `apiURI`/`websocketURI` (self-hosting). `i.date()` fields are typed as
16
+ * the wire format everywhere, so `useDateObjects` stays off.
17
+ */
18
+ export type IdbClientConfig<S extends IdbSchema = IdbRegisteredSchema> = Omit<InstantConfig<S, false>, 'useDateObjects' | 'schema'> & {
19
+ schema?: S;
20
+ };
21
+ /** The authenticated user (official `User`). */
22
+ export type IdbAuthUser = User;
23
+ /** Connection status union (official `ConnectionStatus`). */
24
+ export type IdbConnectionStatus = ConnectionStatus;
25
+ type QueryRefs<Q, S extends IdbSchema> = {
26
+ isLoading: Ref<boolean>;
27
+ error: Ref<{
28
+ message: string;
29
+ } | undefined>;
30
+ pageInfo: Ref<IdbQueryPageInfo<Q> | undefined>;
31
+ } & {
32
+ [K in keyof IdbQueryData<Q, S>]: Ref<IdbQueryData<Q, S>[K]>;
33
+ };
34
+ export type IdbQueryResultRefs<Q, S extends IdbSchema = IdbRegisteredSchema> = QueryRefs<Q, S>;
35
+ export type IdbQueryResultData<Q, S extends IdbSchema = IdbRegisteredSchema> = IdbQueryData<Q, S>;
36
+ export type IdbQueryResultState<Q, S extends IdbSchema = IdbRegisteredSchema> = StateOf<QueryRefs<Q, S>>;
37
+ export type IdbQueryResult<Q, S extends IdbSchema = IdbRegisteredSchema> = IdbResult<QueryRefs<Q, S>>;
38
+ type InfiniteRefs<Q, S extends IdbSchema> = {
39
+ isLoading: Ref<boolean>;
40
+ error: Ref<{
41
+ message: string;
42
+ } | undefined>;
43
+ canLoadNextPage: Ref<boolean>;
44
+ } & {
45
+ [K in keyof IdbQueryData<Q, S>]: Ref<IdbQueryData<Q, S>[K]>;
46
+ };
47
+ export type IdbInfiniteQueryResult<Q, S extends IdbSchema = IdbRegisteredSchema> = IdbResult<InfiniteRefs<Q, S>> & {
48
+ loadNextPage: () => void;
49
+ };
50
+ interface AuthRefs {
51
+ isLoading: Ref<boolean>;
52
+ user: Ref<IdbAuthUser | undefined>;
53
+ error: Ref<{
54
+ message: string;
55
+ } | undefined>;
56
+ }
57
+ export type IdbAuthResultRefs = AuthRefs;
58
+ export type IdbAuthResultState = StateOf<AuthRefs>;
59
+ export type IdbAuthResult = IdbResult<AuthRefs>;
60
+ interface ConnectionRefs {
61
+ status: Ref<IdbConnectionStatus>;
62
+ }
63
+ export type IdbConnectionResult = IdbResult<ConnectionRefs>;
64
+ interface LocalIdRefs {
65
+ localId: Ref<string | null>;
66
+ }
67
+ export type IdbLocalIdResult = IdbResult<LocalIdRefs>;
68
+ export interface IdbUserOptions {
69
+ /** Type `user` as present and treat a missing user as a dev-time error. */
70
+ requireUser?: boolean;
71
+ }
72
+ export {};
73
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/vue/overlay/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,IAAI,EACL,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAKrD;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,SAAS,GAAG,mBAAmB,IAAI,IAAI,CAC3E,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,EACvB,gBAAgB,GAAG,QAAQ,CAC5B,GAAG;IAAE,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,CAAA;AAElB,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAA;AAE9B,6DAA6D;AAC7D,M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1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/vue/overlay/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The `/vue` overlay's public types: the config rename, the result-pattern\n * shapes per domain, and the auth/connection renames. Every stateful hook\n * returns `Idb<Domain>Result` with `-Data`/`-State`/`-Refs` subparts\n * ([conventions §3]).\n */\nimport type {\n ConnectionStatus,\n InstantConfig,\n User,\n} from '@instantdb/core'\nimport type { Ref } from 'vue'\nimport type { IdbQueryData, IdbQueryPageInfo } from '../../query/index.js'\nimport type { IdbSchema } from '../../schema/defineSchema.js'\nimport type { IdbRegisteredSchema } from '../../schema/register.js'\nimport type { IdbResult, StateOf } from './result.js'\n\n// ==========\n// config + auth/connection renames\n\n/**\n * `init`/`defineDb` config — everything core supports, including `devtool`\n * and `apiURI`/`websocketURI` (self-hosting). `i.date()` fields are typed as\n * the wire format everywhere, so `useDateObjects` stays off.\n */\nexport type IdbClientConfig<S extends IdbSchema = IdbRegisteredSchema> = Omit<\n InstantConfig<S, false>,\n 'useDateObjects' | 'schema'\n> & { schema?: S }\n\n/** The authenticated user (official `User`). */\nexport type IdbAuthUser = User\n\n/** Connection status union (official `ConnectionStatus`). */\nexport type IdbConnectionStatus = ConnectionStatus\n\n// ==========\n// result-pattern shapes\n\ntype QueryRefs<Q, S extends IdbSchema> = {\n isLoading: Ref<boolean>\n error: Ref<{ message: string } | undefined>\n pageInfo: Ref<IdbQueryPageInfo<Q> | undefined>\n} & {\n [K in keyof IdbQueryData<Q, S>]: Ref<IdbQueryData<Q, S>[K]>\n}\n\nexport type IdbQueryResultRefs<Q, S extends IdbSchema = IdbRegisteredSchema> = QueryRefs<Q, S>\nexport type IdbQueryResultData<Q, S extends IdbSchema = IdbRegisteredSchema> = IdbQueryData<Q, S>\nexport type IdbQueryResultState<Q, S extends IdbSchema = IdbRegisteredSchema> = StateOf<QueryRefs<Q, S>>\nexport type IdbQueryResult<Q, S extends IdbSchema = IdbRegisteredSchema> = IdbResult<QueryRefs<Q, S>>\n\ntype InfiniteRefs<Q, S extends IdbSchema> = {\n isLoading: Ref<boolean>\n error: Ref<{ message: string } | undefined>\n canLoadNextPage: Ref<boolean>\n} & {\n [K in keyof IdbQueryData<Q, S>]: Ref<IdbQueryData<Q, S>[K]>\n}\n\nexport type IdbInfiniteQueryResult<Q, S extends IdbSchema = IdbRegisteredSchema>\n = IdbResult<InfiniteRefs<Q, S>> & { loadNextPage: () => void }\n\ninterface AuthRefs {\n isLoading: Ref<boolean>\n user: Ref<IdbAuthUser | undefined>\n error: Ref<{ message: string } | undefined>\n}\nexport type IdbAuthResultRefs = AuthRefs\nexport type IdbAuthResultState = StateOf<AuthRefs>\nexport type IdbAuthResult = IdbResult<AuthRefs>\n\ninterface ConnectionRefs { status: Ref<IdbConnectionStatus> }\nexport type IdbConnectionResult = IdbResult<ConnectionRefs>\n\ninterface LocalIdRefs { localId: Ref<string | null> }\nexport type IdbLocalIdResult = IdbResult<LocalIdRefs>\n\nexport interface IdbUserOptions {\n /** Type `user` as present and treat a missing user as a dev-time error. */\n requireUser?: boolean\n}\n"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Authoring webhook handlers as plain object literals with full per-change
3
+ * narrowing — no helper functions, no schema generics at the call site
4
+ * (dux-spec-webhooks.md §4).
5
+ */
6
+ import type { IdbSchema } from '../schema/defineSchema.js';
7
+ import type { IdbRegisteredSchema } from '../schema/register.js';
8
+ import type { IdbWebhookHandlers } from './types.js';
9
+ /**
10
+ * Define webhook handlers as a plain object literal. Contextual typing narrows
11
+ * each handler's `change` per namespace and action ({ after } is
12
+ * `IdbEntity<'ns'>`); pass several maps to merge them.
13
+ *
14
+ * Resolution per change matches the official dispatcher: `namespace.action` →
15
+ * `namespace.$default` → top-level `$default`.
16
+ *
17
+ * @example
18
+ * export const handlers = defineWebhookHandlers({
19
+ * tasks: {
20
+ * create: ({ after }) => notifyAssignee(after),
21
+ * delete: ({ before }) => audit('task removed', before),
22
+ * },
23
+ * $default: change => log(change),
24
+ * })
25
+ */
26
+ export declare function defineWebhookHandlers<S extends IdbSchema = IdbRegisteredSchema>(...maps: IdbWebhookHandlers<S>[]): IdbWebhookHandlers<S>;
27
+ //# sourceMappingURL=defineWebhookHandlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineWebhookHandlers.d.ts","sourceRoot":"","sources":["../../../src/webhooks/defineWebhookHandlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,SAAS,GAAG,mBAAmB,EAC7E,GAAG,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAC/B,kBAAkB,CAAC,CAAC,CAAC,CAWvB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Define webhook handlers as a plain object literal. Contextual typing narrows
3
+ * each handler's `change` per namespace and action ({ after } is
4
+ * `IdbEntity<'ns'>`); pass several maps to merge them.
5
+ *
6
+ * Resolution per change matches the official dispatcher: `namespace.action` →
7
+ * `namespace.$default` → top-level `$default`.
8
+ *
9
+ * @example
10
+ * export const handlers = defineWebhookHandlers({
11
+ * tasks: {
12
+ * create: ({ after }) => notifyAssignee(after),
13
+ * delete: ({ before }) => audit('task removed', before),
14
+ * },
15
+ * $default: change => log(change),
16
+ * })
17
+ */
18
+ export function defineWebhookHandlers(...maps) {
19
+ const result = {};
20
+ for (const map of maps) {
21
+ for (const key of Object.keys(map)) {
22
+ if (key === '$default')
23
+ result.$default = map.$default;
24
+ else
25
+ result[key] = { ...result[key], ...map[key] };
26
+ }
27
+ }
28
+ return result;
29
+ }
30
+ //# sourceMappingURL=defineWebhookHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineWebhookHandlers.js","sourceRoot":"","sources":["../../../src/webhooks/defineWebhookHandlers.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAAG,IAA6B;IAEhC,MAAM,MAAM,GAAwB,EAAE,CAAA;IACtC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,GAAG,KAAK,UAAU;gBACpB,MAAM,CAAC,QAAQ,GAAI,GAA2B,CAAC,QAAQ,CAAA;;gBAEvD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,GAAI,GAA2B,CAAC,GAAG,CAAC,EAAE,CAAA;QAC1E,CAAC;IACH,CAAC;IACD,OAAO,MAA+B,CAAA;AACxC,CAAC","sourcesContent":["/**\n * Authoring webhook handlers as plain object literals with full per-change\n * narrowing — no helper functions, no schema generics at the call site\n * (dux-spec-webhooks.md §4).\n */\nimport type { IdbSchema } from '../schema/defineSchema.js'\nimport type { IdbRegisteredSchema } from '../schema/register.js'\nimport type { IdbWebhookHandlers } from './types.js'\n\n/**\n * Define webhook handlers as a plain object literal. Contextual typing narrows\n * each handler's `change` per namespace and action ({ after } is\n * `IdbEntity<'ns'>`); pass several maps to merge them.\n *\n * Resolution per change matches the official dispatcher: `namespace.action` →\n * `namespace.$default` → top-level `$default`.\n *\n * @example\n * export const handlers = defineWebhookHandlers({\n * tasks: {\n * create: ({ after }) => notifyAssignee(after),\n * delete: ({ before }) => audit('task removed', before),\n * },\n * $default: change => log(change),\n * })\n */\nexport function defineWebhookHandlers<S extends IdbSchema = IdbRegisteredSchema>(\n ...maps: IdbWebhookHandlers<S>[]\n): IdbWebhookHandlers<S> {\n const result: Record<string, any> = {}\n for (const map of maps) {\n for (const key of Object.keys(map)) {\n if (key === '$default')\n result.$default = (map as Record<string, any>).$default\n else\n result[key] = { ...result[key], ...(map as Record<string, any>)[key] }\n }\n }\n return result as IdbWebhookHandlers<S>\n}\n"]}