@enonic-types/lib-common 0.1.1 → 7.11.0-B3
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/README.md +12 -4
- package/common.d.ts +24 -24
- package/package.json +33 -32
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i --save-dev @enonic/lib-common
|
|
8
|
+
npm i --save-dev @enonic-types/lib-common
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Use
|
|
@@ -13,6 +13,7 @@ npm i --save-dev @enonic/lib-common
|
|
|
13
13
|
Add the corresponding types to your `tsconfig.json` file that is used for application's server-side TypeScript code.
|
|
14
14
|
|
|
15
15
|
`tsconfig.json`
|
|
16
|
+
|
|
16
17
|
```json
|
|
17
18
|
{
|
|
18
19
|
"compilerOptions": {
|
|
@@ -25,9 +26,11 @@ Add the corresponding types to your `tsconfig.json` file that is used for applic
|
|
|
25
26
|
|
|
26
27
|
### Require and custom imports
|
|
27
28
|
|
|
28
|
-
To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
29
|
+
To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
30
|
+
global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
|
|
29
31
|
|
|
30
32
|
`tsconfig.json`
|
|
33
|
+
|
|
31
34
|
```diff
|
|
32
35
|
{
|
|
33
36
|
"compilerOptions": {
|
|
@@ -40,17 +43,21 @@ To make `require` work out of box, you must install and add the `@enonic-types/g
|
|
|
40
43
|
```
|
|
41
44
|
|
|
42
45
|
`example.ts`
|
|
46
|
+
|
|
43
47
|
```ts
|
|
44
48
|
const {sanitize} = require('/lib/xp/common');
|
|
45
49
|
```
|
|
46
50
|
|
|
47
|
-
More detailed explanation on how it works and how to type custom import function can be
|
|
51
|
+
More detailed explanation on how it works and how to type custom import function can be
|
|
52
|
+
found [here](https://developer.enonic.com/docs/xp/stable/api).
|
|
48
53
|
|
|
49
54
|
### ES6-style import
|
|
50
55
|
|
|
51
|
-
If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper
|
|
56
|
+
If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper
|
|
57
|
+
types mapping to your configuration.
|
|
52
58
|
|
|
53
59
|
`tsconfig.json`
|
|
60
|
+
|
|
54
61
|
```diff
|
|
55
62
|
{
|
|
56
63
|
"compilerOptions": {
|
|
@@ -66,6 +73,7 @@ If you are planning to use `import` in your code and transpile it with the defau
|
|
|
66
73
|
```
|
|
67
74
|
|
|
68
75
|
`example.ts`
|
|
76
|
+
|
|
69
77
|
```ts
|
|
70
78
|
import {sanitize} from '/lib/xp/common';
|
|
71
79
|
```
|
package/common.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface XpLibraries {
|
|
3
|
-
'/lib/xp/common': typeof import('./common');
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Transform a text string so that it can be safely used in cases where the range of accepted characters is restricted.
|
|
8
|
-
*
|
|
9
|
-
* Some usage examples are: as an XP content or node name, as a principal name, in a URL or in a filesystem path.
|
|
10
|
-
*
|
|
11
|
-
* The following changes will be applied to the input text:
|
|
12
|
-
* - convert characters to lowercase (according to the rules of the default locale)
|
|
13
|
-
* - replace punctuation symbols and blank spaces with the hyphen character ('-')
|
|
14
|
-
* - remove some unsafe and invisible Unicode characters
|
|
15
|
-
* - strip duplicated hyphen characters
|
|
16
|
-
* - remove diacritic characters
|
|
17
|
-
* - map letters to the English alphabet (ASCII encoding)
|
|
18
|
-
*
|
|
19
|
-
* @example-ref examples/common/sanitize.js
|
|
20
|
-
*
|
|
21
|
-
* @param {string} text Text string to sanitize.
|
|
22
|
-
* @returns {string} Sanitized text.
|
|
23
|
-
*/
|
|
24
|
-
export declare function sanitize(text: string): string;
|
|
1
|
+
declare global {
|
|
2
|
+
interface XpLibraries {
|
|
3
|
+
'/lib/xp/common': typeof import('./common');
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Transform a text string so that it can be safely used in cases where the range of accepted characters is restricted.
|
|
8
|
+
*
|
|
9
|
+
* Some usage examples are: as an XP content or node name, as a principal name, in a URL or in a filesystem path.
|
|
10
|
+
*
|
|
11
|
+
* The following changes will be applied to the input text:
|
|
12
|
+
* - convert characters to lowercase (according to the rules of the default locale)
|
|
13
|
+
* - replace punctuation symbols and blank spaces with the hyphen character ('-')
|
|
14
|
+
* - remove some unsafe and invisible Unicode characters
|
|
15
|
+
* - strip duplicated hyphen characters
|
|
16
|
+
* - remove diacritic characters
|
|
17
|
+
* - map letters to the English alphabet (ASCII encoding)
|
|
18
|
+
*
|
|
19
|
+
* @example-ref examples/common/sanitize.js
|
|
20
|
+
*
|
|
21
|
+
* @param {string} text Text string to sanitize.
|
|
22
|
+
* @returns {string} Sanitized text.
|
|
23
|
+
*/
|
|
24
|
+
export declare function sanitize(text: string): string;
|
package/package.json
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@enonic-types/lib-common",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Type definitions for lib-common.",
|
|
5
|
-
"types": "common.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"common.d.ts"
|
|
8
|
-
],
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"enonic",
|
|
15
|
-
"enonic-xp",
|
|
16
|
-
"lib-common",
|
|
17
|
-
"common",
|
|
18
|
-
"types",
|
|
19
|
-
"typescript"
|
|
20
|
-
],
|
|
21
|
-
"contributors": [
|
|
22
|
-
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
-
],
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@enonic-types/lib-common",
|
|
3
|
+
"version": "7.11.0-B3",
|
|
4
|
+
"description": "Type definitions for lib-common.",
|
|
5
|
+
"types": "common.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"common.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"enonic",
|
|
15
|
+
"enonic-xp",
|
|
16
|
+
"lib-common",
|
|
17
|
+
"common",
|
|
18
|
+
"types",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"contributors": [
|
|
22
|
+
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
+
],
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
+
"dependencies": {},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|