@hyperfrontend/immutable-api-utils 0.0.2 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +66 -4
- package/built-in-copy/array/index.cjs.js +40 -0
- package/built-in-copy/array/index.cjs.js.map +1 -0
- package/built-in-copy/array/index.d.ts +40 -0
- package/built-in-copy/array/index.d.ts.map +1 -0
- package/built-in-copy/array/index.esm.js +35 -0
- package/built-in-copy/array/index.esm.js.map +1 -0
- package/built-in-copy/console/index.cjs.js +130 -0
- package/built-in-copy/console/index.cjs.js.map +1 -0
- package/built-in-copy/console/index.d.ts +105 -0
- package/built-in-copy/console/index.d.ts.map +1 -0
- package/built-in-copy/console/index.esm.js +110 -0
- package/built-in-copy/console/index.esm.js.map +1 -0
- package/built-in-copy/date/index.cjs.js +49 -0
- package/built-in-copy/date/index.cjs.js.map +1 -0
- package/built-in-copy/date/index.d.ts +49 -0
- package/built-in-copy/date/index.d.ts.map +1 -0
- package/built-in-copy/date/index.esm.js +43 -0
- package/built-in-copy/date/index.esm.js.map +1 -0
- package/built-in-copy/encoding/index.cjs.js +67 -0
- package/built-in-copy/encoding/index.cjs.js.map +1 -0
- package/built-in-copy/encoding/index.d.ts +52 -0
- package/built-in-copy/encoding/index.d.ts.map +1 -0
- package/built-in-copy/encoding/index.esm.js +61 -0
- package/built-in-copy/encoding/index.esm.js.map +1 -0
- package/built-in-copy/error/index.cjs.js +122 -0
- package/built-in-copy/error/index.cjs.js.map +1 -0
- package/built-in-copy/error/index.d.ts +99 -0
- package/built-in-copy/error/index.d.ts.map +1 -0
- package/built-in-copy/error/index.esm.js +112 -0
- package/built-in-copy/error/index.esm.js.map +1 -0
- package/built-in-copy/function/index.cjs.js +61 -0
- package/built-in-copy/function/index.cjs.js.map +1 -0
- package/built-in-copy/function/index.d.ts +47 -0
- package/built-in-copy/function/index.d.ts.map +1 -0
- package/built-in-copy/function/index.esm.js +54 -0
- package/built-in-copy/function/index.esm.js.map +1 -0
- package/built-in-copy/json/index.cjs.js +34 -0
- package/built-in-copy/json/index.cjs.js.map +1 -0
- package/built-in-copy/json/index.d.ts +31 -0
- package/built-in-copy/json/index.d.ts.map +1 -0
- package/built-in-copy/json/index.esm.js +30 -0
- package/built-in-copy/json/index.esm.js.map +1 -0
- package/built-in-copy/map/index.cjs.js +44 -0
- package/built-in-copy/map/index.cjs.js.map +1 -0
- package/built-in-copy/map/index.d.ts +33 -0
- package/built-in-copy/map/index.d.ts.map +1 -0
- package/built-in-copy/map/index.esm.js +40 -0
- package/built-in-copy/map/index.esm.js.map +1 -0
- package/built-in-copy/math/index.cjs.js +317 -0
- package/built-in-copy/math/index.cjs.js.map +1 -0
- package/built-in-copy/math/index.d.ts +232 -0
- package/built-in-copy/math/index.d.ts.map +1 -0
- package/built-in-copy/math/index.esm.js +272 -0
- package/built-in-copy/math/index.esm.js.map +1 -0
- package/built-in-copy/messaging/index.cjs.js +123 -0
- package/built-in-copy/messaging/index.cjs.js.map +1 -0
- package/built-in-copy/messaging/index.d.ts +95 -0
- package/built-in-copy/messaging/index.d.ts.map +1 -0
- package/built-in-copy/messaging/index.esm.js +114 -0
- package/built-in-copy/messaging/index.esm.js.map +1 -0
- package/built-in-copy/number/index.cjs.js +141 -0
- package/built-in-copy/number/index.cjs.js.map +1 -0
- package/built-in-copy/number/index.d.ts +95 -0
- package/built-in-copy/number/index.d.ts.map +1 -0
- package/built-in-copy/number/index.esm.js +123 -0
- package/built-in-copy/number/index.esm.js.map +1 -0
- package/built-in-copy/object/index.cjs.js +174 -0
- package/built-in-copy/object/index.cjs.js.map +1 -0
- package/built-in-copy/object/index.d.ts +209 -0
- package/built-in-copy/object/index.d.ts.map +1 -0
- package/built-in-copy/object/index.esm.js +149 -0
- package/built-in-copy/object/index.esm.js.map +1 -0
- package/built-in-copy/promise/index.cjs.js +80 -0
- package/built-in-copy/promise/index.cjs.js.map +1 -0
- package/built-in-copy/promise/index.d.ts +63 -0
- package/built-in-copy/promise/index.d.ts.map +1 -0
- package/built-in-copy/promise/index.esm.js +70 -0
- package/built-in-copy/promise/index.esm.js.map +1 -0
- package/built-in-copy/reflect/index.cjs.js +101 -0
- package/built-in-copy/reflect/index.cjs.js.map +1 -0
- package/built-in-copy/reflect/index.d.ts +81 -0
- package/built-in-copy/reflect/index.d.ts.map +1 -0
- package/built-in-copy/reflect/index.esm.js +86 -0
- package/built-in-copy/reflect/index.esm.js.map +1 -0
- package/built-in-copy/regexp/index.cjs.js +37 -0
- package/built-in-copy/regexp/index.cjs.js.map +1 -0
- package/built-in-copy/regexp/index.d.ts +28 -0
- package/built-in-copy/regexp/index.d.ts.map +1 -0
- package/built-in-copy/regexp/index.esm.js +34 -0
- package/built-in-copy/regexp/index.esm.js.map +1 -0
- package/built-in-copy/set/index.cjs.js +36 -0
- package/built-in-copy/set/index.cjs.js.map +1 -0
- package/built-in-copy/set/index.d.ts +27 -0
- package/built-in-copy/set/index.d.ts.map +1 -0
- package/built-in-copy/set/index.esm.js +33 -0
- package/built-in-copy/set/index.esm.js.map +1 -0
- package/built-in-copy/string/index.cjs.js +46 -0
- package/built-in-copy/string/index.cjs.js.map +1 -0
- package/built-in-copy/string/index.d.ts +34 -0
- package/built-in-copy/string/index.d.ts.map +1 -0
- package/built-in-copy/string/index.esm.js +41 -0
- package/built-in-copy/string/index.esm.js.map +1 -0
- package/built-in-copy/symbol/index.cjs.js +123 -0
- package/built-in-copy/symbol/index.cjs.js.map +1 -0
- package/built-in-copy/symbol/index.d.ts +99 -0
- package/built-in-copy/symbol/index.d.ts.map +1 -0
- package/built-in-copy/symbol/index.esm.js +105 -0
- package/built-in-copy/symbol/index.esm.js.map +1 -0
- package/built-in-copy/timers/index.cjs.js +105 -0
- package/built-in-copy/timers/index.cjs.js.map +1 -0
- package/built-in-copy/timers/index.d.ts +73 -0
- package/built-in-copy/timers/index.d.ts.map +1 -0
- package/built-in-copy/timers/index.esm.js +96 -0
- package/built-in-copy/timers/index.esm.js.map +1 -0
- package/built-in-copy/typed-arrays/index.cjs.js +360 -0
- package/built-in-copy/typed-arrays/index.cjs.js.map +1 -0
- package/built-in-copy/typed-arrays/index.d.ts +321 -0
- package/built-in-copy/typed-arrays/index.d.ts.map +1 -0
- package/built-in-copy/typed-arrays/index.esm.js +321 -0
- package/built-in-copy/typed-arrays/index.esm.js.map +1 -0
- package/built-in-copy/url/index.cjs.js +103 -0
- package/built-in-copy/url/index.cjs.js.map +1 -0
- package/built-in-copy/url/index.d.ts +71 -0
- package/built-in-copy/url/index.d.ts.map +1 -0
- package/built-in-copy/url/index.esm.js +95 -0
- package/built-in-copy/url/index.esm.js.map +1 -0
- package/built-in-copy/weak-map/index.cjs.js +36 -0
- package/built-in-copy/weak-map/index.cjs.js.map +1 -0
- package/built-in-copy/weak-map/index.d.ts +27 -0
- package/built-in-copy/weak-map/index.d.ts.map +1 -0
- package/built-in-copy/weak-map/index.esm.js +33 -0
- package/built-in-copy/weak-map/index.esm.js.map +1 -0
- package/built-in-copy/weak-set/index.cjs.js +36 -0
- package/built-in-copy/weak-set/index.cjs.js.map +1 -0
- package/built-in-copy/weak-set/index.d.ts +27 -0
- package/built-in-copy/weak-set/index.d.ts.map +1 -0
- package/built-in-copy/weak-set/index.esm.js +33 -0
- package/built-in-copy/weak-set/index.esm.js.map +1 -0
- package/built-in-copy/websocket/index.cjs.js +50 -0
- package/built-in-copy/websocket/index.cjs.js.map +1 -0
- package/built-in-copy/websocket/index.d.ts +37 -0
- package/built-in-copy/websocket/index.d.ts.map +1 -0
- package/built-in-copy/websocket/index.esm.js +43 -0
- package/built-in-copy/websocket/index.esm.js.map +1 -0
- package/bundle/index.iife.js +1167 -5
- package/bundle/index.iife.js.map +1 -1
- package/bundle/index.iife.min.js +1 -1
- package/bundle/index.iife.min.js.map +1 -1
- package/bundle/index.umd.js +1167 -5
- package/bundle/index.umd.js.map +1 -1
- package/bundle/index.umd.min.js +1 -1
- package/bundle/index.umd.min.js.map +1 -1
- package/index.cjs.js +1167 -5
- package/index.cjs.js.map +1 -1
- package/index.d.ts +32 -3
- package/index.d.ts.map +1 -1
- package/index.esm.js +1151 -6
- package/index.esm.js.map +1 -1
- package/lib/locked-prop-descriptors.d.ts.map +1 -0
- package/lib/locked-props.d.ts.map +1 -0
- package/{locked.d.ts → lib/locked.d.ts} +12 -1
- package/lib/locked.d.ts.map +1 -0
- package/locked/index.cjs.js +107 -0
- package/locked/index.cjs.js.map +1 -0
- package/locked/index.d.ts +2 -0
- package/locked/index.d.ts.map +1 -0
- package/locked/index.esm.js +105 -0
- package/locked/index.esm.js.map +1 -0
- package/locked-prop-descriptors/index.cjs.js +11 -0
- package/locked-prop-descriptors/index.cjs.js.map +1 -0
- package/locked-prop-descriptors/index.d.ts +2 -0
- package/locked-prop-descriptors/index.d.ts.map +1 -0
- package/locked-prop-descriptors/index.esm.js +9 -0
- package/locked-prop-descriptors/index.esm.js.map +1 -0
- package/locked-props/index.cjs.js +32 -0
- package/locked-props/index.cjs.js.map +1 -0
- package/locked-props/index.d.ts +2 -0
- package/locked-props/index.d.ts.map +1 -0
- package/locked-props/index.esm.js +30 -0
- package/locked-props/index.esm.js.map +1 -0
- package/package.json +149 -14
- package/locked-prop-descriptors.d.ts.map +0 -1
- package/locked-props.d.ts.map +0 -1
- package/locked.d.ts.map +0 -1
- /package/{locked-prop-descriptors.d.ts → lib/locked-prop-descriptors.d.ts} +0 -0
- /package/{locked-props.d.ts → lib/locked-props.d.ts} +0 -0
package/bundle/index.iife.js
CHANGED
|
@@ -1,10 +1,1143 @@
|
|
|
1
1
|
var HyperfrontendImmutableApiUtils = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Safe copies of Array built-in static methods.
|
|
6
|
+
*
|
|
7
|
+
* These references are captured at module initialization time to protect against
|
|
8
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
9
|
+
*
|
|
10
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
11
|
+
*/
|
|
12
|
+
// Capture references at module initialization time
|
|
13
|
+
const _Array = globalThis.Array;
|
|
14
|
+
const _freeze$f = globalThis.Object.freeze;
|
|
15
|
+
/**
|
|
16
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
17
|
+
*/
|
|
18
|
+
const isArray = _Array.isArray;
|
|
19
|
+
/**
|
|
20
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
21
|
+
*/
|
|
22
|
+
const from = _Array.from;
|
|
23
|
+
/**
|
|
24
|
+
* (Safe copy) Creates a new Array instance from a variable number of arguments.
|
|
25
|
+
*/
|
|
26
|
+
const of = _Array.of;
|
|
27
|
+
/**
|
|
28
|
+
* (Safe copy) Namespace object containing all Array static methods.
|
|
29
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
30
|
+
*/
|
|
31
|
+
const Array = _freeze$f({
|
|
32
|
+
isArray,
|
|
33
|
+
from,
|
|
34
|
+
of,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Safe copies of Console built-in methods.
|
|
39
|
+
*
|
|
40
|
+
* These references are captured at module initialization time to protect against
|
|
41
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
42
|
+
*
|
|
43
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/console
|
|
44
|
+
*/
|
|
45
|
+
// Capture references at module initialization time
|
|
46
|
+
const _console = globalThis.console;
|
|
47
|
+
const _freeze$e = globalThis.Object.freeze;
|
|
48
|
+
/**
|
|
49
|
+
* (Safe copy) Outputs a message to the console.
|
|
50
|
+
*/
|
|
51
|
+
const log = _console.log.bind(_console);
|
|
52
|
+
/**
|
|
53
|
+
* (Safe copy) Outputs a warning message to the console.
|
|
54
|
+
*/
|
|
55
|
+
const warn = _console.warn.bind(_console);
|
|
56
|
+
/**
|
|
57
|
+
* (Safe copy) Outputs an error message to the console.
|
|
58
|
+
*/
|
|
59
|
+
const error = _console.error.bind(_console);
|
|
60
|
+
/**
|
|
61
|
+
* (Safe copy) Outputs an informational message to the console.
|
|
62
|
+
*/
|
|
63
|
+
const info = _console.info.bind(_console);
|
|
64
|
+
/**
|
|
65
|
+
* (Safe copy) Outputs a debug message to the console.
|
|
66
|
+
*/
|
|
67
|
+
const debug = _console.debug.bind(_console);
|
|
68
|
+
/**
|
|
69
|
+
* (Safe copy) Outputs a stack trace to the console.
|
|
70
|
+
*/
|
|
71
|
+
const trace = _console.trace.bind(_console);
|
|
72
|
+
/**
|
|
73
|
+
* (Safe copy) Displays an interactive listing of the properties of a specified object.
|
|
74
|
+
*/
|
|
75
|
+
const dir = _console.dir.bind(_console);
|
|
76
|
+
/**
|
|
77
|
+
* (Safe copy) Displays tabular data as a table.
|
|
78
|
+
*/
|
|
79
|
+
const table = _console.table.bind(_console);
|
|
80
|
+
/**
|
|
81
|
+
* (Safe copy) Writes an error message to the console if the assertion is false.
|
|
82
|
+
*/
|
|
83
|
+
const assert = _console.assert.bind(_console);
|
|
84
|
+
/**
|
|
85
|
+
* (Safe copy) Clears the console.
|
|
86
|
+
*/
|
|
87
|
+
const clear = _console.clear.bind(_console);
|
|
88
|
+
/**
|
|
89
|
+
* (Safe copy) Logs the number of times that this particular call to count() has been called.
|
|
90
|
+
*/
|
|
91
|
+
const count = _console.count.bind(_console);
|
|
92
|
+
/**
|
|
93
|
+
* (Safe copy) Resets the counter used with console.count().
|
|
94
|
+
*/
|
|
95
|
+
const countReset = _console.countReset.bind(_console);
|
|
96
|
+
/**
|
|
97
|
+
* (Safe copy) Creates a new inline group in the console.
|
|
98
|
+
*/
|
|
99
|
+
const group = _console.group.bind(_console);
|
|
100
|
+
/**
|
|
101
|
+
* (Safe copy) Creates a new inline group in the console that is initially collapsed.
|
|
102
|
+
*/
|
|
103
|
+
const groupCollapsed = _console.groupCollapsed.bind(_console);
|
|
104
|
+
/**
|
|
105
|
+
* (Safe copy) Exits the current inline group.
|
|
106
|
+
*/
|
|
107
|
+
const groupEnd = _console.groupEnd.bind(_console);
|
|
108
|
+
/**
|
|
109
|
+
* (Safe copy) Starts a timer with a name specified as an input parameter.
|
|
110
|
+
*/
|
|
111
|
+
const time = _console.time.bind(_console);
|
|
112
|
+
/**
|
|
113
|
+
* (Safe copy) Stops a timer that was previously started.
|
|
114
|
+
*/
|
|
115
|
+
const timeEnd = _console.timeEnd.bind(_console);
|
|
116
|
+
/**
|
|
117
|
+
* (Safe copy) Logs the current value of a timer that was previously started.
|
|
118
|
+
*/
|
|
119
|
+
const timeLog = _console.timeLog.bind(_console);
|
|
120
|
+
/**
|
|
121
|
+
* (Safe copy) Namespace object containing all Console methods.
|
|
122
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
123
|
+
*/
|
|
124
|
+
const Console = _freeze$e({
|
|
125
|
+
log,
|
|
126
|
+
warn,
|
|
127
|
+
error,
|
|
128
|
+
info,
|
|
129
|
+
debug,
|
|
130
|
+
trace,
|
|
131
|
+
dir,
|
|
132
|
+
table,
|
|
133
|
+
assert,
|
|
134
|
+
clear,
|
|
135
|
+
count,
|
|
136
|
+
countReset,
|
|
137
|
+
group,
|
|
138
|
+
groupCollapsed,
|
|
139
|
+
groupEnd,
|
|
140
|
+
time,
|
|
141
|
+
timeEnd,
|
|
142
|
+
timeLog,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Safe copies of Date built-in via factory function and static methods.
|
|
147
|
+
*
|
|
148
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
149
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
150
|
+
*
|
|
151
|
+
* These references are captured at module initialization time to protect against
|
|
152
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
153
|
+
*
|
|
154
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/date
|
|
155
|
+
*/
|
|
156
|
+
// Capture references at module initialization time
|
|
157
|
+
const _Date = globalThis.Date;
|
|
158
|
+
const _Reflect$b = globalThis.Reflect;
|
|
159
|
+
const _freeze$d = globalThis.Object.freeze;
|
|
160
|
+
function createDate(...args) {
|
|
161
|
+
return _Reflect$b.construct(_Date, args);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* (Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
|
|
165
|
+
*/
|
|
166
|
+
const dateNow = _Date.now;
|
|
167
|
+
/**
|
|
168
|
+
* (Safe copy) Parses a string representation of a date.
|
|
169
|
+
*/
|
|
170
|
+
const dateParse = _Date.parse;
|
|
171
|
+
/**
|
|
172
|
+
* (Safe copy) Returns the number of milliseconds in a Date object since January 1, 1970 UTC.
|
|
173
|
+
*/
|
|
174
|
+
const dateUTC = _Date.UTC;
|
|
175
|
+
/**
|
|
176
|
+
* (Safe copy) Namespace object containing Date factory and static methods.
|
|
177
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
178
|
+
*/
|
|
179
|
+
const Date = _freeze$d({
|
|
180
|
+
create: createDate,
|
|
181
|
+
now: dateNow,
|
|
182
|
+
parse: dateParse,
|
|
183
|
+
UTC: dateUTC,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Safe copies of Error built-ins via factory functions.
|
|
188
|
+
*
|
|
189
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
190
|
+
* provides factory functions that use Reflect.construct internally.
|
|
191
|
+
*
|
|
192
|
+
* These references are captured at module initialization time to protect against
|
|
193
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
194
|
+
*
|
|
195
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/error
|
|
196
|
+
*/
|
|
197
|
+
// Capture references at module initialization time
|
|
198
|
+
const _Error = globalThis.Error;
|
|
199
|
+
const _TypeError = globalThis.TypeError;
|
|
200
|
+
const _RangeError = globalThis.RangeError;
|
|
201
|
+
const _ReferenceError = globalThis.ReferenceError;
|
|
202
|
+
const _SyntaxError = globalThis.SyntaxError;
|
|
203
|
+
const _URIError = globalThis.URIError;
|
|
204
|
+
const _EvalError = globalThis.EvalError;
|
|
205
|
+
const _AggregateError = globalThis.AggregateError;
|
|
206
|
+
const _Reflect$a = globalThis.Reflect;
|
|
207
|
+
const _freeze$c = globalThis.Object.freeze;
|
|
208
|
+
/**
|
|
209
|
+
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
210
|
+
* Use this instead of `new Error()`.
|
|
211
|
+
*
|
|
212
|
+
* @param message - Optional error message.
|
|
213
|
+
* @param options - Optional error options.
|
|
214
|
+
* @returns A new Error instance.
|
|
215
|
+
*/
|
|
216
|
+
const createError = (message, options) => _Reflect$a.construct(_Error, [message, options]);
|
|
217
|
+
/**
|
|
218
|
+
* (Safe copy) Creates a new TypeError using the captured TypeError constructor.
|
|
219
|
+
* Use this instead of `new TypeError()`.
|
|
220
|
+
*
|
|
221
|
+
* @param message - Optional error message.
|
|
222
|
+
* @param options - Optional error options.
|
|
223
|
+
* @returns A new TypeError instance.
|
|
224
|
+
*/
|
|
225
|
+
const createTypeError = (message, options) => _Reflect$a.construct(_TypeError, [message, options]);
|
|
226
|
+
/**
|
|
227
|
+
* (Safe copy) Creates a new RangeError using the captured RangeError constructor.
|
|
228
|
+
* Use this instead of `new RangeError()`.
|
|
229
|
+
*
|
|
230
|
+
* @param message - Optional error message.
|
|
231
|
+
* @param options - Optional error options.
|
|
232
|
+
* @returns A new RangeError instance.
|
|
233
|
+
*/
|
|
234
|
+
const createRangeError = (message, options) => _Reflect$a.construct(_RangeError, [message, options]);
|
|
235
|
+
/**
|
|
236
|
+
* (Safe copy) Creates a new ReferenceError using the captured ReferenceError constructor.
|
|
237
|
+
* Use this instead of `new ReferenceError()`.
|
|
238
|
+
*
|
|
239
|
+
* @param message - Optional error message.
|
|
240
|
+
* @param options - Optional error options.
|
|
241
|
+
* @returns A new ReferenceError instance.
|
|
242
|
+
*/
|
|
243
|
+
const createReferenceError = (message, options) => _Reflect$a.construct(_ReferenceError, [message, options]);
|
|
244
|
+
/**
|
|
245
|
+
* (Safe copy) Creates a new SyntaxError using the captured SyntaxError constructor.
|
|
246
|
+
* Use this instead of `new SyntaxError()`.
|
|
247
|
+
*
|
|
248
|
+
* @param message - Optional error message.
|
|
249
|
+
* @param options - Optional error options.
|
|
250
|
+
* @returns A new SyntaxError instance.
|
|
251
|
+
*/
|
|
252
|
+
const createSyntaxError = (message, options) => _Reflect$a.construct(_SyntaxError, [message, options]);
|
|
253
|
+
/**
|
|
254
|
+
* (Safe copy) Creates a new URIError using the captured URIError constructor.
|
|
255
|
+
* Use this instead of `new URIError()`.
|
|
256
|
+
*
|
|
257
|
+
* @param message - Optional error message.
|
|
258
|
+
* @param options - Optional error options.
|
|
259
|
+
* @returns A new URIError instance.
|
|
260
|
+
*/
|
|
261
|
+
const createURIError = (message, options) => _Reflect$a.construct(_URIError, [message, options]);
|
|
262
|
+
/**
|
|
263
|
+
* (Safe copy) Creates a new EvalError using the captured EvalError constructor.
|
|
264
|
+
* Use this instead of `new EvalError()`.
|
|
265
|
+
*
|
|
266
|
+
* @param message - Optional error message.
|
|
267
|
+
* @param options - Optional error options.
|
|
268
|
+
* @returns A new EvalError instance.
|
|
269
|
+
*/
|
|
270
|
+
const createEvalError = (message, options) => _Reflect$a.construct(_EvalError, [message, options]);
|
|
271
|
+
/**
|
|
272
|
+
* (Safe copy) Creates a new AggregateError using the captured AggregateError constructor.
|
|
273
|
+
* Use this instead of `new AggregateError()`.
|
|
274
|
+
*
|
|
275
|
+
* @param errors - An iterable of errors to aggregate.
|
|
276
|
+
* @param message - Optional error message.
|
|
277
|
+
* @param options - Optional error options.
|
|
278
|
+
* @returns A new AggregateError instance.
|
|
279
|
+
*/
|
|
280
|
+
const createAggregateError = (errors, message, options) => _Reflect$a.construct(_AggregateError, [errors, message, options]);
|
|
281
|
+
/**
|
|
282
|
+
* (Safe copy) Namespace object containing Error factory functions.
|
|
283
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
284
|
+
*/
|
|
285
|
+
const Error = _freeze$c({
|
|
286
|
+
create: createError,
|
|
287
|
+
TypeError: createTypeError,
|
|
288
|
+
RangeError: createRangeError,
|
|
289
|
+
ReferenceError: createReferenceError,
|
|
290
|
+
SyntaxError: createSyntaxError,
|
|
291
|
+
URIError: createURIError,
|
|
292
|
+
EvalError: createEvalError,
|
|
293
|
+
AggregateError: createAggregateError,
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Safe copies of Function built-in and utilities.
|
|
298
|
+
*
|
|
299
|
+
* These references are captured at module initialization time to protect against
|
|
300
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
301
|
+
*
|
|
302
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/function
|
|
303
|
+
*/
|
|
304
|
+
// Capture references at module initialization time
|
|
305
|
+
const _Function = globalThis.Function;
|
|
306
|
+
const _FunctionPrototype = _Function.prototype;
|
|
307
|
+
const _Reflect$9 = globalThis.Reflect;
|
|
308
|
+
const _freeze$b = globalThis.Object.freeze;
|
|
309
|
+
/**
|
|
310
|
+
* (Safe copy) Creates a new Function using the captured Function constructor.
|
|
311
|
+
* Use this instead of `new Function()`.
|
|
312
|
+
*
|
|
313
|
+
* NOTE: Dynamic code generation via Function constructor should be avoided when possible
|
|
314
|
+
* due to security risks similar to eval().
|
|
315
|
+
*
|
|
316
|
+
* @param args - Function body and parameter strings.
|
|
317
|
+
* @returns A new Function.
|
|
318
|
+
*/
|
|
319
|
+
const createFunction = (...args) => _Reflect$9.construct(_Function, args);
|
|
320
|
+
/**
|
|
321
|
+
* (Safe copy) Reference to the captured Function.prototype.
|
|
322
|
+
*/
|
|
323
|
+
const functionPrototype = _FunctionPrototype;
|
|
324
|
+
/**
|
|
325
|
+
* (Safe copy) Reference to the captured Function.prototype.call.
|
|
326
|
+
*/
|
|
327
|
+
const functionCall = _FunctionPrototype.call;
|
|
328
|
+
/**
|
|
329
|
+
* (Safe copy) Reference to the captured Function.prototype.apply.
|
|
330
|
+
*/
|
|
331
|
+
const functionApply = _FunctionPrototype.apply;
|
|
332
|
+
/**
|
|
333
|
+
* (Safe copy) Reference to the captured Function.prototype.bind.
|
|
334
|
+
*/
|
|
335
|
+
const functionBind = _FunctionPrototype.bind;
|
|
336
|
+
/**
|
|
337
|
+
* (Safe copy) Namespace object containing Function utilities.
|
|
338
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
339
|
+
*/
|
|
340
|
+
const Function = _freeze$b({
|
|
341
|
+
create: createFunction,
|
|
342
|
+
prototype: functionPrototype,
|
|
343
|
+
call: functionCall,
|
|
344
|
+
apply: functionApply,
|
|
345
|
+
bind: functionBind,
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Safe copies of JSON built-in methods.
|
|
350
|
+
*
|
|
351
|
+
* These references are captured at module initialization time to protect against
|
|
352
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
353
|
+
*
|
|
354
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/json
|
|
355
|
+
*/
|
|
356
|
+
// Capture references at module initialization time
|
|
357
|
+
const _JSON = globalThis.JSON;
|
|
358
|
+
const _freeze$a = globalThis.Object.freeze;
|
|
359
|
+
/**
|
|
360
|
+
* (Safe copy) Converts a JavaScript Object Notation (JSON) string into an object.
|
|
361
|
+
*/
|
|
362
|
+
const parse = _JSON.parse;
|
|
363
|
+
/**
|
|
364
|
+
* (Safe copy) Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
365
|
+
*/
|
|
366
|
+
const stringify = _JSON.stringify;
|
|
367
|
+
/**
|
|
368
|
+
* (Safe copy) Namespace object containing all JSON methods.
|
|
369
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
370
|
+
*/
|
|
371
|
+
const JSON = _freeze$a({
|
|
372
|
+
parse,
|
|
373
|
+
stringify,
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Safe copies of Map built-in via factory function.
|
|
378
|
+
*
|
|
379
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
380
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
381
|
+
*
|
|
382
|
+
* These references are captured at module initialization time to protect against
|
|
383
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
384
|
+
*
|
|
385
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/map
|
|
386
|
+
*/
|
|
387
|
+
// Capture references at module initialization time
|
|
388
|
+
const _Map = globalThis.Map;
|
|
389
|
+
const _Reflect$8 = globalThis.Reflect;
|
|
390
|
+
const _freeze$9 = globalThis.Object.freeze;
|
|
391
|
+
/**
|
|
392
|
+
* (Safe copy) Creates a new Map using the captured Map constructor.
|
|
393
|
+
* Use this instead of `new Map()`.
|
|
394
|
+
*
|
|
395
|
+
* @param iterable - Optional iterable of key-value pairs.
|
|
396
|
+
* @returns A new Map instance.
|
|
397
|
+
*/
|
|
398
|
+
const createMap = (iterable) => _Reflect$8.construct(_Map, iterable ? [iterable] : []);
|
|
399
|
+
/**
|
|
400
|
+
* (Safe copy) Groups elements by key using the captured Map.groupBy if available.
|
|
401
|
+
* Note: Available only in ES2024+ environments.
|
|
402
|
+
*/
|
|
403
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
404
|
+
const mapGroupBy = _Map.groupBy;
|
|
405
|
+
/**
|
|
406
|
+
* (Safe copy) Namespace object containing Map factory.
|
|
407
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
408
|
+
*/
|
|
409
|
+
const Map = _freeze$9({
|
|
410
|
+
create: createMap,
|
|
411
|
+
groupBy: mapGroupBy,
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Safe copies of Messaging/Communication built-in functions and constructors.
|
|
416
|
+
*
|
|
417
|
+
* These references are captured at module initialization time to protect against
|
|
418
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
419
|
+
*
|
|
420
|
+
* Note: `postMessage` is a method on specific objects (Window, Worker, MessagePort)
|
|
421
|
+
* rather than a global. This module provides factory functions for MessageChannel
|
|
422
|
+
* and BroadcastChannel, whose instances have safe postMessage methods.
|
|
423
|
+
*
|
|
424
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/messaging
|
|
425
|
+
*/
|
|
426
|
+
// Capture references at module initialization time
|
|
427
|
+
const _Reflect$7 = globalThis.Reflect;
|
|
428
|
+
const _freeze$8 = globalThis.Object.freeze;
|
|
429
|
+
const _structuredClone = typeof globalThis.structuredClone === 'function' ? globalThis.structuredClone : undefined;
|
|
430
|
+
const _MessageChannel = typeof globalThis.MessageChannel === 'function' ? globalThis.MessageChannel : undefined;
|
|
431
|
+
const _BroadcastChannel = typeof globalThis.BroadcastChannel === 'function' ? globalThis.BroadcastChannel : undefined;
|
|
432
|
+
/**
|
|
433
|
+
* (Safe copy) Creates a deep clone of a value using the structured clone algorithm.
|
|
434
|
+
* Available in modern browsers and Node.js 17+.
|
|
435
|
+
*
|
|
436
|
+
* @param value - The value to clone.
|
|
437
|
+
* @param options - Optional transfer or serialization options.
|
|
438
|
+
* @returns A deep clone of the value.
|
|
439
|
+
*/
|
|
440
|
+
const structuredClone = _structuredClone
|
|
441
|
+
? (value, options) => _structuredClone(value, options)
|
|
442
|
+
: undefined;
|
|
443
|
+
/**
|
|
444
|
+
* (Safe copy) Creates a new MessageChannel using the captured constructor.
|
|
445
|
+
* MessageChannel provides two ports for bidirectional communication.
|
|
446
|
+
*
|
|
447
|
+
* @returns A new MessageChannel instance or undefined if not available.
|
|
448
|
+
*/
|
|
449
|
+
const createMessageChannel = _MessageChannel
|
|
450
|
+
? () => _Reflect$7.construct(_MessageChannel, [])
|
|
451
|
+
: undefined;
|
|
452
|
+
/**
|
|
453
|
+
* (Safe copy) Creates a new BroadcastChannel using the captured constructor.
|
|
454
|
+
* BroadcastChannel enables communication between browsing contexts with the same origin.
|
|
455
|
+
*
|
|
456
|
+
* @param name - Identifier for the broadcast channel that other contexts use to subscribe.
|
|
457
|
+
* @returns A new BroadcastChannel instance or undefined if not available.
|
|
458
|
+
*/
|
|
459
|
+
const createBroadcastChannel = _BroadcastChannel
|
|
460
|
+
? (name) => _Reflect$7.construct(_BroadcastChannel, [name])
|
|
461
|
+
: undefined;
|
|
462
|
+
/**
|
|
463
|
+
* (Safe copy) Posts a message to a Window object using captured postMessage.
|
|
464
|
+
* This is a helper that wraps Window.postMessage for safe messaging.
|
|
465
|
+
*
|
|
466
|
+
* @param target - Destination window, iframe, or popup context.
|
|
467
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
468
|
+
* @param options - Target origin and optional transferables.
|
|
469
|
+
*/
|
|
470
|
+
const postMessageToWindow = (target, message, options) => {
|
|
471
|
+
target.postMessage(message, options.targetOrigin, options.transfer);
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* (Safe copy) Posts a message to a Worker using captured postMessage.
|
|
475
|
+
*
|
|
476
|
+
* @param target - Web Worker or service worker instance.
|
|
477
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
478
|
+
* @param transfer - Optional array of Transferable objects.
|
|
479
|
+
*/
|
|
480
|
+
const postMessageToWorker = (target, message, transfer) => {
|
|
481
|
+
if (transfer) {
|
|
482
|
+
target.postMessage(message, transfer);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
target.postMessage(message);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* (Safe copy) Posts a message to a MessagePort.
|
|
490
|
+
*
|
|
491
|
+
* @param port - One end of a two-way communication channel.
|
|
492
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
493
|
+
* @param transfer - Optional array of Transferable objects.
|
|
494
|
+
*/
|
|
495
|
+
const postMessageToPort = (port, message, transfer) => {
|
|
496
|
+
if (transfer) {
|
|
497
|
+
port.postMessage(message, transfer);
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
port.postMessage(message);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* (Safe copy) Posts a message to a BroadcastChannel.
|
|
505
|
+
*
|
|
506
|
+
* @param channel - Named broadcast channel for same-origin contexts.
|
|
507
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
508
|
+
*/
|
|
509
|
+
const postMessageToBroadcast = (channel, message) => {
|
|
510
|
+
channel.postMessage(message);
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* (Safe copy) Namespace object containing all Messaging functions.
|
|
514
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
515
|
+
*/
|
|
516
|
+
const Messaging = _freeze$8({
|
|
517
|
+
structuredClone,
|
|
518
|
+
createMessageChannel,
|
|
519
|
+
createBroadcastChannel,
|
|
520
|
+
postMessageToWindow,
|
|
521
|
+
postMessageToWorker,
|
|
522
|
+
postMessageToPort,
|
|
523
|
+
postMessageToBroadcast,
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Safe copies of Object built-in methods.
|
|
528
|
+
*
|
|
529
|
+
* These references are captured at module initialization time to protect against
|
|
530
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
531
|
+
*
|
|
532
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/object
|
|
533
|
+
*/
|
|
534
|
+
// Capture references at module initialization time
|
|
535
|
+
const _Object = globalThis.Object;
|
|
536
|
+
const _Reflect$6 = globalThis.Reflect;
|
|
537
|
+
const _ObjectPrototype = _Object.prototype;
|
|
538
|
+
const _hasOwnProperty = _ObjectPrototype.hasOwnProperty;
|
|
539
|
+
/**
|
|
540
|
+
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
541
|
+
* and prevents the addition of new properties.
|
|
542
|
+
*/
|
|
543
|
+
const freeze = _Object.freeze;
|
|
544
|
+
/**
|
|
545
|
+
* (Safe copy) Creates an object that has the specified prototype or that has null prototype.
|
|
546
|
+
*/
|
|
547
|
+
const create = _Object.create;
|
|
548
|
+
/**
|
|
549
|
+
* (Safe copy) Returns the names of the enumerable string properties and methods of an object.
|
|
550
|
+
*/
|
|
551
|
+
const keys = _Object.keys;
|
|
552
|
+
/**
|
|
553
|
+
* (Safe copy) Returns an array of key/values of the enumerable own properties of an object.
|
|
554
|
+
*/
|
|
555
|
+
const entries = _Object.entries;
|
|
556
|
+
/**
|
|
557
|
+
* (Safe copy) Returns an array of values of the enumerable own properties of an object.
|
|
558
|
+
*/
|
|
559
|
+
const values = _Object.values;
|
|
560
|
+
/**
|
|
561
|
+
* (Safe copy) Returns an object from an iterable of key-value pairs.
|
|
562
|
+
*/
|
|
563
|
+
const fromEntries = _Object.fromEntries;
|
|
564
|
+
/**
|
|
565
|
+
* (Safe copy) Copy the values of all enumerable own properties from one or more source objects
|
|
566
|
+
* to a target object. Returns the target object.
|
|
567
|
+
*/
|
|
568
|
+
const assign = _Object.assign;
|
|
569
|
+
/**
|
|
570
|
+
* (Safe copy) Adds a property to an object, or modifies attributes of an existing property.
|
|
571
|
+
*/
|
|
572
|
+
const defineProperty$1 = _Object.defineProperty;
|
|
573
|
+
/**
|
|
574
|
+
* (Safe copy) Adds one or more properties to an object, and/or modifies attributes of existing properties.
|
|
575
|
+
*/
|
|
576
|
+
const defineProperties = _Object.defineProperties;
|
|
577
|
+
/**
|
|
578
|
+
* (Safe copy) Determines whether an object has a property with the specified name.
|
|
579
|
+
*/
|
|
580
|
+
const objectHasOwn = _Object.hasOwn;
|
|
581
|
+
/**
|
|
582
|
+
* (Safe copy) Sets the prototype of a specified object o to object proto or null.
|
|
583
|
+
*/
|
|
584
|
+
const setPrototypeOf$1 = _Object.setPrototypeOf;
|
|
585
|
+
/**
|
|
586
|
+
* (Safe copy) Returns the prototype of an object.
|
|
587
|
+
*/
|
|
588
|
+
const getPrototypeOf$1 = _Object.getPrototypeOf;
|
|
589
|
+
/**
|
|
590
|
+
* (Safe copy) Prevents the addition of new properties to an object.
|
|
591
|
+
*/
|
|
592
|
+
const seal = _Object.seal;
|
|
593
|
+
/**
|
|
594
|
+
* (Safe copy) Returns true if existing property attributes and values cannot be modified
|
|
595
|
+
* in an object, and new properties cannot be added to the object.
|
|
596
|
+
*/
|
|
597
|
+
const isFrozen = _Object.isFrozen;
|
|
598
|
+
/**
|
|
599
|
+
* (Safe copy) Returns true if existing property attributes cannot be modified in an object
|
|
600
|
+
* and new properties cannot be added to the object.
|
|
601
|
+
*/
|
|
602
|
+
const isSealed = _Object.isSealed;
|
|
603
|
+
/**
|
|
604
|
+
* (Safe copy) Returns a value that indicates whether new properties can be added to an object.
|
|
605
|
+
*/
|
|
606
|
+
const isExtensible$1 = _Object.isExtensible;
|
|
607
|
+
/**
|
|
608
|
+
* (Safe copy) Prevents the addition of new properties to an object.
|
|
609
|
+
*/
|
|
610
|
+
const preventExtensions$1 = _Object.preventExtensions;
|
|
611
|
+
/**
|
|
612
|
+
* (Safe copy) Gets the own property descriptor of the specified object.
|
|
613
|
+
*/
|
|
614
|
+
const getOwnPropertyDescriptor$1 = _Object.getOwnPropertyDescriptor;
|
|
615
|
+
/**
|
|
616
|
+
* (Safe copy) Returns the names of the own properties of an object.
|
|
617
|
+
*/
|
|
618
|
+
const getOwnPropertyNames = _Object.getOwnPropertyNames;
|
|
619
|
+
/**
|
|
620
|
+
* (Safe copy) Returns an array of all symbol properties found directly on object o.
|
|
621
|
+
*/
|
|
622
|
+
const getOwnPropertySymbols = _Object.getOwnPropertySymbols;
|
|
623
|
+
/**
|
|
624
|
+
* (Safe copy) Gets the own property descriptors of the specified object.
|
|
625
|
+
*/
|
|
626
|
+
const getOwnPropertyDescriptors = _Object.getOwnPropertyDescriptors;
|
|
627
|
+
/**
|
|
628
|
+
* (Safe copy) Safe wrapper for Object.prototype.hasOwnProperty.call().
|
|
629
|
+
* Checks if an object has a property as its own (not inherited) property.
|
|
630
|
+
*
|
|
631
|
+
* @param obj - The object to check.
|
|
632
|
+
* @param key - The property key to check.
|
|
633
|
+
* @returns True if the object has the property as its own property.
|
|
634
|
+
*/
|
|
635
|
+
const hasOwn = (obj, key) => _Reflect$6.apply(_hasOwnProperty, obj, [key]);
|
|
636
|
+
/**
|
|
637
|
+
* (Safe copy) Namespace object containing all Object static methods.
|
|
638
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
639
|
+
*/
|
|
640
|
+
const Object$1 = _Object.freeze({
|
|
641
|
+
freeze,
|
|
642
|
+
create,
|
|
643
|
+
keys,
|
|
644
|
+
entries,
|
|
645
|
+
values,
|
|
646
|
+
fromEntries,
|
|
647
|
+
assign,
|
|
648
|
+
defineProperty: defineProperty$1,
|
|
649
|
+
defineProperties,
|
|
650
|
+
hasOwn: objectHasOwn,
|
|
651
|
+
setPrototypeOf: setPrototypeOf$1,
|
|
652
|
+
getPrototypeOf: getPrototypeOf$1,
|
|
653
|
+
seal,
|
|
654
|
+
isFrozen,
|
|
655
|
+
isSealed,
|
|
656
|
+
isExtensible: isExtensible$1,
|
|
657
|
+
preventExtensions: preventExtensions$1,
|
|
658
|
+
getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
|
|
659
|
+
getOwnPropertyNames,
|
|
660
|
+
getOwnPropertySymbols,
|
|
661
|
+
getOwnPropertyDescriptors,
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Safe copies of Promise built-in methods via factory functions.
|
|
666
|
+
*
|
|
667
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
668
|
+
* provides factory functions that use Reflect.construct internally.
|
|
669
|
+
*
|
|
670
|
+
* These references are captured at module initialization time to protect against
|
|
671
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
672
|
+
*
|
|
673
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/promise
|
|
674
|
+
*/
|
|
675
|
+
// Capture references at module initialization time
|
|
676
|
+
const _Promise = globalThis.Promise;
|
|
677
|
+
const _Reflect$5 = globalThis.Reflect;
|
|
678
|
+
const _freeze$7 = globalThis.Object.freeze;
|
|
679
|
+
/**
|
|
680
|
+
* (Safe copy) Creates a new Promise using the captured Promise constructor.
|
|
681
|
+
* Use this instead of `new Promise()`.
|
|
682
|
+
*
|
|
683
|
+
* @param executor - The executor function.
|
|
684
|
+
* @returns A new Promise instance.
|
|
685
|
+
*/
|
|
686
|
+
const createPromise = (executor) => _Reflect$5.construct(_Promise, [executor]);
|
|
687
|
+
/**
|
|
688
|
+
* (Safe copy) Returns a Promise that resolves with the given value.
|
|
689
|
+
*/
|
|
690
|
+
const promiseResolve = _Promise.resolve.bind(_Promise);
|
|
691
|
+
/**
|
|
692
|
+
* (Safe copy) Returns a Promise that rejects with the given reason.
|
|
693
|
+
*/
|
|
694
|
+
const promiseReject = _Promise.reject.bind(_Promise);
|
|
695
|
+
/**
|
|
696
|
+
* (Safe copy) Returns a Promise that resolves when all promises resolve.
|
|
697
|
+
*/
|
|
698
|
+
const promiseAll = _Promise.all.bind(_Promise);
|
|
699
|
+
/**
|
|
700
|
+
* (Safe copy) Returns a Promise that resolves/rejects with the first settled promise.
|
|
701
|
+
*/
|
|
702
|
+
const promiseRace = _Promise.race.bind(_Promise);
|
|
703
|
+
/**
|
|
704
|
+
* (Safe copy) Returns a Promise that resolves when all promises settle.
|
|
705
|
+
*/
|
|
706
|
+
const promiseAllSettled = _Promise.allSettled.bind(_Promise);
|
|
707
|
+
/**
|
|
708
|
+
* (Safe copy) Returns a Promise that resolves with the first fulfilled promise.
|
|
709
|
+
*/
|
|
710
|
+
const promiseAny = _Promise.any.bind(_Promise);
|
|
711
|
+
/**
|
|
712
|
+
* (Safe copy) Creates a Promise along with its resolve and reject functions.
|
|
713
|
+
* Note: Available only in ES2024+ environments.
|
|
714
|
+
*/
|
|
715
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
716
|
+
const promiseWithResolvers = _Promise.withResolvers?.bind(_Promise);
|
|
717
|
+
/**
|
|
718
|
+
* (Safe copy) Namespace object containing all Promise factory functions.
|
|
719
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
720
|
+
*/
|
|
721
|
+
const Promise$1 = _freeze$7({
|
|
722
|
+
create: createPromise,
|
|
723
|
+
resolve: promiseResolve,
|
|
724
|
+
reject: promiseReject,
|
|
725
|
+
all: promiseAll,
|
|
726
|
+
race: promiseRace,
|
|
727
|
+
allSettled: promiseAllSettled,
|
|
728
|
+
any: promiseAny,
|
|
729
|
+
withResolvers: promiseWithResolvers,
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Safe copies of Reflect built-in methods.
|
|
734
|
+
*
|
|
735
|
+
* These references are captured at module initialization time to protect against
|
|
736
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
737
|
+
*
|
|
738
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/reflect
|
|
739
|
+
*/
|
|
740
|
+
// Capture references at module initialization time
|
|
741
|
+
const _Reflect$4 = globalThis.Reflect;
|
|
742
|
+
const _freeze$6 = globalThis.Object.freeze;
|
|
743
|
+
/**
|
|
744
|
+
* (Safe copy) Calls the function with the specified object as the this value
|
|
745
|
+
* and the elements of specified array as the arguments.
|
|
746
|
+
*/
|
|
747
|
+
const apply = _Reflect$4.apply;
|
|
748
|
+
/**
|
|
749
|
+
* (Safe copy) Constructs the target with the elements of specified array as the arguments.
|
|
750
|
+
*/
|
|
751
|
+
const construct = _Reflect$4.construct;
|
|
752
|
+
/**
|
|
753
|
+
* (Safe copy) Gets the property of target, equivalent to target[propertyKey].
|
|
754
|
+
*/
|
|
755
|
+
const get = _Reflect$4.get;
|
|
756
|
+
/**
|
|
757
|
+
* (Safe copy) Sets the property of target, equivalent to target[propertyKey] = value.
|
|
758
|
+
*/
|
|
759
|
+
const set = _Reflect$4.set;
|
|
760
|
+
/**
|
|
761
|
+
* (Safe copy) Determines whether an object has a property with the specified name.
|
|
762
|
+
*/
|
|
763
|
+
const has = _Reflect$4.has;
|
|
764
|
+
/**
|
|
765
|
+
* (Safe copy) Returns an array of the target object's own property keys.
|
|
766
|
+
*/
|
|
767
|
+
const ownKeys = _Reflect$4.ownKeys;
|
|
768
|
+
/**
|
|
769
|
+
* (Safe copy) Adds or modifies a property on an object.
|
|
770
|
+
*/
|
|
771
|
+
const defineProperty = _Reflect$4.defineProperty;
|
|
772
|
+
/**
|
|
773
|
+
* (Safe copy) Deletes a property from an object.
|
|
774
|
+
*/
|
|
775
|
+
const deleteProperty = _Reflect$4.deleteProperty;
|
|
776
|
+
/**
|
|
777
|
+
* (Safe copy) Gets the property descriptor of the specified property.
|
|
778
|
+
*/
|
|
779
|
+
const getOwnPropertyDescriptor = _Reflect$4.getOwnPropertyDescriptor;
|
|
780
|
+
/**
|
|
781
|
+
* (Safe copy) Returns the prototype of the specified object.
|
|
782
|
+
*/
|
|
783
|
+
const getPrototypeOf = _Reflect$4.getPrototypeOf;
|
|
784
|
+
/**
|
|
785
|
+
* (Safe copy) Sets the prototype of the specified object.
|
|
786
|
+
*/
|
|
787
|
+
const setPrototypeOf = _Reflect$4.setPrototypeOf;
|
|
788
|
+
/**
|
|
789
|
+
* (Safe copy) Returns a boolean indicating whether the object is extensible.
|
|
790
|
+
*/
|
|
791
|
+
const isExtensible = _Reflect$4.isExtensible;
|
|
792
|
+
/**
|
|
793
|
+
* (Safe copy) Prevents new properties from being added to the object.
|
|
794
|
+
*/
|
|
795
|
+
const preventExtensions = _Reflect$4.preventExtensions;
|
|
796
|
+
/**
|
|
797
|
+
* (Safe copy) Namespace object containing all Reflect methods.
|
|
798
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
799
|
+
*/
|
|
800
|
+
const Reflect = _freeze$6({
|
|
801
|
+
apply,
|
|
802
|
+
construct,
|
|
803
|
+
get,
|
|
804
|
+
set,
|
|
805
|
+
has,
|
|
806
|
+
ownKeys,
|
|
807
|
+
defineProperty,
|
|
808
|
+
deleteProperty,
|
|
809
|
+
getOwnPropertyDescriptor,
|
|
810
|
+
getPrototypeOf,
|
|
811
|
+
setPrototypeOf,
|
|
812
|
+
isExtensible,
|
|
813
|
+
preventExtensions,
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Safe copies of RegExp built-in via factory function.
|
|
818
|
+
*
|
|
819
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
820
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
821
|
+
*
|
|
822
|
+
* These references are captured at module initialization time to protect against
|
|
823
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
824
|
+
*
|
|
825
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/regexp
|
|
826
|
+
*/
|
|
827
|
+
// Capture references at module initialization time
|
|
828
|
+
const _RegExp = globalThis.RegExp;
|
|
829
|
+
const _Reflect$3 = globalThis.Reflect;
|
|
830
|
+
const _freeze$5 = globalThis.Object.freeze;
|
|
831
|
+
/**
|
|
832
|
+
* (Safe copy) Creates a new RegExp using the captured RegExp constructor.
|
|
833
|
+
* Use this instead of `new RegExp()`.
|
|
834
|
+
*
|
|
835
|
+
* @param pattern - The pattern string or RegExp to copy.
|
|
836
|
+
* @param flags - Optional flags string.
|
|
837
|
+
* @returns A new RegExp instance.
|
|
838
|
+
*/
|
|
839
|
+
const createRegExp = (pattern, flags) => _Reflect$3.construct(_RegExp, [pattern, flags]);
|
|
840
|
+
/**
|
|
841
|
+
* (Safe copy) Namespace object containing RegExp factory.
|
|
842
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
843
|
+
*/
|
|
844
|
+
const RegExp = _freeze$5({
|
|
845
|
+
create: createRegExp,
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Safe copies of Set built-in via factory function.
|
|
850
|
+
*
|
|
851
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
852
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
853
|
+
*
|
|
854
|
+
* These references are captured at module initialization time to protect against
|
|
855
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
856
|
+
*
|
|
857
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
858
|
+
*/
|
|
859
|
+
// Capture references at module initialization time
|
|
860
|
+
const _Set = globalThis.Set;
|
|
861
|
+
const _Reflect$2 = globalThis.Reflect;
|
|
862
|
+
const _freeze$4 = globalThis.Object.freeze;
|
|
863
|
+
/**
|
|
864
|
+
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
865
|
+
* Use this instead of `new Set()`.
|
|
866
|
+
*
|
|
867
|
+
* @param iterable - Optional iterable of values.
|
|
868
|
+
* @returns A new Set instance.
|
|
869
|
+
*/
|
|
870
|
+
const createSet = (iterable) => _Reflect$2.construct(_Set, iterable ? [iterable] : []);
|
|
871
|
+
/**
|
|
872
|
+
* (Safe copy) Namespace object containing Set factory.
|
|
873
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
874
|
+
*/
|
|
875
|
+
const Set = _freeze$4({
|
|
876
|
+
create: createSet,
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Safe copies of Symbol built-in and well-known symbols.
|
|
881
|
+
*
|
|
882
|
+
* These references are captured at module initialization time to protect against
|
|
883
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
884
|
+
*
|
|
885
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/symbol
|
|
886
|
+
*/
|
|
887
|
+
// Capture references at module initialization time
|
|
888
|
+
const _Symbol = globalThis.Symbol;
|
|
889
|
+
const _freeze$3 = globalThis.Object.freeze;
|
|
890
|
+
/**
|
|
891
|
+
* (Safe copy) Creates a new Symbol with optional description.
|
|
892
|
+
* Use this instead of `Symbol()`.
|
|
893
|
+
*
|
|
894
|
+
* @param description - Optional description for the symbol.
|
|
895
|
+
* @returns A new Symbol.
|
|
896
|
+
*/
|
|
897
|
+
const createSymbol = (description) => _Symbol(description);
|
|
898
|
+
/**
|
|
899
|
+
* (Safe copy) Returns a Symbol object from the global symbol registry.
|
|
900
|
+
*/
|
|
901
|
+
const symbolFor = _Symbol.for;
|
|
902
|
+
/**
|
|
903
|
+
* (Safe copy) Returns a key from the global symbol registry.
|
|
904
|
+
*/
|
|
905
|
+
const symbolKeyFor = _Symbol.keyFor;
|
|
906
|
+
// Well-known symbols (captured)
|
|
907
|
+
/**
|
|
908
|
+
* (Safe copy) A method that returns the default iterator for an object.
|
|
909
|
+
*/
|
|
910
|
+
const symbolIterator = _Symbol.iterator;
|
|
911
|
+
/**
|
|
912
|
+
* (Safe copy) A method that returns the default async iterator for an object.
|
|
913
|
+
*/
|
|
914
|
+
const symbolAsyncIterator = _Symbol.asyncIterator;
|
|
915
|
+
/**
|
|
916
|
+
* (Safe copy) A method that converts an object to a primitive value.
|
|
917
|
+
*/
|
|
918
|
+
const symbolToStringTag = _Symbol.toStringTag;
|
|
919
|
+
/**
|
|
920
|
+
* (Safe copy) A method that determines if a constructor object recognizes an object as its instance.
|
|
921
|
+
*/
|
|
922
|
+
const symbolHasInstance = _Symbol.hasInstance;
|
|
923
|
+
/**
|
|
924
|
+
* (Safe copy) A Boolean value indicating if an object should be flattened to its array elements.
|
|
925
|
+
*/
|
|
926
|
+
const symbolIsConcatSpreadable = _Symbol.isConcatSpreadable;
|
|
927
|
+
/**
|
|
928
|
+
* (Safe copy) A method that matches against a string.
|
|
929
|
+
*/
|
|
930
|
+
const symbolMatch = _Symbol.match;
|
|
931
|
+
/**
|
|
932
|
+
* (Safe copy) A method that returns an index within a string that matches the regular expression.
|
|
933
|
+
*/
|
|
934
|
+
const symbolMatchAll = _Symbol.matchAll;
|
|
935
|
+
/**
|
|
936
|
+
* (Safe copy) A method that replaces matched substrings of a string.
|
|
937
|
+
*/
|
|
938
|
+
const symbolReplace = _Symbol.replace;
|
|
939
|
+
/**
|
|
940
|
+
* (Safe copy) A method that returns the index within a string that matches the regular expression.
|
|
941
|
+
*/
|
|
942
|
+
const symbolSearch = _Symbol.search;
|
|
943
|
+
/**
|
|
944
|
+
* (Safe copy) A method that splits a string at the indices that match a regular expression.
|
|
945
|
+
*/
|
|
946
|
+
const symbolSplit = _Symbol.split;
|
|
947
|
+
/**
|
|
948
|
+
* (Safe copy) A function valued property that is the constructor function that is used to create derived objects.
|
|
949
|
+
*/
|
|
950
|
+
const symbolSpecies = _Symbol.species;
|
|
951
|
+
/**
|
|
952
|
+
* (Safe copy) A method that converts an object to a primitive value.
|
|
953
|
+
*/
|
|
954
|
+
const symbolToPrimitive = _Symbol.toPrimitive;
|
|
955
|
+
/**
|
|
956
|
+
* (Safe copy) An Object whose own property names are property names that are excluded from the with environment bindings.
|
|
957
|
+
*/
|
|
958
|
+
const symbolUnscopables = _Symbol.unscopables;
|
|
959
|
+
/**
|
|
960
|
+
* (Safe copy) Namespace object containing Symbol utilities and well-known symbols.
|
|
961
|
+
* Note: Importing this imports all symbols in this namespace (no tree-shaking).
|
|
962
|
+
*/
|
|
963
|
+
const Symbol$1 = _freeze$3({
|
|
964
|
+
create: createSymbol,
|
|
965
|
+
for: symbolFor,
|
|
966
|
+
keyFor: symbolKeyFor,
|
|
967
|
+
iterator: symbolIterator,
|
|
968
|
+
asyncIterator: symbolAsyncIterator,
|
|
969
|
+
toStringTag: symbolToStringTag,
|
|
970
|
+
hasInstance: symbolHasInstance,
|
|
971
|
+
isConcatSpreadable: symbolIsConcatSpreadable,
|
|
972
|
+
match: symbolMatch,
|
|
973
|
+
matchAll: symbolMatchAll,
|
|
974
|
+
replace: symbolReplace,
|
|
975
|
+
search: symbolSearch,
|
|
976
|
+
split: symbolSplit,
|
|
977
|
+
species: symbolSpecies,
|
|
978
|
+
toPrimitive: symbolToPrimitive,
|
|
979
|
+
unscopables: symbolUnscopables,
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Safe copies of Timer/Scheduling built-in functions.
|
|
984
|
+
*
|
|
985
|
+
* These references are captured at module initialization time to protect against
|
|
986
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
987
|
+
*
|
|
988
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/timers
|
|
989
|
+
*/
|
|
990
|
+
// Capture references at module initialization time
|
|
991
|
+
const _setTimeout = globalThis.setTimeout;
|
|
992
|
+
const _setInterval = globalThis.setInterval;
|
|
993
|
+
const _clearTimeout = globalThis.clearTimeout;
|
|
994
|
+
const _clearInterval = globalThis.clearInterval;
|
|
995
|
+
const _queueMicrotask = globalThis.queueMicrotask;
|
|
996
|
+
const _requestAnimationFrame = typeof globalThis.requestAnimationFrame === 'function' ? globalThis.requestAnimationFrame : undefined;
|
|
997
|
+
const _cancelAnimationFrame = typeof globalThis.cancelAnimationFrame === 'function' ? globalThis.cancelAnimationFrame : undefined;
|
|
998
|
+
const _freeze$2 = globalThis.Object.freeze;
|
|
999
|
+
/**
|
|
1000
|
+
* (Safe copy) Sets a timer which executes a function once the timer expires.
|
|
1001
|
+
*
|
|
1002
|
+
* @param callback - Function to call when the timer elapses.
|
|
1003
|
+
* @param delay - Time in milliseconds before executing.
|
|
1004
|
+
* @param args - Additional arguments to pass to the callback.
|
|
1005
|
+
* @returns A numeric ID for the timer.
|
|
1006
|
+
*/
|
|
1007
|
+
const setTimeout = (callback, delay, ...args) => _setTimeout(callback, delay, ...args);
|
|
1008
|
+
/**
|
|
1009
|
+
* (Safe copy) Repeatedly calls a function with a fixed time delay between each call.
|
|
1010
|
+
*
|
|
1011
|
+
* @param callback - Function to call at each interval.
|
|
1012
|
+
* @param delay - Time in milliseconds between calls.
|
|
1013
|
+
* @param args - Additional arguments to pass to the callback.
|
|
1014
|
+
* @returns A numeric ID for the interval.
|
|
1015
|
+
*/
|
|
1016
|
+
const setInterval = (callback, delay, ...args) => _setInterval(callback, delay, ...args);
|
|
1017
|
+
/**
|
|
1018
|
+
* (Safe copy) Cancels a timeout previously established by setTimeout.
|
|
1019
|
+
*
|
|
1020
|
+
* @param id - The identifier of the timeout to cancel.
|
|
1021
|
+
*/
|
|
1022
|
+
const clearTimeout = (id) => {
|
|
1023
|
+
_clearTimeout(id);
|
|
1024
|
+
};
|
|
1025
|
+
/**
|
|
1026
|
+
* (Safe copy) Cancels a timed, repeating action previously established by setInterval.
|
|
1027
|
+
*
|
|
1028
|
+
* @param id - The identifier of the interval to cancel.
|
|
1029
|
+
*/
|
|
1030
|
+
const clearInterval = (id) => {
|
|
1031
|
+
_clearInterval(id);
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* (Safe copy) Queues a microtask to be executed before control returns to the event loop.
|
|
1035
|
+
*
|
|
1036
|
+
* @param callback - Function to execute.
|
|
1037
|
+
*/
|
|
1038
|
+
const queueMicrotask = (callback) => {
|
|
1039
|
+
_queueMicrotask(callback);
|
|
1040
|
+
};
|
|
1041
|
+
/**
|
|
1042
|
+
* (Safe copy) Requests the browser to call a function before the next repaint.
|
|
1043
|
+
* Available only in browser environments.
|
|
1044
|
+
*
|
|
1045
|
+
* @param callback - Function to call before repaint.
|
|
1046
|
+
* @returns A request ID or undefined if not available.
|
|
1047
|
+
*/
|
|
1048
|
+
const requestAnimationFrame = _requestAnimationFrame
|
|
1049
|
+
? (callback) => _requestAnimationFrame(callback)
|
|
1050
|
+
: undefined;
|
|
1051
|
+
/**
|
|
1052
|
+
* (Safe copy) Cancels an animation frame request previously scheduled.
|
|
1053
|
+
* Available only in browser environments.
|
|
1054
|
+
*
|
|
1055
|
+
* @param handle - The ID value returned by requestAnimationFrame.
|
|
1056
|
+
*/
|
|
1057
|
+
const cancelAnimationFrame = _cancelAnimationFrame
|
|
1058
|
+
? (handle) => {
|
|
1059
|
+
_cancelAnimationFrame(handle);
|
|
1060
|
+
}
|
|
1061
|
+
: undefined;
|
|
1062
|
+
/**
|
|
1063
|
+
* (Safe copy) Namespace object containing all Timer/Scheduling functions.
|
|
1064
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
1065
|
+
*/
|
|
1066
|
+
const Timers = _freeze$2({
|
|
1067
|
+
setTimeout,
|
|
1068
|
+
setInterval,
|
|
1069
|
+
clearTimeout,
|
|
1070
|
+
clearInterval,
|
|
1071
|
+
queueMicrotask,
|
|
1072
|
+
requestAnimationFrame,
|
|
1073
|
+
cancelAnimationFrame,
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Safe copies of WeakMap built-in via factory function.
|
|
1078
|
+
*
|
|
1079
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
1080
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
1081
|
+
*
|
|
1082
|
+
* These references are captured at module initialization time to protect against
|
|
1083
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
1084
|
+
*
|
|
1085
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/weak-map
|
|
1086
|
+
*/
|
|
1087
|
+
// Capture references at module initialization time
|
|
1088
|
+
const _WeakMap = globalThis.WeakMap;
|
|
1089
|
+
const _Reflect$1 = globalThis.Reflect;
|
|
1090
|
+
const _freeze$1 = globalThis.Object.freeze;
|
|
1091
|
+
/**
|
|
1092
|
+
* (Safe copy) Creates a new WeakMap using the captured WeakMap constructor.
|
|
1093
|
+
* Use this instead of `new WeakMap()`.
|
|
1094
|
+
*
|
|
1095
|
+
* @param iterable - Optional iterable of key-value pairs.
|
|
1096
|
+
* @returns A new WeakMap instance.
|
|
1097
|
+
*/
|
|
1098
|
+
const createWeakMap = (iterable) => _Reflect$1.construct(_WeakMap, iterable ? [iterable] : []);
|
|
1099
|
+
/**
|
|
1100
|
+
* (Safe copy) Namespace object containing WeakMap factory.
|
|
1101
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
1102
|
+
*/
|
|
1103
|
+
const WeakMap = _freeze$1({
|
|
1104
|
+
create: createWeakMap,
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Safe copies of WeakSet built-in via factory function.
|
|
1109
|
+
*
|
|
1110
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
1111
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
1112
|
+
*
|
|
1113
|
+
* These references are captured at module initialization time to protect against
|
|
1114
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
1115
|
+
*
|
|
1116
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/weak-set
|
|
1117
|
+
*/
|
|
1118
|
+
// Capture references at module initialization time
|
|
1119
|
+
const _WeakSet = globalThis.WeakSet;
|
|
1120
|
+
const _Reflect = globalThis.Reflect;
|
|
1121
|
+
const _freeze = globalThis.Object.freeze;
|
|
1122
|
+
/**
|
|
1123
|
+
* (Safe copy) Creates a new WeakSet using the captured WeakSet constructor.
|
|
1124
|
+
* Use this instead of `new WeakSet()`.
|
|
1125
|
+
*
|
|
1126
|
+
* @param iterable - Optional iterable of values.
|
|
1127
|
+
* @returns A new WeakSet instance.
|
|
1128
|
+
*/
|
|
1129
|
+
const createWeakSet = (iterable) => _Reflect.construct(_WeakSet, iterable ? [iterable] : []);
|
|
1130
|
+
/**
|
|
1131
|
+
* (Safe copy) Namespace object containing WeakSet factory.
|
|
1132
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
1133
|
+
*/
|
|
1134
|
+
const WeakSet = _freeze({
|
|
1135
|
+
create: createWeakSet,
|
|
1136
|
+
});
|
|
1137
|
+
|
|
4
1138
|
/**
|
|
5
1139
|
* Creates a decorator that locks a method to prevent overwriting and ensure correct `this` binding.
|
|
6
1140
|
*
|
|
7
|
-
* @locked
|
|
8
1141
|
* Ensures a classic prototype method cannot be overwritten and is
|
|
9
1142
|
* always called with the correct `this` instance without needing arrow functions.
|
|
10
1143
|
*
|
|
@@ -12,6 +1145,18 @@ var HyperfrontendImmutableApiUtils = (function (exports) {
|
|
|
12
1145
|
* - Any attempt to assign to the method throws an error.
|
|
13
1146
|
* - It does not support class fields / arrow functions.
|
|
14
1147
|
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```ts
|
|
1150
|
+
* class Counter {
|
|
1151
|
+
* private count = 0
|
|
1152
|
+
*
|
|
1153
|
+
* \@locked()
|
|
1154
|
+
* increment() {
|
|
1155
|
+
* return ++this.count
|
|
1156
|
+
* }
|
|
1157
|
+
* }
|
|
1158
|
+
* ```
|
|
1159
|
+
*
|
|
15
1160
|
* @returns A method decorator that locks the method
|
|
16
1161
|
*/
|
|
17
1162
|
const locked = () => {
|
|
@@ -25,8 +1170,8 @@ var HyperfrontendImmutableApiUtils = (function (exports) {
|
|
|
25
1170
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
1171
|
get() {
|
|
27
1172
|
// cache a bound function per instance
|
|
28
|
-
if (!
|
|
29
|
-
|
|
1173
|
+
if (!hasOwn(this, BOUND)) {
|
|
1174
|
+
defineProperty$1(this, BOUND, {
|
|
30
1175
|
value: original.bind(this),
|
|
31
1176
|
writable: false,
|
|
32
1177
|
configurable: false,
|
|
@@ -36,7 +1181,7 @@ var HyperfrontendImmutableApiUtils = (function (exports) {
|
|
|
36
1181
|
return this[BOUND];
|
|
37
1182
|
},
|
|
38
1183
|
set() {
|
|
39
|
-
throw
|
|
1184
|
+
throw createTypeError(`Cannot overwrite locked method ${String(key)}`);
|
|
40
1185
|
},
|
|
41
1186
|
};
|
|
42
1187
|
};
|
|
@@ -52,9 +1197,26 @@ var HyperfrontendImmutableApiUtils = (function (exports) {
|
|
|
52
1197
|
const lockedProps = (object, propertyValuePairs) => {
|
|
53
1198
|
const propertyMap = {};
|
|
54
1199
|
propertyValuePairs.forEach(([key, value]) => (propertyMap[key] = lockedPropertyDescriptors(value)));
|
|
55
|
-
|
|
1200
|
+
defineProperties(object, propertyMap);
|
|
56
1201
|
};
|
|
57
1202
|
|
|
1203
|
+
exports.Array = Array;
|
|
1204
|
+
exports.Console = Console;
|
|
1205
|
+
exports.Date = Date;
|
|
1206
|
+
exports.Error = Error;
|
|
1207
|
+
exports.Function = Function;
|
|
1208
|
+
exports.JSON = JSON;
|
|
1209
|
+
exports.Map = Map;
|
|
1210
|
+
exports.Messaging = Messaging;
|
|
1211
|
+
exports.Object = Object$1;
|
|
1212
|
+
exports.Promise = Promise$1;
|
|
1213
|
+
exports.Reflect = Reflect;
|
|
1214
|
+
exports.RegExp = RegExp;
|
|
1215
|
+
exports.Set = Set;
|
|
1216
|
+
exports.Symbol = Symbol$1;
|
|
1217
|
+
exports.Timers = Timers;
|
|
1218
|
+
exports.WeakMap = WeakMap;
|
|
1219
|
+
exports.WeakSet = WeakSet;
|
|
58
1220
|
exports.locked = locked;
|
|
59
1221
|
exports.lockedPropertyDescriptors = lockedPropertyDescriptors;
|
|
60
1222
|
exports.lockedProps = lockedProps;
|