pi-proactive 0.2.0-beta.2 → 0.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +32 -28
- package/build/cli.mjs +121 -0
- package/build/extensions/proactive.js +47 -6
- package/build/src/commands.js +78 -2
- package/build/src/config.js +511 -4
- package/build/src/daemon-config.js +221 -0
- package/build/src/daemon-contact.js +103 -0
- package/build/src/daemon-host.js +84 -0
- package/build/src/daemon.js +193 -3
- package/build/src/health.js +84 -0
- package/build/src/lineage.js +41 -2
- package/build/src/notify.js +183 -0
- package/build/src/progress-eta.js +134 -0
- package/build/src/trigger.js +43 -0
- package/build/src/trust-loop.js +321 -0
- package/build/src/trust-metrics.js +236 -0
- package/build/src/trust-notify.js +73 -0
- package/build/src/trust-policy.js +58 -0
- package/build/src/trust-registry.js +323 -0
- package/daemon/launchd.plist +48 -0
- package/daemon/pi-proactive-daemon.service +29 -0
- package/daemon/run-daemon.sh +84 -0
- package/node_modules/typebox/build/compile/code.mjs +2 -1
- package/node_modules/typebox/build/compile/validator.mjs +1 -5
- package/node_modules/typebox/build/format/date_time.d.mts +1 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -12
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +0 -1
- package/node_modules/typebox/build/format/idn_email.mjs +0 -1
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/iri.mjs +9 -16
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +5 -7
- package/node_modules/typebox/build/guard/guard.mjs +9 -14
- package/node_modules/typebox/build/guard/index.mjs +0 -6
- package/node_modules/typebox/build/guard/{unicode/unicode_segment.mjs → string.mjs} +19 -16
- package/node_modules/typebox/build/schema/build.mjs +5 -5
- package/node_modules/typebox/build/schema/check.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_context.d.mts +1 -5
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -16
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/_refine.mjs +9 -14
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +20 -34
- package/node_modules/typebox/build/schema/engine/_stack.mjs +202 -143
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +2 -4
- package/node_modules/typebox/build/schema/engine/_unique.mjs +3 -7
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +32 -27
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/allOf.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +9 -4
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/boolean.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/const.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/contains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +7 -5
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/enum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/format.mjs +8 -11
- package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/if.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/items.mjs +5 -8
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minContains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/minItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +11 -6
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/pattern.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +5 -6
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +10 -7
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/ref.mjs +14 -18
- package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/required.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +138 -136
- package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +6 -2
- package/node_modules/typebox/build/schema/errors.mjs +1 -1
- package/node_modules/typebox/build/schema/intern/intern.d.mts +9 -6
- package/node_modules/typebox/build/schema/intern/intern.mjs +56 -90
- package/node_modules/typebox/build/schema/parse.mjs +0 -3
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +6 -1
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +64 -47
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +32 -6
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +227 -231
- package/node_modules/typebox/build/schema/schema.d.mts +0 -1
- package/node_modules/typebox/build/schema/schema.mjs +0 -1
- package/node_modules/typebox/build/system/hashing/hash.mjs +34 -63
- package/node_modules/typebox/build/system/locale/en_US.mjs +1 -2
- package/node_modules/typebox/build/system/memory/assign.d.mts +8 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +6 -13
- package/node_modules/typebox/build/system/memory/clone.d.mts +5 -4
- package/node_modules/typebox/build/system/memory/clone.mjs +96 -8
- package/node_modules/typebox/build/system/memory/create.d.mts +5 -1
- package/node_modules/typebox/build/system/memory/create.mjs +13 -18
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +8 -9
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +4 -1
- package/node_modules/typebox/build/system/memory/update.mjs +16 -43
- package/node_modules/typebox/build/system/settings/settings.d.mts +0 -11
- package/node_modules/typebox/build/system/settings/settings.mjs +0 -14
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +24 -2
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +29 -2
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +1 -5
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +1 -6
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +2 -15
- package/node_modules/typebox/build/type/extends/tuple.d.mts +1 -2
- package/node_modules/typebox/build/type/extends/tuple.mjs +1 -21
- package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/clone/clone.d.mts +3 -4
- package/node_modules/typebox/build/value/clone/clone.mjs +7 -5
- package/node_modules/typebox/build/value/parse/parse.mjs +4 -10
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +14 -25
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +84 -52
- package/package.json +11 -3
- package/skills/pi-proactive/SKILL.md +27 -24
- package/tools/cli.mjs +121 -0
- package/tools/daemon-install.sh +397 -0
- package/tools/daemon-uninstall.sh +226 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +0 -6
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +0 -35
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +0 -11
- package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +0 -288
- package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +0 -300
- package/node_modules/typebox/build/schema/meta/draft_3.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_3.mjs +0 -143
- package/node_modules/typebox/build/schema/meta/draft_4.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_4.mjs +0 -149
- package/node_modules/typebox/build/schema/meta/draft_6.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_6.mjs +0 -155
- package/node_modules/typebox/build/schema/meta/draft_7.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_7.mjs +0 -172
- package/node_modules/typebox/build/schema/meta/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/index.mjs +0 -2
- package/node_modules/typebox/build/schema/meta/meta.d.mts +0 -9
- package/node_modules/typebox/build/schema/meta/meta.mjs +0 -15
- package/node_modules/typebox/build/schema/meta/schema.d.mts +0 -6
- package/node_modules/typebox/build/schema/meta/schema.mjs +0 -1
- package/node_modules/typebox/build/system/memory/deep.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/deep.mjs +0 -108
- package/node_modules/typebox/build/system/memory/finalize.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/finalize.mjs +0 -30
- package/node_modules/typebox/build/system/memory/keys.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/keys.mjs +0 -8
- package/node_modules/typebox/build/system/settings/internal.d.mts +0 -2
- package/node_modules/typebox/build/system/settings/internal.mjs +0 -20
- package/node_modules/typebox/build/type/engine/call/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/call/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +0 -30
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +0 -29
- package/node_modules/typebox/build/type/engine/this/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/this/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +0 -6
- /package/node_modules/typebox/build/guard/{unicode/unicode_segment.d.mts → string.d.mts} +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Unreachable } from '../unreachable/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { Guard, GlobalsGuard } from '../../guard/index.mjs';
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
5
|
// InstanceKeys
|
|
6
6
|
//
|
|
7
|
-
// Retrieves all enumerable and non-enumerable own property keys
|
|
8
|
-
// and inherited prototype keys (excluding symbols and the 'constructor')
|
|
7
|
+
// Retrieves all enumerable and non-enumerable own property keys
|
|
8
|
+
// and inherited prototype keys (excluding symbols and the 'constructor')
|
|
9
9
|
// from an object instance.
|
|
10
10
|
//
|
|
11
|
-
// This function is useful for differentiating between class instances
|
|
12
|
-
// based on their structural keys rather than relying on the
|
|
13
|
-
// constructor name. It provides a more reliable structural comparison
|
|
11
|
+
// This function is useful for differentiating between class instances
|
|
12
|
+
// based on their structural keys rather than relying on the
|
|
13
|
+
// constructor name. It provides a more reliable structural comparison
|
|
14
14
|
// by capturing both own and prototype properties.
|
|
15
15
|
//
|
|
16
16
|
// ------------------------------------------------------------------
|
|
@@ -40,57 +40,38 @@ function IsIEEE754(value) {
|
|
|
40
40
|
// ------------------------------------------------------------------
|
|
41
41
|
// ByteMarker
|
|
42
42
|
// ------------------------------------------------------------------
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
var ByteMarker;
|
|
44
|
+
(function (ByteMarker) {
|
|
45
|
+
ByteMarker[ByteMarker["Array"] = 0] = "Array";
|
|
46
|
+
ByteMarker[ByteMarker["BigInt"] = 1] = "BigInt";
|
|
47
|
+
ByteMarker[ByteMarker["Boolean"] = 2] = "Boolean";
|
|
48
|
+
ByteMarker[ByteMarker["Date"] = 3] = "Date";
|
|
49
|
+
ByteMarker[ByteMarker["Constructor"] = 4] = "Constructor";
|
|
50
|
+
ByteMarker[ByteMarker["Function"] = 5] = "Function";
|
|
51
|
+
ByteMarker[ByteMarker["Null"] = 6] = "Null";
|
|
52
|
+
ByteMarker[ByteMarker["Number"] = 7] = "Number";
|
|
53
|
+
ByteMarker[ByteMarker["Object"] = 8] = "Object";
|
|
54
|
+
ByteMarker[ByteMarker["RegExp"] = 9] = "RegExp";
|
|
55
|
+
ByteMarker[ByteMarker["String"] = 10] = "String";
|
|
56
|
+
ByteMarker[ByteMarker["Symbol"] = 11] = "Symbol";
|
|
57
|
+
ByteMarker[ByteMarker["TypeArray"] = 12] = "TypeArray";
|
|
58
|
+
ByteMarker[ByteMarker["Undefined"] = 13] = "Undefined";
|
|
59
|
+
})(ByteMarker || (ByteMarker = {}));
|
|
59
60
|
// ------------------------------------------------------------------
|
|
60
61
|
// State
|
|
61
62
|
// ------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// arithmetic, avoiding a BigInt multiply and modulo for every byte.
|
|
66
|
-
//
|
|
67
|
-
// Offset: 14695981039346656037 (0xCBF29CE484222325)
|
|
68
|
-
//
|
|
69
|
-
// ------------------------------------------------------------------
|
|
70
|
-
let A0 = 0x2325, A1 = 0x8422, A2 = 0x9CE4, A3 = 0xCBF2;
|
|
63
|
+
let Accumulator = BigInt('14695981039346656037');
|
|
64
|
+
const [Prime, Size] = [BigInt('1099511628211'), BigInt('18446744073709551616' /* 2 ^ 64 */)];
|
|
65
|
+
const Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i));
|
|
71
66
|
const F64 = new Float64Array(1);
|
|
72
67
|
const F64In = new DataView(F64.buffer);
|
|
73
68
|
const F64Out = new Uint8Array(F64.buffer);
|
|
74
69
|
// ------------------------------------------------------------------
|
|
75
70
|
// Operation
|
|
76
|
-
//
|
|
77
|
-
// Prime: 1099511628211 (0x100000001B3 = 2^40 + 0x1B3)
|
|
78
|
-
//
|
|
79
|
-
// The multiply is computed as (A * 0x1B3) + (A << 40) modulo 2^64,
|
|
80
|
-
// where (A << 40) adds (A0 << 8) to the third limb and (A1 << 8)
|
|
81
|
-
// to the fourth.
|
|
82
|
-
//
|
|
83
71
|
// ------------------------------------------------------------------
|
|
84
72
|
function FNV1A64_OP(byte) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const T1 = A1 * 0x1B3 + (T0 >>> 16);
|
|
88
|
-
const T2 = A2 * 0x1B3 + (T1 >>> 16) + (L0 << 8);
|
|
89
|
-
const T3 = A3 * 0x1B3 + (T2 >>> 16) + (A1 << 8);
|
|
90
|
-
A0 = T0 & 0xFFFF;
|
|
91
|
-
A1 = T1 & 0xFFFF;
|
|
92
|
-
A2 = T2 & 0xFFFF;
|
|
93
|
-
A3 = T3 & 0xFFFF;
|
|
73
|
+
Accumulator = Accumulator ^ Bytes[byte];
|
|
74
|
+
Accumulator = (Accumulator * Prime) % Size;
|
|
94
75
|
}
|
|
95
76
|
// ------------------------------------------------------------------
|
|
96
77
|
// Array
|
|
@@ -178,15 +159,8 @@ function FromRegExp(value) {
|
|
|
178
159
|
const encoder = new TextEncoder();
|
|
179
160
|
function FromString(value) {
|
|
180
161
|
FNV1A64_OP(ByteMarker.String);
|
|
181
|
-
for (
|
|
182
|
-
|
|
183
|
-
if (code > 0x7F) {
|
|
184
|
-
for (const byte of encoder.encode(value.slice(i))) {
|
|
185
|
-
FNV1A64_OP(byte);
|
|
186
|
-
}
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
FNV1A64_OP(code);
|
|
162
|
+
for (const byte of encoder.encode(value)) {
|
|
163
|
+
FNV1A64_OP(byte);
|
|
190
164
|
}
|
|
191
165
|
}
|
|
192
166
|
// ------------------------------------------------------------------
|
|
@@ -246,16 +220,13 @@ function FromValue(value) {
|
|
|
246
220
|
// ------------------------------------------------------------------
|
|
247
221
|
// Hash
|
|
248
222
|
// ------------------------------------------------------------------
|
|
249
|
-
function Hex(limb) {
|
|
250
|
-
return limb.toString(16).padStart(4, '0');
|
|
251
|
-
}
|
|
252
223
|
/** Generates a FNV1A-64 non cryptographic hash of the given value */
|
|
253
224
|
export function HashCode(value) {
|
|
254
|
-
|
|
225
|
+
Accumulator = BigInt('14695981039346656037');
|
|
226
|
+
FromValue(value);
|
|
227
|
+
return Accumulator;
|
|
255
228
|
}
|
|
256
229
|
/** Generates a FNV1A-64 non cryptographic hash of the given value */
|
|
257
230
|
export function Hash(value) {
|
|
258
|
-
|
|
259
|
-
FromValue(value);
|
|
260
|
-
return `${Hex(A3)}${Hex(A2)}${Hex(A1)}${Hex(A0)}`;
|
|
231
|
+
return HashCode(value).toString(16).padStart(16, '0');
|
|
261
232
|
}
|
|
@@ -33,8 +33,7 @@ export function en_US(error) {
|
|
|
33
33
|
case 'unevaluatedProperties': return 'must not have unevaluated properties';
|
|
34
34
|
case 'uniqueItems': return `must not have duplicate items`;
|
|
35
35
|
case '~refine': return error.params.message;
|
|
36
|
-
// deno-coverage-ignore
|
|
36
|
+
// deno-coverage-ignore - unreachable
|
|
37
37
|
default: return 'an unknown validation error occurred';
|
|
38
|
-
// deno-coverage-ignore-stop
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
type ObjectLike = Record<PropertyKey, any>;
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Performs an Object assign using the Left and Right object types. We track this operation as it
|
|
4
|
+
* creates a new GC handle per assignment.
|
|
5
|
+
*/
|
|
3
6
|
export type TAssign<Left extends ObjectLike, Right extends ObjectLike, Assigned extends ObjectLike = Omit<Left, keyof Right> & Right> = {
|
|
4
7
|
[Key in keyof Assigned]: Assigned[Key];
|
|
5
8
|
} & {};
|
|
6
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Performs an Object assign using the Left and Right object types. We track this operation as it
|
|
11
|
+
* creates a new GC handle per assignment.
|
|
12
|
+
*/
|
|
7
13
|
export declare function Assign<Left extends ObjectLike, Right extends ObjectLike>(left: Left, right: Right): TAssign<Left, Right>;
|
|
8
14
|
export {};
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
// deno-lint-ignore-file ban-types no-explicit-any
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
3
|
import { Metrics } from './metrics.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { Freeze } from './freeze.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* Performs an Object assign using the Left and Right object types. We track this operation as it
|
|
7
|
+
* creates a new GC handle per assignment.
|
|
8
|
+
*/
|
|
7
9
|
export function Assign(left, right) {
|
|
8
10
|
Metrics.assign += 1;
|
|
9
|
-
|
|
10
|
-
for (const key of leftKeys) {
|
|
11
|
-
if (rightKeys.includes(key))
|
|
12
|
-
continue;
|
|
13
|
-
Object.defineProperty(result, key, Object.getOwnPropertyDescriptor(left, key));
|
|
14
|
-
}
|
|
15
|
-
for (const key of rightKeys) {
|
|
16
|
-
Object.defineProperty(result, key, Object.getOwnPropertyDescriptor(right, key));
|
|
17
|
-
}
|
|
18
|
-
return Finalize(result);
|
|
11
|
+
return Freeze({ ...left, ...right });
|
|
19
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Returns a Clone of the given value. This function is similar to structuredClone()
|
|
3
|
+
* but also supports deep cloning instances of Map, Set and TypeArray.
|
|
4
|
+
*/
|
|
5
|
+
export declare function Clone<Value extends unknown = unknown>(value: Value): Value;
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
// deno-lint-ignore-file no-explicit-any
|
|
2
1
|
// deno-fmt-ignore-file
|
|
3
|
-
import { Guard } from '../../guard/index.mjs';
|
|
2
|
+
import { Guard, GlobalsGuard } from '../../guard/index.mjs';
|
|
4
3
|
import { Metrics } from './metrics.mjs';
|
|
5
|
-
import { Keys } from './keys.mjs';
|
|
6
4
|
// ------------------------------------------------------------------
|
|
7
|
-
//
|
|
5
|
+
// ClassInstance
|
|
6
|
+
//
|
|
7
|
+
// TypeBox does not clone arbitrary class instances. Class instances
|
|
8
|
+
// cannot be safely cloned without potentially breaking private
|
|
9
|
+
// members of the instance.
|
|
10
|
+
//
|
|
8
11
|
// ------------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
function FromClassInstance(value) {
|
|
13
|
+
return value; // atomic
|
|
14
|
+
}
|
|
15
|
+
// ------------------------------------------------------------------
|
|
16
|
+
// SchemaObject
|
|
17
|
+
//
|
|
18
|
+
// Schema objects have non-enumerable properties that MUST be preserved
|
|
19
|
+
// on Clone. The following is the optimal path these objects.
|
|
20
|
+
// ------------------------------------------------------------------
|
|
21
|
+
function IsSchemaObject(value) {
|
|
22
|
+
return (Guard.HasPropertyKey(value, '~kind') ||
|
|
23
|
+
Guard.HasPropertyKey(value, '~unsafe'));
|
|
24
|
+
}
|
|
25
|
+
function FromSchemaObject(value) {
|
|
12
26
|
const result = {};
|
|
13
|
-
for (const key of Keys(value)) {
|
|
27
|
+
for (const key of Guard.Keys(value)) {
|
|
14
28
|
if (Guard.IsUnsafePropertyKey(key))
|
|
15
29
|
continue; // (ignore: prototype-pollution)
|
|
16
30
|
const descriptor = Object.getOwnPropertyDescriptor(value, key); // safe-name!
|
|
31
|
+
descriptor.value = FromValue(descriptor.value);
|
|
17
32
|
if (Guard.IsEqual(descriptor.enumerable, true)) {
|
|
18
33
|
result[key] = descriptor.value;
|
|
19
34
|
}
|
|
@@ -23,3 +38,76 @@ export function Clone(value) {
|
|
|
23
38
|
}
|
|
24
39
|
return result;
|
|
25
40
|
}
|
|
41
|
+
// ------------------------------------------------------------------
|
|
42
|
+
// PlainObject
|
|
43
|
+
// ------------------------------------------------------------------
|
|
44
|
+
function FromPlainObject(value) {
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const key of Guard.Keys(value)) {
|
|
47
|
+
if (Guard.IsUnsafePropertyKey(key))
|
|
48
|
+
continue; // (ignore: prototype-pollution)
|
|
49
|
+
result[key] = FromValue(value[key]);
|
|
50
|
+
}
|
|
51
|
+
for (const key of Guard.Symbols(value)) {
|
|
52
|
+
result[key] = FromValue(value[key]);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
// ------------------------------------------------------------------
|
|
57
|
+
// Object
|
|
58
|
+
// ------------------------------------------------------------------
|
|
59
|
+
function FromObject(value) {
|
|
60
|
+
return (Guard.IsClassInstance(value) ? FromClassInstance(value) :
|
|
61
|
+
IsSchemaObject(value) ? FromSchemaObject(value) :
|
|
62
|
+
FromPlainObject(value));
|
|
63
|
+
}
|
|
64
|
+
// ------------------------------------------------------------------
|
|
65
|
+
// Array
|
|
66
|
+
// ------------------------------------------------------------------
|
|
67
|
+
function FromArray(value) {
|
|
68
|
+
return value.map((element) => FromValue(element));
|
|
69
|
+
}
|
|
70
|
+
// ------------------------------------------------------------------
|
|
71
|
+
// TypeArray
|
|
72
|
+
// ------------------------------------------------------------------
|
|
73
|
+
function FromTypedArray(value) {
|
|
74
|
+
return value.slice();
|
|
75
|
+
}
|
|
76
|
+
// ------------------------------------------------------------------
|
|
77
|
+
// RegExp
|
|
78
|
+
// ------------------------------------------------------------------
|
|
79
|
+
function FromRegExp(value) {
|
|
80
|
+
return new RegExp(value.source, value.flags);
|
|
81
|
+
}
|
|
82
|
+
// ------------------------------------------------------------------
|
|
83
|
+
// Map
|
|
84
|
+
// ------------------------------------------------------------------
|
|
85
|
+
function FromMap(value) {
|
|
86
|
+
return new Map(FromValue([...value.entries()]));
|
|
87
|
+
}
|
|
88
|
+
// ------------------------------------------------------------------
|
|
89
|
+
// Set
|
|
90
|
+
// ------------------------------------------------------------------
|
|
91
|
+
function FromSet(value) {
|
|
92
|
+
return new Set(FromValue([...value.values()]));
|
|
93
|
+
}
|
|
94
|
+
function FromValue(value) {
|
|
95
|
+
return (GlobalsGuard.IsTypeArray(value) ? FromTypedArray(value) :
|
|
96
|
+
GlobalsGuard.IsRegExp(value) ? FromRegExp(value) :
|
|
97
|
+
GlobalsGuard.IsMap(value) ? FromMap(value) :
|
|
98
|
+
GlobalsGuard.IsSet(value) ? FromSet(value) :
|
|
99
|
+
Guard.IsArray(value) ? FromArray(value) :
|
|
100
|
+
Guard.IsObject(value) ? FromObject(value) :
|
|
101
|
+
value);
|
|
102
|
+
}
|
|
103
|
+
// ------------------------------------------------------------------
|
|
104
|
+
// Clone
|
|
105
|
+
// ------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* Returns a Clone of the given value. This function is similar to structuredClone()
|
|
108
|
+
* but also supports deep cloning instances of Map, Set and TypeArray.
|
|
109
|
+
*/
|
|
110
|
+
export function Clone(value) {
|
|
111
|
+
Metrics.clone += 1;
|
|
112
|
+
return FromValue(value);
|
|
113
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
type ObjectLike = Record<PropertyKey, any>;
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Creates an object with hidden, enumerable, and optional property sets. This function
|
|
4
|
+
* ensures types are instantiated according to configuration rules for enumerable and
|
|
5
|
+
* non-enumerable properties.
|
|
6
|
+
*/
|
|
3
7
|
export declare function Create(hidden: ObjectLike, enumerable: ObjectLike, options?: ObjectLike): ObjectLike;
|
|
4
8
|
export {};
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
// deno-lint-ignore-file no-explicit-any
|
|
2
2
|
import { Settings } from '../settings/index.mjs';
|
|
3
3
|
import { Metrics } from './metrics.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
// WithEnumerable
|
|
7
|
-
// ------------------------------------------------------------------
|
|
8
|
-
function WithEnumerable(left, right) {
|
|
9
|
-
return { ...left, ...right };
|
|
10
|
-
}
|
|
11
|
-
// ------------------------------------------------------------------
|
|
12
|
-
// WithHidden
|
|
13
|
-
// ------------------------------------------------------------------
|
|
14
|
-
function WithHidden(left, right) {
|
|
4
|
+
import { Freeze } from './freeze.mjs';
|
|
5
|
+
function MergeHidden(left, right) {
|
|
15
6
|
for (const key of Object.keys(right)) {
|
|
16
7
|
Object.defineProperty(left, key, {
|
|
17
8
|
configurable: true,
|
|
@@ -22,13 +13,17 @@ function WithHidden(left, right) {
|
|
|
22
13
|
}
|
|
23
14
|
return left;
|
|
24
15
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
16
|
+
function Merge(left, right) {
|
|
17
|
+
return { ...left, ...right };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an object with hidden, enumerable, and optional property sets. This function
|
|
21
|
+
* ensures types are instantiated according to configuration rules for enumerable and
|
|
22
|
+
* non-enumerable properties.
|
|
23
|
+
*/
|
|
29
24
|
export function Create(hidden, enumerable, options = {}) {
|
|
30
25
|
Metrics.create += 1;
|
|
31
|
-
const
|
|
32
|
-
const withHidden = Settings.Get().enumerableKind ?
|
|
33
|
-
return
|
|
26
|
+
const withOptions = Merge(enumerable, options);
|
|
27
|
+
const withHidden = Settings.Get().enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);
|
|
28
|
+
return Freeze(withHidden);
|
|
34
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
type ObjectLike = Record<PropertyKey, any>;
|
|
2
|
-
/** Discards property keys from the given object
|
|
2
|
+
/** Discards multiple property keys from the given object value */
|
|
3
3
|
export declare function Discard(value: ObjectLike, propertyKeys: PropertyKey[]): ObjectLike;
|
|
4
4
|
export {};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// deno-lint-ignore-file no-explicit-any
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
2
3
|
import { Metrics } from './metrics.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
// Discard
|
|
7
|
-
// ------------------------------------------------------------------
|
|
8
|
-
/** Discards property keys from the given object. */
|
|
4
|
+
import { Freeze } from './freeze.mjs';
|
|
5
|
+
import { Clone } from './clone.mjs';
|
|
6
|
+
/** Discards multiple property keys from the given object value */
|
|
9
7
|
export function Discard(value, propertyKeys) {
|
|
10
8
|
Metrics.discard += 1;
|
|
11
9
|
const result = {};
|
|
12
|
-
for (const key of Keys(value)) {
|
|
10
|
+
for (const key of Guard.Keys(value)) {
|
|
13
11
|
if (propertyKeys.includes(key))
|
|
14
12
|
continue;
|
|
15
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
13
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key); // safe-name!
|
|
14
|
+
descriptor.value = Clone(descriptor.value);
|
|
16
15
|
Object.defineProperty(result, key, descriptor);
|
|
17
16
|
}
|
|
18
|
-
return
|
|
17
|
+
return Freeze(result);
|
|
19
18
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// deno-lint-ignore-file no-explicit-any
|
|
2
|
+
import { Settings } from '../settings/index.mjs';
|
|
3
|
+
/** Conditionally freezes the value if `immutableTypes` is true, otherwise no action. */
|
|
4
|
+
export function Freeze(value) {
|
|
5
|
+
return Settings.Get().immutableTypes ? Object.freeze(value) : value;
|
|
6
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
type ObjectLike = Record<PropertyKey, any>;
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Updates a value with new properties while preserving property enumerability. Use this function to modify
|
|
4
|
+
* existing types without altering their configuration.
|
|
5
|
+
*/
|
|
3
6
|
export declare function Update(current: ObjectLike, hidden: ObjectLike, enumerable: ObjectLike): ObjectLike;
|
|
4
7
|
export {};
|
|
@@ -1,43 +1,27 @@
|
|
|
1
1
|
// deno-lint-ignore-file no-explicit-any
|
|
2
|
-
import { Guard } from '../../guard/index.mjs';
|
|
3
2
|
import { Settings } from '../settings/index.mjs';
|
|
4
3
|
import { Metrics } from './metrics.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
// ------------------------------------------------------------------
|
|
19
|
-
// WithHidden
|
|
20
|
-
// ------------------------------------------------------------------
|
|
21
|
-
function WithHidden(hidden, keys, result) {
|
|
22
|
-
const enumerableKind = Settings.Get().enumerableKind;
|
|
23
|
-
for (const key of keys) {
|
|
24
|
-
if (Guard.IsUnsafePropertyKey(key))
|
|
25
|
-
continue; // (ignore: prototype-pollution)
|
|
4
|
+
import { Freeze } from './freeze.mjs';
|
|
5
|
+
import { Clone } from './clone.mjs';
|
|
6
|
+
/**
|
|
7
|
+
* Updates a value with new properties while preserving property enumerability. Use this function to modify
|
|
8
|
+
* existing types without altering their configuration.
|
|
9
|
+
*/
|
|
10
|
+
export function Update(current, hidden, enumerable) {
|
|
11
|
+
Metrics.update += 1;
|
|
12
|
+
const settings = Settings.Get();
|
|
13
|
+
const result = Clone(current);
|
|
14
|
+
// hidden
|
|
15
|
+
for (const key of Object.keys(hidden)) {
|
|
26
16
|
Object.defineProperty(result, key, {
|
|
27
17
|
configurable: true,
|
|
28
18
|
writable: true,
|
|
29
|
-
enumerable: enumerableKind,
|
|
19
|
+
enumerable: settings.enumerableKind,
|
|
30
20
|
value: hidden[key]
|
|
31
21
|
});
|
|
32
22
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// WithEnumerable
|
|
36
|
-
// ------------------------------------------------------------------
|
|
37
|
-
function WithEnumerable(enumerable, keys, result) {
|
|
38
|
-
for (const key of keys) {
|
|
39
|
-
if (Guard.IsUnsafePropertyKey(key))
|
|
40
|
-
continue; // (ignore: prototype-pollution)
|
|
23
|
+
// enumerable
|
|
24
|
+
for (const key of Object.keys(enumerable)) {
|
|
41
25
|
Object.defineProperty(result, key, {
|
|
42
26
|
configurable: true,
|
|
43
27
|
enumerable: true,
|
|
@@ -45,16 +29,5 @@ function WithEnumerable(enumerable, keys, result) {
|
|
|
45
29
|
value: enumerable[key]
|
|
46
30
|
});
|
|
47
31
|
}
|
|
48
|
-
|
|
49
|
-
// ------------------------------------------------------------------
|
|
50
|
-
// Update
|
|
51
|
-
// ------------------------------------------------------------------
|
|
52
|
-
/** Updates an existing type with additional hidden and enumerable properties while preserving property configuration. */
|
|
53
|
-
export function Update(current, hidden, enumerable) {
|
|
54
|
-
Metrics.update += 1;
|
|
55
|
-
const result = {}, hiddenKeys = Keys(hidden), enumerableKeys = Keys(enumerable);
|
|
56
|
-
WithCurrent(current, hiddenKeys, enumerableKeys, result);
|
|
57
|
-
WithHidden(hidden, hiddenKeys, result);
|
|
58
|
-
WithEnumerable(enumerable, enumerableKeys, result);
|
|
59
|
-
return Finalize(result);
|
|
32
|
+
return Freeze(result);
|
|
60
33
|
}
|
|
@@ -16,17 +16,6 @@ export interface TSettings {
|
|
|
16
16
|
* @default 8
|
|
17
17
|
*/
|
|
18
18
|
maxErrors: number;
|
|
19
|
-
/**
|
|
20
|
-
* Specifies the maximum number of errors to gather for failed Parse operations. TypeBox will
|
|
21
|
-
* automatically run an error-gathering pass on failed Parses to attach diagnostics to the
|
|
22
|
-
* thrown exception. This setting controls the number of errors gathered in that pass. Higher
|
|
23
|
-
* values will reduce throughput on failure cases, so a maximum of 4 is recommended if more
|
|
24
|
-
* errors are needed. The default setting of 1 will terminate on the first error, while a
|
|
25
|
-
* setting of 0 will skip error gathering entirely.
|
|
26
|
-
*
|
|
27
|
-
* @default 1
|
|
28
|
-
*/
|
|
29
|
-
maxParseErrors: number;
|
|
30
19
|
/**
|
|
31
20
|
* Specifies the maximum number of instantiations allowed within a top-level generic instantiation
|
|
32
21
|
* context. This setting can be used to bound generic calls to a fixed count, which can be useful if
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { Guard } from '../../guard/index.mjs';
|
|
2
|
-
// -------------------------------------------------------------------
|
|
3
|
-
// State
|
|
4
|
-
// -------------------------------------------------------------------
|
|
5
2
|
// Internal mutable state
|
|
6
3
|
const settings = {
|
|
7
4
|
immutableTypes: false,
|
|
8
5
|
maxErrors: 8,
|
|
9
|
-
maxParseErrors: 1,
|
|
10
6
|
maxInstantiationCount: 128,
|
|
11
7
|
useAcceleration: true,
|
|
12
8
|
exactOptionalPropertyTypes: false,
|
|
@@ -14,14 +10,10 @@ const settings = {
|
|
|
14
10
|
correctiveParse: false,
|
|
15
11
|
unionPrioritySort: true
|
|
16
12
|
};
|
|
17
|
-
// -------------------------------------------------------------------
|
|
18
|
-
// Reset
|
|
19
|
-
// -------------------------------------------------------------------
|
|
20
13
|
/** Resets system settings to defaults */
|
|
21
14
|
export function Reset() {
|
|
22
15
|
settings.immutableTypes = false;
|
|
23
16
|
settings.maxErrors = 8;
|
|
24
|
-
settings.maxParseErrors = 1;
|
|
25
17
|
settings.maxInstantiationCount = 128;
|
|
26
18
|
settings.useAcceleration = true;
|
|
27
19
|
settings.exactOptionalPropertyTypes = false;
|
|
@@ -29,9 +21,6 @@ export function Reset() {
|
|
|
29
21
|
settings.correctiveParse = false;
|
|
30
22
|
settings.unionPrioritySort = true;
|
|
31
23
|
}
|
|
32
|
-
// -------------------------------------------------------------------
|
|
33
|
-
// Set
|
|
34
|
-
// -------------------------------------------------------------------
|
|
35
24
|
/** Sets system settings */
|
|
36
25
|
export function Set(options) {
|
|
37
26
|
for (const key of Guard.Keys(options)) {
|
|
@@ -41,9 +30,6 @@ export function Set(options) {
|
|
|
41
30
|
}
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
|
-
// -------------------------------------------------------------------
|
|
45
|
-
// Get
|
|
46
|
-
// -------------------------------------------------------------------
|
|
47
33
|
/** Gets current system settings */
|
|
48
34
|
export function Get() {
|
|
49
35
|
return settings;
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
+
import { type TReadonly } from '../../types/_readonly.mjs';
|
|
2
|
+
import { type TOptional } from '../../types/_optional.mjs';
|
|
1
3
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
4
|
import { type TProperties } from '../../types/properties.mjs';
|
|
3
5
|
import { type TObject } from '../../types/object.mjs';
|
|
4
6
|
import { type TNever } from '../../types/never.mjs';
|
|
5
7
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
8
|
+
import { type TAddReadonly } from '../../action/_add_readonly.mjs';
|
|
9
|
+
import { type TAddOptional } from '../../action/_add_optional.mjs';
|
|
10
|
+
import { type TRemoveReadonly } from '../../action/_remove_readonly.mjs';
|
|
11
|
+
import { type TRemoveOptional } from '../../action/_remove_optional.mjs';
|
|
6
12
|
import { type TTupleElementsToProperties } from '../tuple/to_object.mjs';
|
|
7
|
-
import { type
|
|
8
|
-
|
|
13
|
+
import { type TEvaluateIntersect } from './evaluate.mjs';
|
|
14
|
+
/** Returns true if the type is a valid operand to Composite. */
|
|
15
|
+
export type TCanComposite<Type extends TSchema> = (Type extends TObject<infer _ extends TProperties> ? true : Type extends TTuple<infer _ extends TSchema[]> ? true : false);
|
|
16
|
+
/** Returns true if the type is a valid operand to Composite. */
|
|
17
|
+
export declare function CanComposite<Type extends TSchema>(type: Type): TCanComposite<Type>;
|
|
18
|
+
type TIsReadonlyProperty<Left extends TSchema, Right extends TSchema> = (Left extends TReadonly<Left> ? Right extends TReadonly<Right> ? true : false : false);
|
|
19
|
+
type TIsOptionalProperty<Left extends TSchema, Right extends TSchema> = (Left extends TOptional<Left> ? Right extends TOptional<Right> ? true : false : false);
|
|
20
|
+
type TCompositeProperty<Left extends TSchema, Right extends TSchema, IsReadonly extends boolean = TIsReadonlyProperty<Left, Right>, IsOptional extends boolean = TIsOptionalProperty<Left, Right>, Evaluated extends TSchema = TEvaluateIntersect<[Left, Right]>, Property extends TSchema = TRemoveReadonly<TRemoveOptional<Evaluated>>> = ([
|
|
21
|
+
IsReadonly,
|
|
22
|
+
IsOptional
|
|
23
|
+
] extends [true, true] ? TAddReadonly<TAddOptional<Property>> : [
|
|
24
|
+
IsReadonly,
|
|
25
|
+
IsOptional
|
|
26
|
+
] extends [true, false] ? TAddReadonly<Property> : [
|
|
27
|
+
IsReadonly,
|
|
28
|
+
IsOptional
|
|
29
|
+
] extends [false, true] ? TAddOptional<Property> : Property);
|
|
30
|
+
type TCompositePropertyKey<Left extends TProperties, Right extends TProperties, Key extends PropertyKey, Result extends TSchema = (Key extends keyof Left ? Key extends keyof Right ? TCompositeProperty<Left[Key], Right[Key]> : Left[Key] : Key extends keyof Right ? Right[Key] : TNever)> = Result;
|
|
9
31
|
type TCompositeProperties<Left extends TProperties, Right extends TProperties, Keys extends PropertyKey = keyof (Left & Right), Result extends TProperties = {
|
|
10
32
|
[Key in Keys]: TCompositePropertyKey<Left, Right, Key>;
|
|
11
33
|
}> = Result;
|