properties-file 3.5.12 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/index.js +1 -1
- package/dist/cjs/escape/index.js +1 -1
- package/dist/cjs/properties.js +1 -1
- package/dist/cjs/property.d.ts +0 -2
- package/dist/cjs/property.js +1 -1
- package/dist/cjs/unescape/index.d.ts +4 -5
- package/dist/cjs/unescape/index.js +1 -1
- package/dist/esm/editor/index.js +1 -1
- package/dist/esm/escape/index.js +1 -1
- package/dist/esm/properties.js +1 -1
- package/dist/esm/property.d.ts +0 -2
- package/dist/esm/property.js +1 -1
- package/dist/esm/unescape/index.d.ts +4 -5
- package/dist/esm/unescape/index.js +1 -1
- package/package.json +26 -23
package/dist/cjs/editor/index.js
CHANGED
|
@@ -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(
|
|
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;
|
package/dist/cjs/escape/index.js
CHANGED
|
@@ -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"),
|
|
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"))}})};
|
package/dist/cjs/properties.js
CHANGED
|
@@ -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(
|
|
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;
|
package/dist/cjs/property.d.ts
CHANGED
|
@@ -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. */
|
package/dist/cjs/property.js
CHANGED
|
@@ -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.
|
|
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,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Tries to unescape the content from either key or value of a property.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param content - The content to unescape.
|
|
5
5
|
*
|
|
6
6
|
* @returns The unescaped content.
|
|
7
7
|
*
|
|
8
|
-
* @throws
|
|
9
|
-
* This exception is thrown if malformed escaped unicode characters are present.
|
|
8
|
+
* @throws Error if malformed escaped unicode characters are present.
|
|
10
9
|
*/
|
|
11
|
-
export declare const unescapeContent: (
|
|
10
|
+
export declare const unescapeContent: (content: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unescapeContent=void 0;var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unescapeContent=void 0;var REGEX_INVALID_UNICODE_ESCAPE=/\\u(?![0-9a-fA-F]{4}(?![0-9a-fA-F]))/,REGEX_ESCAPE=/\\(?:([fnrt])|u([0-9a-fA-F]{4})|(.))/g,ESCAPE_MAP={f:"\f",n:"\n",r:"\r",t:"\t"},unescapeContent=function(e){if(!e.includes("\\"))return e;var n=e.match(REGEX_INVALID_UNICODE_ESCAPE);if(n){var r=n.index,t=e.slice(r,r+6);throw new Error("malformed escaped unicode characters '".concat(t,"'"))}return e.replace(REGEX_ESCAPE,function(e,n,r,t){return n?ESCAPE_MAP[n]:r?String.fromCodePoint(Number.parseInt(r,16)):t})};exports.unescapeContent=unescapeContent;
|
package/dist/esm/editor/index.js
CHANGED
|
@@ -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(
|
|
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};
|
package/dist/esm/escape/index.js
CHANGED
|
@@ -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"),
|
|
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"))}})};
|
package/dist/esm/properties.js
CHANGED
|
@@ -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(
|
|
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};
|
package/dist/esm/property.d.ts
CHANGED
|
@@ -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. */
|
package/dist/esm/property.js
CHANGED
|
@@ -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.
|
|
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,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Tries to unescape the content from either key or value of a property.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param content - The content to unescape.
|
|
5
5
|
*
|
|
6
6
|
* @returns The unescaped content.
|
|
7
7
|
*
|
|
8
|
-
* @throws
|
|
9
|
-
* This exception is thrown if malformed escaped unicode characters are present.
|
|
8
|
+
* @throws Error if malformed escaped unicode characters are present.
|
|
10
9
|
*/
|
|
11
|
-
export declare const unescapeContent: (
|
|
10
|
+
export declare const unescapeContent: (content: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var REGEX_INVALID_UNICODE_ESCAPE=/\\u(?![0-9a-fA-F]{4}(?![0-9a-fA-F]))/,REGEX_ESCAPE=/\\(?:([fnrt])|u([0-9a-fA-F]{4})|(.))/g,ESCAPE_MAP={f:"\f",n:"\n",r:"\r",t:"\t"};export var unescapeContent=function(r){if(!r.includes("\\"))return r;var E=r.match(REGEX_INVALID_UNICODE_ESCAPE);if(E){var e=E.index,n=r.slice(e,e+6);throw new Error("malformed escaped unicode characters '".concat(n,"'"))}return r.replace(REGEX_ESCAPE,function(r,E,e,n){return E?ESCAPE_MAP[E]:e?String.fromCodePoint(Number.parseInt(e,16)):n})};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "properties-file",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": ".properties file parser, editor, formatter and Webpack loader.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
".properties",
|
|
@@ -85,43 +85,46 @@
|
|
|
85
85
|
"scripts": {
|
|
86
86
|
"add-file-type-declaration": "node ./dist/esm/add-import-type.js && find ./dist -name 'add-import-type.*' -type f -delete",
|
|
87
87
|
"build": "npm run check-nvm-node-version && npm run prettier-write && npm run eslint-fix && rm -Rf ./dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && echo '{ \"type\": \"commonjs\" }' > dist/cjs/package.json && tsc -p src/build-scripts/tsconfig.json && node dist/build-scripts/build.js && npm run test",
|
|
88
|
-
"check-nvm-node-version": "check-node-version --node $(node -p \"'>='
|
|
88
|
+
"check-nvm-node-version": "check-node-version --node $(node -p \"'>='+require('fs').readFileSync('.nvmrc','utf-8').trim()\")",
|
|
89
89
|
"depcheck": "depcheck",
|
|
90
90
|
"eslint-fix": "eslint --fix",
|
|
91
|
+
"ncu": "npm-check-updates",
|
|
92
|
+
"ncu-update": "npm-check-updates -u",
|
|
91
93
|
"prepare": "husky",
|
|
92
94
|
"prettier-write": "prettier --write .",
|
|
93
95
|
"release": "dotenv -- release-it --only-version",
|
|
94
96
|
"test": "jest --coverage"
|
|
95
97
|
},
|
|
96
98
|
"devDependencies": {
|
|
97
|
-
"@release-it/conventional-changelog": "10.0.
|
|
98
|
-
"@types/jest": "
|
|
99
|
-
"@types/node": "
|
|
99
|
+
"@release-it/conventional-changelog": "10.0.1",
|
|
100
|
+
"@types/jest": "30.0.0",
|
|
101
|
+
"@types/node": "24.3.0",
|
|
100
102
|
"check-node-version": "4.2.1",
|
|
101
103
|
"depcheck": "1.4.7",
|
|
102
|
-
"dotenv-cli": "
|
|
103
|
-
"eslint": "9.
|
|
104
|
-
"eslint-config-prettier": "10.1.
|
|
105
|
-
"eslint-import-resolver-typescript": "
|
|
104
|
+
"dotenv-cli": "10.0.0",
|
|
105
|
+
"eslint": "9.34.0",
|
|
106
|
+
"eslint-config-prettier": "10.1.8",
|
|
107
|
+
"eslint-import-resolver-typescript": "4.4.4",
|
|
106
108
|
"eslint-plugin-compat": "6.0.2",
|
|
107
|
-
"eslint-plugin-import": "
|
|
108
|
-
"eslint-plugin-jest": "
|
|
109
|
-
"eslint-plugin-json-files": "
|
|
109
|
+
"eslint-plugin-import-x": "4.16.1",
|
|
110
|
+
"eslint-plugin-jest": "29.0.1",
|
|
111
|
+
"eslint-plugin-json-files": "5.1.0",
|
|
110
112
|
"eslint-plugin-prefer-arrow-functions": "3.6.2",
|
|
111
|
-
"eslint-plugin-prettier": "5.
|
|
113
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
112
114
|
"eslint-plugin-tsdoc": "0.4.0",
|
|
113
|
-
"eslint-plugin-unicorn": "
|
|
115
|
+
"eslint-plugin-unicorn": "60.0.0",
|
|
114
116
|
"husky": "9.1.7",
|
|
115
|
-
"jest": "
|
|
116
|
-
"jiti": "2.
|
|
117
|
+
"jest": "30.0.5",
|
|
118
|
+
"jiti": "2.5.1",
|
|
117
119
|
"jsonc-eslint-parser": "2.4.0",
|
|
118
|
-
"
|
|
119
|
-
"prettier
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"typescript
|
|
120
|
+
"npm-check-updates": "18.0.2",
|
|
121
|
+
"prettier": "3.6.2",
|
|
122
|
+
"prettier-plugin-organize-imports": "4.2.0",
|
|
123
|
+
"release-it": "19.0.4",
|
|
124
|
+
"terser": "5.43.1",
|
|
125
|
+
"ts-jest": "29.4.1",
|
|
126
|
+
"typescript": "5.9.2",
|
|
127
|
+
"typescript-eslint": "8.40.0"
|
|
125
128
|
},
|
|
126
129
|
"engines": {
|
|
127
130
|
"node": "*"
|