@fgv/ts-bcp47 5.0.1-8 → 5.0.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/dist/ts-bcp47.d.ts +3 -16
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/packlets/iana/index.browser.d.ts +1 -0
- package/lib/packlets/iana/index.browser.js +1 -0
- package/lib/packlets/iana/index.d.ts +1 -0
- package/lib/packlets/iana/index.js +1 -1
- package/lib/packlets/iana/language-subtags/subtagRegistry.d.ts +0 -3
- package/lib/packlets/iana/language-subtags/subtagRegistry.js +0 -19
- package/lib/packlets/iana/language-tag-extensions/extensionsRegistry.d.ts +0 -3
- package/lib/packlets/iana/language-tag-extensions/extensionsRegistry.js +0 -18
- package/lib/packlets/iana/languageRegistries.d.ts +0 -7
- package/lib/packlets/iana/languageRegistries.js +5 -47
- package/lib/packlets/iana/languageRegistriesFileLoader.d.ts +19 -0
- package/lib/packlets/iana/languageRegistriesFileLoader.js +113 -0
- package/lib/packlets/iana/languageRegistriesLoader.d.ts +0 -16
- package/lib/packlets/iana/languageRegistriesLoader.js +1 -46
- package/package.json +8 -8
package/dist/ts-bcp47.d.ts
CHANGED
|
@@ -348,12 +348,12 @@ declare namespace Iana {
|
|
|
348
348
|
Validate_3 as Validate,
|
|
349
349
|
nowAsYearMonthDay,
|
|
350
350
|
LanguageRegistries,
|
|
351
|
-
loadLanguageRegistries,
|
|
352
351
|
loadLanguageRegistriesFromTree,
|
|
353
|
-
loadLanguageRegistriesFromZip,
|
|
354
352
|
loadLanguageRegistriesFromZipBuffer,
|
|
355
353
|
loadLanguageRegistriesFromIanaOrg,
|
|
356
|
-
loadLanguageRegistriesFromUrls
|
|
354
|
+
loadLanguageRegistriesFromUrls,
|
|
355
|
+
loadLanguageRegistries,
|
|
356
|
+
loadLanguageRegistriesFromZip
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
export { Iana }
|
|
@@ -1080,13 +1080,6 @@ declare class LanguageRegistries {
|
|
|
1080
1080
|
* @public
|
|
1081
1081
|
*/
|
|
1082
1082
|
static loadFromUrls(subtagsUrl: string, extensionsUrl: string): Promise<Result<LanguageRegistries>>;
|
|
1083
|
-
/**
|
|
1084
|
-
* Loads language registries from a compressed ZIP file.
|
|
1085
|
-
* @param zipPath - Path to the ZIP file containing the registry data.
|
|
1086
|
-
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
1087
|
-
* @public
|
|
1088
|
-
*/
|
|
1089
|
-
static loadFromZip(zipPath: string): Result<LanguageRegistries>;
|
|
1090
1083
|
/**
|
|
1091
1084
|
* Loads language registries from a compressed ZIP buffer (web-compatible).
|
|
1092
1085
|
* @param zipBuffer - ArrayBuffer or Uint8Array containing the ZIP file data.
|
|
@@ -1289,9 +1282,6 @@ declare class LanguageSubtagRegistry {
|
|
|
1289
1282
|
static create(registry: RegistryFile_2): Result<LanguageSubtagRegistry>;
|
|
1290
1283
|
static createFromJson(from: unknown): Result<LanguageSubtagRegistry>;
|
|
1291
1284
|
static loadDefault(): Result<LanguageSubtagRegistry>;
|
|
1292
|
-
static load(root: string): Result<LanguageSubtagRegistry>;
|
|
1293
|
-
static loadJsonRegistryFile(root: string): Result<LanguageSubtagRegistry>;
|
|
1294
|
-
static loadTxtRegistryFile(root: string): Result<LanguageSubtagRegistry>;
|
|
1295
1285
|
static createFromTxtContent(content: string): Result<LanguageSubtagRegistry>;
|
|
1296
1286
|
}
|
|
1297
1287
|
|
|
@@ -1580,9 +1570,6 @@ declare class LanguageTagExtensionRegistry {
|
|
|
1580
1570
|
static create(registry: Model_2.LanguageTagExtensions): Result<LanguageTagExtensionRegistry>;
|
|
1581
1571
|
static createFromJson(from: unknown): Result<LanguageTagExtensionRegistry>;
|
|
1582
1572
|
static loadDefault(): Result<LanguageTagExtensionRegistry>;
|
|
1583
|
-
static load(path: string): Result<LanguageTagExtensionRegistry>;
|
|
1584
|
-
static loadJsonRegistryFile(path: string): Result<LanguageTagExtensionRegistry>;
|
|
1585
|
-
static loadTxtRegistryFile(path: string): Result<LanguageTagExtensionRegistry>;
|
|
1586
1573
|
static createFromTxtContent(content: string): Result<LanguageTagExtensionRegistry>;
|
|
1587
1574
|
}
|
|
1588
1575
|
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -7,5 +7,6 @@ import * as Model from './model';
|
|
|
7
7
|
import * as Validate from './validate';
|
|
8
8
|
export { DefaultRegistries } from './defaultRegistries';
|
|
9
9
|
export * from './languageRegistries';
|
|
10
|
+
export * from './languageRegistriesLoader';
|
|
10
11
|
export { Converters, Jar, Model, LanguageSubtags, LanguageTagExtensions, Validate, nowAsYearMonthDay };
|
|
11
12
|
//# sourceMappingURL=index.browser.d.ts.map
|
|
@@ -76,4 +76,5 @@ exports.Validate = Validate;
|
|
|
76
76
|
var defaultRegistries_1 = require("./defaultRegistries");
|
|
77
77
|
Object.defineProperty(exports, "DefaultRegistries", { enumerable: true, get: function () { return defaultRegistries_1.DefaultRegistries; } });
|
|
78
78
|
__exportStar(require("./languageRegistries"), exports);
|
|
79
|
+
__exportStar(require("./languageRegistriesLoader"), exports);
|
|
79
80
|
//# sourceMappingURL=index.browser.js.map
|
|
@@ -8,5 +8,6 @@ import * as Validate from './validate';
|
|
|
8
8
|
export { DefaultRegistries } from './defaultRegistries';
|
|
9
9
|
export * from './languageRegistries';
|
|
10
10
|
export * from './languageRegistriesLoader';
|
|
11
|
+
export * from './languageRegistriesFileLoader';
|
|
11
12
|
export { Converters, Jar, Model, LanguageSubtags, LanguageTagExtensions, Validate, nowAsYearMonthDay };
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -75,6 +75,6 @@ exports.Validate = Validate;
|
|
|
75
75
|
var defaultRegistries_1 = require("./defaultRegistries");
|
|
76
76
|
Object.defineProperty(exports, "DefaultRegistries", { enumerable: true, get: function () { return defaultRegistries_1.DefaultRegistries; } });
|
|
77
77
|
__exportStar(require("./languageRegistries"), exports);
|
|
78
|
-
// Export filesystem loader separately for tree-shaking
|
|
79
78
|
__exportStar(require("./languageRegistriesLoader"), exports);
|
|
79
|
+
__exportStar(require("./languageRegistriesFileLoader"), exports);
|
|
80
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -31,9 +31,6 @@ export declare class LanguageSubtagRegistry {
|
|
|
31
31
|
static create(registry: RegistryFile): Result<LanguageSubtagRegistry>;
|
|
32
32
|
static createFromJson(from: unknown): Result<LanguageSubtagRegistry>;
|
|
33
33
|
static loadDefault(): Result<LanguageSubtagRegistry>;
|
|
34
|
-
static load(root: string): Result<LanguageSubtagRegistry>;
|
|
35
|
-
static loadJsonRegistryFile(root: string): Result<LanguageSubtagRegistry>;
|
|
36
|
-
static loadTxtRegistryFile(root: string): Result<LanguageSubtagRegistry>;
|
|
37
34
|
static createFromTxtContent(content: string): Result<LanguageSubtagRegistry>;
|
|
38
35
|
}
|
|
39
36
|
//# sourceMappingURL=subtagRegistry.d.ts.map
|
|
@@ -55,7 +55,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
55
55
|
})();
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
57
|
exports.LanguageSubtagRegistry = void 0;
|
|
58
|
-
const path = __importStar(require("path"));
|
|
59
58
|
const Converters = __importStar(require("./converters"));
|
|
60
59
|
const JarConverters = __importStar(require("./jarConverters"));
|
|
61
60
|
const Scope = __importStar(require("./scope"));
|
|
@@ -138,24 +137,6 @@ class LanguageSubtagRegistry {
|
|
|
138
137
|
return registries.subtags;
|
|
139
138
|
});
|
|
140
139
|
}
|
|
141
|
-
static load(root) {
|
|
142
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
143
|
-
const registry = Converters.loadLanguageSubtagsJsonFileSync(path.join(root)).orThrow();
|
|
144
|
-
return new LanguageSubtagRegistry(registry);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
static loadJsonRegistryFile(root) {
|
|
148
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
149
|
-
const registry = JarConverters.loadJsonSubtagRegistryFileSync(path.join(root)).orThrow();
|
|
150
|
-
return new LanguageSubtagRegistry(registry);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
static loadTxtRegistryFile(root) {
|
|
154
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
155
|
-
const registry = JarConverters.loadTxtSubtagRegistryFileSync(path.join(root)).orThrow();
|
|
156
|
-
return new LanguageSubtagRegistry(registry);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
140
|
static createFromTxtContent(content) {
|
|
160
141
|
return JarConverters.loadTxtSubtagRegistryFromString(content).onSuccess(LanguageSubtagRegistry.create);
|
|
161
142
|
}
|
|
@@ -21,9 +21,6 @@ export declare class LanguageTagExtensionRegistry {
|
|
|
21
21
|
static create(registry: Model.LanguageTagExtensions): Result<LanguageTagExtensionRegistry>;
|
|
22
22
|
static createFromJson(from: unknown): Result<LanguageTagExtensionRegistry>;
|
|
23
23
|
static loadDefault(): Result<LanguageTagExtensionRegistry>;
|
|
24
|
-
static load(path: string): Result<LanguageTagExtensionRegistry>;
|
|
25
|
-
static loadJsonRegistryFile(path: string): Result<LanguageTagExtensionRegistry>;
|
|
26
|
-
static loadTxtRegistryFile(path: string): Result<LanguageTagExtensionRegistry>;
|
|
27
24
|
static createFromTxtContent(content: string): Result<LanguageTagExtensionRegistry>;
|
|
28
25
|
}
|
|
29
26
|
//# sourceMappingURL=extensionsRegistry.d.ts.map
|
|
@@ -93,24 +93,6 @@ class LanguageTagExtensionRegistry {
|
|
|
93
93
|
return registries.extensions;
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
static load(path) {
|
|
97
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
98
|
-
const registry = Converters.loadLanguageTagExtensionsJsonFileSync(path).orThrow();
|
|
99
|
-
return new LanguageTagExtensionRegistry(registry);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
static loadJsonRegistryFile(path) {
|
|
103
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
104
|
-
const registry = JarConverters.loadJsonLanguageTagExtensionsRegistryFileSync(path).orThrow();
|
|
105
|
-
return new LanguageTagExtensionRegistry(registry);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
static loadTxtRegistryFile(path) {
|
|
109
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
110
|
-
const registry = JarConverters.loadTxtLanguageTagExtensionsRegistryFileSync(path).orThrow();
|
|
111
|
-
return new LanguageTagExtensionRegistry(registry);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
96
|
static createFromTxtContent(content) {
|
|
115
97
|
return JarConverters.loadTxtLanguageTagExtensionsRegistryFromString(content).onSuccess(LanguageTagExtensionRegistry.create);
|
|
116
98
|
}
|
|
@@ -32,13 +32,6 @@ export declare class LanguageRegistries {
|
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
34
|
static loadFromUrls(subtagsUrl: string, extensionsUrl: string): Promise<Result<LanguageRegistries>>;
|
|
35
|
-
/**
|
|
36
|
-
* Loads language registries from a compressed ZIP file.
|
|
37
|
-
* @param zipPath - Path to the ZIP file containing the registry data.
|
|
38
|
-
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
static loadFromZip(zipPath: string): Result<LanguageRegistries>;
|
|
42
35
|
/**
|
|
43
36
|
* Loads language registries from a compressed ZIP buffer (web-compatible).
|
|
44
37
|
* @param zipBuffer - ArrayBuffer or Uint8Array containing the ZIP file data.
|
|
@@ -20,43 +20,10 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE.
|
|
22
22
|
*/
|
|
23
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
-
if (k2 === undefined) k2 = k;
|
|
25
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
-
}
|
|
29
|
-
Object.defineProperty(o, k2, desc);
|
|
30
|
-
}) : (function(o, m, k, k2) {
|
|
31
|
-
if (k2 === undefined) k2 = k;
|
|
32
|
-
o[k2] = m[k];
|
|
33
|
-
}));
|
|
34
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
-
}) : function(o, v) {
|
|
37
|
-
o["default"] = v;
|
|
38
|
-
});
|
|
39
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
-
var ownKeys = function(o) {
|
|
41
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
-
var ar = [];
|
|
43
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
-
return ar;
|
|
45
|
-
};
|
|
46
|
-
return ownKeys(o);
|
|
47
|
-
};
|
|
48
|
-
return function (mod) {
|
|
49
|
-
if (mod && mod.__esModule) return mod;
|
|
50
|
-
var result = {};
|
|
51
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
-
__setModuleDefault(result, mod);
|
|
53
|
-
return result;
|
|
54
|
-
};
|
|
55
|
-
})();
|
|
56
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
24
|
exports.LanguageRegistries = void 0;
|
|
58
25
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
-
const
|
|
26
|
+
const languageRegistriesLoader_1 = require("./languageRegistriesLoader");
|
|
60
27
|
const iana_data_embedded_1 = require("./iana-data-embedded");
|
|
61
28
|
/**
|
|
62
29
|
* @public
|
|
@@ -82,7 +49,7 @@ class LanguageRegistries {
|
|
|
82
49
|
static loadDefaultCompressed() {
|
|
83
50
|
return (0, ts_utils_1.captureResult)(() => {
|
|
84
51
|
const zipBuffer = (0, iana_data_embedded_1.getIanaDataBuffer)();
|
|
85
|
-
return
|
|
52
|
+
return (0, languageRegistriesLoader_1.loadLanguageRegistriesFromZipBuffer)(zipBuffer).orThrow();
|
|
86
53
|
});
|
|
87
54
|
}
|
|
88
55
|
/**
|
|
@@ -91,7 +58,7 @@ class LanguageRegistries {
|
|
|
91
58
|
* @public
|
|
92
59
|
*/
|
|
93
60
|
static loadFromIanaOrg() {
|
|
94
|
-
return
|
|
61
|
+
return (0, languageRegistriesLoader_1.loadLanguageRegistriesFromIanaOrg)();
|
|
95
62
|
}
|
|
96
63
|
/**
|
|
97
64
|
* Loads language registries from custom URLs.
|
|
@@ -101,16 +68,7 @@ class LanguageRegistries {
|
|
|
101
68
|
* @public
|
|
102
69
|
*/
|
|
103
70
|
static loadFromUrls(subtagsUrl, extensionsUrl) {
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Loads language registries from a compressed ZIP file.
|
|
108
|
-
* @param zipPath - Path to the ZIP file containing the registry data.
|
|
109
|
-
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
|
-
static loadFromZip(zipPath) {
|
|
113
|
-
return LanguageRegistriesLoader.loadLanguageRegistriesFromZip(zipPath);
|
|
71
|
+
return (0, languageRegistriesLoader_1.loadLanguageRegistriesFromUrls)(subtagsUrl, extensionsUrl);
|
|
114
72
|
}
|
|
115
73
|
/**
|
|
116
74
|
* Loads language registries from a compressed ZIP buffer (web-compatible).
|
|
@@ -119,7 +77,7 @@ class LanguageRegistries {
|
|
|
119
77
|
* @public
|
|
120
78
|
*/
|
|
121
79
|
static loadFromZipBuffer(zipBuffer) {
|
|
122
|
-
return
|
|
80
|
+
return (0, languageRegistriesLoader_1.loadLanguageRegistriesFromZipBuffer)(zipBuffer);
|
|
123
81
|
}
|
|
124
82
|
}
|
|
125
83
|
exports.LanguageRegistries = LanguageRegistries;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { LanguageRegistries } from './languageRegistries';
|
|
3
|
+
/**
|
|
4
|
+
* Loads language registries from filesystem.
|
|
5
|
+
* @param root - The root directory containing the registry JSON files or path to a ZIP file.
|
|
6
|
+
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadLanguageRegistries(root: string): Result<LanguageRegistries>;
|
|
10
|
+
/**
|
|
11
|
+
* Loads language registries from a ZIP file containing the registry JSON files.
|
|
12
|
+
* @param zipPath - Path to the ZIP file containing language-subtags.json and language-tag-extensions.json.
|
|
13
|
+
* @param subtagsPath - Path to the language-subtags.json file within the ZIP (default: 'language-subtags.json').
|
|
14
|
+
* @param extensionsPath - Path to the language-tag-extensions.json file within the ZIP (default: 'language-tag-extensions.json').
|
|
15
|
+
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadLanguageRegistriesFromZip(zipPath: string, subtagsPath?: string, extensionsPath?: string): Result<LanguageRegistries>;
|
|
19
|
+
//# sourceMappingURL=languageRegistriesFileLoader.d.ts.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.loadLanguageRegistries = loadLanguageRegistries;
|
|
61
|
+
exports.loadLanguageRegistriesFromZip = loadLanguageRegistriesFromZip;
|
|
62
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
63
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
64
|
+
const ts_extras_1 = require("@fgv/ts-extras");
|
|
65
|
+
const language_subtags_1 = require("./language-subtags");
|
|
66
|
+
const LanguageSubtagsConverters = __importStar(require("./language-subtags/converters"));
|
|
67
|
+
const language_tag_extensions_1 = require("./language-tag-extensions");
|
|
68
|
+
const LanguageTagExtensionsConverters = __importStar(require("./language-tag-extensions/converters"));
|
|
69
|
+
const languageRegistries_1 = require("./languageRegistries");
|
|
70
|
+
const languageRegistriesLoader_1 = require("./languageRegistriesLoader");
|
|
71
|
+
const path_1 = __importDefault(require("path"));
|
|
72
|
+
const fs_1 = __importDefault(require("fs"));
|
|
73
|
+
/**
|
|
74
|
+
* Loads language registries from filesystem.
|
|
75
|
+
* @param root - The root directory containing the registry JSON files or path to a ZIP file.
|
|
76
|
+
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
function loadLanguageRegistries(root) {
|
|
80
|
+
// Check if root is a ZIP file
|
|
81
|
+
if (root.toLowerCase().endsWith('.zip')) {
|
|
82
|
+
return loadLanguageRegistriesFromZip(root);
|
|
83
|
+
}
|
|
84
|
+
// Handle directory with individual JSON files
|
|
85
|
+
return (0, ts_utils_1.captureResult)(() => {
|
|
86
|
+
const subtagsData = LanguageSubtagsConverters.loadLanguageSubtagsJsonFileSync(path_1.default.join(root, 'language-subtags.json')).orThrow();
|
|
87
|
+
const subtags = language_subtags_1.LanguageSubtagRegistry.create(subtagsData).orThrow();
|
|
88
|
+
const extensionsData = LanguageTagExtensionsConverters.loadLanguageTagExtensionsJsonFileSync(path_1.default.join(root, 'language-tag-extensions.json')).orThrow();
|
|
89
|
+
const extensions = language_tag_extensions_1.LanguageTagExtensionRegistry.create(extensionsData).orThrow();
|
|
90
|
+
return languageRegistries_1.LanguageRegistries.create(subtags, extensions).orThrow();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Loads language registries from a ZIP file containing the registry JSON files.
|
|
95
|
+
* @param zipPath - Path to the ZIP file containing language-subtags.json and language-tag-extensions.json.
|
|
96
|
+
* @param subtagsPath - Path to the language-subtags.json file within the ZIP (default: 'language-subtags.json').
|
|
97
|
+
* @param extensionsPath - Path to the language-tag-extensions.json file within the ZIP (default: 'language-tag-extensions.json').
|
|
98
|
+
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
function loadLanguageRegistriesFromZip(zipPath, subtagsPath = 'language-subtags.json', extensionsPath = 'language-tag-extensions.json') {
|
|
102
|
+
return (0, ts_utils_1.captureResult)(() => {
|
|
103
|
+
// Read the ZIP file
|
|
104
|
+
const zipBuffer = fs_1.default.readFileSync(zipPath);
|
|
105
|
+
// Create ZIP file tree accessors
|
|
106
|
+
const zipAccessors = ts_extras_1.ZipFileTree.ZipFileTreeAccessors.fromBuffer(zipBuffer).orThrow();
|
|
107
|
+
// Create FileTree from ZIP accessors
|
|
108
|
+
const fileTree = ts_json_base_1.FileTree.FileTree.create(zipAccessors).orThrow();
|
|
109
|
+
// Use existing tree loading function
|
|
110
|
+
return (0, languageRegistriesLoader_1.loadLanguageRegistriesFromTree)(fileTree, subtagsPath, extensionsPath).orThrow();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=languageRegistriesFileLoader.js.map
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { Result } from '@fgv/ts-utils';
|
|
2
2
|
import { FileTree } from '@fgv/ts-json-base';
|
|
3
3
|
import { LanguageRegistries } from './languageRegistries';
|
|
4
|
-
/**
|
|
5
|
-
* Loads language registries from filesystem.
|
|
6
|
-
* @param root - The root directory containing the registry JSON files or path to a ZIP file.
|
|
7
|
-
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare function loadLanguageRegistries(root: string): Result<LanguageRegistries>;
|
|
11
4
|
/**
|
|
12
5
|
* Loads language registries from a FileTree (web-compatible).
|
|
13
6
|
* @param fileTree - The FileTree containing the registry JSON files.
|
|
@@ -17,15 +10,6 @@ export declare function loadLanguageRegistries(root: string): Result<LanguageReg
|
|
|
17
10
|
* @public
|
|
18
11
|
*/
|
|
19
12
|
export declare function loadLanguageRegistriesFromTree(fileTree: FileTree.FileTree, subtagsPath?: string, extensionsPath?: string): Result<LanguageRegistries>;
|
|
20
|
-
/**
|
|
21
|
-
* Loads language registries from a ZIP file containing the registry JSON files.
|
|
22
|
-
* @param zipPath - Path to the ZIP file containing language-subtags.json and language-tag-extensions.json.
|
|
23
|
-
* @param subtagsPath - Path to the language-subtags.json file within the ZIP (default: 'language-subtags.json').
|
|
24
|
-
* @param extensionsPath - Path to the language-tag-extensions.json file within the ZIP (default: 'language-tag-extensions.json').
|
|
25
|
-
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export declare function loadLanguageRegistriesFromZip(zipPath: string, subtagsPath?: string, extensionsPath?: string): Result<LanguageRegistries>;
|
|
29
13
|
/**
|
|
30
14
|
* Loads language registries from a ZIP buffer containing the registry JSON files (web-compatible).
|
|
31
15
|
* @param zipBuffer - ArrayBuffer or Uint8Array containing the ZIP file data.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
4
|
*
|
|
5
5
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -20,13 +20,8 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE.
|
|
22
22
|
*/
|
|
23
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
-
};
|
|
26
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.loadLanguageRegistries = loadLanguageRegistries;
|
|
28
24
|
exports.loadLanguageRegistriesFromTree = loadLanguageRegistriesFromTree;
|
|
29
|
-
exports.loadLanguageRegistriesFromZip = loadLanguageRegistriesFromZip;
|
|
30
25
|
exports.loadLanguageRegistriesFromZipBuffer = loadLanguageRegistriesFromZipBuffer;
|
|
31
26
|
exports.loadLanguageRegistriesFromIanaOrg = loadLanguageRegistriesFromIanaOrg;
|
|
32
27
|
exports.loadLanguageRegistriesFromUrls = loadLanguageRegistriesFromUrls;
|
|
@@ -36,26 +31,6 @@ const ts_extras_1 = require("@fgv/ts-extras");
|
|
|
36
31
|
const language_subtags_1 = require("./language-subtags");
|
|
37
32
|
const language_tag_extensions_1 = require("./language-tag-extensions");
|
|
38
33
|
const languageRegistries_1 = require("./languageRegistries");
|
|
39
|
-
const path_1 = __importDefault(require("path"));
|
|
40
|
-
const fs_1 = __importDefault(require("fs"));
|
|
41
|
-
/**
|
|
42
|
-
* Loads language registries from filesystem.
|
|
43
|
-
* @param root - The root directory containing the registry JSON files or path to a ZIP file.
|
|
44
|
-
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
function loadLanguageRegistries(root) {
|
|
48
|
-
// Check if root is a ZIP file
|
|
49
|
-
if (root.toLowerCase().endsWith('.zip')) {
|
|
50
|
-
return loadLanguageRegistriesFromZip(root);
|
|
51
|
-
}
|
|
52
|
-
// Handle directory with individual JSON files
|
|
53
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
54
|
-
const subtags = language_subtags_1.LanguageSubtagRegistry.load(path_1.default.join(root, 'language-subtags.json')).orThrow();
|
|
55
|
-
const extensions = language_tag_extensions_1.LanguageTagExtensionRegistry.load(path_1.default.join(root, 'language-tag-extensions.json')).orThrow();
|
|
56
|
-
return languageRegistries_1.LanguageRegistries.create(subtags, extensions).orThrow();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
34
|
/**
|
|
60
35
|
* Loads language registries from a FileTree (web-compatible).
|
|
61
36
|
* @param fileTree - The FileTree containing the registry JSON files.
|
|
@@ -79,26 +54,6 @@ function loadLanguageRegistriesFromTree(fileTree, subtagsPath = 'language-subtag
|
|
|
79
54
|
});
|
|
80
55
|
});
|
|
81
56
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Loads language registries from a ZIP file containing the registry JSON files.
|
|
84
|
-
* @param zipPath - Path to the ZIP file containing language-subtags.json and language-tag-extensions.json.
|
|
85
|
-
* @param subtagsPath - Path to the language-subtags.json file within the ZIP (default: 'language-subtags.json').
|
|
86
|
-
* @param extensionsPath - Path to the language-tag-extensions.json file within the ZIP (default: 'language-tag-extensions.json').
|
|
87
|
-
* @returns A Result containing the loaded LanguageRegistries or an error.
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
function loadLanguageRegistriesFromZip(zipPath, subtagsPath = 'language-subtags.json', extensionsPath = 'language-tag-extensions.json') {
|
|
91
|
-
return (0, ts_utils_1.captureResult)(() => {
|
|
92
|
-
// Read the ZIP file
|
|
93
|
-
const zipBuffer = fs_1.default.readFileSync(zipPath);
|
|
94
|
-
// Create ZIP file tree accessors
|
|
95
|
-
const zipAccessors = ts_extras_1.ZipFileTree.ZipFileTreeAccessors.fromBuffer(zipBuffer).orThrow();
|
|
96
|
-
// Create FileTree from ZIP accessors
|
|
97
|
-
const fileTree = ts_json_base_1.FileTree.FileTree.create(zipAccessors).orThrow();
|
|
98
|
-
// Use existing tree loading function
|
|
99
|
-
return loadLanguageRegistriesFromTree(fileTree, subtagsPath, extensionsPath).orThrow();
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
57
|
/**
|
|
103
58
|
* Loads language registries from a ZIP buffer containing the registry JSON files (web-compatible).
|
|
104
59
|
* @param zipBuffer - ArrayBuffer or Uint8Array containing the ZIP file data.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-bcp47",
|
|
3
|
-
"version": "5.0.1
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "BCP-47 Tag Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-bcp47.d.ts",
|
|
@@ -58,18 +58,18 @@
|
|
|
58
58
|
"@rushstack/heft-node-rig": "2.11.4",
|
|
59
59
|
"@types/heft-jest": "1.0.6",
|
|
60
60
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
61
|
-
"@fgv/ts-utils": "5.0.1
|
|
62
|
-
"@fgv/ts-utils-jest": "5.0.1
|
|
63
|
-
"@fgv/ts-extras": "5.0.1
|
|
64
|
-
"@fgv/ts-json-base": "5.0.1
|
|
61
|
+
"@fgv/ts-utils": "5.0.1",
|
|
62
|
+
"@fgv/ts-utils-jest": "5.0.1",
|
|
63
|
+
"@fgv/ts-extras": "5.0.1",
|
|
64
|
+
"@fgv/ts-json-base": "5.0.1"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"luxon": "^3.7.2"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@fgv/ts-utils": "5.0.1
|
|
71
|
-
"@fgv/ts-extras": "5.0.1
|
|
72
|
-
"@fgv/ts-json-base": "5.0.1
|
|
70
|
+
"@fgv/ts-utils": "5.0.1",
|
|
71
|
+
"@fgv/ts-extras": "5.0.1",
|
|
72
|
+
"@fgv/ts-json-base": "5.0.1"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "heft build --clean",
|