@discord/intl-loader-core 0.11.3 → 0.11.5
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 +2 -2
- package/src/watcher.js +9 -5
- package/types/src/watcher.d.ts +14 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discord/intl-loader-core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core utilities for writing loaders and transformers using @discord/intl",
|
|
6
6
|
"author": "Jon Egeland",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chokidar": "^3.6.0",
|
|
30
30
|
"debug": "^4.3.6",
|
|
31
|
-
"@discord/intl-message-database": "0.11.
|
|
31
|
+
"@discord/intl-message-database": "0.11.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/debug": "^4.1.12",
|
package/src/watcher.js
CHANGED
|
@@ -28,6 +28,12 @@ const ALWAYS_IGNORE_PATTERNS = [
|
|
|
28
28
|
const MESSAGES_FILE_PATTERNS = ['**/*.messages.*'];
|
|
29
29
|
const DEFAULT_LOCALE = 'en-US';
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {{
|
|
33
|
+
* on(event: string, callback: (event: string, path: string) => void): void
|
|
34
|
+
* }} BasicWatcher
|
|
35
|
+
*/
|
|
36
|
+
|
|
31
37
|
/**
|
|
32
38
|
* Start a new filesystem watcher to discover and monitor messages files, allowing consumers to
|
|
33
39
|
* react to changes in a single, consistent way.
|
|
@@ -39,9 +45,7 @@ const DEFAULT_LOCALE = 'en-US';
|
|
|
39
45
|
* persistent?: boolean,
|
|
40
46
|
* once?: boolean,
|
|
41
47
|
* }} options
|
|
42
|
-
* @returns {Promise<
|
|
43
|
-
* on(event: string, callback: (event: string, path: string) => void): void
|
|
44
|
-
* }>}
|
|
48
|
+
* @returns {Promise<BasicWatcher>}
|
|
45
49
|
*/
|
|
46
50
|
async function watchMessagesFiles(
|
|
47
51
|
watchedFolders,
|
|
@@ -94,7 +98,7 @@ async function watchMessagesFiles(
|
|
|
94
98
|
/**
|
|
95
99
|
* Watch the file system for any changes to message files and regenerate their types.
|
|
96
100
|
*
|
|
97
|
-
* @param {
|
|
101
|
+
* @param {BasicWatcher} watcher
|
|
98
102
|
* @param {{
|
|
99
103
|
* allowNullability?: boolean
|
|
100
104
|
* }} options
|
|
@@ -111,7 +115,7 @@ async function generateMessageTypes(watcher, { allowNullability }) {
|
|
|
111
115
|
* Watch the file system for changes to message _definitions_ files, and pre-process them into
|
|
112
116
|
* compiled assets (with the extension `.compiled.messages.${assetExtension}`).
|
|
113
117
|
*
|
|
114
|
-
* @param {
|
|
118
|
+
* @param {BasicWatcher} watcher
|
|
115
119
|
* @param {{
|
|
116
120
|
* ignore?: string[],
|
|
117
121
|
* assetExtension?: string
|
package/types/src/watcher.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export type BasicWatcher = {
|
|
2
|
+
on(event: string, callback: (event: string, path: string) => void): void;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {{
|
|
6
|
+
* on(event: string, callback: (event: string, path: string) => void): void
|
|
7
|
+
* }} BasicWatcher
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* Start a new filesystem watcher to discover and monitor messages files, allowing consumers to
|
|
3
11
|
* react to changes in a single, consistent way.
|
|
@@ -9,30 +17,26 @@
|
|
|
9
17
|
* persistent?: boolean,
|
|
10
18
|
* once?: boolean,
|
|
11
19
|
* }} options
|
|
12
|
-
* @returns {Promise<
|
|
13
|
-
* on(event: string, callback: (event: string, path: string) => void): void
|
|
14
|
-
* }>}
|
|
20
|
+
* @returns {Promise<BasicWatcher>}
|
|
15
21
|
*/
|
|
16
22
|
export function watchMessagesFiles(watchedFolders: string[], { ignore, skipInitial, once }?: {
|
|
17
23
|
ignore?: string[];
|
|
18
24
|
skipInitial?: boolean;
|
|
19
25
|
persistent?: boolean;
|
|
20
26
|
once?: boolean;
|
|
21
|
-
}): Promise<
|
|
22
|
-
on(event: string, callback: (event: string, path: string) => void): void;
|
|
23
|
-
}>;
|
|
27
|
+
}): Promise<BasicWatcher>;
|
|
24
28
|
/**
|
|
25
29
|
* Watch the file system for changes to message _definitions_ files, and pre-process them into
|
|
26
30
|
* compiled assets (with the extension `.compiled.messages.${assetExtension}`).
|
|
27
31
|
*
|
|
28
|
-
* @param {
|
|
32
|
+
* @param {BasicWatcher} watcher
|
|
29
33
|
* @param {{
|
|
30
34
|
* ignore?: string[],
|
|
31
35
|
* assetExtension?: string
|
|
32
36
|
* precompileOptions?: import('./processing').IntlPrecompileOptions,
|
|
33
37
|
* }} options
|
|
34
38
|
*/
|
|
35
|
-
export function precompileMessageDefinitionsFiles(watcher:
|
|
39
|
+
export function precompileMessageDefinitionsFiles(watcher: BasicWatcher, { assetExtension, precompileOptions }?: {
|
|
36
40
|
ignore?: string[];
|
|
37
41
|
assetExtension?: string;
|
|
38
42
|
precompileOptions?: import("./processing").IntlPrecompileOptions;
|
|
@@ -40,13 +44,12 @@ export function precompileMessageDefinitionsFiles(watcher: chokidar.FSWatcher, {
|
|
|
40
44
|
/**
|
|
41
45
|
* Watch the file system for any changes to message files and regenerate their types.
|
|
42
46
|
*
|
|
43
|
-
* @param {
|
|
47
|
+
* @param {BasicWatcher} watcher
|
|
44
48
|
* @param {{
|
|
45
49
|
* allowNullability?: boolean
|
|
46
50
|
* }} options
|
|
47
51
|
*/
|
|
48
|
-
export function generateMessageTypes(watcher:
|
|
52
|
+
export function generateMessageTypes(watcher: BasicWatcher, { allowNullability }: {
|
|
49
53
|
allowNullability?: boolean;
|
|
50
54
|
}): Promise<void>;
|
|
51
55
|
export const ALWAYS_IGNORE_PATTERNS: string[];
|
|
52
|
-
import chokidar = require("chokidar");
|