@worldware/msg 0.11.0 → 0.12.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/README.md CHANGED
@@ -67,7 +67,7 @@ const loader = async (project, title, language) => {
67
67
  console.warn(`Translations for locale ${language} could not be loaded.`, error);
68
68
  return {
69
69
  title,
70
- attributes: { lang: language, dir: '' },
70
+ attributes: { lang: language, dir: 'auto' },
71
71
  notes: [],
72
72
  messages: []
73
73
  };
@@ -159,6 +159,8 @@ Every message is formatted according to its resolved `format` attribute:
159
159
 
160
160
  The `format` is inheritable: a resource inherits its project's `format` unless it sets its own, and a message inherits its resource's `format` unless it sets its own. The default is `MF2`, so existing code keeps working unchanged. Use a TypeScript union (`'MF1' | 'MF2' | 'NONE'`) — there is no enum.
161
161
 
162
+ `lang`, `dir`, and `dnt` inherit the same way on messages: omitted fields (or omitted `attributes`) take the resource's values, and an explicit per-message value still wins. Compact translation JSON can therefore list only overrides. `create()`, `add()`, `translate()`, and `getTranslation()` all apply this merge.
163
+
162
164
  The following is a **separate illustration** of format inheritance and per-message overrides (not the CLI `Main` / `Messages` scaffold above):
163
165
 
164
166
  ```typescript
@@ -332,7 +334,7 @@ const data = resource.getData();
332
334
  ### Types
333
335
 
334
336
  - `MsgFormat` - `'MF1' | 'MF2' | 'NONE'`; the formatting syntax for a message.
335
- - `MsgAttributes` - `{ lang?: string; dir?: string; dnt?: boolean; format?: MsgFormat }`.
337
+ - `MsgAttributes` - `{ lang?: string; dir?: string; dnt?: boolean; format?: MsgFormat }`. Omitted or empty `dir` resolves to `'auto'`.
336
338
 
337
339
  ### Pseudo-localization helpers
338
340
 
@@ -3,9 +3,11 @@ import {
3
3
  } from "./chunk-GHDKBE4P.mjs";
4
4
  import {
5
5
  MsgMessage
6
- } from "./chunk-OKEV7FY7.mjs";
6
+ } from "./chunk-RMZ42XIY.mjs";
7
+ import {
8
+ applyAttributes
9
+ } from "./chunk-QU3HGZUN.mjs";
7
10
  import {
8
- DEFAULT_ATTRIBUTES,
9
11
  MSG_DEFAULT_FORMAT
10
12
  } from "./chunk-XQVALCKX.mjs";
11
13
 
@@ -40,7 +42,7 @@ var MsgResource = class _MsgResource extends Map {
40
42
  constructor(title, attributes, project, notes) {
41
43
  super();
42
44
  this._title = title;
43
- this._attributes = { ...DEFAULT_ATTRIBUTES, format: project.format, ...attributes };
45
+ this._attributes = applyAttributes(attributes, { format: project.format });
44
46
  this._project = project;
45
47
  if (notes) {
46
48
  notes.forEach((note) => this.setNote(note));
@@ -66,7 +68,7 @@ var MsgResource = class _MsgResource extends Map {
66
68
  }
67
69
  /** Replaces the resource's locale and formatting metadata. */
68
70
  set attributes(attributes) {
69
- this._attributes = attributes;
71
+ this._attributes = applyAttributes(attributes);
70
72
  }
71
73
  /** Notes attached to this resource for translators and tooling. */
72
74
  get notes() {
@@ -110,6 +112,9 @@ var MsgResource = class _MsgResource extends Map {
110
112
  /**
111
113
  * Adds a message to this resource, merging resource attributes with any overrides.
112
114
  *
115
+ * Unspecified `lang`, `dir`, and `dnt` inherit from this resource; explicit
116
+ * values on the message win.
117
+ *
113
118
  * @returns This resource, for chaining.
114
119
  */
115
120
  add(key, value, attributes, notes) {
@@ -127,7 +132,8 @@ var MsgResource = class _MsgResource extends Map {
127
132
  * Builds a translated copy of this resource from translation data.
128
133
  *
129
134
  * Messages present in the translation replace the source; missing keys keep
130
- * the source message. Notes are carried over from the source.
135
+ * the source message. Notes are carried over from the source. Unspecified
136
+ * message `lang`, `dir`, and `dnt` inherit from the translated resource.
131
137
  *
132
138
  * @throws {TypeError} When the translation title does not match this resource.
133
139
  */
@@ -148,17 +154,13 @@ var MsgResource = class _MsgResource extends Map {
148
154
  });
149
155
  messages?.forEach((messageData) => {
150
156
  const { key, value, attributes: attributes2 } = messageData;
151
- const msg = MsgMessage.create({
157
+ const source = this.get(key);
158
+ translated.add(
152
159
  key,
153
160
  value,
154
- // preserve the source message's format unless the translation overrides it
155
- attributes: this.preserveFormat(attributes2, this.get(key)?.attributes.format)
156
- });
157
- const notes = this.get(key)?.notes || [];
158
- notes.forEach((note) => {
159
- msg.addNote(note.type, note.content);
160
- });
161
- translated.set(key, msg);
161
+ this.preserveFormat(attributes2, source?.attributes.format),
162
+ source?.notes
163
+ );
162
164
  });
163
165
  return translated;
164
166
  }
@@ -0,0 +1,16 @@
1
+ import {
2
+ DEFAULT_ATTRIBUTES
3
+ } from "./chunk-XQVALCKX.mjs";
4
+
5
+ // src/lib/apply-attributes.ts
6
+ function applyAttributes(attributes, extras) {
7
+ const merged = { ...DEFAULT_ATTRIBUTES, ...extras, ...attributes };
8
+ if (!merged.dir) {
9
+ merged.dir = "auto";
10
+ }
11
+ return merged;
12
+ }
13
+
14
+ export {
15
+ applyAttributes
16
+ };
@@ -1,5 +1,7 @@
1
1
  import {
2
- DEFAULT_ATTRIBUTES,
2
+ applyAttributes
3
+ } from "./chunk-QU3HGZUN.mjs";
4
+ import {
3
5
  MSG_DEFAULT_FORMAT
4
6
  } from "./chunk-XQVALCKX.mjs";
5
7
 
@@ -18,7 +20,7 @@ var MsgMessage = class _MsgMessage {
18
20
  constructor(key, value, attributes, notes) {
19
21
  this._key = key;
20
22
  this._value = value;
21
- this._attributes = attributes ? { ...DEFAULT_ATTRIBUTES, ...attributes } : {};
23
+ this._attributes = applyAttributes(attributes);
22
24
  if (notes) {
23
25
  notes.forEach((note) => this.setNote(note));
24
26
  }
@@ -30,7 +30,7 @@ declare const MSG_DEFAULT_FORMAT: MsgFormat;
30
30
  type MsgAttributes = {
31
31
  /** BCP 47 language tag for the content (for example, `en` or `zh-Hans`). */
32
32
  lang?: string;
33
- /** Text direction: typically `ltr`, `rtl`, or `auto`. */
33
+ /** Text direction: typically `ltr`, `rtl`, or `auto`. Omitted or empty values resolve to `'auto'`. */
34
34
  dir?: string;
35
35
  /** When true, the content should not be translated (Do Not Translate). */
36
36
  dnt?: boolean;
@@ -30,7 +30,7 @@ declare const MSG_DEFAULT_FORMAT: MsgFormat;
30
30
  type MsgAttributes = {
31
31
  /** BCP 47 language tag for the content (for example, `en` or `zh-Hans`). */
32
32
  lang?: string;
33
- /** Text direction: typically `ltr`, `rtl`, or `auto`. */
33
+ /** Text direction: typically `ltr`, `rtl`, or `auto`. Omitted or empty values resolve to `'auto'`. */
34
34
  dir?: string;
35
35
  /** When true, the content should not be translated (Do Not Translate). */
36
36
  dnt?: boolean;
@@ -34,6 +34,15 @@ var DEFAULT_ATTRIBUTES = {
34
34
  dnt: false
35
35
  };
36
36
 
37
+ // src/lib/apply-attributes.ts
38
+ function applyAttributes(attributes, extras) {
39
+ const merged = { ...DEFAULT_ATTRIBUTES, ...extras, ...attributes };
40
+ if (!merged.dir) {
41
+ merged.dir = "auto";
42
+ }
43
+ return merged;
44
+ }
45
+
37
46
  // src/classes/MsgMessage/MsgMessage.ts
38
47
  var MsgMessage = class _MsgMessage {
39
48
  _key;
@@ -47,7 +56,7 @@ var MsgMessage = class _MsgMessage {
47
56
  constructor(key, value, attributes, notes) {
48
57
  this._key = key;
49
58
  this._value = value;
50
- this._attributes = attributes ? { ...DEFAULT_ATTRIBUTES, ...attributes } : {};
59
+ this._attributes = applyAttributes(attributes);
51
60
  if (notes) {
52
61
  notes.forEach((note) => this.setNote(note));
53
62
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  MsgMessage
3
- } from "../../chunk-OKEV7FY7.mjs";
3
+ } from "../../chunk-RMZ42XIY.mjs";
4
+ import "../../chunk-QU3HGZUN.mjs";
4
5
  import "../../chunk-XQVALCKX.mjs";
5
6
  export {
6
7
  MsgMessage
@@ -36,6 +36,15 @@ var DEFAULT_ATTRIBUTES = {
36
36
  dnt: false
37
37
  };
38
38
 
39
+ // src/lib/apply-attributes.ts
40
+ function applyAttributes(attributes, extras) {
41
+ const merged = { ...DEFAULT_ATTRIBUTES, ...extras, ...attributes };
42
+ if (!merged.dir) {
43
+ merged.dir = "auto";
44
+ }
45
+ return merged;
46
+ }
47
+
39
48
  // src/classes/MsgMessage/MsgMessage.ts
40
49
  var MsgMessage = class _MsgMessage {
41
50
  _key;
@@ -49,7 +58,7 @@ var MsgMessage = class _MsgMessage {
49
58
  constructor(key, value, attributes, notes) {
50
59
  this._key = key;
51
60
  this._value = value;
52
- this._attributes = attributes ? { ...DEFAULT_ATTRIBUTES, ...attributes } : {};
61
+ this._attributes = applyAttributes(attributes);
53
62
  if (notes) {
54
63
  notes.forEach((note) => this.setNote(note));
55
64
  }
@@ -272,7 +281,7 @@ var MsgResource = class _MsgResource extends Map {
272
281
  constructor(title, attributes, project, notes) {
273
282
  super();
274
283
  this._title = title;
275
- this._attributes = { ...DEFAULT_ATTRIBUTES, format: project.format, ...attributes };
284
+ this._attributes = applyAttributes(attributes, { format: project.format });
276
285
  this._project = project;
277
286
  if (notes) {
278
287
  notes.forEach((note) => this.setNote(note));
@@ -298,7 +307,7 @@ var MsgResource = class _MsgResource extends Map {
298
307
  }
299
308
  /** Replaces the resource's locale and formatting metadata. */
300
309
  set attributes(attributes) {
301
- this._attributes = attributes;
310
+ this._attributes = applyAttributes(attributes);
302
311
  }
303
312
  /** Notes attached to this resource for translators and tooling. */
304
313
  get notes() {
@@ -342,6 +351,9 @@ var MsgResource = class _MsgResource extends Map {
342
351
  /**
343
352
  * Adds a message to this resource, merging resource attributes with any overrides.
344
353
  *
354
+ * Unspecified `lang`, `dir`, and `dnt` inherit from this resource; explicit
355
+ * values on the message win.
356
+ *
345
357
  * @returns This resource, for chaining.
346
358
  */
347
359
  add(key, value, attributes, notes) {
@@ -359,7 +371,8 @@ var MsgResource = class _MsgResource extends Map {
359
371
  * Builds a translated copy of this resource from translation data.
360
372
  *
361
373
  * Messages present in the translation replace the source; missing keys keep
362
- * the source message. Notes are carried over from the source.
374
+ * the source message. Notes are carried over from the source. Unspecified
375
+ * message `lang`, `dir`, and `dnt` inherit from the translated resource.
363
376
  *
364
377
  * @throws {TypeError} When the translation title does not match this resource.
365
378
  */
@@ -380,17 +393,13 @@ var MsgResource = class _MsgResource extends Map {
380
393
  });
381
394
  messages?.forEach((messageData) => {
382
395
  const { key, value, attributes: attributes2 } = messageData;
383
- const msg = MsgMessage.create({
396
+ const source = this.get(key);
397
+ translated.add(
384
398
  key,
385
399
  value,
386
- // preserve the source message's format unless the translation overrides it
387
- attributes: this.preserveFormat(attributes2, this.get(key)?.attributes.format)
388
- });
389
- const notes = this.get(key)?.notes || [];
390
- notes.forEach((note) => {
391
- msg.addNote(note.type, note.content);
392
- });
393
- translated.set(key, msg);
400
+ this.preserveFormat(attributes2, source?.attributes.format),
401
+ source?.notes
402
+ );
394
403
  });
395
404
  return translated;
396
405
  }
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  MsgResource
3
- } from "../../chunk-K35ZABAI.mjs";
3
+ } from "../../chunk-CRT2A2HP.mjs";
4
4
  import "../../chunk-GHDKBE4P.mjs";
5
- import "../../chunk-OKEV7FY7.mjs";
5
+ import "../../chunk-RMZ42XIY.mjs";
6
+ import "../../chunk-QU3HGZUN.mjs";
6
7
  import "../../chunk-XQVALCKX.mjs";
7
8
  export {
8
9
  MsgResource
@@ -39,6 +39,17 @@ var DEFAULT_ATTRIBUTES = {
39
39
  // src/classes/MsgMessage/MsgMessage.ts
40
40
  var import_messageformat = require("messageformat");
41
41
  var import_icu_messageformat_1 = require("@messageformat/icu-messageformat-1");
42
+
43
+ // src/lib/apply-attributes.ts
44
+ function applyAttributes(attributes, extras) {
45
+ const merged = { ...DEFAULT_ATTRIBUTES, ...extras, ...attributes };
46
+ if (!merged.dir) {
47
+ merged.dir = "auto";
48
+ }
49
+ return merged;
50
+ }
51
+
52
+ // src/classes/MsgMessage/MsgMessage.ts
42
53
  var MsgMessage = class _MsgMessage {
43
54
  _key;
44
55
  _value;
@@ -51,7 +62,7 @@ var MsgMessage = class _MsgMessage {
51
62
  constructor(key, value, attributes, notes) {
52
63
  this._key = key;
53
64
  this._value = value;
54
- this._attributes = attributes ? { ...DEFAULT_ATTRIBUTES, ...attributes } : {};
65
+ this._attributes = applyAttributes(attributes);
55
66
  if (notes) {
56
67
  notes.forEach((note) => this.setNote(note));
57
68
  }
@@ -274,7 +285,7 @@ var MsgResource = class _MsgResource extends Map {
274
285
  constructor(title, attributes, project, notes) {
275
286
  super();
276
287
  this._title = title;
277
- this._attributes = { ...DEFAULT_ATTRIBUTES, format: project.format, ...attributes };
288
+ this._attributes = applyAttributes(attributes, { format: project.format });
278
289
  this._project = project;
279
290
  if (notes) {
280
291
  notes.forEach((note) => this.setNote(note));
@@ -300,7 +311,7 @@ var MsgResource = class _MsgResource extends Map {
300
311
  }
301
312
  /** Replaces the resource's locale and formatting metadata. */
302
313
  set attributes(attributes) {
303
- this._attributes = attributes;
314
+ this._attributes = applyAttributes(attributes);
304
315
  }
305
316
  /** Notes attached to this resource for translators and tooling. */
306
317
  get notes() {
@@ -344,6 +355,9 @@ var MsgResource = class _MsgResource extends Map {
344
355
  /**
345
356
  * Adds a message to this resource, merging resource attributes with any overrides.
346
357
  *
358
+ * Unspecified `lang`, `dir`, and `dnt` inherit from this resource; explicit
359
+ * values on the message win.
360
+ *
347
361
  * @returns This resource, for chaining.
348
362
  */
349
363
  add(key, value, attributes, notes) {
@@ -361,7 +375,8 @@ var MsgResource = class _MsgResource extends Map {
361
375
  * Builds a translated copy of this resource from translation data.
362
376
  *
363
377
  * Messages present in the translation replace the source; missing keys keep
364
- * the source message. Notes are carried over from the source.
378
+ * the source message. Notes are carried over from the source. Unspecified
379
+ * message `lang`, `dir`, and `dnt` inherit from the translated resource.
365
380
  *
366
381
  * @throws {TypeError} When the translation title does not match this resource.
367
382
  */
@@ -382,17 +397,13 @@ var MsgResource = class _MsgResource extends Map {
382
397
  });
383
398
  messages?.forEach((messageData) => {
384
399
  const { key, value, attributes: attributes2 } = messageData;
385
- const msg = MsgMessage.create({
400
+ const source = this.get(key);
401
+ translated.add(
386
402
  key,
387
403
  value,
388
- // preserve the source message's format unless the translation overrides it
389
- attributes: this.preserveFormat(attributes2, this.get(key)?.attributes.format)
390
- });
391
- const notes = this.get(key)?.notes || [];
392
- notes.forEach((note) => {
393
- msg.addNote(note.type, note.content);
394
- });
395
- translated.set(key, msg);
404
+ this.preserveFormat(attributes2, source?.attributes.format),
405
+ source?.notes
406
+ );
396
407
  });
397
408
  return translated;
398
409
  }
@@ -77,6 +77,9 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
77
77
  /**
78
78
  * Adds a message to this resource, merging resource attributes with any overrides.
79
79
  *
80
+ * Unspecified `lang`, `dir`, and `dnt` inherit from this resource; explicit
81
+ * values on the message win.
82
+ *
80
83
  * @returns This resource, for chaining.
81
84
  */
82
85
  add(key: string, value: string, attributes?: MsgAttributes, notes?: MsgNote[]): this;
@@ -84,7 +87,8 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
84
87
  * Builds a translated copy of this resource from translation data.
85
88
  *
86
89
  * Messages present in the translation replace the source; missing keys keep
87
- * the source message. Notes are carried over from the source.
90
+ * the source message. Notes are carried over from the source. Unspecified
91
+ * message `lang`, `dir`, and `dnt` inherit from the translated resource.
88
92
  *
89
93
  * @throws {TypeError} When the translation title does not match this resource.
90
94
  */
@@ -77,6 +77,9 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
77
77
  /**
78
78
  * Adds a message to this resource, merging resource attributes with any overrides.
79
79
  *
80
+ * Unspecified `lang`, `dir`, and `dnt` inherit from this resource; explicit
81
+ * values on the message win.
82
+ *
80
83
  * @returns This resource, for chaining.
81
84
  */
82
85
  add(key: string, value: string, attributes?: MsgAttributes, notes?: MsgNote[]): this;
@@ -84,7 +87,8 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
84
87
  * Builds a translated copy of this resource from translation data.
85
88
  *
86
89
  * Messages present in the translation replace the source; missing keys keep
87
- * the source message. Notes are carried over from the source.
90
+ * the source message. Notes are carried over from the source. Unspecified
91
+ * message `lang`, `dir`, and `dnt` inherit from the translated resource.
88
92
  *
89
93
  * @throws {TypeError} When the translation title does not match this resource.
90
94
  */
@@ -1,14 +1,15 @@
1
1
  import "../chunk-ORHP7HGX.mjs";
2
+ import {
3
+ MsgProject
4
+ } from "../chunk-DJFPVXQ5.mjs";
2
5
  import {
3
6
  MsgResource
4
- } from "../chunk-K35ZABAI.mjs";
7
+ } from "../chunk-CRT2A2HP.mjs";
5
8
  import "../chunk-GHDKBE4P.mjs";
6
9
  import {
7
10
  MsgMessage
8
- } from "../chunk-OKEV7FY7.mjs";
9
- import {
10
- MsgProject
11
- } from "../chunk-DJFPVXQ5.mjs";
11
+ } from "../chunk-RMZ42XIY.mjs";
12
+ import "../chunk-QU3HGZUN.mjs";
12
13
  import {
13
14
  DEFAULT_ATTRIBUTES,
14
15
  MSG_DEFAULT_FORMAT
package/dist/index.cjs CHANGED
@@ -45,6 +45,17 @@ var DEFAULT_ATTRIBUTES = {
45
45
  // src/classes/MsgMessage/MsgMessage.ts
46
46
  var import_messageformat = require("messageformat");
47
47
  var import_icu_messageformat_1 = require("@messageformat/icu-messageformat-1");
48
+
49
+ // src/lib/apply-attributes.ts
50
+ function applyAttributes(attributes, extras) {
51
+ const merged = { ...DEFAULT_ATTRIBUTES, ...extras, ...attributes };
52
+ if (!merged.dir) {
53
+ merged.dir = "auto";
54
+ }
55
+ return merged;
56
+ }
57
+
58
+ // src/classes/MsgMessage/MsgMessage.ts
48
59
  var MsgMessage = class _MsgMessage {
49
60
  _key;
50
61
  _value;
@@ -57,7 +68,7 @@ var MsgMessage = class _MsgMessage {
57
68
  constructor(key, value, attributes, notes) {
58
69
  this._key = key;
59
70
  this._value = value;
60
- this._attributes = attributes ? { ...DEFAULT_ATTRIBUTES, ...attributes } : {};
71
+ this._attributes = applyAttributes(attributes);
61
72
  if (notes) {
62
73
  notes.forEach((note) => this.setNote(note));
63
74
  }
@@ -280,7 +291,7 @@ var MsgResource = class _MsgResource extends Map {
280
291
  constructor(title, attributes, project, notes) {
281
292
  super();
282
293
  this._title = title;
283
- this._attributes = { ...DEFAULT_ATTRIBUTES, format: project.format, ...attributes };
294
+ this._attributes = applyAttributes(attributes, { format: project.format });
284
295
  this._project = project;
285
296
  if (notes) {
286
297
  notes.forEach((note) => this.setNote(note));
@@ -306,7 +317,7 @@ var MsgResource = class _MsgResource extends Map {
306
317
  }
307
318
  /** Replaces the resource's locale and formatting metadata. */
308
319
  set attributes(attributes) {
309
- this._attributes = attributes;
320
+ this._attributes = applyAttributes(attributes);
310
321
  }
311
322
  /** Notes attached to this resource for translators and tooling. */
312
323
  get notes() {
@@ -350,6 +361,9 @@ var MsgResource = class _MsgResource extends Map {
350
361
  /**
351
362
  * Adds a message to this resource, merging resource attributes with any overrides.
352
363
  *
364
+ * Unspecified `lang`, `dir`, and `dnt` inherit from this resource; explicit
365
+ * values on the message win.
366
+ *
353
367
  * @returns This resource, for chaining.
354
368
  */
355
369
  add(key, value, attributes, notes) {
@@ -367,7 +381,8 @@ var MsgResource = class _MsgResource extends Map {
367
381
  * Builds a translated copy of this resource from translation data.
368
382
  *
369
383
  * Messages present in the translation replace the source; missing keys keep
370
- * the source message. Notes are carried over from the source.
384
+ * the source message. Notes are carried over from the source. Unspecified
385
+ * message `lang`, `dir`, and `dnt` inherit from the translated resource.
371
386
  *
372
387
  * @throws {TypeError} When the translation title does not match this resource.
373
388
  */
@@ -388,17 +403,13 @@ var MsgResource = class _MsgResource extends Map {
388
403
  });
389
404
  messages?.forEach((messageData) => {
390
405
  const { key, value, attributes: attributes2 } = messageData;
391
- const msg = MsgMessage.create({
406
+ const source = this.get(key);
407
+ translated.add(
392
408
  key,
393
409
  value,
394
- // preserve the source message's format unless the translation overrides it
395
- attributes: this.preserveFormat(attributes2, this.get(key)?.attributes.format)
396
- });
397
- const notes = this.get(key)?.notes || [];
398
- notes.forEach((note) => {
399
- msg.addNote(note.type, note.content);
400
- });
401
- translated.set(key, msg);
410
+ this.preserveFormat(attributes2, source?.attributes.format),
411
+ source?.notes
412
+ );
402
413
  });
403
414
  return translated;
404
415
  }
package/dist/index.mjs CHANGED
@@ -1,7 +1,10 @@
1
1
  import "./chunk-ORHP7HGX.mjs";
2
+ import {
3
+ MsgProject
4
+ } from "./chunk-DJFPVXQ5.mjs";
2
5
  import {
3
6
  MsgResource
4
- } from "./chunk-K35ZABAI.mjs";
7
+ } from "./chunk-CRT2A2HP.mjs";
5
8
  import "./chunk-KI3KVHLZ.mjs";
6
9
  import {
7
10
  getLang,
@@ -15,10 +18,8 @@ import {
15
18
  } from "./chunk-GHDKBE4P.mjs";
16
19
  import {
17
20
  MsgMessage
18
- } from "./chunk-OKEV7FY7.mjs";
19
- import {
20
- MsgProject
21
- } from "./chunk-DJFPVXQ5.mjs";
21
+ } from "./chunk-RMZ42XIY.mjs";
22
+ import "./chunk-QU3HGZUN.mjs";
22
23
  import {
23
24
  DEFAULT_ATTRIBUTES,
24
25
  MSG_DEFAULT_FORMAT
@@ -0,0 +1,45 @@
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/lib/apply-attributes.ts
21
+ var apply_attributes_exports = {};
22
+ __export(apply_attributes_exports, {
23
+ applyAttributes: () => applyAttributes
24
+ });
25
+ module.exports = __toCommonJS(apply_attributes_exports);
26
+
27
+ // src/classes/MsgInterface/MsgInterface.ts
28
+ var DEFAULT_ATTRIBUTES = {
29
+ lang: "und",
30
+ dir: "auto",
31
+ dnt: false
32
+ };
33
+
34
+ // src/lib/apply-attributes.ts
35
+ function applyAttributes(attributes, extras) {
36
+ const merged = { ...DEFAULT_ATTRIBUTES, ...extras, ...attributes };
37
+ if (!merged.dir) {
38
+ merged.dir = "auto";
39
+ }
40
+ return merged;
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ applyAttributes
45
+ });
@@ -0,0 +1,11 @@
1
+ import { MsgAttributes } from '../classes/MsgInterface/MsgInterface.cjs';
2
+
3
+ /**
4
+ * Merges {@link DEFAULT_ATTRIBUTES} with optional extras and caller attributes.
5
+ *
6
+ * An empty-string `dir` is treated as unset and becomes `'auto'`. This helper
7
+ * is module-internal (not re-exported from the public API).
8
+ */
9
+ declare function applyAttributes(attributes?: MsgAttributes, extras?: MsgAttributes): MsgAttributes;
10
+
11
+ export { applyAttributes };
@@ -0,0 +1,11 @@
1
+ import { MsgAttributes } from '../classes/MsgInterface/MsgInterface.js';
2
+
3
+ /**
4
+ * Merges {@link DEFAULT_ATTRIBUTES} with optional extras and caller attributes.
5
+ *
6
+ * An empty-string `dir` is treated as unset and becomes `'auto'`. This helper
7
+ * is module-internal (not re-exported from the public API).
8
+ */
9
+ declare function applyAttributes(attributes?: MsgAttributes, extras?: MsgAttributes): MsgAttributes;
10
+
11
+ export { applyAttributes };
@@ -0,0 +1,7 @@
1
+ import {
2
+ applyAttributes
3
+ } from "../chunk-QU3HGZUN.mjs";
4
+ import "../chunk-XQVALCKX.mjs";
5
+ export {
6
+ applyAttributes
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldware/msg",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Message localization tooling",
5
5
  "license": "MIT",
6
6
  "author": "Joel Sahleen",