ilib-tools-common 1.17.0 → 1.19.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/lib/EscaperFactory.js +13 -2
- package/lib/EscaperFactory.js.map +1 -1
- package/lib/Resource.js +12 -2
- package/lib/Resource.js.map +1 -1
- package/lib/escapes/CppEscaper.js +48 -0
- package/lib/escapes/CppEscaper.js.map +1 -0
- package/lib/escapes/EscapeCommon.js +49 -3
- package/lib/escapes/EscapeCommon.js.map +1 -1
- package/lib/escapes/ScalaEscaper.js +43 -0
- package/lib/escapes/ScalaEscaper.js.map +1 -0
- package/package.json +4 -3
- package/src/EscaperFactory.js +30 -0
- package/src/Resource.js +22 -1
- package/src/escapes/CppEscaper.js +100 -0
- package/src/escapes/EscapeCommon.js +315 -0
- package/src/escapes/ScalaEscaper.js +95 -0
package/lib/EscaperFactory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _CSharpEscaper=_interopRequireDefault(require("./escapes/CSharpEscaper.js"));var _JavaEscaper=_interopRequireDefault(require("./escapes/JavaEscaper.js"));var _JavascriptEscaper=_interopRequireDefault(require("./escapes/JavascriptEscaper.js"));var _JsonEscaper=_interopRequireDefault(require("./escapes/JsonEscaper.js"));var _RegexBasedEscaper=_interopRequireDefault(require("./escapes/RegexBasedEscaper.js"));var _PHPEscaper=_interopRequireDefault(require("./escapes/PHPEscaper.js"));var _SmartyEscaper=_interopRequireDefault(require("./escapes/SmartyEscaper.js"));var _PythonEscaper=_interopRequireDefault(require("./escapes/PythonEscaper.js"));var _SwiftEscaper=_interopRequireDefault(require("./escapes/SwiftEscaper.js"));var _URIEscaper=_interopRequireDefault(require("./escapes/URIEscaper.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}/*
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _CppEscaper=_interopRequireDefault(require("./escapes/CppEscaper.js"));var _CSharpEscaper=_interopRequireDefault(require("./escapes/CSharpEscaper.js"));var _JavaEscaper=_interopRequireDefault(require("./escapes/JavaEscaper.js"));var _JavascriptEscaper=_interopRequireDefault(require("./escapes/JavascriptEscaper.js"));var _JsonEscaper=_interopRequireDefault(require("./escapes/JsonEscaper.js"));var _RegexBasedEscaper=_interopRequireDefault(require("./escapes/RegexBasedEscaper.js"));var _PHPEscaper=_interopRequireDefault(require("./escapes/PHPEscaper.js"));var _ScalaEscaper=_interopRequireDefault(require("./escapes/ScalaEscaper.js"));var _SmartyEscaper=_interopRequireDefault(require("./escapes/SmartyEscaper.js"));var _PythonEscaper=_interopRequireDefault(require("./escapes/PythonEscaper.js"));var _SwiftEscaper=_interopRequireDefault(require("./escapes/SwiftEscaper.js"));var _URIEscaper=_interopRequireDefault(require("./escapes/URIEscaper.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}/*
|
|
2
2
|
* EscaperFactory.js - factory function that returns escaper instances
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2025 JEDLSoft
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
* Return an Escaper instance for the given style. The style must be one of the
|
|
20
20
|
* following:
|
|
21
21
|
* <ul>
|
|
22
|
+
* <li>cpp - escape for C++ regular strings</li>
|
|
23
|
+
* <li>cpp-char - escape for C++ character literals</li>
|
|
24
|
+
* <li>cpp-raw - escape for C++ raw strings</li>
|
|
25
|
+
* <li>cpp-wide - escape for C++ wide strings</li>
|
|
26
|
+
* <li>cpp-utf8 - escape for C++ UTF-8 strings</li>
|
|
27
|
+
* <li>cpp-utf16 - escape for C++ UTF-16 strings</li>
|
|
28
|
+
* <li>cpp-utf32 - escape for C++ UTF-32 strings</li>
|
|
22
29
|
* <li>csharp - escape for C#</li>
|
|
23
30
|
* <li>csharp-raw - escape for C# raw strings</li>
|
|
24
31
|
* <li>csharp-verbatim - escape for C# verbatim strings</li>
|
|
@@ -39,6 +46,10 @@
|
|
|
39
46
|
* <li>python-byte - escape for Python byte strings</li>
|
|
40
47
|
* <li>python-multi - escape for Python multi-line strings</li>
|
|
41
48
|
* <li>regexp - escape for regular expressions</li>
|
|
49
|
+
* <li>scala - escape for Scala regular strings</li>
|
|
50
|
+
* <li>scala-raw - escape for Scala raw strings</li>
|
|
51
|
+
* <li>scala-triple - escape for Scala triple-quoted strings</li>
|
|
52
|
+
* <li>scala-char - escape for Scala character literals</li>
|
|
42
53
|
* <li>smarty - escape for Smarty templates (default, same as smarty-double)</li>
|
|
43
54
|
* <li>smarty-double - escape for double-quoted Smarty strings</li>
|
|
44
55
|
* <li>smarty-single - escape for single-quoted Smarty strings</li>
|
|
@@ -52,6 +63,6 @@
|
|
|
52
63
|
* @param {string} style the style to use to determine how to escape
|
|
53
64
|
* @returns {Escaper} a new Escaper instance, or undefined if the style
|
|
54
65
|
* is not recognized
|
|
55
|
-
*/function escaperFactory(style){if(style==="html"){style="xml"}if(escaperCache[style]){return escaperCache[style]}switch(style){case"csharp":case"c#":case"csharp-raw":case"c#-raw":case"csharp-verbatim":case"c#-verbatim":escaperCache[style]=new _CSharpEscaper["default"](style);break;case"kotlin":case"kotlin-raw":case"java":case"java-raw":escaperCache[style]=new _JavaEscaper["default"](style);break;case"json":escaperCache[style]=new _JsonEscaper["default"];break;case"js":case"js-template":case"javascript":case"javascript-template":escaperCache[style]=new _JavascriptEscaper["default"](style);break;case"php":case"php-double":case"php-single":case"php-heredoc":case"php-nowdoc":escaperCache[style]=new _PHPEscaper["default"](style);break;case"smarty":case"smarty-double":case"smarty-single":escaperCache[style]=new _SmartyEscaper["default"](style);break;case"python":case"python-raw":case"python-byte":case"python-multi":escaperCache[style]=new _PythonEscaper["default"](style);break;case"swift":case"swift-multi":case"swift-extended":escaperCache[style]=new _SwiftEscaper["default"](style);break;case"uri":case"url":escaperCache[style]=new _URIEscaper["default"](style);break;default:try{escaperCache[style]=new _RegexBasedEscaper["default"](style)}catch(e){// if the style is not recognized, just return undefined
|
|
66
|
+
*/function escaperFactory(style){if(style==="html"){style="xml"}if(escaperCache[style]){return escaperCache[style]}switch(style){case"cpp":case"cpp-char":case"cpp-raw":case"cpp-wide":case"cpp-utf8":case"cpp-utf16":case"cpp-utf32":escaperCache[style]=new _CppEscaper["default"](style);break;case"csharp":case"c#":case"csharp-raw":case"c#-raw":case"csharp-verbatim":case"c#-verbatim":escaperCache[style]=new _CSharpEscaper["default"](style);break;case"kotlin":case"kotlin-raw":case"java":case"java-raw":escaperCache[style]=new _JavaEscaper["default"](style);break;case"json":escaperCache[style]=new _JsonEscaper["default"];break;case"js":case"js-template":case"javascript":case"javascript-template":escaperCache[style]=new _JavascriptEscaper["default"](style);break;case"php":case"php-double":case"php-single":case"php-heredoc":case"php-nowdoc":escaperCache[style]=new _PHPEscaper["default"](style);break;case"scala":case"scala-raw":case"scala-triple":case"scala-char":escaperCache[style]=new _ScalaEscaper["default"](style);break;case"smarty":case"smarty-double":case"smarty-single":escaperCache[style]=new _SmartyEscaper["default"](style);break;case"python":case"python-raw":case"python-byte":case"python-multi":escaperCache[style]=new _PythonEscaper["default"](style);break;case"swift":case"swift-multi":case"swift-extended":escaperCache[style]=new _SwiftEscaper["default"](style);break;case"uri":case"url":escaperCache[style]=new _URIEscaper["default"](style);break;default:try{escaperCache[style]=new _RegexBasedEscaper["default"](style)}catch(e){// if the style is not recognized, just return undefined
|
|
56
67
|
return undefined}break}return escaperCache[style]}var _default=exports["default"]=escaperFactory;module.exports=exports.default;
|
|
57
68
|
//# sourceMappingURL=EscaperFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EscaperFactory.js","names":["_CSharpEscaper","_interopRequireDefault","require","_JavaEscaper","_JavascriptEscaper","_JsonEscaper","_RegexBasedEscaper","_PHPEscaper","_SmartyEscaper","_PythonEscaper","_SwiftEscaper","_URIEscaper","e","__esModule","escaperCache","escaperFactory","style","CSharpEscaper","JavaEscaper","JsonEscaper","JavascriptEscaper","PHPEscaper","SmartyEscaper","PythonEscaper","SwiftEscaper","URIEscaper","RegexBasedEscaper","undefined","_default","exports","module","default"],"sources":["../src/EscaperFactory.js"],"sourcesContent":["/*\n * EscaperFactory.js - factory function that returns escaper instances\n *\n * Copyright © 2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport CSharpEscaper from \"./escapes/CSharpEscaper.js\";\nimport JavaEscaper from \"./escapes/JavaEscaper.js\";\nimport JavascriptEscaper from \"./escapes/JavascriptEscaper.js\";\nimport JsonEscaper from \"./escapes/JsonEscaper.js\";\nimport RegexBasedEscaper from \"./escapes/RegexBasedEscaper.js\";\nimport PHPEscaper from \"./escapes/PHPEscaper.js\";\nimport SmartyEscaper from \"./escapes/SmartyEscaper.js\";\nimport PythonEscaper from \"./escapes/PythonEscaper.js\";\nimport SwiftEscaper from \"./escapes/SwiftEscaper.js\";\nimport URIEscaper from \"./escapes/URIEscaper.js\";\n\nconst escaperCache = {};\n\n/**\n * Return an Escaper instance for the given style. The style must be one of the\n * following:\n * <ul>\n * <li>csharp - escape for C#</li>\n * <li>csharp-raw - escape for C# raw strings</li>\n * <li>csharp-verbatim - escape for C# verbatim strings</li>\n * <li>java - escape for Java</li>\n * <li>java-raw - escape for JSON raw strings</li>\n * <li>js - escape for JavaScript</li>\n * <li>javascript-template - escape for JavaScript template strings</li>\n * <li>json - escape for JSON</li>\n * <li>kotlin - escape for Kotlin</li>\n * <li>kotlin-raw - escape for Kotlin raw strings</li>\n * <li>php - escape for PHP (default, same as php-double)</li>\n * <li>php-double - escape for double-quoted PHP strings</li>\n * <li>php-single - escape for single-quoted PHP strings</li>\n * <li>php-heredoc - escape for PHP heredoc strings</li>\n * <li>php-nowdoc - escape for PHP nowdoc strings</li>\n * <li>python - escape for Python regular strings (default)</li>\n * <li>python-raw - escape for Python raw strings</li>\n * <li>python-byte - escape for Python byte strings</li>\n * <li>python-multi - escape for Python multi-line strings</li>\n * <li>regexp - escape for regular expressions</li>\n * <li>smarty - escape for Smarty templates (default, same as smarty-double)</li>\n * <li>smarty-double - escape for double-quoted Smarty strings</li>\n * <li>smarty-single - escape for single-quoted Smarty strings</li>\n * <li>swift - escape for regular Swift strings</li>\n * <li>swift-multi - escape for Swift multi-line strings</li>\n * <li>swift-extended - escape for Swift extended strings</li>\n * <li>uri - escape for URLs and URIs</li>\n * <li>xml - escape for XML text, including HTML</li>\n * <li>xml-attr - escape for XML attributes, including HTML</li>\n * </ul>\n * @param {string} style the style to use to determine how to escape\n * @returns {Escaper} a new Escaper instance, or undefined if the style\n * is not recognized\n */\nfunction escaperFactory(style) {\n if (style === \"html\") {\n style = \"xml\";\n }\n if (escaperCache[style]) {\n return escaperCache[style];\n }\n switch (style) {\n case 'csharp':\n case 'c#':\n case 'csharp-raw':\n case 'c#-raw':\n case 'csharp-verbatim':\n case 'c#-verbatim':\n escaperCache[style] = new CSharpEscaper(style);\n break;\n\n case 'kotlin':\n case 'kotlin-raw':\n case 'java':\n case 'java-raw':\n escaperCache[style] = new JavaEscaper(style);\n break;\n\n case 'json':\n escaperCache[style] = new JsonEscaper();\n break;\n\n case 'js':\n case 'js-template':\n case 'javascript':\n case 'javascript-template':\n escaperCache[style] = new JavascriptEscaper(style);\n break;\n\n case 'php':\n case 'php-double':\n case 'php-single':\n case 'php-heredoc':\n case 'php-nowdoc':\n escaperCache[style] = new PHPEscaper(style);\n break;\n\n case 'smarty':\n case 'smarty-double':\n case 'smarty-single':\n escaperCache[style] = new SmartyEscaper(style);\n break;\n\n case 'python':\n case 'python-raw':\n case 'python-byte':\n case 'python-multi':\n escaperCache[style] = new PythonEscaper(style);\n break;\n\n case 'swift':\n case 'swift-multi':\n case 'swift-extended':\n escaperCache[style] = new SwiftEscaper(style);\n break;\n\n case 'uri':\n case 'url':\n escaperCache[style] = new URIEscaper(style);\n break;\n\n default:\n try {\n escaperCache[style] = new RegexBasedEscaper(style);\n } catch (e) {\n // if the style is not recognized, just return undefined\n return undefined;\n }\n break;\n }\n return escaperCache[style];\n}\n\nexport default escaperFactory;"],"mappings":"gGAkBA,IAAAA,cAAA,CAAAC,sBAAA,CAAAC,OAAA,gCACA,IAAAC,YAAA,CAAAF,sBAAA,CAAAC,OAAA,8BACA,IAAAE,kBAAA,CAAAH,sBAAA,CAAAC,OAAA,oCACA,IAAAG,YAAA,CAAAJ,sBAAA,CAAAC,OAAA,8BACA,IAAAI,kBAAA,CAAAL,sBAAA,CAAAC,OAAA,oCACA,IAAAK,WAAA,CAAAN,sBAAA,CAAAC,OAAA,6BACA,IAAAM,cAAA,CAAAP,sBAAA,CAAAC,OAAA,gCACA,IAAAO,cAAA,CAAAR,sBAAA,CAAAC,OAAA,gCACA,IAAAQ,aAAA,CAAAT,sBAAA,CAAAC,OAAA,+BACA,IAAAS,WAAA,CAAAV,sBAAA,CAAAC,OAAA,6BAAiD,SAAAD,uBAAAW,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,EA3BjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAYA,GAAM,CAAAE,YAAY,CAAG,CAAC,CAAC,CAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,cAAcA,CAACC,KAAK,CAAE,CAC3B,GAAIA,KAAK,GAAK,MAAM,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AK,gBAAgB,CACjBF,YAAY,CAACE,KAAK,CAAC,CAAG,GAAI,CAAAQ,wBAAY,CAACR,KAAK,CAAC,CAC7C,MAEJ,IAAK,KAAK,CACV,IAAK,KAAK,CACNF,YAAY,CAACE,KAAK,CAAC,CAAG,GAAI,CAAAS,sBAAU,CAACT,KAAK,CAAC,CAC3C,MAEJ,QACI,GAAI,CACAF,YAAY,CAACE,KAAK,CAAC,CAAG,GAAI,CAAAU,6BAAiB,CAACV,KAAK,CACrD,CAAE,MAAOJ,CAAC,CAAE,CACR;AACA,MAAO,CAAAe,SACX,CACA,KACR,CACA,MAAO,CAAAb,YAAY,CAACE,KAAK,CAC7B,CAAC,IAAAY,QAAA,CAAAC,OAAA,YAEcd,cAAc,CAAAe,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"EscaperFactory.js","names":["_CppEscaper","_interopRequireDefault","require","_CSharpEscaper","_JavaEscaper","_JavascriptEscaper","_JsonEscaper","_RegexBasedEscaper","_PHPEscaper","_ScalaEscaper","_SmartyEscaper","_PythonEscaper","_SwiftEscaper","_URIEscaper","e","__esModule","escaperCache","escaperFactory","style","CppEscaper","CSharpEscaper","JavaEscaper","JsonEscaper","JavascriptEscaper","PHPEscaper","ScalaEscaper","SmartyEscaper","PythonEscaper","SwiftEscaper","URIEscaper","RegexBasedEscaper","undefined","_default","exports","module","default"],"sources":["../src/EscaperFactory.js"],"sourcesContent":["/*\n * EscaperFactory.js - factory function that returns escaper instances\n *\n * Copyright © 2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport CppEscaper from \"./escapes/CppEscaper.js\";\nimport CSharpEscaper from \"./escapes/CSharpEscaper.js\";\nimport JavaEscaper from \"./escapes/JavaEscaper.js\";\nimport JavascriptEscaper from \"./escapes/JavascriptEscaper.js\";\nimport JsonEscaper from \"./escapes/JsonEscaper.js\";\nimport RegexBasedEscaper from \"./escapes/RegexBasedEscaper.js\";\nimport PHPEscaper from \"./escapes/PHPEscaper.js\";\nimport ScalaEscaper from \"./escapes/ScalaEscaper.js\";\nimport SmartyEscaper from \"./escapes/SmartyEscaper.js\";\nimport PythonEscaper from \"./escapes/PythonEscaper.js\";\nimport SwiftEscaper from \"./escapes/SwiftEscaper.js\";\nimport URIEscaper from \"./escapes/URIEscaper.js\";\n\nconst escaperCache = {};\n\n/**\n * Return an Escaper instance for the given style. The style must be one of the\n * following:\n * <ul>\n * <li>cpp - escape for C++ regular strings</li>\n * <li>cpp-char - escape for C++ character literals</li>\n * <li>cpp-raw - escape for C++ raw strings</li>\n * <li>cpp-wide - escape for C++ wide strings</li>\n * <li>cpp-utf8 - escape for C++ UTF-8 strings</li>\n * <li>cpp-utf16 - escape for C++ UTF-16 strings</li>\n * <li>cpp-utf32 - escape for C++ UTF-32 strings</li>\n * <li>csharp - escape for C#</li>\n * <li>csharp-raw - escape for C# raw strings</li>\n * <li>csharp-verbatim - escape for C# verbatim strings</li>\n * <li>java - escape for Java</li>\n * <li>java-raw - escape for JSON raw strings</li>\n * <li>js - escape for JavaScript</li>\n * <li>javascript-template - escape for JavaScript template strings</li>\n * <li>json - escape for JSON</li>\n * <li>kotlin - escape for Kotlin</li>\n * <li>kotlin-raw - escape for Kotlin raw strings</li>\n * <li>php - escape for PHP (default, same as php-double)</li>\n * <li>php-double - escape for double-quoted PHP strings</li>\n * <li>php-single - escape for single-quoted PHP strings</li>\n * <li>php-heredoc - escape for PHP heredoc strings</li>\n * <li>php-nowdoc - escape for PHP nowdoc strings</li>\n * <li>python - escape for Python regular strings (default)</li>\n * <li>python-raw - escape for Python raw strings</li>\n * <li>python-byte - escape for Python byte strings</li>\n * <li>python-multi - escape for Python multi-line strings</li>\n * <li>regexp - escape for regular expressions</li>\n * <li>scala - escape for Scala regular strings</li>\n * <li>scala-raw - escape for Scala raw strings</li>\n * <li>scala-triple - escape for Scala triple-quoted strings</li>\n * <li>scala-char - escape for Scala character literals</li>\n * <li>smarty - escape for Smarty templates (default, same as smarty-double)</li>\n * <li>smarty-double - escape for double-quoted Smarty strings</li>\n * <li>smarty-single - escape for single-quoted Smarty strings</li>\n * <li>swift - escape for regular Swift strings</li>\n * <li>swift-multi - escape for Swift multi-line strings</li>\n * <li>swift-extended - escape for Swift extended strings</li>\n * <li>uri - escape for URLs and URIs</li>\n * <li>xml - escape for XML text, including HTML</li>\n * <li>xml-attr - escape for XML attributes, including HTML</li>\n * </ul>\n * @param {string} style the style to use to determine how to escape\n * @returns {Escaper} a new Escaper instance, or undefined if the style\n * is not recognized\n */\nfunction escaperFactory(style) {\n if (style === \"html\") {\n style = \"xml\";\n }\n if (escaperCache[style]) {\n return escaperCache[style];\n }\n switch (style) {\n case 'cpp':\n case 'cpp-char':\n case 'cpp-raw':\n case 'cpp-wide':\n case 'cpp-utf8':\n case 'cpp-utf16':\n case 'cpp-utf32':\n escaperCache[style] = new CppEscaper(style);\n break;\n\n case 'csharp':\n case 'c#':\n case 'csharp-raw':\n case 'c#-raw':\n case 'csharp-verbatim':\n case 'c#-verbatim':\n escaperCache[style] = new CSharpEscaper(style);\n break;\n\n case 'kotlin':\n case 'kotlin-raw':\n case 'java':\n case 'java-raw':\n escaperCache[style] = new JavaEscaper(style);\n break;\n\n case 'json':\n escaperCache[style] = new JsonEscaper();\n break;\n\n case 'js':\n case 'js-template':\n case 'javascript':\n case 'javascript-template':\n escaperCache[style] = new JavascriptEscaper(style);\n break;\n\n case 'php':\n case 'php-double':\n case 'php-single':\n case 'php-heredoc':\n case 'php-nowdoc':\n escaperCache[style] = new PHPEscaper(style);\n break;\n\n case 'scala':\n case 'scala-raw':\n case 'scala-triple':\n case 'scala-char':\n escaperCache[style] = new ScalaEscaper(style);\n break;\n\n case 'smarty':\n case 'smarty-double':\n case 'smarty-single':\n escaperCache[style] = new SmartyEscaper(style);\n break;\n\n case 'python':\n case 'python-raw':\n case 'python-byte':\n case 'python-multi':\n escaperCache[style] = new PythonEscaper(style);\n break;\n\n case 'swift':\n case 'swift-multi':\n case 'swift-extended':\n escaperCache[style] = new SwiftEscaper(style);\n break;\n\n case 'uri':\n case 'url':\n escaperCache[style] = new URIEscaper(style);\n break;\n\n default:\n try {\n escaperCache[style] = new RegexBasedEscaper(style);\n } catch (e) {\n // if the style is not recognized, just return undefined\n return undefined;\n }\n break;\n }\n return escaperCache[style];\n}\n\nexport default escaperFactory;"],"mappings":"gGAkBA,IAAAA,WAAA,CAAAC,sBAAA,CAAAC,OAAA,6BACA,IAAAC,cAAA,CAAAF,sBAAA,CAAAC,OAAA,gCACA,IAAAE,YAAA,CAAAH,sBAAA,CAAAC,OAAA,8BACA,IAAAG,kBAAA,CAAAJ,sBAAA,CAAAC,OAAA,oCACA,IAAAI,YAAA,CAAAL,sBAAA,CAAAC,OAAA,8BACA,IAAAK,kBAAA,CAAAN,sBAAA,CAAAC,OAAA,oCACA,IAAAM,WAAA,CAAAP,sBAAA,CAAAC,OAAA,6BACA,IAAAO,aAAA,CAAAR,sBAAA,CAAAC,OAAA,+BACA,IAAAQ,cAAA,CAAAT,sBAAA,CAAAC,OAAA,gCACA,IAAAS,cAAA,CAAAV,sBAAA,CAAAC,OAAA,gCACA,IAAAU,aAAA,CAAAX,sBAAA,CAAAC,OAAA,+BACA,IAAAW,WAAA,CAAAZ,sBAAA,CAAAC,OAAA,6BAAiD,SAAAD,uBAAAa,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,EA7BjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AA","ignoreList":[]}
|
package/lib/Resource.js
CHANGED
|
@@ -54,7 +54,10 @@
|
|
|
54
54
|
* property, which is the path to the source file that this resource was extracted from. This property
|
|
55
55
|
* is only used for resources from resource files, such as Android string.xml files or xliff files.
|
|
56
56
|
* Otherwise, the property is undefined.
|
|
57
|
-
|
|
57
|
+
* @param {Object|undefined} [props.metadata] the metadata of the resource or undefined for no metadata.
|
|
58
|
+
* This can be any arbitrary object of any depth, as long as the values of properties are all static.
|
|
59
|
+
* It is up to the parsers to parse this and serializers to serialize this appropriately.
|
|
60
|
+
*/function Resource(props){_classCallCheck(this,Resource);/**
|
|
58
61
|
* The type of this resource instance.
|
|
59
62
|
* @type {String | undefined}
|
|
60
63
|
*/_defineProperty(this,"resType",void 0);/**
|
|
@@ -72,7 +75,7 @@ this.formatted=props.formatted;// for Android layout resources
|
|
|
72
75
|
this.comment=props.comment;this.origin=props.origin||"source";this.dnt=props.dnt;this.datatype=props.datatype;this.sourceHash=props.sourceHash;this.localize=typeof props.localize==="boolean"?props.localize:true;// some files have resources we do not want to localize/translate
|
|
73
76
|
this.flavor=props.flavor;this.index=props.index;this.location=props.location;// optional location of the transunits in the xml file
|
|
74
77
|
this.resfile=props.resfile;// optional resource file path
|
|
75
|
-
}this.instances=[];this.pathName=this.pathName||"";this.dirty=false}/**
|
|
78
|
+
this.metadata=props.metadata||undefined}this.instances=[];this.pathName=this.pathName||"";this.dirty=false}/**
|
|
76
79
|
* Return the project that this resource was found in.
|
|
77
80
|
*
|
|
78
81
|
* @returns {string} the project of this resource
|
|
@@ -111,6 +114,13 @@ this.resfile=props.resfile;// optional resource file path
|
|
|
111
114
|
* @returns {String|undefined} the context of this resource, or undefined if there
|
|
112
115
|
* is no context.
|
|
113
116
|
*/},{key:"getContext",value:function getContext(){return this.context}/**
|
|
117
|
+
* Get the metadata of this resource.
|
|
118
|
+
*
|
|
119
|
+
* @returns {Object|undefined} the metadata of this resource.
|
|
120
|
+
*/},{key:"getMetadata",value:function getMetadata(){return this.metadata}/**
|
|
121
|
+
* Set the metadata of this resource.
|
|
122
|
+
* @param {Object|undefined} data the metadata of this resource.
|
|
123
|
+
*/},{key:"setMetadata",value:function setMetadata(data){this.metadata=data}/**
|
|
114
124
|
* Return the source locale of this resource, or undefined if there
|
|
115
125
|
* is no context or the locale is the same as the project's source locale.
|
|
116
126
|
* @returns {String|undefined} the locale of this resource, or undefined if there
|
package/lib/Resource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.js","names":["validStates","translationImportant","Resource","props","_classCallCheck","_defineProperty","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","state","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","resfile","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setProject","setState","getPath","getComment","setComment","getDNT","setDNT","flag","TypeError","getId","getOrigin","getLocalize","getFlavor","getResFile","same","other","i","length","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","hashKey","cleanHashKey","_default","exports","module","default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst validStates = {\n \"new\":true,\n \"translated\":true,\n \"accepted\":true\n}\n\nconst translationImportant = [\n \"context\",\n \"datatype\",\n \"dnt\",\n \"flavor\",\n \"project\",\n \"reskey\",\n \"resType\",\n \"sourceLocale\",\n \"targetLocale\"\n];\n\n\n/**\n * @class Represents a resource from a resource file or\n * extracted from the code.\n * @abstract\n */\nclass Resource {\n /**\n * The type of this resource instance.\n * @type {String | undefined}\n */\n resType;\n\n /**\n * The source string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n source;\n\n /**\n * The target string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n target;\n\n /**\n * The resource file that this resource was loaded from.\n * @type {string|undefined}\n */\n resfile;\n\n /**\n * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n * @param {string} [props.project] the project that this resource is in\n * @param {string} [props.context] The context for this resource,\n * such as \"landscape mode\", or \"7200dp\", which differentiates it\n * from the base resource that has no special context. The default\n * if this property is not specified is undefined, meaning no\n * context.\n * @param {string} [props.sourceLocale] the locale of the source resource.\n * @param {string} [props.targetLocale] the locale of the target resource.\n * @param {string} [props.key] the unique key of this string, which should include the context\n * of the string\n * @param {string} [props.pathName] pathName to the file where the string was extracted from\n * @param {boolean} [props.autoKey] true if the key was generated based on the source text\n * @param {string} [props.state] current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * @param {string} [props.id] the id of the current resource\n * @param {string} [props.comment] the comment (translator's note) of this resource\n * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false\n * @param {string} [props.datatype] the type of file that this resource came from\n * @param {string} [props.flavor] the \"flavor\" of this string, if any. (Android)\n * @param {Location} [props.location] the location in the file given in pathName where this this resource\n * is located\n * @param {string | undefined} [props.resfile] if this resource was extracted from a resource file, this\n * is the path to the resource file that contains this resource. This is different from the pathName\n * property, which is the path to the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android string.xml files or xliff files.\n * Otherwise, the property is undefined.\n */\n constructor(props) {\n if (this.constructor === Resource) {\n throw new Error(\"Cannot instantiate abstract class Resource!\");\n }\n\n this.autoKey = false;\n\n if (props) {\n this.project = props.project;\n this.context = props.context || undefined; // avoid the empty string\n this.sourceLocale = props.sourceLocale || props.locale;\n this.targetLocale = props.targetLocale;\n this.reskey = props.key || props.reskey;\n this.pathName = props.pathName;\n this.autoKey = typeof(props.autoKey) === \"boolean\" ? props.autoKey : false;\n this.state = props.state || undefined;\n this.id = props.id; // the database id\n this.formatted = props.formatted; // for Android layout resources\n this.comment = props.comment;\n this.origin = props.origin || \"source\";\n this.dnt = props.dnt;\n this.datatype = props.datatype;\n this.sourceHash = props.sourceHash;\n this.localize = typeof(props.localize) === \"boolean\" ? props.localize : true; // some files have resources we do not want to localize/translate\n this.flavor = props.flavor;\n this.index = props.index;\n this.location = props.location; // optional location of the transunits in the xml file\n this.resfile = props.resfile; // optional resource file path\n }\n\n this.instances = [];\n this.pathName = this.pathName || \"\";\n this.dirty = false;\n }\n\n /**\n * Return the project that this resource was found in.\n *\n * @returns {string} the project of this resource\n */\n getProject() {\n return this.project;\n }\n\n /**\n * Return the unique key of this resource.\n *\n * @returns {string} the unique key of this resource\n */\n getKey() {\n return this.reskey;\n }\n\n /**\n * Return the source string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object} the source string or\n * strings of this resource\n */\n getSource() {\n return this.source;\n }\n\n /**\n * Return the target string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object|undefined} the source string or\n * strings of this resource\n */\n getTarget() {\n return this.target;\n }\n\n /**\n * Return the resource type of this resource. This is one of\n * string, array, or plural.\n *\n * @returns {string} the resource type of this resource\n */\n getType() {\n return this.resType || \"string\";\n }\n\n /**\n * Return the data type of this resource.\n *\n * @returns {string} the data type of this resource\n */\n getDataType() {\n return this.datatype;\n }\n\n /**\n * Return true if the key of this resource was automatically generated,\n * and false if it was an explicit key.\n *\n * @returns {boolean} true if the key of this string was auto generated,\n * false otherwise\n */\n getAutoKey() {\n return this.autoKey;\n }\n\n /**\n * Return the context of this resource, or undefined if there\n * is no context.\n * @returns {String|undefined} the context of this resource, or undefined if there\n * is no context.\n */\n getContext() {\n return this.context;\n }\n\n /**\n * Return the source locale of this resource, or undefined if there\n * is no context or the locale is the same as the project's source locale.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getSourceLocale() {\n return this.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source locale of this resource.\n * @param {string} locale the source locale of this resource\n */\n setSourceLocale(locale) {\n this.sourceLocale = locale || this.sourceLocale;\n this.dirty = true;\n }\n\n /**\n * Return the target locale of this resource, or undefined if the resource\n * is a source-only resource.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getTargetLocale() {\n return this.targetLocale;\n }\n\n /**\n * Set the target locale of this resource.\n * @param {string} locale the target locale of this resource\n */\n setTargetLocale(locale) {\n this.targetLocale = locale || this.targetLocale;\n this.dirty = true;\n }\n\n /**\n * Return the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @returns {string} the state of this resource\n */\n getState() {\n return this.state;\n }\n\n /**\n * Set the project of this resource. This is a string that gives the\n * id of the project for this resource.\n *\n * @param {string} project the project name to set for this resource\n */\n setProject(project) {\n this.project = project;\n this.dirty = true;\n }\n\n /**\n * Set the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @param {string} state the state of this resource\n */\n setState(state) {\n this.state = validStates[state] ? state : this.state;\n this.dirty = true;\n }\n\n /**\n * Return the original path to the file from which this resource was\n * originally extracted.\n *\n * @returns {string} the path to the file containing this resource\n */\n getPath() {\n return this.pathName;\n }\n\n /**\n * Return the translator's comment for this resource if there is\n * one, or undefined if not.\n *\n * @returns {String|undefined} the translator's comment for this resource\n * if the engineer put one in the code\n */\n getComment() {\n return this.comment;\n }\n\n /**\n * Set the translator's comment for this resource.\n *\n * @param {String|undefined} comment the translator's comment to set. Use\n * undefined to clear the comment\n */\n setComment(comment) {\n this.comment = comment;\n this.dirty = true;\n }\n\n /**\n * Get the \"do not translate\" flag for this resource.\n *\n * @returns {boolean} true means that the current resource should not\n * be translated, and false means it will be translated.\n */\n getDNT() {\n return typeof(this.dnt) === 'boolean' ? this.dnt : false;\n }\n\n /**\n * Set the \"do not translate\" flag for this resource.\n *\n * @param {boolean} flag set the dnt flag to this value\n */\n setDNT(flag) {\n if (typeof(flag) !== 'boolean') {\n throw new TypeError('value must be boolean');\n }\n this.dnt = flag;\n this.dirty = true;\n }\n\n /**\n * Return the database id if this resource has previously been saved in the\n * database.\n *\n * @returns {number|undefined} the database id if this resource has previously\n * been saved in the database, or undefined if it is has not\n */\n getId() {\n return this.id;\n }\n\n /**\n * Return the origin of this resource. The origin may be either the string\n * \"source\" or \"target\". Source origin resources are ones that are extracted\n * from the source code, whereas target ones are translations from the\n * translators.\n *\n * @returns {string} the origin of this resource\n */\n getOrigin() {\n return this.origin;\n }\n\n /**\n * Return the localize flag of this resource.\n * This flag indicates whether we should look up a translation for this resource.\n * When false, we should simply substitute the source back\n *\n * @returns {Boolean} the localize flag of this resource\n */\n getLocalize() {\n return this.localize;\n }\n\n /**\n * Return the name of the flavor for this resource, or undefined\n * for the \"main\" or default flavor.\n *\n * @return {String|undefined} the name of the flavor for this\n * resource or undefined for the main or default flavor\n */\n getFlavor() {\n return this.flavor;\n }\n\n /**\n * Return the path to the resource file that contains this resource.\n * This is different from the pathName property, which is the path to\n * the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android\n * string.xml files or xliff files. Otherwise, the property is undefined.\n *\n * @returns {string|undefined} the path to the resource file that contains\n * this resource, or undefined if this resource was not extracted from\n * a resource file\n */\n getResFile() {\n return this.resfile;\n }\n\n /**\n * Return true if the other resource represents the same resource as\n * the current one. The project, context, locale, key, flavor, and type must\n * match. Other fields such as the pathName, state, and comment fields are\n * ignored as minor variations.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n same(other) {\n if (!other) return false;\n\n const props = [\"project\", \"context\", \"sourceLocale\", \"targetLocale\", \"reskey\", \"resType\", \"flavor\"];\n for (let i = 0; i < props.length; i++) {\n if (this[props[i]] !== other[props[i]]) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Escape text for writing to a database in a SQL command. This puts single\n * quotes around the string, and makes sure that all single quotes within\n * the string are escaped.\n *\n * @param {Object} str the item to escape\n * @returns {string} the escaped string\n */\n escapeText(str) {\n switch (typeof(str)) {\n case \"string\":\n // unescape first, then re-escape to make everything consistent\n return \"'\" + str.replace(/\\\\'/g, \"'\").replace(/'/g, \"\\\\'\") + \"'\";\n case \"undefined\":\n return \"NULL\";\n case \"boolean\":\n return str ? \"TRUE\" : \"FALSE\";\n default:\n if (str === null) {\n return \"NULL\";\n }\n return str.toString();\n }\n }\n\n /**\n * Add an instance of the same resource to the list of\n * instances. If the given resource matches the\n * current instance in all properties that affect the\n * possible translation, and differs from the current\n * instance by some property that does not affect\n * its translation, it will be added as an instance of\n * the same string. The following properties affect the\n * translation:\n *\n * <ul>\n * <li>context</li>\n * <li>datatype</li>\n * <li>dnt</li>\n * <li>flavor</li>\n * <li>project</li>\n * <li>reskey</li>\n * <li>resType</li>\n * <li>source</li>\n * <li>sourceHash</li>\n * <li>sourceArray</li>\n * <li>sourceLocale</li>\n * <li>targetLocale</li>\n * </ul>\n *\n * Differences in other properties, such as \"comment\" or\n * \"origin\" are considered instances of the same resource.\n *\n * If this method is given a resource that differs from\n * the current one by one of the above translation affecting\n * properties, it is not added to the list of instances. This\n * can be checked easily by calling the isInstance() method.\n *\n * @param {Resource} resource an instance of the current resource to\n * record\n * @returns {boolean} true if the instance was added, and\n * and false otherwise\n */\n addInstance(resource) {\n if (!this.isInstance(resource)) {\n return false;\n }\n const unique = this !== resource && this.instances.every(res => {\n return res !== resource;\n });\n if (!unique) {\n return false;\n }\n this.instances.push(resource);\n this.dirty = true;\n return true;\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource. This method returns true if all properties which\n * affect the possible translation match between the given and\n * the current resource.\n *\n * @param {Resource} resource a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (typeof(resource) !== 'object' || !(resource instanceof Resource)) {\n return false;\n }\n\n return translationImportant.every(prop => {\n return this[prop] === resource[prop];\n });\n }\n\n /**\n * Return the list of instances of the current resource.\n *\n * @returns {Array.<Resource>} the list of instances of\n * the current resource\n */\n getInstances() {\n return this.instances;\n }\n\n /**\n * Return true if this instance has been modified since its creation, and false otherwise.\n */\n isDirty() {\n return this.dirty\n }\n\n /**\n * Clear the dirty flag. This is used for example when the Resource was\n * written to disk and the modifications are already recorded, allowing\n * new modifications later.\n */\n clearDirty() {\n this.dirty = false;\n }\n\n /**\n * Return the location of the resource instance in the original file where it was read\n * from. This is usually an object containing a line and a char property which gives the\n * line number and character within that line where the representation of the resource\n * instance starts.\n *\n * @returns {Location|undefined} the location information, or undefined if no location\n * information is available\n */\n getLocation() {\n return this.location?.getLocation();\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @abstract\n * @returns {string} a unique hash key for this resource\n */\n hashKey() {\n throw new Error(\"hashKey() not implemented\");\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @abstract\n * @returns {string} a unique hash key for this resource with a cleaned string\n */\n cleanHashKey() {\n throw new Error(\"cleanHashKey() not implemented\");\n }\n}\n\nexport default Resource;\n"],"mappings":"k0CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,GAAM,CAAAA,WAAW,CAAG,CAChB,KAAK,CAAC,IAAI,CACV,YAAY,CAAC,IAAI,CACjB,UAAU,CAAC,IACf,CAAC,CAED,GAAM,CAAAC,oBAAoB,CAAG,CACzB,SAAS,CACT,UAAU,CACV,KAAK,CACL,QAAQ,CACR,SAAS,CACT,QAAQ,CACR,SAAS,CACT,cAAc,CACd,cAAc,CACjB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tC,CAEA;AACJ;AACA;AACA;AACA;AACA,OALI,GAAAtE,GAAA,WAAAkB,KAAA,CAMA,SAAAsD,OAAOA,CAAA,CAAG,CACN,KAAM,IAAI,CAAAjF,KAAK,CAAC,2BAA2B,CAC/C,CAEA;AACJ;AACA;AACA;AACA;AACA,OALI,GAAAS,GAAA,gBAAAkB,KAAA,CAMA,SAAAuD,YAAYA,CAAA,CAAG,CACX,KAAM,IAAI,CAAAlF,KAAK,CAAC,gCAAgC,CACpD,CAAC,WAAAmF,QAAA,CAAAC,OAAA,YAGUzF,QAAQ,CAAA0F,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Resource.js","names":["validStates","translationImportant","Resource","props","_classCallCheck","_defineProperty","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","state","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","resfile","metadata","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getMetadata","setMetadata","data","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setProject","setState","getPath","getComment","setComment","getDNT","setDNT","flag","TypeError","getId","getOrigin","getLocalize","getFlavor","getResFile","same","other","i","length","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","hashKey","cleanHashKey","_default","exports","module","default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst validStates = {\n \"new\":true,\n \"translated\":true,\n \"accepted\":true\n}\n\nconst translationImportant = [\n \"context\",\n \"datatype\",\n \"dnt\",\n \"flavor\",\n \"project\",\n \"reskey\",\n \"resType\",\n \"sourceLocale\",\n \"targetLocale\"\n];\n\n\n/**\n * @class Represents a resource from a resource file or\n * extracted from the code.\n * @abstract\n */\nclass Resource {\n /**\n * The type of this resource instance.\n * @type {String | undefined}\n */\n resType;\n\n /**\n * The source string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n source;\n\n /**\n * The target string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n target;\n\n /**\n * The resource file that this resource was loaded from.\n * @type {string|undefined}\n */\n resfile;\n\n /**\n * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n * @param {string} [props.project] the project that this resource is in\n * @param {string} [props.context] The context for this resource,\n * such as \"landscape mode\", or \"7200dp\", which differentiates it\n * from the base resource that has no special context. The default\n * if this property is not specified is undefined, meaning no\n * context.\n * @param {string} [props.sourceLocale] the locale of the source resource.\n * @param {string} [props.targetLocale] the locale of the target resource.\n * @param {string} [props.key] the unique key of this string, which should include the context\n * of the string\n * @param {string} [props.pathName] pathName to the file where the string was extracted from\n * @param {boolean} [props.autoKey] true if the key was generated based on the source text\n * @param {string} [props.state] current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * @param {string} [props.id] the id of the current resource\n * @param {string} [props.comment] the comment (translator's note) of this resource\n * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false\n * @param {string} [props.datatype] the type of file that this resource came from\n * @param {string} [props.flavor] the \"flavor\" of this string, if any. (Android)\n * @param {Location} [props.location] the location in the file given in pathName where this this resource\n * is located\n * @param {string | undefined} [props.resfile] if this resource was extracted from a resource file, this\n * is the path to the resource file that contains this resource. This is different from the pathName\n * property, which is the path to the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android string.xml files or xliff files.\n * Otherwise, the property is undefined.\n * @param {Object|undefined} [props.metadata] the metadata of the resource or undefined for no metadata.\n * This can be any arbitrary object of any depth, as long as the values of properties are all static.\n * It is up to the parsers to parse this and serializers to serialize this appropriately.\n */\n constructor(props) {\n if (this.constructor === Resource) {\n throw new Error(\"Cannot instantiate abstract class Resource!\");\n }\n\n this.autoKey = false;\n\n if (props) {\n this.project = props.project;\n this.context = props.context || undefined; // avoid the empty string\n this.sourceLocale = props.sourceLocale || props.locale;\n this.targetLocale = props.targetLocale;\n this.reskey = props.key || props.reskey;\n this.pathName = props.pathName;\n this.autoKey = typeof(props.autoKey) === \"boolean\" ? props.autoKey : false;\n this.state = props.state || undefined;\n this.id = props.id; // the database id\n this.formatted = props.formatted; // for Android layout resources\n this.comment = props.comment;\n this.origin = props.origin || \"source\";\n this.dnt = props.dnt;\n this.datatype = props.datatype;\n this.sourceHash = props.sourceHash;\n this.localize = typeof(props.localize) === \"boolean\" ? props.localize : true; // some files have resources we do not want to localize/translate\n this.flavor = props.flavor;\n this.index = props.index;\n this.location = props.location; // optional location of the transunits in the xml file\n this.resfile = props.resfile; // optional resource file path\n this.metadata = props.metadata || undefined;\n }\n\n this.instances = [];\n this.pathName = this.pathName || \"\";\n this.dirty = false;\n }\n\n /**\n * Return the project that this resource was found in.\n *\n * @returns {string} the project of this resource\n */\n getProject() {\n return this.project;\n }\n\n /**\n * Return the unique key of this resource.\n *\n * @returns {string} the unique key of this resource\n */\n getKey() {\n return this.reskey;\n }\n\n /**\n * Return the source string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object} the source string or\n * strings of this resource\n */\n getSource() {\n return this.source;\n }\n\n /**\n * Return the target string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object|undefined} the source string or\n * strings of this resource\n */\n getTarget() {\n return this.target;\n }\n\n /**\n * Return the resource type of this resource. This is one of\n * string, array, or plural.\n *\n * @returns {string} the resource type of this resource\n */\n getType() {\n return this.resType || \"string\";\n }\n\n /**\n * Return the data type of this resource.\n *\n * @returns {string} the data type of this resource\n */\n getDataType() {\n return this.datatype;\n }\n\n /**\n * Return true if the key of this resource was automatically generated,\n * and false if it was an explicit key.\n *\n * @returns {boolean} true if the key of this string was auto generated,\n * false otherwise\n */\n getAutoKey() {\n return this.autoKey;\n }\n\n /**\n * Return the context of this resource, or undefined if there\n * is no context.\n * @returns {String|undefined} the context of this resource, or undefined if there\n * is no context.\n */\n getContext() {\n return this.context;\n }\n\n /**\n * Get the metadata of this resource.\n *\n * @returns {Object|undefined} the metadata of this resource.\n */\n getMetadata() {\n return this.metadata;\n }\n\n /**\n * Set the metadata of this resource.\n * @param {Object|undefined} data the metadata of this resource.\n */\n setMetadata(data) {\n this.metadata = data;\n }\n\n /**\n * Return the source locale of this resource, or undefined if there\n * is no context or the locale is the same as the project's source locale.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getSourceLocale() {\n return this.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source locale of this resource.\n * @param {string} locale the source locale of this resource\n */\n setSourceLocale(locale) {\n this.sourceLocale = locale || this.sourceLocale;\n this.dirty = true;\n }\n\n /**\n * Return the target locale of this resource, or undefined if the resource\n * is a source-only resource.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getTargetLocale() {\n return this.targetLocale;\n }\n\n /**\n * Set the target locale of this resource.\n * @param {string} locale the target locale of this resource\n */\n setTargetLocale(locale) {\n this.targetLocale = locale || this.targetLocale;\n this.dirty = true;\n }\n\n /**\n * Return the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @returns {string} the state of this resource\n */\n getState() {\n return this.state;\n }\n\n /**\n * Set the project of this resource. This is a string that gives the\n * id of the project for this resource.\n *\n * @param {string} project the project name to set for this resource\n */\n setProject(project) {\n this.project = project;\n this.dirty = true;\n }\n\n /**\n * Set the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @param {string} state the state of this resource\n */\n setState(state) {\n this.state = validStates[state] ? state : this.state;\n this.dirty = true;\n }\n\n /**\n * Return the original path to the file from which this resource was\n * originally extracted.\n *\n * @returns {string} the path to the file containing this resource\n */\n getPath() {\n return this.pathName;\n }\n\n /**\n * Return the translator's comment for this resource if there is\n * one, or undefined if not.\n *\n * @returns {String|undefined} the translator's comment for this resource\n * if the engineer put one in the code\n */\n getComment() {\n return this.comment;\n }\n\n /**\n * Set the translator's comment for this resource.\n *\n * @param {String|undefined} comment the translator's comment to set. Use\n * undefined to clear the comment\n */\n setComment(comment) {\n this.comment = comment;\n this.dirty = true;\n }\n\n /**\n * Get the \"do not translate\" flag for this resource.\n *\n * @returns {boolean} true means that the current resource should not\n * be translated, and false means it will be translated.\n */\n getDNT() {\n return typeof(this.dnt) === 'boolean' ? this.dnt : false;\n }\n\n /**\n * Set the \"do not translate\" flag for this resource.\n *\n * @param {boolean} flag set the dnt flag to this value\n */\n setDNT(flag) {\n if (typeof(flag) !== 'boolean') {\n throw new TypeError('value must be boolean');\n }\n this.dnt = flag;\n this.dirty = true;\n }\n\n /**\n * Return the database id if this resource has previously been saved in the\n * database.\n *\n * @returns {number|undefined} the database id if this resource has previously\n * been saved in the database, or undefined if it is has not\n */\n getId() {\n return this.id;\n }\n\n /**\n * Return the origin of this resource. The origin may be either the string\n * \"source\" or \"target\". Source origin resources are ones that are extracted\n * from the source code, whereas target ones are translations from the\n * translators.\n *\n * @returns {string} the origin of this resource\n */\n getOrigin() {\n return this.origin;\n }\n\n /**\n * Return the localize flag of this resource.\n * This flag indicates whether we should look up a translation for this resource.\n * When false, we should simply substitute the source back\n *\n * @returns {Boolean} the localize flag of this resource\n */\n getLocalize() {\n return this.localize;\n }\n\n /**\n * Return the name of the flavor for this resource, or undefined\n * for the \"main\" or default flavor.\n *\n * @return {String|undefined} the name of the flavor for this\n * resource or undefined for the main or default flavor\n */\n getFlavor() {\n return this.flavor;\n }\n\n /**\n * Return the path to the resource file that contains this resource.\n * This is different from the pathName property, which is the path to\n * the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android\n * string.xml files or xliff files. Otherwise, the property is undefined.\n *\n * @returns {string|undefined} the path to the resource file that contains\n * this resource, or undefined if this resource was not extracted from\n * a resource file\n */\n getResFile() {\n return this.resfile;\n }\n\n /**\n * Return true if the other resource represents the same resource as\n * the current one. The project, context, locale, key, flavor, and type must\n * match. Other fields such as the pathName, state, and comment fields are\n * ignored as minor variations.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n same(other) {\n if (!other) return false;\n\n const props = [\"project\", \"context\", \"sourceLocale\", \"targetLocale\", \"reskey\", \"resType\", \"flavor\"];\n for (let i = 0; i < props.length; i++) {\n if (this[props[i]] !== other[props[i]]) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Escape text for writing to a database in a SQL command. This puts single\n * quotes around the string, and makes sure that all single quotes within\n * the string are escaped.\n *\n * @param {Object} str the item to escape\n * @returns {string} the escaped string\n */\n escapeText(str) {\n switch (typeof(str)) {\n case \"string\":\n // unescape first, then re-escape to make everything consistent\n return \"'\" + str.replace(/\\\\'/g, \"'\").replace(/'/g, \"\\\\'\") + \"'\";\n case \"undefined\":\n return \"NULL\";\n case \"boolean\":\n return str ? \"TRUE\" : \"FALSE\";\n default:\n if (str === null) {\n return \"NULL\";\n }\n return str.toString();\n }\n }\n\n /**\n * Add an instance of the same resource to the list of\n * instances. If the given resource matches the\n * current instance in all properties that affect the\n * possible translation, and differs from the current\n * instance by some property that does not affect\n * its translation, it will be added as an instance of\n * the same string. The following properties affect the\n * translation:\n *\n * <ul>\n * <li>context</li>\n * <li>datatype</li>\n * <li>dnt</li>\n * <li>flavor</li>\n * <li>project</li>\n * <li>reskey</li>\n * <li>resType</li>\n * <li>source</li>\n * <li>sourceHash</li>\n * <li>sourceArray</li>\n * <li>sourceLocale</li>\n * <li>targetLocale</li>\n * </ul>\n *\n * Differences in other properties, such as \"comment\" or\n * \"origin\" are considered instances of the same resource.\n *\n * If this method is given a resource that differs from\n * the current one by one of the above translation affecting\n * properties, it is not added to the list of instances. This\n * can be checked easily by calling the isInstance() method.\n *\n * @param {Resource} resource an instance of the current resource to\n * record\n * @returns {boolean} true if the instance was added, and\n * and false otherwise\n */\n addInstance(resource) {\n if (!this.isInstance(resource)) {\n return false;\n }\n const unique = this !== resource && this.instances.every(res => {\n return res !== resource;\n });\n if (!unique) {\n return false;\n }\n this.instances.push(resource);\n this.dirty = true;\n return true;\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource. This method returns true if all properties which\n * affect the possible translation match between the given and\n * the current resource.\n *\n * @param {Resource} resource a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (typeof(resource) !== 'object' || !(resource instanceof Resource)) {\n return false;\n }\n\n return translationImportant.every(prop => {\n return this[prop] === resource[prop];\n });\n }\n\n /**\n * Return the list of instances of the current resource.\n *\n * @returns {Array.<Resource>} the list of instances of\n * the current resource\n */\n getInstances() {\n return this.instances;\n }\n\n /**\n * Return true if this instance has been modified since its creation, and false otherwise.\n */\n isDirty() {\n return this.dirty\n }\n\n /**\n * Clear the dirty flag. This is used for example when the Resource was\n * written to disk and the modifications are already recorded, allowing\n * new modifications later.\n */\n clearDirty() {\n this.dirty = false;\n }\n\n /**\n * Return the location of the resource instance in the original file where it was read\n * from. This is usually an object containing a line and a char property which gives the\n * line number and character within that line where the representation of the resource\n * instance starts.\n *\n * @returns {Location|undefined} the location information, or undefined if no location\n * information is available\n */\n getLocation() {\n return this.location?.getLocation();\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @abstract\n * @returns {string} a unique hash key for this resource\n */\n hashKey() {\n throw new Error(\"hashKey() not implemented\");\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @abstract\n * @returns {string} a unique hash key for this resource with a cleaned string\n */\n cleanHashKey() {\n throw new Error(\"cleanHashKey() not implemented\");\n }\n}\n\nexport default Resource;\n"],"mappings":"k0CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,GAAM,CAAAA,WAAW,CAAG,CAChB,KAAK,CAAC,IAAI,CACV,YAAY,CAAC,IAAI,CACjB,UAAU,CAAC,IACf,CAAC,CAED,GAAM,CAAAC,oBAAoB,CAAG,CACzB,SAAS,CACT,UAAU,CACV,KAAK,CACL,QAAQ,CACR,SAAS,CACT,QAAQ,CACR,SAAS,CACT,cAAc,CACd,cAAc,CACjB,CAGD;AACA;AACA;AACA;AACA,GAJA,GAKM,CAAAC,QAAQ,yBAyBV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MACI,SAAAA,SAAYC,KAAK,CAAE,CAAAC,eAAA,MAAAF,QAAA,EA/DnB;AACJ;AACA;AACA,OAHIG,eAAA,wBAMA;AACJ;AACA;AACA,OAHIA,eAAA,uBAMA;AACJ;AACA;AACA,OAHIA,eAAA,uBAMA;AACJ;AACA;AACA,OAHIA,eAAA,wBA8CI,GAAI,IAAI,CAACC,WAAW,GAAKJ,QAAQ,CAAE,CAC/B,KAAM,IAAI,CAAAK,KAAK,CAAC,6CAA6C,CACjE,CAEA,IAAI,CAACC,OAAO,CAAG,KAAK,CAEpB,GAAIL,KAAK,CAAE,CACP,IAAI,CAACM,OAAO,CAAGN,KAAK,CAACM,OAAO,CAC5B,IAAI,CAACC,OAAO,CAAGP,KAAK,CAACO,OAAO,EAAIC,SAAS,CAAE;AAC3C,IAAI,CAACC,YAAY,CAAGT,KAAK,C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+1,48 @@
|
|
|
1
|
+
"use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _Escaper2=_interopRequireDefault(require("./Escaper.js"));var _EscapeCommon=require("./EscapeCommon.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}/*
|
|
2
|
+
* CppEscaper.js - class that escapes and unescapes strings in C++
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2025 JEDLSoft
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
*
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/var validStyles=new Set(["cpp",// regular double-quoted strings
|
|
19
|
+
"cpp-char",// character literals like 'a'
|
|
20
|
+
"cpp-raw",// raw strings like R"(foo)"
|
|
21
|
+
"cpp-wide",// wide strings like L"foo"
|
|
22
|
+
"cpp-utf8",// UTF-8 strings like u8"foo"
|
|
23
|
+
"cpp-utf16",// UTF-16 strings like u"foo"
|
|
24
|
+
"cpp-utf32"// UTF-32 strings like U"foo"
|
|
25
|
+
]);/**
|
|
26
|
+
* @class Escaper for C++
|
|
27
|
+
*/var CppEscaper=/*#__PURE__*/function(_Escaper){/**
|
|
28
|
+
* Can support the following styles:
|
|
29
|
+
* - cpp: regular double-quoted strings
|
|
30
|
+
* - cpp-char: character literals like 'a'
|
|
31
|
+
* - cpp-raw: raw strings like R"(foo)"
|
|
32
|
+
* - cpp-wide: wide strings like L"foo"
|
|
33
|
+
* - cpp-utf8: UTF-8 strings like u8"foo"
|
|
34
|
+
* - cpp-utf16: UTF-16 strings like u"foo"
|
|
35
|
+
* - cpp-utf32: UTF-32 strings like U"foo"
|
|
36
|
+
*
|
|
37
|
+
* @param {string} style the style to use for escaping
|
|
38
|
+
* @constructor
|
|
39
|
+
* @throws {Error} if the style is not supported
|
|
40
|
+
*/function CppEscaper(style){var _this;_classCallCheck(this,CppEscaper);_this=_callSuper(this,CppEscaper,[style]);if(!validStyles.has(style)){throw new Error("invalid cpp escape style ".concat(style))}_this.name="cpp-escaper";_this.description="Escapes and unescapes various types of strings in C++";return _this}/**
|
|
41
|
+
* @override
|
|
42
|
+
*/_inherits(CppEscaper,_Escaper);return _createClass(CppEscaper,[{key:"escape",value:function escape(string){var escaped=string;escaped=(0,_EscapeCommon.escapeRules)(escaped,_EscapeCommon.escapeRegexes[this.style]);// Apply Unicode escaping for all C++ string types except raw strings
|
|
43
|
+
// C++ supports Unicode escapes in all string types except raw strings
|
|
44
|
+
if(this.style!=="cpp-raw"){escaped=(0,_EscapeCommon.escapeUnicodeAsSurrogatePairs)(escaped)}return escaped}/**
|
|
45
|
+
* @override
|
|
46
|
+
*/},{key:"unescape",value:function unescape(string){var unescaped=string;// Apply Unicode unescaping for all C++ string types except raw strings
|
|
47
|
+
if(this.style!=="cpp-raw"){unescaped=(0,_EscapeCommon.unescapeUnicode)(unescaped)}unescaped=(0,_EscapeCommon.unescapeRules)(unescaped,_EscapeCommon.escapeRegexes[this.style]);return unescaped}}])}(_Escaper2["default"]);var _default=exports["default"]=CppEscaper;module.exports=exports.default;
|
|
48
|
+
//# sourceMappingURL=CppEscaper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CppEscaper.js","names":["_Escaper2","_interopRequireDefault","require","_EscapeCommon","e","__esModule","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","o","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","prototype","i","_toPrimitive","_typeof","Symbol","toPrimitive","call","String","Number","_callSuper","_getPrototypeOf","_possibleConstructorReturn","_isNativeReflectConstruct","Reflect","construct","constructor","apply","_assertThisInitialized","ReferenceError","Boolean","valueOf","setPrototypeOf","getPrototypeOf","bind","__proto__","_inherits","create","value","_setPrototypeOf","validStyles","Set","CppEscaper","_Escaper","style","_this","has","Error","concat","name","description","escape","string","escaped","escapeRules","escapeRegexes","escapeUnicodeAsSurrogatePairs","unescape","unescaped","unescapeUnicode","unescapeRules","Escaper","_default","exports","module","default"],"sources":["../../src/escapes/CppEscaper.js"],"sourcesContent":["/*\n * CppEscaper.js - class that escapes and unescapes strings in C++\n *\n * Copyright © 2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Escaper from './Escaper.js';\nimport {\n escapeUnicodeAsSurrogatePairs,\n escapeRules,\n unescapeRules,\n unescapeUnicode,\n escapeRegexes\n} from './EscapeCommon.js';\n\nconst validStyles = new Set([\n \"cpp\", // regular double-quoted strings\n \"cpp-char\", // character literals like 'a'\n \"cpp-raw\", // raw strings like R\"(foo)\"\n \"cpp-wide\", // wide strings like L\"foo\"\n \"cpp-utf8\", // UTF-8 strings like u8\"foo\"\n \"cpp-utf16\", // UTF-16 strings like u\"foo\"\n \"cpp-utf32\" // UTF-32 strings like U\"foo\"\n]);\n\n/**\n * @class Escaper for C++\n */\nclass CppEscaper extends Escaper {\n /**\n * Can support the following styles:\n * - cpp: regular double-quoted strings\n * - cpp-char: character literals like 'a'\n * - cpp-raw: raw strings like R\"(foo)\"\n * - cpp-wide: wide strings like L\"foo\"\n * - cpp-utf8: UTF-8 strings like u8\"foo\"\n * - cpp-utf16: UTF-16 strings like u\"foo\"\n * - cpp-utf32: UTF-32 strings like U\"foo\"\n *\n * @param {string} style the style to use for escaping\n * @constructor\n * @throws {Error} if the style is not supported\n */\n constructor(style) {\n super(style);\n if (!validStyles.has(style)) {\n throw new Error(`invalid cpp escape style ${style}`);\n }\n this.name = \"cpp-escaper\";\n this.description = \"Escapes and unescapes various types of strings in C++\";\n }\n\n /**\n * @override\n */\n escape(string) {\n let escaped = string;\n\n escaped = escapeRules(escaped, escapeRegexes[this.style]);\n\n // Apply Unicode escaping for all C++ string types except raw strings\n // C++ supports Unicode escapes in all string types except raw strings\n if (this.style !== \"cpp-raw\") {\n escaped = escapeUnicodeAsSurrogatePairs(escaped);\n }\n\n return escaped;\n }\n\n /**\n * @override\n */\n unescape(string) {\n let unescaped = string;\n\n // Apply Unicode unescaping for all C++ string types except raw strings\n if (this.style !== \"cpp-raw\") {\n unescaped = unescapeUnicode(unescaped);\n }\n\n unescaped = unescapeRules(unescaped, escapeRegexes[this.style]);\n\n return unescaped;\n }\n}\n\nexport default CppEscaper; "],"mappings":"kXAmBA,IAAAA,SAAA,CAAAC,sBAAA,CAAAC,OAAA,kBACA,IAAAC,aAAA,CAAAD,OAAA,sBAM2B,SAAAD,uBAAAG,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,WAAAE,gBAAAC,CAAA,CAAAC,CAAA,OAAAD,CAAA,YAAAC,CAAA,YAAAC,SAAA,+CAAAC,kBAAAN,CAAA,CAAAO,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAD,CAAA,CAAAE,MAAA,CAAAD,CAAA,QAAAE,CAAA,CAAA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AAA,CAGA,SAAAmB,QAAQA,CAACL,MAAM,CAAE,CACb,GAAI,CAAAM,SAAS,CAAGN,MAAM,CAEtB;AACA,GAAI,IAAI,CAACR,KAAK,GAAK,SAAS,CAAE,CAC1Bc,SAAS,CAAG,GAAAC,6BAAe,EAACD,SAAS,CACzC,CAEAA,SAAS,CAAG,GAAAE,2BAAa,EAACF,SAAS,CAAEH,2BAAa,CAAC,IAAI,CAACX,KAAK,CAAC,CAAC,CAE/D,MAAO,CAAAc,SACX,CAAC,KAvDoBG,oBAAO,MAAAC,QAAA,CAAAC,OAAA,YA0DjBrB,UAAU,CAAAsB,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
|
@@ -51,7 +51,33 @@
|
|
|
51
51
|
},"escape":{"\"":"\"\""// escape quotes
|
|
52
52
|
}},"csharp-raw":{"unescape":{// none
|
|
53
53
|
},"escape":{// none
|
|
54
|
-
}}
|
|
54
|
+
}},// from https://en.cppreference.com/w/cpp/language/string_literal
|
|
55
|
+
"cpp":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
56
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
57
|
+
"^\\\\'":"'",// unescape single quotes
|
|
58
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
59
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-char":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
60
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
61
|
+
"^\\\\'":"'",// unescape single quotes
|
|
62
|
+
"([^\\\\])\\\\'":"$1'","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-raw":{"unescape":{// raw strings don't unescape anything
|
|
63
|
+
},"escape":{// raw strings don't escape anything
|
|
64
|
+
}},"cpp-wide":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
65
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
66
|
+
"^\\\\'":"'",// unescape single quotes
|
|
67
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
68
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-utf8":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
69
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
70
|
+
"^\\\\'":"'",// unescape single quotes
|
|
71
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
72
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-utf16":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
73
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
74
|
+
"^\\\\'":"'",// unescape single quotes
|
|
75
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
76
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"cpp-utf32":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
77
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
78
|
+
"^\\\\'":"'",// unescape single quotes
|
|
79
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
80
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\0":"\0","\\\\a":"\x07","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\v":"\x0B"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\0":"\\0","\x07":"\\a","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\v"}},"java":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
55
81
|
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
56
82
|
"^\\\\'":"'",// unescape quotes
|
|
57
83
|
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"","([^\\\\])\\\\\"":"$1\"","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"}},"java-raw":{"unescape":{"\\\\\\\\n":"",// line continuation
|
|
@@ -87,7 +113,21 @@
|
|
|
87
113
|
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
88
114
|
"^\\\\\"":"\"",// unescape double quotes only, not single
|
|
89
115
|
"([^\\\\])\\\\\"":"$1\"",// unescape double quotes only, not single
|
|
90
|
-
"\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\b":"\b","\\\\f":"\f","\\\\v":"\x0B","\\\\a":"\x07"},"escape":{"([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","\\n":"\\n","\\r":"\\r","\\t":"\\t","\b":"\\b","\\f":"\\f","\\v":"\\v","\x07":"\\a"}},// from https://docs.
|
|
116
|
+
"\\\\n":"\n","\\\\r":"\r","\\\\t":"\t","\\\\b":"\b","\\\\f":"\f","\\\\v":"\x0B","\\\\a":"\x07"},"escape":{"([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","\\n":"\\n","\\r":"\\r","\\t":"\\t","\b":"\\b","\\f":"\\f","\\v":"\\v","\x07":"\\a"}},// from https://docs.scala-lang.org/scala3/book/strings.html
|
|
117
|
+
"scala":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
118
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
119
|
+
"^\\\\'":"'",// unescape single quotes
|
|
120
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
121
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"}},"scala-raw":{"unescape":{// raw strings don't unescape anything
|
|
122
|
+
},"escape":{// raw strings don't escape anything
|
|
123
|
+
}},"scala-triple":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
124
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
125
|
+
"^\\\\'":"'",// unescape single quotes
|
|
126
|
+
"([^\\\\])\\\\'":"$1'","^\\\\\"":"\"",// unescape double quotes
|
|
127
|
+
"([^\\\\])\\\\\"":"$1\"","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^\"":"\\\"","([^\\\\])\"":"$1\\\"","^'":"\\'","([^\\\\])'":"$1\\'","\n":"\\\\n","\r":"\\\\r","\t":"\\\\t"}},"scala-char":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
128
|
+
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
129
|
+
"^\\\\'":"'",// unescape single quotes
|
|
130
|
+
"([^\\\\])\\\\'":"$1'","\\\\b":"\b","\\\\f":"\f","\\\\n":"\n","\\\\r":"\r","\\\\t":"\t"},"escape":{"^\\\\":"\\\\","([^\\\\])\\\\":"$1\\\\","^'":"\\'","([^\\\\])'":"$1\\'","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"}},// from https://docs.swift.org/swift-book/documentation/the-swift-programming-language/stringsandcharacters
|
|
91
131
|
"swift":{"unescape":{"^\\\\\\\\":"\\",// unescape backslashes
|
|
92
132
|
"([^\\\\])\\\\\\\\":"$1\\",// unescape backslashes
|
|
93
133
|
"^\\\\'":"'",// unescape single quotes
|
|
@@ -137,7 +177,13 @@
|
|
|
137
177
|
* @static
|
|
138
178
|
*/function escapeUnicodeAsSurrogatePairs(string){if(!string){return""}var output="";// access the original string character by character to get
|
|
139
179
|
// the surrogate pairs for code points above U+FFFF
|
|
140
|
-
for(var i=0;i<string.length;i++){var ch=string[i];var code=ch.charCodeAt(0)
|
|
180
|
+
for(var i=0;i<string.length;i++){var ch=string[i];var code=ch.charCodeAt(0);// Check if this is a high surrogate (first part of surrogate pair)
|
|
181
|
+
if(code>=55296&&code<=56319){// This is a high surrogate, get the low surrogate
|
|
182
|
+
var lowCode=string.charCodeAt(i+1);if(lowCode>=56320&&lowCode<=57343){// Calculate the full code point
|
|
183
|
+
var fullCode=(code-55296)*1024+(lowCode-56320)+65536;var high=Math.floor((fullCode-65536)/1024)+55296;var low=(fullCode-65536)%1024+56320;output+="\\u"+high.toString(16).toUpperCase()+"\\u"+low.toString(16).toUpperCase();i++;// Skip the low surrogate
|
|
184
|
+
continue}}// Check if this is a low surrogate (shouldn't happen in valid UTF-16)
|
|
185
|
+
if(code>=56320&&code<=57343){continue;// Skip low surrogates that weren't paired
|
|
186
|
+
}if(code<65536&&code>255){var str=code.toString(16).toUpperCase();output+="\\u"+str}else{output+=ch}}return output}/**
|
|
141
187
|
* Escape a string so that it has hexadecimal escape sequences
|
|
142
188
|
* in it instead of the characters themselves. This function
|
|
143
189
|
* will only convert characters from U+0000 to U+001F. The rest
|