@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.11

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 (245) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +19 -0
  3. package/dist/Game/AnimationManager.d.ts +1 -1
  4. package/dist/Game/AnimationManager.js +18 -9
  5. package/dist/Game/AnimationManager.js.map +1 -1
  6. package/dist/Game/AnimationManager.spec.d.ts +1 -0
  7. package/dist/Game/Event.js.map +1 -1
  8. package/dist/Game/Map.d.ts +9 -1
  9. package/dist/Game/Map.js +63 -5
  10. package/dist/Game/Map.js.map +1 -1
  11. package/dist/Game/Object.d.ts +47 -15
  12. package/dist/Game/Object.js +82 -38
  13. package/dist/Game/Object.js.map +1 -1
  14. package/dist/Game/Player.js.map +1 -1
  15. package/dist/Game/ProjectileManager.d.ts +89 -0
  16. package/dist/Game/ProjectileManager.js +179 -0
  17. package/dist/Game/ProjectileManager.js.map +1 -0
  18. package/dist/Game/ProjectileManager.spec.d.ts +1 -0
  19. package/dist/Gui/Gui.d.ts +17 -4
  20. package/dist/Gui/Gui.js +78 -48
  21. package/dist/Gui/Gui.js.map +1 -1
  22. package/dist/Gui/Gui.spec.d.ts +1 -0
  23. package/dist/Gui/NotificationManager.js.map +1 -1
  24. package/dist/Resource.js +1 -1
  25. package/dist/Resource.js.map +1 -1
  26. package/dist/RpgClient.d.ts +110 -15
  27. package/dist/RpgClientEngine.d.ts +86 -10
  28. package/dist/RpgClientEngine.js +306 -49
  29. package/dist/RpgClientEngine.js.map +1 -1
  30. package/dist/Sound.js.map +1 -1
  31. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorate.js +1 -1
  32. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorateMetadata.js +1 -1
  33. package/dist/components/animations/animation.ce.js +4 -5
  34. package/dist/components/animations/animation.ce.js.map +1 -1
  35. package/dist/components/animations/hit.ce.js +19 -25
  36. package/dist/components/animations/hit.ce.js.map +1 -1
  37. package/dist/components/animations/index.js +4 -4
  38. package/dist/components/animations/index.js.map +1 -1
  39. package/dist/components/character.ce.js +422 -240
  40. package/dist/components/character.ce.js.map +1 -1
  41. package/dist/components/dynamics/bar.ce.js +97 -0
  42. package/dist/components/dynamics/bar.ce.js.map +1 -0
  43. package/dist/components/dynamics/image.ce.js +24 -0
  44. package/dist/components/dynamics/image.ce.js.map +1 -0
  45. package/dist/components/dynamics/parse-value.d.ts +3 -0
  46. package/dist/components/dynamics/parse-value.js +54 -35
  47. package/dist/components/dynamics/parse-value.js.map +1 -1
  48. package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
  49. package/dist/components/dynamics/shape-utils.d.ts +16 -0
  50. package/dist/components/dynamics/shape-utils.js +73 -0
  51. package/dist/components/dynamics/shape-utils.js.map +1 -0
  52. package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
  53. package/dist/components/dynamics/shape.ce.js +84 -0
  54. package/dist/components/dynamics/shape.ce.js.map +1 -0
  55. package/dist/components/dynamics/text.ce.js +34 -56
  56. package/dist/components/dynamics/text.ce.js.map +1 -1
  57. package/dist/components/gui/box.ce.js +6 -8
  58. package/dist/components/gui/box.ce.js.map +1 -1
  59. package/dist/components/gui/dialogbox/index.ce.js +56 -62
  60. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  61. package/dist/components/gui/gameover.ce.js +42 -65
  62. package/dist/components/gui/gameover.ce.js.map +1 -1
  63. package/dist/components/gui/hud/hud.ce.js +21 -30
  64. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  65. package/dist/components/gui/menu/equip-menu.ce.js +112 -165
  66. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  67. package/dist/components/gui/menu/exit-menu.ce.js +8 -6
  68. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  69. package/dist/components/gui/menu/items-menu.ce.js +52 -69
  70. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  71. package/dist/components/gui/menu/main-menu.ce.js +75 -92
  72. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  73. package/dist/components/gui/menu/options-menu.ce.js +5 -4
  74. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  75. package/dist/components/gui/menu/skills-menu.ce.js +12 -17
  76. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  77. package/dist/components/gui/mobile/index.js +2 -2
  78. package/dist/components/gui/mobile/index.js.map +1 -1
  79. package/dist/components/gui/mobile/mobile.ce.js +5 -4
  80. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  81. package/dist/components/gui/notification/notification.ce.js +22 -24
  82. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  83. package/dist/components/gui/save-load.ce.js +72 -249
  84. package/dist/components/gui/save-load.ce.js.map +1 -1
  85. package/dist/components/gui/shop/shop.ce.js +90 -127
  86. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  87. package/dist/components/gui/title-screen.ce.js +45 -70
  88. package/dist/components/gui/title-screen.ce.js.map +1 -1
  89. package/dist/components/index.d.ts +2 -1
  90. package/dist/components/index.js +1 -0
  91. package/dist/components/player-components-utils.d.ts +67 -0
  92. package/dist/components/player-components-utils.js +162 -0
  93. package/dist/components/player-components-utils.js.map +1 -0
  94. package/dist/components/player-components-utils.spec.d.ts +1 -0
  95. package/dist/components/player-components.ce.js +189 -0
  96. package/dist/components/player-components.ce.js.map +1 -0
  97. package/dist/components/prebuilt/hp-bar.ce.js +42 -44
  98. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  99. package/dist/components/prebuilt/light-halo.ce.js +36 -59
  100. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  101. package/dist/components/scenes/canvas.ce.js +165 -21
  102. package/dist/components/scenes/canvas.ce.js.map +1 -1
  103. package/dist/components/scenes/draw-map.ce.js +25 -32
  104. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  105. package/dist/components/scenes/event-layer.ce.js +9 -8
  106. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  107. package/dist/core/inject.js +1 -1
  108. package/dist/core/inject.js.map +1 -1
  109. package/dist/core/setup.js +1 -1
  110. package/dist/core/setup.js.map +1 -1
  111. package/dist/decorators/spritesheet.d.ts +1 -0
  112. package/dist/decorators/spritesheet.js +11 -0
  113. package/dist/decorators/spritesheet.js.map +1 -0
  114. package/dist/index.d.ts +4 -0
  115. package/dist/index.js +26 -21
  116. package/dist/module.js +15 -1
  117. package/dist/module.js.map +1 -1
  118. package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@3.0.1}/node_modules/@signe/di/dist/index.js +7 -117
  119. package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
  120. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
  121. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
  122. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
  123. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
  124. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
  125. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
  126. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
  127. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  128. package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@3.0.1}/node_modules/@signe/sync/dist/index.js +57 -141
  129. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +1 -0
  130. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
  131. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
  132. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +27 -27
  133. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
  134. package/dist/presets/animation.js.map +1 -1
  135. package/dist/presets/faceset.js.map +1 -1
  136. package/dist/presets/icon.js.map +1 -1
  137. package/dist/presets/index.js.map +1 -1
  138. package/dist/presets/lpc.js.map +1 -1
  139. package/dist/presets/rmspritesheet.js.map +1 -1
  140. package/dist/services/AbstractSocket.js.map +1 -1
  141. package/dist/services/actionInput.d.ts +12 -0
  142. package/dist/services/actionInput.js +27 -0
  143. package/dist/services/actionInput.js.map +1 -0
  144. package/dist/services/actionInput.spec.d.ts +1 -0
  145. package/dist/services/keyboardControls.js.map +1 -1
  146. package/dist/services/loadMap.d.ts +6 -0
  147. package/dist/services/loadMap.js +1 -1
  148. package/dist/services/loadMap.js.map +1 -1
  149. package/dist/services/mmorpg-connection.d.ts +5 -0
  150. package/dist/services/mmorpg-connection.js +50 -0
  151. package/dist/services/mmorpg-connection.js.map +1 -0
  152. package/dist/services/mmorpg-connection.spec.d.ts +1 -0
  153. package/dist/services/mmorpg.d.ts +10 -4
  154. package/dist/services/mmorpg.js +56 -33
  155. package/dist/services/mmorpg.js.map +1 -1
  156. package/dist/services/pointerContext.d.ts +11 -0
  157. package/dist/services/pointerContext.js +48 -0
  158. package/dist/services/pointerContext.js.map +1 -0
  159. package/dist/services/pointerContext.spec.d.ts +1 -0
  160. package/dist/services/save.js.map +1 -1
  161. package/dist/services/save.spec.d.ts +1 -0
  162. package/dist/services/standalone-message.d.ts +1 -0
  163. package/dist/services/standalone-message.js +9 -0
  164. package/dist/services/standalone-message.js.map +1 -0
  165. package/dist/services/standalone.js +4 -3
  166. package/dist/services/standalone.js.map +1 -1
  167. package/dist/services/standalone.spec.d.ts +1 -0
  168. package/dist/utils/getEntityProp.js +4 -3
  169. package/dist/utils/getEntityProp.js.map +1 -1
  170. package/dist/utils/getEntityProp.spec.d.ts +1 -0
  171. package/dist/utils/readPropValue.d.ts +2 -0
  172. package/dist/utils/readPropValue.js +13 -0
  173. package/dist/utils/readPropValue.js.map +1 -0
  174. package/package.json +13 -14
  175. package/src/Game/AnimationManager.spec.ts +30 -0
  176. package/src/Game/AnimationManager.ts +22 -10
  177. package/src/Game/Map.ts +91 -2
  178. package/src/Game/Object.ts +148 -69
  179. package/src/Game/ProjectileManager.spec.ts +338 -0
  180. package/src/Game/ProjectileManager.ts +324 -0
  181. package/src/Gui/Gui.spec.ts +273 -0
  182. package/src/Gui/Gui.ts +105 -50
  183. package/src/Resource.ts +1 -2
  184. package/src/RpgClient.ts +125 -17
  185. package/src/RpgClientEngine.ts +457 -87
  186. package/src/components/character.ce +441 -32
  187. package/src/components/dynamics/bar.ce +88 -0
  188. package/src/components/dynamics/image.ce +21 -0
  189. package/src/components/dynamics/parse-value.spec.ts +83 -0
  190. package/src/components/dynamics/parse-value.ts +111 -37
  191. package/src/components/dynamics/shape-utils.spec.ts +46 -0
  192. package/src/components/dynamics/shape-utils.ts +61 -0
  193. package/src/components/dynamics/shape.ce +90 -0
  194. package/src/components/dynamics/text.ce +35 -149
  195. package/src/components/gui/dialogbox/index.ce +18 -8
  196. package/src/components/gui/gameover.ce +2 -1
  197. package/src/components/gui/menu/equip-menu.ce +2 -1
  198. package/src/components/gui/menu/exit-menu.ce +2 -1
  199. package/src/components/gui/menu/items-menu.ce +3 -2
  200. package/src/components/gui/menu/main-menu.ce +2 -1
  201. package/src/components/gui/save-load.ce +2 -1
  202. package/src/components/gui/shop/shop.ce +3 -2
  203. package/src/components/gui/title-screen.ce +2 -1
  204. package/src/components/index.ts +2 -1
  205. package/src/components/player-components-utils.spec.ts +109 -0
  206. package/src/components/player-components-utils.ts +205 -0
  207. package/src/components/player-components.ce +222 -0
  208. package/src/components/prebuilt/hp-bar.ce +4 -3
  209. package/src/components/prebuilt/light-halo.ce +2 -2
  210. package/src/components/scenes/canvas.ce +175 -8
  211. package/src/components/scenes/draw-map.ce +18 -17
  212. package/src/components/scenes/event-layer.ce +1 -2
  213. package/src/core/setup.ts +2 -2
  214. package/src/decorators/spritesheet.ts +8 -0
  215. package/src/index.ts +4 -0
  216. package/src/module.ts +18 -1
  217. package/src/services/actionInput.spec.ts +101 -0
  218. package/src/services/actionInput.ts +53 -0
  219. package/src/services/loadMap.ts +2 -0
  220. package/src/services/mmorpg-connection.spec.ts +99 -0
  221. package/src/services/mmorpg-connection.ts +69 -0
  222. package/src/services/mmorpg.ts +68 -36
  223. package/src/services/pointerContext.spec.ts +36 -0
  224. package/src/services/pointerContext.ts +84 -0
  225. package/src/services/save.spec.ts +127 -0
  226. package/src/services/standalone-message.ts +7 -0
  227. package/src/services/standalone.spec.ts +34 -0
  228. package/src/services/standalone.ts +3 -2
  229. package/src/utils/getEntityProp.spec.ts +96 -0
  230. package/src/utils/getEntityProp.ts +4 -3
  231. package/src/utils/readPropValue.ts +16 -0
  232. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
  233. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +0 -457
  234. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +0 -1
  235. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
  236. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
  237. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
  238. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
  239. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
  240. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
  241. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
  242. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
  243. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
  244. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
  245. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
@@ -1,115 +1,24 @@
1
- import { __name } from "./chunk-7QVYU63E.js";
2
- import { isArraySubject, isComputed, isObjectSubject, isSignal } from "../../../../../@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js";
3
- //#region ../../node_modules/.pnpm/@signe+sync@2.9.0/node_modules/@signe/sync/dist/index.js
4
- function isFunction(val) {
5
- return {}.toString.call(val) === "[object Function]";
6
- }
7
- __name(isFunction, "isFunction");
1
+ import { isArraySubject, isComputed, isObjectSubject, isSignal } from "../../../../../@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js";
2
+ //#region ../../node_modules/.pnpm/@signe+sync@3.0.1/node_modules/@signe/sync/dist/index.js
8
3
  function isClass(obj) {
9
4
  return typeof obj === "function" && obj.prototype && obj.prototype.constructor === obj;
10
5
  }
11
- __name(isClass, "isClass");
12
- var isObject = /* @__PURE__ */ __name((item) => item && typeof item === "object" && !Array.isArray(item) && item !== null, "isObject");
6
+ var isObject = (item) => item && typeof item === "object" && !Array.isArray(item) && item !== null;
13
7
  function isInstanceOfClass(value) {
14
8
  if (value === null || typeof value !== "object" || value === void 0 || Array.isArray(value)) return false;
15
9
  return Object.getPrototypeOf(value) !== Object.prototype;
16
10
  }
17
- __name(isInstanceOfClass, "isInstanceOfClass");
18
- function generateShortUUID() {
19
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
20
- let uuid = "";
21
- for (let i = 0; i < 8; i++) {
22
- const randomIndex = Math.floor(Math.random() * 62);
23
- uuid += chars[randomIndex];
24
- }
25
- return uuid;
26
- }
27
- __name(generateShortUUID, "generateShortUUID");
28
11
  var DELETE_TOKEN = "$delete";
29
- var syncClass = /* @__PURE__ */ __name((instance, options = {}) => {
30
- const cacheSync = /* @__PURE__ */ new Map();
31
- const cachePersist = /* @__PURE__ */ new Map();
32
- instance.$valuesChanges = {
33
- set: /* @__PURE__ */ __name((path, value) => {
34
- cacheSync.set(path, value);
35
- options.onSync?.(cacheSync);
36
- }, "set"),
37
- setPersist: /* @__PURE__ */ __name((path, value) => {
38
- if (path == "") path = ".";
39
- cachePersist.set(path, value);
40
- options.onPersist?.(cachePersist);
41
- }, "setPersist"),
42
- has: /* @__PURE__ */ __name((path) => {
43
- return cacheSync.has(path);
44
- }, "has"),
45
- get: /* @__PURE__ */ __name((path) => {
46
- return cacheSync.get(path);
47
- }, "get")
48
- };
49
- createSyncClass(instance);
50
- }, "syncClass");
51
- function createStatesSnapshot(instance) {
52
- let persistObject = {};
53
- if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
54
- const signal = instance.$snapshot.get(key);
55
- const persist2 = signal.options.persist ?? true;
56
- let value = signal();
57
- if (isObject(value) || Array.isArray(value)) continue;
58
- if (persist2) persistObject[key] = value;
59
- }
60
- return persistObject;
61
- }
62
- __name(createStatesSnapshot, "createStatesSnapshot");
63
- var SNAPSHOT_SKIP = Symbol("snapshot-skip");
64
- var serializeSnapshotDeep = /* @__PURE__ */ __name((value, path, options, seen) => {
65
- if (isSignal(value)) return serializeSnapshotDeep(value(), path, options, seen);
66
- if (value instanceof Map) return SNAPSHOT_SKIP;
67
- if (options.filter && !options.filter(value, path)) return SNAPSHOT_SKIP;
68
- if (value instanceof Date) return options.dateToString ? options.dateToString(value) : value.toISOString();
69
- if (value && typeof value === "object") {
70
- if (seen.has(value)) return SNAPSHOT_SKIP;
71
- seen.add(value);
72
- if (Array.isArray(value)) {
73
- const result2 = [];
74
- value.forEach((item, index) => {
75
- const serialized = serializeSnapshotDeep(item, path ? `${path}.${index}` : String(index), options, seen);
76
- if (serialized !== SNAPSHOT_SKIP) result2.push(serialized);
77
- });
78
- return result2;
79
- }
80
- const result = {};
81
- const idKey = isInstanceOfClass(value) ? value.constructor?._propertyMetadata?.get("id") : void 0;
82
- const entries = Object.entries(value).filter(([key]) => isInstanceOfClass(value) ? key.startsWith("__") || (idKey ? key === idKey : false) : true);
83
- for (const [key, childValue] of entries) {
84
- const normalizedKey = key.startsWith("__") ? key.slice(2) : key;
85
- const serialized = serializeSnapshotDeep(childValue, path ? `${path}.${normalizedKey}` : normalizedKey, options, seen);
86
- if (serialized !== SNAPSHOT_SKIP) result[normalizedKey] = serialized;
87
- }
88
- return result;
89
- }
90
- return value;
91
- }, "serializeSnapshotDeep");
92
- function createStatesSnapshotDeep(instance, options = {}) {
93
- const persistObject = {};
94
- if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
95
- const signal = instance.$snapshot.get(key);
96
- if (!(signal.options.persist ?? true)) continue;
97
- const serialized = serializeSnapshotDeep(signal(), key, options, /* @__PURE__ */ new WeakSet());
98
- if (serialized !== SNAPSHOT_SKIP) persistObject[key] = serialized;
99
- }
100
- return persistObject;
101
- }
102
- __name(createStatesSnapshotDeep, "createStatesSnapshotDeep");
103
12
  function setMetadata(target, key, value) {
104
13
  const propId = target.constructor._propertyMetadata?.get(key);
105
14
  if (propId) if (isSignal(target[propId])) target[propId].set(value);
106
15
  else target[propId] = value;
107
16
  }
108
- __name(setMetadata, "setMetadata");
109
- var createSyncClass = /* @__PURE__ */ __name((currentClass, parentKey = null, parentClass = null, path = "") => {
17
+ var createSyncClass = (currentClass, parentKey = null, parentClass = null, path = "") => {
110
18
  currentClass.$path = path;
111
19
  if (parentClass) currentClass.$valuesChanges = parentClass.$valuesChanges;
112
20
  if (parentKey) setMetadata(currentClass, "id", parentKey);
21
+ applyDecoratedSignalMetadata(currentClass);
113
22
  if (currentClass.$snapshot) for (const key of currentClass.$snapshot.keys()) {
114
23
  const signal = currentClass.$snapshot.get(key);
115
24
  const syncToClient = signal.options?.syncToClient ?? true;
@@ -131,11 +40,23 @@ var createSyncClass = /* @__PURE__ */ __name((currentClass, parentKey = null, pa
131
40
  }
132
41
  });
133
42
  }
134
- }, "createSyncClass");
135
- var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance) => {
136
- const { syncToClient = true, persist: persist2 = true, transform } = options;
43
+ };
44
+ function applyDecoratedSignalMetadata(currentClass) {
45
+ const syncMetadata = currentClass.constructor?._syncMetadata;
46
+ if (!syncMetadata) return;
47
+ for (const [propertyKey, options] of syncMetadata) {
48
+ const signal = currentClass[propertyKey];
49
+ if (!isSignal(signal) || signal.options) continue;
50
+ currentClass[propertyKey] = type(signal, propertyKey, {
51
+ ...options,
52
+ skipInitialSync: true
53
+ }, currentClass);
54
+ }
55
+ }
56
+ var type = (_signal, path, options = {}, currentInstance) => {
57
+ const { syncToClient = true, persist: persist2 = true, transform, skipInitialSync = false } = options;
137
58
  let init = true;
138
- const handleObjectSubject = /* @__PURE__ */ __name((value, propPath) => {
59
+ const handleObjectSubject = (value, propPath) => {
139
60
  const newPath = `${propPath}${value.key ? `.${value.key}` : ""}`;
140
61
  if ([
141
62
  "add",
@@ -145,8 +66,8 @@ var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance)
145
66
  else if (value.type === "update" && (isObject(value.value) || Array.isArray(value.value))) createSyncClass(value.value, value.key, currentInstance, newPath);
146
67
  else savePath(newPath, value.value);
147
68
  else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
148
- }, "handleObjectSubject");
149
- const handleArraySubject = /* @__PURE__ */ __name((value, propPath) => {
69
+ };
70
+ const handleArraySubject = (value, propPath) => {
150
71
  if (value.type === "reset" && Array.isArray(value.items)) {
151
72
  value.items.forEach((item, index) => {
152
73
  const newPath2 = `${propPath}.${index}`;
@@ -161,18 +82,19 @@ var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance)
161
82
  else if (value.type === "update" && (isObject(firstItem) || Array.isArray(firstItem))) createSyncClass(firstItem, value.key, currentInstance, newPath);
162
83
  else savePath(newPath, firstItem);
163
84
  else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
164
- }, "handleArraySubject");
165
- const savePath = /* @__PURE__ */ __name((propPath, value) => {
85
+ };
86
+ const savePath = (propPath, value) => {
166
87
  const transformedValue = transform && value !== "$delete" ? transform(value) : value;
167
88
  if (syncToClient) currentInstance.$valuesChanges.set(propPath, transformedValue);
168
- if (persist2 && currentInstance.$path !== void 0) currentInstance.$valuesChanges.setPersist(transformedValue == "$delete" ? propPath : currentInstance.$path, transformedValue);
169
- }, "savePath");
170
- const setupSubscription = /* @__PURE__ */ __name((signal, signalPath) => {
89
+ if (persist2 && currentInstance.$path !== void 0) currentInstance.$valuesChanges.setPersist(propPath, transformedValue);
90
+ };
91
+ const setupSubscription = (signal, signalPath) => {
171
92
  if (!isSignal(signal)) return;
172
- if (syncToClient && currentInstance.$valuesChanges) {
93
+ if (syncToClient && !skipInitialSync && currentInstance.$valuesChanges) {
173
94
  const initialValue = signal();
174
95
  const transformedInitialValue = transform ? transform(initialValue) : initialValue;
175
- currentInstance.$valuesChanges.set(signalPath, transformedInitialValue);
96
+ const initialPath = currentInstance.$path !== void 0 ? `${currentInstance.$path ? `${currentInstance.$path}.` : ""}${signalPath}` : signalPath;
97
+ currentInstance.$valuesChanges.set(initialPath, transformedInitialValue);
176
98
  }
177
99
  signal.options = options;
178
100
  signal.observable.subscribe((value) => {
@@ -187,7 +109,7 @@ var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance)
187
109
  });
188
110
  if (!currentInstance.$snapshot) currentInstance.$snapshot = /* @__PURE__ */ new Map();
189
111
  currentInstance.$snapshot.set(path, signal);
190
- }, "setupSubscription");
112
+ };
191
113
  if (!isSignal(_signal)) {
192
114
  if (_signal && typeof _signal === "object" && !Array.isArray(_signal)) {
193
115
  for (const key in _signal) if (Object.prototype.hasOwnProperty.call(_signal, key)) {
@@ -203,8 +125,8 @@ var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance)
203
125
  setupSubscription(_signal, path);
204
126
  init = false;
205
127
  return _signal;
206
- }, "type");
207
- function sync(options) {
128
+ };
129
+ function normalizeSyncOptions(options) {
208
130
  let classType;
209
131
  let persist2 = true;
210
132
  let syncToClient = true;
@@ -216,33 +138,42 @@ function sync(options) {
216
138
  if (options.hasOwnProperty("syncToClient")) syncToClient = options.syncToClient;
217
139
  if (options.hasOwnProperty("transform")) transform = options.transform;
218
140
  }
141
+ return {
142
+ classType,
143
+ persist: persist2,
144
+ syncToClient,
145
+ transform
146
+ };
147
+ }
148
+ function setSyncMetadata(target, propertyKey, options) {
149
+ if (!target.constructor._syncMetadata) target.constructor._syncMetadata = /* @__PURE__ */ new Map();
150
+ target.constructor._syncMetadata.set(propertyKey, options);
151
+ }
152
+ function sync(options) {
153
+ const normalizedOptions = normalizeSyncOptions(options);
219
154
  return function(target, propertyKey) {
155
+ setSyncMetadata(target, propertyKey, normalizedOptions);
220
156
  const privatePropertyKey = `__${propertyKey}`;
157
+ const getter = function() {
158
+ return this[privatePropertyKey];
159
+ };
160
+ const setter = function(newVal) {
161
+ this[privatePropertyKey] = type(newVal, propertyKey, normalizedOptions, this);
162
+ };
221
163
  Object.defineProperty(target, propertyKey, {
222
- get: /* @__PURE__ */ __name(function() {
223
- return this[privatePropertyKey];
224
- }, "getter"),
225
- set: /* @__PURE__ */ __name(function(newVal) {
226
- this[privatePropertyKey] = type(newVal, propertyKey, {
227
- classType,
228
- persist: persist2,
229
- syncToClient,
230
- transform
231
- }, this);
232
- }, "setter"),
164
+ get: getter,
165
+ set: setter,
233
166
  enumerable: true,
234
167
  configurable: true
235
168
  });
236
169
  };
237
170
  }
238
- __name(sync, "sync");
239
171
  function id() {
240
172
  return function(target, propertyKey) {
241
173
  if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
242
174
  target.constructor._propertyMetadata.set("id", propertyKey);
243
175
  };
244
176
  }
245
- __name(id, "id");
246
177
  function users(options) {
247
178
  return function(target, propertyKey) {
248
179
  if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
@@ -250,31 +181,19 @@ function users(options) {
250
181
  sync(options)(target, propertyKey);
251
182
  };
252
183
  }
253
- __name(users, "users");
254
184
  function persist() {
255
185
  return sync({
256
186
  persist: true,
257
187
  syncToClient: false
258
188
  });
259
189
  }
260
- __name(persist, "persist");
261
- function connected() {
262
- return function(target, propertyKey) {
263
- if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
264
- target.constructor._propertyMetadata.set("connected", propertyKey);
265
- sync({ persist: false })(target, propertyKey);
266
- };
267
- }
268
- __name(connected, "connected");
269
190
  function load(rootInstance, values, valueIsObject) {
270
191
  if (valueIsObject) loadFromObject(rootInstance, values);
271
192
  else loadFromPaths(rootInstance, values);
272
193
  }
273
- __name(load, "load");
274
194
  function loadFromPaths(rootInstance, values) {
275
195
  for (const [path, value] of Object.entries(values)) loadValue(rootInstance, path.split("."), value);
276
196
  }
277
- __name(loadFromPaths, "loadFromPaths");
278
197
  function loadFromObject(rootInstance, values, currentPath = "") {
279
198
  for (let key in values) {
280
199
  const value = values[key];
@@ -283,7 +202,6 @@ function loadFromObject(rootInstance, values, currentPath = "") {
283
202
  else loadValue(rootInstance, newPath.split("."), value);
284
203
  }
285
204
  }
286
- __name(loadFromObject, "loadFromObject");
287
205
  function loadValue(rootInstance, parts, value) {
288
206
  let current = rootInstance;
289
207
  for (let i = 0; i < parts.length; i++) {
@@ -307,7 +225,6 @@ function loadValue(rootInstance, parts, value) {
307
225
  }
308
226
  }
309
227
  }
310
- __name(loadValue, "loadValue");
311
228
  function getByPath(root, path) {
312
229
  const parts = path.split(".");
313
230
  let current = root;
@@ -318,8 +235,7 @@ function getByPath(root, path) {
318
235
  }
319
236
  return current;
320
237
  }
321
- __name(getByPath, "getByPath");
322
238
  //#endregion
323
- export { DELETE_TOKEN, createStatesSnapshot, createStatesSnapshotDeep, generateShortUUID, getByPath, id, load, persist, sync, syncClass, users };
239
+ export { id, load, persist, sync, users };
324
240
 
325
241
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["isSignal2"],"sources":["../../../../../../../../../../node_modules/.pnpm/@signe+sync@3.0.1/node_modules/@signe/sync/dist/index.js"],"sourcesContent":["// src/core.ts\nimport {\n isArraySubject,\n isObjectSubject,\n isSignal,\n isComputed\n} from \"@signe/reactive\";\n\n// src/utils.ts\nfunction isFunction(val) {\n return {}.toString.call(val) === \"[object Function]\";\n}\nfunction isClass(obj) {\n return typeof obj === \"function\" && obj.prototype && obj.prototype.constructor === obj;\n}\nvar isObject = (item) => item && typeof item === \"object\" && !Array.isArray(item) && item !== null;\nfunction isInstanceOfClass(value) {\n if (value === null || typeof value !== \"object\" || value === void 0 || Array.isArray(value)) {\n return false;\n }\n return Object.getPrototypeOf(value) !== Object.prototype;\n}\nfunction generateShortUUID() {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n let uuid = \"\";\n for (let i = 0; i < 8; i++) {\n const randomIndex = Math.floor(Math.random() * chars.length);\n uuid += chars[randomIndex];\n }\n return uuid;\n}\n\n// src/core.ts\nvar DELETE_TOKEN = \"$delete\";\nvar syncClass = (instance, options = {}) => {\n const cacheSync = /* @__PURE__ */ new Map();\n const cachePersist = /* @__PURE__ */ new Map();\n instance.$valuesChanges = {\n set: (path, value) => {\n cacheSync.set(path, value);\n options.onSync?.(cacheSync);\n },\n setPersist: (path, value) => {\n if (path == \"\") path = \".\";\n cachePersist.set(path, value);\n options.onPersist?.(cachePersist);\n },\n has: (path) => {\n return cacheSync.has(path);\n },\n get: (path) => {\n return cacheSync.get(path);\n }\n };\n createSyncClass(instance);\n};\nfunction createStatesSnapshot(instance) {\n let persistObject = {};\n if (instance?.$snapshot) {\n for (const key of instance.$snapshot.keys()) {\n const signal = instance.$snapshot.get(key);\n const persist2 = signal.options.persist ?? true;\n let value = signal();\n if (isObject(value) || Array.isArray(value)) {\n continue;\n }\n if (persist2) {\n persistObject[key] = value;\n }\n }\n }\n return persistObject;\n}\nvar SNAPSHOT_SKIP = Symbol(\"snapshot-skip\");\nvar serializeSnapshotDeep = (value, path, options, seen) => {\n if (isSignal(value)) {\n return serializeSnapshotDeep(value(), path, options, seen);\n }\n if (value instanceof Map) {\n return SNAPSHOT_SKIP;\n }\n if (options.filter && !options.filter(value, path)) {\n return SNAPSHOT_SKIP;\n }\n if (value instanceof Date) {\n return options.dateToString ? options.dateToString(value) : value.toISOString();\n }\n if (value && typeof value === \"object\") {\n if (seen.has(value)) {\n return SNAPSHOT_SKIP;\n }\n seen.add(value);\n if (Array.isArray(value)) {\n const result2 = [];\n value.forEach((item, index) => {\n const itemPath = path ? `${path}.${index}` : String(index);\n const serialized = serializeSnapshotDeep(item, itemPath, options, seen);\n if (serialized !== SNAPSHOT_SKIP) {\n result2.push(serialized);\n }\n });\n return result2;\n }\n const result = {};\n const idKey = isInstanceOfClass(value) ? value.constructor?._propertyMetadata?.get(\"id\") : void 0;\n const entries = Object.entries(value).filter(\n ([key]) => isInstanceOfClass(value) ? key.startsWith(\"__\") || (idKey ? key === idKey : false) : true\n );\n for (const [key, childValue] of entries) {\n const normalizedKey = key.startsWith(\"__\") ? key.slice(2) : key;\n const childPath = path ? `${path}.${normalizedKey}` : normalizedKey;\n const serialized = serializeSnapshotDeep(childValue, childPath, options, seen);\n if (serialized !== SNAPSHOT_SKIP) {\n result[normalizedKey] = serialized;\n }\n }\n return result;\n }\n return value;\n};\nfunction createStatesSnapshotDeep(instance, options = {}) {\n const persistObject = {};\n if (instance?.$snapshot) {\n for (const key of instance.$snapshot.keys()) {\n const signal = instance.$snapshot.get(key);\n const persist2 = signal.options.persist ?? true;\n if (!persist2) {\n continue;\n }\n const value = signal();\n const serialized = serializeSnapshotDeep(\n value,\n key,\n options,\n /* @__PURE__ */ new WeakSet()\n );\n if (serialized !== SNAPSHOT_SKIP) {\n persistObject[key] = serialized;\n }\n }\n }\n return persistObject;\n}\nfunction setMetadata(target, key, value) {\n const meta = target.constructor._propertyMetadata;\n const propId = meta?.get(key);\n if (propId) {\n if (isSignal(target[propId])) {\n target[propId].set(value);\n } else {\n target[propId] = value;\n }\n }\n}\nvar createSyncClass = (currentClass, parentKey = null, parentClass = null, path = \"\") => {\n currentClass.$path = path;\n if (parentClass) {\n currentClass.$valuesChanges = parentClass.$valuesChanges;\n }\n if (parentKey) {\n setMetadata(currentClass, \"id\", parentKey);\n }\n applyDecoratedSignalMetadata(currentClass);\n if (currentClass.$snapshot) {\n for (const key of currentClass.$snapshot.keys()) {\n const signal = currentClass.$snapshot.get(key);\n const syncToClient = signal.options?.syncToClient ?? true;\n const persist2 = signal.options?.persist ?? true;\n const transform = signal.options?.transform;\n let signalValue = signal();\n if (transform) {\n signalValue = transform(signalValue);\n }\n if (isObject(signalValue) || Array.isArray(signalValue)) {\n signalValue = { ...signalValue };\n }\n const transformedValue = signalValue;\n const newPath = (path ? path + \".\" : \"\") + key;\n if (syncToClient) {\n currentClass.$valuesChanges.set(newPath, transformedValue);\n }\n if (persist2) {\n if (parentClass)\n currentClass.$valuesChanges.setPersist(path, transformedValue);\n }\n if (isComputed(signal)) {\n signal.observable.subscribe((newValue) => {\n if (syncToClient) {\n const transformedNewValue = transform ? transform(newValue) : newValue;\n currentClass.$valuesChanges.set(newPath, transformedNewValue);\n }\n });\n }\n }\n }\n};\nfunction applyDecoratedSignalMetadata(currentClass) {\n const syncMetadata = currentClass.constructor?._syncMetadata;\n if (!syncMetadata) {\n return;\n }\n for (const [propertyKey, options] of syncMetadata) {\n const signal = currentClass[propertyKey];\n if (!isSignal(signal) || signal.options) {\n continue;\n }\n currentClass[propertyKey] = type(\n signal,\n propertyKey,\n { ...options, skipInitialSync: true },\n currentClass\n );\n }\n}\nvar type = (_signal, path, options = {}, currentInstance) => {\n const { syncToClient = true, persist: persist2 = true, transform, skipInitialSync = false } = options;\n let init = true;\n const handleObjectSubject = (value, propPath) => {\n const newPath = `${propPath}${value.key ? `.${value.key}` : \"\"}`;\n if ([\"add\", \"reset\", \"update\"].includes(value.type)) {\n if (isInstanceOfClass(value.value)) {\n createSyncClass(value.value, value.key, currentInstance, newPath);\n } else if (value.type === \"update\" && (isObject(value.value) || Array.isArray(value.value))) {\n createSyncClass(value.value, value.key, currentInstance, newPath);\n } else {\n savePath(newPath, value.value);\n }\n } else if (value.type === \"remove\") {\n savePath(newPath, DELETE_TOKEN);\n }\n };\n const handleArraySubject = (value, propPath) => {\n if (value.type === \"reset\" && Array.isArray(value.items)) {\n value.items.forEach((item, index) => {\n const newPath2 = `${propPath}.${index}`;\n if (isInstanceOfClass(item)) {\n createSyncClass(item, value.key, currentInstance, newPath2);\n } else {\n savePath(newPath2, item);\n }\n });\n return;\n }\n const newPath = `${propPath}.${value.index}`;\n const firstItem = value.items?.[0];\n if ([\"add\", \"update\"].includes(value.type) && firstItem !== void 0) {\n if (isInstanceOfClass(firstItem)) {\n createSyncClass(firstItem, value.key, currentInstance, newPath);\n } else if (value.type === \"update\" && (isObject(firstItem) || Array.isArray(firstItem))) {\n createSyncClass(firstItem, value.key, currentInstance, newPath);\n } else {\n savePath(newPath, firstItem);\n }\n } else if (value.type === \"remove\") {\n savePath(newPath, DELETE_TOKEN);\n }\n };\n const savePath = (propPath, value) => {\n const transformedValue = transform && value !== DELETE_TOKEN ? transform(value) : value;\n if (syncToClient) {\n currentInstance.$valuesChanges.set(propPath, transformedValue);\n }\n if (persist2 && currentInstance.$path !== void 0) {\n currentInstance.$valuesChanges.setPersist(\n propPath,\n transformedValue\n );\n }\n };\n const setupSubscription = (signal, signalPath) => {\n if (!isSignal(signal)) return;\n if (syncToClient && !skipInitialSync && currentInstance.$valuesChanges) {\n const initialValue = signal();\n const transformedInitialValue = transform ? transform(initialValue) : initialValue;\n const initialPath = currentInstance.$path !== void 0 ? `${currentInstance.$path ? `${currentInstance.$path}.` : \"\"}${signalPath}` : signalPath;\n currentInstance.$valuesChanges.set(initialPath, transformedInitialValue);\n }\n signal.options = options;\n signal.observable.subscribe((value) => {\n if (init) return;\n if (currentInstance.$path !== void 0) {\n const fullPath = `${currentInstance.$path ? currentInstance.$path + \".\" : \"\"}${signalPath}`;\n if (isComputed(signal)) {\n savePath(fullPath, value);\n } else if (isObjectSubject(signal._subject)) {\n handleObjectSubject(value, fullPath);\n } else if (isArraySubject(signal._subject)) {\n handleArraySubject(value, fullPath);\n } else {\n savePath(fullPath, value);\n }\n }\n });\n if (!currentInstance.$snapshot) {\n currentInstance.$snapshot = /* @__PURE__ */ new Map();\n }\n currentInstance.$snapshot.set(path, signal);\n };\n if (!isSignal(_signal)) {\n if (_signal && typeof _signal === \"object\" && !Array.isArray(_signal)) {\n for (const key in _signal) {\n if (Object.prototype.hasOwnProperty.call(_signal, key)) {\n const value = _signal[key];\n const propertyPath = `${path}.${key}`;\n if (isSignal(value)) {\n setupSubscription(value, propertyPath);\n } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n type(value, propertyPath, options, currentInstance);\n }\n }\n }\n init = false;\n }\n return _signal;\n }\n setupSubscription(_signal, path);\n init = false;\n return _signal;\n};\n\n// src/decorators.ts\nfunction normalizeSyncOptions(options) {\n let classType;\n let persist2 = true;\n let syncToClient = true;\n let transform;\n if (typeof options === \"function\") {\n classType = options;\n } else if (typeof options === \"object\") {\n classType = options.classType;\n if (options.hasOwnProperty(\"persist\")) {\n persist2 = options.persist;\n }\n if (options.hasOwnProperty(\"syncToClient\")) {\n syncToClient = options.syncToClient;\n }\n if (options.hasOwnProperty(\"transform\")) {\n transform = options.transform;\n }\n }\n return { classType, persist: persist2, syncToClient, transform };\n}\nfunction setSyncMetadata(target, propertyKey, options) {\n if (!target.constructor._syncMetadata) {\n target.constructor._syncMetadata = /* @__PURE__ */ new Map();\n }\n target.constructor._syncMetadata.set(propertyKey, options);\n}\nfunction sync(options) {\n const normalizedOptions = normalizeSyncOptions(options);\n return function(target, propertyKey) {\n setSyncMetadata(target, propertyKey, normalizedOptions);\n const privatePropertyKey = `__${propertyKey}`;\n const getter = function() {\n return this[privatePropertyKey];\n };\n const setter = function(newVal) {\n this[privatePropertyKey] = type(\n newVal,\n propertyKey,\n normalizedOptions,\n this\n );\n };\n Object.defineProperty(target, propertyKey, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true\n });\n };\n}\nfunction id() {\n return function(target, propertyKey) {\n if (!target.constructor._propertyMetadata) {\n target.constructor._propertyMetadata = /* @__PURE__ */ new Map();\n }\n target.constructor._propertyMetadata.set(\"id\", propertyKey);\n };\n}\nfunction users(options) {\n return function(target, propertyKey) {\n if (!target.constructor._propertyMetadata) {\n target.constructor._propertyMetadata = /* @__PURE__ */ new Map();\n }\n target.constructor._propertyMetadata.set(\"users\", propertyKey);\n sync(options)(target, propertyKey);\n };\n}\nfunction persist() {\n return sync({\n persist: true,\n syncToClient: false\n });\n}\nfunction connected() {\n return function(target, propertyKey) {\n if (!target.constructor._propertyMetadata) {\n target.constructor._propertyMetadata = /* @__PURE__ */ new Map();\n }\n target.constructor._propertyMetadata.set(\"connected\", propertyKey);\n sync({\n persist: false\n })(target, propertyKey);\n };\n}\n\n// src/load.ts\nimport { isSignal as isSignal2 } from \"@signe/reactive\";\nfunction load(rootInstance, values, valueIsObject) {\n if (valueIsObject) {\n loadFromObject(rootInstance, values);\n } else {\n loadFromPaths(rootInstance, values);\n }\n}\nfunction loadFromPaths(rootInstance, values) {\n for (const [path, value] of Object.entries(values)) {\n const parts = path.split(\".\");\n loadValue(rootInstance, parts, value);\n }\n}\nfunction loadFromObject(rootInstance, values, currentPath = \"\") {\n for (let key in values) {\n const value = values[key];\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n if (typeof value === \"object\" && !Array.isArray(value) && value !== null) {\n loadFromObject(rootInstance, value, newPath);\n } else {\n const parts = newPath.split(\".\");\n loadValue(rootInstance, parts, value);\n }\n }\n}\nfunction loadValue(rootInstance, parts, value) {\n let current = rootInstance;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if (i === parts.length - 1) {\n if (value == DELETE_TOKEN) {\n if (isSignal2(current)) {\n current = current();\n }\n Reflect.deleteProperty(current, part);\n } else if (current[part]?._subject) {\n current[part].set(value);\n } else if (isSignal2(current) && Array.isArray(current()) && !isNaN(Number(part))) {\n current()[Number(part)] = value;\n } else {\n current[part] = value;\n }\n } else {\n if (isSignal2(current)) {\n current = current();\n }\n const currentValue = current[part];\n if (currentValue === void 0) {\n const parentInstance = getByPath(\n rootInstance,\n parts.slice(0, i).join(\".\")\n );\n const classType = parentInstance?.options?.classType;\n if (classType) {\n current[part] = !isClass(classType) ? classType(part) : new classType();\n setMetadata(current[part], \"id\", part);\n } else {\n current[part] = {};\n }\n }\n current = current[part];\n }\n }\n}\nfunction getByPath(root, path) {\n const parts = path.split(\".\");\n let current = root;\n for (const part of parts) {\n if (isSignal2(current)) {\n current = current();\n }\n if (current[part]) {\n current = current[part];\n } else {\n return void 0;\n }\n }\n return current;\n}\nexport {\n DELETE_TOKEN,\n connected,\n createStatesSnapshot,\n createStatesSnapshotDeep,\n createSyncClass,\n generateShortUUID,\n getByPath,\n id,\n isClass,\n isFunction,\n isInstanceOfClass,\n isObject,\n load,\n normalizeSyncOptions,\n persist,\n setMetadata,\n sync,\n syncClass,\n type,\n users\n};\n//# sourceMappingURL=index.js.map"],"x_google_ignoreList":[0],"mappings":";;AAYA,SAAS,QAAQ,KAAK;CACpB,OAAO,OAAO,QAAQ,cAAc,IAAI,aAAa,IAAI,UAAU,gBAAgB;AACrF;AACA,IAAI,YAAY,SAAS,QAAQ,OAAO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U,OAAO,GACnB,UAAU,QAAQ;EAEpB,IAAI,QAAQ,OACV,UAAU,QAAQ;OAElB;CAEJ;CACA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-HAC622V3.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.mjs"],"sourcesContent":["import { ReconnectingWebSocket } from \"./chunk-S74YV6PU.mjs\";\n\n// src/index.ts\nvar valueIsNotNil = (keyValuePair) =>\n keyValuePair[1] !== null && keyValuePair[1] !== void 0;\nfunction generateUUID() {\n if (typeof crypto !== \"undefined\" && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n let d = /* @__PURE__ */ new Date().getTime();\n let d2 =\n (typeof performance !== \"undefined\" &&\n performance.now &&\n performance.now() * 1e3) ||\n 0;\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function (c) {\n let r = Math.random() * 16;\n if (d > 0) {\n r = (d + r) % 16 | 0;\n d = Math.floor(d / 16);\n } else {\n r = (d2 + r) % 16 | 0;\n d2 = Math.floor(d2 / 16);\n }\n return (c === \"x\" ? r : (r & 3) | 8).toString(16);\n });\n}\nfunction getPartyInfo(partySocketOptions, defaultProtocol, defaultParams = {}) {\n const {\n host: rawHost,\n path: rawPath,\n protocol: rawProtocol,\n room,\n party,\n basePath,\n prefix,\n query\n } = partySocketOptions;\n let host = rawHost.replace(/^(http|https|ws|wss):\\/\\//, \"\");\n if (host.endsWith(\"/\")) {\n host = host.slice(0, -1);\n }\n if (rawPath == null ? void 0 : rawPath.startsWith(\"/\")) {\n throw new Error(\"path must not start with a slash\");\n }\n const name = party ?? \"main\";\n const path = rawPath ? `/${rawPath}` : \"\";\n const protocol =\n rawProtocol ||\n (host.startsWith(\"localhost:\") ||\n host.startsWith(\"127.0.0.1:\") ||\n host.startsWith(\"192.168.\") ||\n host.startsWith(\"10.\") ||\n (host.startsWith(\"172.\") &&\n host.split(\".\")[1] >= \"16\" &&\n host.split(\".\")[1] <= \"31\") ||\n host.startsWith(\"[::ffff:7f00:1]:\")\n ? // http / ws\n defaultProtocol\n : // https / wss\n `${defaultProtocol}s`);\n const baseUrl = `${protocol}://${host}/${basePath || `${prefix || \"parties\"}/${name}/${room}`}${path}`;\n const makeUrl = (query2 = {}) =>\n `${baseUrl}?${new URLSearchParams([\n ...Object.entries(defaultParams),\n ...Object.entries(query2).filter(valueIsNotNil)\n ])}`;\n const urlProvider =\n typeof query === \"function\"\n ? async () => makeUrl(await query())\n : makeUrl(query);\n return {\n host,\n path,\n room,\n name,\n protocol,\n partyUrl: baseUrl,\n urlProvider\n };\n}\nvar PartySocket = class extends ReconnectingWebSocket {\n constructor(partySocketOptions) {\n const wsOptions = getWSOptions(partySocketOptions);\n super(wsOptions.urlProvider, wsOptions.protocols, wsOptions.socketOptions);\n this.partySocketOptions = partySocketOptions;\n this.setWSProperties(wsOptions);\n }\n _pk;\n _pkurl;\n name;\n room;\n host;\n path;\n updateProperties(partySocketOptions) {\n const wsOptions = getWSOptions({\n ...this.partySocketOptions,\n ...partySocketOptions,\n host: partySocketOptions.host ?? this.host,\n room: partySocketOptions.room ?? this.room,\n path: partySocketOptions.path ?? this.path\n });\n this._url = wsOptions.urlProvider;\n this._protocols = wsOptions.protocols;\n this._options = wsOptions.socketOptions;\n this.setWSProperties(wsOptions);\n }\n setWSProperties(wsOptions) {\n const { _pk, _pkurl, name, room, host, path } = wsOptions;\n this._pk = _pk;\n this._pkurl = _pkurl;\n this.name = name;\n this.room = room;\n this.host = host;\n this.path = path;\n }\n reconnect(code, reason) {\n if (!this.room || !this.host) {\n throw new Error(\n \"The room and host must be set before connecting, use `updateProperties` method to set them or pass them to the constructor.\"\n );\n }\n super.reconnect(code, reason);\n }\n get id() {\n return this._pk;\n }\n /**\n * Exposes the static PartyKit room URL without applying query parameters.\n * To access the currently connected WebSocket url, use PartySocket#url.\n */\n get roomUrl() {\n return this._pkurl;\n }\n // a `fetch` method that uses (almost) the same options as `PartySocket`\n static async fetch(options, init) {\n const party = getPartyInfo(options, \"http\");\n const url =\n typeof party.urlProvider === \"string\"\n ? party.urlProvider\n : await party.urlProvider();\n const doFetch = options.fetch ?? fetch;\n return doFetch(url, init);\n }\n};\nfunction getWSOptions(partySocketOptions) {\n const {\n id,\n host: _host,\n path: _path,\n party: _party,\n room: _room,\n protocol: _protocol,\n query: _query,\n protocols,\n ...socketOptions\n } = partySocketOptions;\n const _pk = id || generateUUID();\n const party = getPartyInfo(partySocketOptions, \"ws\", { _pk });\n return {\n _pk,\n _pkurl: party.partyUrl,\n name: party.name,\n room: party.room,\n host: party.host,\n path: party.path,\n protocols,\n socketOptions,\n urlProvider: party.urlProvider\n };\n}\n\nexport { PartySocket };\n//# sourceMappingURL=chunk-HAC622V3.mjs.map\n"],"x_google_ignoreList":[0],"mappings":";;AAGA,IAAI,iBAAiB,iBACnB,aAAa,OAAO,QAAQ,aAAa,OAAO,KAAK;AACvD,SAAS,eAAe;AACtB,KAAI,OAAO,WAAW,eAAe,OAAO,WAC1C,QAAO,OAAO,YAAY;CAE5B,IAAI,IAAoB,iCAAA,IAAI,MAAM,EAAC,SAAS;CAC5C,IAAI,KACD,OAAO,gBAAgB,eACtB,YAAY,OACZ,YAAY,KAAK,GAAG,OACtB;AACF,QAAO,uCAAuC,QAAQ,SAAS,SAAU,GAAG;EAC1E,IAAI,IAAI,KAAK,QAAQ,GAAG;AACxB,MAAI,IAAI,GAAG;AACT,QAAK,IAAI,KAAK,KAAK;AACnB,OAAI,KAAK,MAAM,IAAI,GAAG;SACjB;AACL,QAAK,KAAK,KAAK,KAAK;AACpB,QAAK,KAAK,MAAM,KAAK,GAAG;;AAE1B,UAAQ,MAAM,MAAM,IAAK,IAAI,IAAK,GAAG,SAAS,GAAG;GACjD;;AAEJ,SAAS,aAAa,oBAAoB,iBAAiB,gBAAgB,EAAE,EAAE;CAC7E,MAAM,EACJ,MAAM,SACN,MAAM,SACN,UAAU,aAC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../../node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.mjs"],"sourcesContent":["import { ReconnectingWebSocket } from \"./chunk-S74YV6PU.mjs\";\n\n// src/index.ts\nvar valueIsNotNil = (keyValuePair) =>\n keyValuePair[1] !== null && keyValuePair[1] !== void 0;\nfunction generateUUID() {\n if (typeof crypto !== \"undefined\" && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n let d = /* @__PURE__ */ new Date().getTime();\n let d2 =\n (typeof performance !== \"undefined\" &&\n performance.now &&\n performance.now() * 1e3) ||\n 0;\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function (c) {\n let r = Math.random() * 16;\n if (d > 0) {\n r = (d + r) % 16 | 0;\n d = Math.floor(d / 16);\n } else {\n r = (d2 + r) % 16 | 0;\n d2 = Math.floor(d2 / 16);\n }\n return (c === \"x\" ? r : (r & 3) | 8).toString(16);\n });\n}\nfunction getPartyInfo(partySocketOptions, defaultProtocol, defaultParams = {}) {\n const {\n host: rawHost,\n path: rawPath,\n protocol: rawProtocol,\n room,\n party,\n basePath,\n prefix,\n query\n } = partySocketOptions;\n let host = rawHost.replace(/^(http|https|ws|wss):\\/\\//, \"\");\n if (host.endsWith(\"/\")) {\n host = host.slice(0, -1);\n }\n if (rawPath == null ? void 0 : rawPath.startsWith(\"/\")) {\n throw new Error(\"path must not start with a slash\");\n }\n const name = party ?? \"main\";\n const path = rawPath ? `/${rawPath}` : \"\";\n const protocol =\n rawProtocol ||\n (host.startsWith(\"localhost:\") ||\n host.startsWith(\"127.0.0.1:\") ||\n host.startsWith(\"192.168.\") ||\n host.startsWith(\"10.\") ||\n (host.startsWith(\"172.\") &&\n host.split(\".\")[1] >= \"16\" &&\n host.split(\".\")[1] <= \"31\") ||\n host.startsWith(\"[::ffff:7f00:1]:\")\n ? // http / ws\n defaultProtocol\n : // https / wss\n `${defaultProtocol}s`);\n const baseUrl = `${protocol}://${host}/${basePath || `${prefix || \"parties\"}/${name}/${room}`}${path}`;\n const makeUrl = (query2 = {}) =>\n `${baseUrl}?${new URLSearchParams([\n ...Object.entries(defaultParams),\n ...Object.entries(query2).filter(valueIsNotNil)\n ])}`;\n const urlProvider =\n typeof query === \"function\"\n ? async () => makeUrl(await query())\n : makeUrl(query);\n return {\n host,\n path,\n room,\n name,\n protocol,\n partyUrl: baseUrl,\n urlProvider\n };\n}\nvar PartySocket = class extends ReconnectingWebSocket {\n constructor(partySocketOptions) {\n const wsOptions = getWSOptions(partySocketOptions);\n super(wsOptions.urlProvider, wsOptions.protocols, wsOptions.socketOptions);\n this.partySocketOptions = partySocketOptions;\n this.setWSProperties(wsOptions);\n }\n _pk;\n _pkurl;\n name;\n room;\n host;\n path;\n updateProperties(partySocketOptions) {\n const wsOptions = getWSOptions({\n ...this.partySocketOptions,\n ...partySocketOptions,\n host: partySocketOptions.host ?? this.host,\n room: partySocketOptions.room ?? this.room,\n path: partySocketOptions.path ?? this.path\n });\n this._url = wsOptions.urlProvider;\n this._protocols = wsOptions.protocols;\n this._options = wsOptions.socketOptions;\n this.setWSProperties(wsOptions);\n }\n setWSProperties(wsOptions) {\n const { _pk, _pkurl, name, room, host, path } = wsOptions;\n this._pk = _pk;\n this._pkurl = _pkurl;\n this.name = name;\n this.room = room;\n this.host = host;\n this.path = path;\n }\n reconnect(code, reason) {\n if (!this.room || !this.host) {\n throw new Error(\n \"The room and host must be set before connecting, use `updateProperties` method to set them or pass them to the constructor.\"\n );\n }\n super.reconnect(code, reason);\n }\n get id() {\n return this._pk;\n }\n /**\n * Exposes the static PartyKit room URL without applying query parameters.\n * To access the currently connected WebSocket url, use PartySocket#url.\n */\n get roomUrl() {\n return this._pkurl;\n }\n // a `fetch` method that uses (almost) the same options as `PartySocket`\n static async fetch(options, init) {\n const party = getPartyInfo(options, \"http\");\n const url =\n typeof party.urlProvider === \"string\"\n ? party.urlProvider\n : await party.urlProvider();\n const doFetch = options.fetch ?? fetch;\n return doFetch(url, init);\n }\n};\nfunction getWSOptions(partySocketOptions) {\n const {\n id,\n host: _host,\n path: _path,\n party: _party,\n room: _room,\n protocol: _protocol,\n query: _query,\n protocols,\n ...socketOptions\n } = partySocketOptions;\n const _pk = id || generateUUID();\n const party = getPartyInfo(partySocketOptions, \"ws\", { _pk });\n return {\n _pk,\n _pkurl: party.partyUrl,\n name: party.name,\n room: party.room,\n host: party.host,\n path: party.path,\n protocols,\n socketOptions,\n urlProvider: party.urlProvider\n };\n}\n\nexport { PartySocket };\n//# sourceMappingURL=chunk-HAC622V3.mjs.map\n"],"x_google_ignoreList":[0],"mappings":";;AAGA,IAAI,iBAAiB,iBACnB,aAAa,OAAO,QAAQ,aAAa,OAAO,KAAK;AACvD,SAAS,eAAe;CACtB,IAAI,OAAO,WAAW,eAAe,OAAO,YAC1C,OAAO,OAAO,WAAW;CAE3B,IAAI,IAAoB,iCAAA,IAAI,KAAK,GAAE,QAAQ;CAC3C,IAAI,KACD,OAAO,gBAAgB,eACtB,YAAY,OACZ,YAAY,IAAI,IAAI,OACtB;CACF,OAAO,uCAAuC,QAAQ,SAAS,SAAU,GAAG;EAC1E,IAAI,IAAI,KAAK,OAAO,IAAI;EACxB,IAAI,IAAI,GAAG;GACT,KAAK,IAAI,KAAK,KAAK;GACnB,IAAI,KAAK,MAAM,IAAI,EAAE;EACvB,OAAO;GACL,KAAK,KAAK,KAAK,KAAK;GACpB,KAAK,KAAK,MAAM,KAAK,EAAE;EACzB;EACA,QAAQ,MAAM,MAAM,IAAK,IAAI,IAAK,GAAG,SAAS,EAAE;CAClD,CAAC;AACH;AACA,SAAS,aAAa,oBAAoB,iBAAiB,gBAAgB,CAAC,GAAG;CAC7E,MAAM,EACJ,MAAM,SACN,MAAM,SACN,UAAU,aACV,MACA,OACA,UACA,QACA,UACE;CACJ,IAAI,OAAO,QAAQ,QAAQ,6BAA6B,EAAE;CAC1D,IAAI,KAAK,SAAS,GAAG,GACnB,OAAO,KAAK,MAAM,GAAG,EAAE;CAEzB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K,OAAO,UAAU;EACtB,KAAK,aAAa,UAAU;EAC5B,KAAK,WAAW,UAAU;EAC1B,KAAK,gBAAgB,SAAS;CAChC;CACA,gBAAgB,WAAW;EACzB,MAAM,EAAE,KAAK,QAAQ,MAAM,MAAM,MAAM,SAAS;EAChD,KAAK,MAAM;EACX,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;CACA,UAAU,MAAM,QAAQ;EACtB,IAAI,CAAC,KAAK,QAAQ,CAAC,KAAK,MACtB,MAAM,IAAI,MACR,6HACF;EAEF,MAAM,UAAU,MAAM,MAAM;CAC9B;CACA,IAAI,KAAK;EACP,OAAO,KAAK;CACd;;;;;CAKA,IAAI,UAAU;EACZ,OAAO,KAAK;CACd;CAEA,aAAa,MAAM,SAAS,MAAM;EAChC,MAAM,QAAQ,aAAa,SAAS,MAAM;EAC1C,MAAM,MACJ,OAAO,MAAM,gBAAgB,WACzB,MAAM,cACN,MAAM,MAAM,YAAY;EAE9B,QADgB,QAAQ,SAAS,OAClB,KAAK,IAAI;CAC1B;AACF;AACA,SAAS,aAAa,oBAAoB;CACxC,MAAM,EACJ,IACA,MAAM,OACN,MAAM,OACN,OAAO,QACP,MAAM,OACN,UAAU,WACV,OAAO,QACP,WACA,GAAG,kBACD;CACJ,MAAM,MAAM,MAAM,aAAa;CAC/B,MAAM,QAAQ,aAAa,oBAAoB,MAAM,EAAE,IAAI,CAAC;CAC5D,OAAO;EACL;EACA,QAAQ,MAAM;EACd,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ;EACA;EACA,aAAa,MAAM;CACrB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-S74YV6PU.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.mjs"],"sourcesContent":["// src/ws.ts\nif (!globalThis.EventTarget || !globalThis.Event) {\n console.error(`\n PartySocket requires a global 'EventTarget' class to be available!\n You can polyfill this global by adding this to your code before any partysocket imports: \n \n \\`\\`\\`\n import 'partysocket/event-target-polyfill';\n \\`\\`\\`\n Please file an issue at https://github.com/partykit/partykit if you're still having trouble.\n`);\n}\nvar ErrorEvent = class extends Event {\n message;\n error;\n // biome-ignore lint/suspicious/noExplicitAny: vibes\n constructor(error, target) {\n super(\"error\", target);\n this.message = error.message;\n this.error = error;\n }\n};\nvar CloseEvent = class extends Event {\n code;\n reason;\n wasClean = true;\n // biome-ignore lint/style/useDefaultParameterLast: legacy\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n constructor(code = 1e3, reason = \"\", target) {\n super(\"close\", target);\n this.code = code;\n this.reason = reason;\n }\n};\nvar Events = {\n Event,\n ErrorEvent,\n CloseEvent\n};\nfunction assert(condition, msg) {\n if (!condition) {\n throw new Error(msg);\n }\n}\nfunction cloneEventBrowser(e) {\n return new e.constructor(e.type, e);\n}\nfunction cloneEventNode(e) {\n if (\"data\" in e) {\n const evt2 = new MessageEvent(e.type, e);\n return evt2;\n }\n if (\"code\" in e || \"reason\" in e) {\n const evt2 = new CloseEvent(\n // @ts-expect-error we need to fix event/listener types\n e.code || 1999,\n // @ts-expect-error we need to fix event/listener types\n e.reason || \"unknown reason\",\n e\n );\n return evt2;\n }\n if (\"error\" in e) {\n const evt2 = new ErrorEvent(e.error, e);\n return evt2;\n }\n const evt = new Event(e.type, e);\n return evt;\n}\nvar _a;\nvar isNode =\n typeof process !== \"undefined\" &&\n typeof ((_a = process.versions) == null ? void 0 : _a.node) !== \"undefined\" &&\n typeof document === \"undefined\";\nvar cloneEvent = isNode ? cloneEventNode : cloneEventBrowser;\nvar DEFAULT = {\n maxReconnectionDelay: 1e4,\n minReconnectionDelay: 1e3 + Math.random() * 4e3,\n minUptime: 5e3,\n reconnectionDelayGrowFactor: 1.3,\n connectionTimeout: 4e3,\n maxRetries: Number.POSITIVE_INFINITY,\n maxEnqueuedMessages: Number.POSITIVE_INFINITY,\n startClosed: false,\n debug: false\n};\nvar didWarnAboutMissingWebSocket = false;\nvar ReconnectingWebSocket = class _ReconnectingWebSocket extends EventTarget {\n _ws;\n _retryCount = -1;\n _uptimeTimeout;\n _connectTimeout;\n _shouldReconnect = true;\n _connectLock = false;\n _binaryType = \"blob\";\n _closeCalled = false;\n _messageQueue = [];\n _debugLogger = console.log.bind(console);\n _url;\n _protocols;\n _options;\n constructor(url, protocols, options = {}) {\n super();\n this._url = url;\n this._protocols = protocols;\n this._options = options;\n if (this._options.startClosed) {\n this._shouldReconnect = false;\n }\n if (this._options.debugLogger) {\n this._debugLogger = this._options.debugLogger;\n }\n this._connect();\n }\n static get CONNECTING() {\n return 0;\n }\n static get OPEN() {\n return 1;\n }\n static get CLOSING() {\n return 2;\n }\n static get CLOSED() {\n return 3;\n }\n get CONNECTING() {\n return _ReconnectingWebSocket.CONNECTING;\n }\n get OPEN() {\n return _ReconnectingWebSocket.OPEN;\n }\n get CLOSING() {\n return _ReconnectingWebSocket.CLOSING;\n }\n get CLOSED() {\n return _ReconnectingWebSocket.CLOSED;\n }\n get binaryType() {\n return this._ws ? this._ws.binaryType : this._binaryType;\n }\n set binaryType(value) {\n this._binaryType = value;\n if (this._ws) {\n this._ws.binaryType = value;\n }\n }\n /**\n * Returns the number or connection retries\n */\n get retryCount() {\n return Math.max(this._retryCount, 0);\n }\n /**\n * The number of bytes of data that have been queued using calls to send() but not yet\n * transmitted to the network. This value resets to zero once all queued data has been sent.\n * This value does not reset to zero when the connection is closed; if you keep calling send(),\n * this will continue to climb. Read only\n */\n get bufferedAmount() {\n const bytes = this._messageQueue.reduce((acc, message) => {\n if (typeof message === \"string\") {\n acc += message.length;\n } else if (message instanceof Blob) {\n acc += message.size;\n } else {\n acc += message.byteLength;\n }\n return acc;\n }, 0);\n return bytes + (this._ws ? this._ws.bufferedAmount : 0);\n }\n /**\n * The extensions selected by the server. This is currently only the empty string or a list of\n * extensions as negotiated by the connection\n */\n get extensions() {\n return this._ws ? this._ws.extensions : \"\";\n }\n /**\n * A string indicating the name of the sub-protocol the server selected;\n * this will be one of the strings specified in the protocols parameter when creating the\n * WebSocket object\n */\n get protocol() {\n return this._ws ? this._ws.protocol : \"\";\n }\n /**\n * The current state of the connection; this is one of the Ready state constants\n */\n get readyState() {\n if (this._ws) {\n return this._ws.readyState;\n }\n return this._options.startClosed\n ? _ReconnectingWebSocket.CLOSED\n : _ReconnectingWebSocket.CONNECTING;\n }\n /**\n * The URL as resolved by the constructor\n */\n get url() {\n return this._ws ? this._ws.url : \"\";\n }\n /**\n * Whether the websocket object is now in reconnectable state\n */\n get shouldReconnect() {\n return this._shouldReconnect;\n }\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to CLOSED\n */\n onclose = null;\n /**\n * An event listener to be called when an error occurs\n */\n onerror = null;\n /**\n * An event listener to be called when a message is received from the server\n */\n onmessage = null;\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n * this indicates that the connection is ready to send and receive data\n */\n onopen = null;\n /**\n * Closes the WebSocket connection or connection attempt, if any. If the connection is already\n * CLOSED, this method does nothing\n */\n close(code = 1e3, reason) {\n this._closeCalled = true;\n this._shouldReconnect = false;\n this._clearTimeouts();\n if (!this._ws) {\n this._debug(\"close enqueued: no ws instance\");\n return;\n }\n if (this._ws.readyState === this.CLOSED) {\n this._debug(\"close: already closed\");\n return;\n }\n this._ws.close(code, reason);\n }\n /**\n * Closes the WebSocket connection or connection attempt and connects again.\n * Resets retry counter;\n */\n reconnect(code, reason) {\n this._shouldReconnect = true;\n this._closeCalled = false;\n this._retryCount = -1;\n if (!this._ws || this._ws.readyState === this.CLOSED) {\n this._connect();\n } else {\n this._disconnect(code, reason);\n this._connect();\n }\n }\n /**\n * Enqueue specified data to be transmitted to the server over the WebSocket connection\n */\n send(data) {\n if (this._ws && this._ws.readyState === this.OPEN) {\n this._debug(\"send\", data);\n this._ws.send(data);\n } else {\n const { maxEnqueuedMessages = DEFAULT.maxEnqueuedMessages } =\n this._options;\n if (this._messageQueue.length < maxEnqueuedMessages) {\n this._debug(\"enqueue\", data);\n this._messageQueue.push(data);\n }\n }\n }\n _debug(...args) {\n if (this._options.debug) {\n this._debugLogger(\"RWS>\", ...args);\n }\n }\n _getNextDelay() {\n const {\n reconnectionDelayGrowFactor = DEFAULT.reconnectionDelayGrowFactor,\n minReconnectionDelay = DEFAULT.minReconnectionDelay,\n maxReconnectionDelay = DEFAULT.maxReconnectionDelay\n } = this._options;\n let delay = 0;\n if (this._retryCount > 0) {\n delay =\n minReconnectionDelay *\n reconnectionDelayGrowFactor ** (this._retryCount - 1);\n if (delay > maxReconnectionDelay) {\n delay = maxReconnectionDelay;\n }\n }\n this._debug(\"next delay\", delay);\n return delay;\n }\n _wait() {\n return new Promise((resolve) => {\n setTimeout(resolve, this._getNextDelay());\n });\n }\n _getNextProtocols(protocolsProvider) {\n if (!protocolsProvider) return Promise.resolve(null);\n if (\n typeof protocolsProvider === \"string\" ||\n Array.isArray(protocolsProvider)\n ) {\n return Promise.resolve(protocolsProvider);\n }\n if (typeof protocolsProvider === \"function\") {\n const protocols = protocolsProvider();\n if (!protocols) return Promise.resolve(null);\n if (typeof protocols === \"string\" || Array.isArray(protocols)) {\n return Promise.resolve(protocols);\n }\n if (protocols.then) {\n return protocols;\n }\n }\n throw Error(\"Invalid protocols\");\n }\n _getNextUrl(urlProvider) {\n if (typeof urlProvider === \"string\") {\n return Promise.resolve(urlProvider);\n }\n if (typeof urlProvider === \"function\") {\n const url = urlProvider();\n if (typeof url === \"string\") {\n return Promise.resolve(url);\n }\n if (url.then) {\n return url;\n }\n }\n throw Error(\"Invalid URL\");\n }\n _connect() {\n if (this._connectLock || !this._shouldReconnect) {\n return;\n }\n this._connectLock = true;\n const {\n maxRetries = DEFAULT.maxRetries,\n connectionTimeout = DEFAULT.connectionTimeout\n } = this._options;\n if (this._retryCount >= maxRetries) {\n this._debug(\"max retries reached\", this._retryCount, \">=\", maxRetries);\n return;\n }\n this._retryCount++;\n this._debug(\"connect\", this._retryCount);\n this._removeListeners();\n this._wait()\n .then(() =>\n Promise.all([\n this._getNextUrl(this._url),\n this._getNextProtocols(this._protocols || null)\n ])\n )\n .then(([url, protocols]) => {\n if (this._closeCalled) {\n this._connectLock = false;\n return;\n }\n if (\n !this._options.WebSocket &&\n typeof WebSocket === \"undefined\" &&\n !didWarnAboutMissingWebSocket\n ) {\n console.error(`\\u203C\\uFE0F No WebSocket implementation available. You should define options.WebSocket. \n\nFor example, if you're using node.js, run \\`npm install ws\\`, and then in your code:\n\nimport PartySocket from 'partysocket';\nimport WS from 'ws';\n\nconst partysocket = new PartySocket({\n host: \"127.0.0.1:1999\",\n room: \"test-room\",\n WebSocket: WS\n});\n\n`);\n didWarnAboutMissingWebSocket = true;\n }\n const WS = this._options.WebSocket || WebSocket;\n this._debug(\"connect\", { url, protocols });\n this._ws = protocols ? new WS(url, protocols) : new WS(url);\n this._ws.binaryType = this._binaryType;\n this._connectLock = false;\n this._addListeners();\n this._connectTimeout = setTimeout(\n () => this._handleTimeout(),\n connectionTimeout\n );\n })\n .catch((err) => {\n this._connectLock = false;\n this._handleError(new Events.ErrorEvent(Error(err.message), this));\n });\n }\n _handleTimeout() {\n this._debug(\"timeout event\");\n this._handleError(new Events.ErrorEvent(Error(\"TIMEOUT\"), this));\n }\n _disconnect(code = 1e3, reason) {\n this._clearTimeouts();\n if (!this._ws) {\n return;\n }\n this._removeListeners();\n try {\n if (this._ws.readyState === this.OPEN) {\n this._ws.close(code, reason);\n }\n this._handleClose(new Events.CloseEvent(code, reason, this));\n } catch (error) {}\n }\n _acceptOpen() {\n this._debug(\"accept open\");\n this._retryCount = 0;\n }\n _handleOpen = (event) => {\n this._debug(\"open event\");\n const { minUptime = DEFAULT.minUptime } = this._options;\n clearTimeout(this._connectTimeout);\n this._uptimeTimeout = setTimeout(() => this._acceptOpen(), minUptime);\n assert(this._ws, \"WebSocket is not defined\");\n this._ws.binaryType = this._binaryType;\n this._messageQueue.forEach((message) => {\n var _a2;\n return (_a2 = this._ws) == null ? void 0 : _a2.send(message);\n });\n this._messageQueue = [];\n if (this.onopen) {\n this.onopen(event);\n }\n this.dispatchEvent(cloneEvent(event));\n };\n _handleMessage = (event) => {\n this._debug(\"message event\");\n if (this.onmessage) {\n this.onmessage(event);\n }\n this.dispatchEvent(cloneEvent(event));\n };\n _handleError = (event) => {\n this._debug(\"error event\", event.message);\n this._disconnect(void 0, event.message === \"TIMEOUT\" ? \"timeout\" : void 0);\n if (this.onerror) {\n this.onerror(event);\n }\n this._debug(\"exec error listeners\");\n this.dispatchEvent(cloneEvent(event));\n this._connect();\n };\n _handleClose = (event) => {\n this._debug(\"close event\");\n this._clearTimeouts();\n if (this._shouldReconnect) {\n this._connect();\n }\n if (this.onclose) {\n this.onclose(event);\n }\n this.dispatchEvent(cloneEvent(event));\n };\n _removeListeners() {\n if (!this._ws) {\n return;\n }\n this._debug(\"removeListeners\");\n this._ws.removeEventListener(\"open\", this._handleOpen);\n this._ws.removeEventListener(\"close\", this._handleClose);\n this._ws.removeEventListener(\"message\", this._handleMessage);\n this._ws.removeEventListener(\"error\", this._handleError);\n }\n _addListeners() {\n if (!this._ws) {\n return;\n }\n this._debug(\"addListeners\");\n this._ws.addEventListener(\"open\", this._handleOpen);\n this._ws.addEventListener(\"close\", this._handleClose);\n this._ws.addEventListener(\"message\", this._handleMessage);\n this._ws.addEventListener(\"error\", this._handleError);\n }\n _clearTimeouts() {\n clearTimeout(this._connectTimeout);\n clearTimeout(this._uptimeTimeout);\n }\n};\n\nexport { ErrorEvent, CloseEvent, ReconnectingWebSocket };\n/*!\n * Reconnecting WebSocket\n * by Pedro Ladaria <pedro.ladaria@gmail.com>\n * https://github.com/pladaria/reconnecting-websocket\n * License MIT\n */\n//# sourceMappingURL=chunk-S74YV6PU.mjs.map\n"],"x_google_ignoreList":[0],"mappings":";AACA,IAAI,CAAC,WAAW,eAAe,CAAC,WAAW,MACzC,SAAQ,MAAM;;;;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OAAK,IAAI,iBAAiB,QAAQ,KAAK,YAAY;AACnD,OAAK,IAAI,iBAAiB,SAAS,KAAK,aAAa;AACrD,OAAK,IAAI,iBAAiB,WAAW,KAAK,eAAe;AACzD,OAAK,IAAI,iBAAiB,SAAS,KAAK,aAAa;;CAEvD,iBAAiB;AACf,eAAa,KAAK,gBAAgB;AAClC,eAAa,KAAK,eAAe"}
1
+ {"version":3,"file":"chunk-S74YV6PU.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.mjs"],"sourcesContent":["// src/ws.ts\nif (!globalThis.EventTarget || !globalThis.Event) {\n console.error(`\n PartySocket requires a global 'EventTarget' class to be available!\n You can polyfill this global by adding this to your code before any partysocket imports: \n \n \\`\\`\\`\n import 'partysocket/event-target-polyfill';\n \\`\\`\\`\n Please file an issue at https://github.com/partykit/partykit if you're still having trouble.\n`);\n}\nvar ErrorEvent = class extends Event {\n message;\n error;\n // biome-ignore lint/suspicious/noExplicitAny: vibes\n constructor(error, target) {\n super(\"error\", target);\n this.message = error.message;\n this.error = error;\n }\n};\nvar CloseEvent = class extends Event {\n code;\n reason;\n wasClean = true;\n // biome-ignore lint/style/useDefaultParameterLast: legacy\n // biome-ignore lint/suspicious/noExplicitAny: legacy\n constructor(code = 1e3, reason = \"\", target) {\n super(\"close\", target);\n this.code = code;\n this.reason = reason;\n }\n};\nvar Events = {\n Event,\n ErrorEvent,\n CloseEvent\n};\nfunction assert(condition, msg) {\n if (!condition) {\n throw new Error(msg);\n }\n}\nfunction cloneEventBrowser(e) {\n return new e.constructor(e.type, e);\n}\nfunction cloneEventNode(e) {\n if (\"data\" in e) {\n const evt2 = new MessageEvent(e.type, e);\n return evt2;\n }\n if (\"code\" in e || \"reason\" in e) {\n const evt2 = new CloseEvent(\n // @ts-expect-error we need to fix event/listener types\n e.code || 1999,\n // @ts-expect-error we need to fix event/listener types\n e.reason || \"unknown reason\",\n e\n );\n return evt2;\n }\n if (\"error\" in e) {\n const evt2 = new ErrorEvent(e.error, e);\n return evt2;\n }\n const evt = new Event(e.type, e);\n return evt;\n}\nvar _a;\nvar isNode =\n typeof process !== \"undefined\" &&\n typeof ((_a = process.versions) == null ? void 0 : _a.node) !== \"undefined\" &&\n typeof document === \"undefined\";\nvar cloneEvent = isNode ? cloneEventNode : cloneEventBrowser;\nvar DEFAULT = {\n maxReconnectionDelay: 1e4,\n minReconnectionDelay: 1e3 + Math.random() * 4e3,\n minUptime: 5e3,\n reconnectionDelayGrowFactor: 1.3,\n connectionTimeout: 4e3,\n maxRetries: Number.POSITIVE_INFINITY,\n maxEnqueuedMessages: Number.POSITIVE_INFINITY,\n startClosed: false,\n debug: false\n};\nvar didWarnAboutMissingWebSocket = false;\nvar ReconnectingWebSocket = class _ReconnectingWebSocket extends EventTarget {\n _ws;\n _retryCount = -1;\n _uptimeTimeout;\n _connectTimeout;\n _shouldReconnect = true;\n _connectLock = false;\n _binaryType = \"blob\";\n _closeCalled = false;\n _messageQueue = [];\n _debugLogger = console.log.bind(console);\n _url;\n _protocols;\n _options;\n constructor(url, protocols, options = {}) {\n super();\n this._url = url;\n this._protocols = protocols;\n this._options = options;\n if (this._options.startClosed) {\n this._shouldReconnect = false;\n }\n if (this._options.debugLogger) {\n this._debugLogger = this._options.debugLogger;\n }\n this._connect();\n }\n static get CONNECTING() {\n return 0;\n }\n static get OPEN() {\n return 1;\n }\n static get CLOSING() {\n return 2;\n }\n static get CLOSED() {\n return 3;\n }\n get CONNECTING() {\n return _ReconnectingWebSocket.CONNECTING;\n }\n get OPEN() {\n return _ReconnectingWebSocket.OPEN;\n }\n get CLOSING() {\n return _ReconnectingWebSocket.CLOSING;\n }\n get CLOSED() {\n return _ReconnectingWebSocket.CLOSED;\n }\n get binaryType() {\n return this._ws ? this._ws.binaryType : this._binaryType;\n }\n set binaryType(value) {\n this._binaryType = value;\n if (this._ws) {\n this._ws.binaryType = value;\n }\n }\n /**\n * Returns the number or connection retries\n */\n get retryCount() {\n return Math.max(this._retryCount, 0);\n }\n /**\n * The number of bytes of data that have been queued using calls to send() but not yet\n * transmitted to the network. This value resets to zero once all queued data has been sent.\n * This value does not reset to zero when the connection is closed; if you keep calling send(),\n * this will continue to climb. Read only\n */\n get bufferedAmount() {\n const bytes = this._messageQueue.reduce((acc, message) => {\n if (typeof message === \"string\") {\n acc += message.length;\n } else if (message instanceof Blob) {\n acc += message.size;\n } else {\n acc += message.byteLength;\n }\n return acc;\n }, 0);\n return bytes + (this._ws ? this._ws.bufferedAmount : 0);\n }\n /**\n * The extensions selected by the server. This is currently only the empty string or a list of\n * extensions as negotiated by the connection\n */\n get extensions() {\n return this._ws ? this._ws.extensions : \"\";\n }\n /**\n * A string indicating the name of the sub-protocol the server selected;\n * this will be one of the strings specified in the protocols parameter when creating the\n * WebSocket object\n */\n get protocol() {\n return this._ws ? this._ws.protocol : \"\";\n }\n /**\n * The current state of the connection; this is one of the Ready state constants\n */\n get readyState() {\n if (this._ws) {\n return this._ws.readyState;\n }\n return this._options.startClosed\n ? _ReconnectingWebSocket.CLOSED\n : _ReconnectingWebSocket.CONNECTING;\n }\n /**\n * The URL as resolved by the constructor\n */\n get url() {\n return this._ws ? this._ws.url : \"\";\n }\n /**\n * Whether the websocket object is now in reconnectable state\n */\n get shouldReconnect() {\n return this._shouldReconnect;\n }\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to CLOSED\n */\n onclose = null;\n /**\n * An event listener to be called when an error occurs\n */\n onerror = null;\n /**\n * An event listener to be called when a message is received from the server\n */\n onmessage = null;\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n * this indicates that the connection is ready to send and receive data\n */\n onopen = null;\n /**\n * Closes the WebSocket connection or connection attempt, if any. If the connection is already\n * CLOSED, this method does nothing\n */\n close(code = 1e3, reason) {\n this._closeCalled = true;\n this._shouldReconnect = false;\n this._clearTimeouts();\n if (!this._ws) {\n this._debug(\"close enqueued: no ws instance\");\n return;\n }\n if (this._ws.readyState === this.CLOSED) {\n this._debug(\"close: already closed\");\n return;\n }\n this._ws.close(code, reason);\n }\n /**\n * Closes the WebSocket connection or connection attempt and connects again.\n * Resets retry counter;\n */\n reconnect(code, reason) {\n this._shouldReconnect = true;\n this._closeCalled = false;\n this._retryCount = -1;\n if (!this._ws || this._ws.readyState === this.CLOSED) {\n this._connect();\n } else {\n this._disconnect(code, reason);\n this._connect();\n }\n }\n /**\n * Enqueue specified data to be transmitted to the server over the WebSocket connection\n */\n send(data) {\n if (this._ws && this._ws.readyState === this.OPEN) {\n this._debug(\"send\", data);\n this._ws.send(data);\n } else {\n const { maxEnqueuedMessages = DEFAULT.maxEnqueuedMessages } =\n this._options;\n if (this._messageQueue.length < maxEnqueuedMessages) {\n this._debug(\"enqueue\", data);\n this._messageQueue.push(data);\n }\n }\n }\n _debug(...args) {\n if (this._options.debug) {\n this._debugLogger(\"RWS>\", ...args);\n }\n }\n _getNextDelay() {\n const {\n reconnectionDelayGrowFactor = DEFAULT.reconnectionDelayGrowFactor,\n minReconnectionDelay = DEFAULT.minReconnectionDelay,\n maxReconnectionDelay = DEFAULT.maxReconnectionDelay\n } = this._options;\n let delay = 0;\n if (this._retryCount > 0) {\n delay =\n minReconnectionDelay *\n reconnectionDelayGrowFactor ** (this._retryCount - 1);\n if (delay > maxReconnectionDelay) {\n delay = maxReconnectionDelay;\n }\n }\n this._debug(\"next delay\", delay);\n return delay;\n }\n _wait() {\n return new Promise((resolve) => {\n setTimeout(resolve, this._getNextDelay());\n });\n }\n _getNextProtocols(protocolsProvider) {\n if (!protocolsProvider) return Promise.resolve(null);\n if (\n typeof protocolsProvider === \"string\" ||\n Array.isArray(protocolsProvider)\n ) {\n return Promise.resolve(protocolsProvider);\n }\n if (typeof protocolsProvider === \"function\") {\n const protocols = protocolsProvider();\n if (!protocols) return Promise.resolve(null);\n if (typeof protocols === \"string\" || Array.isArray(protocols)) {\n return Promise.resolve(protocols);\n }\n if (protocols.then) {\n return protocols;\n }\n }\n throw Error(\"Invalid protocols\");\n }\n _getNextUrl(urlProvider) {\n if (typeof urlProvider === \"string\") {\n return Promise.resolve(urlProvider);\n }\n if (typeof urlProvider === \"function\") {\n const url = urlProvider();\n if (typeof url === \"string\") {\n return Promise.resolve(url);\n }\n if (url.then) {\n return url;\n }\n }\n throw Error(\"Invalid URL\");\n }\n _connect() {\n if (this._connectLock || !this._shouldReconnect) {\n return;\n }\n this._connectLock = true;\n const {\n maxRetries = DEFAULT.maxRetries,\n connectionTimeout = DEFAULT.connectionTimeout\n } = this._options;\n if (this._retryCount >= maxRetries) {\n this._debug(\"max retries reached\", this._retryCount, \">=\", maxRetries);\n return;\n }\n this._retryCount++;\n this._debug(\"connect\", this._retryCount);\n this._removeListeners();\n this._wait()\n .then(() =>\n Promise.all([\n this._getNextUrl(this._url),\n this._getNextProtocols(this._protocols || null)\n ])\n )\n .then(([url, protocols]) => {\n if (this._closeCalled) {\n this._connectLock = false;\n return;\n }\n if (\n !this._options.WebSocket &&\n typeof WebSocket === \"undefined\" &&\n !didWarnAboutMissingWebSocket\n ) {\n console.error(`\\u203C\\uFE0F No WebSocket implementation available. You should define options.WebSocket. \n\nFor example, if you're using node.js, run \\`npm install ws\\`, and then in your code:\n\nimport PartySocket from 'partysocket';\nimport WS from 'ws';\n\nconst partysocket = new PartySocket({\n host: \"127.0.0.1:1999\",\n room: \"test-room\",\n WebSocket: WS\n});\n\n`);\n didWarnAboutMissingWebSocket = true;\n }\n const WS = this._options.WebSocket || WebSocket;\n this._debug(\"connect\", { url, protocols });\n this._ws = protocols ? new WS(url, protocols) : new WS(url);\n this._ws.binaryType = this._binaryType;\n this._connectLock = false;\n this._addListeners();\n this._connectTimeout = setTimeout(\n () => this._handleTimeout(),\n connectionTimeout\n );\n })\n .catch((err) => {\n this._connectLock = false;\n this._handleError(new Events.ErrorEvent(Error(err.message), this));\n });\n }\n _handleTimeout() {\n this._debug(\"timeout event\");\n this._handleError(new Events.ErrorEvent(Error(\"TIMEOUT\"), this));\n }\n _disconnect(code = 1e3, reason) {\n this._clearTimeouts();\n if (!this._ws) {\n return;\n }\n this._removeListeners();\n try {\n if (this._ws.readyState === this.OPEN) {\n this._ws.close(code, reason);\n }\n this._handleClose(new Events.CloseEvent(code, reason, this));\n } catch (error) {}\n }\n _acceptOpen() {\n this._debug(\"accept open\");\n this._retryCount = 0;\n }\n _handleOpen = (event) => {\n this._debug(\"open event\");\n const { minUptime = DEFAULT.minUptime } = this._options;\n clearTimeout(this._connectTimeout);\n this._uptimeTimeout = setTimeout(() => this._acceptOpen(), minUptime);\n assert(this._ws, \"WebSocket is not defined\");\n this._ws.binaryType = this._binaryType;\n this._messageQueue.forEach((message) => {\n var _a2;\n return (_a2 = this._ws) == null ? void 0 : _a2.send(message);\n });\n this._messageQueue = [];\n if (this.onopen) {\n this.onopen(event);\n }\n this.dispatchEvent(cloneEvent(event));\n };\n _handleMessage = (event) => {\n this._debug(\"message event\");\n if (this.onmessage) {\n this.onmessage(event);\n }\n this.dispatchEvent(cloneEvent(event));\n };\n _handleError = (event) => {\n this._debug(\"error event\", event.message);\n this._disconnect(void 0, event.message === \"TIMEOUT\" ? \"timeout\" : void 0);\n if (this.onerror) {\n this.onerror(event);\n }\n this._debug(\"exec error listeners\");\n this.dispatchEvent(cloneEvent(event));\n this._connect();\n };\n _handleClose = (event) => {\n this._debug(\"close event\");\n this._clearTimeouts();\n if (this._shouldReconnect) {\n this._connect();\n }\n if (this.onclose) {\n this.onclose(event);\n }\n this.dispatchEvent(cloneEvent(event));\n };\n _removeListeners() {\n if (!this._ws) {\n return;\n }\n this._debug(\"removeListeners\");\n this._ws.removeEventListener(\"open\", this._handleOpen);\n this._ws.removeEventListener(\"close\", this._handleClose);\n this._ws.removeEventListener(\"message\", this._handleMessage);\n this._ws.removeEventListener(\"error\", this._handleError);\n }\n _addListeners() {\n if (!this._ws) {\n return;\n }\n this._debug(\"addListeners\");\n this._ws.addEventListener(\"open\", this._handleOpen);\n this._ws.addEventListener(\"close\", this._handleClose);\n this._ws.addEventListener(\"message\", this._handleMessage);\n this._ws.addEventListener(\"error\", this._handleError);\n }\n _clearTimeouts() {\n clearTimeout(this._connectTimeout);\n clearTimeout(this._uptimeTimeout);\n }\n};\n\nexport { ErrorEvent, CloseEvent, ReconnectingWebSocket };\n/*!\n * Reconnecting WebSocket\n * by Pedro Ladaria <pedro.ladaria@gmail.com>\n * https://github.com/pladaria/reconnecting-websocket\n * License MIT\n */\n//# sourceMappingURL=chunk-S74YV6PU.mjs.map\n"],"x_google_ignoreList":[0],"mappings":";AACA,IAAI,CAAC,WAAW,eAAe,CAAC,WAAW,OACzC,QAAQ,MAAM;;;;;;;;CAQf;AAED,IAAI,aAAa,cAAc,MAAM;CACnC;CACA;CAEA,YAAY,OAAO,QAAQ;EACzB,MAAM,SAAS,MAAM;EACrB,KAAK,UAAU,MAAM;EACrB,KAAK,QAAQ;CACf;AACF;AACA,IAAI,aAAa,cAAc,MAAM;CACnC;CACA;CACA,WAAW;CAGX,YAAY,OAAO,KAAK,SAAS,IAAI,QAAQ;EAC3C,MAAM,SAAS,MAAM;EACrB,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AACA,IAAI,SAAS;CACX;CACA;CACA;AACF;AACA,SAAS,OAAO,WAAW,KAAK;CAC9B,IAAI,CAAC,WACH,MAAM,IAAI,MAAM,GAAG;AAEvB;AACA,SAAS,kBAAkB,GAAG;CAC5B,OAAO,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC;AACpC;AACA,SAAS,eAAe,GAAG;CACzB,IAAI,UAAU,GAEZ,OAAO,IADU,aAAa,EAAE,MAAM,CAC5B;CAEZ,IAAI,UAAU,KAAK,YAAY,GAQ7B,OAAO,IAPU,WAEf,EAAE,QAAQ,MAEV,EAAE,UAAU,kBACZ,CAEQ;CAEZ,IAAI,WAAW,GAEb,OAAO,IADU,WAAW,EAAE,OAAO,CAC3B;CAGZ,OAAO,IADS,MAAM,EAAE,MAAM,CACrB;AACX;AACA,IAAI;AAKJ,IAA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;EAEpB,KAAK,OAAO,sBAAsB;EAClC,KAAK,cAAc,WAAW,KAAK,CAAC;EACpC,KAAK,SAAS;CAChB;CACA,gBAAgB,UAAU;EACxB,KAAK,OAAO,aAAa;EACzB,KAAK,eAAe;EACpB,IAAI,KAAK,kBACP,KAAK,SAAS;EAEhB,IAAI,KAAK,SACP,KAAK,QAAQ,KAAK;EAEpB,KAAK,cAAc,WAAW,KAAK,CAAC;CACtC;CACA,mBAAmB;EACjB,IAAI,CAAC,KAAK,KACR;EAEF,KAAK,OAAO,iBAAiB;EAC7B,KAAK,IAAI,oBAAoB,QAAQ,KAAK,WAAW;EACrD,KAAK,IAAI,oBAAoB,SAAS,KAAK,YAAY;EACvD,KAAK,IAAI,oBAAoB,WAAW,KAAK,cAAc;EAC3D,KAAK,IAAI,oBAAoB,SAAS,KAAK,YAAY;CACzD;CACA,gBAAgB;EACd,IAAI,CAAC,KAAK,KACR;EAEF,KAAK,OAAO,cAAc;EAC1B,KAAK,IAAI,iBAAiB,QAAQ,KAAK,WAAW;EAClD,KAAK,IAAI,iBAAiB,SAAS,KAAK,YAAY;EACpD,KAAK,IAAI,iBAAiB,WAAW,KAAK,cAAc;EACxD,KAAK,IAAI,iBAAiB,SAAS,KAAK,YAAY;CACtD;CACA,iBAAiB;EACf,aAAa,KAAK,eAAe;EACjC,aAAa,KAAK,cAAc;CAClC;AACF"}
@@ -432,7 +432,8 @@ var handleResult = (ctx, result) => {
432
432
  success: false,
433
433
  get error() {
434
434
  if (this._error) return this._error;
435
- this._error = new ZodError(ctx.common.issues);
435
+ const error = new ZodError(ctx.common.issues);
436
+ this._error = error;
436
437
  return this._error;
437
438
  }
438
439
  };
@@ -2122,9 +2123,10 @@ var ZodObject = class ZodObject extends ZodType {
2122
2123
  _getCached() {
2123
2124
  if (this._cached !== null) return this._cached;
2124
2125
  const shape = this._def.shape();
2126
+ const keys = util.objectKeys(shape);
2125
2127
  return this._cached = {
2126
2128
  shape,
2127
- keys: util.objectKeys(shape)
2129
+ keys
2128
2130
  };
2129
2131
  }
2130
2132
  _parse(input) {
@@ -3611,29 +3613,6 @@ var pipelineType = ZodPipeline.create;
3611
3613
  var ostring = () => stringType().optional();
3612
3614
  var onumber = () => numberType().optional();
3613
3615
  var oboolean = () => booleanType().optional();
3614
- var coerce = {
3615
- string: ((arg) => ZodString.create({
3616
- ...arg,
3617
- coerce: true
3618
- })),
3619
- number: ((arg) => ZodNumber.create({
3620
- ...arg,
3621
- coerce: true
3622
- })),
3623
- boolean: ((arg) => ZodBoolean.create({
3624
- ...arg,
3625
- coerce: true
3626
- })),
3627
- bigint: ((arg) => ZodBigInt.create({
3628
- ...arg,
3629
- coerce: true
3630
- })),
3631
- date: ((arg) => ZodDate.create({
3632
- ...arg,
3633
- coerce: true
3634
- }))
3635
- };
3636
- var NEVER = INVALID;
3637
3616
  var z = /* @__PURE__ */ Object.freeze({
3638
3617
  __proto__: null,
3639
3618
  defaultErrorMap: errorMap,
@@ -3705,7 +3684,28 @@ var z = /* @__PURE__ */ Object.freeze({
3705
3684
  get ZodFirstPartyTypeKind() {
3706
3685
  return ZodFirstPartyTypeKind;
3707
3686
  },
3708
- coerce,
3687
+ coerce: {
3688
+ string: ((arg) => ZodString.create({
3689
+ ...arg,
3690
+ coerce: true
3691
+ })),
3692
+ number: ((arg) => ZodNumber.create({
3693
+ ...arg,
3694
+ coerce: true
3695
+ })),
3696
+ boolean: ((arg) => ZodBoolean.create({
3697
+ ...arg,
3698
+ coerce: true
3699
+ })),
3700
+ bigint: ((arg) => ZodBigInt.create({
3701
+ ...arg,
3702
+ coerce: true
3703
+ })),
3704
+ date: ((arg) => ZodDate.create({
3705
+ ...arg,
3706
+ coerce: true
3707
+ }))
3708
+ },
3709
3709
  any: anyType,
3710
3710
  array: arrayType,
3711
3711
  bigint: bigIntType,
@@ -3745,7 +3745,7 @@ var z = /* @__PURE__ */ Object.freeze({
3745
3745
  union: unionType,
3746
3746
  unknown: unknownType,
3747
3747
  "void": voidType,
3748
- NEVER,
3748
+ NEVER: INVALID,
3749
3749
  ZodIssueCode,
3750
3750
  quotelessJson,
3751
3751
  ZodError