@worldware/msg 0.5.5 → 0.6.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 (49) hide show
  1. package/README.md +4 -7
  2. package/dist/chunk-4SWDABOO.mjs +135 -0
  3. package/dist/chunk-GHRFKA7N.mjs +72 -0
  4. package/dist/chunk-OMRO6GAZ.mjs +10 -0
  5. package/dist/chunk-XS43NAP2.mjs +42 -0
  6. package/dist/chunk-ZKG5QRBZ.mjs +0 -0
  7. package/dist/classes/MsgInterface/MsgInterface.cjs +34 -0
  8. package/dist/classes/MsgInterface/MsgInterface.d.cts +17 -0
  9. package/dist/classes/MsgInterface/MsgInterface.d.ts +6 -6
  10. package/dist/classes/MsgInterface/MsgInterface.mjs +6 -0
  11. package/dist/classes/MsgMessage/MsgMessage.cjs +96 -0
  12. package/dist/classes/MsgMessage/MsgMessage.d.cts +36 -0
  13. package/dist/classes/MsgMessage/MsgMessage.d.ts +9 -9
  14. package/dist/classes/MsgMessage/MsgMessage.mjs +6 -0
  15. package/dist/classes/MsgProject/MsgProject.cjs +66 -0
  16. package/dist/classes/MsgProject/MsgProject.d.cts +63 -0
  17. package/dist/classes/MsgProject/MsgProject.d.ts +37 -6
  18. package/dist/classes/MsgProject/MsgProject.mjs +6 -0
  19. package/dist/classes/MsgResource/MsgResource.cjs +230 -0
  20. package/dist/classes/MsgResource/MsgResource.d.cts +4 -0
  21. package/dist/classes/MsgResource/MsgResource.d.ts +4 -31
  22. package/dist/classes/MsgResource/MsgResource.mjs +8 -0
  23. package/dist/classes/index.cjs +273 -0
  24. package/dist/classes/index.d.cts +4 -0
  25. package/dist/classes/index.d.ts +4 -4
  26. package/dist/classes/index.mjs +16 -0
  27. package/dist/index.cjs +273 -0
  28. package/dist/index.d.cts +4 -0
  29. package/dist/index.d.ts +4 -2
  30. package/dist/index.mjs +16 -0
  31. package/package.json +3 -2
  32. package/dist/classes/MsgInterface/MsgInterface.d.ts.map +0 -1
  33. package/dist/classes/MsgInterface/MsgInterface.js +0 -6
  34. package/dist/classes/MsgInterface/MsgInterface.js.map +0 -1
  35. package/dist/classes/MsgMessage/MsgMessage.d.ts.map +0 -1
  36. package/dist/classes/MsgMessage/MsgMessage.js +0 -76
  37. package/dist/classes/MsgMessage/MsgMessage.js.map +0 -1
  38. package/dist/classes/MsgProject/MsgProject.d.ts.map +0 -1
  39. package/dist/classes/MsgProject/MsgProject.js +0 -35
  40. package/dist/classes/MsgProject/MsgProject.js.map +0 -1
  41. package/dist/classes/MsgResource/MsgResource.d.ts.map +0 -1
  42. package/dist/classes/MsgResource/MsgResource.js +0 -126
  43. package/dist/classes/MsgResource/MsgResource.js.map +0 -1
  44. package/dist/classes/index.d.ts.map +0 -1
  45. package/dist/classes/index.js +0 -4
  46. package/dist/classes/index.js.map +0 -1
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js +0 -2
  49. package/dist/index.js.map +0 -1
@@ -1,4 +1,7 @@
1
- import { type MsgResourceData } from "../MsgResource/MsgResource.js";
1
+ import { MsgMessageData, MsgMessage } from '../MsgMessage/MsgMessage.js';
2
+ import { MsgAttributes, MsgNote, MsgInterface } from '../MsgInterface/MsgInterface.js';
3
+ import 'messageformat';
4
+
2
5
  type MsgProjectSettings = {
3
6
  name: string;
4
7
  version?: number;
@@ -11,13 +14,13 @@ type MsgLocalesSettings = {
11
14
  pseudoLocale: string;
12
15
  targetLocales: MsgTargetLocalesSettings;
13
16
  };
14
- export type MsgTranslationLoader = (project: string, title: string, lang: string) => Promise<MsgResourceData>;
15
- export type MsgProjectData = {
17
+ type MsgTranslationLoader = (project: string, title: string, lang: string) => Promise<MsgResourceData>;
18
+ type MsgProjectData = {
16
19
  project: MsgProjectSettings;
17
20
  locales: MsgLocalesSettings;
18
21
  loader: MsgTranslationLoader;
19
22
  };
20
- export declare class MsgProject {
23
+ declare class MsgProject {
21
24
  _project: MsgProjectSettings;
22
25
  _locales: MsgLocalesSettings;
23
26
  _loader: MsgTranslationLoader;
@@ -28,5 +31,33 @@ export declare class MsgProject {
28
31
  get loader(): MsgTranslationLoader;
29
32
  getTargetLocale(locale: string): string[] | undefined;
30
33
  }
31
- export {};
32
- //# sourceMappingURL=MsgProject.d.ts.map
34
+
35
+ type MsgResourceData = {
36
+ title: string;
37
+ attributes: MsgAttributes;
38
+ notes?: MsgNote[];
39
+ messages?: MsgMessageData[];
40
+ };
41
+ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterface {
42
+ private _attributes;
43
+ private _notes;
44
+ private _title;
45
+ private _project;
46
+ static create(data: MsgResourceData, project: MsgProject): MsgResource;
47
+ private constructor();
48
+ get attributes(): MsgAttributes;
49
+ set attributes(attributes: MsgAttributes);
50
+ get notes(): MsgNote[];
51
+ set notes(notes: MsgNote[]);
52
+ addNote(note: MsgNote): void;
53
+ get title(): string;
54
+ set title(title: string);
55
+ getProject(): MsgProject;
56
+ add(key: string, value: string, attributes?: MsgAttributes, notes?: MsgNote[]): this;
57
+ translate(data: MsgResourceData): MsgResource;
58
+ getTranslation(lang: string): Promise<MsgResource>;
59
+ getData(stripNotes?: boolean): MsgResourceData;
60
+ toJSON(stripNotes?: boolean): string;
61
+ }
62
+
63
+ export { type MsgResourceData as M, MsgProject, type MsgProjectData, type MsgTranslationLoader, MsgResource as a };
@@ -0,0 +1,6 @@
1
+ import {
2
+ MsgProject
3
+ } from "../../chunk-XS43NAP2.mjs";
4
+ export {
5
+ MsgProject
6
+ };
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/classes/MsgResource/MsgResource.ts
21
+ var MsgResource_exports = {};
22
+ __export(MsgResource_exports, {
23
+ MsgResource: () => MsgResource
24
+ });
25
+ module.exports = __toCommonJS(MsgResource_exports);
26
+
27
+ // src/classes/MsgMessage/MsgMessage.ts
28
+ var import_messageformat = require("messageformat");
29
+ var DEFAULT_ATTRIBUTES = {
30
+ lang: "",
31
+ dir: "",
32
+ dnt: false
33
+ };
34
+ var MsgMessage = class _MsgMessage {
35
+ _key;
36
+ _value;
37
+ _mf;
38
+ _attributes = DEFAULT_ATTRIBUTES;
39
+ _notes = [];
40
+ constructor(key, value, attributes, notes) {
41
+ this._key = key;
42
+ this._value = value;
43
+ this._attributes = attributes ? { ...this._attributes, ...attributes } : this._attributes;
44
+ if (notes) {
45
+ notes.forEach((note) => this.addNote(note));
46
+ }
47
+ }
48
+ static create(data) {
49
+ const { key, value, attributes, notes } = data;
50
+ const message = new _MsgMessage(key, value, attributes, notes);
51
+ return message;
52
+ }
53
+ get key() {
54
+ return this._key;
55
+ }
56
+ get value() {
57
+ return this._value;
58
+ }
59
+ get attributes() {
60
+ return this._attributes;
61
+ }
62
+ get notes() {
63
+ return this._notes;
64
+ }
65
+ addNote(note) {
66
+ this.notes.push(note);
67
+ }
68
+ format(data, options) {
69
+ if (!this._mf) {
70
+ this._mf = new import_messageformat.MessageFormat(this.attributes.lang, this.value, options);
71
+ }
72
+ return this._mf.format(data);
73
+ }
74
+ formatToParts(data, options) {
75
+ if (!this._mf) {
76
+ this._mf = new import_messageformat.MessageFormat(this.attributes.lang, this.value, options);
77
+ }
78
+ return this._mf?.formatToParts(data);
79
+ }
80
+ getData(stripNotes = false) {
81
+ return {
82
+ key: this.key,
83
+ value: this.value,
84
+ attributes: this.attributes,
85
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : void 0
86
+ };
87
+ }
88
+ toString() {
89
+ return this.value;
90
+ }
91
+ toJSON(stripNotes = false) {
92
+ return JSON.stringify(this.getData(stripNotes), null, 2);
93
+ }
94
+ };
95
+
96
+ // src/classes/MsgInterface/MsgInterface.ts
97
+ var DEFAULT_ATTRIBUTES2 = {
98
+ lang: "",
99
+ dir: "",
100
+ dnt: false
101
+ };
102
+
103
+ // src/classes/MsgResource/MsgResource.ts
104
+ var MsgResource = class _MsgResource extends Map {
105
+ _attributes = DEFAULT_ATTRIBUTES2;
106
+ _notes = [];
107
+ _title;
108
+ _project;
109
+ static create(data, project) {
110
+ const { title, attributes, notes, messages } = data;
111
+ const res = new _MsgResource(title, attributes, project, notes);
112
+ if (messages) {
113
+ messages.forEach((messageData) => {
114
+ const { key, value, attributes: attributes2, notes: notes2 } = messageData;
115
+ res.add(key, value, attributes2, notes2);
116
+ });
117
+ } else {
118
+ res.clear();
119
+ }
120
+ return res;
121
+ }
122
+ constructor(title, attributes, project, notes) {
123
+ super();
124
+ this._title = title;
125
+ this._attributes = { ...this._attributes, ...attributes };
126
+ this._project = project;
127
+ if (notes) {
128
+ notes.forEach((note) => this.addNote(note));
129
+ }
130
+ }
131
+ get attributes() {
132
+ return this._attributes;
133
+ }
134
+ set attributes(attributes) {
135
+ this._attributes = attributes;
136
+ }
137
+ get notes() {
138
+ return this._notes;
139
+ }
140
+ set notes(notes) {
141
+ this._notes = notes;
142
+ }
143
+ addNote(note) {
144
+ this.notes.push(note);
145
+ }
146
+ get title() {
147
+ return this._title;
148
+ }
149
+ set title(title) {
150
+ this._title = title;
151
+ }
152
+ getProject() {
153
+ return this._project;
154
+ }
155
+ add(key, value, attributes, notes) {
156
+ const merged = { ...this.attributes, ...attributes };
157
+ const msg = MsgMessage.create({
158
+ key,
159
+ value,
160
+ attributes: merged,
161
+ notes
162
+ });
163
+ this.set(key, msg);
164
+ return this;
165
+ }
166
+ translate(data) {
167
+ const { title, attributes, messages } = data;
168
+ if (title !== this.title) {
169
+ throw new TypeError("Title of resource and translations do not match.");
170
+ }
171
+ const translated = _MsgResource.create({
172
+ title,
173
+ attributes,
174
+ notes: this.notes
175
+ // transfer the notes
176
+ }, this._project);
177
+ this.forEach((msg) => {
178
+ translated.set(msg.key, msg);
179
+ });
180
+ messages?.forEach((messageData) => {
181
+ const { key, value, attributes: attributes2 } = messageData;
182
+ const msg = MsgMessage.create({
183
+ key,
184
+ value,
185
+ attributes: attributes2
186
+ });
187
+ const notes = this.get(key)?.notes || [];
188
+ notes.forEach((note) => {
189
+ msg.addNote(note);
190
+ });
191
+ translated.set(key, msg);
192
+ });
193
+ return translated;
194
+ }
195
+ async getTranslation(lang) {
196
+ const project = this._project;
197
+ const languageChain = project.getTargetLocale(lang);
198
+ if (!languageChain) {
199
+ throw new Error("Unsupported locale for resource.");
200
+ }
201
+ if (languageChain.length == 0) {
202
+ throw new Error(`Empty language chain for locale: ${lang}`);
203
+ }
204
+ let translated = this;
205
+ for (let i = 0; i < languageChain.length; i++) {
206
+ const lang2 = languageChain[i];
207
+ if (lang2 && project._locales.targetLocales[lang2]) {
208
+ translated = await translated._project._loader(project.project.name, translated.title, lang2).then((data) => translated.translate(data));
209
+ }
210
+ }
211
+ return translated;
212
+ }
213
+ getData(stripNotes = false) {
214
+ const messages = [];
215
+ this.forEach((msg) => messages.push(msg.getData(stripNotes)));
216
+ return {
217
+ title: this.title,
218
+ attributes: this.attributes,
219
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : void 0,
220
+ messages
221
+ };
222
+ }
223
+ toJSON(stripNotes = false) {
224
+ return JSON.stringify(this.getData(stripNotes), null, 2);
225
+ }
226
+ };
227
+ // Annotate the CommonJS export names for ESM import in node:
228
+ 0 && (module.exports = {
229
+ MsgResource
230
+ });
@@ -0,0 +1,4 @@
1
+ import '../MsgMessage/MsgMessage.cjs';
2
+ import '../MsgInterface/MsgInterface.cjs';
3
+ export { a as MsgResource, M as MsgResourceData } from '../MsgProject/MsgProject.cjs';
4
+ import 'messageformat';
@@ -1,31 +1,4 @@
1
- import { type MsgMessageData, MsgMessage } from "../MsgMessage/MsgMessage.js";
2
- import { MsgAttributes, MsgInterface, MsgNote } from "../MsgInterface/MsgInterface.js";
3
- import { MsgProject } from "../MsgProject/MsgProject.js";
4
- export type MsgResourceData = {
5
- title: string;
6
- attributes: MsgAttributes;
7
- notes?: MsgNote[];
8
- messages?: MsgMessageData[];
9
- };
10
- export declare class MsgResource extends Map<string, MsgMessage> implements MsgInterface {
11
- private _attributes;
12
- private _notes;
13
- private _title;
14
- private _project;
15
- static create(data: MsgResourceData, project: MsgProject): MsgResource;
16
- private constructor();
17
- get attributes(): MsgAttributes;
18
- set attributes(attributes: MsgAttributes);
19
- get notes(): MsgNote[];
20
- set notes(notes: MsgNote[]);
21
- addNote(note: MsgNote): void;
22
- get title(): string;
23
- set title(title: string);
24
- getProject(): MsgProject;
25
- add(key: string, value: string, attributes?: MsgAttributes, notes?: MsgNote[]): this;
26
- translate(data: MsgResourceData): MsgResource;
27
- getTranslation(lang: string): Promise<MsgResource>;
28
- getData(stripNotes?: boolean): MsgResourceData;
29
- toJSON(stripNotes?: boolean): string;
30
- }
31
- //# sourceMappingURL=MsgResource.d.ts.map
1
+ import '../MsgMessage/MsgMessage.js';
2
+ import '../MsgInterface/MsgInterface.js';
3
+ export { a as MsgResource, M as MsgResourceData } from '../MsgProject/MsgProject.js';
4
+ import 'messageformat';
@@ -0,0 +1,8 @@
1
+ import {
2
+ MsgResource
3
+ } from "../../chunk-4SWDABOO.mjs";
4
+ import "../../chunk-OMRO6GAZ.mjs";
5
+ import "../../chunk-GHRFKA7N.mjs";
6
+ export {
7
+ MsgResource
8
+ };
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/classes/index.ts
21
+ var classes_exports = {};
22
+ __export(classes_exports, {
23
+ MsgMessage: () => MsgMessage,
24
+ MsgProject: () => MsgProject,
25
+ MsgResource: () => MsgResource
26
+ });
27
+ module.exports = __toCommonJS(classes_exports);
28
+
29
+ // src/classes/MsgMessage/MsgMessage.ts
30
+ var import_messageformat = require("messageformat");
31
+ var DEFAULT_ATTRIBUTES = {
32
+ lang: "",
33
+ dir: "",
34
+ dnt: false
35
+ };
36
+ var MsgMessage = class _MsgMessage {
37
+ _key;
38
+ _value;
39
+ _mf;
40
+ _attributes = DEFAULT_ATTRIBUTES;
41
+ _notes = [];
42
+ constructor(key, value, attributes, notes) {
43
+ this._key = key;
44
+ this._value = value;
45
+ this._attributes = attributes ? { ...this._attributes, ...attributes } : this._attributes;
46
+ if (notes) {
47
+ notes.forEach((note) => this.addNote(note));
48
+ }
49
+ }
50
+ static create(data) {
51
+ const { key, value, attributes, notes } = data;
52
+ const message = new _MsgMessage(key, value, attributes, notes);
53
+ return message;
54
+ }
55
+ get key() {
56
+ return this._key;
57
+ }
58
+ get value() {
59
+ return this._value;
60
+ }
61
+ get attributes() {
62
+ return this._attributes;
63
+ }
64
+ get notes() {
65
+ return this._notes;
66
+ }
67
+ addNote(note) {
68
+ this.notes.push(note);
69
+ }
70
+ format(data, options) {
71
+ if (!this._mf) {
72
+ this._mf = new import_messageformat.MessageFormat(this.attributes.lang, this.value, options);
73
+ }
74
+ return this._mf.format(data);
75
+ }
76
+ formatToParts(data, options) {
77
+ if (!this._mf) {
78
+ this._mf = new import_messageformat.MessageFormat(this.attributes.lang, this.value, options);
79
+ }
80
+ return this._mf?.formatToParts(data);
81
+ }
82
+ getData(stripNotes = false) {
83
+ return {
84
+ key: this.key,
85
+ value: this.value,
86
+ attributes: this.attributes,
87
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : void 0
88
+ };
89
+ }
90
+ toString() {
91
+ return this.value;
92
+ }
93
+ toJSON(stripNotes = false) {
94
+ return JSON.stringify(this.getData(stripNotes), null, 2);
95
+ }
96
+ };
97
+
98
+ // src/classes/MsgInterface/MsgInterface.ts
99
+ var DEFAULT_ATTRIBUTES2 = {
100
+ lang: "",
101
+ dir: "",
102
+ dnt: false
103
+ };
104
+
105
+ // src/classes/MsgResource/MsgResource.ts
106
+ var MsgResource = class _MsgResource extends Map {
107
+ _attributes = DEFAULT_ATTRIBUTES2;
108
+ _notes = [];
109
+ _title;
110
+ _project;
111
+ static create(data, project) {
112
+ const { title, attributes, notes, messages } = data;
113
+ const res = new _MsgResource(title, attributes, project, notes);
114
+ if (messages) {
115
+ messages.forEach((messageData) => {
116
+ const { key, value, attributes: attributes2, notes: notes2 } = messageData;
117
+ res.add(key, value, attributes2, notes2);
118
+ });
119
+ } else {
120
+ res.clear();
121
+ }
122
+ return res;
123
+ }
124
+ constructor(title, attributes, project, notes) {
125
+ super();
126
+ this._title = title;
127
+ this._attributes = { ...this._attributes, ...attributes };
128
+ this._project = project;
129
+ if (notes) {
130
+ notes.forEach((note) => this.addNote(note));
131
+ }
132
+ }
133
+ get attributes() {
134
+ return this._attributes;
135
+ }
136
+ set attributes(attributes) {
137
+ this._attributes = attributes;
138
+ }
139
+ get notes() {
140
+ return this._notes;
141
+ }
142
+ set notes(notes) {
143
+ this._notes = notes;
144
+ }
145
+ addNote(note) {
146
+ this.notes.push(note);
147
+ }
148
+ get title() {
149
+ return this._title;
150
+ }
151
+ set title(title) {
152
+ this._title = title;
153
+ }
154
+ getProject() {
155
+ return this._project;
156
+ }
157
+ add(key, value, attributes, notes) {
158
+ const merged = { ...this.attributes, ...attributes };
159
+ const msg = MsgMessage.create({
160
+ key,
161
+ value,
162
+ attributes: merged,
163
+ notes
164
+ });
165
+ this.set(key, msg);
166
+ return this;
167
+ }
168
+ translate(data) {
169
+ const { title, attributes, messages } = data;
170
+ if (title !== this.title) {
171
+ throw new TypeError("Title of resource and translations do not match.");
172
+ }
173
+ const translated = _MsgResource.create({
174
+ title,
175
+ attributes,
176
+ notes: this.notes
177
+ // transfer the notes
178
+ }, this._project);
179
+ this.forEach((msg) => {
180
+ translated.set(msg.key, msg);
181
+ });
182
+ messages?.forEach((messageData) => {
183
+ const { key, value, attributes: attributes2 } = messageData;
184
+ const msg = MsgMessage.create({
185
+ key,
186
+ value,
187
+ attributes: attributes2
188
+ });
189
+ const notes = this.get(key)?.notes || [];
190
+ notes.forEach((note) => {
191
+ msg.addNote(note);
192
+ });
193
+ translated.set(key, msg);
194
+ });
195
+ return translated;
196
+ }
197
+ async getTranslation(lang) {
198
+ const project = this._project;
199
+ const languageChain = project.getTargetLocale(lang);
200
+ if (!languageChain) {
201
+ throw new Error("Unsupported locale for resource.");
202
+ }
203
+ if (languageChain.length == 0) {
204
+ throw new Error(`Empty language chain for locale: ${lang}`);
205
+ }
206
+ let translated = this;
207
+ for (let i = 0; i < languageChain.length; i++) {
208
+ const lang2 = languageChain[i];
209
+ if (lang2 && project._locales.targetLocales[lang2]) {
210
+ translated = await translated._project._loader(project.project.name, translated.title, lang2).then((data) => translated.translate(data));
211
+ }
212
+ }
213
+ return translated;
214
+ }
215
+ getData(stripNotes = false) {
216
+ const messages = [];
217
+ this.forEach((msg) => messages.push(msg.getData(stripNotes)));
218
+ return {
219
+ title: this.title,
220
+ attributes: this.attributes,
221
+ notes: !stripNotes && this.notes.length > 0 ? this.notes : void 0,
222
+ messages
223
+ };
224
+ }
225
+ toJSON(stripNotes = false) {
226
+ return JSON.stringify(this.getData(stripNotes), null, 2);
227
+ }
228
+ };
229
+
230
+ // src/classes/MsgProject/MsgProject.ts
231
+ var defaultProjectSettings = {
232
+ name: "messages",
233
+ version: 1
234
+ };
235
+ var defaultLocalesSettings = {
236
+ sourceLocale: "en",
237
+ pseudoLocale: "en-XA",
238
+ targetLocales: {
239
+ en: ["en"]
240
+ }
241
+ };
242
+ var MsgProject = class _MsgProject {
243
+ _project;
244
+ _locales;
245
+ _loader;
246
+ static create(data) {
247
+ const { project, locales, loader } = data;
248
+ return new _MsgProject(project, locales, loader);
249
+ }
250
+ constructor(projectSettings, localesSettings, loader) {
251
+ this._project = { ...defaultProjectSettings, ...projectSettings };
252
+ this._locales = { ...defaultLocalesSettings, ...localesSettings };
253
+ this._loader = loader;
254
+ }
255
+ get project() {
256
+ return this._project;
257
+ }
258
+ get locales() {
259
+ return this._locales;
260
+ }
261
+ get loader() {
262
+ return this._loader;
263
+ }
264
+ getTargetLocale(locale) {
265
+ return this._locales.targetLocales[locale];
266
+ }
267
+ };
268
+ // Annotate the CommonJS export names for ESM import in node:
269
+ 0 && (module.exports = {
270
+ MsgMessage,
271
+ MsgProject,
272
+ MsgResource
273
+ });
@@ -0,0 +1,4 @@
1
+ export { MsgMessage, MsgMessageData } from './MsgMessage/MsgMessage.cjs';
2
+ export { MsgProject, MsgProjectData, a as MsgResource, M as MsgResourceData, MsgTranslationLoader } from './MsgProject/MsgProject.cjs';
3
+ import 'messageformat';
4
+ import './MsgInterface/MsgInterface.cjs';
@@ -1,4 +1,4 @@
1
- export * from './MsgMessage/MsgMessage.js';
2
- export * from './MsgResource/MsgResource.js';
3
- export * from './MsgProject/MsgProject.js';
4
- //# sourceMappingURL=index.d.ts.map
1
+ export { MsgMessage, MsgMessageData } from './MsgMessage/MsgMessage.js';
2
+ export { MsgProject, MsgProjectData, a as MsgResource, M as MsgResourceData, MsgTranslationLoader } from './MsgProject/MsgProject.js';
3
+ import 'messageformat';
4
+ import './MsgInterface/MsgInterface.js';
@@ -0,0 +1,16 @@
1
+ import "../chunk-ZKG5QRBZ.mjs";
2
+ import {
3
+ MsgProject
4
+ } from "../chunk-XS43NAP2.mjs";
5
+ import {
6
+ MsgResource
7
+ } from "../chunk-4SWDABOO.mjs";
8
+ import "../chunk-OMRO6GAZ.mjs";
9
+ import {
10
+ MsgMessage
11
+ } from "../chunk-GHRFKA7N.mjs";
12
+ export {
13
+ MsgMessage,
14
+ MsgProject,
15
+ MsgResource
16
+ };