@hyperfrontend/immutable-api-utils 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +68 -8
- 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
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Math built-in methods.
|
|
3
|
+
*
|
|
4
|
+
* These references are captured at module initialization time to protect against
|
|
5
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
6
|
+
*
|
|
7
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/math
|
|
8
|
+
*/
|
|
9
|
+
// Capture references at module initialization time
|
|
10
|
+
const _Math = globalThis.Math;
|
|
11
|
+
const _freeze = globalThis.Object.freeze;
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Constants
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* (Safe copy) The mathematical constant e, approximately 2.718.
|
|
17
|
+
*/
|
|
18
|
+
const E = _Math.E;
|
|
19
|
+
/**
|
|
20
|
+
* (Safe copy) The natural logarithm of 2, approximately 0.693.
|
|
21
|
+
*/
|
|
22
|
+
const LN2 = _Math.LN2;
|
|
23
|
+
/**
|
|
24
|
+
* (Safe copy) The natural logarithm of 10, approximately 2.303.
|
|
25
|
+
*/
|
|
26
|
+
const LN10 = _Math.LN10;
|
|
27
|
+
/**
|
|
28
|
+
* (Safe copy) The base-2 logarithm of e, approximately 1.443.
|
|
29
|
+
*/
|
|
30
|
+
const LOG2E = _Math.LOG2E;
|
|
31
|
+
/**
|
|
32
|
+
* (Safe copy) The base-10 logarithm of e, approximately 0.434.
|
|
33
|
+
*/
|
|
34
|
+
const LOG10E = _Math.LOG10E;
|
|
35
|
+
/**
|
|
36
|
+
* (Safe copy) The mathematical constant π, approximately 3.14159.
|
|
37
|
+
*/
|
|
38
|
+
const PI = _Math.PI;
|
|
39
|
+
/**
|
|
40
|
+
* (Safe copy) The square root of 1/2, approximately 0.707.
|
|
41
|
+
*/
|
|
42
|
+
const SQRT1_2 = _Math.SQRT1_2;
|
|
43
|
+
/**
|
|
44
|
+
* (Safe copy) The square root of 2, approximately 1.414.
|
|
45
|
+
*/
|
|
46
|
+
const SQRT2 = _Math.SQRT2;
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Basic Operations
|
|
49
|
+
// ============================================================================
|
|
50
|
+
/**
|
|
51
|
+
* (Safe copy) Returns the absolute value of a number.
|
|
52
|
+
*/
|
|
53
|
+
const abs = _Math.abs;
|
|
54
|
+
/**
|
|
55
|
+
* (Safe copy) Returns the sign of a number (-1, 0, or 1).
|
|
56
|
+
*/
|
|
57
|
+
const sign = _Math.sign;
|
|
58
|
+
/**
|
|
59
|
+
* (Safe copy) Returns the smallest integer greater than or equal to a number.
|
|
60
|
+
*/
|
|
61
|
+
const ceil = _Math.ceil;
|
|
62
|
+
/**
|
|
63
|
+
* (Safe copy) Returns the largest integer less than or equal to a number.
|
|
64
|
+
*/
|
|
65
|
+
const floor = _Math.floor;
|
|
66
|
+
/**
|
|
67
|
+
* (Safe copy) Returns the value of a number rounded to the nearest integer.
|
|
68
|
+
*/
|
|
69
|
+
const round = _Math.round;
|
|
70
|
+
/**
|
|
71
|
+
* (Safe copy) Returns the integer part of a number by removing fractional digits.
|
|
72
|
+
*/
|
|
73
|
+
const trunc = _Math.trunc;
|
|
74
|
+
// ============================================================================
|
|
75
|
+
// Min/Max
|
|
76
|
+
// ============================================================================
|
|
77
|
+
/**
|
|
78
|
+
* (Safe copy) Returns the larger of zero or more numbers.
|
|
79
|
+
*/
|
|
80
|
+
const max = _Math.max;
|
|
81
|
+
/**
|
|
82
|
+
* (Safe copy) Returns the smaller of zero or more numbers.
|
|
83
|
+
*/
|
|
84
|
+
const min = _Math.min;
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Powers and Roots
|
|
87
|
+
// ============================================================================
|
|
88
|
+
/**
|
|
89
|
+
* (Safe copy) Returns the base to the exponent power.
|
|
90
|
+
*/
|
|
91
|
+
const pow = _Math.pow;
|
|
92
|
+
/**
|
|
93
|
+
* (Safe copy) Returns the square root of a number.
|
|
94
|
+
*/
|
|
95
|
+
const sqrt = _Math.sqrt;
|
|
96
|
+
/**
|
|
97
|
+
* (Safe copy) Returns the cube root of a number.
|
|
98
|
+
*/
|
|
99
|
+
const cbrt = _Math.cbrt;
|
|
100
|
+
/**
|
|
101
|
+
* (Safe copy) Returns the square root of the sum of squares of its arguments.
|
|
102
|
+
*/
|
|
103
|
+
const hypot = _Math.hypot;
|
|
104
|
+
/**
|
|
105
|
+
* (Safe copy) Returns e raised to the power of a number.
|
|
106
|
+
*/
|
|
107
|
+
const exp = _Math.exp;
|
|
108
|
+
/**
|
|
109
|
+
* (Safe copy) Returns e raised to the power of a number minus 1.
|
|
110
|
+
*/
|
|
111
|
+
const expm1 = _Math.expm1;
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// Logarithms
|
|
114
|
+
// ============================================================================
|
|
115
|
+
/**
|
|
116
|
+
* (Safe copy) Returns the natural logarithm of a number.
|
|
117
|
+
*/
|
|
118
|
+
const log = _Math.log;
|
|
119
|
+
/**
|
|
120
|
+
* (Safe copy) Returns the base-2 logarithm of a number.
|
|
121
|
+
*/
|
|
122
|
+
const log2 = _Math.log2;
|
|
123
|
+
/**
|
|
124
|
+
* (Safe copy) Returns the base-10 logarithm of a number.
|
|
125
|
+
*/
|
|
126
|
+
const log10 = _Math.log10;
|
|
127
|
+
/**
|
|
128
|
+
* (Safe copy) Returns the natural logarithm of 1 + a number.
|
|
129
|
+
*/
|
|
130
|
+
const log1p = _Math.log1p;
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Trigonometry
|
|
133
|
+
// ============================================================================
|
|
134
|
+
/**
|
|
135
|
+
* (Safe copy) Returns the sine of a number.
|
|
136
|
+
*/
|
|
137
|
+
const sin = _Math.sin;
|
|
138
|
+
/**
|
|
139
|
+
* (Safe copy) Returns the cosine of a number.
|
|
140
|
+
*/
|
|
141
|
+
const cos = _Math.cos;
|
|
142
|
+
/**
|
|
143
|
+
* (Safe copy) Returns the tangent of a number.
|
|
144
|
+
*/
|
|
145
|
+
const tan = _Math.tan;
|
|
146
|
+
/**
|
|
147
|
+
* (Safe copy) Returns the arcsine of a number.
|
|
148
|
+
*/
|
|
149
|
+
const asin = _Math.asin;
|
|
150
|
+
/**
|
|
151
|
+
* (Safe copy) Returns the arccosine of a number.
|
|
152
|
+
*/
|
|
153
|
+
const acos = _Math.acos;
|
|
154
|
+
/**
|
|
155
|
+
* (Safe copy) Returns the arctangent of a number.
|
|
156
|
+
*/
|
|
157
|
+
const atan = _Math.atan;
|
|
158
|
+
/**
|
|
159
|
+
* (Safe copy) Returns the arctangent of the quotient of its arguments.
|
|
160
|
+
*/
|
|
161
|
+
const atan2 = _Math.atan2;
|
|
162
|
+
/**
|
|
163
|
+
* (Safe copy) Returns the hyperbolic sine of a number.
|
|
164
|
+
*/
|
|
165
|
+
const sinh = _Math.sinh;
|
|
166
|
+
/**
|
|
167
|
+
* (Safe copy) Returns the hyperbolic cosine of a number.
|
|
168
|
+
*/
|
|
169
|
+
const cosh = _Math.cosh;
|
|
170
|
+
/**
|
|
171
|
+
* (Safe copy) Returns the hyperbolic tangent of a number.
|
|
172
|
+
*/
|
|
173
|
+
const tanh = _Math.tanh;
|
|
174
|
+
/**
|
|
175
|
+
* (Safe copy) Returns the inverse hyperbolic sine of a number.
|
|
176
|
+
*/
|
|
177
|
+
const asinh = _Math.asinh;
|
|
178
|
+
/**
|
|
179
|
+
* (Safe copy) Returns the inverse hyperbolic cosine of a number.
|
|
180
|
+
*/
|
|
181
|
+
const acosh = _Math.acosh;
|
|
182
|
+
/**
|
|
183
|
+
* (Safe copy) Returns the inverse hyperbolic tangent of a number.
|
|
184
|
+
*/
|
|
185
|
+
const atanh = _Math.atanh;
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// Bitwise/Integer Operations
|
|
188
|
+
// ============================================================================
|
|
189
|
+
/**
|
|
190
|
+
* (Safe copy) Returns the result of the C-like 32-bit multiplication.
|
|
191
|
+
*/
|
|
192
|
+
const imul = _Math.imul;
|
|
193
|
+
/**
|
|
194
|
+
* (Safe copy) Returns the nearest 32-bit single precision float representation.
|
|
195
|
+
*/
|
|
196
|
+
const fround = _Math.fround;
|
|
197
|
+
/**
|
|
198
|
+
* (Safe copy) Returns the number of leading zero bits in the 32-bit binary representation.
|
|
199
|
+
*/
|
|
200
|
+
const clz32 = _Math.clz32;
|
|
201
|
+
// ============================================================================
|
|
202
|
+
// Random
|
|
203
|
+
// ============================================================================
|
|
204
|
+
/**
|
|
205
|
+
* (Safe copy) Returns a pseudo-random number between 0 and 1.
|
|
206
|
+
* Note: This is NOT cryptographically secure. For secure random values,
|
|
207
|
+
* use crypto.getRandomValues().
|
|
208
|
+
*/
|
|
209
|
+
const random = _Math.random;
|
|
210
|
+
// ============================================================================
|
|
211
|
+
// Namespace Export
|
|
212
|
+
// ============================================================================
|
|
213
|
+
/**
|
|
214
|
+
* (Safe copy) Namespace object containing all Math utilities.
|
|
215
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
216
|
+
*/
|
|
217
|
+
const Math = _freeze({
|
|
218
|
+
// Constants
|
|
219
|
+
E,
|
|
220
|
+
LN2,
|
|
221
|
+
LN10,
|
|
222
|
+
LOG2E,
|
|
223
|
+
LOG10E,
|
|
224
|
+
PI,
|
|
225
|
+
SQRT1_2,
|
|
226
|
+
SQRT2,
|
|
227
|
+
// Basic operations
|
|
228
|
+
abs,
|
|
229
|
+
sign,
|
|
230
|
+
ceil,
|
|
231
|
+
floor,
|
|
232
|
+
round,
|
|
233
|
+
trunc,
|
|
234
|
+
// Min/Max
|
|
235
|
+
max,
|
|
236
|
+
min,
|
|
237
|
+
// Powers and roots
|
|
238
|
+
pow,
|
|
239
|
+
sqrt,
|
|
240
|
+
cbrt,
|
|
241
|
+
hypot,
|
|
242
|
+
exp,
|
|
243
|
+
expm1,
|
|
244
|
+
// Logarithms
|
|
245
|
+
log,
|
|
246
|
+
log2,
|
|
247
|
+
log10,
|
|
248
|
+
log1p,
|
|
249
|
+
// Trigonometry
|
|
250
|
+
sin,
|
|
251
|
+
cos,
|
|
252
|
+
tan,
|
|
253
|
+
asin,
|
|
254
|
+
acos,
|
|
255
|
+
atan,
|
|
256
|
+
atan2,
|
|
257
|
+
sinh,
|
|
258
|
+
cosh,
|
|
259
|
+
tanh,
|
|
260
|
+
asinh,
|
|
261
|
+
acosh,
|
|
262
|
+
atanh,
|
|
263
|
+
// Bitwise/Integer
|
|
264
|
+
imul,
|
|
265
|
+
fround,
|
|
266
|
+
clz32,
|
|
267
|
+
// Random
|
|
268
|
+
random,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
export { E, LN10, LN2, LOG10E, LOG2E, Math, PI, SQRT1_2, SQRT2, abs, acos, acosh, asin, asinh, atan, atan2, atanh, cbrt, ceil, clz32, cos, cosh, exp, expm1, floor, fround, hypot, imul, log, log10, log1p, log2, max, min, pow, random, round, sign, sin, sinh, sqrt, tan, tanh, trunc };
|
|
272
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/math/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI;AAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM;AAExC;AACA;AACA;AAEA;;AAEG;AACI,MAAM,CAAC,GAAG,KAAK,CAAC;AAEvB;;AAEG;AACI,MAAM,GAAG,GAAG,KAAK,CAAC;AAEzB;;AAEG;AACI,MAAM,IAAI,GAAG,KAAK,CAAC;AAE1B;;AAEG;AACI,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B;;AAEG;AACI,MAAM,MAAM,GAAG,KAAK,CAAC;AAE5B;;AAEG;AACI,MAAM,EAAE,GAAG,KAAK,CAAC;AAExB;;AAEG;AACI,MAAM,OAAO,GAAG,KAAK,CAAC;AAE7B;;AAEG;AACI,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B;AACA;AACA;AAEA;;AAEG;AACI,MAAM,GAAG,GAAG,KAAK,CAAC;AAEzB;;AAEG;AACI,MAAM,IAAI,GAAG,KAAK,CAAC;AAE1B;;AAEG;AACI,MAAM,IAAI,GAAG,KAAK,CAAC;AAE1B;;AAEG;AACI,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B;;AAEG;AACI,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B;;AAEG;AACI,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B;AACA;AACA;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E3B;;AAEG;AACI,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B;AACA;AACA;AAEA;;AAEG;AACI,MAAM,IAAI,GAAG,KAAK,CAAC;AAE1B;;AAEG;AACI,MAAM,MAAM,GAAG,KAAK,CAAC;AAE5B;;AAEG;AACI,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B;AACA;AACA;AAEA;;;;AAIG;AACI,MAAM,MAAM,GAAG,KAAK,CAAC;AAE5B;AACA;AACA;AAEA;;;AAGG;AACI,MAAM,IAAI,GAAG,OAAO,CAAQ;;IAEjC,CAAC;IACD,GAAG;IACH,IAAI;IACJ,KAAK;IACL,MAAM;IACN,EAAE;IACF,OAAO;IACP,KAAK;;IAEL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;;IAEL,GAAG;IACH,GAAG;;IAEH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,GAAG;IACH,KAAK;;IAEL,GAAG;IACH,IAAI;IACJ,KAAK;IACL,KAAK;;IAEL,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;;IAEL,IAAI;IACJ,MAAM;IACN,KAAK;;IAEL,MAAM;AACP,CAAA;;;;"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Safe copies of Messaging/Communication built-in functions and constructors.
|
|
5
|
+
*
|
|
6
|
+
* These references are captured at module initialization time to protect against
|
|
7
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
8
|
+
*
|
|
9
|
+
* Note: `postMessage` is a method on specific objects (Window, Worker, MessagePort)
|
|
10
|
+
* rather than a global. This module provides factory functions for MessageChannel
|
|
11
|
+
* and BroadcastChannel, whose instances have safe postMessage methods.
|
|
12
|
+
*
|
|
13
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/messaging
|
|
14
|
+
*/
|
|
15
|
+
// Capture references at module initialization time
|
|
16
|
+
const _Reflect = globalThis.Reflect;
|
|
17
|
+
const _freeze = globalThis.Object.freeze;
|
|
18
|
+
const _structuredClone = typeof globalThis.structuredClone === 'function' ? globalThis.structuredClone : undefined;
|
|
19
|
+
const _MessageChannel = typeof globalThis.MessageChannel === 'function' ? globalThis.MessageChannel : undefined;
|
|
20
|
+
const _BroadcastChannel = typeof globalThis.BroadcastChannel === 'function' ? globalThis.BroadcastChannel : undefined;
|
|
21
|
+
/**
|
|
22
|
+
* (Safe copy) Creates a deep clone of a value using the structured clone algorithm.
|
|
23
|
+
* Available in modern browsers and Node.js 17+.
|
|
24
|
+
*
|
|
25
|
+
* @param value - The value to clone.
|
|
26
|
+
* @param options - Optional transfer or serialization options.
|
|
27
|
+
* @returns A deep clone of the value.
|
|
28
|
+
*/
|
|
29
|
+
const structuredClone = _structuredClone
|
|
30
|
+
? (value, options) => _structuredClone(value, options)
|
|
31
|
+
: undefined;
|
|
32
|
+
/**
|
|
33
|
+
* (Safe copy) Creates a new MessageChannel using the captured constructor.
|
|
34
|
+
* MessageChannel provides two ports for bidirectional communication.
|
|
35
|
+
*
|
|
36
|
+
* @returns A new MessageChannel instance or undefined if not available.
|
|
37
|
+
*/
|
|
38
|
+
const createMessageChannel = _MessageChannel
|
|
39
|
+
? () => _Reflect.construct(_MessageChannel, [])
|
|
40
|
+
: undefined;
|
|
41
|
+
/**
|
|
42
|
+
* (Safe copy) Creates a new BroadcastChannel using the captured constructor.
|
|
43
|
+
* BroadcastChannel enables communication between browsing contexts with the same origin.
|
|
44
|
+
*
|
|
45
|
+
* @param name - Identifier for the broadcast channel that other contexts use to subscribe.
|
|
46
|
+
* @returns A new BroadcastChannel instance or undefined if not available.
|
|
47
|
+
*/
|
|
48
|
+
const createBroadcastChannel = _BroadcastChannel
|
|
49
|
+
? (name) => _Reflect.construct(_BroadcastChannel, [name])
|
|
50
|
+
: undefined;
|
|
51
|
+
/**
|
|
52
|
+
* (Safe copy) Posts a message to a Window object using captured postMessage.
|
|
53
|
+
* This is a helper that wraps Window.postMessage for safe messaging.
|
|
54
|
+
*
|
|
55
|
+
* @param target - Destination window, iframe, or popup context.
|
|
56
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
57
|
+
* @param options - Target origin and optional transferables.
|
|
58
|
+
*/
|
|
59
|
+
const postMessageToWindow = (target, message, options) => {
|
|
60
|
+
target.postMessage(message, options.targetOrigin, options.transfer);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* (Safe copy) Posts a message to a Worker using captured postMessage.
|
|
64
|
+
*
|
|
65
|
+
* @param target - Web Worker or service worker instance.
|
|
66
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
67
|
+
* @param transfer - Optional array of Transferable objects.
|
|
68
|
+
*/
|
|
69
|
+
const postMessageToWorker = (target, message, transfer) => {
|
|
70
|
+
if (transfer) {
|
|
71
|
+
target.postMessage(message, transfer);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
target.postMessage(message);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* (Safe copy) Posts a message to a MessagePort.
|
|
79
|
+
*
|
|
80
|
+
* @param port - One end of a two-way communication channel.
|
|
81
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
82
|
+
* @param transfer - Optional array of Transferable objects.
|
|
83
|
+
*/
|
|
84
|
+
const postMessageToPort = (port, message, transfer) => {
|
|
85
|
+
if (transfer) {
|
|
86
|
+
port.postMessage(message, transfer);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
port.postMessage(message);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* (Safe copy) Posts a message to a BroadcastChannel.
|
|
94
|
+
*
|
|
95
|
+
* @param channel - Named broadcast channel for same-origin contexts.
|
|
96
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
97
|
+
*/
|
|
98
|
+
const postMessageToBroadcast = (channel, message) => {
|
|
99
|
+
channel.postMessage(message);
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* (Safe copy) Namespace object containing all Messaging functions.
|
|
103
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
104
|
+
*/
|
|
105
|
+
const Messaging = _freeze({
|
|
106
|
+
structuredClone,
|
|
107
|
+
createMessageChannel,
|
|
108
|
+
createBroadcastChannel,
|
|
109
|
+
postMessageToWindow,
|
|
110
|
+
postMessageToWorker,
|
|
111
|
+
postMessageToPort,
|
|
112
|
+
postMessageToBroadcast,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
exports.Messaging = Messaging;
|
|
116
|
+
exports.createBroadcastChannel = createBroadcastChannel;
|
|
117
|
+
exports.createMessageChannel = createMessageChannel;
|
|
118
|
+
exports.postMessageToBroadcast = postMessageToBroadcast;
|
|
119
|
+
exports.postMessageToPort = postMessageToPort;
|
|
120
|
+
exports.postMessageToWindow = postMessageToWindow;
|
|
121
|
+
exports.postMessageToWorker = postMessageToWorker;
|
|
122
|
+
exports.structuredClone = structuredClone;
|
|
123
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/messaging/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;AAWG;AAEH;AACA,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;AACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM;AACxC,MAAM,gBAAgB,GAAG,OAAO,UAAU,CAAC,eAAe,KAAK,UAAU,GAAG,UAAU,CAAC,eAAe,GAAG,SAAS;AAClH,MAAM,eAAe,GAAG,OAAO,UAAU,CAAC,cAAc,KAAK,UAAU,GAAG,UAAU,CAAC,c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EAAE,OAAgB,KAAU;AAC1F,IAAA,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;AAC9B;AAEA;;;AAGG;AACI,MAAM,SAAS,GAAG,OAAO,CAAQ;IACtC,eAAe;IACf,oBAAoB;IACpB,sBAAsB;IACtB,mBAAmB;IACnB,mBAAmB;IACnB,iBAAiB;IACjB,sBAAsB;AACvB,CAAA;;;;;;;;;;;"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Messaging/Communication built-in functions and constructors.
|
|
3
|
+
*
|
|
4
|
+
* These references are captured at module initialization time to protect against
|
|
5
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
6
|
+
*
|
|
7
|
+
* Note: `postMessage` is a method on specific objects (Window, Worker, MessagePort)
|
|
8
|
+
* rather than a global. This module provides factory functions for MessageChannel
|
|
9
|
+
* and BroadcastChannel, whose instances have safe postMessage methods.
|
|
10
|
+
*
|
|
11
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/messaging
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* (Safe copy) Creates a deep clone of a value using the structured clone algorithm.
|
|
15
|
+
* Available in modern browsers and Node.js 17+.
|
|
16
|
+
*
|
|
17
|
+
* @param value - The value to clone.
|
|
18
|
+
* @param options - Optional transfer or serialization options.
|
|
19
|
+
* @returns A deep clone of the value.
|
|
20
|
+
*/
|
|
21
|
+
export declare const structuredClone: <T>(value: T, options?: StructuredSerializeOptions) => T;
|
|
22
|
+
/**
|
|
23
|
+
* (Safe copy) Creates a new MessageChannel using the captured constructor.
|
|
24
|
+
* MessageChannel provides two ports for bidirectional communication.
|
|
25
|
+
*
|
|
26
|
+
* @returns A new MessageChannel instance or undefined if not available.
|
|
27
|
+
*/
|
|
28
|
+
export declare const createMessageChannel: () => MessageChannel;
|
|
29
|
+
/**
|
|
30
|
+
* (Safe copy) Creates a new BroadcastChannel using the captured constructor.
|
|
31
|
+
* BroadcastChannel enables communication between browsing contexts with the same origin.
|
|
32
|
+
*
|
|
33
|
+
* @param name - Identifier for the broadcast channel that other contexts use to subscribe.
|
|
34
|
+
* @returns A new BroadcastChannel instance or undefined if not available.
|
|
35
|
+
*/
|
|
36
|
+
export declare const createBroadcastChannel: (name: string) => BroadcastChannel;
|
|
37
|
+
/**
|
|
38
|
+
* PostMessage options for Window.postMessage.
|
|
39
|
+
*/
|
|
40
|
+
export interface PostMessageToWindowOptions {
|
|
41
|
+
/**
|
|
42
|
+
* The target origin for the message (e.g., "https://example.com" or "*").
|
|
43
|
+
*/
|
|
44
|
+
targetOrigin: string;
|
|
45
|
+
/**
|
|
46
|
+
* Array of Transferable objects to transfer ownership.
|
|
47
|
+
*/
|
|
48
|
+
transfer?: Transferable[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* (Safe copy) Posts a message to a Window object using captured postMessage.
|
|
52
|
+
* This is a helper that wraps Window.postMessage for safe messaging.
|
|
53
|
+
*
|
|
54
|
+
* @param target - Destination window, iframe, or popup context.
|
|
55
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
56
|
+
* @param options - Target origin and optional transferables.
|
|
57
|
+
*/
|
|
58
|
+
export declare const postMessageToWindow: (target: Window, message: unknown, options: PostMessageToWindowOptions) => void;
|
|
59
|
+
/**
|
|
60
|
+
* (Safe copy) Posts a message to a Worker using captured postMessage.
|
|
61
|
+
*
|
|
62
|
+
* @param target - Web Worker or service worker instance.
|
|
63
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
64
|
+
* @param transfer - Optional array of Transferable objects.
|
|
65
|
+
*/
|
|
66
|
+
export declare const postMessageToWorker: (target: Worker, message: unknown, transfer?: Transferable[]) => void;
|
|
67
|
+
/**
|
|
68
|
+
* (Safe copy) Posts a message to a MessagePort.
|
|
69
|
+
*
|
|
70
|
+
* @param port - One end of a two-way communication channel.
|
|
71
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
72
|
+
* @param transfer - Optional array of Transferable objects.
|
|
73
|
+
*/
|
|
74
|
+
export declare const postMessageToPort: (port: MessagePort, message: unknown, transfer?: Transferable[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* (Safe copy) Posts a message to a BroadcastChannel.
|
|
77
|
+
*
|
|
78
|
+
* @param channel - Named broadcast channel for same-origin contexts.
|
|
79
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
80
|
+
*/
|
|
81
|
+
export declare const postMessageToBroadcast: (channel: BroadcastChannel, message: unknown) => void;
|
|
82
|
+
/**
|
|
83
|
+
* (Safe copy) Namespace object containing all Messaging functions.
|
|
84
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
85
|
+
*/
|
|
86
|
+
export declare const Messaging: Readonly<{
|
|
87
|
+
readonly structuredClone: <T>(value: T, options?: StructuredSerializeOptions) => T;
|
|
88
|
+
readonly createMessageChannel: () => MessageChannel;
|
|
89
|
+
readonly createBroadcastChannel: (name: string) => BroadcastChannel;
|
|
90
|
+
readonly postMessageToWindow: (target: Window, message: unknown, options: PostMessageToWindowOptions) => void;
|
|
91
|
+
readonly postMessageToWorker: (target: Worker, message: unknown, transfer?: Transferable[]) => void;
|
|
92
|
+
readonly postMessageToPort: (port: MessagePort, message: unknown, transfer?: Transferable[]) => void;
|
|
93
|
+
readonly postMessageToBroadcast: (channel: BroadcastChannel, message: unknown) => void;
|
|
94
|
+
}>;
|
|
95
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/messaging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GACvB,CAAC,SAAS,CAAC,YAAY,0BAA0B,KAAG,CAC5C,CAAA;AAEb;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,QACzB,cACK,CAAA;AAEb;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,SACxB,MAAM,KAAG,gBACP,CAAA;AAEb;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAA;CAC1B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,EAAE,SAAS,OAAO,EAAE,SAAS,0BAA0B,KAAG,IAE3G,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,EAAE,SAAS,OAAO,EAAE,WAAW,YAAY,EAAE,KAAG,IAMjG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,WAAW,EAAE,SAAS,OAAO,EAAE,WAAW,YAAY,EAAE,KAAG,IAMlG,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,gBAAgB,EAAE,SAAS,OAAO,KAAG,IAEpF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS;+BA/FjB,CAAC,SAAS,CAAC,YAAY,0BAA0B,KAAG,CAAC;yCAUlD,cAAc;4CAWX,MAAM,KAAG,gBAAgB;2CA0BQ,MAAM,WAAW,OAAO,WAAW,0BAA0B,KAAG,IAAI;2CAWpE,MAAM,WAAW,OAAO,aAAa,YAAY,EAAE,KAAG,IAAI;uCAe9D,WAAW,WAAW,OAAO,aAAa,YAAY,EAAE,KAAG,IAAI;+CAcvD,gBAAgB,WAAW,OAAO,KAAG,IAAI;EAgBvF,CAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Messaging/Communication built-in functions and constructors.
|
|
3
|
+
*
|
|
4
|
+
* These references are captured at module initialization time to protect against
|
|
5
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
6
|
+
*
|
|
7
|
+
* Note: `postMessage` is a method on specific objects (Window, Worker, MessagePort)
|
|
8
|
+
* rather than a global. This module provides factory functions for MessageChannel
|
|
9
|
+
* and BroadcastChannel, whose instances have safe postMessage methods.
|
|
10
|
+
*
|
|
11
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/messaging
|
|
12
|
+
*/
|
|
13
|
+
// Capture references at module initialization time
|
|
14
|
+
const _Reflect = globalThis.Reflect;
|
|
15
|
+
const _freeze = globalThis.Object.freeze;
|
|
16
|
+
const _structuredClone = typeof globalThis.structuredClone === 'function' ? globalThis.structuredClone : undefined;
|
|
17
|
+
const _MessageChannel = typeof globalThis.MessageChannel === 'function' ? globalThis.MessageChannel : undefined;
|
|
18
|
+
const _BroadcastChannel = typeof globalThis.BroadcastChannel === 'function' ? globalThis.BroadcastChannel : undefined;
|
|
19
|
+
/**
|
|
20
|
+
* (Safe copy) Creates a deep clone of a value using the structured clone algorithm.
|
|
21
|
+
* Available in modern browsers and Node.js 17+.
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to clone.
|
|
24
|
+
* @param options - Optional transfer or serialization options.
|
|
25
|
+
* @returns A deep clone of the value.
|
|
26
|
+
*/
|
|
27
|
+
const structuredClone = _structuredClone
|
|
28
|
+
? (value, options) => _structuredClone(value, options)
|
|
29
|
+
: undefined;
|
|
30
|
+
/**
|
|
31
|
+
* (Safe copy) Creates a new MessageChannel using the captured constructor.
|
|
32
|
+
* MessageChannel provides two ports for bidirectional communication.
|
|
33
|
+
*
|
|
34
|
+
* @returns A new MessageChannel instance or undefined if not available.
|
|
35
|
+
*/
|
|
36
|
+
const createMessageChannel = _MessageChannel
|
|
37
|
+
? () => _Reflect.construct(_MessageChannel, [])
|
|
38
|
+
: undefined;
|
|
39
|
+
/**
|
|
40
|
+
* (Safe copy) Creates a new BroadcastChannel using the captured constructor.
|
|
41
|
+
* BroadcastChannel enables communication between browsing contexts with the same origin.
|
|
42
|
+
*
|
|
43
|
+
* @param name - Identifier for the broadcast channel that other contexts use to subscribe.
|
|
44
|
+
* @returns A new BroadcastChannel instance or undefined if not available.
|
|
45
|
+
*/
|
|
46
|
+
const createBroadcastChannel = _BroadcastChannel
|
|
47
|
+
? (name) => _Reflect.construct(_BroadcastChannel, [name])
|
|
48
|
+
: undefined;
|
|
49
|
+
/**
|
|
50
|
+
* (Safe copy) Posts a message to a Window object using captured postMessage.
|
|
51
|
+
* This is a helper that wraps Window.postMessage for safe messaging.
|
|
52
|
+
*
|
|
53
|
+
* @param target - Destination window, iframe, or popup context.
|
|
54
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
55
|
+
* @param options - Target origin and optional transferables.
|
|
56
|
+
*/
|
|
57
|
+
const postMessageToWindow = (target, message, options) => {
|
|
58
|
+
target.postMessage(message, options.targetOrigin, options.transfer);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* (Safe copy) Posts a message to a Worker using captured postMessage.
|
|
62
|
+
*
|
|
63
|
+
* @param target - Web Worker or service worker instance.
|
|
64
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
65
|
+
* @param transfer - Optional array of Transferable objects.
|
|
66
|
+
*/
|
|
67
|
+
const postMessageToWorker = (target, message, transfer) => {
|
|
68
|
+
if (transfer) {
|
|
69
|
+
target.postMessage(message, transfer);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
target.postMessage(message);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* (Safe copy) Posts a message to a MessagePort.
|
|
77
|
+
*
|
|
78
|
+
* @param port - One end of a two-way communication channel.
|
|
79
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
80
|
+
* @param transfer - Optional array of Transferable objects.
|
|
81
|
+
*/
|
|
82
|
+
const postMessageToPort = (port, message, transfer) => {
|
|
83
|
+
if (transfer) {
|
|
84
|
+
port.postMessage(message, transfer);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
port.postMessage(message);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* (Safe copy) Posts a message to a BroadcastChannel.
|
|
92
|
+
*
|
|
93
|
+
* @param channel - Named broadcast channel for same-origin contexts.
|
|
94
|
+
* @param message - The data payload to send, must be structured-cloneable.
|
|
95
|
+
*/
|
|
96
|
+
const postMessageToBroadcast = (channel, message) => {
|
|
97
|
+
channel.postMessage(message);
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* (Safe copy) Namespace object containing all Messaging functions.
|
|
101
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
102
|
+
*/
|
|
103
|
+
const Messaging = _freeze({
|
|
104
|
+
structuredClone,
|
|
105
|
+
createMessageChannel,
|
|
106
|
+
createBroadcastChannel,
|
|
107
|
+
postMessageToWindow,
|
|
108
|
+
postMessageToWorker,
|
|
109
|
+
postMessageToPort,
|
|
110
|
+
postMessageToBroadcast,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export { Messaging, createBroadcastChannel, createMessageChannel, postMessageToBroadcast, postMessageToPort, postMessageToWindow, postMessageToWorker, structuredClone };
|
|
114
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/messaging/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;AAWG;AAEH;AACA,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;AACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM;AACxC,MAAM,gBAAgB,GAAG,OAAO,UAAU,CAAC,eAAe,KAAK,UAAU,GAAG,UAAU,CAAC,eAAe,GAAG,SAAS;AAClH,MAAM,eAAe,GAAG,OAAO,UAAU,CAAC,cAAc,KAAK,UAAU,GAAG,UAAU,CAAC,cAAc,GAAG,SAAS;AAC/G,MAAM,iBAAiB,GAAG,OAAO,UAAU,CAAC,gBAAgB,KAAK,UAAU,G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