@orpc/shared 2.0.0-beta.33 → 2.0.0-beta.34
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/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.mjs +36 -15
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Arrayable, Promisable } from 'type-fest';
|
|
2
2
|
export { Arrayable, IsEqual, PartialDeep, Promisable, Writable } from 'type-fest';
|
|
3
3
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
4
|
-
import { AsyncIteratorClass } from '@
|
|
5
|
-
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@
|
|
4
|
+
import { AsyncIteratorClass } from '@standard-server/shared';
|
|
5
|
+
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@standard-server/shared';
|
|
6
6
|
|
|
7
7
|
type MaybeOptionalOptions<TOptions> = object extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
8
8
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
@@ -272,6 +272,10 @@ declare function set(root: object, path: [PropertyKey, ...PropertyKey[]] | [...P
|
|
|
272
272
|
*/
|
|
273
273
|
declare function mergeTwoLevels(first: unknown, second: unknown): unknown;
|
|
274
274
|
declare function omit<T extends object, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
|
275
|
+
/**
|
|
276
|
+
* Deep clones arrays and plain objects, leaving every other value as is.
|
|
277
|
+
* Circular and shared references are preserved in the copy.
|
|
278
|
+
*/
|
|
275
279
|
declare function clone<T>(value: T): T;
|
|
276
280
|
declare function isPropertyKey(value: unknown): value is PropertyKey;
|
|
277
281
|
declare const NullProtoObj: ({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Arrayable, Promisable } from 'type-fest';
|
|
2
2
|
export { Arrayable, IsEqual, PartialDeep, Promisable, Writable } from 'type-fest';
|
|
3
3
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
4
|
-
import { AsyncIteratorClass } from '@
|
|
5
|
-
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@
|
|
4
|
+
import { AsyncIteratorClass } from '@standard-server/shared';
|
|
5
|
+
export { AbortError, AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@standard-server/shared';
|
|
6
6
|
|
|
7
7
|
type MaybeOptionalOptions<TOptions> = object extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
8
8
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
@@ -272,6 +272,10 @@ declare function set(root: object, path: [PropertyKey, ...PropertyKey[]] | [...P
|
|
|
272
272
|
*/
|
|
273
273
|
declare function mergeTwoLevels(first: unknown, second: unknown): unknown;
|
|
274
274
|
declare function omit<T extends object, K extends keyof T>(obj: T, keys: readonly K[]): Omit<T, K>;
|
|
275
|
+
/**
|
|
276
|
+
* Deep clones arrays and plain objects, leaving every other value as is.
|
|
277
|
+
* Circular and shared references are preserved in the copy.
|
|
278
|
+
*/
|
|
275
279
|
declare function clone<T>(value: T): T;
|
|
276
280
|
declare function isPropertyKey(value: unknown): value is PropertyKey;
|
|
277
281
|
declare const NullProtoObj: ({
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbortError, AsyncIteratorClass, getOrBind, isTypescriptObject, isAsyncIteratorObject } from '@
|
|
2
|
-
export { AbortError, AsyncIteratorClass, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@
|
|
1
|
+
import { AbortError, AsyncIteratorClass, getOrBind, isTypescriptObject, isAsyncIteratorObject } from '@standard-server/shared';
|
|
2
|
+
export { AbortError, AsyncIteratorClass, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray } from '@standard-server/shared';
|
|
3
3
|
|
|
4
4
|
function resolveMaybeOptionalOptions(rest) {
|
|
5
5
|
return rest[0] ?? {};
|
|
@@ -607,21 +607,25 @@ function set(root, path, value) {
|
|
|
607
607
|
const next = Object.hasOwn(current, key) ? current[key] : void 0;
|
|
608
608
|
if (!isTypescriptObject(next)) {
|
|
609
609
|
const child = {};
|
|
610
|
-
|
|
610
|
+
setOwn(current, key, child);
|
|
611
611
|
current = child;
|
|
612
612
|
} else {
|
|
613
613
|
current = next;
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
-
|
|
616
|
+
setOwn(current, path.at(-1), value);
|
|
617
617
|
}
|
|
618
|
-
function
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
618
|
+
function setOwn(object, key, value) {
|
|
619
|
+
if (key === "__proto__") {
|
|
620
|
+
Object.defineProperty(object, key, {
|
|
621
|
+
value,
|
|
622
|
+
writable: true,
|
|
623
|
+
enumerable: true,
|
|
624
|
+
configurable: true
|
|
625
|
+
});
|
|
626
|
+
} else {
|
|
627
|
+
object[key] = value;
|
|
628
|
+
}
|
|
625
629
|
}
|
|
626
630
|
function mergeTwoLevels(first, second) {
|
|
627
631
|
if (!isPlainObject(first) || !isPlainObject(second)) {
|
|
@@ -635,7 +639,7 @@ function mergeTwoLevels(first, second) {
|
|
|
635
639
|
const firstValue = first[key];
|
|
636
640
|
const secondValue = second[key];
|
|
637
641
|
if (isPlainObject(firstValue) && isPlainObject(secondValue)) {
|
|
638
|
-
|
|
642
|
+
setOwn(result, key, { ...firstValue, ...secondValue });
|
|
639
643
|
}
|
|
640
644
|
}
|
|
641
645
|
return result;
|
|
@@ -648,16 +652,33 @@ function omit(obj, keys) {
|
|
|
648
652
|
return result;
|
|
649
653
|
}
|
|
650
654
|
function clone(value) {
|
|
655
|
+
return cloneWithVisited(value, /* @__PURE__ */ new WeakMap());
|
|
656
|
+
}
|
|
657
|
+
function cloneWithVisited(value, visited) {
|
|
651
658
|
if (Array.isArray(value)) {
|
|
652
|
-
|
|
659
|
+
const existing = visited.get(value);
|
|
660
|
+
if (existing) {
|
|
661
|
+
return existing;
|
|
662
|
+
}
|
|
663
|
+
const result = [];
|
|
664
|
+
visited.set(value, result);
|
|
665
|
+
for (const item of value) {
|
|
666
|
+
result.push(cloneWithVisited(item, visited));
|
|
667
|
+
}
|
|
668
|
+
return result;
|
|
653
669
|
}
|
|
654
670
|
if (isPlainObject(value)) {
|
|
671
|
+
const existing = visited.get(value);
|
|
672
|
+
if (existing) {
|
|
673
|
+
return existing;
|
|
674
|
+
}
|
|
655
675
|
const result = {};
|
|
676
|
+
visited.set(value, result);
|
|
656
677
|
for (const key in value) {
|
|
657
|
-
|
|
678
|
+
setOwn(result, key, cloneWithVisited(value[key], visited));
|
|
658
679
|
}
|
|
659
680
|
for (const sym of Object.getOwnPropertySymbols(value)) {
|
|
660
|
-
|
|
681
|
+
setOwn(result, sym, cloneWithVisited(value[sym], visited));
|
|
661
682
|
}
|
|
662
683
|
return result;
|
|
663
684
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.34",
|
|
5
5
|
"description": "Internal utilities shared across oRPC packages",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@
|
|
41
|
+
"@standard-server/shared": "~0.9.0",
|
|
42
42
|
"radash": "^12.1.1",
|
|
43
43
|
"type-fest": "^5.3.1"
|
|
44
44
|
},
|