@native-systems/utility 2.0.1 → 2.1.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/index.cjs +3 -73
- package/dist/index.d.ts +26 -2
- package/dist/index.esm.js +3 -73
- package/package.json +1 -3
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Handlebars = require('handlebars');
|
|
4
|
-
var sanitizeHtml = require('sanitize-html');
|
|
5
|
-
var MarkdownIt = require('markdown-it');
|
|
6
4
|
|
|
7
5
|
var PostgresError = /*#__PURE__*/ (function (PostgresError) {
|
|
8
6
|
PostgresError['SUCCESSFUL_COMPLETION'] = '00000';
|
|
@@ -1094,79 +1092,11 @@ var eqPlugin = function (handlebars) {
|
|
|
1094
1092
|
});
|
|
1095
1093
|
};
|
|
1096
1094
|
|
|
1097
|
-
function
|
|
1098
|
-
|
|
1099
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
1100
|
-
return arr2;
|
|
1101
|
-
}
|
|
1102
|
-
function _array_without_holes(arr) {
|
|
1103
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1104
|
-
}
|
|
1105
|
-
function _iterable_to_array(iter) {
|
|
1106
|
-
if (
|
|
1107
|
-
(typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
|
|
1108
|
-
iter['@@iterator'] != null
|
|
1109
|
-
)
|
|
1110
|
-
return Array.from(iter);
|
|
1111
|
-
}
|
|
1112
|
-
function _non_iterable_spread() {
|
|
1113
|
-
throw new TypeError(
|
|
1114
|
-
'Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
1115
|
-
);
|
|
1116
|
-
}
|
|
1117
|
-
function _to_consumable_array(arr) {
|
|
1118
|
-
return (
|
|
1119
|
-
_array_without_holes(arr) ||
|
|
1120
|
-
_iterable_to_array(arr) ||
|
|
1121
|
-
_unsupported_iterable_to_array(arr) ||
|
|
1122
|
-
_non_iterable_spread()
|
|
1123
|
-
);
|
|
1124
|
-
}
|
|
1125
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1126
|
-
if (!o) return;
|
|
1127
|
-
if (typeof o === 'string') return _array_like_to_array(o, minLen);
|
|
1128
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1129
|
-
if (n === 'Object' && o.constructor) n = o.constructor.name;
|
|
1130
|
-
if (n === 'Map' || n === 'Set') return Array.from(n);
|
|
1131
|
-
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
1132
|
-
return _array_like_to_array(o, minLen);
|
|
1133
|
-
}
|
|
1134
|
-
var mdParser = new MarkdownIt();
|
|
1135
|
-
var markdownPlugin = function (handlebars) {
|
|
1095
|
+
var markdownPlugin = function (handlebars, param) {
|
|
1096
|
+
var renderAndSanitize = param.renderAndSanitize;
|
|
1136
1097
|
handlebars.registerHelper('md', function (markdownText) {
|
|
1137
1098
|
if (!markdownText) return '';
|
|
1138
|
-
var cleanHtml =
|
|
1139
|
-
allowedTags: _to_consumable_array([
|
|
1140
|
-
'h1',
|
|
1141
|
-
'h2',
|
|
1142
|
-
'h3',
|
|
1143
|
-
'h4',
|
|
1144
|
-
'h5',
|
|
1145
|
-
'h6',
|
|
1146
|
-
'b',
|
|
1147
|
-
]).concat(
|
|
1148
|
-
_to_consumable_array([
|
|
1149
|
-
'i',
|
|
1150
|
-
'strong',
|
|
1151
|
-
'em',
|
|
1152
|
-
'a',
|
|
1153
|
-
'ul',
|
|
1154
|
-
'ol',
|
|
1155
|
-
'li',
|
|
1156
|
-
'p',
|
|
1157
|
-
'br',
|
|
1158
|
-
])
|
|
1159
|
-
),
|
|
1160
|
-
allowedAttributes: {
|
|
1161
|
-
a: ['href', 'title', 'target'],
|
|
1162
|
-
},
|
|
1163
|
-
transformTags: {
|
|
1164
|
-
a: sanitizeHtml.simpleTransform('a', {
|
|
1165
|
-
target: '_blank',
|
|
1166
|
-
rel: 'noopener',
|
|
1167
|
-
}),
|
|
1168
|
-
},
|
|
1169
|
-
});
|
|
1099
|
+
var cleanHtml = renderAndSanitize(markdownText);
|
|
1170
1100
|
return new Handlebars.SafeString(cleanHtml);
|
|
1171
1101
|
});
|
|
1172
1102
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -736,7 +736,7 @@ declare module "@native-systems/utility" {
|
|
|
736
736
|
static response<T>(response: Response): Promise<T>;
|
|
737
737
|
/**
|
|
738
738
|
* Http request error handler, that always returns the correct error object.
|
|
739
|
-
* Either fast forwards the already correctly formatted
|
|
739
|
+
* Either fast forwards the already correctly formatted native error or set up a new native error, based on the provided info.
|
|
740
740
|
* The generic typing is just used to prevent type errors.
|
|
741
741
|
* @param response {Response | native.ErrorResponse} The Response object that errored. Can either be a default object, or the modified native version.
|
|
742
742
|
* @throws {native.Error} Always throws an error, which is always of this type.
|
|
@@ -809,7 +809,31 @@ declare module "@native-systems/utility" {
|
|
|
809
809
|
}
|
|
810
810
|
|
|
811
811
|
declare module "@native-systems/utility" {
|
|
812
|
-
export
|
|
812
|
+
export type MarkdownHelpers = {
|
|
813
|
+
renderAndSanitize: (inp: string) => string;
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* Example usage:
|
|
817
|
+
* sanitizeHtml(renderMarkdown(markdownText), {
|
|
818
|
+
* allowedTags: [
|
|
819
|
+
* ...['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'b'],
|
|
820
|
+
* ...['i', 'strong', 'em', 'a', 'ul', 'ol', 'li', 'p', 'br'],
|
|
821
|
+
* ],
|
|
822
|
+
* allowedAttributes: {
|
|
823
|
+
* a: ['href', 'title', 'target'],
|
|
824
|
+
* },
|
|
825
|
+
* // enforce target="_blank" on links
|
|
826
|
+
* transformTags: {
|
|
827
|
+
* a: sanitizeHtml.simpleTransform('a', {
|
|
828
|
+
* target: '_blank',
|
|
829
|
+
* rel: 'noopener',
|
|
830
|
+
* }),
|
|
831
|
+
* },
|
|
832
|
+
* });
|
|
833
|
+
* @param handlebars
|
|
834
|
+
* @param renderAndSanitize
|
|
835
|
+
*/
|
|
836
|
+
export const markdownPlugin: CompilerPlugin<MarkdownHelpers>;
|
|
813
837
|
}
|
|
814
838
|
|
|
815
839
|
declare module "@native-systems/utility" {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import Handlebars from 'handlebars';
|
|
2
|
-
import sanitizeHtml, { simpleTransform } from 'sanitize-html';
|
|
3
|
-
import MarkdownIt from 'markdown-it';
|
|
4
2
|
|
|
5
3
|
var PostgresError = /*#__PURE__*/ (function (PostgresError) {
|
|
6
4
|
PostgresError['SUCCESSFUL_COMPLETION'] = '00000';
|
|
@@ -1092,79 +1090,11 @@ var eqPlugin = function (handlebars) {
|
|
|
1092
1090
|
});
|
|
1093
1091
|
};
|
|
1094
1092
|
|
|
1095
|
-
function
|
|
1096
|
-
|
|
1097
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
1098
|
-
return arr2;
|
|
1099
|
-
}
|
|
1100
|
-
function _array_without_holes(arr) {
|
|
1101
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1102
|
-
}
|
|
1103
|
-
function _iterable_to_array(iter) {
|
|
1104
|
-
if (
|
|
1105
|
-
(typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
|
|
1106
|
-
iter['@@iterator'] != null
|
|
1107
|
-
)
|
|
1108
|
-
return Array.from(iter);
|
|
1109
|
-
}
|
|
1110
|
-
function _non_iterable_spread() {
|
|
1111
|
-
throw new TypeError(
|
|
1112
|
-
'Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
1113
|
-
);
|
|
1114
|
-
}
|
|
1115
|
-
function _to_consumable_array(arr) {
|
|
1116
|
-
return (
|
|
1117
|
-
_array_without_holes(arr) ||
|
|
1118
|
-
_iterable_to_array(arr) ||
|
|
1119
|
-
_unsupported_iterable_to_array(arr) ||
|
|
1120
|
-
_non_iterable_spread()
|
|
1121
|
-
);
|
|
1122
|
-
}
|
|
1123
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1124
|
-
if (!o) return;
|
|
1125
|
-
if (typeof o === 'string') return _array_like_to_array(o, minLen);
|
|
1126
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1127
|
-
if (n === 'Object' && o.constructor) n = o.constructor.name;
|
|
1128
|
-
if (n === 'Map' || n === 'Set') return Array.from(n);
|
|
1129
|
-
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
1130
|
-
return _array_like_to_array(o, minLen);
|
|
1131
|
-
}
|
|
1132
|
-
var mdParser = new MarkdownIt();
|
|
1133
|
-
var markdownPlugin = function (handlebars) {
|
|
1093
|
+
var markdownPlugin = function (handlebars, param) {
|
|
1094
|
+
var renderAndSanitize = param.renderAndSanitize;
|
|
1134
1095
|
handlebars.registerHelper('md', function (markdownText) {
|
|
1135
1096
|
if (!markdownText) return '';
|
|
1136
|
-
var cleanHtml =
|
|
1137
|
-
allowedTags: _to_consumable_array([
|
|
1138
|
-
'h1',
|
|
1139
|
-
'h2',
|
|
1140
|
-
'h3',
|
|
1141
|
-
'h4',
|
|
1142
|
-
'h5',
|
|
1143
|
-
'h6',
|
|
1144
|
-
'b',
|
|
1145
|
-
]).concat(
|
|
1146
|
-
_to_consumable_array([
|
|
1147
|
-
'i',
|
|
1148
|
-
'strong',
|
|
1149
|
-
'em',
|
|
1150
|
-
'a',
|
|
1151
|
-
'ul',
|
|
1152
|
-
'ol',
|
|
1153
|
-
'li',
|
|
1154
|
-
'p',
|
|
1155
|
-
'br',
|
|
1156
|
-
])
|
|
1157
|
-
),
|
|
1158
|
-
allowedAttributes: {
|
|
1159
|
-
a: ['href', 'title', 'target'],
|
|
1160
|
-
},
|
|
1161
|
-
transformTags: {
|
|
1162
|
-
a: simpleTransform('a', {
|
|
1163
|
-
target: '_blank',
|
|
1164
|
-
rel: 'noopener',
|
|
1165
|
-
}),
|
|
1166
|
-
},
|
|
1167
|
-
});
|
|
1097
|
+
var cleanHtml = renderAndSanitize(markdownText);
|
|
1168
1098
|
return new Handlebars.SafeString(cleanHtml);
|
|
1169
1099
|
});
|
|
1170
1100
|
};
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"version": "2.0
|
|
13
|
+
"version": "2.1.0",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"private": false,
|
|
16
16
|
"engines": {
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"handlebars": "^4.7.8",
|
|
79
79
|
"husky": "^9.1.6",
|
|
80
80
|
"lint-staged": "^13.0.3",
|
|
81
|
-
"markdown-it": "^14.1.0",
|
|
82
81
|
"npm-run-all": "^4.1.5",
|
|
83
82
|
"prettier": "3.0.3",
|
|
84
83
|
"rollup": "^4.26.0",
|
|
@@ -89,7 +88,6 @@
|
|
|
89
88
|
"rollup-plugin-swc3": "^0.12.1",
|
|
90
89
|
"rollup-plugin-tsconfig-paths": "^1.5.2",
|
|
91
90
|
"rollup-plugin-typescript-paths": "^1.5.0",
|
|
92
|
-
"sanitize-html": "^2.17.0",
|
|
93
91
|
"ts-node": "^10.9.1",
|
|
94
92
|
"typescript": "5.6.3"
|
|
95
93
|
},
|