textbrowser 0.50.0 → 0.52.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.
Files changed (106) hide show
  1. package/.ncurc.cjs +3 -0
  2. package/CHANGES.md +13 -0
  3. package/dist/WorkInfo-es.js +655 -165
  4. package/dist/activateCallback-es.js +81 -10
  5. package/dist/dist/WorkInfo-es.d.ts +331 -0
  6. package/dist/dist/WorkInfo-es.d.ts.map +1 -0
  7. package/dist/dist/activateCallback-es.d.ts +17 -0
  8. package/dist/dist/activateCallback-es.d.ts.map +1 -0
  9. package/dist/dist/index-es.d.ts +619 -0
  10. package/dist/dist/index-es.d.ts.map +1 -0
  11. package/dist/dist/sw-helper.d.ts +3 -0
  12. package/dist/dist/sw-helper.d.ts.map +1 -0
  13. package/dist/eslint.config.d.ts +126 -0
  14. package/dist/eslint.config.d.ts.map +1 -0
  15. package/dist/index-es.js +3449 -1848
  16. package/dist/index-es.min.js +4 -4
  17. package/dist/resources/activateCallback.d.ts +23 -0
  18. package/dist/resources/activateCallback.d.ts.map +1 -0
  19. package/dist/resources/index.d.ts +128 -0
  20. package/dist/resources/index.d.ts.map +1 -0
  21. package/dist/resources/resultsDisplay.d.ts +110 -0
  22. package/dist/resources/resultsDisplay.d.ts.map +1 -0
  23. package/dist/resources/templates/index.d.ts +59 -0
  24. package/dist/resources/templates/index.d.ts.map +1 -0
  25. package/dist/resources/templates/languageSelect.d.ts +18 -0
  26. package/dist/resources/templates/languageSelect.d.ts.map +1 -0
  27. package/dist/resources/templates/resultsDisplayClient.d.ts +26 -0
  28. package/dist/resources/templates/resultsDisplayClient.d.ts.map +1 -0
  29. package/dist/resources/templates/resultsDisplayServerOrClient.d.ts +131 -0
  30. package/dist/resources/templates/resultsDisplayServerOrClient.d.ts.map +1 -0
  31. package/dist/resources/templates/utils/dom.d.ts +15 -0
  32. package/dist/resources/templates/utils/dom.d.ts.map +1 -0
  33. package/dist/resources/templates/utils/html.d.ts +3 -0
  34. package/dist/resources/templates/utils/html.d.ts.map +1 -0
  35. package/dist/resources/templates/workDisplay.d.ts +183 -0
  36. package/dist/resources/templates/workDisplay.d.ts.map +1 -0
  37. package/dist/resources/templates/workSelect.d.ts +18 -0
  38. package/dist/resources/templates/workSelect.d.ts.map +1 -0
  39. package/dist/resources/user-sample.d.ts +2 -0
  40. package/dist/resources/user-sample.d.ts.map +1 -0
  41. package/dist/resources/user.d.ts +2 -0
  42. package/dist/resources/user.d.ts.map +1 -0
  43. package/dist/resources/utils/IntlURLSearchParams.d.ts +56 -0
  44. package/dist/resources/utils/IntlURLSearchParams.d.ts.map +1 -0
  45. package/dist/resources/utils/Languages.d.ts +81 -0
  46. package/dist/resources/utils/Languages.d.ts.map +1 -0
  47. package/dist/resources/utils/Metadata.d.ts +133 -0
  48. package/dist/resources/utils/Metadata.d.ts.map +1 -0
  49. package/dist/resources/utils/Params.d.ts +30 -0
  50. package/dist/resources/utils/Params.d.ts.map +1 -0
  51. package/dist/resources/utils/Plugin.d.ts +278 -0
  52. package/dist/resources/utils/Plugin.d.ts.map +1 -0
  53. package/dist/resources/utils/ServiceWorker.d.ts +26 -0
  54. package/dist/resources/utils/ServiceWorker.d.ts.map +1 -0
  55. package/dist/resources/utils/WorkInfo.d.ts +104 -0
  56. package/dist/resources/utils/WorkInfo.d.ts.map +1 -0
  57. package/dist/resources/utils/dialogs.d.ts +155 -0
  58. package/dist/resources/utils/dialogs.d.ts.map +1 -0
  59. package/dist/resources/utils/getLocaleFallbackResults.d.ts +19 -0
  60. package/dist/resources/utils/getLocaleFallbackResults.d.ts.map +1 -0
  61. package/dist/resources/utils/sanitize.d.ts +6 -0
  62. package/dist/resources/utils/sanitize.d.ts.map +1 -0
  63. package/dist/resources/vendor/json-refs-min.d.ts +3 -0
  64. package/dist/resources/vendor/json-refs-min.d.ts.map +1 -0
  65. package/dist/resources/workDisplay.d.ts +81 -0
  66. package/dist/resources/workDisplay.d.ts.map +1 -0
  67. package/dist/resources/workSelect.d.ts +17 -0
  68. package/dist/resources/workSelect.d.ts.map +1 -0
  69. package/dist/rollup.config.d.ts +19 -0
  70. package/dist/rollup.config.d.ts.map +1 -0
  71. package/dist/server/main.d.ts +47 -0
  72. package/dist/server/main.d.ts.map +1 -0
  73. package/dist/sw-helper.d.ts +3 -0
  74. package/dist/sw-helper.d.ts.map +1 -0
  75. package/dist/sw-helper.js +52 -12
  76. package/dist/sw-sample.d.ts +2 -0
  77. package/dist/sw-sample.d.ts.map +1 -0
  78. package/general-schemas/files.jsonschema +6 -0
  79. package/package.json +32 -19
  80. package/resources/activateCallback.js +81 -10
  81. package/resources/index.js +169 -58
  82. package/resources/resultsDisplay.js +520 -153
  83. package/resources/templates/index.js +39 -17
  84. package/resources/templates/languageSelect.js +14 -1
  85. package/resources/templates/resultsDisplayClient.js +22 -3
  86. package/resources/templates/resultsDisplayServerOrClient.js +188 -49
  87. package/resources/templates/utils/dom.js +13 -2
  88. package/resources/templates/workDisplay.js +299 -76
  89. package/resources/templates/workSelect.js +16 -3
  90. package/resources/user-sample.js +1 -0
  91. package/resources/utils/IntlURLSearchParams.js +46 -4
  92. package/resources/utils/Languages.js +71 -4
  93. package/resources/utils/Metadata.js +222 -23
  94. package/resources/utils/Params.js +70 -23
  95. package/resources/utils/Plugin.js +175 -1
  96. package/resources/utils/ServiceWorker.js +49 -21
  97. package/resources/utils/WorkInfo.js +256 -44
  98. package/resources/utils/dialogs.js +105 -7
  99. package/resources/utils/getLocaleFallbackResults.js +15 -3
  100. package/resources/utils/sanitize.js +4 -0
  101. package/resources/workDisplay.js +151 -25
  102. package/resources/workSelect.js +37 -17
  103. package/server/main.js +118 -20
  104. package/sw-sample.js +2 -1
  105. package/tsconfig.json +30 -0
  106. package/resources/user.js +0 -20
@@ -4,8 +4,22 @@
4
4
  */
5
5
  /* eslint-env worker -- Worker environment */
6
6
 
7
+ /**
8
+ * @typedef {import('./utils/Metadata.js')} MetadataFile
9
+ */
10
+
11
+ /**
12
+ * @typedef {number} Integer
13
+ */
7
14
  const {ceil} = Math;
15
+
16
+ /* eslint-disable jsdoc/reject-any-type -- Generic */
17
+ /**
18
+ * @param {any[]} arr
19
+ * @param {number} size
20
+ */
8
21
  const arrayChunk = (arr, size) => {
22
+ /* eslint-enable jsdoc/reject-any-type -- Generic */
9
23
  return Array.from({length: ceil(arr.length / size)}, (_, i) => {
10
24
  const offset = i * size;
11
25
  return arr.slice(offset, offset + size);
@@ -18,16 +32,18 @@ const arrayChunk = (arr, size) => {
18
32
  // files in cache?
19
33
  // Todo: Check `oldVersion` and run this first if still too old
20
34
 
35
+ /* eslint-disable jsdoc/reject-any-type -- Generic */
21
36
  /**
22
37
  * @callback Logger
23
38
  * @param {...any} args
24
39
  * @returns {void}
25
40
  */
41
+ /* eslint-enable jsdoc/reject-any-type -- Generic */
26
42
 
27
43
  /**
28
- * @param {PlainObject} cfg
44
+ * @param {object} cfg
29
45
  * @param {string} cfg.namespace
30
- * @param {string[]} cfg.files
46
+ * @param {string} cfg.files The files.json path
31
47
  * @param {Logger} cfg.log
32
48
  * @param {string} [cfg.basePath]
33
49
  * @returns {Promise<void>}
@@ -41,17 +57,36 @@ async function activateCallback ({
41
57
  // already-running versions upon future sw updates
42
58
  log('Activate: Callback called');
43
59
  const r = await fetch(files);
44
- const {groups} = await r.json();
60
+ const {groups} = /** @type {import('./utils/WorkInfo.js').FilesObject} */ (
61
+ await r.json()
62
+ );
45
63
 
64
+ /* eslint-disable jsdoc/reject-any-type -- Generic */
65
+ /**
66
+ * @param {any[]} arr
67
+ * @param {string} path
68
+ */
46
69
  const addJSONFetch = (arr, path) => {
70
+ /* eslint-enable jsdoc/reject-any-type -- Generic */
47
71
  arr.push(
48
72
  (async () => (await fetch(basePath + path)).json())()
49
73
  );
50
74
  };
51
75
 
76
+ /** @type {string[]} */
52
77
  const dataFileNames = [];
78
+
79
+ /** @type {import('./utils/WorkInfo.js').WorkTableContainer[]} */
53
80
  const dataFiles = [];
81
+
82
+ /**
83
+ * @typedef {import('json-schema').JSONSchema4} SchemaFile
84
+ */
85
+
86
+ /** @type {SchemaFile[]} */
54
87
  const schemaFiles = [];
88
+
89
+ /** @type {MetadataFile[]} */
55
90
  const metadataFiles = [];
56
91
  groups.forEach(
57
92
  ({files: fileObjs, metadataBaseDirectory, schemaBaseDirectory}) => {
@@ -59,8 +94,8 @@ async function activateCallback ({
59
94
  // We don't i18nize the name here
60
95
  dataFileNames.push(name);
61
96
  addJSONFetch(dataFiles, filePath);
62
- addJSONFetch(metadataFiles, metadataBaseDirectory + '/' + metadataFile);
63
97
  addJSONFetch(schemaFiles, schemaBaseDirectory + '/' + schemaFile);
98
+ addJSONFetch(metadataFiles, metadataBaseDirectory + '/' + metadataFile);
64
99
  });
65
100
  }
66
101
  );
@@ -69,18 +104,20 @@ async function activateCallback ({
69
104
  ]);
70
105
  const chunked = arrayChunk(promises, dataFiles.length);
71
106
  const [
72
- dataFileResponses, schemaFileResponses, metadataFileResponses
107
+ , schemaFileResponses, metadataFileResponses
73
108
  ] = chunked;
109
+ const dataFileResponses = /** @type {{data: (Integer|string)[][]}[]} */ (chunked[0]);
74
110
 
75
111
  log('Activate: Files fetched');
76
112
  const dbName = namespace + '-textbrowser-cache-data';
77
113
  indexedDB.deleteDatabase(dbName);
78
114
  return new Promise((resolve, reject) => {
79
115
  const req = indexedDB.open(dbName);
116
+ // @ts-expect-error Ok
80
117
  req.addEventListener('upgradeneeded', ({target: {result: db}}) => {
81
118
  db.onversionchange = () => {
82
119
  db.close();
83
- const err = new Error('versionchange');
120
+ const err = /** @type {Error & {type: string}} */ (new Error('versionchange'));
84
121
  err.type = 'versionchange';
85
122
  reject(err);
86
123
  };
@@ -90,11 +127,27 @@ async function activateCallback ({
90
127
 
91
128
  const schemaFileResponse = schemaFileResponses[i];
92
129
  const metadataFileResponse = metadataFileResponses[i];
93
- const fieldItems = schemaFileResponse.items.items;
130
+ const fieldItems = /** @type {{title: string}[]} */ (
131
+ schemaFileResponse.items.items
132
+ );
94
133
 
95
- let browseFields = metadataFileResponse.table.browse_fields;
134
+ /**
135
+ * @typedef {{
136
+ * name?: string,
137
+ * presort?: boolean,
138
+ * set: string[]
139
+ * }} NameSet
140
+ */
141
+
142
+ let browseFields =
143
+ /**
144
+ * @type {(string|NameSet)[]|NameSet}
145
+ */ (
146
+ metadataFileResponse.table.browse_fields
147
+ );
96
148
  browseFields = Array.isArray(browseFields) ? browseFields : [browseFields];
97
149
 
150
+ /** @type {string[]} */
98
151
  const columnIndexes = [];
99
152
  browseFields.forEach((browseFieldSetObj) => {
100
153
  if (typeof browseFieldSetObj === 'string') {
@@ -133,24 +186,42 @@ async function activateCallback ({
133
186
  // Todo: Optionally send notice when complete
134
187
  // To take advantage of indexes on our arrays, we
135
188
  // need to transform them to objects! See https://github.com/w3c/IndexedDB/issues/209
189
+
190
+ /**
191
+ * The `value` property alone contains the latter
192
+ * `(Integer|string)[]` value.
193
+ * @type {{
194
+ * [key: string]: string|Integer|(Integer|string)[]
195
+ * }}
196
+ */
136
197
  const objRow = {
137
198
  value: tableRow
138
199
  };
139
200
  uniqueColumnIndexes.forEach((colIdx) => {
140
- objRow[colIdx] = tableRow[colIdx.slice(1)];
201
+ // Indexed like c0, c1, c2, etc.
202
+ objRow[colIdx] = tableRow[Number.parseInt(colIdx.slice(1))];
141
203
  });
142
204
  // log('objRow', objRow);
143
205
  store.put(objRow, j);
144
206
  });
145
207
  });
146
208
  });
209
+
210
+ // @ts-expect-error Ok
147
211
  req.addEventListener('success', ({target: {result: db}}) => {
148
212
  log('Activate: Database set-up complete', db);
149
213
  // Todo: Replace this with `ready()` check
150
214
  // in calling code?
151
215
  resolve();
152
216
  });
153
- const onerr = ({error = new Error('dbError')}) => {
217
+
218
+ /**
219
+ * @param {Event & {error?: Error}} ev
220
+ */
221
+ const onerr = (ev) => {
222
+ const error = /** @type {Error & {type: string}} */ (
223
+ ev.error ?? new Error('dbError')
224
+ );
154
225
  error.type = 'dbError';
155
226
  reject(error);
156
227
  };
@@ -0,0 +1,331 @@
1
+ export type getJSONCallback = (jsonURL: string | string[], cb: SimpleJSONCallback, errBack: SimpleJSONErrback) => Promise<JSON>;
2
+ export type PromiseChainErrback = (value: any) => Promise<any> | any;
3
+ export type KeyCheckerConverterCallback = (key: string | string[], messageStyle: "plain" | "plainNested" | "rich" | "richNested" | any) => any;
4
+ export type Sort = any;
5
+ export type SortList = any;
6
+ export type List = any;
7
+ export type I18NCallback = any;
8
+ export type Integer = number;
9
+ export type JSON6 = any;
10
+ export type AnyValue = any;
11
+ export type BetweenMatches = (str: string) => void;
12
+ export type AfterMatch = (str: string) => void;
13
+ export type EscapeAtOne = (str: string) => void;
14
+ export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
15
+ /**
16
+ * Callback to give replacement text based on a substitution value.
17
+ *
18
+ * `value` - contains the value returned by the individual substitution.
19
+ * `arg` - See `cfg.arg` of {@link SubstitutionCallback}.
20
+ * `key` - The substitution key Not currently in use
21
+ * `locale` - The locale.
22
+ */
23
+ export type AllSubstitutionCallback = (info: {
24
+ value: any;
25
+ arg?: string;
26
+ key?: string;
27
+ locale?: string;
28
+ }) => string | Node;
29
+ /**
30
+ * `arg` - By default, accepts the third portion of the
31
+ * `formattingRegex` within `insertNodes`, i.e., to allow the locale to
32
+ * supply arguments back to the calling script.
33
+ * `key` - The substitution key.
34
+ */
35
+ export type SubstitutionCallback = (cfg: {
36
+ arg: string;
37
+ key: string;
38
+ }) => string | Element;
39
+ /**
40
+ * May have additional properties if supplying options to an underlying
41
+ * formatter.
42
+ * The first value is the main value.
43
+ * The second are the options related to the main value.
44
+ * The third are any additional options.
45
+ */
46
+ export type ValueArray = [string | number | Date, object?, object?];
47
+ export type ListValueArray = [string[], (((item: string, i: Integer) => Element) | object)?, object?, object?];
48
+ export type DateRangeValueArray = [Date | number, Date | number, Intl.DateTimeFormatOptions | undefined];
49
+ export type RelativeValueArray = [number, Intl.RelativeTimeFormatUnit, object?];
50
+ export type RelativeTimeInfo = {
51
+ relative: RelativeValueArray;
52
+ };
53
+ export type ListInfo = {
54
+ list: ListValueArray;
55
+ };
56
+ export type NumberInfo = {
57
+ number: ValueArray | number;
58
+ };
59
+ export type DateInfo = {
60
+ date: ValueArray;
61
+ };
62
+ export type DateTimeInfo = {
63
+ datetime: ValueArray;
64
+ };
65
+ export type DateRangeInfo = {
66
+ dateRange: DateRangeValueArray;
67
+ };
68
+ export type DatetimeRangeInfo = {
69
+ datetimeRange: DateRangeValueArray;
70
+ };
71
+ export type RegionInfo = {
72
+ region: ValueArray;
73
+ };
74
+ export type LanguageInfo = {
75
+ language: ValueArray;
76
+ };
77
+ export type ScriptInfo = {
78
+ script: ValueArray;
79
+ };
80
+ export type CurrencyInfo = {
81
+ currency: ValueArray;
82
+ };
83
+ export type PluralInfo = {
84
+ plural: ValueArray;
85
+ };
86
+ export type PlainLocaleStringBodyObject = {
87
+ [key: string]: string;
88
+ };
89
+ export type PlainNestedLocaleStringBodyObject = {
90
+ [key: string]: string | PlainNestedLocaleStringBodyObject;
91
+ };
92
+ export type SwitchCaseInfo = {
93
+ /**
94
+ * Whether this conditional is the default
95
+ */
96
+ default?: boolean | undefined;
97
+ };
98
+ /**
99
+ * Contains the type, the message, and optional info about the switch case.
100
+ */
101
+ export type SwitchCaseArray = [string, string, SwitchCaseInfo?];
102
+ export type SwitchArray = {
103
+ [x: string]: SwitchCaseArray;
104
+ };
105
+ export type SwitchArrays = {
106
+ [x: string]: SwitchArray;
107
+ };
108
+ export type SwitchCase = {
109
+ /**
110
+ * The locale message with any formatting
111
+ * place-holders; defaults to use of any single conditional
112
+ */
113
+ message: string;
114
+ /**
115
+ * A description to add for translators
116
+ */
117
+ description?: string | undefined;
118
+ };
119
+ export type Switch = {
120
+ [x: string]: SwitchCase;
121
+ };
122
+ export type Switches = {
123
+ [x: string]: Switch;
124
+ };
125
+ export type RichLocaleStringSubObject = {
126
+ /**
127
+ * The locale message with any formatting
128
+ * place-holders; defaults to use of any single conditional
129
+ */
130
+ message: string;
131
+ /**
132
+ * A description to add for translators
133
+ */
134
+ description?: string | undefined;
135
+ /**
136
+ * Conditionals
137
+ */
138
+ switches?: {
139
+ [x: string]: {
140
+ [x: string]: SwitchCase;
141
+ };
142
+ } | undefined;
143
+ };
144
+ export type RichLocaleStringBodyObject = {
145
+ [key: string]: RichLocaleStringSubObject;
146
+ };
147
+ export type RichNestedLocaleStringBodyObject = {
148
+ [key: string]: RichLocaleStringSubObject | RichNestedLocaleStringBodyObject;
149
+ };
150
+ /**
151
+ * Takes a base path and locale and gives a URL.
152
+ */
153
+ export type LocaleResolver = (localesBasePath: string, locale: string) => string | false;
154
+ export type DateRange = [Date | number, Date | number, (Intl.DateTimeFormatOptions | undefined)?];
155
+ export type SubstitutionObjectValue = string | string[] | number | Date | DateRange | Element | Node | SubstitutionCallback | NumberInfo | PluralInfo | CurrencyInfo | LanguageInfo | ScriptInfo | DatetimeRangeInfo | DateRangeInfo | RegionInfo | DateTimeInfo | DateInfo | ListInfo | RelativeTimeInfo;
156
+ export type SubstitutionObject = {
157
+ [key: string]: SubstitutionObjectValue;
158
+ };
159
+ export type Replace = (cfg: {
160
+ str: string;
161
+ substs?: any;
162
+ formatter?: any | any | any;
163
+ }) => string;
164
+ export type ProcessSubstitutions = (cfg: {
165
+ str: string;
166
+ substs?: any;
167
+ formatter?: any | any | any;
168
+ }) => (string | Node)[];
169
+ /**
170
+ * Callback to return a string or array of nodes and strings based on
171
+ * a localized string, substitutions object, and other metadata.
172
+ *
173
+ * `string` - The localized string.
174
+ * `dom` - If substitutions known to contain DOM, can be set
175
+ * to `true` to optimize.
176
+ * `usedKeys` - Array for tracking which keys have been used. Defaults
177
+ * to empty array.
178
+ * `substitutions` - The formatting substitutions object.
179
+ * `allSubstitutions` - The
180
+ * callback or array composed thereof for applying to each substitution.
181
+ * `locale` - The successfully resolved locale
182
+ * `locals` - The local section.
183
+ * `switches` - The switch section.
184
+ * `maximumLocalNestingDepth` - Depth of local variable resolution to
185
+ * check before reporting a recursion error. Defaults to 3.
186
+ * `missingSuppliedFormatters` - Callback
187
+ * supplied key to throw if the supplied key is present (if
188
+ * `throwOnMissingSuppliedFormatters` is enabled). Defaults to no-op.
189
+ * `checkExtraSuppliedFormatters` - No
190
+ * argument callback to check if any formatters are not present in `string`
191
+ * (if `throwOnExtraSuppliedFormatters` is enabled). Defaults to no-op.
192
+ */
193
+ export type InsertNodesCallback = (cfg: {
194
+ string: string;
195
+ dom?: boolean;
196
+ usedKeys: string[];
197
+ substitutions: any;
198
+ allSubstitutions?: (any | any[]) | null;
199
+ locale: string | undefined;
200
+ locals?: any | undefined;
201
+ switches: any | undefined;
202
+ maximumLocalNestingDepth?: Integer;
203
+ missingSuppliedFormatters: any;
204
+ checkExtraSuppliedFormatters: any;
205
+ }) => string | (Node | string)[];
206
+ export type LocalObject = LocaleBody;
207
+ /**
208
+ * May also contain language code and direction, translator name and
209
+ * contact, etc., but no defaults currently apply besides reserving `locals`
210
+ */
211
+ export type LocaleHead = {
212
+ locals?: LocalObject;
213
+ switches?: any;
214
+ };
215
+ export type LocaleBody = any | any | any | any | object;
216
+ export type LocaleObject = {
217
+ head?: LocaleHead | undefined;
218
+ body: LocaleBody;
219
+ };
220
+ export type MessageStyleCallbackResult = {
221
+ /**
222
+ * Regardless of message style, will contain
223
+ * the string result
224
+ */
225
+ value: string;
226
+ /**
227
+ * Full info on the localized item
228
+ * (for rich message styles only)
229
+ */
230
+ info?: any;
231
+ };
232
+ export type MessageStyleCallback = (obj: LocaleObject, key: string) => false | MessageStyleCallbackResult;
233
+ export type CheckExtraSuppliedFormattersCallback = (substs: any | {
234
+ substitutions: import("./defaultLocaleResolver.js").SubstitutionObject;
235
+ }) => any;
236
+ export type MissingSuppliedFormattersCallback = (cfg: {
237
+ key: string;
238
+ formatter: any | any | any;
239
+ }) => boolean;
240
+ export type LocaleObjectInfo = {
241
+ /**
242
+ * The successfully retrieved locale strings
243
+ */
244
+ strings: any;
245
+ /**
246
+ * The successfully resolved locale
247
+ */
248
+ locale: string;
249
+ };
250
+ export type LocaleStringArgs = {
251
+ locales?: string[];
252
+ defaultLocales?: string[];
253
+ localesBasePath?: string;
254
+ localeResolver?: any;
255
+ localeMatcher?: "lookup" | LocaleMatcher;
256
+ };
257
+ /**
258
+ * `locales` - BCP-47 language strings. Defaults to `navigator.languages`.
259
+ * `defaultLocales` - Defaults to ["en-US"].
260
+ * `localesBasePath` - Defaults to `.`.
261
+ * `localeResolver` - Defaults to `defaultLocaleResolver`.
262
+ */
263
+ export type LocaleStringFinder = (cfg?: LocaleStringArgs) => Promise<LocaleObjectInfo>;
264
+ export function getFilePaths(filesObj: any, fileGroup: any, fileData: any): {
265
+ file: string;
266
+ schemaFile: string;
267
+ metadataFile: string;
268
+ };
269
+ export function getWorkData({ lang, fallbackLanguages, work, files, allowPlugins, basePath, languages, preferredLocale }: {
270
+ lang: any;
271
+ fallbackLanguages: any;
272
+ work: any;
273
+ files: any;
274
+ allowPlugins: any;
275
+ basePath: any;
276
+ languages: any;
277
+ preferredLocale: any;
278
+ }): Promise<{
279
+ fileData: undefined;
280
+ workI18n: any;
281
+ getFieldAliasOrName: (field: any) => any;
282
+ metadataObj: any;
283
+ schemaObj: any;
284
+ schemaItems: any;
285
+ fieldInfo: any;
286
+ pluginsForWork: PluginsForWork;
287
+ groupsToWorks: any;
288
+ metadata: Metadata;
289
+ }>;
290
+ /**
291
+ * Imported by the `dist/sw-helper.js`
292
+ * @param {string} files The files.json file path
293
+ * @returns {PlainObject}
294
+ */
295
+ export function getWorkFiles(files: string): PlainObject;
296
+ declare class PluginsForWork {
297
+ constructor({ pluginsInWork, pluginFieldMappings, pluginObjects }: {
298
+ pluginsInWork: any;
299
+ pluginFieldMappings: any;
300
+ pluginObjects: any;
301
+ });
302
+ pluginsInWork: any;
303
+ pluginFieldMappings: any;
304
+ pluginObjects: any;
305
+ getPluginObject(pluginName: any): any;
306
+ iterateMappings(cb: any): void;
307
+ processTargetLanguages(applicableFields: any, cb: any): boolean;
308
+ isPluginField({ namespace, field }: {
309
+ namespace: any;
310
+ field: any;
311
+ }): any;
312
+ getPluginFieldParts({ namespace, field }: {
313
+ namespace: any;
314
+ field: any;
315
+ }): any[];
316
+ }
317
+ declare class Metadata {
318
+ constructor({ metadataObj }: {
319
+ metadataObj: any;
320
+ });
321
+ metadataObj: any;
322
+ getFieldLang(field: any): any;
323
+ getFieldMatchesLocale({ namespace, preferredLocale, schemaItems, pluginsForWork }: {
324
+ namespace: any;
325
+ preferredLocale: any;
326
+ schemaItems: any;
327
+ pluginsForWork: any;
328
+ }): (field: any) => any;
329
+ }
330
+ export {};
331
+ //# sourceMappingURL=WorkInfo-es.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkInfo-es.d.ts","sourceRoot":"","sources":["../WorkInfo-es.js"],"names":[],"mappings":"wCAIW,MAAM,GAAC,MAAM,EAAE,MACf,kBAAkB,WAClB,iBAAiB,KACf,OAAO,CAAC,IAAI,CAAC;kCAo+Cb,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAC,GAAG;gDA00BlC,MAAM,GAAC,MAAM,EAAE,gBAEf,OAAO,GAAC,aAAa,GAAC,MAAM,GACtC,YAAgB,GAChB,GAA+D;mBA2kBnD,GAAyB;uBAGzB,GAA6B;mBAG7B,GAAyB;2BAIzB,GAAiC;sBAqCjC,MAAM;oBA91EN,GAAG;uBAiBH,GAAG;mCAkBL,MAAM,KACJ,IAAI;+BAKN,MAAM,KACJ,IAAI;gCAKN,MAAM,KACJ,IAAI;oBAyDJ,CACR,KAAK,EAAE,WAAW,GAAC,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KACvC,OAAO,CAAC,QAAQ,CAAC;;;;;;;;;sCAkMZ,CAAC,IAAI,EAAE;IACf,KAAK,EAAE,GAA4D,CAAA;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CA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ACD,gEAgBC;IACD;;;YAEC;IACD;;;cASC;CACF;AAhJD;IACE;;OAEC;IADC,iBAA8B;IAGhC,8BAIC;IAED;;;;;4BAoCC;CACF"}
@@ -0,0 +1,17 @@
1
+ export { activateCallback as default };
2
+ export type Logger = (...args: any[]) => void;
3
+ /**
4
+ * @callback Logger
5
+ * @param {...any} args
6
+ * @returns {void}
7
+ */
8
+ /**
9
+ * @param {PlainObject} cfg
10
+ * @param {string} cfg.namespace
11
+ * @param {string[]} cfg.files
12
+ * @param {Logger} cfg.log
13
+ * @param {string} [cfg.basePath]
14
+ * @returns {Promise<void>}
15
+ */
16
+ declare function activateCallback({ namespace, files, log, basePath }: PlainObject): Promise<void>;
17
+ //# sourceMappingURL=activateCallback-es.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activateCallback-es.d.ts","sourceRoot":"","sources":["../activateCallback-es.js"],"names":[],"mappings":";+BAsBa,GAAG,EAAA,KACJ,IAAI;AAHhB;;;;EAIE;AAEF;;;;;;;GAOG;AACH,uEAPW,WAAW,GAKT,OAAO,CAAC,IAAI,CAAC,CA+HzB"}