wuchale 0.17.0 → 0.17.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.
@@ -23,7 +23,9 @@ export declare class Message {
23
23
  toKey: () => string;
24
24
  }
25
25
  export type HeuristicFunc = (msg: Message) => boolean | null | undefined;
26
+ /** Default heuristic */
26
27
  export declare function defaultHeuristic(msg: Message): boolean;
28
+ /** Default heuristic which ignores messages outside functions in the `script` scope */
27
29
  export declare const defaultHeuristicFuncOnly: HeuristicFunc;
28
30
  export declare const defaultGenerateLoadID: (filename: string) => string;
29
31
  export declare class IndexTracker {
package/dist/adapters.js CHANGED
@@ -19,6 +19,7 @@ export class Message {
19
19
  }
20
20
  const ignoreElements = ['style', 'path', 'code', 'pre'];
21
21
  const ignoreAttribs = [['form', 'method']];
22
+ /** Default heuristic */
22
23
  export function defaultHeuristic(msg) {
23
24
  const msgStr = msg.msgStr.join('\n');
24
25
  if (msgStr.search(/\p{L}/u) === -1) {
@@ -50,7 +51,7 @@ export function defaultHeuristic(msg) {
50
51
  }
51
52
  return !msg.details.call?.startsWith('console.') && msg.details.call !== 'fetch';
52
53
  }
53
- // only allow inside function definitions for script scope
54
+ /** Default heuristic which ignores messages outside functions in the `script` scope */
54
55
  export const defaultHeuristicFuncOnly = msg => {
55
56
  return defaultHeuristic(msg) && (msg.details.scope !== 'script' || msg.details.funcName != null);
56
57
  };
package/dist/config.js CHANGED
@@ -19,7 +19,7 @@ function deepAssign(fromObj, toObj) {
19
19
  continue;
20
20
  }
21
21
  // objects
22
- if (!toObj[key]) {
22
+ if (!toObj[key] || Array.isArray(toObj[key]) || typeof toObj[key] !== 'object') {
23
23
  toObj[key] = {};
24
24
  }
25
25
  deepAssign(fromObj[key], toObj[key]);
package/dist/handler.js CHANGED
@@ -564,13 +564,13 @@ export class AdapterHandler {
564
564
  });
565
565
  if (this.#log.checkLevel('verbose')) {
566
566
  if (msgs.length) {
567
- this.#log.verbose(`Extracted ${msgs.length} messages from ${filename}:`);
567
+ this.#log.verbose(`${this.key}: ${msgs.length} messages from ${filename}:`);
568
568
  for (const msg of msgs) {
569
569
  this.#log.verbose(` ${msg.msgStr.join(', ')} [${msg.details.scope}]`);
570
570
  }
571
571
  }
572
572
  else {
573
- this.#log.verbose(`No messages extracted from ${filename}.`);
573
+ this.#log.verbose(`${this.key}: No messages from ${filename}.`);
574
574
  }
575
575
  }
576
576
  const hmrKeys = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuchale",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Protobuf-like i18n from plain code",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",