properties-file 3.5.12 → 3.5.13

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.
@@ -1 +1 @@
1
- "use strict";var __extends=this&&this.__extends||function(){var e=function(r,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])},e(r,n)};return function(r,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function t(){this.constructor=r}e(r,n),r.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}}(),__read=this&&this.__read||function(e,r){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var t,i,o=n.call(e),s=[];try{for(;(void 0===r||r-- >0)&&!(t=o.next()).done;)s.push(t.value)}catch(e){i={error:e}}finally{try{t&&!t.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},__spreadArray=this&&this.__spreadArray||function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertiesEditor=exports.DEFAULT_COMMENT_DELIMITER=exports.DEFAULT_SEPARATOR=void 0;var escape_1=require("../escape"),properties_1=require("../properties");exports.DEFAULT_SEPARATOR="=",exports.DEFAULT_COMMENT_DELIMITER="#";var PropertiesEditor=function(e){function r(r){var n=e.call(this,r)||this;return n.needsLineParsing=!1,n}return __extends(r,e),r.prototype.parseLinesIfNeeded=function(){this.needsLineParsing&&(this.parseLines(),this.needsLineParsing=!1)},r.prototype.insert=function(e,r,n){var t,i,o,s=(null==n?void 0:n.escapeUnicode)||!1,a=(null==n?void 0:n.separator)?" "===n.separator?" ":" ".concat(n.separator," "):" ".concat(exports.DEFAULT_SEPARATOR," ").replace(" "," "),c=null==n?void 0:n.referenceKey,l=(null==n?void 0:n.position)||"after";c&&this.parseLinesIfNeeded();var p=e.split(/\r?\n/).map((function(e){return(0,escape_1.escapeKey)(e,s)})).join("\\\n"),d=r.split(/\r?\n/).map((function(e){return(0,escape_1.escapeValue)(e,s)})).join("\\\n"),u="".concat((null==n?void 0:n.commentDelimiter)||exports.DEFAULT_COMMENT_DELIMITER," "),_=void 0===(null==n?void 0:n.comment)?"":"".concat("".concat(u).concat(n.comment).split(/\r?\n/).join("\n".concat(u)),"\n"),v="".concat(_).concat(p).concat(a).concat(d).split(/\n/);if(void 0===c)return(t=this.lines).push.apply(t,__spreadArray([],__read(v),!1)),this.needsLineParsing=!0,!0;var y=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===c}));if(y){var f="after"===l?y.endingLineNumber:null!==(o=null===(i=y.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,f)),!1),__read(v),!1),__read(this.lines.slice(f)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.insertComment=function(e,r){var n,t,i,o=null==r?void 0:r.referenceKey,s=(null==r?void 0:r.position)||"after";o&&this.parseLinesIfNeeded();var a="".concat((null==r?void 0:r.commentDelimiter)||exports.DEFAULT_COMMENT_DELIMITER," "),c="".concat(a).concat(e).replace(/\r?\n/g,"\n".concat(a)).split(/\n/);if(void 0===o)return(n=this.lines).push.apply(n,__spreadArray([],__read(c),!1)),this.needsLineParsing=!0,!0;var l=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===o}));if(l){var p="after"===s?l.endingLineNumber:null!==(i=null===(t=l.previousProperty)||void 0===t?void 0:t.endingLineNumber)&&void 0!==i?i:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,p)),!1),__read(c),!1),__read(this.lines.slice(p)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.delete=function(e,r){var n,t;void 0===r&&(r=!0),this.parseLinesIfNeeded();var i=__spreadArray([],__read(this.collection),!1).reverse().find((function(r){return r.key===e}));if(i){var o=r?null!==(t=null===(n=i.previousProperty)||void 0===n?void 0:n.endingLineNumber)&&void 0!==t?t:0:i.startingLineNumber-1,s=i.endingLineNumber;return this.lines=__spreadArray(__spreadArray([],__read(this.lines.slice(0,o)),!1),__read(this.lines.slice(s)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.getKeyWithNewlines=function(e){return 0===e.newlinePositions.length?e.key:__spreadArray([],__read(e.key),!1).reduce((function(r,n,t){return"".concat(r).concat(e.newlinePositions.includes(t)?"\n":"").concat(n)}),"")},r.prototype.getValueWithNewlines=function(e){return 0===e.newlinePositions.length||void 0===e.valuePosition?e.value:__spreadArray([],__read(e.value),!1).reduce((function(r,n,t){return"".concat(r).concat(e.newlinePositions.includes(t+e.valuePosition)?"\n":"").concat(n)}),"")},r.prototype.update=function(e,r){var n,t,i,o;this.parseLinesIfNeeded();var s=__spreadArray([],__read(this.collection),!1).reverse().find((function(r){return r.key===e}));if(!s||!r)return!1;var a=r.escapeUnicode||!1,c=r.separator?" "===r.separator?" ":" ".concat(r.separator," "):s.separator||" ".concat(exports.DEFAULT_SEPARATOR," ").replace(" "," "),l=(null!==(n=r.newKey)&&void 0!==n?n:this.getKeyWithNewlines(s)).split(/\r?\n/).map((function(e){return(0,escape_1.escapeKey)(e,a)})).join("\\\n"),p=(null!==(t=r.newValue)&&void 0!==t?t:this.getValueWithNewlines(s)).split(/\r?\n/).map((function(e){return(0,escape_1.escapeValue)(e,a)})).join("\\\n"),d="".concat(r.commentDelimiter||exports.DEFAULT_COMMENT_DELIMITER," "),u=void 0===r.newComment?"":"".concat("".concat(d).concat(r.newComment).split(/\r?\n/).join("\n".concat(d)),"\n"),_="".concat(u).concat(l).concat(c).concat(p).split(/\n/);return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,void 0===r.newComment?s.startingLineNumber-1:null!==(o=null===(i=s.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0)),!1),__read(_),!1),__read(this.lines.slice(s.endingLineNumber)),!1),this.needsLineParsing=!0,!0},r.prototype.upsert=function(e,r,n){return this.parseLinesIfNeeded(),this.keyLineNumbers[e]?this.update(e,{newValue:r,newComment:null==n?void 0:n.comment,commentDelimiter:null==n?void 0:n.commentDelimiter,separator:null==n?void 0:n.separator,escapeUnicode:null==n?void 0:n.escapeUnicode}):this.insert(e,r,n)},r}(properties_1.Properties);exports.PropertiesEditor=PropertiesEditor;
1
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(r,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])},e(r,n)};return function(r,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function t(){this.constructor=r}e(r,n),r.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}}(),__read=this&&this.__read||function(e,r){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var t,i,o=n.call(e),s=[];try{for(;(void 0===r||r-- >0)&&!(t=o.next()).done;)s.push(t.value)}catch(e){i={error:e}}finally{try{t&&!t.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},__spreadArray=this&&this.__spreadArray||function(e,r,n){if(n||2===arguments.length)for(var t,i=0,o=r.length;i<o;i++)!t&&i in r||(t||(t=Array.prototype.slice.call(r,0,i)),t[i]=r[i]);return e.concat(t||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertiesEditor=exports.DEFAULT_COMMENT_DELIMITER=exports.DEFAULT_SEPARATOR=void 0;var escape_1=require("../escape"),properties_1=require("../properties");exports.DEFAULT_SEPARATOR="=",exports.DEFAULT_COMMENT_DELIMITER="#";var PropertiesEditor=function(e){function r(r){var n=e.call(this,r)||this;return n.needsLineParsing=!1,n}return __extends(r,e),r.prototype.parseLinesIfNeeded=function(){this.needsLineParsing&&(this.parseLines(),this.needsLineParsing=!1)},r.prototype.insert=function(e,r,n){var t,i,o,s=(null==n?void 0:n.escapeUnicode)||!1,a=(null==n?void 0:n.separator)?" "===n.separator?" ":" ".concat(n.separator," "):" ".concat(exports.DEFAULT_SEPARATOR," ").replace(" "," "),c=null==n?void 0:n.referenceKey,l=(null==n?void 0:n.position)||"after";c&&this.parseLinesIfNeeded();var p=e.split(/\r?\n/).map(function(e){return(0,escape_1.escapeKey)(e,s)}).join("\\\n"),d=r.split(/\r?\n/).map(function(e){return(0,escape_1.escapeValue)(e,s)}).join("\\\n"),u="".concat((null==n?void 0:n.commentDelimiter)||exports.DEFAULT_COMMENT_DELIMITER," "),_=void 0===(null==n?void 0:n.comment)?"":"".concat("".concat(u).concat(n.comment).split(/\r?\n/).join("\n".concat(u)),"\n"),v="".concat(_).concat(p).concat(a).concat(d).split(/\n/);if(void 0===c)return(t=this.lines).push.apply(t,__spreadArray([],__read(v),!1)),this.needsLineParsing=!0,!0;var y=__spreadArray([],__read(this.collection),!1).reverse().find(function(e){return e.key===c});if(y){var f="after"===l?y.endingLineNumber:null!==(o=null===(i=y.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,f)),!1),__read(v),!1),__read(this.lines.slice(f)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.insertComment=function(e,r){var n,t,i,o=null==r?void 0:r.referenceKey,s=(null==r?void 0:r.position)||"after";o&&this.parseLinesIfNeeded();var a="".concat((null==r?void 0:r.commentDelimiter)||exports.DEFAULT_COMMENT_DELIMITER," "),c="".concat(a).concat(e).replace(/\r?\n/g,"\n".concat(a)).split(/\n/);if(void 0===o)return(n=this.lines).push.apply(n,__spreadArray([],__read(c),!1)),this.needsLineParsing=!0,!0;var l=__spreadArray([],__read(this.collection),!1).reverse().find(function(e){return e.key===o});if(l){var p="after"===s?l.endingLineNumber:null!==(i=null===(t=l.previousProperty)||void 0===t?void 0:t.endingLineNumber)&&void 0!==i?i:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,p)),!1),__read(c),!1),__read(this.lines.slice(p)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.delete=function(e,r){var n,t;void 0===r&&(r=!0),this.parseLinesIfNeeded();var i=__spreadArray([],__read(this.collection),!1).reverse().find(function(r){return r.key===e});if(i){var o=r?null!==(t=null===(n=i.previousProperty)||void 0===n?void 0:n.endingLineNumber)&&void 0!==t?t:0:i.startingLineNumber-1,s=i.endingLineNumber;return this.lines=__spreadArray(__spreadArray([],__read(this.lines.slice(0,o)),!1),__read(this.lines.slice(s)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.getKeyWithNewlines=function(e){return 0===e.newlinePositions.length?e.key:__spreadArray([],__read(e.key),!1).reduce(function(r,n,t){return"".concat(r).concat(e.newlinePositions.includes(t)?"\n":"").concat(n)},"")},r.prototype.getValueWithNewlines=function(e){return 0===e.newlinePositions.length||void 0===e.valuePosition?e.value:__spreadArray([],__read(e.value),!1).reduce(function(r,n,t){return"".concat(r).concat(e.newlinePositions.includes(t+e.valuePosition)?"\n":"").concat(n)},"")},r.prototype.update=function(e,r){var n,t,i,o;this.parseLinesIfNeeded();var s=__spreadArray([],__read(this.collection),!1).reverse().find(function(r){return r.key===e});if(!s||!r)return!1;var a=r.escapeUnicode||!1,c=r.separator?" "===r.separator?" ":" ".concat(r.separator," "):s.separator||" ".concat(exports.DEFAULT_SEPARATOR," ").replace(" "," "),l=(null!==(n=r.newKey)&&void 0!==n?n:this.getKeyWithNewlines(s)).split(/\r?\n/).map(function(e){return(0,escape_1.escapeKey)(e,a)}).join("\\\n"),p=(null!==(t=r.newValue)&&void 0!==t?t:this.getValueWithNewlines(s)).split(/\r?\n/).map(function(e){return(0,escape_1.escapeValue)(e,a)}).join("\\\n"),d="".concat(r.commentDelimiter||exports.DEFAULT_COMMENT_DELIMITER," "),u=void 0===r.newComment?"":"".concat("".concat(d).concat(r.newComment).split(/\r?\n/).join("\n".concat(d)),"\n"),_="".concat(u).concat(l).concat(c).concat(p).split(/\n/);return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,void 0===r.newComment?s.startingLineNumber-1:null!==(o=null===(i=s.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0)),!1),__read(_),!1),__read(this.lines.slice(s.endingLineNumber)),!1),this.needsLineParsing=!0,!0},r.prototype.upsert=function(e,r,n){return this.parseLinesIfNeeded(),this.keyLineNumbers[e]?this.update(e,{newValue:r,newComment:null==n?void 0:n.comment,commentDelimiter:null==n?void 0:n.commentDelimiter,separator:null==n?void 0:n.separator,escapeUnicode:null==n?void 0:n.escapeUnicode}):this.insert(e,r,n)},r}(properties_1.Properties);exports.PropertiesEditor=PropertiesEditor;
@@ -1 +1 @@
1
- "use strict";var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.escapeValue=exports.escapeKey=void 0;var escapeKey=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!0,t)};exports.escapeKey=escapeKey;var escapeValue=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!1,t)};exports.escapeValue=escapeValue;var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,escapeContent=function(e,t,a){return e.replace(new RegExp("[\\s!#:=\\\\".concat(a?String.raw(templateObject_1||(templateObject_1=__makeTemplateObject(["\0--￿"],["\\u0000-\\u001F\\u007F-\\uFFFF"]))):"","]"),"g"),(function(e,a){switch(e){case" ":return t||0===a?String.raw(templateObject_2||(templateObject_2=__makeTemplateObject([" "],["\\ "]))):" ";case"\\":return"\\\\";case"\f":return String.raw(templateObject_3||(templateObject_3=__makeTemplateObject(["\f"],["\\f"])));case"\n":return String.raw(templateObject_4||(templateObject_4=__makeTemplateObject(["\n"],["\\n"])));case"\r":return String.raw(templateObject_5||(templateObject_5=__makeTemplateObject(["\r"],["\\r"])));case"\t":return String.raw(templateObject_6||(templateObject_6=__makeTemplateObject(["\t"],["\\t"])));case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u".concat(e.codePointAt(0).toString(16).padStart(4,"0"))}}))};
1
+ "use strict";var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.escapeValue=exports.escapeKey=void 0;var escapeKey=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!0,t)};exports.escapeKey=escapeKey;var escapeValue=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!1,t)};exports.escapeValue=escapeValue;var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,escapeContent=function(e,t,a){return e.replace(new RegExp("[\\s!#:=\\\\".concat(a?String.raw(templateObject_1||(templateObject_1=__makeTemplateObject(["\0--￿"],["\\u0000-\\u001F\\u007F-\\uFFFF"]))):"","]"),"g"),function(e,a){switch(e){case" ":return t||0===a?String.raw(templateObject_2||(templateObject_2=__makeTemplateObject([" "],["\\ "]))):" ";case"\\":return"\\\\";case"\f":return String.raw(templateObject_3||(templateObject_3=__makeTemplateObject(["\f"],["\\f"])));case"\n":return String.raw(templateObject_4||(templateObject_4=__makeTemplateObject(["\n"],["\\n"])));case"\r":return String.raw(templateObject_5||(templateObject_5=__makeTemplateObject(["\r"],["\\r"])));case"\t":return String.raw(templateObject_6||(templateObject_6=__makeTemplateObject(["\t"],["\\t"])));case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u".concat(e.codePointAt(0).toString(16).padStart(4,"0"))}})};
@@ -1 +1 @@
1
- "use strict";var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,i,n=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.KeyCollisions=exports.Properties=exports.getFirstEolCharacter=exports.DEFAULT_END_OF_LINE_CHARACTER=exports.BOM_CODE_POINT=exports.BOM=void 0;var property_1=require("./property"),property_line_1=require("./property-line");exports.BOM="\ufeff",exports.BOM_CODE_POINT=exports.BOM.codePointAt(0),exports.DEFAULT_END_OF_LINE_CHARACTER="\n";var getFirstEolCharacter=function(e){var t=e.indexOf("\n");return-1===t?void 0:"".concat("\r"===e[t-1]?"\r":"","\n")};exports.getFirstEolCharacter=getFirstEolCharacter;var Properties=function(){function e(e){var t;this.collection=[],this.keyLineNumbers={};var r="string"==typeof e?e:e.toString();this.hasBom=r.codePointAt(0)===exports.BOM_CODE_POINT,this.eolCharacter=null!==(t=(0,exports.getFirstEolCharacter)(r))&&void 0!==t?t:exports.DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?r.slice(1):r).split(/\r?\n/),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,o,i=0;try{for(var n=__values(this.lines),s=n.next();!s.done;s=n.next()){var l=s.value;i++;var a=new property_line_1.PropertyLine(l,!!r);if(r){if(r.addLine(a),a.isContinuing)continue}else{if(a.isComment||a.isBlank)continue;if(r=new property_1.Property(a,i,o),a.isContinuing)continue}this.addToCollection(r),o=r,r=void 0}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e.prototype.addToCollection=function(e){var t;e.setKeyAndValue(),(null===(t=this.keyLineNumbers[e.key])||void 0===t?void 0:t.length)?(this.keyLineNumbers[e.key].push(e.startingLineNumber),e.hasKeyCollisions=!0,e.keyCollisionLines=this.keyLineNumbers[e.key],this.collection=this.collection.filter((function(t){return t.key!==e.key}))):this.keyLineNumbers[e.key]=[e.startingLineNumber],this.collection.push(e)},e.prototype.getKeyCollisions=function(){var e,t,r=[];try{for(var o=__values(Object.entries(this.keyLineNumbers)),i=o.next();!i.done;i=o.next()){var n=__read(i.value,2),s=n[0],l=n[1];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(){var e={};return this.collection.forEach((function(t){e[t.key]=t.value})),e},e.prototype.format=function(e){return"".concat(this.hasBom?exports.BOM:"").concat(this.lines.join(e||this.eolCharacter))},e}();exports.Properties=Properties;var KeyCollisions=function(){function e(e,t){this.key=e,this.startingLineNumbers=t}return e.prototype.getApplicableLineNumber=function(){return this.startingLineNumbers.slice(-1)[0]},e}();exports.KeyCollisions=KeyCollisions;
1
+ "use strict";var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,i,n=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.KeyCollisions=exports.Properties=exports.getFirstEolCharacter=exports.DEFAULT_END_OF_LINE_CHARACTER=exports.BOM_CODE_POINT=exports.BOM=void 0;var property_1=require("./property"),property_line_1=require("./property-line");exports.BOM="\ufeff",exports.BOM_CODE_POINT=exports.BOM.codePointAt(0),exports.DEFAULT_END_OF_LINE_CHARACTER="\n";var getFirstEolCharacter=function(e){var t=e.indexOf("\n");return-1===t?void 0:"".concat("\r"===e[t-1]?"\r":"","\n")};exports.getFirstEolCharacter=getFirstEolCharacter;var Properties=function(){function e(e){var t;this.collection=[],this.keyLineNumbers={};var r="string"==typeof e?e:e.toString();this.hasBom=r.codePointAt(0)===exports.BOM_CODE_POINT,this.eolCharacter=null!==(t=(0,exports.getFirstEolCharacter)(r))&&void 0!==t?t:exports.DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?r.slice(1):r).split(/\r?\n/),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,o,i=0;try{for(var n=__values(this.lines),s=n.next();!s.done;s=n.next()){var l=s.value;i++;var a=new property_line_1.PropertyLine(l,!!r);if(r){if(r.addLine(a),a.isContinuing)continue}else{if(a.isComment||a.isBlank)continue;if(r=new property_1.Property(a,i,o),a.isContinuing)continue}this.addToCollection(r),o=r,r=void 0}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e.prototype.addToCollection=function(e){var t;e.setKeyAndValue(),(null===(t=this.keyLineNumbers[e.key])||void 0===t?void 0:t.length)?(this.keyLineNumbers[e.key].push(e.startingLineNumber),e.hasKeyCollisions=!0,e.keyCollisionLines=this.keyLineNumbers[e.key],this.collection=this.collection.filter(function(t){return t.key!==e.key})):this.keyLineNumbers[e.key]=[e.startingLineNumber],this.collection.push(e)},e.prototype.getKeyCollisions=function(){var e,t,r=[];try{for(var o=__values(Object.entries(this.keyLineNumbers)),i=o.next();!i.done;i=o.next()){var n=__read(i.value,2),s=n[0],l=n[1];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(){var e={};return this.collection.forEach(function(t){e[t.key]=t.value}),e},e.prototype.format=function(e){return"".concat(this.hasBom?exports.BOM:"").concat(this.lines.join(e||this.eolCharacter))},e}();exports.Properties=Properties;var KeyCollisions=function(){function e(e,t){this.key=e,this.startingLineNumbers=t}return e.prototype.getApplicableLineNumber=function(){return this.startingLineNumbers.slice(-1)[0]},e}();exports.KeyCollisions=KeyCollisions;
@@ -29,8 +29,6 @@ export declare class Property {
29
29
  valuePosition: number | undefined;
30
30
  /** The property value, including its escaped characters. */
31
31
  escapedValue: string;
32
- /** Is the value empty? */
33
- private hasNoValue;
34
32
  /** Positions of the newline characters if any. */
35
33
  newlinePositions: number[];
36
34
  /** The line number at which the property starts. */
@@ -1 +1 @@
1
- "use strict";var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Property=void 0;var unescape_1=require("./unescape"),Property=function(){function t(t,e,i){this.key="",this.escapedKey="",this.hasNoKey=!1,this.hasMultilineKey=!1,this.keyCollisionLines=[],this.hasKeyCollisions=!1,this.value="",this.escapedValue="",this.hasNoValue=!1,this.newlinePositions=[],this.linesContent=t.content,this.startingLineNumber=e,this.endingLineNumber=e,this.previousProperty=i,null==i||i.setNextProperty(this)}return t.prototype.setNextProperty=function(t){this.nextProperty=t},t.prototype.addLine=function(t){this.linesContent.length>0&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=t.content},t.prototype.setKeyAndValue=function(){this.findSeparator(),void 0!==this.separatorPosition&&void 0!==this.separatorLength?(this.hasNoKey||(this.escapedKey=this.linesContent.slice(0,this.separatorPosition),this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber)),this.hasNoValue||(this.escapedValue=this.linesContent.slice(this.separatorPosition+this.separatorLength),this.value=this.unescapeLine(this.escapedValue,this.startingLineNumber))):this.hasNoValue&&(this.escapedKey=this.linesContent,this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber))},t.prototype.unescapeLine=function(t,e){try{return(0,unescape_1.unescapeContent)(t)}catch(t){throw new Error("".concat(t.message," in property starting at line ").concat(e))}},t.prototype.findSeparator=function(){var t,e;if(!(this.hasNoKey||this.hasNoValue||this.separatorPosition)){try{for(var i=__values(this.linesContent.matchAll(/[\t\f :=]/g)),s=i.next();!s.done;s=i.next()){var n=s.value.index,o=this.linesContent.slice(0,n).match(/(\\+)$/);if(o)if(!!(o[1].length%2))continue;var r="";this.separatorPosition=n;var a=this.linesContent.slice(n),h=(a.match(/^([\t\n\v\f\r ]+)/)||[""])[0];h.length>0&&(r+=h,a=a.slice(h.length)),/[:=]/.test(a[0])&&(r+=a[0],r+=((a=a.slice(1)).match(/^([\t\n\v\f\r ]+)/)||[""])[0]),this.separatorLength=r.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),n||(this.hasNoKey=!0);break}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}void 0===this.separatorPosition?this.hasNoValue=!0:this.newlinePositions.length>0&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}},t}();exports.Property=Property;
1
+ "use strict";var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Property=void 0;var unescape_1=require("./unescape"),Property=function(){function t(t,e,i){this.key="",this.escapedKey="",this.hasNoKey=!1,this.hasMultilineKey=!1,this.keyCollisionLines=[],this.hasKeyCollisions=!1,this.value="",this.escapedValue="",this.newlinePositions=[],this.linesContent=t.content,this.startingLineNumber=e,this.endingLineNumber=e,this.previousProperty=i,null==i||i.setNextProperty(this)}return t.prototype.setNextProperty=function(t){this.nextProperty=t},t.prototype.addLine=function(t){this.linesContent.length>0&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=t.content},t.prototype.setKeyAndValue=function(){this.findSeparator(),void 0!==this.separatorPosition&&void 0!==this.separatorLength?(this.hasNoKey||(this.escapedKey=this.linesContent.slice(0,this.separatorPosition),this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber)),this.escapedValue=this.linesContent.slice(this.separatorPosition+this.separatorLength),this.value=this.unescapeLine(this.escapedValue,this.startingLineNumber)):(this.escapedKey=this.linesContent,this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber))},t.prototype.unescapeLine=function(t,e){try{return(0,unescape_1.unescapeContent)(t)}catch(t){throw new Error("".concat(t.message," in property starting at line ").concat(e))}},t.prototype.findSeparator=function(){var t,e;if(!this.hasNoKey&&!this.separator){try{for(var i=__values(this.linesContent.matchAll(/[\t\f :=]/g)),s=i.next();!s.done;s=i.next()){var n=s.value.index,o=this.linesContent.slice(0,n).match(/(\\+)$/);if(o)if(!!(o[1].length%2))continue;var r="";this.separatorPosition=n;var a=this.linesContent.slice(n),h=(a.match(/^([\t\n\v\f\r ]+)/)||[""])[0];h.length>0&&(r+=h,a=a.slice(h.length)),/[:=]/.test(a[0])&&(r+=a[0],r+=((a=a.slice(1)).match(/^([\t\n\v\f\r ]+)/)||[""])[0]),this.separatorLength=r.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),n||(this.hasNoKey=!0);break}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}void 0!==this.separatorPosition&&this.newlinePositions.length>0&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}},t}();exports.Property=Property;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unescapeContent=void 0;var unescapeContent=function(e){return e.replace(/\\[^u]|\\u.{4}/g,(function(e){var r=e.charAt(1);switch(r){case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"u":var t=e.slice(2,6);if(!/[\da-f]{4}/i.test(t))throw new Error("malformed escaped unicode characters '\\u".concat(t,"'"));return String.fromCodePoint(Number.parseInt(t,16));default:return r}}))};exports.unescapeContent=unescapeContent;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unescapeContent=void 0;var unescapeContent=function(e){return e.replace(/\\[^u]|\\u.{4}/g,function(e){var r=e.charAt(1);switch(r){case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"u":var t=e.slice(2,6);if(!/[\da-f]{4}/i.test(t))throw new Error("malformed escaped unicode characters '\\u".concat(t,"'"));return String.fromCodePoint(Number.parseInt(t,16));default:return r}})};exports.unescapeContent=unescapeContent;
@@ -1 +1 @@
1
- var __extends=this&&this.__extends||function(){var e=function(n,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},e(n,r)};return function(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function t(){this.constructor=n}e(n,r),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}}(),__read=this&&this.__read||function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,i,o=r.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(t=o.next()).done;)a.push(t.value)}catch(e){i={error:e}}finally{try{t&&!t.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},__spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||2===arguments.length)for(var t,i=0,o=n.length;i<o;i++)!t&&i in n||(t||(t=Array.prototype.slice.call(n,0,i)),t[i]=n[i]);return e.concat(t||Array.prototype.slice.call(n))};import{escapeKey,escapeValue}from"../escape/index.js";import{Properties}from"../properties.js";export var DEFAULT_SEPARATOR="=";export var DEFAULT_COMMENT_DELIMITER="#";var PropertiesEditor=function(e){function n(n){var r=e.call(this,n)||this;return r.needsLineParsing=!1,r}return __extends(n,e),n.prototype.parseLinesIfNeeded=function(){this.needsLineParsing&&(this.parseLines(),this.needsLineParsing=!1)},n.prototype.insert=function(e,n,r){var t,i,o,a=(null==r?void 0:r.escapeUnicode)||!1,s=(null==r?void 0:r.separator)?" "===r.separator?" ":" ".concat(r.separator," "):" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),c=null==r?void 0:r.referenceKey,l=(null==r?void 0:r.position)||"after";c&&this.parseLinesIfNeeded();var d=e.split(/\r?\n/).map((function(e){return escapeKey(e,a)})).join("\\\n"),p=n.split(/\r?\n/).map((function(e){return escapeValue(e,a)})).join("\\\n"),u="".concat((null==r?void 0:r.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),_=void 0===(null==r?void 0:r.comment)?"":"".concat("".concat(u).concat(r.comment).split(/\r?\n/).join("\n".concat(u)),"\n"),v="".concat(_).concat(d).concat(s).concat(p).split(/\n/);if(void 0===c)return(t=this.lines).push.apply(t,__spreadArray([],__read(v),!1)),this.needsLineParsing=!0,!0;var y=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===c}));if(y){var f="after"===l?y.endingLineNumber:null!==(o=null===(i=y.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,f)),!1),__read(v),!1),__read(this.lines.slice(f)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.insertComment=function(e,n){var r,t,i,o=null==n?void 0:n.referenceKey,a=(null==n?void 0:n.position)||"after";o&&this.parseLinesIfNeeded();var s="".concat((null==n?void 0:n.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),c="".concat(s).concat(e).replace(/\r?\n/g,"\n".concat(s)).split(/\n/);if(void 0===o)return(r=this.lines).push.apply(r,__spreadArray([],__read(c),!1)),this.needsLineParsing=!0,!0;var l=__spreadArray([],__read(this.collection),!1).reverse().find((function(e){return e.key===o}));if(l){var d="after"===a?l.endingLineNumber:null!==(i=null===(t=l.previousProperty)||void 0===t?void 0:t.endingLineNumber)&&void 0!==i?i:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,d)),!1),__read(c),!1),__read(this.lines.slice(d)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.delete=function(e,n){var r,t;void 0===n&&(n=!0),this.parseLinesIfNeeded();var i=__spreadArray([],__read(this.collection),!1).reverse().find((function(n){return n.key===e}));if(i){var o=n?null!==(t=null===(r=i.previousProperty)||void 0===r?void 0:r.endingLineNumber)&&void 0!==t?t:0:i.startingLineNumber-1,a=i.endingLineNumber;return this.lines=__spreadArray(__spreadArray([],__read(this.lines.slice(0,o)),!1),__read(this.lines.slice(a)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.getKeyWithNewlines=function(e){return 0===e.newlinePositions.length?e.key:__spreadArray([],__read(e.key),!1).reduce((function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t)?"\n":"").concat(r)}),"")},n.prototype.getValueWithNewlines=function(e){return 0===e.newlinePositions.length||void 0===e.valuePosition?e.value:__spreadArray([],__read(e.value),!1).reduce((function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t+e.valuePosition)?"\n":"").concat(r)}),"")},n.prototype.update=function(e,n){var r,t,i,o;this.parseLinesIfNeeded();var a=__spreadArray([],__read(this.collection),!1).reverse().find((function(n){return n.key===e}));if(!a||!n)return!1;var s=n.escapeUnicode||!1,c=n.separator?" "===n.separator?" ":" ".concat(n.separator," "):a.separator||" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),l=(null!==(r=n.newKey)&&void 0!==r?r:this.getKeyWithNewlines(a)).split(/\r?\n/).map((function(e){return escapeKey(e,s)})).join("\\\n"),d=(null!==(t=n.newValue)&&void 0!==t?t:this.getValueWithNewlines(a)).split(/\r?\n/).map((function(e){return escapeValue(e,s)})).join("\\\n"),p="".concat(n.commentDelimiter||DEFAULT_COMMENT_DELIMITER," "),u=void 0===n.newComment?"":"".concat("".concat(p).concat(n.newComment).split(/\r?\n/).join("\n".concat(p)),"\n"),_="".concat(u).concat(l).concat(c).concat(d).split(/\n/);return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,void 0===n.newComment?a.startingLineNumber-1:null!==(o=null===(i=a.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0)),!1),__read(_),!1),__read(this.lines.slice(a.endingLineNumber)),!1),this.needsLineParsing=!0,!0},n.prototype.upsert=function(e,n,r){return this.parseLinesIfNeeded(),this.keyLineNumbers[e]?this.update(e,{newValue:n,newComment:null==r?void 0:r.comment,commentDelimiter:null==r?void 0:r.commentDelimiter,separator:null==r?void 0:r.separator,escapeUnicode:null==r?void 0:r.escapeUnicode}):this.insert(e,n,r)},n}(Properties);export{PropertiesEditor};
1
+ var __extends=this&&this.__extends||function(){var e=function(n,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},e(n,r)};return function(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function t(){this.constructor=n}e(n,r),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}}(),__read=this&&this.__read||function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,i,o=r.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(t=o.next()).done;)a.push(t.value)}catch(e){i={error:e}}finally{try{t&&!t.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},__spreadArray=this&&this.__spreadArray||function(e,n,r){if(r||2===arguments.length)for(var t,i=0,o=n.length;i<o;i++)!t&&i in n||(t||(t=Array.prototype.slice.call(n,0,i)),t[i]=n[i]);return e.concat(t||Array.prototype.slice.call(n))};import{escapeKey,escapeValue}from"../escape/index.js";import{Properties}from"../properties.js";export var DEFAULT_SEPARATOR="=";export var DEFAULT_COMMENT_DELIMITER="#";var PropertiesEditor=function(e){function n(n){var r=e.call(this,n)||this;return r.needsLineParsing=!1,r}return __extends(n,e),n.prototype.parseLinesIfNeeded=function(){this.needsLineParsing&&(this.parseLines(),this.needsLineParsing=!1)},n.prototype.insert=function(e,n,r){var t,i,o,a=(null==r?void 0:r.escapeUnicode)||!1,s=(null==r?void 0:r.separator)?" "===r.separator?" ":" ".concat(r.separator," "):" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),c=null==r?void 0:r.referenceKey,l=(null==r?void 0:r.position)||"after";c&&this.parseLinesIfNeeded();var d=e.split(/\r?\n/).map(function(e){return escapeKey(e,a)}).join("\\\n"),p=n.split(/\r?\n/).map(function(e){return escapeValue(e,a)}).join("\\\n"),u="".concat((null==r?void 0:r.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),_=void 0===(null==r?void 0:r.comment)?"":"".concat("".concat(u).concat(r.comment).split(/\r?\n/).join("\n".concat(u)),"\n"),v="".concat(_).concat(d).concat(s).concat(p).split(/\n/);if(void 0===c)return(t=this.lines).push.apply(t,__spreadArray([],__read(v),!1)),this.needsLineParsing=!0,!0;var y=__spreadArray([],__read(this.collection),!1).reverse().find(function(e){return e.key===c});if(y){var f="after"===l?y.endingLineNumber:null!==(o=null===(i=y.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,f)),!1),__read(v),!1),__read(this.lines.slice(f)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.insertComment=function(e,n){var r,t,i,o=null==n?void 0:n.referenceKey,a=(null==n?void 0:n.position)||"after";o&&this.parseLinesIfNeeded();var s="".concat((null==n?void 0:n.commentDelimiter)||DEFAULT_COMMENT_DELIMITER," "),c="".concat(s).concat(e).replace(/\r?\n/g,"\n".concat(s)).split(/\n/);if(void 0===o)return(r=this.lines).push.apply(r,__spreadArray([],__read(c),!1)),this.needsLineParsing=!0,!0;var l=__spreadArray([],__read(this.collection),!1).reverse().find(function(e){return e.key===o});if(l){var d="after"===a?l.endingLineNumber:null!==(i=null===(t=l.previousProperty)||void 0===t?void 0:t.endingLineNumber)&&void 0!==i?i:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,d)),!1),__read(c),!1),__read(this.lines.slice(d)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.delete=function(e,n){var r,t;void 0===n&&(n=!0),this.parseLinesIfNeeded();var i=__spreadArray([],__read(this.collection),!1).reverse().find(function(n){return n.key===e});if(i){var o=n?null!==(t=null===(r=i.previousProperty)||void 0===r?void 0:r.endingLineNumber)&&void 0!==t?t:0:i.startingLineNumber-1,a=i.endingLineNumber;return this.lines=__spreadArray(__spreadArray([],__read(this.lines.slice(0,o)),!1),__read(this.lines.slice(a)),!1),this.needsLineParsing=!0,!0}return!1},n.prototype.getKeyWithNewlines=function(e){return 0===e.newlinePositions.length?e.key:__spreadArray([],__read(e.key),!1).reduce(function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t)?"\n":"").concat(r)},"")},n.prototype.getValueWithNewlines=function(e){return 0===e.newlinePositions.length||void 0===e.valuePosition?e.value:__spreadArray([],__read(e.value),!1).reduce(function(n,r,t){return"".concat(n).concat(e.newlinePositions.includes(t+e.valuePosition)?"\n":"").concat(r)},"")},n.prototype.update=function(e,n){var r,t,i,o;this.parseLinesIfNeeded();var a=__spreadArray([],__read(this.collection),!1).reverse().find(function(n){return n.key===e});if(!a||!n)return!1;var s=n.escapeUnicode||!1,c=n.separator?" "===n.separator?" ":" ".concat(n.separator," "):a.separator||" ".concat(DEFAULT_SEPARATOR," ").replace(" "," "),l=(null!==(r=n.newKey)&&void 0!==r?r:this.getKeyWithNewlines(a)).split(/\r?\n/).map(function(e){return escapeKey(e,s)}).join("\\\n"),d=(null!==(t=n.newValue)&&void 0!==t?t:this.getValueWithNewlines(a)).split(/\r?\n/).map(function(e){return escapeValue(e,s)}).join("\\\n"),p="".concat(n.commentDelimiter||DEFAULT_COMMENT_DELIMITER," "),u=void 0===n.newComment?"":"".concat("".concat(p).concat(n.newComment).split(/\r?\n/).join("\n".concat(p)),"\n"),_="".concat(u).concat(l).concat(c).concat(d).split(/\n/);return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,void 0===n.newComment?a.startingLineNumber-1:null!==(o=null===(i=a.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0)),!1),__read(_),!1),__read(this.lines.slice(a.endingLineNumber)),!1),this.needsLineParsing=!0,!0},n.prototype.upsert=function(e,n,r){return this.parseLinesIfNeeded(),this.keyLineNumbers[e]?this.update(e,{newValue:n,newComment:null==r?void 0:r.comment,commentDelimiter:null==r?void 0:r.commentDelimiter,separator:null==r?void 0:r.separator,escapeUnicode:null==r?void 0:r.escapeUnicode}):this.insert(e,n,r)},n}(Properties);export{PropertiesEditor};
@@ -1 +1 @@
1
- var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e};export var escapeKey=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!0,t)};export var escapeValue=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!1,t)};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,escapeContent=function(e,t,a){return e.replace(new RegExp("[\\s!#:=\\\\".concat(a?String.raw(templateObject_1||(templateObject_1=__makeTemplateObject(["\0--￿"],["\\u0000-\\u001F\\u007F-\\uFFFF"]))):"","]"),"g"),(function(e,a){switch(e){case" ":return t||0===a?String.raw(templateObject_2||(templateObject_2=__makeTemplateObject([" "],["\\ "]))):" ";case"\\":return"\\\\";case"\f":return String.raw(templateObject_3||(templateObject_3=__makeTemplateObject(["\f"],["\\f"])));case"\n":return String.raw(templateObject_4||(templateObject_4=__makeTemplateObject(["\n"],["\\n"])));case"\r":return String.raw(templateObject_5||(templateObject_5=__makeTemplateObject(["\r"],["\\r"])));case"\t":return String.raw(templateObject_6||(templateObject_6=__makeTemplateObject(["\t"],["\\t"])));case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u".concat(e.codePointAt(0).toString(16).padStart(4,"0"))}}))};
1
+ var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e};export var escapeKey=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!0,t)};export var escapeValue=function(e,t){return void 0===t&&(t=!1),escapeContent(e,!1,t)};var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,escapeContent=function(e,t,a){return e.replace(new RegExp("[\\s!#:=\\\\".concat(a?String.raw(templateObject_1||(templateObject_1=__makeTemplateObject(["\0--￿"],["\\u0000-\\u001F\\u007F-\\uFFFF"]))):"","]"),"g"),function(e,a){switch(e){case" ":return t||0===a?String.raw(templateObject_2||(templateObject_2=__makeTemplateObject([" "],["\\ "]))):" ";case"\\":return"\\\\";case"\f":return String.raw(templateObject_3||(templateObject_3=__makeTemplateObject(["\f"],["\\f"])));case"\n":return String.raw(templateObject_4||(templateObject_4=__makeTemplateObject(["\n"],["\\n"])));case"\r":return String.raw(templateObject_5||(templateObject_5=__makeTemplateObject(["\r"],["\\r"])));case"\t":return String.raw(templateObject_6||(templateObject_6=__makeTemplateObject(["\t"],["\\t"])));case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u".concat(e.codePointAt(0).toString(16).padStart(4,"0"))}})};
@@ -1 +1 @@
1
- var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};import{Property}from"./property.js";import{PropertyLine}from"./property-line.js";export var BOM="\ufeff";export var BOM_CODE_POINT=BOM.codePointAt(0);export var DEFAULT_END_OF_LINE_CHARACTER="\n";export var getFirstEolCharacter=function(e){var t=e.indexOf("\n");return-1===t?void 0:"".concat("\r"===e[t-1]?"\r":"","\n")};var Properties=function(){function e(e){var t;this.collection=[],this.keyLineNumbers={};var r="string"==typeof e?e:e.toString();this.hasBom=r.codePointAt(0)===BOM_CODE_POINT,this.eolCharacter=null!==(t=getFirstEolCharacter(r))&&void 0!==t?t:DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?r.slice(1):r).split(/\r?\n/),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,n,i=0;try{for(var o=__values(this.lines),s=o.next();!s.done;s=o.next()){var l=s.value;i++;var a=new PropertyLine(l,!!r);if(r){if(r.addLine(a),a.isContinuing)continue}else{if(a.isComment||a.isBlank)continue;if(r=new Property(a,i,n),a.isContinuing)continue}this.addToCollection(r),n=r,r=void 0}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},e.prototype.addToCollection=function(e){var t;e.setKeyAndValue(),(null===(t=this.keyLineNumbers[e.key])||void 0===t?void 0:t.length)?(this.keyLineNumbers[e.key].push(e.startingLineNumber),e.hasKeyCollisions=!0,e.keyCollisionLines=this.keyLineNumbers[e.key],this.collection=this.collection.filter((function(t){return t.key!==e.key}))):this.keyLineNumbers[e.key]=[e.startingLineNumber],this.collection.push(e)},e.prototype.getKeyCollisions=function(){var e,t,r=[];try{for(var n=__values(Object.entries(this.keyLineNumbers)),i=n.next();!i.done;i=n.next()){var o=__read(i.value,2),s=o[0],l=o[1];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(){var e={};return this.collection.forEach((function(t){e[t.key]=t.value})),e},e.prototype.format=function(e){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(e||this.eolCharacter))},e}();export{Properties};var KeyCollisions=function(){function e(e,t){this.key=e,this.startingLineNumbers=t}return e.prototype.getApplicableLineNumber=function(){return this.startingLineNumbers.slice(-1)[0]},e}();export{KeyCollisions};
1
+ var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};import{Property}from"./property.js";import{PropertyLine}from"./property-line.js";export var BOM="\ufeff";export var BOM_CODE_POINT=BOM.codePointAt(0);export var DEFAULT_END_OF_LINE_CHARACTER="\n";export var getFirstEolCharacter=function(e){var t=e.indexOf("\n");return-1===t?void 0:"".concat("\r"===e[t-1]?"\r":"","\n")};var Properties=function(){function e(e){var t;this.collection=[],this.keyLineNumbers={};var r="string"==typeof e?e:e.toString();this.hasBom=r.codePointAt(0)===BOM_CODE_POINT,this.eolCharacter=null!==(t=getFirstEolCharacter(r))&&void 0!==t?t:DEFAULT_END_OF_LINE_CHARACTER,this.lines=(this.hasBom?r.slice(1):r).split(/\r?\n/),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,n,i=0;try{for(var o=__values(this.lines),s=o.next();!s.done;s=o.next()){var l=s.value;i++;var a=new PropertyLine(l,!!r);if(r){if(r.addLine(a),a.isContinuing)continue}else{if(a.isComment||a.isBlank)continue;if(r=new Property(a,i,n),a.isContinuing)continue}this.addToCollection(r),n=r,r=void 0}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}},e.prototype.addToCollection=function(e){var t;e.setKeyAndValue(),(null===(t=this.keyLineNumbers[e.key])||void 0===t?void 0:t.length)?(this.keyLineNumbers[e.key].push(e.startingLineNumber),e.hasKeyCollisions=!0,e.keyCollisionLines=this.keyLineNumbers[e.key],this.collection=this.collection.filter(function(t){return t.key!==e.key})):this.keyLineNumbers[e.key]=[e.startingLineNumber],this.collection.push(e)},e.prototype.getKeyCollisions=function(){var e,t,r=[];try{for(var n=__values(Object.entries(this.keyLineNumbers)),i=n.next();!i.done;i=n.next()){var o=__read(i.value,2),s=o[0],l=o[1];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(){var e={};return this.collection.forEach(function(t){e[t.key]=t.value}),e},e.prototype.format=function(e){return"".concat(this.hasBom?BOM:"").concat(this.lines.join(e||this.eolCharacter))},e}();export{Properties};var KeyCollisions=function(){function e(e,t){this.key=e,this.startingLineNumbers=t}return e.prototype.getApplicableLineNumber=function(){return this.startingLineNumbers.slice(-1)[0]},e}();export{KeyCollisions};
@@ -29,8 +29,6 @@ export declare class Property {
29
29
  valuePosition: number | undefined;
30
30
  /** The property value, including its escaped characters. */
31
31
  escapedValue: string;
32
- /** Is the value empty? */
33
- private hasNoValue;
34
32
  /** Positions of the newline characters if any. */
35
33
  newlinePositions: number[];
36
34
  /** The line number at which the property starts. */
@@ -1 +1 @@
1
- var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};import{unescapeContent}from"./unescape/index.js";var Property=function(){function t(t,e,i){this.key="",this.escapedKey="",this.hasNoKey=!1,this.hasMultilineKey=!1,this.keyCollisionLines=[],this.hasKeyCollisions=!1,this.value="",this.escapedValue="",this.hasNoValue=!1,this.newlinePositions=[],this.linesContent=t.content,this.startingLineNumber=e,this.endingLineNumber=e,this.previousProperty=i,null==i||i.setNextProperty(this)}return t.prototype.setNextProperty=function(t){this.nextProperty=t},t.prototype.addLine=function(t){this.linesContent.length>0&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=t.content},t.prototype.setKeyAndValue=function(){this.findSeparator(),void 0!==this.separatorPosition&&void 0!==this.separatorLength?(this.hasNoKey||(this.escapedKey=this.linesContent.slice(0,this.separatorPosition),this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber)),this.hasNoValue||(this.escapedValue=this.linesContent.slice(this.separatorPosition+this.separatorLength),this.value=this.unescapeLine(this.escapedValue,this.startingLineNumber))):this.hasNoValue&&(this.escapedKey=this.linesContent,this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber))},t.prototype.unescapeLine=function(t,e){try{return unescapeContent(t)}catch(t){throw new Error("".concat(t.message," in property starting at line ").concat(e))}},t.prototype.findSeparator=function(){var t,e;if(!(this.hasNoKey||this.hasNoValue||this.separatorPosition)){try{for(var i=__values(this.linesContent.matchAll(/[\t\f :=]/g)),s=i.next();!s.done;s=i.next()){var n=s.value.index,o=this.linesContent.slice(0,n).match(/(\\+)$/);if(o)if(!!(o[1].length%2))continue;var r="";this.separatorPosition=n;var a=this.linesContent.slice(n),h=(a.match(/^([\t\n\v\f\r ]+)/)||[""])[0];h.length>0&&(r+=h,a=a.slice(h.length)),/[:=]/.test(a[0])&&(r+=a[0],r+=((a=a.slice(1)).match(/^([\t\n\v\f\r ]+)/)||[""])[0]),this.separatorLength=r.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),n||(this.hasNoKey=!0);break}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}void 0===this.separatorPosition?this.hasNoValue=!0:this.newlinePositions.length>0&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}},t}();export{Property};
1
+ var __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};import{unescapeContent}from"./unescape/index.js";var Property=function(){function t(t,e,i){this.key="",this.escapedKey="",this.hasNoKey=!1,this.hasMultilineKey=!1,this.keyCollisionLines=[],this.hasKeyCollisions=!1,this.value="",this.escapedValue="",this.newlinePositions=[],this.linesContent=t.content,this.startingLineNumber=e,this.endingLineNumber=e,this.previousProperty=i,null==i||i.setNextProperty(this)}return t.prototype.setNextProperty=function(t){this.nextProperty=t},t.prototype.addLine=function(t){this.linesContent.length>0&&(this.newlinePositions.push(this.linesContent.length),this.endingLineNumber++),this.linesContent+=t.content},t.prototype.setKeyAndValue=function(){this.findSeparator(),void 0!==this.separatorPosition&&void 0!==this.separatorLength?(this.hasNoKey||(this.escapedKey=this.linesContent.slice(0,this.separatorPosition),this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber)),this.escapedValue=this.linesContent.slice(this.separatorPosition+this.separatorLength),this.value=this.unescapeLine(this.escapedValue,this.startingLineNumber)):(this.escapedKey=this.linesContent,this.key=this.unescapeLine(this.escapedKey,this.startingLineNumber))},t.prototype.unescapeLine=function(t,e){try{return unescapeContent(t)}catch(t){throw new Error("".concat(t.message," in property starting at line ").concat(e))}},t.prototype.findSeparator=function(){var t,e;if(!this.hasNoKey&&!this.separator){try{for(var i=__values(this.linesContent.matchAll(/[\t\f :=]/g)),s=i.next();!s.done;s=i.next()){var n=s.value.index,o=this.linesContent.slice(0,n).match(/(\\+)$/);if(o)if(!!(o[1].length%2))continue;var r="";this.separatorPosition=n;var a=this.linesContent.slice(n),h=(a.match(/^([\t\n\v\f\r ]+)/)||[""])[0];h.length>0&&(r+=h,a=a.slice(h.length)),/[:=]/.test(a[0])&&(r+=a[0],r+=((a=a.slice(1)).match(/^([\t\n\v\f\r ]+)/)||[""])[0]),this.separatorLength=r.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),n||(this.hasNoKey=!0);break}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}void 0!==this.separatorPosition&&this.newlinePositions.length>0&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}},t}();export{Property};
@@ -1 +1 @@
1
- export var unescapeContent=function(r){return r.replace(/\\[^u]|\\u.{4}/g,(function(r){var e=r.charAt(1);switch(e){case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"u":var t=r.slice(2,6);if(!/[\da-f]{4}/i.test(t))throw new Error("malformed escaped unicode characters '\\u".concat(t,"'"));return String.fromCodePoint(Number.parseInt(t,16));default:return e}}))};
1
+ export var unescapeContent=function(r){return r.replace(/\\[^u]|\\u.{4}/g,function(r){var e=r.charAt(1);switch(e){case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"u":var t=r.slice(2,6);if(!/[\da-f]{4}/i.test(t))throw new Error("malformed escaped unicode characters '\\u".concat(t,"'"));return String.fromCodePoint(Number.parseInt(t,16));default:return e}})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "properties-file",
3
- "version": "3.5.12",
3
+ "version": "3.5.13",
4
4
  "description": ".properties file parser, editor, formatter and Webpack loader.",
5
5
  "keywords": [
6
6
  ".properties",
@@ -94,34 +94,34 @@
94
94
  "test": "jest --coverage"
95
95
  },
96
96
  "devDependencies": {
97
- "@release-it/conventional-changelog": "10.0.0",
98
- "@types/jest": "29.5.14",
99
- "@types/node": "22.13.11",
97
+ "@release-it/conventional-changelog": "10.0.1",
98
+ "@types/jest": "30.0.0",
99
+ "@types/node": "24.0.15",
100
100
  "check-node-version": "4.2.1",
101
101
  "depcheck": "1.4.7",
102
102
  "dotenv-cli": "8.0.0",
103
- "eslint": "9.23.0",
104
- "eslint-config-prettier": "10.1.1",
105
- "eslint-import-resolver-typescript": "^4.2.2",
103
+ "eslint": "9.31.0",
104
+ "eslint-config-prettier": "10.1.8",
105
+ "eslint-import-resolver-typescript": "4.4.4",
106
106
  "eslint-plugin-compat": "6.0.2",
107
- "eslint-plugin-import": "2.31.0",
108
- "eslint-plugin-jest": "28.11.0",
109
- "eslint-plugin-json-files": "4.4.2",
107
+ "eslint-plugin-import-x": "4.16.1",
108
+ "eslint-plugin-jest": "29.0.1",
109
+ "eslint-plugin-json-files": "5.1.0",
110
110
  "eslint-plugin-prefer-arrow-functions": "3.6.2",
111
- "eslint-plugin-prettier": "5.2.3",
111
+ "eslint-plugin-prettier": "5.5.3",
112
112
  "eslint-plugin-tsdoc": "0.4.0",
113
- "eslint-plugin-unicorn": "57.0.0",
113
+ "eslint-plugin-unicorn": "60.0.0",
114
114
  "husky": "9.1.7",
115
- "jest": "29.7.0",
115
+ "jest": "30.0.4",
116
116
  "jiti": "2.4.2",
117
117
  "jsonc-eslint-parser": "2.4.0",
118
- "prettier": "3.5.3",
118
+ "prettier": "3.6.2",
119
119
  "prettier-plugin-organize-imports": "4.1.0",
120
- "release-it": "18.1.2",
121
- "terser": "5.39.0",
122
- "ts-jest": "29.2.6",
123
- "typescript": "5.8.2",
124
- "typescript-eslint": "8.27.0"
120
+ "release-it": "19.0.4",
121
+ "terser": "5.43.1",
122
+ "ts-jest": "29.4.0",
123
+ "typescript": "5.8.3",
124
+ "typescript-eslint": "8.38.0"
125
125
  },
126
126
  "engines": {
127
127
  "node": "*"