@elementor/utils 0.2.0 → 0.2.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 +6 -0
- package/package.json +10 -3
- package/.turbo/turbo-build.log +0 -22
- package/src/errors/__tests__/index.test.tsx +0 -70
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.2.1](https://github.com/elementor/elementor-packages/compare/@elementor/utils@0.2.0...@elementor/utils@0.2.1) (2024-08-05)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- publish only necessary files to npm ([#226](https://github.com/elementor/elementor-packages/issues/226)) ([d808e2f](https://github.com/elementor/elementor-packages/commit/d808e2f60eb7ca2d7b8560d0b79c0e62c2f969a8))
|
|
11
|
+
|
|
6
12
|
# [0.2.0](https://github.com/elementor/elementor-packages/compare/@elementor/utils@0.1.0...@elementor/utils@0.2.0) (2024-07-28)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/utils",
|
|
3
3
|
"description": "This package contains utility functions that are being used across the Elementor packages",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/elementor/elementor-packages.git",
|
|
22
|
+
"url": "git+https://github.com/elementor/elementor-packages.git",
|
|
23
23
|
"directory": "packages/libs/utils"
|
|
24
24
|
},
|
|
25
25
|
"bugs": {
|
|
@@ -28,9 +28,16 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
+
"files": [
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
34
|
+
"/dist",
|
|
35
|
+
"/src",
|
|
36
|
+
"!**/__tests__"
|
|
37
|
+
],
|
|
31
38
|
"scripts": {
|
|
32
39
|
"build": "tsup --config=../../tsup.build.ts",
|
|
33
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
34
41
|
},
|
|
35
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "f4ca33da0842a29d83736d0a173633085edddaee"
|
|
36
43
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @elementor/utils@0.1.0 build
|
|
3
|
-
> tsup --config=../../tsup.build.ts
|
|
4
|
-
|
|
5
|
-
CLI Building entry: src/index.ts
|
|
6
|
-
CLI Using tsconfig: ../../../tsconfig.json
|
|
7
|
-
CLI tsup v7.2.0
|
|
8
|
-
CLI Using tsup config: /home/runner/work/elementor-packages/elementor-packages/tsup.build.ts
|
|
9
|
-
CLI Target: esnext
|
|
10
|
-
CLI Cleaning output folder
|
|
11
|
-
ESM Build start
|
|
12
|
-
CJS Build start
|
|
13
|
-
ESM dist/index.mjs 922.00 B
|
|
14
|
-
ESM dist/index.mjs.map 2.13 KB
|
|
15
|
-
ESM ⚡️ Build success in 114ms
|
|
16
|
-
CJS dist/index.js 1.97 KB
|
|
17
|
-
CJS dist/index.js.map 2.35 KB
|
|
18
|
-
CJS ⚡️ Build success in 115ms
|
|
19
|
-
DTS Build start
|
|
20
|
-
DTS ⚡️ Build success in 22795ms
|
|
21
|
-
DTS dist/index.d.mts 1.24 KB
|
|
22
|
-
DTS dist/index.d.ts 1.24 KB
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createError } from '../create-error';
|
|
2
|
-
import { ElementorError } from '../elementor-error';
|
|
3
|
-
import { ensureError } from '../ensure-error';
|
|
4
|
-
|
|
5
|
-
describe( 'createError', () => {
|
|
6
|
-
it( 'should return an error class with the correct code and message', () => {
|
|
7
|
-
type CustomErrorContext = {
|
|
8
|
-
customField: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// Arrange.
|
|
12
|
-
const code = 'test-error';
|
|
13
|
-
const message = 'This is a test error';
|
|
14
|
-
const CustomError = createError< CustomErrorContext >( { code, message } );
|
|
15
|
-
|
|
16
|
-
// Act.
|
|
17
|
-
const error = new CustomError( {
|
|
18
|
-
cause: new Error( 'internal' ),
|
|
19
|
-
context: { customField: 'customValue' },
|
|
20
|
-
} );
|
|
21
|
-
|
|
22
|
-
// Assert.
|
|
23
|
-
expect( error ).toBeInstanceOf( ElementorError );
|
|
24
|
-
|
|
25
|
-
expect( error.code ).toBe( code );
|
|
26
|
-
expect( error.message ).toBe( message );
|
|
27
|
-
expect( error.context ).toEqual( { customField: 'customValue' } );
|
|
28
|
-
expect( error.cause ).toEqual( new Error( 'internal' ) );
|
|
29
|
-
} );
|
|
30
|
-
} );
|
|
31
|
-
|
|
32
|
-
describe( 'ensureError', () => {
|
|
33
|
-
it( 'should return the same error instance when the input is an error', () => {
|
|
34
|
-
// Arrange.
|
|
35
|
-
const TestError = createError( { code: 'test-error', message: 'This is a test error' } );
|
|
36
|
-
const error = new TestError();
|
|
37
|
-
|
|
38
|
-
// Act.
|
|
39
|
-
const result = ensureError( error );
|
|
40
|
-
|
|
41
|
-
// Assert.
|
|
42
|
-
expect( result ).toBe( error );
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
it( 'should return an error with the stringified input in the error message when the input is not an error', () => {
|
|
46
|
-
// Arrange.
|
|
47
|
-
const errorObject = { message: 'test error' };
|
|
48
|
-
const expectedMessage = JSON.stringify( errorObject );
|
|
49
|
-
|
|
50
|
-
// Act.
|
|
51
|
-
const result = ensureError( errorObject );
|
|
52
|
-
|
|
53
|
-
// Assert.
|
|
54
|
-
expect( result ).toBeInstanceOf( Error );
|
|
55
|
-
expect( result.message ).toContain( expectedMessage );
|
|
56
|
-
} );
|
|
57
|
-
|
|
58
|
-
it( "should return an error when the input can't be stringified", () => {
|
|
59
|
-
// Arrange.
|
|
60
|
-
const errorObject = { circular: {} };
|
|
61
|
-
errorObject.circular = errorObject;
|
|
62
|
-
|
|
63
|
-
// Act.
|
|
64
|
-
const result = ensureError( errorObject );
|
|
65
|
-
|
|
66
|
-
// Assert.
|
|
67
|
-
expect( result ).toBeInstanceOf( Error );
|
|
68
|
-
expect( result.cause ).toBeInstanceOf( TypeError );
|
|
69
|
-
} );
|
|
70
|
-
} );
|