@azure-net/kit 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/delivery/schema/Schema.d.ts +3 -1
  2. package/dist/delivery/schema/Schema.js +3 -0
  3. package/dist/delivery/schema/rules/Rules.d.ts +40 -6
  4. package/dist/delivery/schema/rules/Rules.js +174 -22
  5. package/dist/delivery/schema/rules/messages/En.js +28 -3
  6. package/dist/delivery/schema/rules/messages/Ru.js +28 -3
  7. package/dist/delivery/schema/rules/messages/Types.d.ts +28 -3
  8. package/dist/delivery/schema/rules/messages/WithI18n.js +28 -3
  9. package/dist/infra/datasource/BaseDatasource.js +2 -4
  10. package/dist/infra/query/QueryBuilder.js +37 -17
  11. package/dist/infra/response/BaseResponse.js +1 -1
  12. package/dist/plugin/AzureNetPlugin.js +52 -11
  13. package/dist/shared/app/App.d.ts +25 -2
  14. package/dist/shared/app/App.js +42 -1
  15. package/dist/shared/app/index.d.ts +1 -1
  16. package/dist/shared/background-task/BackgroundTask.d.ts +16 -0
  17. package/dist/shared/background-task/BackgroundTask.js +34 -0
  18. package/dist/shared/background-task/index.d.ts +1 -0
  19. package/dist/shared/background-task/index.js +1 -0
  20. package/dist/shared/boundary-provider/Provider.d.ts +1 -1
  21. package/dist/shared/boundary-provider/Provider.js +12 -8
  22. package/dist/shared/class-mirror/ClassMirror.js +0 -6
  23. package/dist/shared/cookie/UniversalCookie.d.ts +2 -0
  24. package/dist/shared/cookie/UniversalCookie.js +45 -30
  25. package/dist/shared/index.d.ts +2 -1
  26. package/dist/shared/index.js +2 -1
  27. package/dist/shared/logger/index.d.ts +2 -1
  28. package/dist/shared/logger/index.js +15 -10
  29. package/dist/svelte/active-form/ActiveForm.svelte.js +10 -9
  30. package/dist/svelte/query/Query.svelte.js +7 -7
  31. package/dist/svelte/shared/cloneStateValue.d.ts +2 -0
  32. package/dist/svelte/shared/cloneStateValue.js +100 -0
  33. package/package.json +7 -7
@@ -1,10 +1,11 @@
1
1
  import { ObjectUtil } from '../../external/tools/index.js';
2
+ import { cloneStateValue } from '../shared/cloneStateValue.js';
2
3
  export const createActiveForm = (onSubmit, config) => {
3
4
  const isPromise = (value) => {
4
5
  return typeof value?.then === 'function';
5
6
  };
6
7
  let initial = {};
7
- let formData = $state(ObjectUtil.deepClone(initial));
8
+ let formData = $state(cloneStateValue(initial));
8
9
  let formErrors = $state({});
9
10
  let pending = $state(false);
10
11
  let submitRunId = 0;
@@ -15,18 +16,18 @@ export const createActiveForm = (onSubmit, config) => {
15
16
  const source = config?.initialData;
16
17
  if (!source) {
17
18
  initial = {};
18
- formData = ObjectUtil.deepClone(initial);
19
+ formData = cloneStateValue(initial);
19
20
  formErrors = {};
20
- return initial;
21
+ return cloneStateValue(initial);
21
22
  }
22
23
  const value = source();
23
24
  const nextInitial = isPromise(value) ? await value : value;
24
25
  if (runId !== initialLoadRunId)
25
- return initial;
26
- initial = (nextInitial ?? {});
27
- formData = ObjectUtil.deepClone(initial);
26
+ return cloneStateValue(initial);
27
+ initial = cloneStateValue((nextInitial ?? {}));
28
+ formData = cloneStateValue(initial);
28
29
  formErrors = {};
29
- return initial;
30
+ return cloneStateValue(initial);
30
31
  };
31
32
  const ready = loadInitialData();
32
33
  const abortedResponse = () => ({
@@ -45,7 +46,7 @@ export const createActiveForm = (onSubmit, config) => {
45
46
  formData = {};
46
47
  break;
47
48
  case 'initial':
48
- formData = ObjectUtil.deepClone(initial);
49
+ formData = cloneStateValue(initial);
49
50
  break;
50
51
  case 'reloadInitial':
51
52
  await loadInitialData();
@@ -70,7 +71,7 @@ export const createActiveForm = (onSubmit, config) => {
70
71
  if (aborted || runId !== submitRunId)
71
72
  return abortedResponse();
72
73
  }
73
- const result = await onSubmit($state.snapshot(formData));
74
+ const result = await onSubmit(cloneStateValue(formData));
74
75
  if (runId !== submitRunId)
75
76
  return result;
76
77
  if (result.success) {
@@ -1,8 +1,8 @@
1
- import { ObjectUtil } from '../../external/tools/index.js';
2
1
  import { untrack } from 'svelte';
2
+ import { cloneStateValue } from '../shared/cloneStateValue.js';
3
3
  export const createQuery = (initialValue, options) => {
4
- const baseInitial = ObjectUtil.deepClone(initialValue);
5
- let data = $state(ObjectUtil.deepClone(baseInitial));
4
+ const baseInitial = cloneStateValue(initialValue);
5
+ let data = $state(cloneStateValue(baseInitial));
6
6
  const includeKeys = options?.onChange?.include ?? [];
7
7
  const hasWatch = Boolean(options?.onChange?.handler) && includeKeys.length > 0;
8
8
  const lastValues = new Map();
@@ -33,7 +33,7 @@ export const createQuery = (initialValue, options) => {
33
33
  await options.onChange.handler({
34
34
  changedKeys,
35
35
  signal: localController.signal,
36
- snapshot: ObjectUtil.deepClone(data)
36
+ snapshot: cloneStateValue(data)
37
37
  });
38
38
  };
39
39
  untrack(() => {
@@ -54,13 +54,13 @@ export const createQuery = (initialValue, options) => {
54
54
  });
55
55
  }
56
56
  const reset = () => {
57
- data = ObjectUtil.deepClone(baseInitial);
57
+ data = cloneStateValue(baseInitial);
58
58
  };
59
59
  const patch = (value) => {
60
60
  data = { ...data, ...value };
61
61
  };
62
- const snapshot = () => ObjectUtil.deepClone(data);
63
- const initial = () => ObjectUtil.deepClone(baseInitial);
62
+ const snapshot = () => cloneStateValue(data);
63
+ const initial = () => cloneStateValue(baseInitial);
64
64
  return {
65
65
  get data() {
66
66
  return data;
@@ -0,0 +1,2 @@
1
+ /** Creates a detached graph from plain state while preserving opaque values. */
2
+ export declare const cloneStateValue: <T>(value: T) => T;
@@ -0,0 +1,100 @@
1
+ const preserveExtensibility = (source, target) => {
2
+ if (!Object.isExtensible(source))
3
+ Object.preventExtensions(target);
4
+ };
5
+ const cloneProperties = (source, target, seen, excluded) => {
6
+ for (const key of Reflect.ownKeys(source)) {
7
+ if (key === excluded)
8
+ continue;
9
+ const descriptor = Reflect.getOwnPropertyDescriptor(source, key);
10
+ if (!descriptor)
11
+ continue;
12
+ if ('value' in descriptor)
13
+ descriptor.value = cloneValue(descriptor.value, seen);
14
+ Reflect.defineProperty(target, key, descriptor);
15
+ }
16
+ };
17
+ const cloneValue = (value, seen) => {
18
+ if (value === null || typeof value !== 'object')
19
+ return value;
20
+ const cached = seen.get(value);
21
+ if (cached !== undefined)
22
+ return cached;
23
+ if (Array.isArray(value)) {
24
+ const result = new Array(value.length);
25
+ seen.set(value, result);
26
+ cloneProperties(value, result, seen, 'length');
27
+ const lengthDescriptor = Reflect.getOwnPropertyDescriptor(value, 'length');
28
+ if (lengthDescriptor)
29
+ Reflect.defineProperty(result, 'length', lengthDescriptor);
30
+ preserveExtensibility(value, result);
31
+ return result;
32
+ }
33
+ if (value instanceof Date) {
34
+ const result = new Date(value.getTime());
35
+ seen.set(value, result);
36
+ return result;
37
+ }
38
+ if (value instanceof Map) {
39
+ const result = new Map();
40
+ seen.set(value, result);
41
+ for (const [key, entryValue] of value) {
42
+ result.set(cloneValue(key, seen), cloneValue(entryValue, seen));
43
+ }
44
+ return result;
45
+ }
46
+ if (value instanceof Set) {
47
+ const result = new Set();
48
+ seen.set(value, result);
49
+ for (const entryValue of value)
50
+ result.add(cloneValue(entryValue, seen));
51
+ return result;
52
+ }
53
+ if (value instanceof RegExp) {
54
+ const result = new RegExp(value.source, value.flags);
55
+ result.lastIndex = value.lastIndex;
56
+ seen.set(value, result);
57
+ return result;
58
+ }
59
+ if (typeof URL !== 'undefined' && value instanceof URL) {
60
+ const result = new URL(value.href);
61
+ seen.set(value, result);
62
+ return result;
63
+ }
64
+ if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
65
+ const result = new URLSearchParams(value);
66
+ seen.set(value, result);
67
+ return result;
68
+ }
69
+ if (value instanceof ArrayBuffer) {
70
+ const result = value.slice(0);
71
+ seen.set(value, result);
72
+ return result;
73
+ }
74
+ if (typeof SharedArrayBuffer !== 'undefined' && value instanceof SharedArrayBuffer) {
75
+ const result = value.slice(0);
76
+ seen.set(value, result);
77
+ return result;
78
+ }
79
+ if (ArrayBuffer.isView(value)) {
80
+ const buffer = cloneValue(value.buffer, seen);
81
+ const result = value instanceof DataView
82
+ ? new DataView(buffer, value.byteOffset, value.byteLength)
83
+ : new value.constructor(buffer, value.byteOffset, value.length);
84
+ seen.set(value, result);
85
+ return result;
86
+ }
87
+ const prototype = Object.getPrototypeOf(value);
88
+ if (prototype !== Object.prototype && prototype !== null) {
89
+ // File, Blob, Promise and class instances cannot be cloned generically without
90
+ // losing internal slots or behavior. Keeping them is lossless and preserves DX.
91
+ return value;
92
+ }
93
+ const result = Object.create(prototype);
94
+ seen.set(value, result);
95
+ cloneProperties(value, result, seen);
96
+ preserveExtensibility(value, result);
97
+ return result;
98
+ };
99
+ /** Creates a detached graph from plain state while preserving opaque values. */
100
+ export const cloneStateValue = (value) => cloneValue(value, new WeakMap());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "license": "MIT",
5
5
  "author": "Pixel1917",
6
6
  "description": "Universal toolkit and library collection, developed as part of the Azure-net ecosystem",
@@ -73,15 +73,15 @@
73
73
  }
74
74
  },
75
75
  "peerDependencies": {
76
- "@sveltejs/kit": ">=2.16.0",
77
- "svelte": ">=5.0.0"
76
+ "@sveltejs/kit": ">=2.57.1",
77
+ "svelte": ">=5.55.4"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@eslint/compat": "^2.0.5",
81
81
  "@eslint/js": "^10.0.1",
82
82
  "@playwright/test": "^1.59.1",
83
83
  "@sveltejs/adapter-auto": "^7.0.1",
84
- "@sveltejs/kit": "^2.57.1",
84
+ "@sveltejs/kit": "^2.70.2",
85
85
  "@sveltejs/package": "^2.5.7",
86
86
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
87
87
  "@testing-library/jest-dom": "^6.9.1",
@@ -95,7 +95,7 @@
95
95
  "prettier": "^3.8.3",
96
96
  "prettier-plugin-svelte": "^3.5.1",
97
97
  "publint": "^0.3.18",
98
- "svelte": "^5.55.4",
98
+ "svelte": "^5.56.9",
99
99
  "svelte-check": "^4.4.6",
100
100
  "typescript": "^5.0.0",
101
101
  "typescript-eslint": "^8.58.2",
@@ -127,8 +127,8 @@
127
127
  "lint": "prettier --check . && eslint .",
128
128
  "test:unit": "vitest --config vitest.config.ts",
129
129
  "test:integration": "vitest --config vitest.integration.config.ts --run",
130
- "test": "npm run test:unit -- --run && npm run test:e2e",
131
- "test:e2e": "playwright test --pass-with-no-tests",
130
+ "test": "pnpm test:unit -- --run && pnpm test:integration && pnpm test:e2e",
131
+ "test:e2e": "playwright test",
132
132
  "commit": "pnpm format && git add ."
133
133
  }
134
134
  }