@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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.1.1](https://github.com/AndrewRedican/hyperfrontend/compare/lib-immutable-api-utils@0.1.0...lib-immutable-api-utils@0.1.1) (2026-03-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **lib-immutable-api-utils:** handle built-in binding and jsdocs for fn overloads correctly ([da9ff90](https://github.com/AndrewRedican/hyperfrontend/commit/da9ff90ab29bfbdbdc03bb39585b09ca04772a57))
|
|
11
|
+
* **lib-immutable-api-utils:** use correct overload constructor for unit 8 array ([06bb617](https://github.com/AndrewRedican/hyperfrontend/commit/06bb6172a5af486b5500af1207365753fe221680))
|
|
12
|
+
|
|
13
|
+
## [0.1.0](https://github.com/AndrewRedican/hyperfrontend/compare/lib-immutable-api-utils@0.0.2...lib-immutable-api-utils@0.1.0) (2026-03-02)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **lib-immutable-api-utils:** builin copies for number generation and text encoding ([64e4190](https://github.com/AndrewRedican/hyperfrontend/commit/64e419007e301aa24f6f12ab6706637f6ce2ab0c))
|
|
19
|
+
* **lib-immutable-api-utils:** built-in copies for console, messaging, and timers ([f779670](https://github.com/AndrewRedican/hyperfrontend/commit/f7796708f4fa83dbf0142472e3dc16d0819102a7))
|
|
20
|
+
* **lib-immutable-api-utils:** freeze namespace exports ([cde3aae](https://github.com/AndrewRedican/hyperfrontend/commit/cde3aae4803cbbdd8415d663bc6c95e3d27c8de3))
|
|
21
|
+
* **lib-immutable-api-utils:** provide safe built-in copies for pollution mitigation ([37fd505](https://github.com/AndrewRedican/hyperfrontend/commit/37fd505dbe0152deb4f75a235c5b6e36a5741f88))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **lib-immutable-api-utils:** correct package exports ([f63960e](https://github.com/AndrewRedican/hyperfrontend/commit/f63960eb0302512ac420520db1610469377c0f58))
|
|
27
|
+
* **lib-immutable-api-utils:** handle built-in binding and jsdocs for fn overloads correctly ([da9ff90](https://github.com/AndrewRedican/hyperfrontend/commit/da9ff90ab29bfbdbdc03bb39585b09ca04772a57))
|
|
28
|
+
* **lib-immutable-api-utils:** restore index.ts file required entrypoint for iife and umd build ([de75fb5](https://github.com/AndrewRedican/hyperfrontend/commit/de75fb5f4f45eed3544a3039b45aedf51a4489bb))
|
|
29
|
+
* **lib-immutable-api-utils:** use correct overload constructor for unit 8 array ([06bb617](https://github.com/AndrewRedican/hyperfrontend/commit/06bb6172a5af486b5500af1207365753fe221680))
|
|
30
|
+
|
|
5
31
|
## [0.0.2](https://github.com/AndrewRedican/hyperfrontend/compare/lib-immutable-api-utils@0.0.1...lib-immutable-api-utils@0.0.2) (2026-02-26)
|
|
6
32
|
|
|
7
33
|
## 0.0.1 (2026-02-15)
|
package/README.md
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
<a href="https://www.npmjs.com/package/@hyperfrontend/immutable-api-utils">
|
|
11
11
|
<img src="https://img.shields.io/npm/v/@hyperfrontend/immutable-api-utils?style=flat-square" alt="npm version">
|
|
12
12
|
</a>
|
|
13
|
+
<a href="https://bundlephobia.com/package/@hyperfrontend/immutable-api-utils">
|
|
14
|
+
<img src="https://img.shields.io/bundlephobia/min/%40hyperfrontend%2Fimmutable-api-utils?style=flat-square" alt="npm bundle size">
|
|
15
|
+
</a>
|
|
13
16
|
</p>
|
|
14
17
|
<p align="center">
|
|
15
18
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
<img src="https://img.shields.io/badge/tree%20shakeable-%E2%9C%93-success?style=flat-square" alt="Tree Shakeable">
|
|
31
34
|
</p>
|
|
32
35
|
|
|
33
|
-
Decorators and utilities for creating immutable, tamper-proof object APIs.
|
|
36
|
+
Decorators and utilities for creating immutable, tamper-proof object APIs with built-in prototype pollution defense.
|
|
34
37
|
|
|
35
38
|
## What is @hyperfrontend/immutable-api-utils?
|
|
36
39
|
|
|
@@ -38,11 +41,14 @@ Decorators and utilities for creating immutable, tamper-proof object APIs.
|
|
|
38
41
|
|
|
39
42
|
The library offers three approaches: a TypeScript decorator (`@locked()`) for class methods, a functional API (`lockedProps()`) for bulk property locking, and descriptor builders (`lockedPropertyDescriptors()`) for granular control. All utilities enforce non-writable, non-configurable descriptors while maintaining correct `this` binding through per-instance caching.
|
|
40
43
|
|
|
44
|
+
Additionally, the library provides **safe built-in copies**—pre-captured references to JavaScript built-in methods that mitigate prototype pollution attacks when loaded early.
|
|
45
|
+
|
|
41
46
|
### Key Features
|
|
42
47
|
|
|
43
48
|
- **`@locked()` decorator** for TypeScript classes—prevents method overwriting and ensures correct `this` binding
|
|
44
49
|
- **Bulk property locking** via `lockedProps()` for multiple properties in one call
|
|
45
50
|
- **Property descriptor creation** with `lockedPropertyDescriptors()` for custom locking patterns
|
|
51
|
+
- **Safe built-in copies** via secondary entrypoints—captured at module load time before any pollution can occur
|
|
46
52
|
- **Per-instance binding cache** to avoid repeated `.bind()` calls
|
|
47
53
|
- **Zero runtime dependencies** - pure JavaScript property descriptor manipulation
|
|
48
54
|
|
|
@@ -50,6 +56,8 @@ The library offers three approaches: a TypeScript decorator (`@locked()`) for cl
|
|
|
50
56
|
|
|
51
57
|
The `@locked()` decorator uses Symbol-based caching to store bound methods per instance, avoiding the performance cost of repeated `.bind()` calls. Properties are marked `configurable: false` to prevent deletion or descriptor modification, and `writable: false` to block reassignment.
|
|
52
58
|
|
|
59
|
+
The safe built-in copies are captured at module initialization time. **Important:** This only works if the module loads before any malicious code runs—it mitigates pollution, not prevents it retroactively.
|
|
60
|
+
|
|
53
61
|
## Why Use @hyperfrontend/immutable-api-utils?
|
|
54
62
|
|
|
55
63
|
### Prevents Accidental API Tampering in Shared Contexts
|
|
@@ -131,6 +139,57 @@ Object.defineProperty(obj, 'version', lockedPropertyDescriptors('1.0.0', true))
|
|
|
131
139
|
- **`lockedProps(object, pairs)`** - Lock multiple properties on an object with key-value pairs
|
|
132
140
|
- **`lockedPropertyDescriptors(value, enumerable?)`** - Create a locked property descriptor for manual use with `Object.defineProperty`
|
|
133
141
|
|
|
142
|
+
### Safe Built-in Copies
|
|
143
|
+
|
|
144
|
+
Pre-captured references to JavaScript built-ins via secondary entrypoints. Available modules:
|
|
145
|
+
|
|
146
|
+
| Entrypoint | Description |
|
|
147
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
148
|
+
| `built-in-copy/object` | Object static methods (`freeze`, `keys`, `entries`, etc.) |
|
|
149
|
+
| `built-in-copy/array` | Array static methods (`isArray`, `from`, `of`) |
|
|
150
|
+
| `built-in-copy/json` | JSON methods (`parse`, `stringify`) |
|
|
151
|
+
| `built-in-copy/promise` | Promise static methods and factory (`createPromise`, `all`, `race`, etc.) |
|
|
152
|
+
| `built-in-copy/console` | Console methods (`log`, `warn`, `error`, `info`, `debug`, etc.) |
|
|
153
|
+
| `built-in-copy/timers` | Timer functions (`setTimeout`, `setInterval`, `queueMicrotask`, `requestAnimationFrame`, etc.) |
|
|
154
|
+
| `built-in-copy/messaging` | Messaging APIs (`structuredClone`, `createMessageChannel`, `createBroadcastChannel`, `postMessage*` helpers) |
|
|
155
|
+
| `built-in-copy/encoding` | Encoding APIs (`createTextEncoder`, `createTextDecoder`, `atob`, `btoa`) |
|
|
156
|
+
| `built-in-copy/typed-arrays` | Typed arrays and buffers (`createUint8Array`, `createArrayBuffer`, `createDataView`, etc.) |
|
|
157
|
+
| `built-in-copy/url` | URL APIs (`createURL`, `createURLSearchParams`, `canParse`, `createObjectURL`, etc.) |
|
|
158
|
+
| `built-in-copy/websocket` | WebSocket factory (`createWebSocket`, ready state constants) |
|
|
159
|
+
| `built-in-copy/math` | Math methods and constants (`random`, `floor`, `ceil`, `PI`, etc.) |
|
|
160
|
+
| `built-in-copy/number` | Number methods and constants (`isNaN`, `parseInt`, `parseFloat`, `MAX_SAFE_INTEGER`, etc.) |
|
|
161
|
+
| `built-in-copy/string` | String static methods (`fromCharCode`, `fromCodePoint`, `raw`) |
|
|
162
|
+
| `built-in-copy/reflect` | Reflect methods |
|
|
163
|
+
| `built-in-copy/function` | Function utilities |
|
|
164
|
+
| `built-in-copy/symbol` | Symbol static methods |
|
|
165
|
+
| `built-in-copy/map` | Map constructor factory |
|
|
166
|
+
| `built-in-copy/set` | Set constructor factory |
|
|
167
|
+
| `built-in-copy/weak-map` | WeakMap constructor factory |
|
|
168
|
+
| `built-in-copy/weak-set` | WeakSet constructor factory |
|
|
169
|
+
| `built-in-copy/regexp` | RegExp constructor factory |
|
|
170
|
+
| `built-in-copy/date` | Date constructor factory |
|
|
171
|
+
| `built-in-copy/error` | Error constructor factories |
|
|
172
|
+
|
|
173
|
+
**Limitations:**
|
|
174
|
+
|
|
175
|
+
- Only effective if imported before any untrusted code executes
|
|
176
|
+
- Does not protect against pollution that occurred before module load
|
|
177
|
+
- Best used as an early import in application entry points
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
// Import early in your entry point
|
|
181
|
+
import { freeze, keys } from '@hyperfrontend/immutable-api-utils/built-in-copy/object'
|
|
182
|
+
import { parse } from '@hyperfrontend/immutable-api-utils/built-in-copy/json'
|
|
183
|
+
import { log, warn } from '@hyperfrontend/immutable-api-utils/built-in-copy/console'
|
|
184
|
+
import { setTimeout } from '@hyperfrontend/immutable-api-utils/built-in-copy/timers'
|
|
185
|
+
import { structuredClone, createMessageChannel } from '@hyperfrontend/immutable-api-utils/built-in-copy/messaging'
|
|
186
|
+
|
|
187
|
+
const config = freeze({ api: 'https://example.com' })
|
|
188
|
+
const data = parse('{"key": "value"}')
|
|
189
|
+
log('Config loaded:', config)
|
|
190
|
+
setTimeout(() => log('Delayed message'), 1000)
|
|
191
|
+
```
|
|
192
|
+
|
|
134
193
|
## Use Cases
|
|
135
194
|
|
|
136
195
|
- **Plugin APIs**: Prevent plugins from modifying core library methods
|
|
@@ -138,7 +197,10 @@ Object.defineProperty(obj, 'version', lockedPropertyDescriptors('1.0.0', true))
|
|
|
138
197
|
- **Configuration objects**: Lock critical config values after initialization
|
|
139
198
|
- **Public library interfaces**: Protect exported classes from mutation
|
|
140
199
|
- **Event emitters**: Prevent handler list manipulation
|
|
141
|
-
- **Prototype pollution
|
|
200
|
+
- **Prototype pollution mitigation**: Safe built-in copies reduce attack surface when loaded early
|
|
201
|
+
- **Secure logging**: Use safe `console` copies to prevent tampered log output
|
|
202
|
+
- **Safe timers**: Prevent timer functions from being hijacked
|
|
203
|
+
- **Cross-origin messaging**: Secure `postMessage` wrappers with captured references
|
|
142
204
|
|
|
143
205
|
## Compatibility
|
|
144
206
|
|
|
@@ -158,7 +220,7 @@ Object.defineProperty(obj, 'version', lockedPropertyDescriptors('1.0.0', true))
|
|
|
158
220
|
| IIFE | `bundle/index.iife.min.js` | ❌ |
|
|
159
221
|
| UMD | `bundle/index.umd.min.js` | ❌ |
|
|
160
222
|
|
|
161
|
-
|
|
223
|
+
Secondary entrypoints (`built-in-copy/*`) are individually tree-shakeable—import only the built-ins you need.
|
|
162
224
|
|
|
163
225
|
### CDN Usage
|
|
164
226
|
|
|
@@ -170,7 +232,7 @@ Object.defineProperty(obj, 'version', lockedPropertyDescriptors('1.0.0', true))
|
|
|
170
232
|
<script src="https://cdn.jsdelivr.net/npm/@hyperfrontend/immutable-api-utils"></script>
|
|
171
233
|
|
|
172
234
|
<script>
|
|
173
|
-
const {
|
|
235
|
+
const { locked, lockedProps, lockedPropertyDescriptors } = HyperfrontendImmutableApiUtils
|
|
174
236
|
</script>
|
|
175
237
|
```
|
|
176
238
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Safe copies of Array built-in static methods.
|
|
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
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
10
|
+
*/
|
|
11
|
+
// Capture references at module initialization time
|
|
12
|
+
const _Array = globalThis.Array;
|
|
13
|
+
const _freeze = globalThis.Object.freeze;
|
|
14
|
+
/**
|
|
15
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
16
|
+
*/
|
|
17
|
+
const isArray = _Array.isArray;
|
|
18
|
+
/**
|
|
19
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
20
|
+
*/
|
|
21
|
+
const from = _Array.from;
|
|
22
|
+
/**
|
|
23
|
+
* (Safe copy) Creates a new Array instance from a variable number of arguments.
|
|
24
|
+
*/
|
|
25
|
+
const of = _Array.of;
|
|
26
|
+
/**
|
|
27
|
+
* (Safe copy) Namespace object containing all Array static methods.
|
|
28
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
29
|
+
*/
|
|
30
|
+
const Array = _freeze({
|
|
31
|
+
isArray,
|
|
32
|
+
from,
|
|
33
|
+
of,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
exports.Array = Array;
|
|
37
|
+
exports.from = from;
|
|
38
|
+
exports.isArray = isArray;
|
|
39
|
+
exports.of = of;
|
|
40
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK;AAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM;AAExC;;AAEG;AACI,MAAM,OAAO,GAAG,MAAM,CAAC;AAE9B;;AAEG;AACI,MAAM,IAAI,GAAG,MAAM,CAAC;AAE3B;;AAEG;AACI,MAAM,EAAE,GAAG,MAAM,CAAC;AAEzB;;;AAGG;AACI,MAAM,KAAK,GAAG,OAAO,CAAQ;IAClC,OAAO;IACP,IAAI;IACJ,EAAE;AACH,CAAA;;;;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Array built-in static 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/array
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isArray: (arg: any) => arg is any[];
|
|
13
|
+
/**
|
|
14
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
15
|
+
*/
|
|
16
|
+
export declare const from: {
|
|
17
|
+
<T>(arrayLike: ArrayLike<T>): T[];
|
|
18
|
+
<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
19
|
+
<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
20
|
+
<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* (Safe copy) Creates a new Array instance from a variable number of arguments.
|
|
24
|
+
*/
|
|
25
|
+
export declare const of: <T>(...items: T[]) => T[];
|
|
26
|
+
/**
|
|
27
|
+
* (Safe copy) Namespace object containing all Array static methods.
|
|
28
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
29
|
+
*/
|
|
30
|
+
export declare const Array: Readonly<{
|
|
31
|
+
readonly isArray: (arg: any) => arg is any[];
|
|
32
|
+
readonly from: {
|
|
33
|
+
<T>(arrayLike: ArrayLike<T>): T[];
|
|
34
|
+
<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
35
|
+
<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
36
|
+
<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
37
|
+
};
|
|
38
|
+
readonly of: <T>(...items: T[]) => T[];
|
|
39
|
+
}>;
|
|
40
|
+
//# 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/array/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,eAAO,MAAM,OAAO,4BAAiB,CAAA;AAErC;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;CAAc,CAAA;AAE/B;;GAEG;AACH,eAAO,MAAM,EAAE,2BAAY,CAAA;AAE3B;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;;;;;;EAIhB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Array built-in static 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/array
|
|
8
|
+
*/
|
|
9
|
+
// Capture references at module initialization time
|
|
10
|
+
const _Array = globalThis.Array;
|
|
11
|
+
const _freeze = globalThis.Object.freeze;
|
|
12
|
+
/**
|
|
13
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
14
|
+
*/
|
|
15
|
+
const isArray = _Array.isArray;
|
|
16
|
+
/**
|
|
17
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
18
|
+
*/
|
|
19
|
+
const from = _Array.from;
|
|
20
|
+
/**
|
|
21
|
+
* (Safe copy) Creates a new Array instance from a variable number of arguments.
|
|
22
|
+
*/
|
|
23
|
+
const of = _Array.of;
|
|
24
|
+
/**
|
|
25
|
+
* (Safe copy) Namespace object containing all Array static methods.
|
|
26
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
27
|
+
*/
|
|
28
|
+
const Array = _freeze({
|
|
29
|
+
isArray,
|
|
30
|
+
from,
|
|
31
|
+
of,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export { Array, from, isArray, of };
|
|
35
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK;AAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM;AAExC;;AAEG;AACI,MAAM,OAAO,GAAG,MAAM,CAAC;AAE9B;;AAEG;AACI,MAAM,IAAI,GAAG,MAAM,CAAC;AAE3B;;AAEG;AACI,MAAM,EAAE,GAAG,MAAM,CAAC;AAEzB;;;AAGG;AACI,MAAM,KAAK,GAAG,OAAO,CAAQ;IAClC,OAAO;IACP,IAAI;IACJ,EAAE;AACH,CAAA;;;;"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Safe copies of Console built-in methods.
|
|
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
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/console
|
|
10
|
+
*/
|
|
11
|
+
// Capture references at module initialization time
|
|
12
|
+
const _console = globalThis.console;
|
|
13
|
+
const _freeze = globalThis.Object.freeze;
|
|
14
|
+
/**
|
|
15
|
+
* (Safe copy) Outputs a message to the console.
|
|
16
|
+
*/
|
|
17
|
+
const log = _console.log.bind(_console);
|
|
18
|
+
/**
|
|
19
|
+
* (Safe copy) Outputs a warning message to the console.
|
|
20
|
+
*/
|
|
21
|
+
const warn = _console.warn.bind(_console);
|
|
22
|
+
/**
|
|
23
|
+
* (Safe copy) Outputs an error message to the console.
|
|
24
|
+
*/
|
|
25
|
+
const error = _console.error.bind(_console);
|
|
26
|
+
/**
|
|
27
|
+
* (Safe copy) Outputs an informational message to the console.
|
|
28
|
+
*/
|
|
29
|
+
const info = _console.info.bind(_console);
|
|
30
|
+
/**
|
|
31
|
+
* (Safe copy) Outputs a debug message to the console.
|
|
32
|
+
*/
|
|
33
|
+
const debug = _console.debug.bind(_console);
|
|
34
|
+
/**
|
|
35
|
+
* (Safe copy) Outputs a stack trace to the console.
|
|
36
|
+
*/
|
|
37
|
+
const trace = _console.trace.bind(_console);
|
|
38
|
+
/**
|
|
39
|
+
* (Safe copy) Displays an interactive listing of the properties of a specified object.
|
|
40
|
+
*/
|
|
41
|
+
const dir = _console.dir.bind(_console);
|
|
42
|
+
/**
|
|
43
|
+
* (Safe copy) Displays tabular data as a table.
|
|
44
|
+
*/
|
|
45
|
+
const table = _console.table.bind(_console);
|
|
46
|
+
/**
|
|
47
|
+
* (Safe copy) Writes an error message to the console if the assertion is false.
|
|
48
|
+
*/
|
|
49
|
+
const assert = _console.assert.bind(_console);
|
|
50
|
+
/**
|
|
51
|
+
* (Safe copy) Clears the console.
|
|
52
|
+
*/
|
|
53
|
+
const clear = _console.clear.bind(_console);
|
|
54
|
+
/**
|
|
55
|
+
* (Safe copy) Logs the number of times that this particular call to count() has been called.
|
|
56
|
+
*/
|
|
57
|
+
const count = _console.count.bind(_console);
|
|
58
|
+
/**
|
|
59
|
+
* (Safe copy) Resets the counter used with console.count().
|
|
60
|
+
*/
|
|
61
|
+
const countReset = _console.countReset.bind(_console);
|
|
62
|
+
/**
|
|
63
|
+
* (Safe copy) Creates a new inline group in the console.
|
|
64
|
+
*/
|
|
65
|
+
const group = _console.group.bind(_console);
|
|
66
|
+
/**
|
|
67
|
+
* (Safe copy) Creates a new inline group in the console that is initially collapsed.
|
|
68
|
+
*/
|
|
69
|
+
const groupCollapsed = _console.groupCollapsed.bind(_console);
|
|
70
|
+
/**
|
|
71
|
+
* (Safe copy) Exits the current inline group.
|
|
72
|
+
*/
|
|
73
|
+
const groupEnd = _console.groupEnd.bind(_console);
|
|
74
|
+
/**
|
|
75
|
+
* (Safe copy) Starts a timer with a name specified as an input parameter.
|
|
76
|
+
*/
|
|
77
|
+
const time = _console.time.bind(_console);
|
|
78
|
+
/**
|
|
79
|
+
* (Safe copy) Stops a timer that was previously started.
|
|
80
|
+
*/
|
|
81
|
+
const timeEnd = _console.timeEnd.bind(_console);
|
|
82
|
+
/**
|
|
83
|
+
* (Safe copy) Logs the current value of a timer that was previously started.
|
|
84
|
+
*/
|
|
85
|
+
const timeLog = _console.timeLog.bind(_console);
|
|
86
|
+
/**
|
|
87
|
+
* (Safe copy) Namespace object containing all Console methods.
|
|
88
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
89
|
+
*/
|
|
90
|
+
const Console = _freeze({
|
|
91
|
+
log,
|
|
92
|
+
warn,
|
|
93
|
+
error,
|
|
94
|
+
info,
|
|
95
|
+
debug,
|
|
96
|
+
trace,
|
|
97
|
+
dir,
|
|
98
|
+
table,
|
|
99
|
+
assert,
|
|
100
|
+
clear,
|
|
101
|
+
count,
|
|
102
|
+
countReset,
|
|
103
|
+
group,
|
|
104
|
+
groupCollapsed,
|
|
105
|
+
groupEnd,
|
|
106
|
+
time,
|
|
107
|
+
timeEnd,
|
|
108
|
+
timeLog,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
exports.Console = Console;
|
|
112
|
+
exports.assert = assert;
|
|
113
|
+
exports.clear = clear;
|
|
114
|
+
exports.count = count;
|
|
115
|
+
exports.countReset = countReset;
|
|
116
|
+
exports.debug = debug;
|
|
117
|
+
exports.dir = dir;
|
|
118
|
+
exports.error = error;
|
|
119
|
+
exports.group = group;
|
|
120
|
+
exports.groupCollapsed = groupCollapsed;
|
|
121
|
+
exports.groupEnd = groupEnd;
|
|
122
|
+
exports.info = info;
|
|
123
|
+
exports.log = log;
|
|
124
|
+
exports.table = table;
|
|
125
|
+
exports.time = time;
|
|
126
|
+
exports.timeEnd = timeEnd;
|
|
127
|
+
exports.timeLog = timeLog;
|
|
128
|
+
exports.trace = trace;
|
|
129
|
+
exports.warn = warn;
|
|
130
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/console/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;AACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM;AAExC;;AAEG;AACI,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;AAE7C;;AAEG;AACI,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;AAE/C;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;AAE/C;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;AAE7C;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ;AAEnD;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ;AAE3D;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ;AAEnE;;AAEG;AACI,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ;AAEvD;;AAEG;AACI,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;AAE/C;;AAEG;AACI,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ;AAErD;;AAEG;AACI,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ;AAErD;;;AAGG;AACI,MAAM,OAAO,GAAG,OAAO,CAAQ;IACpC,GAAG;IACH,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,KAAK;IACL,GAAG;IACH,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,UAAU;IACV,KAAK;IACL,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,OAAO;IACP,OAAO;AACR,CAAA;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Console 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/console
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* (Safe copy) Outputs a message to the console.
|
|
11
|
+
*/
|
|
12
|
+
export declare const log: any;
|
|
13
|
+
/**
|
|
14
|
+
* (Safe copy) Outputs a warning message to the console.
|
|
15
|
+
*/
|
|
16
|
+
export declare const warn: any;
|
|
17
|
+
/**
|
|
18
|
+
* (Safe copy) Outputs an error message to the console.
|
|
19
|
+
*/
|
|
20
|
+
export declare const error: any;
|
|
21
|
+
/**
|
|
22
|
+
* (Safe copy) Outputs an informational message to the console.
|
|
23
|
+
*/
|
|
24
|
+
export declare const info: any;
|
|
25
|
+
/**
|
|
26
|
+
* (Safe copy) Outputs a debug message to the console.
|
|
27
|
+
*/
|
|
28
|
+
export declare const debug: any;
|
|
29
|
+
/**
|
|
30
|
+
* (Safe copy) Outputs a stack trace to the console.
|
|
31
|
+
*/
|
|
32
|
+
export declare const trace: any;
|
|
33
|
+
/**
|
|
34
|
+
* (Safe copy) Displays an interactive listing of the properties of a specified object.
|
|
35
|
+
*/
|
|
36
|
+
export declare const dir: any;
|
|
37
|
+
/**
|
|
38
|
+
* (Safe copy) Displays tabular data as a table.
|
|
39
|
+
*/
|
|
40
|
+
export declare const table: any;
|
|
41
|
+
/**
|
|
42
|
+
* (Safe copy) Writes an error message to the console if the assertion is false.
|
|
43
|
+
*/
|
|
44
|
+
export declare const assert: any;
|
|
45
|
+
/**
|
|
46
|
+
* (Safe copy) Clears the console.
|
|
47
|
+
*/
|
|
48
|
+
export declare const clear: any;
|
|
49
|
+
/**
|
|
50
|
+
* (Safe copy) Logs the number of times that this particular call to count() has been called.
|
|
51
|
+
*/
|
|
52
|
+
export declare const count: any;
|
|
53
|
+
/**
|
|
54
|
+
* (Safe copy) Resets the counter used with console.count().
|
|
55
|
+
*/
|
|
56
|
+
export declare const countReset: any;
|
|
57
|
+
/**
|
|
58
|
+
* (Safe copy) Creates a new inline group in the console.
|
|
59
|
+
*/
|
|
60
|
+
export declare const group: any;
|
|
61
|
+
/**
|
|
62
|
+
* (Safe copy) Creates a new inline group in the console that is initially collapsed.
|
|
63
|
+
*/
|
|
64
|
+
export declare const groupCollapsed: any;
|
|
65
|
+
/**
|
|
66
|
+
* (Safe copy) Exits the current inline group.
|
|
67
|
+
*/
|
|
68
|
+
export declare const groupEnd: any;
|
|
69
|
+
/**
|
|
70
|
+
* (Safe copy) Starts a timer with a name specified as an input parameter.
|
|
71
|
+
*/
|
|
72
|
+
export declare const time: any;
|
|
73
|
+
/**
|
|
74
|
+
* (Safe copy) Stops a timer that was previously started.
|
|
75
|
+
*/
|
|
76
|
+
export declare const timeEnd: any;
|
|
77
|
+
/**
|
|
78
|
+
* (Safe copy) Logs the current value of a timer that was previously started.
|
|
79
|
+
*/
|
|
80
|
+
export declare const timeLog: any;
|
|
81
|
+
/**
|
|
82
|
+
* (Safe copy) Namespace object containing all Console methods.
|
|
83
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
84
|
+
*/
|
|
85
|
+
export declare const Console: Readonly<{
|
|
86
|
+
readonly log: any;
|
|
87
|
+
readonly warn: any;
|
|
88
|
+
readonly error: any;
|
|
89
|
+
readonly info: any;
|
|
90
|
+
readonly debug: any;
|
|
91
|
+
readonly trace: any;
|
|
92
|
+
readonly dir: any;
|
|
93
|
+
readonly table: any;
|
|
94
|
+
readonly assert: any;
|
|
95
|
+
readonly clear: any;
|
|
96
|
+
readonly count: any;
|
|
97
|
+
readonly countReset: any;
|
|
98
|
+
readonly group: any;
|
|
99
|
+
readonly groupCollapsed: any;
|
|
100
|
+
readonly groupEnd: any;
|
|
101
|
+
readonly time: any;
|
|
102
|
+
readonly timeEnd: any;
|
|
103
|
+
readonly timeLog: any;
|
|
104
|
+
}>;
|
|
105
|
+
//# 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/console/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,eAAO,MAAM,GAAG,KAA8B,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,IAAI,KAA+B,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,KAAK,KAAgC,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,IAAI,KAA+B,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,KAAK,KAAgC,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,KAAK,KAAgC,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,GAAG,KAA8B,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,KAAK,KAAgC,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,MAAM,KAAiC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,KAAK,KAAgC,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,KAAK,KAAgC,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,UAAU,KAAqC,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAM,KAAK,KAAgC,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,cAAc,KAAyC,CAAA;AAEpE;;GAEG;AACH,eAAO,MAAM,QAAQ,KAAmC,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,IAAI,KAA+B,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,OAAO,KAAkC,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,OAAO,KAAkC,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;EAmBlB,CAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Console 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/console
|
|
8
|
+
*/
|
|
9
|
+
// Capture references at module initialization time
|
|
10
|
+
const _console = globalThis.console;
|
|
11
|
+
const _freeze = globalThis.Object.freeze;
|
|
12
|
+
/**
|
|
13
|
+
* (Safe copy) Outputs a message to the console.
|
|
14
|
+
*/
|
|
15
|
+
const log = _console.log.bind(_console);
|
|
16
|
+
/**
|
|
17
|
+
* (Safe copy) Outputs a warning message to the console.
|
|
18
|
+
*/
|
|
19
|
+
const warn = _console.warn.bind(_console);
|
|
20
|
+
/**
|
|
21
|
+
* (Safe copy) Outputs an error message to the console.
|
|
22
|
+
*/
|
|
23
|
+
const error = _console.error.bind(_console);
|
|
24
|
+
/**
|
|
25
|
+
* (Safe copy) Outputs an informational message to the console.
|
|
26
|
+
*/
|
|
27
|
+
const info = _console.info.bind(_console);
|
|
28
|
+
/**
|
|
29
|
+
* (Safe copy) Outputs a debug message to the console.
|
|
30
|
+
*/
|
|
31
|
+
const debug = _console.debug.bind(_console);
|
|
32
|
+
/**
|
|
33
|
+
* (Safe copy) Outputs a stack trace to the console.
|
|
34
|
+
*/
|
|
35
|
+
const trace = _console.trace.bind(_console);
|
|
36
|
+
/**
|
|
37
|
+
* (Safe copy) Displays an interactive listing of the properties of a specified object.
|
|
38
|
+
*/
|
|
39
|
+
const dir = _console.dir.bind(_console);
|
|
40
|
+
/**
|
|
41
|
+
* (Safe copy) Displays tabular data as a table.
|
|
42
|
+
*/
|
|
43
|
+
const table = _console.table.bind(_console);
|
|
44
|
+
/**
|
|
45
|
+
* (Safe copy) Writes an error message to the console if the assertion is false.
|
|
46
|
+
*/
|
|
47
|
+
const assert = _console.assert.bind(_console);
|
|
48
|
+
/**
|
|
49
|
+
* (Safe copy) Clears the console.
|
|
50
|
+
*/
|
|
51
|
+
const clear = _console.clear.bind(_console);
|
|
52
|
+
/**
|
|
53
|
+
* (Safe copy) Logs the number of times that this particular call to count() has been called.
|
|
54
|
+
*/
|
|
55
|
+
const count = _console.count.bind(_console);
|
|
56
|
+
/**
|
|
57
|
+
* (Safe copy) Resets the counter used with console.count().
|
|
58
|
+
*/
|
|
59
|
+
const countReset = _console.countReset.bind(_console);
|
|
60
|
+
/**
|
|
61
|
+
* (Safe copy) Creates a new inline group in the console.
|
|
62
|
+
*/
|
|
63
|
+
const group = _console.group.bind(_console);
|
|
64
|
+
/**
|
|
65
|
+
* (Safe copy) Creates a new inline group in the console that is initially collapsed.
|
|
66
|
+
*/
|
|
67
|
+
const groupCollapsed = _console.groupCollapsed.bind(_console);
|
|
68
|
+
/**
|
|
69
|
+
* (Safe copy) Exits the current inline group.
|
|
70
|
+
*/
|
|
71
|
+
const groupEnd = _console.groupEnd.bind(_console);
|
|
72
|
+
/**
|
|
73
|
+
* (Safe copy) Starts a timer with a name specified as an input parameter.
|
|
74
|
+
*/
|
|
75
|
+
const time = _console.time.bind(_console);
|
|
76
|
+
/**
|
|
77
|
+
* (Safe copy) Stops a timer that was previously started.
|
|
78
|
+
*/
|
|
79
|
+
const timeEnd = _console.timeEnd.bind(_console);
|
|
80
|
+
/**
|
|
81
|
+
* (Safe copy) Logs the current value of a timer that was previously started.
|
|
82
|
+
*/
|
|
83
|
+
const timeLog = _console.timeLog.bind(_console);
|
|
84
|
+
/**
|
|
85
|
+
* (Safe copy) Namespace object containing all Console methods.
|
|
86
|
+
* Note: Importing this imports all methods in this namespace (no tree-shaking).
|
|
87
|
+
*/
|
|
88
|
+
const Console = _freeze({
|
|
89
|
+
log,
|
|
90
|
+
warn,
|
|
91
|
+
error,
|
|
92
|
+
info,
|
|
93
|
+
debug,
|
|
94
|
+
trace,
|
|
95
|
+
dir,
|
|
96
|
+
table,
|
|
97
|
+
assert,
|
|
98
|
+
clear,
|
|
99
|
+
count,
|
|
100
|
+
countReset,
|
|
101
|
+
group,
|
|
102
|
+
groupCollapsed,
|
|
103
|
+
groupEnd,
|
|
104
|
+
time,
|
|
105
|
+
timeEnd,
|
|
106
|
+
timeLog,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export { Console, assert, clear, count, countReset, debug, dir, error, group, groupCollapsed, groupEnd, info, log, table, time, timeEnd, timeLog, trace, warn };
|
|
110
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/console/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;AACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM;AAExC;;AAEG;AACI,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;AAE7C;;AAEG;AACI,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;AAE/C;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;AAE/C;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;AAE7C;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ;AAEnD;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ;AAE3D;;AAEG;AACI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ;AAEjD;;AAEG;AACI,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ;AAEnE;;AAEG;AACI,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ;AAEvD;;AAEG;AACI,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;AAE/C;;AAEG;AACI,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ;AAErD;;AAEG;AACI,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ;AAErD;;;AAGG;AACI,MAAM,OAAO,GAAG,OAAO,CAAQ;IACpC,GAAG;IACH,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,KAAK;IACL,GAAG;IACH,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,UAAU;IACV,KAAK;IACL,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,OAAO;IACP,OAAO;AACR,CAAA;;;;"}
|