@worldware/msg 0.10.1 → 0.11.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.
@@ -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
  }
@@ -163,9 +174,87 @@ var MsgMessage = class _MsgMessage {
163
174
  }
164
175
  };
165
176
 
166
- // src/classes/MsgResource/MsgResource.ts
177
+ // src/lib/pseudo-localize.ts
167
178
  var import_messageformat2 = require("messageformat");
179
+ var import_parser = require("@messageformat/parser");
168
180
  var import_pseudo_localization = require("pseudo-localization");
181
+ function pseudoLocalizeMF2(source, options) {
182
+ const msg = (0, import_messageformat2.parseMessage)(source);
183
+ (0, import_messageformat2.visit)(msg, {
184
+ pattern: (pattern) => {
185
+ for (let i = 0; i < pattern.length; i++) {
186
+ const part = pattern[i];
187
+ if (typeof part === "string") {
188
+ pattern[i] = (0, import_pseudo_localization.localize)(part, options);
189
+ }
190
+ }
191
+ }
192
+ });
193
+ return (0, import_messageformat2.stringifyMessage)(msg);
194
+ }
195
+ function collectMf1ContentTokens(tokens, into = [], inFunctionParam = false) {
196
+ for (const token of tokens) {
197
+ switch (token.type) {
198
+ case "content":
199
+ if (!inFunctionParam && token.value.length > 0) {
200
+ into.push({
201
+ offset: token.ctx.offset,
202
+ length: token.value.length,
203
+ value: token.value
204
+ });
205
+ }
206
+ break;
207
+ case "plural":
208
+ case "select":
209
+ case "selectordinal":
210
+ for (const selectCase of token.cases) {
211
+ collectMf1ContentTokens(selectCase.tokens, into, inFunctionParam);
212
+ }
213
+ break;
214
+ case "function":
215
+ if (token.param) {
216
+ collectMf1ContentTokens(token.param, into, true);
217
+ }
218
+ break;
219
+ case "argument":
220
+ case "octothorpe":
221
+ break;
222
+ }
223
+ }
224
+ return into;
225
+ }
226
+ function pseudoLocalizeMF1(source, options) {
227
+ const spans = collectMf1ContentTokens((0, import_parser.parse)(source));
228
+ if (spans.length === 0) {
229
+ return source;
230
+ }
231
+ spans.sort((a, b) => a.offset - b.offset);
232
+ let result = "";
233
+ let cursor = 0;
234
+ for (const span of spans) {
235
+ result += source.slice(cursor, span.offset);
236
+ result += (0, import_pseudo_localization.localize)(span.value, options);
237
+ cursor = span.offset + span.length;
238
+ }
239
+ result += source.slice(cursor);
240
+ return result;
241
+ }
242
+ function pseudoLocalizeNone(source, options) {
243
+ return (0, import_pseudo_localization.localize)(source, options);
244
+ }
245
+ function pseudoLocalize(source, format, options) {
246
+ switch (format) {
247
+ case "MF1":
248
+ return pseudoLocalizeMF1(source, options);
249
+ case "NONE":
250
+ return pseudoLocalizeNone(source, options);
251
+ case "MF2":
252
+ default:
253
+ return pseudoLocalizeMF2(source, options);
254
+ }
255
+ }
256
+
257
+ // src/classes/MsgResource/MsgResource.ts
169
258
  var MsgResource = class _MsgResource extends Map {
170
259
  _attributes = {};
171
260
  _notes = [];
@@ -196,7 +285,7 @@ var MsgResource = class _MsgResource extends Map {
196
285
  constructor(title, attributes, project, notes) {
197
286
  super();
198
287
  this._title = title;
199
- this._attributes = { ...DEFAULT_ATTRIBUTES, format: project.format, ...attributes };
288
+ this._attributes = applyAttributes(attributes, { format: project.format });
200
289
  this._project = project;
201
290
  if (notes) {
202
291
  notes.forEach((note) => this.setNote(note));
@@ -216,30 +305,13 @@ var MsgResource = class _MsgResource extends Map {
216
305
  resolveFormat(attributes) {
217
306
  return attributes.format ?? MSG_DEFAULT_FORMAT;
218
307
  }
219
- /**
220
- * Pseudo-localizes an MF2 message by localizing only literal text parts.
221
- */
222
- pseudoLocalizeMF2(source, options) {
223
- const msg = (0, import_messageformat2.parseMessage)(source);
224
- (0, import_messageformat2.visit)(msg, {
225
- pattern: (pattern) => {
226
- for (let i = 0; i < pattern.length; i++) {
227
- const part = pattern[i];
228
- if (typeof part === "string") {
229
- pattern[i] = (0, import_pseudo_localization.localize)(part, options);
230
- }
231
- }
232
- }
233
- });
234
- return (0, import_messageformat2.stringifyMessage)(msg);
235
- }
236
308
  /** Locale and formatting metadata for this resource. */
237
309
  get attributes() {
238
310
  return this._attributes;
239
311
  }
240
312
  /** Replaces the resource's locale and formatting metadata. */
241
313
  set attributes(attributes) {
242
- this._attributes = attributes;
314
+ this._attributes = applyAttributes(attributes);
243
315
  }
244
316
  /** Notes attached to this resource for translators and tooling. */
245
317
  get notes() {
@@ -345,7 +417,11 @@ var MsgResource = class _MsgResource extends Map {
345
417
  * Loads and applies translations for a locale via the project loader.
346
418
  *
347
419
  * When `lang` is the project's pseudo-locale, returns a pseudo-localized
348
- * copy without calling the loader.
420
+ * copy without calling the loader. Each message is transformed according to
421
+ * its resolved `format` (`MF1`, `MF2`, or `NONE`): only literal text is
422
+ * accented; placeholders and message-format syntax are preserved.
423
+ *
424
+ * When `lang` is omitted, returns a clone of the current resource.
349
425
  *
350
426
  * @throws {Error} When the locale is unsupported or its language chain is empty.
351
427
  */
@@ -356,19 +432,17 @@ var MsgResource = class _MsgResource extends Map {
356
432
  const project = this._project;
357
433
  const pseudoLocale = project.locales.pseudoLocale;
358
434
  if (lang === pseudoLocale) {
435
+ const messages = [...this.values()].map((msg) => ({
436
+ key: msg.key,
437
+ value: pseudoLocalize(msg.value, this.resolveFormat(msg.attributes)),
438
+ attributes: { ...msg.attributes, lang: pseudoLocale }
439
+ }));
359
440
  const pseudolocalizedData = {
360
441
  title: this.title,
361
442
  attributes: { ...this.attributes, lang: pseudoLocale },
362
443
  notes: this.notes.length > 0 ? this.notes : void 0,
363
- messages: []
444
+ messages
364
445
  };
365
- this.forEach((msg) => {
366
- pseudolocalizedData.messages.push({
367
- key: msg.key,
368
- value: this.pseudoLocalizeMF2(msg.value),
369
- attributes: { ...this.attributes, lang: pseudoLocale }
370
- });
371
- });
372
446
  return this.translate(pseudolocalizedData);
373
447
  }
374
448
  const languageChain = project.getTargetLocale(lang);
@@ -46,10 +46,6 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
46
46
  * Resolves a format from attributes, falling back to the library default.
47
47
  */
48
48
  private resolveFormat;
49
- /**
50
- * Pseudo-localizes an MF2 message by localizing only literal text parts.
51
- */
52
- private pseudoLocalizeMF2;
53
49
  /** Locale and formatting metadata for this resource. */
54
50
  get attributes(): MsgAttributes;
55
51
  /** Replaces the resource's locale and formatting metadata. */
@@ -104,7 +100,11 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
104
100
  * Loads and applies translations for a locale via the project loader.
105
101
  *
106
102
  * When `lang` is the project's pseudo-locale, returns a pseudo-localized
107
- * copy without calling the loader.
103
+ * copy without calling the loader. Each message is transformed according to
104
+ * its resolved `format` (`MF1`, `MF2`, or `NONE`): only literal text is
105
+ * accented; placeholders and message-format syntax are preserved.
106
+ *
107
+ * When `lang` is omitted, returns a clone of the current resource.
108
108
  *
109
109
  * @throws {Error} When the locale is unsupported or its language chain is empty.
110
110
  */
@@ -46,10 +46,6 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
46
46
  * Resolves a format from attributes, falling back to the library default.
47
47
  */
48
48
  private resolveFormat;
49
- /**
50
- * Pseudo-localizes an MF2 message by localizing only literal text parts.
51
- */
52
- private pseudoLocalizeMF2;
53
49
  /** Locale and formatting metadata for this resource. */
54
50
  get attributes(): MsgAttributes;
55
51
  /** Replaces the resource's locale and formatting metadata. */
@@ -104,7 +100,11 @@ declare class MsgResource extends Map<string, MsgMessage> implements MsgInterfac
104
100
  * Loads and applies translations for a locale via the project loader.
105
101
  *
106
102
  * When `lang` is the project's pseudo-locale, returns a pseudo-localized
107
- * copy without calling the loader.
103
+ * copy without calling the loader. Each message is transformed according to
104
+ * its resolved `format` (`MF1`, `MF2`, or `NONE`): only literal text is
105
+ * accented; placeholders and message-format syntax are preserved.
106
+ *
107
+ * When `lang` is omitted, returns a clone of the current resource.
108
108
  *
109
109
  * @throws {Error} When the locale is unsupported or its language chain is empty.
110
110
  */
@@ -4,10 +4,12 @@ import {
4
4
  } from "../chunk-DJFPVXQ5.mjs";
5
5
  import {
6
6
  MsgResource
7
- } from "../chunk-HUWFAJAN.mjs";
7
+ } from "../chunk-VDOVMTPF.mjs";
8
+ import "../chunk-GHDKBE4P.mjs";
8
9
  import {
9
10
  MsgMessage
10
- } from "../chunk-OKEV7FY7.mjs";
11
+ } from "../chunk-RMZ42XIY.mjs";
12
+ import "../chunk-QU3HGZUN.mjs";
11
13
  import {
12
14
  DEFAULT_ATTRIBUTES,
13
15
  MSG_DEFAULT_FORMAT
package/dist/index.cjs CHANGED
@@ -26,6 +26,10 @@ __export(index_exports, {
26
26
  MsgProject: () => MsgProject,
27
27
  MsgResource: () => MsgResource,
28
28
  getLang: () => getLang,
29
+ pseudoLocalize: () => pseudoLocalize,
30
+ pseudoLocalizeMF1: () => pseudoLocalizeMF1,
31
+ pseudoLocalizeMF2: () => pseudoLocalizeMF2,
32
+ pseudoLocalizeNone: () => pseudoLocalizeNone,
29
33
  setLang: () => setLang
30
34
  });
31
35
  module.exports = __toCommonJS(index_exports);
@@ -41,6 +45,17 @@ var DEFAULT_ATTRIBUTES = {
41
45
  // src/classes/MsgMessage/MsgMessage.ts
42
46
  var import_messageformat = require("messageformat");
43
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
44
59
  var MsgMessage = class _MsgMessage {
45
60
  _key;
46
61
  _value;
@@ -53,7 +68,7 @@ var MsgMessage = class _MsgMessage {
53
68
  constructor(key, value, attributes, notes) {
54
69
  this._key = key;
55
70
  this._value = value;
56
- this._attributes = attributes ? { ...DEFAULT_ATTRIBUTES, ...attributes } : {};
71
+ this._attributes = applyAttributes(attributes);
57
72
  if (notes) {
58
73
  notes.forEach((note) => this.setNote(note));
59
74
  }
@@ -165,9 +180,87 @@ var MsgMessage = class _MsgMessage {
165
180
  }
166
181
  };
167
182
 
168
- // src/classes/MsgResource/MsgResource.ts
183
+ // src/lib/pseudo-localize.ts
169
184
  var import_messageformat2 = require("messageformat");
185
+ var import_parser = require("@messageformat/parser");
170
186
  var import_pseudo_localization = require("pseudo-localization");
187
+ function pseudoLocalizeMF2(source, options) {
188
+ const msg = (0, import_messageformat2.parseMessage)(source);
189
+ (0, import_messageformat2.visit)(msg, {
190
+ pattern: (pattern) => {
191
+ for (let i = 0; i < pattern.length; i++) {
192
+ const part = pattern[i];
193
+ if (typeof part === "string") {
194
+ pattern[i] = (0, import_pseudo_localization.localize)(part, options);
195
+ }
196
+ }
197
+ }
198
+ });
199
+ return (0, import_messageformat2.stringifyMessage)(msg);
200
+ }
201
+ function collectMf1ContentTokens(tokens, into = [], inFunctionParam = false) {
202
+ for (const token of tokens) {
203
+ switch (token.type) {
204
+ case "content":
205
+ if (!inFunctionParam && token.value.length > 0) {
206
+ into.push({
207
+ offset: token.ctx.offset,
208
+ length: token.value.length,
209
+ value: token.value
210
+ });
211
+ }
212
+ break;
213
+ case "plural":
214
+ case "select":
215
+ case "selectordinal":
216
+ for (const selectCase of token.cases) {
217
+ collectMf1ContentTokens(selectCase.tokens, into, inFunctionParam);
218
+ }
219
+ break;
220
+ case "function":
221
+ if (token.param) {
222
+ collectMf1ContentTokens(token.param, into, true);
223
+ }
224
+ break;
225
+ case "argument":
226
+ case "octothorpe":
227
+ break;
228
+ }
229
+ }
230
+ return into;
231
+ }
232
+ function pseudoLocalizeMF1(source, options) {
233
+ const spans = collectMf1ContentTokens((0, import_parser.parse)(source));
234
+ if (spans.length === 0) {
235
+ return source;
236
+ }
237
+ spans.sort((a, b) => a.offset - b.offset);
238
+ let result = "";
239
+ let cursor = 0;
240
+ for (const span of spans) {
241
+ result += source.slice(cursor, span.offset);
242
+ result += (0, import_pseudo_localization.localize)(span.value, options);
243
+ cursor = span.offset + span.length;
244
+ }
245
+ result += source.slice(cursor);
246
+ return result;
247
+ }
248
+ function pseudoLocalizeNone(source, options) {
249
+ return (0, import_pseudo_localization.localize)(source, options);
250
+ }
251
+ function pseudoLocalize(source, format, options) {
252
+ switch (format) {
253
+ case "MF1":
254
+ return pseudoLocalizeMF1(source, options);
255
+ case "NONE":
256
+ return pseudoLocalizeNone(source, options);
257
+ case "MF2":
258
+ default:
259
+ return pseudoLocalizeMF2(source, options);
260
+ }
261
+ }
262
+
263
+ // src/classes/MsgResource/MsgResource.ts
171
264
  var MsgResource = class _MsgResource extends Map {
172
265
  _attributes = {};
173
266
  _notes = [];
@@ -198,7 +291,7 @@ var MsgResource = class _MsgResource extends Map {
198
291
  constructor(title, attributes, project, notes) {
199
292
  super();
200
293
  this._title = title;
201
- this._attributes = { ...DEFAULT_ATTRIBUTES, format: project.format, ...attributes };
294
+ this._attributes = applyAttributes(attributes, { format: project.format });
202
295
  this._project = project;
203
296
  if (notes) {
204
297
  notes.forEach((note) => this.setNote(note));
@@ -218,30 +311,13 @@ var MsgResource = class _MsgResource extends Map {
218
311
  resolveFormat(attributes) {
219
312
  return attributes.format ?? MSG_DEFAULT_FORMAT;
220
313
  }
221
- /**
222
- * Pseudo-localizes an MF2 message by localizing only literal text parts.
223
- */
224
- pseudoLocalizeMF2(source, options) {
225
- const msg = (0, import_messageformat2.parseMessage)(source);
226
- (0, import_messageformat2.visit)(msg, {
227
- pattern: (pattern) => {
228
- for (let i = 0; i < pattern.length; i++) {
229
- const part = pattern[i];
230
- if (typeof part === "string") {
231
- pattern[i] = (0, import_pseudo_localization.localize)(part, options);
232
- }
233
- }
234
- }
235
- });
236
- return (0, import_messageformat2.stringifyMessage)(msg);
237
- }
238
314
  /** Locale and formatting metadata for this resource. */
239
315
  get attributes() {
240
316
  return this._attributes;
241
317
  }
242
318
  /** Replaces the resource's locale and formatting metadata. */
243
319
  set attributes(attributes) {
244
- this._attributes = attributes;
320
+ this._attributes = applyAttributes(attributes);
245
321
  }
246
322
  /** Notes attached to this resource for translators and tooling. */
247
323
  get notes() {
@@ -347,7 +423,11 @@ var MsgResource = class _MsgResource extends Map {
347
423
  * Loads and applies translations for a locale via the project loader.
348
424
  *
349
425
  * When `lang` is the project's pseudo-locale, returns a pseudo-localized
350
- * copy without calling the loader.
426
+ * copy without calling the loader. Each message is transformed according to
427
+ * its resolved `format` (`MF1`, `MF2`, or `NONE`): only literal text is
428
+ * accented; placeholders and message-format syntax are preserved.
429
+ *
430
+ * When `lang` is omitted, returns a clone of the current resource.
351
431
  *
352
432
  * @throws {Error} When the locale is unsupported or its language chain is empty.
353
433
  */
@@ -358,19 +438,17 @@ var MsgResource = class _MsgResource extends Map {
358
438
  const project = this._project;
359
439
  const pseudoLocale = project.locales.pseudoLocale;
360
440
  if (lang2 === pseudoLocale) {
441
+ const messages = [...this.values()].map((msg) => ({
442
+ key: msg.key,
443
+ value: pseudoLocalize(msg.value, this.resolveFormat(msg.attributes)),
444
+ attributes: { ...msg.attributes, lang: pseudoLocale }
445
+ }));
361
446
  const pseudolocalizedData = {
362
447
  title: this.title,
363
448
  attributes: { ...this.attributes, lang: pseudoLocale },
364
449
  notes: this.notes.length > 0 ? this.notes : void 0,
365
- messages: []
450
+ messages
366
451
  };
367
- this.forEach((msg) => {
368
- pseudolocalizedData.messages.push({
369
- key: msg.key,
370
- value: this.pseudoLocalizeMF2(msg.value),
371
- attributes: { ...this.attributes, lang: pseudoLocale }
372
- });
373
- });
374
452
  return this.translate(pseudolocalizedData);
375
453
  }
376
454
  const languageChain = project.getTargetLocale(lang2);
@@ -517,5 +595,9 @@ function getLang() {
517
595
  MsgProject,
518
596
  MsgResource,
519
597
  getLang,
598
+ pseudoLocalize,
599
+ pseudoLocalizeMF1,
600
+ pseudoLocalizeMF2,
601
+ pseudoLocalizeNone,
520
602
  setLang
521
603
  });
package/dist/index.d.cts CHANGED
@@ -2,4 +2,5 @@ export { DEFAULT_ATTRIBUTES, MSG_DEFAULT_FORMAT, MsgAttributes, MsgFormat, MsgIn
2
2
  export { MsgMessage, MsgMessageData } from './classes/MsgMessage/MsgMessage.cjs';
3
3
  export { MsgLocalesSettings, MsgProject, MsgProjectData, MsgProjectSettings, MsgResource, MsgResourceData, MsgTargetLocalesSettings, MsgTranslationLoader } from './classes/index.cjs';
4
4
  export { getLang, setLang } from './lib/lang-utils.cjs';
5
+ export { PseudoLocalizeOptions, pseudoLocalize, pseudoLocalizeMF1, pseudoLocalizeMF2, pseudoLocalizeNone } from './lib/pseudo-localize.cjs';
5
6
  import 'messageformat';
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export { DEFAULT_ATTRIBUTES, MSG_DEFAULT_FORMAT, MsgAttributes, MsgFormat, MsgIn
2
2
  export { MsgMessage, MsgMessageData } from './classes/MsgMessage/MsgMessage.js';
3
3
  export { MsgLocalesSettings, MsgProject, MsgProjectData, MsgProjectSettings, MsgResource, MsgResourceData, MsgTargetLocalesSettings, MsgTranslationLoader } from './classes/index.js';
4
4
  export { getLang, setLang } from './lib/lang-utils.js';
5
+ export { PseudoLocalizeOptions, pseudoLocalize, pseudoLocalizeMF1, pseudoLocalizeMF2, pseudoLocalizeNone } from './lib/pseudo-localize.js';
5
6
  import 'messageformat';
package/dist/index.mjs CHANGED
@@ -1,18 +1,25 @@
1
1
  import "./chunk-ORHP7HGX.mjs";
2
- import "./chunk-KQTWUIAM.mjs";
3
- import {
4
- getLang,
5
- setLang
6
- } from "./chunk-PU7ZZ5XH.mjs";
7
2
  import {
8
3
  MsgProject
9
4
  } from "./chunk-DJFPVXQ5.mjs";
10
5
  import {
11
6
  MsgResource
12
- } from "./chunk-HUWFAJAN.mjs";
7
+ } from "./chunk-VDOVMTPF.mjs";
8
+ import "./chunk-KI3KVHLZ.mjs";
9
+ import {
10
+ getLang,
11
+ setLang
12
+ } from "./chunk-PU7ZZ5XH.mjs";
13
+ import {
14
+ pseudoLocalize,
15
+ pseudoLocalizeMF1,
16
+ pseudoLocalizeMF2,
17
+ pseudoLocalizeNone
18
+ } from "./chunk-GHDKBE4P.mjs";
13
19
  import {
14
20
  MsgMessage
15
- } from "./chunk-OKEV7FY7.mjs";
21
+ } from "./chunk-RMZ42XIY.mjs";
22
+ import "./chunk-QU3HGZUN.mjs";
16
23
  import {
17
24
  DEFAULT_ATTRIBUTES,
18
25
  MSG_DEFAULT_FORMAT
@@ -24,5 +31,9 @@ export {
24
31
  MsgProject,
25
32
  MsgResource,
26
33
  getLang,
34
+ pseudoLocalize,
35
+ pseudoLocalizeMF1,
36
+ pseudoLocalizeMF2,
37
+ pseudoLocalizeNone,
27
38
  setLang
28
39
  };
@@ -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
+ };