ilib-tools-common 1.20.1 → 1.21.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/lib/Resource.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/*
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=exports.VALID_STATES=void 0;exports.isValidState=isValidState;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/*
2
2
  * Resource.js - super class that represents a resource
3
3
  *
4
- * Copyright © 2022-2025 JEDLSoft
4
+ * Copyright © 2022-2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,41 @@
15
15
  *
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
- */var validStates={"new":true,"translated":true,"accepted":true};var translationImportant=["context","datatype","dnt","flavor","project","reskey","resType","sourceLocale","targetLocale"];/**
18
+ */var validStates={// XLIFF 2.0 standard states
19
+ // https://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html
20
+ "initial":true,"translated":true,"reviewed":true,"final":true,// XLIFF 1.2 standard states
21
+ // from https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html
22
+ "new":true,"needs-translation":true,"needs-adaptation":true,"needs-l10n":true,"needs-review-translation":true,"needs-review-adaptation":true,"needs-review-l10n":true,"signed-off":true,// Additional common states used in practice
23
+ "needs-review":true,"fuzzy":true,"accepted":true,"rejected":true,"approved":true,"needs-approval":true};/**
24
+ * Array of all valid state names that can be used with Resource objects.
25
+ * This array is sorted alphabetically and includes states from:
26
+ * - XLIFF 2.0 standard states
27
+ * - XLIFF 1.2 standard states
28
+ * - Additional common states used in practice
29
+ *
30
+ * Custom states with "x-" prefix are also valid but not included in this array.
31
+ *
32
+ * @example
33
+ * // Check if a state is valid
34
+ * if (VALID_STATES.includes(state)) {
35
+ * console.log('Valid state');
36
+ * }
37
+ *
38
+ * @type {string[]}
39
+ * @since 1.19.0
40
+ */var VALID_STATES=exports.VALID_STATES=Object.keys(validStates).sort();/**
41
+ * Check if a state is valid according to XLIFF 1.2 or 2.0 specification
42
+ * or if the state is used with ilib projects.
43
+ *
44
+ * @param {string} state the state to validate
45
+ * @returns {boolean} true if the state is valid, false otherwise
46
+ * @since 1.19.0
47
+ */function isValidState(state){// Must be a string
48
+ if(typeof state!=="string"){return false}// Empty string is invalid
49
+ if(state.length===0){return false}// Check predefined states first
50
+ if(validStates[state]){return true}// Custom states must start with "x-" and have content after the hyphen
51
+ if(state.startsWith("x-")){// Must have non-whitespace content after "x-"
52
+ var contentAfterX=state.substring(2);if(contentAfterX.trim().length>0){return true}}return false}var translationImportant=["context","datatype","dnt","flavor","project","reskey","resType","sourceLocale","targetLocale"];/**
19
53
  * @class Represents a resource from a resource file or
20
54
  * extracted from the code.
21
55
  * @abstract
@@ -46,6 +80,7 @@
46
80
  * @param {string} [props.comment] the comment (translator's note) of this resource
47
81
  * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false
48
82
  * @param {string} [props.datatype] the type of file that this resource came from
83
+ * @param {string} [props.sourceHash] the hash value of a source string
49
84
  * @param {string} [props.flavor] the "flavor" of this string, if any. (Android)
50
85
  * @param {Location} [props.location] the location in the file given in pathName where this this resource
51
86
  * is located
@@ -72,7 +107,7 @@
72
107
  */_defineProperty(this,"resfile",void 0);if(this.constructor===Resource){throw new Error("Cannot instantiate abstract class Resource!")}this.autoKey=false;if(props){this.project=props.project;this.context=props.context||undefined;// avoid the empty string
73
108
  this.sourceLocale=props.sourceLocale||props.locale;this.targetLocale=props.targetLocale;this.reskey=props.key||props.reskey;this.pathName=props.pathName;this.autoKey=typeof props.autoKey==="boolean"?props.autoKey:false;this.state=props.state||undefined;this.id=props.id;// the database id
74
109
  this.formatted=props.formatted;// for Android layout resources
75
- this.comment=props.comment;this.origin=props.origin||"source";this.dnt=props.dnt;this.datatype=props.datatype;this.sourceHash=props.sourceHash;this.localize=typeof props.localize==="boolean"?props.localize:true;// some files have resources we do not want to localize/translate
110
+ this.comment=props.comment;this.origin=props.origin||"source";this.dnt=props.dnt;this.datatype=props.datatype;this.sourceHash=props.sourceHash||undefined;this.localize=typeof props.localize==="boolean"?props.localize:true;// some files have resources we do not want to localize/translate
76
111
  this.flavor=props.flavor;this.index=props.index;this.location=props.location;// optional location of the transunits in the xml file
77
112
  this.resfile=props.resfile;// optional resource file path
78
113
  this.metadata=props.metadata||undefined}this.instances=[];this.pathName=this.pathName||"";this.dirty=false}/**
@@ -143,6 +178,14 @@ this.metadata=props.metadata||undefined}this.instances=[];this.pathName=this.pat
143
178
  *
144
179
  * @returns {string} the state of this resource
145
180
  */},{key:"getState",value:function getState(){return this.state}/**
181
+ * Sets the hash value for the source of this resource.
182
+ *
183
+ * @param {string} hashValue the hash value to set for this resource.
184
+ */},{key:"setSourceHash",value:function setSourceHash(hashValue){if(hashValue!==undefined&&typeof hashValue!=="string"){throw new TypeError("hashValue must be a string")}this.sourceHash=hashValue;this.dirty=true}/**
185
+ * Returns the hash value for the source of this resource.
186
+ *
187
+ * @returns {string|undefined} the hash value of this resource.
188
+ */},{key:"getSourceHash",value:function getSourceHash(){return this.sourceHash}/**
146
189
  * Set the project of this resource. This is a string that gives the
147
190
  * id of the project for this resource.
148
191
  *
@@ -153,7 +196,8 @@ this.metadata=props.metadata||undefined}this.instances=[];this.pathName=this.pat
153
196
  * "translated", or "accepted".
154
197
  *
155
198
  * @param {string} state the state of this resource
156
- */},{key:"setState",value:function setState(state){this.state=validStates[state]?state:this.state;this.dirty=true}/**
199
+ * @throws {Error} if the state is invalid
200
+ */},{key:"setState",value:function setState(state){if(!isValidState(state)){throw new Error("Attempt to set an invalid state on a resource: \"".concat(state,"\". Valid states are: ").concat(VALID_STATES.join(", "),", or custom states starting with \"x-\""))}this.state=state;this.dirty=true}/**
157
201
  * Return the original path to the file from which this resource was
158
202
  * originally extracted.
159
203
  *
@@ -304,5 +348,5 @@ return"'"+str.replace(/\\'/g,"'").replace(/'/g,"\\'")+"'";case"undefined":return
304
348
  *
305
349
  * @abstract
306
350
  * @returns {string} a unique hash key for this resource with a cleaned string
307
- */},{key:"cleanHashKey",value:function cleanHashKey(){throw new Error("cleanHashKey() not implemented")}}])}();var _default=exports["default"]=Resource;module.exports=exports.default;
351
+ */},{key:"cleanHashKey",value:function cleanHashKey(){throw new Error("cleanHashKey() not implemented")}}])}();var _default=exports["default"]=Resource;
308
352
  //# sourceMappingURL=Resource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Resource.js","names":["validStates","translationImportant","Resource","props","_classCallCheck","_defineProperty","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","state","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","resfile","metadata","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getMetadata","setMetadata","data","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setProject","setState","getPath","getComment","setComment","getDNT","setDNT","flag","TypeError","getId","getOrigin","getLocalize","getFlavor","getResFile","same","other","i","length","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","hashKey","cleanHashKey","_default","exports","module","default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst validStates = {\n \"new\":true,\n \"translated\":true,\n \"accepted\":true\n}\n\nconst translationImportant = [\n \"context\",\n \"datatype\",\n \"dnt\",\n \"flavor\",\n \"project\",\n \"reskey\",\n \"resType\",\n \"sourceLocale\",\n \"targetLocale\"\n];\n\n\n/**\n * @class Represents a resource from a resource file or\n * extracted from the code.\n * @abstract\n */\nclass Resource {\n /**\n * The type of this resource instance.\n * @type {String | undefined}\n */\n resType;\n\n /**\n * The source string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n source;\n\n /**\n * The target string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n target;\n\n /**\n * The resource file that this resource was loaded from.\n * @type {string|undefined}\n */\n resfile;\n\n /**\n * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n * @param {string} [props.project] the project that this resource is in\n * @param {string} [props.context] The context for this resource,\n * such as \"landscape mode\", or \"7200dp\", which differentiates it\n * from the base resource that has no special context. The default\n * if this property is not specified is undefined, meaning no\n * context.\n * @param {string} [props.sourceLocale] the locale of the source resource.\n * @param {string} [props.targetLocale] the locale of the target resource.\n * @param {string} [props.key] the unique key of this string, which should include the context\n * of the string\n * @param {string} [props.pathName] pathName to the file where the string was extracted from\n * @param {boolean} [props.autoKey] true if the key was generated based on the source text\n * @param {string} [props.state] current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * @param {string} [props.id] the id of the current resource\n * @param {string} [props.comment] the comment (translator's note) of this resource\n * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false\n * @param {string} [props.datatype] the type of file that this resource came from\n * @param {string} [props.flavor] the \"flavor\" of this string, if any. (Android)\n * @param {Location} [props.location] the location in the file given in pathName where this this resource\n * is located\n * @param {string | undefined} [props.resfile] if this resource was extracted from a resource file, this\n * is the path to the resource file that contains this resource. This is different from the pathName\n * property, which is the path to the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android string.xml files or xliff files.\n * Otherwise, the property is undefined.\n * @param {Object|undefined} [props.metadata] the metadata of the resource or undefined for no metadata.\n * This can be any arbitrary object of any depth, as long as the values of properties are all static.\n * It is up to the parsers to parse this and serializers to serialize this appropriately.\n */\n constructor(props) {\n if (this.constructor === Resource) {\n throw new Error(\"Cannot instantiate abstract class Resource!\");\n }\n\n this.autoKey = false;\n\n if (props) {\n this.project = props.project;\n this.context = props.context || undefined; // avoid the empty string\n this.sourceLocale = props.sourceLocale || props.locale;\n this.targetLocale = props.targetLocale;\n this.reskey = props.key || props.reskey;\n this.pathName = props.pathName;\n this.autoKey = typeof(props.autoKey) === \"boolean\" ? props.autoKey : false;\n this.state = props.state || undefined;\n this.id = props.id; // the database id\n this.formatted = props.formatted; // for Android layout resources\n this.comment = props.comment;\n this.origin = props.origin || \"source\";\n this.dnt = props.dnt;\n this.datatype = props.datatype;\n this.sourceHash = props.sourceHash;\n this.localize = typeof(props.localize) === \"boolean\" ? props.localize : true; // some files have resources we do not want to localize/translate\n this.flavor = props.flavor;\n this.index = props.index;\n this.location = props.location; // optional location of the transunits in the xml file\n this.resfile = props.resfile; // optional resource file path\n this.metadata = props.metadata || undefined;\n }\n\n this.instances = [];\n this.pathName = this.pathName || \"\";\n this.dirty = false;\n }\n\n /**\n * Return the project that this resource was found in.\n *\n * @returns {string} the project of this resource\n */\n getProject() {\n return this.project;\n }\n\n /**\n * Return the unique key of this resource.\n *\n * @returns {string} the unique key of this resource\n */\n getKey() {\n return this.reskey;\n }\n\n /**\n * Return the source string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object} the source string or\n * strings of this resource\n */\n getSource() {\n return this.source;\n }\n\n /**\n * Return the target string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object|undefined} the source string or\n * strings of this resource\n */\n getTarget() {\n return this.target;\n }\n\n /**\n * Return the resource type of this resource. This is one of\n * string, array, or plural.\n *\n * @returns {string} the resource type of this resource\n */\n getType() {\n return this.resType || \"string\";\n }\n\n /**\n * Return the data type of this resource.\n *\n * @returns {string} the data type of this resource\n */\n getDataType() {\n return this.datatype;\n }\n\n /**\n * Return true if the key of this resource was automatically generated,\n * and false if it was an explicit key.\n *\n * @returns {boolean} true if the key of this string was auto generated,\n * false otherwise\n */\n getAutoKey() {\n return this.autoKey;\n }\n\n /**\n * Return the context of this resource, or undefined if there\n * is no context.\n * @returns {String|undefined} the context of this resource, or undefined if there\n * is no context.\n */\n getContext() {\n return this.context;\n }\n\n /**\n * Get the metadata of this resource.\n *\n * @returns {Object|undefined} the metadata of this resource.\n */\n getMetadata() {\n return this.metadata;\n }\n\n /**\n * Set the metadata of this resource.\n * @param {Object|undefined} data the metadata of this resource.\n */\n setMetadata(data) {\n this.metadata = data;\n }\n\n /**\n * Return the source locale of this resource, or undefined if there\n * is no context or the locale is the same as the project's source locale.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getSourceLocale() {\n return this.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source locale of this resource.\n * @param {string} locale the source locale of this resource\n */\n setSourceLocale(locale) {\n this.sourceLocale = locale || this.sourceLocale;\n this.dirty = true;\n }\n\n /**\n * Return the target locale of this resource, or undefined if the resource\n * is a source-only resource.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getTargetLocale() {\n return this.targetLocale;\n }\n\n /**\n * Set the target locale of this resource.\n * @param {string} locale the target locale of this resource\n */\n setTargetLocale(locale) {\n this.targetLocale = locale || this.targetLocale;\n this.dirty = true;\n }\n\n /**\n * Return the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @returns {string} the state of this resource\n */\n getState() {\n return this.state;\n }\n\n /**\n * Set the project of this resource. This is a string that gives the\n * id of the project for this resource.\n *\n * @param {string} project the project name to set for this resource\n */\n setProject(project) {\n this.project = project;\n this.dirty = true;\n }\n\n /**\n * Set the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @param {string} state the state of this resource\n */\n setState(state) {\n this.state = validStates[state] ? state : this.state;\n this.dirty = true;\n }\n\n /**\n * Return the original path to the file from which this resource was\n * originally extracted.\n *\n * @returns {string} the path to the file containing this resource\n */\n getPath() {\n return this.pathName;\n }\n\n /**\n * Return the translator's comment for this resource if there is\n * one, or undefined if not.\n *\n * @returns {String|undefined} the translator's comment for this resource\n * if the engineer put one in the code\n */\n getComment() {\n return this.comment;\n }\n\n /**\n * Set the translator's comment for this resource.\n *\n * @param {String|undefined} comment the translator's comment to set. Use\n * undefined to clear the comment\n */\n setComment(comment) {\n this.comment = comment;\n this.dirty = true;\n }\n\n /**\n * Get the \"do not translate\" flag for this resource.\n *\n * @returns {boolean} true means that the current resource should not\n * be translated, and false means it will be translated.\n */\n getDNT() {\n return typeof(this.dnt) === 'boolean' ? this.dnt : false;\n }\n\n /**\n * Set the \"do not translate\" flag for this resource.\n *\n * @param {boolean} flag set the dnt flag to this value\n */\n setDNT(flag) {\n if (typeof(flag) !== 'boolean') {\n throw new TypeError('value must be boolean');\n }\n this.dnt = flag;\n this.dirty = true;\n }\n\n /**\n * Return the database id if this resource has previously been saved in the\n * database.\n *\n * @returns {number|undefined} the database id if this resource has previously\n * been saved in the database, or undefined if it is has not\n */\n getId() {\n return this.id;\n }\n\n /**\n * Return the origin of this resource. The origin may be either the string\n * \"source\" or \"target\". Source origin resources are ones that are extracted\n * from the source code, whereas target ones are translations from the\n * translators.\n *\n * @returns {string} the origin of this resource\n */\n getOrigin() {\n return this.origin;\n }\n\n /**\n * Return the localize flag of this resource.\n * This flag indicates whether we should look up a translation for this resource.\n * When false, we should simply substitute the source back\n *\n * @returns {Boolean} the localize flag of this resource\n */\n getLocalize() {\n return this.localize;\n }\n\n /**\n * Return the name of the flavor for this resource, or undefined\n * for the \"main\" or default flavor.\n *\n * @return {String|undefined} the name of the flavor for this\n * resource or undefined for the main or default flavor\n */\n getFlavor() {\n return this.flavor;\n }\n\n /**\n * Return the path to the resource file that contains this resource.\n * This is different from the pathName property, which is the path to\n * the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android\n * string.xml files or xliff files. Otherwise, the property is undefined.\n *\n * @returns {string|undefined} the path to the resource file that contains\n * this resource, or undefined if this resource was not extracted from\n * a resource file\n */\n getResFile() {\n return this.resfile;\n }\n\n /**\n * Return true if the other resource represents the same resource as\n * the current one. The project, context, locale, key, flavor, and type must\n * match. Other fields such as the pathName, state, and comment fields are\n * ignored as minor variations.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n same(other) {\n if (!other) return false;\n\n const props = [\"project\", \"context\", \"sourceLocale\", \"targetLocale\", \"reskey\", \"resType\", \"flavor\"];\n for (let i = 0; i < props.length; i++) {\n if (this[props[i]] !== other[props[i]]) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Escape text for writing to a database in a SQL command. This puts single\n * quotes around the string, and makes sure that all single quotes within\n * the string are escaped.\n *\n * @param {Object} str the item to escape\n * @returns {string} the escaped string\n */\n escapeText(str) {\n switch (typeof(str)) {\n case \"string\":\n // unescape first, then re-escape to make everything consistent\n return \"'\" + str.replace(/\\\\'/g, \"'\").replace(/'/g, \"\\\\'\") + \"'\";\n case \"undefined\":\n return \"NULL\";\n case \"boolean\":\n return str ? \"TRUE\" : \"FALSE\";\n default:\n if (str === null) {\n return \"NULL\";\n }\n return str.toString();\n }\n }\n\n /**\n * Add an instance of the same resource to the list of\n * instances. If the given resource matches the\n * current instance in all properties that affect the\n * possible translation, and differs from the current\n * instance by some property that does not affect\n * its translation, it will be added as an instance of\n * the same string. The following properties affect the\n * translation:\n *\n * <ul>\n * <li>context</li>\n * <li>datatype</li>\n * <li>dnt</li>\n * <li>flavor</li>\n * <li>project</li>\n * <li>reskey</li>\n * <li>resType</li>\n * <li>source</li>\n * <li>sourceHash</li>\n * <li>sourceArray</li>\n * <li>sourceLocale</li>\n * <li>targetLocale</li>\n * </ul>\n *\n * Differences in other properties, such as \"comment\" or\n * \"origin\" are considered instances of the same resource.\n *\n * If this method is given a resource that differs from\n * the current one by one of the above translation affecting\n * properties, it is not added to the list of instances. This\n * can be checked easily by calling the isInstance() method.\n *\n * @param {Resource} resource an instance of the current resource to\n * record\n * @returns {boolean} true if the instance was added, and\n * and false otherwise\n */\n addInstance(resource) {\n if (!this.isInstance(resource)) {\n return false;\n }\n const unique = this !== resource && this.instances.every(res => {\n return res !== resource;\n });\n if (!unique) {\n return false;\n }\n this.instances.push(resource);\n this.dirty = true;\n return true;\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource. This method returns true if all properties which\n * affect the possible translation match between the given and\n * the current resource.\n *\n * @param {Resource} resource a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (typeof(resource) !== 'object' || !(resource instanceof Resource)) {\n return false;\n }\n\n return translationImportant.every(prop => {\n return this[prop] === resource[prop];\n });\n }\n\n /**\n * Return the list of instances of the current resource.\n *\n * @returns {Array.<Resource>} the list of instances of\n * the current resource\n */\n getInstances() {\n return this.instances;\n }\n\n /**\n * Return true if this instance has been modified since its creation, and false otherwise.\n */\n isDirty() {\n return this.dirty\n }\n\n /**\n * Clear the dirty flag. This is used for example when the Resource was\n * written to disk and the modifications are already recorded, allowing\n * new modifications later.\n */\n clearDirty() {\n this.dirty = false;\n }\n\n /**\n * Return the location of the resource instance in the original file where it was read\n * from. This is usually an object containing a line and a char property which gives the\n * line number and character within that line where the representation of the resource\n * instance starts.\n *\n * @returns {Location|undefined} the location information, or undefined if no location\n * information is available\n */\n getLocation() {\n return this.location?.getLocation();\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @abstract\n * @returns {string} a unique hash key for this resource\n */\n hashKey() {\n throw new Error(\"hashKey() not implemented\");\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @abstract\n * @returns {string} a unique hash key for this resource with a cleaned string\n */\n cleanHashKey() {\n throw new Error(\"cleanHashKey() not implemented\");\n }\n}\n\nexport default Resource;\n"],"mappings":"k0CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,GAAM,CAAAA,WAAW,CAAG,CAChB,KAAK,CAAC,IAAI,CACV,YAAY,CAAC,IAAI,CACjB,UAAU,CAAC,IACf,CAAC,CAED,GAAM,CAAAC,oBAAoB,CAAG,CACzB,SAAS,CACT,UAAU,CACV,KAAK,CACL,QAAQ,CACR,SAAS,CACT,QAAQ,CACR,SAAS,CACT,cAAc,CACd,cAAc,CACjB,CAGD;AACA;AACA;AACA;AACA,GAJA,GAKM,CAAAC,QAAQ,yBAyBV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MACI,SAAAA,SAAYC,KAAK,CAAE,CAAAC,eAAA,MAAAF,QAAA,EA/DnB;AACJ;AACA;AACA,OAHIG,eAAA,wBAMA;AACJ;AACA;AACA,OAHIA,eAAA,uBAMA;AACJ;AACA;AACA,OAHIA,eAAA,uBAMA;AACJ;AACA;AACA,OAHIA,eAAA,wBA8CI,GAAI,IAAI,CAACC,WAAW,GAAKJ,QAAQ,CAAE,CAC/B,KAAM,IAAI,CAAAK,KAAK,CAAC,6CAA6C,CACjE,CAEA,IAAI,CAACC,OAAO,CAAG,KAAK,CAEpB,GAAIL,KAAK,CAAE,CACP,IAAI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AC,gCAAgC,CACpD,CAAC,WAAAuF,QAAA,CAAAC,OAAA,YAGU7F,QAAQ,CAAA8F,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"Resource.js","names":["validStates","VALID_STATES","exports","Object","keys","sort","isValidState","state","length","startsWith","contentAfterX","substring","trim","translationImportant","Resource","props","_classCallCheck","_defineProperty","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","resfile","metadata","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getMetadata","setMetadata","data","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setSourceHash","hashValue","TypeError","getSourceHash","setProject","setState","concat","join","getPath","getComment","setComment","getDNT","setDNT","flag","getId","getOrigin","getLocalize","getFlavor","getResFile","same","other","i","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","hashKey","cleanHashKey","_default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2026 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst validStates = {\n // XLIFF 2.0 standard states\n // https://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html\n \"initial\": true,\n \"translated\": true,\n \"reviewed\": true,\n \"final\": true,\n\n // XLIFF 1.2 standard states\n // from https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html\n \"new\": true,\n \"needs-translation\": true,\n \"needs-adaptation\": true,\n \"needs-l10n\": true,\n \"needs-review-translation\": true,\n \"needs-review-adaptation\": true,\n \"needs-review-l10n\": true,\n \"signed-off\": true,\n\n // Additional common states used in practice\n \"needs-review\": true,\n \"fuzzy\": true,\n \"accepted\": true,\n \"rejected\": true,\n \"approved\": true,\n \"needs-approval\": true\n};\n\n/**\n * Array of all valid state names that can be used with Resource objects.\n * This array is sorted alphabetically and includes states from:\n * - XLIFF 2.0 standard states\n * - XLIFF 1.2 standard states\n * - Additional common states used in practice\n *\n * Custom states with \"x-\" prefix are also valid but not included in this array.\n *\n * @example\n * // Check if a state is valid\n * if (VALID_STATES.includes(state)) {\n * console.log('Valid state');\n * }\n *\n * @type {string[]}\n * @since 1.19.0\n */\nexport const VALID_STATES = Object.keys(validStates).sort();\n\n/**\n * Check if a state is valid according to XLIFF 1.2 or 2.0 specification\n * or if the state is used with ilib projects.\n *\n * @param {string} state the state to validate\n * @returns {boolean} true if the state is valid, false otherwise\n * @since 1.19.0\n */\nfunction isValidState(state) {\n // Must be a string\n if (typeof state !== 'string') {\n return false;\n }\n\n // Empty string is invalid\n if (state.length === 0) {\n return false;\n }\n\n // Check predefined states first\n if (validStates[state]) {\n return true;\n }\n\n // Custom states must start with \"x-\" and have content after the hyphen\n if (state.startsWith('x-')) {\n // Must have non-whitespace content after \"x-\"\n const contentAfterX = state.substring(2);\n if (contentAfterX.trim().length > 0) {\n return true;\n }\n }\n\n return false;\n}\n\nexport { isValidState };\n\nconst translationImportant = [\n \"context\",\n \"datatype\",\n \"dnt\",\n \"flavor\",\n \"project\",\n \"reskey\",\n \"resType\",\n \"sourceLocale\",\n \"targetLocale\"\n];\n\n\n/**\n * @class Represents a resource from a resource file or\n * extracted from the code.\n * @abstract\n */\nclass Resource {\n /**\n * The type of this resource instance.\n * @type {String | undefined}\n */\n resType;\n\n /**\n * The source string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n source;\n\n /**\n * The target string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n target;\n\n /**\n * The resource file that this resource was loaded from.\n * @type {string|undefined}\n */\n resfile;\n\n /**\n * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n * @param {string} [props.project] the project that this resource is in\n * @param {string} [props.context] The context for this resource,\n * such as \"landscape mode\", or \"7200dp\", which differentiates it\n * from the base resource that has no special context. The default\n * if this property is not specified is undefined, meaning no\n * context.\n * @param {string} [props.sourceLocale] the locale of the source resource.\n * @param {string} [props.targetLocale] the locale of the target resource.\n * @param {string} [props.key] the unique key of this string, which should include the context\n * of the string\n * @param {string} [props.pathName] pathName to the file where the string was extracted from\n * @param {boolean} [props.autoKey] true if the key was generated based on the source text\n * @param {string} [props.state] current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * @param {string} [props.id] the id of the current resource\n * @param {string} [props.comment] the comment (translator's note) of this resource\n * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false\n * @param {string} [props.datatype] the type of file that this resource came from\n * @param {string} [props.sourceHash] the hash value of a source string\n * @param {string} [props.flavor] the \"flavor\" of this string, if any. (Android)\n * @param {Location} [props.location] the location in the file given in pathName where this this resource\n * is located\n * @param {string | undefined} [props.resfile] if this resource was extracted from a resource file, this\n * is the path to the resource file that contains this resource. This is different from the pathName\n * property, which is the path to the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android string.xml files or xliff files.\n * Otherwise, the property is undefined.\n * @param {Object|undefined} [props.metadata] the metadata of the resource or undefined for no metadata.\n * This can be any arbitrary object of any depth, as long as the values of properties are all static.\n * It is up to the parsers to parse this and serializers to serialize this appropriately.\n */\n constructor(props) {\n if (this.constructor === Resource) {\n throw new Error(\"Cannot instantiate abstract class Resource!\");\n }\n\n this.autoKey = false;\n\n if (props) {\n this.project = props.project;\n this.context = props.context || undefined; // avoid the empty string\n this.sourceLocale = props.sourceLocale || props.locale;\n this.targetLocale = props.targetLocale;\n this.reskey = props.key || props.reskey;\n this.pathName = props.pathName;\n this.autoKey = typeof(props.autoKey) === \"boolean\" ? props.autoKey : false;\n this.state = props.state || undefined;\n this.id = props.id; // the database id\n this.formatted = props.formatted; // for Android layout resources\n this.comment = props.comment;\n this.origin = props.origin || \"source\";\n this.dnt = props.dnt;\n this.datatype = props.datatype;\n this.sourceHash = props.sourceHash || undefined;\n this.localize = typeof(props.localize) === \"boolean\" ? props.localize : true; // some files have resources we do not want to localize/translate\n this.flavor = props.flavor;\n this.index = props.index;\n this.location = props.location; // optional location of the transunits in the xml file\n this.resfile = props.resfile; // optional resource file path\n this.metadata = props.metadata || undefined;\n }\n\n this.instances = [];\n this.pathName = this.pathName || \"\";\n this.dirty = false;\n }\n\n /**\n * Return the project that this resource was found in.\n *\n * @returns {string} the project of this resource\n */\n getProject() {\n return this.project;\n }\n\n /**\n * Return the unique key of this resource.\n *\n * @returns {string} the unique key of this resource\n */\n getKey() {\n return this.reskey;\n }\n\n /**\n * Return the source string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object} the source string or\n * strings of this resource\n */\n getSource() {\n return this.source;\n }\n\n /**\n * Return the target string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object|undefined} the source string or\n * strings of this resource\n */\n getTarget() {\n return this.target;\n }\n\n /**\n * Return the resource type of this resource. This is one of\n * string, array, or plural.\n *\n * @returns {string} the resource type of this resource\n */\n getType() {\n return this.resType || \"string\";\n }\n\n /**\n * Return the data type of this resource.\n *\n * @returns {string} the data type of this resource\n */\n getDataType() {\n return this.datatype;\n }\n\n /**\n * Return true if the key of this resource was automatically generated,\n * and false if it was an explicit key.\n *\n * @returns {boolean} true if the key of this string was auto generated,\n * false otherwise\n */\n getAutoKey() {\n return this.autoKey;\n }\n\n /**\n * Return the context of this resource, or undefined if there\n * is no context.\n * @returns {String|undefined} the context of this resource, or undefined if there\n * is no context.\n */\n getContext() {\n return this.context;\n }\n\n /**\n * Get the metadata of this resource.\n *\n * @returns {Object|undefined} the metadata of this resource.\n */\n getMetadata() {\n return this.metadata;\n }\n\n /**\n * Set the metadata of this resource.\n * @param {Object|undefined} data the metadata of this resource.\n */\n setMetadata(data) {\n this.metadata = data;\n }\n\n /**\n * Return the source locale of this resource, or undefined if there\n * is no context or the locale is the same as the project's source locale.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getSourceLocale() {\n return this.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source locale of this resource.\n * @param {string} locale the source locale of this resource\n */\n setSourceLocale(locale) {\n this.sourceLocale = locale || this.sourceLocale;\n this.dirty = true;\n }\n\n /**\n * Return the target locale of this resource, or undefined if the resource\n * is a source-only resource.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getTargetLocale() {\n return this.targetLocale;\n }\n\n /**\n * Set the target locale of this resource.\n * @param {string} locale the target locale of this resource\n */\n setTargetLocale(locale) {\n this.targetLocale = locale || this.targetLocale;\n this.dirty = true;\n }\n\n /**\n * Return the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @returns {string} the state of this resource\n */\n getState() {\n return this.state;\n }\n\n /**\n * Sets the hash value for the source of this resource.\n *\n * @param {string} hashValue the hash value to set for this resource.\n */\n setSourceHash(hashValue) {\n if (hashValue !== undefined && typeof hashValue !== 'string') {\n throw new TypeError('hashValue must be a string');\n }\n this.sourceHash = hashValue;\n this.dirty = true;\n }\n\n /**\n * Returns the hash value for the source of this resource.\n *\n * @returns {string|undefined} the hash value of this resource.\n */\n getSourceHash() {\n return this.sourceHash;\n }\n\n /**\n * Set the project of this resource. This is a string that gives the\n * id of the project for this resource.\n *\n * @param {string} project the project name to set for this resource\n */\n setProject(project) {\n this.project = project;\n this.dirty = true;\n }\n\n /**\n * Set the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @param {string} state the state of this resource\n * @throws {Error} if the state is invalid\n */\n setState(state) {\n if (!isValidState(state)) {\n throw new Error(`Attempt to set an invalid state on a resource: \"${state}\". Valid states are: ${VALID_STATES.join(', ')}, or custom states starting with \"x-\"`);\n }\n this.state = state;\n this.dirty = true;\n }\n\n /**\n * Return the original path to the file from which this resource was\n * originally extracted.\n *\n * @returns {string} the path to the file containing this resource\n */\n getPath() {\n return this.pathName;\n }\n\n /**\n * Return the translator's comment for this resource if there is\n * one, or undefined if not.\n *\n * @returns {String|undefined} the translator's comment for this resource\n * if the engineer put one in the code\n */\n getComment() {\n return this.comment;\n }\n\n /**\n * Set the translator's comment for this resource.\n *\n * @param {String|undefined} comment the translator's comment to set. Use\n * undefined to clear the comment\n */\n setComment(comment) {\n this.comment = comment;\n this.dirty = true;\n }\n\n /**\n * Get the \"do not translate\" flag for this resource.\n *\n * @returns {boolean} true means that the current resource should not\n * be translated, and false means it will be translated.\n */\n getDNT() {\n return typeof(this.dnt) === 'boolean' ? this.dnt : false;\n }\n\n /**\n * Set the \"do not translate\" flag for this resource.\n *\n * @param {boolean} flag set the dnt flag to this value\n */\n setDNT(flag) {\n if (typeof(flag) !== 'boolean') {\n throw new TypeError('value must be boolean');\n }\n this.dnt = flag;\n this.dirty = true;\n }\n\n /**\n * Return the database id if this resource has previously been saved in the\n * database.\n *\n * @returns {number|undefined} the database id if this resource has previously\n * been saved in the database, or undefined if it is has not\n */\n getId() {\n return this.id;\n }\n\n /**\n * Return the origin of this resource. The origin may be either the string\n * \"source\" or \"target\". Source origin resources are ones that are extracted\n * from the source code, whereas target ones are translations from the\n * translators.\n *\n * @returns {string} the origin of this resource\n */\n getOrigin() {\n return this.origin;\n }\n\n /**\n * Return the localize flag of this resource.\n * This flag indicates whether we should look up a translation for this resource.\n * When false, we should simply substitute the source back\n *\n * @returns {Boolean} the localize flag of this resource\n */\n getLocalize() {\n return this.localize;\n }\n\n /**\n * Return the name of the flavor for this resource, or undefined\n * for the \"main\" or default flavor.\n *\n * @return {String|undefined} the name of the flavor for this\n * resource or undefined for the main or default flavor\n */\n getFlavor() {\n return this.flavor;\n }\n\n /**\n * Return the path to the resource file that contains this resource.\n * This is different from the pathName property, which is the path to\n * the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android\n * string.xml files or xliff files. Otherwise, the property is undefined.\n *\n * @returns {string|undefined} the path to the resource file that contains\n * this resource, or undefined if this resource was not extracted from\n * a resource file\n */\n getResFile() {\n return this.resfile;\n }\n\n /**\n * Return true if the other resource represents the same resource as\n * the current one. The project, context, locale, key, flavor, and type must\n * match. Other fields such as the pathName, state, and comment fields are\n * ignored as minor variations.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n same(other) {\n if (!other) return false;\n\n const props = [\"project\", \"context\", \"sourceLocale\", \"targetLocale\", \"reskey\", \"resType\", \"flavor\"];\n for (let i = 0; i < props.length; i++) {\n if (this[props[i]] !== other[props[i]]) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Escape text for writing to a database in a SQL command. This puts single\n * quotes around the string, and makes sure that all single quotes within\n * the string are escaped.\n *\n * @param {Object} str the item to escape\n * @returns {string} the escaped string\n */\n escapeText(str) {\n switch (typeof(str)) {\n case \"string\":\n // unescape first, then re-escape to make everything consistent\n return \"'\" + str.replace(/\\\\'/g, \"'\").replace(/'/g, \"\\\\'\") + \"'\";\n case \"undefined\":\n return \"NULL\";\n case \"boolean\":\n return str ? \"TRUE\" : \"FALSE\";\n default:\n if (str === null) {\n return \"NULL\";\n }\n return str.toString();\n }\n }\n\n /**\n * Add an instance of the same resource to the list of\n * instances. If the given resource matches the\n * current instance in all properties that affect the\n * possible translation, and differs from the current\n * instance by some property that does not affect\n * its translation, it will be added as an instance of\n * the same string. The following properties affect the\n * translation:\n *\n * <ul>\n * <li>context</li>\n * <li>datatype</li>\n * <li>dnt</li>\n * <li>flavor</li>\n * <li>project</li>\n * <li>reskey</li>\n * <li>resType</li>\n * <li>source</li>\n * <li>sourceHash</li>\n * <li>sourceArray</li>\n * <li>sourceLocale</li>\n * <li>targetLocale</li>\n * </ul>\n *\n * Differences in other properties, such as \"comment\" or\n * \"origin\" are considered instances of the same resource.\n *\n * If this method is given a resource that differs from\n * the current one by one of the above translation affecting\n * properties, it is not added to the list of instances. This\n * can be checked easily by calling the isInstance() method.\n *\n * @param {Resource} resource an instance of the current resource to\n * record\n * @returns {boolean} true if the instance was added, and\n * and false otherwise\n */\n addInstance(resource) {\n if (!this.isInstance(resource)) {\n return false;\n }\n const unique = this !== resource && this.instances.every(res => {\n return res !== resource;\n });\n if (!unique) {\n return false;\n }\n this.instances.push(resource);\n this.dirty = true;\n return true;\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource. This method returns true if all properties which\n * affect the possible translation match between the given and\n * the current resource.\n *\n * @param {Resource} resource a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (typeof(resource) !== 'object' || !(resource instanceof Resource)) {\n return false;\n }\n\n return translationImportant.every(prop => {\n return this[prop] === resource[prop];\n });\n }\n\n /**\n * Return the list of instances of the current resource.\n *\n * @returns {Array.<Resource>} the list of instances of\n * the current resource\n */\n getInstances() {\n return this.instances;\n }\n\n /**\n * Return true if this instance has been modified since its creation, and false otherwise.\n */\n isDirty() {\n return this.dirty\n }\n\n /**\n * Clear the dirty flag. This is used for example when the Resource was\n * written to disk and the modifications are already recorded, allowing\n * new modifications later.\n */\n clearDirty() {\n this.dirty = false;\n }\n\n /**\n * Return the location of the resource instance in the original file where it was read\n * from. This is usually an object containing a line and a char property which gives the\n * line number and character within that line where the representation of the resource\n * instance starts.\n *\n * @returns {Location|undefined} the location information, or undefined if no location\n * information is available\n */\n getLocation() {\n return this.location?.getLocation();\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @abstract\n * @returns {string} a unique hash key for this resource\n */\n hashKey() {\n throw new Error(\"hashKey() not implemented\");\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @abstract\n * @returns {string} a unique hash key for this resource with a cleaned string\n */\n cleanHashKey() {\n throw new Error(\"cleanHashKey() not implemented\");\n }\n}\n\nexport default Resource;\n"],"mappings":"y3CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,GAAM,CAAAA,WAAW,CAAG,CAChB;AACA;AACA,SAAS,CAAE,IAAI,CACf,YAAY,CAAE,IAAI,CAClB,UAAU,CAAE,IAAI,CAChB,OAAO,CAAE,IAAI,CAEb;AACA;AACA,KAAK,CAAE,IAAI,CACX,mBAAmB,CAAE,IAAI,CACzB,kBAAkB,CAAE,IAAI,CACxB,YAAY,CAAE,IAAI,CAClB,0BAA0B,CAAE,IAAI,CAChC,yBAAyB,CAAE,IAAI,CAC/B,mBAAmB,CAAE,IAAI,CACzB,YAAY,CAAE,IAAI,CAElB;AACA,cAAc,CAAE,IAAI,CACpB,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,IAAI,CAChB,UAAU,CAAE,IAAI,CAChB,UAAU,CAAE,IAAI,CAChB,gBAAgB,CAAE,IACtB,CAAC,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACO,GAAM,CAAAC,YAAY,CAAAC,OAAA,CAAAD,YAAA,CAAGE,MAAM,CAACC,IAAI,CAACJ,WAAW,CAAC,CAACK,IAAI,CAAC,CAAC,CAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,YAAYA,CAACC,KAAK,CAAE,CACzB;AACA,GAAI,MAAO,CAAAA,KAAK,GAAK,QAAQ,CAAE,CAC3B,MAAO,MACX,CAEA;AACA,GAAIA,KAAK,CAACC,MAAM,GAAK,CAAC,CAAE,CACpB,MAAO,MACX,CAEA;AACA,GAAIR,WAAW,CAACO,KAAK,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,CAAA,CAAG,KAAAC,cAAA,CACV,OAAAA,cAAA,CAAO,IAAI,CAAClE,QAAQ,UAAAkE,cAAA,iBAAbA,cAAA,CAAeD,WAAW,CAAC,CACtC,CAEA;AACJ;AACA;AACA;AACA;AACA,OALI,GAAA7E,GAAA,WAAAkB,KAAA,CAMA,SAAA6D,OAAOA,CAAA,CAAG,CACN,KAAM,IAAI,CAAAxF,KAAK,CAAC,2BAA2B,CAC/C,CAEA;AACJ;AACA;AACA;AACA;AACA,OALI,GAAAS,GAAA,gBAAAkB,KAAA,CAMA,SAAA8D,YAAYA,CAAA,CAAG,CACX,KAAM,IAAI,CAAAzF,KAAK,CAAC,gCAAgC,CACpD,CAAC,WAAA0F,QAAA,CAAA3G,OAAA,YAGUY,QAAQ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _Resource2=_interopRequireDefault(require("./Resource.js"));var _utils=require("./utils.js");var _log4jsApi=_interopRequireDefault(require("@log4js-node/log4js-api"));function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t)}:p}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},_get.apply(null,arguments)}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}/*
2
2
  * ResourceString.js - represents an string in a resource file
3
3
  *
4
- * Copyright © 2022-2023 JEDLSoft
4
+ * Copyright © 2022-2023, 2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -64,29 +64,30 @@
64
64
  * @param {String} datatype the datatype of the string
65
65
  * @param {String} flavor the flavor of the string
66
66
  * @param {String} context the context of the string
67
+ * @param {String} sourceHash the sourceHash of the string
67
68
  * @static
68
69
  * @return {String} a hash key
69
70
  */},{key:"hashKey",value:/**
70
71
  * Return the a hash key that uniquely identifies this resource.
71
72
  *
72
73
  * @return {String} a unique hash key for this resource
73
- */function hashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
74
+ */function hashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
74
75
  * Return the a hash key that uniquely identifies the translation of
75
76
  * this resource to the given locale.
76
77
  *
77
78
  * @param {String} locale a locale spec of the desired translation
78
79
  * @return {String} a unique hash key for this resource
79
- */},{key:"hashKeyForTranslation",value:function hashKeyForTranslation(locale){return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
80
+ */},{key:"hashKeyForTranslation",value:function hashKeyForTranslation(locale){return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
80
81
  * Return the a hash key that uniquely identifies this resource, but cleaned
81
82
  *
82
83
  * @return {String} a unique hash key for this resource, but cleaned
83
- */},{key:"cleanHashKey",value:function cleanHashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
84
+ */},{key:"cleanHashKey",value:function cleanHashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
84
85
  * Return the a hash key that uniquely identifies the translation of
85
86
  * this resource to the given locale, but cleaned
86
87
  *
87
88
  * @param {String} locale a locale spec of the desired translation
88
89
  * @return {String} a unique hash key for this resource's string
89
- */},{key:"cleanHashKeyForTranslation",value:function cleanHashKeyForTranslation(locale){return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
90
+ */},{key:"cleanHashKeyForTranslation",value:function cleanHashKeyForTranslation(locale){return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
90
91
  * Check if the given resource is an instance of the current
91
92
  * resource.
92
93
  *
@@ -95,7 +96,7 @@
95
96
  * @returns {boolean} true if this is an instance of
96
97
  * the current resource, false otherwise.
97
98
  */},{key:"isInstance",value:function isInstance(resource){if(!_superPropGet(ResourceString,"isInstance",this,3)([resource])){return false}// now check the properties specific to this resource subclass
98
- return(0,_utils.cleanString)(this.source)===(0,_utils.cleanString)(resource.source)}}],[{key:"hashKey",value:function hashKey(project,locale,reskey,datatype,flavor,context){var key=["rs",project,locale,reskey,datatype,flavor,context].join("_");logger.trace("Hashkey is "+key);return key}/**
99
+ return(0,_utils.cleanString)(this.source)===(0,_utils.cleanString)(resource.source)}}],[{key:"hashKey",value:function hashKey(project,locale,reskey,datatype,flavor,context,sourceHash){var key=["rs",project,locale,reskey,datatype,flavor,context,sourceHash].join("_");logger.trace("Hashkey is "+key);return key}/**
99
100
  * Calculate a resource key string for this class of resource given the
100
101
  * parameters.
101
102
  *
@@ -105,9 +106,10 @@ return(0,_utils.cleanString)(this.source)===(0,_utils.cleanString)(resource.sour
105
106
  * @param {String} datatype the datatype of the string
106
107
  * @param {String} flavor the flavor of the string
107
108
  * @param {String} context the context of the string
109
+ * @param {String} sourceHash the sourceHash of the string
108
110
  * @static
109
111
  * @return {String} a hash key
110
- */},{key:"cleanHashKey",value:function cleanHashKey(project,locale,reskey,datatype,flavor,context){var cleaned=reskey&&reskey.replace(/\s+/g," ").trim()||"";var key=["rs",project,locale,cleaned,datatype,flavor,context].join("_");logger.trace("CleanHashkey is "+key);return key}}])}(_Resource2["default"]);/**
112
+ */},{key:"cleanHashKey",value:function cleanHashKey(project,locale,reskey,datatype,flavor,context,sourceHash){var cleaned=reskey&&reskey.replace(/\s+/g," ").trim()||"";var key=["rs",project,locale,cleaned,datatype,flavor,context,sourceHash].join("_");logger.trace("CleanHashkey is "+key);return key}}])}(_Resource2["default"]);/**
111
113
  * The class of this kind of string resource.
112
114
  *
113
115
  * @static
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceString.js","names":["_Resource2","_interopRequireDefault","require","_utils","_log4jsApi","e","__esModule","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","o","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","prototype","i","_toPrimitive","_typeof","Symbol","toPrimitive","call","String","Number","_callSuper","_getPrototypeOf","_possibleConstructorReturn","_isNativeReflectConstruct","Reflect","construct","constructor","apply","_assertThisInitialized","ReferenceError","Boolean","valueOf","_superPropGet","p","_get","get","bind","_superPropBase","getOwnPropertyDescriptor","arguments","value","hasOwnProperty","setPrototypeOf","getPrototypeOf","__proto__","_inherits","create","_setPrototypeOf","logger","log4js","getLogger","ResourceString","_Resource","props","_this","source","text","target","origin","datatype","resType","resClass","sourceLocale","project","setSource","str","dirty","setTarget","size","clone","overrides","equals","other","same","hashKey","locale","targetLocale","getSourceLocale","reskey","flavor","context","hashKeyForTranslation","cleanHashKey","cleanHashKeyForTranslation","isInstance","resource","cleanString","join","trace","cleaned","replace","trim","Resource","_default","exports","module","default"],"sources":["../src/ResourceString.js"],"sourcesContent":["/*\n * ResourceString.js - represents an string in a resource file\n *\n * Copyright © 2022-2023 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Resource from \"./Resource.js\";\nimport { cleanString } from \"./utils.js\";\nimport log4js from \"@log4js-node/log4js-api\";\n\nconst logger = log4js.getLogger(\"tools-common.ResourceString\");\n\n/**\n * Represents a string resource from a resource file or\n * extracted from the code.\n */\nclass ResourceString extends Resource {\n /**\n * Construct a new ResourceString instance. The props may contain any\n * of properties from the Resource constructor and additionally,\n * these properties:\n *\n * <ul>\n * <li>source {String} - the source string associated with this key\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n */\n constructor(props) {\n super(props);\n\n if (props) {\n this.source = typeof(props.source) === 'string' ? props.source : props.text;\n this.target = props.target;\n }\n\n this.origin = this.origin || \"source\";\n this.datatype = this.datatype || \"plaintext\";\n this.resType = ResourceString.resClass;\n this.sourceLocale = this.sourceLocale || this.project && this.project.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source string written in the source\n * locale of this resource string.\n *\n * @param {String} str the source string\n */\n setSource(str) {\n if (typeof(str) !== 'string') return;\n this.source = str;\n this.dirty = true;\n }\n\n /**\n * Set the target string of this resource.\n *\n * @param {String} str the target string\n */\n setTarget(str) {\n if (typeof(str) !== 'string') return;\n this.target = str;\n this.dirty = true;\n }\n\n /**\n * Return the number of strings in this resource.\n *\n * @returns {number} the number of strings in this resource\n */\n size() {\n return 1;\n }\n\n /**\n * Clone this resource and override the properties with the given ones.\n *\n * @params {Object|undefined} overrides optional properties to override in\n * the cloned object\n * @returns {ResourceArray} a clone of this resource\n */\n clone(overrides) {\n const r = new ResourceString(this);\n if (overrides) {\n for (let p in overrides) {\n r[p] = overrides[p];\n }\n }\n return r;\n }\n\n /**\n * Return true if the other resource contains the exact same resource as\n * the current one. All fields must match.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n equals(other) {\n if (!other || !this.same(other)) return false;\n\n return this.source === other.source;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @static\n * @return {String} a hash key\n */\n static hashKey(project, locale, reskey, datatype, flavor, context) {\n const key = [\"rs\", project, locale, reskey, datatype, flavor, context].join(\"_\");\n logger.trace(\"Hashkey is \" + key);\n return key;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @static\n * @return {String} a hash key\n */\n static cleanHashKey(project, locale, reskey, datatype, flavor, context) {\n const cleaned = reskey && reskey.replace(/\\s+/g, \" \").trim() || \"\";\n const key = [\"rs\", project, locale, cleaned, datatype, flavor, context].join(\"_\");\n logger.trace(\"CleanHashkey is \" + key);\n return key;\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @return {String} a unique hash key for this resource\n */\n hashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale.\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource\n */\n hashKeyForTranslation(locale) {\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but cleaned\n *\n * @return {String} a unique hash key for this resource, but cleaned\n */\n cleanHashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale, but cleaned\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource's string\n */\n cleanHashKeyForTranslation(locale) {\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource.\n *\n * @override\n * @param {Resource} a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (!super.isInstance(resource)) {\n return false;\n }\n\n // now check the properties specific to this resource subclass\n return cleanString(this.source) === cleanString(resource.source);\n }\n}\n\n/**\n * The class of this kind of string resource.\n *\n * @static\n * @const\n */\nResourceString.resClass = \"string\";\n\n\nexport default ResourceString;\n"],"mappings":"kXAmBA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,mBACA,IAAAC,MAAA,CAAAD,OAAA,eACA,IAAAE,UAAA,CAAAH,sBAAA,CAAAC,OAAA,6BAA6C,SAAAD,uBAAAI,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,WAAAE,gBAAAC,CAAA,CAAAC,CAAA,OAAAD,CAAA,YAAAC,CAAA,YAAAC,SAAA,+CAAAC,kBAAAN,CAAA,CAAAO,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAD,CAAA,CAAAE,MAAA,CAAAD,CAAA,QAAAE,CAAA,CAAAH,CAAA,CAAAC,CAAA,EAAAE,CAAA,CAAAC,UAAA,CAAAD,CAAA,CAAAC,UAAA,KAAAD,CAAA,CAAAE,YAAA,cAAAF,CAAA,GAAAA,CAAA,CAAAG,QAAA,KAAAC,MAAA,CAAAC,cAAA,CAAAf,CAAA,CAAAgB,cAAA,CAAAN,CAAA,CAAAO,GAAA,EAAAP,CAAA,YAAAQ,aAAAlB,CAAA,CAAAO,CAAA,CAAAC,CAAA,SAAAD,CAAA,EAAAD,iBAAA,CAAAN,CAAA,CAAAmB,S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ACA;AACA;AACA;AACA;AACA;AACA;AACA,OAZI,GAAAA,GAAA,gBAAA+B,KAAA,CAaA,QAAO,CAAA0C,YAAYA,CAACnB,OAAO,CAAEY,MAAM,CAAEG,MAAM,CAAEnB,QAAQ,CAAEoB,MAAM,CAAEC,OAAO,CAAE,CACpE,GAAM,CAAAS,OAAO,CAAGX,MAAM,EAAIA,MAAM,CAACY,OAAO,CAAC,MAAM,CAAE,GAAG,CAAC,CAACC,IAAI,CAAC,CAAC,EAAI,EAAE,CAClE,GAAM,CAAAlF,GAAG,CAAG,CAAC,IAAI,CAAEsD,OAAO,CAAEY,MAAM,CAAEc,OAAO,CAAE9B,QAAQ,CAAEoB,MAAM,CAAEC,OAAO,CAAC,CAACO,IAAI,CAAC,GAAG,CAAC,CACjFvC,MAAM,CAACwC,KAAK,CAAC,kBAAkB,CAAG/E,GAAG,CAAC,CACtC,MAAO,CAAAA,GACX,CAAC,KA9HwBmF,qBAAQ,EA6LrC;AACA;AACA;AACA;AACA;AACA,GACAzC,cAAc,CAACU,QAAQ,CAAG,QAAQ,CAAC,IAAAgC,QAAA,CAAAC,OAAA,YAGpB3C,cAAc,CAAA4C,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"ResourceString.js","names":["_Resource2","_interopRequireDefault","require","_utils","_log4jsApi","e","__esModule","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","o","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","prototype","i","_toPrimitive","_typeof","Symbol","toPrimitive","call","String","Number","_callSuper","_getPrototypeOf","_possibleConstructorReturn","_isNativeReflectConstruct","Reflect","construct","constructor","apply","_assertThisInitialized","ReferenceError","Boolean","valueOf","_superPropGet","p","_get","get","bind","_superPropBase","getOwnPropertyDescriptor","arguments","value","hasOwnProperty","setPrototypeOf","getPrototypeOf","__proto__","_inherits","create","_setPrototypeOf","logger","log4js","getLogger","ResourceString","_Resource","props","_this","source","text","target","origin","datatype","resType","resClass","sourceLocale","project","setSource","str","dirty","setTarget","size","clone","overrides","equals","other","same","hashKey","locale","targetLocale","getSourceLocale","reskey","flavor","context","sourceHash","hashKeyForTranslation","cleanHashKey","cleanHashKeyForTranslation","isInstance","resource","cleanString","join","trace","cleaned","replace","trim","Resource","_default","exports","module","default"],"sources":["../src/ResourceString.js"],"sourcesContent":["/*\n * ResourceString.js - represents an string in a resource file\n *\n * Copyright © 2022-2023, 2026 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Resource from \"./Resource.js\";\nimport { cleanString } from \"./utils.js\";\nimport log4js from \"@log4js-node/log4js-api\";\n\nconst logger = log4js.getLogger(\"tools-common.ResourceString\");\n\n/**\n * Represents a string resource from a resource file or\n * extracted from the code.\n */\nclass ResourceString extends Resource {\n /**\n * Construct a new ResourceString instance. The props may contain any\n * of properties from the Resource constructor and additionally,\n * these properties:\n *\n * <ul>\n * <li>source {String} - the source string associated with this key\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n */\n constructor(props) {\n super(props);\n\n if (props) {\n this.source = typeof(props.source) === 'string' ? props.source : props.text;\n this.target = props.target;\n }\n\n this.origin = this.origin || \"source\";\n this.datatype = this.datatype || \"plaintext\";\n this.resType = ResourceString.resClass;\n this.sourceLocale = this.sourceLocale || this.project && this.project.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source string written in the source\n * locale of this resource string.\n *\n * @param {String} str the source string\n */\n setSource(str) {\n if (typeof(str) !== 'string') return;\n this.source = str;\n this.dirty = true;\n }\n\n /**\n * Set the target string of this resource.\n *\n * @param {String} str the target string\n */\n setTarget(str) {\n if (typeof(str) !== 'string') return;\n this.target = str;\n this.dirty = true;\n }\n\n /**\n * Return the number of strings in this resource.\n *\n * @returns {number} the number of strings in this resource\n */\n size() {\n return 1;\n }\n\n /**\n * Clone this resource and override the properties with the given ones.\n *\n * @params {Object|undefined} overrides optional properties to override in\n * the cloned object\n * @returns {ResourceArray} a clone of this resource\n */\n clone(overrides) {\n const r = new ResourceString(this);\n if (overrides) {\n for (let p in overrides) {\n r[p] = overrides[p];\n }\n }\n return r;\n }\n\n /**\n * Return true if the other resource contains the exact same resource as\n * the current one. All fields must match.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n equals(other) {\n if (!other || !this.same(other)) return false;\n\n return this.source === other.source;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @param {String} sourceHash the sourceHash of the string\n * @static\n * @return {String} a hash key\n */\n static hashKey(project, locale, reskey, datatype, flavor, context, sourceHash) {\n const key = [\"rs\", project, locale, reskey, datatype, flavor, context, sourceHash].join(\"_\");\n logger.trace(\"Hashkey is \" + key);\n return key;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @param {String} sourceHash the sourceHash of the string\n * @static\n * @return {String} a hash key\n */\n static cleanHashKey(project, locale, reskey, datatype, flavor, context, sourceHash) {\n const cleaned = reskey && reskey.replace(/\\s+/g, \" \").trim() || \"\";\n const key = [\"rs\", project, locale, cleaned, datatype, flavor, context, sourceHash].join(\"_\");\n logger.trace(\"CleanHashkey is \" + key);\n return key;\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @return {String} a unique hash key for this resource\n */\n hashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale.\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource\n */\n hashKeyForTranslation(locale) {\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but cleaned\n *\n * @return {String} a unique hash key for this resource, but cleaned\n */\n cleanHashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale, but cleaned\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource's string\n */\n cleanHashKeyForTranslation(locale) {\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource.\n *\n * @override\n * @param {Resource} a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (!super.isInstance(resource)) {\n return false;\n }\n\n // now check the properties specific to this resource subclass\n return cleanString(this.source) === cleanString(resource.source);\n }\n}\n\n/**\n * The class of this kind of string resource.\n *\n * @static\n * @const\n */\nResourceString.resClass = \"string\";\n\n\nexport default ResourceString;\n"],"mappings":"kXAmBA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,mBACA,IAAAC,MAAA,CAAAD,OAAA,eACA,IAAAE,UAAA,CAAAH,sBAAA,CAAAC,OAAA,6BAA6C,SAAAD,uBAAAI,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAA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,CAAGhF,GAAG,CAAC,CACtC,MAAO,CAAAA,GACX,CAAC,KAhIwBoF,qBAAQ,EA+LrC;AACA;AACA;AACA;AACA;AACA,GACA1C,cAAc,CAACU,QAAQ,CAAG,QAAQ,CAAC,IAAAiC,QAAA,CAAAC,OAAA,YAGpB5C,cAAc,CAAA6C,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _ilibXliff=require("ilib-xliff");var _log4jsApi=_interopRequireDefault(require("@log4js-node/log4js-api"));var _ResourceString=_interopRequireDefault(require("./ResourceString.js"));var _ResourceArray=_interopRequireDefault(require("./ResourceArray.js"));var _ResourcePlural=_interopRequireDefault(require("./ResourcePlural.js"));var _TranslationSet=_interopRequireDefault(require("./TranslationSet.js"));var _Location=_interopRequireDefault(require("./Location.js"));var _utils=require("./utils.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/*
2
- * Xliff.js - convert an Xliff file into a set of resources and vice versa
2
+ * ResourceXliff.js - convert an ResourceXliff file into a set of resources and vice versa
3
3
  *
4
- * Copyright © 2022-2023, 2025 JEDLSoft
4
+ * Copyright © 2022-2023, 2025-2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -42,21 +42,21 @@ return res.comment}}json.pluralForm=form;json.pluralFormOther=res.getKey();retur
42
42
  * @param {string} [options.version] The version of xliff that will be produced by this instance. This
43
43
  * may be either "1.2" or "2.0"
44
44
  * @param {Xliff} [options.xliff] The xliff instance to use for this resource xliff instance.
45
- */function ResourceXliff(options){var _options$xliff;_classCallCheck(this,ResourceXliff);if(options){this["tool-id"]=options["tool-id"];this["tool-name"]=options["tool-name"];this["tool-version"]=options["tool-version"];this["tool-company"]=options["tool-company"];this.copyright=options.copyright;this.path=options.path;this.sourceLocale=options.sourceLocale||"en-US";this.project=options.project;this.allowDups=options.allowDups;this.style=options.style||"standard";if(typeof options.version!=="undefined"){this.version=options.version}}this.sourceLocale=this.sourceLocale||"en-US";this.xliff=(_options$xliff=options===null||options===void 0?void 0:options.xliff)!==null&&_options$xliff!==void 0?_options$xliff:new _ilibXliff.Xliff(options);this.ts=new _TranslationSet["default"](this.sourceLocale)}/**
45
+ */function ResourceXliff(options){var _options$xliff,_this=this;_classCallCheck(this,ResourceXliff);if(options){this["tool-id"]=options["tool-id"];this["tool-name"]=options["tool-name"];this["tool-version"]=options["tool-version"];this["tool-company"]=options["tool-company"];this.copyright=options.copyright;this.path=options.path;this.sourceLocale=options.sourceLocale||"en-US";this.project=options.project;this.allowDups=options.allowDups;this.style=options.style||"standard";if(typeof options.version!=="undefined"){this.version=options.version}}this.sourceLocale=this.sourceLocale||"en-US";this.xliff=(_options$xliff=options===null||options===void 0?void 0:options.xliff)!==null&&_options$xliff!==void 0?_options$xliff:new _ilibXliff.Xliff(options);this.ts=new _TranslationSet["default"](this.sourceLocale);if(this.xliff.getTranslationUnits().length){var translationUnits=this.xliff.getTranslationUnits();translationUnits.forEach(function(tu){_this.ts.add(_this.convertTransUnit(tu))})}}/**
46
46
  * Convert a resource into one or more translation units.
47
47
  *
48
48
  * @private
49
49
  * @param {Resource} res the resource to convert
50
50
  * @returns {Array.<TranslationUnit>} an array of translation units
51
51
  * that represent the resource
52
- */return _createClass(ResourceXliff,[{key:"convertResource",value:function convertResource(res){var units=[],tu;try{switch(res.resType){case"string":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),sourceLocale:res.getSourceLocale(),source:res.getSource(),targetLocale:res.getTargetLocale(),target:res.getTarget(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation()});units.push(tu);break;case"array":var sarr=res.getSource();var tarr=res.getTarget();tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation()});for(var j=0;j<sarr.length;j++){// only output array items that have a translation
53
- if(sarr[j]){var newtu=tu.clone();newtu.source=sarr[j];newtu.ordinal=j;if(tarr&&j<tarr.length&&tarr[j]){newtu.target=tarr[j]}newtu.ordinal=j;units.push(newtu)}else if(tarr[j]){logger.warn("Translated array "+res.getKey()+" has no source string at index "+j+". Cannot translate. Resource is: "+JSON.stringify(res,undefined,4))}}break;case"plural":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,location:res.getLocation(),translate:!res.getDNT()});var sp=res.getSource();var tp=res.getTarget();if(!tp||(0,_utils.isEmpty)(tp)){for(var p in sp){var _newtu=tu.clone();_newtu.source=sp[p];_newtu.quantity=p;_newtu.comment=generatePluralComment(res,sp,p);units.push(_newtu)}}else{for(var _p in tp){var _newtu2=tu.clone();_newtu2.source=sp[_p]||sp.other;_newtu2.target=tp[_p];_newtu2.quantity=_p;_newtu2.comment=generatePluralComment(res,sp,_p);units.push(_newtu2)}}break}}catch(e){logger.warn(e);logger.warn(JSON.stringify(res));logger.warn("Skipping that resource.")}return units}/**
52
+ */return _createClass(ResourceXliff,[{key:"convertResource",value:function convertResource(res){var units=[],tu;try{switch(res.resType){case"string":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),sourceLocale:res.getSourceLocale(),source:res.getSource(),targetLocale:res.getTargetLocale(),target:res.getTarget(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation(),metadata:res.metadata,autoKey:res.getAutoKey()});units.push(tu);break;case"array":var sarr=res.getSource();var tarr=res.getTarget();tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation(),autoKey:res.getAutoKey()});for(var j=0;j<sarr.length;j++){// only output array items that have a translation
53
+ if(sarr[j]){var newtu=tu.clone();newtu.source=sarr[j];newtu.ordinal=j;if(tarr&&j<tarr.length&&tarr[j]){newtu.target=tarr[j]}newtu.ordinal=j;units.push(newtu)}else if(tarr[j]){logger.warn("Translated array "+res.getKey()+" has no source string at index "+j+". Cannot translate. Resource is: "+JSON.stringify(res,undefined,4))}}break;case"plural":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,location:res.getLocation(),translate:!res.getDNT(),autoKey:res.getAutoKey()});var sp=res.getSource();var tp=res.getTarget();if(!tp||(0,_utils.isEmpty)(tp)){for(var p in sp){var _newtu=tu.clone();_newtu.source=sp[p];_newtu.quantity=p;_newtu.comment=generatePluralComment(res,sp,p);units.push(_newtu)}}else{for(var _p in tp){var _newtu2=tu.clone();_newtu2.source=sp[_p]||sp.other;_newtu2.target=tp[_p];_newtu2.quantity=_p;_newtu2.comment=generatePluralComment(res,sp,_p);units.push(_newtu2)}}break}}catch(e){logger.warn(e);logger.warn(JSON.stringify(res));logger.warn("Skipping that resource.")}return units}/**
54
54
  * Convert a translation unit to a new loctool resource.
55
55
  *
56
56
  * @private
57
57
  * @param {TranslationUnit} tu the translation to convert
58
58
  * @return {Resource} the corresponding resource
59
- */},{key:"convertTransUnit",value:function convertTransUnit(tu){var res;switch(tu.resType){default:res=new _ResourceString["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:tu.source,targetLocale:tu.targetLocale,context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.setTarget(tu.target)}break;case"array":var arr=[];arr[tu.ordinal]=tu.source;res=new _ResourceArray["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:arr,targetLocale:tu.targetLocale,target:[],context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetItem(tu.ordinal,tu.target)}break;case"plural":var strings={};strings[tu.quantity]=tu.source;res=new _ResourcePlural["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:strings,targetLocale:tu.targetLocale,target:{},context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetPlural(tu.quantity,tu.target)}break}if(typeof tu.translate==="boolean"){res.setDNT(!tu.translate)}return res}},{key:"getPath",value:function getPath(){return this.path}},{key:"setPath",value:function setPath(newPath){this.path=newPath}/**
59
+ */},{key:"convertTransUnit",value:function convertTransUnit(tu){var res;switch(tu.resType){default:res=new _ResourceString["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:tu.source,targetLocale:tu.targetLocale,context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile,metadata:tu.metadata,sourceHash:tu.sourceHash,autoKey:tu.autoKey});if(tu.target){res.setTarget(tu.target)}break;case"array":var arr=[];arr[tu.ordinal]=tu.source;res=new _ResourceArray["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:arr,targetLocale:tu.targetLocale,target:[],context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetItem(tu.ordinal,tu.target)}break;case"plural":var strings={};strings[tu.quantity]=tu.source;res=new _ResourcePlural["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:strings,targetLocale:tu.targetLocale,target:{},context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetPlural(tu.quantity,tu.target)}break}if(typeof tu.translate==="boolean"){res.setDNT(!tu.translate)}return res}},{key:"getPath",value:function getPath(){return this.path}},{key:"setPath",value:function setPath(newPath){this.path=newPath}/**
60
60
  * Parse the given xml and convert it into a set of resources.
61
61
  *
62
62
  * @param {string} xml the contents of the xliff file to parse