@rpgjs/client 5.0.0-beta.26 → 5.0.0-beta.28
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.
- package/CHANGELOG.md +47 -0
- package/dist/Game/AnimationManager.js.map +1 -1
- package/dist/Game/ClientVisuals.js.map +1 -1
- package/dist/Game/Map.js +2 -2
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.js +1 -1
- package/dist/Game/Object.js.map +1 -1
- package/dist/Game/ProjectileManager.js.map +1 -1
- package/dist/Gui/Gui.d.ts +36 -17
- package/dist/Gui/Gui.js +40 -22
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/RpgClient.d.ts +3 -64
- package/dist/RpgClientEngine.js +1 -1
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.133.0 → _@oxc-project_runtime@0.139.0}/helpers/esm/decorate.js +2 -2
- package/dist/_virtual/{_@oxc-project_runtime@0.133.0 → _@oxc-project_runtime@0.139.0}/helpers/esm/decorateMetadata.js +2 -2
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/fx.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/character-hitbox.js +1 -1
- package/dist/components/character.ce.js +3 -1
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/bar.ce.js.map +1 -1
- package/dist/components/dynamics/image.ce.js.map +1 -1
- package/dist/components/dynamics/parse-value.js +1 -1
- package/dist/components/dynamics/parse-value.js.map +1 -1
- package/dist/components/dynamics/shape-utils.js +1 -1
- package/dist/components/dynamics/shape.ce.js.map +1 -1
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/index.js +17 -16
- package/dist/components/gui/input-field.ce.js.map +1 -1
- package/dist/components/gui/input.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +4 -2
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/index.js +4 -3
- package/dist/components/interaction-components.ce.js.map +1 -1
- package/dist/components/player-components-utils.js +1 -1
- package/dist/components/player-components-utils.js.map +1 -1
- package/dist/components/player-components.ce.js.map +1 -1
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/index.js +3 -2
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/components/scenes/weather-tick-lifecycle.js.map +1 -1
- package/dist/core/inject.d.ts +4 -4
- package/dist/core/inject.js.map +1 -1
- package/dist/core/setup.d.ts +3 -3
- package/dist/core/setup.js +1 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/core/setup.spec.d.ts +1 -0
- package/dist/i18n.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/module.d.ts +2 -2
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_di@3.1.0/node_modules/@signe/di/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@3.1.0/node_modules/@signe/reactive/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@3.1.0/node_modules/@signe/reactive/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/@signe_room@3.1.0_react@19.2.7/node_modules/@signe/room/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/client/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@3.1.0_react@19.2.7/node_modules/@signe/sync/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js +2 -2
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js +7 -7
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js +1 -1
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js +2 -2
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js +1 -1
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js.map +1 -1
- package/dist/presets/faceset.js.map +1 -1
- package/dist/presets/rmspritesheet.js.map +1 -1
- package/dist/public-api-types.spec.d.ts +1 -0
- package/dist/services/AbstractSocket.d.ts +3 -3
- package/dist/services/AbstractSocket.js.map +1 -1
- package/dist/services/cameraFollow.js +1 -1
- package/dist/services/cameraFollow.js.map +1 -1
- package/dist/services/interactions.js.map +1 -1
- package/dist/services/loadMap.d.ts +3 -7
- package/dist/services/loadMap.js +2 -2
- package/dist/services/loadMap.js.map +1 -1
- package/dist/services/mapStreaming.d.ts +2 -16
- package/dist/services/mapStreaming.js.map +1 -1
- package/dist/services/mmorpg-connection.js +1 -1
- package/dist/services/mmorpg-connection.js.map +1 -1
- package/dist/services/mmorpg.d.ts +4 -26
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/pointerContext.js +2 -1
- package/dist/services/pointerContext.js.map +1 -1
- package/dist/services/save.js.map +1 -1
- package/dist/services/standalone.d.ts +2 -98
- package/dist/services/standalone.js.map +1 -1
- package/dist/utils/getEntityProp.js.map +1 -1
- package/dist/utils/syncHitbox.js.map +1 -1
- package/package.json +10 -10
- package/src/Game/Object.spec.ts +1 -1
- package/src/Game/Object.ts +4 -4
- package/src/Gui/Gui.spec.ts +26 -1
- package/src/Gui/Gui.ts +104 -40
- package/src/RpgClient.ts +2 -63
- package/src/core/inject.ts +6 -5
- package/src/core/setup.spec.ts +35 -0
- package/src/core/setup.ts +8 -6
- package/src/index.ts +12 -1
- package/src/module.ts +2 -2
- package/src/public-api-types.spec.ts +37 -0
- package/src/services/AbstractSocket.ts +2 -2
- package/src/services/loadMap.ts +8 -8
- package/src/services/mapStreaming.ts +7 -5
- package/src/services/mmorpg.ts +6 -7
- package/src/services/standalone.ts +4 -5
|
@@ -236,6 +236,6 @@ function getByPath(root, path) {
|
|
|
236
236
|
return current;
|
|
237
237
|
}
|
|
238
238
|
//#endregion
|
|
239
|
-
export { id, load, persist, sync, users };
|
|
239
|
+
export { DELETE_TOKEN, createSyncClass, getByPath, id, isClass, isInstanceOfClass, isObject, load, normalizeSyncOptions, persist, setMetadata, sync, type, users };
|
|
240
240
|
|
|
241
241
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isSignal2"],"sources":["../../../../../../../../../../node_modules/.pnpm/@signe+sync@3.1.0_react@19.2.7/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,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,KAAK,SAAS;AAC9F,SAAS,kBAAkB,OA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EJ;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isSignal2"],"sources":["../../../../../../../../../../node_modules/.pnpm/@signe+sync@3.1.0_react@19.2.7/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,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,KAAK,SAAS;AAC9F,SAAS,kBAAkB,OAAO;CAChC,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,UAAU,KAAK,KAAK,MAAM,QAAQ,KAAK,GACxF,OAAO;CAET,OAAO,OAAO,eAAe,KAAK,MAAM,OAAO;AACjD;AAYA,IAAI,eAAe;AA8GnB,SAAS,YAAY,QAAQ,KAAK,OAAO;CAEvC,MAAM,SADO,OAAO,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index.js
|
|
3
3
|
var valueIsNotNil = (keyValuePair) => keyValuePair[1] !== null && keyValuePair[1] !== void 0;
|
|
4
4
|
function generateUUID() {
|
|
@@ -123,6 +123,6 @@ function getWSOptions(partySocketOptions) {
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
|
-
export { PartySocket };
|
|
126
|
+
export { PartySocket, PartySocket as default, ReconnectingWebSocket as WebSocket };
|
|
127
127
|
|
|
128
128
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js"],"sourcesContent":["import ReconnectingWebSocket from \"./ws.js\";\n//#region src/index.ts\nconst valueIsNotNil = (keyValuePair) =>\n keyValuePair[1] !== null && keyValuePair[1] !== void 0;\nfunction generateUUID() {\n if (crypto?.randomUUID) return crypto.randomUUID();\n let d = Date.now();\n let d2 = (performance?.now && performance.now() * 1e3) || 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(\"/\")) host = host.slice(0, -1);\n if (rawPath?.startsWith(\"/\"))\n throw new Error(\"path must not start with a slash\");\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 ? defaultProtocol\n : `${defaultProtocol}s`);\n const baseUrl = `${protocol}://${host}/${basePath || `${prefix || \"parties\"}/${name}/${room}`}${path}`;\n const makeUrl = (query = {}) =>\n `${baseUrl}?${new URLSearchParams([...Object.entries(defaultParams), ...Object.entries(query).filter(valueIsNotNil)])}`;\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 _pk;\n _pkurl;\n name;\n room;\n host;\n path;\n basePath;\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 if (!partySocketOptions.startClosed && !this.room && !this.basePath) {\n this.close();\n throw new Error(\n \"Either room or basePath must be provided to connect. Use startClosed: true to create a socket and set them via updateProperties before calling reconnect().\"\n );\n }\n if (!partySocketOptions.disableNameValidation) {\n if (partySocketOptions.party?.includes(\"/\"))\n console.warn(\n `PartySocket: party name \"${partySocketOptions.party}\" contains forward slash which may cause routing issues. Consider using a name without forward slashes or set disableNameValidation: true to bypass this warning.`\n );\n if (partySocketOptions.room?.includes(\"/\"))\n console.warn(\n `PartySocket: room name \"${partySocketOptions.room}\" contains forward slash which may cause routing issues. Consider using a name without forward slashes or set disableNameValidation: true to bypass this warning.`\n );\n }\n }\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 basePath: partySocketOptions.basePath ?? this.basePath\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, basePath } = 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 this.basePath = basePath;\n }\n reconnect(code, reason) {\n if (!this.host)\n throw new Error(\n \"The host must be set before connecting, use `updateProperties` method to set it or pass it to the constructor.\"\n );\n if (!this.room && !this.basePath)\n throw new Error(\n \"The room (or basePath) must be set before connecting, use `updateProperties` method to set it or pass it to the constructor.\"\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 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 return (options.fetch ?? fetch)(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 basePath: partySocketOptions.basePath,\n protocols,\n socketOptions,\n urlProvider: party.urlProvider\n };\n}\n//#endregion\nexport {\n PartySocket,\n PartySocket as default,\n ReconnectingWebSocket as WebSocket\n};\n\n//# sourceMappingURL=index.js.map\n"],"x_google_ignoreList":[0],"mappings":";;AAEA,IAAM,iBAAiB,iBACrB,aAAa,OAAO,QAAQ,aAAa,OAAO,KAAK;AACvD,SAAS,eAAe;CACtB,IAAI,QAAQ,YAAY,OAAO,OAAO,WAAW;CACjD,IAAI,IAAI,KAAK,IAAI;CACjB,IAAI,KAAM,aAAa,OAAO,YAAY,IAAI,IAAI,OAAQ;CAC1D,OAAO,uCAAuC,QAAQ,SAAS,SAAU,GAAG;EAC1E,IAAI,IAAI,KAAK,OAAO,IAAI;EACxB,IAAI,IAAI,GAAG;GACT,KAAM,IAAI,KAAK,KAAM;GACrB,IAAI,KAAK,MAAM,IAAI,EAAE;EACvB,OAAO;GACL,KAAM,KAAK,KAAK,KAAM;GACtB,KAAK,KAAK,MAAM,KAAK,EAAE;EACzB;EACA,QAAQ,MAAM,MAAM,IAAK,IAAI,IAAK,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/index.js"],"sourcesContent":["import ReconnectingWebSocket from \"./ws.js\";\n//#region src/index.ts\nconst valueIsNotNil = (keyValuePair) =>\n keyValuePair[1] !== null && keyValuePair[1] !== void 0;\nfunction generateUUID() {\n if (crypto?.randomUUID) return crypto.randomUUID();\n let d = Date.now();\n let d2 = (performance?.now && performance.now() * 1e3) || 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(\"/\")) host = host.slice(0, -1);\n if (rawPath?.startsWith(\"/\"))\n throw new Error(\"path must not start with a slash\");\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 ? defaultProtocol\n : `${defaultProtocol}s`);\n const baseUrl = `${protocol}://${host}/${basePath || `${prefix || \"parties\"}/${name}/${room}`}${path}`;\n const makeUrl = (query = {}) =>\n `${baseUrl}?${new URLSearchParams([...Object.entries(defaultParams), ...Object.entries(query).filter(valueIsNotNil)])}`;\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 _pk;\n _pkurl;\n name;\n room;\n host;\n path;\n basePath;\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 if (!partySocketOptions.startClosed && !this.room && !this.basePath) {\n this.close();\n throw new Error(\n \"Either room or basePath must be provided to connect. Use startClosed: true to create a socket and set them via updateProperties before calling reconnect().\"\n );\n }\n if (!partySocketOptions.disableNameValidation) {\n if (partySocketOptions.party?.includes(\"/\"))\n console.warn(\n `PartySocket: party name \"${partySocketOptions.party}\" contains forward slash which may cause routing issues. Consider using a name without forward slashes or set disableNameValidation: true to bypass this warning.`\n );\n if (partySocketOptions.room?.includes(\"/\"))\n console.warn(\n `PartySocket: room name \"${partySocketOptions.room}\" contains forward slash which may cause routing issues. Consider using a name without forward slashes or set disableNameValidation: true to bypass this warning.`\n );\n }\n }\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 basePath: partySocketOptions.basePath ?? this.basePath\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, basePath } = 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 this.basePath = basePath;\n }\n reconnect(code, reason) {\n if (!this.host)\n throw new Error(\n \"The host must be set before connecting, use `updateProperties` method to set it or pass it to the constructor.\"\n );\n if (!this.room && !this.basePath)\n throw new Error(\n \"The room (or basePath) must be set before connecting, use `updateProperties` method to set it or pass it to the constructor.\"\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 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 return (options.fetch ?? fetch)(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 basePath: partySocketOptions.basePath,\n protocols,\n socketOptions,\n urlProvider: party.urlProvider\n };\n}\n//#endregion\nexport {\n PartySocket,\n PartySocket as default,\n ReconnectingWebSocket as WebSocket\n};\n\n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npm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js"],"sourcesContent":["//#region 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`);\nvar ErrorEvent = class extends Event {\n message;\n error;\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 constructor(code = 1e3, reason = \"\", target) {\n super(\"close\", target);\n this.code = code;\n this.reason = reason;\n }\n};\nconst Events = {\n Event,\n ErrorEvent,\n CloseEvent\n};\nfunction assert(condition, msg) {\n if (!condition) throw new Error(msg);\n}\nfunction cloneEventBrowser(e) {\n return new e.constructor(e.type, e);\n}\nfunction cloneEventNode(e) {\n if (\"data\" in e) return new MessageEvent(e.type, e);\n if (\"code\" in e || \"reason\" in e)\n return new CloseEvent(e.code || 1999, e.reason || \"unknown reason\", e);\n if (\"error\" in e) return new ErrorEvent(e.error, e);\n return new Event(e.type, e);\n}\nconst isNode =\n typeof process !== \"undefined\" &&\n typeof process.versions?.node !== \"undefined\";\nconst isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\nconst cloneEvent = isNode || isReactNative ? cloneEventNode : cloneEventBrowser;\nconst DEFAULT = {\n maxReconnectionDelay: 1e4,\n minReconnectionDelay: 3e3,\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};\nlet didWarnAboutMissingWebSocket = false;\nfunction absorbError() {}\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 _didWarnAboutClosedSend = 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) this._shouldReconnect = false;\n if (this._options.debugLogger)\n this._debugLogger = this._options.debugLogger;\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) this._ws.binaryType = value;\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 return (\n this._messageQueue.reduce((acc, message) => {\n if (typeof message === \"string\") acc += message.length;\n else if (message instanceof Blob) acc += message.size;\n else acc += message.byteLength;\n return acc;\n }, 0) + (this._ws ? this._ws.bufferedAmount : 0)\n );\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._closeCalled) return ReconnectingWebSocket.CLOSED;\n if (this._ws) return this._ws.readyState;\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 or CLOSING, this method does nothing.\n *\n * The `close` event is dispatched synchronously (mirroring how\n * `reconnect()` dispatches its synthetic close). This guarantees\n * consumers observe a terminal event for every explicit close, even\n * if their listeners are detached right after this call — previously\n * the real (asynchronous) browser close event could fire after\n * listeners were removed and go unobserved entirely.\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 (\n this._ws.readyState === this.CLOSED ||\n this._ws.readyState === this.CLOSING\n ) {\n this._debug(\"close: already closing or closed\");\n return;\n }\n this._disconnect(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._didWarnAboutClosedSend = false;\n this._retryCount = -1;\n if (\n !this._ws ||\n this._ws.readyState === this.CLOSED ||\n this._ws.readyState === this.CLOSING\n )\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 * @returns `true` if the message was transmitted immediately over an open\n * connection; `false` if it was buffered (sent when the connection next\n * opens — the buffer is always flushed before the `open` event is\n * dispatched) or dropped because `maxEnqueuedMessages` was reached.\n */\n send(data) {\n if (this._ws && this._ws.readyState === this.OPEN) {\n this._debug(\"send\", data);\n this._ws.send(data);\n return true;\n }\n if (this._closeCalled && !this._didWarnAboutClosedSend) {\n this._didWarnAboutClosedSend = true;\n console.warn(\n \"ReconnectingWebSocket: send() was called after close(). The message has been buffered, but it will only be delivered if reconnect() is called on this socket. If this socket has been discarded, the message is lost — this usually means a stale socket reference is being used.\"\n );\n }\n const { maxEnqueuedMessages = DEFAULT.maxEnqueuedMessages } = this._options;\n if (this._messageQueue.length < maxEnqueuedMessages) {\n this._debug(\"enqueue\", data);\n this._messageQueue.push(data);\n }\n return false;\n }\n /**\n * Removes and returns all messages that were passed to send() but never\n * transmitted (they were buffered while the connection wasn't open).\n *\n * Useful when a socket is being discarded and replaced (e.g. the React\n * hooks recreate the socket when connection options change): the\n * replacement socket can re-send these messages, instead of them being\n * silently lost with the old instance.\n */\n drainQueuedMessages() {\n const queue = this._messageQueue;\n this._messageQueue = [];\n return queue;\n }\n _debug(...args) {\n if (this._options.debug) this._debugLogger(\"RWS>\", ...args);\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) delay = maxReconnectionDelay;\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 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 if (protocols.then) return protocols;\n }\n throw Error(\"Invalid protocols\");\n }\n _getNextUrl(urlProvider) {\n if (typeof urlProvider === \"string\") return Promise.resolve(urlProvider);\n if (typeof urlProvider === \"function\") {\n const url = urlProvider();\n if (typeof url === \"string\") return Promise.resolve(url);\n if (url.then) return url;\n }\n throw Error(\"Invalid URL\");\n }\n _connect() {\n if (this._connectLock || !this._shouldReconnect) return;\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 this._connectLock = false;\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(`‼️ 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\", {\n url,\n protocols\n });\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) return;\n this._removeListeners();\n try {\n if (\n this._ws.readyState === this.OPEN ||\n this._ws.readyState === this.CONNECTING\n )\n this._ws.close(code, reason);\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 this._ws?.send(message);\n });\n this._messageQueue = [];\n if (this.onopen) this.onopen(event);\n this.dispatchEvent(cloneEvent(event));\n };\n _handleMessage = (event) => {\n this._debug(\"message event\");\n if (this.onmessage) this.onmessage(event);\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) this.onerror(event);\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) this._connect();\n if (this.onclose) this.onclose(event);\n this.dispatchEvent(cloneEvent(event));\n };\n _removeListeners() {\n if (!this._ws) return;\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 this._ws.addEventListener(\"error\", absorbError);\n }\n _addListeners() {\n if (!this._ws) return;\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//#endregion\nexport { CloseEvent, ErrorEvent, ReconnectingWebSocket as default };\n\n//# sourceMappingURL=ws.js.map\n"],"x_google_ignoreList":[0],"mappings":";AACA,IAAI,CAAC,WAAW,eAAe,CAAC,WAAW,OACzC,QAAQ,MAAM;;;;;;;;CAQf;AACD,IAAI,aAAa,cAAc,MAAM;CACnC;CACA;CACA,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;CACX,YAAY,OAAO,KAAK,SAAS,IAAI,QAAQ;EAC3C,MAAM,SAAS,MAAM;EACrB,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AACA,IAAM,SAAS;CACb;CACA;CACA;AACF;AACA,SAAS,OAAO,WAAW,KAAK;CAC9B,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,GAAG;AACrC;AACA,SAAS,kBAAkB,GAAG;CAC5B,OAAO,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC;AACpC;AACA,SAAS,eAAe,GAAG;CACzB,IAAI,UAAU,GAAG,OAAO,IAAI,aAAa,EAAE,MAAM,CAAC;CAClD,IAAI,UAAU,KAAK,YAAY,GAC7B,OAAO,IAAI,WAAW,EAAE,QAAQ,MAAM,EAAE,UAAU,kBAAkB,CAAC;CACvE,IAAI,WAAW,GAAG,OAAO,IAAI,WAAW,EAAE,OAAO,CAAC;CAClD,OAAO,IAAI,MAAM,EAAE,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AAiB;EACf,aAAa,KAAK,eAAe;EACjC,aAAa,KAAK,cAAc;CAClC;AACF"}
|
|
1
|
+
{"version":3,"file":"ws.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/partysocket@1.2.0_react@19.2.7/node_modules/partysocket/dist/ws.js"],"sourcesContent":["//#region 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`);\nvar ErrorEvent = class extends Event {\n message;\n error;\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 constructor(code = 1e3, reason = \"\", target) {\n super(\"close\", target);\n this.code = code;\n this.reason = reason;\n }\n};\nconst Events = {\n Event,\n ErrorEvent,\n CloseEvent\n};\nfunction assert(condition, msg) {\n if (!condition) throw new Error(msg);\n}\nfunction cloneEventBrowser(e) {\n return new e.constructor(e.type, e);\n}\nfunction cloneEventNode(e) {\n if (\"data\" in e) return new MessageEvent(e.type, e);\n if (\"code\" in e || \"reason\" in e)\n return new CloseEvent(e.code || 1999, e.reason || \"unknown reason\", e);\n if (\"error\" in e) return new ErrorEvent(e.error, e);\n return new Event(e.type, e);\n}\nconst isNode =\n typeof process !== \"undefined\" &&\n typeof process.versions?.node !== \"undefined\";\nconst isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\nconst cloneEvent = isNode || isReactNative ? cloneEventNode : cloneEventBrowser;\nconst DEFAULT = {\n maxReconnectionDelay: 1e4,\n minReconnectionDelay: 3e3,\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};\nlet didWarnAboutMissingWebSocket = false;\nfunction absorbError() {}\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 _didWarnAboutClosedSend = 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) this._shouldReconnect = false;\n if (this._options.debugLogger)\n this._debugLogger = this._options.debugLogger;\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) this._ws.binaryType = value;\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 return (\n this._messageQueue.reduce((acc, message) => {\n if (typeof message === \"string\") acc += message.length;\n else if (message instanceof Blob) acc += message.size;\n else acc += message.byteLength;\n return acc;\n }, 0) + (this._ws ? this._ws.bufferedAmount : 0)\n );\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._closeCalled) return ReconnectingWebSocket.CLOSED;\n if (this._ws) return this._ws.readyState;\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 or CLOSING, this method does nothing.\n *\n * The `close` event is dispatched synchronously (mirroring how\n * `reconnect()` dispatches its synthetic close). This guarantees\n * consumers observe a terminal event for every explicit close, even\n * if their listeners are detached right after this call — previously\n * the real (asynchronous) browser close event could fire after\n * listeners were removed and go unobserved entirely.\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 (\n this._ws.readyState === this.CLOSED ||\n this._ws.readyState === this.CLOSING\n ) {\n this._debug(\"close: already closing or closed\");\n return;\n }\n this._disconnect(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._didWarnAboutClosedSend = false;\n this._retryCount = -1;\n if (\n !this._ws ||\n this._ws.readyState === this.CLOSED ||\n this._ws.readyState === this.CLOSING\n )\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 * @returns `true` if the message was transmitted immediately over an open\n * connection; `false` if it was buffered (sent when the connection next\n * opens — the buffer is always flushed before the `open` event is\n * dispatched) or dropped because `maxEnqueuedMessages` was reached.\n */\n send(data) {\n if (this._ws && this._ws.readyState === this.OPEN) {\n this._debug(\"send\", data);\n this._ws.send(data);\n return true;\n }\n if (this._closeCalled && !this._didWarnAboutClosedSend) {\n this._didWarnAboutClosedSend = true;\n console.warn(\n \"ReconnectingWebSocket: send() was called after close(). The message has been buffered, but it will only be delivered if reconnect() is called on this socket. If this socket has been discarded, the message is lost — this usually means a stale socket reference is being used.\"\n );\n }\n const { maxEnqueuedMessages = DEFAULT.maxEnqueuedMessages } = this._options;\n if (this._messageQueue.length < maxEnqueuedMessages) {\n this._debug(\"enqueue\", data);\n this._messageQueue.push(data);\n }\n return false;\n }\n /**\n * Removes and returns all messages that were passed to send() but never\n * transmitted (they were buffered while the connection wasn't open).\n *\n * Useful when a socket is being discarded and replaced (e.g. the React\n * hooks recreate the socket when connection options change): the\n * replacement socket can re-send these messages, instead of them being\n * silently lost with the old instance.\n */\n drainQueuedMessages() {\n const queue = this._messageQueue;\n this._messageQueue = [];\n return queue;\n }\n _debug(...args) {\n if (this._options.debug) this._debugLogger(\"RWS>\", ...args);\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) delay = maxReconnectionDelay;\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 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 if (protocols.then) return protocols;\n }\n throw Error(\"Invalid protocols\");\n }\n _getNextUrl(urlProvider) {\n if (typeof urlProvider === \"string\") return Promise.resolve(urlProvider);\n if (typeof urlProvider === \"function\") {\n const url = urlProvider();\n if (typeof url === \"string\") return Promise.resolve(url);\n if (url.then) return url;\n }\n throw Error(\"Invalid URL\");\n }\n _connect() {\n if (this._connectLock || !this._shouldReconnect) return;\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 this._connectLock = false;\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(`‼️ 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\", {\n url,\n protocols\n });\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) return;\n this._removeListeners();\n try {\n if (\n this._ws.readyState === this.OPEN ||\n this._ws.readyState === this.CONNECTING\n )\n this._ws.close(code, reason);\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 this._ws?.send(message);\n });\n this._messageQueue = [];\n if (this.onopen) this.onopen(event);\n this.dispatchEvent(cloneEvent(event));\n };\n _handleMessage = (event) => {\n this._debug(\"message event\");\n if (this.onmessage) this.onmessage(event);\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) this.onerror(event);\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) this._connect();\n if (this.onclose) this.onclose(event);\n this.dispatchEvent(cloneEvent(event));\n };\n _removeListeners() {\n if (!this._ws) return;\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 this._ws.addEventListener(\"error\", absorbError);\n }\n _addListeners() {\n if (!this._ws) return;\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//#endregion\nexport { CloseEvent, ErrorEvent, ReconnectingWebSocket as default };\n\n//# sourceMappingURL=ws.js.map\n"],"x_google_ignoreList":[0],"mappings":";AACA,IAAI,CAAC,WAAW,eAAe,CAAC,WAAW,OACzC,QAAQ,MAAM;;;;;;;;CAQf;AACD,IAAI,aAAa,cAAc,MAAM;CACnC;CACA;CACA,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;CACX,YAAY,OAAO,KAAK,SAAS,IAAI,QAAQ;EAC3C,MAAM,SAAS,MAAM;EACrB,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AACA,IAAM,SAAS;CACb;CACA;CACA;AACF;AACA,SAAS,OAAO,WAAW,KAAK;CAC9B,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,GAAG;AACrC;AACA,SAAS,kBAAkB,GAAG;CAC5B,OAAO,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC;AACpC;AACA,SAAS,eAAe,GAAG;CACzB,IAAI,UAAU,GAAG,OAAO,IAAI,aAAa,EAAE,MAAM,CAAC;CAClD,IAAI,UAAU,KAAK,YAAY,GAC7B,OAAO,IAAI,WAAW,EAAE,QAA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ClD,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"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "./v3/helpers/util.js";
|
|
2
|
-
import "./v3/ZodError.js";
|
|
3
|
-
import "./v3/locales/en.js";
|
|
4
|
-
import "./v3/errors.js";
|
|
5
|
-
import "./v3/helpers/parseUtil.js";
|
|
6
|
-
import "./v3/types.js";
|
|
1
|
+
import { ZodParsedType, getParsedType, objectUtil, util } from "./v3/helpers/util.js";
|
|
2
|
+
import { ZodError, ZodIssueCode, quotelessJson } from "./v3/ZodError.js";
|
|
3
|
+
import errorMap from "./v3/locales/en.js";
|
|
4
|
+
import { getErrorMap, setErrorMap } from "./v3/errors.js";
|
|
5
|
+
import { DIRTY, EMPTY_PATH, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue } from "./v3/helpers/parseUtil.js";
|
|
6
|
+
import { BRAND, NEVER, Schema as ZodType, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, any as anyType, array as arrayType, bigint as bigIntType, boolean as booleanType, coerce, custom, date as dateType, datetimeRegex, discriminatedUnion as discriminatedUnionType, effect as effectsType, enum as enumType, function as functionType, instanceof as instanceOfType, intersection as intersectionType, late, lazy as lazyType, literal as literalType, map as mapType, nan as nanType, nativeEnum as nativeEnumType, never as neverType, null as nullType, nullable as nullableType, number as numberType, object as objectType, oboolean, onumber, optional as optionalType, ostring, pipeline as pipelineType, preprocess as preprocessType, promise as promiseType, record as recordType, set as setType, strictObject as strictObjectType, string as stringType, symbol as symbolType, tuple as tupleType, undefined as undefinedType, union as unionType, unknown as unknownType, void as voidType } from "./v3/types.js";
|
|
7
7
|
import { external_exports } from "./v3/external.js";
|
|
8
8
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js
|
|
9
9
|
var zod_default = external_exports;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { zod_default as default };
|
|
11
|
+
export { BRAND, DIRTY, EMPTY_PATH, INVALID, NEVER, OK, ParseStatus, ZodType as Schema, ZodType as ZodSchema, ZodType, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEffects as ZodTransformer, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, coerce, custom, dateType as date, datetimeRegex, zod_default as default, errorMap as defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, effectsType as transformer, enumType as enum, functionType as function, getErrorMap, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, symbolType as symbol, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, util, voidType as void, external_exports as z };
|
|
12
12
|
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZodError.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js"],"sourcesContent":["import { util } from \"./helpers/util.js\";\nexport const ZodIssueCode = util.arrayToEnum([\n \"invalid_type\",\n \"invalid_literal\",\n \"custom\",\n \"invalid_union\",\n \"invalid_union_discriminator\",\n \"invalid_enum_value\",\n \"unrecognized_keys\",\n \"invalid_arguments\",\n \"invalid_return_type\",\n \"invalid_date\",\n \"invalid_string\",\n \"too_small\",\n \"too_big\",\n \"invalid_intersection_types\",\n \"not_multiple_of\",\n \"not_finite\",\n]);\nexport const quotelessJson = (obj) => {\n const json = JSON.stringify(obj, null, 2);\n return json.replace(/\"([^\"]+)\":/g, \"$1:\");\n};\nexport class ZodError extends Error {\n get errors() {\n return this.issues;\n }\n constructor(issues) {\n super();\n this.issues = [];\n this.addIssue = (sub) => {\n this.issues = [...this.issues, sub];\n };\n this.addIssues = (subs = []) => {\n this.issues = [...this.issues, ...subs];\n };\n const actualProto = new.target.prototype;\n if (Object.setPrototypeOf) {\n // eslint-disable-next-line ban/ban\n Object.setPrototypeOf(this, actualProto);\n }\n else {\n this.__proto__ = actualProto;\n }\n this.name = \"ZodError\";\n this.issues = issues;\n }\n format(_mapper) {\n const mapper = _mapper ||\n function (issue) {\n return issue.message;\n };\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\") {\n issue.unionErrors.map(processError);\n }\n else if (issue.code === \"invalid_return_type\") {\n processError(issue.returnTypeError);\n }\n else if (issue.code === \"invalid_arguments\") {\n processError(issue.argumentsError);\n }\n else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < issue.path.length) {\n const el = issue.path[i];\n const terminal = i === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n // if (typeof el === \"string\") {\n // curr[el] = curr[el] || { _errors: [] };\n // } else if (typeof el === \"number\") {\n // const errorArray: any = [];\n // errorArray._errors = [];\n // curr[el] = curr[el] || errorArray;\n // }\n }\n else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i++;\n }\n }\n }\n };\n processError(this);\n return fieldErrors;\n }\n static assert(value) {\n if (!(value instanceof ZodError)) {\n throw new Error(`Not a ZodError: ${value}`);\n }\n }\n toString() {\n return this.message;\n }\n get message() {\n return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n }\n get isEmpty() {\n return this.issues.length === 0;\n }\n flatten(mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of this.issues) {\n if (sub.path.length > 0) {\n const firstEl = sub.path[0];\n fieldErrors[firstEl] = fieldErrors[firstEl] || [];\n fieldErrors[firstEl].push(mapper(sub));\n }\n else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n }\n get formErrors() {\n return this.flatten();\n }\n}\nZodError.create = (issues) => {\n const error = new ZodError(issues);\n return error;\n};\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAa,eAAe,KAAK,YAAY;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AACD,IAAa,iBAAiB,QAAQ;CAElC,OADa,KAAK,UAAU,KAAK,MAAM,CAC7B,
|
|
1
|
+
{"version":3,"file":"ZodError.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js"],"sourcesContent":["import { util } from \"./helpers/util.js\";\nexport const ZodIssueCode = util.arrayToEnum([\n \"invalid_type\",\n \"invalid_literal\",\n \"custom\",\n \"invalid_union\",\n \"invalid_union_discriminator\",\n \"invalid_enum_value\",\n \"unrecognized_keys\",\n \"invalid_arguments\",\n \"invalid_return_type\",\n \"invalid_date\",\n \"invalid_string\",\n \"too_small\",\n \"too_big\",\n \"invalid_intersection_types\",\n \"not_multiple_of\",\n \"not_finite\",\n]);\nexport const quotelessJson = (obj) => {\n const json = JSON.stringify(obj, null, 2);\n return json.replace(/\"([^\"]+)\":/g, \"$1:\");\n};\nexport class ZodError extends Error {\n get errors() {\n return this.issues;\n }\n constructor(issues) {\n super();\n this.issues = [];\n this.addIssue = (sub) => {\n this.issues = [...this.issues, sub];\n };\n this.addIssues = (subs = []) => {\n this.issues = [...this.issues, ...subs];\n };\n const actualProto = new.target.prototype;\n if (Object.setPrototypeOf) {\n // eslint-disable-next-line ban/ban\n Object.setPrototypeOf(this, actualProto);\n }\n else {\n this.__proto__ = actualProto;\n }\n this.name = \"ZodError\";\n this.issues = issues;\n }\n format(_mapper) {\n const mapper = _mapper ||\n function (issue) {\n return issue.message;\n };\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === \"invalid_union\") {\n issue.unionErrors.map(processError);\n }\n else if (issue.code === \"invalid_return_type\") {\n processError(issue.returnTypeError);\n }\n else if (issue.code === \"invalid_arguments\") {\n processError(issue.argumentsError);\n }\n else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n }\n else {\n let curr = fieldErrors;\n let i = 0;\n while (i < issue.path.length) {\n const el = issue.path[i];\n const terminal = i === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n // if (typeof el === \"string\") {\n // curr[el] = curr[el] || { _errors: [] };\n // } else if (typeof el === \"number\") {\n // const errorArray: any = [];\n // errorArray._errors = [];\n // curr[el] = curr[el] || errorArray;\n // }\n }\n else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i++;\n }\n }\n }\n };\n processError(this);\n return fieldErrors;\n }\n static assert(value) {\n if (!(value instanceof ZodError)) {\n throw new Error(`Not a ZodError: ${value}`);\n }\n }\n toString() {\n return this.message;\n }\n get message() {\n return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n }\n get isEmpty() {\n return this.issues.length === 0;\n }\n flatten(mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of this.issues) {\n if (sub.path.length > 0) {\n const firstEl = sub.path[0];\n fieldErrors[firstEl] = fieldErrors[firstEl] || [];\n fieldErrors[firstEl].push(mapper(sub));\n }\n else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n }\n get formErrors() {\n return this.flatten();\n }\n}\nZodError.create = (issues) => {\n const error = new ZodError(issues);\n return error;\n};\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAa,eAAe,KAAK,YAAY;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AACD,IAAa,iBAAiB,QAAQ;CAElC,OADa,KAAK,UAAU,KAAK,MAAM,CAC7B,CAAC,CAAC,QAAQ,eAAe,KAAK;AAC5C;AACA,IAAa,WAAb,MAAa,iBAAiB,MAAM;CAChC,IAAI,SAAS;EACT,OAAO,KAAK;CAChB;CACA,YAAY,QAAQ;EAChB,MAAM;EACN,KAAK,SAAS,CAAC;EACf,KAAK,YAAY,QAAQ;GACrB,KAAK,SAAS,CAAC,GAAG,KAAK,QAAQ,GAAG;EACtC;EACA,KAAK,aAAa,OAAO,CAAC,MAAM;GAC5B,KAAK,SAAS,CAAC,GAAG,KAAK,QAAQ,GAAG,IAAI;EAC1C;EACA,MAAM,cAAc,IAAI,OAAO;EAC/B,IAAI,OAAO,gBAEP,OAAO,eAAe,MAA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M,OAAO,KAAK,QACnB,IAAI,IAAI,KAAK,SAAS,GAAG;GACrB,MAAM,UAAU,IAAI,KAAK;GACzB,YAAY,WAAW,YAAY,YAAY,CAAC;GAChD,YAAY,QAAQ,CAAC,KAAK,OAAO,GAAG,CAAC;EACzC,OAEI,WAAW,KAAK,OAAO,GAAG,CAAC;EAGnC,OAAO;GAAE;GAAY;EAAY;CACrC;CACA,IAAI,aAAa;EACb,OAAO,KAAK,QAAQ;CACxB;AACJ;AACA,SAAS,UAAU,WAAW;CAE1B,OAAO,IADW,SAAS,MAChB;AACf"}
|
|
@@ -4,7 +4,7 @@ import { ZodError, ZodIssueCode, quotelessJson } from "./ZodError.js";
|
|
|
4
4
|
import errorMap from "./locales/en.js";
|
|
5
5
|
import { getErrorMap, setErrorMap } from "./errors.js";
|
|
6
6
|
import { DIRTY, EMPTY_PATH, INVALID, OK, ParseStatus, addIssueToContext, isAborted, isAsync, isDirty, isValid, makeIssue } from "./helpers/parseUtil.js";
|
|
7
|
-
import { BRAND, NEVER, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple,
|
|
7
|
+
import { BRAND, NEVER, Schema as ZodType, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, any as anyType, array as arrayType, bigint as bigIntType, boolean as booleanType, coerce, custom, date as dateType, datetimeRegex, discriminatedUnion as discriminatedUnionType, effect as effectsType, enum as enumType, function as functionType, instanceof as instanceOfType, intersection as intersectionType, late, lazy as lazyType, literal as literalType, map as mapType, nan as nanType, nativeEnum as nativeEnumType, never as neverType, null as nullType, nullable as nullableType, number as numberType, object as objectType, oboolean, onumber, optional as optionalType, ostring, pipeline as pipelineType, preprocess as preprocessType, promise as promiseType, record as recordType, set as setType, strictObject as strictObjectType, string as stringType, symbol as symbolType, tuple as tupleType, undefined as undefinedType, union as unionType, unknown as unknownType, void as voidType } from "./types.js";
|
|
8
8
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
9
9
|
var external_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
BRAND: () => BRAND,
|
|
@@ -116,6 +116,6 @@ var external_exports = /* @__PURE__ */ __exportAll({
|
|
|
116
116
|
void: () => voidType
|
|
117
117
|
});
|
|
118
118
|
//#endregion
|
|
119
|
-
export { external_exports };
|
|
119
|
+
export { BRAND, DIRTY, EMPTY_PATH, INVALID, NEVER, OK, ParseStatus, ZodType as Schema, ZodType as ZodSchema, ZodType, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEffects as ZodTransformer, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, coerce, custom, dateType as date, datetimeRegex, errorMap as defaultErrorMap, discriminatedUnionType as discriminatedUnion, effectsType as effect, effectsType as transformer, enumType as enum, external_exports, functionType as function, getErrorMap, getParsedType, instanceOfType as instanceof, intersectionType as intersection, isAborted, isAsync, isDirty, isValid, late, lazyType as lazy, literalType as literal, makeIssue, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, objectUtil, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, quotelessJson, recordType as record, setType as set, setErrorMap, strictObjectType as strictObject, stringType as string, symbolType as symbol, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, util, voidType as void };
|
|
120
120
|
|
|
121
121
|
//# sourceMappingURL=external.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorUtil.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js"],"sourcesContent":["export var errorUtil;\n(function (errorUtil) {\n errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n // biome-ignore lint:\n errorUtil.toString = (message) => typeof message === \"string\" ? message : message?.message;\n})(errorUtil || (errorUtil = {}));\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAW;CACV,SAAU,WAAW;CAClB,UAAU,YAAY,YAAY,OAAO,YAAY,WAAW,EAAE,QAAQ,IAAI,WAAW,CAAC;CAE1F,UAAU,YAAY,YAAY,OAAO,YAAY,WAAW,UAAU,SAAS;AACvF,
|
|
1
|
+
{"version":3,"file":"errorUtil.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js"],"sourcesContent":["export var errorUtil;\n(function (errorUtil) {\n errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n // biome-ignore lint:\n errorUtil.toString = (message) => typeof message === \"string\" ? message : message?.message;\n})(errorUtil || (errorUtil = {}));\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAW;CACV,SAAU,WAAW;CAClB,UAAU,YAAY,YAAY,OAAO,YAAY,WAAW,EAAE,QAAQ,IAAI,WAAW,CAAC;CAE1F,UAAU,YAAY,YAAY,OAAO,YAAY,WAAW,UAAU,SAAS;AACvF,EAAA,CAAG,cAAc,YAAY,CAAC,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseUtil.js","names":["defaultErrorMap"],"sources":["../../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js"],"sourcesContent":["import { getErrorMap } from \"../errors.js\";\nimport defaultErrorMap from \"../locales/en.js\";\nexport const makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...(issueData.path || [])];\n const fullIssue = {\n ...issueData,\n path: fullPath,\n };\n if (issueData.message !== undefined) {\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message,\n };\n }\n let errorMessage = \"\";\n const maps = errorMaps\n .filter((m) => !!m)\n .slice()\n .reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: errorMessage,\n };\n};\nexport const EMPTY_PATH = [];\nexport function addIssueToContext(ctx, issueData) {\n const overrideMap = getErrorMap();\n const issue = makeIssue({\n issueData: issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap, // contextual error map is first priority\n ctx.schemaErrorMap, // then schema-bound map if available\n overrideMap, // then global override map\n overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map\n ].filter((x) => !!x),\n });\n ctx.common.issues.push(issue);\n}\nexport class ParseStatus {\n constructor() {\n this.value = \"valid\";\n }\n dirty() {\n if (this.value === \"valid\")\n this.value = \"dirty\";\n }\n abort() {\n if (this.value !== \"aborted\")\n this.value = \"aborted\";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s of results) {\n if (s.status === \"aborted\")\n return INVALID;\n if (s.status === \"dirty\")\n status.dirty();\n arrayValue.push(s.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value,\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === \"aborted\")\n return INVALID;\n if (value.status === \"aborted\")\n return INVALID;\n if (key.status === \"dirty\")\n status.dirty();\n if (value.status === \"dirty\")\n status.dirty();\n if (key.value !== \"__proto__\" && (typeof value.value !== \"undefined\" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n}\nexport const INVALID = Object.freeze({\n status: \"aborted\",\n});\nexport const DIRTY = (value) => ({ status: \"dirty\", value });\nexport const OK = (value) => ({ status: \"valid\", value });\nexport const isAborted = (x) => x.status === \"aborted\";\nexport const isDirty = (x) => x.status === \"dirty\";\nexport const isValid = (x) => x.status === \"valid\";\nexport const isAsync = (x) => typeof Promise !== \"undefined\" && x instanceof Promise;\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,IAAa,aAAa,WAAW;CACjC,MAAM,EAAE,MAAM,MAAM,WAAW,cAAc;CAC7C,MAAM,WAAW,CAAC,GAAG,MAAM,GAAI,UAAU,QAAQ,CAAC,CAAE;CACpD,MAAM,YAAY;EACd,GAAG;EACH,MAAM;CACV;CACA,IAAI,UAAU,YAAY,KAAA,GACtB,OAAO;EACH,GAAG;EACH,MAAM;EACN,SAAS,UAAU;CACvB;CAEJ,IAAI,eAAe;CACnB,MAAM,OAAO,UACR,QAAQ,MAAM,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"parseUtil.js","names":["defaultErrorMap"],"sources":["../../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js"],"sourcesContent":["import { getErrorMap } from \"../errors.js\";\nimport defaultErrorMap from \"../locales/en.js\";\nexport const makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...(issueData.path || [])];\n const fullIssue = {\n ...issueData,\n path: fullPath,\n };\n if (issueData.message !== undefined) {\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message,\n };\n }\n let errorMessage = \"\";\n const maps = errorMaps\n .filter((m) => !!m)\n .slice()\n .reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: errorMessage,\n };\n};\nexport const EMPTY_PATH = [];\nexport function addIssueToContext(ctx, issueData) {\n const overrideMap = getErrorMap();\n const issue = makeIssue({\n issueData: issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap, // contextual error map is first priority\n ctx.schemaErrorMap, // then schema-bound map if available\n overrideMap, // then global override map\n overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map\n ].filter((x) => !!x),\n });\n ctx.common.issues.push(issue);\n}\nexport class ParseStatus {\n constructor() {\n this.value = \"valid\";\n }\n dirty() {\n if (this.value === \"valid\")\n this.value = \"dirty\";\n }\n abort() {\n if (this.value !== \"aborted\")\n this.value = \"aborted\";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s of results) {\n if (s.status === \"aborted\")\n return INVALID;\n if (s.status === \"dirty\")\n status.dirty();\n arrayValue.push(s.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value,\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === \"aborted\")\n return INVALID;\n if (value.status === \"aborted\")\n return INVALID;\n if (key.status === \"dirty\")\n status.dirty();\n if (value.status === \"dirty\")\n status.dirty();\n if (key.value !== \"__proto__\" && (typeof value.value !== \"undefined\" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n}\nexport const INVALID = Object.freeze({\n status: \"aborted\",\n});\nexport const DIRTY = (value) => ({ status: \"dirty\", value });\nexport const OK = (value) => ({ status: \"valid\", value });\nexport const isAborted = (x) => x.status === \"aborted\";\nexport const isDirty = (x) => x.status === \"dirty\";\nexport const isValid = (x) => x.status === \"valid\";\nexport const isAsync = (x) => typeof Promise !== \"undefined\" && x instanceof Promise;\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,IAAa,aAAa,WAAW;CACjC,MAAM,EAAE,MAAM,MAAM,WAAW,cAAc;CAC7C,MAAM,WAAW,CAAC,GAAG,MAAM,GAAI,UAAU,QAAQ,CAAC,CAAE;CACpD,MAAM,YAAY;EACd,GAAG;EACH,MAAM;CACV;CACA,IAAI,UAAU,YAAY,KAAA,GACtB,OAAO;EACH,GAAG;EACH,MAAM;EACN,SAAS,UAAU;CACvB;CAEJ,IAAI,eAAe;CACnB,MAAM,OAAO,UACR,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,CAClB,MAAM,CAAC,CACP,QAAQ;CACb,KAAK,MAAM,OAAO,MACd,eAAe,IAAI,WAAW;EAAE;EAAM,cAAc;CAAa,CAAC,CAAC,CAAC;CAExE,OAAO;EACH,GAAG;EACH,MAAM;EACN,SAAS;CACb;AACJ;AACA,IAAa,aAAa,CAAC;AAC3B,SAAgB,kBAAkB,KAAK,WAAW;CAC9C,MAAM,cAAc,YAAY;CAChC,MAAM,QAAQ,UAAU;EACT;EACX,MAAM,IAAI;EACV,MAAM,IAAI;EACV,WAAW;GACP,IAAI,OAAO;GACX,IAAI;GACJ;GACA,gBAAgBA,WAA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a,UAAU,OAAO,OAAO,EACjC,QAAQ,UACZ,CAAC;AACD,IAAa,SAAS,WAAW;CAAE,QAAQ;CAAS;AAAM;AAC1D,IAAa,MAAM,WAAW;CAAE,QAAQ;CAAS;AAAM;AACvD,IAAa,aAAa,MAAM,EAAE,WAAW;AAC7C,IAAa,WAAW,MAAM,EAAE,WAAW;AAC3C,IAAa,WAAW,MAAM,EAAE,WAAW;AAC3C,IAAa,WAAW,MAAM,OAAO,YAAY,eAAe,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js"],"sourcesContent":["export var util;\n(function (util) {\n util.assertEqual = (_) => { };\n function assertIs(_arg) { }\n util.assertIs = assertIs;\n function assertNever(_x) {\n throw new Error();\n }\n util.assertNever = assertNever;\n util.arrayToEnum = (items) => {\n const obj = {};\n for (const item of items) {\n obj[item] = item;\n }\n return obj;\n };\n util.getValidEnumValues = (obj) => {\n const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== \"number\");\n const filtered = {};\n for (const k of validKeys) {\n filtered[k] = obj[k];\n }\n return util.objectValues(filtered);\n };\n util.objectValues = (obj) => {\n return util.objectKeys(obj).map(function (e) {\n return obj[e];\n });\n };\n util.objectKeys = typeof Object.keys === \"function\" // eslint-disable-line ban/ban\n ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban\n : (object) => {\n const keys = [];\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n };\n util.find = (arr, checker) => {\n for (const item of arr) {\n if (checker(item))\n return item;\n }\n return undefined;\n };\n util.isInteger = typeof Number.isInteger === \"function\"\n ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban\n : (val) => typeof val === \"number\" && Number.isFinite(val) && Math.floor(val) === val;\n function joinValues(array, separator = \" | \") {\n return array.map((val) => (typeof val === \"string\" ? `'${val}'` : val)).join(separator);\n }\n util.joinValues = joinValues;\n util.jsonStringifyReplacer = (_, value) => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n return value;\n };\n})(util || (util = {}));\nexport var objectUtil;\n(function (objectUtil) {\n objectUtil.mergeShapes = (first, second) => {\n return {\n ...first,\n ...second, // second overwrites first\n };\n };\n})(objectUtil || (objectUtil = {}));\nexport const ZodParsedType = util.arrayToEnum([\n \"string\",\n \"nan\",\n \"number\",\n \"integer\",\n \"float\",\n \"boolean\",\n \"date\",\n \"bigint\",\n \"symbol\",\n \"function\",\n \"undefined\",\n \"null\",\n \"array\",\n \"object\",\n \"unknown\",\n \"promise\",\n \"void\",\n \"never\",\n \"map\",\n \"set\",\n]);\nexport const getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case \"undefined\":\n return ZodParsedType.undefined;\n case \"string\":\n return ZodParsedType.string;\n case \"number\":\n return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n case \"boolean\":\n return ZodParsedType.boolean;\n case \"function\":\n return ZodParsedType.function;\n case \"bigint\":\n return ZodParsedType.bigint;\n case \"symbol\":\n return ZodParsedType.symbol;\n case \"object\":\n if (Array.isArray(data)) {\n return ZodParsedType.array;\n }\n if (data === null) {\n return ZodParsedType.null;\n }\n if (data.then && typeof data.then === \"function\" && data.catch && typeof data.catch === \"function\") {\n return ZodParsedType.promise;\n }\n if (typeof Map !== \"undefined\" && data instanceof Map) {\n return ZodParsedType.map;\n }\n if (typeof Set !== \"undefined\" && data instanceof Set) {\n return ZodParsedType.set;\n }\n if (typeof Date !== \"undefined\" && data instanceof Date) {\n return ZodParsedType.date;\n }\n return ZodParsedType.object;\n default:\n return ZodParsedType.unknown;\n }\n};\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAW;CACV,SAAU,MAAM;CACb,KAAK,eAAe,MAAM,CAAE;CAC5B,SAAS,SAAS,MAAM,CAAE;CAC1B,KAAK,WAAW;CAChB,SAAS,YAAY,IAAI;EACrB,MAAM,IAAI,MAAM;CACpB;CACA,KAAK,cAAc;CACnB,KAAK,eAAe,UAAU;EAC1B,MAAM,MAAM,CAAC;EACb,KAAK,MAAM,QAAQ,OACf,IAAI,QAAQ;EAEhB,OAAO;CACX;CACA,KAAK,sBAAsB,QAAQ;EAC/B,MAAM,YAAY,KAAK,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"util.js","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js"],"sourcesContent":["export var util;\n(function (util) {\n util.assertEqual = (_) => { };\n function assertIs(_arg) { }\n util.assertIs = assertIs;\n function assertNever(_x) {\n throw new Error();\n }\n util.assertNever = assertNever;\n util.arrayToEnum = (items) => {\n const obj = {};\n for (const item of items) {\n obj[item] = item;\n }\n return obj;\n };\n util.getValidEnumValues = (obj) => {\n const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== \"number\");\n const filtered = {};\n for (const k of validKeys) {\n filtered[k] = obj[k];\n }\n return util.objectValues(filtered);\n };\n util.objectValues = (obj) => {\n return util.objectKeys(obj).map(function (e) {\n return obj[e];\n });\n };\n util.objectKeys = typeof Object.keys === \"function\" // eslint-disable-line ban/ban\n ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban\n : (object) => {\n const keys = [];\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n };\n util.find = (arr, checker) => {\n for (const item of arr) {\n if (checker(item))\n return item;\n }\n return undefined;\n };\n util.isInteger = typeof Number.isInteger === \"function\"\n ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban\n : (val) => typeof val === \"number\" && Number.isFinite(val) && Math.floor(val) === val;\n function joinValues(array, separator = \" | \") {\n return array.map((val) => (typeof val === \"string\" ? `'${val}'` : val)).join(separator);\n }\n util.joinValues = joinValues;\n util.jsonStringifyReplacer = (_, value) => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n return value;\n };\n})(util || (util = {}));\nexport var objectUtil;\n(function (objectUtil) {\n objectUtil.mergeShapes = (first, second) => {\n return {\n ...first,\n ...second, // second overwrites first\n };\n };\n})(objectUtil || (objectUtil = {}));\nexport const ZodParsedType = util.arrayToEnum([\n \"string\",\n \"nan\",\n \"number\",\n \"integer\",\n \"float\",\n \"boolean\",\n \"date\",\n \"bigint\",\n \"symbol\",\n \"function\",\n \"undefined\",\n \"null\",\n \"array\",\n \"object\",\n \"unknown\",\n \"promise\",\n \"void\",\n \"never\",\n \"map\",\n \"set\",\n]);\nexport const getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case \"undefined\":\n return ZodParsedType.undefined;\n case \"string\":\n return ZodParsedType.string;\n case \"number\":\n return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n case \"boolean\":\n return ZodParsedType.boolean;\n case \"function\":\n return ZodParsedType.function;\n case \"bigint\":\n return ZodParsedType.bigint;\n case \"symbol\":\n return ZodParsedType.symbol;\n case \"object\":\n if (Array.isArray(data)) {\n return ZodParsedType.array;\n }\n if (data === null) {\n return ZodParsedType.null;\n }\n if (data.then && typeof data.then === \"function\" && data.catch && typeof data.catch === \"function\") {\n return ZodParsedType.promise;\n }\n if (typeof Map !== \"undefined\" && data instanceof Map) {\n return ZodParsedType.map;\n }\n if (typeof Set !== \"undefined\" && data instanceof Set) {\n return ZodParsedType.set;\n }\n if (typeof Date !== \"undefined\" && data instanceof Date) {\n return ZodParsedType.date;\n }\n return ZodParsedType.object;\n default:\n return ZodParsedType.unknown;\n }\n};\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAW;CACV,SAAU,MAAM;CACb,KAAK,eAAe,MAAM,CAAE;CAC5B,SAAS,SAAS,MAAM,CAAE;CAC1B,KAAK,WAAW;CAChB,SAAS,YAAY,IAAI;EACrB,MAAM,IAAI,MAAM;CACpB;CACA,KAAK,cAAc;CACnB,KAAK,eAAe,UAAU;EAC1B,MAAM,MAAM,CAAC;EACb,KAAK,MA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;GACH,GAAG;GACH,GAAG;EACP;CACJ;AACJ,EAAA,CAAG,eAAe,aAAa,CAAC,EAAE;AAClC,IAAa,gBAAgB,KAAK,YAAY;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AACD,IAAa,iBAAiB,SAAS;CAEnC,QAAQ,OADS,MACjB;EACI,KAAK,aACD,OAAO,cAAc;EACzB,KAAK,UACD,OAAO,cAAc;EACzB,KAAK,UACD,OAAO,OAAO,MAAM,IAAI,IAAI,cAAc,MAAM,cAAc;EAClE,KAAK,WACD,OAAO,cAAc;EACzB,KAAK,YACD,OAAO,cAAc;EACzB,KAAK,UACD,OAAO,cAAc;EACzB,KAAK,UACD,OAAO,cAAc;EACzB,KAAK;GACD,IAAI,MAAM,QAAQ,IAAI,GAClB,OAAO,cAAc;GAEzB,IAAI,SAAS,MACT,OAAO,cAAc;GAEzB,IAAI,KAAK,QAAQ,OAAO,KAAK,SAAS,cAAc,KAAK,SAAS,OAAO,KAAK,UAAU,YACpF,OAAO,cAAc;GAEzB,IAAI,OAAO,QAAQ,eAAe,gBAAgB,KAC9C,OAAO,cAAc;GAEzB,IAAI,OAAO,QAAQ,eAAe,gBAAgB,KAC9C,OAAO,cAAc;GAEzB,IAAI,OAAO,SAAS,eAAe,gBAAgB,MAC/C,OAAO,cAAc;GAEzB,OAAO,cAAc;EACzB,SACI,OAAO,cAAc;CAC7B;AACJ"}
|
|
@@ -3214,6 +3214,6 @@ var coerce = {
|
|
|
3214
3214
|
};
|
|
3215
3215
|
var NEVER = INVALID;
|
|
3216
3216
|
//#endregion
|
|
3217
|
-
export { BRAND, NEVER, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple,
|
|
3217
|
+
export { BRAND, NEVER, ZodType as Schema, ZodType as ZodSchema, ZodType, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEffects as ZodTransformer, ZodEnum, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSet, ZodString, ZodSymbol, ZodTuple, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, anyType as any, arrayType as array, bigIntType as bigint, booleanType as boolean, coerce, custom, dateType as date, datetimeRegex, discriminatedUnionType as discriminatedUnion, effectsType as effect, effectsType as transformer, enumType as enum, functionType as function, instanceOfType as instanceof, intersectionType as intersection, late, lazyType as lazy, literalType as literal, mapType as map, nanType as nan, nativeEnumType as nativeEnum, neverType as never, nullType as null, nullableType as nullable, numberType as number, objectType as object, oboolean, onumber, optionalType as optional, ostring, pipelineType as pipeline, preprocessType as preprocess, promiseType as promise, recordType as record, setType as set, strictObjectType as strictObject, stringType as string, symbolType as symbol, tupleType as tuple, undefinedType as undefined, unionType as union, unknownType as unknown, voidType as void };
|
|
3218
3218
|
|
|
3219
3219
|
//# sourceMappingURL=types.js.map
|