@rpgjs/server 5.0.0-beta.5 → 5.0.0-beta.7
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/dist/Player/Player.d.ts +34 -1
- package/dist/index.js +1584 -914
- package/dist/index.js.map +1 -1
- package/dist/{module-BmvXIvlE.js → module-5HOX9Ovu.js} +520 -935
- package/dist/module-5HOX9Ovu.js.map +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +12 -12
- package/src/Player/Player.ts +53 -4
- package/src/rooms/map.ts +21 -15
- package/tests/action-interaction.spec.ts +97 -0
- package/tests/item.spec.ts +72 -1
- package/tests/move.spec.ts +65 -1
- package/tests/world-maps.spec.ts +4 -0
- package/dist/module-BmvXIvlE.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as Skill, A as isArray$2, B as ProjectileMovement, C as SDEF, D as arrayFlat, E as PrebuiltGui, F as ModulesToken, G as Knockback, H as PathFollow, I as RpgModule, J as Entity, K as IceMovement, L as WorldMapsManager, M as isInstanceOf, N as isString, O as arrayUniq, P as random, Q as RpgCommonPlayer, R as RpgCommonMap, S as PDEF, T as PerlinNoise2D, U as Oscillate, V as ProjectileType, W as LinearRepulsion, X as RpgShape, Y as Vector2, Z as Direction, _ as ATK, a as isMapUpdateAuthorized, at as map, b as MAXHP, ct as BehaviorSubject, d as context, dt as Observable, et as Item, f as inject, ft as identity, g as AGI, gt as __spreadArray, h as injector, ht as __read, it as filter, j as isFunction$1, k as capitalize, l as context$1, lt as createOperatorSubscriber, m as inject$1, mt as isFunction, n as MAP_UPDATE_TOKEN_ENV, nt as __decorateMetadata, ot as from, p as setInject, pt as createErrorClass, q as Dash, r as MAP_UPDATE_TOKEN_HEADER, rt as signal$1, st as executeSchedule, t as provideServerModules, tt as __decorate, u as clearInject, ut as operate, v as DEX, w as STR, x as MAXSP, y as INT, z as SeekAvoid } from "./module-5HOX9Ovu.js";
|
|
2
2
|
//#region ../../node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.mjs
|
|
3
3
|
function dset(obj, keys, val) {
|
|
4
4
|
keys.split && (keys = keys.split("."));
|
|
@@ -126,7 +126,7 @@ var ZodIssueCode = util.arrayToEnum([
|
|
|
126
126
|
var quotelessJson = (obj) => {
|
|
127
127
|
return JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
128
128
|
};
|
|
129
|
-
var ZodError
|
|
129
|
+
var ZodError = class ZodError extends Error {
|
|
130
130
|
get errors() {
|
|
131
131
|
return this.issues;
|
|
132
132
|
}
|
|
@@ -174,7 +174,7 @@ var ZodError$1 = class ZodError$1 extends Error {
|
|
|
174
174
|
return fieldErrors;
|
|
175
175
|
}
|
|
176
176
|
static assert(value) {
|
|
177
|
-
if (!(value instanceof ZodError
|
|
177
|
+
if (!(value instanceof ZodError)) throw new Error(`Not a ZodError: ${value}`);
|
|
178
178
|
}
|
|
179
179
|
toString() {
|
|
180
180
|
return this.message;
|
|
@@ -201,8 +201,8 @@ var ZodError$1 = class ZodError$1 extends Error {
|
|
|
201
201
|
return this.flatten();
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
|
-
ZodError
|
|
205
|
-
return new ZodError
|
|
204
|
+
ZodError.create = (issues) => {
|
|
205
|
+
return new ZodError(issues);
|
|
206
206
|
};
|
|
207
207
|
var errorMap = (issue, _ctx) => {
|
|
208
208
|
let message;
|
|
@@ -444,7 +444,7 @@ var handleResult = (ctx, result) => {
|
|
|
444
444
|
success: false,
|
|
445
445
|
get error() {
|
|
446
446
|
if (this._error) return this._error;
|
|
447
|
-
const error = new ZodError
|
|
447
|
+
const error = new ZodError(ctx.common.issues);
|
|
448
448
|
this._error = error;
|
|
449
449
|
return this._error;
|
|
450
450
|
}
|
|
@@ -2379,7 +2379,7 @@ var ZodUnion$1 = class extends ZodType$1 {
|
|
|
2379
2379
|
ctx.common.issues.push(...result.ctx.common.issues);
|
|
2380
2380
|
return result.result;
|
|
2381
2381
|
}
|
|
2382
|
-
const unionErrors = results.map((result) => new ZodError
|
|
2382
|
+
const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
|
|
2383
2383
|
addIssueToContext(ctx, {
|
|
2384
2384
|
code: ZodIssueCode.invalid_union,
|
|
2385
2385
|
unionErrors
|
|
@@ -2432,7 +2432,7 @@ var ZodUnion$1 = class extends ZodType$1 {
|
|
|
2432
2432
|
ctx.common.issues.push(...dirty.ctx.common.issues);
|
|
2433
2433
|
return dirty.result;
|
|
2434
2434
|
}
|
|
2435
|
-
const unionErrors = issues.map((issues) => new ZodError
|
|
2435
|
+
const unionErrors = issues.map((issues) => new ZodError(issues));
|
|
2436
2436
|
addIssueToContext(ctx, {
|
|
2437
2437
|
code: ZodIssueCode.invalid_union,
|
|
2438
2438
|
unionErrors
|
|
@@ -2934,7 +2934,7 @@ var ZodFunction = class ZodFunction extends ZodType$1 {
|
|
|
2934
2934
|
if (this._def.returns instanceof ZodPromise) {
|
|
2935
2935
|
const me = this;
|
|
2936
2936
|
return OK(async function(...args) {
|
|
2937
|
-
const error = new ZodError
|
|
2937
|
+
const error = new ZodError([]);
|
|
2938
2938
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
2939
2939
|
error.addIssue(makeArgsIssue(args, e));
|
|
2940
2940
|
throw error;
|
|
@@ -2949,10 +2949,10 @@ var ZodFunction = class ZodFunction extends ZodType$1 {
|
|
|
2949
2949
|
const me = this;
|
|
2950
2950
|
return OK(function(...args) {
|
|
2951
2951
|
const parsedArgs = me._def.args.safeParse(args, params);
|
|
2952
|
-
if (!parsedArgs.success) throw new ZodError
|
|
2952
|
+
if (!parsedArgs.success) throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
2953
2953
|
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
2954
2954
|
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
2955
|
-
if (!parsedReturns.success) throw new ZodError
|
|
2955
|
+
if (!parsedReturns.success) throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
2956
2956
|
return parsedReturns.data;
|
|
2957
2957
|
});
|
|
2958
2958
|
}
|
|
@@ -3380,7 +3380,7 @@ var ZodCatch$1 = class extends ZodType$1 {
|
|
|
3380
3380
|
status: "valid",
|
|
3381
3381
|
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
3382
3382
|
get error() {
|
|
3383
|
-
return new ZodError
|
|
3383
|
+
return new ZodError(newCtx.common.issues);
|
|
3384
3384
|
},
|
|
3385
3385
|
input: newCtx.data
|
|
3386
3386
|
})
|
|
@@ -3390,7 +3390,7 @@ var ZodCatch$1 = class extends ZodType$1 {
|
|
|
3390
3390
|
status: "valid",
|
|
3391
3391
|
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
3392
3392
|
get error() {
|
|
3393
|
-
return new ZodError
|
|
3393
|
+
return new ZodError(newCtx.common.issues);
|
|
3394
3394
|
},
|
|
3395
3395
|
input: newCtx.data
|
|
3396
3396
|
})
|
|
@@ -3760,9 +3760,25 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3760
3760
|
NEVER: INVALID,
|
|
3761
3761
|
ZodIssueCode,
|
|
3762
3762
|
quotelessJson,
|
|
3763
|
-
ZodError
|
|
3763
|
+
ZodError
|
|
3764
3764
|
});
|
|
3765
3765
|
//#endregion
|
|
3766
|
+
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
|
|
3767
|
+
function isScheduler(value) {
|
|
3768
|
+
return value && isFunction(value.schedule);
|
|
3769
|
+
}
|
|
3770
|
+
//#endregion
|
|
3771
|
+
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/args.js
|
|
3772
|
+
function last(arr) {
|
|
3773
|
+
return arr[arr.length - 1];
|
|
3774
|
+
}
|
|
3775
|
+
function popResultSelector(args) {
|
|
3776
|
+
return isFunction(last(args)) ? args.pop() : void 0;
|
|
3777
|
+
}
|
|
3778
|
+
function popScheduler(args) {
|
|
3779
|
+
return isScheduler(last(args)) ? args.pop() : void 0;
|
|
3780
|
+
}
|
|
3781
|
+
//#endregion
|
|
3766
3782
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
|
|
3767
3783
|
var EmptyError = createErrorClass(function(_super) {
|
|
3768
3784
|
return function EmptyErrorImpl() {
|
|
@@ -3793,12 +3809,855 @@ function lastValueFrom(source, config) {
|
|
|
3793
3809
|
});
|
|
3794
3810
|
}
|
|
3795
3811
|
//#endregion
|
|
3796
|
-
//#region ../../node_modules/.pnpm
|
|
3812
|
+
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js
|
|
3813
|
+
var isArray$1 = Array.isArray;
|
|
3814
|
+
function callOrApply(fn, args) {
|
|
3815
|
+
return isArray$1(args) ? fn.apply(void 0, __spreadArray([], __read(args))) : fn(args);
|
|
3816
|
+
}
|
|
3817
|
+
function mapOneOrManyArgs(fn) {
|
|
3818
|
+
return map(function(args) {
|
|
3819
|
+
return callOrApply(fn, args);
|
|
3820
|
+
});
|
|
3821
|
+
}
|
|
3822
|
+
//#endregion
|
|
3823
|
+
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js
|
|
3824
|
+
var isArray = Array.isArray;
|
|
3825
|
+
var getPrototypeOf = Object.getPrototypeOf, objectProto = Object.prototype, getKeys = Object.keys;
|
|
3826
|
+
function argsArgArrayOrObject(args) {
|
|
3827
|
+
if (args.length === 1) {
|
|
3828
|
+
var first_1 = args[0];
|
|
3829
|
+
if (isArray(first_1)) return {
|
|
3830
|
+
args: first_1,
|
|
3831
|
+
keys: null
|
|
3832
|
+
};
|
|
3833
|
+
if (isPOJO(first_1)) {
|
|
3834
|
+
var keys = getKeys(first_1);
|
|
3835
|
+
return {
|
|
3836
|
+
args: keys.map(function(key) {
|
|
3837
|
+
return first_1[key];
|
|
3838
|
+
}),
|
|
3839
|
+
keys
|
|
3840
|
+
};
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
return {
|
|
3844
|
+
args,
|
|
3845
|
+
keys: null
|
|
3846
|
+
};
|
|
3847
|
+
}
|
|
3848
|
+
function isPOJO(obj) {
|
|
3849
|
+
return obj && typeof obj === "object" && getPrototypeOf(obj) === objectProto;
|
|
3850
|
+
}
|
|
3851
|
+
//#endregion
|
|
3852
|
+
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/util/createObject.js
|
|
3853
|
+
function createObject(keys, values) {
|
|
3854
|
+
return keys.reduce(function(result, key, i) {
|
|
3855
|
+
return result[key] = values[i], result;
|
|
3856
|
+
}, {});
|
|
3857
|
+
}
|
|
3858
|
+
//#endregion
|
|
3859
|
+
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js
|
|
3860
|
+
function combineLatest() {
|
|
3861
|
+
var args = [];
|
|
3862
|
+
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
|
|
3863
|
+
var scheduler = popScheduler(args);
|
|
3864
|
+
var resultSelector = popResultSelector(args);
|
|
3865
|
+
var _a = argsArgArrayOrObject(args), observables = _a.args, keys = _a.keys;
|
|
3866
|
+
if (observables.length === 0) return from([], scheduler);
|
|
3867
|
+
var result = new Observable(combineLatestInit(observables, scheduler, keys ? function(values) {
|
|
3868
|
+
return createObject(keys, values);
|
|
3869
|
+
} : identity));
|
|
3870
|
+
return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result;
|
|
3871
|
+
}
|
|
3872
|
+
function combineLatestInit(observables, scheduler, valueTransform) {
|
|
3873
|
+
if (valueTransform === void 0) valueTransform = identity;
|
|
3874
|
+
return function(subscriber) {
|
|
3875
|
+
maybeSchedule(scheduler, function() {
|
|
3876
|
+
var length = observables.length;
|
|
3877
|
+
var values = new Array(length);
|
|
3878
|
+
var active = length;
|
|
3879
|
+
var remainingFirstValues = length;
|
|
3880
|
+
var _loop_1 = function(i) {
|
|
3881
|
+
maybeSchedule(scheduler, function() {
|
|
3882
|
+
var source = from(observables[i], scheduler);
|
|
3883
|
+
var hasFirstValue = false;
|
|
3884
|
+
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
3885
|
+
values[i] = value;
|
|
3886
|
+
if (!hasFirstValue) {
|
|
3887
|
+
hasFirstValue = true;
|
|
3888
|
+
remainingFirstValues--;
|
|
3889
|
+
}
|
|
3890
|
+
if (!remainingFirstValues) subscriber.next(valueTransform(values.slice()));
|
|
3891
|
+
}, function() {
|
|
3892
|
+
if (!--active) subscriber.complete();
|
|
3893
|
+
}));
|
|
3894
|
+
}, subscriber);
|
|
3895
|
+
};
|
|
3896
|
+
for (var i = 0; i < length; i++) _loop_1(i);
|
|
3897
|
+
}, subscriber);
|
|
3898
|
+
};
|
|
3899
|
+
}
|
|
3900
|
+
function maybeSchedule(scheduler, execute, subscription) {
|
|
3901
|
+
if (scheduler) executeSchedule(subscription, scheduler, execute);
|
|
3902
|
+
else execute();
|
|
3903
|
+
}
|
|
3904
|
+
//#endregion
|
|
3905
|
+
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/finalize.js
|
|
3906
|
+
function finalize$1(callback) {
|
|
3907
|
+
return operate(function(source, subscriber) {
|
|
3908
|
+
try {
|
|
3909
|
+
source.subscribe(subscriber);
|
|
3910
|
+
} finally {
|
|
3911
|
+
subscriber.add(callback);
|
|
3912
|
+
}
|
|
3913
|
+
});
|
|
3914
|
+
}
|
|
3915
|
+
//#endregion
|
|
3916
|
+
//#region ../../node_modules/.pnpm/@signe+reactive@2.10.0/node_modules/@signe/reactive/dist/index.js
|
|
3917
|
+
var ArraySubject = class extends BehaviorSubject {
|
|
3918
|
+
constructor(items = []) {
|
|
3919
|
+
super({
|
|
3920
|
+
type: "init",
|
|
3921
|
+
items
|
|
3922
|
+
});
|
|
3923
|
+
this._items = [];
|
|
3924
|
+
this.createProxy(items);
|
|
3925
|
+
}
|
|
3926
|
+
createProxy(items) {
|
|
3927
|
+
this._items = new Proxy(items, {
|
|
3928
|
+
get: (target, prop, receiver) => {
|
|
3929
|
+
const origMethod = target[prop];
|
|
3930
|
+
if (typeof origMethod === "function") return (...args) => {
|
|
3931
|
+
let changeType = "update";
|
|
3932
|
+
let index = void 0;
|
|
3933
|
+
let isMutateFn = false;
|
|
3934
|
+
let itemsToEmit = [];
|
|
3935
|
+
let changeSplice = true;
|
|
3936
|
+
switch (prop) {
|
|
3937
|
+
case "push":
|
|
3938
|
+
index = target.length;
|
|
3939
|
+
changeType = "add";
|
|
3940
|
+
isMutateFn = true;
|
|
3941
|
+
break;
|
|
3942
|
+
case "pop":
|
|
3943
|
+
index = target.length - 1;
|
|
3944
|
+
changeType = "remove";
|
|
3945
|
+
isMutateFn = true;
|
|
3946
|
+
break;
|
|
3947
|
+
case "unshift":
|
|
3948
|
+
index = 0;
|
|
3949
|
+
changeType = "add";
|
|
3950
|
+
isMutateFn = true;
|
|
3951
|
+
break;
|
|
3952
|
+
case "shift":
|
|
3953
|
+
index = 0;
|
|
3954
|
+
changeType = "remove";
|
|
3955
|
+
isMutateFn = true;
|
|
3956
|
+
break;
|
|
3957
|
+
case "splice":
|
|
3958
|
+
index = args[0];
|
|
3959
|
+
const deleteCount = args[1];
|
|
3960
|
+
const newItems = args.slice(2);
|
|
3961
|
+
itemsToEmit = newItems;
|
|
3962
|
+
if (deleteCount > 0 && newItems.length === 0) changeType = "remove";
|
|
3963
|
+
else if (deleteCount === 0 && newItems.length > 0) changeType = "add";
|
|
3964
|
+
else if (deleteCount === 0 && newItems.length === 0) changeSplice = false;
|
|
3965
|
+
else changeType = "update";
|
|
3966
|
+
isMutateFn = true;
|
|
3967
|
+
break;
|
|
3968
|
+
}
|
|
3969
|
+
const result = origMethod.apply(target, args);
|
|
3970
|
+
if (isMutateFn && changeSplice) if (prop === "splice") this.next({
|
|
3971
|
+
type: changeType,
|
|
3972
|
+
index,
|
|
3973
|
+
items: itemsToEmit
|
|
3974
|
+
});
|
|
3975
|
+
else this.next({
|
|
3976
|
+
type: changeType,
|
|
3977
|
+
index,
|
|
3978
|
+
items: args
|
|
3979
|
+
});
|
|
3980
|
+
return result;
|
|
3981
|
+
};
|
|
3982
|
+
return Reflect.get(target, prop, receiver);
|
|
3983
|
+
},
|
|
3984
|
+
set: (target, prop, value) => {
|
|
3985
|
+
const index = !isNaN(Number(prop)) ? Number(prop) : void 0;
|
|
3986
|
+
target[prop] = value;
|
|
3987
|
+
this.next({
|
|
3988
|
+
type: "update",
|
|
3989
|
+
index,
|
|
3990
|
+
items: [value]
|
|
3991
|
+
});
|
|
3992
|
+
return true;
|
|
3993
|
+
}
|
|
3994
|
+
});
|
|
3995
|
+
}
|
|
3996
|
+
get items() {
|
|
3997
|
+
return this._items;
|
|
3998
|
+
}
|
|
3999
|
+
set items(newItems) {
|
|
4000
|
+
this.createProxy(newItems);
|
|
4001
|
+
this.next({
|
|
4002
|
+
type: "reset",
|
|
4003
|
+
items: newItems
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
};
|
|
4007
|
+
var isArraySubject = (value) => {
|
|
4008
|
+
return "_items" in value;
|
|
4009
|
+
};
|
|
4010
|
+
var ObjectSubject = class extends BehaviorSubject {
|
|
4011
|
+
constructor(obj = {}) {
|
|
4012
|
+
super({
|
|
4013
|
+
type: "init",
|
|
4014
|
+
value: obj
|
|
4015
|
+
});
|
|
4016
|
+
this.createProxy(obj);
|
|
4017
|
+
}
|
|
4018
|
+
createProxy(obj) {
|
|
4019
|
+
this._obj = new Proxy(obj, {
|
|
4020
|
+
get: (target, prop, receiver) => {
|
|
4021
|
+
return Reflect.get(target, prop, receiver);
|
|
4022
|
+
},
|
|
4023
|
+
set: (target, prop, value, receiver) => {
|
|
4024
|
+
const key = prop;
|
|
4025
|
+
const changeType = key in target ? "update" : "add";
|
|
4026
|
+
target[key] = value;
|
|
4027
|
+
this.next({
|
|
4028
|
+
type: changeType,
|
|
4029
|
+
key,
|
|
4030
|
+
value
|
|
4031
|
+
});
|
|
4032
|
+
return true;
|
|
4033
|
+
},
|
|
4034
|
+
deleteProperty: (target, prop) => {
|
|
4035
|
+
const key = prop;
|
|
4036
|
+
if (key in target) {
|
|
4037
|
+
const value = target[key];
|
|
4038
|
+
delete target[key];
|
|
4039
|
+
this.next({
|
|
4040
|
+
type: "remove",
|
|
4041
|
+
key,
|
|
4042
|
+
value
|
|
4043
|
+
});
|
|
4044
|
+
return true;
|
|
4045
|
+
}
|
|
4046
|
+
return false;
|
|
4047
|
+
}
|
|
4048
|
+
});
|
|
4049
|
+
}
|
|
4050
|
+
get obj() {
|
|
4051
|
+
return this._obj;
|
|
4052
|
+
}
|
|
4053
|
+
set obj(newObj) {
|
|
4054
|
+
this.createProxy(newObj);
|
|
4055
|
+
this.next({
|
|
4056
|
+
type: "reset",
|
|
4057
|
+
value: newObj
|
|
4058
|
+
});
|
|
4059
|
+
}
|
|
4060
|
+
};
|
|
4061
|
+
var isObjectSubject = (value) => {
|
|
4062
|
+
return "_obj" in value;
|
|
4063
|
+
};
|
|
4064
|
+
var getGlobalReactiveStore = () => {
|
|
4065
|
+
const globalKey = "__REACTIVE_STORE__";
|
|
4066
|
+
if (typeof globalThis !== "undefined") {
|
|
4067
|
+
if (!globalThis[globalKey]) globalThis[globalKey] = {
|
|
4068
|
+
currentDependencyTracker: null,
|
|
4069
|
+
currentSubscriptionsTracker: null
|
|
4070
|
+
};
|
|
4071
|
+
return globalThis[globalKey];
|
|
4072
|
+
}
|
|
4073
|
+
let globalObj;
|
|
4074
|
+
if (typeof window !== "undefined") globalObj = window;
|
|
4075
|
+
else if (typeof process !== "undefined" && process.versions && process.versions.node) globalObj = Function("return this")();
|
|
4076
|
+
else if (typeof self !== "undefined") globalObj = self;
|
|
4077
|
+
else {
|
|
4078
|
+
console.warn("Unable to find global object, using local instance");
|
|
4079
|
+
return {
|
|
4080
|
+
currentDependencyTracker: null,
|
|
4081
|
+
currentSubscriptionsTracker: null
|
|
4082
|
+
};
|
|
4083
|
+
}
|
|
4084
|
+
if (!globalObj[globalKey]) globalObj[globalKey] = {
|
|
4085
|
+
currentDependencyTracker: null,
|
|
4086
|
+
currentSubscriptionsTracker: null
|
|
4087
|
+
};
|
|
4088
|
+
return globalObj[globalKey];
|
|
4089
|
+
};
|
|
4090
|
+
var reactiveStore = getGlobalReactiveStore();
|
|
4091
|
+
var trackDependency = (signal2) => {
|
|
4092
|
+
if (reactiveStore.currentDependencyTracker) reactiveStore.currentDependencyTracker(signal2);
|
|
4093
|
+
};
|
|
4094
|
+
function signal(defaultValue, options) {
|
|
4095
|
+
let subject;
|
|
4096
|
+
if (Array.isArray(defaultValue)) subject = new ArraySubject(defaultValue);
|
|
4097
|
+
else if (typeof defaultValue === "object" && defaultValue !== null) subject = new ObjectSubject(defaultValue);
|
|
4098
|
+
else subject = new BehaviorSubject(defaultValue);
|
|
4099
|
+
const getValue = () => {
|
|
4100
|
+
if (subject instanceof ArraySubject) return subject.items;
|
|
4101
|
+
else if (subject instanceof ObjectSubject) return subject.obj;
|
|
4102
|
+
return subject.value;
|
|
4103
|
+
};
|
|
4104
|
+
const fn = function() {
|
|
4105
|
+
trackDependency(fn);
|
|
4106
|
+
return getValue();
|
|
4107
|
+
};
|
|
4108
|
+
fn.set = (value) => {
|
|
4109
|
+
const currentValue = getValue();
|
|
4110
|
+
let shouldEmit = true;
|
|
4111
|
+
if (options?.equal) shouldEmit = !options.equal(currentValue, value);
|
|
4112
|
+
else shouldEmit = currentValue !== value;
|
|
4113
|
+
if (shouldEmit) if (subject instanceof ArraySubject) subject.items = value;
|
|
4114
|
+
else if (subject instanceof ObjectSubject) subject.obj = value;
|
|
4115
|
+
else subject.next(value);
|
|
4116
|
+
};
|
|
4117
|
+
fn._isFrozen = false;
|
|
4118
|
+
fn.freeze = () => {
|
|
4119
|
+
fn._isFrozen = true;
|
|
4120
|
+
};
|
|
4121
|
+
fn.unfreeze = () => {
|
|
4122
|
+
fn._isFrozen = false;
|
|
4123
|
+
if (subject instanceof ArraySubject) subject.next({
|
|
4124
|
+
type: "init",
|
|
4125
|
+
items: subject.items
|
|
4126
|
+
});
|
|
4127
|
+
else if (subject instanceof ObjectSubject) subject.next({
|
|
4128
|
+
type: "init",
|
|
4129
|
+
value: subject.obj
|
|
4130
|
+
});
|
|
4131
|
+
else subject.next(subject.value);
|
|
4132
|
+
};
|
|
4133
|
+
fn.mutate = (mutateFn) => {
|
|
4134
|
+
mutateFn(getValue());
|
|
4135
|
+
};
|
|
4136
|
+
fn.update = (updateFn) => {
|
|
4137
|
+
const updatedValue = updateFn(getValue());
|
|
4138
|
+
fn.set(updatedValue);
|
|
4139
|
+
};
|
|
4140
|
+
fn.observable = subject.asObservable().pipe(filter(() => !fn._isFrozen));
|
|
4141
|
+
fn._subject = subject;
|
|
4142
|
+
return fn;
|
|
4143
|
+
}
|
|
4144
|
+
function isSignal(value) {
|
|
4145
|
+
return !!(value && value.observable);
|
|
4146
|
+
}
|
|
4147
|
+
function isComputed(value) {
|
|
4148
|
+
return isSignal(value) && !!value.dependencies;
|
|
4149
|
+
}
|
|
4150
|
+
function computed(computeFunction, disposableFn) {
|
|
4151
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
4152
|
+
let init = true;
|
|
4153
|
+
let lastComputedValue;
|
|
4154
|
+
const previousTracker = reactiveStore.currentDependencyTracker;
|
|
4155
|
+
reactiveStore.currentDependencyTracker = (signal2) => {
|
|
4156
|
+
dependencies.add(signal2);
|
|
4157
|
+
};
|
|
4158
|
+
lastComputedValue = computeFunction();
|
|
4159
|
+
if (computeFunction["isEffect"]) disposableFn = lastComputedValue;
|
|
4160
|
+
reactiveStore.currentDependencyTracker = previousTracker;
|
|
4161
|
+
const computedObservable = combineLatest([...dependencies].map((dep) => {
|
|
4162
|
+
if (isComputed(dep) && "dependencies" in dep) {
|
|
4163
|
+
const computedDep = dep;
|
|
4164
|
+
if (computedDep.dependencies.size === 0) return new BehaviorSubject(computedDep()).asObservable();
|
|
4165
|
+
}
|
|
4166
|
+
return dep.observable;
|
|
4167
|
+
})).pipe(filter(() => !init), map(() => computeFunction()), finalize$1(() => disposableFn?.()));
|
|
4168
|
+
const fn = function() {
|
|
4169
|
+
trackDependency(fn);
|
|
4170
|
+
return lastComputedValue;
|
|
4171
|
+
};
|
|
4172
|
+
fn.observable = computedObservable;
|
|
4173
|
+
fn.subscription = computedObservable.subscribe((value) => {
|
|
4174
|
+
lastComputedValue = value;
|
|
4175
|
+
});
|
|
4176
|
+
fn.dependencies = dependencies;
|
|
4177
|
+
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
4178
|
+
init = false;
|
|
4179
|
+
return fn;
|
|
4180
|
+
}
|
|
4181
|
+
function linkedSignal(computationOrOptions, simpleOptions) {
|
|
4182
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
4183
|
+
let init = true;
|
|
4184
|
+
let lastComputedValue;
|
|
4185
|
+
let computeFunction;
|
|
4186
|
+
let sourceSignal;
|
|
4187
|
+
let computationFn;
|
|
4188
|
+
let equalFn;
|
|
4189
|
+
let previousValue;
|
|
4190
|
+
let isOverridden = false;
|
|
4191
|
+
let overriddenValue;
|
|
4192
|
+
let depVersion = 0;
|
|
4193
|
+
let overrideDepVersion = null;
|
|
4194
|
+
if (typeof computationOrOptions === "function") {
|
|
4195
|
+
computeFunction = computationOrOptions;
|
|
4196
|
+
equalFn = simpleOptions?.equal;
|
|
4197
|
+
} else {
|
|
4198
|
+
const options = computationOrOptions;
|
|
4199
|
+
sourceSignal = options.source;
|
|
4200
|
+
computationFn = options.computation;
|
|
4201
|
+
equalFn = options.equal;
|
|
4202
|
+
if (typeof sourceSignal === "function" && !isSignal(sourceSignal)) {
|
|
4203
|
+
const sourceFn = sourceSignal;
|
|
4204
|
+
computeFunction = () => {
|
|
4205
|
+
const sourceValue = sourceFn();
|
|
4206
|
+
if (computationFn.length > 1) {
|
|
4207
|
+
const result = computationFn(sourceValue, previousValue);
|
|
4208
|
+
previousValue = {
|
|
4209
|
+
source: sourceValue,
|
|
4210
|
+
value: result
|
|
4211
|
+
};
|
|
4212
|
+
return result;
|
|
4213
|
+
} else {
|
|
4214
|
+
const result = computationFn(sourceValue);
|
|
4215
|
+
previousValue = {
|
|
4216
|
+
source: sourceValue,
|
|
4217
|
+
value: result
|
|
4218
|
+
};
|
|
4219
|
+
return result;
|
|
4220
|
+
}
|
|
4221
|
+
};
|
|
4222
|
+
} else {
|
|
4223
|
+
const source = typeof sourceSignal === "function" ? sourceSignal : sourceSignal;
|
|
4224
|
+
computeFunction = () => {
|
|
4225
|
+
const sourceValue = source();
|
|
4226
|
+
if (computationFn.length > 1) {
|
|
4227
|
+
const result = computationFn(sourceValue, previousValue);
|
|
4228
|
+
previousValue = {
|
|
4229
|
+
source: sourceValue,
|
|
4230
|
+
value: result
|
|
4231
|
+
};
|
|
4232
|
+
return result;
|
|
4233
|
+
} else {
|
|
4234
|
+
const result = computationFn(sourceValue);
|
|
4235
|
+
previousValue = {
|
|
4236
|
+
source: sourceValue,
|
|
4237
|
+
value: result
|
|
4238
|
+
};
|
|
4239
|
+
return result;
|
|
4240
|
+
}
|
|
4241
|
+
};
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
const previousTracker = reactiveStore.currentDependencyTracker;
|
|
4245
|
+
reactiveStore.currentDependencyTracker = (signal2) => {
|
|
4246
|
+
dependencies.add(signal2);
|
|
4247
|
+
};
|
|
4248
|
+
if (sourceSignal && typeof sourceSignal === "function" && !isSignal(sourceSignal)) lastComputedValue = computeFunction();
|
|
4249
|
+
else if (sourceSignal && isSignal(sourceSignal)) {
|
|
4250
|
+
dependencies.add(sourceSignal);
|
|
4251
|
+
lastComputedValue = computeFunction();
|
|
4252
|
+
} else lastComputedValue = computeFunction();
|
|
4253
|
+
reactiveStore.currentDependencyTracker = previousTracker;
|
|
4254
|
+
const subject = new BehaviorSubject(lastComputedValue);
|
|
4255
|
+
const observables = [...dependencies].map((dep) => {
|
|
4256
|
+
if (isComputed(dep) && "dependencies" in dep) {
|
|
4257
|
+
const computedDep = dep;
|
|
4258
|
+
if (computedDep.dependencies.size === 0) return new BehaviorSubject(computedDep()).asObservable();
|
|
4259
|
+
}
|
|
4260
|
+
return dep.observable;
|
|
4261
|
+
});
|
|
4262
|
+
let linkedObservable;
|
|
4263
|
+
if (observables.length > 0) linkedObservable = combineLatest(observables).pipe(filter(() => !init), map(() => {
|
|
4264
|
+
const computed2 = computeFunction();
|
|
4265
|
+
if (equalFn) {
|
|
4266
|
+
if (!equalFn(lastComputedValue, computed2)) {
|
|
4267
|
+
lastComputedValue = computed2;
|
|
4268
|
+
isOverridden = false;
|
|
4269
|
+
}
|
|
4270
|
+
} else if (lastComputedValue !== computed2) {
|
|
4271
|
+
lastComputedValue = computed2;
|
|
4272
|
+
isOverridden = false;
|
|
4273
|
+
}
|
|
4274
|
+
return lastComputedValue;
|
|
4275
|
+
}));
|
|
4276
|
+
else linkedObservable = subject.asObservable().pipe(filter(() => !init));
|
|
4277
|
+
const fn = function() {
|
|
4278
|
+
trackDependency(fn);
|
|
4279
|
+
if (isOverridden && dependencies.size > 0) {
|
|
4280
|
+
if (overrideDepVersion !== depVersion) {
|
|
4281
|
+
const computed2 = computeFunction();
|
|
4282
|
+
isOverridden = false;
|
|
4283
|
+
overriddenValue = void 0;
|
|
4284
|
+
lastComputedValue = computed2;
|
|
4285
|
+
overrideDepVersion = null;
|
|
4286
|
+
return computed2;
|
|
4287
|
+
}
|
|
4288
|
+
return overriddenValue;
|
|
4289
|
+
}
|
|
4290
|
+
if (isOverridden) return overriddenValue;
|
|
4291
|
+
if (dependencies.size === 0) lastComputedValue = computeFunction();
|
|
4292
|
+
return lastComputedValue;
|
|
4293
|
+
};
|
|
4294
|
+
fn.observable = new Observable((observer) => {
|
|
4295
|
+
const depSubscription = linkedObservable.subscribe((value) => {
|
|
4296
|
+
if (dependencies.size > 0) {
|
|
4297
|
+
depVersion++;
|
|
4298
|
+
isOverridden = false;
|
|
4299
|
+
overrideDepVersion = null;
|
|
4300
|
+
lastComputedValue = value;
|
|
4301
|
+
} else lastComputedValue = value;
|
|
4302
|
+
observer.next(value);
|
|
4303
|
+
});
|
|
4304
|
+
let subjectSubscription;
|
|
4305
|
+
if (dependencies.size === 0) subjectSubscription = subject.pipe(filter(() => !init)).subscribe((value) => {
|
|
4306
|
+
observer.next(value);
|
|
4307
|
+
});
|
|
4308
|
+
observer.next(lastComputedValue);
|
|
4309
|
+
return () => {
|
|
4310
|
+
depSubscription.unsubscribe();
|
|
4311
|
+
if (subjectSubscription) subjectSubscription.unsubscribe();
|
|
4312
|
+
};
|
|
4313
|
+
});
|
|
4314
|
+
fn.subscription = fn.observable.subscribe(() => {});
|
|
4315
|
+
fn.dependencies = dependencies;
|
|
4316
|
+
fn._subject = subject;
|
|
4317
|
+
fn.set = (value) => {
|
|
4318
|
+
if (!isOverridden) {
|
|
4319
|
+
overrideDepVersion = depVersion;
|
|
4320
|
+
if (computationFn && sourceSignal) previousValue = {
|
|
4321
|
+
source: untracked(() => {
|
|
4322
|
+
if (typeof sourceSignal === "function") {
|
|
4323
|
+
const source = sourceSignal;
|
|
4324
|
+
return isSignal(source) ? source() : sourceSignal();
|
|
4325
|
+
}
|
|
4326
|
+
return sourceSignal();
|
|
4327
|
+
}),
|
|
4328
|
+
value
|
|
4329
|
+
};
|
|
4330
|
+
}
|
|
4331
|
+
isOverridden = true;
|
|
4332
|
+
overriddenValue = value;
|
|
4333
|
+
lastComputedValue = value;
|
|
4334
|
+
subject.next(value);
|
|
4335
|
+
};
|
|
4336
|
+
reactiveStore.currentSubscriptionsTracker?.(fn.subscription);
|
|
4337
|
+
init = false;
|
|
4338
|
+
return fn;
|
|
4339
|
+
}
|
|
4340
|
+
function untracked(fn) {
|
|
4341
|
+
const prevDepTracker = reactiveStore.currentDependencyTracker;
|
|
4342
|
+
const prevSubTracker = reactiveStore.currentSubscriptionsTracker;
|
|
4343
|
+
reactiveStore.currentDependencyTracker = null;
|
|
4344
|
+
reactiveStore.currentSubscriptionsTracker = null;
|
|
4345
|
+
try {
|
|
4346
|
+
return fn();
|
|
4347
|
+
} finally {
|
|
4348
|
+
reactiveStore.currentDependencyTracker = prevDepTracker;
|
|
4349
|
+
reactiveStore.currentSubscriptionsTracker = prevSubTracker;
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4352
|
+
function effect(fn) {
|
|
4353
|
+
fn["isEffect"] = true;
|
|
4354
|
+
return computed(fn);
|
|
4355
|
+
}
|
|
4356
|
+
//#endregion
|
|
4357
|
+
//#region ../../node_modules/.pnpm/@signe+sync@2.10.0/node_modules/@signe/sync/dist/index.js
|
|
4358
|
+
function isClass$1(obj) {
|
|
4359
|
+
return typeof obj === "function" && obj.prototype && obj.prototype.constructor === obj;
|
|
4360
|
+
}
|
|
4361
|
+
var isObject$2 = (item) => item && typeof item === "object" && !Array.isArray(item) && item !== null;
|
|
4362
|
+
function isInstanceOfClass(value) {
|
|
4363
|
+
if (value === null || typeof value !== "object" || value === void 0 || Array.isArray(value)) return false;
|
|
4364
|
+
return Object.getPrototypeOf(value) !== Object.prototype;
|
|
4365
|
+
}
|
|
4366
|
+
function generateShortUUID() {
|
|
4367
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
4368
|
+
let uuid = "";
|
|
4369
|
+
for (let i = 0; i < 8; i++) {
|
|
4370
|
+
const randomIndex = Math.floor(Math.random() * 62);
|
|
4371
|
+
uuid += chars[randomIndex];
|
|
4372
|
+
}
|
|
4373
|
+
return uuid;
|
|
4374
|
+
}
|
|
4375
|
+
var DELETE_TOKEN = "$delete";
|
|
4376
|
+
var syncClass = (instance, options = {}) => {
|
|
4377
|
+
const cacheSync = /* @__PURE__ */ new Map();
|
|
4378
|
+
const cachePersist = /* @__PURE__ */ new Map();
|
|
4379
|
+
instance.$valuesChanges = {
|
|
4380
|
+
set: (path, value) => {
|
|
4381
|
+
cacheSync.set(path, value);
|
|
4382
|
+
options.onSync?.(cacheSync);
|
|
4383
|
+
},
|
|
4384
|
+
setPersist: (path, value) => {
|
|
4385
|
+
if (path == "") path = ".";
|
|
4386
|
+
cachePersist.set(path, value);
|
|
4387
|
+
options.onPersist?.(cachePersist);
|
|
4388
|
+
},
|
|
4389
|
+
has: (path) => {
|
|
4390
|
+
return cacheSync.has(path);
|
|
4391
|
+
},
|
|
4392
|
+
get: (path) => {
|
|
4393
|
+
return cacheSync.get(path);
|
|
4394
|
+
}
|
|
4395
|
+
};
|
|
4396
|
+
createSyncClass(instance);
|
|
4397
|
+
};
|
|
4398
|
+
function createStatesSnapshot(instance) {
|
|
4399
|
+
let persistObject = {};
|
|
4400
|
+
if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
|
|
4401
|
+
const signal = instance.$snapshot.get(key);
|
|
4402
|
+
const persist2 = signal.options.persist ?? true;
|
|
4403
|
+
let value = signal();
|
|
4404
|
+
if (isObject$2(value) || Array.isArray(value)) continue;
|
|
4405
|
+
if (persist2) persistObject[key] = value;
|
|
4406
|
+
}
|
|
4407
|
+
return persistObject;
|
|
4408
|
+
}
|
|
4409
|
+
var SNAPSHOT_SKIP = Symbol("snapshot-skip");
|
|
4410
|
+
var serializeSnapshotDeep = (value, path, options, seen) => {
|
|
4411
|
+
if (isSignal(value)) return serializeSnapshotDeep(value(), path, options, seen);
|
|
4412
|
+
if (value instanceof Map) return SNAPSHOT_SKIP;
|
|
4413
|
+
if (options.filter && !options.filter(value, path)) return SNAPSHOT_SKIP;
|
|
4414
|
+
if (value instanceof Date) return options.dateToString ? options.dateToString(value) : value.toISOString();
|
|
4415
|
+
if (value && typeof value === "object") {
|
|
4416
|
+
if (seen.has(value)) return SNAPSHOT_SKIP;
|
|
4417
|
+
seen.add(value);
|
|
4418
|
+
if (Array.isArray(value)) {
|
|
4419
|
+
const result2 = [];
|
|
4420
|
+
value.forEach((item, index) => {
|
|
4421
|
+
const serialized = serializeSnapshotDeep(item, path ? `${path}.${index}` : String(index), options, seen);
|
|
4422
|
+
if (serialized !== SNAPSHOT_SKIP) result2.push(serialized);
|
|
4423
|
+
});
|
|
4424
|
+
return result2;
|
|
4425
|
+
}
|
|
4426
|
+
const result = {};
|
|
4427
|
+
const idKey = isInstanceOfClass(value) ? value.constructor?._propertyMetadata?.get("id") : void 0;
|
|
4428
|
+
const entries = Object.entries(value).filter(([key]) => isInstanceOfClass(value) ? key.startsWith("__") || (idKey ? key === idKey : false) : true);
|
|
4429
|
+
for (const [key, childValue] of entries) {
|
|
4430
|
+
const normalizedKey = key.startsWith("__") ? key.slice(2) : key;
|
|
4431
|
+
const serialized = serializeSnapshotDeep(childValue, path ? `${path}.${normalizedKey}` : normalizedKey, options, seen);
|
|
4432
|
+
if (serialized !== SNAPSHOT_SKIP) result[normalizedKey] = serialized;
|
|
4433
|
+
}
|
|
4434
|
+
return result;
|
|
4435
|
+
}
|
|
4436
|
+
return value;
|
|
4437
|
+
};
|
|
4438
|
+
function createStatesSnapshotDeep(instance, options = {}) {
|
|
4439
|
+
const persistObject = {};
|
|
4440
|
+
if (instance?.$snapshot) for (const key of instance.$snapshot.keys()) {
|
|
4441
|
+
const signal = instance.$snapshot.get(key);
|
|
4442
|
+
if (!(signal.options.persist ?? true)) continue;
|
|
4443
|
+
const serialized = serializeSnapshotDeep(signal(), key, options, /* @__PURE__ */ new WeakSet());
|
|
4444
|
+
if (serialized !== SNAPSHOT_SKIP) persistObject[key] = serialized;
|
|
4445
|
+
}
|
|
4446
|
+
return persistObject;
|
|
4447
|
+
}
|
|
4448
|
+
function setMetadata(target, key, value) {
|
|
4449
|
+
const propId = target.constructor._propertyMetadata?.get(key);
|
|
4450
|
+
if (propId) if (isSignal(target[propId])) target[propId].set(value);
|
|
4451
|
+
else target[propId] = value;
|
|
4452
|
+
}
|
|
4453
|
+
var createSyncClass = (currentClass, parentKey = null, parentClass = null, path = "") => {
|
|
4454
|
+
currentClass.$path = path;
|
|
4455
|
+
if (parentClass) currentClass.$valuesChanges = parentClass.$valuesChanges;
|
|
4456
|
+
if (parentKey) setMetadata(currentClass, "id", parentKey);
|
|
4457
|
+
if (currentClass.$snapshot) for (const key of currentClass.$snapshot.keys()) {
|
|
4458
|
+
const signal = currentClass.$snapshot.get(key);
|
|
4459
|
+
const syncToClient = signal.options?.syncToClient ?? true;
|
|
4460
|
+
const persist2 = signal.options?.persist ?? true;
|
|
4461
|
+
const transform = signal.options?.transform;
|
|
4462
|
+
let signalValue = signal();
|
|
4463
|
+
if (transform) signalValue = transform(signalValue);
|
|
4464
|
+
if (isObject$2(signalValue) || Array.isArray(signalValue)) signalValue = { ...signalValue };
|
|
4465
|
+
const transformedValue = signalValue;
|
|
4466
|
+
const newPath = (path ? path + "." : "") + key;
|
|
4467
|
+
if (syncToClient) currentClass.$valuesChanges.set(newPath, transformedValue);
|
|
4468
|
+
if (persist2) {
|
|
4469
|
+
if (parentClass) currentClass.$valuesChanges.setPersist(path, transformedValue);
|
|
4470
|
+
}
|
|
4471
|
+
if (isComputed(signal)) signal.observable.subscribe((newValue) => {
|
|
4472
|
+
if (syncToClient) {
|
|
4473
|
+
const transformedNewValue = transform ? transform(newValue) : newValue;
|
|
4474
|
+
currentClass.$valuesChanges.set(newPath, transformedNewValue);
|
|
4475
|
+
}
|
|
4476
|
+
});
|
|
4477
|
+
}
|
|
4478
|
+
};
|
|
4479
|
+
var type = (_signal, path, options = {}, currentInstance) => {
|
|
4480
|
+
const { syncToClient = true, persist: persist2 = true, transform } = options;
|
|
4481
|
+
let init = true;
|
|
4482
|
+
const handleObjectSubject = (value, propPath) => {
|
|
4483
|
+
const newPath = `${propPath}${value.key ? `.${value.key}` : ""}`;
|
|
4484
|
+
if ([
|
|
4485
|
+
"add",
|
|
4486
|
+
"reset",
|
|
4487
|
+
"update"
|
|
4488
|
+
].includes(value.type)) if (isInstanceOfClass(value.value)) createSyncClass(value.value, value.key, currentInstance, newPath);
|
|
4489
|
+
else if (value.type === "update" && (isObject$2(value.value) || Array.isArray(value.value))) createSyncClass(value.value, value.key, currentInstance, newPath);
|
|
4490
|
+
else savePath(newPath, value.value);
|
|
4491
|
+
else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
|
|
4492
|
+
};
|
|
4493
|
+
const handleArraySubject = (value, propPath) => {
|
|
4494
|
+
if (value.type === "reset" && Array.isArray(value.items)) {
|
|
4495
|
+
value.items.forEach((item, index) => {
|
|
4496
|
+
const newPath2 = `${propPath}.${index}`;
|
|
4497
|
+
if (isInstanceOfClass(item)) createSyncClass(item, value.key, currentInstance, newPath2);
|
|
4498
|
+
else savePath(newPath2, item);
|
|
4499
|
+
});
|
|
4500
|
+
return;
|
|
4501
|
+
}
|
|
4502
|
+
const newPath = `${propPath}.${value.index}`;
|
|
4503
|
+
const firstItem = value.items?.[0];
|
|
4504
|
+
if (["add", "update"].includes(value.type) && firstItem !== void 0) if (isInstanceOfClass(firstItem)) createSyncClass(firstItem, value.key, currentInstance, newPath);
|
|
4505
|
+
else if (value.type === "update" && (isObject$2(firstItem) || Array.isArray(firstItem))) createSyncClass(firstItem, value.key, currentInstance, newPath);
|
|
4506
|
+
else savePath(newPath, firstItem);
|
|
4507
|
+
else if (value.type === "remove") savePath(newPath, DELETE_TOKEN);
|
|
4508
|
+
};
|
|
4509
|
+
const savePath = (propPath, value) => {
|
|
4510
|
+
const transformedValue = transform && value !== "$delete" ? transform(value) : value;
|
|
4511
|
+
if (syncToClient) currentInstance.$valuesChanges.set(propPath, transformedValue);
|
|
4512
|
+
if (persist2 && currentInstance.$path !== void 0) currentInstance.$valuesChanges.setPersist(transformedValue == "$delete" ? propPath : currentInstance.$path, transformedValue);
|
|
4513
|
+
};
|
|
4514
|
+
const setupSubscription = (signal, signalPath) => {
|
|
4515
|
+
if (!isSignal(signal)) return;
|
|
4516
|
+
if (syncToClient && currentInstance.$valuesChanges) {
|
|
4517
|
+
const initialValue = signal();
|
|
4518
|
+
const transformedInitialValue = transform ? transform(initialValue) : initialValue;
|
|
4519
|
+
currentInstance.$valuesChanges.set(signalPath, transformedInitialValue);
|
|
4520
|
+
}
|
|
4521
|
+
signal.options = options;
|
|
4522
|
+
signal.observable.subscribe((value) => {
|
|
4523
|
+
if (init) return;
|
|
4524
|
+
if (currentInstance.$path !== void 0) {
|
|
4525
|
+
const fullPath = `${currentInstance.$path ? currentInstance.$path + "." : ""}${signalPath}`;
|
|
4526
|
+
if (isComputed(signal)) savePath(fullPath, value);
|
|
4527
|
+
else if (isObjectSubject(signal._subject)) handleObjectSubject(value, fullPath);
|
|
4528
|
+
else if (isArraySubject(signal._subject)) handleArraySubject(value, fullPath);
|
|
4529
|
+
else savePath(fullPath, value);
|
|
4530
|
+
}
|
|
4531
|
+
});
|
|
4532
|
+
if (!currentInstance.$snapshot) currentInstance.$snapshot = /* @__PURE__ */ new Map();
|
|
4533
|
+
currentInstance.$snapshot.set(path, signal);
|
|
4534
|
+
};
|
|
4535
|
+
if (!isSignal(_signal)) {
|
|
4536
|
+
if (_signal && typeof _signal === "object" && !Array.isArray(_signal)) {
|
|
4537
|
+
for (const key in _signal) if (Object.prototype.hasOwnProperty.call(_signal, key)) {
|
|
4538
|
+
const value = _signal[key];
|
|
4539
|
+
const propertyPath = `${path}.${key}`;
|
|
4540
|
+
if (isSignal(value)) setupSubscription(value, propertyPath);
|
|
4541
|
+
else if (value && typeof value === "object" && !Array.isArray(value)) type(value, propertyPath, options, currentInstance);
|
|
4542
|
+
}
|
|
4543
|
+
init = false;
|
|
4544
|
+
}
|
|
4545
|
+
return _signal;
|
|
4546
|
+
}
|
|
4547
|
+
setupSubscription(_signal, path);
|
|
4548
|
+
init = false;
|
|
4549
|
+
return _signal;
|
|
4550
|
+
};
|
|
4551
|
+
function sync(options) {
|
|
4552
|
+
let classType;
|
|
4553
|
+
let persist2 = true;
|
|
4554
|
+
let syncToClient = true;
|
|
4555
|
+
let transform;
|
|
4556
|
+
if (typeof options === "function") classType = options;
|
|
4557
|
+
else if (typeof options === "object") {
|
|
4558
|
+
classType = options.classType;
|
|
4559
|
+
if (options.hasOwnProperty("persist")) persist2 = options.persist;
|
|
4560
|
+
if (options.hasOwnProperty("syncToClient")) syncToClient = options.syncToClient;
|
|
4561
|
+
if (options.hasOwnProperty("transform")) transform = options.transform;
|
|
4562
|
+
}
|
|
4563
|
+
return function(target, propertyKey) {
|
|
4564
|
+
const privatePropertyKey = `__${propertyKey}`;
|
|
4565
|
+
const getter = function() {
|
|
4566
|
+
return this[privatePropertyKey];
|
|
4567
|
+
};
|
|
4568
|
+
const setter = function(newVal) {
|
|
4569
|
+
this[privatePropertyKey] = type(newVal, propertyKey, {
|
|
4570
|
+
classType,
|
|
4571
|
+
persist: persist2,
|
|
4572
|
+
syncToClient,
|
|
4573
|
+
transform
|
|
4574
|
+
}, this);
|
|
4575
|
+
};
|
|
4576
|
+
Object.defineProperty(target, propertyKey, {
|
|
4577
|
+
get: getter,
|
|
4578
|
+
set: setter,
|
|
4579
|
+
enumerable: true,
|
|
4580
|
+
configurable: true
|
|
4581
|
+
});
|
|
4582
|
+
};
|
|
4583
|
+
}
|
|
4584
|
+
function id() {
|
|
4585
|
+
return function(target, propertyKey) {
|
|
4586
|
+
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
4587
|
+
target.constructor._propertyMetadata.set("id", propertyKey);
|
|
4588
|
+
};
|
|
4589
|
+
}
|
|
4590
|
+
function users(options) {
|
|
4591
|
+
return function(target, propertyKey) {
|
|
4592
|
+
if (!target.constructor._propertyMetadata) target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
|
|
4593
|
+
target.constructor._propertyMetadata.set("users", propertyKey);
|
|
4594
|
+
sync(options)(target, propertyKey);
|
|
4595
|
+
};
|
|
4596
|
+
}
|
|
4597
|
+
function persist() {
|
|
4598
|
+
return sync({
|
|
4599
|
+
persist: true,
|
|
4600
|
+
syncToClient: false
|
|
4601
|
+
});
|
|
4602
|
+
}
|
|
4603
|
+
function load(rootInstance, values, valueIsObject) {
|
|
4604
|
+
if (valueIsObject) loadFromObject(rootInstance, values);
|
|
4605
|
+
else loadFromPaths(rootInstance, values);
|
|
4606
|
+
}
|
|
4607
|
+
function loadFromPaths(rootInstance, values) {
|
|
4608
|
+
for (const [path, value] of Object.entries(values)) loadValue(rootInstance, path.split("."), value);
|
|
4609
|
+
}
|
|
4610
|
+
function loadFromObject(rootInstance, values, currentPath = "") {
|
|
4611
|
+
for (let key in values) {
|
|
4612
|
+
const value = values[key];
|
|
4613
|
+
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
|
4614
|
+
if (typeof value === "object" && !Array.isArray(value) && value !== null) loadFromObject(rootInstance, value, newPath);
|
|
4615
|
+
else loadValue(rootInstance, newPath.split("."), value);
|
|
4616
|
+
}
|
|
4617
|
+
}
|
|
4618
|
+
function loadValue(rootInstance, parts, value) {
|
|
4619
|
+
let current = rootInstance;
|
|
4620
|
+
for (let i = 0; i < parts.length; i++) {
|
|
4621
|
+
const part = parts[i];
|
|
4622
|
+
if (i === parts.length - 1) if (value == "$delete") {
|
|
4623
|
+
if (isSignal(current)) current = current();
|
|
4624
|
+
Reflect.deleteProperty(current, part);
|
|
4625
|
+
} else if (current[part]?._subject) current[part].set(value);
|
|
4626
|
+
else if (isSignal(current) && Array.isArray(current()) && !isNaN(Number(part))) current()[Number(part)] = value;
|
|
4627
|
+
else current[part] = value;
|
|
4628
|
+
else {
|
|
4629
|
+
if (isSignal(current)) current = current();
|
|
4630
|
+
if (current[part] === void 0) {
|
|
4631
|
+
const classType = getByPath(rootInstance, parts.slice(0, i).join("."))?.options?.classType;
|
|
4632
|
+
if (classType) {
|
|
4633
|
+
current[part] = !isClass$1(classType) ? classType(part) : new classType();
|
|
4634
|
+
setMetadata(current[part], "id", part);
|
|
4635
|
+
} else current[part] = {};
|
|
4636
|
+
}
|
|
4637
|
+
current = current[part];
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
function getByPath(root, path) {
|
|
4642
|
+
const parts = path.split(".");
|
|
4643
|
+
let current = root;
|
|
4644
|
+
for (const part of parts) {
|
|
4645
|
+
if (isSignal(current)) current = current();
|
|
4646
|
+
if (current[part]) current = current[part];
|
|
4647
|
+
else return;
|
|
4648
|
+
}
|
|
4649
|
+
return current;
|
|
4650
|
+
}
|
|
4651
|
+
//#endregion
|
|
4652
|
+
//#region ../../node_modules/.pnpm/@signe+room@2.10.0/node_modules/@signe/room/dist/index.js
|
|
3797
4653
|
var __defProp = Object.defineProperty;
|
|
3798
|
-
var
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
4654
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4655
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4656
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
4657
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
4658
|
+
if (kind && result) __defProp(target, key, result);
|
|
4659
|
+
return result;
|
|
4660
|
+
};
|
|
3802
4661
|
function Action(name, bodyValidation) {
|
|
3803
4662
|
return function(target, propertyKey) {
|
|
3804
4663
|
if (!target.constructor._actionMetadata) target.constructor._actionMetadata = /* @__PURE__ */ new Map();
|
|
@@ -3808,13 +4667,11 @@ function Action(name, bodyValidation) {
|
|
|
3808
4667
|
});
|
|
3809
4668
|
};
|
|
3810
4669
|
}
|
|
3811
|
-
__name(Action, "Action");
|
|
3812
4670
|
function UnhandledAction() {
|
|
3813
4671
|
return function(target, propertyKey) {
|
|
3814
4672
|
target.constructor._unhandledActionMetadata = { key: propertyKey };
|
|
3815
4673
|
};
|
|
3816
4674
|
}
|
|
3817
|
-
__name(UnhandledAction, "UnhandledAction");
|
|
3818
4675
|
function Request2(options, bodyValidation) {
|
|
3819
4676
|
return function(target, propertyKey) {
|
|
3820
4677
|
if (!target.constructor._requestMetadata) target.constructor._requestMetadata = /* @__PURE__ */ new Map();
|
|
@@ -3829,7 +4686,6 @@ function Request2(options, bodyValidation) {
|
|
|
3829
4686
|
});
|
|
3830
4687
|
};
|
|
3831
4688
|
}
|
|
3832
|
-
__name(Request2, "Request");
|
|
3833
4689
|
function Room(options) {
|
|
3834
4690
|
return function(target) {
|
|
3835
4691
|
target.path = options.path;
|
|
@@ -3840,13 +4696,6 @@ function Room(options) {
|
|
|
3840
4696
|
if (options.guards) target["_roomGuards"] = options.guards;
|
|
3841
4697
|
};
|
|
3842
4698
|
}
|
|
3843
|
-
__name(Room, "Room");
|
|
3844
|
-
function RoomGuard(guards) {
|
|
3845
|
-
return function(target) {
|
|
3846
|
-
target["_roomGuards"] = guards;
|
|
3847
|
-
};
|
|
3848
|
-
}
|
|
3849
|
-
__name(RoomGuard, "RoomGuard");
|
|
3850
4699
|
function Guard(guards) {
|
|
3851
4700
|
return function(target, propertyKey, descriptor) {
|
|
3852
4701
|
if (!target.constructor["_actionGuards"]) target.constructor["_actionGuards"] = /* @__PURE__ */ new Map();
|
|
@@ -3854,47 +4703,15 @@ function Guard(guards) {
|
|
|
3854
4703
|
target.constructor["_actionGuards"].set(propertyKey, guards);
|
|
3855
4704
|
};
|
|
3856
4705
|
}
|
|
3857
|
-
__name(Guard, "Guard");
|
|
3858
|
-
function generateShortUUID() {
|
|
3859
|
-
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
3860
|
-
let uuid = "";
|
|
3861
|
-
for (let i = 0; i < 8; i++) {
|
|
3862
|
-
const randomIndex = Math.floor(Math.random() * 62);
|
|
3863
|
-
uuid += chars[randomIndex];
|
|
3864
|
-
}
|
|
3865
|
-
return uuid;
|
|
3866
|
-
}
|
|
3867
|
-
__name(generateShortUUID, "generateShortUUID");
|
|
3868
|
-
var Storage = class {
|
|
3869
|
-
static {
|
|
3870
|
-
__name(this, "Storage");
|
|
3871
|
-
}
|
|
3872
|
-
memory = /* @__PURE__ */ new Map();
|
|
3873
|
-
async put(key, value) {
|
|
3874
|
-
this.memory.set(key, value);
|
|
3875
|
-
}
|
|
3876
|
-
async get(key) {
|
|
3877
|
-
return this.memory.get(key);
|
|
3878
|
-
}
|
|
3879
|
-
async delete(key) {
|
|
3880
|
-
this.memory.delete(key);
|
|
3881
|
-
}
|
|
3882
|
-
async list() {
|
|
3883
|
-
return this.memory;
|
|
3884
|
-
}
|
|
3885
|
-
};
|
|
3886
4706
|
function isPromise(value) {
|
|
3887
4707
|
return value instanceof Promise;
|
|
3888
4708
|
}
|
|
3889
|
-
__name(isPromise, "isPromise");
|
|
3890
4709
|
async function awaitReturn(val) {
|
|
3891
4710
|
return isPromise(val) ? await val : val;
|
|
3892
4711
|
}
|
|
3893
|
-
__name(awaitReturn, "awaitReturn");
|
|
3894
4712
|
function isClass(obj) {
|
|
3895
4713
|
return typeof obj === "function" && obj.prototype && obj.prototype.constructor === obj;
|
|
3896
4714
|
}
|
|
3897
|
-
__name(isClass, "isClass");
|
|
3898
4715
|
function throttle(func, wait) {
|
|
3899
4716
|
let timeout = null;
|
|
3900
4717
|
let lastArgs = null;
|
|
@@ -3911,7 +4728,6 @@ function throttle(func, wait) {
|
|
|
3911
4728
|
} else lastArgs = args;
|
|
3912
4729
|
};
|
|
3913
4730
|
}
|
|
3914
|
-
__name(throttle, "throttle");
|
|
3915
4731
|
function extractParams(pattern, str) {
|
|
3916
4732
|
const regexPattern = pattern.replace(/{(\w+)}/g, "(?<$1>[\\w-]+)");
|
|
3917
4733
|
const match = new RegExp(`^${regexPattern}$`).exec(str);
|
|
@@ -3919,7 +4735,6 @@ function extractParams(pattern, str) {
|
|
|
3919
4735
|
else if (pattern === str) return {};
|
|
3920
4736
|
else return null;
|
|
3921
4737
|
}
|
|
3922
|
-
__name(extractParams, "extractParams");
|
|
3923
4738
|
function dremove(obj, keys) {
|
|
3924
4739
|
if (typeof keys === "string") keys = keys.split(".");
|
|
3925
4740
|
let i = 0;
|
|
@@ -3935,7 +4750,6 @@ function dremove(obj, keys) {
|
|
|
3935
4750
|
k = keys[i];
|
|
3936
4751
|
if (t && typeof t === "object" && !(k === "__proto__" || k === "constructor" || k === "prototype")) delete t[k];
|
|
3937
4752
|
}
|
|
3938
|
-
__name(dremove, "dremove");
|
|
3939
4753
|
function buildObject(valuesMap, allMemory) {
|
|
3940
4754
|
let memoryObj = {};
|
|
3941
4755
|
for (let path of valuesMap.keys()) {
|
|
@@ -3946,27 +4760,15 @@ function buildObject(valuesMap, allMemory) {
|
|
|
3946
4760
|
}
|
|
3947
4761
|
return memoryObj;
|
|
3948
4762
|
}
|
|
3949
|
-
__name(buildObject, "buildObject");
|
|
3950
|
-
function response(status, body) {
|
|
3951
|
-
return new Response(JSON.stringify(body), {
|
|
3952
|
-
status,
|
|
3953
|
-
headers: { "Content-Type": "application/json" }
|
|
3954
|
-
});
|
|
3955
|
-
}
|
|
3956
|
-
__name(response, "response");
|
|
3957
4763
|
var ServerResponse = class {
|
|
3958
|
-
static {
|
|
3959
|
-
__name(this, "ServerResponse");
|
|
3960
|
-
}
|
|
3961
|
-
interceptors;
|
|
3962
|
-
statusCode = 200;
|
|
3963
|
-
responseBody = {};
|
|
3964
|
-
responseHeaders = { "Content-Type": "application/json" };
|
|
3965
4764
|
/**
|
|
3966
4765
|
* Creates a new ServerResponse instance
|
|
3967
4766
|
* @param interceptors Array of interceptor functions that can modify the response
|
|
3968
4767
|
*/
|
|
3969
4768
|
constructor(interceptors = []) {
|
|
4769
|
+
this.statusCode = 200;
|
|
4770
|
+
this.responseBody = {};
|
|
4771
|
+
this.responseHeaders = { "Content-Type": "application/json" };
|
|
3970
4772
|
this.interceptors = interceptors;
|
|
3971
4773
|
}
|
|
3972
4774
|
/**
|
|
@@ -4164,22 +4966,14 @@ function cors(res, options = {}) {
|
|
|
4164
4966
|
headers: newHeaders
|
|
4165
4967
|
});
|
|
4166
4968
|
}
|
|
4167
|
-
__name(cors, "cors");
|
|
4168
4969
|
function createCorsInterceptor(options = {}) {
|
|
4169
4970
|
return (res) => cors(res, options);
|
|
4170
4971
|
}
|
|
4171
|
-
__name(createCorsInterceptor, "createCorsInterceptor");
|
|
4172
4972
|
var Message = z.object({
|
|
4173
4973
|
action: z.string(),
|
|
4174
4974
|
value: z.any()
|
|
4175
4975
|
});
|
|
4176
4976
|
var Server = class {
|
|
4177
|
-
static {
|
|
4178
|
-
__name(this, "Server");
|
|
4179
|
-
}
|
|
4180
|
-
room;
|
|
4181
|
-
subRoom;
|
|
4182
|
-
rooms;
|
|
4183
4977
|
/**
|
|
4184
4978
|
* @constructor
|
|
4185
4979
|
* @param {Party.Room} room - The room object representing the current game or application instance.
|
|
@@ -4306,7 +5100,7 @@ var Server = class {
|
|
|
4306
5100
|
}
|
|
4307
5101
|
}
|
|
4308
5102
|
if (!instance) return null;
|
|
4309
|
-
const loadMemory =
|
|
5103
|
+
const loadMemory = async () => {
|
|
4310
5104
|
const root = await this.room.storage.get(".");
|
|
4311
5105
|
const memory = await this.room.storage.list();
|
|
4312
5106
|
const tmpObject = root || {};
|
|
@@ -4316,7 +5110,7 @@ var Server = class {
|
|
|
4316
5110
|
dset(tmpObject, key, value);
|
|
4317
5111
|
}
|
|
4318
5112
|
load(instance, tmpObject, true);
|
|
4319
|
-
}
|
|
5113
|
+
};
|
|
4320
5114
|
instance.$memoryAll = {};
|
|
4321
5115
|
instance.$autoSync = instance["autoSync"] !== false;
|
|
4322
5116
|
instance.$pendingSync = /* @__PURE__ */ new Map();
|
|
@@ -4398,7 +5192,7 @@ var Server = class {
|
|
|
4398
5192
|
return null;
|
|
4399
5193
|
}
|
|
4400
5194
|
};
|
|
4401
|
-
const syncCb =
|
|
5195
|
+
const syncCb = (values) => {
|
|
4402
5196
|
if (options.getMemoryAll) buildObject(values, instance.$memoryAll);
|
|
4403
5197
|
if (init && this.isHibernate) {
|
|
4404
5198
|
init = false;
|
|
@@ -4415,8 +5209,8 @@ var Server = class {
|
|
|
4415
5209
|
value: packet
|
|
4416
5210
|
}, instance);
|
|
4417
5211
|
values.clear();
|
|
4418
|
-
}
|
|
4419
|
-
const persistCb =
|
|
5212
|
+
};
|
|
5213
|
+
const persistCb = async (values) => {
|
|
4420
5214
|
if (initPersist) {
|
|
4421
5215
|
values.clear();
|
|
4422
5216
|
return;
|
|
@@ -4427,7 +5221,7 @@ var Server = class {
|
|
|
4427
5221
|
else await this.room.storage.put(path, itemValue);
|
|
4428
5222
|
}
|
|
4429
5223
|
values.clear();
|
|
4430
|
-
}
|
|
5224
|
+
};
|
|
4431
5225
|
syncClass(instance, {
|
|
4432
5226
|
onSync: instance["throttleSync"] ? throttle(syncCb, instance["throttleSync"]) : syncCb,
|
|
4433
5227
|
onPersist: instance["throttleStorage"] ? throttle(persistCb, instance["throttleStorage"]) : persistCb
|
|
@@ -4586,7 +5380,7 @@ var Server = class {
|
|
|
4586
5380
|
if (transferData) await this.room.storage.delete(`transfer:${transferToken}`);
|
|
4587
5381
|
}
|
|
4588
5382
|
const existingSession = await this.getSession(conn.id);
|
|
4589
|
-
const publicId = existingSession?.publicId || transferData?.publicId || generateShortUUID
|
|
5383
|
+
const publicId = existingSession?.publicId || transferData?.publicId || generateShortUUID();
|
|
4590
5384
|
let user = null;
|
|
4591
5385
|
const signal2 = this.getUsersProperty(subRoom);
|
|
4592
5386
|
const usersPropName = this.getUsersPropName(subRoom);
|
|
@@ -4755,28 +5549,28 @@ var Server = class {
|
|
|
4755
5549
|
} : void 0 };
|
|
4756
5550
|
const virtualConnection = {
|
|
4757
5551
|
id: privateId,
|
|
4758
|
-
send:
|
|
5552
|
+
send: (data) => {
|
|
4759
5553
|
shardConnection.send(JSON.stringify({
|
|
4760
5554
|
targetClientId: privateId,
|
|
4761
5555
|
data
|
|
4762
5556
|
}));
|
|
4763
|
-
},
|
|
5557
|
+
},
|
|
4764
5558
|
state: {},
|
|
4765
|
-
setState:
|
|
5559
|
+
setState: (state) => {
|
|
4766
5560
|
const clients = shardState.clients;
|
|
4767
5561
|
const currentState = clients.get(privateId) || {};
|
|
4768
5562
|
const mergedState = Object.assign({}, currentState, state);
|
|
4769
5563
|
clients.set(privateId, mergedState);
|
|
4770
5564
|
virtualConnection.state = clients.get(privateId);
|
|
4771
5565
|
return virtualConnection.state;
|
|
4772
|
-
},
|
|
4773
|
-
close:
|
|
5566
|
+
},
|
|
5567
|
+
close: () => {
|
|
4774
5568
|
shardConnection.send(JSON.stringify({
|
|
4775
5569
|
type: "shard.closeClient",
|
|
4776
5570
|
privateId
|
|
4777
5571
|
}));
|
|
4778
5572
|
if (shardState.clients) shardState.clients.delete(privateId);
|
|
4779
|
-
}
|
|
5573
|
+
}
|
|
4780
5574
|
};
|
|
4781
5575
|
if (!shardState.clients.has(privateId)) shardState.clients.set(privateId, {});
|
|
4782
5576
|
await this.onConnectClient(virtualConnection, virtualContext);
|
|
@@ -4800,27 +5594,27 @@ var Server = class {
|
|
|
4800
5594
|
}
|
|
4801
5595
|
const virtualConnection = {
|
|
4802
5596
|
id: privateId,
|
|
4803
|
-
send:
|
|
5597
|
+
send: (data) => {
|
|
4804
5598
|
shardConnection.send(JSON.stringify({
|
|
4805
5599
|
targetClientId: privateId,
|
|
4806
5600
|
data
|
|
4807
5601
|
}));
|
|
4808
|
-
},
|
|
5602
|
+
},
|
|
4809
5603
|
state: clients.get(privateId),
|
|
4810
|
-
setState:
|
|
5604
|
+
setState: (state) => {
|
|
4811
5605
|
const currentState = clients.get(privateId) || {};
|
|
4812
5606
|
const mergedState = Object.assign({}, currentState, state);
|
|
4813
5607
|
clients.set(privateId, mergedState);
|
|
4814
5608
|
virtualConnection.state = clients.get(privateId);
|
|
4815
5609
|
return virtualConnection.state;
|
|
4816
|
-
},
|
|
4817
|
-
close:
|
|
5610
|
+
},
|
|
5611
|
+
close: () => {
|
|
4818
5612
|
shardConnection.send(JSON.stringify({
|
|
4819
5613
|
type: "shard.closeClient",
|
|
4820
5614
|
privateId
|
|
4821
5615
|
}));
|
|
4822
5616
|
if (shardState.clients) shardState.clients.delete(privateId);
|
|
4823
|
-
}
|
|
5617
|
+
}
|
|
4824
5618
|
};
|
|
4825
5619
|
const payloadString = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
4826
5620
|
await this.onMessage(payloadString, virtualConnection);
|
|
@@ -4844,12 +5638,12 @@ var Server = class {
|
|
|
4844
5638
|
}
|
|
4845
5639
|
const virtualConnection = {
|
|
4846
5640
|
id: privateId,
|
|
4847
|
-
send:
|
|
5641
|
+
send: () => {},
|
|
4848
5642
|
state: clientState,
|
|
4849
|
-
setState:
|
|
5643
|
+
setState: () => {
|
|
4850
5644
|
return {};
|
|
4851
|
-
},
|
|
4852
|
-
close:
|
|
5645
|
+
},
|
|
5646
|
+
close: () => {}
|
|
4853
5647
|
};
|
|
4854
5648
|
await this.onClose(virtualConnection);
|
|
4855
5649
|
clients.delete(privateId);
|
|
@@ -4949,7 +5743,7 @@ var Server = class {
|
|
|
4949
5743
|
await this.room.storage.put(`${usersPropName}.${publicId}`, userSnapshot);
|
|
4950
5744
|
}
|
|
4951
5745
|
}
|
|
4952
|
-
const transferToken = generateShortUUID
|
|
5746
|
+
const transferToken = generateShortUUID();
|
|
4953
5747
|
await this.room.storage.put(`transfer:${transferToken}`, {
|
|
4954
5748
|
privateId,
|
|
4955
5749
|
publicId,
|
|
@@ -5088,424 +5882,30 @@ var Server = class {
|
|
|
5088
5882
|
const response2 = await this.tryMatchRequestHandler(enhancedReq, res, subRoom);
|
|
5089
5883
|
if (response2) return response2;
|
|
5090
5884
|
const legacyResponse = await awaitReturn(subRoom["onRequest"]?.(enhancedReq, res));
|
|
5091
|
-
if (!legacyResponse) return res.notFound();
|
|
5092
|
-
if (legacyResponse instanceof Response) return legacyResponse;
|
|
5093
|
-
return res.success(legacyResponse);
|
|
5094
|
-
} catch (error) {
|
|
5095
|
-
console.error(`Error processing request from shard ${shardId}:`, error);
|
|
5096
|
-
return res.serverError();
|
|
5097
|
-
}
|
|
5098
|
-
}
|
|
5099
|
-
/**
|
|
5100
|
-
* @method createEnhancedRequest
|
|
5101
|
-
* @private
|
|
5102
|
-
* @param {Party.Request} originalReq - The original request received from the shard
|
|
5103
|
-
* @param {string | null} originalClientIp - The original client IP, if available
|
|
5104
|
-
* @description Creates an enhanced request object that preserves the original client context
|
|
5105
|
-
* @returns {Party.Request} The enhanced request object
|
|
5106
|
-
*/
|
|
5107
|
-
createEnhancedRequest(originalReq, originalClientIp) {
|
|
5108
|
-
const clonedReq = originalReq.clone();
|
|
5109
|
-
clonedReq.viaShard = true;
|
|
5110
|
-
if (originalClientIp) clonedReq.originalClientIp = originalClientIp;
|
|
5111
|
-
return clonedReq;
|
|
5112
|
-
}
|
|
5113
|
-
};
|
|
5114
|
-
var Shard = class {
|
|
5115
|
-
static {
|
|
5116
|
-
__name(this, "Shard");
|
|
5117
|
-
}
|
|
5118
|
-
room;
|
|
5119
|
-
ws;
|
|
5120
|
-
connectionMap;
|
|
5121
|
-
mainServerStub;
|
|
5122
|
-
worldUrl;
|
|
5123
|
-
worldId;
|
|
5124
|
-
lastReportedConnections;
|
|
5125
|
-
statsInterval;
|
|
5126
|
-
statsIntervalId;
|
|
5127
|
-
constructor(room) {
|
|
5128
|
-
this.room = room;
|
|
5129
|
-
this.connectionMap = /* @__PURE__ */ new Map();
|
|
5130
|
-
this.worldUrl = null;
|
|
5131
|
-
this.worldId = "default";
|
|
5132
|
-
this.lastReportedConnections = 0;
|
|
5133
|
-
this.statsInterval = 3e4;
|
|
5134
|
-
this.statsIntervalId = null;
|
|
5135
|
-
}
|
|
5136
|
-
async onStart() {
|
|
5137
|
-
const roomId = this.room.id.split(":")[0];
|
|
5138
|
-
const roomStub = this.room.context.parties.main.get(roomId);
|
|
5139
|
-
if (!roomStub) {
|
|
5140
|
-
console.warn("No room room stub found in main party context");
|
|
5141
|
-
return;
|
|
5142
|
-
}
|
|
5143
|
-
this.mainServerStub = roomStub;
|
|
5144
|
-
this.ws = await roomStub.socket({ headers: { "x-shard-id": this.room.id } });
|
|
5145
|
-
this.ws.addEventListener("message", (event) => {
|
|
5146
|
-
try {
|
|
5147
|
-
const message = JSON.parse(event.data);
|
|
5148
|
-
if (message.targetClientId) {
|
|
5149
|
-
const clientConn = this.connectionMap.get(message.targetClientId);
|
|
5150
|
-
if (clientConn) {
|
|
5151
|
-
delete message.targetClientId;
|
|
5152
|
-
clientConn.send(message.data);
|
|
5153
|
-
}
|
|
5154
|
-
} else this.room.broadcast(event.data);
|
|
5155
|
-
} catch (error) {
|
|
5156
|
-
console.error("Error processing message from main server:", error);
|
|
5157
|
-
}
|
|
5158
|
-
});
|
|
5159
|
-
await this.updateWorldStats();
|
|
5160
|
-
this.startPeriodicStatsUpdates();
|
|
5161
|
-
}
|
|
5162
|
-
startPeriodicStatsUpdates() {
|
|
5163
|
-
if (!this.worldUrl) return;
|
|
5164
|
-
if (this.statsIntervalId) clearInterval(this.statsIntervalId);
|
|
5165
|
-
this.statsIntervalId = setInterval(() => {
|
|
5166
|
-
this.updateWorldStats().catch((error) => {
|
|
5167
|
-
console.error("Error in periodic stats update:", error);
|
|
5168
|
-
});
|
|
5169
|
-
}, this.statsInterval);
|
|
5170
|
-
}
|
|
5171
|
-
stopPeriodicStatsUpdates() {
|
|
5172
|
-
if (this.statsIntervalId) {
|
|
5173
|
-
clearInterval(this.statsIntervalId);
|
|
5174
|
-
this.statsIntervalId = null;
|
|
5175
|
-
}
|
|
5176
|
-
}
|
|
5177
|
-
onConnect(conn, ctx) {
|
|
5178
|
-
this.connectionMap.set(conn.id, conn);
|
|
5179
|
-
const headers = {};
|
|
5180
|
-
if (ctx.request?.headers) ctx.request.headers.forEach((value, key) => {
|
|
5181
|
-
headers[key] = value;
|
|
5182
|
-
});
|
|
5183
|
-
const requestInfo = ctx.request ? {
|
|
5184
|
-
headers,
|
|
5185
|
-
url: ctx.request.url,
|
|
5186
|
-
method: ctx.request.method
|
|
5187
|
-
} : null;
|
|
5188
|
-
this.ws.send(JSON.stringify({
|
|
5189
|
-
type: "shard.clientConnected",
|
|
5190
|
-
privateId: conn.id,
|
|
5191
|
-
requestInfo
|
|
5192
|
-
}));
|
|
5193
|
-
this.updateWorldStats();
|
|
5194
|
-
}
|
|
5195
|
-
onMessage(message, sender) {
|
|
5196
|
-
try {
|
|
5197
|
-
const parsedMessage = typeof message === "string" ? JSON.parse(message) : message;
|
|
5198
|
-
const wrappedMessage = JSON.stringify({
|
|
5199
|
-
type: "shard.clientMessage",
|
|
5200
|
-
privateId: sender.id,
|
|
5201
|
-
publicId: sender.state?.publicId,
|
|
5202
|
-
payload: parsedMessage
|
|
5203
|
-
});
|
|
5204
|
-
this.ws.send(wrappedMessage);
|
|
5205
|
-
} catch (error) {
|
|
5206
|
-
console.error("Error forwarding message to main server:", error);
|
|
5207
|
-
}
|
|
5208
|
-
}
|
|
5209
|
-
onClose(conn) {
|
|
5210
|
-
this.connectionMap.delete(conn.id);
|
|
5211
|
-
this.ws.send(JSON.stringify({
|
|
5212
|
-
type: "shard.clientDisconnected",
|
|
5213
|
-
privateId: conn.id,
|
|
5214
|
-
publicId: conn.state?.publicId
|
|
5215
|
-
}));
|
|
5216
|
-
this.updateWorldStats();
|
|
5217
|
-
}
|
|
5218
|
-
async updateWorldStats() {
|
|
5219
|
-
const currentConnections = this.connectionMap.size;
|
|
5220
|
-
if (currentConnections === this.lastReportedConnections) return true;
|
|
5221
|
-
try {
|
|
5222
|
-
const response2 = await this.room.context.parties.world.get("world-default").fetch("/update-shard", {
|
|
5223
|
-
method: "POST",
|
|
5224
|
-
headers: {
|
|
5225
|
-
"Content-Type": "application/json",
|
|
5226
|
-
"x-access-shard": this.room.env.SHARD_SECRET
|
|
5227
|
-
},
|
|
5228
|
-
body: JSON.stringify({
|
|
5229
|
-
shardId: this.room.id,
|
|
5230
|
-
connections: currentConnections
|
|
5231
|
-
})
|
|
5232
|
-
});
|
|
5233
|
-
if (!response2.ok) {
|
|
5234
|
-
const errorData = await response2.json().catch(() => ({ error: "Unknown error" }));
|
|
5235
|
-
console.error(`Failed to update World stats: ${response2.status} - ${errorData.error || "Unknown error"}`);
|
|
5236
|
-
return false;
|
|
5237
|
-
}
|
|
5238
|
-
this.lastReportedConnections = currentConnections;
|
|
5239
|
-
return true;
|
|
5240
|
-
} catch (error) {
|
|
5241
|
-
console.error("Error updating World stats:", error);
|
|
5242
|
-
return false;
|
|
5243
|
-
}
|
|
5244
|
-
}
|
|
5245
|
-
/**
|
|
5246
|
-
* @method onRequest
|
|
5247
|
-
* @async
|
|
5248
|
-
* @param {Party.Request} req - The HTTP request to handle
|
|
5249
|
-
* @description Forwards HTTP requests to the main server, preserving client context
|
|
5250
|
-
* @returns {Promise<Response>} The response from the main server
|
|
5251
|
-
*/
|
|
5252
|
-
async onRequest(req) {
|
|
5253
|
-
if (!this.mainServerStub) return response(503, { error: "Shard not connected to main server" });
|
|
5254
|
-
try {
|
|
5255
|
-
const path = new URL(req.url).pathname;
|
|
5256
|
-
const method = req.method;
|
|
5257
|
-
let body = null;
|
|
5258
|
-
if (method !== "GET" && method !== "HEAD") body = await req.text();
|
|
5259
|
-
const headers = new Headers();
|
|
5260
|
-
req.headers.forEach((value, key) => {
|
|
5261
|
-
headers.set(key, value);
|
|
5262
|
-
});
|
|
5263
|
-
headers.set("x-shard-id", this.room.id);
|
|
5264
|
-
headers.set("x-forwarded-by-shard", "true");
|
|
5265
|
-
const clientIp = req.headers.get("x-forwarded-for") || "unknown";
|
|
5266
|
-
if (clientIp) headers.set("x-original-client-ip", clientIp);
|
|
5267
|
-
const requestInit = {
|
|
5268
|
-
method,
|
|
5269
|
-
headers,
|
|
5270
|
-
body
|
|
5271
|
-
};
|
|
5272
|
-
return await this.mainServerStub.fetch(path, requestInit);
|
|
5273
|
-
} catch (error) {
|
|
5274
|
-
return response(500, { error: "Error forwarding request" });
|
|
5275
|
-
}
|
|
5276
|
-
}
|
|
5277
|
-
/**
|
|
5278
|
-
* @method onAlarm
|
|
5279
|
-
* @async
|
|
5280
|
-
* @description Executed periodically, used to perform maintenance tasks
|
|
5281
|
-
*/
|
|
5282
|
-
async onAlarm() {
|
|
5283
|
-
await this.updateWorldStats();
|
|
5284
|
-
}
|
|
5285
|
-
};
|
|
5286
|
-
async function testRoom(Room3, options = {}) {
|
|
5287
|
-
const createServer = /* @__PURE__ */ __name((io2) => {
|
|
5288
|
-
const server2 = new Server(io2);
|
|
5289
|
-
server2.rooms = [Room3];
|
|
5290
|
-
return server2;
|
|
5291
|
-
}, "createServer");
|
|
5292
|
-
const isShard = options.shard || false;
|
|
5293
|
-
const io = new ServerIo(Room3.path, isShard ? {
|
|
5294
|
-
parties: {
|
|
5295
|
-
game: createServer,
|
|
5296
|
-
...options.parties || {}
|
|
5297
|
-
},
|
|
5298
|
-
partyFn: options.partyFn,
|
|
5299
|
-
env: options.env
|
|
5300
|
-
} : {
|
|
5301
|
-
parties: options.parties,
|
|
5302
|
-
partyFn: options.partyFn,
|
|
5303
|
-
env: options.env
|
|
5304
|
-
});
|
|
5305
|
-
Room3.prototype.throttleSync = 0;
|
|
5306
|
-
Room3.prototype.throttleStorage = 0;
|
|
5307
|
-
Room3.prototype.options = options;
|
|
5308
|
-
let server;
|
|
5309
|
-
if (options.shard) {
|
|
5310
|
-
const shardServer = new Shard(io);
|
|
5311
|
-
shardServer.subRoom = null;
|
|
5312
|
-
server = shardServer;
|
|
5313
|
-
if (io.context.parties.main instanceof Map) for (const lobby of io.context.parties.main.values()) await lobby.server.onStart();
|
|
5314
|
-
} else {
|
|
5315
|
-
server = await createServer(io);
|
|
5316
|
-
if (io.context.parties.main instanceof Map) {
|
|
5317
|
-
for (const lobby of io.context.parties.main.values()) if (lobby.server && lobby.server !== server) await lobby.server.onStart();
|
|
5318
|
-
}
|
|
5319
|
-
}
|
|
5320
|
-
await server.onStart();
|
|
5321
|
-
return {
|
|
5322
|
-
server,
|
|
5323
|
-
room: server.subRoom,
|
|
5324
|
-
createClient: /* @__PURE__ */ __name(async (id2, opts) => {
|
|
5325
|
-
return await io.connection(server, id2, opts);
|
|
5326
|
-
}, "createClient"),
|
|
5327
|
-
getServerUser: /* @__PURE__ */ __name(async (client, prop = "users") => {
|
|
5328
|
-
const privateId = client.conn.id;
|
|
5329
|
-
const session = await server.getSession(privateId);
|
|
5330
|
-
return server.subRoom[prop]()[session?.publicId];
|
|
5331
|
-
}, "getServerUser")
|
|
5332
|
-
};
|
|
5333
|
-
}
|
|
5334
|
-
__name(testRoom, "testRoom");
|
|
5335
|
-
async function request(room, path, options = { method: "GET" }) {
|
|
5336
|
-
const url = new URL("http://localhost" + path);
|
|
5337
|
-
const request1 = new Request(url.toString(), options);
|
|
5338
|
-
return await room.onRequest(request1);
|
|
5339
|
-
}
|
|
5340
|
-
__name(request, "request");
|
|
5341
|
-
function tick(ms = 0) {
|
|
5342
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5343
|
-
}
|
|
5344
|
-
__name(tick, "tick");
|
|
5345
|
-
var MockPartyClient = class {
|
|
5346
|
-
static {
|
|
5347
|
-
__name(this, "MockPartyClient");
|
|
5348
|
-
}
|
|
5349
|
-
server;
|
|
5350
|
-
events;
|
|
5351
|
-
id;
|
|
5352
|
-
conn;
|
|
5353
|
-
constructor(server, id2) {
|
|
5354
|
-
this.server = server;
|
|
5355
|
-
this.events = /* @__PURE__ */ new Map();
|
|
5356
|
-
this.id = id2 || generateShortUUID();
|
|
5357
|
-
this.conn = new MockConnection(this);
|
|
5358
|
-
}
|
|
5359
|
-
addEventListener(event, cb) {
|
|
5360
|
-
if (!this.events.has(event)) this.events.set(event, []);
|
|
5361
|
-
this.events.get(event).push(cb);
|
|
5362
|
-
}
|
|
5363
|
-
removeEventListener(event, cb) {
|
|
5364
|
-
if (!this.events.has(event)) return;
|
|
5365
|
-
const callbacks = this.events.get(event);
|
|
5366
|
-
const index = callbacks.indexOf(cb);
|
|
5367
|
-
if (index !== -1) callbacks.splice(index, 1);
|
|
5368
|
-
if (callbacks.length === 0) this.events.delete(event);
|
|
5369
|
-
}
|
|
5370
|
-
_trigger(event, data) {
|
|
5371
|
-
const callbacks = this.events.get(event);
|
|
5372
|
-
if (callbacks) for (const cb of callbacks) cb(data);
|
|
5373
|
-
}
|
|
5374
|
-
send(data) {
|
|
5375
|
-
return this.server.onMessage(JSON.stringify(data), this.conn);
|
|
5376
|
-
}
|
|
5377
|
-
};
|
|
5378
|
-
var MockLobby = class MockLobby2 {
|
|
5379
|
-
static {
|
|
5380
|
-
__name(this, "MockLobby");
|
|
5381
|
-
}
|
|
5382
|
-
server;
|
|
5383
|
-
lobbyId;
|
|
5384
|
-
constructor(server, lobbyId) {
|
|
5385
|
-
this.server = server;
|
|
5386
|
-
this.lobbyId = lobbyId;
|
|
5387
|
-
}
|
|
5388
|
-
socket(_init) {
|
|
5389
|
-
return new MockPartyClient(this.server);
|
|
5390
|
-
}
|
|
5391
|
-
async connection(idOrOptions, maybeOptions) {
|
|
5392
|
-
const id2 = typeof idOrOptions === "string" ? idOrOptions : idOrOptions?.id;
|
|
5393
|
-
const options = (typeof idOrOptions === "string" ? maybeOptions : idOrOptions) || {};
|
|
5394
|
-
return this.server.room.connection(this.server, id2, options);
|
|
5395
|
-
}
|
|
5396
|
-
fetch(url, options) {
|
|
5397
|
-
const baseUrl = url.includes("shard") ? "" : "/parties/main/" + this.lobbyId;
|
|
5398
|
-
return request(this.server, baseUrl + url, options);
|
|
5399
|
-
}
|
|
5400
|
-
};
|
|
5401
|
-
var MockContext = class MockContext2 {
|
|
5402
|
-
static {
|
|
5403
|
-
__name(this, "MockContext");
|
|
5404
|
-
}
|
|
5405
|
-
room;
|
|
5406
|
-
parties;
|
|
5407
|
-
constructor(room, options = {}) {
|
|
5408
|
-
this.room = room;
|
|
5409
|
-
this.parties = { main: /* @__PURE__ */ new Map() };
|
|
5410
|
-
const parties = options.parties || {};
|
|
5411
|
-
if (options.partyFn) {
|
|
5412
|
-
const serverCache = /* @__PURE__ */ new Map();
|
|
5413
|
-
this.parties.main = { get: /* @__PURE__ */ __name(async (lobbyId) => {
|
|
5414
|
-
if (!serverCache.has(lobbyId)) {
|
|
5415
|
-
const server = await options.partyFn(lobbyId);
|
|
5416
|
-
serverCache.set(lobbyId, new MockLobby(server, lobbyId));
|
|
5417
|
-
}
|
|
5418
|
-
return serverCache.get(lobbyId);
|
|
5419
|
-
}, "get") };
|
|
5420
|
-
} else for (let lobbyId in parties) {
|
|
5421
|
-
const server = parties[lobbyId](room);
|
|
5422
|
-
this.parties.main.set(lobbyId, new MockLobby(server, lobbyId));
|
|
5885
|
+
if (!legacyResponse) return res.notFound();
|
|
5886
|
+
if (legacyResponse instanceof Response) return legacyResponse;
|
|
5887
|
+
return res.success(legacyResponse);
|
|
5888
|
+
} catch (error) {
|
|
5889
|
+
console.error(`Error processing request from shard ${shardId}:`, error);
|
|
5890
|
+
return res.serverError();
|
|
5423
5891
|
}
|
|
5424
5892
|
}
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
}
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
this.storage = new Storage();
|
|
5439
|
-
this.env = {};
|
|
5440
|
-
this.id = id2 || generateShortUUID();
|
|
5441
|
-
this.context = new MockContext(this, {
|
|
5442
|
-
parties: options.parties,
|
|
5443
|
-
partyFn: options.partyFn
|
|
5444
|
-
});
|
|
5445
|
-
this.env = options.env || {};
|
|
5446
|
-
}
|
|
5447
|
-
async connection(server, id2, opts) {
|
|
5448
|
-
const socket = new MockPartyClient(server, id2);
|
|
5449
|
-
const url = new URL("http://localhost");
|
|
5450
|
-
if (opts?.query) for (const [key, value] of Object.entries(opts.query)) url.searchParams.set(key, String(value));
|
|
5451
|
-
const request2 = new Request(url.toString(), {
|
|
5452
|
-
method: "GET",
|
|
5453
|
-
headers: {
|
|
5454
|
-
"Content-Type": "application/json",
|
|
5455
|
-
...opts?.headers || {}
|
|
5456
|
-
}
|
|
5457
|
-
});
|
|
5458
|
-
await server.onConnect(socket.conn, { request: request2 });
|
|
5459
|
-
this.clients.set(socket.id, socket);
|
|
5460
|
-
return socket;
|
|
5461
|
-
}
|
|
5462
|
-
broadcast(data) {
|
|
5463
|
-
this.clients.forEach((client) => {
|
|
5464
|
-
client._trigger("message", data);
|
|
5465
|
-
});
|
|
5466
|
-
}
|
|
5467
|
-
getConnection(id2) {
|
|
5468
|
-
return this.clients.get(id2);
|
|
5469
|
-
}
|
|
5470
|
-
getConnections() {
|
|
5471
|
-
return Array.from(this.clients.values()).map((client) => client.conn);
|
|
5472
|
-
}
|
|
5473
|
-
clear() {
|
|
5474
|
-
this.clients.clear();
|
|
5475
|
-
}
|
|
5476
|
-
};
|
|
5477
|
-
var MockConnection = class {
|
|
5478
|
-
static {
|
|
5479
|
-
__name(this, "MockConnection");
|
|
5480
|
-
}
|
|
5481
|
-
client;
|
|
5482
|
-
server;
|
|
5483
|
-
id;
|
|
5484
|
-
constructor(client) {
|
|
5485
|
-
this.client = client;
|
|
5486
|
-
this.state = {};
|
|
5487
|
-
this.server = client.server;
|
|
5488
|
-
this.id = client.id;
|
|
5489
|
-
}
|
|
5490
|
-
state;
|
|
5491
|
-
setState(value) {
|
|
5492
|
-
this.state = value;
|
|
5493
|
-
}
|
|
5494
|
-
send(data) {
|
|
5495
|
-
this.client._trigger("message", data);
|
|
5496
|
-
}
|
|
5497
|
-
close() {
|
|
5498
|
-
this.server.onClose(this);
|
|
5893
|
+
/**
|
|
5894
|
+
* @method createEnhancedRequest
|
|
5895
|
+
* @private
|
|
5896
|
+
* @param {Party.Request} originalReq - The original request received from the shard
|
|
5897
|
+
* @param {string | null} originalClientIp - The original client IP, if available
|
|
5898
|
+
* @description Creates an enhanced request object that preserves the original client context
|
|
5899
|
+
* @returns {Party.Request} The enhanced request object
|
|
5900
|
+
*/
|
|
5901
|
+
createEnhancedRequest(originalReq, originalClientIp) {
|
|
5902
|
+
const clonedReq = originalReq.clone();
|
|
5903
|
+
clonedReq.viaShard = true;
|
|
5904
|
+
if (originalClientIp) clonedReq.originalClientIp = originalClientIp;
|
|
5905
|
+
return clonedReq;
|
|
5499
5906
|
}
|
|
5500
5907
|
};
|
|
5501
|
-
var ServerIo = MockPartyRoom;
|
|
5502
5908
|
var JWTAuth = class {
|
|
5503
|
-
static {
|
|
5504
|
-
__name(this, "JWTAuth");
|
|
5505
|
-
}
|
|
5506
|
-
secret;
|
|
5507
|
-
encoder;
|
|
5508
|
-
decoder;
|
|
5509
5909
|
/**
|
|
5510
5910
|
* Constructor for the JWTAuth class
|
|
5511
5911
|
* @param {string} secret - The secret key used for signing and verifying tokens
|
|
@@ -5615,7 +6015,7 @@ var JWTAuth = class {
|
|
|
5615
6015
|
}
|
|
5616
6016
|
}
|
|
5617
6017
|
};
|
|
5618
|
-
var guardManageWorld =
|
|
6018
|
+
var guardManageWorld = async (_, req, room) => {
|
|
5619
6019
|
const tokenShard = req.headers.get("x-access-shard");
|
|
5620
6020
|
if (tokenShard) {
|
|
5621
6021
|
if (tokenShard !== room.env.SHARD_SECRET) return false;
|
|
@@ -5631,18 +6031,7 @@ var guardManageWorld = /* @__PURE__ */ __name(async (_, req, room) => {
|
|
|
5631
6031
|
return false;
|
|
5632
6032
|
}
|
|
5633
6033
|
return true;
|
|
5634
|
-
}
|
|
5635
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
5636
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5637
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5638
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5639
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5640
|
-
}
|
|
5641
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
5642
|
-
function _ts_metadata(k, v) {
|
|
5643
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5644
|
-
}
|
|
5645
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
6034
|
+
};
|
|
5646
6035
|
var MAX_PLAYERS_PER_SHARD = 75;
|
|
5647
6036
|
z.object({
|
|
5648
6037
|
name: z.string(),
|
|
@@ -5678,61 +6067,48 @@ z.object({
|
|
|
5678
6067
|
maxConnections: z.number().int().positive()
|
|
5679
6068
|
}).optional()
|
|
5680
6069
|
});
|
|
5681
|
-
var RoomConfig = class
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
minShards = signal(1);
|
|
5691
|
-
maxShards = signal(void 0);
|
|
6070
|
+
var RoomConfig = class {
|
|
6071
|
+
constructor() {
|
|
6072
|
+
this.name = signal$1("");
|
|
6073
|
+
this.balancingStrategy = signal$1("round-robin");
|
|
6074
|
+
this.public = signal$1(true);
|
|
6075
|
+
this.maxPlayersPerShard = signal$1(MAX_PLAYERS_PER_SHARD);
|
|
6076
|
+
this.minShards = signal$1(1);
|
|
6077
|
+
this.maxShards = signal$1(void 0);
|
|
6078
|
+
}
|
|
5692
6079
|
};
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
var ShardInfo = class
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
status = signal("active");
|
|
5710
|
-
lastHeartbeat = signal(0);
|
|
6080
|
+
__decorateClass([id()], RoomConfig.prototype, "id", 2);
|
|
6081
|
+
__decorateClass([sync()], RoomConfig.prototype, "name", 2);
|
|
6082
|
+
__decorateClass([sync()], RoomConfig.prototype, "balancingStrategy", 2);
|
|
6083
|
+
__decorateClass([sync()], RoomConfig.prototype, "public", 2);
|
|
6084
|
+
__decorateClass([sync()], RoomConfig.prototype, "maxPlayersPerShard", 2);
|
|
6085
|
+
__decorateClass([sync()], RoomConfig.prototype, "minShards", 2);
|
|
6086
|
+
__decorateClass([sync()], RoomConfig.prototype, "maxShards", 2);
|
|
6087
|
+
var ShardInfo = class {
|
|
6088
|
+
constructor() {
|
|
6089
|
+
this.roomId = signal$1("");
|
|
6090
|
+
this.url = signal$1("");
|
|
6091
|
+
this.currentConnections = signal$1(0);
|
|
6092
|
+
this.maxConnections = signal$1(MAX_PLAYERS_PER_SHARD);
|
|
6093
|
+
this.status = signal$1("active");
|
|
6094
|
+
this.lastHeartbeat = signal$1(0);
|
|
6095
|
+
}
|
|
5711
6096
|
};
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
6097
|
+
__decorateClass([id()], ShardInfo.prototype, "id", 2);
|
|
6098
|
+
__decorateClass([sync()], ShardInfo.prototype, "roomId", 2);
|
|
6099
|
+
__decorateClass([sync()], ShardInfo.prototype, "url", 2);
|
|
6100
|
+
__decorateClass([sync({ persist: false })], ShardInfo.prototype, "currentConnections", 2);
|
|
6101
|
+
__decorateClass([sync()], ShardInfo.prototype, "maxConnections", 2);
|
|
6102
|
+
__decorateClass([sync()], ShardInfo.prototype, "status", 2);
|
|
6103
|
+
__decorateClass([sync()], ShardInfo.prototype, "lastHeartbeat", 2);
|
|
5719
6104
|
var WorldRoom = class {
|
|
5720
|
-
static {
|
|
5721
|
-
__name(this, "WorldRoom");
|
|
5722
|
-
}
|
|
5723
|
-
room;
|
|
5724
|
-
rooms;
|
|
5725
|
-
shards;
|
|
5726
|
-
rrCounters;
|
|
5727
|
-
defaultShardUrlTemplate;
|
|
5728
|
-
defaultMaxConnectionsPerShard;
|
|
5729
6105
|
constructor(room) {
|
|
5730
6106
|
this.room = room;
|
|
5731
|
-
this.rooms = signal({});
|
|
5732
|
-
this.shards = signal({});
|
|
5733
|
-
this.rrCounters = signal({});
|
|
5734
|
-
this.defaultShardUrlTemplate = signal("{shardId}");
|
|
5735
|
-
this.defaultMaxConnectionsPerShard = signal(MAX_PLAYERS_PER_SHARD);
|
|
6107
|
+
this.rooms = signal$1({});
|
|
6108
|
+
this.shards = signal$1({});
|
|
6109
|
+
this.rrCounters = signal$1({});
|
|
6110
|
+
this.defaultShardUrlTemplate = signal$1("{shardId}");
|
|
6111
|
+
this.defaultMaxConnectionsPerShard = signal$1(MAX_PLAYERS_PER_SHARD);
|
|
5736
6112
|
const { AUTH_JWT_SECRET, SHARD_SECRET } = this.room.env;
|
|
5737
6113
|
if (!AUTH_JWT_SECRET) throw new Error("AUTH_JWT_SECRET env variable is not set");
|
|
5738
6114
|
if (!SHARD_SECRET) throw new Error("SHARD_SECRET env variable is not set");
|
|
@@ -5843,15 +6219,14 @@ var WorldRoom = class {
|
|
|
5843
6219
|
async findOptimalShard(roomId, autoCreate = true) {
|
|
5844
6220
|
let room = this.rooms()[roomId];
|
|
5845
6221
|
if (!room) if (autoCreate) {
|
|
5846
|
-
|
|
6222
|
+
await this.registerRoom({ json: async () => ({
|
|
5847
6223
|
name: roomId,
|
|
5848
6224
|
balancingStrategy: "round-robin",
|
|
5849
6225
|
public: true,
|
|
5850
6226
|
maxPlayersPerShard: this.defaultMaxConnectionsPerShard(),
|
|
5851
6227
|
minShards: 1,
|
|
5852
6228
|
maxShards: void 0
|
|
5853
|
-
})
|
|
5854
|
-
await this.registerRoom(mockRequest);
|
|
6229
|
+
}) });
|
|
5855
6230
|
room = this.rooms()[roomId];
|
|
5856
6231
|
if (!room) return { error: `Failed to create room ${roomId}` };
|
|
5857
6232
|
} else return { error: `Room ${roomId} does not exist` };
|
|
@@ -5908,73 +6283,31 @@ var WorldRoom = class {
|
|
|
5908
6283
|
return newShard;
|
|
5909
6284
|
}
|
|
5910
6285
|
};
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
path: "scale-room",
|
|
5937
|
-
method: "POST"
|
|
5938
|
-
}),
|
|
5939
|
-
Guard([guardManageWorld]),
|
|
5940
|
-
_ts_metadata("design:type", Function),
|
|
5941
|
-
_ts_metadata("design:paramtypes", [Object, typeof ServerResponse === "undefined" ? Object : ServerResponse]),
|
|
5942
|
-
_ts_metadata("design:returntype", Promise)
|
|
5943
|
-
], WorldRoom.prototype, "scaleRoom", null);
|
|
5944
|
-
_ts_decorate([
|
|
5945
|
-
Request2({
|
|
5946
|
-
path: "connect",
|
|
5947
|
-
method: "POST"
|
|
5948
|
-
}),
|
|
5949
|
-
_ts_metadata("design:type", Function),
|
|
5950
|
-
_ts_metadata("design:paramtypes", [Object, typeof ServerResponse === "undefined" ? Object : ServerResponse]),
|
|
5951
|
-
_ts_metadata("design:returntype", Promise)
|
|
5952
|
-
], WorldRoom.prototype, "connect", null);
|
|
5953
|
-
WorldRoom = _ts_decorate([
|
|
5954
|
-
Room({
|
|
5955
|
-
path: "world-{worldId}",
|
|
5956
|
-
maxUsers: 100,
|
|
5957
|
-
throttleStorage: 2e3,
|
|
5958
|
-
throttleSync: 500
|
|
5959
|
-
}),
|
|
5960
|
-
_ts_metadata("design:type", Function),
|
|
5961
|
-
_ts_metadata("design:paramtypes", [Object])
|
|
5962
|
-
], WorldRoom);
|
|
5963
|
-
function createRequireSessionGuard(storage) {
|
|
5964
|
-
return async (sender, value) => {
|
|
5965
|
-
if (!sender || !sender.id) return false;
|
|
5966
|
-
try {
|
|
5967
|
-
const session = await storage.get(`session:${sender.id}`);
|
|
5968
|
-
if (!session) return false;
|
|
5969
|
-
if (!session.publicId) return false;
|
|
5970
|
-
return true;
|
|
5971
|
-
} catch (error) {
|
|
5972
|
-
console.error("Error checking session in requireSession guard:", error);
|
|
5973
|
-
return false;
|
|
5974
|
-
}
|
|
5975
|
-
};
|
|
5976
|
-
}
|
|
5977
|
-
__name(createRequireSessionGuard, "createRequireSessionGuard");
|
|
6286
|
+
__decorateClass([sync(RoomConfig)], WorldRoom.prototype, "rooms", 2);
|
|
6287
|
+
__decorateClass([sync(ShardInfo)], WorldRoom.prototype, "shards", 2);
|
|
6288
|
+
__decorateClass([persist()], WorldRoom.prototype, "rrCounters", 2);
|
|
6289
|
+
__decorateClass([Request2({
|
|
6290
|
+
path: "register-room",
|
|
6291
|
+
method: "POST"
|
|
6292
|
+
}), Guard([guardManageWorld])], WorldRoom.prototype, "registerRoom", 1);
|
|
6293
|
+
__decorateClass([Request2({
|
|
6294
|
+
path: "update-shard",
|
|
6295
|
+
method: "POST"
|
|
6296
|
+
}), Guard([guardManageWorld])], WorldRoom.prototype, "updateShardStats", 1);
|
|
6297
|
+
__decorateClass([Request2({
|
|
6298
|
+
path: "scale-room",
|
|
6299
|
+
method: "POST"
|
|
6300
|
+
}), Guard([guardManageWorld])], WorldRoom.prototype, "scaleRoom", 1);
|
|
6301
|
+
__decorateClass([Request2({
|
|
6302
|
+
path: "connect",
|
|
6303
|
+
method: "POST"
|
|
6304
|
+
})], WorldRoom.prototype, "connect", 1);
|
|
6305
|
+
WorldRoom = __decorateClass([Room({
|
|
6306
|
+
path: "world-{worldId}",
|
|
6307
|
+
maxUsers: 100,
|
|
6308
|
+
throttleStorage: 2e3,
|
|
6309
|
+
throttleSync: 500
|
|
6310
|
+
})], WorldRoom);
|
|
5978
6311
|
//#endregion
|
|
5979
6312
|
//#region src/Player/ComponentManager.ts
|
|
5980
6313
|
/**
|
|
@@ -6576,7 +6909,7 @@ var MoveList = class MoveList {
|
|
|
6576
6909
|
break;
|
|
6577
6910
|
}
|
|
6578
6911
|
let direction = method(newDirection);
|
|
6579
|
-
if (isFunction(direction)) direction = direction(player, map);
|
|
6912
|
+
if (isFunction$1(direction)) direction = direction(player, map);
|
|
6580
6913
|
return direction;
|
|
6581
6914
|
};
|
|
6582
6915
|
}
|
|
@@ -9880,7 +10213,7 @@ function WithSkillManager(Base) {
|
|
|
9880
10213
|
throw SkillLog.chanceToUseFailed(skill);
|
|
9881
10214
|
}
|
|
9882
10215
|
if (otherPlayer) {
|
|
9883
|
-
const players = isArray(otherPlayer) ? otherPlayer : [otherPlayer];
|
|
10216
|
+
const players = isArray$2(otherPlayer) ? otherPlayer : [otherPlayer];
|
|
9884
10217
|
for (const player of players) {
|
|
9885
10218
|
this.applyStates(player, skill);
|
|
9886
10219
|
player.applyDamage(this, skill);
|
|
@@ -10521,7 +10854,7 @@ var RpgPlayer = class extends BasicPlayerMixins(RpgCommonPlayer) {
|
|
|
10521
10854
|
const height = hitbox?.h ?? 32;
|
|
10522
10855
|
const centerX = positions.x + width / 2;
|
|
10523
10856
|
const centerY = positions.y + height / 2;
|
|
10524
|
-
this.map.physic.
|
|
10857
|
+
this.map.physic.teleportEntity(entity, {
|
|
10525
10858
|
x: centerX,
|
|
10526
10859
|
y: centerY
|
|
10527
10860
|
});
|
|
@@ -11294,18 +11627,58 @@ var RpgEvent = class extends RpgPlayer {
|
|
|
11294
11627
|
*
|
|
11295
11628
|
* Stops all movements before removing to prevent "unable to resolve entity" errors
|
|
11296
11629
|
* from the MovementManager when the entity is destroyed while moving.
|
|
11630
|
+
*
|
|
11631
|
+
* Pass options to keep the sprite visible briefly on clients while
|
|
11632
|
+
* `sprite.onBeforeRemove` runs a visual transition. Gameplay collision is
|
|
11633
|
+
* removed immediately; the event is deleted from the map after `timeoutMs`.
|
|
11634
|
+
*
|
|
11635
|
+
* The server only sends the removal context. The client decides how to render
|
|
11636
|
+
* `transition` in `sprite.onBeforeRemove`, so the payload can describe an
|
|
11637
|
+
* animation, sound, particle effect, GUI transition, or project-specific data.
|
|
11638
|
+
*
|
|
11639
|
+
* @example
|
|
11640
|
+
* ```ts
|
|
11641
|
+
* event.remove({
|
|
11642
|
+
* reason: 'defeated',
|
|
11643
|
+
* transition: {
|
|
11644
|
+
* type: 'enemy-death',
|
|
11645
|
+
* animation: 'die',
|
|
11646
|
+
* graphic: 'slime_die',
|
|
11647
|
+
* sound: 'slime-death',
|
|
11648
|
+
* duration: 700
|
|
11649
|
+
* },
|
|
11650
|
+
* timeoutMs: 700
|
|
11651
|
+
* })
|
|
11652
|
+
* ```
|
|
11297
11653
|
*/
|
|
11298
|
-
remove() {
|
|
11654
|
+
remove(options) {
|
|
11299
11655
|
const map = this.getCurrentMap();
|
|
11300
11656
|
if (!map) return;
|
|
11301
11657
|
this.stopMoveTo();
|
|
11302
|
-
|
|
11658
|
+
const timeoutMs = Math.max(0, options?.timeoutMs ?? options?.transition?.duration ?? 0);
|
|
11659
|
+
if (!options || timeoutMs <= 0) {
|
|
11660
|
+
map.removeEvent(this.id);
|
|
11661
|
+
return;
|
|
11662
|
+
}
|
|
11663
|
+
this._removeTransition.set(JSON.stringify({
|
|
11664
|
+
active: true,
|
|
11665
|
+
reason: options.reason,
|
|
11666
|
+
data: options.data,
|
|
11667
|
+
transition: options.transition,
|
|
11668
|
+
timeoutMs
|
|
11669
|
+
}));
|
|
11670
|
+
map.removeHitbox?.(this.id, this, "npc");
|
|
11671
|
+
setTimeout(() => {
|
|
11672
|
+
map.removeEvent(this.id);
|
|
11673
|
+
}, timeoutMs);
|
|
11303
11674
|
}
|
|
11304
11675
|
isEvent() {
|
|
11305
11676
|
return true;
|
|
11306
11677
|
}
|
|
11307
11678
|
};
|
|
11308
|
-
|
|
11679
|
+
//#endregion
|
|
11680
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
11681
|
+
var _a$1;
|
|
11309
11682
|
function $constructor(name, initializer, params) {
|
|
11310
11683
|
function init(inst, def) {
|
|
11311
11684
|
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
@@ -11356,13 +11729,14 @@ var $ZodEncodeError = class extends Error {
|
|
|
11356
11729
|
this.name = "ZodEncodeError";
|
|
11357
11730
|
}
|
|
11358
11731
|
};
|
|
11359
|
-
|
|
11732
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
11733
|
+
var globalConfig = globalThis.__zod_globalConfig;
|
|
11360
11734
|
function config(newConfig) {
|
|
11361
11735
|
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
11362
11736
|
return globalConfig;
|
|
11363
11737
|
}
|
|
11364
11738
|
//#endregion
|
|
11365
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
11739
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
|
|
11366
11740
|
function getEnumValues(entries) {
|
|
11367
11741
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
11368
11742
|
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -11390,17 +11764,13 @@ function cleanRegex(source) {
|
|
|
11390
11764
|
return source.slice(start, end);
|
|
11391
11765
|
}
|
|
11392
11766
|
function floatSafeRemainder(val, step) {
|
|
11393
|
-
const
|
|
11394
|
-
const
|
|
11395
|
-
|
|
11396
|
-
if (
|
|
11397
|
-
|
|
11398
|
-
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
11399
|
-
}
|
|
11400
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
11401
|
-
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
11767
|
+
const ratio = val / step;
|
|
11768
|
+
const roundedRatio = Math.round(ratio);
|
|
11769
|
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
11770
|
+
if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
|
|
11771
|
+
return ratio - roundedRatio;
|
|
11402
11772
|
}
|
|
11403
|
-
var EVALUATING = Symbol("evaluating");
|
|
11773
|
+
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
11404
11774
|
function defineLazy(object, key, getter) {
|
|
11405
11775
|
let value = void 0;
|
|
11406
11776
|
Object.defineProperty(object, key, {
|
|
@@ -11441,7 +11811,8 @@ var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace :
|
|
|
11441
11811
|
function isObject(data) {
|
|
11442
11812
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
11443
11813
|
}
|
|
11444
|
-
var allowsEval = cached(() => {
|
|
11814
|
+
var allowsEval = /* @__PURE__ */ cached(() => {
|
|
11815
|
+
if (globalConfig.jitless) return false;
|
|
11445
11816
|
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
11446
11817
|
try {
|
|
11447
11818
|
new Function("");
|
|
@@ -11463,9 +11834,11 @@ function isPlainObject(o) {
|
|
|
11463
11834
|
function shallowClone(o) {
|
|
11464
11835
|
if (isPlainObject(o)) return { ...o };
|
|
11465
11836
|
if (Array.isArray(o)) return [...o];
|
|
11837
|
+
if (o instanceof Map) return new Map(o);
|
|
11838
|
+
if (o instanceof Set) return new Set(o);
|
|
11466
11839
|
return o;
|
|
11467
11840
|
}
|
|
11468
|
-
var propertyKeyTypes = new Set([
|
|
11841
|
+
var propertyKeyTypes = /* @__PURE__ */ new Set([
|
|
11469
11842
|
"string",
|
|
11470
11843
|
"number",
|
|
11471
11844
|
"symbol"
|
|
@@ -11569,6 +11942,7 @@ function safeExtend(schema, shape) {
|
|
|
11569
11942
|
} }));
|
|
11570
11943
|
}
|
|
11571
11944
|
function merge(a, b) {
|
|
11945
|
+
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
11572
11946
|
return clone(a, mergeDefs(a._zod.def, {
|
|
11573
11947
|
get shape() {
|
|
11574
11948
|
const _shape = {
|
|
@@ -11581,7 +11955,7 @@ function merge(a, b) {
|
|
|
11581
11955
|
get catchall() {
|
|
11582
11956
|
return b._zod.def.catchall;
|
|
11583
11957
|
},
|
|
11584
|
-
checks: []
|
|
11958
|
+
checks: b._zod.def.checks ?? []
|
|
11585
11959
|
}));
|
|
11586
11960
|
}
|
|
11587
11961
|
function partial(Class, schema, mask) {
|
|
@@ -11634,6 +12008,11 @@ function aborted(x, startIndex = 0) {
|
|
|
11634
12008
|
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
11635
12009
|
return false;
|
|
11636
12010
|
}
|
|
12011
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
12012
|
+
if (x.aborted === true) return true;
|
|
12013
|
+
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
|
|
12014
|
+
return false;
|
|
12015
|
+
}
|
|
11637
12016
|
function prefixIssues(path, issues) {
|
|
11638
12017
|
return issues.map((iss) => {
|
|
11639
12018
|
var _a;
|
|
@@ -11646,15 +12025,12 @@ function unwrapMessage(message) {
|
|
|
11646
12025
|
return typeof message === "string" ? message : message?.message;
|
|
11647
12026
|
}
|
|
11648
12027
|
function finalizeIssue(iss, ctx, config) {
|
|
11649
|
-
const
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
if (
|
|
11654
|
-
|
|
11655
|
-
delete full.continue;
|
|
11656
|
-
if (!ctx?.reportInput) delete full.input;
|
|
11657
|
-
return full;
|
|
12028
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
12029
|
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
12030
|
+
rest.path ?? (rest.path = []);
|
|
12031
|
+
rest.message = message;
|
|
12032
|
+
if (ctx?.reportInput) rest.input = _input;
|
|
12033
|
+
return rest;
|
|
11658
12034
|
}
|
|
11659
12035
|
function getLengthableOrigin(input) {
|
|
11660
12036
|
if (Array.isArray(input)) return "array";
|
|
@@ -11672,7 +12048,7 @@ function issue(...args) {
|
|
|
11672
12048
|
return { ...iss };
|
|
11673
12049
|
}
|
|
11674
12050
|
//#endregion
|
|
11675
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
12051
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
|
|
11676
12052
|
var initializer$1 = (inst, def) => {
|
|
11677
12053
|
inst.name = "$ZodError";
|
|
11678
12054
|
Object.defineProperty(inst, "_zod", {
|
|
@@ -11705,23 +12081,26 @@ function flattenError(error, mapper = (issue) => issue.message) {
|
|
|
11705
12081
|
}
|
|
11706
12082
|
function formatError(error, mapper = (issue) => issue.message) {
|
|
11707
12083
|
const fieldErrors = { _errors: [] };
|
|
11708
|
-
const processError = (error) => {
|
|
11709
|
-
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
|
|
11710
|
-
else if (issue.code === "invalid_key") processError({ issues: issue.issues });
|
|
11711
|
-
else if (issue.code === "invalid_element") processError({ issues: issue.issues });
|
|
11712
|
-
else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
12084
|
+
const processError = (error, path = []) => {
|
|
12085
|
+
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
12086
|
+
else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
12087
|
+
else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
11713
12088
|
else {
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
curr[el]
|
|
12089
|
+
const fullpath = [...path, ...issue.path];
|
|
12090
|
+
if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
12091
|
+
else {
|
|
12092
|
+
let curr = fieldErrors;
|
|
12093
|
+
let i = 0;
|
|
12094
|
+
while (i < fullpath.length) {
|
|
12095
|
+
const el = fullpath[i];
|
|
12096
|
+
if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
12097
|
+
else {
|
|
12098
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
12099
|
+
curr[el]._errors.push(mapper(issue));
|
|
12100
|
+
}
|
|
12101
|
+
curr = curr[el];
|
|
12102
|
+
i++;
|
|
11722
12103
|
}
|
|
11723
|
-
curr = curr[el];
|
|
11724
|
-
i++;
|
|
11725
12104
|
}
|
|
11726
12105
|
}
|
|
11727
12106
|
};
|
|
@@ -11729,9 +12108,12 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
11729
12108
|
return fieldErrors;
|
|
11730
12109
|
}
|
|
11731
12110
|
//#endregion
|
|
11732
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
12111
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
|
|
11733
12112
|
var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
11734
|
-
const ctx = _ctx ?
|
|
12113
|
+
const ctx = _ctx ? {
|
|
12114
|
+
..._ctx,
|
|
12115
|
+
async: false
|
|
12116
|
+
} : { async: false };
|
|
11735
12117
|
const result = schema._zod.run({
|
|
11736
12118
|
value,
|
|
11737
12119
|
issues: []
|
|
@@ -11745,7 +12127,10 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
11745
12127
|
return result.value;
|
|
11746
12128
|
};
|
|
11747
12129
|
var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
11748
|
-
const ctx = _ctx ?
|
|
12130
|
+
const ctx = _ctx ? {
|
|
12131
|
+
..._ctx,
|
|
12132
|
+
async: true
|
|
12133
|
+
} : { async: true };
|
|
11749
12134
|
let result = schema._zod.run({
|
|
11750
12135
|
value,
|
|
11751
12136
|
issues: []
|
|
@@ -11778,7 +12163,10 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
11778
12163
|
};
|
|
11779
12164
|
var safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
11780
12165
|
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
11781
|
-
const ctx = _ctx ?
|
|
12166
|
+
const ctx = _ctx ? {
|
|
12167
|
+
..._ctx,
|
|
12168
|
+
async: true
|
|
12169
|
+
} : { async: true };
|
|
11782
12170
|
let result = schema._zod.run({
|
|
11783
12171
|
value,
|
|
11784
12172
|
issues: []
|
|
@@ -11794,36 +12182,53 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
11794
12182
|
};
|
|
11795
12183
|
var safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
11796
12184
|
var _encode = (_Err) => (schema, value, _ctx) => {
|
|
11797
|
-
const ctx = _ctx ?
|
|
12185
|
+
const ctx = _ctx ? {
|
|
12186
|
+
..._ctx,
|
|
12187
|
+
direction: "backward"
|
|
12188
|
+
} : { direction: "backward" };
|
|
11798
12189
|
return _parse(_Err)(schema, value, ctx);
|
|
11799
12190
|
};
|
|
11800
12191
|
var _decode = (_Err) => (schema, value, _ctx) => {
|
|
11801
12192
|
return _parse(_Err)(schema, value, _ctx);
|
|
11802
12193
|
};
|
|
11803
12194
|
var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
11804
|
-
const ctx = _ctx ?
|
|
12195
|
+
const ctx = _ctx ? {
|
|
12196
|
+
..._ctx,
|
|
12197
|
+
direction: "backward"
|
|
12198
|
+
} : { direction: "backward" };
|
|
11805
12199
|
return _parseAsync(_Err)(schema, value, ctx);
|
|
11806
12200
|
};
|
|
11807
12201
|
var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
11808
12202
|
return _parseAsync(_Err)(schema, value, _ctx);
|
|
11809
12203
|
};
|
|
11810
12204
|
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
11811
|
-
const ctx = _ctx ?
|
|
12205
|
+
const ctx = _ctx ? {
|
|
12206
|
+
..._ctx,
|
|
12207
|
+
direction: "backward"
|
|
12208
|
+
} : { direction: "backward" };
|
|
11812
12209
|
return _safeParse(_Err)(schema, value, ctx);
|
|
11813
12210
|
};
|
|
11814
12211
|
var _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
11815
12212
|
return _safeParse(_Err)(schema, value, _ctx);
|
|
11816
12213
|
};
|
|
11817
12214
|
var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
11818
|
-
const ctx = _ctx ?
|
|
12215
|
+
const ctx = _ctx ? {
|
|
12216
|
+
..._ctx,
|
|
12217
|
+
direction: "backward"
|
|
12218
|
+
} : { direction: "backward" };
|
|
11819
12219
|
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
11820
12220
|
};
|
|
11821
12221
|
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
11822
12222
|
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
11823
12223
|
};
|
|
11824
12224
|
//#endregion
|
|
11825
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
11826
|
-
|
|
12225
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
|
|
12226
|
+
/**
|
|
12227
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
12228
|
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
12229
|
+
* See https://github.com/paralleldrive/cuid.
|
|
12230
|
+
*/
|
|
12231
|
+
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
11827
12232
|
var cuid2 = /^[0-9a-z]+$/;
|
|
11828
12233
|
var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
11829
12234
|
var xid = /^[0-9a-vA-V]{20}$/;
|
|
@@ -11852,6 +12257,7 @@ var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]
|
|
|
11852
12257
|
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
11853
12258
|
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
11854
12259
|
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
12260
|
+
var httpProtocol = /^https?$/;
|
|
11855
12261
|
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
11856
12262
|
var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
11857
12263
|
var date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
@@ -11879,7 +12285,7 @@ var number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
|
11879
12285
|
var lowercase = /^[^A-Z]*$/;
|
|
11880
12286
|
var uppercase = /^[^a-z]*$/;
|
|
11881
12287
|
//#endregion
|
|
11882
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
12288
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
|
|
11883
12289
|
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
11884
12290
|
var _a;
|
|
11885
12291
|
inst._zod ?? (inst._zod = {});
|
|
@@ -12237,7 +12643,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
|
|
|
12237
12643
|
};
|
|
12238
12644
|
});
|
|
12239
12645
|
//#endregion
|
|
12240
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
12646
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
|
|
12241
12647
|
var Doc = class {
|
|
12242
12648
|
constructor(args = []) {
|
|
12243
12649
|
this.content = [];
|
|
@@ -12268,14 +12674,14 @@ var Doc = class {
|
|
|
12268
12674
|
}
|
|
12269
12675
|
};
|
|
12270
12676
|
//#endregion
|
|
12271
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
12677
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
|
|
12272
12678
|
var version = {
|
|
12273
12679
|
major: 4,
|
|
12274
|
-
minor:
|
|
12275
|
-
patch:
|
|
12680
|
+
minor: 4,
|
|
12681
|
+
patch: 3
|
|
12276
12682
|
};
|
|
12277
12683
|
//#endregion
|
|
12278
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
12684
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
|
|
12279
12685
|
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
12280
12686
|
var _a;
|
|
12281
12687
|
inst ?? (inst = {});
|
|
@@ -12296,6 +12702,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
12296
12702
|
let asyncResult;
|
|
12297
12703
|
for (const ch of checks) {
|
|
12298
12704
|
if (ch._zod.def.when) {
|
|
12705
|
+
if (explicitlyAborted(payload)) continue;
|
|
12299
12706
|
if (!ch._zod.def.when(payload)) continue;
|
|
12300
12707
|
} else if (isAborted) continue;
|
|
12301
12708
|
const currLen = payload.issues.length;
|
|
@@ -12415,6 +12822,19 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
12415
12822
|
inst._zod.check = (payload) => {
|
|
12416
12823
|
try {
|
|
12417
12824
|
const trimmed = payload.value.trim();
|
|
12825
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
12826
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
12827
|
+
payload.issues.push({
|
|
12828
|
+
code: "invalid_format",
|
|
12829
|
+
format: "url",
|
|
12830
|
+
note: "Invalid URL format",
|
|
12831
|
+
input: payload.value,
|
|
12832
|
+
inst,
|
|
12833
|
+
continue: !def.abort
|
|
12834
|
+
});
|
|
12835
|
+
return;
|
|
12836
|
+
}
|
|
12837
|
+
}
|
|
12418
12838
|
const url = new URL(trimmed);
|
|
12419
12839
|
if (def.hostname) {
|
|
12420
12840
|
def.hostname.lastIndex = 0;
|
|
@@ -12462,6 +12882,11 @@ var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
|
12462
12882
|
def.pattern ?? (def.pattern = nanoid);
|
|
12463
12883
|
$ZodStringFormat.init(inst, def);
|
|
12464
12884
|
});
|
|
12885
|
+
/**
|
|
12886
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
12887
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
12888
|
+
* See https://github.com/paralleldrive/cuid.
|
|
12889
|
+
*/
|
|
12465
12890
|
var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
12466
12891
|
def.pattern ?? (def.pattern = cuid);
|
|
12467
12892
|
$ZodStringFormat.init(inst, def);
|
|
@@ -12551,6 +12976,7 @@ var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
12551
12976
|
});
|
|
12552
12977
|
function isValidBase64(data) {
|
|
12553
12978
|
if (data === "") return true;
|
|
12979
|
+
if (/\s/.test(data)) return false;
|
|
12554
12980
|
if (data.length % 4 !== 0) return false;
|
|
12555
12981
|
try {
|
|
12556
12982
|
atob(data);
|
|
@@ -12702,13 +13128,23 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
12702
13128
|
return payload;
|
|
12703
13129
|
};
|
|
12704
13130
|
});
|
|
12705
|
-
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
13131
|
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
|
13132
|
+
const isPresent = key in input;
|
|
12706
13133
|
if (result.issues.length) {
|
|
12707
|
-
if (isOptionalOut && !
|
|
13134
|
+
if (isOptionalIn && isOptionalOut && !isPresent) return;
|
|
12708
13135
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
12709
13136
|
}
|
|
13137
|
+
if (!isPresent && !isOptionalIn) {
|
|
13138
|
+
if (!result.issues.length) final.issues.push({
|
|
13139
|
+
code: "invalid_type",
|
|
13140
|
+
expected: "nonoptional",
|
|
13141
|
+
input: void 0,
|
|
13142
|
+
path: [key]
|
|
13143
|
+
});
|
|
13144
|
+
return;
|
|
13145
|
+
}
|
|
12710
13146
|
if (result.value === void 0) {
|
|
12711
|
-
if (
|
|
13147
|
+
if (isPresent) final.value[key] = void 0;
|
|
12712
13148
|
} else final.value[key] = result.value;
|
|
12713
13149
|
}
|
|
12714
13150
|
function normalizeDef(def) {
|
|
@@ -12728,8 +13164,10 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
12728
13164
|
const keySet = def.keySet;
|
|
12729
13165
|
const _catchall = def.catchall._zod;
|
|
12730
13166
|
const t = _catchall.def.type;
|
|
13167
|
+
const isOptionalIn = _catchall.optin === "optional";
|
|
12731
13168
|
const isOptionalOut = _catchall.optout === "optional";
|
|
12732
13169
|
for (const key in input) {
|
|
13170
|
+
if (key === "__proto__") continue;
|
|
12733
13171
|
if (keySet.has(key)) continue;
|
|
12734
13172
|
if (t === "never") {
|
|
12735
13173
|
unrecognized.push(key);
|
|
@@ -12739,8 +13177,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
12739
13177
|
value: input[key],
|
|
12740
13178
|
issues: []
|
|
12741
13179
|
}, ctx);
|
|
12742
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
12743
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
13180
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
13181
|
+
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
12744
13182
|
}
|
|
12745
13183
|
if (unrecognized.length) payload.issues.push({
|
|
12746
13184
|
code: "unrecognized_keys",
|
|
@@ -12796,13 +13234,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
12796
13234
|
const shape = value.shape;
|
|
12797
13235
|
for (const key of value.keys) {
|
|
12798
13236
|
const el = shape[key];
|
|
13237
|
+
const isOptionalIn = el._zod.optin === "optional";
|
|
12799
13238
|
const isOptionalOut = el._zod.optout === "optional";
|
|
12800
13239
|
const r = el._zod.run({
|
|
12801
13240
|
value: input[key],
|
|
12802
13241
|
issues: []
|
|
12803
13242
|
}, ctx);
|
|
12804
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
12805
|
-
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
13243
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
13244
|
+
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
12806
13245
|
}
|
|
12807
13246
|
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
12808
13247
|
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
@@ -12831,9 +13270,11 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
12831
13270
|
for (const key of normalized.keys) {
|
|
12832
13271
|
const id = ids[key];
|
|
12833
13272
|
const k = esc(key);
|
|
12834
|
-
const
|
|
13273
|
+
const schema = shape[key];
|
|
13274
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
13275
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
12835
13276
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
12836
|
-
if (isOptionalOut) doc.write(`
|
|
13277
|
+
if (isOptionalIn && isOptionalOut) doc.write(`
|
|
12837
13278
|
if (${id}.issues.length) {
|
|
12838
13279
|
if (${k} in input) {
|
|
12839
13280
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
@@ -12851,6 +13292,32 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
12851
13292
|
newResult[${k}] = ${id}.value;
|
|
12852
13293
|
}
|
|
12853
13294
|
|
|
13295
|
+
`);
|
|
13296
|
+
else if (!isOptionalIn) doc.write(`
|
|
13297
|
+
const ${id}_present = ${k} in input;
|
|
13298
|
+
if (${id}.issues.length) {
|
|
13299
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
13300
|
+
...iss,
|
|
13301
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
13302
|
+
})));
|
|
13303
|
+
}
|
|
13304
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
13305
|
+
payload.issues.push({
|
|
13306
|
+
code: "invalid_type",
|
|
13307
|
+
expected: "nonoptional",
|
|
13308
|
+
input: undefined,
|
|
13309
|
+
path: [${k}]
|
|
13310
|
+
});
|
|
13311
|
+
}
|
|
13312
|
+
|
|
13313
|
+
if (${id}_present) {
|
|
13314
|
+
if (${id}.value === undefined) {
|
|
13315
|
+
newResult[${k}] = undefined;
|
|
13316
|
+
} else {
|
|
13317
|
+
newResult[${k}] = ${id}.value;
|
|
13318
|
+
}
|
|
13319
|
+
}
|
|
13320
|
+
|
|
12854
13321
|
`);
|
|
12855
13322
|
else doc.write(`
|
|
12856
13323
|
if (${id}.issues.length) {
|
|
@@ -12876,7 +13343,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
12876
13343
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
12877
13344
|
};
|
|
12878
13345
|
let fastpass;
|
|
12879
|
-
const isObject$
|
|
13346
|
+
const isObject$4 = isObject;
|
|
12880
13347
|
const jit = !globalConfig.jitless;
|
|
12881
13348
|
const fastEnabled = jit && allowsEval.value;
|
|
12882
13349
|
const catchall = def.catchall;
|
|
@@ -12884,7 +13351,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
12884
13351
|
inst._zod.parse = (payload, ctx) => {
|
|
12885
13352
|
value ?? (value = _normalized.value);
|
|
12886
13353
|
const input = payload.value;
|
|
12887
|
-
if (!isObject$
|
|
13354
|
+
if (!isObject$4(input)) {
|
|
12888
13355
|
payload.issues.push({
|
|
12889
13356
|
expected: "object",
|
|
12890
13357
|
code: "invalid_type",
|
|
@@ -12933,10 +13400,9 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
12933
13400
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
12934
13401
|
}
|
|
12935
13402
|
});
|
|
12936
|
-
const
|
|
12937
|
-
const first = def.options[0]._zod.run;
|
|
13403
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
12938
13404
|
inst._zod.parse = (payload, ctx) => {
|
|
12939
|
-
if (
|
|
13405
|
+
if (first) return first(payload, ctx);
|
|
12940
13406
|
let async = false;
|
|
12941
13407
|
const results = [];
|
|
12942
13408
|
for (const option of def.options) {
|
|
@@ -13077,20 +13543,23 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
13077
13543
|
});
|
|
13078
13544
|
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
13079
13545
|
$ZodType.init(inst, def);
|
|
13546
|
+
inst._zod.optin = "optional";
|
|
13080
13547
|
inst._zod.parse = (payload, ctx) => {
|
|
13081
13548
|
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
13082
13549
|
const _out = def.transform(payload.value, payload);
|
|
13083
13550
|
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
13084
13551
|
payload.value = output;
|
|
13552
|
+
payload.fallback = true;
|
|
13085
13553
|
return payload;
|
|
13086
13554
|
});
|
|
13087
13555
|
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
13088
13556
|
payload.value = _out;
|
|
13557
|
+
payload.fallback = true;
|
|
13089
13558
|
return payload;
|
|
13090
13559
|
};
|
|
13091
13560
|
});
|
|
13092
13561
|
function handleOptionalResult(result, input) {
|
|
13093
|
-
if (result.issues.length
|
|
13562
|
+
if (input === void 0 && (result.issues.length || result.fallback)) return {
|
|
13094
13563
|
issues: [],
|
|
13095
13564
|
value: void 0
|
|
13096
13565
|
};
|
|
@@ -13109,9 +13578,10 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
|
13109
13578
|
});
|
|
13110
13579
|
inst._zod.parse = (payload, ctx) => {
|
|
13111
13580
|
if (def.innerType._zod.optin === "optional") {
|
|
13581
|
+
const input = payload.value;
|
|
13112
13582
|
const result = def.innerType._zod.run(payload, ctx);
|
|
13113
|
-
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r,
|
|
13114
|
-
return handleOptionalResult(result,
|
|
13583
|
+
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
|
|
13584
|
+
return handleOptionalResult(result, input);
|
|
13115
13585
|
}
|
|
13116
13586
|
if (payload.value === void 0) return payload;
|
|
13117
13587
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -13196,7 +13666,7 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
13196
13666
|
}
|
|
13197
13667
|
var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
13198
13668
|
$ZodType.init(inst, def);
|
|
13199
|
-
|
|
13669
|
+
inst._zod.optin = "optional";
|
|
13200
13670
|
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
13201
13671
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
13202
13672
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -13211,6 +13681,7 @@ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
13211
13681
|
input: payload.value
|
|
13212
13682
|
});
|
|
13213
13683
|
payload.issues = [];
|
|
13684
|
+
payload.fallback = true;
|
|
13214
13685
|
}
|
|
13215
13686
|
return payload;
|
|
13216
13687
|
});
|
|
@@ -13222,6 +13693,7 @@ var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
13222
13693
|
input: payload.value
|
|
13223
13694
|
});
|
|
13224
13695
|
payload.issues = [];
|
|
13696
|
+
payload.fallback = true;
|
|
13225
13697
|
}
|
|
13226
13698
|
return payload;
|
|
13227
13699
|
};
|
|
@@ -13250,7 +13722,8 @@ function handlePipeResult(left, next, ctx) {
|
|
|
13250
13722
|
}
|
|
13251
13723
|
return next._zod.run({
|
|
13252
13724
|
value: left.value,
|
|
13253
|
-
issues: left.issues
|
|
13725
|
+
issues: left.issues,
|
|
13726
|
+
fallback: left.fallback
|
|
13254
13727
|
}, ctx);
|
|
13255
13728
|
}
|
|
13256
13729
|
var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
@@ -13297,7 +13770,7 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
13297
13770
|
}
|
|
13298
13771
|
}
|
|
13299
13772
|
//#endregion
|
|
13300
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
13773
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
|
|
13301
13774
|
var _a;
|
|
13302
13775
|
var $ZodRegistry = class {
|
|
13303
13776
|
constructor() {
|
|
@@ -13344,7 +13817,7 @@ function registry() {
|
|
|
13344
13817
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
13345
13818
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
13346
13819
|
//#endregion
|
|
13347
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
13820
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
|
|
13348
13821
|
/* @__NO_SIDE_EFFECTS__ */
|
|
13349
13822
|
function _string(Class, params) {
|
|
13350
13823
|
return new Class({
|
|
@@ -13445,6 +13918,11 @@ function _nanoid(Class, params) {
|
|
|
13445
13918
|
...normalizeParams(params)
|
|
13446
13919
|
});
|
|
13447
13920
|
}
|
|
13921
|
+
/**
|
|
13922
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
13923
|
+
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
|
13924
|
+
* See https://github.com/paralleldrive/cuid.
|
|
13925
|
+
*/
|
|
13448
13926
|
/* @__NO_SIDE_EFFECTS__ */
|
|
13449
13927
|
function _cuid(Class, params) {
|
|
13450
13928
|
return new Class({
|
|
@@ -13813,7 +14291,7 @@ function _refine(Class, fn, _params) {
|
|
|
13813
14291
|
});
|
|
13814
14292
|
}
|
|
13815
14293
|
/* @__NO_SIDE_EFFECTS__ */
|
|
13816
|
-
function _superRefine(fn) {
|
|
14294
|
+
function _superRefine(fn, params) {
|
|
13817
14295
|
const ch = /* @__PURE__ */ _check((payload) => {
|
|
13818
14296
|
payload.addIssue = (issue$2) => {
|
|
13819
14297
|
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
|
|
@@ -13828,7 +14306,7 @@ function _superRefine(fn) {
|
|
|
13828
14306
|
}
|
|
13829
14307
|
};
|
|
13830
14308
|
return fn(payload.value, payload);
|
|
13831
|
-
});
|
|
14309
|
+
}, params);
|
|
13832
14310
|
return ch;
|
|
13833
14311
|
}
|
|
13834
14312
|
/* @__NO_SIDE_EFFECTS__ */
|
|
@@ -13841,7 +14319,7 @@ function _check(fn, params) {
|
|
|
13841
14319
|
return ch;
|
|
13842
14320
|
}
|
|
13843
14321
|
//#endregion
|
|
13844
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
14322
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
|
|
13845
14323
|
function initializeContext(params) {
|
|
13846
14324
|
let target = params?.target ?? "draft-2020-12";
|
|
13847
14325
|
if (target === "draft-4") target = "draft-04";
|
|
@@ -13860,7 +14338,7 @@ function initializeContext(params) {
|
|
|
13860
14338
|
external: params?.external ?? void 0
|
|
13861
14339
|
};
|
|
13862
14340
|
}
|
|
13863
|
-
function process(schema, ctx, _params = {
|
|
14341
|
+
function process$1(schema, ctx, _params = {
|
|
13864
14342
|
path: [],
|
|
13865
14343
|
schemaPath: []
|
|
13866
14344
|
}) {
|
|
@@ -13897,7 +14375,7 @@ function process(schema, ctx, _params = {
|
|
|
13897
14375
|
const parent = schema._zod.parent;
|
|
13898
14376
|
if (parent) {
|
|
13899
14377
|
if (!result.ref) result.ref = parent;
|
|
13900
|
-
process(parent, ctx, params);
|
|
14378
|
+
process$1(parent, ctx, params);
|
|
13901
14379
|
ctx.seen.get(parent).isParent = true;
|
|
13902
14380
|
}
|
|
13903
14381
|
}
|
|
@@ -13907,7 +14385,7 @@ function process(schema, ctx, _params = {
|
|
|
13907
14385
|
delete result.schema.examples;
|
|
13908
14386
|
delete result.schema.default;
|
|
13909
14387
|
}
|
|
13910
|
-
if (ctx.io === "input" && result.schema
|
|
14388
|
+
if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
13911
14389
|
delete result.schema._prefault;
|
|
13912
14390
|
return ctx.seen.get(schema).schema;
|
|
13913
14391
|
}
|
|
@@ -14047,10 +14525,15 @@ function finalize(ctx, schema) {
|
|
|
14047
14525
|
result.$id = ctx.external.uri(id);
|
|
14048
14526
|
}
|
|
14049
14527
|
Object.assign(result, root.def ?? root.schema);
|
|
14528
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
14529
|
+
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
|
|
14050
14530
|
const defs = ctx.external?.defs ?? {};
|
|
14051
14531
|
for (const entry of ctx.seen.entries()) {
|
|
14052
14532
|
const seen = entry[1];
|
|
14053
|
-
if (seen.def && seen.defId)
|
|
14533
|
+
if (seen.def && seen.defId) {
|
|
14534
|
+
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
14535
|
+
defs[seen.defId] = seen.def;
|
|
14536
|
+
}
|
|
14054
14537
|
}
|
|
14055
14538
|
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
14056
14539
|
else result.definitions = defs;
|
|
@@ -14084,7 +14567,10 @@ function isTransforming(_schema, _ctx) {
|
|
|
14084
14567
|
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
14085
14568
|
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
14086
14569
|
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
14087
|
-
if (def.type === "pipe")
|
|
14570
|
+
if (def.type === "pipe") {
|
|
14571
|
+
if (_schema._zod.traits.has("$ZodCodec")) return true;
|
|
14572
|
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
14573
|
+
}
|
|
14088
14574
|
if (def.type === "object") {
|
|
14089
14575
|
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
14090
14576
|
return false;
|
|
@@ -14109,7 +14595,7 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
14109
14595
|
...params,
|
|
14110
14596
|
processors
|
|
14111
14597
|
});
|
|
14112
|
-
process(schema, ctx);
|
|
14598
|
+
process$1(schema, ctx);
|
|
14113
14599
|
extractDefs(ctx, schema);
|
|
14114
14600
|
return finalize(ctx, schema);
|
|
14115
14601
|
};
|
|
@@ -14121,12 +14607,12 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
|
|
|
14121
14607
|
io,
|
|
14122
14608
|
processors
|
|
14123
14609
|
});
|
|
14124
|
-
process(schema, ctx);
|
|
14610
|
+
process$1(schema, ctx);
|
|
14125
14611
|
extractDefs(ctx, schema);
|
|
14126
14612
|
return finalize(ctx, schema);
|
|
14127
14613
|
};
|
|
14128
14614
|
//#endregion
|
|
14129
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
14615
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
|
|
14130
14616
|
var formatMap = {
|
|
14131
14617
|
guid: "uuid",
|
|
14132
14618
|
url: "uri",
|
|
@@ -14160,31 +14646,24 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
14160
14646
|
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
14161
14647
|
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
14162
14648
|
else json.type = "number";
|
|
14163
|
-
|
|
14649
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
14650
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
14651
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
14652
|
+
if (exMin) if (legacy) {
|
|
14164
14653
|
json.minimum = exclusiveMinimum;
|
|
14165
14654
|
json.exclusiveMinimum = true;
|
|
14166
14655
|
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
14167
|
-
if (typeof minimum === "number")
|
|
14168
|
-
|
|
14169
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
14170
|
-
else delete json.exclusiveMinimum;
|
|
14171
|
-
}
|
|
14172
|
-
if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
14656
|
+
else if (typeof minimum === "number") json.minimum = minimum;
|
|
14657
|
+
if (exMax) if (legacy) {
|
|
14173
14658
|
json.maximum = exclusiveMaximum;
|
|
14174
14659
|
json.exclusiveMaximum = true;
|
|
14175
14660
|
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
14176
|
-
if (typeof maximum === "number")
|
|
14177
|
-
json.maximum = maximum;
|
|
14178
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
14179
|
-
else delete json.exclusiveMaximum;
|
|
14180
|
-
}
|
|
14661
|
+
else if (typeof maximum === "number") json.maximum = maximum;
|
|
14181
14662
|
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
14182
14663
|
};
|
|
14183
14664
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
14184
14665
|
json.not = {};
|
|
14185
14666
|
};
|
|
14186
|
-
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
14187
|
-
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
14188
14667
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
14189
14668
|
const def = schema._zod.def;
|
|
14190
14669
|
const values = getEnumValues(def.entries);
|
|
@@ -14205,7 +14684,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
14205
14684
|
if (typeof minimum === "number") json.minItems = minimum;
|
|
14206
14685
|
if (typeof maximum === "number") json.maxItems = maximum;
|
|
14207
14686
|
json.type = "array";
|
|
14208
|
-
json.items = process(def.element, ctx, {
|
|
14687
|
+
json.items = process$1(def.element, ctx, {
|
|
14209
14688
|
...params,
|
|
14210
14689
|
path: [...params.path, "items"]
|
|
14211
14690
|
});
|
|
@@ -14216,7 +14695,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
14216
14695
|
json.type = "object";
|
|
14217
14696
|
json.properties = {};
|
|
14218
14697
|
const shape = def.shape;
|
|
14219
|
-
for (const key in shape) json.properties[key] = process(shape[key], ctx, {
|
|
14698
|
+
for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
|
|
14220
14699
|
...params,
|
|
14221
14700
|
path: [
|
|
14222
14701
|
...params.path,
|
|
@@ -14234,7 +14713,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
14234
14713
|
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
14235
14714
|
else if (!def.catchall) {
|
|
14236
14715
|
if (ctx.io === "output") json.additionalProperties = false;
|
|
14237
|
-
} else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
|
|
14716
|
+
} else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
|
|
14238
14717
|
...params,
|
|
14239
14718
|
path: [...params.path, "additionalProperties"]
|
|
14240
14719
|
});
|
|
@@ -14242,7 +14721,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
14242
14721
|
var unionProcessor = (schema, ctx, json, params) => {
|
|
14243
14722
|
const def = schema._zod.def;
|
|
14244
14723
|
const isExclusive = def.inclusive === false;
|
|
14245
|
-
const options = def.options.map((x, i) => process(x, ctx, {
|
|
14724
|
+
const options = def.options.map((x, i) => process$1(x, ctx, {
|
|
14246
14725
|
...params,
|
|
14247
14726
|
path: [
|
|
14248
14727
|
...params.path,
|
|
@@ -14255,7 +14734,7 @@ var unionProcessor = (schema, ctx, json, params) => {
|
|
|
14255
14734
|
};
|
|
14256
14735
|
var intersectionProcessor = (schema, ctx, json, params) => {
|
|
14257
14736
|
const def = schema._zod.def;
|
|
14258
|
-
const a = process(def.left, ctx, {
|
|
14737
|
+
const a = process$1(def.left, ctx, {
|
|
14259
14738
|
...params,
|
|
14260
14739
|
path: [
|
|
14261
14740
|
...params.path,
|
|
@@ -14263,7 +14742,7 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
14263
14742
|
0
|
|
14264
14743
|
]
|
|
14265
14744
|
});
|
|
14266
|
-
const b = process(def.right, ctx, {
|
|
14745
|
+
const b = process$1(def.right, ctx, {
|
|
14267
14746
|
...params,
|
|
14268
14747
|
path: [
|
|
14269
14748
|
...params.path,
|
|
@@ -14276,7 +14755,7 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
14276
14755
|
};
|
|
14277
14756
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
14278
14757
|
const def = schema._zod.def;
|
|
14279
|
-
const inner = process(def.innerType, ctx, params);
|
|
14758
|
+
const inner = process$1(def.innerType, ctx, params);
|
|
14280
14759
|
const seen = ctx.seen.get(schema);
|
|
14281
14760
|
if (ctx.target === "openapi-3.0") {
|
|
14282
14761
|
seen.ref = def.innerType;
|
|
@@ -14285,27 +14764,27 @@ var nullableProcessor = (schema, ctx, json, params) => {
|
|
|
14285
14764
|
};
|
|
14286
14765
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
14287
14766
|
const def = schema._zod.def;
|
|
14288
|
-
process(def.innerType, ctx, params);
|
|
14767
|
+
process$1(def.innerType, ctx, params);
|
|
14289
14768
|
const seen = ctx.seen.get(schema);
|
|
14290
14769
|
seen.ref = def.innerType;
|
|
14291
14770
|
};
|
|
14292
14771
|
var defaultProcessor = (schema, ctx, json, params) => {
|
|
14293
14772
|
const def = schema._zod.def;
|
|
14294
|
-
process(def.innerType, ctx, params);
|
|
14773
|
+
process$1(def.innerType, ctx, params);
|
|
14295
14774
|
const seen = ctx.seen.get(schema);
|
|
14296
14775
|
seen.ref = def.innerType;
|
|
14297
14776
|
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
14298
14777
|
};
|
|
14299
14778
|
var prefaultProcessor = (schema, ctx, json, params) => {
|
|
14300
14779
|
const def = schema._zod.def;
|
|
14301
|
-
process(def.innerType, ctx, params);
|
|
14780
|
+
process$1(def.innerType, ctx, params);
|
|
14302
14781
|
const seen = ctx.seen.get(schema);
|
|
14303
14782
|
seen.ref = def.innerType;
|
|
14304
14783
|
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
14305
14784
|
};
|
|
14306
14785
|
var catchProcessor = (schema, ctx, json, params) => {
|
|
14307
14786
|
const def = schema._zod.def;
|
|
14308
|
-
process(def.innerType, ctx, params);
|
|
14787
|
+
process$1(def.innerType, ctx, params);
|
|
14309
14788
|
const seen = ctx.seen.get(schema);
|
|
14310
14789
|
seen.ref = def.innerType;
|
|
14311
14790
|
let catchValue;
|
|
@@ -14318,26 +14797,27 @@ var catchProcessor = (schema, ctx, json, params) => {
|
|
|
14318
14797
|
};
|
|
14319
14798
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
14320
14799
|
const def = schema._zod.def;
|
|
14321
|
-
const
|
|
14322
|
-
|
|
14800
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
14801
|
+
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
14802
|
+
process$1(innerType, ctx, params);
|
|
14323
14803
|
const seen = ctx.seen.get(schema);
|
|
14324
14804
|
seen.ref = innerType;
|
|
14325
14805
|
};
|
|
14326
14806
|
var readonlyProcessor = (schema, ctx, json, params) => {
|
|
14327
14807
|
const def = schema._zod.def;
|
|
14328
|
-
process(def.innerType, ctx, params);
|
|
14808
|
+
process$1(def.innerType, ctx, params);
|
|
14329
14809
|
const seen = ctx.seen.get(schema);
|
|
14330
14810
|
seen.ref = def.innerType;
|
|
14331
14811
|
json.readOnly = true;
|
|
14332
14812
|
};
|
|
14333
14813
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
14334
14814
|
const def = schema._zod.def;
|
|
14335
|
-
process(def.innerType, ctx, params);
|
|
14815
|
+
process$1(def.innerType, ctx, params);
|
|
14336
14816
|
const seen = ctx.seen.get(schema);
|
|
14337
14817
|
seen.ref = def.innerType;
|
|
14338
14818
|
};
|
|
14339
14819
|
//#endregion
|
|
14340
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
14820
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
|
|
14341
14821
|
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
14342
14822
|
$ZodISODateTime.init(inst, def);
|
|
14343
14823
|
ZodStringFormat.init(inst, def);
|
|
@@ -14367,7 +14847,7 @@ function duration(params) {
|
|
|
14367
14847
|
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
14368
14848
|
}
|
|
14369
14849
|
//#endregion
|
|
14370
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
14850
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
|
|
14371
14851
|
var initializer = (inst, issues) => {
|
|
14372
14852
|
$ZodError.init(inst, issues);
|
|
14373
14853
|
inst.name = "ZodError";
|
|
@@ -14387,10 +14867,9 @@ var initializer = (inst, issues) => {
|
|
|
14387
14867
|
} }
|
|
14388
14868
|
});
|
|
14389
14869
|
};
|
|
14390
|
-
$constructor("ZodError", initializer);
|
|
14391
|
-
var ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
|
|
14870
|
+
var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer, { Parent: Error });
|
|
14392
14871
|
//#endregion
|
|
14393
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
14872
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
|
|
14394
14873
|
var parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
14395
14874
|
var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
14396
14875
|
var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
@@ -14404,7 +14883,43 @@ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
|
14404
14883
|
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
14405
14884
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
14406
14885
|
//#endregion
|
|
14407
|
-
//#region ../../node_modules/.pnpm/zod@4.3
|
|
14886
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
|
|
14887
|
+
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
14888
|
+
function _installLazyMethods(inst, group, methods) {
|
|
14889
|
+
const proto = Object.getPrototypeOf(inst);
|
|
14890
|
+
let installed = _installedGroups.get(proto);
|
|
14891
|
+
if (!installed) {
|
|
14892
|
+
installed = /* @__PURE__ */ new Set();
|
|
14893
|
+
_installedGroups.set(proto, installed);
|
|
14894
|
+
}
|
|
14895
|
+
if (installed.has(group)) return;
|
|
14896
|
+
installed.add(group);
|
|
14897
|
+
for (const key in methods) {
|
|
14898
|
+
const fn = methods[key];
|
|
14899
|
+
Object.defineProperty(proto, key, {
|
|
14900
|
+
configurable: true,
|
|
14901
|
+
enumerable: false,
|
|
14902
|
+
get() {
|
|
14903
|
+
const bound = fn.bind(this);
|
|
14904
|
+
Object.defineProperty(this, key, {
|
|
14905
|
+
configurable: true,
|
|
14906
|
+
writable: true,
|
|
14907
|
+
enumerable: true,
|
|
14908
|
+
value: bound
|
|
14909
|
+
});
|
|
14910
|
+
return bound;
|
|
14911
|
+
},
|
|
14912
|
+
set(v) {
|
|
14913
|
+
Object.defineProperty(this, key, {
|
|
14914
|
+
configurable: true,
|
|
14915
|
+
writable: true,
|
|
14916
|
+
enumerable: true,
|
|
14917
|
+
value: v
|
|
14918
|
+
});
|
|
14919
|
+
}
|
|
14920
|
+
});
|
|
14921
|
+
}
|
|
14922
|
+
}
|
|
14408
14923
|
var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
14409
14924
|
$ZodType.init(inst, def);
|
|
14410
14925
|
Object.assign(inst["~standard"], { jsonSchema: {
|
|
@@ -14415,20 +14930,6 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
14415
14930
|
inst.def = def;
|
|
14416
14931
|
inst.type = def.type;
|
|
14417
14932
|
Object.defineProperty(inst, "_def", { value: def });
|
|
14418
|
-
inst.check = (...checks) => {
|
|
14419
|
-
return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
14420
|
-
check: ch,
|
|
14421
|
-
def: { check: "custom" },
|
|
14422
|
-
onattach: []
|
|
14423
|
-
} } : ch)] }), { parent: true });
|
|
14424
|
-
};
|
|
14425
|
-
inst.with = inst.check;
|
|
14426
|
-
inst.clone = (def, params) => clone(inst, def, params);
|
|
14427
|
-
inst.brand = () => inst;
|
|
14428
|
-
inst.register = ((reg, meta) => {
|
|
14429
|
-
reg.add(inst, meta);
|
|
14430
|
-
return inst;
|
|
14431
|
-
});
|
|
14432
14933
|
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
14433
14934
|
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
14434
14935
|
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
@@ -14442,43 +14943,106 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
14442
14943
|
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
14443
14944
|
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
14444
14945
|
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
14445
|
-
inst
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14946
|
+
_installLazyMethods(inst, "ZodType", {
|
|
14947
|
+
check(...chks) {
|
|
14948
|
+
const def = this.def;
|
|
14949
|
+
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
14950
|
+
check: ch,
|
|
14951
|
+
def: { check: "custom" },
|
|
14952
|
+
onattach: []
|
|
14953
|
+
} } : ch)] }), { parent: true });
|
|
14954
|
+
},
|
|
14955
|
+
with(...chks) {
|
|
14956
|
+
return this.check(...chks);
|
|
14957
|
+
},
|
|
14958
|
+
clone(def, params) {
|
|
14959
|
+
return clone(this, def, params);
|
|
14960
|
+
},
|
|
14961
|
+
brand() {
|
|
14962
|
+
return this;
|
|
14963
|
+
},
|
|
14964
|
+
register(reg, meta) {
|
|
14965
|
+
reg.add(this, meta);
|
|
14966
|
+
return this;
|
|
14967
|
+
},
|
|
14968
|
+
refine(check, params) {
|
|
14969
|
+
return this.check(refine(check, params));
|
|
14970
|
+
},
|
|
14971
|
+
superRefine(refinement, params) {
|
|
14972
|
+
return this.check(superRefine(refinement, params));
|
|
14973
|
+
},
|
|
14974
|
+
overwrite(fn) {
|
|
14975
|
+
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
14976
|
+
},
|
|
14977
|
+
optional() {
|
|
14978
|
+
return optional(this);
|
|
14979
|
+
},
|
|
14980
|
+
exactOptional() {
|
|
14981
|
+
return exactOptional(this);
|
|
14982
|
+
},
|
|
14983
|
+
nullable() {
|
|
14984
|
+
return nullable(this);
|
|
14985
|
+
},
|
|
14986
|
+
nullish() {
|
|
14987
|
+
return optional(nullable(this));
|
|
14988
|
+
},
|
|
14989
|
+
nonoptional(params) {
|
|
14990
|
+
return nonoptional(this, params);
|
|
14991
|
+
},
|
|
14992
|
+
array() {
|
|
14993
|
+
return array(this);
|
|
14994
|
+
},
|
|
14995
|
+
or(arg) {
|
|
14996
|
+
return union([this, arg]);
|
|
14997
|
+
},
|
|
14998
|
+
and(arg) {
|
|
14999
|
+
return intersection(this, arg);
|
|
15000
|
+
},
|
|
15001
|
+
transform(tx) {
|
|
15002
|
+
return pipe(this, transform(tx));
|
|
15003
|
+
},
|
|
15004
|
+
default(d) {
|
|
15005
|
+
return _default(this, d);
|
|
15006
|
+
},
|
|
15007
|
+
prefault(d) {
|
|
15008
|
+
return prefault(this, d);
|
|
15009
|
+
},
|
|
15010
|
+
catch(params) {
|
|
15011
|
+
return _catch(this, params);
|
|
15012
|
+
},
|
|
15013
|
+
pipe(target) {
|
|
15014
|
+
return pipe(this, target);
|
|
15015
|
+
},
|
|
15016
|
+
readonly() {
|
|
15017
|
+
return readonly(this);
|
|
15018
|
+
},
|
|
15019
|
+
describe(description) {
|
|
15020
|
+
const cl = this.clone();
|
|
15021
|
+
globalRegistry.add(cl, { description });
|
|
15022
|
+
return cl;
|
|
15023
|
+
},
|
|
15024
|
+
meta(...args) {
|
|
15025
|
+
if (args.length === 0) return globalRegistry.get(this);
|
|
15026
|
+
const cl = this.clone();
|
|
15027
|
+
globalRegistry.add(cl, args[0]);
|
|
15028
|
+
return cl;
|
|
15029
|
+
},
|
|
15030
|
+
isOptional() {
|
|
15031
|
+
return this.safeParse(void 0).success;
|
|
15032
|
+
},
|
|
15033
|
+
isNullable() {
|
|
15034
|
+
return this.safeParse(null).success;
|
|
15035
|
+
},
|
|
15036
|
+
apply(fn) {
|
|
15037
|
+
return fn(this);
|
|
15038
|
+
}
|
|
15039
|
+
});
|
|
14467
15040
|
Object.defineProperty(inst, "description", {
|
|
14468
15041
|
get() {
|
|
14469
15042
|
return globalRegistry.get(inst)?.description;
|
|
14470
15043
|
},
|
|
14471
15044
|
configurable: true
|
|
14472
15045
|
});
|
|
14473
|
-
inst.meta = (...args) => {
|
|
14474
|
-
if (args.length === 0) return globalRegistry.get(inst);
|
|
14475
|
-
const cl = inst.clone();
|
|
14476
|
-
globalRegistry.add(cl, args[0]);
|
|
14477
|
-
return cl;
|
|
14478
|
-
};
|
|
14479
|
-
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
14480
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
14481
|
-
inst.apply = (fn) => fn(inst);
|
|
14482
15046
|
return inst;
|
|
14483
15047
|
});
|
|
14484
15048
|
/** @internal */
|
|
@@ -14490,21 +15054,53 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
14490
15054
|
inst.format = bag.format ?? null;
|
|
14491
15055
|
inst.minLength = bag.minimum ?? null;
|
|
14492
15056
|
inst.maxLength = bag.maximum ?? null;
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
15057
|
+
_installLazyMethods(inst, "_ZodString", {
|
|
15058
|
+
regex(...args) {
|
|
15059
|
+
return this.check(/* @__PURE__ */ _regex(...args));
|
|
15060
|
+
},
|
|
15061
|
+
includes(...args) {
|
|
15062
|
+
return this.check(/* @__PURE__ */ _includes(...args));
|
|
15063
|
+
},
|
|
15064
|
+
startsWith(...args) {
|
|
15065
|
+
return this.check(/* @__PURE__ */ _startsWith(...args));
|
|
15066
|
+
},
|
|
15067
|
+
endsWith(...args) {
|
|
15068
|
+
return this.check(/* @__PURE__ */ _endsWith(...args));
|
|
15069
|
+
},
|
|
15070
|
+
min(...args) {
|
|
15071
|
+
return this.check(/* @__PURE__ */ _minLength(...args));
|
|
15072
|
+
},
|
|
15073
|
+
max(...args) {
|
|
15074
|
+
return this.check(/* @__PURE__ */ _maxLength(...args));
|
|
15075
|
+
},
|
|
15076
|
+
length(...args) {
|
|
15077
|
+
return this.check(/* @__PURE__ */ _length(...args));
|
|
15078
|
+
},
|
|
15079
|
+
nonempty(...args) {
|
|
15080
|
+
return this.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
15081
|
+
},
|
|
15082
|
+
lowercase(params) {
|
|
15083
|
+
return this.check(/* @__PURE__ */ _lowercase(params));
|
|
15084
|
+
},
|
|
15085
|
+
uppercase(params) {
|
|
15086
|
+
return this.check(/* @__PURE__ */ _uppercase(params));
|
|
15087
|
+
},
|
|
15088
|
+
trim() {
|
|
15089
|
+
return this.check(/* @__PURE__ */ _trim());
|
|
15090
|
+
},
|
|
15091
|
+
normalize(...args) {
|
|
15092
|
+
return this.check(/* @__PURE__ */ _normalize(...args));
|
|
15093
|
+
},
|
|
15094
|
+
toLowerCase() {
|
|
15095
|
+
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
15096
|
+
},
|
|
15097
|
+
toUpperCase() {
|
|
15098
|
+
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
15099
|
+
},
|
|
15100
|
+
slugify() {
|
|
15101
|
+
return this.check(/* @__PURE__ */ _slugify());
|
|
15102
|
+
}
|
|
15103
|
+
});
|
|
14508
15104
|
});
|
|
14509
15105
|
var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
14510
15106
|
$ZodString.init(inst, def);
|
|
@@ -14568,6 +15164,11 @@ var ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
|
14568
15164
|
$ZodNanoID.init(inst, def);
|
|
14569
15165
|
ZodStringFormat.init(inst, def);
|
|
14570
15166
|
});
|
|
15167
|
+
/**
|
|
15168
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
15169
|
+
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
|
|
15170
|
+
* See https://github.com/paralleldrive/cuid.
|
|
15171
|
+
*/
|
|
14571
15172
|
var ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
14572
15173
|
$ZodCUID.init(inst, def);
|
|
14573
15174
|
ZodStringFormat.init(inst, def);
|
|
@@ -14624,21 +15225,53 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
14624
15225
|
$ZodNumber.init(inst, def);
|
|
14625
15226
|
ZodType.init(inst, def);
|
|
14626
15227
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
14627
|
-
inst
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
15228
|
+
_installLazyMethods(inst, "ZodNumber", {
|
|
15229
|
+
gt(value, params) {
|
|
15230
|
+
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
15231
|
+
},
|
|
15232
|
+
gte(value, params) {
|
|
15233
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
15234
|
+
},
|
|
15235
|
+
min(value, params) {
|
|
15236
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
15237
|
+
},
|
|
15238
|
+
lt(value, params) {
|
|
15239
|
+
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
15240
|
+
},
|
|
15241
|
+
lte(value, params) {
|
|
15242
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
15243
|
+
},
|
|
15244
|
+
max(value, params) {
|
|
15245
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
15246
|
+
},
|
|
15247
|
+
int(params) {
|
|
15248
|
+
return this.check(int(params));
|
|
15249
|
+
},
|
|
15250
|
+
safe(params) {
|
|
15251
|
+
return this.check(int(params));
|
|
15252
|
+
},
|
|
15253
|
+
positive(params) {
|
|
15254
|
+
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
15255
|
+
},
|
|
15256
|
+
nonnegative(params) {
|
|
15257
|
+
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
15258
|
+
},
|
|
15259
|
+
negative(params) {
|
|
15260
|
+
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
15261
|
+
},
|
|
15262
|
+
nonpositive(params) {
|
|
15263
|
+
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
15264
|
+
},
|
|
15265
|
+
multipleOf(value, params) {
|
|
15266
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
15267
|
+
},
|
|
15268
|
+
step(value, params) {
|
|
15269
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
15270
|
+
},
|
|
15271
|
+
finite() {
|
|
15272
|
+
return this;
|
|
15273
|
+
}
|
|
15274
|
+
});
|
|
14642
15275
|
const bag = inst._zod.bag;
|
|
14643
15276
|
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
14644
15277
|
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
@@ -14659,7 +15292,7 @@ function int(params) {
|
|
|
14659
15292
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
14660
15293
|
$ZodAny.init(inst, def);
|
|
14661
15294
|
ZodType.init(inst, def);
|
|
14662
|
-
inst._zod.processJSONSchema = (ctx, json, params) =>
|
|
15295
|
+
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
|
|
14663
15296
|
});
|
|
14664
15297
|
function any() {
|
|
14665
15298
|
return /* @__PURE__ */ _any(ZodAny);
|
|
@@ -14667,7 +15300,7 @@ function any() {
|
|
|
14667
15300
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
14668
15301
|
$ZodUnknown.init(inst, def);
|
|
14669
15302
|
ZodType.init(inst, def);
|
|
14670
|
-
inst._zod.processJSONSchema = (ctx, json, params) =>
|
|
15303
|
+
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
|
|
14671
15304
|
});
|
|
14672
15305
|
function unknown() {
|
|
14673
15306
|
return /* @__PURE__ */ _unknown(ZodUnknown);
|
|
@@ -14685,11 +15318,23 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
14685
15318
|
ZodType.init(inst, def);
|
|
14686
15319
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
14687
15320
|
inst.element = def.element;
|
|
14688
|
-
inst
|
|
14689
|
-
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
|
|
15321
|
+
_installLazyMethods(inst, "ZodArray", {
|
|
15322
|
+
min(n, params) {
|
|
15323
|
+
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
15324
|
+
},
|
|
15325
|
+
nonempty(params) {
|
|
15326
|
+
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
15327
|
+
},
|
|
15328
|
+
max(n, params) {
|
|
15329
|
+
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
15330
|
+
},
|
|
15331
|
+
length(n, params) {
|
|
15332
|
+
return this.check(/* @__PURE__ */ _length(n, params));
|
|
15333
|
+
},
|
|
15334
|
+
unwrap() {
|
|
15335
|
+
return this.element;
|
|
15336
|
+
}
|
|
15337
|
+
});
|
|
14693
15338
|
});
|
|
14694
15339
|
function array(element, params) {
|
|
14695
15340
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
@@ -14701,38 +15346,62 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
14701
15346
|
defineLazy(inst, "shape", () => {
|
|
14702
15347
|
return def.shape;
|
|
14703
15348
|
});
|
|
14704
|
-
inst
|
|
14705
|
-
|
|
14706
|
-
|
|
14707
|
-
|
|
14708
|
-
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
|
|
14717
|
-
|
|
14718
|
-
|
|
14719
|
-
|
|
14720
|
-
|
|
14721
|
-
|
|
14722
|
-
|
|
14723
|
-
|
|
15349
|
+
_installLazyMethods(inst, "ZodObject", {
|
|
15350
|
+
keyof() {
|
|
15351
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
15352
|
+
},
|
|
15353
|
+
catchall(catchall) {
|
|
15354
|
+
return this.clone({
|
|
15355
|
+
...this._zod.def,
|
|
15356
|
+
catchall
|
|
15357
|
+
});
|
|
15358
|
+
},
|
|
15359
|
+
passthrough() {
|
|
15360
|
+
return this.clone({
|
|
15361
|
+
...this._zod.def,
|
|
15362
|
+
catchall: unknown()
|
|
15363
|
+
});
|
|
15364
|
+
},
|
|
15365
|
+
loose() {
|
|
15366
|
+
return this.clone({
|
|
15367
|
+
...this._zod.def,
|
|
15368
|
+
catchall: unknown()
|
|
15369
|
+
});
|
|
15370
|
+
},
|
|
15371
|
+
strict() {
|
|
15372
|
+
return this.clone({
|
|
15373
|
+
...this._zod.def,
|
|
15374
|
+
catchall: never()
|
|
15375
|
+
});
|
|
15376
|
+
},
|
|
15377
|
+
strip() {
|
|
15378
|
+
return this.clone({
|
|
15379
|
+
...this._zod.def,
|
|
15380
|
+
catchall: void 0
|
|
15381
|
+
});
|
|
15382
|
+
},
|
|
15383
|
+
extend(incoming) {
|
|
15384
|
+
return extend(this, incoming);
|
|
15385
|
+
},
|
|
15386
|
+
safeExtend(incoming) {
|
|
15387
|
+
return safeExtend(this, incoming);
|
|
15388
|
+
},
|
|
15389
|
+
merge(other) {
|
|
15390
|
+
return merge(this, other);
|
|
15391
|
+
},
|
|
15392
|
+
pick(mask) {
|
|
15393
|
+
return pick(this, mask);
|
|
15394
|
+
},
|
|
15395
|
+
omit(mask) {
|
|
15396
|
+
return omit(this, mask);
|
|
15397
|
+
},
|
|
15398
|
+
partial(...args) {
|
|
15399
|
+
return partial(ZodOptional, this, args[0]);
|
|
15400
|
+
},
|
|
15401
|
+
required(...args) {
|
|
15402
|
+
return required(ZodNonOptional, this, args[0]);
|
|
15403
|
+
}
|
|
14724
15404
|
});
|
|
14725
|
-
inst.extend = (incoming) => {
|
|
14726
|
-
return extend(inst, incoming);
|
|
14727
|
-
};
|
|
14728
|
-
inst.safeExtend = (incoming) => {
|
|
14729
|
-
return safeExtend(inst, incoming);
|
|
14730
|
-
};
|
|
14731
|
-
inst.merge = (other) => merge(inst, other);
|
|
14732
|
-
inst.pick = (mask) => pick(inst, mask);
|
|
14733
|
-
inst.omit = (mask) => omit(inst, mask);
|
|
14734
|
-
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
14735
|
-
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
14736
15405
|
});
|
|
14737
15406
|
function object(shape, params) {
|
|
14738
15407
|
return new ZodObject({
|
|
@@ -14823,9 +15492,11 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
14823
15492
|
const output = def.transform(payload.value, payload);
|
|
14824
15493
|
if (output instanceof Promise) return output.then((output) => {
|
|
14825
15494
|
payload.value = output;
|
|
15495
|
+
payload.fallback = true;
|
|
14826
15496
|
return payload;
|
|
14827
15497
|
});
|
|
14828
15498
|
payload.value = output;
|
|
15499
|
+
payload.fallback = true;
|
|
14829
15500
|
return payload;
|
|
14830
15501
|
};
|
|
14831
15502
|
});
|
|
@@ -14963,8 +15634,8 @@ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
|
14963
15634
|
function refine(fn, _params = {}) {
|
|
14964
15635
|
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
14965
15636
|
}
|
|
14966
|
-
function superRefine(fn) {
|
|
14967
|
-
return /* @__PURE__ */ _superRefine(fn);
|
|
15637
|
+
function superRefine(fn, params) {
|
|
15638
|
+
return /* @__PURE__ */ _superRefine(fn, params);
|
|
14968
15639
|
}
|
|
14969
15640
|
//#endregion
|
|
14970
15641
|
//#region src/decorators/event.ts
|
|
@@ -15312,11 +15983,11 @@ var RpgMap = class RpgMap extends RpgCommonMap {
|
|
|
15312
15983
|
return clone;
|
|
15313
15984
|
}
|
|
15314
15985
|
buildRuntimeEventId(baseId, mode, scenarioOwnerId) {
|
|
15315
|
-
const fallbackId = baseId || generateShortUUID
|
|
15986
|
+
const fallbackId = baseId || generateShortUUID();
|
|
15316
15987
|
if (mode !== EventMode.Scenario || !scenarioOwnerId) return fallbackId;
|
|
15317
15988
|
const scopedId = `${fallbackId}::${scenarioOwnerId}`;
|
|
15318
15989
|
if (!this.events()[scopedId]) return scopedId;
|
|
15319
|
-
return `${scopedId}::${generateShortUUID
|
|
15990
|
+
return `${scopedId}::${generateShortUUID()}`;
|
|
15320
15991
|
}
|
|
15321
15992
|
setEventRuntimeMetadata(eventId, mode, scenarioOwnerId) {
|
|
15322
15993
|
this._eventModeById.set(eventId, mode);
|
|
@@ -15743,7 +16414,11 @@ var RpgMap = class RpgMap extends RpgCommonMap {
|
|
|
15743
16414
|
* ```
|
|
15744
16415
|
*/
|
|
15745
16416
|
onAction(player, action) {
|
|
15746
|
-
const
|
|
16417
|
+
const direction = typeof player.getDirection === "function" ? player.getDirection() : typeof player.direction === "function" ? player.direction() : void 0;
|
|
16418
|
+
const collisions = new Set(this.getCollisions(player.id));
|
|
16419
|
+
const interactionCollisions = this.getInteractionCollisions?.(player.id, direction);
|
|
16420
|
+
if (Array.isArray(interactionCollisions)) interactionCollisions.forEach((id) => collisions.add(id));
|
|
16421
|
+
const events = Array.from(collisions).map((id) => this.getEvent(id)).filter((event) => !!event && this.isEventVisibleForPlayer(event, player));
|
|
15747
16422
|
if (events.length > 0) events.forEach((event) => {
|
|
15748
16423
|
event.execMethod("onAction", [player, action]);
|
|
15749
16424
|
});
|
|
@@ -16890,23 +17565,18 @@ var RpgMap = class RpgMap extends RpgCommonMap {
|
|
|
16890
17565
|
if (typeof x !== "number" || typeof y !== "number") throw new Error("Shape x and y must be numbers");
|
|
16891
17566
|
if (typeof width !== "number" || width <= 0) throw new Error("Shape width must be a positive number");
|
|
16892
17567
|
if (typeof height !== "number" || height <= 0) throw new Error("Shape height must be a positive number");
|
|
16893
|
-
const name = obj.name || generateShortUUID
|
|
17568
|
+
const name = obj.name || generateShortUUID();
|
|
16894
17569
|
if (this._shapes.has(name)) throw new Error(`Shape with name "${name}" already exists`);
|
|
16895
17570
|
const centerX = x + width / 2;
|
|
16896
17571
|
const centerY = y + height / 2;
|
|
16897
17572
|
const entityId = `shape-${name}`;
|
|
16898
|
-
this.physic.
|
|
16899
|
-
|
|
16900
|
-
|
|
16901
|
-
x: centerX,
|
|
16902
|
-
y: centerY
|
|
16903
|
-
},
|
|
17573
|
+
this.physic.createStaticObstacle(entityId, {
|
|
17574
|
+
x: centerX,
|
|
17575
|
+
y: centerY,
|
|
16904
17576
|
width,
|
|
16905
17577
|
height,
|
|
16906
|
-
mass: Infinity,
|
|
16907
|
-
state: EntityState.Static,
|
|
16908
17578
|
restitution: 0
|
|
16909
|
-
})
|
|
17579
|
+
});
|
|
16910
17580
|
const properties = { ...obj.properties || {} };
|
|
16911
17581
|
if (obj.z !== void 0) properties.z = obj.z;
|
|
16912
17582
|
if (obj.color !== void 0) properties.color = obj.color;
|