properties-file 3.6.5 → 3.7.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.d.ts +8 -0
- package/dist/cjs/editor/index.js +1 -1
- package/dist/cjs/escape/index.js +1 -1
- package/dist/cjs/properties.d.ts +3 -1
- package/dist/cjs/properties.js +1 -1
- package/dist/cjs/property-line.js +1 -1
- package/dist/cjs/property.js +1 -1
- package/dist/cjs/unescape/index.js +1 -1
- package/dist/esm/editor/index.d.ts +8 -0
- package/dist/esm/editor/index.js +1 -1
- package/dist/esm/escape/index.js +1 -1
- package/dist/esm/properties.d.ts +3 -1
- package/dist/esm/properties.js +1 -1
- package/dist/esm/property-line.js +1 -1
- package/dist/esm/property.js +1 -1
- package/dist/esm/unescape/index.js +1 -1
- package/package.json +2 -3
|
@@ -70,6 +70,14 @@ export declare class PropertiesEditor extends Properties {
|
|
|
70
70
|
* @param content - The content of a `.properties` file.
|
|
71
71
|
*/
|
|
72
72
|
constructor(content: string);
|
|
73
|
+
/**
|
|
74
|
+
* Find the last occurrence of a property by key (iterates backward for performance).
|
|
75
|
+
*
|
|
76
|
+
* @param key - The property key to search for.
|
|
77
|
+
*
|
|
78
|
+
* @returns The last matching property, or undefined if not found.
|
|
79
|
+
*/
|
|
80
|
+
private findLastPropertyByKey;
|
|
73
81
|
/**
|
|
74
82
|
* Parse the `.properties` content line by line only when needed.
|
|
75
83
|
*/
|
package/dist/cjs/editor/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,
|
|
1
|
+
"use strict";var __extends=this&&this.__extends||function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},e(r,t)};return function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,i,o=t.call(e),s=[];try{for(;(void 0===r||r-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(i)throw i.error}}return s},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var n,i=0,o=r.length;i<o;i++)!n&&i in r||(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return e.concat(n||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"),REGEX_NEWLINE_GLOBAL=/\r?\n/g,REGEX_LF=/\n/;exports.DEFAULT_SEPARATOR="=",exports.DEFAULT_COMMENT_DELIMITER="#";var PropertiesEditor=function(e){function r(r){var t=e.call(this,r)||this;return t.needsLineParsing=!1,t}return __extends(r,e),r.prototype.findLastPropertyByKey=function(e){for(var r=this.collection.length-1;r>=0;r--){var t=this.collection[r];if(t.key===e)return t}},r.prototype.parseLinesIfNeeded=function(){this.needsLineParsing&&(this.parseLines(),this.needsLineParsing=!1)},r.prototype.insert=function(e,r,t){var n,i,o,s=(null==t?void 0:t.escapeUnicode)||!1,a=(null==t?void 0:t.separator)?" "===t.separator?" ":" ".concat(t.separator," "):" ".concat(exports.DEFAULT_SEPARATOR," ").replace(" "," "),p=null==t?void 0:t.referenceKey,c=(null==t?void 0:t.position)||"after";p&&this.parseLinesIfNeeded();var l=e.split(properties_1.REGEX_NEWLINE).map(function(e){return(0,escape_1.escapeKey)(e,s)}).join("\\\n"),d=r.split(properties_1.REGEX_NEWLINE).map(function(e){return(0,escape_1.escapeValue)(e,s)}).join("\\\n"),u="".concat((null==t?void 0:t.commentDelimiter)||exports.DEFAULT_COMMENT_DELIMITER," "),_=void 0===(null==t?void 0:t.comment)?"":"".concat("".concat(u).concat(t.comment).split(properties_1.REGEX_NEWLINE).join("\n".concat(u)),"\n"),y="".concat(_).concat(l).concat(a).concat(d).split(REGEX_LF);if(void 0===p)return(n=this.lines).push.apply(n,__spreadArray([],__read(y),!1)),this.needsLineParsing=!0,!0;var E=this.findLastPropertyByKey(p);if(E){var v="after"===c?E.endingLineNumber:null!==(o=null===(i=E.previousProperty)||void 0===i?void 0:i.endingLineNumber)&&void 0!==o?o:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,v)),!1),__read(y),!1),__read(this.lines.slice(v)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.insertComment=function(e,r){var t,n,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," "),p="".concat(a).concat(e).replace(REGEX_NEWLINE_GLOBAL,"\n".concat(a)).split(REGEX_LF);if(void 0===o)return(t=this.lines).push.apply(t,__spreadArray([],__read(p),!1)),this.needsLineParsing=!0,!0;var c=this.findLastPropertyByKey(o);if(c){var l="after"===s?c.endingLineNumber:null!==(i=null===(n=c.previousProperty)||void 0===n?void 0:n.endingLineNumber)&&void 0!==i?i:0;return this.lines=__spreadArray(__spreadArray(__spreadArray([],__read(this.lines.slice(0,l)),!1),__read(p),!1),__read(this.lines.slice(l)),!1),this.needsLineParsing=!0,!0}return!1},r.prototype.delete=function(e,r){var t,n;void 0===r&&(r=!0),this.parseLinesIfNeeded();var i=this.findLastPropertyByKey(e);if(i){var o=r?null!==(n=null===(t=i.previousProperty)||void 0===t?void 0:t.endingLineNumber)&&void 0!==n?n: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,t,n){return"".concat(r).concat(-1!==e.newlinePositions.indexOf(n)?"\n":"").concat(t)},"")},r.prototype.getValueWithNewlines=function(e){return 0===e.newlinePositions.length||void 0===e.valuePosition?e.value:__spreadArray([],__read(e.value),!1).reduce(function(r,t,n){return"".concat(r).concat(-1!==e.newlinePositions.indexOf(n+e.valuePosition)?"\n":"").concat(t)},"")},r.prototype.update=function(e,r){var t,n,i,o;this.parseLinesIfNeeded();var s=this.findLastPropertyByKey(e);if(!s||!r)return!1;var a=r.escapeUnicode||!1,p=r.separator?" "===r.separator?" ":" ".concat(r.separator," "):s.separator||" ".concat(exports.DEFAULT_SEPARATOR," ").replace(" "," "),c=(null!==(t=r.newKey)&&void 0!==t?t:this.getKeyWithNewlines(s)).split(properties_1.REGEX_NEWLINE).map(function(e){return(0,escape_1.escapeKey)(e,a)}).join("\\\n"),l=(null!==(n=r.newValue)&&void 0!==n?n:this.getValueWithNewlines(s)).split(properties_1.REGEX_NEWLINE).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(properties_1.REGEX_NEWLINE).join("\n".concat(d)),"\n"),_="".concat(u).concat(c).concat(p).concat(l).split(REGEX_LF);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,t){return this.parseLinesIfNeeded(),this.keyLineNumbers[e]?this.update(e,{newValue:r,newComment:null==t?void 0:t.comment,commentDelimiter:null==t?void 0:t.commentDelimiter,separator:null==t?void 0:t.separator,escapeUnicode:null==t?void 0:t.escapeUnicode}):this.insert(e,r,t)},r.prototype.toObject=function(){return this.parseLinesIfNeeded(),e.prototype.toObject.call(this)},r}(properties_1.Properties);exports.PropertiesEditor=PropertiesEditor;
|
package/dist/cjs/escape/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.escapeValue=exports.escapeKey=void 0;var escapeKey=function(e,r){return void 0===r&&(r=!1),escapeContent(e,!0,r)};exports.escapeKey=escapeKey;var escapeValue=function(e,r){return void 0===r&&(r=!1),escapeContent(e,!1,r)};exports.escapeValue=escapeValue;var escapeContent=function(e,r,t){return e.replace(new RegExp("[\\s!#:=\\\\".concat(t?"\0--":"","]"),"g"),function(e,t){var a;switch(e){case" ":return r||0===t?"\\ ":" ";case"\\":return"\\\\";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\t":return"\\t";case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u"+("0000"+(null!==(a=e.charCodeAt(0))&&void 0!==a?a:0).toString(16)).slice(-4)}})};
|
package/dist/cjs/properties.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { Property } from './property';
|
|
|
4
4
|
* Byte-order mark.
|
|
5
5
|
*/
|
|
6
6
|
export declare const BOM = "\uFEFF";
|
|
7
|
-
export declare const BOM_CODE_POINT: number
|
|
7
|
+
export declare const BOM_CODE_POINT: number;
|
|
8
|
+
/** Matches a newline, optionally preceded by a carriage return. */
|
|
9
|
+
export declare const REGEX_NEWLINE: RegExp;
|
|
8
10
|
/** The default end of line character. */
|
|
9
11
|
export declare const DEFAULT_END_OF_LINE_CHARACTER = "\n";
|
|
10
12
|
/**
|
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],
|
|
1
|
+
"use strict";var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.KeyCollisions=exports.Properties=exports.getFirstEolCharacter=exports.DEFAULT_END_OF_LINE_CHARACTER=exports.REGEX_NEWLINE=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.charCodeAt(0),exports.REGEX_NEWLINE=/\r?\n/,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.charCodeAt(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(exports.REGEX_NEWLINE),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,i,o=0;try{for(var n=__values(this.lines),s=n.next();!s.done;s=n.next()){var l=s.value;o++;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,o,i),a.isContinuing)continue}this.addToCollection(r),i=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=[],i=Object.keys(this.keyLineNumbers);try{for(var o=__values(i),n=o.next();!n.done;n=o.next()){var s=n.value,l=this.keyLineNumbers[s];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{n&&!n.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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertyLine=void 0;var PropertyLine=function(t,i){if(this.isContinuing=!1,this.isBlank=!1,this.isComment=!1,this.content=t.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PropertyLine=void 0;var REGEX_LEADING_WHITESPACE=/^\s+/,REGEX_COMMENT=/^[!#]/,REGEX_TRAILING_BACKSLASHES=/(\\+)$/,PropertyLine=function(t,i){if(this.isContinuing=!1,this.isBlank=!1,this.isComment=!1,this.content=t.replace(REGEX_LEADING_WHITESPACE,""),this.isMultiline=i,0===this.content.length)this.isBlank=!0;else if(this.isMultiline||(this.isComment=REGEX_COMMENT.test(this.content)),!this.isComment){var e=this.content.match(REGEX_TRAILING_BACKSLASHES);e&&(this.isContinuing=e[1].length%2==1,this.isContinuing&&(this.content=this.content.slice(0,-1)))}};exports.PropertyLine=PropertyLine;
|
package/dist/cjs/property.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Property=void 0;var unescape_1=require("./unescape"),REGEX_TRAILING_BACKSLASHES=/(\\+)$/,REGEX_LEADING_WHITESPACE=/^([\t\n\v\f\r ]+)/,REGEX_SEPARATOR=/[\t\f :=]/g,REGEX_COLON_OR_EQUALS=/[:=]/,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,i,s;if(!this.hasNoKey&&!this.separator){var n;for(REGEX_SEPARATOR.lastIndex=0;null!==(n=REGEX_SEPARATOR.exec(this.linesContent));){var o=n.index,r=this.linesContent.slice(0,o).match(REGEX_TRAILING_BACKSLASHES);if(r)if(r[1].length%2==1)continue;var h="";this.separatorPosition=o;var a=this.linesContent.slice(o),l=null!==(e=null===(t=a.match(REGEX_LEADING_WHITESPACE))||void 0===t?void 0:t[0])&&void 0!==e?e:"";l.length>0&&(h+=l,a=a.slice(l.length)),REGEX_COLON_OR_EQUALS.test(a[0])&&(h+=a[0],h+=null!==(s=null===(i=(a=a.slice(1)).match(REGEX_LEADING_WHITESPACE))||void 0===i?void 0:i[0])&&void 0!==s?s:""),this.separatorLength=h.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),o||(this.hasNoKey=!0);break}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 REGEX_INVALID_UNICODE_ESCAPE=/\\u(?![0-9a-fA-F]{4})/,REGEX_ESCAPE=/\\(?:([fnrt])|u([0-9a-fA-F]{4})|(.))/g,ESCAPE_MAP={f:"\f",n:"\n",r:"\r",t:"\t"},unescapeContent=function(e){var n;if(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unescapeContent=void 0;var REGEX_INVALID_UNICODE_ESCAPE=/\\u(?![0-9a-fA-F]{4})/,REGEX_ESCAPE=/\\(?:([fnrt])|u([0-9a-fA-F]{4})|(.))/g,ESCAPE_MAP={f:"\f",n:"\n",r:"\r",t:"\t"},unescapeContent=function(e){var n;if(-1===e.indexOf("\\"))return e;var r=e.match(REGEX_INVALID_UNICODE_ESCAPE);if(r){var t=null!==(n=r.index)&&void 0!==n?n:0,E=e.slice(t,t+6);throw new Error("malformed escaped unicode characters '".concat(E,"'"))}return e.replace(REGEX_ESCAPE,function(e,n,r,t){return n?ESCAPE_MAP[n]:r?String.fromCharCode(parseInt(r,16)):null!=t?t:""})};exports.unescapeContent=unescapeContent;
|
|
@@ -70,6 +70,14 @@ export declare class PropertiesEditor extends Properties {
|
|
|
70
70
|
* @param content - The content of a `.properties` file.
|
|
71
71
|
*/
|
|
72
72
|
constructor(content: string);
|
|
73
|
+
/**
|
|
74
|
+
* Find the last occurrence of a property by key (iterates backward for performance).
|
|
75
|
+
*
|
|
76
|
+
* @param key - The property key to search for.
|
|
77
|
+
*
|
|
78
|
+
* @returns The last matching property, or undefined if not found.
|
|
79
|
+
*/
|
|
80
|
+
private findLastPropertyByKey;
|
|
73
81
|
/**
|
|
74
82
|
* Parse the `.properties` content line by line only when needed.
|
|
75
83
|
*/
|
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 p=e.split(
|
|
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,REGEX_NEWLINE}from"../properties.js";var REGEX_NEWLINE_GLOBAL=/\r?\n/g,REGEX_LF=/\n/;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.findLastPropertyByKey=function(e){for(var n=this.collection.length-1;n>=0;n--){var r=this.collection[n];if(r.key===e)return r}},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 p=e.split(REGEX_NEWLINE).map(function(e){return escapeKey(e,a)}).join("\\\n"),d=n.split(REGEX_NEWLINE).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(REGEX_NEWLINE).join("\n".concat(u)),"\n"),y="".concat(_).concat(p).concat(s).concat(d).split(REGEX_LF);if(void 0===c)return(t=this.lines).push.apply(t,__spreadArray([],__read(y),!1)),this.needsLineParsing=!0,!0;var v=this.findLastPropertyByKey(c);if(v){var f="after"===l?v.endingLineNumber:null!==(o=null===(i=v.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(y),!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(REGEX_NEWLINE_GLOBAL,"\n".concat(s)).split(REGEX_LF);if(void 0===o)return(r=this.lines).push.apply(r,__spreadArray([],__read(c),!1)),this.needsLineParsing=!0,!0;var l=this.findLastPropertyByKey(o);if(l){var p="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,p)),!1),__read(c),!1),__read(this.lines.slice(p)),!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=this.findLastPropertyByKey(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(-1!==e.newlinePositions.indexOf(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(-1!==e.newlinePositions.indexOf(t+e.valuePosition)?"\n":"").concat(r)},"")},n.prototype.update=function(e,n){var r,t,i,o;this.parseLinesIfNeeded();var a=this.findLastPropertyByKey(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(REGEX_NEWLINE).map(function(e){return escapeKey(e,s)}).join("\\\n"),p=(null!==(t=n.newValue)&&void 0!==t?t:this.getValueWithNewlines(a)).split(REGEX_NEWLINE).map(function(e){return escapeValue(e,s)}).join("\\\n"),d="".concat(n.commentDelimiter||DEFAULT_COMMENT_DELIMITER," "),u=void 0===n.newComment?"":"".concat("".concat(d).concat(n.newComment).split(REGEX_NEWLINE).join("\n".concat(d)),"\n"),_="".concat(u).concat(l).concat(c).concat(p).split(REGEX_LF);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.prototype.toObject=function(){return this.parseLinesIfNeeded(),e.prototype.toObject.call(this)},n}(Properties);export{PropertiesEditor};
|
package/dist/esm/escape/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export var escapeKey=function(e,r){return void 0===r&&(r=!1),escapeContent(e,!0,r)};export var escapeValue=function(e,r){return void 0===r&&(r=!1),escapeContent(e,!1,r)};var escapeContent=function(e,r,n){return e.replace(new RegExp("[\\s!#:=\\\\".concat(n?"\0--":"","]"),"g"),function(e,n){var t;switch(e){case" ":return r||0===n?"\\ ":" ";case"\\":return"\\\\";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\t":return"\\t";case"=":case":":case"#":case"!":return"\\".concat(e);default:return"\\u"+("0000"+(null!==(t=e.charCodeAt(0))&&void 0!==t?t:0).toString(16)).slice(-4)}})};
|
package/dist/esm/properties.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { Property } from './property.js';
|
|
|
4
4
|
* Byte-order mark.
|
|
5
5
|
*/
|
|
6
6
|
export declare const BOM = "\uFEFF";
|
|
7
|
-
export declare const BOM_CODE_POINT: number
|
|
7
|
+
export declare const BOM_CODE_POINT: number;
|
|
8
|
+
/** Matches a newline, optionally preceded by a carriage return. */
|
|
9
|
+
export declare const REGEX_NEWLINE: RegExp;
|
|
8
10
|
/** The default end of line character. */
|
|
9
11
|
export declare const DEFAULT_END_OF_LINE_CHARACTER = "\n";
|
|
10
12
|
/**
|
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],
|
|
1
|
+
var __values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};import{Property}from"./property.js";import{PropertyLine}from"./property-line.js";export var BOM="\ufeff";export var BOM_CODE_POINT=BOM.charCodeAt(0);export var REGEX_NEWLINE=/\r?\n/;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.charCodeAt(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(REGEX_NEWLINE),this.parseLines()}return e.prototype.parseLines=function(){var e,t;this.collection=[],this.keyLineNumbers={};var r,i,n=0;try{for(var o=__values(this.lines),s=o.next();!s.done;s=o.next()){var l=s.value;n++;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,n,i),a.isContinuing)continue}this.addToCollection(r),i=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=[],i=Object.keys(this.keyLineNumbers);try{for(var n=__values(i),o=n.next();!o.done;o=n.next()){var s=o.value,l=this.keyLineNumbers[s];l.length>1&&r.push(new KeyCollisions(s,l))}}catch(t){e={error:t}}finally{try{o&&!o.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 +1 @@
|
|
|
1
|
-
var PropertyLine=function(t,i){if(this.isContinuing=!1,this.isBlank=!1,this.isComment=!1,this.content=t.
|
|
1
|
+
var REGEX_LEADING_WHITESPACE=/^\s+/,REGEX_COMMENT=/^[!#]/,REGEX_TRAILING_BACKSLASHES=/(\\+)$/,PropertyLine=function(t,i){if(this.isContinuing=!1,this.isBlank=!1,this.isComment=!1,this.content=t.replace(REGEX_LEADING_WHITESPACE,""),this.isMultiline=i,0===this.content.length)this.isBlank=!0;else if(this.isMultiline||(this.isComment=REGEX_COMMENT.test(this.content)),!this.isComment){var n=this.content.match(REGEX_TRAILING_BACKSLASHES);n&&(this.isContinuing=n[1].length%2==1,this.isContinuing&&(this.content=this.content.slice(0,-1)))}};export{PropertyLine};
|
package/dist/esm/property.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{unescapeContent}from"./unescape/index.js";var REGEX_TRAILING_BACKSLASHES=/(\\+)$/,REGEX_LEADING_WHITESPACE=/^([\t\n\v\f\r ]+)/,REGEX_SEPARATOR=/[\t\f :=]/g,REGEX_COLON_OR_EQUALS=/[:=]/,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,i,s;if(!this.hasNoKey&&!this.separator){var n;for(REGEX_SEPARATOR.lastIndex=0;null!==(n=REGEX_SEPARATOR.exec(this.linesContent));){var o=n.index,h=this.linesContent.slice(0,o).match(REGEX_TRAILING_BACKSLASHES);if(h)if(h[1].length%2==1)continue;var r="";this.separatorPosition=o;var a=this.linesContent.slice(o),l=null!==(e=null===(t=a.match(REGEX_LEADING_WHITESPACE))||void 0===t?void 0:t[0])&&void 0!==e?e:"";l.length>0&&(r+=l,a=a.slice(l.length)),REGEX_COLON_OR_EQUALS.test(a[0])&&(r+=a[0],r+=null!==(s=null===(i=(a=a.slice(1)).match(REGEX_LEADING_WHITESPACE))||void 0===i?void 0:i[0])&&void 0!==s?s:""),this.separatorLength=r.length,this.valuePosition=this.separatorPosition+this.separatorLength,this.separator=this.linesContent.slice(this.separatorPosition,this.separatorPosition+this.separatorLength),o||(this.hasNoKey=!0);break}void 0!==this.separatorPosition&&this.newlinePositions.length>0&&this.newlinePositions[0]<this.separatorPosition&&(this.hasMultilineKey=!0)}},t}();export{Property};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var REGEX_INVALID_UNICODE_ESCAPE=/\\u(?![0-9a-fA-F]{4})/,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){var
|
|
1
|
+
var REGEX_INVALID_UNICODE_ESCAPE=/\\u(?![0-9a-fA-F]{4})/,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){var E;if(-1===r.indexOf("\\"))return r;var n=r.match(REGEX_INVALID_UNICODE_ESCAPE);if(n){var e=null!==(E=n.index)&&void 0!==E?E:0,a=r.slice(e,e+6);throw new Error("malformed escaped unicode characters '".concat(a,"'"))}return r.replace(REGEX_ESCAPE,function(r,E,n,e){return E?ESCAPE_MAP[E]:n?String.fromCharCode(parseInt(n,16)):null!=e?e:""})};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "properties-file",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": ".properties file parser, editor, formatter and Webpack loader.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
".properties",
|
|
@@ -100,14 +100,13 @@
|
|
|
100
100
|
"@release-it/conventional-changelog": "10.0.6",
|
|
101
101
|
"@types/jest": "30.0.0",
|
|
102
102
|
"@types/node": "25.5.0",
|
|
103
|
-
"baseline-browser-mapping": "2.10.8",
|
|
104
103
|
"check-node-version": "4.2.1",
|
|
105
104
|
"depcheck": "1.4.7",
|
|
106
105
|
"dotenv-cli": "11.0.0",
|
|
107
106
|
"eslint": "10.0.3",
|
|
108
107
|
"eslint-config-prettier": "10.1.8",
|
|
109
108
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
110
|
-
"eslint-plugin-
|
|
109
|
+
"eslint-plugin-es-x": "9.5.0",
|
|
111
110
|
"eslint-plugin-import-x": "4.16.2",
|
|
112
111
|
"eslint-plugin-jest": "29.15.0",
|
|
113
112
|
"eslint-plugin-package-json": "0.91.0",
|