@difizen/libro-common 0.0.2-alpha.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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/es/array.d.ts +368 -0
  4. package/es/array.d.ts.map +1 -0
  5. package/es/array.js +577 -0
  6. package/es/display-wrapper.d.ts +6 -0
  7. package/es/display-wrapper.d.ts.map +1 -0
  8. package/es/display-wrapper.js +12 -0
  9. package/es/index.d.ts +11 -0
  10. package/es/index.d.ts.map +1 -0
  11. package/es/index.js +10 -0
  12. package/es/iter.d.ts +147 -0
  13. package/es/iter.d.ts.map +1 -0
  14. package/es/iter.js +162 -0
  15. package/es/json.d.ts +126 -0
  16. package/es/json.d.ts.map +1 -0
  17. package/es/json.js +274 -0
  18. package/es/path.d.ts +97 -0
  19. package/es/path.d.ts.map +1 -0
  20. package/es/path.js +60 -0
  21. package/es/polling/index.d.ts +3 -0
  22. package/es/polling/index.d.ts.map +1 -0
  23. package/es/polling/index.js +2 -0
  24. package/es/polling/poll.d.ts +193 -0
  25. package/es/polling/poll.d.ts.map +1 -0
  26. package/es/polling/poll.js +501 -0
  27. package/es/polling/protocol.d.ts +120 -0
  28. package/es/polling/protocol.d.ts.map +1 -0
  29. package/es/polling/protocol.js +13 -0
  30. package/es/posix.d.ts +2 -0
  31. package/es/posix.d.ts.map +1 -0
  32. package/es/posix.js +71 -0
  33. package/es/protocol/cell-protocol.d.ts +181 -0
  34. package/es/protocol/cell-protocol.d.ts.map +1 -0
  35. package/es/protocol/cell-protocol.js +1 -0
  36. package/es/protocol/index.d.ts +4 -0
  37. package/es/protocol/index.d.ts.map +1 -0
  38. package/es/protocol/index.js +3 -0
  39. package/es/protocol/notebook-protocol.d.ts +63 -0
  40. package/es/protocol/notebook-protocol.d.ts.map +1 -0
  41. package/es/protocol/notebook-protocol.js +41 -0
  42. package/es/protocol/output-protocol.d.ts +125 -0
  43. package/es/protocol/output-protocol.d.ts.map +1 -0
  44. package/es/protocol/output-protocol.js +1 -0
  45. package/es/sanitizer.d.ts +44 -0
  46. package/es/sanitizer.d.ts.map +1 -0
  47. package/es/sanitizer.js +659 -0
  48. package/es/url.d.ts +98 -0
  49. package/es/url.d.ts.map +1 -0
  50. package/es/url.js +134 -0
  51. package/es/utils.d.ts +57 -0
  52. package/es/utils.d.ts.map +1 -0
  53. package/es/utils.js +124 -0
  54. package/package.json +62 -0
  55. package/src/array.ts +608 -0
  56. package/src/display-wrapper.tsx +11 -0
  57. package/src/index.ts +10 -0
  58. package/src/iter.ts +199 -0
  59. package/src/json.ts +321 -0
  60. package/src/path.ts +138 -0
  61. package/src/polling/index.ts +2 -0
  62. package/src/polling/poll.ts +508 -0
  63. package/src/polling/protocol.ts +145 -0
  64. package/src/posix.ts +75 -0
  65. package/src/protocol/cell-protocol.ts +215 -0
  66. package/src/protocol/index.ts +3 -0
  67. package/src/protocol/notebook-protocol.ts +73 -0
  68. package/src/protocol/output-protocol.ts +162 -0
  69. package/src/sanitizer.ts +944 -0
  70. package/src/url.ts +157 -0
  71. package/src/utils.ts +145 -0
package/es/posix.js ADDED
@@ -0,0 +1,71 @@
1
+ var isString = function isString(x) {
2
+ return typeof x === 'string';
3
+ };
4
+
5
+ // resolves . and .. elements in a path array with directory names there
6
+ // must be no slashes or device names (c:\) in the array
7
+ // (so also no leading and trailing slashes - it does not distinguish
8
+ // relative and absolute paths)
9
+ function normalizeArray(parts, allowAboveRoot) {
10
+ var res = [];
11
+ for (var i = 0; i < parts.length; i++) {
12
+ var p = parts[i];
13
+
14
+ // ignore empty parts
15
+ if (!p || p === '.') {
16
+ continue;
17
+ }
18
+ if (p === '..') {
19
+ if (res.length && res[res.length - 1] !== '..') {
20
+ res.pop();
21
+ } else if (allowAboveRoot) {
22
+ res.push('..');
23
+ }
24
+ } else {
25
+ res.push(p);
26
+ }
27
+ }
28
+ return res;
29
+ }
30
+
31
+ // posix version
32
+ var isAbsolute = function isAbsolute(path) {
33
+ return path.charAt(0) === '/';
34
+ };
35
+
36
+ // path.normalize(path)
37
+ // posix version
38
+ var normalize = function normalize(source) {
39
+ var path = source;
40
+ var isAbs = isAbsolute(path),
41
+ trailingSlash = path.substr(-1) === '/';
42
+
43
+ // Normalize the path
44
+ path = normalizeArray(path.split('/'), !isAbs).join('/');
45
+ if (!path && !isAbs) {
46
+ path = '.';
47
+ }
48
+ if (path && trailingSlash) {
49
+ path += '/';
50
+ }
51
+ return (isAbs ? '/' : '') + path;
52
+ };
53
+
54
+ // posix version
55
+ export var join = function join() {
56
+ var path = '';
57
+ for (var i = 0; i < arguments.length; i++) {
58
+ var segment = i < 0 || arguments.length <= i ? undefined : arguments[i];
59
+ if (!isString(segment)) {
60
+ throw new TypeError('Arguments to path.join must be strings');
61
+ }
62
+ if (segment) {
63
+ if (!path) {
64
+ path += segment;
65
+ } else {
66
+ path += '/' + segment;
67
+ }
68
+ }
69
+ }
70
+ return normalize(path);
71
+ };
@@ -0,0 +1,181 @@
1
+ import type { PartialJSONObject } from '../json.js';
2
+ import type { ExecutionCount, IAttachments, MultilineString } from './notebook-protocol.js';
3
+ import type { IOutput } from './output-protocol.js';
4
+ /**
5
+ * A type which describes the type of cell.
6
+ */
7
+ export type CellType = 'code' | 'markdown' | 'raw' | string;
8
+ /**
9
+ * The Jupyter metadata namespace.
10
+ */
11
+ export interface IBaseCellJupyterMetadata extends PartialJSONObject {
12
+ /**
13
+ * Whether the source is hidden.
14
+ */
15
+ source_hidden: boolean;
16
+ }
17
+ /**
18
+ * Cell-level metadata.
19
+ */
20
+ export interface IBaseCellMetadata extends PartialJSONObject {
21
+ /**
22
+ * Whether the cell is trusted.
23
+ *
24
+ * #### Notes
25
+ * This is not strictly part of the nbformat spec, but it is added by
26
+ * the contents manager.
27
+ *
28
+ * See https://jupyter-server.readthedocs.io/en/latest/operators/security.html.
29
+ */
30
+ trusted: boolean;
31
+ /**
32
+ * The cell's name. If present, must be a non-empty string.
33
+ */
34
+ name: string;
35
+ /**
36
+ * The Jupyter metadata namespace
37
+ */
38
+ jupyter: Partial<IBaseCellJupyterMetadata>;
39
+ /**
40
+ * The cell's tags. Tags must be unique, and must not contain commas.
41
+ */
42
+ tags: string[];
43
+ }
44
+ /**
45
+ * The base cell interface.
46
+ */
47
+ export interface IBaseCell extends PartialJSONObject {
48
+ /**
49
+ * String identifying the type of cell.
50
+ */
51
+ cell_type: string;
52
+ /**
53
+ * Contents of the cell, represented as an array of lines.
54
+ */
55
+ source: MultilineString;
56
+ /**
57
+ * Cell-level metadata.
58
+ */
59
+ metadata: Partial<ICellMetadata>;
60
+ }
61
+ /**
62
+ * Metadata for the raw cell.
63
+ */
64
+ export interface IRawCellMetadata extends IBaseCellMetadata {
65
+ /**
66
+ * Raw cell metadata format for nbconvert.
67
+ */
68
+ format: string;
69
+ }
70
+ /**
71
+ * A raw cell.
72
+ */
73
+ export interface IRawCell extends IBaseCell {
74
+ /**
75
+ * A string field representing the identifier of this particular cell.
76
+ *
77
+ * Notebook format 4.4 requires no id field, but format 4.5 requires an id
78
+ * field. We need to handle both cases, so we make id optional here.
79
+ */
80
+ id?: string | undefined;
81
+ /**
82
+ * String identifying the type of cell.
83
+ */
84
+ cell_type: 'raw';
85
+ /**
86
+ * Cell-level metadata.
87
+ */
88
+ metadata: Partial<IRawCellMetadata>;
89
+ /**
90
+ * Cell attachments.
91
+ */
92
+ attachments?: IAttachments | undefined;
93
+ }
94
+ /**
95
+ * A markdown cell.
96
+ */
97
+ export interface IMarkdownCell extends IBaseCell {
98
+ /**
99
+ * A string field representing the identifier of this particular cell.
100
+ *
101
+ * Notebook format 4.4 requires no id field, but format 4.5 requires an id
102
+ * field. We need to handle both cases, so we make id optional here.
103
+ */
104
+ id?: string | undefined;
105
+ /**
106
+ * String identifying the type of cell.
107
+ */
108
+ cell_type: 'markdown';
109
+ /**
110
+ * Cell attachments.
111
+ */
112
+ attachments?: IAttachments | undefined;
113
+ }
114
+ /**
115
+ * The Jupyter metadata namespace for code cells.
116
+ */
117
+ export interface ICodeCellJupyterMetadata extends IBaseCellJupyterMetadata {
118
+ /**
119
+ * Whether the outputs are hidden. See https://github.com/jupyter/nbformat/issues/137.
120
+ */
121
+ outputs_hidden: boolean;
122
+ }
123
+ /**
124
+ * Metadata for a code cell.
125
+ */
126
+ export interface ICodeCellMetadata extends IBaseCellMetadata {
127
+ /**
128
+ * Whether the cell is collapsed/expanded.
129
+ */
130
+ collapsed: boolean;
131
+ /**
132
+ * The Jupyter metadata namespace
133
+ */
134
+ jupyter: Partial<ICodeCellJupyterMetadata>;
135
+ /**
136
+ * Whether the cell's output is scrolled, unscrolled, or autoscrolled.
137
+ */
138
+ scrolled: boolean | 'auto';
139
+ }
140
+ /**
141
+ * A code cell.
142
+ */
143
+ export interface ICodeCell extends IBaseCell {
144
+ /**
145
+ * A string field representing the identifier of this particular cell.
146
+ *
147
+ * Notebook format 4.4 requires no id field, but format 4.5 requires an id
148
+ * field. We need to handle both cases, so we make id optional here.
149
+ */
150
+ id?: string | undefined;
151
+ /**
152
+ * String identifying the type of cell.
153
+ * Changed in Libro: cell_type 不再限制只能是code,以便支持多种语言的cell
154
+ */
155
+ cell_type: string;
156
+ /**
157
+ * Cell-level metadata.
158
+ */
159
+ metadata: Partial<ICodeCellMetadata>;
160
+ /**
161
+ * Execution, display, or stream outputs.
162
+ */
163
+ outputs: IOutput[];
164
+ /**
165
+ * The code cell's prompt number. Will be null if the cell has not been run.
166
+ */
167
+ execution_count: ExecutionCount;
168
+ }
169
+ /**
170
+ * An unrecognized cell.
171
+ */
172
+ export type IUnrecognizedCell = IBaseCell;
173
+ /**
174
+ * A cell union type.
175
+ */
176
+ export type ICell = IRawCell | IMarkdownCell | ICodeCell | IUnrecognizedCell;
177
+ /**
178
+ * A union metadata type.
179
+ */
180
+ export type ICellMetadata = IBaseCellMetadata | IRawCellMetadata | ICodeCellMetadata;
181
+ //# sourceMappingURL=cell-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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
+ export * from './cell-protocol.js';
2
+ export * from './notebook-protocol.js';
3
+ export * from './output-protocol.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./cell-protocol.js";
2
+ export * from "./notebook-protocol.js";
3
+ export * from "./output-protocol.js";
@@ -0,0 +1,63 @@
1
+ import type { PartialJSONObject } from '../json.js';
2
+ import type { ICell } from './cell-protocol.js';
3
+ /**
4
+ * The earliest major version of the notebook format we support.
5
+ */
6
+ export declare const MAJOR_VERSION = 4;
7
+ /**
8
+ * The earliest minor version of the notebook format we support.
9
+ */
10
+ export declare const MINOR_VERSION = 4;
11
+ /**
12
+ * The kernelspec metadata.
13
+ */
14
+ export interface IKernelspecMetadata extends PartialJSONObject {
15
+ name: string;
16
+ display_name: string;
17
+ }
18
+ /**
19
+ * The language info metadata
20
+ */
21
+ export interface ILanguageInfoMetadata extends PartialJSONObject {
22
+ name: string;
23
+ codemirror_mode?: string | PartialJSONObject;
24
+ file_extension?: string;
25
+ mimetype?: string;
26
+ pygments_lexer?: string;
27
+ }
28
+ /**
29
+ * The default metadata for the notebook.
30
+ */
31
+ export interface INotebookMetadata extends PartialJSONObject {
32
+ kernelspec?: IKernelspecMetadata;
33
+ language_info?: ILanguageInfoMetadata;
34
+ orig_nbformat?: number;
35
+ }
36
+ /**
37
+ * The notebook content.
38
+ */
39
+ export interface INotebookContent extends PartialJSONObject {
40
+ metadata: INotebookMetadata;
41
+ nbformat_minor: number;
42
+ nbformat: number;
43
+ cells: ICell[];
44
+ }
45
+ /**
46
+ * A multiline string.
47
+ */
48
+ export type MultilineString = string | string[];
49
+ /**
50
+ * A mime-type keyed dictionary of data.
51
+ */
52
+ export interface IMimeBundle extends PartialJSONObject {
53
+ [key: string]: MultilineString | PartialJSONObject;
54
+ }
55
+ /**
56
+ * Media attachments (e.g. inline images).
57
+ */
58
+ export type IAttachments = Record<string, IMimeBundle | undefined>;
59
+ /**
60
+ * The code cell's prompt number. Will be null if the cell has not been run.
61
+ */
62
+ export type ExecutionCount = number | null;
63
+ //# sourceMappingURL=notebook-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-protocol.d.ts","sourceRoot":"","sources":["../../src/protocol/notebook-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAC;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACpD,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,iBAAiB,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The earliest major version of the notebook format we support.
3
+ */
4
+ export var MAJOR_VERSION = 4;
5
+
6
+ /**
7
+ * The earliest minor version of the notebook format we support.
8
+ */
9
+ export var MINOR_VERSION = 4;
10
+
11
+ /**
12
+ * The kernelspec metadata.
13
+ */
14
+
15
+ /**
16
+ * The language info metadata
17
+ */
18
+
19
+ /**
20
+ * The default metadata for the notebook.
21
+ */
22
+
23
+ /**
24
+ * The notebook content.
25
+ */
26
+
27
+ /**
28
+ * A multiline string.
29
+ */
30
+
31
+ /**
32
+ * A mime-type keyed dictionary of data.
33
+ */
34
+
35
+ /**
36
+ * Media attachments (e.g. inline images).
37
+ */
38
+
39
+ /**
40
+ * The code cell's prompt number. Will be null if the cell has not been run.
41
+ */
@@ -0,0 +1,125 @@
1
+ import type { PartialJSONObject } from '../json.js';
2
+ import type { ExecutionCount, IMimeBundle, MultilineString } from './notebook-protocol.js';
3
+ /**
4
+ * Cell output metadata.
5
+ */
6
+ export type OutputMetadata = PartialJSONObject;
7
+ /**
8
+ * The valid output types.
9
+ */
10
+ export type OutputType = 'execute_result' | 'display_data' | 'stream' | 'error' | 'update_display_data';
11
+ /**
12
+ * The base output type.
13
+ */
14
+ export interface IBaseOutput extends PartialJSONObject {
15
+ /**
16
+ * Type of cell output.
17
+ */
18
+ output_type: string;
19
+ }
20
+ /**
21
+ * Result of executing a code cell.
22
+ */
23
+ export interface IExecuteResult extends IBaseOutput {
24
+ /**
25
+ * Type of cell output.
26
+ */
27
+ output_type: 'execute_result';
28
+ /**
29
+ * A result's prompt number.
30
+ */
31
+ execution_count: ExecutionCount;
32
+ /**
33
+ * A mime-type keyed dictionary of data.
34
+ */
35
+ data: IMimeBundle;
36
+ /**
37
+ * Cell output metadata.
38
+ */
39
+ metadata: OutputMetadata;
40
+ }
41
+ /**
42
+ * Data displayed as a result of code cell execution.
43
+ */
44
+ export interface IDisplayData extends IBaseOutput {
45
+ /**
46
+ * Type of cell output.
47
+ */
48
+ output_type: 'display_data';
49
+ /**
50
+ * A mime-type keyed dictionary of data.
51
+ */
52
+ data: IMimeBundle;
53
+ /**
54
+ * Cell output metadata.
55
+ */
56
+ metadata: OutputMetadata;
57
+ }
58
+ /**
59
+ * Data displayed as an update to existing display data.
60
+ */
61
+ export interface IDisplayUpdate extends IBaseOutput {
62
+ /**
63
+ * Type of cell output.
64
+ */
65
+ output_type: 'update_display_data';
66
+ /**
67
+ * A mime-type keyed dictionary of data.
68
+ */
69
+ data: IMimeBundle;
70
+ /**
71
+ * Cell output metadata.
72
+ */
73
+ metadata: OutputMetadata;
74
+ }
75
+ /**
76
+ * Stream output from a code cell.
77
+ */
78
+ export interface IStream extends IBaseOutput {
79
+ /**
80
+ * Type of cell output.
81
+ */
82
+ output_type: 'stream';
83
+ /**
84
+ * The name of the stream.
85
+ */
86
+ name: StreamType;
87
+ /**
88
+ * The stream's text output.
89
+ */
90
+ text: MultilineString;
91
+ }
92
+ /**
93
+ * An alias for a stream type.
94
+ */
95
+ export type StreamType = 'stdout' | 'stderr';
96
+ /**
97
+ * Output of an error that occurred during code cell execution.
98
+ */
99
+ export interface IError extends IBaseOutput {
100
+ /**
101
+ * Type of cell output.
102
+ */
103
+ output_type: 'error';
104
+ /**
105
+ * The name of the error.
106
+ */
107
+ ename: string;
108
+ /**
109
+ * The value, or message, of the error.
110
+ */
111
+ evalue: string;
112
+ /**
113
+ * The error's traceback.
114
+ */
115
+ traceback: string[];
116
+ }
117
+ /**
118
+ * Unrecognized output.
119
+ */
120
+ export type IUnrecognizedOutput = IBaseOutput;
121
+ /**
122
+ * An output union type.
123
+ */
124
+ export type IOutput = IUnrecognizedOutput | IExecuteResult | IDisplayData | IStream | IError;
125
+ //# sourceMappingURL=output-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-protocol.d.ts","sourceRoot":"","sources":["../../src/protocol/output-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,cAAc,GACd,QAAQ,GACR,OAAO,GACP,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACpD;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD;;OAEG;IACH,WAAW,EAAE,gBAAgB,CAAC;IAE9B;;OAEG;IACH,eAAe,EAAE,cAAc,CAAC;IAEhC;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C;;OAEG;IACH,WAAW,EAAE,cAAc,CAAC;IAE5B;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD;;OAEG;IACH,WAAW,EAAE,qBAAqB,CAAC;IAEnC;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAC1C;;OAEG;IACH,WAAW,EAAE,QAAQ,CAAC;IAEtB;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,WAAW;IACzC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,OAAO,GACf,mBAAmB,GACnB,cAAc,GACd,YAAY,GACZ,OAAO,GACP,MAAM,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
1
+ export interface ISanitizerOptions {
2
+ /**
3
+ * The allowed tags.
4
+ */
5
+ allowedTags?: string[];
6
+ /**
7
+ * The allowed attributes for a given tag.
8
+ */
9
+ allowedAttributes?: Record<string, string[]>;
10
+ /**
11
+ * The allowed style values for a given tag.
12
+ */
13
+ allowedStyles?: Record<string, Record<string, RegExp[]>>;
14
+ }
15
+ export interface ISanitizer {
16
+ /**
17
+ * Sanitize an HTML string.
18
+ *
19
+ * @param dirty - The dirty text.
20
+ *
21
+ * @param options - The optional sanitization options.
22
+ *
23
+ * @returns The sanitized string.
24
+ */
25
+ sanitize: (dirty: string, options?: ISanitizerOptions) => string;
26
+ }
27
+ /**
28
+ * A class to sanitize HTML strings.
29
+ */
30
+ export declare class Sanitizer implements ISanitizer {
31
+ /**
32
+ * Sanitize an HTML string.
33
+ *
34
+ * @param dirty - The dirty text.
35
+ *
36
+ * @param options - The optional sanitization options.
37
+ *
38
+ * @returns The sanitized string.
39
+ */
40
+ sanitize(dirty: string, options?: ISanitizerOptions): string;
41
+ private _options;
42
+ }
43
+ export declare const defaultSanitizer: ISanitizer;
44
+ //# sourceMappingURL=sanitizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":"AA4ZA,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7C;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;CAC1D;AACD,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,MAAM,CAAC;CAClE;AAED;;GAEG;AACH,qBAAa,SAAU,YAAW,UAAU;IAC1C;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM;IAI5D,OAAO,CAAC,QAAQ,CAmed;CACH;AACD,eAAO,MAAM,gBAAgB,EAAE,UAA4B,CAAC"}