@platforma-sdk/ui-vue 1.40.6 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +49 -22
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +20 -0
- package/dist/AgGridVue/useAgGridOptions.js +54 -53
- package/dist/AgGridVue/useAgGridOptions.js.map +1 -1
- package/dist/components/BlockLayout.vue.d.ts.map +1 -1
- package/dist/components/BlockLayout.vue.js +7 -50
- package/dist/components/BlockLayout.vue.js.map +1 -1
- package/dist/components/BlockLayout.vue2.js +53 -2
- package/dist/components/BlockLayout.vue2.js.map +1 -1
- package/dist/components/BlockLayout.vue3.js +9 -0
- package/dist/components/BlockLayout.vue3.js.map +1 -0
- package/dist/components/NotFound.vue.d.ts.map +1 -1
- package/dist/components/NotFound.vue.js +12 -14
- package/dist/components/NotFound.vue.js.map +1 -1
- package/dist/components/PlAgDataTable/PlAgRowCount.vue.js +7 -6
- package/dist/components/PlAgDataTable/PlAgRowCount.vue.js.map +1 -1
- package/dist/components/PlAgDataTable/sources/table-source-v2.js +12 -12
- package/dist/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue.js +10 -9
- package/dist/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue.js.map +1 -1
- package/dist/components/PlAgRowNumHeader.vue.js +3 -2
- package/dist/components/PlAgRowNumHeader.vue.js.map +1 -1
- package/dist/components/PlAnnotations/components/DynamicForm.vue2.js +10 -10
- package/dist/components/PlAnnotations/components/PlAnnotationCreateDialog.vue.d.ts +1 -1
- package/dist/components/PlAnnotations/components/PlAnnotationCreateDialog.vue.d.ts.map +1 -1
- package/dist/components/PlMultiSequenceAlignment/data.js +51 -51
- package/dist/composition/fileContent.js +16 -16
- package/dist/defineApp.d.ts +19 -6
- package/dist/defineApp.d.ts.map +1 -1
- package/dist/defineApp.js +50 -30
- package/dist/defineApp.js.map +1 -1
- package/dist/internal/UpdateSerializer.d.ts +26 -0
- package/dist/internal/UpdateSerializer.d.ts.map +1 -0
- package/dist/internal/UpdateSerializer.js +65 -0
- package/dist/internal/UpdateSerializer.js.map +1 -0
- package/dist/internal/createAppModel.d.ts +1 -1
- package/dist/internal/createAppModel.d.ts.map +1 -1
- package/dist/internal/createAppModel.js +43 -51
- package/dist/internal/createAppModel.js.map +1 -1
- package/dist/internal/{createApp.d.ts → createAppV1.d.ts} +4 -4
- package/dist/internal/createAppV1.d.ts.map +1 -0
- package/dist/internal/{createApp.js → createAppV1.js} +17 -18
- package/dist/internal/createAppV1.js.map +1 -0
- package/dist/internal/createAppV2.d.ts +56 -0
- package/dist/internal/createAppV2.d.ts.map +1 -0
- package/dist/internal/createAppV2.js +158 -0
- package/dist/internal/createAppV2.js.map +1 -0
- package/dist/internal/test-helpers/BlockMock.d.ts +28 -0
- package/dist/internal/test-helpers/BlockMock.d.ts.map +1 -0
- package/dist/internal/test-helpers/createMockApi.d.ts +4 -0
- package/dist/internal/test-helpers/createMockApi.d.ts.map +1 -0
- package/dist/internal/test-helpers/utils.d.ts +4 -0
- package/dist/internal/test-helpers/utils.d.ts.map +1 -0
- package/dist/{types.static-test.d.ts → internal/v1.static-test.d.ts} +3 -3
- package/dist/internal/v1.static-test.d.ts.map +1 -0
- package/dist/internal/v2.static-test.d.ts +7 -0
- package/dist/internal/v2.static-test.d.ts.map +1 -0
- package/dist/lib/model/common/dist/index.js +214 -199
- package/dist/lib/model/common/dist/index.js.map +1 -1
- package/dist/lib/ui/uikit/dist/lib/model/common/dist/index.js +8 -8
- package/dist/lib/ui/uikit/dist/sdk/model/dist/index.js +64 -43
- package/dist/lib/ui/uikit/dist/sdk/model/dist/index.js.map +1 -1
- package/dist/lib/util/helpers/dist/index.js +67 -56
- package/dist/lib/util/helpers/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.js +29 -0
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js +208 -0
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/duplex.js +95 -0
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/duplex.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/helpers.js +112 -0
- package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/helpers.js.map +1 -0
- package/dist/sdk/model/dist/index.js +151 -131
- package/dist/sdk/model/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/components/BlockLayout.vue +9 -1
- package/src/components/NotFound.vue +1 -3
- package/src/defineApp.ts +134 -36
- package/src/internal/UpdateSerializer.ts +112 -0
- package/src/internal/createAppModel.ts +7 -20
- package/src/internal/{createApp.ts → createAppV1.ts} +10 -6
- package/src/internal/createAppV2.test.ts +158 -0
- package/src/internal/createAppV2.ts +309 -0
- package/src/internal/test-helpers/BlockMock.ts +144 -0
- package/src/internal/test-helpers/createMockApi.ts +92 -0
- package/src/internal/test-helpers/utils.ts +65 -0
- package/src/{types.static-test.ts → internal/v1.static-test.ts} +5 -9
- package/src/internal/v2.static-test.ts +98 -0
- package/src/types.ts +2 -2
- package/dist/internal/createApp.d.ts.map +0 -1
- package/dist/internal/createApp.js.map +0 -1
- package/dist/types.static-test.d.ts.map +0 -1
|
@@ -1,80 +1,91 @@
|
|
|
1
|
-
function
|
|
1
|
+
function d(n) {
|
|
2
2
|
return n == null;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function b(n, r) {
|
|
5
5
|
if (n == null)
|
|
6
|
-
throw Error(
|
|
6
|
+
throw Error(r ?? "Empty (null | undefined) value");
|
|
7
7
|
return n;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function m(n) {
|
|
10
|
+
return new Promise((r) => setTimeout(r, n));
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function p(n, r) {
|
|
13
|
+
return r(n);
|
|
14
|
+
}
|
|
15
|
+
function h(n, r) {
|
|
13
16
|
if (n != null)
|
|
14
|
-
return
|
|
17
|
+
return r(n);
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
function f(n, r) {
|
|
20
|
+
return n = Math.ceil(n), r = Math.floor(r), Math.floor(Math.random() * (r - n)) + n;
|
|
21
|
+
}
|
|
22
|
+
function l(n) {
|
|
23
|
+
let r = "";
|
|
24
|
+
for (let e = 0; e < n; e++)
|
|
25
|
+
r += String.fromCharCode(f(65, 91));
|
|
26
|
+
return r;
|
|
27
|
+
}
|
|
28
|
+
function g(n = 42) {
|
|
29
|
+
return l(n);
|
|
30
|
+
}
|
|
31
|
+
const o = Array.isArray;
|
|
32
|
+
function u(n) {
|
|
18
33
|
return n !== null && typeof n == "object";
|
|
19
34
|
}
|
|
20
|
-
function
|
|
35
|
+
function c(n) {
|
|
21
36
|
return typeof n == "object" && n !== null;
|
|
22
37
|
}
|
|
23
|
-
function
|
|
24
|
-
if (!
|
|
38
|
+
function t(n) {
|
|
39
|
+
if (!c(n))
|
|
25
40
|
return !1;
|
|
26
|
-
const
|
|
27
|
-
return
|
|
41
|
+
const r = Object.getPrototypeOf(n);
|
|
42
|
+
return r === null || r === Object.prototype || Object.getPrototypeOf(r) === null;
|
|
28
43
|
}
|
|
29
|
-
function
|
|
30
|
-
return Object.values(n).reduce((
|
|
44
|
+
function a(n) {
|
|
45
|
+
return Object.values(n).reduce((r, e) => e !== void 0 ? r + 1 : r, 0);
|
|
31
46
|
}
|
|
32
|
-
function
|
|
33
|
-
if (!(
|
|
34
|
-
return n ===
|
|
35
|
-
if (
|
|
36
|
-
return n.length !==
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
39
|
-
throw Error(`Cannot compare a ${String(n)} and b ${String(
|
|
47
|
+
function i(n, r) {
|
|
48
|
+
if (!(u(n) && u(r)))
|
|
49
|
+
return n === r;
|
|
50
|
+
if (o(n) && o(r))
|
|
51
|
+
return n.length !== r.length ? !1 : [...n.keys()].every((e) => i(n[e], r[e]));
|
|
52
|
+
if (t(n) && t(r))
|
|
53
|
+
return a(n) !== a(r) ? !1 : Object.keys(n).every((e) => i(n[e], r[e]));
|
|
54
|
+
throw Error(`Cannot compare a ${String(n)} and b ${String(r)}`);
|
|
40
55
|
}
|
|
41
|
-
function
|
|
56
|
+
function s(n) {
|
|
42
57
|
if (Array.isArray(n)) {
|
|
43
|
-
const
|
|
44
|
-
for (let
|
|
45
|
-
e
|
|
46
|
-
return
|
|
47
|
-
} else if (
|
|
48
|
-
const
|
|
49
|
-
return Object.keys(n).forEach((
|
|
50
|
-
e
|
|
51
|
-
}),
|
|
58
|
+
const r = [];
|
|
59
|
+
for (let e = 0; e < n.length; e++)
|
|
60
|
+
r[e] = s(n[e]);
|
|
61
|
+
return r;
|
|
62
|
+
} else if (t(n)) {
|
|
63
|
+
const r = {};
|
|
64
|
+
return Object.keys(n).forEach((e) => {
|
|
65
|
+
r[e] = s(n[e]);
|
|
66
|
+
}), r;
|
|
52
67
|
} else
|
|
53
68
|
return n;
|
|
54
69
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
o(u) && o(t) || a(u) && a(t) && u.length === t.length ? y(u, t) : n[r] = t;
|
|
59
|
-
}), n;
|
|
60
|
-
}
|
|
61
|
-
const b = Math.random;
|
|
62
|
-
function E() {
|
|
63
|
-
return b() * Number.MAX_SAFE_INTEGER | 0;
|
|
70
|
+
const y = Math.random;
|
|
71
|
+
function j() {
|
|
72
|
+
return y() * Number.MAX_SAFE_INTEGER | 0;
|
|
64
73
|
}
|
|
65
74
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
s as deepClone,
|
|
76
|
+
m as delay,
|
|
77
|
+
o as isArray,
|
|
78
|
+
i as isJsonEqual,
|
|
79
|
+
d as isNil,
|
|
80
|
+
u as isNonPrimitive,
|
|
81
|
+
c as isObject,
|
|
82
|
+
t as isPlainObject,
|
|
83
|
+
b as notEmpty,
|
|
84
|
+
y as random,
|
|
85
|
+
j as randomInt,
|
|
86
|
+
l as randomString,
|
|
87
|
+
p as tap,
|
|
88
|
+
h as tapIf,
|
|
89
|
+
g as uniqueId
|
|
79
90
|
};
|
|
80
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../lib/util/helpers/src/utils.ts","../../../../../../../lib/util/helpers/src/objects.ts","../../../../../../../lib/util/helpers/src/random.ts"],"sourcesContent":["import type { AwaitedStruct, Option, Primitive, Result, Unionize } from './types';\n\nexport function isNil(v: unknown): v is null | undefined | void {\n return v === null || v === undefined;\n}\n\nexport function isPrimitive(v: unknown): v is Primitive {\n return isNil(v)\n || typeof v === 'string'\n || typeof v === 'number'\n || typeof v === 'boolean'\n || typeof v === 'bigint'\n ;\n}\n\nexport function notEmpty<T>(v: T | null | undefined, message?: string): T {\n if (v === null || v === undefined) {\n throw Error(message ?? 'Empty (null | undefined) value');\n }\n\n return v;\n}\n\nexport function notUndef<T>(v: T | undefined, message?: string): T {\n if (v === undefined) {\n throw Error(message ?? 'Undefined value');\n }\n\n return v;\n}\n\nexport function undef<V>(v: V | undefined = undefined): V | undefined {\n return v;\n}\n\nexport function bool<V extends boolean>(v: V): boolean {\n return v;\n}\n\nexport function uniqueValues<T>(items: T[]): T[] {\n return [...new Set(items)];\n}\n\nexport function checkIfNotEmpty<T>(v: T | null | undefined, message?: string): asserts v is T {\n if (v === undefined || v === null) {\n throw Error(message ?? 'Empty (null | undefined) value');\n }\n}\n\nexport function checkIfDefined<T>(v: T | undefined, message?: string): asserts v is T {\n if (v === undefined) {\n throw Error(message ?? 'Undefined value');\n }\n}\n\nexport function between(n: number, a: number, b: number) {\n const min = Math.min(a, b);\n const max = Math.max(a, b);\n\n return n >= min && n <= max;\n}\n\nexport function listToOptions<T>(list: T[] | readonly T[]): Option<T>[] {\n return list.map((value) => ({ text: String(value), value }));\n}\n\nexport function async<A extends unknown[]>(gf: (...args: A) => Generator) {\n return function (...args: A) {\n const generator = gf(...args);\n\n async function handle(result: IteratorResult<unknown>): Promise<unknown> {\n if (result.done) {\n return Promise.resolve(result.value);\n }\n\n return Promise.resolve(result.value).then((res) => {\n return handle(generator.next(res));\n }).catch((err) => {\n return handle(generator.throw(err));\n });\n }\n\n try {\n return handle(generator.next());\n } catch (ex) {\n return Promise.reject(ex instanceof Error ? ex : Error(String(ex)));\n }\n };\n}\n\nexport class Deferred<T> {\n public readonly promise: Promise<T>;\n\n constructor() {\n this.promise = new Promise<T>((res, rej) => {\n this.resolve = res;\n this.reject = rej;\n });\n }\n\n public resolve: (v: T) => void = () => {\n };\n\n public reject: (err: Error) => void = () => {\n };\n}\n\nexport function delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function tear() {\n return new Promise<void>((r) => queueMicrotask(r));\n}\n\nexport function timer() {\n const t = new Date().getTime();\n return function () {\n return new Date().getTime() - t;\n };\n}\n\nexport function performanceTimer() {\n const t = performance.now();\n return function () {\n return performance.now() - t;\n };\n}\n\nexport function call<R>(f: () => R): R {\n return f();\n}\n\nexport function clamp(n: number, lo: number, up: number) {\n return lo > n ? lo : n > up ? up : n;\n}\n\nexport function tap<T, R>(v: T, cb: (v: T) => R) {\n return cb(v);\n}\n\nexport function tapIf<T, R>(v: T | null | undefined, cb: (v: T) => R) {\n if (v !== null && v !== undefined) {\n return cb(v);\n }\n\n return;\n}\n\nexport function* range(from: number, to: number, step = 1) {\n for (let i = from; i < to; i += step) {\n yield i;\n }\n}\n\nexport function toList<T>(iterable: Iterable<T>): T[] {\n const lst: T[] = [];\n for (const it of iterable) {\n lst.push(it);\n }\n\n return lst;\n}\n\nexport function times<R>(n: number, cb: (i: number) => R): R[] {\n return toList(range(0, n)).map(cb);\n}\n\nexport class Interval {\n constructor(private _delay: number) {\n }\n\n async* generate(): AsyncGenerator<number> {\n let i = 0;\n while (true) {\n await delay(this._delay);\n yield i++;\n }\n }\n\n async* [Symbol.asyncIterator]() {\n let i = 0;\n while (true) {\n await delay(this._delay);\n yield i++;\n }\n }\n}\n\nexport function arrayFrom<T>(length: number, cb: (i: number) => T) {\n return Array.from({ length }, (_, i) => cb(i));\n}\n\nexport function exhaustive(v: never, message: string): never {\n throw Error(message);\n}\n\nexport type Matcher<T extends string, R = unknown> = {\n [P in T]: () => R;\n};\n\nexport function match<T extends string, R = unknown>(matcher: Matcher<T, R>) {\n return (key: T) => matcher[key]();\n}\n\nexport function okOptional<V>(v: { ok: true; value: V } | { ok: false } | undefined) {\n if (!v) {\n return undefined;\n }\n\n if (v.ok) {\n return v.value;\n }\n}\n\nexport function errorOptional<V>(v: Result<V> | undefined) {\n if (!v) {\n return undefined;\n }\n\n if (!v.ok) {\n return v.error;\n }\n}\n\nexport function unwrap<T>(r: Result<T>): T {\n if (r.ok) {\n return r.value;\n }\n\n throw Error(r.error);\n}\n\nexport function flatValue<T>(v: T | T[]): T[] {\n return Array.isArray(v) ? v : [v];\n}\n\nexport async function resolveAwaited<O extends Record<string, unknown>>(obj: O): Promise<AwaitedStruct<O>> {\n return Object.fromEntries(await Promise.all(Object.entries(obj).map(async ([k, v]) => [k, await v]))) as Promise<AwaitedStruct<O>>;\n}\n\nexport function alike(obj: Record<string, unknown>, to: Record<string, unknown>) {\n return Object.keys(to).every((bKey) => obj[bKey] === to[bKey]);\n}\n\nexport const identity = <T>(v: T): T => v;\n\nexport function asConst<const T>(v: T) {\n return v;\n}\n\nexport function unionize<K extends keyof O, V, O extends Record<K, V>>(obj: O): Unionize<O>[] {\n return Object.entries(obj).map(([key, value]) => ({\n key,\n value,\n })) as Unionize<O>[];\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { PartialBy, PlainObject } from './types';\nimport { isNil } from './utils';\n\n/**\n * Alias to Array.isArray\n */\nexport const isArray = Array.isArray;\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport function isNonPrimitive<V, T extends PlainObject<V> | V[]>(obj: T | unknown): obj is T {\n return obj !== null && typeof obj === 'object';\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Checks if the given value is a plain object.\n *\n * A plain object is defined as an object created by the `{}` literal,\n * an object created with `Object.create(null)`, or an object with a\n * prototype that resolves to `Object.prototype`.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a plain object, otherwise `false`.\n *\n * @example\n * ```typescript\n * isPlainObject({}); // true\n * isPlainObject(Object.create(null)); // true\n * isPlainObject(new Date()); // false\n * isPlainObject(null); // false\n * isPlainObject([]); // false\n * ```\n */\nexport function isPlainObject(value: unknown): value is PlainObject {\n if (!isObject(value)) {\n return false;\n }\n\n const prototype: unknown = Object.getPrototypeOf(value);\n\n return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null);\n}\n\nexport function map<U, T extends Record<string, unknown>>(obj: T, callback: (curr: T[keyof T], key: keyof T) => U) {\n const keys = Object.keys(obj) as Array<keyof T>;\n\n return keys.map((key: keyof T) => {\n return callback(obj[key], key);\n });\n}\n\nfunction definedKeysSize(obj: PlainObject) {\n return Object.values(obj).reduce((length: number, v) => {\n return v !== undefined ? length + 1 : length;\n }, 0);\n}\n\n/**\n * Performs a deep equality check between two values, `a` and `b`, to determine if they are JSON-equivalent.\n *\n * JSON equivalence means that the two values are strictly equal in structure and content, including arrays and plain objects.\n * Non-primitive values that are neither arrays nor plain objects will throw an error.\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n * @returns `true` if the values are JSON-equivalent, otherwise `false`.\n *\n * @throws If the values are non-primitive and not arrays or plain objects.\n *\n * @example\n * ```typescript\n * isJsonEqual(1, 1); // true\n * isJsonEqual({ a: 1 }, { a: 1 }); // true\n * isJsonEqual([1, 2], [1, 2]); // true\n * isJsonEqual({ a: 1 }, { a: 2 }); // false\n * isJsonEqual([1, 2], [2, 1]); // false\n * isJsonEqual(new Date(), new Date()); // Error\n * ```\n */\nexport function isJsonEqual(a: unknown, b: unknown): boolean {\n if (!(isNonPrimitive(a) && isNonPrimitive(b))) {\n return a === b;\n }\n\n if (isArray(a) && isArray(b)) {\n if (a.length !== b.length) {\n return false;\n } else {\n return [...a.keys()].every((k) => isJsonEqual(a[k], b[k]));\n }\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n if (definedKeysSize(a) !== definedKeysSize(b)) {\n return false;\n }\n\n return Object.keys(a).every((k) => isJsonEqual(a[k], b[k]));\n }\n\n /* eslint-disable @typescript-eslint/no-base-to-string */\n throw Error(`Cannot compare a ${String(a)} and b ${String(b)}`);\n}\n\n/**\n * Alias to isJsonEqual function\n * @deprecated change to isJsonEqual\n */\nexport const deepEqual = isJsonEqual;\n\nexport function deepClone<T>(obj: T): T {\n if (Array.isArray(obj)) {\n const copy: any[] = [];\n for (let i = 0; i < obj.length; i++) {\n copy[i] = deepClone(obj[i]) as unknown;\n }\n return copy as T;\n } else if (isPlainObject(obj)) {\n const copy: Record<string, any> = {};\n Object.keys(obj).forEach((k) => {\n copy[k] = deepClone(obj[k]);\n });\n return copy as T;\n } else {\n return obj;\n }\n}\n\nexport function shallowClone<T>(obj: T): T {\n if (isNil(obj)) return obj;\n if (Array.isArray(obj)) return obj.slice() as T;\n if (isPlainObject(obj)) return Object.assign({}, obj) as T;\n if (obj instanceof Map) return new Map(obj) as T;\n if (obj instanceof Set) return new Set(obj) as T;\n throw Error(`Not implemented clone strategy for ${JSON.stringify(obj)}`);\n}\n\nexport function shallowDiff<T>(to: T, from: T): Partial<T> {\n const diff: Partial<T> = {};\n\n for (const key in from) {\n if (from[key] !== to[key]) {\n diff[key] = to[key];\n }\n }\n\n return diff;\n}\n\nexport function bindMethods<O extends Record<string, unknown>>(obj: O) {\n Object.entries(obj).forEach(([key, m]) => {\n if (m instanceof Function) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n obj[key as keyof O] = m.bind(obj);\n }\n });\n\n return obj;\n}\n\nexport function setProp<O, K extends keyof O>(obj: O, key: K, value: O[K]) {\n obj[key] = value;\n return obj;\n}\n\nexport function getProp<O, K extends keyof O>(obj: O, key: K): O[K] {\n return obj[key];\n}\n\nexport function shiftProp<O, K extends keyof O>(obj: O, key: K): [O[K], Omit<O, K>] {\n obj = { ...obj };\n const val = obj[key];\n delete obj[key];\n return [val, obj];\n}\n\nexport function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K> {\n return Object.assign({}, ...keys.map((k) => ({ [k]: obj[k] }))) as Pick<T, K>;\n}\n\nexport function pickValues<T, K extends keyof T>(obj: T, ...keys: K[]) {\n return keys.map((k) => obj[k]);\n}\n\nexport function omit<T, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K> {\n const o = Object.assign({}, obj) as PartialBy<T, K>;\n keys.forEach((k) => delete o[k]);\n return o;\n}\n\n/**\n * Performs a deep patch of the target object or array using the source object or array.\n *\n * This function recursively merges properties of the source into the target:\n * - If a property in both target and source is a plain object, they are recursively merged.\n * - If a property in both target and source is an array of the same length, the arrays are recursively patched element by element.\n * - Otherwise, the property value in the target is replaced by the corresponding value from the source.\n *\n * The patch is applied in-place to the target object or array, which is also returned for convenience.\n *\n * @typeParam T - The type of the target and source, which must be either a plain object or an array.\n * @param target - The target object or array to be patched. This object/array is modified in-place.\n * @param source - The source object or array providing the new values for the patch.\n * @returns The modified target object or array.\n *\n * @example\n * ```typescript\n * const target = { a: { b: 1 }, c: [1, 2] };\n * const source = { a: { b: 2 }, c: [3, 4], d: 5 };\n * const result = deepPatch(target, source);\n * // target is now: { a: { b: 2 }, c: [3, 4], d: 5 }\n * // result is the same reference as target.\n *\n * const targetArray = [{ a: 1 }, { b: 2 }];\n * const sourceArray = [{ a: 2 }, { b: 3 }];\n * const resultArray = deepPatch(targetArray, sourceArray);\n * // targetArray is now: [{ a: 2 }, { b: 3 }]\n * ```\n */\nexport function deepPatch<T extends PlainObject | unknown[]>(target: T, source: T) {\n const sk = new Set<keyof T>([...Object.keys(target) as (keyof T)[], ...Object.keys(source) as (keyof T)[]]);\n\n sk.forEach((key) => {\n const t = target[key];\n const s = source[key];\n if (isPlainObject(t) && isPlainObject(s)) {\n deepPatch(t, s);\n } else if (isArray(t) && isArray(s) && t.length === s.length) {\n deepPatch(t, s);\n } else {\n target[key] = s;\n }\n });\n\n return target;\n}\n","export const random = Math.random;\n\nexport function randomInt(): number {\n return (random() * Number.MAX_SAFE_INTEGER) | 0;\n}\n\nexport function randomRangeFloat(min: number, max: number): number {\n return random() * (max - min) + min;\n}\n\nexport function randomRangeInt(min: number, max: number): number {\n min = Math.ceil(min);\n max = Math.floor(max);\n return Math.floor(randomRangeFloat(min, max));\n}\n\nexport function randomSign(): number {\n return random() > 0.5 ? 1 : -1;\n}\n"],"names":["isNil","v","notEmpty","message","tap","cb","tapIf","isArray","isNonPrimitive","obj","isObject","value","isPlainObject","prototype","definedKeysSize","length","isJsonEqual","a","b","k","deepClone","copy","i","deepPatch","target","source","key","t","s","random","randomInt"],"mappings":"AAEO,SAASA,EAAMC,GAA0C;AACvD,SAAAA,KAAM;AACf;AAWgB,SAAAC,EAAYD,GAAyBE,GAAqB;AACpE,MAAAF,KAAM;AACF,UAAA,MAAME,KAAW,gCAAgC;AAGlDF,SAAAA;AACT;AAoHgB,SAAAG,EAAUH,GAAMI,GAAiB;AAC/C,SAAOA,EAAGJ,CAAC;AACb;AAEgB,SAAAK,EAAYL,GAAyBI,GAAiB;AAChE,MAAAJ,KAAM;AACR,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GAAGA,IAAIb,EAAI,QAAQa;AAC9BD,QAAKC,CAAC,IAAIF,EAAUX,EAAIa,CAAC,CAAC;AAErBD,WAAAA;AAAAA,EAAA,WACET,EAAcH,CAAG,GAAG;AAC7B,UAAMY,IAA4B,CAAC;AACnC,WAAA,OAAO,KAAKZ,CAAG,EAAE,QAAQ,CAACU,MAAM;AAC9BE,QAAKF,CAAC,IAAIC,EAAUX,EAAIU,CAAC,CAAC;AAAA,IAC3B,CAAA,GACME;AAAAA,EAAA;AAEAZ,WAAAA;AAEX;AA6FgB,SAAAc,EAA6CC,GAAWC,GAAW;AAG9E,8BAFY,IAAa,CAAC,GAAG,OAAO,KAAKD,CAAM,GAAkB,GAAG,OAAO,KAAKC,CAAM,CAAgB,CAAC,GAEvG,QAAQ,CAACC,MAAQ;AACZ,UAAAC,IAAIH,EAAOE,CAAG,GACdE,IAAIH,EAAOC,CAAG;AAChBd,IAAAA,EAAce,CAAC,KAAKf,EAAcgB,CAAC,KAE5BrB,EAAQoB,CAAC,KAAKpB,EAAQqB,CAAC,KAAKD,EAAE,WAAWC,EAAE,SADpDL,EAAUI,GAAGC,CAAC,IAIdJ,EAAOE,CAAG,IAAIE;AAAAA,EAEjB,CAAA,GAEMJ;AACT;AChPO,MAAMK,IAAS,KAAK;AAEpB,SAASC,IAAoB;AAC1BD,SAAAA,EAAW,IAAA,OAAO,mBAAoB;AAChD;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../lib/util/helpers/src/utils.ts","../../../../../../../lib/util/helpers/src/strings.ts","../../../../../../../lib/util/helpers/src/objects.ts","../../../../../../../lib/util/helpers/src/random.ts"],"sourcesContent":["import type { AwaitedStruct, Option, Primitive, Result, Unionize } from './types';\n\nexport function isNil(v: unknown): v is null | undefined | void {\n return v === null || v === undefined;\n}\n\nexport function isPrimitive(v: unknown): v is Primitive {\n return isNil(v)\n || typeof v === 'string'\n || typeof v === 'number'\n || typeof v === 'boolean'\n || typeof v === 'bigint'\n ;\n}\n\nexport function notEmpty<T>(v: T | null | undefined, message?: string): T {\n if (v === null || v === undefined) {\n throw Error(message ?? 'Empty (null | undefined) value');\n }\n\n return v;\n}\n\nexport function notUndef<T>(v: T | undefined, message?: string): T {\n if (v === undefined) {\n throw Error(message ?? 'Undefined value');\n }\n\n return v;\n}\n\nexport function undef<V>(v: V | undefined = undefined): V | undefined {\n return v;\n}\n\nexport function bool<V extends boolean>(v: V): boolean {\n return v;\n}\n\nexport function uniqueValues<T>(items: T[]): T[] {\n return [...new Set(items)];\n}\n\nexport function checkIfNotEmpty<T>(v: T | null | undefined, message?: string): asserts v is T {\n if (v === undefined || v === null) {\n throw Error(message ?? 'Empty (null | undefined) value');\n }\n}\n\nexport function checkIfDefined<T>(v: T | undefined, message?: string): asserts v is T {\n if (v === undefined) {\n throw Error(message ?? 'Undefined value');\n }\n}\n\nexport function between(n: number, a: number, b: number) {\n const min = Math.min(a, b);\n const max = Math.max(a, b);\n\n return n >= min && n <= max;\n}\n\nexport function listToOptions<T>(list: T[] | readonly T[]): Option<T>[] {\n return list.map((value) => ({ text: String(value), value }));\n}\n\nexport function async<A extends unknown[]>(gf: (...args: A) => Generator) {\n return function (...args: A) {\n const generator = gf(...args);\n\n async function handle(result: IteratorResult<unknown>): Promise<unknown> {\n if (result.done) {\n return Promise.resolve(result.value);\n }\n\n return Promise.resolve(result.value).then((res) => {\n return handle(generator.next(res));\n }).catch((err) => {\n return handle(generator.throw(err));\n });\n }\n\n try {\n return handle(generator.next());\n } catch (ex) {\n return Promise.reject(ex instanceof Error ? ex : Error(String(ex)));\n }\n };\n}\n\nexport class Deferred<T> {\n public readonly promise: Promise<T>;\n\n constructor() {\n this.promise = new Promise<T>((res, rej) => {\n this.resolve = res;\n this.reject = rej;\n });\n }\n\n public resolve: (v: T) => void = () => {\n };\n\n public reject: (err: Error) => void = () => {\n };\n}\n\nexport function delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function tear() {\n return new Promise<void>((r) => queueMicrotask(r));\n}\n\nexport function timer() {\n const t = new Date().getTime();\n return function () {\n return new Date().getTime() - t;\n };\n}\n\nexport function performanceTimer() {\n const t = performance.now();\n return function () {\n return performance.now() - t;\n };\n}\n\nexport function call<R>(f: () => R): R {\n return f();\n}\n\nexport function clamp(n: number, lo: number, up: number) {\n return lo > n ? lo : n > up ? up : n;\n}\n\nexport function tap<T, R>(v: T, cb: (v: T) => R) {\n return cb(v);\n}\n\nexport function tapIf<T, R>(v: T | null | undefined, cb: (v: T) => R) {\n if (v !== null && v !== undefined) {\n return cb(v);\n }\n\n return;\n}\n\nexport function* range(from: number, to: number, step = 1) {\n for (let i = from; i < to; i += step) {\n yield i;\n }\n}\n\nexport function toList<T>(iterable: Iterable<T>): T[] {\n const lst: T[] = [];\n for (const it of iterable) {\n lst.push(it);\n }\n\n return lst;\n}\n\nexport function times<R>(n: number, cb: (i: number) => R): R[] {\n return toList(range(0, n)).map(cb);\n}\n\nexport class Interval {\n constructor(private _delay: number) {\n }\n\n async* generate(): AsyncGenerator<number> {\n let i = 0;\n while (true) {\n await delay(this._delay);\n yield i++;\n }\n }\n\n async* [Symbol.asyncIterator]() {\n let i = 0;\n while (true) {\n await delay(this._delay);\n yield i++;\n }\n }\n}\n\nexport function arrayFrom<T>(length: number, cb: (i: number) => T) {\n return Array.from({ length }, (_, i) => cb(i));\n}\n\nexport function exhaustive(v: never, message: string): never {\n throw Error(message);\n}\n\nexport type Matcher<T extends string, R = unknown> = {\n [P in T]: () => R;\n};\n\nexport function match<T extends string, R = unknown>(matcher: Matcher<T, R>) {\n return (key: T) => matcher[key]();\n}\n\nexport function okOptional<V>(v: { ok: true; value: V } | { ok: false } | undefined) {\n if (!v) {\n return undefined;\n }\n\n if (v.ok) {\n return v.value;\n }\n}\n\nexport function errorOptional<V>(v: Result<V> | undefined) {\n if (!v) {\n return undefined;\n }\n\n if (!v.ok) {\n return v.error;\n }\n}\n\nexport function unwrap<T>(r: Result<T>): T {\n if (r.ok) {\n return r.value;\n }\n\n throw Error(r.error);\n}\n\nexport function flatValue<T>(v: T | T[]): T[] {\n return Array.isArray(v) ? v : [v];\n}\n\nexport async function resolveAwaited<O extends Record<string, unknown>>(obj: O): Promise<AwaitedStruct<O>> {\n return Object.fromEntries(await Promise.all(Object.entries(obj).map(async ([k, v]) => [k, await v]))) as Promise<AwaitedStruct<O>>;\n}\n\nexport function alike(obj: Record<string, unknown>, to: Record<string, unknown>) {\n return Object.keys(to).every((bKey) => obj[bKey] === to[bKey]);\n}\n\nexport const identity = <T>(v: T): T => v;\n\nexport function asConst<const T>(v: T) {\n return v;\n}\n\nexport function unionize<K extends keyof O, V, O extends Record<K, V>>(obj: O): Unionize<O>[] {\n return Object.entries(obj).map(([key, value]) => ({\n key,\n value,\n })) as Unionize<O>[];\n}\n","function getRandomInt(min: number, max: number) {\n min = Math.ceil(min);\n max = Math.floor(max);\n return Math.floor(Math.random() * (max - min)) + min;\n}\n\nexport function camelToKebab(str: string) {\n str = str.replace(' ', '-');\n return (str[0] || '').toLowerCase() + str.slice(1).replace(/[A-Z]/g, (l) => `-${l.toLowerCase()}`);\n}\n\nexport function trimChars(str: string, chars: string[] = []) {\n str = str ? String(str) : '';\n while (chars.includes(str.charAt(0))) str = str.substr(1);\n while (chars.includes(str.charAt(str.length - 1))) str = str.substr(0, str.length - 1);\n return str;\n}\n\nexport function trimCharsLeft(str: string, chars: string[] = []) {\n str = str ? String(str) : '';\n while (chars.includes(str.charAt(0))) str = str.substring(1);\n return str;\n}\n\nexport function extractFileName(filePath: string) {\n return filePath.replace(/^.*[\\\\/]/, '');\n}\n\nexport function extractExtension(fileName: string) {\n return fileName.replace(/^.*?[.]/, '');\n}\n\n// @TODO move from here\nexport function extractPaths(e: DragEvent, extensions?: string[]) {\n const paths: string[] = [];\n\n if (e.dataTransfer) {\n for (let i = 0; i < e.dataTransfer.items.length; i++) {\n if (e.dataTransfer.items[i].kind !== 'file') {\n continue;\n }\n const file = e.dataTransfer.items[i].getAsFile() as (File & { path: string }) | null; // @TODO electron specific\n if (file && file.path) {\n paths.push(file.path);\n }\n }\n }\n\n if (extensions) {\n return paths.filter((p) => extensions.includes(extractExtension(extractFileName(p))));\n }\n\n return paths;\n}\n\nexport const pluralize = (count: number, noun: string, suffix = 's') => `${count} ${noun}${count !== 1 ? suffix : ''}`;\n\nexport function isRegexpValid(exp: string) {\n try {\n new RegExp(exp);\n return true;\n } catch (_e) {\n return false;\n }\n}\n\nexport function ucFirst(str: string) {\n if (!str) {\n return '';\n }\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nexport function lcFirst(str: string) {\n if (!str) {\n return '';\n }\n return str.charAt(0).toLowerCase() + str.slice(1);\n}\n\nexport function randomString(length: number) {\n let s = '';\n for (let i = 0; i < length; i++) {\n s += String.fromCharCode(getRandomInt(65, 91));\n }\n return s;\n}\n\nexport function uniqueId(length: number = 42) {\n return randomString(length);\n}\n\nexport function before(str: string, sub: string) {\n return str.substring(0, str.indexOf(sub));\n}\n\nexport function beforeLast(str: string, sub: string) {\n return str.substring(0, str.lastIndexOf(sub));\n}\n\nexport function after(str: string, sub: string) {\n return str.substring(str.indexOf(sub) + sub.length, str.length);\n}\n\nexport function assertString(v: unknown): asserts v is string {\n if (typeof v !== 'string') {\n throw Error('Expect string value, got: ' + typeof v);\n }\n}\n\nexport function hashCode(str: string) {\n let hash = 0, i, chr;\n if (str.length === 0) return hash;\n for (i = 0; i < str.length; i++) {\n chr = str.charCodeAt(i);\n hash = ((hash << 5) - hash) + chr;\n hash |= 0; // Convert to 32bit integer\n }\n return hash;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { PartialBy, PlainObject } from './types';\nimport { isNil } from './utils';\n\n/**\n * Alias to Array.isArray\n */\nexport const isArray = Array.isArray;\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport function isNonPrimitive<V, T extends PlainObject<V> | V[]>(obj: T | unknown): obj is T {\n return obj !== null && typeof obj === 'object';\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Checks if the given value is a plain object.\n *\n * A plain object is defined as an object created by the `{}` literal,\n * an object created with `Object.create(null)`, or an object with a\n * prototype that resolves to `Object.prototype`.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a plain object, otherwise `false`.\n *\n * @example\n * ```typescript\n * isPlainObject({}); // true\n * isPlainObject(Object.create(null)); // true\n * isPlainObject(new Date()); // false\n * isPlainObject(null); // false\n * isPlainObject([]); // false\n * ```\n */\nexport function isPlainObject(value: unknown): value is PlainObject {\n if (!isObject(value)) {\n return false;\n }\n\n const prototype: unknown = Object.getPrototypeOf(value);\n\n return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null);\n}\n\nexport function map<U, T extends Record<string, unknown>>(obj: T, callback: (curr: T[keyof T], key: keyof T) => U) {\n const keys = Object.keys(obj) as Array<keyof T>;\n\n return keys.map((key: keyof T) => {\n return callback(obj[key], key);\n });\n}\n\nfunction definedKeysSize(obj: PlainObject) {\n return Object.values(obj).reduce((length: number, v) => {\n return v !== undefined ? length + 1 : length;\n }, 0);\n}\n\n/**\n * Performs a deep equality check between two values, `a` and `b`, to determine if they are JSON-equivalent.\n *\n * JSON equivalence means that the two values are strictly equal in structure and content, including arrays and plain objects.\n * Non-primitive values that are neither arrays nor plain objects will throw an error.\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n * @returns `true` if the values are JSON-equivalent, otherwise `false`.\n *\n * @throws If the values are non-primitive and not arrays or plain objects.\n *\n * @example\n * ```typescript\n * isJsonEqual(1, 1); // true\n * isJsonEqual({ a: 1 }, { a: 1 }); // true\n * isJsonEqual([1, 2], [1, 2]); // true\n * isJsonEqual({ a: 1 }, { a: 2 }); // false\n * isJsonEqual([1, 2], [2, 1]); // false\n * isJsonEqual(new Date(), new Date()); // Error\n * ```\n */\nexport function isJsonEqual(a: unknown, b: unknown): boolean {\n if (!(isNonPrimitive(a) && isNonPrimitive(b))) {\n return a === b;\n }\n\n if (isArray(a) && isArray(b)) {\n if (a.length !== b.length) {\n return false;\n } else {\n return [...a.keys()].every((k) => isJsonEqual(a[k], b[k]));\n }\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n if (definedKeysSize(a) !== definedKeysSize(b)) {\n return false;\n }\n\n return Object.keys(a).every((k) => isJsonEqual(a[k], b[k]));\n }\n\n /* eslint-disable @typescript-eslint/no-base-to-string */\n throw Error(`Cannot compare a ${String(a)} and b ${String(b)}`);\n}\n\n/**\n * Alias to isJsonEqual function\n * @deprecated change to isJsonEqual\n */\nexport const deepEqual = isJsonEqual;\n\nexport function deepClone<T>(obj: T): T {\n if (Array.isArray(obj)) {\n const copy: any[] = [];\n for (let i = 0; i < obj.length; i++) {\n copy[i] = deepClone(obj[i]) as unknown;\n }\n return copy as T;\n } else if (isPlainObject(obj)) {\n const copy: Record<string, any> = {};\n Object.keys(obj).forEach((k) => {\n copy[k] = deepClone(obj[k]);\n });\n return copy as T;\n } else {\n return obj;\n }\n}\n\nexport function shallowClone<T>(obj: T): T {\n if (isNil(obj)) return obj;\n if (Array.isArray(obj)) return obj.slice() as T;\n if (isPlainObject(obj)) return Object.assign({}, obj) as T;\n if (obj instanceof Map) return new Map(obj) as T;\n if (obj instanceof Set) return new Set(obj) as T;\n throw Error(`Not implemented clone strategy for ${JSON.stringify(obj)}`);\n}\n\nexport function shallowDiff<T>(to: T, from: T): Partial<T> {\n const diff: Partial<T> = {};\n\n for (const key in from) {\n if (from[key] !== to[key]) {\n diff[key] = to[key];\n }\n }\n\n return diff;\n}\n\nexport function bindMethods<O extends Record<string, unknown>>(obj: O) {\n Object.entries(obj).forEach(([key, m]) => {\n if (m instanceof Function) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n obj[key as keyof O] = m.bind(obj);\n }\n });\n\n return obj;\n}\n\nexport function setProp<O, K extends keyof O>(obj: O, key: K, value: O[K]) {\n obj[key] = value;\n return obj;\n}\n\nexport function getProp<O, K extends keyof O>(obj: O, key: K): O[K] {\n return obj[key];\n}\n\nexport function shiftProp<O, K extends keyof O>(obj: O, key: K): [O[K], Omit<O, K>] {\n obj = { ...obj };\n const val = obj[key];\n delete obj[key];\n return [val, obj];\n}\n\nexport function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K> {\n return Object.assign({}, ...keys.map((k) => ({ [k]: obj[k] }))) as Pick<T, K>;\n}\n\nexport function pickValues<T, K extends keyof T>(obj: T, ...keys: K[]) {\n return keys.map((k) => obj[k]);\n}\n\nexport function omit<T, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K> {\n const o = Object.assign({}, obj) as PartialBy<T, K>;\n keys.forEach((k) => delete o[k]);\n return o;\n}\n\n/**\n * Performs a deep patch of the target object or array using the source object or array.\n *\n * This function recursively merges properties of the source into the target:\n * - If a property in both target and source is a plain object, they are recursively merged.\n * - If a property in both target and source is an array of the same length, the arrays are recursively patched element by element.\n * - Otherwise, the property value in the target is replaced by the corresponding value from the source.\n *\n * The patch is applied in-place to the target object or array, which is also returned for convenience.\n *\n * @typeParam T - The type of the target and source, which must be either a plain object or an array.\n * @param target - The target object or array to be patched. This object/array is modified in-place.\n * @param source - The source object or array providing the new values for the patch.\n * @returns The modified target object or array.\n *\n * @example\n * ```typescript\n * const target = { a: { b: 1 }, c: [1, 2] };\n * const source = { a: { b: 2 }, c: [3, 4], d: 5 };\n * const result = deepPatch(target, source);\n * // target is now: { a: { b: 2 }, c: [3, 4], d: 5 }\n * // result is the same reference as target.\n *\n * const targetArray = [{ a: 1 }, { b: 2 }];\n * const sourceArray = [{ a: 2 }, { b: 3 }];\n * const resultArray = deepPatch(targetArray, sourceArray);\n * // targetArray is now: [{ a: 2 }, { b: 3 }]\n * ```\n */\nexport function deepPatch<T extends PlainObject | unknown[]>(target: T, source: T) {\n const sk = new Set<keyof T>([...Object.keys(target) as (keyof T)[], ...Object.keys(source) as (keyof T)[]]);\n\n sk.forEach((key) => {\n const t = target[key];\n const s = source[key];\n if (isPlainObject(t) && isPlainObject(s)) {\n deepPatch(t, s);\n } else if (isArray(t) && isArray(s) && t.length === s.length) {\n deepPatch(t, s);\n } else {\n target[key] = s;\n }\n });\n\n return target;\n}\n","export const random = Math.random;\n\nexport function randomInt(): number {\n return (random() * Number.MAX_SAFE_INTEGER) | 0;\n}\n\nexport function randomRangeFloat(min: number, max: number): number {\n return random() * (max - min) + min;\n}\n\nexport function randomRangeInt(min: number, max: number): number {\n min = Math.ceil(min);\n max = Math.floor(max);\n return Math.floor(randomRangeFloat(min, max));\n}\n\nexport function randomSign(): number {\n return random() > 0.5 ? 1 : -1;\n}\n"],"names":["isNil","v","notEmpty","message","delay","ms","resolve","tap","cb","tapIf","getRandomInt","min","max","randomString","length","s","i","uniqueId","isArray","isNonPrimitive","obj","isObject","value","isPlainObject","prototype","definedKeysSize","isJsonEqual","a","b","k","deepClone","copy","random","randomInt"],"mappings":"AAEO,SAASA,EAAMC,GAA0C;AACvD,SAAAA,KAAM;AACf;AAWgB,SAAAC,EAAYD,GAAyBE,GAAqB;AACpE,MAAAF,KAAM;AACF,UAAA,MAAME,KAAW,gCAAgC;AAGlDF,SAAAA;AACT;AAsFO,SAASG,EAAMC,GAAY;AAChC,SAAO,IAAI,QAAQ,CAACC,MAAY,WAAWA,GAASD,CAAE,CAAC;AACzD;AA4BgB,SAAAE,EAAUN,GAAMO,GAAiB;AAC/C,SAAOA,EAAGP,CAAC;AACb;AAEgB,SAAAQ,EAAYR,GAAyBO,GAAiB;AAChE,MAAAP,KAAM;AACR,WAAOO,EAAGP,CAAC;AAIf;ACnJA,SAASS,EAAaC,GAAaC,GAAa;AACxC,SAAAD,IAAA,KAAK,KAAKA,CAAG,GACbC,IAAA,KAAK,MAAMA,CAAG,GACb,KAAK,MAAM,KAAK,OAAYA,KAAAA,IAAMD,EAAI,IAAIA;AACnD;AA4EO,SAASE,EAAaC,GAAgB;AAC3C,MAAIC,IAAI;AACCC,WAAAA,IAAI,GAAGA,IAAIF,GAAQE;AAC1B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AAChE;AAQO,SAASE,EAAaV,GAAW;AAClC,MAAA,MAAM,QAAQA,CAAG,GAAG;AACtB,UAAMW,IAAc,CAAC;AACrB,aAASf,IAAI,GAAGA,IAAII,EAAI,QAAQJ;AAC9Be,MAAAA,EAAKf,CAAC,IAAIc,EAAUV,EAAIJ,CAAC,CAAC;AAErBe,WAAAA;AAAAA,EAAA,WACER,EAAcH,CAAG,GAAG;AAC7B,UAAMW,IAA4B,CAAC;AACnC,WAAA,OAAO,KAAKX,CAAG,EAAE,QAAQ,CAACS,MAAM;AAC9BE,MAAAA,EAAKF,CAAC,IAAIC,EAAUV,EAAIS,CAAC,CAAC;AAAA,IAC3B,CAAA,GACME;AAAAA,EAAA;AAEAX,WAAAA;AAEX;ACnIO,MAAMY,IAAS,KAAK;AAEpB,SAASC,IAAoB;AAC1BD,SAAAA,EAAW,IAAA,OAAO,mBAAoB;AAChD;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as e from "./module/core.js";
|
|
2
|
+
import { _areEquals as m, applyOperation as c, applyPatch as i, applyReducer as d, getValueByPointer as P, validate as h, validator as u } from "./module/core.js";
|
|
3
|
+
import * as o from "./module/duplex.js";
|
|
4
|
+
import { compare as C, generate as v, observe as x, unobserve as y } from "./module/duplex.js";
|
|
5
|
+
import { unescapePathComponent as r, escapePathComponent as a, _deepClone as p, PatchError as t } from "./module/helpers.js";
|
|
6
|
+
Object.assign({}, e, o, {
|
|
7
|
+
JsonPatchError: t,
|
|
8
|
+
deepClone: p,
|
|
9
|
+
escapePathComponent: a,
|
|
10
|
+
unescapePathComponent: r
|
|
11
|
+
});
|
|
12
|
+
export {
|
|
13
|
+
t as JsonPatchError,
|
|
14
|
+
m as _areEquals,
|
|
15
|
+
c as applyOperation,
|
|
16
|
+
i as applyPatch,
|
|
17
|
+
d as applyReducer,
|
|
18
|
+
C as compare,
|
|
19
|
+
p as deepClone,
|
|
20
|
+
a as escapePathComponent,
|
|
21
|
+
v as generate,
|
|
22
|
+
P as getValueByPointer,
|
|
23
|
+
x as observe,
|
|
24
|
+
r as unescapePathComponent,
|
|
25
|
+
y as unobserve,
|
|
26
|
+
h as validate,
|
|
27
|
+
u as validator
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.mjs"],"sourcesContent":["export * from './module/core.mjs';\nexport * from './module/duplex.mjs';\nexport {\n PatchError as JsonPatchError,\n _deepClone as deepClone,\n escapePathComponent,\n unescapePathComponent\n} from './module/helpers.mjs';\n\n\n/**\n * Default export for backwards compat\n */\n\nimport * as core from './module/core.mjs';\nimport * as duplex from './module/duplex.mjs';\nimport {\n PatchError as JsonPatchError,\n _deepClone as deepClone,\n escapePathComponent,\n unescapePathComponent\n} from './module/helpers.mjs';\n\nexport default Object.assign({}, core, duplex, {\n JsonPatchError,\n deepClone,\n escapePathComponent,\n unescapePathComponent\n});"],"names":["core","duplex","JsonPatchError","deepClone","escapePathComponent","unescapePathComponent"],"mappings":";;;;;AAuBe,OAAO,OAAO,CAAA,GAAIA,GAAMC,GAAQ;AAAA,EAC/C,gBAAIC;AAAAA,EACJ,WAAIC;AAAAA,EACA,qBAAAC;AAAA,EACA,uBAAAC;AACJ,CAAC;","x_google_ignoreList":[0]}
|
package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { PatchError as D, _deepClone as A, unescapePathComponent as c, isInteger as u, hasUndefined as P } from "./helpers.js";
|
|
2
|
+
var p = D, C = A, O = {
|
|
3
|
+
add: function(e, r, f) {
|
|
4
|
+
return e[r] = this.value, { newDocument: f };
|
|
5
|
+
},
|
|
6
|
+
remove: function(e, r, f) {
|
|
7
|
+
var s = e[r];
|
|
8
|
+
return delete e[r], { newDocument: f, removed: s };
|
|
9
|
+
},
|
|
10
|
+
replace: function(e, r, f) {
|
|
11
|
+
var s = e[r];
|
|
12
|
+
return e[r] = this.value, { newDocument: f, removed: s };
|
|
13
|
+
},
|
|
14
|
+
move: function(e, r, f) {
|
|
15
|
+
var s = R(f, this.path);
|
|
16
|
+
s && (s = A(s));
|
|
17
|
+
var h = a(f, { op: "remove", path: this.from }).removed;
|
|
18
|
+
return a(f, { op: "add", path: this.path, value: h }), { newDocument: f, removed: s };
|
|
19
|
+
},
|
|
20
|
+
copy: function(e, r, f) {
|
|
21
|
+
var s = R(f, this.from);
|
|
22
|
+
return a(f, { op: "add", path: this.path, value: A(s) }), { newDocument: f };
|
|
23
|
+
},
|
|
24
|
+
test: function(e, r, f) {
|
|
25
|
+
return { newDocument: f, test: o(e[r], this.value) };
|
|
26
|
+
},
|
|
27
|
+
_get: function(e, r, f) {
|
|
28
|
+
return this.value = e[r], { newDocument: f };
|
|
29
|
+
}
|
|
30
|
+
}, y = {
|
|
31
|
+
add: function(e, r, f) {
|
|
32
|
+
return u(r) ? e.splice(r, 0, this.value) : e[r] = this.value, { newDocument: f, index: r };
|
|
33
|
+
},
|
|
34
|
+
remove: function(e, r, f) {
|
|
35
|
+
var s = e.splice(r, 1);
|
|
36
|
+
return { newDocument: f, removed: s[0] };
|
|
37
|
+
},
|
|
38
|
+
replace: function(e, r, f) {
|
|
39
|
+
var s = e[r];
|
|
40
|
+
return e[r] = this.value, { newDocument: f, removed: s };
|
|
41
|
+
},
|
|
42
|
+
move: O.move,
|
|
43
|
+
copy: O.copy,
|
|
44
|
+
test: O.test,
|
|
45
|
+
_get: O._get
|
|
46
|
+
};
|
|
47
|
+
function R(e, r) {
|
|
48
|
+
if (r == "")
|
|
49
|
+
return e;
|
|
50
|
+
var f = { op: "_get", path: r };
|
|
51
|
+
return a(e, f), f.value;
|
|
52
|
+
}
|
|
53
|
+
function a(e, r, f, s, h, l) {
|
|
54
|
+
if (f === void 0 && (f = !1), s === void 0 && (s = !0), h === void 0 && (h = !0), l === void 0 && (l = 0), f && (typeof f == "function" ? f(r, 0, e, r.path) : I(r, 0)), r.path === "") {
|
|
55
|
+
var t = { newDocument: e };
|
|
56
|
+
if (r.op === "add")
|
|
57
|
+
return t.newDocument = r.value, t;
|
|
58
|
+
if (r.op === "replace")
|
|
59
|
+
return t.newDocument = r.value, t.removed = e, t;
|
|
60
|
+
if (r.op === "move" || r.op === "copy")
|
|
61
|
+
return t.newDocument = R(e, r.from), r.op === "move" && (t.removed = e), t;
|
|
62
|
+
if (r.op === "test") {
|
|
63
|
+
if (t.test = o(e, r.value), t.test === !1)
|
|
64
|
+
throw new p("Test operation failed", "TEST_OPERATION_FAILED", l, r, e);
|
|
65
|
+
return t.newDocument = e, t;
|
|
66
|
+
} else {
|
|
67
|
+
if (r.op === "remove")
|
|
68
|
+
return t.removed = e, t.newDocument = null, t;
|
|
69
|
+
if (r.op === "_get")
|
|
70
|
+
return r.value = e, t;
|
|
71
|
+
if (f)
|
|
72
|
+
throw new p("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", l, r, e);
|
|
73
|
+
return t;
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
s || (e = A(e));
|
|
77
|
+
var n = r.path || "", E = n.split("/"), w = e, _ = 1, T = E.length, i = void 0, v = void 0, N = void 0;
|
|
78
|
+
for (typeof f == "function" ? N = f : N = I; ; ) {
|
|
79
|
+
if (v = E[_], v && v.indexOf("~") != -1 && (v = c(v)), h && (v == "__proto__" || v == "prototype" && _ > 0 && E[_ - 1] == "constructor"))
|
|
80
|
+
throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");
|
|
81
|
+
if (f && i === void 0 && (w[v] === void 0 ? i = E.slice(0, _).join("/") : _ == T - 1 && (i = r.path), i !== void 0 && N(r, 0, e, i)), _++, Array.isArray(w)) {
|
|
82
|
+
if (v === "-")
|
|
83
|
+
v = w.length;
|
|
84
|
+
else {
|
|
85
|
+
if (f && !u(v))
|
|
86
|
+
throw new p("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", l, r, e);
|
|
87
|
+
u(v) && (v = ~~v);
|
|
88
|
+
}
|
|
89
|
+
if (_ >= T) {
|
|
90
|
+
if (f && r.op === "add" && v > w.length)
|
|
91
|
+
throw new p("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", l, r, e);
|
|
92
|
+
var t = y[r.op].call(r, w, v, e);
|
|
93
|
+
if (t.test === !1)
|
|
94
|
+
throw new p("Test operation failed", "TEST_OPERATION_FAILED", l, r, e);
|
|
95
|
+
return t;
|
|
96
|
+
}
|
|
97
|
+
} else if (_ >= T) {
|
|
98
|
+
var t = O[r.op].call(r, w, v, e);
|
|
99
|
+
if (t.test === !1)
|
|
100
|
+
throw new p("Test operation failed", "TEST_OPERATION_FAILED", l, r, e);
|
|
101
|
+
return t;
|
|
102
|
+
}
|
|
103
|
+
if (w = w[v], f && _ < T && (!w || typeof w != "object"))
|
|
104
|
+
throw new p("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", l, r, e);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function L(e, r, f, s, h) {
|
|
109
|
+
if (s === void 0 && (s = !0), h === void 0 && (h = !0), f && !Array.isArray(r))
|
|
110
|
+
throw new p("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
111
|
+
s || (e = A(e));
|
|
112
|
+
for (var l = new Array(r.length), t = 0, n = r.length; t < n; t++)
|
|
113
|
+
l[t] = a(e, r[t], f, !0, h, t), e = l[t].newDocument;
|
|
114
|
+
return l.newDocument = e, l;
|
|
115
|
+
}
|
|
116
|
+
function U(e, r, f) {
|
|
117
|
+
var s = a(e, r);
|
|
118
|
+
if (s.test === !1)
|
|
119
|
+
throw new p("Test operation failed", "TEST_OPERATION_FAILED", f, r, e);
|
|
120
|
+
return s.newDocument;
|
|
121
|
+
}
|
|
122
|
+
function I(e, r, f, s) {
|
|
123
|
+
if (typeof e != "object" || e === null || Array.isArray(e))
|
|
124
|
+
throw new p("Operation is not an object", "OPERATION_NOT_AN_OBJECT", r, e, f);
|
|
125
|
+
if (O[e.op]) {
|
|
126
|
+
if (typeof e.path != "string")
|
|
127
|
+
throw new p("Operation `path` property is not a string", "OPERATION_PATH_INVALID", r, e, f);
|
|
128
|
+
if (e.path.indexOf("/") !== 0 && e.path.length > 0)
|
|
129
|
+
throw new p('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", r, e, f);
|
|
130
|
+
if ((e.op === "move" || e.op === "copy") && typeof e.from != "string")
|
|
131
|
+
throw new p("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", r, e, f);
|
|
132
|
+
if ((e.op === "add" || e.op === "replace" || e.op === "test") && e.value === void 0)
|
|
133
|
+
throw new p("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", r, e, f);
|
|
134
|
+
if ((e.op === "add" || e.op === "replace" || e.op === "test") && P(e.value))
|
|
135
|
+
throw new p("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", r, e, f);
|
|
136
|
+
if (f) {
|
|
137
|
+
if (e.op == "add") {
|
|
138
|
+
var h = e.path.split("/").length, l = s.split("/").length;
|
|
139
|
+
if (h !== l + 1 && h !== l)
|
|
140
|
+
throw new p("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", r, e, f);
|
|
141
|
+
} else if (e.op === "replace" || e.op === "remove" || e.op === "_get") {
|
|
142
|
+
if (e.path !== s)
|
|
143
|
+
throw new p("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", r, e, f);
|
|
144
|
+
} else if (e.op === "move" || e.op === "copy") {
|
|
145
|
+
var t = { op: "_get", path: e.from, value: void 0 }, n = g([t], f);
|
|
146
|
+
if (n && n.name === "OPERATION_PATH_UNRESOLVABLE")
|
|
147
|
+
throw new p("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", r, e, f);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
} else throw new p("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", r, e, f);
|
|
151
|
+
}
|
|
152
|
+
function g(e, r, f) {
|
|
153
|
+
try {
|
|
154
|
+
if (!Array.isArray(e))
|
|
155
|
+
throw new p("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
156
|
+
if (r)
|
|
157
|
+
L(A(r), A(e), f || !0);
|
|
158
|
+
else {
|
|
159
|
+
f = f || I;
|
|
160
|
+
for (var s = 0; s < e.length; s++)
|
|
161
|
+
f(e[s], s, r, void 0);
|
|
162
|
+
}
|
|
163
|
+
} catch (h) {
|
|
164
|
+
if (h instanceof p)
|
|
165
|
+
return h;
|
|
166
|
+
throw h;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function o(e, r) {
|
|
170
|
+
if (e === r)
|
|
171
|
+
return !0;
|
|
172
|
+
if (e && r && typeof e == "object" && typeof r == "object") {
|
|
173
|
+
var f = Array.isArray(e), s = Array.isArray(r), h, l, t;
|
|
174
|
+
if (f && s) {
|
|
175
|
+
if (l = e.length, l != r.length)
|
|
176
|
+
return !1;
|
|
177
|
+
for (h = l; h-- !== 0; )
|
|
178
|
+
if (!o(e[h], r[h]))
|
|
179
|
+
return !1;
|
|
180
|
+
return !0;
|
|
181
|
+
}
|
|
182
|
+
if (f != s)
|
|
183
|
+
return !1;
|
|
184
|
+
var n = Object.keys(e);
|
|
185
|
+
if (l = n.length, l !== Object.keys(r).length)
|
|
186
|
+
return !1;
|
|
187
|
+
for (h = l; h-- !== 0; )
|
|
188
|
+
if (!r.hasOwnProperty(n[h]))
|
|
189
|
+
return !1;
|
|
190
|
+
for (h = l; h-- !== 0; )
|
|
191
|
+
if (t = n[h], !o(e[t], r[t]))
|
|
192
|
+
return !1;
|
|
193
|
+
return !0;
|
|
194
|
+
}
|
|
195
|
+
return e !== e && r !== r;
|
|
196
|
+
}
|
|
197
|
+
export {
|
|
198
|
+
p as JsonPatchError,
|
|
199
|
+
o as _areEquals,
|
|
200
|
+
a as applyOperation,
|
|
201
|
+
L as applyPatch,
|
|
202
|
+
U as applyReducer,
|
|
203
|
+
C as deepClone,
|
|
204
|
+
R as getValueByPointer,
|
|
205
|
+
g as validate,
|
|
206
|
+
I as validator
|
|
207
|
+
};
|
|
208
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../../../../../../../../node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.mjs"],"sourcesContent":["import { PatchError, _deepClone, isInteger, unescapePathComponent, hasUndefined } from './helpers.mjs';\nexport var JsonPatchError = PatchError;\nexport var deepClone = _deepClone;\n/* We use a Javascript hash to store each\n function. Each hash entry (property) uses\n the operation identifiers specified in rfc6902.\n In this way, we can map each patch operation\n to its dedicated function in efficient way.\n */\n/* The operations applicable to an object */\nvar objOps = {\n add: function (obj, key, document) {\n obj[key] = this.value;\n return { newDocument: document };\n },\n remove: function (obj, key, document) {\n var removed = obj[key];\n delete obj[key];\n return { newDocument: document, removed: removed };\n },\n replace: function (obj, key, document) {\n var removed = obj[key];\n obj[key] = this.value;\n return { newDocument: document, removed: removed };\n },\n move: function (obj, key, document) {\n /* in case move target overwrites an existing value,\n return the removed value, this can be taxing performance-wise,\n and is potentially unneeded */\n var removed = getValueByPointer(document, this.path);\n if (removed) {\n removed = _deepClone(removed);\n }\n var originalValue = applyOperation(document, { op: \"remove\", path: this.from }).removed;\n applyOperation(document, { op: \"add\", path: this.path, value: originalValue });\n return { newDocument: document, removed: removed };\n },\n copy: function (obj, key, document) {\n var valueToCopy = getValueByPointer(document, this.from);\n // enforce copy by value so further operations don't affect source (see issue #177)\n applyOperation(document, { op: \"add\", path: this.path, value: _deepClone(valueToCopy) });\n return { newDocument: document };\n },\n test: function (obj, key, document) {\n return { newDocument: document, test: _areEquals(obj[key], this.value) };\n },\n _get: function (obj, key, document) {\n this.value = obj[key];\n return { newDocument: document };\n }\n};\n/* The operations applicable to an array. Many are the same as for the object */\nvar arrOps = {\n add: function (arr, i, document) {\n if (isInteger(i)) {\n arr.splice(i, 0, this.value);\n }\n else { // array props\n arr[i] = this.value;\n }\n // this may be needed when using '-' in an array\n return { newDocument: document, index: i };\n },\n remove: function (arr, i, document) {\n var removedList = arr.splice(i, 1);\n return { newDocument: document, removed: removedList[0] };\n },\n replace: function (arr, i, document) {\n var removed = arr[i];\n arr[i] = this.value;\n return { newDocument: document, removed: removed };\n },\n move: objOps.move,\n copy: objOps.copy,\n test: objOps.test,\n _get: objOps._get\n};\n/**\n * Retrieves a value from a JSON document by a JSON pointer.\n * Returns the value.\n *\n * @param document The document to get the value from\n * @param pointer an escaped JSON pointer\n * @return The retrieved value\n */\nexport function getValueByPointer(document, pointer) {\n if (pointer == '') {\n return document;\n }\n var getOriginalDestination = { op: \"_get\", path: pointer };\n applyOperation(document, getOriginalDestination);\n return getOriginalDestination.value;\n}\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the {newDocument, result} of the operation.\n * It modifies the `document` and `operation` objects - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyOperation(document, jsonpatch._deepClone(operation))`.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return `{newDocument, result}` after the operation\n */\nexport function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {\n if (validateOperation === void 0) { validateOperation = false; }\n if (mutateDocument === void 0) { mutateDocument = true; }\n if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }\n if (index === void 0) { index = 0; }\n if (validateOperation) {\n if (typeof validateOperation == 'function') {\n validateOperation(operation, 0, document, operation.path);\n }\n else {\n validator(operation, 0);\n }\n }\n /* ROOT OPERATIONS */\n if (operation.path === \"\") {\n var returnValue = { newDocument: document };\n if (operation.op === 'add') {\n returnValue.newDocument = operation.value;\n return returnValue;\n }\n else if (operation.op === 'replace') {\n returnValue.newDocument = operation.value;\n returnValue.removed = document; //document we removed\n return returnValue;\n }\n else if (operation.op === 'move' || operation.op === 'copy') { // it's a move or copy to root\n returnValue.newDocument = getValueByPointer(document, operation.from); // get the value by json-pointer in `from` field\n if (operation.op === 'move') { // report removed item\n returnValue.removed = document;\n }\n return returnValue;\n }\n else if (operation.op === 'test') {\n returnValue.test = _areEquals(document, operation.value);\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n returnValue.newDocument = document;\n return returnValue;\n }\n else if (operation.op === 'remove') { // a remove on root\n returnValue.removed = document;\n returnValue.newDocument = null;\n return returnValue;\n }\n else if (operation.op === '_get') {\n operation.value = document;\n return returnValue;\n }\n else { /* bad operation */\n if (validateOperation) {\n throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);\n }\n else {\n return returnValue;\n }\n }\n } /* END ROOT OPERATIONS */\n else {\n if (!mutateDocument) {\n document = _deepClone(document);\n }\n var path = operation.path || \"\";\n var keys = path.split('/');\n var obj = document;\n var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift\n var len = keys.length;\n var existingPathFragment = undefined;\n var key = void 0;\n var validateFunction = void 0;\n if (typeof validateOperation == 'function') {\n validateFunction = validateOperation;\n }\n else {\n validateFunction = validator;\n }\n while (true) {\n key = keys[t];\n if (key && key.indexOf('~') != -1) {\n key = unescapePathComponent(key);\n }\n if (banPrototypeModifications &&\n (key == '__proto__' ||\n (key == 'prototype' && t > 0 && keys[t - 1] == 'constructor'))) {\n throw new TypeError('JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');\n }\n if (validateOperation) {\n if (existingPathFragment === undefined) {\n if (obj[key] === undefined) {\n existingPathFragment = keys.slice(0, t).join('/');\n }\n else if (t == len - 1) {\n existingPathFragment = operation.path;\n }\n if (existingPathFragment !== undefined) {\n validateFunction(operation, 0, document, existingPathFragment);\n }\n }\n }\n t++;\n if (Array.isArray(obj)) {\n if (key === '-') {\n key = obj.length;\n }\n else {\n if (validateOperation && !isInteger(key)) {\n throw new JsonPatchError(\"Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index\", \"OPERATION_PATH_ILLEGAL_ARRAY_INDEX\", index, operation, document);\n } // only parse key when it's an integer for `arr.prop` to work\n else if (isInteger(key)) {\n key = ~~key;\n }\n }\n if (t >= len) {\n if (validateOperation && operation.op === \"add\" && key > obj.length) {\n throw new JsonPatchError(\"The specified index MUST NOT be greater than the number of elements in the array\", \"OPERATION_VALUE_OUT_OF_BOUNDS\", index, operation, document);\n }\n var returnValue = arrOps[operation.op].call(operation, obj, key, document); // Apply patch\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return returnValue;\n }\n }\n else {\n if (t >= len) {\n var returnValue = objOps[operation.op].call(operation, obj, key, document); // Apply patch\n if (returnValue.test === false) {\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return returnValue;\n }\n }\n obj = obj[key];\n // If we have more keys in the path, but the next value isn't a non-null object,\n // throw an OPERATION_PATH_UNRESOLVABLE error instead of iterating again.\n if (validateOperation && t < len && (!obj || typeof obj !== \"object\")) {\n throw new JsonPatchError('Cannot perform operation at the desired path', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);\n }\n }\n }\n}\n/**\n * Apply a full JSON Patch array on a JSON document.\n * Returns the {newDocument, result} of the patch.\n * It modifies the `document` object and `patch` - it gets the values by reference.\n * If you would like to avoid touching your values, clone them:\n * `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`.\n *\n * @param document The document to patch\n * @param patch The patch to apply\n * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.\n * @param mutateDocument Whether to mutate the original document or clone it before applying\n * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.\n * @return An array of `{newDocument, result}` after the patch\n */\nexport function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {\n if (mutateDocument === void 0) { mutateDocument = true; }\n if (banPrototypeModifications === void 0) { banPrototypeModifications = true; }\n if (validateOperation) {\n if (!Array.isArray(patch)) {\n throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');\n }\n }\n if (!mutateDocument) {\n document = _deepClone(document);\n }\n var results = new Array(patch.length);\n for (var i = 0, length_1 = patch.length; i < length_1; i++) {\n // we don't need to pass mutateDocument argument because if it was true, we already deep cloned the object, we'll just pass `true`\n results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);\n document = results[i].newDocument; // in case root was replaced\n }\n results.newDocument = document;\n return results;\n}\n/**\n * Apply a single JSON Patch Operation on a JSON document.\n * Returns the updated document.\n * Suitable as a reducer.\n *\n * @param document The document to patch\n * @param operation The operation to apply\n * @return The updated document\n */\nexport function applyReducer(document, operation, index) {\n var operationResult = applyOperation(document, operation);\n if (operationResult.test === false) { // failed test\n throw new JsonPatchError(\"Test operation failed\", 'TEST_OPERATION_FAILED', index, operation, document);\n }\n return operationResult.newDocument;\n}\n/**\n * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.\n * @param {object} operation - operation object (patch)\n * @param {number} index - index of operation in the sequence\n * @param {object} [document] - object where the operation is supposed to be applied\n * @param {string} [existingPathFragment] - comes along with `document`\n */\nexport function validator(operation, index, document, existingPathFragment) {\n if (typeof operation !== 'object' || operation === null || Array.isArray(operation)) {\n throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, document);\n }\n else if (!objOps[operation.op]) {\n throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);\n }\n else if (typeof operation.path !== 'string') {\n throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, document);\n }\n else if (operation.path.indexOf('/') !== 0 && operation.path.length > 0) {\n // paths that aren't empty string should start with \"/\"\n throw new JsonPatchError('Operation `path` property must start with \"/\"', 'OPERATION_PATH_INVALID', index, operation, document);\n }\n else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {\n throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, document);\n }\n else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {\n throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, document);\n }\n else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {\n throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, document);\n }\n else if (document) {\n if (operation.op == \"add\") {\n var pathLen = operation.path.split(\"/\").length;\n var existingPathLen = existingPathFragment.split(\"/\").length;\n if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {\n throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, document);\n }\n }\n else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {\n if (operation.path !== existingPathFragment) {\n throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);\n }\n }\n else if (operation.op === 'move' || operation.op === 'copy') {\n var existingValue = { op: \"_get\", path: operation.from, value: undefined };\n var error = validate([existingValue], document);\n if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {\n throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, document);\n }\n }\n }\n}\n/**\n * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.\n * If error is encountered, returns a JsonPatchError object\n * @param sequence\n * @param document\n * @returns {JsonPatchError|undefined}\n */\nexport function validate(sequence, document, externalValidator) {\n try {\n if (!Array.isArray(sequence)) {\n throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');\n }\n if (document) {\n //clone document and sequence so that we can safely try applying operations\n applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);\n }\n else {\n externalValidator = externalValidator || validator;\n for (var i = 0; i < sequence.length; i++) {\n externalValidator(sequence[i], i, document, undefined);\n }\n }\n }\n catch (e) {\n if (e instanceof JsonPatchError) {\n return e;\n }\n else {\n throw e;\n }\n }\n}\n// based on https://github.com/epoberezkin/fast-deep-equal\n// MIT License\n// Copyright (c) 2017 Evgeny Poberezkin\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\nexport function _areEquals(a, b) {\n if (a === b)\n return true;\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n var arrA = Array.isArray(a), arrB = Array.isArray(b), i, length, key;\n if (arrA && arrB) {\n length = a.length;\n if (length != b.length)\n return false;\n for (i = length; i-- !== 0;)\n if (!_areEquals(a[i], b[i]))\n return false;\n return true;\n }\n if (arrA != arrB)\n return false;\n var keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length)\n return false;\n for (i = length; i-- !== 0;)\n if (!b.hasOwnProperty(keys[i]))\n return false;\n for (i = length; i-- !== 0;) {\n key = keys[i];\n if (!_areEquals(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a !== a && b !== b;\n}\n;\n"],"names":["JsonPatchError","PatchError","deepClone","_deepClone","objOps","obj","key","document","removed","getValueByPointer","originalValue","applyOperation","valueToCopy","_areEquals","arrOps","arr","i","isInteger","removedList","pointer","getOriginalDestination","operation","validateOperation","mutateDocument","banPrototypeModifications","index","validator","returnValue","path","keys","t","len","existingPathFragment","validateFunction","unescapePathComponent","applyPatch","patch","results","length_1","applyReducer","operationResult","hasUndefined","pathLen","existingPathLen","existingValue","error","validate","sequence","externalValidator","e","a","b","arrA","arrB","length"],"mappings":";AACU,IAACA,IAAiBC,GACjBC,IAAYC,GAQnBC,IAAS;AAAA,EACT,KAAK,SAAUC,GAAKC,GAAKC,GAAU;AAC/B,WAAAF,EAAIC,CAAG,IAAI,KAAK,OACT,EAAE,aAAaC,EAAU;AAAA,EACnC;AAAA,EACD,QAAQ,SAAUF,GAA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