@openclaw/firecrawl-plugin 2026.10.10 → 2026.11.5-beta.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.
Files changed (89) hide show
  1. package/dist/.setup/{firecrawl-client-Dk_bi5M_.mjs → firecrawl-client-CDyLQvtN.mjs} +97 -140
  2. package/dist/.setup/{firecrawl-fetch-provider-EP1XFhDE.mjs → firecrawl-fetch-provider-QmPccHZS.mjs} +4 -9
  3. package/dist/.setup/{firecrawl-search-provider-Dg-_xx_m.mjs → firecrawl-search-provider-wsRgx6kl.mjs} +6 -17
  4. package/dist/.source-module-urls/ad8205c790d921269d4ea28d22ab658579b9674fd00e025664fcf0b8ea32155c.json +1 -1
  5. package/dist/api.js +1 -1
  6. package/dist/index.js +69 -87
  7. package/dist/web-fetch-contract-api.js +1 -1
  8. package/dist/web-fetch-provider.js +1 -1
  9. package/dist/web-search-contract-api.js +1 -1
  10. package/dist/web-search-provider.js +1 -1
  11. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  12. package/node_modules/typebox/build/format/duration.mjs +2 -2
  13. package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
  14. package/node_modules/typebox/build/format/idn_email.mjs +1 -0
  15. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  16. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  17. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  18. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  19. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  20. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  21. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  22. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  23. package/node_modules/typebox/build/schema/build.mjs +1 -0
  24. package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
  25. package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
  26. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  27. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
  28. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
  29. package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
  30. package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
  31. package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
  32. package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
  33. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
  34. package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
  35. package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
  36. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
  37. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
  38. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
  39. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
  40. package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
  41. package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
  42. package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
  43. package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
  44. package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
  45. package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
  46. package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
  47. package/node_modules/typebox/build/system/memory/create.mjs +18 -13
  48. package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
  49. package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
  50. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  51. package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
  52. package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
  53. package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
  54. package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
  55. package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
  56. package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
  57. package/node_modules/typebox/build/system/memory/update.mjs +43 -16
  58. package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
  59. package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
  60. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
  61. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
  62. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
  63. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
  64. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
  65. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
  66. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
  67. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
  68. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
  69. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
  70. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  71. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  72. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  73. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  74. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
  75. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
  76. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
  77. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
  78. package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
  79. package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
  80. package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
  81. package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
  82. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
  83. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
  84. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
  85. package/node_modules/typebox/package.json +1 -1
  86. package/node_modules/typebox/readme.md +1 -1
  87. package/package.json +5 -5
  88. package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
  89. package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
@@ -1,14 +1,8 @@
1
1
  type ObjectLike = Record<PropertyKey, any>;
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
- */
2
+ /** Performs an Object assign using the Left and Right object types. */
6
3
  export type TAssign<Left extends ObjectLike, Right extends ObjectLike, Assigned extends ObjectLike = Omit<Left, keyof Right> & Right> = {
7
4
  [Key in keyof Assigned]: Assigned[Key];
8
5
  } & {};
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
- */
6
+ /** Performs an Object assign using the Left and Right object types. */
13
7
  export declare function Assign<Left extends ObjectLike, Right extends ObjectLike>(left: Left, right: Right): TAssign<Left, Right>;
14
8
  export {};
@@ -1,12 +1,19 @@
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 { 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
- */
4
+ import { Finalize } from './finalize.mjs';
5
+ import { Keys } from './keys.mjs';
6
+ /** Performs an Object assign using the Left and Right object types. */
9
7
  export function Assign(left, right) {
10
8
  Metrics.assign += 1;
11
- return Freeze({ ...left, ...right });
9
+ const result = {}, rightKeys = Keys(right), leftKeys = Keys(left);
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);
12
19
  }
@@ -1,5 +1,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
+ type ObjectLike = Record<PropertyKey, any>;
2
+ /** Returns a shallow clone of the given object. */
3
+ export declare function Clone<Value extends ObjectLike = ObjectLike>(value: Value): Value;
4
+ export {};
@@ -1,34 +1,19 @@
1
+ // deno-lint-ignore-file no-explicit-any
1
2
  // deno-fmt-ignore-file
2
- import { Guard, GlobalsGuard } from '../../guard/index.mjs';
3
+ import { Guard } from '../../guard/index.mjs';
3
4
  import { Metrics } from './metrics.mjs';
5
+ import { Keys } from './keys.mjs';
4
6
  // ------------------------------------------------------------------
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
- //
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.
7
+ // Clone
20
8
  // ------------------------------------------------------------------
21
- function IsSchemaObject(value) {
22
- return (Guard.HasPropertyKey(value, '~kind') ||
23
- Guard.HasPropertyKey(value, '~unsafe'));
24
- }
25
- function FromSchemaObject(value) {
9
+ /** Returns a shallow clone of the given object. */
10
+ export function Clone(value) {
11
+ Metrics.clone += 1;
26
12
  const result = {};
27
- for (const key of Guard.Keys(value)) {
13
+ for (const key of Keys(value)) {
28
14
  if (Guard.IsUnsafePropertyKey(key))
29
15
  continue; // (ignore: prototype-pollution)
30
16
  const descriptor = Object.getOwnPropertyDescriptor(value, key); // safe-name!
31
- descriptor.value = FromValue(descriptor.value);
32
17
  if (Guard.IsEqual(descriptor.enumerable, true)) {
33
18
  result[key] = descriptor.value;
34
19
  }
@@ -38,76 +23,3 @@ function FromSchemaObject(value) {
38
23
  }
39
24
  return result;
40
25
  }
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,8 +1,4 @@
1
1
  type ObjectLike = Record<PropertyKey, any>;
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
- */
2
+ /** Creates an object with hidden, enumerable, and optional property sets. */
7
3
  export declare function Create(hidden: ObjectLike, enumerable: ObjectLike, options?: ObjectLike): ObjectLike;
8
4
  export {};
@@ -1,8 +1,17 @@
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 { Freeze } from './freeze.mjs';
5
- function MergeHidden(left, right) {
4
+ import { Finalize } from './finalize.mjs';
5
+ // ------------------------------------------------------------------
6
+ // WithEnumerable
7
+ // ------------------------------------------------------------------
8
+ function WithEnumerable(left, right) {
9
+ return { ...left, ...right };
10
+ }
11
+ // ------------------------------------------------------------------
12
+ // WithHidden
13
+ // ------------------------------------------------------------------
14
+ function WithHidden(left, right) {
6
15
  for (const key of Object.keys(right)) {
7
16
  Object.defineProperty(left, key, {
8
17
  configurable: true,
@@ -13,17 +22,13 @@ function MergeHidden(left, right) {
13
22
  }
14
23
  return left;
15
24
  }
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
- */
25
+ // ------------------------------------------------------------------
26
+ // Create
27
+ // ------------------------------------------------------------------
28
+ /** Creates an object with hidden, enumerable, and optional property sets. */
24
29
  export function Create(hidden, enumerable, options = {}) {
25
30
  Metrics.create += 1;
26
- const withOptions = Merge(enumerable, options);
27
- const withHidden = Settings.Get().enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);
28
- return Freeze(withHidden);
31
+ const withEnumerable = WithEnumerable(enumerable, options);
32
+ const withHidden = Settings.Get().enumerableKind ? WithEnumerable(withEnumerable, hidden) : WithHidden(withEnumerable, hidden);
33
+ return Finalize(withHidden);
29
34
  }
@@ -0,0 +1,2 @@
1
+ /** Returns a deep Clone of the given value. This function is similar to structuredClone() but also supports deep cloning instances of Map, Set and TypeArray. */
2
+ export declare function Deep<Value extends unknown = unknown>(value: Value): Value;
@@ -0,0 +1,108 @@
1
+ // deno-fmt-ignore-file
2
+ import { Guard, GlobalsGuard } from '../../guard/index.mjs';
3
+ // ------------------------------------------------------------------
4
+ // ClassInstance
5
+ //
6
+ // TypeBox does not clone arbitrary class instances. Class instances
7
+ // cannot be safely cloned without potentially breaking private
8
+ // members of the instance.
9
+ //
10
+ // ------------------------------------------------------------------
11
+ function FromClassInstance(value) {
12
+ return value; // atomic
13
+ }
14
+ // ------------------------------------------------------------------
15
+ // SchemaObject
16
+ //
17
+ // Schema objects have non-enumerable properties that MUST be preserved
18
+ // on Clone. The following is the optimal path these objects.
19
+ // ------------------------------------------------------------------
20
+ function IsSchemaObject(value) {
21
+ return (Guard.HasPropertyKey(value, '~kind') ||
22
+ Guard.HasPropertyKey(value, '~unsafe'));
23
+ }
24
+ function FromSchemaObject(value) {
25
+ const result = {};
26
+ for (const key of Guard.Keys(value)) {
27
+ if (Guard.IsUnsafePropertyKey(key))
28
+ continue; // (ignore: prototype-pollution)
29
+ const descriptor = Object.getOwnPropertyDescriptor(value, key); // safe-name!
30
+ descriptor.value = FromValue(descriptor.value);
31
+ if (Guard.IsEqual(descriptor.enumerable, true)) {
32
+ result[key] = descriptor.value;
33
+ }
34
+ else {
35
+ Object.defineProperty(result, key, descriptor);
36
+ }
37
+ }
38
+ return result;
39
+ }
40
+ // ------------------------------------------------------------------
41
+ // PlainObject
42
+ // ------------------------------------------------------------------
43
+ function FromPlainObject(value) {
44
+ const result = {};
45
+ for (const key of Guard.Keys(value)) {
46
+ if (Guard.IsUnsafePropertyKey(key))
47
+ continue; // (ignore: prototype-pollution)
48
+ result[key] = FromValue(value[key]);
49
+ }
50
+ for (const key of Guard.Symbols(value)) {
51
+ result[key] = FromValue(value[key]);
52
+ }
53
+ return result;
54
+ }
55
+ // ------------------------------------------------------------------
56
+ // Object
57
+ // ------------------------------------------------------------------
58
+ function FromObject(value) {
59
+ return (Guard.IsClassInstance(value) ? FromClassInstance(value) :
60
+ IsSchemaObject(value) ? FromSchemaObject(value) :
61
+ FromPlainObject(value));
62
+ }
63
+ // ------------------------------------------------------------------
64
+ // Array
65
+ // ------------------------------------------------------------------
66
+ function FromArray(value) {
67
+ return value.map((element) => FromValue(element));
68
+ }
69
+ // ------------------------------------------------------------------
70
+ // TypeArray
71
+ // ------------------------------------------------------------------
72
+ function FromTypedArray(value) {
73
+ return value.slice();
74
+ }
75
+ // ------------------------------------------------------------------
76
+ // RegExp
77
+ // ------------------------------------------------------------------
78
+ function FromRegExp(value) {
79
+ return new RegExp(value.source, value.flags);
80
+ }
81
+ // ------------------------------------------------------------------
82
+ // Map
83
+ // ------------------------------------------------------------------
84
+ function FromMap(value) {
85
+ return new Map(FromValue([...value.entries()]));
86
+ }
87
+ // ------------------------------------------------------------------
88
+ // Set
89
+ // ------------------------------------------------------------------
90
+ function FromSet(value) {
91
+ return new Set(FromValue([...value.values()]));
92
+ }
93
+ function FromValue(value) {
94
+ return (GlobalsGuard.IsTypeArray(value) ? FromTypedArray(value) :
95
+ GlobalsGuard.IsRegExp(value) ? FromRegExp(value) :
96
+ GlobalsGuard.IsMap(value) ? FromMap(value) :
97
+ GlobalsGuard.IsSet(value) ? FromSet(value) :
98
+ Guard.IsArray(value) ? FromArray(value) :
99
+ Guard.IsObject(value) ? FromObject(value) :
100
+ value);
101
+ }
102
+ // ------------------------------------------------------------------
103
+ // Deep
104
+ // ------------------------------------------------------------------
105
+ /** Returns a deep Clone of the given value. This function is similar to structuredClone() but also supports deep cloning instances of Map, Set and TypeArray. */
106
+ export function Deep(value) {
107
+ return FromValue(value);
108
+ }
@@ -1,4 +1,4 @@
1
1
  type ObjectLike = Record<PropertyKey, any>;
2
- /** Discards multiple property keys from the given object value */
2
+ /** Discards property keys from the given object. */
3
3
  export declare function Discard(value: ObjectLike, propertyKeys: PropertyKey[]): ObjectLike;
4
4
  export {};
@@ -1,18 +1,19 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- import { Guard } from '../../guard/index.mjs';
3
2
  import { Metrics } from './metrics.mjs';
4
- import { Freeze } from './freeze.mjs';
5
- import { Clone } from './clone.mjs';
6
- /** Discards multiple property keys from the given object value */
3
+ import { Finalize } from './finalize.mjs';
4
+ import { Keys } from './keys.mjs';
5
+ // ------------------------------------------------------------------
6
+ // Discard
7
+ // ------------------------------------------------------------------
8
+ /** Discards property keys from the given object. */
7
9
  export function Discard(value, propertyKeys) {
8
10
  Metrics.discard += 1;
9
11
  const result = {};
10
- for (const key of Guard.Keys(value)) {
12
+ for (const key of Keys(value)) {
11
13
  if (propertyKeys.includes(key))
12
14
  continue;
13
- const descriptor = Object.getOwnPropertyDescriptor(value, key); // safe-name!
14
- descriptor.value = Clone(descriptor.value);
15
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
15
16
  Object.defineProperty(result, key, descriptor);
16
17
  }
17
- return Freeze(result);
18
+ return Finalize(result);
18
19
  }
@@ -0,0 +1,4 @@
1
+ type ObjectLike = Record<PropertyKey, any>;
2
+ /** Finalizes a type. Will recursively freeze if `immutableTypes` is true, otherwise no action. */
3
+ export declare function Finalize(value: ObjectLike): ObjectLike;
4
+ export {};
@@ -0,0 +1,30 @@
1
+ // deno-lint-ignore-file no-explicit-any
2
+ import { Guard } from '../../guard/index.mjs';
3
+ import { Settings } from '../settings/index.mjs';
4
+ import { Keys } from './keys.mjs';
5
+ // ------------------------------------------------------------------
6
+ // Freeze
7
+ // ------------------------------------------------------------------
8
+ function Freeze(value, seen) {
9
+ if (seen.has(value))
10
+ return;
11
+ seen.add(value);
12
+ for (const key of Keys(value)) {
13
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
14
+ if (!descriptor || !('value' in descriptor))
15
+ continue;
16
+ if (Guard.IsObject(descriptor.value))
17
+ Freeze(descriptor.value, seen);
18
+ }
19
+ Object.freeze(value);
20
+ }
21
+ // ------------------------------------------------------------------
22
+ // Finalize
23
+ // ------------------------------------------------------------------
24
+ /** Finalizes a type. Will recursively freeze if `immutableTypes` is true, otherwise no action. */
25
+ export function Finalize(value) {
26
+ if (!Settings.Get().immutableTypes)
27
+ return value;
28
+ Freeze(value, new WeakSet());
29
+ return value;
30
+ }
@@ -0,0 +1,2 @@
1
+ /** Returns the own string and symbol keys of the given object. */
2
+ export declare function Keys(value: Record<PropertyKey, unknown>): PropertyKey[];
@@ -0,0 +1,8 @@
1
+ import { Guard } from '../../guard/index.mjs';
2
+ // ------------------------------------------------------------------
3
+ // Keys (alternatively, Reflect.ownKeys(...))
4
+ // ------------------------------------------------------------------
5
+ /** Returns the own string and symbol keys of the given object. */
6
+ export function Keys(value) {
7
+ return [...Guard.Keys(value), ...Guard.Symbols(value)];
8
+ }
@@ -1,7 +1,4 @@
1
1
  type ObjectLike = Record<PropertyKey, any>;
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
- */
2
+ /** Updates an existing type with additional hidden and enumerable properties while preserving property configuration. */
6
3
  export declare function Update(current: ObjectLike, hidden: ObjectLike, enumerable: ObjectLike): ObjectLike;
7
4
  export {};
@@ -1,27 +1,43 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
+ import { Guard } from '../../guard/index.mjs';
2
3
  import { Settings } from '../settings/index.mjs';
3
4
  import { Metrics } from './metrics.mjs';
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)) {
5
+ import { Finalize } from './finalize.mjs';
6
+ import { Keys } from './keys.mjs';
7
+ // ------------------------------------------------------------------
8
+ // WithCurrent
9
+ // ------------------------------------------------------------------
10
+ function WithCurrent(current, hiddenKeys, enumerableKeys, result) {
11
+ for (const key of Keys(current)) {
12
+ if (Guard.IsUnsafePropertyKey(key) || hiddenKeys.includes(key) || enumerableKeys.includes(key))
13
+ continue; // (ignore: prototype-pollution)
14
+ const descriptor = Object.getOwnPropertyDescriptor(current, key); // safe-name!
15
+ Object.defineProperty(result, key, descriptor);
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)
16
26
  Object.defineProperty(result, key, {
17
27
  configurable: true,
18
28
  writable: true,
19
- enumerable: settings.enumerableKind,
29
+ enumerable: enumerableKind,
20
30
  value: hidden[key]
21
31
  });
22
32
  }
23
- // enumerable
24
- for (const key of Object.keys(enumerable)) {
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)
25
41
  Object.defineProperty(result, key, {
26
42
  configurable: true,
27
43
  enumerable: true,
@@ -29,5 +45,16 @@ export function Update(current, hidden, enumerable) {
29
45
  value: enumerable[key]
30
46
  });
31
47
  }
32
- return Freeze(result);
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);
33
60
  }
@@ -0,0 +1 @@
1
+ export * from './instantiate.mjs';
@@ -0,0 +1 @@
1
+ export * from './instantiate.mjs';
@@ -1,33 +1,11 @@
1
- import { type TReadonly } from '../../types/_readonly.mjs';
2
- import { type TOptional } from '../../types/_optional.mjs';
3
1
  import { type TSchema } from '../../types/schema.mjs';
4
2
  import { type TProperties } from '../../types/properties.mjs';
5
3
  import { type TObject } from '../../types/object.mjs';
6
4
  import { type TNever } from '../../types/never.mjs';
7
5
  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';
12
6
  import { type TTupleElementsToProperties } from '../tuple/to_object.mjs';
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;
7
+ import { type TEvaluatePropertyIntersect } from './property.mjs';
8
+ type TCompositePropertyKey<Left extends TProperties, Right extends TProperties, Key extends PropertyKey, Result extends TSchema = (Key extends keyof Left ? Key extends keyof Right ? TEvaluatePropertyIntersect<Left[Key], Right[Key]> : Left[Key] : Key extends keyof Right ? Right[Key] : TNever)> = Result;
31
9
  type TCompositeProperties<Left extends TProperties, Right extends TProperties, Keys extends PropertyKey = keyof (Left & Right), Result extends TProperties = {
32
10
  [Key in Keys]: TCompositePropertyKey<Left, Right, Key>;
33
11
  }> = Result;
@@ -1,41 +1,14 @@
1
1
  // deno-fmt-ignore-file
2
2
  // deno-lint-ignore-file
3
3
  import { Guard } from '../../../guard/index.mjs';
4
- import { IsReadonly } from '../../types/_readonly.mjs';
5
- import { IsOptional } from '../../types/_optional.mjs';
6
4
  import { Object, IsObject } from '../../types/object.mjs';
7
5
  import { Never } from '../../types/never.mjs';
8
6
  import { IsTuple } from '../../types/tuple.mjs';
9
- import { AddReadonly } from '../../action/_add_readonly.mjs';
10
- import { AddOptional } from '../../action/_add_optional.mjs';
11
- import { RemoveReadonly } from '../../action/_remove_readonly.mjs';
12
- import { RemoveOptional } from '../../action/_remove_optional.mjs';
13
7
  import { TupleElementsToProperties } from '../tuple/to_object.mjs';
14
- import { EvaluateIntersect } from './evaluate.mjs';
15
- /** Returns true if the type is a valid operand to Composite. */
16
- export function CanComposite(type) {
17
- return (IsObject(type) || IsTuple(type));
18
- }
19
- function IsReadonlyProperty(left, right) {
20
- return (IsReadonly(left) ? IsReadonly(right) ? true : false : false);
21
- }
22
- function IsOptionalProperty(left, right) {
23
- return (IsOptional(left) ? IsOptional(right) ? true : false : false);
24
- }
25
- function CompositeProperty(left, right) {
26
- const isReadonly = IsReadonlyProperty(left, right);
27
- const isOptional = IsOptionalProperty(left, right);
28
- const evaluated = EvaluateIntersect([left, right]);
29
- // Modifiers need to be discarded and re-applied
30
- const property = RemoveReadonly(RemoveOptional(evaluated));
31
- return (isReadonly && isOptional ? AddReadonly(AddOptional(property)) :
32
- isReadonly && !isOptional ? AddReadonly(property) :
33
- !isReadonly && isOptional ? AddOptional(property) :
34
- property);
35
- }
8
+ import { EvaluatePropertyIntersect } from './property.mjs';
36
9
  function CompositePropertyKey(left, right, key) {
37
10
  return (key in left
38
- ? key in right ? CompositeProperty(left[key], right[key]) : left[key]
11
+ ? key in right ? EvaluatePropertyIntersect(left[key], right[key]) : left[key]
39
12
  : key in right ? right[key] : Never());
40
13
  }
41
14
  function CompositeProperties(left, right) {
@@ -6,3 +6,4 @@ export * from './evaluate.mjs';
6
6
  export * from './flatten.mjs';
7
7
  export * from './instantiate.mjs';
8
8
  export * from './narrow.mjs';
9
+ export * from './property.mjs';
@@ -6,3 +6,4 @@ export * from './evaluate.mjs';
6
6
  export * from './flatten.mjs';
7
7
  export * from './instantiate.mjs';
8
8
  export * from './narrow.mjs';
9
+ export * from './property.mjs';
@@ -1,10 +1,14 @@
1
1
  import { type TSchema } from '../../types/schema.mjs';
2
+ import { type TProperties } from '../../types/properties.mjs';
3
+ import { type TObject } from '../../types/object.mjs';
2
4
  import { type TAny } from '../../types/any.mjs';
3
5
  import { type TNever } from '../../types/never.mjs';
6
+ import { type TTuple } from '../../types/tuple.mjs';
4
7
  import { type TUnknown } from '../../types/unknown.mjs';
5
8
  import { type TCompare, type TCompareResult, CompareResultLeftInside, CompareResultRightInside, CompareResultEqual } from './compare.mjs';
6
- import { type TComposite, type TCanComposite } from './composite.mjs';
9
+ import { type TComposite } from './composite.mjs';
7
10
  type TNarrowCompareRule<Left extends TSchema, Right extends TSchema, Result extends TCompareResult = TCompare<Left, Right>> = (Result extends typeof CompareResultLeftInside ? Left : Result extends typeof CompareResultRightInside ? Right : Result extends typeof CompareResultEqual ? Right : TNever);
11
+ type TCanComposite<Type extends TSchema> = (Type extends TObject<infer _ extends TProperties> ? true : Type extends TTuple<infer _ extends TSchema[]> ? true : false);
8
12
  type TNarrowCompositeRule<Left extends TSchema, Right extends TSchema, CanCompositeLeft extends boolean = TCanComposite<Left>, CanCompositeRight extends boolean = TCanComposite<Right>> = ([
9
13
  CanCompositeLeft,
10
14
  CanCompositeRight