document-model 2.20.0 → 2.21.1

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 (740) hide show
  1. package/dist/index.d.ts +17 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +11 -0
  4. package/dist/{browser/src → src}/document/actions/creators.d.ts +3 -2
  5. package/dist/src/document/actions/creators.d.ts.map +1 -0
  6. package/dist/{node/src/document/actions/creators.d.ts → src/document/actions/creators.js} +17 -9
  7. package/dist/src/document/actions/operations.d.ts +23 -0
  8. package/dist/src/document/actions/operations.d.ts.map +1 -0
  9. package/dist/src/document/actions/operations.js +130 -0
  10. package/dist/src/document/actions/types.d.ts +16 -0
  11. package/dist/src/document/actions/types.d.ts.map +1 -0
  12. package/dist/src/document/actions/types.js +6 -0
  13. package/dist/{browser/src → src}/document/object.d.ts +16 -14
  14. package/dist/src/document/object.d.ts.map +1 -0
  15. package/dist/{node/src/document/object.d.ts → src/document/object.js} +92 -30
  16. package/dist/src/document/reducer.d.ts +49 -0
  17. package/dist/src/document/reducer.d.ts.map +1 -0
  18. package/dist/src/document/reducer.js +341 -0
  19. package/dist/{browser/src → src}/document/schema/types.d.ts +1 -1
  20. package/dist/src/document/schema/types.d.ts.map +1 -0
  21. package/dist/src/document/schema/types.js +1 -0
  22. package/dist/{browser/src → src}/document/schema/zod.d.ts +20 -20
  23. package/dist/src/document/schema/zod.d.ts.map +1 -0
  24. package/dist/src/document/schema/zod.js +112 -0
  25. package/dist/{node/src → src}/document/signal.d.ts +9 -9
  26. package/dist/src/document/signal.d.ts.map +1 -0
  27. package/dist/src/document/signal.js +1 -0
  28. package/dist/src/document/types.d.ts +302 -0
  29. package/dist/src/document/types.d.ts.map +1 -0
  30. package/dist/src/document/types.js +1 -0
  31. package/dist/src/document/utils/base.d.ts +84 -0
  32. package/dist/src/document/utils/base.d.ts.map +1 -0
  33. package/dist/src/document/utils/base.js +328 -0
  34. package/dist/{browser/src → src}/document/utils/browser.d.ts +1 -1
  35. package/dist/src/document/utils/browser.d.ts.map +1 -0
  36. package/dist/src/document/utils/browser.js +46 -0
  37. package/dist/src/document/utils/crypto.d.ts +11 -0
  38. package/dist/src/document/utils/crypto.d.ts.map +1 -0
  39. package/dist/src/document/utils/crypto.js +79 -0
  40. package/dist/src/document/utils/document-helpers.d.ts +78 -0
  41. package/dist/src/document/utils/document-helpers.d.ts.map +1 -0
  42. package/dist/src/document/utils/document-helpers.js +410 -0
  43. package/dist/{browser/src → src}/document/utils/errors.d.ts +1 -1
  44. package/dist/src/document/utils/errors.d.ts.map +1 -0
  45. package/dist/src/document/utils/errors.js +18 -0
  46. package/dist/{browser/src → src}/document/utils/file.d.ts +9 -8
  47. package/dist/src/document/utils/file.d.ts.map +1 -0
  48. package/dist/src/document/utils/file.js +155 -0
  49. package/dist/{browser/src → src}/document/utils/node.d.ts +2 -2
  50. package/dist/src/document/utils/node.d.ts.map +1 -0
  51. package/dist/src/document/utils/node.js +54 -0
  52. package/dist/src/document/utils/validation.d.ts +3 -0
  53. package/dist/src/document/utils/validation.d.ts.map +1 -0
  54. package/dist/src/document/utils/validation.js +22 -0
  55. package/dist/src/document-model/custom/reducers/header.d.ts +3 -0
  56. package/dist/src/document-model/custom/reducers/header.d.ts.map +1 -0
  57. package/dist/src/document-model/custom/reducers/header.js +22 -0
  58. package/dist/src/document-model/custom/reducers/module.d.ts +3 -0
  59. package/dist/src/document-model/custom/reducers/module.d.ts.map +1 -0
  60. package/dist/src/document-model/custom/reducers/module.js +40 -0
  61. package/dist/src/document-model/custom/reducers/operation-error.d.ts +3 -0
  62. package/dist/src/document-model/custom/reducers/operation-error.d.ts.map +1 -0
  63. package/dist/src/document-model/custom/reducers/operation-error.js +93 -0
  64. package/dist/src/document-model/custom/reducers/operation-example.d.ts +3 -0
  65. package/dist/src/document-model/custom/reducers/operation-example.d.ts.map +1 -0
  66. package/dist/src/document-model/custom/reducers/operation-example.js +52 -0
  67. package/dist/src/document-model/custom/reducers/operation.d.ts +3 -0
  68. package/dist/src/document-model/custom/reducers/operation.d.ts.map +1 -0
  69. package/dist/src/document-model/custom/reducers/operation.js +124 -0
  70. package/dist/src/document-model/custom/reducers/state.d.ts +3 -0
  71. package/dist/src/document-model/custom/reducers/state.d.ts.map +1 -0
  72. package/dist/src/document-model/custom/reducers/state.js +70 -0
  73. package/dist/src/document-model/custom/reducers/versioning.d.ts +8 -0
  74. package/dist/src/document-model/custom/reducers/versioning.d.ts.map +1 -0
  75. package/dist/src/document-model/custom/reducers/versioning.js +22 -0
  76. package/dist/{browser/src → src}/document-model/custom/utils.d.ts +3 -3
  77. package/dist/src/document-model/custom/utils.d.ts.map +1 -0
  78. package/dist/src/document-model/custom/utils.js +104 -0
  79. package/dist/src/document-model/gen/actions.d.ts +16 -0
  80. package/dist/src/document-model/gen/actions.d.ts.map +1 -0
  81. package/dist/src/document-model/gen/actions.js +7 -0
  82. package/dist/src/document-model/gen/constants.d.ts +7 -0
  83. package/dist/src/document-model/gen/constants.d.ts.map +1 -0
  84. package/dist/src/document-model/gen/constants.js +33 -0
  85. package/dist/src/document-model/gen/creators.d.ts +8 -0
  86. package/dist/src/document-model/gen/creators.d.ts.map +1 -0
  87. package/dist/src/document-model/gen/creators.js +7 -0
  88. package/dist/src/document-model/gen/document-model.d.ts +3 -0
  89. package/dist/src/document-model/gen/document-model.d.ts.map +1 -0
  90. package/dist/src/document-model/gen/document-model.js +541 -0
  91. package/dist/src/document-model/gen/header/actions.d.ts +10 -0
  92. package/dist/src/document-model/gen/header/actions.d.ts.map +1 -0
  93. package/dist/src/document-model/gen/header/actions.js +1 -0
  94. package/dist/{browser/src → src}/document-model/gen/header/creators.d.ts +2 -2
  95. package/dist/src/document-model/gen/header/creators.d.ts.map +1 -0
  96. package/dist/src/document-model/gen/header/creators.js +9 -0
  97. package/dist/src/document-model/gen/header/object.d.ts +13 -0
  98. package/dist/src/document-model/gen/header/object.d.ts.map +1 -0
  99. package/dist/src/document-model/gen/header/object.js +22 -0
  100. package/dist/{node/src → src}/document-model/gen/header/operations.d.ts +2 -2
  101. package/dist/src/document-model/gen/header/operations.d.ts.map +1 -0
  102. package/dist/src/document-model/gen/header/operations.js +1 -0
  103. package/dist/src/document-model/gen/module/actions.d.ts +9 -0
  104. package/dist/src/document-model/gen/module/actions.d.ts.map +1 -0
  105. package/dist/src/document-model/gen/module/actions.js +1 -0
  106. package/dist/{node/src → src}/document-model/gen/module/creators.d.ts +2 -2
  107. package/dist/src/document-model/gen/module/creators.d.ts.map +1 -0
  108. package/dist/src/document-model/gen/module/creators.js +8 -0
  109. package/dist/src/document-model/gen/module/object.d.ts +12 -0
  110. package/dist/src/document-model/gen/module/object.d.ts.map +1 -0
  111. package/dist/src/document-model/gen/module/object.js +19 -0
  112. package/dist/{browser/src → src}/document-model/gen/module/operations.d.ts +2 -2
  113. package/dist/src/document-model/gen/module/operations.d.ts.map +1 -0
  114. package/dist/src/document-model/gen/module/operations.js +1 -0
  115. package/dist/src/document-model/gen/object.d.ts +30 -0
  116. package/dist/src/document-model/gen/object.d.ts.map +1 -0
  117. package/dist/src/document-model/gen/object.js +46 -0
  118. package/dist/src/document-model/gen/operation/actions.d.ts +14 -0
  119. package/dist/src/document-model/gen/operation/actions.d.ts.map +1 -0
  120. package/dist/src/document-model/gen/operation/actions.js +1 -0
  121. package/dist/{browser/src → src}/document-model/gen/operation/creators.d.ts +2 -2
  122. package/dist/src/document-model/gen/operation/creators.d.ts.map +1 -0
  123. package/dist/src/document-model/gen/operation/creators.js +19 -0
  124. package/dist/{node/src → src}/document-model/gen/operation/object.d.ts +6 -5
  125. package/dist/src/document-model/gen/operation/object.d.ts.map +1 -0
  126. package/dist/src/document-model/gen/operation/object.js +34 -0
  127. package/dist/{browser/src → src}/document-model/gen/operation/operations.d.ts +2 -2
  128. package/dist/src/document-model/gen/operation/operations.d.ts.map +1 -0
  129. package/dist/src/document-model/gen/operation/operations.js +1 -0
  130. package/dist/src/document-model/gen/operation-error/actions.d.ts +11 -0
  131. package/dist/src/document-model/gen/operation-error/actions.d.ts.map +1 -0
  132. package/dist/src/document-model/gen/operation-error/actions.js +1 -0
  133. package/dist/{node/src → src}/document-model/gen/operation-error/creators.d.ts +2 -2
  134. package/dist/src/document-model/gen/operation-error/creators.d.ts.map +1 -0
  135. package/dist/src/document-model/gen/operation-error/creators.js +16 -0
  136. package/dist/{node/src → src}/document-model/gen/operation-error/object.d.ts +6 -5
  137. package/dist/src/document-model/gen/operation-error/object.d.ts.map +1 -0
  138. package/dist/src/document-model/gen/operation-error/object.js +25 -0
  139. package/dist/{browser/src → src}/document-model/gen/operation-error/operations.d.ts +2 -2
  140. package/dist/src/document-model/gen/operation-error/operations.d.ts.map +1 -0
  141. package/dist/src/document-model/gen/operation-error/operations.js +1 -0
  142. package/dist/src/document-model/gen/operation-example/actions.d.ts +8 -0
  143. package/dist/src/document-model/gen/operation-example/actions.d.ts.map +1 -0
  144. package/dist/src/document-model/gen/operation-example/actions.js +1 -0
  145. package/dist/{browser/src → src}/document-model/gen/operation-example/creators.d.ts +2 -2
  146. package/dist/src/document-model/gen/operation-example/creators.d.ts.map +1 -0
  147. package/dist/src/document-model/gen/operation-example/creators.js +13 -0
  148. package/dist/src/document-model/gen/operation-example/object.d.ts +12 -0
  149. package/dist/src/document-model/gen/operation-example/object.d.ts.map +1 -0
  150. package/dist/src/document-model/gen/operation-example/object.js +16 -0
  151. package/dist/{browser/src → src}/document-model/gen/operation-example/operations.d.ts +2 -2
  152. package/dist/src/document-model/gen/operation-example/operations.d.ts.map +1 -0
  153. package/dist/src/document-model/gen/operation-example/operations.js +1 -0
  154. package/dist/src/document-model/gen/reducer.d.ts +5 -0
  155. package/dist/src/document-model/gen/reducer.d.ts.map +1 -0
  156. package/dist/src/document-model/gen/reducer.js +192 -0
  157. package/dist/{node/src → src}/document-model/gen/schema/types.d.ts +5 -1
  158. package/dist/src/document-model/gen/schema/types.d.ts.map +1 -0
  159. package/dist/src/document-model/gen/schema/types.js +1 -0
  160. package/dist/{browser/src → src}/document-model/gen/schema/zod.d.ts +198 -198
  161. package/dist/src/document-model/gen/schema/zod.d.ts.map +1 -0
  162. package/dist/src/document-model/gen/schema/zod.js +393 -0
  163. package/dist/src/document-model/gen/state/actions.d.ts +10 -0
  164. package/dist/src/document-model/gen/state/actions.d.ts.map +1 -0
  165. package/dist/src/document-model/gen/state/actions.js +1 -0
  166. package/dist/{browser/src → src}/document-model/gen/state/creators.d.ts +2 -2
  167. package/dist/src/document-model/gen/state/creators.d.ts.map +1 -0
  168. package/dist/src/document-model/gen/state/creators.js +9 -0
  169. package/dist/src/document-model/gen/state/object.d.ts +13 -0
  170. package/dist/src/document-model/gen/state/object.d.ts.map +1 -0
  171. package/dist/src/document-model/gen/state/object.js +22 -0
  172. package/dist/{browser/src → src}/document-model/gen/state/operations.d.ts +2 -2
  173. package/dist/src/document-model/gen/state/operations.d.ts.map +1 -0
  174. package/dist/src/document-model/gen/state/operations.js +1 -0
  175. package/dist/src/document-model/gen/types.d.ts +7 -0
  176. package/dist/src/document-model/gen/types.d.ts.map +1 -0
  177. package/dist/src/document-model/gen/types.js +1 -0
  178. package/dist/src/document-model/gen/utils.d.ts +11 -0
  179. package/dist/src/document-model/gen/utils.d.ts.map +1 -0
  180. package/dist/src/document-model/gen/utils.js +29 -0
  181. package/dist/src/document-model/gen/versioning/actions.d.ts +9 -0
  182. package/dist/src/document-model/gen/versioning/actions.d.ts.map +1 -0
  183. package/dist/src/document-model/gen/versioning/actions.js +1 -0
  184. package/dist/{browser/src → src}/document-model/gen/versioning/creators.d.ts +2 -2
  185. package/dist/src/document-model/gen/versioning/creators.d.ts.map +1 -0
  186. package/dist/src/document-model/gen/versioning/creators.js +12 -0
  187. package/dist/src/document-model/gen/versioning/object.d.ts +13 -0
  188. package/dist/src/document-model/gen/versioning/object.d.ts.map +1 -0
  189. package/dist/src/document-model/gen/versioning/object.js +19 -0
  190. package/dist/{browser/src → src}/document-model/gen/versioning/operations.d.ts +2 -2
  191. package/dist/src/document-model/gen/versioning/operations.d.ts.map +1 -0
  192. package/dist/src/document-model/gen/versioning/operations.js +1 -0
  193. package/dist/src/document-model/module.d.ts +3 -0
  194. package/dist/src/document-model/module.d.ts.map +1 -0
  195. package/dist/src/document-model/module.js +12 -0
  196. package/dist/src/document-model/types.d.ts +4 -0
  197. package/dist/src/document-model/types.d.ts.map +1 -0
  198. package/dist/src/document-model/types.js +1 -0
  199. package/dist/test/document/crypto.test.d.ts.map +1 -0
  200. package/dist/test/document/crypto.test.js +180 -0
  201. package/dist/test/document/event-vs-command.test.d.ts.map +1 -0
  202. package/dist/test/document/event-vs-command.test.js +168 -0
  203. package/dist/test/document/local.test.d.ts.map +1 -0
  204. package/dist/test/document/local.test.js +247 -0
  205. package/dist/test/document/object.test.d.ts.map +1 -0
  206. package/dist/test/document/object.test.js +12 -0
  207. package/dist/test/document/operation-id.test.d.ts.map +1 -0
  208. package/dist/test/document/operation-id.test.js +158 -0
  209. package/dist/test/document/prune.test.d.ts.map +1 -0
  210. package/dist/test/document/prune.test.js +176 -0
  211. package/dist/test/document/reducer.test.d.ts.map +1 -0
  212. package/dist/test/document/reducer.test.js +268 -0
  213. package/dist/test/document/skip-operations.test.d.ts.map +1 -0
  214. package/dist/test/document/skip-operations.test.js +441 -0
  215. package/dist/test/document/undo-redo.test.d.ts.map +1 -0
  216. package/dist/test/document/undo-redo.test.js +376 -0
  217. package/dist/test/document/utils.test.d.ts.map +1 -0
  218. package/dist/test/document/utils.test.js +151 -0
  219. package/dist/test/document-helpers/addUndo.test.d.ts.map +1 -0
  220. package/dist/test/document-helpers/addUndo.test.js +119 -0
  221. package/dist/test/document-helpers/attachBranch.test.d.ts.map +1 -0
  222. package/dist/test/document-helpers/attachBranch.test.js +363 -0
  223. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +1 -0
  224. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js +251 -0
  225. package/dist/test/document-helpers/conflictResolution.test.d.ts.map +1 -0
  226. package/dist/test/document-helpers/conflictResolution.test.js +108 -0
  227. package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +1 -0
  228. package/dist/test/document-helpers/filterDuplicatedOperations.test.js +125 -0
  229. package/dist/test/document-helpers/garbageCollect.test.d.ts.map +1 -0
  230. package/dist/test/document-helpers/garbageCollect.test.js +135 -0
  231. package/dist/test/document-helpers/groupOperationsByScope.test.d.ts.map +1 -0
  232. package/dist/test/document-helpers/groupOperationsByScope.test.js +97 -0
  233. package/dist/test/document-helpers/merge.test.d.ts.map +1 -0
  234. package/dist/test/document-helpers/merge.test.js +905 -0
  235. package/dist/test/document-helpers/nextSkipNumber.test.d.ts.map +1 -0
  236. package/dist/test/document-helpers/nextSkipNumber.test.js +134 -0
  237. package/dist/test/document-helpers/prepareOperations.test.d.ts.map +1 -0
  238. package/dist/test/document-helpers/prepareOperations.test.js +303 -0
  239. package/dist/test/document-helpers/removeExistingOperations.test.d.ts.map +1 -0
  240. package/dist/test/document-helpers/removeExistingOperations.test.js +149 -0
  241. package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +1 -0
  242. package/dist/test/document-helpers/reshuffleByTimestamp.test.js +147 -0
  243. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +1 -0
  244. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js +199 -0
  245. package/dist/test/document-helpers/skipHeaderOperations.test.d.ts.map +1 -0
  246. package/dist/test/document-helpers/skipHeaderOperations.test.js +73 -0
  247. package/dist/test/document-helpers/sortOperations.test.d.ts.map +1 -0
  248. package/dist/test/document-helpers/sortOperations.test.js +100 -0
  249. package/dist/test/document-helpers/split.test.d.ts.map +1 -0
  250. package/dist/test/document-helpers/split.test.js +120 -0
  251. package/dist/{browser/test → test}/document-helpers/utils.d.ts +1 -1
  252. package/dist/test/document-helpers/utils.d.ts.map +1 -0
  253. package/dist/test/document-helpers/utils.js +21 -0
  254. package/dist/test/document-model/object.test.d.ts.map +1 -0
  255. package/dist/test/document-model/object.test.js +242 -0
  256. package/dist/test/document-model/replay.test.d.ts.map +1 -0
  257. package/dist/test/document-model/replay.test.js +137 -0
  258. package/dist/test/document-model/skip-operations.test.d.ts.map +1 -0
  259. package/dist/test/document-model/skip-operations.test.js +216 -0
  260. package/dist/test/document-model/validation.test.d.ts.map +1 -0
  261. package/dist/test/document-model/validation.test.js +257 -0
  262. package/dist/test/document-model/zip.test.d.ts.map +1 -0
  263. package/dist/test/document-model/zip.test.js +80 -0
  264. package/dist/test/helpers.d.ts +31 -0
  265. package/dist/test/helpers.d.ts.map +1 -0
  266. package/dist/test/helpers.js +69 -0
  267. package/dist/tsconfig.tsbuildinfo +1 -0
  268. package/dist/vitest.config.d.ts +3 -0
  269. package/dist/vitest.config.d.ts.map +1 -0
  270. package/dist/vitest.config.js +6 -0
  271. package/package.json +16 -53
  272. package/dist/browser/cjs/document-model.js +0 -21
  273. package/dist/browser/cjs/document-model.js.map +0 -1
  274. package/dist/browser/cjs/document.js +0 -16
  275. package/dist/browser/cjs/document.js.map +0 -1
  276. package/dist/browser/cjs/index.js +0 -14
  277. package/dist/browser/cjs/index.js.map +0 -1
  278. package/dist/browser/cjs/internal/creators-DJg3Kd1P.js +0 -2901
  279. package/dist/browser/cjs/internal/creators-DJg3Kd1P.js.map +0 -1
  280. package/dist/browser/cjs/internal/index-CGExio27.js +0 -2216
  281. package/dist/browser/cjs/internal/index-CGExio27.js.map +0 -1
  282. package/dist/browser/cjs/internal/index-CQg4iLBq.js +0 -19
  283. package/dist/browser/cjs/internal/index-CQg4iLBq.js.map +0 -1
  284. package/dist/browser/cjs/internal/index-DcdJY5J3.js +0 -47
  285. package/dist/browser/cjs/internal/index-DcdJY5J3.js.map +0 -1
  286. package/dist/browser/cjs/internal/object-C3OfcOUa.js +0 -183
  287. package/dist/browser/cjs/internal/object-C3OfcOUa.js.map +0 -1
  288. package/dist/browser/cjs/package.json +0 -1
  289. package/dist/browser/cjs/utils.js +0 -44
  290. package/dist/browser/cjs/utils.js.map +0 -1
  291. package/dist/browser/document-model.d.ts +0 -2
  292. package/dist/browser/document.d.ts +0 -2
  293. package/dist/browser/es/document-model.js +0 -21
  294. package/dist/browser/es/document-model.js.map +0 -1
  295. package/dist/browser/es/document.js +0 -16
  296. package/dist/browser/es/document.js.map +0 -1
  297. package/dist/browser/es/index.js +0 -14
  298. package/dist/browser/es/index.js.map +0 -1
  299. package/dist/browser/es/internal/creators-Dir4K_-h.js +0 -2902
  300. package/dist/browser/es/internal/creators-Dir4K_-h.js.map +0 -1
  301. package/dist/browser/es/internal/index-BxCiP58y.js +0 -48
  302. package/dist/browser/es/internal/index-BxCiP58y.js.map +0 -1
  303. package/dist/browser/es/internal/index-HlkIVQZ6.js +0 -2217
  304. package/dist/browser/es/internal/index-HlkIVQZ6.js.map +0 -1
  305. package/dist/browser/es/internal/index-qYp7hG3r.js +0 -20
  306. package/dist/browser/es/internal/index-qYp7hG3r.js.map +0 -1
  307. package/dist/browser/es/internal/object-CzFSgK3q.js +0 -184
  308. package/dist/browser/es/internal/object-CzFSgK3q.js.map +0 -1
  309. package/dist/browser/es/package.json +0 -1
  310. package/dist/browser/es/utils.js +0 -44
  311. package/dist/browser/es/utils.js.map +0 -1
  312. package/dist/browser/index.d.ts +0 -6
  313. package/dist/browser/src/document/actions/creators.d.ts.map +0 -1
  314. package/dist/browser/src/document/actions/index.d.ts +0 -15
  315. package/dist/browser/src/document/actions/index.d.ts.map +0 -1
  316. package/dist/browser/src/document/actions/types.d.ts +0 -16
  317. package/dist/browser/src/document/actions/types.d.ts.map +0 -1
  318. package/dist/browser/src/document/index.d.ts +0 -7
  319. package/dist/browser/src/document/index.d.ts.map +0 -1
  320. package/dist/browser/src/document/object.d.ts.map +0 -1
  321. package/dist/browser/src/document/reducer.d.ts +0 -66
  322. package/dist/browser/src/document/reducer.d.ts.map +0 -1
  323. package/dist/browser/src/document/schema/index.d.ts +0 -3
  324. package/dist/browser/src/document/schema/index.d.ts.map +0 -1
  325. package/dist/browser/src/document/schema/types.d.ts.map +0 -1
  326. package/dist/browser/src/document/schema/zod.d.ts.map +0 -1
  327. package/dist/browser/src/document/signal.d.ts +0 -30
  328. package/dist/browser/src/document/signal.d.ts.map +0 -1
  329. package/dist/browser/src/document/types.d.ts +0 -292
  330. package/dist/browser/src/document/types.d.ts.map +0 -1
  331. package/dist/browser/src/document/utils/base.d.ts +0 -89
  332. package/dist/browser/src/document/utils/base.d.ts.map +0 -1
  333. package/dist/browser/src/document/utils/browser.d.ts.map +0 -1
  334. package/dist/browser/src/document/utils/crypto.d.ts +0 -11
  335. package/dist/browser/src/document/utils/crypto.d.ts.map +0 -1
  336. package/dist/browser/src/document/utils/document-helpers.d.ts +0 -74
  337. package/dist/browser/src/document/utils/document-helpers.d.ts.map +0 -1
  338. package/dist/browser/src/document/utils/errors.d.ts.map +0 -1
  339. package/dist/browser/src/document/utils/file.d.ts.map +0 -1
  340. package/dist/browser/src/document/utils/index.d.ts +0 -8
  341. package/dist/browser/src/document/utils/index.d.ts.map +0 -1
  342. package/dist/browser/src/document/utils/node.d.ts.map +0 -1
  343. package/dist/browser/src/document/utils/validation.d.ts +0 -3
  344. package/dist/browser/src/document/utils/validation.d.ts.map +0 -1
  345. package/dist/browser/src/document-model/custom/reducers/header.d.ts +0 -3
  346. package/dist/browser/src/document-model/custom/reducers/header.d.ts.map +0 -1
  347. package/dist/browser/src/document-model/custom/reducers/module.d.ts +0 -3
  348. package/dist/browser/src/document-model/custom/reducers/module.d.ts.map +0 -1
  349. package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts +0 -3
  350. package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts.map +0 -1
  351. package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts +0 -3
  352. package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts.map +0 -1
  353. package/dist/browser/src/document-model/custom/reducers/operation.d.ts +0 -3
  354. package/dist/browser/src/document-model/custom/reducers/operation.d.ts.map +0 -1
  355. package/dist/browser/src/document-model/custom/reducers/state.d.ts +0 -3
  356. package/dist/browser/src/document-model/custom/reducers/state.d.ts.map +0 -1
  357. package/dist/browser/src/document-model/custom/reducers/versioning.d.ts +0 -3
  358. package/dist/browser/src/document-model/custom/reducers/versioning.d.ts.map +0 -1
  359. package/dist/browser/src/document-model/custom/utils.d.ts.map +0 -1
  360. package/dist/browser/src/document-model/gen/actions.d.ts +0 -16
  361. package/dist/browser/src/document-model/gen/actions.d.ts.map +0 -1
  362. package/dist/browser/src/document-model/gen/creators.d.ts +0 -8
  363. package/dist/browser/src/document-model/gen/creators.d.ts.map +0 -1
  364. package/dist/browser/src/document-model/gen/document-model.d.ts +0 -3
  365. package/dist/browser/src/document-model/gen/document-model.d.ts.map +0 -1
  366. package/dist/browser/src/document-model/gen/header/actions.d.ts +0 -10
  367. package/dist/browser/src/document-model/gen/header/actions.d.ts.map +0 -1
  368. package/dist/browser/src/document-model/gen/header/creators.d.ts.map +0 -1
  369. package/dist/browser/src/document-model/gen/header/object.d.ts +0 -13
  370. package/dist/browser/src/document-model/gen/header/object.d.ts.map +0 -1
  371. package/dist/browser/src/document-model/gen/header/operations.d.ts +0 -11
  372. package/dist/browser/src/document-model/gen/header/operations.d.ts.map +0 -1
  373. package/dist/browser/src/document-model/gen/index.d.ts +0 -6
  374. package/dist/browser/src/document-model/gen/index.d.ts.map +0 -1
  375. package/dist/browser/src/document-model/gen/module/actions.d.ts +0 -9
  376. package/dist/browser/src/document-model/gen/module/actions.d.ts.map +0 -1
  377. package/dist/browser/src/document-model/gen/module/creators.d.ts +0 -8
  378. package/dist/browser/src/document-model/gen/module/creators.d.ts.map +0 -1
  379. package/dist/browser/src/document-model/gen/module/object.d.ts +0 -12
  380. package/dist/browser/src/document-model/gen/module/object.d.ts.map +0 -1
  381. package/dist/browser/src/document-model/gen/module/operations.d.ts.map +0 -1
  382. package/dist/browser/src/document-model/gen/object.d.ts +0 -29
  383. package/dist/browser/src/document-model/gen/object.d.ts.map +0 -1
  384. package/dist/browser/src/document-model/gen/operation/actions.d.ts +0 -14
  385. package/dist/browser/src/document-model/gen/operation/actions.d.ts.map +0 -1
  386. package/dist/browser/src/document-model/gen/operation/creators.d.ts.map +0 -1
  387. package/dist/browser/src/document-model/gen/operation/object.d.ts +0 -17
  388. package/dist/browser/src/document-model/gen/operation/object.d.ts.map +0 -1
  389. package/dist/browser/src/document-model/gen/operation/operations.d.ts.map +0 -1
  390. package/dist/browser/src/document-model/gen/operation-error/actions.d.ts +0 -11
  391. package/dist/browser/src/document-model/gen/operation-error/actions.d.ts.map +0 -1
  392. package/dist/browser/src/document-model/gen/operation-error/creators.d.ts +0 -10
  393. package/dist/browser/src/document-model/gen/operation-error/creators.d.ts.map +0 -1
  394. package/dist/browser/src/document-model/gen/operation-error/object.d.ts +0 -14
  395. package/dist/browser/src/document-model/gen/operation-error/object.d.ts.map +0 -1
  396. package/dist/browser/src/document-model/gen/operation-error/operations.d.ts.map +0 -1
  397. package/dist/browser/src/document-model/gen/operation-example/actions.d.ts +0 -8
  398. package/dist/browser/src/document-model/gen/operation-example/actions.d.ts.map +0 -1
  399. package/dist/browser/src/document-model/gen/operation-example/creators.d.ts.map +0 -1
  400. package/dist/browser/src/document-model/gen/operation-example/object.d.ts +0 -11
  401. package/dist/browser/src/document-model/gen/operation-example/object.d.ts.map +0 -1
  402. package/dist/browser/src/document-model/gen/operation-example/operations.d.ts.map +0 -1
  403. package/dist/browser/src/document-model/gen/reducer.d.ts +0 -6
  404. package/dist/browser/src/document-model/gen/reducer.d.ts.map +0 -1
  405. package/dist/browser/src/document-model/gen/schema/index.d.ts +0 -3
  406. package/dist/browser/src/document-model/gen/schema/index.d.ts.map +0 -1
  407. package/dist/browser/src/document-model/gen/schema/types.d.ts +0 -454
  408. package/dist/browser/src/document-model/gen/schema/types.d.ts.map +0 -1
  409. package/dist/browser/src/document-model/gen/schema/zod.d.ts.map +0 -1
  410. package/dist/browser/src/document-model/gen/state/actions.d.ts +0 -10
  411. package/dist/browser/src/document-model/gen/state/actions.d.ts.map +0 -1
  412. package/dist/browser/src/document-model/gen/state/creators.d.ts.map +0 -1
  413. package/dist/browser/src/document-model/gen/state/object.d.ts +0 -13
  414. package/dist/browser/src/document-model/gen/state/object.d.ts.map +0 -1
  415. package/dist/browser/src/document-model/gen/state/operations.d.ts.map +0 -1
  416. package/dist/browser/src/document-model/gen/types.d.ts +0 -9
  417. package/dist/browser/src/document-model/gen/types.d.ts.map +0 -1
  418. package/dist/browser/src/document-model/gen/utils.d.ts +0 -7
  419. package/dist/browser/src/document-model/gen/utils.d.ts.map +0 -1
  420. package/dist/browser/src/document-model/gen/versioning/actions.d.ts +0 -9
  421. package/dist/browser/src/document-model/gen/versioning/actions.d.ts.map +0 -1
  422. package/dist/browser/src/document-model/gen/versioning/creators.d.ts.map +0 -1
  423. package/dist/browser/src/document-model/gen/versioning/object.d.ts +0 -12
  424. package/dist/browser/src/document-model/gen/versioning/object.d.ts.map +0 -1
  425. package/dist/browser/src/document-model/gen/versioning/operations.d.ts.map +0 -1
  426. package/dist/browser/src/document-model/index.d.ts +0 -77
  427. package/dist/browser/src/document-model/index.d.ts.map +0 -1
  428. package/dist/browser/src/index.d.ts +0 -25
  429. package/dist/browser/src/index.d.ts.map +0 -1
  430. package/dist/browser/test/document/crypto.test.d.ts.map +0 -1
  431. package/dist/browser/test/document/event-vs-command.test.d.ts.map +0 -1
  432. package/dist/browser/test/document/local.test.d.ts.map +0 -1
  433. package/dist/browser/test/document/object.test.d.ts.map +0 -1
  434. package/dist/browser/test/document/operation-id.test.d.ts.map +0 -1
  435. package/dist/browser/test/document/prune.test.d.ts.map +0 -1
  436. package/dist/browser/test/document/reducer.test.d.ts.map +0 -1
  437. package/dist/browser/test/document/skip-operations.test.d.ts.map +0 -1
  438. package/dist/browser/test/document/undo-redo.test.d.ts.map +0 -1
  439. package/dist/browser/test/document/utils.test.d.ts.map +0 -1
  440. package/dist/browser/test/document-helpers/addUndo.test.d.ts.map +0 -1
  441. package/dist/browser/test/document-helpers/attachBranch.test.d.ts.map +0 -1
  442. package/dist/browser/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
  443. package/dist/browser/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
  444. package/dist/browser/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
  445. package/dist/browser/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
  446. package/dist/browser/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
  447. package/dist/browser/test/document-helpers/merge.test.d.ts.map +0 -1
  448. package/dist/browser/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
  449. package/dist/browser/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
  450. package/dist/browser/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
  451. package/dist/browser/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
  452. package/dist/browser/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
  453. package/dist/browser/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
  454. package/dist/browser/test/document-helpers/sortOperations.test.d.ts.map +0 -1
  455. package/dist/browser/test/document-helpers/split.test.d.ts.map +0 -1
  456. package/dist/browser/test/document-helpers/utils.d.ts.map +0 -1
  457. package/dist/browser/test/document-model/object.test.d.ts.map +0 -1
  458. package/dist/browser/test/document-model/replay.test.d.ts.map +0 -1
  459. package/dist/browser/test/document-model/skip-operations.test.d.ts.map +0 -1
  460. package/dist/browser/test/document-model/validation.test.d.ts.map +0 -1
  461. package/dist/browser/test/document-model/zip.test.d.ts.map +0 -1
  462. package/dist/browser/test/helpers.d.ts +0 -40
  463. package/dist/browser/test/helpers.d.ts.map +0 -1
  464. package/dist/browser/utils.d.ts +0 -2
  465. package/dist/browser/vite.config.d.ts +0 -3
  466. package/dist/browser/vite.config.d.ts.map +0 -1
  467. package/dist/browser/vitest.config.d.ts +0 -3
  468. package/dist/browser/vitest.config.d.ts.map +0 -1
  469. package/dist/node/cjs/document-model.js +0 -25
  470. package/dist/node/cjs/document-model.js.map +0 -1
  471. package/dist/node/cjs/document.js +0 -16
  472. package/dist/node/cjs/document.js.map +0 -1
  473. package/dist/node/cjs/index.js +0 -14
  474. package/dist/node/cjs/index.js.map +0 -1
  475. package/dist/node/cjs/internal/creators-ZpkFlacS.js +0 -2684
  476. package/dist/node/cjs/internal/creators-ZpkFlacS.js.map +0 -1
  477. package/dist/node/cjs/internal/index-B9N2GsMZ.js +0 -47
  478. package/dist/node/cjs/internal/index-B9N2GsMZ.js.map +0 -1
  479. package/dist/node/cjs/internal/index-ClITlWIV.js +0 -19
  480. package/dist/node/cjs/internal/index-ClITlWIV.js.map +0 -1
  481. package/dist/node/cjs/internal/index-DVgdtYs7.js +0 -2220
  482. package/dist/node/cjs/internal/index-DVgdtYs7.js.map +0 -1
  483. package/dist/node/cjs/internal/object-DVKEoARn.js +0 -183
  484. package/dist/node/cjs/internal/object-DVKEoARn.js.map +0 -1
  485. package/dist/node/cjs/package.json +0 -1
  486. package/dist/node/cjs/utils.js +0 -44
  487. package/dist/node/cjs/utils.js.map +0 -1
  488. package/dist/node/document-model.d.ts +0 -2
  489. package/dist/node/document.d.ts +0 -2
  490. package/dist/node/es/document-model.js +0 -25
  491. package/dist/node/es/document-model.js.map +0 -1
  492. package/dist/node/es/document.js +0 -16
  493. package/dist/node/es/document.js.map +0 -1
  494. package/dist/node/es/index.js +0 -14
  495. package/dist/node/es/index.js.map +0 -1
  496. package/dist/node/es/internal/creators-0lHfLHX0.js +0 -2685
  497. package/dist/node/es/internal/creators-0lHfLHX0.js.map +0 -1
  498. package/dist/node/es/internal/index-BOhJLvSm.js +0 -48
  499. package/dist/node/es/internal/index-BOhJLvSm.js.map +0 -1
  500. package/dist/node/es/internal/index-CxWihLAA.js +0 -2221
  501. package/dist/node/es/internal/index-CxWihLAA.js.map +0 -1
  502. package/dist/node/es/internal/index-bxdb71Hw.js +0 -20
  503. package/dist/node/es/internal/index-bxdb71Hw.js.map +0 -1
  504. package/dist/node/es/internal/object-Bl-LmXHF.js +0 -184
  505. package/dist/node/es/internal/object-Bl-LmXHF.js.map +0 -1
  506. package/dist/node/es/package.json +0 -1
  507. package/dist/node/es/utils.js +0 -44
  508. package/dist/node/es/utils.js.map +0 -1
  509. package/dist/node/index.d.ts +0 -6
  510. package/dist/node/src/document/actions/creators.d.ts.map +0 -1
  511. package/dist/node/src/document/actions/index.d.ts +0 -15
  512. package/dist/node/src/document/actions/index.d.ts.map +0 -1
  513. package/dist/node/src/document/actions/types.d.ts +0 -16
  514. package/dist/node/src/document/actions/types.d.ts.map +0 -1
  515. package/dist/node/src/document/index.d.ts +0 -7
  516. package/dist/node/src/document/index.d.ts.map +0 -1
  517. package/dist/node/src/document/object.d.ts.map +0 -1
  518. package/dist/node/src/document/reducer.d.ts +0 -66
  519. package/dist/node/src/document/reducer.d.ts.map +0 -1
  520. package/dist/node/src/document/schema/index.d.ts +0 -3
  521. package/dist/node/src/document/schema/index.d.ts.map +0 -1
  522. package/dist/node/src/document/schema/types.d.ts +0 -177
  523. package/dist/node/src/document/schema/types.d.ts.map +0 -1
  524. package/dist/node/src/document/schema/zod.d.ts +0 -99
  525. package/dist/node/src/document/schema/zod.d.ts.map +0 -1
  526. package/dist/node/src/document/signal.d.ts.map +0 -1
  527. package/dist/node/src/document/types.d.ts +0 -292
  528. package/dist/node/src/document/types.d.ts.map +0 -1
  529. package/dist/node/src/document/utils/base.d.ts +0 -89
  530. package/dist/node/src/document/utils/base.d.ts.map +0 -1
  531. package/dist/node/src/document/utils/browser.d.ts +0 -11
  532. package/dist/node/src/document/utils/browser.d.ts.map +0 -1
  533. package/dist/node/src/document/utils/crypto.d.ts +0 -11
  534. package/dist/node/src/document/utils/crypto.d.ts.map +0 -1
  535. package/dist/node/src/document/utils/document-helpers.d.ts +0 -74
  536. package/dist/node/src/document/utils/document-helpers.d.ts.map +0 -1
  537. package/dist/node/src/document/utils/errors.d.ts +0 -10
  538. package/dist/node/src/document/utils/errors.d.ts.map +0 -1
  539. package/dist/node/src/document/utils/file.d.ts +0 -49
  540. package/dist/node/src/document/utils/file.d.ts.map +0 -1
  541. package/dist/node/src/document/utils/index.d.ts +0 -8
  542. package/dist/node/src/document/utils/index.d.ts.map +0 -1
  543. package/dist/node/src/document/utils/node.d.ts +0 -11
  544. package/dist/node/src/document/utils/node.d.ts.map +0 -1
  545. package/dist/node/src/document/utils/validation.d.ts +0 -3
  546. package/dist/node/src/document/utils/validation.d.ts.map +0 -1
  547. package/dist/node/src/document-model/custom/reducers/header.d.ts +0 -3
  548. package/dist/node/src/document-model/custom/reducers/header.d.ts.map +0 -1
  549. package/dist/node/src/document-model/custom/reducers/module.d.ts +0 -3
  550. package/dist/node/src/document-model/custom/reducers/module.d.ts.map +0 -1
  551. package/dist/node/src/document-model/custom/reducers/operation-error.d.ts +0 -3
  552. package/dist/node/src/document-model/custom/reducers/operation-error.d.ts.map +0 -1
  553. package/dist/node/src/document-model/custom/reducers/operation-example.d.ts +0 -3
  554. package/dist/node/src/document-model/custom/reducers/operation-example.d.ts.map +0 -1
  555. package/dist/node/src/document-model/custom/reducers/operation.d.ts +0 -3
  556. package/dist/node/src/document-model/custom/reducers/operation.d.ts.map +0 -1
  557. package/dist/node/src/document-model/custom/reducers/state.d.ts +0 -3
  558. package/dist/node/src/document-model/custom/reducers/state.d.ts.map +0 -1
  559. package/dist/node/src/document-model/custom/reducers/versioning.d.ts +0 -3
  560. package/dist/node/src/document-model/custom/reducers/versioning.d.ts.map +0 -1
  561. package/dist/node/src/document-model/custom/utils.d.ts +0 -8
  562. package/dist/node/src/document-model/custom/utils.d.ts.map +0 -1
  563. package/dist/node/src/document-model/gen/actions.d.ts +0 -16
  564. package/dist/node/src/document-model/gen/actions.d.ts.map +0 -1
  565. package/dist/node/src/document-model/gen/creators.d.ts +0 -8
  566. package/dist/node/src/document-model/gen/creators.d.ts.map +0 -1
  567. package/dist/node/src/document-model/gen/document-model.d.ts +0 -3
  568. package/dist/node/src/document-model/gen/document-model.d.ts.map +0 -1
  569. package/dist/node/src/document-model/gen/header/actions.d.ts +0 -10
  570. package/dist/node/src/document-model/gen/header/actions.d.ts.map +0 -1
  571. package/dist/node/src/document-model/gen/header/creators.d.ts +0 -9
  572. package/dist/node/src/document-model/gen/header/creators.d.ts.map +0 -1
  573. package/dist/node/src/document-model/gen/header/object.d.ts +0 -13
  574. package/dist/node/src/document-model/gen/header/object.d.ts.map +0 -1
  575. package/dist/node/src/document-model/gen/header/operations.d.ts.map +0 -1
  576. package/dist/node/src/document-model/gen/index.d.ts +0 -6
  577. package/dist/node/src/document-model/gen/index.d.ts.map +0 -1
  578. package/dist/node/src/document-model/gen/module/actions.d.ts +0 -9
  579. package/dist/node/src/document-model/gen/module/actions.d.ts.map +0 -1
  580. package/dist/node/src/document-model/gen/module/creators.d.ts.map +0 -1
  581. package/dist/node/src/document-model/gen/module/object.d.ts +0 -12
  582. package/dist/node/src/document-model/gen/module/object.d.ts.map +0 -1
  583. package/dist/node/src/document-model/gen/module/operations.d.ts +0 -10
  584. package/dist/node/src/document-model/gen/module/operations.d.ts.map +0 -1
  585. package/dist/node/src/document-model/gen/object.d.ts +0 -29
  586. package/dist/node/src/document-model/gen/object.d.ts.map +0 -1
  587. package/dist/node/src/document-model/gen/operation/actions.d.ts +0 -14
  588. package/dist/node/src/document-model/gen/operation/actions.d.ts.map +0 -1
  589. package/dist/node/src/document-model/gen/operation/creators.d.ts +0 -13
  590. package/dist/node/src/document-model/gen/operation/creators.d.ts.map +0 -1
  591. package/dist/node/src/document-model/gen/operation/object.d.ts.map +0 -1
  592. package/dist/node/src/document-model/gen/operation/operations.d.ts +0 -15
  593. package/dist/node/src/document-model/gen/operation/operations.d.ts.map +0 -1
  594. package/dist/node/src/document-model/gen/operation-error/actions.d.ts +0 -11
  595. package/dist/node/src/document-model/gen/operation-error/actions.d.ts.map +0 -1
  596. package/dist/node/src/document-model/gen/operation-error/creators.d.ts.map +0 -1
  597. package/dist/node/src/document-model/gen/operation-error/object.d.ts.map +0 -1
  598. package/dist/node/src/document-model/gen/operation-error/operations.d.ts +0 -12
  599. package/dist/node/src/document-model/gen/operation-error/operations.d.ts.map +0 -1
  600. package/dist/node/src/document-model/gen/operation-example/actions.d.ts +0 -8
  601. package/dist/node/src/document-model/gen/operation-example/actions.d.ts.map +0 -1
  602. package/dist/node/src/document-model/gen/operation-example/creators.d.ts +0 -7
  603. package/dist/node/src/document-model/gen/operation-example/creators.d.ts.map +0 -1
  604. package/dist/node/src/document-model/gen/operation-example/object.d.ts +0 -11
  605. package/dist/node/src/document-model/gen/operation-example/object.d.ts.map +0 -1
  606. package/dist/node/src/document-model/gen/operation-example/operations.d.ts +0 -9
  607. package/dist/node/src/document-model/gen/operation-example/operations.d.ts.map +0 -1
  608. package/dist/node/src/document-model/gen/reducer.d.ts +0 -6
  609. package/dist/node/src/document-model/gen/reducer.d.ts.map +0 -1
  610. package/dist/node/src/document-model/gen/schema/index.d.ts +0 -3
  611. package/dist/node/src/document-model/gen/schema/index.d.ts.map +0 -1
  612. package/dist/node/src/document-model/gen/schema/types.d.ts.map +0 -1
  613. package/dist/node/src/document-model/gen/schema/zod.d.ts +0 -454
  614. package/dist/node/src/document-model/gen/schema/zod.d.ts.map +0 -1
  615. package/dist/node/src/document-model/gen/state/actions.d.ts +0 -10
  616. package/dist/node/src/document-model/gen/state/actions.d.ts.map +0 -1
  617. package/dist/node/src/document-model/gen/state/creators.d.ts +0 -9
  618. package/dist/node/src/document-model/gen/state/creators.d.ts.map +0 -1
  619. package/dist/node/src/document-model/gen/state/object.d.ts +0 -13
  620. package/dist/node/src/document-model/gen/state/object.d.ts.map +0 -1
  621. package/dist/node/src/document-model/gen/state/operations.d.ts +0 -11
  622. package/dist/node/src/document-model/gen/state/operations.d.ts.map +0 -1
  623. package/dist/node/src/document-model/gen/types.d.ts +0 -9
  624. package/dist/node/src/document-model/gen/types.d.ts.map +0 -1
  625. package/dist/node/src/document-model/gen/utils.d.ts +0 -7
  626. package/dist/node/src/document-model/gen/utils.d.ts.map +0 -1
  627. package/dist/node/src/document-model/gen/versioning/actions.d.ts +0 -9
  628. package/dist/node/src/document-model/gen/versioning/actions.d.ts.map +0 -1
  629. package/dist/node/src/document-model/gen/versioning/creators.d.ts +0 -8
  630. package/dist/node/src/document-model/gen/versioning/creators.d.ts.map +0 -1
  631. package/dist/node/src/document-model/gen/versioning/object.d.ts +0 -12
  632. package/dist/node/src/document-model/gen/versioning/object.d.ts.map +0 -1
  633. package/dist/node/src/document-model/gen/versioning/operations.d.ts +0 -10
  634. package/dist/node/src/document-model/gen/versioning/operations.d.ts.map +0 -1
  635. package/dist/node/src/document-model/index.d.ts +0 -77
  636. package/dist/node/src/document-model/index.d.ts.map +0 -1
  637. package/dist/node/src/index.d.ts +0 -25
  638. package/dist/node/src/index.d.ts.map +0 -1
  639. package/dist/node/test/document/crypto.test.d.ts +0 -2
  640. package/dist/node/test/document/crypto.test.d.ts.map +0 -1
  641. package/dist/node/test/document/event-vs-command.test.d.ts +0 -2
  642. package/dist/node/test/document/event-vs-command.test.d.ts.map +0 -1
  643. package/dist/node/test/document/local.test.d.ts +0 -2
  644. package/dist/node/test/document/local.test.d.ts.map +0 -1
  645. package/dist/node/test/document/object.test.d.ts +0 -2
  646. package/dist/node/test/document/object.test.d.ts.map +0 -1
  647. package/dist/node/test/document/operation-id.test.d.ts +0 -2
  648. package/dist/node/test/document/operation-id.test.d.ts.map +0 -1
  649. package/dist/node/test/document/prune.test.d.ts +0 -2
  650. package/dist/node/test/document/prune.test.d.ts.map +0 -1
  651. package/dist/node/test/document/reducer.test.d.ts +0 -2
  652. package/dist/node/test/document/reducer.test.d.ts.map +0 -1
  653. package/dist/node/test/document/skip-operations.test.d.ts +0 -2
  654. package/dist/node/test/document/skip-operations.test.d.ts.map +0 -1
  655. package/dist/node/test/document/undo-redo.test.d.ts +0 -2
  656. package/dist/node/test/document/undo-redo.test.d.ts.map +0 -1
  657. package/dist/node/test/document/utils.test.d.ts +0 -2
  658. package/dist/node/test/document/utils.test.d.ts.map +0 -1
  659. package/dist/node/test/document-helpers/addUndo.test.d.ts +0 -2
  660. package/dist/node/test/document-helpers/addUndo.test.d.ts.map +0 -1
  661. package/dist/node/test/document-helpers/attachBranch.test.d.ts +0 -2
  662. package/dist/node/test/document-helpers/attachBranch.test.d.ts.map +0 -1
  663. package/dist/node/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -2
  664. package/dist/node/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
  665. package/dist/node/test/document-helpers/conflictResolution.test.d.ts +0 -2
  666. package/dist/node/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
  667. package/dist/node/test/document-helpers/filterDuplicatedOperations.test.d.ts +0 -2
  668. package/dist/node/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
  669. package/dist/node/test/document-helpers/garbageCollect.test.d.ts +0 -2
  670. package/dist/node/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
  671. package/dist/node/test/document-helpers/groupOperationsByScope.test.d.ts +0 -2
  672. package/dist/node/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
  673. package/dist/node/test/document-helpers/merge.test.d.ts +0 -2
  674. package/dist/node/test/document-helpers/merge.test.d.ts.map +0 -1
  675. package/dist/node/test/document-helpers/nextSkipNumber.test.d.ts +0 -2
  676. package/dist/node/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
  677. package/dist/node/test/document-helpers/prepareOperations.test.d.ts +0 -2
  678. package/dist/node/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
  679. package/dist/node/test/document-helpers/removeExistingOperations.test.d.ts +0 -2
  680. package/dist/node/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
  681. package/dist/node/test/document-helpers/reshuffleByTimestamp.test.d.ts +0 -2
  682. package/dist/node/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
  683. package/dist/node/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -2
  684. package/dist/node/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
  685. package/dist/node/test/document-helpers/skipHeaderOperations.test.d.ts +0 -2
  686. package/dist/node/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
  687. package/dist/node/test/document-helpers/sortOperations.test.d.ts +0 -2
  688. package/dist/node/test/document-helpers/sortOperations.test.d.ts.map +0 -1
  689. package/dist/node/test/document-helpers/split.test.d.ts +0 -2
  690. package/dist/node/test/document-helpers/split.test.d.ts.map +0 -1
  691. package/dist/node/test/document-helpers/utils.d.ts +0 -8
  692. package/dist/node/test/document-helpers/utils.d.ts.map +0 -1
  693. package/dist/node/test/document-model/object.test.d.ts +0 -2
  694. package/dist/node/test/document-model/object.test.d.ts.map +0 -1
  695. package/dist/node/test/document-model/replay.test.d.ts +0 -2
  696. package/dist/node/test/document-model/replay.test.d.ts.map +0 -1
  697. package/dist/node/test/document-model/skip-operations.test.d.ts +0 -2
  698. package/dist/node/test/document-model/skip-operations.test.d.ts.map +0 -1
  699. package/dist/node/test/document-model/validation.test.d.ts +0 -2
  700. package/dist/node/test/document-model/validation.test.d.ts.map +0 -1
  701. package/dist/node/test/document-model/zip.test.d.ts +0 -2
  702. package/dist/node/test/document-model/zip.test.d.ts.map +0 -1
  703. package/dist/node/test/helpers.d.ts +0 -40
  704. package/dist/node/test/helpers.d.ts.map +0 -1
  705. package/dist/node/utils.d.ts +0 -2
  706. package/dist/node/vite.config.d.ts +0 -3
  707. package/dist/node/vite.config.d.ts.map +0 -1
  708. package/dist/node/vitest.config.d.ts +0 -3
  709. package/dist/node/vitest.config.d.ts.map +0 -1
  710. /package/dist/{browser/test → test}/document/crypto.test.d.ts +0 -0
  711. /package/dist/{browser/test → test}/document/event-vs-command.test.d.ts +0 -0
  712. /package/dist/{browser/test → test}/document/local.test.d.ts +0 -0
  713. /package/dist/{browser/test → test}/document/object.test.d.ts +0 -0
  714. /package/dist/{browser/test → test}/document/operation-id.test.d.ts +0 -0
  715. /package/dist/{browser/test → test}/document/prune.test.d.ts +0 -0
  716. /package/dist/{browser/test → test}/document/reducer.test.d.ts +0 -0
  717. /package/dist/{browser/test → test}/document/skip-operations.test.d.ts +0 -0
  718. /package/dist/{browser/test → test}/document/undo-redo.test.d.ts +0 -0
  719. /package/dist/{browser/test → test}/document/utils.test.d.ts +0 -0
  720. /package/dist/{browser/test → test}/document-helpers/addUndo.test.d.ts +0 -0
  721. /package/dist/{browser/test → test}/document-helpers/attachBranch.test.d.ts +0 -0
  722. /package/dist/{browser/test → test}/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -0
  723. /package/dist/{browser/test → test}/document-helpers/conflictResolution.test.d.ts +0 -0
  724. /package/dist/{browser/test → test}/document-helpers/filterDuplicatedOperations.test.d.ts +0 -0
  725. /package/dist/{browser/test → test}/document-helpers/garbageCollect.test.d.ts +0 -0
  726. /package/dist/{browser/test → test}/document-helpers/groupOperationsByScope.test.d.ts +0 -0
  727. /package/dist/{browser/test → test}/document-helpers/merge.test.d.ts +0 -0
  728. /package/dist/{browser/test → test}/document-helpers/nextSkipNumber.test.d.ts +0 -0
  729. /package/dist/{browser/test → test}/document-helpers/prepareOperations.test.d.ts +0 -0
  730. /package/dist/{browser/test → test}/document-helpers/removeExistingOperations.test.d.ts +0 -0
  731. /package/dist/{browser/test → test}/document-helpers/reshuffleByTimestamp.test.d.ts +0 -0
  732. /package/dist/{browser/test → test}/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -0
  733. /package/dist/{browser/test → test}/document-helpers/skipHeaderOperations.test.d.ts +0 -0
  734. /package/dist/{browser/test → test}/document-helpers/sortOperations.test.d.ts +0 -0
  735. /package/dist/{browser/test → test}/document-helpers/split.test.d.ts +0 -0
  736. /package/dist/{browser/test → test}/document-model/object.test.d.ts +0 -0
  737. /package/dist/{browser/test → test}/document-model/replay.test.d.ts +0 -0
  738. /package/dist/{browser/test → test}/document-model/skip-operations.test.d.ts +0 -0
  739. /package/dist/{browser/test → test}/document-model/validation.test.d.ts +0 -0
  740. /package/dist/{browser/test → test}/document-model/zip.test.d.ts +0 -0
@@ -1,2901 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- const JSZip = require("jszip");
6
- const zod$1 = require("zod");
7
- const mutative = require("mutative");
8
- const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
9
- const definedNonNullAnySchema = zod$1.z.any().refine((v) => isDefinedNonNullAny(v));
10
- const Load_StateSchema = zod$1.z.enum(["LOAD_STATE"]);
11
- const PruneSchema = zod$1.z.enum(["PRUNE"]);
12
- const RedoSchema = zod$1.z.enum(["REDO"]);
13
- const Set_NameSchema = zod$1.z.enum(["SET_NAME"]);
14
- const UndoSchema = zod$1.z.enum(["UNDO"]);
15
- function ActionSchema() {
16
- return zod$1.z.object({
17
- __typename: zod$1.z.literal("Action").optional(),
18
- type: zod$1.z.string()
19
- });
20
- }
21
- function OperationScopeSchema() {
22
- return zod$1.z.literal("global").or(zod$1.z.literal("local"));
23
- }
24
- function BaseActionSchema() {
25
- return zod$1.z.union([
26
- LoadStateActionSchema(),
27
- PruneActionSchema(),
28
- RedoActionSchema(),
29
- SetNameActionSchema(),
30
- UndoActionSchema()
31
- ]);
32
- }
33
- function DocumentFileSchema() {
34
- return zod$1.z.object({
35
- __typename: zod$1.z.literal("DocumentFile").optional(),
36
- data: zod$1.z.string(),
37
- extension: zod$1.z.string().nullable(),
38
- fileName: zod$1.z.string().nullable(),
39
- mimeType: zod$1.z.string()
40
- });
41
- }
42
- function LoadStateActionSchema() {
43
- return zod$1.z.object({
44
- input: zod$1.z.lazy(() => LoadStateActionInputSchema()),
45
- type: Load_StateSchema,
46
- scope: OperationScopeSchema()
47
- });
48
- }
49
- function LoadStateActionInputSchema() {
50
- return zod$1.z.object({
51
- operations: zod$1.z.number(),
52
- state: zod$1.z.lazy(() => LoadStateActionStateInputSchema())
53
- });
54
- }
55
- function LoadStateActionStateInputSchema() {
56
- return zod$1.z.object({
57
- data: zod$1.z.unknown().nullish(),
58
- name: zod$1.z.string()
59
- });
60
- }
61
- function OperationSchema() {
62
- return zod$1.z.object({
63
- __typename: zod$1.z.literal("Operation").optional(),
64
- hash: zod$1.z.string(),
65
- index: zod$1.z.number(),
66
- timestamp: zod$1.z.string().datetime(),
67
- type: zod$1.z.string()
68
- });
69
- }
70
- function PruneActionSchema() {
71
- return zod$1.z.object({
72
- input: zod$1.z.lazy(() => PruneActionInputSchema()),
73
- type: PruneSchema,
74
- scope: OperationScopeSchema()
75
- });
76
- }
77
- function PruneActionInputSchema() {
78
- return zod$1.z.object({
79
- end: zod$1.z.number().nullish(),
80
- start: zod$1.z.number().nullish()
81
- });
82
- }
83
- const RedoActionInputSchema = zod$1.z.number;
84
- function RedoActionSchema() {
85
- return zod$1.z.object({
86
- input: RedoActionInputSchema(),
87
- type: RedoSchema,
88
- scope: OperationScopeSchema()
89
- });
90
- }
91
- const SetNameActionInputSchema = zod$1.z.string;
92
- function SetNameActionSchema() {
93
- return zod$1.z.object({
94
- input: SetNameActionInputSchema(),
95
- type: Set_NameSchema,
96
- scope: zod$1.z.literal("global")
97
- });
98
- }
99
- function SetNameOperationSchema() {
100
- return zod$1.z.object({
101
- __typename: zod$1.z.literal("SetNameOperation").optional(),
102
- hash: zod$1.z.string(),
103
- index: zod$1.z.number(),
104
- input: zod$1.z.string(),
105
- timestamp: zod$1.z.string().datetime(),
106
- type: zod$1.z.string()
107
- });
108
- }
109
- const UndoActionInputSchema = zod$1.z.number;
110
- function UndoActionSchema() {
111
- return zod$1.z.object({
112
- input: UndoActionInputSchema(),
113
- type: UndoSchema,
114
- scope: OperationScopeSchema()
115
- });
116
- }
117
- const zod = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
118
- __proto__: null,
119
- ActionSchema,
120
- BaseActionSchema,
121
- DocumentFileSchema,
122
- LoadStateActionInputSchema,
123
- LoadStateActionSchema,
124
- LoadStateActionStateInputSchema,
125
- Load_StateSchema,
126
- OperationSchema,
127
- OperationScopeSchema,
128
- PruneActionInputSchema,
129
- PruneActionSchema,
130
- PruneSchema,
131
- RedoActionInputSchema,
132
- RedoActionSchema,
133
- RedoSchema,
134
- SetNameActionInputSchema,
135
- SetNameActionSchema,
136
- SetNameOperationSchema,
137
- Set_NameSchema,
138
- UndoActionInputSchema,
139
- UndoActionSchema,
140
- UndoSchema,
141
- definedNonNullAnySchema,
142
- isDefinedNonNullAny
143
- }, Symbol.toStringTag, { value: "Module" }));
144
- function getDefaultExportFromCjs(x) {
145
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
146
- }
147
- var safeStableStringify = { exports: {} };
148
- var hasRequiredSafeStableStringify;
149
- function requireSafeStableStringify() {
150
- if (hasRequiredSafeStableStringify) return safeStableStringify.exports;
151
- hasRequiredSafeStableStringify = 1;
152
- (function(module2, exports2) {
153
- const { hasOwnProperty } = Object.prototype;
154
- const stringify = configure();
155
- stringify.configure = configure;
156
- stringify.stringify = stringify;
157
- stringify.default = stringify;
158
- exports2.stringify = stringify;
159
- exports2.configure = configure;
160
- module2.exports = stringify;
161
- const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
162
- function strEscape(str) {
163
- if (str.length < 5e3 && !strEscapeSequencesRegExp.test(str)) {
164
- return `"${str}"`;
165
- }
166
- return JSON.stringify(str);
167
- }
168
- function sort(array, comparator) {
169
- if (array.length > 200 || comparator) {
170
- return array.sort(comparator);
171
- }
172
- for (let i = 1; i < array.length; i++) {
173
- const currentValue = array[i];
174
- let position = i;
175
- while (position !== 0 && array[position - 1] > currentValue) {
176
- array[position] = array[position - 1];
177
- position--;
178
- }
179
- array[position] = currentValue;
180
- }
181
- return array;
182
- }
183
- const typedArrayPrototypeGetSymbolToStringTag = Object.getOwnPropertyDescriptor(
184
- Object.getPrototypeOf(
185
- Object.getPrototypeOf(
186
- new Int8Array()
187
- )
188
- ),
189
- Symbol.toStringTag
190
- ).get;
191
- function isTypedArrayWithEntries(value) {
192
- return typedArrayPrototypeGetSymbolToStringTag.call(value) !== void 0 && value.length !== 0;
193
- }
194
- function stringifyTypedArray(array, separator, maximumBreadth) {
195
- if (array.length < maximumBreadth) {
196
- maximumBreadth = array.length;
197
- }
198
- const whitespace = separator === "," ? "" : " ";
199
- let res = `"0":${whitespace}${array[0]}`;
200
- for (let i = 1; i < maximumBreadth; i++) {
201
- res += `${separator}"${i}":${whitespace}${array[i]}`;
202
- }
203
- return res;
204
- }
205
- function getCircularValueOption(options) {
206
- if (hasOwnProperty.call(options, "circularValue")) {
207
- const circularValue = options.circularValue;
208
- if (typeof circularValue === "string") {
209
- return `"${circularValue}"`;
210
- }
211
- if (circularValue == null) {
212
- return circularValue;
213
- }
214
- if (circularValue === Error || circularValue === TypeError) {
215
- return {
216
- toString() {
217
- throw new TypeError("Converting circular structure to JSON");
218
- }
219
- };
220
- }
221
- throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
222
- }
223
- return '"[Circular]"';
224
- }
225
- function getDeterministicOption(options) {
226
- let value;
227
- if (hasOwnProperty.call(options, "deterministic")) {
228
- value = options.deterministic;
229
- if (typeof value !== "boolean" && typeof value !== "function") {
230
- throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');
231
- }
232
- }
233
- return value === void 0 ? true : value;
234
- }
235
- function getBooleanOption(options, key) {
236
- let value;
237
- if (hasOwnProperty.call(options, key)) {
238
- value = options[key];
239
- if (typeof value !== "boolean") {
240
- throw new TypeError(`The "${key}" argument must be of type boolean`);
241
- }
242
- }
243
- return value === void 0 ? true : value;
244
- }
245
- function getPositiveIntegerOption(options, key) {
246
- let value;
247
- if (hasOwnProperty.call(options, key)) {
248
- value = options[key];
249
- if (typeof value !== "number") {
250
- throw new TypeError(`The "${key}" argument must be of type number`);
251
- }
252
- if (!Number.isInteger(value)) {
253
- throw new TypeError(`The "${key}" argument must be an integer`);
254
- }
255
- if (value < 1) {
256
- throw new RangeError(`The "${key}" argument must be >= 1`);
257
- }
258
- }
259
- return value === void 0 ? Infinity : value;
260
- }
261
- function getItemCount(number) {
262
- if (number === 1) {
263
- return "1 item";
264
- }
265
- return `${number} items`;
266
- }
267
- function getUniqueReplacerSet(replacerArray) {
268
- const replacerSet = /* @__PURE__ */ new Set();
269
- for (const value of replacerArray) {
270
- if (typeof value === "string" || typeof value === "number") {
271
- replacerSet.add(String(value));
272
- }
273
- }
274
- return replacerSet;
275
- }
276
- function getStrictOption(options) {
277
- if (hasOwnProperty.call(options, "strict")) {
278
- const value = options.strict;
279
- if (typeof value !== "boolean") {
280
- throw new TypeError('The "strict" argument must be of type boolean');
281
- }
282
- if (value) {
283
- return (value2) => {
284
- let message = `Object can not safely be stringified. Received type ${typeof value2}`;
285
- if (typeof value2 !== "function") message += ` (${value2.toString()})`;
286
- throw new Error(message);
287
- };
288
- }
289
- }
290
- }
291
- function configure(options) {
292
- options = { ...options };
293
- const fail = getStrictOption(options);
294
- if (fail) {
295
- if (options.bigint === void 0) {
296
- options.bigint = false;
297
- }
298
- if (!("circularValue" in options)) {
299
- options.circularValue = Error;
300
- }
301
- }
302
- const circularValue = getCircularValueOption(options);
303
- const bigint = getBooleanOption(options, "bigint");
304
- const deterministic = getDeterministicOption(options);
305
- const comparator = typeof deterministic === "function" ? deterministic : void 0;
306
- const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
307
- const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
308
- function stringifyFnReplacer(key, parent, stack, replacer, spacer, indentation) {
309
- let value = parent[key];
310
- if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
311
- value = value.toJSON(key);
312
- }
313
- value = replacer.call(parent, key, value);
314
- switch (typeof value) {
315
- case "string":
316
- return strEscape(value);
317
- case "object": {
318
- if (value === null) {
319
- return "null";
320
- }
321
- if (stack.indexOf(value) !== -1) {
322
- return circularValue;
323
- }
324
- let res = "";
325
- let join = ",";
326
- const originalIndentation = indentation;
327
- if (Array.isArray(value)) {
328
- if (value.length === 0) {
329
- return "[]";
330
- }
331
- if (maximumDepth < stack.length + 1) {
332
- return '"[Array]"';
333
- }
334
- stack.push(value);
335
- if (spacer !== "") {
336
- indentation += spacer;
337
- res += `
338
- ${indentation}`;
339
- join = `,
340
- ${indentation}`;
341
- }
342
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
343
- let i = 0;
344
- for (; i < maximumValuesToStringify - 1; i++) {
345
- const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
346
- res += tmp2 !== void 0 ? tmp2 : "null";
347
- res += join;
348
- }
349
- const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
350
- res += tmp !== void 0 ? tmp : "null";
351
- if (value.length - 1 > maximumBreadth) {
352
- const removedKeys = value.length - maximumBreadth - 1;
353
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
354
- }
355
- if (spacer !== "") {
356
- res += `
357
- ${originalIndentation}`;
358
- }
359
- stack.pop();
360
- return `[${res}]`;
361
- }
362
- let keys = Object.keys(value);
363
- const keyLength = keys.length;
364
- if (keyLength === 0) {
365
- return "{}";
366
- }
367
- if (maximumDepth < stack.length + 1) {
368
- return '"[Object]"';
369
- }
370
- let whitespace = "";
371
- let separator = "";
372
- if (spacer !== "") {
373
- indentation += spacer;
374
- join = `,
375
- ${indentation}`;
376
- whitespace = " ";
377
- }
378
- const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
379
- if (deterministic && !isTypedArrayWithEntries(value)) {
380
- keys = sort(keys, comparator);
381
- }
382
- stack.push(value);
383
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
384
- const key2 = keys[i];
385
- const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
386
- if (tmp !== void 0) {
387
- res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
388
- separator = join;
389
- }
390
- }
391
- if (keyLength > maximumBreadth) {
392
- const removedKeys = keyLength - maximumBreadth;
393
- res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
394
- separator = join;
395
- }
396
- if (spacer !== "" && separator.length > 1) {
397
- res = `
398
- ${indentation}${res}
399
- ${originalIndentation}`;
400
- }
401
- stack.pop();
402
- return `{${res}}`;
403
- }
404
- case "number":
405
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
406
- case "boolean":
407
- return value === true ? "true" : "false";
408
- case "undefined":
409
- return void 0;
410
- case "bigint":
411
- if (bigint) {
412
- return String(value);
413
- }
414
- // fallthrough
415
- default:
416
- return fail ? fail(value) : void 0;
417
- }
418
- }
419
- function stringifyArrayReplacer(key, value, stack, replacer, spacer, indentation) {
420
- if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
421
- value = value.toJSON(key);
422
- }
423
- switch (typeof value) {
424
- case "string":
425
- return strEscape(value);
426
- case "object": {
427
- if (value === null) {
428
- return "null";
429
- }
430
- if (stack.indexOf(value) !== -1) {
431
- return circularValue;
432
- }
433
- const originalIndentation = indentation;
434
- let res = "";
435
- let join = ",";
436
- if (Array.isArray(value)) {
437
- if (value.length === 0) {
438
- return "[]";
439
- }
440
- if (maximumDepth < stack.length + 1) {
441
- return '"[Array]"';
442
- }
443
- stack.push(value);
444
- if (spacer !== "") {
445
- indentation += spacer;
446
- res += `
447
- ${indentation}`;
448
- join = `,
449
- ${indentation}`;
450
- }
451
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
452
- let i = 0;
453
- for (; i < maximumValuesToStringify - 1; i++) {
454
- const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
455
- res += tmp2 !== void 0 ? tmp2 : "null";
456
- res += join;
457
- }
458
- const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
459
- res += tmp !== void 0 ? tmp : "null";
460
- if (value.length - 1 > maximumBreadth) {
461
- const removedKeys = value.length - maximumBreadth - 1;
462
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
463
- }
464
- if (spacer !== "") {
465
- res += `
466
- ${originalIndentation}`;
467
- }
468
- stack.pop();
469
- return `[${res}]`;
470
- }
471
- stack.push(value);
472
- let whitespace = "";
473
- if (spacer !== "") {
474
- indentation += spacer;
475
- join = `,
476
- ${indentation}`;
477
- whitespace = " ";
478
- }
479
- let separator = "";
480
- for (const key2 of replacer) {
481
- const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
482
- if (tmp !== void 0) {
483
- res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
484
- separator = join;
485
- }
486
- }
487
- if (spacer !== "" && separator.length > 1) {
488
- res = `
489
- ${indentation}${res}
490
- ${originalIndentation}`;
491
- }
492
- stack.pop();
493
- return `{${res}}`;
494
- }
495
- case "number":
496
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
497
- case "boolean":
498
- return value === true ? "true" : "false";
499
- case "undefined":
500
- return void 0;
501
- case "bigint":
502
- if (bigint) {
503
- return String(value);
504
- }
505
- // fallthrough
506
- default:
507
- return fail ? fail(value) : void 0;
508
- }
509
- }
510
- function stringifyIndent(key, value, stack, spacer, indentation) {
511
- switch (typeof value) {
512
- case "string":
513
- return strEscape(value);
514
- case "object": {
515
- if (value === null) {
516
- return "null";
517
- }
518
- if (typeof value.toJSON === "function") {
519
- value = value.toJSON(key);
520
- if (typeof value !== "object") {
521
- return stringifyIndent(key, value, stack, spacer, indentation);
522
- }
523
- if (value === null) {
524
- return "null";
525
- }
526
- }
527
- if (stack.indexOf(value) !== -1) {
528
- return circularValue;
529
- }
530
- const originalIndentation = indentation;
531
- if (Array.isArray(value)) {
532
- if (value.length === 0) {
533
- return "[]";
534
- }
535
- if (maximumDepth < stack.length + 1) {
536
- return '"[Array]"';
537
- }
538
- stack.push(value);
539
- indentation += spacer;
540
- let res2 = `
541
- ${indentation}`;
542
- const join2 = `,
543
- ${indentation}`;
544
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
545
- let i = 0;
546
- for (; i < maximumValuesToStringify - 1; i++) {
547
- const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
548
- res2 += tmp2 !== void 0 ? tmp2 : "null";
549
- res2 += join2;
550
- }
551
- const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
552
- res2 += tmp !== void 0 ? tmp : "null";
553
- if (value.length - 1 > maximumBreadth) {
554
- const removedKeys = value.length - maximumBreadth - 1;
555
- res2 += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
556
- }
557
- res2 += `
558
- ${originalIndentation}`;
559
- stack.pop();
560
- return `[${res2}]`;
561
- }
562
- let keys = Object.keys(value);
563
- const keyLength = keys.length;
564
- if (keyLength === 0) {
565
- return "{}";
566
- }
567
- if (maximumDepth < stack.length + 1) {
568
- return '"[Object]"';
569
- }
570
- indentation += spacer;
571
- const join = `,
572
- ${indentation}`;
573
- let res = "";
574
- let separator = "";
575
- let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
576
- if (isTypedArrayWithEntries(value)) {
577
- res += stringifyTypedArray(value, join, maximumBreadth);
578
- keys = keys.slice(value.length);
579
- maximumPropertiesToStringify -= value.length;
580
- separator = join;
581
- }
582
- if (deterministic) {
583
- keys = sort(keys, comparator);
584
- }
585
- stack.push(value);
586
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
587
- const key2 = keys[i];
588
- const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
589
- if (tmp !== void 0) {
590
- res += `${separator}${strEscape(key2)}: ${tmp}`;
591
- separator = join;
592
- }
593
- }
594
- if (keyLength > maximumBreadth) {
595
- const removedKeys = keyLength - maximumBreadth;
596
- res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
597
- separator = join;
598
- }
599
- if (separator !== "") {
600
- res = `
601
- ${indentation}${res}
602
- ${originalIndentation}`;
603
- }
604
- stack.pop();
605
- return `{${res}}`;
606
- }
607
- case "number":
608
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
609
- case "boolean":
610
- return value === true ? "true" : "false";
611
- case "undefined":
612
- return void 0;
613
- case "bigint":
614
- if (bigint) {
615
- return String(value);
616
- }
617
- // fallthrough
618
- default:
619
- return fail ? fail(value) : void 0;
620
- }
621
- }
622
- function stringifySimple(key, value, stack) {
623
- switch (typeof value) {
624
- case "string":
625
- return strEscape(value);
626
- case "object": {
627
- if (value === null) {
628
- return "null";
629
- }
630
- if (typeof value.toJSON === "function") {
631
- value = value.toJSON(key);
632
- if (typeof value !== "object") {
633
- return stringifySimple(key, value, stack);
634
- }
635
- if (value === null) {
636
- return "null";
637
- }
638
- }
639
- if (stack.indexOf(value) !== -1) {
640
- return circularValue;
641
- }
642
- let res = "";
643
- const hasLength = value.length !== void 0;
644
- if (hasLength && Array.isArray(value)) {
645
- if (value.length === 0) {
646
- return "[]";
647
- }
648
- if (maximumDepth < stack.length + 1) {
649
- return '"[Array]"';
650
- }
651
- stack.push(value);
652
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
653
- let i = 0;
654
- for (; i < maximumValuesToStringify - 1; i++) {
655
- const tmp2 = stringifySimple(String(i), value[i], stack);
656
- res += tmp2 !== void 0 ? tmp2 : "null";
657
- res += ",";
658
- }
659
- const tmp = stringifySimple(String(i), value[i], stack);
660
- res += tmp !== void 0 ? tmp : "null";
661
- if (value.length - 1 > maximumBreadth) {
662
- const removedKeys = value.length - maximumBreadth - 1;
663
- res += `,"... ${getItemCount(removedKeys)} not stringified"`;
664
- }
665
- stack.pop();
666
- return `[${res}]`;
667
- }
668
- let keys = Object.keys(value);
669
- const keyLength = keys.length;
670
- if (keyLength === 0) {
671
- return "{}";
672
- }
673
- if (maximumDepth < stack.length + 1) {
674
- return '"[Object]"';
675
- }
676
- let separator = "";
677
- let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
678
- if (hasLength && isTypedArrayWithEntries(value)) {
679
- res += stringifyTypedArray(value, ",", maximumBreadth);
680
- keys = keys.slice(value.length);
681
- maximumPropertiesToStringify -= value.length;
682
- separator = ",";
683
- }
684
- if (deterministic) {
685
- keys = sort(keys, comparator);
686
- }
687
- stack.push(value);
688
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
689
- const key2 = keys[i];
690
- const tmp = stringifySimple(key2, value[key2], stack);
691
- if (tmp !== void 0) {
692
- res += `${separator}${strEscape(key2)}:${tmp}`;
693
- separator = ",";
694
- }
695
- }
696
- if (keyLength > maximumBreadth) {
697
- const removedKeys = keyLength - maximumBreadth;
698
- res += `${separator}"...":"${getItemCount(removedKeys)} not stringified"`;
699
- }
700
- stack.pop();
701
- return `{${res}}`;
702
- }
703
- case "number":
704
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
705
- case "boolean":
706
- return value === true ? "true" : "false";
707
- case "undefined":
708
- return void 0;
709
- case "bigint":
710
- if (bigint) {
711
- return String(value);
712
- }
713
- // fallthrough
714
- default:
715
- return fail ? fail(value) : void 0;
716
- }
717
- }
718
- function stringify2(value, replacer, space) {
719
- if (arguments.length > 1) {
720
- let spacer = "";
721
- if (typeof space === "number") {
722
- spacer = " ".repeat(Math.min(space, 10));
723
- } else if (typeof space === "string") {
724
- spacer = space.slice(0, 10);
725
- }
726
- if (replacer != null) {
727
- if (typeof replacer === "function") {
728
- return stringifyFnReplacer("", { "": value }, [], replacer, spacer, "");
729
- }
730
- if (Array.isArray(replacer)) {
731
- return stringifyArrayReplacer("", value, [], getUniqueReplacerSet(replacer), spacer, "");
732
- }
733
- }
734
- if (spacer.length !== 0) {
735
- return stringifyIndent("", value, [], spacer, "");
736
- }
737
- }
738
- return stringifySimple("", value, []);
739
- }
740
- return stringify2;
741
- }
742
- })(safeStableStringify, safeStableStringify.exports);
743
- return safeStableStringify.exports;
744
- }
745
- var safeStableStringifyExports = requireSafeStableStringify();
746
- const cjsModule = /* @__PURE__ */ getDefaultExportFromCjs(safeStableStringifyExports);
747
- cjsModule.configure;
748
- const K = [
749
- 1518500249 | 0,
750
- 1859775393 | 0,
751
- 2400959708 | 0,
752
- 3395469782 | 0
753
- ];
754
- function createHash(algorithm) {
755
- return new Hash();
756
- }
757
- class Hash {
758
- constructor() {
759
- this.A = 1732584193 | 0;
760
- this.B = 4023233417 | 0;
761
- this.C = 2562383102 | 0;
762
- this.D = 271733878 | 0;
763
- this.E = 3285377520 | 0;
764
- this._size = 0;
765
- this._sp = 0;
766
- if (!sharedBuffer || sharedOffset >= 8e3) {
767
- sharedBuffer = new ArrayBuffer(
768
- 8e3
769
- /* N.allocTotal */
770
- );
771
- sharedOffset = 0;
772
- }
773
- this._byte = new Uint8Array(
774
- sharedBuffer,
775
- sharedOffset,
776
- 80
777
- /* N.allocBytes */
778
- );
779
- this._word = new Int32Array(
780
- sharedBuffer,
781
- sharedOffset,
782
- 20
783
- /* N.allocWords */
784
- );
785
- sharedOffset += 80;
786
- }
787
- update(data) {
788
- if ("string" === typeof data) {
789
- return this._utf8(data);
790
- }
791
- if (data == null) {
792
- throw new TypeError("Invalid type: " + typeof data);
793
- }
794
- const byteOffset = data.byteOffset;
795
- const length = data.byteLength;
796
- let blocks = length / 64 | 0;
797
- let offset = 0;
798
- if (blocks && !(byteOffset & 3) && !(this._size % 64)) {
799
- const block = new Int32Array(
800
- data.buffer,
801
- byteOffset,
802
- blocks * 16
803
- /* N.inputWords */
804
- );
805
- while (blocks--) {
806
- this._int32(block, offset >> 2);
807
- offset += 64;
808
- }
809
- this._size += offset;
810
- }
811
- const BYTES_PER_ELEMENT = data.BYTES_PER_ELEMENT;
812
- if (BYTES_PER_ELEMENT !== 1 && data.buffer) {
813
- const rest = new Uint8Array(data.buffer, byteOffset + offset, length - offset);
814
- return this._uint8(rest);
815
- }
816
- if (offset === length)
817
- return this;
818
- return this._uint8(data, offset);
819
- }
820
- _uint8(data, offset) {
821
- const { _byte, _word } = this;
822
- const length = data.length;
823
- offset = offset | 0;
824
- while (offset < length) {
825
- const start = this._size % 64;
826
- let index = start;
827
- while (offset < length && index < 64) {
828
- _byte[index++] = data[offset++];
829
- }
830
- if (index >= 64) {
831
- this._int32(_word);
832
- }
833
- this._size += index - start;
834
- }
835
- return this;
836
- }
837
- _utf8(text) {
838
- const { _byte, _word } = this;
839
- const length = text.length;
840
- let surrogate = this._sp;
841
- for (let offset = 0; offset < length; ) {
842
- const start = this._size % 64;
843
- let index = start;
844
- while (offset < length && index < 64) {
845
- let code = text.charCodeAt(offset++) | 0;
846
- if (code < 128) {
847
- _byte[index++] = code;
848
- } else if (code < 2048) {
849
- _byte[index++] = 192 | code >>> 6;
850
- _byte[index++] = 128 | code & 63;
851
- } else if (code < 55296 || code > 57343) {
852
- _byte[index++] = 224 | code >>> 12;
853
- _byte[index++] = 128 | code >>> 6 & 63;
854
- _byte[index++] = 128 | code & 63;
855
- } else if (surrogate) {
856
- code = ((surrogate & 1023) << 10) + (code & 1023) + 65536;
857
- _byte[index++] = 240 | code >>> 18;
858
- _byte[index++] = 128 | code >>> 12 & 63;
859
- _byte[index++] = 128 | code >>> 6 & 63;
860
- _byte[index++] = 128 | code & 63;
861
- surrogate = 0;
862
- } else {
863
- surrogate = code;
864
- }
865
- }
866
- if (index >= 64) {
867
- this._int32(_word);
868
- _word[0] = _word[
869
- 16
870
- /* N.inputWords */
871
- ];
872
- }
873
- this._size += index - start;
874
- }
875
- this._sp = surrogate;
876
- return this;
877
- }
878
- _int32(data, offset) {
879
- let { A, B, C, D, E } = this;
880
- let i = 0;
881
- offset = offset | 0;
882
- while (i < 16) {
883
- W[i++] = swap32(data[offset++]);
884
- }
885
- for (i = 16; i < 80; i++) {
886
- W[i] = rotate1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]);
887
- }
888
- for (i = 0; i < 80; i++) {
889
- const S = i / 20 | 0;
890
- const T = rotate5(A) + ft(S, B, C, D) + E + W[i] + K[S] | 0;
891
- E = D;
892
- D = C;
893
- C = rotate30(B);
894
- B = A;
895
- A = T;
896
- }
897
- this.A = A + this.A | 0;
898
- this.B = B + this.B | 0;
899
- this.C = C + this.C | 0;
900
- this.D = D + this.D | 0;
901
- this.E = E + this.E | 0;
902
- }
903
- digest(encoding) {
904
- const { _byte, _word } = this;
905
- let i = this._size % 64 | 0;
906
- _byte[i++] = 128;
907
- while (i & 3) {
908
- _byte[i++] = 0;
909
- }
910
- i >>= 2;
911
- if (i > 14) {
912
- while (i < 16) {
913
- _word[i++] = 0;
914
- }
915
- i = 0;
916
- this._int32(_word);
917
- }
918
- while (i < 16) {
919
- _word[i++] = 0;
920
- }
921
- const bits64 = this._size * 8;
922
- const low32 = (bits64 & 4294967295) >>> 0;
923
- const high32 = (bits64 - low32) / 4294967296;
924
- if (high32)
925
- _word[
926
- 14
927
- /* N.highIndex */
928
- ] = swap32(high32);
929
- if (low32)
930
- _word[
931
- 15
932
- /* N.lowIndex */
933
- ] = swap32(low32);
934
- this._int32(_word);
935
- return encoding === "hex" ? this._hex() : this._bin();
936
- }
937
- _hex() {
938
- const { A, B, C, D, E } = this;
939
- return hex32(A) + hex32(B) + hex32(C) + hex32(D) + hex32(E);
940
- }
941
- _bin() {
942
- const { A, B, C, D, E, _byte, _word } = this;
943
- _word[0] = swap32(A);
944
- _word[1] = swap32(B);
945
- _word[2] = swap32(C);
946
- _word[3] = swap32(D);
947
- _word[4] = swap32(E);
948
- return _byte.slice(0, 20);
949
- }
950
- }
951
- const W = new Int32Array(
952
- 80
953
- /* N.workWords */
954
- );
955
- let sharedBuffer;
956
- let sharedOffset = 0;
957
- const hex32 = (num) => (num + 4294967296).toString(16).substr(-8);
958
- const swapLE = (c) => c << 24 & 4278190080 | c << 8 & 16711680 | c >> 8 & 65280 | c >> 24 & 255;
959
- const swapBE = (c) => c;
960
- const swap32 = isBE() ? swapBE : swapLE;
961
- const rotate1 = (num) => num << 1 | num >>> 31;
962
- const rotate5 = (num) => num << 5 | num >>> 27;
963
- const rotate30 = (num) => num << 30 | num >>> 2;
964
- function ft(s, b, c, d) {
965
- if (s === 0)
966
- return b & c | ~b & d;
967
- if (s === 2)
968
- return b & c | b & d | c & d;
969
- return b ^ c ^ d;
970
- }
971
- function isBE() {
972
- const buf = new Uint8Array(new Uint16Array([65279]).buffer);
973
- return buf[0] === 254;
974
- }
975
- const FileSystemError = new Error("File system not available.");
976
- function generateUUID() {
977
- if (!crypto.randomUUID) {
978
- throw new Error("generateUUID is not available in unsecure contexts.");
979
- }
980
- return crypto.randomUUID();
981
- }
982
- function writeFile(path, name, stream) {
983
- throw FileSystemError;
984
- }
985
- function readFile(path) {
986
- throw FileSystemError;
987
- }
988
- function fetchFile(url) {
989
- throw FileSystemError;
990
- }
991
- const getFile = async (file) => {
992
- return readFile();
993
- };
994
- const hash = (data, algorithm = "sha1") => {
995
- if (!["sha1"].includes(algorithm)) {
996
- throw new Error("Hashing algorithm not supported: Available: sha1");
997
- }
998
- const hash2 = hashUIntArray(data);
999
- return uint8ArrayToBase64(hash2);
1000
- };
1001
- function uint8ArrayToBase64(uint8Array) {
1002
- let binaryString = "";
1003
- for (let i = 0; i < uint8Array.length; i++) {
1004
- binaryString += String.fromCharCode(uint8Array[i]);
1005
- }
1006
- const base64String = btoa(binaryString);
1007
- return base64String;
1008
- }
1009
- function hashUIntArray(data, algorithm = "sha1") {
1010
- if (!["sha1"].includes(algorithm)) {
1011
- throw new Error("Hashing algorithm not supported: Available: sha1");
1012
- }
1013
- return createHash().update(data).digest();
1014
- }
1015
- function generateId(method) {
1016
- if (method && method.toString() !== "UUIDv4") {
1017
- throw new Error(
1018
- `Id generation method not supported: "${method.toString()}"`
1019
- );
1020
- }
1021
- return generateUUID();
1022
- }
1023
- function getUnixTimestamp(date) {
1024
- return (new Date(date).getTime() / 1e3).toFixed(0);
1025
- }
1026
- function buildOperationSignatureParams({
1027
- documentId,
1028
- signer,
1029
- operation,
1030
- previousStateHash
1031
- }) {
1032
- const { timestamp, scope, id, type } = operation;
1033
- return [
1034
- getUnixTimestamp(timestamp),
1035
- // timestamp,
1036
- signer.app.key,
1037
- // signer public key
1038
- hash(
1039
- // hash (docID, scope, operationID, operationName, operationInput)
1040
- [documentId, scope, id, type, cjsModule(operation.input)].join("")
1041
- ),
1042
- previousStateHash
1043
- // state hash that the operation was applied to
1044
- ];
1045
- }
1046
- const textEncode = new TextEncoder();
1047
- function buildOperationSignatureMessage(params) {
1048
- const message = params.join("");
1049
- const prefix = "Signed Operation:\n" + message.length.toString();
1050
- return textEncode.encode(prefix + message);
1051
- }
1052
- function ab2hex(ab) {
1053
- const view = ArrayBuffer.isView(ab) ? ab : new Uint8Array(ab);
1054
- return Array.prototype.map.call(view, (x) => ("00" + x.toString(16)).slice(-2)).join("");
1055
- }
1056
- function hex2ab(hex) {
1057
- var _a;
1058
- return new Uint8Array(
1059
- ((_a = hex.match(/[\da-f]{2}/gi)) == null ? void 0 : _a.map(function(h) {
1060
- return parseInt(h, 16);
1061
- })) ?? []
1062
- );
1063
- }
1064
- async function buildOperationSignature(context, signMethod) {
1065
- const params = buildOperationSignatureParams(context);
1066
- const message = buildOperationSignatureMessage(params);
1067
- const signature = await signMethod(message);
1068
- return [...params, `0x${ab2hex(signature)}`];
1069
- }
1070
- async function buildSignedOperation(action, reducer, document, context, signHandler) {
1071
- var _a, _b;
1072
- const result = reducer(document, action, void 0, {
1073
- reuseHash: true,
1074
- reuseOperationResultingState: true
1075
- });
1076
- const operation = result.operations[action.scope].at(-1);
1077
- if (!operation) {
1078
- throw new Error("Action was not applied");
1079
- }
1080
- const previousStateHash = ((_a = result.operations[action.scope].at(-2)) == null ? void 0 : _a.hash) ?? "";
1081
- const signature = await buildOperationSignature(
1082
- {
1083
- ...context,
1084
- operation,
1085
- previousStateHash
1086
- },
1087
- signHandler
1088
- );
1089
- return {
1090
- ...operation,
1091
- context: {
1092
- ...operation.context,
1093
- signer: {
1094
- ...(_b = operation.context) == null ? void 0 : _b.signer,
1095
- ...context.signer,
1096
- signatures: [...context.signer.signatures ?? [], signature]
1097
- }
1098
- }
1099
- };
1100
- }
1101
- async function verifyOperationSignature(signature, signer, verifyHandler) {
1102
- const publicKey = signer.app.key;
1103
- const params = signature.slice(0, 4);
1104
- const signatureBytes = hex2ab(signature[4]);
1105
- const expectedMessage = buildOperationSignatureMessage(params);
1106
- return verifyHandler(publicKey, signatureBytes, expectedMessage);
1107
- }
1108
- class InvalidActionInputError extends Error {
1109
- constructor(data) {
1110
- super();
1111
- __publicField(this, "data");
1112
- this.name = "InvalidActionInputError";
1113
- this.data = data;
1114
- this.message = this.message || `Invalid action input: ${JSON.stringify(data, null, 2)}`;
1115
- }
1116
- }
1117
- class InvalidActionInputZodError extends InvalidActionInputError {
1118
- constructor(issues) {
1119
- super(issues);
1120
- __publicField(this, "issues");
1121
- this.issues = issues;
1122
- this.name = "InvalidActionInputZodError";
1123
- }
1124
- }
1125
- const types = {
1126
- "application/andrew-inset": ["ez"],
1127
- "application/appinstaller": ["appinstaller"],
1128
- "application/applixware": ["aw"],
1129
- "application/appx": ["appx"],
1130
- "application/appxbundle": ["appxbundle"],
1131
- "application/atom+xml": ["atom"],
1132
- "application/atomcat+xml": ["atomcat"],
1133
- "application/atomdeleted+xml": ["atomdeleted"],
1134
- "application/atomsvc+xml": ["atomsvc"],
1135
- "application/atsc-dwd+xml": ["dwd"],
1136
- "application/atsc-held+xml": ["held"],
1137
- "application/atsc-rsat+xml": ["rsat"],
1138
- "application/automationml-aml+xml": ["aml"],
1139
- "application/automationml-amlx+zip": ["amlx"],
1140
- "application/bdoc": ["bdoc"],
1141
- "application/calendar+xml": ["xcs"],
1142
- "application/ccxml+xml": ["ccxml"],
1143
- "application/cdfx+xml": ["cdfx"],
1144
- "application/cdmi-capability": ["cdmia"],
1145
- "application/cdmi-container": ["cdmic"],
1146
- "application/cdmi-domain": ["cdmid"],
1147
- "application/cdmi-object": ["cdmio"],
1148
- "application/cdmi-queue": ["cdmiq"],
1149
- "application/cpl+xml": ["cpl"],
1150
- "application/cu-seeme": ["cu"],
1151
- "application/cwl": ["cwl"],
1152
- "application/dash+xml": ["mpd"],
1153
- "application/dash-patch+xml": ["mpp"],
1154
- "application/davmount+xml": ["davmount"],
1155
- "application/docbook+xml": ["dbk"],
1156
- "application/dssc+der": ["dssc"],
1157
- "application/dssc+xml": ["xdssc"],
1158
- "application/ecmascript": ["ecma"],
1159
- "application/emma+xml": ["emma"],
1160
- "application/emotionml+xml": ["emotionml"],
1161
- "application/epub+zip": ["epub"],
1162
- "application/exi": ["exi"],
1163
- "application/express": ["exp"],
1164
- "application/fdf": ["fdf"],
1165
- "application/fdt+xml": ["fdt"],
1166
- "application/font-tdpfr": ["pfr"],
1167
- "application/geo+json": ["geojson"],
1168
- "application/gml+xml": ["gml"],
1169
- "application/gpx+xml": ["gpx"],
1170
- "application/gxf": ["gxf"],
1171
- "application/gzip": ["gz"],
1172
- "application/hjson": ["hjson"],
1173
- "application/hyperstudio": ["stk"],
1174
- "application/inkml+xml": ["ink", "inkml"],
1175
- "application/ipfix": ["ipfix"],
1176
- "application/its+xml": ["its"],
1177
- "application/java-archive": ["jar", "war", "ear"],
1178
- "application/java-serialized-object": ["ser"],
1179
- "application/java-vm": ["class"],
1180
- "application/javascript": ["*js"],
1181
- "application/json": ["json", "map"],
1182
- "application/json5": ["json5"],
1183
- "application/jsonml+json": ["jsonml"],
1184
- "application/ld+json": ["jsonld"],
1185
- "application/lgr+xml": ["lgr"],
1186
- "application/lost+xml": ["lostxml"],
1187
- "application/mac-binhex40": ["hqx"],
1188
- "application/mac-compactpro": ["cpt"],
1189
- "application/mads+xml": ["mads"],
1190
- "application/manifest+json": ["webmanifest"],
1191
- "application/marc": ["mrc"],
1192
- "application/marcxml+xml": ["mrcx"],
1193
- "application/mathematica": ["ma", "nb", "mb"],
1194
- "application/mathml+xml": ["mathml"],
1195
- "application/mbox": ["mbox"],
1196
- "application/media-policy-dataset+xml": ["mpf"],
1197
- "application/mediaservercontrol+xml": ["mscml"],
1198
- "application/metalink+xml": ["metalink"],
1199
- "application/metalink4+xml": ["meta4"],
1200
- "application/mets+xml": ["mets"],
1201
- "application/mmt-aei+xml": ["maei"],
1202
- "application/mmt-usd+xml": ["musd"],
1203
- "application/mods+xml": ["mods"],
1204
- "application/mp21": ["m21", "mp21"],
1205
- "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"],
1206
- "application/msix": ["msix"],
1207
- "application/msixbundle": ["msixbundle"],
1208
- "application/msword": ["doc", "dot"],
1209
- "application/mxf": ["mxf"],
1210
- "application/n-quads": ["nq"],
1211
- "application/n-triples": ["nt"],
1212
- "application/node": ["cjs"],
1213
- "application/octet-stream": [
1214
- "bin",
1215
- "dms",
1216
- "lrf",
1217
- "mar",
1218
- "so",
1219
- "dist",
1220
- "distz",
1221
- "pkg",
1222
- "bpk",
1223
- "dump",
1224
- "elc",
1225
- "deploy",
1226
- "exe",
1227
- "dll",
1228
- "deb",
1229
- "dmg",
1230
- "iso",
1231
- "img",
1232
- "msi",
1233
- "msp",
1234
- "msm",
1235
- "buffer"
1236
- ],
1237
- "application/oda": ["oda"],
1238
- "application/oebps-package+xml": ["opf"],
1239
- "application/ogg": ["ogx"],
1240
- "application/omdoc+xml": ["omdoc"],
1241
- "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"],
1242
- "application/oxps": ["oxps"],
1243
- "application/p2p-overlay+xml": ["relo"],
1244
- "application/patch-ops-error+xml": ["xer"],
1245
- "application/pdf": ["pdf"],
1246
- "application/pgp-encrypted": ["pgp"],
1247
- "application/pgp-keys": ["asc"],
1248
- "application/pgp-signature": ["sig", "*asc"],
1249
- "application/pics-rules": ["prf"],
1250
- "application/pkcs10": ["p10"],
1251
- "application/pkcs7-mime": ["p7m", "p7c"],
1252
- "application/pkcs7-signature": ["p7s"],
1253
- "application/pkcs8": ["p8"],
1254
- "application/pkix-attr-cert": ["ac"],
1255
- "application/pkix-cert": ["cer"],
1256
- "application/pkix-crl": ["crl"],
1257
- "application/pkix-pkipath": ["pkipath"],
1258
- "application/pkixcmp": ["pki"],
1259
- "application/pls+xml": ["pls"],
1260
- "application/postscript": ["ai", "eps", "ps"],
1261
- "application/provenance+xml": ["provx"],
1262
- "application/pskc+xml": ["pskcxml"],
1263
- "application/raml+yaml": ["raml"],
1264
- "application/rdf+xml": ["rdf", "owl"],
1265
- "application/reginfo+xml": ["rif"],
1266
- "application/relax-ng-compact-syntax": ["rnc"],
1267
- "application/resource-lists+xml": ["rl"],
1268
- "application/resource-lists-diff+xml": ["rld"],
1269
- "application/rls-services+xml": ["rs"],
1270
- "application/route-apd+xml": ["rapd"],
1271
- "application/route-s-tsid+xml": ["sls"],
1272
- "application/route-usd+xml": ["rusd"],
1273
- "application/rpki-ghostbusters": ["gbr"],
1274
- "application/rpki-manifest": ["mft"],
1275
- "application/rpki-roa": ["roa"],
1276
- "application/rsd+xml": ["rsd"],
1277
- "application/rss+xml": ["rss"],
1278
- "application/rtf": ["rtf"],
1279
- "application/sbml+xml": ["sbml"],
1280
- "application/scvp-cv-request": ["scq"],
1281
- "application/scvp-cv-response": ["scs"],
1282
- "application/scvp-vp-request": ["spq"],
1283
- "application/scvp-vp-response": ["spp"],
1284
- "application/sdp": ["sdp"],
1285
- "application/senml+xml": ["senmlx"],
1286
- "application/sensml+xml": ["sensmlx"],
1287
- "application/set-payment-initiation": ["setpay"],
1288
- "application/set-registration-initiation": ["setreg"],
1289
- "application/shf+xml": ["shf"],
1290
- "application/sieve": ["siv", "sieve"],
1291
- "application/smil+xml": ["smi", "smil"],
1292
- "application/sparql-query": ["rq"],
1293
- "application/sparql-results+xml": ["srx"],
1294
- "application/sql": ["sql"],
1295
- "application/srgs": ["gram"],
1296
- "application/srgs+xml": ["grxml"],
1297
- "application/sru+xml": ["sru"],
1298
- "application/ssdl+xml": ["ssdl"],
1299
- "application/ssml+xml": ["ssml"],
1300
- "application/swid+xml": ["swidtag"],
1301
- "application/tei+xml": ["tei", "teicorpus"],
1302
- "application/thraud+xml": ["tfi"],
1303
- "application/timestamped-data": ["tsd"],
1304
- "application/toml": ["toml"],
1305
- "application/trig": ["trig"],
1306
- "application/ttml+xml": ["ttml"],
1307
- "application/ubjson": ["ubj"],
1308
- "application/urc-ressheet+xml": ["rsheet"],
1309
- "application/urc-targetdesc+xml": ["td"],
1310
- "application/voicexml+xml": ["vxml"],
1311
- "application/wasm": ["wasm"],
1312
- "application/watcherinfo+xml": ["wif"],
1313
- "application/widget": ["wgt"],
1314
- "application/winhlp": ["hlp"],
1315
- "application/wsdl+xml": ["wsdl"],
1316
- "application/wspolicy+xml": ["wspolicy"],
1317
- "application/xaml+xml": ["xaml"],
1318
- "application/xcap-att+xml": ["xav"],
1319
- "application/xcap-caps+xml": ["xca"],
1320
- "application/xcap-diff+xml": ["xdf"],
1321
- "application/xcap-el+xml": ["xel"],
1322
- "application/xcap-ns+xml": ["xns"],
1323
- "application/xenc+xml": ["xenc"],
1324
- "application/xfdf": ["xfdf"],
1325
- "application/xhtml+xml": ["xhtml", "xht"],
1326
- "application/xliff+xml": ["xlf"],
1327
- "application/xml": ["xml", "xsl", "xsd", "rng"],
1328
- "application/xml-dtd": ["dtd"],
1329
- "application/xop+xml": ["xop"],
1330
- "application/xproc+xml": ["xpl"],
1331
- "application/xslt+xml": ["*xsl", "xslt"],
1332
- "application/xspf+xml": ["xspf"],
1333
- "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"],
1334
- "application/yang": ["yang"],
1335
- "application/yin+xml": ["yin"],
1336
- "application/zip": ["zip"],
1337
- "audio/3gpp": ["*3gpp"],
1338
- "audio/aac": ["adts", "aac"],
1339
- "audio/adpcm": ["adp"],
1340
- "audio/amr": ["amr"],
1341
- "audio/basic": ["au", "snd"],
1342
- "audio/midi": ["mid", "midi", "kar", "rmi"],
1343
- "audio/mobile-xmf": ["mxmf"],
1344
- "audio/mp3": ["*mp3"],
1345
- "audio/mp4": ["m4a", "mp4a"],
1346
- "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
1347
- "audio/ogg": ["oga", "ogg", "spx", "opus"],
1348
- "audio/s3m": ["s3m"],
1349
- "audio/silk": ["sil"],
1350
- "audio/wav": ["wav"],
1351
- "audio/wave": ["*wav"],
1352
- "audio/webm": ["weba"],
1353
- "audio/xm": ["xm"],
1354
- "font/collection": ["ttc"],
1355
- "font/otf": ["otf"],
1356
- "font/ttf": ["ttf"],
1357
- "font/woff": ["woff"],
1358
- "font/woff2": ["woff2"],
1359
- "image/aces": ["exr"],
1360
- "image/apng": ["apng"],
1361
- "image/avci": ["avci"],
1362
- "image/avcs": ["avcs"],
1363
- "image/avif": ["avif"],
1364
- "image/bmp": ["bmp", "dib"],
1365
- "image/cgm": ["cgm"],
1366
- "image/dicom-rle": ["drle"],
1367
- "image/dpx": ["dpx"],
1368
- "image/emf": ["emf"],
1369
- "image/fits": ["fits"],
1370
- "image/g3fax": ["g3"],
1371
- "image/gif": ["gif"],
1372
- "image/heic": ["heic"],
1373
- "image/heic-sequence": ["heics"],
1374
- "image/heif": ["heif"],
1375
- "image/heif-sequence": ["heifs"],
1376
- "image/hej2k": ["hej2"],
1377
- "image/hsj2": ["hsj2"],
1378
- "image/ief": ["ief"],
1379
- "image/jls": ["jls"],
1380
- "image/jp2": ["jp2", "jpg2"],
1381
- "image/jpeg": ["jpeg", "jpg", "jpe"],
1382
- "image/jph": ["jph"],
1383
- "image/jphc": ["jhc"],
1384
- "image/jpm": ["jpm", "jpgm"],
1385
- "image/jpx": ["jpx", "jpf"],
1386
- "image/jxl": ["jxl"],
1387
- "image/jxr": ["jxr"],
1388
- "image/jxra": ["jxra"],
1389
- "image/jxrs": ["jxrs"],
1390
- "image/jxs": ["jxs"],
1391
- "image/jxsc": ["jxsc"],
1392
- "image/jxsi": ["jxsi"],
1393
- "image/jxss": ["jxss"],
1394
- "image/ktx": ["ktx"],
1395
- "image/ktx2": ["ktx2"],
1396
- "image/png": ["png"],
1397
- "image/sgi": ["sgi"],
1398
- "image/svg+xml": ["svg", "svgz"],
1399
- "image/t38": ["t38"],
1400
- "image/tiff": ["tif", "tiff"],
1401
- "image/tiff-fx": ["tfx"],
1402
- "image/webp": ["webp"],
1403
- "image/wmf": ["wmf"],
1404
- "message/disposition-notification": ["disposition-notification"],
1405
- "message/global": ["u8msg"],
1406
- "message/global-delivery-status": ["u8dsn"],
1407
- "message/global-disposition-notification": ["u8mdn"],
1408
- "message/global-headers": ["u8hdr"],
1409
- "message/rfc822": ["eml", "mime"],
1410
- "model/3mf": ["3mf"],
1411
- "model/gltf+json": ["gltf"],
1412
- "model/gltf-binary": ["glb"],
1413
- "model/iges": ["igs", "iges"],
1414
- "model/jt": ["jt"],
1415
- "model/mesh": ["msh", "mesh", "silo"],
1416
- "model/mtl": ["mtl"],
1417
- "model/obj": ["obj"],
1418
- "model/prc": ["prc"],
1419
- "model/step+xml": ["stpx"],
1420
- "model/step+zip": ["stpz"],
1421
- "model/step-xml+zip": ["stpxz"],
1422
- "model/stl": ["stl"],
1423
- "model/u3d": ["u3d"],
1424
- "model/vrml": ["wrl", "vrml"],
1425
- "model/x3d+binary": ["*x3db", "x3dbz"],
1426
- "model/x3d+fastinfoset": ["x3db"],
1427
- "model/x3d+vrml": ["*x3dv", "x3dvz"],
1428
- "model/x3d+xml": ["x3d", "x3dz"],
1429
- "model/x3d-vrml": ["x3dv"],
1430
- "text/cache-manifest": ["appcache", "manifest"],
1431
- "text/calendar": ["ics", "ifb"],
1432
- "text/coffeescript": ["coffee", "litcoffee"],
1433
- "text/css": ["css"],
1434
- "text/csv": ["csv"],
1435
- "text/html": ["html", "htm", "shtml"],
1436
- "text/jade": ["jade"],
1437
- "text/javascript": ["js", "mjs"],
1438
- "text/jsx": ["jsx"],
1439
- "text/less": ["less"],
1440
- "text/markdown": ["md", "markdown"],
1441
- "text/mathml": ["mml"],
1442
- "text/mdx": ["mdx"],
1443
- "text/n3": ["n3"],
1444
- "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"],
1445
- "text/richtext": ["rtx"],
1446
- "text/rtf": ["*rtf"],
1447
- "text/sgml": ["sgml", "sgm"],
1448
- "text/shex": ["shex"],
1449
- "text/slim": ["slim", "slm"],
1450
- "text/spdx": ["spdx"],
1451
- "text/stylus": ["stylus", "styl"],
1452
- "text/tab-separated-values": ["tsv"],
1453
- "text/troff": ["t", "tr", "roff", "man", "me", "ms"],
1454
- "text/turtle": ["ttl"],
1455
- "text/uri-list": ["uri", "uris", "urls"],
1456
- "text/vcard": ["vcard"],
1457
- "text/vtt": ["vtt"],
1458
- "text/wgsl": ["wgsl"],
1459
- "text/xml": ["*xml"],
1460
- "text/yaml": ["yaml", "yml"],
1461
- "video/3gpp": ["3gp", "3gpp"],
1462
- "video/3gpp2": ["3g2"],
1463
- "video/h261": ["h261"],
1464
- "video/h263": ["h263"],
1465
- "video/h264": ["h264"],
1466
- "video/iso.segment": ["m4s"],
1467
- "video/jpeg": ["jpgv"],
1468
- "video/jpm": ["*jpm", "*jpgm"],
1469
- "video/mj2": ["mj2", "mjp2"],
1470
- "video/mp2t": ["ts", "m2t", "m2ts", "mts"],
1471
- "video/mp4": ["mp4", "mp4v", "mpg4"],
1472
- "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"],
1473
- "video/ogg": ["ogv"],
1474
- "video/quicktime": ["qt", "mov"],
1475
- "video/webm": ["webm"]
1476
- };
1477
- Object.freeze(types);
1478
- var __classPrivateFieldGet = function(receiver, state, kind, f) {
1479
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1480
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1481
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1482
- };
1483
- var _Mime_extensionToType, _Mime_typeToExtension, _Mime_typeToExtensions;
1484
- class Mime {
1485
- constructor(...args) {
1486
- _Mime_extensionToType.set(this, /* @__PURE__ */ new Map());
1487
- _Mime_typeToExtension.set(this, /* @__PURE__ */ new Map());
1488
- _Mime_typeToExtensions.set(this, /* @__PURE__ */ new Map());
1489
- for (const arg of args) {
1490
- this.define(arg);
1491
- }
1492
- }
1493
- define(typeMap, force = false) {
1494
- for (let [type, extensions] of Object.entries(typeMap)) {
1495
- type = type.toLowerCase();
1496
- extensions = extensions.map((ext) => ext.toLowerCase());
1497
- if (!__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").has(type)) {
1498
- __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").set(type, /* @__PURE__ */ new Set());
1499
- }
1500
- const allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
1501
- let first = true;
1502
- for (let extension of extensions) {
1503
- const starred = extension.startsWith("*");
1504
- extension = starred ? extension.slice(1) : extension;
1505
- allExtensions == null ? void 0 : allExtensions.add(extension);
1506
- if (first) {
1507
- __classPrivateFieldGet(this, _Mime_typeToExtension, "f").set(type, extension);
1508
- }
1509
- first = false;
1510
- if (starred)
1511
- continue;
1512
- const currentType = __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(extension);
1513
- if (currentType && currentType != type && !force) {
1514
- throw new Error(`"${type} -> ${extension}" conflicts with "${currentType} -> ${extension}". Pass \`force=true\` to override this definition.`);
1515
- }
1516
- __classPrivateFieldGet(this, _Mime_extensionToType, "f").set(extension, type);
1517
- }
1518
- }
1519
- return this;
1520
- }
1521
- getType(path) {
1522
- if (typeof path !== "string")
1523
- return null;
1524
- const last = path.replace(/^.*[/\\]/, "").toLowerCase();
1525
- const ext = last.replace(/^.*\./, "").toLowerCase();
1526
- const hasPath = last.length < path.length;
1527
- const hasDot = ext.length < last.length - 1;
1528
- if (!hasDot && hasPath)
1529
- return null;
1530
- return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
1531
- }
1532
- getExtension(type) {
1533
- var _a;
1534
- if (typeof type !== "string")
1535
- return null;
1536
- type = (_a = type == null ? void 0 : type.split) == null ? void 0 : _a.call(type, ";")[0];
1537
- return (type && __classPrivateFieldGet(this, _Mime_typeToExtension, "f").get(type.trim().toLowerCase())) ?? null;
1538
- }
1539
- getAllExtensions(type) {
1540
- if (typeof type !== "string")
1541
- return null;
1542
- return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type.toLowerCase()) ?? null;
1543
- }
1544
- _freeze() {
1545
- this.define = () => {
1546
- throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
1547
- };
1548
- Object.freeze(this);
1549
- for (const extensions of __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").values()) {
1550
- Object.freeze(extensions);
1551
- }
1552
- return this;
1553
- }
1554
- _getTestState() {
1555
- return {
1556
- types: __classPrivateFieldGet(this, _Mime_extensionToType, "f"),
1557
- extensions: __classPrivateFieldGet(this, _Mime_typeToExtension, "f")
1558
- };
1559
- }
1560
- }
1561
- _Mime_extensionToType = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtension = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtensions = /* @__PURE__ */ new WeakMap();
1562
- const mime = new Mime(types)._freeze();
1563
- function validateOperations(operations) {
1564
- const errors = [];
1565
- const scopes = Object.keys(operations);
1566
- for (const scope of scopes) {
1567
- const ops = operations[scope].sort((a, b) => a.index - b.index);
1568
- let opIndex = -1;
1569
- for (let i = 0; i < ops.length; i++) {
1570
- opIndex = opIndex + 1 + ops[i].skip;
1571
- if (ops[i].index !== opIndex) {
1572
- errors.push({
1573
- message: `Invalid operation index ${ops[i].index} at position ${i}`,
1574
- details: {
1575
- position: i,
1576
- operation: ops[i],
1577
- scope: ops[i].scope
1578
- }
1579
- });
1580
- }
1581
- }
1582
- }
1583
- return errors;
1584
- }
1585
- var IntegrityIssueType = /* @__PURE__ */ ((IntegrityIssueType2) => {
1586
- IntegrityIssueType2["UNEXPECTED_INDEX"] = "UNEXPECTED_INDEX";
1587
- return IntegrityIssueType2;
1588
- })(IntegrityIssueType || {});
1589
- var IntegrityIssueSubType = /* @__PURE__ */ ((IntegrityIssueSubType2) => {
1590
- IntegrityIssueSubType2["DUPLICATED_INDEX"] = "DUPLICATED_INDEX";
1591
- IntegrityIssueSubType2["MISSING_INDEX"] = "MISSING_INDEX";
1592
- return IntegrityIssueSubType2;
1593
- })(IntegrityIssueSubType || {});
1594
- function checkCleanedOperationsIntegrity(sortedOperations) {
1595
- const result = [];
1596
- let currentIndex = -1;
1597
- for (const nextOperation of sortedOperations) {
1598
- const nextIndex = nextOperation.index - nextOperation.skip;
1599
- if (nextIndex !== currentIndex + 1) {
1600
- result.push({
1601
- operation: {
1602
- index: nextOperation.index,
1603
- skip: nextOperation.skip
1604
- },
1605
- issue: "UNEXPECTED_INDEX",
1606
- category: nextIndex > currentIndex + 1 ? "MISSING_INDEX" : "DUPLICATED_INDEX",
1607
- message: `Expected index ${currentIndex + 1} with skip 0 or equivalent, got index ${nextOperation.index} with skip ${nextOperation.skip}`
1608
- });
1609
- }
1610
- currentIndex = nextOperation.index;
1611
- }
1612
- return result;
1613
- }
1614
- function garbageCollect(sortedOperations) {
1615
- var _a, _b, _c;
1616
- const result = [];
1617
- let i = sortedOperations.length - 1;
1618
- while (i > -1) {
1619
- result.unshift(sortedOperations[i]);
1620
- const skipUntil = (((_a = sortedOperations[i]) == null ? void 0 : _a.index) || 0) - (((_b = sortedOperations[i]) == null ? void 0 : _b.skip) || 0) - 1;
1621
- let j = i - 1;
1622
- while (j > -1 && (((_c = sortedOperations[j]) == null ? void 0 : _c.index) || 0) > skipUntil) {
1623
- j--;
1624
- }
1625
- i = j;
1626
- }
1627
- return result;
1628
- }
1629
- function addUndo(sortedOperations) {
1630
- const operationsCopy = [...sortedOperations];
1631
- const latestOperation = operationsCopy[operationsCopy.length - 1];
1632
- if (!latestOperation) return operationsCopy;
1633
- if (latestOperation.type === "NOOP") {
1634
- operationsCopy.push({
1635
- ...latestOperation,
1636
- index: latestOperation.index,
1637
- type: "NOOP",
1638
- skip: nextSkipNumber(sortedOperations)
1639
- });
1640
- } else {
1641
- operationsCopy.push({
1642
- type: "NOOP",
1643
- index: latestOperation.index + 1,
1644
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1645
- input: {},
1646
- skip: 1,
1647
- scope: latestOperation.scope,
1648
- hash: latestOperation.hash
1649
- });
1650
- }
1651
- return operationsCopy;
1652
- }
1653
- function sortOperations$1(operations) {
1654
- return operations.slice().sort((a, b) => a.skip - b.skip).sort((a, b) => a.index - b.index);
1655
- }
1656
- const reshuffleByTimestamp = (startIndex, opsA, opsB) => {
1657
- return [...opsA, ...opsB].sort(
1658
- (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
1659
- ).map((op, i) => ({
1660
- ...op,
1661
- index: startIndex.index + i,
1662
- skip: i === 0 ? startIndex.skip : 0
1663
- }));
1664
- };
1665
- const reshuffleByTimestampAndIndex = (startIndex, opsA, opsB) => {
1666
- return [...opsA, ...opsB].sort(
1667
- (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
1668
- ).sort((a, b) => a.index - b.index).map((op, i) => ({
1669
- ...op,
1670
- index: startIndex.index + i,
1671
- skip: i === 0 ? startIndex.skip : 0
1672
- }));
1673
- };
1674
- function operationsAreEqual(op1, op2) {
1675
- return cjsModule(op1) === cjsModule(op2);
1676
- }
1677
- function attachBranch(trunk, newBranch) {
1678
- const trunkCopy = garbageCollect(sortOperations$1(trunk.slice()));
1679
- const newOperations = garbageCollect(sortOperations$1(newBranch.slice()));
1680
- if (trunkCopy.length < 1) {
1681
- return [newOperations, []];
1682
- }
1683
- const result = [];
1684
- let enteredBranch = false;
1685
- while (newOperations.length > 0) {
1686
- const newOperationCandidate = newOperations[0];
1687
- let nextTrunkOperation = trunkCopy.shift();
1688
- while (nextTrunkOperation && precedes(nextTrunkOperation, newOperationCandidate)) {
1689
- result.push(nextTrunkOperation);
1690
- nextTrunkOperation = trunkCopy.shift();
1691
- }
1692
- if (!nextTrunkOperation) {
1693
- enteredBranch = true;
1694
- } else if (!enteredBranch) {
1695
- if (operationsAreEqual(nextTrunkOperation, newOperationCandidate)) {
1696
- newOperations.shift();
1697
- result.push(nextTrunkOperation);
1698
- } else {
1699
- trunkCopy.unshift(nextTrunkOperation);
1700
- enteredBranch = true;
1701
- }
1702
- }
1703
- if (enteredBranch) {
1704
- let nextAppend = newOperations.shift();
1705
- while (nextAppend) {
1706
- result.push(nextAppend);
1707
- nextAppend = newOperations.shift();
1708
- }
1709
- }
1710
- }
1711
- if (!enteredBranch) {
1712
- let nextAppend = trunkCopy.shift();
1713
- while (nextAppend) {
1714
- result.push(nextAppend);
1715
- nextAppend = trunkCopy.shift();
1716
- }
1717
- }
1718
- return [garbageCollect(result), trunkCopy];
1719
- }
1720
- function precedes(op1, op2) {
1721
- return op1.index < op2.index || op1.index === op2.index && op1.id === op2.id && op1.skip < op2.skip;
1722
- }
1723
- function split(sortedTargetOperations, sortedMergeOperations) {
1724
- const commonOperations = [];
1725
- const targetDiffOperations = [];
1726
- const mergeDiffOperations = [];
1727
- const maxLength = Math.max(
1728
- sortedTargetOperations.length,
1729
- sortedMergeOperations.length
1730
- );
1731
- let splitHappened = false;
1732
- for (let i = 0; i < maxLength; i++) {
1733
- const targetOperation = sortedTargetOperations[i];
1734
- const mergeOperation = sortedMergeOperations[i];
1735
- if (targetOperation && mergeOperation) {
1736
- if (!splitHappened && operationsAreEqual(targetOperation, mergeOperation)) {
1737
- commonOperations.push(targetOperation);
1738
- } else {
1739
- splitHappened = true;
1740
- targetDiffOperations.push(targetOperation);
1741
- mergeDiffOperations.push(mergeOperation);
1742
- }
1743
- } else if (targetOperation) {
1744
- targetDiffOperations.push(targetOperation);
1745
- } else if (mergeOperation) {
1746
- mergeDiffOperations.push(mergeOperation);
1747
- }
1748
- }
1749
- return [commonOperations, targetDiffOperations, mergeDiffOperations];
1750
- }
1751
- function merge(sortedTargetOperations, sortedMergeOperations, reshuffle) {
1752
- const [_commonOperations, _targetOperations, _mergeOperations] = split(
1753
- garbageCollect(sortedTargetOperations),
1754
- garbageCollect(sortedMergeOperations)
1755
- );
1756
- const maxCommonIndex = getMaxIndex(_commonOperations);
1757
- const nextIndex = 1 + Math.max(
1758
- maxCommonIndex,
1759
- getMaxIndex(_targetOperations),
1760
- getMaxIndex(_mergeOperations)
1761
- );
1762
- const filteredMergeOperations = filterDuplicatedOperations(
1763
- _mergeOperations,
1764
- _targetOperations
1765
- );
1766
- const newOperationHistory = reshuffle(
1767
- {
1768
- index: nextIndex,
1769
- skip: nextIndex - (maxCommonIndex + 1)
1770
- },
1771
- _targetOperations,
1772
- filteredMergeOperations
1773
- );
1774
- return _commonOperations.concat(newOperationHistory);
1775
- }
1776
- function getMaxIndex(sortedOperations) {
1777
- const lastElement = sortedOperations[sortedOperations.length - 1];
1778
- if (!lastElement) {
1779
- return -1;
1780
- }
1781
- return lastElement.index;
1782
- }
1783
- function nextSkipNumber(sortedOperations) {
1784
- var _a, _b, _c;
1785
- if (sortedOperations.length < 1) {
1786
- return -1;
1787
- }
1788
- const cleanedOperations = garbageCollect(sortedOperations);
1789
- let nextSkip = (((_a = cleanedOperations[cleanedOperations.length - 1]) == null ? void 0 : _a.skip) || 0) + 1;
1790
- if (cleanedOperations.length > 1) {
1791
- nextSkip += ((_b = cleanedOperations[cleanedOperations.length - 2]) == null ? void 0 : _b.skip) || 0;
1792
- }
1793
- return (((_c = cleanedOperations[cleanedOperations.length - 1]) == null ? void 0 : _c.index) || -1) < nextSkip ? -1 : nextSkip;
1794
- }
1795
- const checkOperationsIntegrity = (operations) => {
1796
- return checkCleanedOperationsIntegrity(
1797
- garbageCollect(sortOperations$1(operations))
1798
- );
1799
- };
1800
- const groupOperationsByScope = (operations) => {
1801
- const result = operations.reduce((acc, operation) => {
1802
- var _a;
1803
- if (!acc[operation.scope]) {
1804
- acc[operation.scope] = [];
1805
- }
1806
- (_a = acc[operation.scope]) == null ? void 0 : _a.push(operation);
1807
- return acc;
1808
- }, {});
1809
- return result;
1810
- };
1811
- const prepareOperations = (operationsHistory, newOperations) => {
1812
- var _a;
1813
- const result = {
1814
- integrityIssues: [],
1815
- validOperations: [],
1816
- invalidOperations: [],
1817
- duplicatedOperations: []
1818
- };
1819
- const sortedOperationsHistory = sortOperations$1(operationsHistory);
1820
- const sortedOperations = sortOperations$1(newOperations);
1821
- const integrityErrors = checkCleanedOperationsIntegrity([
1822
- ...sortedOperationsHistory,
1823
- ...sortedOperations
1824
- ]);
1825
- const missingIndexErrors = integrityErrors.filter(
1826
- (integrityIssue) => integrityIssue.category === "MISSING_INDEX"
1827
- /* MISSING_INDEX */
1828
- );
1829
- const firstMissingIndexOperation = (_a = [...missingIndexErrors].sort((a, b) => b.operation.index - a.operation.index).pop()) == null ? void 0 : _a.operation;
1830
- for (const newOperation of sortedOperations) {
1831
- if (firstMissingIndexOperation && newOperation.index >= firstMissingIndexOperation.index) {
1832
- result.invalidOperations.push(newOperation);
1833
- continue;
1834
- }
1835
- const isDuplicatedOperation = integrityErrors.some((integrityError) => {
1836
- return integrityError.operation.index === newOperation.index && integrityError.operation.skip === newOperation.skip && integrityError.category === "DUPLICATED_INDEX";
1837
- });
1838
- if (isDuplicatedOperation) {
1839
- result.duplicatedOperations.push(newOperation);
1840
- continue;
1841
- }
1842
- result.validOperations.push(newOperation);
1843
- }
1844
- result.integrityIssues.push(...integrityErrors);
1845
- return result;
1846
- };
1847
- function removeExistingOperations(newOperations, operationsHistory) {
1848
- return newOperations.filter((newOperation) => {
1849
- return !operationsHistory.some((historyOperation) => {
1850
- return newOperation.type === "NOOP" && newOperation.skip === 0 && newOperation.index === historyOperation.index || newOperation.index === historyOperation.index && newOperation.skip === historyOperation.skip && newOperation.scope === historyOperation.scope && newOperation.hash === historyOperation.hash && newOperation.type === historyOperation.type;
1851
- });
1852
- });
1853
- }
1854
- function skipHeaderOperations(operations, skipHeaderOperation) {
1855
- const [lastOperation] = sortOperations$1(operations).slice(-1);
1856
- const lastIndex = (lastOperation == null ? void 0 : lastOperation.index) ?? -1;
1857
- const nextIndex = lastIndex + 1;
1858
- const skipOperationIndex = {
1859
- ...skipHeaderOperation,
1860
- index: skipHeaderOperation.index ?? nextIndex
1861
- };
1862
- if (skipOperationIndex.index < lastIndex) {
1863
- throw new Error(
1864
- `The skip header operation index must be greater than or equal to ${lastIndex}`
1865
- );
1866
- }
1867
- const clearedOperations = garbageCollect(
1868
- sortOperations$1([...operations, skipOperationIndex])
1869
- );
1870
- return (clearedOperations || []).slice(0, -1);
1871
- }
1872
- function garbageCollectDocumentOperations(documentOperations) {
1873
- const clearedOperations = Object.entries(documentOperations).reduce(
1874
- (acc, entry) => {
1875
- const [scope, ops] = entry;
1876
- return {
1877
- ...acc,
1878
- [scope]: garbageCollect(sortOperations$1(ops))
1879
- };
1880
- },
1881
- {}
1882
- );
1883
- return {
1884
- ...clearedOperations
1885
- };
1886
- }
1887
- function filterDuplicatedOperations(targetOperations, sourceOperations) {
1888
- return targetOperations.filter((op) => {
1889
- if (op.id) {
1890
- return !sourceOperations.some((targetOp) => targetOp.id === op.id);
1891
- }
1892
- return true;
1893
- });
1894
- }
1895
- function filterDocumentOperationsResultingState(documentOperations) {
1896
- if (!documentOperations) {
1897
- return {};
1898
- }
1899
- const entries = Object.entries(documentOperations);
1900
- return entries.reduce(
1901
- (acc, [scope, operations]) => ({
1902
- ...acc,
1903
- [scope]: operations.map((op) => {
1904
- const { resultingState, ...restProps } = op;
1905
- return restProps;
1906
- })
1907
- }),
1908
- {}
1909
- );
1910
- }
1911
- function diffOperations(clearedOperationsA, clearedOperationsB) {
1912
- return clearedOperationsA.filter(
1913
- (operationA) => !clearedOperationsB.some(
1914
- (operationB) => operationA.index === operationB.index
1915
- )
1916
- );
1917
- }
1918
- const documentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1919
- __proto__: null,
1920
- IntegrityIssueSubType,
1921
- IntegrityIssueType,
1922
- addUndo,
1923
- attachBranch,
1924
- checkCleanedOperationsIntegrity,
1925
- checkOperationsIntegrity,
1926
- diffOperations,
1927
- filterDocumentOperationsResultingState,
1928
- filterDuplicatedOperations,
1929
- garbageCollect,
1930
- garbageCollectDocumentOperations,
1931
- groupOperationsByScope,
1932
- merge,
1933
- nextSkipNumber,
1934
- operationsAreEqual,
1935
- precedes,
1936
- prepareOperations,
1937
- removeExistingOperations,
1938
- reshuffleByTimestamp,
1939
- reshuffleByTimestampAndIndex,
1940
- skipHeaderOperations,
1941
- sortOperations: sortOperations$1,
1942
- split
1943
- }, Symbol.toStringTag, { value: "Module" }));
1944
- const createZip = async (document) => {
1945
- const zip = new JSZip();
1946
- const { name, revision, documentType, created, lastModified } = document;
1947
- const header = {
1948
- name,
1949
- revision,
1950
- documentType,
1951
- created,
1952
- lastModified
1953
- };
1954
- zip.file("header.json", JSON.stringify(header, null, 2));
1955
- zip.file("state.json", JSON.stringify(document.initialState || {}, null, 2));
1956
- zip.file("current-state.json", JSON.stringify(document.state || {}, null, 2));
1957
- zip.file(
1958
- "operations.json",
1959
- JSON.stringify(
1960
- filterDocumentOperationsResultingState(document.operations),
1961
- null,
1962
- 2
1963
- )
1964
- );
1965
- if (document.attachments) {
1966
- const attachments = Object.keys(document.attachments);
1967
- attachments.forEach((key) => {
1968
- const { data, ...attributes } = document.attachments[key];
1969
- zip.file(key, data, {
1970
- base64: true,
1971
- createFolders: true,
1972
- comment: JSON.stringify(attributes)
1973
- });
1974
- });
1975
- }
1976
- return zip;
1977
- };
1978
- const saveToFile = async (document, path, extension, name) => {
1979
- const zip = await createZip(document);
1980
- await zip.generateAsync({
1981
- type: "uint8array",
1982
- streamFiles: true
1983
- });
1984
- const fileName = name ?? document.name;
1985
- const fileExtension = `.${extension}.zip`;
1986
- return writeFile(
1987
- path,
1988
- fileName.endsWith(fileExtension) ? fileName : `${fileName}${fileExtension}`
1989
- );
1990
- };
1991
- const saveToFileHandle = async (document, input) => {
1992
- const zip = await createZip(document);
1993
- const blob = await zip.generateAsync({ type: "blob" });
1994
- const writable = await input.createWritable();
1995
- await writable.write(blob);
1996
- await writable.close();
1997
- };
1998
- const loadFromFile = async (path, reducer, options) => {
1999
- const file = readFile();
2000
- return loadFromInput(file, reducer, options);
2001
- };
2002
- const loadFromInput = async (input, reducer, options) => {
2003
- const zip = new JSZip();
2004
- await zip.loadAsync(input);
2005
- return loadFromZip(zip, reducer, options);
2006
- };
2007
- async function loadFromZip(zip, reducer, options) {
2008
- const initialStateZip = zip.file("state.json");
2009
- if (!initialStateZip) {
2010
- throw new Error("Initial state not found");
2011
- }
2012
- const initialStateStr = await initialStateZip.async("string");
2013
- const initialState = JSON.parse(initialStateStr);
2014
- const headerZip = zip.file("header.json");
2015
- let header = void 0;
2016
- if (headerZip) {
2017
- header = JSON.parse(await headerZip.async("string"));
2018
- }
2019
- const operationsZip = zip.file("operations.json");
2020
- if (!operationsZip) {
2021
- throw new Error("Operations history not found");
2022
- }
2023
- const operations = JSON.parse(
2024
- await operationsZip.async("string")
2025
- );
2026
- const clearedOperations = garbageCollectDocumentOperations(operations);
2027
- const operationsError = validateOperations(clearedOperations);
2028
- if (operationsError.length) {
2029
- const errorMessages = operationsError.map((err) => err.message);
2030
- throw new Error(errorMessages.join("\n"));
2031
- }
2032
- let result = replayDocument(
2033
- initialState,
2034
- clearedOperations,
2035
- reducer,
2036
- void 0,
2037
- header,
2038
- {},
2039
- options
2040
- );
2041
- if (header) {
2042
- result = {
2043
- ...result,
2044
- ...header
2045
- };
2046
- }
2047
- return result;
2048
- }
2049
- function getFileAttributes(file) {
2050
- const extension = file.replace(/^.*\./, "") || void 0;
2051
- const fileName = file.replace(/^.*[/\\]/, "") || void 0;
2052
- return { extension, fileName };
2053
- }
2054
- async function getRemoteFile(url) {
2055
- const { buffer, mimeType = "application/octet-stream" } = await fetchFile();
2056
- const attributes = getFileAttributes(url);
2057
- const data = buffer.toString("base64");
2058
- return {
2059
- data,
2060
- hash: hash(data),
2061
- mimeType,
2062
- ...attributes
2063
- };
2064
- }
2065
- async function getLocalFile(path) {
2066
- const buffer = await getFile();
2067
- const mimeType = mime.getType(path) || "application/octet-stream";
2068
- const attributes = getFileAttributes(path);
2069
- const data = buffer.toString("base64");
2070
- return { data, hash: hash(data), mimeType, ...attributes };
2071
- }
2072
- function setNameOperation(document, name) {
2073
- return { ...document, name };
2074
- }
2075
- function undoOperation(document, action, skip) {
2076
- const { scope, input } = action;
2077
- const defaultResult = {
2078
- document,
2079
- action,
2080
- skip,
2081
- reuseLastOperationIndex: false
2082
- };
2083
- return mutative.create(defaultResult, (draft) => {
2084
- const operations = [...document.operations[scope]];
2085
- const sortedOperations = sortOperations$1(operations);
2086
- draft.action = noop(scope);
2087
- const lastOperation = sortedOperations.at(-1);
2088
- let nextIndex = (lastOperation == null ? void 0 : lastOperation.index) ?? -1;
2089
- const isNewNoop = (lastOperation == null ? void 0 : lastOperation.type) !== "NOOP";
2090
- if (isNewNoop) {
2091
- nextIndex = nextIndex + 1;
2092
- } else {
2093
- draft.reuseLastOperationIndex = true;
2094
- }
2095
- const nextOperationHistory = isNewNoop ? [...sortedOperations, { index: nextIndex, skip: 0 }] : sortedOperations;
2096
- draft.skip = nextSkipNumber(nextOperationHistory);
2097
- if (lastOperation && draft.skip > lastOperation.skip + 1) {
2098
- draft.skip = draft.skip + 1;
2099
- }
2100
- if (draft.skip < 0) {
2101
- throw new Error(
2102
- `Cannot undo: you can't undo more operations than the ones in the scope history`
2103
- );
2104
- }
2105
- });
2106
- }
2107
- function redoOperation(document, action, skip) {
2108
- const { scope, input } = action;
2109
- const defaultResult = {
2110
- document,
2111
- action,
2112
- skip,
2113
- reuseLastOperationIndex: false
2114
- };
2115
- return mutative.create(defaultResult, (draft) => {
2116
- if (draft.skip > 0) {
2117
- throw new Error(
2118
- `Cannot redo: skip value from reducer cannot be used with REDO action`
2119
- );
2120
- }
2121
- if (input > 1) {
2122
- throw new Error(`Cannot redo: you can only redo one operation at a time`);
2123
- }
2124
- if (input < 1) {
2125
- throw new Error(`Invalid REDO action: invalid redo input value`);
2126
- }
2127
- if (draft.document.clipboard.length < 1) {
2128
- throw new Error(`Cannot redo: no operations in the clipboard`);
2129
- }
2130
- const operationIndex = draft.document.clipboard.findLastIndex(
2131
- (op) => op.scope === scope
2132
- );
2133
- if (operationIndex < 0) {
2134
- throw new Error(
2135
- `Cannot redo: no operations in clipboard for scope "${scope}"`
2136
- );
2137
- }
2138
- const operation = draft.document.clipboard.splice(operationIndex, 1)[0];
2139
- draft.action = mutative.castDraft({
2140
- type: operation.type,
2141
- scope: operation.scope,
2142
- input: operation.input
2143
- });
2144
- });
2145
- }
2146
- function pruneOperation(document, action, wrappedReducer) {
2147
- const { scope } = action;
2148
- const operations = document.operations[scope];
2149
- let {
2150
- input: { start, end }
2151
- } = action;
2152
- start = start || 0;
2153
- end = end || operations.length;
2154
- const actionsToPrune = operations.slice(start, end);
2155
- const actionsToKeepStart = operations.slice(0, start);
2156
- const actionsToKeepEnd = operations.slice(end);
2157
- const newDocument = replayOperations(
2158
- document.initialState,
2159
- {
2160
- ...document.operations,
2161
- [scope]: actionsToKeepStart.concat(actionsToPrune)
2162
- },
2163
- wrappedReducer
2164
- );
2165
- const { name, state: newState } = newDocument;
2166
- const loadStateIndex = actionsToKeepStart.length;
2167
- const loadStateTimestamp = actionsToKeepStart.length ? actionsToKeepStart[actionsToKeepStart.length - 1].timestamp : actionsToKeepEnd.length ? actionsToKeepEnd[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
2168
- return replayOperations(
2169
- document.initialState,
2170
- {
2171
- ...document.operations,
2172
- [scope]: [
2173
- ...actionsToKeepStart,
2174
- {
2175
- ...loadState({ name, state: newState }, actionsToPrune.length),
2176
- timestamp: loadStateTimestamp,
2177
- index: loadStateIndex,
2178
- hash: hashDocument({ state: newState }, "global")
2179
- },
2180
- ...actionsToKeepEnd.map((action2, index) => ({
2181
- ...action2,
2182
- index: loadStateIndex + index + 1
2183
- }))
2184
- ]
2185
- },
2186
- wrappedReducer
2187
- );
2188
- }
2189
- function loadStateOperation(oldDocument, newDocument) {
2190
- return {
2191
- ...oldDocument,
2192
- name: newDocument.name,
2193
- state: newDocument.state ?? { global: {}, local: {} }
2194
- };
2195
- }
2196
- const SET_NAME = "SET_NAME";
2197
- const UNDO = "UNDO";
2198
- const REDO = "REDO";
2199
- const PRUNE = "PRUNE";
2200
- const LOAD_STATE = "LOAD_STATE";
2201
- const NOOP = "NOOP";
2202
- function getNextRevision(document, action) {
2203
- let latestOperation;
2204
- if ("index" in action) {
2205
- latestOperation = { ...action };
2206
- } else {
2207
- latestOperation = document.operations[action.scope].at(-1);
2208
- }
2209
- return ((latestOperation == null ? void 0 : latestOperation.index) ?? -1) + 1;
2210
- }
2211
- function updateHeader(document, action) {
2212
- return {
2213
- ...document,
2214
- revision: {
2215
- ...document.revision,
2216
- [action.scope]: getNextRevision(document, action)
2217
- },
2218
- lastModified: getDocumentLastModified(document)
2219
- };
2220
- }
2221
- function updateOperations(document, action, skip = 0, reuseLastOperationIndex = false) {
2222
- if ([UNDO, REDO, PRUNE].includes(action.type)) {
2223
- return document;
2224
- }
2225
- const { scope } = action;
2226
- const operations = document.operations[scope].slice();
2227
- let operationId;
2228
- const latestOperation = operations.at(-1);
2229
- const lastOperationIndex = (latestOperation == null ? void 0 : latestOperation.index) ?? -1;
2230
- let nextIndex = reuseLastOperationIndex ? lastOperationIndex : lastOperationIndex + 1;
2231
- let timestamp = (/* @__PURE__ */ new Date()).toISOString();
2232
- if ("index" in action) {
2233
- if (action.index - skip > nextIndex) {
2234
- throw new Error(
2235
- `Missing operations: expected ${nextIndex} with skip 0 or equivalent, got index ${action.index} with skip ${skip}`
2236
- );
2237
- }
2238
- nextIndex = action.index;
2239
- operationId = action.id;
2240
- timestamp = action.timestamp;
2241
- } else {
2242
- operationId = "id" in action ? action.id : generateId();
2243
- }
2244
- operations.push({
2245
- ...action,
2246
- id: operationId,
2247
- index: nextIndex,
2248
- timestamp,
2249
- hash: "",
2250
- scope,
2251
- skip,
2252
- error: void 0
2253
- });
2254
- return {
2255
- ...document,
2256
- operations: { ...document.operations, [scope]: operations }
2257
- };
2258
- }
2259
- function updateDocument(document, action, skip = 0, reuseLastOperationIndex = false) {
2260
- let newDocument = updateOperations(
2261
- document,
2262
- action,
2263
- skip,
2264
- reuseLastOperationIndex
2265
- );
2266
- newDocument = updateHeader(newDocument, action);
2267
- return newDocument;
2268
- }
2269
- function _baseReducer(document, action, wrappedReducer) {
2270
- BaseActionSchema().parse(action);
2271
- switch (action.type) {
2272
- case SET_NAME:
2273
- return setNameOperation(document, action.input);
2274
- case PRUNE:
2275
- return pruneOperation(document, action, wrappedReducer);
2276
- case LOAD_STATE:
2277
- return loadStateOperation(document, action.input.state);
2278
- default:
2279
- return document;
2280
- }
2281
- }
2282
- function processUndoRedo(document, action, skip) {
2283
- switch (action.type) {
2284
- case UNDO:
2285
- return undoOperation(document, action, skip);
2286
- case REDO:
2287
- return redoOperation(document, action, skip);
2288
- default:
2289
- return { document, action, skip, reuseLastOperationIndex: false };
2290
- }
2291
- }
2292
- function processSkipOperation(document, action, customReducer, skipValue, reuseOperationResultingState = false, resultingStateParser = parseResultingState) {
2293
- const scope = action.scope;
2294
- const latestOperation = document.operations[scope].at(-1);
2295
- if (!latestOperation) return document;
2296
- const documentOperations = garbageCollectDocumentOperations({
2297
- ...document.operations,
2298
- [scope]: skipHeaderOperations(
2299
- document.operations[scope],
2300
- latestOperation
2301
- )
2302
- });
2303
- let scopeState = void 0;
2304
- const lastRemainingOperation = documentOperations[scope].at(-1);
2305
- if (reuseOperationResultingState && (lastRemainingOperation == null ? void 0 : lastRemainingOperation.resultingState)) {
2306
- scopeState = resultingStateParser(lastRemainingOperation.resultingState);
2307
- } else {
2308
- const { state } = replayOperations(
2309
- document.initialState,
2310
- documentOperations,
2311
- customReducer,
2312
- void 0,
2313
- void 0,
2314
- void 0,
2315
- void 0,
2316
- {
2317
- reuseHash: true,
2318
- reuseOperationResultingState,
2319
- operationResultingStateParser: resultingStateParser
2320
- }
2321
- );
2322
- scopeState = state[scope];
2323
- }
2324
- return {
2325
- ...document,
2326
- state: {
2327
- ...document.state,
2328
- [scope]: scopeState
2329
- },
2330
- operations: garbageCollectDocumentOperations({
2331
- ...document.operations
2332
- })
2333
- };
2334
- }
2335
- function processUndoOperation(document, scope, customReducer, reuseOperationResultingState = false, resultingStateParser = parseResultingState) {
2336
- const operations = [...document.operations[scope]];
2337
- const sortedOperations = sortOperations$1(operations);
2338
- sortedOperations.pop();
2339
- const documentOperations = garbageCollectDocumentOperations({
2340
- ...document.operations
2341
- });
2342
- const clearedOperations = [...documentOperations[scope]];
2343
- const diff = diffOperations(
2344
- garbageCollect(sortedOperations),
2345
- clearedOperations
2346
- );
2347
- const doc = replayOperations(
2348
- document.initialState,
2349
- documentOperations,
2350
- customReducer,
2351
- void 0,
2352
- void 0,
2353
- void 0,
2354
- void 0,
2355
- {
2356
- reuseHash: true,
2357
- reuseOperationResultingState,
2358
- operationResultingStateParser: resultingStateParser
2359
- }
2360
- );
2361
- const clipboard = sortOperations$1(
2362
- [...document.clipboard, ...diff].filter((op) => op.type !== "NOOP")
2363
- ).reverse();
2364
- return { ...doc, clipboard };
2365
- }
2366
- function baseReducer(document, action, customReducer, dispatch, options = {}) {
2367
- const {
2368
- skip,
2369
- ignoreSkipOperations = false,
2370
- reuseHash = false,
2371
- reuseOperationResultingState = false,
2372
- operationResultingStateParser
2373
- } = options;
2374
- let _action = { ...action };
2375
- let skipValue = skip || 0;
2376
- let newDocument = { ...document };
2377
- let reuseLastOperationIndex = false;
2378
- const shouldProcessSkipOperation = !ignoreSkipOperations && (skipValue > 0 || "index" in _action && _action.skip > 0);
2379
- if (isUndoRedo(_action)) {
2380
- const {
2381
- skip: calculatedSkip,
2382
- action: transformedAction,
2383
- document: processedDocument,
2384
- reuseLastOperationIndex: reuseIndex
2385
- } = processUndoRedo(document, _action, skipValue);
2386
- _action = transformedAction;
2387
- skipValue = calculatedSkip;
2388
- newDocument = processedDocument;
2389
- reuseLastOperationIndex = reuseIndex;
2390
- } else {
2391
- newDocument = {
2392
- ...newDocument,
2393
- clipboard: []
2394
- };
2395
- }
2396
- if (isBaseAction(_action)) {
2397
- newDocument = _baseReducer(newDocument, _action, customReducer);
2398
- }
2399
- newDocument = updateDocument(
2400
- newDocument,
2401
- _action,
2402
- skipValue,
2403
- reuseLastOperationIndex
2404
- );
2405
- const isUndoAction = isUndo(action);
2406
- if (isUndoAction) {
2407
- const result = processUndoOperation(
2408
- newDocument,
2409
- action.scope,
2410
- customReducer
2411
- );
2412
- return result;
2413
- }
2414
- if (shouldProcessSkipOperation) {
2415
- newDocument = processSkipOperation(
2416
- newDocument,
2417
- _action,
2418
- customReducer,
2419
- skipValue,
2420
- reuseOperationResultingState,
2421
- operationResultingStateParser
2422
- );
2423
- }
2424
- newDocument = mutative.create(newDocument, (draft) => {
2425
- try {
2426
- const newState = customReducer(draft.state, _action, dispatch);
2427
- if (newState) {
2428
- mutative.unsafe(() => {
2429
- draft.state = mutative.castDraft(newState);
2430
- });
2431
- } else {
2432
- }
2433
- } catch (error) {
2434
- const lastOperationIndex = newDocument.operations[_action.scope].length - 1;
2435
- draft.operations[_action.scope][lastOperationIndex].error = error.message;
2436
- draft.operations[_action.scope][lastOperationIndex].skip = 0;
2437
- if (shouldProcessSkipOperation) {
2438
- draft.state = mutative.castDraft({ ...document.state });
2439
- draft.operations = mutative.castDraft({
2440
- ...document.operations,
2441
- [_action.scope]: [
2442
- ...document.operations[_action.scope],
2443
- {
2444
- ...draft.operations[_action.scope][lastOperationIndex]
2445
- }
2446
- ]
2447
- });
2448
- }
2449
- }
2450
- });
2451
- if ([UNDO, REDO, PRUNE].includes(_action.type)) {
2452
- return newDocument;
2453
- }
2454
- const scope = _action.scope || "global";
2455
- const hash2 = reuseHash && Object.prototype.hasOwnProperty.call(_action, "hash") ? _action.hash : hashDocument(newDocument, scope);
2456
- const lastOperation = newDocument.operations[scope].at(-1);
2457
- if (lastOperation) {
2458
- lastOperation.hash = hash2;
2459
- if (reuseOperationResultingState) {
2460
- lastOperation.resultingState = newDocument.state[scope];
2461
- }
2462
- if (!isBaseAction(_action) && _action.attachments) {
2463
- _action.attachments.forEach((attachment) => {
2464
- const { hash: hash22, ...file } = attachment;
2465
- newDocument.attachments[hash22] = {
2466
- ...file
2467
- };
2468
- });
2469
- }
2470
- }
2471
- return newDocument;
2472
- }
2473
- function mutableBaseReducer(document, action, customReducer, dispatch, options = {}) {
2474
- const {
2475
- skip,
2476
- ignoreSkipOperations = false,
2477
- reuseHash = false,
2478
- reuseOperationResultingState = false,
2479
- operationResultingStateParser
2480
- } = options;
2481
- const _action = { ...action };
2482
- const skipValue = skip || 0;
2483
- let newDocument = { ...document };
2484
- const shouldProcessSkipOperation = !ignoreSkipOperations && (skipValue > 0 || "index" in _action && _action.skip > 0);
2485
- if (isBaseAction(_action)) {
2486
- newDocument = _baseReducer(newDocument, _action, customReducer);
2487
- }
2488
- newDocument = updateDocument(newDocument, _action, skipValue);
2489
- if (shouldProcessSkipOperation) {
2490
- newDocument = processSkipOperation(
2491
- newDocument,
2492
- _action,
2493
- customReducer,
2494
- skipValue,
2495
- reuseOperationResultingState,
2496
- operationResultingStateParser
2497
- );
2498
- }
2499
- try {
2500
- const newState = customReducer(
2501
- newDocument.state,
2502
- _action,
2503
- dispatch
2504
- );
2505
- if (newState) {
2506
- newDocument.state = newState;
2507
- }
2508
- } catch (error) {
2509
- const lastOperationIndex = newDocument.operations[_action.scope].length - 1;
2510
- newDocument.operations[_action.scope][lastOperationIndex].error = error.message;
2511
- newDocument.operations[_action.scope][lastOperationIndex].skip = 0;
2512
- if (shouldProcessSkipOperation) {
2513
- newDocument.state = { ...document.state };
2514
- newDocument.operations = {
2515
- ...document.operations,
2516
- [_action.scope]: [
2517
- ...document.operations[_action.scope],
2518
- {
2519
- ...newDocument.operations[_action.scope][lastOperationIndex]
2520
- }
2521
- ]
2522
- };
2523
- }
2524
- }
2525
- if ([UNDO, REDO, PRUNE].includes(_action.type)) {
2526
- return newDocument;
2527
- }
2528
- const scope = _action.scope || "global";
2529
- const hash2 = reuseHash && Object.prototype.hasOwnProperty.call(_action, "hash") ? _action.hash : hashDocument(newDocument, scope);
2530
- const lastOperation = newDocument.operations[scope].at(-1);
2531
- if (lastOperation) {
2532
- lastOperation.hash = hash2;
2533
- if (reuseOperationResultingState) {
2534
- lastOperation.resultingState = newDocument.state[scope];
2535
- }
2536
- if (!isBaseAction(_action) && _action.attachments) {
2537
- _action.attachments.forEach((attachment) => {
2538
- const { hash: hash22, ...file } = attachment;
2539
- newDocument.attachments[hash22] = {
2540
- ...file
2541
- };
2542
- });
2543
- }
2544
- }
2545
- return newDocument;
2546
- }
2547
- function isNoopOperation(op) {
2548
- return op.type === NOOP && op.skip !== void 0 && op.skip > 0 && op.hash !== void 0;
2549
- }
2550
- function isUndoRedo(action) {
2551
- return [UNDO, REDO].includes(action.type);
2552
- }
2553
- function isUndo(action) {
2554
- return action.type === UNDO;
2555
- }
2556
- function isBaseAction(action) {
2557
- return [SET_NAME, UNDO, REDO, PRUNE, LOAD_STATE].includes(action.type);
2558
- }
2559
- function createAction(type, input, attachments, validator, scope = "global") {
2560
- if (!type) {
2561
- throw new Error("Empty action type");
2562
- }
2563
- if (typeof type !== "string") {
2564
- throw new Error(`Invalid action type: ${JSON.stringify(type)}`);
2565
- }
2566
- const action = { type, input, scope };
2567
- if (attachments) {
2568
- action.attachments = attachments;
2569
- }
2570
- try {
2571
- validator == null ? void 0 : validator().parse(action.input);
2572
- } catch (error) {
2573
- if (error instanceof zod$1.ZodError) {
2574
- throw new InvalidActionInputZodError(error.issues);
2575
- } else {
2576
- throw new InvalidActionInputError(error);
2577
- }
2578
- }
2579
- return action;
2580
- }
2581
- function createReducer(reducer, documentReducer = baseReducer) {
2582
- return (document, action, dispatch, options) => {
2583
- return documentReducer(document, action, reducer, dispatch, options);
2584
- };
2585
- }
2586
- function createUnsafeReducer(reducer, documentReducer = mutableBaseReducer) {
2587
- return (document, action, dispatch, options) => {
2588
- return documentReducer(document, action, reducer, dispatch, options);
2589
- };
2590
- }
2591
- const createExtendedState = (initialState, createState) => {
2592
- return {
2593
- name: "",
2594
- documentType: "",
2595
- revision: {
2596
- global: 0,
2597
- local: 0
2598
- },
2599
- created: (/* @__PURE__ */ new Date()).toISOString(),
2600
- lastModified: (/* @__PURE__ */ new Date()).toISOString(),
2601
- attachments: {},
2602
- ...initialState,
2603
- state: (createState == null ? void 0 : createState(initialState == null ? void 0 : initialState.state)) ?? ((initialState == null ? void 0 : initialState.state) ?? { global: {}, local: {} })
2604
- };
2605
- };
2606
- const createDocument = (initialState, createState) => {
2607
- const state = createExtendedState(
2608
- initialState,
2609
- createState
2610
- );
2611
- return {
2612
- ...state,
2613
- initialState: state,
2614
- operations: { global: [], local: [] },
2615
- clipboard: []
2616
- };
2617
- };
2618
- const hashDocument = (document, scope = "global") => {
2619
- return hash(cjsModule(document.state[scope] || ""));
2620
- };
2621
- const hashKey = (date, randomLimit = 1e3) => {
2622
- const random = Math.random() * randomLimit;
2623
- return hash(`${(date ?? /* @__PURE__ */ new Date()).toISOString()}${random}`);
2624
- };
2625
- function readOnly(value) {
2626
- return Object.freeze(value);
2627
- }
2628
- function mapSkippedOperations(operations, skippedHeadOperations) {
2629
- const ops = [...operations];
2630
- let skipped = skippedHeadOperations || 0;
2631
- let latestOpIndex = ops.length > 0 ? ops[ops.length - 1].index : 0;
2632
- const scopeOpsWithIgnore = [];
2633
- for (const operation of ops.reverse()) {
2634
- if (skipped > 0) {
2635
- const operationsDiff = latestOpIndex - operation.index;
2636
- skipped -= operationsDiff;
2637
- }
2638
- if (skipped < 0) {
2639
- throw new Error("Invalid operation index, missing operations");
2640
- }
2641
- const mappedOp = {
2642
- ignore: skipped > 0,
2643
- operation
2644
- };
2645
- const operationSkip = operation.skip > 0 ? operation.skip + 1 : 0;
2646
- if (operationSkip > 0 && operationSkip > skipped) {
2647
- const skipDiff = operationSkip - skipped;
2648
- skipped = skipped + skipDiff;
2649
- }
2650
- latestOpIndex = operation.index;
2651
- scopeOpsWithIgnore.push(mappedOp);
2652
- }
2653
- return scopeOpsWithIgnore.reverse();
2654
- }
2655
- function sortOperations(operations) {
2656
- return Object.values(operations).flatMap((array) => array).sort(
2657
- (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
2658
- );
2659
- }
2660
- function sortMappedOperations(operations) {
2661
- return Object.values(operations).flatMap((array) => array).sort(
2662
- (a, b) => new Date(a.operation.timestamp).getTime() - new Date(b.operation.timestamp).getTime()
2663
- );
2664
- }
2665
- function getDocumentLastModified(document) {
2666
- var _a;
2667
- const sortedOperations = sortOperations(document.operations);
2668
- const timestamp = ((_a = sortedOperations.at(-1)) == null ? void 0 : _a.timestamp) || document.initialState.lastModified;
2669
- return timestamp;
2670
- }
2671
- function replayOperations(initialState, clearedOperations, reducer, dispatch, header, documentReducer = baseReducer, skipHeaderOperations2 = {}, options) {
2672
- const wrappedReducer = createReducer(reducer, documentReducer);
2673
- return replayDocument(
2674
- initialState,
2675
- clearedOperations,
2676
- wrappedReducer,
2677
- dispatch,
2678
- header,
2679
- skipHeaderOperations2,
2680
- options
2681
- );
2682
- }
2683
- function replayDocument(initialState, operations, reducer, dispatch, header, skipHeaderOperations2 = {}, options) {
2684
- const {
2685
- checkHashes = true,
2686
- reuseOperationResultingState,
2687
- operationResultingStateParser = parseResultingState
2688
- } = options || {};
2689
- let documentState = initialState;
2690
- const operationsToReplay = [];
2691
- const initialOperations = {
2692
- global: [],
2693
- local: []
2694
- };
2695
- if (reuseOperationResultingState) {
2696
- for (const [scope, scopeOperations] of Object.entries(operations)) {
2697
- const index = scopeOperations.findLastIndex((s) => !!s.resultingState);
2698
- if (index < 0) {
2699
- operationsToReplay.push(...scopeOperations);
2700
- continue;
2701
- }
2702
- const opWithState = scopeOperations[index];
2703
- try {
2704
- const scopeState = operationResultingStateParser(
2705
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
2706
- opWithState.resultingState
2707
- );
2708
- documentState = {
2709
- ...documentState,
2710
- state: {
2711
- ...documentState.state,
2712
- // TODO how to deal with attachments?
2713
- [scope]: scopeState
2714
- }
2715
- };
2716
- initialOperations[scope].push(
2717
- ...scopeOperations.slice(0, index + 1)
2718
- );
2719
- operationsToReplay.push(...scopeOperations.slice(index + 1));
2720
- } catch {
2721
- operationsToReplay.push(...scopeOperations);
2722
- }
2723
- }
2724
- } else {
2725
- operationsToReplay.push(...Object.values(operations).flat());
2726
- }
2727
- const document = createDocument(documentState);
2728
- document.initialState = initialState;
2729
- document.operations = initialOperations;
2730
- let result = document;
2731
- if (operationsToReplay.length) {
2732
- result = operationsToReplay.reduce((document2, operation) => {
2733
- const doc = reducer(document2, operation, dispatch, {
2734
- skip: operation.skip,
2735
- ignoreSkipOperations: true,
2736
- reuseHash: !checkHashes
2737
- });
2738
- return doc;
2739
- }, document);
2740
- } else {
2741
- for (const scopeOperations of Object.values(initialOperations)) {
2742
- const lastOperation = scopeOperations.at(-1);
2743
- if (lastOperation) {
2744
- result = updateHeader(result, lastOperation);
2745
- }
2746
- }
2747
- }
2748
- if (!checkHashes) {
2749
- for (const scope of Object.keys(result.state)) {
2750
- for (let i = operationsToReplay.length - 1; i >= 0; i--) {
2751
- const operation = operationsToReplay[i];
2752
- if (operation.scope !== scope) {
2753
- continue;
2754
- }
2755
- if (operation.hash !== hashDocument(result, scope)) {
2756
- throw new Error(`Hash mismatch for scope ${scope}`);
2757
- } else {
2758
- break;
2759
- }
2760
- }
2761
- }
2762
- }
2763
- const resultOperations = Object.keys(
2764
- result.operations
2765
- ).reduce(
2766
- (acc, key) => {
2767
- const scope = key;
2768
- return {
2769
- ...acc,
2770
- [scope]: [
2771
- ...result.operations[scope].map((operation, index) => {
2772
- var _a;
2773
- return {
2774
- ...operation,
2775
- timestamp: ((_a = operations[scope][index]) == null ? void 0 : _a.timestamp) ?? operation.timestamp
2776
- };
2777
- })
2778
- ]
2779
- };
2780
- },
2781
- { global: [], local: [] }
2782
- );
2783
- const lastModified = Object.values(resultOperations).reduce((acc, curr) => {
2784
- const operation = curr.at(-1);
2785
- if (operation && operation.timestamp > acc) {
2786
- acc = operation.timestamp;
2787
- }
2788
- return acc;
2789
- }, initialState.lastModified);
2790
- return { ...result, operations: resultOperations, lastModified };
2791
- }
2792
- function isSameDocument(documentA, documentB) {
2793
- return cjsModule(documentA) === cjsModule(documentB);
2794
- }
2795
- function parseResultingState(state) {
2796
- const stateType = typeof state;
2797
- if (stateType === "string") {
2798
- return JSON.parse(state);
2799
- } else if (stateType === "object") {
2800
- return state;
2801
- } else {
2802
- throw new Error(`Providing resulting state is of type: ${stateType}`);
2803
- }
2804
- }
2805
- const setName = (name) => createAction(
2806
- "SET_NAME",
2807
- name,
2808
- void 0,
2809
- SetNameActionInputSchema,
2810
- void 0
2811
- );
2812
- const undo = (skip = 1, scope = "global") => createAction(
2813
- "UNDO",
2814
- skip,
2815
- void 0,
2816
- UndoActionInputSchema,
2817
- scope
2818
- );
2819
- const redo = (count = 1, scope = "global") => createAction(
2820
- "REDO",
2821
- count,
2822
- void 0,
2823
- RedoActionInputSchema,
2824
- scope
2825
- );
2826
- const prune = (start, end, scope = "global") => createAction(
2827
- "PRUNE",
2828
- { start, end },
2829
- void 0,
2830
- PruneActionInputSchema,
2831
- scope
2832
- );
2833
- const loadState = (state, operations) => createAction(
2834
- "LOAD_STATE",
2835
- { state, operations },
2836
- void 0,
2837
- LoadStateActionInputSchema
2838
- );
2839
- const noop = (scope = "global") => createAction("NOOP", {}, void 0, void 0, scope);
2840
- const BaseActions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2841
- __proto__: null,
2842
- loadState,
2843
- noop,
2844
- prune,
2845
- redo,
2846
- setName,
2847
- undo
2848
- }, Symbol.toStringTag, { value: "Module" }));
2849
- exports.BaseActions = BaseActions;
2850
- exports.InvalidActionInputError = InvalidActionInputError;
2851
- exports.InvalidActionInputZodError = InvalidActionInputZodError;
2852
- exports.ab2hex = ab2hex;
2853
- exports.baseReducer = baseReducer;
2854
- exports.buildOperationSignature = buildOperationSignature;
2855
- exports.buildOperationSignatureMessage = buildOperationSignatureMessage;
2856
- exports.buildOperationSignatureParams = buildOperationSignatureParams;
2857
- exports.buildSignedOperation = buildSignedOperation;
2858
- exports.createAction = createAction;
2859
- exports.createDocument = createDocument;
2860
- exports.createExtendedState = createExtendedState;
2861
- exports.createReducer = createReducer;
2862
- exports.createUnsafeReducer = createUnsafeReducer;
2863
- exports.createZip = createZip;
2864
- exports.documentHelpers = documentHelpers;
2865
- exports.generateId = generateId;
2866
- exports.getDocumentLastModified = getDocumentLastModified;
2867
- exports.getLocalFile = getLocalFile;
2868
- exports.getRemoteFile = getRemoteFile;
2869
- exports.getUnixTimestamp = getUnixTimestamp;
2870
- exports.hashDocument = hashDocument;
2871
- exports.hashKey = hashKey;
2872
- exports.hex2ab = hex2ab;
2873
- exports.isBaseAction = isBaseAction;
2874
- exports.isNoopOperation = isNoopOperation;
2875
- exports.isSameDocument = isSameDocument;
2876
- exports.isUndo = isUndo;
2877
- exports.isUndoRedo = isUndoRedo;
2878
- exports.loadFromFile = loadFromFile;
2879
- exports.loadFromInput = loadFromInput;
2880
- exports.loadState = loadState;
2881
- exports.mapSkippedOperations = mapSkippedOperations;
2882
- exports.mutableBaseReducer = mutableBaseReducer;
2883
- exports.parseResultingState = parseResultingState;
2884
- exports.processUndoRedo = processUndoRedo;
2885
- exports.prune = prune;
2886
- exports.readOnly = readOnly;
2887
- exports.redo = redo;
2888
- exports.replayDocument = replayDocument;
2889
- exports.replayOperations = replayOperations;
2890
- exports.saveToFile = saveToFile;
2891
- exports.saveToFileHandle = saveToFileHandle;
2892
- exports.setName = setName;
2893
- exports.sortMappedOperations = sortMappedOperations;
2894
- exports.sortOperations = sortOperations;
2895
- exports.undo = undo;
2896
- exports.updateDocument = updateDocument;
2897
- exports.updateHeader = updateHeader;
2898
- exports.validateOperations = validateOperations;
2899
- exports.verifyOperationSignature = verifyOperationSignature;
2900
- exports.zod = zod;
2901
- //# sourceMappingURL=creators-DJg3Kd1P.js.map