@jahia/javascript-modules-library 0.1.0 → 0.3.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/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@jahia/javascript-modules-library",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "main": "index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "repository": "git@github.com:Jahia/javascript-modules.git",
7
7
  "license": "MIT",
8
8
  "scripts": {
9
- "types:copy": "mkdir -p dist/types && ncp types/manual dist/types && ncp types/generated/build/types dist/types",
9
+ "types:copy": "mkdir -p dist/types && ncp target/types dist/types",
10
10
  "build:development": "run types:copy && tsc && node generate-index",
11
11
  "build:production": "run build:development && run minify",
12
12
  "build": "run build:production",
13
13
  "minify": "node minify",
14
14
  "doc": "typedoc",
15
15
  "clean": "rm -rf dist",
16
- "lint": "eslint --ext js,jsx,json,ts .",
17
- "lint:fix": "eslint --ext js,jsx,json,ts --fix .",
16
+ "lint": "eslint --ext js,jsx,json,ts src/",
17
+ "lint:fix": "eslint --ext js,jsx,json,ts --fix src/",
18
18
  "prepack": "echo 'Please run 'mvn package' to create the tgz so the Maven version can be injected in the package.json' && exit 1"
19
19
  },
20
20
  "files": [
@@ -23,10 +23,31 @@
23
23
  "dependencies": {
24
24
  "graphql": "^16.0.1",
25
25
  "graphql-tag": "^2.12.6",
26
- "i18next": "^23.10.1",
27
- "prop-types": "^15.8.1",
28
- "react": "^18.2.0",
29
- "react-i18next": "^14.1.0"
26
+ "prop-types": "^15.8.1"
27
+ },
28
+ "peerDependencies": {
29
+ "i18next": ">=23.0.0 <23.11.0",
30
+ "react": ">=18.0.0 <18.3.0",
31
+ "react-dom": ">=18.0.0 <18.3.0",
32
+ "react-i18next": ">=14.0.0 <14.2.0",
33
+ "styled-jsx": ">=5.0.0 <5.2.0"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "i18next": {
37
+ "optional": true
38
+ },
39
+ "react": {
40
+ "optional": true
41
+ },
42
+ "react-dom": {
43
+ "optional": true
44
+ },
45
+ "react-i18next": {
46
+ "optional": true
47
+ },
48
+ "styled-jsx": {
49
+ "optional": true
50
+ }
30
51
  },
31
52
  "resolutions": {
32
53
  "minimist": "^1.2.6",
@@ -51,7 +72,10 @@
51
72
  "eslint-plugin-prettier": "^4.0.0",
52
73
  "eslint-plugin-react": "^7.32.2",
53
74
  "eslint-plugin-react-hooks": "^4.6.0",
75
+ "i18next": "^23.10.1",
54
76
  "ncp": "^2.0.0",
77
+ "react": "^18.2.0",
78
+ "react-i18next": "^14.1.0",
55
79
  "terser": "^5.36.0",
56
80
  "typedoc": "^0.25.13",
57
81
  "typescript": "^4.3.5"
@@ -1,4 +1,4 @@
1
- import {ConfigHelper, GQLHelper, OSGiHelper, RegistryHelper, RenderHelper} from 'org.jahia.modules.npm.modules.engine.js.server';
1
+ import {ConfigHelper, GQLHelper, OSGiHelper, RegistryHelper, RenderHelper} from 'org.jahia.modules.javascript.modules.engine.js.server';
2
2
  import {JCRNodeWrapper} from 'org.jahia.services.content';
3
3
  import {Resource, RenderContext} from 'org.jahia.services.render';
4
4
 
package/types/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export * from './java.util';
8
8
  export * from './javax.jcr';
9
9
  export * from './javax.servlet';
10
10
  export * from './javax.servlet.http';
11
- export * from './org.jahia.modules.npm.modules.engine.js.server';
11
+ export * from './org.jahia.modules.javascript.modules.engine.js.server';
12
12
  export * from './org.jahia.services.content';
13
13
  export * from './org.jahia.services.content.decorator';
14
14
  export * from './org.jahia.services.query';
@@ -7,7 +7,7 @@ export class BufferedReader {
7
7
  * @return The character read, as an integer in the range
8
8
  * 0 to 65535 (`0x00-0xffff`), or -1 if the
9
9
  * end of the stream has been reached
10
- * @exception IOException If an I/O error occurs
10
+ * @throws IOException If an I/O error occurs
11
11
  */
12
12
  read(): number;
13
13
  /**
@@ -17,22 +17,24 @@ export class BufferedReader {
17
17
  * {@link Reader#read(char[], int, int) read} method of the
18
18
  * {@link Reader} class. As an additional convenience, it
19
19
  * attempts to read as many characters as possible by repeatedly invoking
20
- * the read method of the underlying stream. This iterated
21
- * read continues until one of the following conditions becomes
22
- * true:
20
+ * the `read` method of the underlying stream. This iterated
21
+ * `read` continues until one of the following conditions becomes
22
+ * true:
23
+ *
23
24
  *
24
25
  * The specified number of characters have been read,
25
26
  *
26
- * The read method of the underlying stream returns
27
- * -1, indicating end-of-file, or
27
+ * The `read` method of the underlying stream returns
28
+ * `-1`, indicating end-of-file, or
28
29
  *
29
- * The ready method of the underlying stream
30
- * returns false, indicating that further input requests
30
+ * The `ready` method of the underlying stream
31
+ * returns `false`, indicating that further input requests
31
32
  * would block.
32
33
  *
33
- * If the first read on the underlying stream returns
34
- * -1 to indicate end-of-file then this method returns
35
- * -1. Otherwise this method returns the number of characters
34
+ *
35
+ * If the first `read` on the underlying stream returns
36
+ * `-1` to indicate end-of-file then this method returns
37
+ * `-1`. Otherwise this method returns the number of characters
36
38
  * actually read.
37
39
  *
38
40
  * Subclasses of this class are encouraged, but not required, to
@@ -43,18 +45,17 @@ export class BufferedReader {
43
45
  * however, the buffer is empty, the mark is not valid, and the requested
44
46
  * length is at least as large as the buffer, then this method will read
45
47
  * characters directly from the underlying stream into the given array.
46
- * Thus redundant BufferedReaders will not copy data
48
+ * Thus redundant `BufferedReader`s will not copy data
47
49
  * unnecessarily.
48
50
  *
49
- * @param cbuf Destination buffer
50
- * @param off Offset at which to start storing characters
51
- * @param len Maximum number of characters to read
51
+ * @param cbuf {@inheritDoc}
52
+ * @param off {@inheritDoc}
53
+ * @param len {@inheritDoc}
52
54
  *
53
- * @return The number of characters read, or -1 if the end of the
54
- * stream has been reached
55
+ * @return {@inheritDoc}
55
56
  *
56
- * @exception IOException If an I/O error occurs
57
- * @exception IndexOutOfBoundsException {@inheritDoc}
57
+ * @throws IndexOutOfBoundsException {@inheritDoc}
58
+ * @throws IOException {@inheritDoc}
58
59
  */
59
60
  read(cbuf: string[], off: number, len: number): number;
60
61
  /**
@@ -67,7 +68,7 @@ export class BufferedReader {
67
68
  * any line-termination characters, or null if the end of the
68
69
  * stream has been reached without reading any characters
69
70
  *
70
- * @exception IOException If an I/O error occurs
71
+ * @throws IOException If an I/O error occurs
71
72
  *
72
73
  * @see java.nio.file.Files#readAllLines
73
74
  */
@@ -77,7 +78,7 @@ export class BufferedReader {
77
78
  * stream is ready if the buffer is not empty, or if the underlying
78
79
  * character stream is ready.
79
80
  *
80
- * @exception IOException If an I/O error occurs
81
+ * @throws IOException If an I/O error occurs
81
82
  */
82
83
  ready(): boolean;
83
84
  }
@@ -95,7 +96,7 @@ export class File {
95
96
  getName(): string;
96
97
  /**
97
98
  * Returns the pathname string of this abstract pathname's parent, or
98
- * null if this pathname does not name a parent directory.
99
+ * `null` if this pathname does not name a parent directory.
99
100
  *
100
101
  * The parent of an abstract pathname consists of the
101
102
  * pathname's prefix, if any, and each name in the pathname's name
@@ -103,13 +104,13 @@ export class File {
103
104
  * the pathname does not name a parent directory.
104
105
  *
105
106
  * @return The pathname string of the parent directory named by this
106
- * abstract pathname, or null if this pathname
107
+ * abstract pathname, or `null` if this pathname
107
108
  * does not name a parent
108
109
  */
109
110
  getParent(): string;
110
111
  /**
111
112
  * Returns the abstract pathname of this abstract pathname's parent,
112
- * or null if this pathname does not name a parent
113
+ * or `null` if this pathname does not name a parent
113
114
  * directory.
114
115
  *
115
116
  * The parent of an abstract pathname consists of the
@@ -118,7 +119,7 @@ export class File {
118
119
  * the pathname does not name a parent directory.
119
120
  *
120
121
  * @return The abstract pathname of the parent directory named by this
121
- * abstract pathname, or null if this pathname
122
+ * abstract pathname, or `null` if this pathname
122
123
  * does not name a parent
123
124
  *
124
125
  * @since 1.2
@@ -135,12 +136,12 @@ export class File {
135
136
  /**
136
137
  * Tests whether this abstract pathname is absolute. The definition of
137
138
  * absolute pathname is system dependent. On UNIX systems, a pathname is
138
- * absolute if its prefix is "/". On Microsoft Windows systems, a
139
+ * absolute if its prefix is `"/"`. On Microsoft Windows systems, a
139
140
  * pathname is absolute if its prefix is a drive specifier followed by
140
- * "\\", or if its prefix is "\\\\".
141
+ * `"\\"`, or if its prefix is `"\\\\"`.
141
142
  *
142
- * @return true if this abstract pathname is absolute,
143
- * false otherwise
143
+ * @return `true` if this abstract pathname is absolute,
144
+ * `false` otherwise
144
145
  */
145
146
  isAbsolute(): boolean;
146
147
  /**
@@ -150,7 +151,7 @@ export class File {
150
151
  * string is simply returned as if by the {@link #getPath}
151
152
  * method. If this abstract pathname is the empty abstract pathname then
152
153
  * the pathname string of the current user directory, which is named by the
153
- * system property user.dir, is returned. Otherwise this
154
+ * system property `user.dir`, is returned. Otherwise this
154
155
  * pathname is resolved in a system-dependent way. On UNIX systems, a
155
156
  * relative pathname is made absolute by resolving it against the current
156
157
  * user directory. On Microsoft Windows systems, a relative pathname is made absolute
@@ -251,9 +252,9 @@ export class File {
251
252
  * java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
252
253
  * Files.readAttributes} method may be used.
253
254
  *
254
- * @return true if and only if the file denoted by this
255
+ * @return `true` if and only if the file denoted by this
255
256
  * abstract pathname exists and is a directory;
256
- * false otherwise
257
+ * `false` otherwise
257
258
  *
258
259
  * @throws SecurityException
259
260
  * If a security manager exists and its {@link
@@ -273,9 +274,9 @@ export class File {
273
274
  * java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
274
275
  * Files.readAttributes} method may be used.
275
276
  *
276
- * @return true if and only if the file denoted by this
277
+ * @return `true` if and only if the file denoted by this
277
278
  * abstract pathname exists and is a normal file;
278
- * false otherwise
279
+ * `false` otherwise
279
280
  *
280
281
  * @throws SecurityException
281
282
  * If a security manager exists and its {@link
@@ -287,10 +288,10 @@ export class File {
287
288
  * Tests whether the file named by this abstract pathname is a hidden
288
289
  * file. The exact definition of hidden is system-dependent. On
289
290
  * UNIX systems, a file is considered to be hidden if its name begins with
290
- * a period character ('.'). On Microsoft Windows systems, a file is
291
+ * a period character (`'.'`). On Microsoft Windows systems, a file is
291
292
  * considered to be hidden if it has been marked as such in the filesystem.
292
293
  *
293
- * @return true if and only if the file denoted by this
294
+ * @return `true` if and only if the file denoted by this
294
295
  * abstract pathname is hidden according to the conventions of the
295
296
  * underlying platform
296
297
  *
@@ -304,10 +305,13 @@ export class File {
304
305
  isHidden(): boolean;
305
306
  /**
306
307
  * Returns the size of the partition named by this
307
- * abstract pathname.
308
+ * abstract pathname. If the total number of bytes in the partition is
309
+ * greater than {@link Long#MAX_VALUE}, then `Long.MAX_VALUE` will be
310
+ * returned.
308
311
  *
309
312
  * @return The size, in bytes, of the partition or `0L` if this
310
- * abstract pathname does not name a partition
313
+ * abstract pathname does not name a partition or if the size
314
+ * cannot be obtained
311
315
  *
312
316
  * @throws SecurityException
313
317
  * If a security manager has been installed and it denies
@@ -316,10 +320,13 @@ export class File {
316
320
  * read access to the file named by this abstract pathname
317
321
  *
318
322
  * @since 1.6
323
+ * @see FileStore#getTotalSpace
319
324
  */
320
325
  getTotalSpace(): number;
321
326
  /**
322
- * Returns the number of unallocated bytes in the partition named by this abstract path name.
327
+ * Returns the number of unallocated bytes in the partition named by this abstract path name. If the
328
+ * number of unallocated bytes in the partition is greater than
329
+ * {@link Long#MAX_VALUE}, then `Long.MAX_VALUE` will be returned.
323
330
  *
324
331
  * The returned number of unallocated bytes is a hint, but not
325
332
  * a guarantee, that it is possible to use most or any of these
@@ -331,9 +338,10 @@ export class File {
331
338
  * will succeed.
332
339
  *
333
340
  * @return The number of unallocated bytes on the partition or `0L`
334
- * if the abstract pathname does not name a partition. This
335
- * value will be less than or equal to the total file system size
336
- * returned by {@link #getTotalSpace}.
341
+ * if the abstract pathname does not name a partition or if this
342
+ * number cannot be obtained. This value will be less than or
343
+ * equal to the total file system size returned by
344
+ * {@link #getTotalSpace}.
337
345
  *
338
346
  * @throws SecurityException
339
347
  * If a security manager has been installed and it denies
@@ -342,28 +350,32 @@ export class File {
342
350
  * read access to the file named by this abstract pathname
343
351
  *
344
352
  * @since 1.6
353
+ * @see FileStore#getUnallocatedSpace
345
354
  */
346
355
  getFreeSpace(): number;
347
356
  /**
348
357
  * Returns the number of bytes available to this virtual machine on the
349
- * partition named by this abstract pathname. When
350
- * possible, this method checks for write permissions and other operating
351
- * system restrictions and will therefore usually provide a more accurate
352
- * estimate of how much new data can actually be written than {@link
353
- * #getFreeSpace}.
358
+ * partition named by this abstract pathname. If
359
+ * the number of available bytes in the partition is greater than
360
+ * {@link Long#MAX_VALUE}, then `Long.MAX_VALUE` will be returned.
361
+ * When possible, this method checks for write permissions and other
362
+ * operating system restrictions and will therefore usually provide a more
363
+ * accurate estimate of how much new data can actually be written than
364
+ * {@link #getFreeSpace}.
354
365
  *
355
366
  * The returned number of available bytes is a hint, but not a
356
367
  * guarantee, that it is possible to use most or any of these bytes. The
357
- * number of unallocated bytes is most likely to be accurate immediately
368
+ * number of available bytes is most likely to be accurate immediately
358
369
  * after this call. It is likely to be made inaccurate by any external
359
370
  * I/O operations including those made on the system outside of this
360
371
  * virtual machine. This method makes no guarantee that write operations
361
372
  * to this file system will succeed.
362
373
  *
363
374
  * @return The number of available bytes on the partition or `0L`
364
- * if the abstract pathname does not name a partition. On
365
- * systems where this information is not available, this method
366
- * will be equivalent to a call to {@link #getFreeSpace}.
375
+ * if the abstract pathname does not name a partition or if this
376
+ * number cannot be obtained. On systems where this information
377
+ * is not available, this method will be equivalent to a call to
378
+ * {@link #getFreeSpace}.
367
379
  *
368
380
  * @throws SecurityException
369
381
  * If a security manager has been installed and it denies
@@ -372,6 +384,7 @@ export class File {
372
384
  * read access to the file named by this abstract pathname
373
385
  *
374
386
  * @since 1.6
387
+ * @see FileStore#getUsableSpace
375
388
  */
376
389
  getUsableSpace(): number;
377
390
  }
@@ -476,9 +489,8 @@ export class PrintWriter {
476
489
  print(obj: any): void;
477
490
  /**
478
491
  * Terminates the current line by writing the line separator string. The
479
- * line separator string is defined by the system property
480
- * `line.separator`, and is not necessarily a single newline
481
- * character (`'\n'`).
492
+ * line separator is {@link System#lineSeparator()} and is not necessarily
493
+ * a single newline character (`'\n'`).
482
494
  */
483
495
  println(): void;
484
496
  /**
@@ -545,7 +557,7 @@ export class PrintWriter {
545
557
  * extra arguments are ignored. The number of arguments is
546
558
  * variable and may be zero. The maximum number of arguments is
547
559
  * limited by the maximum dimension of a Java array as defined by
548
- * The Java Virtual Machine Specification.
560
+ * The Java Virtual Machine Specification.
549
561
  * The behaviour on a
550
562
  * `null` argument depends on the conversion.
551
563
  *
@@ -592,7 +604,7 @@ export class PrintWriter {
592
604
  * extra arguments are ignored. The number of arguments is
593
605
  * variable and may be zero. The maximum number of arguments is
594
606
  * limited by the maximum dimension of a Java array as defined by
595
- * The Java Virtual Machine Specification.
607
+ * The Java Virtual Machine Specification.
596
608
  * The behaviour on a
597
609
  * `null` argument depends on the conversion.
598
610
  *
@@ -630,7 +642,7 @@ export class PrintWriter {
630
642
  * extra arguments are ignored. The number of arguments is
631
643
  * variable and may be zero. The maximum number of arguments is
632
644
  * limited by the maximum dimension of a Java array as defined by
633
- * The Java Virtual Machine Specification.
645
+ * The Java Virtual Machine Specification.
634
646
  * The behaviour on a
635
647
  * `null` argument depends on the conversion.
636
648
  *
@@ -669,7 +681,7 @@ export class PrintWriter {
669
681
  * extra arguments are ignored. The number of arguments is
670
682
  * variable and may be zero. The maximum number of arguments is
671
683
  * limited by the maximum dimension of a Java array as defined by
672
- * The Java Virtual Machine Specification.
684
+ * The Java Virtual Machine Specification.
673
685
  * The behaviour on a
674
686
  * `null` argument depends on the conversion.
675
687
  *
@@ -42,7 +42,7 @@ declare module 'java.net' {
42
42
  * A URL may have appended to it a "fragment", also known
43
43
  * as a "ref" or a "reference". The fragment is indicated by the sharp
44
44
  * sign character "#" followed by more characters. For example,
45
- * * http://java.sun.com/index.html#chapter1
45
+ * * http://www.example.com/index.html#chapter1
46
46
  *
47
47
  *
48
48
  * This fragment is not technically part of the URL. Rather, it
@@ -55,13 +55,13 @@ declare module 'java.net' {
55
55
  * which contains only enough information to reach the resource
56
56
  * relative to another URL. Relative URLs are frequently used within
57
57
  * HTML pages. For example, if the contents of the URL:
58
- * * http://java.sun.com/index.html
58
+ * * http://www.example.com/index.html
59
59
  *
60
60
  * contained within it the relative URL:
61
61
  * * FAQ.html
62
62
  *
63
63
  * it would be a shorthand for:
64
- * * http://java.sun.com/FAQ.html
64
+ * * http://www.example.com/FAQ.html
65
65
  *
66
66
  *
67
67
  * The relative URL need not specify all the components of a URL. If
@@ -89,6 +89,26 @@ declare module 'java.net' {
89
89
  * used, but only for HTML form encoding, which is not the same
90
90
  * as the encoding scheme defined in RFC2396.
91
91
  *
92
+ * @apiNote
93
+ *
94
+ * Applications working with file paths and file URIs should take great
95
+ * care to use the appropriate methods to convert between the two.
96
+ * The {@link Path#of(URI)} factory method and the {@link File#File(URI)}
97
+ * constructor can be used to create {@link Path} or {@link File}
98
+ * objects from a file URI. {@link Path#toUri()} and {@link File#toURI()}
99
+ * can be used to create a {@link URI} from a file path, which can be
100
+ * converted to URL using {@link URI#toURL()}.
101
+ * Applications should never try to {@linkplain #URL(String, String, String)
102
+ * construct} or {@linkplain #URL(String) parse} a `URL`
103
+ * from the direct string representation of a `File` or `Path`
104
+ * instance.
105
+ *
106
+ * Some components of a URL or URI, such as userinfo, may
107
+ * be abused to construct misleading URLs or URIs. Applications
108
+ * that deal with URLs or URIs should take into account
109
+ * the recommendations advised in RFC3986,
110
+ * Section 7, Security Considerations.
111
+ *
92
112
  * @author James Gosling
93
113
  * @since 1.0
94
114
  */
@@ -181,7 +201,7 @@ export class URL {
181
201
  *
182
202
  *
183
203
  * @return the contents of this URL.
184
- * @exception IOException if an I/O exception occurs.
204
+ * @throws IOException if an I/O exception occurs.
185
205
  * @see java.net.URLConnection#getContent()
186
206
  */
187
207
  getContent(): any;
@@ -84,11 +84,11 @@ export class Collection<E> {
84
84
  * global positioning system (GPS) is synchronized to UTC but is
85
85
  * not adjusted for leap seconds. An interesting source of
86
86
  * further information is the United States Naval Observatory (USNO):
87
- * * http://www.usno.navy.mil/USNO
87
+ * * https://www.usno.navy.mil/USNO
88
88
  *
89
89
  *
90
90
  * and the material regarding "Systems of Time" at:
91
- * * http://www.usno.navy.mil/USNO/time/master-clock/systems-of-time
91
+ * * https://www.usno.navy.mil/USNO/time/master-clock/systems-of-time
92
92
  *
93
93
  *
94
94
  * which has descriptions of various different time systems including
@@ -183,7 +183,6 @@ export class Date {
183
183
  * NOTE: This class is obsolete. New implementations should
184
184
  * implement the Map interface, rather than extending this class.
185
185
  *
186
- * @author unascribed
187
186
  * @see java.util.Map
188
187
  * @see java.lang.Object#equals(java.lang.Object)
189
188
  * @see java.lang.Object#hashCode()
@@ -216,7 +215,7 @@ export class Dictionary<K, V> {
216
215
  * @param key a key in this dictionary.
217
216
  * `null` if the key is not mapped to any value in
218
217
  * this dictionary.
219
- * @exception NullPointerException if the `key` is `null`.
218
+ * @throws NullPointerException if the `key` is `null`.
220
219
  * @see java.util.Dictionary#put(java.lang.Object, java.lang.Object)
221
220
  */
222
221
  get(key: any): V;
@@ -270,7 +269,7 @@ export class Enumeration<E> {
270
269
  * object has at least one more element to provide.
271
270
  *
272
271
  * @return the next element of this enumeration.
273
- * @exception NoSuchElementException if no more elements exist.
272
+ * @throws NoSuchElementException if no more elements exist.
274
273
  */
275
274
  nextElement(): E;
276
275
  }
@@ -351,9 +350,9 @@ export class List<E> {
351
350
  get(index: number): E;
352
351
  }
353
352
  /**
354
- * A Locale object represents a specific geographical, political,
355
- * or cultural region. An operation that requires a Locale to perform
356
- * its task is called locale-sensitive and uses the Locale
353
+ * A `Locale` object represents a specific geographical, political,
354
+ * or cultural region. An operation that requires a `Locale` to perform
355
+ * its task is called locale-sensitive and uses the `Locale`
357
356
  * to tailor information for the user. For example, displaying a number
358
357
  * is a locale-sensitive operation— the number should be formatted
359
358
  * according to the customs and conventions of the user's native country,
@@ -366,7 +365,7 @@ export class List<E> {
366
365
  * Locale Data Markup Language") BCP 47-compatible extensions for locale data
367
366
  * exchange.
368
367
  *
369
- * A Locale object logically consists of the fields
368
+ * A `Locale` object logically consists of the fields
370
369
  * described below.
371
370
  *
372
371
  *
@@ -378,7 +377,7 @@ export class List<E> {
378
377
  * alpha-2 code must be used. You can find a full list of valid
379
378
  * language codes in the IANA Language Subtag Registry (search for
380
379
  * "Type: language"). The language field is case insensitive, but
381
- * Locale always canonicalizes to lower case.
380
+ * `Locale` always canonicalizes to lower case.
382
381
  *
383
382
  * Well-formed language values have the form
384
383
  * [a-zA-Z]{2,8}. Note that this is not the full
@@ -393,7 +392,7 @@ export class List<E> {
393
392
  * ISO 15924 alpha-4 script code. You can find a full list of
394
393
  * valid script codes in the IANA Language Subtag Registry (search
395
394
  * for "Type: script"). The script field is case insensitive, but
396
- * Locale always canonicalizes to title case (the first
395
+ * `Locale` always canonicalizes to title case (the first
397
396
  * letter is upper case and the rest of the letters are lower
398
397
  * case).
399
398
  *
@@ -408,7 +407,7 @@ export class List<E> {
408
407
  * You can find a full list of valid country and region codes in the
409
408
  * IANA Language Subtag Registry (search for "Type: region"). The
410
409
  * country (region) field is case insensitive, but
411
- * Locale always canonicalizes to upper case.
410
+ * `Locale` always canonicalizes to upper case.
412
411
  *
413
412
  * Well-formed country/region values have
414
413
  * the form [a-zA-Z]{2} | [0-9]{3}
@@ -419,7 +418,7 @@ export class List<E> {
419
418
  * variant
420
419
  *
421
420
  * Any arbitrary value used to indicate a variation of a
422
- * Locale. Where there are two or more variant values
421
+ * `Locale`. Where there are two or more variant values
423
422
  * each indicating its own semantics, these values should be ordered
424
423
  * by importance, with most important first, separated by
425
424
  * underscore('_'). The variant field is case sensitive.
@@ -431,7 +430,7 @@ export class List<E> {
431
430
  * region subtags. You can find a full list of valid variant codes
432
431
  * in the IANA Language Subtag Registry (search for "Type: variant").
433
432
  *
434
- * However, the variant field in Locale has
433
+ * However, the variant field in `Locale` has
435
434
  * historically been used for any kind of variation, not just
436
435
  * language variations. For example, some supported variants
437
436
  * available in Java SE Runtime Environments indicate alternative
@@ -451,15 +450,15 @@ export class List<E> {
451
450
  *
452
451
  * A map from single character keys to string values, indicating
453
452
  * extensions apart from language identification. The extensions in
454
- * Locale implement the semantics and syntax of BCP 47
453
+ * `Locale` implement the semantics and syntax of BCP 47
455
454
  * extension subtags and private use subtags. The extensions are
456
- * case insensitive, but Locale canonicalizes all
455
+ * case insensitive, but `Locale` canonicalizes all
457
456
  * extension keys and values to lower case. Note that extensions
458
457
  * cannot have empty values.
459
458
  *
460
459
  * Well-formed keys are single characters from the set
461
- * [0-9a-zA-Z]. Well-formed values have the form
462
- * SUBTAG ('-' SUBTAG)* where for the key 'x'
460
+ * `[0-9a-zA-Z]`. Well-formed values have the form
461
+ * `SUBTAG ('-' SUBTAG)*` where for the key 'x'
463
462
  * SUBTAG = [0-9a-zA-Z]{1,8} and for other keys
464
463
  * SUBTAG = [0-9a-zA-Z]{2,8} (that is, 'x' allows
465
464
  * single-character subtags).
@@ -469,8 +468,8 @@ export class List<E> {
469
468
  *
470
469
  *
471
470
  * Note: Although BCP 47 requires field values to be registered
472
- * in the IANA Language Subtag Registry, the Locale class
473
- * does not provide any validation features. The Builder
471
+ * in the IANA Language Subtag Registry, the `Locale` class
472
+ * does not provide any validation features. The `Builder`
474
473
  * only checks if an individual field satisfies the syntactic
475
474
  * requirement (is well-formed), but does not validate the value
476
475
  * itself. See {@link Builder} for details.
@@ -488,11 +487,11 @@ export class List<E> {
488
487
  * extension key 'u' ({@link #UNICODE_LOCALE_EXTENSION}). The above
489
488
  * example, "nu-thai", becomes the extension "u-nu-thai".
490
489
  *
491
- * Thus, when a Locale object contains Unicode locale
490
+ * Thus, when a `Locale` object contains Unicode locale
492
491
  * attributes and keywords,
493
- * getExtension(UNICODE_LOCALE_EXTENSION) will return a
492
+ * `getExtension(UNICODE_LOCALE_EXTENSION)` will return a
494
493
  * String representing this information, for example, "nu-thai". The
495
- * Locale class also provides {@link
494
+ * `Locale` class also provides {@link
496
495
  * #getUnicodeLocaleAttributes}, {@link #getUnicodeLocaleKeys}, and
497
496
  * {@link #getUnicodeLocaleType} which allow you to access Unicode
498
497
  * locale attributes and key/type pairs directly. When represented as
@@ -517,37 +516,37 @@ export class List<E> {
517
516
  *
518
517
  * Creating a Locale
519
518
  *
520
- * There are several different ways to create a Locale
519
+ * There are several different ways to create a `Locale`
521
520
  * object.
522
521
  *
523
522
  * Builder
524
523
  *
525
- * Using {@link Builder} you can construct a Locale object
524
+ * Using {@link Builder} you can construct a `Locale` object
526
525
  * that conforms to BCP 47 syntax.
527
526
  *
528
527
  * Constructors
529
528
  *
530
- * The Locale class provides three constructors:
529
+ * The `Locale` class provides three constructors:
531
530
  *
532
531
  * * {@link #Locale(String language)}
533
532
  * {@link #Locale(String language, String country)}
534
533
  * {@link #Locale(String language, String country, String variant)}
535
534
  *
536
535
  *
537
- * These constructors allow you to create a Locale object
536
+ * These constructors allow you to create a `Locale` object
538
537
  * with language, country and variant, but you cannot specify
539
538
  * script or extensions.
540
539
  *
541
540
  * Factory Methods
542
541
  *
543
- * The method {@link #forLanguageTag} creates a Locale
542
+ * The method {@link #forLanguageTag} creates a `Locale`
544
543
  * object for a well-formed BCP 47 language tag.
545
544
  *
546
545
  * Locale Constants
547
546
  *
548
- * The Locale class provides a number of convenient constants
549
- * that you can use to create Locale objects for commonly used
550
- * locales. For example, the following creates a Locale object
547
+ * The `Locale` class provides a number of convenient constants
548
+ * that you can use to create `Locale` objects for commonly used
549
+ * locales. For example, the following creates a `Locale` object
551
550
  * for the United States:
552
551
  *
553
552
  * * Locale.US
@@ -626,25 +625,25 @@ export class List<E> {
626
625
  *
627
626
  * Use of Locale
628
627
  *
629
- * Once you've created a Locale you can query it for information
630
- * about itself. Use getCountry to get the country (or region)
631
- * code and getLanguage to get the language code.
632
- * You can use getDisplayCountry to get the
628
+ * Once you've created a `Locale` you can query it for information
629
+ * about itself. Use `getCountry` to get the country (or region)
630
+ * code and `getLanguage` to get the language code.
631
+ * You can use `getDisplayCountry` to get the
633
632
  * name of the country suitable for displaying to the user. Similarly,
634
- * you can use getDisplayLanguage to get the name of
633
+ * you can use `getDisplayLanguage` to get the name of
635
634
  * the language suitable for displaying to the user. Interestingly,
636
- * the getDisplayXXX methods are themselves locale-sensitive
635
+ * the `getDisplayXXX` methods are themselves locale-sensitive
637
636
  * and have two versions: one that uses the default
638
637
  * {@link Locale.Category#DISPLAY DISPLAY} locale and one
639
638
  * that uses the locale specified as an argument.
640
639
  *
641
640
  * The Java Platform provides a number of classes that perform locale-sensitive
642
- * operations. For example, the NumberFormat class formats
641
+ * operations. For example, the `NumberFormat` class formats
643
642
  * numbers, currency, and percentages in a locale-sensitive manner. Classes
644
- * such as NumberFormat have several convenience methods
643
+ * such as `NumberFormat` have several convenience methods
645
644
  * for creating a default object of that type. For example, the
646
- * NumberFormat class provides these three convenience methods
647
- * for creating a default NumberFormat object:
645
+ * `NumberFormat` class provides these three convenience methods
646
+ * for creating a default `NumberFormat` object:
648
647
  *
649
648
  * * NumberFormat.getInstance()
650
649
  * NumberFormat.getCurrencyInstance()
@@ -660,8 +659,8 @@ export class List<E> {
660
659
  * NumberFormat.getPercentInstance(myLocale)
661
660
  *
662
661
  *
663
- * A Locale is the mechanism for identifying the kind of object
664
- * (NumberFormat) that you would like to get. The locale is
662
+ * A `Locale` is the mechanism for identifying the kind of object
663
+ * (`NumberFormat`) that you would like to get. The locale is
665
664
  * just a mechanism for identifying objects,
666
665
  * not a container for the objects themselves.
667
666
  *
@@ -670,7 +669,7 @@ export class List<E> {
670
669
  * In order to maintain compatibility with existing usage, Locale's
671
670
  * constructors retain their behavior prior to the Java Runtime
672
671
  * Environment version 1.7. The same is largely true for the
673
- * toString method. Thus Locale objects can continue to
672
+ * `toString` method. Thus Locale objects can continue to
674
673
  * be used as they were. In particular, clients who parse the output
675
674
  * of toString into language, country, and variant fields can continue
676
675
  * to do so (although this is strongly discouraged), although the
@@ -680,15 +679,15 @@ export class List<E> {
680
679
  * In addition, BCP 47 imposes syntax restrictions that are not
681
680
  * imposed by Locale's constructors. This means that conversions
682
681
  * between some Locales and BCP 47 language tags cannot be made without
683
- * losing information. Thus toLanguageTag cannot
682
+ * losing information. Thus `toLanguageTag` cannot
684
683
  * represent the state of locales whose language, country, or variant
685
684
  * do not conform to BCP 47.
686
685
  *
687
686
  * Because of these issues, it is recommended that clients migrate
688
687
  * away from constructing non-conforming locales and use the
689
- * forLanguageTag and Locale.Builder APIs instead.
688
+ * `forLanguageTag` and `Locale.Builder` APIs instead.
690
689
  * Clients desiring a string representation of the complete locale can
691
- * then always rely on toLanguageTag for this purpose.
690
+ * then always rely on `toLanguageTag` for this purpose.
692
691
  *
693
692
  * Special cases
694
693
  *
@@ -729,14 +728,24 @@ export class List<E> {
729
728
  * Locale's constructor has always converted three language codes to
730
729
  * their earlier, obsoleted forms: `he` maps to `iw`,
731
730
  * `yi` maps to `ji`, and `id` maps to
732
- * `in`. This continues to be the case, in order to not break
733
- * backwards compatibility.
731
+ * `in`. Since Java SE 17, this is no longer the case. Each
732
+ * language maps to its new form; `iw` maps to `he`, `ji`
733
+ * maps to `yi`, and `in` maps to `id`.
734
+ *
735
+ * For the backward compatible behavior, the system property
736
+ * {@systemProperty java.locale.useOldISOCodes} reverts the behavior
737
+ * back to that of before Java SE 17. If the system property is set to
738
+ * `true`, those three current language codes are mapped to their
739
+ * backward compatible forms. The property is only read at Java runtime
740
+ * startup and subsequent calls to `System.setProperty()` will
741
+ * have no effect.
734
742
  *
735
743
  * The APIs added in 1.7 map between the old and new language codes,
736
- * maintaining the old codes internal to Locale (so that
737
- * getLanguage and toString reflect the old
738
- * code), but using the new codes in the BCP 47 language tag APIs (so
739
- * that toLanguageTag reflects the new one). This
744
+ * maintaining the mapped codes internal to Locale (so that
745
+ * `getLanguage` and `toString` reflect the mapped
746
+ * code, which depends on the `java.locale.useOldISOCodes` system
747
+ * property), but using the new codes in the BCP 47 language tag APIs (so
748
+ * that `toLanguageTag` reflects the new one). This
740
749
  * preserves the equivalence between Locales no matter which code or
741
750
  * API is used to construct them. Java's default resource bundle
742
751
  * lookup mechanism also implements this mapping, so that resources
@@ -781,7 +790,7 @@ export class Locale {
781
790
  * The returned array represents the union of locales supported
782
791
  * by the Java runtime environment and by installed
783
792
  * {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider}
784
- * implementations. It must contain at least a Locale
793
+ * implementations. It must contain at least a `Locale`
785
794
  * instance equal to {@link java.util.Locale#US Locale.US}.
786
795
  *
787
796
  * @return An array of installed locales.
@@ -793,7 +802,7 @@ export class Locale {
793
802
  * This method is equivalent to {@link #getISOCountries(Locale.IsoCountryCode type)}
794
803
  * with `type` {@link IsoCountryCode#PART1_ALPHA2}.
795
804
  *
796
- * Note: The Locale class also supports other codes for
805
+ * Note: The `Locale` class also supports other codes for
797
806
  * country (region), such as 3-letter numeric UN M.49 area codes.
798
807
  * Therefore, the list returned by this method does not contain ALL valid
799
808
  * codes that can be used to create Locales.
@@ -814,7 +823,7 @@ export class Locale {
814
823
  * ISO 639 is not a stable standard— some languages' codes have changed.
815
824
  * The list this function returns includes both the new and the old codes for the
816
825
  * languages whose codes have changed.
817
- * The Locale class also supports language codes up to
826
+ * The `Locale` class also supports language codes up to
818
827
  * 8 characters in length. Therefore, the list returned by this method does
819
828
  * not contain ALL valid codes that can be used to create Locales.
820
829
  *
@@ -825,17 +834,10 @@ export class Locale {
825
834
  /**
826
835
  * Returns the language code of this Locale.
827
836
  *
828
- * Note: ISO 639 is not a stable standard— some languages' codes have changed.
829
- * Locale's constructor recognizes both the new and the old codes for the languages
830
- * whose codes have changed, but this function always returns the old code. If you
831
- * want to check for a specific language whose code has changed, don't do
832
- * * if (locale.getLanguage().equals("he")) // BAD!
833
- * ...
834
- *
835
- * Instead, do
836
- * * if (locale.getLanguage().equals(new Locale("he").getLanguage()))
837
- * ...
838
- *
837
+ * @implNote This method returns the new forms for the obsolete ISO 639
838
+ * codes ("iw", "ji", and "in"). See
839
+ * Legacy language codes for more information.
840
+ *
839
841
  * @return The language code, or the empty string if none is defined.
840
842
  * @see #getDisplayLanguage
841
843
  */
@@ -871,7 +873,7 @@ export class Locale {
871
873
  * Returns the extension (or private use) value associated with
872
874
  * the specified key, or null if there is no extension
873
875
  * associated with the key. To be well-formed, the key must be one
874
- * of [0-9A-Za-z]. Keys are case-insensitive, so
876
+ * of `[0-9A-Za-z]`. Keys are case-insensitive, so
875
877
  * for example 'z' and 'Z' represent the same extension.
876
878
  *
877
879
  * @param key the extension key
@@ -913,7 +915,7 @@ export class Locale {
913
915
  * @return The Unicode locale type associated with the key, or null if the
914
916
  * locale does not define the key.
915
917
  * @throws IllegalArgumentException if the key is not well-formed
916
- * @throws NullPointerException if key is null
918
+ * @throws NullPointerException if `key` is null
917
919
  * @since 1.7
918
920
  */
919
921
  getUnicodeLocaleType(key: string): string;
@@ -927,7 +929,7 @@ export class Locale {
927
929
  */
928
930
  getUnicodeLocaleKeys(): Set<string>;
929
931
  /**
930
- * Returns a string representation of this Locale
932
+ * Returns a string representation of this `Locale`
931
933
  * object, consisting of language, country, variant, script,
932
934
  * and extensions as below:
933
935
  *
@@ -950,7 +952,7 @@ export class Locale {
950
952
  * added before the "#".
951
953
  *
952
954
  * This behavior is designed to support debugging and to be compatible with
953
- * previous uses of toString that expected language, country, and variant
955
+ * previous uses of `toString` that expected language, country, and variant
954
956
  * fields only. To represent a Locale as a String for interchange purposes, use
955
957
  * {@link #toLanguageTag}.
956
958
  *
@@ -980,7 +982,7 @@ export class Locale {
980
982
  * not specify a language the empty string is returned.
981
983
  *
982
984
  * @return A three-letter abbreviation of this locale's language.
983
- * @exception MissingResourceException Throws MissingResourceException if
985
+ * @throws MissingResourceException Throws MissingResourceException if
984
986
  * three-letter language abbreviation is not available for this locale.
985
987
  */
986
988
  getISO3Language(): string;
@@ -994,7 +996,7 @@ export class Locale {
994
996
  * The ISO 3166-1 codes can be found on-line.
995
997
  *
996
998
  * @return A three-letter abbreviation of this locale's country.
997
- * @exception MissingResourceException Throws MissingResourceException if the
999
+ * @throws MissingResourceException Throws MissingResourceException if the
998
1000
  * three-letter country abbreviation is not available for this locale.
999
1001
  */
1000
1002
  getISO3Country(): string;
@@ -1032,7 +1034,7 @@ export class Locale {
1032
1034
  *
1033
1035
  * @param inLocale The locale for which to retrieve the display language.
1034
1036
  * @return The name of the display language appropriate to the given locale.
1035
- * @exception NullPointerException if inLocale is null
1037
+ * @throws NullPointerException if `inLocale` is `null`
1036
1038
  */
1037
1039
  getDisplayLanguage(inLocale: Locale): string;
1038
1040
  /**
@@ -1055,7 +1057,7 @@ export class Locale {
1055
1057
  * @param inLocale The locale for which to retrieve the display script.
1056
1058
  * @return the display name of the script code for the current default
1057
1059
  * {@link Locale.Category#DISPLAY DISPLAY} locale
1058
- * @throws NullPointerException if inLocale is null
1060
+ * @throws NullPointerException if `inLocale` is `null`
1059
1061
  * @since 1.7
1060
1062
  */
1061
1063
  getDisplayScript(inLocale: Locale): string;
@@ -1093,7 +1095,7 @@ export class Locale {
1093
1095
  *
1094
1096
  * @param inLocale The locale for which to retrieve the display country.
1095
1097
  * @return The name of the country appropriate to the given locale.
1096
- * @exception NullPointerException if inLocale is null
1098
+ * @throws NullPointerException if `inLocale` is `null`
1097
1099
  */
1098
1100
  getDisplayCountry(inLocale: Locale): string;
1099
1101
  /**
@@ -1112,7 +1114,7 @@ export class Locale {
1112
1114
  *
1113
1115
  * @param inLocale The locale for which to retrieve the display variant code.
1114
1116
  * @return The name of the display variant code appropriate to the given locale.
1115
- * @exception NullPointerException if inLocale is null
1117
+ * @throws NullPointerException if `inLocale` is `null`
1116
1118
  */
1117
1119
  getDisplayVariant(inLocale: Locale): string;
1118
1120
  /**
@@ -1159,7 +1161,7 @@ export class Locale {
1159
1161
  *
1160
1162
  * @param inLocale The locale for which to retrieve the display name.
1161
1163
  * @return The name of the locale appropriate to display.
1162
- * @throws NullPointerException if inLocale is null
1164
+ * @throws NullPointerException if `inLocale` is `null`
1163
1165
  */
1164
1166
  getDisplayName(inLocale: Locale): string;
1165
1167
  }
@@ -1264,10 +1266,12 @@ export class Locale {
1264
1266
  * passed to a static factory method result in `IllegalArgumentException`.
1265
1267
  * The iteration order of mappings is unspecified and is subject to change.
1266
1268
  * They are value-based.
1267
- * Callers should make no assumptions about the identity of the returned instances.
1268
- * Factories are free to create new instances or reuse existing ones. Therefore,
1269
- * identity-sensitive operations on these instances (reference equality (`==`),
1270
- * identity hash code, and synchronization) are unreliable and should be avoided.
1269
+ * Programmers should treat instances that are {@linkplain #equals(Object) equal}
1270
+ * as interchangeable and should not use them for synchronization, or
1271
+ * unpredictable behavior may occur. For example, in a future release,
1272
+ * synchronization may fail. Callers should make no assumptions
1273
+ * about the identity of the returned instances. Factories are free to
1274
+ * create new instances or reuse existing ones.
1271
1275
  * They are serialized as specified on the
1272
1276
  * Serialized Form
1273
1277
  * page.
@@ -1423,7 +1427,7 @@ export class Map<K, V> {
1423
1427
  * `null`, else returns the current value.
1424
1428
  *
1425
1429
  * @implSpec
1426
- * The default implementation is equivalent to, for this ` * map`:
1430
+ * The default implementation is equivalent to, for this `map`:
1427
1431
  *
1428
1432
  * {@code
1429
1433
  * V v = map.get(key);
@@ -1,12 +1,12 @@
1
- declare module 'org.jahia.modules.npm.modules.engine.js.server' {
1
+ declare module 'org.jahia.modules.javascript.modules.engine.js.server' {
2
2
  import { Bundle } from 'org.osgi.framework';
3
3
  import { Collection, List, Map } from 'java.util';
4
4
 
5
5
  import { JCRNodeWrapper, JCRCallback } from 'org.jahia.services.content';
6
- import { Promise } from 'org.jahia.modules.npm.modules.engine.jsengine';
7
6
 
8
7
  import { JCRSiteNode } from 'org.jahia.services.content.decorator';
9
8
  import { RenderContext, Resource } from 'org.jahia.services.render';
9
+ import { Promise, Registry, ContextProvider } from 'org.jahia.modules.javascript.modules.engine.jsengine';
10
10
  /**
11
11
  * Java helper to expose OSGi configuration values to Javascript code
12
12
  */
@@ -184,6 +184,7 @@ export class RegistryHelper {
184
184
  * @param key the key of the object to remove within the type
185
185
  */
186
186
  remove(type: string, key: string): void;
187
+ getRegistry(): Registry;
187
188
  }
188
189
  /**
189
190
  * Helper class to provide rendering functions to the Javascript engine
package/types/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {ConfigHelper, GQLHelper, OSGiHelper, RegistryHelper, RenderHelper} from 'org.jahia.modules.npm.modules.engine.js.server';
1
+ import {ConfigHelper, GQLHelper, OSGiHelper, RegistryHelper, RenderHelper} from 'org.jahia.modules.javascript.modules.engine.js.server';
2
2
 
3
3
  /**
4
4
  * A set of helpers that provide common functionality provided by Jahia for Javascript server-side rendering